# HG changeset patch # User Paper # Date 1767597346 18000 # Node ID 20d02a178406e4cd4a960f0567a5ca588b34f844 # Parent e9bb126753e71abec0bc0947f397664a48f236e3 *: check in everything else yay diff -r e9bb126753e7 -r 20d02a178406 .hgignore --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.hgignore Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,4 @@ +# This is to keep build files from cluttering hg +^build$ +^build64$ +^build32$ \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 CMakeLists.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/CMakeLists.txt Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.10) + +set(CMAKE_CXX_STANDARD 17) + +project(foo_out_sdl) + +# add foosdk +add_subdirectory(foosdk) + +# force shared library +add_library(foo_out_sdl SHARED foo_out_sdl.cc) + +target_include_directories(foo_out_sdl PRIVATE ".") +target_link_libraries(foo_out_sdl PUBLIC foosdk) diff -r e9bb126753e7 -r 20d02a178406 README --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/README Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,13 @@ +This is a plugin for foobar2000 that uses SDL for output instead of +DirectSound/WASAPI/etc. + +The primary motivation here is not to have SDL as a backend on Windows, +but on Linux/wine. It effectively means we bypass the directsound +emulation. Of course we're still going through a compatibility layer, +so the real-world benefits may not be as good as it seems. Oh well. +DirectSound sucks anyway. + +You can use this today as a wrapper on wine by compiling the tiny +wrapper .c file. + + -- paper diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,91 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * Main include header for the SDL library, version 3.4.0 + * + * It is almost always best to include just this one header instead of + * picking out individual headers included here. There are exceptions to + * this rule--SDL_main.h is special and not included here--but usually + * letting SDL.h include the kitchen sink for you is the correct approach. + */ + +#ifndef SDL_h_ +#define SDL_h_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif /* SDL_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_assert.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_assert.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,695 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * # CategoryAssert + * + * A helpful assertion macro! + * + * SDL assertions operate like your usual `assert` macro, but with some added + * features: + * + * - It uses a trick with the `sizeof` operator, so disabled assertions + * vaporize out of the compiled code, but variables only referenced in the + * assertion won't trigger compiler warnings about being unused. + * - It is safe to use with a dangling-else: `if (x) SDL_assert(y); else + * do_something();` + * - It works the same everywhere, instead of counting on various platforms' + * compiler and C runtime to behave. + * - It provides multiple levels of assertion (SDL_assert, SDL_assert_release, + * SDL_assert_paranoid) instead of a single all-or-nothing option. + * - It offers a variety of responses when an assertion fails (retry, trigger + * the debugger, abort the program, ignore the failure once, ignore it for + * the rest of the program's run). + * - It tries to show the user a dialog by default, if possible, but the app + * can provide a callback to handle assertion failures however they like. + * - It lets failed assertions be retried. Perhaps you had a network failure + * and just want to retry the test after plugging your network cable back + * in? You can. + * - It lets the user ignore an assertion failure, if there's a harmless + * problem that one can continue past. + * - It lets the user mark an assertion as ignored for the rest of the + * program's run; if there's a harmless problem that keeps popping up. + * - It provides statistics and data on all failed assertions to the app. + * - It allows the default assertion handler to be controlled with environment + * variables, in case an automated script needs to control it. + * - It can be used as an aid to Clang's static analysis; it will treat SDL + * assertions as universally true (under the assumption that you are serious + * about the asserted claims and that your debug builds will detect when + * these claims were wrong). This can help the analyzer avoid false + * positives. + * + * To use it: compile a debug build and just sprinkle around tests to check + * your code! + */ + +#ifndef SDL_assert_h_ +#define SDL_assert_h_ + +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef SDL_WIKI_DOCUMENTATION_SECTION + +/** + * The level of assertion aggressiveness. + * + * This value changes depending on compiler options and other preprocessor + * defines. + * + * It is currently one of the following values, but future SDL releases might + * add more: + * + * - 0: All SDL assertion macros are disabled. + * - 1: Release settings: SDL_assert disabled, SDL_assert_release enabled. + * - 2: Debug settings: SDL_assert and SDL_assert_release enabled. + * - 3: Paranoid settings: All SDL assertion macros enabled, including + * SDL_assert_paranoid. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_ASSERT_LEVEL SomeNumberBasedOnVariousFactors + +#elif !defined(SDL_ASSERT_LEVEL) +#ifdef SDL_DEFAULT_ASSERT_LEVEL +#define SDL_ASSERT_LEVEL SDL_DEFAULT_ASSERT_LEVEL +#elif defined(_DEBUG) || defined(DEBUG) || \ + (defined(__GNUC__) && !defined(__OPTIMIZE__)) +#define SDL_ASSERT_LEVEL 2 +#else +#define SDL_ASSERT_LEVEL 1 +#endif +#endif + +#ifdef SDL_WIKI_DOCUMENTATION_SECTION + +/** + * Attempt to tell an attached debugger to pause. + * + * This allows an app to programmatically halt ("break") the debugger as if it + * had hit a breakpoint, allowing the developer to examine program state, etc. + * + * This is a macro--not a function--so that the debugger breaks on the source + * code line that used SDL_TriggerBreakpoint and not in some random guts of + * SDL. SDL_assert uses this macro for the same reason. + * + * If the program is not running under a debugger, SDL_TriggerBreakpoint will + * likely terminate the app, possibly without warning. If the current platform + * isn't supported, this macro is left undefined. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_TriggerBreakpoint() TriggerABreakpointInAPlatformSpecificManner + +#elif defined(__MINGW32__) || (defined(_MSC_VER) && _MSC_VER >= 1310) + /* Don't include intrin.h here because it contains C++ code */ + extern void __cdecl __debugbreak(void); + #define SDL_TriggerBreakpoint() __debugbreak() +#elif defined(_MSC_VER) && defined(_M_IX86) + #define SDL_TriggerBreakpoint() { _asm { int 0x03 } } +#elif SDL_HAS_BUILTIN(__builtin_debugtrap) + #define SDL_TriggerBreakpoint() __builtin_debugtrap() +#elif SDL_HAS_BUILTIN(__builtin_trap) + #define SDL_TriggerBreakpoint() __builtin_trap() +#elif (defined(__GNUC__) || defined(__clang__) || defined(__TINYC__)) && (defined(__i386__) || defined(__x86_64__)) + #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "int $3\n\t" ) +#elif (defined(__GNUC__) || defined(__clang__)) && defined(__riscv) + #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "ebreak\n\t" ) +#elif ( defined(SDL_PLATFORM_APPLE) && (defined(__arm64__) || defined(__aarch64__)) ) /* this might work on other ARM targets, but this is a known quantity... */ + #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "brk #22\n\t" ) +#elif defined(SDL_PLATFORM_APPLE) && defined(__arm__) + #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "bkpt #22\n\t" ) +#elif defined(_WIN32) && ((defined(__GNUC__) || defined(__clang__)) && (defined(__arm64__) || defined(__aarch64__)) ) + #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "brk #0xF000\n\t" ) +#elif defined(__GNUC__) || defined(__clang__) + #define SDL_TriggerBreakpoint() __builtin_trap() /* older gcc may not support SDL_HAS_BUILTIN(__builtin_trap) above */ +#elif defined(__386__) && defined(__WATCOMC__) + #define SDL_TriggerBreakpoint() { _asm { int 0x03 } } +#elif defined(HAVE_SIGNAL_H) && !defined(__WATCOMC__) + #include + #define SDL_TriggerBreakpoint() raise(SIGTRAP) +#else + /* SDL_TriggerBreakpoint is intentionally left undefined on unknown platforms. */ +#endif + +#ifdef SDL_WIKI_DOCUMENTATION_SECTION + +/** + * A macro that reports the current function being compiled. + * + * If SDL can't figure how the compiler reports this, it will use "???". + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_FUNCTION __FUNCTION__ + +#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 supports __func__ as a standard. */ +# define SDL_FUNCTION __func__ +#elif ((defined(__GNUC__) && (__GNUC__ >= 2)) || defined(_MSC_VER) || defined (__WATCOMC__)) +# define SDL_FUNCTION __FUNCTION__ +#else +# define SDL_FUNCTION "???" +#endif + +#ifdef SDL_WIKI_DOCUMENTATION_SECTION + +/** + * A macro that reports the current file being compiled. + * + * This macro is only defined if it isn't already defined, so to override it + * (perhaps with something that doesn't provide path information at all, so + * build machine information doesn't leak into public binaries), apps can + * define this macro before including SDL.h or SDL_assert.h. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_FILE __FILE_NAME__ + +#elif !defined(SDL_FILE) +#ifdef __FILE_NAME__ +#define SDL_FILE __FILE_NAME__ +#else +#define SDL_FILE __FILE__ +#endif +#endif + +#ifdef SDL_WIKI_DOCUMENTATION_SECTION + +/** + * A macro that reports the current file being compiled, for use in + * assertions. + * + * This macro is only defined if it isn't already defined, so to override it + * (perhaps with something that doesn't provide path information at all, so + * build machine information doesn't leak into public binaries), apps can + * define this macro before including SDL_assert.h. For example, defining this + * to `""` will make sure no source path information is included in asserts. + * + * \since This macro is available since SDL 3.4.0. + */ +#define SDL_ASSERT_FILE SDL_FILE + +#elif !defined(SDL_ASSERT_FILE) +#define SDL_ASSERT_FILE SDL_FILE +#endif + + +/** + * A macro that reports the current line number of the file being compiled. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_LINE __LINE__ + +/* +sizeof (x) makes the compiler still parse the expression even without +assertions enabled, so the code is always checked at compile time, but +doesn't actually generate code for it, so there are no side effects or +expensive checks at run time, just the constant size of what x WOULD be, +which presumably gets optimized out as unused. +This also solves the problem of... + + int somevalue = blah(); + SDL_assert(somevalue == 1); + +...which would cause compiles to complain that somevalue is unused if we +disable assertions. +*/ + +#ifdef SDL_WIKI_DOCUMENTATION_SECTION + +/** + * A macro for wrapping code in `do {} while (0);` without compiler warnings. + * + * Visual Studio with really aggressive warnings enabled needs this to avoid + * compiler complaints. + * + * the `do {} while (0);` trick is useful for wrapping code in a macro that + * may or may not be a single statement, to avoid various C language + * accidents. + * + * To use: + * + * ```c + * do { SomethingOnce(); } while (SDL_NULL_WHILE_LOOP_CONDITION (0)); + * ``` + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_NULL_WHILE_LOOP_CONDITION (0) + +#elif defined(_MSC_VER) /* Avoid /W4 warnings. */ +/* "while (0,0)" fools Microsoft's compiler's /W4 warning level into thinking + this condition isn't constant. And looks like an owl's face! */ +#define SDL_NULL_WHILE_LOOP_CONDITION (0,0) +#else +#define SDL_NULL_WHILE_LOOP_CONDITION (0) +#endif + +/** + * The macro used when an assertion is disabled. + * + * This isn't for direct use by apps, but this is the code that is inserted + * when an SDL_assert is disabled (perhaps in a release build). + * + * The code does nothing, but wraps `condition` in a sizeof operator, which + * generates no code and has no side effects, but avoid compiler warnings + * about unused variables. + * + * \param condition the condition to assert (but not actually run here). + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_disabled_assert(condition) \ + do { (void) sizeof ((condition)); } while (SDL_NULL_WHILE_LOOP_CONDITION) + +/** + * Possible outcomes from a triggered assertion. + * + * When an enabled assertion triggers, it may call the assertion handler + * (possibly one provided by the app via SDL_SetAssertionHandler), which will + * return one of these values, possibly after asking the user. + * + * Then SDL will respond based on this outcome (loop around to retry the + * condition, try to break in a debugger, kill the program, or ignore the + * problem). + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_AssertState +{ + SDL_ASSERTION_RETRY, /**< Retry the assert immediately. */ + SDL_ASSERTION_BREAK, /**< Make the debugger trigger a breakpoint. */ + SDL_ASSERTION_ABORT, /**< Terminate the program. */ + SDL_ASSERTION_IGNORE, /**< Ignore the assert. */ + SDL_ASSERTION_ALWAYS_IGNORE /**< Ignore the assert from now on. */ +} SDL_AssertState; + +/** + * Information about an assertion failure. + * + * This structure is filled in with information about a triggered assertion, + * used by the assertion handler, then added to the assertion report. This is + * returned as a linked list from SDL_GetAssertionReport(). + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_AssertData +{ + bool always_ignore; /**< true if app should always continue when assertion is triggered. */ + unsigned int trigger_count; /**< Number of times this assertion has been triggered. */ + const char *condition; /**< A string of this assert's test code. */ + const char *filename; /**< The source file where this assert lives. */ + int linenum; /**< The line in `filename` where this assert lives. */ + const char *function; /**< The name of the function where this assert lives. */ + const struct SDL_AssertData *next; /**< next item in the linked list. */ +} SDL_AssertData; + +/** + * Never call this directly. + * + * Use the SDL_assert macros instead. + * + * \param data assert data structure. + * \param func function name. + * \param file file name. + * \param line line number. + * \returns assert state. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *data, + const char *func, + const char *file, int line) SDL_ANALYZER_NORETURN; + + +#ifdef SDL_WIKI_DOCUMENTATION_SECTION + +/** + * The macro used when an assertion triggers a breakpoint. + * + * This isn't for direct use by apps; use SDL_assert or SDL_TriggerBreakpoint + * instead. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_AssertBreakpoint() SDL_TriggerBreakpoint() + +#elif !defined(SDL_AssertBreakpoint) +# if defined(ANDROID) && defined(assert) + /* Define this as empty in case assert() is defined as SDL_assert */ +# define SDL_AssertBreakpoint() +# else +# define SDL_AssertBreakpoint() SDL_TriggerBreakpoint() +# endif +#endif /* !SDL_AssertBreakpoint */ + +/** + * The macro used when an assertion is enabled. + * + * This isn't for direct use by apps, but this is the code that is inserted + * when an SDL_assert is enabled. + * + * The `do {} while(0)` avoids dangling else problems: + * + * ```c + * if (x) SDL_assert(y); else blah(); + * ``` + * + * ... without the do/while, the "else" could attach to this macro's "if". We + * try to handle just the minimum we need here in a macro...the loop, the + * static vars, and break points. The heavy lifting is handled in + * SDL_ReportAssertion(). + * + * \param condition the condition to assert. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_enabled_assert(condition) \ + do { \ + while ( !(condition) ) { \ + static struct SDL_AssertData sdl_assert_data = { false, 0, #condition, NULL, 0, NULL, NULL }; \ + const SDL_AssertState sdl_assert_state = SDL_ReportAssertion(&sdl_assert_data, SDL_FUNCTION, SDL_ASSERT_FILE, SDL_LINE); \ + if (sdl_assert_state == SDL_ASSERTION_RETRY) { \ + continue; /* go again. */ \ + } else if (sdl_assert_state == SDL_ASSERTION_BREAK) { \ + SDL_AssertBreakpoint(); \ + } \ + break; /* not retrying. */ \ + } \ + } while (SDL_NULL_WHILE_LOOP_CONDITION) + +#ifdef SDL_WIKI_DOCUMENTATION_SECTION + +/** + * An assertion test that is normally performed only in debug builds. + * + * This macro is enabled when the SDL_ASSERT_LEVEL is >= 2, otherwise it is + * disabled. This is meant to only do these tests in debug builds, so they can + * tend to be more expensive, and they are meant to bring everything to a halt + * when they fail, with the programmer there to assess the problem. + * + * In short: you can sprinkle these around liberally and assume they will + * evaporate out of the build when building for end-users. + * + * When assertions are disabled, this wraps `condition` in a `sizeof` + * operator, which means any function calls and side effects will not run, but + * the compiler will not complain about any otherwise-unused variables that + * are only referenced in the assertion. + * + * One can set the environment variable "SDL_ASSERT" to one of several strings + * ("abort", "break", "retry", "ignore", "always_ignore") to force a default + * behavior, which may be desirable for automation purposes. If your platform + * requires GUI interfaces to happen on the main thread but you're debugging + * an assertion in a background thread, it might be desirable to set this to + * "break" so that your debugger takes control as soon as assert is triggered, + * instead of risking a bad UI interaction (deadlock, etc) in the application. + * + * \param condition boolean value to test. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_assert(condition) if (assertion_enabled && (condition)) { trigger_assertion; } + +/** + * An assertion test that is performed even in release builds. + * + * This macro is enabled when the SDL_ASSERT_LEVEL is >= 1, otherwise it is + * disabled. This is meant to be for tests that are cheap to make and + * extremely unlikely to fail; generally it is frowned upon to have an + * assertion failure in a release build, so these assertions generally need to + * be of more than life-and-death importance if there's a chance they might + * trigger. You should almost always consider handling these cases more + * gracefully than an assert allows. + * + * When assertions are disabled, this wraps `condition` in a `sizeof` + * operator, which means any function calls and side effects will not run, but + * the compiler will not complain about any otherwise-unused variables that + * are only referenced in the assertion. + * + * One can set the environment variable "SDL_ASSERT" to one of several strings + * ("abort", "break", "retry", "ignore", "always_ignore") to force a default + * behavior, which may be desirable for automation purposes. If your platform + * requires GUI interfaces to happen on the main thread but you're debugging + * an assertion in a background thread, it might be desirable to set this to + * "break" so that your debugger takes control as soon as assert is triggered, + * instead of risking a bad UI interaction (deadlock, etc) in the application. + * * + * + * \param condition boolean value to test. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_assert_release(condition) SDL_disabled_assert(condition) + +/** + * An assertion test that is performed only when built with paranoid settings. + * + * This macro is enabled when the SDL_ASSERT_LEVEL is >= 3, otherwise it is + * disabled. This is a higher level than both release and debug, so these + * tests are meant to be expensive and only run when specifically looking for + * extremely unexpected failure cases in a special build. + * + * When assertions are disabled, this wraps `condition` in a `sizeof` + * operator, which means any function calls and side effects will not run, but + * the compiler will not complain about any otherwise-unused variables that + * are only referenced in the assertion. + * + * One can set the environment variable "SDL_ASSERT" to one of several strings + * ("abort", "break", "retry", "ignore", "always_ignore") to force a default + * behavior, which may be desirable for automation purposes. If your platform + * requires GUI interfaces to happen on the main thread but you're debugging + * an assertion in a background thread, it might be desirable to set this to + * "break" so that your debugger takes control as soon as assert is triggered, + * instead of risking a bad UI interaction (deadlock, etc) in the application. + * + * \param condition boolean value to test. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_assert_paranoid(condition) SDL_disabled_assert(condition) + +/* Enable various levels of assertions. */ +#elif SDL_ASSERT_LEVEL == 0 /* assertions disabled */ +# define SDL_assert(condition) SDL_disabled_assert(condition) +# define SDL_assert_release(condition) SDL_disabled_assert(condition) +# define SDL_assert_paranoid(condition) SDL_disabled_assert(condition) +#elif SDL_ASSERT_LEVEL == 1 /* release settings. */ +# define SDL_assert(condition) SDL_disabled_assert(condition) +# define SDL_assert_release(condition) SDL_enabled_assert(condition) +# define SDL_assert_paranoid(condition) SDL_disabled_assert(condition) +#elif SDL_ASSERT_LEVEL == 2 /* debug settings. */ +# define SDL_assert(condition) SDL_enabled_assert(condition) +# define SDL_assert_release(condition) SDL_enabled_assert(condition) +# define SDL_assert_paranoid(condition) SDL_disabled_assert(condition) +#elif SDL_ASSERT_LEVEL == 3 /* paranoid settings. */ +# define SDL_assert(condition) SDL_enabled_assert(condition) +# define SDL_assert_release(condition) SDL_enabled_assert(condition) +# define SDL_assert_paranoid(condition) SDL_enabled_assert(condition) +#else +# error Unknown assertion level. +#endif + +/** + * An assertion test that is always performed. + * + * This macro is always enabled no matter what SDL_ASSERT_LEVEL is set to. You + * almost never want to use this, as it could trigger on an end-user's system, + * crashing your program. + * + * One can set the environment variable "SDL_ASSERT" to one of several strings + * ("abort", "break", "retry", "ignore", "always_ignore") to force a default + * behavior, which may be desirable for automation purposes. If your platform + * requires GUI interfaces to happen on the main thread but you're debugging + * an assertion in a background thread, it might be desirable to set this to + * "break" so that your debugger takes control as soon as assert is triggered, + * instead of risking a bad UI interaction (deadlock, etc) in the application. + * + * \param condition boolean value to test. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_assert_always(condition) SDL_enabled_assert(condition) + + +/** + * A callback that fires when an SDL assertion fails. + * + * \param data a pointer to the SDL_AssertData structure corresponding to the + * current assertion. + * \param userdata what was passed as `userdata` to SDL_SetAssertionHandler(). + * \returns an SDL_AssertState value indicating how to handle the failure. + * + * \threadsafety This callback may be called from any thread that triggers an + * assert at any time. + * + * \since This datatype is available since SDL 3.2.0. + */ +typedef SDL_AssertState (SDLCALL *SDL_AssertionHandler)( + const SDL_AssertData *data, void *userdata); + +/** + * Set an application-defined assertion handler. + * + * This function allows an application to show its own assertion UI and/or + * force the response to an assertion failure. If the application doesn't + * provide this, SDL will try to do the right thing, popping up a + * system-specific GUI dialog, and probably minimizing any fullscreen windows. + * + * This callback may fire from any thread, but it runs wrapped in a mutex, so + * it will only fire from one thread at a time. + * + * This callback is NOT reset to SDL's internal handler upon SDL_Quit()! + * + * \param handler the SDL_AssertionHandler function to call when an assertion + * fails or NULL for the default handler. + * \param userdata a pointer that is passed to `handler`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetAssertionHandler + */ +extern SDL_DECLSPEC void SDLCALL SDL_SetAssertionHandler( + SDL_AssertionHandler handler, + void *userdata); + +/** + * Get the default assertion handler. + * + * This returns the function pointer that is called by default when an + * assertion is triggered. This is an internal function provided by SDL, that + * is used for assertions when SDL_SetAssertionHandler() hasn't been used to + * provide a different function. + * + * \returns the default SDL_AssertionHandler that is called when an assert + * triggers. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetAssertionHandler + */ +extern SDL_DECLSPEC SDL_AssertionHandler SDLCALL SDL_GetDefaultAssertionHandler(void); + +/** + * Get the current assertion handler. + * + * This returns the function pointer that is called when an assertion is + * triggered. This is either the value last passed to + * SDL_SetAssertionHandler(), or if no application-specified function is set, + * is equivalent to calling SDL_GetDefaultAssertionHandler(). + * + * The parameter `puserdata` is a pointer to a void*, which will store the + * "userdata" pointer that was passed to SDL_SetAssertionHandler(). This value + * will always be NULL for the default handler. If you don't care about this + * data, it is safe to pass a NULL pointer to this function to ignore it. + * + * \param puserdata pointer which is filled with the "userdata" pointer that + * was passed to SDL_SetAssertionHandler(). + * \returns the SDL_AssertionHandler that is called when an assert triggers. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetAssertionHandler + */ +extern SDL_DECLSPEC SDL_AssertionHandler SDLCALL SDL_GetAssertionHandler(void **puserdata); + +/** + * Get a list of all assertion failures. + * + * This function gets all assertions triggered since the last call to + * SDL_ResetAssertionReport(), or the start of the program. + * + * The proper way to examine this data looks something like this: + * + * ```c + * const SDL_AssertData *item = SDL_GetAssertionReport(); + * while (item) { + * printf("'%s', %s (%s:%d), triggered %u times, always ignore: %s.\\n", + * item->condition, item->function, item->filename, + * item->linenum, item->trigger_count, + * item->always_ignore ? "yes" : "no"); + * item = item->next; + * } + * ``` + * + * \returns a list of all failed assertions or NULL if the list is empty. This + * memory should not be modified or freed by the application. This + * pointer remains valid until the next call to SDL_Quit() or + * SDL_ResetAssertionReport(). + * + * \threadsafety This function is not thread safe. Other threads calling + * SDL_ResetAssertionReport() simultaneously, may render the + * returned pointer invalid. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_ResetAssertionReport + */ +extern SDL_DECLSPEC const SDL_AssertData * SDLCALL SDL_GetAssertionReport(void); + +/** + * Clear the list of all assertion failures. + * + * This function will clear the list of all assertions triggered up to that + * point. Immediately following this call, SDL_GetAssertionReport will return + * no items. In addition, any previously-triggered assertions will be reset to + * a trigger_count of zero, and their always_ignore state will be false. + * + * \threadsafety This function is not thread safe. Other threads triggering an + * assertion, or simultaneously calling this function may cause + * memory leaks or crashes. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetAssertionReport + */ +extern SDL_DECLSPEC void SDLCALL SDL_ResetAssertionReport(void); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_assert_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_asyncio.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_asyncio.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,546 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* WIKI CATEGORY: AsyncIO */ + +/** + * # CategoryAsyncIO + * + * SDL offers a way to perform I/O asynchronously. This allows an app to read + * or write files without waiting for data to actually transfer; the functions + * that request I/O never block while the request is fulfilled. + * + * Instead, the data moves in the background and the app can check for results + * at their leisure. + * + * This is more complicated than just reading and writing files in a + * synchronous way, but it can allow for more efficiency, and never having + * framerate drops as the hard drive catches up, etc. + * + * The general usage pattern for async I/O is: + * + * - Create one or more SDL_AsyncIOQueue objects. + * - Open files with SDL_AsyncIOFromFile. + * - Start I/O tasks to the files with SDL_ReadAsyncIO or SDL_WriteAsyncIO, + * putting those tasks into one of the queues. + * - Later on, use SDL_GetAsyncIOResult on a queue to see if any task is + * finished without blocking. Tasks might finish in any order with success + * or failure. + * - When all your tasks are done, close the file with SDL_CloseAsyncIO. This + * also generates a task, since it might flush data to disk! + * + * This all works, without blocking, in a single thread, but one can also wait + * on a queue in a background thread, sleeping until new results have arrived: + * + * - Call SDL_WaitAsyncIOResult from one or more threads to efficiently block + * until new tasks complete. + * - When shutting down, call SDL_SignalAsyncIOQueue to unblock any sleeping + * threads despite there being no new tasks completed. + * + * And, of course, to match the synchronous SDL_LoadFile, we offer + * SDL_LoadFileAsync as a convenience function. This will handle allocating a + * buffer, slurping in the file data, and null-terminating it; you still check + * for results later. + * + * Behind the scenes, SDL will use newer, efficient APIs on platforms that + * support them: Linux's io_uring and Windows 11's IoRing, for example. If + * those technologies aren't available, SDL will offload the work to a thread + * pool that will manage otherwise-synchronous loads without blocking the app. + * + * ## Best Practices + * + * Simple non-blocking I/O--for an app that just wants to pick up data + * whenever it's ready without losing framerate waiting on disks to spin--can + * use whatever pattern works well for the program. In this case, simply call + * SDL_ReadAsyncIO, or maybe SDL_LoadFileAsync, as needed. Once a frame, call + * SDL_GetAsyncIOResult to check for any completed tasks and deal with the + * data as it arrives. + * + * If two separate pieces of the same program need their own I/O, it is legal + * for each to create their own queue. This will prevent either piece from + * accidentally consuming the other's completed tasks. Each queue does require + * some amount of resources, but it is not an overwhelming cost. Do not make a + * queue for each task, however. It is better to put many tasks into a single + * queue. They will be reported in order of completion, not in the order they + * were submitted, so it doesn't generally matter what order tasks are + * started. + * + * One async I/O queue can be shared by multiple threads, or one thread can + * have more than one queue, but the most efficient way--if ruthless + * efficiency is the goal--is to have one queue per thread, with multiple + * threads working in parallel, and attempt to keep each queue loaded with + * tasks that are both started by and consumed by the same thread. On modern + * platforms that can use newer interfaces, this can keep data flowing as + * efficiently as possible all the way from storage hardware to the app, with + * no contention between threads for access to the same queue. + * + * Written data is not guaranteed to make it to physical media by the time a + * closing task is completed, unless SDL_CloseAsyncIO is called with its + * `flush` parameter set to true, which is to say that a successful result + * here can still result in lost data during an unfortunately-timed power + * outage if not flushed. However, flushing will take longer and may be + * unnecessary, depending on the app's needs. + */ + +#ifndef SDL_asyncio_h_ +#define SDL_asyncio_h_ + +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * The asynchronous I/O operation structure. + * + * This operates as an opaque handle. One can then request read or write + * operations on it. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_AsyncIOFromFile + */ +typedef struct SDL_AsyncIO SDL_AsyncIO; + +/** + * Types of asynchronous I/O tasks. + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_AsyncIOTaskType +{ + SDL_ASYNCIO_TASK_READ, /**< A read operation. */ + SDL_ASYNCIO_TASK_WRITE, /**< A write operation. */ + SDL_ASYNCIO_TASK_CLOSE /**< A close operation. */ +} SDL_AsyncIOTaskType; + +/** + * Possible outcomes of an asynchronous I/O task. + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_AsyncIOResult +{ + SDL_ASYNCIO_COMPLETE, /**< request was completed without error */ + SDL_ASYNCIO_FAILURE, /**< request failed for some reason; check SDL_GetError()! */ + SDL_ASYNCIO_CANCELED /**< request was canceled before completing. */ +} SDL_AsyncIOResult; + +/** + * Information about a completed asynchronous I/O request. + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_AsyncIOOutcome +{ + SDL_AsyncIO *asyncio; /**< what generated this task. This pointer will be invalid if it was closed! */ + SDL_AsyncIOTaskType type; /**< What sort of task was this? Read, write, etc? */ + SDL_AsyncIOResult result; /**< the result of the work (success, failure, cancellation). */ + void *buffer; /**< buffer where data was read/written. */ + Uint64 offset; /**< offset in the SDL_AsyncIO where data was read/written. */ + Uint64 bytes_requested; /**< number of bytes the task was to read/write. */ + Uint64 bytes_transferred; /**< actual number of bytes that were read/written. */ + void *userdata; /**< pointer provided by the app when starting the task */ +} SDL_AsyncIOOutcome; + +/** + * A queue of completed asynchronous I/O tasks. + * + * When starting an asynchronous operation, you specify a queue for the new + * task. A queue can be asked later if any tasks in it have completed, + * allowing an app to manage multiple pending tasks in one place, in whatever + * order they complete. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_CreateAsyncIOQueue + * \sa SDL_ReadAsyncIO + * \sa SDL_WriteAsyncIO + * \sa SDL_GetAsyncIOResult + * \sa SDL_WaitAsyncIOResult + */ +typedef struct SDL_AsyncIOQueue SDL_AsyncIOQueue; + +/** + * Use this function to create a new SDL_AsyncIO object for reading from + * and/or writing to a named file. + * + * The `mode` string understands the following values: + * + * - "r": Open a file for reading only. It must exist. + * - "w": Open a file for writing only. It will create missing files or + * truncate existing ones. + * - "r+": Open a file for update both reading and writing. The file must + * exist. + * - "w+": Create an empty file for both reading and writing. If a file with + * the same name already exists its content is erased and the file is + * treated as a new empty file. + * + * There is no "b" mode, as there is only "binary" style I/O, and no "a" mode + * for appending, since you specify the position when starting a task. + * + * This function supports Unicode filenames, but they must be encoded in UTF-8 + * format, regardless of the underlying operating system. + * + * This call is _not_ asynchronous; it will open the file before returning, + * under the assumption that doing so is generally a fast operation. Future + * reads and writes to the opened file will be async, however. + * + * \param file a UTF-8 string representing the filename to open. + * \param mode an ASCII string representing the mode to be used for opening + * the file. + * \returns a pointer to the SDL_AsyncIO structure that is created or NULL on + * failure; call SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CloseAsyncIO + * \sa SDL_ReadAsyncIO + * \sa SDL_WriteAsyncIO + */ +extern SDL_DECLSPEC SDL_AsyncIO * SDLCALL SDL_AsyncIOFromFile(const char *file, const char *mode); + +/** + * Use this function to get the size of the data stream in an SDL_AsyncIO. + * + * This call is _not_ asynchronous; it assumes that obtaining this info is a + * non-blocking operation in most reasonable cases. + * + * \param asyncio the SDL_AsyncIO to get the size of the data stream from. + * \returns the size of the data stream in the SDL_IOStream on success or a + * negative error code on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC Sint64 SDLCALL SDL_GetAsyncIOSize(SDL_AsyncIO *asyncio); + +/** + * Start an async read. + * + * This function reads up to `size` bytes from `offset` position in the data + * source to the area pointed at by `ptr`. This function may read less bytes + * than requested. + * + * This function returns as quickly as possible; it does not wait for the read + * to complete. On a successful return, this work will continue in the + * background. If the work begins, even failure is asynchronous: a failing + * return value from this function only means the work couldn't start at all. + * + * `ptr` must remain available until the work is done, and may be accessed by + * the system at any time until then. Do not allocate it on the stack, as this + * might take longer than the life of the calling function to complete! + * + * An SDL_AsyncIOQueue must be specified. The newly-created task will be added + * to it when it completes its work. + * + * \param asyncio a pointer to an SDL_AsyncIO structure. + * \param ptr a pointer to a buffer to read data into. + * \param offset the position to start reading in the data source. + * \param size the number of bytes to read from the data source. + * \param queue a queue to add the new SDL_AsyncIO to. + * \param userdata an app-defined pointer that will be provided with the task + * results. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_WriteAsyncIO + * \sa SDL_CreateAsyncIOQueue + */ +extern SDL_DECLSPEC bool SDLCALL SDL_ReadAsyncIO(SDL_AsyncIO *asyncio, void *ptr, Uint64 offset, Uint64 size, SDL_AsyncIOQueue *queue, void *userdata); + +/** + * Start an async write. + * + * This function writes `size` bytes from `offset` position in the data source + * to the area pointed at by `ptr`. + * + * This function returns as quickly as possible; it does not wait for the + * write to complete. On a successful return, this work will continue in the + * background. If the work begins, even failure is asynchronous: a failing + * return value from this function only means the work couldn't start at all. + * + * `ptr` must remain available until the work is done, and may be accessed by + * the system at any time until then. Do not allocate it on the stack, as this + * might take longer than the life of the calling function to complete! + * + * An SDL_AsyncIOQueue must be specified. The newly-created task will be added + * to it when it completes its work. + * + * \param asyncio a pointer to an SDL_AsyncIO structure. + * \param ptr a pointer to a buffer to write data from. + * \param offset the position to start writing to the data source. + * \param size the number of bytes to write to the data source. + * \param queue a queue to add the new SDL_AsyncIO to. + * \param userdata an app-defined pointer that will be provided with the task + * results. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_ReadAsyncIO + * \sa SDL_CreateAsyncIOQueue + */ +extern SDL_DECLSPEC bool SDLCALL SDL_WriteAsyncIO(SDL_AsyncIO *asyncio, void *ptr, Uint64 offset, Uint64 size, SDL_AsyncIOQueue *queue, void *userdata); + +/** + * Close and free any allocated resources for an async I/O object. + * + * Closing a file is _also_ an asynchronous task! If a write failure were to + * happen during the closing process, for example, the task results will + * report it as usual. + * + * Closing a file that has been written to does not guarantee the data has + * made it to physical media; it may remain in the operating system's file + * cache, for later writing to disk. This means that a successfully-closed + * file can be lost if the system crashes or loses power in this small window. + * To prevent this, call this function with the `flush` parameter set to true. + * This will make the operation take longer, and perhaps increase system load + * in general, but a successful result guarantees that the data has made it to + * physical storage. Don't use this for temporary files, caches, and + * unimportant data, and definitely use it for crucial irreplaceable files, + * like game saves. + * + * This function guarantees that the close will happen after any other pending + * tasks to `asyncio`, so it's safe to open a file, start several operations, + * close the file immediately, then check for all results later. This function + * will not block until the tasks have completed. + * + * Once this function returns true, `asyncio` is no longer valid, regardless + * of any future outcomes. Any completed tasks might still contain this + * pointer in their SDL_AsyncIOOutcome data, in case the app was using this + * value to track information, but it should not be used again. + * + * If this function returns false, the close wasn't started at all, and it's + * safe to attempt to close again later. + * + * An SDL_AsyncIOQueue must be specified. The newly-created task will be added + * to it when it completes its work. + * + * \param asyncio a pointer to an SDL_AsyncIO structure to close. + * \param flush true if data should sync to disk before the task completes. + * \param queue a queue to add the new SDL_AsyncIO to. + * \param userdata an app-defined pointer that will be provided with the task + * results. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread, but two + * threads should not attempt to close the same object. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_CloseAsyncIO(SDL_AsyncIO *asyncio, bool flush, SDL_AsyncIOQueue *queue, void *userdata); + +/** + * Create a task queue for tracking multiple I/O operations. + * + * Async I/O operations are assigned to a queue when started. The queue can be + * checked for completed tasks thereafter. + * + * \returns a new task queue object or NULL if there was an error; call + * SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_DestroyAsyncIOQueue + * \sa SDL_GetAsyncIOResult + * \sa SDL_WaitAsyncIOResult + */ +extern SDL_DECLSPEC SDL_AsyncIOQueue * SDLCALL SDL_CreateAsyncIOQueue(void); + +/** + * Destroy a previously-created async I/O task queue. + * + * If there are still tasks pending for this queue, this call will block until + * those tasks are finished. All those tasks will be deallocated. Their + * results will be lost to the app. + * + * Any pending reads from SDL_LoadFileAsync() that are still in this queue + * will have their buffers deallocated by this function, to prevent a memory + * leak. + * + * Once this function is called, the queue is no longer valid and should not + * be used, including by other threads that might access it while destruction + * is blocking on pending tasks. + * + * Do not destroy a queue that still has threads waiting on it through + * SDL_WaitAsyncIOResult(). You can call SDL_SignalAsyncIOQueue() first to + * unblock those threads, and take measures (such as SDL_WaitThread()) to make + * sure they have finished their wait and won't wait on the queue again. + * + * \param queue the task queue to destroy. + * + * \threadsafety It is safe to call this function from any thread, so long as + * no other thread is waiting on the queue with + * SDL_WaitAsyncIOResult. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_DestroyAsyncIOQueue(SDL_AsyncIOQueue *queue); + +/** + * Query an async I/O task queue for completed tasks. + * + * If a task assigned to this queue has finished, this will return true and + * fill in `outcome` with the details of the task. If no task in the queue has + * finished, this function will return false. This function does not block. + * + * If a task has completed, this function will free its resources and the task + * pointer will no longer be valid. The task will be removed from the queue. + * + * It is safe for multiple threads to call this function on the same queue at + * once; a completed task will only go to one of the threads. + * + * \param queue the async I/O task queue to query. + * \param outcome details of a finished task will be written here. May not be + * NULL. + * \returns true if a task has completed, false otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_WaitAsyncIOResult + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetAsyncIOResult(SDL_AsyncIOQueue *queue, SDL_AsyncIOOutcome *outcome); + +/** + * Block until an async I/O task queue has a completed task. + * + * This function puts the calling thread to sleep until there a task assigned + * to the queue that has finished. + * + * If a task assigned to the queue has finished, this will return true and + * fill in `outcome` with the details of the task. If no task in the queue has + * finished, this function will return false. + * + * If a task has completed, this function will free its resources and the task + * pointer will no longer be valid. The task will be removed from the queue. + * + * It is safe for multiple threads to call this function on the same queue at + * once; a completed task will only go to one of the threads. + * + * Note that by the nature of various platforms, more than one waiting thread + * may wake to handle a single task, but only one will obtain it, so + * `timeoutMS` is a _maximum_ wait time, and this function may return false + * sooner. + * + * This function may return false if there was a system error, the OS + * inadvertently awoke multiple threads, or if SDL_SignalAsyncIOQueue() was + * called to wake up all waiting threads without a finished task. + * + * A timeout can be used to specify a maximum wait time, but rather than + * polling, it is possible to have a timeout of -1 to wait forever, and use + * SDL_SignalAsyncIOQueue() to wake up the waiting threads later. + * + * \param queue the async I/O task queue to wait on. + * \param outcome details of a finished task will be written here. May not be + * NULL. + * \param timeoutMS the maximum time to wait, in milliseconds, or -1 to wait + * indefinitely. + * \returns true if task has completed, false otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SignalAsyncIOQueue + */ +extern SDL_DECLSPEC bool SDLCALL SDL_WaitAsyncIOResult(SDL_AsyncIOQueue *queue, SDL_AsyncIOOutcome *outcome, Sint32 timeoutMS); + +/** + * Wake up any threads that are blocking in SDL_WaitAsyncIOResult(). + * + * This will unblock any threads that are sleeping in a call to + * SDL_WaitAsyncIOResult for the specified queue, and cause them to return + * from that function. + * + * This can be useful when destroying a queue to make sure nothing is touching + * it indefinitely. In this case, once this call completes, the caller should + * take measures to make sure any previously-blocked threads have returned + * from their wait and will not touch the queue again (perhaps by setting a + * flag to tell the threads to terminate and then using SDL_WaitThread() to + * make sure they've done so). + * + * \param queue the async I/O task queue to signal. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_WaitAsyncIOResult + */ +extern SDL_DECLSPEC void SDLCALL SDL_SignalAsyncIOQueue(SDL_AsyncIOQueue *queue); + +/** + * Load all the data from a file path, asynchronously. + * + * This function returns as quickly as possible; it does not wait for the read + * to complete. On a successful return, this work will continue in the + * background. If the work begins, even failure is asynchronous: a failing + * return value from this function only means the work couldn't start at all. + * + * The data is allocated with a zero byte at the end (null terminated) for + * convenience. This extra byte is not included in SDL_AsyncIOOutcome's + * bytes_transferred value. + * + * This function will allocate the buffer to contain the file. It must be + * deallocated by calling SDL_free() on SDL_AsyncIOOutcome's buffer field + * after completion. + * + * An SDL_AsyncIOQueue must be specified. The newly-created task will be added + * to it when it completes its work. + * + * \param file the path to read all available data from. + * \param queue a queue to add the new SDL_AsyncIO to. + * \param userdata an app-defined pointer that will be provided with the task + * results. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_LoadFile_IO + */ +extern SDL_DECLSPEC bool SDLCALL SDL_LoadFileAsync(const char *file, SDL_AsyncIOQueue *queue, void *userdata); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_asyncio_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_atomic.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_atomic.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,682 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * # CategoryAtomic + * + * Atomic operations. + * + * IMPORTANT: If you are not an expert in concurrent lockless programming, you + * should not be using any functions in this file. You should be protecting + * your data structures with full mutexes instead. + * + * ***Seriously, here be dragons!*** + * + * You can find out a little more about lockless programming and the subtle + * issues that can arise here: + * https://learn.microsoft.com/en-us/windows/win32/dxtecharts/lockless-programming + * + * There's also lots of good information here: + * + * - https://www.1024cores.net/home/lock-free-algorithms + * - https://preshing.com/ + * + * These operations may or may not actually be implemented using processor + * specific atomic operations. When possible they are implemented as true + * processor specific atomic operations. When that is not possible the are + * implemented using locks that *do* use the available atomic operations. + * + * All of the atomic operations that modify memory are full memory barriers. + */ + +#ifndef SDL_atomic_h_ +#define SDL_atomic_h_ + +#include +#include + +#include + +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * An atomic spinlock. + * + * The atomic locks are efficient spinlocks using CPU instructions, but are + * vulnerable to starvation and can spin forever if a thread holding a lock + * has been terminated. For this reason you should minimize the code executed + * inside an atomic lock and never do expensive things like API or system + * calls while holding them. + * + * They are also vulnerable to starvation if the thread holding the lock is + * lower priority than other threads and doesn't get scheduled. In general you + * should use mutexes instead, since they have better performance and + * contention behavior. + * + * The atomic locks are not safe to lock recursively. + * + * Porting Note: The spin lock functions and type are required and can not be + * emulated because they are used in the atomic emulation code. + */ +typedef int SDL_SpinLock; + +/** + * Try to lock a spin lock by setting it to a non-zero value. + * + * ***Please note that spinlocks are dangerous if you don't know what you're + * doing. Please be careful using any sort of spinlock!*** + * + * \param lock a pointer to a lock variable. + * \returns true if the lock succeeded, false if the lock is already held. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_LockSpinlock + * \sa SDL_UnlockSpinlock + */ +extern SDL_DECLSPEC bool SDLCALL SDL_TryLockSpinlock(SDL_SpinLock *lock); + +/** + * Lock a spin lock by setting it to a non-zero value. + * + * ***Please note that spinlocks are dangerous if you don't know what you're + * doing. Please be careful using any sort of spinlock!*** + * + * \param lock a pointer to a lock variable. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_TryLockSpinlock + * \sa SDL_UnlockSpinlock + */ +extern SDL_DECLSPEC void SDLCALL SDL_LockSpinlock(SDL_SpinLock *lock); + +/** + * Unlock a spin lock by setting it to 0. + * + * Always returns immediately. + * + * ***Please note that spinlocks are dangerous if you don't know what you're + * doing. Please be careful using any sort of spinlock!*** + * + * \param lock a pointer to a lock variable. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_LockSpinlock + * \sa SDL_TryLockSpinlock + */ +extern SDL_DECLSPEC void SDLCALL SDL_UnlockSpinlock(SDL_SpinLock *lock); + + +#ifdef SDL_WIKI_DOCUMENTATION_SECTION + +/** + * Mark a compiler barrier. + * + * A compiler barrier prevents the compiler from reordering reads and writes + * to globally visible variables across the call. + * + * This macro only prevents the compiler from reordering reads and writes, it + * does not prevent the CPU from reordering reads and writes. However, all of + * the atomic operations that modify memory are full memory barriers. + * + * \threadsafety Obviously this macro is safe to use from any thread at any + * time, but if you find yourself needing this, you are probably + * dealing with some very sensitive code; be careful! + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_CompilerBarrier() DoCompilerSpecificReadWriteBarrier() + +#elif defined(_MSC_VER) && (_MSC_VER > 1200) && !defined(__clang__) +void _ReadWriteBarrier(void); +#pragma intrinsic(_ReadWriteBarrier) +#define SDL_CompilerBarrier() _ReadWriteBarrier() +#elif (defined(__GNUC__) && !defined(SDL_PLATFORM_EMSCRIPTEN)) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x5120)) +/* This is correct for all CPUs when using GCC or Solaris Studio 12.1+. */ +#define SDL_CompilerBarrier() __asm__ __volatile__ ("" : : : "memory") +#elif defined(__WATCOMC__) +extern __inline void SDL_CompilerBarrier(void); +#pragma aux SDL_CompilerBarrier = "" parm [] modify exact []; +#else +#define SDL_CompilerBarrier() \ +{ SDL_SpinLock _tmp = 0; SDL_LockSpinlock(&_tmp); SDL_UnlockSpinlock(&_tmp); } +#endif + +/** + * Insert a memory release barrier (function version). + * + * Please refer to SDL_MemoryBarrierRelease for details. This is a function + * version, which might be useful if you need to use this functionality from a + * scripting language, etc. Also, some of the macro versions call this + * function behind the scenes, where more heavy lifting can happen inside of + * SDL. Generally, though, an app written in C/C++/etc should use the macro + * version, as it will be more efficient. + * + * \threadsafety Obviously this function is safe to use from any thread at any + * time, but if you find yourself needing this, you are probably + * dealing with some very sensitive code; be careful! + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_MemoryBarrierRelease + */ +extern SDL_DECLSPEC void SDLCALL SDL_MemoryBarrierReleaseFunction(void); + +/** + * Insert a memory acquire barrier (function version). + * + * Please refer to SDL_MemoryBarrierRelease for details. This is a function + * version, which might be useful if you need to use this functionality from a + * scripting language, etc. Also, some of the macro versions call this + * function behind the scenes, where more heavy lifting can happen inside of + * SDL. Generally, though, an app written in C/C++/etc should use the macro + * version, as it will be more efficient. + * + * \threadsafety Obviously this function is safe to use from any thread at any + * time, but if you find yourself needing this, you are probably + * dealing with some very sensitive code; be careful! + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_MemoryBarrierAcquire + */ +extern SDL_DECLSPEC void SDLCALL SDL_MemoryBarrierAcquireFunction(void); + + +#ifdef SDL_WIKI_DOCUMENTATION_SECTION + +/** + * Insert a memory release barrier (macro version). + * + * Memory barriers are designed to prevent reads and writes from being + * reordered by the compiler and being seen out of order on multi-core CPUs. + * + * A typical pattern would be for thread A to write some data and a flag, and + * for thread B to read the flag and get the data. In this case you would + * insert a release barrier between writing the data and the flag, + * guaranteeing that the data write completes no later than the flag is + * written, and you would insert an acquire barrier between reading the flag + * and reading the data, to ensure that all the reads associated with the flag + * have completed. + * + * In this pattern you should always see a release barrier paired with an + * acquire barrier and you should gate the data reads/writes with a single + * flag variable. + * + * For more information on these semantics, take a look at the blog post: + * http://preshing.com/20120913/acquire-and-release-semantics + * + * This is the macro version of this functionality; if possible, SDL will use + * compiler intrinsics or inline assembly, but some platforms might need to + * call the function version of this, SDL_MemoryBarrierReleaseFunction to do + * the heavy lifting. Apps that can use the macro should favor it over the + * function. + * + * \threadsafety Obviously this macro is safe to use from any thread at any + * time, but if you find yourself needing this, you are probably + * dealing with some very sensitive code; be careful! + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_MemoryBarrierAcquire + * \sa SDL_MemoryBarrierReleaseFunction + */ +#define SDL_MemoryBarrierRelease() SDL_MemoryBarrierReleaseFunction() + +/** + * Insert a memory acquire barrier (macro version). + * + * Please see SDL_MemoryBarrierRelease for the details on what memory barriers + * are and when to use them. + * + * This is the macro version of this functionality; if possible, SDL will use + * compiler intrinsics or inline assembly, but some platforms might need to + * call the function version of this, SDL_MemoryBarrierAcquireFunction, to do + * the heavy lifting. Apps that can use the macro should favor it over the + * function. + * + * \threadsafety Obviously this macro is safe to use from any thread at any + * time, but if you find yourself needing this, you are probably + * dealing with some very sensitive code; be careful! + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_MemoryBarrierRelease + * \sa SDL_MemoryBarrierAcquireFunction + */ +#define SDL_MemoryBarrierAcquire() SDL_MemoryBarrierAcquireFunction() + +#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) +#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("lwsync" : : : "memory") +#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("lwsync" : : : "memory") +#elif defined(__GNUC__) && defined(__aarch64__) +#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("dmb ish" : : : "memory") +#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("dmb ish" : : : "memory") +#elif defined(__GNUC__) && defined(__arm__) +#if 0 /* defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_ANDROID) */ +/* Information from: + https://chromium.googlesource.com/chromium/chromium/+/trunk/base/atomicops_internals_arm_gcc.h#19 + + The Linux kernel provides a helper function which provides the right code for a memory barrier, + hard-coded at address 0xffff0fa0 +*/ +typedef void (*SDL_KernelMemoryBarrierFunc)(); +#define SDL_MemoryBarrierRelease() ((SDL_KernelMemoryBarrierFunc)0xffff0fa0)() +#define SDL_MemoryBarrierAcquire() ((SDL_KernelMemoryBarrierFunc)0xffff0fa0)() +#else +#if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__) || defined(__ARM_ARCH_8A__) +#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("dmb ish" : : : "memory") +#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("dmb ish" : : : "memory") +#elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6T2__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) +#ifdef __thumb__ +/* The mcr instruction isn't available in thumb mode, use real functions */ +#define SDL_MEMORY_BARRIER_USES_FUNCTION +#define SDL_MemoryBarrierRelease() SDL_MemoryBarrierReleaseFunction() +#define SDL_MemoryBarrierAcquire() SDL_MemoryBarrierAcquireFunction() +#else +#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 5" : : "r"(0) : "memory") +#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 5" : : "r"(0) : "memory") +#endif /* __thumb__ */ +#else +#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("" : : : "memory") +#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("" : : : "memory") +#endif /* SDL_PLATFORM_LINUX || SDL_PLATFORM_ANDROID */ +#endif /* __GNUC__ && __arm__ */ +#else +#if (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x5120)) +/* This is correct for all CPUs on Solaris when using Solaris Studio 12.1+. */ +#include +#define SDL_MemoryBarrierRelease() __machine_rel_barrier() +#define SDL_MemoryBarrierAcquire() __machine_acq_barrier() +#else +/* This is correct for the x86 and x64 CPUs, and we'll expand this over time. */ +#define SDL_MemoryBarrierRelease() SDL_CompilerBarrier() +#define SDL_MemoryBarrierAcquire() SDL_CompilerBarrier() +#endif +#endif + +/* "REP NOP" is PAUSE, coded for tools that don't know it by that name. */ +#ifdef SDL_WIKI_DOCUMENTATION_SECTION + +/** + * A macro to insert a CPU-specific "pause" instruction into the program. + * + * This can be useful in busy-wait loops, as it serves as a hint to the CPU as + * to the program's intent; some CPUs can use this to do more efficient + * processing. On some platforms, this doesn't do anything, so using this + * macro might just be a harmless no-op. + * + * Note that if you are busy-waiting, there are often more-efficient + * approaches with other synchronization primitives: mutexes, semaphores, + * condition variables, etc. + * + * \threadsafety This macro is safe to use from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_CPUPauseInstruction() DoACPUPauseInACompilerAndArchitectureSpecificWay + +#elif (defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__)) + #define SDL_CPUPauseInstruction() __asm__ __volatile__("pause\n") /* Some assemblers can't do REP NOP, so go with PAUSE. */ +#elif (defined(__arm__) && defined(__ARM_ARCH) && __ARM_ARCH >= 7) || defined(__aarch64__) + #define SDL_CPUPauseInstruction() __asm__ __volatile__("yield" ::: "memory") +#elif (defined(__powerpc__) || defined(__powerpc64__)) + #define SDL_CPUPauseInstruction() __asm__ __volatile__("or 27,27,27"); +#elif (defined(__riscv) && __riscv_xlen == 64) + #define SDL_CPUPauseInstruction() __asm__ __volatile__(".insn i 0x0F, 0, x0, x0, 0x010"); +#elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64)) + #define SDL_CPUPauseInstruction() _mm_pause() /* this is actually "rep nop" and not a SIMD instruction. No inline asm in MSVC x86-64! */ +#elif defined(_MSC_VER) && (defined(_M_ARM) || defined(_M_ARM64)) + #define SDL_CPUPauseInstruction() __yield() +#elif defined(__WATCOMC__) && defined(__386__) + extern __inline void SDL_CPUPauseInstruction(void); + #pragma aux SDL_CPUPauseInstruction = ".686p" ".xmm2" "pause" +#else + #define SDL_CPUPauseInstruction() +#endif + + +/** + * A type representing an atomic integer value. + * + * This can be used to manage a value that is synchronized across multiple + * CPUs without a race condition; when an app sets a value with + * SDL_SetAtomicInt all other threads, regardless of the CPU it is running on, + * will see that value when retrieved with SDL_GetAtomicInt, regardless of CPU + * caches, etc. + * + * This is also useful for atomic compare-and-swap operations: a thread can + * change the value as long as its current value matches expectations. When + * done in a loop, one can guarantee data consistency across threads without a + * lock (but the usual warnings apply: if you don't know what you're doing, or + * you don't do it carefully, you can confidently cause any number of + * disasters with this, so in most cases, you _should_ use a mutex instead of + * this!). + * + * This is a struct so people don't accidentally use numeric operations on it + * directly. You have to use SDL atomic functions. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_CompareAndSwapAtomicInt + * \sa SDL_GetAtomicInt + * \sa SDL_SetAtomicInt + * \sa SDL_AddAtomicInt + */ +typedef struct SDL_AtomicInt { int value; } SDL_AtomicInt; + +/** + * Set an atomic variable to a new value if it is currently an old value. + * + * ***Note: If you don't know what this function is for, you shouldn't use + * it!*** + * + * \param a a pointer to an SDL_AtomicInt variable to be modified. + * \param oldval the old value. + * \param newval the new value. + * \returns true if the atomic variable was set, false otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetAtomicInt + * \sa SDL_SetAtomicInt + */ +extern SDL_DECLSPEC bool SDLCALL SDL_CompareAndSwapAtomicInt(SDL_AtomicInt *a, int oldval, int newval); + +/** + * Set an atomic variable to a value. + * + * This function also acts as a full memory barrier. + * + * ***Note: If you don't know what this function is for, you shouldn't use + * it!*** + * + * \param a a pointer to an SDL_AtomicInt variable to be modified. + * \param v the desired value. + * \returns the previous value of the atomic variable. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetAtomicInt + */ +extern SDL_DECLSPEC int SDLCALL SDL_SetAtomicInt(SDL_AtomicInt *a, int v); + +/** + * Get the value of an atomic variable. + * + * ***Note: If you don't know what this function is for, you shouldn't use + * it!*** + * + * \param a a pointer to an SDL_AtomicInt variable. + * \returns the current value of an atomic variable. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetAtomicInt + */ +extern SDL_DECLSPEC int SDLCALL SDL_GetAtomicInt(SDL_AtomicInt *a); + +/** + * Add to an atomic variable. + * + * This function also acts as a full memory barrier. + * + * ***Note: If you don't know what this function is for, you shouldn't use + * it!*** + * + * \param a a pointer to an SDL_AtomicInt variable to be modified. + * \param v the desired value to add. + * \returns the previous value of the atomic variable. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_AtomicDecRef + * \sa SDL_AtomicIncRef + */ +extern SDL_DECLSPEC int SDLCALL SDL_AddAtomicInt(SDL_AtomicInt *a, int v); + +#ifndef SDL_AtomicIncRef + +/** + * Increment an atomic variable used as a reference count. + * + * ***Note: If you don't know what this macro is for, you shouldn't use it!*** + * + * \param a a pointer to an SDL_AtomicInt to increment. + * \returns the previous value of the atomic variable. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_AtomicDecRef + */ +#define SDL_AtomicIncRef(a) SDL_AddAtomicInt(a, 1) +#endif + +#ifndef SDL_AtomicDecRef + +/** + * Decrement an atomic variable used as a reference count. + * + * ***Note: If you don't know what this macro is for, you shouldn't use it!*** + * + * \param a a pointer to an SDL_AtomicInt to decrement. + * \returns true if the variable reached zero after decrementing, false + * otherwise. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_AtomicIncRef + */ +#define SDL_AtomicDecRef(a) (SDL_AddAtomicInt(a, -1) == 1) +#endif + +/** + * A type representing an atomic unsigned 32-bit value. + * + * This can be used to manage a value that is synchronized across multiple + * CPUs without a race condition; when an app sets a value with + * SDL_SetAtomicU32 all other threads, regardless of the CPU it is running on, + * will see that value when retrieved with SDL_GetAtomicU32, regardless of CPU + * caches, etc. + * + * This is also useful for atomic compare-and-swap operations: a thread can + * change the value as long as its current value matches expectations. When + * done in a loop, one can guarantee data consistency across threads without a + * lock (but the usual warnings apply: if you don't know what you're doing, or + * you don't do it carefully, you can confidently cause any number of + * disasters with this, so in most cases, you _should_ use a mutex instead of + * this!). + * + * This is a struct so people don't accidentally use numeric operations on it + * directly. You have to use SDL atomic functions. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_CompareAndSwapAtomicU32 + * \sa SDL_GetAtomicU32 + * \sa SDL_SetAtomicU32 + */ +typedef struct SDL_AtomicU32 { Uint32 value; } SDL_AtomicU32; + +/** + * Set an atomic variable to a new value if it is currently an old value. + * + * ***Note: If you don't know what this function is for, you shouldn't use + * it!*** + * + * \param a a pointer to an SDL_AtomicU32 variable to be modified. + * \param oldval the old value. + * \param newval the new value. + * \returns true if the atomic variable was set, false otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetAtomicU32 + * \sa SDL_SetAtomicU32 + */ +extern SDL_DECLSPEC bool SDLCALL SDL_CompareAndSwapAtomicU32(SDL_AtomicU32 *a, Uint32 oldval, Uint32 newval); + +/** + * Set an atomic variable to a value. + * + * This function also acts as a full memory barrier. + * + * ***Note: If you don't know what this function is for, you shouldn't use + * it!*** + * + * \param a a pointer to an SDL_AtomicU32 variable to be modified. + * \param v the desired value. + * \returns the previous value of the atomic variable. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetAtomicU32 + */ +extern SDL_DECLSPEC Uint32 SDLCALL SDL_SetAtomicU32(SDL_AtomicU32 *a, Uint32 v); + +/** + * Get the value of an atomic variable. + * + * ***Note: If you don't know what this function is for, you shouldn't use + * it!*** + * + * \param a a pointer to an SDL_AtomicU32 variable. + * \returns the current value of an atomic variable. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetAtomicU32 + */ +extern SDL_DECLSPEC Uint32 SDLCALL SDL_GetAtomicU32(SDL_AtomicU32 *a); + +/** + * Add to an atomic variable. + * + * This function also acts as a full memory barrier. + * + * ***Note: If you don't know what this function is for, you shouldn't use + * it!*** + * + * \param a a pointer to an SDL_AtomicU32 variable to be modified. + * \param v the desired value to add or subtract. + * \returns the previous value of the atomic variable. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.4.0. + */ +extern SDL_DECLSPEC Uint32 SDLCALL SDL_AddAtomicU32(SDL_AtomicU32 *a, int v); + +/** + * Set a pointer to a new value if it is currently an old value. + * + * ***Note: If you don't know what this function is for, you shouldn't use + * it!*** + * + * \param a a pointer to a pointer. + * \param oldval the old pointer value. + * \param newval the new pointer value. + * \returns true if the pointer was set, false otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CompareAndSwapAtomicInt + * \sa SDL_GetAtomicPointer + * \sa SDL_SetAtomicPointer + */ +extern SDL_DECLSPEC bool SDLCALL SDL_CompareAndSwapAtomicPointer(void **a, void *oldval, void *newval); + +/** + * Set a pointer to a value atomically. + * + * ***Note: If you don't know what this function is for, you shouldn't use + * it!*** + * + * \param a a pointer to a pointer. + * \param v the desired pointer value. + * \returns the previous value of the pointer. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CompareAndSwapAtomicPointer + * \sa SDL_GetAtomicPointer + */ +extern SDL_DECLSPEC void * SDLCALL SDL_SetAtomicPointer(void **a, void *v); + +/** + * Get the value of a pointer atomically. + * + * ***Note: If you don't know what this function is for, you shouldn't use + * it!*** + * + * \param a a pointer to a pointer. + * \returns the current value of a pointer. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CompareAndSwapAtomicPointer + * \sa SDL_SetAtomicPointer + */ +extern SDL_DECLSPEC void * SDLCALL SDL_GetAtomicPointer(void **a); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif + +#include + +#endif /* SDL_atomic_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_audio.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_audio.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,2357 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * # CategoryAudio + * + * Audio functionality for the SDL library. + * + * All audio in SDL3 revolves around SDL_AudioStream. Whether you want to play + * or record audio, convert it, stream it, buffer it, or mix it, you're going + * to be passing it through an audio stream. + * + * Audio streams are quite flexible; they can accept any amount of data at a + * time, in any supported format, and output it as needed in any other format, + * even if the data format changes on either side halfway through. + * + * An app opens an audio device and binds any number of audio streams to it, + * feeding more data to the streams as available. When the device needs more + * data, it will pull it from all bound streams and mix them together for + * playback. + * + * Audio streams can also use an app-provided callback to supply data + * on-demand, which maps pretty closely to the SDL2 audio model. + * + * SDL also provides a simple .WAV loader in SDL_LoadWAV (and SDL_LoadWAV_IO + * if you aren't reading from a file) as a basic means to load sound data into + * your program. + * + * ## Logical audio devices + * + * In SDL3, opening a physical device (like a SoundBlaster 16 Pro) gives you a + * logical device ID that you can bind audio streams to. In almost all cases, + * logical devices can be used anywhere in the API that a physical device is + * normally used. However, since each device opening generates a new logical + * device, different parts of the program (say, a VoIP library, or + * text-to-speech framework, or maybe some other sort of mixer on top of SDL) + * can have their own device opens that do not interfere with each other; each + * logical device will mix its separate audio down to a single buffer, fed to + * the physical device, behind the scenes. As many logical devices as you like + * can come and go; SDL will only have to open the physical device at the OS + * level once, and will manage all the logical devices on top of it + * internally. + * + * One other benefit of logical devices: if you don't open a specific physical + * device, instead opting for the default, SDL can automatically migrate those + * logical devices to different hardware as circumstances change: a user + * plugged in headphones? The system default changed? SDL can transparently + * migrate the logical devices to the correct physical device seamlessly and + * keep playing; the app doesn't even have to know it happened if it doesn't + * want to. + * + * ## Simplified audio + * + * As a simplified model for when a single source of audio is all that's + * needed, an app can use SDL_OpenAudioDeviceStream, which is a single + * function to open an audio device, create an audio stream, bind that stream + * to the newly-opened device, and (optionally) provide a callback for + * obtaining audio data. When using this function, the primary interface is + * the SDL_AudioStream and the device handle is mostly hidden away; destroying + * a stream created through this function will also close the device, stream + * bindings cannot be changed, etc. One other quirk of this is that the device + * is started in a _paused_ state and must be explicitly resumed; this is + * partially to offer a clean migration for SDL2 apps and partially because + * the app might have to do more setup before playback begins; in the + * non-simplified form, nothing will play until a stream is bound to a device, + * so they start _unpaused_. + * + * ## Channel layouts + * + * Audio data passing through SDL is uncompressed PCM data, interleaved. One + * can provide their own decompression through an MP3, etc, decoder, but SDL + * does not provide this directly. Each interleaved channel of data is meant + * to be in a specific order. + * + * Abbreviations: + * + * - FRONT = single mono speaker + * - FL = front left speaker + * - FR = front right speaker + * - FC = front center speaker + * - BL = back left speaker + * - BR = back right speaker + * - SR = surround right speaker + * - SL = surround left speaker + * - BC = back center speaker + * - LFE = low-frequency speaker + * + * These are listed in the order they are laid out in memory, so "FL, FR" + * means "the front left speaker is laid out in memory first, then the front + * right, then it repeats for the next audio frame". + * + * - 1 channel (mono) layout: FRONT + * - 2 channels (stereo) layout: FL, FR + * - 3 channels (2.1) layout: FL, FR, LFE + * - 4 channels (quad) layout: FL, FR, BL, BR + * - 5 channels (4.1) layout: FL, FR, LFE, BL, BR + * - 6 channels (5.1) layout: FL, FR, FC, LFE, BL, BR (last two can also be + * SL, SR) + * - 7 channels (6.1) layout: FL, FR, FC, LFE, BC, SL, SR + * - 8 channels (7.1) layout: FL, FR, FC, LFE, BL, BR, SL, SR + * + * This is the same order as DirectSound expects, but applied to all + * platforms; SDL will swizzle the channels as necessary if a platform expects + * something different. + * + * SDL_AudioStream can also be provided channel maps to change this ordering + * to whatever is necessary, in other audio processing scenarios. + */ + +#ifndef SDL_audio_h_ +#define SDL_audio_h_ + +#include +#include +#include +#include +#include +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Mask of bits in an SDL_AudioFormat that contains the format bit size. + * + * Generally one should use SDL_AUDIO_BITSIZE instead of this macro directly. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_AUDIO_MASK_BITSIZE (0xFFu) + +/** + * Mask of bits in an SDL_AudioFormat that contain the floating point flag. + * + * Generally one should use SDL_AUDIO_ISFLOAT instead of this macro directly. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_AUDIO_MASK_FLOAT (1u<<8) + +/** + * Mask of bits in an SDL_AudioFormat that contain the bigendian flag. + * + * Generally one should use SDL_AUDIO_ISBIGENDIAN or SDL_AUDIO_ISLITTLEENDIAN + * instead of this macro directly. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_AUDIO_MASK_BIG_ENDIAN (1u<<12) + +/** + * Mask of bits in an SDL_AudioFormat that contain the signed data flag. + * + * Generally one should use SDL_AUDIO_ISSIGNED instead of this macro directly. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_AUDIO_MASK_SIGNED (1u<<15) + +/** + * Define an SDL_AudioFormat value. + * + * SDL does not support custom audio formats, so this macro is not of much use + * externally, but it can be illustrative as to what the various bits of an + * SDL_AudioFormat mean. + * + * For example, SDL_AUDIO_S32LE looks like this: + * + * ```c + * SDL_DEFINE_AUDIO_FORMAT(1, 0, 0, 32) + * ``` + * + * \param signed 1 for signed data, 0 for unsigned data. + * \param bigendian 1 for bigendian data, 0 for littleendian data. + * \param flt 1 for floating point data, 0 for integer data. + * \param size number of bits per sample. + * \returns a format value in the style of SDL_AudioFormat. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_DEFINE_AUDIO_FORMAT(signed, bigendian, flt, size) \ + (((Uint16)(signed) << 15) | ((Uint16)(bigendian) << 12) | ((Uint16)(flt) << 8) | ((size) & SDL_AUDIO_MASK_BITSIZE)) + +/** + * Audio format. + * + * \since This enum is available since SDL 3.2.0. + * + * \sa SDL_AUDIO_BITSIZE + * \sa SDL_AUDIO_BYTESIZE + * \sa SDL_AUDIO_ISINT + * \sa SDL_AUDIO_ISFLOAT + * \sa SDL_AUDIO_ISBIGENDIAN + * \sa SDL_AUDIO_ISLITTLEENDIAN + * \sa SDL_AUDIO_ISSIGNED + * \sa SDL_AUDIO_ISUNSIGNED + */ +typedef enum SDL_AudioFormat +{ + SDL_AUDIO_UNKNOWN = 0x0000u, /**< Unspecified audio format */ + SDL_AUDIO_U8 = 0x0008u, /**< Unsigned 8-bit samples */ + /* SDL_DEFINE_AUDIO_FORMAT(0, 0, 0, 8), */ + SDL_AUDIO_S8 = 0x8008u, /**< Signed 8-bit samples */ + /* SDL_DEFINE_AUDIO_FORMAT(1, 0, 0, 8), */ + SDL_AUDIO_S16LE = 0x8010u, /**< Signed 16-bit samples */ + /* SDL_DEFINE_AUDIO_FORMAT(1, 0, 0, 16), */ + SDL_AUDIO_S16BE = 0x9010u, /**< As above, but big-endian byte order */ + /* SDL_DEFINE_AUDIO_FORMAT(1, 1, 0, 16), */ + SDL_AUDIO_S32LE = 0x8020u, /**< 32-bit integer samples */ + /* SDL_DEFINE_AUDIO_FORMAT(1, 0, 0, 32), */ + SDL_AUDIO_S32BE = 0x9020u, /**< As above, but big-endian byte order */ + /* SDL_DEFINE_AUDIO_FORMAT(1, 1, 0, 32), */ + SDL_AUDIO_F32LE = 0x8120u, /**< 32-bit floating point samples */ + /* SDL_DEFINE_AUDIO_FORMAT(1, 0, 1, 32), */ + SDL_AUDIO_F32BE = 0x9120u, /**< As above, but big-endian byte order */ + /* SDL_DEFINE_AUDIO_FORMAT(1, 1, 1, 32), */ + + /* These represent the current system's byteorder. */ + #if SDL_BYTEORDER == SDL_LIL_ENDIAN + SDL_AUDIO_S16 = SDL_AUDIO_S16LE, + SDL_AUDIO_S32 = SDL_AUDIO_S32LE, + SDL_AUDIO_F32 = SDL_AUDIO_F32LE + #else + SDL_AUDIO_S16 = SDL_AUDIO_S16BE, + SDL_AUDIO_S32 = SDL_AUDIO_S32BE, + SDL_AUDIO_F32 = SDL_AUDIO_F32BE + #endif +} SDL_AudioFormat; + + +/** + * Retrieve the size, in bits, from an SDL_AudioFormat. + * + * For example, `SDL_AUDIO_BITSIZE(SDL_AUDIO_S16)` returns 16. + * + * \param x an SDL_AudioFormat value. + * \returns data size in bits. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_AUDIO_BITSIZE(x) ((x) & SDL_AUDIO_MASK_BITSIZE) + +/** + * Retrieve the size, in bytes, from an SDL_AudioFormat. + * + * For example, `SDL_AUDIO_BYTESIZE(SDL_AUDIO_S16)` returns 2. + * + * \param x an SDL_AudioFormat value. + * \returns data size in bytes. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_AUDIO_BYTESIZE(x) (SDL_AUDIO_BITSIZE(x) / 8) + +/** + * Determine if an SDL_AudioFormat represents floating point data. + * + * For example, `SDL_AUDIO_ISFLOAT(SDL_AUDIO_S16)` returns 0. + * + * \param x an SDL_AudioFormat value. + * \returns non-zero if format is floating point, zero otherwise. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_AUDIO_ISFLOAT(x) ((x) & SDL_AUDIO_MASK_FLOAT) + +/** + * Determine if an SDL_AudioFormat represents bigendian data. + * + * For example, `SDL_AUDIO_ISBIGENDIAN(SDL_AUDIO_S16LE)` returns 0. + * + * \param x an SDL_AudioFormat value. + * \returns non-zero if format is bigendian, zero otherwise. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_AUDIO_ISBIGENDIAN(x) ((x) & SDL_AUDIO_MASK_BIG_ENDIAN) + +/** + * Determine if an SDL_AudioFormat represents littleendian data. + * + * For example, `SDL_AUDIO_ISLITTLEENDIAN(SDL_AUDIO_S16BE)` returns 0. + * + * \param x an SDL_AudioFormat value. + * \returns non-zero if format is littleendian, zero otherwise. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_AUDIO_ISLITTLEENDIAN(x) (!SDL_AUDIO_ISBIGENDIAN(x)) + +/** + * Determine if an SDL_AudioFormat represents signed data. + * + * For example, `SDL_AUDIO_ISSIGNED(SDL_AUDIO_U8)` returns 0. + * + * \param x an SDL_AudioFormat value. + * \returns non-zero if format is signed, zero otherwise. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_AUDIO_ISSIGNED(x) ((x) & SDL_AUDIO_MASK_SIGNED) + +/** + * Determine if an SDL_AudioFormat represents integer data. + * + * For example, `SDL_AUDIO_ISINT(SDL_AUDIO_F32)` returns 0. + * + * \param x an SDL_AudioFormat value. + * \returns non-zero if format is integer, zero otherwise. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_AUDIO_ISINT(x) (!SDL_AUDIO_ISFLOAT(x)) + +/** + * Determine if an SDL_AudioFormat represents unsigned data. + * + * For example, `SDL_AUDIO_ISUNSIGNED(SDL_AUDIO_S16)` returns 0. + * + * \param x an SDL_AudioFormat value. + * \returns non-zero if format is unsigned, zero otherwise. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_AUDIO_ISUNSIGNED(x) (!SDL_AUDIO_ISSIGNED(x)) + + +/** + * SDL Audio Device instance IDs. + * + * Zero is used to signify an invalid/null device. + * + * \since This datatype is available since SDL 3.2.0. + */ +typedef Uint32 SDL_AudioDeviceID; + +/** + * A value used to request a default playback audio device. + * + * Several functions that require an SDL_AudioDeviceID will accept this value + * to signify the app just wants the system to choose a default device instead + * of the app providing a specific one. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK ((SDL_AudioDeviceID) 0xFFFFFFFFu) + +/** + * A value used to request a default recording audio device. + * + * Several functions that require an SDL_AudioDeviceID will accept this value + * to signify the app just wants the system to choose a default device instead + * of the app providing a specific one. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_AUDIO_DEVICE_DEFAULT_RECORDING ((SDL_AudioDeviceID) 0xFFFFFFFEu) + +/** + * Format specifier for audio data. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_AudioFormat + */ +typedef struct SDL_AudioSpec +{ + SDL_AudioFormat format; /**< Audio data format */ + int channels; /**< Number of channels: 1 mono, 2 stereo, etc */ + int freq; /**< sample rate: sample frames per second */ +} SDL_AudioSpec; + +/** + * Calculate the size of each audio frame (in bytes) from an SDL_AudioSpec. + * + * This reports on the size of an audio sample frame: stereo Sint16 data (2 + * channels of 2 bytes each) would be 4 bytes per frame, for example. + * + * \param x an SDL_AudioSpec to query. + * \returns the number of bytes used per sample frame. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_AUDIO_FRAMESIZE(x) (SDL_AUDIO_BYTESIZE((x).format) * (x).channels) + +/** + * The opaque handle that represents an audio stream. + * + * SDL_AudioStream is an audio conversion interface. + * + * - It can handle resampling data in chunks without generating artifacts, + * when it doesn't have the complete buffer available. + * - It can handle incoming data in any variable size. + * - It can handle input/output format changes on the fly. + * - It can remap audio channels between inputs and outputs. + * - You push data as you have it, and pull it when you need it + * - It can also function as a basic audio data queue even if you just have + * sound that needs to pass from one place to another. + * - You can hook callbacks up to them when more data is added or requested, + * to manage data on-the-fly. + * + * Audio streams are the core of the SDL3 audio interface. You create one or + * more of them, bind them to an opened audio device, and feed data to them + * (or for recording, consume data from them). + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_CreateAudioStream + */ +typedef struct SDL_AudioStream SDL_AudioStream; + + +/* Function prototypes */ + +/** + * Use this function to get the number of built-in audio drivers. + * + * This function returns a hardcoded number. This never returns a negative + * value; if there are no drivers compiled into this build of SDL, this + * function returns zero. The presence of a driver in this list does not mean + * it will function, it just means SDL is capable of interacting with that + * interface. For example, a build of SDL might have esound support, but if + * there's no esound server available, SDL's esound driver would fail if used. + * + * By default, SDL tries all drivers, in its preferred order, until one is + * found to be usable. + * + * \returns the number of built-in audio drivers. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetAudioDriver + */ +extern SDL_DECLSPEC int SDLCALL SDL_GetNumAudioDrivers(void); + +/** + * Use this function to get the name of a built in audio driver. + * + * The list of audio drivers is given in the order that they are normally + * initialized by default; the drivers that seem more reasonable to choose + * first (as far as the SDL developers believe) are earlier in the list. + * + * The names of drivers are all simple, low-ASCII identifiers, like "alsa", + * "coreaudio" or "wasapi". These never have Unicode characters, and are not + * meant to be proper names. + * + * \param index the index of the audio driver; the value ranges from 0 to + * SDL_GetNumAudioDrivers() - 1. + * \returns the name of the audio driver at the requested index, or NULL if an + * invalid index was specified. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetNumAudioDrivers + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetAudioDriver(int index); + +/** + * Get the name of the current audio driver. + * + * The names of drivers are all simple, low-ASCII identifiers, like "alsa", + * "coreaudio" or "wasapi". These never have Unicode characters, and are not + * meant to be proper names. + * + * \returns the name of the current audio driver or NULL if no driver has been + * initialized. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetCurrentAudioDriver(void); + +/** + * Get a list of currently-connected audio playback devices. + * + * This returns of list of available devices that play sound, perhaps to + * speakers or headphones ("playback" devices). If you want devices that + * record audio, like a microphone ("recording" devices), use + * SDL_GetAudioRecordingDevices() instead. + * + * This only returns a list of physical devices; it will not have any device + * IDs returned by SDL_OpenAudioDevice(). + * + * If this function returns NULL, to signify an error, `*count` will be set to + * zero. + * + * \param count a pointer filled in with the number of devices returned, may + * be NULL. + * \returns a 0 terminated array of device instance IDs or NULL on error; call + * SDL_GetError() for more information. This should be freed with + * SDL_free() when it is no longer needed. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_OpenAudioDevice + * \sa SDL_GetAudioRecordingDevices + */ +extern SDL_DECLSPEC SDL_AudioDeviceID * SDLCALL SDL_GetAudioPlaybackDevices(int *count); + +/** + * Get a list of currently-connected audio recording devices. + * + * This returns of list of available devices that record audio, like a + * microphone ("recording" devices). If you want devices that play sound, + * perhaps to speakers or headphones ("playback" devices), use + * SDL_GetAudioPlaybackDevices() instead. + * + * This only returns a list of physical devices; it will not have any device + * IDs returned by SDL_OpenAudioDevice(). + * + * If this function returns NULL, to signify an error, `*count` will be set to + * zero. + * + * \param count a pointer filled in with the number of devices returned, may + * be NULL. + * \returns a 0 terminated array of device instance IDs, or NULL on failure; + * call SDL_GetError() for more information. This should be freed + * with SDL_free() when it is no longer needed. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_OpenAudioDevice + * \sa SDL_GetAudioPlaybackDevices + */ +extern SDL_DECLSPEC SDL_AudioDeviceID * SDLCALL SDL_GetAudioRecordingDevices(int *count); + +/** + * Get the human-readable name of a specific audio device. + * + * **WARNING**: this function will work with SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK + * and SDL_AUDIO_DEVICE_DEFAULT_RECORDING, returning the current default + * physical devices' names. However, as the default device may change at any + * time, it is likely better to show a generic name to the user, like "System + * default audio device" or perhaps "default [currently %s]". Do not store + * this name to disk to reidentify the device in a later run of the program, + * as the default might change in general, and the string will be the name of + * a specific device and not the abstract system default. + * + * \param devid the instance ID of the device to query. + * \returns the name of the audio device, or NULL on failure; call + * SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetAudioPlaybackDevices + * \sa SDL_GetAudioRecordingDevices + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetAudioDeviceName(SDL_AudioDeviceID devid); + +/** + * Get the current audio format of a specific audio device. + * + * For an opened device, this will report the format the device is currently + * using. If the device isn't yet opened, this will report the device's + * preferred format (or a reasonable default if this can't be determined). + * + * You may also specify SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK or + * SDL_AUDIO_DEVICE_DEFAULT_RECORDING here, which is useful for getting a + * reasonable recommendation before opening the system-recommended default + * device. + * + * You can also use this to request the current device buffer size. This is + * specified in sample frames and represents the amount of data SDL will feed + * to the physical hardware in each chunk. This can be converted to + * milliseconds of audio with the following equation: + * + * `ms = (int) ((((Sint64) frames) * 1000) / spec.freq);` + * + * Buffer size is only important if you need low-level control over the audio + * playback timing. Most apps do not need this. + * + * \param devid the instance ID of the device to query. + * \param spec on return, will be filled with device details. + * \param sample_frames pointer to store device buffer size, in sample frames. + * Can be NULL. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetAudioDeviceFormat(SDL_AudioDeviceID devid, SDL_AudioSpec *spec, int *sample_frames); + +/** + * Get the current channel map of an audio device. + * + * Channel maps are optional; most things do not need them, instead passing + * data in the [order that SDL expects](CategoryAudio#channel-layouts). + * + * Audio devices usually have no remapping applied. This is represented by + * returning NULL, and does not signify an error. + * + * \param devid the instance ID of the device to query. + * \param count On output, set to number of channels in the map. Can be NULL. + * \returns an array of the current channel mapping, with as many elements as + * the current output spec's channels, or NULL if default. This + * should be freed with SDL_free() when it is no longer needed. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetAudioStreamInputChannelMap + */ +extern SDL_DECLSPEC int * SDLCALL SDL_GetAudioDeviceChannelMap(SDL_AudioDeviceID devid, int *count); + +/** + * Open a specific audio device. + * + * You can open both playback and recording devices through this function. + * Playback devices will take data from bound audio streams, mix it, and send + * it to the hardware. Recording devices will feed any bound audio streams + * with a copy of any incoming data. + * + * An opened audio device starts out with no audio streams bound. To start + * audio playing, bind a stream and supply audio data to it. Unlike SDL2, + * there is no audio callback; you only bind audio streams and make sure they + * have data flowing into them (however, you can simulate SDL2's semantics + * fairly closely by using SDL_OpenAudioDeviceStream instead of this + * function). + * + * If you don't care about opening a specific device, pass a `devid` of either + * `SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK` or + * `SDL_AUDIO_DEVICE_DEFAULT_RECORDING`. In this case, SDL will try to pick + * the most reasonable default, and may also switch between physical devices + * seamlessly later, if the most reasonable default changes during the + * lifetime of this opened device (user changed the default in the OS's system + * preferences, the default got unplugged so the system jumped to a new + * default, the user plugged in headphones on a mobile device, etc). Unless + * you have a good reason to choose a specific device, this is probably what + * you want. + * + * You may request a specific format for the audio device, but there is no + * promise the device will honor that request for several reasons. As such, + * it's only meant to be a hint as to what data your app will provide. Audio + * streams will accept data in whatever format you specify and manage + * conversion for you as appropriate. SDL_GetAudioDeviceFormat can tell you + * the preferred format for the device before opening and the actual format + * the device is using after opening. + * + * It's legal to open the same device ID more than once; each successful open + * will generate a new logical SDL_AudioDeviceID that is managed separately + * from others on the same physical device. This allows libraries to open a + * device separately from the main app and bind its own streams without + * conflicting. + * + * It is also legal to open a device ID returned by a previous call to this + * function; doing so just creates another logical device on the same physical + * device. This may be useful for making logical groupings of audio streams. + * + * This function returns the opened device ID on success. This is a new, + * unique SDL_AudioDeviceID that represents a logical device. + * + * Some backends might offer arbitrary devices (for example, a networked audio + * protocol that can connect to an arbitrary server). For these, as a change + * from SDL2, you should open a default device ID and use an SDL hint to + * specify the target if you care, or otherwise let the backend figure out a + * reasonable default. Most backends don't offer anything like this, and often + * this would be an end user setting an environment variable for their custom + * need, and not something an application should specifically manage. + * + * When done with an audio device, possibly at the end of the app's life, one + * should call SDL_CloseAudioDevice() on the returned device id. + * + * \param devid the device instance id to open, or + * SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK or + * SDL_AUDIO_DEVICE_DEFAULT_RECORDING for the most reasonable + * default device. + * \param spec the requested device configuration. Can be NULL to use + * reasonable defaults. + * \returns the device ID on success or 0 on failure; call SDL_GetError() for + * more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CloseAudioDevice + * \sa SDL_GetAudioDeviceFormat + */ +extern SDL_DECLSPEC SDL_AudioDeviceID SDLCALL SDL_OpenAudioDevice(SDL_AudioDeviceID devid, const SDL_AudioSpec *spec); + +/** + * Determine if an audio device is physical (instead of logical). + * + * An SDL_AudioDeviceID that represents physical hardware is a physical + * device; there is one for each piece of hardware that SDL can see. Logical + * devices are created by calling SDL_OpenAudioDevice or + * SDL_OpenAudioDeviceStream, and while each is associated with a physical + * device, there can be any number of logical devices on one physical device. + * + * For the most part, logical and physical IDs are interchangeable--if you try + * to open a logical device, SDL understands to assign that effort to the + * underlying physical device, etc. However, it might be useful to know if an + * arbitrary device ID is physical or logical. This function reports which. + * + * This function may return either true or false for invalid device IDs. + * + * \param devid the device ID to query. + * \returns true if devid is a physical device, false if it is logical. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_IsAudioDevicePhysical(SDL_AudioDeviceID devid); + +/** + * Determine if an audio device is a playback device (instead of recording). + * + * This function may return either true or false for invalid device IDs. + * + * \param devid the device ID to query. + * \returns true if devid is a playback device, false if it is recording. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_IsAudioDevicePlayback(SDL_AudioDeviceID devid); + +/** + * Use this function to pause audio playback on a specified device. + * + * This function pauses audio processing for a given device. Any bound audio + * streams will not progress, and no audio will be generated. Pausing one + * device does not prevent other unpaused devices from running. + * + * Unlike in SDL2, audio devices start in an _unpaused_ state, since an app + * has to bind a stream before any audio will flow. Pausing a paused device is + * a legal no-op. + * + * Pausing a device can be useful to halt all audio without unbinding all the + * audio streams. This might be useful while a game is paused, or a level is + * loading, etc. + * + * Physical devices can not be paused or unpaused, only logical devices + * created through SDL_OpenAudioDevice() can be. + * + * \param devid a device opened by SDL_OpenAudioDevice(). + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_ResumeAudioDevice + * \sa SDL_AudioDevicePaused + */ +extern SDL_DECLSPEC bool SDLCALL SDL_PauseAudioDevice(SDL_AudioDeviceID devid); + +/** + * Use this function to unpause audio playback on a specified device. + * + * This function unpauses audio processing for a given device that has + * previously been paused with SDL_PauseAudioDevice(). Once unpaused, any + * bound audio streams will begin to progress again, and audio can be + * generated. + * + * Unlike in SDL2, audio devices start in an _unpaused_ state, since an app + * has to bind a stream before any audio will flow. Unpausing an unpaused + * device is a legal no-op. + * + * Physical devices can not be paused or unpaused, only logical devices + * created through SDL_OpenAudioDevice() can be. + * + * \param devid a device opened by SDL_OpenAudioDevice(). + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_AudioDevicePaused + * \sa SDL_PauseAudioDevice + */ +extern SDL_DECLSPEC bool SDLCALL SDL_ResumeAudioDevice(SDL_AudioDeviceID devid); + +/** + * Use this function to query if an audio device is paused. + * + * Unlike in SDL2, audio devices start in an _unpaused_ state, since an app + * has to bind a stream before any audio will flow. + * + * Physical devices can not be paused or unpaused, only logical devices + * created through SDL_OpenAudioDevice() can be. Physical and invalid device + * IDs will report themselves as unpaused here. + * + * \param devid a device opened by SDL_OpenAudioDevice(). + * \returns true if device is valid and paused, false otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_PauseAudioDevice + * \sa SDL_ResumeAudioDevice + */ +extern SDL_DECLSPEC bool SDLCALL SDL_AudioDevicePaused(SDL_AudioDeviceID devid); + +/** + * Get the gain of an audio device. + * + * The gain of a device is its volume; a larger gain means a louder output, + * with a gain of zero being silence. + * + * Audio devices default to a gain of 1.0f (no change in output). + * + * Physical devices may not have their gain changed, only logical devices, and + * this function will always return -1.0f when used on physical devices. + * + * \param devid the audio device to query. + * \returns the gain of the device or -1.0f on failure; call SDL_GetError() + * for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetAudioDeviceGain + */ +extern SDL_DECLSPEC float SDLCALL SDL_GetAudioDeviceGain(SDL_AudioDeviceID devid); + +/** + * Change the gain of an audio device. + * + * The gain of a device is its volume; a larger gain means a louder output, + * with a gain of zero being silence. + * + * Audio devices default to a gain of 1.0f (no change in output). + * + * Physical devices may not have their gain changed, only logical devices, and + * this function will always return false when used on physical devices. While + * it might seem attractive to adjust several logical devices at once in this + * way, it would allow an app or library to interfere with another portion of + * the program's otherwise-isolated devices. + * + * This is applied, along with any per-audiostream gain, during playback to + * the hardware, and can be continuously changed to create various effects. On + * recording devices, this will adjust the gain before passing the data into + * an audiostream; that recording audiostream can then adjust its gain further + * when outputting the data elsewhere, if it likes, but that second gain is + * not applied until the data leaves the audiostream again. + * + * \param devid the audio device on which to change gain. + * \param gain the gain. 1.0f is no change, 0.0f is silence. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread, as it holds + * a stream-specific mutex while running. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetAudioDeviceGain + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetAudioDeviceGain(SDL_AudioDeviceID devid, float gain); + +/** + * Close a previously-opened audio device. + * + * The application should close open audio devices once they are no longer + * needed. + * + * This function may block briefly while pending audio data is played by the + * hardware, so that applications don't drop the last buffer of data they + * supplied if terminating immediately afterwards. + * + * \param devid an audio device id previously returned by + * SDL_OpenAudioDevice(). + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_OpenAudioDevice + */ +extern SDL_DECLSPEC void SDLCALL SDL_CloseAudioDevice(SDL_AudioDeviceID devid); + +/** + * Bind a list of audio streams to an audio device. + * + * Audio data will flow through any bound streams. For a playback device, data + * for all bound streams will be mixed together and fed to the device. For a + * recording device, a copy of recorded data will be provided to each bound + * stream. + * + * Audio streams can only be bound to an open device. This operation is + * atomic--all streams bound in the same call will start processing at the + * same time, so they can stay in sync. Also: either all streams will be bound + * or none of them will be. + * + * It is an error to bind an already-bound stream; it must be explicitly + * unbound first. + * + * Binding a stream to a device will set its output format for playback + * devices, and its input format for recording devices, so they match the + * device's settings. The caller is welcome to change the other end of the + * stream's format at any time with SDL_SetAudioStreamFormat(). If the other + * end of the stream's format has never been set (the audio stream was created + * with a NULL audio spec), this function will set it to match the device + * end's format. + * + * \param devid an audio device to bind a stream to. + * \param streams an array of audio streams to bind. + * \param num_streams number streams listed in the `streams` array. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_BindAudioStreams + * \sa SDL_UnbindAudioStream + * \sa SDL_GetAudioStreamDevice + */ +extern SDL_DECLSPEC bool SDLCALL SDL_BindAudioStreams(SDL_AudioDeviceID devid, SDL_AudioStream * const *streams, int num_streams); + +/** + * Bind a single audio stream to an audio device. + * + * This is a convenience function, equivalent to calling + * `SDL_BindAudioStreams(devid, &stream, 1)`. + * + * \param devid an audio device to bind a stream to. + * \param stream an audio stream to bind to a device. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_BindAudioStreams + * \sa SDL_UnbindAudioStream + * \sa SDL_GetAudioStreamDevice + */ +extern SDL_DECLSPEC bool SDLCALL SDL_BindAudioStream(SDL_AudioDeviceID devid, SDL_AudioStream *stream); + +/** + * Unbind a list of audio streams from their audio devices. + * + * The streams being unbound do not all have to be on the same device. All + * streams on the same device will be unbound atomically (data will stop + * flowing through all unbound streams on the same device at the same time). + * + * Unbinding a stream that isn't bound to a device is a legal no-op. + * + * \param streams an array of audio streams to unbind. Can be NULL or contain + * NULL. + * \param num_streams number streams listed in the `streams` array. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_BindAudioStreams + */ +extern SDL_DECLSPEC void SDLCALL SDL_UnbindAudioStreams(SDL_AudioStream * const *streams, int num_streams); + +/** + * Unbind a single audio stream from its audio device. + * + * This is a convenience function, equivalent to calling + * `SDL_UnbindAudioStreams(&stream, 1)`. + * + * \param stream an audio stream to unbind from a device. Can be NULL. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_BindAudioStream + */ +extern SDL_DECLSPEC void SDLCALL SDL_UnbindAudioStream(SDL_AudioStream *stream); + +/** + * Query an audio stream for its currently-bound device. + * + * This reports the logical audio device that an audio stream is currently + * bound to. + * + * If not bound, or invalid, this returns zero, which is not a valid device + * ID. + * + * \param stream the audio stream to query. + * \returns the bound audio device, or 0 if not bound or invalid. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_BindAudioStream + * \sa SDL_BindAudioStreams + */ +extern SDL_DECLSPEC SDL_AudioDeviceID SDLCALL SDL_GetAudioStreamDevice(SDL_AudioStream *stream); + +/** + * Create a new audio stream. + * + * \param src_spec the format details of the input audio. + * \param dst_spec the format details of the output audio. + * \returns a new audio stream on success or NULL on failure; call + * SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_PutAudioStreamData + * \sa SDL_GetAudioStreamData + * \sa SDL_GetAudioStreamAvailable + * \sa SDL_FlushAudioStream + * \sa SDL_ClearAudioStream + * \sa SDL_SetAudioStreamFormat + * \sa SDL_DestroyAudioStream + */ +extern SDL_DECLSPEC SDL_AudioStream * SDLCALL SDL_CreateAudioStream(const SDL_AudioSpec *src_spec, const SDL_AudioSpec *dst_spec); + +/** + * Get the properties associated with an audio stream. + * + * The application can hang any data it wants here, but the following + * properties are understood by SDL: + * + * - `SDL_PROP_AUDIOSTREAM_AUTO_CLEANUP_BOOLEAN`: if true (the default), the + * stream be automatically cleaned up when the audio subsystem quits. If set + * to false, the streams will persist beyond that. This property is ignored + * for streams created through SDL_OpenAudioDeviceStream(), and will always + * be cleaned up. Streams that are not cleaned up will still be unbound from + * devices when the audio subsystem quits. This property was added in SDL + * 3.4.0. + * + * \param stream the SDL_AudioStream to query. + * \returns a valid property ID on success or 0 on failure; call + * SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetAudioStreamProperties(SDL_AudioStream *stream); + +#define SDL_PROP_AUDIOSTREAM_AUTO_CLEANUP_BOOLEAN "SDL.audiostream.auto_cleanup" + + +/** + * Query the current format of an audio stream. + * + * \param stream the SDL_AudioStream to query. + * \param src_spec where to store the input audio format; ignored if NULL. + * \param dst_spec where to store the output audio format; ignored if NULL. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread, as it holds + * a stream-specific mutex while running. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetAudioStreamFormat + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetAudioStreamFormat(SDL_AudioStream *stream, SDL_AudioSpec *src_spec, SDL_AudioSpec *dst_spec); + +/** + * Change the input and output formats of an audio stream. + * + * Future calls to and SDL_GetAudioStreamAvailable and SDL_GetAudioStreamData + * will reflect the new format, and future calls to SDL_PutAudioStreamData + * must provide data in the new input formats. + * + * Data that was previously queued in the stream will still be operated on in + * the format that was current when it was added, which is to say you can put + * the end of a sound file in one format to a stream, change formats for the + * next sound file, and start putting that new data while the previous sound + * file is still queued, and everything will still play back correctly. + * + * If a stream is bound to a device, then the format of the side of the stream + * bound to a device cannot be changed (src_spec for recording devices, + * dst_spec for playback devices). Attempts to make a change to this side will + * be ignored, but this will not report an error. The other side's format can + * be changed. + * + * \param stream the stream the format is being changed. + * \param src_spec the new format of the audio input; if NULL, it is not + * changed. + * \param dst_spec the new format of the audio output; if NULL, it is not + * changed. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread, as it holds + * a stream-specific mutex while running. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetAudioStreamFormat + * \sa SDL_SetAudioStreamFrequencyRatio + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetAudioStreamFormat(SDL_AudioStream *stream, const SDL_AudioSpec *src_spec, const SDL_AudioSpec *dst_spec); + +/** + * Get the frequency ratio of an audio stream. + * + * \param stream the SDL_AudioStream to query. + * \returns the frequency ratio of the stream or 0.0 on failure; call + * SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread, as it holds + * a stream-specific mutex while running. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetAudioStreamFrequencyRatio + */ +extern SDL_DECLSPEC float SDLCALL SDL_GetAudioStreamFrequencyRatio(SDL_AudioStream *stream); + +/** + * Change the frequency ratio of an audio stream. + * + * The frequency ratio is used to adjust the rate at which input data is + * consumed. Changing this effectively modifies the speed and pitch of the + * audio. A value greater than 1.0f will play the audio faster, and at a + * higher pitch. A value less than 1.0f will play the audio slower, and at a + * lower pitch. 1.0f means play at normal speed. + * + * This is applied during SDL_GetAudioStreamData, and can be continuously + * changed to create various effects. + * + * \param stream the stream on which the frequency ratio is being changed. + * \param ratio the frequency ratio. 1.0 is normal speed. Must be between 0.01 + * and 100. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread, as it holds + * a stream-specific mutex while running. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetAudioStreamFrequencyRatio + * \sa SDL_SetAudioStreamFormat + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetAudioStreamFrequencyRatio(SDL_AudioStream *stream, float ratio); + +/** + * Get the gain of an audio stream. + * + * The gain of a stream is its volume; a larger gain means a louder output, + * with a gain of zero being silence. + * + * Audio streams default to a gain of 1.0f (no change in output). + * + * \param stream the SDL_AudioStream to query. + * \returns the gain of the stream or -1.0f on failure; call SDL_GetError() + * for more information. + * + * \threadsafety It is safe to call this function from any thread, as it holds + * a stream-specific mutex while running. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetAudioStreamGain + */ +extern SDL_DECLSPEC float SDLCALL SDL_GetAudioStreamGain(SDL_AudioStream *stream); + +/** + * Change the gain of an audio stream. + * + * The gain of a stream is its volume; a larger gain means a louder output, + * with a gain of zero being silence. + * + * Audio streams default to a gain of 1.0f (no change in output). + * + * This is applied during SDL_GetAudioStreamData, and can be continuously + * changed to create various effects. + * + * \param stream the stream on which the gain is being changed. + * \param gain the gain. 1.0f is no change, 0.0f is silence. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread, as it holds + * a stream-specific mutex while running. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetAudioStreamGain + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetAudioStreamGain(SDL_AudioStream *stream, float gain); + +/** + * Get the current input channel map of an audio stream. + * + * Channel maps are optional; most things do not need them, instead passing + * data in the [order that SDL expects](CategoryAudio#channel-layouts). + * + * Audio streams default to no remapping applied. This is represented by + * returning NULL, and does not signify an error. + * + * \param stream the SDL_AudioStream to query. + * \param count On output, set to number of channels in the map. Can be NULL. + * \returns an array of the current channel mapping, with as many elements as + * the current output spec's channels, or NULL if default. This + * should be freed with SDL_free() when it is no longer needed. + * + * \threadsafety It is safe to call this function from any thread, as it holds + * a stream-specific mutex while running. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetAudioStreamInputChannelMap + */ +extern SDL_DECLSPEC int * SDLCALL SDL_GetAudioStreamInputChannelMap(SDL_AudioStream *stream, int *count); + +/** + * Get the current output channel map of an audio stream. + * + * Channel maps are optional; most things do not need them, instead passing + * data in the [order that SDL expects](CategoryAudio#channel-layouts). + * + * Audio streams default to no remapping applied. This is represented by + * returning NULL, and does not signify an error. + * + * \param stream the SDL_AudioStream to query. + * \param count On output, set to number of channels in the map. Can be NULL. + * \returns an array of the current channel mapping, with as many elements as + * the current output spec's channels, or NULL if default. This + * should be freed with SDL_free() when it is no longer needed. + * + * \threadsafety It is safe to call this function from any thread, as it holds + * a stream-specific mutex while running. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetAudioStreamInputChannelMap + */ +extern SDL_DECLSPEC int * SDLCALL SDL_GetAudioStreamOutputChannelMap(SDL_AudioStream *stream, int *count); + +/** + * Set the current input channel map of an audio stream. + * + * Channel maps are optional; most things do not need them, instead passing + * data in the [order that SDL expects](CategoryAudio#channel-layouts). + * + * The input channel map reorders data that is added to a stream via + * SDL_PutAudioStreamData. Future calls to SDL_PutAudioStreamData must provide + * data in the new channel order. + * + * Each item in the array represents an input channel, and its value is the + * channel that it should be remapped to. To reverse a stereo signal's left + * and right values, you'd have an array of `{ 1, 0 }`. It is legal to remap + * multiple channels to the same thing, so `{ 1, 1 }` would duplicate the + * right channel to both channels of a stereo signal. An element in the + * channel map set to -1 instead of a valid channel will mute that channel, + * setting it to a silence value. + * + * You cannot change the number of channels through a channel map, just + * reorder/mute them. + * + * Data that was previously queued in the stream will still be operated on in + * the order that was current when it was added, which is to say you can put + * the end of a sound file in one order to a stream, change orders for the + * next sound file, and start putting that new data while the previous sound + * file is still queued, and everything will still play back correctly. + * + * Audio streams default to no remapping applied. Passing a NULL channel map + * is legal, and turns off remapping. + * + * SDL will copy the channel map; the caller does not have to save this array + * after this call. + * + * If `count` is not equal to the current number of channels in the audio + * stream's format, this will fail. This is a safety measure to make sure a + * race condition hasn't changed the format while this call is setting the + * channel map. + * + * Unlike attempting to change the stream's format, the input channel map on a + * stream bound to a recording device is permitted to change at any time; any + * data added to the stream from the device after this call will have the new + * mapping, but previously-added data will still have the prior mapping. + * + * \param stream the SDL_AudioStream to change. + * \param chmap the new channel map, NULL to reset to default. + * \param count The number of channels in the map. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread, as it holds + * a stream-specific mutex while running. Don't change the + * stream's format to have a different number of channels from a + * different thread at the same time, though! + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetAudioStreamInputChannelMap + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetAudioStreamInputChannelMap(SDL_AudioStream *stream, const int *chmap, int count); + +/** + * Set the current output channel map of an audio stream. + * + * Channel maps are optional; most things do not need them, instead passing + * data in the [order that SDL expects](CategoryAudio#channel-layouts). + * + * The output channel map reorders data that is leaving a stream via + * SDL_GetAudioStreamData. + * + * Each item in the array represents an input channel, and its value is the + * channel that it should be remapped to. To reverse a stereo signal's left + * and right values, you'd have an array of `{ 1, 0 }`. It is legal to remap + * multiple channels to the same thing, so `{ 1, 1 }` would duplicate the + * right channel to both channels of a stereo signal. An element in the + * channel map set to -1 instead of a valid channel will mute that channel, + * setting it to a silence value. + * + * You cannot change the number of channels through a channel map, just + * reorder/mute them. + * + * The output channel map can be changed at any time, as output remapping is + * applied during SDL_GetAudioStreamData. + * + * Audio streams default to no remapping applied. Passing a NULL channel map + * is legal, and turns off remapping. + * + * SDL will copy the channel map; the caller does not have to save this array + * after this call. + * + * If `count` is not equal to the current number of channels in the audio + * stream's format, this will fail. This is a safety measure to make sure a + * race condition hasn't changed the format while this call is setting the + * channel map. + * + * Unlike attempting to change the stream's format, the output channel map on + * a stream bound to a recording device is permitted to change at any time; + * any data added to the stream after this call will have the new mapping, but + * previously-added data will still have the prior mapping. When the channel + * map doesn't match the hardware's channel layout, SDL will convert the data + * before feeding it to the device for playback. + * + * \param stream the SDL_AudioStream to change. + * \param chmap the new channel map, NULL to reset to default. + * \param count The number of channels in the map. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread, as it holds + * a stream-specific mutex while running. Don't change the + * stream's format to have a different number of channels from a + * a different thread at the same time, though! + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetAudioStreamInputChannelMap + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetAudioStreamOutputChannelMap(SDL_AudioStream *stream, const int *chmap, int count); + +/** + * Add data to the stream. + * + * This data must match the format/channels/samplerate specified in the latest + * call to SDL_SetAudioStreamFormat, or the format specified when creating the + * stream if it hasn't been changed. + * + * Note that this call simply copies the unconverted data for later. This is + * different than SDL2, where data was converted during the Put call and the + * Get call would just dequeue the previously-converted data. + * + * \param stream the stream the audio data is being added to. + * \param buf a pointer to the audio data to add. + * \param len the number of bytes to write to the stream. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread, but if the + * stream has a callback set, the caller might need to manage + * extra locking. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_ClearAudioStream + * \sa SDL_FlushAudioStream + * \sa SDL_GetAudioStreamData + * \sa SDL_GetAudioStreamQueued + */ +extern SDL_DECLSPEC bool SDLCALL SDL_PutAudioStreamData(SDL_AudioStream *stream, const void *buf, int len); + +/** + * A callback that fires for completed SDL_PutAudioStreamDataNoCopy() data. + * + * When using SDL_PutAudioStreamDataNoCopy() to provide data to an + * SDL_AudioStream, it's not safe to dispose of the data until the stream has + * completely consumed it. Often times it's difficult to know exactly when + * this has happened. + * + * This callback fires once when the stream no longer needs the buffer, + * allowing the app to easily free or reuse it. + * + * \param userdata an opaque pointer provided by the app for their personal + * use. + * \param buf the pointer provided to SDL_PutAudioStreamDataNoCopy(). + * \param buflen the size of buffer, in bytes, provided to + * SDL_PutAudioStreamDataNoCopy(). + * + * \threadsafety This callbacks may run from any thread, so if you need to + * protect shared data, you should use SDL_LockAudioStream to + * serialize access; this lock will be held before your callback + * is called, so your callback does not need to manage the lock + * explicitly. + * + * \since This datatype is available since SDL 3.4.0. + * + * \sa SDL_SetAudioStreamGetCallback + * \sa SDL_SetAudioStreamPutCallback + */ +typedef void (SDLCALL *SDL_AudioStreamDataCompleteCallback)(void *userdata, const void *buf, int buflen); + +/** + * Add external data to an audio stream without copying it. + * + * Unlike SDL_PutAudioStreamData(), this function does not make a copy of the + * provided data, instead storing the provided pointer. This means that the + * put operation does not need to allocate and copy the data, but the original + * data must remain available until the stream is done with it, either by + * being read from the stream in its entirety, or a call to + * SDL_ClearAudioStream() or SDL_DestroyAudioStream(). + * + * The data must match the format/channels/samplerate specified in the latest + * call to SDL_SetAudioStreamFormat, or the format specified when creating the + * stream if it hasn't been changed. + * + * An optional callback may be provided, which is called when the stream no + * longer needs the data. Once this callback fires, the stream will not access + * the data again. This callback will fire for any reason the data is no + * longer needed, including clearing or destroying the stream. + * + * Note that there is still an allocation to store tracking information, so + * this function is more efficient for larger blocks of data. If you're + * planning to put a few samples at a time, it will be more efficient to use + * SDL_PutAudioStreamData(), which allocates and buffers in blocks. + * + * \param stream the stream the audio data is being added to. + * \param buf a pointer to the audio data to add. + * \param len the number of bytes to add to the stream. + * \param callback the callback function to call when the data is no longer + * needed by the stream. May be NULL. + * \param userdata an opaque pointer provided to the callback for its own + * personal use. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread, but if the + * stream has a callback set, the caller might need to manage + * extra locking. + * + * \since This function is available since SDL 3.4.0. + * + * \sa SDL_ClearAudioStream + * \sa SDL_FlushAudioStream + * \sa SDL_GetAudioStreamData + * \sa SDL_GetAudioStreamQueued + */ +extern SDL_DECLSPEC bool SDLCALL SDL_PutAudioStreamDataNoCopy(SDL_AudioStream *stream, const void *buf, int len, SDL_AudioStreamDataCompleteCallback callback, void *userdata); + +/** + * Add data to the stream with each channel in a separate array. + * + * This data must match the format/channels/samplerate specified in the latest + * call to SDL_SetAudioStreamFormat, or the format specified when creating the + * stream if it hasn't been changed. + * + * The data will be interleaved and queued. Note that SDL_AudioStream only + * operates on interleaved data, so this is simply a convenience function for + * easily queueing data from sources that provide separate arrays. There is no + * equivalent function to retrieve planar data. + * + * The arrays in `channel_buffers` are ordered as they are to be interleaved; + * the first array will be the first sample in the interleaved data. Any + * individual array may be NULL; in this case, silence will be interleaved for + * that channel. + * + * `num_channels` specifies how many arrays are in `channel_buffers`. This can + * be used as a safety to prevent overflow, in case the stream format has + * changed elsewhere. If more channels are specified than the current input + * spec, they are ignored. If less channels are specified, the missing arrays + * are treated as if they are NULL (silence is written to those channels). If + * the count is -1, SDL will assume the array count matches the current input + * spec. + * + * Note that `num_samples` is the number of _samples per array_. This can also + * be thought of as the number of _sample frames_ to be queued. A value of 1 + * with stereo arrays will queue two samples to the stream. This is different + * than SDL_PutAudioStreamData, which wants the size of a single array in + * bytes. + * + * \param stream the stream the audio data is being added to. + * \param channel_buffers a pointer to an array of arrays, one array per + * channel. + * \param num_channels the number of arrays in `channel_buffers` or -1. + * \param num_samples the number of _samples_ per array to write to the + * stream. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread, but if the + * stream has a callback set, the caller might need to manage + * extra locking. + * + * \since This function is available since SDL 3.4.0. + * + * \sa SDL_ClearAudioStream + * \sa SDL_FlushAudioStream + * \sa SDL_GetAudioStreamData + * \sa SDL_GetAudioStreamQueued + */ +extern SDL_DECLSPEC bool SDLCALL SDL_PutAudioStreamPlanarData(SDL_AudioStream *stream, const void * const *channel_buffers, int num_channels, int num_samples); + +/** + * Get converted/resampled data from the stream. + * + * The input/output data format/channels/samplerate is specified when creating + * the stream, and can be changed after creation by calling + * SDL_SetAudioStreamFormat. + * + * Note that any conversion and resampling necessary is done during this call, + * and SDL_PutAudioStreamData simply queues unconverted data for later. This + * is different than SDL2, where that work was done while inputting new data + * to the stream and requesting the output just copied the converted data. + * + * \param stream the stream the audio is being requested from. + * \param buf a buffer to fill with audio data. + * \param len the maximum number of bytes to fill. + * \returns the number of bytes read from the stream or -1 on failure; call + * SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread, but if the + * stream has a callback set, the caller might need to manage + * extra locking. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_ClearAudioStream + * \sa SDL_GetAudioStreamAvailable + * \sa SDL_PutAudioStreamData + */ +extern SDL_DECLSPEC int SDLCALL SDL_GetAudioStreamData(SDL_AudioStream *stream, void *buf, int len); + +/** + * Get the number of converted/resampled bytes available. + * + * The stream may be buffering data behind the scenes until it has enough to + * resample correctly, so this number might be lower than what you expect, or + * even be zero. Add more data or flush the stream if you need the data now. + * + * If the stream has so much data that it would overflow an int, the return + * value is clamped to a maximum value, but no queued data is lost; if there + * are gigabytes of data queued, the app might need to read some of it with + * SDL_GetAudioStreamData before this function's return value is no longer + * clamped. + * + * \param stream the audio stream to query. + * \returns the number of converted/resampled bytes available or -1 on + * failure; call SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetAudioStreamData + * \sa SDL_PutAudioStreamData + */ +extern SDL_DECLSPEC int SDLCALL SDL_GetAudioStreamAvailable(SDL_AudioStream *stream); + + +/** + * Get the number of bytes currently queued. + * + * This is the number of bytes put into a stream as input, not the number that + * can be retrieved as output. Because of several details, it's not possible + * to calculate one number directly from the other. If you need to know how + * much usable data can be retrieved right now, you should use + * SDL_GetAudioStreamAvailable() and not this function. + * + * Note that audio streams can change their input format at any time, even if + * there is still data queued in a different format, so the returned byte + * count will not necessarily match the number of _sample frames_ available. + * Users of this API should be aware of format changes they make when feeding + * a stream and plan accordingly. + * + * Queued data is not converted until it is consumed by + * SDL_GetAudioStreamData, so this value should be representative of the exact + * data that was put into the stream. + * + * If the stream has so much data that it would overflow an int, the return + * value is clamped to a maximum value, but no queued data is lost; if there + * are gigabytes of data queued, the app might need to read some of it with + * SDL_GetAudioStreamData before this function's return value is no longer + * clamped. + * + * \param stream the audio stream to query. + * \returns the number of bytes queued or -1 on failure; call SDL_GetError() + * for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_PutAudioStreamData + * \sa SDL_ClearAudioStream + */ +extern SDL_DECLSPEC int SDLCALL SDL_GetAudioStreamQueued(SDL_AudioStream *stream); + + +/** + * Tell the stream that you're done sending data, and anything being buffered + * should be converted/resampled and made available immediately. + * + * It is legal to add more data to a stream after flushing, but there may be + * audio gaps in the output. Generally this is intended to signal the end of + * input, so the complete output becomes available. + * + * \param stream the audio stream to flush. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_PutAudioStreamData + */ +extern SDL_DECLSPEC bool SDLCALL SDL_FlushAudioStream(SDL_AudioStream *stream); + +/** + * Clear any pending data in the stream. + * + * This drops any queued data, so there will be nothing to read from the + * stream until more is added. + * + * \param stream the audio stream to clear. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetAudioStreamAvailable + * \sa SDL_GetAudioStreamData + * \sa SDL_GetAudioStreamQueued + * \sa SDL_PutAudioStreamData + */ +extern SDL_DECLSPEC bool SDLCALL SDL_ClearAudioStream(SDL_AudioStream *stream); + +/** + * Use this function to pause audio playback on the audio device associated + * with an audio stream. + * + * This function pauses audio processing for a given device. Any bound audio + * streams will not progress, and no audio will be generated. Pausing one + * device does not prevent other unpaused devices from running. + * + * Pausing a device can be useful to halt all audio without unbinding all the + * audio streams. This might be useful while a game is paused, or a level is + * loading, etc. + * + * \param stream the audio stream associated with the audio device to pause. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_ResumeAudioStreamDevice + */ +extern SDL_DECLSPEC bool SDLCALL SDL_PauseAudioStreamDevice(SDL_AudioStream *stream); + +/** + * Use this function to unpause audio playback on the audio device associated + * with an audio stream. + * + * This function unpauses audio processing for a given device that has + * previously been paused. Once unpaused, any bound audio streams will begin + * to progress again, and audio can be generated. + * + * SDL_OpenAudioDeviceStream opens audio devices in a paused state, so this + * function call is required for audio playback to begin on such devices. + * + * \param stream the audio stream associated with the audio device to resume. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_PauseAudioStreamDevice + */ +extern SDL_DECLSPEC bool SDLCALL SDL_ResumeAudioStreamDevice(SDL_AudioStream *stream); + +/** + * Use this function to query if an audio device associated with a stream is + * paused. + * + * Unlike in SDL2, audio devices start in an _unpaused_ state, since an app + * has to bind a stream before any audio will flow. + * + * \param stream the audio stream associated with the audio device to query. + * \returns true if device is valid and paused, false otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_PauseAudioStreamDevice + * \sa SDL_ResumeAudioStreamDevice + */ +extern SDL_DECLSPEC bool SDLCALL SDL_AudioStreamDevicePaused(SDL_AudioStream *stream); + + +/** + * Lock an audio stream for serialized access. + * + * Each SDL_AudioStream has an internal mutex it uses to protect its data + * structures from threading conflicts. This function allows an app to lock + * that mutex, which could be useful if registering callbacks on this stream. + * + * One does not need to lock a stream to use in it most cases, as the stream + * manages this lock internally. However, this lock is held during callbacks, + * which may run from arbitrary threads at any time, so if an app needs to + * protect shared data during those callbacks, locking the stream guarantees + * that the callback is not running while the lock is held. + * + * As this is just a wrapper over SDL_LockMutex for an internal lock; it has + * all the same attributes (recursive locks are allowed, etc). + * + * \param stream the audio stream to lock. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_UnlockAudioStream + */ +extern SDL_DECLSPEC bool SDLCALL SDL_LockAudioStream(SDL_AudioStream *stream); + + +/** + * Unlock an audio stream for serialized access. + * + * This unlocks an audio stream after a call to SDL_LockAudioStream. + * + * \param stream the audio stream to unlock. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety You should only call this from the same thread that + * previously called SDL_LockAudioStream. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_LockAudioStream + */ +extern SDL_DECLSPEC bool SDLCALL SDL_UnlockAudioStream(SDL_AudioStream *stream); + +/** + * A callback that fires when data passes through an SDL_AudioStream. + * + * Apps can (optionally) register a callback with an audio stream that is + * called when data is added with SDL_PutAudioStreamData, or requested with + * SDL_GetAudioStreamData. + * + * Two values are offered here: one is the amount of additional data needed to + * satisfy the immediate request (which might be zero if the stream already + * has enough data queued) and the other is the total amount being requested. + * In a Get call triggering a Put callback, these values can be different. In + * a Put call triggering a Get callback, these values are always the same. + * + * Byte counts might be slightly overestimated due to buffering or resampling, + * and may change from call to call. + * + * This callback is not required to do anything. Generally this is useful for + * adding/reading data on demand, and the app will often put/get data as + * appropriate, but the system goes on with the data currently available to it + * if this callback does nothing. + * + * \param stream the SDL audio stream associated with this callback. + * \param additional_amount the amount of data, in bytes, that is needed right + * now. + * \param total_amount the total amount of data requested, in bytes, that is + * requested or available. + * \param userdata an opaque pointer provided by the app for their personal + * use. + * + * \threadsafety This callbacks may run from any thread, so if you need to + * protect shared data, you should use SDL_LockAudioStream to + * serialize access; this lock will be held before your callback + * is called, so your callback does not need to manage the lock + * explicitly. + * + * \since This datatype is available since SDL 3.2.0. + * + * \sa SDL_SetAudioStreamGetCallback + * \sa SDL_SetAudioStreamPutCallback + */ +typedef void (SDLCALL *SDL_AudioStreamCallback)(void *userdata, SDL_AudioStream *stream, int additional_amount, int total_amount); + +/** + * Set a callback that runs when data is requested from an audio stream. + * + * This callback is called _before_ data is obtained from the stream, giving + * the callback the chance to add more on-demand. + * + * The callback can (optionally) call SDL_PutAudioStreamData() to add more + * audio to the stream during this call; if needed, the request that triggered + * this callback will obtain the new data immediately. + * + * The callback's `additional_amount` argument is roughly how many bytes of + * _unconverted_ data (in the stream's input format) is needed by the caller, + * although this may overestimate a little for safety. This takes into account + * how much is already in the stream and only asks for any extra necessary to + * resolve the request, which means the callback may be asked for zero bytes, + * and a different amount on each call. + * + * The callback is not required to supply exact amounts; it is allowed to + * supply too much or too little or none at all. The caller will get what's + * available, up to the amount they requested, regardless of this callback's + * outcome. + * + * Clearing or flushing an audio stream does not call this callback. + * + * This function obtains the stream's lock, which means any existing callback + * (get or put) in progress will finish running before setting the new + * callback. + * + * Setting a NULL function turns off the callback. + * + * \param stream the audio stream to set the new callback on. + * \param callback the new callback function to call when data is requested + * from the stream. + * \param userdata an opaque pointer provided to the callback for its own + * personal use. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. This only fails if `stream` is NULL. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetAudioStreamPutCallback + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetAudioStreamGetCallback(SDL_AudioStream *stream, SDL_AudioStreamCallback callback, void *userdata); + +/** + * Set a callback that runs when data is added to an audio stream. + * + * This callback is called _after_ the data is added to the stream, giving the + * callback the chance to obtain it immediately. + * + * The callback can (optionally) call SDL_GetAudioStreamData() to obtain audio + * from the stream during this call. + * + * The callback's `additional_amount` argument is how many bytes of + * _converted_ data (in the stream's output format) was provided by the + * caller, although this may underestimate a little for safety. This value + * might be less than what is currently available in the stream, if data was + * already there, and might be less than the caller provided if the stream + * needs to keep a buffer to aid in resampling. Which means the callback may + * be provided with zero bytes, and a different amount on each call. + * + * The callback may call SDL_GetAudioStreamAvailable to see the total amount + * currently available to read from the stream, instead of the total provided + * by the current call. + * + * The callback is not required to obtain all data. It is allowed to read less + * or none at all. Anything not read now simply remains in the stream for + * later access. + * + * Clearing or flushing an audio stream does not call this callback. + * + * This function obtains the stream's lock, which means any existing callback + * (get or put) in progress will finish running before setting the new + * callback. + * + * Setting a NULL function turns off the callback. + * + * \param stream the audio stream to set the new callback on. + * \param callback the new callback function to call when data is added to the + * stream. + * \param userdata an opaque pointer provided to the callback for its own + * personal use. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. This only fails if `stream` is NULL. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetAudioStreamGetCallback + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetAudioStreamPutCallback(SDL_AudioStream *stream, SDL_AudioStreamCallback callback, void *userdata); + + +/** + * Free an audio stream. + * + * This will release all allocated data, including any audio that is still + * queued. You do not need to manually clear the stream first. + * + * If this stream was bound to an audio device, it is unbound during this + * call. If this stream was created with SDL_OpenAudioDeviceStream, the audio + * device that was opened alongside this stream's creation will be closed, + * too. + * + * \param stream the audio stream to destroy. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateAudioStream + */ +extern SDL_DECLSPEC void SDLCALL SDL_DestroyAudioStream(SDL_AudioStream *stream); + + +/** + * Convenience function for straightforward audio init for the common case. + * + * If all your app intends to do is provide a single source of PCM audio, this + * function allows you to do all your audio setup in a single call. + * + * This is also intended to be a clean means to migrate apps from SDL2. + * + * This function will open an audio device, create a stream and bind it. + * Unlike other methods of setup, the audio device will be closed when this + * stream is destroyed, so the app can treat the returned SDL_AudioStream as + * the only object needed to manage audio playback. + * + * Also unlike other functions, the audio device begins paused. This is to map + * more closely to SDL2-style behavior, since there is no extra step here to + * bind a stream to begin audio flowing. The audio device should be resumed + * with SDL_ResumeAudioStreamDevice(). + * + * This function works with both playback and recording devices. + * + * The `spec` parameter represents the app's side of the audio stream. That + * is, for recording audio, this will be the output format, and for playing + * audio, this will be the input format. If spec is NULL, the system will + * choose the format, and the app can use SDL_GetAudioStreamFormat() to obtain + * this information later. + * + * If you don't care about opening a specific audio device, you can (and + * probably _should_), use SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK for playback and + * SDL_AUDIO_DEVICE_DEFAULT_RECORDING for recording. + * + * One can optionally provide a callback function; if NULL, the app is + * expected to queue audio data for playback (or unqueue audio data if + * capturing). Otherwise, the callback will begin to fire once the device is + * unpaused. + * + * Destroying the returned stream with SDL_DestroyAudioStream will also close + * the audio device associated with this stream. + * + * \param devid an audio device to open, or SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK + * or SDL_AUDIO_DEVICE_DEFAULT_RECORDING. + * \param spec the audio stream's data format. Can be NULL. + * \param callback a callback where the app will provide new data for + * playback, or receive new data for recording. Can be NULL, + * in which case the app will need to call + * SDL_PutAudioStreamData or SDL_GetAudioStreamData as + * necessary. + * \param userdata app-controlled pointer passed to callback. Can be NULL. + * Ignored if callback is NULL. + * \returns an audio stream on success, ready to use, or NULL on failure; call + * SDL_GetError() for more information. When done with this stream, + * call SDL_DestroyAudioStream to free resources and close the + * device. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetAudioStreamDevice + * \sa SDL_ResumeAudioStreamDevice + */ +extern SDL_DECLSPEC SDL_AudioStream * SDLCALL SDL_OpenAudioDeviceStream(SDL_AudioDeviceID devid, const SDL_AudioSpec *spec, SDL_AudioStreamCallback callback, void *userdata); + +/** + * A callback that fires when data is about to be fed to an audio device. + * + * This is useful for accessing the final mix, perhaps for writing a + * visualizer or applying a final effect to the audio data before playback. + * + * This callback should run as quickly as possible and not block for any + * significant time, as this callback delays submission of data to the audio + * device, which can cause audio playback problems. + * + * The postmix callback _must_ be able to handle any audio data format + * specified in `spec`, which can change between callbacks if the audio device + * changed. However, this only covers frequency and channel count; data is + * always provided here in SDL_AUDIO_F32 format. + * + * The postmix callback runs _after_ logical device gain and audiostream gain + * have been applied, which is to say you can make the output data louder at + * this point than the gain settings would suggest. + * + * \param userdata a pointer provided by the app through + * SDL_SetAudioPostmixCallback, for its own use. + * \param spec the current format of audio that is to be submitted to the + * audio device. + * \param buffer the buffer of audio samples to be submitted. The callback can + * inspect and/or modify this data. + * \param buflen the size of `buffer` in bytes. + * + * \threadsafety This will run from a background thread owned by SDL. The + * application is responsible for locking resources the callback + * touches that need to be protected. + * + * \since This datatype is available since SDL 3.2.0. + * + * \sa SDL_SetAudioPostmixCallback + */ +typedef void (SDLCALL *SDL_AudioPostmixCallback)(void *userdata, const SDL_AudioSpec *spec, float *buffer, int buflen); + +/** + * Set a callback that fires when data is about to be fed to an audio device. + * + * This is useful for accessing the final mix, perhaps for writing a + * visualizer or applying a final effect to the audio data before playback. + * + * The buffer is the final mix of all bound audio streams on an opened device; + * this callback will fire regularly for any device that is both opened and + * unpaused. If there is no new data to mix, either because no streams are + * bound to the device or all the streams are empty, this callback will still + * fire with the entire buffer set to silence. + * + * This callback is allowed to make changes to the data; the contents of the + * buffer after this call is what is ultimately passed along to the hardware. + * + * The callback is always provided the data in float format (values from -1.0f + * to 1.0f), but the number of channels or sample rate may be different than + * the format the app requested when opening the device; SDL might have had to + * manage a conversion behind the scenes, or the playback might have jumped to + * new physical hardware when a system default changed, etc. These details may + * change between calls. Accordingly, the size of the buffer might change + * between calls as well. + * + * This callback can run at any time, and from any thread; if you need to + * serialize access to your app's data, you should provide and use a mutex or + * other synchronization device. + * + * All of this to say: there are specific needs this callback can fulfill, but + * it is not the simplest interface. Apps should generally provide audio in + * their preferred format through an SDL_AudioStream and let SDL handle the + * difference. + * + * This function is extremely time-sensitive; the callback should do the least + * amount of work possible and return as quickly as it can. The longer the + * callback runs, the higher the risk of audio dropouts or other problems. + * + * This function will block until the audio device is in between iterations, + * so any existing callback that might be running will finish before this + * function sets the new callback and returns. + * + * Setting a NULL callback function disables any previously-set callback. + * + * \param devid the ID of an opened audio device. + * \param callback a callback function to be called. Can be NULL. + * \param userdata app-controlled pointer passed to callback. Can be NULL. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetAudioPostmixCallback(SDL_AudioDeviceID devid, SDL_AudioPostmixCallback callback, void *userdata); + + +/** + * Load the audio data of a WAVE file into memory. + * + * Loading a WAVE file requires `src`, `spec`, `audio_buf` and `audio_len` to + * be valid pointers. The entire data portion of the file is then loaded into + * memory and decoded if necessary. + * + * Supported formats are RIFF WAVE files with the formats PCM (8, 16, 24, and + * 32 bits), IEEE Float (32 bits), Microsoft ADPCM and IMA ADPCM (4 bits), and + * A-law and mu-law (8 bits). Other formats are currently unsupported and + * cause an error. + * + * If this function succeeds, the return value is zero and the pointer to the + * audio data allocated by the function is written to `audio_buf` and its + * length in bytes to `audio_len`. The SDL_AudioSpec members `freq`, + * `channels`, and `format` are set to the values of the audio data in the + * buffer. + * + * It's necessary to use SDL_free() to free the audio data returned in + * `audio_buf` when it is no longer used. + * + * Because of the underspecification of the .WAV format, there are many + * problematic files in the wild that cause issues with strict decoders. To + * provide compatibility with these files, this decoder is lenient in regards + * to the truncation of the file, the fact chunk, and the size of the RIFF + * chunk. The hints `SDL_HINT_WAVE_RIFF_CHUNK_SIZE`, + * `SDL_HINT_WAVE_TRUNCATION`, and `SDL_HINT_WAVE_FACT_CHUNK` can be used to + * tune the behavior of the loading process. + * + * Any file that is invalid (due to truncation, corruption, or wrong values in + * the headers), too big, or unsupported causes an error. Additionally, any + * critical I/O error from the data source will terminate the loading process + * with an error. The function returns NULL on error and in all cases (with + * the exception of `src` being NULL), an appropriate error message will be + * set. + * + * It is required that the data source supports seeking. + * + * Example: + * + * ```c + * SDL_LoadWAV_IO(SDL_IOFromFile("sample.wav", "rb"), true, &spec, &buf, &len); + * ``` + * + * Note that the SDL_LoadWAV function does this same thing for you, but in a + * less messy way: + * + * ```c + * SDL_LoadWAV("sample.wav", &spec, &buf, &len); + * ``` + * + * \param src the data source for the WAVE data. + * \param closeio if true, calls SDL_CloseIO() on `src` before returning, even + * in the case of an error. + * \param spec a pointer to an SDL_AudioSpec that will be set to the WAVE + * data's format details on successful return. + * \param audio_buf a pointer filled with the audio data, allocated by the + * function. + * \param audio_len a pointer filled with the length of the audio data buffer + * in bytes. + * \returns true on success. `audio_buf` will be filled with a pointer to an + * allocated buffer containing the audio data, and `audio_len` is + * filled with the length of that audio buffer in bytes. + * + * This function returns false if the .WAV file cannot be opened, + * uses an unknown data format, or is corrupt; call SDL_GetError() + * for more information. + * + * When the application is done with the data returned in + * `audio_buf`, it should call SDL_free() to dispose of it. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_free + * \sa SDL_LoadWAV + */ +extern SDL_DECLSPEC bool SDLCALL SDL_LoadWAV_IO(SDL_IOStream *src, bool closeio, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len); + +/** + * Loads a WAV from a file path. + * + * This is a convenience function that is effectively the same as: + * + * ```c + * SDL_LoadWAV_IO(SDL_IOFromFile(path, "rb"), true, spec, audio_buf, audio_len); + * ``` + * + * \param path the file path of the WAV file to open. + * \param spec a pointer to an SDL_AudioSpec that will be set to the WAVE + * data's format details on successful return. + * \param audio_buf a pointer filled with the audio data, allocated by the + * function. + * \param audio_len a pointer filled with the length of the audio data buffer + * in bytes. + * \returns true on success. `audio_buf` will be filled with a pointer to an + * allocated buffer containing the audio data, and `audio_len` is + * filled with the length of that audio buffer in bytes. + * + * This function returns false if the .WAV file cannot be opened, + * uses an unknown data format, or is corrupt; call SDL_GetError() + * for more information. + * + * When the application is done with the data returned in + * `audio_buf`, it should call SDL_free() to dispose of it. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_free + * \sa SDL_LoadWAV_IO + */ +extern SDL_DECLSPEC bool SDLCALL SDL_LoadWAV(const char *path, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len); + +/** + * Mix audio data in a specified format. + * + * This takes an audio buffer `src` of `len` bytes of `format` data and mixes + * it into `dst`, performing addition, volume adjustment, and overflow + * clipping. The buffer pointed to by `dst` must also be `len` bytes of + * `format` data. + * + * This is provided for convenience -- you can mix your own audio data. + * + * Do not use this function for mixing together more than two streams of + * sample data. The output from repeated application of this function may be + * distorted by clipping, because there is no accumulator with greater range + * than the input (not to mention this being an inefficient way of doing it). + * + * It is a common misconception that this function is required to write audio + * data to an output stream in an audio callback. While you can do that, + * SDL_MixAudio() is really only needed when you're mixing a single audio + * stream with a volume adjustment. + * + * \param dst the destination for the mixed audio. + * \param src the source audio buffer to be mixed. + * \param format the SDL_AudioFormat structure representing the desired audio + * format. + * \param len the length of the audio buffer in bytes. + * \param volume ranges from 0.0 - 1.0, and should be set to 1.0 for full + * audio volume. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_MixAudio(Uint8 *dst, const Uint8 *src, SDL_AudioFormat format, Uint32 len, float volume); + +/** + * Convert some audio data of one format to another format. + * + * Please note that this function is for convenience, but should not be used + * to resample audio in blocks, as it will introduce audio artifacts on the + * boundaries. You should only use this function if you are converting audio + * data in its entirety in one call. If you want to convert audio in smaller + * chunks, use an SDL_AudioStream, which is designed for this situation. + * + * Internally, this function creates and destroys an SDL_AudioStream on each + * use, so it's also less efficient than using one directly, if you need to + * convert multiple times. + * + * \param src_spec the format details of the input audio. + * \param src_data the audio data to be converted. + * \param src_len the len of src_data. + * \param dst_spec the format details of the output audio. + * \param dst_data will be filled with a pointer to converted audio data, + * which should be freed with SDL_free(). On error, it will be + * NULL. + * \param dst_len will be filled with the len of dst_data. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_ConvertAudioSamples(const SDL_AudioSpec *src_spec, const Uint8 *src_data, int src_len, const SDL_AudioSpec *dst_spec, Uint8 **dst_data, int *dst_len); + +/** + * Get the human readable name of an audio format. + * + * \param format the audio format to query. + * \returns the human readable name of the specified audio format or + * "SDL_AUDIO_UNKNOWN" if the format isn't recognized. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetAudioFormatName(SDL_AudioFormat format); + +/** + * Get the appropriate memset value for silencing an audio format. + * + * The value returned by this function can be used as the second argument to + * memset (or SDL_memset) to set an audio buffer in a specific format to + * silence. + * + * \param format the audio data format to query. + * \returns a byte value that can be passed to memset. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_GetSilenceValueForFormat(SDL_AudioFormat format); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_audio_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_begin_code.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_begin_code.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,553 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* WIKI CATEGORY: BeginCode */ + +/** + * # CategoryBeginCode + * + * `SDL_begin_code.h` sets things up for C dynamic library function + * definitions, static inlined functions, and structures aligned at 4-byte + * alignment. If you don't like ugly C preprocessor code, don't look at this + * file. :) + * + * SDL's headers use this; applications generally should not include this + * header directly. + */ + +/* This shouldn't be nested -- included it around code only. */ +#ifdef SDL_begin_code_h +#error Nested inclusion of SDL_begin_code.h +#endif +#define SDL_begin_code_h + +#ifdef SDL_WIKI_DOCUMENTATION_SECTION + +/** + * A macro to tag a symbol as deprecated. + * + * A function is marked deprecated by adding this macro to its declaration: + * + * ```c + * extern SDL_DEPRECATED int ThisFunctionWasABadIdea(void); + * ``` + * + * Compilers with deprecation support can give a warning when a deprecated + * function is used. This symbol may be used in SDL's headers, but apps are + * welcome to use it for their own interfaces as well. + * + * SDL, on occasion, might deprecate a function for various reasons. However, + * SDL never removes symbols before major versions, so deprecated interfaces + * in SDL3 will remain available until SDL4, where it would be expected an app + * would have to take steps to migrate anyhow. + * + * On compilers without a deprecation mechanism, this is defined to nothing, + * and using a deprecated function will not generate a warning. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_DEPRECATED __attribute__((deprecated)) + +/** + * A macro to tag a symbol as a public API. + * + * SDL uses this macro for all its public functions. On some targets, it is + * used to signal to the compiler that this function needs to be exported from + * a shared library, but it might have other side effects. + * + * This symbol is used in SDL's headers, but apps and other libraries are + * welcome to use it for their own interfaces as well. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_DECLSPEC __attribute__ ((visibility("default"))) + +/** + * A macro to set a function's calling conventions. + * + * SDL uses this macro for all its public functions, and any callbacks it + * defines. This macro guarantees that calling conventions match between SDL + * and the app, even if the two were built with different compilers or + * optimization settings. + * + * When writing a callback function, it is very important for it to be + * correctly tagged with SDLCALL, as mismatched calling conventions can cause + * strange behaviors and can be difficult to diagnose. Plus, on many + * platforms, SDLCALL is defined to nothing, so compilers won't be able to + * warn that the tag is missing. + * + * This symbol is used in SDL's headers, but apps and other libraries are + * welcome to use it for their own interfaces as well. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDLCALL __cdecl + +/** + * A macro to request a function be inlined. + * + * This is a hint to the compiler to inline a function. The compiler is free + * to ignore this request. On compilers without inline support, this is + * defined to nothing. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_INLINE __inline + +/** + * A macro to demand a function be inlined. + * + * This is a command to the compiler to inline a function. SDL uses this macro + * in its public headers for a handful of simple functions. On compilers + * without forceinline support, this is defined to `static SDL_INLINE`, which + * is often good enough. + * + * This symbol is used in SDL's headers, but apps and other libraries are + * welcome to use it for their own interfaces as well. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_FORCE_INLINE __forceinline + +/** + * A macro to tag a function as never-returning. + * + * This is a hint to the compiler that a function does not return. An example + * of a function like this is the C runtime's exit() function. + * + * This hint can lead to code optimizations, and help analyzers understand + * code flow better. On compilers without noreturn support, this is defined to + * nothing. + * + * This symbol is used in SDL's headers, but apps and other libraries are + * welcome to use it for their own interfaces as well. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_NORETURN __attribute__((noreturn)) + +/** + * A macro to tag a function as never-returning (for analysis purposes). + * + * This is almost identical to SDL_NORETURN, except functions marked with this + * _can_ actually return. The difference is that this isn't used for code + * generation, but rather static analyzers use this information to assume + * truths about program state and available code paths. Specifically, this tag + * is useful for writing an assertion mechanism. Indeed, SDL_assert uses this + * tag behind the scenes. Generally, apps that don't understand the specific + * use-case for this tag should avoid using it directly. + * + * On compilers without analyzer_noreturn support, this is defined to nothing. + * + * This symbol is used in SDL's headers, but apps and other libraries are + * welcome to use it for their own interfaces as well. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_ANALYZER_NORETURN __attribute__((analyzer_noreturn)) + + +/** + * A macro to signal that a case statement without a `break` is intentional. + * + * C compilers have gotten more aggressive about warning when a switch's + * `case` block does not end with a `break` or other flow control statement, + * flowing into the next case's code, as this is a common accident that leads + * to strange bugs. But sometimes falling through to the next case is the + * correct and desired behavior. This symbol lets an app communicate this + * intention to the compiler, so it doesn't generate a warning. + * + * It is used like this: + * + * ```c + * switch (x) { + * case 1: + * DoSomethingOnlyForOne(); + * SDL_FALLTHROUGH; // tell the compiler this was intentional. + * case 2: + * DoSomethingForOneAndTwo(); + * break; + * } + * ``` + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_FALLTHROUGH [[fallthrough]] + +/** + * A macro to tag a function's return value as critical. + * + * This is a hint to the compiler that a function's return value should not be + * ignored. + * + * If an NODISCARD function's return value is thrown away (the function is + * called as if it returns `void`), the compiler will issue a warning. + * + * While it's generally good practice to check return values for errors, often + * times legitimate programs do not for good reasons. Be careful about what + * functions are tagged as NODISCARD. It operates best when used on a function + * that's failure is surprising and catastrophic; a good example would be a + * program that checks the return values of all its file write function calls + * but not the call to close the file, which it assumes incorrectly never + * fails. + * + * Function callers that want to throw away a NODISCARD return value can call + * the function with a `(void)` cast, which informs the compiler the act is + * intentional. + * + * On compilers without nodiscard support, this is defined to nothing. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_NODISCARD [[nodiscard]] + +/** + * A macro to tag a function as an allocator. + * + * This is a hint to the compiler that a function is an allocator, like + * malloc(), with certain rules. A description of how GCC treats this hint is + * here: + * + * https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-malloc-function-attribute + * + * On compilers without allocator tag support, this is defined to nothing. + * + * Most apps don't need to, and should not, use this directly. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_MALLOC __declspec(allocator) __desclspec(restrict) + +/** + * A macro to tag a function as returning a certain allocation. + * + * This is a hint to the compiler that a function allocates and returns a + * specific amount of memory based on one of its arguments. For example, the C + * runtime's malloc() function could use this macro with an argument of 1 + * (first argument to malloc is the size of the allocation). + * + * On compilers without alloc_size support, this is defined to nothing. + * + * Most apps don't need to, and should not, use this directly. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_ALLOC_SIZE(p) __attribute__((alloc_size(p))) + +/** + * A macro to tag a pointer variable, to help with pointer aliasing. + * + * A good explanation of the restrict keyword is here: + * + * https://en.wikipedia.org/wiki/Restrict + * + * On compilers without restrict support, this is defined to nothing. + * + * \since This macro is available since SDL 3.4.0. + */ +#define SDL_RESTRICT __restrict + +/** + * Check if the compiler supports a given builtin functionality. + * + * This allows preprocessor checks for things that otherwise might fail to + * compile. + * + * Supported by virtually all clang versions and more-recent GCCs. Use this + * instead of checking the clang version if possible. + * + * On compilers without has_builtin support, this is defined to 0 (always + * false). + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_HAS_BUILTIN(x) __has_builtin(x) + +/** + * A macro to specify data alignment. + * + * This informs the compiler that a given datatype or variable must be aligned + * to a specific byte count. + * + * For example: + * + * ```c + * // make sure this is struct is aligned to 16 bytes for SIMD access. + * typedef struct { + * float x, y, z, w; + * } SDL_ALIGNED(16) MySIMDAlignedData; + * + * // make sure this one field in a struct is aligned to 16 bytes for SIMD access. + * typedef struct { + * SomeStuff stuff; + * float SDL_ALIGNED(16) position[4]; + * SomeOtherStuff other_stuff; + * } MyStruct; + * + * // make sure this variable is aligned to 32 bytes. + * int SDL_ALIGNED(32) myval = 0; + * ``` + * + * Alignment is only guaranteed for things the compiler places: local + * variables on the stack and global/static variables. To dynamically allocate + * something that respects this alignment, use SDL_aligned_alloc() or some + * other mechanism. + * + * On compilers without alignment support, this macro is defined to an invalid + * symbol, to make it clear that the current compiler is likely to generate + * incorrect code when it sees this macro. + * + * \param x the byte count to align to, so the data's address will be a + * multiple of this value. + * + * \since This macro is available since SDL 3.4.0. + */ +#define SDL_ALIGNED(x) __attribute__((aligned(x))) + +/* end of wiki documentation section. */ +#endif + +/* `restrict` is from C99, but __restrict works with both Visual Studio and GCC. */ +#ifndef SDL_RESTRICT +# if defined(restrict) || ((defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))) +# define SDL_RESTRICT restrict +# elif defined(_MSC_VER) || defined(__GNUC__) || defined(__clang__) +# define SDL_RESTRICT __restrict +# else +# define SDL_RESTRICT +# endif +#endif + +#ifndef SDL_HAS_BUILTIN +#ifdef __has_builtin +#define SDL_HAS_BUILTIN(x) __has_builtin(x) +#else +#define SDL_HAS_BUILTIN(x) 0 +#endif +#endif + +#ifndef SDL_DEPRECATED +# if defined(__GNUC__) && (__GNUC__ >= 4) /* technically, this arrived in gcc 3.1, but oh well. */ +# define SDL_DEPRECATED __attribute__((deprecated)) +# elif defined(_MSC_VER) +# define SDL_DEPRECATED __declspec(deprecated) +# else +# define SDL_DEPRECATED +# endif +#endif + +#ifndef SDL_UNUSED +# ifdef __GNUC__ +# define SDL_UNUSED __attribute__((unused)) +# else +# define SDL_UNUSED +# endif +#endif + +/* Some compilers use a special export keyword */ +#ifndef SDL_DECLSPEC +# if defined(SDL_PLATFORM_WINDOWS) +# ifdef DLL_EXPORT +# define SDL_DECLSPEC __declspec(dllexport) +# else +# define SDL_DECLSPEC +# endif +# else +# if defined(__GNUC__) && __GNUC__ >= 4 +# define SDL_DECLSPEC __attribute__ ((visibility("default"))) +# else +# define SDL_DECLSPEC +# endif +# endif +#endif + +/* By default SDL uses the C calling convention */ +#ifndef SDLCALL +#if defined(SDL_PLATFORM_WINDOWS) && !defined(__GNUC__) +#define SDLCALL __cdecl +#else +#define SDLCALL +#endif +#endif /* SDLCALL */ + +/* Force structure packing at 4 byte alignment. + This is necessary if the header is included in code which has structure + packing set to an alternate value, say for loading structures from disk. + The packing is reset to the previous value in SDL_close_code.h + */ +#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__) +#ifdef _MSC_VER +#pragma warning(disable: 4103) +#endif +#ifdef __clang__ +#pragma clang diagnostic ignored "-Wpragma-pack" +#endif +#ifdef __BORLANDC__ +#pragma nopackwarning +#endif +#ifdef _WIN64 +/* Use 8-byte alignment on 64-bit architectures, so pointers are aligned */ +#pragma pack(push,8) +#else +#pragma pack(push,4) +#endif +#endif /* Compiler needs structure packing set */ + +#ifndef SDL_INLINE +#ifdef __GNUC__ +#define SDL_INLINE __inline__ +#elif defined(_MSC_VER) || defined(__BORLANDC__) || \ + defined(__DMC__) || defined(__SC__) || \ + defined(__WATCOMC__) || defined(__LCC__) || \ + defined(__DECC) || defined(__CC_ARM) +#define SDL_INLINE __inline +#ifndef __inline__ +#define __inline__ __inline +#endif +#else +#define SDL_INLINE inline +#ifndef __inline__ +#define __inline__ inline +#endif +#endif +#endif /* SDL_INLINE not defined */ + +#ifndef SDL_FORCE_INLINE +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +#define SDL_FORCE_INLINE __forceinline +#elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) ) +#define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__ +#else +#define SDL_FORCE_INLINE static SDL_INLINE +#endif +#endif /* SDL_FORCE_INLINE not defined */ + +#ifndef SDL_NORETURN +#if defined(__GNUC__) +#define SDL_NORETURN __attribute__((noreturn)) +#elif defined(_MSC_VER) +#define SDL_NORETURN __declspec(noreturn) +#else +#define SDL_NORETURN +#endif +#endif /* SDL_NORETURN not defined */ + +#ifdef __clang__ +#if __has_feature(attribute_analyzer_noreturn) +#define SDL_ANALYZER_NORETURN __attribute__((analyzer_noreturn)) +#endif +#endif + +#ifndef SDL_ANALYZER_NORETURN +#define SDL_ANALYZER_NORETURN +#endif + +/* Apparently this is needed by several Windows compilers */ +#ifndef __MACH__ +#ifndef NULL +#ifdef __cplusplus +#define NULL 0 +#else +#define NULL ((void *)0) +#endif +#endif /* NULL */ +#endif /* ! macOS - breaks precompiled headers */ + +#ifndef SDL_FALLTHROUGH +#if (defined(__cplusplus) && __cplusplus >= 201703L) || \ + (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000L) +#define SDL_FALLTHROUGH [[fallthrough]] +#else +#if defined(__has_attribute) && !defined(__SUNPRO_C) && !defined(__SUNPRO_CC) +#define SDL_HAS_FALLTHROUGH __has_attribute(__fallthrough__) +#else +#define SDL_HAS_FALLTHROUGH 0 +#endif /* __has_attribute */ +#if SDL_HAS_FALLTHROUGH && \ + ((defined(__GNUC__) && __GNUC__ >= 7) || \ + (defined(__clang_major__) && __clang_major__ >= 10)) +#define SDL_FALLTHROUGH __attribute__((__fallthrough__)) +#else +#define SDL_FALLTHROUGH do {} while (0) /* fallthrough */ +#endif /* SDL_HAS_FALLTHROUGH */ +#undef SDL_HAS_FALLTHROUGH +#endif /* C++17 or C2x */ +#endif /* SDL_FALLTHROUGH not defined */ + +#ifndef SDL_NODISCARD +#if (defined(__cplusplus) && __cplusplus >= 201703L) || \ + (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) +#define SDL_NODISCARD [[nodiscard]] +#elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) ) +#define SDL_NODISCARD __attribute__((warn_unused_result)) +#elif defined(_MSC_VER) && (_MSC_VER >= 1700) +#define SDL_NODISCARD _Check_return_ +#else +#define SDL_NODISCARD +#endif /* C++17 or C23 */ +#endif /* SDL_NODISCARD not defined */ + +#ifndef SDL_MALLOC +#if defined(__GNUC__) && (__GNUC__ >= 3) +#define SDL_MALLOC __attribute__((malloc)) +/** FIXME +#elif defined(_MSC_VER) +#define SDL_MALLOC __declspec(allocator) __desclspec(restrict) +**/ +#else +#define SDL_MALLOC +#endif +#endif /* SDL_MALLOC not defined */ + +#ifndef SDL_ALLOC_SIZE +#if (defined(__clang__) && __clang_major__ >= 4) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) +#define SDL_ALLOC_SIZE(p) __attribute__((alloc_size(p))) +#elif defined(_MSC_VER) +#define SDL_ALLOC_SIZE(p) +#else +#define SDL_ALLOC_SIZE(p) +#endif +#endif /* SDL_ALLOC_SIZE not defined */ + +#ifndef SDL_ALLOC_SIZE2 +#if (defined(__clang__) && __clang_major__ >= 4) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) +#define SDL_ALLOC_SIZE2(p1, p2) __attribute__((alloc_size(p1, p2))) +#elif defined(_MSC_VER) +#define SDL_ALLOC_SIZE2(p1, p2) +#else +#define SDL_ALLOC_SIZE2(p1, p2) +#endif +#endif /* SDL_ALLOC_SIZE2 not defined */ + +#ifndef SDL_ALIGNED +#if defined(__clang__) || defined(__GNUC__) +#define SDL_ALIGNED(x) __attribute__((aligned(x))) +#elif defined(_MSC_VER) +#define SDL_ALIGNED(x) __declspec(align(x)) +#elif defined(__cplusplus) && (__cplusplus >= 201103L) +#define SDL_ALIGNED(x) alignas(x) +#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) +#define SDL_ALIGNED(x) _Alignas(x) +#else +#define SDL_ALIGNED(x) PLEASE_DEFINE_SDL_ALIGNED +#endif +#endif /* SDL_ALIGNED not defined */ + diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_bits.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_bits.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,147 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * # CategoryBits + * + * Functions for fiddling with bits and bitmasks. + */ + +#ifndef SDL_bits_h_ +#define SDL_bits_h_ + +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(__WATCOMC__) && defined(__386__) +extern __inline int _SDL_bsr_watcom(Uint32); +#pragma aux _SDL_bsr_watcom = \ + "bsr eax, eax" \ + parm [eax] nomemory \ + value [eax] \ + modify exact [eax] nomemory; +#endif + +/** + * Get the index of the most significant (set) bit in a 32-bit number. + * + * Result is undefined when called with 0. This operation can also be stated + * as "count leading zeroes" and "log base 2". + * + * Note that this is a forced-inline function in a header, and not a public + * API function available in the SDL library (which is to say, the code is + * embedded in the calling program and the linker and dynamic loader will not + * be able to find this function inside SDL itself). + * + * \param x the 32-bit value to examine. + * \returns the index of the most significant bit, or -1 if the value is 0. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +SDL_FORCE_INLINE int SDL_MostSignificantBitIndex32(Uint32 x) +{ +#if defined(__GNUC__) && (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) + /* Count Leading Zeroes builtin in GCC. + * http://gcc.gnu.org/onlinedocs/gcc-4.3.4/gcc/Other-Builtins.html + */ + if (x == 0) { + return -1; + } + return 31 - __builtin_clz(x); +#elif defined(__WATCOMC__) && defined(__386__) + if (x == 0) { + return -1; + } + return _SDL_bsr_watcom(x); +#elif defined(_MSC_VER) && _MSC_VER >= 1400 + unsigned long index; + if (_BitScanReverse(&index, x)) { + return (int)index; + } + return -1; +#else + /* Based off of Bit Twiddling Hacks by Sean Eron Anderson + * , released in the public domain. + * http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog + */ + const Uint32 b[] = {0x2, 0xC, 0xF0, 0xFF00, 0xFFFF0000}; + const int S[] = {1, 2, 4, 8, 16}; + + int msbIndex = 0; + int i; + + if (x == 0) { + return -1; + } + + for (i = 4; i >= 0; i--) + { + if (x & b[i]) + { + x >>= S[i]; + msbIndex |= S[i]; + } + } + + return msbIndex; +#endif +} + +/** + * Determine if a unsigned 32-bit value has exactly one bit set. + * + * If there are no bits set (`x` is zero), or more than one bit set, this + * returns false. If any one bit is exclusively set, this returns true. + * + * Note that this is a forced-inline function in a header, and not a public + * API function available in the SDL library (which is to say, the code is + * embedded in the calling program and the linker and dynamic loader will not + * be able to find this function inside SDL itself). + * + * \param x the 32-bit value to examine. + * \returns true if exactly one bit is set in `x`, false otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +SDL_FORCE_INLINE bool SDL_HasExactlyOneBitSet32(Uint32 x) +{ + if (x && !(x & (x - 1))) { + return true; + } + return false; +} + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_bits_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_blendmode.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_blendmode.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,202 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * # CategoryBlendmode + * + * Blend modes decide how two colors will mix together. There are both + * standard modes for basic needs and a means to create custom modes, + * dictating what sort of math to do on what color components. + */ + +#ifndef SDL_blendmode_h_ +#define SDL_blendmode_h_ + +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * A set of blend modes used in drawing operations. + * + * These predefined blend modes are supported everywhere. + * + * Additional values may be obtained from SDL_ComposeCustomBlendMode. + * + * \since This datatype is available since SDL 3.2.0. + * + * \sa SDL_ComposeCustomBlendMode + */ +typedef Uint32 SDL_BlendMode; + +#define SDL_BLENDMODE_NONE 0x00000000u /**< no blending: dstRGBA = srcRGBA */ +#define SDL_BLENDMODE_BLEND 0x00000001u /**< alpha blending: dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA)), dstA = srcA + (dstA * (1-srcA)) */ +#define SDL_BLENDMODE_BLEND_PREMULTIPLIED 0x00000010u /**< pre-multiplied alpha blending: dstRGBA = srcRGBA + (dstRGBA * (1-srcA)) */ +#define SDL_BLENDMODE_ADD 0x00000002u /**< additive blending: dstRGB = (srcRGB * srcA) + dstRGB, dstA = dstA */ +#define SDL_BLENDMODE_ADD_PREMULTIPLIED 0x00000020u /**< pre-multiplied additive blending: dstRGB = srcRGB + dstRGB, dstA = dstA */ +#define SDL_BLENDMODE_MOD 0x00000004u /**< color modulate: dstRGB = srcRGB * dstRGB, dstA = dstA */ +#define SDL_BLENDMODE_MUL 0x00000008u /**< color multiply: dstRGB = (srcRGB * dstRGB) + (dstRGB * (1-srcA)), dstA = dstA */ +#define SDL_BLENDMODE_INVALID 0x7FFFFFFFu + +/** + * The blend operation used when combining source and destination pixel + * components. + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_BlendOperation +{ + SDL_BLENDOPERATION_ADD = 0x1, /**< dst + src: supported by all renderers */ + SDL_BLENDOPERATION_SUBTRACT = 0x2, /**< src - dst : supported by D3D, OpenGL, OpenGLES, and Vulkan */ + SDL_BLENDOPERATION_REV_SUBTRACT = 0x3, /**< dst - src : supported by D3D, OpenGL, OpenGLES, and Vulkan */ + SDL_BLENDOPERATION_MINIMUM = 0x4, /**< min(dst, src) : supported by D3D, OpenGL, OpenGLES, and Vulkan */ + SDL_BLENDOPERATION_MAXIMUM = 0x5 /**< max(dst, src) : supported by D3D, OpenGL, OpenGLES, and Vulkan */ +} SDL_BlendOperation; + +/** + * The normalized factor used to multiply pixel components. + * + * The blend factors are multiplied with the pixels from a drawing operation + * (src) and the pixels from the render target (dst) before the blend + * operation. The comma-separated factors listed above are always applied in + * the component order red, green, blue, and alpha. + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_BlendFactor +{ + SDL_BLENDFACTOR_ZERO = 0x1, /**< 0, 0, 0, 0 */ + SDL_BLENDFACTOR_ONE = 0x2, /**< 1, 1, 1, 1 */ + SDL_BLENDFACTOR_SRC_COLOR = 0x3, /**< srcR, srcG, srcB, srcA */ + SDL_BLENDFACTOR_ONE_MINUS_SRC_COLOR = 0x4, /**< 1-srcR, 1-srcG, 1-srcB, 1-srcA */ + SDL_BLENDFACTOR_SRC_ALPHA = 0x5, /**< srcA, srcA, srcA, srcA */ + SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA = 0x6, /**< 1-srcA, 1-srcA, 1-srcA, 1-srcA */ + SDL_BLENDFACTOR_DST_COLOR = 0x7, /**< dstR, dstG, dstB, dstA */ + SDL_BLENDFACTOR_ONE_MINUS_DST_COLOR = 0x8, /**< 1-dstR, 1-dstG, 1-dstB, 1-dstA */ + SDL_BLENDFACTOR_DST_ALPHA = 0x9, /**< dstA, dstA, dstA, dstA */ + SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA = 0xA /**< 1-dstA, 1-dstA, 1-dstA, 1-dstA */ +} SDL_BlendFactor; + +/** + * Compose a custom blend mode for renderers. + * + * The functions SDL_SetRenderDrawBlendMode and SDL_SetTextureBlendMode accept + * the SDL_BlendMode returned by this function if the renderer supports it. + * + * A blend mode controls how the pixels from a drawing operation (source) get + * combined with the pixels from the render target (destination). First, the + * components of the source and destination pixels get multiplied with their + * blend factors. Then, the blend operation takes the two products and + * calculates the result that will get stored in the render target. + * + * Expressed in pseudocode, it would look like this: + * + * ```c + * dstRGB = colorOperation(srcRGB * srcColorFactor, dstRGB * dstColorFactor); + * dstA = alphaOperation(srcA * srcAlphaFactor, dstA * dstAlphaFactor); + * ``` + * + * Where the functions `colorOperation(src, dst)` and `alphaOperation(src, + * dst)` can return one of the following: + * + * - `src + dst` + * - `src - dst` + * - `dst - src` + * - `min(src, dst)` + * - `max(src, dst)` + * + * The red, green, and blue components are always multiplied with the first, + * second, and third components of the SDL_BlendFactor, respectively. The + * fourth component is not used. + * + * The alpha component is always multiplied with the fourth component of the + * SDL_BlendFactor. The other components are not used in the alpha + * calculation. + * + * Support for these blend modes varies for each renderer. To check if a + * specific SDL_BlendMode is supported, create a renderer and pass it to + * either SDL_SetRenderDrawBlendMode or SDL_SetTextureBlendMode. They will + * return with an error if the blend mode is not supported. + * + * This list describes the support of custom blend modes for each renderer. + * All renderers support the four blend modes listed in the SDL_BlendMode + * enumeration. + * + * - **direct3d**: Supports all operations with all factors. However, some + * factors produce unexpected results with `SDL_BLENDOPERATION_MINIMUM` and + * `SDL_BLENDOPERATION_MAXIMUM`. + * - **direct3d11**: Same as Direct3D 9. + * - **opengl**: Supports the `SDL_BLENDOPERATION_ADD` operation with all + * factors. OpenGL versions 1.1, 1.2, and 1.3 do not work correctly here. + * - **opengles2**: Supports the `SDL_BLENDOPERATION_ADD`, + * `SDL_BLENDOPERATION_SUBTRACT`, `SDL_BLENDOPERATION_REV_SUBTRACT` + * operations with all factors. + * - **psp**: No custom blend mode support. + * - **software**: No custom blend mode support. + * + * Some renderers do not provide an alpha component for the default render + * target. The `SDL_BLENDFACTOR_DST_ALPHA` and + * `SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA` factors do not have an effect in this + * case. + * + * \param srcColorFactor the SDL_BlendFactor applied to the red, green, and + * blue components of the source pixels. + * \param dstColorFactor the SDL_BlendFactor applied to the red, green, and + * blue components of the destination pixels. + * \param colorOperation the SDL_BlendOperation used to combine the red, + * green, and blue components of the source and + * destination pixels. + * \param srcAlphaFactor the SDL_BlendFactor applied to the alpha component of + * the source pixels. + * \param dstAlphaFactor the SDL_BlendFactor applied to the alpha component of + * the destination pixels. + * \param alphaOperation the SDL_BlendOperation used to combine the alpha + * component of the source and destination pixels. + * \returns an SDL_BlendMode that represents the chosen factors and + * operations. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetRenderDrawBlendMode + * \sa SDL_GetRenderDrawBlendMode + * \sa SDL_SetTextureBlendMode + * \sa SDL_GetTextureBlendMode + */ +extern SDL_DECLSPEC SDL_BlendMode SDLCALL SDL_ComposeCustomBlendMode(SDL_BlendFactor srcColorFactor, + SDL_BlendFactor dstColorFactor, + SDL_BlendOperation colorOperation, + SDL_BlendFactor srcAlphaFactor, + SDL_BlendFactor dstAlphaFactor, + SDL_BlendOperation alphaOperation); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_blendmode_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_camera.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_camera.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,535 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * # CategoryCamera + * + * Video capture for the SDL library. + * + * This API lets apps read input from video sources, like webcams. Camera + * devices can be enumerated, queried, and opened. Once opened, it will + * provide SDL_Surface objects as new frames of video come in. These surfaces + * can be uploaded to an SDL_Texture or processed as pixels in memory. + * + * Several platforms will alert the user if an app tries to access a camera, + * and some will present a UI asking the user if your application should be + * allowed to obtain images at all, which they can deny. A successfully opened + * camera will not provide images until permission is granted. Applications, + * after opening a camera device, can see if they were granted access by + * either polling with the SDL_GetCameraPermissionState() function, or waiting + * for an SDL_EVENT_CAMERA_DEVICE_APPROVED or SDL_EVENT_CAMERA_DEVICE_DENIED + * event. Platforms that don't have any user approval process will report + * approval immediately. + * + * Note that SDL cameras only provide video as individual frames; they will + * not provide full-motion video encoded in a movie file format, although an + * app is free to encode the acquired frames into any format it likes. It also + * does not provide audio from the camera hardware through this API; not only + * do many webcams not have microphones at all, many people--from streamers to + * people on Zoom calls--will want to use a separate microphone regardless of + * the camera. In any case, recorded audio will be available through SDL's + * audio API no matter what hardware provides the microphone. + * + * ## Camera gotchas + * + * Consumer-level camera hardware tends to take a little while to warm up, + * once the device has been opened. Generally most camera apps have some sort + * of UI to take a picture (a button to snap a pic while a preview is showing, + * some sort of multi-second countdown for the user to pose, like a photo + * booth), which puts control in the users' hands, or they are intended to + * stay on for long times (Pokemon Go, etc). + * + * It's not uncommon that a newly-opened camera will provide a couple of + * completely black frames, maybe followed by some under-exposed images. If + * taking a single frame automatically, or recording video from a camera's + * input without the user initiating it from a preview, it could be wise to + * drop the first several frames (if not the first several _seconds_ worth of + * frames!) before using images from a camera. + */ + +#ifndef SDL_camera_h_ +#define SDL_camera_h_ + +#include +#include +#include +#include +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * This is a unique ID for a camera device for the time it is connected to the + * system, and is never reused for the lifetime of the application. + * + * If the device is disconnected and reconnected, it will get a new ID. + * + * The value 0 is an invalid ID. + * + * \since This datatype is available since SDL 3.2.0. + * + * \sa SDL_GetCameras + */ +typedef Uint32 SDL_CameraID; + +/** + * The opaque structure used to identify an opened SDL camera. + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_Camera SDL_Camera; + +/** + * The details of an output format for a camera device. + * + * Cameras often support multiple formats; each one will be encapsulated in + * this struct. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_GetCameraSupportedFormats + * \sa SDL_GetCameraFormat + */ +typedef struct SDL_CameraSpec +{ + SDL_PixelFormat format; /**< Frame format */ + SDL_Colorspace colorspace; /**< Frame colorspace */ + int width; /**< Frame width */ + int height; /**< Frame height */ + int framerate_numerator; /**< Frame rate numerator ((num / denom) == FPS, (denom / num) == duration in seconds) */ + int framerate_denominator; /**< Frame rate denominator ((num / denom) == FPS, (denom / num) == duration in seconds) */ +} SDL_CameraSpec; + +/** + * The position of camera in relation to system device. + * + * \since This enum is available since SDL 3.2.0. + * + * \sa SDL_GetCameraPosition + */ +typedef enum SDL_CameraPosition +{ + SDL_CAMERA_POSITION_UNKNOWN, + SDL_CAMERA_POSITION_FRONT_FACING, + SDL_CAMERA_POSITION_BACK_FACING +} SDL_CameraPosition; + +/** + * The current state of a request for camera access. + * + * \since This enum is available since SDL 3.4.0. + * + * \sa SDL_GetCameraPermissionState + */ +typedef enum SDL_CameraPermissionState +{ + SDL_CAMERA_PERMISSION_STATE_DENIED = -1, + SDL_CAMERA_PERMISSION_STATE_PENDING, + SDL_CAMERA_PERMISSION_STATE_APPROVED, +} SDL_CameraPermissionState; + + +/** + * Use this function to get the number of built-in camera drivers. + * + * This function returns a hardcoded number. This never returns a negative + * value; if there are no drivers compiled into this build of SDL, this + * function returns zero. The presence of a driver in this list does not mean + * it will function, it just means SDL is capable of interacting with that + * interface. For example, a build of SDL might have v4l2 support, but if + * there's no kernel support available, SDL's v4l2 driver would fail if used. + * + * By default, SDL tries all drivers, in its preferred order, until one is + * found to be usable. + * + * \returns the number of built-in camera drivers. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetCameraDriver + */ +extern SDL_DECLSPEC int SDLCALL SDL_GetNumCameraDrivers(void); + +/** + * Use this function to get the name of a built in camera driver. + * + * The list of camera drivers is given in the order that they are normally + * initialized by default; the drivers that seem more reasonable to choose + * first (as far as the SDL developers believe) are earlier in the list. + * + * The names of drivers are all simple, low-ASCII identifiers, like "v4l2", + * "coremedia" or "android". These never have Unicode characters, and are not + * meant to be proper names. + * + * \param index the index of the camera driver; the value ranges from 0 to + * SDL_GetNumCameraDrivers() - 1. + * \returns the name of the camera driver at the requested index, or NULL if + * an invalid index was specified. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetNumCameraDrivers + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetCameraDriver(int index); + +/** + * Get the name of the current camera driver. + * + * The names of drivers are all simple, low-ASCII identifiers, like "v4l2", + * "coremedia" or "android". These never have Unicode characters, and are not + * meant to be proper names. + * + * \returns the name of the current camera driver or NULL if no driver has + * been initialized. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetCurrentCameraDriver(void); + +/** + * Get a list of currently connected camera devices. + * + * \param count a pointer filled in with the number of cameras returned, may + * be NULL. + * \returns a 0 terminated array of camera instance IDs or NULL on failure; + * call SDL_GetError() for more information. This should be freed + * with SDL_free() when it is no longer needed. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_OpenCamera + */ +extern SDL_DECLSPEC SDL_CameraID * SDLCALL SDL_GetCameras(int *count); + +/** + * Get the list of native formats/sizes a camera supports. + * + * This returns a list of all formats and frame sizes that a specific camera + * can offer. This is useful if your app can accept a variety of image formats + * and sizes and so want to find the optimal spec that doesn't require + * conversion. + * + * This function isn't strictly required; if you call SDL_OpenCamera with a + * NULL spec, SDL will choose a native format for you, and if you instead + * specify a desired format, it will transparently convert to the requested + * format on your behalf. + * + * If `count` is not NULL, it will be filled with the number of elements in + * the returned array. + * + * Note that it's legal for a camera to supply an empty list. This is what + * will happen on Emscripten builds, since that platform won't tell _anything_ + * about available cameras until you've opened one, and won't even tell if + * there _is_ a camera until the user has given you permission to check + * through a scary warning popup. + * + * \param instance_id the camera device instance ID. + * \param count a pointer filled in with the number of elements in the list, + * may be NULL. + * \returns a NULL terminated array of pointers to SDL_CameraSpec or NULL on + * failure; call SDL_GetError() for more information. This is a + * single allocation that should be freed with SDL_free() when it is + * no longer needed. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetCameras + * \sa SDL_OpenCamera + */ +extern SDL_DECLSPEC SDL_CameraSpec ** SDLCALL SDL_GetCameraSupportedFormats(SDL_CameraID instance_id, int *count); + +/** + * Get the human-readable device name for a camera. + * + * \param instance_id the camera device instance ID. + * \returns a human-readable device name or NULL on failure; call + * SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetCameras + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetCameraName(SDL_CameraID instance_id); + +/** + * Get the position of the camera in relation to the system. + * + * Most platforms will report UNKNOWN, but mobile devices, like phones, can + * often make a distinction between cameras on the front of the device (that + * points towards the user, for taking "selfies") and cameras on the back (for + * filming in the direction the user is facing). + * + * \param instance_id the camera device instance ID. + * \returns the position of the camera on the system hardware. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetCameras + */ +extern SDL_DECLSPEC SDL_CameraPosition SDLCALL SDL_GetCameraPosition(SDL_CameraID instance_id); + +/** + * Open a video recording device (a "camera"). + * + * You can open the device with any reasonable spec, and if the hardware can't + * directly support it, it will convert data seamlessly to the requested + * format. This might incur overhead, including scaling of image data. + * + * If you would rather accept whatever format the device offers, you can pass + * a NULL spec here and it will choose one for you (and you can use + * SDL_Surface's conversion/scaling functions directly if necessary). + * + * You can call SDL_GetCameraFormat() to get the actual data format if passing + * a NULL spec here. You can see the exact specs a device can support without + * conversion with SDL_GetCameraSupportedFormats(). + * + * SDL will not attempt to emulate framerate; it will try to set the hardware + * to the rate closest to the requested speed, but it won't attempt to limit + * or duplicate frames artificially; call SDL_GetCameraFormat() to see the + * actual framerate of the opened the device, and check your timestamps if + * this is crucial to your app! + * + * Note that the camera is not usable until the user approves its use! On some + * platforms, the operating system will prompt the user to permit access to + * the camera, and they can choose Yes or No at that point. Until they do, the + * camera will not be usable. The app should either wait for an + * SDL_EVENT_CAMERA_DEVICE_APPROVED (or SDL_EVENT_CAMERA_DEVICE_DENIED) event, + * or poll SDL_GetCameraPermissionState() occasionally until it returns + * non-zero. On platforms that don't require explicit user approval (and + * perhaps in places where the user previously permitted access), the approval + * event might come immediately, but it might come seconds, minutes, or hours + * later! + * + * \param instance_id the camera device instance ID. + * \param spec the desired format for data the device will provide. Can be + * NULL. + * \returns an SDL_Camera object or NULL on failure; call SDL_GetError() for + * more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetCameras + * \sa SDL_GetCameraFormat + */ +extern SDL_DECLSPEC SDL_Camera * SDLCALL SDL_OpenCamera(SDL_CameraID instance_id, const SDL_CameraSpec *spec); + +/** + * Query if camera access has been approved by the user. + * + * Cameras will not function between when the device is opened by the app and + * when the user permits access to the hardware. On some platforms, this + * presents as a popup dialog where the user has to explicitly approve access; + * on others the approval might be implicit and not alert the user at all. + * + * This function can be used to check the status of that approval. It will + * return SDL_CAMERA_PERMISSION_STATE_PENDING if waiting for user response, + * SDL_CAMERA_PERMISSION_STATE_APPROVED if the camera is approved for use, and + * SDL_CAMERA_PERMISSION_STATE_DENIED if the user denied access. + * + * Instead of polling with this function, you can wait for a + * SDL_EVENT_CAMERA_DEVICE_APPROVED (or SDL_EVENT_CAMERA_DEVICE_DENIED) event + * in the standard SDL event loop, which is guaranteed to be sent once when + * permission to use the camera is decided. + * + * If a camera is declined, there's nothing to be done but call + * SDL_CloseCamera() to dispose of it. + * + * \param camera the opened camera device to query. + * \returns an SDL_CameraPermissionState value indicating if access is + * granted, or `SDL_CAMERA_PERMISSION_STATE_PENDING` if the decision + * is still pending. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_OpenCamera + * \sa SDL_CloseCamera + */ +extern SDL_DECLSPEC SDL_CameraPermissionState SDLCALL SDL_GetCameraPermissionState(SDL_Camera *camera); + +/** + * Get the instance ID of an opened camera. + * + * \param camera an SDL_Camera to query. + * \returns the instance ID of the specified camera on success or 0 on + * failure; call SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_OpenCamera + */ +extern SDL_DECLSPEC SDL_CameraID SDLCALL SDL_GetCameraID(SDL_Camera *camera); + +/** + * Get the properties associated with an opened camera. + * + * \param camera the SDL_Camera obtained from SDL_OpenCamera(). + * \returns a valid property ID on success or 0 on failure; call + * SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetCameraProperties(SDL_Camera *camera); + +/** + * Get the spec that a camera is using when generating images. + * + * Note that this might not be the native format of the hardware, as SDL might + * be converting to this format behind the scenes. + * + * If the system is waiting for the user to approve access to the camera, as + * some platforms require, this will return false, but this isn't necessarily + * a fatal error; you should either wait for an + * SDL_EVENT_CAMERA_DEVICE_APPROVED (or SDL_EVENT_CAMERA_DEVICE_DENIED) event, + * or poll SDL_GetCameraPermissionState() occasionally until it returns + * non-zero. + * + * \param camera opened camera device. + * \param spec the SDL_CameraSpec to be initialized by this function. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_OpenCamera + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetCameraFormat(SDL_Camera *camera, SDL_CameraSpec *spec); + +/** + * Acquire a frame. + * + * The frame is a memory pointer to the image data, whose size and format are + * given by the spec requested when opening the device. + * + * This is a non blocking API. If there is a frame available, a non-NULL + * surface is returned, and timestampNS will be filled with a non-zero value. + * + * Note that an error case can also return NULL, but a NULL by itself is + * normal and just signifies that a new frame is not yet available. Note that + * even if a camera device fails outright (a USB camera is unplugged while in + * use, etc), SDL will send an event separately to notify the app, but + * continue to provide blank frames at ongoing intervals until + * SDL_CloseCamera() is called, so real failure here is almost always an out + * of memory condition. + * + * After use, the frame should be released with SDL_ReleaseCameraFrame(). If + * you don't do this, the system may stop providing more video! + * + * Do not call SDL_DestroySurface() on the returned surface! It must be given + * back to the camera subsystem with SDL_ReleaseCameraFrame! + * + * If the system is waiting for the user to approve access to the camera, as + * some platforms require, this will return NULL (no frames available); you + * should either wait for an SDL_EVENT_CAMERA_DEVICE_APPROVED (or + * SDL_EVENT_CAMERA_DEVICE_DENIED) event, or poll + * SDL_GetCameraPermissionState() occasionally until it returns non-zero. + * + * \param camera opened camera device. + * \param timestampNS a pointer filled in with the frame's timestamp, or 0 on + * error. Can be NULL. + * \returns a new frame of video on success, NULL if none is currently + * available. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_ReleaseCameraFrame + */ +extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_AcquireCameraFrame(SDL_Camera *camera, Uint64 *timestampNS); + +/** + * Release a frame of video acquired from a camera. + * + * Let the back-end re-use the internal buffer for camera. + * + * This function _must_ be called only on surface objects returned by + * SDL_AcquireCameraFrame(). This function should be called as quickly as + * possible after acquisition, as SDL keeps a small FIFO queue of surfaces for + * video frames; if surfaces aren't released in a timely manner, SDL may drop + * upcoming video frames from the camera. + * + * If the app needs to keep the surface for a significant time, they should + * make a copy of it and release the original. + * + * The app should not use the surface again after calling this function; + * assume the surface is freed and the pointer is invalid. + * + * \param camera opened camera device. + * \param frame the video frame surface to release. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_AcquireCameraFrame + */ +extern SDL_DECLSPEC void SDLCALL SDL_ReleaseCameraFrame(SDL_Camera *camera, SDL_Surface *frame); + +/** + * Use this function to shut down camera processing and close the camera + * device. + * + * \param camera opened camera device. + * + * \threadsafety It is safe to call this function from any thread, but no + * thread may reference `device` once this function is called. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_OpenCamera + */ +extern SDL_DECLSPEC void SDLCALL SDL_CloseCamera(SDL_Camera *camera); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_camera_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_clipboard.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_clipboard.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,331 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * # CategoryClipboard + * + * SDL provides access to the system clipboard, both for reading information + * from other processes and publishing information of its own. + * + * This is not just text! SDL apps can access and publish data by mimetype. + * + * ## Basic use (text) + * + * Obtaining and publishing simple text to the system clipboard is as easy as + * calling SDL_GetClipboardText() and SDL_SetClipboardText(), respectively. + * These deal with C strings in UTF-8 encoding. Data transmission and encoding + * conversion is completely managed by SDL. + * + * ## Clipboard callbacks (data other than text) + * + * Things get more complicated when the clipboard contains something other + * than text. Not only can the system clipboard contain data of any type, in + * some cases it can contain the same data in different formats! For example, + * an image painting app might let the user copy a graphic to the clipboard, + * and offers it in .BMP, .JPG, or .PNG format for other apps to consume. + * + * Obtaining clipboard data ("pasting") like this is a matter of calling + * SDL_GetClipboardData() and telling it the mimetype of the data you want. + * But how does one know if that format is available? SDL_HasClipboardData() + * can report if a specific mimetype is offered, and + * SDL_GetClipboardMimeTypes() can provide the entire list of mimetypes + * available, so the app can decide what to do with the data and what formats + * it can support. + * + * Setting the clipboard ("copying") to arbitrary data is done with + * SDL_SetClipboardData. The app does not provide the data in this call, but + * rather the mimetypes it is willing to provide and a callback function. + * During the callback, the app will generate the data. This allows massive + * data sets to be provided to the clipboard, without any data being copied + * before it is explicitly requested. More specifically, it allows an app to + * offer data in multiple formats without providing a copy of all of them + * upfront. If the app has an image that it could provide in PNG or JPG + * format, it doesn't have to encode it to either of those unless and until + * something tries to paste it. + * + * ## Primary Selection + * + * The X11 and Wayland video targets have a concept of the "primary selection" + * in addition to the usual clipboard. This is generally highlighted (but not + * explicitly copied) text from various apps. SDL offers APIs for this through + * SDL_GetPrimarySelectionText() and SDL_SetPrimarySelectionText(). SDL offers + * these APIs on platforms without this concept, too, but only so far that it + * will keep a copy of a string that the app sets for later retrieval; the + * operating system will not ever attempt to change the string externally if + * it doesn't support a primary selection. + */ + +#ifndef SDL_clipboard_h_ +#define SDL_clipboard_h_ + +#include +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Function prototypes */ + +/** + * Put UTF-8 text into the clipboard. + * + * \param text the text to store in the clipboard. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetClipboardText + * \sa SDL_HasClipboardText + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetClipboardText(const char *text); + +/** + * Get UTF-8 text from the clipboard. + * + * This function returns an empty string if there is not enough memory left + * for a copy of the clipboard's content. + * + * \returns the clipboard text on success or an empty string on failure; call + * SDL_GetError() for more information. This should be freed with + * SDL_free() when it is no longer needed. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_HasClipboardText + * \sa SDL_SetClipboardText + */ +extern SDL_DECLSPEC char * SDLCALL SDL_GetClipboardText(void); + +/** + * Query whether the clipboard exists and contains a non-empty text string. + * + * \returns true if the clipboard has text, or false if it does not. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetClipboardText + * \sa SDL_SetClipboardText + */ +extern SDL_DECLSPEC bool SDLCALL SDL_HasClipboardText(void); + +/** + * Put UTF-8 text into the primary selection. + * + * \param text the text to store in the primary selection. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetPrimarySelectionText + * \sa SDL_HasPrimarySelectionText + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetPrimarySelectionText(const char *text); + +/** + * Get UTF-8 text from the primary selection. + * + * This function returns an empty string if there is not enough memory left + * for a copy of the primary selection's content. + * + * \returns the primary selection text on success or an empty string on + * failure; call SDL_GetError() for more information. This should be + * freed with SDL_free() when it is no longer needed. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_HasPrimarySelectionText + * \sa SDL_SetPrimarySelectionText + */ +extern SDL_DECLSPEC char * SDLCALL SDL_GetPrimarySelectionText(void); + +/** + * Query whether the primary selection exists and contains a non-empty text + * string. + * + * \returns true if the primary selection has text, or false if it does not. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetPrimarySelectionText + * \sa SDL_SetPrimarySelectionText + */ +extern SDL_DECLSPEC bool SDLCALL SDL_HasPrimarySelectionText(void); + +/** + * Callback function that will be called when data for the specified mime-type + * is requested by the OS. + * + * The callback function is called with NULL as the mime_type when the + * clipboard is cleared or new data is set. The clipboard is automatically + * cleared in SDL_Quit(). + * + * \param userdata a pointer to the provided user data. + * \param mime_type the requested mime-type. + * \param size a pointer filled in with the length of the returned data. + * \returns a pointer to the data for the provided mime-type. Returning NULL + * or setting the length to 0 will cause zero length data to be sent + * to the "receiver", which should be able to handle this. The + * returned data will not be freed, so it needs to be retained and + * dealt with internally. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetClipboardData + */ +typedef const void *(SDLCALL *SDL_ClipboardDataCallback)(void *userdata, const char *mime_type, size_t *size); + +/** + * Callback function that will be called when the clipboard is cleared, or + * when new data is set. + * + * \param userdata a pointer to the provided user data. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetClipboardData + */ +typedef void (SDLCALL *SDL_ClipboardCleanupCallback)(void *userdata); + +/** + * Offer clipboard data to the OS. + * + * Tell the operating system that the application is offering clipboard data + * for each of the provided mime-types. Once another application requests the + * data the callback function will be called, allowing it to generate and + * respond with the data for the requested mime-type. + * + * The size of text data does not include any terminator, and the text does + * not need to be null-terminated (e.g., you can directly copy a portion of a + * document). + * + * \param callback a function pointer to the function that provides the + * clipboard data. + * \param cleanup a function pointer to the function that cleans up the + * clipboard data. + * \param userdata an opaque pointer that will be forwarded to the callbacks. + * \param mime_types a list of mime-types that are being offered. SDL copies + * the given list. + * \param num_mime_types the number of mime-types in the mime_types list. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_ClearClipboardData + * \sa SDL_GetClipboardData + * \sa SDL_HasClipboardData + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetClipboardData(SDL_ClipboardDataCallback callback, SDL_ClipboardCleanupCallback cleanup, void *userdata, const char **mime_types, size_t num_mime_types); + +/** + * Clear the clipboard data. + * + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetClipboardData + */ +extern SDL_DECLSPEC bool SDLCALL SDL_ClearClipboardData(void); + +/** + * Get the data from the clipboard for a given mime type. + * + * The size of text data does not include the terminator, but the text is + * guaranteed to be null-terminated. + * + * \param mime_type the mime type to read from the clipboard. + * \param size a pointer filled in with the length of the returned data. + * \returns the retrieved data buffer or NULL on failure; call SDL_GetError() + * for more information. This should be freed with SDL_free() when it + * is no longer needed. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_HasClipboardData + * \sa SDL_SetClipboardData + */ +extern SDL_DECLSPEC void * SDLCALL SDL_GetClipboardData(const char *mime_type, size_t *size); + +/** + * Query whether there is data in the clipboard for the provided mime type. + * + * \param mime_type the mime type to check for data. + * \returns true if data exists in the clipboard for the provided mime type, + * false if it does not. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetClipboardData + * \sa SDL_GetClipboardData + */ +extern SDL_DECLSPEC bool SDLCALL SDL_HasClipboardData(const char *mime_type); + +/** + * Retrieve the list of mime types available in the clipboard. + * + * \param num_mime_types a pointer filled with the number of mime types, may + * be NULL. + * \returns a null-terminated array of strings with mime types, or NULL on + * failure; call SDL_GetError() for more information. This should be + * freed with SDL_free() when it is no longer needed. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetClipboardData + */ +extern SDL_DECLSPEC char ** SDLCALL SDL_GetClipboardMimeTypes(size_t *num_mime_types); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_clipboard_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_close_code.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_close_code.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,41 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* + * This file reverses the effects of SDL_begin_code.h and should be included + * after you finish any function and structure declarations in your headers. + * + * SDL's headers use this; applications generally should not include this + * header directly. + */ + +#ifndef SDL_begin_code_h +#error SDL_close_code.h included without matching SDL_begin_code.h +#endif +#undef SDL_begin_code_h + +/* Reset structure packing at previous byte alignment */ +#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__) +#ifdef __BORLANDC__ +#pragma nopackwarning +#endif +#pragma pack(pop) +#endif /* Compiler needs structure packing set */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_copying.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_copying.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,22 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* Header file containing SDL's license. */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_cpuinfo.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_cpuinfo.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,374 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* WIKI CATEGORY: CPUInfo */ + +/** + * # CategoryCPUInfo + * + * CPU feature detection for SDL. + * + * These functions are largely concerned with reporting if the system has + * access to various SIMD instruction sets, but also has other important info + * to share, such as system RAM size and number of logical CPU cores. + * + * CPU instruction set checks, like SDL_HasSSE() and SDL_HasNEON(), are + * available on all platforms, even if they don't make sense (an ARM processor + * will never have SSE and an x86 processor will never have NEON, for example, + * but these functions still exist and will simply return false in these + * cases). + */ + +#ifndef SDL_cpuinfo_h_ +#define SDL_cpuinfo_h_ + +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * A guess for the cacheline size used for padding. + * + * Most x86 processors have a 64 byte cache line. The 64-bit PowerPC + * processors have a 128 byte cache line. We use the larger value to be + * generally safe. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_CACHELINE_SIZE 128 + +/** + * Get the number of logical CPU cores available. + * + * \returns the total number of logical CPU cores. On CPUs that include + * technologies such as hyperthreading, the number of logical cores + * may be more than the number of physical cores. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_GetNumLogicalCPUCores(void); + +/** + * Determine the L1 cache line size of the CPU. + * + * This is useful for determining multi-threaded structure padding or SIMD + * prefetch sizes. + * + * \returns the L1 cache line size of the CPU, in bytes. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_GetCPUCacheLineSize(void); + +/** + * Determine whether the CPU has AltiVec features. + * + * This always returns false on CPUs that aren't using PowerPC instruction + * sets. + * + * \returns true if the CPU has AltiVec features or false if not. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_HasAltiVec(void); + +/** + * Determine whether the CPU has MMX features. + * + * This always returns false on CPUs that aren't using Intel instruction sets. + * + * \returns true if the CPU has MMX features or false if not. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_HasMMX(void); + +/** + * Determine whether the CPU has SSE features. + * + * This always returns false on CPUs that aren't using Intel instruction sets. + * + * \returns true if the CPU has SSE features or false if not. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_HasSSE2 + * \sa SDL_HasSSE3 + * \sa SDL_HasSSE41 + * \sa SDL_HasSSE42 + */ +extern SDL_DECLSPEC bool SDLCALL SDL_HasSSE(void); + +/** + * Determine whether the CPU has SSE2 features. + * + * This always returns false on CPUs that aren't using Intel instruction sets. + * + * \returns true if the CPU has SSE2 features or false if not. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_HasSSE + * \sa SDL_HasSSE3 + * \sa SDL_HasSSE41 + * \sa SDL_HasSSE42 + */ +extern SDL_DECLSPEC bool SDLCALL SDL_HasSSE2(void); + +/** + * Determine whether the CPU has SSE3 features. + * + * This always returns false on CPUs that aren't using Intel instruction sets. + * + * \returns true if the CPU has SSE3 features or false if not. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_HasSSE + * \sa SDL_HasSSE2 + * \sa SDL_HasSSE41 + * \sa SDL_HasSSE42 + */ +extern SDL_DECLSPEC bool SDLCALL SDL_HasSSE3(void); + +/** + * Determine whether the CPU has SSE4.1 features. + * + * This always returns false on CPUs that aren't using Intel instruction sets. + * + * \returns true if the CPU has SSE4.1 features or false if not. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_HasSSE + * \sa SDL_HasSSE2 + * \sa SDL_HasSSE3 + * \sa SDL_HasSSE42 + */ +extern SDL_DECLSPEC bool SDLCALL SDL_HasSSE41(void); + +/** + * Determine whether the CPU has SSE4.2 features. + * + * This always returns false on CPUs that aren't using Intel instruction sets. + * + * \returns true if the CPU has SSE4.2 features or false if not. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_HasSSE + * \sa SDL_HasSSE2 + * \sa SDL_HasSSE3 + * \sa SDL_HasSSE41 + */ +extern SDL_DECLSPEC bool SDLCALL SDL_HasSSE42(void); + +/** + * Determine whether the CPU has AVX features. + * + * This always returns false on CPUs that aren't using Intel instruction sets. + * + * \returns true if the CPU has AVX features or false if not. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_HasAVX2 + * \sa SDL_HasAVX512F + */ +extern SDL_DECLSPEC bool SDLCALL SDL_HasAVX(void); + +/** + * Determine whether the CPU has AVX2 features. + * + * This always returns false on CPUs that aren't using Intel instruction sets. + * + * \returns true if the CPU has AVX2 features or false if not. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_HasAVX + * \sa SDL_HasAVX512F + */ +extern SDL_DECLSPEC bool SDLCALL SDL_HasAVX2(void); + +/** + * Determine whether the CPU has AVX-512F (foundation) features. + * + * This always returns false on CPUs that aren't using Intel instruction sets. + * + * \returns true if the CPU has AVX-512F features or false if not. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_HasAVX + * \sa SDL_HasAVX2 + */ +extern SDL_DECLSPEC bool SDLCALL SDL_HasAVX512F(void); + +/** + * Determine whether the CPU has ARM SIMD (ARMv6) features. + * + * This is different from ARM NEON, which is a different instruction set. + * + * This always returns false on CPUs that aren't using ARM instruction sets. + * + * \returns true if the CPU has ARM SIMD features or false if not. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_HasNEON + */ +extern SDL_DECLSPEC bool SDLCALL SDL_HasARMSIMD(void); + +/** + * Determine whether the CPU has NEON (ARM SIMD) features. + * + * This always returns false on CPUs that aren't using ARM instruction sets. + * + * \returns true if the CPU has ARM NEON features or false if not. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_HasNEON(void); + +/** + * Determine whether the CPU has LSX (LOONGARCH SIMD) features. + * + * This always returns false on CPUs that aren't using LOONGARCH instruction + * sets. + * + * \returns true if the CPU has LOONGARCH LSX features or false if not. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_HasLSX(void); + +/** + * Determine whether the CPU has LASX (LOONGARCH SIMD) features. + * + * This always returns false on CPUs that aren't using LOONGARCH instruction + * sets. + * + * \returns true if the CPU has LOONGARCH LASX features or false if not. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_HasLASX(void); + +/** + * Get the amount of RAM configured in the system. + * + * \returns the amount of RAM configured in the system in MiB. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_GetSystemRAM(void); + +/** + * Report the alignment this system needs for SIMD allocations. + * + * This will return the minimum number of bytes to which a pointer must be + * aligned to be compatible with SIMD instructions on the current machine. For + * example, if the machine supports SSE only, it will return 16, but if it + * supports AVX-512F, it'll return 64 (etc). This only reports values for + * instruction sets SDL knows about, so if your SDL build doesn't have + * SDL_HasAVX512F(), then it might return 16 for the SSE support it sees and + * not 64 for the AVX-512 instructions that exist but SDL doesn't know about. + * Plan accordingly. + * + * \returns the alignment in bytes needed for available, known SIMD + * instructions. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_aligned_alloc + * \sa SDL_aligned_free + */ +extern SDL_DECLSPEC size_t SDLCALL SDL_GetSIMDAlignment(void); + +/** + * Report the size of a page of memory. + * + * Different platforms might have different memory page sizes. In current + * times, 4 kilobytes is not unusual, but newer systems are moving to larger + * page sizes, and esoteric platforms might have any unexpected size. + * + * Note that this function can return 0, which means SDL can't determine the + * page size on this platform. It will _not_ set an error string to be + * retrieved with SDL_GetError() in this case! In this case, defaulting to + * 4096 is often a reasonable option. + * + * \returns the size of a single page of memory, in bytes, or 0 if SDL can't + * determine this information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.4.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_GetSystemPageSize(void); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_cpuinfo_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_dialog.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_dialog.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,343 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * # CategoryDialog + * + * File dialog support. + * + * SDL offers file dialogs, to let users select files with native GUI + * interfaces. There are "open" dialogs, "save" dialogs, and folder selection + * dialogs. The app can control some details, such as filtering to specific + * files, or whether multiple files can be selected by the user. + * + * Note that launching a file dialog is a non-blocking operation; control + * returns to the app immediately, and a callback is called later (possibly in + * another thread) when the user makes a choice. + */ + +#ifndef SDL_dialog_h_ +#define SDL_dialog_h_ + +#include +#include +#include +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * An entry for filters for file dialogs. + * + * `name` is a user-readable label for the filter (for example, "Office + * document"). + * + * `pattern` is a semicolon-separated list of file extensions (for example, + * "doc;docx"). File extensions may only contain alphanumeric characters, + * hyphens, underscores and periods. Alternatively, the whole string can be a + * single asterisk ("*"), which serves as an "All files" filter. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_DialogFileCallback + * \sa SDL_ShowOpenFileDialog + * \sa SDL_ShowSaveFileDialog + * \sa SDL_ShowOpenFolderDialog + * \sa SDL_ShowFileDialogWithProperties + */ +typedef struct SDL_DialogFileFilter +{ + const char *name; + const char *pattern; +} SDL_DialogFileFilter; + +/** + * Callback used by file dialog functions. + * + * The specific usage is described in each function. + * + * If `filelist` is: + * + * - NULL, an error occurred. Details can be obtained with SDL_GetError(). + * - A pointer to NULL, the user either didn't choose any file or canceled the + * dialog. + * - A pointer to non-`NULL`, the user chose one or more files. The argument + * is a null-terminated array of pointers to UTF-8 encoded strings, each + * containing a path. + * + * The filelist argument should not be freed; it will automatically be freed + * when the callback returns. + * + * The filter argument is the index of the filter that was selected, or -1 if + * no filter was selected or if the platform or method doesn't support + * fetching the selected filter. + * + * In Android, the `filelist` are `content://` URIs. They should be opened + * using SDL_IOFromFile() with appropriate modes. This applies both to open + * and save file dialog. + * + * \param userdata an app-provided pointer, for the callback's use. + * \param filelist the file(s) chosen by the user. + * \param filter index of the selected filter. + * + * \since This datatype is available since SDL 3.2.0. + * + * \sa SDL_DialogFileFilter + * \sa SDL_ShowOpenFileDialog + * \sa SDL_ShowSaveFileDialog + * \sa SDL_ShowOpenFolderDialog + * \sa SDL_ShowFileDialogWithProperties + */ +typedef void (SDLCALL *SDL_DialogFileCallback)(void *userdata, const char * const *filelist, int filter); + +/** + * Displays a dialog that lets the user select a file on their filesystem. + * + * This is an asynchronous function; it will return immediately, and the + * result will be passed to the callback. + * + * The callback will be invoked with a null-terminated list of files the user + * chose. The list will be empty if the user canceled the dialog, and it will + * be NULL if an error occurred. + * + * Note that the callback may be called from a different thread than the one + * the function was invoked on. + * + * Depending on the platform, the user may be allowed to input paths that + * don't yet exist. + * + * On Linux, dialogs may require XDG Portals, which requires DBus, which + * requires an event-handling loop. Apps that do not use SDL to handle events + * should add a call to SDL_PumpEvents in their main loop. + * + * \param callback a function pointer to be invoked when the user selects a + * file and accepts, or cancels the dialog, or an error + * occurs. + * \param userdata an optional pointer to pass extra data to the callback when + * it will be invoked. + * \param window the window that the dialog should be modal for, may be NULL. + * Not all platforms support this option. + * \param filters a list of filters, may be NULL. See the + * [`SDL_DialogFileFilter`](SDL_DialogFileFilter#code-examples) + * documentation for examples]. Not all platforms support this + * option, and platforms that do support it may allow the user + * to ignore the filters. If non-NULL, it must remain valid at + * least until the callback is invoked. + * \param nfilters the number of filters. Ignored if filters is NULL. + * \param default_location the default folder or file to start the dialog at, + * may be NULL. Not all platforms support this option. + * \param allow_many if non-zero, the user will be allowed to select multiple + * entries. Not all platforms support this option. + * + * \threadsafety This function should be called only from the main thread. The + * callback may be invoked from the same thread or from a + * different one, depending on the OS's constraints. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_DialogFileCallback + * \sa SDL_DialogFileFilter + * \sa SDL_ShowSaveFileDialog + * \sa SDL_ShowOpenFolderDialog + * \sa SDL_ShowFileDialogWithProperties + */ +extern SDL_DECLSPEC void SDLCALL SDL_ShowOpenFileDialog(SDL_DialogFileCallback callback, void *userdata, SDL_Window *window, const SDL_DialogFileFilter *filters, int nfilters, const char *default_location, bool allow_many); + +/** + * Displays a dialog that lets the user choose a new or existing file on their + * filesystem. + * + * This is an asynchronous function; it will return immediately, and the + * result will be passed to the callback. + * + * The callback will be invoked with a null-terminated list of files the user + * chose. The list will be empty if the user canceled the dialog, and it will + * be NULL if an error occurred. + * + * Note that the callback may be called from a different thread than the one + * the function was invoked on. + * + * The chosen file may or may not already exist. + * + * On Linux, dialogs may require XDG Portals, which requires DBus, which + * requires an event-handling loop. Apps that do not use SDL to handle events + * should add a call to SDL_PumpEvents in their main loop. + * + * \param callback a function pointer to be invoked when the user selects a + * file and accepts, or cancels the dialog, or an error + * occurs. + * \param userdata an optional pointer to pass extra data to the callback when + * it will be invoked. + * \param window the window that the dialog should be modal for, may be NULL. + * Not all platforms support this option. + * \param filters a list of filters, may be NULL. Not all platforms support + * this option, and platforms that do support it may allow the + * user to ignore the filters. If non-NULL, it must remain + * valid at least until the callback is invoked. + * \param nfilters the number of filters. Ignored if filters is NULL. + * \param default_location the default folder or file to start the dialog at, + * may be NULL. Not all platforms support this option. + * + * \threadsafety This function should be called only from the main thread. The + * callback may be invoked from the same thread or from a + * different one, depending on the OS's constraints. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_DialogFileCallback + * \sa SDL_DialogFileFilter + * \sa SDL_ShowOpenFileDialog + * \sa SDL_ShowOpenFolderDialog + * \sa SDL_ShowFileDialogWithProperties + */ +extern SDL_DECLSPEC void SDLCALL SDL_ShowSaveFileDialog(SDL_DialogFileCallback callback, void *userdata, SDL_Window *window, const SDL_DialogFileFilter *filters, int nfilters, const char *default_location); + +/** + * Displays a dialog that lets the user select a folder on their filesystem. + * + * This is an asynchronous function; it will return immediately, and the + * result will be passed to the callback. + * + * The callback will be invoked with a null-terminated list of files the user + * chose. The list will be empty if the user canceled the dialog, and it will + * be NULL if an error occurred. + * + * Note that the callback may be called from a different thread than the one + * the function was invoked on. + * + * Depending on the platform, the user may be allowed to input paths that + * don't yet exist. + * + * On Linux, dialogs may require XDG Portals, which requires DBus, which + * requires an event-handling loop. Apps that do not use SDL to handle events + * should add a call to SDL_PumpEvents in their main loop. + * + * \param callback a function pointer to be invoked when the user selects a + * file and accepts, or cancels the dialog, or an error + * occurs. + * \param userdata an optional pointer to pass extra data to the callback when + * it will be invoked. + * \param window the window that the dialog should be modal for, may be NULL. + * Not all platforms support this option. + * \param default_location the default folder or file to start the dialog at, + * may be NULL. Not all platforms support this option. + * \param allow_many if non-zero, the user will be allowed to select multiple + * entries. Not all platforms support this option. + * + * \threadsafety This function should be called only from the main thread. The + * callback may be invoked from the same thread or from a + * different one, depending on the OS's constraints. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_DialogFileCallback + * \sa SDL_ShowOpenFileDialog + * \sa SDL_ShowSaveFileDialog + * \sa SDL_ShowFileDialogWithProperties + */ +extern SDL_DECLSPEC void SDLCALL SDL_ShowOpenFolderDialog(SDL_DialogFileCallback callback, void *userdata, SDL_Window *window, const char *default_location, bool allow_many); + +/** + * Various types of file dialogs. + * + * This is used by SDL_ShowFileDialogWithProperties() to decide what kind of + * dialog to present to the user. + * + * \since This enum is available since SDL 3.2.0. + * + * \sa SDL_ShowFileDialogWithProperties + */ +typedef enum SDL_FileDialogType +{ + SDL_FILEDIALOG_OPENFILE, + SDL_FILEDIALOG_SAVEFILE, + SDL_FILEDIALOG_OPENFOLDER +} SDL_FileDialogType; + +/** + * Create and launch a file dialog with the specified properties. + * + * These are the supported properties: + * + * - `SDL_PROP_FILE_DIALOG_FILTERS_POINTER`: a pointer to a list of + * SDL_DialogFileFilter structs, which will be used as filters for + * file-based selections. Ignored if the dialog is an "Open Folder" dialog. + * If non-NULL, the array of filters must remain valid at least until the + * callback is invoked. + * - `SDL_PROP_FILE_DIALOG_NFILTERS_NUMBER`: the number of filters in the + * array of filters, if it exists. + * - `SDL_PROP_FILE_DIALOG_WINDOW_POINTER`: the window that the dialog should + * be modal for. + * - `SDL_PROP_FILE_DIALOG_LOCATION_STRING`: the default folder or file to + * start the dialog at. + * - `SDL_PROP_FILE_DIALOG_MANY_BOOLEAN`: true to allow the user to select + * more than one entry. + * - `SDL_PROP_FILE_DIALOG_TITLE_STRING`: the title for the dialog. + * - `SDL_PROP_FILE_DIALOG_ACCEPT_STRING`: the label that the accept button + * should have. + * - `SDL_PROP_FILE_DIALOG_CANCEL_STRING`: the label that the cancel button + * should have. + * + * Note that each platform may or may not support any of the properties. + * + * \param type the type of file dialog. + * \param callback a function pointer to be invoked when the user selects a + * file and accepts, or cancels the dialog, or an error + * occurs. + * \param userdata an optional pointer to pass extra data to the callback when + * it will be invoked. + * \param props the properties to use. + * + * \threadsafety This function should be called only from the main thread. The + * callback may be invoked from the same thread or from a + * different one, depending on the OS's constraints. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_FileDialogType + * \sa SDL_DialogFileCallback + * \sa SDL_DialogFileFilter + * \sa SDL_ShowOpenFileDialog + * \sa SDL_ShowSaveFileDialog + * \sa SDL_ShowOpenFolderDialog + */ +extern SDL_DECLSPEC void SDLCALL SDL_ShowFileDialogWithProperties(SDL_FileDialogType type, SDL_DialogFileCallback callback, void *userdata, SDL_PropertiesID props); + +#define SDL_PROP_FILE_DIALOG_FILTERS_POINTER "SDL.filedialog.filters" +#define SDL_PROP_FILE_DIALOG_NFILTERS_NUMBER "SDL.filedialog.nfilters" +#define SDL_PROP_FILE_DIALOG_WINDOW_POINTER "SDL.filedialog.window" +#define SDL_PROP_FILE_DIALOG_LOCATION_STRING "SDL.filedialog.location" +#define SDL_PROP_FILE_DIALOG_MANY_BOOLEAN "SDL.filedialog.many" +#define SDL_PROP_FILE_DIALOG_TITLE_STRING "SDL.filedialog.title" +#define SDL_PROP_FILE_DIALOG_ACCEPT_STRING "SDL.filedialog.accept" +#define SDL_PROP_FILE_DIALOG_CANCEL_STRING "SDL.filedialog.cancel" + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_dialog_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_dlopennote.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_dlopennote.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,234 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* WIKI CATEGORY: DlopenNotes */ + +/** + * # CategoryDlopenNotes + * + * This header allows you to annotate your code so external tools know about + * dynamic shared library dependencies. + * + * If you determine that your toolchain doesn't support dlopen notes, you can + * disable this feature by defining `SDL_DISABLE_DLOPEN_NOTES`. You can use + * this CMake snippet to check for support: + * + * ```cmake + * include(CheckCSourceCompiles) + * find_package(SDL3 REQUIRED CONFIG COMPONENTS Headers) + * list(APPEND CMAKE_REQUIRED_LIBRARIES SDL3::Headers) + * check_c_source_compiles([==[ + * #include + * SDL_ELF_NOTE_DLOPEN("sdl-video", + * "Support for video through SDL", + * SDL_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED, + * "libSDL-1.2.so.0", "libSDL-2.0.so.0", "libSDL3.so.0" + * ) + * int main(int argc, char *argv[]) { + * return argc + argv[0][1]; + * } + * ]==] COMPILER_SUPPORTS_SDL_ELF_NOTE_DLOPEN) + * if(NOT COMPILER_SUPPORTS_SDL_ELF_NOTE_DLOPEN) + * add_compile_definitions(-DSDL_DISABLE_DLOPEN_NOTE) + * endif() + * ``` + */ + +#ifndef SDL_dlopennote_h +#define SDL_dlopennote_h + +/** + * Use this macro with SDL_ELF_NOTE_DLOPEN() to note that a dynamic shared + * library dependency is optional. + * + * Optional functionality uses the dependency, the binary will work and the + * dependency is only needed for full-featured installations. + * + * \since This macro is available since SDL 3.4.0. + * + * \sa SDL_ELF_NOTE_DLOPEN + * \sa SDL_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED + * \sa SDL_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED + */ +#define SDL_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED "suggested" + +/** + * Use this macro with SDL_ELF_NOTE_DLOPEN() to note that a dynamic shared + * library dependency is recommended. + * + * Important functionality needs the dependency, the binary will work but in + * most cases the dependency should be provided. + * + * \since This macro is available since SDL 3.4.0. + * + * \sa SDL_ELF_NOTE_DLOPEN + * \sa SDL_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED + * \sa SDL_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED + */ +#define SDL_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED "recommended" + +/** + * Use this macro with SDL_ELF_NOTE_DLOPEN() to note that a dynamic shared + * library dependency is required. + * + * Core functionality needs the dependency, the binary will not work if it + * cannot be found. + * + * \since This macro is available since SDL 3.4.0. + * + * \sa SDL_ELF_NOTE_DLOPEN + * \sa SDL_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED + * \sa SDL_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED + */ +#define SDL_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED "required" + + +#if !defined(SDL_PLATFORM_UNIX) || defined(SDL_PLATFORM_ANDROID) +/* The dlopen note functionality isn't used on this platform */ +#ifndef SDL_DISABLE_DLOPEN_NOTES +#define SDL_DISABLE_DLOPEN_NOTES +#endif +#elif defined(__GNUC__) && (__GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 1)) +/* gcc < 3.1 too old */ +#ifndef SDL_DISABLE_DLOPEN_NOTES +#define SDL_DISABLE_DLOPEN_NOTES +#endif +#endif /* SDL_PLATFORM_UNIX || SDL_PLATFORM_ANDROID */ + +#if defined(__ELF__) && !defined(SDL_DISABLE_DLOPEN_NOTES) + +#include + +#define SDL_ELF_NOTE_DLOPEN_VENDOR "FDO" +#define SDL_ELF_NOTE_DLOPEN_TYPE 0x407c0c0aU + +#define SDL_ELF_NOTE_INTERNAL2(json, variable_name) \ + __attribute__((aligned(4), used, section(".note.dlopen"))) \ + static const struct { \ + struct { \ + Uint32 n_namesz; \ + Uint32 n_descsz; \ + Uint32 n_type; \ + } nhdr; \ + char name[4]; \ + __attribute__((aligned(4))) char dlopen_json[sizeof(json)]; \ + } variable_name = { \ + { \ + sizeof(SDL_ELF_NOTE_DLOPEN_VENDOR), \ + sizeof(json), \ + SDL_ELF_NOTE_DLOPEN_TYPE \ + }, \ + SDL_ELF_NOTE_DLOPEN_VENDOR, \ + json \ + } + +#define SDL_ELF_NOTE_INTERNAL(json, variable_name) \ + SDL_ELF_NOTE_INTERNAL2(json, variable_name) + +#define SDL_DLNOTE_JSON_ARRAY1(N1) "[\"" N1 "\"]" +#define SDL_DLNOTE_JSON_ARRAY2(N1,N2) "[\"" N1 "\",\"" N2 "\"]" +#define SDL_DLNOTE_JSON_ARRAY3(N1,N2,N3) "[\"" N1 "\",\"" N2 "\",\"" N3 "\"]" +#define SDL_DLNOTE_JSON_ARRAY4(N1,N2,N3,N4) "[\"" N1 "\",\"" N2 "\",\"" N3 "\",\"" N4 "\"]" +#define SDL_DLNOTE_JSON_ARRAY5(N1,N2,N3,N4,N5) "[\"" N1 "\",\"" N2 "\",\"" N3 "\",\"" N4 "\",\"" N5 "\"]" +#define SDL_DLNOTE_JSON_ARRAY6(N1,N2,N3,N4,N5,N6) "[\"" N1 "\",\"" N2 "\",\"" N3 "\",\"" N4 "\",\"" N5 "\",\"" N6 "\"]" +#define SDL_DLNOTE_JSON_ARRAY7(N1,N2,N3,N4,N5,N6,N7) "[\"" N1 "\",\"" N2 "\",\"" N3 "\",\"" N4 "\",\"" N5 "\",\"" N6 "\",\"" N7 "\"]" +#define SDL_DLNOTE_JSON_ARRAY8(N1,N2,N3,N4,N5,N6,N7,N8) "[\"" N1 "\",\"" N2 "\",\"" N3 "\",\"" N4 "\",\"" N5 "\",\"" N6 "\",\"" N7 "\",\"" N8 "\"]" +#define SDL_DLNOTE_JSON_ARRAY_GET(N1,N2,N3,N4,N5,N6,N7,N8,NAME,...) NAME +#define SDL_DLNOTE_JSON_ARRAY(...) \ + SDL_DLNOTE_JSON_ARRAY_GET( \ + __VA_ARGS__, \ + SDL_DLNOTE_JSON_ARRAY8, \ + SDL_DLNOTE_JSON_ARRAY7, \ + SDL_DLNOTE_JSON_ARRAY6, \ + SDL_DLNOTE_JSON_ARRAY5, \ + SDL_DLNOTE_JSON_ARRAY4, \ + SDL_DLNOTE_JSON_ARRAY3, \ + SDL_DLNOTE_JSON_ARRAY2, \ + SDL_DLNOTE_JSON_ARRAY1 \ + )(__VA_ARGS__) + +/* Create "unique" variable name using __LINE__, + * so creating multiple elf notes on the same line is not supported + */ +#define SDL_DLNOTE_JOIN2(A,B) A##B +#define SDL_DLNOTE_JOIN(A,B) SDL_DLNOTE_JOIN2(A,B) +#define SDL_DLNOTE_UNIQUE_NAME SDL_DLNOTE_JOIN(s_SDL_dlopen_note_, __LINE__) + +/** + * Add a note that your application has dynamic shared library dependencies. + * + * You can do this by adding the following to the global scope: + * + * ```c + * SDL_ELF_NOTE_DLOPEN( + * "png", + * "Support for loading PNG images using libpng (required for APNG)", + * SDL_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED, + * "libpng12.so.0" + * ) + * ``` + * + * A trailing semicolon is not needed. + * + * Or if you support multiple versions of a library, you can list them: + * + * ```c + * // Our app supports SDL1, SDL2, and SDL3 by dynamically loading them + * SDL_ELF_NOTE_DLOPEN( + * "SDL", + * "Create windows through SDL video backend", + * SDL_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED + * "libSDL-1.2.so.0", "libSDL2-2.0.so.0", "libSDL3.so.0" + * ) + * ``` + * + * This macro is not available for compilers that do not support variadic + * macro's. + * + * \since This macro is available since SDL 3.4.0. + * + * \sa SDL_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED + * \sa SDL_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED + * \sa SDL_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED + */ +#define SDL_ELF_NOTE_DLOPEN(feature, description, priority, ...) \ + SDL_ELF_NOTE_INTERNAL( \ + "[{\"feature\":\"" feature \ + "\",\"description\":\"" description \ + "\",\"priority\":\"" priority \ + "\",\"soname\":" SDL_DLNOTE_JSON_ARRAY(__VA_ARGS__) "}]", \ + SDL_DLNOTE_UNIQUE_NAME); + +#elif defined(__GNUC__) && __GNUC__ < 3 + +#define SDL_ELF_NOTE_DLOPEN(args...) + +#elif defined(_MSC_VER) && _MSC_VER < 1400 + +/* Variadic macros are not supported */ + +#else + +#define SDL_ELF_NOTE_DLOPEN(...) + +#endif + +#endif /* SDL_dlopennote_h */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_egl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_egl.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,2355 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* + * This is a simple file to encapsulate the EGL API headers. + */ + +#include + +#if !defined(_MSC_VER) && !defined(SDL_PLATFORM_ANDROID) && !defined(SDL_USE_BUILTIN_OPENGL_DEFINITIONS) + +#if defined(SDL_PLATFORM_VITA) +#include +#include +#include +#endif + +#include +#include + +#else /* _MSC_VER */ + +/* EGL headers for Visual Studio */ + +#ifndef __khrplatform_h_ +#define __khrplatform_h_ + +/* +** Copyright (c) 2008-2018 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +/* Khronos platform-specific types and definitions. + * + * The master copy of khrplatform.h is maintained in the Khronos EGL + * Registry repository at https://github.com/KhronosGroup/EGL-Registry + * The last semantic modification to khrplatform.h was at commit ID: + * 67a3e0864c2d75ea5287b9f3d2eb74a745936692 + * + * Adopters may modify this file to suit their platform. Adopters are + * encouraged to submit platform specific modifications to the Khronos + * group so that they can be included in future versions of this file. + * Please submit changes by filing pull requests or issues on + * the EGL Registry repository linked above. + * + * + * See the Implementer's Guidelines for information about where this file + * should be located on your system and for more details of its use: + * http://www.khronos.org/registry/implementers_guide.pdf + * + * This file should be included as + * #include + * by Khronos client API header files that use its types and defines. + * + * The types in khrplatform.h should only be used to define API-specific types. + * + * Types defined in khrplatform.h: + * khronos_int8_t signed 8 bit + * khronos_uint8_t unsigned 8 bit + * khronos_int16_t signed 16 bit + * khronos_uint16_t unsigned 16 bit + * khronos_int32_t signed 32 bit + * khronos_uint32_t unsigned 32 bit + * khronos_int64_t signed 64 bit + * khronos_uint64_t unsigned 64 bit + * khronos_intptr_t signed same number of bits as a pointer + * khronos_uintptr_t unsigned same number of bits as a pointer + * khronos_ssize_t signed size + * khronos_usize_t unsigned size + * khronos_float_t signed 32 bit floating point + * khronos_time_ns_t unsigned 64 bit time in nanoseconds + * khronos_utime_nanoseconds_t unsigned time interval or absolute time in + * nanoseconds + * khronos_stime_nanoseconds_t signed time interval in nanoseconds + * khronos_boolean_enum_t enumerated boolean type. This should + * only be used as a base type when a client API's boolean type is + * an enum. Client APIs which use an integer or other type for + * booleans cannot use this as the base type for their boolean. + * + * Tokens defined in khrplatform.h: + * + * KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values. + * + * KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0. + * KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0. + * + * Calling convention macros defined in this file: + * KHRONOS_APICALL + * KHRONOS_APIENTRY + * KHRONOS_APIATTRIBUTES + * + * These may be used in function prototypes as: + * + * KHRONOS_APICALL void KHRONOS_APIENTRY funcname( + * int arg1, + * int arg2) KHRONOS_APIATTRIBUTES; + */ + +#if defined(__SCITECH_SNAP__) && !defined(KHRONOS_STATIC) +# define KHRONOS_STATIC 1 +#endif + +/*------------------------------------------------------------------------- + * Definition of KHRONOS_APICALL + *------------------------------------------------------------------------- + * This precedes the return type of the function in the function prototype. + */ +#if defined(KHRONOS_STATIC) + /* If the preprocessor constant KHRONOS_STATIC is defined, make the + * header compatible with static linking. */ +# define KHRONOS_APICALL +#elif defined(_WIN32) +# define KHRONOS_APICALL __declspec(dllimport) +#elif defined (__SYMBIAN32__) +# define KHRONOS_APICALL IMPORT_C +#elif defined(__ANDROID__) +# define KHRONOS_APICALL __attribute__((visibility("default"))) +#else +# define KHRONOS_APICALL +#endif + +/*------------------------------------------------------------------------- + * Definition of KHRONOS_APIENTRY + *------------------------------------------------------------------------- + * This follows the return type of the function and precedes the function + * name in the function prototype. + */ +#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__) + /* Win32 but not WinCE */ +# define KHRONOS_APIENTRY __stdcall +#else +# define KHRONOS_APIENTRY +#endif + +/*------------------------------------------------------------------------- + * Definition of KHRONOS_APIATTRIBUTES + *------------------------------------------------------------------------- + * This follows the closing parenthesis of the function prototype arguments. + */ +#if defined (__ARMCC_2__) +#define KHRONOS_APIATTRIBUTES __softfp +#else +#define KHRONOS_APIATTRIBUTES +#endif + +/*------------------------------------------------------------------------- + * basic type definitions + *-----------------------------------------------------------------------*/ +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__) + + +/* + * Using + */ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 +/* + * To support platform where unsigned long cannot be used interchangeably with + * inptr_t (e.g. CHERI-extended ISAs), we can use the stdint.h intptr_t. + * Ideally, we could just use (u)intptr_t everywhere, but this could result in + * ABI breakage if khronos_uintptr_t is changed from unsigned long to + * unsigned long long or similar (this results in different C++ name mangling). + * To avoid changes for existing platforms, we restrict usage of intptr_t to + * platforms where the size of a pointer is larger than the size of long. + */ +#if defined(__SIZEOF_LONG__) && defined(__SIZEOF_POINTER__) +#if __SIZEOF_POINTER__ > __SIZEOF_LONG__ +#define KHRONOS_USE_INTPTR_T +#endif +#endif + +#elif defined(__VMS ) || defined(__sgi) + +/* + * Using + */ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(_WIN32) && !defined(__SCITECH_SNAP__) + +/* + * Win32 + */ +typedef __int32 khronos_int32_t; +typedef unsigned __int32 khronos_uint32_t; +typedef __int64 khronos_int64_t; +typedef unsigned __int64 khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(__sun__) || defined(__digital__) + +/* + * Sun or Digital + */ +typedef int khronos_int32_t; +typedef unsigned int khronos_uint32_t; +#if defined(__arch64__) || defined(_LP64) +typedef long int khronos_int64_t; +typedef unsigned long int khronos_uint64_t; +#else +typedef long long int khronos_int64_t; +typedef unsigned long long int khronos_uint64_t; +#endif /* __arch64__ */ +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif 0 + +/* + * Hypothetical platform with no float or int64 support + */ +typedef int khronos_int32_t; +typedef unsigned int khronos_uint32_t; +#define KHRONOS_SUPPORT_INT64 0 +#define KHRONOS_SUPPORT_FLOAT 0 + +#else + +/* + * Generic fallback + */ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#endif + + +/* + * Types that are (so far) the same on all platforms + */ +typedef signed char khronos_int8_t; +typedef unsigned char khronos_uint8_t; +typedef signed short int khronos_int16_t; +typedef unsigned short int khronos_uint16_t; + +/* + * Types that differ between LLP64 and LP64 architectures - in LLP64, + * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears + * to be the only LLP64 architecture in current use. + */ +#ifdef KHRONOS_USE_INTPTR_T +typedef intptr_t khronos_intptr_t; +typedef uintptr_t khronos_uintptr_t; +#elif defined(_WIN64) +typedef signed long long int khronos_intptr_t; +typedef unsigned long long int khronos_uintptr_t; +#else +typedef signed long int khronos_intptr_t; +typedef unsigned long int khronos_uintptr_t; +#endif + +#if defined(_WIN64) +typedef signed long long int khronos_ssize_t; +typedef unsigned long long int khronos_usize_t; +#else +typedef signed long int khronos_ssize_t; +typedef unsigned long int khronos_usize_t; +#endif + +#if KHRONOS_SUPPORT_FLOAT +/* + * Float type + */ +typedef float khronos_float_t; +#endif + +#if KHRONOS_SUPPORT_INT64 +/* Time types + * + * These types can be used to represent a time interval in nanoseconds or + * an absolute Unadjusted System Time. Unadjusted System Time is the number + * of nanoseconds since some arbitrary system event (e.g. since the last + * time the system booted). The Unadjusted System Time is an unsigned + * 64 bit value that wraps back to 0 every 584 years. Time intervals + * may be either signed or unsigned. + */ +typedef khronos_uint64_t khronos_utime_nanoseconds_t; +typedef khronos_int64_t khronos_stime_nanoseconds_t; +#endif + +/* + * Dummy value used to pad enum types to 32 bits. + */ +#ifndef KHRONOS_MAX_ENUM +#define KHRONOS_MAX_ENUM 0x7FFFFFFF +#endif + +/* + * Enumerated boolean type + * + * Values other than zero should be considered to be true. Therefore + * comparisons should not be made against KHRONOS_TRUE. + */ +typedef enum { + KHRONOS_FALSE = 0, + KHRONOS_TRUE = 1, + KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM +} khronos_boolean_enum_t; + +#endif /* __khrplatform_h_ */ + + +#ifndef __eglplatform_h_ +#define __eglplatform_h_ + +/* +** Copyright 2007-2020 The Khronos Group Inc. +** SPDX-License-Identifier: Apache-2.0 +*/ + +/* Platform-specific types and definitions for egl.h + * + * Adopters may modify khrplatform.h and this file to suit their platform. + * You are encouraged to submit all modifications to the Khronos group so that + * they can be included in future versions of this file. Please submit changes + * by filing an issue or pull request on the public Khronos EGL Registry, at + * https://www.github.com/KhronosGroup/EGL-Registry/ + */ + +/*#include */ + +/* Macros used in EGL function prototype declarations. + * + * EGL functions should be prototyped as: + * + * EGLAPI return-type EGLAPIENTRY eglFunction(arguments); + * typedef return-type (EXPAPIENTRYP PFNEGLFUNCTIONPROC) (arguments); + * + * KHRONOS_APICALL and KHRONOS_APIENTRY are defined in KHR/khrplatform.h + */ + +#ifndef EGLAPI +#define EGLAPI KHRONOS_APICALL +#endif + +#ifndef EGLAPIENTRY +#define EGLAPIENTRY KHRONOS_APIENTRY +#endif +#define EGLAPIENTRYP EGLAPIENTRY* + +/* The types NativeDisplayType, NativeWindowType, and NativePixmapType + * are aliases of window-system-dependent types, such as X Display * or + * Windows Device Context. They must be defined in platform-specific + * code below. The EGL-prefixed versions of Native*Type are the same + * types, renamed in EGL 1.3 so all types in the API start with "EGL". + * + * Khronos STRONGLY RECOMMENDS that you use the default definitions + * provided below, since these changes affect both binary and source + * portability of applications using EGL running on different EGL + * implementations. + */ + +#if defined(EGL_NO_PLATFORM_SPECIFIC_TYPES) + +typedef void *EGLNativeDisplayType; +typedef void *EGLNativePixmapType; +typedef void *EGLNativeWindowType; + +#elif defined(_WIN32) || defined(__VC32__) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) /* Win32 and WinCE */ +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN 1 +#endif +#include + +typedef HDC EGLNativeDisplayType; +typedef HBITMAP EGLNativePixmapType; +typedef HWND EGLNativeWindowType; + +#elif defined(SDL_PLATFORM_EMSCRIPTEN) + +typedef int EGLNativeDisplayType; +typedef int EGLNativePixmapType; +typedef int EGLNativeWindowType; + +#elif defined(__WINSCW__) || defined(__SYMBIAN32__) /* Symbian */ + +typedef int EGLNativeDisplayType; +typedef void *EGLNativePixmapType; +typedef void *EGLNativeWindowType; + +#elif defined(WL_EGL_PLATFORM) + +typedef struct wl_display *EGLNativeDisplayType; +typedef struct wl_egl_pixmap *EGLNativePixmapType; +typedef struct wl_egl_window *EGLNativeWindowType; + +#elif defined(__GBM__) + +typedef struct gbm_device *EGLNativeDisplayType; +typedef struct gbm_bo *EGLNativePixmapType; +typedef void *EGLNativeWindowType; + +#elif defined(__ANDROID__) || defined(ANDROID) + +struct ANativeWindow; +struct egl_native_pixmap_t; + +typedef void* EGLNativeDisplayType; +typedef struct egl_native_pixmap_t* EGLNativePixmapType; +typedef struct ANativeWindow* EGLNativeWindowType; + +#elif defined(USE_OZONE) + +typedef intptr_t EGLNativeDisplayType; +typedef intptr_t EGLNativePixmapType; +typedef intptr_t EGLNativeWindowType; + +#elif defined(USE_X11) + +/* X11 (tentative) */ +#include +#include + +typedef Display *EGLNativeDisplayType; +typedef Pixmap EGLNativePixmapType; +typedef Window EGLNativeWindowType; + +#elif defined(__unix__) + +typedef void *EGLNativeDisplayType; +typedef khronos_uintptr_t EGLNativePixmapType; +typedef khronos_uintptr_t EGLNativeWindowType; + +#elif defined(__APPLE__) + +typedef int EGLNativeDisplayType; +typedef void *EGLNativePixmapType; +typedef void *EGLNativeWindowType; + +#elif defined(__HAIKU__) + +#include + +typedef void *EGLNativeDisplayType; +typedef khronos_uintptr_t EGLNativePixmapType; +typedef khronos_uintptr_t EGLNativeWindowType; + +#elif defined(__Fuchsia__) + +typedef void *EGLNativeDisplayType; +typedef khronos_uintptr_t EGLNativePixmapType; +typedef khronos_uintptr_t EGLNativeWindowType; + +#else +#error "Platform not recognized" +#endif + +/* EGL 1.2 types, renamed for consistency in EGL 1.3 */ +typedef EGLNativeDisplayType NativeDisplayType; +typedef EGLNativePixmapType NativePixmapType; +typedef EGLNativeWindowType NativeWindowType; + + +/* Define EGLint. This must be a signed integral type large enough to contain + * all legal attribute names and values passed into and out of EGL, whether + * their type is boolean, bitmask, enumerant (symbolic constant), integer, + * handle, or other. While in general a 32-bit integer will suffice, if + * handles are 64 bit types, then EGLint should be defined as a signed 64-bit + * integer type. + */ +typedef khronos_int32_t EGLint; + + +/* C++ / C typecast macros for special EGL handle values */ +#if defined(__cplusplus) +#define EGL_CAST(type, value) (static_cast(value)) +#else +#define EGL_CAST(type, value) ((type) (value)) +#endif + +#endif /* __eglplatform_h */ + + +#ifndef __egl_h_ +#define __egl_h_ 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Copyright 2013-2020 The Khronos Group Inc. +** SPDX-License-Identifier: Apache-2.0 +** +** This header is generated from the Khronos EGL XML API Registry. +** The current version of the Registry, generator scripts +** used to make the header, and the header can be found at +** http://www.khronos.org/registry/egl +** +** Khronos $Git commit SHA1: 6fb1daea15 $ on $Git commit date: 2022-05-25 09:41:13 -0600 $ +*/ + +/*#include */ + +#ifndef EGL_EGL_PROTOTYPES +#define EGL_EGL_PROTOTYPES 1 +#endif + +/* Generated on date 20220525 */ + +/* Generated C header for: + * API: egl + * Versions considered: .* + * Versions emitted: .* + * Default extensions included: None + * Additional extensions included: _nomatch_^ + * Extensions removed: _nomatch_^ + */ + +#ifndef EGL_VERSION_1_0 +#define EGL_VERSION_1_0 1 +typedef unsigned int EGLBoolean; +typedef void *EGLDisplay; +/*#include */ +/*#include */ +typedef void *EGLConfig; +typedef void *EGLSurface; +typedef void *EGLContext; +typedef void (*__eglMustCastToProperFunctionPointerType)(void); +#define EGL_ALPHA_SIZE 0x3021 +#define EGL_BAD_ACCESS 0x3002 +#define EGL_BAD_ALLOC 0x3003 +#define EGL_BAD_ATTRIBUTE 0x3004 +#define EGL_BAD_CONFIG 0x3005 +#define EGL_BAD_CONTEXT 0x3006 +#define EGL_BAD_CURRENT_SURFACE 0x3007 +#define EGL_BAD_DISPLAY 0x3008 +#define EGL_BAD_MATCH 0x3009 +#define EGL_BAD_NATIVE_PIXMAP 0x300A +#define EGL_BAD_NATIVE_WINDOW 0x300B +#define EGL_BAD_PARAMETER 0x300C +#define EGL_BAD_SURFACE 0x300D +#define EGL_BLUE_SIZE 0x3022 +#define EGL_BUFFER_SIZE 0x3020 +#define EGL_CONFIG_CAVEAT 0x3027 +#define EGL_CONFIG_ID 0x3028 +#define EGL_CORE_NATIVE_ENGINE 0x305B +#define EGL_DEPTH_SIZE 0x3025 +#define EGL_DONT_CARE EGL_CAST(EGLint,-1) +#define EGL_DRAW 0x3059 +#define EGL_EXTENSIONS 0x3055 +#define EGL_FALSE 0 +#define EGL_GREEN_SIZE 0x3023 +#define EGL_HEIGHT 0x3056 +#define EGL_LARGEST_PBUFFER 0x3058 +#define EGL_LEVEL 0x3029 +#define EGL_MAX_PBUFFER_HEIGHT 0x302A +#define EGL_MAX_PBUFFER_PIXELS 0x302B +#define EGL_MAX_PBUFFER_WIDTH 0x302C +#define EGL_NATIVE_RENDERABLE 0x302D +#define EGL_NATIVE_VISUAL_ID 0x302E +#define EGL_NATIVE_VISUAL_TYPE 0x302F +#define EGL_NONE 0x3038 +#define EGL_NON_CONFORMANT_CONFIG 0x3051 +#define EGL_NOT_INITIALIZED 0x3001 +#define EGL_NO_CONTEXT EGL_CAST(EGLContext,0) +#define EGL_NO_DISPLAY EGL_CAST(EGLDisplay,0) +#define EGL_NO_SURFACE EGL_CAST(EGLSurface,0) +#define EGL_PBUFFER_BIT 0x0001 +#define EGL_PIXMAP_BIT 0x0002 +#define EGL_READ 0x305A +#define EGL_RED_SIZE 0x3024 +#define EGL_SAMPLES 0x3031 +#define EGL_SAMPLE_BUFFERS 0x3032 +#define EGL_SLOW_CONFIG 0x3050 +#define EGL_STENCIL_SIZE 0x3026 +#define EGL_SUCCESS 0x3000 +#define EGL_SURFACE_TYPE 0x3033 +#define EGL_TRANSPARENT_BLUE_VALUE 0x3035 +#define EGL_TRANSPARENT_GREEN_VALUE 0x3036 +#define EGL_TRANSPARENT_RED_VALUE 0x3037 +#define EGL_TRANSPARENT_RGB 0x3052 +#define EGL_TRANSPARENT_TYPE 0x3034 +#define EGL_TRUE 1 +#define EGL_VENDOR 0x3053 +#define EGL_VERSION 0x3054 +#define EGL_WIDTH 0x3057 +#define EGL_WINDOW_BIT 0x0004 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLCHOOSECONFIGPROC) (EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLCOPYBUFFERSPROC) (EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target); +typedef EGLContext (EGLAPIENTRYP PFNEGLCREATECONTEXTPROC) (EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list); +typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPBUFFERSURFACEPROC) (EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list); +typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPIXMAPSURFACEPROC) (EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list); +typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEWINDOWSURFACEPROC) (EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYCONTEXTPROC) (EGLDisplay dpy, EGLContext ctx); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSURFACEPROC) (EGLDisplay dpy, EGLSurface surface); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETCONFIGATTRIBPROC) (EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETCONFIGSPROC) (EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config); +typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETCURRENTDISPLAYPROC) (void); +typedef EGLSurface (EGLAPIENTRYP PFNEGLGETCURRENTSURFACEPROC) (EGLint readdraw); +typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETDISPLAYPROC) (EGLNativeDisplayType display_id); +typedef EGLint (EGLAPIENTRYP PFNEGLGETERRORPROC) (void); +typedef __eglMustCastToProperFunctionPointerType (EGLAPIENTRYP PFNEGLGETPROCADDRESSPROC) (const char *procname); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLINITIALIZEPROC) (EGLDisplay dpy, EGLint *major, EGLint *minor); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLMAKECURRENTPROC) (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYCONTEXTPROC) (EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value); +typedef const char *(EGLAPIENTRYP PFNEGLQUERYSTRINGPROC) (EGLDisplay dpy, EGLint name); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSURFACEPROC) (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSPROC) (EGLDisplay dpy, EGLSurface surface); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLTERMINATEPROC) (EGLDisplay dpy); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLWAITGLPROC) (void); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLWAITNATIVEPROC) (EGLint engine); +#if EGL_EGL_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig (EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config); +EGLAPI EGLBoolean EGLAPIENTRY eglCopyBuffers (EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target); +EGLAPI EGLContext EGLAPIENTRY eglCreateContext (EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list); +EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferSurface (EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list); +EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurface (EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list); +EGLAPI EGLSurface EGLAPIENTRY eglCreateWindowSurface (EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroyContext (EGLDisplay dpy, EGLContext ctx); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroySurface (EGLDisplay dpy, EGLSurface surface); +EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigAttrib (EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value); +EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigs (EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config); +EGLAPI EGLDisplay EGLAPIENTRY eglGetCurrentDisplay (void); +EGLAPI EGLSurface EGLAPIENTRY eglGetCurrentSurface (EGLint readdraw); +EGLAPI EGLDisplay EGLAPIENTRY eglGetDisplay (EGLNativeDisplayType display_id); +EGLAPI EGLint EGLAPIENTRY eglGetError (void); +EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY eglGetProcAddress (const char *procname); +EGLAPI EGLBoolean EGLAPIENTRY eglInitialize (EGLDisplay dpy, EGLint *major, EGLint *minor); +EGLAPI EGLBoolean EGLAPIENTRY eglMakeCurrent (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryContext (EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value); +EGLAPI const char *EGLAPIENTRY eglQueryString (EGLDisplay dpy, EGLint name); +EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value); +EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers (EGLDisplay dpy, EGLSurface surface); +EGLAPI EGLBoolean EGLAPIENTRY eglTerminate (EGLDisplay dpy); +EGLAPI EGLBoolean EGLAPIENTRY eglWaitGL (void); +EGLAPI EGLBoolean EGLAPIENTRY eglWaitNative (EGLint engine); +#endif +#endif /* EGL_VERSION_1_0 */ + +#ifndef EGL_VERSION_1_1 +#define EGL_VERSION_1_1 1 +#define EGL_BACK_BUFFER 0x3084 +#define EGL_BIND_TO_TEXTURE_RGB 0x3039 +#define EGL_BIND_TO_TEXTURE_RGBA 0x303A +#define EGL_CONTEXT_LOST 0x300E +#define EGL_MIN_SWAP_INTERVAL 0x303B +#define EGL_MAX_SWAP_INTERVAL 0x303C +#define EGL_MIPMAP_TEXTURE 0x3082 +#define EGL_MIPMAP_LEVEL 0x3083 +#define EGL_NO_TEXTURE 0x305C +#define EGL_TEXTURE_2D 0x305F +#define EGL_TEXTURE_FORMAT 0x3080 +#define EGL_TEXTURE_RGB 0x305D +#define EGL_TEXTURE_RGBA 0x305E +#define EGL_TEXTURE_TARGET 0x3081 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLBINDTEXIMAGEPROC) (EGLDisplay dpy, EGLSurface surface, EGLint buffer); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLRELEASETEXIMAGEPROC) (EGLDisplay dpy, EGLSurface surface, EGLint buffer); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSURFACEATTRIBPROC) (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPINTERVALPROC) (EGLDisplay dpy, EGLint interval); +#if EGL_EGL_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglBindTexImage (EGLDisplay dpy, EGLSurface surface, EGLint buffer); +EGLAPI EGLBoolean EGLAPIENTRY eglReleaseTexImage (EGLDisplay dpy, EGLSurface surface, EGLint buffer); +EGLAPI EGLBoolean EGLAPIENTRY eglSurfaceAttrib (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value); +EGLAPI EGLBoolean EGLAPIENTRY eglSwapInterval (EGLDisplay dpy, EGLint interval); +#endif +#endif /* EGL_VERSION_1_1 */ + +#ifndef EGL_VERSION_1_2 +#define EGL_VERSION_1_2 1 +typedef unsigned int EGLenum; +typedef void *EGLClientBuffer; +#define EGL_ALPHA_FORMAT 0x3088 +#define EGL_ALPHA_FORMAT_NONPRE 0x308B +#define EGL_ALPHA_FORMAT_PRE 0x308C +#define EGL_ALPHA_MASK_SIZE 0x303E +#define EGL_BUFFER_PRESERVED 0x3094 +#define EGL_BUFFER_DESTROYED 0x3095 +#define EGL_CLIENT_APIS 0x308D +#define EGL_COLORSPACE 0x3087 +#define EGL_COLORSPACE_sRGB 0x3089 +#define EGL_COLORSPACE_LINEAR 0x308A +#define EGL_COLOR_BUFFER_TYPE 0x303F +#define EGL_CONTEXT_CLIENT_TYPE 0x3097 +#define EGL_DISPLAY_SCALING 10000 +#define EGL_HORIZONTAL_RESOLUTION 0x3090 +#define EGL_LUMINANCE_BUFFER 0x308F +#define EGL_LUMINANCE_SIZE 0x303D +#define EGL_OPENGL_ES_BIT 0x0001 +#define EGL_OPENVG_BIT 0x0002 +#define EGL_OPENGL_ES_API 0x30A0 +#define EGL_OPENVG_API 0x30A1 +#define EGL_OPENVG_IMAGE 0x3096 +#define EGL_PIXEL_ASPECT_RATIO 0x3092 +#define EGL_RENDERABLE_TYPE 0x3040 +#define EGL_RENDER_BUFFER 0x3086 +#define EGL_RGB_BUFFER 0x308E +#define EGL_SINGLE_BUFFER 0x3085 +#define EGL_SWAP_BEHAVIOR 0x3093 +#define EGL_UNKNOWN EGL_CAST(EGLint,-1) +#define EGL_VERTICAL_RESOLUTION 0x3091 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLBINDAPIPROC) (EGLenum api); +typedef EGLenum (EGLAPIENTRYP PFNEGLQUERYAPIPROC) (void); +typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPBUFFERFROMCLIENTBUFFERPROC) (EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLRELEASETHREADPROC) (void); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLWAITCLIENTPROC) (void); +#if EGL_EGL_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglBindAPI (EGLenum api); +EGLAPI EGLenum EGLAPIENTRY eglQueryAPI (void); +EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferFromClientBuffer (EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglReleaseThread (void); +EGLAPI EGLBoolean EGLAPIENTRY eglWaitClient (void); +#endif +#endif /* EGL_VERSION_1_2 */ + +#ifndef EGL_VERSION_1_3 +#define EGL_VERSION_1_3 1 +#define EGL_CONFORMANT 0x3042 +#define EGL_CONTEXT_CLIENT_VERSION 0x3098 +#define EGL_MATCH_NATIVE_PIXMAP 0x3041 +#define EGL_OPENGL_ES2_BIT 0x0004 +#define EGL_VG_ALPHA_FORMAT 0x3088 +#define EGL_VG_ALPHA_FORMAT_NONPRE 0x308B +#define EGL_VG_ALPHA_FORMAT_PRE 0x308C +#define EGL_VG_ALPHA_FORMAT_PRE_BIT 0x0040 +#define EGL_VG_COLORSPACE 0x3087 +#define EGL_VG_COLORSPACE_sRGB 0x3089 +#define EGL_VG_COLORSPACE_LINEAR 0x308A +#define EGL_VG_COLORSPACE_LINEAR_BIT 0x0020 +#endif /* EGL_VERSION_1_3 */ + +#ifndef EGL_VERSION_1_4 +#define EGL_VERSION_1_4 1 +#define EGL_DEFAULT_DISPLAY EGL_CAST(EGLNativeDisplayType,0) +#define EGL_MULTISAMPLE_RESOLVE_BOX_BIT 0x0200 +#define EGL_MULTISAMPLE_RESOLVE 0x3099 +#define EGL_MULTISAMPLE_RESOLVE_DEFAULT 0x309A +#define EGL_MULTISAMPLE_RESOLVE_BOX 0x309B +#define EGL_OPENGL_API 0x30A2 +#define EGL_OPENGL_BIT 0x0008 +#define EGL_SWAP_BEHAVIOR_PRESERVED_BIT 0x0400 +typedef EGLContext (EGLAPIENTRYP PFNEGLGETCURRENTCONTEXTPROC) (void); +#if EGL_EGL_PROTOTYPES +EGLAPI EGLContext EGLAPIENTRY eglGetCurrentContext (void); +#endif +#endif /* EGL_VERSION_1_4 */ + +#ifndef EGL_VERSION_1_5 +#define EGL_VERSION_1_5 1 +typedef void *EGLSync; +typedef intptr_t EGLAttrib; +typedef khronos_utime_nanoseconds_t EGLTime; +typedef void *EGLImage; +#define EGL_CONTEXT_MAJOR_VERSION 0x3098 +#define EGL_CONTEXT_MINOR_VERSION 0x30FB +#define EGL_CONTEXT_OPENGL_PROFILE_MASK 0x30FD +#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY 0x31BD +#define EGL_NO_RESET_NOTIFICATION 0x31BE +#define EGL_LOSE_CONTEXT_ON_RESET 0x31BF +#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT 0x00000001 +#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT 0x00000002 +#define EGL_CONTEXT_OPENGL_DEBUG 0x31B0 +#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE 0x31B1 +#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS 0x31B2 +#define EGL_OPENGL_ES3_BIT 0x00000040 +#define EGL_CL_EVENT_HANDLE 0x309C +#define EGL_SYNC_CL_EVENT 0x30FE +#define EGL_SYNC_CL_EVENT_COMPLETE 0x30FF +#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE 0x30F0 +#define EGL_SYNC_TYPE 0x30F7 +#define EGL_SYNC_STATUS 0x30F1 +#define EGL_SYNC_CONDITION 0x30F8 +#define EGL_SIGNALED 0x30F2 +#define EGL_UNSIGNALED 0x30F3 +#define EGL_SYNC_FLUSH_COMMANDS_BIT 0x0001 +#define EGL_FOREVER 0xFFFFFFFFFFFFFFFFull +#define EGL_TIMEOUT_EXPIRED 0x30F5 +#define EGL_CONDITION_SATISFIED 0x30F6 +#define EGL_NO_SYNC EGL_CAST(EGLSync,0) +#define EGL_SYNC_FENCE 0x30F9 +#define EGL_GL_COLORSPACE 0x309D +#define EGL_GL_COLORSPACE_SRGB 0x3089 +#define EGL_GL_COLORSPACE_LINEAR 0x308A +#define EGL_GL_RENDERBUFFER 0x30B9 +#define EGL_GL_TEXTURE_2D 0x30B1 +#define EGL_GL_TEXTURE_LEVEL 0x30BC +#define EGL_GL_TEXTURE_3D 0x30B2 +#define EGL_GL_TEXTURE_ZOFFSET 0x30BD +#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x30B3 +#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x30B4 +#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x30B5 +#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x30B6 +#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x30B7 +#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x30B8 +#define EGL_IMAGE_PRESERVED 0x30D2 +#define EGL_NO_IMAGE EGL_CAST(EGLImage,0) +typedef EGLSync (EGLAPIENTRYP PFNEGLCREATESYNCPROC) (EGLDisplay dpy, EGLenum type, const EGLAttrib *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCPROC) (EGLDisplay dpy, EGLSync sync); +typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCPROC) (EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBPROC) (EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLAttrib *value); +typedef EGLImage (EGLAPIENTRYP PFNEGLCREATEIMAGEPROC) (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLAttrib *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYIMAGEPROC) (EGLDisplay dpy, EGLImage image); +typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETPLATFORMDISPLAYPROC) (EGLenum platform, void *native_display, const EGLAttrib *attrib_list); +typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPLATFORMWINDOWSURFACEPROC) (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLAttrib *attrib_list); +typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPLATFORMPIXMAPSURFACEPROC) (EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLAttrib *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLWAITSYNCPROC) (EGLDisplay dpy, EGLSync sync, EGLint flags); +#if EGL_EGL_PROTOTYPES +EGLAPI EGLSync EGLAPIENTRY eglCreateSync (EGLDisplay dpy, EGLenum type, const EGLAttrib *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroySync (EGLDisplay dpy, EGLSync sync); +EGLAPI EGLint EGLAPIENTRY eglClientWaitSync (EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout); +EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttrib (EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLAttrib *value); +EGLAPI EGLImage EGLAPIENTRY eglCreateImage (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLAttrib *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImage (EGLDisplay dpy, EGLImage image); +EGLAPI EGLDisplay EGLAPIENTRY eglGetPlatformDisplay (EGLenum platform, void *native_display, const EGLAttrib *attrib_list); +EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformWindowSurface (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLAttrib *attrib_list); +EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformPixmapSurface (EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLAttrib *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglWaitSync (EGLDisplay dpy, EGLSync sync, EGLint flags); +#endif +#endif /* EGL_VERSION_1_5 */ + +#ifdef __cplusplus +} +#endif + +#endif /* __egl_h_ */ + + +#ifndef __eglext_h_ +#define __eglext_h_ 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Copyright 2013-2020 The Khronos Group Inc. +** SPDX-License-Identifier: Apache-2.0 +** +** This header is generated from the Khronos EGL XML API Registry. +** The current version of the Registry, generator scripts +** used to make the header, and the header can be found at +** http://www.khronos.org/registry/egl +** +** Khronos $Git commit SHA1: 6fb1daea15 $ on $Git commit date: 2022-05-25 09:41:13 -0600 $ +*/ + +/*#include */ + +#define EGL_EGLEXT_VERSION 20220525 + +/* Generated C header for: + * API: egl + * Versions considered: .* + * Versions emitted: _nomatch_^ + * Default extensions included: egl + * Additional extensions included: _nomatch_^ + * Extensions removed: _nomatch_^ + */ + +#ifndef EGL_KHR_cl_event +#define EGL_KHR_cl_event 1 +#define EGL_CL_EVENT_HANDLE_KHR 0x309C +#define EGL_SYNC_CL_EVENT_KHR 0x30FE +#define EGL_SYNC_CL_EVENT_COMPLETE_KHR 0x30FF +#endif /* EGL_KHR_cl_event */ + +#ifndef EGL_KHR_cl_event2 +#define EGL_KHR_cl_event2 1 +typedef void *EGLSyncKHR; +typedef intptr_t EGLAttribKHR; +typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESYNC64KHRPROC) (EGLDisplay dpy, EGLenum type, const EGLAttribKHR *attrib_list); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSync64KHR (EGLDisplay dpy, EGLenum type, const EGLAttribKHR *attrib_list); +#endif +#endif /* EGL_KHR_cl_event2 */ + +#ifndef EGL_KHR_client_get_all_proc_addresses +#define EGL_KHR_client_get_all_proc_addresses 1 +#endif /* EGL_KHR_client_get_all_proc_addresses */ + +#ifndef EGL_KHR_config_attribs +#define EGL_KHR_config_attribs 1 +#define EGL_CONFORMANT_KHR 0x3042 +#define EGL_VG_COLORSPACE_LINEAR_BIT_KHR 0x0020 +#define EGL_VG_ALPHA_FORMAT_PRE_BIT_KHR 0x0040 +#endif /* EGL_KHR_config_attribs */ + +#ifndef EGL_KHR_context_flush_control +#define EGL_KHR_context_flush_control 1 +#define EGL_CONTEXT_RELEASE_BEHAVIOR_NONE_KHR 0 +#define EGL_CONTEXT_RELEASE_BEHAVIOR_KHR 0x2097 +#define EGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR 0x2098 +#endif /* EGL_KHR_context_flush_control */ + +#ifndef EGL_KHR_create_context +#define EGL_KHR_create_context 1 +#define EGL_CONTEXT_MAJOR_VERSION_KHR 0x3098 +#define EGL_CONTEXT_MINOR_VERSION_KHR 0x30FB +#define EGL_CONTEXT_FLAGS_KHR 0x30FC +#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30FD +#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR 0x31BD +#define EGL_NO_RESET_NOTIFICATION_KHR 0x31BE +#define EGL_LOSE_CONTEXT_ON_RESET_KHR 0x31BF +#define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR 0x00000001 +#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002 +#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR 0x00000004 +#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001 +#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002 +#define EGL_OPENGL_ES3_BIT_KHR 0x00000040 +#endif /* EGL_KHR_create_context */ + +#ifndef EGL_KHR_create_context_no_error +#define EGL_KHR_create_context_no_error 1 +#define EGL_CONTEXT_OPENGL_NO_ERROR_KHR 0x31B3 +#endif /* EGL_KHR_create_context_no_error */ + +#ifndef EGL_KHR_debug +#define EGL_KHR_debug 1 +typedef void *EGLLabelKHR; +typedef void *EGLObjectKHR; +typedef void (EGLAPIENTRY *EGLDEBUGPROCKHR)(EGLenum error,const char *command,EGLint messageType,EGLLabelKHR threadLabel,EGLLabelKHR objectLabel,const char* message); +#define EGL_OBJECT_THREAD_KHR 0x33B0 +#define EGL_OBJECT_DISPLAY_KHR 0x33B1 +#define EGL_OBJECT_CONTEXT_KHR 0x33B2 +#define EGL_OBJECT_SURFACE_KHR 0x33B3 +#define EGL_OBJECT_IMAGE_KHR 0x33B4 +#define EGL_OBJECT_SYNC_KHR 0x33B5 +#define EGL_OBJECT_STREAM_KHR 0x33B6 +#define EGL_DEBUG_MSG_CRITICAL_KHR 0x33B9 +#define EGL_DEBUG_MSG_ERROR_KHR 0x33BA +#define EGL_DEBUG_MSG_WARN_KHR 0x33BB +#define EGL_DEBUG_MSG_INFO_KHR 0x33BC +#define EGL_DEBUG_CALLBACK_KHR 0x33B8 +typedef EGLint (EGLAPIENTRYP PFNEGLDEBUGMESSAGECONTROLKHRPROC) (EGLDEBUGPROCKHR callback, const EGLAttrib *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDEBUGKHRPROC) (EGLint attribute, EGLAttrib *value); +typedef EGLint (EGLAPIENTRYP PFNEGLLABELOBJECTKHRPROC) (EGLDisplay display, EGLenum objectType, EGLObjectKHR object, EGLLabelKHR label); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLint EGLAPIENTRY eglDebugMessageControlKHR (EGLDEBUGPROCKHR callback, const EGLAttrib *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryDebugKHR (EGLint attribute, EGLAttrib *value); +EGLAPI EGLint EGLAPIENTRY eglLabelObjectKHR (EGLDisplay display, EGLenum objectType, EGLObjectKHR object, EGLLabelKHR label); +#endif +#endif /* EGL_KHR_debug */ + +#ifndef EGL_KHR_display_reference +#define EGL_KHR_display_reference 1 +#define EGL_TRACK_REFERENCES_KHR 0x3352 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDISPLAYATTRIBKHRPROC) (EGLDisplay dpy, EGLint name, EGLAttrib *value); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglQueryDisplayAttribKHR (EGLDisplay dpy, EGLint name, EGLAttrib *value); +#endif +#endif /* EGL_KHR_display_reference */ + +#ifndef EGL_KHR_fence_sync +#define EGL_KHR_fence_sync 1 +typedef khronos_utime_nanoseconds_t EGLTimeKHR; +#ifdef KHRONOS_SUPPORT_INT64 +#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR 0x30F0 +#define EGL_SYNC_CONDITION_KHR 0x30F8 +#define EGL_SYNC_FENCE_KHR 0x30F9 +typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESYNCKHRPROC) (EGLDisplay dpy, EGLenum type, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync); +typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSyncKHR (EGLDisplay dpy, EGLenum type, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncKHR (EGLDisplay dpy, EGLSyncKHR sync); +EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout); +EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value); +#endif +#endif /* KHRONOS_SUPPORT_INT64 */ +#endif /* EGL_KHR_fence_sync */ + +#ifndef EGL_KHR_get_all_proc_addresses +#define EGL_KHR_get_all_proc_addresses 1 +#endif /* EGL_KHR_get_all_proc_addresses */ + +#ifndef EGL_KHR_gl_colorspace +#define EGL_KHR_gl_colorspace 1 +#define EGL_GL_COLORSPACE_KHR 0x309D +#define EGL_GL_COLORSPACE_SRGB_KHR 0x3089 +#define EGL_GL_COLORSPACE_LINEAR_KHR 0x308A +#endif /* EGL_KHR_gl_colorspace */ + +#ifndef EGL_KHR_gl_renderbuffer_image +#define EGL_KHR_gl_renderbuffer_image 1 +#define EGL_GL_RENDERBUFFER_KHR 0x30B9 +#endif /* EGL_KHR_gl_renderbuffer_image */ + +#ifndef EGL_KHR_gl_texture_2D_image +#define EGL_KHR_gl_texture_2D_image 1 +#define EGL_GL_TEXTURE_2D_KHR 0x30B1 +#define EGL_GL_TEXTURE_LEVEL_KHR 0x30BC +#endif /* EGL_KHR_gl_texture_2D_image */ + +#ifndef EGL_KHR_gl_texture_3D_image +#define EGL_KHR_gl_texture_3D_image 1 +#define EGL_GL_TEXTURE_3D_KHR 0x30B2 +#define EGL_GL_TEXTURE_ZOFFSET_KHR 0x30BD +#endif /* EGL_KHR_gl_texture_3D_image */ + +#ifndef EGL_KHR_gl_texture_cubemap_image +#define EGL_KHR_gl_texture_cubemap_image 1 +#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR 0x30B3 +#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X_KHR 0x30B4 +#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y_KHR 0x30B5 +#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_KHR 0x30B6 +#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_KHR 0x30B7 +#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_KHR 0x30B8 +#endif /* EGL_KHR_gl_texture_cubemap_image */ + +#ifndef EGL_KHR_image +#define EGL_KHR_image 1 +typedef void *EGLImageKHR; +#define EGL_NATIVE_PIXMAP_KHR 0x30B0 +#define EGL_NO_IMAGE_KHR EGL_CAST(EGLImageKHR,0) +typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEIMAGEKHRPROC) (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYIMAGEKHRPROC) (EGLDisplay dpy, EGLImageKHR image); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLImageKHR EGLAPIENTRY eglCreateImageKHR (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImageKHR (EGLDisplay dpy, EGLImageKHR image); +#endif +#endif /* EGL_KHR_image */ + +#ifndef EGL_KHR_image_base +#define EGL_KHR_image_base 1 +#define EGL_IMAGE_PRESERVED_KHR 0x30D2 +#endif /* EGL_KHR_image_base */ + +#ifndef EGL_KHR_image_pixmap +#define EGL_KHR_image_pixmap 1 +#endif /* EGL_KHR_image_pixmap */ + +#ifndef EGL_KHR_lock_surface +#define EGL_KHR_lock_surface 1 +#define EGL_READ_SURFACE_BIT_KHR 0x0001 +#define EGL_WRITE_SURFACE_BIT_KHR 0x0002 +#define EGL_LOCK_SURFACE_BIT_KHR 0x0080 +#define EGL_OPTIMAL_FORMAT_BIT_KHR 0x0100 +#define EGL_MATCH_FORMAT_KHR 0x3043 +#define EGL_FORMAT_RGB_565_EXACT_KHR 0x30C0 +#define EGL_FORMAT_RGB_565_KHR 0x30C1 +#define EGL_FORMAT_RGBA_8888_EXACT_KHR 0x30C2 +#define EGL_FORMAT_RGBA_8888_KHR 0x30C3 +#define EGL_MAP_PRESERVE_PIXELS_KHR 0x30C4 +#define EGL_LOCK_USAGE_HINT_KHR 0x30C5 +#define EGL_BITMAP_POINTER_KHR 0x30C6 +#define EGL_BITMAP_PITCH_KHR 0x30C7 +#define EGL_BITMAP_ORIGIN_KHR 0x30C8 +#define EGL_BITMAP_PIXEL_RED_OFFSET_KHR 0x30C9 +#define EGL_BITMAP_PIXEL_GREEN_OFFSET_KHR 0x30CA +#define EGL_BITMAP_PIXEL_BLUE_OFFSET_KHR 0x30CB +#define EGL_BITMAP_PIXEL_ALPHA_OFFSET_KHR 0x30CC +#define EGL_BITMAP_PIXEL_LUMINANCE_OFFSET_KHR 0x30CD +#define EGL_LOWER_LEFT_KHR 0x30CE +#define EGL_UPPER_LEFT_KHR 0x30CF +typedef EGLBoolean (EGLAPIENTRYP PFNEGLLOCKSURFACEKHRPROC) (EGLDisplay dpy, EGLSurface surface, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNLOCKSURFACEKHRPROC) (EGLDisplay dpy, EGLSurface surface); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglLockSurfaceKHR (EGLDisplay dpy, EGLSurface surface, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglUnlockSurfaceKHR (EGLDisplay dpy, EGLSurface surface); +#endif +#endif /* EGL_KHR_lock_surface */ + +#ifndef EGL_KHR_lock_surface2 +#define EGL_KHR_lock_surface2 1 +#define EGL_BITMAP_PIXEL_SIZE_KHR 0x3110 +#endif /* EGL_KHR_lock_surface2 */ + +#ifndef EGL_KHR_lock_surface3 +#define EGL_KHR_lock_surface3 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSURFACE64KHRPROC) (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLAttribKHR *value); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface64KHR (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLAttribKHR *value); +#endif +#endif /* EGL_KHR_lock_surface3 */ + +#ifndef EGL_KHR_mutable_render_buffer +#define EGL_KHR_mutable_render_buffer 1 +#define EGL_MUTABLE_RENDER_BUFFER_BIT_KHR 0x1000 +#endif /* EGL_KHR_mutable_render_buffer */ + +#ifndef EGL_KHR_no_config_context +#define EGL_KHR_no_config_context 1 +#define EGL_NO_CONFIG_KHR EGL_CAST(EGLConfig,0) +#endif /* EGL_KHR_no_config_context */ + +#ifndef EGL_KHR_partial_update +#define EGL_KHR_partial_update 1 +#define EGL_BUFFER_AGE_KHR 0x313D +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSETDAMAGEREGIONKHRPROC) (EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglSetDamageRegionKHR (EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects); +#endif +#endif /* EGL_KHR_partial_update */ + +#ifndef EGL_KHR_platform_android +#define EGL_KHR_platform_android 1 +#define EGL_PLATFORM_ANDROID_KHR 0x3141 +#endif /* EGL_KHR_platform_android */ + +#ifndef EGL_KHR_platform_gbm +#define EGL_KHR_platform_gbm 1 +#define EGL_PLATFORM_GBM_KHR 0x31D7 +#endif /* EGL_KHR_platform_gbm */ + +#ifndef EGL_KHR_platform_wayland +#define EGL_KHR_platform_wayland 1 +#define EGL_PLATFORM_WAYLAND_KHR 0x31D8 +#endif /* EGL_KHR_platform_wayland */ + +#ifndef EGL_KHR_platform_x11 +#define EGL_KHR_platform_x11 1 +#define EGL_PLATFORM_X11_KHR 0x31D5 +#define EGL_PLATFORM_X11_SCREEN_KHR 0x31D6 +#endif /* EGL_KHR_platform_x11 */ + +#ifndef EGL_KHR_reusable_sync +#define EGL_KHR_reusable_sync 1 +#ifdef KHRONOS_SUPPORT_INT64 +#define EGL_SYNC_STATUS_KHR 0x30F1 +#define EGL_SIGNALED_KHR 0x30F2 +#define EGL_UNSIGNALED_KHR 0x30F3 +#define EGL_TIMEOUT_EXPIRED_KHR 0x30F5 +#define EGL_CONDITION_SATISFIED_KHR 0x30F6 +#define EGL_SYNC_TYPE_KHR 0x30F7 +#define EGL_SYNC_REUSABLE_KHR 0x30FA +#define EGL_SYNC_FLUSH_COMMANDS_BIT_KHR 0x0001 +#define EGL_FOREVER_KHR 0xFFFFFFFFFFFFFFFFull +#define EGL_NO_SYNC_KHR EGL_CAST(EGLSyncKHR,0) +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode); +#endif +#endif /* KHRONOS_SUPPORT_INT64 */ +#endif /* EGL_KHR_reusable_sync */ + +#ifndef EGL_KHR_stream +#define EGL_KHR_stream 1 +typedef void *EGLStreamKHR; +typedef khronos_uint64_t EGLuint64KHR; +#ifdef KHRONOS_SUPPORT_INT64 +#define EGL_NO_STREAM_KHR EGL_CAST(EGLStreamKHR,0) +#define EGL_CONSUMER_LATENCY_USEC_KHR 0x3210 +#define EGL_PRODUCER_FRAME_KHR 0x3212 +#define EGL_CONSUMER_FRAME_KHR 0x3213 +#define EGL_STREAM_STATE_KHR 0x3214 +#define EGL_STREAM_STATE_CREATED_KHR 0x3215 +#define EGL_STREAM_STATE_CONNECTING_KHR 0x3216 +#define EGL_STREAM_STATE_EMPTY_KHR 0x3217 +#define EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR 0x3218 +#define EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR 0x3219 +#define EGL_STREAM_STATE_DISCONNECTED_KHR 0x321A +#define EGL_BAD_STREAM_KHR 0x321B +#define EGL_BAD_STATE_KHR 0x321C +typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMKHRPROC) (EGLDisplay dpy, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSTREAMKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMATTRIBKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMU64KHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamKHR (EGLDisplay dpy, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroyStreamKHR (EGLDisplay dpy, EGLStreamKHR stream); +EGLAPI EGLBoolean EGLAPIENTRY eglStreamAttribKHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamKHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamu64KHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value); +#endif +#endif /* KHRONOS_SUPPORT_INT64 */ +#endif /* EGL_KHR_stream */ + +#ifndef EGL_KHR_stream_attrib +#define EGL_KHR_stream_attrib 1 +#ifdef KHRONOS_SUPPORT_INT64 +typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMATTRIBKHRPROC) (EGLDisplay dpy, const EGLAttrib *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSETSTREAMATTRIBKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLAttrib value); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMATTRIBKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLAttrib *value); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERACQUIREATTRIBKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, const EGLAttrib *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERRELEASEATTRIBKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, const EGLAttrib *attrib_list); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamAttribKHR (EGLDisplay dpy, const EGLAttrib *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglSetStreamAttribKHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLAttrib value); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamAttribKHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLAttrib *value); +EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerAcquireAttribKHR (EGLDisplay dpy, EGLStreamKHR stream, const EGLAttrib *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerReleaseAttribKHR (EGLDisplay dpy, EGLStreamKHR stream, const EGLAttrib *attrib_list); +#endif +#endif /* KHRONOS_SUPPORT_INT64 */ +#endif /* EGL_KHR_stream_attrib */ + +#ifndef EGL_KHR_stream_consumer_gltexture +#define EGL_KHR_stream_consumer_gltexture 1 +#ifdef EGL_KHR_stream +#define EGL_CONSUMER_ACQUIRE_TIMEOUT_USEC_KHR 0x321E +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERGLTEXTUREEXTERNALKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERACQUIREKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERRELEASEKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerGLTextureExternalKHR (EGLDisplay dpy, EGLStreamKHR stream); +EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerAcquireKHR (EGLDisplay dpy, EGLStreamKHR stream); +EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerReleaseKHR (EGLDisplay dpy, EGLStreamKHR stream); +#endif +#endif /* EGL_KHR_stream */ +#endif /* EGL_KHR_stream_consumer_gltexture */ + +#ifndef EGL_KHR_stream_cross_process_fd +#define EGL_KHR_stream_cross_process_fd 1 +typedef int EGLNativeFileDescriptorKHR; +#ifdef EGL_KHR_stream +#define EGL_NO_FILE_DESCRIPTOR_KHR EGL_CAST(EGLNativeFileDescriptorKHR,-1) +typedef EGLNativeFileDescriptorKHR (EGLAPIENTRYP PFNEGLGETSTREAMFILEDESCRIPTORKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); +typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMFROMFILEDESCRIPTORKHRPROC) (EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLNativeFileDescriptorKHR EGLAPIENTRY eglGetStreamFileDescriptorKHR (EGLDisplay dpy, EGLStreamKHR stream); +EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamFromFileDescriptorKHR (EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor); +#endif +#endif /* EGL_KHR_stream */ +#endif /* EGL_KHR_stream_cross_process_fd */ + +#ifndef EGL_KHR_stream_fifo +#define EGL_KHR_stream_fifo 1 +#ifdef EGL_KHR_stream +#define EGL_STREAM_FIFO_LENGTH_KHR 0x31FC +#define EGL_STREAM_TIME_NOW_KHR 0x31FD +#define EGL_STREAM_TIME_CONSUMER_KHR 0x31FE +#define EGL_STREAM_TIME_PRODUCER_KHR 0x31FF +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMTIMEKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR *value); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamTimeKHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR *value); +#endif +#endif /* EGL_KHR_stream */ +#endif /* EGL_KHR_stream_fifo */ + +#ifndef EGL_KHR_stream_producer_aldatalocator +#define EGL_KHR_stream_producer_aldatalocator 1 +#ifdef EGL_KHR_stream +#endif /* EGL_KHR_stream */ +#endif /* EGL_KHR_stream_producer_aldatalocator */ + +#ifndef EGL_KHR_stream_producer_eglsurface +#define EGL_KHR_stream_producer_eglsurface 1 +#ifdef EGL_KHR_stream +#define EGL_STREAM_BIT_KHR 0x0800 +typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATESTREAMPRODUCERSURFACEKHRPROC) (EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint *attrib_list); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLSurface EGLAPIENTRY eglCreateStreamProducerSurfaceKHR (EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint *attrib_list); +#endif +#endif /* EGL_KHR_stream */ +#endif /* EGL_KHR_stream_producer_eglsurface */ + +#ifndef EGL_KHR_surfaceless_context +#define EGL_KHR_surfaceless_context 1 +#endif /* EGL_KHR_surfaceless_context */ + +#ifndef EGL_KHR_swap_buffers_with_damage +#define EGL_KHR_swap_buffers_with_damage 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSWITHDAMAGEKHRPROC) (EGLDisplay dpy, EGLSurface surface, const EGLint *rects, EGLint n_rects); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersWithDamageKHR (EGLDisplay dpy, EGLSurface surface, const EGLint *rects, EGLint n_rects); +#endif +#endif /* EGL_KHR_swap_buffers_with_damage */ + +#ifndef EGL_KHR_vg_parent_image +#define EGL_KHR_vg_parent_image 1 +#define EGL_VG_PARENT_IMAGE_KHR 0x30BA +#endif /* EGL_KHR_vg_parent_image */ + +#ifndef EGL_KHR_wait_sync +#define EGL_KHR_wait_sync 1 +typedef EGLint (EGLAPIENTRYP PFNEGLWAITSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLint EGLAPIENTRY eglWaitSyncKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags); +#endif +#endif /* EGL_KHR_wait_sync */ + +#ifndef EGL_ANDROID_GLES_layers +#define EGL_ANDROID_GLES_layers 1 +#endif /* EGL_ANDROID_GLES_layers */ + +#ifndef EGL_ANDROID_blob_cache +#define EGL_ANDROID_blob_cache 1 +typedef khronos_ssize_t EGLsizeiANDROID; +typedef void (*EGLSetBlobFuncANDROID) (const void *key, EGLsizeiANDROID keySize, const void *value, EGLsizeiANDROID valueSize); +typedef EGLsizeiANDROID (*EGLGetBlobFuncANDROID) (const void *key, EGLsizeiANDROID keySize, void *value, EGLsizeiANDROID valueSize); +typedef void (EGLAPIENTRYP PFNEGLSETBLOBCACHEFUNCSANDROIDPROC) (EGLDisplay dpy, EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI void EGLAPIENTRY eglSetBlobCacheFuncsANDROID (EGLDisplay dpy, EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get); +#endif +#endif /* EGL_ANDROID_blob_cache */ + +#ifndef EGL_ANDROID_create_native_client_buffer +#define EGL_ANDROID_create_native_client_buffer 1 +#define EGL_NATIVE_BUFFER_USAGE_ANDROID 0x3143 +#define EGL_NATIVE_BUFFER_USAGE_PROTECTED_BIT_ANDROID 0x00000001 +#define EGL_NATIVE_BUFFER_USAGE_RENDERBUFFER_BIT_ANDROID 0x00000002 +#define EGL_NATIVE_BUFFER_USAGE_TEXTURE_BIT_ANDROID 0x00000004 +typedef EGLClientBuffer (EGLAPIENTRYP PFNEGLCREATENATIVECLIENTBUFFERANDROIDPROC) (const EGLint *attrib_list); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLClientBuffer EGLAPIENTRY eglCreateNativeClientBufferANDROID (const EGLint *attrib_list); +#endif +#endif /* EGL_ANDROID_create_native_client_buffer */ + +#ifndef EGL_ANDROID_framebuffer_target +#define EGL_ANDROID_framebuffer_target 1 +#define EGL_FRAMEBUFFER_TARGET_ANDROID 0x3147 +#endif /* EGL_ANDROID_framebuffer_target */ + +#ifndef EGL_ANDROID_front_buffer_auto_refresh +#define EGL_ANDROID_front_buffer_auto_refresh 1 +#define EGL_FRONT_BUFFER_AUTO_REFRESH_ANDROID 0x314C +#endif /* EGL_ANDROID_front_buffer_auto_refresh */ + +#ifndef EGL_ANDROID_get_frame_timestamps +#define EGL_ANDROID_get_frame_timestamps 1 +typedef khronos_stime_nanoseconds_t EGLnsecsANDROID; +#define EGL_TIMESTAMP_PENDING_ANDROID EGL_CAST(EGLnsecsANDROID,-2) +#define EGL_TIMESTAMP_INVALID_ANDROID EGL_CAST(EGLnsecsANDROID,-1) +#define EGL_TIMESTAMPS_ANDROID 0x3430 +#define EGL_COMPOSITE_DEADLINE_ANDROID 0x3431 +#define EGL_COMPOSITE_INTERVAL_ANDROID 0x3432 +#define EGL_COMPOSITE_TO_PRESENT_LATENCY_ANDROID 0x3433 +#define EGL_REQUESTED_PRESENT_TIME_ANDROID 0x3434 +#define EGL_RENDERING_COMPLETE_TIME_ANDROID 0x3435 +#define EGL_COMPOSITION_LATCH_TIME_ANDROID 0x3436 +#define EGL_FIRST_COMPOSITION_START_TIME_ANDROID 0x3437 +#define EGL_LAST_COMPOSITION_START_TIME_ANDROID 0x3438 +#define EGL_FIRST_COMPOSITION_GPU_FINISHED_TIME_ANDROID 0x3439 +#define EGL_DISPLAY_PRESENT_TIME_ANDROID 0x343A +#define EGL_DEQUEUE_READY_TIME_ANDROID 0x343B +#define EGL_READS_DONE_TIME_ANDROID 0x343C +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETCOMPOSITORTIMINGSUPPORTEDANDROIDPROC) (EGLDisplay dpy, EGLSurface surface, EGLint name); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETCOMPOSITORTIMINGANDROIDPROC) (EGLDisplay dpy, EGLSurface surface, EGLint numTimestamps, const EGLint *names, EGLnsecsANDROID *values); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETNEXTFRAMEIDANDROIDPROC) (EGLDisplay dpy, EGLSurface surface, EGLuint64KHR *frameId); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETFRAMETIMESTAMPSUPPORTEDANDROIDPROC) (EGLDisplay dpy, EGLSurface surface, EGLint timestamp); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETFRAMETIMESTAMPSANDROIDPROC) (EGLDisplay dpy, EGLSurface surface, EGLuint64KHR frameId, EGLint numTimestamps, const EGLint *timestamps, EGLnsecsANDROID *values); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglGetCompositorTimingSupportedANDROID (EGLDisplay dpy, EGLSurface surface, EGLint name); +EGLAPI EGLBoolean EGLAPIENTRY eglGetCompositorTimingANDROID (EGLDisplay dpy, EGLSurface surface, EGLint numTimestamps, const EGLint *names, EGLnsecsANDROID *values); +EGLAPI EGLBoolean EGLAPIENTRY eglGetNextFrameIdANDROID (EGLDisplay dpy, EGLSurface surface, EGLuint64KHR *frameId); +EGLAPI EGLBoolean EGLAPIENTRY eglGetFrameTimestampSupportedANDROID (EGLDisplay dpy, EGLSurface surface, EGLint timestamp); +EGLAPI EGLBoolean EGLAPIENTRY eglGetFrameTimestampsANDROID (EGLDisplay dpy, EGLSurface surface, EGLuint64KHR frameId, EGLint numTimestamps, const EGLint *timestamps, EGLnsecsANDROID *values); +#endif +#endif /* EGL_ANDROID_get_frame_timestamps */ + +#ifndef EGL_ANDROID_get_native_client_buffer +#define EGL_ANDROID_get_native_client_buffer 1 +struct AHardwareBuffer; +typedef EGLClientBuffer (EGLAPIENTRYP PFNEGLGETNATIVECLIENTBUFFERANDROIDPROC) (const struct AHardwareBuffer *buffer); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLClientBuffer EGLAPIENTRY eglGetNativeClientBufferANDROID (const struct AHardwareBuffer *buffer); +#endif +#endif /* EGL_ANDROID_get_native_client_buffer */ + +#ifndef EGL_ANDROID_image_native_buffer +#define EGL_ANDROID_image_native_buffer 1 +#define EGL_NATIVE_BUFFER_ANDROID 0x3140 +#endif /* EGL_ANDROID_image_native_buffer */ + +#ifndef EGL_ANDROID_native_fence_sync +#define EGL_ANDROID_native_fence_sync 1 +#define EGL_SYNC_NATIVE_FENCE_ANDROID 0x3144 +#define EGL_SYNC_NATIVE_FENCE_FD_ANDROID 0x3145 +#define EGL_SYNC_NATIVE_FENCE_SIGNALED_ANDROID 0x3146 +#define EGL_NO_NATIVE_FENCE_FD_ANDROID -1 +typedef EGLint (EGLAPIENTRYP PFNEGLDUPNATIVEFENCEFDANDROIDPROC) (EGLDisplay dpy, EGLSyncKHR sync); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLint EGLAPIENTRY eglDupNativeFenceFDANDROID (EGLDisplay dpy, EGLSyncKHR sync); +#endif +#endif /* EGL_ANDROID_native_fence_sync */ + +#ifndef EGL_ANDROID_presentation_time +#define EGL_ANDROID_presentation_time 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLPRESENTATIONTIMEANDROIDPROC) (EGLDisplay dpy, EGLSurface surface, EGLnsecsANDROID time); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglPresentationTimeANDROID (EGLDisplay dpy, EGLSurface surface, EGLnsecsANDROID time); +#endif +#endif /* EGL_ANDROID_presentation_time */ + +#ifndef EGL_ANDROID_recordable +#define EGL_ANDROID_recordable 1 +#define EGL_RECORDABLE_ANDROID 0x3142 +#endif /* EGL_ANDROID_recordable */ + +#ifndef EGL_ANGLE_d3d_share_handle_client_buffer +#define EGL_ANGLE_d3d_share_handle_client_buffer 1 +#define EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE 0x3200 +#endif /* EGL_ANGLE_d3d_share_handle_client_buffer */ + +#ifndef EGL_ANGLE_device_d3d +#define EGL_ANGLE_device_d3d 1 +#define EGL_D3D9_DEVICE_ANGLE 0x33A0 +#define EGL_D3D11_DEVICE_ANGLE 0x33A1 +#endif /* EGL_ANGLE_device_d3d */ + +#ifndef EGL_ANGLE_query_surface_pointer +#define EGL_ANGLE_query_surface_pointer 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSURFACEPOINTERANGLEPROC) (EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurfacePointerANGLE (EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value); +#endif +#endif /* EGL_ANGLE_query_surface_pointer */ + +#ifndef EGL_ANGLE_surface_d3d_texture_2d_share_handle +#define EGL_ANGLE_surface_d3d_texture_2d_share_handle 1 +#endif /* EGL_ANGLE_surface_d3d_texture_2d_share_handle */ + +#ifndef EGL_ANGLE_sync_control_rate +#define EGL_ANGLE_sync_control_rate 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETMSCRATEANGLEPROC) (EGLDisplay dpy, EGLSurface surface, EGLint *numerator, EGLint *denominator); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglGetMscRateANGLE (EGLDisplay dpy, EGLSurface surface, EGLint *numerator, EGLint *denominator); +#endif +#endif /* EGL_ANGLE_sync_control_rate */ + +#ifndef EGL_ANGLE_window_fixed_size +#define EGL_ANGLE_window_fixed_size 1 +#define EGL_FIXED_SIZE_ANGLE 0x3201 +#endif /* EGL_ANGLE_window_fixed_size */ + +#ifndef EGL_ARM_image_format +#define EGL_ARM_image_format 1 +#define EGL_COLOR_COMPONENT_TYPE_UNSIGNED_INTEGER_ARM 0x3287 +#define EGL_COLOR_COMPONENT_TYPE_INTEGER_ARM 0x3288 +#endif /* EGL_ARM_image_format */ + +#ifndef EGL_ARM_implicit_external_sync +#define EGL_ARM_implicit_external_sync 1 +#define EGL_SYNC_PRIOR_COMMANDS_IMPLICIT_EXTERNAL_ARM 0x328A +#endif /* EGL_ARM_implicit_external_sync */ + +#ifndef EGL_ARM_pixmap_multisample_discard +#define EGL_ARM_pixmap_multisample_discard 1 +#define EGL_DISCARD_SAMPLES_ARM 0x3286 +#endif /* EGL_ARM_pixmap_multisample_discard */ + +#ifndef EGL_EXT_bind_to_front +#define EGL_EXT_bind_to_front 1 +#define EGL_FRONT_BUFFER_EXT 0x3464 +#endif /* EGL_EXT_bind_to_front */ + +#ifndef EGL_EXT_buffer_age +#define EGL_EXT_buffer_age 1 +#define EGL_BUFFER_AGE_EXT 0x313D +#endif /* EGL_EXT_buffer_age */ + +#ifndef EGL_EXT_client_extensions +#define EGL_EXT_client_extensions 1 +#endif /* EGL_EXT_client_extensions */ + +#ifndef EGL_EXT_client_sync +#define EGL_EXT_client_sync 1 +#define EGL_SYNC_CLIENT_EXT 0x3364 +#define EGL_SYNC_CLIENT_SIGNAL_EXT 0x3365 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLCLIENTSIGNALSYNCEXTPROC) (EGLDisplay dpy, EGLSync sync, const EGLAttrib *attrib_list); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglClientSignalSyncEXT (EGLDisplay dpy, EGLSync sync, const EGLAttrib *attrib_list); +#endif +#endif /* EGL_EXT_client_sync */ + +#ifndef EGL_EXT_compositor +#define EGL_EXT_compositor 1 +#define EGL_PRIMARY_COMPOSITOR_CONTEXT_EXT 0x3460 +#define EGL_EXTERNAL_REF_ID_EXT 0x3461 +#define EGL_COMPOSITOR_DROP_NEWEST_FRAME_EXT 0x3462 +#define EGL_COMPOSITOR_KEEP_NEWEST_FRAME_EXT 0x3463 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLCOMPOSITORSETCONTEXTLISTEXTPROC) (const EGLint *external_ref_ids, EGLint num_entries); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLCOMPOSITORSETCONTEXTATTRIBUTESEXTPROC) (EGLint external_ref_id, const EGLint *context_attributes, EGLint num_entries); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLCOMPOSITORSETWINDOWLISTEXTPROC) (EGLint external_ref_id, const EGLint *external_win_ids, EGLint num_entries); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLCOMPOSITORSETWINDOWATTRIBUTESEXTPROC) (EGLint external_win_id, const EGLint *window_attributes, EGLint num_entries); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLCOMPOSITORBINDTEXWINDOWEXTPROC) (EGLint external_win_id); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLCOMPOSITORSETSIZEEXTPROC) (EGLint external_win_id, EGLint width, EGLint height); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLCOMPOSITORSWAPPOLICYEXTPROC) (EGLint external_win_id, EGLint policy); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglCompositorSetContextListEXT (const EGLint *external_ref_ids, EGLint num_entries); +EGLAPI EGLBoolean EGLAPIENTRY eglCompositorSetContextAttributesEXT (EGLint external_ref_id, const EGLint *context_attributes, EGLint num_entries); +EGLAPI EGLBoolean EGLAPIENTRY eglCompositorSetWindowListEXT (EGLint external_ref_id, const EGLint *external_win_ids, EGLint num_entries); +EGLAPI EGLBoolean EGLAPIENTRY eglCompositorSetWindowAttributesEXT (EGLint external_win_id, const EGLint *window_attributes, EGLint num_entries); +EGLAPI EGLBoolean EGLAPIENTRY eglCompositorBindTexWindowEXT (EGLint external_win_id); +EGLAPI EGLBoolean EGLAPIENTRY eglCompositorSetSizeEXT (EGLint external_win_id, EGLint width, EGLint height); +EGLAPI EGLBoolean EGLAPIENTRY eglCompositorSwapPolicyEXT (EGLint external_win_id, EGLint policy); +#endif +#endif /* EGL_EXT_compositor */ + +#ifndef EGL_EXT_config_select_group +#define EGL_EXT_config_select_group 1 +#define EGL_CONFIG_SELECT_GROUP_EXT 0x34C0 +#endif /* EGL_EXT_config_select_group */ + +#ifndef EGL_EXT_create_context_robustness +#define EGL_EXT_create_context_robustness 1 +#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT 0x30BF +#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT 0x3138 +#define EGL_NO_RESET_NOTIFICATION_EXT 0x31BE +#define EGL_LOSE_CONTEXT_ON_RESET_EXT 0x31BF +#endif /* EGL_EXT_create_context_robustness */ + +#ifndef EGL_EXT_device_base +#define EGL_EXT_device_base 1 +typedef void *EGLDeviceEXT; +#define EGL_NO_DEVICE_EXT EGL_CAST(EGLDeviceEXT,0) +#define EGL_BAD_DEVICE_EXT 0x322B +#define EGL_DEVICE_EXT 0x322C +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDEVICEATTRIBEXTPROC) (EGLDeviceEXT device, EGLint attribute, EGLAttrib *value); +typedef const char *(EGLAPIENTRYP PFNEGLQUERYDEVICESTRINGEXTPROC) (EGLDeviceEXT device, EGLint name); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDEVICESEXTPROC) (EGLint max_devices, EGLDeviceEXT *devices, EGLint *num_devices); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDISPLAYATTRIBEXTPROC) (EGLDisplay dpy, EGLint attribute, EGLAttrib *value); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglQueryDeviceAttribEXT (EGLDeviceEXT device, EGLint attribute, EGLAttrib *value); +EGLAPI const char *EGLAPIENTRY eglQueryDeviceStringEXT (EGLDeviceEXT device, EGLint name); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryDevicesEXT (EGLint max_devices, EGLDeviceEXT *devices, EGLint *num_devices); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryDisplayAttribEXT (EGLDisplay dpy, EGLint attribute, EGLAttrib *value); +#endif +#endif /* EGL_EXT_device_base */ + +#ifndef EGL_EXT_device_drm +#define EGL_EXT_device_drm 1 +#define EGL_DRM_DEVICE_FILE_EXT 0x3233 +#define EGL_DRM_MASTER_FD_EXT 0x333C +#endif /* EGL_EXT_device_drm */ + +#ifndef EGL_EXT_device_drm_render_node +#define EGL_EXT_device_drm_render_node 1 +#define EGL_DRM_RENDER_NODE_FILE_EXT 0x3377 +#endif /* EGL_EXT_device_drm_render_node */ + +#ifndef EGL_EXT_device_enumeration +#define EGL_EXT_device_enumeration 1 +#endif /* EGL_EXT_device_enumeration */ + +#ifndef EGL_EXT_device_openwf +#define EGL_EXT_device_openwf 1 +#define EGL_OPENWF_DEVICE_ID_EXT 0x3237 +#define EGL_OPENWF_DEVICE_EXT 0x333D +#endif /* EGL_EXT_device_openwf */ + +#ifndef EGL_EXT_device_persistent_id +#define EGL_EXT_device_persistent_id 1 +#define EGL_DEVICE_UUID_EXT 0x335C +#define EGL_DRIVER_UUID_EXT 0x335D +#define EGL_DRIVER_NAME_EXT 0x335E +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDEVICEBINARYEXTPROC) (EGLDeviceEXT device, EGLint name, EGLint max_size, void *value, EGLint *size); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglQueryDeviceBinaryEXT (EGLDeviceEXT device, EGLint name, EGLint max_size, void *value, EGLint *size); +#endif +#endif /* EGL_EXT_device_persistent_id */ + +#ifndef EGL_EXT_device_query +#define EGL_EXT_device_query 1 +#endif /* EGL_EXT_device_query */ + +#ifndef EGL_EXT_device_query_name +#define EGL_EXT_device_query_name 1 +#define EGL_RENDERER_EXT 0x335F +#endif /* EGL_EXT_device_query_name */ + +#ifndef EGL_EXT_explicit_device +#define EGL_EXT_explicit_device 1 +#endif /* EGL_EXT_explicit_device */ + +#ifndef EGL_EXT_gl_colorspace_bt2020_linear +#define EGL_EXT_gl_colorspace_bt2020_linear 1 +#define EGL_GL_COLORSPACE_BT2020_LINEAR_EXT 0x333F +#endif /* EGL_EXT_gl_colorspace_bt2020_linear */ + +#ifndef EGL_EXT_gl_colorspace_bt2020_pq +#define EGL_EXT_gl_colorspace_bt2020_pq 1 +#define EGL_GL_COLORSPACE_BT2020_PQ_EXT 0x3340 +#endif /* EGL_EXT_gl_colorspace_bt2020_pq */ + +#ifndef EGL_EXT_gl_colorspace_display_p3 +#define EGL_EXT_gl_colorspace_display_p3 1 +#define EGL_GL_COLORSPACE_DISPLAY_P3_EXT 0x3363 +#endif /* EGL_EXT_gl_colorspace_display_p3 */ + +#ifndef EGL_EXT_gl_colorspace_display_p3_linear +#define EGL_EXT_gl_colorspace_display_p3_linear 1 +#define EGL_GL_COLORSPACE_DISPLAY_P3_LINEAR_EXT 0x3362 +#endif /* EGL_EXT_gl_colorspace_display_p3_linear */ + +#ifndef EGL_EXT_gl_colorspace_display_p3_passthrough +#define EGL_EXT_gl_colorspace_display_p3_passthrough 1 +#define EGL_GL_COLORSPACE_DISPLAY_P3_PASSTHROUGH_EXT 0x3490 +#endif /* EGL_EXT_gl_colorspace_display_p3_passthrough */ + +#ifndef EGL_EXT_gl_colorspace_scrgb +#define EGL_EXT_gl_colorspace_scrgb 1 +#define EGL_GL_COLORSPACE_SCRGB_EXT 0x3351 +#endif /* EGL_EXT_gl_colorspace_scrgb */ + +#ifndef EGL_EXT_gl_colorspace_scrgb_linear +#define EGL_EXT_gl_colorspace_scrgb_linear 1 +#define EGL_GL_COLORSPACE_SCRGB_LINEAR_EXT 0x3350 +#endif /* EGL_EXT_gl_colorspace_scrgb_linear */ + +#ifndef EGL_EXT_image_dma_buf_import +#define EGL_EXT_image_dma_buf_import 1 +#define EGL_LINUX_DMA_BUF_EXT 0x3270 +#define EGL_LINUX_DRM_FOURCC_EXT 0x3271 +#define EGL_DMA_BUF_PLANE0_FD_EXT 0x3272 +#define EGL_DMA_BUF_PLANE0_OFFSET_EXT 0x3273 +#define EGL_DMA_BUF_PLANE0_PITCH_EXT 0x3274 +#define EGL_DMA_BUF_PLANE1_FD_EXT 0x3275 +#define EGL_DMA_BUF_PLANE1_OFFSET_EXT 0x3276 +#define EGL_DMA_BUF_PLANE1_PITCH_EXT 0x3277 +#define EGL_DMA_BUF_PLANE2_FD_EXT 0x3278 +#define EGL_DMA_BUF_PLANE2_OFFSET_EXT 0x3279 +#define EGL_DMA_BUF_PLANE2_PITCH_EXT 0x327A +#define EGL_YUV_COLOR_SPACE_HINT_EXT 0x327B +#define EGL_SAMPLE_RANGE_HINT_EXT 0x327C +#define EGL_YUV_CHROMA_HORIZONTAL_SITING_HINT_EXT 0x327D +#define EGL_YUV_CHROMA_VERTICAL_SITING_HINT_EXT 0x327E +#define EGL_ITU_REC601_EXT 0x327F +#define EGL_ITU_REC709_EXT 0x3280 +#define EGL_ITU_REC2020_EXT 0x3281 +#define EGL_YUV_FULL_RANGE_EXT 0x3282 +#define EGL_YUV_NARROW_RANGE_EXT 0x3283 +#define EGL_YUV_CHROMA_SITING_0_EXT 0x3284 +#define EGL_YUV_CHROMA_SITING_0_5_EXT 0x3285 +#endif /* EGL_EXT_image_dma_buf_import */ + +#ifndef EGL_EXT_image_dma_buf_import_modifiers +#define EGL_EXT_image_dma_buf_import_modifiers 1 +#define EGL_DMA_BUF_PLANE3_FD_EXT 0x3440 +#define EGL_DMA_BUF_PLANE3_OFFSET_EXT 0x3441 +#define EGL_DMA_BUF_PLANE3_PITCH_EXT 0x3442 +#define EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT 0x3443 +#define EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT 0x3444 +#define EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT 0x3445 +#define EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT 0x3446 +#define EGL_DMA_BUF_PLANE2_MODIFIER_LO_EXT 0x3447 +#define EGL_DMA_BUF_PLANE2_MODIFIER_HI_EXT 0x3448 +#define EGL_DMA_BUF_PLANE3_MODIFIER_LO_EXT 0x3449 +#define EGL_DMA_BUF_PLANE3_MODIFIER_HI_EXT 0x344A +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDMABUFFORMATSEXTPROC) (EGLDisplay dpy, EGLint max_formats, EGLint *formats, EGLint *num_formats); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDMABUFMODIFIERSEXTPROC) (EGLDisplay dpy, EGLint format, EGLint max_modifiers, EGLuint64KHR *modifiers, EGLBoolean *external_only, EGLint *num_modifiers); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglQueryDmaBufFormatsEXT (EGLDisplay dpy, EGLint max_formats, EGLint *formats, EGLint *num_formats); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryDmaBufModifiersEXT (EGLDisplay dpy, EGLint format, EGLint max_modifiers, EGLuint64KHR *modifiers, EGLBoolean *external_only, EGLint *num_modifiers); +#endif +#endif /* EGL_EXT_image_dma_buf_import_modifiers */ + +#ifndef EGL_EXT_image_gl_colorspace +#define EGL_EXT_image_gl_colorspace 1 +#define EGL_GL_COLORSPACE_DEFAULT_EXT 0x314D +#endif /* EGL_EXT_image_gl_colorspace */ + +#ifndef EGL_EXT_image_implicit_sync_control +#define EGL_EXT_image_implicit_sync_control 1 +#define EGL_IMPORT_SYNC_TYPE_EXT 0x3470 +#define EGL_IMPORT_IMPLICIT_SYNC_EXT 0x3471 +#define EGL_IMPORT_EXPLICIT_SYNC_EXT 0x3472 +#endif /* EGL_EXT_image_implicit_sync_control */ + +#ifndef EGL_EXT_multiview_window +#define EGL_EXT_multiview_window 1 +#define EGL_MULTIVIEW_VIEW_COUNT_EXT 0x3134 +#endif /* EGL_EXT_multiview_window */ + +#ifndef EGL_EXT_output_base +#define EGL_EXT_output_base 1 +typedef void *EGLOutputLayerEXT; +typedef void *EGLOutputPortEXT; +#define EGL_NO_OUTPUT_LAYER_EXT EGL_CAST(EGLOutputLayerEXT,0) +#define EGL_NO_OUTPUT_PORT_EXT EGL_CAST(EGLOutputPortEXT,0) +#define EGL_BAD_OUTPUT_LAYER_EXT 0x322D +#define EGL_BAD_OUTPUT_PORT_EXT 0x322E +#define EGL_SWAP_INTERVAL_EXT 0x322F +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETOUTPUTLAYERSEXTPROC) (EGLDisplay dpy, const EGLAttrib *attrib_list, EGLOutputLayerEXT *layers, EGLint max_layers, EGLint *num_layers); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETOUTPUTPORTSEXTPROC) (EGLDisplay dpy, const EGLAttrib *attrib_list, EGLOutputPortEXT *ports, EGLint max_ports, EGLint *num_ports); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLOUTPUTLAYERATTRIBEXTPROC) (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint attribute, EGLAttrib value); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYOUTPUTLAYERATTRIBEXTPROC) (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint attribute, EGLAttrib *value); +typedef const char *(EGLAPIENTRYP PFNEGLQUERYOUTPUTLAYERSTRINGEXTPROC) (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint name); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLOUTPUTPORTATTRIBEXTPROC) (EGLDisplay dpy, EGLOutputPortEXT port, EGLint attribute, EGLAttrib value); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYOUTPUTPORTATTRIBEXTPROC) (EGLDisplay dpy, EGLOutputPortEXT port, EGLint attribute, EGLAttrib *value); +typedef const char *(EGLAPIENTRYP PFNEGLQUERYOUTPUTPORTSTRINGEXTPROC) (EGLDisplay dpy, EGLOutputPortEXT port, EGLint name); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglGetOutputLayersEXT (EGLDisplay dpy, const EGLAttrib *attrib_list, EGLOutputLayerEXT *layers, EGLint max_layers, EGLint *num_layers); +EGLAPI EGLBoolean EGLAPIENTRY eglGetOutputPortsEXT (EGLDisplay dpy, const EGLAttrib *attrib_list, EGLOutputPortEXT *ports, EGLint max_ports, EGLint *num_ports); +EGLAPI EGLBoolean EGLAPIENTRY eglOutputLayerAttribEXT (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint attribute, EGLAttrib value); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryOutputLayerAttribEXT (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint attribute, EGLAttrib *value); +EGLAPI const char *EGLAPIENTRY eglQueryOutputLayerStringEXT (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint name); +EGLAPI EGLBoolean EGLAPIENTRY eglOutputPortAttribEXT (EGLDisplay dpy, EGLOutputPortEXT port, EGLint attribute, EGLAttrib value); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryOutputPortAttribEXT (EGLDisplay dpy, EGLOutputPortEXT port, EGLint attribute, EGLAttrib *value); +EGLAPI const char *EGLAPIENTRY eglQueryOutputPortStringEXT (EGLDisplay dpy, EGLOutputPortEXT port, EGLint name); +#endif +#endif /* EGL_EXT_output_base */ + +#ifndef EGL_EXT_output_drm +#define EGL_EXT_output_drm 1 +#define EGL_DRM_CRTC_EXT 0x3234 +#define EGL_DRM_PLANE_EXT 0x3235 +#define EGL_DRM_CONNECTOR_EXT 0x3236 +#endif /* EGL_EXT_output_drm */ + +#ifndef EGL_EXT_output_openwf +#define EGL_EXT_output_openwf 1 +#define EGL_OPENWF_PIPELINE_ID_EXT 0x3238 +#define EGL_OPENWF_PORT_ID_EXT 0x3239 +#endif /* EGL_EXT_output_openwf */ + +#ifndef EGL_EXT_pixel_format_float +#define EGL_EXT_pixel_format_float 1 +#define EGL_COLOR_COMPONENT_TYPE_EXT 0x3339 +#define EGL_COLOR_COMPONENT_TYPE_FIXED_EXT 0x333A +#define EGL_COLOR_COMPONENT_TYPE_FLOAT_EXT 0x333B +#endif /* EGL_EXT_pixel_format_float */ + +#ifndef EGL_EXT_platform_base +#define EGL_EXT_platform_base 1 +typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETPLATFORMDISPLAYEXTPROC) (EGLenum platform, void *native_display, const EGLint *attrib_list); +typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC) (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLint *attrib_list); +typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPLATFORMPIXMAPSURFACEEXTPROC) (EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLint *attrib_list); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLDisplay EGLAPIENTRY eglGetPlatformDisplayEXT (EGLenum platform, void *native_display, const EGLint *attrib_list); +EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformWindowSurfaceEXT (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLint *attrib_list); +EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformPixmapSurfaceEXT (EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLint *attrib_list); +#endif +#endif /* EGL_EXT_platform_base */ + +#ifndef EGL_EXT_platform_device +#define EGL_EXT_platform_device 1 +#define EGL_PLATFORM_DEVICE_EXT 0x313F +#endif /* EGL_EXT_platform_device */ + +#ifndef EGL_EXT_platform_wayland +#define EGL_EXT_platform_wayland 1 +#define EGL_PLATFORM_WAYLAND_EXT 0x31D8 +#endif /* EGL_EXT_platform_wayland */ + +#ifndef EGL_EXT_platform_x11 +#define EGL_EXT_platform_x11 1 +#define EGL_PLATFORM_X11_EXT 0x31D5 +#define EGL_PLATFORM_X11_SCREEN_EXT 0x31D6 +#endif /* EGL_EXT_platform_x11 */ + +#ifndef EGL_EXT_platform_xcb +#define EGL_EXT_platform_xcb 1 +#define EGL_PLATFORM_XCB_EXT 0x31DC +#define EGL_PLATFORM_XCB_SCREEN_EXT 0x31DE +#endif /* EGL_EXT_platform_xcb */ + +#ifndef EGL_EXT_present_opaque +#define EGL_EXT_present_opaque 1 +#define EGL_PRESENT_OPAQUE_EXT 0x31DF +#endif /* EGL_EXT_present_opaque */ + +#ifndef EGL_EXT_protected_content +#define EGL_EXT_protected_content 1 +#define EGL_PROTECTED_CONTENT_EXT 0x32C0 +#endif /* EGL_EXT_protected_content */ + +#ifndef EGL_EXT_protected_surface +#define EGL_EXT_protected_surface 1 +#endif /* EGL_EXT_protected_surface */ + +#ifndef EGL_EXT_stream_consumer_egloutput +#define EGL_EXT_stream_consumer_egloutput 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMEROUTPUTEXTPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLOutputLayerEXT layer); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerOutputEXT (EGLDisplay dpy, EGLStreamKHR stream, EGLOutputLayerEXT layer); +#endif +#endif /* EGL_EXT_stream_consumer_egloutput */ + +#ifndef EGL_EXT_surface_CTA861_3_metadata +#define EGL_EXT_surface_CTA861_3_metadata 1 +#define EGL_CTA861_3_MAX_CONTENT_LIGHT_LEVEL_EXT 0x3360 +#define EGL_CTA861_3_MAX_FRAME_AVERAGE_LEVEL_EXT 0x3361 +#endif /* EGL_EXT_surface_CTA861_3_metadata */ + +#ifndef EGL_EXT_surface_SMPTE2086_metadata +#define EGL_EXT_surface_SMPTE2086_metadata 1 +#define EGL_SMPTE2086_DISPLAY_PRIMARY_RX_EXT 0x3341 +#define EGL_SMPTE2086_DISPLAY_PRIMARY_RY_EXT 0x3342 +#define EGL_SMPTE2086_DISPLAY_PRIMARY_GX_EXT 0x3343 +#define EGL_SMPTE2086_DISPLAY_PRIMARY_GY_EXT 0x3344 +#define EGL_SMPTE2086_DISPLAY_PRIMARY_BX_EXT 0x3345 +#define EGL_SMPTE2086_DISPLAY_PRIMARY_BY_EXT 0x3346 +#define EGL_SMPTE2086_WHITE_POINT_X_EXT 0x3347 +#define EGL_SMPTE2086_WHITE_POINT_Y_EXT 0x3348 +#define EGL_SMPTE2086_MAX_LUMINANCE_EXT 0x3349 +#define EGL_SMPTE2086_MIN_LUMINANCE_EXT 0x334A +#define EGL_METADATA_SCALING_EXT 50000 +#endif /* EGL_EXT_surface_SMPTE2086_metadata */ + +#ifndef EGL_EXT_surface_compression +#define EGL_EXT_surface_compression 1 +#define EGL_SURFACE_COMPRESSION_EXT 0x34B0 +#define EGL_SURFACE_COMPRESSION_PLANE1_EXT 0x328E +#define EGL_SURFACE_COMPRESSION_PLANE2_EXT 0x328F +#define EGL_SURFACE_COMPRESSION_FIXED_RATE_NONE_EXT 0x34B1 +#define EGL_SURFACE_COMPRESSION_FIXED_RATE_DEFAULT_EXT 0x34B2 +#define EGL_SURFACE_COMPRESSION_FIXED_RATE_1BPC_EXT 0x34B4 +#define EGL_SURFACE_COMPRESSION_FIXED_RATE_2BPC_EXT 0x34B5 +#define EGL_SURFACE_COMPRESSION_FIXED_RATE_3BPC_EXT 0x34B6 +#define EGL_SURFACE_COMPRESSION_FIXED_RATE_4BPC_EXT 0x34B7 +#define EGL_SURFACE_COMPRESSION_FIXED_RATE_5BPC_EXT 0x34B8 +#define EGL_SURFACE_COMPRESSION_FIXED_RATE_6BPC_EXT 0x34B9 +#define EGL_SURFACE_COMPRESSION_FIXED_RATE_7BPC_EXT 0x34BA +#define EGL_SURFACE_COMPRESSION_FIXED_RATE_8BPC_EXT 0x34BB +#define EGL_SURFACE_COMPRESSION_FIXED_RATE_9BPC_EXT 0x34BC +#define EGL_SURFACE_COMPRESSION_FIXED_RATE_10BPC_EXT 0x34BD +#define EGL_SURFACE_COMPRESSION_FIXED_RATE_11BPC_EXT 0x34BE +#define EGL_SURFACE_COMPRESSION_FIXED_RATE_12BPC_EXT 0x34BF +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSUPPORTEDCOMPRESSIONRATESEXTPROC) (EGLDisplay dpy, EGLConfig config, const EGLAttrib *attrib_list, EGLint *rates, EGLint rate_size, EGLint *num_rates); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglQuerySupportedCompressionRatesEXT (EGLDisplay dpy, EGLConfig config, const EGLAttrib *attrib_list, EGLint *rates, EGLint rate_size, EGLint *num_rates); +#endif +#endif /* EGL_EXT_surface_compression */ + +#ifndef EGL_EXT_swap_buffers_with_damage +#define EGL_EXT_swap_buffers_with_damage 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC) (EGLDisplay dpy, EGLSurface surface, const EGLint *rects, EGLint n_rects); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersWithDamageEXT (EGLDisplay dpy, EGLSurface surface, const EGLint *rects, EGLint n_rects); +#endif +#endif /* EGL_EXT_swap_buffers_with_damage */ + +#ifndef EGL_EXT_sync_reuse +#define EGL_EXT_sync_reuse 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNSIGNALSYNCEXTPROC) (EGLDisplay dpy, EGLSync sync, const EGLAttrib *attrib_list); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglUnsignalSyncEXT (EGLDisplay dpy, EGLSync sync, const EGLAttrib *attrib_list); +#endif +#endif /* EGL_EXT_sync_reuse */ + +#ifndef EGL_EXT_yuv_surface +#define EGL_EXT_yuv_surface 1 +#define EGL_YUV_ORDER_EXT 0x3301 +#define EGL_YUV_NUMBER_OF_PLANES_EXT 0x3311 +#define EGL_YUV_SUBSAMPLE_EXT 0x3312 +#define EGL_YUV_DEPTH_RANGE_EXT 0x3317 +#define EGL_YUV_CSC_STANDARD_EXT 0x330A +#define EGL_YUV_PLANE_BPP_EXT 0x331A +#define EGL_YUV_BUFFER_EXT 0x3300 +#define EGL_YUV_ORDER_YUV_EXT 0x3302 +#define EGL_YUV_ORDER_YVU_EXT 0x3303 +#define EGL_YUV_ORDER_YUYV_EXT 0x3304 +#define EGL_YUV_ORDER_UYVY_EXT 0x3305 +#define EGL_YUV_ORDER_YVYU_EXT 0x3306 +#define EGL_YUV_ORDER_VYUY_EXT 0x3307 +#define EGL_YUV_ORDER_AYUV_EXT 0x3308 +#define EGL_YUV_SUBSAMPLE_4_2_0_EXT 0x3313 +#define EGL_YUV_SUBSAMPLE_4_2_2_EXT 0x3314 +#define EGL_YUV_SUBSAMPLE_4_4_4_EXT 0x3315 +#define EGL_YUV_DEPTH_RANGE_LIMITED_EXT 0x3318 +#define EGL_YUV_DEPTH_RANGE_FULL_EXT 0x3319 +#define EGL_YUV_CSC_STANDARD_601_EXT 0x330B +#define EGL_YUV_CSC_STANDARD_709_EXT 0x330C +#define EGL_YUV_CSC_STANDARD_2020_EXT 0x330D +#define EGL_YUV_PLANE_BPP_0_EXT 0x331B +#define EGL_YUV_PLANE_BPP_8_EXT 0x331C +#define EGL_YUV_PLANE_BPP_10_EXT 0x331D +#endif /* EGL_EXT_yuv_surface */ + +#ifndef EGL_HI_clientpixmap +#define EGL_HI_clientpixmap 1 +struct EGLClientPixmapHI { + void *pData; + EGLint iWidth; + EGLint iHeight; + EGLint iStride; +}; +#define EGL_CLIENT_PIXMAP_POINTER_HI 0x8F74 +typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPIXMAPSURFACEHIPROC) (EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI *pixmap); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurfaceHI (EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI *pixmap); +#endif +#endif /* EGL_HI_clientpixmap */ + +#ifndef EGL_HI_colorformats +#define EGL_HI_colorformats 1 +#define EGL_COLOR_FORMAT_HI 0x8F70 +#define EGL_COLOR_RGB_HI 0x8F71 +#define EGL_COLOR_RGBA_HI 0x8F72 +#define EGL_COLOR_ARGB_HI 0x8F73 +#endif /* EGL_HI_colorformats */ + +#ifndef EGL_IMG_context_priority +#define EGL_IMG_context_priority 1 +#define EGL_CONTEXT_PRIORITY_LEVEL_IMG 0x3100 +#define EGL_CONTEXT_PRIORITY_HIGH_IMG 0x3101 +#define EGL_CONTEXT_PRIORITY_MEDIUM_IMG 0x3102 +#define EGL_CONTEXT_PRIORITY_LOW_IMG 0x3103 +#endif /* EGL_IMG_context_priority */ + +#ifndef EGL_IMG_image_plane_attribs +#define EGL_IMG_image_plane_attribs 1 +#define EGL_NATIVE_BUFFER_MULTIPLANE_SEPARATE_IMG 0x3105 +#define EGL_NATIVE_BUFFER_PLANE_OFFSET_IMG 0x3106 +#endif /* EGL_IMG_image_plane_attribs */ + +#ifndef EGL_MESA_drm_image +#define EGL_MESA_drm_image 1 +#define EGL_DRM_BUFFER_FORMAT_MESA 0x31D0 +#define EGL_DRM_BUFFER_USE_MESA 0x31D1 +#define EGL_DRM_BUFFER_FORMAT_ARGB32_MESA 0x31D2 +#define EGL_DRM_BUFFER_MESA 0x31D3 +#define EGL_DRM_BUFFER_STRIDE_MESA 0x31D4 +#define EGL_DRM_BUFFER_USE_SCANOUT_MESA 0x00000001 +#define EGL_DRM_BUFFER_USE_SHARE_MESA 0x00000002 +#define EGL_DRM_BUFFER_USE_CURSOR_MESA 0x00000004 +typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEDRMIMAGEMESAPROC) (EGLDisplay dpy, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDRMIMAGEMESAPROC) (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLImageKHR EGLAPIENTRY eglCreateDRMImageMESA (EGLDisplay dpy, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglExportDRMImageMESA (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride); +#endif +#endif /* EGL_MESA_drm_image */ + +#ifndef EGL_MESA_image_dma_buf_export +#define EGL_MESA_image_dma_buf_export 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDMABUFIMAGEQUERYMESAPROC) (EGLDisplay dpy, EGLImageKHR image, int *fourcc, int *num_planes, EGLuint64KHR *modifiers); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDMABUFIMAGEMESAPROC) (EGLDisplay dpy, EGLImageKHR image, int *fds, EGLint *strides, EGLint *offsets); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglExportDMABUFImageQueryMESA (EGLDisplay dpy, EGLImageKHR image, int *fourcc, int *num_planes, EGLuint64KHR *modifiers); +EGLAPI EGLBoolean EGLAPIENTRY eglExportDMABUFImageMESA (EGLDisplay dpy, EGLImageKHR image, int *fds, EGLint *strides, EGLint *offsets); +#endif +#endif /* EGL_MESA_image_dma_buf_export */ + +#ifndef EGL_MESA_platform_gbm +#define EGL_MESA_platform_gbm 1 +#define EGL_PLATFORM_GBM_MESA 0x31D7 +#endif /* EGL_MESA_platform_gbm */ + +#ifndef EGL_MESA_platform_surfaceless +#define EGL_MESA_platform_surfaceless 1 +#define EGL_PLATFORM_SURFACELESS_MESA 0x31DD +#endif /* EGL_MESA_platform_surfaceless */ + +#ifndef EGL_MESA_query_driver +#define EGL_MESA_query_driver 1 +typedef char *(EGLAPIENTRYP PFNEGLGETDISPLAYDRIVERCONFIGPROC) (EGLDisplay dpy); +typedef const char *(EGLAPIENTRYP PFNEGLGETDISPLAYDRIVERNAMEPROC) (EGLDisplay dpy); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI char *EGLAPIENTRY eglGetDisplayDriverConfig (EGLDisplay dpy); +EGLAPI const char *EGLAPIENTRY eglGetDisplayDriverName (EGLDisplay dpy); +#endif +#endif /* EGL_MESA_query_driver */ + +#ifndef EGL_NOK_swap_region +#define EGL_NOK_swap_region 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSREGIONNOKPROC) (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint *rects); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersRegionNOK (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint *rects); +#endif +#endif /* EGL_NOK_swap_region */ + +#ifndef EGL_NOK_swap_region2 +#define EGL_NOK_swap_region2 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSREGION2NOKPROC) (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint *rects); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersRegion2NOK (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint *rects); +#endif +#endif /* EGL_NOK_swap_region2 */ + +#ifndef EGL_NOK_texture_from_pixmap +#define EGL_NOK_texture_from_pixmap 1 +#define EGL_Y_INVERTED_NOK 0x307F +#endif /* EGL_NOK_texture_from_pixmap */ + +#ifndef EGL_NV_3dvision_surface +#define EGL_NV_3dvision_surface 1 +#define EGL_AUTO_STEREO_NV 0x3136 +#endif /* EGL_NV_3dvision_surface */ + +#ifndef EGL_NV_context_priority_realtime +#define EGL_NV_context_priority_realtime 1 +#define EGL_CONTEXT_PRIORITY_REALTIME_NV 0x3357 +#endif /* EGL_NV_context_priority_realtime */ + +#ifndef EGL_NV_coverage_sample +#define EGL_NV_coverage_sample 1 +#define EGL_COVERAGE_BUFFERS_NV 0x30E0 +#define EGL_COVERAGE_SAMPLES_NV 0x30E1 +#endif /* EGL_NV_coverage_sample */ + +#ifndef EGL_NV_coverage_sample_resolve +#define EGL_NV_coverage_sample_resolve 1 +#define EGL_COVERAGE_SAMPLE_RESOLVE_NV 0x3131 +#define EGL_COVERAGE_SAMPLE_RESOLVE_DEFAULT_NV 0x3132 +#define EGL_COVERAGE_SAMPLE_RESOLVE_NONE_NV 0x3133 +#endif /* EGL_NV_coverage_sample_resolve */ + +#ifndef EGL_NV_cuda_event +#define EGL_NV_cuda_event 1 +#define EGL_CUDA_EVENT_HANDLE_NV 0x323B +#define EGL_SYNC_CUDA_EVENT_NV 0x323C +#define EGL_SYNC_CUDA_EVENT_COMPLETE_NV 0x323D +#endif /* EGL_NV_cuda_event */ + +#ifndef EGL_NV_depth_nonlinear +#define EGL_NV_depth_nonlinear 1 +#define EGL_DEPTH_ENCODING_NV 0x30E2 +#define EGL_DEPTH_ENCODING_NONE_NV 0 +#define EGL_DEPTH_ENCODING_NONLINEAR_NV 0x30E3 +#endif /* EGL_NV_depth_nonlinear */ + +#ifndef EGL_NV_device_cuda +#define EGL_NV_device_cuda 1 +#define EGL_CUDA_DEVICE_NV 0x323A +#endif /* EGL_NV_device_cuda */ + +#ifndef EGL_NV_native_query +#define EGL_NV_native_query 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEDISPLAYNVPROC) (EGLDisplay dpy, EGLNativeDisplayType *display_id); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEWINDOWNVPROC) (EGLDisplay dpy, EGLSurface surf, EGLNativeWindowType *window); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEPIXMAPNVPROC) (EGLDisplay dpy, EGLSurface surf, EGLNativePixmapType *pixmap); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativeDisplayNV (EGLDisplay dpy, EGLNativeDisplayType *display_id); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativeWindowNV (EGLDisplay dpy, EGLSurface surf, EGLNativeWindowType *window); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativePixmapNV (EGLDisplay dpy, EGLSurface surf, EGLNativePixmapType *pixmap); +#endif +#endif /* EGL_NV_native_query */ + +#ifndef EGL_NV_post_convert_rounding +#define EGL_NV_post_convert_rounding 1 +#endif /* EGL_NV_post_convert_rounding */ + +#ifndef EGL_NV_post_sub_buffer +#define EGL_NV_post_sub_buffer 1 +#define EGL_POST_SUB_BUFFER_SUPPORTED_NV 0x30BE +typedef EGLBoolean (EGLAPIENTRYP PFNEGLPOSTSUBBUFFERNVPROC) (EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglPostSubBufferNV (EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height); +#endif +#endif /* EGL_NV_post_sub_buffer */ + +#ifndef EGL_NV_quadruple_buffer +#define EGL_NV_quadruple_buffer 1 +#define EGL_QUADRUPLE_BUFFER_NV 0x3231 +#endif /* EGL_NV_quadruple_buffer */ + +#ifndef EGL_NV_robustness_video_memory_purge +#define EGL_NV_robustness_video_memory_purge 1 +#define EGL_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV 0x334C +#endif /* EGL_NV_robustness_video_memory_purge */ + +#ifndef EGL_NV_stream_consumer_eglimage +#define EGL_NV_stream_consumer_eglimage 1 +#define EGL_STREAM_CONSUMER_IMAGE_NV 0x3373 +#define EGL_STREAM_IMAGE_ADD_NV 0x3374 +#define EGL_STREAM_IMAGE_REMOVE_NV 0x3375 +#define EGL_STREAM_IMAGE_AVAILABLE_NV 0x3376 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMIMAGECONSUMERCONNECTNVPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLint num_modifiers, const EGLuint64KHR *modifiers, const EGLAttrib *attrib_list); +typedef EGLint (EGLAPIENTRYP PFNEGLQUERYSTREAMCONSUMEREVENTNVPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLTime timeout, EGLenum *event, EGLAttrib *aux); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMACQUIREIMAGENVPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLImage *pImage, EGLSync sync); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMRELEASEIMAGENVPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLImage image, EGLSync sync); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglStreamImageConsumerConnectNV (EGLDisplay dpy, EGLStreamKHR stream, EGLint num_modifiers, const EGLuint64KHR *modifiers, const EGLAttrib *attrib_list); +EGLAPI EGLint EGLAPIENTRY eglQueryStreamConsumerEventNV (EGLDisplay dpy, EGLStreamKHR stream, EGLTime timeout, EGLenum *event, EGLAttrib *aux); +EGLAPI EGLBoolean EGLAPIENTRY eglStreamAcquireImageNV (EGLDisplay dpy, EGLStreamKHR stream, EGLImage *pImage, EGLSync sync); +EGLAPI EGLBoolean EGLAPIENTRY eglStreamReleaseImageNV (EGLDisplay dpy, EGLStreamKHR stream, EGLImage image, EGLSync sync); +#endif +#endif /* EGL_NV_stream_consumer_eglimage */ + +#ifndef EGL_NV_stream_consumer_gltexture_yuv +#define EGL_NV_stream_consumer_gltexture_yuv 1 +#define EGL_YUV_PLANE0_TEXTURE_UNIT_NV 0x332C +#define EGL_YUV_PLANE1_TEXTURE_UNIT_NV 0x332D +#define EGL_YUV_PLANE2_TEXTURE_UNIT_NV 0x332E +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERGLTEXTUREEXTERNALATTRIBSNVPROC) (EGLDisplay dpy, EGLStreamKHR stream, const EGLAttrib *attrib_list); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerGLTextureExternalAttribsNV (EGLDisplay dpy, EGLStreamKHR stream, const EGLAttrib *attrib_list); +#endif +#endif /* EGL_NV_stream_consumer_gltexture_yuv */ + +#ifndef EGL_NV_stream_cross_display +#define EGL_NV_stream_cross_display 1 +#define EGL_STREAM_CROSS_DISPLAY_NV 0x334E +#endif /* EGL_NV_stream_cross_display */ + +#ifndef EGL_NV_stream_cross_object +#define EGL_NV_stream_cross_object 1 +#define EGL_STREAM_CROSS_OBJECT_NV 0x334D +#endif /* EGL_NV_stream_cross_object */ + +#ifndef EGL_NV_stream_cross_partition +#define EGL_NV_stream_cross_partition 1 +#define EGL_STREAM_CROSS_PARTITION_NV 0x323F +#endif /* EGL_NV_stream_cross_partition */ + +#ifndef EGL_NV_stream_cross_process +#define EGL_NV_stream_cross_process 1 +#define EGL_STREAM_CROSS_PROCESS_NV 0x3245 +#endif /* EGL_NV_stream_cross_process */ + +#ifndef EGL_NV_stream_cross_system +#define EGL_NV_stream_cross_system 1 +#define EGL_STREAM_CROSS_SYSTEM_NV 0x334F +#endif /* EGL_NV_stream_cross_system */ + +#ifndef EGL_NV_stream_dma +#define EGL_NV_stream_dma 1 +#define EGL_STREAM_DMA_NV 0x3371 +#define EGL_STREAM_DMA_SERVER_NV 0x3372 +#endif /* EGL_NV_stream_dma */ + +#ifndef EGL_NV_stream_fifo_next +#define EGL_NV_stream_fifo_next 1 +#define EGL_PENDING_FRAME_NV 0x3329 +#define EGL_STREAM_TIME_PENDING_NV 0x332A +#endif /* EGL_NV_stream_fifo_next */ + +#ifndef EGL_NV_stream_fifo_synchronous +#define EGL_NV_stream_fifo_synchronous 1 +#define EGL_STREAM_FIFO_SYNCHRONOUS_NV 0x3336 +#endif /* EGL_NV_stream_fifo_synchronous */ + +#ifndef EGL_NV_stream_flush +#define EGL_NV_stream_flush 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMFLUSHNVPROC) (EGLDisplay dpy, EGLStreamKHR stream); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglStreamFlushNV (EGLDisplay dpy, EGLStreamKHR stream); +#endif +#endif /* EGL_NV_stream_flush */ + +#ifndef EGL_NV_stream_frame_limits +#define EGL_NV_stream_frame_limits 1 +#define EGL_PRODUCER_MAX_FRAME_HINT_NV 0x3337 +#define EGL_CONSUMER_MAX_FRAME_HINT_NV 0x3338 +#endif /* EGL_NV_stream_frame_limits */ + +#ifndef EGL_NV_stream_metadata +#define EGL_NV_stream_metadata 1 +#define EGL_MAX_STREAM_METADATA_BLOCKS_NV 0x3250 +#define EGL_MAX_STREAM_METADATA_BLOCK_SIZE_NV 0x3251 +#define EGL_MAX_STREAM_METADATA_TOTAL_SIZE_NV 0x3252 +#define EGL_PRODUCER_METADATA_NV 0x3253 +#define EGL_CONSUMER_METADATA_NV 0x3254 +#define EGL_PENDING_METADATA_NV 0x3328 +#define EGL_METADATA0_SIZE_NV 0x3255 +#define EGL_METADATA1_SIZE_NV 0x3256 +#define EGL_METADATA2_SIZE_NV 0x3257 +#define EGL_METADATA3_SIZE_NV 0x3258 +#define EGL_METADATA0_TYPE_NV 0x3259 +#define EGL_METADATA1_TYPE_NV 0x325A +#define EGL_METADATA2_TYPE_NV 0x325B +#define EGL_METADATA3_TYPE_NV 0x325C +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDISPLAYATTRIBNVPROC) (EGLDisplay dpy, EGLint attribute, EGLAttrib *value); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSETSTREAMMETADATANVPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLint n, EGLint offset, EGLint size, const void *data); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMMETADATANVPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum name, EGLint n, EGLint offset, EGLint size, void *data); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglQueryDisplayAttribNV (EGLDisplay dpy, EGLint attribute, EGLAttrib *value); +EGLAPI EGLBoolean EGLAPIENTRY eglSetStreamMetadataNV (EGLDisplay dpy, EGLStreamKHR stream, EGLint n, EGLint offset, EGLint size, const void *data); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamMetadataNV (EGLDisplay dpy, EGLStreamKHR stream, EGLenum name, EGLint n, EGLint offset, EGLint size, void *data); +#endif +#endif /* EGL_NV_stream_metadata */ + +#ifndef EGL_NV_stream_origin +#define EGL_NV_stream_origin 1 +#define EGL_STREAM_FRAME_ORIGIN_X_NV 0x3366 +#define EGL_STREAM_FRAME_ORIGIN_Y_NV 0x3367 +#define EGL_STREAM_FRAME_MAJOR_AXIS_NV 0x3368 +#define EGL_CONSUMER_AUTO_ORIENTATION_NV 0x3369 +#define EGL_PRODUCER_AUTO_ORIENTATION_NV 0x336A +#define EGL_LEFT_NV 0x336B +#define EGL_RIGHT_NV 0x336C +#define EGL_TOP_NV 0x336D +#define EGL_BOTTOM_NV 0x336E +#define EGL_X_AXIS_NV 0x336F +#define EGL_Y_AXIS_NV 0x3370 +#endif /* EGL_NV_stream_origin */ + +#ifndef EGL_NV_stream_remote +#define EGL_NV_stream_remote 1 +#define EGL_STREAM_STATE_INITIALIZING_NV 0x3240 +#define EGL_STREAM_TYPE_NV 0x3241 +#define EGL_STREAM_PROTOCOL_NV 0x3242 +#define EGL_STREAM_ENDPOINT_NV 0x3243 +#define EGL_STREAM_LOCAL_NV 0x3244 +#define EGL_STREAM_PRODUCER_NV 0x3247 +#define EGL_STREAM_CONSUMER_NV 0x3248 +#define EGL_STREAM_PROTOCOL_FD_NV 0x3246 +#endif /* EGL_NV_stream_remote */ + +#ifndef EGL_NV_stream_reset +#define EGL_NV_stream_reset 1 +#define EGL_SUPPORT_RESET_NV 0x3334 +#define EGL_SUPPORT_REUSE_NV 0x3335 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLRESETSTREAMNVPROC) (EGLDisplay dpy, EGLStreamKHR stream); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglResetStreamNV (EGLDisplay dpy, EGLStreamKHR stream); +#endif +#endif /* EGL_NV_stream_reset */ + +#ifndef EGL_NV_stream_socket +#define EGL_NV_stream_socket 1 +#define EGL_STREAM_PROTOCOL_SOCKET_NV 0x324B +#define EGL_SOCKET_HANDLE_NV 0x324C +#define EGL_SOCKET_TYPE_NV 0x324D +#endif /* EGL_NV_stream_socket */ + +#ifndef EGL_NV_stream_socket_inet +#define EGL_NV_stream_socket_inet 1 +#define EGL_SOCKET_TYPE_INET_NV 0x324F +#endif /* EGL_NV_stream_socket_inet */ + +#ifndef EGL_NV_stream_socket_unix +#define EGL_NV_stream_socket_unix 1 +#define EGL_SOCKET_TYPE_UNIX_NV 0x324E +#endif /* EGL_NV_stream_socket_unix */ + +#ifndef EGL_NV_stream_sync +#define EGL_NV_stream_sync 1 +#define EGL_SYNC_NEW_FRAME_NV 0x321F +typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESTREAMSYNCNVPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum type, const EGLint *attrib_list); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateStreamSyncNV (EGLDisplay dpy, EGLStreamKHR stream, EGLenum type, const EGLint *attrib_list); +#endif +#endif /* EGL_NV_stream_sync */ + +#ifndef EGL_NV_sync +#define EGL_NV_sync 1 +typedef void *EGLSyncNV; +typedef khronos_utime_nanoseconds_t EGLTimeNV; +#ifdef KHRONOS_SUPPORT_INT64 +#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_NV 0x30E6 +#define EGL_SYNC_STATUS_NV 0x30E7 +#define EGL_SIGNALED_NV 0x30E8 +#define EGL_UNSIGNALED_NV 0x30E9 +#define EGL_SYNC_FLUSH_COMMANDS_BIT_NV 0x0001 +#define EGL_FOREVER_NV 0xFFFFFFFFFFFFFFFFull +#define EGL_ALREADY_SIGNALED_NV 0x30EA +#define EGL_TIMEOUT_EXPIRED_NV 0x30EB +#define EGL_CONDITION_SATISFIED_NV 0x30EC +#define EGL_SYNC_TYPE_NV 0x30ED +#define EGL_SYNC_CONDITION_NV 0x30EE +#define EGL_SYNC_FENCE_NV 0x30EF +#define EGL_NO_SYNC_NV EGL_CAST(EGLSyncNV,0) +typedef EGLSyncNV (EGLAPIENTRYP PFNEGLCREATEFENCESYNCNVPROC) (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCNVPROC) (EGLSyncNV sync); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLFENCENVPROC) (EGLSyncNV sync); +typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCNVPROC) (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCNVPROC) (EGLSyncNV sync, EGLenum mode); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBNVPROC) (EGLSyncNV sync, EGLint attribute, EGLint *value); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLSyncNV EGLAPIENTRY eglCreateFenceSyncNV (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncNV (EGLSyncNV sync); +EGLAPI EGLBoolean EGLAPIENTRY eglFenceNV (EGLSyncNV sync); +EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncNV (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout); +EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncNV (EGLSyncNV sync, EGLenum mode); +EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribNV (EGLSyncNV sync, EGLint attribute, EGLint *value); +#endif +#endif /* KHRONOS_SUPPORT_INT64 */ +#endif /* EGL_NV_sync */ + +#ifndef EGL_NV_system_time +#define EGL_NV_system_time 1 +typedef khronos_utime_nanoseconds_t EGLuint64NV; +#ifdef KHRONOS_SUPPORT_INT64 +typedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMEFREQUENCYNVPROC) (void); +typedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMENVPROC) (void); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeFrequencyNV (void); +EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeNV (void); +#endif +#endif /* KHRONOS_SUPPORT_INT64 */ +#endif /* EGL_NV_system_time */ + +#ifndef EGL_NV_triple_buffer +#define EGL_NV_triple_buffer 1 +#define EGL_TRIPLE_BUFFER_NV 0x3230 +#endif /* EGL_NV_triple_buffer */ + +#ifndef EGL_TIZEN_image_native_buffer +#define EGL_TIZEN_image_native_buffer 1 +#define EGL_NATIVE_BUFFER_TIZEN 0x32A0 +#endif /* EGL_TIZEN_image_native_buffer */ + +#ifndef EGL_TIZEN_image_native_surface +#define EGL_TIZEN_image_native_surface 1 +#define EGL_NATIVE_SURFACE_TIZEN 0x32A1 +#endif /* EGL_TIZEN_image_native_surface */ + +#ifndef EGL_WL_bind_wayland_display +#define EGL_WL_bind_wayland_display 1 +#define PFNEGLBINDWAYLANDDISPLAYWL PFNEGLBINDWAYLANDDISPLAYWLPROC +#define PFNEGLUNBINDWAYLANDDISPLAYWL PFNEGLUNBINDWAYLANDDISPLAYWLPROC +#define PFNEGLQUERYWAYLANDBUFFERWL PFNEGLQUERYWAYLANDBUFFERWLPROC +struct wl_display; +struct wl_resource; +#define EGL_WAYLAND_BUFFER_WL 0x31D5 +#define EGL_WAYLAND_PLANE_WL 0x31D6 +#define EGL_TEXTURE_Y_U_V_WL 0x31D7 +#define EGL_TEXTURE_Y_UV_WL 0x31D8 +#define EGL_TEXTURE_Y_XUXV_WL 0x31D9 +#define EGL_TEXTURE_EXTERNAL_WL 0x31DA +#define EGL_WAYLAND_Y_INVERTED_WL 0x31DB +typedef EGLBoolean (EGLAPIENTRYP PFNEGLBINDWAYLANDDISPLAYWLPROC) (EGLDisplay dpy, struct wl_display *display); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNBINDWAYLANDDISPLAYWLPROC) (EGLDisplay dpy, struct wl_display *display); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYWAYLANDBUFFERWLPROC) (EGLDisplay dpy, struct wl_resource *buffer, EGLint attribute, EGLint *value); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglBindWaylandDisplayWL (EGLDisplay dpy, struct wl_display *display); +EGLAPI EGLBoolean EGLAPIENTRY eglUnbindWaylandDisplayWL (EGLDisplay dpy, struct wl_display *display); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryWaylandBufferWL (EGLDisplay dpy, struct wl_resource *buffer, EGLint attribute, EGLint *value); +#endif +#endif /* EGL_WL_bind_wayland_display */ + +#ifndef EGL_WL_create_wayland_buffer_from_image +#define EGL_WL_create_wayland_buffer_from_image 1 +#define PFNEGLCREATEWAYLANDBUFFERFROMIMAGEWL PFNEGLCREATEWAYLANDBUFFERFROMIMAGEWLPROC +struct wl_buffer; +typedef struct wl_buffer *(EGLAPIENTRYP PFNEGLCREATEWAYLANDBUFFERFROMIMAGEWLPROC) (EGLDisplay dpy, EGLImageKHR image); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI struct wl_buffer *EGLAPIENTRY eglCreateWaylandBufferFromImageWL (EGLDisplay dpy, EGLImageKHR image); +#endif +#endif /* EGL_WL_create_wayland_buffer_from_image */ + +#ifdef __cplusplus +} +#endif + +#endif /* __eglext_h_ */ + +#endif /* _MSC_VER */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_endian.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_endian.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,645 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * # CategoryEndian + * + * Functions converting endian-specific values to different byte orders. + * + * These functions either unconditionally swap byte order (SDL_Swap16, + * SDL_Swap32, SDL_Swap64, SDL_SwapFloat), or they swap to/from the system's + * native byte order (SDL_Swap16LE, SDL_Swap16BE, SDL_Swap32LE, SDL_Swap32BE, + * SDL_Swap32LE, SDL_Swap32BE, SDL_SwapFloatLE, SDL_SwapFloatBE). In the + * latter case, the functionality is provided by macros that become no-ops if + * a swap isn't necessary: on an x86 (littleendian) processor, SDL_Swap32LE + * does nothing, but SDL_Swap32BE reverses the bytes of the data. On a PowerPC + * processor (bigendian), the macros behavior is reversed. + * + * The swap routines are inline functions, and attempt to use compiler + * intrinsics, inline assembly, and other magic to make byteswapping + * efficient. + */ + +#ifndef SDL_endian_h_ +#define SDL_endian_h_ + +#include + +#if defined(_MSC_VER) && (_MSC_VER >= 1400) +/* As of Clang 11, '_m_prefetchw' is conflicting with the winnt.h's version, + so we define the needed '_m_prefetch' here as a pseudo-header, until the issue is fixed. */ +#if defined(__clang__) && !SDL_HAS_BUILTIN(_m_prefetch) +#ifndef __PRFCHWINTRIN_H +#define __PRFCHWINTRIN_H +static __inline__ void __attribute__((__always_inline__, __nodebug__)) +_m_prefetch(void *__P) +{ + __builtin_prefetch(__P, 0, 3 /* _MM_HINT_T0 */); +} +#endif /* __PRFCHWINTRIN_H */ +#endif /* __clang__ */ + +#include +#endif + +/** + * \name The two types of endianness + */ +/* @{ */ + + +/** + * A value to represent littleendian byteorder. + * + * This is used with the preprocessor macro SDL_BYTEORDER, to determine a + * platform's byte ordering: + * + * ```c + * #if SDL_BYTEORDER == SDL_LIL_ENDIAN + * SDL_Log("This system is littleendian."); + * #endif + * ``` + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_BYTEORDER + * \sa SDL_BIG_ENDIAN + */ +#define SDL_LIL_ENDIAN 1234 + +/** + * A value to represent bigendian byteorder. + * + * This is used with the preprocessor macro SDL_BYTEORDER, to determine a + * platform's byte ordering: + * + * ```c + * #if SDL_BYTEORDER == SDL_BIG_ENDIAN + * SDL_Log("This system is bigendian."); + * #endif + * ``` + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_BYTEORDER + * \sa SDL_LIL_ENDIAN + */ +#define SDL_BIG_ENDIAN 4321 + +/* @} */ + +#ifndef SDL_BYTEORDER +#ifdef SDL_WIKI_DOCUMENTATION_SECTION + +/** + * A macro that reports the target system's byte order. + * + * This is set to either SDL_LIL_ENDIAN or SDL_BIG_ENDIAN (and maybe other + * values in the future, if something else becomes popular). This can be + * tested with the preprocessor, so decisions can be made at compile time. + * + * ```c + * #if SDL_BYTEORDER == SDL_BIG_ENDIAN + * SDL_Log("This system is bigendian."); + * #endif + * ``` + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_LIL_ENDIAN + * \sa SDL_BIG_ENDIAN + */ +#define SDL_BYTEORDER SDL_LIL_ENDIAN___or_maybe___SDL_BIG_ENDIAN +#elif defined(SDL_PLATFORM_LINUX) || defined(__GLIBC__) +#include +#define SDL_BYTEORDER __BYTE_ORDER +#elif defined(SDL_PLATFORM_SOLARIS) +#include +#if defined(_LITTLE_ENDIAN) +#define SDL_BYTEORDER SDL_LIL_ENDIAN +#elif defined(_BIG_ENDIAN) +#define SDL_BYTEORDER SDL_BIG_ENDIAN +#else +#error Unsupported endianness +#endif +#elif defined(SDL_PLATFORM_OPENBSD) || defined(__DragonFly__) +#include +#define SDL_BYTEORDER BYTE_ORDER +#elif defined(SDL_PLATFORM_FREEBSD) || defined(SDL_PLATFORM_NETBSD) +#include +#define SDL_BYTEORDER BYTE_ORDER +/* predefs from newer gcc and clang versions: */ +#elif defined(__ORDER_LITTLE_ENDIAN__) && defined(__ORDER_BIG_ENDIAN__) && defined(__BYTE_ORDER__) +#if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) +#define SDL_BYTEORDER SDL_LIL_ENDIAN +#elif (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) +#define SDL_BYTEORDER SDL_BIG_ENDIAN +#else +#error Unsupported endianness +#endif /**/ +#else +#if defined(__hppa__) || \ + defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \ + (defined(__MIPS__) && defined(__MIPSEB__)) || \ + defined(__ppc__) || defined(__POWERPC__) || defined(__powerpc__) || defined(__PPC__) || \ + defined(__sparc__) || defined(__sparc) +#define SDL_BYTEORDER SDL_BIG_ENDIAN +#else +#define SDL_BYTEORDER SDL_LIL_ENDIAN +#endif +#endif /* SDL_PLATFORM_LINUX */ +#endif /* !SDL_BYTEORDER */ + +#ifndef SDL_FLOATWORDORDER +#ifdef SDL_WIKI_DOCUMENTATION_SECTION + +/** + * A macro that reports the target system's floating point word order. + * + * This is set to either SDL_LIL_ENDIAN or SDL_BIG_ENDIAN (and maybe other + * values in the future, if something else becomes popular). This can be + * tested with the preprocessor, so decisions can be made at compile time. + * + * ```c + * #if SDL_FLOATWORDORDER == SDL_BIG_ENDIAN + * SDL_Log("This system's floats are bigendian."); + * #endif + * ``` + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_LIL_ENDIAN + * \sa SDL_BIG_ENDIAN + */ +#define SDL_FLOATWORDORDER SDL_LIL_ENDIAN___or_maybe___SDL_BIG_ENDIAN +/* predefs from newer gcc versions: */ +#elif defined(__ORDER_LITTLE_ENDIAN__) && defined(__ORDER_BIG_ENDIAN__) && defined(__FLOAT_WORD_ORDER__) +#if (__FLOAT_WORD_ORDER__ == __ORDER_LITTLE_ENDIAN__) +#define SDL_FLOATWORDORDER SDL_LIL_ENDIAN +#elif (__FLOAT_WORD_ORDER__ == __ORDER_BIG_ENDIAN__) +#define SDL_FLOATWORDORDER SDL_BIG_ENDIAN +#else +#error Unsupported endianness +#endif /**/ +#elif defined(__MAVERICK__) +/* For Maverick, float words are always little-endian. */ +#define SDL_FLOATWORDORDER SDL_LIL_ENDIAN +#elif (defined(__arm__) || defined(__thumb__)) && !defined(__VFP_FP__) && !defined(__ARM_EABI__) +/* For FPA, float words are always big-endian. */ +#define SDL_FLOATWORDORDER SDL_BIG_ENDIAN +#else +/* By default, assume that floats words follow the memory system mode. */ +#define SDL_FLOATWORDORDER SDL_BYTEORDER +#endif /* __FLOAT_WORD_ORDER__ */ +#endif /* !SDL_FLOATWORDORDER */ + + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* various modern compilers may have builtin swap */ +#if defined(__GNUC__) || defined(__clang__) +# define HAS_BUILTIN_BSWAP16 (SDL_HAS_BUILTIN(__builtin_bswap16)) || \ + (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)) +# define HAS_BUILTIN_BSWAP32 (SDL_HAS_BUILTIN(__builtin_bswap32)) || \ + (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) +# define HAS_BUILTIN_BSWAP64 (SDL_HAS_BUILTIN(__builtin_bswap64)) || \ + (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) + + /* this one is broken */ +# define HAS_BROKEN_BSWAP (__GNUC__ == 2 && __GNUC_MINOR__ <= 95) +#else +# define HAS_BUILTIN_BSWAP16 0 +# define HAS_BUILTIN_BSWAP32 0 +# define HAS_BUILTIN_BSWAP64 0 +# define HAS_BROKEN_BSWAP 0 +#endif + +/* Byte swap 16-bit integer. */ +#ifndef SDL_WIKI_DOCUMENTATION_SECTION +#if HAS_BUILTIN_BSWAP16 +#define SDL_Swap16(x) __builtin_bswap16(x) +#elif (defined(_MSC_VER) && (_MSC_VER >= 1400)) && !defined(__ICL) +#pragma intrinsic(_byteswap_ushort) +#define SDL_Swap16(x) _byteswap_ushort(x) +#elif defined(__i386__) && !HAS_BROKEN_BSWAP +SDL_FORCE_INLINE Uint16 SDL_Swap16(Uint16 x) +{ + __asm__("xchgb %b0,%h0": "=q"(x):"0"(x)); + return x; +} +#elif defined(__x86_64__) +SDL_FORCE_INLINE Uint16 SDL_Swap16(Uint16 x) +{ + __asm__("xchgb %b0,%h0": "=abcd"(x):"0"(x)); + return x; +} +#elif (defined(__powerpc__) || defined(__ppc__)) +SDL_FORCE_INLINE Uint16 SDL_Swap16(Uint16 x) +{ + int result; + + __asm__("rlwimi %0,%2,8,16,23": "=&r"(result):"0"(x >> 8), "r"(x)); + return (Uint16)result; +} +#elif (defined(__m68k__) && !defined(__mcoldfire__)) +SDL_FORCE_INLINE Uint16 SDL_Swap16(Uint16 x) +{ + __asm__("rorw #8,%0": "=d"(x): "0"(x):"cc"); + return x; +} +#elif defined(__WATCOMC__) && defined(__386__) +extern __inline Uint16 SDL_Swap16(Uint16); +#pragma aux SDL_Swap16 = \ + "xchg al, ah" \ + parm [ax] \ + modify [ax]; +#else +SDL_FORCE_INLINE Uint16 SDL_Swap16(Uint16 x) +{ + return SDL_static_cast(Uint16, ((x << 8) | (x >> 8))); +} +#endif +#endif + +/* Byte swap 32-bit integer. */ +#ifndef SDL_WIKI_DOCUMENTATION_SECTION +#if HAS_BUILTIN_BSWAP32 +#define SDL_Swap32(x) __builtin_bswap32(x) +#elif (defined(_MSC_VER) && (_MSC_VER >= 1400)) && !defined(__ICL) +#pragma intrinsic(_byteswap_ulong) +#define SDL_Swap32(x) _byteswap_ulong(x) +#elif defined(__i386__) && !HAS_BROKEN_BSWAP +SDL_FORCE_INLINE Uint32 SDL_Swap32(Uint32 x) +{ + __asm__("bswap %0": "=r"(x):"0"(x)); + return x; +} +#elif defined(__x86_64__) +SDL_FORCE_INLINE Uint32 SDL_Swap32(Uint32 x) +{ + __asm__("bswapl %0": "=r"(x):"0"(x)); + return x; +} +#elif (defined(__powerpc__) || defined(__ppc__)) +SDL_FORCE_INLINE Uint32 SDL_Swap32(Uint32 x) +{ + Uint32 result; + + __asm__("rlwimi %0,%2,24,16,23": "=&r"(result): "0" (x>>24), "r"(x)); + __asm__("rlwimi %0,%2,8,8,15" : "=&r"(result): "0" (result), "r"(x)); + __asm__("rlwimi %0,%2,24,0,7" : "=&r"(result): "0" (result), "r"(x)); + return result; +} +#elif (defined(__m68k__) && !defined(__mcoldfire__)) +SDL_FORCE_INLINE Uint32 SDL_Swap32(Uint32 x) +{ + __asm__("rorw #8,%0\n\tswap %0\n\trorw #8,%0": "=d"(x): "0"(x):"cc"); + return x; +} +#elif defined(__WATCOMC__) && defined(__386__) +extern __inline Uint32 SDL_Swap32(Uint32); +#pragma aux SDL_Swap32 = \ + "bswap eax" \ + parm [eax] \ + modify [eax]; +#else +SDL_FORCE_INLINE Uint32 SDL_Swap32(Uint32 x) +{ + return SDL_static_cast(Uint32, ((x << 24) | ((x << 8) & 0x00FF0000) | + ((x >> 8) & 0x0000FF00) | (x >> 24))); +} +#endif +#endif + +/* Byte swap 64-bit integer. */ +#ifndef SDL_WIKI_DOCUMENTATION_SECTION +#if HAS_BUILTIN_BSWAP64 +#define SDL_Swap64(x) __builtin_bswap64(x) +#elif (defined(_MSC_VER) && (_MSC_VER >= 1400)) && !defined(__ICL) +#pragma intrinsic(_byteswap_uint64) +#define SDL_Swap64(x) _byteswap_uint64(x) +#elif defined(__i386__) && !HAS_BROKEN_BSWAP +SDL_FORCE_INLINE Uint64 SDL_Swap64(Uint64 x) +{ + union { + struct { + Uint32 a, b; + } s; + Uint64 u; + } v; + v.u = x; + __asm__("bswapl %0 ; bswapl %1 ; xchgl %0,%1" + : "=r"(v.s.a), "=r"(v.s.b) + : "0" (v.s.a), "1"(v.s.b)); + return v.u; +} +#elif defined(__x86_64__) +SDL_FORCE_INLINE Uint64 SDL_Swap64(Uint64 x) +{ + __asm__("bswapq %0": "=r"(x):"0"(x)); + return x; +} +#elif defined(__WATCOMC__) && defined(__386__) +extern __inline Uint64 SDL_Swap64(Uint64); +#pragma aux SDL_Swap64 = \ + "bswap eax" \ + "bswap edx" \ + "xchg eax,edx" \ + parm [eax edx] \ + modify [eax edx]; +#else +SDL_FORCE_INLINE Uint64 SDL_Swap64(Uint64 x) +{ + Uint32 hi, lo; + + /* Separate into high and low 32-bit values and swap them */ + lo = SDL_static_cast(Uint32, x & 0xFFFFFFFF); + x >>= 32; + hi = SDL_static_cast(Uint32, x & 0xFFFFFFFF); + x = SDL_Swap32(lo); + x <<= 32; + x |= SDL_Swap32(hi); + return (x); +} +#endif +#endif + +/** + * Byte-swap a floating point number. + * + * This will always byte-swap the value, whether it's currently in the native + * byteorder of the system or not. You should use SDL_SwapFloatLE or + * SDL_SwapFloatBE instead, in most cases. + * + * Note that this is a forced-inline function in a header, and not a public + * API function available in the SDL library (which is to say, the code is + * embedded in the calling program and the linker and dynamic loader will not + * be able to find this function inside SDL itself). + * + * \param x the value to byte-swap. + * \returns x, with its bytes in the opposite endian order. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +SDL_FORCE_INLINE float SDL_SwapFloat(float x) +{ + union { + float f; + Uint32 ui32; + } swapper; + swapper.f = x; + swapper.ui32 = SDL_Swap32(swapper.ui32); + return swapper.f; +} + +/* remove extra macros */ +#undef HAS_BROKEN_BSWAP +#undef HAS_BUILTIN_BSWAP16 +#undef HAS_BUILTIN_BSWAP32 +#undef HAS_BUILTIN_BSWAP64 + + +#ifdef SDL_WIKI_DOCUMENTATION_SECTION + +/** + * Byte-swap an unsigned 16-bit number. + * + * This will always byte-swap the value, whether it's currently in the native + * byteorder of the system or not. You should use SDL_Swap16LE or SDL_Swap16BE + * instead, in most cases. + * + * Note that this is a forced-inline function in a header, and not a public + * API function available in the SDL library (which is to say, the code is + * embedded in the calling program and the linker and dynamic loader will not + * be able to find this function inside SDL itself). + * + * \param x the value to byte-swap. + * \returns `x`, with its bytes in the opposite endian order. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +SDL_FORCE_INLINE Uint16 SDL_Swap16(Uint16 x) { return x_but_byteswapped; } + +/** + * Byte-swap an unsigned 32-bit number. + * + * This will always byte-swap the value, whether it's currently in the native + * byteorder of the system or not. You should use SDL_Swap32LE or SDL_Swap32BE + * instead, in most cases. + * + * Note that this is a forced-inline function in a header, and not a public + * API function available in the SDL library (which is to say, the code is + * embedded in the calling program and the linker and dynamic loader will not + * be able to find this function inside SDL itself). + * + * \param x the value to byte-swap. + * \returns `x`, with its bytes in the opposite endian order. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +SDL_FORCE_INLINE Uint32 SDL_Swap32(Uint32 x) { return x_but_byteswapped; } + +/** + * Byte-swap an unsigned 64-bit number. + * + * This will always byte-swap the value, whether it's currently in the native + * byteorder of the system or not. You should use SDL_Swap64LE or SDL_Swap64BE + * instead, in most cases. + * + * Note that this is a forced-inline function in a header, and not a public + * API function available in the SDL library (which is to say, the code is + * embedded in the calling program and the linker and dynamic loader will not + * be able to find this function inside SDL itself). + * + * \param x the value to byte-swap. + * \returns `x`, with its bytes in the opposite endian order. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +SDL_FORCE_INLINE Uint64 SDL_Swap64(Uint64 x) { return x_but_byteswapped; } + +/** + * Swap a 16-bit value from littleendian to native byte order. + * + * If this is running on a littleendian system, `x` is returned unchanged. + * + * This macro never references `x` more than once, avoiding side effects. + * + * \param x the value to swap, in littleendian byte order. + * \returns `x` in native byte order. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_Swap16LE(x) SwapOnlyIfNecessary(x) + +/** + * Swap a 32-bit value from littleendian to native byte order. + * + * If this is running on a littleendian system, `x` is returned unchanged. + * + * This macro never references `x` more than once, avoiding side effects. + * + * \param x the value to swap, in littleendian byte order. + * \returns `x` in native byte order. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_Swap32LE(x) SwapOnlyIfNecessary(x) + +/** + * Swap a 64-bit value from littleendian to native byte order. + * + * If this is running on a littleendian system, `x` is returned unchanged. + * + * This macro never references `x` more than once, avoiding side effects. + * + * \param x the value to swap, in littleendian byte order. + * \returns `x` in native byte order. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_Swap64LE(x) SwapOnlyIfNecessary(x) + +/** + * Swap a floating point value from littleendian to native byte order. + * + * If this is running on a littleendian system, `x` is returned unchanged. + * + * This macro never references `x` more than once, avoiding side effects. + * + * \param x the value to swap, in littleendian byte order. + * \returns `x` in native byte order. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_SwapFloatLE(x) SwapOnlyIfNecessary(x) + +/** + * Swap a 16-bit value from bigendian to native byte order. + * + * If this is running on a bigendian system, `x` is returned unchanged. + * + * This macro never references `x` more than once, avoiding side effects. + * + * \param x the value to swap, in bigendian byte order. + * \returns `x` in native byte order. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_Swap16BE(x) SwapOnlyIfNecessary(x) + +/** + * Swap a 32-bit value from bigendian to native byte order. + * + * If this is running on a bigendian system, `x` is returned unchanged. + * + * This macro never references `x` more than once, avoiding side effects. + * + * \param x the value to swap, in bigendian byte order. + * \returns `x` in native byte order. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_Swap32BE(x) SwapOnlyIfNecessary(x) + +/** + * Swap a 64-bit value from bigendian to native byte order. + * + * If this is running on a bigendian system, `x` is returned unchanged. + * + * This macro never references `x` more than once, avoiding side effects. + * + * \param x the value to swap, in bigendian byte order. + * \returns `x` in native byte order. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_Swap64BE(x) SwapOnlyIfNecessary(x) + +/** + * Swap a floating point value from bigendian to native byte order. + * + * If this is running on a bigendian system, `x` is returned unchanged. + * + * This macro never references `x` more than once, avoiding side effects. + * + * \param x the value to swap, in bigendian byte order. + * \returns `x` in native byte order. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_SwapFloatBE(x) SwapOnlyIfNecessary(x) + +#elif SDL_BYTEORDER == SDL_LIL_ENDIAN +#define SDL_Swap16LE(x) (x) +#define SDL_Swap32LE(x) (x) +#define SDL_Swap64LE(x) (x) +#define SDL_SwapFloatLE(x) (x) +#define SDL_Swap16BE(x) SDL_Swap16(x) +#define SDL_Swap32BE(x) SDL_Swap32(x) +#define SDL_Swap64BE(x) SDL_Swap64(x) +#define SDL_SwapFloatBE(x) SDL_SwapFloat(x) +#else +#define SDL_Swap16LE(x) SDL_Swap16(x) +#define SDL_Swap32LE(x) SDL_Swap32(x) +#define SDL_Swap64LE(x) SDL_Swap64(x) +#define SDL_SwapFloatLE(x) SDL_SwapFloat(x) +#define SDL_Swap16BE(x) (x) +#define SDL_Swap32BE(x) (x) +#define SDL_Swap64BE(x) (x) +#define SDL_SwapFloatBE(x) (x) +#endif + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_endian_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_error.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_error.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,226 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * # CategoryError + * + * Simple error message routines for SDL. + * + * Most apps will interface with these APIs in exactly one function: when + * almost any SDL function call reports failure, you can get a human-readable + * string of the problem from SDL_GetError(). + * + * These strings are maintained per-thread, and apps are welcome to set their + * own errors, which is popular when building libraries on top of SDL for + * other apps to consume. These strings are set by calling SDL_SetError(). + * + * A common usage pattern is to have a function that returns true for success + * and false for failure, and do this when something fails: + * + * ```c + * if (something_went_wrong) { + * return SDL_SetError("The thing broke in this specific way: %d", errcode); + * } + * ``` + * + * It's also common to just return `false` in this case if the failing thing + * is known to call SDL_SetError(), so errors simply propagate through. + */ + +#ifndef SDL_error_h_ +#define SDL_error_h_ + +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Public functions */ + + +/** + * Set the SDL error message for the current thread. + * + * Calling this function will replace any previous error message that was set. + * + * This function always returns false, since SDL frequently uses false to + * signify a failing result, leading to this idiom: + * + * ```c + * if (error_code) { + * return SDL_SetError("This operation has failed: %d", error_code); + * } + * ``` + * + * \param fmt a printf()-style message format string. + * \param ... additional parameters matching % tokens in the `fmt` string, if + * any. + * \returns false. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_ClearError + * \sa SDL_GetError + * \sa SDL_SetErrorV + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1); + +/** + * Set the SDL error message for the current thread. + * + * Calling this function will replace any previous error message that was set. + * + * \param fmt a printf()-style message format string. + * \param ap a variable argument list. + * \returns false. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_ClearError + * \sa SDL_GetError + * \sa SDL_SetError + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetErrorV(SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap) SDL_PRINTF_VARARG_FUNCV(1); + +/** + * Set an error indicating that memory allocation failed. + * + * This function does not do any memory allocation. + * + * \returns false. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_OutOfMemory(void); + +/** + * Retrieve a message about the last error that occurred on the current + * thread. + * + * It is possible for multiple errors to occur before calling SDL_GetError(). + * Only the last error is returned. + * + * The message is only applicable when an SDL function has signaled an error. + * You must check the return values of SDL function calls to determine when to + * appropriately call SDL_GetError(). You should *not* use the results of + * SDL_GetError() to decide if an error has occurred! Sometimes SDL will set + * an error string even when reporting success. + * + * SDL will *not* clear the error string for successful API calls. You *must* + * check return values for failure cases before you can assume the error + * string applies. + * + * Error strings are set per-thread, so an error set in a different thread + * will not interfere with the current thread's operation. + * + * The returned value is a thread-local string which will remain valid until + * the current thread's error string is changed. The caller should make a copy + * if the value is needed after the next SDL API call. + * + * \returns a message with information about the specific error that occurred, + * or an empty string if there hasn't been an error message set since + * the last call to SDL_ClearError(). + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_ClearError + * \sa SDL_SetError + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetError(void); + +/** + * Clear any previous error message for this thread. + * + * \returns true. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetError + * \sa SDL_SetError + */ +extern SDL_DECLSPEC bool SDLCALL SDL_ClearError(void); + +/** + * \name Internal error functions + * + * \internal + * Private error reporting function - used internally. + */ +/* @{ */ + +/** + * A macro to standardize error reporting on unsupported operations. + * + * This simply calls SDL_SetError() with a standardized error string, for + * convenience, consistency, and clarity. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_Unsupported() SDL_SetError("That operation is not supported") + +/** + * A macro to standardize error reporting on unsupported operations. + * + * This simply calls SDL_SetError() with a standardized error string, for + * convenience, consistency, and clarity. + * + * A common usage pattern inside SDL is this: + * + * ```c + * bool MyFunction(const char *str) { + * if (!str) { + * return SDL_InvalidParamError("str"); // returns false. + * } + * DoSomething(str); + * return true; + * } + * ``` + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_InvalidParamError(param) SDL_SetError("Parameter '%s' is invalid", (param)) + +/* @} *//* Internal error functions */ + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_error_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_events.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_events.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,1647 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * # CategoryEvents + * + * Event queue management. + * + * It's extremely common--often required--that an app deal with SDL's event + * queue. Almost all useful information about interactions with the real world + * flow through here: the user interacting with the computer and app, hardware + * coming and going, the system changing in some way, etc. + * + * An app generally takes a moment, perhaps at the start of a new frame, to + * examine any events that have occurred since the last time and process or + * ignore them. This is generally done by calling SDL_PollEvent() in a loop + * until it returns false (or, if using the main callbacks, events are + * provided one at a time in calls to SDL_AppEvent() before the next call to + * SDL_AppIterate(); in this scenario, the app does not call SDL_PollEvent() + * at all). + * + * There is other forms of control, too: SDL_PeepEvents() has more + * functionality at the cost of more complexity, and SDL_WaitEvent() can block + * the process until something interesting happens, which might be beneficial + * for certain types of programs on low-power hardware. One may also call + * SDL_AddEventWatch() to set a callback when new events arrive. + * + * The app is free to generate their own events, too: SDL_PushEvent allows the + * app to put events onto the queue for later retrieval; SDL_RegisterEvents + * can guarantee that these events have a type that isn't in use by other + * parts of the system. + */ + +#ifndef SDL_events_h_ +#define SDL_events_h_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* General keyboard/mouse/pen state definitions */ + +/** + * The types of events that can be delivered. + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_EventType +{ + SDL_EVENT_FIRST = 0, /**< Unused (do not remove) */ + + /* Application events */ + SDL_EVENT_QUIT = 0x100, /**< User-requested quit */ + + /* These application events have special meaning on iOS and Android, see README-ios.md and README-android.md for details */ + SDL_EVENT_TERMINATING, /**< The application is being terminated by the OS. This event must be handled in a callback set with SDL_AddEventWatch(). + Called on iOS in applicationWillTerminate() + Called on Android in onDestroy() + */ + SDL_EVENT_LOW_MEMORY, /**< The application is low on memory, free memory if possible. This event must be handled in a callback set with SDL_AddEventWatch(). + Called on iOS in applicationDidReceiveMemoryWarning() + Called on Android in onTrimMemory() + */ + SDL_EVENT_WILL_ENTER_BACKGROUND, /**< The application is about to enter the background. This event must be handled in a callback set with SDL_AddEventWatch(). + Called on iOS in applicationWillResignActive() + Called on Android in onPause() + */ + SDL_EVENT_DID_ENTER_BACKGROUND, /**< The application did enter the background and may not get CPU for some time. This event must be handled in a callback set with SDL_AddEventWatch(). + Called on iOS in applicationDidEnterBackground() + Called on Android in onPause() + */ + SDL_EVENT_WILL_ENTER_FOREGROUND, /**< The application is about to enter the foreground. This event must be handled in a callback set with SDL_AddEventWatch(). + Called on iOS in applicationWillEnterForeground() + Called on Android in onResume() + */ + SDL_EVENT_DID_ENTER_FOREGROUND, /**< The application is now interactive. This event must be handled in a callback set with SDL_AddEventWatch(). + Called on iOS in applicationDidBecomeActive() + Called on Android in onResume() + */ + + SDL_EVENT_LOCALE_CHANGED, /**< The user's locale preferences have changed. */ + + SDL_EVENT_SYSTEM_THEME_CHANGED, /**< The system theme changed */ + + /* Display events */ + /* 0x150 was SDL_DISPLAYEVENT, reserve the number for sdl2-compat */ + SDL_EVENT_DISPLAY_ORIENTATION = 0x151, /**< Display orientation has changed to data1 */ + SDL_EVENT_DISPLAY_ADDED, /**< Display has been added to the system */ + SDL_EVENT_DISPLAY_REMOVED, /**< Display has been removed from the system */ + SDL_EVENT_DISPLAY_MOVED, /**< Display has changed position */ + SDL_EVENT_DISPLAY_DESKTOP_MODE_CHANGED, /**< Display has changed desktop mode */ + SDL_EVENT_DISPLAY_CURRENT_MODE_CHANGED, /**< Display has changed current mode */ + SDL_EVENT_DISPLAY_CONTENT_SCALE_CHANGED, /**< Display has changed content scale */ + SDL_EVENT_DISPLAY_USABLE_BOUNDS_CHANGED, /**< Display has changed usable bounds */ + SDL_EVENT_DISPLAY_FIRST = SDL_EVENT_DISPLAY_ORIENTATION, + SDL_EVENT_DISPLAY_LAST = SDL_EVENT_DISPLAY_USABLE_BOUNDS_CHANGED, + + /* Window events */ + /* 0x200 was SDL_WINDOWEVENT, reserve the number for sdl2-compat */ + /* 0x201 was SDL_SYSWMEVENT, reserve the number for sdl2-compat */ + SDL_EVENT_WINDOW_SHOWN = 0x202, /**< Window has been shown */ + SDL_EVENT_WINDOW_HIDDEN, /**< Window has been hidden */ + SDL_EVENT_WINDOW_EXPOSED, /**< Window has been exposed and should be redrawn, and can be redrawn directly from event watchers for this event. + data1 is 1 for live-resize expose events, 0 otherwise. */ + SDL_EVENT_WINDOW_MOVED, /**< Window has been moved to data1, data2 */ + SDL_EVENT_WINDOW_RESIZED, /**< Window has been resized to data1xdata2 */ + SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED,/**< The pixel size of the window has changed to data1xdata2 */ + SDL_EVENT_WINDOW_METAL_VIEW_RESIZED,/**< The pixel size of a Metal view associated with the window has changed */ + SDL_EVENT_WINDOW_MINIMIZED, /**< Window has been minimized */ + SDL_EVENT_WINDOW_MAXIMIZED, /**< Window has been maximized */ + SDL_EVENT_WINDOW_RESTORED, /**< Window has been restored to normal size and position */ + SDL_EVENT_WINDOW_MOUSE_ENTER, /**< Window has gained mouse focus */ + SDL_EVENT_WINDOW_MOUSE_LEAVE, /**< Window has lost mouse focus */ + SDL_EVENT_WINDOW_FOCUS_GAINED, /**< Window has gained keyboard focus */ + SDL_EVENT_WINDOW_FOCUS_LOST, /**< Window has lost keyboard focus */ + SDL_EVENT_WINDOW_CLOSE_REQUESTED, /**< The window manager requests that the window be closed */ + SDL_EVENT_WINDOW_HIT_TEST, /**< Window had a hit test that wasn't SDL_HITTEST_NORMAL */ + SDL_EVENT_WINDOW_ICCPROF_CHANGED, /**< The ICC profile of the window's display has changed */ + SDL_EVENT_WINDOW_DISPLAY_CHANGED, /**< Window has been moved to display data1 */ + SDL_EVENT_WINDOW_DISPLAY_SCALE_CHANGED, /**< Window display scale has been changed */ + SDL_EVENT_WINDOW_SAFE_AREA_CHANGED, /**< The window safe area has been changed */ + SDL_EVENT_WINDOW_OCCLUDED, /**< The window has been occluded */ + SDL_EVENT_WINDOW_ENTER_FULLSCREEN, /**< The window has entered fullscreen mode */ + SDL_EVENT_WINDOW_LEAVE_FULLSCREEN, /**< The window has left fullscreen mode */ + SDL_EVENT_WINDOW_DESTROYED, /**< The window with the associated ID is being or has been destroyed. If this message is being handled + in an event watcher, the window handle is still valid and can still be used to retrieve any properties + associated with the window. Otherwise, the handle has already been destroyed and all resources + associated with it are invalid */ + SDL_EVENT_WINDOW_HDR_STATE_CHANGED, /**< Window HDR properties have changed */ + SDL_EVENT_WINDOW_FIRST = SDL_EVENT_WINDOW_SHOWN, + SDL_EVENT_WINDOW_LAST = SDL_EVENT_WINDOW_HDR_STATE_CHANGED, + + /* Keyboard events */ + SDL_EVENT_KEY_DOWN = 0x300, /**< Key pressed */ + SDL_EVENT_KEY_UP, /**< Key released */ + SDL_EVENT_TEXT_EDITING, /**< Keyboard text editing (composition) */ + SDL_EVENT_TEXT_INPUT, /**< Keyboard text input */ + SDL_EVENT_KEYMAP_CHANGED, /**< Keymap changed due to a system event such as an + input language or keyboard layout change. */ + SDL_EVENT_KEYBOARD_ADDED, /**< A new keyboard has been inserted into the system */ + SDL_EVENT_KEYBOARD_REMOVED, /**< A keyboard has been removed */ + SDL_EVENT_TEXT_EDITING_CANDIDATES, /**< Keyboard text editing candidates */ + SDL_EVENT_SCREEN_KEYBOARD_SHOWN, /**< The on-screen keyboard has been shown */ + SDL_EVENT_SCREEN_KEYBOARD_HIDDEN, /**< The on-screen keyboard has been hidden */ + + /* Mouse events */ + SDL_EVENT_MOUSE_MOTION = 0x400, /**< Mouse moved */ + SDL_EVENT_MOUSE_BUTTON_DOWN, /**< Mouse button pressed */ + SDL_EVENT_MOUSE_BUTTON_UP, /**< Mouse button released */ + SDL_EVENT_MOUSE_WHEEL, /**< Mouse wheel motion */ + SDL_EVENT_MOUSE_ADDED, /**< A new mouse has been inserted into the system */ + SDL_EVENT_MOUSE_REMOVED, /**< A mouse has been removed */ + + /* Joystick events */ + SDL_EVENT_JOYSTICK_AXIS_MOTION = 0x600, /**< Joystick axis motion */ + SDL_EVENT_JOYSTICK_BALL_MOTION, /**< Joystick trackball motion */ + SDL_EVENT_JOYSTICK_HAT_MOTION, /**< Joystick hat position change */ + SDL_EVENT_JOYSTICK_BUTTON_DOWN, /**< Joystick button pressed */ + SDL_EVENT_JOYSTICK_BUTTON_UP, /**< Joystick button released */ + SDL_EVENT_JOYSTICK_ADDED, /**< A new joystick has been inserted into the system */ + SDL_EVENT_JOYSTICK_REMOVED, /**< An opened joystick has been removed */ + SDL_EVENT_JOYSTICK_BATTERY_UPDATED, /**< Joystick battery level change */ + SDL_EVENT_JOYSTICK_UPDATE_COMPLETE, /**< Joystick update is complete */ + + /* Gamepad events */ + SDL_EVENT_GAMEPAD_AXIS_MOTION = 0x650, /**< Gamepad axis motion */ + SDL_EVENT_GAMEPAD_BUTTON_DOWN, /**< Gamepad button pressed */ + SDL_EVENT_GAMEPAD_BUTTON_UP, /**< Gamepad button released */ + SDL_EVENT_GAMEPAD_ADDED, /**< A new gamepad has been inserted into the system */ + SDL_EVENT_GAMEPAD_REMOVED, /**< A gamepad has been removed */ + SDL_EVENT_GAMEPAD_REMAPPED, /**< The gamepad mapping was updated */ + SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN, /**< Gamepad touchpad was touched */ + SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION, /**< Gamepad touchpad finger was moved */ + SDL_EVENT_GAMEPAD_TOUCHPAD_UP, /**< Gamepad touchpad finger was lifted */ + SDL_EVENT_GAMEPAD_SENSOR_UPDATE, /**< Gamepad sensor was updated */ + SDL_EVENT_GAMEPAD_UPDATE_COMPLETE, /**< Gamepad update is complete */ + SDL_EVENT_GAMEPAD_STEAM_HANDLE_UPDATED, /**< Gamepad Steam handle has changed */ + + /* Touch events */ + SDL_EVENT_FINGER_DOWN = 0x700, + SDL_EVENT_FINGER_UP, + SDL_EVENT_FINGER_MOTION, + SDL_EVENT_FINGER_CANCELED, + + /* Pinch events */ + SDL_EVENT_PINCH_BEGIN = 0x710, /**< Pinch gesture started */ + SDL_EVENT_PINCH_UPDATE, /**< Pinch gesture updated */ + SDL_EVENT_PINCH_END, /**< Pinch gesture ended */ + + /* 0x800, 0x801, and 0x802 were the Gesture events from SDL2. Do not reuse these values! sdl2-compat needs them! */ + + /* Clipboard events */ + SDL_EVENT_CLIPBOARD_UPDATE = 0x900, /**< The clipboard changed */ + + /* Drag and drop events */ + SDL_EVENT_DROP_FILE = 0x1000, /**< The system requests a file open */ + SDL_EVENT_DROP_TEXT, /**< text/plain drag-and-drop event */ + SDL_EVENT_DROP_BEGIN, /**< A new set of drops is beginning (NULL filename) */ + SDL_EVENT_DROP_COMPLETE, /**< Current set of drops is now complete (NULL filename) */ + SDL_EVENT_DROP_POSITION, /**< Position while moving over the window */ + + /* Audio hotplug events */ + SDL_EVENT_AUDIO_DEVICE_ADDED = 0x1100, /**< A new audio device is available */ + SDL_EVENT_AUDIO_DEVICE_REMOVED, /**< An audio device has been removed. */ + SDL_EVENT_AUDIO_DEVICE_FORMAT_CHANGED, /**< An audio device's format has been changed by the system. */ + + /* Sensor events */ + SDL_EVENT_SENSOR_UPDATE = 0x1200, /**< A sensor was updated */ + + /* Pressure-sensitive pen events */ + SDL_EVENT_PEN_PROXIMITY_IN = 0x1300, /**< Pressure-sensitive pen has become available */ + SDL_EVENT_PEN_PROXIMITY_OUT, /**< Pressure-sensitive pen has become unavailable */ + SDL_EVENT_PEN_DOWN, /**< Pressure-sensitive pen touched drawing surface */ + SDL_EVENT_PEN_UP, /**< Pressure-sensitive pen stopped touching drawing surface */ + SDL_EVENT_PEN_BUTTON_DOWN, /**< Pressure-sensitive pen button pressed */ + SDL_EVENT_PEN_BUTTON_UP, /**< Pressure-sensitive pen button released */ + SDL_EVENT_PEN_MOTION, /**< Pressure-sensitive pen is moving on the tablet */ + SDL_EVENT_PEN_AXIS, /**< Pressure-sensitive pen angle/pressure/etc changed */ + + /* Camera hotplug events */ + SDL_EVENT_CAMERA_DEVICE_ADDED = 0x1400, /**< A new camera device is available */ + SDL_EVENT_CAMERA_DEVICE_REMOVED, /**< A camera device has been removed. */ + SDL_EVENT_CAMERA_DEVICE_APPROVED, /**< A camera device has been approved for use by the user. */ + SDL_EVENT_CAMERA_DEVICE_DENIED, /**< A camera device has been denied for use by the user. */ + + /* Render events */ + SDL_EVENT_RENDER_TARGETS_RESET = 0x2000, /**< The render targets have been reset and their contents need to be updated */ + SDL_EVENT_RENDER_DEVICE_RESET, /**< The device has been reset and all textures need to be recreated */ + SDL_EVENT_RENDER_DEVICE_LOST, /**< The device has been lost and can't be recovered. */ + + /* Reserved events for private platforms */ + SDL_EVENT_PRIVATE0 = 0x4000, + SDL_EVENT_PRIVATE1, + SDL_EVENT_PRIVATE2, + SDL_EVENT_PRIVATE3, + + /* Internal events */ + SDL_EVENT_POLL_SENTINEL = 0x7F00, /**< Signals the end of an event poll cycle */ + + /** Events SDL_EVENT_USER through SDL_EVENT_LAST are for your use, + * and should be allocated with SDL_RegisterEvents() + */ + SDL_EVENT_USER = 0x8000, + + /** + * This last event is only for bounding internal arrays + */ + SDL_EVENT_LAST = 0xFFFF, + + /* This just makes sure the enum is the size of Uint32 */ + SDL_EVENT_ENUM_PADDING = 0x7FFFFFFF + +} SDL_EventType; + +/** + * Fields shared by every event + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_CommonEvent +{ + Uint32 type; /**< Event type, shared with all events, Uint32 to cover user events which are not in the SDL_EventType enumeration */ + Uint32 reserved; + Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ +} SDL_CommonEvent; + +/** + * Display state change event data (event.display.*) + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_DisplayEvent +{ + SDL_EventType type; /**< SDL_EVENT_DISPLAY_* */ + Uint32 reserved; + Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ + SDL_DisplayID displayID;/**< The associated display */ + Sint32 data1; /**< event dependent data */ + Sint32 data2; /**< event dependent data */ +} SDL_DisplayEvent; + +/** + * Window state change event data (event.window.*) + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_WindowEvent +{ + SDL_EventType type; /**< SDL_EVENT_WINDOW_* */ + Uint32 reserved; + Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ + SDL_WindowID windowID; /**< The associated window */ + Sint32 data1; /**< event dependent data */ + Sint32 data2; /**< event dependent data */ +} SDL_WindowEvent; + +/** + * Keyboard device event structure (event.kdevice.*) + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_KeyboardDeviceEvent +{ + SDL_EventType type; /**< SDL_EVENT_KEYBOARD_ADDED or SDL_EVENT_KEYBOARD_REMOVED */ + Uint32 reserved; + Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ + SDL_KeyboardID which; /**< The keyboard instance id */ +} SDL_KeyboardDeviceEvent; + +/** + * Keyboard button event structure (event.key.*) + * + * The `key` is the base SDL_Keycode generated by pressing the `scancode` + * using the current keyboard layout, applying any options specified in + * SDL_HINT_KEYCODE_OPTIONS. You can get the SDL_Keycode corresponding to the + * event scancode and modifiers directly from the keyboard layout, bypassing + * SDL_HINT_KEYCODE_OPTIONS, by calling SDL_GetKeyFromScancode(). + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_GetKeyFromScancode + * \sa SDL_HINT_KEYCODE_OPTIONS + */ +typedef struct SDL_KeyboardEvent +{ + SDL_EventType type; /**< SDL_EVENT_KEY_DOWN or SDL_EVENT_KEY_UP */ + Uint32 reserved; + Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ + SDL_WindowID windowID; /**< The window with keyboard focus, if any */ + SDL_KeyboardID which; /**< The keyboard instance id, or 0 if unknown or virtual */ + SDL_Scancode scancode; /**< SDL physical key code */ + SDL_Keycode key; /**< SDL virtual key code */ + SDL_Keymod mod; /**< current key modifiers */ + Uint16 raw; /**< The platform dependent scancode for this event */ + bool down; /**< true if the key is pressed */ + bool repeat; /**< true if this is a key repeat */ +} SDL_KeyboardEvent; + +/** + * Keyboard text editing event structure (event.edit.*) + * + * The start cursor is the position, in UTF-8 characters, where new typing + * will be inserted into the editing text. The length is the number of UTF-8 + * characters that will be replaced by new typing. + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_TextEditingEvent +{ + SDL_EventType type; /**< SDL_EVENT_TEXT_EDITING */ + Uint32 reserved; + Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ + SDL_WindowID windowID; /**< The window with keyboard focus, if any */ + const char *text; /**< The editing text */ + Sint32 start; /**< The start cursor of selected editing text, or -1 if not set */ + Sint32 length; /**< The length of selected editing text, or -1 if not set */ +} SDL_TextEditingEvent; + +/** + * Keyboard IME candidates event structure (event.edit_candidates.*) + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_TextEditingCandidatesEvent +{ + SDL_EventType type; /**< SDL_EVENT_TEXT_EDITING_CANDIDATES */ + Uint32 reserved; + Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ + SDL_WindowID windowID; /**< The window with keyboard focus, if any */ + const char * const *candidates; /**< The list of candidates, or NULL if there are no candidates available */ + Sint32 num_candidates; /**< The number of strings in `candidates` */ + Sint32 selected_candidate; /**< The index of the selected candidate, or -1 if no candidate is selected */ + bool horizontal; /**< true if the list is horizontal, false if it's vertical */ + Uint8 padding1; + Uint8 padding2; + Uint8 padding3; +} SDL_TextEditingCandidatesEvent; + +/** + * Keyboard text input event structure (event.text.*) + * + * This event will never be delivered unless text input is enabled by calling + * SDL_StartTextInput(). Text input is disabled by default! + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_StartTextInput + * \sa SDL_StopTextInput + */ +typedef struct SDL_TextInputEvent +{ + SDL_EventType type; /**< SDL_EVENT_TEXT_INPUT */ + Uint32 reserved; + Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ + SDL_WindowID windowID; /**< The window with keyboard focus, if any */ + const char *text; /**< The input text, UTF-8 encoded */ +} SDL_TextInputEvent; + +/** + * Mouse device event structure (event.mdevice.*) + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_MouseDeviceEvent +{ + SDL_EventType type; /**< SDL_EVENT_MOUSE_ADDED or SDL_EVENT_MOUSE_REMOVED */ + Uint32 reserved; + Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ + SDL_MouseID which; /**< The mouse instance id */ +} SDL_MouseDeviceEvent; + +/** + * Mouse motion event structure (event.motion.*) + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_MouseMotionEvent +{ + SDL_EventType type; /**< SDL_EVENT_MOUSE_MOTION */ + Uint32 reserved; + Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ + SDL_WindowID windowID; /**< The window with mouse focus, if any */ + SDL_MouseID which; /**< The mouse instance id in relative mode, SDL_TOUCH_MOUSEID for touch events, or 0 */ + SDL_MouseButtonFlags state; /**< The current button state */ + float x; /**< X coordinate, relative to window */ + float y; /**< Y coordinate, relative to window */ + float xrel; /**< The relative motion in the X direction */ + float yrel; /**< The relative motion in the Y direction */ +} SDL_MouseMotionEvent; + +/** + * Mouse button event structure (event.button.*) + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_MouseButtonEvent +{ + SDL_EventType type; /**< SDL_EVENT_MOUSE_BUTTON_DOWN or SDL_EVENT_MOUSE_BUTTON_UP */ + Uint32 reserved; + Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ + SDL_WindowID windowID; /**< The window with mouse focus, if any */ + SDL_MouseID which; /**< The mouse instance id in relative mode, SDL_TOUCH_MOUSEID for touch events, or 0 */ + Uint8 button; /**< The mouse button index */ + bool down; /**< true if the button is pressed */ + Uint8 clicks; /**< 1 for single-click, 2 for double-click, etc. */ + Uint8 padding; + float x; /**< X coordinate, relative to window */ + float y; /**< Y coordinate, relative to window */ +} SDL_MouseButtonEvent; + +/** + * Mouse wheel event structure (event.wheel.*) + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_MouseWheelEvent +{ + SDL_EventType type; /**< SDL_EVENT_MOUSE_WHEEL */ + Uint32 reserved; + Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ + SDL_WindowID windowID; /**< The window with mouse focus, if any */ + SDL_MouseID which; /**< The mouse instance id in relative mode or 0 */ + float x; /**< The amount scrolled horizontally, positive to the right and negative to the left */ + float y; /**< The amount scrolled vertically, positive away from the user and negative toward the user */ + SDL_MouseWheelDirection direction; /**< Set to one of the SDL_MOUSEWHEEL_* defines. When FLIPPED the values in X and Y will be opposite. Multiply by -1 to change them back */ + float mouse_x; /**< X coordinate, relative to window */ + float mouse_y; /**< Y coordinate, relative to window */ + Sint32 integer_x; /**< The amount scrolled horizontally, accumulated to whole scroll "ticks" (added in 3.2.12) */ + Sint32 integer_y; /**< The amount scrolled vertically, accumulated to whole scroll "ticks" (added in 3.2.12) */ +} SDL_MouseWheelEvent; + +/** + * Joystick axis motion event structure (event.jaxis.*) + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_JoyAxisEvent +{ + SDL_EventType type; /**< SDL_EVENT_JOYSTICK_AXIS_MOTION */ + Uint32 reserved; + Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ + SDL_JoystickID which; /**< The joystick instance id */ + Uint8 axis; /**< The joystick axis index */ + Uint8 padding1; + Uint8 padding2; + Uint8 padding3; + Sint16 value; /**< The axis value (range: -32768 to 32767) */ + Uint16 padding4; +} SDL_JoyAxisEvent; + +/** + * Joystick trackball motion event structure (event.jball.*) + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_JoyBallEvent +{ + SDL_EventType type; /**< SDL_EVENT_JOYSTICK_BALL_MOTION */ + Uint32 reserved; + Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ + SDL_JoystickID which; /**< The joystick instance id */ + Uint8 ball; /**< The joystick trackball index */ + Uint8 padding1; + Uint8 padding2; + Uint8 padding3; + Sint16 xrel; /**< The relative motion in the X direction */ + Sint16 yrel; /**< The relative motion in the Y direction */ +} SDL_JoyBallEvent; + +/** + * Joystick hat position change event structure (event.jhat.*) + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_JoyHatEvent +{ + SDL_EventType type; /**< SDL_EVENT_JOYSTICK_HAT_MOTION */ + Uint32 reserved; + Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ + SDL_JoystickID which; /**< The joystick instance id */ + Uint8 hat; /**< The joystick hat index */ + Uint8 value; /**< The hat position value. + * \sa SDL_HAT_LEFTUP SDL_HAT_UP SDL_HAT_RIGHTUP + * \sa SDL_HAT_LEFT SDL_HAT_CENTERED SDL_HAT_RIGHT + * \sa SDL_HAT_LEFTDOWN SDL_HAT_DOWN SDL_HAT_RIGHTDOWN + * + * Note that zero means the POV is centered. + */ + Uint8 padding1; + Uint8 padding2; +} SDL_JoyHatEvent; + +/** + * Joystick button event structure (event.jbutton.*) + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_JoyButtonEvent +{ + SDL_EventType type; /**< SDL_EVENT_JOYSTICK_BUTTON_DOWN or SDL_EVENT_JOYSTICK_BUTTON_UP */ + Uint32 reserved; + Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ + SDL_JoystickID which; /**< The joystick instance id */ + Uint8 button; /**< The joystick button index */ + bool down; /**< true if the button is pressed */ + Uint8 padding1; + Uint8 padding2; +} SDL_JoyButtonEvent; + +/** + * Joystick device event structure (event.jdevice.*) + * + * SDL will send JOYSTICK_ADDED events for devices that are already plugged in + * during SDL_Init. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_GamepadDeviceEvent + */ +typedef struct SDL_JoyDeviceEvent +{ + SDL_EventType type; /**< SDL_EVENT_JOYSTICK_ADDED or SDL_EVENT_JOYSTICK_REMOVED or SDL_EVENT_JOYSTICK_UPDATE_COMPLETE */ + Uint32 reserved; + Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ + SDL_JoystickID which; /**< The joystick instance id */ +} SDL_JoyDeviceEvent; + +/** + * Joystick battery level change event structure (event.jbattery.*) + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_JoyBatteryEvent +{ + SDL_EventType type; /**< SDL_EVENT_JOYSTICK_BATTERY_UPDATED */ + Uint32 reserved; + Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ + SDL_JoystickID which; /**< The joystick instance id */ + SDL_PowerState state; /**< The joystick battery state */ + int percent; /**< The joystick battery percent charge remaining */ +} SDL_JoyBatteryEvent; + +/** + * Gamepad axis motion event structure (event.gaxis.*) + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_GamepadAxisEvent +{ + SDL_EventType type; /**< SDL_EVENT_GAMEPAD_AXIS_MOTION */ + Uint32 reserved; + Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ + SDL_JoystickID which; /**< The joystick instance id */ + Uint8 axis; /**< The gamepad axis (SDL_GamepadAxis) */ + Uint8 padding1; + Uint8 padding2; + Uint8 padding3; + Sint16 value; /**< The axis value (range: -32768 to 32767) */ + Uint16 padding4; +} SDL_GamepadAxisEvent; + + +/** + * Gamepad button event structure (event.gbutton.*) + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_GamepadButtonEvent +{ + SDL_EventType type; /**< SDL_EVENT_GAMEPAD_BUTTON_DOWN or SDL_EVENT_GAMEPAD_BUTTON_UP */ + Uint32 reserved; + Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ + SDL_JoystickID which; /**< The joystick instance id */ + Uint8 button; /**< The gamepad button (SDL_GamepadButton) */ + bool down; /**< true if the button is pressed */ + Uint8 padding1; + Uint8 padding2; +} SDL_GamepadButtonEvent; + + +/** + * Gamepad device event structure (event.gdevice.*) + * + * Joysticks that are supported gamepads receive both an SDL_JoyDeviceEvent + * and an SDL_GamepadDeviceEvent. + * + * SDL will send GAMEPAD_ADDED events for joysticks that are already plugged + * in during SDL_Init() and are recognized as gamepads. It will also send + * events for joysticks that get gamepad mappings at runtime. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_JoyDeviceEvent + */ +typedef struct SDL_GamepadDeviceEvent +{ + SDL_EventType type; /**< SDL_EVENT_GAMEPAD_ADDED, SDL_EVENT_GAMEPAD_REMOVED, or SDL_EVENT_GAMEPAD_REMAPPED, SDL_EVENT_GAMEPAD_UPDATE_COMPLETE or SDL_EVENT_GAMEPAD_STEAM_HANDLE_UPDATED */ + Uint32 reserved; + Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ + SDL_JoystickID which; /**< The joystick instance id */ +} SDL_GamepadDeviceEvent; + +/** + * Gamepad touchpad event structure (event.gtouchpad.*) + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_GamepadTouchpadEvent +{ + SDL_EventType type; /**< SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN or SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION or SDL_EVENT_GAMEPAD_TOUCHPAD_UP */ + Uint32 reserved; + Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ + SDL_JoystickID which; /**< The joystick instance id */ + Sint32 touchpad; /**< The index of the touchpad */ + Sint32 finger; /**< The index of the finger on the touchpad */ + float x; /**< Normalized in the range 0...1 with 0 being on the left */ + float y; /**< Normalized in the range 0...1 with 0 being at the top */ + float pressure; /**< Normalized in the range 0...1 */ +} SDL_GamepadTouchpadEvent; + +/** + * Gamepad sensor event structure (event.gsensor.*) + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_GamepadSensorEvent +{ + SDL_EventType type; /**< SDL_EVENT_GAMEPAD_SENSOR_UPDATE */ + Uint32 reserved; + Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ + SDL_JoystickID which; /**< The joystick instance id */ + Sint32 sensor; /**< The type of the sensor, one of the values of SDL_SensorType */ + float data[3]; /**< Up to 3 values from the sensor, as defined in SDL_sensor.h */ + Uint64 sensor_timestamp; /**< The timestamp of the sensor reading in nanoseconds, not necessarily synchronized with the system clock */ +} SDL_GamepadSensorEvent; + +/** + * Audio device event structure (event.adevice.*) + * + * Note that SDL will send a SDL_EVENT_AUDIO_DEVICE_ADDED event for every + * device it discovers during initialization. After that, this event will only + * arrive when a device is hotplugged during the program's run. + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_AudioDeviceEvent +{ + SDL_EventType type; /**< SDL_EVENT_AUDIO_DEVICE_ADDED, or SDL_EVENT_AUDIO_DEVICE_REMOVED, or SDL_EVENT_AUDIO_DEVICE_FORMAT_CHANGED */ + Uint32 reserved; + Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ + SDL_AudioDeviceID which; /**< SDL_AudioDeviceID for the device being added or removed or changing */ + bool recording; /**< false if a playback device, true if a recording device. */ + Uint8 padding1; + Uint8 padding2; + Uint8 padding3; +} SDL_AudioDeviceEvent; + +/** + * Camera device event structure (event.cdevice.*) + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_CameraDeviceEvent +{ + SDL_EventType type; /**< SDL_EVENT_CAMERA_DEVICE_ADDED, SDL_EVENT_CAMERA_DEVICE_REMOVED, SDL_EVENT_CAMERA_DEVICE_APPROVED, SDL_EVENT_CAMERA_DEVICE_DENIED */ + Uint32 reserved; + Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ + SDL_CameraID which; /**< SDL_CameraID for the device being added or removed or changing */ +} SDL_CameraDeviceEvent; + + +/** + * Renderer event structure (event.render.*) + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_RenderEvent +{ + SDL_EventType type; /**< SDL_EVENT_RENDER_TARGETS_RESET, SDL_EVENT_RENDER_DEVICE_RESET, SDL_EVENT_RENDER_DEVICE_LOST */ + Uint32 reserved; + Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ + SDL_WindowID windowID; /**< The window containing the renderer in question. */ +} SDL_RenderEvent; + + +/** + * Touch finger event structure (event.tfinger.*) + * + * Coordinates in this event are normalized. `x` and `y` are normalized to a + * range between 0.0f and 1.0f, relative to the window, so (0,0) is the top + * left and (1,1) is the bottom right. Delta coordinates `dx` and `dy` are + * normalized in the ranges of -1.0f (traversed all the way from the bottom or + * right to all the way up or left) to 1.0f (traversed all the way from the + * top or left to all the way down or right). + * + * Note that while the coordinates are _normalized_, they are not _clamped_, + * which means in some circumstances you can get a value outside of this + * range. For example, a renderer using logical presentation might give a + * negative value when the touch is in the letterboxing. Some platforms might + * report a touch outside of the window, which will also be outside of the + * range. + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_TouchFingerEvent +{ + SDL_EventType type; /**< SDL_EVENT_FINGER_DOWN, SDL_EVENT_FINGER_UP, SDL_EVENT_FINGER_MOTION, or SDL_EVENT_FINGER_CANCELED */ + Uint32 reserved; + Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ + SDL_TouchID touchID; /**< The touch device id */ + SDL_FingerID fingerID; + float x; /**< Normalized in the range 0...1 */ + float y; /**< Normalized in the range 0...1 */ + float dx; /**< Normalized in the range -1...1 */ + float dy; /**< Normalized in the range -1...1 */ + float pressure; /**< Normalized in the range 0...1 */ + SDL_WindowID windowID; /**< The window underneath the finger, if any */ +} SDL_TouchFingerEvent; + +/** + * Pinch event structure (event.pinch.*) + */ +typedef struct SDL_PinchFingerEvent +{ + SDL_EventType type; /**< ::SDL_EVENT_PINCH_BEGIN or ::SDL_EVENT_PINCH_UPDATE or ::SDL_EVENT_PINCH_END */ + Uint32 reserved; + Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ + float scale; /**< The scale change since the last SDL_EVENT_PINCH_UPDATE. Scale < 1 is "zoom out". Scale > 1 is "zoom in". */ + SDL_WindowID windowID; /**< The window underneath the finger, if any */ +} SDL_PinchFingerEvent; + +/** + * Pressure-sensitive pen proximity event structure (event.pproximity.*) + * + * When a pen becomes visible to the system (it is close enough to a tablet, + * etc), SDL will send an SDL_EVENT_PEN_PROXIMITY_IN event with the new pen's + * ID. This ID is valid until the pen leaves proximity again (has been removed + * from the tablet's area, the tablet has been unplugged, etc). If the same + * pen reenters proximity again, it will be given a new ID. + * + * Note that "proximity" means "close enough for the tablet to know the tool + * is there." The pen touching and lifting off from the tablet while not + * leaving the area are handled by SDL_EVENT_PEN_DOWN and SDL_EVENT_PEN_UP. + * + * Not all platforms have a window associated with the pen during proximity + * events. Some wait until motion/button/etc events to offer this info. + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_PenProximityEvent +{ + SDL_EventType type; /**< SDL_EVENT_PEN_PROXIMITY_IN or SDL_EVENT_PEN_PROXIMITY_OUT */ + Uint32 reserved; + Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ + SDL_WindowID windowID; /**< The window with pen focus, if any */ + SDL_PenID which; /**< The pen instance id */ +} SDL_PenProximityEvent; + +/** + * Pressure-sensitive pen motion event structure (event.pmotion.*) + * + * Depending on the hardware, you may get motion events when the pen is not + * touching a tablet, for tracking a pen even when it isn't drawing. You + * should listen for SDL_EVENT_PEN_DOWN and SDL_EVENT_PEN_UP events, or check + * `pen_state & SDL_PEN_INPUT_DOWN` to decide if a pen is "drawing" when + * dealing with pen motion. + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_PenMotionEvent +{ + SDL_EventType type; /**< SDL_EVENT_PEN_MOTION */ + Uint32 reserved; + Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ + SDL_WindowID windowID; /**< The window with pen focus, if any */ + SDL_PenID which; /**< The pen instance id */ + SDL_PenInputFlags pen_state; /**< Complete pen input state at time of event */ + float x; /**< X coordinate, relative to window */ + float y; /**< Y coordinate, relative to window */ +} SDL_PenMotionEvent; + +/** + * Pressure-sensitive pen touched event structure (event.ptouch.*) + * + * These events come when a pen touches a surface (a tablet, etc), or lifts + * off from one. + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_PenTouchEvent +{ + SDL_EventType type; /**< SDL_EVENT_PEN_DOWN or SDL_EVENT_PEN_UP */ + Uint32 reserved; + Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ + SDL_WindowID windowID; /**< The window with pen focus, if any */ + SDL_PenID which; /**< The pen instance id */ + SDL_PenInputFlags pen_state; /**< Complete pen input state at time of event */ + float x; /**< X coordinate, relative to window */ + float y; /**< Y coordinate, relative to window */ + bool eraser; /**< true if eraser end is used (not all pens support this). */ + bool down; /**< true if the pen is touching or false if the pen is lifted off */ +} SDL_PenTouchEvent; + +/** + * Pressure-sensitive pen button event structure (event.pbutton.*) + * + * This is for buttons on the pen itself that the user might click. The pen + * itself pressing down to draw triggers a SDL_EVENT_PEN_DOWN event instead. + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_PenButtonEvent +{ + SDL_EventType type; /**< SDL_EVENT_PEN_BUTTON_DOWN or SDL_EVENT_PEN_BUTTON_UP */ + Uint32 reserved; + Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ + SDL_WindowID windowID; /**< The window with mouse focus, if any */ + SDL_PenID which; /**< The pen instance id */ + SDL_PenInputFlags pen_state; /**< Complete pen input state at time of event */ + float x; /**< X coordinate, relative to window */ + float y; /**< Y coordinate, relative to window */ + Uint8 button; /**< The pen button index (first button is 1). */ + bool down; /**< true if the button is pressed */ +} SDL_PenButtonEvent; + +/** + * Pressure-sensitive pen pressure / angle event structure (event.paxis.*) + * + * You might get some of these events even if the pen isn't touching the + * tablet. + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_PenAxisEvent +{ + SDL_EventType type; /**< SDL_EVENT_PEN_AXIS */ + Uint32 reserved; + Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ + SDL_WindowID windowID; /**< The window with pen focus, if any */ + SDL_PenID which; /**< The pen instance id */ + SDL_PenInputFlags pen_state; /**< Complete pen input state at time of event */ + float x; /**< X coordinate, relative to window */ + float y; /**< Y coordinate, relative to window */ + SDL_PenAxis axis; /**< Axis that has changed */ + float value; /**< New value of axis */ +} SDL_PenAxisEvent; + +/** + * An event used to drop text or request a file open by the system + * (event.drop.*) + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_DropEvent +{ + SDL_EventType type; /**< SDL_EVENT_DROP_BEGIN or SDL_EVENT_DROP_FILE or SDL_EVENT_DROP_TEXT or SDL_EVENT_DROP_COMPLETE or SDL_EVENT_DROP_POSITION */ + Uint32 reserved; + Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ + SDL_WindowID windowID; /**< The window that was dropped on, if any */ + float x; /**< X coordinate, relative to window (not on begin) */ + float y; /**< Y coordinate, relative to window (not on begin) */ + const char *source; /**< The source app that sent this drop event, or NULL if that isn't available */ + const char *data; /**< The text for SDL_EVENT_DROP_TEXT and the file name for SDL_EVENT_DROP_FILE, NULL for other events */ +} SDL_DropEvent; + +/** + * An event triggered when the clipboard contents have changed + * (event.clipboard.*) + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_ClipboardEvent +{ + SDL_EventType type; /**< SDL_EVENT_CLIPBOARD_UPDATE */ + Uint32 reserved; + Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ + bool owner; /**< are we owning the clipboard (internal update) */ + Sint32 num_mime_types; /**< number of mime types */ + const char **mime_types; /**< current mime types */ +} SDL_ClipboardEvent; + +/** + * Sensor event structure (event.sensor.*) + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_SensorEvent +{ + SDL_EventType type; /**< SDL_EVENT_SENSOR_UPDATE */ + Uint32 reserved; + Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ + SDL_SensorID which; /**< The instance ID of the sensor */ + float data[6]; /**< Up to 6 values from the sensor - additional values can be queried using SDL_GetSensorData() */ + Uint64 sensor_timestamp; /**< The timestamp of the sensor reading in nanoseconds, not necessarily synchronized with the system clock */ +} SDL_SensorEvent; + +/** + * The "quit requested" event + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_QuitEvent +{ + SDL_EventType type; /**< SDL_EVENT_QUIT */ + Uint32 reserved; + Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ +} SDL_QuitEvent; + +/** + * A user-defined event type (event.user.*) + * + * This event is unique; it is never created by SDL, but only by the + * application. The event can be pushed onto the event queue using + * SDL_PushEvent(). The contents of the structure members are completely up to + * the programmer; the only requirement is that '''type''' is a value obtained + * from SDL_RegisterEvents(). + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_UserEvent +{ + Uint32 type; /**< SDL_EVENT_USER through SDL_EVENT_LAST, Uint32 because these are not in the SDL_EventType enumeration */ + Uint32 reserved; + Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ + SDL_WindowID windowID; /**< The associated window if any */ + Sint32 code; /**< User defined event code */ + void *data1; /**< User defined data pointer */ + void *data2; /**< User defined data pointer */ +} SDL_UserEvent; + + +/** + * The structure for all events in SDL. + * + * The SDL_Event structure is the core of all event handling in SDL. SDL_Event + * is a union of all event structures used in SDL. + * + * \since This struct is available since SDL 3.2.0. + */ +typedef union SDL_Event +{ + Uint32 type; /**< Event type, shared with all events, Uint32 to cover user events which are not in the SDL_EventType enumeration */ + SDL_CommonEvent common; /**< Common event data */ + SDL_DisplayEvent display; /**< Display event data */ + SDL_WindowEvent window; /**< Window event data */ + SDL_KeyboardDeviceEvent kdevice; /**< Keyboard device change event data */ + SDL_KeyboardEvent key; /**< Keyboard event data */ + SDL_TextEditingEvent edit; /**< Text editing event data */ + SDL_TextEditingCandidatesEvent edit_candidates; /**< Text editing candidates event data */ + SDL_TextInputEvent text; /**< Text input event data */ + SDL_MouseDeviceEvent mdevice; /**< Mouse device change event data */ + SDL_MouseMotionEvent motion; /**< Mouse motion event data */ + SDL_MouseButtonEvent button; /**< Mouse button event data */ + SDL_MouseWheelEvent wheel; /**< Mouse wheel event data */ + SDL_JoyDeviceEvent jdevice; /**< Joystick device change event data */ + SDL_JoyAxisEvent jaxis; /**< Joystick axis event data */ + SDL_JoyBallEvent jball; /**< Joystick ball event data */ + SDL_JoyHatEvent jhat; /**< Joystick hat event data */ + SDL_JoyButtonEvent jbutton; /**< Joystick button event data */ + SDL_JoyBatteryEvent jbattery; /**< Joystick battery event data */ + SDL_GamepadDeviceEvent gdevice; /**< Gamepad device event data */ + SDL_GamepadAxisEvent gaxis; /**< Gamepad axis event data */ + SDL_GamepadButtonEvent gbutton; /**< Gamepad button event data */ + SDL_GamepadTouchpadEvent gtouchpad; /**< Gamepad touchpad event data */ + SDL_GamepadSensorEvent gsensor; /**< Gamepad sensor event data */ + SDL_AudioDeviceEvent adevice; /**< Audio device event data */ + SDL_CameraDeviceEvent cdevice; /**< Camera device event data */ + SDL_SensorEvent sensor; /**< Sensor event data */ + SDL_QuitEvent quit; /**< Quit request event data */ + SDL_UserEvent user; /**< Custom event data */ + SDL_TouchFingerEvent tfinger; /**< Touch finger event data */ + SDL_PinchFingerEvent pinch; /**< Pinch event data */ + SDL_PenProximityEvent pproximity; /**< Pen proximity event data */ + SDL_PenTouchEvent ptouch; /**< Pen tip touching event data */ + SDL_PenMotionEvent pmotion; /**< Pen motion event data */ + SDL_PenButtonEvent pbutton; /**< Pen button event data */ + SDL_PenAxisEvent paxis; /**< Pen axis event data */ + SDL_RenderEvent render; /**< Render event data */ + SDL_DropEvent drop; /**< Drag and drop event data */ + SDL_ClipboardEvent clipboard; /**< Clipboard event data */ + + /* This is necessary for ABI compatibility between Visual C++ and GCC. + Visual C++ will respect the push pack pragma and use 52 bytes (size of + SDL_TextEditingEvent, the largest structure for 32-bit and 64-bit + architectures) for this union, and GCC will use the alignment of the + largest datatype within the union, which is 8 bytes on 64-bit + architectures. + + So... we'll add padding to force the size to be the same for both. + + On architectures where pointers are 16 bytes, this needs rounding up to + the next multiple of 16, 64, and on architectures where pointers are + even larger the size of SDL_UserEvent will dominate as being 3 pointers. + */ + Uint8 padding[128]; +} SDL_Event; + +/* Make sure we haven't broken binary compatibility */ +SDL_COMPILE_TIME_ASSERT(SDL_Event, sizeof(SDL_Event) == sizeof((SDL_static_cast(SDL_Event *, NULL))->padding)); + + +/* Function prototypes */ + +/** + * Pump the event loop, gathering events from the input devices. + * + * This function updates the event queue and internal input device state. + * + * SDL_PumpEvents() gathers all the pending input information from devices and + * places it in the event queue. Without calls to SDL_PumpEvents() no events + * would ever be placed on the queue. Often the need for calls to + * SDL_PumpEvents() is hidden from the user since SDL_PollEvent() and + * SDL_WaitEvent() implicitly call SDL_PumpEvents(). However, if you are not + * polling or waiting for events (e.g. you are filtering them), then you must + * call SDL_PumpEvents() to force an event queue update. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_PollEvent + * \sa SDL_WaitEvent + */ +extern SDL_DECLSPEC void SDLCALL SDL_PumpEvents(void); + +/* @{ */ + +/** + * The type of action to request from SDL_PeepEvents(). + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_EventAction +{ + SDL_ADDEVENT, /**< Add events to the back of the queue. */ + SDL_PEEKEVENT, /**< Check but don't remove events from the queue front. */ + SDL_GETEVENT /**< Retrieve/remove events from the front of the queue. */ +} SDL_EventAction; + +/** + * Check the event queue for messages and optionally return them. + * + * `action` may be any of the following: + * + * - `SDL_ADDEVENT`: up to `numevents` events will be added to the back of the + * event queue. + * - `SDL_PEEKEVENT`: `numevents` events at the front of the event queue, + * within the specified minimum and maximum type, will be returned to the + * caller and will _not_ be removed from the queue. If you pass NULL for + * `events`, then `numevents` is ignored and the total number of matching + * events will be returned. + * - `SDL_GETEVENT`: up to `numevents` events at the front of the event queue, + * within the specified minimum and maximum type, will be returned to the + * caller and will be removed from the queue. + * + * You may have to call SDL_PumpEvents() before calling this function. + * Otherwise, the events may not be ready to be filtered when you call + * SDL_PeepEvents(). + * + * \param events destination buffer for the retrieved events, may be NULL to + * leave the events in the queue and return the number of events + * that would have been stored. + * \param numevents if action is SDL_ADDEVENT, the number of events to add + * back to the event queue; if action is SDL_PEEKEVENT or + * SDL_GETEVENT, the maximum number of events to retrieve. + * \param action action to take; see [Remarks](#remarks) for details. + * \param minType minimum value of the event type to be considered; + * SDL_EVENT_FIRST is a safe choice. + * \param maxType maximum value of the event type to be considered; + * SDL_EVENT_LAST is a safe choice. + * \returns the number of events actually stored or -1 on failure; call + * SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_PollEvent + * \sa SDL_PumpEvents + * \sa SDL_PushEvent + */ +extern SDL_DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event *events, int numevents, SDL_EventAction action, Uint32 minType, Uint32 maxType); +/* @} */ + +/** + * Check for the existence of a certain event type in the event queue. + * + * If you need to check for a range of event types, use SDL_HasEvents() + * instead. + * + * \param type the type of event to be queried; see SDL_EventType for details. + * \returns true if events matching `type` are present, or false if events + * matching `type` are not present. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_HasEvents + */ +extern SDL_DECLSPEC bool SDLCALL SDL_HasEvent(Uint32 type); + + +/** + * Check for the existence of certain event types in the event queue. + * + * If you need to check for a single event type, use SDL_HasEvent() instead. + * + * \param minType the low end of event type to be queried, inclusive; see + * SDL_EventType for details. + * \param maxType the high end of event type to be queried, inclusive; see + * SDL_EventType for details. + * \returns true if events with type >= `minType` and <= `maxType` are + * present, or false if not. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_HasEvents + */ +extern SDL_DECLSPEC bool SDLCALL SDL_HasEvents(Uint32 minType, Uint32 maxType); + +/** + * Clear events of a specific type from the event queue. + * + * This will unconditionally remove any events from the queue that match + * `type`. If you need to remove a range of event types, use SDL_FlushEvents() + * instead. + * + * It's also normal to just ignore events you don't care about in your event + * loop without calling this function. + * + * This function only affects currently queued events. If you want to make + * sure that all pending OS events are flushed, you can call SDL_PumpEvents() + * on the main thread immediately before the flush call. + * + * If you have user events with custom data that needs to be freed, you should + * use SDL_PeepEvents() to remove and clean up those events before calling + * this function. + * + * \param type the type of event to be cleared; see SDL_EventType for details. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_FlushEvents + */ +extern SDL_DECLSPEC void SDLCALL SDL_FlushEvent(Uint32 type); + +/** + * Clear events of a range of types from the event queue. + * + * This will unconditionally remove any events from the queue that are in the + * range of `minType` to `maxType`, inclusive. If you need to remove a single + * event type, use SDL_FlushEvent() instead. + * + * It's also normal to just ignore events you don't care about in your event + * loop without calling this function. + * + * This function only affects currently queued events. If you want to make + * sure that all pending OS events are flushed, you can call SDL_PumpEvents() + * on the main thread immediately before the flush call. + * + * \param minType the low end of event type to be cleared, inclusive; see + * SDL_EventType for details. + * \param maxType the high end of event type to be cleared, inclusive; see + * SDL_EventType for details. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_FlushEvent + */ +extern SDL_DECLSPEC void SDLCALL SDL_FlushEvents(Uint32 minType, Uint32 maxType); + +/** + * Poll for currently pending events. + * + * If `event` is not NULL, the next event is removed from the queue and stored + * in the SDL_Event structure pointed to by `event`. The 1 returned refers to + * this event, immediately stored in the SDL Event structure -- not an event + * to follow. + * + * If `event` is NULL, it simply returns 1 if there is an event in the queue, + * but will not remove it from the queue. + * + * As this function may implicitly call SDL_PumpEvents(), you can only call + * this function in the thread that set the video mode. + * + * SDL_PollEvent() is the favored way of receiving system events since it can + * be done from the main loop and does not suspend the main loop while waiting + * on an event to be posted. + * + * The common practice is to fully process the event queue once every frame, + * usually as a first step before updating the game's state: + * + * ```c + * while (game_is_still_running) { + * SDL_Event event; + * while (SDL_PollEvent(&event)) { // poll until all events are handled! + * // decide what to do with this event. + * } + * + * // update game state, draw the current frame + * } + * ``` + * + * Note that Windows (and possibly other platforms) has a quirk about how it + * handles events while dragging/resizing a window, which can cause this + * function to block for significant amounts of time. Technical explanations + * and solutions are discussed on the wiki: + * + * https://wiki.libsdl.org/SDL3/AppFreezeDuringDrag + * + * \param event the SDL_Event structure to be filled with the next event from + * the queue, or NULL. + * \returns true if this got an event or false if there are none available. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_PushEvent + * \sa SDL_WaitEvent + * \sa SDL_WaitEventTimeout + */ +extern SDL_DECLSPEC bool SDLCALL SDL_PollEvent(SDL_Event *event); + +/** + * Wait indefinitely for the next available event. + * + * If `event` is not NULL, the next event is removed from the queue and stored + * in the SDL_Event structure pointed to by `event`. + * + * As this function may implicitly call SDL_PumpEvents(), you can only call + * this function in the thread that initialized the video subsystem. + * + * \param event the SDL_Event structure to be filled in with the next event + * from the queue, or NULL. + * \returns true on success or false if there was an error while waiting for + * events; call SDL_GetError() for more information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_PollEvent + * \sa SDL_PushEvent + * \sa SDL_WaitEventTimeout + */ +extern SDL_DECLSPEC bool SDLCALL SDL_WaitEvent(SDL_Event *event); + +/** + * Wait until the specified timeout (in milliseconds) for the next available + * event. + * + * If `event` is not NULL, the next event is removed from the queue and stored + * in the SDL_Event structure pointed to by `event`. + * + * As this function may implicitly call SDL_PumpEvents(), you can only call + * this function in the thread that initialized the video subsystem. + * + * The timeout is not guaranteed, the actual wait time could be longer due to + * system scheduling. + * + * \param event the SDL_Event structure to be filled in with the next event + * from the queue, or NULL. + * \param timeoutMS the maximum number of milliseconds to wait for the next + * available event. + * \returns true if this got an event or false if the timeout elapsed without + * any events available. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_PollEvent + * \sa SDL_PushEvent + * \sa SDL_WaitEvent + */ +extern SDL_DECLSPEC bool SDLCALL SDL_WaitEventTimeout(SDL_Event *event, Sint32 timeoutMS); + +/** + * Add an event to the event queue. + * + * The event queue can actually be used as a two way communication channel. + * Not only can events be read from the queue, but the user can also push + * their own events onto it. `event` is a pointer to the event structure you + * wish to push onto the queue. The event is copied into the queue, and the + * caller may dispose of the memory pointed to after SDL_PushEvent() returns. + * + * Note: Pushing device input events onto the queue doesn't modify the state + * of the device within SDL. + * + * Note: Events pushed onto the queue with SDL_PushEvent() get passed through + * the event filter but events added with SDL_PeepEvents() do not. + * + * For pushing application-specific events, please use SDL_RegisterEvents() to + * get an event type that does not conflict with other code that also wants + * its own custom event types. + * + * \param event the SDL_Event to be added to the queue. + * \returns true on success, false if the event was filtered or on failure; + * call SDL_GetError() for more information. A common reason for + * error is the event queue being full. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_PeepEvents + * \sa SDL_PollEvent + * \sa SDL_RegisterEvents + */ +extern SDL_DECLSPEC bool SDLCALL SDL_PushEvent(SDL_Event *event); + +/** + * A function pointer used for callbacks that watch the event queue. + * + * \param userdata what was passed as `userdata` to SDL_SetEventFilter() or + * SDL_AddEventWatch, etc. + * \param event the event that triggered the callback. + * \returns true to permit event to be added to the queue, and false to + * disallow it. When used with SDL_AddEventWatch, the return value is + * ignored. + * + * \threadsafety SDL may call this callback at any time from any thread; the + * application is responsible for locking resources the callback + * touches that need to be protected. + * + * \since This datatype is available since SDL 3.2.0. + * + * \sa SDL_SetEventFilter + * \sa SDL_AddEventWatch + */ +typedef bool (SDLCALL *SDL_EventFilter)(void *userdata, SDL_Event *event); + +/** + * Set up a filter to process all events before they are added to the internal + * event queue. + * + * If you just want to see events without modifying them or preventing them + * from being queued, you should use SDL_AddEventWatch() instead. + * + * If the filter function returns true when called, then the event will be + * added to the internal queue. If it returns false, then the event will be + * dropped from the queue, but the internal state will still be updated. This + * allows selective filtering of dynamically arriving events. + * + * **WARNING**: Be very careful of what you do in the event filter function, + * as it may run in a different thread! The exception is handling of + * SDL_EVENT_WINDOW_EXPOSED, which is guaranteed to be sent from the OS on the + * main thread and you are expected to redraw your window in response to this + * event. + * + * On platforms that support it, if the quit event is generated by an + * interrupt signal (e.g. pressing Ctrl-C), it will be delivered to the + * application at the next event poll. + * + * Note: Disabled events never make it to the event filter function; see + * SDL_SetEventEnabled(). + * + * Note: Events pushed onto the queue with SDL_PushEvent() get passed through + * the event filter, but events pushed onto the queue with SDL_PeepEvents() do + * not. + * + * \param filter a function to call when an event happens. + * \param userdata a pointer that is passed to `filter`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_AddEventWatch + * \sa SDL_SetEventEnabled + * \sa SDL_GetEventFilter + * \sa SDL_PeepEvents + * \sa SDL_PushEvent + */ +extern SDL_DECLSPEC void SDLCALL SDL_SetEventFilter(SDL_EventFilter filter, void *userdata); + +/** + * Query the current event filter. + * + * This function can be used to "chain" filters, by saving the existing filter + * before replacing it with a function that will call that saved filter. + * + * \param filter the current callback function will be stored here. + * \param userdata the pointer that is passed to the current event filter will + * be stored here. + * \returns true on success or false if there is no event filter set. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetEventFilter + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetEventFilter(SDL_EventFilter *filter, void **userdata); + +/** + * Add a callback to be triggered when an event is added to the event queue. + * + * `filter` will be called when an event happens, and its return value is + * ignored. + * + * **WARNING**: Be very careful of what you do in the event filter function, + * as it may run in a different thread! + * + * If the quit event is generated by a signal (e.g. SIGINT), it will bypass + * the internal queue and be delivered to the watch callback immediately, and + * arrive at the next event poll. + * + * Note: the callback is called for events posted by the user through + * SDL_PushEvent(), but not for disabled events, nor for events by a filter + * callback set with SDL_SetEventFilter(), nor for events posted by the user + * through SDL_PeepEvents(). + * + * \param filter an SDL_EventFilter function to call when an event happens. + * \param userdata a pointer that is passed to `filter`. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_RemoveEventWatch + * \sa SDL_SetEventFilter + */ +extern SDL_DECLSPEC bool SDLCALL SDL_AddEventWatch(SDL_EventFilter filter, void *userdata); + +/** + * Remove an event watch callback added with SDL_AddEventWatch(). + * + * This function takes the same input as SDL_AddEventWatch() to identify and + * delete the corresponding callback. + * + * \param filter the function originally passed to SDL_AddEventWatch(). + * \param userdata the pointer originally passed to SDL_AddEventWatch(). + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_AddEventWatch + */ +extern SDL_DECLSPEC void SDLCALL SDL_RemoveEventWatch(SDL_EventFilter filter, void *userdata); + +/** + * Run a specific filter function on the current event queue, removing any + * events for which the filter returns false. + * + * See SDL_SetEventFilter() for more information. Unlike SDL_SetEventFilter(), + * this function does not change the filter permanently, it only uses the + * supplied filter until this function returns. + * + * \param filter the SDL_EventFilter function to call when an event happens. + * \param userdata a pointer that is passed to `filter`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetEventFilter + * \sa SDL_SetEventFilter + */ +extern SDL_DECLSPEC void SDLCALL SDL_FilterEvents(SDL_EventFilter filter, void *userdata); + +/** + * Set the state of processing events by type. + * + * \param type the type of event; see SDL_EventType for details. + * \param enabled whether to process the event or not. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_EventEnabled + */ +extern SDL_DECLSPEC void SDLCALL SDL_SetEventEnabled(Uint32 type, bool enabled); + +/** + * Query the state of processing events by type. + * + * \param type the type of event; see SDL_EventType for details. + * \returns true if the event is being processed, false otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetEventEnabled + */ +extern SDL_DECLSPEC bool SDLCALL SDL_EventEnabled(Uint32 type); + +/** + * Allocate a set of user-defined events, and return the beginning event + * number for that set of events. + * + * \param numevents the number of events to be allocated. + * \returns the beginning event number, or 0 if numevents is invalid or if + * there are not enough user-defined events left. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_PushEvent + */ +extern SDL_DECLSPEC Uint32 SDLCALL SDL_RegisterEvents(int numevents); + +/** + * Get window associated with an event. + * + * \param event an event containing a `windowID`. + * \returns the associated window on success or NULL if there is none. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_PollEvent + * \sa SDL_WaitEvent + * \sa SDL_WaitEventTimeout + */ +extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetWindowFromEvent(const SDL_Event *event); + +/** + * Generate an English description of an event. + * + * This will fill `buf` with a null-terminated string that might look + * something like this: + * + * ``` + * SDL_EVENT_MOUSE_MOTION (timestamp=1140256324 windowid=2 which=0 state=0 x=492.99 y=139.09 xrel=52 yrel=6) + * ``` + * + * The exact format of the string is not guaranteed; it is intended for + * logging purposes, to be read by a human, and not parsed by a computer. + * + * The returned value follows the same rules as SDL_snprintf(): `buf` will + * always be NULL-terminated (unless `buflen` is zero), and will be truncated + * if `buflen` is too small. The return code is the number of bytes needed for + * the complete string, not counting the NULL-terminator, whether the string + * was truncated or not. Unlike SDL_snprintf(), though, this function never + * returns -1. + * + * \param event an event to describe. May be NULL. + * \param buf the buffer to fill with the description string. May be NULL. + * \param buflen the maximum bytes that can be written to `buf`. + * \returns number of bytes needed for the full string, not counting the + * null-terminator byte. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.4.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_GetEventDescription(const SDL_Event *event, char *buf, int buflen); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_events_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_filesystem.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_filesystem.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,534 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * # CategoryFilesystem + * + * SDL offers an API for examining and manipulating the system's filesystem. + * This covers most things one would need to do with directories, except for + * actual file I/O (which is covered by [CategoryIOStream](CategoryIOStream) + * and [CategoryAsyncIO](CategoryAsyncIO) instead). + * + * There are functions to answer necessary path questions: + * + * - Where is my app's data? SDL_GetBasePath(). + * - Where can I safely write files? SDL_GetPrefPath(). + * - Where are paths like Downloads, Desktop, Music? SDL_GetUserFolder(). + * - What is this thing at this location? SDL_GetPathInfo(). + * - What items live in this folder? SDL_EnumerateDirectory(). + * - What items live in this folder by wildcard? SDL_GlobDirectory(). + * - What is my current working directory? SDL_GetCurrentDirectory(). + * + * SDL also offers functions to manipulate the directory tree: renaming, + * removing, copying files. + */ + +#ifndef SDL_filesystem_h_ +#define SDL_filesystem_h_ + +#include +#include + +#include + +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Get the directory where the application was run from. + * + * SDL caches the result of this call internally, but the first call to this + * function is not necessarily fast, so plan accordingly. + * + * **macOS and iOS Specific Functionality**: If the application is in a ".app" + * bundle, this function returns the Resource directory (e.g. + * MyApp.app/Contents/Resources/). This behaviour can be overridden by adding + * a property to the Info.plist file. Adding a string key with the name + * SDL_FILESYSTEM_BASE_DIR_TYPE with a supported value will change the + * behaviour. + * + * Supported values for the SDL_FILESYSTEM_BASE_DIR_TYPE property (Given an + * application in /Applications/SDLApp/MyApp.app): + * + * - `resource`: bundle resource directory (the default). For example: + * `/Applications/SDLApp/MyApp.app/Contents/Resources` + * - `bundle`: the Bundle directory. For example: + * `/Applications/SDLApp/MyApp.app/` + * - `parent`: the containing directory of the bundle. For example: + * `/Applications/SDLApp/` + * + * **Android Specific Functionality**: This function returns "./", which + * allows filesystem operations to use internal storage and the asset system. + * + * **Nintendo 3DS Specific Functionality**: This function returns "romfs" + * directory of the application as it is uncommon to store resources outside + * the executable. As such it is not a writable directory. + * + * The returned path is guaranteed to end with a path separator ('\\' on + * Windows, '/' on most other platforms). + * + * \returns an absolute path in UTF-8 encoding to the application data + * directory. NULL will be returned on error or when the platform + * doesn't implement this functionality, call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetPrefPath + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetBasePath(void); + +/** + * Get the user-and-app-specific path where files can be written. + * + * Get the "pref dir". This is meant to be where users can write personal + * files (preferences and save games, etc) that are specific to your + * application. This directory is unique per user, per application. + * + * This function will decide the appropriate location in the native + * filesystem, create the directory if necessary, and return a string of the + * absolute path to the directory in UTF-8 encoding. + * + * On Windows, the string might look like: + * + * `C:\\Users\\bob\\AppData\\Roaming\\My Company\\My Program Name\\` + * + * On Linux, the string might look like: + * + * `/home/bob/.local/share/My Program Name/` + * + * On macOS, the string might look like: + * + * `/Users/bob/Library/Application Support/My Program Name/` + * + * You should assume the path returned by this function is the only safe place + * to write files (and that SDL_GetBasePath(), while it might be writable, or + * even the parent of the returned path, isn't where you should be writing + * things). + * + * Both the org and app strings may become part of a directory name, so please + * follow these rules: + * + * - Try to use the same org string (_including case-sensitivity_) for all + * your applications that use this function. + * - Always use a unique app string for each one, and make sure it never + * changes for an app once you've decided on it. + * - Unicode characters are legal, as long as they are UTF-8 encoded, but... + * - ...only use letters, numbers, and spaces. Avoid punctuation like "Game + * Name 2: Bad Guy's Revenge!" ... "Game Name 2" is sufficient. + * + * Due to historical mistakes, `org` is allowed to be NULL or "". In such + * cases, SDL will omit the org subdirectory, including on platforms where it + * shouldn't, and including on platforms where this would make your app fail + * certification for an app store. New apps should definitely specify a real + * string for `org`. + * + * The returned path is guaranteed to end with a path separator ('\\' on + * Windows, '/' on most other platforms). + * + * \param org the name of your organization. + * \param app the name of your application. + * \returns a UTF-8 string of the user directory in platform-dependent + * notation. NULL if there's a problem (creating directory failed, + * etc.). This should be freed with SDL_free() when it is no longer + * needed. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetBasePath + */ +extern SDL_DECLSPEC char * SDLCALL SDL_GetPrefPath(const char *org, const char *app); + +/** + * The type of the OS-provided default folder for a specific purpose. + * + * Note that the Trash folder isn't included here, because trashing files + * usually involves extra OS-specific functionality to remember the file's + * original location. + * + * The folders supported per platform are: + * + * | | Windows | macOS/iOS | tvOS | Unix (XDG) | Haiku | Emscripten | + * | ----------- | ------- | --------- | ---- | ---------- | ----- | ---------- | + * | HOME | X | X | | X | X | X | + * | DESKTOP | X | X | | X | X | | + * | DOCUMENTS | X | X | | X | | | + * | DOWNLOADS | Vista+ | X | | X | | | + * | MUSIC | X | X | | X | | | + * | PICTURES | X | X | | X | | | + * | PUBLICSHARE | | X | | X | | | + * | SAVEDGAMES | Vista+ | | | | | | + * | SCREENSHOTS | Vista+ | | | | | | + * | TEMPLATES | X | X | | X | | | + * | VIDEOS | X | X* | | X | | | + * + * Note that on macOS/iOS, the Videos folder is called "Movies". + * + * \since This enum is available since SDL 3.2.0. + * + * \sa SDL_GetUserFolder + */ +typedef enum SDL_Folder +{ + SDL_FOLDER_HOME, /**< The folder which contains all of the current user's data, preferences, and documents. It usually contains most of the other folders. If a requested folder does not exist, the home folder can be considered a safe fallback to store a user's documents. */ + SDL_FOLDER_DESKTOP, /**< The folder of files that are displayed on the desktop. Note that the existence of a desktop folder does not guarantee that the system does show icons on its desktop; certain GNU/Linux distros with a graphical environment may not have desktop icons. */ + SDL_FOLDER_DOCUMENTS, /**< User document files, possibly application-specific. This is a good place to save a user's projects. */ + SDL_FOLDER_DOWNLOADS, /**< Standard folder for user files downloaded from the internet. */ + SDL_FOLDER_MUSIC, /**< Music files that can be played using a standard music player (mp3, ogg...). */ + SDL_FOLDER_PICTURES, /**< Image files that can be displayed using a standard viewer (png, jpg...). */ + SDL_FOLDER_PUBLICSHARE, /**< Files that are meant to be shared with other users on the same computer. */ + SDL_FOLDER_SAVEDGAMES, /**< Save files for games. */ + SDL_FOLDER_SCREENSHOTS, /**< Application screenshots. */ + SDL_FOLDER_TEMPLATES, /**< Template files to be used when the user requests the desktop environment to create a new file in a certain folder, such as "New Text File.txt". Any file in the Templates folder can be used as a starting point for a new file. */ + SDL_FOLDER_VIDEOS, /**< Video files that can be played using a standard video player (mp4, webm...). */ + SDL_FOLDER_COUNT /**< Total number of types in this enum, not a folder type by itself. */ +} SDL_Folder; + +/** + * Finds the most suitable user folder for a specific purpose. + * + * Many OSes provide certain standard folders for certain purposes, such as + * storing pictures, music or videos for a certain user. This function gives + * the path for many of those special locations. + * + * This function is specifically for _user_ folders, which are meant for the + * user to access and manage. For application-specific folders, meant to hold + * data for the application to manage, see SDL_GetBasePath() and + * SDL_GetPrefPath(). + * + * The returned path is guaranteed to end with a path separator ('\\' on + * Windows, '/' on most other platforms). + * + * If NULL is returned, the error may be obtained with SDL_GetError(). + * + * \param folder the type of folder to find. + * \returns either a null-terminated C string containing the full path to the + * folder, or NULL if an error happened. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetUserFolder(SDL_Folder folder); + + +/* Abstract filesystem interface */ + +/** + * Types of filesystem entries. + * + * Note that there may be other sorts of items on a filesystem: devices, + * symlinks, named pipes, etc. They are currently reported as + * SDL_PATHTYPE_OTHER. + * + * \since This enum is available since SDL 3.2.0. + * + * \sa SDL_PathInfo + */ +typedef enum SDL_PathType +{ + SDL_PATHTYPE_NONE, /**< path does not exist */ + SDL_PATHTYPE_FILE, /**< a normal file */ + SDL_PATHTYPE_DIRECTORY, /**< a directory */ + SDL_PATHTYPE_OTHER /**< something completely different like a device node (not a symlink, those are always followed) */ +} SDL_PathType; + +/** + * Information about a path on the filesystem. + * + * \since This datatype is available since SDL 3.2.0. + * + * \sa SDL_GetPathInfo + * \sa SDL_GetStoragePathInfo + */ +typedef struct SDL_PathInfo +{ + SDL_PathType type; /**< the path type */ + Uint64 size; /**< the file size in bytes */ + SDL_Time create_time; /**< the time when the path was created */ + SDL_Time modify_time; /**< the last time the path was modified */ + SDL_Time access_time; /**< the last time the path was read */ +} SDL_PathInfo; + +/** + * Flags for path matching. + * + * \since This datatype is available since SDL 3.2.0. + * + * \sa SDL_GlobDirectory + * \sa SDL_GlobStorageDirectory + */ +typedef Uint32 SDL_GlobFlags; + +#define SDL_GLOB_CASEINSENSITIVE (1u << 0) + +/** + * Create a directory, and any missing parent directories. + * + * This reports success if `path` already exists as a directory. + * + * If parent directories are missing, it will also create them. Note that if + * this fails, it will not remove any parent directories it already made. + * + * \param path the path of the directory to create. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_CreateDirectory(const char *path); + +/** + * Possible results from an enumeration callback. + * + * \since This enum is available since SDL 3.2.0. + * + * \sa SDL_EnumerateDirectoryCallback + */ +typedef enum SDL_EnumerationResult +{ + SDL_ENUM_CONTINUE, /**< Value that requests that enumeration continue. */ + SDL_ENUM_SUCCESS, /**< Value that requests that enumeration stop, successfully. */ + SDL_ENUM_FAILURE /**< Value that requests that enumeration stop, as a failure. */ +} SDL_EnumerationResult; + +/** + * Callback for directory enumeration. + * + * Enumeration of directory entries will continue until either all entries + * have been provided to the callback, or the callback has requested a stop + * through its return value. + * + * Returning SDL_ENUM_CONTINUE will let enumeration proceed, calling the + * callback with further entries. SDL_ENUM_SUCCESS and SDL_ENUM_FAILURE will + * terminate the enumeration early, and dictate the return value of the + * enumeration function itself. + * + * `dirname` is guaranteed to end with a path separator ('\\' on Windows, '/' + * on most other platforms). + * + * \param userdata an app-controlled pointer that is passed to the callback. + * \param dirname the directory that is being enumerated. + * \param fname the next entry in the enumeration. + * \returns how the enumeration should proceed. + * + * \since This datatype is available since SDL 3.2.0. + * + * \sa SDL_EnumerateDirectory + */ +typedef SDL_EnumerationResult (SDLCALL *SDL_EnumerateDirectoryCallback)(void *userdata, const char *dirname, const char *fname); + +/** + * Enumerate a directory through a callback function. + * + * This function provides every directory entry through an app-provided + * callback, called once for each directory entry, until all results have been + * provided or the callback returns either SDL_ENUM_SUCCESS or + * SDL_ENUM_FAILURE. + * + * This will return false if there was a system problem in general, or if a + * callback returns SDL_ENUM_FAILURE. A successful return means a callback + * returned SDL_ENUM_SUCCESS to halt enumeration, or all directory entries + * were enumerated. + * + * \param path the path of the directory to enumerate. + * \param callback a function that is called for each entry in the directory. + * \param userdata a pointer that is passed to `callback`. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_EnumerateDirectory(const char *path, SDL_EnumerateDirectoryCallback callback, void *userdata); + +/** + * Remove a file or an empty directory. + * + * Directories that are not empty will fail; this function will not recursely + * delete directory trees. + * + * \param path the path to remove from the filesystem. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_RemovePath(const char *path); + +/** + * Rename a file or directory. + * + * If the file at `newpath` already exists, it will be replaced. + * + * Note that this will not copy files across filesystems/drives/volumes, as + * that is a much more complicated (and possibly time-consuming) operation. + * + * Which is to say, if this function fails, SDL_CopyFile() to a temporary file + * in the same directory as `newpath`, then SDL_RenamePath() from the + * temporary file to `newpath` and SDL_RemovePath() on `oldpath` might work + * for files. Renaming a non-empty directory across filesystems is + * dramatically more complex, however. + * + * \param oldpath the old path. + * \param newpath the new path. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_RenamePath(const char *oldpath, const char *newpath); + +/** + * Copy a file. + * + * If the file at `newpath` already exists, it will be overwritten with the + * contents of the file at `oldpath`. + * + * This function will block until the copy is complete, which might be a + * significant time for large files on slow disks. On some platforms, the copy + * can be handed off to the OS itself, but on others SDL might just open both + * paths, and read from one and write to the other. + * + * Note that this is not an atomic operation! If something tries to read from + * `newpath` while the copy is in progress, it will see an incomplete copy of + * the data, and if the calling thread terminates (or the power goes out) + * during the copy, `newpath`'s previous contents will be gone, replaced with + * an incomplete copy of the data. To avoid this risk, it is recommended that + * the app copy to a temporary file in the same directory as `newpath`, and if + * the copy is successful, use SDL_RenamePath() to replace `newpath` with the + * temporary file. This will ensure that reads of `newpath` will either see a + * complete copy of the data, or it will see the pre-copy state of `newpath`. + * + * This function attempts to synchronize the newly-copied data to disk before + * returning, if the platform allows it, so that the renaming trick will not + * have a problem in a system crash or power failure, where the file could be + * renamed but the contents never made it from the system file cache to the + * physical disk. + * + * If the copy fails for any reason, the state of `newpath` is undefined. It + * might be half a copy, it might be the untouched data of what was already + * there, or it might be a zero-byte file, etc. + * + * \param oldpath the old path. + * \param newpath the new path. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread, but this + * operation is not atomic, so the app might need to protect + * access to specific paths from other threads if appropriate. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_CopyFile(const char *oldpath, const char *newpath); + +/** + * Get information about a filesystem path. + * + * \param path the path to query. + * \param info a pointer filled in with information about the path, or NULL to + * check for the existence of a file. + * \returns true on success or false if the file doesn't exist, or another + * failure; call SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetPathInfo(const char *path, SDL_PathInfo *info); + +/** + * Enumerate a directory tree, filtered by pattern, and return a list. + * + * Files are filtered out if they don't match the string in `pattern`, which + * may contain wildcard characters `*` (match everything) and `?` (match one + * character). If pattern is NULL, no filtering is done and all results are + * returned. Subdirectories are permitted, and are specified with a path + * separator of `/`. Wildcard characters `*` and `?` never match a path + * separator. + * + * `flags` may be set to SDL_GLOB_CASEINSENSITIVE to make the pattern matching + * case-insensitive. + * + * The returned array is always NULL-terminated, for your iterating + * convenience, but if `count` is non-NULL, on return it will contain the + * number of items in the array, not counting the NULL terminator. + * + * \param path the path of the directory to enumerate. + * \param pattern the pattern that files in the directory must match. Can be + * NULL. + * \param flags `SDL_GLOB_*` bitflags that affect this search. + * \param count on return, will be set to the number of items in the returned + * array. Can be NULL. + * \returns an array of strings on success or NULL on failure; call + * SDL_GetError() for more information. This is a single allocation + * that should be freed with SDL_free() when it is no longer needed. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC char ** SDLCALL SDL_GlobDirectory(const char *path, const char *pattern, SDL_GlobFlags flags, int *count); + +/** + * Get what the system believes is the "current working directory." + * + * For systems without a concept of a current working directory, this will + * still attempt to provide something reasonable. + * + * SDL does not provide a means to _change_ the current working directory; for + * platforms without this concept, this would cause surprises with file access + * outside of SDL. + * + * The returned path is guaranteed to end with a path separator ('\\' on + * Windows, '/' on most other platforms). + * + * \returns a UTF-8 string of the current working directory in + * platform-dependent notation. NULL if there's a problem. This + * should be freed with SDL_free() when it is no longer needed. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC char * SDLCALL SDL_GetCurrentDirectory(void); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_filesystem_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_gamepad.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_gamepad.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,1656 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * # CategoryGamepad + * + * SDL provides a low-level joystick API, which just treats joysticks as an + * arbitrary pile of buttons, axes, and hat switches. If you're planning to + * write your own control configuration screen, this can give you a lot of + * flexibility, but that's a lot of work, and most things that we consider + * "joysticks" now are actually console-style gamepads. So SDL provides the + * gamepad API on top of the lower-level joystick functionality. + * + * The difference between a joystick and a gamepad is that a gamepad tells you + * _where_ a button or axis is on the device. You don't speak to gamepads in + * terms of arbitrary numbers like "button 3" or "axis 2" but in standard + * locations: the d-pad, the shoulder buttons, triggers, A/B/X/Y (or + * X/O/Square/Triangle, if you will). + * + * One turns a joystick into a gamepad by providing a magic configuration + * string, which tells SDL the details of a specific device: when you see this + * specific hardware, if button 2 gets pressed, this is actually D-Pad Up, + * etc. + * + * SDL has many popular controllers configured out of the box, and users can + * add their own controller details through an environment variable if it's + * otherwise unknown to SDL. + * + * In order to use these functions, SDL_Init() must have been called with the + * SDL_INIT_GAMEPAD flag. This causes SDL to scan the system for gamepads, and + * load appropriate drivers. + * + * If you're using SDL gamepad support in a Steam game, you must call + * SteamAPI_InitEx() before calling SDL_Init(). + * + * If you would like to receive gamepad updates while the application is in + * the background, you should set the following hint before calling + * SDL_Init(): SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS + * + * Gamepads support various optional features such as rumble, color LEDs, + * touchpad, gyro, etc. The support for these features varies depending on the + * controller and OS support available. You can check for LED and rumble + * capabilities at runtime by calling SDL_GetGamepadProperties() and checking + * the various capability properties. You can check for touchpad by calling + * SDL_GetNumGamepadTouchpads() and check for gyro and accelerometer by + * calling SDL_GamepadHasSensor(). + * + * By default SDL will try to use the most capable driver available, but you + * can tune which OS drivers to use with the various joystick hints in + * SDL_hints.h. + * + * Your application should always support gamepad hotplugging. On some + * platforms like Xbox, Steam Deck, etc., this is a requirement for + * certification. On other platforms, like macOS and Windows when using + * Windows.Gaming.Input, controllers may not be available at startup and will + * come in at some point after you've started processing events. + */ + +#ifndef SDL_gamepad_h_ +#define SDL_gamepad_h_ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * The structure used to identify an SDL gamepad + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_Gamepad SDL_Gamepad; + +/** + * Standard gamepad types. + * + * This type does not necessarily map to first-party controllers from + * Microsoft/Sony/Nintendo; in many cases, third-party controllers can report + * as these, either because they were designed for a specific console, or they + * simply most closely match that console's controllers (does it have A/B/X/Y + * buttons or X/O/Square/Triangle? Does it have a touchpad? etc). + */ +typedef enum SDL_GamepadType +{ + SDL_GAMEPAD_TYPE_UNKNOWN = 0, + SDL_GAMEPAD_TYPE_STANDARD, + SDL_GAMEPAD_TYPE_XBOX360, + SDL_GAMEPAD_TYPE_XBOXONE, + SDL_GAMEPAD_TYPE_PS3, + SDL_GAMEPAD_TYPE_PS4, + SDL_GAMEPAD_TYPE_PS5, + SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_PRO, + SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_LEFT, + SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT, + SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_PAIR, + SDL_GAMEPAD_TYPE_GAMECUBE, + SDL_GAMEPAD_TYPE_COUNT +} SDL_GamepadType; + +/** + * The list of buttons available on a gamepad + * + * For controllers that use a diamond pattern for the face buttons, the + * south/east/west/north buttons below correspond to the locations in the + * diamond pattern. For Xbox controllers, this would be A/B/X/Y, for Nintendo + * Switch controllers, this would be B/A/Y/X, for GameCube controllers this + * would be A/X/B/Y, for PlayStation controllers this would be + * Cross/Circle/Square/Triangle. + * + * For controllers that don't use a diamond pattern for the face buttons, the + * south/east/west/north buttons indicate the buttons labeled A, B, C, D, or + * 1, 2, 3, 4, or for controllers that aren't labeled, they are the primary, + * secondary, etc. buttons. + * + * The activate action is often the south button and the cancel action is + * often the east button, but in some regions this is reversed, so your game + * should allow remapping actions based on user preferences. + * + * You can query the labels for the face buttons using + * SDL_GetGamepadButtonLabel() + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_GamepadButton +{ + SDL_GAMEPAD_BUTTON_INVALID = -1, + SDL_GAMEPAD_BUTTON_SOUTH, /**< Bottom face button (e.g. Xbox A button) */ + SDL_GAMEPAD_BUTTON_EAST, /**< Right face button (e.g. Xbox B button) */ + SDL_GAMEPAD_BUTTON_WEST, /**< Left face button (e.g. Xbox X button) */ + SDL_GAMEPAD_BUTTON_NORTH, /**< Top face button (e.g. Xbox Y button) */ + SDL_GAMEPAD_BUTTON_BACK, + SDL_GAMEPAD_BUTTON_GUIDE, + SDL_GAMEPAD_BUTTON_START, + SDL_GAMEPAD_BUTTON_LEFT_STICK, + SDL_GAMEPAD_BUTTON_RIGHT_STICK, + SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, + SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, + SDL_GAMEPAD_BUTTON_DPAD_UP, + SDL_GAMEPAD_BUTTON_DPAD_DOWN, + SDL_GAMEPAD_BUTTON_DPAD_LEFT, + SDL_GAMEPAD_BUTTON_DPAD_RIGHT, + SDL_GAMEPAD_BUTTON_MISC1, /**< Additional button (e.g. Xbox Series X share button, PS5 microphone button, Nintendo Switch Pro capture button, Amazon Luna microphone button, Google Stadia capture button) */ + SDL_GAMEPAD_BUTTON_RIGHT_PADDLE1, /**< Upper or primary paddle, under your right hand (e.g. Xbox Elite paddle P1, DualSense Edge RB button, Right Joy-Con SR button) */ + SDL_GAMEPAD_BUTTON_LEFT_PADDLE1, /**< Upper or primary paddle, under your left hand (e.g. Xbox Elite paddle P3, DualSense Edge LB button, Left Joy-Con SL button) */ + SDL_GAMEPAD_BUTTON_RIGHT_PADDLE2, /**< Lower or secondary paddle, under your right hand (e.g. Xbox Elite paddle P2, DualSense Edge right Fn button, Right Joy-Con SL button) */ + SDL_GAMEPAD_BUTTON_LEFT_PADDLE2, /**< Lower or secondary paddle, under your left hand (e.g. Xbox Elite paddle P4, DualSense Edge left Fn button, Left Joy-Con SR button) */ + SDL_GAMEPAD_BUTTON_TOUCHPAD, /**< PS4/PS5 touchpad button */ + SDL_GAMEPAD_BUTTON_MISC2, /**< Additional button */ + SDL_GAMEPAD_BUTTON_MISC3, /**< Additional button (e.g. Nintendo GameCube left trigger click) */ + SDL_GAMEPAD_BUTTON_MISC4, /**< Additional button (e.g. Nintendo GameCube right trigger click) */ + SDL_GAMEPAD_BUTTON_MISC5, /**< Additional button */ + SDL_GAMEPAD_BUTTON_MISC6, /**< Additional button */ + SDL_GAMEPAD_BUTTON_COUNT +} SDL_GamepadButton; + +/** + * The set of gamepad button labels + * + * This isn't a complete set, just the face buttons to make it easy to show + * button prompts. + * + * For a complete set, you should look at the button and gamepad type and have + * a set of symbols that work well with your art style. + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_GamepadButtonLabel +{ + SDL_GAMEPAD_BUTTON_LABEL_UNKNOWN, + SDL_GAMEPAD_BUTTON_LABEL_A, + SDL_GAMEPAD_BUTTON_LABEL_B, + SDL_GAMEPAD_BUTTON_LABEL_X, + SDL_GAMEPAD_BUTTON_LABEL_Y, + SDL_GAMEPAD_BUTTON_LABEL_CROSS, + SDL_GAMEPAD_BUTTON_LABEL_CIRCLE, + SDL_GAMEPAD_BUTTON_LABEL_SQUARE, + SDL_GAMEPAD_BUTTON_LABEL_TRIANGLE +} SDL_GamepadButtonLabel; + +/** + * The list of axes available on a gamepad + * + * Thumbstick axis values range from SDL_JOYSTICK_AXIS_MIN to + * SDL_JOYSTICK_AXIS_MAX, and are centered within ~8000 of zero, though + * advanced UI will allow users to set or autodetect the dead zone, which + * varies between gamepads. + * + * Trigger axis values range from 0 (released) to SDL_JOYSTICK_AXIS_MAX (fully + * pressed) when reported by SDL_GetGamepadAxis(). Note that this is not the + * same range that will be reported by the lower-level SDL_GetJoystickAxis(). + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_GamepadAxis +{ + SDL_GAMEPAD_AXIS_INVALID = -1, + SDL_GAMEPAD_AXIS_LEFTX, + SDL_GAMEPAD_AXIS_LEFTY, + SDL_GAMEPAD_AXIS_RIGHTX, + SDL_GAMEPAD_AXIS_RIGHTY, + SDL_GAMEPAD_AXIS_LEFT_TRIGGER, + SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, + SDL_GAMEPAD_AXIS_COUNT +} SDL_GamepadAxis; + +/** + * Types of gamepad control bindings. + * + * A gamepad is a collection of bindings that map arbitrary joystick buttons, + * axes and hat switches to specific positions on a generic console-style + * gamepad. This enum is used as part of SDL_GamepadBinding to specify those + * mappings. + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_GamepadBindingType +{ + SDL_GAMEPAD_BINDTYPE_NONE = 0, + SDL_GAMEPAD_BINDTYPE_BUTTON, + SDL_GAMEPAD_BINDTYPE_AXIS, + SDL_GAMEPAD_BINDTYPE_HAT +} SDL_GamepadBindingType; + +/** + * A mapping between one joystick input to a gamepad control. + * + * A gamepad has a collection of several bindings, to say, for example, when + * joystick button number 5 is pressed, that should be treated like the + * gamepad's "start" button. + * + * SDL has these bindings built-in for many popular controllers, and can add + * more with a simple text string. Those strings are parsed into a collection + * of these structs to make it easier to operate on the data. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_GetGamepadBindings + */ +typedef struct SDL_GamepadBinding +{ + SDL_GamepadBindingType input_type; + union + { + int button; + + struct + { + int axis; + int axis_min; + int axis_max; + } axis; + + struct + { + int hat; + int hat_mask; + } hat; + + } input; + + SDL_GamepadBindingType output_type; + union + { + SDL_GamepadButton button; + + struct + { + SDL_GamepadAxis axis; + int axis_min; + int axis_max; + } axis; + + } output; +} SDL_GamepadBinding; + + +/** + * Add support for gamepads that SDL is unaware of or change the binding of an + * existing gamepad. + * + * The mapping string has the format "GUID,name,mapping", where GUID is the + * string value from SDL_GUIDToString(), name is the human readable string for + * the device and mappings are gamepad mappings to joystick ones. Under + * Windows there is a reserved GUID of "xinput" that covers all XInput + * devices. The mapping format for joystick is: + * + * - `bX`: a joystick button, index X + * - `hX.Y`: hat X with value Y + * - `aX`: axis X of the joystick + * + * Buttons can be used as a gamepad axes and vice versa. + * + * If a device with this GUID is already plugged in, SDL will generate an + * SDL_EVENT_GAMEPAD_ADDED event. + * + * This string shows an example of a valid mapping for a gamepad: + * + * ```c + * "341a3608000000000000504944564944,Afterglow PS3 Controller,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftshoulder:b4,rightshoulder:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7" + * ``` + * + * \param mapping the mapping string. + * \returns 1 if a new mapping is added, 0 if an existing mapping is updated, + * -1 on failure; call SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_AddGamepadMappingsFromFile + * \sa SDL_AddGamepadMappingsFromIO + * \sa SDL_GetGamepadMapping + * \sa SDL_GetGamepadMappingForGUID + * \sa SDL_HINT_GAMECONTROLLERCONFIG + * \sa SDL_HINT_GAMECONTROLLERCONFIG_FILE + * \sa SDL_EVENT_GAMEPAD_ADDED + */ +extern SDL_DECLSPEC int SDLCALL SDL_AddGamepadMapping(const char *mapping); + +/** + * Load a set of gamepad mappings from an SDL_IOStream. + * + * You can call this function several times, if needed, to load different + * database files. + * + * If a new mapping is loaded for an already known gamepad GUID, the later + * version will overwrite the one currently loaded. + * + * Any new mappings for already plugged in controllers will generate + * SDL_EVENT_GAMEPAD_ADDED events. + * + * Mappings not belonging to the current platform or with no platform field + * specified will be ignored (i.e. mappings for Linux will be ignored in + * Windows, etc). + * + * This function will load the text database entirely in memory before + * processing it, so take this into consideration if you are in a memory + * constrained environment. + * + * \param src the data stream for the mappings to be added. + * \param closeio if true, calls SDL_CloseIO() on `src` before returning, even + * in the case of an error. + * \returns the number of mappings added or -1 on failure; call SDL_GetError() + * for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_AddGamepadMapping + * \sa SDL_AddGamepadMappingsFromFile + * \sa SDL_GetGamepadMapping + * \sa SDL_GetGamepadMappingForGUID + * \sa SDL_HINT_GAMECONTROLLERCONFIG + * \sa SDL_HINT_GAMECONTROLLERCONFIG_FILE + * \sa SDL_EVENT_GAMEPAD_ADDED + */ +extern SDL_DECLSPEC int SDLCALL SDL_AddGamepadMappingsFromIO(SDL_IOStream *src, bool closeio); + +/** + * Load a set of gamepad mappings from a file. + * + * You can call this function several times, if needed, to load different + * database files. + * + * If a new mapping is loaded for an already known gamepad GUID, the later + * version will overwrite the one currently loaded. + * + * Any new mappings for already plugged in controllers will generate + * SDL_EVENT_GAMEPAD_ADDED events. + * + * Mappings not belonging to the current platform or with no platform field + * specified will be ignored (i.e. mappings for Linux will be ignored in + * Windows, etc). + * + * \param file the mappings file to load. + * \returns the number of mappings added or -1 on failure; call SDL_GetError() + * for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_AddGamepadMapping + * \sa SDL_AddGamepadMappingsFromIO + * \sa SDL_GetGamepadMapping + * \sa SDL_GetGamepadMappingForGUID + * \sa SDL_HINT_GAMECONTROLLERCONFIG + * \sa SDL_HINT_GAMECONTROLLERCONFIG_FILE + * \sa SDL_EVENT_GAMEPAD_ADDED + */ +extern SDL_DECLSPEC int SDLCALL SDL_AddGamepadMappingsFromFile(const char *file); + +/** + * Reinitialize the SDL mapping database to its initial state. + * + * This will generate gamepad events as needed if device mappings change. + * + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_ReloadGamepadMappings(void); + +/** + * Get the current gamepad mappings. + * + * \param count a pointer filled in with the number of mappings returned, can + * be NULL. + * \returns an array of the mapping strings, NULL-terminated, or NULL on + * failure; call SDL_GetError() for more information. This is a + * single allocation that should be freed with SDL_free() when it is + * no longer needed. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC char ** SDLCALL SDL_GetGamepadMappings(int *count); + +/** + * Get the gamepad mapping string for a given GUID. + * + * \param guid a structure containing the GUID for which a mapping is desired. + * \returns a mapping string or NULL on failure; call SDL_GetError() for more + * information. This should be freed with SDL_free() when it is no + * longer needed. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetJoystickGUIDForID + * \sa SDL_GetJoystickGUID + */ +extern SDL_DECLSPEC char * SDLCALL SDL_GetGamepadMappingForGUID(SDL_GUID guid); + +/** + * Get the current mapping of a gamepad. + * + * Details about mappings are discussed with SDL_AddGamepadMapping(). + * + * \param gamepad the gamepad you want to get the current mapping for. + * \returns a string that has the gamepad's mapping or NULL if no mapping is + * available; call SDL_GetError() for more information. This should + * be freed with SDL_free() when it is no longer needed. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_AddGamepadMapping + * \sa SDL_GetGamepadMappingForID + * \sa SDL_GetGamepadMappingForGUID + * \sa SDL_SetGamepadMapping + */ +extern SDL_DECLSPEC char * SDLCALL SDL_GetGamepadMapping(SDL_Gamepad *gamepad); + +/** + * Set the current mapping of a joystick or gamepad. + * + * Details about mappings are discussed with SDL_AddGamepadMapping(). + * + * \param instance_id the joystick instance ID. + * \param mapping the mapping to use for this device, or NULL to clear the + * mapping. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_AddGamepadMapping + * \sa SDL_GetGamepadMapping + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetGamepadMapping(SDL_JoystickID instance_id, const char *mapping); + +/** + * Return whether a gamepad is currently connected. + * + * \returns true if a gamepad is connected, false otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetGamepads + */ +extern SDL_DECLSPEC bool SDLCALL SDL_HasGamepad(void); + +/** + * Get a list of currently connected gamepads. + * + * \param count a pointer filled in with the number of gamepads returned, may + * be NULL. + * \returns a 0 terminated array of joystick instance IDs or NULL on failure; + * call SDL_GetError() for more information. This should be freed + * with SDL_free() when it is no longer needed. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_HasGamepad + * \sa SDL_OpenGamepad + */ +extern SDL_DECLSPEC SDL_JoystickID * SDLCALL SDL_GetGamepads(int *count); + +/** + * Check if the given joystick is supported by the gamepad interface. + * + * \param instance_id the joystick instance ID. + * \returns true if the given joystick is supported by the gamepad interface, + * false if it isn't or it's an invalid index. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetJoysticks + * \sa SDL_OpenGamepad + */ +extern SDL_DECLSPEC bool SDLCALL SDL_IsGamepad(SDL_JoystickID instance_id); + +/** + * Get the implementation dependent name of a gamepad. + * + * This can be called before any gamepads are opened. + * + * \param instance_id the joystick instance ID. + * \returns the name of the selected gamepad. If no name can be found, this + * function returns NULL; call SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetGamepadName + * \sa SDL_GetGamepads + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadNameForID(SDL_JoystickID instance_id); + +/** + * Get the implementation dependent path of a gamepad. + * + * This can be called before any gamepads are opened. + * + * \param instance_id the joystick instance ID. + * \returns the path of the selected gamepad. If no path can be found, this + * function returns NULL; call SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetGamepadPath + * \sa SDL_GetGamepads + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadPathForID(SDL_JoystickID instance_id); + +/** + * Get the player index of a gamepad. + * + * This can be called before any gamepads are opened. + * + * \param instance_id the joystick instance ID. + * \returns the player index of a gamepad, or -1 if it's not available. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetGamepadPlayerIndex + * \sa SDL_GetGamepads + */ +extern SDL_DECLSPEC int SDLCALL SDL_GetGamepadPlayerIndexForID(SDL_JoystickID instance_id); + +/** + * Get the implementation-dependent GUID of a gamepad. + * + * This can be called before any gamepads are opened. + * + * \param instance_id the joystick instance ID. + * \returns the GUID of the selected gamepad. If called on an invalid index, + * this function returns a zero GUID. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GUIDToString + * \sa SDL_GetGamepads + */ +extern SDL_DECLSPEC SDL_GUID SDLCALL SDL_GetGamepadGUIDForID(SDL_JoystickID instance_id); + +/** + * Get the USB vendor ID of a gamepad, if available. + * + * This can be called before any gamepads are opened. If the vendor ID isn't + * available this function returns 0. + * + * \param instance_id the joystick instance ID. + * \returns the USB vendor ID of the selected gamepad. If called on an invalid + * index, this function returns zero. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetGamepadVendor + * \sa SDL_GetGamepads + */ +extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadVendorForID(SDL_JoystickID instance_id); + +/** + * Get the USB product ID of a gamepad, if available. + * + * This can be called before any gamepads are opened. If the product ID isn't + * available this function returns 0. + * + * \param instance_id the joystick instance ID. + * \returns the USB product ID of the selected gamepad. If called on an + * invalid index, this function returns zero. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetGamepadProduct + * \sa SDL_GetGamepads + */ +extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadProductForID(SDL_JoystickID instance_id); + +/** + * Get the product version of a gamepad, if available. + * + * This can be called before any gamepads are opened. If the product version + * isn't available this function returns 0. + * + * \param instance_id the joystick instance ID. + * \returns the product version of the selected gamepad. If called on an + * invalid index, this function returns zero. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetGamepadProductVersion + * \sa SDL_GetGamepads + */ +extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadProductVersionForID(SDL_JoystickID instance_id); + +/** + * Get the type of a gamepad. + * + * This can be called before any gamepads are opened. + * + * \param instance_id the joystick instance ID. + * \returns the gamepad type. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetGamepadType + * \sa SDL_GetGamepads + * \sa SDL_GetRealGamepadTypeForID + */ +extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetGamepadTypeForID(SDL_JoystickID instance_id); + +/** + * Get the type of a gamepad, ignoring any mapping override. + * + * This can be called before any gamepads are opened. + * + * \param instance_id the joystick instance ID. + * \returns the gamepad type. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetGamepadTypeForID + * \sa SDL_GetGamepads + * \sa SDL_GetRealGamepadType + */ +extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetRealGamepadTypeForID(SDL_JoystickID instance_id); + +/** + * Get the mapping of a gamepad. + * + * This can be called before any gamepads are opened. + * + * \param instance_id the joystick instance ID. + * \returns the mapping string. Returns NULL if no mapping is available. This + * should be freed with SDL_free() when it is no longer needed. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetGamepads + * \sa SDL_GetGamepadMapping + */ +extern SDL_DECLSPEC char * SDLCALL SDL_GetGamepadMappingForID(SDL_JoystickID instance_id); + +/** + * Open a gamepad for use. + * + * \param instance_id the joystick instance ID. + * \returns a gamepad identifier or NULL if an error occurred; call + * SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CloseGamepad + * \sa SDL_IsGamepad + */ +extern SDL_DECLSPEC SDL_Gamepad * SDLCALL SDL_OpenGamepad(SDL_JoystickID instance_id); + +/** + * Get the SDL_Gamepad associated with a joystick instance ID, if it has been + * opened. + * + * \param instance_id the joystick instance ID of the gamepad. + * \returns an SDL_Gamepad on success or NULL on failure or if it hasn't been + * opened yet; call SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_Gamepad * SDLCALL SDL_GetGamepadFromID(SDL_JoystickID instance_id); + +/** + * Get the SDL_Gamepad associated with a player index. + * + * \param player_index the player index, which different from the instance ID. + * \returns the SDL_Gamepad associated with a player index. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetGamepadPlayerIndex + * \sa SDL_SetGamepadPlayerIndex + */ +extern SDL_DECLSPEC SDL_Gamepad * SDLCALL SDL_GetGamepadFromPlayerIndex(int player_index); + +/** + * Get the properties associated with an opened gamepad. + * + * These properties are shared with the underlying joystick object. + * + * The following read-only properties are provided by SDL: + * + * - `SDL_PROP_GAMEPAD_CAP_MONO_LED_BOOLEAN`: true if this gamepad has an LED + * that has adjustable brightness + * - `SDL_PROP_GAMEPAD_CAP_RGB_LED_BOOLEAN`: true if this gamepad has an LED + * that has adjustable color + * - `SDL_PROP_GAMEPAD_CAP_PLAYER_LED_BOOLEAN`: true if this gamepad has a + * player LED + * - `SDL_PROP_GAMEPAD_CAP_RUMBLE_BOOLEAN`: true if this gamepad has + * left/right rumble + * - `SDL_PROP_GAMEPAD_CAP_TRIGGER_RUMBLE_BOOLEAN`: true if this gamepad has + * simple trigger rumble + * + * \param gamepad a gamepad identifier previously returned by + * SDL_OpenGamepad(). + * \returns a valid property ID on success or 0 on failure; call + * SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetGamepadProperties(SDL_Gamepad *gamepad); + +#define SDL_PROP_GAMEPAD_CAP_MONO_LED_BOOLEAN SDL_PROP_JOYSTICK_CAP_MONO_LED_BOOLEAN +#define SDL_PROP_GAMEPAD_CAP_RGB_LED_BOOLEAN SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN +#define SDL_PROP_GAMEPAD_CAP_PLAYER_LED_BOOLEAN SDL_PROP_JOYSTICK_CAP_PLAYER_LED_BOOLEAN +#define SDL_PROP_GAMEPAD_CAP_RUMBLE_BOOLEAN SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN +#define SDL_PROP_GAMEPAD_CAP_TRIGGER_RUMBLE_BOOLEAN SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN + +/** + * Get the instance ID of an opened gamepad. + * + * \param gamepad a gamepad identifier previously returned by + * SDL_OpenGamepad(). + * \returns the instance ID of the specified gamepad on success or 0 on + * failure; call SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_JoystickID SDLCALL SDL_GetGamepadID(SDL_Gamepad *gamepad); + +/** + * Get the implementation-dependent name for an opened gamepad. + * + * \param gamepad a gamepad identifier previously returned by + * SDL_OpenGamepad(). + * \returns the implementation dependent name for the gamepad, or NULL if + * there is no name or the identifier passed is invalid. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetGamepadNameForID + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadName(SDL_Gamepad *gamepad); + +/** + * Get the implementation-dependent path for an opened gamepad. + * + * \param gamepad a gamepad identifier previously returned by + * SDL_OpenGamepad(). + * \returns the implementation dependent path for the gamepad, or NULL if + * there is no path or the identifier passed is invalid. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetGamepadPathForID + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadPath(SDL_Gamepad *gamepad); + +/** + * Get the type of an opened gamepad. + * + * \param gamepad the gamepad object to query. + * \returns the gamepad type, or SDL_GAMEPAD_TYPE_UNKNOWN if it's not + * available. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetGamepadTypeForID + */ +extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetGamepadType(SDL_Gamepad *gamepad); + +/** + * Get the type of an opened gamepad, ignoring any mapping override. + * + * \param gamepad the gamepad object to query. + * \returns the gamepad type, or SDL_GAMEPAD_TYPE_UNKNOWN if it's not + * available. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetRealGamepadTypeForID + */ +extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetRealGamepadType(SDL_Gamepad *gamepad); + +/** + * Get the player index of an opened gamepad. + * + * For XInput gamepads this returns the XInput user index. + * + * \param gamepad the gamepad object to query. + * \returns the player index for gamepad, or -1 if it's not available. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetGamepadPlayerIndex + */ +extern SDL_DECLSPEC int SDLCALL SDL_GetGamepadPlayerIndex(SDL_Gamepad *gamepad); + +/** + * Set the player index of an opened gamepad. + * + * \param gamepad the gamepad object to adjust. + * \param player_index player index to assign to this gamepad, or -1 to clear + * the player index and turn off player LEDs. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetGamepadPlayerIndex + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetGamepadPlayerIndex(SDL_Gamepad *gamepad, int player_index); + +/** + * Get the USB vendor ID of an opened gamepad, if available. + * + * If the vendor ID isn't available this function returns 0. + * + * \param gamepad the gamepad object to query. + * \returns the USB vendor ID, or zero if unavailable. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetGamepadVendorForID + */ +extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadVendor(SDL_Gamepad *gamepad); + +/** + * Get the USB product ID of an opened gamepad, if available. + * + * If the product ID isn't available this function returns 0. + * + * \param gamepad the gamepad object to query. + * \returns the USB product ID, or zero if unavailable. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetGamepadProductForID + */ +extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadProduct(SDL_Gamepad *gamepad); + +/** + * Get the product version of an opened gamepad, if available. + * + * If the product version isn't available this function returns 0. + * + * \param gamepad the gamepad object to query. + * \returns the USB product version, or zero if unavailable. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetGamepadProductVersionForID + */ +extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadProductVersion(SDL_Gamepad *gamepad); + +/** + * Get the firmware version of an opened gamepad, if available. + * + * If the firmware version isn't available this function returns 0. + * + * \param gamepad the gamepad object to query. + * \returns the gamepad firmware version, or zero if unavailable. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadFirmwareVersion(SDL_Gamepad *gamepad); + +/** + * Get the serial number of an opened gamepad, if available. + * + * Returns the serial number of the gamepad, or NULL if it is not available. + * + * \param gamepad the gamepad object to query. + * \returns the serial number, or NULL if unavailable. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadSerial(SDL_Gamepad *gamepad); + +/** + * Get the Steam Input handle of an opened gamepad, if available. + * + * Returns an InputHandle_t for the gamepad that can be used with Steam Input + * API: https://partner.steamgames.com/doc/api/ISteamInput + * + * \param gamepad the gamepad object to query. + * \returns the gamepad handle, or 0 if unavailable. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC Uint64 SDLCALL SDL_GetGamepadSteamHandle(SDL_Gamepad *gamepad); + +/** + * Get the connection state of a gamepad. + * + * \param gamepad the gamepad object to query. + * \returns the connection state on success or + * `SDL_JOYSTICK_CONNECTION_INVALID` on failure; call SDL_GetError() + * for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_JoystickConnectionState SDLCALL SDL_GetGamepadConnectionState(SDL_Gamepad *gamepad); + +/** + * Get the battery state of a gamepad. + * + * You should never take a battery status as absolute truth. Batteries + * (especially failing batteries) are delicate hardware, and the values + * reported here are best estimates based on what that hardware reports. It's + * not uncommon for older batteries to lose stored power much faster than it + * reports, or completely drain when reporting it has 20 percent left, etc. + * + * \param gamepad the gamepad object to query. + * \param percent a pointer filled in with the percentage of battery life + * left, between 0 and 100, or NULL to ignore. This will be + * filled in with -1 we can't determine a value or there is no + * battery. + * \returns the current battery state. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_PowerState SDLCALL SDL_GetGamepadPowerInfo(SDL_Gamepad *gamepad, int *percent); + +/** + * Check if a gamepad has been opened and is currently connected. + * + * \param gamepad a gamepad identifier previously returned by + * SDL_OpenGamepad(). + * \returns true if the gamepad has been opened and is currently connected, or + * false if not. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GamepadConnected(SDL_Gamepad *gamepad); + +/** + * Get the underlying joystick from a gamepad. + * + * This function will give you a SDL_Joystick object, which allows you to use + * the SDL_Joystick functions with a SDL_Gamepad object. This would be useful + * for getting a joystick's position at any given time, even if it hasn't + * moved (moving it would produce an event, which would have the axis' value). + * + * The pointer returned is owned by the SDL_Gamepad. You should not call + * SDL_CloseJoystick() on it, for example, since doing so will likely cause + * SDL to crash. + * + * \param gamepad the gamepad object that you want to get a joystick from. + * \returns an SDL_Joystick object, or NULL on failure; call SDL_GetError() + * for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_Joystick * SDLCALL SDL_GetGamepadJoystick(SDL_Gamepad *gamepad); + +/** + * Set the state of gamepad event processing. + * + * If gamepad events are disabled, you must call SDL_UpdateGamepads() yourself + * and check the state of the gamepad when you want gamepad information. + * + * \param enabled whether to process gamepad events or not. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GamepadEventsEnabled + * \sa SDL_UpdateGamepads + */ +extern SDL_DECLSPEC void SDLCALL SDL_SetGamepadEventsEnabled(bool enabled); + +/** + * Query the state of gamepad event processing. + * + * If gamepad events are disabled, you must call SDL_UpdateGamepads() yourself + * and check the state of the gamepad when you want gamepad information. + * + * \returns true if gamepad events are being processed, false otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetGamepadEventsEnabled + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GamepadEventsEnabled(void); + +/** + * Get the SDL joystick layer bindings for a gamepad. + * + * \param gamepad a gamepad. + * \param count a pointer filled in with the number of bindings returned. + * \returns a NULL terminated array of pointers to bindings or NULL on + * failure; call SDL_GetError() for more information. This is a + * single allocation that should be freed with SDL_free() when it is + * no longer needed. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_GamepadBinding ** SDLCALL SDL_GetGamepadBindings(SDL_Gamepad *gamepad, int *count); + +/** + * Manually pump gamepad updates if not using the loop. + * + * This function is called automatically by the event loop if events are + * enabled. Under such circumstances, it will not be necessary to call this + * function. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_UpdateGamepads(void); + +/** + * Convert a string into SDL_GamepadType enum. + * + * This function is called internally to translate SDL_Gamepad mapping strings + * for the underlying joystick device into the consistent SDL_Gamepad mapping. + * You do not normally need to call this function unless you are parsing + * SDL_Gamepad mappings in your own code. + * + * \param str string representing a SDL_GamepadType type. + * \returns the SDL_GamepadType enum corresponding to the input string, or + * `SDL_GAMEPAD_TYPE_UNKNOWN` if no match was found. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetGamepadStringForType + */ +extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetGamepadTypeFromString(const char *str); + +/** + * Convert from an SDL_GamepadType enum to a string. + * + * \param type an enum value for a given SDL_GamepadType. + * \returns a string for the given type, or NULL if an invalid type is + * specified. The string returned is of the format used by + * SDL_Gamepad mapping strings. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetGamepadTypeFromString + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadStringForType(SDL_GamepadType type); + +/** + * Convert a string into SDL_GamepadAxis enum. + * + * This function is called internally to translate SDL_Gamepad mapping strings + * for the underlying joystick device into the consistent SDL_Gamepad mapping. + * You do not normally need to call this function unless you are parsing + * SDL_Gamepad mappings in your own code. + * + * Note specially that "righttrigger" and "lefttrigger" map to + * `SDL_GAMEPAD_AXIS_RIGHT_TRIGGER` and `SDL_GAMEPAD_AXIS_LEFT_TRIGGER`, + * respectively. + * + * \param str string representing a SDL_Gamepad axis. + * \returns the SDL_GamepadAxis enum corresponding to the input string, or + * `SDL_GAMEPAD_AXIS_INVALID` if no match was found. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetGamepadStringForAxis + */ +extern SDL_DECLSPEC SDL_GamepadAxis SDLCALL SDL_GetGamepadAxisFromString(const char *str); + +/** + * Convert from an SDL_GamepadAxis enum to a string. + * + * \param axis an enum value for a given SDL_GamepadAxis. + * \returns a string for the given axis, or NULL if an invalid axis is + * specified. The string returned is of the format used by + * SDL_Gamepad mapping strings. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetGamepadAxisFromString + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadStringForAxis(SDL_GamepadAxis axis); + +/** + * Query whether a gamepad has a given axis. + * + * This merely reports whether the gamepad's mapping defined this axis, as + * that is all the information SDL has about the physical device. + * + * \param gamepad a gamepad. + * \param axis an axis enum value (an SDL_GamepadAxis value). + * \returns true if the gamepad has this axis, false otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GamepadHasButton + * \sa SDL_GetGamepadAxis + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GamepadHasAxis(SDL_Gamepad *gamepad, SDL_GamepadAxis axis); + +/** + * Get the current state of an axis control on a gamepad. + * + * The axis indices start at index 0. + * + * For thumbsticks, the state is a value ranging from -32768 (up/left) to + * 32767 (down/right). + * + * Triggers range from 0 when released to 32767 when fully pressed, and never + * return a negative value. Note that this differs from the value reported by + * the lower-level SDL_GetJoystickAxis(), which normally uses the full range. + * + * Note that for invalid gamepads or axes, this will return 0. Zero is also a + * valid value in normal operation; usually it means a centered axis. + * + * \param gamepad a gamepad. + * \param axis an axis index (one of the SDL_GamepadAxis values). + * \returns axis state. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GamepadHasAxis + * \sa SDL_GetGamepadButton + */ +extern SDL_DECLSPEC Sint16 SDLCALL SDL_GetGamepadAxis(SDL_Gamepad *gamepad, SDL_GamepadAxis axis); + +/** + * Convert a string into an SDL_GamepadButton enum. + * + * This function is called internally to translate SDL_Gamepad mapping strings + * for the underlying joystick device into the consistent SDL_Gamepad mapping. + * You do not normally need to call this function unless you are parsing + * SDL_Gamepad mappings in your own code. + * + * \param str string representing a SDL_Gamepad button. + * \returns the SDL_GamepadButton enum corresponding to the input string, or + * `SDL_GAMEPAD_BUTTON_INVALID` if no match was found. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetGamepadStringForButton + */ +extern SDL_DECLSPEC SDL_GamepadButton SDLCALL SDL_GetGamepadButtonFromString(const char *str); + +/** + * Convert from an SDL_GamepadButton enum to a string. + * + * \param button an enum value for a given SDL_GamepadButton. + * \returns a string for the given button, or NULL if an invalid button is + * specified. The string returned is of the format used by + * SDL_Gamepad mapping strings. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetGamepadButtonFromString + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadStringForButton(SDL_GamepadButton button); + +/** + * Query whether a gamepad has a given button. + * + * This merely reports whether the gamepad's mapping defined this button, as + * that is all the information SDL has about the physical device. + * + * \param gamepad a gamepad. + * \param button a button enum value (an SDL_GamepadButton value). + * \returns true if the gamepad has this button, false otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GamepadHasAxis + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GamepadHasButton(SDL_Gamepad *gamepad, SDL_GamepadButton button); + +/** + * Get the current state of a button on a gamepad. + * + * \param gamepad a gamepad. + * \param button a button index (one of the SDL_GamepadButton values). + * \returns true if the button is pressed, false otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GamepadHasButton + * \sa SDL_GetGamepadAxis + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetGamepadButton(SDL_Gamepad *gamepad, SDL_GamepadButton button); + +/** + * Get the label of a button on a gamepad. + * + * \param type the type of gamepad to check. + * \param button a button index (one of the SDL_GamepadButton values). + * \returns the SDL_GamepadButtonLabel enum corresponding to the button label. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetGamepadButtonLabel + */ +extern SDL_DECLSPEC SDL_GamepadButtonLabel SDLCALL SDL_GetGamepadButtonLabelForType(SDL_GamepadType type, SDL_GamepadButton button); + +/** + * Get the label of a button on a gamepad. + * + * \param gamepad a gamepad. + * \param button a button index (one of the SDL_GamepadButton values). + * \returns the SDL_GamepadButtonLabel enum corresponding to the button label. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetGamepadButtonLabelForType + */ +extern SDL_DECLSPEC SDL_GamepadButtonLabel SDLCALL SDL_GetGamepadButtonLabel(SDL_Gamepad *gamepad, SDL_GamepadButton button); + +/** + * Get the number of touchpads on a gamepad. + * + * \param gamepad a gamepad. + * \returns number of touchpads. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetNumGamepadTouchpadFingers + */ +extern SDL_DECLSPEC int SDLCALL SDL_GetNumGamepadTouchpads(SDL_Gamepad *gamepad); + +/** + * Get the number of supported simultaneous fingers on a touchpad on a game + * gamepad. + * + * \param gamepad a gamepad. + * \param touchpad a touchpad. + * \returns number of supported simultaneous fingers. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetGamepadTouchpadFinger + * \sa SDL_GetNumGamepadTouchpads + */ +extern SDL_DECLSPEC int SDLCALL SDL_GetNumGamepadTouchpadFingers(SDL_Gamepad *gamepad, int touchpad); + +/** + * Get the current state of a finger on a touchpad on a gamepad. + * + * \param gamepad a gamepad. + * \param touchpad a touchpad. + * \param finger a finger. + * \param down a pointer filled with true if the finger is down, false + * otherwise, may be NULL. + * \param x a pointer filled with the x position, normalized 0 to 1, with the + * origin in the upper left, may be NULL. + * \param y a pointer filled with the y position, normalized 0 to 1, with the + * origin in the upper left, may be NULL. + * \param pressure a pointer filled with pressure value, may be NULL. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetNumGamepadTouchpadFingers + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetGamepadTouchpadFinger(SDL_Gamepad *gamepad, int touchpad, int finger, bool *down, float *x, float *y, float *pressure); + +/** + * Return whether a gamepad has a particular sensor. + * + * \param gamepad the gamepad to query. + * \param type the type of sensor to query. + * \returns true if the sensor exists, false otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetGamepadSensorData + * \sa SDL_GetGamepadSensorDataRate + * \sa SDL_SetGamepadSensorEnabled + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GamepadHasSensor(SDL_Gamepad *gamepad, SDL_SensorType type); + +/** + * Set whether data reporting for a gamepad sensor is enabled. + * + * \param gamepad the gamepad to update. + * \param type the type of sensor to enable/disable. + * \param enabled whether data reporting should be enabled. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GamepadHasSensor + * \sa SDL_GamepadSensorEnabled + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetGamepadSensorEnabled(SDL_Gamepad *gamepad, SDL_SensorType type, bool enabled); + +/** + * Query whether sensor data reporting is enabled for a gamepad. + * + * \param gamepad the gamepad to query. + * \param type the type of sensor to query. + * \returns true if the sensor is enabled, false otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetGamepadSensorEnabled + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GamepadSensorEnabled(SDL_Gamepad *gamepad, SDL_SensorType type); + +/** + * Get the data rate (number of events per second) of a gamepad sensor. + * + * \param gamepad the gamepad to query. + * \param type the type of sensor to query. + * \returns the data rate, or 0.0f if the data rate is not available. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC float SDLCALL SDL_GetGamepadSensorDataRate(SDL_Gamepad *gamepad, SDL_SensorType type); + +/** + * Get the current state of a gamepad sensor. + * + * The number of values and interpretation of the data is sensor dependent. + * See the remarks in SDL_SensorType for details for each type of sensor. + * + * \param gamepad the gamepad to query. + * \param type the type of sensor to query. + * \param data a pointer filled with the current sensor state. + * \param num_values the number of values to write to data. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetGamepadSensorData(SDL_Gamepad *gamepad, SDL_SensorType type, float *data, int num_values); + +/** + * Start a rumble effect on a gamepad. + * + * Each call to this function cancels any previous rumble effect, and calling + * it with 0 intensity stops any rumbling. + * + * This function requires you to process SDL events or call + * SDL_UpdateJoysticks() to update rumble state. + * + * \param gamepad the gamepad to vibrate. + * \param low_frequency_rumble the intensity of the low frequency (left) + * rumble motor, from 0 to 0xFFFF. + * \param high_frequency_rumble the intensity of the high frequency (right) + * rumble motor, from 0 to 0xFFFF. + * \param duration_ms the duration of the rumble effect, in milliseconds. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_RumbleGamepad(SDL_Gamepad *gamepad, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms); + +/** + * Start a rumble effect in the gamepad's triggers. + * + * Each call to this function cancels any previous trigger rumble effect, and + * calling it with 0 intensity stops any rumbling. + * + * Note that this is rumbling of the _triggers_ and not the gamepad as a + * whole. This is currently only supported on Xbox One gamepads. If you want + * the (more common) whole-gamepad rumble, use SDL_RumbleGamepad() instead. + * + * This function requires you to process SDL events or call + * SDL_UpdateJoysticks() to update rumble state. + * + * \param gamepad the gamepad to vibrate. + * \param left_rumble the intensity of the left trigger rumble motor, from 0 + * to 0xFFFF. + * \param right_rumble the intensity of the right trigger rumble motor, from 0 + * to 0xFFFF. + * \param duration_ms the duration of the rumble effect, in milliseconds. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_RumbleGamepad + */ +extern SDL_DECLSPEC bool SDLCALL SDL_RumbleGamepadTriggers(SDL_Gamepad *gamepad, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms); + +/** + * Update a gamepad's LED color. + * + * An example of a joystick LED is the light on the back of a PlayStation 4's + * DualShock 4 controller. + * + * For gamepads with a single color LED, the maximum of the RGB values will be + * used as the LED brightness. + * + * \param gamepad the gamepad to update. + * \param red the intensity of the red LED. + * \param green the intensity of the green LED. + * \param blue the intensity of the blue LED. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetGamepadLED(SDL_Gamepad *gamepad, Uint8 red, Uint8 green, Uint8 blue); + +/** + * Send a gamepad specific effect packet. + * + * \param gamepad the gamepad to affect. + * \param data the data to send to the gamepad. + * \param size the size of the data to send to the gamepad. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SendGamepadEffect(SDL_Gamepad *gamepad, const void *data, int size); + +/** + * Close a gamepad previously opened with SDL_OpenGamepad(). + * + * \param gamepad a gamepad identifier previously returned by + * SDL_OpenGamepad(). + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_OpenGamepad + */ +extern SDL_DECLSPEC void SDLCALL SDL_CloseGamepad(SDL_Gamepad *gamepad); + +/** + * Return the sfSymbolsName for a given button on a gamepad on Apple + * platforms. + * + * \param gamepad the gamepad to query. + * \param button a button on the gamepad. + * \returns the sfSymbolsName or NULL if the name can't be found. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetGamepadAppleSFSymbolsNameForAxis + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadAppleSFSymbolsNameForButton(SDL_Gamepad *gamepad, SDL_GamepadButton button); + +/** + * Return the sfSymbolsName for a given axis on a gamepad on Apple platforms. + * + * \param gamepad the gamepad to query. + * \param axis an axis on the gamepad. + * \returns the sfSymbolsName or NULL if the name can't be found. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetGamepadAppleSFSymbolsNameForButton + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadAppleSFSymbolsNameForAxis(SDL_Gamepad *gamepad, SDL_GamepadAxis axis); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_gamepad_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_gpu.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_gpu.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,4578 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* WIKI CATEGORY: GPU */ + +/** + * # CategoryGPU + * + * The GPU API offers a cross-platform way for apps to talk to modern graphics + * hardware. It offers both 3D graphics and compute support, in the style of + * Metal, Vulkan, and Direct3D 12. + * + * A basic workflow might be something like this: + * + * The app creates a GPU device with SDL_CreateGPUDevice(), and assigns it to + * a window with SDL_ClaimWindowForGPUDevice()--although strictly speaking you + * can render offscreen entirely, perhaps for image processing, and not use a + * window at all. + * + * Next, the app prepares static data (things that are created once and used + * over and over). For example: + * + * - Shaders (programs that run on the GPU): use SDL_CreateGPUShader(). + * - Vertex buffers (arrays of geometry data) and other rendering data: use + * SDL_CreateGPUBuffer() and SDL_UploadToGPUBuffer(). + * - Textures (images): use SDL_CreateGPUTexture() and + * SDL_UploadToGPUTexture(). + * - Samplers (how textures should be read from): use SDL_CreateGPUSampler(). + * - Render pipelines (precalculated rendering state): use + * SDL_CreateGPUGraphicsPipeline() + * + * To render, the app creates one or more command buffers, with + * SDL_AcquireGPUCommandBuffer(). Command buffers collect rendering + * instructions that will be submitted to the GPU in batch. Complex scenes can + * use multiple command buffers, maybe configured across multiple threads in + * parallel, as long as they are submitted in the correct order, but many apps + * will just need one command buffer per frame. + * + * Rendering can happen to a texture (what other APIs call a "render target") + * or it can happen to the swapchain texture (which is just a special texture + * that represents a window's contents). The app can use + * SDL_WaitAndAcquireGPUSwapchainTexture() to render to the window. + * + * Rendering actually happens in a Render Pass, which is encoded into a + * command buffer. One can encode multiple render passes (or alternate between + * render and compute passes) in a single command buffer, but many apps might + * simply need a single render pass in a single command buffer. Render Passes + * can render to up to four color textures and one depth texture + * simultaneously. If the set of textures being rendered to needs to change, + * the Render Pass must be ended and a new one must be begun. + * + * The app calls SDL_BeginGPURenderPass(). Then it sets states it needs for + * each draw: + * + * - SDL_BindGPUGraphicsPipeline() + * - SDL_SetGPUViewport() + * - SDL_BindGPUVertexBuffers() + * - SDL_BindGPUVertexSamplers() + * - etc + * + * Then, make the actual draw commands with these states: + * + * - SDL_DrawGPUPrimitives() + * - SDL_DrawGPUPrimitivesIndirect() + * - SDL_DrawGPUIndexedPrimitivesIndirect() + * - etc + * + * After all the drawing commands for a pass are complete, the app should call + * SDL_EndGPURenderPass(). Once a render pass ends all render-related state is + * reset. + * + * The app can begin new Render Passes and make new draws in the same command + * buffer until the entire scene is rendered. + * + * Once all of the render commands for the scene are complete, the app calls + * SDL_SubmitGPUCommandBuffer() to send it to the GPU for processing. + * + * If the app needs to read back data from texture or buffers, the API has an + * efficient way of doing this, provided that the app is willing to tolerate + * some latency. When the app uses SDL_DownloadFromGPUTexture() or + * SDL_DownloadFromGPUBuffer(), submitting the command buffer with + * SDL_SubmitGPUCommandBufferAndAcquireFence() will return a fence handle that + * the app can poll or wait on in a thread. Once the fence indicates that the + * command buffer is done processing, it is safe to read the downloaded data. + * Make sure to call SDL_ReleaseGPUFence() when done with the fence. + * + * The API also has "compute" support. The app calls SDL_BeginGPUComputePass() + * with compute-writeable textures and/or buffers, which can be written to in + * a compute shader. Then it sets states it needs for the compute dispatches: + * + * - SDL_BindGPUComputePipeline() + * - SDL_BindGPUComputeStorageBuffers() + * - SDL_BindGPUComputeStorageTextures() + * + * Then, dispatch compute work: + * + * - SDL_DispatchGPUCompute() + * + * For advanced users, this opens up powerful GPU-driven workflows. + * + * Graphics and compute pipelines require the use of shaders, which as + * mentioned above are small programs executed on the GPU. Each backend + * (Vulkan, Metal, D3D12) requires a different shader format. When the app + * creates the GPU device, the app lets the device know which shader formats + * the app can provide. It will then select the appropriate backend depending + * on the available shader formats and the backends available on the platform. + * When creating shaders, the app must provide the correct shader format for + * the selected backend. If you would like to learn more about why the API + * works this way, there is a detailed + * [blog post](https://moonside.games/posts/layers-all-the-way-down/) + * explaining this situation. + * + * It is optimal for apps to pre-compile the shader formats they might use, + * but for ease of use SDL provides a separate project, + * [SDL_shadercross](https://github.com/libsdl-org/SDL_shadercross) + * , for performing runtime shader cross-compilation. It also has a CLI + * interface for offline precompilation as well. + * + * This is an extremely quick overview that leaves out several important + * details. Already, though, one can see that GPU programming can be quite + * complex! If you just need simple 2D graphics, the + * [Render API](https://wiki.libsdl.org/SDL3/CategoryRender) + * is much easier to use but still hardware-accelerated. That said, even for + * 2D applications the performance benefits and expressiveness of the GPU API + * are significant. + * + * The GPU API targets a feature set with a wide range of hardware support and + * ease of portability. It is designed so that the app won't have to branch + * itself by querying feature support. If you need cutting-edge features with + * limited hardware support, this API is probably not for you. + * + * Examples demonstrating proper usage of this API can be found + * [here](https://github.com/TheSpydog/SDL_gpu_examples) + * . + * + * ## Performance considerations + * + * Here are some basic tips for maximizing your rendering performance. + * + * - Beginning a new render pass is relatively expensive. Use as few render + * passes as you can. + * - Minimize the amount of state changes. For example, binding a pipeline is + * relatively cheap, but doing it hundreds of times when you don't need to + * will slow the performance significantly. + * - Perform your data uploads as early as possible in the frame. + * - Don't churn resources. Creating and releasing resources is expensive. + * It's better to create what you need up front and cache it. + * - Don't use uniform buffers for large amounts of data (more than a matrix + * or so). Use a storage buffer instead. + * - Use cycling correctly. There is a detailed explanation of cycling further + * below. + * - Use culling techniques to minimize pixel writes. The less writing the GPU + * has to do the better. Culling can be a very advanced topic but even + * simple culling techniques can boost performance significantly. + * + * In general try to remember the golden rule of performance: doing things is + * more expensive than not doing things. Don't Touch The Driver! + * + * ## FAQ + * + * **Question: When are you adding more advanced features, like ray tracing or + * mesh shaders?** + * + * Answer: We don't have immediate plans to add more bleeding-edge features, + * but we certainly might in the future, when these features prove worthwhile, + * and reasonable to implement across several platforms and underlying APIs. + * So while these things are not in the "never" category, they are definitely + * not "near future" items either. + * + * **Question: Why is my shader not working?** + * + * Answer: A common oversight when using shaders is not properly laying out + * the shader resources/registers correctly. The GPU API is very strict with + * how it wants resources to be laid out and it's difficult for the API to + * automatically validate shaders to see if they have a compatible layout. See + * the documentation for SDL_CreateGPUShader() and + * SDL_CreateGPUComputePipeline() for information on the expected layout. + * + * Another common issue is not setting the correct number of samplers, + * textures, and buffers in SDL_GPUShaderCreateInfo. If possible use shader + * reflection to extract the required information from the shader + * automatically instead of manually filling in the struct's values. + * + * **Question: My application isn't performing very well. Is this the GPU + * API's fault?** + * + * Answer: No. Long answer: The GPU API is a relatively thin layer over the + * underlying graphics API. While it's possible that we have done something + * inefficiently, it's very unlikely especially if you are relatively + * inexperienced with GPU rendering. Please see the performance tips above and + * make sure you are following them. Additionally, tools like + * [RenderDoc](https://renderdoc.org/) + * can be very helpful for diagnosing incorrect behavior and performance + * issues. + * + * ## System Requirements + * + * ### Vulkan + * + * SDL driver name: "vulkan" (for use in SDL_CreateGPUDevice() and + * SDL_PROP_GPU_DEVICE_CREATE_NAME_STRING) + * + * Supported on Windows, Linux, Nintendo Switch, and certain Android devices. + * Requires Vulkan 1.0 with the following extensions and device features: + * + * - `VK_KHR_swapchain` + * - `VK_KHR_maintenance1` + * - `independentBlend` + * - `imageCubeArray` + * - `depthClamp` + * - `shaderClipDistance` + * - `drawIndirectFirstInstance` + * - `sampleRateShading` + * + * You can remove some of these requirements to increase compatibility with + * Android devices by using these properties when creating the GPU device with + * SDL_CreateGPUDeviceWithProperties(): + * + * - SDL_PROP_GPU_DEVICE_CREATE_FEATURE_CLIP_DISTANCE_BOOLEAN + * - SDL_PROP_GPU_DEVICE_CREATE_FEATURE_DEPTH_CLAMPING_BOOLEAN + * - SDL_PROP_GPU_DEVICE_CREATE_FEATURE_INDIRECT_DRAW_FIRST_INSTANCE_BOOLEAN + * - SDL_PROP_GPU_DEVICE_CREATE_FEATURE_ANISOTROPY_BOOLEAN + * + * ### D3D12 + * + * SDL driver name: "direct3d12" + * + * Supported on Windows 10 or newer, Xbox One (GDK), and Xbox Series X|S + * (GDK). Requires a GPU that supports DirectX 12 Feature Level 11_0 and + * Resource Binding Tier 2 or above. + * + * You can remove the Tier 2 resource binding requirement to support Intel + * Haswell and Broadwell GPUs by using this property when creating the GPU + * device with SDL_CreateGPUDeviceWithProperties(): + * + * - SDL_PROP_GPU_DEVICE_CREATE_D3D12_ALLOW_FEWER_RESOURCE_SLOTS_BOOLEAN + * + * ### Metal + * + * SDL driver name: "metal" + * + * Supported on macOS 10.14+ and iOS/tvOS 13.0+. Hardware requirements vary by + * operating system: + * + * - macOS requires an Apple Silicon or + * [Intel Mac2 family](https://developer.apple.com/documentation/metal/mtlfeatureset/mtlfeatureset_macos_gpufamily2_v1?language=objc) + * GPU + * - iOS/tvOS requires an A9 GPU or newer + * - iOS Simulator and tvOS Simulator are unsupported + * + * ## Coordinate System + * + * The GPU API uses a left-handed coordinate system, following the convention + * of D3D12 and Metal. Specifically: + * + * - **Normalized Device Coordinates:** The lower-left corner has an x,y + * coordinate of `(-1.0, -1.0)`. The upper-right corner is `(1.0, 1.0)`. Z + * values range from `[0.0, 1.0]` where 0 is the near plane. + * - **Viewport Coordinates:** The top-left corner has an x,y coordinate of + * `(0, 0)` and extends to the bottom-right corner at `(viewportWidth, + * viewportHeight)`. +Y is down. + * - **Texture Coordinates:** The top-left corner has an x,y coordinate of + * `(0, 0)` and extends to the bottom-right corner at `(1.0, 1.0)`. +Y is + * down. + * + * If the backend driver differs from this convention (e.g. Vulkan, which has + * an NDC that assumes +Y is down), SDL will automatically convert the + * coordinate system behind the scenes, so you don't need to perform any + * coordinate flipping logic in your shaders. + * + * ## Uniform Data + * + * Uniforms are for passing data to shaders. The uniform data will be constant + * across all executions of the shader. + * + * There are 4 available uniform slots per shader stage (where the stages are + * vertex, fragment, and compute). Uniform data pushed to a slot on a stage + * keeps its value throughout the command buffer until you call the relevant + * Push function on that slot again. + * + * For example, you could write your vertex shaders to read a camera matrix + * from uniform binding slot 0, push the camera matrix at the start of the + * command buffer, and that data will be used for every subsequent draw call. + * + * It is valid to push uniform data during a render or compute pass. + * + * Uniforms are best for pushing small amounts of data. If you are pushing + * more than a matrix or two per call you should consider using a storage + * buffer instead. + * + * ## A Note On Cycling + * + * When using a command buffer, operations do not occur immediately - they + * occur some time after the command buffer is submitted. + * + * When a resource is used in a pending or active command buffer, it is + * considered to be "bound". When a resource is no longer used in any pending + * or active command buffers, it is considered to be "unbound". + * + * If data resources are bound, it is unspecified when that data will be + * unbound unless you acquire a fence when submitting the command buffer and + * wait on it. However, this doesn't mean you need to track resource usage + * manually. + * + * All of the functions and structs that involve writing to a resource have a + * "cycle" bool. SDL_GPUTransferBuffer, SDL_GPUBuffer, and SDL_GPUTexture all + * effectively function as ring buffers on internal resources. When cycle is + * true, if the resource is bound, the cycle rotates to the next unbound + * internal resource, or if none are available, a new one is created. This + * means you don't have to worry about complex state tracking and + * synchronization as long as cycling is correctly employed. + * + * For example: you can call SDL_MapGPUTransferBuffer(), write texture data, + * SDL_UnmapGPUTransferBuffer(), and then SDL_UploadToGPUTexture(). The next + * time you write texture data to the transfer buffer, if you set the cycle + * param to true, you don't have to worry about overwriting any data that is + * not yet uploaded. + * + * Another example: If you are using a texture in a render pass every frame, + * this can cause a data dependency between frames. If you set cycle to true + * in the SDL_GPUColorTargetInfo struct, you can prevent this data dependency. + * + * Cycling will never undefine already bound data. When cycling, all data in + * the resource is considered to be undefined for subsequent commands until + * that data is written again. You must take care not to read undefined data. + * + * Note that when cycling a texture, the entire texture will be cycled, even + * if only part of the texture is used in the call, so you must consider the + * entire texture to contain undefined data after cycling. + * + * You must also take care not to overwrite a section of data that has been + * referenced in a command without cycling first. It is OK to overwrite + * unreferenced data in a bound resource without cycling, but overwriting a + * section of data that has already been referenced will produce unexpected + * results. + * + * ## Debugging + * + * At some point of your GPU journey, you will probably encounter issues that + * are not traceable with regular debugger - for example, your code compiles + * but you get an empty screen, or your shader fails in runtime. + * + * For debugging such cases, there are tools that allow visually inspecting + * the whole GPU frame, every drawcall, every bound resource, memory buffers, + * etc. They are the following, per platform: + * + * * For Windows/Linux, use + * [RenderDoc](https://renderdoc.org/) + * * For MacOS (Metal), use Xcode built-in debugger (Open XCode, go to Debug > + * Debug Executable..., select your application, set "GPU Frame Capture" to + * "Metal" in scheme "Options" window, run your app, and click the small + * Metal icon on the bottom to capture a frame) + * + * Aside from that, you may want to enable additional debug layers to receive + * more detailed error messages, based on your GPU backend: + * + * * For D3D12, the debug layer is an optional feature that can be installed + * via "Windows Settings -> System -> Optional features" and adding the + * "Graphics Tools" optional feature. + * * For Vulkan, you will need to install Vulkan SDK on Windows, and on Linux, + * you usually have some sort of `vulkan-validation-layers` system package + * that should be installed. + * * For Metal, it should be enough just to run the application from XCode to + * receive detailed errors or warnings in the output. + * + * Don't hesitate to use tools as RenderDoc when encountering runtime issues + * or unexpected output on screen, quick GPU frame inspection can usually help + * you fix the majority of such problems. + */ + +#ifndef SDL_gpu_h_ +#define SDL_gpu_h_ + +#include +#include +#include +#include +#include +#include + +#include +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Type Declarations */ + +/** + * An opaque handle representing the SDL_GPU context. + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_GPUDevice SDL_GPUDevice; + +/** + * An opaque handle representing a buffer. + * + * Used for vertices, indices, indirect draw commands, and general compute + * data. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUBuffer + * \sa SDL_UploadToGPUBuffer + * \sa SDL_DownloadFromGPUBuffer + * \sa SDL_CopyGPUBufferToBuffer + * \sa SDL_BindGPUVertexBuffers + * \sa SDL_BindGPUIndexBuffer + * \sa SDL_BindGPUVertexStorageBuffers + * \sa SDL_BindGPUFragmentStorageBuffers + * \sa SDL_DrawGPUPrimitivesIndirect + * \sa SDL_DrawGPUIndexedPrimitivesIndirect + * \sa SDL_BindGPUComputeStorageBuffers + * \sa SDL_DispatchGPUComputeIndirect + * \sa SDL_ReleaseGPUBuffer + */ +typedef struct SDL_GPUBuffer SDL_GPUBuffer; + +/** + * An opaque handle representing a transfer buffer. + * + * Used for transferring data to and from the device. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUTransferBuffer + * \sa SDL_MapGPUTransferBuffer + * \sa SDL_UnmapGPUTransferBuffer + * \sa SDL_UploadToGPUBuffer + * \sa SDL_UploadToGPUTexture + * \sa SDL_DownloadFromGPUBuffer + * \sa SDL_DownloadFromGPUTexture + * \sa SDL_ReleaseGPUTransferBuffer + */ +typedef struct SDL_GPUTransferBuffer SDL_GPUTransferBuffer; + +/** + * An opaque handle representing a texture. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUTexture + * \sa SDL_UploadToGPUTexture + * \sa SDL_DownloadFromGPUTexture + * \sa SDL_CopyGPUTextureToTexture + * \sa SDL_BindGPUVertexSamplers + * \sa SDL_BindGPUVertexStorageTextures + * \sa SDL_BindGPUFragmentSamplers + * \sa SDL_BindGPUFragmentStorageTextures + * \sa SDL_BindGPUComputeStorageTextures + * \sa SDL_GenerateMipmapsForGPUTexture + * \sa SDL_BlitGPUTexture + * \sa SDL_ReleaseGPUTexture + */ +typedef struct SDL_GPUTexture SDL_GPUTexture; + +/** + * An opaque handle representing a sampler. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUSampler + * \sa SDL_BindGPUVertexSamplers + * \sa SDL_BindGPUFragmentSamplers + * \sa SDL_ReleaseGPUSampler + */ +typedef struct SDL_GPUSampler SDL_GPUSampler; + +/** + * An opaque handle representing a compiled shader object. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUShader + * \sa SDL_CreateGPUGraphicsPipeline + * \sa SDL_ReleaseGPUShader + */ +typedef struct SDL_GPUShader SDL_GPUShader; + +/** + * An opaque handle representing a compute pipeline. + * + * Used during compute passes. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUComputePipeline + * \sa SDL_BindGPUComputePipeline + * \sa SDL_ReleaseGPUComputePipeline + */ +typedef struct SDL_GPUComputePipeline SDL_GPUComputePipeline; + +/** + * An opaque handle representing a graphics pipeline. + * + * Used during render passes. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUGraphicsPipeline + * \sa SDL_BindGPUGraphicsPipeline + * \sa SDL_ReleaseGPUGraphicsPipeline + */ +typedef struct SDL_GPUGraphicsPipeline SDL_GPUGraphicsPipeline; + +/** + * An opaque handle representing a command buffer. + * + * Most state is managed via command buffers. When setting state using a + * command buffer, that state is local to the command buffer. + * + * Commands only begin execution on the GPU once SDL_SubmitGPUCommandBuffer is + * called. Once the command buffer is submitted, it is no longer valid to use + * it. + * + * Command buffers are executed in submission order. If you submit command + * buffer A and then command buffer B all commands in A will begin executing + * before any command in B begins executing. + * + * In multi-threading scenarios, you should only access a command buffer on + * the thread you acquired it from. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_AcquireGPUCommandBuffer + * \sa SDL_SubmitGPUCommandBuffer + * \sa SDL_SubmitGPUCommandBufferAndAcquireFence + */ +typedef struct SDL_GPUCommandBuffer SDL_GPUCommandBuffer; + +/** + * An opaque handle representing a render pass. + * + * This handle is transient and should not be held or referenced after + * SDL_EndGPURenderPass is called. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_BeginGPURenderPass + * \sa SDL_EndGPURenderPass + */ +typedef struct SDL_GPURenderPass SDL_GPURenderPass; + +/** + * An opaque handle representing a compute pass. + * + * This handle is transient and should not be held or referenced after + * SDL_EndGPUComputePass is called. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_BeginGPUComputePass + * \sa SDL_EndGPUComputePass + */ +typedef struct SDL_GPUComputePass SDL_GPUComputePass; + +/** + * An opaque handle representing a copy pass. + * + * This handle is transient and should not be held or referenced after + * SDL_EndGPUCopyPass is called. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_BeginGPUCopyPass + * \sa SDL_EndGPUCopyPass + */ +typedef struct SDL_GPUCopyPass SDL_GPUCopyPass; + +/** + * An opaque handle representing a fence. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_SubmitGPUCommandBufferAndAcquireFence + * \sa SDL_QueryGPUFence + * \sa SDL_WaitForGPUFences + * \sa SDL_ReleaseGPUFence + */ +typedef struct SDL_GPUFence SDL_GPUFence; + +/** + * Specifies the primitive topology of a graphics pipeline. + * + * If you are using POINTLIST you must include a point size output in the + * vertex shader. + * + * - For HLSL compiling to SPIRV you must decorate a float output with + * [[vk::builtin("PointSize")]]. + * - For GLSL you must set the gl_PointSize builtin. + * - For MSL you must include a float output with the [[point_size]] + * decorator. + * + * Note that sized point topology is totally unsupported on D3D12. Any size + * other than 1 will be ignored. In general, you should avoid using point + * topology for both compatibility and performance reasons. You WILL regret + * using it. + * + * \since This enum is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUGraphicsPipeline + */ +typedef enum SDL_GPUPrimitiveType +{ + SDL_GPU_PRIMITIVETYPE_TRIANGLELIST, /**< A series of separate triangles. */ + SDL_GPU_PRIMITIVETYPE_TRIANGLESTRIP, /**< A series of connected triangles. */ + SDL_GPU_PRIMITIVETYPE_LINELIST, /**< A series of separate lines. */ + SDL_GPU_PRIMITIVETYPE_LINESTRIP, /**< A series of connected lines. */ + SDL_GPU_PRIMITIVETYPE_POINTLIST /**< A series of separate points. */ +} SDL_GPUPrimitiveType; + +/** + * Specifies how the contents of a texture attached to a render pass are + * treated at the beginning of the render pass. + * + * \since This enum is available since SDL 3.2.0. + * + * \sa SDL_BeginGPURenderPass + */ +typedef enum SDL_GPULoadOp +{ + SDL_GPU_LOADOP_LOAD, /**< The previous contents of the texture will be preserved. */ + SDL_GPU_LOADOP_CLEAR, /**< The contents of the texture will be cleared to a color. */ + SDL_GPU_LOADOP_DONT_CARE /**< The previous contents of the texture need not be preserved. The contents will be undefined. */ +} SDL_GPULoadOp; + +/** + * Specifies how the contents of a texture attached to a render pass are + * treated at the end of the render pass. + * + * \since This enum is available since SDL 3.2.0. + * + * \sa SDL_BeginGPURenderPass + */ +typedef enum SDL_GPUStoreOp +{ + SDL_GPU_STOREOP_STORE, /**< The contents generated during the render pass will be written to memory. */ + SDL_GPU_STOREOP_DONT_CARE, /**< The contents generated during the render pass are not needed and may be discarded. The contents will be undefined. */ + SDL_GPU_STOREOP_RESOLVE, /**< The multisample contents generated during the render pass will be resolved to a non-multisample texture. The contents in the multisample texture may then be discarded and will be undefined. */ + SDL_GPU_STOREOP_RESOLVE_AND_STORE /**< The multisample contents generated during the render pass will be resolved to a non-multisample texture. The contents in the multisample texture will be written to memory. */ +} SDL_GPUStoreOp; + +/** + * Specifies the size of elements in an index buffer. + * + * \since This enum is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUGraphicsPipeline + */ +typedef enum SDL_GPUIndexElementSize +{ + SDL_GPU_INDEXELEMENTSIZE_16BIT, /**< The index elements are 16-bit. */ + SDL_GPU_INDEXELEMENTSIZE_32BIT /**< The index elements are 32-bit. */ +} SDL_GPUIndexElementSize; + +/** + * Specifies the pixel format of a texture. + * + * Texture format support varies depending on driver, hardware, and usage + * flags. In general, you should use SDL_GPUTextureSupportsFormat to query if + * a format is supported before using it. However, there are a few guaranteed + * formats. + * + * FIXME: Check universal support for 32-bit component formats FIXME: Check + * universal support for SIMULTANEOUS_READ_WRITE + * + * For SAMPLER usage, the following formats are universally supported: + * + * - R8G8B8A8_UNORM + * - B8G8R8A8_UNORM + * - R8_UNORM + * - R8_SNORM + * - R8G8_UNORM + * - R8G8_SNORM + * - R8G8B8A8_SNORM + * - R16_FLOAT + * - R16G16_FLOAT + * - R16G16B16A16_FLOAT + * - R32_FLOAT + * - R32G32_FLOAT + * - R32G32B32A32_FLOAT + * - R11G11B10_UFLOAT + * - R8G8B8A8_UNORM_SRGB + * - B8G8R8A8_UNORM_SRGB + * - D16_UNORM + * + * For COLOR_TARGET usage, the following formats are universally supported: + * + * - R8G8B8A8_UNORM + * - B8G8R8A8_UNORM + * - R8_UNORM + * - R16_FLOAT + * - R16G16_FLOAT + * - R16G16B16A16_FLOAT + * - R32_FLOAT + * - R32G32_FLOAT + * - R32G32B32A32_FLOAT + * - R8_UINT + * - R8G8_UINT + * - R8G8B8A8_UINT + * - R16_UINT + * - R16G16_UINT + * - R16G16B16A16_UINT + * - R8_INT + * - R8G8_INT + * - R8G8B8A8_INT + * - R16_INT + * - R16G16_INT + * - R16G16B16A16_INT + * - R8G8B8A8_UNORM_SRGB + * - B8G8R8A8_UNORM_SRGB + * + * For STORAGE usages, the following formats are universally supported: + * + * - R8G8B8A8_UNORM + * - R8G8B8A8_SNORM + * - R16G16B16A16_FLOAT + * - R32_FLOAT + * - R32G32_FLOAT + * - R32G32B32A32_FLOAT + * - R8G8B8A8_UINT + * - R16G16B16A16_UINT + * - R8G8B8A8_INT + * - R16G16B16A16_INT + * + * For DEPTH_STENCIL_TARGET usage, the following formats are universally + * supported: + * + * - D16_UNORM + * - Either (but not necessarily both!) D24_UNORM or D32_FLOAT + * - Either (but not necessarily both!) D24_UNORM_S8_UINT or D32_FLOAT_S8_UINT + * + * Unless D16_UNORM is sufficient for your purposes, always check which of + * D24/D32 is supported before creating a depth-stencil texture! + * + * \since This enum is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUTexture + * \sa SDL_GPUTextureSupportsFormat + */ +typedef enum SDL_GPUTextureFormat +{ + SDL_GPU_TEXTUREFORMAT_INVALID, + + /* Unsigned Normalized Float Color Formats */ + SDL_GPU_TEXTUREFORMAT_A8_UNORM, + SDL_GPU_TEXTUREFORMAT_R8_UNORM, + SDL_GPU_TEXTUREFORMAT_R8G8_UNORM, + SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM, + SDL_GPU_TEXTUREFORMAT_R16_UNORM, + SDL_GPU_TEXTUREFORMAT_R16G16_UNORM, + SDL_GPU_TEXTUREFORMAT_R16G16B16A16_UNORM, + SDL_GPU_TEXTUREFORMAT_R10G10B10A2_UNORM, + SDL_GPU_TEXTUREFORMAT_B5G6R5_UNORM, + SDL_GPU_TEXTUREFORMAT_B5G5R5A1_UNORM, + SDL_GPU_TEXTUREFORMAT_B4G4R4A4_UNORM, + SDL_GPU_TEXTUREFORMAT_B8G8R8A8_UNORM, + /* Compressed Unsigned Normalized Float Color Formats */ + SDL_GPU_TEXTUREFORMAT_BC1_RGBA_UNORM, + SDL_GPU_TEXTUREFORMAT_BC2_RGBA_UNORM, + SDL_GPU_TEXTUREFORMAT_BC3_RGBA_UNORM, + SDL_GPU_TEXTUREFORMAT_BC4_R_UNORM, + SDL_GPU_TEXTUREFORMAT_BC5_RG_UNORM, + SDL_GPU_TEXTUREFORMAT_BC7_RGBA_UNORM, + /* Compressed Signed Float Color Formats */ + SDL_GPU_TEXTUREFORMAT_BC6H_RGB_FLOAT, + /* Compressed Unsigned Float Color Formats */ + SDL_GPU_TEXTUREFORMAT_BC6H_RGB_UFLOAT, + /* Signed Normalized Float Color Formats */ + SDL_GPU_TEXTUREFORMAT_R8_SNORM, + SDL_GPU_TEXTUREFORMAT_R8G8_SNORM, + SDL_GPU_TEXTUREFORMAT_R8G8B8A8_SNORM, + SDL_GPU_TEXTUREFORMAT_R16_SNORM, + SDL_GPU_TEXTUREFORMAT_R16G16_SNORM, + SDL_GPU_TEXTUREFORMAT_R16G16B16A16_SNORM, + /* Signed Float Color Formats */ + SDL_GPU_TEXTUREFORMAT_R16_FLOAT, + SDL_GPU_TEXTUREFORMAT_R16G16_FLOAT, + SDL_GPU_TEXTUREFORMAT_R16G16B16A16_FLOAT, + SDL_GPU_TEXTUREFORMAT_R32_FLOAT, + SDL_GPU_TEXTUREFORMAT_R32G32_FLOAT, + SDL_GPU_TEXTUREFORMAT_R32G32B32A32_FLOAT, + /* Unsigned Float Color Formats */ + SDL_GPU_TEXTUREFORMAT_R11G11B10_UFLOAT, + /* Unsigned Integer Color Formats */ + SDL_GPU_TEXTUREFORMAT_R8_UINT, + SDL_GPU_TEXTUREFORMAT_R8G8_UINT, + SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UINT, + SDL_GPU_TEXTUREFORMAT_R16_UINT, + SDL_GPU_TEXTUREFORMAT_R16G16_UINT, + SDL_GPU_TEXTUREFORMAT_R16G16B16A16_UINT, + SDL_GPU_TEXTUREFORMAT_R32_UINT, + SDL_GPU_TEXTUREFORMAT_R32G32_UINT, + SDL_GPU_TEXTUREFORMAT_R32G32B32A32_UINT, + /* Signed Integer Color Formats */ + SDL_GPU_TEXTUREFORMAT_R8_INT, + SDL_GPU_TEXTUREFORMAT_R8G8_INT, + SDL_GPU_TEXTUREFORMAT_R8G8B8A8_INT, + SDL_GPU_TEXTUREFORMAT_R16_INT, + SDL_GPU_TEXTUREFORMAT_R16G16_INT, + SDL_GPU_TEXTUREFORMAT_R16G16B16A16_INT, + SDL_GPU_TEXTUREFORMAT_R32_INT, + SDL_GPU_TEXTUREFORMAT_R32G32_INT, + SDL_GPU_TEXTUREFORMAT_R32G32B32A32_INT, + /* SRGB Unsigned Normalized Color Formats */ + SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM_SRGB, + SDL_GPU_TEXTUREFORMAT_B8G8R8A8_UNORM_SRGB, + /* Compressed SRGB Unsigned Normalized Color Formats */ + SDL_GPU_TEXTUREFORMAT_BC1_RGBA_UNORM_SRGB, + SDL_GPU_TEXTUREFORMAT_BC2_RGBA_UNORM_SRGB, + SDL_GPU_TEXTUREFORMAT_BC3_RGBA_UNORM_SRGB, + SDL_GPU_TEXTUREFORMAT_BC7_RGBA_UNORM_SRGB, + /* Depth Formats */ + SDL_GPU_TEXTUREFORMAT_D16_UNORM, + SDL_GPU_TEXTUREFORMAT_D24_UNORM, + SDL_GPU_TEXTUREFORMAT_D32_FLOAT, + SDL_GPU_TEXTUREFORMAT_D24_UNORM_S8_UINT, + SDL_GPU_TEXTUREFORMAT_D32_FLOAT_S8_UINT, + /* Compressed ASTC Normalized Float Color Formats*/ + SDL_GPU_TEXTUREFORMAT_ASTC_4x4_UNORM, + SDL_GPU_TEXTUREFORMAT_ASTC_5x4_UNORM, + SDL_GPU_TEXTUREFORMAT_ASTC_5x5_UNORM, + SDL_GPU_TEXTUREFORMAT_ASTC_6x5_UNORM, + SDL_GPU_TEXTUREFORMAT_ASTC_6x6_UNORM, + SDL_GPU_TEXTUREFORMAT_ASTC_8x5_UNORM, + SDL_GPU_TEXTUREFORMAT_ASTC_8x6_UNORM, + SDL_GPU_TEXTUREFORMAT_ASTC_8x8_UNORM, + SDL_GPU_TEXTUREFORMAT_ASTC_10x5_UNORM, + SDL_GPU_TEXTUREFORMAT_ASTC_10x6_UNORM, + SDL_GPU_TEXTUREFORMAT_ASTC_10x8_UNORM, + SDL_GPU_TEXTUREFORMAT_ASTC_10x10_UNORM, + SDL_GPU_TEXTUREFORMAT_ASTC_12x10_UNORM, + SDL_GPU_TEXTUREFORMAT_ASTC_12x12_UNORM, + /* Compressed SRGB ASTC Normalized Float Color Formats*/ + SDL_GPU_TEXTUREFORMAT_ASTC_4x4_UNORM_SRGB, + SDL_GPU_TEXTUREFORMAT_ASTC_5x4_UNORM_SRGB, + SDL_GPU_TEXTUREFORMAT_ASTC_5x5_UNORM_SRGB, + SDL_GPU_TEXTUREFORMAT_ASTC_6x5_UNORM_SRGB, + SDL_GPU_TEXTUREFORMAT_ASTC_6x6_UNORM_SRGB, + SDL_GPU_TEXTUREFORMAT_ASTC_8x5_UNORM_SRGB, + SDL_GPU_TEXTUREFORMAT_ASTC_8x6_UNORM_SRGB, + SDL_GPU_TEXTUREFORMAT_ASTC_8x8_UNORM_SRGB, + SDL_GPU_TEXTUREFORMAT_ASTC_10x5_UNORM_SRGB, + SDL_GPU_TEXTUREFORMAT_ASTC_10x6_UNORM_SRGB, + SDL_GPU_TEXTUREFORMAT_ASTC_10x8_UNORM_SRGB, + SDL_GPU_TEXTUREFORMAT_ASTC_10x10_UNORM_SRGB, + SDL_GPU_TEXTUREFORMAT_ASTC_12x10_UNORM_SRGB, + SDL_GPU_TEXTUREFORMAT_ASTC_12x12_UNORM_SRGB, + /* Compressed ASTC Signed Float Color Formats*/ + SDL_GPU_TEXTUREFORMAT_ASTC_4x4_FLOAT, + SDL_GPU_TEXTUREFORMAT_ASTC_5x4_FLOAT, + SDL_GPU_TEXTUREFORMAT_ASTC_5x5_FLOAT, + SDL_GPU_TEXTUREFORMAT_ASTC_6x5_FLOAT, + SDL_GPU_TEXTUREFORMAT_ASTC_6x6_FLOAT, + SDL_GPU_TEXTUREFORMAT_ASTC_8x5_FLOAT, + SDL_GPU_TEXTUREFORMAT_ASTC_8x6_FLOAT, + SDL_GPU_TEXTUREFORMAT_ASTC_8x8_FLOAT, + SDL_GPU_TEXTUREFORMAT_ASTC_10x5_FLOAT, + SDL_GPU_TEXTUREFORMAT_ASTC_10x6_FLOAT, + SDL_GPU_TEXTUREFORMAT_ASTC_10x8_FLOAT, + SDL_GPU_TEXTUREFORMAT_ASTC_10x10_FLOAT, + SDL_GPU_TEXTUREFORMAT_ASTC_12x10_FLOAT, + SDL_GPU_TEXTUREFORMAT_ASTC_12x12_FLOAT +} SDL_GPUTextureFormat; + +/** + * Specifies how a texture is intended to be used by the client. + * + * A texture must have at least one usage flag. Note that some usage flag + * combinations are invalid. + * + * With regards to compute storage usage, READ | WRITE means that you can have + * shader A that only writes into the texture and shader B that only reads + * from the texture and bind the same texture to either shader respectively. + * SIMULTANEOUS means that you can do reads and writes within the same shader + * or compute pass. It also implies that atomic ops can be used, since those + * are read-modify-write operations. If you use SIMULTANEOUS, you are + * responsible for avoiding data races, as there is no data synchronization + * within a compute pass. Note that SIMULTANEOUS usage is only supported by a + * limited number of texture formats. + * + * \since This datatype is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUTexture + */ +typedef Uint32 SDL_GPUTextureUsageFlags; + +#define SDL_GPU_TEXTUREUSAGE_SAMPLER (1u << 0) /**< Texture supports sampling. */ +#define SDL_GPU_TEXTUREUSAGE_COLOR_TARGET (1u << 1) /**< Texture is a color render target. */ +#define SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET (1u << 2) /**< Texture is a depth stencil target. */ +#define SDL_GPU_TEXTUREUSAGE_GRAPHICS_STORAGE_READ (1u << 3) /**< Texture supports storage reads in graphics stages. */ +#define SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_READ (1u << 4) /**< Texture supports storage reads in the compute stage. */ +#define SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_WRITE (1u << 5) /**< Texture supports storage writes in the compute stage. */ +#define SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_SIMULTANEOUS_READ_WRITE (1u << 6) /**< Texture supports reads and writes in the same compute shader. This is NOT equivalent to READ | WRITE. */ + +/** + * Specifies the type of a texture. + * + * \since This enum is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUTexture + */ +typedef enum SDL_GPUTextureType +{ + SDL_GPU_TEXTURETYPE_2D, /**< The texture is a 2-dimensional image. */ + SDL_GPU_TEXTURETYPE_2D_ARRAY, /**< The texture is a 2-dimensional array image. */ + SDL_GPU_TEXTURETYPE_3D, /**< The texture is a 3-dimensional image. */ + SDL_GPU_TEXTURETYPE_CUBE, /**< The texture is a cube image. */ + SDL_GPU_TEXTURETYPE_CUBE_ARRAY /**< The texture is a cube array image. */ +} SDL_GPUTextureType; + +/** + * Specifies the sample count of a texture. + * + * Used in multisampling. Note that this value only applies when the texture + * is used as a render target. + * + * \since This enum is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUTexture + * \sa SDL_GPUTextureSupportsSampleCount + */ +typedef enum SDL_GPUSampleCount +{ + SDL_GPU_SAMPLECOUNT_1, /**< No multisampling. */ + SDL_GPU_SAMPLECOUNT_2, /**< MSAA 2x */ + SDL_GPU_SAMPLECOUNT_4, /**< MSAA 4x */ + SDL_GPU_SAMPLECOUNT_8 /**< MSAA 8x */ +} SDL_GPUSampleCount; + + +/** + * Specifies the face of a cube map. + * + * Can be passed in as the layer field in texture-related structs. + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_GPUCubeMapFace +{ + SDL_GPU_CUBEMAPFACE_POSITIVEX, + SDL_GPU_CUBEMAPFACE_NEGATIVEX, + SDL_GPU_CUBEMAPFACE_POSITIVEY, + SDL_GPU_CUBEMAPFACE_NEGATIVEY, + SDL_GPU_CUBEMAPFACE_POSITIVEZ, + SDL_GPU_CUBEMAPFACE_NEGATIVEZ +} SDL_GPUCubeMapFace; + +/** + * Specifies how a buffer is intended to be used by the client. + * + * A buffer must have at least one usage flag. Note that some usage flag + * combinations are invalid. + * + * Unlike textures, READ | WRITE can be used for simultaneous read-write + * usage. The same data synchronization concerns as textures apply. + * + * If you use a STORAGE flag, the data in the buffer must respect std140 + * layout conventions. In practical terms this means you must ensure that vec3 + * and vec4 fields are 16-byte aligned. + * + * \since This datatype is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUBuffer + */ +typedef Uint32 SDL_GPUBufferUsageFlags; + +#define SDL_GPU_BUFFERUSAGE_VERTEX (1u << 0) /**< Buffer is a vertex buffer. */ +#define SDL_GPU_BUFFERUSAGE_INDEX (1u << 1) /**< Buffer is an index buffer. */ +#define SDL_GPU_BUFFERUSAGE_INDIRECT (1u << 2) /**< Buffer is an indirect buffer. */ +#define SDL_GPU_BUFFERUSAGE_GRAPHICS_STORAGE_READ (1u << 3) /**< Buffer supports storage reads in graphics stages. */ +#define SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_READ (1u << 4) /**< Buffer supports storage reads in the compute stage. */ +#define SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_WRITE (1u << 5) /**< Buffer supports storage writes in the compute stage. */ + +/** + * Specifies how a transfer buffer is intended to be used by the client. + * + * Note that mapping and copying FROM an upload transfer buffer or TO a + * download transfer buffer is undefined behavior. + * + * \since This enum is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUTransferBuffer + */ +typedef enum SDL_GPUTransferBufferUsage +{ + SDL_GPU_TRANSFERBUFFERUSAGE_UPLOAD, + SDL_GPU_TRANSFERBUFFERUSAGE_DOWNLOAD +} SDL_GPUTransferBufferUsage; + +/** + * Specifies which stage a shader program corresponds to. + * + * \since This enum is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUShader + */ +typedef enum SDL_GPUShaderStage +{ + SDL_GPU_SHADERSTAGE_VERTEX, + SDL_GPU_SHADERSTAGE_FRAGMENT +} SDL_GPUShaderStage; + +/** + * Specifies the format of shader code. + * + * Each format corresponds to a specific backend that accepts it. + * + * \since This datatype is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUShader + */ +typedef Uint32 SDL_GPUShaderFormat; + +#define SDL_GPU_SHADERFORMAT_INVALID 0 +#define SDL_GPU_SHADERFORMAT_PRIVATE (1u << 0) /**< Shaders for NDA'd platforms. */ +#define SDL_GPU_SHADERFORMAT_SPIRV (1u << 1) /**< SPIR-V shaders for Vulkan. */ +#define SDL_GPU_SHADERFORMAT_DXBC (1u << 2) /**< DXBC SM5_1 shaders for D3D12. */ +#define SDL_GPU_SHADERFORMAT_DXIL (1u << 3) /**< DXIL SM6_0 shaders for D3D12. */ +#define SDL_GPU_SHADERFORMAT_MSL (1u << 4) /**< MSL shaders for Metal. */ +#define SDL_GPU_SHADERFORMAT_METALLIB (1u << 5) /**< Precompiled metallib shaders for Metal. */ + +/** + * Specifies the format of a vertex attribute. + * + * \since This enum is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUGraphicsPipeline + */ +typedef enum SDL_GPUVertexElementFormat +{ + SDL_GPU_VERTEXELEMENTFORMAT_INVALID, + + /* 32-bit Signed Integers */ + SDL_GPU_VERTEXELEMENTFORMAT_INT, + SDL_GPU_VERTEXELEMENTFORMAT_INT2, + SDL_GPU_VERTEXELEMENTFORMAT_INT3, + SDL_GPU_VERTEXELEMENTFORMAT_INT4, + + /* 32-bit Unsigned Integers */ + SDL_GPU_VERTEXELEMENTFORMAT_UINT, + SDL_GPU_VERTEXELEMENTFORMAT_UINT2, + SDL_GPU_VERTEXELEMENTFORMAT_UINT3, + SDL_GPU_VERTEXELEMENTFORMAT_UINT4, + + /* 32-bit Floats */ + SDL_GPU_VERTEXELEMENTFORMAT_FLOAT, + SDL_GPU_VERTEXELEMENTFORMAT_FLOAT2, + SDL_GPU_VERTEXELEMENTFORMAT_FLOAT3, + SDL_GPU_VERTEXELEMENTFORMAT_FLOAT4, + + /* 8-bit Signed Integers */ + SDL_GPU_VERTEXELEMENTFORMAT_BYTE2, + SDL_GPU_VERTEXELEMENTFORMAT_BYTE4, + + /* 8-bit Unsigned Integers */ + SDL_GPU_VERTEXELEMENTFORMAT_UBYTE2, + SDL_GPU_VERTEXELEMENTFORMAT_UBYTE4, + + /* 8-bit Signed Normalized */ + SDL_GPU_VERTEXELEMENTFORMAT_BYTE2_NORM, + SDL_GPU_VERTEXELEMENTFORMAT_BYTE4_NORM, + + /* 8-bit Unsigned Normalized */ + SDL_GPU_VERTEXELEMENTFORMAT_UBYTE2_NORM, + SDL_GPU_VERTEXELEMENTFORMAT_UBYTE4_NORM, + + /* 16-bit Signed Integers */ + SDL_GPU_VERTEXELEMENTFORMAT_SHORT2, + SDL_GPU_VERTEXELEMENTFORMAT_SHORT4, + + /* 16-bit Unsigned Integers */ + SDL_GPU_VERTEXELEMENTFORMAT_USHORT2, + SDL_GPU_VERTEXELEMENTFORMAT_USHORT4, + + /* 16-bit Signed Normalized */ + SDL_GPU_VERTEXELEMENTFORMAT_SHORT2_NORM, + SDL_GPU_VERTEXELEMENTFORMAT_SHORT4_NORM, + + /* 16-bit Unsigned Normalized */ + SDL_GPU_VERTEXELEMENTFORMAT_USHORT2_NORM, + SDL_GPU_VERTEXELEMENTFORMAT_USHORT4_NORM, + + /* 16-bit Floats */ + SDL_GPU_VERTEXELEMENTFORMAT_HALF2, + SDL_GPU_VERTEXELEMENTFORMAT_HALF4 +} SDL_GPUVertexElementFormat; + +/** + * Specifies the rate at which vertex attributes are pulled from buffers. + * + * \since This enum is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUGraphicsPipeline + */ +typedef enum SDL_GPUVertexInputRate +{ + SDL_GPU_VERTEXINPUTRATE_VERTEX, /**< Attribute addressing is a function of the vertex index. */ + SDL_GPU_VERTEXINPUTRATE_INSTANCE /**< Attribute addressing is a function of the instance index. */ +} SDL_GPUVertexInputRate; + +/** + * Specifies the fill mode of the graphics pipeline. + * + * \since This enum is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUGraphicsPipeline + */ +typedef enum SDL_GPUFillMode +{ + SDL_GPU_FILLMODE_FILL, /**< Polygons will be rendered via rasterization. */ + SDL_GPU_FILLMODE_LINE /**< Polygon edges will be drawn as line segments. */ +} SDL_GPUFillMode; + +/** + * Specifies the facing direction in which triangle faces will be culled. + * + * \since This enum is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUGraphicsPipeline + */ +typedef enum SDL_GPUCullMode +{ + SDL_GPU_CULLMODE_NONE, /**< No triangles are culled. */ + SDL_GPU_CULLMODE_FRONT, /**< Front-facing triangles are culled. */ + SDL_GPU_CULLMODE_BACK /**< Back-facing triangles are culled. */ +} SDL_GPUCullMode; + +/** + * Specifies the vertex winding that will cause a triangle to be determined to + * be front-facing. + * + * \since This enum is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUGraphicsPipeline + */ +typedef enum SDL_GPUFrontFace +{ + SDL_GPU_FRONTFACE_COUNTER_CLOCKWISE, /**< A triangle with counter-clockwise vertex winding will be considered front-facing. */ + SDL_GPU_FRONTFACE_CLOCKWISE /**< A triangle with clockwise vertex winding will be considered front-facing. */ +} SDL_GPUFrontFace; + +/** + * Specifies a comparison operator for depth, stencil and sampler operations. + * + * \since This enum is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUGraphicsPipeline + */ +typedef enum SDL_GPUCompareOp +{ + SDL_GPU_COMPAREOP_INVALID, + SDL_GPU_COMPAREOP_NEVER, /**< The comparison always evaluates false. */ + SDL_GPU_COMPAREOP_LESS, /**< The comparison evaluates reference < test. */ + SDL_GPU_COMPAREOP_EQUAL, /**< The comparison evaluates reference == test. */ + SDL_GPU_COMPAREOP_LESS_OR_EQUAL, /**< The comparison evaluates reference <= test. */ + SDL_GPU_COMPAREOP_GREATER, /**< The comparison evaluates reference > test. */ + SDL_GPU_COMPAREOP_NOT_EQUAL, /**< The comparison evaluates reference != test. */ + SDL_GPU_COMPAREOP_GREATER_OR_EQUAL, /**< The comparison evaluates reference >= test. */ + SDL_GPU_COMPAREOP_ALWAYS /**< The comparison always evaluates true. */ +} SDL_GPUCompareOp; + +/** + * Specifies what happens to a stored stencil value if stencil tests fail or + * pass. + * + * \since This enum is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUGraphicsPipeline + */ +typedef enum SDL_GPUStencilOp +{ + SDL_GPU_STENCILOP_INVALID, + SDL_GPU_STENCILOP_KEEP, /**< Keeps the current value. */ + SDL_GPU_STENCILOP_ZERO, /**< Sets the value to 0. */ + SDL_GPU_STENCILOP_REPLACE, /**< Sets the value to reference. */ + SDL_GPU_STENCILOP_INCREMENT_AND_CLAMP, /**< Increments the current value and clamps to the maximum value. */ + SDL_GPU_STENCILOP_DECREMENT_AND_CLAMP, /**< Decrements the current value and clamps to 0. */ + SDL_GPU_STENCILOP_INVERT, /**< Bitwise-inverts the current value. */ + SDL_GPU_STENCILOP_INCREMENT_AND_WRAP, /**< Increments the current value and wraps back to 0. */ + SDL_GPU_STENCILOP_DECREMENT_AND_WRAP /**< Decrements the current value and wraps to the maximum value. */ +} SDL_GPUStencilOp; + +/** + * Specifies the operator to be used when pixels in a render target are + * blended with existing pixels in the texture. + * + * The source color is the value written by the fragment shader. The + * destination color is the value currently existing in the texture. + * + * \since This enum is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUGraphicsPipeline + */ +typedef enum SDL_GPUBlendOp +{ + SDL_GPU_BLENDOP_INVALID, + SDL_GPU_BLENDOP_ADD, /**< (source * source_factor) + (destination * destination_factor) */ + SDL_GPU_BLENDOP_SUBTRACT, /**< (source * source_factor) - (destination * destination_factor) */ + SDL_GPU_BLENDOP_REVERSE_SUBTRACT, /**< (destination * destination_factor) - (source * source_factor) */ + SDL_GPU_BLENDOP_MIN, /**< min(source, destination) */ + SDL_GPU_BLENDOP_MAX /**< max(source, destination) */ +} SDL_GPUBlendOp; + +/** + * Specifies a blending factor to be used when pixels in a render target are + * blended with existing pixels in the texture. + * + * The source color is the value written by the fragment shader. The + * destination color is the value currently existing in the texture. + * + * \since This enum is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUGraphicsPipeline + */ +typedef enum SDL_GPUBlendFactor +{ + SDL_GPU_BLENDFACTOR_INVALID, + SDL_GPU_BLENDFACTOR_ZERO, /**< 0 */ + SDL_GPU_BLENDFACTOR_ONE, /**< 1 */ + SDL_GPU_BLENDFACTOR_SRC_COLOR, /**< source color */ + SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_COLOR, /**< 1 - source color */ + SDL_GPU_BLENDFACTOR_DST_COLOR, /**< destination color */ + SDL_GPU_BLENDFACTOR_ONE_MINUS_DST_COLOR, /**< 1 - destination color */ + SDL_GPU_BLENDFACTOR_SRC_ALPHA, /**< source alpha */ + SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, /**< 1 - source alpha */ + SDL_GPU_BLENDFACTOR_DST_ALPHA, /**< destination alpha */ + SDL_GPU_BLENDFACTOR_ONE_MINUS_DST_ALPHA, /**< 1 - destination alpha */ + SDL_GPU_BLENDFACTOR_CONSTANT_COLOR, /**< blend constant */ + SDL_GPU_BLENDFACTOR_ONE_MINUS_CONSTANT_COLOR, /**< 1 - blend constant */ + SDL_GPU_BLENDFACTOR_SRC_ALPHA_SATURATE /**< min(source alpha, 1 - destination alpha) */ +} SDL_GPUBlendFactor; + +/** + * Specifies which color components are written in a graphics pipeline. + * + * \since This datatype is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUGraphicsPipeline + */ +typedef Uint8 SDL_GPUColorComponentFlags; + +#define SDL_GPU_COLORCOMPONENT_R (1u << 0) /**< the red component */ +#define SDL_GPU_COLORCOMPONENT_G (1u << 1) /**< the green component */ +#define SDL_GPU_COLORCOMPONENT_B (1u << 2) /**< the blue component */ +#define SDL_GPU_COLORCOMPONENT_A (1u << 3) /**< the alpha component */ + +/** + * Specifies a filter operation used by a sampler. + * + * \since This enum is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUSampler + */ +typedef enum SDL_GPUFilter +{ + SDL_GPU_FILTER_NEAREST, /**< Point filtering. */ + SDL_GPU_FILTER_LINEAR /**< Linear filtering. */ +} SDL_GPUFilter; + +/** + * Specifies a mipmap mode used by a sampler. + * + * \since This enum is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUSampler + */ +typedef enum SDL_GPUSamplerMipmapMode +{ + SDL_GPU_SAMPLERMIPMAPMODE_NEAREST, /**< Point filtering. */ + SDL_GPU_SAMPLERMIPMAPMODE_LINEAR /**< Linear filtering. */ +} SDL_GPUSamplerMipmapMode; + +/** + * Specifies behavior of texture sampling when the coordinates exceed the 0-1 + * range. + * + * \since This enum is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUSampler + */ +typedef enum SDL_GPUSamplerAddressMode +{ + SDL_GPU_SAMPLERADDRESSMODE_REPEAT, /**< Specifies that the coordinates will wrap around. */ + SDL_GPU_SAMPLERADDRESSMODE_MIRRORED_REPEAT, /**< Specifies that the coordinates will wrap around mirrored. */ + SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE /**< Specifies that the coordinates will clamp to the 0-1 range. */ +} SDL_GPUSamplerAddressMode; + +/** + * Specifies the timing that will be used to present swapchain textures to the + * OS. + * + * VSYNC mode will always be supported. IMMEDIATE and MAILBOX modes may not be + * supported on certain systems. + * + * It is recommended to query SDL_WindowSupportsGPUPresentMode after claiming + * the window if you wish to change the present mode to IMMEDIATE or MAILBOX. + * + * - VSYNC: Waits for vblank before presenting. No tearing is possible. If + * there is a pending image to present, the new image is enqueued for + * presentation. Disallows tearing at the cost of visual latency. + * - IMMEDIATE: Immediately presents. Lowest latency option, but tearing may + * occur. + * - MAILBOX: Waits for vblank before presenting. No tearing is possible. If + * there is a pending image to present, the pending image is replaced by the + * new image. Similar to VSYNC, but with reduced visual latency. + * + * \since This enum is available since SDL 3.2.0. + * + * \sa SDL_SetGPUSwapchainParameters + * \sa SDL_WindowSupportsGPUPresentMode + * \sa SDL_WaitAndAcquireGPUSwapchainTexture + */ +typedef enum SDL_GPUPresentMode +{ + SDL_GPU_PRESENTMODE_VSYNC, + SDL_GPU_PRESENTMODE_IMMEDIATE, + SDL_GPU_PRESENTMODE_MAILBOX +} SDL_GPUPresentMode; + +/** + * Specifies the texture format and colorspace of the swapchain textures. + * + * SDR will always be supported. Other compositions may not be supported on + * certain systems. + * + * It is recommended to query SDL_WindowSupportsGPUSwapchainComposition after + * claiming the window if you wish to change the swapchain composition from + * SDR. + * + * - SDR: B8G8R8A8 or R8G8B8A8 swapchain. Pixel values are in sRGB encoding. + * - SDR_LINEAR: B8G8R8A8_SRGB or R8G8B8A8_SRGB swapchain. Pixel values are + * stored in memory in sRGB encoding but accessed in shaders in "linear + * sRGB" encoding which is sRGB but with a linear transfer function. + * - HDR_EXTENDED_LINEAR: R16G16B16A16_FLOAT swapchain. Pixel values are in + * extended linear sRGB encoding and permits values outside of the [0, 1] + * range. + * - HDR10_ST2084: A2R10G10B10 or A2B10G10R10 swapchain. Pixel values are in + * BT.2020 ST2084 (PQ) encoding. + * + * \since This enum is available since SDL 3.2.0. + * + * \sa SDL_SetGPUSwapchainParameters + * \sa SDL_WindowSupportsGPUSwapchainComposition + * \sa SDL_WaitAndAcquireGPUSwapchainTexture + */ +typedef enum SDL_GPUSwapchainComposition +{ + SDL_GPU_SWAPCHAINCOMPOSITION_SDR, + SDL_GPU_SWAPCHAINCOMPOSITION_SDR_LINEAR, + SDL_GPU_SWAPCHAINCOMPOSITION_HDR_EXTENDED_LINEAR, + SDL_GPU_SWAPCHAINCOMPOSITION_HDR10_ST2084 +} SDL_GPUSwapchainComposition; + +/* Structures */ + +/** + * A structure specifying a viewport. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_SetGPUViewport + */ +typedef struct SDL_GPUViewport +{ + float x; /**< The left offset of the viewport. */ + float y; /**< The top offset of the viewport. */ + float w; /**< The width of the viewport. */ + float h; /**< The height of the viewport. */ + float min_depth; /**< The minimum depth of the viewport. */ + float max_depth; /**< The maximum depth of the viewport. */ +} SDL_GPUViewport; + +/** + * A structure specifying parameters related to transferring data to or from a + * texture. + * + * If either of `pixels_per_row` or `rows_per_layer` is zero, then width and + * height of passed SDL_GPUTextureRegion to SDL_UploadToGPUTexture or + * SDL_DownloadFromGPUTexture are used as default values respectively and data + * is considered to be tightly packed. + * + * **WARNING**: Direct3D 12 requires texture data row pitch to be 256 byte + * aligned, and offsets to be aligned to 512 bytes. If they are not, SDL will + * make a temporary copy of the data that is properly aligned, but this adds + * overhead to the transfer process. Apps can avoid this by aligning their + * data appropriately, or using a different GPU backend than Direct3D 12. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_UploadToGPUTexture + * \sa SDL_DownloadFromGPUTexture + */ +typedef struct SDL_GPUTextureTransferInfo +{ + SDL_GPUTransferBuffer *transfer_buffer; /**< The transfer buffer used in the transfer operation. */ + Uint32 offset; /**< The starting byte of the image data in the transfer buffer. */ + Uint32 pixels_per_row; /**< The number of pixels from one row to the next. */ + Uint32 rows_per_layer; /**< The number of rows from one layer/depth-slice to the next. */ +} SDL_GPUTextureTransferInfo; + +/** + * A structure specifying a location in a transfer buffer. + * + * Used when transferring buffer data to or from a transfer buffer. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_UploadToGPUBuffer + * \sa SDL_DownloadFromGPUBuffer + */ +typedef struct SDL_GPUTransferBufferLocation +{ + SDL_GPUTransferBuffer *transfer_buffer; /**< The transfer buffer used in the transfer operation. */ + Uint32 offset; /**< The starting byte of the buffer data in the transfer buffer. */ +} SDL_GPUTransferBufferLocation; + +/** + * A structure specifying a location in a texture. + * + * Used when copying data from one texture to another. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_CopyGPUTextureToTexture + */ +typedef struct SDL_GPUTextureLocation +{ + SDL_GPUTexture *texture; /**< The texture used in the copy operation. */ + Uint32 mip_level; /**< The mip level index of the location. */ + Uint32 layer; /**< The layer index of the location. */ + Uint32 x; /**< The left offset of the location. */ + Uint32 y; /**< The top offset of the location. */ + Uint32 z; /**< The front offset of the location. */ +} SDL_GPUTextureLocation; + +/** + * A structure specifying a region of a texture. + * + * Used when transferring data to or from a texture. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_UploadToGPUTexture + * \sa SDL_DownloadFromGPUTexture + * \sa SDL_CreateGPUTexture + */ +typedef struct SDL_GPUTextureRegion +{ + SDL_GPUTexture *texture; /**< The texture used in the copy operation. */ + Uint32 mip_level; /**< The mip level index to transfer. */ + Uint32 layer; /**< The layer index to transfer. */ + Uint32 x; /**< The left offset of the region. */ + Uint32 y; /**< The top offset of the region. */ + Uint32 z; /**< The front offset of the region. */ + Uint32 w; /**< The width of the region. */ + Uint32 h; /**< The height of the region. */ + Uint32 d; /**< The depth of the region. */ +} SDL_GPUTextureRegion; + +/** + * A structure specifying a region of a texture used in the blit operation. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_BlitGPUTexture + */ +typedef struct SDL_GPUBlitRegion +{ + SDL_GPUTexture *texture; /**< The texture. */ + Uint32 mip_level; /**< The mip level index of the region. */ + Uint32 layer_or_depth_plane; /**< The layer index or depth plane of the region. This value is treated as a layer index on 2D array and cube textures, and as a depth plane on 3D textures. */ + Uint32 x; /**< The left offset of the region. */ + Uint32 y; /**< The top offset of the region. */ + Uint32 w; /**< The width of the region. */ + Uint32 h; /**< The height of the region. */ +} SDL_GPUBlitRegion; + +/** + * A structure specifying a location in a buffer. + * + * Used when copying data between buffers. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_CopyGPUBufferToBuffer + */ +typedef struct SDL_GPUBufferLocation +{ + SDL_GPUBuffer *buffer; /**< The buffer. */ + Uint32 offset; /**< The starting byte within the buffer. */ +} SDL_GPUBufferLocation; + +/** + * A structure specifying a region of a buffer. + * + * Used when transferring data to or from buffers. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_UploadToGPUBuffer + * \sa SDL_DownloadFromGPUBuffer + */ +typedef struct SDL_GPUBufferRegion +{ + SDL_GPUBuffer *buffer; /**< The buffer. */ + Uint32 offset; /**< The starting byte within the buffer. */ + Uint32 size; /**< The size in bytes of the region. */ +} SDL_GPUBufferRegion; + +/** + * A structure specifying the parameters of an indirect draw command. + * + * Note that the `first_vertex` and `first_instance` parameters are NOT + * compatible with built-in vertex/instance ID variables in shaders (for + * example, SV_VertexID); GPU APIs and shader languages do not define these + * built-in variables consistently, so if your shader depends on them, the + * only way to keep behavior consistent and portable is to always pass 0 for + * the correlating parameter in the draw calls. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_DrawGPUPrimitivesIndirect + */ +typedef struct SDL_GPUIndirectDrawCommand +{ + Uint32 num_vertices; /**< The number of vertices to draw. */ + Uint32 num_instances; /**< The number of instances to draw. */ + Uint32 first_vertex; /**< The index of the first vertex to draw. */ + Uint32 first_instance; /**< The ID of the first instance to draw. */ +} SDL_GPUIndirectDrawCommand; + +/** + * A structure specifying the parameters of an indexed indirect draw command. + * + * Note that the `first_vertex` and `first_instance` parameters are NOT + * compatible with built-in vertex/instance ID variables in shaders (for + * example, SV_VertexID); GPU APIs and shader languages do not define these + * built-in variables consistently, so if your shader depends on them, the + * only way to keep behavior consistent and portable is to always pass 0 for + * the correlating parameter in the draw calls. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_DrawGPUIndexedPrimitivesIndirect + */ +typedef struct SDL_GPUIndexedIndirectDrawCommand +{ + Uint32 num_indices; /**< The number of indices to draw per instance. */ + Uint32 num_instances; /**< The number of instances to draw. */ + Uint32 first_index; /**< The base index within the index buffer. */ + Sint32 vertex_offset; /**< The value added to the vertex index before indexing into the vertex buffer. */ + Uint32 first_instance; /**< The ID of the first instance to draw. */ +} SDL_GPUIndexedIndirectDrawCommand; + +/** + * A structure specifying the parameters of an indexed dispatch command. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_DispatchGPUComputeIndirect + */ +typedef struct SDL_GPUIndirectDispatchCommand +{ + Uint32 groupcount_x; /**< The number of local workgroups to dispatch in the X dimension. */ + Uint32 groupcount_y; /**< The number of local workgroups to dispatch in the Y dimension. */ + Uint32 groupcount_z; /**< The number of local workgroups to dispatch in the Z dimension. */ +} SDL_GPUIndirectDispatchCommand; + +/* State structures */ + +/** + * A structure specifying the parameters of a sampler. + * + * Note that mip_lod_bias is a no-op for the Metal driver. For Metal, LOD bias + * must be applied via shader instead. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUSampler + * \sa SDL_GPUFilter + * \sa SDL_GPUSamplerMipmapMode + * \sa SDL_GPUSamplerAddressMode + * \sa SDL_GPUCompareOp + */ +typedef struct SDL_GPUSamplerCreateInfo +{ + SDL_GPUFilter min_filter; /**< The minification filter to apply to lookups. */ + SDL_GPUFilter mag_filter; /**< The magnification filter to apply to lookups. */ + SDL_GPUSamplerMipmapMode mipmap_mode; /**< The mipmap filter to apply to lookups. */ + SDL_GPUSamplerAddressMode address_mode_u; /**< The addressing mode for U coordinates outside [0, 1). */ + SDL_GPUSamplerAddressMode address_mode_v; /**< The addressing mode for V coordinates outside [0, 1). */ + SDL_GPUSamplerAddressMode address_mode_w; /**< The addressing mode for W coordinates outside [0, 1). */ + float mip_lod_bias; /**< The bias to be added to mipmap LOD calculation. */ + float max_anisotropy; /**< The anisotropy value clamp used by the sampler. If enable_anisotropy is false, this is ignored. */ + SDL_GPUCompareOp compare_op; /**< The comparison operator to apply to fetched data before filtering. */ + float min_lod; /**< Clamps the minimum of the computed LOD value. */ + float max_lod; /**< Clamps the maximum of the computed LOD value. */ + bool enable_anisotropy; /**< true to enable anisotropic filtering. */ + bool enable_compare; /**< true to enable comparison against a reference value during lookups. */ + Uint8 padding1; + Uint8 padding2; + + SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */ +} SDL_GPUSamplerCreateInfo; + +/** + * A structure specifying the parameters of vertex buffers used in a graphics + * pipeline. + * + * When you call SDL_BindGPUVertexBuffers, you specify the binding slots of + * the vertex buffers. For example if you called SDL_BindGPUVertexBuffers with + * a first_slot of 2 and num_bindings of 3, the binding slots 2, 3, 4 would be + * used by the vertex buffers you pass in. + * + * Vertex attributes are linked to buffers via the buffer_slot field of + * SDL_GPUVertexAttribute. For example, if an attribute has a buffer_slot of + * 0, then that attribute belongs to the vertex buffer bound at slot 0. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_GPUVertexAttribute + * \sa SDL_GPUVertexInputRate + */ +typedef struct SDL_GPUVertexBufferDescription +{ + Uint32 slot; /**< The binding slot of the vertex buffer. */ + Uint32 pitch; /**< The size of a single element + the offset between elements. */ + SDL_GPUVertexInputRate input_rate; /**< Whether attribute addressing is a function of the vertex index or instance index. */ + Uint32 instance_step_rate; /**< Reserved for future use. Must be set to 0. */ +} SDL_GPUVertexBufferDescription; + +/** + * A structure specifying a vertex attribute. + * + * All vertex attribute locations provided to an SDL_GPUVertexInputState must + * be unique. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_GPUVertexBufferDescription + * \sa SDL_GPUVertexInputState + * \sa SDL_GPUVertexElementFormat + */ +typedef struct SDL_GPUVertexAttribute +{ + Uint32 location; /**< The shader input location index. */ + Uint32 buffer_slot; /**< The binding slot of the associated vertex buffer. */ + SDL_GPUVertexElementFormat format; /**< The size and type of the attribute data. */ + Uint32 offset; /**< The byte offset of this attribute relative to the start of the vertex element. */ +} SDL_GPUVertexAttribute; + +/** + * A structure specifying the parameters of a graphics pipeline vertex input + * state. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_GPUGraphicsPipelineCreateInfo + * \sa SDL_GPUVertexBufferDescription + * \sa SDL_GPUVertexAttribute + */ +typedef struct SDL_GPUVertexInputState +{ + const SDL_GPUVertexBufferDescription *vertex_buffer_descriptions; /**< A pointer to an array of vertex buffer descriptions. */ + Uint32 num_vertex_buffers; /**< The number of vertex buffer descriptions in the above array. */ + const SDL_GPUVertexAttribute *vertex_attributes; /**< A pointer to an array of vertex attribute descriptions. */ + Uint32 num_vertex_attributes; /**< The number of vertex attribute descriptions in the above array. */ +} SDL_GPUVertexInputState; + +/** + * A structure specifying the stencil operation state of a graphics pipeline. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_GPUDepthStencilState + */ +typedef struct SDL_GPUStencilOpState +{ + SDL_GPUStencilOp fail_op; /**< The action performed on samples that fail the stencil test. */ + SDL_GPUStencilOp pass_op; /**< The action performed on samples that pass the depth and stencil tests. */ + SDL_GPUStencilOp depth_fail_op; /**< The action performed on samples that pass the stencil test and fail the depth test. */ + SDL_GPUCompareOp compare_op; /**< The comparison operator used in the stencil test. */ +} SDL_GPUStencilOpState; + +/** + * A structure specifying the blend state of a color target. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_GPUColorTargetDescription + * \sa SDL_GPUBlendFactor + * \sa SDL_GPUBlendOp + * \sa SDL_GPUColorComponentFlags + */ +typedef struct SDL_GPUColorTargetBlendState +{ + SDL_GPUBlendFactor src_color_blendfactor; /**< The value to be multiplied by the source RGB value. */ + SDL_GPUBlendFactor dst_color_blendfactor; /**< The value to be multiplied by the destination RGB value. */ + SDL_GPUBlendOp color_blend_op; /**< The blend operation for the RGB components. */ + SDL_GPUBlendFactor src_alpha_blendfactor; /**< The value to be multiplied by the source alpha. */ + SDL_GPUBlendFactor dst_alpha_blendfactor; /**< The value to be multiplied by the destination alpha. */ + SDL_GPUBlendOp alpha_blend_op; /**< The blend operation for the alpha component. */ + SDL_GPUColorComponentFlags color_write_mask; /**< A bitmask specifying which of the RGBA components are enabled for writing. Writes to all channels if enable_color_write_mask is false. */ + bool enable_blend; /**< Whether blending is enabled for the color target. */ + bool enable_color_write_mask; /**< Whether the color write mask is enabled. */ + Uint8 padding1; + Uint8 padding2; +} SDL_GPUColorTargetBlendState; + + +/** + * A structure specifying code and metadata for creating a shader object. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUShader + * \sa SDL_GPUShaderFormat + * \sa SDL_GPUShaderStage + */ +typedef struct SDL_GPUShaderCreateInfo +{ + size_t code_size; /**< The size in bytes of the code pointed to. */ + const Uint8 *code; /**< A pointer to shader code. */ + const char *entrypoint; /**< A pointer to a null-terminated UTF-8 string specifying the entry point function name for the shader. */ + SDL_GPUShaderFormat format; /**< The format of the shader code. */ + SDL_GPUShaderStage stage; /**< The stage the shader program corresponds to. */ + Uint32 num_samplers; /**< The number of samplers defined in the shader. */ + Uint32 num_storage_textures; /**< The number of storage textures defined in the shader. */ + Uint32 num_storage_buffers; /**< The number of storage buffers defined in the shader. */ + Uint32 num_uniform_buffers; /**< The number of uniform buffers defined in the shader. */ + + SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */ +} SDL_GPUShaderCreateInfo; + +/** + * A structure specifying the parameters of a texture. + * + * Usage flags can be bitwise OR'd together for combinations of usages. Note + * that certain usage combinations are invalid, for example SAMPLER and + * GRAPHICS_STORAGE. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUTexture + * \sa SDL_GPUTextureType + * \sa SDL_GPUTextureFormat + * \sa SDL_GPUTextureUsageFlags + * \sa SDL_GPUSampleCount + */ +typedef struct SDL_GPUTextureCreateInfo +{ + SDL_GPUTextureType type; /**< The base dimensionality of the texture. */ + SDL_GPUTextureFormat format; /**< The pixel format of the texture. */ + SDL_GPUTextureUsageFlags usage; /**< How the texture is intended to be used by the client. */ + Uint32 width; /**< The width of the texture. */ + Uint32 height; /**< The height of the texture. */ + Uint32 layer_count_or_depth; /**< The layer count or depth of the texture. This value is treated as a layer count on 2D array textures, and as a depth value on 3D textures. */ + Uint32 num_levels; /**< The number of mip levels in the texture. */ + SDL_GPUSampleCount sample_count; /**< The number of samples per texel. Only applies if the texture is used as a render target. */ + + SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */ +} SDL_GPUTextureCreateInfo; + +/** + * A structure specifying the parameters of a buffer. + * + * Usage flags can be bitwise OR'd together for combinations of usages. Note + * that certain combinations are invalid, for example VERTEX and INDEX. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUBuffer + * \sa SDL_GPUBufferUsageFlags + */ +typedef struct SDL_GPUBufferCreateInfo +{ + SDL_GPUBufferUsageFlags usage; /**< How the buffer is intended to be used by the client. */ + Uint32 size; /**< The size in bytes of the buffer. */ + + SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */ +} SDL_GPUBufferCreateInfo; + +/** + * A structure specifying the parameters of a transfer buffer. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUTransferBuffer + */ +typedef struct SDL_GPUTransferBufferCreateInfo +{ + SDL_GPUTransferBufferUsage usage; /**< How the transfer buffer is intended to be used by the client. */ + Uint32 size; /**< The size in bytes of the transfer buffer. */ + + SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */ +} SDL_GPUTransferBufferCreateInfo; + +/* Pipeline state structures */ + +/** + * A structure specifying the parameters of the graphics pipeline rasterizer + * state. + * + * Note that SDL_GPU_FILLMODE_LINE is not supported on many Android devices. + * For those devices, the fill mode will automatically fall back to FILL. + * + * Also note that the D3D12 driver will enable depth clamping even if + * enable_depth_clip is true. If you need this clamp+clip behavior, consider + * enabling depth clip and then manually clamping depth in your fragment + * shaders on Metal and Vulkan. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_GPUGraphicsPipelineCreateInfo + */ +typedef struct SDL_GPURasterizerState +{ + SDL_GPUFillMode fill_mode; /**< Whether polygons will be filled in or drawn as lines. */ + SDL_GPUCullMode cull_mode; /**< The facing direction in which triangles will be culled. */ + SDL_GPUFrontFace front_face; /**< The vertex winding that will cause a triangle to be determined as front-facing. */ + float depth_bias_constant_factor; /**< A scalar factor controlling the depth value added to each fragment. */ + float depth_bias_clamp; /**< The maximum depth bias of a fragment. */ + float depth_bias_slope_factor; /**< A scalar factor applied to a fragment's slope in depth calculations. */ + bool enable_depth_bias; /**< true to bias fragment depth values. */ + bool enable_depth_clip; /**< true to enable depth clip, false to enable depth clamp. */ + Uint8 padding1; + Uint8 padding2; +} SDL_GPURasterizerState; + +/** + * A structure specifying the parameters of the graphics pipeline multisample + * state. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_GPUGraphicsPipelineCreateInfo + */ +typedef struct SDL_GPUMultisampleState +{ + SDL_GPUSampleCount sample_count; /**< The number of samples to be used in rasterization. */ + Uint32 sample_mask; /**< Reserved for future use. Must be set to 0. */ + bool enable_mask; /**< Reserved for future use. Must be set to false. */ + bool enable_alpha_to_coverage; /**< true enables the alpha-to-coverage feature. */ + Uint8 padding2; + Uint8 padding3; +} SDL_GPUMultisampleState; + +/** + * A structure specifying the parameters of the graphics pipeline depth + * stencil state. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_GPUGraphicsPipelineCreateInfo + */ +typedef struct SDL_GPUDepthStencilState +{ + SDL_GPUCompareOp compare_op; /**< The comparison operator used for depth testing. */ + SDL_GPUStencilOpState back_stencil_state; /**< The stencil op state for back-facing triangles. */ + SDL_GPUStencilOpState front_stencil_state; /**< The stencil op state for front-facing triangles. */ + Uint8 compare_mask; /**< Selects the bits of the stencil values participating in the stencil test. */ + Uint8 write_mask; /**< Selects the bits of the stencil values updated by the stencil test. */ + bool enable_depth_test; /**< true enables the depth test. */ + bool enable_depth_write; /**< true enables depth writes. Depth writes are always disabled when enable_depth_test is false. */ + bool enable_stencil_test; /**< true enables the stencil test. */ + Uint8 padding1; + Uint8 padding2; + Uint8 padding3; +} SDL_GPUDepthStencilState; + +/** + * A structure specifying the parameters of color targets used in a graphics + * pipeline. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_GPUGraphicsPipelineTargetInfo + */ +typedef struct SDL_GPUColorTargetDescription +{ + SDL_GPUTextureFormat format; /**< The pixel format of the texture to be used as a color target. */ + SDL_GPUColorTargetBlendState blend_state; /**< The blend state to be used for the color target. */ +} SDL_GPUColorTargetDescription; + +/** + * A structure specifying the descriptions of render targets used in a + * graphics pipeline. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_GPUGraphicsPipelineCreateInfo + * \sa SDL_GPUColorTargetDescription + * \sa SDL_GPUTextureFormat + */ +typedef struct SDL_GPUGraphicsPipelineTargetInfo +{ + const SDL_GPUColorTargetDescription *color_target_descriptions; /**< A pointer to an array of color target descriptions. */ + Uint32 num_color_targets; /**< The number of color target descriptions in the above array. */ + SDL_GPUTextureFormat depth_stencil_format; /**< The pixel format of the depth-stencil target. Ignored if has_depth_stencil_target is false. */ + bool has_depth_stencil_target; /**< true specifies that the pipeline uses a depth-stencil target. */ + Uint8 padding1; + Uint8 padding2; + Uint8 padding3; +} SDL_GPUGraphicsPipelineTargetInfo; + +/** + * A structure specifying the parameters of a graphics pipeline state. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUGraphicsPipeline + * \sa SDL_GPUShader + * \sa SDL_GPUVertexInputState + * \sa SDL_GPUPrimitiveType + * \sa SDL_GPURasterizerState + * \sa SDL_GPUMultisampleState + * \sa SDL_GPUDepthStencilState + * \sa SDL_GPUGraphicsPipelineTargetInfo + */ +typedef struct SDL_GPUGraphicsPipelineCreateInfo +{ + SDL_GPUShader *vertex_shader; /**< The vertex shader used by the graphics pipeline. */ + SDL_GPUShader *fragment_shader; /**< The fragment shader used by the graphics pipeline. */ + SDL_GPUVertexInputState vertex_input_state; /**< The vertex layout of the graphics pipeline. */ + SDL_GPUPrimitiveType primitive_type; /**< The primitive topology of the graphics pipeline. */ + SDL_GPURasterizerState rasterizer_state; /**< The rasterizer state of the graphics pipeline. */ + SDL_GPUMultisampleState multisample_state; /**< The multisample state of the graphics pipeline. */ + SDL_GPUDepthStencilState depth_stencil_state; /**< The depth-stencil state of the graphics pipeline. */ + SDL_GPUGraphicsPipelineTargetInfo target_info; /**< Formats and blend modes for the render targets of the graphics pipeline. */ + + SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */ +} SDL_GPUGraphicsPipelineCreateInfo; + +/** + * A structure specifying the parameters of a compute pipeline state. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUComputePipeline + * \sa SDL_GPUShaderFormat + */ +typedef struct SDL_GPUComputePipelineCreateInfo +{ + size_t code_size; /**< The size in bytes of the compute shader code pointed to. */ + const Uint8 *code; /**< A pointer to compute shader code. */ + const char *entrypoint; /**< A pointer to a null-terminated UTF-8 string specifying the entry point function name for the shader. */ + SDL_GPUShaderFormat format; /**< The format of the compute shader code. */ + Uint32 num_samplers; /**< The number of samplers defined in the shader. */ + Uint32 num_readonly_storage_textures; /**< The number of readonly storage textures defined in the shader. */ + Uint32 num_readonly_storage_buffers; /**< The number of readonly storage buffers defined in the shader. */ + Uint32 num_readwrite_storage_textures; /**< The number of read-write storage textures defined in the shader. */ + Uint32 num_readwrite_storage_buffers; /**< The number of read-write storage buffers defined in the shader. */ + Uint32 num_uniform_buffers; /**< The number of uniform buffers defined in the shader. */ + Uint32 threadcount_x; /**< The number of threads in the X dimension. This should match the value in the shader. */ + Uint32 threadcount_y; /**< The number of threads in the Y dimension. This should match the value in the shader. */ + Uint32 threadcount_z; /**< The number of threads in the Z dimension. This should match the value in the shader. */ + + SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */ +} SDL_GPUComputePipelineCreateInfo; + +/** + * A structure specifying the parameters of a color target used by a render + * pass. + * + * The load_op field determines what is done with the texture at the beginning + * of the render pass. + * + * - LOAD: Loads the data currently in the texture. Not recommended for + * multisample textures as it requires significant memory bandwidth. + * - CLEAR: Clears the texture to a single color. + * - DONT_CARE: The driver will do whatever it wants with the texture memory. + * This is a good option if you know that every single pixel will be touched + * in the render pass. + * + * The store_op field determines what is done with the color results of the + * render pass. + * + * - STORE: Stores the results of the render pass in the texture. Not + * recommended for multisample textures as it requires significant memory + * bandwidth. + * - DONT_CARE: The driver will do whatever it wants with the texture memory. + * This is often a good option for depth/stencil textures. + * - RESOLVE: Resolves a multisample texture into resolve_texture, which must + * have a sample count of 1. Then the driver may discard the multisample + * texture memory. This is the most performant method of resolving a + * multisample target. + * - RESOLVE_AND_STORE: Resolves a multisample texture into the + * resolve_texture, which must have a sample count of 1. Then the driver + * stores the multisample texture's contents. Not recommended as it requires + * significant memory bandwidth. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_BeginGPURenderPass + * \sa SDL_FColor + */ +typedef struct SDL_GPUColorTargetInfo +{ + SDL_GPUTexture *texture; /**< The texture that will be used as a color target by a render pass. */ + Uint32 mip_level; /**< The mip level to use as a color target. */ + Uint32 layer_or_depth_plane; /**< The layer index or depth plane to use as a color target. This value is treated as a layer index on 2D array and cube textures, and as a depth plane on 3D textures. */ + SDL_FColor clear_color; /**< The color to clear the color target to at the start of the render pass. Ignored if SDL_GPU_LOADOP_CLEAR is not used. */ + SDL_GPULoadOp load_op; /**< What is done with the contents of the color target at the beginning of the render pass. */ + SDL_GPUStoreOp store_op; /**< What is done with the results of the render pass. */ + SDL_GPUTexture *resolve_texture; /**< The texture that will receive the results of a multisample resolve operation. Ignored if a RESOLVE* store_op is not used. */ + Uint32 resolve_mip_level; /**< The mip level of the resolve texture to use for the resolve operation. Ignored if a RESOLVE* store_op is not used. */ + Uint32 resolve_layer; /**< The layer index of the resolve texture to use for the resolve operation. Ignored if a RESOLVE* store_op is not used. */ + bool cycle; /**< true cycles the texture if the texture is bound and load_op is not LOAD */ + bool cycle_resolve_texture; /**< true cycles the resolve texture if the resolve texture is bound. Ignored if a RESOLVE* store_op is not used. */ + Uint8 padding1; + Uint8 padding2; +} SDL_GPUColorTargetInfo; + +/** + * A structure specifying the parameters of a depth-stencil target used by a + * render pass. + * + * The load_op field determines what is done with the depth contents of the + * texture at the beginning of the render pass. + * + * - LOAD: Loads the depth values currently in the texture. + * - CLEAR: Clears the texture to a single depth. + * - DONT_CARE: The driver will do whatever it wants with the memory. This is + * a good option if you know that every single pixel will be touched in the + * render pass. + * + * The store_op field determines what is done with the depth results of the + * render pass. + * + * - STORE: Stores the depth results in the texture. + * - DONT_CARE: The driver will do whatever it wants with the depth results. + * This is often a good option for depth/stencil textures that don't need to + * be reused again. + * + * The stencil_load_op field determines what is done with the stencil contents + * of the texture at the beginning of the render pass. + * + * - LOAD: Loads the stencil values currently in the texture. + * - CLEAR: Clears the stencil values to a single value. + * - DONT_CARE: The driver will do whatever it wants with the memory. This is + * a good option if you know that every single pixel will be touched in the + * render pass. + * + * The stencil_store_op field determines what is done with the stencil results + * of the render pass. + * + * - STORE: Stores the stencil results in the texture. + * - DONT_CARE: The driver will do whatever it wants with the stencil results. + * This is often a good option for depth/stencil textures that don't need to + * be reused again. + * + * Note that depth/stencil targets do not support multisample resolves. + * + * Due to ABI limitations, depth textures with more than 255 layers are not + * supported. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_BeginGPURenderPass + */ +typedef struct SDL_GPUDepthStencilTargetInfo +{ + SDL_GPUTexture *texture; /**< The texture that will be used as the depth stencil target by the render pass. */ + float clear_depth; /**< The value to clear the depth component to at the beginning of the render pass. Ignored if SDL_GPU_LOADOP_CLEAR is not used. */ + SDL_GPULoadOp load_op; /**< What is done with the depth contents at the beginning of the render pass. */ + SDL_GPUStoreOp store_op; /**< What is done with the depth results of the render pass. */ + SDL_GPULoadOp stencil_load_op; /**< What is done with the stencil contents at the beginning of the render pass. */ + SDL_GPUStoreOp stencil_store_op; /**< What is done with the stencil results of the render pass. */ + bool cycle; /**< true cycles the texture if the texture is bound and any load ops are not LOAD */ + Uint8 clear_stencil; /**< The value to clear the stencil component to at the beginning of the render pass. Ignored if SDL_GPU_LOADOP_CLEAR is not used. */ + Uint8 mip_level; /**< The mip level to use as the depth stencil target. */ + Uint8 layer; /**< The layer index to use as the depth stencil target. */ +} SDL_GPUDepthStencilTargetInfo; + +/** + * A structure containing parameters for a blit command. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_BlitGPUTexture + */ +typedef struct SDL_GPUBlitInfo { + SDL_GPUBlitRegion source; /**< The source region for the blit. */ + SDL_GPUBlitRegion destination; /**< The destination region for the blit. */ + SDL_GPULoadOp load_op; /**< What is done with the contents of the destination before the blit. */ + SDL_FColor clear_color; /**< The color to clear the destination region to before the blit. Ignored if load_op is not SDL_GPU_LOADOP_CLEAR. */ + SDL_FlipMode flip_mode; /**< The flip mode for the source region. */ + SDL_GPUFilter filter; /**< The filter mode used when blitting. */ + bool cycle; /**< true cycles the destination texture if it is already bound. */ + Uint8 padding1; + Uint8 padding2; + Uint8 padding3; +} SDL_GPUBlitInfo; + +/* Binding structs */ + +/** + * A structure specifying parameters in a buffer binding call. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_BindGPUVertexBuffers + * \sa SDL_BindGPUIndexBuffer + */ +typedef struct SDL_GPUBufferBinding +{ + SDL_GPUBuffer *buffer; /**< The buffer to bind. Must have been created with SDL_GPU_BUFFERUSAGE_VERTEX for SDL_BindGPUVertexBuffers, or SDL_GPU_BUFFERUSAGE_INDEX for SDL_BindGPUIndexBuffer. */ + Uint32 offset; /**< The starting byte of the data to bind in the buffer. */ +} SDL_GPUBufferBinding; + +/** + * A structure specifying parameters in a sampler binding call. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_BindGPUVertexSamplers + * \sa SDL_BindGPUFragmentSamplers + * \sa SDL_GPUTexture + * \sa SDL_GPUSampler + */ +typedef struct SDL_GPUTextureSamplerBinding +{ + SDL_GPUTexture *texture; /**< The texture to bind. Must have been created with SDL_GPU_TEXTUREUSAGE_SAMPLER. */ + SDL_GPUSampler *sampler; /**< The sampler to bind. */ +} SDL_GPUTextureSamplerBinding; + +/** + * A structure specifying parameters related to binding buffers in a compute + * pass. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_BeginGPUComputePass + */ +typedef struct SDL_GPUStorageBufferReadWriteBinding +{ + SDL_GPUBuffer *buffer; /**< The buffer to bind. Must have been created with SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_WRITE. */ + bool cycle; /**< true cycles the buffer if it is already bound. */ + Uint8 padding1; + Uint8 padding2; + Uint8 padding3; +} SDL_GPUStorageBufferReadWriteBinding; + +/** + * A structure specifying parameters related to binding textures in a compute + * pass. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_BeginGPUComputePass + */ +typedef struct SDL_GPUStorageTextureReadWriteBinding +{ + SDL_GPUTexture *texture; /**< The texture to bind. Must have been created with SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_WRITE or SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_SIMULTANEOUS_READ_WRITE. */ + Uint32 mip_level; /**< The mip level index to bind. */ + Uint32 layer; /**< The layer index to bind. */ + bool cycle; /**< true cycles the texture if it is already bound. */ + Uint8 padding1; + Uint8 padding2; + Uint8 padding3; +} SDL_GPUStorageTextureReadWriteBinding; + +/* Functions */ + +/* Device */ + +/** + * Checks for GPU runtime support. + * + * \param format_flags a bitflag indicating which shader formats the app is + * able to provide. + * \param name the preferred GPU driver, or NULL to let SDL pick the optimal + * driver. + * \returns true if supported, false otherwise. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUDevice + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GPUSupportsShaderFormats( + SDL_GPUShaderFormat format_flags, + const char *name); + +/** + * Checks for GPU runtime support. + * + * \param props the properties to use. + * \returns true if supported, false otherwise. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUDeviceWithProperties + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GPUSupportsProperties( + SDL_PropertiesID props); + +/** + * Creates a GPU context. + * + * The GPU driver name can be one of the following: + * + * - "vulkan": [Vulkan](CategoryGPU#vulkan) + * - "direct3d12": [D3D12](CategoryGPU#d3d12) + * - "metal": [Metal](CategoryGPU#metal) + * - NULL: let SDL pick the optimal driver + * + * \param format_flags a bitflag indicating which shader formats the app is + * able to provide. + * \param debug_mode enable debug mode properties and validations. + * \param name the preferred GPU driver, or NULL to let SDL pick the optimal + * driver. + * \returns a GPU context on success or NULL on failure; call SDL_GetError() + * for more information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUDeviceWithProperties + * \sa SDL_GetGPUShaderFormats + * \sa SDL_GetGPUDeviceDriver + * \sa SDL_DestroyGPUDevice + * \sa SDL_GPUSupportsShaderFormats + */ +extern SDL_DECLSPEC SDL_GPUDevice * SDLCALL SDL_CreateGPUDevice( + SDL_GPUShaderFormat format_flags, + bool debug_mode, + const char *name); + +/** + * Creates a GPU context. + * + * These are the supported properties: + * + * - `SDL_PROP_GPU_DEVICE_CREATE_DEBUGMODE_BOOLEAN`: enable debug mode + * properties and validations, defaults to true. + * - `SDL_PROP_GPU_DEVICE_CREATE_PREFERLOWPOWER_BOOLEAN`: enable to prefer + * energy efficiency over maximum GPU performance, defaults to false. + * - `SDL_PROP_GPU_DEVICE_CREATE_VERBOSE_BOOLEAN`: enable to automatically log + * useful debug information on device creation, defaults to true. + * - `SDL_PROP_GPU_DEVICE_CREATE_NAME_STRING`: the name of the GPU driver to + * use, if a specific one is desired. + * - `SDL_PROP_GPU_DEVICE_CREATE_FEATURE_CLIP_DISTANCE_BOOLEAN`: Enable Vulkan + * device feature shaderClipDistance. If disabled, clip distances are not + * supported in shader code: gl_ClipDistance[] built-ins of GLSL, + * SV_ClipDistance0/1 semantics of HLSL and [[clip_distance]] attribute of + * Metal. Disabling optional features allows the application to run on some + * older Android devices. Defaults to true. + * - `SDL_PROP_GPU_DEVICE_CREATE_FEATURE_DEPTH_CLAMPING_BOOLEAN`: Enable + * Vulkan device feature depthClamp. If disabled, there is no depth clamp + * support and enable_depth_clip in SDL_GPURasterizerState must always be + * set to true. Disabling optional features allows the application to run on + * some older Android devices. Defaults to true. + * - `SDL_PROP_GPU_DEVICE_CREATE_FEATURE_INDIRECT_DRAW_FIRST_INSTANCE_BOOLEAN`: + * Enable Vulkan device feature drawIndirectFirstInstance. If disabled, the + * argument first_instance of SDL_GPUIndirectDrawCommand must be set to + * zero. Disabling optional features allows the application to run on some + * older Android devices. Defaults to true. + * - `SDL_PROP_GPU_DEVICE_CREATE_FEATURE_ANISOTROPY_BOOLEAN`: Enable Vulkan + * device feature samplerAnisotropy. If disabled, enable_anisotropy of + * SDL_GPUSamplerCreateInfo must be set to false. Disabling optional + * features allows the application to run on some older Android devices. + * Defaults to true. + * + * These are the current shader format properties: + * + * - `SDL_PROP_GPU_DEVICE_CREATE_SHADERS_PRIVATE_BOOLEAN`: The app is able to + * provide shaders for an NDA platform. + * - `SDL_PROP_GPU_DEVICE_CREATE_SHADERS_SPIRV_BOOLEAN`: The app is able to + * provide SPIR-V shaders if applicable. + * - `SDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXBC_BOOLEAN`: The app is able to + * provide DXBC shaders if applicable + * - `SDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXIL_BOOLEAN`: The app is able to + * provide DXIL shaders if applicable. + * - `SDL_PROP_GPU_DEVICE_CREATE_SHADERS_MSL_BOOLEAN`: The app is able to + * provide MSL shaders if applicable. + * - `SDL_PROP_GPU_DEVICE_CREATE_SHADERS_METALLIB_BOOLEAN`: The app is able to + * provide Metal shader libraries if applicable. + * + * With the D3D12 backend: + * + * - `SDL_PROP_GPU_DEVICE_CREATE_D3D12_SEMANTIC_NAME_STRING`: the prefix to + * use for all vertex semantics, default is "TEXCOORD". + * - `SDL_PROP_GPU_DEVICE_CREATE_D3D12_ALLOW_FEWER_RESOURCE_SLOTS_BOOLEAN`: By + * default, Resourcing Binding Tier 2 is required for D3D12 support. + * However, an application can set this property to true to enable Tier 1 + * support, if (and only if) the application uses 8 or fewer storage + * resources across all shader stages. As of writing, this property is + * useful for targeting Intel Haswell and Broadwell GPUs; other hardware + * either supports Tier 2 Resource Binding or does not support D3D12 in any + * capacity. Defaults to false. + * + * With the Vulkan backend: + * + * - `SDL_PROP_GPU_DEVICE_CREATE_VULKAN_REQUIRE_HARDWARE_ACCELERATION_BOOLEAN`: + * By default, Vulkan device enumeration includes drivers of all types, + * including software renderers (for example, the Lavapipe Mesa driver). + * This can be useful if your application _requires_ SDL_GPU, but if you can + * provide your own fallback renderer (for example, an OpenGL renderer) this + * property can be set to true. Defaults to false. + * - `SDL_PROP_GPU_DEVICE_CREATE_VULKAN_OPTIONS_POINTER`: a pointer to an + * SDL_GPUVulkanOptions structure to be processed during device creation. + * This allows configuring a variety of Vulkan-specific options such as + * increasing the API version and opting into extensions aside from the + * minimal set SDL requires. + * + * \param props the properties to use. + * \returns a GPU context on success or NULL on failure; call SDL_GetError() + * for more information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetGPUShaderFormats + * \sa SDL_GetGPUDeviceDriver + * \sa SDL_DestroyGPUDevice + * \sa SDL_GPUSupportsProperties + */ +extern SDL_DECLSPEC SDL_GPUDevice * SDLCALL SDL_CreateGPUDeviceWithProperties( + SDL_PropertiesID props); + +#define SDL_PROP_GPU_DEVICE_CREATE_DEBUGMODE_BOOLEAN "SDL.gpu.device.create.debugmode" +#define SDL_PROP_GPU_DEVICE_CREATE_PREFERLOWPOWER_BOOLEAN "SDL.gpu.device.create.preferlowpower" +#define SDL_PROP_GPU_DEVICE_CREATE_VERBOSE_BOOLEAN "SDL.gpu.device.create.verbose" +#define SDL_PROP_GPU_DEVICE_CREATE_NAME_STRING "SDL.gpu.device.create.name" +#define SDL_PROP_GPU_DEVICE_CREATE_FEATURE_CLIP_DISTANCE_BOOLEAN "SDL.gpu.device.create.feature.clip_distance" +#define SDL_PROP_GPU_DEVICE_CREATE_FEATURE_DEPTH_CLAMPING_BOOLEAN "SDL.gpu.device.create.feature.depth_clamping" +#define SDL_PROP_GPU_DEVICE_CREATE_FEATURE_INDIRECT_DRAW_FIRST_INSTANCE_BOOLEAN "SDL.gpu.device.create.feature.indirect_draw_first_instance" +#define SDL_PROP_GPU_DEVICE_CREATE_FEATURE_ANISOTROPY_BOOLEAN "SDL.gpu.device.create.feature.anisotropy" +#define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_PRIVATE_BOOLEAN "SDL.gpu.device.create.shaders.private" +#define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_SPIRV_BOOLEAN "SDL.gpu.device.create.shaders.spirv" +#define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXBC_BOOLEAN "SDL.gpu.device.create.shaders.dxbc" +#define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXIL_BOOLEAN "SDL.gpu.device.create.shaders.dxil" +#define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_MSL_BOOLEAN "SDL.gpu.device.create.shaders.msl" +#define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_METALLIB_BOOLEAN "SDL.gpu.device.create.shaders.metallib" +#define SDL_PROP_GPU_DEVICE_CREATE_D3D12_ALLOW_FEWER_RESOURCE_SLOTS_BOOLEAN "SDL.gpu.device.create.d3d12.allowtier1resourcebinding" +#define SDL_PROP_GPU_DEVICE_CREATE_D3D12_SEMANTIC_NAME_STRING "SDL.gpu.device.create.d3d12.semantic" +#define SDL_PROP_GPU_DEVICE_CREATE_VULKAN_REQUIRE_HARDWARE_ACCELERATION_BOOLEAN "SDL.gpu.device.create.vulkan.requirehardwareacceleration" +#define SDL_PROP_GPU_DEVICE_CREATE_VULKAN_OPTIONS_POINTER "SDL.gpu.device.create.vulkan.options" + + +/** + * A structure specifying additional options when using Vulkan. + * + * When no such structure is provided, SDL will use Vulkan API version 1.0 and + * a minimal set of features. The requested API version influences how the + * feature_list is processed by SDL. When requesting API version 1.0, the + * feature_list is ignored. Only the vulkan_10_physical_device_features and + * the extension lists are used. When requesting API version 1.1, the + * feature_list is scanned for feature structures introduced in Vulkan 1.1. + * When requesting Vulkan 1.2 or higher, the feature_list is additionally + * scanned for compound feature structs such as + * VkPhysicalDeviceVulkan11Features. The device and instance extension lists, + * as well as vulkan_10_physical_device_features, are always processed. + * + * \since This struct is available since SDL 3.4.0. + */ +typedef struct SDL_GPUVulkanOptions +{ + Uint32 vulkan_api_version; /**< The Vulkan API version to request for the instance. Use Vulkan's VK_MAKE_VERSION or VK_MAKE_API_VERSION. */ + void *feature_list; /**< Pointer to the first element of a chain of Vulkan feature structs. (Requires API version 1.1 or higher.)*/ + void *vulkan_10_physical_device_features; /**< Pointer to a VkPhysicalDeviceFeatures struct to enable additional Vulkan 1.0 features. */ + Uint32 device_extension_count; /**< Number of additional device extensions to require. */ + const char **device_extension_names; /**< Pointer to a list of additional device extensions to require. */ + Uint32 instance_extension_count; /**< Number of additional instance extensions to require. */ + const char **instance_extension_names; /**< Pointer to a list of additional instance extensions to require. */ +} SDL_GPUVulkanOptions; + +/** + * Destroys a GPU context previously returned by SDL_CreateGPUDevice. + * + * \param device a GPU Context to destroy. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUDevice + */ +extern SDL_DECLSPEC void SDLCALL SDL_DestroyGPUDevice(SDL_GPUDevice *device); + +/** + * Get the number of GPU drivers compiled into SDL. + * + * \returns the number of built in GPU drivers. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetGPUDriver + */ +extern SDL_DECLSPEC int SDLCALL SDL_GetNumGPUDrivers(void); + +/** + * Get the name of a built in GPU driver. + * + * The GPU drivers are presented in the order in which they are normally + * checked during initialization. + * + * The names of drivers are all simple, low-ASCII identifiers, like "vulkan", + * "metal" or "direct3d12". These never have Unicode characters, and are not + * meant to be proper names. + * + * \param index the index of a GPU driver. + * \returns the name of the GPU driver with the given **index**. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetNumGPUDrivers + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetGPUDriver(int index); + +/** + * Returns the name of the backend used to create this GPU context. + * + * \param device a GPU context to query. + * \returns the name of the device's driver, or NULL on error. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetGPUDeviceDriver(SDL_GPUDevice *device); + +/** + * Returns the supported shader formats for this GPU context. + * + * \param device a GPU context to query. + * \returns a bitflag indicating which shader formats the driver is able to + * consume. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_GPUShaderFormat SDLCALL SDL_GetGPUShaderFormats(SDL_GPUDevice *device); + +/** + * Get the properties associated with a GPU device. + * + * All properties are optional and may differ between GPU backends and SDL + * versions. + * + * The following properties are provided by SDL: + * + * `SDL_PROP_GPU_DEVICE_NAME_STRING`: Contains the name of the underlying + * device as reported by the system driver. This string has no standardized + * format, is highly inconsistent between hardware devices and drivers, and is + * able to change at any time. Do not attempt to parse this string as it is + * bound to fail at some point in the future when system drivers are updated, + * new hardware devices are introduced, or when SDL adds new GPU backends or + * modifies existing ones. + * + * Strings that have been found in the wild include: + * + * - GTX 970 + * - GeForce GTX 970 + * - NVIDIA GeForce GTX 970 + * - Microsoft Direct3D12 (NVIDIA GeForce GTX 970) + * - NVIDIA Graphics Device + * - GeForce GPU + * - P106-100 + * - AMD 15D8:C9 + * - AMD Custom GPU 0405 + * - AMD Radeon (TM) Graphics + * - ASUS Radeon RX 470 Series + * - Intel(R) Arc(tm) A380 Graphics (DG2) + * - Virtio-GPU Venus (NVIDIA TITAN V) + * - SwiftShader Device (LLVM 16.0.0) + * - llvmpipe (LLVM 15.0.4, 256 bits) + * - Microsoft Basic Render Driver + * - unknown device + * + * The above list shows that the same device can have different formats, the + * vendor name may or may not appear in the string, the included vendor name + * may not be the vendor of the chipset on the device, some manufacturers + * include pseudo-legal marks while others don't, some devices may not use a + * marketing name in the string, the device string may be wrapped by the name + * of a translation interface, the device may be emulated in software, or the + * string may contain generic text that does not identify the device at all. + * + * `SDL_PROP_GPU_DEVICE_DRIVER_NAME_STRING`: Contains the self-reported name + * of the underlying system driver. + * + * Strings that have been found in the wild include: + * + * - Intel Corporation + * - Intel open-source Mesa driver + * - Qualcomm Technologies Inc. Adreno Vulkan Driver + * - MoltenVK + * - Mali-G715 + * - venus + * + * `SDL_PROP_GPU_DEVICE_DRIVER_VERSION_STRING`: Contains the self-reported + * version of the underlying system driver. This is a relatively short version + * string in an unspecified format. If SDL_PROP_GPU_DEVICE_DRIVER_INFO_STRING + * is available then that property should be preferred over this one as it may + * contain additional information that is useful for identifying the exact + * driver version used. + * + * Strings that have been found in the wild include: + * + * - 53.0.0 + * - 0.405.2463 + * - 32.0.15.6614 + * + * `SDL_PROP_GPU_DEVICE_DRIVER_INFO_STRING`: Contains the detailed version + * information of the underlying system driver as reported by the driver. This + * is an arbitrary string with no standardized format and it may contain + * newlines. This property should be preferred over + * SDL_PROP_GPU_DEVICE_DRIVER_VERSION_STRING if it is available as it usually + * contains the same information but in a format that is easier to read. + * + * Strings that have been found in the wild include: + * + * - 101.6559 + * - 1.2.11 + * - Mesa 21.2.2 (LLVM 12.0.1) + * - Mesa 22.2.0-devel (git-f226222 2022-04-14 impish-oibaf-ppa) + * - v1.r53p0-00eac0.824c4f31403fb1fbf8ee1042422c2129 + * + * This string has also been observed to be a multiline string (which has a + * trailing newline): + * + * ``` + * Driver Build: 85da404, I46ff5fc46f, 1606794520 + * Date: 11/30/20 + * Compiler Version: EV031.31.04.01 + * Driver Branch: promo490_3_Google + * ``` + * + * \param device a GPU context to query. + * \returns a valid property ID on success or 0 on failure; call + * SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.4.0. + */ +extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetGPUDeviceProperties(SDL_GPUDevice *device); + +#define SDL_PROP_GPU_DEVICE_NAME_STRING "SDL.gpu.device.name" +#define SDL_PROP_GPU_DEVICE_DRIVER_NAME_STRING "SDL.gpu.device.driver_name" +#define SDL_PROP_GPU_DEVICE_DRIVER_VERSION_STRING "SDL.gpu.device.driver_version" +#define SDL_PROP_GPU_DEVICE_DRIVER_INFO_STRING "SDL.gpu.device.driver_info" + + +/* State Creation */ + +/** + * Creates a pipeline object to be used in a compute workflow. + * + * Shader resource bindings must be authored to follow a particular order + * depending on the shader format. + * + * For SPIR-V shaders, use the following resource sets: + * + * - 0: Sampled textures, followed by read-only storage textures, followed by + * read-only storage buffers + * - 1: Read-write storage textures, followed by read-write storage buffers + * - 2: Uniform buffers + * + * For DXBC and DXIL shaders, use the following register order: + * + * - (t[n], space0): Sampled textures, followed by read-only storage textures, + * followed by read-only storage buffers + * - (u[n], space1): Read-write storage textures, followed by read-write + * storage buffers + * - (b[n], space2): Uniform buffers + * + * For MSL/metallib, use the following order: + * + * - [[buffer]]: Uniform buffers, followed by read-only storage buffers, + * followed by read-write storage buffers + * - [[texture]]: Sampled textures, followed by read-only storage textures, + * followed by read-write storage textures + * + * There are optional properties that can be provided through `props`. These + * are the supported properties: + * + * - `SDL_PROP_GPU_COMPUTEPIPELINE_CREATE_NAME_STRING`: a name that can be + * displayed in debugging tools. + * + * \param device a GPU Context. + * \param createinfo a struct describing the state of the compute pipeline to + * create. + * \returns a compute pipeline object on success, or NULL on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_BindGPUComputePipeline + * \sa SDL_ReleaseGPUComputePipeline + */ +extern SDL_DECLSPEC SDL_GPUComputePipeline * SDLCALL SDL_CreateGPUComputePipeline( + SDL_GPUDevice *device, + const SDL_GPUComputePipelineCreateInfo *createinfo); + +#define SDL_PROP_GPU_COMPUTEPIPELINE_CREATE_NAME_STRING "SDL.gpu.computepipeline.create.name" + +/** + * Creates a pipeline object to be used in a graphics workflow. + * + * There are optional properties that can be provided through `props`. These + * are the supported properties: + * + * - `SDL_PROP_GPU_GRAPHICSPIPELINE_CREATE_NAME_STRING`: a name that can be + * displayed in debugging tools. + * + * \param device a GPU Context. + * \param createinfo a struct describing the state of the graphics pipeline to + * create. + * \returns a graphics pipeline object on success, or NULL on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUShader + * \sa SDL_BindGPUGraphicsPipeline + * \sa SDL_ReleaseGPUGraphicsPipeline + */ +extern SDL_DECLSPEC SDL_GPUGraphicsPipeline * SDLCALL SDL_CreateGPUGraphicsPipeline( + SDL_GPUDevice *device, + const SDL_GPUGraphicsPipelineCreateInfo *createinfo); + +#define SDL_PROP_GPU_GRAPHICSPIPELINE_CREATE_NAME_STRING "SDL.gpu.graphicspipeline.create.name" + +/** + * Creates a sampler object to be used when binding textures in a graphics + * workflow. + * + * There are optional properties that can be provided through `props`. These + * are the supported properties: + * + * - `SDL_PROP_GPU_SAMPLER_CREATE_NAME_STRING`: a name that can be displayed + * in debugging tools. + * + * \param device a GPU Context. + * \param createinfo a struct describing the state of the sampler to create. + * \returns a sampler object on success, or NULL on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_BindGPUVertexSamplers + * \sa SDL_BindGPUFragmentSamplers + * \sa SDL_ReleaseGPUSampler + */ +extern SDL_DECLSPEC SDL_GPUSampler * SDLCALL SDL_CreateGPUSampler( + SDL_GPUDevice *device, + const SDL_GPUSamplerCreateInfo *createinfo); + +#define SDL_PROP_GPU_SAMPLER_CREATE_NAME_STRING "SDL.gpu.sampler.create.name" + +/** + * Creates a shader to be used when creating a graphics pipeline. + * + * Shader resource bindings must be authored to follow a particular order + * depending on the shader format. + * + * For SPIR-V shaders, use the following resource sets: + * + * For vertex shaders: + * + * - 0: Sampled textures, followed by storage textures, followed by storage + * buffers + * - 1: Uniform buffers + * + * For fragment shaders: + * + * - 2: Sampled textures, followed by storage textures, followed by storage + * buffers + * - 3: Uniform buffers + * + * For DXBC and DXIL shaders, use the following register order: + * + * For vertex shaders: + * + * - (t[n], space0): Sampled textures, followed by storage textures, followed + * by storage buffers + * - (s[n], space0): Samplers with indices corresponding to the sampled + * textures + * - (b[n], space1): Uniform buffers + * + * For pixel shaders: + * + * - (t[n], space2): Sampled textures, followed by storage textures, followed + * by storage buffers + * - (s[n], space2): Samplers with indices corresponding to the sampled + * textures + * - (b[n], space3): Uniform buffers + * + * For MSL/metallib, use the following order: + * + * - [[texture]]: Sampled textures, followed by storage textures + * - [[sampler]]: Samplers with indices corresponding to the sampled textures + * - [[buffer]]: Uniform buffers, followed by storage buffers. Vertex buffer 0 + * is bound at [[buffer(14)]], vertex buffer 1 at [[buffer(15)]], and so on. + * Rather than manually authoring vertex buffer indices, use the + * [[stage_in]] attribute which will automatically use the vertex input + * information from the SDL_GPUGraphicsPipeline. + * + * Shader semantics other than system-value semantics do not matter in D3D12 + * and for ease of use the SDL implementation assumes that non system-value + * semantics will all be TEXCOORD. If you are using HLSL as the shader source + * language, your vertex semantics should start at TEXCOORD0 and increment + * like so: TEXCOORD1, TEXCOORD2, etc. If you wish to change the semantic + * prefix to something other than TEXCOORD you can use + * SDL_PROP_GPU_DEVICE_CREATE_D3D12_SEMANTIC_NAME_STRING with + * SDL_CreateGPUDeviceWithProperties(). + * + * There are optional properties that can be provided through `props`. These + * are the supported properties: + * + * - `SDL_PROP_GPU_SHADER_CREATE_NAME_STRING`: a name that can be displayed in + * debugging tools. + * + * \param device a GPU Context. + * \param createinfo a struct describing the state of the shader to create. + * \returns a shader object on success, or NULL on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUGraphicsPipeline + * \sa SDL_ReleaseGPUShader + */ +extern SDL_DECLSPEC SDL_GPUShader * SDLCALL SDL_CreateGPUShader( + SDL_GPUDevice *device, + const SDL_GPUShaderCreateInfo *createinfo); + +#define SDL_PROP_GPU_SHADER_CREATE_NAME_STRING "SDL.gpu.shader.create.name" + +/** + * Creates a texture object to be used in graphics or compute workflows. + * + * The contents of this texture are undefined until data is written to the + * texture, either via SDL_UploadToGPUTexture or by performing a render or + * compute pass with this texture as a target. + * + * Note that certain combinations of usage flags are invalid. For example, a + * texture cannot have both the SAMPLER and GRAPHICS_STORAGE_READ flags. + * + * If you request a sample count higher than the hardware supports, the + * implementation will automatically fall back to the highest available sample + * count. + * + * There are optional properties that can be provided through + * SDL_GPUTextureCreateInfo's `props`. These are the supported properties: + * + * - `SDL_PROP_GPU_TEXTURE_CREATE_D3D12_CLEAR_R_FLOAT`: (Direct3D 12 only) if + * the texture usage is SDL_GPU_TEXTUREUSAGE_COLOR_TARGET, clear the texture + * to a color with this red intensity. Defaults to zero. + * - `SDL_PROP_GPU_TEXTURE_CREATE_D3D12_CLEAR_G_FLOAT`: (Direct3D 12 only) if + * the texture usage is SDL_GPU_TEXTUREUSAGE_COLOR_TARGET, clear the texture + * to a color with this green intensity. Defaults to zero. + * - `SDL_PROP_GPU_TEXTURE_CREATE_D3D12_CLEAR_B_FLOAT`: (Direct3D 12 only) if + * the texture usage is SDL_GPU_TEXTUREUSAGE_COLOR_TARGET, clear the texture + * to a color with this blue intensity. Defaults to zero. + * - `SDL_PROP_GPU_TEXTURE_CREATE_D3D12_CLEAR_A_FLOAT`: (Direct3D 12 only) if + * the texture usage is SDL_GPU_TEXTUREUSAGE_COLOR_TARGET, clear the texture + * to a color with this alpha intensity. Defaults to zero. + * - `SDL_PROP_GPU_TEXTURE_CREATE_D3D12_CLEAR_DEPTH_FLOAT`: (Direct3D 12 only) + * if the texture usage is SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET, clear + * the texture to a depth of this value. Defaults to zero. + * - `SDL_PROP_GPU_TEXTURE_CREATE_D3D12_CLEAR_STENCIL_NUMBER`: (Direct3D 12 + * only) if the texture usage is SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET, + * clear the texture to a stencil of this Uint8 value. Defaults to zero. + * - `SDL_PROP_GPU_TEXTURE_CREATE_NAME_STRING`: a name that can be displayed + * in debugging tools. + * + * \param device a GPU Context. + * \param createinfo a struct describing the state of the texture to create. + * \returns a texture object on success, or NULL on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_UploadToGPUTexture + * \sa SDL_DownloadFromGPUTexture + * \sa SDL_BeginGPURenderPass + * \sa SDL_BeginGPUComputePass + * \sa SDL_BindGPUVertexSamplers + * \sa SDL_BindGPUVertexStorageTextures + * \sa SDL_BindGPUFragmentSamplers + * \sa SDL_BindGPUFragmentStorageTextures + * \sa SDL_BindGPUComputeStorageTextures + * \sa SDL_BlitGPUTexture + * \sa SDL_ReleaseGPUTexture + * \sa SDL_GPUTextureSupportsFormat + */ +extern SDL_DECLSPEC SDL_GPUTexture * SDLCALL SDL_CreateGPUTexture( + SDL_GPUDevice *device, + const SDL_GPUTextureCreateInfo *createinfo); + +#define SDL_PROP_GPU_TEXTURE_CREATE_D3D12_CLEAR_R_FLOAT "SDL.gpu.texture.create.d3d12.clear.r" +#define SDL_PROP_GPU_TEXTURE_CREATE_D3D12_CLEAR_G_FLOAT "SDL.gpu.texture.create.d3d12.clear.g" +#define SDL_PROP_GPU_TEXTURE_CREATE_D3D12_CLEAR_B_FLOAT "SDL.gpu.texture.create.d3d12.clear.b" +#define SDL_PROP_GPU_TEXTURE_CREATE_D3D12_CLEAR_A_FLOAT "SDL.gpu.texture.create.d3d12.clear.a" +#define SDL_PROP_GPU_TEXTURE_CREATE_D3D12_CLEAR_DEPTH_FLOAT "SDL.gpu.texture.create.d3d12.clear.depth" +#define SDL_PROP_GPU_TEXTURE_CREATE_D3D12_CLEAR_STENCIL_NUMBER "SDL.gpu.texture.create.d3d12.clear.stencil" +#define SDL_PROP_GPU_TEXTURE_CREATE_NAME_STRING "SDL.gpu.texture.create.name" + +/** + * Creates a buffer object to be used in graphics or compute workflows. + * + * The contents of this buffer are undefined until data is written to the + * buffer. + * + * Note that certain combinations of usage flags are invalid. For example, a + * buffer cannot have both the VERTEX and INDEX flags. + * + * If you use a STORAGE flag, the data in the buffer must respect std140 + * layout conventions. In practical terms this means you must ensure that vec3 + * and vec4 fields are 16-byte aligned. + * + * For better understanding of underlying concepts and memory management with + * SDL GPU API, you may refer + * [this blog post](https://moonside.games/posts/sdl-gpu-concepts-cycling/) + * . + * + * There are optional properties that can be provided through `props`. These + * are the supported properties: + * + * - `SDL_PROP_GPU_BUFFER_CREATE_NAME_STRING`: a name that can be displayed in + * debugging tools. + * + * \param device a GPU Context. + * \param createinfo a struct describing the state of the buffer to create. + * \returns a buffer object on success, or NULL on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_UploadToGPUBuffer + * \sa SDL_DownloadFromGPUBuffer + * \sa SDL_CopyGPUBufferToBuffer + * \sa SDL_BindGPUVertexBuffers + * \sa SDL_BindGPUIndexBuffer + * \sa SDL_BindGPUVertexStorageBuffers + * \sa SDL_BindGPUFragmentStorageBuffers + * \sa SDL_DrawGPUPrimitivesIndirect + * \sa SDL_DrawGPUIndexedPrimitivesIndirect + * \sa SDL_BindGPUComputeStorageBuffers + * \sa SDL_DispatchGPUComputeIndirect + * \sa SDL_ReleaseGPUBuffer + */ +extern SDL_DECLSPEC SDL_GPUBuffer * SDLCALL SDL_CreateGPUBuffer( + SDL_GPUDevice *device, + const SDL_GPUBufferCreateInfo *createinfo); + +#define SDL_PROP_GPU_BUFFER_CREATE_NAME_STRING "SDL.gpu.buffer.create.name" + +/** + * Creates a transfer buffer to be used when uploading to or downloading from + * graphics resources. + * + * Download buffers can be particularly expensive to create, so it is good + * practice to reuse them if data will be downloaded regularly. + * + * There are optional properties that can be provided through `props`. These + * are the supported properties: + * + * - `SDL_PROP_GPU_TRANSFERBUFFER_CREATE_NAME_STRING`: a name that can be + * displayed in debugging tools. + * + * \param device a GPU Context. + * \param createinfo a struct describing the state of the transfer buffer to + * create. + * \returns a transfer buffer on success, or NULL on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_UploadToGPUBuffer + * \sa SDL_DownloadFromGPUBuffer + * \sa SDL_UploadToGPUTexture + * \sa SDL_DownloadFromGPUTexture + * \sa SDL_ReleaseGPUTransferBuffer + */ +extern SDL_DECLSPEC SDL_GPUTransferBuffer * SDLCALL SDL_CreateGPUTransferBuffer( + SDL_GPUDevice *device, + const SDL_GPUTransferBufferCreateInfo *createinfo); + +#define SDL_PROP_GPU_TRANSFERBUFFER_CREATE_NAME_STRING "SDL.gpu.transferbuffer.create.name" + +/* Debug Naming */ + +/** + * Sets an arbitrary string constant to label a buffer. + * + * You should use SDL_PROP_GPU_BUFFER_CREATE_NAME_STRING with + * SDL_CreateGPUBuffer instead of this function to avoid thread safety issues. + * + * \param device a GPU Context. + * \param buffer a buffer to attach the name to. + * \param text a UTF-8 string constant to mark as the name of the buffer. + * + * \threadsafety This function is not thread safe, you must make sure the + * buffer is not simultaneously used by any other thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUBuffer + */ +extern SDL_DECLSPEC void SDLCALL SDL_SetGPUBufferName( + SDL_GPUDevice *device, + SDL_GPUBuffer *buffer, + const char *text); + +/** + * Sets an arbitrary string constant to label a texture. + * + * You should use SDL_PROP_GPU_TEXTURE_CREATE_NAME_STRING with + * SDL_CreateGPUTexture instead of this function to avoid thread safety + * issues. + * + * \param device a GPU Context. + * \param texture a texture to attach the name to. + * \param text a UTF-8 string constant to mark as the name of the texture. + * + * \threadsafety This function is not thread safe, you must make sure the + * texture is not simultaneously used by any other thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUTexture + */ +extern SDL_DECLSPEC void SDLCALL SDL_SetGPUTextureName( + SDL_GPUDevice *device, + SDL_GPUTexture *texture, + const char *text); + +/** + * Inserts an arbitrary string label into the command buffer callstream. + * + * Useful for debugging. + * + * On Direct3D 12, using SDL_InsertGPUDebugLabel requires + * WinPixEventRuntime.dll to be in your PATH or in the same directory as your + * executable. See + * [here](https://devblogs.microsoft.com/pix/winpixeventruntime/) + * for instructions on how to obtain it. + * + * \param command_buffer a command buffer. + * \param text a UTF-8 string constant to insert as the label. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_InsertGPUDebugLabel( + SDL_GPUCommandBuffer *command_buffer, + const char *text); + +/** + * Begins a debug group with an arbitrary name. + * + * Used for denoting groups of calls when viewing the command buffer + * callstream in a graphics debugging tool. + * + * Each call to SDL_PushGPUDebugGroup must have a corresponding call to + * SDL_PopGPUDebugGroup. + * + * On Direct3D 12, using SDL_PushGPUDebugGroup requires WinPixEventRuntime.dll + * to be in your PATH or in the same directory as your executable. See + * [here](https://devblogs.microsoft.com/pix/winpixeventruntime/) + * for instructions on how to obtain it. + * + * On some backends (e.g. Metal), pushing a debug group during a + * render/blit/compute pass will create a group that is scoped to the native + * pass rather than the command buffer. For best results, if you push a debug + * group during a pass, always pop it in the same pass. + * + * \param command_buffer a command buffer. + * \param name a UTF-8 string constant that names the group. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_PopGPUDebugGroup + */ +extern SDL_DECLSPEC void SDLCALL SDL_PushGPUDebugGroup( + SDL_GPUCommandBuffer *command_buffer, + const char *name); + +/** + * Ends the most-recently pushed debug group. + * + * On Direct3D 12, using SDL_PopGPUDebugGroup requires WinPixEventRuntime.dll + * to be in your PATH or in the same directory as your executable. See + * [here](https://devblogs.microsoft.com/pix/winpixeventruntime/) + * for instructions on how to obtain it. + * + * \param command_buffer a command buffer. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_PushGPUDebugGroup + */ +extern SDL_DECLSPEC void SDLCALL SDL_PopGPUDebugGroup( + SDL_GPUCommandBuffer *command_buffer); + +/* Disposal */ + +/** + * Frees the given texture as soon as it is safe to do so. + * + * You must not reference the texture after calling this function. + * + * \param device a GPU context. + * \param texture a texture to be destroyed. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUTexture( + SDL_GPUDevice *device, + SDL_GPUTexture *texture); + +/** + * Frees the given sampler as soon as it is safe to do so. + * + * You must not reference the sampler after calling this function. + * + * \param device a GPU context. + * \param sampler a sampler to be destroyed. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUSampler( + SDL_GPUDevice *device, + SDL_GPUSampler *sampler); + +/** + * Frees the given buffer as soon as it is safe to do so. + * + * You must not reference the buffer after calling this function. + * + * \param device a GPU context. + * \param buffer a buffer to be destroyed. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUBuffer( + SDL_GPUDevice *device, + SDL_GPUBuffer *buffer); + +/** + * Frees the given transfer buffer as soon as it is safe to do so. + * + * You must not reference the transfer buffer after calling this function. + * + * \param device a GPU context. + * \param transfer_buffer a transfer buffer to be destroyed. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUTransferBuffer( + SDL_GPUDevice *device, + SDL_GPUTransferBuffer *transfer_buffer); + +/** + * Frees the given compute pipeline as soon as it is safe to do so. + * + * You must not reference the compute pipeline after calling this function. + * + * \param device a GPU context. + * \param compute_pipeline a compute pipeline to be destroyed. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUComputePipeline( + SDL_GPUDevice *device, + SDL_GPUComputePipeline *compute_pipeline); + +/** + * Frees the given shader as soon as it is safe to do so. + * + * You must not reference the shader after calling this function. + * + * \param device a GPU context. + * \param shader a shader to be destroyed. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUShader( + SDL_GPUDevice *device, + SDL_GPUShader *shader); + +/** + * Frees the given graphics pipeline as soon as it is safe to do so. + * + * You must not reference the graphics pipeline after calling this function. + * + * \param device a GPU context. + * \param graphics_pipeline a graphics pipeline to be destroyed. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUGraphicsPipeline( + SDL_GPUDevice *device, + SDL_GPUGraphicsPipeline *graphics_pipeline); + +/** + * Acquire a command buffer. + * + * This command buffer is managed by the implementation and should not be + * freed by the user. The command buffer may only be used on the thread it was + * acquired on. The command buffer should be submitted on the thread it was + * acquired on. + * + * It is valid to acquire multiple command buffers on the same thread at once. + * In fact a common design pattern is to acquire two command buffers per frame + * where one is dedicated to render and compute passes and the other is + * dedicated to copy passes and other preparatory work such as generating + * mipmaps. Interleaving commands between the two command buffers reduces the + * total amount of passes overall which improves rendering performance. + * + * \param device a GPU context. + * \returns a command buffer, or NULL on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SubmitGPUCommandBuffer + * \sa SDL_SubmitGPUCommandBufferAndAcquireFence + */ +extern SDL_DECLSPEC SDL_GPUCommandBuffer * SDLCALL SDL_AcquireGPUCommandBuffer( + SDL_GPUDevice *device); + +/* Uniform Data */ + +/** + * Pushes data to a vertex uniform slot on the command buffer. + * + * Subsequent draw calls in this command buffer will use this uniform data. + * + * The data being pushed must respect std140 layout conventions. In practical + * terms this means you must ensure that vec3 and vec4 fields are 16-byte + * aligned. + * + * For detailed information about accessing uniform data from a shader, please + * refer to SDL_CreateGPUShader. + * + * \param command_buffer a command buffer. + * \param slot_index the vertex uniform slot to push data to. + * \param data client data to write. + * \param length the length of the data to write. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_PushGPUVertexUniformData( + SDL_GPUCommandBuffer *command_buffer, + Uint32 slot_index, + const void *data, + Uint32 length); + +/** + * Pushes data to a fragment uniform slot on the command buffer. + * + * Subsequent draw calls in this command buffer will use this uniform data. + * + * The data being pushed must respect std140 layout conventions. In practical + * terms this means you must ensure that vec3 and vec4 fields are 16-byte + * aligned. + * + * \param command_buffer a command buffer. + * \param slot_index the fragment uniform slot to push data to. + * \param data client data to write. + * \param length the length of the data to write. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_PushGPUFragmentUniformData( + SDL_GPUCommandBuffer *command_buffer, + Uint32 slot_index, + const void *data, + Uint32 length); + +/** + * Pushes data to a uniform slot on the command buffer. + * + * Subsequent draw calls in this command buffer will use this uniform data. + * + * The data being pushed must respect std140 layout conventions. In practical + * terms this means you must ensure that vec3 and vec4 fields are 16-byte + * aligned. + * + * \param command_buffer a command buffer. + * \param slot_index the uniform slot to push data to. + * \param data client data to write. + * \param length the length of the data to write. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_PushGPUComputeUniformData( + SDL_GPUCommandBuffer *command_buffer, + Uint32 slot_index, + const void *data, + Uint32 length); + +/* Graphics State */ + +/** + * Begins a render pass on a command buffer. + * + * A render pass consists of a set of texture subresources (or depth slices in + * the 3D texture case) which will be rendered to during the render pass, + * along with corresponding clear values and load/store operations. All + * operations related to graphics pipelines must take place inside of a render + * pass. A default viewport and scissor state are automatically set when this + * is called. You cannot begin another render pass, or begin a compute pass or + * copy pass until you have ended the render pass. + * + * Using SDL_GPU_LOADOP_LOAD before any contents have been written to the + * texture subresource will result in undefined behavior. SDL_GPU_LOADOP_CLEAR + * will set the contents of the texture subresource to a single value before + * any rendering is performed. It's fine to do an empty render pass using + * SDL_GPU_STOREOP_STORE to clear a texture, but in general it's better to + * think of clearing not as an independent operation but as something that's + * done as the beginning of a render pass. + * + * \param command_buffer a command buffer. + * \param color_target_infos an array of texture subresources with + * corresponding clear values and load/store ops. + * \param num_color_targets the number of color targets in the + * color_target_infos array. + * \param depth_stencil_target_info a texture subresource with corresponding + * clear value and load/store ops, may be + * NULL. + * \returns a render pass handle. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_EndGPURenderPass + */ +extern SDL_DECLSPEC SDL_GPURenderPass * SDLCALL SDL_BeginGPURenderPass( + SDL_GPUCommandBuffer *command_buffer, + const SDL_GPUColorTargetInfo *color_target_infos, + Uint32 num_color_targets, + const SDL_GPUDepthStencilTargetInfo *depth_stencil_target_info); + +/** + * Binds a graphics pipeline on a render pass to be used in rendering. + * + * A graphics pipeline must be bound before making any draw calls. + * + * \param render_pass a render pass handle. + * \param graphics_pipeline the graphics pipeline to bind. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_BindGPUGraphicsPipeline( + SDL_GPURenderPass *render_pass, + SDL_GPUGraphicsPipeline *graphics_pipeline); + +/** + * Sets the current viewport state on a command buffer. + * + * \param render_pass a render pass handle. + * \param viewport the viewport to set. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_SetGPUViewport( + SDL_GPURenderPass *render_pass, + const SDL_GPUViewport *viewport); + +/** + * Sets the current scissor state on a command buffer. + * + * \param render_pass a render pass handle. + * \param scissor the scissor area to set. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_SetGPUScissor( + SDL_GPURenderPass *render_pass, + const SDL_Rect *scissor); + +/** + * Sets the current blend constants on a command buffer. + * + * \param render_pass a render pass handle. + * \param blend_constants the blend constant color. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GPU_BLENDFACTOR_CONSTANT_COLOR + * \sa SDL_GPU_BLENDFACTOR_ONE_MINUS_CONSTANT_COLOR + */ +extern SDL_DECLSPEC void SDLCALL SDL_SetGPUBlendConstants( + SDL_GPURenderPass *render_pass, + SDL_FColor blend_constants); + +/** + * Sets the current stencil reference value on a command buffer. + * + * \param render_pass a render pass handle. + * \param reference the stencil reference value to set. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_SetGPUStencilReference( + SDL_GPURenderPass *render_pass, + Uint8 reference); + +/** + * Binds vertex buffers on a command buffer for use with subsequent draw + * calls. + * + * \param render_pass a render pass handle. + * \param first_slot the vertex buffer slot to begin binding from. + * \param bindings an array of SDL_GPUBufferBinding structs containing vertex + * buffers and offset values. + * \param num_bindings the number of bindings in the bindings array. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_BindGPUVertexBuffers( + SDL_GPURenderPass *render_pass, + Uint32 first_slot, + const SDL_GPUBufferBinding *bindings, + Uint32 num_bindings); + +/** + * Binds an index buffer on a command buffer for use with subsequent draw + * calls. + * + * \param render_pass a render pass handle. + * \param binding a pointer to a struct containing an index buffer and offset. + * \param index_element_size whether the index values in the buffer are 16- or + * 32-bit. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_BindGPUIndexBuffer( + SDL_GPURenderPass *render_pass, + const SDL_GPUBufferBinding *binding, + SDL_GPUIndexElementSize index_element_size); + +/** + * Binds texture-sampler pairs for use on the vertex shader. + * + * The textures must have been created with SDL_GPU_TEXTUREUSAGE_SAMPLER. + * + * Be sure your shader is set up according to the requirements documented in + * SDL_CreateGPUShader(). + * + * \param render_pass a render pass handle. + * \param first_slot the vertex sampler slot to begin binding from. + * \param texture_sampler_bindings an array of texture-sampler binding + * structs. + * \param num_bindings the number of texture-sampler pairs to bind from the + * array. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUShader + */ +extern SDL_DECLSPEC void SDLCALL SDL_BindGPUVertexSamplers( + SDL_GPURenderPass *render_pass, + Uint32 first_slot, + const SDL_GPUTextureSamplerBinding *texture_sampler_bindings, + Uint32 num_bindings); + +/** + * Binds storage textures for use on the vertex shader. + * + * These textures must have been created with + * SDL_GPU_TEXTUREUSAGE_GRAPHICS_STORAGE_READ. + * + * Be sure your shader is set up according to the requirements documented in + * SDL_CreateGPUShader(). + * + * \param render_pass a render pass handle. + * \param first_slot the vertex storage texture slot to begin binding from. + * \param storage_textures an array of storage textures. + * \param num_bindings the number of storage texture to bind from the array. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUShader + */ +extern SDL_DECLSPEC void SDLCALL SDL_BindGPUVertexStorageTextures( + SDL_GPURenderPass *render_pass, + Uint32 first_slot, + SDL_GPUTexture *const *storage_textures, + Uint32 num_bindings); + +/** + * Binds storage buffers for use on the vertex shader. + * + * These buffers must have been created with + * SDL_GPU_BUFFERUSAGE_GRAPHICS_STORAGE_READ. + * + * Be sure your shader is set up according to the requirements documented in + * SDL_CreateGPUShader(). + * + * \param render_pass a render pass handle. + * \param first_slot the vertex storage buffer slot to begin binding from. + * \param storage_buffers an array of buffers. + * \param num_bindings the number of buffers to bind from the array. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUShader + */ +extern SDL_DECLSPEC void SDLCALL SDL_BindGPUVertexStorageBuffers( + SDL_GPURenderPass *render_pass, + Uint32 first_slot, + SDL_GPUBuffer *const *storage_buffers, + Uint32 num_bindings); + +/** + * Binds texture-sampler pairs for use on the fragment shader. + * + * The textures must have been created with SDL_GPU_TEXTUREUSAGE_SAMPLER. + * + * Be sure your shader is set up according to the requirements documented in + * SDL_CreateGPUShader(). + * + * \param render_pass a render pass handle. + * \param first_slot the fragment sampler slot to begin binding from. + * \param texture_sampler_bindings an array of texture-sampler binding + * structs. + * \param num_bindings the number of texture-sampler pairs to bind from the + * array. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUShader + */ +extern SDL_DECLSPEC void SDLCALL SDL_BindGPUFragmentSamplers( + SDL_GPURenderPass *render_pass, + Uint32 first_slot, + const SDL_GPUTextureSamplerBinding *texture_sampler_bindings, + Uint32 num_bindings); + +/** + * Binds storage textures for use on the fragment shader. + * + * These textures must have been created with + * SDL_GPU_TEXTUREUSAGE_GRAPHICS_STORAGE_READ. + * + * Be sure your shader is set up according to the requirements documented in + * SDL_CreateGPUShader(). + * + * \param render_pass a render pass handle. + * \param first_slot the fragment storage texture slot to begin binding from. + * \param storage_textures an array of storage textures. + * \param num_bindings the number of storage textures to bind from the array. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUShader + */ +extern SDL_DECLSPEC void SDLCALL SDL_BindGPUFragmentStorageTextures( + SDL_GPURenderPass *render_pass, + Uint32 first_slot, + SDL_GPUTexture *const *storage_textures, + Uint32 num_bindings); + +/** + * Binds storage buffers for use on the fragment shader. + * + * These buffers must have been created with + * SDL_GPU_BUFFERUSAGE_GRAPHICS_STORAGE_READ. + * + * Be sure your shader is set up according to the requirements documented in + * SDL_CreateGPUShader(). + * + * \param render_pass a render pass handle. + * \param first_slot the fragment storage buffer slot to begin binding from. + * \param storage_buffers an array of storage buffers. + * \param num_bindings the number of storage buffers to bind from the array. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUShader + */ +extern SDL_DECLSPEC void SDLCALL SDL_BindGPUFragmentStorageBuffers( + SDL_GPURenderPass *render_pass, + Uint32 first_slot, + SDL_GPUBuffer *const *storage_buffers, + Uint32 num_bindings); + +/* Drawing */ + +/** + * Draws data using bound graphics state with an index buffer and instancing + * enabled. + * + * You must not call this function before binding a graphics pipeline. + * + * Note that the `first_vertex` and `first_instance` parameters are NOT + * compatible with built-in vertex/instance ID variables in shaders (for + * example, SV_VertexID); GPU APIs and shader languages do not define these + * built-in variables consistently, so if your shader depends on them, the + * only way to keep behavior consistent and portable is to always pass 0 for + * the correlating parameter in the draw calls. + * + * \param render_pass a render pass handle. + * \param num_indices the number of indices to draw per instance. + * \param num_instances the number of instances to draw. + * \param first_index the starting index within the index buffer. + * \param vertex_offset value added to vertex index before indexing into the + * vertex buffer. + * \param first_instance the ID of the first instance to draw. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_DrawGPUIndexedPrimitives( + SDL_GPURenderPass *render_pass, + Uint32 num_indices, + Uint32 num_instances, + Uint32 first_index, + Sint32 vertex_offset, + Uint32 first_instance); + +/** + * Draws data using bound graphics state. + * + * You must not call this function before binding a graphics pipeline. + * + * Note that the `first_vertex` and `first_instance` parameters are NOT + * compatible with built-in vertex/instance ID variables in shaders (for + * example, SV_VertexID); GPU APIs and shader languages do not define these + * built-in variables consistently, so if your shader depends on them, the + * only way to keep behavior consistent and portable is to always pass 0 for + * the correlating parameter in the draw calls. + * + * \param render_pass a render pass handle. + * \param num_vertices the number of vertices to draw. + * \param num_instances the number of instances that will be drawn. + * \param first_vertex the index of the first vertex to draw. + * \param first_instance the ID of the first instance to draw. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_DrawGPUPrimitives( + SDL_GPURenderPass *render_pass, + Uint32 num_vertices, + Uint32 num_instances, + Uint32 first_vertex, + Uint32 first_instance); + +/** + * Draws data using bound graphics state and with draw parameters set from a + * buffer. + * + * The buffer must consist of tightly-packed draw parameter sets that each + * match the layout of SDL_GPUIndirectDrawCommand. You must not call this + * function before binding a graphics pipeline. + * + * \param render_pass a render pass handle. + * \param buffer a buffer containing draw parameters. + * \param offset the offset to start reading from the draw buffer. + * \param draw_count the number of draw parameter sets that should be read + * from the draw buffer. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_DrawGPUPrimitivesIndirect( + SDL_GPURenderPass *render_pass, + SDL_GPUBuffer *buffer, + Uint32 offset, + Uint32 draw_count); + +/** + * Draws data using bound graphics state with an index buffer enabled and with + * draw parameters set from a buffer. + * + * The buffer must consist of tightly-packed draw parameter sets that each + * match the layout of SDL_GPUIndexedIndirectDrawCommand. You must not call + * this function before binding a graphics pipeline. + * + * \param render_pass a render pass handle. + * \param buffer a buffer containing draw parameters. + * \param offset the offset to start reading from the draw buffer. + * \param draw_count the number of draw parameter sets that should be read + * from the draw buffer. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_DrawGPUIndexedPrimitivesIndirect( + SDL_GPURenderPass *render_pass, + SDL_GPUBuffer *buffer, + Uint32 offset, + Uint32 draw_count); + +/** + * Ends the given render pass. + * + * All bound graphics state on the render pass command buffer is unset. The + * render pass handle is now invalid. + * + * \param render_pass a render pass handle. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_EndGPURenderPass( + SDL_GPURenderPass *render_pass); + +/* Compute Pass */ + +/** + * Begins a compute pass on a command buffer. + * + * A compute pass is defined by a set of texture subresources and buffers that + * may be written to by compute pipelines. These textures and buffers must + * have been created with the COMPUTE_STORAGE_WRITE bit or the + * COMPUTE_STORAGE_SIMULTANEOUS_READ_WRITE bit. If you do not create a texture + * with COMPUTE_STORAGE_SIMULTANEOUS_READ_WRITE, you must not read from the + * texture in the compute pass. All operations related to compute pipelines + * must take place inside of a compute pass. You must not begin another + * compute pass, or a render pass or copy pass before ending the compute pass. + * + * A VERY IMPORTANT NOTE - Reads and writes in compute passes are NOT + * implicitly synchronized. This means you may cause data races by both + * reading and writing a resource region in a compute pass, or by writing + * multiple times to a resource region. If your compute work depends on + * reading the completed output from a previous dispatch, you MUST end the + * current compute pass and begin a new one before you can safely access the + * data. Otherwise you will receive unexpected results. Reading and writing a + * texture in the same compute pass is only supported by specific texture + * formats. Make sure you check the format support! + * + * \param command_buffer a command buffer. + * \param storage_texture_bindings an array of writeable storage texture + * binding structs. + * \param num_storage_texture_bindings the number of storage textures to bind + * from the array. + * \param storage_buffer_bindings an array of writeable storage buffer binding + * structs. + * \param num_storage_buffer_bindings the number of storage buffers to bind + * from the array. + * \returns a compute pass handle. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_EndGPUComputePass + */ +extern SDL_DECLSPEC SDL_GPUComputePass * SDLCALL SDL_BeginGPUComputePass( + SDL_GPUCommandBuffer *command_buffer, + const SDL_GPUStorageTextureReadWriteBinding *storage_texture_bindings, + Uint32 num_storage_texture_bindings, + const SDL_GPUStorageBufferReadWriteBinding *storage_buffer_bindings, + Uint32 num_storage_buffer_bindings); + +/** + * Binds a compute pipeline on a command buffer for use in compute dispatch. + * + * \param compute_pass a compute pass handle. + * \param compute_pipeline a compute pipeline to bind. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_BindGPUComputePipeline( + SDL_GPUComputePass *compute_pass, + SDL_GPUComputePipeline *compute_pipeline); + +/** + * Binds texture-sampler pairs for use on the compute shader. + * + * The textures must have been created with SDL_GPU_TEXTUREUSAGE_SAMPLER. + * + * Be sure your shader is set up according to the requirements documented in + * SDL_CreateGPUComputePipeline(). + * + * \param compute_pass a compute pass handle. + * \param first_slot the compute sampler slot to begin binding from. + * \param texture_sampler_bindings an array of texture-sampler binding + * structs. + * \param num_bindings the number of texture-sampler bindings to bind from the + * array. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUComputePipeline + */ +extern SDL_DECLSPEC void SDLCALL SDL_BindGPUComputeSamplers( + SDL_GPUComputePass *compute_pass, + Uint32 first_slot, + const SDL_GPUTextureSamplerBinding *texture_sampler_bindings, + Uint32 num_bindings); + +/** + * Binds storage textures as readonly for use on the compute pipeline. + * + * These textures must have been created with + * SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_READ. + * + * Be sure your shader is set up according to the requirements documented in + * SDL_CreateGPUComputePipeline(). + * + * \param compute_pass a compute pass handle. + * \param first_slot the compute storage texture slot to begin binding from. + * \param storage_textures an array of storage textures. + * \param num_bindings the number of storage textures to bind from the array. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUComputePipeline + */ +extern SDL_DECLSPEC void SDLCALL SDL_BindGPUComputeStorageTextures( + SDL_GPUComputePass *compute_pass, + Uint32 first_slot, + SDL_GPUTexture *const *storage_textures, + Uint32 num_bindings); + +/** + * Binds storage buffers as readonly for use on the compute pipeline. + * + * These buffers must have been created with + * SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_READ. + * + * Be sure your shader is set up according to the requirements documented in + * SDL_CreateGPUComputePipeline(). + * + * \param compute_pass a compute pass handle. + * \param first_slot the compute storage buffer slot to begin binding from. + * \param storage_buffers an array of storage buffer binding structs. + * \param num_bindings the number of storage buffers to bind from the array. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateGPUComputePipeline + */ +extern SDL_DECLSPEC void SDLCALL SDL_BindGPUComputeStorageBuffers( + SDL_GPUComputePass *compute_pass, + Uint32 first_slot, + SDL_GPUBuffer *const *storage_buffers, + Uint32 num_bindings); + +/** + * Dispatches compute work. + * + * You must not call this function before binding a compute pipeline. + * + * A VERY IMPORTANT NOTE If you dispatch multiple times in a compute pass, and + * the dispatches write to the same resource region as each other, there is no + * guarantee of which order the writes will occur. If the write order matters, + * you MUST end the compute pass and begin another one. + * + * \param compute_pass a compute pass handle. + * \param groupcount_x number of local workgroups to dispatch in the X + * dimension. + * \param groupcount_y number of local workgroups to dispatch in the Y + * dimension. + * \param groupcount_z number of local workgroups to dispatch in the Z + * dimension. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_DispatchGPUCompute( + SDL_GPUComputePass *compute_pass, + Uint32 groupcount_x, + Uint32 groupcount_y, + Uint32 groupcount_z); + +/** + * Dispatches compute work with parameters set from a buffer. + * + * The buffer layout should match the layout of + * SDL_GPUIndirectDispatchCommand. You must not call this function before + * binding a compute pipeline. + * + * A VERY IMPORTANT NOTE If you dispatch multiple times in a compute pass, and + * the dispatches write to the same resource region as each other, there is no + * guarantee of which order the writes will occur. If the write order matters, + * you MUST end the compute pass and begin another one. + * + * \param compute_pass a compute pass handle. + * \param buffer a buffer containing dispatch parameters. + * \param offset the offset to start reading from the dispatch buffer. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_DispatchGPUComputeIndirect( + SDL_GPUComputePass *compute_pass, + SDL_GPUBuffer *buffer, + Uint32 offset); + +/** + * Ends the current compute pass. + * + * All bound compute state on the command buffer is unset. The compute pass + * handle is now invalid. + * + * \param compute_pass a compute pass handle. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_EndGPUComputePass( + SDL_GPUComputePass *compute_pass); + +/* TransferBuffer Data */ + +/** + * Maps a transfer buffer into application address space. + * + * You must unmap the transfer buffer before encoding upload commands. The + * memory is owned by the graphics driver - do NOT call SDL_free() on the + * returned pointer. + * + * \param device a GPU context. + * \param transfer_buffer a transfer buffer. + * \param cycle if true, cycles the transfer buffer if it is already bound. + * \returns the address of the mapped transfer buffer memory, or NULL on + * failure; call SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void * SDLCALL SDL_MapGPUTransferBuffer( + SDL_GPUDevice *device, + SDL_GPUTransferBuffer *transfer_buffer, + bool cycle); + +/** + * Unmaps a previously mapped transfer buffer. + * + * \param device a GPU context. + * \param transfer_buffer a previously mapped transfer buffer. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_UnmapGPUTransferBuffer( + SDL_GPUDevice *device, + SDL_GPUTransferBuffer *transfer_buffer); + +/* Copy Pass */ + +/** + * Begins a copy pass on a command buffer. + * + * All operations related to copying to or from buffers or textures take place + * inside a copy pass. You must not begin another copy pass, or a render pass + * or compute pass before ending the copy pass. + * + * \param command_buffer a command buffer. + * \returns a copy pass handle. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_EndGPUCopyPass + */ +extern SDL_DECLSPEC SDL_GPUCopyPass * SDLCALL SDL_BeginGPUCopyPass( + SDL_GPUCommandBuffer *command_buffer); + +/** + * Uploads data from a transfer buffer to a texture. + * + * The upload occurs on the GPU timeline. You may assume that the upload has + * finished in subsequent commands. + * + * You must align the data in the transfer buffer to a multiple of the texel + * size of the texture format. + * + * \param copy_pass a copy pass handle. + * \param source the source transfer buffer with image layout information. + * \param destination the destination texture region. + * \param cycle if true, cycles the texture if the texture is bound, otherwise + * overwrites the data. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_UploadToGPUTexture( + SDL_GPUCopyPass *copy_pass, + const SDL_GPUTextureTransferInfo *source, + const SDL_GPUTextureRegion *destination, + bool cycle); + +/** + * Uploads data from a transfer buffer to a buffer. + * + * The upload occurs on the GPU timeline. You may assume that the upload has + * finished in subsequent commands. + * + * \param copy_pass a copy pass handle. + * \param source the source transfer buffer with offset. + * \param destination the destination buffer with offset and size. + * \param cycle if true, cycles the buffer if it is already bound, otherwise + * overwrites the data. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_UploadToGPUBuffer( + SDL_GPUCopyPass *copy_pass, + const SDL_GPUTransferBufferLocation *source, + const SDL_GPUBufferRegion *destination, + bool cycle); + +/** + * Performs a texture-to-texture copy. + * + * This copy occurs on the GPU timeline. You may assume the copy has finished + * in subsequent commands. + * + * This function does not support copying between depth and color textures. + * For those, copy the texture to a buffer and then to the destination + * texture. + * + * \param copy_pass a copy pass handle. + * \param source a source texture region. + * \param destination a destination texture region. + * \param w the width of the region to copy. + * \param h the height of the region to copy. + * \param d the depth of the region to copy. + * \param cycle if true, cycles the destination texture if the destination + * texture is bound, otherwise overwrites the data. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_CopyGPUTextureToTexture( + SDL_GPUCopyPass *copy_pass, + const SDL_GPUTextureLocation *source, + const SDL_GPUTextureLocation *destination, + Uint32 w, + Uint32 h, + Uint32 d, + bool cycle); + +/** + * Performs a buffer-to-buffer copy. + * + * This copy occurs on the GPU timeline. You may assume the copy has finished + * in subsequent commands. + * + * \param copy_pass a copy pass handle. + * \param source the buffer and offset to copy from. + * \param destination the buffer and offset to copy to. + * \param size the length of the buffer to copy. + * \param cycle if true, cycles the destination buffer if it is already bound, + * otherwise overwrites the data. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_CopyGPUBufferToBuffer( + SDL_GPUCopyPass *copy_pass, + const SDL_GPUBufferLocation *source, + const SDL_GPUBufferLocation *destination, + Uint32 size, + bool cycle); + +/** + * Copies data from a texture to a transfer buffer on the GPU timeline. + * + * This data is not guaranteed to be copied until the command buffer fence is + * signaled. + * + * \param copy_pass a copy pass handle. + * \param source the source texture region. + * \param destination the destination transfer buffer with image layout + * information. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_DownloadFromGPUTexture( + SDL_GPUCopyPass *copy_pass, + const SDL_GPUTextureRegion *source, + const SDL_GPUTextureTransferInfo *destination); + +/** + * Copies data from a buffer to a transfer buffer on the GPU timeline. + * + * This data is not guaranteed to be copied until the command buffer fence is + * signaled. + * + * \param copy_pass a copy pass handle. + * \param source the source buffer with offset and size. + * \param destination the destination transfer buffer with offset. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_DownloadFromGPUBuffer( + SDL_GPUCopyPass *copy_pass, + const SDL_GPUBufferRegion *source, + const SDL_GPUTransferBufferLocation *destination); + +/** + * Ends the current copy pass. + * + * \param copy_pass a copy pass handle. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_EndGPUCopyPass( + SDL_GPUCopyPass *copy_pass); + +/** + * Generates mipmaps for the given texture. + * + * This function must not be called inside of any pass. + * + * \param command_buffer a command_buffer. + * \param texture a texture with more than 1 mip level. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_GenerateMipmapsForGPUTexture( + SDL_GPUCommandBuffer *command_buffer, + SDL_GPUTexture *texture); + +/** + * Blits from a source texture region to a destination texture region. + * + * This function must not be called inside of any pass. + * + * \param command_buffer a command buffer. + * \param info the blit info struct containing the blit parameters. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_BlitGPUTexture( + SDL_GPUCommandBuffer *command_buffer, + const SDL_GPUBlitInfo *info); + +/* Submission/Presentation */ + +/** + * Determines whether a swapchain composition is supported by the window. + * + * The window must be claimed before calling this function. + * + * \param device a GPU context. + * \param window an SDL_Window. + * \param swapchain_composition the swapchain composition to check. + * \returns true if supported, false if unsupported. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_ClaimWindowForGPUDevice + */ +extern SDL_DECLSPEC bool SDLCALL SDL_WindowSupportsGPUSwapchainComposition( + SDL_GPUDevice *device, + SDL_Window *window, + SDL_GPUSwapchainComposition swapchain_composition); + +/** + * Determines whether a presentation mode is supported by the window. + * + * The window must be claimed before calling this function. + * + * \param device a GPU context. + * \param window an SDL_Window. + * \param present_mode the presentation mode to check. + * \returns true if supported, false if unsupported. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_ClaimWindowForGPUDevice + */ +extern SDL_DECLSPEC bool SDLCALL SDL_WindowSupportsGPUPresentMode( + SDL_GPUDevice *device, + SDL_Window *window, + SDL_GPUPresentMode present_mode); + +/** + * Claims a window, creating a swapchain structure for it. + * + * This must be called before SDL_AcquireGPUSwapchainTexture is called using + * the window. You should only call this function from the thread that created + * the window. + * + * The swapchain will be created with SDL_GPU_SWAPCHAINCOMPOSITION_SDR and + * SDL_GPU_PRESENTMODE_VSYNC. If you want to have different swapchain + * parameters, you must call SDL_SetGPUSwapchainParameters after claiming the + * window. + * + * \param device a GPU context. + * \param window an SDL_Window. + * \returns true on success, or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called from the thread that + * created the window. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_WaitAndAcquireGPUSwapchainTexture + * \sa SDL_ReleaseWindowFromGPUDevice + * \sa SDL_WindowSupportsGPUPresentMode + * \sa SDL_WindowSupportsGPUSwapchainComposition + */ +extern SDL_DECLSPEC bool SDLCALL SDL_ClaimWindowForGPUDevice( + SDL_GPUDevice *device, + SDL_Window *window); + +/** + * Unclaims a window, destroying its swapchain structure. + * + * \param device a GPU context. + * \param window an SDL_Window that has been claimed. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_ClaimWindowForGPUDevice + */ +extern SDL_DECLSPEC void SDLCALL SDL_ReleaseWindowFromGPUDevice( + SDL_GPUDevice *device, + SDL_Window *window); + +/** + * Changes the swapchain parameters for the given claimed window. + * + * This function will fail if the requested present mode or swapchain + * composition are unsupported by the device. Check if the parameters are + * supported via SDL_WindowSupportsGPUPresentMode / + * SDL_WindowSupportsGPUSwapchainComposition prior to calling this function. + * + * SDL_GPU_PRESENTMODE_VSYNC with SDL_GPU_SWAPCHAINCOMPOSITION_SDR is always + * supported. + * + * \param device a GPU context. + * \param window an SDL_Window that has been claimed. + * \param swapchain_composition the desired composition of the swapchain. + * \param present_mode the desired present mode for the swapchain. + * \returns true if successful, false on error; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_WindowSupportsGPUPresentMode + * \sa SDL_WindowSupportsGPUSwapchainComposition + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetGPUSwapchainParameters( + SDL_GPUDevice *device, + SDL_Window *window, + SDL_GPUSwapchainComposition swapchain_composition, + SDL_GPUPresentMode present_mode); + +/** + * Configures the maximum allowed number of frames in flight. + * + * The default value when the device is created is 2. This means that after + * you have submitted 2 frames for presentation, if the GPU has not finished + * working on the first frame, SDL_AcquireGPUSwapchainTexture() will fill the + * swapchain texture pointer with NULL, and + * SDL_WaitAndAcquireGPUSwapchainTexture() will block. + * + * Higher values increase throughput at the expense of visual latency. Lower + * values decrease visual latency at the expense of throughput. + * + * Note that calling this function will stall and flush the command queue to + * prevent synchronization issues. + * + * The minimum value of allowed frames in flight is 1, and the maximum is 3. + * + * \param device a GPU context. + * \param allowed_frames_in_flight the maximum number of frames that can be + * pending on the GPU. + * \returns true if successful, false on error; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetGPUAllowedFramesInFlight( + SDL_GPUDevice *device, + Uint32 allowed_frames_in_flight); + +/** + * Obtains the texture format of the swapchain for the given window. + * + * Note that this format can change if the swapchain parameters change. + * + * \param device a GPU context. + * \param window an SDL_Window that has been claimed. + * \returns the texture format of the swapchain. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_GPUTextureFormat SDLCALL SDL_GetGPUSwapchainTextureFormat( + SDL_GPUDevice *device, + SDL_Window *window); + +/** + * Acquire a texture to use in presentation. + * + * When a swapchain texture is acquired on a command buffer, it will + * automatically be submitted for presentation when the command buffer is + * submitted. The swapchain texture should only be referenced by the command + * buffer used to acquire it. + * + * This function will fill the swapchain texture handle with NULL if too many + * frames are in flight. This is not an error. This NULL pointer should not be + * passed back into SDL. Instead, it should be considered as an indication to + * wait until the swapchain is available. + * + * If you use this function, it is possible to create a situation where many + * command buffers are allocated while the rendering context waits for the GPU + * to catch up, which will cause memory usage to grow. You should use + * SDL_WaitAndAcquireGPUSwapchainTexture() unless you know what you are doing + * with timing. + * + * The swapchain texture is managed by the implementation and must not be + * freed by the user. You MUST NOT call this function from any thread other + * than the one that created the window. + * + * \param command_buffer a command buffer. + * \param window a window that has been claimed. + * \param swapchain_texture a pointer filled in with a swapchain texture + * handle. + * \param swapchain_texture_width a pointer filled in with the swapchain + * texture width, may be NULL. + * \param swapchain_texture_height a pointer filled in with the swapchain + * texture height, may be NULL. + * \returns true on success, false on error; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called from the thread that + * created the window. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_ClaimWindowForGPUDevice + * \sa SDL_SubmitGPUCommandBuffer + * \sa SDL_SubmitGPUCommandBufferAndAcquireFence + * \sa SDL_CancelGPUCommandBuffer + * \sa SDL_GetWindowSizeInPixels + * \sa SDL_WaitForGPUSwapchain + * \sa SDL_WaitAndAcquireGPUSwapchainTexture + * \sa SDL_SetGPUAllowedFramesInFlight + */ +extern SDL_DECLSPEC bool SDLCALL SDL_AcquireGPUSwapchainTexture( + SDL_GPUCommandBuffer *command_buffer, + SDL_Window *window, + SDL_GPUTexture **swapchain_texture, + Uint32 *swapchain_texture_width, + Uint32 *swapchain_texture_height); + +/** + * Blocks the thread until a swapchain texture is available to be acquired. + * + * \param device a GPU context. + * \param window a window that has been claimed. + * \returns true on success, false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called from the thread that + * created the window. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_AcquireGPUSwapchainTexture + * \sa SDL_WaitAndAcquireGPUSwapchainTexture + * \sa SDL_SetGPUAllowedFramesInFlight + */ +extern SDL_DECLSPEC bool SDLCALL SDL_WaitForGPUSwapchain( + SDL_GPUDevice *device, + SDL_Window *window); + +/** + * Blocks the thread until a swapchain texture is available to be acquired, + * and then acquires it. + * + * When a swapchain texture is acquired on a command buffer, it will + * automatically be submitted for presentation when the command buffer is + * submitted. The swapchain texture should only be referenced by the command + * buffer used to acquire it. It is an error to call + * SDL_CancelGPUCommandBuffer() after a swapchain texture is acquired. + * + * This function can fill the swapchain texture handle with NULL in certain + * cases, for example if the window is minimized. This is not an error. You + * should always make sure to check whether the pointer is NULL before + * actually using it. + * + * The swapchain texture is managed by the implementation and must not be + * freed by the user. You MUST NOT call this function from any thread other + * than the one that created the window. + * + * The swapchain texture is write-only and cannot be used as a sampler or for + * another reading operation. + * + * \param command_buffer a command buffer. + * \param window a window that has been claimed. + * \param swapchain_texture a pointer filled in with a swapchain texture + * handle. + * \param swapchain_texture_width a pointer filled in with the swapchain + * texture width, may be NULL. + * \param swapchain_texture_height a pointer filled in with the swapchain + * texture height, may be NULL. + * \returns true on success, false on error; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called from the thread that + * created the window. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SubmitGPUCommandBuffer + * \sa SDL_SubmitGPUCommandBufferAndAcquireFence + * \sa SDL_AcquireGPUSwapchainTexture + */ +extern SDL_DECLSPEC bool SDLCALL SDL_WaitAndAcquireGPUSwapchainTexture( + SDL_GPUCommandBuffer *command_buffer, + SDL_Window *window, + SDL_GPUTexture **swapchain_texture, + Uint32 *swapchain_texture_width, + Uint32 *swapchain_texture_height); + +/** + * Submits a command buffer so its commands can be processed on the GPU. + * + * It is invalid to use the command buffer after this is called. + * + * This must be called from the thread the command buffer was acquired on. + * + * All commands in the submission are guaranteed to begin executing before any + * command in a subsequent submission begins executing. + * + * \param command_buffer a command buffer. + * \returns true on success, false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_AcquireGPUCommandBuffer + * \sa SDL_WaitAndAcquireGPUSwapchainTexture + * \sa SDL_AcquireGPUSwapchainTexture + * \sa SDL_SubmitGPUCommandBufferAndAcquireFence + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SubmitGPUCommandBuffer( + SDL_GPUCommandBuffer *command_buffer); + +/** + * Submits a command buffer so its commands can be processed on the GPU, and + * acquires a fence associated with the command buffer. + * + * You must release this fence when it is no longer needed or it will cause a + * leak. It is invalid to use the command buffer after this is called. + * + * This must be called from the thread the command buffer was acquired on. + * + * All commands in the submission are guaranteed to begin executing before any + * command in a subsequent submission begins executing. + * + * \param command_buffer a command buffer. + * \returns a fence associated with the command buffer, or NULL on failure; + * call SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_AcquireGPUCommandBuffer + * \sa SDL_WaitAndAcquireGPUSwapchainTexture + * \sa SDL_AcquireGPUSwapchainTexture + * \sa SDL_SubmitGPUCommandBuffer + * \sa SDL_ReleaseGPUFence + */ +extern SDL_DECLSPEC SDL_GPUFence * SDLCALL SDL_SubmitGPUCommandBufferAndAcquireFence( + SDL_GPUCommandBuffer *command_buffer); + +/** + * Cancels a command buffer. + * + * None of the enqueued commands are executed. + * + * It is an error to call this function after a swapchain texture has been + * acquired. + * + * This must be called from the thread the command buffer was acquired on. + * + * You must not reference the command buffer after calling this function. + * + * \param command_buffer a command buffer. + * \returns true on success, false on error; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_WaitAndAcquireGPUSwapchainTexture + * \sa SDL_AcquireGPUCommandBuffer + * \sa SDL_AcquireGPUSwapchainTexture + */ +extern SDL_DECLSPEC bool SDLCALL SDL_CancelGPUCommandBuffer( + SDL_GPUCommandBuffer *command_buffer); + +/** + * Blocks the thread until the GPU is completely idle. + * + * \param device a GPU context. + * \returns true on success, false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_WaitForGPUFences + */ +extern SDL_DECLSPEC bool SDLCALL SDL_WaitForGPUIdle( + SDL_GPUDevice *device); + +/** + * Blocks the thread until the given fences are signaled. + * + * \param device a GPU context. + * \param wait_all if 0, wait for any fence to be signaled, if 1, wait for all + * fences to be signaled. + * \param fences an array of fences to wait on. + * \param num_fences the number of fences in the fences array. + * \returns true on success, false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SubmitGPUCommandBufferAndAcquireFence + * \sa SDL_WaitForGPUIdle + */ +extern SDL_DECLSPEC bool SDLCALL SDL_WaitForGPUFences( + SDL_GPUDevice *device, + bool wait_all, + SDL_GPUFence *const *fences, + Uint32 num_fences); + +/** + * Checks the status of a fence. + * + * \param device a GPU context. + * \param fence a fence. + * \returns true if the fence is signaled, false if it is not. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SubmitGPUCommandBufferAndAcquireFence + */ +extern SDL_DECLSPEC bool SDLCALL SDL_QueryGPUFence( + SDL_GPUDevice *device, + SDL_GPUFence *fence); + +/** + * Releases a fence obtained from SDL_SubmitGPUCommandBufferAndAcquireFence. + * + * You must not reference the fence after calling this function. + * + * \param device a GPU context. + * \param fence a fence. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SubmitGPUCommandBufferAndAcquireFence + */ +extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUFence( + SDL_GPUDevice *device, + SDL_GPUFence *fence); + +/* Format Info */ + +/** + * Obtains the texel block size for a texture format. + * + * \param format the texture format you want to know the texel size of. + * \returns the texel block size of the texture format. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_UploadToGPUTexture + */ +extern SDL_DECLSPEC Uint32 SDLCALL SDL_GPUTextureFormatTexelBlockSize( + SDL_GPUTextureFormat format); + +/** + * Determines whether a texture format is supported for a given type and + * usage. + * + * \param device a GPU context. + * \param format the texture format to check. + * \param type the type of texture (2D, 3D, Cube). + * \param usage a bitmask of all usage scenarios to check. + * \returns whether the texture format is supported for this type and usage. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GPUTextureSupportsFormat( + SDL_GPUDevice *device, + SDL_GPUTextureFormat format, + SDL_GPUTextureType type, + SDL_GPUTextureUsageFlags usage); + +/** + * Determines if a sample count for a texture format is supported. + * + * \param device a GPU context. + * \param format the texture format to check. + * \param sample_count the sample count to check. + * \returns whether the sample count is supported for this texture format. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GPUTextureSupportsSampleCount( + SDL_GPUDevice *device, + SDL_GPUTextureFormat format, + SDL_GPUSampleCount sample_count); + +/** + * Calculate the size in bytes of a texture format with dimensions. + * + * \param format a texture format. + * \param width width in pixels. + * \param height height in pixels. + * \param depth_or_layer_count depth for 3D textures or layer count otherwise. + * \returns the size of a texture with this format and dimensions. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC Uint32 SDLCALL SDL_CalculateGPUTextureFormatSize( + SDL_GPUTextureFormat format, + Uint32 width, + Uint32 height, + Uint32 depth_or_layer_count); + +/** + * Get the SDL pixel format corresponding to a GPU texture format. + * + * \param format a texture format. + * \returns the corresponding pixel format, or SDL_PIXELFORMAT_UNKNOWN if + * there is no corresponding pixel format. + * + * \since This function is available since SDL 3.4.0. + */ +extern SDL_DECLSPEC SDL_PixelFormat SDLCALL SDL_GetPixelFormatFromGPUTextureFormat(SDL_GPUTextureFormat format); + +/** + * Get the GPU texture format corresponding to an SDL pixel format. + * + * \param format a pixel format. + * \returns the corresponding GPU texture format, or + * SDL_GPU_TEXTUREFORMAT_INVALID if there is no corresponding GPU + * texture format. + * + * \since This function is available since SDL 3.4.0. + */ +extern SDL_DECLSPEC SDL_GPUTextureFormat SDLCALL SDL_GetGPUTextureFormatFromPixelFormat(SDL_PixelFormat format); + +#ifdef SDL_PLATFORM_GDK + +/** + * Call this to suspend GPU operation on Xbox when you receive the + * SDL_EVENT_DID_ENTER_BACKGROUND event. + * + * Do NOT call any SDL_GPU functions after calling this function! This must + * also be called before calling SDL_GDKSuspendComplete. + * + * \param device a GPU context. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_AddEventWatch + */ +extern SDL_DECLSPEC void SDLCALL SDL_GDKSuspendGPU(SDL_GPUDevice *device); + +/** + * Call this to resume GPU operation on Xbox when you receive the + * SDL_EVENT_WILL_ENTER_FOREGROUND event. + * + * When resuming, this function MUST be called before calling any other + * SDL_GPU functions. + * + * \param device a GPU context. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_AddEventWatch + */ +extern SDL_DECLSPEC void SDLCALL SDL_GDKResumeGPU(SDL_GPUDevice *device); + +#endif /* SDL_PLATFORM_GDK */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#include + +#endif /* SDL_gpu_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_guid.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_guid.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,106 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* WIKI CATEGORY: GUID */ + +/** + * # CategoryGUID + * + * A GUID is a 128-bit value that represents something that is uniquely + * identifiable by this value: "globally unique." + * + * SDL provides functions to convert a GUID to/from a string. + */ + +#ifndef SDL_guid_h_ +#define SDL_guid_h_ + +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * An SDL_GUID is a 128-bit identifier for an input device that identifies + * that device across runs of SDL programs on the same platform. + * + * If the device is detached and then re-attached to a different port, or if + * the base system is rebooted, the device should still report the same GUID. + * + * GUIDs are as precise as possible but are not guaranteed to distinguish + * physically distinct but equivalent devices. For example, two game + * controllers from the same vendor with the same product ID and revision may + * have the same GUID. + * + * GUIDs may be platform-dependent (i.e., the same device may report different + * GUIDs on different operating systems). + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_GUID { + Uint8 data[16]; +} SDL_GUID; + +/* Function prototypes */ + +/** + * Get an ASCII string representation for a given SDL_GUID. + * + * \param guid the SDL_GUID you wish to convert to string. + * \param pszGUID buffer in which to write the ASCII string. + * \param cbGUID the size of pszGUID, should be at least 33 bytes. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_StringToGUID + */ +extern SDL_DECLSPEC void SDLCALL SDL_GUIDToString(SDL_GUID guid, char *pszGUID, int cbGUID); + +/** + * Convert a GUID string into a SDL_GUID structure. + * + * Performs no error checking. If this function is given a string containing + * an invalid GUID, the function will silently succeed, but the GUID generated + * will not be useful. + * + * \param pchGUID string containing an ASCII representation of a GUID. + * \returns a SDL_GUID structure. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GUIDToString + */ +extern SDL_DECLSPEC SDL_GUID SDLCALL SDL_StringToGUID(const char *pchGUID); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_guid_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_haptic.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_haptic.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,1461 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * # CategoryHaptic + * + * The SDL haptic subsystem manages haptic (force feedback) devices. + * + * The basic usage is as follows: + * + * - Initialize the subsystem (SDL_INIT_HAPTIC). + * - Open a haptic device. + * - SDL_OpenHaptic() to open from index. + * - SDL_OpenHapticFromJoystick() to open from an existing joystick. + * - Create an effect (SDL_HapticEffect). + * - Upload the effect with SDL_CreateHapticEffect(). + * - Run the effect with SDL_RunHapticEffect(). + * - (optional) Free the effect with SDL_DestroyHapticEffect(). + * - Close the haptic device with SDL_CloseHaptic(). + * + * Simple rumble example: + * + * ```c + * SDL_Haptic *haptic = NULL; + * + * // Open the device + * SDL_HapticID *haptics = SDL_GetHaptics(NULL); + * if (haptics) { + * haptic = SDL_OpenHaptic(haptics[0]); + * SDL_free(haptics); + * } + * if (haptic == NULL) + * return; + * + * // Initialize simple rumble + * if (!SDL_InitHapticRumble(haptic)) + * return; + * + * // Play effect at 50% strength for 2 seconds + * if (!SDL_PlayHapticRumble(haptic, 0.5, 2000)) + * return; + * SDL_Delay(2000); + * + * // Clean up + * SDL_CloseHaptic(haptic); + * ``` + * + * Complete example: + * + * ```c + * bool test_haptic(SDL_Joystick *joystick) + * { + * SDL_Haptic *haptic; + * SDL_HapticEffect effect; + * SDL_HapticEffectID effect_id; + * + * // Open the device + * haptic = SDL_OpenHapticFromJoystick(joystick); + * if (haptic == NULL) return false; // Most likely joystick isn't haptic + * + * // See if it can do sine waves + * if ((SDL_GetHapticFeatures(haptic) & SDL_HAPTIC_SINE)==0) { + * SDL_CloseHaptic(haptic); // No sine effect + * return false; + * } + * + * // Create the effect + * SDL_memset(&effect, 0, sizeof(SDL_HapticEffect)); // 0 is safe default + * effect.type = SDL_HAPTIC_SINE; + * effect.periodic.direction.type = SDL_HAPTIC_POLAR; // Polar coordinates + * effect.periodic.direction.dir[0] = 18000; // Force comes from south + * effect.periodic.period = 1000; // 1000 ms + * effect.periodic.magnitude = 20000; // 20000/32767 strength + * effect.periodic.length = 5000; // 5 seconds long + * effect.periodic.attack_length = 1000; // Takes 1 second to get max strength + * effect.periodic.fade_length = 1000; // Takes 1 second to fade away + * + * // Upload the effect + * effect_id = SDL_CreateHapticEffect(haptic, &effect); + * + * // Test the effect + * SDL_RunHapticEffect(haptic, effect_id, 1); + * SDL_Delay(5000); // Wait for the effect to finish + * + * // We destroy the effect, although closing the device also does this + * SDL_DestroyHapticEffect(haptic, effect_id); + * + * // Close the device + * SDL_CloseHaptic(haptic); + * + * return true; // Success + * } + * ``` + * + * Note that the SDL haptic subsystem is not thread-safe. + */ + + +#ifndef SDL_haptic_h_ +#define SDL_haptic_h_ + +#include +#include +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* FIXME: + * + * At the moment the magnitude variables are mixed between signed/unsigned, and + * it is also not made clear that ALL of those variables expect a max of 0x7FFF. + * + * Some platforms may have higher precision than that (Linux FF, Windows XInput) + * so we should fix the inconsistency in favor of higher possible precision, + * adjusting for platforms that use different scales. + * -flibit + */ + +/** + * The haptic structure used to identify an SDL haptic. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_OpenHaptic + * \sa SDL_OpenHapticFromJoystick + * \sa SDL_CloseHaptic + */ +typedef struct SDL_Haptic SDL_Haptic; + +/* + * Misc defines. + */ + +/** + * Used to play a device an infinite number of times. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_RunHapticEffect + */ +#define SDL_HAPTIC_INFINITY 4294967295U + + +/** + * \name Haptic features + * + * Different haptic features a device can have. + */ +/* @{ */ + +/** + * \name Haptic effects + */ +/* @{ */ + +/** + * Type of haptic effect. + */ +typedef Uint16 SDL_HapticEffectType; + +/** + * Constant effect supported. + * + * Constant haptic effect. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_HapticCondition + */ +#define SDL_HAPTIC_CONSTANT (1u<<0) + +/** + * Sine wave effect supported. + * + * Periodic haptic effect that simulates sine waves. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_HapticPeriodic + */ +#define SDL_HAPTIC_SINE (1u<<1) + +/** + * Square wave effect supported. + * + * Periodic haptic effect that simulates square waves. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_HapticPeriodic + */ +#define SDL_HAPTIC_SQUARE (1u<<2) + +/** + * Triangle wave effect supported. + * + * Periodic haptic effect that simulates triangular waves. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_HapticPeriodic + */ +#define SDL_HAPTIC_TRIANGLE (1u<<3) + +/** + * Sawtoothup wave effect supported. + * + * Periodic haptic effect that simulates saw tooth up waves. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_HapticPeriodic + */ +#define SDL_HAPTIC_SAWTOOTHUP (1u<<4) + +/** + * Sawtoothdown wave effect supported. + * + * Periodic haptic effect that simulates saw tooth down waves. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_HapticPeriodic + */ +#define SDL_HAPTIC_SAWTOOTHDOWN (1u<<5) + +/** + * Ramp effect supported. + * + * Ramp haptic effect. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_HapticRamp + */ +#define SDL_HAPTIC_RAMP (1u<<6) + +/** + * Spring effect supported - uses axes position. + * + * Condition haptic effect that simulates a spring. Effect is based on the + * axes position. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_HapticCondition + */ +#define SDL_HAPTIC_SPRING (1u<<7) + +/** + * Damper effect supported - uses axes velocity. + * + * Condition haptic effect that simulates dampening. Effect is based on the + * axes velocity. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_HapticCondition + */ +#define SDL_HAPTIC_DAMPER (1u<<8) + +/** + * Inertia effect supported - uses axes acceleration. + * + * Condition haptic effect that simulates inertia. Effect is based on the axes + * acceleration. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_HapticCondition + */ +#define SDL_HAPTIC_INERTIA (1u<<9) + +/** + * Friction effect supported - uses axes movement. + * + * Condition haptic effect that simulates friction. Effect is based on the + * axes movement. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_HapticCondition + */ +#define SDL_HAPTIC_FRICTION (1u<<10) + +/** + * Left/Right effect supported. + * + * Haptic effect for direct control over high/low frequency motors. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_HapticLeftRight + */ +#define SDL_HAPTIC_LEFTRIGHT (1u<<11) + +/** + * Reserved for future use. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_HAPTIC_RESERVED1 (1u<<12) + +/** + * Reserved for future use. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_HAPTIC_RESERVED2 (1u<<13) + +/** + * Reserved for future use. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_HAPTIC_RESERVED3 (1u<<14) + +/** + * Custom effect is supported. + * + * User defined custom haptic effect. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_HAPTIC_CUSTOM (1u<<15) + +/* @} *//* Haptic effects */ + +/* These last few are features the device has, not effects */ + +/** + * Device can set global gain. + * + * Device supports setting the global gain. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_SetHapticGain + */ +#define SDL_HAPTIC_GAIN (1u<<16) + +/** + * Device can set autocenter. + * + * Device supports setting autocenter. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_SetHapticAutocenter + */ +#define SDL_HAPTIC_AUTOCENTER (1u<<17) + +/** + * Device can be queried for effect status. + * + * Device supports querying effect status. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_GetHapticEffectStatus + */ +#define SDL_HAPTIC_STATUS (1u<<18) + +/** + * Device can be paused. + * + * Devices supports being paused. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_PauseHaptic + * \sa SDL_ResumeHaptic + */ +#define SDL_HAPTIC_PAUSE (1u<<19) + + +/** + * \name Direction encodings + */ +/* @{ */ + +/** + * Type of coordinates used for haptic direction. + */ +typedef Uint8 SDL_HapticDirectionType; + +/** + * Uses polar coordinates for the direction. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_HapticDirection + */ +#define SDL_HAPTIC_POLAR 0 + +/** + * Uses cartesian coordinates for the direction. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_HapticDirection + */ +#define SDL_HAPTIC_CARTESIAN 1 + +/** + * Uses spherical coordinates for the direction. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_HapticDirection + */ +#define SDL_HAPTIC_SPHERICAL 2 + +/** + * Use this value to play an effect on the steering wheel axis. + * + * This provides better compatibility across platforms and devices as SDL will + * guess the correct axis. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_HapticDirection + */ +#define SDL_HAPTIC_STEERING_AXIS 3 + +/* @} *//* Direction encodings */ + +/* @} *//* Haptic features */ + + +/** + * ID for haptic effects. + * + * This is -1 if the ID is invalid. + * + * \sa SDL_CreateHapticEffect + */ +typedef int SDL_HapticEffectID; + + +/** + * Structure that represents a haptic direction. + * + * This is the direction where the force comes from, instead of the direction + * in which the force is exerted. + * + * Directions can be specified by: + * + * - SDL_HAPTIC_POLAR : Specified by polar coordinates. + * - SDL_HAPTIC_CARTESIAN : Specified by cartesian coordinates. + * - SDL_HAPTIC_SPHERICAL : Specified by spherical coordinates. + * + * Cardinal directions of the haptic device are relative to the positioning of + * the device. North is considered to be away from the user. + * + * The following diagram represents the cardinal directions: + * + * ``` + * .--. + * |__| .-------. + * |=.| |.-----.| + * |--| || || + * | | |'-----'| + * |__|~')_____(' + * [ COMPUTER ] + * + * + * North (0,-1) + * ^ + * | + * | + * (-1,0) West <----[ HAPTIC ]----> East (1,0) + * | + * | + * v + * South (0,1) + * + * + * [ USER ] + * \|||/ + * (o o) + * ---ooO-(_)-Ooo--- + * ``` + * + * If type is SDL_HAPTIC_POLAR, direction is encoded by hundredths of a degree + * starting north and turning clockwise. SDL_HAPTIC_POLAR only uses the first + * `dir` parameter. The cardinal directions would be: + * + * - North: 0 (0 degrees) + * - East: 9000 (90 degrees) + * - South: 18000 (180 degrees) + * - West: 27000 (270 degrees) + * + * If type is SDL_HAPTIC_CARTESIAN, direction is encoded by three positions (X + * axis, Y axis and Z axis (with 3 axes)). SDL_HAPTIC_CARTESIAN uses the first + * three `dir` parameters. The cardinal directions would be: + * + * - North: 0,-1, 0 + * - East: 1, 0, 0 + * - South: 0, 1, 0 + * - West: -1, 0, 0 + * + * The Z axis represents the height of the effect if supported, otherwise it's + * unused. In cartesian encoding (1, 2) would be the same as (2, 4), you can + * use any multiple you want, only the direction matters. + * + * If type is SDL_HAPTIC_SPHERICAL, direction is encoded by two rotations. The + * first two `dir` parameters are used. The `dir` parameters are as follows + * (all values are in hundredths of degrees): + * + * - Degrees from (1, 0) rotated towards (0, 1). + * - Degrees towards (0, 0, 1) (device needs at least 3 axes). + * + * Example of force coming from the south with all encodings (force coming + * from the south means the user will have to pull the stick to counteract): + * + * ```c + * SDL_HapticDirection direction; + * + * // Cartesian directions + * direction.type = SDL_HAPTIC_CARTESIAN; // Using cartesian direction encoding. + * direction.dir[0] = 0; // X position + * direction.dir[1] = 1; // Y position + * // Assuming the device has 2 axes, we don't need to specify third parameter. + * + * // Polar directions + * direction.type = SDL_HAPTIC_POLAR; // We'll be using polar direction encoding. + * direction.dir[0] = 18000; // Polar only uses first parameter + * + * // Spherical coordinates + * direction.type = SDL_HAPTIC_SPHERICAL; // Spherical encoding + * direction.dir[0] = 9000; // Since we only have two axes we don't need more parameters. + * ``` + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_HAPTIC_POLAR + * \sa SDL_HAPTIC_CARTESIAN + * \sa SDL_HAPTIC_SPHERICAL + * \sa SDL_HAPTIC_STEERING_AXIS + * \sa SDL_HapticEffect + * \sa SDL_GetNumHapticAxes + */ +typedef struct SDL_HapticDirection +{ + SDL_HapticDirectionType type; /**< The type of encoding. */ + Sint32 dir[3]; /**< The encoded direction. */ +} SDL_HapticDirection; + + +/** + * A structure containing a template for a Constant effect. + * + * This struct is exclusively for the SDL_HAPTIC_CONSTANT effect. + * + * A constant effect applies a constant force in the specified direction to + * the joystick. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_HAPTIC_CONSTANT + * \sa SDL_HapticEffect + */ +typedef struct SDL_HapticConstant +{ + /* Header */ + SDL_HapticEffectType type; /**< SDL_HAPTIC_CONSTANT */ + SDL_HapticDirection direction; /**< Direction of the effect. */ + + /* Replay */ + Uint32 length; /**< Duration of the effect. */ + Uint16 delay; /**< Delay before starting the effect. */ + + /* Trigger */ + Uint16 button; /**< Button that triggers the effect. */ + Uint16 interval; /**< How soon it can be triggered again after button. */ + + /* Constant */ + Sint16 level; /**< Strength of the constant effect. */ + + /* Envelope */ + Uint16 attack_length; /**< Duration of the attack. */ + Uint16 attack_level; /**< Level at the start of the attack. */ + Uint16 fade_length; /**< Duration of the fade. */ + Uint16 fade_level; /**< Level at the end of the fade. */ +} SDL_HapticConstant; + +/** + * A structure containing a template for a Periodic effect. + * + * The struct handles the following effects: + * + * - SDL_HAPTIC_SINE + * - SDL_HAPTIC_SQUARE + * - SDL_HAPTIC_TRIANGLE + * - SDL_HAPTIC_SAWTOOTHUP + * - SDL_HAPTIC_SAWTOOTHDOWN + * + * A periodic effect consists in a wave-shaped effect that repeats itself over + * time. The type determines the shape of the wave and the parameters + * determine the dimensions of the wave. + * + * Phase is given by hundredth of a degree meaning that giving the phase a + * value of 9000 will displace it 25% of its period. Here are sample values: + * + * - 0: No phase displacement. + * - 9000: Displaced 25% of its period. + * - 18000: Displaced 50% of its period. + * - 27000: Displaced 75% of its period. + * - 36000: Displaced 100% of its period, same as 0, but 0 is preferred. + * + * Examples: + * + * ``` + * SDL_HAPTIC_SINE + * __ __ __ __ + * / \ / \ / \ / + * / \__/ \__/ \__/ + * + * SDL_HAPTIC_SQUARE + * __ __ __ __ __ + * | | | | | | | | | | + * | |__| |__| |__| |__| | + * + * SDL_HAPTIC_TRIANGLE + * /\ /\ /\ /\ /\ + * / \ / \ / \ / \ / + * / \/ \/ \/ \/ + * + * SDL_HAPTIC_SAWTOOTHUP + * /| /| /| /| /| /| /| + * / | / | / | / | / | / | / | + * / |/ |/ |/ |/ |/ |/ | + * + * SDL_HAPTIC_SAWTOOTHDOWN + * \ |\ |\ |\ |\ |\ |\ | + * \ | \ | \ | \ | \ | \ | \ | + * \| \| \| \| \| \| \| + * ``` + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_HAPTIC_SINE + * \sa SDL_HAPTIC_SQUARE + * \sa SDL_HAPTIC_TRIANGLE + * \sa SDL_HAPTIC_SAWTOOTHUP + * \sa SDL_HAPTIC_SAWTOOTHDOWN + * \sa SDL_HapticEffect + */ +typedef struct SDL_HapticPeriodic +{ + /* Header */ + SDL_HapticEffectType type; /**< SDL_HAPTIC_SINE, SDL_HAPTIC_SQUARE + SDL_HAPTIC_TRIANGLE, SDL_HAPTIC_SAWTOOTHUP or + SDL_HAPTIC_SAWTOOTHDOWN */ + SDL_HapticDirection direction; /**< Direction of the effect. */ + + /* Replay */ + Uint32 length; /**< Duration of the effect. */ + Uint16 delay; /**< Delay before starting the effect. */ + + /* Trigger */ + Uint16 button; /**< Button that triggers the effect. */ + Uint16 interval; /**< How soon it can be triggered again after button. */ + + /* Periodic */ + Uint16 period; /**< Period of the wave. */ + Sint16 magnitude; /**< Peak value; if negative, equivalent to 180 degrees extra phase shift. */ + Sint16 offset; /**< Mean value of the wave. */ + Uint16 phase; /**< Positive phase shift given by hundredth of a degree. */ + + /* Envelope */ + Uint16 attack_length; /**< Duration of the attack. */ + Uint16 attack_level; /**< Level at the start of the attack. */ + Uint16 fade_length; /**< Duration of the fade. */ + Uint16 fade_level; /**< Level at the end of the fade. */ +} SDL_HapticPeriodic; + +/** + * A structure containing a template for a Condition effect. + * + * The struct handles the following effects: + * + * - SDL_HAPTIC_SPRING: Effect based on axes position. + * - SDL_HAPTIC_DAMPER: Effect based on axes velocity. + * - SDL_HAPTIC_INERTIA: Effect based on axes acceleration. + * - SDL_HAPTIC_FRICTION: Effect based on axes movement. + * + * Direction is handled by condition internals instead of a direction member. + * The condition effect specific members have three parameters. The first + * refers to the X axis, the second refers to the Y axis and the third refers + * to the Z axis. The right terms refer to the positive side of the axis and + * the left terms refer to the negative side of the axis. Please refer to the + * SDL_HapticDirection diagram for which side is positive and which is + * negative. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_HapticDirection + * \sa SDL_HAPTIC_SPRING + * \sa SDL_HAPTIC_DAMPER + * \sa SDL_HAPTIC_INERTIA + * \sa SDL_HAPTIC_FRICTION + * \sa SDL_HapticEffect + */ +typedef struct SDL_HapticCondition +{ + /* Header */ + SDL_HapticEffectType type; /**< SDL_HAPTIC_SPRING, SDL_HAPTIC_DAMPER, + SDL_HAPTIC_INERTIA or SDL_HAPTIC_FRICTION */ + SDL_HapticDirection direction; /**< Direction of the effect. */ + + /* Replay */ + Uint32 length; /**< Duration of the effect. */ + Uint16 delay; /**< Delay before starting the effect. */ + + /* Trigger */ + Uint16 button; /**< Button that triggers the effect. */ + Uint16 interval; /**< How soon it can be triggered again after button. */ + + /* Condition */ + Uint16 right_sat[3]; /**< Level when joystick is to the positive side; max 0xFFFF. */ + Uint16 left_sat[3]; /**< Level when joystick is to the negative side; max 0xFFFF. */ + Sint16 right_coeff[3]; /**< How fast to increase the force towards the positive side. */ + Sint16 left_coeff[3]; /**< How fast to increase the force towards the negative side. */ + Uint16 deadband[3]; /**< Size of the dead zone; max 0xFFFF: whole axis-range when 0-centered. */ + Sint16 center[3]; /**< Position of the dead zone. */ +} SDL_HapticCondition; + +/** + * A structure containing a template for a Ramp effect. + * + * This struct is exclusively for the SDL_HAPTIC_RAMP effect. + * + * The ramp effect starts at start strength and ends at end strength. It + * augments in linear fashion. If you use attack and fade with a ramp the + * effects get added to the ramp effect making the effect become quadratic + * instead of linear. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_HAPTIC_RAMP + * \sa SDL_HapticEffect + */ +typedef struct SDL_HapticRamp +{ + /* Header */ + SDL_HapticEffectType type; /**< SDL_HAPTIC_RAMP */ + SDL_HapticDirection direction; /**< Direction of the effect. */ + + /* Replay */ + Uint32 length; /**< Duration of the effect. */ + Uint16 delay; /**< Delay before starting the effect. */ + + /* Trigger */ + Uint16 button; /**< Button that triggers the effect. */ + Uint16 interval; /**< How soon it can be triggered again after button. */ + + /* Ramp */ + Sint16 start; /**< Beginning strength level. */ + Sint16 end; /**< Ending strength level. */ + + /* Envelope */ + Uint16 attack_length; /**< Duration of the attack. */ + Uint16 attack_level; /**< Level at the start of the attack. */ + Uint16 fade_length; /**< Duration of the fade. */ + Uint16 fade_level; /**< Level at the end of the fade. */ +} SDL_HapticRamp; + +/** + * A structure containing a template for a Left/Right effect. + * + * This struct is exclusively for the SDL_HAPTIC_LEFTRIGHT effect. + * + * The Left/Right effect is used to explicitly control the large and small + * motors, commonly found in modern game controllers. The small (right) motor + * is high frequency, and the large (left) motor is low frequency. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_HAPTIC_LEFTRIGHT + * \sa SDL_HapticEffect + */ +typedef struct SDL_HapticLeftRight +{ + /* Header */ + SDL_HapticEffectType type; /**< SDL_HAPTIC_LEFTRIGHT */ + + /* Replay */ + Uint32 length; /**< Duration of the effect in milliseconds. */ + + /* Rumble */ + Uint16 large_magnitude; /**< Control of the large controller motor. */ + Uint16 small_magnitude; /**< Control of the small controller motor. */ +} SDL_HapticLeftRight; + +/** + * A structure containing a template for the SDL_HAPTIC_CUSTOM effect. + * + * This struct is exclusively for the SDL_HAPTIC_CUSTOM effect. + * + * A custom force feedback effect is much like a periodic effect, where the + * application can define its exact shape. You will have to allocate the data + * yourself. Data should consist of channels * samples Uint16 samples. + * + * If channels is one, the effect is rotated using the defined direction. + * Otherwise it uses the samples in data for the different axes. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_HAPTIC_CUSTOM + * \sa SDL_HapticEffect + */ +typedef struct SDL_HapticCustom +{ + /* Header */ + SDL_HapticEffectType type; /**< SDL_HAPTIC_CUSTOM */ + SDL_HapticDirection direction; /**< Direction of the effect. */ + + /* Replay */ + Uint32 length; /**< Duration of the effect. */ + Uint16 delay; /**< Delay before starting the effect. */ + + /* Trigger */ + Uint16 button; /**< Button that triggers the effect. */ + Uint16 interval; /**< How soon it can be triggered again after button. */ + + /* Custom */ + Uint8 channels; /**< Axes to use, minimum of one. */ + Uint16 period; /**< Sample periods. */ + Uint16 samples; /**< Amount of samples. */ + Uint16 *data; /**< Should contain channels*samples items. */ + + /* Envelope */ + Uint16 attack_length; /**< Duration of the attack. */ + Uint16 attack_level; /**< Level at the start of the attack. */ + Uint16 fade_length; /**< Duration of the fade. */ + Uint16 fade_level; /**< Level at the end of the fade. */ +} SDL_HapticCustom; + +/** + * The generic template for any haptic effect. + * + * All values max at 32767 (0x7FFF). Signed values also can be negative. Time + * values unless specified otherwise are in milliseconds. + * + * You can also pass SDL_HAPTIC_INFINITY to length instead of a 0-32767 value. + * Neither delay, interval, attack_length nor fade_length support + * SDL_HAPTIC_INFINITY. Fade will also not be used since effect never ends. + * + * Additionally, the SDL_HAPTIC_RAMP effect does not support a duration of + * SDL_HAPTIC_INFINITY. + * + * Button triggers may not be supported on all devices, it is advised to not + * use them if possible. Buttons start at index 1 instead of index 0 like the + * joystick. + * + * If both attack_length and fade_level are 0, the envelope is not used, + * otherwise both values are used. + * + * Common parts: + * + * ```c + * // Replay - All effects have this + * Uint32 length; // Duration of effect (ms). + * Uint16 delay; // Delay before starting effect. + * + * // Trigger - All effects have this + * Uint16 button; // Button that triggers effect. + * Uint16 interval; // How soon before effect can be triggered again. + * + * // Envelope - All effects except condition effects have this + * Uint16 attack_length; // Duration of the attack (ms). + * Uint16 attack_level; // Level at the start of the attack. + * Uint16 fade_length; // Duration of the fade out (ms). + * Uint16 fade_level; // Level at the end of the fade. + * ``` + * + * Here we have an example of a constant effect evolution in time: + * + * ``` + * Strength + * ^ + * | + * | effect level --> _________________ + * | / \ + * | / \ + * | / \ + * | / \ + * | attack_level --> | \ + * | | | <--- fade_level + * | + * +--------------------------------------------------> Time + * [--] [---] + * attack_length fade_length + * + * [------------------][-----------------------] + * delay length + * ``` + * + * Note either the attack_level or the fade_level may be above the actual + * effect level. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_HapticConstant + * \sa SDL_HapticPeriodic + * \sa SDL_HapticCondition + * \sa SDL_HapticRamp + * \sa SDL_HapticLeftRight + * \sa SDL_HapticCustom + */ +typedef union SDL_HapticEffect +{ + /* Common for all force feedback effects */ + SDL_HapticEffectType type; /**< Effect type. */ + SDL_HapticConstant constant; /**< Constant effect. */ + SDL_HapticPeriodic periodic; /**< Periodic effect. */ + SDL_HapticCondition condition; /**< Condition effect. */ + SDL_HapticRamp ramp; /**< Ramp effect. */ + SDL_HapticLeftRight leftright; /**< Left/Right effect. */ + SDL_HapticCustom custom; /**< Custom effect. */ +} SDL_HapticEffect; + +/** + * This is a unique ID for a haptic device for the time it is connected to the + * system, and is never reused for the lifetime of the application. + * + * If the haptic device is disconnected and reconnected, it will get a new ID. + * + * The value 0 is an invalid ID. + * + * \since This datatype is available since SDL 3.2.0. + */ +typedef Uint32 SDL_HapticID; + + +/* Function prototypes */ + +/** + * Get a list of currently connected haptic devices. + * + * \param count a pointer filled in with the number of haptic devices + * returned, may be NULL. + * \returns a 0 terminated array of haptic device instance IDs or NULL on + * failure; call SDL_GetError() for more information. This should be + * freed with SDL_free() when it is no longer needed. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_OpenHaptic + */ +extern SDL_DECLSPEC SDL_HapticID * SDLCALL SDL_GetHaptics(int *count); + +/** + * Get the implementation dependent name of a haptic device. + * + * This can be called before any haptic devices are opened. + * + * \param instance_id the haptic device instance ID. + * \returns the name of the selected haptic device. If no name can be found, + * this function returns NULL; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetHapticName + * \sa SDL_OpenHaptic + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetHapticNameForID(SDL_HapticID instance_id); + +/** + * Open a haptic device for use. + * + * The index passed as an argument refers to the N'th haptic device on this + * system. + * + * When opening a haptic device, its gain will be set to maximum and + * autocenter will be disabled. To modify these values use SDL_SetHapticGain() + * and SDL_SetHapticAutocenter(). + * + * \param instance_id the haptic device instance ID. + * \returns the device identifier or NULL on failure; call SDL_GetError() for + * more information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CloseHaptic + * \sa SDL_GetHaptics + * \sa SDL_OpenHapticFromJoystick + * \sa SDL_OpenHapticFromMouse + * \sa SDL_SetHapticAutocenter + * \sa SDL_SetHapticGain + */ +extern SDL_DECLSPEC SDL_Haptic * SDLCALL SDL_OpenHaptic(SDL_HapticID instance_id); + + +/** + * Get the SDL_Haptic associated with an instance ID, if it has been opened. + * + * \param instance_id the instance ID to get the SDL_Haptic for. + * \returns an SDL_Haptic on success or NULL on failure or if it hasn't been + * opened yet; call SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_Haptic * SDLCALL SDL_GetHapticFromID(SDL_HapticID instance_id); + +/** + * Get the instance ID of an opened haptic device. + * + * \param haptic the SDL_Haptic device to query. + * \returns the instance ID of the specified haptic device on success or 0 on + * failure; call SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_HapticID SDLCALL SDL_GetHapticID(SDL_Haptic *haptic); + +/** + * Get the implementation dependent name of a haptic device. + * + * \param haptic the SDL_Haptic obtained from SDL_OpenJoystick(). + * \returns the name of the selected haptic device. If no name can be found, + * this function returns NULL; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetHapticNameForID + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetHapticName(SDL_Haptic *haptic); + +/** + * Query whether or not the current mouse has haptic capabilities. + * + * \returns true if the mouse is haptic or false if it isn't. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_OpenHapticFromMouse + */ +extern SDL_DECLSPEC bool SDLCALL SDL_IsMouseHaptic(void); + +/** + * Try to open a haptic device from the current mouse. + * + * \returns the haptic device identifier or NULL on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CloseHaptic + * \sa SDL_IsMouseHaptic + */ +extern SDL_DECLSPEC SDL_Haptic * SDLCALL SDL_OpenHapticFromMouse(void); + +/** + * Query if a joystick has haptic features. + * + * \param joystick the SDL_Joystick to test for haptic capabilities. + * \returns true if the joystick is haptic or false if it isn't. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_OpenHapticFromJoystick + */ +extern SDL_DECLSPEC bool SDLCALL SDL_IsJoystickHaptic(SDL_Joystick *joystick); + +/** + * Open a haptic device for use from a joystick device. + * + * You must still close the haptic device separately. It will not be closed + * with the joystick. + * + * When opened from a joystick you should first close the haptic device before + * closing the joystick device. If not, on some implementations the haptic + * device will also get unallocated and you'll be unable to use force feedback + * on that device. + * + * \param joystick the SDL_Joystick to create a haptic device from. + * \returns a valid haptic device identifier on success or NULL on failure; + * call SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CloseHaptic + * \sa SDL_IsJoystickHaptic + */ +extern SDL_DECLSPEC SDL_Haptic * SDLCALL SDL_OpenHapticFromJoystick(SDL_Joystick *joystick); + +/** + * Close a haptic device previously opened with SDL_OpenHaptic(). + * + * \param haptic the SDL_Haptic device to close. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_OpenHaptic + */ +extern SDL_DECLSPEC void SDLCALL SDL_CloseHaptic(SDL_Haptic *haptic); + +/** + * Get the number of effects a haptic device can store. + * + * On some platforms this isn't fully supported, and therefore is an + * approximation. Always check to see if your created effect was actually + * created and do not rely solely on SDL_GetMaxHapticEffects(). + * + * \param haptic the SDL_Haptic device to query. + * \returns the number of effects the haptic device can store or a negative + * error code on failure; call SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetMaxHapticEffectsPlaying + * \sa SDL_GetHapticFeatures + */ +extern SDL_DECLSPEC int SDLCALL SDL_GetMaxHapticEffects(SDL_Haptic *haptic); + +/** + * Get the number of effects a haptic device can play at the same time. + * + * This is not supported on all platforms, but will always return a value. + * + * \param haptic the SDL_Haptic device to query maximum playing effects. + * \returns the number of effects the haptic device can play at the same time + * or -1 on failure; call SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetMaxHapticEffects + * \sa SDL_GetHapticFeatures + */ +extern SDL_DECLSPEC int SDLCALL SDL_GetMaxHapticEffectsPlaying(SDL_Haptic *haptic); + +/** + * Get the haptic device's supported features in bitwise manner. + * + * \param haptic the SDL_Haptic device to query. + * \returns a list of supported haptic features in bitwise manner (OR'd), or 0 + * on failure; call SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_HapticEffectSupported + * \sa SDL_GetMaxHapticEffects + */ +extern SDL_DECLSPEC Uint32 SDLCALL SDL_GetHapticFeatures(SDL_Haptic *haptic); + +/** + * Get the number of haptic axes the device has. + * + * The number of haptic axes might be useful if working with the + * SDL_HapticDirection effect. + * + * \param haptic the SDL_Haptic device to query. + * \returns the number of axes on success or -1 on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_GetNumHapticAxes(SDL_Haptic *haptic); + +/** + * Check to see if an effect is supported by a haptic device. + * + * \param haptic the SDL_Haptic device to query. + * \param effect the desired effect to query. + * \returns true if the effect is supported or false if it isn't. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateHapticEffect + * \sa SDL_GetHapticFeatures + */ +extern SDL_DECLSPEC bool SDLCALL SDL_HapticEffectSupported(SDL_Haptic *haptic, const SDL_HapticEffect *effect); + +/** + * Create a new haptic effect on a specified device. + * + * \param haptic an SDL_Haptic device to create the effect on. + * \param effect an SDL_HapticEffect structure containing the properties of + * the effect to create. + * \returns the ID of the effect on success or -1 on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_DestroyHapticEffect + * \sa SDL_RunHapticEffect + * \sa SDL_UpdateHapticEffect + */ +extern SDL_DECLSPEC SDL_HapticEffectID SDLCALL SDL_CreateHapticEffect(SDL_Haptic *haptic, const SDL_HapticEffect *effect); + +/** + * Update the properties of an effect. + * + * Can be used dynamically, although behavior when dynamically changing + * direction may be strange. Specifically the effect may re-upload itself and + * start playing from the start. You also cannot change the type either when + * running SDL_UpdateHapticEffect(). + * + * \param haptic the SDL_Haptic device that has the effect. + * \param effect the identifier of the effect to update. + * \param data an SDL_HapticEffect structure containing the new effect + * properties to use. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateHapticEffect + * \sa SDL_RunHapticEffect + */ +extern SDL_DECLSPEC bool SDLCALL SDL_UpdateHapticEffect(SDL_Haptic *haptic, SDL_HapticEffectID effect, const SDL_HapticEffect *data); + +/** + * Run the haptic effect on its associated haptic device. + * + * To repeat the effect over and over indefinitely, set `iterations` to + * `SDL_HAPTIC_INFINITY`. (Repeats the envelope - attack and fade.) To make + * one instance of the effect last indefinitely (so the effect does not fade), + * set the effect's `length` in its structure/union to `SDL_HAPTIC_INFINITY` + * instead. + * + * \param haptic the SDL_Haptic device to run the effect on. + * \param effect the ID of the haptic effect to run. + * \param iterations the number of iterations to run the effect; use + * `SDL_HAPTIC_INFINITY` to repeat forever. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetHapticEffectStatus + * \sa SDL_StopHapticEffect + * \sa SDL_StopHapticEffects + */ +extern SDL_DECLSPEC bool SDLCALL SDL_RunHapticEffect(SDL_Haptic *haptic, SDL_HapticEffectID effect, Uint32 iterations); + +/** + * Stop the haptic effect on its associated haptic device. + * + * \param haptic the SDL_Haptic device to stop the effect on. + * \param effect the ID of the haptic effect to stop. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_RunHapticEffect + * \sa SDL_StopHapticEffects + */ +extern SDL_DECLSPEC bool SDLCALL SDL_StopHapticEffect(SDL_Haptic *haptic, SDL_HapticEffectID effect); + +/** + * Destroy a haptic effect on the device. + * + * This will stop the effect if it's running. Effects are automatically + * destroyed when the device is closed. + * + * \param haptic the SDL_Haptic device to destroy the effect on. + * \param effect the ID of the haptic effect to destroy. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateHapticEffect + */ +extern SDL_DECLSPEC void SDLCALL SDL_DestroyHapticEffect(SDL_Haptic *haptic, SDL_HapticEffectID effect); + +/** + * Get the status of the current effect on the specified haptic device. + * + * Device must support the SDL_HAPTIC_STATUS feature. + * + * \param haptic the SDL_Haptic device to query for the effect status on. + * \param effect the ID of the haptic effect to query its status. + * \returns true if it is playing, false if it isn't playing or haptic status + * isn't supported. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetHapticFeatures + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetHapticEffectStatus(SDL_Haptic *haptic, SDL_HapticEffectID effect); + +/** + * Set the global gain of the specified haptic device. + * + * Device must support the SDL_HAPTIC_GAIN feature. + * + * The user may specify the maximum gain by setting the environment variable + * `SDL_HAPTIC_GAIN_MAX` which should be between 0 and 100. All calls to + * SDL_SetHapticGain() will scale linearly using `SDL_HAPTIC_GAIN_MAX` as the + * maximum. + * + * \param haptic the SDL_Haptic device to set the gain on. + * \param gain value to set the gain to, should be between 0 and 100 (0 - + * 100). + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetHapticFeatures + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetHapticGain(SDL_Haptic *haptic, int gain); + +/** + * Set the global autocenter of the device. + * + * Autocenter should be between 0 and 100. Setting it to 0 will disable + * autocentering. + * + * Device must support the SDL_HAPTIC_AUTOCENTER feature. + * + * \param haptic the SDL_Haptic device to set autocentering on. + * \param autocenter value to set autocenter to (0-100). + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetHapticFeatures + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetHapticAutocenter(SDL_Haptic *haptic, int autocenter); + +/** + * Pause a haptic device. + * + * Device must support the `SDL_HAPTIC_PAUSE` feature. Call SDL_ResumeHaptic() + * to resume playback. + * + * Do not modify the effects nor add new ones while the device is paused. That + * can cause all sorts of weird errors. + * + * \param haptic the SDL_Haptic device to pause. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_ResumeHaptic + */ +extern SDL_DECLSPEC bool SDLCALL SDL_PauseHaptic(SDL_Haptic *haptic); + +/** + * Resume a haptic device. + * + * Call to unpause after SDL_PauseHaptic(). + * + * \param haptic the SDL_Haptic device to unpause. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_PauseHaptic + */ +extern SDL_DECLSPEC bool SDLCALL SDL_ResumeHaptic(SDL_Haptic *haptic); + +/** + * Stop all the currently playing effects on a haptic device. + * + * \param haptic the SDL_Haptic device to stop. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_RunHapticEffect + * \sa SDL_StopHapticEffects + */ +extern SDL_DECLSPEC bool SDLCALL SDL_StopHapticEffects(SDL_Haptic *haptic); + +/** + * Check whether rumble is supported on a haptic device. + * + * \param haptic haptic device to check for rumble support. + * \returns true if the effect is supported or false if it isn't. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_InitHapticRumble + */ +extern SDL_DECLSPEC bool SDLCALL SDL_HapticRumbleSupported(SDL_Haptic *haptic); + +/** + * Initialize a haptic device for simple rumble playback. + * + * \param haptic the haptic device to initialize for simple rumble playback. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_PlayHapticRumble + * \sa SDL_StopHapticRumble + * \sa SDL_HapticRumbleSupported + */ +extern SDL_DECLSPEC bool SDLCALL SDL_InitHapticRumble(SDL_Haptic *haptic); + +/** + * Run a simple rumble effect on a haptic device. + * + * \param haptic the haptic device to play the rumble effect on. + * \param strength strength of the rumble to play as a 0-1 float value. + * \param length length of the rumble to play in milliseconds. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_InitHapticRumble + * \sa SDL_StopHapticRumble + */ +extern SDL_DECLSPEC bool SDLCALL SDL_PlayHapticRumble(SDL_Haptic *haptic, float strength, Uint32 length); + +/** + * Stop the simple rumble on a haptic device. + * + * \param haptic the haptic device to stop the rumble effect on. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_PlayHapticRumble + */ +extern SDL_DECLSPEC bool SDLCALL SDL_StopHapticRumble(SDL_Haptic *haptic); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_haptic_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_hidapi.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_hidapi.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,571 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* WIKI CATEGORY: HIDAPI */ + +/** + * # CategoryHIDAPI + * + * Header file for SDL HIDAPI functions. + * + * This is an adaptation of the original HIDAPI interface by Alan Ott, and + * includes source code licensed under the following license: + * + * ``` + * HIDAPI - Multi-Platform library for + * communication with HID devices. + * + * Copyright 2009, Alan Ott, Signal 11 Software. + * All Rights Reserved. + * + * This software may be used by anyone for any reason so + * long as the copyright notice in the source files + * remains intact. + * ``` + * + * (Note that this license is the same as item three of SDL's zlib license, so + * it adds no new requirements on the user.) + * + * If you would like a version of SDL without this code, you can build SDL + * with SDL_HIDAPI_DISABLED defined to 1. You might want to do this for + * example on iOS or tvOS to avoid a dependency on the CoreBluetooth + * framework. + */ + +#ifndef SDL_hidapi_h_ +#define SDL_hidapi_h_ + +#include +#include +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * An opaque handle representing an open HID device. + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_hid_device SDL_hid_device; + +/** + * HID underlying bus types. + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_hid_bus_type { + /** Unknown bus type */ + SDL_HID_API_BUS_UNKNOWN = 0x00, + + /** USB bus + Specifications: + https://usb.org/hid */ + SDL_HID_API_BUS_USB = 0x01, + + /** Bluetooth or Bluetooth LE bus + Specifications: + https://www.bluetooth.com/specifications/specs/human-interface-device-profile-1-1-1/ + https://www.bluetooth.com/specifications/specs/hid-service-1-0/ + https://www.bluetooth.com/specifications/specs/hid-over-gatt-profile-1-0/ */ + SDL_HID_API_BUS_BLUETOOTH = 0x02, + + /** I2C bus + Specifications: + https://docs.microsoft.com/previous-versions/windows/hardware/design/dn642101(v=vs.85) */ + SDL_HID_API_BUS_I2C = 0x03, + + /** SPI bus + Specifications: + https://www.microsoft.com/download/details.aspx?id=103325 */ + SDL_HID_API_BUS_SPI = 0x04 + +} SDL_hid_bus_type; + +/** hidapi info structure */ + +/** + * Information about a connected HID device + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_hid_device_info +{ + /** Platform-specific device path */ + char *path; + /** Device Vendor ID */ + unsigned short vendor_id; + /** Device Product ID */ + unsigned short product_id; + /** Serial Number */ + wchar_t *serial_number; + /** Device Release Number in binary-coded decimal, + also known as Device Version Number */ + unsigned short release_number; + /** Manufacturer String */ + wchar_t *manufacturer_string; + /** Product string */ + wchar_t *product_string; + /** Usage Page for this Device/Interface + (Windows/Mac/hidraw only) */ + unsigned short usage_page; + /** Usage for this Device/Interface + (Windows/Mac/hidraw only) */ + unsigned short usage; + /** The USB interface which this logical device + represents. + + Valid only if the device is a USB HID device. + Set to -1 in all other cases. + */ + int interface_number; + + /** Additional information about the USB interface. + Valid on libusb and Android implementations. */ + int interface_class; + int interface_subclass; + int interface_protocol; + + /** Underlying bus type */ + SDL_hid_bus_type bus_type; + + /** Pointer to the next device */ + struct SDL_hid_device_info *next; + +} SDL_hid_device_info; + + +/** + * Initialize the HIDAPI library. + * + * This function initializes the HIDAPI library. Calling it is not strictly + * necessary, as it will be called automatically by SDL_hid_enumerate() and + * any of the SDL_hid_open_*() functions if it is needed. This function should + * be called at the beginning of execution however, if there is a chance of + * HIDAPI handles being opened by different threads simultaneously. + * + * Each call to this function should have a matching call to SDL_hid_exit() + * + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_hid_exit + */ +extern SDL_DECLSPEC int SDLCALL SDL_hid_init(void); + +/** + * Finalize the HIDAPI library. + * + * This function frees all of the static data associated with HIDAPI. It + * should be called at the end of execution to avoid memory leaks. + * + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_hid_init + */ +extern SDL_DECLSPEC int SDLCALL SDL_hid_exit(void); + +/** + * Check to see if devices may have been added or removed. + * + * Enumerating the HID devices is an expensive operation, so you can call this + * to see if there have been any system device changes since the last call to + * this function. A change in the counter returned doesn't necessarily mean + * that anything has changed, but you can call SDL_hid_enumerate() to get an + * updated device list. + * + * Calling this function for the first time may cause a thread or other system + * resource to be allocated to track device change notifications. + * + * \returns a change counter that is incremented with each potential device + * change, or 0 if device change detection isn't available. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_hid_enumerate + */ +extern SDL_DECLSPEC Uint32 SDLCALL SDL_hid_device_change_count(void); + +/** + * Enumerate the HID Devices. + * + * This function returns a linked list of all the HID devices attached to the + * system which match vendor_id and product_id. If `vendor_id` is set to 0 + * then any vendor matches. If `product_id` is set to 0 then any product + * matches. If `vendor_id` and `product_id` are both set to 0, then all HID + * devices will be returned. + * + * By default SDL will only enumerate controllers, to reduce risk of hanging + * or crashing on bad drivers, but SDL_HINT_HIDAPI_ENUMERATE_ONLY_CONTROLLERS + * can be set to "0" to enumerate all HID devices. + * + * \param vendor_id the Vendor ID (VID) of the types of device to open, or 0 + * to match any vendor. + * \param product_id the Product ID (PID) of the types of device to open, or 0 + * to match any product. + * \returns a pointer to a linked list of type SDL_hid_device_info, containing + * information about the HID devices attached to the system, or NULL + * in the case of failure. Free this linked list by calling + * SDL_hid_free_enumeration(). + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_hid_device_change_count + */ +extern SDL_DECLSPEC SDL_hid_device_info * SDLCALL SDL_hid_enumerate(unsigned short vendor_id, unsigned short product_id); + +/** + * Free an enumeration linked list. + * + * This function frees a linked list created by SDL_hid_enumerate(). + * + * \param devs pointer to a list of struct_device returned from + * SDL_hid_enumerate(). + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_hid_free_enumeration(SDL_hid_device_info *devs); + +/** + * Open a HID device using a Vendor ID (VID), Product ID (PID) and optionally + * a serial number. + * + * If `serial_number` is NULL, the first device with the specified VID and PID + * is opened. + * + * \param vendor_id the Vendor ID (VID) of the device to open. + * \param product_id the Product ID (PID) of the device to open. + * \param serial_number the Serial Number of the device to open (Optionally + * NULL). + * \returns a pointer to a SDL_hid_device object on success or NULL on + * failure; call SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_hid_device * SDLCALL SDL_hid_open(unsigned short vendor_id, unsigned short product_id, const wchar_t *serial_number); + +/** + * Open a HID device by its path name. + * + * The path name be determined by calling SDL_hid_enumerate(), or a + * platform-specific path name can be used (eg: /dev/hidraw0 on Linux). + * + * \param path the path name of the device to open. + * \returns a pointer to a SDL_hid_device object on success or NULL on + * failure; call SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_hid_device * SDLCALL SDL_hid_open_path(const char *path); + +/** + * Get the properties associated with an SDL_hid_device. + * + * The following read-only properties are provided by SDL: + * + * - `SDL_PROP_HIDAPI_LIBUSB_DEVICE_HANDLE_POINTER`: the libusb_device_handle + * associated with the device, if it was opened using libusb. + * + * \param dev a device handle returned from SDL_hid_open(). + * \returns a valid property ID on success or 0 on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 3.4.0. + */ +extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_hid_get_properties(SDL_hid_device *dev); + +#define SDL_PROP_HIDAPI_LIBUSB_DEVICE_HANDLE_POINTER "SDL.hidapi.libusb.device.handle" + +/** + * Write an Output report to a HID device. + * + * The first byte of `data` must contain the Report ID. For devices which only + * support a single report, this must be set to 0x0. The remaining bytes + * contain the report data. Since the Report ID is mandatory, calls to + * SDL_hid_write() will always contain one more byte than the report contains. + * For example, if a hid report is 16 bytes long, 17 bytes must be passed to + * SDL_hid_write(), the Report ID (or 0x0, for devices with a single report), + * followed by the report data (16 bytes). In this example, the length passed + * in would be 17. + * + * SDL_hid_write() will send the data on the first OUT endpoint, if one + * exists. If it does not, it will send the data through the Control Endpoint + * (Endpoint 0). + * + * \param dev a device handle returned from SDL_hid_open(). + * \param data the data to send, including the report number as the first + * byte. + * \param length the length in bytes of the data to send. + * \returns the actual number of bytes written and -1 on on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_hid_write(SDL_hid_device *dev, const unsigned char *data, size_t length); + +/** + * Read an Input report from a HID device with timeout. + * + * Input reports are returned to the host through the INTERRUPT IN endpoint. + * The first byte will contain the Report number if the device uses numbered + * reports. + * + * \param dev a device handle returned from SDL_hid_open(). + * \param data a buffer to put the read data into. + * \param length the number of bytes to read. For devices with multiple + * reports, make sure to read an extra byte for the report + * number. + * \param milliseconds timeout in milliseconds or -1 for blocking wait. + * \returns the actual number of bytes read and -1 on on failure; call + * SDL_GetError() for more information. If no packet was available to + * be read within the timeout period, this function returns 0. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_hid_read_timeout(SDL_hid_device *dev, unsigned char *data, size_t length, int milliseconds); + +/** + * Read an Input report from a HID device. + * + * Input reports are returned to the host through the INTERRUPT IN endpoint. + * The first byte will contain the Report number if the device uses numbered + * reports. + * + * \param dev a device handle returned from SDL_hid_open(). + * \param data a buffer to put the read data into. + * \param length the number of bytes to read. For devices with multiple + * reports, make sure to read an extra byte for the report + * number. + * \returns the actual number of bytes read and -1 on failure; call + * SDL_GetError() for more information. If no packet was available to + * be read and the handle is in non-blocking mode, this function + * returns 0. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_hid_read(SDL_hid_device *dev, unsigned char *data, size_t length); + +/** + * Set the device handle to be non-blocking. + * + * In non-blocking mode calls to SDL_hid_read() will return immediately with a + * value of 0 if there is no data to be read. In blocking mode, SDL_hid_read() + * will wait (block) until there is data to read before returning. + * + * Nonblocking can be turned on and off at any time. + * + * \param dev a device handle returned from SDL_hid_open(). + * \param nonblock enable or not the nonblocking reads - 1 to enable + * nonblocking - 0 to disable nonblocking. + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_hid_set_nonblocking(SDL_hid_device *dev, int nonblock); + +/** + * Send a Feature report to the device. + * + * Feature reports are sent over the Control endpoint as a Set_Report + * transfer. The first byte of `data` must contain the Report ID. For devices + * which only support a single report, this must be set to 0x0. The remaining + * bytes contain the report data. Since the Report ID is mandatory, calls to + * SDL_hid_send_feature_report() will always contain one more byte than the + * report contains. For example, if a hid report is 16 bytes long, 17 bytes + * must be passed to SDL_hid_send_feature_report(): the Report ID (or 0x0, for + * devices which do not use numbered reports), followed by the report data (16 + * bytes). In this example, the length passed in would be 17. + * + * \param dev a device handle returned from SDL_hid_open(). + * \param data the data to send, including the report number as the first + * byte. + * \param length the length in bytes of the data to send, including the report + * number. + * \returns the actual number of bytes written and -1 on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_hid_send_feature_report(SDL_hid_device *dev, const unsigned char *data, size_t length); + +/** + * Get a feature report from a HID device. + * + * Set the first byte of `data` to the Report ID of the report to be read. + * Make sure to allow space for this extra byte in `data`. Upon return, the + * first byte will still contain the Report ID, and the report data will start + * in data[1]. + * + * \param dev a device handle returned from SDL_hid_open(). + * \param data a buffer to put the read data into, including the Report ID. + * Set the first byte of `data` to the Report ID of the report to + * be read, or set it to zero if your device does not use numbered + * reports. + * \param length the number of bytes to read, including an extra byte for the + * report ID. The buffer can be longer than the actual report. + * \returns the number of bytes read plus one for the report ID (which is + * still in the first byte), or -1 on on failure; call SDL_GetError() + * for more information. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_hid_get_feature_report(SDL_hid_device *dev, unsigned char *data, size_t length); + +/** + * Get an input report from a HID device. + * + * Set the first byte of `data` to the Report ID of the report to be read. + * Make sure to allow space for this extra byte in `data`. Upon return, the + * first byte will still contain the Report ID, and the report data will start + * in data[1]. + * + * \param dev a device handle returned from SDL_hid_open(). + * \param data a buffer to put the read data into, including the Report ID. + * Set the first byte of `data` to the Report ID of the report to + * be read, or set it to zero if your device does not use numbered + * reports. + * \param length the number of bytes to read, including an extra byte for the + * report ID. The buffer can be longer than the actual report. + * \returns the number of bytes read plus one for the report ID (which is + * still in the first byte), or -1 on on failure; call SDL_GetError() + * for more information. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_hid_get_input_report(SDL_hid_device *dev, unsigned char *data, size_t length); + +/** + * Close a HID device. + * + * \param dev a device handle returned from SDL_hid_open(). + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_hid_close(SDL_hid_device *dev); + +/** + * Get The Manufacturer String from a HID device. + * + * \param dev a device handle returned from SDL_hid_open(). + * \param string a wide string buffer to put the data into. + * \param maxlen the length of the buffer in multiples of wchar_t. + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_hid_get_manufacturer_string(SDL_hid_device *dev, wchar_t *string, size_t maxlen); + +/** + * Get The Product String from a HID device. + * + * \param dev a device handle returned from SDL_hid_open(). + * \param string a wide string buffer to put the data into. + * \param maxlen the length of the buffer in multiples of wchar_t. + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_hid_get_product_string(SDL_hid_device *dev, wchar_t *string, size_t maxlen); + +/** + * Get The Serial Number String from a HID device. + * + * \param dev a device handle returned from SDL_hid_open(). + * \param string a wide string buffer to put the data into. + * \param maxlen the length of the buffer in multiples of wchar_t. + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_hid_get_serial_number_string(SDL_hid_device *dev, wchar_t *string, size_t maxlen); + +/** + * Get a string from a HID device, based on its string index. + * + * \param dev a device handle returned from SDL_hid_open(). + * \param string_index the index of the string to get. + * \param string a wide string buffer to put the data into. + * \param maxlen the length of the buffer in multiples of wchar_t. + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_hid_get_indexed_string(SDL_hid_device *dev, int string_index, wchar_t *string, size_t maxlen); + +/** + * Get the device info from a HID device. + * + * \param dev a device handle returned from SDL_hid_open(). + * \returns a pointer to the SDL_hid_device_info for this hid_device or NULL + * on failure; call SDL_GetError() for more information. This struct + * is valid until the device is closed with SDL_hid_close(). + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_hid_device_info * SDLCALL SDL_hid_get_device_info(SDL_hid_device *dev); + +/** + * Get a report descriptor from a HID device. + * + * User has to provide a preallocated buffer where descriptor will be copied + * to. The recommended size for a preallocated buffer is 4096 bytes. + * + * \param dev a device handle returned from SDL_hid_open(). + * \param buf the buffer to copy descriptor into. + * \param buf_size the size of the buffer in bytes. + * \returns the number of bytes actually copied or -1 on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_hid_get_report_descriptor(SDL_hid_device *dev, unsigned char *buf, size_t buf_size); + +/** + * Start or stop a BLE scan on iOS and tvOS to pair Steam Controllers. + * + * \param active true to start the scan, false to stop the scan. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_hid_ble_scan(bool active); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_hidapi_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_hints.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_hints.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,4831 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * # CategoryHints + * + * This file contains functions to set and get configuration hints, as well as + * listing each of them alphabetically. + * + * The convention for naming hints is SDL_HINT_X, where "SDL_X" is the + * environment variable that can be used to override the default. + * + * In general these hints are just that - they may or may not be supported or + * applicable on any given platform, but they provide a way for an application + * or user to give the library a hint as to how they would like the library to + * work. + */ + +#ifndef SDL_hints_h_ +#define SDL_hints_h_ + +#include +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Specify the behavior of Alt+Tab while the keyboard is grabbed. + * + * By default, SDL emulates Alt+Tab functionality while the keyboard is + * grabbed and your window is full-screen. This prevents the user from getting + * stuck in your application if you've enabled keyboard grab. + * + * The variable can be set to the following values: + * + * - "0": SDL will not handle Alt+Tab. Your application is responsible for + * handling Alt+Tab while the keyboard is grabbed. + * - "1": SDL will minimize your window when Alt+Tab is pressed (default) + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_ALLOW_ALT_TAB_WHILE_GRABBED "SDL_ALLOW_ALT_TAB_WHILE_GRABBED" + +/** + * A variable to control whether the SDL activity is allowed to be re-created. + * + * If this hint is true, the activity can be recreated on demand by the OS, + * and Java static data and C++ static data remain with their current values. + * If this hint is false, then SDL will call exit() when you return from your + * main function and the application will be terminated and then started fresh + * each time. + * + * The variable can be set to the following values: + * + * - "0": The application starts fresh at each launch. (default) + * - "1": The application activity can be recreated by the OS. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_ANDROID_ALLOW_RECREATE_ACTIVITY "SDL_ANDROID_ALLOW_RECREATE_ACTIVITY" + +/** + * A variable to control whether the event loop will block itself when the app + * is paused. + * + * The variable can be set to the following values: + * + * - "0": Non blocking. + * - "1": Blocking. (default) + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_ANDROID_BLOCK_ON_PAUSE "SDL_ANDROID_BLOCK_ON_PAUSE" + +/** + * A variable to control whether low latency audio should be enabled. + * + * Some devices have poor quality output when this is enabled, but this is + * usually an improvement in audio latency. + * + * The variable can be set to the following values: + * + * - "0": Low latency audio is not enabled. + * - "1": Low latency audio is enabled. (default) + * + * This hint should be set before SDL audio is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_ANDROID_LOW_LATENCY_AUDIO "SDL_ANDROID_LOW_LATENCY_AUDIO" + +/** + * A variable to control whether we trap the Android back button to handle it + * manually. + * + * This is necessary for the right mouse button to work on some Android + * devices, or to be able to trap the back button for use in your code + * reliably. If this hint is true, the back button will show up as an + * SDL_EVENT_KEY_DOWN / SDL_EVENT_KEY_UP pair with a keycode of + * SDL_SCANCODE_AC_BACK. + * + * The variable can be set to the following values: + * + * - "0": Back button will be handled as usual for system. (default) + * - "1": Back button will be trapped, allowing you to handle the key press + * manually. (This will also let right mouse click work on systems where the + * right mouse button functions as back.) + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_ANDROID_TRAP_BACK_BUTTON "SDL_ANDROID_TRAP_BACK_BUTTON" + +/** + * A variable setting the app ID string. + * + * This string is used by desktop compositors to identify and group windows + * together, as well as match applications with associated desktop settings + * and icons. + * + * This will override SDL_PROP_APP_METADATA_IDENTIFIER_STRING, if set by the + * application. + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_APP_ID "SDL_APP_ID" + +/** + * A variable setting the application name. + * + * This hint lets you specify the application name sent to the OS when + * required. For example, this will often appear in volume control applets for + * audio streams, and in lists of applications which are inhibiting the + * screensaver. You should use a string that describes your program ("My Game + * 2: The Revenge") + * + * This will override SDL_PROP_APP_METADATA_NAME_STRING, if set by the + * application. + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_APP_NAME "SDL_APP_NAME" + +/** + * A variable controlling whether controllers used with the Apple TV generate + * UI events. + * + * When UI events are generated by controller input, the app will be + * backgrounded when the Apple TV remote's menu button is pressed, and when + * the pause or B buttons on gamepads are pressed. + * + * More information about properly making use of controllers for the Apple TV + * can be found here: + * https://developer.apple.com/tvos/human-interface-guidelines/remote-and-controllers/ + * + * The variable can be set to the following values: + * + * - "0": Controller input does not generate UI events. (default) + * - "1": Controller input generates UI events. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_APPLE_TV_CONTROLLER_UI_EVENTS "SDL_APPLE_TV_CONTROLLER_UI_EVENTS" + +/** + * A variable controlling whether the Apple TV remote's joystick axes will + * automatically match the rotation of the remote. + * + * The variable can be set to the following values: + * + * - "0": Remote orientation does not affect joystick axes. (default) + * - "1": Joystick axes are based on the orientation of the remote. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_APPLE_TV_REMOTE_ALLOW_ROTATION "SDL_APPLE_TV_REMOTE_ALLOW_ROTATION" + +/** + * Specify the default ALSA audio device name. + * + * This variable is a specific audio device to open when the "default" audio + * device is used. + * + * This hint will be ignored when opening the default playback device if + * SDL_HINT_AUDIO_ALSA_DEFAULT_PLAYBACK_DEVICE is set, or when opening the + * default recording device if SDL_HINT_AUDIO_ALSA_DEFAULT_RECORDING_DEVICE is + * set. + * + * This hint should be set before an audio device is opened. + * + * \since This hint is available since SDL 3.2.0. + * + * \sa SDL_HINT_AUDIO_ALSA_DEFAULT_PLAYBACK_DEVICE + * \sa SDL_HINT_AUDIO_ALSA_DEFAULT_RECORDING_DEVICE + */ +#define SDL_HINT_AUDIO_ALSA_DEFAULT_DEVICE "SDL_AUDIO_ALSA_DEFAULT_DEVICE" + +/** + * Specify the default ALSA audio playback device name. + * + * This variable is a specific audio device to open for playback, when the + * "default" audio device is used. + * + * If this hint isn't set, SDL will check SDL_HINT_AUDIO_ALSA_DEFAULT_DEVICE + * before choosing a reasonable default. + * + * This hint should be set before an audio device is opened. + * + * \since This hint is available since SDL 3.2.0. + * + * \sa SDL_HINT_AUDIO_ALSA_DEFAULT_RECORDING_DEVICE + * \sa SDL_HINT_AUDIO_ALSA_DEFAULT_DEVICE + */ +#define SDL_HINT_AUDIO_ALSA_DEFAULT_PLAYBACK_DEVICE "SDL_AUDIO_ALSA_DEFAULT_PLAYBACK_DEVICE" + +/** + * Specify the default ALSA audio recording device name. + * + * This variable is a specific audio device to open for recording, when the + * "default" audio device is used. + * + * If this hint isn't set, SDL will check SDL_HINT_AUDIO_ALSA_DEFAULT_DEVICE + * before choosing a reasonable default. + * + * This hint should be set before an audio device is opened. + * + * \since This hint is available since SDL 3.2.0. + * + * \sa SDL_HINT_AUDIO_ALSA_DEFAULT_PLAYBACK_DEVICE + * \sa SDL_HINT_AUDIO_ALSA_DEFAULT_DEVICE + */ +#define SDL_HINT_AUDIO_ALSA_DEFAULT_RECORDING_DEVICE "SDL_AUDIO_ALSA_DEFAULT_RECORDING_DEVICE" + +/** + * A variable controlling the audio category on iOS and macOS. + * + * The variable can be set to the following values: + * + * - "ambient": Use the AVAudioSessionCategoryAmbient audio category, will be + * muted by the phone mute switch (default) + * - "playback": Use the AVAudioSessionCategoryPlayback category. + * + * For more information, see Apple's documentation: + * https://developer.apple.com/library/content/documentation/Audio/Conceptual/AudioSessionProgrammingGuide/AudioSessionCategoriesandModes/AudioSessionCategoriesandModes.html + * + * This hint should be set before an audio device is opened. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_AUDIO_CATEGORY "SDL_AUDIO_CATEGORY" + +/** + * A variable controlling the default audio channel count. + * + * If the application doesn't specify the audio channel count when opening the + * device, this hint can be used to specify a default channel count that will + * be used. This defaults to "1" for recording and "2" for playback devices. + * + * This hint should be set before an audio device is opened. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_AUDIO_CHANNELS "SDL_AUDIO_CHANNELS" + +/** + * Specify an application icon name for an audio device. + * + * Some audio backends (such as Pulseaudio and Pipewire) allow you to set an + * XDG icon name for your application. Among other things, this icon might + * show up in a system control panel that lets the user adjust the volume on + * specific audio streams instead of using one giant master volume slider. + * Note that this is unrelated to the icon used by the windowing system, which + * may be set with SDL_SetWindowIcon (or via desktop file on Wayland). + * + * Setting this to "" or leaving it unset will have SDL use a reasonable + * default, "applications-games", which is likely to be installed. See + * https://specifications.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html + * and + * https://specifications.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html + * for the relevant XDG icon specs. + * + * This hint should be set before an audio device is opened. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_AUDIO_DEVICE_APP_ICON_NAME "SDL_AUDIO_DEVICE_APP_ICON_NAME" + +/** + * A variable controlling device buffer size. + * + * This hint is an integer > 0, that represents the size of the device's + * buffer in sample frames (stereo audio data in 16-bit format is 4 bytes per + * sample frame, for example). + * + * SDL3 generally decides this value on behalf of the app, but if for some + * reason the app needs to dictate this (because they want either lower + * latency or higher throughput AND ARE WILLING TO DEAL WITH what that might + * require of the app), they can specify it. + * + * SDL will try to accommodate this value, but there is no promise you'll get + * the buffer size requested. Many platforms won't honor this request at all, + * or might adjust it. + * + * This hint should be set before an audio device is opened. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_AUDIO_DEVICE_SAMPLE_FRAMES "SDL_AUDIO_DEVICE_SAMPLE_FRAMES" + +/** + * Specify an audio stream name for an audio device. + * + * Some audio backends (such as PulseAudio) allow you to describe your audio + * stream. Among other things, this description might show up in a system + * control panel that lets the user adjust the volume on specific audio + * streams instead of using one giant master volume slider. + * + * This hints lets you transmit that information to the OS. The contents of + * this hint are used while opening an audio device. You should use a string + * that describes your what your program is playing ("audio stream" is + * probably sufficient in many cases, but this could be useful for something + * like "team chat" if you have a headset playing VoIP audio separately). + * + * Setting this to "" or leaving it unset will have SDL use a reasonable + * default: "audio stream" or something similar. + * + * Note that while this talks about audio streams, this is an OS-level + * concept, so it applies to a physical audio device in this case, and not an + * SDL_AudioStream, nor an SDL logical audio device. + * + * This hint should be set before an audio device is opened. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_AUDIO_DEVICE_STREAM_NAME "SDL_AUDIO_DEVICE_STREAM_NAME" + +/** + * Specify an application role for an audio device. + * + * Some audio backends (such as Pipewire) allow you to describe the role of + * your audio stream. Among other things, this description might show up in a + * system control panel or software for displaying and manipulating media + * playback/recording graphs. + * + * This hints lets you transmit that information to the OS. The contents of + * this hint are used while opening an audio device. You should use a string + * that describes your what your program is playing (Game, Music, Movie, + * etc...). + * + * Setting this to "" or leaving it unset will have SDL use a reasonable + * default: "Game" or something similar. + * + * Note that while this talks about audio streams, this is an OS-level + * concept, so it applies to a physical audio device in this case, and not an + * SDL_AudioStream, nor an SDL logical audio device. + * + * For Windows WASAPI audio, the following roles are supported, and map to + * `AUDIO_STREAM_CATEGORY`: + * + * - "Other" (default) + * - "Communications" - Real-time communications, such as VOIP or chat + * - "Game" - Game audio + * - "GameChat" - Game chat audio, similar to "Communications" except that + * this will not attenuate other audio streams + * - "Movie" - Music or sound with dialog + * - "Media" - Music or sound without dialog + * + * If your application applies its own echo cancellation, gain control, and + * noise reduction it should also set SDL_HINT_AUDIO_DEVICE_RAW_STREAM. + * + * This hint should be set before an audio device is opened. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_AUDIO_DEVICE_STREAM_ROLE "SDL_AUDIO_DEVICE_STREAM_ROLE" + +/** + * Specify whether this audio device should do audio processing. + * + * Some operating systems perform echo cancellation, gain control, and noise + * reduction as needed. If your application already handles these, you can set + * this hint to prevent the OS from doing additional audio processing. + * + * This corresponds to the WASAPI audio option `AUDCLNT_STREAMOPTIONS_RAW`. + * + * The variable can be set to the following values: + * + * - "0": audio processing can be done by the OS. (default) + * - "1": audio processing is done by the application. + * + * This hint should be set before an audio device is opened. + * + * \since This hint is available since SDL 3.4.0. + */ +#define SDL_HINT_AUDIO_DEVICE_RAW_STREAM "SDL_AUDIO_DEVICE_RAW_STREAM" + +/** + * Specify the input file when recording audio using the disk audio driver. + * + * This defaults to "sdlaudio-in.raw" + * + * This hint should be set before an audio device is opened. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_AUDIO_DISK_INPUT_FILE "SDL_AUDIO_DISK_INPUT_FILE" + +/** + * Specify the output file when playing audio using the disk audio driver. + * + * This defaults to "sdlaudio.raw" + * + * This hint should be set before an audio device is opened. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_AUDIO_DISK_OUTPUT_FILE "SDL_AUDIO_DISK_OUTPUT_FILE" + +/** + * A variable controlling the audio rate when using the disk audio driver. + * + * The disk audio driver normally simulates real-time for the audio rate that + * was specified, but you can use this variable to adjust this rate higher or + * lower down to 0. The default value is "1.0". + * + * This hint should be set before an audio device is opened. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_AUDIO_DISK_TIMESCALE "SDL_AUDIO_DISK_TIMESCALE" + +/** + * A variable that specifies an audio backend to use. + * + * By default, SDL will try all available audio backends in a reasonable order + * until it finds one that can work, but this hint allows the app or user to + * force a specific driver, such as "pipewire" if, say, you are on PulseAudio + * but want to try talking to the lower level instead. + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_AUDIO_DRIVER "SDL_AUDIO_DRIVER" + +/** + * A variable controlling the audio rate when using the dummy audio driver. + * + * The dummy audio driver normally simulates real-time for the audio rate that + * was specified, but you can use this variable to adjust this rate higher or + * lower down to 0. The default value is "1.0". + * + * This hint should be set before an audio device is opened. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_AUDIO_DUMMY_TIMESCALE "SDL_AUDIO_DUMMY_TIMESCALE" + +/** + * A variable controlling the default audio format. + * + * If the application doesn't specify the audio format when opening the + * device, this hint can be used to specify a default format that will be + * used. + * + * The variable can be set to the following values: + * + * - "U8": Unsigned 8-bit audio + * - "S8": Signed 8-bit audio + * - "S16LE": Signed 16-bit little-endian audio + * - "S16BE": Signed 16-bit big-endian audio + * - "S16": Signed 16-bit native-endian audio (default) + * - "S32LE": Signed 32-bit little-endian audio + * - "S32BE": Signed 32-bit big-endian audio + * - "S32": Signed 32-bit native-endian audio + * - "F32LE": Floating point little-endian audio + * - "F32BE": Floating point big-endian audio + * - "F32": Floating point native-endian audio + * + * This hint should be set before an audio device is opened. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_AUDIO_FORMAT "SDL_AUDIO_FORMAT" + +/** + * A variable controlling the default audio frequency. + * + * If the application doesn't specify the audio frequency when opening the + * device, this hint can be used to specify a default frequency that will be + * used. This defaults to "44100". + * + * This hint should be set before an audio device is opened. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_AUDIO_FREQUENCY "SDL_AUDIO_FREQUENCY" + +/** + * A variable that causes SDL to not ignore audio "monitors". + * + * This is currently only used by the PulseAudio driver. + * + * By default, SDL ignores audio devices that aren't associated with physical + * hardware. Changing this hint to "1" will expose anything SDL sees that + * appears to be an audio source or sink. This will add "devices" to the list + * that the user probably doesn't want or need, but it can be useful in + * scenarios where you want to hook up SDL to some sort of virtual device, + * etc. + * + * The variable can be set to the following values: + * + * - "0": Audio monitor devices will be ignored. (default) + * - "1": Audio monitor devices will show up in the device list. + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_AUDIO_INCLUDE_MONITORS "SDL_AUDIO_INCLUDE_MONITORS" + +/** + * A variable controlling whether SDL updates joystick state when getting + * input events. + * + * The variable can be set to the following values: + * + * - "0": You'll call SDL_UpdateJoysticks() manually. + * - "1": SDL will automatically call SDL_UpdateJoysticks(). (default) + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_AUTO_UPDATE_JOYSTICKS "SDL_AUTO_UPDATE_JOYSTICKS" + +/** + * A variable controlling whether SDL updates sensor state when getting input + * events. + * + * The variable can be set to the following values: + * + * - "0": You'll call SDL_UpdateSensors() manually. + * - "1": SDL will automatically call SDL_UpdateSensors(). (default) + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_AUTO_UPDATE_SENSORS "SDL_AUTO_UPDATE_SENSORS" + +/** + * Prevent SDL from using version 4 of the bitmap header when saving BMPs. + * + * The bitmap header version 4 is required for proper alpha channel support + * and SDL will use it when required. Should this not be desired, this hint + * can force the use of the 40 byte header version which is supported + * everywhere. + * + * The variable can be set to the following values: + * + * - "0": Surfaces with a colorkey or an alpha channel are saved to a 32-bit + * BMP file with an alpha mask. SDL will use the bitmap header version 4 and + * set the alpha mask accordingly. (default) + * - "1": Surfaces with a colorkey or an alpha channel are saved to a 32-bit + * BMP file without an alpha mask. The alpha channel data will be in the + * file, but applications are going to ignore it. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_BMP_SAVE_LEGACY_FORMAT "SDL_BMP_SAVE_LEGACY_FORMAT" + +/** + * A variable that decides what camera backend to use. + * + * By default, SDL will try all available camera backends in a reasonable + * order until it finds one that can work, but this hint allows the app or + * user to force a specific target, such as "directshow" if, say, you are on + * Windows Media Foundations but want to try DirectShow instead. + * + * The default value is unset, in which case SDL will try to figure out the + * best camera backend on your behalf. This hint needs to be set before + * SDL_Init() is called to be useful. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_CAMERA_DRIVER "SDL_CAMERA_DRIVER" + +/** + * A variable that limits what CPU features are available. + * + * By default, SDL marks all features the current CPU supports as available. + * This hint allows the enabled features to be limited to a subset. + * + * When the hint is unset, or empty, SDL will enable all detected CPU + * features. + * + * The variable can be set to a comma separated list containing the following + * items: + * + * - "all" + * - "altivec" + * - "sse" + * - "sse2" + * - "sse3" + * - "sse41" + * - "sse42" + * - "avx" + * - "avx2" + * - "avx512f" + * - "arm-simd" + * - "neon" + * - "lsx" + * - "lasx" + * + * The items can be prefixed by '+'/'-' to add/remove features. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_CPU_FEATURE_MASK "SDL_CPU_FEATURE_MASK" + +/** + * A variable controlling whether DirectInput should be used for controllers. + * + * The variable can be set to the following values: + * + * - "0": Disable DirectInput detection. + * - "1": Enable DirectInput detection. (default) + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_DIRECTINPUT "SDL_JOYSTICK_DIRECTINPUT" + +/** + * A variable that specifies a dialog backend to use. + * + * By default, SDL will try all available dialog backends in a reasonable + * order until it finds one that can work, but this hint allows the app or + * user to force a specific target. + * + * If the specified target does not exist or is not available, the + * dialog-related function calls will fail. + * + * This hint currently only applies to platforms using the generic "Unix" + * dialog implementation, but may be extended to more platforms in the future. + * Note that some Unix and Unix-like platforms have their own implementation, + * such as macOS and Haiku. + * + * The variable can be set to the following values: + * + * - NULL: Select automatically (default, all platforms) + * - "portal": Use XDG Portals through DBus (Unix only) + * - "zenity": Use the Zenity program (Unix only) + * + * More options may be added in the future. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_FILE_DIALOG_DRIVER "SDL_FILE_DIALOG_DRIVER" + +/** + * Override for SDL_GetDisplayUsableBounds(). + * + * If set, this hint will override the expected results for + * SDL_GetDisplayUsableBounds() for display index 0. Generally you don't want + * to do this, but this allows an embedded system to request that some of the + * screen be reserved for other uses when paired with a well-behaved + * application. + * + * The contents of this hint must be 4 comma-separated integers, the first is + * the bounds x, then y, width and height, in that order. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_DISPLAY_USABLE_BOUNDS "SDL_DISPLAY_USABLE_BOUNDS" + +/** + * Set the level of checking for invalid parameters passed to SDL functions. + * + * The variable can be set to the following values: + * + * - "1": Enable fast parameter error checking, e.g. quick NULL checks, etc. + * - "2": Enable full parameter error checking, e.g. validating objects are + * the correct type, etc. (default) + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.4.0. + */ +#define SDL_HINT_INVALID_PARAM_CHECKS "SDL_INVALID_PARAM_CHECKS" + +/** + * Disable giving back control to the browser automatically when running with + * asyncify. + * + * With -s ASYNCIFY, SDL calls emscripten_sleep during operations such as + * refreshing the screen or polling events. + * + * This hint only applies to the emscripten platform. + * + * The variable can be set to the following values: + * + * - "0": Disable emscripten_sleep calls (if you give back browser control + * manually or use asyncify for other purposes). + * - "1": Enable emscripten_sleep calls. (default) + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_EMSCRIPTEN_ASYNCIFY "SDL_EMSCRIPTEN_ASYNCIFY" + +/** + * Specify the CSS selector used for the "default" window/canvas. + * + * This hint only applies to the emscripten platform. + * + * This hint should be set before creating a window. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_EMSCRIPTEN_CANVAS_SELECTOR "SDL_EMSCRIPTEN_CANVAS_SELECTOR" + +/** + * Override the binding element for keyboard inputs for Emscripten builds. + * + * This hint only applies to the emscripten platform. + * + * The variable can be one of: + * + * - "#window": the javascript window object + * - "#document": the javascript document object + * - "#screen": the javascript window.screen object + * - "#canvas": the WebGL canvas element + * - "#none": Don't bind anything at all + * - any other string without a leading # sign applies to the element on the + * page with that ID. + * + * This hint should be set before creating a window. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT "SDL_EMSCRIPTEN_KEYBOARD_ELEMENT" + +/** + * A variable that controls whether the on-screen keyboard should be shown + * when text input is active. + * + * The variable can be set to the following values: + * + * - "auto": The on-screen keyboard will be shown if there is no physical + * keyboard attached. (default) + * - "0": Do not show the on-screen keyboard. + * - "1": Show the on-screen keyboard, if available. + * + * This hint must be set before SDL_StartTextInput() is called + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_ENABLE_SCREEN_KEYBOARD "SDL_ENABLE_SCREEN_KEYBOARD" + +/** + * A variable containing a list of evdev devices to use if udev is not + * available. + * + * The list of devices is in the form: + * + * deviceclass:path[,deviceclass:path[,...]] + * + * where device class is an integer representing the SDL_UDEV_deviceclass and + * path is the full path to the event device. + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_EVDEV_DEVICES "SDL_EVDEV_DEVICES" + +/** + * A variable controlling verbosity of the logging of SDL events pushed onto + * the internal queue. + * + * The variable can be set to the following values, from least to most + * verbose: + * + * - "0": Don't log any events. (default) + * - "1": Log most events (other than the really spammy ones). + * - "2": Include mouse and finger motion events. + * + * This is generally meant to be used to debug SDL itself, but can be useful + * for application developers that need better visibility into what is going + * on in the event queue. Logged events are sent through SDL_Log(), which + * means by default they appear on stdout on most platforms or maybe + * OutputDebugString() on Windows, and can be funneled by the app with + * SDL_SetLogOutputFunction(), etc. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_EVENT_LOGGING "SDL_EVENT_LOGGING" + +/** + * A variable controlling whether raising the window should be done more + * forcefully. + * + * The variable can be set to the following values: + * + * - "0": Honor the OS policy for raising windows. (default) + * - "1": Force the window to be raised, overriding any OS policy. + * + * At present, this is only an issue under MS Windows, which makes it nearly + * impossible to programmatically move a window to the foreground, for + * "security" reasons. See http://stackoverflow.com/a/34414846 for a + * discussion. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_FORCE_RAISEWINDOW "SDL_FORCE_RAISEWINDOW" + +/** + * A variable controlling how 3D acceleration is used to accelerate the SDL + * screen surface. + * + * SDL can try to accelerate the SDL screen surface by using streaming + * textures with a 3D rendering engine. This variable controls whether and how + * this is done. + * + * The variable can be set to the following values: + * + * - "0": Disable 3D acceleration + * - "1": Enable 3D acceleration, using the default renderer. (default) + * - "X": Enable 3D acceleration, using X where X is one of the valid + * rendering drivers. (e.g. "direct3d", "opengl", etc.) + * + * This hint should be set before calling SDL_GetWindowSurface() + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_FRAMEBUFFER_ACCELERATION "SDL_FRAMEBUFFER_ACCELERATION" + +/** + * A variable that lets you manually hint extra gamecontroller db entries. + * + * The variable should be newline delimited rows of gamecontroller config + * data, see SDL_gamepad.h + * + * You can update mappings after SDL is initialized with + * SDL_GetGamepadMappingForGUID() and SDL_AddGamepadMapping() + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_GAMECONTROLLERCONFIG "SDL_GAMECONTROLLERCONFIG" + +/** + * A variable that lets you provide a file with extra gamecontroller db + * entries. + * + * The file should contain lines of gamecontroller config data, see + * SDL_gamepad.h + * + * You can update mappings after SDL is initialized with + * SDL_GetGamepadMappingForGUID() and SDL_AddGamepadMapping() + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_GAMECONTROLLERCONFIG_FILE "SDL_GAMECONTROLLERCONFIG_FILE" + +/** + * A variable that overrides the automatic controller type detection. + * + * The variable should be comma separated entries, in the form: VID/PID=type + * + * The VID and PID should be hexadecimal with exactly 4 digits, e.g. 0x00fd + * + * This hint affects what low level protocol is used with the HIDAPI driver. + * + * The variable can be set to the following values: + * + * - "Xbox360" + * - "XboxOne" + * - "PS3" + * - "PS4" + * - "PS5" + * - "SwitchPro" + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_GAMECONTROLLERTYPE "SDL_GAMECONTROLLERTYPE" + +/** + * A variable containing a list of devices to skip when scanning for game + * controllers. + * + * The format of the string is a comma separated list of USB VID/PID pairs in + * hexadecimal form, e.g. + * + * 0xAAAA/0xBBBB,0xCCCC/0xDDDD + * + * The variable can also take the form of "@file", in which case the named + * file will be loaded and interpreted as the value of the variable. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_GAMECONTROLLER_IGNORE_DEVICES "SDL_GAMECONTROLLER_IGNORE_DEVICES" + +/** + * If set, all devices will be skipped when scanning for game controllers + * except for the ones listed in this variable. + * + * The format of the string is a comma separated list of USB VID/PID pairs in + * hexadecimal form, e.g. + * + * 0xAAAA/0xBBBB,0xCCCC/0xDDDD + * + * The variable can also take the form of "@file", in which case the named + * file will be loaded and interpreted as the value of the variable. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT "SDL_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT" + +/** + * A variable that controls whether the device's built-in accelerometer and + * gyro should be used as sensors for gamepads. + * + * The variable can be set to the following values: + * + * - "0": Sensor fusion is disabled + * - "1": Sensor fusion is enabled for all controllers that lack sensors + * + * Or the variable can be a comma separated list of USB VID/PID pairs in + * hexadecimal form, e.g. + * + * 0xAAAA/0xBBBB,0xCCCC/0xDDDD + * + * The variable can also take the form of "@file", in which case the named + * file will be loaded and interpreted as the value of the variable. + * + * This hint should be set before a gamepad is opened. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_GAMECONTROLLER_SENSOR_FUSION "SDL_GAMECONTROLLER_SENSOR_FUSION" + +/** + * This variable sets the default text of the TextInput window on GDK + * platforms. + * + * This hint is available only if SDL_GDK_TEXTINPUT defined. + * + * This hint should be set before calling SDL_StartTextInput() + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_GDK_TEXTINPUT_DEFAULT_TEXT "SDL_GDK_TEXTINPUT_DEFAULT_TEXT" + +/** + * This variable sets the description of the TextInput window on GDK + * platforms. + * + * This hint is available only if SDL_GDK_TEXTINPUT defined. + * + * This hint should be set before calling SDL_StartTextInput() + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_GDK_TEXTINPUT_DESCRIPTION "SDL_GDK_TEXTINPUT_DESCRIPTION" + +/** + * This variable sets the maximum input length of the TextInput window on GDK + * platforms. + * + * The value must be a stringified integer, for example "10" to allow for up + * to 10 characters of text input. + * + * This hint is available only if SDL_GDK_TEXTINPUT defined. + * + * This hint should be set before calling SDL_StartTextInput() + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_GDK_TEXTINPUT_MAX_LENGTH "SDL_GDK_TEXTINPUT_MAX_LENGTH" + +/** + * This variable sets the input scope of the TextInput window on GDK + * platforms. + * + * Set this hint to change the XGameUiTextEntryInputScope value that will be + * passed to the window creation function. The value must be a stringified + * integer, for example "0" for XGameUiTextEntryInputScope::Default. + * + * This hint is available only if SDL_GDK_TEXTINPUT defined. + * + * This hint should be set before calling SDL_StartTextInput() + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_GDK_TEXTINPUT_SCOPE "SDL_GDK_TEXTINPUT_SCOPE" + +/** + * This variable sets the title of the TextInput window on GDK platforms. + * + * This hint is available only if SDL_GDK_TEXTINPUT defined. + * + * This hint should be set before calling SDL_StartTextInput() + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_GDK_TEXTINPUT_TITLE "SDL_GDK_TEXTINPUT_TITLE" + +/** + * A variable to control whether HIDAPI uses libusb for device access. + * + * By default libusb will only be used for a few devices that require direct + * USB access, and this can be controlled with + * SDL_HINT_HIDAPI_LIBUSB_WHITELIST. + * + * The variable can be set to the following values: + * + * - "0": HIDAPI will not use libusb for device access. + * - "1": HIDAPI will use libusb for device access if available. (default) + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_HIDAPI_LIBUSB "SDL_HIDAPI_LIBUSB" + + +/** + * A variable to control whether HIDAPI uses libusb for GameCube adapters. + * + * The variable can be set to the following values: + * + * - "0": HIDAPI will not use libusb for GameCube adapters. + * - "1": HIDAPI will use libusb for GameCube adapters if available. (default) + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_HIDAPI_LIBUSB_GAMECUBE "SDL_HIDAPI_LIBUSB_GAMECUBE" + +/** + * A variable to control whether HIDAPI uses libusb only for whitelisted + * devices. + * + * By default libusb will only be used for a few devices that require direct + * USB access. + * + * The variable can be set to the following values: + * + * - "0": HIDAPI will use libusb for all device access. + * - "1": HIDAPI will use libusb only for whitelisted devices. (default) + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_HIDAPI_LIBUSB_WHITELIST "SDL_HIDAPI_LIBUSB_WHITELIST" + +/** + * A variable to control whether HIDAPI uses udev for device detection. + * + * The variable can be set to the following values: + * + * - "0": HIDAPI will poll for device changes. + * - "1": HIDAPI will use udev for device detection. (default) + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_HIDAPI_UDEV "SDL_HIDAPI_UDEV" + +/** + * A variable that specifies a GPU backend to use. + * + * By default, SDL will try all available GPU backends in a reasonable order + * until it finds one that can work, but this hint allows the app or user to + * force a specific target, such as "direct3d12" if, say, your hardware + * supports Vulkan but you want to try using D3D12 instead. + * + * This hint should be set before any GPU functions are called. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_GPU_DRIVER "SDL_GPU_DRIVER" + +/** + * A variable to control whether SDL_hid_enumerate() enumerates all HID + * devices or only controllers. + * + * The variable can be set to the following values: + * + * - "0": SDL_hid_enumerate() will enumerate all HID devices. + * - "1": SDL_hid_enumerate() will only enumerate controllers. (default) + * + * By default SDL will only enumerate controllers, to reduce risk of hanging + * or crashing on devices with bad drivers and avoiding macOS keyboard capture + * permission prompts. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_HIDAPI_ENUMERATE_ONLY_CONTROLLERS "SDL_HIDAPI_ENUMERATE_ONLY_CONTROLLERS" + +/** + * A variable containing a list of devices to ignore in SDL_hid_enumerate(). + * + * The format of the string is a comma separated list of USB VID/PID pairs in + * hexadecimal form, e.g. + * + * `0xAAAA/0xBBBB,0xCCCC/0xDDDD` + * + * For example, to ignore the Shanwan DS3 controller and any Valve controller, + * you might use the string "0x2563/0x0523,0x28de/0x0000" + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_HIDAPI_IGNORE_DEVICES "SDL_HIDAPI_IGNORE_DEVICES" + +/** + * A variable describing what IME UI elements the application can display. + * + * By default IME UI is handled using native components by the OS where + * possible, however this can interfere with or not be visible when exclusive + * fullscreen mode is used. + * + * The variable can be set to a comma separated list containing the following + * items: + * + * - "none" or "0": The application can't render any IME elements, and native + * UI should be used. (default) + * - "composition": The application handles SDL_EVENT_TEXT_EDITING events and + * can render the composition text. + * - "candidates": The application handles SDL_EVENT_TEXT_EDITING_CANDIDATES + * and can render the candidate list. + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_IME_IMPLEMENTED_UI "SDL_IME_IMPLEMENTED_UI" + +/** + * A variable controlling whether the home indicator bar on iPhone X and later + * should be hidden. + * + * The variable can be set to the following values: + * + * - "0": The indicator bar is not hidden. (default for windowed applications) + * - "1": The indicator bar is hidden and is shown when the screen is touched + * (useful for movie playback applications). + * - "2": The indicator bar is dim and the first swipe makes it visible and + * the second swipe performs the "home" action. (default for fullscreen + * applications) + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_IOS_HIDE_HOME_INDICATOR "SDL_IOS_HIDE_HOME_INDICATOR" + +/** + * A variable that lets you enable joystick (and gamecontroller) events even + * when your app is in the background. + * + * The variable can be set to the following values: + * + * - "0": Disable joystick & gamecontroller input events when the application + * is in the background. (default) + * - "1": Enable joystick & gamecontroller input events when the application + * is in the background. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS "SDL_JOYSTICK_ALLOW_BACKGROUND_EVENTS" + +/** + * A variable containing a list of arcade stick style controllers. + * + * The format of the string is a comma separated list of USB VID/PID pairs in + * hexadecimal form, e.g. + * + * `0xAAAA/0xBBBB,0xCCCC/0xDDDD` + * + * The variable can also take the form of "@file", in which case the named + * file will be loaded and interpreted as the value of the variable. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_ARCADESTICK_DEVICES "SDL_JOYSTICK_ARCADESTICK_DEVICES" + +/** + * A variable containing a list of devices that are not arcade stick style + * controllers. + * + * This will override SDL_HINT_JOYSTICK_ARCADESTICK_DEVICES and the built in + * device list. + * + * The format of the string is a comma separated list of USB VID/PID pairs in + * hexadecimal form, e.g. + * + * `0xAAAA/0xBBBB,0xCCCC/0xDDDD` + * + * The variable can also take the form of "@file", in which case the named + * file will be loaded and interpreted as the value of the variable. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_ARCADESTICK_DEVICES_EXCLUDED "SDL_JOYSTICK_ARCADESTICK_DEVICES_EXCLUDED" + +/** + * A variable containing a list of devices that should not be considered + * joysticks. + * + * The format of the string is a comma separated list of USB VID/PID pairs in + * hexadecimal form, e.g. + * + * `0xAAAA/0xBBBB,0xCCCC/0xDDDD` + * + * The variable can also take the form of "@file", in which case the named + * file will be loaded and interpreted as the value of the variable. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_BLACKLIST_DEVICES "SDL_JOYSTICK_BLACKLIST_DEVICES" + +/** + * A variable containing a list of devices that should be considered + * joysticks. + * + * This will override SDL_HINT_JOYSTICK_BLACKLIST_DEVICES and the built in + * device list. + * + * The format of the string is a comma separated list of USB VID/PID pairs in + * hexadecimal form, e.g. + * + * `0xAAAA/0xBBBB,0xCCCC/0xDDDD` + * + * The variable can also take the form of "@file", in which case the named + * file will be loaded and interpreted as the value of the variable. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_BLACKLIST_DEVICES_EXCLUDED "SDL_JOYSTICK_BLACKLIST_DEVICES_EXCLUDED" + +/** + * A variable containing a comma separated list of devices to open as + * joysticks. + * + * This variable is currently only used by the Linux joystick driver. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_DEVICE "SDL_JOYSTICK_DEVICE" + +/** + * A variable controlling whether enhanced reports should be used for + * controllers when using the HIDAPI driver. + * + * Enhanced reports allow rumble and effects on Bluetooth PlayStation + * controllers and gyro on Nintendo Switch controllers, but break Windows + * DirectInput for other applications that don't use SDL. + * + * Once enhanced reports are enabled, they can't be disabled on PlayStation + * controllers without power cycling the controller. + * + * The variable can be set to the following values: + * + * - "0": enhanced reports are not enabled. + * - "1": enhanced reports are enabled. (default) + * - "auto": enhanced features are advertised to the application, but SDL + * doesn't change the controller report mode unless the application uses + * them. + * + * This hint can be enabled anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_ENHANCED_REPORTS "SDL_JOYSTICK_ENHANCED_REPORTS" + +/** + * A variable containing a list of flightstick style controllers. + * + * The format of the string is a comma separated list of USB VID/PID pairs in + * hexadecimal form, e.g. + * + * `0xAAAA/0xBBBB,0xCCCC/0xDDDD` + * + * The variable can also take the form of @file, in which case the named file + * will be loaded and interpreted as the value of the variable. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_FLIGHTSTICK_DEVICES "SDL_JOYSTICK_FLIGHTSTICK_DEVICES" + +/** + * A variable containing a list of devices that are not flightstick style + * controllers. + * + * This will override SDL_HINT_JOYSTICK_FLIGHTSTICK_DEVICES and the built in + * device list. + * + * The format of the string is a comma separated list of USB VID/PID pairs in + * hexadecimal form, e.g. + * + * `0xAAAA/0xBBBB,0xCCCC/0xDDDD` + * + * The variable can also take the form of "@file", in which case the named + * file will be loaded and interpreted as the value of the variable. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_FLIGHTSTICK_DEVICES_EXCLUDED "SDL_JOYSTICK_FLIGHTSTICK_DEVICES_EXCLUDED" + +/** + * A variable controlling whether GameInput should be used for controller + * handling on Windows. + * + * The variable can be set to the following values: + * + * - "0": GameInput is not used. + * - "1": GameInput is used. + * + * The default is "1" on GDK platforms, and "0" otherwise. + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_GAMEINPUT "SDL_JOYSTICK_GAMEINPUT" + +/** + * A variable containing a list of devices known to have a GameCube form + * factor. + * + * The format of the string is a comma separated list of USB VID/PID pairs in + * hexadecimal form, e.g. + * + * `0xAAAA/0xBBBB,0xCCCC/0xDDDD` + * + * The variable can also take the form of "@file", in which case the named + * file will be loaded and interpreted as the value of the variable. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_GAMECUBE_DEVICES "SDL_JOYSTICK_GAMECUBE_DEVICES" + +/** + * A variable containing a list of devices known not to have a GameCube form + * factor. + * + * This will override SDL_HINT_JOYSTICK_GAMECUBE_DEVICES and the built in + * device list. + * + * The format of the string is a comma separated list of USB VID/PID pairs in + * hexadecimal form, e.g. + * + * `0xAAAA/0xBBBB,0xCCCC/0xDDDD` + * + * The variable can also take the form of "@file", in which case the named + * file will be loaded and interpreted as the value of the variable. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_GAMECUBE_DEVICES_EXCLUDED "SDL_JOYSTICK_GAMECUBE_DEVICES_EXCLUDED" + +/** + * A variable controlling whether the HIDAPI joystick drivers should be used. + * + * The variable can be set to the following values: + * + * - "0": HIDAPI drivers are not used. + * - "1": HIDAPI drivers are used. (default) + * + * This variable is the default for all drivers, but can be overridden by the + * hints for specific drivers below. + * + * This hint should be set before initializing joysticks and gamepads. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_HIDAPI "SDL_JOYSTICK_HIDAPI" + +/** + * A variable controlling whether Nintendo Switch Joy-Con controllers will be + * combined into a single Pro-like controller when using the HIDAPI driver. + * + * The variable can be set to the following values: + * + * - "0": Left and right Joy-Con controllers will not be combined and each + * will be a mini-gamepad. + * - "1": Left and right Joy-Con controllers will be combined into a single + * controller. (default) + * + * This hint should be set before initializing joysticks and gamepads. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_HIDAPI_COMBINE_JOY_CONS "SDL_JOYSTICK_HIDAPI_COMBINE_JOY_CONS" + +/** + * A variable controlling whether the HIDAPI driver for Nintendo GameCube + * controllers should be used. + * + * The variable can be set to the following values: + * + * - "0": HIDAPI driver is not used. + * - "1": HIDAPI driver is used. + * + * The default is the value of SDL_HINT_JOYSTICK_HIDAPI + * + * This hint should be set before initializing joysticks and gamepads. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_HIDAPI_GAMECUBE "SDL_JOYSTICK_HIDAPI_GAMECUBE" + +/** + * A variable controlling whether rumble is used to implement the GameCube + * controller's 3 rumble modes, Stop(0), Rumble(1), and StopHard(2). + * + * This is useful for applications that need full compatibility for things + * like ADSR envelopes. - Stop is implemented by setting low_frequency_rumble + * to 0 and high_frequency_rumble >0 - Rumble is both at any arbitrary value - + * StopHard is implemented by setting both low_frequency_rumble and + * high_frequency_rumble to 0 + * + * The variable can be set to the following values: + * + * - "0": Normal rumble behavior is behavior is used. (default) + * - "1": Proper GameCube controller rumble behavior is used. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_HIDAPI_GAMECUBE_RUMBLE_BRAKE "SDL_JOYSTICK_HIDAPI_GAMECUBE_RUMBLE_BRAKE" + +/** + * A variable controlling whether the HIDAPI driver for Nintendo Switch + * Joy-Cons should be used. + * + * The variable can be set to the following values: + * + * - "0": HIDAPI driver is not used. + * - "1": HIDAPI driver is used. + * + * The default is the value of SDL_HINT_JOYSTICK_HIDAPI. + * + * This hint should be set before initializing joysticks and gamepads. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS "SDL_JOYSTICK_HIDAPI_JOY_CONS" + +/** + * A variable controlling whether the Home button LED should be turned on when + * a Nintendo Switch Joy-Con controller is opened. + * + * The variable can be set to the following values: + * + * - "0": home button LED is turned off + * - "1": home button LED is turned on + * + * By default the Home button LED state is not changed. This hint can also be + * set to a floating point value between 0.0 and 1.0 which controls the + * brightness of the Home button LED. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_HIDAPI_JOYCON_HOME_LED "SDL_JOYSTICK_HIDAPI_JOYCON_HOME_LED" + +/** + * A variable controlling whether the HIDAPI driver for Amazon Luna + * controllers connected via Bluetooth should be used. + * + * The variable can be set to the following values: + * + * - "0": HIDAPI driver is not used. + * - "1": HIDAPI driver is used. + * + * The default is the value of SDL_HINT_JOYSTICK_HIDAPI. + * + * This hint should be set before initializing joysticks and gamepads. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_HIDAPI_LUNA "SDL_JOYSTICK_HIDAPI_LUNA" + +/** + * A variable controlling whether the HIDAPI driver for Nintendo Online + * classic controllers should be used. + * + * The variable can be set to the following values: + * + * - "0": HIDAPI driver is not used. + * - "1": HIDAPI driver is used. + * + * The default is the value of SDL_HINT_JOYSTICK_HIDAPI. + * + * This hint should be set before initializing joysticks and gamepads. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_HIDAPI_NINTENDO_CLASSIC "SDL_JOYSTICK_HIDAPI_NINTENDO_CLASSIC" + +/** + * A variable controlling whether the HIDAPI driver for PS3 controllers should + * be used. + * + * The variable can be set to the following values: + * + * - "0": HIDAPI driver is not used. + * - "1": HIDAPI driver is used. + * + * The default is the value of SDL_HINT_JOYSTICK_HIDAPI on macOS, and "0" on + * other platforms. + * + * For official Sony driver (sixaxis.sys) use + * SDL_HINT_JOYSTICK_HIDAPI_PS3_SIXAXIS_DRIVER. See + * https://github.com/ViGEm/DsHidMini for an alternative driver on Windows. + * + * This hint should be set before initializing joysticks and gamepads. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_HIDAPI_PS3 "SDL_JOYSTICK_HIDAPI_PS3" + +/** + * A variable controlling whether the Sony driver (sixaxis.sys) for PS3 + * controllers (Sixaxis/DualShock 3) should be used. + * + * The variable can be set to the following values: + * + * - "0": Sony driver (sixaxis.sys) is not used. + * - "1": Sony driver (sixaxis.sys) is used. + * + * The default value is 0. + * + * This hint should be set before initializing joysticks and gamepads. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_HIDAPI_PS3_SIXAXIS_DRIVER "SDL_JOYSTICK_HIDAPI_PS3_SIXAXIS_DRIVER" + +/** + * A variable controlling whether the HIDAPI driver for PS4 controllers should + * be used. + * + * The variable can be set to the following values: + * + * - "0": HIDAPI driver is not used. + * - "1": HIDAPI driver is used. + * + * The default is the value of SDL_HINT_JOYSTICK_HIDAPI. + * + * This hint should be set before initializing joysticks and gamepads. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_HIDAPI_PS4 "SDL_JOYSTICK_HIDAPI_PS4" + +/** + * A variable controlling the update rate of the PS4 controller over Bluetooth + * when using the HIDAPI driver. + * + * This defaults to 4 ms, to match the behavior over USB, and to be more + * friendly to other Bluetooth devices and older Bluetooth hardware on the + * computer. It can be set to "1" (1000Hz), "2" (500Hz) and "4" (250Hz) + * + * This hint can be set anytime, but only takes effect when extended input + * reports are enabled. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_HIDAPI_PS4_REPORT_INTERVAL "SDL_JOYSTICK_HIDAPI_PS4_REPORT_INTERVAL" + +/** + * A variable controlling whether the HIDAPI driver for PS5 controllers should + * be used. + * + * The variable can be set to the following values: + * + * - "0": HIDAPI driver is not used. + * - "1": HIDAPI driver is used. + * + * The default is the value of SDL_HINT_JOYSTICK_HIDAPI. + * + * This hint should be set before initializing joysticks and gamepads. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_HIDAPI_PS5 "SDL_JOYSTICK_HIDAPI_PS5" + +/** + * A variable controlling whether the player LEDs should be lit to indicate + * which player is associated with a PS5 controller. + * + * The variable can be set to the following values: + * + * - "0": player LEDs are not enabled. + * - "1": player LEDs are enabled. (default) + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_HIDAPI_PS5_PLAYER_LED "SDL_JOYSTICK_HIDAPI_PS5_PLAYER_LED" + +/** + * A variable controlling whether the HIDAPI driver for NVIDIA SHIELD + * controllers should be used. + * + * The variable can be set to the following values: + * + * - "0": HIDAPI driver is not used. + * - "1": HIDAPI driver is used. + * + * The default is the value of SDL_HINT_JOYSTICK_HIDAPI. + * + * This hint should be set before initializing joysticks and gamepads. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_HIDAPI_SHIELD "SDL_JOYSTICK_HIDAPI_SHIELD" + +/** + * A variable controlling whether the HIDAPI driver for Google Stadia + * controllers should be used. + * + * The variable can be set to the following values: + * + * - "0": HIDAPI driver is not used. + * - "1": HIDAPI driver is used. + * + * The default is the value of SDL_HINT_JOYSTICK_HIDAPI. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_HIDAPI_STADIA "SDL_JOYSTICK_HIDAPI_STADIA" + +/** + * A variable controlling whether the HIDAPI driver for Bluetooth Steam + * Controllers should be used. + * + * The variable can be set to the following values: + * + * - "0": HIDAPI driver is not used. (default) + * - "1": HIDAPI driver is used for Steam Controllers, which requires + * Bluetooth access and may prompt the user for permission on iOS and + * Android. + * + * This hint should be set before initializing joysticks and gamepads. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_HIDAPI_STEAM "SDL_JOYSTICK_HIDAPI_STEAM" + +/** + * A variable controlling whether the Steam button LED should be turned on + * when a Steam controller is opened. + * + * The variable can be set to the following values: + * + * - "0": Steam button LED is turned off. + * - "1": Steam button LED is turned on. + * + * By default the Steam button LED state is not changed. This hint can also be + * set to a floating point value between 0.0 and 1.0 which controls the + * brightness of the Steam button LED. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_HIDAPI_STEAM_HOME_LED "SDL_JOYSTICK_HIDAPI_STEAM_HOME_LED" + +/** + * A variable controlling whether the HIDAPI driver for the Steam Deck builtin + * controller should be used. + * + * The variable can be set to the following values: + * + * - "0": HIDAPI driver is not used. + * - "1": HIDAPI driver is used. + * + * The default is the value of SDL_HINT_JOYSTICK_HIDAPI. + * + * This hint should be set before initializing joysticks and gamepads. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_HIDAPI_STEAMDECK "SDL_JOYSTICK_HIDAPI_STEAMDECK" + +/** + * A variable controlling whether the HIDAPI driver for HORI licensed Steam + * controllers should be used. + * + * This variable can be set to the following values: "0" - HIDAPI driver is + * not used "1" - HIDAPI driver is used + * + * The default is the value of SDL_HINT_JOYSTICK_HIDAPI + */ +#define SDL_HINT_JOYSTICK_HIDAPI_STEAM_HORI "SDL_JOYSTICK_HIDAPI_STEAM_HORI" + +/** + * A variable controlling whether the HIDAPI driver for some Logitech wheels + * should be used. + * + * This variable can be set to the following values: + * + * - "0": HIDAPI driver is not used + * - "1": HIDAPI driver is used + * + * The default is the value of SDL_HINT_JOYSTICK_HIDAPI + */ +#define SDL_HINT_JOYSTICK_HIDAPI_LG4FF "SDL_JOYSTICK_HIDAPI_LG4FF" + +/** + * A variable controlling whether the HIDAPI driver for 8BitDo controllers + * should be used. + * + * This variable can be set to the following values: + * + * "0" - HIDAPI driver is not used. "1" - HIDAPI driver is used. + * + * The default is the value of SDL_HINT_JOYSTICK_HIDAPI + */ +#define SDL_HINT_JOYSTICK_HIDAPI_8BITDO "SDL_JOYSTICK_HIDAPI_8BITDO" + +/** + * A variable controlling whether the HIDAPI driver for SInput controllers + * should be used. + * + * More info - https://github.com/HandHeldLegend/SInput-HID + * + * This variable can be set to the following values: + * + * "0" - HIDAPI driver is not used. "1" - HIDAPI driver is used. + * + * The default is the value of SDL_HINT_JOYSTICK_HIDAPI + */ +#define SDL_HINT_JOYSTICK_HIDAPI_SINPUT "SDL_JOYSTICK_HIDAPI_SINPUT" + +/** + * A variable controlling whether the HIDAPI driver for ZUIKI controllers + * should be used. + * + * This variable can be set to the following values: + * + * "0" - HIDAPI driver is not used. "1" - HIDAPI driver is used. + * + * The default is the value of SDL_HINT_JOYSTICK_HIDAPI + */ +#define SDL_HINT_JOYSTICK_HIDAPI_ZUIKI "SDL_JOYSTICK_HIDAPI_ZUIKI" + +/** + * A variable controlling whether the HIDAPI driver for Flydigi controllers + * should be used. + * + * This variable can be set to the following values: + * + * "0" - HIDAPI driver is not used. "1" - HIDAPI driver is used. + * + * The default is the value of SDL_HINT_JOYSTICK_HIDAPI + */ +#define SDL_HINT_JOYSTICK_HIDAPI_FLYDIGI "SDL_JOYSTICK_HIDAPI_FLYDIGI" + +/** + * A variable controlling whether the HIDAPI driver for Nintendo Switch + * controllers should be used. + * + * The variable can be set to the following values: + * + * - "0": HIDAPI driver is not used. + * - "1": HIDAPI driver is used. + * + * The default is the value of SDL_HINT_JOYSTICK_HIDAPI. + * + * This hint should be set before initializing joysticks and gamepads. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_HIDAPI_SWITCH "SDL_JOYSTICK_HIDAPI_SWITCH" + +/** + * A variable controlling whether the Home button LED should be turned on when + * a Nintendo Switch Pro controller is opened. + * + * The variable can be set to the following values: + * + * - "0": Home button LED is turned off. + * - "1": Home button LED is turned on. + * + * By default the Home button LED state is not changed. This hint can also be + * set to a floating point value between 0.0 and 1.0 which controls the + * brightness of the Home button LED. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_HIDAPI_SWITCH_HOME_LED "SDL_JOYSTICK_HIDAPI_SWITCH_HOME_LED" + +/** + * A variable controlling whether the player LEDs should be lit to indicate + * which player is associated with a Nintendo Switch controller. + * + * The variable can be set to the following values: + * + * - "0": Player LEDs are not enabled. + * - "1": Player LEDs are enabled. (default) + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_HIDAPI_SWITCH_PLAYER_LED "SDL_JOYSTICK_HIDAPI_SWITCH_PLAYER_LED" + +/** + * A variable controlling whether the HIDAPI driver for Nintendo Switch 2 + * controllers should be used. + * + * The variable can be set to the following values: + * + * - "0": HIDAPI driver is not used. + * - "1": HIDAPI driver is used. + * + * The default is the value of SDL_HINT_JOYSTICK_HIDAPI. + * + * This hint should be set before initializing joysticks and gamepads. + * + * \since This hint is available since SDL 3.4.0. + */ +#define SDL_HINT_JOYSTICK_HIDAPI_SWITCH2 "SDL_JOYSTICK_HIDAPI_SWITCH2" + +/** + * A variable controlling whether Nintendo Switch Joy-Con controllers will be + * in vertical mode when using the HIDAPI driver. + * + * The variable can be set to the following values: + * + * - "0": Left and right Joy-Con controllers will not be in vertical mode. + * (default) + * - "1": Left and right Joy-Con controllers will be in vertical mode. + * + * This hint should be set before opening a Joy-Con controller. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_HIDAPI_VERTICAL_JOY_CONS "SDL_JOYSTICK_HIDAPI_VERTICAL_JOY_CONS" + +/** + * A variable controlling whether the HIDAPI driver for Nintendo Wii and Wii U + * controllers should be used. + * + * The variable can be set to the following values: + * + * - "0": HIDAPI driver is not used. + * - "1": HIDAPI driver is used. + * + * This driver doesn't work with the dolphinbar, so the default is false for + * now. + * + * This hint should be set before initializing joysticks and gamepads. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_HIDAPI_WII "SDL_JOYSTICK_HIDAPI_WII" + +/** + * A variable controlling whether the player LEDs should be lit to indicate + * which player is associated with a Wii controller. + * + * The variable can be set to the following values: + * + * - "0": Player LEDs are not enabled. + * - "1": Player LEDs are enabled. (default) + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_HIDAPI_WII_PLAYER_LED "SDL_JOYSTICK_HIDAPI_WII_PLAYER_LED" + +/** + * A variable controlling whether the HIDAPI driver for XBox controllers + * should be used. + * + * The variable can be set to the following values: + * + * - "0": HIDAPI driver is not used. + * - "1": HIDAPI driver is used. + * + * The default is "0" on Windows, otherwise the value of + * SDL_HINT_JOYSTICK_HIDAPI + * + * This hint should be set before initializing joysticks and gamepads. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_HIDAPI_XBOX "SDL_JOYSTICK_HIDAPI_XBOX" + +/** + * A variable controlling whether the HIDAPI driver for XBox 360 controllers + * should be used. + * + * The variable can be set to the following values: + * + * - "0": HIDAPI driver is not used. + * - "1": HIDAPI driver is used. + * + * The default is the value of SDL_HINT_JOYSTICK_HIDAPI_XBOX + * + * This hint should be set before initializing joysticks and gamepads. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_HIDAPI_XBOX_360 "SDL_JOYSTICK_HIDAPI_XBOX_360" + +/** + * A variable controlling whether the player LEDs should be lit to indicate + * which player is associated with an Xbox 360 controller. + * + * The variable can be set to the following values: + * + * - "0": Player LEDs are not enabled. + * - "1": Player LEDs are enabled. (default) + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_HIDAPI_XBOX_360_PLAYER_LED "SDL_JOYSTICK_HIDAPI_XBOX_360_PLAYER_LED" + +/** + * A variable controlling whether the HIDAPI driver for XBox 360 wireless + * controllers should be used. + * + * The variable can be set to the following values: + * + * - "0": HIDAPI driver is not used. + * - "1": HIDAPI driver is used. + * + * The default is the value of SDL_HINT_JOYSTICK_HIDAPI_XBOX_360 + * + * This hint should be set before initializing joysticks and gamepads. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_HIDAPI_XBOX_360_WIRELESS "SDL_JOYSTICK_HIDAPI_XBOX_360_WIRELESS" + +/** + * A variable controlling whether the HIDAPI driver for XBox One controllers + * should be used. + * + * The variable can be set to the following values: + * + * - "0": HIDAPI driver is not used. + * - "1": HIDAPI driver is used. + * + * The default is the value of SDL_HINT_JOYSTICK_HIDAPI_XBOX. + * + * This hint should be set before initializing joysticks and gamepads. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_HIDAPI_XBOX_ONE "SDL_JOYSTICK_HIDAPI_XBOX_ONE" + +/** + * A variable controlling whether the Home button LED should be turned on when + * an Xbox One controller is opened. + * + * The variable can be set to the following values: + * + * - "0": Home button LED is turned off. + * - "1": Home button LED is turned on. + * + * By default the Home button LED state is not changed. This hint can also be + * set to a floating point value between 0.0 and 1.0 which controls the + * brightness of the Home button LED. The default brightness is 0.4. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_HIDAPI_XBOX_ONE_HOME_LED "SDL_JOYSTICK_HIDAPI_XBOX_ONE_HOME_LED" + +/** + * A variable controlling whether the new HIDAPI driver for wired Xbox One + * (GIP) controllers should be used. + * + * The variable can be set to the following values: + * + * - "0": HIDAPI driver is not used. + * - "1": HIDAPI driver is used. + * + * The default is the value of SDL_HINT_JOYSTICK_HIDAPI_XBOX_ONE. + * + * This hint should be set before initializing joysticks and gamepads. + * + * \since This hint is available since SDL 3.4.0. + */ +#define SDL_HINT_JOYSTICK_HIDAPI_GIP "SDL_JOYSTICK_HIDAPI_GIP" + +/** + * A variable controlling whether the new HIDAPI driver for wired Xbox One + * (GIP) controllers should reset the controller if it can't get the metadata + * from the controller. + * + * The variable can be set to the following values: + * + * - "0": Assume this is a generic controller. + * - "1": Reset the controller to get metadata. + * + * By default the controller is not reset. + * + * This hint should be set before initializing joysticks and gamepads. + * + * \since This hint is available since SDL 3.4.0. + */ +#define SDL_HINT_JOYSTICK_HIDAPI_GIP_RESET_FOR_METADATA "SDL_JOYSTICK_HIDAPI_GIP_RESET_FOR_METADATA" + +/** + * A variable controlling whether IOKit should be used for controller + * handling. + * + * The variable can be set to the following values: + * + * - "0": IOKit is not used. + * - "1": IOKit is used. (default) + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_IOKIT "SDL_JOYSTICK_IOKIT" + +/** + * A variable controlling whether to use the classic /dev/input/js* joystick + * interface or the newer /dev/input/event* joystick interface on Linux. + * + * The variable can be set to the following values: + * + * - "0": Use /dev/input/event* (default) + * - "1": Use /dev/input/js* + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_LINUX_CLASSIC "SDL_JOYSTICK_LINUX_CLASSIC" + +/** + * A variable controlling whether joysticks on Linux adhere to their + * HID-defined deadzones or return unfiltered values. + * + * The variable can be set to the following values: + * + * - "0": Return unfiltered joystick axis values. (default) + * - "1": Return axis values with deadzones taken into account. + * + * This hint should be set before a controller is opened. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_LINUX_DEADZONES "SDL_JOYSTICK_LINUX_DEADZONES" + +/** + * A variable controlling whether joysticks on Linux will always treat 'hat' + * axis inputs (ABS_HAT0X - ABS_HAT3Y) as 8-way digital hats without checking + * whether they may be analog. + * + * The variable can be set to the following values: + * + * - "0": Only map hat axis inputs to digital hat outputs if the input axes + * appear to actually be digital. (default) + * - "1": Always handle the input axes numbered ABS_HAT0X to ABS_HAT3Y as + * digital hats. + * + * This hint should be set before a controller is opened. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_LINUX_DIGITAL_HATS "SDL_JOYSTICK_LINUX_DIGITAL_HATS" + +/** + * A variable controlling whether digital hats on Linux will apply deadzones + * to their underlying input axes or use unfiltered values. + * + * The variable can be set to the following values: + * + * - "0": Return digital hat values based on unfiltered input axis values. + * - "1": Return digital hat values with deadzones on the input axes taken + * into account. (default) + * + * This hint should be set before a controller is opened. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_LINUX_HAT_DEADZONES "SDL_JOYSTICK_LINUX_HAT_DEADZONES" + +/** + * A variable controlling whether GCController should be used for controller + * handling. + * + * The variable can be set to the following values: + * + * - "0": GCController is not used. + * - "1": GCController is used. (default) + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_MFI "SDL_JOYSTICK_MFI" + +/** + * A variable controlling whether the RAWINPUT joystick drivers should be used + * for better handling XInput-capable devices. + * + * The variable can be set to the following values: + * + * - "0": RAWINPUT drivers are not used. (default) + * - "1": RAWINPUT drivers are used. + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_RAWINPUT "SDL_JOYSTICK_RAWINPUT" + +/** + * A variable controlling whether the RAWINPUT driver should pull correlated + * data from XInput. + * + * The variable can be set to the following values: + * + * - "0": RAWINPUT driver will only use data from raw input APIs. + * - "1": RAWINPUT driver will also pull data from XInput and + * Windows.Gaming.Input, providing better trigger axes, guide button + * presses, and rumble support for Xbox controllers. (default) + * + * This hint should be set before a gamepad is opened. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_RAWINPUT_CORRELATE_XINPUT "SDL_JOYSTICK_RAWINPUT_CORRELATE_XINPUT" + +/** + * A variable controlling whether the ROG Chakram mice should show up as + * joysticks. + * + * The variable can be set to the following values: + * + * - "0": ROG Chakram mice do not show up as joysticks. (default) + * - "1": ROG Chakram mice show up as joysticks. + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_ROG_CHAKRAM "SDL_JOYSTICK_ROG_CHAKRAM" + +/** + * A variable controlling whether a separate thread should be used for + * handling joystick detection and raw input messages on Windows. + * + * The variable can be set to the following values: + * + * - "0": A separate thread is not used. + * - "1": A separate thread is used for handling raw input messages. (default) + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_THREAD "SDL_JOYSTICK_THREAD" + +/** + * A variable containing a list of throttle style controllers. + * + * The format of the string is a comma separated list of USB VID/PID pairs in + * hexadecimal form, e.g. + * + * `0xAAAA/0xBBBB,0xCCCC/0xDDDD` + * + * The variable can also take the form of "@file", in which case the named + * file will be loaded and interpreted as the value of the variable. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_THROTTLE_DEVICES "SDL_JOYSTICK_THROTTLE_DEVICES" + +/** + * A variable containing a list of devices that are not throttle style + * controllers. + * + * This will override SDL_HINT_JOYSTICK_THROTTLE_DEVICES and the built in + * device list. + * + * The format of the string is a comma separated list of USB VID/PID pairs in + * hexadecimal form, e.g. + * + * `0xAAAA/0xBBBB,0xCCCC/0xDDDD` + * + * The variable can also take the form of "@file", in which case the named + * file will be loaded and interpreted as the value of the variable. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_THROTTLE_DEVICES_EXCLUDED "SDL_JOYSTICK_THROTTLE_DEVICES_EXCLUDED" + +/** + * A variable controlling whether Windows.Gaming.Input should be used for + * controller handling. + * + * The variable can be set to the following values: + * + * - "0": WGI is not used. (default) + * - "1": WGI is used. + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_WGI "SDL_JOYSTICK_WGI" + +/** + * A variable containing a list of wheel style controllers. + * + * The format of the string is a comma separated list of USB VID/PID pairs in + * hexadecimal form, e.g. + * + * `0xAAAA/0xBBBB,0xCCCC/0xDDDD` + * + * The variable can also take the form of "@file", in which case the named + * file will be loaded and interpreted as the value of the variable. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_WHEEL_DEVICES "SDL_JOYSTICK_WHEEL_DEVICES" + +/** + * A variable containing a list of devices that are not wheel style + * controllers. + * + * This will override SDL_HINT_JOYSTICK_WHEEL_DEVICES and the built in device + * list. + * + * The format of the string is a comma separated list of USB VID/PID pairs in + * hexadecimal form, e.g. + * + * `0xAAAA/0xBBBB,0xCCCC/0xDDDD` + * + * The variable can also take the form of "@file", in which case the named + * file will be loaded and interpreted as the value of the variable. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_WHEEL_DEVICES_EXCLUDED "SDL_JOYSTICK_WHEEL_DEVICES_EXCLUDED" + +/** + * A variable containing a list of devices known to have all axes centered at + * zero. + * + * The format of the string is a comma separated list of USB VID/PID pairs in + * hexadecimal form, e.g. + * + * `0xAAAA/0xBBBB,0xCCCC/0xDDDD` + * + * The variable can also take the form of "@file", in which case the named + * file will be loaded and interpreted as the value of the variable. + * + * This hint should be set before a controller is opened. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_JOYSTICK_ZERO_CENTERED_DEVICES "SDL_JOYSTICK_ZERO_CENTERED_DEVICES" + +/** + * A variable containing a list of devices and their desired number of haptic + * (force feedback) enabled axis. + * + * The format of the string is a comma separated list of USB VID/PID pairs in + * hexadecimal form plus the number of desired axes, e.g. + * + * `0xAAAA/0xBBBB/1,0xCCCC/0xDDDD/3` + * + * This hint supports a "wildcard" device that will set the number of haptic + * axes on all initialized haptic devices which were not defined explicitly in + * this hint. + * + * `0xFFFF/0xFFFF/1` + * + * This hint should be set before a controller is opened. The number of haptic + * axes won't exceed the number of real axes found on the device. + * + * \since This hint is available since SDL 3.2.5. + */ +#define SDL_HINT_JOYSTICK_HAPTIC_AXES "SDL_JOYSTICK_HAPTIC_AXES" + +/** + * A variable that controls keycode representation in keyboard events. + * + * This variable is a comma separated set of options for translating keycodes + * in events: + * + * - "none": Keycode options are cleared, this overrides other options. + * - "hide_numpad": The numpad keysyms will be translated into their + * non-numpad versions based on the current NumLock state. For example, + * SDLK_KP_4 would become SDLK_4 if SDL_KMOD_NUM is set in the event + * modifiers, and SDLK_LEFT if it is unset. + * - "french_numbers": The number row on French keyboards is inverted, so + * pressing the 1 key would yield the keycode SDLK_1, or '1', instead of + * SDLK_AMPERSAND, or '&' + * - "latin_letters": For keyboards using non-Latin letters, such as Russian + * or Thai, the letter keys generate keycodes as though it had an English + * QWERTY layout. e.g. pressing the key associated with SDL_SCANCODE_A on a + * Russian keyboard would yield 'a' instead of a Cyrillic letter. + * + * The default value for this hint is "french_numbers,latin_letters" + * + * Some platforms like Emscripten only provide modified keycodes and the + * options are not used. + * + * These options do not affect the return value of SDL_GetKeyFromScancode() or + * SDL_GetScancodeFromKey(), they just apply to the keycode included in key + * events. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_KEYCODE_OPTIONS "SDL_KEYCODE_OPTIONS" + +/** + * A variable that controls what KMSDRM device to use. + * + * SDL might open something like "/dev/dri/cardNN" to access KMSDRM + * functionality, where "NN" is a device index number. SDL makes a guess at + * the best index to use (usually zero), but the app or user can set this hint + * to a number between 0 and 99 to force selection. + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_KMSDRM_DEVICE_INDEX "SDL_KMSDRM_DEVICE_INDEX" + +/** + * A variable that controls whether SDL requires DRM master access in order to + * initialize the KMSDRM video backend. + * + * The DRM subsystem has a concept of a "DRM master" which is a DRM client + * that has the ability to set planes, set cursor, etc. When SDL is DRM + * master, it can draw to the screen using the SDL rendering APIs. Without DRM + * master, SDL is still able to process input and query attributes of attached + * displays, but it cannot change display state or draw to the screen + * directly. + * + * In some cases, it can be useful to have the KMSDRM backend even if it + * cannot be used for rendering. An app may want to use SDL for input + * processing while using another rendering API (such as an MMAL overlay on + * Raspberry Pi) or using its own code to render to DRM overlays that SDL + * doesn't support. + * + * The variable can be set to the following values: + * + * - "0": SDL will allow usage of the KMSDRM backend without DRM master. + * - "1": SDL Will require DRM master to use the KMSDRM backend. (default) + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_KMSDRM_REQUIRE_DRM_MASTER "SDL_KMSDRM_REQUIRE_DRM_MASTER" + +/** + * A variable that controls whether KMSDRM will use "atomic" functionality. + * + * The KMSDRM backend can use atomic commits, if both DRM_CLIENT_CAP_ATOMIC + * and DRM_CLIENT_CAP_UNIVERSAL_PLANES is supported by the system. As of SDL + * 3.4.0, it will favor this functionality, but in case this doesn't work well + * on a given system or other surprises, this hint can be used to disable it. + * + * This hint can not enable the functionality if it isn't available. + * + * The variable can be set to the following values: + * + * - "0": SDL will not use the KMSDRM "atomic" functionality. + * - "1": SDL will allow usage of the KMSDRM "atomic" functionality. (default) + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.4.0. + */ +#define SDL_HINT_KMSDRM_ATOMIC "SDL_KMSDRM_ATOMIC" + +/** + * A variable controlling the default SDL log levels. + * + * This variable is a comma separated set of category=level tokens that define + * the default logging levels for SDL applications. + * + * The category can be a numeric category, one of "app", "error", "assert", + * "system", "audio", "video", "render", "input", "test", or `*` for any + * unspecified category. + * + * The level can be a numeric level, one of "verbose", "debug", "info", + * "warn", "error", "critical", or "quiet" to disable that category. + * + * You can omit the category if you want to set the logging level for all + * categories. + * + * If this hint isn't set, the default log levels are equivalent to: + * + * `app=info,assert=warn,test=verbose,*=error` + * + * If the `DEBUG_INVOCATION` environment variable is set to "1", the default + * log levels are equivalent to: + * + * `assert=warn,test=verbose,*=debug` + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_LOGGING "SDL_LOGGING" + +/** + * A variable controlling whether to force the application to become the + * foreground process when launched on macOS. + * + * The variable can be set to the following values: + * + * - "0": The application is brought to the foreground when launched. + * (default) + * - "1": The application may remain in the background when launched. + * + * This hint needs to be set before SDL_Init(). + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_MAC_BACKGROUND_APP "SDL_MAC_BACKGROUND_APP" + +/** + * A variable that determines whether Ctrl+Click should generate a right-click + * event on macOS. + * + * The variable can be set to the following values: + * + * - "0": Ctrl+Click does not generate a right mouse button click event. + * (default) + * - "1": Ctrl+Click generated a right mouse button click event. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK "SDL_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK" + +/** + * A variable controlling whether dispatching OpenGL context updates should + * block the dispatching thread until the main thread finishes processing on + * macOS. + * + * The variable can be set to the following values: + * + * - "0": Dispatching OpenGL context updates will block the dispatching thread + * until the main thread finishes processing. (default) + * - "1": Dispatching OpenGL context updates will allow the dispatching thread + * to continue execution. + * + * Generally you want the default, but if you have OpenGL code in a background + * thread on a Mac, and the main thread hangs because it's waiting for that + * background thread, but that background thread is also hanging because it's + * waiting for the main thread to do an update, this might fix your issue. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_MAC_OPENGL_ASYNC_DISPATCH "SDL_MAC_OPENGL_ASYNC_DISPATCH" + +/** + * A variable controlling whether the Option key on macOS should be remapped + * to act as the Alt key. + * + * The variable can be set to the following values: + * + * - "none": The Option key is not remapped to Alt. (default) + * - "only_left": Only the left Option key is remapped to Alt. + * - "only_right": Only the right Option key is remapped to Alt. + * - "both": Both Option keys are remapped to Alt. + * + * This will prevent the triggering of key compositions that rely on the + * Option key, but will still send the Alt modifier for keyboard events. In + * the case that both Alt and Option are pressed, the Option key will be + * ignored. This is particularly useful for applications like terminal + * emulators and graphical user interfaces (GUIs) that rely on Alt key + * functionality for shortcuts or navigation. This does not apply to + * SDL_GetKeyFromScancode and only has an effect if IME is enabled. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_MAC_OPTION_AS_ALT "SDL_MAC_OPTION_AS_ALT" + +/** + * A variable controlling whether SDL_EVENT_MOUSE_WHEEL event values will have + * momentum on macOS. + * + * The variable can be set to the following values: + * + * - "0": The mouse wheel events will have no momentum. (default) + * - "1": The mouse wheel events will have momentum. + * + * This hint needs to be set before SDL_Init(). + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_MAC_SCROLL_MOMENTUM "SDL_MAC_SCROLL_MOMENTUM" + +/** + * A variable controlling whether holding down a key will repeat the pressed + * key or open the accents menu on macOS. + * + * The variable can be set to the following values: + * + * - "0": Holding a key will open the accents menu for that key. + * - "1": Holding a key will repeat the pressed key. (default) + * + * This hint needs to be set before SDL_Init(). + * + * \since This hint is available since SDL 3.4.0. + */ +#define SDL_HINT_MAC_PRESS_AND_HOLD "SDL_MAC_PRESS_AND_HOLD" + +/** + * Request SDL_AppIterate() be called at a specific rate. + * + * If this is set to a number, it represents Hz, so "60" means try to iterate + * 60 times per second. "0" means to iterate as fast as possible. Negative + * values are illegal, but reserved, in case they are useful in a future + * revision of SDL. + * + * There are other strings that have special meaning. If set to "waitevent", + * SDL_AppIterate will not be called until new event(s) have arrived (and been + * processed by SDL_AppEvent). This can be useful for apps that are completely + * idle except in response to input. + * + * On some platforms, or if you are using SDL_main instead of SDL_AppIterate, + * this hint is ignored. When the hint can be used, it is allowed to be + * changed at any time. + * + * This defaults to 0, and specifying NULL for the hint's value will restore + * the default. + * + * This doesn't have to be an integer value. For example, "59.94" won't be + * rounded to an integer rate; the digits after the decimal are actually + * respected. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_MAIN_CALLBACK_RATE "SDL_MAIN_CALLBACK_RATE" + +/** + * A variable controlling whether the mouse is captured while mouse buttons + * are pressed. + * + * The variable can be set to the following values: + * + * - "0": The mouse is not captured while mouse buttons are pressed. + * - "1": The mouse is captured while mouse buttons are pressed. + * + * By default the mouse is captured while mouse buttons are pressed so if the + * mouse is dragged outside the window, the application continues to receive + * mouse events until the button is released. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_MOUSE_AUTO_CAPTURE "SDL_MOUSE_AUTO_CAPTURE" + +/** + * A variable setting the double click radius, in pixels. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_MOUSE_DOUBLE_CLICK_RADIUS "SDL_MOUSE_DOUBLE_CLICK_RADIUS" + +/** + * A variable setting the double click time, in milliseconds. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_MOUSE_DOUBLE_CLICK_TIME "SDL_MOUSE_DOUBLE_CLICK_TIME" + +/** + * A variable setting which system cursor to use as the default cursor. + * + * This should be an integer corresponding to the SDL_SystemCursor enum. The + * default value is zero (SDL_SYSTEM_CURSOR_DEFAULT). + * + * This hint needs to be set before SDL_Init(). + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_MOUSE_DEFAULT_SYSTEM_CURSOR "SDL_MOUSE_DEFAULT_SYSTEM_CURSOR" + +/** + * A variable setting whether we should scale cursors by the current display + * scale. + * + * The variable can be set to the following values: + * + * - "0": Cursors will not change size based on the display content scale. + * (default) + * - "1": Cursors will automatically match the display content scale (e.g. a + * 2x sized cursor will be used when the window is on a monitor with 200% + * scale). This is currently implemented on Windows and Wayland. + * + * This hint needs to be set before creating cursors. + * + * \since This hint is available since SDL 3.4.0. + */ +#define SDL_HINT_MOUSE_DPI_SCALE_CURSORS "SDL_MOUSE_DPI_SCALE_CURSORS" + +/** + * A variable controlling whether warping a hidden mouse cursor will activate + * relative mouse mode. + * + * When this hint is set, the mouse cursor is hidden, and multiple warps to + * the window center occur within a short time period, SDL will emulate mouse + * warps using relative mouse mode. This can provide smoother and more + * reliable mouse motion for some older games, which continuously calculate + * the distance traveled by the mouse pointer and warp it back to the center + * of the window, rather than using relative mouse motion. + * + * Note that relative mouse mode may have different mouse acceleration + * behavior than pointer warps. + * + * If your application needs to repeatedly warp the hidden mouse cursor at a + * high-frequency for other purposes, it should disable this hint. + * + * The variable can be set to the following values: + * + * - "0": Attempts to warp the mouse will always be made. + * - "1": Some mouse warps will be emulated by forcing relative mouse mode. + * (default) + * + * If not set, this is automatically enabled unless an application uses + * relative mouse mode directly. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_MOUSE_EMULATE_WARP_WITH_RELATIVE "SDL_MOUSE_EMULATE_WARP_WITH_RELATIVE" + +/** + * Allow mouse click events when clicking to focus an SDL window. + * + * The variable can be set to the following values: + * + * - "0": Ignore mouse clicks that activate a window. (default) + * - "1": Generate events for mouse clicks that activate a window. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH "SDL_MOUSE_FOCUS_CLICKTHROUGH" + +/** + * A variable setting the speed scale for mouse motion, in floating point, + * when the mouse is not in relative mode. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_MOUSE_NORMAL_SPEED_SCALE "SDL_MOUSE_NORMAL_SPEED_SCALE" + +/** + * A variable controlling whether relative mouse mode constrains the mouse to + * the center of the window. + * + * Constraining to the center of the window works better for FPS games and + * when the application is running over RDP. Constraining to the whole window + * works better for 2D games and increases the chance that the mouse will be + * in the correct position when using high DPI mice. + * + * The variable can be set to the following values: + * + * - "0": Relative mouse mode constrains the mouse to the window. + * - "1": Relative mouse mode constrains the mouse to the center of the + * window. (default) + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_MOUSE_RELATIVE_MODE_CENTER "SDL_MOUSE_RELATIVE_MODE_CENTER" + +/** + * A variable setting the scale for mouse motion, in floating point, when the + * mouse is in relative mode. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_MOUSE_RELATIVE_SPEED_SCALE "SDL_MOUSE_RELATIVE_SPEED_SCALE" + +/** + * A variable controlling whether the system mouse acceleration curve is used + * for relative mouse motion. + * + * The variable can be set to the following values: + * + * - "0": Relative mouse motion will be unscaled. (default) + * - "1": Relative mouse motion will be scaled using the system mouse + * acceleration curve. + * + * If SDL_HINT_MOUSE_RELATIVE_SPEED_SCALE is set, that will be applied after + * system speed scale. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_MOUSE_RELATIVE_SYSTEM_SCALE "SDL_MOUSE_RELATIVE_SYSTEM_SCALE" + +/** + * A variable controlling whether a motion event should be generated for mouse + * warping in relative mode. + * + * The variable can be set to the following values: + * + * - "0": Warping the mouse will not generate a motion event in relative mode + * - "1": Warping the mouse will generate a motion event in relative mode + * + * By default warping the mouse will not generate motion events in relative + * mode. This avoids the application having to filter out large relative + * motion due to warping. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_MOUSE_RELATIVE_WARP_MOTION "SDL_MOUSE_RELATIVE_WARP_MOTION" + +/** + * A variable controlling whether the hardware cursor stays visible when + * relative mode is active. + * + * This variable can be set to the following values: + * + * - "0": The cursor will be hidden while relative mode is active (default) + * - "1": The cursor will remain visible while relative mode is active + * + * Note that for systems without raw hardware inputs, relative mode is + * implemented using warping, so the hardware cursor will visibly warp between + * frames if this is enabled on those systems. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_MOUSE_RELATIVE_CURSOR_VISIBLE "SDL_MOUSE_RELATIVE_CURSOR_VISIBLE" + +/** + * A variable controlling whether mouse events should generate synthetic touch + * events. + * + * The variable can be set to the following values: + * + * - "0": Mouse events will not generate touch events. (default for desktop + * platforms) + * - "1": Mouse events will generate touch events. (default for mobile + * platforms, such as Android and iOS) + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_MOUSE_TOUCH_EVENTS "SDL_MOUSE_TOUCH_EVENTS" + +/** + * A variable controlling whether the keyboard should be muted on the console. + * + * Normally the keyboard is muted while SDL applications are running so that + * keyboard input doesn't show up as key strokes on the console. This hint + * allows you to turn that off for debugging purposes. + * + * The variable can be set to the following values: + * + * - "0": Allow keystrokes to go through to the console. + * - "1": Mute keyboard input so it doesn't show up on the console. (default) + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_MUTE_CONSOLE_KEYBOARD "SDL_MUTE_CONSOLE_KEYBOARD" + +/** + * Tell SDL not to catch the SIGINT or SIGTERM signals on POSIX platforms. + * + * The variable can be set to the following values: + * + * - "0": SDL will install a SIGINT and SIGTERM handler, and when it catches a + * signal, convert it into an SDL_EVENT_QUIT event. (default) + * - "1": SDL will not install a signal handler at all. + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_NO_SIGNAL_HANDLERS "SDL_NO_SIGNAL_HANDLERS" + +/** + * Specify the OpenGL library to load. + * + * This hint should be set before creating an OpenGL window or creating an + * OpenGL context. If this hint isn't set, SDL will choose a reasonable + * default. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_OPENGL_LIBRARY "SDL_OPENGL_LIBRARY" + +/** + * Specify the EGL library to load. + * + * This hint should be set before creating an OpenGL window or creating an + * OpenGL context. This hint is only considered if SDL is using EGL to manage + * OpenGL contexts. If this hint isn't set, SDL will choose a reasonable + * default. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_EGL_LIBRARY "SDL_EGL_LIBRARY" + +/** + * A variable controlling what driver to use for OpenGL ES contexts. + * + * On some platforms, currently Windows and X11, OpenGL drivers may support + * creating contexts with an OpenGL ES profile. By default SDL uses these + * profiles, when available, otherwise it attempts to load an OpenGL ES + * library, e.g. that provided by the ANGLE project. This variable controls + * whether SDL follows this default behaviour or will always load an OpenGL ES + * library. + * + * Circumstances where this is useful include - Testing an app with a + * particular OpenGL ES implementation, e.g ANGLE, or emulator, e.g. those + * from ARM, Imagination or Qualcomm. - Resolving OpenGL ES function addresses + * at link time by linking with the OpenGL ES library instead of querying them + * at run time with SDL_GL_GetProcAddress(). + * + * Caution: for an application to work with the default behaviour across + * different OpenGL drivers it must query the OpenGL ES function addresses at + * run time using SDL_GL_GetProcAddress(). + * + * This variable is ignored on most platforms because OpenGL ES is native or + * not supported. + * + * The variable can be set to the following values: + * + * - "0": Use ES profile of OpenGL, if available. (default) + * - "1": Load OpenGL ES library using the default library names. + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_OPENGL_ES_DRIVER "SDL_OPENGL_ES_DRIVER" + +/** + * Mechanism to specify openvr_api library location + * + * By default, when using the OpenVR driver, it will search for the API + * library in the current folder. But, if you wish to use a system API you can + * specify that by using this hint. This should be the full or relative path + * to a .dll on Windows or .so on Linux. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_OPENVR_LIBRARY "SDL_OPENVR_LIBRARY" + +/** + * A variable controlling which orientations are allowed on iOS/Android. + * + * In some circumstances it is necessary to be able to explicitly control + * which UI orientations are allowed. + * + * This variable is a space delimited list of the following values: + * + * - "LandscapeLeft" + * - "LandscapeRight" + * - "Portrait" + * - "PortraitUpsideDown" + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_ORIENTATIONS "SDL_ORIENTATIONS" + +/** + * A variable controlling the use of a sentinel event when polling the event + * queue. + * + * When polling for events, SDL_PumpEvents is used to gather new events from + * devices. If a device keeps producing new events between calls to + * SDL_PumpEvents, a poll loop will become stuck until the new events stop. + * This is most noticeable when moving a high frequency mouse. + * + * The variable can be set to the following values: + * + * - "0": Disable poll sentinels. + * - "1": Enable poll sentinels. (default) + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_POLL_SENTINEL "SDL_POLL_SENTINEL" + +/** + * Override for SDL_GetPreferredLocales(). + * + * If set, this will be favored over anything the OS might report for the + * user's preferred locales. Changing this hint at runtime will not generate a + * SDL_EVENT_LOCALE_CHANGED event (but if you can change the hint, you can + * push your own event, if you want). + * + * The format of this hint is a comma-separated list of language and locale, + * combined with an underscore, as is a common format: "en_GB". Locale is + * optional: "en". So you might have a list like this: "en_GB,jp,es_PT" + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_PREFERRED_LOCALES "SDL_PREFERRED_LOCALES" + +/** + * A variable that decides whether to send SDL_EVENT_QUIT when closing the + * last window. + * + * The variable can be set to the following values: + * + * - "0": SDL will not send an SDL_EVENT_QUIT event when the last window is + * requesting to close. Note that in this case, there are still other + * legitimate reasons one might get an SDL_EVENT_QUIT event: choosing "Quit" + * from the macOS menu bar, sending a SIGINT (ctrl-c) on Unix, etc. + * - "1": SDL will send a quit event when the last window is requesting to + * close. (default) + * + * If there is at least one active system tray icon, SDL_EVENT_QUIT will + * instead be sent when both the last window will be closed and the last tray + * icon will be destroyed. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_QUIT_ON_LAST_WINDOW_CLOSE "SDL_QUIT_ON_LAST_WINDOW_CLOSE" + +/** + * A variable controlling whether the Direct3D device is initialized for + * thread-safe operations. + * + * The variable can be set to the following values: + * + * - "0": Thread-safety is not enabled. (default) + * - "1": Thread-safety is enabled. + * + * This hint should be set before creating a renderer. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_RENDER_DIRECT3D_THREADSAFE "SDL_RENDER_DIRECT3D_THREADSAFE" + +/** + * A variable controlling whether to enable Direct3D 11+'s Debug Layer. + * + * This variable does not have any effect on the Direct3D 9 based renderer. + * + * The variable can be set to the following values: + * + * - "0": Disable Debug Layer use. (default) + * - "1": Enable Debug Layer use. + * + * This hint should be set before creating a renderer. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_RENDER_DIRECT3D11_DEBUG "SDL_RENDER_DIRECT3D11_DEBUG" + +/** + * A variable controlling whether to use the Direct3D 11 WARP software + * rasterizer. + * + * For more information, see: + * https://learn.microsoft.com/en-us/windows/win32/direct3darticles/directx-warp + * + * The variable can be set to the following values: + * + * - "0": Disable WARP rasterizer. (default) + * - "1": Enable WARP rasterizer. + * + * This hint should be set before creating a renderer. + * + * \since This hint is available since SDL 3.4.0. + */ +#define SDL_HINT_RENDER_DIRECT3D11_WARP "SDL_RENDER_DIRECT3D11_WARP" + +/** + * A variable controlling whether to enable Vulkan Validation Layers. + * + * This variable can be set to the following values: + * + * - "0": Disable Validation Layer use + * - "1": Enable Validation Layer use + * + * By default, SDL does not use Vulkan Validation Layers. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_RENDER_VULKAN_DEBUG "SDL_RENDER_VULKAN_DEBUG" + +/** + * A variable controlling whether to create the GPU device in debug mode. + * + * This variable can be set to the following values: + * + * - "0": Disable debug mode use (default) + * - "1": Enable debug mode use + * + * This hint should be set before creating a renderer. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_RENDER_GPU_DEBUG "SDL_RENDER_GPU_DEBUG" + +/** + * A variable controlling whether to prefer a low-power GPU on multi-GPU + * systems. + * + * This variable can be set to the following values: + * + * - "0": Prefer high-performance GPU (default) + * - "1": Prefer low-power GPU + * + * This hint should be set before creating a renderer. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_RENDER_GPU_LOW_POWER "SDL_RENDER_GPU_LOW_POWER" + +/** + * A variable specifying which render driver to use. + * + * If the application doesn't pick a specific renderer to use, this variable + * specifies the name of the preferred renderer. If the preferred renderer + * can't be initialized, creating a renderer will fail. + * + * This variable is case insensitive and can be set to the following values: + * + * - "direct3d" + * - "direct3d11" + * - "direct3d12" + * - "opengl" + * - "opengles2" + * - "opengles" + * - "metal" + * - "vulkan" + * - "gpu" + * - "software" + * + * This hint accepts a comma-separated list of driver names, and each will be + * tried in the order listed when creating a renderer until one succeeds or + * all of them fail. + * + * The default varies by platform, but it's the first one in the list that is + * available on the current platform. + * + * This hint should be set before creating a renderer. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_RENDER_DRIVER "SDL_RENDER_DRIVER" + +/** + * A variable controlling how the 2D render API renders lines. + * + * The variable can be set to the following values: + * + * - "0": Use the default line drawing method (Bresenham's line algorithm) + * - "1": Use the driver point API using Bresenham's line algorithm (correct, + * draws many points) + * - "2": Use the driver line API (occasionally misses line endpoints based on + * hardware driver quirks + * - "3": Use the driver geometry API (correct, draws thicker diagonal lines) + * + * This hint should be set before creating a renderer. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_RENDER_LINE_METHOD "SDL_RENDER_LINE_METHOD" + +/** + * A variable controlling whether the Metal render driver select low power + * device over default one. + * + * The variable can be set to the following values: + * + * - "0": Use the preferred OS device. (default) + * - "1": Select a low power device. + * + * This hint should be set before creating a renderer. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_RENDER_METAL_PREFER_LOW_POWER_DEVICE "SDL_RENDER_METAL_PREFER_LOW_POWER_DEVICE" + +/** + * A variable controlling whether updates to the SDL screen surface should be + * synchronized with the vertical refresh, to avoid tearing. + * + * This hint overrides the application preference when creating a renderer. + * + * The variable can be set to the following values: + * + * - "0": Disable vsync. (default) + * - "1": Enable vsync. + * + * This hint should be set before creating a renderer. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_RENDER_VSYNC "SDL_RENDER_VSYNC" + +/** + * A variable to control whether the return key on the soft keyboard should + * hide the soft keyboard on Android and iOS. + * + * This hint sets the default value of SDL_PROP_TEXTINPUT_MULTILINE_BOOLEAN. + * + * The variable can be set to the following values: + * + * - "0": The return key will be handled as a key event. (default) + * - "1": The return key will hide the keyboard. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_RETURN_KEY_HIDES_IME "SDL_RETURN_KEY_HIDES_IME" + +/** + * A variable containing a list of ROG gamepad capable mice. + * + * The format of the string is a comma separated list of USB VID/PID pairs in + * hexadecimal form, e.g. + * + * `0xAAAA/0xBBBB,0xCCCC/0xDDDD` + * + * The variable can also take the form of "@file", in which case the named + * file will be loaded and interpreted as the value of the variable. + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + * + * \sa SDL_HINT_ROG_GAMEPAD_MICE_EXCLUDED + */ +#define SDL_HINT_ROG_GAMEPAD_MICE "SDL_ROG_GAMEPAD_MICE" + +/** + * A variable containing a list of devices that are not ROG gamepad capable + * mice. + * + * This will override SDL_HINT_ROG_GAMEPAD_MICE and the built in device list. + * + * The format of the string is a comma separated list of USB VID/PID pairs in + * hexadecimal form, e.g. + * + * `0xAAAA/0xBBBB,0xCCCC/0xDDDD` + * + * The variable can also take the form of "@file", in which case the named + * file will be loaded and interpreted as the value of the variable. + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_ROG_GAMEPAD_MICE_EXCLUDED "SDL_ROG_GAMEPAD_MICE_EXCLUDED" + +/** + * Variable controlling the width of the PS2's framebuffer in pixels + * + * By default, this variable is "640" + */ +#define SDL_HINT_PS2_GS_WIDTH "SDL_PS2_GS_WIDTH" + +/** + * Variable controlling the height of the PS2's framebuffer in pixels + * + * By default, this variable is "448" + */ +#define SDL_HINT_PS2_GS_HEIGHT "SDL_PS2_GS_HEIGHT" + +/** + * Variable controlling whether the signal is interlaced or progressive + * + * - "0": Image is interlaced. (default) + * - "1": Image is progressive + */ +#define SDL_HINT_PS2_GS_PROGRESSIVE "SDL_PS2_GS_PROGRESSIVE" + +/** + * Variable controlling the video mode of the console + * + * - "": Console-native. (default) + * - "NTSC": 60hz region + * - "PAL": 50hz region + */ +#define SDL_HINT_PS2_GS_MODE "SDL_PS2_GS_MODE" + +/** + * A variable controlling which Dispmanx layer to use on a Raspberry PI. + * + * Also known as Z-order. The variable can take a negative or positive value. + * The default is 10000. + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_RPI_VIDEO_LAYER "SDL_RPI_VIDEO_LAYER" + +/** + * Specify an "activity name" for screensaver inhibition. + * + * Some platforms, notably Linux desktops, list the applications which are + * inhibiting the screensaver or other power-saving features. + * + * This hint lets you specify the "activity name" sent to the OS when + * SDL_DisableScreenSaver() is used (or the screensaver is automatically + * disabled). The contents of this hint are used when the screensaver is + * disabled. You should use a string that describes what your program is doing + * (and, therefore, why the screensaver is disabled). For example, "Playing a + * game" or "Watching a video". + * + * Setting this to "" or leaving it unset will have SDL use a reasonable + * default: "Playing a game" or something similar. + * + * This hint should be set before calling SDL_DisableScreenSaver() + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_SCREENSAVER_INHIBIT_ACTIVITY_NAME "SDL_SCREENSAVER_INHIBIT_ACTIVITY_NAME" + +/** + * A variable controlling whether SDL calls dbus_shutdown() on quit. + * + * This is useful as a debug tool to validate memory leaks, but shouldn't ever + * be set in production applications, as other libraries used by the + * application might use dbus under the hood and this can cause crashes if + * they continue after SDL_Quit(). + * + * The variable can be set to the following values: + * + * - "0": SDL will not call dbus_shutdown() on quit. (default) + * - "1": SDL will call dbus_shutdown() on quit. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_SHUTDOWN_DBUS_ON_QUIT "SDL_SHUTDOWN_DBUS_ON_QUIT" + +/** + * A variable that specifies a backend to use for title storage. + * + * By default, SDL will try all available storage backends in a reasonable + * order until it finds one that can work, but this hint allows the app or + * user to force a specific target, such as "pc" if, say, you are on Steam but + * want to avoid SteamRemoteStorage for title data. + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_STORAGE_TITLE_DRIVER "SDL_STORAGE_TITLE_DRIVER" + +/** + * A variable that specifies a backend to use for user storage. + * + * By default, SDL will try all available storage backends in a reasonable + * order until it finds one that can work, but this hint allows the app or + * user to force a specific target, such as "pc" if, say, you are on Steam but + * want to avoid SteamRemoteStorage for user data. + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_STORAGE_USER_DRIVER "SDL_STORAGE_USER_DRIVER" + +/** + * Specifies whether SDL_THREAD_PRIORITY_TIME_CRITICAL should be treated as + * realtime. + * + * On some platforms, like Linux, a realtime priority thread may be subject to + * restrictions that require special handling by the application. This hint + * exists to let SDL know that the app is prepared to handle said + * restrictions. + * + * On Linux, SDL will apply the following configuration to any thread that + * becomes realtime: + * + * - The SCHED_RESET_ON_FORK bit will be set on the scheduling policy, + * - An RLIMIT_RTTIME budget will be configured to the rtkit specified limit. + * - Exceeding this limit will result in the kernel sending SIGKILL to the + * app, refer to the man pages for more information. + * + * The variable can be set to the following values: + * + * - "0": default platform specific behaviour + * - "1": Force SDL_THREAD_PRIORITY_TIME_CRITICAL to a realtime scheduling + * policy + * + * This hint should be set before calling SDL_SetCurrentThreadPriority() + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_THREAD_FORCE_REALTIME_TIME_CRITICAL "SDL_THREAD_FORCE_REALTIME_TIME_CRITICAL" + +/** + * A string specifying additional information to use with + * SDL_SetCurrentThreadPriority. + * + * By default SDL_SetCurrentThreadPriority will make appropriate system + * changes in order to apply a thread priority. For example on systems using + * pthreads the scheduler policy is changed automatically to a policy that + * works well with a given priority. Code which has specific requirements can + * override SDL's default behavior with this hint. + * + * pthread hint values are "current", "other", "fifo" and "rr". Currently no + * other platform hint values are defined but may be in the future. + * + * On Linux, the kernel may send SIGKILL to realtime tasks which exceed the + * distro configured execution budget for rtkit. This budget can be queried + * through RLIMIT_RTTIME after calling SDL_SetCurrentThreadPriority(). + * + * This hint should be set before calling SDL_SetCurrentThreadPriority() + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_THREAD_PRIORITY_POLICY "SDL_THREAD_PRIORITY_POLICY" + +/** + * A variable that controls the timer resolution, in milliseconds. + * + * The higher resolution the timer, the more frequently the CPU services timer + * interrupts, and the more precise delays are, but this takes up power and + * CPU time. This hint is only used on Windows. + * + * See this blog post for more information: + * http://randomascii.wordpress.com/2013/07/08/windows-timer-resolution-megawatts-wasted/ + * + * The default value is "1". + * + * If this variable is set to "0", the system timer resolution is not set. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_TIMER_RESOLUTION "SDL_TIMER_RESOLUTION" + +/** + * A variable controlling whether touch events should generate synthetic mouse + * events. + * + * The variable can be set to the following values: + * + * - "0": Touch events will not generate mouse events. + * - "1": Touch events will generate mouse events. (default) + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_TOUCH_MOUSE_EVENTS "SDL_TOUCH_MOUSE_EVENTS" + +/** + * A variable controlling whether trackpads should be treated as touch + * devices. + * + * On macOS (and possibly other platforms in the future), SDL will report + * touches on a trackpad as mouse input, which is generally what users expect + * from this device; however, these are often actually full multitouch-capable + * touch devices, so it might be preferable to some apps to treat them as + * such. + * + * The variable can be set to the following values: + * + * - "0": Trackpad will send mouse events. (default) + * - "1": Trackpad will send touch events. + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_TRACKPAD_IS_TOUCH_ONLY "SDL_TRACKPAD_IS_TOUCH_ONLY" + +/** + * A variable controlling whether the Android / tvOS remotes should be listed + * as joystick devices, instead of sending keyboard events. + * + * The variable can be set to the following values: + * + * - "0": Remotes send enter/escape/arrow key events. + * - "1": Remotes are available as 2 axis, 2 button joysticks. (default) + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_TV_REMOTE_AS_JOYSTICK "SDL_TV_REMOTE_AS_JOYSTICK" + +/** + * A variable controlling whether the screensaver is enabled. + * + * The variable can be set to the following values: + * + * - "0": Disable screensaver. (default) + * - "1": Enable screensaver. + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_VIDEO_ALLOW_SCREENSAVER "SDL_VIDEO_ALLOW_SCREENSAVER" + +/** + * A comma separated list containing the names of the displays that SDL should + * sort to the front of the display list. + * + * When this hint is set, displays with matching name strings will be + * prioritized in the list of displays, as exposed by calling + * SDL_GetDisplays(), with the first listed becoming the primary display. The + * naming convention can vary depending on the environment, but it is usually + * a connector name (e.g. 'DP-1', 'DP-2', 'HDMI-A-1', etc...). + * + * On Wayland desktops, the connector names associated with displays can be + * found in the `name` property of the info output from `wayland-info -i + * wl_output`. On X11 desktops, the `xrandr` utility can be used to retrieve + * the connector names associated with displays. + * + * This hint is currently supported on the following drivers: + * + * - KMSDRM (kmsdrm) + * - Wayland (wayland) + * - X11 (x11) + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_VIDEO_DISPLAY_PRIORITY "SDL_VIDEO_DISPLAY_PRIORITY" + +/** + * Tell the video driver that we only want a double buffer. + * + * By default, most lowlevel 2D APIs will use a triple buffer scheme that + * wastes no CPU time on waiting for vsync after issuing a flip, but + * introduces a frame of latency. On the other hand, using a double buffer + * scheme instead is recommended for cases where low latency is an important + * factor because we save a whole frame of latency. + * + * We do so by waiting for vsync immediately after issuing a flip, usually + * just after eglSwapBuffers call in the backend's *_SwapWindow function. + * + * This hint is currently supported on the following drivers: + * + * - Raspberry Pi (raspberrypi) + * - Wayland (wayland) + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_VIDEO_DOUBLE_BUFFER "SDL_VIDEO_DOUBLE_BUFFER" + +/** + * A variable that specifies a video backend to use. + * + * By default, SDL will try all available video backends in a reasonable order + * until it finds one that can work, but this hint allows the app or user to + * force a specific target, such as "x11" if, say, you are on Wayland but want + * to try talking to the X server instead. + * + * This hint accepts a comma-separated list of driver names, and each will be + * tried in the order listed during init, until one succeeds or all of them + * fail. + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_VIDEO_DRIVER "SDL_VIDEO_DRIVER" + +/** + * A variable controlling whether the dummy video driver saves output frames. + * + * - "0": Video frames are not saved to disk. (default) + * - "1": Video frames are saved to files in the format "SDL_windowX-Y.bmp", + * where X is the window ID, and Y is the frame number. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_VIDEO_DUMMY_SAVE_FRAMES "SDL_VIDEO_DUMMY_SAVE_FRAMES" + +/** + * If eglGetPlatformDisplay fails, fall back to calling eglGetDisplay. + * + * The variable can be set to one of the following values: + * + * - "0": Do not fall back to eglGetDisplay. + * - "1": Fall back to eglGetDisplay if eglGetPlatformDisplay fails. (default) + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_VIDEO_EGL_ALLOW_GETDISPLAY_FALLBACK "SDL_VIDEO_EGL_ALLOW_GETDISPLAY_FALLBACK" + +/** + * A variable controlling whether the OpenGL context should be created with + * EGL. + * + * The variable can be set to the following values: + * + * - "0": Use platform-specific GL context creation API (GLX, WGL, CGL, etc). + * (default) + * - "1": Use EGL + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_VIDEO_FORCE_EGL "SDL_VIDEO_FORCE_EGL" + +/** + * A variable that specifies the policy for fullscreen Spaces on macOS. + * + * The variable can be set to the following values: + * + * - "0": Disable Spaces support (FULLSCREEN_DESKTOP won't use them and + * SDL_WINDOW_RESIZABLE windows won't offer the "fullscreen" button on their + * titlebars). + * - "1": Enable Spaces support (FULLSCREEN_DESKTOP will use them and + * SDL_WINDOW_RESIZABLE windows will offer the "fullscreen" button on their + * titlebars). (default) + * + * This hint should be set before creating a window. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES "SDL_VIDEO_MAC_FULLSCREEN_SPACES" + +/** + * A variable that specifies the menu visibility when a window is fullscreen + * in Spaces on macOS. + * + * The variable can be set to the following values: + * + * - "0": The menu will be hidden when the window is in a fullscreen space, + * and not accessible by moving the mouse to the top of the screen. + * - "1": The menu will be accessible when the window is in a fullscreen + * space. + * - "auto": The menu will be hidden if fullscreen mode was toggled on + * programmatically via `SDL_SetWindowFullscreen()`, and accessible if + * fullscreen was entered via the "fullscreen" button on the window title + * bar. (default) + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_VIDEO_MAC_FULLSCREEN_MENU_VISIBILITY "SDL_VIDEO_MAC_FULLSCREEN_MENU_VISIBILITY" + +/** + * A variable indicating whether the metal layer drawable size should be + * updated for the SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED event on macOS. + * + * The variable can be set to the following values: + * + * - "0": the metal layer drawable size will not be updated on the + * SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED event. + * - "1": the metal layer drawable size will be updated on the + * SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED event. (default) + * + * This hint should be set before SDL_Metal_CreateView called. + * + * \since This hint is available since SDL 3.4.0. + */ +#define SDL_HINT_VIDEO_METAL_AUTO_RESIZE_DRAWABLE "SDL_VIDEO_METAL_AUTO_RESIZE_DRAWABLE" + +/** + * A variable controlling whether SDL will attempt to automatically set the + * destination display to a mode most closely matching that of the previous + * display if an exclusive fullscreen window is moved onto it. + * + * The variable can be set to the following values: + * + * - "0": SDL will not attempt to automatically set a matching mode on the + * destination display. If an exclusive fullscreen window is moved to a new + * display, the window will become fullscreen desktop. + * - "1": SDL will attempt to automatically set a mode on the destination + * display that most closely matches the mode of the display that the + * exclusive fullscreen window was previously on. (default) + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.4.0. + */ +#define SDL_HINT_VIDEO_MATCH_EXCLUSIVE_MODE_ON_MOVE "SDL_VIDEO_MATCH_EXCLUSIVE_MODE_ON_MOVE" + +/** + * A variable controlling whether fullscreen windows are minimized when they + * lose focus. + * + * The variable can be set to the following values: + * + * - "0": Fullscreen windows will not be minimized when they lose focus. + * - "1": Fullscreen windows are minimized when they lose focus. + * - "auto": Fullscreen windows are minimized when they lose focus if they use + * exclusive fullscreen modes, so the desktop video mode is restored. + * (default) + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS "SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS" + +/** + * A variable controlling whether the offscreen video driver saves output + * frames. + * + * This only saves frames that are generated using software rendering, not + * accelerated OpenGL rendering. + * + * - "0": Video frames are not saved to disk. (default) + * - "1": Video frames are saved to files in the format "SDL_windowX-Y.bmp", + * where X is the window ID, and Y is the frame number. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_VIDEO_OFFSCREEN_SAVE_FRAMES "SDL_VIDEO_OFFSCREEN_SAVE_FRAMES" + +/** + * A variable controlling whether all window operations will block until + * complete. + * + * Window systems that run asynchronously may not have the results of window + * operations that resize or move the window applied immediately upon the + * return of the requesting function. Setting this hint will cause such + * operations to block after every call until the pending operation has + * completed. Setting this to '1' is the equivalent of calling + * SDL_SyncWindow() after every function call. + * + * Be aware that amount of time spent blocking while waiting for window + * operations to complete can be quite lengthy, as animations may have to + * complete, which can take upwards of multiple seconds in some cases. + * + * The variable can be set to the following values: + * + * - "0": Window operations are non-blocking. (default) + * - "1": Window operations will block until completed. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_VIDEO_SYNC_WINDOW_OPERATIONS "SDL_VIDEO_SYNC_WINDOW_OPERATIONS" + +/** + * A variable controlling whether the libdecor Wayland backend is allowed to + * be used. + * + * libdecor is used over xdg-shell when xdg-decoration protocol is + * unavailable. + * + * The variable can be set to the following values: + * + * - "0": libdecor use is disabled. + * - "1": libdecor use is enabled. (default) + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_VIDEO_WAYLAND_ALLOW_LIBDECOR "SDL_VIDEO_WAYLAND_ALLOW_LIBDECOR" + +/** + * A variable controlling whether video mode emulation is enabled under + * Wayland. + * + * When this hint is set, a standard set of emulated CVT video modes will be + * exposed for use by the application. If it is disabled, the only modes + * exposed will be the logical desktop size and, in the case of a scaled + * desktop, the native display resolution. + * + * The variable can be set to the following values: + * + * - "0": Video mode emulation is disabled. + * - "1": Video mode emulation is enabled. (default) + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_VIDEO_WAYLAND_MODE_EMULATION "SDL_VIDEO_WAYLAND_MODE_EMULATION" + +/** + * A variable controlling how modes with a non-native aspect ratio are + * displayed under Wayland. + * + * When this hint is set, the requested scaling will be used when displaying + * fullscreen video modes that don't match the display's native aspect ratio. + * This is contingent on compositor viewport support. + * + * The variable can be set to the following values: + * + * - "aspect" - Video modes will be displayed scaled, in their proper aspect + * ratio, with black bars. + * - "stretch" - Video modes will be scaled to fill the entire display. + * (default) + * - "none" - Video modes will be displayed as 1:1 with no scaling. + * + * This hint should be set before creating a window. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_VIDEO_WAYLAND_MODE_SCALING "SDL_VIDEO_WAYLAND_MODE_SCALING" + +/** + * A variable controlling whether the libdecor Wayland backend is preferred + * over native decorations. + * + * When this hint is set, libdecor will be used to provide window decorations, + * even if xdg-decoration is available. (Note that, by default, libdecor will + * use xdg-decoration itself if available). + * + * The variable can be set to the following values: + * + * - "0": libdecor is enabled only if server-side decorations are unavailable. + * (default) + * - "1": libdecor is always enabled if available. + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_VIDEO_WAYLAND_PREFER_LIBDECOR "SDL_VIDEO_WAYLAND_PREFER_LIBDECOR" + +/** + * A variable forcing non-DPI-aware Wayland windows to output at 1:1 scaling. + * + * This must be set before initializing the video subsystem. + * + * When this hint is set, Wayland windows that are not flagged as being + * DPI-aware will be output with scaling designed to force 1:1 pixel mapping. + * + * This is intended to allow legacy applications to be displayed without + * desktop scaling being applied, and has issues with certain display + * configurations, as this forces the window to behave in a way that Wayland + * desktops were not designed to accommodate: + * + * - Rounding errors can result with odd window sizes and/or desktop scales, + * which can cause the window contents to appear slightly blurry. + * - Positioning the window may be imprecise due to unit conversions and + * rounding. + * - The window may be unusably small on scaled desktops. + * - The window may jump in size when moving between displays of different + * scale factors. + * - Displays may appear to overlap when using a multi-monitor setup with + * scaling enabled. + * - Possible loss of cursor precision due to the logical size of the window + * being reduced. + * + * New applications should be designed with proper DPI awareness handling + * instead of enabling this. + * + * The variable can be set to the following values: + * + * - "0": Windows will be scaled normally. + * - "1": Windows will be forced to scale to achieve 1:1 output. + * + * This hint should be set before creating a window. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_VIDEO_WAYLAND_SCALE_TO_DISPLAY "SDL_VIDEO_WAYLAND_SCALE_TO_DISPLAY" + +/** + * A variable specifying which shader compiler to preload when using the + * Chrome ANGLE binaries. + * + * SDL has EGL and OpenGL ES2 support on Windows via the ANGLE project. It can + * use two different sets of binaries, those compiled by the user from source + * or those provided by the Chrome browser. In the later case, these binaries + * require that SDL loads a DLL providing the shader compiler. + * + * The variable can be set to the following values: + * + * - "d3dcompiler_46.dll" - best for Vista or later. (default) + * - "d3dcompiler_43.dll" - for XP support. + * - "none" - do not load any library, useful if you compiled ANGLE from + * source and included the compiler in your binaries. + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_VIDEO_WIN_D3DCOMPILER "SDL_VIDEO_WIN_D3DCOMPILER" + +/** + * A variable controlling whether SDL should call XSelectInput() to enable + * input events on X11 windows wrapped by SDL windows. + * + * The variable can be set to the following values: + * + * - "0": Don't call XSelectInput(), assuming the native window code has done + * it already. + * - "1": Call XSelectInput() to enable input events. (default) + * + * This hint should be set before creating a window. + * + * \since This hint is available since SDL 3.2.10. + */ +#define SDL_HINT_VIDEO_X11_EXTERNAL_WINDOW_INPUT "SDL_VIDEO_X11_EXTERNAL_WINDOW_INPUT" + +/** + * A variable controlling whether the X11 _NET_WM_BYPASS_COMPOSITOR hint + * should be used. + * + * The variable can be set to the following values: + * + * - "0": Disable _NET_WM_BYPASS_COMPOSITOR. + * - "1": Enable _NET_WM_BYPASS_COMPOSITOR. (default) + * + * This hint should be set before creating a window. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR "SDL_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR" + +/** + * A variable controlling whether the X11 _NET_WM_PING protocol should be + * supported. + * + * By default SDL will use _NET_WM_PING, but for applications that know they + * will not always be able to respond to ping requests in a timely manner they + * can turn it off to avoid the window manager thinking the app is hung. + * + * The variable can be set to the following values: + * + * - "0": Disable _NET_WM_PING. + * - "1": Enable _NET_WM_PING. (default) + * + * This hint should be set before creating a window. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_VIDEO_X11_NET_WM_PING "SDL_VIDEO_X11_NET_WM_PING" + +/** + * A variable controlling whether SDL uses DirectColor visuals. + * + * The variable can be set to the following values: + * + * - "0": Disable DirectColor visuals. + * - "1": Enable DirectColor visuals. (default) + * + * This hint should be set before initializing the video subsystem. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_VIDEO_X11_NODIRECTCOLOR "SDL_VIDEO_X11_NODIRECTCOLOR" + +/** + * A variable forcing the content scaling factor for X11 displays. + * + * The variable can be set to a floating point value in the range 1.0-10.0f + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_VIDEO_X11_SCALING_FACTOR "SDL_VIDEO_X11_SCALING_FACTOR" + +/** + * A variable forcing the visual ID used for X11 display modes. + * + * This hint should be set before initializing the video subsystem. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_VIDEO_X11_VISUALID "SDL_VIDEO_X11_VISUALID" + +/** + * A variable forcing the visual ID chosen for new X11 windows. + * + * This hint should be set before creating a window. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_VIDEO_X11_WINDOW_VISUALID "SDL_VIDEO_X11_WINDOW_VISUALID" + +/** + * A variable controlling whether the X11 XRandR extension should be used. + * + * The variable can be set to the following values: + * + * - "0": Disable XRandR. + * - "1": Enable XRandR. (default) + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_VIDEO_X11_XRANDR "SDL_VIDEO_X11_XRANDR" + +/** + * A variable controlling whether touch should be enabled on the back panel of + * the PlayStation Vita. + * + * The variable can be set to the following values: + * + * - "0": Disable touch on the back panel. + * - "1": Enable touch on the back panel. (default) + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_VITA_ENABLE_BACK_TOUCH "SDL_VITA_ENABLE_BACK_TOUCH" + +/** + * A variable controlling whether touch should be enabled on the front panel + * of the PlayStation Vita. + * + * The variable can be set to the following values: + * + * - "0": Disable touch on the front panel. + * - "1": Enable touch on the front panel. (default) + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_VITA_ENABLE_FRONT_TOUCH "SDL_VITA_ENABLE_FRONT_TOUCH" + +/** + * A variable controlling the module path on the PlayStation Vita. + * + * This hint defaults to "app0:module" + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_VITA_MODULE_PATH "SDL_VITA_MODULE_PATH" + +/** + * A variable controlling whether to perform PVR initialization on the + * PlayStation Vita. + * + * - "0": Skip PVR initialization. + * - "1": Perform the normal PVR initialization. (default) + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_VITA_PVR_INIT "SDL_VITA_PVR_INIT" + +/** + * A variable overriding the resolution reported on the PlayStation Vita. + * + * The variable can be set to the following values: + * + * - "544": 544p (default) + * - "720": 725p for PSTV + * - "1080": 1088i for PSTV + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_VITA_RESOLUTION "SDL_VITA_RESOLUTION" + +/** + * A variable controlling whether OpenGL should be used instead of OpenGL ES + * on the PlayStation Vita. + * + * The variable can be set to the following values: + * + * - "0": Use OpenGL ES. (default) + * - "1": Use OpenGL. + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_VITA_PVR_OPENGL "SDL_VITA_PVR_OPENGL" + +/** + * A variable controlling which touchpad should generate synthetic mouse + * events. + * + * The variable can be set to the following values: + * + * - "0": Only front touchpad should generate mouse events. (default) + * - "1": Only back touchpad should generate mouse events. + * - "2": Both touchpads should generate mouse events. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_VITA_TOUCH_MOUSE_DEVICE "SDL_VITA_TOUCH_MOUSE_DEVICE" + +/** + * A variable overriding the display index used in SDL_Vulkan_CreateSurface() + * + * The display index starts at 0, which is the default. + * + * This hint should be set before calling SDL_Vulkan_CreateSurface() + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_VULKAN_DISPLAY "SDL_VULKAN_DISPLAY" + +/** + * Specify the Vulkan library to load. + * + * This hint should be set before creating a Vulkan window or calling + * SDL_Vulkan_LoadLibrary(). + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_VULKAN_LIBRARY "SDL_VULKAN_LIBRARY" + +/** + * A variable controlling how the fact chunk affects the loading of a WAVE + * file. + * + * The fact chunk stores information about the number of samples of a WAVE + * file. The Standards Update from Microsoft notes that this value can be used + * to 'determine the length of the data in seconds'. This is especially useful + * for compressed formats (for which this is a mandatory chunk) if they + * produce multiple sample frames per block and truncating the block is not + * allowed. The fact chunk can exactly specify how many sample frames there + * should be in this case. + * + * Unfortunately, most application seem to ignore the fact chunk and so SDL + * ignores it by default as well. + * + * The variable can be set to the following values: + * + * - "truncate" - Use the number of samples to truncate the wave data if the + * fact chunk is present and valid. + * - "strict" - Like "truncate", but raise an error if the fact chunk is + * invalid, not present for non-PCM formats, or if the data chunk doesn't + * have that many samples. + * - "ignorezero" - Like "truncate", but ignore fact chunk if the number of + * samples is zero. + * - "ignore" - Ignore fact chunk entirely. (default) + * + * This hint should be set before calling SDL_LoadWAV() or SDL_LoadWAV_IO() + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_WAVE_FACT_CHUNK "SDL_WAVE_FACT_CHUNK" + +/** + * A variable controlling the maximum number of chunks in a WAVE file. + * + * This sets an upper bound on the number of chunks in a WAVE file to avoid + * wasting time on malformed or corrupt WAVE files. This defaults to "10000". + * + * This hint should be set before calling SDL_LoadWAV() or SDL_LoadWAV_IO() + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_WAVE_CHUNK_LIMIT "SDL_WAVE_CHUNK_LIMIT" + +/** + * A variable controlling how the size of the RIFF chunk affects the loading + * of a WAVE file. + * + * The size of the RIFF chunk (which includes all the sub-chunks of the WAVE + * file) is not always reliable. In case the size is wrong, it's possible to + * just ignore it and step through the chunks until a fixed limit is reached. + * + * Note that files that have trailing data unrelated to the WAVE file or + * corrupt files may slow down the loading process without a reliable + * boundary. By default, SDL stops after 10000 chunks to prevent wasting time. + * Use SDL_HINT_WAVE_CHUNK_LIMIT to adjust this value. + * + * The variable can be set to the following values: + * + * - "force" - Always use the RIFF chunk size as a boundary for the chunk + * search. + * - "ignorezero" - Like "force", but a zero size searches up to 4 GiB. + * (default) + * - "ignore" - Ignore the RIFF chunk size and always search up to 4 GiB. + * - "maximum" - Search for chunks until the end of file. (not recommended) + * + * This hint should be set before calling SDL_LoadWAV() or SDL_LoadWAV_IO() + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_WAVE_RIFF_CHUNK_SIZE "SDL_WAVE_RIFF_CHUNK_SIZE" + +/** + * A variable controlling how a truncated WAVE file is handled. + * + * A WAVE file is considered truncated if any of the chunks are incomplete or + * the data chunk size is not a multiple of the block size. By default, SDL + * decodes until the first incomplete block, as most applications seem to do. + * + * The variable can be set to the following values: + * + * - "verystrict" - Raise an error if the file is truncated. + * - "strict" - Like "verystrict", but the size of the RIFF chunk is ignored. + * - "dropframe" - Decode until the first incomplete sample frame. + * - "dropblock" - Decode until the first incomplete block. (default) + * + * This hint should be set before calling SDL_LoadWAV() or SDL_LoadWAV_IO() + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_WAVE_TRUNCATION "SDL_WAVE_TRUNCATION" + +/** + * A variable controlling whether the window is activated when the + * SDL_RaiseWindow function is called. + * + * The variable can be set to the following values: + * + * - "0": The window is not activated when the SDL_RaiseWindow function is + * called. + * - "1": The window is activated when the SDL_RaiseWindow function is called. + * (default) + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_WINDOW_ACTIVATE_WHEN_RAISED "SDL_WINDOW_ACTIVATE_WHEN_RAISED" + +/** + * A variable controlling whether the window is activated when the + * SDL_ShowWindow function is called. + * + * The variable can be set to the following values: + * + * - "0": The window is not activated when the SDL_ShowWindow function is + * called. + * - "1": The window is activated when the SDL_ShowWindow function is called. + * (default) + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_WINDOW_ACTIVATE_WHEN_SHOWN "SDL_WINDOW_ACTIVATE_WHEN_SHOWN" + +/** + * If set to "0" then never set the top-most flag on an SDL Window even if the + * application requests it. + * + * This is a debugging aid for developers and not expected to be used by end + * users. + * + * The variable can be set to the following values: + * + * - "0": don't allow topmost + * - "1": allow topmost (default) + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_WINDOW_ALLOW_TOPMOST "SDL_WINDOW_ALLOW_TOPMOST" + +/** + * A variable controlling whether the window frame and title bar are + * interactive when the cursor is hidden. + * + * The variable can be set to the following values: + * + * - "0": The window frame is not interactive when the cursor is hidden (no + * move, resize, etc). + * - "1": The window frame is interactive when the cursor is hidden. (default) + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN "SDL_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN" + +/** + * A variable controlling whether SDL generates window-close events for Alt+F4 + * on Windows. + * + * The variable can be set to the following values: + * + * - "0": SDL will only do normal key handling for Alt+F4. + * - "1": SDL will generate a window-close event when it sees Alt+F4. + * (default) + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_WINDOWS_CLOSE_ON_ALT_F4 "SDL_WINDOWS_CLOSE_ON_ALT_F4" + +/** + * A variable controlling whether menus can be opened with their keyboard + * shortcut (Alt+mnemonic). + * + * If the mnemonics are enabled, then menus can be opened by pressing the Alt + * key and the corresponding mnemonic (for example, Alt+F opens the File + * menu). However, in case an invalid mnemonic is pressed, Windows makes an + * audible beep to convey that nothing happened. This is true even if the + * window has no menu at all! + * + * Because most SDL applications don't have menus, and some want to use the + * Alt key for other purposes, SDL disables mnemonics (and the beeping) by + * default. + * + * Note: This also affects keyboard events: with mnemonics enabled, when a + * menu is opened from the keyboard, you will not receive a KEYUP event for + * the mnemonic key, and *might* not receive one for Alt. + * + * The variable can be set to the following values: + * + * - "0": Alt+mnemonic does nothing, no beeping. (default) + * - "1": Alt+mnemonic opens menus, invalid mnemonics produce a beep. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_WINDOWS_ENABLE_MENU_MNEMONICS "SDL_WINDOWS_ENABLE_MENU_MNEMONICS" + +/** + * A variable controlling whether the windows message loop is processed by + * SDL. + * + * The variable can be set to the following values: + * + * - "0": The window message loop is not run. + * - "1": The window message loop is processed in SDL_PumpEvents(). (default) + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_WINDOWS_ENABLE_MESSAGELOOP "SDL_WINDOWS_ENABLE_MESSAGELOOP" + +/** + * A variable controlling whether GameInput is used for raw keyboard and mouse + * on Windows. + * + * The variable can be set to the following values: + * + * - "0": GameInput is not used for raw keyboard and mouse events. (default) + * - "1": GameInput is used for raw keyboard and mouse events, if available. + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_WINDOWS_GAMEINPUT "SDL_WINDOWS_GAMEINPUT" + +/** + * A variable controlling whether raw keyboard events are used on Windows. + * + * The variable can be set to the following values: + * + * - "0": The Windows message loop is used for keyboard events. (default) + * - "1": Low latency raw keyboard events are used. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_WINDOWS_RAW_KEYBOARD "SDL_WINDOWS_RAW_KEYBOARD" + +/** + * A variable controlling whether or not the RIDEV_NOHOTKEYS flag is set when + * enabling Windows raw keyboard events. + * + * This blocks any hotkeys that have been registered by applications from + * having any effect beyond generating raw WM_INPUT events. + * + * This flag does not affect system-hotkeys like ALT-TAB or CTRL-ALT-DEL, but + * does affect the Windows Logo key since it is a userland hotkey registered + * by explorer.exe. + * + * The variable can be set to the following values: + * + * - "0": Hotkeys are not excluded. (default) + * - "1": Hotkeys are excluded. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.4.0. + */ +#define SDL_HINT_WINDOWS_RAW_KEYBOARD_EXCLUDE_HOTKEYS "SDL_WINDOWS_RAW_KEYBOARD_EXCLUDE_HOTKEYS" + +/** + * A variable controlling whether SDL uses Kernel Semaphores on Windows. + * + * Kernel Semaphores are inter-process and require a context switch on every + * interaction. On Windows 8 and newer, the WaitOnAddress API is available. + * Using that and atomics to implement semaphores increases performance. SDL + * will fall back to Kernel Objects on older OS versions or if forced to by + * this hint. + * + * The variable can be set to the following values: + * + * - "0": Use Atomics and WaitOnAddress API when available, otherwise fall + * back to Kernel Objects. (default) + * - "1": Force the use of Kernel Objects in all cases. + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_WINDOWS_FORCE_SEMAPHORE_KERNEL "SDL_WINDOWS_FORCE_SEMAPHORE_KERNEL" + +/** + * A variable to specify custom icon resource id from RC file on Windows + * platform. + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_WINDOWS_INTRESOURCE_ICON "SDL_WINDOWS_INTRESOURCE_ICON" + +/** + * A variable to specify custom icon resource id from RC file on Windows + * platform. + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_WINDOWS_INTRESOURCE_ICON_SMALL "SDL_WINDOWS_INTRESOURCE_ICON_SMALL" + +/** + * A variable controlling whether SDL uses the D3D9Ex API introduced in + * Windows Vista, instead of normal D3D9. + * + * Direct3D 9Ex contains changes to state management that can eliminate device + * loss errors during scenarios like Alt+Tab or UAC prompts. D3D9Ex may + * require some changes to your application to cope with the new behavior, so + * this is disabled by default. + * + * For more information on Direct3D 9Ex, see: + * + * - https://docs.microsoft.com/en-us/windows/win32/direct3darticles/graphics-apis-in-windows-vista#direct3d-9ex + * - https://docs.microsoft.com/en-us/windows/win32/direct3darticles/direct3d-9ex-improvements + * + * The variable can be set to the following values: + * + * - "0": Use the original Direct3D 9 API. (default) + * - "1": Use the Direct3D 9Ex API on Vista and later (and fall back if D3D9Ex + * is unavailable) + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_WINDOWS_USE_D3D9EX "SDL_WINDOWS_USE_D3D9EX" + +/** + * A variable controlling whether SDL will clear the window contents when the + * WM_ERASEBKGND message is received. + * + * The variable can be set to the following values: + * + * - "0"/"never": Never clear the window. + * - "1"/"initial": Clear the window when the first WM_ERASEBKGND event fires. + * (default) + * - "2"/"always": Clear the window on every WM_ERASEBKGND event. + * + * This hint should be set before creating a window. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_WINDOWS_ERASE_BACKGROUND_MODE "SDL_WINDOWS_ERASE_BACKGROUND_MODE" + +/** + * A variable controlling whether X11 windows are marked as override-redirect. + * + * If set, this _might_ increase framerate at the expense of the desktop not + * working as expected. Override-redirect windows aren't noticed by the window + * manager at all. + * + * You should probably only use this for fullscreen windows, and you probably + * shouldn't even use it for that. But it's here if you want to try! + * + * The variable can be set to the following values: + * + * - "0": Do not mark the window as override-redirect. (default) + * - "1": Mark the window as override-redirect. + * + * This hint should be set before creating a window. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_X11_FORCE_OVERRIDE_REDIRECT "SDL_X11_FORCE_OVERRIDE_REDIRECT" + +/** + * A variable specifying the type of an X11 window. + * + * During SDL_CreateWindow, SDL uses the _NET_WM_WINDOW_TYPE X11 property to + * report to the window manager the type of window it wants to create. This + * might be set to various things if SDL_WINDOW_TOOLTIP or + * SDL_WINDOW_POPUP_MENU, etc, were specified. For "normal" windows that + * haven't set a specific type, this hint can be used to specify a custom + * type. For example, a dock window might set this to + * "_NET_WM_WINDOW_TYPE_DOCK". + * + * This hint should be set before creating a window. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_X11_WINDOW_TYPE "SDL_X11_WINDOW_TYPE" + +/** + * Specify the XCB library to load for the X11 driver. + * + * The default is platform-specific, often "libX11-xcb.so.1". + * + * This hint should be set before initializing the video subsystem. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_X11_XCB_LIBRARY "SDL_X11_XCB_LIBRARY" + +/** + * A variable controlling whether XInput should be used for controller + * handling. + * + * The variable can be set to the following values: + * + * - "0": XInput is not enabled. + * - "1": XInput is enabled. (default) + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_XINPUT_ENABLED "SDL_XINPUT_ENABLED" + +/** + * A variable controlling response to SDL_assert failures. + * + * The variable can be set to the following case-sensitive values: + * + * - "abort": Program terminates immediately. + * - "break": Program triggers a debugger breakpoint. + * - "retry": Program reruns the SDL_assert's test again. + * - "ignore": Program continues on, ignoring this assertion failure this + * time. + * - "always_ignore": Program continues on, ignoring this assertion failure + * for the rest of the run. + * + * Note that SDL_SetAssertionHandler offers a programmatic means to deal with + * assertion failures through a callback, and this hint is largely intended to + * be used via environment variables by end users and automated tools. + * + * This hint should be set before an assertion failure is triggered and can be + * changed at any time. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_ASSERT "SDL_ASSERT" + +/** + * A variable controlling whether pen events should generate synthetic mouse + * events. + * + * The variable can be set to the following values: + * + * - "0": Pen events will not generate mouse events. + * - "1": Pen events will generate mouse events. (default) + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_PEN_MOUSE_EVENTS "SDL_PEN_MOUSE_EVENTS" + +/** + * A variable controlling whether pen events should generate synthetic touch + * events. + * + * The variable can be set to the following values: + * + * - "0": Pen events will not generate touch events. + * - "1": Pen events will generate touch events. (default) + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_PEN_TOUCH_EVENTS "SDL_PEN_TOUCH_EVENTS" + +/** + * An enumeration of hint priorities. + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_HintPriority +{ + SDL_HINT_DEFAULT, + SDL_HINT_NORMAL, + SDL_HINT_OVERRIDE +} SDL_HintPriority; + +/** + * Set a hint with a specific priority. + * + * The priority controls the behavior when setting a hint that already has a + * value. Hints will replace existing hints of their priority and lower. + * Environment variables are considered to have override priority. + * + * \param name the hint to set. + * \param value the value of the hint variable. + * \param priority the SDL_HintPriority level for the hint. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetHint + * \sa SDL_ResetHint + * \sa SDL_SetHint + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetHintWithPriority(const char *name, const char *value, SDL_HintPriority priority); + +/** + * Set a hint with normal priority. + * + * Hints will not be set if there is an existing override hint or environment + * variable that takes precedence. You can use SDL_SetHintWithPriority() to + * set the hint with override priority instead. + * + * \param name the hint to set. + * \param value the value of the hint variable. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetHint + * \sa SDL_ResetHint + * \sa SDL_SetHintWithPriority + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetHint(const char *name, const char *value); + +/** + * Reset a hint to the default value. + * + * This will reset a hint to the value of the environment variable, or NULL if + * the environment isn't set. Callbacks will be called normally with this + * change. + * + * \param name the hint to set. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetHint + * \sa SDL_ResetHints + */ +extern SDL_DECLSPEC bool SDLCALL SDL_ResetHint(const char *name); + +/** + * Reset all hints to the default values. + * + * This will reset all hints to the value of the associated environment + * variable, or NULL if the environment isn't set. Callbacks will be called + * normally with this change. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_ResetHint + */ +extern SDL_DECLSPEC void SDLCALL SDL_ResetHints(void); + +/** + * Get the value of a hint. + * + * \param name the hint to query. + * \returns the string value of a hint or NULL if the hint isn't set. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetHint + * \sa SDL_SetHintWithPriority + */ +extern SDL_DECLSPEC const char *SDLCALL SDL_GetHint(const char *name); + +/** + * Get the boolean value of a hint variable. + * + * \param name the name of the hint to get the boolean value from. + * \param default_value the value to return if the hint does not exist. + * \returns the boolean value of a hint or the provided default value if the + * hint does not exist. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetHint + * \sa SDL_SetHint + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetHintBoolean(const char *name, bool default_value); + +/** + * A callback used to send notifications of hint value changes. + * + * This is called an initial time during SDL_AddHintCallback with the hint's + * current value, and then again each time the hint's value changes. + * + * \param userdata what was passed as `userdata` to SDL_AddHintCallback(). + * \param name what was passed as `name` to SDL_AddHintCallback(). + * \param oldValue the previous hint value. + * \param newValue the new value hint is to be set to. + * + * \threadsafety This callback is fired from whatever thread is setting a new + * hint value. SDL holds a lock on the hint subsystem when + * calling this callback. + * + * \since This datatype is available since SDL 3.2.0. + * + * \sa SDL_AddHintCallback + */ +typedef void(SDLCALL *SDL_HintCallback)(void *userdata, const char *name, const char *oldValue, const char *newValue); + +/** + * Add a function to watch a particular hint. + * + * The callback function is called _during_ this function, to provide it an + * initial value, and again each time the hint's value changes. + * + * \param name the hint to watch. + * \param callback An SDL_HintCallback function that will be called when the + * hint value changes. + * \param userdata a pointer to pass to the callback function. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_RemoveHintCallback + */ +extern SDL_DECLSPEC bool SDLCALL SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *userdata); + +/** + * Remove a function watching a particular hint. + * + * \param name the hint being watched. + * \param callback an SDL_HintCallback function that will be called when the + * hint value changes. + * \param userdata a pointer being passed to the callback function. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_AddHintCallback + */ +extern SDL_DECLSPEC void SDLCALL SDL_RemoveHintCallback(const char *name, + SDL_HintCallback callback, + void *userdata); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_hints_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_init.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_init.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,497 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * # CategoryInit + * + * All SDL programs need to initialize the library before starting to work + * with it. + * + * Almost everything can simply call SDL_Init() near startup, with a handful + * of flags to specify subsystems to touch. These are here to make sure SDL + * does not even attempt to touch low-level pieces of the operating system + * that you don't intend to use. For example, you might be using SDL for video + * and input but chose an external library for audio, and in this case you + * would just need to leave off the `SDL_INIT_AUDIO` flag to make sure that + * external library has complete control. + * + * Most apps, when terminating, should call SDL_Quit(). This will clean up + * (nearly) everything that SDL might have allocated, and crucially, it'll + * make sure that the display's resolution is back to what the user expects if + * you had previously changed it for your game. + * + * SDL3 apps are strongly encouraged to call SDL_SetAppMetadata() at startup + * to fill in details about the program. This is completely optional, but it + * helps in small ways (we can provide an About dialog box for the macOS menu, + * we can name the app in the system's audio mixer, etc). Those that want to + * provide a _lot_ of information should look at the more-detailed + * SDL_SetAppMetadataProperty(). + */ + +#ifndef SDL_init_h_ +#define SDL_init_h_ + +#include +#include +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* As of version 0.5, SDL is loaded dynamically into the application */ + +/** + * Initialization flags for SDL_Init and/or SDL_InitSubSystem + * + * These are the flags which may be passed to SDL_Init(). You should specify + * the subsystems which you will be using in your application. + * + * \since This datatype is available since SDL 3.2.0. + * + * \sa SDL_Init + * \sa SDL_Quit + * \sa SDL_InitSubSystem + * \sa SDL_QuitSubSystem + * \sa SDL_WasInit + */ +typedef Uint32 SDL_InitFlags; + +#define SDL_INIT_AUDIO 0x00000010u /**< `SDL_INIT_AUDIO` implies `SDL_INIT_EVENTS` */ +#define SDL_INIT_VIDEO 0x00000020u /**< `SDL_INIT_VIDEO` implies `SDL_INIT_EVENTS`, should be initialized on the main thread */ +#define SDL_INIT_JOYSTICK 0x00000200u /**< `SDL_INIT_JOYSTICK` implies `SDL_INIT_EVENTS` */ +#define SDL_INIT_HAPTIC 0x00001000u +#define SDL_INIT_GAMEPAD 0x00002000u /**< `SDL_INIT_GAMEPAD` implies `SDL_INIT_JOYSTICK` */ +#define SDL_INIT_EVENTS 0x00004000u +#define SDL_INIT_SENSOR 0x00008000u /**< `SDL_INIT_SENSOR` implies `SDL_INIT_EVENTS` */ +#define SDL_INIT_CAMERA 0x00010000u /**< `SDL_INIT_CAMERA` implies `SDL_INIT_EVENTS` */ + +/** + * Return values for optional main callbacks. + * + * Returning SDL_APP_SUCCESS or SDL_APP_FAILURE from SDL_AppInit, + * SDL_AppEvent, or SDL_AppIterate will terminate the program and report + * success/failure to the operating system. What that means is + * platform-dependent. On Unix, for example, on success, the process error + * code will be zero, and on failure it will be 1. This interface doesn't + * allow you to return specific exit codes, just whether there was an error + * generally or not. + * + * Returning SDL_APP_CONTINUE from these functions will let the app continue + * to run. + * + * See + * [Main callbacks in SDL3](https://wiki.libsdl.org/SDL3/README-main-functions#main-callbacks-in-sdl3) + * for complete details. + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_AppResult +{ + SDL_APP_CONTINUE, /**< Value that requests that the app continue from the main callbacks. */ + SDL_APP_SUCCESS, /**< Value that requests termination with success from the main callbacks. */ + SDL_APP_FAILURE /**< Value that requests termination with error from the main callbacks. */ +} SDL_AppResult; + +/** + * Function pointer typedef for SDL_AppInit. + * + * These are used by SDL_EnterAppMainCallbacks. This mechanism operates behind + * the scenes for apps using the optional main callbacks. Apps that want to + * use this should just implement SDL_AppInit directly. + * + * \param appstate a place where the app can optionally store a pointer for + * future use. + * \param argc the standard ANSI C main's argc; number of elements in `argv`. + * \param argv the standard ANSI C main's argv; array of command line + * arguments. + * \returns SDL_APP_FAILURE to terminate with an error, SDL_APP_SUCCESS to + * terminate with success, SDL_APP_CONTINUE to continue. + * + * \since This datatype is available since SDL 3.2.0. + */ +typedef SDL_AppResult (SDLCALL *SDL_AppInit_func)(void **appstate, int argc, char *argv[]); + +/** + * Function pointer typedef for SDL_AppIterate. + * + * These are used by SDL_EnterAppMainCallbacks. This mechanism operates behind + * the scenes for apps using the optional main callbacks. Apps that want to + * use this should just implement SDL_AppIterate directly. + * + * \param appstate an optional pointer, provided by the app in SDL_AppInit. + * \returns SDL_APP_FAILURE to terminate with an error, SDL_APP_SUCCESS to + * terminate with success, SDL_APP_CONTINUE to continue. + * + * \since This datatype is available since SDL 3.2.0. + */ +typedef SDL_AppResult (SDLCALL *SDL_AppIterate_func)(void *appstate); + +/** + * Function pointer typedef for SDL_AppEvent. + * + * These are used by SDL_EnterAppMainCallbacks. This mechanism operates behind + * the scenes for apps using the optional main callbacks. Apps that want to + * use this should just implement SDL_AppEvent directly. + * + * \param appstate an optional pointer, provided by the app in SDL_AppInit. + * \param event the new event for the app to examine. + * \returns SDL_APP_FAILURE to terminate with an error, SDL_APP_SUCCESS to + * terminate with success, SDL_APP_CONTINUE to continue. + * + * \since This datatype is available since SDL 3.2.0. + */ +typedef SDL_AppResult (SDLCALL *SDL_AppEvent_func)(void *appstate, SDL_Event *event); + +/** + * Function pointer typedef for SDL_AppQuit. + * + * These are used by SDL_EnterAppMainCallbacks. This mechanism operates behind + * the scenes for apps using the optional main callbacks. Apps that want to + * use this should just implement SDL_AppEvent directly. + * + * \param appstate an optional pointer, provided by the app in SDL_AppInit. + * \param result the result code that terminated the app (success or failure). + * + * \since This datatype is available since SDL 3.2.0. + */ +typedef void (SDLCALL *SDL_AppQuit_func)(void *appstate, SDL_AppResult result); + + +/** + * Initialize the SDL library. + * + * SDL_Init() simply forwards to calling SDL_InitSubSystem(). Therefore, the + * two may be used interchangeably. Though for readability of your code + * SDL_InitSubSystem() might be preferred. + * + * The file I/O (for example: SDL_IOFromFile) and threading (SDL_CreateThread) + * subsystems are initialized by default. Message boxes + * (SDL_ShowSimpleMessageBox) also attempt to work without initializing the + * video subsystem, in hopes of being useful in showing an error dialog when + * SDL_Init fails. You must specifically initialize other subsystems if you + * use them in your application. + * + * Logging (such as SDL_Log) works without initialization, too. + * + * `flags` may be any of the following OR'd together: + * + * - `SDL_INIT_AUDIO`: audio subsystem; automatically initializes the events + * subsystem + * - `SDL_INIT_VIDEO`: video subsystem; automatically initializes the events + * subsystem, should be initialized on the main thread. + * - `SDL_INIT_JOYSTICK`: joystick subsystem; automatically initializes the + * events subsystem + * - `SDL_INIT_HAPTIC`: haptic (force feedback) subsystem + * - `SDL_INIT_GAMEPAD`: gamepad subsystem; automatically initializes the + * joystick subsystem + * - `SDL_INIT_EVENTS`: events subsystem + * - `SDL_INIT_SENSOR`: sensor subsystem; automatically initializes the events + * subsystem + * - `SDL_INIT_CAMERA`: camera subsystem; automatically initializes the events + * subsystem + * + * Subsystem initialization is ref-counted, you must call SDL_QuitSubSystem() + * for each SDL_InitSubSystem() to correctly shutdown a subsystem manually (or + * call SDL_Quit() to force shutdown). If a subsystem is already loaded then + * this call will increase the ref-count and return. + * + * Consider reporting some basic metadata about your application before + * calling SDL_Init, using either SDL_SetAppMetadata() or + * SDL_SetAppMetadataProperty(). + * + * \param flags subsystem initialization flags. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetAppMetadata + * \sa SDL_SetAppMetadataProperty + * \sa SDL_InitSubSystem + * \sa SDL_Quit + * \sa SDL_SetMainReady + * \sa SDL_WasInit + */ +extern SDL_DECLSPEC bool SDLCALL SDL_Init(SDL_InitFlags flags); + +/** + * Compatibility function to initialize the SDL library. + * + * This function and SDL_Init() are interchangeable. + * + * \param flags any of the flags used by SDL_Init(); see SDL_Init for details. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_Init + * \sa SDL_Quit + * \sa SDL_QuitSubSystem + */ +extern SDL_DECLSPEC bool SDLCALL SDL_InitSubSystem(SDL_InitFlags flags); + +/** + * Shut down specific SDL subsystems. + * + * You still need to call SDL_Quit() even if you close all open subsystems + * with SDL_QuitSubSystem(). + * + * \param flags any of the flags used by SDL_Init(); see SDL_Init for details. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_InitSubSystem + * \sa SDL_Quit + */ +extern SDL_DECLSPEC void SDLCALL SDL_QuitSubSystem(SDL_InitFlags flags); + +/** + * Get a mask of the specified subsystems which are currently initialized. + * + * \param flags any of the flags used by SDL_Init(); see SDL_Init for details. + * \returns a mask of all initialized subsystems if `flags` is 0, otherwise it + * returns the initialization status of the specified subsystems. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_Init + * \sa SDL_InitSubSystem + */ +extern SDL_DECLSPEC SDL_InitFlags SDLCALL SDL_WasInit(SDL_InitFlags flags); + +/** + * Clean up all initialized subsystems. + * + * You should call this function even if you have already shutdown each + * initialized subsystem with SDL_QuitSubSystem(). It is safe to call this + * function even in the case of errors in initialization. + * + * You can use this function with atexit() to ensure that it is run when your + * application is shutdown, but it is not wise to do this from a library or + * other dynamically loaded code. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_Init + * \sa SDL_QuitSubSystem + */ +extern SDL_DECLSPEC void SDLCALL SDL_Quit(void); + +/** + * Return whether this is the main thread. + * + * On Apple platforms, the main thread is the thread that runs your program's + * main() entry point. On other platforms, the main thread is the one that + * calls SDL_Init(SDL_INIT_VIDEO), which should usually be the one that runs + * your program's main() entry point. If you are using the main callbacks, + * SDL_AppInit(), SDL_AppIterate(), and SDL_AppQuit() are all called on the + * main thread. + * + * \returns true if this thread is the main thread, or false otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_RunOnMainThread + */ +extern SDL_DECLSPEC bool SDLCALL SDL_IsMainThread(void); + +/** + * Callback run on the main thread. + * + * \param userdata an app-controlled pointer that is passed to the callback. + * + * \since This datatype is available since SDL 3.2.0. + * + * \sa SDL_RunOnMainThread + */ +typedef void (SDLCALL *SDL_MainThreadCallback)(void *userdata); + +/** + * Call a function on the main thread during event processing. + * + * If this is called on the main thread, the callback is executed immediately. + * If this is called on another thread, this callback is queued for execution + * on the main thread during event processing. + * + * Be careful of deadlocks when using this functionality. You should not have + * the main thread wait for the current thread while this function is being + * called with `wait_complete` true. + * + * \param callback the callback to call on the main thread. + * \param userdata a pointer that is passed to `callback`. + * \param wait_complete true to wait for the callback to complete, false to + * return immediately. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_IsMainThread + */ +extern SDL_DECLSPEC bool SDLCALL SDL_RunOnMainThread(SDL_MainThreadCallback callback, void *userdata, bool wait_complete); + +/** + * Specify basic metadata about your app. + * + * You can optionally provide metadata about your app to SDL. This is not + * required, but strongly encouraged. + * + * There are several locations where SDL can make use of metadata (an "About" + * box in the macOS menu bar, the name of the app can be shown on some audio + * mixers, etc). Any piece of metadata can be left as NULL, if a specific + * detail doesn't make sense for the app. + * + * This function should be called as early as possible, before SDL_Init. + * Multiple calls to this function are allowed, but various state might not + * change once it has been set up with a previous call to this function. + * + * Passing a NULL removes any previous metadata. + * + * This is a simplified interface for the most important information. You can + * supply significantly more detailed metadata with + * SDL_SetAppMetadataProperty(). + * + * \param appname The name of the application ("My Game 2: Bad Guy's + * Revenge!"). + * \param appversion The version of the application ("1.0.0beta5" or a git + * hash, or whatever makes sense). + * \param appidentifier A unique string in reverse-domain format that + * identifies this app ("com.example.mygame2"). + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetAppMetadataProperty + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetAppMetadata(const char *appname, const char *appversion, const char *appidentifier); + +/** + * Specify metadata about your app through a set of properties. + * + * You can optionally provide metadata about your app to SDL. This is not + * required, but strongly encouraged. + * + * There are several locations where SDL can make use of metadata (an "About" + * box in the macOS menu bar, the name of the app can be shown on some audio + * mixers, etc). Any piece of metadata can be left out, if a specific detail + * doesn't make sense for the app. + * + * This function should be called as early as possible, before SDL_Init. + * Multiple calls to this function are allowed, but various state might not + * change once it has been set up with a previous call to this function. + * + * Once set, this metadata can be read using SDL_GetAppMetadataProperty(). + * + * These are the supported properties: + * + * - `SDL_PROP_APP_METADATA_NAME_STRING`: The human-readable name of the + * application, like "My Game 2: Bad Guy's Revenge!". This will show up + * anywhere the OS shows the name of the application separately from window + * titles, such as volume control applets, etc. This defaults to "SDL + * Application". + * - `SDL_PROP_APP_METADATA_VERSION_STRING`: The version of the app that is + * running; there are no rules on format, so "1.0.3beta2" and "April 22nd, + * 2024" and a git hash are all valid options. This has no default. + * - `SDL_PROP_APP_METADATA_IDENTIFIER_STRING`: A unique string that + * identifies this app. This must be in reverse-domain format, like + * "com.example.mygame2". This string is used by desktop compositors to + * identify and group windows together, as well as match applications with + * associated desktop settings and icons. If you plan to package your + * application in a container such as Flatpak, the app ID should match the + * name of your Flatpak container as well. This has no default. + * - `SDL_PROP_APP_METADATA_CREATOR_STRING`: The human-readable name of the + * creator/developer/maker of this app, like "MojoWorkshop, LLC" + * - `SDL_PROP_APP_METADATA_COPYRIGHT_STRING`: The human-readable copyright + * notice, like "Copyright (c) 2024 MojoWorkshop, LLC" or whatnot. Keep this + * to one line, don't paste a copy of a whole software license in here. This + * has no default. + * - `SDL_PROP_APP_METADATA_URL_STRING`: A URL to the app on the web. Maybe a + * product page, or a storefront, or even a GitHub repository, for user's + * further information This has no default. + * - `SDL_PROP_APP_METADATA_TYPE_STRING`: The type of application this is. + * Currently this string can be "game" for a video game, "mediaplayer" for a + * media player, or generically "application" if nothing else applies. + * Future versions of SDL might add new types. This defaults to + * "application". + * + * \param name the name of the metadata property to set. + * \param value the value of the property, or NULL to remove that property. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetAppMetadataProperty + * \sa SDL_SetAppMetadata + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetAppMetadataProperty(const char *name, const char *value); + +#define SDL_PROP_APP_METADATA_NAME_STRING "SDL.app.metadata.name" +#define SDL_PROP_APP_METADATA_VERSION_STRING "SDL.app.metadata.version" +#define SDL_PROP_APP_METADATA_IDENTIFIER_STRING "SDL.app.metadata.identifier" +#define SDL_PROP_APP_METADATA_CREATOR_STRING "SDL.app.metadata.creator" +#define SDL_PROP_APP_METADATA_COPYRIGHT_STRING "SDL.app.metadata.copyright" +#define SDL_PROP_APP_METADATA_URL_STRING "SDL.app.metadata.url" +#define SDL_PROP_APP_METADATA_TYPE_STRING "SDL.app.metadata.type" + +/** + * Get metadata about your app. + * + * This returns metadata previously set using SDL_SetAppMetadata() or + * SDL_SetAppMetadataProperty(). See SDL_SetAppMetadataProperty() for the list + * of available properties and their meanings. + * + * \param name the name of the metadata property to get. + * \returns the current value of the metadata property, or the default if it + * is not set, NULL for properties with no default. + * + * \threadsafety It is safe to call this function from any thread, although + * the string returned is not protected and could potentially be + * freed if you call SDL_SetAppMetadataProperty() to set that + * property from another thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetAppMetadata + * \sa SDL_SetAppMetadataProperty + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetAppMetadataProperty(const char *name); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_init_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_intrin.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_intrin.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,410 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* WIKI CATEGORY: Intrinsics */ + +/** + * # CategoryIntrinsics + * + * SDL does some preprocessor gymnastics to determine if any CPU-specific + * compiler intrinsics are available, as this is not necessarily an easy thing + * to calculate, and sometimes depends on quirks of a system, versions of + * build tools, and other external forces. + * + * Apps including SDL's headers will be able to check consistent preprocessor + * definitions to decide if it's safe to use compiler intrinsics for a + * specific CPU architecture. This check only tells you that the compiler is + * capable of using those intrinsics; at runtime, you should still check if + * they are available on the current system with the + * [CPU info functions](https://wiki.libsdl.org/SDL3/CategoryCPUInfo) + * , such as SDL_HasSSE() or SDL_HasNEON(). Otherwise, the process might crash + * for using an unsupported CPU instruction. + * + * SDL only sets preprocessor defines for CPU intrinsics if they are + * supported, so apps should check with `#ifdef` and not `#if`. + * + * SDL will also include the appropriate instruction-set-specific support + * headers, so if SDL decides to define SDL_SSE2_INTRINSICS, it will also + * `#include ` as well. + */ + +#ifndef SDL_intrin_h_ +#define SDL_intrin_h_ + +#include + +#ifdef SDL_WIKI_DOCUMENTATION_SECTION + +/** + * Defined if (and only if) the compiler supports Loongarch LSX intrinsics. + * + * If this macro is defined, SDL will have already included `` + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_LASX_INTRINSICS + */ +#define SDL_LSX_INTRINSICS 1 + +/** + * Defined if (and only if) the compiler supports Loongarch LSX intrinsics. + * + * If this macro is defined, SDL will have already included `` + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_LASX_INTRINSICS + */ +#define SDL_LASX_INTRINSICS 1 + +/** + * Defined if (and only if) the compiler supports ARM NEON intrinsics. + * + * If this macro is defined, SDL will have already included `` + * ``, ``, and ``, as appropriate. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_NEON_INTRINSICS 1 + +/** + * Defined if (and only if) the compiler supports PowerPC Altivec intrinsics. + * + * If this macro is defined, SDL will have already included `` + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_ALTIVEC_INTRINSICS 1 + +/** + * Defined if (and only if) the compiler supports Intel MMX intrinsics. + * + * If this macro is defined, SDL will have already included `` + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_SSE_INTRINSICS + */ +#define SDL_MMX_INTRINSICS 1 + +/** + * Defined if (and only if) the compiler supports Intel SSE intrinsics. + * + * If this macro is defined, SDL will have already included `` + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_SSE2_INTRINSICS + * \sa SDL_SSE3_INTRINSICS + * \sa SDL_SSE4_1_INTRINSICS + * \sa SDL_SSE4_2_INTRINSICS + */ +#define SDL_SSE_INTRINSICS 1 + +/** + * Defined if (and only if) the compiler supports Intel SSE2 intrinsics. + * + * If this macro is defined, SDL will have already included `` + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_SSE_INTRINSICS + * \sa SDL_SSE3_INTRINSICS + * \sa SDL_SSE4_1_INTRINSICS + * \sa SDL_SSE4_2_INTRINSICS + */ +#define SDL_SSE2_INTRINSICS 1 + +/** + * Defined if (and only if) the compiler supports Intel SSE3 intrinsics. + * + * If this macro is defined, SDL will have already included `` + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_SSE_INTRINSICS + * \sa SDL_SSE2_INTRINSICS + * \sa SDL_SSE4_1_INTRINSICS + * \sa SDL_SSE4_2_INTRINSICS + */ +#define SDL_SSE3_INTRINSICS 1 + +/** + * Defined if (and only if) the compiler supports Intel SSE4.1 intrinsics. + * + * If this macro is defined, SDL will have already included `` + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_SSE_INTRINSICS + * \sa SDL_SSE2_INTRINSICS + * \sa SDL_SSE3_INTRINSICS + * \sa SDL_SSE4_2_INTRINSICS + */ +#define SDL_SSE4_1_INTRINSICS 1 + +/** + * Defined if (and only if) the compiler supports Intel SSE4.2 intrinsics. + * + * If this macro is defined, SDL will have already included `` + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_SSE_INTRINSICS + * \sa SDL_SSE2_INTRINSICS + * \sa SDL_SSE3_INTRINSICS + * \sa SDL_SSE4_1_INTRINSICS + */ +#define SDL_SSE4_2_INTRINSICS 1 + +/** + * Defined if (and only if) the compiler supports Intel AVX intrinsics. + * + * If this macro is defined, SDL will have already included `` + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_AVX2_INTRINSICS + * \sa SDL_AVX512F_INTRINSICS + */ +#define SDL_AVX_INTRINSICS 1 + +/** + * Defined if (and only if) the compiler supports Intel AVX2 intrinsics. + * + * If this macro is defined, SDL will have already included `` + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_AVX_INTRINSICS + * \sa SDL_AVX512F_INTRINSICS + */ +#define SDL_AVX2_INTRINSICS 1 + +/** + * Defined if (and only if) the compiler supports Intel AVX-512F intrinsics. + * + * AVX-512F is also sometimes referred to as "AVX-512 Foundation." + * + * If this macro is defined, SDL will have already included `` + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_AVX_INTRINSICS + * \sa SDL_AVX2_INTRINSICS + */ +#define SDL_AVX512F_INTRINSICS 1 +#endif + +/* Need to do this here because intrin.h has C++ code in it */ +/* Visual Studio 2005 has a bug where intrin.h conflicts with winnt.h */ +#if defined(_MSC_VER) && (_MSC_VER >= 1500) && (defined(_M_IX86) || defined(_M_X64)) +#ifdef __clang__ +/* As of Clang 11, '_m_prefetchw' is conflicting with the winnt.h's version, + so we define the needed '_m_prefetch' here as a pseudo-header, until the issue is fixed. */ +#ifndef __PRFCHWINTRIN_H +#define __PRFCHWINTRIN_H +static __inline__ void __attribute__((__always_inline__, __nodebug__)) +_m_prefetch(void *__P) +{ + __builtin_prefetch (__P, 0, 3 /* _MM_HINT_T0 */); +} +#endif /* __PRFCHWINTRIN_H */ +#endif /* __clang__ */ +#include + +#elif defined(__MINGW64_VERSION_MAJOR) +#include +#if defined(__ARM_NEON) && !defined(SDL_DISABLE_NEON) +# define SDL_NEON_INTRINSICS 1 +# include +#endif + +#else +/* altivec.h redefining bool causes a number of problems, see bugs 3993 and 4392, so you need to explicitly define SDL_ENABLE_ALTIVEC to have it included. */ +#if defined(__ALTIVEC__) && defined(SDL_ENABLE_ALTIVEC) +#define SDL_ALTIVEC_INTRINSICS 1 +#include +#endif +#ifndef SDL_DISABLE_NEON +# ifdef __ARM_NEON +# define SDL_NEON_INTRINSICS 1 +# include +# elif defined(SDL_PLATFORM_WINDOWS) +/* Visual Studio doesn't define __ARM_ARCH, but _M_ARM (if set, always 7), and _M_ARM64 (if set, always 1). */ +# ifdef _M_ARM +# define SDL_NEON_INTRINSICS 1 +# include +# include +# define __ARM_NEON 1 /* Set __ARM_NEON so that it can be used elsewhere, at compile time */ +# endif +# if defined (_M_ARM64) +# define SDL_NEON_INTRINSICS 1 +# include +# include +# define __ARM_NEON 1 /* Set __ARM_NEON so that it can be used elsewhere, at compile time */ +# define __ARM_ARCH 8 +# endif +# endif +#endif +#endif /* compiler version */ + +#ifdef SDL_WIKI_DOCUMENTATION_SECTION + +/** + * A macro to decide if the compiler supports `__attribute__((target))`. + * + * Even though this is defined in SDL's public headers, it is generally not + * used directly by apps. Apps should probably just use SDL_TARGETING + * directly, instead. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_TARGETING + */ +#define SDL_HAS_TARGET_ATTRIBS +#elif defined(__loongarch64) && defined(__GNUC__) && (__GNUC__ >= 15) +/* LoongArch requires GCC 15+ for target attribute support */ +# define SDL_HAS_TARGET_ATTRIBS +#elif defined(__clang__) && defined(__has_attribute) +# if __has_attribute(target) +# define SDL_HAS_TARGET_ATTRIBS +# endif +#elif defined(__GNUC__) && !defined(__loongarch64) && (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) /* gcc >= 4.9 */ +# define SDL_HAS_TARGET_ATTRIBS +#elif defined(__ICC) && __ICC >= 1600 +# define SDL_HAS_TARGET_ATTRIBS +#endif + + +#ifdef SDL_WIKI_DOCUMENTATION_SECTION + +/** + * A macro to tag a function as targeting a specific CPU architecture. + * + * This is a hint to the compiler that a function should be built with support + * for a CPU instruction set that might be different than the rest of the + * program. + * + * The particulars of this are explained in the GCC documentation: + * + * https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-target-function-attribute + * + * An example of using this feature is to turn on SSE2 support for a specific + * function, even if the rest of the source code is not compiled to use SSE2 + * code: + * + * ```c + * #ifdef SDL_SSE2_INTRINSICS + * static void SDL_TARGETING("sse2") DoSomethingWithSSE2(char *x) { + * ...use SSE2 intrinsic functions, etc... + * } + * #endif + * + * // later... + * #ifdef SDL_SSE2_INTRINSICS + * if (SDL_HasSSE2()) { + * DoSomethingWithSSE2(str); + * } + * #endif + * ``` + * + * The application is, on a whole, built without SSE2 instructions, so it will + * run on Intel machines that don't support SSE2. But then at runtime, it + * checks if the system supports the instructions, and then calls into a + * function that uses SSE2 opcodes. The ifdefs make sure that this code isn't + * used on platforms that don't have SSE2 at all. + * + * On compilers without target support, this is defined to nothing. + * + * This symbol is used by SDL internally, but apps and other libraries are + * welcome to use it for their own interfaces as well. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_TARGETING(x) __attribute__((target(x))) + +#elif defined(SDL_HAS_TARGET_ATTRIBS) +# define SDL_TARGETING(x) __attribute__((target(x))) +#else +# define SDL_TARGETING(x) +#endif + +#ifdef __loongarch64 +# ifndef SDL_DISABLE_LSX +# define SDL_LSX_INTRINSICS 1 +# include +# endif +# ifndef SDL_DISABLE_LASX +# define SDL_LASX_INTRINSICS 1 +# include +# endif +#endif + +#if defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || defined(_M_IX86) +# if ((defined(_MSC_VER) && !defined(_M_X64)) || defined(__MMX__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(SDL_DISABLE_MMX) +# define SDL_MMX_INTRINSICS 1 +# include +# endif +# if (defined(_MSC_VER) || defined(__SSE__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(SDL_DISABLE_SSE) +# define SDL_SSE_INTRINSICS 1 +# include +# endif +# if (defined(_MSC_VER) || defined(__SSE2__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(SDL_DISABLE_SSE2) +# define SDL_SSE2_INTRINSICS 1 +# include +# endif +# if (defined(_MSC_VER) || defined(__SSE3__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(SDL_DISABLE_SSE3) +# define SDL_SSE3_INTRINSICS 1 +# include +# endif +# if (defined(_MSC_VER) || defined(__SSE4_1__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(SDL_DISABLE_SSE4_1) +# define SDL_SSE4_1_INTRINSICS 1 +# include +# endif +# if (defined(_MSC_VER) || defined(__SSE4_2__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(SDL_DISABLE_SSE4_2) +# define SDL_SSE4_2_INTRINSICS 1 +# include +# endif +# if defined(__clang__) && (defined(_MSC_VER) || defined(__SCE__)) && !defined(__AVX__) && !defined(SDL_DISABLE_AVX) +# define SDL_DISABLE_AVX /* see https://reviews.llvm.org/D20291 and https://reviews.llvm.org/D79194 */ +# endif +# if (defined(_MSC_VER) || defined(__AVX__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(_M_ARM64EC) && !defined(SDL_DISABLE_AVX) +# define SDL_AVX_INTRINSICS 1 +# include +# endif +# if defined(__clang__) && (defined(_MSC_VER) || defined(__SCE__)) && !defined(__AVX2__) && !defined(SDL_DISABLE_AVX2) +# define SDL_DISABLE_AVX2 /* see https://reviews.llvm.org/D20291 and https://reviews.llvm.org/D79194 */ +# endif +# if (defined(_MSC_VER) || defined(__AVX2__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(_M_ARM64EC) && !defined(SDL_DISABLE_AVX2) +# define SDL_AVX2_INTRINSICS 1 +# include +# endif +# if defined(__clang__) && (defined(_MSC_VER) || defined(__SCE__)) && !defined(__AVX512F__) && !defined(SDL_DISABLE_AVX512F) +# define SDL_DISABLE_AVX512F /* see https://reviews.llvm.org/D20291 and https://reviews.llvm.org/D79194 */ +# endif +# if (defined(_MSC_VER) || defined(__AVX512F__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(_M_ARM64EC) && !defined(SDL_DISABLE_AVX512F) +# define SDL_AVX512F_INTRINSICS 1 +# include +# endif +#endif /* defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || defined(_M_IX86) */ + +#endif /* SDL_intrin_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_iostream.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_iostream.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,1379 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* WIKI CATEGORY: IOStream */ + +/** + * # CategoryIOStream + * + * SDL provides an abstract interface for reading and writing data streams. It + * offers implementations for files, memory, etc, and the app can provide + * their own implementations, too. + * + * SDL_IOStream is not related to the standard C++ iostream class, other than + * both are abstract interfaces to read/write data. + */ + +#ifndef SDL_iostream_h_ +#define SDL_iostream_h_ + +#include +#include +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * SDL_IOStream status, set by a read or write operation. + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_IOStatus +{ + SDL_IO_STATUS_READY, /**< Everything is ready (no errors and not EOF). */ + SDL_IO_STATUS_ERROR, /**< Read or write I/O error */ + SDL_IO_STATUS_EOF, /**< End of file */ + SDL_IO_STATUS_NOT_READY, /**< Non blocking I/O, not ready */ + SDL_IO_STATUS_READONLY, /**< Tried to write a read-only buffer */ + SDL_IO_STATUS_WRITEONLY /**< Tried to read a write-only buffer */ +} SDL_IOStatus; + +/** + * Possible `whence` values for SDL_IOStream seeking. + * + * These map to the same "whence" concept that `fseek` or `lseek` use in the + * standard C runtime. + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_IOWhence +{ + SDL_IO_SEEK_SET, /**< Seek from the beginning of data */ + SDL_IO_SEEK_CUR, /**< Seek relative to current read point */ + SDL_IO_SEEK_END /**< Seek relative to the end of data */ +} SDL_IOWhence; + +/** + * The function pointers that drive an SDL_IOStream. + * + * Applications can provide this struct to SDL_OpenIO() to create their own + * implementation of SDL_IOStream. This is not necessarily required, as SDL + * already offers several common types of I/O streams, via functions like + * SDL_IOFromFile() and SDL_IOFromMem(). + * + * This structure should be initialized using SDL_INIT_INTERFACE() + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_INIT_INTERFACE + */ +typedef struct SDL_IOStreamInterface +{ + /* The version of this interface */ + Uint32 version; + + /** + * Return the number of bytes in this SDL_IOStream + * + * \return the total size of the data stream, or -1 on error. + */ + Sint64 (SDLCALL *size)(void *userdata); + + /** + * Seek to `offset` relative to `whence`, one of stdio's whence values: + * SDL_IO_SEEK_SET, SDL_IO_SEEK_CUR, SDL_IO_SEEK_END + * + * \return the final offset in the data stream, or -1 on error. + */ + Sint64 (SDLCALL *seek)(void *userdata, Sint64 offset, SDL_IOWhence whence); + + /** + * Read up to `size` bytes from the data stream to the area pointed + * at by `ptr`. `size` will always be > 0. + * + * On an incomplete read, you should set `*status` to a value from the + * SDL_IOStatus enum. You do not have to explicitly set this on + * a complete, successful read. + * + * \return the number of bytes read + */ + size_t (SDLCALL *read)(void *userdata, void *ptr, size_t size, SDL_IOStatus *status); + + /** + * Write exactly `size` bytes from the area pointed at by `ptr` + * to data stream. `size` will always be > 0. + * + * On an incomplete write, you should set `*status` to a value from the + * SDL_IOStatus enum. You do not have to explicitly set this on + * a complete, successful write. + * + * \return the number of bytes written + */ + size_t (SDLCALL *write)(void *userdata, const void *ptr, size_t size, SDL_IOStatus *status); + + /** + * If the stream is buffering, make sure the data is written out. + * + * On failure, you should set `*status` to a value from the + * SDL_IOStatus enum. You do not have to explicitly set this on + * a successful flush. + * + * \return true if successful or false on write error when flushing data. + */ + bool (SDLCALL *flush)(void *userdata, SDL_IOStatus *status); + + /** + * Close and free any allocated resources. + * + * This does not guarantee file writes will sync to physical media; they + * can be in the system's file cache, waiting to go to disk. + * + * The SDL_IOStream is still destroyed even if this fails, so clean up anything + * even if flushing buffers, etc, returns an error. + * + * \return true if successful or false on write error when flushing data. + */ + bool (SDLCALL *close)(void *userdata); + +} SDL_IOStreamInterface; + +/* Check the size of SDL_IOStreamInterface + * + * If this assert fails, either the compiler is padding to an unexpected size, + * or the interface has been updated and this should be updated to match and + * the code using this interface should be updated to handle the old version. + */ +SDL_COMPILE_TIME_ASSERT(SDL_IOStreamInterface_SIZE, + (sizeof(void *) == 4 && sizeof(SDL_IOStreamInterface) == 28) || + (sizeof(void *) == 8 && sizeof(SDL_IOStreamInterface) == 56)); + +/** + * The read/write operation structure. + * + * This operates as an opaque handle. There are several APIs to create various + * types of I/O streams, or an app can supply an SDL_IOStreamInterface to + * SDL_OpenIO() to provide their own stream implementation behind this + * struct's abstract interface. + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_IOStream SDL_IOStream; + + +/** + * \name IOFrom functions + * + * Functions to create SDL_IOStream structures from various data streams. + */ +/* @{ */ + +/** + * Use this function to create a new SDL_IOStream structure for reading from + * and/or writing to a named file. + * + * The `mode` string is treated roughly the same as in a call to the C + * library's fopen(), even if SDL doesn't happen to use fopen() behind the + * scenes. + * + * Available `mode` strings: + * + * - "r": Open a file for reading. The file must exist. + * - "w": Create an empty file for writing. If a file with the same name + * already exists its content is erased and the file is treated as a new + * empty file. + * - "wx": Create an empty file for writing. If a file with the same name + * already exists, the call fails. + * - "a": Append to a file. Writing operations append data at the end of the + * file. The file is created if it does not exist. + * - "r+": Open a file for update both reading and writing. The file must + * exist. + * - "w+": Create an empty file for both reading and writing. If a file with + * the same name already exists its content is erased and the file is + * treated as a new empty file. + * - "w+x": Create an empty file for both reading and writing. If a file with + * the same name already exists, the call fails. + * - "a+": Open a file for reading and appending. All writing operations are + * performed at the end of the file, protecting the previous content to be + * overwritten. You can reposition (fseek, rewind) the internal pointer to + * anywhere in the file for reading, but writing operations will move it + * back to the end of file. The file is created if it does not exist. + * + * **NOTE**: In order to open a file as a binary file, a "b" character has to + * be included in the `mode` string. This additional "b" character can either + * be appended at the end of the string (thus making the following compound + * modes: "rb", "wb", "ab", "r+b", "w+b", "a+b") or be inserted between the + * letter and the "+" sign for the mixed modes ("rb+", "wb+", "ab+"). + * Additional characters may follow the sequence, although they should have no + * effect. For example, "t" is sometimes appended to make explicit the file is + * a text file. + * + * This function supports Unicode filenames, but they must be encoded in UTF-8 + * format, regardless of the underlying operating system. + * + * In Android, SDL_IOFromFile() can be used to open content:// URIs. As a + * fallback, SDL_IOFromFile() will transparently open a matching filename in + * the app's `assets`. + * + * Closing the SDL_IOStream will close SDL's internal file handle. + * + * The following properties may be set at creation time by SDL: + * + * - `SDL_PROP_IOSTREAM_WINDOWS_HANDLE_POINTER`: a pointer, that can be cast + * to a win32 `HANDLE`, that this SDL_IOStream is using to access the + * filesystem. If the program isn't running on Windows, or SDL used some + * other method to access the filesystem, this property will not be set. + * - `SDL_PROP_IOSTREAM_STDIO_FILE_POINTER`: a pointer, that can be cast to a + * stdio `FILE *`, that this SDL_IOStream is using to access the filesystem. + * If SDL used some other method to access the filesystem, this property + * will not be set. PLEASE NOTE that if SDL is using a different C runtime + * than your app, trying to use this pointer will almost certainly result in + * a crash! This is mostly a problem on Windows; make sure you build SDL and + * your app with the same compiler and settings to avoid it. + * - `SDL_PROP_IOSTREAM_FILE_DESCRIPTOR_NUMBER`: a file descriptor that this + * SDL_IOStream is using to access the filesystem. + * - `SDL_PROP_IOSTREAM_ANDROID_AASSET_POINTER`: a pointer, that can be cast + * to an Android NDK `AAsset *`, that this SDL_IOStream is using to access + * the filesystem. If SDL used some other method to access the filesystem, + * this property will not be set. + * + * \param file a UTF-8 string representing the filename to open. + * \param mode an ASCII string representing the mode to be used for opening + * the file. + * \returns a pointer to the SDL_IOStream structure that is created or NULL on + * failure; call SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CloseIO + * \sa SDL_FlushIO + * \sa SDL_ReadIO + * \sa SDL_SeekIO + * \sa SDL_TellIO + * \sa SDL_WriteIO + */ +extern SDL_DECLSPEC SDL_IOStream * SDLCALL SDL_IOFromFile(const char *file, const char *mode); + +#define SDL_PROP_IOSTREAM_WINDOWS_HANDLE_POINTER "SDL.iostream.windows.handle" +#define SDL_PROP_IOSTREAM_STDIO_FILE_POINTER "SDL.iostream.stdio.file" +#define SDL_PROP_IOSTREAM_FILE_DESCRIPTOR_NUMBER "SDL.iostream.file_descriptor" +#define SDL_PROP_IOSTREAM_ANDROID_AASSET_POINTER "SDL.iostream.android.aasset" + +/** + * Use this function to prepare a read-write memory buffer for use with + * SDL_IOStream. + * + * This function sets up an SDL_IOStream struct based on a memory area of a + * certain size, for both read and write access. + * + * This memory buffer is not copied by the SDL_IOStream; the pointer you + * provide must remain valid until you close the stream. + * + * If you need to make sure the SDL_IOStream never writes to the memory + * buffer, you should use SDL_IOFromConstMem() with a read-only buffer of + * memory instead. + * + * The following properties will be set at creation time by SDL: + * + * - `SDL_PROP_IOSTREAM_MEMORY_POINTER`: this will be the `mem` parameter that + * was passed to this function. + * - `SDL_PROP_IOSTREAM_MEMORY_SIZE_NUMBER`: this will be the `size` parameter + * that was passed to this function. + * + * Additionally, the following properties are recognized: + * + * - `SDL_PROP_IOSTREAM_MEMORY_FREE_FUNC_POINTER`: if this property is set to + * a non-NULL value it will be interpreted as a function of SDL_free_func + * type and called with the passed `mem` pointer when closing the stream. By + * default it is unset, i.e., the memory will not be freed. + * + * \param mem a pointer to a buffer to feed an SDL_IOStream stream. + * \param size the buffer size, in bytes. + * \returns a pointer to a new SDL_IOStream structure or NULL on failure; call + * SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_IOFromConstMem + * \sa SDL_CloseIO + * \sa SDL_FlushIO + * \sa SDL_ReadIO + * \sa SDL_SeekIO + * \sa SDL_TellIO + * \sa SDL_WriteIO + */ +extern SDL_DECLSPEC SDL_IOStream * SDLCALL SDL_IOFromMem(void *mem, size_t size); + +#define SDL_PROP_IOSTREAM_MEMORY_POINTER "SDL.iostream.memory.base" +#define SDL_PROP_IOSTREAM_MEMORY_SIZE_NUMBER "SDL.iostream.memory.size" +#define SDL_PROP_IOSTREAM_MEMORY_FREE_FUNC_POINTER "SDL.iostream.memory.free" + +/** + * Use this function to prepare a read-only memory buffer for use with + * SDL_IOStream. + * + * This function sets up an SDL_IOStream struct based on a memory area of a + * certain size. It assumes the memory area is not writable. + * + * Attempting to write to this SDL_IOStream stream will report an error + * without writing to the memory buffer. + * + * This memory buffer is not copied by the SDL_IOStream; the pointer you + * provide must remain valid until you close the stream. + * + * If you need to write to a memory buffer, you should use SDL_IOFromMem() + * with a writable buffer of memory instead. + * + * The following properties will be set at creation time by SDL: + * + * - `SDL_PROP_IOSTREAM_MEMORY_POINTER`: this will be the `mem` parameter that + * was passed to this function. + * - `SDL_PROP_IOSTREAM_MEMORY_SIZE_NUMBER`: this will be the `size` parameter + * that was passed to this function. + * + * Additionally, the following properties are recognized: + * + * - `SDL_PROP_IOSTREAM_MEMORY_FREE_FUNC_POINTER`: if this property is set to + * a non-NULL value it will be interpreted as a function of SDL_free_func + * type and called with the passed `mem` pointer when closing the stream. By + * default it is unset, i.e., the memory will not be freed. + * + * \param mem a pointer to a read-only buffer to feed an SDL_IOStream stream. + * \param size the buffer size, in bytes. + * \returns a pointer to a new SDL_IOStream structure or NULL on failure; call + * SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_IOFromMem + * \sa SDL_CloseIO + * \sa SDL_ReadIO + * \sa SDL_SeekIO + * \sa SDL_TellIO + */ +extern SDL_DECLSPEC SDL_IOStream * SDLCALL SDL_IOFromConstMem(const void *mem, size_t size); + +/** + * Use this function to create an SDL_IOStream that is backed by dynamically + * allocated memory. + * + * This supports the following properties to provide access to the memory and + * control over allocations: + * + * - `SDL_PROP_IOSTREAM_DYNAMIC_MEMORY_POINTER`: a pointer to the internal + * memory of the stream. This can be set to NULL to transfer ownership of + * the memory to the application, which should free the memory with + * SDL_free(). If this is done, the next operation on the stream must be + * SDL_CloseIO(). + * - `SDL_PROP_IOSTREAM_DYNAMIC_CHUNKSIZE_NUMBER`: memory will be allocated in + * multiples of this size, defaulting to 1024. + * + * \returns a pointer to a new SDL_IOStream structure or NULL on failure; call + * SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CloseIO + * \sa SDL_ReadIO + * \sa SDL_SeekIO + * \sa SDL_TellIO + * \sa SDL_WriteIO + */ +extern SDL_DECLSPEC SDL_IOStream * SDLCALL SDL_IOFromDynamicMem(void); + +#define SDL_PROP_IOSTREAM_DYNAMIC_MEMORY_POINTER "SDL.iostream.dynamic.memory" +#define SDL_PROP_IOSTREAM_DYNAMIC_CHUNKSIZE_NUMBER "SDL.iostream.dynamic.chunksize" + +/* @} *//* IOFrom functions */ + + +/** + * Create a custom SDL_IOStream. + * + * Applications do not need to use this function unless they are providing + * their own SDL_IOStream implementation. If you just need an SDL_IOStream to + * read/write a common data source, you should use the built-in + * implementations in SDL, like SDL_IOFromFile() or SDL_IOFromMem(), etc. + * + * This function makes a copy of `iface` and the caller does not need to keep + * it around after this call. + * + * \param iface the interface that implements this SDL_IOStream, initialized + * using SDL_INIT_INTERFACE(). + * \param userdata the pointer that will be passed to the interface functions. + * \returns a pointer to the allocated memory on success or NULL on failure; + * call SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CloseIO + * \sa SDL_INIT_INTERFACE + * \sa SDL_IOFromConstMem + * \sa SDL_IOFromFile + * \sa SDL_IOFromMem + */ +extern SDL_DECLSPEC SDL_IOStream * SDLCALL SDL_OpenIO(const SDL_IOStreamInterface *iface, void *userdata); + +/** + * Close and free an allocated SDL_IOStream structure. + * + * SDL_CloseIO() closes and cleans up the SDL_IOStream stream. It releases any + * resources used by the stream and frees the SDL_IOStream itself. This + * returns true on success, or false if the stream failed to flush to its + * output (e.g. to disk). + * + * Note that if this fails to flush the stream for any reason, this function + * reports an error, but the SDL_IOStream is still invalid once this function + * returns. + * + * This call flushes any buffered writes to the operating system, but there + * are no guarantees that those writes have gone to physical media; they might + * be in the OS's file cache, waiting to go to disk later. If it's absolutely + * crucial that writes go to disk immediately, so they are definitely stored + * even if the power fails before the file cache would have caught up, one + * should call SDL_FlushIO() before closing. Note that flushing takes time and + * makes the system and your app operate less efficiently, so do so sparingly. + * + * \param context SDL_IOStream structure to close. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety Do not use the same SDL_IOStream from two threads at once. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_OpenIO + */ +extern SDL_DECLSPEC bool SDLCALL SDL_CloseIO(SDL_IOStream *context); + +/** + * Get the properties associated with an SDL_IOStream. + * + * \param context a pointer to an SDL_IOStream structure. + * \returns a valid property ID on success or 0 on failure; call + * SDL_GetError() for more information. + * + * \threadsafety Do not use the same SDL_IOStream from two threads at once. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetIOProperties(SDL_IOStream *context); + +/** + * Query the stream status of an SDL_IOStream. + * + * This information can be useful to decide if a short read or write was due + * to an error, an EOF, or a non-blocking operation that isn't yet ready to + * complete. + * + * An SDL_IOStream's status is only expected to change after a SDL_ReadIO or + * SDL_WriteIO call; don't expect it to change if you just call this query + * function in a tight loop. + * + * \param context the SDL_IOStream to query. + * \returns an SDL_IOStatus enum with the current state. + * + * \threadsafety Do not use the same SDL_IOStream from two threads at once. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_IOStatus SDLCALL SDL_GetIOStatus(SDL_IOStream *context); + +/** + * Use this function to get the size of the data stream in an SDL_IOStream. + * + * \param context the SDL_IOStream to get the size of the data stream from. + * \returns the size of the data stream in the SDL_IOStream on success or a + * negative error code on failure; call SDL_GetError() for more + * information. + * + * \threadsafety Do not use the same SDL_IOStream from two threads at once. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC Sint64 SDLCALL SDL_GetIOSize(SDL_IOStream *context); + +/** + * Seek within an SDL_IOStream data stream. + * + * This function seeks to byte `offset`, relative to `whence`. + * + * `whence` may be any of the following values: + * + * - `SDL_IO_SEEK_SET`: seek from the beginning of data + * - `SDL_IO_SEEK_CUR`: seek relative to current read point + * - `SDL_IO_SEEK_END`: seek relative to the end of data + * + * If this stream can not seek, it will return -1. + * + * \param context a pointer to an SDL_IOStream structure. + * \param offset an offset in bytes, relative to `whence` location; can be + * negative. + * \param whence any of `SDL_IO_SEEK_SET`, `SDL_IO_SEEK_CUR`, + * `SDL_IO_SEEK_END`. + * \returns the final offset in the data stream after the seek or -1 on + * failure; call SDL_GetError() for more information. + * + * \threadsafety Do not use the same SDL_IOStream from two threads at once. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_TellIO + */ +extern SDL_DECLSPEC Sint64 SDLCALL SDL_SeekIO(SDL_IOStream *context, Sint64 offset, SDL_IOWhence whence); + +/** + * Determine the current read/write offset in an SDL_IOStream data stream. + * + * SDL_TellIO is actually a wrapper function that calls the SDL_IOStream's + * `seek` method, with an offset of 0 bytes from `SDL_IO_SEEK_CUR`, to + * simplify application development. + * + * \param context an SDL_IOStream data stream object from which to get the + * current offset. + * \returns the current offset in the stream, or -1 if the information can not + * be determined. + * + * \threadsafety Do not use the same SDL_IOStream from two threads at once. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SeekIO + */ +extern SDL_DECLSPEC Sint64 SDLCALL SDL_TellIO(SDL_IOStream *context); + +/** + * Read from a data source. + * + * This function reads up `size` bytes from the data source to the area + * pointed at by `ptr`. This function may read less bytes than requested. + * + * This function will return zero when the data stream is completely read, and + * SDL_GetIOStatus() will return SDL_IO_STATUS_EOF. If zero is returned and + * the stream is not at EOF, SDL_GetIOStatus() will return a different error + * value and SDL_GetError() will offer a human-readable message. + * + * A request for zero bytes on a valid stream will return zero immediately + * without accessing the stream, so the stream status (EOF, err, etc) will not + * change. + * + * \param context a pointer to an SDL_IOStream structure. + * \param ptr a pointer to a buffer to read data into. + * \param size the number of bytes to read from the data source. + * \returns the number of bytes read, or 0 on end of file or other failure; + * call SDL_GetError() for more information. + * + * \threadsafety Do not use the same SDL_IOStream from two threads at once. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_WriteIO + * \sa SDL_GetIOStatus + */ +extern SDL_DECLSPEC size_t SDLCALL SDL_ReadIO(SDL_IOStream *context, void *ptr, size_t size); + +/** + * Write to an SDL_IOStream data stream. + * + * This function writes exactly `size` bytes from the area pointed at by `ptr` + * to the stream. If this fails for any reason, it'll return less than `size` + * to demonstrate how far the write progressed. On success, it returns `size`. + * + * On error, this function still attempts to write as much as possible, so it + * might return a positive value less than the requested write size. + * + * The caller can use SDL_GetIOStatus() to determine if the problem is + * recoverable, such as a non-blocking write that can simply be retried later, + * or a fatal error. + * + * A request for zero bytes on a valid stream will return zero immediately + * without accessing the stream, so the stream status (EOF, err, etc) will not + * change. + * + * \param context a pointer to an SDL_IOStream structure. + * \param ptr a pointer to a buffer containing data to write. + * \param size the number of bytes to write. + * \returns the number of bytes written, which will be less than `size` on + * failure; call SDL_GetError() for more information. + * + * \threadsafety Do not use the same SDL_IOStream from two threads at once. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_IOprintf + * \sa SDL_ReadIO + * \sa SDL_SeekIO + * \sa SDL_FlushIO + * \sa SDL_GetIOStatus + */ +extern SDL_DECLSPEC size_t SDLCALL SDL_WriteIO(SDL_IOStream *context, const void *ptr, size_t size); + +/** + * Print to an SDL_IOStream data stream. + * + * This function does formatted printing to the stream. + * + * \param context a pointer to an SDL_IOStream structure. + * \param fmt a printf() style format string. + * \param ... additional parameters matching % tokens in the `fmt` string, if + * any. + * \returns the number of bytes written or 0 on failure; call SDL_GetError() + * for more information. + * + * \threadsafety Do not use the same SDL_IOStream from two threads at once. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_IOvprintf + * \sa SDL_WriteIO + */ +extern SDL_DECLSPEC size_t SDLCALL SDL_IOprintf(SDL_IOStream *context, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); + +/** + * Print to an SDL_IOStream data stream. + * + * This function does formatted printing to the stream. + * + * \param context a pointer to an SDL_IOStream structure. + * \param fmt a printf() style format string. + * \param ap a variable argument list. + * \returns the number of bytes written or 0 on failure; call SDL_GetError() + * for more information. + * + * \threadsafety Do not use the same SDL_IOStream from two threads at once. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_IOprintf + * \sa SDL_WriteIO + */ +extern SDL_DECLSPEC size_t SDLCALL SDL_IOvprintf(SDL_IOStream *context, SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap) SDL_PRINTF_VARARG_FUNCV(2); + +/** + * Flush any buffered data in the stream. + * + * This function makes sure that any buffered data is written to the stream. + * Normally this isn't necessary but if the stream is a pipe or socket it + * guarantees that any pending data is sent. + * + * \param context SDL_IOStream structure to flush. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety Do not use the same SDL_IOStream from two threads at once. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_OpenIO + * \sa SDL_WriteIO + */ +extern SDL_DECLSPEC bool SDLCALL SDL_FlushIO(SDL_IOStream *context); + +/** + * Load all the data from an SDL data stream. + * + * The data is allocated with a zero byte at the end (null terminated) for + * convenience. This extra byte is not included in the value reported via + * `datasize`. + * + * The data should be freed with SDL_free(). + * + * \param src the SDL_IOStream to read all available data from. + * \param datasize a pointer filled in with the number of bytes read, may be + * NULL. + * \param closeio if true, calls SDL_CloseIO() on `src` before returning, even + * in the case of an error. + * \returns the data or NULL on failure; call SDL_GetError() for more + * information. + * + * \threadsafety Do not use the same SDL_IOStream from two threads at once. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_LoadFile + * \sa SDL_SaveFile_IO + */ +extern SDL_DECLSPEC void * SDLCALL SDL_LoadFile_IO(SDL_IOStream *src, size_t *datasize, bool closeio); + +/** + * Load all the data from a file path. + * + * The data is allocated with a zero byte at the end (null terminated) for + * convenience. This extra byte is not included in the value reported via + * `datasize`. + * + * The data should be freed with SDL_free(). + * + * \param file the path to read all available data from. + * \param datasize if not NULL, will store the number of bytes read. + * \returns the data or NULL on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_LoadFile_IO + * \sa SDL_SaveFile + */ +extern SDL_DECLSPEC void * SDLCALL SDL_LoadFile(const char *file, size_t *datasize); + +/** + * Save all the data into an SDL data stream. + * + * \param src the SDL_IOStream to write all data to. + * \param data the data to be written. If datasize is 0, may be NULL or a + * invalid pointer. + * \param datasize the number of bytes to be written. + * \param closeio if true, calls SDL_CloseIO() on `src` before returning, even + * in the case of an error. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety Do not use the same SDL_IOStream from two threads at once. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SaveFile + * \sa SDL_LoadFile_IO + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SaveFile_IO(SDL_IOStream *src, const void *data, size_t datasize, bool closeio); + +/** + * Save all the data into a file path. + * + * \param file the path to write all available data into. + * \param data the data to be written. If datasize is 0, may be NULL or a + * invalid pointer. + * \param datasize the number of bytes to be written. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SaveFile_IO + * \sa SDL_LoadFile + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SaveFile(const char *file, const void *data, size_t datasize); + +/** + * \name Read endian functions + * + * Read an item of the specified endianness and return in native format. + */ +/* @{ */ + +/** + * Use this function to read a byte from an SDL_IOStream. + * + * This function will return false when the data stream is completely read, + * and SDL_GetIOStatus() will return SDL_IO_STATUS_EOF. If false is returned + * and the stream is not at EOF, SDL_GetIOStatus() will return a different + * error value and SDL_GetError() will offer a human-readable message. + * + * \param src the SDL_IOStream to read from. + * \param value a pointer filled in with the data read. + * \returns true on success or false on failure or EOF; call SDL_GetError() + * for more information. + * + * \threadsafety Do not use the same SDL_IOStream from two threads at once. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_ReadU8(SDL_IOStream *src, Uint8 *value); + +/** + * Use this function to read a signed byte from an SDL_IOStream. + * + * This function will return false when the data stream is completely read, + * and SDL_GetIOStatus() will return SDL_IO_STATUS_EOF. If false is returned + * and the stream is not at EOF, SDL_GetIOStatus() will return a different + * error value and SDL_GetError() will offer a human-readable message. + * + * \param src the SDL_IOStream to read from. + * \param value a pointer filled in with the data read. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety Do not use the same SDL_IOStream from two threads at once. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_ReadS8(SDL_IOStream *src, Sint8 *value); + +/** + * Use this function to read 16 bits of little-endian data from an + * SDL_IOStream and return in native format. + * + * SDL byteswaps the data only if necessary, so the data returned will be in + * the native byte order. + * + * This function will return false when the data stream is completely read, + * and SDL_GetIOStatus() will return SDL_IO_STATUS_EOF. If false is returned + * and the stream is not at EOF, SDL_GetIOStatus() will return a different + * error value and SDL_GetError() will offer a human-readable message. + * + * \param src the stream from which to read data. + * \param value a pointer filled in with the data read. + * \returns true on successful read or false on failure; call SDL_GetError() + * for more information. + * + * \threadsafety Do not use the same SDL_IOStream from two threads at once. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_ReadU16LE(SDL_IOStream *src, Uint16 *value); + +/** + * Use this function to read 16 bits of little-endian data from an + * SDL_IOStream and return in native format. + * + * SDL byteswaps the data only if necessary, so the data returned will be in + * the native byte order. + * + * This function will return false when the data stream is completely read, + * and SDL_GetIOStatus() will return SDL_IO_STATUS_EOF. If false is returned + * and the stream is not at EOF, SDL_GetIOStatus() will return a different + * error value and SDL_GetError() will offer a human-readable message. + * + * \param src the stream from which to read data. + * \param value a pointer filled in with the data read. + * \returns true on successful read or false on failure; call SDL_GetError() + * for more information. + * + * \threadsafety Do not use the same SDL_IOStream from two threads at once. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_ReadS16LE(SDL_IOStream *src, Sint16 *value); + +/** + * Use this function to read 16 bits of big-endian data from an SDL_IOStream + * and return in native format. + * + * SDL byteswaps the data only if necessary, so the data returned will be in + * the native byte order. + * + * This function will return false when the data stream is completely read, + * and SDL_GetIOStatus() will return SDL_IO_STATUS_EOF. If false is returned + * and the stream is not at EOF, SDL_GetIOStatus() will return a different + * error value and SDL_GetError() will offer a human-readable message. + * + * \param src the stream from which to read data. + * \param value a pointer filled in with the data read. + * \returns true on successful read or false on failure; call SDL_GetError() + * for more information. + * + * \threadsafety Do not use the same SDL_IOStream from two threads at once. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_ReadU16BE(SDL_IOStream *src, Uint16 *value); + +/** + * Use this function to read 16 bits of big-endian data from an SDL_IOStream + * and return in native format. + * + * SDL byteswaps the data only if necessary, so the data returned will be in + * the native byte order. + * + * This function will return false when the data stream is completely read, + * and SDL_GetIOStatus() will return SDL_IO_STATUS_EOF. If false is returned + * and the stream is not at EOF, SDL_GetIOStatus() will return a different + * error value and SDL_GetError() will offer a human-readable message. + * + * \param src the stream from which to read data. + * \param value a pointer filled in with the data read. + * \returns true on successful read or false on failure; call SDL_GetError() + * for more information. + * + * \threadsafety Do not use the same SDL_IOStream from two threads at once. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_ReadS16BE(SDL_IOStream *src, Sint16 *value); + +/** + * Use this function to read 32 bits of little-endian data from an + * SDL_IOStream and return in native format. + * + * SDL byteswaps the data only if necessary, so the data returned will be in + * the native byte order. + * + * This function will return false when the data stream is completely read, + * and SDL_GetIOStatus() will return SDL_IO_STATUS_EOF. If false is returned + * and the stream is not at EOF, SDL_GetIOStatus() will return a different + * error value and SDL_GetError() will offer a human-readable message. + * + * \param src the stream from which to read data. + * \param value a pointer filled in with the data read. + * \returns true on successful read or false on failure; call SDL_GetError() + * for more information. + * + * \threadsafety Do not use the same SDL_IOStream from two threads at once. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_ReadU32LE(SDL_IOStream *src, Uint32 *value); + +/** + * Use this function to read 32 bits of little-endian data from an + * SDL_IOStream and return in native format. + * + * SDL byteswaps the data only if necessary, so the data returned will be in + * the native byte order. + * + * This function will return false when the data stream is completely read, + * and SDL_GetIOStatus() will return SDL_IO_STATUS_EOF. If false is returned + * and the stream is not at EOF, SDL_GetIOStatus() will return a different + * error value and SDL_GetError() will offer a human-readable message. + * + * \param src the stream from which to read data. + * \param value a pointer filled in with the data read. + * \returns true on successful read or false on failure; call SDL_GetError() + * for more information. + * + * \threadsafety Do not use the same SDL_IOStream from two threads at once. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_ReadS32LE(SDL_IOStream *src, Sint32 *value); + +/** + * Use this function to read 32 bits of big-endian data from an SDL_IOStream + * and return in native format. + * + * SDL byteswaps the data only if necessary, so the data returned will be in + * the native byte order. + * + * This function will return false when the data stream is completely read, + * and SDL_GetIOStatus() will return SDL_IO_STATUS_EOF. If false is returned + * and the stream is not at EOF, SDL_GetIOStatus() will return a different + * error value and SDL_GetError() will offer a human-readable message. + * + * \param src the stream from which to read data. + * \param value a pointer filled in with the data read. + * \returns true on successful read or false on failure; call SDL_GetError() + * for more information. + * + * \threadsafety Do not use the same SDL_IOStream from two threads at once. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_ReadU32BE(SDL_IOStream *src, Uint32 *value); + +/** + * Use this function to read 32 bits of big-endian data from an SDL_IOStream + * and return in native format. + * + * SDL byteswaps the data only if necessary, so the data returned will be in + * the native byte order. + * + * This function will return false when the data stream is completely read, + * and SDL_GetIOStatus() will return SDL_IO_STATUS_EOF. If false is returned + * and the stream is not at EOF, SDL_GetIOStatus() will return a different + * error value and SDL_GetError() will offer a human-readable message. + * + * \param src the stream from which to read data. + * \param value a pointer filled in with the data read. + * \returns true on successful read or false on failure; call SDL_GetError() + * for more information. + * + * \threadsafety Do not use the same SDL_IOStream from two threads at once. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_ReadS32BE(SDL_IOStream *src, Sint32 *value); + +/** + * Use this function to read 64 bits of little-endian data from an + * SDL_IOStream and return in native format. + * + * SDL byteswaps the data only if necessary, so the data returned will be in + * the native byte order. + * + * This function will return false when the data stream is completely read, + * and SDL_GetIOStatus() will return SDL_IO_STATUS_EOF. If false is returned + * and the stream is not at EOF, SDL_GetIOStatus() will return a different + * error value and SDL_GetError() will offer a human-readable message. + * + * \param src the stream from which to read data. + * \param value a pointer filled in with the data read. + * \returns true on successful read or false on failure; call SDL_GetError() + * for more information. + * + * \threadsafety Do not use the same SDL_IOStream from two threads at once. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_ReadU64LE(SDL_IOStream *src, Uint64 *value); + +/** + * Use this function to read 64 bits of little-endian data from an + * SDL_IOStream and return in native format. + * + * SDL byteswaps the data only if necessary, so the data returned will be in + * the native byte order. + * + * This function will return false when the data stream is completely read, + * and SDL_GetIOStatus() will return SDL_IO_STATUS_EOF. If false is returned + * and the stream is not at EOF, SDL_GetIOStatus() will return a different + * error value and SDL_GetError() will offer a human-readable message. + * + * \param src the stream from which to read data. + * \param value a pointer filled in with the data read. + * \returns true on successful read or false on failure; call SDL_GetError() + * for more information. + * + * \threadsafety Do not use the same SDL_IOStream from two threads at once. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_ReadS64LE(SDL_IOStream *src, Sint64 *value); + +/** + * Use this function to read 64 bits of big-endian data from an SDL_IOStream + * and return in native format. + * + * SDL byteswaps the data only if necessary, so the data returned will be in + * the native byte order. + * + * This function will return false when the data stream is completely read, + * and SDL_GetIOStatus() will return SDL_IO_STATUS_EOF. If false is returned + * and the stream is not at EOF, SDL_GetIOStatus() will return a different + * error value and SDL_GetError() will offer a human-readable message. + * + * \param src the stream from which to read data. + * \param value a pointer filled in with the data read. + * \returns true on successful read or false on failure; call SDL_GetError() + * for more information. + * + * \threadsafety Do not use the same SDL_IOStream from two threads at once. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_ReadU64BE(SDL_IOStream *src, Uint64 *value); + +/** + * Use this function to read 64 bits of big-endian data from an SDL_IOStream + * and return in native format. + * + * SDL byteswaps the data only if necessary, so the data returned will be in + * the native byte order. + * + * This function will return false when the data stream is completely read, + * and SDL_GetIOStatus() will return SDL_IO_STATUS_EOF. If false is returned + * and the stream is not at EOF, SDL_GetIOStatus() will return a different + * error value and SDL_GetError() will offer a human-readable message. + * + * \param src the stream from which to read data. + * \param value a pointer filled in with the data read. + * \returns true on successful read or false on failure; call SDL_GetError() + * for more information. + * + * \threadsafety Do not use the same SDL_IOStream from two threads at once. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_ReadS64BE(SDL_IOStream *src, Sint64 *value); +/* @} *//* Read endian functions */ + +/** + * \name Write endian functions + * + * Write an item of native format to the specified endianness. + */ +/* @{ */ + +/** + * Use this function to write a byte to an SDL_IOStream. + * + * \param dst the SDL_IOStream to write to. + * \param value the byte value to write. + * \returns true on successful write or false on failure; call SDL_GetError() + * for more information. + * + * \threadsafety Do not use the same SDL_IOStream from two threads at once. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_WriteU8(SDL_IOStream *dst, Uint8 value); + +/** + * Use this function to write a signed byte to an SDL_IOStream. + * + * \param dst the SDL_IOStream to write to. + * \param value the byte value to write. + * \returns true on successful write or false on failure; call SDL_GetError() + * for more information. + * + * \threadsafety Do not use the same SDL_IOStream from two threads at once. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_WriteS8(SDL_IOStream *dst, Sint8 value); + +/** + * Use this function to write 16 bits in native format to an SDL_IOStream as + * little-endian data. + * + * SDL byteswaps the data only if necessary, so the application always + * specifies native format, and the data written will be in little-endian + * format. + * + * \param dst the stream to which data will be written. + * \param value the data to be written, in native format. + * \returns true on successful write or false on failure; call SDL_GetError() + * for more information. + * + * \threadsafety Do not use the same SDL_IOStream from two threads at once. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_WriteU16LE(SDL_IOStream *dst, Uint16 value); + +/** + * Use this function to write 16 bits in native format to an SDL_IOStream as + * little-endian data. + * + * SDL byteswaps the data only if necessary, so the application always + * specifies native format, and the data written will be in little-endian + * format. + * + * \param dst the stream to which data will be written. + * \param value the data to be written, in native format. + * \returns true on successful write or false on failure; call SDL_GetError() + * for more information. + * + * \threadsafety Do not use the same SDL_IOStream from two threads at once. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_WriteS16LE(SDL_IOStream *dst, Sint16 value); + +/** + * Use this function to write 16 bits in native format to an SDL_IOStream as + * big-endian data. + * + * SDL byteswaps the data only if necessary, so the application always + * specifies native format, and the data written will be in big-endian format. + * + * \param dst the stream to which data will be written. + * \param value the data to be written, in native format. + * \returns true on successful write or false on failure; call SDL_GetError() + * for more information. + * + * \threadsafety Do not use the same SDL_IOStream from two threads at once. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_WriteU16BE(SDL_IOStream *dst, Uint16 value); + +/** + * Use this function to write 16 bits in native format to an SDL_IOStream as + * big-endian data. + * + * SDL byteswaps the data only if necessary, so the application always + * specifies native format, and the data written will be in big-endian format. + * + * \param dst the stream to which data will be written. + * \param value the data to be written, in native format. + * \returns true on successful write or false on failure; call SDL_GetError() + * for more information. + * + * \threadsafety Do not use the same SDL_IOStream from two threads at once. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_WriteS16BE(SDL_IOStream *dst, Sint16 value); + +/** + * Use this function to write 32 bits in native format to an SDL_IOStream as + * little-endian data. + * + * SDL byteswaps the data only if necessary, so the application always + * specifies native format, and the data written will be in little-endian + * format. + * + * \param dst the stream to which data will be written. + * \param value the data to be written, in native format. + * \returns true on successful write or false on failure; call SDL_GetError() + * for more information. + * + * \threadsafety Do not use the same SDL_IOStream from two threads at once. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_WriteU32LE(SDL_IOStream *dst, Uint32 value); + +/** + * Use this function to write 32 bits in native format to an SDL_IOStream as + * little-endian data. + * + * SDL byteswaps the data only if necessary, so the application always + * specifies native format, and the data written will be in little-endian + * format. + * + * \param dst the stream to which data will be written. + * \param value the data to be written, in native format. + * \returns true on successful write or false on failure; call SDL_GetError() + * for more information. + * + * \threadsafety Do not use the same SDL_IOStream from two threads at once. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_WriteS32LE(SDL_IOStream *dst, Sint32 value); + +/** + * Use this function to write 32 bits in native format to an SDL_IOStream as + * big-endian data. + * + * SDL byteswaps the data only if necessary, so the application always + * specifies native format, and the data written will be in big-endian format. + * + * \param dst the stream to which data will be written. + * \param value the data to be written, in native format. + * \returns true on successful write or false on failure; call SDL_GetError() + * for more information. + * + * \threadsafety Do not use the same SDL_IOStream from two threads at once. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_WriteU32BE(SDL_IOStream *dst, Uint32 value); + +/** + * Use this function to write 32 bits in native format to an SDL_IOStream as + * big-endian data. + * + * SDL byteswaps the data only if necessary, so the application always + * specifies native format, and the data written will be in big-endian format. + * + * \param dst the stream to which data will be written. + * \param value the data to be written, in native format. + * \returns true on successful write or false on failure; call SDL_GetError() + * for more information. + * + * \threadsafety Do not use the same SDL_IOStream from two threads at once. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_WriteS32BE(SDL_IOStream *dst, Sint32 value); + +/** + * Use this function to write 64 bits in native format to an SDL_IOStream as + * little-endian data. + * + * SDL byteswaps the data only if necessary, so the application always + * specifies native format, and the data written will be in little-endian + * format. + * + * \param dst the stream to which data will be written. + * \param value the data to be written, in native format. + * \returns true on successful write or false on failure; call SDL_GetError() + * for more information. + * + * \threadsafety Do not use the same SDL_IOStream from two threads at once. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_WriteU64LE(SDL_IOStream *dst, Uint64 value); + +/** + * Use this function to write 64 bits in native format to an SDL_IOStream as + * little-endian data. + * + * SDL byteswaps the data only if necessary, so the application always + * specifies native format, and the data written will be in little-endian + * format. + * + * \param dst the stream to which data will be written. + * \param value the data to be written, in native format. + * \returns true on successful write or false on failure; call SDL_GetError() + * for more information. + * + * \threadsafety Do not use the same SDL_IOStream from two threads at once. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_WriteS64LE(SDL_IOStream *dst, Sint64 value); + +/** + * Use this function to write 64 bits in native format to an SDL_IOStream as + * big-endian data. + * + * SDL byteswaps the data only if necessary, so the application always + * specifies native format, and the data written will be in big-endian format. + * + * \param dst the stream to which data will be written. + * \param value the data to be written, in native format. + * \returns true on successful write or false on failure; call SDL_GetError() + * for more information. + * + * \threadsafety Do not use the same SDL_IOStream from two threads at once. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_WriteU64BE(SDL_IOStream *dst, Uint64 value); + +/** + * Use this function to write 64 bits in native format to an SDL_IOStream as + * big-endian data. + * + * SDL byteswaps the data only if necessary, so the application always + * specifies native format, and the data written will be in big-endian format. + * + * \param dst the stream to which data will be written. + * \param value the data to be written, in native format. + * \returns true on successful write or false on failure; call SDL_GetError() + * for more information. + * + * \threadsafety Do not use the same SDL_IOStream from two threads at once. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_WriteS64BE(SDL_IOStream *dst, Sint64 value); + +/* @} *//* Write endian functions */ + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_iostream_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_joystick.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_joystick.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,1385 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * # CategoryJoystick + * + * SDL joystick support. + * + * This is the lower-level joystick handling. If you want the simpler option, + * where what each button does is well-defined, you should use the gamepad API + * instead. + * + * The term "instance_id" is the current instantiation of a joystick device in + * the system. If the joystick is removed and then re-inserted then it will + * get a new instance_id. instance_id's are monotonically increasing + * identifiers of a joystick plugged in. + * + * The term "player_index" is the number assigned to a player on a specific + * controller. For XInput controllers this returns the XInput user index. Many + * joysticks will not be able to supply this information. + * + * SDL_GUID is used as a stable 128-bit identifier for a joystick device that + * does not change over time. It identifies class of the device (a X360 wired + * controller for example). This identifier is platform dependent. + * + * In order to use these functions, SDL_Init() must have been called with the + * SDL_INIT_JOYSTICK flag. This causes SDL to scan the system for joysticks, + * and load appropriate drivers. + * + * If you would like to receive joystick updates while the application is in + * the background, you should set the following hint before calling + * SDL_Init(): SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS + * + * SDL can provide virtual joysticks as well: the app defines an imaginary + * controller with SDL_AttachVirtualJoystick(), and then can provide inputs + * for it via SDL_SetJoystickVirtualAxis(), SDL_SetJoystickVirtualButton(), + * etc. As this data is supplied, it will look like a normal joystick to SDL, + * just not backed by a hardware driver. This has been used to make unusual + * devices, like VR headset controllers, look like normal joysticks, or + * provide recording/playback of game inputs, etc. + */ + +#ifndef SDL_joystick_h_ +#define SDL_joystick_h_ + +#include +#include +#include +#include +#include +#include +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef SDL_THREAD_SAFETY_ANALYSIS +/* + * This is not an exported symbol from SDL, this is only in the headers to + * help Clang's thread safety analysis tools to function. Do not attempt + * to access this symbol from your app, it will not work! + */ +extern SDL_Mutex *SDL_joystick_lock; +#endif + +/** + * The joystick structure used to identify an SDL joystick. + * + * This is opaque data. + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_Joystick SDL_Joystick; + +/** + * This is a unique ID for a joystick for the time it is connected to the + * system, and is never reused for the lifetime of the application. + * + * If the joystick is disconnected and reconnected, it will get a new ID. + * + * The value 0 is an invalid ID. + * + * \since This datatype is available since SDL 3.2.0. + */ +typedef Uint32 SDL_JoystickID; + +/** + * An enum of some common joystick types. + * + * In some cases, SDL can identify a low-level joystick as being a certain + * type of device, and will report it through SDL_GetJoystickType (or + * SDL_GetJoystickTypeForID). + * + * This is by no means a complete list of everything that can be plugged into + * a computer. + * + * You may refer to + * [XInput Controller Types](https://learn.microsoft.com/en-us/windows/win32/xinput/xinput-and-controller-subtypes) + * table for a general understanding of each joystick type. + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_JoystickType +{ + SDL_JOYSTICK_TYPE_UNKNOWN, + SDL_JOYSTICK_TYPE_GAMEPAD, + SDL_JOYSTICK_TYPE_WHEEL, + SDL_JOYSTICK_TYPE_ARCADE_STICK, + SDL_JOYSTICK_TYPE_FLIGHT_STICK, + SDL_JOYSTICK_TYPE_DANCE_PAD, + SDL_JOYSTICK_TYPE_GUITAR, + SDL_JOYSTICK_TYPE_DRUM_KIT, + SDL_JOYSTICK_TYPE_ARCADE_PAD, + SDL_JOYSTICK_TYPE_THROTTLE, + SDL_JOYSTICK_TYPE_COUNT +} SDL_JoystickType; + +/** + * Possible connection states for a joystick device. + * + * This is used by SDL_GetJoystickConnectionState to report how a device is + * connected to the system. + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_JoystickConnectionState +{ + SDL_JOYSTICK_CONNECTION_INVALID = -1, + SDL_JOYSTICK_CONNECTION_UNKNOWN, + SDL_JOYSTICK_CONNECTION_WIRED, + SDL_JOYSTICK_CONNECTION_WIRELESS +} SDL_JoystickConnectionState; + +/** + * The largest value an SDL_Joystick's axis can report. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_JOYSTICK_AXIS_MIN + */ +#define SDL_JOYSTICK_AXIS_MAX 32767 + +/** + * The smallest value an SDL_Joystick's axis can report. + * + * This is a negative number! + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_JOYSTICK_AXIS_MAX + */ +#define SDL_JOYSTICK_AXIS_MIN -32768 + + +/* Function prototypes */ + +/** + * Locking for atomic access to the joystick API. + * + * The SDL joystick functions are thread-safe, however you can lock the + * joysticks while processing to guarantee that the joystick list won't change + * and joystick and gamepad events will not be delivered. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_LockJoysticks(void) SDL_ACQUIRE(SDL_joystick_lock); + +/** + * Unlocking for atomic access to the joystick API. + * + * \threadsafety This should be called from the same thread that called + * SDL_LockJoysticks(). + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_UnlockJoysticks(void) SDL_RELEASE(SDL_joystick_lock); + +/** + * Return whether a joystick is currently connected. + * + * \returns true if a joystick is connected, false otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetJoysticks + */ +extern SDL_DECLSPEC bool SDLCALL SDL_HasJoystick(void); + +/** + * Get a list of currently connected joysticks. + * + * \param count a pointer filled in with the number of joysticks returned, may + * be NULL. + * \returns a 0 terminated array of joystick instance IDs or NULL on failure; + * call SDL_GetError() for more information. This should be freed + * with SDL_free() when it is no longer needed. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_HasJoystick + * \sa SDL_OpenJoystick + */ +extern SDL_DECLSPEC SDL_JoystickID * SDLCALL SDL_GetJoysticks(int *count); + +/** + * Get the implementation dependent name of a joystick. + * + * This can be called before any joysticks are opened. + * + * \param instance_id the joystick instance ID. + * \returns the name of the selected joystick. If no name can be found, this + * function returns NULL; call SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetJoystickName + * \sa SDL_GetJoysticks + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetJoystickNameForID(SDL_JoystickID instance_id); + +/** + * Get the implementation dependent path of a joystick. + * + * This can be called before any joysticks are opened. + * + * \param instance_id the joystick instance ID. + * \returns the path of the selected joystick. If no path can be found, this + * function returns NULL; call SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetJoystickPath + * \sa SDL_GetJoysticks + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetJoystickPathForID(SDL_JoystickID instance_id); + +/** + * Get the player index of a joystick. + * + * This can be called before any joysticks are opened. + * + * \param instance_id the joystick instance ID. + * \returns the player index of a joystick, or -1 if it's not available. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetJoystickPlayerIndex + * \sa SDL_GetJoysticks + */ +extern SDL_DECLSPEC int SDLCALL SDL_GetJoystickPlayerIndexForID(SDL_JoystickID instance_id); + +/** + * Get the implementation-dependent GUID of a joystick. + * + * This can be called before any joysticks are opened. + * + * \param instance_id the joystick instance ID. + * \returns the GUID of the selected joystick. If called with an invalid + * instance_id, this function returns a zero GUID. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetJoystickGUID + * \sa SDL_GUIDToString + */ +extern SDL_DECLSPEC SDL_GUID SDLCALL SDL_GetJoystickGUIDForID(SDL_JoystickID instance_id); + +/** + * Get the USB vendor ID of a joystick, if available. + * + * This can be called before any joysticks are opened. If the vendor ID isn't + * available this function returns 0. + * + * \param instance_id the joystick instance ID. + * \returns the USB vendor ID of the selected joystick. If called with an + * invalid instance_id, this function returns 0. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetJoystickVendor + * \sa SDL_GetJoysticks + */ +extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetJoystickVendorForID(SDL_JoystickID instance_id); + +/** + * Get the USB product ID of a joystick, if available. + * + * This can be called before any joysticks are opened. If the product ID isn't + * available this function returns 0. + * + * \param instance_id the joystick instance ID. + * \returns the USB product ID of the selected joystick. If called with an + * invalid instance_id, this function returns 0. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetJoystickProduct + * \sa SDL_GetJoysticks + */ +extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetJoystickProductForID(SDL_JoystickID instance_id); + +/** + * Get the product version of a joystick, if available. + * + * This can be called before any joysticks are opened. If the product version + * isn't available this function returns 0. + * + * \param instance_id the joystick instance ID. + * \returns the product version of the selected joystick. If called with an + * invalid instance_id, this function returns 0. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetJoystickProductVersion + * \sa SDL_GetJoysticks + */ +extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetJoystickProductVersionForID(SDL_JoystickID instance_id); + +/** + * Get the type of a joystick, if available. + * + * This can be called before any joysticks are opened. + * + * \param instance_id the joystick instance ID. + * \returns the SDL_JoystickType of the selected joystick. If called with an + * invalid instance_id, this function returns + * `SDL_JOYSTICK_TYPE_UNKNOWN`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetJoystickType + * \sa SDL_GetJoysticks + */ +extern SDL_DECLSPEC SDL_JoystickType SDLCALL SDL_GetJoystickTypeForID(SDL_JoystickID instance_id); + +/** + * Open a joystick for use. + * + * The joystick subsystem must be initialized before a joystick can be opened + * for use. + * + * \param instance_id the joystick instance ID. + * \returns a joystick identifier or NULL on failure; call SDL_GetError() for + * more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CloseJoystick + */ +extern SDL_DECLSPEC SDL_Joystick * SDLCALL SDL_OpenJoystick(SDL_JoystickID instance_id); + +/** + * Get the SDL_Joystick associated with an instance ID, if it has been opened. + * + * \param instance_id the instance ID to get the SDL_Joystick for. + * \returns an SDL_Joystick on success or NULL on failure or if it hasn't been + * opened yet; call SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_Joystick * SDLCALL SDL_GetJoystickFromID(SDL_JoystickID instance_id); + +/** + * Get the SDL_Joystick associated with a player index. + * + * \param player_index the player index to get the SDL_Joystick for. + * \returns an SDL_Joystick on success or NULL on failure; call SDL_GetError() + * for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetJoystickPlayerIndex + * \sa SDL_SetJoystickPlayerIndex + */ +extern SDL_DECLSPEC SDL_Joystick * SDLCALL SDL_GetJoystickFromPlayerIndex(int player_index); + +/** + * The structure that describes a virtual joystick touchpad. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_VirtualJoystickDesc + */ +typedef struct SDL_VirtualJoystickTouchpadDesc +{ + Uint16 nfingers; /**< the number of simultaneous fingers on this touchpad */ + Uint16 padding[3]; +} SDL_VirtualJoystickTouchpadDesc; + +/** + * The structure that describes a virtual joystick sensor. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_VirtualJoystickDesc + */ +typedef struct SDL_VirtualJoystickSensorDesc +{ + SDL_SensorType type; /**< the type of this sensor */ + float rate; /**< the update frequency of this sensor, may be 0.0f */ +} SDL_VirtualJoystickSensorDesc; + +/** + * The structure that describes a virtual joystick. + * + * This structure should be initialized using SDL_INIT_INTERFACE(). All + * elements of this structure are optional. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_AttachVirtualJoystick + * \sa SDL_INIT_INTERFACE + * \sa SDL_VirtualJoystickSensorDesc + * \sa SDL_VirtualJoystickTouchpadDesc + */ +typedef struct SDL_VirtualJoystickDesc +{ + Uint32 version; /**< the version of this interface */ + Uint16 type; /**< `SDL_JoystickType` */ + Uint16 padding; /**< unused */ + Uint16 vendor_id; /**< the USB vendor ID of this joystick */ + Uint16 product_id; /**< the USB product ID of this joystick */ + Uint16 naxes; /**< the number of axes on this joystick */ + Uint16 nbuttons; /**< the number of buttons on this joystick */ + Uint16 nballs; /**< the number of balls on this joystick */ + Uint16 nhats; /**< the number of hats on this joystick */ + Uint16 ntouchpads; /**< the number of touchpads on this joystick, requires `touchpads` to point at valid descriptions */ + Uint16 nsensors; /**< the number of sensors on this joystick, requires `sensors` to point at valid descriptions */ + Uint16 padding2[2]; /**< unused */ + Uint32 button_mask; /**< A mask of which buttons are valid for this controller + e.g. (1 << SDL_GAMEPAD_BUTTON_SOUTH) */ + Uint32 axis_mask; /**< A mask of which axes are valid for this controller + e.g. (1 << SDL_GAMEPAD_AXIS_LEFTX) */ + const char *name; /**< the name of the joystick */ + const SDL_VirtualJoystickTouchpadDesc *touchpads; /**< A pointer to an array of touchpad descriptions, required if `ntouchpads` is > 0 */ + const SDL_VirtualJoystickSensorDesc *sensors; /**< A pointer to an array of sensor descriptions, required if `nsensors` is > 0 */ + + void *userdata; /**< User data pointer passed to callbacks */ + void (SDLCALL *Update)(void *userdata); /**< Called when the joystick state should be updated */ + void (SDLCALL *SetPlayerIndex)(void *userdata, int player_index); /**< Called when the player index is set */ + bool (SDLCALL *Rumble)(void *userdata, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble); /**< Implements SDL_RumbleJoystick() */ + bool (SDLCALL *RumbleTriggers)(void *userdata, Uint16 left_rumble, Uint16 right_rumble); /**< Implements SDL_RumbleJoystickTriggers() */ + bool (SDLCALL *SetLED)(void *userdata, Uint8 red, Uint8 green, Uint8 blue); /**< Implements SDL_SetJoystickLED() */ + bool (SDLCALL *SendEffect)(void *userdata, const void *data, int size); /**< Implements SDL_SendJoystickEffect() */ + bool (SDLCALL *SetSensorsEnabled)(void *userdata, bool enabled); /**< Implements SDL_SetGamepadSensorEnabled() */ + void (SDLCALL *Cleanup)(void *userdata); /**< Cleans up the userdata when the joystick is detached */ +} SDL_VirtualJoystickDesc; + +/* Check the size of SDL_VirtualJoystickDesc + * + * If this assert fails, either the compiler is padding to an unexpected size, + * or the interface has been updated and this should be updated to match and + * the code using this interface should be updated to handle the old version. + */ +SDL_COMPILE_TIME_ASSERT(SDL_VirtualJoystickDesc_SIZE, + (sizeof(void *) == 4 && sizeof(SDL_VirtualJoystickDesc) == 84) || + (sizeof(void *) == 8 && sizeof(SDL_VirtualJoystickDesc) == 136)); + +/** + * Attach a new virtual joystick. + * + * Apps can create virtual joysticks, that exist without hardware directly + * backing them, and have program-supplied inputs. Once attached, a virtual + * joystick looks like any other joystick that SDL can access. These can be + * used to make other things look like joysticks, or provide pre-recorded + * input, etc. + * + * Once attached, the app can send joystick inputs to the new virtual joystick + * using SDL_SetJoystickVirtualAxis(), etc. + * + * When no longer needed, the virtual joystick can be removed by calling + * SDL_DetachVirtualJoystick(). + * + * \param desc joystick description, initialized using SDL_INIT_INTERFACE(). + * \returns the joystick instance ID, or 0 on failure; call SDL_GetError() for + * more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_DetachVirtualJoystick + * \sa SDL_SetJoystickVirtualAxis + * \sa SDL_SetJoystickVirtualButton + * \sa SDL_SetJoystickVirtualBall + * \sa SDL_SetJoystickVirtualHat + * \sa SDL_SetJoystickVirtualTouchpad + * \sa SDL_SetJoystickVirtualSensorData + */ +extern SDL_DECLSPEC SDL_JoystickID SDLCALL SDL_AttachVirtualJoystick(const SDL_VirtualJoystickDesc *desc); + +/** + * Detach a virtual joystick. + * + * \param instance_id the joystick instance ID, previously returned from + * SDL_AttachVirtualJoystick(). + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_AttachVirtualJoystick + */ +extern SDL_DECLSPEC bool SDLCALL SDL_DetachVirtualJoystick(SDL_JoystickID instance_id); + +/** + * Query whether or not a joystick is virtual. + * + * \param instance_id the joystick instance ID. + * \returns true if the joystick is virtual, false otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_IsJoystickVirtual(SDL_JoystickID instance_id); + +/** + * Set the state of an axis on an opened virtual joystick. + * + * Please note that values set here will not be applied until the next call to + * SDL_UpdateJoysticks, which can either be called directly, or can be called + * indirectly through various other SDL APIs, including, but not limited to + * the following: SDL_PollEvent, SDL_PumpEvents, SDL_WaitEventTimeout, + * SDL_WaitEvent. + * + * Note that when sending trigger axes, you should scale the value to the full + * range of Sint16. For example, a trigger at rest would have the value of + * `SDL_JOYSTICK_AXIS_MIN`. + * + * \param joystick the virtual joystick on which to set state. + * \param axis the index of the axis on the virtual joystick to update. + * \param value the new value for the specified axis. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetJoystickVirtualButton + * \sa SDL_SetJoystickVirtualBall + * \sa SDL_SetJoystickVirtualHat + * \sa SDL_SetJoystickVirtualTouchpad + * \sa SDL_SetJoystickVirtualSensorData + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetJoystickVirtualAxis(SDL_Joystick *joystick, int axis, Sint16 value); + +/** + * Generate ball motion on an opened virtual joystick. + * + * Please note that values set here will not be applied until the next call to + * SDL_UpdateJoysticks, which can either be called directly, or can be called + * indirectly through various other SDL APIs, including, but not limited to + * the following: SDL_PollEvent, SDL_PumpEvents, SDL_WaitEventTimeout, + * SDL_WaitEvent. + * + * \param joystick the virtual joystick on which to set state. + * \param ball the index of the ball on the virtual joystick to update. + * \param xrel the relative motion on the X axis. + * \param yrel the relative motion on the Y axis. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetJoystickVirtualAxis + * \sa SDL_SetJoystickVirtualButton + * \sa SDL_SetJoystickVirtualHat + * \sa SDL_SetJoystickVirtualTouchpad + * \sa SDL_SetJoystickVirtualSensorData + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetJoystickVirtualBall(SDL_Joystick *joystick, int ball, Sint16 xrel, Sint16 yrel); + +/** + * Set the state of a button on an opened virtual joystick. + * + * Please note that values set here will not be applied until the next call to + * SDL_UpdateJoysticks, which can either be called directly, or can be called + * indirectly through various other SDL APIs, including, but not limited to + * the following: SDL_PollEvent, SDL_PumpEvents, SDL_WaitEventTimeout, + * SDL_WaitEvent. + * + * \param joystick the virtual joystick on which to set state. + * \param button the index of the button on the virtual joystick to update. + * \param down true if the button is pressed, false otherwise. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetJoystickVirtualAxis + * \sa SDL_SetJoystickVirtualBall + * \sa SDL_SetJoystickVirtualHat + * \sa SDL_SetJoystickVirtualTouchpad + * \sa SDL_SetJoystickVirtualSensorData + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetJoystickVirtualButton(SDL_Joystick *joystick, int button, bool down); + +/** + * Set the state of a hat on an opened virtual joystick. + * + * Please note that values set here will not be applied until the next call to + * SDL_UpdateJoysticks, which can either be called directly, or can be called + * indirectly through various other SDL APIs, including, but not limited to + * the following: SDL_PollEvent, SDL_PumpEvents, SDL_WaitEventTimeout, + * SDL_WaitEvent. + * + * \param joystick the virtual joystick on which to set state. + * \param hat the index of the hat on the virtual joystick to update. + * \param value the new value for the specified hat. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetJoystickVirtualAxis + * \sa SDL_SetJoystickVirtualButton + * \sa SDL_SetJoystickVirtualBall + * \sa SDL_SetJoystickVirtualTouchpad + * \sa SDL_SetJoystickVirtualSensorData + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetJoystickVirtualHat(SDL_Joystick *joystick, int hat, Uint8 value); + +/** + * Set touchpad finger state on an opened virtual joystick. + * + * Please note that values set here will not be applied until the next call to + * SDL_UpdateJoysticks, which can either be called directly, or can be called + * indirectly through various other SDL APIs, including, but not limited to + * the following: SDL_PollEvent, SDL_PumpEvents, SDL_WaitEventTimeout, + * SDL_WaitEvent. + * + * \param joystick the virtual joystick on which to set state. + * \param touchpad the index of the touchpad on the virtual joystick to + * update. + * \param finger the index of the finger on the touchpad to set. + * \param down true if the finger is pressed, false if the finger is released. + * \param x the x coordinate of the finger on the touchpad, normalized 0 to 1, + * with the origin in the upper left. + * \param y the y coordinate of the finger on the touchpad, normalized 0 to 1, + * with the origin in the upper left. + * \param pressure the pressure of the finger. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetJoystickVirtualAxis + * \sa SDL_SetJoystickVirtualButton + * \sa SDL_SetJoystickVirtualBall + * \sa SDL_SetJoystickVirtualHat + * \sa SDL_SetJoystickVirtualSensorData + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetJoystickVirtualTouchpad(SDL_Joystick *joystick, int touchpad, int finger, bool down, float x, float y, float pressure); + +/** + * Send a sensor update for an opened virtual joystick. + * + * Please note that values set here will not be applied until the next call to + * SDL_UpdateJoysticks, which can either be called directly, or can be called + * indirectly through various other SDL APIs, including, but not limited to + * the following: SDL_PollEvent, SDL_PumpEvents, SDL_WaitEventTimeout, + * SDL_WaitEvent. + * + * \param joystick the virtual joystick on which to set state. + * \param type the type of the sensor on the virtual joystick to update. + * \param sensor_timestamp a 64-bit timestamp in nanoseconds associated with + * the sensor reading. + * \param data the data associated with the sensor reading. + * \param num_values the number of values pointed to by `data`. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetJoystickVirtualAxis + * \sa SDL_SetJoystickVirtualButton + * \sa SDL_SetJoystickVirtualBall + * \sa SDL_SetJoystickVirtualHat + * \sa SDL_SetJoystickVirtualTouchpad + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SendJoystickVirtualSensorData(SDL_Joystick *joystick, SDL_SensorType type, Uint64 sensor_timestamp, const float *data, int num_values); + +/** + * Get the properties associated with a joystick. + * + * The following read-only properties are provided by SDL: + * + * - `SDL_PROP_JOYSTICK_CAP_MONO_LED_BOOLEAN`: true if this joystick has an + * LED that has adjustable brightness + * - `SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN`: true if this joystick has an LED + * that has adjustable color + * - `SDL_PROP_JOYSTICK_CAP_PLAYER_LED_BOOLEAN`: true if this joystick has a + * player LED + * - `SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN`: true if this joystick has + * left/right rumble + * - `SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN`: true if this joystick has + * simple trigger rumble + * + * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick(). + * \returns a valid property ID on success or 0 on failure; call + * SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetJoystickProperties(SDL_Joystick *joystick); + +#define SDL_PROP_JOYSTICK_CAP_MONO_LED_BOOLEAN "SDL.joystick.cap.mono_led" +#define SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN "SDL.joystick.cap.rgb_led" +#define SDL_PROP_JOYSTICK_CAP_PLAYER_LED_BOOLEAN "SDL.joystick.cap.player_led" +#define SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN "SDL.joystick.cap.rumble" +#define SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN "SDL.joystick.cap.trigger_rumble" + +/** + * Get the implementation dependent name of a joystick. + * + * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick(). + * \returns the name of the selected joystick. If no name can be found, this + * function returns NULL; call SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetJoystickNameForID + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetJoystickName(SDL_Joystick *joystick); + +/** + * Get the implementation dependent path of a joystick. + * + * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick(). + * \returns the path of the selected joystick. If no path can be found, this + * function returns NULL; call SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetJoystickPathForID + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetJoystickPath(SDL_Joystick *joystick); + +/** + * Get the player index of an opened joystick. + * + * For XInput controllers this returns the XInput user index. Many joysticks + * will not be able to supply this information. + * + * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick(). + * \returns the player index, or -1 if it's not available. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetJoystickPlayerIndex + */ +extern SDL_DECLSPEC int SDLCALL SDL_GetJoystickPlayerIndex(SDL_Joystick *joystick); + +/** + * Set the player index of an opened joystick. + * + * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick(). + * \param player_index player index to assign to this joystick, or -1 to clear + * the player index and turn off player LEDs. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetJoystickPlayerIndex + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetJoystickPlayerIndex(SDL_Joystick *joystick, int player_index); + +/** + * Get the implementation-dependent GUID for the joystick. + * + * This function requires an open joystick. + * + * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick(). + * \returns the GUID of the given joystick. If called on an invalid index, + * this function returns a zero GUID; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetJoystickGUIDForID + * \sa SDL_GUIDToString + */ +extern SDL_DECLSPEC SDL_GUID SDLCALL SDL_GetJoystickGUID(SDL_Joystick *joystick); + +/** + * Get the USB vendor ID of an opened joystick, if available. + * + * If the vendor ID isn't available this function returns 0. + * + * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick(). + * \returns the USB vendor ID of the selected joystick, or 0 if unavailable. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetJoystickVendorForID + */ +extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetJoystickVendor(SDL_Joystick *joystick); + +/** + * Get the USB product ID of an opened joystick, if available. + * + * If the product ID isn't available this function returns 0. + * + * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick(). + * \returns the USB product ID of the selected joystick, or 0 if unavailable. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetJoystickProductForID + */ +extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetJoystickProduct(SDL_Joystick *joystick); + +/** + * Get the product version of an opened joystick, if available. + * + * If the product version isn't available this function returns 0. + * + * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick(). + * \returns the product version of the selected joystick, or 0 if unavailable. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetJoystickProductVersionForID + */ +extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetJoystickProductVersion(SDL_Joystick *joystick); + +/** + * Get the firmware version of an opened joystick, if available. + * + * If the firmware version isn't available this function returns 0. + * + * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick(). + * \returns the firmware version of the selected joystick, or 0 if + * unavailable. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetJoystickFirmwareVersion(SDL_Joystick *joystick); + +/** + * Get the serial number of an opened joystick, if available. + * + * Returns the serial number of the joystick, or NULL if it is not available. + * + * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick(). + * \returns the serial number of the selected joystick, or NULL if + * unavailable. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetJoystickSerial(SDL_Joystick *joystick); + +/** + * Get the type of an opened joystick. + * + * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick(). + * \returns the SDL_JoystickType of the selected joystick. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetJoystickTypeForID + */ +extern SDL_DECLSPEC SDL_JoystickType SDLCALL SDL_GetJoystickType(SDL_Joystick *joystick); + +/** + * Get the device information encoded in a SDL_GUID structure. + * + * \param guid the SDL_GUID you wish to get info about. + * \param vendor a pointer filled in with the device VID, or 0 if not + * available. + * \param product a pointer filled in with the device PID, or 0 if not + * available. + * \param version a pointer filled in with the device version, or 0 if not + * available. + * \param crc16 a pointer filled in with a CRC used to distinguish different + * products with the same VID/PID, or 0 if not available. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetJoystickGUIDForID + */ +extern SDL_DECLSPEC void SDLCALL SDL_GetJoystickGUIDInfo(SDL_GUID guid, Uint16 *vendor, Uint16 *product, Uint16 *version, Uint16 *crc16); + +/** + * Get the status of a specified joystick. + * + * \param joystick the joystick to query. + * \returns true if the joystick has been opened, false if it has not; call + * SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_JoystickConnected(SDL_Joystick *joystick); + +/** + * Get the instance ID of an opened joystick. + * + * \param joystick an SDL_Joystick structure containing joystick information. + * \returns the instance ID of the specified joystick on success or 0 on + * failure; call SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_JoystickID SDLCALL SDL_GetJoystickID(SDL_Joystick *joystick); + +/** + * Get the number of general axis controls on a joystick. + * + * Often, the directional pad on a game controller will either look like 4 + * separate buttons or a POV hat, and not axes, but all of this is up to the + * device and platform. + * + * \param joystick an SDL_Joystick structure containing joystick information. + * \returns the number of axis controls/number of axes on success or -1 on + * failure; call SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetJoystickAxis + * \sa SDL_GetNumJoystickBalls + * \sa SDL_GetNumJoystickButtons + * \sa SDL_GetNumJoystickHats + */ +extern SDL_DECLSPEC int SDLCALL SDL_GetNumJoystickAxes(SDL_Joystick *joystick); + +/** + * Get the number of trackballs on a joystick. + * + * Joystick trackballs have only relative motion events associated with them + * and their state cannot be polled. + * + * Most joysticks do not have trackballs. + * + * \param joystick an SDL_Joystick structure containing joystick information. + * \returns the number of trackballs on success or -1 on failure; call + * SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetJoystickBall + * \sa SDL_GetNumJoystickAxes + * \sa SDL_GetNumJoystickButtons + * \sa SDL_GetNumJoystickHats + */ +extern SDL_DECLSPEC int SDLCALL SDL_GetNumJoystickBalls(SDL_Joystick *joystick); + +/** + * Get the number of POV hats on a joystick. + * + * \param joystick an SDL_Joystick structure containing joystick information. + * \returns the number of POV hats on success or -1 on failure; call + * SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetJoystickHat + * \sa SDL_GetNumJoystickAxes + * \sa SDL_GetNumJoystickBalls + * \sa SDL_GetNumJoystickButtons + */ +extern SDL_DECLSPEC int SDLCALL SDL_GetNumJoystickHats(SDL_Joystick *joystick); + +/** + * Get the number of buttons on a joystick. + * + * \param joystick an SDL_Joystick structure containing joystick information. + * \returns the number of buttons on success or -1 on failure; call + * SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetJoystickButton + * \sa SDL_GetNumJoystickAxes + * \sa SDL_GetNumJoystickBalls + * \sa SDL_GetNumJoystickHats + */ +extern SDL_DECLSPEC int SDLCALL SDL_GetNumJoystickButtons(SDL_Joystick *joystick); + +/** + * Set the state of joystick event processing. + * + * If joystick events are disabled, you must call SDL_UpdateJoysticks() + * yourself and check the state of the joystick when you want joystick + * information. + * + * \param enabled whether to process joystick events or not. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_JoystickEventsEnabled + * \sa SDL_UpdateJoysticks + */ +extern SDL_DECLSPEC void SDLCALL SDL_SetJoystickEventsEnabled(bool enabled); + +/** + * Query the state of joystick event processing. + * + * If joystick events are disabled, you must call SDL_UpdateJoysticks() + * yourself and check the state of the joystick when you want joystick + * information. + * + * \returns true if joystick events are being processed, false otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetJoystickEventsEnabled + */ +extern SDL_DECLSPEC bool SDLCALL SDL_JoystickEventsEnabled(void); + +/** + * Update the current state of the open joysticks. + * + * This is called automatically by the event loop if any joystick events are + * enabled. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_UpdateJoysticks(void); + +/** + * Get the current state of an axis control on a joystick. + * + * SDL makes no promises about what part of the joystick any given axis refers + * to. Your game should have some sort of configuration UI to let users + * specify what each axis should be bound to. Alternately, SDL's higher-level + * Game Controller API makes a great effort to apply order to this lower-level + * interface, so you know that a specific axis is the "left thumb stick," etc. + * + * The value returned by SDL_GetJoystickAxis() is a signed integer (-32768 to + * 32767) representing the current position of the axis. It may be necessary + * to impose certain tolerances on these values to account for jitter. + * + * \param joystick an SDL_Joystick structure containing joystick information. + * \param axis the axis to query; the axis indices start at index 0. + * \returns a 16-bit signed integer representing the current position of the + * axis or 0 on failure; call SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetNumJoystickAxes + */ +extern SDL_DECLSPEC Sint16 SDLCALL SDL_GetJoystickAxis(SDL_Joystick *joystick, int axis); + +/** + * Get the initial state of an axis control on a joystick. + * + * The state is a value ranging from -32768 to 32767. + * + * The axis indices start at index 0. + * + * \param joystick an SDL_Joystick structure containing joystick information. + * \param axis the axis to query; the axis indices start at index 0. + * \param state upon return, the initial value is supplied here. + * \returns true if this axis has any initial value, or false if not. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetJoystickAxisInitialState(SDL_Joystick *joystick, int axis, Sint16 *state); + +/** + * Get the ball axis change since the last poll. + * + * Trackballs can only return relative motion since the last call to + * SDL_GetJoystickBall(), these motion deltas are placed into `dx` and `dy`. + * + * Most joysticks do not have trackballs. + * + * \param joystick the SDL_Joystick to query. + * \param ball the ball index to query; ball indices start at index 0. + * \param dx stores the difference in the x axis position since the last poll. + * \param dy stores the difference in the y axis position since the last poll. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetNumJoystickBalls + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetJoystickBall(SDL_Joystick *joystick, int ball, int *dx, int *dy); + +/** + * Get the current state of a POV hat on a joystick. + * + * The returned value will be one of the `SDL_HAT_*` values. + * + * \param joystick an SDL_Joystick structure containing joystick information. + * \param hat the hat index to get the state from; indices start at index 0. + * \returns the current hat position. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetNumJoystickHats + */ +extern SDL_DECLSPEC Uint8 SDLCALL SDL_GetJoystickHat(SDL_Joystick *joystick, int hat); + +#define SDL_HAT_CENTERED 0x00u +#define SDL_HAT_UP 0x01u +#define SDL_HAT_RIGHT 0x02u +#define SDL_HAT_DOWN 0x04u +#define SDL_HAT_LEFT 0x08u +#define SDL_HAT_RIGHTUP (SDL_HAT_RIGHT|SDL_HAT_UP) +#define SDL_HAT_RIGHTDOWN (SDL_HAT_RIGHT|SDL_HAT_DOWN) +#define SDL_HAT_LEFTUP (SDL_HAT_LEFT|SDL_HAT_UP) +#define SDL_HAT_LEFTDOWN (SDL_HAT_LEFT|SDL_HAT_DOWN) + +/** + * Get the current state of a button on a joystick. + * + * \param joystick an SDL_Joystick structure containing joystick information. + * \param button the button index to get the state from; indices start at + * index 0. + * \returns true if the button is pressed, false otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetNumJoystickButtons + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetJoystickButton(SDL_Joystick *joystick, int button); + +/** + * Start a rumble effect. + * + * Each call to this function cancels any previous rumble effect, and calling + * it with 0 intensity stops any rumbling. + * + * This function requires you to process SDL events or call + * SDL_UpdateJoysticks() to update rumble state. + * + * \param joystick the joystick to vibrate. + * \param low_frequency_rumble the intensity of the low frequency (left) + * rumble motor, from 0 to 0xFFFF. + * \param high_frequency_rumble the intensity of the high frequency (right) + * rumble motor, from 0 to 0xFFFF. + * \param duration_ms the duration of the rumble effect, in milliseconds. + * \returns true, or false if rumble isn't supported on this joystick. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_RumbleJoystick(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms); + +/** + * Start a rumble effect in the joystick's triggers. + * + * Each call to this function cancels any previous trigger rumble effect, and + * calling it with 0 intensity stops any rumbling. + * + * Note that this is rumbling of the _triggers_ and not the game controller as + * a whole. This is currently only supported on Xbox One controllers. If you + * want the (more common) whole-controller rumble, use SDL_RumbleJoystick() + * instead. + * + * This function requires you to process SDL events or call + * SDL_UpdateJoysticks() to update rumble state. + * + * \param joystick the joystick to vibrate. + * \param left_rumble the intensity of the left trigger rumble motor, from 0 + * to 0xFFFF. + * \param right_rumble the intensity of the right trigger rumble motor, from 0 + * to 0xFFFF. + * \param duration_ms the duration of the rumble effect, in milliseconds. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_RumbleJoystick + */ +extern SDL_DECLSPEC bool SDLCALL SDL_RumbleJoystickTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms); + +/** + * Update a joystick's LED color. + * + * An example of a joystick LED is the light on the back of a PlayStation 4's + * DualShock 4 controller. + * + * For joysticks with a single color LED, the maximum of the RGB values will + * be used as the LED brightness. + * + * \param joystick the joystick to update. + * \param red the intensity of the red LED. + * \param green the intensity of the green LED. + * \param blue the intensity of the blue LED. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetJoystickLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue); + +/** + * Send a joystick specific effect packet. + * + * \param joystick the joystick to affect. + * \param data the data to send to the joystick. + * \param size the size of the data to send to the joystick. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SendJoystickEffect(SDL_Joystick *joystick, const void *data, int size); + +/** + * Close a joystick previously opened with SDL_OpenJoystick(). + * + * \param joystick the joystick device to close. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_OpenJoystick + */ +extern SDL_DECLSPEC void SDLCALL SDL_CloseJoystick(SDL_Joystick *joystick); + +/** + * Get the connection state of a joystick. + * + * \param joystick the joystick to query. + * \returns the connection state on success or + * `SDL_JOYSTICK_CONNECTION_INVALID` on failure; call SDL_GetError() + * for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_JoystickConnectionState SDLCALL SDL_GetJoystickConnectionState(SDL_Joystick *joystick); + +/** + * Get the battery state of a joystick. + * + * You should never take a battery status as absolute truth. Batteries + * (especially failing batteries) are delicate hardware, and the values + * reported here are best estimates based on what that hardware reports. It's + * not uncommon for older batteries to lose stored power much faster than it + * reports, or completely drain when reporting it has 20 percent left, etc. + * + * \param joystick the joystick to query. + * \param percent a pointer filled in with the percentage of battery life + * left, between 0 and 100, or NULL to ignore. This will be + * filled in with -1 we can't determine a value or there is no + * battery. + * \returns the current battery state or `SDL_POWERSTATE_ERROR` on failure; + * call SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_PowerState SDLCALL SDL_GetJoystickPowerInfo(SDL_Joystick *joystick, int *percent); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_joystick_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_keyboard.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_keyboard.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,608 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * # CategoryKeyboard + * + * SDL keyboard management. + * + * Please refer to the Best Keyboard Practices document for details on how + * best to accept keyboard input in various types of programs: + * + * https://wiki.libsdl.org/SDL3/BestKeyboardPractices + */ + +#ifndef SDL_keyboard_h_ +#define SDL_keyboard_h_ + +#include +#include +#include +#include +#include +#include +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * This is a unique ID for a keyboard for the time it is connected to the + * system, and is never reused for the lifetime of the application. + * + * If the keyboard is disconnected and reconnected, it will get a new ID. + * + * The value 0 is an invalid ID. + * + * \since This datatype is available since SDL 3.2.0. + */ +typedef Uint32 SDL_KeyboardID; + +/* Function prototypes */ + +/** + * Return whether a keyboard is currently connected. + * + * \returns true if a keyboard is connected, false otherwise. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetKeyboards + */ +extern SDL_DECLSPEC bool SDLCALL SDL_HasKeyboard(void); + +/** + * Get a list of currently connected keyboards. + * + * Note that this will include any device or virtual driver that includes + * keyboard functionality, including some mice, KVM switches, motherboard + * power buttons, etc. You should wait for input from a device before you + * consider it actively in use. + * + * \param count a pointer filled in with the number of keyboards returned, may + * be NULL. + * \returns a 0 terminated array of keyboards instance IDs or NULL on failure; + * call SDL_GetError() for more information. This should be freed + * with SDL_free() when it is no longer needed. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetKeyboardNameForID + * \sa SDL_HasKeyboard + */ +extern SDL_DECLSPEC SDL_KeyboardID * SDLCALL SDL_GetKeyboards(int *count); + +/** + * Get the name of a keyboard. + * + * This function returns "" if the keyboard doesn't have a name. + * + * \param instance_id the keyboard instance ID. + * \returns the name of the selected keyboard or NULL on failure; call + * SDL_GetError() for more information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetKeyboards + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetKeyboardNameForID(SDL_KeyboardID instance_id); + +/** + * Query the window which currently has keyboard focus. + * + * \returns the window with keyboard focus. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetKeyboardFocus(void); + +/** + * Get a snapshot of the current state of the keyboard. + * + * The pointer returned is a pointer to an internal SDL array. It will be + * valid for the whole lifetime of the application and should not be freed by + * the caller. + * + * A array element with a value of true means that the key is pressed and a + * value of false means that it is not. Indexes into this array are obtained + * by using SDL_Scancode values. + * + * Use SDL_PumpEvents() to update the state array. + * + * This function gives you the current state after all events have been + * processed, so if a key or button has been pressed and released before you + * process events, then the pressed state will never show up in the + * SDL_GetKeyboardState() calls. + * + * Note: This function doesn't take into account whether shift has been + * pressed or not. + * + * \param numkeys if non-NULL, receives the length of the returned array. + * \returns a pointer to an array of key states. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_PumpEvents + * \sa SDL_ResetKeyboard + */ +extern SDL_DECLSPEC const bool * SDLCALL SDL_GetKeyboardState(int *numkeys); + +/** + * Clear the state of the keyboard. + * + * This function will generate key up events for all pressed keys. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetKeyboardState + */ +extern SDL_DECLSPEC void SDLCALL SDL_ResetKeyboard(void); + +/** + * Get the current key modifier state for the keyboard. + * + * \returns an OR'd combination of the modifier keys for the keyboard. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetKeyboardState + * \sa SDL_SetModState + */ +extern SDL_DECLSPEC SDL_Keymod SDLCALL SDL_GetModState(void); + +/** + * Set the current key modifier state for the keyboard. + * + * The inverse of SDL_GetModState(), SDL_SetModState() allows you to impose + * modifier key states on your application. Simply pass your desired modifier + * states into `modstate`. This value may be a bitwise, OR'd combination of + * SDL_Keymod values. + * + * This does not change the keyboard state, only the key modifier flags that + * SDL reports. + * + * \param modstate the desired SDL_Keymod for the keyboard. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetModState + */ +extern SDL_DECLSPEC void SDLCALL SDL_SetModState(SDL_Keymod modstate); + +/** + * Get the key code corresponding to the given scancode according to the + * current keyboard layout. + * + * If you want to get the keycode as it would be delivered in key events, + * including options specified in SDL_HINT_KEYCODE_OPTIONS, then you should + * pass `key_event` as true. Otherwise this function simply translates the + * scancode based on the given modifier state. + * + * \param scancode the desired SDL_Scancode to query. + * \param modstate the modifier state to use when translating the scancode to + * a keycode. + * \param key_event true if the keycode will be used in key events. + * \returns the SDL_Keycode that corresponds to the given SDL_Scancode. + * + * \threadsafety This function is not thread safe. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetKeyName + * \sa SDL_GetScancodeFromKey + */ +extern SDL_DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromScancode(SDL_Scancode scancode, SDL_Keymod modstate, bool key_event); + +/** + * Get the scancode corresponding to the given key code according to the + * current keyboard layout. + * + * Note that there may be multiple scancode+modifier states that can generate + * this keycode, this will just return the first one found. + * + * \param key the desired SDL_Keycode to query. + * \param modstate a pointer to the modifier state that would be used when the + * scancode generates this key, may be NULL. + * \returns the SDL_Scancode that corresponds to the given SDL_Keycode. + * + * \threadsafety This function is not thread safe. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetKeyFromScancode + * \sa SDL_GetScancodeName + */ +extern SDL_DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromKey(SDL_Keycode key, SDL_Keymod *modstate); + +/** + * Set a human-readable name for a scancode. + * + * \param scancode the desired SDL_Scancode. + * \param name the name to use for the scancode, encoded as UTF-8. The string + * is not copied, so the pointer given to this function must stay + * valid while SDL is being used. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function is not thread safe. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetScancodeName + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetScancodeName(SDL_Scancode scancode, const char *name); + +/** + * Get a human-readable name for a scancode. + * + * **Warning**: The returned name is by design not stable across platforms, + * e.g. the name for `SDL_SCANCODE_LGUI` is "Left GUI" under Linux but "Left + * Windows" under Microsoft Windows, and some scancodes like + * `SDL_SCANCODE_NONUSBACKSLASH` don't have any name at all. There are even + * scancodes that share names, e.g. `SDL_SCANCODE_RETURN` and + * `SDL_SCANCODE_RETURN2` (both called "Return"). This function is therefore + * unsuitable for creating a stable cross-platform two-way mapping between + * strings and scancodes. + * + * \param scancode the desired SDL_Scancode to query. + * \returns a pointer to the name for the scancode. If the scancode doesn't + * have a name this function returns an empty string (""). + * + * \threadsafety This function is not thread safe. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetScancodeFromKey + * \sa SDL_GetScancodeFromName + * \sa SDL_SetScancodeName + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetScancodeName(SDL_Scancode scancode); + +/** + * Get a scancode from a human-readable name. + * + * \param name the human-readable scancode name. + * \returns the SDL_Scancode, or `SDL_SCANCODE_UNKNOWN` if the name wasn't + * recognized; call SDL_GetError() for more information. + * + * \threadsafety This function is not thread safe. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetKeyFromName + * \sa SDL_GetScancodeFromKey + * \sa SDL_GetScancodeName + */ +extern SDL_DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromName(const char *name); + +/** + * Get a human-readable name for a key. + * + * If the key doesn't have a name, this function returns an empty string (""). + * + * Letters will be presented in their uppercase form, if applicable. + * + * \param key the desired SDL_Keycode to query. + * \returns a UTF-8 encoded string of the key name. + * + * \threadsafety This function is not thread safe. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetKeyFromName + * \sa SDL_GetKeyFromScancode + * \sa SDL_GetScancodeFromKey + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetKeyName(SDL_Keycode key); + +/** + * Get a key code from a human-readable name. + * + * \param name the human-readable key name. + * \returns key code, or `SDLK_UNKNOWN` if the name wasn't recognized; call + * SDL_GetError() for more information. + * + * \threadsafety This function is not thread safe. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetKeyFromScancode + * \sa SDL_GetKeyName + * \sa SDL_GetScancodeFromName + */ +extern SDL_DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromName(const char *name); + +/** + * Start accepting Unicode text input events in a window. + * + * This function will enable text input (SDL_EVENT_TEXT_INPUT and + * SDL_EVENT_TEXT_EDITING events) in the specified window. Please use this + * function paired with SDL_StopTextInput(). + * + * Text input events are not received by default. + * + * On some platforms using this function shows the screen keyboard and/or + * activates an IME, which can prevent some key press events from being passed + * through. + * + * \param window the window to enable text input. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetTextInputArea + * \sa SDL_StartTextInputWithProperties + * \sa SDL_StopTextInput + * \sa SDL_TextInputActive + */ +extern SDL_DECLSPEC bool SDLCALL SDL_StartTextInput(SDL_Window *window); + +/** + * Text input type. + * + * These are the valid values for SDL_PROP_TEXTINPUT_TYPE_NUMBER. Not every + * value is valid on every platform, but where a value isn't supported, a + * reasonable fallback will be used. + * + * \since This enum is available since SDL 3.2.0. + * + * \sa SDL_StartTextInputWithProperties + */ +typedef enum SDL_TextInputType +{ + SDL_TEXTINPUT_TYPE_TEXT, /**< The input is text */ + SDL_TEXTINPUT_TYPE_TEXT_NAME, /**< The input is a person's name */ + SDL_TEXTINPUT_TYPE_TEXT_EMAIL, /**< The input is an e-mail address */ + SDL_TEXTINPUT_TYPE_TEXT_USERNAME, /**< The input is a username */ + SDL_TEXTINPUT_TYPE_TEXT_PASSWORD_HIDDEN, /**< The input is a secure password that is hidden */ + SDL_TEXTINPUT_TYPE_TEXT_PASSWORD_VISIBLE, /**< The input is a secure password that is visible */ + SDL_TEXTINPUT_TYPE_NUMBER, /**< The input is a number */ + SDL_TEXTINPUT_TYPE_NUMBER_PASSWORD_HIDDEN, /**< The input is a secure PIN that is hidden */ + SDL_TEXTINPUT_TYPE_NUMBER_PASSWORD_VISIBLE /**< The input is a secure PIN that is visible */ +} SDL_TextInputType; + +/** + * Auto capitalization type. + * + * These are the valid values for SDL_PROP_TEXTINPUT_CAPITALIZATION_NUMBER. + * Not every value is valid on every platform, but where a value isn't + * supported, a reasonable fallback will be used. + * + * \since This enum is available since SDL 3.2.0. + * + * \sa SDL_StartTextInputWithProperties + */ +typedef enum SDL_Capitalization +{ + SDL_CAPITALIZE_NONE, /**< No auto-capitalization will be done */ + SDL_CAPITALIZE_SENTENCES, /**< The first letter of sentences will be capitalized */ + SDL_CAPITALIZE_WORDS, /**< The first letter of words will be capitalized */ + SDL_CAPITALIZE_LETTERS /**< All letters will be capitalized */ +} SDL_Capitalization; + +/** + * Start accepting Unicode text input events in a window, with properties + * describing the input. + * + * This function will enable text input (SDL_EVENT_TEXT_INPUT and + * SDL_EVENT_TEXT_EDITING events) in the specified window. Please use this + * function paired with SDL_StopTextInput(). + * + * Text input events are not received by default. + * + * On some platforms using this function shows the screen keyboard and/or + * activates an IME, which can prevent some key press events from being passed + * through. + * + * These are the supported properties: + * + * - `SDL_PROP_TEXTINPUT_TYPE_NUMBER` - an SDL_TextInputType value that + * describes text being input, defaults to SDL_TEXTINPUT_TYPE_TEXT. + * - `SDL_PROP_TEXTINPUT_CAPITALIZATION_NUMBER` - an SDL_Capitalization value + * that describes how text should be capitalized, defaults to + * SDL_CAPITALIZE_SENTENCES for normal text entry, SDL_CAPITALIZE_WORDS for + * SDL_TEXTINPUT_TYPE_TEXT_NAME, and SDL_CAPITALIZE_NONE for e-mail + * addresses, usernames, and passwords. + * - `SDL_PROP_TEXTINPUT_AUTOCORRECT_BOOLEAN` - true to enable auto completion + * and auto correction, defaults to true. + * - `SDL_PROP_TEXTINPUT_MULTILINE_BOOLEAN` - true if multiple lines of text + * are allowed. This defaults to true if SDL_HINT_RETURN_KEY_HIDES_IME is + * "0" or is not set, and defaults to false if SDL_HINT_RETURN_KEY_HIDES_IME + * is "1". + * + * On Android you can directly specify the input type: + * + * - `SDL_PROP_TEXTINPUT_ANDROID_INPUTTYPE_NUMBER` - the text input type to + * use, overriding other properties. This is documented at + * https://developer.android.com/reference/android/text/InputType + * + * \param window the window to enable text input. + * \param props the properties to use. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetTextInputArea + * \sa SDL_StartTextInput + * \sa SDL_StopTextInput + * \sa SDL_TextInputActive + */ +extern SDL_DECLSPEC bool SDLCALL SDL_StartTextInputWithProperties(SDL_Window *window, SDL_PropertiesID props); + +#define SDL_PROP_TEXTINPUT_TYPE_NUMBER "SDL.textinput.type" +#define SDL_PROP_TEXTINPUT_CAPITALIZATION_NUMBER "SDL.textinput.capitalization" +#define SDL_PROP_TEXTINPUT_AUTOCORRECT_BOOLEAN "SDL.textinput.autocorrect" +#define SDL_PROP_TEXTINPUT_MULTILINE_BOOLEAN "SDL.textinput.multiline" +#define SDL_PROP_TEXTINPUT_ANDROID_INPUTTYPE_NUMBER "SDL.textinput.android.inputtype" + +/** + * Check whether or not Unicode text input events are enabled for a window. + * + * \param window the window to check. + * \returns true if text input events are enabled else false. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_StartTextInput + */ +extern SDL_DECLSPEC bool SDLCALL SDL_TextInputActive(SDL_Window *window); + +/** + * Stop receiving any text input events in a window. + * + * If SDL_StartTextInput() showed the screen keyboard, this function will hide + * it. + * + * \param window the window to disable text input. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_StartTextInput + */ +extern SDL_DECLSPEC bool SDLCALL SDL_StopTextInput(SDL_Window *window); + +/** + * Dismiss the composition window/IME without disabling the subsystem. + * + * \param window the window to affect. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_StartTextInput + * \sa SDL_StopTextInput + */ +extern SDL_DECLSPEC bool SDLCALL SDL_ClearComposition(SDL_Window *window); + +/** + * Set the area used to type Unicode text input. + * + * Native input methods may place a window with word suggestions near the + * cursor, without covering the text being entered. + * + * \param window the window for which to set the text input area. + * \param rect the SDL_Rect representing the text input area, in window + * coordinates, or NULL to clear it. + * \param cursor the offset of the current cursor location relative to + * `rect->x`, in window coordinates. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetTextInputArea + * \sa SDL_StartTextInput + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetTextInputArea(SDL_Window *window, const SDL_Rect *rect, int cursor); + +/** + * Get the area used to type Unicode text input. + * + * This returns the values previously set by SDL_SetTextInputArea(). + * + * \param window the window for which to query the text input area. + * \param rect a pointer to an SDL_Rect filled in with the text input area, + * may be NULL. + * \param cursor a pointer to the offset of the current cursor location + * relative to `rect->x`, may be NULL. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetTextInputArea + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetTextInputArea(SDL_Window *window, SDL_Rect *rect, int *cursor); + +/** + * Check whether the platform has screen keyboard support. + * + * \returns true if the platform has some screen keyboard support or false if + * not. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_StartTextInput + * \sa SDL_ScreenKeyboardShown + */ +extern SDL_DECLSPEC bool SDLCALL SDL_HasScreenKeyboardSupport(void); + +/** + * Check whether the screen keyboard is shown for given window. + * + * \param window the window for which screen keyboard should be queried. + * \returns true if screen keyboard is shown or false if not. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_HasScreenKeyboardSupport + */ +extern SDL_DECLSPEC bool SDLCALL SDL_ScreenKeyboardShown(SDL_Window *window); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_keyboard_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_keycode.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_keycode.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,347 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * # CategoryKeycode + * + * Defines constants which identify keyboard keys and modifiers. + * + * Please refer to the Best Keyboard Practices document for details on what + * this information means and how best to use it. + * + * https://wiki.libsdl.org/SDL3/BestKeyboardPractices + */ + +#ifndef SDL_keycode_h_ +#define SDL_keycode_h_ + +#include +#include + +/** + * The SDL virtual key representation. + * + * Values of this type are used to represent keyboard keys using the current + * layout of the keyboard. These values include Unicode values representing + * the unmodified character that would be generated by pressing the key, or an + * `SDLK_*` constant for those keys that do not generate characters. + * + * A special exception is the number keys at the top of the keyboard which map + * by default to SDLK_0...SDLK_9 on AZERTY layouts. + * + * Keys with the `SDLK_EXTENDED_MASK` bit set do not map to a scancode or + * Unicode code point. + * + * Many common keycodes are listed below, but this list is not exhaustive. + * + * \since This datatype is available since SDL 3.2.0. + * + * \sa SDL_HINT_KEYCODE_OPTIONS + */ +typedef Uint32 SDL_Keycode; + +#define SDLK_EXTENDED_MASK (1u << 29) +#define SDLK_SCANCODE_MASK (1u << 30) +#define SDL_SCANCODE_TO_KEYCODE(X) (X | SDLK_SCANCODE_MASK) +#define SDLK_UNKNOWN 0x00000000u /**< 0 */ +#define SDLK_RETURN 0x0000000du /**< '\r' */ +#define SDLK_ESCAPE 0x0000001bu /**< '\x1B' */ +#define SDLK_BACKSPACE 0x00000008u /**< '\b' */ +#define SDLK_TAB 0x00000009u /**< '\t' */ +#define SDLK_SPACE 0x00000020u /**< ' ' */ +#define SDLK_EXCLAIM 0x00000021u /**< '!' */ +#define SDLK_DBLAPOSTROPHE 0x00000022u /**< '"' */ +#define SDLK_HASH 0x00000023u /**< '#' */ +#define SDLK_DOLLAR 0x00000024u /**< '$' */ +#define SDLK_PERCENT 0x00000025u /**< '%' */ +#define SDLK_AMPERSAND 0x00000026u /**< '&' */ +#define SDLK_APOSTROPHE 0x00000027u /**< '\'' */ +#define SDLK_LEFTPAREN 0x00000028u /**< '(' */ +#define SDLK_RIGHTPAREN 0x00000029u /**< ')' */ +#define SDLK_ASTERISK 0x0000002au /**< '*' */ +#define SDLK_PLUS 0x0000002bu /**< '+' */ +#define SDLK_COMMA 0x0000002cu /**< ',' */ +#define SDLK_MINUS 0x0000002du /**< '-' */ +#define SDLK_PERIOD 0x0000002eu /**< '.' */ +#define SDLK_SLASH 0x0000002fu /**< '/' */ +#define SDLK_0 0x00000030u /**< '0' */ +#define SDLK_1 0x00000031u /**< '1' */ +#define SDLK_2 0x00000032u /**< '2' */ +#define SDLK_3 0x00000033u /**< '3' */ +#define SDLK_4 0x00000034u /**< '4' */ +#define SDLK_5 0x00000035u /**< '5' */ +#define SDLK_6 0x00000036u /**< '6' */ +#define SDLK_7 0x00000037u /**< '7' */ +#define SDLK_8 0x00000038u /**< '8' */ +#define SDLK_9 0x00000039u /**< '9' */ +#define SDLK_COLON 0x0000003au /**< ':' */ +#define SDLK_SEMICOLON 0x0000003bu /**< ';' */ +#define SDLK_LESS 0x0000003cu /**< '<' */ +#define SDLK_EQUALS 0x0000003du /**< '=' */ +#define SDLK_GREATER 0x0000003eu /**< '>' */ +#define SDLK_QUESTION 0x0000003fu /**< '?' */ +#define SDLK_AT 0x00000040u /**< '@' */ +#define SDLK_LEFTBRACKET 0x0000005bu /**< '[' */ +#define SDLK_BACKSLASH 0x0000005cu /**< '\\' */ +#define SDLK_RIGHTBRACKET 0x0000005du /**< ']' */ +#define SDLK_CARET 0x0000005eu /**< '^' */ +#define SDLK_UNDERSCORE 0x0000005fu /**< '_' */ +#define SDLK_GRAVE 0x00000060u /**< '`' */ +#define SDLK_A 0x00000061u /**< 'a' */ +#define SDLK_B 0x00000062u /**< 'b' */ +#define SDLK_C 0x00000063u /**< 'c' */ +#define SDLK_D 0x00000064u /**< 'd' */ +#define SDLK_E 0x00000065u /**< 'e' */ +#define SDLK_F 0x00000066u /**< 'f' */ +#define SDLK_G 0x00000067u /**< 'g' */ +#define SDLK_H 0x00000068u /**< 'h' */ +#define SDLK_I 0x00000069u /**< 'i' */ +#define SDLK_J 0x0000006au /**< 'j' */ +#define SDLK_K 0x0000006bu /**< 'k' */ +#define SDLK_L 0x0000006cu /**< 'l' */ +#define SDLK_M 0x0000006du /**< 'm' */ +#define SDLK_N 0x0000006eu /**< 'n' */ +#define SDLK_O 0x0000006fu /**< 'o' */ +#define SDLK_P 0x00000070u /**< 'p' */ +#define SDLK_Q 0x00000071u /**< 'q' */ +#define SDLK_R 0x00000072u /**< 'r' */ +#define SDLK_S 0x00000073u /**< 's' */ +#define SDLK_T 0x00000074u /**< 't' */ +#define SDLK_U 0x00000075u /**< 'u' */ +#define SDLK_V 0x00000076u /**< 'v' */ +#define SDLK_W 0x00000077u /**< 'w' */ +#define SDLK_X 0x00000078u /**< 'x' */ +#define SDLK_Y 0x00000079u /**< 'y' */ +#define SDLK_Z 0x0000007au /**< 'z' */ +#define SDLK_LEFTBRACE 0x0000007bu /**< '{' */ +#define SDLK_PIPE 0x0000007cu /**< '|' */ +#define SDLK_RIGHTBRACE 0x0000007du /**< '}' */ +#define SDLK_TILDE 0x0000007eu /**< '~' */ +#define SDLK_DELETE 0x0000007fu /**< '\x7F' */ +#define SDLK_PLUSMINUS 0x000000b1u /**< '\xB1' */ +#define SDLK_CAPSLOCK 0x40000039u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CAPSLOCK) */ +#define SDLK_F1 0x4000003au /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F1) */ +#define SDLK_F2 0x4000003bu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F2) */ +#define SDLK_F3 0x4000003cu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F3) */ +#define SDLK_F4 0x4000003du /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F4) */ +#define SDLK_F5 0x4000003eu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F5) */ +#define SDLK_F6 0x4000003fu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F6) */ +#define SDLK_F7 0x40000040u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F7) */ +#define SDLK_F8 0x40000041u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F8) */ +#define SDLK_F9 0x40000042u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F9) */ +#define SDLK_F10 0x40000043u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F10) */ +#define SDLK_F11 0x40000044u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F11) */ +#define SDLK_F12 0x40000045u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F12) */ +#define SDLK_PRINTSCREEN 0x40000046u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PRINTSCREEN) */ +#define SDLK_SCROLLLOCK 0x40000047u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SCROLLLOCK) */ +#define SDLK_PAUSE 0x40000048u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PAUSE) */ +#define SDLK_INSERT 0x40000049u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_INSERT) */ +#define SDLK_HOME 0x4000004au /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_HOME) */ +#define SDLK_PAGEUP 0x4000004bu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PAGEUP) */ +#define SDLK_END 0x4000004du /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_END) */ +#define SDLK_PAGEDOWN 0x4000004eu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PAGEDOWN) */ +#define SDLK_RIGHT 0x4000004fu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RIGHT) */ +#define SDLK_LEFT 0x40000050u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LEFT) */ +#define SDLK_DOWN 0x40000051u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_DOWN) */ +#define SDLK_UP 0x40000052u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_UP) */ +#define SDLK_NUMLOCKCLEAR 0x40000053u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_NUMLOCKCLEAR) */ +#define SDLK_KP_DIVIDE 0x40000054u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_DIVIDE) */ +#define SDLK_KP_MULTIPLY 0x40000055u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MULTIPLY) */ +#define SDLK_KP_MINUS 0x40000056u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MINUS) */ +#define SDLK_KP_PLUS 0x40000057u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_PLUS) */ +#define SDLK_KP_ENTER 0x40000058u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_ENTER) */ +#define SDLK_KP_1 0x40000059u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_1) */ +#define SDLK_KP_2 0x4000005au /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_2) */ +#define SDLK_KP_3 0x4000005bu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_3) */ +#define SDLK_KP_4 0x4000005cu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_4) */ +#define SDLK_KP_5 0x4000005du /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_5) */ +#define SDLK_KP_6 0x4000005eu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_6) */ +#define SDLK_KP_7 0x4000005fu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_7) */ +#define SDLK_KP_8 0x40000060u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_8) */ +#define SDLK_KP_9 0x40000061u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_9) */ +#define SDLK_KP_0 0x40000062u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_0) */ +#define SDLK_KP_PERIOD 0x40000063u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_PERIOD) */ +#define SDLK_APPLICATION 0x40000065u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_APPLICATION) */ +#define SDLK_POWER 0x40000066u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_POWER) */ +#define SDLK_KP_EQUALS 0x40000067u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_EQUALS) */ +#define SDLK_F13 0x40000068u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F13) */ +#define SDLK_F14 0x40000069u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F14) */ +#define SDLK_F15 0x4000006au /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F15) */ +#define SDLK_F16 0x4000006bu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F16) */ +#define SDLK_F17 0x4000006cu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F17) */ +#define SDLK_F18 0x4000006du /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F18) */ +#define SDLK_F19 0x4000006eu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F19) */ +#define SDLK_F20 0x4000006fu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F20) */ +#define SDLK_F21 0x40000070u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F21) */ +#define SDLK_F22 0x40000071u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F22) */ +#define SDLK_F23 0x40000072u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F23) */ +#define SDLK_F24 0x40000073u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F24) */ +#define SDLK_EXECUTE 0x40000074u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_EXECUTE) */ +#define SDLK_HELP 0x40000075u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_HELP) */ +#define SDLK_MENU 0x40000076u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MENU) */ +#define SDLK_SELECT 0x40000077u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SELECT) */ +#define SDLK_STOP 0x40000078u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_STOP) */ +#define SDLK_AGAIN 0x40000079u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AGAIN) */ +#define SDLK_UNDO 0x4000007au /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_UNDO) */ +#define SDLK_CUT 0x4000007bu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CUT) */ +#define SDLK_COPY 0x4000007cu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_COPY) */ +#define SDLK_PASTE 0x4000007du /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PASTE) */ +#define SDLK_FIND 0x4000007eu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_FIND) */ +#define SDLK_MUTE 0x4000007fu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MUTE) */ +#define SDLK_VOLUMEUP 0x40000080u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_VOLUMEUP) */ +#define SDLK_VOLUMEDOWN 0x40000081u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_VOLUMEDOWN) */ +#define SDLK_KP_COMMA 0x40000085u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_COMMA) */ +#define SDLK_KP_EQUALSAS400 0x40000086u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_EQUALSAS400) */ +#define SDLK_ALTERASE 0x40000099u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_ALTERASE) */ +#define SDLK_SYSREQ 0x4000009au /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SYSREQ) */ +#define SDLK_CANCEL 0x4000009bu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CANCEL) */ +#define SDLK_CLEAR 0x4000009cu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CLEAR) */ +#define SDLK_PRIOR 0x4000009du /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PRIOR) */ +#define SDLK_RETURN2 0x4000009eu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RETURN2) */ +#define SDLK_SEPARATOR 0x4000009fu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SEPARATOR) */ +#define SDLK_OUT 0x400000a0u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_OUT) */ +#define SDLK_OPER 0x400000a1u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_OPER) */ +#define SDLK_CLEARAGAIN 0x400000a2u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CLEARAGAIN) */ +#define SDLK_CRSEL 0x400000a3u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CRSEL) */ +#define SDLK_EXSEL 0x400000a4u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_EXSEL) */ +#define SDLK_KP_00 0x400000b0u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_00) */ +#define SDLK_KP_000 0x400000b1u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_000) */ +#define SDLK_THOUSANDSSEPARATOR 0x400000b2u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_THOUSANDSSEPARATOR) */ +#define SDLK_DECIMALSEPARATOR 0x400000b3u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_DECIMALSEPARATOR) */ +#define SDLK_CURRENCYUNIT 0x400000b4u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CURRENCYUNIT) */ +#define SDLK_CURRENCYSUBUNIT 0x400000b5u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CURRENCYSUBUNIT) */ +#define SDLK_KP_LEFTPAREN 0x400000b6u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_LEFTPAREN) */ +#define SDLK_KP_RIGHTPAREN 0x400000b7u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_RIGHTPAREN) */ +#define SDLK_KP_LEFTBRACE 0x400000b8u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_LEFTBRACE) */ +#define SDLK_KP_RIGHTBRACE 0x400000b9u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_RIGHTBRACE) */ +#define SDLK_KP_TAB 0x400000bau /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_TAB) */ +#define SDLK_KP_BACKSPACE 0x400000bbu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_BACKSPACE) */ +#define SDLK_KP_A 0x400000bcu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_A) */ +#define SDLK_KP_B 0x400000bdu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_B) */ +#define SDLK_KP_C 0x400000beu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_C) */ +#define SDLK_KP_D 0x400000bfu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_D) */ +#define SDLK_KP_E 0x400000c0u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_E) */ +#define SDLK_KP_F 0x400000c1u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_F) */ +#define SDLK_KP_XOR 0x400000c2u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_XOR) */ +#define SDLK_KP_POWER 0x400000c3u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_POWER) */ +#define SDLK_KP_PERCENT 0x400000c4u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_PERCENT) */ +#define SDLK_KP_LESS 0x400000c5u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_LESS) */ +#define SDLK_KP_GREATER 0x400000c6u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_GREATER) */ +#define SDLK_KP_AMPERSAND 0x400000c7u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_AMPERSAND) */ +#define SDLK_KP_DBLAMPERSAND 0x400000c8u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_DBLAMPERSAND) */ +#define SDLK_KP_VERTICALBAR 0x400000c9u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_VERTICALBAR) */ +#define SDLK_KP_DBLVERTICALBAR 0x400000cau /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_DBLVERTICALBAR) */ +#define SDLK_KP_COLON 0x400000cbu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_COLON) */ +#define SDLK_KP_HASH 0x400000ccu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_HASH) */ +#define SDLK_KP_SPACE 0x400000cdu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_SPACE) */ +#define SDLK_KP_AT 0x400000ceu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_AT) */ +#define SDLK_KP_EXCLAM 0x400000cfu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_EXCLAM) */ +#define SDLK_KP_MEMSTORE 0x400000d0u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMSTORE) */ +#define SDLK_KP_MEMRECALL 0x400000d1u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMRECALL) */ +#define SDLK_KP_MEMCLEAR 0x400000d2u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMCLEAR) */ +#define SDLK_KP_MEMADD 0x400000d3u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMADD) */ +#define SDLK_KP_MEMSUBTRACT 0x400000d4u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMSUBTRACT) */ +#define SDLK_KP_MEMMULTIPLY 0x400000d5u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMMULTIPLY) */ +#define SDLK_KP_MEMDIVIDE 0x400000d6u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMDIVIDE) */ +#define SDLK_KP_PLUSMINUS 0x400000d7u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_PLUSMINUS) */ +#define SDLK_KP_CLEAR 0x400000d8u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_CLEAR) */ +#define SDLK_KP_CLEARENTRY 0x400000d9u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_CLEARENTRY) */ +#define SDLK_KP_BINARY 0x400000dau /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_BINARY) */ +#define SDLK_KP_OCTAL 0x400000dbu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_OCTAL) */ +#define SDLK_KP_DECIMAL 0x400000dcu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_DECIMAL) */ +#define SDLK_KP_HEXADECIMAL 0x400000ddu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_HEXADECIMAL) */ +#define SDLK_LCTRL 0x400000e0u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LCTRL) */ +#define SDLK_LSHIFT 0x400000e1u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LSHIFT) */ +#define SDLK_LALT 0x400000e2u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LALT) */ +#define SDLK_LGUI 0x400000e3u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LGUI) */ +#define SDLK_RCTRL 0x400000e4u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RCTRL) */ +#define SDLK_RSHIFT 0x400000e5u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RSHIFT) */ +#define SDLK_RALT 0x400000e6u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RALT) */ +#define SDLK_RGUI 0x400000e7u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RGUI) */ +#define SDLK_MODE 0x40000101u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MODE) */ +#define SDLK_SLEEP 0x40000102u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SLEEP) */ +#define SDLK_WAKE 0x40000103u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_WAKE) */ +#define SDLK_CHANNEL_INCREMENT 0x40000104u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CHANNEL_INCREMENT) */ +#define SDLK_CHANNEL_DECREMENT 0x40000105u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CHANNEL_DECREMENT) */ +#define SDLK_MEDIA_PLAY 0x40000106u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MEDIA_PLAY) */ +#define SDLK_MEDIA_PAUSE 0x40000107u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MEDIA_PAUSE) */ +#define SDLK_MEDIA_RECORD 0x40000108u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MEDIA_RECORD) */ +#define SDLK_MEDIA_FAST_FORWARD 0x40000109u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MEDIA_FAST_FORWARD) */ +#define SDLK_MEDIA_REWIND 0x4000010au /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MEDIA_REWIND) */ +#define SDLK_MEDIA_NEXT_TRACK 0x4000010bu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MEDIA_NEXT_TRACK) */ +#define SDLK_MEDIA_PREVIOUS_TRACK 0x4000010cu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MEDIA_PREVIOUS_TRACK) */ +#define SDLK_MEDIA_STOP 0x4000010du /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MEDIA_STOP) */ +#define SDLK_MEDIA_EJECT 0x4000010eu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MEDIA_EJECT) */ +#define SDLK_MEDIA_PLAY_PAUSE 0x4000010fu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MEDIA_PLAY_PAUSE) */ +#define SDLK_MEDIA_SELECT 0x40000110u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MEDIA_SELECT) */ +#define SDLK_AC_NEW 0x40000111u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_NEW) */ +#define SDLK_AC_OPEN 0x40000112u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_OPEN) */ +#define SDLK_AC_CLOSE 0x40000113u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_CLOSE) */ +#define SDLK_AC_EXIT 0x40000114u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_EXIT) */ +#define SDLK_AC_SAVE 0x40000115u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_SAVE) */ +#define SDLK_AC_PRINT 0x40000116u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_PRINT) */ +#define SDLK_AC_PROPERTIES 0x40000117u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_PROPERTIES) */ +#define SDLK_AC_SEARCH 0x40000118u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_SEARCH) */ +#define SDLK_AC_HOME 0x40000119u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_HOME) */ +#define SDLK_AC_BACK 0x4000011au /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_BACK) */ +#define SDLK_AC_FORWARD 0x4000011bu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_FORWARD) */ +#define SDLK_AC_STOP 0x4000011cu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_STOP) */ +#define SDLK_AC_REFRESH 0x4000011du /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_REFRESH) */ +#define SDLK_AC_BOOKMARKS 0x4000011eu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_BOOKMARKS) */ +#define SDLK_SOFTLEFT 0x4000011fu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SOFTLEFT) */ +#define SDLK_SOFTRIGHT 0x40000120u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SOFTRIGHT) */ +#define SDLK_CALL 0x40000121u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CALL) */ +#define SDLK_ENDCALL 0x40000122u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_ENDCALL) */ +#define SDLK_LEFT_TAB 0x20000001u /**< Extended key Left Tab */ +#define SDLK_LEVEL5_SHIFT 0x20000002u /**< Extended key Level 5 Shift */ +#define SDLK_MULTI_KEY_COMPOSE 0x20000003u /**< Extended key Multi-key Compose */ +#define SDLK_LMETA 0x20000004u /**< Extended key Left Meta */ +#define SDLK_RMETA 0x20000005u /**< Extended key Right Meta */ +#define SDLK_LHYPER 0x20000006u /**< Extended key Left Hyper */ +#define SDLK_RHYPER 0x20000007u /**< Extended key Right Hyper */ + +/** + * Valid key modifiers (possibly OR'd together). + * + * \since This datatype is available since SDL 3.2.0. + */ +typedef Uint16 SDL_Keymod; + +#define SDL_KMOD_NONE 0x0000u /**< no modifier is applicable. */ +#define SDL_KMOD_LSHIFT 0x0001u /**< the left Shift key is down. */ +#define SDL_KMOD_RSHIFT 0x0002u /**< the right Shift key is down. */ +#define SDL_KMOD_LEVEL5 0x0004u /**< the Level 5 Shift key is down. */ +#define SDL_KMOD_LCTRL 0x0040u /**< the left Ctrl (Control) key is down. */ +#define SDL_KMOD_RCTRL 0x0080u /**< the right Ctrl (Control) key is down. */ +#define SDL_KMOD_LALT 0x0100u /**< the left Alt key is down. */ +#define SDL_KMOD_RALT 0x0200u /**< the right Alt key is down. */ +#define SDL_KMOD_LGUI 0x0400u /**< the left GUI key (often the Windows key) is down. */ +#define SDL_KMOD_RGUI 0x0800u /**< the right GUI key (often the Windows key) is down. */ +#define SDL_KMOD_NUM 0x1000u /**< the Num Lock key (may be located on an extended keypad) is down. */ +#define SDL_KMOD_CAPS 0x2000u /**< the Caps Lock key is down. */ +#define SDL_KMOD_MODE 0x4000u /**< the !AltGr key is down. */ +#define SDL_KMOD_SCROLL 0x8000u /**< the Scroll Lock key is down. */ +#define SDL_KMOD_CTRL (SDL_KMOD_LCTRL | SDL_KMOD_RCTRL) /**< Any Ctrl key is down. */ +#define SDL_KMOD_SHIFT (SDL_KMOD_LSHIFT | SDL_KMOD_RSHIFT) /**< Any Shift key is down. */ +#define SDL_KMOD_ALT (SDL_KMOD_LALT | SDL_KMOD_RALT) /**< Any Alt key is down. */ +#define SDL_KMOD_GUI (SDL_KMOD_LGUI | SDL_KMOD_RGUI) /**< Any GUI key is down. */ + +#endif /* SDL_keycode_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_loadso.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_loadso.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,145 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* WIKI CATEGORY: SharedObject */ + +/** + * # CategorySharedObject + * + * System-dependent library loading routines. + * + * Shared objects are code that is programmatically loadable at runtime. + * Windows calls these "DLLs", Linux calls them "shared libraries", etc. + * + * To use them, build such a library, then call SDL_LoadObject() on it. Once + * loaded, you can use SDL_LoadFunction() on that object to find the address + * of its exported symbols. When done with the object, call SDL_UnloadObject() + * to dispose of it. + * + * Some things to keep in mind: + * + * - These functions only work on C function names. Other languages may have + * name mangling and intrinsic language support that varies from compiler to + * compiler. + * - Make sure you declare your function pointers with the same calling + * convention as the actual library function. Your code will crash + * mysteriously if you do not do this. + * - Avoid namespace collisions. If you load a symbol from the library, it is + * not defined whether or not it goes into the global symbol namespace for + * the application. If it does and it conflicts with symbols in your code or + * other shared libraries, you will not get the results you expect. :) + * - Once a library is unloaded, all pointers into it obtained through + * SDL_LoadFunction() become invalid, even if the library is later reloaded. + * Don't unload a library if you plan to use these pointers in the future. + * Notably: beware of giving one of these pointers to atexit(), since it may + * call that pointer after the library unloads. + */ + +#ifndef SDL_loadso_h_ +#define SDL_loadso_h_ + +#include +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * An opaque datatype that represents a loaded shared object. + * + * \since This datatype is available since SDL 3.2.0. + * + * \sa SDL_LoadObject + * \sa SDL_LoadFunction + * \sa SDL_UnloadObject + */ +typedef struct SDL_SharedObject SDL_SharedObject; + +/** + * Dynamically load a shared object. + * + * \param sofile a system-dependent name of the object file. + * \returns an opaque pointer to the object handle or NULL on failure; call + * SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_LoadFunction + * \sa SDL_UnloadObject + */ +extern SDL_DECLSPEC SDL_SharedObject * SDLCALL SDL_LoadObject(const char *sofile); + +/** + * Look up the address of the named function in a shared object. + * + * This function pointer is no longer valid after calling SDL_UnloadObject(). + * + * This function can only look up C function names. Other languages may have + * name mangling and intrinsic language support that varies from compiler to + * compiler. + * + * Make sure you declare your function pointers with the same calling + * convention as the actual library function. Your code will crash + * mysteriously if you do not do this. + * + * If the requested function doesn't exist, NULL is returned. + * + * \param handle a valid shared object handle returned by SDL_LoadObject(). + * \param name the name of the function to look up. + * \returns a pointer to the function or NULL on failure; call SDL_GetError() + * for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_LoadObject + */ +extern SDL_DECLSPEC SDL_FunctionPointer SDLCALL SDL_LoadFunction(SDL_SharedObject *handle, const char *name); + +/** + * Unload a shared object from memory. + * + * Note that any pointers from this object looked up through + * SDL_LoadFunction() will no longer be valid. + * + * \param handle a valid shared object handle returned by SDL_LoadObject(). + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_LoadObject + */ +extern SDL_DECLSPEC void SDLCALL SDL_UnloadObject(SDL_SharedObject *handle); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_loadso_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_locale.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_locale.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,117 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * # CategoryLocale + * + * SDL locale services. + * + * This provides a way to get a list of preferred locales (language plus + * country) for the user. There is exactly one function: + * SDL_GetPreferredLocales(), which handles all the heavy lifting, and offers + * documentation on all the strange ways humans might have configured their + * language settings. + */ + +#ifndef SDL_locale_h +#define SDL_locale_h + +#include +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +/* *INDENT-OFF* */ +extern "C" { +/* *INDENT-ON* */ +#endif + +/** + * A struct to provide locale data. + * + * Locale data is split into a spoken language, like English, and an optional + * country, like Canada. The language will be in ISO-639 format (so English + * would be "en"), and the country, if not NULL, will be an ISO-3166 country + * code (so Canada would be "CA"). + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetPreferredLocales + */ +typedef struct SDL_Locale +{ + const char *language; /**< A language name, like "en" for English. */ + const char *country; /**< A country, like "US" for America. Can be NULL. */ +} SDL_Locale; + +/** + * Report the user's preferred locale. + * + * Returned language strings are in the format xx, where 'xx' is an ISO-639 + * language specifier (such as "en" for English, "de" for German, etc). + * Country strings are in the format YY, where "YY" is an ISO-3166 country + * code (such as "US" for the United States, "CA" for Canada, etc). Country + * might be NULL if there's no specific guidance on them (so you might get { + * "en", "US" } for American English, but { "en", NULL } means "English + * language, generically"). Language strings are never NULL, except to + * terminate the array. + * + * Please note that not all of these strings are 2 characters; some are three + * or more. + * + * The returned list of locales are in the order of the user's preference. For + * example, a German citizen that is fluent in US English and knows enough + * Japanese to navigate around Tokyo might have a list like: { "de", "en_US", + * "jp", NULL }. Someone from England might prefer British English (where + * "color" is spelled "colour", etc), but will settle for anything like it: { + * "en_GB", "en", NULL }. + * + * This function returns NULL on error, including when the platform does not + * supply this information at all. + * + * This might be a "slow" call that has to query the operating system. It's + * best to ask for this once and save the results. However, this list can + * change, usually because the user has changed a system preference outside of + * your program; SDL will send an SDL_EVENT_LOCALE_CHANGED event in this case, + * if possible, and you can call this function again to get an updated copy of + * preferred locales. + * + * \param count a pointer filled in with the number of locales returned, may + * be NULL. + * \returns a NULL terminated array of locale pointers, or NULL on failure; + * call SDL_GetError() for more information. This is a single + * allocation that should be freed with SDL_free() when it is no + * longer needed. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_Locale ** SDLCALL SDL_GetPreferredLocales(int *count); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +/* *INDENT-OFF* */ +} +/* *INDENT-ON* */ +#endif +#include + +#endif /* SDL_locale_h */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_log.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_log.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,540 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * # CategoryLog + * + * Simple log messages with priorities and categories. A message's + * SDL_LogPriority signifies how important the message is. A message's + * SDL_LogCategory signifies from what domain it belongs to. Every category + * has a minimum priority specified: when a message belongs to that category, + * it will only be sent out if it has that minimum priority or higher. + * + * SDL's own logs are sent below the default priority threshold, so they are + * quiet by default. + * + * You can change the log verbosity programmatically using + * SDL_SetLogPriority() or with SDL_SetHint(SDL_HINT_LOGGING, ...), or with + * the "SDL_LOGGING" environment variable. This variable is a comma separated + * set of category=level tokens that define the default logging levels for SDL + * applications. + * + * The category can be a numeric category, one of "app", "error", "assert", + * "system", "audio", "video", "render", "input", "test", or `*` for any + * unspecified category. + * + * The level can be a numeric level, one of "trace", "verbose", "debug", + * "info", "warn", "error", "critical", or "quiet" to disable that category. + * + * You can omit the category if you want to set the logging level for all + * categories. + * + * If this hint isn't set, the default log levels are equivalent to: + * + * `app=info,assert=warn,test=verbose,*=error` + * + * Here's where the messages go on different platforms: + * + * - Windows: debug output stream + * - Android: log output + * - Others: standard error output (stderr) + * + * You don't need to have a newline (`\n`) on the end of messages, the + * functions will do that for you. For consistent behavior cross-platform, you + * shouldn't have any newlines in messages, such as to log multiple lines in + * one call; unusual platform-specific behavior can be observed in such usage. + * Do one log call per line instead, with no newlines in messages. + * + * Each log call is atomic, so you won't see log messages cut off one another + * when logging from multiple threads. + */ + +#ifndef SDL_log_h_ +#define SDL_log_h_ + +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * The predefined log categories + * + * By default the application and gpu categories are enabled at the INFO + * level, the assert category is enabled at the WARN level, test is enabled at + * the VERBOSE level and all other categories are enabled at the ERROR level. + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_LogCategory +{ + SDL_LOG_CATEGORY_APPLICATION, + SDL_LOG_CATEGORY_ERROR, + SDL_LOG_CATEGORY_ASSERT, + SDL_LOG_CATEGORY_SYSTEM, + SDL_LOG_CATEGORY_AUDIO, + SDL_LOG_CATEGORY_VIDEO, + SDL_LOG_CATEGORY_RENDER, + SDL_LOG_CATEGORY_INPUT, + SDL_LOG_CATEGORY_TEST, + SDL_LOG_CATEGORY_GPU, + + /* Reserved for future SDL library use */ + SDL_LOG_CATEGORY_RESERVED2, + SDL_LOG_CATEGORY_RESERVED3, + SDL_LOG_CATEGORY_RESERVED4, + SDL_LOG_CATEGORY_RESERVED5, + SDL_LOG_CATEGORY_RESERVED6, + SDL_LOG_CATEGORY_RESERVED7, + SDL_LOG_CATEGORY_RESERVED8, + SDL_LOG_CATEGORY_RESERVED9, + SDL_LOG_CATEGORY_RESERVED10, + + /* Beyond this point is reserved for application use, e.g. + enum { + MYAPP_CATEGORY_AWESOME1 = SDL_LOG_CATEGORY_CUSTOM, + MYAPP_CATEGORY_AWESOME2, + MYAPP_CATEGORY_AWESOME3, + ... + }; + */ + SDL_LOG_CATEGORY_CUSTOM +} SDL_LogCategory; + +/** + * The predefined log priorities + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_LogPriority +{ + SDL_LOG_PRIORITY_INVALID, + SDL_LOG_PRIORITY_TRACE, + SDL_LOG_PRIORITY_VERBOSE, + SDL_LOG_PRIORITY_DEBUG, + SDL_LOG_PRIORITY_INFO, + SDL_LOG_PRIORITY_WARN, + SDL_LOG_PRIORITY_ERROR, + SDL_LOG_PRIORITY_CRITICAL, + SDL_LOG_PRIORITY_COUNT +} SDL_LogPriority; + + +/** + * Set the priority of all log categories. + * + * \param priority the SDL_LogPriority to assign. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_ResetLogPriorities + * \sa SDL_SetLogPriority + */ +extern SDL_DECLSPEC void SDLCALL SDL_SetLogPriorities(SDL_LogPriority priority); + +/** + * Set the priority of a particular log category. + * + * \param category the category to assign a priority to. + * \param priority the SDL_LogPriority to assign. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetLogPriority + * \sa SDL_ResetLogPriorities + * \sa SDL_SetLogPriorities + */ +extern SDL_DECLSPEC void SDLCALL SDL_SetLogPriority(int category, SDL_LogPriority priority); + +/** + * Get the priority of a particular log category. + * + * \param category the category to query. + * \returns the SDL_LogPriority for the requested category. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetLogPriority + */ +extern SDL_DECLSPEC SDL_LogPriority SDLCALL SDL_GetLogPriority(int category); + +/** + * Reset all priorities to default. + * + * This is called by SDL_Quit(). + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetLogPriorities + * \sa SDL_SetLogPriority + */ +extern SDL_DECLSPEC void SDLCALL SDL_ResetLogPriorities(void); + +/** + * Set the text prepended to log messages of a given priority. + * + * By default SDL_LOG_PRIORITY_INFO and below have no prefix, and + * SDL_LOG_PRIORITY_WARN and higher have a prefix showing their priority, e.g. + * "WARNING: ". + * + * This function makes a copy of its string argument, **prefix**, so it is not + * necessary to keep the value of **prefix** alive after the call returns. + * + * \param priority the SDL_LogPriority to modify. + * \param prefix the prefix to use for that log priority, or NULL to use no + * prefix. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetLogPriorities + * \sa SDL_SetLogPriority + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetLogPriorityPrefix(SDL_LogPriority priority, const char *prefix); + +/** + * Log a message with SDL_LOG_CATEGORY_APPLICATION and SDL_LOG_PRIORITY_INFO. + * + * \param fmt a printf() style message format string. + * \param ... additional parameters matching % tokens in the `fmt` string, if + * any. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_LogCritical + * \sa SDL_LogDebug + * \sa SDL_LogError + * \sa SDL_LogInfo + * \sa SDL_LogMessage + * \sa SDL_LogMessageV + * \sa SDL_LogTrace + * \sa SDL_LogVerbose + * \sa SDL_LogWarn + */ +extern SDL_DECLSPEC void SDLCALL SDL_Log(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1); + +/** + * Log a message with SDL_LOG_PRIORITY_TRACE. + * + * \param category the category of the message. + * \param fmt a printf() style message format string. + * \param ... additional parameters matching % tokens in the **fmt** string, + * if any. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_Log + * \sa SDL_LogCritical + * \sa SDL_LogDebug + * \sa SDL_LogError + * \sa SDL_LogInfo + * \sa SDL_LogMessage + * \sa SDL_LogMessageV + * \sa SDL_LogVerbose + * \sa SDL_LogWarn + */ +extern SDL_DECLSPEC void SDLCALL SDL_LogTrace(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); + +/** + * Log a message with SDL_LOG_PRIORITY_VERBOSE. + * + * \param category the category of the message. + * \param fmt a printf() style message format string. + * \param ... additional parameters matching % tokens in the **fmt** string, + * if any. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_Log + * \sa SDL_LogCritical + * \sa SDL_LogDebug + * \sa SDL_LogError + * \sa SDL_LogInfo + * \sa SDL_LogMessage + * \sa SDL_LogMessageV + * \sa SDL_LogWarn + */ +extern SDL_DECLSPEC void SDLCALL SDL_LogVerbose(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); + +/** + * Log a message with SDL_LOG_PRIORITY_DEBUG. + * + * \param category the category of the message. + * \param fmt a printf() style message format string. + * \param ... additional parameters matching % tokens in the **fmt** string, + * if any. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_Log + * \sa SDL_LogCritical + * \sa SDL_LogError + * \sa SDL_LogInfo + * \sa SDL_LogMessage + * \sa SDL_LogMessageV + * \sa SDL_LogTrace + * \sa SDL_LogVerbose + * \sa SDL_LogWarn + */ +extern SDL_DECLSPEC void SDLCALL SDL_LogDebug(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); + +/** + * Log a message with SDL_LOG_PRIORITY_INFO. + * + * \param category the category of the message. + * \param fmt a printf() style message format string. + * \param ... additional parameters matching % tokens in the **fmt** string, + * if any. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_Log + * \sa SDL_LogCritical + * \sa SDL_LogDebug + * \sa SDL_LogError + * \sa SDL_LogMessage + * \sa SDL_LogMessageV + * \sa SDL_LogTrace + * \sa SDL_LogVerbose + * \sa SDL_LogWarn + */ +extern SDL_DECLSPEC void SDLCALL SDL_LogInfo(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); + +/** + * Log a message with SDL_LOG_PRIORITY_WARN. + * + * \param category the category of the message. + * \param fmt a printf() style message format string. + * \param ... additional parameters matching % tokens in the **fmt** string, + * if any. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_Log + * \sa SDL_LogCritical + * \sa SDL_LogDebug + * \sa SDL_LogError + * \sa SDL_LogInfo + * \sa SDL_LogMessage + * \sa SDL_LogMessageV + * \sa SDL_LogTrace + * \sa SDL_LogVerbose + */ +extern SDL_DECLSPEC void SDLCALL SDL_LogWarn(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); + +/** + * Log a message with SDL_LOG_PRIORITY_ERROR. + * + * \param category the category of the message. + * \param fmt a printf() style message format string. + * \param ... additional parameters matching % tokens in the **fmt** string, + * if any. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_Log + * \sa SDL_LogCritical + * \sa SDL_LogDebug + * \sa SDL_LogInfo + * \sa SDL_LogMessage + * \sa SDL_LogMessageV + * \sa SDL_LogTrace + * \sa SDL_LogVerbose + * \sa SDL_LogWarn + */ +extern SDL_DECLSPEC void SDLCALL SDL_LogError(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); + +/** + * Log a message with SDL_LOG_PRIORITY_CRITICAL. + * + * \param category the category of the message. + * \param fmt a printf() style message format string. + * \param ... additional parameters matching % tokens in the **fmt** string, + * if any. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_Log + * \sa SDL_LogDebug + * \sa SDL_LogError + * \sa SDL_LogInfo + * \sa SDL_LogMessage + * \sa SDL_LogMessageV + * \sa SDL_LogTrace + * \sa SDL_LogVerbose + * \sa SDL_LogWarn + */ +extern SDL_DECLSPEC void SDLCALL SDL_LogCritical(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); + +/** + * Log a message with the specified category and priority. + * + * \param category the category of the message. + * \param priority the priority of the message. + * \param fmt a printf() style message format string. + * \param ... additional parameters matching % tokens in the **fmt** string, + * if any. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_Log + * \sa SDL_LogCritical + * \sa SDL_LogDebug + * \sa SDL_LogError + * \sa SDL_LogInfo + * \sa SDL_LogMessageV + * \sa SDL_LogTrace + * \sa SDL_LogVerbose + * \sa SDL_LogWarn + */ +extern SDL_DECLSPEC void SDLCALL SDL_LogMessage(int category, + SDL_LogPriority priority, + SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(3); + +/** + * Log a message with the specified category and priority. + * + * \param category the category of the message. + * \param priority the priority of the message. + * \param fmt a printf() style message format string. + * \param ap a variable argument list. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_Log + * \sa SDL_LogCritical + * \sa SDL_LogDebug + * \sa SDL_LogError + * \sa SDL_LogInfo + * \sa SDL_LogMessage + * \sa SDL_LogTrace + * \sa SDL_LogVerbose + * \sa SDL_LogWarn + */ +extern SDL_DECLSPEC void SDLCALL SDL_LogMessageV(int category, + SDL_LogPriority priority, + SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap) SDL_PRINTF_VARARG_FUNCV(3); + +/** + * The prototype for the log output callback function. + * + * This function is called by SDL when there is new text to be logged. A mutex + * is held so that this function is never called by more than one thread at + * once. + * + * \param userdata what was passed as `userdata` to + * SDL_SetLogOutputFunction(). + * \param category the category of the message. + * \param priority the priority of the message. + * \param message the message being output. + * + * \since This datatype is available since SDL 3.2.0. + */ +typedef void (SDLCALL *SDL_LogOutputFunction)(void *userdata, int category, SDL_LogPriority priority, const char *message); + +/** + * Get the default log output function. + * + * \returns the default log output callback. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetLogOutputFunction + * \sa SDL_GetLogOutputFunction + */ +extern SDL_DECLSPEC SDL_LogOutputFunction SDLCALL SDL_GetDefaultLogOutputFunction(void); + +/** + * Get the current log output function. + * + * \param callback an SDL_LogOutputFunction filled in with the current log + * callback. + * \param userdata a pointer filled in with the pointer that is passed to + * `callback`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetDefaultLogOutputFunction + * \sa SDL_SetLogOutputFunction + */ +extern SDL_DECLSPEC void SDLCALL SDL_GetLogOutputFunction(SDL_LogOutputFunction *callback, void **userdata); + +/** + * Replace the default log output function with one of your own. + * + * \param callback an SDL_LogOutputFunction to call instead of the default. + * \param userdata a pointer that is passed to `callback`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetDefaultLogOutputFunction + * \sa SDL_GetLogOutputFunction + */ +extern SDL_DECLSPEC void SDLCALL SDL_SetLogOutputFunction(SDL_LogOutputFunction callback, void *userdata); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_log_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_main.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_main.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,679 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * # CategoryMain + * + * Redefine main() if necessary so that it is called by SDL. + * + * In order to make this consistent on all platforms, the application's main() + * should look like this: + * + * ```c + * #include + * #include + * + * int main(int argc, char *argv[]) + * { + * } + * ``` + * + * SDL will take care of platform specific details on how it gets called. + * + * This is also where an app can be configured to use the main callbacks, via + * the SDL_MAIN_USE_CALLBACKS macro. + * + * SDL_main.h is a "single-header library," which is to say that including + * this header inserts code into your program, and you should only include it + * once in most cases. SDL.h does not include this header automatically. + * + * For more information, see: + * + * https://wiki.libsdl.org/SDL3/README-main-functions + */ + +#ifndef SDL_main_h_ +#define SDL_main_h_ + +#include +#include +#include +#include + +#ifdef SDL_WIKI_DOCUMENTATION_SECTION + +/** + * Inform SDL that the app is providing an entry point instead of SDL. + * + * SDL does not define this macro, but will check if it is defined when + * including `SDL_main.h`. If defined, SDL will expect the app to provide the + * proper entry point for the platform, and all the other magic details + * needed, like manually calling SDL_SetMainReady. + * + * Please see [README-main-functions](README-main-functions), (or + * docs/README-main-functions.md in the source tree) for a more detailed + * explanation. + * + * \since This macro is used by the headers since SDL 3.2.0. + */ +#define SDL_MAIN_HANDLED 1 + +/** + * Inform SDL to use the main callbacks instead of main. + * + * SDL does not define this macro, but will check if it is defined when + * including `SDL_main.h`. If defined, SDL will expect the app to provide + * several functions: SDL_AppInit, SDL_AppEvent, SDL_AppIterate, and + * SDL_AppQuit. The app should not provide a `main` function in this case, and + * doing so will likely cause the build to fail. + * + * Please see [README-main-functions](README-main-functions), (or + * docs/README-main-functions.md in the source tree) for a more detailed + * explanation. + * + * \since This macro is used by the headers since SDL 3.2.0. + * + * \sa SDL_AppInit + * \sa SDL_AppEvent + * \sa SDL_AppIterate + * \sa SDL_AppQuit + */ +#define SDL_MAIN_USE_CALLBACKS 1 + +/** + * Defined if the target platform offers a special mainline through SDL. + * + * This won't be defined otherwise. If defined, SDL's headers will redefine + * `main` to `SDL_main`. + * + * This macro is defined by `SDL_main.h`, which is not automatically included + * by `SDL.h`. + * + * Even if available, an app can define SDL_MAIN_HANDLED and provide their + * own, if they know what they're doing. + * + * This macro is used internally by SDL, and apps probably shouldn't rely on + * it. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_MAIN_AVAILABLE + +/** + * Defined if the target platform _requires_ a special mainline through SDL. + * + * This won't be defined otherwise. If defined, SDL's headers will redefine + * `main` to `SDL_main`. + * + * This macro is defined by `SDL_main.h`, which is not automatically included + * by `SDL.h`. + * + * Even if required, an app can define SDL_MAIN_HANDLED and provide their own, + * if they know what they're doing. + * + * This macro is used internally by SDL, and apps probably shouldn't rely on + * it. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_MAIN_NEEDED + +#endif + +#if defined(__has_include) + #if __has_include("SDL_main_private.h") && __has_include("SDL_main_impl_private.h") + #define SDL_PLATFORM_PRIVATE_MAIN + #endif +#endif + +#ifndef SDL_MAIN_HANDLED + #if defined(SDL_PLATFORM_PRIVATE_MAIN) + /* Private platforms may have their own ideas about entry points. */ + #include "SDL_main_private.h" + + #elif defined(SDL_PLATFORM_WIN32) + /* On Windows SDL provides WinMain(), which parses the command line and passes + the arguments to your main function. + + If you provide your own WinMain(), you may define SDL_MAIN_HANDLED + */ + #define SDL_MAIN_AVAILABLE + + #elif defined(SDL_PLATFORM_GDK) + /* On GDK, SDL provides a main function that initializes the game runtime. + + If you prefer to write your own WinMain-function instead of having SDL + provide one that calls your main() function, + #define SDL_MAIN_HANDLED before #include'ing SDL_main.h + and call the SDL_RunApp function from your entry point. + */ + #define SDL_MAIN_NEEDED + + #elif defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_TVOS) + /* On iOS and tvOS SDL provides a main function that creates an application delegate and starts the application run loop. + + To use it, just #include in the source file that contains your main() function. + + See src/video/uikit/SDL_uikitappdelegate.m for more details. + */ + #define SDL_MAIN_NEEDED + + #elif defined(SDL_PLATFORM_ANDROID) + /* On Android SDL provides a Java class in SDLActivity.java that is the + main activity entry point. + + See docs/README-android.md for more details on extending that class. + */ + #define SDL_MAIN_NEEDED + + /* As this is launched from Java, the real entry point (main() function) + is outside of the the binary built from this code. + This define makes sure that, unlike on other platforms, SDL_main.h + and SDL_main_impl.h export an `SDL_main()` function (to be called + from Java), but don't implement a native `int main(int argc, char* argv[])` + or similar. + */ + #define SDL_MAIN_EXPORTED + + #elif defined(SDL_PLATFORM_EMSCRIPTEN) + /* On Emscripten, SDL provides a main function that converts URL + parameters that start with "SDL_" to environment variables, so + they can be used as SDL hints, etc. + + This is 100% optional, so if you don't want this to happen, you may + define SDL_MAIN_HANDLED + */ + #define SDL_MAIN_AVAILABLE + + #elif defined(SDL_PLATFORM_PSP) + /* On PSP SDL provides a main function that sets the module info, + activates the GPU and starts the thread required to be able to exit + the software. + + If you provide this yourself, you may define SDL_MAIN_HANDLED + */ + #define SDL_MAIN_AVAILABLE + + #elif defined(SDL_PLATFORM_PS2) + #define SDL_MAIN_AVAILABLE + + #define SDL_PS2_SKIP_IOP_RESET() \ + void reset_IOP(); \ + void reset_IOP() {} + + #elif defined(SDL_PLATFORM_3DS) + /* + On N3DS, SDL provides a main function that sets up the screens + and storage. + + If you provide this yourself, you may define SDL_MAIN_HANDLED + */ + #define SDL_MAIN_AVAILABLE + + #endif +#endif /* SDL_MAIN_HANDLED */ + + +#ifdef SDL_WIKI_DOCUMENTATION_SECTION + +/** + * A macro to tag a main entry point function as exported. + * + * Most platforms don't need this, and the macro will be defined to nothing. + * Some, like Android, keep the entry points in a shared library and need to + * explicitly export the symbols. + * + * External code rarely needs this, and if it needs something, it's almost + * always SDL_DECLSPEC instead. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_DECLSPEC + */ +#define SDLMAIN_DECLSPEC + +#elif defined(SDL_MAIN_EXPORTED) +/* We need to export SDL_main so it can be launched from external code, + like SDLActivity.java on Android */ +#define SDLMAIN_DECLSPEC SDL_DECLSPEC +#else +/* usually this is empty */ +#define SDLMAIN_DECLSPEC +#endif /* SDL_MAIN_EXPORTED */ + +#if defined(SDL_MAIN_NEEDED) || defined(SDL_MAIN_AVAILABLE) || defined(SDL_MAIN_USE_CALLBACKS) +#define main SDL_main +#endif + +#include +#include +#ifdef __cplusplus +extern "C" { +#endif + +/* + * You can (optionally!) define SDL_MAIN_USE_CALLBACKS before including + * SDL_main.h, and then your application will _not_ have a standard + * "main" entry point. Instead, it will operate as a collection of + * functions that are called as necessary by the system. On some + * platforms, this is just a layer where SDL drives your program + * instead of your program driving SDL, on other platforms this might + * hook into the OS to manage the lifecycle. Programs on most platforms + * can use whichever approach they prefer, but the decision boils down + * to: + * + * - Using a standard "main" function: this works like it always has for + * the past 50+ years in C programming, and your app is in control. + * - Using the callback functions: this might clean up some code, + * avoid some #ifdef blocks in your program for some platforms, be more + * resource-friendly to the system, and possibly be the primary way to + * access some future platforms (but none require this at the moment). + * + * This is up to the app; both approaches are considered valid and supported + * ways to write SDL apps. + * + * If using the callbacks, don't define a "main" function. Instead, implement + * the functions listed below in your program. + */ +#ifdef SDL_MAIN_USE_CALLBACKS + +/** + * App-implemented initial entry point for SDL_MAIN_USE_CALLBACKS apps. + * + * Apps implement this function when using SDL_MAIN_USE_CALLBACKS. If using a + * standard "main" function, you should not supply this. + * + * This function is called by SDL once, at startup. The function should + * initialize whatever is necessary, possibly create windows and open audio + * devices, etc. The `argc` and `argv` parameters work like they would with a + * standard "main" function. + * + * This function should not go into an infinite mainloop; it should do any + * one-time setup it requires and then return. + * + * The app may optionally assign a pointer to `*appstate`. This pointer will + * be provided on every future call to the other entry points, to allow + * application state to be preserved between functions without the app needing + * to use a global variable. If this isn't set, the pointer will be NULL in + * future entry points. + * + * If this function returns SDL_APP_CONTINUE, the app will proceed to normal + * operation, and will begin receiving repeated calls to SDL_AppIterate and + * SDL_AppEvent for the life of the program. If this function returns + * SDL_APP_FAILURE, SDL will call SDL_AppQuit and terminate the process with + * an exit code that reports an error to the platform. If it returns + * SDL_APP_SUCCESS, SDL calls SDL_AppQuit and terminates with an exit code + * that reports success to the platform. + * + * This function is called by SDL on the main thread. + * + * \param appstate a place where the app can optionally store a pointer for + * future use. + * \param argc the standard ANSI C main's argc; number of elements in `argv`. + * \param argv the standard ANSI C main's argv; array of command line + * arguments. + * \returns SDL_APP_FAILURE to terminate with an error, SDL_APP_SUCCESS to + * terminate with success, SDL_APP_CONTINUE to continue. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_AppIterate + * \sa SDL_AppEvent + * \sa SDL_AppQuit + */ +extern SDLMAIN_DECLSPEC SDL_AppResult SDLCALL SDL_AppInit(void **appstate, int argc, char *argv[]); + +/** + * App-implemented iteration entry point for SDL_MAIN_USE_CALLBACKS apps. + * + * Apps implement this function when using SDL_MAIN_USE_CALLBACKS. If using a + * standard "main" function, you should not supply this. + * + * This function is called repeatedly by SDL after SDL_AppInit returns + * SDL_APP_CONTINUE. The function should operate as a single iteration the + * program's primary loop; it should update whatever state it needs and draw a + * new frame of video, usually. + * + * On some platforms, this function will be called at the refresh rate of the + * display (which might change during the life of your app!). There are no + * promises made about what frequency this function might run at. You should + * use SDL's timer functions if you need to see how much time has passed since + * the last iteration. + * + * There is no need to process the SDL event queue during this function; SDL + * will send events as they arrive in SDL_AppEvent, and in most cases the + * event queue will be empty when this function runs anyhow. + * + * This function should not go into an infinite mainloop; it should do one + * iteration of whatever the program does and return. + * + * The `appstate` parameter is an optional pointer provided by the app during + * SDL_AppInit(). If the app never provided a pointer, this will be NULL. + * + * If this function returns SDL_APP_CONTINUE, the app will continue normal + * operation, receiving repeated calls to SDL_AppIterate and SDL_AppEvent for + * the life of the program. If this function returns SDL_APP_FAILURE, SDL will + * call SDL_AppQuit and terminate the process with an exit code that reports + * an error to the platform. If it returns SDL_APP_SUCCESS, SDL calls + * SDL_AppQuit and terminates with an exit code that reports success to the + * platform. + * + * This function is called by SDL on the main thread. + * + * \param appstate an optional pointer, provided by the app in SDL_AppInit. + * \returns SDL_APP_FAILURE to terminate with an error, SDL_APP_SUCCESS to + * terminate with success, SDL_APP_CONTINUE to continue. + * + * \threadsafety This function may get called concurrently with SDL_AppEvent() + * for events not pushed on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_AppInit + * \sa SDL_AppEvent + */ +extern SDLMAIN_DECLSPEC SDL_AppResult SDLCALL SDL_AppIterate(void *appstate); + +/** + * App-implemented event entry point for SDL_MAIN_USE_CALLBACKS apps. + * + * Apps implement this function when using SDL_MAIN_USE_CALLBACKS. If using a + * standard "main" function, you should not supply this. + * + * This function is called as needed by SDL after SDL_AppInit returns + * SDL_APP_CONTINUE. It is called once for each new event. + * + * There is (currently) no guarantee about what thread this will be called + * from; whatever thread pushes an event onto SDL's queue will trigger this + * function. SDL is responsible for pumping the event queue between each call + * to SDL_AppIterate, so in normal operation one should only get events in a + * serial fashion, but be careful if you have a thread that explicitly calls + * SDL_PushEvent. SDL itself will push events to the queue on the main thread. + * + * Events sent to this function are not owned by the app; if you need to save + * the data, you should copy it. + * + * This function should not go into an infinite mainloop; it should handle the + * provided event appropriately and return. + * + * The `appstate` parameter is an optional pointer provided by the app during + * SDL_AppInit(). If the app never provided a pointer, this will be NULL. + * + * If this function returns SDL_APP_CONTINUE, the app will continue normal + * operation, receiving repeated calls to SDL_AppIterate and SDL_AppEvent for + * the life of the program. If this function returns SDL_APP_FAILURE, SDL will + * call SDL_AppQuit and terminate the process with an exit code that reports + * an error to the platform. If it returns SDL_APP_SUCCESS, SDL calls + * SDL_AppQuit and terminates with an exit code that reports success to the + * platform. + * + * \param appstate an optional pointer, provided by the app in SDL_AppInit. + * \param event the new event for the app to examine. + * \returns SDL_APP_FAILURE to terminate with an error, SDL_APP_SUCCESS to + * terminate with success, SDL_APP_CONTINUE to continue. + * + * \threadsafety This function may get called concurrently with + * SDL_AppIterate() or SDL_AppQuit() for events not pushed from + * the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_AppInit + * \sa SDL_AppIterate + */ +extern SDLMAIN_DECLSPEC SDL_AppResult SDLCALL SDL_AppEvent(void *appstate, SDL_Event *event); + +/** + * App-implemented deinit entry point for SDL_MAIN_USE_CALLBACKS apps. + * + * Apps implement this function when using SDL_MAIN_USE_CALLBACKS. If using a + * standard "main" function, you should not supply this. + * + * This function is called once by SDL before terminating the program. + * + * This function will be called in all cases, even if SDL_AppInit requests + * termination at startup. + * + * This function should not go into an infinite mainloop; it should + * deinitialize any resources necessary, perform whatever shutdown activities, + * and return. + * + * You do not need to call SDL_Quit() in this function, as SDL will call it + * after this function returns and before the process terminates, but it is + * safe to do so. + * + * The `appstate` parameter is an optional pointer provided by the app during + * SDL_AppInit(). If the app never provided a pointer, this will be NULL. This + * function call is the last time this pointer will be provided, so any + * resources to it should be cleaned up here. + * + * This function is called by SDL on the main thread. + * + * \param appstate an optional pointer, provided by the app in SDL_AppInit. + * \param result the result code that terminated the app (success or failure). + * + * \threadsafety SDL_AppEvent() may get called concurrently with this function + * if other threads that push events are still active. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_AppInit + */ +extern SDLMAIN_DECLSPEC void SDLCALL SDL_AppQuit(void *appstate, SDL_AppResult result); + +#endif /* SDL_MAIN_USE_CALLBACKS */ + + +/** + * The prototype for the application's main() function + * + * \param argc an ANSI-C style main function's argc. + * \param argv an ANSI-C style main function's argv. + * \returns an ANSI-C main return code; generally 0 is considered successful + * program completion, and small non-zero values are considered + * errors. + * + * \since This datatype is available since SDL 3.2.0. + */ +typedef int (SDLCALL *SDL_main_func)(int argc, char *argv[]); + +/** + * An app-supplied function for program entry. + * + * Apps do not directly create this function; they should create a standard + * ANSI-C `main` function instead. If SDL needs to insert some startup code + * before `main` runs, or the platform doesn't actually _use_ a function + * called "main", SDL will do some macro magic to redefine `main` to + * `SDL_main` and provide its own `main`. + * + * Apps should include `SDL_main.h` in the same file as their `main` function, + * and they should not use that symbol for anything else in that file, as it + * might get redefined. + * + * This function is only provided by the app if it isn't using + * SDL_MAIN_USE_CALLBACKS. + * + * Program startup is a surprisingly complex topic. Please see + * [README-main-functions](README-main-functions), (or + * docs/README-main-functions.md in the source tree) for a more detailed + * explanation. + * + * \param argc an ANSI-C style main function's argc. + * \param argv an ANSI-C style main function's argv. + * \returns an ANSI-C main return code; generally 0 is considered successful + * program completion, and small non-zero values are considered + * errors. + * + * \threadsafety This is the program entry point. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDLMAIN_DECLSPEC int SDLCALL SDL_main(int argc, char *argv[]); + +/** + * Circumvent failure of SDL_Init() when not using SDL_main() as an entry + * point. + * + * This function is defined in SDL_main.h, along with the preprocessor rule to + * redefine main() as SDL_main(). Thus to ensure that your main() function + * will not be changed it is necessary to define SDL_MAIN_HANDLED before + * including SDL.h. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_Init + */ +extern SDL_DECLSPEC void SDLCALL SDL_SetMainReady(void); + +/** + * Initializes and launches an SDL application, by doing platform-specific + * initialization before calling your mainFunction and cleanups after it + * returns, if that is needed for a specific platform, otherwise it just calls + * mainFunction. + * + * You can use this if you want to use your own main() implementation without + * using SDL_main (like when using SDL_MAIN_HANDLED). When using this, you do + * *not* need SDL_SetMainReady(). + * + * If `argv` is NULL, SDL will provide command line arguments, either by + * querying the OS for them if possible, or supplying a filler array if not. + * + * \param argc the argc parameter from the application's main() function, or 0 + * if the platform's main-equivalent has no argc. + * \param argv the argv parameter from the application's main() function, or + * NULL if the platform's main-equivalent has no argv. + * \param mainFunction your SDL app's C-style main(). NOT the function you're + * calling this from! Its name doesn't matter; it doesn't + * literally have to be `main`. + * \param reserved should be NULL (reserved for future use, will probably be + * platform-specific then). + * \returns the return value from mainFunction: 0 on success, otherwise + * failure; SDL_GetError() might have more information on the + * failure. + * + * \threadsafety Generally this is called once, near startup, from the + * process's initial thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_RunApp(int argc, char *argv[], SDL_main_func mainFunction, void *reserved); + +/** + * An entry point for SDL's use in SDL_MAIN_USE_CALLBACKS. + * + * Generally, you should not call this function directly. This only exists to + * hand off work into SDL as soon as possible, where it has a lot more control + * and functionality available, and make the inline code in SDL_main.h as + * small as possible. + * + * Not all platforms use this, it's actual use is hidden in a magic + * header-only library, and you should not call this directly unless you + * _really_ know what you're doing. + * + * \param argc standard Unix main argc. + * \param argv standard Unix main argv. + * \param appinit the application's SDL_AppInit function. + * \param appiter the application's SDL_AppIterate function. + * \param appevent the application's SDL_AppEvent function. + * \param appquit the application's SDL_AppQuit function. + * \returns standard Unix main return value. + * + * \threadsafety It is not safe to call this anywhere except as the only + * function call in SDL_main. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_EnterAppMainCallbacks(int argc, char *argv[], SDL_AppInit_func appinit, SDL_AppIterate_func appiter, SDL_AppEvent_func appevent, SDL_AppQuit_func appquit); + + +#if defined(SDL_PLATFORM_WINDOWS) + +/** + * Register a win32 window class for SDL's use. + * + * This can be called to set the application window class at startup. It is + * safe to call this multiple times, as long as every call is eventually + * paired with a call to SDL_UnregisterApp, but a second registration attempt + * while a previous registration is still active will be ignored, other than + * to increment a counter. + * + * Most applications do not need to, and should not, call this directly; SDL + * will call it when initializing the video subsystem. + * + * If `name` is NULL, SDL currently uses `(CS_BYTEALIGNCLIENT | CS_OWNDC)` for + * the style, regardless of what is specified here. + * + * \param name the window class name, in UTF-8 encoding. If NULL, SDL + * currently uses "SDL_app" but this isn't guaranteed. + * \param style the value to use in WNDCLASSEX::style. + * \param hInst the HINSTANCE to use in WNDCLASSEX::hInstance. If zero, SDL + * will use `GetModuleHandle(NULL)` instead. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_RegisterApp(const char *name, Uint32 style, void *hInst); + +/** + * Deregister the win32 window class from an SDL_RegisterApp call. + * + * This can be called to undo the effects of SDL_RegisterApp. + * + * Most applications do not need to, and should not, call this directly; SDL + * will call it when deinitializing the video subsystem. + * + * It is safe to call this multiple times, as long as every call is eventually + * paired with a prior call to SDL_RegisterApp. The window class will only be + * deregistered when the registration counter in SDL_RegisterApp decrements to + * zero through calls to this function. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_UnregisterApp(void); + +#endif /* defined(SDL_PLATFORM_WINDOWS) */ + +/** + * Callback from the application to let the suspend continue. + * + * This function is only needed for Xbox GDK support; all other platforms will + * do nothing and set an "unsupported" error message. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_GDKSuspendComplete(void); + +#ifdef __cplusplus +} +#endif + +#include + +#if !defined(SDL_MAIN_HANDLED) && !defined(SDL_MAIN_NOIMPL) + /* include header-only SDL_main implementations */ + #if defined(SDL_MAIN_USE_CALLBACKS) || defined(SDL_MAIN_NEEDED) || defined(SDL_MAIN_AVAILABLE) + /* platforms which main (-equivalent) can be implemented in plain C */ + #include + #endif +#endif + +#endif /* SDL_main_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_main_impl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_main_impl.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,151 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* WIKI CATEGORY: Main */ + +#ifndef SDL_main_impl_h_ +#define SDL_main_impl_h_ + +#ifndef SDL_main_h_ +#error "This header should not be included directly, but only via SDL_main.h!" +#endif + +/* if someone wants to include SDL_main.h but doesn't want the main handing magic, + (maybe to call SDL_RegisterApp()) they can #define SDL_MAIN_HANDLED first. + SDL_MAIN_NOIMPL is for SDL-internal usage (only affects implementation, + not definition of SDL_MAIN_AVAILABLE etc in SDL_main.h) and if the user wants + to have the SDL_main implementation (from this header) in another source file + than their main() function, for example if SDL_main requires C++ + and main() is implemented in plain C */ +#if !defined(SDL_MAIN_HANDLED) && !defined(SDL_MAIN_NOIMPL) + + /* the implementations below must be able to use the implement real main(), nothing renamed + (the user's main() will be renamed to SDL_main so it can be called from here) */ + #ifdef main + #undef main + #endif + + #ifdef SDL_MAIN_USE_CALLBACKS + + #if 0 + /* currently there are no platforms that _need_ a magic entry point here + for callbacks, but if one shows up, implement it here. */ + + #else /* use a standard SDL_main, which the app SHOULD NOT ALSO SUPPLY. */ + + /* this define makes the normal SDL_main entry point stuff work...we just provide SDL_main() instead of the app. */ + #define SDL_MAIN_CALLBACK_STANDARD 1 + + int SDL_main(int argc, char **argv) + { + return SDL_EnterAppMainCallbacks(argc, argv, SDL_AppInit, SDL_AppIterate, SDL_AppEvent, SDL_AppQuit); + } + + #endif /* platform-specific tests */ + + #endif /* SDL_MAIN_USE_CALLBACKS */ + + + /* set up the usual SDL_main stuff if we're not using callbacks or if we are but need the normal entry point, + unless the real entry point needs to be somewhere else entirely, like Android where it's in Java code */ + #if (!defined(SDL_MAIN_USE_CALLBACKS) || defined(SDL_MAIN_CALLBACK_STANDARD)) && !defined(SDL_MAIN_EXPORTED) + + #if defined(SDL_PLATFORM_PRIVATE_MAIN) + /* Private platforms may have their own ideas about entry points. */ + #include "SDL_main_impl_private.h" + + #elif defined(SDL_PLATFORM_WINDOWS) + + /* these defines/typedefs are needed for the WinMain() definition */ + #ifndef WINAPI + #define WINAPI __stdcall + #endif + + typedef struct HINSTANCE__ * HINSTANCE; + typedef char *LPSTR; + typedef wchar_t *PWSTR; + + /* The VC++ compiler needs main/wmain defined, but not for GDK */ + #if defined(_MSC_VER) && !defined(SDL_PLATFORM_GDK) + + /* This is where execution begins [console apps] */ + #if defined(UNICODE) && UNICODE + int wmain(int argc, wchar_t *wargv[], wchar_t *wenvp) + { + (void)argc; + (void)wargv; + (void)wenvp; + return SDL_RunApp(0, NULL, SDL_main, NULL); + } + #else /* ANSI */ + int main(int argc, char *argv[]) + { + (void)argc; + (void)argv; + return SDL_RunApp(0, NULL, SDL_main, NULL); + } + #endif /* UNICODE */ + + #endif /* _MSC_VER && ! SDL_PLATFORM_GDK */ + + /* This is where execution begins [windowed apps and GDK] */ + + #ifdef __cplusplus + extern "C" { + #endif + + #if defined(UNICODE) && UNICODE + int WINAPI wWinMain(HINSTANCE hInst, HINSTANCE hPrev, PWSTR szCmdLine, int sw) + #else /* ANSI */ + int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) + #endif + { + (void)hInst; + (void)hPrev; + (void)szCmdLine; + (void)sw; + return SDL_RunApp(0, NULL, SDL_main, NULL); + } + + #ifdef __cplusplus + } /* extern "C" */ + #endif + + /* end of SDL_PLATFORM_WINDOWS impls */ + + #else /* platforms that use a standard main() and just call SDL_RunApp(), like iOS and 3DS */ + int main(int argc, char *argv[]) + { + return SDL_RunApp(argc, argv, SDL_main, NULL); + } + + /* end of impls for standard-conforming platforms */ + + #endif /* SDL_PLATFORM_WIN32 etc */ + + #endif /* !defined(SDL_MAIN_USE_CALLBACKS) || defined(SDL_MAIN_CALLBACK_STANDARD) */ + + /* rename users main() function to SDL_main() so it can be called from the wrappers above */ + #define main SDL_main + +#endif /* SDL_MAIN_HANDLED */ + +#endif /* SDL_main_impl_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_messagebox.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_messagebox.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,226 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * # CategoryMessagebox + * + * SDL offers a simple message box API, which is useful for simple alerts, + * such as informing the user when something fatal happens at startup without + * the need to build a UI for it (or informing the user _before_ your UI is + * ready). + * + * These message boxes are native system dialogs where possible. + * + * There is both a customizable function (SDL_ShowMessageBox()) that offers + * lots of options for what to display and reports on what choice the user + * made, and also a much-simplified version (SDL_ShowSimpleMessageBox()), + * merely takes a text message and title, and waits until the user presses a + * single "OK" UI button. Often, this is all that is necessary. + */ + +#ifndef SDL_messagebox_h_ +#define SDL_messagebox_h_ + +#include +#include +#include /* For SDL_Window */ + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Message box flags. + * + * If supported will display warning icon, etc. + * + * \since This datatype is available since SDL 3.2.0. + */ +typedef Uint32 SDL_MessageBoxFlags; + +#define SDL_MESSAGEBOX_ERROR 0x00000010u /**< error dialog */ +#define SDL_MESSAGEBOX_WARNING 0x00000020u /**< warning dialog */ +#define SDL_MESSAGEBOX_INFORMATION 0x00000040u /**< informational dialog */ +#define SDL_MESSAGEBOX_BUTTONS_LEFT_TO_RIGHT 0x00000080u /**< buttons placed left to right */ +#define SDL_MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT 0x00000100u /**< buttons placed right to left */ + +/** + * SDL_MessageBoxButtonData flags. + * + * \since This datatype is available since SDL 3.2.0. + */ +typedef Uint32 SDL_MessageBoxButtonFlags; + +#define SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT 0x00000001u /**< Marks the default button when return is hit */ +#define SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT 0x00000002u /**< Marks the default button when escape is hit */ + +/** + * Individual button data. + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_MessageBoxButtonData +{ + SDL_MessageBoxButtonFlags flags; + int buttonID; /**< User defined button id (value returned via SDL_ShowMessageBox) */ + const char *text; /**< The UTF-8 button text */ +} SDL_MessageBoxButtonData; + +/** + * RGB value used in a message box color scheme + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_MessageBoxColor +{ + Uint8 r, g, b; +} SDL_MessageBoxColor; + +/** + * An enumeration of indices inside the colors array of + * SDL_MessageBoxColorScheme. + */ +typedef enum SDL_MessageBoxColorType +{ + SDL_MESSAGEBOX_COLOR_BACKGROUND, + SDL_MESSAGEBOX_COLOR_TEXT, + SDL_MESSAGEBOX_COLOR_BUTTON_BORDER, + SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND, + SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED, + SDL_MESSAGEBOX_COLOR_COUNT /**< Size of the colors array of SDL_MessageBoxColorScheme. */ +} SDL_MessageBoxColorType; + +/** + * A set of colors to use for message box dialogs + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_MessageBoxColorScheme +{ + SDL_MessageBoxColor colors[SDL_MESSAGEBOX_COLOR_COUNT]; +} SDL_MessageBoxColorScheme; + +/** + * MessageBox structure containing title, text, window, etc. + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_MessageBoxData +{ + SDL_MessageBoxFlags flags; + SDL_Window *window; /**< Parent window, can be NULL */ + const char *title; /**< UTF-8 title */ + const char *message; /**< UTF-8 message text */ + + int numbuttons; + const SDL_MessageBoxButtonData *buttons; + + const SDL_MessageBoxColorScheme *colorScheme; /**< SDL_MessageBoxColorScheme, can be NULL to use system settings */ +} SDL_MessageBoxData; + +/** + * Create a modal message box. + * + * If your needs aren't complex, it might be easier to use + * SDL_ShowSimpleMessageBox. + * + * This function should be called on the thread that created the parent + * window, or on the main thread if the messagebox has no parent. It will + * block execution of that thread until the user clicks a button or closes the + * messagebox. + * + * This function may be called at any time, even before SDL_Init(). This makes + * it useful for reporting errors like a failure to create a renderer or + * OpenGL context. + * + * On X11, SDL rolls its own dialog box with X11 primitives instead of a + * formal toolkit like GTK+ or Qt. + * + * Note that if SDL_Init() would fail because there isn't any available video + * target, this function is likely to fail for the same reasons. If this is a + * concern, check the return value from this function and fall back to writing + * to stderr if you can. + * + * \param messageboxdata the SDL_MessageBoxData structure with title, text and + * other options. + * \param buttonid the pointer to which user id of hit button should be + * copied. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_ShowSimpleMessageBox + */ +extern SDL_DECLSPEC bool SDLCALL SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid); + +/** + * Display a simple modal message box. + * + * If your needs aren't complex, this function is preferred over + * SDL_ShowMessageBox. + * + * `flags` may be any of the following: + * + * - `SDL_MESSAGEBOX_ERROR`: error dialog + * - `SDL_MESSAGEBOX_WARNING`: warning dialog + * - `SDL_MESSAGEBOX_INFORMATION`: informational dialog + * + * This function should be called on the thread that created the parent + * window, or on the main thread if the messagebox has no parent. It will + * block execution of that thread until the user clicks a button or closes the + * messagebox. + * + * This function may be called at any time, even before SDL_Init(). This makes + * it useful for reporting errors like a failure to create a renderer or + * OpenGL context. + * + * On X11, SDL rolls its own dialog box with X11 primitives instead of a + * formal toolkit like GTK+ or Qt. + * + * Note that if SDL_Init() would fail because there isn't any available video + * target, this function is likely to fail for the same reasons. If this is a + * concern, check the return value from this function and fall back to writing + * to stderr if you can. + * + * \param flags an SDL_MessageBoxFlags value. + * \param title UTF-8 title text. + * \param message UTF-8 message text. + * \param window the parent window, or NULL for no parent. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_ShowMessageBox + */ +extern SDL_DECLSPEC bool SDLCALL SDL_ShowSimpleMessageBox(SDL_MessageBoxFlags flags, const char *title, const char *message, SDL_Window *window); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_messagebox_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_metal.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_metal.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,107 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * # CategoryMetal + * + * Functions to creating Metal layers and views on SDL windows. + * + * This provides some platform-specific glue for Apple platforms. Most macOS + * and iOS apps can use SDL without these functions, but this API they can be + * useful for specific OS-level integration tasks. + */ + +#ifndef SDL_metal_h_ +#define SDL_metal_h_ + +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * A handle to a CAMetalLayer-backed NSView (macOS) or UIView (iOS/tvOS). + * + * \since This datatype is available since SDL 3.2.0. + */ +typedef void *SDL_MetalView; + +/** + * \name Metal support functions + */ +/* @{ */ + +/** + * Create a CAMetalLayer-backed NSView/UIView and attach it to the specified + * window. + * + * On macOS, this does *not* associate a MTLDevice with the CAMetalLayer on + * its own. It is up to user code to do that. + * + * The returned handle can be casted directly to a NSView or UIView. To access + * the backing CAMetalLayer, call SDL_Metal_GetLayer(). + * + * \param window the window. + * \returns handle NSView or UIView. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_Metal_DestroyView + * \sa SDL_Metal_GetLayer + */ +extern SDL_DECLSPEC SDL_MetalView SDLCALL SDL_Metal_CreateView(SDL_Window *window); + +/** + * Destroy an existing SDL_MetalView object. + * + * This should be called before SDL_DestroyWindow, if SDL_Metal_CreateView was + * called after SDL_CreateWindow. + * + * \param view the SDL_MetalView object. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_Metal_CreateView + */ +extern SDL_DECLSPEC void SDLCALL SDL_Metal_DestroyView(SDL_MetalView view); + +/** + * Get a pointer to the backing CAMetalLayer for the given view. + * + * \param view the SDL_MetalView object. + * \returns a pointer. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void * SDLCALL SDL_Metal_GetLayer(SDL_MetalView view); + +/* @} *//* Metal support functions */ + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_metal_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_misc.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_misc.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,78 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * # CategoryMisc + * + * SDL API functions that don't fit elsewhere. + */ + +#ifndef SDL_misc_h_ +#define SDL_misc_h_ + +#include +#include + +#include + +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Open a URL/URI in the browser or other appropriate external application. + * + * Open a URL in a separate, system-provided application. How this works will + * vary wildly depending on the platform. This will likely launch what makes + * sense to handle a specific URL's protocol (a web browser for `http://`, + * etc), but it might also be able to launch file managers for directories and + * other things. + * + * What happens when you open a URL varies wildly as well: your game window + * may lose focus (and may or may not lose focus if your game was fullscreen + * or grabbing input at the time). On mobile devices, your app will likely + * move to the background or your process might be paused. Any given platform + * may or may not handle a given URL. + * + * If this is unimplemented (or simply unavailable) for a platform, this will + * fail with an error. A successful result does not mean the URL loaded, just + * that we launched _something_ to handle it (or at least believe we did). + * + * All this to say: this function can be useful, but you should definitely + * test it on every platform you target. + * + * \param url a valid URL/URI to open. Use `file:///full/path/to/file` for + * local files, if supported. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_OpenURL(const char *url); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_misc_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_mouse.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_mouse.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,813 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * # CategoryMouse + * + * Any GUI application has to deal with the mouse, and SDL provides functions + * to manage mouse input and the displayed cursor. + * + * Most interactions with the mouse will come through the event subsystem. + * Moving a mouse generates an SDL_EVENT_MOUSE_MOTION event, pushing a button + * generates SDL_EVENT_MOUSE_BUTTON_DOWN, etc, but one can also query the + * current state of the mouse at any time with SDL_GetMouseState(). + * + * For certain games, it's useful to disassociate the mouse cursor from mouse + * input. An FPS, for example, would not want the player's motion to stop as + * the mouse hits the edge of the window. For these scenarios, use + * SDL_SetWindowRelativeMouseMode(), which hides the cursor, grabs mouse input + * to the window, and reads mouse input no matter how far it moves. + * + * Games that want the system to track the mouse but want to draw their own + * cursor can use SDL_HideCursor() and SDL_ShowCursor(). It might be more + * efficient to let the system manage the cursor, if possible, using + * SDL_SetCursor() with a custom image made through SDL_CreateColorCursor(), + * or perhaps just a specific system cursor from SDL_CreateSystemCursor(). + * + * SDL can, on many platforms, differentiate between multiple connected mice, + * allowing for interesting input scenarios and multiplayer games. They can be + * enumerated with SDL_GetMice(), and SDL will send SDL_EVENT_MOUSE_ADDED and + * SDL_EVENT_MOUSE_REMOVED events as they are connected and unplugged. + * + * Since many apps only care about basic mouse input, SDL offers a virtual + * mouse device for touch and pen input, which often can make a desktop + * application work on a touchscreen phone without any code changes. Apps that + * care about touch/pen separately from mouse input should filter out events + * with a `which` field of SDL_TOUCH_MOUSEID/SDL_PEN_MOUSEID. + */ + +#ifndef SDL_mouse_h_ +#define SDL_mouse_h_ + +#include +#include +#include +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * This is a unique ID for a mouse for the time it is connected to the system, + * and is never reused for the lifetime of the application. + * + * If the mouse is disconnected and reconnected, it will get a new ID. + * + * The value 0 is an invalid ID. + * + * \since This datatype is available since SDL 3.2.0. + */ +typedef Uint32 SDL_MouseID; + +/** + * The structure used to identify an SDL cursor. + * + * This is opaque data. + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_Cursor SDL_Cursor; + +/** + * Cursor types for SDL_CreateSystemCursor(). + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_SystemCursor +{ + SDL_SYSTEM_CURSOR_DEFAULT, /**< Default cursor. Usually an arrow. */ + SDL_SYSTEM_CURSOR_TEXT, /**< Text selection. Usually an I-beam. */ + SDL_SYSTEM_CURSOR_WAIT, /**< Wait. Usually an hourglass or watch or spinning ball. */ + SDL_SYSTEM_CURSOR_CROSSHAIR, /**< Crosshair. */ + SDL_SYSTEM_CURSOR_PROGRESS, /**< Program is busy but still interactive. Usually it's WAIT with an arrow. */ + SDL_SYSTEM_CURSOR_NWSE_RESIZE, /**< Double arrow pointing northwest and southeast. */ + SDL_SYSTEM_CURSOR_NESW_RESIZE, /**< Double arrow pointing northeast and southwest. */ + SDL_SYSTEM_CURSOR_EW_RESIZE, /**< Double arrow pointing west and east. */ + SDL_SYSTEM_CURSOR_NS_RESIZE, /**< Double arrow pointing north and south. */ + SDL_SYSTEM_CURSOR_MOVE, /**< Four pointed arrow pointing north, south, east, and west. */ + SDL_SYSTEM_CURSOR_NOT_ALLOWED, /**< Not permitted. Usually a slashed circle or crossbones. */ + SDL_SYSTEM_CURSOR_POINTER, /**< Pointer that indicates a link. Usually a pointing hand. */ + SDL_SYSTEM_CURSOR_NW_RESIZE, /**< Window resize top-left. This may be a single arrow or a double arrow like NWSE_RESIZE. */ + SDL_SYSTEM_CURSOR_N_RESIZE, /**< Window resize top. May be NS_RESIZE. */ + SDL_SYSTEM_CURSOR_NE_RESIZE, /**< Window resize top-right. May be NESW_RESIZE. */ + SDL_SYSTEM_CURSOR_E_RESIZE, /**< Window resize right. May be EW_RESIZE. */ + SDL_SYSTEM_CURSOR_SE_RESIZE, /**< Window resize bottom-right. May be NWSE_RESIZE. */ + SDL_SYSTEM_CURSOR_S_RESIZE, /**< Window resize bottom. May be NS_RESIZE. */ + SDL_SYSTEM_CURSOR_SW_RESIZE, /**< Window resize bottom-left. May be NESW_RESIZE. */ + SDL_SYSTEM_CURSOR_W_RESIZE, /**< Window resize left. May be EW_RESIZE. */ + SDL_SYSTEM_CURSOR_COUNT +} SDL_SystemCursor; + +/** + * Scroll direction types for the Scroll event + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_MouseWheelDirection +{ + SDL_MOUSEWHEEL_NORMAL, /**< The scroll direction is normal */ + SDL_MOUSEWHEEL_FLIPPED /**< The scroll direction is flipped / natural */ +} SDL_MouseWheelDirection; + +/** + * Animated cursor frame info. + * + * \since This struct is available since SDL 3.4.0. + */ +typedef struct SDL_CursorFrameInfo +{ + SDL_Surface *surface; /**< The surface data for this frame */ + Uint32 duration; /**< The frame duration in milliseconds (a duration of 0 is infinite) */ +} SDL_CursorFrameInfo; + +/** + * A bitmask of pressed mouse buttons, as reported by SDL_GetMouseState, etc. + * + * - Button 1: Left mouse button + * - Button 2: Middle mouse button + * - Button 3: Right mouse button + * - Button 4: Side mouse button 1 + * - Button 5: Side mouse button 2 + * + * \since This datatype is available since SDL 3.2.0. + * + * \sa SDL_GetMouseState + * \sa SDL_GetGlobalMouseState + * \sa SDL_GetRelativeMouseState + */ +typedef Uint32 SDL_MouseButtonFlags; + +#define SDL_BUTTON_LEFT 1 +#define SDL_BUTTON_MIDDLE 2 +#define SDL_BUTTON_RIGHT 3 +#define SDL_BUTTON_X1 4 +#define SDL_BUTTON_X2 5 + +#define SDL_BUTTON_MASK(X) (1u << ((X)-1)) +#define SDL_BUTTON_LMASK SDL_BUTTON_MASK(SDL_BUTTON_LEFT) +#define SDL_BUTTON_MMASK SDL_BUTTON_MASK(SDL_BUTTON_MIDDLE) +#define SDL_BUTTON_RMASK SDL_BUTTON_MASK(SDL_BUTTON_RIGHT) +#define SDL_BUTTON_X1MASK SDL_BUTTON_MASK(SDL_BUTTON_X1) +#define SDL_BUTTON_X2MASK SDL_BUTTON_MASK(SDL_BUTTON_X2) + +/** + * A callback used to transform mouse motion delta from raw values. + * + * This is called during SDL's handling of platform mouse events to scale the + * values of the resulting motion delta. + * + * \param userdata what was passed as `userdata` to + * SDL_SetRelativeMouseTransform(). + * \param timestamp the associated time at which this mouse motion event was + * received. + * \param window the associated window to which this mouse motion event was + * addressed. + * \param mouseID the associated mouse from which this mouse motion event was + * emitted. + * \param x pointer to a variable that will be treated as the resulting x-axis + * motion. + * \param y pointer to a variable that will be treated as the resulting y-axis + * motion. + * + * \threadsafety This callback is called by SDL's internal mouse input + * processing procedure, which may be a thread separate from the + * main event loop that is run at realtime priority. Stalling + * this thread with too much work in the callback can therefore + * potentially freeze the entire system. Care should be taken + * with proper synchronization practices when adding other side + * effects beyond mutation of the x and y values. + * + * \since This datatype is available since SDL 3.4.0. + * + * \sa SDL_SetRelativeMouseTransform + */ +typedef void (SDLCALL *SDL_MouseMotionTransformCallback)( + void *userdata, + Uint64 timestamp, + SDL_Window *window, + SDL_MouseID mouseID, + float *x, float *y +); + +/* Function prototypes */ + +/** + * Return whether a mouse is currently connected. + * + * \returns true if a mouse is connected, false otherwise. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetMice + */ +extern SDL_DECLSPEC bool SDLCALL SDL_HasMouse(void); + +/** + * Get a list of currently connected mice. + * + * Note that this will include any device or virtual driver that includes + * mouse functionality, including some game controllers, KVM switches, etc. + * You should wait for input from a device before you consider it actively in + * use. + * + * \param count a pointer filled in with the number of mice returned, may be + * NULL. + * \returns a 0 terminated array of mouse instance IDs or NULL on failure; + * call SDL_GetError() for more information. This should be freed + * with SDL_free() when it is no longer needed. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetMouseNameForID + * \sa SDL_HasMouse + */ +extern SDL_DECLSPEC SDL_MouseID * SDLCALL SDL_GetMice(int *count); + +/** + * Get the name of a mouse. + * + * This function returns "" if the mouse doesn't have a name. + * + * \param instance_id the mouse instance ID. + * \returns the name of the selected mouse, or NULL on failure; call + * SDL_GetError() for more information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetMice + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetMouseNameForID(SDL_MouseID instance_id); + +/** + * Get the window which currently has mouse focus. + * + * \returns the window with mouse focus. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetMouseFocus(void); + +/** + * Query SDL's cache for the synchronous mouse button state and the + * window-relative SDL-cursor position. + * + * This function returns the cached synchronous state as SDL understands it + * from the last pump of the event queue. + * + * To query the platform for immediate asynchronous state, use + * SDL_GetGlobalMouseState. + * + * Passing non-NULL pointers to `x` or `y` will write the destination with + * respective x or y coordinates relative to the focused window. + * + * In Relative Mode, the SDL-cursor's position usually contradicts the + * platform-cursor's position as manually calculated from + * SDL_GetGlobalMouseState() and SDL_GetWindowPosition. + * + * \param x a pointer to receive the SDL-cursor's x-position from the focused + * window's top left corner, can be NULL if unused. + * \param y a pointer to receive the SDL-cursor's y-position from the focused + * window's top left corner, can be NULL if unused. + * \returns a 32-bit bitmask of the button state that can be bitwise-compared + * against the SDL_BUTTON_MASK(X) macro. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetGlobalMouseState + * \sa SDL_GetRelativeMouseState + */ +extern SDL_DECLSPEC SDL_MouseButtonFlags SDLCALL SDL_GetMouseState(float *x, float *y); + +/** + * Query the platform for the asynchronous mouse button state and the + * desktop-relative platform-cursor position. + * + * This function immediately queries the platform for the most recent + * asynchronous state, more costly than retrieving SDL's cached state in + * SDL_GetMouseState(). + * + * Passing non-NULL pointers to `x` or `y` will write the destination with + * respective x or y coordinates relative to the desktop. + * + * In Relative Mode, the platform-cursor's position usually contradicts the + * SDL-cursor's position as manually calculated from SDL_GetMouseState() and + * SDL_GetWindowPosition. + * + * This function can be useful if you need to track the mouse outside of a + * specific window and SDL_CaptureMouse() doesn't fit your needs. For example, + * it could be useful if you need to track the mouse while dragging a window, + * where coordinates relative to a window might not be in sync at all times. + * + * \param x a pointer to receive the platform-cursor's x-position from the + * desktop's top left corner, can be NULL if unused. + * \param y a pointer to receive the platform-cursor's y-position from the + * desktop's top left corner, can be NULL if unused. + * \returns a 32-bit bitmask of the button state that can be bitwise-compared + * against the SDL_BUTTON_MASK(X) macro. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CaptureMouse + * \sa SDL_GetMouseState + * \sa SDL_GetGlobalMouseState + */ +extern SDL_DECLSPEC SDL_MouseButtonFlags SDLCALL SDL_GetGlobalMouseState(float *x, float *y); + +/** + * Query SDL's cache for the synchronous mouse button state and accumulated + * mouse delta since last call. + * + * This function returns the cached synchronous state as SDL understands it + * from the last pump of the event queue. + * + * To query the platform for immediate asynchronous state, use + * SDL_GetGlobalMouseState. + * + * Passing non-NULL pointers to `x` or `y` will write the destination with + * respective x or y deltas accumulated since the last call to this function + * (or since event initialization). + * + * This function is useful for reducing overhead by processing relative mouse + * inputs in one go per-frame instead of individually per-event, at the + * expense of losing the order between events within the frame (e.g. quickly + * pressing and releasing a button within the same frame). + * + * \param x a pointer to receive the x mouse delta accumulated since last + * call, can be NULL if unused. + * \param y a pointer to receive the y mouse delta accumulated since last + * call, can be NULL if unused. + * \returns a 32-bit bitmask of the button state that can be bitwise-compared + * against the SDL_BUTTON_MASK(X) macro. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetMouseState + * \sa SDL_GetGlobalMouseState + */ +extern SDL_DECLSPEC SDL_MouseButtonFlags SDLCALL SDL_GetRelativeMouseState(float *x, float *y); + +/** + * Move the mouse cursor to the given position within the window. + * + * This function generates a mouse motion event if relative mode is not + * enabled. If relative mode is enabled, you can force mouse events for the + * warp by setting the SDL_HINT_MOUSE_RELATIVE_WARP_MOTION hint. + * + * Note that this function will appear to succeed, but not actually move the + * mouse when used over Microsoft Remote Desktop. + * + * \param window the window to move the mouse into, or NULL for the current + * mouse focus. + * \param x the x coordinate within the window. + * \param y the y coordinate within the window. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_WarpMouseGlobal + */ +extern SDL_DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_Window *window, + float x, float y); + +/** + * Move the mouse to the given position in global screen space. + * + * This function generates a mouse motion event. + * + * A failure of this function usually means that it is unsupported by a + * platform. + * + * Note that this function will appear to succeed, but not actually move the + * mouse when used over Microsoft Remote Desktop. + * + * \param x the x coordinate. + * \param y the y coordinate. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_WarpMouseInWindow + */ +extern SDL_DECLSPEC bool SDLCALL SDL_WarpMouseGlobal(float x, float y); + +/** + * Set a user-defined function by which to transform relative mouse inputs. + * + * This overrides the relative system scale and relative speed scale hints. + * Should be called prior to enabling relative mouse mode, fails otherwise. + * + * \param callback a callback used to transform relative mouse motion, or NULL + * for default behavior. + * \param userdata a pointer that will be passed to `callback`. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.4.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetRelativeMouseTransform(SDL_MouseMotionTransformCallback callback, void *userdata); + +/** + * Set relative mouse mode for a window. + * + * While the window has focus and relative mouse mode is enabled, the cursor + * is hidden, the mouse position is constrained to the window, and SDL will + * report continuous relative mouse motion even if the mouse is at the edge of + * the window. + * + * If you'd like to keep the mouse position fixed while in relative mode you + * can use SDL_SetWindowMouseRect(). If you'd like the cursor to be at a + * specific location when relative mode ends, you should use + * SDL_WarpMouseInWindow() before disabling relative mode. + * + * This function will flush any pending mouse motion for this window. + * + * \param window the window to change. + * \param enabled true to enable relative mode, false to disable. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetWindowRelativeMouseMode + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowRelativeMouseMode(SDL_Window *window, bool enabled); + +/** + * Query whether relative mouse mode is enabled for a window. + * + * \param window the window to query. + * \returns true if relative mode is enabled for a window or false otherwise. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetWindowRelativeMouseMode + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetWindowRelativeMouseMode(SDL_Window *window); + +/** + * Capture the mouse and to track input outside an SDL window. + * + * Capturing enables your app to obtain mouse events globally, instead of just + * within your window. Not all video targets support this function. When + * capturing is enabled, the current window will get all mouse events, but + * unlike relative mode, no change is made to the cursor and it is not + * restrained to your window. + * + * This function may also deny mouse input to other windows--both those in + * your application and others on the system--so you should use this function + * sparingly, and in small bursts. For example, you might want to track the + * mouse while the user is dragging something, until the user releases a mouse + * button. It is not recommended that you capture the mouse for long periods + * of time, such as the entire time your app is running. For that, you should + * probably use SDL_SetWindowRelativeMouseMode() or SDL_SetWindowMouseGrab(), + * depending on your goals. + * + * While captured, mouse events still report coordinates relative to the + * current (foreground) window, but those coordinates may be outside the + * bounds of the window (including negative values). Capturing is only allowed + * for the foreground window. If the window loses focus while capturing, the + * capture will be disabled automatically. + * + * While capturing is enabled, the current window will have the + * `SDL_WINDOW_MOUSE_CAPTURE` flag set. + * + * Please note that SDL will attempt to "auto capture" the mouse while the + * user is pressing a button; this is to try and make mouse behavior more + * consistent between platforms, and deal with the common case of a user + * dragging the mouse outside of the window. This means that if you are + * calling SDL_CaptureMouse() only to deal with this situation, you do not + * have to (although it is safe to do so). If this causes problems for your + * app, you can disable auto capture by setting the + * `SDL_HINT_MOUSE_AUTO_CAPTURE` hint to zero. + * + * \param enabled true to enable capturing, false to disable. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetGlobalMouseState + */ +extern SDL_DECLSPEC bool SDLCALL SDL_CaptureMouse(bool enabled); + +/** + * Create a cursor using the specified bitmap data and mask (in MSB format). + * + * `mask` has to be in MSB (Most Significant Bit) format. + * + * The cursor width (`w`) must be a multiple of 8 bits. + * + * The cursor is created in black and white according to the following: + * + * - data=0, mask=1: white + * - data=1, mask=1: black + * - data=0, mask=0: transparent + * - data=1, mask=0: inverted color if possible, black if not. + * + * Cursors created with this function must be freed with SDL_DestroyCursor(). + * + * If you want to have a color cursor, or create your cursor from an + * SDL_Surface, you should use SDL_CreateColorCursor(). Alternately, you can + * hide the cursor and draw your own as part of your game's rendering, but it + * will be bound to the framerate. + * + * Also, SDL_CreateSystemCursor() is available, which provides several + * readily-available system cursors to pick from. + * + * \param data the color value for each pixel of the cursor. + * \param mask the mask value for each pixel of the cursor. + * \param w the width of the cursor. + * \param h the height of the cursor. + * \param hot_x the x-axis offset from the left of the cursor image to the + * mouse x position, in the range of 0 to `w` - 1. + * \param hot_y the y-axis offset from the top of the cursor image to the + * mouse y position, in the range of 0 to `h` - 1. + * \returns a new cursor with the specified parameters on success or NULL on + * failure; call SDL_GetError() for more information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateAnimatedCursor + * \sa SDL_CreateColorCursor + * \sa SDL_CreateSystemCursor + * \sa SDL_DestroyCursor + * \sa SDL_SetCursor + */ +extern SDL_DECLSPEC SDL_Cursor * SDLCALL SDL_CreateCursor(const Uint8 *data, + const Uint8 *mask, + int w, int h, int hot_x, + int hot_y); + +/** + * Create a color cursor. + * + * If this function is passed a surface with alternate representations added + * with SDL_AddSurfaceAlternateImage(), the surface will be interpreted as the + * content to be used for 100% display scale, and the alternate + * representations will be used for high DPI situations if + * SDL_HINT_MOUSE_DPI_SCALE_CURSORS is enabled. For example, if the original + * surface is 32x32, then on a 2x macOS display or 200% display scale on + * Windows, a 64x64 version of the image will be used, if available. If a + * matching version of the image isn't available, the closest larger size + * image will be downscaled to the appropriate size and be used instead, if + * available. Otherwise, the closest smaller image will be upscaled and be + * used instead. + * + * \param surface an SDL_Surface structure representing the cursor image. + * \param hot_x the x position of the cursor hot spot. + * \param hot_y the y position of the cursor hot spot. + * \returns the new cursor on success or NULL on failure; call SDL_GetError() + * for more information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_AddSurfaceAlternateImage + * \sa SDL_CreateAnimatedCursor + * \sa SDL_CreateCursor + * \sa SDL_CreateSystemCursor + * \sa SDL_DestroyCursor + * \sa SDL_SetCursor + */ +extern SDL_DECLSPEC SDL_Cursor * SDLCALL SDL_CreateColorCursor(SDL_Surface *surface, + int hot_x, + int hot_y); + +/** + * Create an animated color cursor. + * + * Animated cursors are composed of a sequential array of frames, specified as + * surfaces and durations in an array of SDL_CursorFrameInfo structs. The hot + * spot coordinates are universal to all frames, and all frames must have the + * same dimensions. + * + * Frame durations are specified in milliseconds. A duration of 0 implies an + * infinite frame time, and the animation will stop on that frame. To create a + * one-shot animation, set the duration of the last frame in the sequence to + * 0. + * + * If this function is passed surfaces with alternate representations added + * with SDL_AddSurfaceAlternateImage(), the surfaces will be interpreted as + * the content to be used for 100% display scale, and the alternate + * representations will be used for high DPI situations. For example, if the + * original surfaces are 32x32, then on a 2x macOS display or 200% display + * scale on Windows, a 64x64 version of the image will be used, if available. + * If a matching version of the image isn't available, the closest larger size + * image will be downscaled to the appropriate size and be used instead, if + * available. Otherwise, the closest smaller image will be upscaled and be + * used instead. + * + * If the underlying platform does not support animated cursors, this function + * will fall back to creating a static color cursor using the first frame in + * the sequence. + * + * \param frames an array of cursor images composing the animation. + * \param frame_count the number of frames in the sequence. + * \param hot_x the x position of the cursor hot spot. + * \param hot_y the y position of the cursor hot spot. + * \returns the new cursor on success or NULL on failure; call SDL_GetError() + * for more information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.4.0. + * + * \sa SDL_AddSurfaceAlternateImage + * \sa SDL_CreateCursor + * \sa SDL_CreateColorCursor + * \sa SDL_CreateSystemCursor + * \sa SDL_DestroyCursor + * \sa SDL_SetCursor + */ +extern SDL_DECLSPEC SDL_Cursor *SDLCALL SDL_CreateAnimatedCursor(SDL_CursorFrameInfo *frames, + int frame_count, + int hot_x, + int hot_y); + +/** + * Create a system cursor. + * + * \param id an SDL_SystemCursor enum value. + * \returns a cursor on success or NULL on failure; call SDL_GetError() for + * more information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_DestroyCursor + */ +extern SDL_DECLSPEC SDL_Cursor * SDLCALL SDL_CreateSystemCursor(SDL_SystemCursor id); + +/** + * Set the active cursor. + * + * This function sets the currently active cursor to the specified one. If the + * cursor is currently visible, the change will be immediately represented on + * the display. SDL_SetCursor(NULL) can be used to force cursor redraw, if + * this is desired for any reason. + * + * \param cursor a cursor to make active. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetCursor + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetCursor(SDL_Cursor *cursor); + +/** + * Get the active cursor. + * + * This function returns a pointer to the current cursor which is owned by the + * library. It is not necessary to free the cursor with SDL_DestroyCursor(). + * + * \returns the active cursor or NULL if there is no mouse. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetCursor + */ +extern SDL_DECLSPEC SDL_Cursor * SDLCALL SDL_GetCursor(void); + +/** + * Get the default cursor. + * + * You do not have to call SDL_DestroyCursor() on the return value, but it is + * safe to do so. + * + * \returns the default cursor on success or NULL on failure; call + * SDL_GetError() for more information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_Cursor * SDLCALL SDL_GetDefaultCursor(void); + +/** + * Free a previously-created cursor. + * + * Use this function to free cursor resources created with SDL_CreateCursor(), + * SDL_CreateColorCursor() or SDL_CreateSystemCursor(). + * + * \param cursor the cursor to free. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateAnimatedCursor + * \sa SDL_CreateColorCursor + * \sa SDL_CreateCursor + * \sa SDL_CreateSystemCursor + */ +extern SDL_DECLSPEC void SDLCALL SDL_DestroyCursor(SDL_Cursor *cursor); + +/** + * Show the cursor. + * + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CursorVisible + * \sa SDL_HideCursor + */ +extern SDL_DECLSPEC bool SDLCALL SDL_ShowCursor(void); + +/** + * Hide the cursor. + * + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CursorVisible + * \sa SDL_ShowCursor + */ +extern SDL_DECLSPEC bool SDLCALL SDL_HideCursor(void); + +/** + * Return whether the cursor is currently being shown. + * + * \returns `true` if the cursor is being shown, or `false` if the cursor is + * hidden. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_HideCursor + * \sa SDL_ShowCursor + */ +extern SDL_DECLSPEC bool SDLCALL SDL_CursorVisible(void); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_mouse_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_mutex.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_mutex.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,1073 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_mutex_h_ +#define SDL_mutex_h_ + +/** + * # CategoryMutex + * + * SDL offers several thread synchronization primitives. This document can't + * cover the complicated topic of thread safety, but reading up on what each + * of these primitives are, why they are useful, and how to correctly use them + * is vital to writing correct and safe multithreaded programs. + * + * - Mutexes: SDL_CreateMutex() + * - Read/Write locks: SDL_CreateRWLock() + * - Semaphores: SDL_CreateSemaphore() + * - Condition variables: SDL_CreateCondition() + * + * SDL also offers a datatype, SDL_InitState, which can be used to make sure + * only one thread initializes/deinitializes some resource that several + * threads might try to use for the first time simultaneously. + */ + +#include +#include +#include +#include + +#ifdef SDL_WIKI_DOCUMENTATION_SECTION + +/** + * Enable thread safety attributes, only with clang. + * + * The attributes can be safely erased when compiling with other compilers. + * + * To enable analysis, set these environment variables before running cmake: + * + * ```bash + * export CC=clang + * export CFLAGS="-DSDL_THREAD_SAFETY_ANALYSIS -Wthread-safety" + * ``` + */ +#define SDL_THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x)) + +#elif defined(SDL_THREAD_SAFETY_ANALYSIS) && defined(__clang__) && (!defined(SWIG)) +#define SDL_THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x)) +#else +#define SDL_THREAD_ANNOTATION_ATTRIBUTE__(x) /* no-op */ +#endif + +/** + * Wrapper around Clang thread safety analysis annotations. + * + * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_CAPABILITY(x) \ + SDL_THREAD_ANNOTATION_ATTRIBUTE__(capability(x)) + +/** + * Wrapper around Clang thread safety analysis annotations. + * + * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_SCOPED_CAPABILITY \ + SDL_THREAD_ANNOTATION_ATTRIBUTE__(scoped_lockable) + +/** + * Wrapper around Clang thread safety analysis annotations. + * + * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_GUARDED_BY(x) \ + SDL_THREAD_ANNOTATION_ATTRIBUTE__(guarded_by(x)) + +/** + * Wrapper around Clang thread safety analysis annotations. + * + * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PT_GUARDED_BY(x) \ + SDL_THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_by(x)) + +/** + * Wrapper around Clang thread safety analysis annotations. + * + * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_ACQUIRED_BEFORE(x) \ + SDL_THREAD_ANNOTATION_ATTRIBUTE__(acquired_before(x)) + +/** + * Wrapper around Clang thread safety analysis annotations. + * + * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_ACQUIRED_AFTER(x) \ + SDL_THREAD_ANNOTATION_ATTRIBUTE__(acquired_after(x)) + +/** + * Wrapper around Clang thread safety analysis annotations. + * + * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_REQUIRES(x) \ + SDL_THREAD_ANNOTATION_ATTRIBUTE__(requires_capability(x)) + +/** + * Wrapper around Clang thread safety analysis annotations. + * + * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_REQUIRES_SHARED(x) \ + SDL_THREAD_ANNOTATION_ATTRIBUTE__(requires_shared_capability(x)) + +/** + * Wrapper around Clang thread safety analysis annotations. + * + * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_ACQUIRE(x) \ + SDL_THREAD_ANNOTATION_ATTRIBUTE__(acquire_capability(x)) + +/** + * Wrapper around Clang thread safety analysis annotations. + * + * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_ACQUIRE_SHARED(x) \ + SDL_THREAD_ANNOTATION_ATTRIBUTE__(acquire_shared_capability(x)) + +/** + * Wrapper around Clang thread safety analysis annotations. + * + * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_RELEASE(x) \ + SDL_THREAD_ANNOTATION_ATTRIBUTE__(release_capability(x)) + +/** + * Wrapper around Clang thread safety analysis annotations. + * + * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_RELEASE_SHARED(x) \ + SDL_THREAD_ANNOTATION_ATTRIBUTE__(release_shared_capability(x)) + +/** + * Wrapper around Clang thread safety analysis annotations. + * + * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_RELEASE_GENERIC(x) \ + SDL_THREAD_ANNOTATION_ATTRIBUTE__(release_generic_capability(x)) + +/** + * Wrapper around Clang thread safety analysis annotations. + * + * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_TRY_ACQUIRE(x, y) \ + SDL_THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_capability(x, y)) + +/** + * Wrapper around Clang thread safety analysis annotations. + * + * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_TRY_ACQUIRE_SHARED(x, y) \ + SDL_THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_shared_capability(x, y)) + +/** + * Wrapper around Clang thread safety analysis annotations. + * + * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_EXCLUDES(x) \ + SDL_THREAD_ANNOTATION_ATTRIBUTE__(locks_excluded(x)) + +/** + * Wrapper around Clang thread safety analysis annotations. + * + * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_ASSERT_CAPABILITY(x) \ + SDL_THREAD_ANNOTATION_ATTRIBUTE__(assert_capability(x)) + +/** + * Wrapper around Clang thread safety analysis annotations. + * + * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_ASSERT_SHARED_CAPABILITY(x) \ + SDL_THREAD_ANNOTATION_ATTRIBUTE__(assert_shared_capability(x)) + +/** + * Wrapper around Clang thread safety analysis annotations. + * + * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_RETURN_CAPABILITY(x) \ + SDL_THREAD_ANNOTATION_ATTRIBUTE__(lock_returned(x)) + +/** + * Wrapper around Clang thread safety analysis annotations. + * + * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_NO_THREAD_SAFETY_ANALYSIS \ + SDL_THREAD_ANNOTATION_ATTRIBUTE__(no_thread_safety_analysis) + +/******************************************************************************/ + + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \name Mutex functions + */ +/* @{ */ + +/** + * A means to serialize access to a resource between threads. + * + * Mutexes (short for "mutual exclusion") are a synchronization primitive that + * allows exactly one thread to proceed at a time. + * + * Wikipedia has a thorough explanation of the concept: + * + * https://en.wikipedia.org/wiki/Mutex + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_Mutex SDL_Mutex; + +/** + * Create a new mutex. + * + * All newly-created mutexes begin in the _unlocked_ state. + * + * Calls to SDL_LockMutex() will not return while the mutex is locked by + * another thread. See SDL_TryLockMutex() to attempt to lock without blocking. + * + * SDL mutexes are reentrant. + * + * \returns the initialized and unlocked mutex or NULL on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_DestroyMutex + * \sa SDL_LockMutex + * \sa SDL_TryLockMutex + * \sa SDL_UnlockMutex + */ +extern SDL_DECLSPEC SDL_Mutex * SDLCALL SDL_CreateMutex(void); + +/** + * Lock the mutex. + * + * This will block until the mutex is available, which is to say it is in the + * unlocked state and the OS has chosen the caller as the next thread to lock + * it. Of all threads waiting to lock the mutex, only one may do so at a time. + * + * It is legal for the owning thread to lock an already-locked mutex. It must + * unlock it the same number of times before it is actually made available for + * other threads in the system (this is known as a "recursive mutex"). + * + * This function does not fail; if mutex is NULL, it will return immediately + * having locked nothing. If the mutex is valid, this function will always + * block until it can lock the mutex, and return with it locked. + * + * \param mutex the mutex to lock. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_TryLockMutex + * \sa SDL_UnlockMutex + */ +extern SDL_DECLSPEC void SDLCALL SDL_LockMutex(SDL_Mutex *mutex) SDL_ACQUIRE(mutex); + +/** + * Try to lock a mutex without blocking. + * + * This works just like SDL_LockMutex(), but if the mutex is not available, + * this function returns false immediately. + * + * This technique is useful if you need exclusive access to a resource but + * don't want to wait for it, and will return to it to try again later. + * + * This function returns true if passed a NULL mutex. + * + * \param mutex the mutex to try to lock. + * \returns true on success, false if the mutex would block. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_LockMutex + * \sa SDL_UnlockMutex + */ +extern SDL_DECLSPEC bool SDLCALL SDL_TryLockMutex(SDL_Mutex *mutex) SDL_TRY_ACQUIRE(true, mutex); + +/** + * Unlock the mutex. + * + * It is legal for the owning thread to lock an already-locked mutex. It must + * unlock it the same number of times before it is actually made available for + * other threads in the system (this is known as a "recursive mutex"). + * + * It is illegal to unlock a mutex that has not been locked by the current + * thread, and doing so results in undefined behavior. + * + * \param mutex the mutex to unlock. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_LockMutex + * \sa SDL_TryLockMutex + */ +extern SDL_DECLSPEC void SDLCALL SDL_UnlockMutex(SDL_Mutex *mutex) SDL_RELEASE(mutex); + +/** + * Destroy a mutex created with SDL_CreateMutex(). + * + * This function must be called on any mutex that is no longer needed. Failure + * to destroy a mutex will result in a system memory or resource leak. While + * it is safe to destroy a mutex that is _unlocked_, it is not safe to attempt + * to destroy a locked mutex, and may result in undefined behavior depending + * on the platform. + * + * \param mutex the mutex to destroy. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateMutex + */ +extern SDL_DECLSPEC void SDLCALL SDL_DestroyMutex(SDL_Mutex *mutex); + +/* @} *//* Mutex functions */ + + +/** + * \name Read/write lock functions + */ +/* @{ */ + +/** + * A mutex that allows read-only threads to run in parallel. + * + * A rwlock is roughly the same concept as SDL_Mutex, but allows threads that + * request read-only access to all hold the lock at the same time. If a thread + * requests write access, it will block until all read-only threads have + * released the lock, and no one else can hold the thread (for reading or + * writing) at the same time as the writing thread. + * + * This can be more efficient in cases where several threads need to access + * data frequently, but changes to that data are rare. + * + * There are other rules that apply to rwlocks that don't apply to mutexes, + * about how threads are scheduled and when they can be recursively locked. + * These are documented in the other rwlock functions. + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_RWLock SDL_RWLock; + +/** + * Create a new read/write lock. + * + * A read/write lock is useful for situations where you have multiple threads + * trying to access a resource that is rarely updated. All threads requesting + * a read-only lock will be allowed to run in parallel; if a thread requests a + * write lock, it will be provided exclusive access. This makes it safe for + * multiple threads to use a resource at the same time if they promise not to + * change it, and when it has to be changed, the rwlock will serve as a + * gateway to make sure those changes can be made safely. + * + * In the right situation, a rwlock can be more efficient than a mutex, which + * only lets a single thread proceed at a time, even if it won't be modifying + * the data. + * + * All newly-created read/write locks begin in the _unlocked_ state. + * + * Calls to SDL_LockRWLockForReading() and SDL_LockRWLockForWriting will not + * return while the rwlock is locked _for writing_ by another thread. See + * SDL_TryLockRWLockForReading() and SDL_TryLockRWLockForWriting() to attempt + * to lock without blocking. + * + * SDL read/write locks are only recursive for read-only locks! They are not + * guaranteed to be fair, or provide access in a FIFO manner! They are not + * guaranteed to favor writers. You may not lock a rwlock for both read-only + * and write access at the same time from the same thread (so you can't + * promote your read-only lock to a write lock without unlocking first). + * + * \returns the initialized and unlocked read/write lock or NULL on failure; + * call SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_DestroyRWLock + * \sa SDL_LockRWLockForReading + * \sa SDL_LockRWLockForWriting + * \sa SDL_TryLockRWLockForReading + * \sa SDL_TryLockRWLockForWriting + * \sa SDL_UnlockRWLock + */ +extern SDL_DECLSPEC SDL_RWLock * SDLCALL SDL_CreateRWLock(void); + +/** + * Lock the read/write lock for _read only_ operations. + * + * This will block until the rwlock is available, which is to say it is not + * locked for writing by any other thread. Of all threads waiting to lock the + * rwlock, all may do so at the same time as long as they are requesting + * read-only access; if a thread wants to lock for writing, only one may do so + * at a time, and no other threads, read-only or not, may hold the lock at the + * same time. + * + * It is legal for the owning thread to lock an already-locked rwlock for + * reading. It must unlock it the same number of times before it is actually + * made available for other threads in the system (this is known as a + * "recursive rwlock"). + * + * Note that locking for writing is not recursive (this is only available to + * read-only locks). + * + * It is illegal to request a read-only lock from a thread that already holds + * the write lock. Doing so results in undefined behavior. Unlock the write + * lock before requesting a read-only lock. (But, of course, if you have the + * write lock, you don't need further locks to read in any case.) + * + * This function does not fail; if rwlock is NULL, it will return immediately + * having locked nothing. If the rwlock is valid, this function will always + * block until it can lock the mutex, and return with it locked. + * + * \param rwlock the read/write lock to lock. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_LockRWLockForWriting + * \sa SDL_TryLockRWLockForReading + * \sa SDL_UnlockRWLock + */ +extern SDL_DECLSPEC void SDLCALL SDL_LockRWLockForReading(SDL_RWLock *rwlock) SDL_ACQUIRE_SHARED(rwlock); + +/** + * Lock the read/write lock for _write_ operations. + * + * This will block until the rwlock is available, which is to say it is not + * locked for reading or writing by any other thread. Only one thread may hold + * the lock when it requests write access; all other threads, whether they + * also want to write or only want read-only access, must wait until the + * writer thread has released the lock. + * + * It is illegal for the owning thread to lock an already-locked rwlock for + * writing (read-only may be locked recursively, writing can not). Doing so + * results in undefined behavior. + * + * It is illegal to request a write lock from a thread that already holds a + * read-only lock. Doing so results in undefined behavior. Unlock the + * read-only lock before requesting a write lock. + * + * This function does not fail; if rwlock is NULL, it will return immediately + * having locked nothing. If the rwlock is valid, this function will always + * block until it can lock the mutex, and return with it locked. + * + * \param rwlock the read/write lock to lock. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_LockRWLockForReading + * \sa SDL_TryLockRWLockForWriting + * \sa SDL_UnlockRWLock + */ +extern SDL_DECLSPEC void SDLCALL SDL_LockRWLockForWriting(SDL_RWLock *rwlock) SDL_ACQUIRE(rwlock); + +/** + * Try to lock a read/write lock _for reading_ without blocking. + * + * This works just like SDL_LockRWLockForReading(), but if the rwlock is not + * available, then this function returns false immediately. + * + * This technique is useful if you need access to a resource but don't want to + * wait for it, and will return to it to try again later. + * + * Trying to lock for read-only access can succeed if other threads are + * holding read-only locks, as this won't prevent access. + * + * This function returns true if passed a NULL rwlock. + * + * \param rwlock the rwlock to try to lock. + * \returns true on success, false if the lock would block. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_LockRWLockForReading + * \sa SDL_TryLockRWLockForWriting + * \sa SDL_UnlockRWLock + */ +extern SDL_DECLSPEC bool SDLCALL SDL_TryLockRWLockForReading(SDL_RWLock *rwlock) SDL_TRY_ACQUIRE_SHARED(true, rwlock); + +/** + * Try to lock a read/write lock _for writing_ without blocking. + * + * This works just like SDL_LockRWLockForWriting(), but if the rwlock is not + * available, then this function returns false immediately. + * + * This technique is useful if you need exclusive access to a resource but + * don't want to wait for it, and will return to it to try again later. + * + * It is illegal for the owning thread to lock an already-locked rwlock for + * writing (read-only may be locked recursively, writing can not). Doing so + * results in undefined behavior. + * + * It is illegal to request a write lock from a thread that already holds a + * read-only lock. Doing so results in undefined behavior. Unlock the + * read-only lock before requesting a write lock. + * + * This function returns true if passed a NULL rwlock. + * + * \param rwlock the rwlock to try to lock. + * \returns true on success, false if the lock would block. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_LockRWLockForWriting + * \sa SDL_TryLockRWLockForReading + * \sa SDL_UnlockRWLock + */ +extern SDL_DECLSPEC bool SDLCALL SDL_TryLockRWLockForWriting(SDL_RWLock *rwlock) SDL_TRY_ACQUIRE(true, rwlock); + +/** + * Unlock the read/write lock. + * + * Use this function to unlock the rwlock, whether it was locked for read-only + * or write operations. + * + * It is legal for the owning thread to lock an already-locked read-only lock. + * It must unlock it the same number of times before it is actually made + * available for other threads in the system (this is known as a "recursive + * rwlock"). + * + * It is illegal to unlock a rwlock that has not been locked by the current + * thread, and doing so results in undefined behavior. + * + * \param rwlock the rwlock to unlock. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_LockRWLockForReading + * \sa SDL_LockRWLockForWriting + * \sa SDL_TryLockRWLockForReading + * \sa SDL_TryLockRWLockForWriting + */ +extern SDL_DECLSPEC void SDLCALL SDL_UnlockRWLock(SDL_RWLock *rwlock) SDL_RELEASE_GENERIC(rwlock); + +/** + * Destroy a read/write lock created with SDL_CreateRWLock(). + * + * This function must be called on any read/write lock that is no longer + * needed. Failure to destroy a rwlock will result in a system memory or + * resource leak. While it is safe to destroy a rwlock that is _unlocked_, it + * is not safe to attempt to destroy a locked rwlock, and may result in + * undefined behavior depending on the platform. + * + * \param rwlock the rwlock to destroy. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateRWLock + */ +extern SDL_DECLSPEC void SDLCALL SDL_DestroyRWLock(SDL_RWLock *rwlock); + +/* @} *//* Read/write lock functions */ + + +/** + * \name Semaphore functions + */ +/* @{ */ + +/** + * A means to manage access to a resource, by count, between threads. + * + * Semaphores (specifically, "counting semaphores"), let X number of threads + * request access at the same time, each thread granted access decrementing a + * counter. When the counter reaches zero, future requests block until a prior + * thread releases their request, incrementing the counter again. + * + * Wikipedia has a thorough explanation of the concept: + * + * https://en.wikipedia.org/wiki/Semaphore_(programming) + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_Semaphore SDL_Semaphore; + +/** + * Create a semaphore. + * + * This function creates a new semaphore and initializes it with the value + * `initial_value`. Each wait operation on the semaphore will atomically + * decrement the semaphore value and potentially block if the semaphore value + * is 0. Each post operation will atomically increment the semaphore value and + * wake waiting threads and allow them to retry the wait operation. + * + * \param initial_value the starting value of the semaphore. + * \returns a new semaphore or NULL on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_DestroySemaphore + * \sa SDL_SignalSemaphore + * \sa SDL_TryWaitSemaphore + * \sa SDL_GetSemaphoreValue + * \sa SDL_WaitSemaphore + * \sa SDL_WaitSemaphoreTimeout + */ +extern SDL_DECLSPEC SDL_Semaphore * SDLCALL SDL_CreateSemaphore(Uint32 initial_value); + +/** + * Destroy a semaphore. + * + * It is not safe to destroy a semaphore if there are threads currently + * waiting on it. + * + * \param sem the semaphore to destroy. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateSemaphore + */ +extern SDL_DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_Semaphore *sem); + +/** + * Wait until a semaphore has a positive value and then decrements it. + * + * This function suspends the calling thread until the semaphore pointed to by + * `sem` has a positive value, and then atomically decrement the semaphore + * value. + * + * This function is the equivalent of calling SDL_WaitSemaphoreTimeout() with + * a time length of -1. + * + * \param sem the semaphore wait on. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SignalSemaphore + * \sa SDL_TryWaitSemaphore + * \sa SDL_WaitSemaphoreTimeout + */ +extern SDL_DECLSPEC void SDLCALL SDL_WaitSemaphore(SDL_Semaphore *sem); + +/** + * See if a semaphore has a positive value and decrement it if it does. + * + * This function checks to see if the semaphore pointed to by `sem` has a + * positive value and atomically decrements the semaphore value if it does. If + * the semaphore doesn't have a positive value, the function immediately + * returns false. + * + * \param sem the semaphore to wait on. + * \returns true if the wait succeeds, false if the wait would block. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SignalSemaphore + * \sa SDL_WaitSemaphore + * \sa SDL_WaitSemaphoreTimeout + */ +extern SDL_DECLSPEC bool SDLCALL SDL_TryWaitSemaphore(SDL_Semaphore *sem); + +/** + * Wait until a semaphore has a positive value and then decrements it. + * + * This function suspends the calling thread until either the semaphore + * pointed to by `sem` has a positive value or the specified time has elapsed. + * If the call is successful it will atomically decrement the semaphore value. + * + * \param sem the semaphore to wait on. + * \param timeoutMS the length of the timeout, in milliseconds, or -1 to wait + * indefinitely. + * \returns true if the wait succeeds or false if the wait times out. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SignalSemaphore + * \sa SDL_TryWaitSemaphore + * \sa SDL_WaitSemaphore + */ +extern SDL_DECLSPEC bool SDLCALL SDL_WaitSemaphoreTimeout(SDL_Semaphore *sem, Sint32 timeoutMS); + +/** + * Atomically increment a semaphore's value and wake waiting threads. + * + * \param sem the semaphore to increment. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_TryWaitSemaphore + * \sa SDL_WaitSemaphore + * \sa SDL_WaitSemaphoreTimeout + */ +extern SDL_DECLSPEC void SDLCALL SDL_SignalSemaphore(SDL_Semaphore *sem); + +/** + * Get the current value of a semaphore. + * + * \param sem the semaphore to query. + * \returns the current value of the semaphore. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC Uint32 SDLCALL SDL_GetSemaphoreValue(SDL_Semaphore *sem); + +/* @} *//* Semaphore functions */ + + +/** + * \name Condition variable functions + */ +/* @{ */ + +/** + * A means to block multiple threads until a condition is satisfied. + * + * Condition variables, paired with an SDL_Mutex, let an app halt multiple + * threads until a condition has occurred, at which time the app can release + * one or all waiting threads. + * + * Wikipedia has a thorough explanation of the concept: + * + * https://en.wikipedia.org/wiki/Condition_variable + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_Condition SDL_Condition; + +/** + * Create a condition variable. + * + * \returns a new condition variable or NULL on failure; call SDL_GetError() + * for more information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_BroadcastCondition + * \sa SDL_SignalCondition + * \sa SDL_WaitCondition + * \sa SDL_WaitConditionTimeout + * \sa SDL_DestroyCondition + */ +extern SDL_DECLSPEC SDL_Condition * SDLCALL SDL_CreateCondition(void); + +/** + * Destroy a condition variable. + * + * \param cond the condition variable to destroy. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateCondition + */ +extern SDL_DECLSPEC void SDLCALL SDL_DestroyCondition(SDL_Condition *cond); + +/** + * Restart one of the threads that are waiting on the condition variable. + * + * \param cond the condition variable to signal. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_BroadcastCondition + * \sa SDL_WaitCondition + * \sa SDL_WaitConditionTimeout + */ +extern SDL_DECLSPEC void SDLCALL SDL_SignalCondition(SDL_Condition *cond); + +/** + * Restart all threads that are waiting on the condition variable. + * + * \param cond the condition variable to signal. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SignalCondition + * \sa SDL_WaitCondition + * \sa SDL_WaitConditionTimeout + */ +extern SDL_DECLSPEC void SDLCALL SDL_BroadcastCondition(SDL_Condition *cond); + +/** + * Wait until a condition variable is signaled. + * + * This function unlocks the specified `mutex` and waits for another thread to + * call SDL_SignalCondition() or SDL_BroadcastCondition() on the condition + * variable `cond`. Once the condition variable is signaled, the mutex is + * re-locked and the function returns. + * + * The mutex must be locked before calling this function. Locking the mutex + * recursively (more than once) is not supported and leads to undefined + * behavior. + * + * This function is the equivalent of calling SDL_WaitConditionTimeout() with + * a time length of -1. + * + * \param cond the condition variable to wait on. + * \param mutex the mutex used to coordinate thread access. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_BroadcastCondition + * \sa SDL_SignalCondition + * \sa SDL_WaitConditionTimeout + */ +extern SDL_DECLSPEC void SDLCALL SDL_WaitCondition(SDL_Condition *cond, SDL_Mutex *mutex); + +/** + * Wait until a condition variable is signaled or a certain time has passed. + * + * This function unlocks the specified `mutex` and waits for another thread to + * call SDL_SignalCondition() or SDL_BroadcastCondition() on the condition + * variable `cond`, or for the specified time to elapse. Once the condition + * variable is signaled or the time elapsed, the mutex is re-locked and the + * function returns. + * + * The mutex must be locked before calling this function. Locking the mutex + * recursively (more than once) is not supported and leads to undefined + * behavior. + * + * \param cond the condition variable to wait on. + * \param mutex the mutex used to coordinate thread access. + * \param timeoutMS the maximum time to wait, in milliseconds, or -1 to wait + * indefinitely. + * \returns true if the condition variable is signaled, false if the condition + * is not signaled in the allotted time. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_BroadcastCondition + * \sa SDL_SignalCondition + * \sa SDL_WaitCondition + */ +extern SDL_DECLSPEC bool SDLCALL SDL_WaitConditionTimeout(SDL_Condition *cond, + SDL_Mutex *mutex, Sint32 timeoutMS); + +/* @} *//* Condition variable functions */ + +/** + * \name Thread-safe initialization state functions + */ +/* @{ */ + +/** + * The current status of an SDL_InitState structure. + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_InitStatus +{ + SDL_INIT_STATUS_UNINITIALIZED, + SDL_INIT_STATUS_INITIALIZING, + SDL_INIT_STATUS_INITIALIZED, + SDL_INIT_STATUS_UNINITIALIZING +} SDL_InitStatus; + +/** + * A structure used for thread-safe initialization and shutdown. + * + * Here is an example of using this: + * + * ```c + * static SDL_InitState init; + * + * bool InitSystem(void) + * { + * if (!SDL_ShouldInit(&init)) { + * // The system is initialized + * return true; + * } + * + * // At this point, you should not leave this function without calling SDL_SetInitialized() + * + * bool initialized = DoInitTasks(); + * SDL_SetInitialized(&init, initialized); + * return initialized; + * } + * + * bool UseSubsystem(void) + * { + * if (SDL_ShouldInit(&init)) { + * // Error, the subsystem isn't initialized + * SDL_SetInitialized(&init, false); + * return false; + * } + * + * // Do work using the initialized subsystem + * + * return true; + * } + * + * void QuitSystem(void) + * { + * if (!SDL_ShouldQuit(&init)) { + * // The system is not initialized + * return; + * } + * + * // At this point, you should not leave this function without calling SDL_SetInitialized() + * + * DoQuitTasks(); + * SDL_SetInitialized(&init, false); + * } + * ``` + * + * Note that this doesn't protect any resources created during initialization, + * or guarantee that nobody is using those resources during cleanup. You + * should use other mechanisms to protect those, if that's a concern for your + * code. + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_InitState +{ + SDL_AtomicInt status; + SDL_ThreadID thread; + void *reserved; +} SDL_InitState; + +/** + * Return whether initialization should be done. + * + * This function checks the passed in state and if initialization should be + * done, sets the status to `SDL_INIT_STATUS_INITIALIZING` and returns true. + * If another thread is already modifying this state, it will wait until + * that's done before returning. + * + * If this function returns true, the calling code must call + * SDL_SetInitialized() to complete the initialization. + * + * \param state the initialization state to check. + * \returns true if initialization needs to be done, false otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetInitialized + * \sa SDL_ShouldQuit + */ +extern SDL_DECLSPEC bool SDLCALL SDL_ShouldInit(SDL_InitState *state); + +/** + * Return whether cleanup should be done. + * + * This function checks the passed in state and if cleanup should be done, + * sets the status to `SDL_INIT_STATUS_UNINITIALIZING` and returns true. + * + * If this function returns true, the calling code must call + * SDL_SetInitialized() to complete the cleanup. + * + * \param state the initialization state to check. + * \returns true if cleanup needs to be done, false otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetInitialized + * \sa SDL_ShouldInit + */ +extern SDL_DECLSPEC bool SDLCALL SDL_ShouldQuit(SDL_InitState *state); + +/** + * Finish an initialization state transition. + * + * This function sets the status of the passed in state to + * `SDL_INIT_STATUS_INITIALIZED` or `SDL_INIT_STATUS_UNINITIALIZED` and allows + * any threads waiting for the status to proceed. + * + * \param state the initialization state to check. + * \param initialized the new initialization state. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_ShouldInit + * \sa SDL_ShouldQuit + */ +extern SDL_DECLSPEC void SDLCALL SDL_SetInitialized(SDL_InitState *state, bool initialized); + +/* @} *//* Thread-safe initialization state functions */ + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_mutex_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_oldnames.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_oldnames.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,1327 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* + * Definitions to ease transition from SDL2 code + */ + +#ifndef SDL_oldnames_h_ +#define SDL_oldnames_h_ + +#include + +/* The new function names are recommended, but if you want to have the + * old names available while you are in the process of migrating code + * to SDL3, you can define `SDL_ENABLE_OLD_NAMES` in your project. + * + * You can use https://github.com/libsdl-org/SDL/blob/main/build-scripts/rename_symbols.py to mass rename the symbols defined here in your codebase: + * rename_symbols.py --all-symbols source_code_path + */ +#ifdef SDL_ENABLE_OLD_NAMES + +/* ##SDL_atomic.h */ +#define SDL_AtomicAdd SDL_AddAtomicInt +#define SDL_AtomicCAS SDL_CompareAndSwapAtomicInt +#define SDL_AtomicCASPtr SDL_CompareAndSwapAtomicPointer +#define SDL_AtomicGet SDL_GetAtomicInt +#define SDL_AtomicGetPtr SDL_GetAtomicPointer +#define SDL_AtomicLock SDL_LockSpinlock +#define SDL_AtomicSet SDL_SetAtomicInt +#define SDL_AtomicSetPtr SDL_SetAtomicPointer +#define SDL_AtomicTryLock SDL_TryLockSpinlock +#define SDL_AtomicUnlock SDL_UnlockSpinlock +#define SDL_atomic_t SDL_AtomicInt + +/* ##SDL_audio.h */ +#define AUDIO_F32 SDL_AUDIO_F32LE +#define AUDIO_F32LSB SDL_AUDIO_F32LE +#define AUDIO_F32MSB SDL_AUDIO_F32BE +#define AUDIO_F32SYS SDL_AUDIO_F32 +#define AUDIO_S16 SDL_AUDIO_S16LE +#define AUDIO_S16LSB SDL_AUDIO_S16LE +#define AUDIO_S16MSB SDL_AUDIO_S16BE +#define AUDIO_S16SYS SDL_AUDIO_S16 +#define AUDIO_S32 SDL_AUDIO_S32LE +#define AUDIO_S32LSB SDL_AUDIO_S32LE +#define AUDIO_S32MSB SDL_AUDIO_S32BE +#define AUDIO_S32SYS SDL_AUDIO_S32 +#define AUDIO_S8 SDL_AUDIO_S8 +#define AUDIO_U8 SDL_AUDIO_U8 +#define SDL_AudioStreamAvailable SDL_GetAudioStreamAvailable +#define SDL_AudioStreamClear SDL_ClearAudioStream +#define SDL_AudioStreamFlush SDL_FlushAudioStream +#define SDL_AudioStreamGet SDL_GetAudioStreamData +#define SDL_AudioStreamPut SDL_PutAudioStreamData +#define SDL_FreeAudioStream SDL_DestroyAudioStream +#define SDL_FreeWAV SDL_free +#define SDL_LoadWAV_RW SDL_LoadWAV_IO +#define SDL_MixAudioFormat SDL_MixAudio +#define SDL_NewAudioStream SDL_CreateAudioStream + +/* ##SDL_cpuinfo.h */ +#define SDL_GetCPUCount SDL_GetNumLogicalCPUCores +#define SDL_SIMDGetAlignment SDL_GetSIMDAlignment + +/* ##SDL_endian.h */ +#define SDL_SwapBE16 SDL_Swap16BE +#define SDL_SwapBE32 SDL_Swap32BE +#define SDL_SwapBE64 SDL_Swap64BE +#define SDL_SwapLE16 SDL_Swap16LE +#define SDL_SwapLE32 SDL_Swap32LE +#define SDL_SwapLE64 SDL_Swap64LE + +/* ##SDL_events.h */ +#define SDL_APP_DIDENTERBACKGROUND SDL_EVENT_DID_ENTER_BACKGROUND +#define SDL_APP_DIDENTERFOREGROUND SDL_EVENT_DID_ENTER_FOREGROUND +#define SDL_APP_LOWMEMORY SDL_EVENT_LOW_MEMORY +#define SDL_APP_TERMINATING SDL_EVENT_TERMINATING +#define SDL_APP_WILLENTERBACKGROUND SDL_EVENT_WILL_ENTER_BACKGROUND +#define SDL_APP_WILLENTERFOREGROUND SDL_EVENT_WILL_ENTER_FOREGROUND +#define SDL_AUDIODEVICEADDED SDL_EVENT_AUDIO_DEVICE_ADDED +#define SDL_AUDIODEVICEREMOVED SDL_EVENT_AUDIO_DEVICE_REMOVED +#define SDL_CLIPBOARDUPDATE SDL_EVENT_CLIPBOARD_UPDATE +#define SDL_CONTROLLERAXISMOTION SDL_EVENT_GAMEPAD_AXIS_MOTION +#define SDL_CONTROLLERBUTTONDOWN SDL_EVENT_GAMEPAD_BUTTON_DOWN +#define SDL_CONTROLLERBUTTONUP SDL_EVENT_GAMEPAD_BUTTON_UP +#define SDL_CONTROLLERDEVICEADDED SDL_EVENT_GAMEPAD_ADDED +#define SDL_CONTROLLERDEVICEREMAPPED SDL_EVENT_GAMEPAD_REMAPPED +#define SDL_CONTROLLERDEVICEREMOVED SDL_EVENT_GAMEPAD_REMOVED +#define SDL_CONTROLLERSENSORUPDATE SDL_EVENT_GAMEPAD_SENSOR_UPDATE +#define SDL_CONTROLLERSTEAMHANDLEUPDATED SDL_EVENT_GAMEPAD_STEAM_HANDLE_UPDATED +#define SDL_CONTROLLERTOUCHPADDOWN SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN +#define SDL_CONTROLLERTOUCHPADMOTION SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION +#define SDL_CONTROLLERTOUCHPADUP SDL_EVENT_GAMEPAD_TOUCHPAD_UP +#define SDL_ControllerAxisEvent SDL_GamepadAxisEvent +#define SDL_ControllerButtonEvent SDL_GamepadButtonEvent +#define SDL_ControllerDeviceEvent SDL_GamepadDeviceEvent +#define SDL_ControllerSensorEvent SDL_GamepadSensorEvent +#define SDL_ControllerTouchpadEvent SDL_GamepadTouchpadEvent +#define SDL_DISPLAYEVENT_CONNECTED SDL_EVENT_DISPLAY_ADDED +#define SDL_DISPLAYEVENT_DISCONNECTED SDL_EVENT_DISPLAY_REMOVED +#define SDL_DISPLAYEVENT_MOVED SDL_EVENT_DISPLAY_MOVED +#define SDL_DISPLAYEVENT_ORIENTATION SDL_EVENT_DISPLAY_ORIENTATION +#define SDL_DROPBEGIN SDL_EVENT_DROP_BEGIN +#define SDL_DROPCOMPLETE SDL_EVENT_DROP_COMPLETE +#define SDL_DROPFILE SDL_EVENT_DROP_FILE +#define SDL_DROPTEXT SDL_EVENT_DROP_TEXT +#define SDL_DelEventWatch SDL_RemoveEventWatch +#define SDL_FINGERDOWN SDL_EVENT_FINGER_DOWN +#define SDL_FINGERMOTION SDL_EVENT_FINGER_MOTION +#define SDL_FINGERUP SDL_EVENT_FINGER_UP +#define SDL_FIRSTEVENT SDL_EVENT_FIRST +#define SDL_JOYAXISMOTION SDL_EVENT_JOYSTICK_AXIS_MOTION +#define SDL_JOYBATTERYUPDATED SDL_EVENT_JOYSTICK_BATTERY_UPDATED +#define SDL_JOYBUTTONDOWN SDL_EVENT_JOYSTICK_BUTTON_DOWN +#define SDL_JOYBUTTONUP SDL_EVENT_JOYSTICK_BUTTON_UP +#define SDL_JOYDEVICEADDED SDL_EVENT_JOYSTICK_ADDED +#define SDL_JOYDEVICEREMOVED SDL_EVENT_JOYSTICK_REMOVED +#define SDL_JOYBALLMOTION SDL_EVENT_JOYSTICK_BALL_MOTION +#define SDL_JOYHATMOTION SDL_EVENT_JOYSTICK_HAT_MOTION +#define SDL_KEYDOWN SDL_EVENT_KEY_DOWN +#define SDL_KEYMAPCHANGED SDL_EVENT_KEYMAP_CHANGED +#define SDL_KEYUP SDL_EVENT_KEY_UP +#define SDL_LASTEVENT SDL_EVENT_LAST +#define SDL_LOCALECHANGED SDL_EVENT_LOCALE_CHANGED +#define SDL_MOUSEBUTTONDOWN SDL_EVENT_MOUSE_BUTTON_DOWN +#define SDL_MOUSEBUTTONUP SDL_EVENT_MOUSE_BUTTON_UP +#define SDL_MOUSEMOTION SDL_EVENT_MOUSE_MOTION +#define SDL_MOUSEWHEEL SDL_EVENT_MOUSE_WHEEL +#define SDL_POLLSENTINEL SDL_EVENT_POLL_SENTINEL +#define SDL_QUIT SDL_EVENT_QUIT +#define SDL_RENDER_DEVICE_RESET SDL_EVENT_RENDER_DEVICE_RESET +#define SDL_RENDER_TARGETS_RESET SDL_EVENT_RENDER_TARGETS_RESET +#define SDL_SENSORUPDATE SDL_EVENT_SENSOR_UPDATE +#define SDL_TEXTEDITING SDL_EVENT_TEXT_EDITING +#define SDL_TEXTEDITING_EXT SDL_EVENT_TEXT_EDITING_EXT +#define SDL_TEXTINPUT SDL_EVENT_TEXT_INPUT +#define SDL_USEREVENT SDL_EVENT_USER +#define SDL_WINDOWEVENT_CLOSE SDL_EVENT_WINDOW_CLOSE_REQUESTED +#define SDL_WINDOWEVENT_DISPLAY_CHANGED SDL_EVENT_WINDOW_DISPLAY_CHANGED +#define SDL_WINDOWEVENT_ENTER SDL_EVENT_WINDOW_MOUSE_ENTER +#define SDL_WINDOWEVENT_EXPOSED SDL_EVENT_WINDOW_EXPOSED +#define SDL_WINDOWEVENT_FOCUS_GAINED SDL_EVENT_WINDOW_FOCUS_GAINED +#define SDL_WINDOWEVENT_FOCUS_LOST SDL_EVENT_WINDOW_FOCUS_LOST +#define SDL_WINDOWEVENT_HIDDEN SDL_EVENT_WINDOW_HIDDEN +#define SDL_WINDOWEVENT_HIT_TEST SDL_EVENT_WINDOW_HIT_TEST +#define SDL_WINDOWEVENT_ICCPROF_CHANGED SDL_EVENT_WINDOW_ICCPROF_CHANGED +#define SDL_WINDOWEVENT_LEAVE SDL_EVENT_WINDOW_MOUSE_LEAVE +#define SDL_WINDOWEVENT_MAXIMIZED SDL_EVENT_WINDOW_MAXIMIZED +#define SDL_WINDOWEVENT_MINIMIZED SDL_EVENT_WINDOW_MINIMIZED +#define SDL_WINDOWEVENT_MOVED SDL_EVENT_WINDOW_MOVED +#define SDL_WINDOWEVENT_RESIZED SDL_EVENT_WINDOW_RESIZED +#define SDL_WINDOWEVENT_RESTORED SDL_EVENT_WINDOW_RESTORED +#define SDL_WINDOWEVENT_SHOWN SDL_EVENT_WINDOW_SHOWN +#define SDL_WINDOWEVENT_SIZE_CHANGED SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED +#define SDL_eventaction SDL_EventAction + +/* ##SDL_gamecontroller.h */ +#define SDL_CONTROLLER_AXIS_INVALID SDL_GAMEPAD_AXIS_INVALID +#define SDL_CONTROLLER_AXIS_LEFTX SDL_GAMEPAD_AXIS_LEFTX +#define SDL_CONTROLLER_AXIS_LEFTY SDL_GAMEPAD_AXIS_LEFTY +#define SDL_CONTROLLER_AXIS_MAX SDL_GAMEPAD_AXIS_COUNT +#define SDL_CONTROLLER_AXIS_RIGHTX SDL_GAMEPAD_AXIS_RIGHTX +#define SDL_CONTROLLER_AXIS_RIGHTY SDL_GAMEPAD_AXIS_RIGHTY +#define SDL_CONTROLLER_AXIS_TRIGGERLEFT SDL_GAMEPAD_AXIS_LEFT_TRIGGER +#define SDL_CONTROLLER_AXIS_TRIGGERRIGHT SDL_GAMEPAD_AXIS_RIGHT_TRIGGER +#define SDL_CONTROLLER_BINDTYPE_AXIS SDL_GAMEPAD_BINDTYPE_AXIS +#define SDL_CONTROLLER_BINDTYPE_BUTTON SDL_GAMEPAD_BINDTYPE_BUTTON +#define SDL_CONTROLLER_BINDTYPE_HAT SDL_GAMEPAD_BINDTYPE_HAT +#define SDL_CONTROLLER_BINDTYPE_NONE SDL_GAMEPAD_BINDTYPE_NONE +#define SDL_CONTROLLER_BUTTON_A SDL_GAMEPAD_BUTTON_SOUTH +#define SDL_CONTROLLER_BUTTON_B SDL_GAMEPAD_BUTTON_EAST +#define SDL_CONTROLLER_BUTTON_BACK SDL_GAMEPAD_BUTTON_BACK +#define SDL_CONTROLLER_BUTTON_DPAD_DOWN SDL_GAMEPAD_BUTTON_DPAD_DOWN +#define SDL_CONTROLLER_BUTTON_DPAD_LEFT SDL_GAMEPAD_BUTTON_DPAD_LEFT +#define SDL_CONTROLLER_BUTTON_DPAD_RIGHT SDL_GAMEPAD_BUTTON_DPAD_RIGHT +#define SDL_CONTROLLER_BUTTON_DPAD_UP SDL_GAMEPAD_BUTTON_DPAD_UP +#define SDL_CONTROLLER_BUTTON_GUIDE SDL_GAMEPAD_BUTTON_GUIDE +#define SDL_CONTROLLER_BUTTON_INVALID SDL_GAMEPAD_BUTTON_INVALID +#define SDL_CONTROLLER_BUTTON_LEFTSHOULDER SDL_GAMEPAD_BUTTON_LEFT_SHOULDER +#define SDL_CONTROLLER_BUTTON_LEFTSTICK SDL_GAMEPAD_BUTTON_LEFT_STICK +#define SDL_CONTROLLER_BUTTON_MAX SDL_GAMEPAD_BUTTON_COUNT +#define SDL_CONTROLLER_BUTTON_MISC1 SDL_GAMEPAD_BUTTON_MISC1 +#define SDL_CONTROLLER_BUTTON_PADDLE1 SDL_GAMEPAD_BUTTON_RIGHT_PADDLE1 +#define SDL_CONTROLLER_BUTTON_PADDLE2 SDL_GAMEPAD_BUTTON_LEFT_PADDLE1 +#define SDL_CONTROLLER_BUTTON_PADDLE3 SDL_GAMEPAD_BUTTON_RIGHT_PADDLE2 +#define SDL_CONTROLLER_BUTTON_PADDLE4 SDL_GAMEPAD_BUTTON_LEFT_PADDLE2 +#define SDL_CONTROLLER_BUTTON_RIGHTSHOULDER SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER +#define SDL_CONTROLLER_BUTTON_RIGHTSTICK SDL_GAMEPAD_BUTTON_RIGHT_STICK +#define SDL_CONTROLLER_BUTTON_START SDL_GAMEPAD_BUTTON_START +#define SDL_CONTROLLER_BUTTON_TOUCHPAD SDL_GAMEPAD_BUTTON_TOUCHPAD +#define SDL_CONTROLLER_BUTTON_X SDL_GAMEPAD_BUTTON_WEST +#define SDL_CONTROLLER_BUTTON_Y SDL_GAMEPAD_BUTTON_NORTH +#define SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_LEFT SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_LEFT +#define SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_PAIR SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_PAIR +#define SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT +#define SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_PRO +#define SDL_CONTROLLER_TYPE_PS3 SDL_GAMEPAD_TYPE_PS3 +#define SDL_CONTROLLER_TYPE_PS4 SDL_GAMEPAD_TYPE_PS4 +#define SDL_CONTROLLER_TYPE_PS5 SDL_GAMEPAD_TYPE_PS5 +#define SDL_CONTROLLER_TYPE_UNKNOWN SDL_GAMEPAD_TYPE_STANDARD +#define SDL_CONTROLLER_TYPE_VIRTUAL SDL_GAMEPAD_TYPE_VIRTUAL +#define SDL_CONTROLLER_TYPE_XBOX360 SDL_GAMEPAD_TYPE_XBOX360 +#define SDL_CONTROLLER_TYPE_XBOXONE SDL_GAMEPAD_TYPE_XBOXONE +#define SDL_GameController SDL_Gamepad +#define SDL_GameControllerAddMapping SDL_AddGamepadMapping +#define SDL_GameControllerAddMappingsFromFile SDL_AddGamepadMappingsFromFile +#define SDL_GameControllerAddMappingsFromRW SDL_AddGamepadMappingsFromIO +#define SDL_GameControllerAxis SDL_GamepadAxis +#define SDL_GameControllerBindType SDL_GamepadBindingType +#define SDL_GameControllerButton SDL_GamepadButton +#define SDL_GameControllerClose SDL_CloseGamepad +#define SDL_GameControllerFromInstanceID SDL_GetGamepadFromID +#define SDL_GameControllerFromPlayerIndex SDL_GetGamepadFromPlayerIndex +#define SDL_GameControllerGetAppleSFSymbolsNameForAxis SDL_GetGamepadAppleSFSymbolsNameForAxis +#define SDL_GameControllerGetAppleSFSymbolsNameForButton SDL_GetGamepadAppleSFSymbolsNameForButton +#define SDL_GameControllerGetAttached SDL_GamepadConnected +#define SDL_GameControllerGetAxis SDL_GetGamepadAxis +#define SDL_GameControllerGetAxisFromString SDL_GetGamepadAxisFromString +#define SDL_GameControllerGetButton SDL_GetGamepadButton +#define SDL_GameControllerGetButtonFromString SDL_GetGamepadButtonFromString +#define SDL_GameControllerGetFirmwareVersion SDL_GetGamepadFirmwareVersion +#define SDL_GameControllerGetJoystick SDL_GetGamepadJoystick +#define SDL_GameControllerGetNumTouchpadFingers SDL_GetNumGamepadTouchpadFingers +#define SDL_GameControllerGetNumTouchpads SDL_GetNumGamepadTouchpads +#define SDL_GameControllerGetPlayerIndex SDL_GetGamepadPlayerIndex +#define SDL_GameControllerGetProduct SDL_GetGamepadProduct +#define SDL_GameControllerGetProductVersion SDL_GetGamepadProductVersion +#define SDL_GameControllerGetSensorData SDL_GetGamepadSensorData +#define SDL_GameControllerGetSensorDataRate SDL_GetGamepadSensorDataRate +#define SDL_GameControllerGetSerial SDL_GetGamepadSerial +#define SDL_GameControllerGetSteamHandle SDL_GetGamepadSteamHandle +#define SDL_GameControllerGetStringForAxis SDL_GetGamepadStringForAxis +#define SDL_GameControllerGetStringForButton SDL_GetGamepadStringForButton +#define SDL_GameControllerGetTouchpadFinger SDL_GetGamepadTouchpadFinger +#define SDL_GameControllerGetType SDL_GetGamepadType +#define SDL_GameControllerGetVendor SDL_GetGamepadVendor +#define SDL_GameControllerHasAxis SDL_GamepadHasAxis +#define SDL_GameControllerHasButton SDL_GamepadHasButton +#define SDL_GameControllerHasSensor SDL_GamepadHasSensor +#define SDL_GameControllerIsSensorEnabled SDL_GamepadSensorEnabled +#define SDL_GameControllerMapping SDL_GetGamepadMapping +#define SDL_GameControllerMappingForGUID SDL_GetGamepadMappingForGUID +#define SDL_GameControllerName SDL_GetGamepadName +#define SDL_GameControllerOpen SDL_OpenGamepad +#define SDL_GameControllerPath SDL_GetGamepadPath +#define SDL_GameControllerRumble SDL_RumbleGamepad +#define SDL_GameControllerRumbleTriggers SDL_RumbleGamepadTriggers +#define SDL_GameControllerSendEffect SDL_SendGamepadEffect +#define SDL_GameControllerSetLED SDL_SetGamepadLED +#define SDL_GameControllerSetPlayerIndex SDL_SetGamepadPlayerIndex +#define SDL_GameControllerSetSensorEnabled SDL_SetGamepadSensorEnabled +#define SDL_GameControllerType SDL_GamepadType +#define SDL_GameControllerUpdate SDL_UpdateGamepads +#define SDL_INIT_GAMECONTROLLER SDL_INIT_GAMEPAD +#define SDL_IsGameController SDL_IsGamepad + +/* ##SDL_guid.h */ +#define SDL_GUIDFromString SDL_StringToGUID + +/* ##SDL_haptic.h */ +#define SDL_HapticClose SDL_CloseHaptic +#define SDL_HapticDestroyEffect SDL_DestroyHapticEffect +#define SDL_HapticGetEffectStatus SDL_GetHapticEffectStatus +#define SDL_HapticNewEffect SDL_CreateHapticEffect +#define SDL_HapticNumAxes SDL_GetNumHapticAxes +#define SDL_HapticNumEffects SDL_GetMaxHapticEffects +#define SDL_HapticNumEffectsPlaying SDL_GetMaxHapticEffectsPlaying +#define SDL_HapticOpen SDL_OpenHaptic +#define SDL_HapticOpenFromJoystick SDL_OpenHapticFromJoystick +#define SDL_HapticOpenFromMouse SDL_OpenHapticFromMouse +#define SDL_HapticPause SDL_PauseHaptic +#define SDL_HapticQuery SDL_GetHapticFeatures +#define SDL_HapticRumbleInit SDL_InitHapticRumble +#define SDL_HapticRumblePlay SDL_PlayHapticRumble +#define SDL_HapticRumbleStop SDL_StopHapticRumble +#define SDL_HapticRunEffect SDL_RunHapticEffect +#define SDL_HapticSetAutocenter SDL_SetHapticAutocenter +#define SDL_HapticSetGain SDL_SetHapticGain +#define SDL_HapticStopAll SDL_StopHapticEffects +#define SDL_HapticStopEffect SDL_StopHapticEffect +#define SDL_HapticUnpause SDL_ResumeHaptic +#define SDL_HapticUpdateEffect SDL_UpdateHapticEffect +#define SDL_JoystickIsHaptic SDL_IsJoystickHaptic +#define SDL_MouseIsHaptic SDL_IsMouseHaptic + +/* ##SDL_hints.h */ +#define SDL_DelHintCallback SDL_RemoveHintCallback +#define SDL_HINT_ALLOW_TOPMOST SDL_HINT_WINDOW_ALLOW_TOPMOST +#define SDL_HINT_DIRECTINPUT_ENABLED SDL_HINT_JOYSTICK_DIRECTINPUT +#define SDL_HINT_GDK_TEXTINPUT_DEFAULT SDL_HINT_GDK_TEXTINPUT_DEFAULT_TEXT +#define SDL_HINT_JOYSTICK_GAMECUBE_RUMBLE_BRAKE SDL_HINT_JOYSTICK_HIDAPI_GAMECUBE_RUMBLE_BRAKE +#define SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE SDL_HINT_JOYSTICK_ENHANCED_REPORTS +#define SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE SDL_HINT_JOYSTICK_ENHANCED_REPORTS +#define SDL_HINT_LINUX_DIGITAL_HATS SDL_HINT_JOYSTICK_LINUX_DIGITAL_HATS +#define SDL_HINT_LINUX_HAT_DEADZONES SDL_HINT_JOYSTICK_LINUX_HAT_DEADZONES +#define SDL_HINT_LINUX_JOYSTICK_CLASSIC SDL_HINT_JOYSTICK_LINUX_CLASSIC +#define SDL_HINT_LINUX_JOYSTICK_DEADZONES SDL_HINT_JOYSTICK_LINUX_DEADZONES + +/* ##SDL_joystick.h */ +#define SDL_JOYSTICK_TYPE_GAMECONTROLLER SDL_JOYSTICK_TYPE_GAMEPAD +#define SDL_JoystickAttachVirtualEx SDL_AttachVirtualJoystick +#define SDL_JoystickClose SDL_CloseJoystick +#define SDL_JoystickDetachVirtual SDL_DetachVirtualJoystick +#define SDL_JoystickFromInstanceID SDL_GetJoystickFromID +#define SDL_JoystickFromPlayerIndex SDL_GetJoystickFromPlayerIndex +#define SDL_JoystickGUID SDL_GUID +#define SDL_JoystickGetAttached SDL_JoystickConnected +#define SDL_JoystickGetAxis SDL_GetJoystickAxis +#define SDL_JoystickGetAxisInitialState SDL_GetJoystickAxisInitialState +#define SDL_JoystickGetBall SDL_GetJoystickBall +#define SDL_JoystickGetButton SDL_GetJoystickButton +#define SDL_JoystickGetFirmwareVersion SDL_GetJoystickFirmwareVersion +#define SDL_JoystickGetGUID SDL_GetJoystickGUID +#define SDL_JoystickGetGUIDFromString SDL_StringToGUID +#define SDL_JoystickGetHat SDL_GetJoystickHat +#define SDL_JoystickGetPlayerIndex SDL_GetJoystickPlayerIndex +#define SDL_JoystickGetProduct SDL_GetJoystickProduct +#define SDL_JoystickGetProductVersion SDL_GetJoystickProductVersion +#define SDL_JoystickGetSerial SDL_GetJoystickSerial +#define SDL_JoystickGetType SDL_GetJoystickType +#define SDL_JoystickGetVendor SDL_GetJoystickVendor +#define SDL_JoystickInstanceID SDL_GetJoystickID +#define SDL_JoystickIsVirtual SDL_IsJoystickVirtual +#define SDL_JoystickName SDL_GetJoystickName +#define SDL_JoystickNumAxes SDL_GetNumJoystickAxes +#define SDL_JoystickNumBalls SDL_GetNumJoystickBalls +#define SDL_JoystickNumButtons SDL_GetNumJoystickButtons +#define SDL_JoystickNumHats SDL_GetNumJoystickHats +#define SDL_JoystickOpen SDL_OpenJoystick +#define SDL_JoystickPath SDL_GetJoystickPath +#define SDL_JoystickRumble SDL_RumbleJoystick +#define SDL_JoystickRumbleTriggers SDL_RumbleJoystickTriggers +#define SDL_JoystickSendEffect SDL_SendJoystickEffect +#define SDL_JoystickSetLED SDL_SetJoystickLED +#define SDL_JoystickSetPlayerIndex SDL_SetJoystickPlayerIndex +#define SDL_JoystickSetVirtualAxis SDL_SetJoystickVirtualAxis +#define SDL_JoystickSetVirtualButton SDL_SetJoystickVirtualButton +#define SDL_JoystickSetVirtualHat SDL_SetJoystickVirtualHat +#define SDL_JoystickUpdate SDL_UpdateJoysticks + +/* ##SDL_keyboard.h */ +#define SDL_IsScreenKeyboardShown SDL_ScreenKeyboardShown +#define SDL_IsTextInputActive SDL_TextInputActive + +/* ##SDL_keycode.h */ +#define KMOD_ALT SDL_KMOD_ALT +#define KMOD_CAPS SDL_KMOD_CAPS +#define KMOD_CTRL SDL_KMOD_CTRL +#define KMOD_GUI SDL_KMOD_GUI +#define KMOD_LALT SDL_KMOD_LALT +#define KMOD_LCTRL SDL_KMOD_LCTRL +#define KMOD_LGUI SDL_KMOD_LGUI +#define KMOD_LSHIFT SDL_KMOD_LSHIFT +#define KMOD_MODE SDL_KMOD_MODE +#define KMOD_NONE SDL_KMOD_NONE +#define KMOD_NUM SDL_KMOD_NUM +#define KMOD_RALT SDL_KMOD_RALT +#define KMOD_RCTRL SDL_KMOD_RCTRL +#define KMOD_RGUI SDL_KMOD_RGUI +#define KMOD_RSHIFT SDL_KMOD_RSHIFT +#define KMOD_SCROLL SDL_KMOD_SCROLL +#define KMOD_SHIFT SDL_KMOD_SHIFT +#define SDLK_AUDIOFASTFORWARD SDLK_MEDIA_FAST_FORWARD +#define SDLK_AUDIOMUTE SDLK_MUTE +#define SDLK_AUDIONEXT SDLK_MEDIA_NEXT_TRACK +#define SDLK_AUDIOPLAY SDLK_MEDIA_PLAY +#define SDLK_AUDIOPREV SDLK_MEDIA_PREVIOUS_TRACK +#define SDLK_AUDIOREWIND SDLK_MEDIA_REWIND +#define SDLK_AUDIOSTOP SDLK_MEDIA_STOP +#define SDLK_BACKQUOTE SDLK_GRAVE +#define SDLK_EJECT SDLK_MEDIA_EJECT +#define SDLK_MEDIASELECT SDLK_MEDIA_SELECT +#define SDLK_QUOTE SDLK_APOSTROPHE +#define SDLK_QUOTEDBL SDLK_DBLAPOSTROPHE +#define SDLK_a SDLK_A +#define SDLK_b SDLK_B +#define SDLK_c SDLK_C +#define SDLK_d SDLK_D +#define SDLK_e SDLK_E +#define SDLK_f SDLK_F +#define SDLK_g SDLK_G +#define SDLK_h SDLK_H +#define SDLK_i SDLK_I +#define SDLK_j SDLK_J +#define SDLK_k SDLK_K +#define SDLK_l SDLK_L +#define SDLK_m SDLK_M +#define SDLK_n SDLK_N +#define SDLK_o SDLK_O +#define SDLK_p SDLK_P +#define SDLK_q SDLK_Q +#define SDLK_r SDLK_R +#define SDLK_s SDLK_S +#define SDLK_t SDLK_T +#define SDLK_u SDLK_U +#define SDLK_v SDLK_V +#define SDLK_w SDLK_W +#define SDLK_x SDLK_X +#define SDLK_y SDLK_Y +#define SDLK_z SDLK_Z + +/* ##SDL_log.h */ +#define SDL_LogGetOutputFunction SDL_GetLogOutputFunction +#define SDL_LogGetPriority SDL_GetLogPriority +#define SDL_LogResetPriorities SDL_ResetLogPriorities +#define SDL_LogSetAllPriority SDL_SetLogPriorities +#define SDL_LogSetOutputFunction SDL_SetLogOutputFunction +#define SDL_LogSetPriority SDL_SetLogPriority +#define SDL_NUM_LOG_PRIORITIES SDL_LOG_PRIORITY_COUNT + +/* ##SDL_messagebox.h */ +#define SDL_MESSAGEBOX_COLOR_MAX SDL_MESSAGEBOX_COLOR_COUNT + +/* ##SDL_mouse.h */ +#define SDL_BUTTON SDL_BUTTON_MASK +#define SDL_FreeCursor SDL_DestroyCursor +#define SDL_NUM_SYSTEM_CURSORS SDL_SYSTEM_CURSOR_COUNT +#define SDL_SYSTEM_CURSOR_ARROW SDL_SYSTEM_CURSOR_DEFAULT +#define SDL_SYSTEM_CURSOR_HAND SDL_SYSTEM_CURSOR_POINTER +#define SDL_SYSTEM_CURSOR_IBEAM SDL_SYSTEM_CURSOR_TEXT +#define SDL_SYSTEM_CURSOR_NO SDL_SYSTEM_CURSOR_NOT_ALLOWED +#define SDL_SYSTEM_CURSOR_SIZEALL SDL_SYSTEM_CURSOR_MOVE +#define SDL_SYSTEM_CURSOR_SIZENESW SDL_SYSTEM_CURSOR_NESW_RESIZE +#define SDL_SYSTEM_CURSOR_SIZENS SDL_SYSTEM_CURSOR_NS_RESIZE +#define SDL_SYSTEM_CURSOR_SIZENWSE SDL_SYSTEM_CURSOR_NWSE_RESIZE +#define SDL_SYSTEM_CURSOR_SIZEWE SDL_SYSTEM_CURSOR_EW_RESIZE +#define SDL_SYSTEM_CURSOR_WAITARROW SDL_SYSTEM_CURSOR_PROGRESS +#define SDL_SYSTEM_CURSOR_WINDOW_BOTTOM SDL_SYSTEM_CURSOR_S_RESIZE +#define SDL_SYSTEM_CURSOR_WINDOW_BOTTOMLEFT SDL_SYSTEM_CURSOR_SW_RESIZE +#define SDL_SYSTEM_CURSOR_WINDOW_BOTTOMRIGHT SDL_SYSTEM_CURSOR_SE_RESIZE +#define SDL_SYSTEM_CURSOR_WINDOW_LEFT SDL_SYSTEM_CURSOR_W_RESIZE +#define SDL_SYSTEM_CURSOR_WINDOW_RIGHT SDL_SYSTEM_CURSOR_E_RESIZE +#define SDL_SYSTEM_CURSOR_WINDOW_TOP SDL_SYSTEM_CURSOR_N_RESIZE +#define SDL_SYSTEM_CURSOR_WINDOW_TOPLEFT SDL_SYSTEM_CURSOR_NW_RESIZE +#define SDL_SYSTEM_CURSOR_WINDOW_TOPRIGHT SDL_SYSTEM_CURSOR_NE_RESIZE + +/* ##SDL_mutex.h */ +#define SDL_CondBroadcast SDL_BroadcastCondition +#define SDL_CondSignal SDL_SignalCondition +#define SDL_CondWait SDL_WaitCondition +#define SDL_CondWaitTimeout SDL_WaitConditionTimeout +#define SDL_CreateCond SDL_CreateCondition +#define SDL_DestroyCond SDL_DestroyCondition +#define SDL_SemPost SDL_SignalSemaphore +#define SDL_SemTryWait SDL_TryWaitSemaphore +#define SDL_SemValue SDL_GetSemaphoreValue +#define SDL_SemWait SDL_WaitSemaphore +#define SDL_SemWaitTimeout SDL_WaitSemaphoreTimeout + +/* ##SDL_mutex.h */ +#define SDL_cond SDL_Condition +#define SDL_mutex SDL_Mutex +#define SDL_sem SDL_Semaphore + +/* ##SDL_pixels.h */ +#define SDL_AllocFormat SDL_GetPixelFormatDetails +#define SDL_AllocPalette SDL_CreatePalette +#define SDL_Colour SDL_Color +#define SDL_FreePalette SDL_DestroyPalette +#define SDL_MasksToPixelFormatEnum SDL_GetPixelFormatForMasks +#define SDL_PIXELFORMAT_BGR444 SDL_PIXELFORMAT_XBGR4444 +#define SDL_PIXELFORMAT_BGR555 SDL_PIXELFORMAT_XBGR1555 +#define SDL_PIXELFORMAT_BGR888 SDL_PIXELFORMAT_XBGR8888 +#define SDL_PIXELFORMAT_RGB444 SDL_PIXELFORMAT_XRGB4444 +#define SDL_PIXELFORMAT_RGB555 SDL_PIXELFORMAT_XRGB1555 +#define SDL_PIXELFORMAT_RGB888 SDL_PIXELFORMAT_XRGB8888 +#define SDL_PixelFormatEnumToMasks SDL_GetMasksForPixelFormat + +/* ##SDL_rect.h */ +#define SDL_EncloseFPoints SDL_GetRectEnclosingPointsFloat +#define SDL_EnclosePoints SDL_GetRectEnclosingPoints +#define SDL_FRectEmpty SDL_RectEmptyFloat +#define SDL_FRectEquals SDL_RectsEqualFloat +#define SDL_FRectEqualsEpsilon SDL_RectsEqualEpsilon +#define SDL_HasIntersection SDL_HasRectIntersection +#define SDL_HasIntersectionF SDL_HasRectIntersectionFloat +#define SDL_IntersectFRect SDL_GetRectIntersectionFloat +#define SDL_IntersectFRectAndLine SDL_GetRectAndLineIntersectionFloat +#define SDL_IntersectRect SDL_GetRectIntersection +#define SDL_IntersectRectAndLine SDL_GetRectAndLineIntersection +#define SDL_PointInFRect SDL_PointInRectFloat +#define SDL_RectEquals SDL_RectsEqual +#define SDL_UnionFRect SDL_GetRectUnionFloat +#define SDL_UnionRect SDL_GetRectUnion + +/* ##SDL_render.h */ +#define SDL_GetRendererOutputSize SDL_GetCurrentRenderOutputSize +#define SDL_RenderCopy SDL_RenderTexture +#define SDL_RenderCopyEx SDL_RenderTextureRotated +#define SDL_RenderCopyExF SDL_RenderTextureRotated +#define SDL_RenderCopyF SDL_RenderTexture +#define SDL_RenderDrawLine SDL_RenderLine +#define SDL_RenderDrawLineF SDL_RenderLine +#define SDL_RenderDrawLines SDL_RenderLines +#define SDL_RenderDrawLinesF SDL_RenderLines +#define SDL_RenderDrawPoint SDL_RenderPoint +#define SDL_RenderDrawPointF SDL_RenderPoint +#define SDL_RenderDrawPoints SDL_RenderPoints +#define SDL_RenderDrawPointsF SDL_RenderPoints +#define SDL_RenderDrawRect SDL_RenderRect +#define SDL_RenderDrawRectF SDL_RenderRect +#define SDL_RenderDrawRects SDL_RenderRects +#define SDL_RenderDrawRectsF SDL_RenderRects +#define SDL_RenderFillRectF SDL_RenderFillRect +#define SDL_RenderFillRectsF SDL_RenderFillRects +#define SDL_RendererFlip SDL_FlipMode +#define SDL_RenderFlush SDL_FlushRenderer +#define SDL_RenderGetClipRect SDL_GetRenderClipRect +#define SDL_RenderGetLogicalSize SDL_GetRenderLogicalPresentation +#define SDL_RenderGetMetalCommandEncoder SDL_GetRenderMetalCommandEncoder +#define SDL_RenderGetMetalLayer SDL_GetRenderMetalLayer +#define SDL_RenderGetScale SDL_GetRenderScale +#define SDL_RenderGetViewport SDL_GetRenderViewport +#define SDL_RenderGetWindow SDL_GetRenderWindow +#define SDL_RenderIsClipEnabled SDL_RenderClipEnabled +#define SDL_RenderLogicalToWindow SDL_RenderCoordinatesToWindow +#define SDL_RenderSetClipRect SDL_SetRenderClipRect +#define SDL_RenderSetLogicalSize SDL_SetRenderLogicalPresentation +#define SDL_RenderSetScale SDL_SetRenderScale +#define SDL_RenderSetVSync SDL_SetRenderVSync +#define SDL_RenderSetViewport SDL_SetRenderViewport +#define SDL_RenderWindowToLogical SDL_RenderCoordinatesFromWindow +#define SDL_ScaleModeLinear SDL_SCALEMODE_LINEAR +#define SDL_ScaleModeNearest SDL_SCALEMODE_NEAREST + +/* ##SDL_rwops.h */ +#define RW_SEEK_CUR SDL_IO_SEEK_CUR +#define RW_SEEK_END SDL_IO_SEEK_END +#define RW_SEEK_SET SDL_IO_SEEK_SET +#define SDL_RWFromConstMem SDL_IOFromConstMem +#define SDL_RWFromFile SDL_IOFromFile +#define SDL_RWFromMem SDL_IOFromMem +#define SDL_RWclose SDL_CloseIO +#define SDL_RWops SDL_IOStream +#define SDL_RWread SDL_ReadIO +#define SDL_RWseek SDL_SeekIO +#define SDL_RWsize SDL_GetIOSize +#define SDL_RWtell SDL_TellIO +#define SDL_RWwrite SDL_WriteIO +#define SDL_ReadBE16 SDL_ReadU16BE +#define SDL_ReadBE32 SDL_ReadU32BE +#define SDL_ReadBE64 SDL_ReadU64BE +#define SDL_ReadLE16 SDL_ReadU16LE +#define SDL_ReadLE32 SDL_ReadU32LE +#define SDL_ReadLE64 SDL_ReadU64LE +#define SDL_WriteBE16 SDL_WriteU16BE +#define SDL_WriteBE32 SDL_WriteU32BE +#define SDL_WriteBE64 SDL_WriteU64BE +#define SDL_WriteLE16 SDL_WriteU16LE +#define SDL_WriteLE32 SDL_WriteU32LE +#define SDL_WriteLE64 SDL_WriteU64LE + +/* ##SDL_scancode.h */ +#define SDL_NUM_SCANCODES SDL_SCANCODE_COUNT +#define SDL_SCANCODE_AUDIOFASTFORWARD SDL_SCANCODE_MEDIA_FAST_FORWARD +#define SDL_SCANCODE_AUDIOMUTE SDL_SCANCODE_MUTE +#define SDL_SCANCODE_AUDIONEXT SDL_SCANCODE_MEDIA_NEXT_TRACK +#define SDL_SCANCODE_AUDIOPLAY SDL_SCANCODE_MEDIA_PLAY +#define SDL_SCANCODE_AUDIOPREV SDL_SCANCODE_MEDIA_PREVIOUS_TRACK +#define SDL_SCANCODE_AUDIOREWIND SDL_SCANCODE_MEDIA_REWIND +#define SDL_SCANCODE_AUDIOSTOP SDL_SCANCODE_MEDIA_STOP +#define SDL_SCANCODE_EJECT SDL_SCANCODE_MEDIA_EJECT +#define SDL_SCANCODE_MEDIASELECT SDL_SCANCODE_MEDIA_SELECT + +/* ##SDL_sensor.h */ +#define SDL_SensorClose SDL_CloseSensor +#define SDL_SensorFromInstanceID SDL_GetSensorFromID +#define SDL_SensorGetData SDL_GetSensorData +#define SDL_SensorGetInstanceID SDL_GetSensorID +#define SDL_SensorGetName SDL_GetSensorName +#define SDL_SensorGetNonPortableType SDL_GetSensorNonPortableType +#define SDL_SensorGetType SDL_GetSensorType +#define SDL_SensorOpen SDL_OpenSensor +#define SDL_SensorUpdate SDL_UpdateSensors + +/* ##SDL_stdinc.h */ +#define SDL_FALSE false +#define SDL_TABLESIZE SDL_arraysize +#define SDL_TRUE true +#define SDL_bool bool +#define SDL_size_add_overflow SDL_size_add_check_overflow +#define SDL_size_mul_overflow SDL_size_mul_check_overflow +#define SDL_strtokr SDL_strtok_r + +/* ##SDL_surface.h */ +#define SDL_BlitScaled SDL_BlitSurfaceScaled +#define SDL_ConvertSurfaceFormat SDL_ConvertSurface +#define SDL_FillRect SDL_FillSurfaceRect +#define SDL_FillRects SDL_FillSurfaceRects +#define SDL_FreeSurface SDL_DestroySurface +#define SDL_GetClipRect SDL_GetSurfaceClipRect +#define SDL_GetColorKey SDL_GetSurfaceColorKey +#define SDL_HasColorKey SDL_SurfaceHasColorKey +#define SDL_HasSurfaceRLE SDL_SurfaceHasRLE +#define SDL_LoadBMP_RW SDL_LoadBMP_IO +#define SDL_LowerBlit SDL_BlitSurfaceUnchecked +#define SDL_LowerBlitScaled SDL_BlitSurfaceUncheckedScaled +#define SDL_PREALLOC SDL_SURFACE_PREALLOCATED +#define SDL_SIMD_ALIGNED SDL_SURFACE_SIMD_ALIGNED +#define SDL_SaveBMP_RW SDL_SaveBMP_IO +#define SDL_SetClipRect SDL_SetSurfaceClipRect +#define SDL_SetColorKey SDL_SetSurfaceColorKey +#define SDL_UpperBlit SDL_BlitSurface +#define SDL_UpperBlitScaled SDL_BlitSurfaceScaled + +/* ##SDL_system.h */ +#define SDL_AndroidBackButton SDL_SendAndroidBackButton +#define SDL_AndroidGetActivity SDL_GetAndroidActivity +#define SDL_AndroidGetExternalStoragePath SDL_GetAndroidExternalStoragePath +#define SDL_AndroidGetExternalStorageState SDL_GetAndroidExternalStorageState +#define SDL_AndroidGetInternalStoragePath SDL_GetAndroidInternalStoragePath +#define SDL_AndroidGetJNIEnv SDL_GetAndroidJNIEnv +#define SDL_AndroidRequestPermission SDL_RequestAndroidPermission +#define SDL_AndroidRequestPermissionCallback SDL_RequestAndroidPermissionCallback +#define SDL_AndroidSendMessage SDL_SendAndroidMessage +#define SDL_AndroidShowToast SDL_ShowAndroidToast +#define SDL_DXGIGetOutputInfo SDL_GetDXGIOutputInfo +#define SDL_Direct3D9GetAdapterIndex SDL_GetDirect3D9AdapterIndex +#define SDL_GDKGetDefaultUser SDL_GetGDKDefaultUser +#define SDL_GDKGetTaskQueue SDL_GetGDKTaskQueue +#define SDL_LinuxSetThreadPriority SDL_SetLinuxThreadPriority +#define SDL_LinuxSetThreadPriorityAndPolicy SDL_SetLinuxThreadPriorityAndPolicy +#define SDL_OnApplicationDidBecomeActive SDL_OnApplicationDidEnterForeground +#define SDL_OnApplicationWillResignActive SDL_OnApplicationWillEnterBackground +#define SDL_iOSSetAnimationCallback SDL_SetiOSAnimationCallback +#define SDL_iOSSetEventPump SDL_SetiOSEventPump +#define SDL_iPhoneSetAnimationCallback SDL_SetiOSAnimationCallback +#define SDL_iPhoneSetEventPump SDL_SetiOSEventPump + +/* ##SDL_thread.h */ +#define SDL_SetThreadPriority SDL_SetCurrentThreadPriority +#define SDL_TLSCleanup SDL_CleanupTLS +#define SDL_TLSGet SDL_GetTLS +#define SDL_TLSSet SDL_SetTLS +#define SDL_threadID SDL_ThreadID + +/* ##SDL_timer.h */ +#define SDL_GetTicks64 SDL_GetTicks + +/* ##SDL_version.h */ +#define SDL_COMPILEDVERSION SDL_VERSION +#define SDL_PATCHLEVEL SDL_MICRO_VERSION + +/* ##SDL_video.h */ +#define SDL_GL_DeleteContext SDL_GL_DestroyContext +#define SDL_GLattr SDL_GLAttr +#define SDL_GLcontextFlag SDL_GLContextFlag +#define SDL_GLcontextReleaseFlag SDL_GLContextReleaseFlag +#define SDL_GLprofile SDL_GLProfile +#define SDL_GetClosestDisplayMode SDL_GetClosestFullscreenDisplayMode +#define SDL_GetDisplayOrientation SDL_GetCurrentDisplayOrientation +#define SDL_GetPointDisplayIndex SDL_GetDisplayForPoint +#define SDL_GetRectDisplayIndex SDL_GetDisplayForRect +#define SDL_GetWindowDisplayIndex SDL_GetDisplayForWindow +#define SDL_GetWindowDisplayMode SDL_GetWindowFullscreenMode +#define SDL_HasWindowSurface SDL_WindowHasSurface +#define SDL_IsScreenSaverEnabled SDL_ScreenSaverEnabled +#define SDL_SetWindowDisplayMode SDL_SetWindowFullscreenMode +#define SDL_WINDOW_ALLOW_HIGHDPI SDL_WINDOW_HIGH_PIXEL_DENSITY +#define SDL_WINDOW_INPUT_GRABBED SDL_WINDOW_MOUSE_GRABBED +#define SDL_WINDOW_SKIP_TASKBAR SDL_WINDOW_UTILITY + +#elif !defined(SDL_DISABLE_OLD_NAMES) + +/* ##SDL_atomic.h */ +#define SDL_AtomicAdd SDL_AtomicAdd_renamed_SDL_AddAtomicInt +#define SDL_AtomicCAS SDL_AtomicCAS_renamed_SDL_CompareAndSwapAtomicInt +#define SDL_AtomicCASPtr SDL_AtomicCASPtr_renamed_SDL_CompareAndSwapAtomicPointer +#define SDL_AtomicGet SDL_AtomicGet_renamed_SDL_GetAtomicInt +#define SDL_AtomicGetPtr SDL_AtomicGetPtr_renamed_SDL_GetAtomicPointer +#define SDL_AtomicLock SDL_AtomicLock_renamed_SDL_LockSpinlock +#define SDL_AtomicSet SDL_AtomicSet_renamed_SDL_SetAtomicInt +#define SDL_AtomicSetPtr SDL_AtomicSetPtr_renamed_SDL_SetAtomicPointer +#define SDL_AtomicTryLock SDL_AtomicTryLock_renamed_SDL_TryLockSpinlock +#define SDL_AtomicUnlock SDL_AtomicUnlock_renamed_SDL_UnlockSpinlock +#define SDL_atomic_t SDL_atomic_t_renamed_SDL_AtomicInt + +/* ##SDL_audio.h */ +#define AUDIO_F32 AUDIO_F32_renamed_SDL_AUDIO_F32LE +#define AUDIO_F32LSB AUDIO_F32LSB_renamed_SDL_AUDIO_F32LE +#define AUDIO_F32MSB AUDIO_F32MSB_renamed_SDL_AUDIO_F32BE +#define AUDIO_F32SYS AUDIO_F32SYS_renamed_SDL_AUDIO_F32 +#define AUDIO_S16 AUDIO_S16_renamed_SDL_AUDIO_S16LE +#define AUDIO_S16LSB AUDIO_S16LSB_renamed_SDL_AUDIO_S16LE +#define AUDIO_S16MSB AUDIO_S16MSB_renamed_SDL_AUDIO_S16BE +#define AUDIO_S16SYS AUDIO_S16SYS_renamed_SDL_AUDIO_S16 +#define AUDIO_S32 AUDIO_S32_renamed_SDL_AUDIO_S32LE +#define AUDIO_S32LSB AUDIO_S32LSB_renamed_SDL_AUDIO_S32LE +#define AUDIO_S32MSB AUDIO_S32MSB_renamed_SDL_AUDIO_S32BE +#define AUDIO_S32SYS AUDIO_S32SYS_renamed_SDL_AUDIO_S32 +#define AUDIO_S8 AUDIO_S8_renamed_SDL_AUDIO_S8 +#define AUDIO_U8 AUDIO_U8_renamed_SDL_AUDIO_U8 +#define SDL_AudioStreamAvailable SDL_AudioStreamAvailable_renamed_SDL_GetAudioStreamAvailable +#define SDL_AudioStreamClear SDL_AudioStreamClear_renamed_SDL_ClearAudioStream +#define SDL_AudioStreamFlush SDL_AudioStreamFlush_renamed_SDL_FlushAudioStream +#define SDL_AudioStreamGet SDL_AudioStreamGet_renamed_SDL_GetAudioStreamData +#define SDL_AudioStreamPut SDL_AudioStreamPut_renamed_SDL_PutAudioStreamData +#define SDL_FreeAudioStream SDL_FreeAudioStream_renamed_SDL_DestroyAudioStream +#define SDL_FreeWAV SDL_FreeWAV_renamed_SDL_free +#define SDL_LoadWAV_RW SDL_LoadWAV_RW_renamed_SDL_LoadWAV_IO +#define SDL_MixAudioFormat SDL_MixAudioFormat_renamed_SDL_MixAudio +#define SDL_NewAudioStream SDL_NewAudioStream_renamed_SDL_CreateAudioStream + +/* ##SDL_cpuinfo.h */ +#define SDL_GetCPUCount SDL_GetCPUCount_renamed_SDL_GetNumLogicalCPUCores +#define SDL_SIMDGetAlignment SDL_SIMDGetAlignment_renamed_SDL_GetSIMDAlignment + +/* ##SDL_endian.h */ +#define SDL_SwapBE16 SDL_SwapBE16_renamed_SDL_Swap16BE +#define SDL_SwapBE32 SDL_SwapBE32_renamed_SDL_Swap32BE +#define SDL_SwapBE64 SDL_SwapBE64_renamed_SDL_Swap64BE +#define SDL_SwapLE16 SDL_SwapLE16_renamed_SDL_Swap16LE +#define SDL_SwapLE32 SDL_SwapLE32_renamed_SDL_Swap32LE +#define SDL_SwapLE64 SDL_SwapLE64_renamed_SDL_Swap64LE + +/* ##SDL_events.h */ +#define SDL_APP_DIDENTERBACKGROUND SDL_APP_DIDENTERBACKGROUND_renamed_SDL_EVENT_DID_ENTER_BACKGROUND +#define SDL_APP_DIDENTERFOREGROUND SDL_APP_DIDENTERFOREGROUND_renamed_SDL_EVENT_DID_ENTER_FOREGROUND +#define SDL_APP_LOWMEMORY SDL_APP_LOWMEMORY_renamed_SDL_EVENT_LOW_MEMORY +#define SDL_APP_TERMINATING SDL_APP_TERMINATING_renamed_SDL_EVENT_TERMINATING +#define SDL_APP_WILLENTERBACKGROUND SDL_APP_WILLENTERBACKGROUND_renamed_SDL_EVENT_WILL_ENTER_BACKGROUND +#define SDL_APP_WILLENTERFOREGROUND SDL_APP_WILLENTERFOREGROUND_renamed_SDL_EVENT_WILL_ENTER_FOREGROUND +#define SDL_AUDIODEVICEADDED SDL_AUDIODEVICEADDED_renamed_SDL_EVENT_AUDIO_DEVICE_ADDED +#define SDL_AUDIODEVICEREMOVED SDL_AUDIODEVICEREMOVED_renamed_SDL_EVENT_AUDIO_DEVICE_REMOVED +#define SDL_CLIPBOARDUPDATE SDL_CLIPBOARDUPDATE_renamed_SDL_EVENT_CLIPBOARD_UPDATE +#define SDL_CONTROLLERAXISMOTION SDL_CONTROLLERAXISMOTION_renamed_SDL_EVENT_GAMEPAD_AXIS_MOTION +#define SDL_CONTROLLERBUTTONDOWN SDL_CONTROLLERBUTTONDOWN_renamed_SDL_EVENT_GAMEPAD_BUTTON_DOWN +#define SDL_CONTROLLERBUTTONUP SDL_CONTROLLERBUTTONUP_renamed_SDL_EVENT_GAMEPAD_BUTTON_UP +#define SDL_CONTROLLERDEVICEADDED SDL_CONTROLLERDEVICEADDED_renamed_SDL_EVENT_GAMEPAD_ADDED +#define SDL_CONTROLLERDEVICEREMAPPED SDL_CONTROLLERDEVICEREMAPPED_renamed_SDL_EVENT_GAMEPAD_REMAPPED +#define SDL_CONTROLLERDEVICEREMOVED SDL_CONTROLLERDEVICEREMOVED_renamed_SDL_EVENT_GAMEPAD_REMOVED +#define SDL_CONTROLLERSENSORUPDATE SDL_CONTROLLERSENSORUPDATE_renamed_SDL_EVENT_GAMEPAD_SENSOR_UPDATE +#define SDL_CONTROLLERSTEAMHANDLEUPDATED SDL_CONTROLLERSTEAMHANDLEUPDATED_renamed_SDL_EVENT_GAMEPAD_STEAM_HANDLE_UPDATED +#define SDL_CONTROLLERTOUCHPADDOWN SDL_CONTROLLERTOUCHPADDOWN_renamed_SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN +#define SDL_CONTROLLERTOUCHPADMOTION SDL_CONTROLLERTOUCHPADMOTION_renamed_SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION +#define SDL_CONTROLLERTOUCHPADUP SDL_CONTROLLERTOUCHPADUP_renamed_SDL_EVENT_GAMEPAD_TOUCHPAD_UP +#define SDL_ControllerAxisEvent SDL_ControllerAxisEvent_renamed_SDL_GamepadAxisEvent +#define SDL_ControllerButtonEvent SDL_ControllerButtonEvent_renamed_SDL_GamepadButtonEvent +#define SDL_ControllerDeviceEvent SDL_ControllerDeviceEvent_renamed_SDL_GamepadDeviceEvent +#define SDL_ControllerSensorEvent SDL_ControllerSensorEvent_renamed_SDL_GamepadSensorEvent +#define SDL_ControllerTouchpadEvent SDL_ControllerTouchpadEvent_renamed_SDL_GamepadTouchpadEvent +#define SDL_DISPLAYEVENT_CONNECTED SDL_DISPLAYEVENT_CONNECTED_renamed_SDL_EVENT_DISPLAY_ADDED +#define SDL_DISPLAYEVENT_DISCONNECTED SDL_DISPLAYEVENT_DISCONNECTED_renamed_SDL_EVENT_DISPLAY_REMOVED +#define SDL_DISPLAYEVENT_MOVED SDL_DISPLAYEVENT_MOVED_renamed_SDL_EVENT_DISPLAY_MOVED +#define SDL_DISPLAYEVENT_ORIENTATION SDL_DISPLAYEVENT_ORIENTATION_renamed_SDL_EVENT_DISPLAY_ORIENTATION +#define SDL_DROPBEGIN SDL_DROPBEGIN_renamed_SDL_EVENT_DROP_BEGIN +#define SDL_DROPCOMPLETE SDL_DROPCOMPLETE_renamed_SDL_EVENT_DROP_COMPLETE +#define SDL_DROPFILE SDL_DROPFILE_renamed_SDL_EVENT_DROP_FILE +#define SDL_DROPTEXT SDL_DROPTEXT_renamed_SDL_EVENT_DROP_TEXT +#define SDL_DelEventWatch SDL_DelEventWatch_renamed_SDL_RemoveEventWatch +#define SDL_FINGERDOWN SDL_FINGERDOWN_renamed_SDL_EVENT_FINGER_DOWN +#define SDL_FINGERMOTION SDL_FINGERMOTION_renamed_SDL_EVENT_FINGER_MOTION +#define SDL_FINGERUP SDL_FINGERUP_renamed_SDL_EVENT_FINGER_UP +#define SDL_FIRSTEVENT SDL_FIRSTEVENT_renamed_SDL_EVENT_FIRST +#define SDL_JOYAXISMOTION SDL_JOYAXISMOTION_renamed_SDL_EVENT_JOYSTICK_AXIS_MOTION +#define SDL_JOYBATTERYUPDATED SDL_JOYBATTERYUPDATED_renamed_SDL_EVENT_JOYSTICK_BATTERY_UPDATED +#define SDL_JOYBUTTONDOWN SDL_JOYBUTTONDOWN_renamed_SDL_EVENT_JOYSTICK_BUTTON_DOWN +#define SDL_JOYBUTTONUP SDL_JOYBUTTONUP_renamed_SDL_EVENT_JOYSTICK_BUTTON_UP +#define SDL_JOYDEVICEADDED SDL_JOYDEVICEADDED_renamed_SDL_EVENT_JOYSTICK_ADDED +#define SDL_JOYDEVICEREMOVED SDL_JOYDEVICEREMOVED_renamed_SDL_EVENT_JOYSTICK_REMOVED +#define SDL_JOYBALLMOTION SDL_JOYBALLMOTION_renamed_SDL_EVENT_JOYSTICK_BALL_MOTION +#define SDL_JOYHATMOTION SDL_JOYHATMOTION_renamed_SDL_EVENT_JOYSTICK_HAT_MOTION +#define SDL_KEYDOWN SDL_KEYDOWN_renamed_SDL_EVENT_KEY_DOWN +#define SDL_KEYMAPCHANGED SDL_KEYMAPCHANGED_renamed_SDL_EVENT_KEYMAP_CHANGED +#define SDL_KEYUP SDL_KEYUP_renamed_SDL_EVENT_KEY_UP +#define SDL_LASTEVENT SDL_LASTEVENT_renamed_SDL_EVENT_LAST +#define SDL_LOCALECHANGED SDL_LOCALECHANGED_renamed_SDL_EVENT_LOCALE_CHANGED +#define SDL_MOUSEBUTTONDOWN SDL_MOUSEBUTTONDOWN_renamed_SDL_EVENT_MOUSE_BUTTON_DOWN +#define SDL_MOUSEBUTTONUP SDL_MOUSEBUTTONUP_renamed_SDL_EVENT_MOUSE_BUTTON_UP +#define SDL_MOUSEMOTION SDL_MOUSEMOTION_renamed_SDL_EVENT_MOUSE_MOTION +#define SDL_MOUSEWHEEL SDL_MOUSEWHEEL_renamed_SDL_EVENT_MOUSE_WHEEL +#define SDL_POLLSENTINEL SDL_POLLSENTINEL_renamed_SDL_EVENT_POLL_SENTINEL +#define SDL_QUIT SDL_QUIT_renamed_SDL_EVENT_QUIT +#define SDL_RENDER_DEVICE_RESET SDL_RENDER_DEVICE_RESET_renamed_SDL_EVENT_RENDER_DEVICE_RESET +#define SDL_RENDER_TARGETS_RESET SDL_RENDER_TARGETS_RESET_renamed_SDL_EVENT_RENDER_TARGETS_RESET +#define SDL_SENSORUPDATE SDL_SENSORUPDATE_renamed_SDL_EVENT_SENSOR_UPDATE +#define SDL_TEXTEDITING SDL_TEXTEDITING_renamed_SDL_EVENT_TEXT_EDITING +#define SDL_TEXTEDITING_EXT SDL_TEXTEDITING_EXT_renamed_SDL_EVENT_TEXT_EDITING_EXT +#define SDL_TEXTINPUT SDL_TEXTINPUT_renamed_SDL_EVENT_TEXT_INPUT +#define SDL_USEREVENT SDL_USEREVENT_renamed_SDL_EVENT_USER +#define SDL_WINDOWEVENT_CLOSE SDL_WINDOWEVENT_CLOSE_renamed_SDL_EVENT_WINDOW_CLOSE_REQUESTED +#define SDL_WINDOWEVENT_DISPLAY_CHANGED SDL_WINDOWEVENT_DISPLAY_CHANGED_renamed_SDL_EVENT_WINDOW_DISPLAY_CHANGED +#define SDL_WINDOWEVENT_ENTER SDL_WINDOWEVENT_ENTER_renamed_SDL_EVENT_WINDOW_MOUSE_ENTER +#define SDL_WINDOWEVENT_EXPOSED SDL_WINDOWEVENT_EXPOSED_renamed_SDL_EVENT_WINDOW_EXPOSED +#define SDL_WINDOWEVENT_FOCUS_GAINED SDL_WINDOWEVENT_FOCUS_GAINED_renamed_SDL_EVENT_WINDOW_FOCUS_GAINED +#define SDL_WINDOWEVENT_FOCUS_LOST SDL_WINDOWEVENT_FOCUS_LOST_renamed_SDL_EVENT_WINDOW_FOCUS_LOST +#define SDL_WINDOWEVENT_HIDDEN SDL_WINDOWEVENT_HIDDEN_renamed_SDL_EVENT_WINDOW_HIDDEN +#define SDL_WINDOWEVENT_HIT_TEST SDL_WINDOWEVENT_HIT_TEST_renamed_SDL_EVENT_WINDOW_HIT_TEST +#define SDL_WINDOWEVENT_ICCPROF_CHANGED SDL_WINDOWEVENT_ICCPROF_CHANGED_renamed_SDL_EVENT_WINDOW_ICCPROF_CHANGED +#define SDL_WINDOWEVENT_LEAVE SDL_WINDOWEVENT_LEAVE_renamed_SDL_EVENT_WINDOW_MOUSE_LEAVE +#define SDL_WINDOWEVENT_MAXIMIZED SDL_WINDOWEVENT_MAXIMIZED_renamed_SDL_EVENT_WINDOW_MAXIMIZED +#define SDL_WINDOWEVENT_MINIMIZED SDL_WINDOWEVENT_MINIMIZED_renamed_SDL_EVENT_WINDOW_MINIMIZED +#define SDL_WINDOWEVENT_MOVED SDL_WINDOWEVENT_MOVED_renamed_SDL_EVENT_WINDOW_MOVED +#define SDL_WINDOWEVENT_RESIZED SDL_WINDOWEVENT_RESIZED_renamed_SDL_EVENT_WINDOW_RESIZED +#define SDL_WINDOWEVENT_RESTORED SDL_WINDOWEVENT_RESTORED_renamed_SDL_EVENT_WINDOW_RESTORED +#define SDL_WINDOWEVENT_SHOWN SDL_WINDOWEVENT_SHOWN_renamed_SDL_EVENT_WINDOW_SHOWN +#define SDL_WINDOWEVENT_SIZE_CHANGED SDL_WINDOWEVENT_SIZE_CHANGED_renamed_SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED +#define SDL_eventaction SDL_eventaction_renamed_SDL_EventAction + +/* ##SDL_gamecontroller.h */ +#define SDL_CONTROLLER_AXIS_INVALID SDL_CONTROLLER_AXIS_INVALID_renamed_SDL_GAMEPAD_AXIS_INVALID +#define SDL_CONTROLLER_AXIS_LEFTX SDL_CONTROLLER_AXIS_LEFTX_renamed_SDL_GAMEPAD_AXIS_LEFTX +#define SDL_CONTROLLER_AXIS_LEFTY SDL_CONTROLLER_AXIS_LEFTY_renamed_SDL_GAMEPAD_AXIS_LEFTY +#define SDL_CONTROLLER_AXIS_MAX SDL_CONTROLLER_AXIS_MAX_renamed_SDL_GAMEPAD_AXIS_COUNT +#define SDL_CONTROLLER_AXIS_RIGHTX SDL_CONTROLLER_AXIS_RIGHTX_renamed_SDL_GAMEPAD_AXIS_RIGHTX +#define SDL_CONTROLLER_AXIS_RIGHTY SDL_CONTROLLER_AXIS_RIGHTY_renamed_SDL_GAMEPAD_AXIS_RIGHTY +#define SDL_CONTROLLER_AXIS_TRIGGERLEFT SDL_CONTROLLER_AXIS_TRIGGERLEFT_renamed_SDL_GAMEPAD_AXIS_LEFT_TRIGGER +#define SDL_CONTROLLER_AXIS_TRIGGERRIGHT SDL_CONTROLLER_AXIS_TRIGGERRIGHT_renamed_SDL_GAMEPAD_AXIS_RIGHT_TRIGGER +#define SDL_CONTROLLER_BINDTYPE_AXIS SDL_CONTROLLER_BINDTYPE_AXIS_renamed_SDL_GAMEPAD_BINDTYPE_AXIS +#define SDL_CONTROLLER_BINDTYPE_BUTTON SDL_CONTROLLER_BINDTYPE_BUTTON_renamed_SDL_GAMEPAD_BINDTYPE_BUTTON +#define SDL_CONTROLLER_BINDTYPE_HAT SDL_CONTROLLER_BINDTYPE_HAT_renamed_SDL_GAMEPAD_BINDTYPE_HAT +#define SDL_CONTROLLER_BINDTYPE_NONE SDL_CONTROLLER_BINDTYPE_NONE_renamed_SDL_GAMEPAD_BINDTYPE_NONE +#define SDL_CONTROLLER_BUTTON_A SDL_CONTROLLER_BUTTON_A_renamed_SDL_GAMEPAD_BUTTON_SOUTH +#define SDL_CONTROLLER_BUTTON_B SDL_CONTROLLER_BUTTON_B_renamed_SDL_GAMEPAD_BUTTON_EAST +#define SDL_CONTROLLER_BUTTON_BACK SDL_CONTROLLER_BUTTON_BACK_renamed_SDL_GAMEPAD_BUTTON_BACK +#define SDL_CONTROLLER_BUTTON_DPAD_DOWN SDL_CONTROLLER_BUTTON_DPAD_DOWN_renamed_SDL_GAMEPAD_BUTTON_DPAD_DOWN +#define SDL_CONTROLLER_BUTTON_DPAD_LEFT SDL_CONTROLLER_BUTTON_DPAD_LEFT_renamed_SDL_GAMEPAD_BUTTON_DPAD_LEFT +#define SDL_CONTROLLER_BUTTON_DPAD_RIGHT SDL_CONTROLLER_BUTTON_DPAD_RIGHT_renamed_SDL_GAMEPAD_BUTTON_DPAD_RIGHT +#define SDL_CONTROLLER_BUTTON_DPAD_UP SDL_CONTROLLER_BUTTON_DPAD_UP_renamed_SDL_GAMEPAD_BUTTON_DPAD_UP +#define SDL_CONTROLLER_BUTTON_GUIDE SDL_CONTROLLER_BUTTON_GUIDE_renamed_SDL_GAMEPAD_BUTTON_GUIDE +#define SDL_CONTROLLER_BUTTON_INVALID SDL_CONTROLLER_BUTTON_INVALID_renamed_SDL_GAMEPAD_BUTTON_INVALID +#define SDL_CONTROLLER_BUTTON_LEFTSHOULDER SDL_CONTROLLER_BUTTON_LEFTSHOULDER_renamed_SDL_GAMEPAD_BUTTON_LEFT_SHOULDER +#define SDL_CONTROLLER_BUTTON_LEFTSTICK SDL_CONTROLLER_BUTTON_LEFTSTICK_renamed_SDL_GAMEPAD_BUTTON_LEFT_STICK +#define SDL_CONTROLLER_BUTTON_MAX SDL_CONTROLLER_BUTTON_MAX_renamed_SDL_GAMEPAD_BUTTON_COUNT +#define SDL_CONTROLLER_BUTTON_MISC1 SDL_CONTROLLER_BUTTON_MISC1_renamed_SDL_GAMEPAD_BUTTON_MISC1 +#define SDL_CONTROLLER_BUTTON_PADDLE1 SDL_CONTROLLER_BUTTON_PADDLE1_renamed_SDL_GAMEPAD_BUTTON_RIGHT_PADDLE1 +#define SDL_CONTROLLER_BUTTON_PADDLE2 SDL_CONTROLLER_BUTTON_PADDLE2_renamed_SDL_GAMEPAD_BUTTON_LEFT_PADDLE1 +#define SDL_CONTROLLER_BUTTON_PADDLE3 SDL_CONTROLLER_BUTTON_PADDLE3_renamed_SDL_GAMEPAD_BUTTON_RIGHT_PADDLE2 +#define SDL_CONTROLLER_BUTTON_PADDLE4 SDL_CONTROLLER_BUTTON_PADDLE4_renamed_SDL_GAMEPAD_BUTTON_LEFT_PADDLE2 +#define SDL_CONTROLLER_BUTTON_RIGHTSHOULDER SDL_CONTROLLER_BUTTON_RIGHTSHOULDER_renamed_SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER +#define SDL_CONTROLLER_BUTTON_RIGHTSTICK SDL_CONTROLLER_BUTTON_RIGHTSTICK_renamed_SDL_GAMEPAD_BUTTON_RIGHT_STICK +#define SDL_CONTROLLER_BUTTON_START SDL_CONTROLLER_BUTTON_START_renamed_SDL_GAMEPAD_BUTTON_START +#define SDL_CONTROLLER_BUTTON_TOUCHPAD SDL_CONTROLLER_BUTTON_TOUCHPAD_renamed_SDL_GAMEPAD_BUTTON_TOUCHPAD +#define SDL_CONTROLLER_BUTTON_X SDL_CONTROLLER_BUTTON_X_renamed_SDL_GAMEPAD_BUTTON_WEST +#define SDL_CONTROLLER_BUTTON_Y SDL_CONTROLLER_BUTTON_Y_renamed_SDL_GAMEPAD_BUTTON_NORTH +#define SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_LEFT SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_LEFT_renamed_SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_LEFT +#define SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_PAIR SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_PAIR_renamed_SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_PAIR +#define SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT_renamed_SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT +#define SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO_renamed_SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_PRO +#define SDL_CONTROLLER_TYPE_PS3 SDL_CONTROLLER_TYPE_PS3_renamed_SDL_GAMEPAD_TYPE_PS3 +#define SDL_CONTROLLER_TYPE_PS4 SDL_CONTROLLER_TYPE_PS4_renamed_SDL_GAMEPAD_TYPE_PS4 +#define SDL_CONTROLLER_TYPE_PS5 SDL_CONTROLLER_TYPE_PS5_renamed_SDL_GAMEPAD_TYPE_PS5 +#define SDL_CONTROLLER_TYPE_UNKNOWN SDL_CONTROLLER_TYPE_UNKNOWN_renamed_SDL_GAMEPAD_TYPE_STANDARD +#define SDL_CONTROLLER_TYPE_VIRTUAL SDL_CONTROLLER_TYPE_VIRTUAL_renamed_SDL_GAMEPAD_TYPE_VIRTUAL +#define SDL_CONTROLLER_TYPE_XBOX360 SDL_CONTROLLER_TYPE_XBOX360_renamed_SDL_GAMEPAD_TYPE_XBOX360 +#define SDL_CONTROLLER_TYPE_XBOXONE SDL_CONTROLLER_TYPE_XBOXONE_renamed_SDL_GAMEPAD_TYPE_XBOXONE +#define SDL_GameController SDL_GameController_renamed_SDL_Gamepad +#define SDL_GameControllerAddMapping SDL_GameControllerAddMapping_renamed_SDL_AddGamepadMapping +#define SDL_GameControllerAddMappingsFromFile SDL_GameControllerAddMappingsFromFile_renamed_SDL_AddGamepadMappingsFromFile +#define SDL_GameControllerAddMappingsFromRW SDL_GameControllerAddMappingsFromRW_renamed_SDL_AddGamepadMappingsFromIO +#define SDL_GameControllerAxis SDL_GameControllerAxis_renamed_SDL_GamepadAxis +#define SDL_GameControllerBindType SDL_GameControllerBindType_renamed_SDL_GamepadBindingType +#define SDL_GameControllerButton SDL_GameControllerButton_renamed_SDL_GamepadButton +#define SDL_GameControllerClose SDL_GameControllerClose_renamed_SDL_CloseGamepad +#define SDL_GameControllerFromInstanceID SDL_GameControllerFromInstanceID_renamed_SDL_GetGamepadFromID +#define SDL_GameControllerFromPlayerIndex SDL_GameControllerFromPlayerIndex_renamed_SDL_GetGamepadFromPlayerIndex +#define SDL_GameControllerGetAppleSFSymbolsNameForAxis SDL_GameControllerGetAppleSFSymbolsNameForAxis_renamed_SDL_GetGamepadAppleSFSymbolsNameForAxis +#define SDL_GameControllerGetAppleSFSymbolsNameForButton SDL_GameControllerGetAppleSFSymbolsNameForButton_renamed_SDL_GetGamepadAppleSFSymbolsNameForButton +#define SDL_GameControllerGetAttached SDL_GameControllerGetAttached_renamed_SDL_GamepadConnected +#define SDL_GameControllerGetAxis SDL_GameControllerGetAxis_renamed_SDL_GetGamepadAxis +#define SDL_GameControllerGetAxisFromString SDL_GameControllerGetAxisFromString_renamed_SDL_GetGamepadAxisFromString +#define SDL_GameControllerGetButton SDL_GameControllerGetButton_renamed_SDL_GetGamepadButton +#define SDL_GameControllerGetButtonFromString SDL_GameControllerGetButtonFromString_renamed_SDL_GetGamepadButtonFromString +#define SDL_GameControllerGetFirmwareVersion SDL_GameControllerGetFirmwareVersion_renamed_SDL_GetGamepadFirmwareVersion +#define SDL_GameControllerGetJoystick SDL_GameControllerGetJoystick_renamed_SDL_GetGamepadJoystick +#define SDL_GameControllerGetNumTouchpadFingers SDL_GameControllerGetNumTouchpadFingers_renamed_SDL_GetNumGamepadTouchpadFingers +#define SDL_GameControllerGetNumTouchpads SDL_GameControllerGetNumTouchpads_renamed_SDL_GetNumGamepadTouchpads +#define SDL_GameControllerGetPlayerIndex SDL_GameControllerGetPlayerIndex_renamed_SDL_GetGamepadPlayerIndex +#define SDL_GameControllerGetProduct SDL_GameControllerGetProduct_renamed_SDL_GetGamepadProduct +#define SDL_GameControllerGetProductVersion SDL_GameControllerGetProductVersion_renamed_SDL_GetGamepadProductVersion +#define SDL_GameControllerGetSensorData SDL_GameControllerGetSensorData_renamed_SDL_GetGamepadSensorData +#define SDL_GameControllerGetSensorDataRate SDL_GameControllerGetSensorDataRate_renamed_SDL_GetGamepadSensorDataRate +#define SDL_GameControllerGetSerial SDL_GameControllerGetSerial_renamed_SDL_GetGamepadSerial +#define SDL_GameControllerGetSteamHandle SDL_GameControllerGetSteamHandle_renamed_SDL_GetGamepadSteamHandle +#define SDL_GameControllerGetStringForAxis SDL_GameControllerGetStringForAxis_renamed_SDL_GetGamepadStringForAxis +#define SDL_GameControllerGetStringForButton SDL_GameControllerGetStringForButton_renamed_SDL_GetGamepadStringForButton +#define SDL_GameControllerGetTouchpadFinger SDL_GameControllerGetTouchpadFinger_renamed_SDL_GetGamepadTouchpadFinger +#define SDL_GameControllerGetType SDL_GameControllerGetType_renamed_SDL_GetGamepadType +#define SDL_GameControllerGetVendor SDL_GameControllerGetVendor_renamed_SDL_GetGamepadVendor +#define SDL_GameControllerHasAxis SDL_GameControllerHasAxis_renamed_SDL_GamepadHasAxis +#define SDL_GameControllerHasButton SDL_GameControllerHasButton_renamed_SDL_GamepadHasButton +#define SDL_GameControllerHasSensor SDL_GameControllerHasSensor_renamed_SDL_GamepadHasSensor +#define SDL_GameControllerIsSensorEnabled SDL_GameControllerIsSensorEnabled_renamed_SDL_GamepadSensorEnabled +#define SDL_GameControllerMapping SDL_GameControllerMapping_renamed_SDL_GetGamepadMapping +#define SDL_GameControllerMappingForDeviceIndex SDL_GameControllerMappingForDeviceIndex_renamed_SDL_GetGamepadMappingForDeviceIndex +#define SDL_GameControllerMappingForGUID SDL_GameControllerMappingForGUID_renamed_SDL_GetGamepadMappingForGUID +#define SDL_GameControllerName SDL_GameControllerName_renamed_SDL_GetGamepadName +#define SDL_GameControllerOpen SDL_GameControllerOpen_renamed_SDL_OpenGamepad +#define SDL_GameControllerPath SDL_GameControllerPath_renamed_SDL_GetGamepadPath +#define SDL_GameControllerRumble SDL_GameControllerRumble_renamed_SDL_RumbleGamepad +#define SDL_GameControllerRumbleTriggers SDL_GameControllerRumbleTriggers_renamed_SDL_RumbleGamepadTriggers +#define SDL_GameControllerSendEffect SDL_GameControllerSendEffect_renamed_SDL_SendGamepadEffect +#define SDL_GameControllerSetLED SDL_GameControllerSetLED_renamed_SDL_SetGamepadLED +#define SDL_GameControllerSetPlayerIndex SDL_GameControllerSetPlayerIndex_renamed_SDL_SetGamepadPlayerIndex +#define SDL_GameControllerSetSensorEnabled SDL_GameControllerSetSensorEnabled_renamed_SDL_SetGamepadSensorEnabled +#define SDL_GameControllerType SDL_GameControllerType_renamed_SDL_GamepadType +#define SDL_GameControllerUpdate SDL_GameControllerUpdate_renamed_SDL_UpdateGamepads +#define SDL_INIT_GAMECONTROLLER SDL_INIT_GAMECONTROLLER_renamed_SDL_INIT_GAMEPAD +#define SDL_IsGameController SDL_IsGameController_renamed_SDL_IsGamepad + +/* ##SDL_guid.h */ +#define SDL_GUIDFromString SDL_GUIDFromString_renamed_SDL_StringToGUID + +/* ##SDL_haptic.h */ +#define SDL_HapticClose SDL_HapticClose_renamed_SDL_CloseHaptic +#define SDL_HapticDestroyEffect SDL_HapticDestroyEffect_renamed_SDL_DestroyHapticEffect +#define SDL_HapticGetEffectStatus SDL_HapticGetEffectStatus_renamed_SDL_GetHapticEffectStatus +#define SDL_HapticNewEffect SDL_HapticNewEffect_renamed_SDL_CreateHapticEffect +#define SDL_HapticNumAxes SDL_HapticNumAxes_renamed_SDL_GetNumHapticAxes +#define SDL_HapticNumEffects SDL_HapticNumEffects_renamed_SDL_GetMaxHapticEffects +#define SDL_HapticNumEffectsPlaying SDL_HapticNumEffectsPlaying_renamed_SDL_GetMaxHapticEffectsPlaying +#define SDL_HapticOpen SDL_HapticOpen_renamed_SDL_OpenHaptic +#define SDL_HapticOpenFromJoystick SDL_HapticOpenFromJoystick_renamed_SDL_OpenHapticFromJoystick +#define SDL_HapticOpenFromMouse SDL_HapticOpenFromMouse_renamed_SDL_OpenHapticFromMouse +#define SDL_HapticPause SDL_HapticPause_renamed_SDL_PauseHaptic +#define SDL_HapticQuery SDL_HapticQuery_renamed_SDL_GetHapticFeatures +#define SDL_HapticRumbleInit SDL_HapticRumbleInit_renamed_SDL_InitHapticRumble +#define SDL_HapticRumblePlay SDL_HapticRumblePlay_renamed_SDL_PlayHapticRumble +#define SDL_HapticRumbleStop SDL_HapticRumbleStop_renamed_SDL_StopHapticRumble +#define SDL_HapticRunEffect SDL_HapticRunEffect_renamed_SDL_RunHapticEffect +#define SDL_HapticSetAutocenter SDL_HapticSetAutocenter_renamed_SDL_SetHapticAutocenter +#define SDL_HapticSetGain SDL_HapticSetGain_renamed_SDL_SetHapticGain +#define SDL_HapticStopAll SDL_HapticStopAll_renamed_SDL_StopHapticEffects +#define SDL_HapticStopEffect SDL_HapticStopEffect_renamed_SDL_StopHapticEffect +#define SDL_HapticUnpause SDL_HapticUnpause_renamed_SDL_ResumeHaptic +#define SDL_HapticUpdateEffect SDL_HapticUpdateEffect_renamed_SDL_UpdateHapticEffect +#define SDL_JoystickIsHaptic SDL_JoystickIsHaptic_renamed_SDL_IsJoystickHaptic +#define SDL_MouseIsHaptic SDL_MouseIsHaptic_renamed_SDL_IsMouseHaptic + +/* ##SDL_hints.h */ +#define SDL_DelHintCallback SDL_DelHintCallback_renamed_SDL_RemoveHintCallback +#define SDL_HINT_ALLOW_TOPMOST SDL_HINT_ALLOW_TOPMOST_renamed_SDL_HINT_WINDOW_ALLOW_TOPMOST +#define SDL_HINT_DIRECTINPUT_ENABLED SDL_HINT_DIRECTINPUT_ENABLED_renamed_SDL_HINT_JOYSTICK_DIRECTINPUT +#define SDL_HINT_GDK_TEXTINPUT_DEFAULT SDL_HINT_GDK_TEXTINPUT_DEFAULT_renamed_SDL_HINT_GDK_TEXTINPUT_DEFAULT_TEXT +#define SDL_HINT_JOYSTICK_GAMECUBE_RUMBLE_BRAKE SDL_HINT_JOYSTICK_GAMECUBE_RUMBLE_BRAKE_renamed_SDL_HINT_JOYSTICK_HIDAPI_GAMECUBE_RUMBLE_BRAKE +#define SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE_renamed_SDL_HINT_JOYSTICK_ENHANCED_REPORTS +#define SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE_renamed_SDL_HINT_JOYSTICK_ENHANCED_REPORTS +#define SDL_HINT_LINUX_DIGITAL_HATS SDL_HINT_LINUX_DIGITAL_HATS_renamed_SDL_HINT_JOYSTICK_LINUX_DIGITAL_HATS +#define SDL_HINT_LINUX_HAT_DEADZONES SDL_HINT_LINUX_HAT_DEADZONES_renamed_SDL_HINT_JOYSTICK_LINUX_HAT_DEADZONES +#define SDL_HINT_LINUX_JOYSTICK_CLASSIC SDL_HINT_LINUX_JOYSTICK_CLASSIC_renamed_SDL_HINT_JOYSTICK_LINUX_CLASSIC +#define SDL_HINT_LINUX_JOYSTICK_DEADZONES SDL_HINT_LINUX_JOYSTICK_DEADZONES_renamed_SDL_HINT_JOYSTICK_LINUX_DEADZONES + +/* ##SDL_joystick.h */ +#define SDL_JOYSTICK_TYPE_GAMECONTROLLER SDL_JOYSTICK_TYPE_GAMECONTROLLER_renamed_SDL_JOYSTICK_TYPE_GAMEPAD +#define SDL_JoystickAttachVirtualEx SDL_JoystickAttachVirtualEx_renamed_SDL_AttachVirtualJoystick +#define SDL_JoystickClose SDL_JoystickClose_renamed_SDL_CloseJoystick +#define SDL_JoystickDetachVirtual SDL_JoystickDetachVirtual_renamed_SDL_DetachVirtualJoystick +#define SDL_JoystickFromInstanceID SDL_JoystickFromInstanceID_renamed_SDL_GetJoystickFromID +#define SDL_JoystickFromPlayerIndex SDL_JoystickFromPlayerIndex_renamed_SDL_GetJoystickFromPlayerIndex +#define SDL_JoystickGUID SDL_JoystickGUID_renamed_SDL_GUID +#define SDL_JoystickGetAttached SDL_JoystickGetAttached_renamed_SDL_JoystickConnected +#define SDL_JoystickGetAxis SDL_JoystickGetAxis_renamed_SDL_GetJoystickAxis +#define SDL_JoystickGetAxisInitialState SDL_JoystickGetAxisInitialState_renamed_SDL_GetJoystickAxisInitialState +#define SDL_JoystickGetBall SDL_JoystickGetBall_renamed_SDL_GetJoystickBall +#define SDL_JoystickGetButton SDL_JoystickGetButton_renamed_SDL_GetJoystickButton +#define SDL_JoystickGetFirmwareVersion SDL_JoystickGetFirmwareVersion_renamed_SDL_GetJoystickFirmwareVersion +#define SDL_JoystickGetGUID SDL_JoystickGetGUID_renamed_SDL_GetJoystickGUID +#define SDL_JoystickGetGUIDFromString SDL_JoystickGetGUIDFromString_renamed_SDL_GUIDFromString +#define SDL_JoystickGetHat SDL_JoystickGetHat_renamed_SDL_GetJoystickHat +#define SDL_JoystickGetPlayerIndex SDL_JoystickGetPlayerIndex_renamed_SDL_GetJoystickPlayerIndex +#define SDL_JoystickGetProduct SDL_JoystickGetProduct_renamed_SDL_GetJoystickProduct +#define SDL_JoystickGetProductVersion SDL_JoystickGetProductVersion_renamed_SDL_GetJoystickProductVersion +#define SDL_JoystickGetSerial SDL_JoystickGetSerial_renamed_SDL_GetJoystickSerial +#define SDL_JoystickGetType SDL_JoystickGetType_renamed_SDL_GetJoystickType +#define SDL_JoystickGetVendor SDL_JoystickGetVendor_renamed_SDL_GetJoystickVendor +#define SDL_JoystickInstanceID SDL_JoystickInstanceID_renamed_SDL_GetJoystickID +#define SDL_JoystickIsVirtual SDL_JoystickIsVirtual_renamed_SDL_IsJoystickVirtual +#define SDL_JoystickName SDL_JoystickName_renamed_SDL_GetJoystickName +#define SDL_JoystickNumAxes SDL_JoystickNumAxes_renamed_SDL_GetNumJoystickAxes +#define SDL_JoystickNumBalls SDL_JoystickNumBalls_renamed_SDL_GetNumJoystickBalls +#define SDL_JoystickNumButtons SDL_JoystickNumButtons_renamed_SDL_GetNumJoystickButtons +#define SDL_JoystickNumHats SDL_JoystickNumHats_renamed_SDL_GetNumJoystickHats +#define SDL_JoystickOpen SDL_JoystickOpen_renamed_SDL_OpenJoystick +#define SDL_JoystickPath SDL_JoystickPath_renamed_SDL_GetJoystickPath +#define SDL_JoystickRumble SDL_JoystickRumble_renamed_SDL_RumbleJoystick +#define SDL_JoystickRumbleTriggers SDL_JoystickRumbleTriggers_renamed_SDL_RumbleJoystickTriggers +#define SDL_JoystickSendEffect SDL_JoystickSendEffect_renamed_SDL_SendJoystickEffect +#define SDL_JoystickSetLED SDL_JoystickSetLED_renamed_SDL_SetJoystickLED +#define SDL_JoystickSetPlayerIndex SDL_JoystickSetPlayerIndex_renamed_SDL_SetJoystickPlayerIndex +#define SDL_JoystickSetVirtualAxis SDL_JoystickSetVirtualAxis_renamed_SDL_SetJoystickVirtualAxis +#define SDL_JoystickSetVirtualButton SDL_JoystickSetVirtualButton_renamed_SDL_SetJoystickVirtualButton +#define SDL_JoystickSetVirtualHat SDL_JoystickSetVirtualHat_renamed_SDL_SetJoystickVirtualHat +#define SDL_JoystickUpdate SDL_JoystickUpdate_renamed_SDL_UpdateJoysticks + +/* ##SDL_keyboard.h */ +#define SDL_IsScreenKeyboardShown SDL_IsScreenKeyboardShown_renamed_SDL_ScreenKeyboardShown +#define SDL_IsTextInputActive SDL_IsTextInputActive_renamed_SDL_TextInputActive + +/* ##SDL_keycode.h */ +#define KMOD_ALT KMOD_ALT_renamed_SDL_KMOD_ALT +#define KMOD_CAPS KMOD_CAPS_renamed_SDL_KMOD_CAPS +#define KMOD_CTRL KMOD_CTRL_renamed_SDL_KMOD_CTRL +#define KMOD_GUI KMOD_GUI_renamed_SDL_KMOD_GUI +#define KMOD_LALT KMOD_LALT_renamed_SDL_KMOD_LALT +#define KMOD_LCTRL KMOD_LCTRL_renamed_SDL_KMOD_LCTRL +#define KMOD_LGUI KMOD_LGUI_renamed_SDL_KMOD_LGUI +#define KMOD_LSHIFT KMOD_LSHIFT_renamed_SDL_KMOD_LSHIFT +#define KMOD_MODE KMOD_MODE_renamed_SDL_KMOD_MODE +#define KMOD_NONE KMOD_NONE_renamed_SDL_KMOD_NONE +#define KMOD_NUM KMOD_NUM_renamed_SDL_KMOD_NUM +#define KMOD_RALT KMOD_RALT_renamed_SDL_KMOD_RALT +#define KMOD_RCTRL KMOD_RCTRL_renamed_SDL_KMOD_RCTRL +#define KMOD_RGUI KMOD_RGUI_renamed_SDL_KMOD_RGUI +#define KMOD_RSHIFT KMOD_RSHIFT_renamed_SDL_KMOD_RSHIFT +#define KMOD_SCROLL KMOD_SCROLL_renamed_SDL_KMOD_SCROLL +#define KMOD_SHIFT KMOD_SHIFT_renamed_SDL_KMOD_SHIFT +#define SDLK_AUDIOFASTFORWARD SDLK_AUDIOFASTFORWARD_renamed_SDLK_MEDIA_FAST_FORWARD +#define SDLK_AUDIOMUTE SDLK_AUDIOMUTE_renamed_SDLK_MUTE +#define SDLK_AUDIONEXT SDLK_AUDIONEXT_renamed_SDLK_MEDIA_NEXT_TRACK +#define SDLK_AUDIOPLAY SDLK_AUDIOPLAY_renamed_SDLK_MEDIA_PLAY +#define SDLK_AUDIOPREV SDLK_AUDIOPREV_renamed_SDLK_MEDIA_PREVIOUS_TRACK +#define SDLK_AUDIOREWIND SDLK_AUDIOREWIND_renamed_SDLK_MEDIA_REWIND +#define SDLK_AUDIOSTOP SDLK_AUDIOSTOP_renamed_SDLK_MEDIA_STOP +#define SDLK_BACKQUOTE SDLK_BACKQUOTE_renamed_SDLK_GRAVE +#define SDLK_EJECT SDLK_EJECT_renamed_SDLK_MEDIA_EJECT +#define SDLK_MEDIASELECT SDLK_MEDIASELECT_renamed_SDLK_MEDIA_SELECT +#define SDLK_QUOTE SDLK_QUOTE_renamed_SDLK_APOSTROPHE +#define SDLK_QUOTEDBL SDLK_QUOTEDBL_renamed_SDLK_DBLAPOSTROPHE +#define SDLK_a SDLK_a_renamed_SDLK_A +#define SDLK_b SDLK_b_renamed_SDLK_B +#define SDLK_c SDLK_c_renamed_SDLK_C +#define SDLK_d SDLK_d_renamed_SDLK_D +#define SDLK_e SDLK_e_renamed_SDLK_E +#define SDLK_f SDLK_f_renamed_SDLK_F +#define SDLK_g SDLK_g_renamed_SDLK_G +#define SDLK_h SDLK_h_renamed_SDLK_H +#define SDLK_i SDLK_i_renamed_SDLK_I +#define SDLK_j SDLK_j_renamed_SDLK_J +#define SDLK_k SDLK_k_renamed_SDLK_K +#define SDLK_l SDLK_l_renamed_SDLK_L +#define SDLK_m SDLK_m_renamed_SDLK_M +#define SDLK_n SDLK_n_renamed_SDLK_N +#define SDLK_o SDLK_o_renamed_SDLK_O +#define SDLK_p SDLK_p_renamed_SDLK_P +#define SDLK_q SDLK_q_renamed_SDLK_Q +#define SDLK_r SDLK_r_renamed_SDLK_R +#define SDLK_s SDLK_s_renamed_SDLK_S +#define SDLK_t SDLK_t_renamed_SDLK_T +#define SDLK_u SDLK_u_renamed_SDLK_U +#define SDLK_v SDLK_v_renamed_SDLK_V +#define SDLK_w SDLK_w_renamed_SDLK_W +#define SDLK_x SDLK_x_renamed_SDLK_X +#define SDLK_y SDLK_y_renamed_SDLK_Y +#define SDLK_z SDLK_z_renamed_SDLK_Z + +/* ##SDL_log.h */ +#define SDL_LogGetOutputFunction SDL_LogGetOutputFunction_renamed_SDL_GetLogOutputFunction +#define SDL_LogGetPriority SDL_LogGetPriority_renamed_SDL_GetLogPriority +#define SDL_LogResetPriorities SDL_LogResetPriorities_renamed_SDL_ResetLogPriorities +#define SDL_LogSetAllPriority SDL_LogSetAllPriority_renamed_SDL_SetLogPriorities +#define SDL_LogSetOutputFunction SDL_LogSetOutputFunction_renamed_SDL_SetLogOutputFunction +#define SDL_LogSetPriority SDL_LogSetPriority_renamed_SDL_SetLogPriority +#define SDL_NUM_LOG_PRIORITIES SDL_NUM_LOG_PRIORITIES_renamed_SDL_LOG_PRIORITY_COUNT + +/* ##SDL_messagebox.h */ +#define SDL_MESSAGEBOX_COLOR_MAX SDL_MESSAGEBOX_COLOR_MAX_renamed_SDL_MESSAGEBOX_COLOR_COUNT + +/* ##SDL_mouse.h */ +#define SDL_BUTTON SDL_BUTTON_renamed_SDL_BUTTON_MASK +#define SDL_FreeCursor SDL_FreeCursor_renamed_SDL_DestroyCursor +#define SDL_NUM_SYSTEM_CURSORS SDL_NUM_SYSTEM_CURSORS_renamed_SDL_SYSTEM_CURSOR_COUNT +#define SDL_SYSTEM_CURSOR_ARROW SDL_SYSTEM_CURSOR_ARROW_renamed_SDL_SYSTEM_CURSOR_DEFAULT +#define SDL_SYSTEM_CURSOR_HAND SDL_SYSTEM_CURSOR_HAND_renamed_SDL_SYSTEM_CURSOR_POINTER +#define SDL_SYSTEM_CURSOR_IBEAM SDL_SYSTEM_CURSOR_IBEAM_renamed_SDL_SYSTEM_CURSOR_TEXT +#define SDL_SYSTEM_CURSOR_NO SDL_SYSTEM_CURSOR_NO_renamed_SDL_SYSTEM_CURSOR_NOT_ALLOWED +#define SDL_SYSTEM_CURSOR_SIZEALL SDL_SYSTEM_CURSOR_SIZEALL_renamed_SDL_SYSTEM_CURSOR_MOVE +#define SDL_SYSTEM_CURSOR_SIZENESW SDL_SYSTEM_CURSOR_SIZENESW_renamed_SDL_SYSTEM_CURSOR_NESW_RESIZE +#define SDL_SYSTEM_CURSOR_SIZENS SDL_SYSTEM_CURSOR_SIZENS_renamed_SDL_SYSTEM_CURSOR_NS_RESIZE +#define SDL_SYSTEM_CURSOR_SIZENWSE SDL_SYSTEM_CURSOR_SIZENWSE_renamed_SDL_SYSTEM_CURSOR_NWSE_RESIZE +#define SDL_SYSTEM_CURSOR_SIZEWE SDL_SYSTEM_CURSOR_SIZEWE_renamed_SDL_SYSTEM_CURSOR_EW_RESIZE +#define SDL_SYSTEM_CURSOR_WAITARROW SDL_SYSTEM_CURSOR_WAITARROW_renamed_SDL_SYSTEM_CURSOR_PROGRESS +#define SDL_SYSTEM_CURSOR_WINDOW_BOTTOM SDL_SYSTEM_CURSOR_WINDOW_BOTTOM_renamed_SDL_SYSTEM_CURSOR_S_RESIZE +#define SDL_SYSTEM_CURSOR_WINDOW_BOTTOMLEFT SDL_SYSTEM_CURSOR_WINDOW_BOTTOMLEFT_renamed_SDL_SYSTEM_CURSOR_SW_RESIZE +#define SDL_SYSTEM_CURSOR_WINDOW_BOTTOMRIGHT SDL_SYSTEM_CURSOR_WINDOW_BOTTOMRIGHT_renamed_SDL_SYSTEM_CURSOR_SE_RESIZE +#define SDL_SYSTEM_CURSOR_WINDOW_LEFT SDL_SYSTEM_CURSOR_WINDOW_LEFT_renamed_SDL_SYSTEM_CURSOR_W_RESIZE +#define SDL_SYSTEM_CURSOR_WINDOW_RIGHT SDL_SYSTEM_CURSOR_WINDOW_RIGHT_renamed_SDL_SYSTEM_CURSOR_E_RESIZE +#define SDL_SYSTEM_CURSOR_WINDOW_TOP SDL_SYSTEM_CURSOR_WINDOW_TOP_renamed_SDL_SYSTEM_CURSOR_N_RESIZE +#define SDL_SYSTEM_CURSOR_WINDOW_TOPLEFT SDL_SYSTEM_CURSOR_WINDOW_TOPLEFT_renamed_SDL_SYSTEM_CURSOR_NW_RESIZE +#define SDL_SYSTEM_CURSOR_WINDOW_TOPRIGHT SDL_SYSTEM_CURSOR_WINDOW_TOPRIGHT_renamed_SDL_SYSTEM_CURSOR_NE_RESIZE + +/* ##SDL_mutex.h */ +#define SDL_CondBroadcast SDL_CondBroadcast_renamed_SDL_BroadcastCondition +#define SDL_CondSignal SDL_CondSignal_renamed_SDL_SignalCondition +#define SDL_CondWait SDL_CondWait_renamed_SDL_WaitCondition +#define SDL_CondWaitTimeout SDL_CondWaitTimeout_renamed_SDL_WaitConditionTimeout +#define SDL_CreateCond SDL_CreateCond_renamed_SDL_CreateCondition +#define SDL_DestroyCond SDL_DestroyCond_renamed_SDL_DestroyCondition +#define SDL_SemPost SDL_SemPost_renamed_SDL_SignalSemaphore +#define SDL_SemTryWait SDL_SemTryWait_renamed_SDL_TryWaitSemaphore +#define SDL_SemValue SDL_SemValue_renamed_SDL_GetSemaphoreValue +#define SDL_SemWait SDL_SemWait_renamed_SDL_WaitSemaphore +#define SDL_SemWaitTimeout SDL_SemWaitTimeout_renamed_SDL_WaitSemaphoreTimeout + +/* ##SDL_mutex.h */ +#define SDL_cond SDL_cond_renamed_SDL_Condition +#define SDL_mutex SDL_mutex_renamed_SDL_Mutex +#define SDL_sem SDL_sem_renamed_SDL_Semaphore + +/* ##SDL_pixels.h */ +#define SDL_AllocFormat SDL_AllocFormat_renamed_SDL_GetPixelFormatDetails +#define SDL_AllocPalette SDL_AllocPalette_renamed_SDL_CreatePalette +#define SDL_Colour SDL_Colour_renamed_SDL_Color +#define SDL_FreePalette SDL_FreePalette_renamed_SDL_DestroyPalette +#define SDL_MasksToPixelFormatEnum SDL_MasksToPixelFormatEnum_renamed_SDL_GetPixelFormatForMasks +#define SDL_PIXELFORMAT_BGR444 SDL_PIXELFORMAT_BGR444_renamed_SDL_PIXELFORMAT_XBGR4444 +#define SDL_PIXELFORMAT_BGR555 SDL_PIXELFORMAT_BGR555_renamed_SDL_PIXELFORMAT_XBGR1555 +#define SDL_PIXELFORMAT_BGR888 SDL_PIXELFORMAT_BGR888_renamed_SDL_PIXELFORMAT_XBGR8888 +#define SDL_PIXELFORMAT_RGB444 SDL_PIXELFORMAT_RGB444_renamed_SDL_PIXELFORMAT_XRGB4444 +#define SDL_PIXELFORMAT_RGB555 SDL_PIXELFORMAT_RGB555_renamed_SDL_PIXELFORMAT_XRGB1555 +#define SDL_PIXELFORMAT_RGB888 SDL_PIXELFORMAT_RGB888_renamed_SDL_PIXELFORMAT_XRGB8888 +#define SDL_PixelFormatEnumToMasks SDL_PixelFormatEnumToMasks_renamed_SDL_GetMasksForPixelFormat + +/* ##SDL_rect.h */ +#define SDL_EncloseFPoints SDL_EncloseFPoints_renamed_SDL_GetRectEnclosingPointsFloat +#define SDL_EnclosePoints SDL_EnclosePoints_renamed_SDL_GetRectEnclosingPoints +#define SDL_FRectEmpty SDL_FRectEmpty_renamed_SDL_RectEmptyFloat +#define SDL_FRectEquals SDL_FRectEquals_renamed_SDL_RectsEqualFloat +#define SDL_FRectEqualsEpsilon SDL_FRectEqualsEpsilon_renamed_SDL_RectsEqualEpsilon +#define SDL_HasIntersection SDL_HasIntersection_renamed_SDL_HasRectIntersection +#define SDL_HasIntersectionF SDL_HasIntersectionF_renamed_SDL_HasRectIntersectionFloat +#define SDL_IntersectFRect SDL_IntersectFRect_renamed_SDL_GetRectIntersectionFloat +#define SDL_IntersectFRectAndLine SDL_IntersectFRectAndLine_renamed_SDL_GetRectAndLineIntersectionFloat +#define SDL_IntersectRect SDL_IntersectRect_renamed_SDL_GetRectIntersection +#define SDL_IntersectRectAndLine SDL_IntersectRectAndLine_renamed_SDL_GetRectAndLineIntersection +#define SDL_PointInFRect SDL_PointInFRect_renamed_SDL_PointInRectFloat +#define SDL_RectEquals SDL_RectEquals_renamed_SDL_RectsEqual +#define SDL_UnionFRect SDL_UnionFRect_renamed_SDL_GetRectUnionFloat +#define SDL_UnionRect SDL_UnionRect_renamed_SDL_GetRectUnion + +/* ##SDL_render.h */ +#define SDL_GetRendererOutputSize SDL_GetRendererOutputSize_renamed_SDL_GetCurrentRenderOutputSize +#define SDL_RenderCopy SDL_RenderCopy_renamed_SDL_RenderTexture +#define SDL_RenderCopyEx SDL_RenderCopyEx_renamed_SDL_RenderTextureRotated +#define SDL_RenderCopyExF SDL_RenderCopyExF_renamed_SDL_RenderTextureRotated +#define SDL_RenderCopyF SDL_RenderCopyF_renamed_SDL_RenderTexture +#define SDL_RenderDrawLine SDL_RenderDrawLine_renamed_SDL_RenderLine +#define SDL_RenderDrawLineF SDL_RenderDrawLineF_renamed_SDL_RenderLine +#define SDL_RenderDrawLines SDL_RenderDrawLines_renamed_SDL_RenderLines +#define SDL_RenderDrawLinesF SDL_RenderDrawLinesF_renamed_SDL_RenderLines +#define SDL_RenderDrawPoint SDL_RenderDrawPoint_renamed_SDL_RenderPoint +#define SDL_RenderDrawPointF SDL_RenderDrawPointF_renamed_SDL_RenderPoint +#define SDL_RenderDrawPoints SDL_RenderDrawPoints_renamed_SDL_RenderPoints +#define SDL_RenderDrawPointsF SDL_RenderDrawPointsF_renamed_SDL_RenderPoints +#define SDL_RenderDrawRect SDL_RenderDrawRect_renamed_SDL_RenderRect +#define SDL_RenderDrawRectF SDL_RenderDrawRectF_renamed_SDL_RenderRect +#define SDL_RenderDrawRects SDL_RenderDrawRects_renamed_SDL_RenderRects +#define SDL_RenderDrawRectsF SDL_RenderDrawRectsF_renamed_SDL_RenderRects +#define SDL_RenderFillRectF SDL_RenderFillRectF_renamed_SDL_RenderFillRect +#define SDL_RenderFillRectsF SDL_RenderFillRectsF_renamed_SDL_RenderFillRects +#define SDL_RendererFlip SDL_RendererFlip_renamed_SDL_FlipMode +#define SDL_RenderFlush SDL_RenderFlush_renamed_SDL_FlushRenderer +#define SDL_RenderGetClipRect SDL_RenderGetClipRect_renamed_SDL_GetRenderClipRect +#define SDL_RenderGetLogicalSize SDL_RenderGetLogicalSize_renamed_SDL_GetRenderLogicalPresentation +#define SDL_RenderGetMetalCommandEncoder SDL_RenderGetMetalCommandEncoder_renamed_SDL_GetRenderMetalCommandEncoder +#define SDL_RenderGetMetalLayer SDL_RenderGetMetalLayer_renamed_SDL_GetRenderMetalLayer +#define SDL_RenderGetScale SDL_RenderGetScale_renamed_SDL_GetRenderScale +#define SDL_RenderGetViewport SDL_RenderGetViewport_renamed_SDL_GetRenderViewport +#define SDL_RenderGetWindow SDL_RenderGetWindow_renamed_SDL_GetRenderWindow +#define SDL_RenderIsClipEnabled SDL_RenderIsClipEnabled_renamed_SDL_RenderClipEnabled +#define SDL_RenderLogicalToWindow SDL_RenderLogicalToWindow_renamed_SDL_RenderCoordinatesToWindow +#define SDL_RenderSetClipRect SDL_RenderSetClipRect_renamed_SDL_SetRenderClipRect +#define SDL_RenderSetLogicalSize SDL_RenderSetLogicalSize_renamed_SDL_SetRenderLogicalPresentation +#define SDL_RenderSetScale SDL_RenderSetScale_renamed_SDL_SetRenderScale +#define SDL_RenderSetVSync SDL_RenderSetVSync_renamed_SDL_SetRenderVSync +#define SDL_RenderSetViewport SDL_RenderSetViewport_renamed_SDL_SetRenderViewport +#define SDL_RenderWindowToLogical SDL_RenderWindowToLogical_renamed_SDL_RenderCoordinatesFromWindow +#define SDL_ScaleModeLinear SDL_ScaleModeLinear_renamed_SDL_SCALEMODE_LINEAR +#define SDL_ScaleModeNearest SDL_ScaleModeNearest_renamed_SDL_SCALEMODE_NEAREST + +/* ##SDL_rwops.h */ +#define RW_SEEK_CUR RW_SEEK_CUR_renamed_SDL_IO_SEEK_CUR +#define RW_SEEK_END RW_SEEK_END_renamed_SDL_IO_SEEK_END +#define RW_SEEK_SET RW_SEEK_SET_renamed_SDL_IO_SEEK_SET +#define SDL_RWFromConstMem SDL_RWFromConstMem_renamed_SDL_IOFromConstMem +#define SDL_RWFromFile SDL_RWFromFile_renamed_SDL_IOFromFile +#define SDL_RWFromMem SDL_RWFromMem_renamed_SDL_IOFromMem +#define SDL_RWclose SDL_RWclose_renamed_SDL_CloseIO +#define SDL_RWops SDL_RWops_renamed_SDL_IOStream +#define SDL_RWread SDL_RWread_renamed_SDL_ReadIO +#define SDL_RWseek SDL_RWseek_renamed_SDL_SeekIO +#define SDL_RWsize SDL_RWsize_renamed_SDL_GetIOSize +#define SDL_RWtell SDL_RWtell_renamed_SDL_TellIO +#define SDL_RWwrite SDL_RWwrite_renamed_SDL_WriteIO +#define SDL_ReadBE16 SDL_ReadBE16_renamed_SDL_ReadU16BE +#define SDL_ReadBE32 SDL_ReadBE32_renamed_SDL_ReadU32BE +#define SDL_ReadBE64 SDL_ReadBE64_renamed_SDL_ReadU64BE +#define SDL_ReadLE16 SDL_ReadLE16_renamed_SDL_ReadU16LE +#define SDL_ReadLE32 SDL_ReadLE32_renamed_SDL_ReadU32LE +#define SDL_ReadLE64 SDL_ReadLE64_renamed_SDL_ReadU64LE +#define SDL_WriteBE16 SDL_WriteBE16_renamed_SDL_WriteU16BE +#define SDL_WriteBE32 SDL_WriteBE32_renamed_SDL_WriteU32BE +#define SDL_WriteBE64 SDL_WriteBE64_renamed_SDL_WriteU64BE +#define SDL_WriteLE16 SDL_WriteLE16_renamed_SDL_WriteU16LE +#define SDL_WriteLE32 SDL_WriteLE32_renamed_SDL_WriteU32LE +#define SDL_WriteLE64 SDL_WriteLE64_renamed_SDL_WriteU64LE + +/* ##SDL_scancode.h */ +#define SDL_NUM_SCANCODES SDL_NUM_SCANCODES_renamed_SDL_SCANCODE_COUNT +#define SDL_SCANCODE_AUDIOFASTFORWARD SDL_SCANCODE_AUDIOFASTFORWARD_renamed_SDL_SCANCODE_MEDIA_FAST_FORWARD +#define SDL_SCANCODE_AUDIOMUTE SDL_SCANCODE_AUDIOMUTE_renamed_SDL_SCANCODE_MUTE +#define SDL_SCANCODE_AUDIONEXT SDL_SCANCODE_AUDIONEXT_renamed_SDL_SCANCODE_MEDIA_NEXT_TRACK +#define SDL_SCANCODE_AUDIOPLAY SDL_SCANCODE_AUDIOPLAY_renamed_SDL_SCANCODE_MEDIA_PLAY +#define SDL_SCANCODE_AUDIOPREV SDL_SCANCODE_AUDIOPREV_renamed_SDL_SCANCODE_MEDIA_PREVIOUS_TRACK +#define SDL_SCANCODE_AUDIOREWIND SDL_SCANCODE_AUDIOREWIND_renamed_SDL_SCANCODE_MEDIA_REWIND +#define SDL_SCANCODE_AUDIOSTOP SDL_SCANCODE_AUDIOSTOP_renamed_SDL_SCANCODE_MEDIA_STOP +#define SDL_SCANCODE_EJECT SDL_SCANCODE_EJECT_renamed_SDL_SCANCODE_MEDIA_EJECT +#define SDL_SCANCODE_MEDIASELECT SDL_SCANCODE_MEDIASELECT_renamed_SDL_SCANCODE_MEDIA_SELECT + +/* ##SDL_sensor.h */ +#define SDL_SensorClose SDL_SensorClose_renamed_SDL_CloseSensor +#define SDL_SensorFromInstanceID SDL_SensorFromInstanceID_renamed_SDL_GetSensorFromID +#define SDL_SensorGetData SDL_SensorGetData_renamed_SDL_GetSensorData +#define SDL_SensorGetInstanceID SDL_SensorGetInstanceID_renamed_SDL_GetSensorID +#define SDL_SensorGetName SDL_SensorGetName_renamed_SDL_GetSensorName +#define SDL_SensorGetNonPortableType SDL_SensorGetNonPortableType_renamed_SDL_GetSensorNonPortableType +#define SDL_SensorGetType SDL_SensorGetType_renamed_SDL_GetSensorType +#define SDL_SensorOpen SDL_SensorOpen_renamed_SDL_OpenSensor +#define SDL_SensorUpdate SDL_SensorUpdate_renamed_SDL_UpdateSensors + +/* ##SDL_stdinc.h */ +#define SDL_FALSE SDL_FALSE_renamed_false +#define SDL_TABLESIZE SDL_TABLESIZE_renamed_SDL_arraysize +#define SDL_TRUE SDL_TRUE_renamed_true +#define SDL_bool SDL_bool_renamed_bool +#define SDL_size_add_overflow SDL_size_add_overflow_renamed_SDL_size_add_check_overflow +#define SDL_size_mul_overflow SDL_size_mul_overflow_renamed_SDL_size_mul_check_overflow +#define SDL_strtokr SDL_strtokr_renamed_SDL_strtok_r + +/* ##SDL_surface.h */ +#define SDL_BlitScaled SDL_BlitScaled_renamed_SDL_BlitSurfaceScaled +#define SDL_ConvertSurfaceFormat SDL_ConvertSurfaceFormat_renamed_SDL_ConvertSurface +#define SDL_FillRect SDL_FillRect_renamed_SDL_FillSurfaceRect +#define SDL_FillRects SDL_FillRects_renamed_SDL_FillSurfaceRects +#define SDL_FreeSurface SDL_FreeSurface_renamed_SDL_DestroySurface +#define SDL_GetClipRect SDL_GetClipRect_renamed_SDL_GetSurfaceClipRect +#define SDL_GetColorKey SDL_GetColorKey_renamed_SDL_GetSurfaceColorKey +#define SDL_HasColorKey SDL_HasColorKey_renamed_SDL_SurfaceHasColorKey +#define SDL_HasSurfaceRLE SDL_HasSurfaceRLE_renamed_SDL_SurfaceHasRLE +#define SDL_LoadBMP_RW SDL_LoadBMP_RW_renamed_SDL_LoadBMP_IO +#define SDL_LowerBlit SDL_LowerBlit_renamed_SDL_BlitSurfaceUnchecked +#define SDL_LowerBlitScaled SDL_LowerBlitScaled_renamed_SDL_BlitSurfaceUncheckedScaled +#define SDL_PREALLOC SDL_PREALLOC_renamed_SDL_SURFACE_PREALLOCATED +#define SDL_SIMD_ALIGNED SDL_SIMD_ALIGNED_renamed_SDL_SURFACE_SIMD_ALIGNED +#define SDL_SaveBMP_RW SDL_SaveBMP_RW_renamed_SDL_SaveBMP_IO +#define SDL_SetClipRect SDL_SetClipRect_renamed_SDL_SetSurfaceClipRect +#define SDL_SetColorKey SDL_SetColorKey_renamed_SDL_SetSurfaceColorKey +#define SDL_UpperBlit SDL_UpperBlit_renamed_SDL_BlitSurface +#define SDL_UpperBlitScaled SDL_UpperBlitScaled_renamed_SDL_BlitSurfaceScaled + +/* ##SDL_system.h */ +#define SDL_AndroidBackButton SDL_AndroidBackButton_renamed_SDL_SendAndroidBackButton +#define SDL_AndroidGetActivity SDL_AndroidGetActivity_renamed_SDL_GetAndroidActivity +#define SDL_AndroidGetExternalStoragePath SDL_AndroidGetExternalStoragePath_renamed_SDL_GetAndroidExternalStoragePath +#define SDL_AndroidGetExternalStorageState SDL_AndroidGetExternalStorageState_renamed_SDL_GetAndroidExternalStorageState +#define SDL_AndroidGetInternalStoragePath SDL_AndroidGetInternalStoragePath_renamed_SDL_GetAndroidInternalStoragePath +#define SDL_AndroidGetJNIEnv SDL_AndroidGetJNIEnv_renamed_SDL_GetAndroidJNIEnv +#define SDL_AndroidRequestPermission SDL_AndroidRequestPermission_renamed_SDL_RequestAndroidPermission +#define SDL_AndroidRequestPermissionCallback SDL_AndroidRequestPermissionCallback_renamed_SDL_RequestAndroidPermissionCallback +#define SDL_AndroidSendMessage SDL_AndroidSendMessage_renamed_SDL_SendAndroidMessage +#define SDL_AndroidShowToast SDL_AndroidShowToast_renamed_SDL_ShowAndroidToast +#define SDL_DXGIGetOutputInfo SDL_DXGIGetOutputInfo_renamed_SDL_GetDXGIOutputInfo +#define SDL_Direct3D9GetAdapterIndex SDL_Direct3D9GetAdapterIndex_renamed_SDL_GetDirect3D9AdapterIndex +#define SDL_GDKGetDefaultUser SDL_GDKGetDefaultUser_renamed_SDL_GetGDKDefaultUser +#define SDL_GDKGetTaskQueue SDL_GDKGetTaskQueue_renamed_SDL_GetGDKTaskQueue +#define SDL_LinuxSetThreadPriority SDL_LinuxSetThreadPriority_renamed_SDL_SetLinuxThreadPriority +#define SDL_LinuxSetThreadPriorityAndPolicy SDL_LinuxSetThreadPriorityAndPolicy_renamed_SDL_SetLinuxThreadPriorityAndPolicy +#define SDL_OnApplicationDidBecomeActive SDL_OnApplicationDidBecomeActive_renamed_SDL_OnApplicationDidEnterForeground +#define SDL_OnApplicationWillResignActive SDL_OnApplicationWillResignActive_renamed_SDL_OnApplicationWillEnterBackground +#define SDL_iOSSetAnimationCallback SDL_iOSSetAnimationCallback_renamed_SDL_SetiOSAnimationCallback +#define SDL_iOSSetEventPump SDL_iOSSetEventPump_renamed_SDL_SetiOSEventPump +#define SDL_iPhoneSetAnimationCallback SDL_iPhoneSetAnimationCallback_renamed_SDL_iOSSetAnimationCallback +#define SDL_iPhoneSetEventPump SDL_iPhoneSetEventPump_renamed_SDL_iOSSetEventPump + +/* ##SDL_thread.h */ +#define SDL_SetThreadPriority SDL_SetThreadPriority_renamed_SDL_SetCurrentThreadPriority +#define SDL_TLSCleanup SDL_TLSCleanup_renamed_SDL_CleanupTLS +#define SDL_TLSGet SDL_TLSGet_renamed_SDL_GetTLS +#define SDL_TLSSet SDL_TLSSet_renamed_SDL_SetTLS +#define SDL_threadID SDL_threadID_renamed_SDL_ThreadID + +/* ##SDL_timer.h */ +#define SDL_GetTicks64 SDL_GetTicks64_renamed_SDL_GetTicks + +/* ##SDL_version.h */ +#define SDL_COMPILEDVERSION SDL_COMPILEDVERSION_renamed_SDL_VERSION +#define SDL_PATCHLEVEL SDL_PATCHLEVEL_renamed_SDL_MICRO_VERSION + +/* ##SDL_video.h */ +#define SDL_GL_DeleteContext SDL_GL_DeleteContext_renamed_SDL_GL_DestroyContext +#define SDL_GLattr SDL_GLattr_renamed_SDL_GLAttr +#define SDL_GLcontextFlag SDL_GLcontextFlag_renamed_SDL_GLContextFlag +#define SDL_GLcontextReleaseFlag SDL_GLcontextReleaseFlag_renamed_SDL_GLContextReleaseFlag +#define SDL_GLprofile SDL_GLprofile_renamed_SDL_GLProfile +#define SDL_GetClosestDisplayMode SDL_GetClosestDisplayMode_renamed_SDL_GetClosestFullscreenDisplayMode +#define SDL_GetDisplayOrientation SDL_GetDisplayOrientation_renamed_SDL_GetCurrentDisplayOrientation +#define SDL_GetPointDisplayIndex SDL_GetPointDisplayIndex_renamed_SDL_GetDisplayForPoint +#define SDL_GetRectDisplayIndex SDL_GetRectDisplayIndex_renamed_SDL_GetDisplayForRect +#define SDL_GetWindowDisplayIndex SDL_GetWindowDisplayIndex_renamed_SDL_GetDisplayForWindow +#define SDL_GetWindowDisplayMode SDL_GetWindowDisplayMode_renamed_SDL_GetWindowFullscreenMode +#define SDL_HasWindowSurface SDL_HasWindowSurface_renamed_SDL_WindowHasSurface +#define SDL_IsScreenSaverEnabled SDL_IsScreenSaverEnabled_renamed_SDL_ScreenSaverEnabled +#define SDL_SetWindowDisplayMode SDL_SetWindowDisplayMode_renamed_SDL_SetWindowFullscreenMode +#define SDL_WINDOW_ALLOW_HIGHDPI SDL_WINDOW_ALLOW_HIGHDPI_renamed_SDL_WINDOW_HIGH_PIXEL_DENSITY +#define SDL_WINDOW_INPUT_GRABBED SDL_WINDOW_INPUT_GRABBED_renamed_SDL_WINDOW_MOUSE_GRABBED +#define SDL_WINDOW_SKIP_TASKBAR SDL_WINDOW_SKIP_TASKBAR_renamed_SDL_WINDOW_UTILITY + +#endif /* SDL_ENABLE_OLD_NAMES */ + +#endif /* SDL_oldnames_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_opengl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_opengl.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,3101 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* + * This is a simple file to encapsulate the OpenGL API headers. + * + * Define NO_SDL_GLEXT if you have your own version of glext.h and want + * to disable the version included in SDL_opengl.h. + */ + +#ifndef SDL_opengl_h_ +#define SDL_opengl_h_ + +#include + +#ifndef SDL_PLATFORM_IOS /* No OpenGL on iOS. */ + +/* + * Mesa 3-D graphics library + * + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef __gl_h_ +#define __gl_h_ + +#ifdef USE_MGL_NAMESPACE +#include +#endif + + +/********************************************************************** + * Begin system-specific stuff. + */ + +#if defined(_WIN32) && !defined(__CYGWIN__) +# if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(BUILD_GL32) /* tag specify we're building mesa as a DLL */ +# define GLAPI __declspec(dllexport) +# elif (defined(_MSC_VER) || defined(__MINGW32__)) && defined(_DLL) /* tag specifying we're building for DLL runtime support */ +# define GLAPI __declspec(dllimport) +# else /* for use with static link lib build of Win32 edition only */ +# define GLAPI extern +# endif /* _STATIC_MESA support */ +# if defined(__MINGW32__) && defined(GL_NO_STDCALL) || defined(UNDER_CE) /* The generated DLLs by MingW with STDCALL are not compatible with the ones done by Microsoft's compilers */ +# define GLAPIENTRY +# else +# define GLAPIENTRY __stdcall +# endif +#elif defined(__CYGWIN__) && defined(USE_OPENGL32) /* use native windows opengl32 */ +# define GLAPI extern +# define GLAPIENTRY __stdcall +#elif (defined(__GNUC__) && __GNUC__ >= 4) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) +# define GLAPI __attribute__((visibility("default"))) +# define GLAPIENTRY +#endif /* WIN32 && !CYGWIN */ + +/* + * WINDOWS: Include windows.h here to define APIENTRY. + * It is also useful when applications include this file by + * including only glut.h, since glut.h depends on windows.h. + * Applications needing to include windows.h with parms other + * than "WIN32_LEAN_AND_MEAN" may include windows.h before + * glut.h or gl.h. + */ +#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN 1 +#endif +#ifndef NOMINMAX /* don't define min() and max(). */ +#define NOMINMAX +#endif +#include +#endif + +#ifndef GLAPI +#define GLAPI extern +#endif + +#ifndef GLAPIENTRY +#define GLAPIENTRY +#endif + +#ifndef APIENTRY +#define APIENTRY GLAPIENTRY +#endif + +/* "P" suffix to be used for a pointer to a function */ +#ifndef APIENTRYP +#define APIENTRYP APIENTRY * +#endif + +#ifndef GLAPIENTRYP +#define GLAPIENTRYP GLAPIENTRY * +#endif + +#if defined(PRAGMA_EXPORT_SUPPORTED) +#pragma export on +#endif + +/* + * End system-specific stuff. + **********************************************************************/ + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +#define GL_VERSION_1_1 1 +#define GL_VERSION_1_2 1 +#define GL_VERSION_1_3 1 +#define GL_ARB_imaging 1 + + +/* + * Datatypes + */ +typedef unsigned int GLenum; +typedef unsigned char GLboolean; +typedef unsigned int GLbitfield; +typedef void GLvoid; +typedef signed char GLbyte; /* 1-byte signed */ +typedef short GLshort; /* 2-byte signed */ +typedef int GLint; /* 4-byte signed */ +typedef unsigned char GLubyte; /* 1-byte unsigned */ +typedef unsigned short GLushort; /* 2-byte unsigned */ +typedef unsigned int GLuint; /* 4-byte unsigned */ +typedef int GLsizei; /* 4-byte signed */ +typedef float GLfloat; /* single precision float */ +typedef float GLclampf; /* single precision float in [0,1] */ +typedef double GLdouble; /* double precision float */ +typedef double GLclampd; /* double precision float in [0,1] */ + + + +/* + * Constants + */ + +/* Boolean values */ +#define GL_FALSE 0 +#define GL_TRUE 1 + +/* Data types */ +#define GL_BYTE 0x1400 +#define GL_UNSIGNED_BYTE 0x1401 +#define GL_SHORT 0x1402 +#define GL_UNSIGNED_SHORT 0x1403 +#define GL_INT 0x1404 +#define GL_UNSIGNED_INT 0x1405 +#define GL_FLOAT 0x1406 +#define GL_2_BYTES 0x1407 +#define GL_3_BYTES 0x1408 +#define GL_4_BYTES 0x1409 +#define GL_DOUBLE 0x140A + +/* Primitives */ +#define GL_POINTS 0x0000 +#define GL_LINES 0x0001 +#define GL_LINE_LOOP 0x0002 +#define GL_LINE_STRIP 0x0003 +#define GL_TRIANGLES 0x0004 +#define GL_TRIANGLE_STRIP 0x0005 +#define GL_TRIANGLE_FAN 0x0006 +#define GL_QUADS 0x0007 +#define GL_QUAD_STRIP 0x0008 +#define GL_POLYGON 0x0009 + +/* Vertex Arrays */ +#define GL_VERTEX_ARRAY 0x8074 +#define GL_NORMAL_ARRAY 0x8075 +#define GL_COLOR_ARRAY 0x8076 +#define GL_INDEX_ARRAY 0x8077 +#define GL_TEXTURE_COORD_ARRAY 0x8078 +#define GL_EDGE_FLAG_ARRAY 0x8079 +#define GL_VERTEX_ARRAY_SIZE 0x807A +#define GL_VERTEX_ARRAY_TYPE 0x807B +#define GL_VERTEX_ARRAY_STRIDE 0x807C +#define GL_NORMAL_ARRAY_TYPE 0x807E +#define GL_NORMAL_ARRAY_STRIDE 0x807F +#define GL_COLOR_ARRAY_SIZE 0x8081 +#define GL_COLOR_ARRAY_TYPE 0x8082 +#define GL_COLOR_ARRAY_STRIDE 0x8083 +#define GL_INDEX_ARRAY_TYPE 0x8085 +#define GL_INDEX_ARRAY_STRIDE 0x8086 +#define GL_TEXTURE_COORD_ARRAY_SIZE 0x8088 +#define GL_TEXTURE_COORD_ARRAY_TYPE 0x8089 +#define GL_TEXTURE_COORD_ARRAY_STRIDE 0x808A +#define GL_EDGE_FLAG_ARRAY_STRIDE 0x808C +#define GL_VERTEX_ARRAY_POINTER 0x808E +#define GL_NORMAL_ARRAY_POINTER 0x808F +#define GL_COLOR_ARRAY_POINTER 0x8090 +#define GL_INDEX_ARRAY_POINTER 0x8091 +#define GL_TEXTURE_COORD_ARRAY_POINTER 0x8092 +#define GL_EDGE_FLAG_ARRAY_POINTER 0x8093 +#define GL_V2F 0x2A20 +#define GL_V3F 0x2A21 +#define GL_C4UB_V2F 0x2A22 +#define GL_C4UB_V3F 0x2A23 +#define GL_C3F_V3F 0x2A24 +#define GL_N3F_V3F 0x2A25 +#define GL_C4F_N3F_V3F 0x2A26 +#define GL_T2F_V3F 0x2A27 +#define GL_T4F_V4F 0x2A28 +#define GL_T2F_C4UB_V3F 0x2A29 +#define GL_T2F_C3F_V3F 0x2A2A +#define GL_T2F_N3F_V3F 0x2A2B +#define GL_T2F_C4F_N3F_V3F 0x2A2C +#define GL_T4F_C4F_N3F_V4F 0x2A2D + +/* Matrix Mode */ +#define GL_MATRIX_MODE 0x0BA0 +#define GL_MODELVIEW 0x1700 +#define GL_PROJECTION 0x1701 +#define GL_TEXTURE 0x1702 + +/* Points */ +#define GL_POINT_SMOOTH 0x0B10 +#define GL_POINT_SIZE 0x0B11 +#define GL_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_POINT_SIZE_RANGE 0x0B12 + +/* Lines */ +#define GL_LINE_SMOOTH 0x0B20 +#define GL_LINE_STIPPLE 0x0B24 +#define GL_LINE_STIPPLE_PATTERN 0x0B25 +#define GL_LINE_STIPPLE_REPEAT 0x0B26 +#define GL_LINE_WIDTH 0x0B21 +#define GL_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_LINE_WIDTH_RANGE 0x0B22 + +/* Polygons */ +#define GL_POINT 0x1B00 +#define GL_LINE 0x1B01 +#define GL_FILL 0x1B02 +#define GL_CW 0x0900 +#define GL_CCW 0x0901 +#define GL_FRONT 0x0404 +#define GL_BACK 0x0405 +#define GL_POLYGON_MODE 0x0B40 +#define GL_POLYGON_SMOOTH 0x0B41 +#define GL_POLYGON_STIPPLE 0x0B42 +#define GL_EDGE_FLAG 0x0B43 +#define GL_CULL_FACE 0x0B44 +#define GL_CULL_FACE_MODE 0x0B45 +#define GL_FRONT_FACE 0x0B46 +#define GL_POLYGON_OFFSET_FACTOR 0x8038 +#define GL_POLYGON_OFFSET_UNITS 0x2A00 +#define GL_POLYGON_OFFSET_POINT 0x2A01 +#define GL_POLYGON_OFFSET_LINE 0x2A02 +#define GL_POLYGON_OFFSET_FILL 0x8037 + +/* Display Lists */ +#define GL_COMPILE 0x1300 +#define GL_COMPILE_AND_EXECUTE 0x1301 +#define GL_LIST_BASE 0x0B32 +#define GL_LIST_INDEX 0x0B33 +#define GL_LIST_MODE 0x0B30 + +/* Depth buffer */ +#define GL_NEVER 0x0200 +#define GL_LESS 0x0201 +#define GL_EQUAL 0x0202 +#define GL_LEQUAL 0x0203 +#define GL_GREATER 0x0204 +#define GL_NOTEQUAL 0x0205 +#define GL_GEQUAL 0x0206 +#define GL_ALWAYS 0x0207 +#define GL_DEPTH_TEST 0x0B71 +#define GL_DEPTH_BITS 0x0D56 +#define GL_DEPTH_CLEAR_VALUE 0x0B73 +#define GL_DEPTH_FUNC 0x0B74 +#define GL_DEPTH_RANGE 0x0B70 +#define GL_DEPTH_WRITEMASK 0x0B72 +#define GL_DEPTH_COMPONENT 0x1902 + +/* Lighting */ +#define GL_LIGHTING 0x0B50 +#define GL_LIGHT0 0x4000 +#define GL_LIGHT1 0x4001 +#define GL_LIGHT2 0x4002 +#define GL_LIGHT3 0x4003 +#define GL_LIGHT4 0x4004 +#define GL_LIGHT5 0x4005 +#define GL_LIGHT6 0x4006 +#define GL_LIGHT7 0x4007 +#define GL_SPOT_EXPONENT 0x1205 +#define GL_SPOT_CUTOFF 0x1206 +#define GL_CONSTANT_ATTENUATION 0x1207 +#define GL_LINEAR_ATTENUATION 0x1208 +#define GL_QUADRATIC_ATTENUATION 0x1209 +#define GL_AMBIENT 0x1200 +#define GL_DIFFUSE 0x1201 +#define GL_SPECULAR 0x1202 +#define GL_SHININESS 0x1601 +#define GL_EMISSION 0x1600 +#define GL_POSITION 0x1203 +#define GL_SPOT_DIRECTION 0x1204 +#define GL_AMBIENT_AND_DIFFUSE 0x1602 +#define GL_COLOR_INDEXES 0x1603 +#define GL_LIGHT_MODEL_TWO_SIDE 0x0B52 +#define GL_LIGHT_MODEL_LOCAL_VIEWER 0x0B51 +#define GL_LIGHT_MODEL_AMBIENT 0x0B53 +#define GL_FRONT_AND_BACK 0x0408 +#define GL_SHADE_MODEL 0x0B54 +#define GL_FLAT 0x1D00 +#define GL_SMOOTH 0x1D01 +#define GL_COLOR_MATERIAL 0x0B57 +#define GL_COLOR_MATERIAL_FACE 0x0B55 +#define GL_COLOR_MATERIAL_PARAMETER 0x0B56 +#define GL_NORMALIZE 0x0BA1 + +/* User clipping planes */ +#define GL_CLIP_PLANE0 0x3000 +#define GL_CLIP_PLANE1 0x3001 +#define GL_CLIP_PLANE2 0x3002 +#define GL_CLIP_PLANE3 0x3003 +#define GL_CLIP_PLANE4 0x3004 +#define GL_CLIP_PLANE5 0x3005 + +/* Accumulation buffer */ +#define GL_ACCUM_RED_BITS 0x0D58 +#define GL_ACCUM_GREEN_BITS 0x0D59 +#define GL_ACCUM_BLUE_BITS 0x0D5A +#define GL_ACCUM_ALPHA_BITS 0x0D5B +#define GL_ACCUM_CLEAR_VALUE 0x0B80 +#define GL_ACCUM 0x0100 +#define GL_ADD 0x0104 +#define GL_LOAD 0x0101 +#define GL_MULT 0x0103 +#define GL_RETURN 0x0102 + +/* Alpha testing */ +#define GL_ALPHA_TEST 0x0BC0 +#define GL_ALPHA_TEST_REF 0x0BC2 +#define GL_ALPHA_TEST_FUNC 0x0BC1 + +/* Blending */ +#define GL_BLEND 0x0BE2 +#define GL_BLEND_SRC 0x0BE1 +#define GL_BLEND_DST 0x0BE0 +#define GL_ZERO 0 +#define GL_ONE 1 +#define GL_SRC_COLOR 0x0300 +#define GL_ONE_MINUS_SRC_COLOR 0x0301 +#define GL_SRC_ALPHA 0x0302 +#define GL_ONE_MINUS_SRC_ALPHA 0x0303 +#define GL_DST_ALPHA 0x0304 +#define GL_ONE_MINUS_DST_ALPHA 0x0305 +#define GL_DST_COLOR 0x0306 +#define GL_ONE_MINUS_DST_COLOR 0x0307 +#define GL_SRC_ALPHA_SATURATE 0x0308 + +/* Render Mode */ +#define GL_FEEDBACK 0x1C01 +#define GL_RENDER 0x1C00 +#define GL_SELECT 0x1C02 + +/* Feedback */ +#define GL_2D 0x0600 +#define GL_3D 0x0601 +#define GL_3D_COLOR 0x0602 +#define GL_3D_COLOR_TEXTURE 0x0603 +#define GL_4D_COLOR_TEXTURE 0x0604 +#define GL_POINT_TOKEN 0x0701 +#define GL_LINE_TOKEN 0x0702 +#define GL_LINE_RESET_TOKEN 0x0707 +#define GL_POLYGON_TOKEN 0x0703 +#define GL_BITMAP_TOKEN 0x0704 +#define GL_DRAW_PIXEL_TOKEN 0x0705 +#define GL_COPY_PIXEL_TOKEN 0x0706 +#define GL_PASS_THROUGH_TOKEN 0x0700 +#define GL_FEEDBACK_BUFFER_POINTER 0x0DF0 +#define GL_FEEDBACK_BUFFER_SIZE 0x0DF1 +#define GL_FEEDBACK_BUFFER_TYPE 0x0DF2 + +/* Selection */ +#define GL_SELECTION_BUFFER_POINTER 0x0DF3 +#define GL_SELECTION_BUFFER_SIZE 0x0DF4 + +/* Fog */ +#define GL_FOG 0x0B60 +#define GL_FOG_MODE 0x0B65 +#define GL_FOG_DENSITY 0x0B62 +#define GL_FOG_COLOR 0x0B66 +#define GL_FOG_INDEX 0x0B61 +#define GL_FOG_START 0x0B63 +#define GL_FOG_END 0x0B64 +#define GL_LINEAR 0x2601 +#define GL_EXP 0x0800 +#define GL_EXP2 0x0801 + +/* Logic Ops */ +#define GL_LOGIC_OP 0x0BF1 +#define GL_INDEX_LOGIC_OP 0x0BF1 +#define GL_COLOR_LOGIC_OP 0x0BF2 +#define GL_LOGIC_OP_MODE 0x0BF0 +#define GL_CLEAR 0x1500 +#define GL_SET 0x150F +#define GL_COPY 0x1503 +#define GL_COPY_INVERTED 0x150C +#define GL_NOOP 0x1505 +#define GL_INVERT 0x150A +#define GL_AND 0x1501 +#define GL_NAND 0x150E +#define GL_OR 0x1507 +#define GL_NOR 0x1508 +#define GL_XOR 0x1506 +#define GL_EQUIV 0x1509 +#define GL_AND_REVERSE 0x1502 +#define GL_AND_INVERTED 0x1504 +#define GL_OR_REVERSE 0x150B +#define GL_OR_INVERTED 0x150D + +/* Stencil */ +#define GL_STENCIL_BITS 0x0D57 +#define GL_STENCIL_TEST 0x0B90 +#define GL_STENCIL_CLEAR_VALUE 0x0B91 +#define GL_STENCIL_FUNC 0x0B92 +#define GL_STENCIL_VALUE_MASK 0x0B93 +#define GL_STENCIL_FAIL 0x0B94 +#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 +#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 +#define GL_STENCIL_REF 0x0B97 +#define GL_STENCIL_WRITEMASK 0x0B98 +#define GL_STENCIL_INDEX 0x1901 +#define GL_KEEP 0x1E00 +#define GL_REPLACE 0x1E01 +#define GL_INCR 0x1E02 +#define GL_DECR 0x1E03 + +/* Buffers, Pixel Drawing/Reading */ +#define GL_NONE 0 +#define GL_LEFT 0x0406 +#define GL_RIGHT 0x0407 +/*GL_FRONT 0x0404 */ +/*GL_BACK 0x0405 */ +/*GL_FRONT_AND_BACK 0x0408 */ +#define GL_FRONT_LEFT 0x0400 +#define GL_FRONT_RIGHT 0x0401 +#define GL_BACK_LEFT 0x0402 +#define GL_BACK_RIGHT 0x0403 +#define GL_AUX0 0x0409 +#define GL_AUX1 0x040A +#define GL_AUX2 0x040B +#define GL_AUX3 0x040C +#define GL_COLOR_INDEX 0x1900 +#define GL_RED 0x1903 +#define GL_GREEN 0x1904 +#define GL_BLUE 0x1905 +#define GL_ALPHA 0x1906 +#define GL_LUMINANCE 0x1909 +#define GL_LUMINANCE_ALPHA 0x190A +#define GL_ALPHA_BITS 0x0D55 +#define GL_RED_BITS 0x0D52 +#define GL_GREEN_BITS 0x0D53 +#define GL_BLUE_BITS 0x0D54 +#define GL_INDEX_BITS 0x0D51 +#define GL_SUBPIXEL_BITS 0x0D50 +#define GL_AUX_BUFFERS 0x0C00 +#define GL_READ_BUFFER 0x0C02 +#define GL_DRAW_BUFFER 0x0C01 +#define GL_DOUBLEBUFFER 0x0C32 +#define GL_STEREO 0x0C33 +#define GL_BITMAP 0x1A00 +#define GL_COLOR 0x1800 +#define GL_DEPTH 0x1801 +#define GL_STENCIL 0x1802 +#define GL_DITHER 0x0BD0 +#define GL_RGB 0x1907 +#define GL_RGBA 0x1908 + +/* Implementation limits */ +#define GL_MAX_LIST_NESTING 0x0B31 +#define GL_MAX_EVAL_ORDER 0x0D30 +#define GL_MAX_LIGHTS 0x0D31 +#define GL_MAX_CLIP_PLANES 0x0D32 +#define GL_MAX_TEXTURE_SIZE 0x0D33 +#define GL_MAX_PIXEL_MAP_TABLE 0x0D34 +#define GL_MAX_ATTRIB_STACK_DEPTH 0x0D35 +#define GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36 +#define GL_MAX_NAME_STACK_DEPTH 0x0D37 +#define GL_MAX_PROJECTION_STACK_DEPTH 0x0D38 +#define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39 +#define GL_MAX_VIEWPORT_DIMS 0x0D3A +#define GL_MAX_CLIENT_ATTRIB_STACK_DEPTH 0x0D3B + +/* Gets */ +#define GL_ATTRIB_STACK_DEPTH 0x0BB0 +#define GL_CLIENT_ATTRIB_STACK_DEPTH 0x0BB1 +#define GL_COLOR_CLEAR_VALUE 0x0C22 +#define GL_COLOR_WRITEMASK 0x0C23 +#define GL_CURRENT_INDEX 0x0B01 +#define GL_CURRENT_COLOR 0x0B00 +#define GL_CURRENT_NORMAL 0x0B02 +#define GL_CURRENT_RASTER_COLOR 0x0B04 +#define GL_CURRENT_RASTER_DISTANCE 0x0B09 +#define GL_CURRENT_RASTER_INDEX 0x0B05 +#define GL_CURRENT_RASTER_POSITION 0x0B07 +#define GL_CURRENT_RASTER_TEXTURE_COORDS 0x0B06 +#define GL_CURRENT_RASTER_POSITION_VALID 0x0B08 +#define GL_CURRENT_TEXTURE_COORDS 0x0B03 +#define GL_INDEX_CLEAR_VALUE 0x0C20 +#define GL_INDEX_MODE 0x0C30 +#define GL_INDEX_WRITEMASK 0x0C21 +#define GL_MODELVIEW_MATRIX 0x0BA6 +#define GL_MODELVIEW_STACK_DEPTH 0x0BA3 +#define GL_NAME_STACK_DEPTH 0x0D70 +#define GL_PROJECTION_MATRIX 0x0BA7 +#define GL_PROJECTION_STACK_DEPTH 0x0BA4 +#define GL_RENDER_MODE 0x0C40 +#define GL_RGBA_MODE 0x0C31 +#define GL_TEXTURE_MATRIX 0x0BA8 +#define GL_TEXTURE_STACK_DEPTH 0x0BA5 +#define GL_VIEWPORT 0x0BA2 + +/* Evaluators */ +#define GL_AUTO_NORMAL 0x0D80 +#define GL_MAP1_COLOR_4 0x0D90 +#define GL_MAP1_INDEX 0x0D91 +#define GL_MAP1_NORMAL 0x0D92 +#define GL_MAP1_TEXTURE_COORD_1 0x0D93 +#define GL_MAP1_TEXTURE_COORD_2 0x0D94 +#define GL_MAP1_TEXTURE_COORD_3 0x0D95 +#define GL_MAP1_TEXTURE_COORD_4 0x0D96 +#define GL_MAP1_VERTEX_3 0x0D97 +#define GL_MAP1_VERTEX_4 0x0D98 +#define GL_MAP2_COLOR_4 0x0DB0 +#define GL_MAP2_INDEX 0x0DB1 +#define GL_MAP2_NORMAL 0x0DB2 +#define GL_MAP2_TEXTURE_COORD_1 0x0DB3 +#define GL_MAP2_TEXTURE_COORD_2 0x0DB4 +#define GL_MAP2_TEXTURE_COORD_3 0x0DB5 +#define GL_MAP2_TEXTURE_COORD_4 0x0DB6 +#define GL_MAP2_VERTEX_3 0x0DB7 +#define GL_MAP2_VERTEX_4 0x0DB8 +#define GL_MAP1_GRID_DOMAIN 0x0DD0 +#define GL_MAP1_GRID_SEGMENTS 0x0DD1 +#define GL_MAP2_GRID_DOMAIN 0x0DD2 +#define GL_MAP2_GRID_SEGMENTS 0x0DD3 +#define GL_COEFF 0x0A00 +#define GL_ORDER 0x0A01 +#define GL_DOMAIN 0x0A02 + +/* Hints */ +#define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50 +#define GL_POINT_SMOOTH_HINT 0x0C51 +#define GL_LINE_SMOOTH_HINT 0x0C52 +#define GL_POLYGON_SMOOTH_HINT 0x0C53 +#define GL_FOG_HINT 0x0C54 +#define GL_DONT_CARE 0x1100 +#define GL_FASTEST 0x1101 +#define GL_NICEST 0x1102 + +/* Scissor box */ +#define GL_SCISSOR_BOX 0x0C10 +#define GL_SCISSOR_TEST 0x0C11 + +/* Pixel Mode / Transfer */ +#define GL_MAP_COLOR 0x0D10 +#define GL_MAP_STENCIL 0x0D11 +#define GL_INDEX_SHIFT 0x0D12 +#define GL_INDEX_OFFSET 0x0D13 +#define GL_RED_SCALE 0x0D14 +#define GL_RED_BIAS 0x0D15 +#define GL_GREEN_SCALE 0x0D18 +#define GL_GREEN_BIAS 0x0D19 +#define GL_BLUE_SCALE 0x0D1A +#define GL_BLUE_BIAS 0x0D1B +#define GL_ALPHA_SCALE 0x0D1C +#define GL_ALPHA_BIAS 0x0D1D +#define GL_DEPTH_SCALE 0x0D1E +#define GL_DEPTH_BIAS 0x0D1F +#define GL_PIXEL_MAP_S_TO_S_SIZE 0x0CB1 +#define GL_PIXEL_MAP_I_TO_I_SIZE 0x0CB0 +#define GL_PIXEL_MAP_I_TO_R_SIZE 0x0CB2 +#define GL_PIXEL_MAP_I_TO_G_SIZE 0x0CB3 +#define GL_PIXEL_MAP_I_TO_B_SIZE 0x0CB4 +#define GL_PIXEL_MAP_I_TO_A_SIZE 0x0CB5 +#define GL_PIXEL_MAP_R_TO_R_SIZE 0x0CB6 +#define GL_PIXEL_MAP_G_TO_G_SIZE 0x0CB7 +#define GL_PIXEL_MAP_B_TO_B_SIZE 0x0CB8 +#define GL_PIXEL_MAP_A_TO_A_SIZE 0x0CB9 +#define GL_PIXEL_MAP_S_TO_S 0x0C71 +#define GL_PIXEL_MAP_I_TO_I 0x0C70 +#define GL_PIXEL_MAP_I_TO_R 0x0C72 +#define GL_PIXEL_MAP_I_TO_G 0x0C73 +#define GL_PIXEL_MAP_I_TO_B 0x0C74 +#define GL_PIXEL_MAP_I_TO_A 0x0C75 +#define GL_PIXEL_MAP_R_TO_R 0x0C76 +#define GL_PIXEL_MAP_G_TO_G 0x0C77 +#define GL_PIXEL_MAP_B_TO_B 0x0C78 +#define GL_PIXEL_MAP_A_TO_A 0x0C79 +#define GL_PACK_ALIGNMENT 0x0D05 +#define GL_PACK_LSB_FIRST 0x0D01 +#define GL_PACK_ROW_LENGTH 0x0D02 +#define GL_PACK_SKIP_PIXELS 0x0D04 +#define GL_PACK_SKIP_ROWS 0x0D03 +#define GL_PACK_SWAP_BYTES 0x0D00 +#define GL_UNPACK_ALIGNMENT 0x0CF5 +#define GL_UNPACK_LSB_FIRST 0x0CF1 +#define GL_UNPACK_ROW_LENGTH 0x0CF2 +#define GL_UNPACK_SKIP_PIXELS 0x0CF4 +#define GL_UNPACK_SKIP_ROWS 0x0CF3 +#define GL_UNPACK_SWAP_BYTES 0x0CF0 +#define GL_ZOOM_X 0x0D16 +#define GL_ZOOM_Y 0x0D17 + +/* Texture mapping */ +#define GL_TEXTURE_ENV 0x2300 +#define GL_TEXTURE_ENV_MODE 0x2200 +#define GL_TEXTURE_1D 0x0DE0 +#define GL_TEXTURE_2D 0x0DE1 +#define GL_TEXTURE_WRAP_S 0x2802 +#define GL_TEXTURE_WRAP_T 0x2803 +#define GL_TEXTURE_MAG_FILTER 0x2800 +#define GL_TEXTURE_MIN_FILTER 0x2801 +#define GL_TEXTURE_ENV_COLOR 0x2201 +#define GL_TEXTURE_GEN_S 0x0C60 +#define GL_TEXTURE_GEN_T 0x0C61 +#define GL_TEXTURE_GEN_R 0x0C62 +#define GL_TEXTURE_GEN_Q 0x0C63 +#define GL_TEXTURE_GEN_MODE 0x2500 +#define GL_TEXTURE_BORDER_COLOR 0x1004 +#define GL_TEXTURE_WIDTH 0x1000 +#define GL_TEXTURE_HEIGHT 0x1001 +#define GL_TEXTURE_BORDER 0x1005 +#define GL_TEXTURE_COMPONENTS 0x1003 +#define GL_TEXTURE_RED_SIZE 0x805C +#define GL_TEXTURE_GREEN_SIZE 0x805D +#define GL_TEXTURE_BLUE_SIZE 0x805E +#define GL_TEXTURE_ALPHA_SIZE 0x805F +#define GL_TEXTURE_LUMINANCE_SIZE 0x8060 +#define GL_TEXTURE_INTENSITY_SIZE 0x8061 +#define GL_NEAREST_MIPMAP_NEAREST 0x2700 +#define GL_NEAREST_MIPMAP_LINEAR 0x2702 +#define GL_LINEAR_MIPMAP_NEAREST 0x2701 +#define GL_LINEAR_MIPMAP_LINEAR 0x2703 +#define GL_OBJECT_LINEAR 0x2401 +#define GL_OBJECT_PLANE 0x2501 +#define GL_EYE_LINEAR 0x2400 +#define GL_EYE_PLANE 0x2502 +#define GL_SPHERE_MAP 0x2402 +#define GL_DECAL 0x2101 +#define GL_MODULATE 0x2100 +#define GL_NEAREST 0x2600 +#define GL_REPEAT 0x2901 +#define GL_CLAMP 0x2900 +#define GL_S 0x2000 +#define GL_T 0x2001 +#define GL_R 0x2002 +#define GL_Q 0x2003 + +/* Utility */ +#define GL_VENDOR 0x1F00 +#define GL_RENDERER 0x1F01 +#define GL_VERSION 0x1F02 +#define GL_EXTENSIONS 0x1F03 + +/* Errors */ +#define GL_NO_ERROR 0 +#define GL_INVALID_ENUM 0x0500 +#define GL_INVALID_VALUE 0x0501 +#define GL_INVALID_OPERATION 0x0502 +#define GL_STACK_OVERFLOW 0x0503 +#define GL_STACK_UNDERFLOW 0x0504 +#define GL_OUT_OF_MEMORY 0x0505 + +/* glPush/PopAttrib bits */ +#define GL_CURRENT_BIT 0x00000001 +#define GL_POINT_BIT 0x00000002 +#define GL_LINE_BIT 0x00000004 +#define GL_POLYGON_BIT 0x00000008 +#define GL_POLYGON_STIPPLE_BIT 0x00000010 +#define GL_PIXEL_MODE_BIT 0x00000020 +#define GL_LIGHTING_BIT 0x00000040 +#define GL_FOG_BIT 0x00000080 +#define GL_DEPTH_BUFFER_BIT 0x00000100 +#define GL_ACCUM_BUFFER_BIT 0x00000200 +#define GL_STENCIL_BUFFER_BIT 0x00000400 +#define GL_VIEWPORT_BIT 0x00000800 +#define GL_TRANSFORM_BIT 0x00001000 +#define GL_ENABLE_BIT 0x00002000 +#define GL_COLOR_BUFFER_BIT 0x00004000 +#define GL_HINT_BIT 0x00008000 +#define GL_EVAL_BIT 0x00010000 +#define GL_LIST_BIT 0x00020000 +#define GL_TEXTURE_BIT 0x00040000 +#define GL_SCISSOR_BIT 0x00080000 +#define GL_ALL_ATTRIB_BITS 0x000FFFFF + + +/* OpenGL 1.1 */ +#define GL_PROXY_TEXTURE_1D 0x8063 +#define GL_PROXY_TEXTURE_2D 0x8064 +#define GL_TEXTURE_PRIORITY 0x8066 +#define GL_TEXTURE_RESIDENT 0x8067 +#define GL_TEXTURE_BINDING_1D 0x8068 +#define GL_TEXTURE_BINDING_2D 0x8069 +#define GL_TEXTURE_INTERNAL_FORMAT 0x1003 +#define GL_ALPHA4 0x803B +#define GL_ALPHA8 0x803C +#define GL_ALPHA12 0x803D +#define GL_ALPHA16 0x803E +#define GL_LUMINANCE4 0x803F +#define GL_LUMINANCE8 0x8040 +#define GL_LUMINANCE12 0x8041 +#define GL_LUMINANCE16 0x8042 +#define GL_LUMINANCE4_ALPHA4 0x8043 +#define GL_LUMINANCE6_ALPHA2 0x8044 +#define GL_LUMINANCE8_ALPHA8 0x8045 +#define GL_LUMINANCE12_ALPHA4 0x8046 +#define GL_LUMINANCE12_ALPHA12 0x8047 +#define GL_LUMINANCE16_ALPHA16 0x8048 +#define GL_INTENSITY 0x8049 +#define GL_INTENSITY4 0x804A +#define GL_INTENSITY8 0x804B +#define GL_INTENSITY12 0x804C +#define GL_INTENSITY16 0x804D +#define GL_R3_G3_B2 0x2A10 +#define GL_RGB4 0x804F +#define GL_RGB5 0x8050 +#define GL_RGB8 0x8051 +#define GL_RGB10 0x8052 +#define GL_RGB12 0x8053 +#define GL_RGB16 0x8054 +#define GL_RGBA2 0x8055 +#define GL_RGBA4 0x8056 +#define GL_RGB5_A1 0x8057 +#define GL_RGBA8 0x8058 +#define GL_RGB10_A2 0x8059 +#define GL_RGBA12 0x805A +#define GL_RGBA16 0x805B +#define GL_CLIENT_PIXEL_STORE_BIT 0x00000001 +#define GL_CLIENT_VERTEX_ARRAY_BIT 0x00000002 +#define GL_ALL_CLIENT_ATTRIB_BITS 0xFFFFFFFF +#define GL_CLIENT_ALL_ATTRIB_BITS 0xFFFFFFFF + + + +/* + * Miscellaneous + */ + +#ifndef SDL_OPENGL_1_NO_PROTOTYPES +GLAPI void GLAPIENTRY glClearIndex( GLfloat c ); + +GLAPI void GLAPIENTRY glClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ); + +GLAPI void GLAPIENTRY glClear( GLbitfield mask ); + +GLAPI void GLAPIENTRY glIndexMask( GLuint mask ); + +GLAPI void GLAPIENTRY glColorMask( GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha ); + +GLAPI void GLAPIENTRY glAlphaFunc( GLenum func, GLclampf ref ); + +GLAPI void GLAPIENTRY glBlendFunc( GLenum sfactor, GLenum dfactor ); + +GLAPI void GLAPIENTRY glLogicOp( GLenum opcode ); + +GLAPI void GLAPIENTRY glCullFace( GLenum mode ); + +GLAPI void GLAPIENTRY glFrontFace( GLenum mode ); + +GLAPI void GLAPIENTRY glPointSize( GLfloat size ); + +GLAPI void GLAPIENTRY glLineWidth( GLfloat width ); + +GLAPI void GLAPIENTRY glLineStipple( GLint factor, GLushort pattern ); + +GLAPI void GLAPIENTRY glPolygonMode( GLenum face, GLenum mode ); + +GLAPI void GLAPIENTRY glPolygonOffset( GLfloat factor, GLfloat units ); + +GLAPI void GLAPIENTRY glPolygonStipple( const GLubyte *mask ); + +GLAPI void GLAPIENTRY glGetPolygonStipple( GLubyte *mask ); + +GLAPI void GLAPIENTRY glEdgeFlag( GLboolean flag ); + +GLAPI void GLAPIENTRY glEdgeFlagv( const GLboolean *flag ); + +GLAPI void GLAPIENTRY glScissor( GLint x, GLint y, GLsizei width, GLsizei height); + +GLAPI void GLAPIENTRY glClipPlane( GLenum plane, const GLdouble *equation ); + +GLAPI void GLAPIENTRY glGetClipPlane( GLenum plane, GLdouble *equation ); + +GLAPI void GLAPIENTRY glDrawBuffer( GLenum mode ); + +GLAPI void GLAPIENTRY glReadBuffer( GLenum mode ); + +GLAPI void GLAPIENTRY glEnable( GLenum cap ); + +GLAPI void GLAPIENTRY glDisable( GLenum cap ); + +GLAPI GLboolean GLAPIENTRY glIsEnabled( GLenum cap ); + + +GLAPI void GLAPIENTRY glEnableClientState( GLenum cap ); /* 1.1 */ + +GLAPI void GLAPIENTRY glDisableClientState( GLenum cap ); /* 1.1 */ + + +GLAPI void GLAPIENTRY glGetBooleanv( GLenum pname, GLboolean *params ); + +GLAPI void GLAPIENTRY glGetDoublev( GLenum pname, GLdouble *params ); + +GLAPI void GLAPIENTRY glGetFloatv( GLenum pname, GLfloat *params ); + +GLAPI void GLAPIENTRY glGetIntegerv( GLenum pname, GLint *params ); + + +GLAPI void GLAPIENTRY glPushAttrib( GLbitfield mask ); + +GLAPI void GLAPIENTRY glPopAttrib( void ); + + +GLAPI void GLAPIENTRY glPushClientAttrib( GLbitfield mask ); /* 1.1 */ + +GLAPI void GLAPIENTRY glPopClientAttrib( void ); /* 1.1 */ + + +GLAPI GLint GLAPIENTRY glRenderMode( GLenum mode ); + +GLAPI GLenum GLAPIENTRY glGetError( void ); + +GLAPI const GLubyte * GLAPIENTRY glGetString( GLenum name ); + +GLAPI void GLAPIENTRY glFinish( void ); + +GLAPI void GLAPIENTRY glFlush( void ); + +GLAPI void GLAPIENTRY glHint( GLenum target, GLenum mode ); + + +/* + * Depth Buffer + */ + +GLAPI void GLAPIENTRY glClearDepth( GLclampd depth ); + +GLAPI void GLAPIENTRY glDepthFunc( GLenum func ); + +GLAPI void GLAPIENTRY glDepthMask( GLboolean flag ); + +GLAPI void GLAPIENTRY glDepthRange( GLclampd near_val, GLclampd far_val ); + + +/* + * Accumulation Buffer + */ + +GLAPI void GLAPIENTRY glClearAccum( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ); + +GLAPI void GLAPIENTRY glAccum( GLenum op, GLfloat value ); + + +/* + * Transformation + */ + +GLAPI void GLAPIENTRY glMatrixMode( GLenum mode ); + +GLAPI void GLAPIENTRY glOrtho( GLdouble left, GLdouble right, + GLdouble bottom, GLdouble top, + GLdouble near_val, GLdouble far_val ); + +GLAPI void GLAPIENTRY glFrustum( GLdouble left, GLdouble right, + GLdouble bottom, GLdouble top, + GLdouble near_val, GLdouble far_val ); + +GLAPI void GLAPIENTRY glViewport( GLint x, GLint y, + GLsizei width, GLsizei height ); + +GLAPI void GLAPIENTRY glPushMatrix( void ); + +GLAPI void GLAPIENTRY glPopMatrix( void ); + +GLAPI void GLAPIENTRY glLoadIdentity( void ); + +GLAPI void GLAPIENTRY glLoadMatrixd( const GLdouble *m ); +GLAPI void GLAPIENTRY glLoadMatrixf( const GLfloat *m ); + +GLAPI void GLAPIENTRY glMultMatrixd( const GLdouble *m ); +GLAPI void GLAPIENTRY glMultMatrixf( const GLfloat *m ); + +GLAPI void GLAPIENTRY glRotated( GLdouble angle, + GLdouble x, GLdouble y, GLdouble z ); +GLAPI void GLAPIENTRY glRotatef( GLfloat angle, + GLfloat x, GLfloat y, GLfloat z ); + +GLAPI void GLAPIENTRY glScaled( GLdouble x, GLdouble y, GLdouble z ); +GLAPI void GLAPIENTRY glScalef( GLfloat x, GLfloat y, GLfloat z ); + +GLAPI void GLAPIENTRY glTranslated( GLdouble x, GLdouble y, GLdouble z ); +GLAPI void GLAPIENTRY glTranslatef( GLfloat x, GLfloat y, GLfloat z ); + + +/* + * Display Lists + */ + +GLAPI GLboolean GLAPIENTRY glIsList( GLuint list ); + +GLAPI void GLAPIENTRY glDeleteLists( GLuint list, GLsizei range ); + +GLAPI GLuint GLAPIENTRY glGenLists( GLsizei range ); + +GLAPI void GLAPIENTRY glNewList( GLuint list, GLenum mode ); + +GLAPI void GLAPIENTRY glEndList( void ); + +GLAPI void GLAPIENTRY glCallList( GLuint list ); + +GLAPI void GLAPIENTRY glCallLists( GLsizei n, GLenum type, + const GLvoid *lists ); + +GLAPI void GLAPIENTRY glListBase( GLuint base ); + + +/* + * Drawing Functions + */ + +GLAPI void GLAPIENTRY glBegin( GLenum mode ); + +GLAPI void GLAPIENTRY glEnd( void ); + + +GLAPI void GLAPIENTRY glVertex2d( GLdouble x, GLdouble y ); +GLAPI void GLAPIENTRY glVertex2f( GLfloat x, GLfloat y ); +GLAPI void GLAPIENTRY glVertex2i( GLint x, GLint y ); +GLAPI void GLAPIENTRY glVertex2s( GLshort x, GLshort y ); + +GLAPI void GLAPIENTRY glVertex3d( GLdouble x, GLdouble y, GLdouble z ); +GLAPI void GLAPIENTRY glVertex3f( GLfloat x, GLfloat y, GLfloat z ); +GLAPI void GLAPIENTRY glVertex3i( GLint x, GLint y, GLint z ); +GLAPI void GLAPIENTRY glVertex3s( GLshort x, GLshort y, GLshort z ); + +GLAPI void GLAPIENTRY glVertex4d( GLdouble x, GLdouble y, GLdouble z, GLdouble w ); +GLAPI void GLAPIENTRY glVertex4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w ); +GLAPI void GLAPIENTRY glVertex4i( GLint x, GLint y, GLint z, GLint w ); +GLAPI void GLAPIENTRY glVertex4s( GLshort x, GLshort y, GLshort z, GLshort w ); + +GLAPI void GLAPIENTRY glVertex2dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glVertex2fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glVertex2iv( const GLint *v ); +GLAPI void GLAPIENTRY glVertex2sv( const GLshort *v ); + +GLAPI void GLAPIENTRY glVertex3dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glVertex3fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glVertex3iv( const GLint *v ); +GLAPI void GLAPIENTRY glVertex3sv( const GLshort *v ); + +GLAPI void GLAPIENTRY glVertex4dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glVertex4fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glVertex4iv( const GLint *v ); +GLAPI void GLAPIENTRY glVertex4sv( const GLshort *v ); + + +GLAPI void GLAPIENTRY glNormal3b( GLbyte nx, GLbyte ny, GLbyte nz ); +GLAPI void GLAPIENTRY glNormal3d( GLdouble nx, GLdouble ny, GLdouble nz ); +GLAPI void GLAPIENTRY glNormal3f( GLfloat nx, GLfloat ny, GLfloat nz ); +GLAPI void GLAPIENTRY glNormal3i( GLint nx, GLint ny, GLint nz ); +GLAPI void GLAPIENTRY glNormal3s( GLshort nx, GLshort ny, GLshort nz ); + +GLAPI void GLAPIENTRY glNormal3bv( const GLbyte *v ); +GLAPI void GLAPIENTRY glNormal3dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glNormal3fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glNormal3iv( const GLint *v ); +GLAPI void GLAPIENTRY glNormal3sv( const GLshort *v ); + + +GLAPI void GLAPIENTRY glIndexd( GLdouble c ); +GLAPI void GLAPIENTRY glIndexf( GLfloat c ); +GLAPI void GLAPIENTRY glIndexi( GLint c ); +GLAPI void GLAPIENTRY glIndexs( GLshort c ); +GLAPI void GLAPIENTRY glIndexub( GLubyte c ); /* 1.1 */ + +GLAPI void GLAPIENTRY glIndexdv( const GLdouble *c ); +GLAPI void GLAPIENTRY glIndexfv( const GLfloat *c ); +GLAPI void GLAPIENTRY glIndexiv( const GLint *c ); +GLAPI void GLAPIENTRY glIndexsv( const GLshort *c ); +GLAPI void GLAPIENTRY glIndexubv( const GLubyte *c ); /* 1.1 */ + +GLAPI void GLAPIENTRY glColor3b( GLbyte red, GLbyte green, GLbyte blue ); +GLAPI void GLAPIENTRY glColor3d( GLdouble red, GLdouble green, GLdouble blue ); +GLAPI void GLAPIENTRY glColor3f( GLfloat red, GLfloat green, GLfloat blue ); +GLAPI void GLAPIENTRY glColor3i( GLint red, GLint green, GLint blue ); +GLAPI void GLAPIENTRY glColor3s( GLshort red, GLshort green, GLshort blue ); +GLAPI void GLAPIENTRY glColor3ub( GLubyte red, GLubyte green, GLubyte blue ); +GLAPI void GLAPIENTRY glColor3ui( GLuint red, GLuint green, GLuint blue ); +GLAPI void GLAPIENTRY glColor3us( GLushort red, GLushort green, GLushort blue ); + +GLAPI void GLAPIENTRY glColor4b( GLbyte red, GLbyte green, + GLbyte blue, GLbyte alpha ); +GLAPI void GLAPIENTRY glColor4d( GLdouble red, GLdouble green, + GLdouble blue, GLdouble alpha ); +GLAPI void GLAPIENTRY glColor4f( GLfloat red, GLfloat green, + GLfloat blue, GLfloat alpha ); +GLAPI void GLAPIENTRY glColor4i( GLint red, GLint green, + GLint blue, GLint alpha ); +GLAPI void GLAPIENTRY glColor4s( GLshort red, GLshort green, + GLshort blue, GLshort alpha ); +GLAPI void GLAPIENTRY glColor4ub( GLubyte red, GLubyte green, + GLubyte blue, GLubyte alpha ); +GLAPI void GLAPIENTRY glColor4ui( GLuint red, GLuint green, + GLuint blue, GLuint alpha ); +GLAPI void GLAPIENTRY glColor4us( GLushort red, GLushort green, + GLushort blue, GLushort alpha ); + + +GLAPI void GLAPIENTRY glColor3bv( const GLbyte *v ); +GLAPI void GLAPIENTRY glColor3dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glColor3fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glColor3iv( const GLint *v ); +GLAPI void GLAPIENTRY glColor3sv( const GLshort *v ); +GLAPI void GLAPIENTRY glColor3ubv( const GLubyte *v ); +GLAPI void GLAPIENTRY glColor3uiv( const GLuint *v ); +GLAPI void GLAPIENTRY glColor3usv( const GLushort *v ); + +GLAPI void GLAPIENTRY glColor4bv( const GLbyte *v ); +GLAPI void GLAPIENTRY glColor4dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glColor4fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glColor4iv( const GLint *v ); +GLAPI void GLAPIENTRY glColor4sv( const GLshort *v ); +GLAPI void GLAPIENTRY glColor4ubv( const GLubyte *v ); +GLAPI void GLAPIENTRY glColor4uiv( const GLuint *v ); +GLAPI void GLAPIENTRY glColor4usv( const GLushort *v ); + + +GLAPI void GLAPIENTRY glTexCoord1d( GLdouble s ); +GLAPI void GLAPIENTRY glTexCoord1f( GLfloat s ); +GLAPI void GLAPIENTRY glTexCoord1i( GLint s ); +GLAPI void GLAPIENTRY glTexCoord1s( GLshort s ); + +GLAPI void GLAPIENTRY glTexCoord2d( GLdouble s, GLdouble t ); +GLAPI void GLAPIENTRY glTexCoord2f( GLfloat s, GLfloat t ); +GLAPI void GLAPIENTRY glTexCoord2i( GLint s, GLint t ); +GLAPI void GLAPIENTRY glTexCoord2s( GLshort s, GLshort t ); + +GLAPI void GLAPIENTRY glTexCoord3d( GLdouble s, GLdouble t, GLdouble r ); +GLAPI void GLAPIENTRY glTexCoord3f( GLfloat s, GLfloat t, GLfloat r ); +GLAPI void GLAPIENTRY glTexCoord3i( GLint s, GLint t, GLint r ); +GLAPI void GLAPIENTRY glTexCoord3s( GLshort s, GLshort t, GLshort r ); + +GLAPI void GLAPIENTRY glTexCoord4d( GLdouble s, GLdouble t, GLdouble r, GLdouble q ); +GLAPI void GLAPIENTRY glTexCoord4f( GLfloat s, GLfloat t, GLfloat r, GLfloat q ); +GLAPI void GLAPIENTRY glTexCoord4i( GLint s, GLint t, GLint r, GLint q ); +GLAPI void GLAPIENTRY glTexCoord4s( GLshort s, GLshort t, GLshort r, GLshort q ); + +GLAPI void GLAPIENTRY glTexCoord1dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glTexCoord1fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glTexCoord1iv( const GLint *v ); +GLAPI void GLAPIENTRY glTexCoord1sv( const GLshort *v ); + +GLAPI void GLAPIENTRY glTexCoord2dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glTexCoord2fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glTexCoord2iv( const GLint *v ); +GLAPI void GLAPIENTRY glTexCoord2sv( const GLshort *v ); + +GLAPI void GLAPIENTRY glTexCoord3dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glTexCoord3fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glTexCoord3iv( const GLint *v ); +GLAPI void GLAPIENTRY glTexCoord3sv( const GLshort *v ); + +GLAPI void GLAPIENTRY glTexCoord4dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glTexCoord4fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glTexCoord4iv( const GLint *v ); +GLAPI void GLAPIENTRY glTexCoord4sv( const GLshort *v ); + + +GLAPI void GLAPIENTRY glRasterPos2d( GLdouble x, GLdouble y ); +GLAPI void GLAPIENTRY glRasterPos2f( GLfloat x, GLfloat y ); +GLAPI void GLAPIENTRY glRasterPos2i( GLint x, GLint y ); +GLAPI void GLAPIENTRY glRasterPos2s( GLshort x, GLshort y ); + +GLAPI void GLAPIENTRY glRasterPos3d( GLdouble x, GLdouble y, GLdouble z ); +GLAPI void GLAPIENTRY glRasterPos3f( GLfloat x, GLfloat y, GLfloat z ); +GLAPI void GLAPIENTRY glRasterPos3i( GLint x, GLint y, GLint z ); +GLAPI void GLAPIENTRY glRasterPos3s( GLshort x, GLshort y, GLshort z ); + +GLAPI void GLAPIENTRY glRasterPos4d( GLdouble x, GLdouble y, GLdouble z, GLdouble w ); +GLAPI void GLAPIENTRY glRasterPos4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w ); +GLAPI void GLAPIENTRY glRasterPos4i( GLint x, GLint y, GLint z, GLint w ); +GLAPI void GLAPIENTRY glRasterPos4s( GLshort x, GLshort y, GLshort z, GLshort w ); + +GLAPI void GLAPIENTRY glRasterPos2dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glRasterPos2fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glRasterPos2iv( const GLint *v ); +GLAPI void GLAPIENTRY glRasterPos2sv( const GLshort *v ); + +GLAPI void GLAPIENTRY glRasterPos3dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glRasterPos3fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glRasterPos3iv( const GLint *v ); +GLAPI void GLAPIENTRY glRasterPos3sv( const GLshort *v ); + +GLAPI void GLAPIENTRY glRasterPos4dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glRasterPos4fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glRasterPos4iv( const GLint *v ); +GLAPI void GLAPIENTRY glRasterPos4sv( const GLshort *v ); + + +GLAPI void GLAPIENTRY glRectd( GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2 ); +GLAPI void GLAPIENTRY glRectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 ); +GLAPI void GLAPIENTRY glRecti( GLint x1, GLint y1, GLint x2, GLint y2 ); +GLAPI void GLAPIENTRY glRects( GLshort x1, GLshort y1, GLshort x2, GLshort y2 ); + + +GLAPI void GLAPIENTRY glRectdv( const GLdouble *v1, const GLdouble *v2 ); +GLAPI void GLAPIENTRY glRectfv( const GLfloat *v1, const GLfloat *v2 ); +GLAPI void GLAPIENTRY glRectiv( const GLint *v1, const GLint *v2 ); +GLAPI void GLAPIENTRY glRectsv( const GLshort *v1, const GLshort *v2 ); + + +/* + * Vertex Arrays (1.1) + */ + +GLAPI void GLAPIENTRY glVertexPointer( GLint size, GLenum type, + GLsizei stride, const GLvoid *ptr ); + +GLAPI void GLAPIENTRY glNormalPointer( GLenum type, GLsizei stride, + const GLvoid *ptr ); + +GLAPI void GLAPIENTRY glColorPointer( GLint size, GLenum type, + GLsizei stride, const GLvoid *ptr ); + +GLAPI void GLAPIENTRY glIndexPointer( GLenum type, GLsizei stride, + const GLvoid *ptr ); + +GLAPI void GLAPIENTRY glTexCoordPointer( GLint size, GLenum type, + GLsizei stride, const GLvoid *ptr ); + +GLAPI void GLAPIENTRY glEdgeFlagPointer( GLsizei stride, const GLvoid *ptr ); + +GLAPI void GLAPIENTRY glGetPointerv( GLenum pname, GLvoid **params ); + +GLAPI void GLAPIENTRY glArrayElement( GLint i ); + +GLAPI void GLAPIENTRY glDrawArrays( GLenum mode, GLint first, GLsizei count ); + +GLAPI void GLAPIENTRY glDrawElements( GLenum mode, GLsizei count, + GLenum type, const GLvoid *indices ); + +GLAPI void GLAPIENTRY glInterleavedArrays( GLenum format, GLsizei stride, + const GLvoid *pointer ); + +/* + * Lighting + */ + +GLAPI void GLAPIENTRY glShadeModel( GLenum mode ); + +GLAPI void GLAPIENTRY glLightf( GLenum light, GLenum pname, GLfloat param ); +GLAPI void GLAPIENTRY glLighti( GLenum light, GLenum pname, GLint param ); +GLAPI void GLAPIENTRY glLightfv( GLenum light, GLenum pname, + const GLfloat *params ); +GLAPI void GLAPIENTRY glLightiv( GLenum light, GLenum pname, + const GLint *params ); + +GLAPI void GLAPIENTRY glGetLightfv( GLenum light, GLenum pname, + GLfloat *params ); +GLAPI void GLAPIENTRY glGetLightiv( GLenum light, GLenum pname, + GLint *params ); + +GLAPI void GLAPIENTRY glLightModelf( GLenum pname, GLfloat param ); +GLAPI void GLAPIENTRY glLightModeli( GLenum pname, GLint param ); +GLAPI void GLAPIENTRY glLightModelfv( GLenum pname, const GLfloat *params ); +GLAPI void GLAPIENTRY glLightModeliv( GLenum pname, const GLint *params ); + +GLAPI void GLAPIENTRY glMaterialf( GLenum face, GLenum pname, GLfloat param ); +GLAPI void GLAPIENTRY glMateriali( GLenum face, GLenum pname, GLint param ); +GLAPI void GLAPIENTRY glMaterialfv( GLenum face, GLenum pname, const GLfloat *params ); +GLAPI void GLAPIENTRY glMaterialiv( GLenum face, GLenum pname, const GLint *params ); + +GLAPI void GLAPIENTRY glGetMaterialfv( GLenum face, GLenum pname, GLfloat *params ); +GLAPI void GLAPIENTRY glGetMaterialiv( GLenum face, GLenum pname, GLint *params ); + +GLAPI void GLAPIENTRY glColorMaterial( GLenum face, GLenum mode ); + + +/* + * Raster functions + */ + +GLAPI void GLAPIENTRY glPixelZoom( GLfloat xfactor, GLfloat yfactor ); + +GLAPI void GLAPIENTRY glPixelStoref( GLenum pname, GLfloat param ); +GLAPI void GLAPIENTRY glPixelStorei( GLenum pname, GLint param ); + +GLAPI void GLAPIENTRY glPixelTransferf( GLenum pname, GLfloat param ); +GLAPI void GLAPIENTRY glPixelTransferi( GLenum pname, GLint param ); + +GLAPI void GLAPIENTRY glPixelMapfv( GLenum map, GLsizei mapsize, + const GLfloat *values ); +GLAPI void GLAPIENTRY glPixelMapuiv( GLenum map, GLsizei mapsize, + const GLuint *values ); +GLAPI void GLAPIENTRY glPixelMapusv( GLenum map, GLsizei mapsize, + const GLushort *values ); + +GLAPI void GLAPIENTRY glGetPixelMapfv( GLenum map, GLfloat *values ); +GLAPI void GLAPIENTRY glGetPixelMapuiv( GLenum map, GLuint *values ); +GLAPI void GLAPIENTRY glGetPixelMapusv( GLenum map, GLushort *values ); + +GLAPI void GLAPIENTRY glBitmap( GLsizei width, GLsizei height, + GLfloat xorig, GLfloat yorig, + GLfloat xmove, GLfloat ymove, + const GLubyte *bitmap ); + +GLAPI void GLAPIENTRY glReadPixels( GLint x, GLint y, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + GLvoid *pixels ); + +GLAPI void GLAPIENTRY glDrawPixels( GLsizei width, GLsizei height, + GLenum format, GLenum type, + const GLvoid *pixels ); + +GLAPI void GLAPIENTRY glCopyPixels( GLint x, GLint y, + GLsizei width, GLsizei height, + GLenum type ); + +/* + * Stenciling + */ + +GLAPI void GLAPIENTRY glStencilFunc( GLenum func, GLint ref, GLuint mask ); + +GLAPI void GLAPIENTRY glStencilMask( GLuint mask ); + +GLAPI void GLAPIENTRY glStencilOp( GLenum fail, GLenum zfail, GLenum zpass ); + +GLAPI void GLAPIENTRY glClearStencil( GLint s ); + + + +/* + * Texture mapping + */ + +GLAPI void GLAPIENTRY glTexGend( GLenum coord, GLenum pname, GLdouble param ); +GLAPI void GLAPIENTRY glTexGenf( GLenum coord, GLenum pname, GLfloat param ); +GLAPI void GLAPIENTRY glTexGeni( GLenum coord, GLenum pname, GLint param ); + +GLAPI void GLAPIENTRY glTexGendv( GLenum coord, GLenum pname, const GLdouble *params ); +GLAPI void GLAPIENTRY glTexGenfv( GLenum coord, GLenum pname, const GLfloat *params ); +GLAPI void GLAPIENTRY glTexGeniv( GLenum coord, GLenum pname, const GLint *params ); + +GLAPI void GLAPIENTRY glGetTexGendv( GLenum coord, GLenum pname, GLdouble *params ); +GLAPI void GLAPIENTRY glGetTexGenfv( GLenum coord, GLenum pname, GLfloat *params ); +GLAPI void GLAPIENTRY glGetTexGeniv( GLenum coord, GLenum pname, GLint *params ); + + +GLAPI void GLAPIENTRY glTexEnvf( GLenum target, GLenum pname, GLfloat param ); +GLAPI void GLAPIENTRY glTexEnvi( GLenum target, GLenum pname, GLint param ); + +GLAPI void GLAPIENTRY glTexEnvfv( GLenum target, GLenum pname, const GLfloat *params ); +GLAPI void GLAPIENTRY glTexEnviv( GLenum target, GLenum pname, const GLint *params ); + +GLAPI void GLAPIENTRY glGetTexEnvfv( GLenum target, GLenum pname, GLfloat *params ); +GLAPI void GLAPIENTRY glGetTexEnviv( GLenum target, GLenum pname, GLint *params ); + + +GLAPI void GLAPIENTRY glTexParameterf( GLenum target, GLenum pname, GLfloat param ); +GLAPI void GLAPIENTRY glTexParameteri( GLenum target, GLenum pname, GLint param ); + +GLAPI void GLAPIENTRY glTexParameterfv( GLenum target, GLenum pname, + const GLfloat *params ); +GLAPI void GLAPIENTRY glTexParameteriv( GLenum target, GLenum pname, + const GLint *params ); + +GLAPI void GLAPIENTRY glGetTexParameterfv( GLenum target, + GLenum pname, GLfloat *params); +GLAPI void GLAPIENTRY glGetTexParameteriv( GLenum target, + GLenum pname, GLint *params ); + +GLAPI void GLAPIENTRY glGetTexLevelParameterfv( GLenum target, GLint level, + GLenum pname, GLfloat *params ); +GLAPI void GLAPIENTRY glGetTexLevelParameteriv( GLenum target, GLint level, + GLenum pname, GLint *params ); + + +GLAPI void GLAPIENTRY glTexImage1D( GLenum target, GLint level, + GLint internalFormat, + GLsizei width, GLint border, + GLenum format, GLenum type, + const GLvoid *pixels ); + +GLAPI void GLAPIENTRY glTexImage2D( GLenum target, GLint level, + GLint internalFormat, + GLsizei width, GLsizei height, + GLint border, GLenum format, GLenum type, + const GLvoid *pixels ); + +GLAPI void GLAPIENTRY glGetTexImage( GLenum target, GLint level, + GLenum format, GLenum type, + GLvoid *pixels ); + + +/* 1.1 functions */ + +GLAPI void GLAPIENTRY glGenTextures( GLsizei n, GLuint *textures ); + +GLAPI void GLAPIENTRY glDeleteTextures( GLsizei n, const GLuint *textures); + +GLAPI void GLAPIENTRY glBindTexture( GLenum target, GLuint texture ); + +GLAPI void GLAPIENTRY glPrioritizeTextures( GLsizei n, + const GLuint *textures, + const GLclampf *priorities ); + +GLAPI GLboolean GLAPIENTRY glAreTexturesResident( GLsizei n, + const GLuint *textures, + GLboolean *residences ); + +GLAPI GLboolean GLAPIENTRY glIsTexture( GLuint texture ); + + +GLAPI void GLAPIENTRY glTexSubImage1D( GLenum target, GLint level, + GLint xoffset, + GLsizei width, GLenum format, + GLenum type, const GLvoid *pixels ); + + +GLAPI void GLAPIENTRY glTexSubImage2D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + const GLvoid *pixels ); + + +GLAPI void GLAPIENTRY glCopyTexImage1D( GLenum target, GLint level, + GLenum internalformat, + GLint x, GLint y, + GLsizei width, GLint border ); + + +GLAPI void GLAPIENTRY glCopyTexImage2D( GLenum target, GLint level, + GLenum internalformat, + GLint x, GLint y, + GLsizei width, GLsizei height, + GLint border ); + + +GLAPI void GLAPIENTRY glCopyTexSubImage1D( GLenum target, GLint level, + GLint xoffset, GLint x, GLint y, + GLsizei width ); + + +GLAPI void GLAPIENTRY glCopyTexSubImage2D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint x, GLint y, + GLsizei width, GLsizei height ); + + +/* + * Evaluators + */ + +GLAPI void GLAPIENTRY glMap1d( GLenum target, GLdouble u1, GLdouble u2, + GLint stride, + GLint order, const GLdouble *points ); +GLAPI void GLAPIENTRY glMap1f( GLenum target, GLfloat u1, GLfloat u2, + GLint stride, + GLint order, const GLfloat *points ); + +GLAPI void GLAPIENTRY glMap2d( GLenum target, + GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, + GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, + const GLdouble *points ); +GLAPI void GLAPIENTRY glMap2f( GLenum target, + GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, + GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, + const GLfloat *points ); + +GLAPI void GLAPIENTRY glGetMapdv( GLenum target, GLenum query, GLdouble *v ); +GLAPI void GLAPIENTRY glGetMapfv( GLenum target, GLenum query, GLfloat *v ); +GLAPI void GLAPIENTRY glGetMapiv( GLenum target, GLenum query, GLint *v ); + +GLAPI void GLAPIENTRY glEvalCoord1d( GLdouble u ); +GLAPI void GLAPIENTRY glEvalCoord1f( GLfloat u ); + +GLAPI void GLAPIENTRY glEvalCoord1dv( const GLdouble *u ); +GLAPI void GLAPIENTRY glEvalCoord1fv( const GLfloat *u ); + +GLAPI void GLAPIENTRY glEvalCoord2d( GLdouble u, GLdouble v ); +GLAPI void GLAPIENTRY glEvalCoord2f( GLfloat u, GLfloat v ); + +GLAPI void GLAPIENTRY glEvalCoord2dv( const GLdouble *u ); +GLAPI void GLAPIENTRY glEvalCoord2fv( const GLfloat *u ); + +GLAPI void GLAPIENTRY glMapGrid1d( GLint un, GLdouble u1, GLdouble u2 ); +GLAPI void GLAPIENTRY glMapGrid1f( GLint un, GLfloat u1, GLfloat u2 ); + +GLAPI void GLAPIENTRY glMapGrid2d( GLint un, GLdouble u1, GLdouble u2, + GLint vn, GLdouble v1, GLdouble v2 ); +GLAPI void GLAPIENTRY glMapGrid2f( GLint un, GLfloat u1, GLfloat u2, + GLint vn, GLfloat v1, GLfloat v2 ); + +GLAPI void GLAPIENTRY glEvalPoint1( GLint i ); + +GLAPI void GLAPIENTRY glEvalPoint2( GLint i, GLint j ); + +GLAPI void GLAPIENTRY glEvalMesh1( GLenum mode, GLint i1, GLint i2 ); + +GLAPI void GLAPIENTRY glEvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 ); + + +/* + * Fog + */ + +GLAPI void GLAPIENTRY glFogf( GLenum pname, GLfloat param ); + +GLAPI void GLAPIENTRY glFogi( GLenum pname, GLint param ); + +GLAPI void GLAPIENTRY glFogfv( GLenum pname, const GLfloat *params ); + +GLAPI void GLAPIENTRY glFogiv( GLenum pname, const GLint *params ); + + +/* + * Selection and Feedback + */ + +GLAPI void GLAPIENTRY glFeedbackBuffer( GLsizei size, GLenum type, GLfloat *buffer ); + +GLAPI void GLAPIENTRY glPassThrough( GLfloat token ); + +GLAPI void GLAPIENTRY glSelectBuffer( GLsizei size, GLuint *buffer ); + +GLAPI void GLAPIENTRY glInitNames( void ); + +GLAPI void GLAPIENTRY glLoadName( GLuint name ); + +GLAPI void GLAPIENTRY glPushName( GLuint name ); + +GLAPI void GLAPIENTRY glPopName( void ); + +#endif +#ifdef SDL_OPENGL_1_FUNCTION_TYPEDEFS + +typedef void (APIENTRYP PFNGLCLEARINDEXPROC) ( GLfloat c ); + +typedef void (APIENTRYP PFNGLCLEARCOLORPROC) ( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ); + +typedef void (APIENTRYP PFNGLCLEARPROC) ( GLbitfield mask ); + +typedef void (APIENTRYP PFNGLINDEXMASKPROC) ( GLuint mask ); + +typedef void (APIENTRYP PFNGLCOLORMASKPROC) ( GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha ); + +typedef void (APIENTRYP PFNGLALPHAFUNCPROC) ( GLenum func, GLclampf ref ); + +typedef void (APIENTRYP PFNGLBLENDFUNCPROC) ( GLenum sfactor, GLenum dfactor ); + +typedef void (APIENTRYP PFNGLLOGICOPPROC) ( GLenum opcode ); + +typedef void (APIENTRYP PFNGLCULLFACEPROC) ( GLenum mode ); + +typedef void (APIENTRYP PFNGLFRONTFACEPROC) ( GLenum mode ); + +typedef void (APIENTRYP PFNGLPOINTSIZEPROC) ( GLfloat size ); + +typedef void (APIENTRYP PFNGLLINEWIDTHPROC) ( GLfloat width ); + +typedef void (APIENTRYP PFNGLLINESTIPPLEPROC) ( GLint factor, GLushort pattern ); + +typedef void (APIENTRYP PFNGLPOLYGONMODEPROC) ( GLenum face, GLenum mode ); + +typedef void (APIENTRYP PFNGLPOLYGONOFFSETPROC) ( GLfloat factor, GLfloat units ); + +typedef void (APIENTRYP PFNGLPOLYGONSTIPPLEPROC) ( const GLubyte *mask ); + +typedef void (APIENTRYP PFNGLGETPOLYGONSTIPPLEPROC) ( GLubyte *mask ); + +typedef void (APIENTRYP PFNGLEDGEFLAGPROC) ( GLboolean flag ); + +typedef void (APIENTRYP PFNGLEDGEFLAGVPROC) ( const GLboolean *flag ); + +typedef void (APIENTRYP PFNGLSCISSORPROC) ( GLint x, GLint y, GLsizei width, GLsizei height); + +typedef void (APIENTRYP PFNGLCLIPPLANEPROC) ( GLenum plane, const GLdouble *equation ); + +typedef void (APIENTRYP PFNGLGETCLIPPLANEPROC) ( GLenum plane, GLdouble *equation ); + +typedef void (APIENTRYP PFNGLDRAWBUFFERPROC) ( GLenum mode ); + +typedef void (APIENTRYP PFNGLREADBUFFERPROC) ( GLenum mode ); + +typedef void (APIENTRYP PFNGLENABLEPROC) ( GLenum cap ); + +typedef void (APIENTRYP PFNGLDISABLEPROC) ( GLenum cap ); + +typedef GLboolean (APIENTRYP PFNGLISENABLEDPROC) ( GLenum cap ); + + +typedef void (APIENTRYP PFNGLENABLECLIENTSTATEPROC) ( GLenum cap ); /* 1.1 */ + +typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEPROC) ( GLenum cap ); /* 1.1 */ + + +typedef void (APIENTRYP PFNGLGETBOOLEANVPROC) ( GLenum pname, GLboolean *params ); + +typedef void (APIENTRYP PFNGLGETDOUBLEVPROC) ( GLenum pname, GLdouble *params ); + +typedef void (APIENTRYP PFNGLGETFLOATVPROC) ( GLenum pname, GLfloat *params ); + +typedef void (APIENTRYP PFNGLGETINTEGERVPROC) ( GLenum pname, GLint *params ); + + +typedef void (APIENTRYP PFNGLPUSHATTRIBPROC) ( GLbitfield mask ); + +typedef void (APIENTRYP PFNGLPOPATTRIBPROC) ( void ); + + +typedef void (APIENTRYP PFNGLPUSHCLIENTATTRIBPROC) ( GLbitfield mask ); /* 1.1 */ + +typedef void (APIENTRYP PFNGLPOPCLIENTATTRIBPROC) ( void ); /* 1.1 */ + + +typedef GLint (APIENTRYP PFNGLRENDERMODEPROC) ( GLenum mode ); + +typedef GLenum (APIENTRYP PFNGLGETERRORPROC) ( void ); + +typedef const GLubyte * (APIENTRYP PFNGLGETSTRINGPROC) ( GLenum name ); + +typedef void (APIENTRYP PFNGLFINISHPROC) ( void ); + +typedef void (APIENTRYP PFNGLFLUSHPROC) ( void ); + +typedef void (APIENTRYP PFNGLHINTPROC) ( GLenum target, GLenum mode ); + + +/* + * Depth Buffer + */ + +typedef void (APIENTRYP PFNGLCLEARDEPTHPROC) ( GLclampd depth ); + +typedef void (APIENTRYP PFNGLDEPTHFUNCPROC) ( GLenum func ); + +typedef void (APIENTRYP PFNGLDEPTHMASKPROC) ( GLboolean flag ); + +typedef void (APIENTRYP PFNGLDEPTHRANGEPROC) ( GLclampd near_val, GLclampd far_val ); + + +/* + * Accumulation Buffer + */ + +typedef void (APIENTRYP PFNGLCLEARACCUMPROC) ( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ); + +typedef void (APIENTRYP PFNGLACCUMPROC) ( GLenum op, GLfloat value ); + + +/* + * Transformation + */ + +typedef void (APIENTRYP PFNGLMATRIXMODEPROC) ( GLenum mode ); + +typedef void (APIENTRYP PFNGLORTHOPROC) ( GLdouble left, GLdouble right, + GLdouble bottom, GLdouble top, + GLdouble near_val, GLdouble far_val ); + +typedef void (APIENTRYP PFNGLFRUSTUMPROC) ( GLdouble left, GLdouble right, + GLdouble bottom, GLdouble top, + GLdouble near_val, GLdouble far_val ); + +typedef void (APIENTRYP PFNGLVIEWPORTPROC) ( GLint x, GLint y, + GLsizei width, GLsizei height ); + +typedef void (APIENTRYP PFNGLPUSHMATRIXPROC) ( void ); + +typedef void (APIENTRYP PFNGLPOPMATRIXPROC) ( void ); + +typedef void (APIENTRYP PFNGLLOADIDENTITYPROC) ( void ); + +typedef void (APIENTRYP PFNGLLOADMATRIXDPROC) ( const GLdouble *m ); +typedef void (APIENTRYP PFNGLLOADMATRIXFPROC) ( const GLfloat *m ); + +typedef void (APIENTRYP PFNGLMULTMATRIXDPROC) ( const GLdouble *m ); +typedef void (APIENTRYP PFNGLMULTMATRIXFPROC) ( const GLfloat *m ); + +typedef void (APIENTRYP PFNGLROTATEDPROC) ( GLdouble angle, + GLdouble x, GLdouble y, GLdouble z ); +typedef void (APIENTRYP PFNGLROTATEFPROC) ( GLfloat angle, + GLfloat x, GLfloat y, GLfloat z ); + +typedef void (APIENTRYP PFNGLSCALEDPROC) ( GLdouble x, GLdouble y, GLdouble z ); +typedef void (APIENTRYP PFNGLSCALEFPROC) ( GLfloat x, GLfloat y, GLfloat z ); + +typedef void (APIENTRYP PFNGLTRANSLATEDPROC) ( GLdouble x, GLdouble y, GLdouble z ); +typedef void (APIENTRYP PFNGLTRANSLATEFPROC) ( GLfloat x, GLfloat y, GLfloat z ); + + +/* + * Display Lists + */ + +typedef GLboolean (APIENTRYP PFNGLISLISTPROC) ( GLuint list ); + +typedef void (APIENTRYP PFNGLDELETELISTSPROC) ( GLuint list, GLsizei range ); + +typedef GLuint (APIENTRYP PFNGLGENLISTSPROC) ( GLsizei range ); + +typedef void (APIENTRYP PFNGLNEWLISTPROC) ( GLuint list, GLenum mode ); + +typedef void (APIENTRYP PFNGLENDLISTPROC) ( void ); + +typedef void (APIENTRYP PFNGLCALLLISTPROC) ( GLuint list ); + +typedef void (APIENTRYP PFNGLCALLLISTSPROC) ( GLsizei n, GLenum type, + const GLvoid *lists ); + +typedef void (APIENTRYP PFNGLLISTBASEPROC) ( GLuint base ); + + +/* + * Drawing Functions + */ + +typedef void (APIENTRYP PFNGLBEGINPROC) ( GLenum mode ); + +typedef void (APIENTRYP PFNGLENDPROC) ( void ); + + +typedef void (APIENTRYP PFNGLVERTEX2DPROC) ( GLdouble x, GLdouble y ); +typedef void (APIENTRYP PFNGLVERTEX2FPROC) ( GLfloat x, GLfloat y ); +typedef void (APIENTRYP PFNGLVERTEX2IPROC) ( GLint x, GLint y ); +typedef void (APIENTRYP PFNGLVERTEX2SPROC) ( GLshort x, GLshort y ); + +typedef void (APIENTRYP PFNGLVERTEX3DPROC) ( GLdouble x, GLdouble y, GLdouble z ); +typedef void (APIENTRYP PFNGLVERTEX3FPROC) ( GLfloat x, GLfloat y, GLfloat z ); +typedef void (APIENTRYP PFNGLVERTEX3IPROC) ( GLint x, GLint y, GLint z ); +typedef void (APIENTRYP PFNGLVERTEX3SPROC) ( GLshort x, GLshort y, GLshort z ); + +typedef void (APIENTRYP PFNGLVERTEX4DPROC) ( GLdouble x, GLdouble y, GLdouble z, GLdouble w ); +typedef void (APIENTRYP PFNGLVERTEX4FPROC) ( GLfloat x, GLfloat y, GLfloat z, GLfloat w ); +typedef void (APIENTRYP PFNGLVERTEX4IPROC) ( GLint x, GLint y, GLint z, GLint w ); +typedef void (APIENTRYP PFNGLVERTEX4SPROC) ( GLshort x, GLshort y, GLshort z, GLshort w ); + +typedef void (APIENTRYP PFNGLVERTEX2DVPROC) ( const GLdouble *v ); +typedef void (APIENTRYP PFNGLVERTEX2FVPROC) ( const GLfloat *v ); +typedef void (APIENTRYP PFNGLVERTEX2IVPROC) ( const GLint *v ); +typedef void (APIENTRYP PFNGLVERTEX2SVPROC) ( const GLshort *v ); + +typedef void (APIENTRYP PFNGLVERTEX3DVPROC) ( const GLdouble *v ); +typedef void (APIENTRYP PFNGLVERTEX3FVPROC) ( const GLfloat *v ); +typedef void (APIENTRYP PFNGLVERTEX3IVPROC) ( const GLint *v ); +typedef void (APIENTRYP PFNGLVERTEX3SVPROC) ( const GLshort *v ); + +typedef void (APIENTRYP PFNGLVERTEX4DVPROC) ( const GLdouble *v ); +typedef void (APIENTRYP PFNGLVERTEX4FVPROC) ( const GLfloat *v ); +typedef void (APIENTRYP PFNGLVERTEX4IVPROC) ( const GLint *v ); +typedef void (APIENTRYP PFNGLVERTEX4SVPROC) ( const GLshort *v ); + + +typedef void (APIENTRYP PFNGLNORMAL3BPROC) ( GLbyte nx, GLbyte ny, GLbyte nz ); +typedef void (APIENTRYP PFNGLNORMAL3DPROC) ( GLdouble nx, GLdouble ny, GLdouble nz ); +typedef void (APIENTRYP PFNGLNORMAL3FPROC) ( GLfloat nx, GLfloat ny, GLfloat nz ); +typedef void (APIENTRYP PFNGLNORMAL3IPROC) ( GLint nx, GLint ny, GLint nz ); +typedef void (APIENTRYP PFNGLNORMAL3SPROC) ( GLshort nx, GLshort ny, GLshort nz ); + +typedef void (APIENTRYP PFNGLNORMAL3BVPROC) ( const GLbyte *v ); +typedef void (APIENTRYP PFNGLNORMAL3DVPROC) ( const GLdouble *v ); +typedef void (APIENTRYP PFNGLNORMAL3FVPROC) ( const GLfloat *v ); +typedef void (APIENTRYP PFNGLNORMAL3IVPROC) ( const GLint *v ); +typedef void (APIENTRYP PFNGLNORMAL3SVPROC) ( const GLshort *v ); + + +typedef void (APIENTRYP PFNGLINDEXDPROC) ( GLdouble c ); +typedef void (APIENTRYP PFNGLINDEXFPROC) ( GLfloat c ); +typedef void (APIENTRYP PFNGLINDEXIPROC) ( GLint c ); +typedef void (APIENTRYP PFNGLINDEXSPROC) ( GLshort c ); +typedef void (APIENTRYP PFNGLINDEXUBPROC) ( GLubyte c ); /* 1.1 */ + +typedef void (APIENTRYP PFNGLINDEXDVPROC) ( const GLdouble *c ); +typedef void (APIENTRYP PFNGLINDEXFVPROC) ( const GLfloat *c ); +typedef void (APIENTRYP PFNGLINDEXIVPROC) ( const GLint *c ); +typedef void (APIENTRYP PFNGLINDEXSVPROC) ( const GLshort *c ); +typedef void (APIENTRYP PFNGLINDEXUBVPROC) ( const GLubyte *c ); /* 1.1 */ + +typedef void (APIENTRYP PFNGLCOLOR3BPROC) ( GLbyte red, GLbyte green, GLbyte blue ); +typedef void (APIENTRYP PFNGLCOLOR3DPROC) ( GLdouble red, GLdouble green, GLdouble blue ); +typedef void (APIENTRYP PFNGLCOLOR3FPROC) ( GLfloat red, GLfloat green, GLfloat blue ); +typedef void (APIENTRYP PFNGLCOLOR3IPROC) ( GLint red, GLint green, GLint blue ); +typedef void (APIENTRYP PFNGLCOLOR3SPROC) ( GLshort red, GLshort green, GLshort blue ); +typedef void (APIENTRYP PFNGLCOLOR3UBPROC) ( GLubyte red, GLubyte green, GLubyte blue ); +typedef void (APIENTRYP PFNGLCOLOR3UIPROC) ( GLuint red, GLuint green, GLuint blue ); +typedef void (APIENTRYP PFNGLCOLOR3USPROC) ( GLushort red, GLushort green, GLushort blue ); + +typedef void (APIENTRYP PFNGLCOLOR4BPROC) ( GLbyte red, GLbyte green, + GLbyte blue, GLbyte alpha ); +typedef void (APIENTRYP PFNGLCOLOR4DPROC) ( GLdouble red, GLdouble green, + GLdouble blue, GLdouble alpha ); +typedef void (APIENTRYP PFNGLCOLOR4FPROC) ( GLfloat red, GLfloat green, + GLfloat blue, GLfloat alpha ); +typedef void (APIENTRYP PFNGLCOLOR4IPROC) ( GLint red, GLint green, + GLint blue, GLint alpha ); +typedef void (APIENTRYP PFNGLCOLOR4SPROC) ( GLshort red, GLshort green, + GLshort blue, GLshort alpha ); +typedef void (APIENTRYP PFNGLCOLOR4UBPROC) ( GLubyte red, GLubyte green, + GLubyte blue, GLubyte alpha ); +typedef void (APIENTRYP PFNGLCOLOR4UIPROC) ( GLuint red, GLuint green, + GLuint blue, GLuint alpha ); +typedef void (APIENTRYP PFNGLCOLOR4USPROC) ( GLushort red, GLushort green, + GLushort blue, GLushort alpha ); + + +typedef void (APIENTRYP PFNGLCOLOR3BVPROC) ( const GLbyte *v ); +typedef void (APIENTRYP PFNGLCOLOR3DVPROC) ( const GLdouble *v ); +typedef void (APIENTRYP PFNGLCOLOR3FVPROC) ( const GLfloat *v ); +typedef void (APIENTRYP PFNGLCOLOR3IVPROC) ( const GLint *v ); +typedef void (APIENTRYP PFNGLCOLOR3SVPROC) ( const GLshort *v ); +typedef void (APIENTRYP PFNGLCOLOR3UBVPROC) ( const GLubyte *v ); +typedef void (APIENTRYP PFNGLCOLOR3UIVPROC) ( const GLuint *v ); +typedef void (APIENTRYP PFNGLCOLOR3USVPROC) ( const GLushort *v ); + +typedef void (APIENTRYP PFNGLCOLOR4BVPROC) ( const GLbyte *v ); +typedef void (APIENTRYP PFNGLCOLOR4DVPROC) ( const GLdouble *v ); +typedef void (APIENTRYP PFNGLCOLOR4FVPROC) ( const GLfloat *v ); +typedef void (APIENTRYP PFNGLCOLOR4IVPROC) ( const GLint *v ); +typedef void (APIENTRYP PFNGLCOLOR4SVPROC) ( const GLshort *v ); +typedef void (APIENTRYP PFNGLCOLOR4UBVPROC) ( const GLubyte *v ); +typedef void (APIENTRYP PFNGLCOLOR4UIVPROC) ( const GLuint *v ); +typedef void (APIENTRYP PFNGLCOLOR4USVPROC) ( const GLushort *v ); + + +typedef void (APIENTRYP PFNGLTEXCOORD1DPROC) ( GLdouble s ); +typedef void (APIENTRYP PFNGLTEXCOORD1FPROC) ( GLfloat s ); +typedef void (APIENTRYP PFNGLTEXCOORD1IPROC) ( GLint s ); +typedef void (APIENTRYP PFNGLTEXCOORD1SPROC) ( GLshort s ); + +typedef void (APIENTRYP PFNGLTEXCOORD2DPROC) ( GLdouble s, GLdouble t ); +typedef void (APIENTRYP PFNGLTEXCOORD2FPROC) ( GLfloat s, GLfloat t ); +typedef void (APIENTRYP PFNGLTEXCOORD2IPROC) ( GLint s, GLint t ); +typedef void (APIENTRYP PFNGLTEXCOORD2SPROC) ( GLshort s, GLshort t ); + +typedef void (APIENTRYP PFNGLTEXCOORD3DPROC) ( GLdouble s, GLdouble t, GLdouble r ); +typedef void (APIENTRYP PFNGLTEXCOORD3FPROC) ( GLfloat s, GLfloat t, GLfloat r ); +typedef void (APIENTRYP PFNGLTEXCOORD3IPROC) ( GLint s, GLint t, GLint r ); +typedef void (APIENTRYP PFNGLTEXCOORD3SPROC) ( GLshort s, GLshort t, GLshort r ); + +typedef void (APIENTRYP PFNGLTEXCOORD4DPROC) ( GLdouble s, GLdouble t, GLdouble r, GLdouble q ); +typedef void (APIENTRYP PFNGLTEXCOORD4FPROC) ( GLfloat s, GLfloat t, GLfloat r, GLfloat q ); +typedef void (APIENTRYP PFNGLTEXCOORD4IPROC) ( GLint s, GLint t, GLint r, GLint q ); +typedef void (APIENTRYP PFNGLTEXCOORD4SPROC) ( GLshort s, GLshort t, GLshort r, GLshort q ); + +typedef void (APIENTRYP PFNGLTEXCOORD1DVPROC) ( const GLdouble *v ); +typedef void (APIENTRYP PFNGLTEXCOORD1FVPROC) ( const GLfloat *v ); +typedef void (APIENTRYP PFNGLTEXCOORD1IVPROC) ( const GLint *v ); +typedef void (APIENTRYP PFNGLTEXCOORD1SVPROC) ( const GLshort *v ); + +typedef void (APIENTRYP PFNGLTEXCOORD2DVPROC) ( const GLdouble *v ); +typedef void (APIENTRYP PFNGLTEXCOORD2FVPROC) ( const GLfloat *v ); +typedef void (APIENTRYP PFNGLTEXCOORD2IVPROC) ( const GLint *v ); +typedef void (APIENTRYP PFNGLTEXCOORD2SVPROC) ( const GLshort *v ); + +typedef void (APIENTRYP PFNGLTEXCOORD3DVPROC) ( const GLdouble *v ); +typedef void (APIENTRYP PFNGLTEXCOORD3FVPROC) ( const GLfloat *v ); +typedef void (APIENTRYP PFNGLTEXCOORD3IVPROC) ( const GLint *v ); +typedef void (APIENTRYP PFNGLTEXCOORD3SVPROC) ( const GLshort *v ); + +typedef void (APIENTRYP PFNGLTEXCOORD4DVPROC) ( const GLdouble *v ); +typedef void (APIENTRYP PFNGLTEXCOORD4FVPROC) ( const GLfloat *v ); +typedef void (APIENTRYP PFNGLTEXCOORD4IVPROC) ( const GLint *v ); +typedef void (APIENTRYP PFNGLTEXCOORD4SVPROC) ( const GLshort *v ); + + +typedef void (APIENTRYP PFNGLRASTERPOS2DPROC) ( GLdouble x, GLdouble y ); +typedef void (APIENTRYP PFNGLRASTERPOS2FPROC) ( GLfloat x, GLfloat y ); +typedef void (APIENTRYP PFNGLRASTERPOS2IPROC) ( GLint x, GLint y ); +typedef void (APIENTRYP PFNGLRASTERPOS2SPROC) ( GLshort x, GLshort y ); + +typedef void (APIENTRYP PFNGLRASTERPOS3DPROC) ( GLdouble x, GLdouble y, GLdouble z ); +typedef void (APIENTRYP PFNGLRASTERPOS3FPROC) ( GLfloat x, GLfloat y, GLfloat z ); +typedef void (APIENTRYP PFNGLRASTERPOS3IPROC) ( GLint x, GLint y, GLint z ); +typedef void (APIENTRYP PFNGLRASTERPOS3SPROC) ( GLshort x, GLshort y, GLshort z ); + +typedef void (APIENTRYP PFNGLRASTERPOS4DPROC) ( GLdouble x, GLdouble y, GLdouble z, GLdouble w ); +typedef void (APIENTRYP PFNGLRASTERPOS4FPROC) ( GLfloat x, GLfloat y, GLfloat z, GLfloat w ); +typedef void (APIENTRYP PFNGLRASTERPOS4IPROC) ( GLint x, GLint y, GLint z, GLint w ); +typedef void (APIENTRYP PFNGLRASTERPOS4SPROC) ( GLshort x, GLshort y, GLshort z, GLshort w ); + +typedef void (APIENTRYP PFNGLRASTERPOS2DVPROC) ( const GLdouble *v ); +typedef void (APIENTRYP PFNGLRASTERPOS2FVPROC) ( const GLfloat *v ); +typedef void (APIENTRYP PFNGLRASTERPOS2IVPROC) ( const GLint *v ); +typedef void (APIENTRYP PFNGLRASTERPOS2SVPROC) ( const GLshort *v ); + +typedef void (APIENTRYP PFNGLRASTERPOS3DVPROC) ( const GLdouble *v ); +typedef void (APIENTRYP PFNGLRASTERPOS3FVPROC) ( const GLfloat *v ); +typedef void (APIENTRYP PFNGLRASTERPOS3IVPROC) ( const GLint *v ); +typedef void (APIENTRYP PFNGLRASTERPOS3SVPROC) ( const GLshort *v ); + +typedef void (APIENTRYP PFNGLRASTERPOS4DVPROC) ( const GLdouble *v ); +typedef void (APIENTRYP PFNGLRASTERPOS4FVPROC) ( const GLfloat *v ); +typedef void (APIENTRYP PFNGLRASTERPOS4IVPROC) ( const GLint *v ); +typedef void (APIENTRYP PFNGLRASTERPOS4SVPROC) ( const GLshort *v ); + + +typedef void (APIENTRYP PFNGLRECTDPROC) ( GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2 ); +typedef void (APIENTRYP PFNGLRECTFPROC) ( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 ); +typedef void (APIENTRYP PFNGLRECTIPROC) ( GLint x1, GLint y1, GLint x2, GLint y2 ); +typedef void (APIENTRYP PFNGLRECTSPROC) ( GLshort x1, GLshort y1, GLshort x2, GLshort y2 ); + + +typedef void (APIENTRYP PFNGLRECTDVPROC) ( const GLdouble *v1, const GLdouble *v2 ); +typedef void (APIENTRYP PFNGLRECTFVPROC) ( const GLfloat *v1, const GLfloat *v2 ); +typedef void (APIENTRYP PFNGLRECTIVPROC) ( const GLint *v1, const GLint *v2 ); +typedef void (APIENTRYP PFNGLRECTSVPROC) ( const GLshort *v1, const GLshort *v2 ); + + +/* + * Vertex Arrays (1.1) + */ + +typedef void (APIENTRYP PFNGLVERTEXPOINTERPROC) ( GLint size, GLenum type, + GLsizei stride, const GLvoid *ptr ); + +typedef void (APIENTRYP PFNGLNORMALPOINTERPROC) ( GLenum type, GLsizei stride, + const GLvoid *ptr ); + +typedef void (APIENTRYP PFNGLCOLORPOINTERPROC) ( GLint size, GLenum type, + GLsizei stride, const GLvoid *ptr ); + +typedef void (APIENTRYP PFNGLINDEXPOINTERPROC) ( GLenum type, GLsizei stride, + const GLvoid *ptr ); + +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERPROC) ( GLint size, GLenum type, + GLsizei stride, const GLvoid *ptr ); + +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERPROC) ( GLsizei stride, const GLvoid *ptr ); + +typedef void (APIENTRYP PFNGLGETPOINTERVPROC) ( GLenum pname, GLvoid **params ); + +typedef void (APIENTRYP PFNGLARRAYELEMENTPROC) ( GLint i ); + +typedef void (APIENTRYP PFNGLDRAWARRAYSPROC) ( GLenum mode, GLint first, GLsizei count ); + +typedef void (APIENTRYP PFNGLDRAWELEMENTSPROC) ( GLenum mode, GLsizei count, + GLenum type, const GLvoid *indices ); + +typedef void (APIENTRYP PFNGLINTERLEAVEDARRAYSPROC) ( GLenum format, GLsizei stride, + const GLvoid *pointer ); + +/* + * Lighting + */ + +typedef void (APIENTRYP PFNGLSHADEMODELPROC) ( GLenum mode ); + +typedef void (APIENTRYP PFNGLLIGHTFPROC) ( GLenum light, GLenum pname, GLfloat param ); +typedef void (APIENTRYP PFNGLLIGHTIPROC) ( GLenum light, GLenum pname, GLint param ); +typedef void (APIENTRYP PFNGLLIGHTFVPROC) ( GLenum light, GLenum pname, + const GLfloat *params ); +typedef void (APIENTRYP PFNGLLIGHTIVPROC) ( GLenum light, GLenum pname, + const GLint *params ); + +typedef void (APIENTRYP PFNGLGETLIGHTFVPROC) ( GLenum light, GLenum pname, + GLfloat *params ); +typedef void (APIENTRYP PFNGLGETLIGHTIVPROC) ( GLenum light, GLenum pname, + GLint *params ); + +typedef void (APIENTRYP PFNGLLIGHTMODELFPROC) ( GLenum pname, GLfloat param ); +typedef void (APIENTRYP PFNGLLIGHTMODELIPROC) ( GLenum pname, GLint param ); +typedef void (APIENTRYP PFNGLLIGHTMODELFVPROC) ( GLenum pname, const GLfloat *params ); +typedef void (APIENTRYP PFNGLLIGHTMODELIVPROC) ( GLenum pname, const GLint *params ); + +typedef void (APIENTRYP PFNGLMATERIALFPROC) ( GLenum face, GLenum pname, GLfloat param ); +typedef void (APIENTRYP PFNGLMATERIALIPROC) ( GLenum face, GLenum pname, GLint param ); +typedef void (APIENTRYP PFNGLMATERIALFVPROC) ( GLenum face, GLenum pname, const GLfloat *params ); +typedef void (APIENTRYP PFNGLMATERIALIVPROC) ( GLenum face, GLenum pname, const GLint *params ); + +typedef void (APIENTRYP PFNGLGETMATERIALFVPROC) ( GLenum face, GLenum pname, GLfloat *params ); +typedef void (APIENTRYP PFNGLGETMATERIALIVPROC) ( GLenum face, GLenum pname, GLint *params ); + +typedef void (APIENTRYP PFNGLCOLORMATERIALPROC) ( GLenum face, GLenum mode ); + + +/* + * Raster functions + */ + +typedef void (APIENTRYP PFNGLPIXELZOOMPROC) ( GLfloat xfactor, GLfloat yfactor ); + +typedef void (APIENTRYP PFNGLPIXELSTOREFPROC) ( GLenum pname, GLfloat param ); +typedef void (APIENTRYP PFNGLPIXELSTOREIPROC) ( GLenum pname, GLint param ); + +typedef void (APIENTRYP PFNGLPIXELTRANSFERFPROC) ( GLenum pname, GLfloat param ); +typedef void (APIENTRYP PFNGLPIXELTRANSFERIPROC) ( GLenum pname, GLint param ); + +typedef void (APIENTRYP PFNGLPIXELMAPFVPROC) ( GLenum map, GLsizei mapsize, + const GLfloat *values ); +typedef void (APIENTRYP PFNGLPIXELMAPUIVPROC) ( GLenum map, GLsizei mapsize, + const GLuint *values ); +typedef void (APIENTRYP PFNGLPIXELMAPUSVPROC) ( GLenum map, GLsizei mapsize, + const GLushort *values ); + +typedef void (APIENTRYP PFNGLGETPIXELMAPFVPROC) ( GLenum map, GLfloat *values ); +typedef void (APIENTRYP PFNGLGETPIXELMAPUIVPROC) ( GLenum map, GLuint *values ); +typedef void (APIENTRYP PFNGLGETPIXELMAPUSVPROC) ( GLenum map, GLushort *values ); + +typedef void (APIENTRYP PFNGLBITMAPPROC) ( GLsizei width, GLsizei height, + GLfloat xorig, GLfloat yorig, + GLfloat xmove, GLfloat ymove, + const GLubyte *bitmap ); + +typedef void (APIENTRYP PFNGLREADPIXELSPROC) ( GLint x, GLint y, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + GLvoid *pixels ); + +typedef void (APIENTRYP PFNGLDRAWPIXELSPROC) ( GLsizei width, GLsizei height, + GLenum format, GLenum type, + const GLvoid *pixels ); + +typedef void (APIENTRYP PFNGLCOPYPIXELSPROC) ( GLint x, GLint y, + GLsizei width, GLsizei height, + GLenum type ); + +/* + * Stenciling + */ + +typedef void (APIENTRYP PFNGLSTENCILFUNCPROC) ( GLenum func, GLint ref, GLuint mask ); + +typedef void (APIENTRYP PFNGLSTENCILMASKPROC) ( GLuint mask ); + +typedef void (APIENTRYP PFNGLSTENCILOPPROC) ( GLenum fail, GLenum zfail, GLenum zpass ); + +typedef void (APIENTRYP PFNGLCLEARSTENCILPROC) ( GLint s ); + + + +/* + * Texture mapping + */ + +typedef void (APIENTRYP PFNGLTEXGENDPROC) ( GLenum coord, GLenum pname, GLdouble param ); +typedef void (APIENTRYP PFNGLTEXGENFPROC) ( GLenum coord, GLenum pname, GLfloat param ); +typedef void (APIENTRYP PFNGLTEXGENIPROC) ( GLenum coord, GLenum pname, GLint param ); + +typedef void (APIENTRYP PFNGLTEXGENDVPROC) ( GLenum coord, GLenum pname, const GLdouble *params ); +typedef void (APIENTRYP PFNGLTEXGENFVPROC) ( GLenum coord, GLenum pname, const GLfloat *params ); +typedef void (APIENTRYP PFNGLTEXGENIVPROC) ( GLenum coord, GLenum pname, const GLint *params ); + +typedef void (APIENTRYP PFNGLGETTEXGENDVPROC) ( GLenum coord, GLenum pname, GLdouble *params ); +typedef void (APIENTRYP PFNGLGETTEXGENFVPROC) ( GLenum coord, GLenum pname, GLfloat *params ); +typedef void (APIENTRYP PFNGLGETTEXGENIVPROC) ( GLenum coord, GLenum pname, GLint *params ); + + +typedef void (APIENTRYP PFNGLTEXENVFPROC) ( GLenum target, GLenum pname, GLfloat param ); +typedef void (APIENTRYP PFNGLTEXENVIPROC) ( GLenum target, GLenum pname, GLint param ); + +typedef void (APIENTRYP PFNGLTEXENVFVPROC) ( GLenum target, GLenum pname, const GLfloat *params ); +typedef void (APIENTRYP PFNGLTEXENVIVPROC) ( GLenum target, GLenum pname, const GLint *params ); + +typedef void (APIENTRYP PFNGLGETTEXENVFVPROC) ( GLenum target, GLenum pname, GLfloat *params ); +typedef void (APIENTRYP PFNGLGETTEXENVIVPROC) ( GLenum target, GLenum pname, GLint *params ); + + +typedef void (APIENTRYP PFNGLTEXPARAMETERFPROC) ( GLenum target, GLenum pname, GLfloat param ); +typedef void (APIENTRYP PFNGLTEXPARAMETERIPROC) ( GLenum target, GLenum pname, GLint param ); + +typedef void (APIENTRYP PFNGLTEXPARAMETERFVPROC) ( GLenum target, GLenum pname, + const GLfloat *params ); +typedef void (APIENTRYP PFNGLTEXPARAMETERIVPROC) ( GLenum target, GLenum pname, + const GLint *params ); + +typedef void (APIENTRYP PFNGLGETTEXPARAMETERFVPROC) ( GLenum target, + GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIVPROC) ( GLenum target, + GLenum pname, GLint *params ); + +typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERFVPROC) ( GLenum target, GLint level, + GLenum pname, GLfloat *params ); +typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERIVPROC) ( GLenum target, GLint level, + GLenum pname, GLint *params ); + + +typedef void (APIENTRYP PFNGLTEXIMAGE1DPROC) ( GLenum target, GLint level, + GLint internalFormat, + GLsizei width, GLint border, + GLenum format, GLenum type, + const GLvoid *pixels ); + +typedef void (APIENTRYP PFNGLTEXIMAGE2DPROC) ( GLenum target, GLint level, + GLint internalFormat, + GLsizei width, GLsizei height, + GLint border, GLenum format, GLenum type, + const GLvoid *pixels ); + +typedef void (APIENTRYP PFNGLGETTEXIMAGEPROC) ( GLenum target, GLint level, + GLenum format, GLenum type, + GLvoid *pixels ); + + +/* 1.1 functions */ + +typedef void (APIENTRYP PFNGLGENTEXTURESPROC) ( GLsizei n, GLuint *textures ); + +typedef void (APIENTRYP PFNGLDELETETEXTURESPROC) ( GLsizei n, const GLuint *textures); + +typedef void (APIENTRYP PFNGLBINDTEXTUREPROC) ( GLenum target, GLuint texture ); + +typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESPROC) ( GLsizei n, + const GLuint *textures, + const GLclampf *priorities ); + +typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTPROC) ( GLsizei n, + const GLuint *textures, + GLboolean *residences ); + +typedef GLboolean (APIENTRYP PFNGLISTEXTUREPROC) ( GLuint texture ); + + +typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DPROC) ( GLenum target, GLint level, + GLint xoffset, + GLsizei width, GLenum format, + GLenum type, const GLvoid *pixels ); + + +typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DPROC) ( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + const GLvoid *pixels ); + + +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DPROC) ( GLenum target, GLint level, + GLenum internalformat, + GLint x, GLint y, + GLsizei width, GLint border ); + + +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DPROC) ( GLenum target, GLint level, + GLenum internalformat, + GLint x, GLint y, + GLsizei width, GLsizei height, + GLint border ); + + +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DPROC) ( GLenum target, GLint level, + GLint xoffset, GLint x, GLint y, + GLsizei width ); + + +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DPROC) ( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint x, GLint y, + GLsizei width, GLsizei height ); + + +/* + * Evaluators + */ + +typedef void (APIENTRYP PFNGLMAP1DPROC) ( GLenum target, GLdouble u1, GLdouble u2, + GLint stride, + GLint order, const GLdouble *points ); +typedef void (APIENTRYP PFNGLMAP1FPROC) ( GLenum target, GLfloat u1, GLfloat u2, + GLint stride, + GLint order, const GLfloat *points ); + +typedef void (APIENTRYP PFNGLMAP2DPROC) ( GLenum target, + GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, + GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, + const GLdouble *points ); +typedef void (APIENTRYP PFNGLMAP2FPROC) ( GLenum target, + GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, + GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, + const GLfloat *points ); + +typedef void (APIENTRYP PFNGLGETMAPDVPROC) ( GLenum target, GLenum query, GLdouble *v ); +typedef void (APIENTRYP PFNGLGETMAPFVPROC) ( GLenum target, GLenum query, GLfloat *v ); +typedef void (APIENTRYP PFNGLGETMAPIVPROC) ( GLenum target, GLenum query, GLint *v ); + +typedef void (APIENTRYP PFNGLEVALCOORD1DPROC) ( GLdouble u ); +typedef void (APIENTRYP PFNGLEVALCOORD1FPROC) ( GLfloat u ); + +typedef void (APIENTRYP PFNGLEVALCOORD1DVPROC) ( const GLdouble *u ); +typedef void (APIENTRYP PFNGLEVALCOORD1FVPROC) ( const GLfloat *u ); + +typedef void (APIENTRYP PFNGLEVALCOORD2DPROC) ( GLdouble u, GLdouble v ); +typedef void (APIENTRYP PFNGLEVALCOORD2FPROC) ( GLfloat u, GLfloat v ); + +typedef void (APIENTRYP PFNGLEVALCOORD2DVPROC) ( const GLdouble *u ); +typedef void (APIENTRYP PFNGLEVALCOORD2FVPROC) ( const GLfloat *u ); + +typedef void (APIENTRYP PFNGLMAPGRID1DPROC) ( GLint un, GLdouble u1, GLdouble u2 ); +typedef void (APIENTRYP PFNGLMAPGRID1FPROC) ( GLint un, GLfloat u1, GLfloat u2 ); + +typedef void (APIENTRYP PFNGLMAPGRID2DPROC) ( GLint un, GLdouble u1, GLdouble u2, + GLint vn, GLdouble v1, GLdouble v2 ); +typedef void (APIENTRYP PFNGLMAPGRID2FPROC) ( GLint un, GLfloat u1, GLfloat u2, + GLint vn, GLfloat v1, GLfloat v2 ); + +typedef void (APIENTRYP PFNGLEVALPOINT1PROC) ( GLint i ); + +typedef void (APIENTRYP PFNGLEVALPOINT2PROC) ( GLint i, GLint j ); + +typedef void (APIENTRYP PFNGLEVALMESH1PROC) ( GLenum mode, GLint i1, GLint i2 ); + +typedef void (APIENTRYP PFNGLEVALMESH2PROC) ( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 ); + + +/* + * Fog + */ + +typedef void (APIENTRYP PFNGLFOGFPROC) ( GLenum pname, GLfloat param ); + +typedef void (APIENTRYP PFNGLFOGIPROC) ( GLenum pname, GLint param ); + +typedef void (APIENTRYP PFNGLFOGFVPROC) ( GLenum pname, const GLfloat *params ); + +typedef void (APIENTRYP PFNGLFOGIVPROC) ( GLenum pname, const GLint *params ); + + +/* + * Selection and Feedback + */ + +typedef void (APIENTRYP PFNGLFEEDBACKBUFFERPROC) ( GLsizei size, GLenum type, GLfloat *buffer ); + +typedef void (APIENTRYP PFNGLPASSTHROUGHPROC) ( GLfloat token ); + +typedef void (APIENTRYP PFNGLSELECTBUFFERPROC) ( GLsizei size, GLuint *buffer ); + +typedef void (APIENTRYP PFNGLINITNAMESPROC) ( void ); + +typedef void (APIENTRYP PFNGLLOADNAMEPROC) ( GLuint name ); + +typedef void (APIENTRYP PFNGLPUSHNAMEPROC) ( GLuint name ); + +typedef void (APIENTRYP PFNGLPOPNAMEPROC) ( void ); +#endif + + +/* + * OpenGL 1.2 + */ + +#define GL_RESCALE_NORMAL 0x803A +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_BGR 0x80E0 +#define GL_BGRA 0x80E1 +#define GL_UNSIGNED_BYTE_3_3_2 0x8032 +#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 +#define GL_UNSIGNED_INT_8_8_8_8 0x8035 +#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 +#define GL_UNSIGNED_INT_10_10_10_2 0x8036 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 +#define GL_SINGLE_COLOR 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR 0x81FA +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_BASE_LEVEL 0x813C +#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 +#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 +#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#define GL_PACK_SKIP_IMAGES 0x806B +#define GL_PACK_IMAGE_HEIGHT 0x806C +#define GL_UNPACK_SKIP_IMAGES 0x806D +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#define GL_TEXTURE_3D 0x806F +#define GL_PROXY_TEXTURE_3D 0x8070 +#define GL_TEXTURE_DEPTH 0x8071 +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_TEXTURE_BINDING_3D 0x806A + +#ifndef SDL_OPENGL_1_NO_PROTOTYPES + +GLAPI void GLAPIENTRY glDrawRangeElements( GLenum mode, GLuint start, + GLuint end, GLsizei count, GLenum type, const GLvoid *indices ); + +GLAPI void GLAPIENTRY glTexImage3D( GLenum target, GLint level, + GLint internalFormat, + GLsizei width, GLsizei height, + GLsizei depth, GLint border, + GLenum format, GLenum type, + const GLvoid *pixels ); + +GLAPI void GLAPIENTRY glTexSubImage3D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint zoffset, GLsizei width, + GLsizei height, GLsizei depth, + GLenum format, + GLenum type, const GLvoid *pixels); + +GLAPI void GLAPIENTRY glCopyTexSubImage3D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint zoffset, GLint x, + GLint y, GLsizei width, + GLsizei height ); + +#endif +#ifdef SDL_OPENGL_1_FUNCTION_TYPEDEFS + +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) ( GLenum mode, GLuint start, + GLuint end, GLsizei count, GLenum type, const GLvoid *indices ); + +typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) ( GLenum target, GLint level, + GLint internalFormat, + GLsizei width, GLsizei height, + GLsizei depth, GLint border, + GLenum format, GLenum type, + const GLvoid *pixels ); + +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) ( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint zoffset, GLsizei width, + GLsizei height, GLsizei depth, + GLenum format, + GLenum type, const GLvoid *pixels); + +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) ( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint zoffset, GLint x, + GLint y, GLsizei width, + GLsizei height ); + +#endif + +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); + + +/* + * GL_ARB_imaging + */ + +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_COLOR_TABLE 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 +#define GL_PROXY_COLOR_TABLE 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 +#define GL_COLOR_TABLE_SCALE 0x80D6 +#define GL_COLOR_TABLE_BIAS 0x80D7 +#define GL_COLOR_TABLE_FORMAT 0x80D8 +#define GL_COLOR_TABLE_WIDTH 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF +#define GL_CONVOLUTION_1D 0x8010 +#define GL_CONVOLUTION_2D 0x8011 +#define GL_SEPARABLE_2D 0x8012 +#define GL_CONVOLUTION_BORDER_MODE 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS 0x8015 +#define GL_REDUCE 0x8016 +#define GL_CONVOLUTION_FORMAT 0x8017 +#define GL_CONVOLUTION_WIDTH 0x8018 +#define GL_CONVOLUTION_HEIGHT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 +#define GL_CONSTANT_BORDER 0x8151 +#define GL_REPLICATE_BORDER 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR 0x8154 +#define GL_COLOR_MATRIX 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB +#define GL_HISTOGRAM 0x8024 +#define GL_PROXY_HISTOGRAM 0x8025 +#define GL_HISTOGRAM_WIDTH 0x8026 +#define GL_HISTOGRAM_FORMAT 0x8027 +#define GL_HISTOGRAM_RED_SIZE 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C +#define GL_HISTOGRAM_SINK 0x802D +#define GL_MINMAX 0x802E +#define GL_MINMAX_FORMAT 0x802F +#define GL_MINMAX_SINK 0x8030 +#define GL_TABLE_TOO_LARGE 0x8031 +#define GL_BLEND_EQUATION 0x8009 +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +#define GL_FUNC_ADD 0x8006 +#define GL_FUNC_SUBTRACT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#define GL_BLEND_COLOR 0x8005 + + +#ifndef SDL_OPENGL_1_NO_PROTOTYPES + +GLAPI void GLAPIENTRY glColorTable( GLenum target, GLenum internalformat, + GLsizei width, GLenum format, + GLenum type, const GLvoid *table ); + +GLAPI void GLAPIENTRY glColorSubTable( GLenum target, + GLsizei start, GLsizei count, + GLenum format, GLenum type, + const GLvoid *data ); + +GLAPI void GLAPIENTRY glColorTableParameteriv(GLenum target, GLenum pname, + const GLint *params); + +GLAPI void GLAPIENTRY glColorTableParameterfv(GLenum target, GLenum pname, + const GLfloat *params); + +GLAPI void GLAPIENTRY glCopyColorSubTable( GLenum target, GLsizei start, + GLint x, GLint y, GLsizei width ); + +GLAPI void GLAPIENTRY glCopyColorTable( GLenum target, GLenum internalformat, + GLint x, GLint y, GLsizei width ); + +GLAPI void GLAPIENTRY glGetColorTable( GLenum target, GLenum format, + GLenum type, GLvoid *table ); + +GLAPI void GLAPIENTRY glGetColorTableParameterfv( GLenum target, GLenum pname, + GLfloat *params ); + +GLAPI void GLAPIENTRY glGetColorTableParameteriv( GLenum target, GLenum pname, + GLint *params ); + +GLAPI void GLAPIENTRY glBlendEquation( GLenum mode ); + +GLAPI void GLAPIENTRY glBlendColor( GLclampf red, GLclampf green, + GLclampf blue, GLclampf alpha ); + +GLAPI void GLAPIENTRY glHistogram( GLenum target, GLsizei width, + GLenum internalformat, GLboolean sink ); + +GLAPI void GLAPIENTRY glResetHistogram( GLenum target ); + +GLAPI void GLAPIENTRY glGetHistogram( GLenum target, GLboolean reset, + GLenum format, GLenum type, + GLvoid *values ); + +GLAPI void GLAPIENTRY glGetHistogramParameterfv( GLenum target, GLenum pname, + GLfloat *params ); + +GLAPI void GLAPIENTRY glGetHistogramParameteriv( GLenum target, GLenum pname, + GLint *params ); + +GLAPI void GLAPIENTRY glMinmax( GLenum target, GLenum internalformat, + GLboolean sink ); + +GLAPI void GLAPIENTRY glResetMinmax( GLenum target ); + +GLAPI void GLAPIENTRY glGetMinmax( GLenum target, GLboolean reset, + GLenum format, GLenum types, + GLvoid *values ); + +GLAPI void GLAPIENTRY glGetMinmaxParameterfv( GLenum target, GLenum pname, + GLfloat *params ); + +GLAPI void GLAPIENTRY glGetMinmaxParameteriv( GLenum target, GLenum pname, + GLint *params ); + +GLAPI void GLAPIENTRY glConvolutionFilter1D( GLenum target, + GLenum internalformat, GLsizei width, GLenum format, GLenum type, + const GLvoid *image ); + +GLAPI void GLAPIENTRY glConvolutionFilter2D( GLenum target, + GLenum internalformat, GLsizei width, GLsizei height, GLenum format, + GLenum type, const GLvoid *image ); + +GLAPI void GLAPIENTRY glConvolutionParameterf( GLenum target, GLenum pname, + GLfloat params ); + +GLAPI void GLAPIENTRY glConvolutionParameterfv( GLenum target, GLenum pname, + const GLfloat *params ); + +GLAPI void GLAPIENTRY glConvolutionParameteri( GLenum target, GLenum pname, + GLint params ); + +GLAPI void GLAPIENTRY glConvolutionParameteriv( GLenum target, GLenum pname, + const GLint *params ); + +GLAPI void GLAPIENTRY glCopyConvolutionFilter1D( GLenum target, + GLenum internalformat, GLint x, GLint y, GLsizei width ); + +GLAPI void GLAPIENTRY glCopyConvolutionFilter2D( GLenum target, + GLenum internalformat, GLint x, GLint y, GLsizei width, + GLsizei height); + +GLAPI void GLAPIENTRY glGetConvolutionFilter( GLenum target, GLenum format, + GLenum type, GLvoid *image ); + +GLAPI void GLAPIENTRY glGetConvolutionParameterfv( GLenum target, GLenum pname, + GLfloat *params ); + +GLAPI void GLAPIENTRY glGetConvolutionParameteriv( GLenum target, GLenum pname, + GLint *params ); + +GLAPI void GLAPIENTRY glSeparableFilter2D( GLenum target, + GLenum internalformat, GLsizei width, GLsizei height, GLenum format, + GLenum type, const GLvoid *row, const GLvoid *column ); + +GLAPI void GLAPIENTRY glGetSeparableFilter( GLenum target, GLenum format, + GLenum type, GLvoid *row, GLvoid *column, GLvoid *span ); + +#endif +#ifdef SDL_OPENGL_1_FUNCTION_TYPEDEFS + +typedef void (APIENTRYP PFNGLCOLORTABLEPROC) ( GLenum target, GLenum internalformat, + GLsizei width, GLenum format, + GLenum type, const GLvoid *table ); + +typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) ( GLenum target, + GLsizei start, GLsizei count, + GLenum format, GLenum type, + const GLvoid *data ); + +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, + const GLint *params); + +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, + const GLfloat *params); + +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) ( GLenum target, GLsizei start, + GLint x, GLint y, GLsizei width ); + +typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) ( GLenum target, GLenum internalformat, + GLint x, GLint y, GLsizei width ); + +typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) ( GLenum target, GLenum format, + GLenum type, GLvoid *table ); + +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) ( GLenum target, GLenum pname, + GLfloat *params ); + +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) ( GLenum target, GLenum pname, + GLint *params ); + +typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) ( GLenum mode ); + +typedef void (APIENTRYP PFNGLBLENDCOLORPROC) ( GLclampf red, GLclampf green, + GLclampf blue, GLclampf alpha ); + +typedef void (APIENTRYP PFNGLHISTOGRAMPROC) ( GLenum target, GLsizei width, + GLenum internalformat, GLboolean sink ); + +typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) ( GLenum target ); + +typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) ( GLenum target, GLboolean reset, + GLenum format, GLenum type, + GLvoid *values ); + +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) ( GLenum target, GLenum pname, + GLfloat *params ); + +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) ( GLenum target, GLenum pname, + GLint *params ); + +typedef void (APIENTRYP PFNGLMINMAXPROC) ( GLenum target, GLenum internalformat, + GLboolean sink ); + +typedef void (APIENTRYP PFNGLRESETMINMAXPROC) ( GLenum target ); + +typedef void (APIENTRYP PFNGLGETMINMAXPROC) ( GLenum target, GLboolean reset, + GLenum format, GLenum types, + GLvoid *values ); + +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) ( GLenum target, GLenum pname, + GLfloat *params ); + +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) ( GLenum target, GLenum pname, + GLint *params ); + +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) ( GLenum target, + GLenum internalformat, GLsizei width, GLenum format, GLenum type, + const GLvoid *image ); + +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) ( GLenum target, + GLenum internalformat, GLsizei width, GLsizei height, GLenum format, + GLenum type, const GLvoid *image ); + +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) ( GLenum target, GLenum pname, + GLfloat params ); + +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) ( GLenum target, GLenum pname, + const GLfloat *params ); + +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) ( GLenum target, GLenum pname, + GLint params ); + +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) ( GLenum target, GLenum pname, + const GLint *params ); + +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) ( GLenum target, + GLenum internalformat, GLint x, GLint y, GLsizei width ); + +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) ( GLenum target, + GLenum internalformat, GLint x, GLint y, GLsizei width, + GLsizei height); + +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) ( GLenum target, GLenum format, + GLenum type, GLvoid *image ); + +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) ( GLenum target, GLenum pname, + GLfloat *params ); + +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) ( GLenum target, GLenum pname, + GLint *params ); + +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) ( GLenum target, + GLenum internalformat, GLsizei width, GLsizei height, GLenum format, + GLenum type, const GLvoid *row, const GLvoid *column ); + +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) ( GLenum target, GLenum format, + GLenum type, GLvoid *row, GLvoid *column, GLvoid *span ); + +#endif + + + + +/* + * OpenGL 1.3 + */ + +/* multitexture */ +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 +#define GL_MAX_TEXTURE_UNITS 0x84E2 +/* texture_cube_map */ +#define GL_NORMAL_MAP 0x8511 +#define GL_REFLECTION_MAP 0x8512 +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +/* texture_compression */ +#define GL_COMPRESSED_ALPHA 0x84E9 +#define GL_COMPRESSED_LUMINANCE 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB +#define GL_COMPRESSED_INTENSITY 0x84EC +#define GL_COMPRESSED_RGB 0x84ED +#define GL_COMPRESSED_RGBA 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 +#define GL_TEXTURE_COMPRESSED 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +/* multisample */ +#define GL_MULTISAMPLE 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE 0x809F +#define GL_SAMPLE_COVERAGE 0x80A0 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#define GL_MULTISAMPLE_BIT 0x20000000 +/* transpose_matrix */ +#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 +/* texture_env_combine */ +#define GL_COMBINE 0x8570 +#define GL_COMBINE_RGB 0x8571 +#define GL_COMBINE_ALPHA 0x8572 +#define GL_SOURCE0_RGB 0x8580 +#define GL_SOURCE1_RGB 0x8581 +#define GL_SOURCE2_RGB 0x8582 +#define GL_SOURCE0_ALPHA 0x8588 +#define GL_SOURCE1_ALPHA 0x8589 +#define GL_SOURCE2_ALPHA 0x858A +#define GL_OPERAND0_RGB 0x8590 +#define GL_OPERAND1_RGB 0x8591 +#define GL_OPERAND2_RGB 0x8592 +#define GL_OPERAND0_ALPHA 0x8598 +#define GL_OPERAND1_ALPHA 0x8599 +#define GL_OPERAND2_ALPHA 0x859A +#define GL_RGB_SCALE 0x8573 +#define GL_ADD_SIGNED 0x8574 +#define GL_INTERPOLATE 0x8575 +#define GL_SUBTRACT 0x84E7 +#define GL_CONSTANT 0x8576 +#define GL_PRIMARY_COLOR 0x8577 +#define GL_PREVIOUS 0x8578 +/* texture_env_dot3 */ +#define GL_DOT3_RGB 0x86AE +#define GL_DOT3_RGBA 0x86AF +/* texture_border_clamp */ +#define GL_CLAMP_TO_BORDER 0x812D + +#ifndef SDL_OPENGL_1_NO_PROTOTYPES + +GLAPI void GLAPIENTRY glActiveTexture( GLenum texture ); + +GLAPI void GLAPIENTRY glClientActiveTexture( GLenum texture ); + +GLAPI void GLAPIENTRY glCompressedTexImage1D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data ); + +GLAPI void GLAPIENTRY glCompressedTexImage2D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data ); + +GLAPI void GLAPIENTRY glCompressedTexImage3D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data ); + +GLAPI void GLAPIENTRY glCompressedTexSubImage1D( GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data ); + +GLAPI void GLAPIENTRY glCompressedTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data ); + +GLAPI void GLAPIENTRY glCompressedTexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data ); + +GLAPI void GLAPIENTRY glGetCompressedTexImage( GLenum target, GLint lod, GLvoid *img ); + +GLAPI void GLAPIENTRY glMultiTexCoord1d( GLenum target, GLdouble s ); + +GLAPI void GLAPIENTRY glMultiTexCoord1dv( GLenum target, const GLdouble *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord1f( GLenum target, GLfloat s ); + +GLAPI void GLAPIENTRY glMultiTexCoord1fv( GLenum target, const GLfloat *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord1i( GLenum target, GLint s ); + +GLAPI void GLAPIENTRY glMultiTexCoord1iv( GLenum target, const GLint *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord1s( GLenum target, GLshort s ); + +GLAPI void GLAPIENTRY glMultiTexCoord1sv( GLenum target, const GLshort *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord2d( GLenum target, GLdouble s, GLdouble t ); + +GLAPI void GLAPIENTRY glMultiTexCoord2dv( GLenum target, const GLdouble *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord2f( GLenum target, GLfloat s, GLfloat t ); + +GLAPI void GLAPIENTRY glMultiTexCoord2fv( GLenum target, const GLfloat *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord2i( GLenum target, GLint s, GLint t ); + +GLAPI void GLAPIENTRY glMultiTexCoord2iv( GLenum target, const GLint *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord2s( GLenum target, GLshort s, GLshort t ); + +GLAPI void GLAPIENTRY glMultiTexCoord2sv( GLenum target, const GLshort *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord3d( GLenum target, GLdouble s, GLdouble t, GLdouble r ); + +GLAPI void GLAPIENTRY glMultiTexCoord3dv( GLenum target, const GLdouble *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord3f( GLenum target, GLfloat s, GLfloat t, GLfloat r ); + +GLAPI void GLAPIENTRY glMultiTexCoord3fv( GLenum target, const GLfloat *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord3i( GLenum target, GLint s, GLint t, GLint r ); + +GLAPI void GLAPIENTRY glMultiTexCoord3iv( GLenum target, const GLint *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord3s( GLenum target, GLshort s, GLshort t, GLshort r ); + +GLAPI void GLAPIENTRY glMultiTexCoord3sv( GLenum target, const GLshort *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord4d( GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q ); + +GLAPI void GLAPIENTRY glMultiTexCoord4dv( GLenum target, const GLdouble *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord4f( GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q ); + +GLAPI void GLAPIENTRY glMultiTexCoord4fv( GLenum target, const GLfloat *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord4i( GLenum target, GLint s, GLint t, GLint r, GLint q ); + +GLAPI void GLAPIENTRY glMultiTexCoord4iv( GLenum target, const GLint *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord4s( GLenum target, GLshort s, GLshort t, GLshort r, GLshort q ); + +GLAPI void GLAPIENTRY glMultiTexCoord4sv( GLenum target, const GLshort *v ); + + +GLAPI void GLAPIENTRY glLoadTransposeMatrixd( const GLdouble m[16] ); + +GLAPI void GLAPIENTRY glLoadTransposeMatrixf( const GLfloat m[16] ); + +GLAPI void GLAPIENTRY glMultTransposeMatrixd( const GLdouble m[16] ); + +GLAPI void GLAPIENTRY glMultTransposeMatrixf( const GLfloat m[16] ); + +GLAPI void GLAPIENTRY glSampleCoverage( GLclampf value, GLboolean invert ); + +#endif +#ifdef SDL_OPENGL_1_FUNCTION_TYPEDEFS + +typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) ( GLenum texture ); + +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) ( GLenum texture ); + +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) ( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data ); + +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) ( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data ); + +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) ( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data ); + +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) ( GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data ); + +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) ( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data ); + +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) ( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data ); + +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) ( GLenum target, GLint lod, GLvoid *img ); + +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) ( GLenum target, GLdouble s ); + +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) ( GLenum target, const GLdouble *v ); + +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) ( GLenum target, GLfloat s ); + +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) ( GLenum target, const GLfloat *v ); + +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) ( GLenum target, GLint s ); + +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) ( GLenum target, const GLint *v ); + +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) ( GLenum target, GLshort s ); + +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) ( GLenum target, const GLshort *v ); + +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) ( GLenum target, GLdouble s, GLdouble t ); + +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) ( GLenum target, const GLdouble *v ); + +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) ( GLenum target, GLfloat s, GLfloat t ); + +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) ( GLenum target, const GLfloat *v ); + +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) ( GLenum target, GLint s, GLint t ); + +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) ( GLenum target, const GLint *v ); + +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) ( GLenum target, GLshort s, GLshort t ); + +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) ( GLenum target, const GLshort *v ); + +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) ( GLenum target, GLdouble s, GLdouble t, GLdouble r ); + +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) ( GLenum target, const GLdouble *v ); + +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) ( GLenum target, GLfloat s, GLfloat t, GLfloat r ); + +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) ( GLenum target, const GLfloat *v ); + +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) ( GLenum target, GLint s, GLint t, GLint r ); + +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) ( GLenum target, const GLint *v ); + +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) ( GLenum target, GLshort s, GLshort t, GLshort r ); + +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) ( GLenum target, const GLshort *v ); + +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) ( GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q ); + +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) ( GLenum target, const GLdouble *v ); + +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) ( GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q ); + +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) ( GLenum target, const GLfloat *v ); + +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) ( GLenum target, GLint s, GLint t, GLint r, GLint q ); + +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) ( GLenum target, const GLint *v ); + +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) ( GLenum target, GLshort s, GLshort t, GLshort r, GLshort q ); + +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) ( GLenum target, const GLshort *v ); + + +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) ( const GLdouble m[16] ); + +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) ( const GLfloat m[16] ); + +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) ( const GLdouble m[16] ); + +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) ( const GLfloat m[16] ); + +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) ( GLclampf value, GLboolean invert ); + +#endif + + +typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img); + + + +/* + * GL_ARB_multitexture (ARB extension 1 and OpenGL 1.2.1) + */ +#ifndef GL_ARB_multitexture +#define GL_ARB_multitexture 1 + +#define GL_TEXTURE0_ARB 0x84C0 +#define GL_TEXTURE1_ARB 0x84C1 +#define GL_TEXTURE2_ARB 0x84C2 +#define GL_TEXTURE3_ARB 0x84C3 +#define GL_TEXTURE4_ARB 0x84C4 +#define GL_TEXTURE5_ARB 0x84C5 +#define GL_TEXTURE6_ARB 0x84C6 +#define GL_TEXTURE7_ARB 0x84C7 +#define GL_TEXTURE8_ARB 0x84C8 +#define GL_TEXTURE9_ARB 0x84C9 +#define GL_TEXTURE10_ARB 0x84CA +#define GL_TEXTURE11_ARB 0x84CB +#define GL_TEXTURE12_ARB 0x84CC +#define GL_TEXTURE13_ARB 0x84CD +#define GL_TEXTURE14_ARB 0x84CE +#define GL_TEXTURE15_ARB 0x84CF +#define GL_TEXTURE16_ARB 0x84D0 +#define GL_TEXTURE17_ARB 0x84D1 +#define GL_TEXTURE18_ARB 0x84D2 +#define GL_TEXTURE19_ARB 0x84D3 +#define GL_TEXTURE20_ARB 0x84D4 +#define GL_TEXTURE21_ARB 0x84D5 +#define GL_TEXTURE22_ARB 0x84D6 +#define GL_TEXTURE23_ARB 0x84D7 +#define GL_TEXTURE24_ARB 0x84D8 +#define GL_TEXTURE25_ARB 0x84D9 +#define GL_TEXTURE26_ARB 0x84DA +#define GL_TEXTURE27_ARB 0x84DB +#define GL_TEXTURE28_ARB 0x84DC +#define GL_TEXTURE29_ARB 0x84DD +#define GL_TEXTURE30_ARB 0x84DE +#define GL_TEXTURE31_ARB 0x84DF +#define GL_ACTIVE_TEXTURE_ARB 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 +#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 + +#ifndef SDL_OPENGL_1_NO_PROTOTYPES + +GLAPI void GLAPIENTRY glActiveTextureARB(GLenum texture); +GLAPI void GLAPIENTRY glClientActiveTextureARB(GLenum texture); +GLAPI void GLAPIENTRY glMultiTexCoord1dARB(GLenum target, GLdouble s); +GLAPI void GLAPIENTRY glMultiTexCoord1dvARB(GLenum target, const GLdouble *v); +GLAPI void GLAPIENTRY glMultiTexCoord1fARB(GLenum target, GLfloat s); +GLAPI void GLAPIENTRY glMultiTexCoord1fvARB(GLenum target, const GLfloat *v); +GLAPI void GLAPIENTRY glMultiTexCoord1iARB(GLenum target, GLint s); +GLAPI void GLAPIENTRY glMultiTexCoord1ivARB(GLenum target, const GLint *v); +GLAPI void GLAPIENTRY glMultiTexCoord1sARB(GLenum target, GLshort s); +GLAPI void GLAPIENTRY glMultiTexCoord1svARB(GLenum target, const GLshort *v); +GLAPI void GLAPIENTRY glMultiTexCoord2dARB(GLenum target, GLdouble s, GLdouble t); +GLAPI void GLAPIENTRY glMultiTexCoord2dvARB(GLenum target, const GLdouble *v); +GLAPI void GLAPIENTRY glMultiTexCoord2fARB(GLenum target, GLfloat s, GLfloat t); +GLAPI void GLAPIENTRY glMultiTexCoord2fvARB(GLenum target, const GLfloat *v); +GLAPI void GLAPIENTRY glMultiTexCoord2iARB(GLenum target, GLint s, GLint t); +GLAPI void GLAPIENTRY glMultiTexCoord2ivARB(GLenum target, const GLint *v); +GLAPI void GLAPIENTRY glMultiTexCoord2sARB(GLenum target, GLshort s, GLshort t); +GLAPI void GLAPIENTRY glMultiTexCoord2svARB(GLenum target, const GLshort *v); +GLAPI void GLAPIENTRY glMultiTexCoord3dARB(GLenum target, GLdouble s, GLdouble t, GLdouble r); +GLAPI void GLAPIENTRY glMultiTexCoord3dvARB(GLenum target, const GLdouble *v); +GLAPI void GLAPIENTRY glMultiTexCoord3fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r); +GLAPI void GLAPIENTRY glMultiTexCoord3fvARB(GLenum target, const GLfloat *v); +GLAPI void GLAPIENTRY glMultiTexCoord3iARB(GLenum target, GLint s, GLint t, GLint r); +GLAPI void GLAPIENTRY glMultiTexCoord3ivARB(GLenum target, const GLint *v); +GLAPI void GLAPIENTRY glMultiTexCoord3sARB(GLenum target, GLshort s, GLshort t, GLshort r); +GLAPI void GLAPIENTRY glMultiTexCoord3svARB(GLenum target, const GLshort *v); +GLAPI void GLAPIENTRY glMultiTexCoord4dARB(GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +GLAPI void GLAPIENTRY glMultiTexCoord4dvARB(GLenum target, const GLdouble *v); +GLAPI void GLAPIENTRY glMultiTexCoord4fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +GLAPI void GLAPIENTRY glMultiTexCoord4fvARB(GLenum target, const GLfloat *v); +GLAPI void GLAPIENTRY glMultiTexCoord4iARB(GLenum target, GLint s, GLint t, GLint r, GLint q); +GLAPI void GLAPIENTRY glMultiTexCoord4ivARB(GLenum target, const GLint *v); +GLAPI void GLAPIENTRY glMultiTexCoord4sARB(GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +GLAPI void GLAPIENTRY glMultiTexCoord4svARB(GLenum target, const GLshort *v); + +#endif +#ifdef SDL_OPENGL_1_FUNCTION_TYPEDEFS + +typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); + +#endif + +typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); + +#endif /* GL_ARB_multitexture */ + + + +/* + * Define this token if you want "old-style" header file behaviour (extensions + * defined in gl.h). Otherwise, extensions will be included from glext.h. + */ +#if !defined(NO_SDL_GLEXT) && !defined(GL_GLEXT_LEGACY) +#include +#endif /* GL_GLEXT_LEGACY */ + + + +/********************************************************************** + * Begin system-specific stuff + */ +#if defined(PRAGMA_EXPORT_SUPPORTED) +#pragma export off +#endif + +/* + * End system-specific stuff + **********************************************************************/ + + +#ifdef __cplusplus +} +#endif + +#endif /* __gl_h_ */ + +#endif /* !SDL_PLATFORM_IOS */ + +#endif /* SDL_opengl_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_opengl_glext.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_opengl_glext.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,13213 @@ +/* SDL modified the include guard to be compatible with Mesa and Apple include guards: + * - Mesa uses: __gl_glext_h_ + * - Apple uses: __glext_h_ */ +#if !defined(__glext_h_) && !defined(__gl_glext_h_) +#define __glext_h_ 1 +#define __gl_glext_h_ 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Copyright 2013-2020 The Khronos Group Inc. +** SPDX-License-Identifier: MIT +** +** This header is generated from the Khronos OpenGL / OpenGL ES XML +** API Registry. The current version of the Registry, generator scripts +** used to make the header, and the header can be found at +** https://github.com/KhronosGroup/OpenGL-Registry +*/ + +#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN 1 +#endif +#include +#endif + +#ifndef APIENTRY +#define APIENTRY +#endif +#ifndef APIENTRYP +#define APIENTRYP APIENTRY * +#endif +#ifndef GLAPI +#define GLAPI extern +#endif + +#define GL_GLEXT_VERSION 20220530 + +/*#include */ +#ifndef __khrplatform_h_ +#define __khrplatform_h_ + +/* +** Copyright (c) 2008-2018 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +/* Khronos platform-specific types and definitions. + * + * The master copy of khrplatform.h is maintained in the Khronos EGL + * Registry repository at https://github.com/KhronosGroup/EGL-Registry + * The last semantic modification to khrplatform.h was at commit ID: + * 67a3e0864c2d75ea5287b9f3d2eb74a745936692 + * + * Adopters may modify this file to suit their platform. Adopters are + * encouraged to submit platform specific modifications to the Khronos + * group so that they can be included in future versions of this file. + * Please submit changes by filing pull requests or issues on + * the EGL Registry repository linked above. + * + * + * See the Implementer's Guidelines for information about where this file + * should be located on your system and for more details of its use: + * http://www.khronos.org/registry/implementers_guide.pdf + * + * This file should be included as + * #include + * by Khronos client API header files that use its types and defines. + * + * The types in khrplatform.h should only be used to define API-specific types. + * + * Types defined in khrplatform.h: + * khronos_int8_t signed 8 bit + * khronos_uint8_t unsigned 8 bit + * khronos_int16_t signed 16 bit + * khronos_uint16_t unsigned 16 bit + * khronos_int32_t signed 32 bit + * khronos_uint32_t unsigned 32 bit + * khronos_int64_t signed 64 bit + * khronos_uint64_t unsigned 64 bit + * khronos_intptr_t signed same number of bits as a pointer + * khronos_uintptr_t unsigned same number of bits as a pointer + * khronos_ssize_t signed size + * khronos_usize_t unsigned size + * khronos_float_t signed 32 bit floating point + * khronos_time_ns_t unsigned 64 bit time in nanoseconds + * khronos_utime_nanoseconds_t unsigned time interval or absolute time in + * nanoseconds + * khronos_stime_nanoseconds_t signed time interval in nanoseconds + * khronos_boolean_enum_t enumerated boolean type. This should + * only be used as a base type when a client API's boolean type is + * an enum. Client APIs which use an integer or other type for + * booleans cannot use this as the base type for their boolean. + * + * Tokens defined in khrplatform.h: + * + * KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values. + * + * KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0. + * KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0. + * + * Calling convention macros defined in this file: + * KHRONOS_APICALL + * KHRONOS_APIENTRY + * KHRONOS_APIATTRIBUTES + * + * These may be used in function prototypes as: + * + * KHRONOS_APICALL void KHRONOS_APIENTRY funcname( + * int arg1, + * int arg2) KHRONOS_APIATTRIBUTES; + */ + +#if defined(__SCITECH_SNAP__) && !defined(KHRONOS_STATIC) +# define KHRONOS_STATIC 1 +#endif + +/*------------------------------------------------------------------------- + * Definition of KHRONOS_APICALL + *------------------------------------------------------------------------- + * This precedes the return type of the function in the function prototype. + */ +#if defined(KHRONOS_STATIC) + /* If the preprocessor constant KHRONOS_STATIC is defined, make the + * header compatible with static linking. */ +# define KHRONOS_APICALL +#elif defined(_WIN32) +# define KHRONOS_APICALL __declspec(dllimport) +#elif defined (__SYMBIAN32__) +# define KHRONOS_APICALL IMPORT_C +#elif defined(__ANDROID__) +# define KHRONOS_APICALL __attribute__((visibility("default"))) +#else +# define KHRONOS_APICALL +#endif + +/*------------------------------------------------------------------------- + * Definition of KHRONOS_APIENTRY + *------------------------------------------------------------------------- + * This follows the return type of the function and precedes the function + * name in the function prototype. + */ +#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__) + /* Win32 but not WinCE */ +# define KHRONOS_APIENTRY __stdcall +#else +# define KHRONOS_APIENTRY +#endif + +/*------------------------------------------------------------------------- + * Definition of KHRONOS_APIATTRIBUTES + *------------------------------------------------------------------------- + * This follows the closing parenthesis of the function prototype arguments. + */ +#if defined (__ARMCC_2__) +#define KHRONOS_APIATTRIBUTES __softfp +#else +#define KHRONOS_APIATTRIBUTES +#endif + +/*------------------------------------------------------------------------- + * basic type definitions + *-----------------------------------------------------------------------*/ +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__) + + +/* + * Using + */ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 +/* + * To support platform where unsigned long cannot be used interchangeably with + * inptr_t (e.g. CHERI-extended ISAs), we can use the stdint.h intptr_t. + * Ideally, we could just use (u)intptr_t everywhere, but this could result in + * ABI breakage if khronos_uintptr_t is changed from unsigned long to + * unsigned long long or similar (this results in different C++ name mangling). + * To avoid changes for existing platforms, we restrict usage of intptr_t to + * platforms where the size of a pointer is larger than the size of long. + */ +#if defined(__SIZEOF_LONG__) && defined(__SIZEOF_POINTER__) +#if __SIZEOF_POINTER__ > __SIZEOF_LONG__ +#define KHRONOS_USE_INTPTR_T +#endif +#endif + +#elif defined(__VMS ) || defined(__sgi) + +/* + * Using + */ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(_WIN32) && !defined(__SCITECH_SNAP__) + +/* + * Win32 + */ +typedef __int32 khronos_int32_t; +typedef unsigned __int32 khronos_uint32_t; +typedef __int64 khronos_int64_t; +typedef unsigned __int64 khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(__sun__) || defined(__digital__) + +/* + * Sun or Digital + */ +typedef int khronos_int32_t; +typedef unsigned int khronos_uint32_t; +#if defined(__arch64__) || defined(_LP64) +typedef long int khronos_int64_t; +typedef unsigned long int khronos_uint64_t; +#else +typedef long long int khronos_int64_t; +typedef unsigned long long int khronos_uint64_t; +#endif /* __arch64__ */ +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif 0 + +/* + * Hypothetical platform with no float or int64 support + */ +typedef int khronos_int32_t; +typedef unsigned int khronos_uint32_t; +#define KHRONOS_SUPPORT_INT64 0 +#define KHRONOS_SUPPORT_FLOAT 0 + +#else + +/* + * Generic fallback + */ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#endif + + +/* + * Types that are (so far) the same on all platforms + */ +typedef signed char khronos_int8_t; +typedef unsigned char khronos_uint8_t; +typedef signed short int khronos_int16_t; +typedef unsigned short int khronos_uint16_t; + +/* + * Types that differ between LLP64 and LP64 architectures - in LLP64, + * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears + * to be the only LLP64 architecture in current use. + */ +#ifdef KHRONOS_USE_INTPTR_T +typedef intptr_t khronos_intptr_t; +typedef uintptr_t khronos_uintptr_t; +#elif defined(_WIN64) +typedef signed long long int khronos_intptr_t; +typedef unsigned long long int khronos_uintptr_t; +#else +typedef signed long int khronos_intptr_t; +typedef unsigned long int khronos_uintptr_t; +#endif + +#if defined(_WIN64) +typedef signed long long int khronos_ssize_t; +typedef unsigned long long int khronos_usize_t; +#else +typedef signed long int khronos_ssize_t; +typedef unsigned long int khronos_usize_t; +#endif + +#if KHRONOS_SUPPORT_FLOAT +/* + * Float type + */ +typedef float khronos_float_t; +#endif + +#if KHRONOS_SUPPORT_INT64 +/* Time types + * + * These types can be used to represent a time interval in nanoseconds or + * an absolute Unadjusted System Time. Unadjusted System Time is the number + * of nanoseconds since some arbitrary system event (e.g. since the last + * time the system booted). The Unadjusted System Time is an unsigned + * 64 bit value that wraps back to 0 every 584 years. Time intervals + * may be either signed or unsigned. + */ +typedef khronos_uint64_t khronos_utime_nanoseconds_t; +typedef khronos_int64_t khronos_stime_nanoseconds_t; +#endif + +/* + * Dummy value used to pad enum types to 32 bits. + */ +#ifndef KHRONOS_MAX_ENUM +#define KHRONOS_MAX_ENUM 0x7FFFFFFF +#endif + +/* + * Enumerated boolean type + * + * Values other than zero should be considered to be true. Therefore + * comparisons should not be made against KHRONOS_TRUE. + */ +typedef enum { + KHRONOS_FALSE = 0, + KHRONOS_TRUE = 1, + KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM +} khronos_boolean_enum_t; + +#endif /* __khrplatform_h_ */ + +/* Generated C header for: + * API: gl + * Profile: compatibility + * Versions considered: .* + * Versions emitted: 1\.[2-9]|[234]\.[0-9] + * Default extensions included: gl + * Additional extensions included: _nomatch_^ + * Extensions removed: _nomatch_^ + */ + +#ifndef GL_VERSION_1_2 +#define GL_VERSION_1_2 1 +#define GL_UNSIGNED_BYTE_3_3_2 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2 0x8036 +#define GL_TEXTURE_BINDING_3D 0x806A +#define GL_PACK_SKIP_IMAGES 0x806B +#define GL_PACK_IMAGE_HEIGHT 0x806C +#define GL_UNPACK_SKIP_IMAGES 0x806D +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#define GL_TEXTURE_3D 0x806F +#define GL_PROXY_TEXTURE_3D 0x8070 +#define GL_TEXTURE_DEPTH 0x8071 +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 +#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_BGR 0x80E0 +#define GL_BGRA 0x80E1 +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_BASE_LEVEL 0x813C +#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 +#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 +#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#define GL_RESCALE_NORMAL 0x803A +#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 +#define GL_SINGLE_COLOR 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR 0x81FA +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); +typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); +GLAPI void APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif +#endif /* GL_VERSION_1_2 */ + +#ifndef GL_VERSION_1_3 +#define GL_VERSION_1_3 1 +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_MULTISAMPLE 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE 0x809F +#define GL_SAMPLE_COVERAGE 0x80A0 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +#define GL_COMPRESSED_RGB 0x84ED +#define GL_COMPRESSED_RGBA 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 +#define GL_TEXTURE_COMPRESSED 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +#define GL_CLAMP_TO_BORDER 0x812D +#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 +#define GL_MAX_TEXTURE_UNITS 0x84E2 +#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 +#define GL_MULTISAMPLE_BIT 0x20000000 +#define GL_NORMAL_MAP 0x8511 +#define GL_REFLECTION_MAP 0x8512 +#define GL_COMPRESSED_ALPHA 0x84E9 +#define GL_COMPRESSED_LUMINANCE 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB +#define GL_COMPRESSED_INTENSITY 0x84EC +#define GL_COMBINE 0x8570 +#define GL_COMBINE_RGB 0x8571 +#define GL_COMBINE_ALPHA 0x8572 +#define GL_SOURCE0_RGB 0x8580 +#define GL_SOURCE1_RGB 0x8581 +#define GL_SOURCE2_RGB 0x8582 +#define GL_SOURCE0_ALPHA 0x8588 +#define GL_SOURCE1_ALPHA 0x8589 +#define GL_SOURCE2_ALPHA 0x858A +#define GL_OPERAND0_RGB 0x8590 +#define GL_OPERAND1_RGB 0x8591 +#define GL_OPERAND2_RGB 0x8592 +#define GL_OPERAND0_ALPHA 0x8598 +#define GL_OPERAND1_ALPHA 0x8599 +#define GL_OPERAND2_ALPHA 0x859A +#define GL_RGB_SCALE 0x8573 +#define GL_ADD_SIGNED 0x8574 +#define GL_INTERPOLATE 0x8575 +#define GL_SUBTRACT 0x84E7 +#define GL_CONSTANT 0x8576 +#define GL_PRIMARY_COLOR 0x8577 +#define GL_PREVIOUS 0x8578 +#define GL_DOT3_RGB 0x86AE +#define GL_DOT3_RGBA 0x86AF +typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLfloat value, GLboolean invert); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, void *img); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTexture (GLenum texture); +GLAPI void APIENTRY glSampleCoverage (GLfloat value, GLboolean invert); +GLAPI void APIENTRY glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexImage1D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glGetCompressedTexImage (GLenum target, GLint level, void *img); +GLAPI void APIENTRY glClientActiveTexture (GLenum texture); +GLAPI void APIENTRY glMultiTexCoord1d (GLenum target, GLdouble s); +GLAPI void APIENTRY glMultiTexCoord1dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord1f (GLenum target, GLfloat s); +GLAPI void APIENTRY glMultiTexCoord1fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord1i (GLenum target, GLint s); +GLAPI void APIENTRY glMultiTexCoord1iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord1s (GLenum target, GLshort s); +GLAPI void APIENTRY glMultiTexCoord1sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord2d (GLenum target, GLdouble s, GLdouble t); +GLAPI void APIENTRY glMultiTexCoord2dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord2f (GLenum target, GLfloat s, GLfloat t); +GLAPI void APIENTRY glMultiTexCoord2fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord2i (GLenum target, GLint s, GLint t); +GLAPI void APIENTRY glMultiTexCoord2iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord2s (GLenum target, GLshort s, GLshort t); +GLAPI void APIENTRY glMultiTexCoord2sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord3d (GLenum target, GLdouble s, GLdouble t, GLdouble r); +GLAPI void APIENTRY glMultiTexCoord3dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord3f (GLenum target, GLfloat s, GLfloat t, GLfloat r); +GLAPI void APIENTRY glMultiTexCoord3fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord3i (GLenum target, GLint s, GLint t, GLint r); +GLAPI void APIENTRY glMultiTexCoord3iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord3s (GLenum target, GLshort s, GLshort t, GLshort r); +GLAPI void APIENTRY glMultiTexCoord3sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord4d (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +GLAPI void APIENTRY glMultiTexCoord4dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord4f (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +GLAPI void APIENTRY glMultiTexCoord4fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord4i (GLenum target, GLint s, GLint t, GLint r, GLint q); +GLAPI void APIENTRY glMultiTexCoord4iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord4s (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +GLAPI void APIENTRY glMultiTexCoord4sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *m); +GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *m); +GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *m); +GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *m); +#endif +#endif /* GL_VERSION_1_3 */ + +#ifndef GL_VERSION_1_4 +#define GL_VERSION_1_4 1 +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_DEPTH_COMPONENT24 0x81A6 +#define GL_DEPTH_COMPONENT32 0x81A7 +#define GL_MIRRORED_REPEAT 0x8370 +#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD +#define GL_TEXTURE_LOD_BIAS 0x8501 +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 +#define GL_TEXTURE_DEPTH_SIZE 0x884A +#define GL_TEXTURE_COMPARE_MODE 0x884C +#define GL_TEXTURE_COMPARE_FUNC 0x884D +#define GL_POINT_SIZE_MIN 0x8126 +#define GL_POINT_SIZE_MAX 0x8127 +#define GL_POINT_DISTANCE_ATTENUATION 0x8129 +#define GL_GENERATE_MIPMAP 0x8191 +#define GL_GENERATE_MIPMAP_HINT 0x8192 +#define GL_FOG_COORDINATE_SOURCE 0x8450 +#define GL_FOG_COORDINATE 0x8451 +#define GL_FRAGMENT_DEPTH 0x8452 +#define GL_CURRENT_FOG_COORDINATE 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 +#define GL_FOG_COORDINATE_ARRAY 0x8457 +#define GL_COLOR_SUM 0x8458 +#define GL_CURRENT_SECONDARY_COLOR 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D +#define GL_SECONDARY_COLOR_ARRAY 0x845E +#define GL_TEXTURE_FILTER_CONTROL 0x8500 +#define GL_DEPTH_TEXTURE_MODE 0x884B +#define GL_COMPARE_R_TO_TEXTURE 0x884E +#define GL_BLEND_COLOR 0x8005 +#define GL_BLEND_EQUATION 0x8009 +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_FUNC_ADD 0x8006 +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#define GL_FUNC_SUBTRACT 0x800A +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +GLAPI void APIENTRY glMultiDrawArrays (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); +GLAPI void APIENTRY glMultiDrawElements (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount); +GLAPI void APIENTRY glPointParameterf (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfv (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glPointParameteri (GLenum pname, GLint param); +GLAPI void APIENTRY glPointParameteriv (GLenum pname, const GLint *params); +GLAPI void APIENTRY glFogCoordf (GLfloat coord); +GLAPI void APIENTRY glFogCoordfv (const GLfloat *coord); +GLAPI void APIENTRY glFogCoordd (GLdouble coord); +GLAPI void APIENTRY glFogCoorddv (const GLdouble *coord); +GLAPI void APIENTRY glFogCoordPointer (GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glSecondaryColor3b (GLbyte red, GLbyte green, GLbyte blue); +GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *v); +GLAPI void APIENTRY glSecondaryColor3d (GLdouble red, GLdouble green, GLdouble blue); +GLAPI void APIENTRY glSecondaryColor3dv (const GLdouble *v); +GLAPI void APIENTRY glSecondaryColor3f (GLfloat red, GLfloat green, GLfloat blue); +GLAPI void APIENTRY glSecondaryColor3fv (const GLfloat *v); +GLAPI void APIENTRY glSecondaryColor3i (GLint red, GLint green, GLint blue); +GLAPI void APIENTRY glSecondaryColor3iv (const GLint *v); +GLAPI void APIENTRY glSecondaryColor3s (GLshort red, GLshort green, GLshort blue); +GLAPI void APIENTRY glSecondaryColor3sv (const GLshort *v); +GLAPI void APIENTRY glSecondaryColor3ub (GLubyte red, GLubyte green, GLubyte blue); +GLAPI void APIENTRY glSecondaryColor3ubv (const GLubyte *v); +GLAPI void APIENTRY glSecondaryColor3ui (GLuint red, GLuint green, GLuint blue); +GLAPI void APIENTRY glSecondaryColor3uiv (const GLuint *v); +GLAPI void APIENTRY glSecondaryColor3us (GLushort red, GLushort green, GLushort blue); +GLAPI void APIENTRY glSecondaryColor3usv (const GLushort *v); +GLAPI void APIENTRY glSecondaryColorPointer (GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glWindowPos2d (GLdouble x, GLdouble y); +GLAPI void APIENTRY glWindowPos2dv (const GLdouble *v); +GLAPI void APIENTRY glWindowPos2f (GLfloat x, GLfloat y); +GLAPI void APIENTRY glWindowPos2fv (const GLfloat *v); +GLAPI void APIENTRY glWindowPos2i (GLint x, GLint y); +GLAPI void APIENTRY glWindowPos2iv (const GLint *v); +GLAPI void APIENTRY glWindowPos2s (GLshort x, GLshort y); +GLAPI void APIENTRY glWindowPos2sv (const GLshort *v); +GLAPI void APIENTRY glWindowPos3d (GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glWindowPos3dv (const GLdouble *v); +GLAPI void APIENTRY glWindowPos3f (GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glWindowPos3fv (const GLfloat *v); +GLAPI void APIENTRY glWindowPos3i (GLint x, GLint y, GLint z); +GLAPI void APIENTRY glWindowPos3iv (const GLint *v); +GLAPI void APIENTRY glWindowPos3s (GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glWindowPos3sv (const GLshort *v); +GLAPI void APIENTRY glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GLAPI void APIENTRY glBlendEquation (GLenum mode); +#endif +#endif /* GL_VERSION_1_4 */ + +#ifndef GL_VERSION_1_5 +#define GL_VERSION_1_5 1 +typedef khronos_ssize_t GLsizeiptr; +typedef khronos_intptr_t GLintptr; +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 +#define GL_QUERY_COUNTER_BITS 0x8864 +#define GL_CURRENT_QUERY 0x8865 +#define GL_QUERY_RESULT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE 0x8867 +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F +#define GL_READ_ONLY 0x88B8 +#define GL_WRITE_ONLY 0x88B9 +#define GL_READ_WRITE 0x88BA +#define GL_BUFFER_ACCESS 0x88BB +#define GL_BUFFER_MAPPED 0x88BC +#define GL_BUFFER_MAP_POINTER 0x88BD +#define GL_STREAM_DRAW 0x88E0 +#define GL_STREAM_READ 0x88E1 +#define GL_STREAM_COPY 0x88E2 +#define GL_STATIC_DRAW 0x88E4 +#define GL_STATIC_READ 0x88E5 +#define GL_STATIC_COPY 0x88E6 +#define GL_DYNAMIC_DRAW 0x88E8 +#define GL_DYNAMIC_READ 0x88E9 +#define GL_DYNAMIC_COPY 0x88EA +#define GL_SAMPLES_PASSED 0x8914 +#define GL_SRC1_ALPHA 0x8589 +#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E +#define GL_FOG_COORD_SRC 0x8450 +#define GL_FOG_COORD 0x8451 +#define GL_CURRENT_FOG_COORD 0x8453 +#define GL_FOG_COORD_ARRAY_TYPE 0x8454 +#define GL_FOG_COORD_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORD_ARRAY_POINTER 0x8456 +#define GL_FOG_COORD_ARRAY 0x8457 +#define GL_FOG_COORD_ARRAY_BUFFER_BINDING 0x889D +#define GL_SRC0_RGB 0x8580 +#define GL_SRC1_RGB 0x8581 +#define GL_SRC2_RGB 0x8582 +#define GL_SRC0_ALPHA 0x8588 +#define GL_SRC2_ALPHA 0x858A +typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const void *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, void *data); +typedef void *(APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, void **params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueries (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteQueries (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsQuery (GLuint id); +GLAPI void APIENTRY glBeginQuery (GLenum target, GLuint id); +GLAPI void APIENTRY glEndQuery (GLenum target); +GLAPI void APIENTRY glGetQueryiv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectiv (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectuiv (GLuint id, GLenum pname, GLuint *params); +GLAPI void APIENTRY glBindBuffer (GLenum target, GLuint buffer); +GLAPI void APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers); +GLAPI void APIENTRY glGenBuffers (GLsizei n, GLuint *buffers); +GLAPI GLboolean APIENTRY glIsBuffer (GLuint buffer); +GLAPI void APIENTRY glBufferData (GLenum target, GLsizeiptr size, const void *data, GLenum usage); +GLAPI void APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); +GLAPI void APIENTRY glGetBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, void *data); +GLAPI void *APIENTRY glMapBuffer (GLenum target, GLenum access); +GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum target); +GLAPI void APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetBufferPointerv (GLenum target, GLenum pname, void **params); +#endif +#endif /* GL_VERSION_1_5 */ + +#ifndef GL_VERSION_2_0 +#define GL_VERSION_2_0 1 +typedef char GLchar; +#define GL_BLEND_EQUATION_RGB 0x8009 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 +#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#define GL_STENCIL_BACK_FUNC 0x8800 +#define GL_STENCIL_BACK_FAIL 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#define GL_MAX_DRAW_BUFFERS 0x8824 +#define GL_DRAW_BUFFER0 0x8825 +#define GL_DRAW_BUFFER1 0x8826 +#define GL_DRAW_BUFFER2 0x8827 +#define GL_DRAW_BUFFER3 0x8828 +#define GL_DRAW_BUFFER4 0x8829 +#define GL_DRAW_BUFFER5 0x882A +#define GL_DRAW_BUFFER6 0x882B +#define GL_DRAW_BUFFER7 0x882C +#define GL_DRAW_BUFFER8 0x882D +#define GL_DRAW_BUFFER9 0x882E +#define GL_DRAW_BUFFER10 0x882F +#define GL_DRAW_BUFFER11 0x8830 +#define GL_DRAW_BUFFER12 0x8831 +#define GL_DRAW_BUFFER13 0x8832 +#define GL_DRAW_BUFFER14 0x8833 +#define GL_DRAW_BUFFER15 0x8834 +#define GL_BLEND_EQUATION_ALPHA 0x883D +#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A +#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_VERTEX_SHADER 0x8B31 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A +#define GL_MAX_VARYING_FLOATS 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D +#define GL_SHADER_TYPE 0x8B4F +#define GL_FLOAT_VEC2 0x8B50 +#define GL_FLOAT_VEC3 0x8B51 +#define GL_FLOAT_VEC4 0x8B52 +#define GL_INT_VEC2 0x8B53 +#define GL_INT_VEC3 0x8B54 +#define GL_INT_VEC4 0x8B55 +#define GL_BOOL 0x8B56 +#define GL_BOOL_VEC2 0x8B57 +#define GL_BOOL_VEC3 0x8B58 +#define GL_BOOL_VEC4 0x8B59 +#define GL_FLOAT_MAT2 0x8B5A +#define GL_FLOAT_MAT3 0x8B5B +#define GL_FLOAT_MAT4 0x8B5C +#define GL_SAMPLER_1D 0x8B5D +#define GL_SAMPLER_2D 0x8B5E +#define GL_SAMPLER_3D 0x8B5F +#define GL_SAMPLER_CUBE 0x8B60 +#define GL_SAMPLER_1D_SHADOW 0x8B61 +#define GL_SAMPLER_2D_SHADOW 0x8B62 +#define GL_DELETE_STATUS 0x8B80 +#define GL_COMPILE_STATUS 0x8B81 +#define GL_LINK_STATUS 0x8B82 +#define GL_VALIDATE_STATUS 0x8B83 +#define GL_INFO_LOG_LENGTH 0x8B84 +#define GL_ATTACHED_SHADERS 0x8B85 +#define GL_ACTIVE_UNIFORMS 0x8B86 +#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 +#define GL_SHADER_SOURCE_LENGTH 0x8B88 +#define GL_ACTIVE_ATTRIBUTES 0x8B89 +#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B +#define GL_SHADING_LANGUAGE_VERSION 0x8B8C +#define GL_CURRENT_PROGRAM 0x8B8D +#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 +#define GL_LOWER_LEFT 0x8CA1 +#define GL_UPPER_LEFT 0x8CA2 +#define GL_STENCIL_BACK_REF 0x8CA3 +#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 +#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 +#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 +#define GL_POINT_SPRITE 0x8861 +#define GL_COORD_REPLACE 0x8862 +#define GL_MAX_TEXTURE_COORDS 0x8871 +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum face, GLenum func, GLint ref, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); +typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); +typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); +typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); +typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, void **pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); +typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); +typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glDrawBuffers (GLsizei n, const GLenum *bufs); +GLAPI void APIENTRY glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +GLAPI void APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); +GLAPI void APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); +GLAPI void APIENTRY glAttachShader (GLuint program, GLuint shader); +GLAPI void APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar *name); +GLAPI void APIENTRY glCompileShader (GLuint shader); +GLAPI GLuint APIENTRY glCreateProgram (void); +GLAPI GLuint APIENTRY glCreateShader (GLenum type); +GLAPI void APIENTRY glDeleteProgram (GLuint program); +GLAPI void APIENTRY glDeleteShader (GLuint shader); +GLAPI void APIENTRY glDetachShader (GLuint program, GLuint shader); +GLAPI void APIENTRY glDisableVertexAttribArray (GLuint index); +GLAPI void APIENTRY glEnableVertexAttribArray (GLuint index); +GLAPI void APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); +GLAPI GLint APIENTRY glGetAttribLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI void APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI void APIENTRY glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +GLAPI GLint APIENTRY glGetUniformLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat *params); +GLAPI void APIENTRY glGetUniformiv (GLuint program, GLint location, GLint *params); +GLAPI void APIENTRY glGetVertexAttribdv (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, void **pointer); +GLAPI GLboolean APIENTRY glIsProgram (GLuint program); +GLAPI GLboolean APIENTRY glIsShader (GLuint shader); +GLAPI void APIENTRY glLinkProgram (GLuint program); +GLAPI void APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); +GLAPI void APIENTRY glUseProgram (GLuint program); +GLAPI void APIENTRY glUniform1f (GLint location, GLfloat v0); +GLAPI void APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glUniform1i (GLint location, GLint v0); +GLAPI void APIENTRY glUniform2i (GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glValidateProgram (GLuint program); +GLAPI void APIENTRY glVertexAttrib1d (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1f (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1s (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2d (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2s (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3s (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4Niv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4Nub (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttrib4bv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4s (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4usv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +#endif +#endif /* GL_VERSION_2_0 */ + +#ifndef GL_VERSION_2_1 +#define GL_VERSION_2_1 1 +#define GL_PIXEL_PACK_BUFFER 0x88EB +#define GL_PIXEL_UNPACK_BUFFER 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF +#define GL_FLOAT_MAT2x3 0x8B65 +#define GL_FLOAT_MAT2x4 0x8B66 +#define GL_FLOAT_MAT3x2 0x8B67 +#define GL_FLOAT_MAT3x4 0x8B68 +#define GL_FLOAT_MAT4x2 0x8B69 +#define GL_FLOAT_MAT4x3 0x8B6A +#define GL_SRGB 0x8C40 +#define GL_SRGB8 0x8C41 +#define GL_SRGB_ALPHA 0x8C42 +#define GL_SRGB8_ALPHA8 0x8C43 +#define GL_COMPRESSED_SRGB 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA 0x8C49 +#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F +#define GL_SLUMINANCE_ALPHA 0x8C44 +#define GL_SLUMINANCE8_ALPHA8 0x8C45 +#define GL_SLUMINANCE 0x8C46 +#define GL_SLUMINANCE8 0x8C47 +#define GL_COMPRESSED_SLUMINANCE 0x8C4A +#define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#endif +#endif /* GL_VERSION_2_1 */ + +#ifndef GL_VERSION_3_0 +#define GL_VERSION_3_0 1 +typedef khronos_uint16_t GLhalf; +#define GL_COMPARE_REF_TO_TEXTURE 0x884E +#define GL_CLIP_DISTANCE0 0x3000 +#define GL_CLIP_DISTANCE1 0x3001 +#define GL_CLIP_DISTANCE2 0x3002 +#define GL_CLIP_DISTANCE3 0x3003 +#define GL_CLIP_DISTANCE4 0x3004 +#define GL_CLIP_DISTANCE5 0x3005 +#define GL_CLIP_DISTANCE6 0x3006 +#define GL_CLIP_DISTANCE7 0x3007 +#define GL_MAX_CLIP_DISTANCES 0x0D32 +#define GL_MAJOR_VERSION 0x821B +#define GL_MINOR_VERSION 0x821C +#define GL_NUM_EXTENSIONS 0x821D +#define GL_CONTEXT_FLAGS 0x821E +#define GL_COMPRESSED_RED 0x8225 +#define GL_COMPRESSED_RG 0x8226 +#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x00000001 +#define GL_RGBA32F 0x8814 +#define GL_RGB32F 0x8815 +#define GL_RGBA16F 0x881A +#define GL_RGB16F 0x881B +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD +#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF +#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 +#define GL_CLAMP_READ_COLOR 0x891C +#define GL_FIXED_ONLY 0x891D +#define GL_MAX_VARYING_COMPONENTS 0x8B4B +#define GL_TEXTURE_1D_ARRAY 0x8C18 +#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19 +#define GL_TEXTURE_2D_ARRAY 0x8C1A +#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B +#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C +#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D +#define GL_R11F_G11F_B10F 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B +#define GL_RGB9_E5 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E +#define GL_TEXTURE_SHARED_SIZE 0x8C3F +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 +#define GL_PRIMITIVES_GENERATED 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 +#define GL_RASTERIZER_DISCARD 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B +#define GL_INTERLEAVED_ATTRIBS 0x8C8C +#define GL_SEPARATE_ATTRIBS 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F +#define GL_RGBA32UI 0x8D70 +#define GL_RGB32UI 0x8D71 +#define GL_RGBA16UI 0x8D76 +#define GL_RGB16UI 0x8D77 +#define GL_RGBA8UI 0x8D7C +#define GL_RGB8UI 0x8D7D +#define GL_RGBA32I 0x8D82 +#define GL_RGB32I 0x8D83 +#define GL_RGBA16I 0x8D88 +#define GL_RGB16I 0x8D89 +#define GL_RGBA8I 0x8D8E +#define GL_RGB8I 0x8D8F +#define GL_RED_INTEGER 0x8D94 +#define GL_GREEN_INTEGER 0x8D95 +#define GL_BLUE_INTEGER 0x8D96 +#define GL_RGB_INTEGER 0x8D98 +#define GL_RGBA_INTEGER 0x8D99 +#define GL_BGR_INTEGER 0x8D9A +#define GL_BGRA_INTEGER 0x8D9B +#define GL_SAMPLER_1D_ARRAY 0x8DC0 +#define GL_SAMPLER_2D_ARRAY 0x8DC1 +#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3 +#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW 0x8DC5 +#define GL_UNSIGNED_INT_VEC2 0x8DC6 +#define GL_UNSIGNED_INT_VEC3 0x8DC7 +#define GL_UNSIGNED_INT_VEC4 0x8DC8 +#define GL_INT_SAMPLER_1D 0x8DC9 +#define GL_INT_SAMPLER_2D 0x8DCA +#define GL_INT_SAMPLER_3D 0x8DCB +#define GL_INT_SAMPLER_CUBE 0x8DCC +#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE +#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF +#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1 +#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 +#define GL_QUERY_WAIT 0x8E13 +#define GL_QUERY_NO_WAIT 0x8E14 +#define GL_QUERY_BY_REGION_WAIT 0x8E15 +#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16 +#define GL_BUFFER_ACCESS_FLAGS 0x911F +#define GL_BUFFER_MAP_LENGTH 0x9120 +#define GL_BUFFER_MAP_OFFSET 0x9121 +#define GL_DEPTH_COMPONENT32F 0x8CAC +#define GL_DEPTH32F_STENCIL8 0x8CAD +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD +#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 +#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 +#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 +#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 +#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 +#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 +#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 +#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 +#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 +#define GL_FRAMEBUFFER_DEFAULT 0x8218 +#define GL_FRAMEBUFFER_UNDEFINED 0x8219 +#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A +#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 +#define GL_DEPTH_STENCIL 0x84F9 +#define GL_UNSIGNED_INT_24_8 0x84FA +#define GL_DEPTH24_STENCIL8 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE 0x88F1 +#define GL_TEXTURE_RED_TYPE 0x8C10 +#define GL_TEXTURE_GREEN_TYPE 0x8C11 +#define GL_TEXTURE_BLUE_TYPE 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE 0x8C13 +#define GL_TEXTURE_DEPTH_TYPE 0x8C16 +#define GL_UNSIGNED_NORMALIZED 0x8C17 +#define GL_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_RENDERBUFFER_BINDING 0x8CA7 +#define GL_READ_FRAMEBUFFER 0x8CA8 +#define GL_DRAW_FRAMEBUFFER 0x8CA9 +#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA +#define GL_RENDERBUFFER_SAMPLES 0x8CAB +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF +#define GL_COLOR_ATTACHMENT0 0x8CE0 +#define GL_COLOR_ATTACHMENT1 0x8CE1 +#define GL_COLOR_ATTACHMENT2 0x8CE2 +#define GL_COLOR_ATTACHMENT3 0x8CE3 +#define GL_COLOR_ATTACHMENT4 0x8CE4 +#define GL_COLOR_ATTACHMENT5 0x8CE5 +#define GL_COLOR_ATTACHMENT6 0x8CE6 +#define GL_COLOR_ATTACHMENT7 0x8CE7 +#define GL_COLOR_ATTACHMENT8 0x8CE8 +#define GL_COLOR_ATTACHMENT9 0x8CE9 +#define GL_COLOR_ATTACHMENT10 0x8CEA +#define GL_COLOR_ATTACHMENT11 0x8CEB +#define GL_COLOR_ATTACHMENT12 0x8CEC +#define GL_COLOR_ATTACHMENT13 0x8CED +#define GL_COLOR_ATTACHMENT14 0x8CEE +#define GL_COLOR_ATTACHMENT15 0x8CEF +#define GL_COLOR_ATTACHMENT16 0x8CF0 +#define GL_COLOR_ATTACHMENT17 0x8CF1 +#define GL_COLOR_ATTACHMENT18 0x8CF2 +#define GL_COLOR_ATTACHMENT19 0x8CF3 +#define GL_COLOR_ATTACHMENT20 0x8CF4 +#define GL_COLOR_ATTACHMENT21 0x8CF5 +#define GL_COLOR_ATTACHMENT22 0x8CF6 +#define GL_COLOR_ATTACHMENT23 0x8CF7 +#define GL_COLOR_ATTACHMENT24 0x8CF8 +#define GL_COLOR_ATTACHMENT25 0x8CF9 +#define GL_COLOR_ATTACHMENT26 0x8CFA +#define GL_COLOR_ATTACHMENT27 0x8CFB +#define GL_COLOR_ATTACHMENT28 0x8CFC +#define GL_COLOR_ATTACHMENT29 0x8CFD +#define GL_COLOR_ATTACHMENT30 0x8CFE +#define GL_COLOR_ATTACHMENT31 0x8CFF +#define GL_DEPTH_ATTACHMENT 0x8D00 +#define GL_STENCIL_ATTACHMENT 0x8D20 +#define GL_FRAMEBUFFER 0x8D40 +#define GL_RENDERBUFFER 0x8D41 +#define GL_RENDERBUFFER_WIDTH 0x8D42 +#define GL_RENDERBUFFER_HEIGHT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 +#define GL_STENCIL_INDEX1 0x8D46 +#define GL_STENCIL_INDEX4 0x8D47 +#define GL_STENCIL_INDEX8 0x8D48 +#define GL_STENCIL_INDEX16 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 +#define GL_MAX_SAMPLES 0x8D57 +#define GL_INDEX 0x8222 +#define GL_TEXTURE_LUMINANCE_TYPE 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE 0x8C15 +#define GL_FRAMEBUFFER_SRGB 0x8DB9 +#define GL_HALF_FLOAT 0x140B +#define GL_MAP_READ_BIT 0x0001 +#define GL_MAP_WRITE_BIT 0x0002 +#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 +#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 +#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 +#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 +#define GL_COMPRESSED_RED_RGTC1 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC +#define GL_COMPRESSED_RG_RGTC2 0x8DBD +#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE +#define GL_RG 0x8227 +#define GL_RG_INTEGER 0x8228 +#define GL_R8 0x8229 +#define GL_R16 0x822A +#define GL_RG8 0x822B +#define GL_RG16 0x822C +#define GL_R16F 0x822D +#define GL_R32F 0x822E +#define GL_RG16F 0x822F +#define GL_RG32F 0x8230 +#define GL_R8I 0x8231 +#define GL_R8UI 0x8232 +#define GL_R16I 0x8233 +#define GL_R16UI 0x8234 +#define GL_R32I 0x8235 +#define GL_R32UI 0x8236 +#define GL_RG8I 0x8237 +#define GL_RG8UI 0x8238 +#define GL_RG16I 0x8239 +#define GL_RG16UI 0x823A +#define GL_RG32I 0x823B +#define GL_RG32UI 0x823C +#define GL_VERTEX_ARRAY_BINDING 0x85B5 +#define GL_CLAMP_VERTEX_COLOR 0x891A +#define GL_CLAMP_FRAGMENT_COLOR 0x891B +#define GL_ALPHA_INTEGER 0x8D97 +typedef void (APIENTRYP PFNGLCOLORMASKIPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +typedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC) (GLenum target, GLuint index, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data); +typedef void (APIENTRYP PFNGLENABLEIPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLDISABLEIPROC) (GLenum target, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISENABLEDIPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLCLAMPCOLORPROC) (GLenum target, GLenum clamp); +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERPROC) (GLuint id, GLenum mode); +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERPROC) (void); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC) (GLuint index, GLint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC) (GLuint index, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC) (GLuint index, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC) (GLuint index, GLuint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC) (GLuint index, GLuint x, GLuint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLGETUNIFORMUIVPROC) (GLuint program, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONPROC) (GLuint program, GLuint color, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORM1UIPROC) (GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLUNIFORM2UIPROC) (GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLUNIFORM3UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLUNIFORM4UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLCLEARBUFFERIVPROC) (GLenum buffer, GLint drawbuffer, const GLint *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERUIVPROC) (GLenum buffer, GLint drawbuffer, const GLuint *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawbuffer, const GLfloat *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +typedef const GLubyte *(APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer); +typedef void (APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer); +typedef void (APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer); +typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); +typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target); +typedef void (APIENTRYP PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void *(APIENTRYP PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array); +typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays); +typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYPROC) (GLuint array); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorMaski (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +GLAPI void APIENTRY glGetBooleani_v (GLenum target, GLuint index, GLboolean *data); +GLAPI void APIENTRY glGetIntegeri_v (GLenum target, GLuint index, GLint *data); +GLAPI void APIENTRY glEnablei (GLenum target, GLuint index); +GLAPI void APIENTRY glDisablei (GLenum target, GLuint index); +GLAPI GLboolean APIENTRY glIsEnabledi (GLenum target, GLuint index); +GLAPI void APIENTRY glBeginTransformFeedback (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedback (void); +GLAPI void APIENTRY glBindBufferRange (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferBase (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +GLAPI void APIENTRY glGetTransformFeedbackVarying (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glClampColor (GLenum target, GLenum clamp); +GLAPI void APIENTRY glBeginConditionalRender (GLuint id, GLenum mode); +GLAPI void APIENTRY glEndConditionalRender (void); +GLAPI void APIENTRY glVertexAttribIPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glGetVertexAttribIiv (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribIuiv (GLuint index, GLenum pname, GLuint *params); +GLAPI void APIENTRY glVertexAttribI1i (GLuint index, GLint x); +GLAPI void APIENTRY glVertexAttribI2i (GLuint index, GLint x, GLint y); +GLAPI void APIENTRY glVertexAttribI3i (GLuint index, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexAttribI4i (GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexAttribI1ui (GLuint index, GLuint x); +GLAPI void APIENTRY glVertexAttribI2ui (GLuint index, GLuint x, GLuint y); +GLAPI void APIENTRY glVertexAttribI3ui (GLuint index, GLuint x, GLuint y, GLuint z); +GLAPI void APIENTRY glVertexAttribI4ui (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glVertexAttribI1iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI2iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI3iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI4iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI1uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI2uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI3uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4bv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttribI4sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttribI4ubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribI4usv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glGetUniformuiv (GLuint program, GLint location, GLuint *params); +GLAPI void APIENTRY glBindFragDataLocation (GLuint program, GLuint color, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glUniform1ui (GLint location, GLuint v0); +GLAPI void APIENTRY glUniform2ui (GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glUniform3ui (GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glUniform4ui (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glUniform1uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform2uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform3uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform4uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glTexParameterIiv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTexParameterIuiv (GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTexParameterIiv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTexParameterIuiv (GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint *value); +GLAPI void APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint *value); +GLAPI void APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat *value); +GLAPI void APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +GLAPI const GLubyte *APIENTRY glGetStringi (GLenum name, GLuint index); +GLAPI GLboolean APIENTRY glIsRenderbuffer (GLuint renderbuffer); +GLAPI void APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers); +GLAPI void APIENTRY glGenRenderbuffers (GLsizei n, GLuint *renderbuffers); +GLAPI void APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI GLboolean APIENTRY glIsFramebuffer (GLuint framebuffer); +GLAPI void APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); +GLAPI void APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers); +GLAPI void APIENTRY glGenFramebuffers (GLsizei n, GLuint *framebuffers); +GLAPI GLenum APIENTRY glCheckFramebufferStatus (GLenum target); +GLAPI void APIENTRY glFramebufferTexture1D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture3D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateMipmap (GLenum target); +GLAPI void APIENTRY glBlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +GLAPI void APIENTRY glRenderbufferStorageMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glFramebufferTextureLayer (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void *APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +GLAPI void APIENTRY glFlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glBindVertexArray (GLuint array); +GLAPI void APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint *arrays); +GLAPI void APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays); +GLAPI GLboolean APIENTRY glIsVertexArray (GLuint array); +#endif +#endif /* GL_VERSION_3_0 */ + +#ifndef GL_VERSION_3_1 +#define GL_VERSION_3_1 1 +#define GL_SAMPLER_2D_RECT 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64 +#define GL_SAMPLER_BUFFER 0x8DC2 +#define GL_INT_SAMPLER_2D_RECT 0x8DCD +#define GL_INT_SAMPLER_BUFFER 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8 +#define GL_TEXTURE_BUFFER 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D +#define GL_TEXTURE_RECTANGLE 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8 +#define GL_R8_SNORM 0x8F94 +#define GL_RG8_SNORM 0x8F95 +#define GL_RGB8_SNORM 0x8F96 +#define GL_RGBA8_SNORM 0x8F97 +#define GL_R16_SNORM 0x8F98 +#define GL_RG16_SNORM 0x8F99 +#define GL_RGB16_SNORM 0x8F9A +#define GL_RGBA16_SNORM 0x8F9B +#define GL_SIGNED_NORMALIZED 0x8F9C +#define GL_PRIMITIVE_RESTART 0x8F9D +#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E +#define GL_COPY_READ_BUFFER 0x8F36 +#define GL_COPY_WRITE_BUFFER 0x8F37 +#define GL_UNIFORM_BUFFER 0x8A11 +#define GL_UNIFORM_BUFFER_BINDING 0x8A28 +#define GL_UNIFORM_BUFFER_START 0x8A29 +#define GL_UNIFORM_BUFFER_SIZE 0x8A2A +#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B +#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C +#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D +#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E +#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F +#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 +#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 +#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32 +#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 +#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 +#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 +#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 +#define GL_UNIFORM_TYPE 0x8A37 +#define GL_UNIFORM_SIZE 0x8A38 +#define GL_UNIFORM_NAME_LENGTH 0x8A39 +#define GL_UNIFORM_BLOCK_INDEX 0x8A3A +#define GL_UNIFORM_OFFSET 0x8A3B +#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C +#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D +#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E +#define GL_UNIFORM_BLOCK_BINDING 0x8A3F +#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 +#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 +#define GL_INVALID_INDEX 0xFFFFFFFFu +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount); +typedef void (APIENTRYP PFNGLTEXBUFFERPROC) (GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXPROC) (GLuint index); +typedef void (APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMNAMEPROC) (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); +typedef GLuint (APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar *uniformBlockName); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +typedef void (APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +GLAPI void APIENTRY glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount); +GLAPI void APIENTRY glTexBuffer (GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glPrimitiveRestartIndex (GLuint index); +GLAPI void APIENTRY glCopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GLAPI void APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); +GLAPI void APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetActiveUniformName (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); +GLAPI GLuint APIENTRY glGetUniformBlockIndex (GLuint program, const GLchar *uniformBlockName); +GLAPI void APIENTRY glGetActiveUniformBlockiv (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +GLAPI void APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +#endif +#endif /* GL_VERSION_3_1 */ + +#ifndef GL_VERSION_3_2 +#define GL_VERSION_3_2 1 +typedef struct __GLsync *GLsync; +typedef khronos_uint64_t GLuint64; +typedef khronos_int64_t GLint64; +#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001 +#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002 +#define GL_LINES_ADJACENCY 0x000A +#define GL_LINE_STRIP_ADJACENCY 0x000B +#define GL_TRIANGLES_ADJACENCY 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D +#define GL_PROGRAM_POINT_SIZE 0x8642 +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8 +#define GL_GEOMETRY_SHADER 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT 0x8916 +#define GL_GEOMETRY_INPUT_TYPE 0x8917 +#define GL_GEOMETRY_OUTPUT_TYPE 0x8918 +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1 +#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 +#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123 +#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124 +#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 +#define GL_CONTEXT_PROFILE_MASK 0x9126 +#define GL_DEPTH_CLAMP 0x864F +#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C +#define GL_FIRST_VERTEX_CONVENTION 0x8E4D +#define GL_LAST_VERTEX_CONVENTION 0x8E4E +#define GL_PROVOKING_VERTEX 0x8E4F +#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F +#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 +#define GL_OBJECT_TYPE 0x9112 +#define GL_SYNC_CONDITION 0x9113 +#define GL_SYNC_STATUS 0x9114 +#define GL_SYNC_FLAGS 0x9115 +#define GL_SYNC_FENCE 0x9116 +#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 +#define GL_UNSIGNALED 0x9118 +#define GL_SIGNALED 0x9119 +#define GL_ALREADY_SIGNALED 0x911A +#define GL_TIMEOUT_EXPIRED 0x911B +#define GL_CONDITION_SATISFIED 0x911C +#define GL_WAIT_FAILED 0x911D +#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull +#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 +#define GL_SAMPLE_POSITION 0x8E50 +#define GL_SAMPLE_MASK 0x8E51 +#define GL_SAMPLE_MASK_VALUE 0x8E52 +#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59 +#define GL_TEXTURE_2D_MULTISAMPLE 0x9100 +#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101 +#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 +#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105 +#define GL_TEXTURE_SAMPLES 0x9106 +#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107 +#define GL_SAMPLER_2D_MULTISAMPLE 0x9108 +#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A +#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B +#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D +#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E +#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F +#define GL_MAX_INTEGER_SAMPLES 0x9110 +typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount, const GLint *basevertex); +typedef void (APIENTRYP PFNGLPROVOKINGVERTEXPROC) (GLenum mode); +typedef GLsync (APIENTRYP PFNGLFENCESYNCPROC) (GLenum condition, GLbitfield flags); +typedef GLboolean (APIENTRYP PFNGLISSYNCPROC) (GLsync sync); +typedef void (APIENTRYP PFNGLDELETESYNCPROC) (GLsync sync); +typedef GLenum (APIENTRYP PFNGLCLIENTWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (APIENTRYP PFNGLWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (APIENTRYP PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64 *data); +typedef void (APIENTRYP PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei count, GLsizei *length, GLint *values); +typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum target, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat *val); +typedef void (APIENTRYP PFNGLSAMPLEMASKIPROC) (GLuint maskNumber, GLbitfield mask); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawElementsBaseVertex (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); +GLAPI void APIENTRY glDrawRangeElementsBaseVertex (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); +GLAPI void APIENTRY glDrawElementsInstancedBaseVertex (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); +GLAPI void APIENTRY glMultiDrawElementsBaseVertex (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount, const GLint *basevertex); +GLAPI void APIENTRY glProvokingVertex (GLenum mode); +GLAPI GLsync APIENTRY glFenceSync (GLenum condition, GLbitfield flags); +GLAPI GLboolean APIENTRY glIsSync (GLsync sync); +GLAPI void APIENTRY glDeleteSync (GLsync sync); +GLAPI GLenum APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GLAPI void APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GLAPI void APIENTRY glGetInteger64v (GLenum pname, GLint64 *data); +GLAPI void APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei count, GLsizei *length, GLint *values); +GLAPI void APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64 *data); +GLAPI void APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glFramebufferTexture (GLenum target, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glTexImage2DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTexImage3DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glGetMultisamplefv (GLenum pname, GLuint index, GLfloat *val); +GLAPI void APIENTRY glSampleMaski (GLuint maskNumber, GLbitfield mask); +#endif +#endif /* GL_VERSION_3_2 */ + +#ifndef GL_VERSION_3_3 +#define GL_VERSION_3_3 1 +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE +#define GL_SRC1_COLOR 0x88F9 +#define GL_ONE_MINUS_SRC1_COLOR 0x88FA +#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB +#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC +#define GL_ANY_SAMPLES_PASSED 0x8C2F +#define GL_SAMPLER_BINDING 0x8919 +#define GL_RGB10_A2UI 0x906F +#define GL_TEXTURE_SWIZZLE_R 0x8E42 +#define GL_TEXTURE_SWIZZLE_G 0x8E43 +#define GL_TEXTURE_SWIZZLE_B 0x8E44 +#define GL_TEXTURE_SWIZZLE_A 0x8E45 +#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46 +#define GL_TIME_ELAPSED 0x88BF +#define GL_TIMESTAMP 0x8E28 +#define GL_INT_2_10_10_10_REV 0x8D9F +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATAINDEXPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint *samplers); +typedef void (APIENTRYP PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint *samplers); +typedef GLboolean (APIENTRYP PFNGLISSAMPLERPROC) (GLuint sampler); +typedef void (APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, const GLuint *param); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLQUERYCOUNTERPROC) (GLuint id, GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VPROC) (GLuint id, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VPROC) (GLuint id, GLenum pname, GLuint64 *params); +typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXP2UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP2UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXP3UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP3UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXP4UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP4UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLTEXCOORDP1UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP1UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP2UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP2UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP3UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP3UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP4UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP4UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLNORMALP3UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLNORMALP3UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLCOLORP3UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLCOLORP3UIVPROC) (GLenum type, const GLuint *color); +typedef void (APIENTRYP PFNGLCOLORP4UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLCOLORP4UIVPROC) (GLenum type, const GLuint *color); +typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIVPROC) (GLenum type, const GLuint *color); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindFragDataLocationIndexed (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataIndex (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGenSamplers (GLsizei count, GLuint *samplers); +GLAPI void APIENTRY glDeleteSamplers (GLsizei count, const GLuint *samplers); +GLAPI GLboolean APIENTRY glIsSampler (GLuint sampler); +GLAPI void APIENTRY glBindSampler (GLuint unit, GLuint sampler); +GLAPI void APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param); +GLAPI void APIENTRY glSamplerParameteriv (GLuint sampler, GLenum pname, const GLint *param); +GLAPI void APIENTRY glSamplerParameterf (GLuint sampler, GLenum pname, GLfloat param); +GLAPI void APIENTRY glSamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat *param); +GLAPI void APIENTRY glSamplerParameterIiv (GLuint sampler, GLenum pname, const GLint *param); +GLAPI void APIENTRY glSamplerParameterIuiv (GLuint sampler, GLenum pname, const GLuint *param); +GLAPI void APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSamplerParameterIiv (GLuint sampler, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetSamplerParameterIuiv (GLuint sampler, GLenum pname, GLuint *params); +GLAPI void APIENTRY glQueryCounter (GLuint id, GLenum target); +GLAPI void APIENTRY glGetQueryObjecti64v (GLuint id, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glGetQueryObjectui64v (GLuint id, GLenum pname, GLuint64 *params); +GLAPI void APIENTRY glVertexAttribDivisor (GLuint index, GLuint divisor); +GLAPI void APIENTRY glVertexAttribP1ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP1uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP2ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP2uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP3ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP3uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP4ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP4uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexP2ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP2uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glVertexP3ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP3uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glVertexP4ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP4uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glTexCoordP1ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP1uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP2ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP2uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP3ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP3uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP4ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP4uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP1ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP1uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP2ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP2uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP3ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP3uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP4ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP4uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glNormalP3ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glNormalP3uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glColorP3ui (GLenum type, GLuint color); +GLAPI void APIENTRY glColorP3uiv (GLenum type, const GLuint *color); +GLAPI void APIENTRY glColorP4ui (GLenum type, GLuint color); +GLAPI void APIENTRY glColorP4uiv (GLenum type, const GLuint *color); +GLAPI void APIENTRY glSecondaryColorP3ui (GLenum type, GLuint color); +GLAPI void APIENTRY glSecondaryColorP3uiv (GLenum type, const GLuint *color); +#endif +#endif /* GL_VERSION_3_3 */ + +#ifndef GL_VERSION_4_0 +#define GL_VERSION_4_0 1 +#define GL_SAMPLE_SHADING 0x8C36 +#define GL_MIN_SAMPLE_SHADING_VALUE 0x8C37 +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F +#define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY 0x900B +#define GL_SAMPLER_CUBE_MAP_ARRAY 0x900C +#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW 0x900D +#define GL_INT_SAMPLER_CUBE_MAP_ARRAY 0x900E +#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F +#define GL_DRAW_INDIRECT_BUFFER 0x8F3F +#define GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43 +#define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F +#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A +#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B +#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C +#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D +#define GL_MAX_VERTEX_STREAMS 0x8E71 +#define GL_DOUBLE_VEC2 0x8FFC +#define GL_DOUBLE_VEC3 0x8FFD +#define GL_DOUBLE_VEC4 0x8FFE +#define GL_DOUBLE_MAT2 0x8F46 +#define GL_DOUBLE_MAT3 0x8F47 +#define GL_DOUBLE_MAT4 0x8F48 +#define GL_DOUBLE_MAT2x3 0x8F49 +#define GL_DOUBLE_MAT2x4 0x8F4A +#define GL_DOUBLE_MAT3x2 0x8F4B +#define GL_DOUBLE_MAT3x4 0x8F4C +#define GL_DOUBLE_MAT4x2 0x8F4D +#define GL_DOUBLE_MAT4x3 0x8F4E +#define GL_ACTIVE_SUBROUTINES 0x8DE5 +#define GL_ACTIVE_SUBROUTINE_UNIFORMS 0x8DE6 +#define GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS 0x8E47 +#define GL_ACTIVE_SUBROUTINE_MAX_LENGTH 0x8E48 +#define GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH 0x8E49 +#define GL_MAX_SUBROUTINES 0x8DE7 +#define GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS 0x8DE8 +#define GL_NUM_COMPATIBLE_SUBROUTINES 0x8E4A +#define GL_COMPATIBLE_SUBROUTINES 0x8E4B +#define GL_PATCHES 0x000E +#define GL_PATCH_VERTICES 0x8E72 +#define GL_PATCH_DEFAULT_INNER_LEVEL 0x8E73 +#define GL_PATCH_DEFAULT_OUTER_LEVEL 0x8E74 +#define GL_TESS_CONTROL_OUTPUT_VERTICES 0x8E75 +#define GL_TESS_GEN_MODE 0x8E76 +#define GL_TESS_GEN_SPACING 0x8E77 +#define GL_TESS_GEN_VERTEX_ORDER 0x8E78 +#define GL_TESS_GEN_POINT_MODE 0x8E79 +#define GL_ISOLINES 0x8E7A +#define GL_FRACTIONAL_ODD 0x8E7B +#define GL_FRACTIONAL_EVEN 0x8E7C +#define GL_MAX_PATCH_VERTICES 0x8E7D +#define GL_MAX_TESS_GEN_LEVEL 0x8E7E +#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E7F +#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E80 +#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS 0x8E81 +#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS 0x8E82 +#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS 0x8E83 +#define GL_MAX_TESS_PATCH_COMPONENTS 0x8E84 +#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 0x8E85 +#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS 0x8E86 +#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS 0x8E89 +#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS 0x8E8A +#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS 0x886C +#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS 0x886D +#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E1E +#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E1F +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER 0x84F0 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER 0x84F1 +#define GL_TESS_EVALUATION_SHADER 0x8E87 +#define GL_TESS_CONTROL_SHADER 0x8E88 +#define GL_TRANSFORM_FEEDBACK 0x8E22 +#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED 0x8E23 +#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE 0x8E24 +#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 +#define GL_MAX_TRANSFORM_FEEDBACK_BUFFERS 0x8E70 +typedef void (APIENTRYP PFNGLMINSAMPLESHADINGPROC) (GLfloat value); +typedef void (APIENTRYP PFNGLBLENDEQUATIONIPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLBLENDFUNCIPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +typedef void (APIENTRYP PFNGLDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect); +typedef void (APIENTRYP PFNGLUNIFORM1DPROC) (GLint location, GLdouble x); +typedef void (APIENTRYP PFNGLUNIFORM2DPROC) (GLint location, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLUNIFORM3DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLUNIFORM4DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLUNIFORM1DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM2DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM3DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM4DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLGETUNIFORMDVPROC) (GLuint program, GLint location, GLdouble *params); +typedef GLint (APIENTRYP PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC) (GLuint program, GLenum shadertype, const GLchar *name); +typedef GLuint (APIENTRYP PFNGLGETSUBROUTINEINDEXPROC) (GLuint program, GLenum shadertype, const GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC) (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINENAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORMSUBROUTINESUIVPROC) (GLenum shadertype, GLsizei count, const GLuint *indices); +typedef void (APIENTRYP PFNGLGETUNIFORMSUBROUTINEUIVPROC) (GLenum shadertype, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTAGEIVPROC) (GLuint program, GLenum shadertype, GLenum pname, GLint *values); +typedef void (APIENTRYP PFNGLPATCHPARAMETERIPROC) (GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLPATCHPARAMETERFVPROC) (GLenum pname, const GLfloat *values); +typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSPROC) (GLsizei n, const GLuint *ids); +typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKPROC) (GLuint id); +typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKPROC) (GLenum mode, GLuint id); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC) (GLenum mode, GLuint id, GLuint stream); +typedef void (APIENTRYP PFNGLBEGINQUERYINDEXEDPROC) (GLenum target, GLuint index, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYINDEXEDPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLGETQUERYINDEXEDIVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMinSampleShading (GLfloat value); +GLAPI void APIENTRY glBlendEquationi (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparatei (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glBlendFunci (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparatei (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +GLAPI void APIENTRY glDrawArraysIndirect (GLenum mode, const void *indirect); +GLAPI void APIENTRY glDrawElementsIndirect (GLenum mode, GLenum type, const void *indirect); +GLAPI void APIENTRY glUniform1d (GLint location, GLdouble x); +GLAPI void APIENTRY glUniform2d (GLint location, GLdouble x, GLdouble y); +GLAPI void APIENTRY glUniform3d (GLint location, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glUniform4d (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glUniform1dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform2dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform3dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform4dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glGetUniformdv (GLuint program, GLint location, GLdouble *params); +GLAPI GLint APIENTRY glGetSubroutineUniformLocation (GLuint program, GLenum shadertype, const GLchar *name); +GLAPI GLuint APIENTRY glGetSubroutineIndex (GLuint program, GLenum shadertype, const GLchar *name); +GLAPI void APIENTRY glGetActiveSubroutineUniformiv (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); +GLAPI void APIENTRY glGetActiveSubroutineUniformName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glGetActiveSubroutineName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glUniformSubroutinesuiv (GLenum shadertype, GLsizei count, const GLuint *indices); +GLAPI void APIENTRY glGetUniformSubroutineuiv (GLenum shadertype, GLint location, GLuint *params); +GLAPI void APIENTRY glGetProgramStageiv (GLuint program, GLenum shadertype, GLenum pname, GLint *values); +GLAPI void APIENTRY glPatchParameteri (GLenum pname, GLint value); +GLAPI void APIENTRY glPatchParameterfv (GLenum pname, const GLfloat *values); +GLAPI void APIENTRY glBindTransformFeedback (GLenum target, GLuint id); +GLAPI void APIENTRY glDeleteTransformFeedbacks (GLsizei n, const GLuint *ids); +GLAPI void APIENTRY glGenTransformFeedbacks (GLsizei n, GLuint *ids); +GLAPI GLboolean APIENTRY glIsTransformFeedback (GLuint id); +GLAPI void APIENTRY glPauseTransformFeedback (void); +GLAPI void APIENTRY glResumeTransformFeedback (void); +GLAPI void APIENTRY glDrawTransformFeedback (GLenum mode, GLuint id); +GLAPI void APIENTRY glDrawTransformFeedbackStream (GLenum mode, GLuint id, GLuint stream); +GLAPI void APIENTRY glBeginQueryIndexed (GLenum target, GLuint index, GLuint id); +GLAPI void APIENTRY glEndQueryIndexed (GLenum target, GLuint index); +GLAPI void APIENTRY glGetQueryIndexediv (GLenum target, GLuint index, GLenum pname, GLint *params); +#endif +#endif /* GL_VERSION_4_0 */ + +#ifndef GL_VERSION_4_1 +#define GL_VERSION_4_1 1 +#define GL_FIXED 0x140C +#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B +#define GL_LOW_FLOAT 0x8DF0 +#define GL_MEDIUM_FLOAT 0x8DF1 +#define GL_HIGH_FLOAT 0x8DF2 +#define GL_LOW_INT 0x8DF3 +#define GL_MEDIUM_INT 0x8DF4 +#define GL_HIGH_INT 0x8DF5 +#define GL_SHADER_COMPILER 0x8DFA +#define GL_SHADER_BINARY_FORMATS 0x8DF8 +#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 +#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB +#define GL_MAX_VARYING_VECTORS 0x8DFC +#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD +#define GL_RGB565 0x8D62 +#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257 +#define GL_PROGRAM_BINARY_LENGTH 0x8741 +#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE +#define GL_PROGRAM_BINARY_FORMATS 0x87FF +#define GL_VERTEX_SHADER_BIT 0x00000001 +#define GL_FRAGMENT_SHADER_BIT 0x00000002 +#define GL_GEOMETRY_SHADER_BIT 0x00000004 +#define GL_TESS_CONTROL_SHADER_BIT 0x00000008 +#define GL_TESS_EVALUATION_SHADER_BIT 0x00000010 +#define GL_ALL_SHADER_BITS 0xFFFFFFFF +#define GL_PROGRAM_SEPARABLE 0x8258 +#define GL_ACTIVE_PROGRAM 0x8259 +#define GL_PROGRAM_PIPELINE_BINDING 0x825A +#define GL_MAX_VIEWPORTS 0x825B +#define GL_VIEWPORT_SUBPIXEL_BITS 0x825C +#define GL_VIEWPORT_BOUNDS_RANGE 0x825D +#define GL_LAYER_PROVOKING_VERTEX 0x825E +#define GL_VIEWPORT_INDEX_PROVOKING_VERTEX 0x825F +#define GL_UNDEFINED_VERTEX 0x8260 +typedef void (APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void); +typedef void (APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryFormat, const void *binary, GLsizei length); +typedef void (APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +typedef void (APIENTRYP PFNGLDEPTHRANGEFPROC) (GLfloat n, GLfloat f); +typedef void (APIENTRYP PFNGLCLEARDEPTHFPROC) (GLfloat d); +typedef void (APIENTRYP PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); +typedef void (APIENTRYP PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLUSEPROGRAMSTAGESPROC) (GLuint pipeline, GLbitfield stages, GLuint program); +typedef void (APIENTRYP PFNGLACTIVESHADERPROGRAMPROC) (GLuint pipeline, GLuint program); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMVPROC) (GLenum type, GLsizei count, const GLchar *const*strings); +typedef void (APIENTRYP PFNGLBINDPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLDELETEPROGRAMPIPELINESPROC) (GLsizei n, const GLuint *pipelines); +typedef void (APIENTRYP PFNGLGENPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEIVPROC) (GLuint pipeline, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IPROC) (GLuint program, GLint location, GLint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FPROC) (GLuint program, GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DPROC) (GLuint program, GLint location, GLdouble v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIPROC) (GLuint program, GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IPROC) (GLuint program, GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLVIEWPORTARRAYVPROC) (GLuint first, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLSCISSORARRAYVPROC) (GLuint first, GLsizei count, const GLint *v); +typedef void (APIENTRYP PFNGLSCISSORINDEXEDPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLSCISSORINDEXEDVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLDEPTHRANGEARRAYVPROC) (GLuint first, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLDEPTHRANGEINDEXEDPROC) (GLuint index, GLdouble n, GLdouble f); +typedef void (APIENTRYP PFNGLGETFLOATI_VPROC) (GLenum target, GLuint index, GLfloat *data); +typedef void (APIENTRYP PFNGLGETDOUBLEI_VPROC) (GLenum target, GLuint index, GLdouble *data); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReleaseShaderCompiler (void); +GLAPI void APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryFormat, const void *binary, GLsizei length); +GLAPI void APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +GLAPI void APIENTRY glDepthRangef (GLfloat n, GLfloat f); +GLAPI void APIENTRY glClearDepthf (GLfloat d); +GLAPI void APIENTRY glGetProgramBinary (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); +GLAPI void APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length); +GLAPI void APIENTRY glProgramParameteri (GLuint program, GLenum pname, GLint value); +GLAPI void APIENTRY glUseProgramStages (GLuint pipeline, GLbitfield stages, GLuint program); +GLAPI void APIENTRY glActiveShaderProgram (GLuint pipeline, GLuint program); +GLAPI GLuint APIENTRY glCreateShaderProgramv (GLenum type, GLsizei count, const GLchar *const*strings); +GLAPI void APIENTRY glBindProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glDeleteProgramPipelines (GLsizei n, const GLuint *pipelines); +GLAPI void APIENTRY glGenProgramPipelines (GLsizei n, GLuint *pipelines); +GLAPI GLboolean APIENTRY glIsProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glGetProgramPipelineiv (GLuint pipeline, GLenum pname, GLint *params); +GLAPI void APIENTRY glProgramUniform1i (GLuint program, GLint location, GLint v0); +GLAPI void APIENTRY glProgramUniform1iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform1f (GLuint program, GLint location, GLfloat v0); +GLAPI void APIENTRY glProgramUniform1fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform1d (GLuint program, GLint location, GLdouble v0); +GLAPI void APIENTRY glProgramUniform1dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform1ui (GLuint program, GLint location, GLuint v0); +GLAPI void APIENTRY glProgramUniform1uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform2i (GLuint program, GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glProgramUniform2iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform2f (GLuint program, GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glProgramUniform2fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform2d (GLuint program, GLint location, GLdouble v0, GLdouble v1); +GLAPI void APIENTRY glProgramUniform2dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform2ui (GLuint program, GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glProgramUniform2uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform3i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glProgramUniform3iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform3f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glProgramUniform3fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform3d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); +GLAPI void APIENTRY glProgramUniform3dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform3ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glProgramUniform3uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform4i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glProgramUniform4iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform4f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glProgramUniform4fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform4d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); +GLAPI void APIENTRY glProgramUniform4dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform4ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glProgramUniform4uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniformMatrix2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glValidateProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glGetProgramPipelineInfoLog (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI void APIENTRY glVertexAttribL1d (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttribL2d (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttribL3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttribL4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttribL1dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL2dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL3dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL4dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribLPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glGetVertexAttribLdv (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glViewportArrayv (GLuint first, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glViewportIndexedf (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +GLAPI void APIENTRY glViewportIndexedfv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glScissorArrayv (GLuint first, GLsizei count, const GLint *v); +GLAPI void APIENTRY glScissorIndexed (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +GLAPI void APIENTRY glScissorIndexedv (GLuint index, const GLint *v); +GLAPI void APIENTRY glDepthRangeArrayv (GLuint first, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glDepthRangeIndexed (GLuint index, GLdouble n, GLdouble f); +GLAPI void APIENTRY glGetFloati_v (GLenum target, GLuint index, GLfloat *data); +GLAPI void APIENTRY glGetDoublei_v (GLenum target, GLuint index, GLdouble *data); +#endif +#endif /* GL_VERSION_4_1 */ + +#ifndef GL_VERSION_4_2 +#define GL_VERSION_4_2 1 +#define GL_COPY_READ_BUFFER_BINDING 0x8F36 +#define GL_COPY_WRITE_BUFFER_BINDING 0x8F37 +#define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24 +#define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23 +#define GL_UNPACK_COMPRESSED_BLOCK_WIDTH 0x9127 +#define GL_UNPACK_COMPRESSED_BLOCK_HEIGHT 0x9128 +#define GL_UNPACK_COMPRESSED_BLOCK_DEPTH 0x9129 +#define GL_UNPACK_COMPRESSED_BLOCK_SIZE 0x912A +#define GL_PACK_COMPRESSED_BLOCK_WIDTH 0x912B +#define GL_PACK_COMPRESSED_BLOCK_HEIGHT 0x912C +#define GL_PACK_COMPRESSED_BLOCK_DEPTH 0x912D +#define GL_PACK_COMPRESSED_BLOCK_SIZE 0x912E +#define GL_NUM_SAMPLE_COUNTS 0x9380 +#define GL_MIN_MAP_BUFFER_ALIGNMENT 0x90BC +#define GL_ATOMIC_COUNTER_BUFFER 0x92C0 +#define GL_ATOMIC_COUNTER_BUFFER_BINDING 0x92C1 +#define GL_ATOMIC_COUNTER_BUFFER_START 0x92C2 +#define GL_ATOMIC_COUNTER_BUFFER_SIZE 0x92C3 +#define GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE 0x92C4 +#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS 0x92C5 +#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES 0x92C6 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER 0x92C7 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER 0x92C8 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER 0x92C9 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER 0x92CA +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER 0x92CB +#define GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS 0x92CC +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS 0x92CD +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS 0x92CE +#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS 0x92CF +#define GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS 0x92D0 +#define GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS 0x92D1 +#define GL_MAX_VERTEX_ATOMIC_COUNTERS 0x92D2 +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS 0x92D3 +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS 0x92D4 +#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS 0x92D5 +#define GL_MAX_FRAGMENT_ATOMIC_COUNTERS 0x92D6 +#define GL_MAX_COMBINED_ATOMIC_COUNTERS 0x92D7 +#define GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE 0x92D8 +#define GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS 0x92DC +#define GL_ACTIVE_ATOMIC_COUNTER_BUFFERS 0x92D9 +#define GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX 0x92DA +#define GL_UNSIGNED_INT_ATOMIC_COUNTER 0x92DB +#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001 +#define GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002 +#define GL_UNIFORM_BARRIER_BIT 0x00000004 +#define GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008 +#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020 +#define GL_COMMAND_BARRIER_BIT 0x00000040 +#define GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080 +#define GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100 +#define GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200 +#define GL_FRAMEBUFFER_BARRIER_BIT 0x00000400 +#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800 +#define GL_ATOMIC_COUNTER_BARRIER_BIT 0x00001000 +#define GL_ALL_BARRIER_BITS 0xFFFFFFFF +#define GL_MAX_IMAGE_UNITS 0x8F38 +#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS 0x8F39 +#define GL_IMAGE_BINDING_NAME 0x8F3A +#define GL_IMAGE_BINDING_LEVEL 0x8F3B +#define GL_IMAGE_BINDING_LAYERED 0x8F3C +#define GL_IMAGE_BINDING_LAYER 0x8F3D +#define GL_IMAGE_BINDING_ACCESS 0x8F3E +#define GL_IMAGE_1D 0x904C +#define GL_IMAGE_2D 0x904D +#define GL_IMAGE_3D 0x904E +#define GL_IMAGE_2D_RECT 0x904F +#define GL_IMAGE_CUBE 0x9050 +#define GL_IMAGE_BUFFER 0x9051 +#define GL_IMAGE_1D_ARRAY 0x9052 +#define GL_IMAGE_2D_ARRAY 0x9053 +#define GL_IMAGE_CUBE_MAP_ARRAY 0x9054 +#define GL_IMAGE_2D_MULTISAMPLE 0x9055 +#define GL_IMAGE_2D_MULTISAMPLE_ARRAY 0x9056 +#define GL_INT_IMAGE_1D 0x9057 +#define GL_INT_IMAGE_2D 0x9058 +#define GL_INT_IMAGE_3D 0x9059 +#define GL_INT_IMAGE_2D_RECT 0x905A +#define GL_INT_IMAGE_CUBE 0x905B +#define GL_INT_IMAGE_BUFFER 0x905C +#define GL_INT_IMAGE_1D_ARRAY 0x905D +#define GL_INT_IMAGE_2D_ARRAY 0x905E +#define GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F +#define GL_INT_IMAGE_2D_MULTISAMPLE 0x9060 +#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x9061 +#define GL_UNSIGNED_INT_IMAGE_1D 0x9062 +#define GL_UNSIGNED_INT_IMAGE_2D 0x9063 +#define GL_UNSIGNED_INT_IMAGE_3D 0x9064 +#define GL_UNSIGNED_INT_IMAGE_2D_RECT 0x9065 +#define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066 +#define GL_UNSIGNED_INT_IMAGE_BUFFER 0x9067 +#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY 0x9068 +#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069 +#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE 0x906B +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x906C +#define GL_MAX_IMAGE_SAMPLES 0x906D +#define GL_IMAGE_BINDING_FORMAT 0x906E +#define GL_IMAGE_FORMAT_COMPATIBILITY_TYPE 0x90C7 +#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE 0x90C8 +#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS 0x90C9 +#define GL_MAX_VERTEX_IMAGE_UNIFORMS 0x90CA +#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS 0x90CB +#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS 0x90CC +#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS 0x90CD +#define GL_MAX_FRAGMENT_IMAGE_UNIFORMS 0x90CE +#define GL_MAX_COMBINED_IMAGE_UNIFORMS 0x90CF +#define GL_COMPRESSED_RGBA_BPTC_UNORM 0x8E8C +#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM 0x8E8D +#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT 0x8E8E +#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT 0x8E8F +#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); +typedef void (APIENTRYP PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei count, GLint *params); +typedef void (APIENTRYP PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC) (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); +typedef void (APIENTRYP PFNGLMEMORYBARRIERPROC) (GLbitfield barriers); +typedef void (APIENTRYP PFNGLTEXSTORAGE1DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (APIENTRYP PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC) (GLenum mode, GLuint id, GLsizei instancecount); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedBaseInstance (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); +GLAPI void APIENTRY glDrawElementsInstancedBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); +GLAPI void APIENTRY glDrawElementsInstancedBaseVertexBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); +GLAPI void APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei count, GLint *params); +GLAPI void APIENTRY glGetActiveAtomicCounterBufferiv (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); +GLAPI void APIENTRY glBindImageTexture (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); +GLAPI void APIENTRY glMemoryBarrier (GLbitfield barriers); +GLAPI void APIENTRY glTexStorage1D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +GLAPI void APIENTRY glTexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glDrawTransformFeedbackInstanced (GLenum mode, GLuint id, GLsizei instancecount); +GLAPI void APIENTRY glDrawTransformFeedbackStreamInstanced (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); +#endif +#endif /* GL_VERSION_4_2 */ + +#ifndef GL_VERSION_4_3 +#define GL_VERSION_4_3 1 +typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); +#define GL_NUM_SHADING_LANGUAGE_VERSIONS 0x82E9 +#define GL_VERTEX_ATTRIB_ARRAY_LONG 0x874E +#define GL_COMPRESSED_RGB8_ETC2 0x9274 +#define GL_COMPRESSED_SRGB8_ETC2 0x9275 +#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276 +#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277 +#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278 +#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279 +#define GL_COMPRESSED_R11_EAC 0x9270 +#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271 +#define GL_COMPRESSED_RG11_EAC 0x9272 +#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273 +#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69 +#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A +#define GL_MAX_ELEMENT_INDEX 0x8D6B +#define GL_COMPUTE_SHADER 0x91B9 +#define GL_MAX_COMPUTE_UNIFORM_BLOCKS 0x91BB +#define GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS 0x91BC +#define GL_MAX_COMPUTE_IMAGE_UNIFORMS 0x91BD +#define GL_MAX_COMPUTE_SHARED_MEMORY_SIZE 0x8262 +#define GL_MAX_COMPUTE_UNIFORM_COMPONENTS 0x8263 +#define GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS 0x8264 +#define GL_MAX_COMPUTE_ATOMIC_COUNTERS 0x8265 +#define GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS 0x8266 +#define GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS 0x90EB +#define GL_MAX_COMPUTE_WORK_GROUP_COUNT 0x91BE +#define GL_MAX_COMPUTE_WORK_GROUP_SIZE 0x91BF +#define GL_COMPUTE_WORK_GROUP_SIZE 0x8267 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER 0x90EC +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER 0x90ED +#define GL_DISPATCH_INDIRECT_BUFFER 0x90EE +#define GL_DISPATCH_INDIRECT_BUFFER_BINDING 0x90EF +#define GL_COMPUTE_SHADER_BIT 0x00000020 +#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243 +#define GL_DEBUG_CALLBACK_FUNCTION 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM 0x8245 +#define GL_DEBUG_SOURCE_API 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION 0x824A +#define GL_DEBUG_SOURCE_OTHER 0x824B +#define GL_DEBUG_TYPE_ERROR 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E +#define GL_DEBUG_TYPE_PORTABILITY 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE 0x8250 +#define GL_DEBUG_TYPE_OTHER 0x8251 +#define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES 0x9145 +#define GL_DEBUG_SEVERITY_HIGH 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM 0x9147 +#define GL_DEBUG_SEVERITY_LOW 0x9148 +#define GL_DEBUG_TYPE_MARKER 0x8268 +#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269 +#define GL_DEBUG_TYPE_POP_GROUP 0x826A +#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B +#define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C +#define GL_DEBUG_GROUP_STACK_DEPTH 0x826D +#define GL_BUFFER 0x82E0 +#define GL_SHADER 0x82E1 +#define GL_PROGRAM 0x82E2 +#define GL_QUERY 0x82E3 +#define GL_PROGRAM_PIPELINE 0x82E4 +#define GL_SAMPLER 0x82E6 +#define GL_MAX_LABEL_LENGTH 0x82E8 +#define GL_DEBUG_OUTPUT 0x92E0 +#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002 +#define GL_MAX_UNIFORM_LOCATIONS 0x826E +#define GL_FRAMEBUFFER_DEFAULT_WIDTH 0x9310 +#define GL_FRAMEBUFFER_DEFAULT_HEIGHT 0x9311 +#define GL_FRAMEBUFFER_DEFAULT_LAYERS 0x9312 +#define GL_FRAMEBUFFER_DEFAULT_SAMPLES 0x9313 +#define GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS 0x9314 +#define GL_MAX_FRAMEBUFFER_WIDTH 0x9315 +#define GL_MAX_FRAMEBUFFER_HEIGHT 0x9316 +#define GL_MAX_FRAMEBUFFER_LAYERS 0x9317 +#define GL_MAX_FRAMEBUFFER_SAMPLES 0x9318 +#define GL_INTERNALFORMAT_SUPPORTED 0x826F +#define GL_INTERNALFORMAT_PREFERRED 0x8270 +#define GL_INTERNALFORMAT_RED_SIZE 0x8271 +#define GL_INTERNALFORMAT_GREEN_SIZE 0x8272 +#define GL_INTERNALFORMAT_BLUE_SIZE 0x8273 +#define GL_INTERNALFORMAT_ALPHA_SIZE 0x8274 +#define GL_INTERNALFORMAT_DEPTH_SIZE 0x8275 +#define GL_INTERNALFORMAT_STENCIL_SIZE 0x8276 +#define GL_INTERNALFORMAT_SHARED_SIZE 0x8277 +#define GL_INTERNALFORMAT_RED_TYPE 0x8278 +#define GL_INTERNALFORMAT_GREEN_TYPE 0x8279 +#define GL_INTERNALFORMAT_BLUE_TYPE 0x827A +#define GL_INTERNALFORMAT_ALPHA_TYPE 0x827B +#define GL_INTERNALFORMAT_DEPTH_TYPE 0x827C +#define GL_INTERNALFORMAT_STENCIL_TYPE 0x827D +#define GL_MAX_WIDTH 0x827E +#define GL_MAX_HEIGHT 0x827F +#define GL_MAX_DEPTH 0x8280 +#define GL_MAX_LAYERS 0x8281 +#define GL_MAX_COMBINED_DIMENSIONS 0x8282 +#define GL_COLOR_COMPONENTS 0x8283 +#define GL_DEPTH_COMPONENTS 0x8284 +#define GL_STENCIL_COMPONENTS 0x8285 +#define GL_COLOR_RENDERABLE 0x8286 +#define GL_DEPTH_RENDERABLE 0x8287 +#define GL_STENCIL_RENDERABLE 0x8288 +#define GL_FRAMEBUFFER_RENDERABLE 0x8289 +#define GL_FRAMEBUFFER_RENDERABLE_LAYERED 0x828A +#define GL_FRAMEBUFFER_BLEND 0x828B +#define GL_READ_PIXELS 0x828C +#define GL_READ_PIXELS_FORMAT 0x828D +#define GL_READ_PIXELS_TYPE 0x828E +#define GL_TEXTURE_IMAGE_FORMAT 0x828F +#define GL_TEXTURE_IMAGE_TYPE 0x8290 +#define GL_GET_TEXTURE_IMAGE_FORMAT 0x8291 +#define GL_GET_TEXTURE_IMAGE_TYPE 0x8292 +#define GL_MIPMAP 0x8293 +#define GL_MANUAL_GENERATE_MIPMAP 0x8294 +#define GL_AUTO_GENERATE_MIPMAP 0x8295 +#define GL_COLOR_ENCODING 0x8296 +#define GL_SRGB_READ 0x8297 +#define GL_SRGB_WRITE 0x8298 +#define GL_FILTER 0x829A +#define GL_VERTEX_TEXTURE 0x829B +#define GL_TESS_CONTROL_TEXTURE 0x829C +#define GL_TESS_EVALUATION_TEXTURE 0x829D +#define GL_GEOMETRY_TEXTURE 0x829E +#define GL_FRAGMENT_TEXTURE 0x829F +#define GL_COMPUTE_TEXTURE 0x82A0 +#define GL_TEXTURE_SHADOW 0x82A1 +#define GL_TEXTURE_GATHER 0x82A2 +#define GL_TEXTURE_GATHER_SHADOW 0x82A3 +#define GL_SHADER_IMAGE_LOAD 0x82A4 +#define GL_SHADER_IMAGE_STORE 0x82A5 +#define GL_SHADER_IMAGE_ATOMIC 0x82A6 +#define GL_IMAGE_TEXEL_SIZE 0x82A7 +#define GL_IMAGE_COMPATIBILITY_CLASS 0x82A8 +#define GL_IMAGE_PIXEL_FORMAT 0x82A9 +#define GL_IMAGE_PIXEL_TYPE 0x82AA +#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST 0x82AC +#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST 0x82AD +#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE 0x82AE +#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE 0x82AF +#define GL_TEXTURE_COMPRESSED_BLOCK_WIDTH 0x82B1 +#define GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT 0x82B2 +#define GL_TEXTURE_COMPRESSED_BLOCK_SIZE 0x82B3 +#define GL_CLEAR_BUFFER 0x82B4 +#define GL_TEXTURE_VIEW 0x82B5 +#define GL_VIEW_COMPATIBILITY_CLASS 0x82B6 +#define GL_FULL_SUPPORT 0x82B7 +#define GL_CAVEAT_SUPPORT 0x82B8 +#define GL_IMAGE_CLASS_4_X_32 0x82B9 +#define GL_IMAGE_CLASS_2_X_32 0x82BA +#define GL_IMAGE_CLASS_1_X_32 0x82BB +#define GL_IMAGE_CLASS_4_X_16 0x82BC +#define GL_IMAGE_CLASS_2_X_16 0x82BD +#define GL_IMAGE_CLASS_1_X_16 0x82BE +#define GL_IMAGE_CLASS_4_X_8 0x82BF +#define GL_IMAGE_CLASS_2_X_8 0x82C0 +#define GL_IMAGE_CLASS_1_X_8 0x82C1 +#define GL_IMAGE_CLASS_11_11_10 0x82C2 +#define GL_IMAGE_CLASS_10_10_10_2 0x82C3 +#define GL_VIEW_CLASS_128_BITS 0x82C4 +#define GL_VIEW_CLASS_96_BITS 0x82C5 +#define GL_VIEW_CLASS_64_BITS 0x82C6 +#define GL_VIEW_CLASS_48_BITS 0x82C7 +#define GL_VIEW_CLASS_32_BITS 0x82C8 +#define GL_VIEW_CLASS_24_BITS 0x82C9 +#define GL_VIEW_CLASS_16_BITS 0x82CA +#define GL_VIEW_CLASS_8_BITS 0x82CB +#define GL_VIEW_CLASS_S3TC_DXT1_RGB 0x82CC +#define GL_VIEW_CLASS_S3TC_DXT1_RGBA 0x82CD +#define GL_VIEW_CLASS_S3TC_DXT3_RGBA 0x82CE +#define GL_VIEW_CLASS_S3TC_DXT5_RGBA 0x82CF +#define GL_VIEW_CLASS_RGTC1_RED 0x82D0 +#define GL_VIEW_CLASS_RGTC2_RG 0x82D1 +#define GL_VIEW_CLASS_BPTC_UNORM 0x82D2 +#define GL_VIEW_CLASS_BPTC_FLOAT 0x82D3 +#define GL_UNIFORM 0x92E1 +#define GL_UNIFORM_BLOCK 0x92E2 +#define GL_PROGRAM_INPUT 0x92E3 +#define GL_PROGRAM_OUTPUT 0x92E4 +#define GL_BUFFER_VARIABLE 0x92E5 +#define GL_SHADER_STORAGE_BLOCK 0x92E6 +#define GL_VERTEX_SUBROUTINE 0x92E8 +#define GL_TESS_CONTROL_SUBROUTINE 0x92E9 +#define GL_TESS_EVALUATION_SUBROUTINE 0x92EA +#define GL_GEOMETRY_SUBROUTINE 0x92EB +#define GL_FRAGMENT_SUBROUTINE 0x92EC +#define GL_COMPUTE_SUBROUTINE 0x92ED +#define GL_VERTEX_SUBROUTINE_UNIFORM 0x92EE +#define GL_TESS_CONTROL_SUBROUTINE_UNIFORM 0x92EF +#define GL_TESS_EVALUATION_SUBROUTINE_UNIFORM 0x92F0 +#define GL_GEOMETRY_SUBROUTINE_UNIFORM 0x92F1 +#define GL_FRAGMENT_SUBROUTINE_UNIFORM 0x92F2 +#define GL_COMPUTE_SUBROUTINE_UNIFORM 0x92F3 +#define GL_TRANSFORM_FEEDBACK_VARYING 0x92F4 +#define GL_ACTIVE_RESOURCES 0x92F5 +#define GL_MAX_NAME_LENGTH 0x92F6 +#define GL_MAX_NUM_ACTIVE_VARIABLES 0x92F7 +#define GL_MAX_NUM_COMPATIBLE_SUBROUTINES 0x92F8 +#define GL_NAME_LENGTH 0x92F9 +#define GL_TYPE 0x92FA +#define GL_ARRAY_SIZE 0x92FB +#define GL_OFFSET 0x92FC +#define GL_BLOCK_INDEX 0x92FD +#define GL_ARRAY_STRIDE 0x92FE +#define GL_MATRIX_STRIDE 0x92FF +#define GL_IS_ROW_MAJOR 0x9300 +#define GL_ATOMIC_COUNTER_BUFFER_INDEX 0x9301 +#define GL_BUFFER_BINDING 0x9302 +#define GL_BUFFER_DATA_SIZE 0x9303 +#define GL_NUM_ACTIVE_VARIABLES 0x9304 +#define GL_ACTIVE_VARIABLES 0x9305 +#define GL_REFERENCED_BY_VERTEX_SHADER 0x9306 +#define GL_REFERENCED_BY_TESS_CONTROL_SHADER 0x9307 +#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER 0x9308 +#define GL_REFERENCED_BY_GEOMETRY_SHADER 0x9309 +#define GL_REFERENCED_BY_FRAGMENT_SHADER 0x930A +#define GL_REFERENCED_BY_COMPUTE_SHADER 0x930B +#define GL_TOP_LEVEL_ARRAY_SIZE 0x930C +#define GL_TOP_LEVEL_ARRAY_STRIDE 0x930D +#define GL_LOCATION 0x930E +#define GL_LOCATION_INDEX 0x930F +#define GL_IS_PER_PATCH 0x92E7 +#define GL_SHADER_STORAGE_BUFFER 0x90D2 +#define GL_SHADER_STORAGE_BUFFER_BINDING 0x90D3 +#define GL_SHADER_STORAGE_BUFFER_START 0x90D4 +#define GL_SHADER_STORAGE_BUFFER_SIZE 0x90D5 +#define GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS 0x90D6 +#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS 0x90D7 +#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS 0x90D8 +#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS 0x90D9 +#define GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS 0x90DA +#define GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS 0x90DB +#define GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS 0x90DC +#define GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS 0x90DD +#define GL_MAX_SHADER_STORAGE_BLOCK_SIZE 0x90DE +#define GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT 0x90DF +#define GL_SHADER_STORAGE_BARRIER_BIT 0x00002000 +#define GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES 0x8F39 +#define GL_DEPTH_STENCIL_TEXTURE_MODE 0x90EA +#define GL_TEXTURE_BUFFER_OFFSET 0x919D +#define GL_TEXTURE_BUFFER_SIZE 0x919E +#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT 0x919F +#define GL_TEXTURE_VIEW_MIN_LEVEL 0x82DB +#define GL_TEXTURE_VIEW_NUM_LEVELS 0x82DC +#define GL_TEXTURE_VIEW_MIN_LAYER 0x82DD +#define GL_TEXTURE_VIEW_NUM_LAYERS 0x82DE +#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF +#define GL_VERTEX_ATTRIB_BINDING 0x82D4 +#define GL_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D5 +#define GL_VERTEX_BINDING_DIVISOR 0x82D6 +#define GL_VERTEX_BINDING_OFFSET 0x82D7 +#define GL_VERTEX_BINDING_STRIDE 0x82D8 +#define GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D9 +#define GL_MAX_VERTEX_ATTRIB_BINDINGS 0x82DA +#define GL_VERTEX_BINDING_BUFFER 0x8F4F +#define GL_DISPLAY_LIST 0x82E7 +typedef void (APIENTRYP PFNGLCLEARBUFFERDATAPROC) (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARBUFFERSUBDATAPROC) (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); +typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEINDIRECTPROC) (GLintptr indirect); +typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATAPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +typedef void (APIENTRYP PFNGLFRAMEBUFFERPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETINTERNALFORMATI64VPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei count, GLint64 *params); +typedef void (APIENTRYP PFNGLINVALIDATETEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLINVALIDATETEXIMAGEPROC) (GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLINVALIDATEBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLINVALIDATEBUFFERDATAPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLINVALIDATEFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments); +typedef void (APIENTRYP PFNGLINVALIDATESUBFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLGETPROGRAMINTERFACEIVPROC) (GLuint program, GLenum programInterface, GLenum pname, GLint *params); +typedef GLuint (APIENTRYP PFNGLGETPROGRAMRESOURCEINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCENAMEPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCEIVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei count, GLsizei *length, GLint *params); +typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef void (APIENTRYP PFNGLSHADERSTORAGEBLOCKBINDINGPROC) (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); +typedef void (APIENTRYP PFNGLTEXBUFFERRANGEPROC) (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLTEXSTORAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXSTORAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTUREVIEWPROC) (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); +typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERPROC) (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBBINDINGPROC) (GLuint attribindex, GLuint bindingindex); +typedef void (APIENTRYP PFNGLVERTEXBINDINGDIVISORPROC) (GLuint bindingindex, GLuint divisor); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKPROC) (GLDEBUGPROC callback, const void *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGPROC) (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +typedef void (APIENTRYP PFNGLPUSHDEBUGGROUPPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message); +typedef void (APIENTRYP PFNGLPOPDEBUGGROUPPROC) (void); +typedef void (APIENTRYP PFNGLOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +typedef void (APIENTRYP PFNGLGETOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +typedef void (APIENTRYP PFNGLOBJECTPTRLABELPROC) (const void *ptr, GLsizei length, const GLchar *label); +typedef void (APIENTRYP PFNGLGETOBJECTPTRLABELPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClearBufferData (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearBufferSubData (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glDispatchCompute (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); +GLAPI void APIENTRY glDispatchComputeIndirect (GLintptr indirect); +GLAPI void APIENTRY glCopyImageSubData (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +GLAPI void APIENTRY glFramebufferParameteri (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glGetFramebufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetInternalformati64v (GLenum target, GLenum internalformat, GLenum pname, GLsizei count, GLint64 *params); +GLAPI void APIENTRY glInvalidateTexSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glInvalidateTexImage (GLuint texture, GLint level); +GLAPI void APIENTRY glInvalidateBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glInvalidateBufferData (GLuint buffer); +GLAPI void APIENTRY glInvalidateFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments); +GLAPI void APIENTRY glInvalidateSubFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glMultiDrawArraysIndirect (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirect (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); +GLAPI void APIENTRY glGetProgramInterfaceiv (GLuint program, GLenum programInterface, GLenum pname, GLint *params); +GLAPI GLuint APIENTRY glGetProgramResourceIndex (GLuint program, GLenum programInterface, const GLchar *name); +GLAPI void APIENTRY glGetProgramResourceName (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glGetProgramResourceiv (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei count, GLsizei *length, GLint *params); +GLAPI GLint APIENTRY glGetProgramResourceLocation (GLuint program, GLenum programInterface, const GLchar *name); +GLAPI GLint APIENTRY glGetProgramResourceLocationIndex (GLuint program, GLenum programInterface, const GLchar *name); +GLAPI void APIENTRY glShaderStorageBlockBinding (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); +GLAPI void APIENTRY glTexBufferRange (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glTexStorage2DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTexStorage3DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureView (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); +GLAPI void APIENTRY glBindVertexBuffer (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +GLAPI void APIENTRY glVertexAttribFormat (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribIFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribLFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribBinding (GLuint attribindex, GLuint bindingindex); +GLAPI void APIENTRY glVertexBindingDivisor (GLuint bindingindex, GLuint divisor); +GLAPI void APIENTRY glDebugMessageControl (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsert (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallback (GLDEBUGPROC callback, const void *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLog (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +GLAPI void APIENTRY glPushDebugGroup (GLenum source, GLuint id, GLsizei length, const GLchar *message); +GLAPI void APIENTRY glPopDebugGroup (void); +GLAPI void APIENTRY glObjectLabel (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +GLAPI void APIENTRY glGetObjectLabel (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +GLAPI void APIENTRY glObjectPtrLabel (const void *ptr, GLsizei length, const GLchar *label); +GLAPI void APIENTRY glGetObjectPtrLabel (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +#endif +#endif /* GL_VERSION_4_3 */ + +#ifndef GL_VERSION_4_4 +#define GL_VERSION_4_4 1 +#define GL_MAX_VERTEX_ATTRIB_STRIDE 0x82E5 +#define GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED 0x8221 +#define GL_TEXTURE_BUFFER_BINDING 0x8C2A +#define GL_MAP_PERSISTENT_BIT 0x0040 +#define GL_MAP_COHERENT_BIT 0x0080 +#define GL_DYNAMIC_STORAGE_BIT 0x0100 +#define GL_CLIENT_STORAGE_BIT 0x0200 +#define GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT 0x00004000 +#define GL_BUFFER_IMMUTABLE_STORAGE 0x821F +#define GL_BUFFER_STORAGE_FLAGS 0x8220 +#define GL_CLEAR_TEXTURE 0x9365 +#define GL_LOCATION_COMPONENT 0x934A +#define GL_TRANSFORM_FEEDBACK_BUFFER_INDEX 0x934B +#define GL_TRANSFORM_FEEDBACK_BUFFER_STRIDE 0x934C +#define GL_QUERY_BUFFER 0x9192 +#define GL_QUERY_BUFFER_BARRIER_BIT 0x00008000 +#define GL_QUERY_BUFFER_BINDING 0x9193 +#define GL_QUERY_RESULT_NO_WAIT 0x9194 +#define GL_MIRROR_CLAMP_TO_EDGE 0x8743 +typedef void (APIENTRYP PFNGLBUFFERSTORAGEPROC) (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags); +typedef void (APIENTRYP PFNGLCLEARTEXIMAGEPROC) (GLuint texture, GLint level, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARTEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLBINDBUFFERSBASEPROC) (GLenum target, GLuint first, GLsizei count, const GLuint *buffers); +typedef void (APIENTRYP PFNGLBINDBUFFERSRANGEPROC) (GLenum target, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizeiptr *sizes); +typedef void (APIENTRYP PFNGLBINDTEXTURESPROC) (GLuint first, GLsizei count, const GLuint *textures); +typedef void (APIENTRYP PFNGLBINDSAMPLERSPROC) (GLuint first, GLsizei count, const GLuint *samplers); +typedef void (APIENTRYP PFNGLBINDIMAGETEXTURESPROC) (GLuint first, GLsizei count, const GLuint *textures); +typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERSPROC) (GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferStorage (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags); +GLAPI void APIENTRY glClearTexImage (GLuint texture, GLint level, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearTexSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glBindBuffersBase (GLenum target, GLuint first, GLsizei count, const GLuint *buffers); +GLAPI void APIENTRY glBindBuffersRange (GLenum target, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizeiptr *sizes); +GLAPI void APIENTRY glBindTextures (GLuint first, GLsizei count, const GLuint *textures); +GLAPI void APIENTRY glBindSamplers (GLuint first, GLsizei count, const GLuint *samplers); +GLAPI void APIENTRY glBindImageTextures (GLuint first, GLsizei count, const GLuint *textures); +GLAPI void APIENTRY glBindVertexBuffers (GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); +#endif +#endif /* GL_VERSION_4_4 */ + +#ifndef GL_VERSION_4_5 +#define GL_VERSION_4_5 1 +#define GL_CONTEXT_LOST 0x0507 +#define GL_NEGATIVE_ONE_TO_ONE 0x935E +#define GL_ZERO_TO_ONE 0x935F +#define GL_CLIP_ORIGIN 0x935C +#define GL_CLIP_DEPTH_MODE 0x935D +#define GL_QUERY_WAIT_INVERTED 0x8E17 +#define GL_QUERY_NO_WAIT_INVERTED 0x8E18 +#define GL_QUERY_BY_REGION_WAIT_INVERTED 0x8E19 +#define GL_QUERY_BY_REGION_NO_WAIT_INVERTED 0x8E1A +#define GL_MAX_CULL_DISTANCES 0x82F9 +#define GL_MAX_COMBINED_CLIP_AND_CULL_DISTANCES 0x82FA +#define GL_TEXTURE_TARGET 0x1006 +#define GL_QUERY_TARGET 0x82EA +#define GL_GUILTY_CONTEXT_RESET 0x8253 +#define GL_INNOCENT_CONTEXT_RESET 0x8254 +#define GL_UNKNOWN_CONTEXT_RESET 0x8255 +#define GL_RESET_NOTIFICATION_STRATEGY 0x8256 +#define GL_LOSE_CONTEXT_ON_RESET 0x8252 +#define GL_NO_RESET_NOTIFICATION 0x8261 +#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT 0x00000004 +#define GL_COLOR_TABLE 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 +#define GL_PROXY_COLOR_TABLE 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 +#define GL_CONVOLUTION_1D 0x8010 +#define GL_CONVOLUTION_2D 0x8011 +#define GL_SEPARABLE_2D 0x8012 +#define GL_HISTOGRAM 0x8024 +#define GL_PROXY_HISTOGRAM 0x8025 +#define GL_MINMAX 0x802E +#define GL_CONTEXT_RELEASE_BEHAVIOR 0x82FB +#define GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH 0x82FC +typedef void (APIENTRYP PFNGLCLIPCONTROLPROC) (GLenum origin, GLenum depth); +typedef void (APIENTRYP PFNGLCREATETRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKBUFFERBASEPROC) (GLuint xfb, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKBUFFERRANGEPROC) (GLuint xfb, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKIVPROC) (GLuint xfb, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKI_VPROC) (GLuint xfb, GLenum pname, GLuint index, GLint *param); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKI64_VPROC) (GLuint xfb, GLenum pname, GLuint index, GLint64 *param); +typedef void (APIENTRYP PFNGLCREATEBUFFERSPROC) (GLsizei n, GLuint *buffers); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); +typedef void (APIENTRYP PFNGLNAMEDBUFFERDATAPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +typedef void (APIENTRYP PFNGLCOPYNAMEDBUFFERSUBDATAPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERDATAPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAPROC) (GLuint buffer, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFERPROC) (GLuint buffer, GLenum access); +typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFERRANGEPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFERPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERI64VPROC) (GLuint buffer, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVPROC) (GLuint buffer, GLenum pname, void **params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); +typedef void (APIENTRYP PFNGLCREATEFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERRENDERBUFFERPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERPARAMETERIPROC) (GLuint framebuffer, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURELAYERPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERDRAWBUFFERPROC) (GLuint framebuffer, GLenum buf); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERDRAWBUFFERSPROC) (GLuint framebuffer, GLsizei n, const GLenum *bufs); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERREADBUFFERPROC) (GLuint framebuffer, GLenum src); +typedef void (APIENTRYP PFNGLINVALIDATENAMEDFRAMEBUFFERDATAPROC) (GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments); +typedef void (APIENTRYP PFNGLINVALIDATENAMEDFRAMEBUFFERSUBDATAPROC) (GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERIVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLint *value); +typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERUIVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLuint *value); +typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERFVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLfloat *value); +typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERFIPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +typedef void (APIENTRYP PFNGLBLITNAMEDFRAMEBUFFERPROC) (GLuint readFramebuffer, GLuint drawFramebuffer, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef GLenum (APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSPROC) (GLuint framebuffer, GLenum target); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVPROC) (GLuint framebuffer, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLCREATERENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETNAMEDRENDERBUFFERPARAMETERIVPROC) (GLuint renderbuffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLCREATETEXTURESPROC) (GLenum target, GLsizei n, GLuint *textures); +typedef void (APIENTRYP PFNGLTEXTUREBUFFERPROC) (GLuint texture, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLTEXTUREBUFFERRANGEPROC) (GLuint texture, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DPROC) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DPROC) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DPROC) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DMULTISAMPLEPROC) (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DMULTISAMPLEPROC) (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE1DPROC) (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE2DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE3DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE1DPROC) (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE2DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE3DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE1DPROC) (GLuint texture, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE2DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE3DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFPROC) (GLuint texture, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFVPROC) (GLuint texture, GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIPROC) (GLuint texture, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVPROC) (GLuint texture, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVPROC) (GLuint texture, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIVPROC) (GLuint texture, GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLGENERATETEXTUREMIPMAPPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLBINDTEXTUREUNITPROC) (GLuint unit, GLuint texture); +typedef void (APIENTRYP PFNGLGETTEXTUREIMAGEPROC) (GLuint texture, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTUREIMAGEPROC) (GLuint texture, GLint level, GLsizei bufSize, void *pixels); +typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERFVPROC) (GLuint texture, GLint level, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERIVPROC) (GLuint texture, GLint level, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERFVPROC) (GLuint texture, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVPROC) (GLuint texture, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVPROC) (GLuint texture, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIVPROC) (GLuint texture, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLCREATEVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); +typedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYATTRIBPROC) (GLuint vaobj, GLuint index); +typedef void (APIENTRYP PFNGLENABLEVERTEXARRAYATTRIBPROC) (GLuint vaobj, GLuint index); +typedef void (APIENTRYP PFNGLVERTEXARRAYELEMENTBUFFERPROC) (GLuint vaobj, GLuint buffer); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBUFFERPROC) (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBUFFERSPROC) (GLuint vaobj, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); +typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBBINDINGPROC) (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBFORMATPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBIFORMATPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBLFORMATPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYBINDINGDIVISORPROC) (GLuint vaobj, GLuint bindingindex, GLuint divisor); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYIVPROC) (GLuint vaobj, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYINDEXEDIVPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYINDEXED64IVPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint64 *param); +typedef void (APIENTRYP PFNGLCREATESAMPLERSPROC) (GLsizei n, GLuint *samplers); +typedef void (APIENTRYP PFNGLCREATEPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines); +typedef void (APIENTRYP PFNGLCREATEQUERIESPROC) (GLenum target, GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTI64VPROC) (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTIVPROC) (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTUI64VPROC) (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTUIVPROC) (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +typedef void (APIENTRYP PFNGLMEMORYBARRIERBYREGIONPROC) (GLbitfield barriers); +typedef void (APIENTRYP PFNGLGETTEXTURESUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLsizei bufSize, void *pixels); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTURESUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei bufSize, void *pixels); +typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSPROC) (void); +typedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint lod, GLsizei bufSize, void *pixels); +typedef void (APIENTRYP PFNGLGETNTEXIMAGEPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); +typedef void (APIENTRYP PFNGLGETNUNIFORMDVPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMFVPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMIVPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMUIVPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +typedef void (APIENTRYP PFNGLREADNPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); +typedef void (APIENTRYP PFNGLGETNMAPDVPROC) (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); +typedef void (APIENTRYP PFNGLGETNMAPFVPROC) (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); +typedef void (APIENTRYP PFNGLGETNMAPIVPROC) (GLenum target, GLenum query, GLsizei bufSize, GLint *v); +typedef void (APIENTRYP PFNGLGETNPIXELMAPFVPROC) (GLenum map, GLsizei bufSize, GLfloat *values); +typedef void (APIENTRYP PFNGLGETNPIXELMAPUIVPROC) (GLenum map, GLsizei bufSize, GLuint *values); +typedef void (APIENTRYP PFNGLGETNPIXELMAPUSVPROC) (GLenum map, GLsizei bufSize, GLushort *values); +typedef void (APIENTRYP PFNGLGETNPOLYGONSTIPPLEPROC) (GLsizei bufSize, GLubyte *pattern); +typedef void (APIENTRYP PFNGLGETNCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table); +typedef void (APIENTRYP PFNGLGETNCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image); +typedef void (APIENTRYP PFNGLGETNSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span); +typedef void (APIENTRYP PFNGLGETNHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +typedef void (APIENTRYP PFNGLGETNMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +typedef void (APIENTRYP PFNGLTEXTUREBARRIERPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClipControl (GLenum origin, GLenum depth); +GLAPI void APIENTRY glCreateTransformFeedbacks (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glTransformFeedbackBufferBase (GLuint xfb, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackBufferRange (GLuint xfb, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glGetTransformFeedbackiv (GLuint xfb, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetTransformFeedbacki_v (GLuint xfb, GLenum pname, GLuint index, GLint *param); +GLAPI void APIENTRY glGetTransformFeedbacki64_v (GLuint xfb, GLenum pname, GLuint index, GLint64 *param); +GLAPI void APIENTRY glCreateBuffers (GLsizei n, GLuint *buffers); +GLAPI void APIENTRY glNamedBufferStorage (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); +GLAPI void APIENTRY glNamedBufferData (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); +GLAPI void APIENTRY glNamedBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +GLAPI void APIENTRY glCopyNamedBufferSubData (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GLAPI void APIENTRY glClearNamedBufferData (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearNamedBufferSubData (GLuint buffer, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +GLAPI void *APIENTRY glMapNamedBuffer (GLuint buffer, GLenum access); +GLAPI void *APIENTRY glMapNamedBufferRange (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); +GLAPI GLboolean APIENTRY glUnmapNamedBuffer (GLuint buffer); +GLAPI void APIENTRY glFlushMappedNamedBufferRange (GLuint buffer, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glGetNamedBufferParameteriv (GLuint buffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetNamedBufferParameteri64v (GLuint buffer, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glGetNamedBufferPointerv (GLuint buffer, GLenum pname, void **params); +GLAPI void APIENTRY glGetNamedBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); +GLAPI void APIENTRY glCreateFramebuffers (GLsizei n, GLuint *framebuffers); +GLAPI void APIENTRY glNamedFramebufferRenderbuffer (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glNamedFramebufferParameteri (GLuint framebuffer, GLenum pname, GLint param); +GLAPI void APIENTRY glNamedFramebufferTexture (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTextureLayer (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glNamedFramebufferDrawBuffer (GLuint framebuffer, GLenum buf); +GLAPI void APIENTRY glNamedFramebufferDrawBuffers (GLuint framebuffer, GLsizei n, const GLenum *bufs); +GLAPI void APIENTRY glNamedFramebufferReadBuffer (GLuint framebuffer, GLenum src); +GLAPI void APIENTRY glInvalidateNamedFramebufferData (GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments); +GLAPI void APIENTRY glInvalidateNamedFramebufferSubData (GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glClearNamedFramebufferiv (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLint *value); +GLAPI void APIENTRY glClearNamedFramebufferuiv (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLuint *value); +GLAPI void APIENTRY glClearNamedFramebufferfv (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLfloat *value); +GLAPI void APIENTRY glClearNamedFramebufferfi (GLuint framebuffer, GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +GLAPI void APIENTRY glBlitNamedFramebuffer (GLuint readFramebuffer, GLuint drawFramebuffer, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +GLAPI GLenum APIENTRY glCheckNamedFramebufferStatus (GLuint framebuffer, GLenum target); +GLAPI void APIENTRY glGetNamedFramebufferParameteriv (GLuint framebuffer, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetNamedFramebufferAttachmentParameteriv (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glCreateRenderbuffers (GLsizei n, GLuint *renderbuffers); +GLAPI void APIENTRY glNamedRenderbufferStorage (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glNamedRenderbufferStorageMultisample (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetNamedRenderbufferParameteriv (GLuint renderbuffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glCreateTextures (GLenum target, GLsizei n, GLuint *textures); +GLAPI void APIENTRY glTextureBuffer (GLuint texture, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glTextureBufferRange (GLuint texture, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glTextureStorage1D (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width); +GLAPI void APIENTRY glTextureStorage2D (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTextureStorage3D (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glTextureStorage2DMultisample (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureStorage3DMultisample (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureSubImage1D (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureSubImage2D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureSubImage3D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCompressedTextureSubImage1D (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTextureSubImage2D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTextureSubImage3D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCopyTextureSubImage1D (GLuint texture, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyTextureSubImage2D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glCopyTextureSubImage3D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTextureParameterf (GLuint texture, GLenum pname, GLfloat param); +GLAPI void APIENTRY glTextureParameterfv (GLuint texture, GLenum pname, const GLfloat *param); +GLAPI void APIENTRY glTextureParameteri (GLuint texture, GLenum pname, GLint param); +GLAPI void APIENTRY glTextureParameterIiv (GLuint texture, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTextureParameterIuiv (GLuint texture, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glTextureParameteriv (GLuint texture, GLenum pname, const GLint *param); +GLAPI void APIENTRY glGenerateTextureMipmap (GLuint texture); +GLAPI void APIENTRY glBindTextureUnit (GLuint unit, GLuint texture); +GLAPI void APIENTRY glGetTextureImage (GLuint texture, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); +GLAPI void APIENTRY glGetCompressedTextureImage (GLuint texture, GLint level, GLsizei bufSize, void *pixels); +GLAPI void APIENTRY glGetTextureLevelParameterfv (GLuint texture, GLint level, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTextureLevelParameteriv (GLuint texture, GLint level, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTextureParameterfv (GLuint texture, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTextureParameterIiv (GLuint texture, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTextureParameterIuiv (GLuint texture, GLenum pname, GLuint *params); +GLAPI void APIENTRY glGetTextureParameteriv (GLuint texture, GLenum pname, GLint *params); +GLAPI void APIENTRY glCreateVertexArrays (GLsizei n, GLuint *arrays); +GLAPI void APIENTRY glDisableVertexArrayAttrib (GLuint vaobj, GLuint index); +GLAPI void APIENTRY glEnableVertexArrayAttrib (GLuint vaobj, GLuint index); +GLAPI void APIENTRY glVertexArrayElementBuffer (GLuint vaobj, GLuint buffer); +GLAPI void APIENTRY glVertexArrayVertexBuffer (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +GLAPI void APIENTRY glVertexArrayVertexBuffers (GLuint vaobj, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); +GLAPI void APIENTRY glVertexArrayAttribBinding (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +GLAPI void APIENTRY glVertexArrayAttribFormat (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayAttribIFormat (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayAttribLFormat (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayBindingDivisor (GLuint vaobj, GLuint bindingindex, GLuint divisor); +GLAPI void APIENTRY glGetVertexArrayiv (GLuint vaobj, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetVertexArrayIndexediv (GLuint vaobj, GLuint index, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetVertexArrayIndexed64iv (GLuint vaobj, GLuint index, GLenum pname, GLint64 *param); +GLAPI void APIENTRY glCreateSamplers (GLsizei n, GLuint *samplers); +GLAPI void APIENTRY glCreateProgramPipelines (GLsizei n, GLuint *pipelines); +GLAPI void APIENTRY glCreateQueries (GLenum target, GLsizei n, GLuint *ids); +GLAPI void APIENTRY glGetQueryBufferObjecti64v (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +GLAPI void APIENTRY glGetQueryBufferObjectiv (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +GLAPI void APIENTRY glGetQueryBufferObjectui64v (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +GLAPI void APIENTRY glGetQueryBufferObjectuiv (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +GLAPI void APIENTRY glMemoryBarrierByRegion (GLbitfield barriers); +GLAPI void APIENTRY glGetTextureSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLsizei bufSize, void *pixels); +GLAPI void APIENTRY glGetCompressedTextureSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei bufSize, void *pixels); +GLAPI GLenum APIENTRY glGetGraphicsResetStatus (void); +GLAPI void APIENTRY glGetnCompressedTexImage (GLenum target, GLint lod, GLsizei bufSize, void *pixels); +GLAPI void APIENTRY glGetnTexImage (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); +GLAPI void APIENTRY glGetnUniformdv (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +GLAPI void APIENTRY glGetnUniformfv (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +GLAPI void APIENTRY glGetnUniformiv (GLuint program, GLint location, GLsizei bufSize, GLint *params); +GLAPI void APIENTRY glGetnUniformuiv (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +GLAPI void APIENTRY glReadnPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); +GLAPI void APIENTRY glGetnMapdv (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); +GLAPI void APIENTRY glGetnMapfv (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); +GLAPI void APIENTRY glGetnMapiv (GLenum target, GLenum query, GLsizei bufSize, GLint *v); +GLAPI void APIENTRY glGetnPixelMapfv (GLenum map, GLsizei bufSize, GLfloat *values); +GLAPI void APIENTRY glGetnPixelMapuiv (GLenum map, GLsizei bufSize, GLuint *values); +GLAPI void APIENTRY glGetnPixelMapusv (GLenum map, GLsizei bufSize, GLushort *values); +GLAPI void APIENTRY glGetnPolygonStipple (GLsizei bufSize, GLubyte *pattern); +GLAPI void APIENTRY glGetnColorTable (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table); +GLAPI void APIENTRY glGetnConvolutionFilter (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image); +GLAPI void APIENTRY glGetnSeparableFilter (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span); +GLAPI void APIENTRY glGetnHistogram (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +GLAPI void APIENTRY glGetnMinmax (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +GLAPI void APIENTRY glTextureBarrier (void); +#endif +#endif /* GL_VERSION_4_5 */ + +#ifndef GL_VERSION_4_6 +#define GL_VERSION_4_6 1 +#define GL_SHADER_BINARY_FORMAT_SPIR_V 0x9551 +#define GL_SPIR_V_BINARY 0x9552 +#define GL_PARAMETER_BUFFER 0x80EE +#define GL_PARAMETER_BUFFER_BINDING 0x80EF +#define GL_CONTEXT_FLAG_NO_ERROR_BIT 0x00000008 +#define GL_VERTICES_SUBMITTED 0x82EE +#define GL_PRIMITIVES_SUBMITTED 0x82EF +#define GL_VERTEX_SHADER_INVOCATIONS 0x82F0 +#define GL_TESS_CONTROL_SHADER_PATCHES 0x82F1 +#define GL_TESS_EVALUATION_SHADER_INVOCATIONS 0x82F2 +#define GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED 0x82F3 +#define GL_FRAGMENT_SHADER_INVOCATIONS 0x82F4 +#define GL_COMPUTE_SHADER_INVOCATIONS 0x82F5 +#define GL_CLIPPING_INPUT_PRIMITIVES 0x82F6 +#define GL_CLIPPING_OUTPUT_PRIMITIVES 0x82F7 +#define GL_POLYGON_OFFSET_CLAMP 0x8E1B +#define GL_SPIR_V_EXTENSIONS 0x9553 +#define GL_NUM_SPIR_V_EXTENSIONS 0x9554 +#define GL_TEXTURE_MAX_ANISOTROPY 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY 0x84FF +#define GL_TRANSFORM_FEEDBACK_OVERFLOW 0x82EC +#define GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW 0x82ED +typedef void (APIENTRYP PFNGLSPECIALIZESHADERPROC) (GLuint shader, const GLchar *pEntryPoint, GLuint numSpecializationConstants, const GLuint *pConstantIndex, const GLuint *pConstantValue); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTCOUNTPROC) (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTPROC) (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLPOLYGONOFFSETCLAMPPROC) (GLfloat factor, GLfloat units, GLfloat clamp); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSpecializeShader (GLuint shader, const GLchar *pEntryPoint, GLuint numSpecializationConstants, const GLuint *pConstantIndex, const GLuint *pConstantValue); +GLAPI void APIENTRY glMultiDrawArraysIndirectCount (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirectCount (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +GLAPI void APIENTRY glPolygonOffsetClamp (GLfloat factor, GLfloat units, GLfloat clamp); +#endif +#endif /* GL_VERSION_4_6 */ + +#ifndef GL_ARB_ES2_compatibility +#define GL_ARB_ES2_compatibility 1 +#endif /* GL_ARB_ES2_compatibility */ + +#ifndef GL_ARB_ES3_1_compatibility +#define GL_ARB_ES3_1_compatibility 1 +#endif /* GL_ARB_ES3_1_compatibility */ + +#ifndef GL_ARB_ES3_2_compatibility +#define GL_ARB_ES3_2_compatibility 1 +#define GL_PRIMITIVE_BOUNDING_BOX_ARB 0x92BE +#define GL_MULTISAMPLE_LINE_WIDTH_RANGE_ARB 0x9381 +#define GL_MULTISAMPLE_LINE_WIDTH_GRANULARITY_ARB 0x9382 +typedef void (APIENTRYP PFNGLPRIMITIVEBOUNDINGBOXARBPROC) (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPrimitiveBoundingBoxARB (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW); +#endif +#endif /* GL_ARB_ES3_2_compatibility */ + +#ifndef GL_ARB_ES3_compatibility +#define GL_ARB_ES3_compatibility 1 +#endif /* GL_ARB_ES3_compatibility */ + +#ifndef GL_ARB_arrays_of_arrays +#define GL_ARB_arrays_of_arrays 1 +#endif /* GL_ARB_arrays_of_arrays */ + +#ifndef GL_ARB_base_instance +#define GL_ARB_base_instance 1 +#endif /* GL_ARB_base_instance */ + +#ifndef GL_ARB_bindless_texture +#define GL_ARB_bindless_texture 1 +typedef khronos_uint64_t GLuint64EXT; +#define GL_UNSIGNED_INT64_ARB 0x140F +typedef GLuint64 (APIENTRYP PFNGLGETTEXTUREHANDLEARBPROC) (GLuint texture); +typedef GLuint64 (APIENTRYP PFNGLGETTEXTURESAMPLERHANDLEARBPROC) (GLuint texture, GLuint sampler); +typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTARBPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTARBPROC) (GLuint64 handle); +typedef GLuint64 (APIENTRYP PFNGLGETIMAGEHANDLEARBPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTARBPROC) (GLuint64 handle, GLenum access); +typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTARBPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64ARBPROC) (GLint location, GLuint64 value); +typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64ARBPROC) (GLuint program, GLint location, GLuint64 value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREHANDLERESIDENTARBPROC) (GLuint64 handle); +typedef GLboolean (APIENTRYP PFNGLISIMAGEHANDLERESIDENTARBPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64ARBPROC) (GLuint index, GLuint64EXT x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64VARBPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLUI64VARBPROC) (GLuint index, GLenum pname, GLuint64EXT *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint64 APIENTRY glGetTextureHandleARB (GLuint texture); +GLAPI GLuint64 APIENTRY glGetTextureSamplerHandleARB (GLuint texture, GLuint sampler); +GLAPI void APIENTRY glMakeTextureHandleResidentARB (GLuint64 handle); +GLAPI void APIENTRY glMakeTextureHandleNonResidentARB (GLuint64 handle); +GLAPI GLuint64 APIENTRY glGetImageHandleARB (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +GLAPI void APIENTRY glMakeImageHandleResidentARB (GLuint64 handle, GLenum access); +GLAPI void APIENTRY glMakeImageHandleNonResidentARB (GLuint64 handle); +GLAPI void APIENTRY glUniformHandleui64ARB (GLint location, GLuint64 value); +GLAPI void APIENTRY glUniformHandleui64vARB (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glProgramUniformHandleui64ARB (GLuint program, GLint location, GLuint64 value); +GLAPI void APIENTRY glProgramUniformHandleui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +GLAPI GLboolean APIENTRY glIsTextureHandleResidentARB (GLuint64 handle); +GLAPI GLboolean APIENTRY glIsImageHandleResidentARB (GLuint64 handle); +GLAPI void APIENTRY glVertexAttribL1ui64ARB (GLuint index, GLuint64EXT x); +GLAPI void APIENTRY glVertexAttribL1ui64vARB (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glGetVertexAttribLui64vARB (GLuint index, GLenum pname, GLuint64EXT *params); +#endif +#endif /* GL_ARB_bindless_texture */ + +#ifndef GL_ARB_blend_func_extended +#define GL_ARB_blend_func_extended 1 +#endif /* GL_ARB_blend_func_extended */ + +#ifndef GL_ARB_buffer_storage +#define GL_ARB_buffer_storage 1 +#endif /* GL_ARB_buffer_storage */ + +#ifndef GL_ARB_cl_event +#define GL_ARB_cl_event 1 +struct _cl_context; +struct _cl_event; +#define GL_SYNC_CL_EVENT_ARB 0x8240 +#define GL_SYNC_CL_EVENT_COMPLETE_ARB 0x8241 +typedef GLsync (APIENTRYP PFNGLCREATESYNCFROMCLEVENTARBPROC) (struct _cl_context *context, struct _cl_event *event, GLbitfield flags); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLsync APIENTRY glCreateSyncFromCLeventARB (struct _cl_context *context, struct _cl_event *event, GLbitfield flags); +#endif +#endif /* GL_ARB_cl_event */ + +#ifndef GL_ARB_clear_buffer_object +#define GL_ARB_clear_buffer_object 1 +#endif /* GL_ARB_clear_buffer_object */ + +#ifndef GL_ARB_clear_texture +#define GL_ARB_clear_texture 1 +#endif /* GL_ARB_clear_texture */ + +#ifndef GL_ARB_clip_control +#define GL_ARB_clip_control 1 +#endif /* GL_ARB_clip_control */ + +#ifndef GL_ARB_color_buffer_float +#define GL_ARB_color_buffer_float 1 +#define GL_RGBA_FLOAT_MODE_ARB 0x8820 +#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A +#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B +#define GL_CLAMP_READ_COLOR_ARB 0x891C +#define GL_FIXED_ONLY_ARB 0x891D +typedef void (APIENTRYP PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClampColorARB (GLenum target, GLenum clamp); +#endif +#endif /* GL_ARB_color_buffer_float */ + +#ifndef GL_ARB_compatibility +#define GL_ARB_compatibility 1 +#endif /* GL_ARB_compatibility */ + +#ifndef GL_ARB_compressed_texture_pixel_storage +#define GL_ARB_compressed_texture_pixel_storage 1 +#endif /* GL_ARB_compressed_texture_pixel_storage */ + +#ifndef GL_ARB_compute_shader +#define GL_ARB_compute_shader 1 +#endif /* GL_ARB_compute_shader */ + +#ifndef GL_ARB_compute_variable_group_size +#define GL_ARB_compute_variable_group_size 1 +#define GL_MAX_COMPUTE_VARIABLE_GROUP_INVOCATIONS_ARB 0x9344 +#define GL_MAX_COMPUTE_FIXED_GROUP_INVOCATIONS_ARB 0x90EB +#define GL_MAX_COMPUTE_VARIABLE_GROUP_SIZE_ARB 0x9345 +#define GL_MAX_COMPUTE_FIXED_GROUP_SIZE_ARB 0x91BF +typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEGROUPSIZEARBPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z, GLuint group_size_x, GLuint group_size_y, GLuint group_size_z); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDispatchComputeGroupSizeARB (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z, GLuint group_size_x, GLuint group_size_y, GLuint group_size_z); +#endif +#endif /* GL_ARB_compute_variable_group_size */ + +#ifndef GL_ARB_conditional_render_inverted +#define GL_ARB_conditional_render_inverted 1 +#endif /* GL_ARB_conditional_render_inverted */ + +#ifndef GL_ARB_conservative_depth +#define GL_ARB_conservative_depth 1 +#endif /* GL_ARB_conservative_depth */ + +#ifndef GL_ARB_copy_buffer +#define GL_ARB_copy_buffer 1 +#endif /* GL_ARB_copy_buffer */ + +#ifndef GL_ARB_copy_image +#define GL_ARB_copy_image 1 +#endif /* GL_ARB_copy_image */ + +#ifndef GL_ARB_cull_distance +#define GL_ARB_cull_distance 1 +#endif /* GL_ARB_cull_distance */ + +#ifndef GL_ARB_debug_output +#define GL_ARB_debug_output 1 +typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); +#define GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB 0x8242 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243 +#define GL_DEBUG_CALLBACK_FUNCTION_ARB 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM_ARB 0x8245 +#define GL_DEBUG_SOURCE_API_ARB 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER_ARB 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY_ARB 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION_ARB 0x824A +#define GL_DEBUG_SOURCE_OTHER_ARB 0x824B +#define GL_DEBUG_TYPE_ERROR_ARB 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB 0x824E +#define GL_DEBUG_TYPE_PORTABILITY_ARB 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE_ARB 0x8250 +#define GL_DEBUG_TYPE_OTHER_ARB 0x8251 +#define GL_MAX_DEBUG_MESSAGE_LENGTH_ARB 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES_ARB 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES_ARB 0x9145 +#define GL_DEBUG_SEVERITY_HIGH_ARB 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM_ARB 0x9147 +#define GL_DEBUG_SEVERITY_LOW_ARB 0x9148 +typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLARBPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTARBPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, const void *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGARBPROC) (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDebugMessageControlARB (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsertARB (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallbackARB (GLDEBUGPROCARB callback, const void *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLogARB (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +#endif +#endif /* GL_ARB_debug_output */ + +#ifndef GL_ARB_depth_buffer_float +#define GL_ARB_depth_buffer_float 1 +#endif /* GL_ARB_depth_buffer_float */ + +#ifndef GL_ARB_depth_clamp +#define GL_ARB_depth_clamp 1 +#endif /* GL_ARB_depth_clamp */ + +#ifndef GL_ARB_depth_texture +#define GL_ARB_depth_texture 1 +#define GL_DEPTH_COMPONENT16_ARB 0x81A5 +#define GL_DEPTH_COMPONENT24_ARB 0x81A6 +#define GL_DEPTH_COMPONENT32_ARB 0x81A7 +#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A +#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B +#endif /* GL_ARB_depth_texture */ + +#ifndef GL_ARB_derivative_control +#define GL_ARB_derivative_control 1 +#endif /* GL_ARB_derivative_control */ + +#ifndef GL_ARB_direct_state_access +#define GL_ARB_direct_state_access 1 +#endif /* GL_ARB_direct_state_access */ + +#ifndef GL_ARB_draw_buffers +#define GL_ARB_draw_buffers 1 +#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 +#define GL_DRAW_BUFFER0_ARB 0x8825 +#define GL_DRAW_BUFFER1_ARB 0x8826 +#define GL_DRAW_BUFFER2_ARB 0x8827 +#define GL_DRAW_BUFFER3_ARB 0x8828 +#define GL_DRAW_BUFFER4_ARB 0x8829 +#define GL_DRAW_BUFFER5_ARB 0x882A +#define GL_DRAW_BUFFER6_ARB 0x882B +#define GL_DRAW_BUFFER7_ARB 0x882C +#define GL_DRAW_BUFFER8_ARB 0x882D +#define GL_DRAW_BUFFER9_ARB 0x882E +#define GL_DRAW_BUFFER10_ARB 0x882F +#define GL_DRAW_BUFFER11_ARB 0x8830 +#define GL_DRAW_BUFFER12_ARB 0x8831 +#define GL_DRAW_BUFFER13_ARB 0x8832 +#define GL_DRAW_BUFFER14_ARB 0x8833 +#define GL_DRAW_BUFFER15_ARB 0x8834 +typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawBuffersARB (GLsizei n, const GLenum *bufs); +#endif +#endif /* GL_ARB_draw_buffers */ + +#ifndef GL_ARB_draw_buffers_blend +#define GL_ARB_draw_buffers_blend 1 +typedef void (APIENTRYP PFNGLBLENDEQUATIONIARBPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIARBPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLBLENDFUNCIARBPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIARBPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationiARB (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparateiARB (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glBlendFunciARB (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparateiARB (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#endif +#endif /* GL_ARB_draw_buffers_blend */ + +#ifndef GL_ARB_draw_elements_base_vertex +#define GL_ARB_draw_elements_base_vertex 1 +#endif /* GL_ARB_draw_elements_base_vertex */ + +#ifndef GL_ARB_draw_indirect +#define GL_ARB_draw_indirect 1 +#endif /* GL_ARB_draw_indirect */ + +#ifndef GL_ARB_draw_instanced +#define GL_ARB_draw_instanced 1 +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDARBPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedARB (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +GLAPI void APIENTRY glDrawElementsInstancedARB (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#endif +#endif /* GL_ARB_draw_instanced */ + +#ifndef GL_ARB_enhanced_layouts +#define GL_ARB_enhanced_layouts 1 +#endif /* GL_ARB_enhanced_layouts */ + +#ifndef GL_ARB_explicit_attrib_location +#define GL_ARB_explicit_attrib_location 1 +#endif /* GL_ARB_explicit_attrib_location */ + +#ifndef GL_ARB_explicit_uniform_location +#define GL_ARB_explicit_uniform_location 1 +#endif /* GL_ARB_explicit_uniform_location */ + +#ifndef GL_ARB_fragment_coord_conventions +#define GL_ARB_fragment_coord_conventions 1 +#endif /* GL_ARB_fragment_coord_conventions */ + +#ifndef GL_ARB_fragment_layer_viewport +#define GL_ARB_fragment_layer_viewport 1 +#endif /* GL_ARB_fragment_layer_viewport */ + +#ifndef GL_ARB_fragment_program +#define GL_ARB_fragment_program 1 +#define GL_FRAGMENT_PROGRAM_ARB 0x8804 +#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 +#define GL_PROGRAM_LENGTH_ARB 0x8627 +#define GL_PROGRAM_FORMAT_ARB 0x8876 +#define GL_PROGRAM_BINDING_ARB 0x8677 +#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 +#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 +#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 +#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 +#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 +#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 +#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 +#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 +#define GL_PROGRAM_PARAMETERS_ARB 0x88A8 +#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 +#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA +#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB +#define GL_PROGRAM_ATTRIBS_ARB 0x88AC +#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD +#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE +#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF +#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 +#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 +#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 +#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 +#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 +#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 +#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 +#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 +#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A +#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B +#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C +#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D +#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E +#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F +#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 +#define GL_PROGRAM_STRING_ARB 0x8628 +#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B +#define GL_CURRENT_MATRIX_ARB 0x8641 +#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 +#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 +#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F +#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E +#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 +#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 +#define GL_MATRIX0_ARB 0x88C0 +#define GL_MATRIX1_ARB 0x88C1 +#define GL_MATRIX2_ARB 0x88C2 +#define GL_MATRIX3_ARB 0x88C3 +#define GL_MATRIX4_ARB 0x88C4 +#define GL_MATRIX5_ARB 0x88C5 +#define GL_MATRIX6_ARB 0x88C6 +#define GL_MATRIX7_ARB 0x88C7 +#define GL_MATRIX8_ARB 0x88C8 +#define GL_MATRIX9_ARB 0x88C9 +#define GL_MATRIX10_ARB 0x88CA +#define GL_MATRIX11_ARB 0x88CB +#define GL_MATRIX12_ARB 0x88CC +#define GL_MATRIX13_ARB 0x88CD +#define GL_MATRIX14_ARB 0x88CE +#define GL_MATRIX15_ARB 0x88CF +#define GL_MATRIX16_ARB 0x88D0 +#define GL_MATRIX17_ARB 0x88D1 +#define GL_MATRIX18_ARB 0x88D2 +#define GL_MATRIX19_ARB 0x88D3 +#define GL_MATRIX20_ARB 0x88D4 +#define GL_MATRIX21_ARB 0x88D5 +#define GL_MATRIX22_ARB 0x88D6 +#define GL_MATRIX23_ARB 0x88D7 +#define GL_MATRIX24_ARB 0x88D8 +#define GL_MATRIX25_ARB 0x88D9 +#define GL_MATRIX26_ARB 0x88DA +#define GL_MATRIX27_ARB 0x88DB +#define GL_MATRIX28_ARB 0x88DC +#define GL_MATRIX29_ARB 0x88DD +#define GL_MATRIX30_ARB 0x88DE +#define GL_MATRIX31_ARB 0x88DF +typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const void *string); +typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); +typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, void *string); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC) (GLuint program); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramStringARB (GLenum target, GLenum format, GLsizei len, const void *string); +GLAPI void APIENTRY glBindProgramARB (GLenum target, GLuint program); +GLAPI void APIENTRY glDeleteProgramsARB (GLsizei n, const GLuint *programs); +GLAPI void APIENTRY glGenProgramsARB (GLsizei n, GLuint *programs); +GLAPI void APIENTRY glProgramEnvParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramEnvParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); +GLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramEnvParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); +GLAPI void APIENTRY glProgramLocalParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramLocalParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); +GLAPI void APIENTRY glProgramLocalParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramLocalParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); +GLAPI void APIENTRY glGetProgramEnvParameterdvARB (GLenum target, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetProgramEnvParameterfvARB (GLenum target, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetProgramLocalParameterdvARB (GLenum target, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetProgramLocalParameterfvARB (GLenum target, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetProgramivARB (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramStringARB (GLenum target, GLenum pname, void *string); +GLAPI GLboolean APIENTRY glIsProgramARB (GLuint program); +#endif +#endif /* GL_ARB_fragment_program */ + +#ifndef GL_ARB_fragment_program_shadow +#define GL_ARB_fragment_program_shadow 1 +#endif /* GL_ARB_fragment_program_shadow */ + +#ifndef GL_ARB_fragment_shader +#define GL_ARB_fragment_shader 1 +#define GL_FRAGMENT_SHADER_ARB 0x8B30 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B +#endif /* GL_ARB_fragment_shader */ + +#ifndef GL_ARB_fragment_shader_interlock +#define GL_ARB_fragment_shader_interlock 1 +#endif /* GL_ARB_fragment_shader_interlock */ + +#ifndef GL_ARB_framebuffer_no_attachments +#define GL_ARB_framebuffer_no_attachments 1 +#endif /* GL_ARB_framebuffer_no_attachments */ + +#ifndef GL_ARB_framebuffer_object +#define GL_ARB_framebuffer_object 1 +#endif /* GL_ARB_framebuffer_object */ + +#ifndef GL_ARB_framebuffer_sRGB +#define GL_ARB_framebuffer_sRGB 1 +#endif /* GL_ARB_framebuffer_sRGB */ + +#ifndef GL_ARB_geometry_shader4 +#define GL_ARB_geometry_shader4 1 +#define GL_LINES_ADJACENCY_ARB 0x000A +#define GL_LINE_STRIP_ADJACENCY_ARB 0x000B +#define GL_TRIANGLES_ADJACENCY_ARB 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0x000D +#define GL_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9 +#define GL_GEOMETRY_SHADER_ARB 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT_ARB 0x8DDA +#define GL_GEOMETRY_INPUT_TYPE_ARB 0x8DDB +#define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8DDC +#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD +#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1 +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIARBPROC) (GLuint program, GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramParameteriARB (GLuint program, GLenum pname, GLint value); +GLAPI void APIENTRY glFramebufferTextureARB (GLenum target, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTextureLayerARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glFramebufferTextureFaceARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif +#endif /* GL_ARB_geometry_shader4 */ + +#ifndef GL_ARB_get_program_binary +#define GL_ARB_get_program_binary 1 +#endif /* GL_ARB_get_program_binary */ + +#ifndef GL_ARB_get_texture_sub_image +#define GL_ARB_get_texture_sub_image 1 +#endif /* GL_ARB_get_texture_sub_image */ + +#ifndef GL_ARB_gl_spirv +#define GL_ARB_gl_spirv 1 +#define GL_SHADER_BINARY_FORMAT_SPIR_V_ARB 0x9551 +#define GL_SPIR_V_BINARY_ARB 0x9552 +typedef void (APIENTRYP PFNGLSPECIALIZESHADERARBPROC) (GLuint shader, const GLchar *pEntryPoint, GLuint numSpecializationConstants, const GLuint *pConstantIndex, const GLuint *pConstantValue); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSpecializeShaderARB (GLuint shader, const GLchar *pEntryPoint, GLuint numSpecializationConstants, const GLuint *pConstantIndex, const GLuint *pConstantValue); +#endif +#endif /* GL_ARB_gl_spirv */ + +#ifndef GL_ARB_gpu_shader5 +#define GL_ARB_gpu_shader5 1 +#endif /* GL_ARB_gpu_shader5 */ + +#ifndef GL_ARB_gpu_shader_fp64 +#define GL_ARB_gpu_shader_fp64 1 +#endif /* GL_ARB_gpu_shader_fp64 */ + +#ifndef GL_ARB_gpu_shader_int64 +#define GL_ARB_gpu_shader_int64 1 +#define GL_INT64_ARB 0x140E +#define GL_INT64_VEC2_ARB 0x8FE9 +#define GL_INT64_VEC3_ARB 0x8FEA +#define GL_INT64_VEC4_ARB 0x8FEB +#define GL_UNSIGNED_INT64_VEC2_ARB 0x8FF5 +#define GL_UNSIGNED_INT64_VEC3_ARB 0x8FF6 +#define GL_UNSIGNED_INT64_VEC4_ARB 0x8FF7 +typedef void (APIENTRYP PFNGLUNIFORM1I64ARBPROC) (GLint location, GLint64 x); +typedef void (APIENTRYP PFNGLUNIFORM2I64ARBPROC) (GLint location, GLint64 x, GLint64 y); +typedef void (APIENTRYP PFNGLUNIFORM3I64ARBPROC) (GLint location, GLint64 x, GLint64 y, GLint64 z); +typedef void (APIENTRYP PFNGLUNIFORM4I64ARBPROC) (GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); +typedef void (APIENTRYP PFNGLUNIFORM1I64VARBPROC) (GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM2I64VARBPROC) (GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM3I64VARBPROC) (GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM4I64VARBPROC) (GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM1UI64ARBPROC) (GLint location, GLuint64 x); +typedef void (APIENTRYP PFNGLUNIFORM2UI64ARBPROC) (GLint location, GLuint64 x, GLuint64 y); +typedef void (APIENTRYP PFNGLUNIFORM3UI64ARBPROC) (GLint location, GLuint64 x, GLuint64 y, GLuint64 z); +typedef void (APIENTRYP PFNGLUNIFORM4UI64ARBPROC) (GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); +typedef void (APIENTRYP PFNGLUNIFORM1UI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM2UI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM3UI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM4UI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLGETUNIFORMI64VARBPROC) (GLuint program, GLint location, GLint64 *params); +typedef void (APIENTRYP PFNGLGETUNIFORMUI64VARBPROC) (GLuint program, GLint location, GLuint64 *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMI64VARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint64 *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMUI64VARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint64 *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64ARBPROC) (GLuint program, GLint location, GLint64 x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64ARBPROC) (GLuint program, GLint location, GLint64 x, GLint64 y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64ARBPROC) (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64ARBPROC) (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64ARBPROC) (GLuint program, GLint location, GLuint64 x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64ARBPROC) (GLuint program, GLint location, GLuint64 x, GLuint64 y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64ARBPROC) (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64ARBPROC) (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniform1i64ARB (GLint location, GLint64 x); +GLAPI void APIENTRY glUniform2i64ARB (GLint location, GLint64 x, GLint64 y); +GLAPI void APIENTRY glUniform3i64ARB (GLint location, GLint64 x, GLint64 y, GLint64 z); +GLAPI void APIENTRY glUniform4i64ARB (GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); +GLAPI void APIENTRY glUniform1i64vARB (GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glUniform2i64vARB (GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glUniform3i64vARB (GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glUniform4i64vARB (GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glUniform1ui64ARB (GLint location, GLuint64 x); +GLAPI void APIENTRY glUniform2ui64ARB (GLint location, GLuint64 x, GLuint64 y); +GLAPI void APIENTRY glUniform3ui64ARB (GLint location, GLuint64 x, GLuint64 y, GLuint64 z); +GLAPI void APIENTRY glUniform4ui64ARB (GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); +GLAPI void APIENTRY glUniform1ui64vARB (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glUniform2ui64vARB (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glUniform3ui64vARB (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glUniform4ui64vARB (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glGetUniformi64vARB (GLuint program, GLint location, GLint64 *params); +GLAPI void APIENTRY glGetUniformui64vARB (GLuint program, GLint location, GLuint64 *params); +GLAPI void APIENTRY glGetnUniformi64vARB (GLuint program, GLint location, GLsizei bufSize, GLint64 *params); +GLAPI void APIENTRY glGetnUniformui64vARB (GLuint program, GLint location, GLsizei bufSize, GLuint64 *params); +GLAPI void APIENTRY glProgramUniform1i64ARB (GLuint program, GLint location, GLint64 x); +GLAPI void APIENTRY glProgramUniform2i64ARB (GLuint program, GLint location, GLint64 x, GLint64 y); +GLAPI void APIENTRY glProgramUniform3i64ARB (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z); +GLAPI void APIENTRY glProgramUniform4i64ARB (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); +GLAPI void APIENTRY glProgramUniform1i64vARB (GLuint program, GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glProgramUniform2i64vARB (GLuint program, GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glProgramUniform3i64vARB (GLuint program, GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glProgramUniform4i64vARB (GLuint program, GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glProgramUniform1ui64ARB (GLuint program, GLint location, GLuint64 x); +GLAPI void APIENTRY glProgramUniform2ui64ARB (GLuint program, GLint location, GLuint64 x, GLuint64 y); +GLAPI void APIENTRY glProgramUniform3ui64ARB (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z); +GLAPI void APIENTRY glProgramUniform4ui64ARB (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); +GLAPI void APIENTRY glProgramUniform1ui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glProgramUniform2ui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glProgramUniform3ui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glProgramUniform4ui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +#endif +#endif /* GL_ARB_gpu_shader_int64 */ + +#ifndef GL_ARB_half_float_pixel +#define GL_ARB_half_float_pixel 1 +typedef khronos_uint16_t GLhalfARB; +#define GL_HALF_FLOAT_ARB 0x140B +#endif /* GL_ARB_half_float_pixel */ + +#ifndef GL_ARB_half_float_vertex +#define GL_ARB_half_float_vertex 1 +#endif /* GL_ARB_half_float_vertex */ + +#ifndef GL_ARB_imaging +#define GL_ARB_imaging 1 +#define GL_CONVOLUTION_BORDER_MODE 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS 0x8015 +#define GL_REDUCE 0x8016 +#define GL_CONVOLUTION_FORMAT 0x8017 +#define GL_CONVOLUTION_WIDTH 0x8018 +#define GL_CONVOLUTION_HEIGHT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 +#define GL_HISTOGRAM_WIDTH 0x8026 +#define GL_HISTOGRAM_FORMAT 0x8027 +#define GL_HISTOGRAM_RED_SIZE 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C +#define GL_HISTOGRAM_SINK 0x802D +#define GL_MINMAX_FORMAT 0x802F +#define GL_MINMAX_SINK 0x8030 +#define GL_TABLE_TOO_LARGE 0x8031 +#define GL_COLOR_MATRIX 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB +#define GL_COLOR_TABLE_SCALE 0x80D6 +#define GL_COLOR_TABLE_BIAS 0x80D7 +#define GL_COLOR_TABLE_FORMAT 0x80D8 +#define GL_COLOR_TABLE_WIDTH 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF +#define GL_CONSTANT_BORDER 0x8151 +#define GL_REPLICATE_BORDER 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR 0x8154 +typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, void *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, void *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTable (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); +GLAPI void APIENTRY glColorTableParameterfv (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glColorTableParameteriv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyColorTable (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glGetColorTable (GLenum target, GLenum format, GLenum type, void *table); +GLAPI void APIENTRY glGetColorTableParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetColorTableParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glColorSubTable (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glCopyColorSubTable (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glConvolutionFilter1D (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); +GLAPI void APIENTRY glConvolutionFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); +GLAPI void APIENTRY glConvolutionParameterf (GLenum target, GLenum pname, GLfloat params); +GLAPI void APIENTRY glConvolutionParameterfv (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glConvolutionParameteri (GLenum target, GLenum pname, GLint params); +GLAPI void APIENTRY glConvolutionParameteriv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetConvolutionFilter (GLenum target, GLenum format, GLenum type, void *image); +GLAPI void APIENTRY glGetConvolutionParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetConvolutionParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSeparableFilter (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); +GLAPI void APIENTRY glSeparableFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); +GLAPI void APIENTRY glGetHistogram (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +GLAPI void APIENTRY glGetHistogramParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetHistogramParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMinmax (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +GLAPI void APIENTRY glGetMinmaxParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMinmaxParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glHistogram (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glMinmax (GLenum target, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glResetHistogram (GLenum target); +GLAPI void APIENTRY glResetMinmax (GLenum target); +#endif +#endif /* GL_ARB_imaging */ + +#ifndef GL_ARB_indirect_parameters +#define GL_ARB_indirect_parameters 1 +#define GL_PARAMETER_BUFFER_ARB 0x80EE +#define GL_PARAMETER_BUFFER_BINDING_ARB 0x80EF +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTCOUNTARBPROC) (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTARBPROC) (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysIndirectCountARB (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirectCountARB (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +#endif +#endif /* GL_ARB_indirect_parameters */ + +#ifndef GL_ARB_instanced_arrays +#define GL_ARB_instanced_arrays 1 +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0x88FE +typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORARBPROC) (GLuint index, GLuint divisor); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribDivisorARB (GLuint index, GLuint divisor); +#endif +#endif /* GL_ARB_instanced_arrays */ + +#ifndef GL_ARB_internalformat_query +#define GL_ARB_internalformat_query 1 +#endif /* GL_ARB_internalformat_query */ + +#ifndef GL_ARB_internalformat_query2 +#define GL_ARB_internalformat_query2 1 +#define GL_SRGB_DECODE_ARB 0x8299 +#define GL_VIEW_CLASS_EAC_R11 0x9383 +#define GL_VIEW_CLASS_EAC_RG11 0x9384 +#define GL_VIEW_CLASS_ETC2_RGB 0x9385 +#define GL_VIEW_CLASS_ETC2_RGBA 0x9386 +#define GL_VIEW_CLASS_ETC2_EAC_RGBA 0x9387 +#define GL_VIEW_CLASS_ASTC_4x4_RGBA 0x9388 +#define GL_VIEW_CLASS_ASTC_5x4_RGBA 0x9389 +#define GL_VIEW_CLASS_ASTC_5x5_RGBA 0x938A +#define GL_VIEW_CLASS_ASTC_6x5_RGBA 0x938B +#define GL_VIEW_CLASS_ASTC_6x6_RGBA 0x938C +#define GL_VIEW_CLASS_ASTC_8x5_RGBA 0x938D +#define GL_VIEW_CLASS_ASTC_8x6_RGBA 0x938E +#define GL_VIEW_CLASS_ASTC_8x8_RGBA 0x938F +#define GL_VIEW_CLASS_ASTC_10x5_RGBA 0x9390 +#define GL_VIEW_CLASS_ASTC_10x6_RGBA 0x9391 +#define GL_VIEW_CLASS_ASTC_10x8_RGBA 0x9392 +#define GL_VIEW_CLASS_ASTC_10x10_RGBA 0x9393 +#define GL_VIEW_CLASS_ASTC_12x10_RGBA 0x9394 +#define GL_VIEW_CLASS_ASTC_12x12_RGBA 0x9395 +#endif /* GL_ARB_internalformat_query2 */ + +#ifndef GL_ARB_invalidate_subdata +#define GL_ARB_invalidate_subdata 1 +#endif /* GL_ARB_invalidate_subdata */ + +#ifndef GL_ARB_map_buffer_alignment +#define GL_ARB_map_buffer_alignment 1 +#endif /* GL_ARB_map_buffer_alignment */ + +#ifndef GL_ARB_map_buffer_range +#define GL_ARB_map_buffer_range 1 +#endif /* GL_ARB_map_buffer_range */ + +#ifndef GL_ARB_matrix_palette +#define GL_ARB_matrix_palette 1 +#define GL_MATRIX_PALETTE_ARB 0x8840 +#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 +#define GL_MAX_PALETTE_MATRICES_ARB 0x8842 +#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 +#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 +#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 +#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 +#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 +#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 +#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 +typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); +typedef void (APIENTRYP PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCurrentPaletteMatrixARB (GLint index); +GLAPI void APIENTRY glMatrixIndexubvARB (GLint size, const GLubyte *indices); +GLAPI void APIENTRY glMatrixIndexusvARB (GLint size, const GLushort *indices); +GLAPI void APIENTRY glMatrixIndexuivARB (GLint size, const GLuint *indices); +GLAPI void APIENTRY glMatrixIndexPointerARB (GLint size, GLenum type, GLsizei stride, const void *pointer); +#endif +#endif /* GL_ARB_matrix_palette */ + +#ifndef GL_ARB_multi_bind +#define GL_ARB_multi_bind 1 +#endif /* GL_ARB_multi_bind */ + +#ifndef GL_ARB_multi_draw_indirect +#define GL_ARB_multi_draw_indirect 1 +#endif /* GL_ARB_multi_draw_indirect */ + +#ifndef GL_ARB_multisample +#define GL_ARB_multisample 1 +#define GL_MULTISAMPLE_ARB 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F +#define GL_SAMPLE_COVERAGE_ARB 0x80A0 +#define GL_SAMPLE_BUFFERS_ARB 0x80A8 +#define GL_SAMPLES_ARB 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB +#define GL_MULTISAMPLE_BIT_ARB 0x20000000 +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLfloat value, GLboolean invert); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleCoverageARB (GLfloat value, GLboolean invert); +#endif +#endif /* GL_ARB_multisample */ + +#ifndef GL_ARB_multitexture +#define GL_ARB_multitexture 1 +#define GL_TEXTURE0_ARB 0x84C0 +#define GL_TEXTURE1_ARB 0x84C1 +#define GL_TEXTURE2_ARB 0x84C2 +#define GL_TEXTURE3_ARB 0x84C3 +#define GL_TEXTURE4_ARB 0x84C4 +#define GL_TEXTURE5_ARB 0x84C5 +#define GL_TEXTURE6_ARB 0x84C6 +#define GL_TEXTURE7_ARB 0x84C7 +#define GL_TEXTURE8_ARB 0x84C8 +#define GL_TEXTURE9_ARB 0x84C9 +#define GL_TEXTURE10_ARB 0x84CA +#define GL_TEXTURE11_ARB 0x84CB +#define GL_TEXTURE12_ARB 0x84CC +#define GL_TEXTURE13_ARB 0x84CD +#define GL_TEXTURE14_ARB 0x84CE +#define GL_TEXTURE15_ARB 0x84CF +#define GL_TEXTURE16_ARB 0x84D0 +#define GL_TEXTURE17_ARB 0x84D1 +#define GL_TEXTURE18_ARB 0x84D2 +#define GL_TEXTURE19_ARB 0x84D3 +#define GL_TEXTURE20_ARB 0x84D4 +#define GL_TEXTURE21_ARB 0x84D5 +#define GL_TEXTURE22_ARB 0x84D6 +#define GL_TEXTURE23_ARB 0x84D7 +#define GL_TEXTURE24_ARB 0x84D8 +#define GL_TEXTURE25_ARB 0x84D9 +#define GL_TEXTURE26_ARB 0x84DA +#define GL_TEXTURE27_ARB 0x84DB +#define GL_TEXTURE28_ARB 0x84DC +#define GL_TEXTURE29_ARB 0x84DD +#define GL_TEXTURE30_ARB 0x84DE +#define GL_TEXTURE31_ARB 0x84DF +#define GL_ACTIVE_TEXTURE_ARB 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 +#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 +typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTextureARB (GLenum texture); +GLAPI void APIENTRY glClientActiveTextureARB (GLenum texture); +GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum target, GLdouble s); +GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum target, GLfloat s); +GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum target, GLint s); +GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum target, GLshort s); +GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum target, GLdouble s, GLdouble t); +GLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord2fARB (GLenum target, GLfloat s, GLfloat t); +GLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord2iARB (GLenum target, GLint s, GLint t); +GLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord2sARB (GLenum target, GLshort s, GLshort t); +GLAPI void APIENTRY glMultiTexCoord2svARB (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord3dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r); +GLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord3fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r); +GLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord3iARB (GLenum target, GLint s, GLint t, GLint r); +GLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord3sARB (GLenum target, GLshort s, GLshort t, GLshort r); +GLAPI void APIENTRY glMultiTexCoord3svARB (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord4dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +GLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord4fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +GLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord4iARB (GLenum target, GLint s, GLint t, GLint r, GLint q); +GLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord4sARB (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +GLAPI void APIENTRY glMultiTexCoord4svARB (GLenum target, const GLshort *v); +#endif +#endif /* GL_ARB_multitexture */ + +#ifndef GL_ARB_occlusion_query +#define GL_ARB_occlusion_query 1 +#define GL_QUERY_COUNTER_BITS_ARB 0x8864 +#define GL_CURRENT_QUERY_ARB 0x8865 +#define GL_QUERY_RESULT_ARB 0x8866 +#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 +#define GL_SAMPLES_PASSED_ARB 0x8914 +typedef void (APIENTRYP PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYARBPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueriesARB (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteQueriesARB (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsQueryARB (GLuint id); +GLAPI void APIENTRY glBeginQueryARB (GLenum target, GLuint id); +GLAPI void APIENTRY glEndQueryARB (GLenum target); +GLAPI void APIENTRY glGetQueryivARB (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectivARB (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint id, GLenum pname, GLuint *params); +#endif +#endif /* GL_ARB_occlusion_query */ + +#ifndef GL_ARB_occlusion_query2 +#define GL_ARB_occlusion_query2 1 +#endif /* GL_ARB_occlusion_query2 */ + +#ifndef GL_ARB_parallel_shader_compile +#define GL_ARB_parallel_shader_compile 1 +#define GL_MAX_SHADER_COMPILER_THREADS_ARB 0x91B0 +#define GL_COMPLETION_STATUS_ARB 0x91B1 +typedef void (APIENTRYP PFNGLMAXSHADERCOMPILERTHREADSARBPROC) (GLuint count); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMaxShaderCompilerThreadsARB (GLuint count); +#endif +#endif /* GL_ARB_parallel_shader_compile */ + +#ifndef GL_ARB_pipeline_statistics_query +#define GL_ARB_pipeline_statistics_query 1 +#define GL_VERTICES_SUBMITTED_ARB 0x82EE +#define GL_PRIMITIVES_SUBMITTED_ARB 0x82EF +#define GL_VERTEX_SHADER_INVOCATIONS_ARB 0x82F0 +#define GL_TESS_CONTROL_SHADER_PATCHES_ARB 0x82F1 +#define GL_TESS_EVALUATION_SHADER_INVOCATIONS_ARB 0x82F2 +#define GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED_ARB 0x82F3 +#define GL_FRAGMENT_SHADER_INVOCATIONS_ARB 0x82F4 +#define GL_COMPUTE_SHADER_INVOCATIONS_ARB 0x82F5 +#define GL_CLIPPING_INPUT_PRIMITIVES_ARB 0x82F6 +#define GL_CLIPPING_OUTPUT_PRIMITIVES_ARB 0x82F7 +#endif /* GL_ARB_pipeline_statistics_query */ + +#ifndef GL_ARB_pixel_buffer_object +#define GL_ARB_pixel_buffer_object 1 +#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF +#endif /* GL_ARB_pixel_buffer_object */ + +#ifndef GL_ARB_point_parameters +#define GL_ARB_point_parameters 1 +#define GL_POINT_SIZE_MIN_ARB 0x8126 +#define GL_POINT_SIZE_MAX_ARB 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 +#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 +typedef void (APIENTRYP PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfARB (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfvARB (GLenum pname, const GLfloat *params); +#endif +#endif /* GL_ARB_point_parameters */ + +#ifndef GL_ARB_point_sprite +#define GL_ARB_point_sprite 1 +#define GL_POINT_SPRITE_ARB 0x8861 +#define GL_COORD_REPLACE_ARB 0x8862 +#endif /* GL_ARB_point_sprite */ + +#ifndef GL_ARB_polygon_offset_clamp +#define GL_ARB_polygon_offset_clamp 1 +#endif /* GL_ARB_polygon_offset_clamp */ + +#ifndef GL_ARB_post_depth_coverage +#define GL_ARB_post_depth_coverage 1 +#endif /* GL_ARB_post_depth_coverage */ + +#ifndef GL_ARB_program_interface_query +#define GL_ARB_program_interface_query 1 +#endif /* GL_ARB_program_interface_query */ + +#ifndef GL_ARB_provoking_vertex +#define GL_ARB_provoking_vertex 1 +#endif /* GL_ARB_provoking_vertex */ + +#ifndef GL_ARB_query_buffer_object +#define GL_ARB_query_buffer_object 1 +#endif /* GL_ARB_query_buffer_object */ + +#ifndef GL_ARB_robust_buffer_access_behavior +#define GL_ARB_robust_buffer_access_behavior 1 +#endif /* GL_ARB_robust_buffer_access_behavior */ + +#ifndef GL_ARB_robustness +#define GL_ARB_robustness 1 +#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB 0x00000004 +#define GL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 +#define GL_GUILTY_CONTEXT_RESET_ARB 0x8253 +#define GL_INNOCENT_CONTEXT_RESET_ARB 0x8254 +#define GL_UNKNOWN_CONTEXT_RESET_ARB 0x8255 +#define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 +#define GL_NO_RESET_NOTIFICATION_ARB 0x8261 +typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSARBPROC) (void); +typedef void (APIENTRYP PFNGLGETNTEXIMAGEARBPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *img); +typedef void (APIENTRYP PFNGLREADNPIXELSARBPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); +typedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, GLsizei bufSize, void *img); +typedef void (APIENTRYP PFNGLGETNUNIFORMFVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMUIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMDVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +typedef void (APIENTRYP PFNGLGETNMAPDVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); +typedef void (APIENTRYP PFNGLGETNMAPFVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); +typedef void (APIENTRYP PFNGLGETNMAPIVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLint *v); +typedef void (APIENTRYP PFNGLGETNPIXELMAPFVARBPROC) (GLenum map, GLsizei bufSize, GLfloat *values); +typedef void (APIENTRYP PFNGLGETNPIXELMAPUIVARBPROC) (GLenum map, GLsizei bufSize, GLuint *values); +typedef void (APIENTRYP PFNGLGETNPIXELMAPUSVARBPROC) (GLenum map, GLsizei bufSize, GLushort *values); +typedef void (APIENTRYP PFNGLGETNPOLYGONSTIPPLEARBPROC) (GLsizei bufSize, GLubyte *pattern); +typedef void (APIENTRYP PFNGLGETNCOLORTABLEARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table); +typedef void (APIENTRYP PFNGLGETNCONVOLUTIONFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image); +typedef void (APIENTRYP PFNGLGETNSEPARABLEFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span); +typedef void (APIENTRYP PFNGLGETNHISTOGRAMARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +typedef void (APIENTRYP PFNGLGETNMINMAXARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLenum APIENTRY glGetGraphicsResetStatusARB (void); +GLAPI void APIENTRY glGetnTexImageARB (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *img); +GLAPI void APIENTRY glReadnPixelsARB (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); +GLAPI void APIENTRY glGetnCompressedTexImageARB (GLenum target, GLint lod, GLsizei bufSize, void *img); +GLAPI void APIENTRY glGetnUniformfvARB (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +GLAPI void APIENTRY glGetnUniformivARB (GLuint program, GLint location, GLsizei bufSize, GLint *params); +GLAPI void APIENTRY glGetnUniformuivARB (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +GLAPI void APIENTRY glGetnUniformdvARB (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +GLAPI void APIENTRY glGetnMapdvARB (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); +GLAPI void APIENTRY glGetnMapfvARB (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); +GLAPI void APIENTRY glGetnMapivARB (GLenum target, GLenum query, GLsizei bufSize, GLint *v); +GLAPI void APIENTRY glGetnPixelMapfvARB (GLenum map, GLsizei bufSize, GLfloat *values); +GLAPI void APIENTRY glGetnPixelMapuivARB (GLenum map, GLsizei bufSize, GLuint *values); +GLAPI void APIENTRY glGetnPixelMapusvARB (GLenum map, GLsizei bufSize, GLushort *values); +GLAPI void APIENTRY glGetnPolygonStippleARB (GLsizei bufSize, GLubyte *pattern); +GLAPI void APIENTRY glGetnColorTableARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table); +GLAPI void APIENTRY glGetnConvolutionFilterARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image); +GLAPI void APIENTRY glGetnSeparableFilterARB (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span); +GLAPI void APIENTRY glGetnHistogramARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +GLAPI void APIENTRY glGetnMinmaxARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +#endif +#endif /* GL_ARB_robustness */ + +#ifndef GL_ARB_robustness_isolation +#define GL_ARB_robustness_isolation 1 +#endif /* GL_ARB_robustness_isolation */ + +#ifndef GL_ARB_sample_locations +#define GL_ARB_sample_locations 1 +#define GL_SAMPLE_LOCATION_SUBPIXEL_BITS_ARB 0x933D +#define GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_ARB 0x933E +#define GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_ARB 0x933F +#define GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_ARB 0x9340 +#define GL_SAMPLE_LOCATION_ARB 0x8E50 +#define GL_PROGRAMMABLE_SAMPLE_LOCATION_ARB 0x9341 +#define GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOCATIONS_ARB 0x9342 +#define GL_FRAMEBUFFER_SAMPLE_LOCATION_PIXEL_GRID_ARB 0x9343 +typedef void (APIENTRYP PFNGLFRAMEBUFFERSAMPLELOCATIONSFVARBPROC) (GLenum target, GLuint start, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVARBPROC) (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLEVALUATEDEPTHVALUESARBPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferSampleLocationsfvARB (GLenum target, GLuint start, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glNamedFramebufferSampleLocationsfvARB (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glEvaluateDepthValuesARB (void); +#endif +#endif /* GL_ARB_sample_locations */ + +#ifndef GL_ARB_sample_shading +#define GL_ARB_sample_shading 1 +#define GL_SAMPLE_SHADING_ARB 0x8C36 +#define GL_MIN_SAMPLE_SHADING_VALUE_ARB 0x8C37 +typedef void (APIENTRYP PFNGLMINSAMPLESHADINGARBPROC) (GLfloat value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMinSampleShadingARB (GLfloat value); +#endif +#endif /* GL_ARB_sample_shading */ + +#ifndef GL_ARB_sampler_objects +#define GL_ARB_sampler_objects 1 +#endif /* GL_ARB_sampler_objects */ + +#ifndef GL_ARB_seamless_cube_map +#define GL_ARB_seamless_cube_map 1 +#endif /* GL_ARB_seamless_cube_map */ + +#ifndef GL_ARB_seamless_cubemap_per_texture +#define GL_ARB_seamless_cubemap_per_texture 1 +#endif /* GL_ARB_seamless_cubemap_per_texture */ + +#ifndef GL_ARB_separate_shader_objects +#define GL_ARB_separate_shader_objects 1 +#endif /* GL_ARB_separate_shader_objects */ + +#ifndef GL_ARB_shader_atomic_counter_ops +#define GL_ARB_shader_atomic_counter_ops 1 +#endif /* GL_ARB_shader_atomic_counter_ops */ + +#ifndef GL_ARB_shader_atomic_counters +#define GL_ARB_shader_atomic_counters 1 +#endif /* GL_ARB_shader_atomic_counters */ + +#ifndef GL_ARB_shader_ballot +#define GL_ARB_shader_ballot 1 +#endif /* GL_ARB_shader_ballot */ + +#ifndef GL_ARB_shader_bit_encoding +#define GL_ARB_shader_bit_encoding 1 +#endif /* GL_ARB_shader_bit_encoding */ + +#ifndef GL_ARB_shader_clock +#define GL_ARB_shader_clock 1 +#endif /* GL_ARB_shader_clock */ + +#ifndef GL_ARB_shader_draw_parameters +#define GL_ARB_shader_draw_parameters 1 +#endif /* GL_ARB_shader_draw_parameters */ + +#ifndef GL_ARB_shader_group_vote +#define GL_ARB_shader_group_vote 1 +#endif /* GL_ARB_shader_group_vote */ + +#ifndef GL_ARB_shader_image_load_store +#define GL_ARB_shader_image_load_store 1 +#endif /* GL_ARB_shader_image_load_store */ + +#ifndef GL_ARB_shader_image_size +#define GL_ARB_shader_image_size 1 +#endif /* GL_ARB_shader_image_size */ + +#ifndef GL_ARB_shader_objects +#define GL_ARB_shader_objects 1 +#ifdef __APPLE__ +typedef void *GLhandleARB; +#else +typedef unsigned int GLhandleARB; +#endif +typedef char GLcharARB; +#define GL_PROGRAM_OBJECT_ARB 0x8B40 +#define GL_SHADER_OBJECT_ARB 0x8B48 +#define GL_OBJECT_TYPE_ARB 0x8B4E +#define GL_OBJECT_SUBTYPE_ARB 0x8B4F +#define GL_FLOAT_VEC2_ARB 0x8B50 +#define GL_FLOAT_VEC3_ARB 0x8B51 +#define GL_FLOAT_VEC4_ARB 0x8B52 +#define GL_INT_VEC2_ARB 0x8B53 +#define GL_INT_VEC3_ARB 0x8B54 +#define GL_INT_VEC4_ARB 0x8B55 +#define GL_BOOL_ARB 0x8B56 +#define GL_BOOL_VEC2_ARB 0x8B57 +#define GL_BOOL_VEC3_ARB 0x8B58 +#define GL_BOOL_VEC4_ARB 0x8B59 +#define GL_FLOAT_MAT2_ARB 0x8B5A +#define GL_FLOAT_MAT3_ARB 0x8B5B +#define GL_FLOAT_MAT4_ARB 0x8B5C +#define GL_SAMPLER_1D_ARB 0x8B5D +#define GL_SAMPLER_2D_ARB 0x8B5E +#define GL_SAMPLER_3D_ARB 0x8B5F +#define GL_SAMPLER_CUBE_ARB 0x8B60 +#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 +#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 +#define GL_SAMPLER_2D_RECT_ARB 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 +#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 +#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 +#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 +#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 +#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 +#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 +#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 +#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 +#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 +typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); +typedef GLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); +typedef GLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); +typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB **string, const GLint *length); +typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); +typedef GLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void); +typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); +typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); +typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeleteObjectARB (GLhandleARB obj); +GLAPI GLhandleARB APIENTRY glGetHandleARB (GLenum pname); +GLAPI void APIENTRY glDetachObjectARB (GLhandleARB containerObj, GLhandleARB attachedObj); +GLAPI GLhandleARB APIENTRY glCreateShaderObjectARB (GLenum shaderType); +GLAPI void APIENTRY glShaderSourceARB (GLhandleARB shaderObj, GLsizei count, const GLcharARB **string, const GLint *length); +GLAPI void APIENTRY glCompileShaderARB (GLhandleARB shaderObj); +GLAPI GLhandleARB APIENTRY glCreateProgramObjectARB (void); +GLAPI void APIENTRY glAttachObjectARB (GLhandleARB containerObj, GLhandleARB obj); +GLAPI void APIENTRY glLinkProgramARB (GLhandleARB programObj); +GLAPI void APIENTRY glUseProgramObjectARB (GLhandleARB programObj); +GLAPI void APIENTRY glValidateProgramARB (GLhandleARB programObj); +GLAPI void APIENTRY glUniform1fARB (GLint location, GLfloat v0); +GLAPI void APIENTRY glUniform2fARB (GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glUniform3fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glUniform4fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glUniform1iARB (GLint location, GLint v0); +GLAPI void APIENTRY glUniform2iARB (GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glUniform3iARB (GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glUniform4iARB (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glUniform1fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform2fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform3fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform4fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform1ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform2ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform3ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform4ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniformMatrix2fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glGetObjectParameterfvARB (GLhandleARB obj, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetObjectParameterivARB (GLhandleARB obj, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetInfoLogARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); +GLAPI void APIENTRY glGetAttachedObjectsARB (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); +GLAPI GLint APIENTRY glGetUniformLocationARB (GLhandleARB programObj, const GLcharARB *name); +GLAPI void APIENTRY glGetActiveUniformARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +GLAPI void APIENTRY glGetUniformfvARB (GLhandleARB programObj, GLint location, GLfloat *params); +GLAPI void APIENTRY glGetUniformivARB (GLhandleARB programObj, GLint location, GLint *params); +GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); +#endif +#endif /* GL_ARB_shader_objects */ + +#ifndef GL_ARB_shader_precision +#define GL_ARB_shader_precision 1 +#endif /* GL_ARB_shader_precision */ + +#ifndef GL_ARB_shader_stencil_export +#define GL_ARB_shader_stencil_export 1 +#endif /* GL_ARB_shader_stencil_export */ + +#ifndef GL_ARB_shader_storage_buffer_object +#define GL_ARB_shader_storage_buffer_object 1 +#endif /* GL_ARB_shader_storage_buffer_object */ + +#ifndef GL_ARB_shader_subroutine +#define GL_ARB_shader_subroutine 1 +#endif /* GL_ARB_shader_subroutine */ + +#ifndef GL_ARB_shader_texture_image_samples +#define GL_ARB_shader_texture_image_samples 1 +#endif /* GL_ARB_shader_texture_image_samples */ + +#ifndef GL_ARB_shader_texture_lod +#define GL_ARB_shader_texture_lod 1 +#endif /* GL_ARB_shader_texture_lod */ + +#ifndef GL_ARB_shader_viewport_layer_array +#define GL_ARB_shader_viewport_layer_array 1 +#endif /* GL_ARB_shader_viewport_layer_array */ + +#ifndef GL_ARB_shading_language_100 +#define GL_ARB_shading_language_100 1 +#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C +#endif /* GL_ARB_shading_language_100 */ + +#ifndef GL_ARB_shading_language_420pack +#define GL_ARB_shading_language_420pack 1 +#endif /* GL_ARB_shading_language_420pack */ + +#ifndef GL_ARB_shading_language_include +#define GL_ARB_shading_language_include 1 +#define GL_SHADER_INCLUDE_ARB 0x8DAE +#define GL_NAMED_STRING_LENGTH_ARB 0x8DE9 +#define GL_NAMED_STRING_TYPE_ARB 0x8DEA +typedef void (APIENTRYP PFNGLNAMEDSTRINGARBPROC) (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); +typedef void (APIENTRYP PFNGLDELETENAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); +typedef void (APIENTRYP PFNGLCOMPILESHADERINCLUDEARBPROC) (GLuint shader, GLsizei count, const GLchar *const*path, const GLint *length); +typedef GLboolean (APIENTRYP PFNGLISNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); +typedef void (APIENTRYP PFNGLGETNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); +typedef void (APIENTRYP PFNGLGETNAMEDSTRINGIVARBPROC) (GLint namelen, const GLchar *name, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glNamedStringARB (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); +GLAPI void APIENTRY glDeleteNamedStringARB (GLint namelen, const GLchar *name); +GLAPI void APIENTRY glCompileShaderIncludeARB (GLuint shader, GLsizei count, const GLchar *const*path, const GLint *length); +GLAPI GLboolean APIENTRY glIsNamedStringARB (GLint namelen, const GLchar *name); +GLAPI void APIENTRY glGetNamedStringARB (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); +GLAPI void APIENTRY glGetNamedStringivARB (GLint namelen, const GLchar *name, GLenum pname, GLint *params); +#endif +#endif /* GL_ARB_shading_language_include */ + +#ifndef GL_ARB_shading_language_packing +#define GL_ARB_shading_language_packing 1 +#endif /* GL_ARB_shading_language_packing */ + +#ifndef GL_ARB_shadow +#define GL_ARB_shadow 1 +#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C +#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D +#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E +#endif /* GL_ARB_shadow */ + +#ifndef GL_ARB_shadow_ambient +#define GL_ARB_shadow_ambient 1 +#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF +#endif /* GL_ARB_shadow_ambient */ + +#ifndef GL_ARB_sparse_buffer +#define GL_ARB_sparse_buffer 1 +#define GL_SPARSE_STORAGE_BIT_ARB 0x0400 +#define GL_SPARSE_BUFFER_PAGE_SIZE_ARB 0x82F8 +typedef void (APIENTRYP PFNGLBUFFERPAGECOMMITMENTARBPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLboolean commit); +typedef void (APIENTRYP PFNGLNAMEDBUFFERPAGECOMMITMENTEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLboolean commit); +typedef void (APIENTRYP PFNGLNAMEDBUFFERPAGECOMMITMENTARBPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLboolean commit); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferPageCommitmentARB (GLenum target, GLintptr offset, GLsizeiptr size, GLboolean commit); +GLAPI void APIENTRY glNamedBufferPageCommitmentEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, GLboolean commit); +GLAPI void APIENTRY glNamedBufferPageCommitmentARB (GLuint buffer, GLintptr offset, GLsizeiptr size, GLboolean commit); +#endif +#endif /* GL_ARB_sparse_buffer */ + +#ifndef GL_ARB_sparse_texture +#define GL_ARB_sparse_texture 1 +#define GL_TEXTURE_SPARSE_ARB 0x91A6 +#define GL_VIRTUAL_PAGE_SIZE_INDEX_ARB 0x91A7 +#define GL_NUM_SPARSE_LEVELS_ARB 0x91AA +#define GL_NUM_VIRTUAL_PAGE_SIZES_ARB 0x91A8 +#define GL_VIRTUAL_PAGE_SIZE_X_ARB 0x9195 +#define GL_VIRTUAL_PAGE_SIZE_Y_ARB 0x9196 +#define GL_VIRTUAL_PAGE_SIZE_Z_ARB 0x9197 +#define GL_MAX_SPARSE_TEXTURE_SIZE_ARB 0x9198 +#define GL_MAX_SPARSE_3D_TEXTURE_SIZE_ARB 0x9199 +#define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS_ARB 0x919A +#define GL_SPARSE_TEXTURE_FULL_ARRAY_CUBE_MIPMAPS_ARB 0x91A9 +typedef void (APIENTRYP PFNGLTEXPAGECOMMITMENTARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexPageCommitmentARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); +#endif +#endif /* GL_ARB_sparse_texture */ + +#ifndef GL_ARB_sparse_texture2 +#define GL_ARB_sparse_texture2 1 +#endif /* GL_ARB_sparse_texture2 */ + +#ifndef GL_ARB_sparse_texture_clamp +#define GL_ARB_sparse_texture_clamp 1 +#endif /* GL_ARB_sparse_texture_clamp */ + +#ifndef GL_ARB_spirv_extensions +#define GL_ARB_spirv_extensions 1 +#endif /* GL_ARB_spirv_extensions */ + +#ifndef GL_ARB_stencil_texturing +#define GL_ARB_stencil_texturing 1 +#endif /* GL_ARB_stencil_texturing */ + +#ifndef GL_ARB_sync +#define GL_ARB_sync 1 +#endif /* GL_ARB_sync */ + +#ifndef GL_ARB_tessellation_shader +#define GL_ARB_tessellation_shader 1 +#endif /* GL_ARB_tessellation_shader */ + +#ifndef GL_ARB_texture_barrier +#define GL_ARB_texture_barrier 1 +#endif /* GL_ARB_texture_barrier */ + +#ifndef GL_ARB_texture_border_clamp +#define GL_ARB_texture_border_clamp 1 +#define GL_CLAMP_TO_BORDER_ARB 0x812D +#endif /* GL_ARB_texture_border_clamp */ + +#ifndef GL_ARB_texture_buffer_object +#define GL_ARB_texture_buffer_object 1 +#define GL_TEXTURE_BUFFER_ARB 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_ARB 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_ARB 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT_ARB 0x8C2E +typedef void (APIENTRYP PFNGLTEXBUFFERARBPROC) (GLenum target, GLenum internalformat, GLuint buffer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBufferARB (GLenum target, GLenum internalformat, GLuint buffer); +#endif +#endif /* GL_ARB_texture_buffer_object */ + +#ifndef GL_ARB_texture_buffer_object_rgb32 +#define GL_ARB_texture_buffer_object_rgb32 1 +#endif /* GL_ARB_texture_buffer_object_rgb32 */ + +#ifndef GL_ARB_texture_buffer_range +#define GL_ARB_texture_buffer_range 1 +#endif /* GL_ARB_texture_buffer_range */ + +#ifndef GL_ARB_texture_compression +#define GL_ARB_texture_compression 1 +#define GL_COMPRESSED_ALPHA_ARB 0x84E9 +#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB +#define GL_COMPRESSED_INTENSITY_ARB 0x84EC +#define GL_COMPRESSED_RGB_ARB 0x84ED +#define GL_COMPRESSED_RGBA_ARB 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 +#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, void *img); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexImage1DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexSubImage3DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexSubImage2DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexSubImage1DARB (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum target, GLint level, void *img); +#endif +#endif /* GL_ARB_texture_compression */ + +#ifndef GL_ARB_texture_compression_bptc +#define GL_ARB_texture_compression_bptc 1 +#define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C +#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB 0x8E8D +#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB 0x8E8E +#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F +#endif /* GL_ARB_texture_compression_bptc */ + +#ifndef GL_ARB_texture_compression_rgtc +#define GL_ARB_texture_compression_rgtc 1 +#endif /* GL_ARB_texture_compression_rgtc */ + +#ifndef GL_ARB_texture_cube_map +#define GL_ARB_texture_cube_map 1 +#define GL_NORMAL_MAP_ARB 0x8511 +#define GL_REFLECTION_MAP_ARB 0x8512 +#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C +#endif /* GL_ARB_texture_cube_map */ + +#ifndef GL_ARB_texture_cube_map_array +#define GL_ARB_texture_cube_map_array 1 +#define GL_TEXTURE_CUBE_MAP_ARRAY_ARB 0x9009 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB 0x900A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB 0x900B +#define GL_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900C +#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB 0x900D +#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900E +#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900F +#endif /* GL_ARB_texture_cube_map_array */ + +#ifndef GL_ARB_texture_env_add +#define GL_ARB_texture_env_add 1 +#endif /* GL_ARB_texture_env_add */ + +#ifndef GL_ARB_texture_env_combine +#define GL_ARB_texture_env_combine 1 +#define GL_COMBINE_ARB 0x8570 +#define GL_COMBINE_RGB_ARB 0x8571 +#define GL_COMBINE_ALPHA_ARB 0x8572 +#define GL_SOURCE0_RGB_ARB 0x8580 +#define GL_SOURCE1_RGB_ARB 0x8581 +#define GL_SOURCE2_RGB_ARB 0x8582 +#define GL_SOURCE0_ALPHA_ARB 0x8588 +#define GL_SOURCE1_ALPHA_ARB 0x8589 +#define GL_SOURCE2_ALPHA_ARB 0x858A +#define GL_OPERAND0_RGB_ARB 0x8590 +#define GL_OPERAND1_RGB_ARB 0x8591 +#define GL_OPERAND2_RGB_ARB 0x8592 +#define GL_OPERAND0_ALPHA_ARB 0x8598 +#define GL_OPERAND1_ALPHA_ARB 0x8599 +#define GL_OPERAND2_ALPHA_ARB 0x859A +#define GL_RGB_SCALE_ARB 0x8573 +#define GL_ADD_SIGNED_ARB 0x8574 +#define GL_INTERPOLATE_ARB 0x8575 +#define GL_SUBTRACT_ARB 0x84E7 +#define GL_CONSTANT_ARB 0x8576 +#define GL_PRIMARY_COLOR_ARB 0x8577 +#define GL_PREVIOUS_ARB 0x8578 +#endif /* GL_ARB_texture_env_combine */ + +#ifndef GL_ARB_texture_env_crossbar +#define GL_ARB_texture_env_crossbar 1 +#endif /* GL_ARB_texture_env_crossbar */ + +#ifndef GL_ARB_texture_env_dot3 +#define GL_ARB_texture_env_dot3 1 +#define GL_DOT3_RGB_ARB 0x86AE +#define GL_DOT3_RGBA_ARB 0x86AF +#endif /* GL_ARB_texture_env_dot3 */ + +#ifndef GL_ARB_texture_filter_anisotropic +#define GL_ARB_texture_filter_anisotropic 1 +#endif /* GL_ARB_texture_filter_anisotropic */ + +#ifndef GL_ARB_texture_filter_minmax +#define GL_ARB_texture_filter_minmax 1 +#define GL_TEXTURE_REDUCTION_MODE_ARB 0x9366 +#define GL_WEIGHTED_AVERAGE_ARB 0x9367 +#endif /* GL_ARB_texture_filter_minmax */ + +#ifndef GL_ARB_texture_float +#define GL_ARB_texture_float 1 +#define GL_TEXTURE_RED_TYPE_ARB 0x8C10 +#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 +#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 +#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 +#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 +#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 +#define GL_RGBA32F_ARB 0x8814 +#define GL_RGB32F_ARB 0x8815 +#define GL_ALPHA32F_ARB 0x8816 +#define GL_INTENSITY32F_ARB 0x8817 +#define GL_LUMINANCE32F_ARB 0x8818 +#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 +#define GL_RGBA16F_ARB 0x881A +#define GL_RGB16F_ARB 0x881B +#define GL_ALPHA16F_ARB 0x881C +#define GL_INTENSITY16F_ARB 0x881D +#define GL_LUMINANCE16F_ARB 0x881E +#define GL_LUMINANCE_ALPHA16F_ARB 0x881F +#endif /* GL_ARB_texture_float */ + +#ifndef GL_ARB_texture_gather +#define GL_ARB_texture_gather 1 +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5F +#define GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS_ARB 0x8F9F +#endif /* GL_ARB_texture_gather */ + +#ifndef GL_ARB_texture_mirror_clamp_to_edge +#define GL_ARB_texture_mirror_clamp_to_edge 1 +#endif /* GL_ARB_texture_mirror_clamp_to_edge */ + +#ifndef GL_ARB_texture_mirrored_repeat +#define GL_ARB_texture_mirrored_repeat 1 +#define GL_MIRRORED_REPEAT_ARB 0x8370 +#endif /* GL_ARB_texture_mirrored_repeat */ + +#ifndef GL_ARB_texture_multisample +#define GL_ARB_texture_multisample 1 +#endif /* GL_ARB_texture_multisample */ + +#ifndef GL_ARB_texture_non_power_of_two +#define GL_ARB_texture_non_power_of_two 1 +#endif /* GL_ARB_texture_non_power_of_two */ + +#ifndef GL_ARB_texture_query_levels +#define GL_ARB_texture_query_levels 1 +#endif /* GL_ARB_texture_query_levels */ + +#ifndef GL_ARB_texture_query_lod +#define GL_ARB_texture_query_lod 1 +#endif /* GL_ARB_texture_query_lod */ + +#ifndef GL_ARB_texture_rectangle +#define GL_ARB_texture_rectangle 1 +#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 +#endif /* GL_ARB_texture_rectangle */ + +#ifndef GL_ARB_texture_rg +#define GL_ARB_texture_rg 1 +#endif /* GL_ARB_texture_rg */ + +#ifndef GL_ARB_texture_rgb10_a2ui +#define GL_ARB_texture_rgb10_a2ui 1 +#endif /* GL_ARB_texture_rgb10_a2ui */ + +#ifndef GL_ARB_texture_stencil8 +#define GL_ARB_texture_stencil8 1 +#endif /* GL_ARB_texture_stencil8 */ + +#ifndef GL_ARB_texture_storage +#define GL_ARB_texture_storage 1 +#endif /* GL_ARB_texture_storage */ + +#ifndef GL_ARB_texture_storage_multisample +#define GL_ARB_texture_storage_multisample 1 +#endif /* GL_ARB_texture_storage_multisample */ + +#ifndef GL_ARB_texture_swizzle +#define GL_ARB_texture_swizzle 1 +#endif /* GL_ARB_texture_swizzle */ + +#ifndef GL_ARB_texture_view +#define GL_ARB_texture_view 1 +#endif /* GL_ARB_texture_view */ + +#ifndef GL_ARB_timer_query +#define GL_ARB_timer_query 1 +#endif /* GL_ARB_timer_query */ + +#ifndef GL_ARB_transform_feedback2 +#define GL_ARB_transform_feedback2 1 +#endif /* GL_ARB_transform_feedback2 */ + +#ifndef GL_ARB_transform_feedback3 +#define GL_ARB_transform_feedback3 1 +#endif /* GL_ARB_transform_feedback3 */ + +#ifndef GL_ARB_transform_feedback_instanced +#define GL_ARB_transform_feedback_instanced 1 +#endif /* GL_ARB_transform_feedback_instanced */ + +#ifndef GL_ARB_transform_feedback_overflow_query +#define GL_ARB_transform_feedback_overflow_query 1 +#define GL_TRANSFORM_FEEDBACK_OVERFLOW_ARB 0x82EC +#define GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW_ARB 0x82ED +#endif /* GL_ARB_transform_feedback_overflow_query */ + +#ifndef GL_ARB_transpose_matrix +#define GL_ARB_transpose_matrix 1 +#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *m); +GLAPI void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *m); +GLAPI void APIENTRY glMultTransposeMatrixfARB (const GLfloat *m); +GLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *m); +#endif +#endif /* GL_ARB_transpose_matrix */ + +#ifndef GL_ARB_uniform_buffer_object +#define GL_ARB_uniform_buffer_object 1 +#endif /* GL_ARB_uniform_buffer_object */ + +#ifndef GL_ARB_vertex_array_bgra +#define GL_ARB_vertex_array_bgra 1 +#endif /* GL_ARB_vertex_array_bgra */ + +#ifndef GL_ARB_vertex_array_object +#define GL_ARB_vertex_array_object 1 +#endif /* GL_ARB_vertex_array_object */ + +#ifndef GL_ARB_vertex_attrib_64bit +#define GL_ARB_vertex_attrib_64bit 1 +#endif /* GL_ARB_vertex_attrib_64bit */ + +#ifndef GL_ARB_vertex_attrib_binding +#define GL_ARB_vertex_attrib_binding 1 +#endif /* GL_ARB_vertex_attrib_binding */ + +#ifndef GL_ARB_vertex_blend +#define GL_ARB_vertex_blend 1 +#define GL_MAX_VERTEX_UNITS_ARB 0x86A4 +#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 +#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 +#define GL_VERTEX_BLEND_ARB 0x86A7 +#define GL_CURRENT_WEIGHT_ARB 0x86A8 +#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 +#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA +#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB +#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC +#define GL_WEIGHT_ARRAY_ARB 0x86AD +#define GL_MODELVIEW0_ARB 0x1700 +#define GL_MODELVIEW1_ARB 0x850A +#define GL_MODELVIEW2_ARB 0x8722 +#define GL_MODELVIEW3_ARB 0x8723 +#define GL_MODELVIEW4_ARB 0x8724 +#define GL_MODELVIEW5_ARB 0x8725 +#define GL_MODELVIEW6_ARB 0x8726 +#define GL_MODELVIEW7_ARB 0x8727 +#define GL_MODELVIEW8_ARB 0x8728 +#define GL_MODELVIEW9_ARB 0x8729 +#define GL_MODELVIEW10_ARB 0x872A +#define GL_MODELVIEW11_ARB 0x872B +#define GL_MODELVIEW12_ARB 0x872C +#define GL_MODELVIEW13_ARB 0x872D +#define GL_MODELVIEW14_ARB 0x872E +#define GL_MODELVIEW15_ARB 0x872F +#define GL_MODELVIEW16_ARB 0x8730 +#define GL_MODELVIEW17_ARB 0x8731 +#define GL_MODELVIEW18_ARB 0x8732 +#define GL_MODELVIEW19_ARB 0x8733 +#define GL_MODELVIEW20_ARB 0x8734 +#define GL_MODELVIEW21_ARB 0x8735 +#define GL_MODELVIEW22_ARB 0x8736 +#define GL_MODELVIEW23_ARB 0x8737 +#define GL_MODELVIEW24_ARB 0x8738 +#define GL_MODELVIEW25_ARB 0x8739 +#define GL_MODELVIEW26_ARB 0x873A +#define GL_MODELVIEW27_ARB 0x873B +#define GL_MODELVIEW28_ARB 0x873C +#define GL_MODELVIEW29_ARB 0x873D +#define GL_MODELVIEW30_ARB 0x873E +#define GL_MODELVIEW31_ARB 0x873F +typedef void (APIENTRYP PFNGLWEIGHTBVARBPROC) (GLint size, const GLbyte *weights); +typedef void (APIENTRYP PFNGLWEIGHTSVARBPROC) (GLint size, const GLshort *weights); +typedef void (APIENTRYP PFNGLWEIGHTIVARBPROC) (GLint size, const GLint *weights); +typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights); +typedef void (APIENTRYP PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weights); +typedef void (APIENTRYP PFNGLWEIGHTUBVARBPROC) (GLint size, const GLubyte *weights); +typedef void (APIENTRYP PFNGLWEIGHTUSVARBPROC) (GLint size, const GLushort *weights); +typedef void (APIENTRYP PFNGLWEIGHTUIVARBPROC) (GLint size, const GLuint *weights); +typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWeightbvARB (GLint size, const GLbyte *weights); +GLAPI void APIENTRY glWeightsvARB (GLint size, const GLshort *weights); +GLAPI void APIENTRY glWeightivARB (GLint size, const GLint *weights); +GLAPI void APIENTRY glWeightfvARB (GLint size, const GLfloat *weights); +GLAPI void APIENTRY glWeightdvARB (GLint size, const GLdouble *weights); +GLAPI void APIENTRY glWeightubvARB (GLint size, const GLubyte *weights); +GLAPI void APIENTRY glWeightusvARB (GLint size, const GLushort *weights); +GLAPI void APIENTRY glWeightuivARB (GLint size, const GLuint *weights); +GLAPI void APIENTRY glWeightPointerARB (GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glVertexBlendARB (GLint count); +#endif +#endif /* GL_ARB_vertex_blend */ + +#ifndef GL_ARB_vertex_buffer_object +#define GL_ARB_vertex_buffer_object 1 +typedef khronos_ssize_t GLsizeiptrARB; +typedef khronos_intptr_t GLintptrARB; +#define GL_BUFFER_SIZE_ARB 0x8764 +#define GL_BUFFER_USAGE_ARB 0x8765 +#define GL_ARRAY_BUFFER_ARB 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 +#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 +#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F +#define GL_READ_ONLY_ARB 0x88B8 +#define GL_WRITE_ONLY_ARB 0x88B9 +#define GL_READ_WRITE_ARB 0x88BA +#define GL_BUFFER_ACCESS_ARB 0x88BB +#define GL_BUFFER_MAPPED_ARB 0x88BC +#define GL_BUFFER_MAP_POINTER_ARB 0x88BD +#define GL_STREAM_DRAW_ARB 0x88E0 +#define GL_STREAM_READ_ARB 0x88E1 +#define GL_STREAM_COPY_ARB 0x88E2 +#define GL_STATIC_DRAW_ARB 0x88E4 +#define GL_STATIC_READ_ARB 0x88E5 +#define GL_STATIC_COPY_ARB 0x88E6 +#define GL_DYNAMIC_DRAW_ARB 0x88E8 +#define GL_DYNAMIC_READ_ARB 0x88E9 +#define GL_DYNAMIC_COPY_ARB 0x88EA +typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const void *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const void *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, void *data); +typedef void *(APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, void **params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindBufferARB (GLenum target, GLuint buffer); +GLAPI void APIENTRY glDeleteBuffersARB (GLsizei n, const GLuint *buffers); +GLAPI void APIENTRY glGenBuffersARB (GLsizei n, GLuint *buffers); +GLAPI GLboolean APIENTRY glIsBufferARB (GLuint buffer); +GLAPI void APIENTRY glBufferDataARB (GLenum target, GLsizeiptrARB size, const void *data, GLenum usage); +GLAPI void APIENTRY glBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const void *data); +GLAPI void APIENTRY glGetBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, void *data); +GLAPI void *APIENTRY glMapBufferARB (GLenum target, GLenum access); +GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum target); +GLAPI void APIENTRY glGetBufferParameterivARB (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetBufferPointervARB (GLenum target, GLenum pname, void **params); +#endif +#endif /* GL_ARB_vertex_buffer_object */ + +#ifndef GL_ARB_vertex_program +#define GL_ARB_vertex_program 1 +#define GL_COLOR_SUM_ARB 0x8458 +#define GL_VERTEX_PROGRAM_ARB 0x8620 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 +#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 +#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A +#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 +#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 +#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 +#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, void **pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttrib1dARB (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1fARB (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1sARB (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2dARB (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2fARB (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2sARB (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3sARB (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4NbvARB (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4NivARB (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4NsvARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4NubARB (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4NubvARB (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4NuivARB (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4NusvARB (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttrib4bvARB (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4ivARB (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4sARB (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubvARB (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4uivARB (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4usvARB (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribPointerARB (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glEnableVertexAttribArrayARB (GLuint index); +GLAPI void APIENTRY glDisableVertexAttribArrayARB (GLuint index); +GLAPI void APIENTRY glGetVertexAttribdvARB (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfvARB (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribivARB (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointervARB (GLuint index, GLenum pname, void **pointer); +#endif +#endif /* GL_ARB_vertex_program */ + +#ifndef GL_ARB_vertex_shader +#define GL_ARB_vertex_shader 1 +#define GL_VERTEX_SHADER_ARB 0x8B31 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A +#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D +#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 +#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindAttribLocationARB (GLhandleARB programObj, GLuint index, const GLcharARB *name); +GLAPI void APIENTRY glGetActiveAttribARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +GLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB programObj, const GLcharARB *name); +#endif +#endif /* GL_ARB_vertex_shader */ + +#ifndef GL_ARB_vertex_type_10f_11f_11f_rev +#define GL_ARB_vertex_type_10f_11f_11f_rev 1 +#endif /* GL_ARB_vertex_type_10f_11f_11f_rev */ + +#ifndef GL_ARB_vertex_type_2_10_10_10_rev +#define GL_ARB_vertex_type_2_10_10_10_rev 1 +#endif /* GL_ARB_vertex_type_2_10_10_10_rev */ + +#ifndef GL_ARB_viewport_array +#define GL_ARB_viewport_array 1 +typedef void (APIENTRYP PFNGLDEPTHRANGEARRAYDVNVPROC) (GLuint first, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLDEPTHRANGEINDEXEDDNVPROC) (GLuint index, GLdouble n, GLdouble f); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthRangeArraydvNV (GLuint first, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glDepthRangeIndexeddNV (GLuint index, GLdouble n, GLdouble f); +#endif +#endif /* GL_ARB_viewport_array */ + +#ifndef GL_ARB_window_pos +#define GL_ARB_window_pos 1 +typedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowPos2dARB (GLdouble x, GLdouble y); +GLAPI void APIENTRY glWindowPos2dvARB (const GLdouble *v); +GLAPI void APIENTRY glWindowPos2fARB (GLfloat x, GLfloat y); +GLAPI void APIENTRY glWindowPos2fvARB (const GLfloat *v); +GLAPI void APIENTRY glWindowPos2iARB (GLint x, GLint y); +GLAPI void APIENTRY glWindowPos2ivARB (const GLint *v); +GLAPI void APIENTRY glWindowPos2sARB (GLshort x, GLshort y); +GLAPI void APIENTRY glWindowPos2svARB (const GLshort *v); +GLAPI void APIENTRY glWindowPos3dARB (GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glWindowPos3dvARB (const GLdouble *v); +GLAPI void APIENTRY glWindowPos3fARB (GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glWindowPos3fvARB (const GLfloat *v); +GLAPI void APIENTRY glWindowPos3iARB (GLint x, GLint y, GLint z); +GLAPI void APIENTRY glWindowPos3ivARB (const GLint *v); +GLAPI void APIENTRY glWindowPos3sARB (GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glWindowPos3svARB (const GLshort *v); +#endif +#endif /* GL_ARB_window_pos */ + +#ifndef GL_KHR_blend_equation_advanced +#define GL_KHR_blend_equation_advanced 1 +#define GL_MULTIPLY_KHR 0x9294 +#define GL_SCREEN_KHR 0x9295 +#define GL_OVERLAY_KHR 0x9296 +#define GL_DARKEN_KHR 0x9297 +#define GL_LIGHTEN_KHR 0x9298 +#define GL_COLORDODGE_KHR 0x9299 +#define GL_COLORBURN_KHR 0x929A +#define GL_HARDLIGHT_KHR 0x929B +#define GL_SOFTLIGHT_KHR 0x929C +#define GL_DIFFERENCE_KHR 0x929E +#define GL_EXCLUSION_KHR 0x92A0 +#define GL_HSL_HUE_KHR 0x92AD +#define GL_HSL_SATURATION_KHR 0x92AE +#define GL_HSL_COLOR_KHR 0x92AF +#define GL_HSL_LUMINOSITY_KHR 0x92B0 +typedef void (APIENTRYP PFNGLBLENDBARRIERKHRPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendBarrierKHR (void); +#endif +#endif /* GL_KHR_blend_equation_advanced */ + +#ifndef GL_KHR_blend_equation_advanced_coherent +#define GL_KHR_blend_equation_advanced_coherent 1 +#define GL_BLEND_ADVANCED_COHERENT_KHR 0x9285 +#endif /* GL_KHR_blend_equation_advanced_coherent */ + +#ifndef GL_KHR_context_flush_control +#define GL_KHR_context_flush_control 1 +#endif /* GL_KHR_context_flush_control */ + +#ifndef GL_KHR_debug +#define GL_KHR_debug 1 +#endif /* GL_KHR_debug */ + +#ifndef GL_KHR_no_error +#define GL_KHR_no_error 1 +#define GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR 0x00000008 +#endif /* GL_KHR_no_error */ + +#ifndef GL_KHR_parallel_shader_compile +#define GL_KHR_parallel_shader_compile 1 +#define GL_MAX_SHADER_COMPILER_THREADS_KHR 0x91B0 +#define GL_COMPLETION_STATUS_KHR 0x91B1 +typedef void (APIENTRYP PFNGLMAXSHADERCOMPILERTHREADSKHRPROC) (GLuint count); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMaxShaderCompilerThreadsKHR (GLuint count); +#endif +#endif /* GL_KHR_parallel_shader_compile */ + +#ifndef GL_KHR_robust_buffer_access_behavior +#define GL_KHR_robust_buffer_access_behavior 1 +#endif /* GL_KHR_robust_buffer_access_behavior */ + +#ifndef GL_KHR_robustness +#define GL_KHR_robustness 1 +#define GL_CONTEXT_ROBUST_ACCESS 0x90F3 +#endif /* GL_KHR_robustness */ + +#ifndef GL_KHR_shader_subgroup +#define GL_KHR_shader_subgroup 1 +#define GL_SUBGROUP_SIZE_KHR 0x9532 +#define GL_SUBGROUP_SUPPORTED_STAGES_KHR 0x9533 +#define GL_SUBGROUP_SUPPORTED_FEATURES_KHR 0x9534 +#define GL_SUBGROUP_QUAD_ALL_STAGES_KHR 0x9535 +#define GL_SUBGROUP_FEATURE_BASIC_BIT_KHR 0x00000001 +#define GL_SUBGROUP_FEATURE_VOTE_BIT_KHR 0x00000002 +#define GL_SUBGROUP_FEATURE_ARITHMETIC_BIT_KHR 0x00000004 +#define GL_SUBGROUP_FEATURE_BALLOT_BIT_KHR 0x00000008 +#define GL_SUBGROUP_FEATURE_SHUFFLE_BIT_KHR 0x00000010 +#define GL_SUBGROUP_FEATURE_SHUFFLE_RELATIVE_BIT_KHR 0x00000020 +#define GL_SUBGROUP_FEATURE_CLUSTERED_BIT_KHR 0x00000040 +#define GL_SUBGROUP_FEATURE_QUAD_BIT_KHR 0x00000080 +#endif /* GL_KHR_shader_subgroup */ + +#ifndef GL_KHR_texture_compression_astc_hdr +#define GL_KHR_texture_compression_astc_hdr 1 +#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 +#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 +#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 +#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 +#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 +#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 +#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 +#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 +#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 +#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 +#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA +#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB +#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC +#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD +#endif /* GL_KHR_texture_compression_astc_hdr */ + +#ifndef GL_KHR_texture_compression_astc_ldr +#define GL_KHR_texture_compression_astc_ldr 1 +#endif /* GL_KHR_texture_compression_astc_ldr */ + +#ifndef GL_KHR_texture_compression_astc_sliced_3d +#define GL_KHR_texture_compression_astc_sliced_3d 1 +#endif /* GL_KHR_texture_compression_astc_sliced_3d */ + +#ifndef GL_OES_byte_coordinates +#define GL_OES_byte_coordinates 1 +typedef void (APIENTRYP PFNGLMULTITEXCOORD1BOESPROC) (GLenum texture, GLbyte s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1BVOESPROC) (GLenum texture, const GLbyte *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2BOESPROC) (GLenum texture, GLbyte s, GLbyte t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2BVOESPROC) (GLenum texture, const GLbyte *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3BOESPROC) (GLenum texture, GLbyte s, GLbyte t, GLbyte r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3BVOESPROC) (GLenum texture, const GLbyte *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4BOESPROC) (GLenum texture, GLbyte s, GLbyte t, GLbyte r, GLbyte q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4BVOESPROC) (GLenum texture, const GLbyte *coords); +typedef void (APIENTRYP PFNGLTEXCOORD1BOESPROC) (GLbyte s); +typedef void (APIENTRYP PFNGLTEXCOORD1BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLTEXCOORD2BOESPROC) (GLbyte s, GLbyte t); +typedef void (APIENTRYP PFNGLTEXCOORD2BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLTEXCOORD3BOESPROC) (GLbyte s, GLbyte t, GLbyte r); +typedef void (APIENTRYP PFNGLTEXCOORD3BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLTEXCOORD4BOESPROC) (GLbyte s, GLbyte t, GLbyte r, GLbyte q); +typedef void (APIENTRYP PFNGLTEXCOORD4BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLVERTEX2BOESPROC) (GLbyte x, GLbyte y); +typedef void (APIENTRYP PFNGLVERTEX2BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLVERTEX3BOESPROC) (GLbyte x, GLbyte y, GLbyte z); +typedef void (APIENTRYP PFNGLVERTEX3BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLVERTEX4BOESPROC) (GLbyte x, GLbyte y, GLbyte z, GLbyte w); +typedef void (APIENTRYP PFNGLVERTEX4BVOESPROC) (const GLbyte *coords); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiTexCoord1bOES (GLenum texture, GLbyte s); +GLAPI void APIENTRY glMultiTexCoord1bvOES (GLenum texture, const GLbyte *coords); +GLAPI void APIENTRY glMultiTexCoord2bOES (GLenum texture, GLbyte s, GLbyte t); +GLAPI void APIENTRY glMultiTexCoord2bvOES (GLenum texture, const GLbyte *coords); +GLAPI void APIENTRY glMultiTexCoord3bOES (GLenum texture, GLbyte s, GLbyte t, GLbyte r); +GLAPI void APIENTRY glMultiTexCoord3bvOES (GLenum texture, const GLbyte *coords); +GLAPI void APIENTRY glMultiTexCoord4bOES (GLenum texture, GLbyte s, GLbyte t, GLbyte r, GLbyte q); +GLAPI void APIENTRY glMultiTexCoord4bvOES (GLenum texture, const GLbyte *coords); +GLAPI void APIENTRY glTexCoord1bOES (GLbyte s); +GLAPI void APIENTRY glTexCoord1bvOES (const GLbyte *coords); +GLAPI void APIENTRY glTexCoord2bOES (GLbyte s, GLbyte t); +GLAPI void APIENTRY glTexCoord2bvOES (const GLbyte *coords); +GLAPI void APIENTRY glTexCoord3bOES (GLbyte s, GLbyte t, GLbyte r); +GLAPI void APIENTRY glTexCoord3bvOES (const GLbyte *coords); +GLAPI void APIENTRY glTexCoord4bOES (GLbyte s, GLbyte t, GLbyte r, GLbyte q); +GLAPI void APIENTRY glTexCoord4bvOES (const GLbyte *coords); +GLAPI void APIENTRY glVertex2bOES (GLbyte x, GLbyte y); +GLAPI void APIENTRY glVertex2bvOES (const GLbyte *coords); +GLAPI void APIENTRY glVertex3bOES (GLbyte x, GLbyte y, GLbyte z); +GLAPI void APIENTRY glVertex3bvOES (const GLbyte *coords); +GLAPI void APIENTRY glVertex4bOES (GLbyte x, GLbyte y, GLbyte z, GLbyte w); +GLAPI void APIENTRY glVertex4bvOES (const GLbyte *coords); +#endif +#endif /* GL_OES_byte_coordinates */ + +#ifndef GL_OES_compressed_paletted_texture +#define GL_OES_compressed_paletted_texture 1 +#define GL_PALETTE4_RGB8_OES 0x8B90 +#define GL_PALETTE4_RGBA8_OES 0x8B91 +#define GL_PALETTE4_R5_G6_B5_OES 0x8B92 +#define GL_PALETTE4_RGBA4_OES 0x8B93 +#define GL_PALETTE4_RGB5_A1_OES 0x8B94 +#define GL_PALETTE8_RGB8_OES 0x8B95 +#define GL_PALETTE8_RGBA8_OES 0x8B96 +#define GL_PALETTE8_R5_G6_B5_OES 0x8B97 +#define GL_PALETTE8_RGBA4_OES 0x8B98 +#define GL_PALETTE8_RGB5_A1_OES 0x8B99 +#endif /* GL_OES_compressed_paletted_texture */ + +#ifndef GL_OES_fixed_point +#define GL_OES_fixed_point 1 +typedef khronos_int32_t GLfixed; +#define GL_FIXED_OES 0x140C +typedef void (APIENTRYP PFNGLALPHAFUNCXOESPROC) (GLenum func, GLfixed ref); +typedef void (APIENTRYP PFNGLCLEARCOLORXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (APIENTRYP PFNGLCLEARDEPTHXOESPROC) (GLfixed depth); +typedef void (APIENTRYP PFNGLCLIPPLANEXOESPROC) (GLenum plane, const GLfixed *equation); +typedef void (APIENTRYP PFNGLCOLOR4XOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (APIENTRYP PFNGLDEPTHRANGEXOESPROC) (GLfixed n, GLfixed f); +typedef void (APIENTRYP PFNGLFOGXOESPROC) (GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLFOGXVOESPROC) (GLenum pname, const GLfixed *param); +typedef void (APIENTRYP PFNGLFRUSTUMXOESPROC) (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); +typedef void (APIENTRYP PFNGLGETCLIPPLANEXOESPROC) (GLenum plane, GLfixed *equation); +typedef void (APIENTRYP PFNGLGETFIXEDVOESPROC) (GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETTEXENVXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLLIGHTMODELXOESPROC) (GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLLIGHTMODELXVOESPROC) (GLenum pname, const GLfixed *param); +typedef void (APIENTRYP PFNGLLIGHTXOESPROC) (GLenum light, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLLIGHTXVOESPROC) (GLenum light, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLLINEWIDTHXOESPROC) (GLfixed width); +typedef void (APIENTRYP PFNGLLOADMATRIXXOESPROC) (const GLfixed *m); +typedef void (APIENTRYP PFNGLMATERIALXOESPROC) (GLenum face, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLMATERIALXVOESPROC) (GLenum face, GLenum pname, const GLfixed *param); +typedef void (APIENTRYP PFNGLMULTMATRIXXOESPROC) (const GLfixed *m); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4XOESPROC) (GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q); +typedef void (APIENTRYP PFNGLNORMAL3XOESPROC) (GLfixed nx, GLfixed ny, GLfixed nz); +typedef void (APIENTRYP PFNGLORTHOXOESPROC) (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); +typedef void (APIENTRYP PFNGLPOINTPARAMETERXVOESPROC) (GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLPOINTSIZEXOESPROC) (GLfixed size); +typedef void (APIENTRYP PFNGLPOLYGONOFFSETXOESPROC) (GLfixed factor, GLfixed units); +typedef void (APIENTRYP PFNGLROTATEXOESPROC) (GLfixed angle, GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLSCALEXOESPROC) (GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLTEXENVXOESPROC) (GLenum target, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLTEXENVXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERXOESPROC) (GLenum target, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLTRANSLATEXOESPROC) (GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLACCUMXOESPROC) (GLenum op, GLfixed value); +typedef void (APIENTRYP PFNGLBITMAPXOESPROC) (GLsizei width, GLsizei height, GLfixed xorig, GLfixed yorig, GLfixed xmove, GLfixed ymove, const GLubyte *bitmap); +typedef void (APIENTRYP PFNGLBLENDCOLORXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (APIENTRYP PFNGLCLEARACCUMXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (APIENTRYP PFNGLCOLOR3XOESPROC) (GLfixed red, GLfixed green, GLfixed blue); +typedef void (APIENTRYP PFNGLCOLOR3XVOESPROC) (const GLfixed *components); +typedef void (APIENTRYP PFNGLCOLOR4XVOESPROC) (const GLfixed *components); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERXOESPROC) (GLenum target, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLEVALCOORD1XOESPROC) (GLfixed u); +typedef void (APIENTRYP PFNGLEVALCOORD1XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLEVALCOORD2XOESPROC) (GLfixed u, GLfixed v); +typedef void (APIENTRYP PFNGLEVALCOORD2XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLFEEDBACKBUFFERXOESPROC) (GLsizei n, GLenum type, const GLfixed *buffer); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETLIGHTXOESPROC) (GLenum light, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETMAPXVOESPROC) (GLenum target, GLenum query, GLfixed *v); +typedef void (APIENTRYP PFNGLGETMATERIALXOESPROC) (GLenum face, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLGETPIXELMAPXVPROC) (GLenum map, GLint size, GLfixed *values); +typedef void (APIENTRYP PFNGLGETTEXGENXVOESPROC) (GLenum coord, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERXVOESPROC) (GLenum target, GLint level, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLINDEXXOESPROC) (GLfixed component); +typedef void (APIENTRYP PFNGLINDEXXVOESPROC) (const GLfixed *component); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXXOESPROC) (const GLfixed *m); +typedef void (APIENTRYP PFNGLMAP1XOESPROC) (GLenum target, GLfixed u1, GLfixed u2, GLint stride, GLint order, GLfixed points); +typedef void (APIENTRYP PFNGLMAP2XOESPROC) (GLenum target, GLfixed u1, GLfixed u2, GLint ustride, GLint uorder, GLfixed v1, GLfixed v2, GLint vstride, GLint vorder, GLfixed points); +typedef void (APIENTRYP PFNGLMAPGRID1XOESPROC) (GLint n, GLfixed u1, GLfixed u2); +typedef void (APIENTRYP PFNGLMAPGRID2XOESPROC) (GLint n, GLfixed u1, GLfixed u2, GLfixed v1, GLfixed v2); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXXOESPROC) (const GLfixed *m); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1XOESPROC) (GLenum texture, GLfixed s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1XVOESPROC) (GLenum texture, const GLfixed *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2XOESPROC) (GLenum texture, GLfixed s, GLfixed t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2XVOESPROC) (GLenum texture, const GLfixed *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3XOESPROC) (GLenum texture, GLfixed s, GLfixed t, GLfixed r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3XVOESPROC) (GLenum texture, const GLfixed *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4XVOESPROC) (GLenum texture, const GLfixed *coords); +typedef void (APIENTRYP PFNGLNORMAL3XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLPASSTHROUGHXOESPROC) (GLfixed token); +typedef void (APIENTRYP PFNGLPIXELMAPXPROC) (GLenum map, GLint size, const GLfixed *values); +typedef void (APIENTRYP PFNGLPIXELSTOREXPROC) (GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLPIXELTRANSFERXOESPROC) (GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLPIXELZOOMXOESPROC) (GLfixed xfactor, GLfixed yfactor); +typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESXOESPROC) (GLsizei n, const GLuint *textures, const GLfixed *priorities); +typedef void (APIENTRYP PFNGLRASTERPOS2XOESPROC) (GLfixed x, GLfixed y); +typedef void (APIENTRYP PFNGLRASTERPOS2XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLRASTERPOS3XOESPROC) (GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLRASTERPOS3XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLRASTERPOS4XOESPROC) (GLfixed x, GLfixed y, GLfixed z, GLfixed w); +typedef void (APIENTRYP PFNGLRASTERPOS4XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLRECTXOESPROC) (GLfixed x1, GLfixed y1, GLfixed x2, GLfixed y2); +typedef void (APIENTRYP PFNGLRECTXVOESPROC) (const GLfixed *v1, const GLfixed *v2); +typedef void (APIENTRYP PFNGLTEXCOORD1XOESPROC) (GLfixed s); +typedef void (APIENTRYP PFNGLTEXCOORD1XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLTEXCOORD2XOESPROC) (GLfixed s, GLfixed t); +typedef void (APIENTRYP PFNGLTEXCOORD2XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLTEXCOORD3XOESPROC) (GLfixed s, GLfixed t, GLfixed r); +typedef void (APIENTRYP PFNGLTEXCOORD3XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLTEXCOORD4XOESPROC) (GLfixed s, GLfixed t, GLfixed r, GLfixed q); +typedef void (APIENTRYP PFNGLTEXCOORD4XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLTEXGENXOESPROC) (GLenum coord, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLTEXGENXVOESPROC) (GLenum coord, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLVERTEX2XOESPROC) (GLfixed x); +typedef void (APIENTRYP PFNGLVERTEX2XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLVERTEX3XOESPROC) (GLfixed x, GLfixed y); +typedef void (APIENTRYP PFNGLVERTEX3XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLVERTEX4XOESPROC) (GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLVERTEX4XVOESPROC) (const GLfixed *coords); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glAlphaFuncxOES (GLenum func, GLfixed ref); +GLAPI void APIENTRY glClearColorxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +GLAPI void APIENTRY glClearDepthxOES (GLfixed depth); +GLAPI void APIENTRY glClipPlanexOES (GLenum plane, const GLfixed *equation); +GLAPI void APIENTRY glColor4xOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +GLAPI void APIENTRY glDepthRangexOES (GLfixed n, GLfixed f); +GLAPI void APIENTRY glFogxOES (GLenum pname, GLfixed param); +GLAPI void APIENTRY glFogxvOES (GLenum pname, const GLfixed *param); +GLAPI void APIENTRY glFrustumxOES (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); +GLAPI void APIENTRY glGetClipPlanexOES (GLenum plane, GLfixed *equation); +GLAPI void APIENTRY glGetFixedvOES (GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetTexEnvxvOES (GLenum target, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetTexParameterxvOES (GLenum target, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glLightModelxOES (GLenum pname, GLfixed param); +GLAPI void APIENTRY glLightModelxvOES (GLenum pname, const GLfixed *param); +GLAPI void APIENTRY glLightxOES (GLenum light, GLenum pname, GLfixed param); +GLAPI void APIENTRY glLightxvOES (GLenum light, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glLineWidthxOES (GLfixed width); +GLAPI void APIENTRY glLoadMatrixxOES (const GLfixed *m); +GLAPI void APIENTRY glMaterialxOES (GLenum face, GLenum pname, GLfixed param); +GLAPI void APIENTRY glMaterialxvOES (GLenum face, GLenum pname, const GLfixed *param); +GLAPI void APIENTRY glMultMatrixxOES (const GLfixed *m); +GLAPI void APIENTRY glMultiTexCoord4xOES (GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q); +GLAPI void APIENTRY glNormal3xOES (GLfixed nx, GLfixed ny, GLfixed nz); +GLAPI void APIENTRY glOrthoxOES (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); +GLAPI void APIENTRY glPointParameterxvOES (GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glPointSizexOES (GLfixed size); +GLAPI void APIENTRY glPolygonOffsetxOES (GLfixed factor, GLfixed units); +GLAPI void APIENTRY glRotatexOES (GLfixed angle, GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glScalexOES (GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glTexEnvxOES (GLenum target, GLenum pname, GLfixed param); +GLAPI void APIENTRY glTexEnvxvOES (GLenum target, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glTexParameterxOES (GLenum target, GLenum pname, GLfixed param); +GLAPI void APIENTRY glTexParameterxvOES (GLenum target, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glTranslatexOES (GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glAccumxOES (GLenum op, GLfixed value); +GLAPI void APIENTRY glBitmapxOES (GLsizei width, GLsizei height, GLfixed xorig, GLfixed yorig, GLfixed xmove, GLfixed ymove, const GLubyte *bitmap); +GLAPI void APIENTRY glBlendColorxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +GLAPI void APIENTRY glClearAccumxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +GLAPI void APIENTRY glColor3xOES (GLfixed red, GLfixed green, GLfixed blue); +GLAPI void APIENTRY glColor3xvOES (const GLfixed *components); +GLAPI void APIENTRY glColor4xvOES (const GLfixed *components); +GLAPI void APIENTRY glConvolutionParameterxOES (GLenum target, GLenum pname, GLfixed param); +GLAPI void APIENTRY glConvolutionParameterxvOES (GLenum target, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glEvalCoord1xOES (GLfixed u); +GLAPI void APIENTRY glEvalCoord1xvOES (const GLfixed *coords); +GLAPI void APIENTRY glEvalCoord2xOES (GLfixed u, GLfixed v); +GLAPI void APIENTRY glEvalCoord2xvOES (const GLfixed *coords); +GLAPI void APIENTRY glFeedbackBufferxOES (GLsizei n, GLenum type, const GLfixed *buffer); +GLAPI void APIENTRY glGetConvolutionParameterxvOES (GLenum target, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetHistogramParameterxvOES (GLenum target, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetLightxOES (GLenum light, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetMapxvOES (GLenum target, GLenum query, GLfixed *v); +GLAPI void APIENTRY glGetMaterialxOES (GLenum face, GLenum pname, GLfixed param); +GLAPI void APIENTRY glGetPixelMapxv (GLenum map, GLint size, GLfixed *values); +GLAPI void APIENTRY glGetTexGenxvOES (GLenum coord, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetTexLevelParameterxvOES (GLenum target, GLint level, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glIndexxOES (GLfixed component); +GLAPI void APIENTRY glIndexxvOES (const GLfixed *component); +GLAPI void APIENTRY glLoadTransposeMatrixxOES (const GLfixed *m); +GLAPI void APIENTRY glMap1xOES (GLenum target, GLfixed u1, GLfixed u2, GLint stride, GLint order, GLfixed points); +GLAPI void APIENTRY glMap2xOES (GLenum target, GLfixed u1, GLfixed u2, GLint ustride, GLint uorder, GLfixed v1, GLfixed v2, GLint vstride, GLint vorder, GLfixed points); +GLAPI void APIENTRY glMapGrid1xOES (GLint n, GLfixed u1, GLfixed u2); +GLAPI void APIENTRY glMapGrid2xOES (GLint n, GLfixed u1, GLfixed u2, GLfixed v1, GLfixed v2); +GLAPI void APIENTRY glMultTransposeMatrixxOES (const GLfixed *m); +GLAPI void APIENTRY glMultiTexCoord1xOES (GLenum texture, GLfixed s); +GLAPI void APIENTRY glMultiTexCoord1xvOES (GLenum texture, const GLfixed *coords); +GLAPI void APIENTRY glMultiTexCoord2xOES (GLenum texture, GLfixed s, GLfixed t); +GLAPI void APIENTRY glMultiTexCoord2xvOES (GLenum texture, const GLfixed *coords); +GLAPI void APIENTRY glMultiTexCoord3xOES (GLenum texture, GLfixed s, GLfixed t, GLfixed r); +GLAPI void APIENTRY glMultiTexCoord3xvOES (GLenum texture, const GLfixed *coords); +GLAPI void APIENTRY glMultiTexCoord4xvOES (GLenum texture, const GLfixed *coords); +GLAPI void APIENTRY glNormal3xvOES (const GLfixed *coords); +GLAPI void APIENTRY glPassThroughxOES (GLfixed token); +GLAPI void APIENTRY glPixelMapx (GLenum map, GLint size, const GLfixed *values); +GLAPI void APIENTRY glPixelStorex (GLenum pname, GLfixed param); +GLAPI void APIENTRY glPixelTransferxOES (GLenum pname, GLfixed param); +GLAPI void APIENTRY glPixelZoomxOES (GLfixed xfactor, GLfixed yfactor); +GLAPI void APIENTRY glPrioritizeTexturesxOES (GLsizei n, const GLuint *textures, const GLfixed *priorities); +GLAPI void APIENTRY glRasterPos2xOES (GLfixed x, GLfixed y); +GLAPI void APIENTRY glRasterPos2xvOES (const GLfixed *coords); +GLAPI void APIENTRY glRasterPos3xOES (GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glRasterPos3xvOES (const GLfixed *coords); +GLAPI void APIENTRY glRasterPos4xOES (GLfixed x, GLfixed y, GLfixed z, GLfixed w); +GLAPI void APIENTRY glRasterPos4xvOES (const GLfixed *coords); +GLAPI void APIENTRY glRectxOES (GLfixed x1, GLfixed y1, GLfixed x2, GLfixed y2); +GLAPI void APIENTRY glRectxvOES (const GLfixed *v1, const GLfixed *v2); +GLAPI void APIENTRY glTexCoord1xOES (GLfixed s); +GLAPI void APIENTRY glTexCoord1xvOES (const GLfixed *coords); +GLAPI void APIENTRY glTexCoord2xOES (GLfixed s, GLfixed t); +GLAPI void APIENTRY glTexCoord2xvOES (const GLfixed *coords); +GLAPI void APIENTRY glTexCoord3xOES (GLfixed s, GLfixed t, GLfixed r); +GLAPI void APIENTRY glTexCoord3xvOES (const GLfixed *coords); +GLAPI void APIENTRY glTexCoord4xOES (GLfixed s, GLfixed t, GLfixed r, GLfixed q); +GLAPI void APIENTRY glTexCoord4xvOES (const GLfixed *coords); +GLAPI void APIENTRY glTexGenxOES (GLenum coord, GLenum pname, GLfixed param); +GLAPI void APIENTRY glTexGenxvOES (GLenum coord, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glVertex2xOES (GLfixed x); +GLAPI void APIENTRY glVertex2xvOES (const GLfixed *coords); +GLAPI void APIENTRY glVertex3xOES (GLfixed x, GLfixed y); +GLAPI void APIENTRY glVertex3xvOES (const GLfixed *coords); +GLAPI void APIENTRY glVertex4xOES (GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glVertex4xvOES (const GLfixed *coords); +#endif +#endif /* GL_OES_fixed_point */ + +#ifndef GL_OES_query_matrix +#define GL_OES_query_matrix 1 +typedef GLbitfield (APIENTRYP PFNGLQUERYMATRIXXOESPROC) (GLfixed *mantissa, GLint *exponent); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLbitfield APIENTRY glQueryMatrixxOES (GLfixed *mantissa, GLint *exponent); +#endif +#endif /* GL_OES_query_matrix */ + +#ifndef GL_OES_read_format +#define GL_OES_read_format 1 +#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B +#endif /* GL_OES_read_format */ + +#ifndef GL_OES_single_precision +#define GL_OES_single_precision 1 +typedef void (APIENTRYP PFNGLCLEARDEPTHFOESPROC) (GLclampf depth); +typedef void (APIENTRYP PFNGLCLIPPLANEFOESPROC) (GLenum plane, const GLfloat *equation); +typedef void (APIENTRYP PFNGLDEPTHRANGEFOESPROC) (GLclampf n, GLclampf f); +typedef void (APIENTRYP PFNGLFRUSTUMFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); +typedef void (APIENTRYP PFNGLGETCLIPPLANEFOESPROC) (GLenum plane, GLfloat *equation); +typedef void (APIENTRYP PFNGLORTHOFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClearDepthfOES (GLclampf depth); +GLAPI void APIENTRY glClipPlanefOES (GLenum plane, const GLfloat *equation); +GLAPI void APIENTRY glDepthRangefOES (GLclampf n, GLclampf f); +GLAPI void APIENTRY glFrustumfOES (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); +GLAPI void APIENTRY glGetClipPlanefOES (GLenum plane, GLfloat *equation); +GLAPI void APIENTRY glOrthofOES (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); +#endif +#endif /* GL_OES_single_precision */ + +#ifndef GL_3DFX_multisample +#define GL_3DFX_multisample 1 +#define GL_MULTISAMPLE_3DFX 0x86B2 +#define GL_SAMPLE_BUFFERS_3DFX 0x86B3 +#define GL_SAMPLES_3DFX 0x86B4 +#define GL_MULTISAMPLE_BIT_3DFX 0x20000000 +#endif /* GL_3DFX_multisample */ + +#ifndef GL_3DFX_tbuffer +#define GL_3DFX_tbuffer 1 +typedef void (APIENTRYP PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTbufferMask3DFX (GLuint mask); +#endif +#endif /* GL_3DFX_tbuffer */ + +#ifndef GL_3DFX_texture_compression_FXT1 +#define GL_3DFX_texture_compression_FXT1 1 +#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 +#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 +#endif /* GL_3DFX_texture_compression_FXT1 */ + +#ifndef GL_AMD_blend_minmax_factor +#define GL_AMD_blend_minmax_factor 1 +#define GL_FACTOR_MIN_AMD 0x901C +#define GL_FACTOR_MAX_AMD 0x901D +#endif /* GL_AMD_blend_minmax_factor */ + +#ifndef GL_AMD_conservative_depth +#define GL_AMD_conservative_depth 1 +#endif /* GL_AMD_conservative_depth */ + +#ifndef GL_AMD_debug_output +#define GL_AMD_debug_output 1 +typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,void *userParam); +#define GL_MAX_DEBUG_MESSAGE_LENGTH_AMD 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES_AMD 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES_AMD 0x9145 +#define GL_DEBUG_SEVERITY_HIGH_AMD 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM_AMD 0x9147 +#define GL_DEBUG_SEVERITY_LOW_AMD 0x9148 +#define GL_DEBUG_CATEGORY_API_ERROR_AMD 0x9149 +#define GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD 0x914A +#define GL_DEBUG_CATEGORY_DEPRECATION_AMD 0x914B +#define GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD 0x914C +#define GL_DEBUG_CATEGORY_PERFORMANCE_AMD 0x914D +#define GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD 0x914E +#define GL_DEBUG_CATEGORY_APPLICATION_AMD 0x914F +#define GL_DEBUG_CATEGORY_OTHER_AMD 0x9150 +typedef void (APIENTRYP PFNGLDEBUGMESSAGEENABLEAMDPROC) (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTAMDPROC) (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKAMDPROC) (GLDEBUGPROCAMD callback, void *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGAMDPROC) (GLuint count, GLsizei bufSize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDebugMessageEnableAMD (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsertAMD (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallbackAMD (GLDEBUGPROCAMD callback, void *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLogAMD (GLuint count, GLsizei bufSize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); +#endif +#endif /* GL_AMD_debug_output */ + +#ifndef GL_AMD_depth_clamp_separate +#define GL_AMD_depth_clamp_separate 1 +#define GL_DEPTH_CLAMP_NEAR_AMD 0x901E +#define GL_DEPTH_CLAMP_FAR_AMD 0x901F +#endif /* GL_AMD_depth_clamp_separate */ + +#ifndef GL_AMD_draw_buffers_blend +#define GL_AMD_draw_buffers_blend 1 +typedef void (APIENTRYP PFNGLBLENDFUNCINDEXEDAMDPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +typedef void (APIENTRYP PFNGLBLENDEQUATIONINDEXEDAMDPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncIndexedAMD (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparateIndexedAMD (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +GLAPI void APIENTRY glBlendEquationIndexedAMD (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparateIndexedAMD (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +#endif +#endif /* GL_AMD_draw_buffers_blend */ + +#ifndef GL_AMD_framebuffer_multisample_advanced +#define GL_AMD_framebuffer_multisample_advanced 1 +#define GL_RENDERBUFFER_STORAGE_SAMPLES_AMD 0x91B2 +#define GL_MAX_COLOR_FRAMEBUFFER_SAMPLES_AMD 0x91B3 +#define GL_MAX_COLOR_FRAMEBUFFER_STORAGE_SAMPLES_AMD 0x91B4 +#define GL_MAX_DEPTH_STENCIL_FRAMEBUFFER_SAMPLES_AMD 0x91B5 +#define GL_NUM_SUPPORTED_MULTISAMPLE_MODES_AMD 0x91B6 +#define GL_SUPPORTED_MULTISAMPLE_MODES_AMD 0x91B7 +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEADVANCEDAMDPROC) (GLenum target, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEADVANCEDAMDPROC) (GLuint renderbuffer, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderbufferStorageMultisampleAdvancedAMD (GLenum target, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleAdvancedAMD (GLuint renderbuffer, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); +#endif +#endif /* GL_AMD_framebuffer_multisample_advanced */ + +#ifndef GL_AMD_framebuffer_sample_positions +#define GL_AMD_framebuffer_sample_positions 1 +#define GL_SUBSAMPLE_DISTANCE_AMD 0x883F +#define GL_PIXELS_PER_SAMPLE_PATTERN_X_AMD 0x91AE +#define GL_PIXELS_PER_SAMPLE_PATTERN_Y_AMD 0x91AF +#define GL_ALL_PIXELS_AMD 0xFFFFFFFF +typedef void (APIENTRYP PFNGLFRAMEBUFFERSAMPLEPOSITIONSFVAMDPROC) (GLenum target, GLuint numsamples, GLuint pixelindex, const GLfloat *values); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERSAMPLEPOSITIONSFVAMDPROC) (GLuint framebuffer, GLuint numsamples, GLuint pixelindex, const GLfloat *values); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERFVAMDPROC) (GLenum target, GLenum pname, GLuint numsamples, GLuint pixelindex, GLsizei size, GLfloat *values); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERFVAMDPROC) (GLuint framebuffer, GLenum pname, GLuint numsamples, GLuint pixelindex, GLsizei size, GLfloat *values); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferSamplePositionsfvAMD (GLenum target, GLuint numsamples, GLuint pixelindex, const GLfloat *values); +GLAPI void APIENTRY glNamedFramebufferSamplePositionsfvAMD (GLuint framebuffer, GLuint numsamples, GLuint pixelindex, const GLfloat *values); +GLAPI void APIENTRY glGetFramebufferParameterfvAMD (GLenum target, GLenum pname, GLuint numsamples, GLuint pixelindex, GLsizei size, GLfloat *values); +GLAPI void APIENTRY glGetNamedFramebufferParameterfvAMD (GLuint framebuffer, GLenum pname, GLuint numsamples, GLuint pixelindex, GLsizei size, GLfloat *values); +#endif +#endif /* GL_AMD_framebuffer_sample_positions */ + +#ifndef GL_AMD_gcn_shader +#define GL_AMD_gcn_shader 1 +#endif /* GL_AMD_gcn_shader */ + +#ifndef GL_AMD_gpu_shader_half_float +#define GL_AMD_gpu_shader_half_float 1 +#define GL_FLOAT16_NV 0x8FF8 +#define GL_FLOAT16_VEC2_NV 0x8FF9 +#define GL_FLOAT16_VEC3_NV 0x8FFA +#define GL_FLOAT16_VEC4_NV 0x8FFB +#define GL_FLOAT16_MAT2_AMD 0x91C5 +#define GL_FLOAT16_MAT3_AMD 0x91C6 +#define GL_FLOAT16_MAT4_AMD 0x91C7 +#define GL_FLOAT16_MAT2x3_AMD 0x91C8 +#define GL_FLOAT16_MAT2x4_AMD 0x91C9 +#define GL_FLOAT16_MAT3x2_AMD 0x91CA +#define GL_FLOAT16_MAT3x4_AMD 0x91CB +#define GL_FLOAT16_MAT4x2_AMD 0x91CC +#define GL_FLOAT16_MAT4x3_AMD 0x91CD +#endif /* GL_AMD_gpu_shader_half_float */ + +#ifndef GL_AMD_gpu_shader_int16 +#define GL_AMD_gpu_shader_int16 1 +#endif /* GL_AMD_gpu_shader_int16 */ + +#ifndef GL_AMD_gpu_shader_int64 +#define GL_AMD_gpu_shader_int64 1 +typedef khronos_int64_t GLint64EXT; +#define GL_INT64_NV 0x140E +#define GL_UNSIGNED_INT64_NV 0x140F +#define GL_INT8_NV 0x8FE0 +#define GL_INT8_VEC2_NV 0x8FE1 +#define GL_INT8_VEC3_NV 0x8FE2 +#define GL_INT8_VEC4_NV 0x8FE3 +#define GL_INT16_NV 0x8FE4 +#define GL_INT16_VEC2_NV 0x8FE5 +#define GL_INT16_VEC3_NV 0x8FE6 +#define GL_INT16_VEC4_NV 0x8FE7 +#define GL_INT64_VEC2_NV 0x8FE9 +#define GL_INT64_VEC3_NV 0x8FEA +#define GL_INT64_VEC4_NV 0x8FEB +#define GL_UNSIGNED_INT8_NV 0x8FEC +#define GL_UNSIGNED_INT8_VEC2_NV 0x8FED +#define GL_UNSIGNED_INT8_VEC3_NV 0x8FEE +#define GL_UNSIGNED_INT8_VEC4_NV 0x8FEF +#define GL_UNSIGNED_INT16_NV 0x8FF0 +#define GL_UNSIGNED_INT16_VEC2_NV 0x8FF1 +#define GL_UNSIGNED_INT16_VEC3_NV 0x8FF2 +#define GL_UNSIGNED_INT16_VEC4_NV 0x8FF3 +#define GL_UNSIGNED_INT64_VEC2_NV 0x8FF5 +#define GL_UNSIGNED_INT64_VEC3_NV 0x8FF6 +#define GL_UNSIGNED_INT64_VEC4_NV 0x8FF7 +typedef void (APIENTRYP PFNGLUNIFORM1I64NVPROC) (GLint location, GLint64EXT x); +typedef void (APIENTRYP PFNGLUNIFORM2I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLUNIFORM3I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLUNIFORM4I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLUNIFORM1I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM2I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM3I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM4I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM1UI64NVPROC) (GLint location, GLuint64EXT x); +typedef void (APIENTRYP PFNGLUNIFORM2UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLUNIFORM3UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLUNIFORM4UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLUNIFORM1UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM2UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM3UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM4UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLGETUNIFORMI64VNVPROC) (GLuint program, GLint location, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64NVPROC) (GLuint program, GLint location, GLint64EXT x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniform1i64NV (GLint location, GLint64EXT x); +GLAPI void APIENTRY glUniform2i64NV (GLint location, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glUniform3i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glUniform4i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glUniform1i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform2i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform3i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform4i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform1ui64NV (GLint location, GLuint64EXT x); +GLAPI void APIENTRY glUniform2ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glUniform3ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glUniform4ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glUniform1ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform2ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform3ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform4ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glGetUniformi64vNV (GLuint program, GLint location, GLint64EXT *params); +GLAPI void APIENTRY glGetUniformui64vNV (GLuint program, GLint location, GLuint64EXT *params); +GLAPI void APIENTRY glProgramUniform1i64NV (GLuint program, GLint location, GLint64EXT x); +GLAPI void APIENTRY glProgramUniform2i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glProgramUniform3i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glProgramUniform4i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glProgramUniform1i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform2i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform3i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform4i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform1ui64NV (GLuint program, GLint location, GLuint64EXT x); +GLAPI void APIENTRY glProgramUniform2ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glProgramUniform3ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glProgramUniform4ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glProgramUniform1ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform2ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform3ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform4ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif +#endif /* GL_AMD_gpu_shader_int64 */ + +#ifndef GL_AMD_interleaved_elements +#define GL_AMD_interleaved_elements 1 +#define GL_VERTEX_ELEMENT_SWIZZLE_AMD 0x91A4 +#define GL_VERTEX_ID_SWIZZLE_AMD 0x91A5 +typedef void (APIENTRYP PFNGLVERTEXATTRIBPARAMETERIAMDPROC) (GLuint index, GLenum pname, GLint param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribParameteriAMD (GLuint index, GLenum pname, GLint param); +#endif +#endif /* GL_AMD_interleaved_elements */ + +#ifndef GL_AMD_multi_draw_indirect +#define GL_AMD_multi_draw_indirect 1 +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTAMDPROC) (GLenum mode, const void *indirect, GLsizei primcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTAMDPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei primcount, GLsizei stride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysIndirectAMD (GLenum mode, const void *indirect, GLsizei primcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirectAMD (GLenum mode, GLenum type, const void *indirect, GLsizei primcount, GLsizei stride); +#endif +#endif /* GL_AMD_multi_draw_indirect */ + +#ifndef GL_AMD_name_gen_delete +#define GL_AMD_name_gen_delete 1 +#define GL_DATA_BUFFER_AMD 0x9151 +#define GL_PERFORMANCE_MONITOR_AMD 0x9152 +#define GL_QUERY_OBJECT_AMD 0x9153 +#define GL_VERTEX_ARRAY_OBJECT_AMD 0x9154 +#define GL_SAMPLER_OBJECT_AMD 0x9155 +typedef void (APIENTRYP PFNGLGENNAMESAMDPROC) (GLenum identifier, GLuint num, GLuint *names); +typedef void (APIENTRYP PFNGLDELETENAMESAMDPROC) (GLenum identifier, GLuint num, const GLuint *names); +typedef GLboolean (APIENTRYP PFNGLISNAMEAMDPROC) (GLenum identifier, GLuint name); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenNamesAMD (GLenum identifier, GLuint num, GLuint *names); +GLAPI void APIENTRY glDeleteNamesAMD (GLenum identifier, GLuint num, const GLuint *names); +GLAPI GLboolean APIENTRY glIsNameAMD (GLenum identifier, GLuint name); +#endif +#endif /* GL_AMD_name_gen_delete */ + +#ifndef GL_AMD_occlusion_query_event +#define GL_AMD_occlusion_query_event 1 +#define GL_OCCLUSION_QUERY_EVENT_MASK_AMD 0x874F +#define GL_QUERY_DEPTH_PASS_EVENT_BIT_AMD 0x00000001 +#define GL_QUERY_DEPTH_FAIL_EVENT_BIT_AMD 0x00000002 +#define GL_QUERY_STENCIL_FAIL_EVENT_BIT_AMD 0x00000004 +#define GL_QUERY_DEPTH_BOUNDS_FAIL_EVENT_BIT_AMD 0x00000008 +#define GL_QUERY_ALL_EVENT_BITS_AMD 0xFFFFFFFF +typedef void (APIENTRYP PFNGLQUERYOBJECTPARAMETERUIAMDPROC) (GLenum target, GLuint id, GLenum pname, GLuint param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glQueryObjectParameteruiAMD (GLenum target, GLuint id, GLenum pname, GLuint param); +#endif +#endif /* GL_AMD_occlusion_query_event */ + +#ifndef GL_AMD_performance_monitor +#define GL_AMD_performance_monitor 1 +#define GL_COUNTER_TYPE_AMD 0x8BC0 +#define GL_COUNTER_RANGE_AMD 0x8BC1 +#define GL_UNSIGNED_INT64_AMD 0x8BC2 +#define GL_PERCENTAGE_AMD 0x8BC3 +#define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4 +#define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5 +#define GL_PERFMON_RESULT_AMD 0x8BC6 +typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); +typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, void *data); +typedef void (APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); +typedef void (APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); +typedef void (APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); +typedef void (APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor); +typedef void (APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetPerfMonitorGroupsAMD (GLint *numGroups, GLsizei groupsSize, GLuint *groups); +GLAPI void APIENTRY glGetPerfMonitorCountersAMD (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); +GLAPI void APIENTRY glGetPerfMonitorGroupStringAMD (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); +GLAPI void APIENTRY glGetPerfMonitorCounterStringAMD (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); +GLAPI void APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, void *data); +GLAPI void APIENTRY glGenPerfMonitorsAMD (GLsizei n, GLuint *monitors); +GLAPI void APIENTRY glDeletePerfMonitorsAMD (GLsizei n, GLuint *monitors); +GLAPI void APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); +GLAPI void APIENTRY glBeginPerfMonitorAMD (GLuint monitor); +GLAPI void APIENTRY glEndPerfMonitorAMD (GLuint monitor); +GLAPI void APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); +#endif +#endif /* GL_AMD_performance_monitor */ + +#ifndef GL_AMD_pinned_memory +#define GL_AMD_pinned_memory 1 +#define GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD 0x9160 +#endif /* GL_AMD_pinned_memory */ + +#ifndef GL_AMD_query_buffer_object +#define GL_AMD_query_buffer_object 1 +#define GL_QUERY_BUFFER_AMD 0x9192 +#define GL_QUERY_BUFFER_BINDING_AMD 0x9193 +#define GL_QUERY_RESULT_NO_WAIT_AMD 0x9194 +#endif /* GL_AMD_query_buffer_object */ + +#ifndef GL_AMD_sample_positions +#define GL_AMD_sample_positions 1 +typedef void (APIENTRYP PFNGLSETMULTISAMPLEFVAMDPROC) (GLenum pname, GLuint index, const GLfloat *val); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSetMultisamplefvAMD (GLenum pname, GLuint index, const GLfloat *val); +#endif +#endif /* GL_AMD_sample_positions */ + +#ifndef GL_AMD_seamless_cubemap_per_texture +#define GL_AMD_seamless_cubemap_per_texture 1 +#endif /* GL_AMD_seamless_cubemap_per_texture */ + +#ifndef GL_AMD_shader_atomic_counter_ops +#define GL_AMD_shader_atomic_counter_ops 1 +#endif /* GL_AMD_shader_atomic_counter_ops */ + +#ifndef GL_AMD_shader_ballot +#define GL_AMD_shader_ballot 1 +#endif /* GL_AMD_shader_ballot */ + +#ifndef GL_AMD_shader_explicit_vertex_parameter +#define GL_AMD_shader_explicit_vertex_parameter 1 +#endif /* GL_AMD_shader_explicit_vertex_parameter */ + +#ifndef GL_AMD_shader_gpu_shader_half_float_fetch +#define GL_AMD_shader_gpu_shader_half_float_fetch 1 +#endif /* GL_AMD_shader_gpu_shader_half_float_fetch */ + +#ifndef GL_AMD_shader_image_load_store_lod +#define GL_AMD_shader_image_load_store_lod 1 +#endif /* GL_AMD_shader_image_load_store_lod */ + +#ifndef GL_AMD_shader_stencil_export +#define GL_AMD_shader_stencil_export 1 +#endif /* GL_AMD_shader_stencil_export */ + +#ifndef GL_AMD_shader_trinary_minmax +#define GL_AMD_shader_trinary_minmax 1 +#endif /* GL_AMD_shader_trinary_minmax */ + +#ifndef GL_AMD_sparse_texture +#define GL_AMD_sparse_texture 1 +#define GL_VIRTUAL_PAGE_SIZE_X_AMD 0x9195 +#define GL_VIRTUAL_PAGE_SIZE_Y_AMD 0x9196 +#define GL_VIRTUAL_PAGE_SIZE_Z_AMD 0x9197 +#define GL_MAX_SPARSE_TEXTURE_SIZE_AMD 0x9198 +#define GL_MAX_SPARSE_3D_TEXTURE_SIZE_AMD 0x9199 +#define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS 0x919A +#define GL_MIN_SPARSE_LEVEL_AMD 0x919B +#define GL_MIN_LOD_WARNING_AMD 0x919C +#define GL_TEXTURE_STORAGE_SPARSE_BIT_AMD 0x00000001 +typedef void (APIENTRYP PFNGLTEXSTORAGESPARSEAMDPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +typedef void (APIENTRYP PFNGLTEXTURESTORAGESPARSEAMDPROC) (GLuint texture, GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexStorageSparseAMD (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +GLAPI void APIENTRY glTextureStorageSparseAMD (GLuint texture, GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +#endif +#endif /* GL_AMD_sparse_texture */ + +#ifndef GL_AMD_stencil_operation_extended +#define GL_AMD_stencil_operation_extended 1 +#define GL_SET_AMD 0x874A +#define GL_REPLACE_VALUE_AMD 0x874B +#define GL_STENCIL_OP_VALUE_AMD 0x874C +#define GL_STENCIL_BACK_OP_VALUE_AMD 0x874D +typedef void (APIENTRYP PFNGLSTENCILOPVALUEAMDPROC) (GLenum face, GLuint value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilOpValueAMD (GLenum face, GLuint value); +#endif +#endif /* GL_AMD_stencil_operation_extended */ + +#ifndef GL_AMD_texture_gather_bias_lod +#define GL_AMD_texture_gather_bias_lod 1 +#endif /* GL_AMD_texture_gather_bias_lod */ + +#ifndef GL_AMD_texture_texture4 +#define GL_AMD_texture_texture4 1 +#endif /* GL_AMD_texture_texture4 */ + +#ifndef GL_AMD_transform_feedback3_lines_triangles +#define GL_AMD_transform_feedback3_lines_triangles 1 +#endif /* GL_AMD_transform_feedback3_lines_triangles */ + +#ifndef GL_AMD_transform_feedback4 +#define GL_AMD_transform_feedback4 1 +#define GL_STREAM_RASTERIZATION_AMD 0x91A0 +#endif /* GL_AMD_transform_feedback4 */ + +#ifndef GL_AMD_vertex_shader_layer +#define GL_AMD_vertex_shader_layer 1 +#endif /* GL_AMD_vertex_shader_layer */ + +#ifndef GL_AMD_vertex_shader_tessellator +#define GL_AMD_vertex_shader_tessellator 1 +#define GL_SAMPLER_BUFFER_AMD 0x9001 +#define GL_INT_SAMPLER_BUFFER_AMD 0x9002 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER_AMD 0x9003 +#define GL_TESSELLATION_MODE_AMD 0x9004 +#define GL_TESSELLATION_FACTOR_AMD 0x9005 +#define GL_DISCRETE_AMD 0x9006 +#define GL_CONTINUOUS_AMD 0x9007 +typedef void (APIENTRYP PFNGLTESSELLATIONFACTORAMDPROC) (GLfloat factor); +typedef void (APIENTRYP PFNGLTESSELLATIONMODEAMDPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTessellationFactorAMD (GLfloat factor); +GLAPI void APIENTRY glTessellationModeAMD (GLenum mode); +#endif +#endif /* GL_AMD_vertex_shader_tessellator */ + +#ifndef GL_AMD_vertex_shader_viewport_index +#define GL_AMD_vertex_shader_viewport_index 1 +#endif /* GL_AMD_vertex_shader_viewport_index */ + +#ifndef GL_APPLE_aux_depth_stencil +#define GL_APPLE_aux_depth_stencil 1 +#define GL_AUX_DEPTH_STENCIL_APPLE 0x8A14 +#endif /* GL_APPLE_aux_depth_stencil */ + +#ifndef GL_APPLE_client_storage +#define GL_APPLE_client_storage 1 +#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 +#endif /* GL_APPLE_client_storage */ + +#ifndef GL_APPLE_element_array +#define GL_APPLE_element_array 1 +#define GL_ELEMENT_ARRAY_APPLE 0x8A0C +#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8A0D +#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x8A0E +typedef void (APIENTRYP PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const void *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glElementPointerAPPLE (GLenum type, const void *pointer); +GLAPI void APIENTRY glDrawElementArrayAPPLE (GLenum mode, GLint first, GLsizei count); +GLAPI void APIENTRY glDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); +GLAPI void APIENTRY glMultiDrawElementArrayAPPLE (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +GLAPI void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); +#endif +#endif /* GL_APPLE_element_array */ + +#ifndef GL_APPLE_fence +#define GL_APPLE_fence 1 +#define GL_DRAW_PIXELS_APPLE 0x8A0A +#define GL_FENCE_APPLE 0x8A0B +typedef void (APIENTRYP PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences); +typedef void (APIENTRYP PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLSETFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLISFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCEAPPLEPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); +typedef void (APIENTRYP PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenFencesAPPLE (GLsizei n, GLuint *fences); +GLAPI void APIENTRY glDeleteFencesAPPLE (GLsizei n, const GLuint *fences); +GLAPI void APIENTRY glSetFenceAPPLE (GLuint fence); +GLAPI GLboolean APIENTRY glIsFenceAPPLE (GLuint fence); +GLAPI GLboolean APIENTRY glTestFenceAPPLE (GLuint fence); +GLAPI void APIENTRY glFinishFenceAPPLE (GLuint fence); +GLAPI GLboolean APIENTRY glTestObjectAPPLE (GLenum object, GLuint name); +GLAPI void APIENTRY glFinishObjectAPPLE (GLenum object, GLint name); +#endif +#endif /* GL_APPLE_fence */ + +#ifndef GL_APPLE_float_pixels +#define GL_APPLE_float_pixels 1 +#define GL_HALF_APPLE 0x140B +#define GL_RGBA_FLOAT32_APPLE 0x8814 +#define GL_RGB_FLOAT32_APPLE 0x8815 +#define GL_ALPHA_FLOAT32_APPLE 0x8816 +#define GL_INTENSITY_FLOAT32_APPLE 0x8817 +#define GL_LUMINANCE_FLOAT32_APPLE 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_APPLE 0x8819 +#define GL_RGBA_FLOAT16_APPLE 0x881A +#define GL_RGB_FLOAT16_APPLE 0x881B +#define GL_ALPHA_FLOAT16_APPLE 0x881C +#define GL_INTENSITY_FLOAT16_APPLE 0x881D +#define GL_LUMINANCE_FLOAT16_APPLE 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_APPLE 0x881F +#define GL_COLOR_FLOAT_APPLE 0x8A0F +#endif /* GL_APPLE_float_pixels */ + +#ifndef GL_APPLE_flush_buffer_range +#define GL_APPLE_flush_buffer_range 1 +#define GL_BUFFER_SERIALIZED_MODIFY_APPLE 0x8A12 +#define GL_BUFFER_FLUSHING_UNMAP_APPLE 0x8A13 +typedef void (APIENTRYP PFNGLBUFFERPARAMETERIAPPLEPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC) (GLenum target, GLintptr offset, GLsizeiptr size); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferParameteriAPPLE (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glFlushMappedBufferRangeAPPLE (GLenum target, GLintptr offset, GLsizeiptr size); +#endif +#endif /* GL_APPLE_flush_buffer_range */ + +#ifndef GL_APPLE_object_purgeable +#define GL_APPLE_object_purgeable 1 +#define GL_BUFFER_OBJECT_APPLE 0x85B3 +#define GL_RELEASED_APPLE 0x8A19 +#define GL_VOLATILE_APPLE 0x8A1A +#define GL_RETAINED_APPLE 0x8A1B +#define GL_UNDEFINED_APPLE 0x8A1C +#define GL_PURGEABLE_APPLE 0x8A1D +typedef GLenum (APIENTRYP PFNGLOBJECTPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); +typedef GLenum (APIENTRYP PFNGLOBJECTUNPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVAPPLEPROC) (GLenum objectType, GLuint name, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLenum APIENTRY glObjectPurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); +GLAPI GLenum APIENTRY glObjectUnpurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); +GLAPI void APIENTRY glGetObjectParameterivAPPLE (GLenum objectType, GLuint name, GLenum pname, GLint *params); +#endif +#endif /* GL_APPLE_object_purgeable */ + +#ifndef GL_APPLE_rgb_422 +#define GL_APPLE_rgb_422 1 +#define GL_RGB_422_APPLE 0x8A1F +#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB +#define GL_RGB_RAW_422_APPLE 0x8A51 +#endif /* GL_APPLE_rgb_422 */ + +#ifndef GL_APPLE_row_bytes +#define GL_APPLE_row_bytes 1 +#define GL_PACK_ROW_BYTES_APPLE 0x8A15 +#define GL_UNPACK_ROW_BYTES_APPLE 0x8A16 +#endif /* GL_APPLE_row_bytes */ + +#ifndef GL_APPLE_specular_vector +#define GL_APPLE_specular_vector 1 +#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 +#endif /* GL_APPLE_specular_vector */ + +#ifndef GL_APPLE_texture_range +#define GL_APPLE_texture_range 1 +#define GL_TEXTURE_RANGE_LENGTH_APPLE 0x85B7 +#define GL_TEXTURE_RANGE_POINTER_APPLE 0x85B8 +#define GL_TEXTURE_STORAGE_HINT_APPLE 0x85BC +#define GL_STORAGE_PRIVATE_APPLE 0x85BD +#define GL_STORAGE_CACHED_APPLE 0x85BE +#define GL_STORAGE_SHARED_APPLE 0x85BF +typedef void (APIENTRYP PFNGLTEXTURERANGEAPPLEPROC) (GLenum target, GLsizei length, const void *pointer); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC) (GLenum target, GLenum pname, void **params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureRangeAPPLE (GLenum target, GLsizei length, const void *pointer); +GLAPI void APIENTRY glGetTexParameterPointervAPPLE (GLenum target, GLenum pname, void **params); +#endif +#endif /* GL_APPLE_texture_range */ + +#ifndef GL_APPLE_transform_hint +#define GL_APPLE_transform_hint 1 +#define GL_TRANSFORM_HINT_APPLE 0x85B1 +#endif /* GL_APPLE_transform_hint */ + +#ifndef GL_APPLE_vertex_array_object +#define GL_APPLE_vertex_array_object 1 +#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 +typedef void (APIENTRYP PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); +typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); +typedef void (APIENTRYP PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindVertexArrayAPPLE (GLuint array); +GLAPI void APIENTRY glDeleteVertexArraysAPPLE (GLsizei n, const GLuint *arrays); +GLAPI void APIENTRY glGenVertexArraysAPPLE (GLsizei n, GLuint *arrays); +GLAPI GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint array); +#endif +#endif /* GL_APPLE_vertex_array_object */ + +#ifndef GL_APPLE_vertex_array_range +#define GL_APPLE_vertex_array_range 1 +#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E +#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F +#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 +#define GL_STORAGE_CLIENT_APPLE 0x85B4 +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void *pointer); +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void *pointer); +typedef void (APIENTRYP PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexArrayRangeAPPLE (GLsizei length, void *pointer); +GLAPI void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei length, void *pointer); +GLAPI void APIENTRY glVertexArrayParameteriAPPLE (GLenum pname, GLint param); +#endif +#endif /* GL_APPLE_vertex_array_range */ + +#ifndef GL_APPLE_vertex_program_evaluators +#define GL_APPLE_vertex_program_evaluators 1 +#define GL_VERTEX_ATTRIB_MAP1_APPLE 0x8A00 +#define GL_VERTEX_ATTRIB_MAP2_APPLE 0x8A01 +#define GL_VERTEX_ATTRIB_MAP1_SIZE_APPLE 0x8A02 +#define GL_VERTEX_ATTRIB_MAP1_COEFF_APPLE 0x8A03 +#define GL_VERTEX_ATTRIB_MAP1_ORDER_APPLE 0x8A04 +#define GL_VERTEX_ATTRIB_MAP1_DOMAIN_APPLE 0x8A05 +#define GL_VERTEX_ATTRIB_MAP2_SIZE_APPLE 0x8A06 +#define GL_VERTEX_ATTRIB_MAP2_COEFF_APPLE 0x8A07 +#define GL_VERTEX_ATTRIB_MAP2_ORDER_APPLE 0x8A08 +#define GL_VERTEX_ATTRIB_MAP2_DOMAIN_APPLE 0x8A09 +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); +typedef GLboolean (APIENTRYP PFNGLISVERTEXATTRIBENABLEDAPPLEPROC) (GLuint index, GLenum pname); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glEnableVertexAttribAPPLE (GLuint index, GLenum pname); +GLAPI void APIENTRY glDisableVertexAttribAPPLE (GLuint index, GLenum pname); +GLAPI GLboolean APIENTRY glIsVertexAttribEnabledAPPLE (GLuint index, GLenum pname); +GLAPI void APIENTRY glMapVertexAttrib1dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); +GLAPI void APIENTRY glMapVertexAttrib1fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); +GLAPI void APIENTRY glMapVertexAttrib2dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); +GLAPI void APIENTRY glMapVertexAttrib2fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); +#endif +#endif /* GL_APPLE_vertex_program_evaluators */ + +#ifndef GL_APPLE_ycbcr_422 +#define GL_APPLE_ycbcr_422 1 +#define GL_YCBCR_422_APPLE 0x85B9 +#endif /* GL_APPLE_ycbcr_422 */ + +#ifndef GL_ATI_draw_buffers +#define GL_ATI_draw_buffers 1 +#define GL_MAX_DRAW_BUFFERS_ATI 0x8824 +#define GL_DRAW_BUFFER0_ATI 0x8825 +#define GL_DRAW_BUFFER1_ATI 0x8826 +#define GL_DRAW_BUFFER2_ATI 0x8827 +#define GL_DRAW_BUFFER3_ATI 0x8828 +#define GL_DRAW_BUFFER4_ATI 0x8829 +#define GL_DRAW_BUFFER5_ATI 0x882A +#define GL_DRAW_BUFFER6_ATI 0x882B +#define GL_DRAW_BUFFER7_ATI 0x882C +#define GL_DRAW_BUFFER8_ATI 0x882D +#define GL_DRAW_BUFFER9_ATI 0x882E +#define GL_DRAW_BUFFER10_ATI 0x882F +#define GL_DRAW_BUFFER11_ATI 0x8830 +#define GL_DRAW_BUFFER12_ATI 0x8831 +#define GL_DRAW_BUFFER13_ATI 0x8832 +#define GL_DRAW_BUFFER14_ATI 0x8833 +#define GL_DRAW_BUFFER15_ATI 0x8834 +typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawBuffersATI (GLsizei n, const GLenum *bufs); +#endif +#endif /* GL_ATI_draw_buffers */ + +#ifndef GL_ATI_element_array +#define GL_ATI_element_array 1 +#define GL_ELEMENT_ARRAY_ATI 0x8768 +#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 +#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A +typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC) (GLenum type, const void *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glElementPointerATI (GLenum type, const void *pointer); +GLAPI void APIENTRY glDrawElementArrayATI (GLenum mode, GLsizei count); +GLAPI void APIENTRY glDrawRangeElementArrayATI (GLenum mode, GLuint start, GLuint end, GLsizei count); +#endif +#endif /* GL_ATI_element_array */ + +#ifndef GL_ATI_envmap_bumpmap +#define GL_ATI_envmap_bumpmap 1 +#define GL_BUMP_ROT_MATRIX_ATI 0x8775 +#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 +#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 +#define GL_BUMP_TEX_UNITS_ATI 0x8778 +#define GL_DUDV_ATI 0x8779 +#define GL_DU8DV8_ATI 0x877A +#define GL_BUMP_ENVMAP_ATI 0x877B +#define GL_BUMP_TARGET_ATI 0x877C +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBumpParameterivATI (GLenum pname, const GLint *param); +GLAPI void APIENTRY glTexBumpParameterfvATI (GLenum pname, const GLfloat *param); +GLAPI void APIENTRY glGetTexBumpParameterivATI (GLenum pname, GLint *param); +GLAPI void APIENTRY glGetTexBumpParameterfvATI (GLenum pname, GLfloat *param); +#endif +#endif /* GL_ATI_envmap_bumpmap */ + +#ifndef GL_ATI_fragment_shader +#define GL_ATI_fragment_shader 1 +#define GL_FRAGMENT_SHADER_ATI 0x8920 +#define GL_REG_0_ATI 0x8921 +#define GL_REG_1_ATI 0x8922 +#define GL_REG_2_ATI 0x8923 +#define GL_REG_3_ATI 0x8924 +#define GL_REG_4_ATI 0x8925 +#define GL_REG_5_ATI 0x8926 +#define GL_REG_6_ATI 0x8927 +#define GL_REG_7_ATI 0x8928 +#define GL_REG_8_ATI 0x8929 +#define GL_REG_9_ATI 0x892A +#define GL_REG_10_ATI 0x892B +#define GL_REG_11_ATI 0x892C +#define GL_REG_12_ATI 0x892D +#define GL_REG_13_ATI 0x892E +#define GL_REG_14_ATI 0x892F +#define GL_REG_15_ATI 0x8930 +#define GL_REG_16_ATI 0x8931 +#define GL_REG_17_ATI 0x8932 +#define GL_REG_18_ATI 0x8933 +#define GL_REG_19_ATI 0x8934 +#define GL_REG_20_ATI 0x8935 +#define GL_REG_21_ATI 0x8936 +#define GL_REG_22_ATI 0x8937 +#define GL_REG_23_ATI 0x8938 +#define GL_REG_24_ATI 0x8939 +#define GL_REG_25_ATI 0x893A +#define GL_REG_26_ATI 0x893B +#define GL_REG_27_ATI 0x893C +#define GL_REG_28_ATI 0x893D +#define GL_REG_29_ATI 0x893E +#define GL_REG_30_ATI 0x893F +#define GL_REG_31_ATI 0x8940 +#define GL_CON_0_ATI 0x8941 +#define GL_CON_1_ATI 0x8942 +#define GL_CON_2_ATI 0x8943 +#define GL_CON_3_ATI 0x8944 +#define GL_CON_4_ATI 0x8945 +#define GL_CON_5_ATI 0x8946 +#define GL_CON_6_ATI 0x8947 +#define GL_CON_7_ATI 0x8948 +#define GL_CON_8_ATI 0x8949 +#define GL_CON_9_ATI 0x894A +#define GL_CON_10_ATI 0x894B +#define GL_CON_11_ATI 0x894C +#define GL_CON_12_ATI 0x894D +#define GL_CON_13_ATI 0x894E +#define GL_CON_14_ATI 0x894F +#define GL_CON_15_ATI 0x8950 +#define GL_CON_16_ATI 0x8951 +#define GL_CON_17_ATI 0x8952 +#define GL_CON_18_ATI 0x8953 +#define GL_CON_19_ATI 0x8954 +#define GL_CON_20_ATI 0x8955 +#define GL_CON_21_ATI 0x8956 +#define GL_CON_22_ATI 0x8957 +#define GL_CON_23_ATI 0x8958 +#define GL_CON_24_ATI 0x8959 +#define GL_CON_25_ATI 0x895A +#define GL_CON_26_ATI 0x895B +#define GL_CON_27_ATI 0x895C +#define GL_CON_28_ATI 0x895D +#define GL_CON_29_ATI 0x895E +#define GL_CON_30_ATI 0x895F +#define GL_CON_31_ATI 0x8960 +#define GL_MOV_ATI 0x8961 +#define GL_ADD_ATI 0x8963 +#define GL_MUL_ATI 0x8964 +#define GL_SUB_ATI 0x8965 +#define GL_DOT3_ATI 0x8966 +#define GL_DOT4_ATI 0x8967 +#define GL_MAD_ATI 0x8968 +#define GL_LERP_ATI 0x8969 +#define GL_CND_ATI 0x896A +#define GL_CND0_ATI 0x896B +#define GL_DOT2_ADD_ATI 0x896C +#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D +#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E +#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F +#define GL_NUM_PASSES_ATI 0x8970 +#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 +#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 +#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 +#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 +#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 +#define GL_SWIZZLE_STR_ATI 0x8976 +#define GL_SWIZZLE_STQ_ATI 0x8977 +#define GL_SWIZZLE_STR_DR_ATI 0x8978 +#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 +#define GL_SWIZZLE_STRQ_ATI 0x897A +#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B +#define GL_RED_BIT_ATI 0x00000001 +#define GL_GREEN_BIT_ATI 0x00000002 +#define GL_BLUE_BIT_ATI 0x00000004 +#define GL_2X_BIT_ATI 0x00000001 +#define GL_4X_BIT_ATI 0x00000002 +#define GL_8X_BIT_ATI 0x00000004 +#define GL_HALF_BIT_ATI 0x00000008 +#define GL_QUARTER_BIT_ATI 0x00000010 +#define GL_EIGHTH_BIT_ATI 0x00000020 +#define GL_SATURATE_BIT_ATI 0x00000040 +#define GL_COMP_BIT_ATI 0x00000002 +#define GL_NEGATE_BIT_ATI 0x00000004 +#define GL_BIAS_BIT_ATI 0x00000008 +typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); +typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); +typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glGenFragmentShadersATI (GLuint range); +GLAPI void APIENTRY glBindFragmentShaderATI (GLuint id); +GLAPI void APIENTRY glDeleteFragmentShaderATI (GLuint id); +GLAPI void APIENTRY glBeginFragmentShaderATI (void); +GLAPI void APIENTRY glEndFragmentShaderATI (void); +GLAPI void APIENTRY glPassTexCoordATI (GLuint dst, GLuint coord, GLenum swizzle); +GLAPI void APIENTRY glSampleMapATI (GLuint dst, GLuint interp, GLenum swizzle); +GLAPI void APIENTRY glColorFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +GLAPI void APIENTRY glColorFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +GLAPI void APIENTRY glColorFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +GLAPI void APIENTRY glAlphaFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +GLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +GLAPI void APIENTRY glAlphaFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +GLAPI void APIENTRY glSetFragmentShaderConstantATI (GLuint dst, const GLfloat *value); +#endif +#endif /* GL_ATI_fragment_shader */ + +#ifndef GL_ATI_map_object_buffer +#define GL_ATI_map_object_buffer 1 +typedef void *(APIENTRYP PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void *APIENTRY glMapObjectBufferATI (GLuint buffer); +GLAPI void APIENTRY glUnmapObjectBufferATI (GLuint buffer); +#endif +#endif /* GL_ATI_map_object_buffer */ + +#ifndef GL_ATI_meminfo +#define GL_ATI_meminfo 1 +#define GL_VBO_FREE_MEMORY_ATI 0x87FB +#define GL_TEXTURE_FREE_MEMORY_ATI 0x87FC +#define GL_RENDERBUFFER_FREE_MEMORY_ATI 0x87FD +#endif /* GL_ATI_meminfo */ + +#ifndef GL_ATI_pixel_format_float +#define GL_ATI_pixel_format_float 1 +#define GL_RGBA_FLOAT_MODE_ATI 0x8820 +#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 +#endif /* GL_ATI_pixel_format_float */ + +#ifndef GL_ATI_pn_triangles +#define GL_ATI_pn_triangles 1 +#define GL_PN_TRIANGLES_ATI 0x87F0 +#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 +#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 +#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 +#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 +#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 +#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 +#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 +#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 +typedef void (APIENTRYP PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPNTrianglesiATI (GLenum pname, GLint param); +GLAPI void APIENTRY glPNTrianglesfATI (GLenum pname, GLfloat param); +#endif +#endif /* GL_ATI_pn_triangles */ + +#ifndef GL_ATI_separate_stencil +#define GL_ATI_separate_stencil 1 +#define GL_STENCIL_BACK_FUNC_ATI 0x8800 +#define GL_STENCIL_BACK_FAIL_ATI 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilOpSeparateATI (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +GLAPI void APIENTRY glStencilFuncSeparateATI (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +#endif +#endif /* GL_ATI_separate_stencil */ + +#ifndef GL_ATI_text_fragment_shader +#define GL_ATI_text_fragment_shader 1 +#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 +#endif /* GL_ATI_text_fragment_shader */ + +#ifndef GL_ATI_texture_env_combine3 +#define GL_ATI_texture_env_combine3 1 +#define GL_MODULATE_ADD_ATI 0x8744 +#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 +#define GL_MODULATE_SUBTRACT_ATI 0x8746 +#endif /* GL_ATI_texture_env_combine3 */ + +#ifndef GL_ATI_texture_float +#define GL_ATI_texture_float 1 +#define GL_RGBA_FLOAT32_ATI 0x8814 +#define GL_RGB_FLOAT32_ATI 0x8815 +#define GL_ALPHA_FLOAT32_ATI 0x8816 +#define GL_INTENSITY_FLOAT32_ATI 0x8817 +#define GL_LUMINANCE_FLOAT32_ATI 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 +#define GL_RGBA_FLOAT16_ATI 0x881A +#define GL_RGB_FLOAT16_ATI 0x881B +#define GL_ALPHA_FLOAT16_ATI 0x881C +#define GL_INTENSITY_FLOAT16_ATI 0x881D +#define GL_LUMINANCE_FLOAT16_ATI 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F +#endif /* GL_ATI_texture_float */ + +#ifndef GL_ATI_texture_mirror_once +#define GL_ATI_texture_mirror_once 1 +#define GL_MIRROR_CLAMP_ATI 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 +#endif /* GL_ATI_texture_mirror_once */ + +#ifndef GL_ATI_vertex_array_object +#define GL_ATI_vertex_array_object 1 +#define GL_STATIC_ATI 0x8760 +#define GL_DYNAMIC_ATI 0x8761 +#define GL_PRESERVE_ATI 0x8762 +#define GL_DISCARD_ATI 0x8763 +#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 +#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 +#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 +#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 +typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const void *pointer, GLenum usage); +typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const void *pointer, GLenum preserve); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glNewObjectBufferATI (GLsizei size, const void *pointer, GLenum usage); +GLAPI GLboolean APIENTRY glIsObjectBufferATI (GLuint buffer); +GLAPI void APIENTRY glUpdateObjectBufferATI (GLuint buffer, GLuint offset, GLsizei size, const void *pointer, GLenum preserve); +GLAPI void APIENTRY glGetObjectBufferfvATI (GLuint buffer, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetObjectBufferivATI (GLuint buffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glFreeObjectBufferATI (GLuint buffer); +GLAPI void APIENTRY glArrayObjectATI (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +GLAPI void APIENTRY glGetArrayObjectfvATI (GLenum array, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetArrayObjectivATI (GLenum array, GLenum pname, GLint *params); +GLAPI void APIENTRY glVariantArrayObjectATI (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +GLAPI void APIENTRY glGetVariantArrayObjectfvATI (GLuint id, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVariantArrayObjectivATI (GLuint id, GLenum pname, GLint *params); +#endif +#endif /* GL_ATI_vertex_array_object */ + +#ifndef GL_ATI_vertex_attrib_array_object +#define GL_ATI_vertex_attrib_array_object 1 +typedef void (APIENTRYP PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribArrayObjectATI (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); +GLAPI void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint index, GLenum pname, GLint *params); +#endif +#endif /* GL_ATI_vertex_attrib_array_object */ + +#ifndef GL_ATI_vertex_streams +#define GL_ATI_vertex_streams 1 +#define GL_MAX_VERTEX_STREAMS_ATI 0x876B +#define GL_VERTEX_STREAM0_ATI 0x876C +#define GL_VERTEX_STREAM1_ATI 0x876D +#define GL_VERTEX_STREAM2_ATI 0x876E +#define GL_VERTEX_STREAM3_ATI 0x876F +#define GL_VERTEX_STREAM4_ATI 0x8770 +#define GL_VERTEX_STREAM5_ATI 0x8771 +#define GL_VERTEX_STREAM6_ATI 0x8772 +#define GL_VERTEX_STREAM7_ATI 0x8773 +#define GL_VERTEX_SOURCE_ATI 0x8774 +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexStream1sATI (GLenum stream, GLshort x); +GLAPI void APIENTRY glVertexStream1svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream1iATI (GLenum stream, GLint x); +GLAPI void APIENTRY glVertexStream1ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream1fATI (GLenum stream, GLfloat x); +GLAPI void APIENTRY glVertexStream1fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream1dATI (GLenum stream, GLdouble x); +GLAPI void APIENTRY glVertexStream1dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glVertexStream2sATI (GLenum stream, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexStream2svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream2iATI (GLenum stream, GLint x, GLint y); +GLAPI void APIENTRY glVertexStream2ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream2fATI (GLenum stream, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexStream2fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream2dATI (GLenum stream, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexStream2dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glVertexStream3sATI (GLenum stream, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexStream3svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream3iATI (GLenum stream, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexStream3ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream3fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexStream3fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream3dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexStream3dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glVertexStream4sATI (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexStream4svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream4iATI (GLenum stream, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexStream4ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream4fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexStream4fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream4dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexStream4dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glNormalStream3bATI (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); +GLAPI void APIENTRY glNormalStream3bvATI (GLenum stream, const GLbyte *coords); +GLAPI void APIENTRY glNormalStream3sATI (GLenum stream, GLshort nx, GLshort ny, GLshort nz); +GLAPI void APIENTRY glNormalStream3svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glNormalStream3iATI (GLenum stream, GLint nx, GLint ny, GLint nz); +GLAPI void APIENTRY glNormalStream3ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glNormalStream3fATI (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); +GLAPI void APIENTRY glNormalStream3fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glNormalStream3dATI (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); +GLAPI void APIENTRY glNormalStream3dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glClientActiveVertexStreamATI (GLenum stream); +GLAPI void APIENTRY glVertexBlendEnviATI (GLenum pname, GLint param); +GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum pname, GLfloat param); +#endif +#endif /* GL_ATI_vertex_streams */ + +#ifndef GL_EXT_422_pixels +#define GL_EXT_422_pixels 1 +#define GL_422_EXT 0x80CC +#define GL_422_REV_EXT 0x80CD +#define GL_422_AVERAGE_EXT 0x80CE +#define GL_422_REV_AVERAGE_EXT 0x80CF +#endif /* GL_EXT_422_pixels */ + +#ifndef GL_EXT_EGL_image_storage +#define GL_EXT_EGL_image_storage 1 +typedef void *GLeglImageOES; +typedef void (APIENTRYP PFNGLEGLIMAGETARGETTEXSTORAGEEXTPROC) (GLenum target, GLeglImageOES image, const GLint* attrib_list); +typedef void (APIENTRYP PFNGLEGLIMAGETARGETTEXTURESTORAGEEXTPROC) (GLuint texture, GLeglImageOES image, const GLint* attrib_list); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glEGLImageTargetTexStorageEXT (GLenum target, GLeglImageOES image, const GLint* attrib_list); +GLAPI void APIENTRY glEGLImageTargetTextureStorageEXT (GLuint texture, GLeglImageOES image, const GLint* attrib_list); +#endif +#endif /* GL_EXT_EGL_image_storage */ + +#ifndef GL_EXT_EGL_sync +#define GL_EXT_EGL_sync 1 +#endif /* GL_EXT_EGL_sync */ + +#ifndef GL_EXT_abgr +#define GL_EXT_abgr 1 +#define GL_ABGR_EXT 0x8000 +#endif /* GL_EXT_abgr */ + +#ifndef GL_EXT_bgra +#define GL_EXT_bgra 1 +#define GL_BGR_EXT 0x80E0 +#define GL_BGRA_EXT 0x80E1 +#endif /* GL_EXT_bgra */ + +#ifndef GL_EXT_bindable_uniform +#define GL_EXT_bindable_uniform 1 +#define GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT 0x8DE2 +#define GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT 0x8DE3 +#define GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT 0x8DE4 +#define GL_MAX_BINDABLE_UNIFORM_SIZE_EXT 0x8DED +#define GL_UNIFORM_BUFFER_EXT 0x8DEE +#define GL_UNIFORM_BUFFER_BINDING_EXT 0x8DEF +typedef void (APIENTRYP PFNGLUNIFORMBUFFEREXTPROC) (GLuint program, GLint location, GLuint buffer); +typedef GLint (APIENTRYP PFNGLGETUNIFORMBUFFERSIZEEXTPROC) (GLuint program, GLint location); +typedef GLintptr (APIENTRYP PFNGLGETUNIFORMOFFSETEXTPROC) (GLuint program, GLint location); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniformBufferEXT (GLuint program, GLint location, GLuint buffer); +GLAPI GLint APIENTRY glGetUniformBufferSizeEXT (GLuint program, GLint location); +GLAPI GLintptr APIENTRY glGetUniformOffsetEXT (GLuint program, GLint location); +#endif +#endif /* GL_EXT_bindable_uniform */ + +#ifndef GL_EXT_blend_color +#define GL_EXT_blend_color 1 +#define GL_CONSTANT_COLOR_EXT 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 +#define GL_CONSTANT_ALPHA_EXT 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 +#define GL_BLEND_COLOR_EXT 0x8005 +typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendColorEXT (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +#endif +#endif /* GL_EXT_blend_color */ + +#ifndef GL_EXT_blend_equation_separate +#define GL_EXT_blend_equation_separate 1 +#define GL_BLEND_EQUATION_RGB_EXT 0x8009 +#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationSeparateEXT (GLenum modeRGB, GLenum modeAlpha); +#endif +#endif /* GL_EXT_blend_equation_separate */ + +#ifndef GL_EXT_blend_func_separate +#define GL_EXT_blend_func_separate 1 +#define GL_BLEND_DST_RGB_EXT 0x80C8 +#define GL_BLEND_SRC_RGB_EXT 0x80C9 +#define GL_BLEND_DST_ALPHA_EXT 0x80CA +#define GL_BLEND_SRC_ALPHA_EXT 0x80CB +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparateEXT (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif +#endif /* GL_EXT_blend_func_separate */ + +#ifndef GL_EXT_blend_logic_op +#define GL_EXT_blend_logic_op 1 +#endif /* GL_EXT_blend_logic_op */ + +#ifndef GL_EXT_blend_minmax +#define GL_EXT_blend_minmax 1 +#define GL_MIN_EXT 0x8007 +#define GL_MAX_EXT 0x8008 +#define GL_FUNC_ADD_EXT 0x8006 +#define GL_BLEND_EQUATION_EXT 0x8009 +typedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationEXT (GLenum mode); +#endif +#endif /* GL_EXT_blend_minmax */ + +#ifndef GL_EXT_blend_subtract +#define GL_EXT_blend_subtract 1 +#define GL_FUNC_SUBTRACT_EXT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B +#endif /* GL_EXT_blend_subtract */ + +#ifndef GL_EXT_clip_volume_hint +#define GL_EXT_clip_volume_hint 1 +#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 +#endif /* GL_EXT_clip_volume_hint */ + +#ifndef GL_EXT_cmyka +#define GL_EXT_cmyka 1 +#define GL_CMYK_EXT 0x800C +#define GL_CMYKA_EXT 0x800D +#define GL_PACK_CMYK_HINT_EXT 0x800E +#define GL_UNPACK_CMYK_HINT_EXT 0x800F +#endif /* GL_EXT_cmyka */ + +#ifndef GL_EXT_color_subtable +#define GL_EXT_color_subtable 1 +typedef void (APIENTRYP PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorSubTableEXT (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glCopyColorSubTableEXT (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +#endif +#endif /* GL_EXT_color_subtable */ + +#ifndef GL_EXT_compiled_vertex_array +#define GL_EXT_compiled_vertex_array 1 +#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 +#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 +typedef void (APIENTRYP PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLUNLOCKARRAYSEXTPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLockArraysEXT (GLint first, GLsizei count); +GLAPI void APIENTRY glUnlockArraysEXT (void); +#endif +#endif /* GL_EXT_compiled_vertex_array */ + +#ifndef GL_EXT_convolution +#define GL_EXT_convolution 1 +#define GL_CONVOLUTION_1D_EXT 0x8010 +#define GL_CONVOLUTION_2D_EXT 0x8011 +#define GL_SEPARABLE_2D_EXT 0x8012 +#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 +#define GL_REDUCE_EXT 0x8016 +#define GL_CONVOLUTION_FORMAT_EXT 0x8017 +#define GL_CONVOLUTION_WIDTH_EXT 0x8018 +#define GL_CONVOLUTION_HEIGHT_EXT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, void *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); +GLAPI void APIENTRY glConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); +GLAPI void APIENTRY glConvolutionParameterfEXT (GLenum target, GLenum pname, GLfloat params); +GLAPI void APIENTRY glConvolutionParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glConvolutionParameteriEXT (GLenum target, GLenum pname, GLint params); +GLAPI void APIENTRY glConvolutionParameterivEXT (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetConvolutionFilterEXT (GLenum target, GLenum format, GLenum type, void *image); +GLAPI void APIENTRY glGetConvolutionParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetConvolutionParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSeparableFilterEXT (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); +GLAPI void APIENTRY glSeparableFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); +#endif +#endif /* GL_EXT_convolution */ + +#ifndef GL_EXT_coordinate_frame +#define GL_EXT_coordinate_frame 1 +#define GL_TANGENT_ARRAY_EXT 0x8439 +#define GL_BINORMAL_ARRAY_EXT 0x843A +#define GL_CURRENT_TANGENT_EXT 0x843B +#define GL_CURRENT_BINORMAL_EXT 0x843C +#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E +#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F +#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 +#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 +#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 +#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 +#define GL_MAP1_TANGENT_EXT 0x8444 +#define GL_MAP2_TANGENT_EXT 0x8445 +#define GL_MAP1_BINORMAL_EXT 0x8446 +#define GL_MAP2_BINORMAL_EXT 0x8447 +typedef void (APIENTRYP PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz); +typedef void (APIENTRYP PFNGLTANGENT3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz); +typedef void (APIENTRYP PFNGLTANGENT3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz); +typedef void (APIENTRYP PFNGLTANGENT3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz); +typedef void (APIENTRYP PFNGLTANGENT3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz); +typedef void (APIENTRYP PFNGLTANGENT3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz); +typedef void (APIENTRYP PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz); +typedef void (APIENTRYP PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz); +typedef void (APIENTRYP PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz); +typedef void (APIENTRYP PFNGLBINORMAL3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz); +typedef void (APIENTRYP PFNGLBINORMAL3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTangent3bEXT (GLbyte tx, GLbyte ty, GLbyte tz); +GLAPI void APIENTRY glTangent3bvEXT (const GLbyte *v); +GLAPI void APIENTRY glTangent3dEXT (GLdouble tx, GLdouble ty, GLdouble tz); +GLAPI void APIENTRY glTangent3dvEXT (const GLdouble *v); +GLAPI void APIENTRY glTangent3fEXT (GLfloat tx, GLfloat ty, GLfloat tz); +GLAPI void APIENTRY glTangent3fvEXT (const GLfloat *v); +GLAPI void APIENTRY glTangent3iEXT (GLint tx, GLint ty, GLint tz); +GLAPI void APIENTRY glTangent3ivEXT (const GLint *v); +GLAPI void APIENTRY glTangent3sEXT (GLshort tx, GLshort ty, GLshort tz); +GLAPI void APIENTRY glTangent3svEXT (const GLshort *v); +GLAPI void APIENTRY glBinormal3bEXT (GLbyte bx, GLbyte by, GLbyte bz); +GLAPI void APIENTRY glBinormal3bvEXT (const GLbyte *v); +GLAPI void APIENTRY glBinormal3dEXT (GLdouble bx, GLdouble by, GLdouble bz); +GLAPI void APIENTRY glBinormal3dvEXT (const GLdouble *v); +GLAPI void APIENTRY glBinormal3fEXT (GLfloat bx, GLfloat by, GLfloat bz); +GLAPI void APIENTRY glBinormal3fvEXT (const GLfloat *v); +GLAPI void APIENTRY glBinormal3iEXT (GLint bx, GLint by, GLint bz); +GLAPI void APIENTRY glBinormal3ivEXT (const GLint *v); +GLAPI void APIENTRY glBinormal3sEXT (GLshort bx, GLshort by, GLshort bz); +GLAPI void APIENTRY glBinormal3svEXT (const GLshort *v); +GLAPI void APIENTRY glTangentPointerEXT (GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glBinormalPointerEXT (GLenum type, GLsizei stride, const void *pointer); +#endif +#endif /* GL_EXT_coordinate_frame */ + +#ifndef GL_EXT_copy_texture +#define GL_EXT_copy_texture 1 +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCopyTexImage1DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyTexImage2DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glCopyTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif +#endif /* GL_EXT_copy_texture */ + +#ifndef GL_EXT_cull_vertex +#define GL_EXT_cull_vertex 1 +#define GL_CULL_VERTEX_EXT 0x81AA +#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB +#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC +typedef void (APIENTRYP PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCullParameterdvEXT (GLenum pname, GLdouble *params); +GLAPI void APIENTRY glCullParameterfvEXT (GLenum pname, GLfloat *params); +#endif +#endif /* GL_EXT_cull_vertex */ + +#ifndef GL_EXT_debug_label +#define GL_EXT_debug_label 1 +#define GL_PROGRAM_PIPELINE_OBJECT_EXT 0x8A4F +#define GL_PROGRAM_OBJECT_EXT 0x8B40 +#define GL_SHADER_OBJECT_EXT 0x8B48 +#define GL_BUFFER_OBJECT_EXT 0x9151 +#define GL_QUERY_OBJECT_EXT 0x9153 +#define GL_VERTEX_ARRAY_OBJECT_EXT 0x9154 +typedef void (APIENTRYP PFNGLLABELOBJECTEXTPROC) (GLenum type, GLuint object, GLsizei length, const GLchar *label); +typedef void (APIENTRYP PFNGLGETOBJECTLABELEXTPROC) (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLabelObjectEXT (GLenum type, GLuint object, GLsizei length, const GLchar *label); +GLAPI void APIENTRY glGetObjectLabelEXT (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label); +#endif +#endif /* GL_EXT_debug_label */ + +#ifndef GL_EXT_debug_marker +#define GL_EXT_debug_marker 1 +typedef void (APIENTRYP PFNGLINSERTEVENTMARKEREXTPROC) (GLsizei length, const GLchar *marker); +typedef void (APIENTRYP PFNGLPUSHGROUPMARKEREXTPROC) (GLsizei length, const GLchar *marker); +typedef void (APIENTRYP PFNGLPOPGROUPMARKEREXTPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glInsertEventMarkerEXT (GLsizei length, const GLchar *marker); +GLAPI void APIENTRY glPushGroupMarkerEXT (GLsizei length, const GLchar *marker); +GLAPI void APIENTRY glPopGroupMarkerEXT (void); +#endif +#endif /* GL_EXT_debug_marker */ + +#ifndef GL_EXT_depth_bounds_test +#define GL_EXT_depth_bounds_test 1 +#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 +#define GL_DEPTH_BOUNDS_EXT 0x8891 +typedef void (APIENTRYP PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthBoundsEXT (GLclampd zmin, GLclampd zmax); +#endif +#endif /* GL_EXT_depth_bounds_test */ + +#ifndef GL_EXT_direct_state_access +#define GL_EXT_direct_state_access 1 +#define GL_PROGRAM_MATRIX_EXT 0x8E2D +#define GL_TRANSPOSE_PROGRAM_MATRIX_EXT 0x8E2E +#define GL_PROGRAM_MATRIX_STACK_DEPTH_EXT 0x8E2F +typedef void (APIENTRYP PFNGLMATRIXLOADFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXLOADDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLMATRIXMULTFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULTDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLMATRIXLOADIDENTITYEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLMATRIXROTATEFEXTPROC) (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLMATRIXROTATEDEXTPROC) (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLMATRIXSCALEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLMATRIXSCALEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLMATRIXTRANSLATEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLMATRIXTRANSLATEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLMATRIXFRUSTUMEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLMATRIXORTHOEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLMATRIXPOPEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLMATRIXPUSHEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLBINDMULTITEXTUREEXTPROC) (GLenum texunit, GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORDPOINTEREXTPROC) (GLenum texunit, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLMULTITEXENVFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLMULTITEXENVIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXGENDEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); +typedef void (APIENTRYP PFNGLMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); +typedef void (APIENTRYP PFNGLMULTITEXGENFEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLMULTITEXGENIEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLENABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLGETFLOATINDEXEDVEXTPROC) (GLenum target, GLuint index, GLfloat *data); +typedef void (APIENTRYP PFNGLGETDOUBLEINDEXEDVEXTPROC) (GLenum target, GLuint index, GLdouble *data); +typedef void (APIENTRYP PFNGLGETPOINTERINDEXEDVEXTPROC) (GLenum target, GLuint index, void **data); +typedef void (APIENTRYP PFNGLENABLEINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLDISABLEINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISENABLEDINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLGETINTEGERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLint *data); +typedef void (APIENTRYP PFNGLGETBOOLEANINDEXEDVEXTPROC) (GLenum target, GLuint index, GLboolean *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint lod, void *img); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint lod, void *img); +typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFEREXTPROC) (GLuint buffer, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFEREXTPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVEXTPROC) (GLuint buffer, GLenum pname, void **params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLTEXTUREBUFFEREXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLMULTITEXBUFFEREXTPROC) (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIEXTPROC) (GLuint program, GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC) (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint *params); +typedef void (APIENTRYP PFNGLENABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLGETFLOATI_VEXTPROC) (GLenum pname, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETDOUBLEI_VEXTPROC) (GLenum pname, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPOINTERI_VEXTPROC) (GLenum pname, GLuint index, void **params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum format, GLsizei len, const void *string); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMIVEXTPROC) (GLuint program, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum pname, void *string); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC) (GLuint renderbuffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC) (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +typedef GLenum (APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC) (GLuint framebuffer, GLenum target); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATETEXTUREMIPMAPEXTPROC) (GLuint texture, GLenum target); +typedef void (APIENTRYP PFNGLGENERATEMULTITEXMIPMAPEXTPROC) (GLenum texunit, GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); +typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC) (GLuint framebuffer, GLsizei n, const GLenum *bufs); +typedef void (APIENTRYP PFNGLFRAMEBUFFERREADBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); +typedef void (APIENTRYP PFNGLTEXTURERENDERBUFFEREXTPROC) (GLuint texture, GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLMULTITEXRENDERBUFFEREXTPROC) (GLenum texunit, GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYEDGEFLAGOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYINDEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYNORMALOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYTEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYMULTITEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum texunit, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYFOGCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYSECONDARYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBIOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLENABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array); +typedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array); +typedef void (APIENTRYP PFNGLENABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index); +typedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYINTEGERVEXTPROC) (GLuint vaobj, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYPOINTERVEXTPROC) (GLuint vaobj, GLenum pname, void **param); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYINTEGERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYPOINTERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, void **param); +typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEEXTPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLsizeiptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERPARAMETERIEXTPROC) (GLuint framebuffer, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DEXTPROC) (GLuint program, GLint location, GLdouble x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLTEXTUREBUFFERRANGEEXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLVERTEXARRAYBINDVERTEXBUFFEREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBIFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBBINDINGEXTPROC) (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBINDINGDIVISOREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint divisor); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLTEXTUREPAGECOMMITMENTEXTPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBDIVISOREXTPROC) (GLuint vaobj, GLuint index, GLuint divisor); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMatrixLoadfEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixLoaddEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixMultfEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMultdEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixLoadIdentityEXT (GLenum mode); +GLAPI void APIENTRY glMatrixRotatefEXT (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixRotatedEXT (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixScalefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixScaledEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixTranslatefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixTranslatedEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixFrustumEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glMatrixOrthoEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glMatrixPopEXT (GLenum mode); +GLAPI void APIENTRY glMatrixPushEXT (GLenum mode); +GLAPI void APIENTRY glClientAttribDefaultEXT (GLbitfield mask); +GLAPI void APIENTRY glPushClientAttribDefaultEXT (GLbitfield mask); +GLAPI void APIENTRY glTextureParameterfEXT (GLuint texture, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glTextureParameteriEXT (GLuint texture, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCopyTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetTextureImageEXT (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); +GLAPI void APIENTRY glGetTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTextureLevelParameterfvEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTextureLevelParameterivEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); +GLAPI void APIENTRY glTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCopyTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glBindMultiTextureEXT (GLenum texunit, GLenum target, GLuint texture); +GLAPI void APIENTRY glMultiTexCoordPointerEXT (GLenum texunit, GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glMultiTexEnvfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexEnviEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexGendEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); +GLAPI void APIENTRY glMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); +GLAPI void APIENTRY glMultiTexGenfEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexGeniEXT (GLenum texunit, GLenum coord, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); +GLAPI void APIENTRY glGetMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, GLint *params); +GLAPI void APIENTRY glMultiTexParameteriEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexParameterfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCopyMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetMultiTexImageEXT (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); +GLAPI void APIENTRY glGetMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexLevelParameterfvEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexLevelParameterivEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); +GLAPI void APIENTRY glMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCopyMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glEnableClientStateIndexedEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glDisableClientStateIndexedEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glGetFloatIndexedvEXT (GLenum target, GLuint index, GLfloat *data); +GLAPI void APIENTRY glGetDoubleIndexedvEXT (GLenum target, GLuint index, GLdouble *data); +GLAPI void APIENTRY glGetPointerIndexedvEXT (GLenum target, GLuint index, void **data); +GLAPI void APIENTRY glEnableIndexedEXT (GLenum target, GLuint index); +GLAPI void APIENTRY glDisableIndexedEXT (GLenum target, GLuint index); +GLAPI GLboolean APIENTRY glIsEnabledIndexedEXT (GLenum target, GLuint index); +GLAPI void APIENTRY glGetIntegerIndexedvEXT (GLenum target, GLuint index, GLint *data); +GLAPI void APIENTRY glGetBooleanIndexedvEXT (GLenum target, GLuint index, GLboolean *data); +GLAPI void APIENTRY glCompressedTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glGetCompressedTextureImageEXT (GLuint texture, GLenum target, GLint lod, void *img); +GLAPI void APIENTRY glCompressedMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glGetCompressedMultiTexImageEXT (GLenum texunit, GLenum target, GLint lod, void *img); +GLAPI void APIENTRY glMatrixLoadTransposefEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixLoadTransposedEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixMultTransposefEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMultTransposedEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glNamedBufferDataEXT (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); +GLAPI void APIENTRY glNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +GLAPI void *APIENTRY glMapNamedBufferEXT (GLuint buffer, GLenum access); +GLAPI GLboolean APIENTRY glUnmapNamedBufferEXT (GLuint buffer); +GLAPI void APIENTRY glGetNamedBufferParameterivEXT (GLuint buffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetNamedBufferPointervEXT (GLuint buffer, GLenum pname, void **params); +GLAPI void APIENTRY glGetNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); +GLAPI void APIENTRY glProgramUniform1fEXT (GLuint program, GLint location, GLfloat v0); +GLAPI void APIENTRY glProgramUniform2fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glProgramUniform3fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glProgramUniform4fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glProgramUniform1iEXT (GLuint program, GLint location, GLint v0); +GLAPI void APIENTRY glProgramUniform2iEXT (GLuint program, GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glProgramUniform3iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glProgramUniform4iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glProgramUniform1fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform2fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform3fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform4fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform1ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform2ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform3ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform4ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniformMatrix2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glTextureBufferEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glMultiTexBufferEXT (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glProgramUniform1uiEXT (GLuint program, GLint location, GLuint v0); +GLAPI void APIENTRY glProgramUniform2uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glProgramUniform3uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glProgramUniform4uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glProgramUniform1uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform2uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform3uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform4uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glNamedProgramLocalParameters4fvEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glNamedProgramLocalParameterI4iEXT (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glNamedProgramLocalParameterI4ivEXT (GLuint program, GLenum target, GLuint index, const GLint *params); +GLAPI void APIENTRY glNamedProgramLocalParametersI4ivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glNamedProgramLocalParameterI4uiEXT (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glNamedProgramLocalParameterI4uivEXT (GLuint program, GLenum target, GLuint index, const GLuint *params); +GLAPI void APIENTRY glNamedProgramLocalParametersI4uivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterIivEXT (GLuint program, GLenum target, GLuint index, GLint *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterIuivEXT (GLuint program, GLenum target, GLuint index, GLuint *params); +GLAPI void APIENTRY glEnableClientStateiEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glDisableClientStateiEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glGetFloati_vEXT (GLenum pname, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetDoublei_vEXT (GLenum pname, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetPointeri_vEXT (GLenum pname, GLuint index, void **params); +GLAPI void APIENTRY glNamedProgramStringEXT (GLuint program, GLenum target, GLenum format, GLsizei len, const void *string); +GLAPI void APIENTRY glNamedProgramLocalParameter4dEXT (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glNamedProgramLocalParameter4dvEXT (GLuint program, GLenum target, GLuint index, const GLdouble *params); +GLAPI void APIENTRY glNamedProgramLocalParameter4fEXT (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glNamedProgramLocalParameter4fvEXT (GLuint program, GLenum target, GLuint index, const GLfloat *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterdvEXT (GLuint program, GLenum target, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterfvEXT (GLuint program, GLenum target, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetNamedProgramivEXT (GLuint program, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetNamedProgramStringEXT (GLuint program, GLenum target, GLenum pname, void *string); +GLAPI void APIENTRY glNamedRenderbufferStorageEXT (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetNamedRenderbufferParameterivEXT (GLuint renderbuffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleEXT (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleCoverageEXT (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI GLenum APIENTRY glCheckNamedFramebufferStatusEXT (GLuint framebuffer, GLenum target); +GLAPI void APIENTRY glNamedFramebufferTexture1DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTexture2DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTexture3DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glNamedFramebufferRenderbufferEXT (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetNamedFramebufferAttachmentParameterivEXT (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateTextureMipmapEXT (GLuint texture, GLenum target); +GLAPI void APIENTRY glGenerateMultiTexMipmapEXT (GLenum texunit, GLenum target); +GLAPI void APIENTRY glFramebufferDrawBufferEXT (GLuint framebuffer, GLenum mode); +GLAPI void APIENTRY glFramebufferDrawBuffersEXT (GLuint framebuffer, GLsizei n, const GLenum *bufs); +GLAPI void APIENTRY glFramebufferReadBufferEXT (GLuint framebuffer, GLenum mode); +GLAPI void APIENTRY glGetFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glNamedCopyBufferSubDataEXT (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GLAPI void APIENTRY glNamedFramebufferTextureEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTextureLayerEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glNamedFramebufferTextureFaceEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); +GLAPI void APIENTRY glTextureRenderbufferEXT (GLuint texture, GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glMultiTexRenderbufferEXT (GLenum texunit, GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glVertexArrayVertexOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayColorOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayEdgeFlagOffsetEXT (GLuint vaobj, GLuint buffer, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayIndexOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayNormalOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayTexCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayMultiTexCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLenum texunit, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayFogCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArraySecondaryColorOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayVertexAttribOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayVertexAttribIOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glEnableVertexArrayEXT (GLuint vaobj, GLenum array); +GLAPI void APIENTRY glDisableVertexArrayEXT (GLuint vaobj, GLenum array); +GLAPI void APIENTRY glEnableVertexArrayAttribEXT (GLuint vaobj, GLuint index); +GLAPI void APIENTRY glDisableVertexArrayAttribEXT (GLuint vaobj, GLuint index); +GLAPI void APIENTRY glGetVertexArrayIntegervEXT (GLuint vaobj, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetVertexArrayPointervEXT (GLuint vaobj, GLenum pname, void **param); +GLAPI void APIENTRY glGetVertexArrayIntegeri_vEXT (GLuint vaobj, GLuint index, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetVertexArrayPointeri_vEXT (GLuint vaobj, GLuint index, GLenum pname, void **param); +GLAPI void *APIENTRY glMapNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); +GLAPI void APIENTRY glFlushMappedNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glNamedBufferStorageEXT (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); +GLAPI void APIENTRY glClearNamedBufferDataEXT (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearNamedBufferSubDataEXT (GLuint buffer, GLenum internalformat, GLsizeiptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glNamedFramebufferParameteriEXT (GLuint framebuffer, GLenum pname, GLint param); +GLAPI void APIENTRY glGetNamedFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glProgramUniform1dEXT (GLuint program, GLint location, GLdouble x); +GLAPI void APIENTRY glProgramUniform2dEXT (GLuint program, GLint location, GLdouble x, GLdouble y); +GLAPI void APIENTRY glProgramUniform3dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glProgramUniform4dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramUniform1dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform2dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform3dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform4dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glTextureBufferRangeEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +GLAPI void APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glTextureStorage2DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureStorage3DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glVertexArrayBindVertexBufferEXT (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +GLAPI void APIENTRY glVertexArrayVertexAttribFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribIFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribLFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribBindingEXT (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +GLAPI void APIENTRY glVertexArrayVertexBindingDivisorEXT (GLuint vaobj, GLuint bindingindex, GLuint divisor); +GLAPI void APIENTRY glVertexArrayVertexAttribLOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glTexturePageCommitmentEXT (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); +GLAPI void APIENTRY glVertexArrayVertexAttribDivisorEXT (GLuint vaobj, GLuint index, GLuint divisor); +#endif +#endif /* GL_EXT_direct_state_access */ + +#ifndef GL_EXT_draw_buffers2 +#define GL_EXT_draw_buffers2 1 +typedef void (APIENTRYP PFNGLCOLORMASKINDEXEDEXTPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorMaskIndexedEXT (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +#endif +#endif /* GL_EXT_draw_buffers2 */ + +#ifndef GL_EXT_draw_instanced +#define GL_EXT_draw_instanced 1 +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedEXT (GLenum mode, GLint start, GLsizei count, GLsizei primcount); +GLAPI void APIENTRY glDrawElementsInstancedEXT (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#endif +#endif /* GL_EXT_draw_instanced */ + +#ifndef GL_EXT_draw_range_elements +#define GL_EXT_draw_range_elements 1 +#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8 +#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9 +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); +#endif +#endif /* GL_EXT_draw_range_elements */ + +#ifndef GL_EXT_external_buffer +#define GL_EXT_external_buffer 1 +typedef void *GLeglClientBufferEXT; +typedef void (APIENTRYP PFNGLBUFFERSTORAGEEXTERNALEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEEXTERNALEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferStorageExternalEXT (GLenum target, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); +GLAPI void APIENTRY glNamedBufferStorageExternalEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); +#endif +#endif /* GL_EXT_external_buffer */ + +#ifndef GL_EXT_fog_coord +#define GL_EXT_fog_coord 1 +#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 +#define GL_FOG_COORDINATE_EXT 0x8451 +#define GL_FRAGMENT_DEPTH_EXT 0x8452 +#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 +#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 +typedef void (APIENTRYP PFNGLFOGCOORDFEXTPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDEXTPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogCoordfEXT (GLfloat coord); +GLAPI void APIENTRY glFogCoordfvEXT (const GLfloat *coord); +GLAPI void APIENTRY glFogCoorddEXT (GLdouble coord); +GLAPI void APIENTRY glFogCoorddvEXT (const GLdouble *coord); +GLAPI void APIENTRY glFogCoordPointerEXT (GLenum type, GLsizei stride, const void *pointer); +#endif +#endif /* GL_EXT_fog_coord */ + +#ifndef GL_EXT_framebuffer_blit +#define GL_EXT_framebuffer_blit 1 +#define GL_READ_FRAMEBUFFER_EXT 0x8CA8 +#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9 +#define GL_DRAW_FRAMEBUFFER_BINDING_EXT 0x8CA6 +#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA +typedef void (APIENTRYP PFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlitFramebufferEXT (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif +#endif /* GL_EXT_framebuffer_blit */ + +#ifndef GL_EXT_framebuffer_multisample +#define GL_EXT_framebuffer_multisample 1 +#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 +#define GL_MAX_SAMPLES_EXT 0x8D57 +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderbufferStorageMultisampleEXT (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#endif +#endif /* GL_EXT_framebuffer_multisample */ + +#ifndef GL_EXT_framebuffer_multisample_blit_scaled +#define GL_EXT_framebuffer_multisample_blit_scaled 1 +#define GL_SCALED_RESOLVE_FASTEST_EXT 0x90BA +#define GL_SCALED_RESOLVE_NICEST_EXT 0x90BB +#endif /* GL_EXT_framebuffer_multisample_blit_scaled */ + +#ifndef GL_EXT_framebuffer_object +#define GL_EXT_framebuffer_object 1 +#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 +#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 +#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 +#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 +#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF +#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 +#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 +#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 +#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 +#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 +#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 +#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 +#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 +#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 +#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 +#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA +#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB +#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC +#define GL_COLOR_ATTACHMENT13_EXT 0x8CED +#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE +#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF +#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 +#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 +#define GL_FRAMEBUFFER_EXT 0x8D40 +#define GL_RENDERBUFFER_EXT 0x8D41 +#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 +#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 +#define GL_STENCIL_INDEX1_EXT 0x8D46 +#define GL_STENCIL_INDEX4_EXT 0x8D47 +#define GL_STENCIL_INDEX8_EXT 0x8D48 +#define GL_STENCIL_INDEX16_EXT 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 +typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer); +typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer); +typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); +typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers); +typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glIsRenderbufferEXT (GLuint renderbuffer); +GLAPI void APIENTRY glBindRenderbufferEXT (GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glDeleteRenderbuffersEXT (GLsizei n, const GLuint *renderbuffers); +GLAPI void APIENTRY glGenRenderbuffersEXT (GLsizei n, GLuint *renderbuffers); +GLAPI void APIENTRY glRenderbufferStorageEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetRenderbufferParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI GLboolean APIENTRY glIsFramebufferEXT (GLuint framebuffer); +GLAPI void APIENTRY glBindFramebufferEXT (GLenum target, GLuint framebuffer); +GLAPI void APIENTRY glDeleteFramebuffersEXT (GLsizei n, const GLuint *framebuffers); +GLAPI void APIENTRY glGenFramebuffersEXT (GLsizei n, GLuint *framebuffers); +GLAPI GLenum APIENTRY glCheckFramebufferStatusEXT (GLenum target); +GLAPI void APIENTRY glFramebufferTexture1DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture2DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture3DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glFramebufferRenderbufferEXT (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetFramebufferAttachmentParameterivEXT (GLenum target, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateMipmapEXT (GLenum target); +#endif +#endif /* GL_EXT_framebuffer_object */ + +#ifndef GL_EXT_framebuffer_sRGB +#define GL_EXT_framebuffer_sRGB 1 +#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 +#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA +#endif /* GL_EXT_framebuffer_sRGB */ + +#ifndef GL_EXT_geometry_shader4 +#define GL_EXT_geometry_shader4 1 +#define GL_GEOMETRY_SHADER_EXT 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT_EXT 0x8DDA +#define GL_GEOMETRY_INPUT_TYPE_EXT 0x8DDB +#define GL_GEOMETRY_OUTPUT_TYPE_EXT 0x8DDC +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29 +#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT 0x8DDD +#define GL_MAX_VERTEX_VARYING_COMPONENTS_EXT 0x8DDE +#define GL_MAX_VARYING_COMPONENTS_EXT 0x8B4B +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1 +#define GL_LINES_ADJACENCY_EXT 0x000A +#define GL_LINE_STRIP_ADJACENCY_EXT 0x000B +#define GL_TRIANGLES_ADJACENCY_EXT 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0x000D +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT 0x8DA9 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4 +#define GL_PROGRAM_POINT_SIZE_EXT 0x8642 +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramParameteriEXT (GLuint program, GLenum pname, GLint value); +#endif +#endif /* GL_EXT_geometry_shader4 */ + +#ifndef GL_EXT_gpu_program_parameters +#define GL_EXT_gpu_program_parameters 1 +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramEnvParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glProgramLocalParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +#endif +#endif /* GL_EXT_gpu_program_parameters */ + +#ifndef GL_EXT_gpu_shader4 +#define GL_EXT_gpu_shader4 1 +#define GL_SAMPLER_1D_ARRAY_EXT 0x8DC0 +#define GL_SAMPLER_2D_ARRAY_EXT 0x8DC1 +#define GL_SAMPLER_BUFFER_EXT 0x8DC2 +#define GL_SAMPLER_1D_ARRAY_SHADOW_EXT 0x8DC3 +#define GL_SAMPLER_2D_ARRAY_SHADOW_EXT 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW_EXT 0x8DC5 +#define GL_UNSIGNED_INT_VEC2_EXT 0x8DC6 +#define GL_UNSIGNED_INT_VEC3_EXT 0x8DC7 +#define GL_UNSIGNED_INT_VEC4_EXT 0x8DC8 +#define GL_INT_SAMPLER_1D_EXT 0x8DC9 +#define GL_INT_SAMPLER_2D_EXT 0x8DCA +#define GL_INT_SAMPLER_3D_EXT 0x8DCB +#define GL_INT_SAMPLER_CUBE_EXT 0x8DCC +#define GL_INT_SAMPLER_2D_RECT_EXT 0x8DCD +#define GL_INT_SAMPLER_1D_ARRAY_EXT 0x8DCE +#define GL_INT_SAMPLER_2D_ARRAY_EXT 0x8DCF +#define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_1D_EXT 0x8DD1 +#define GL_UNSIGNED_INT_SAMPLER_2D_EXT 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D_EXT 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE_EXT 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT 0x8DD5 +#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT 0x8DD6 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT 0x8DD7 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8 +#define GL_MIN_PROGRAM_TEXEL_OFFSET_EXT 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET_EXT 0x8905 +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_EXT 0x88FD +typedef void (APIENTRYP PFNGLGETUNIFORMUIVEXTPROC) (GLuint program, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONEXTPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORM1UIEXTPROC) (GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLUNIFORM2UIEXTPROC) (GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLUNIFORM3UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLUNIFORM4UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLUNIFORM1UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM2UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM3UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM4UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IEXTPROC) (GLuint index, GLint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IEXTPROC) (GLuint index, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IEXTPROC) (GLuint index, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IEXTPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIEXTPROC) (GLuint index, GLuint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIEXTPROC) (GLuint index, GLuint x, GLuint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVEXTPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVEXTPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVEXTPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVEXTPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVEXTPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVEXTPROC) (GLuint index, GLenum pname, GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetUniformuivEXT (GLuint program, GLint location, GLuint *params); +GLAPI void APIENTRY glBindFragDataLocationEXT (GLuint program, GLuint color, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataLocationEXT (GLuint program, const GLchar *name); +GLAPI void APIENTRY glUniform1uiEXT (GLint location, GLuint v0); +GLAPI void APIENTRY glUniform2uiEXT (GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glUniform3uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glUniform4uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glUniform1uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform2uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform3uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform4uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glVertexAttribI1iEXT (GLuint index, GLint x); +GLAPI void APIENTRY glVertexAttribI2iEXT (GLuint index, GLint x, GLint y); +GLAPI void APIENTRY glVertexAttribI3iEXT (GLuint index, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexAttribI4iEXT (GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexAttribI1uiEXT (GLuint index, GLuint x); +GLAPI void APIENTRY glVertexAttribI2uiEXT (GLuint index, GLuint x, GLuint y); +GLAPI void APIENTRY glVertexAttribI3uiEXT (GLuint index, GLuint x, GLuint y, GLuint z); +GLAPI void APIENTRY glVertexAttribI4uiEXT (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glVertexAttribI1ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI2ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI3ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI4ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI1uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI2uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI3uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4bvEXT (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttribI4svEXT (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttribI4ubvEXT (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribI4usvEXT (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribIPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glGetVertexAttribIivEXT (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribIuivEXT (GLuint index, GLenum pname, GLuint *params); +#endif +#endif /* GL_EXT_gpu_shader4 */ + +#ifndef GL_EXT_histogram +#define GL_EXT_histogram 1 +#define GL_HISTOGRAM_EXT 0x8024 +#define GL_PROXY_HISTOGRAM_EXT 0x8025 +#define GL_HISTOGRAM_WIDTH_EXT 0x8026 +#define GL_HISTOGRAM_FORMAT_EXT 0x8027 +#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C +#define GL_HISTOGRAM_SINK_EXT 0x802D +#define GL_MINMAX_EXT 0x802E +#define GL_MINMAX_FORMAT_EXT 0x802F +#define GL_MINMAX_SINK_EXT 0x8030 +#define GL_TABLE_TOO_LARGE_EXT 0x8031 +typedef void (APIENTRYP PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXEXTPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetHistogramEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +GLAPI void APIENTRY glGetHistogramParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetHistogramParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMinmaxEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +GLAPI void APIENTRY glGetMinmaxParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMinmaxParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glHistogramEXT (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glMinmaxEXT (GLenum target, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glResetHistogramEXT (GLenum target); +GLAPI void APIENTRY glResetMinmaxEXT (GLenum target); +#endif +#endif /* GL_EXT_histogram */ + +#ifndef GL_EXT_index_array_formats +#define GL_EXT_index_array_formats 1 +#define GL_IUI_V2F_EXT 0x81AD +#define GL_IUI_V3F_EXT 0x81AE +#define GL_IUI_N3F_V2F_EXT 0x81AF +#define GL_IUI_N3F_V3F_EXT 0x81B0 +#define GL_T2F_IUI_V2F_EXT 0x81B1 +#define GL_T2F_IUI_V3F_EXT 0x81B2 +#define GL_T2F_IUI_N3F_V2F_EXT 0x81B3 +#define GL_T2F_IUI_N3F_V3F_EXT 0x81B4 +#endif /* GL_EXT_index_array_formats */ + +#ifndef GL_EXT_index_func +#define GL_EXT_index_func 1 +#define GL_INDEX_TEST_EXT 0x81B5 +#define GL_INDEX_TEST_FUNC_EXT 0x81B6 +#define GL_INDEX_TEST_REF_EXT 0x81B7 +typedef void (APIENTRYP PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIndexFuncEXT (GLenum func, GLclampf ref); +#endif +#endif /* GL_EXT_index_func */ + +#ifndef GL_EXT_index_material +#define GL_EXT_index_material 1 +#define GL_INDEX_MATERIAL_EXT 0x81B8 +#define GL_INDEX_MATERIAL_PARAMETER_EXT 0x81B9 +#define GL_INDEX_MATERIAL_FACE_EXT 0x81BA +typedef void (APIENTRYP PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIndexMaterialEXT (GLenum face, GLenum mode); +#endif +#endif /* GL_EXT_index_material */ + +#ifndef GL_EXT_index_texture +#define GL_EXT_index_texture 1 +#endif /* GL_EXT_index_texture */ + +#ifndef GL_EXT_light_texture +#define GL_EXT_light_texture 1 +#define GL_FRAGMENT_MATERIAL_EXT 0x8349 +#define GL_FRAGMENT_NORMAL_EXT 0x834A +#define GL_FRAGMENT_COLOR_EXT 0x834C +#define GL_ATTENUATION_EXT 0x834D +#define GL_SHADOW_ATTENUATION_EXT 0x834E +#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F +#define GL_TEXTURE_LIGHT_EXT 0x8350 +#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 +#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 +typedef void (APIENTRYP PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glApplyTextureEXT (GLenum mode); +GLAPI void APIENTRY glTextureLightEXT (GLenum pname); +GLAPI void APIENTRY glTextureMaterialEXT (GLenum face, GLenum mode); +#endif +#endif /* GL_EXT_light_texture */ + +#ifndef GL_EXT_memory_object +#define GL_EXT_memory_object 1 +#define GL_TEXTURE_TILING_EXT 0x9580 +#define GL_DEDICATED_MEMORY_OBJECT_EXT 0x9581 +#define GL_PROTECTED_MEMORY_OBJECT_EXT 0x959B +#define GL_NUM_TILING_TYPES_EXT 0x9582 +#define GL_TILING_TYPES_EXT 0x9583 +#define GL_OPTIMAL_TILING_EXT 0x9584 +#define GL_LINEAR_TILING_EXT 0x9585 +#define GL_NUM_DEVICE_UUIDS_EXT 0x9596 +#define GL_DEVICE_UUID_EXT 0x9597 +#define GL_DRIVER_UUID_EXT 0x9598 +#define GL_UUID_SIZE_EXT 16 +typedef void (APIENTRYP PFNGLGETUNSIGNEDBYTEVEXTPROC) (GLenum pname, GLubyte *data); +typedef void (APIENTRYP PFNGLGETUNSIGNEDBYTEI_VEXTPROC) (GLenum target, GLuint index, GLubyte *data); +typedef void (APIENTRYP PFNGLDELETEMEMORYOBJECTSEXTPROC) (GLsizei n, const GLuint *memoryObjects); +typedef GLboolean (APIENTRYP PFNGLISMEMORYOBJECTEXTPROC) (GLuint memoryObject); +typedef void (APIENTRYP PFNGLCREATEMEMORYOBJECTSEXTPROC) (GLsizei n, GLuint *memoryObjects); +typedef void (APIENTRYP PFNGLMEMORYOBJECTPARAMETERIVEXTPROC) (GLuint memoryObject, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETMEMORYOBJECTPARAMETERIVEXTPROC) (GLuint memoryObject, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLTEXSTORAGEMEM2DEXTPROC) (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXSTORAGEMEM2DMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXSTORAGEMEM3DEXTPROC) (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXSTORAGEMEM3DMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLBUFFERSTORAGEMEMEXTPROC) (GLenum target, GLsizeiptr size, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM2DEXTPROC) (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM2DMULTISAMPLEEXTPROC) (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM3DEXTPROC) (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM3DMULTISAMPLEEXTPROC) (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEMEMEXTPROC) (GLuint buffer, GLsizeiptr size, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXSTORAGEMEM1DEXTPROC) (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM1DEXTPROC) (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLuint memory, GLuint64 offset); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetUnsignedBytevEXT (GLenum pname, GLubyte *data); +GLAPI void APIENTRY glGetUnsignedBytei_vEXT (GLenum target, GLuint index, GLubyte *data); +GLAPI void APIENTRY glDeleteMemoryObjectsEXT (GLsizei n, const GLuint *memoryObjects); +GLAPI GLboolean APIENTRY glIsMemoryObjectEXT (GLuint memoryObject); +GLAPI void APIENTRY glCreateMemoryObjectsEXT (GLsizei n, GLuint *memoryObjects); +GLAPI void APIENTRY glMemoryObjectParameterivEXT (GLuint memoryObject, GLenum pname, const GLint *params); +GLAPI void APIENTRY glGetMemoryObjectParameterivEXT (GLuint memoryObject, GLenum pname, GLint *params); +GLAPI void APIENTRY glTexStorageMem2DEXT (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTexStorageMem2DMultisampleEXT (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTexStorageMem3DEXT (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTexStorageMem3DMultisampleEXT (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glBufferStorageMemEXT (GLenum target, GLsizeiptr size, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTextureStorageMem2DEXT (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTextureStorageMem2DMultisampleEXT (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTextureStorageMem3DEXT (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTextureStorageMem3DMultisampleEXT (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glNamedBufferStorageMemEXT (GLuint buffer, GLsizeiptr size, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTexStorageMem1DEXT (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTextureStorageMem1DEXT (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLuint memory, GLuint64 offset); +#endif +#endif /* GL_EXT_memory_object */ + +#ifndef GL_EXT_memory_object_fd +#define GL_EXT_memory_object_fd 1 +#define GL_HANDLE_TYPE_OPAQUE_FD_EXT 0x9586 +typedef void (APIENTRYP PFNGLIMPORTMEMORYFDEXTPROC) (GLuint memory, GLuint64 size, GLenum handleType, GLint fd); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImportMemoryFdEXT (GLuint memory, GLuint64 size, GLenum handleType, GLint fd); +#endif +#endif /* GL_EXT_memory_object_fd */ + +#ifndef GL_EXT_memory_object_win32 +#define GL_EXT_memory_object_win32 1 +#define GL_HANDLE_TYPE_OPAQUE_WIN32_EXT 0x9587 +#define GL_HANDLE_TYPE_OPAQUE_WIN32_KMT_EXT 0x9588 +#define GL_DEVICE_LUID_EXT 0x9599 +#define GL_DEVICE_NODE_MASK_EXT 0x959A +#define GL_LUID_SIZE_EXT 8 +#define GL_HANDLE_TYPE_D3D12_TILEPOOL_EXT 0x9589 +#define GL_HANDLE_TYPE_D3D12_RESOURCE_EXT 0x958A +#define GL_HANDLE_TYPE_D3D11_IMAGE_EXT 0x958B +#define GL_HANDLE_TYPE_D3D11_IMAGE_KMT_EXT 0x958C +typedef void (APIENTRYP PFNGLIMPORTMEMORYWIN32HANDLEEXTPROC) (GLuint memory, GLuint64 size, GLenum handleType, void *handle); +typedef void (APIENTRYP PFNGLIMPORTMEMORYWIN32NAMEEXTPROC) (GLuint memory, GLuint64 size, GLenum handleType, const void *name); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImportMemoryWin32HandleEXT (GLuint memory, GLuint64 size, GLenum handleType, void *handle); +GLAPI void APIENTRY glImportMemoryWin32NameEXT (GLuint memory, GLuint64 size, GLenum handleType, const void *name); +#endif +#endif /* GL_EXT_memory_object_win32 */ + +#ifndef GL_EXT_misc_attribute +#define GL_EXT_misc_attribute 1 +#endif /* GL_EXT_misc_attribute */ + +#ifndef GL_EXT_multi_draw_arrays +#define GL_EXT_multi_draw_arrays 1 +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysEXT (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +GLAPI void APIENTRY glMultiDrawElementsEXT (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount); +#endif +#endif /* GL_EXT_multi_draw_arrays */ + +#ifndef GL_EXT_multisample +#define GL_EXT_multisample 1 +#define GL_MULTISAMPLE_EXT 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F +#define GL_SAMPLE_MASK_EXT 0x80A0 +#define GL_1PASS_EXT 0x80A1 +#define GL_2PASS_0_EXT 0x80A2 +#define GL_2PASS_1_EXT 0x80A3 +#define GL_4PASS_0_EXT 0x80A4 +#define GL_4PASS_1_EXT 0x80A5 +#define GL_4PASS_2_EXT 0x80A6 +#define GL_4PASS_3_EXT 0x80A7 +#define GL_SAMPLE_BUFFERS_EXT 0x80A8 +#define GL_SAMPLES_EXT 0x80A9 +#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA +#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB +#define GL_SAMPLE_PATTERN_EXT 0x80AC +#define GL_MULTISAMPLE_BIT_EXT 0x20000000 +typedef void (APIENTRYP PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleMaskEXT (GLclampf value, GLboolean invert); +GLAPI void APIENTRY glSamplePatternEXT (GLenum pattern); +#endif +#endif /* GL_EXT_multisample */ + +#ifndef GL_EXT_multiview_tessellation_geometry_shader +#define GL_EXT_multiview_tessellation_geometry_shader 1 +#endif /* GL_EXT_multiview_tessellation_geometry_shader */ + +#ifndef GL_EXT_multiview_texture_multisample +#define GL_EXT_multiview_texture_multisample 1 +#endif /* GL_EXT_multiview_texture_multisample */ + +#ifndef GL_EXT_multiview_timer_query +#define GL_EXT_multiview_timer_query 1 +#endif /* GL_EXT_multiview_timer_query */ + +#ifndef GL_EXT_packed_depth_stencil +#define GL_EXT_packed_depth_stencil 1 +#define GL_DEPTH_STENCIL_EXT 0x84F9 +#define GL_UNSIGNED_INT_24_8_EXT 0x84FA +#define GL_DEPTH24_STENCIL8_EXT 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1 +#endif /* GL_EXT_packed_depth_stencil */ + +#ifndef GL_EXT_packed_float +#define GL_EXT_packed_float 1 +#define GL_R11F_G11F_B10F_EXT 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV_EXT 0x8C3B +#define GL_RGBA_SIGNED_COMPONENTS_EXT 0x8C3C +#endif /* GL_EXT_packed_float */ + +#ifndef GL_EXT_packed_pixels +#define GL_EXT_packed_pixels 1 +#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 +#endif /* GL_EXT_packed_pixels */ + +#ifndef GL_EXT_paletted_texture +#define GL_EXT_paletted_texture 1 +#define GL_COLOR_INDEX1_EXT 0x80E2 +#define GL_COLOR_INDEX2_EXT 0x80E3 +#define GL_COLOR_INDEX4_EXT 0x80E4 +#define GL_COLOR_INDEX8_EXT 0x80E5 +#define GL_COLOR_INDEX12_EXT 0x80E6 +#define GL_COLOR_INDEX16_EXT 0x80E7 +#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED +typedef void (APIENTRYP PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const void *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, void *data); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTableEXT (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const void *table); +GLAPI void APIENTRY glGetColorTableEXT (GLenum target, GLenum format, GLenum type, void *data); +GLAPI void APIENTRY glGetColorTableParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetColorTableParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +#endif +#endif /* GL_EXT_paletted_texture */ + +#ifndef GL_EXT_pixel_buffer_object +#define GL_EXT_pixel_buffer_object 1 +#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF +#endif /* GL_EXT_pixel_buffer_object */ + +#ifndef GL_EXT_pixel_transform +#define GL_EXT_pixel_transform 1 +#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 +#define GL_PIXEL_MAG_FILTER_EXT 0x8331 +#define GL_PIXEL_MIN_FILTER_EXT 0x8332 +#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 +#define GL_CUBIC_EXT 0x8334 +#define GL_AVERAGE_EXT 0x8335 +#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 +#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 +#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetPixelTransformParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetPixelTransformParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +#endif +#endif /* GL_EXT_pixel_transform */ + +#ifndef GL_EXT_pixel_transform_color_table +#define GL_EXT_pixel_transform_color_table 1 +#endif /* GL_EXT_pixel_transform_color_table */ + +#ifndef GL_EXT_point_parameters +#define GL_EXT_point_parameters 1 +#define GL_POINT_SIZE_MIN_EXT 0x8126 +#define GL_POINT_SIZE_MAX_EXT 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 +#define GL_DISTANCE_ATTENUATION_EXT 0x8129 +typedef void (APIENTRYP PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfEXT (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfvEXT (GLenum pname, const GLfloat *params); +#endif +#endif /* GL_EXT_point_parameters */ + +#ifndef GL_EXT_polygon_offset +#define GL_EXT_polygon_offset 1 +#define GL_POLYGON_OFFSET_EXT 0x8037 +#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 +#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 +typedef void (APIENTRYP PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPolygonOffsetEXT (GLfloat factor, GLfloat bias); +#endif +#endif /* GL_EXT_polygon_offset */ + +#ifndef GL_EXT_polygon_offset_clamp +#define GL_EXT_polygon_offset_clamp 1 +#define GL_POLYGON_OFFSET_CLAMP_EXT 0x8E1B +typedef void (APIENTRYP PFNGLPOLYGONOFFSETCLAMPEXTPROC) (GLfloat factor, GLfloat units, GLfloat clamp); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPolygonOffsetClampEXT (GLfloat factor, GLfloat units, GLfloat clamp); +#endif +#endif /* GL_EXT_polygon_offset_clamp */ + +#ifndef GL_EXT_post_depth_coverage +#define GL_EXT_post_depth_coverage 1 +#endif /* GL_EXT_post_depth_coverage */ + +#ifndef GL_EXT_provoking_vertex +#define GL_EXT_provoking_vertex 1 +#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT 0x8E4C +#define GL_FIRST_VERTEX_CONVENTION_EXT 0x8E4D +#define GL_LAST_VERTEX_CONVENTION_EXT 0x8E4E +#define GL_PROVOKING_VERTEX_EXT 0x8E4F +typedef void (APIENTRYP PFNGLPROVOKINGVERTEXEXTPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProvokingVertexEXT (GLenum mode); +#endif +#endif /* GL_EXT_provoking_vertex */ + +#ifndef GL_EXT_raster_multisample +#define GL_EXT_raster_multisample 1 +#define GL_RASTER_MULTISAMPLE_EXT 0x9327 +#define GL_RASTER_SAMPLES_EXT 0x9328 +#define GL_MAX_RASTER_SAMPLES_EXT 0x9329 +#define GL_RASTER_FIXED_SAMPLE_LOCATIONS_EXT 0x932A +#define GL_MULTISAMPLE_RASTERIZATION_ALLOWED_EXT 0x932B +#define GL_EFFECTIVE_RASTER_SAMPLES_EXT 0x932C +typedef void (APIENTRYP PFNGLRASTERSAMPLESEXTPROC) (GLuint samples, GLboolean fixedsamplelocations); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRasterSamplesEXT (GLuint samples, GLboolean fixedsamplelocations); +#endif +#endif /* GL_EXT_raster_multisample */ + +#ifndef GL_EXT_rescale_normal +#define GL_EXT_rescale_normal 1 +#define GL_RESCALE_NORMAL_EXT 0x803A +#endif /* GL_EXT_rescale_normal */ + +#ifndef GL_EXT_secondary_color +#define GL_EXT_secondary_color 1 +#define GL_COLOR_SUM_EXT 0x8458 +#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D +#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSecondaryColor3bEXT (GLbyte red, GLbyte green, GLbyte blue); +GLAPI void APIENTRY glSecondaryColor3bvEXT (const GLbyte *v); +GLAPI void APIENTRY glSecondaryColor3dEXT (GLdouble red, GLdouble green, GLdouble blue); +GLAPI void APIENTRY glSecondaryColor3dvEXT (const GLdouble *v); +GLAPI void APIENTRY glSecondaryColor3fEXT (GLfloat red, GLfloat green, GLfloat blue); +GLAPI void APIENTRY glSecondaryColor3fvEXT (const GLfloat *v); +GLAPI void APIENTRY glSecondaryColor3iEXT (GLint red, GLint green, GLint blue); +GLAPI void APIENTRY glSecondaryColor3ivEXT (const GLint *v); +GLAPI void APIENTRY glSecondaryColor3sEXT (GLshort red, GLshort green, GLshort blue); +GLAPI void APIENTRY glSecondaryColor3svEXT (const GLshort *v); +GLAPI void APIENTRY glSecondaryColor3ubEXT (GLubyte red, GLubyte green, GLubyte blue); +GLAPI void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *v); +GLAPI void APIENTRY glSecondaryColor3uiEXT (GLuint red, GLuint green, GLuint blue); +GLAPI void APIENTRY glSecondaryColor3uivEXT (const GLuint *v); +GLAPI void APIENTRY glSecondaryColor3usEXT (GLushort red, GLushort green, GLushort blue); +GLAPI void APIENTRY glSecondaryColor3usvEXT (const GLushort *v); +GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint size, GLenum type, GLsizei stride, const void *pointer); +#endif +#endif /* GL_EXT_secondary_color */ + +#ifndef GL_EXT_semaphore +#define GL_EXT_semaphore 1 +#define GL_LAYOUT_GENERAL_EXT 0x958D +#define GL_LAYOUT_COLOR_ATTACHMENT_EXT 0x958E +#define GL_LAYOUT_DEPTH_STENCIL_ATTACHMENT_EXT 0x958F +#define GL_LAYOUT_DEPTH_STENCIL_READ_ONLY_EXT 0x9590 +#define GL_LAYOUT_SHADER_READ_ONLY_EXT 0x9591 +#define GL_LAYOUT_TRANSFER_SRC_EXT 0x9592 +#define GL_LAYOUT_TRANSFER_DST_EXT 0x9593 +#define GL_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_EXT 0x9530 +#define GL_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_EXT 0x9531 +typedef void (APIENTRYP PFNGLGENSEMAPHORESEXTPROC) (GLsizei n, GLuint *semaphores); +typedef void (APIENTRYP PFNGLDELETESEMAPHORESEXTPROC) (GLsizei n, const GLuint *semaphores); +typedef GLboolean (APIENTRYP PFNGLISSEMAPHOREEXTPROC) (GLuint semaphore); +typedef void (APIENTRYP PFNGLSEMAPHOREPARAMETERUI64VEXTPROC) (GLuint semaphore, GLenum pname, const GLuint64 *params); +typedef void (APIENTRYP PFNGLGETSEMAPHOREPARAMETERUI64VEXTPROC) (GLuint semaphore, GLenum pname, GLuint64 *params); +typedef void (APIENTRYP PFNGLWAITSEMAPHOREEXTPROC) (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *srcLayouts); +typedef void (APIENTRYP PFNGLSIGNALSEMAPHOREEXTPROC) (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *dstLayouts); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenSemaphoresEXT (GLsizei n, GLuint *semaphores); +GLAPI void APIENTRY glDeleteSemaphoresEXT (GLsizei n, const GLuint *semaphores); +GLAPI GLboolean APIENTRY glIsSemaphoreEXT (GLuint semaphore); +GLAPI void APIENTRY glSemaphoreParameterui64vEXT (GLuint semaphore, GLenum pname, const GLuint64 *params); +GLAPI void APIENTRY glGetSemaphoreParameterui64vEXT (GLuint semaphore, GLenum pname, GLuint64 *params); +GLAPI void APIENTRY glWaitSemaphoreEXT (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *srcLayouts); +GLAPI void APIENTRY glSignalSemaphoreEXT (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *dstLayouts); +#endif +#endif /* GL_EXT_semaphore */ + +#ifndef GL_EXT_semaphore_fd +#define GL_EXT_semaphore_fd 1 +typedef void (APIENTRYP PFNGLIMPORTSEMAPHOREFDEXTPROC) (GLuint semaphore, GLenum handleType, GLint fd); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImportSemaphoreFdEXT (GLuint semaphore, GLenum handleType, GLint fd); +#endif +#endif /* GL_EXT_semaphore_fd */ + +#ifndef GL_EXT_semaphore_win32 +#define GL_EXT_semaphore_win32 1 +#define GL_HANDLE_TYPE_D3D12_FENCE_EXT 0x9594 +#define GL_D3D12_FENCE_VALUE_EXT 0x9595 +typedef void (APIENTRYP PFNGLIMPORTSEMAPHOREWIN32HANDLEEXTPROC) (GLuint semaphore, GLenum handleType, void *handle); +typedef void (APIENTRYP PFNGLIMPORTSEMAPHOREWIN32NAMEEXTPROC) (GLuint semaphore, GLenum handleType, const void *name); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImportSemaphoreWin32HandleEXT (GLuint semaphore, GLenum handleType, void *handle); +GLAPI void APIENTRY glImportSemaphoreWin32NameEXT (GLuint semaphore, GLenum handleType, const void *name); +#endif +#endif /* GL_EXT_semaphore_win32 */ + +#ifndef GL_EXT_separate_shader_objects +#define GL_EXT_separate_shader_objects 1 +#define GL_ACTIVE_PROGRAM_EXT 0x8B8D +typedef void (APIENTRYP PFNGLUSESHADERPROGRAMEXTPROC) (GLenum type, GLuint program); +typedef void (APIENTRYP PFNGLACTIVEPROGRAMEXTPROC) (GLuint program); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMEXTPROC) (GLenum type, const GLchar *string); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUseShaderProgramEXT (GLenum type, GLuint program); +GLAPI void APIENTRY glActiveProgramEXT (GLuint program); +GLAPI GLuint APIENTRY glCreateShaderProgramEXT (GLenum type, const GLchar *string); +#endif +#endif /* GL_EXT_separate_shader_objects */ + +#ifndef GL_EXT_separate_specular_color +#define GL_EXT_separate_specular_color 1 +#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 +#define GL_SINGLE_COLOR_EXT 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA +#endif /* GL_EXT_separate_specular_color */ + +#ifndef GL_EXT_shader_framebuffer_fetch +#define GL_EXT_shader_framebuffer_fetch 1 +#define GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT 0x8A52 +#endif /* GL_EXT_shader_framebuffer_fetch */ + +#ifndef GL_EXT_shader_framebuffer_fetch_non_coherent +#define GL_EXT_shader_framebuffer_fetch_non_coherent 1 +typedef void (APIENTRYP PFNGLFRAMEBUFFERFETCHBARRIEREXTPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferFetchBarrierEXT (void); +#endif +#endif /* GL_EXT_shader_framebuffer_fetch_non_coherent */ + +#ifndef GL_EXT_shader_image_load_formatted +#define GL_EXT_shader_image_load_formatted 1 +#endif /* GL_EXT_shader_image_load_formatted */ + +#ifndef GL_EXT_shader_image_load_store +#define GL_EXT_shader_image_load_store 1 +#define GL_MAX_IMAGE_UNITS_EXT 0x8F38 +#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS_EXT 0x8F39 +#define GL_IMAGE_BINDING_NAME_EXT 0x8F3A +#define GL_IMAGE_BINDING_LEVEL_EXT 0x8F3B +#define GL_IMAGE_BINDING_LAYERED_EXT 0x8F3C +#define GL_IMAGE_BINDING_LAYER_EXT 0x8F3D +#define GL_IMAGE_BINDING_ACCESS_EXT 0x8F3E +#define GL_IMAGE_1D_EXT 0x904C +#define GL_IMAGE_2D_EXT 0x904D +#define GL_IMAGE_3D_EXT 0x904E +#define GL_IMAGE_2D_RECT_EXT 0x904F +#define GL_IMAGE_CUBE_EXT 0x9050 +#define GL_IMAGE_BUFFER_EXT 0x9051 +#define GL_IMAGE_1D_ARRAY_EXT 0x9052 +#define GL_IMAGE_2D_ARRAY_EXT 0x9053 +#define GL_IMAGE_CUBE_MAP_ARRAY_EXT 0x9054 +#define GL_IMAGE_2D_MULTISAMPLE_EXT 0x9055 +#define GL_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9056 +#define GL_INT_IMAGE_1D_EXT 0x9057 +#define GL_INT_IMAGE_2D_EXT 0x9058 +#define GL_INT_IMAGE_3D_EXT 0x9059 +#define GL_INT_IMAGE_2D_RECT_EXT 0x905A +#define GL_INT_IMAGE_CUBE_EXT 0x905B +#define GL_INT_IMAGE_BUFFER_EXT 0x905C +#define GL_INT_IMAGE_1D_ARRAY_EXT 0x905D +#define GL_INT_IMAGE_2D_ARRAY_EXT 0x905E +#define GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x905F +#define GL_INT_IMAGE_2D_MULTISAMPLE_EXT 0x9060 +#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9061 +#define GL_UNSIGNED_INT_IMAGE_1D_EXT 0x9062 +#define GL_UNSIGNED_INT_IMAGE_2D_EXT 0x9063 +#define GL_UNSIGNED_INT_IMAGE_3D_EXT 0x9064 +#define GL_UNSIGNED_INT_IMAGE_2D_RECT_EXT 0x9065 +#define GL_UNSIGNED_INT_IMAGE_CUBE_EXT 0x9066 +#define GL_UNSIGNED_INT_IMAGE_BUFFER_EXT 0x9067 +#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY_EXT 0x9068 +#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY_EXT 0x9069 +#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x906A +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_EXT 0x906B +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x906C +#define GL_MAX_IMAGE_SAMPLES_EXT 0x906D +#define GL_IMAGE_BINDING_FORMAT_EXT 0x906E +#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT_EXT 0x00000001 +#define GL_ELEMENT_ARRAY_BARRIER_BIT_EXT 0x00000002 +#define GL_UNIFORM_BARRIER_BIT_EXT 0x00000004 +#define GL_TEXTURE_FETCH_BARRIER_BIT_EXT 0x00000008 +#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT_EXT 0x00000020 +#define GL_COMMAND_BARRIER_BIT_EXT 0x00000040 +#define GL_PIXEL_BUFFER_BARRIER_BIT_EXT 0x00000080 +#define GL_TEXTURE_UPDATE_BARRIER_BIT_EXT 0x00000100 +#define GL_BUFFER_UPDATE_BARRIER_BIT_EXT 0x00000200 +#define GL_FRAMEBUFFER_BARRIER_BIT_EXT 0x00000400 +#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT_EXT 0x00000800 +#define GL_ATOMIC_COUNTER_BARRIER_BIT_EXT 0x00001000 +#define GL_ALL_BARRIER_BITS_EXT 0xFFFFFFFF +typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREEXTPROC) (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); +typedef void (APIENTRYP PFNGLMEMORYBARRIEREXTPROC) (GLbitfield barriers); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindImageTextureEXT (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); +GLAPI void APIENTRY glMemoryBarrierEXT (GLbitfield barriers); +#endif +#endif /* GL_EXT_shader_image_load_store */ + +#ifndef GL_EXT_shader_integer_mix +#define GL_EXT_shader_integer_mix 1 +#endif /* GL_EXT_shader_integer_mix */ + +#ifndef GL_EXT_shader_samples_identical +#define GL_EXT_shader_samples_identical 1 +#endif /* GL_EXT_shader_samples_identical */ + +#ifndef GL_EXT_shadow_funcs +#define GL_EXT_shadow_funcs 1 +#endif /* GL_EXT_shadow_funcs */ + +#ifndef GL_EXT_shared_texture_palette +#define GL_EXT_shared_texture_palette 1 +#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB +#endif /* GL_EXT_shared_texture_palette */ + +#ifndef GL_EXT_sparse_texture2 +#define GL_EXT_sparse_texture2 1 +#endif /* GL_EXT_sparse_texture2 */ + +#ifndef GL_EXT_stencil_clear_tag +#define GL_EXT_stencil_clear_tag 1 +#define GL_STENCIL_TAG_BITS_EXT 0x88F2 +#define GL_STENCIL_CLEAR_TAG_VALUE_EXT 0x88F3 +typedef void (APIENTRYP PFNGLSTENCILCLEARTAGEXTPROC) (GLsizei stencilTagBits, GLuint stencilClearTag); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilClearTagEXT (GLsizei stencilTagBits, GLuint stencilClearTag); +#endif +#endif /* GL_EXT_stencil_clear_tag */ + +#ifndef GL_EXT_stencil_two_side +#define GL_EXT_stencil_two_side 1 +#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 +#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 +typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveStencilFaceEXT (GLenum face); +#endif +#endif /* GL_EXT_stencil_two_side */ + +#ifndef GL_EXT_stencil_wrap +#define GL_EXT_stencil_wrap 1 +#define GL_INCR_WRAP_EXT 0x8507 +#define GL_DECR_WRAP_EXT 0x8508 +#endif /* GL_EXT_stencil_wrap */ + +#ifndef GL_EXT_subtexture +#define GL_EXT_subtexture 1 +typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +#endif +#endif /* GL_EXT_subtexture */ + +#ifndef GL_EXT_texture +#define GL_EXT_texture 1 +#define GL_ALPHA4_EXT 0x803B +#define GL_ALPHA8_EXT 0x803C +#define GL_ALPHA12_EXT 0x803D +#define GL_ALPHA16_EXT 0x803E +#define GL_LUMINANCE4_EXT 0x803F +#define GL_LUMINANCE8_EXT 0x8040 +#define GL_LUMINANCE12_EXT 0x8041 +#define GL_LUMINANCE16_EXT 0x8042 +#define GL_LUMINANCE4_ALPHA4_EXT 0x8043 +#define GL_LUMINANCE6_ALPHA2_EXT 0x8044 +#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 +#define GL_LUMINANCE12_ALPHA4_EXT 0x8046 +#define GL_LUMINANCE12_ALPHA12_EXT 0x8047 +#define GL_LUMINANCE16_ALPHA16_EXT 0x8048 +#define GL_INTENSITY_EXT 0x8049 +#define GL_INTENSITY4_EXT 0x804A +#define GL_INTENSITY8_EXT 0x804B +#define GL_INTENSITY12_EXT 0x804C +#define GL_INTENSITY16_EXT 0x804D +#define GL_RGB2_EXT 0x804E +#define GL_RGB4_EXT 0x804F +#define GL_RGB5_EXT 0x8050 +#define GL_RGB8_EXT 0x8051 +#define GL_RGB10_EXT 0x8052 +#define GL_RGB12_EXT 0x8053 +#define GL_RGB16_EXT 0x8054 +#define GL_RGBA2_EXT 0x8055 +#define GL_RGBA4_EXT 0x8056 +#define GL_RGB5_A1_EXT 0x8057 +#define GL_RGBA8_EXT 0x8058 +#define GL_RGB10_A2_EXT 0x8059 +#define GL_RGBA12_EXT 0x805A +#define GL_RGBA16_EXT 0x805B +#define GL_TEXTURE_RED_SIZE_EXT 0x805C +#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D +#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E +#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F +#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 +#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 +#define GL_REPLACE_EXT 0x8062 +#define GL_PROXY_TEXTURE_1D_EXT 0x8063 +#define GL_PROXY_TEXTURE_2D_EXT 0x8064 +#define GL_TEXTURE_TOO_LARGE_EXT 0x8065 +#endif /* GL_EXT_texture */ + +#ifndef GL_EXT_texture3D +#define GL_EXT_texture3D 1 +#define GL_PACK_SKIP_IMAGES_EXT 0x806B +#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C +#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D +#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E +#define GL_TEXTURE_3D_EXT 0x806F +#define GL_PROXY_TEXTURE_3D_EXT 0x8070 +#define GL_TEXTURE_DEPTH_EXT 0x8071 +#define GL_TEXTURE_WRAP_R_EXT 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 +typedef void (APIENTRYP PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage3DEXT (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +#endif +#endif /* GL_EXT_texture3D */ + +#ifndef GL_EXT_texture_array +#define GL_EXT_texture_array 1 +#define GL_TEXTURE_1D_ARRAY_EXT 0x8C18 +#define GL_PROXY_TEXTURE_1D_ARRAY_EXT 0x8C19 +#define GL_TEXTURE_2D_ARRAY_EXT 0x8C1A +#define GL_PROXY_TEXTURE_2D_ARRAY_EXT 0x8C1B +#define GL_TEXTURE_BINDING_1D_ARRAY_EXT 0x8C1C +#define GL_TEXTURE_BINDING_2D_ARRAY_EXT 0x8C1D +#define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF +#define GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT 0x884E +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferTextureLayerEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +#endif +#endif /* GL_EXT_texture_array */ + +#ifndef GL_EXT_texture_buffer_object +#define GL_EXT_texture_buffer_object 1 +#define GL_TEXTURE_BUFFER_EXT 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT_EXT 0x8C2E +typedef void (APIENTRYP PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBufferEXT (GLenum target, GLenum internalformat, GLuint buffer); +#endif +#endif /* GL_EXT_texture_buffer_object */ + +#ifndef GL_EXT_texture_compression_latc +#define GL_EXT_texture_compression_latc 1 +#define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70 +#define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71 +#define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72 +#define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73 +#endif /* GL_EXT_texture_compression_latc */ + +#ifndef GL_EXT_texture_compression_rgtc +#define GL_EXT_texture_compression_rgtc 1 +#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC +#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD +#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE +#endif /* GL_EXT_texture_compression_rgtc */ + +#ifndef GL_EXT_texture_compression_s3tc +#define GL_EXT_texture_compression_s3tc 1 +#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 +#endif /* GL_EXT_texture_compression_s3tc */ + +#ifndef GL_EXT_texture_cube_map +#define GL_EXT_texture_cube_map 1 +#define GL_NORMAL_MAP_EXT 0x8511 +#define GL_REFLECTION_MAP_EXT 0x8512 +#define GL_TEXTURE_CUBE_MAP_EXT 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C +#endif /* GL_EXT_texture_cube_map */ + +#ifndef GL_EXT_texture_env_add +#define GL_EXT_texture_env_add 1 +#endif /* GL_EXT_texture_env_add */ + +#ifndef GL_EXT_texture_env_combine +#define GL_EXT_texture_env_combine 1 +#define GL_COMBINE_EXT 0x8570 +#define GL_COMBINE_RGB_EXT 0x8571 +#define GL_COMBINE_ALPHA_EXT 0x8572 +#define GL_RGB_SCALE_EXT 0x8573 +#define GL_ADD_SIGNED_EXT 0x8574 +#define GL_INTERPOLATE_EXT 0x8575 +#define GL_CONSTANT_EXT 0x8576 +#define GL_PRIMARY_COLOR_EXT 0x8577 +#define GL_PREVIOUS_EXT 0x8578 +#define GL_SOURCE0_RGB_EXT 0x8580 +#define GL_SOURCE1_RGB_EXT 0x8581 +#define GL_SOURCE2_RGB_EXT 0x8582 +#define GL_SOURCE0_ALPHA_EXT 0x8588 +#define GL_SOURCE1_ALPHA_EXT 0x8589 +#define GL_SOURCE2_ALPHA_EXT 0x858A +#define GL_OPERAND0_RGB_EXT 0x8590 +#define GL_OPERAND1_RGB_EXT 0x8591 +#define GL_OPERAND2_RGB_EXT 0x8592 +#define GL_OPERAND0_ALPHA_EXT 0x8598 +#define GL_OPERAND1_ALPHA_EXT 0x8599 +#define GL_OPERAND2_ALPHA_EXT 0x859A +#endif /* GL_EXT_texture_env_combine */ + +#ifndef GL_EXT_texture_env_dot3 +#define GL_EXT_texture_env_dot3 1 +#define GL_DOT3_RGB_EXT 0x8740 +#define GL_DOT3_RGBA_EXT 0x8741 +#endif /* GL_EXT_texture_env_dot3 */ + +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_EXT_texture_filter_anisotropic 1 +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF +#endif /* GL_EXT_texture_filter_anisotropic */ + +#ifndef GL_EXT_texture_filter_minmax +#define GL_EXT_texture_filter_minmax 1 +#define GL_TEXTURE_REDUCTION_MODE_EXT 0x9366 +#define GL_WEIGHTED_AVERAGE_EXT 0x9367 +#endif /* GL_EXT_texture_filter_minmax */ + +#ifndef GL_EXT_texture_integer +#define GL_EXT_texture_integer 1 +#define GL_RGBA32UI_EXT 0x8D70 +#define GL_RGB32UI_EXT 0x8D71 +#define GL_ALPHA32UI_EXT 0x8D72 +#define GL_INTENSITY32UI_EXT 0x8D73 +#define GL_LUMINANCE32UI_EXT 0x8D74 +#define GL_LUMINANCE_ALPHA32UI_EXT 0x8D75 +#define GL_RGBA16UI_EXT 0x8D76 +#define GL_RGB16UI_EXT 0x8D77 +#define GL_ALPHA16UI_EXT 0x8D78 +#define GL_INTENSITY16UI_EXT 0x8D79 +#define GL_LUMINANCE16UI_EXT 0x8D7A +#define GL_LUMINANCE_ALPHA16UI_EXT 0x8D7B +#define GL_RGBA8UI_EXT 0x8D7C +#define GL_RGB8UI_EXT 0x8D7D +#define GL_ALPHA8UI_EXT 0x8D7E +#define GL_INTENSITY8UI_EXT 0x8D7F +#define GL_LUMINANCE8UI_EXT 0x8D80 +#define GL_LUMINANCE_ALPHA8UI_EXT 0x8D81 +#define GL_RGBA32I_EXT 0x8D82 +#define GL_RGB32I_EXT 0x8D83 +#define GL_ALPHA32I_EXT 0x8D84 +#define GL_INTENSITY32I_EXT 0x8D85 +#define GL_LUMINANCE32I_EXT 0x8D86 +#define GL_LUMINANCE_ALPHA32I_EXT 0x8D87 +#define GL_RGBA16I_EXT 0x8D88 +#define GL_RGB16I_EXT 0x8D89 +#define GL_ALPHA16I_EXT 0x8D8A +#define GL_INTENSITY16I_EXT 0x8D8B +#define GL_LUMINANCE16I_EXT 0x8D8C +#define GL_LUMINANCE_ALPHA16I_EXT 0x8D8D +#define GL_RGBA8I_EXT 0x8D8E +#define GL_RGB8I_EXT 0x8D8F +#define GL_ALPHA8I_EXT 0x8D90 +#define GL_INTENSITY8I_EXT 0x8D91 +#define GL_LUMINANCE8I_EXT 0x8D92 +#define GL_LUMINANCE_ALPHA8I_EXT 0x8D93 +#define GL_RED_INTEGER_EXT 0x8D94 +#define GL_GREEN_INTEGER_EXT 0x8D95 +#define GL_BLUE_INTEGER_EXT 0x8D96 +#define GL_ALPHA_INTEGER_EXT 0x8D97 +#define GL_RGB_INTEGER_EXT 0x8D98 +#define GL_RGBA_INTEGER_EXT 0x8D99 +#define GL_BGR_INTEGER_EXT 0x8D9A +#define GL_BGRA_INTEGER_EXT 0x8D9B +#define GL_LUMINANCE_INTEGER_EXT 0x8D9C +#define GL_LUMINANCE_ALPHA_INTEGER_EXT 0x8D9D +#define GL_RGBA_INTEGER_MODE_EXT 0x8D9E +typedef void (APIENTRYP PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLCLEARCOLORIIEXTPROC) (GLint red, GLint green, GLint blue, GLint alpha); +typedef void (APIENTRYP PFNGLCLEARCOLORIUIEXTPROC) (GLuint red, GLuint green, GLuint blue, GLuint alpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexParameterIivEXT (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTexParameterIuivEXT (GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTexParameterIivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTexParameterIuivEXT (GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glClearColorIiEXT (GLint red, GLint green, GLint blue, GLint alpha); +GLAPI void APIENTRY glClearColorIuiEXT (GLuint red, GLuint green, GLuint blue, GLuint alpha); +#endif +#endif /* GL_EXT_texture_integer */ + +#ifndef GL_EXT_texture_lod_bias +#define GL_EXT_texture_lod_bias 1 +#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD +#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 +#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 +#endif /* GL_EXT_texture_lod_bias */ + +#ifndef GL_EXT_texture_mirror_clamp +#define GL_EXT_texture_mirror_clamp 1 +#define GL_MIRROR_CLAMP_EXT 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 +#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 +#endif /* GL_EXT_texture_mirror_clamp */ + +#ifndef GL_EXT_texture_object +#define GL_EXT_texture_object 1 +#define GL_TEXTURE_PRIORITY_EXT 0x8066 +#define GL_TEXTURE_RESIDENT_EXT 0x8067 +#define GL_TEXTURE_1D_BINDING_EXT 0x8068 +#define GL_TEXTURE_2D_BINDING_EXT 0x8069 +#define GL_TEXTURE_3D_BINDING_EXT 0x806A +typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences); +typedef void (APIENTRYP PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures); +typedef void (APIENTRYP PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREEXTPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei n, const GLuint *textures, GLboolean *residences); +GLAPI void APIENTRY glBindTextureEXT (GLenum target, GLuint texture); +GLAPI void APIENTRY glDeleteTexturesEXT (GLsizei n, const GLuint *textures); +GLAPI void APIENTRY glGenTexturesEXT (GLsizei n, GLuint *textures); +GLAPI GLboolean APIENTRY glIsTextureEXT (GLuint texture); +GLAPI void APIENTRY glPrioritizeTexturesEXT (GLsizei n, const GLuint *textures, const GLclampf *priorities); +#endif +#endif /* GL_EXT_texture_object */ + +#ifndef GL_EXT_texture_perturb_normal +#define GL_EXT_texture_perturb_normal 1 +#define GL_PERTURB_EXT 0x85AE +#define GL_TEXTURE_NORMAL_EXT 0x85AF +typedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureNormalEXT (GLenum mode); +#endif +#endif /* GL_EXT_texture_perturb_normal */ + +#ifndef GL_EXT_texture_sRGB +#define GL_EXT_texture_sRGB 1 +#define GL_SRGB_EXT 0x8C40 +#define GL_SRGB8_EXT 0x8C41 +#define GL_SRGB_ALPHA_EXT 0x8C42 +#define GL_SRGB8_ALPHA8_EXT 0x8C43 +#define GL_SLUMINANCE_ALPHA_EXT 0x8C44 +#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45 +#define GL_SLUMINANCE_EXT 0x8C46 +#define GL_SLUMINANCE8_EXT 0x8C47 +#define GL_COMPRESSED_SRGB_EXT 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49 +#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A +#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B +#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F +#endif /* GL_EXT_texture_sRGB */ + +#ifndef GL_EXT_texture_sRGB_R8 +#define GL_EXT_texture_sRGB_R8 1 +#define GL_SR8_EXT 0x8FBD +#endif /* GL_EXT_texture_sRGB_R8 */ + +#ifndef GL_EXT_texture_sRGB_RG8 +#define GL_EXT_texture_sRGB_RG8 1 +#define GL_SRG8_EXT 0x8FBE +#endif /* GL_EXT_texture_sRGB_RG8 */ + +#ifndef GL_EXT_texture_sRGB_decode +#define GL_EXT_texture_sRGB_decode 1 +#define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48 +#define GL_DECODE_EXT 0x8A49 +#define GL_SKIP_DECODE_EXT 0x8A4A +#endif /* GL_EXT_texture_sRGB_decode */ + +#ifndef GL_EXT_texture_shadow_lod +#define GL_EXT_texture_shadow_lod 1 +#endif /* GL_EXT_texture_shadow_lod */ + +#ifndef GL_EXT_texture_shared_exponent +#define GL_EXT_texture_shared_exponent 1 +#define GL_RGB9_E5_EXT 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV_EXT 0x8C3E +#define GL_TEXTURE_SHARED_SIZE_EXT 0x8C3F +#endif /* GL_EXT_texture_shared_exponent */ + +#ifndef GL_EXT_texture_snorm +#define GL_EXT_texture_snorm 1 +#define GL_ALPHA_SNORM 0x9010 +#define GL_LUMINANCE_SNORM 0x9011 +#define GL_LUMINANCE_ALPHA_SNORM 0x9012 +#define GL_INTENSITY_SNORM 0x9013 +#define GL_ALPHA8_SNORM 0x9014 +#define GL_LUMINANCE8_SNORM 0x9015 +#define GL_LUMINANCE8_ALPHA8_SNORM 0x9016 +#define GL_INTENSITY8_SNORM 0x9017 +#define GL_ALPHA16_SNORM 0x9018 +#define GL_LUMINANCE16_SNORM 0x9019 +#define GL_LUMINANCE16_ALPHA16_SNORM 0x901A +#define GL_INTENSITY16_SNORM 0x901B +#define GL_RED_SNORM 0x8F90 +#define GL_RG_SNORM 0x8F91 +#define GL_RGB_SNORM 0x8F92 +#define GL_RGBA_SNORM 0x8F93 +#endif /* GL_EXT_texture_snorm */ + +#ifndef GL_EXT_texture_storage +#define GL_EXT_texture_storage 1 +#define GL_TEXTURE_IMMUTABLE_FORMAT_EXT 0x912F +#define GL_RGBA32F_EXT 0x8814 +#define GL_RGB32F_EXT 0x8815 +#define GL_ALPHA32F_EXT 0x8816 +#define GL_LUMINANCE32F_EXT 0x8818 +#define GL_LUMINANCE_ALPHA32F_EXT 0x8819 +#define GL_RGBA16F_EXT 0x881A +#define GL_RGB16F_EXT 0x881B +#define GL_ALPHA16F_EXT 0x881C +#define GL_LUMINANCE16F_EXT 0x881E +#define GL_LUMINANCE_ALPHA16F_EXT 0x881F +#define GL_BGRA8_EXT 0x93A1 +#define GL_R8_EXT 0x8229 +#define GL_RG8_EXT 0x822B +#define GL_R32F_EXT 0x822E +#define GL_RG32F_EXT 0x8230 +#define GL_R16F_EXT 0x822D +#define GL_RG16F_EXT 0x822F +typedef void (APIENTRYP PFNGLTEXSTORAGE1DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (APIENTRYP PFNGLTEXSTORAGE2DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXSTORAGE3DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexStorage1DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +GLAPI void APIENTRY glTexStorage2DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTexStorage3DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +#endif +#endif /* GL_EXT_texture_storage */ + +#ifndef GL_EXT_texture_swizzle +#define GL_EXT_texture_swizzle 1 +#define GL_TEXTURE_SWIZZLE_R_EXT 0x8E42 +#define GL_TEXTURE_SWIZZLE_G_EXT 0x8E43 +#define GL_TEXTURE_SWIZZLE_B_EXT 0x8E44 +#define GL_TEXTURE_SWIZZLE_A_EXT 0x8E45 +#define GL_TEXTURE_SWIZZLE_RGBA_EXT 0x8E46 +#endif /* GL_EXT_texture_swizzle */ + +#ifndef GL_EXT_timer_query +#define GL_EXT_timer_query 1 +#define GL_TIME_ELAPSED_EXT 0x88BF +typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64 *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetQueryObjecti64vEXT (GLuint id, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glGetQueryObjectui64vEXT (GLuint id, GLenum pname, GLuint64 *params); +#endif +#endif /* GL_EXT_timer_query */ + +#ifndef GL_EXT_transform_feedback +#define GL_EXT_transform_feedback 1 +#define GL_TRANSFORM_FEEDBACK_BUFFER_EXT 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT 0x8C85 +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT 0x8C8F +#define GL_INTERLEAVED_ATTRIBS_EXT 0x8C8C +#define GL_SEPARATE_ATTRIBS_EXT 0x8C8D +#define GL_PRIMITIVES_GENERATED_EXT 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT 0x8C88 +#define GL_RASTERIZER_DISCARD_EXT 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT 0x8C8B +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS_EXT 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT 0x8C7F +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT 0x8C76 +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKEXTPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKEXTPROC) (void); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGEEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +typedef void (APIENTRYP PFNGLBINDBUFFERBASEEXTPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC) (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginTransformFeedbackEXT (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedbackEXT (void); +GLAPI void APIENTRY glBindBufferRangeEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferOffsetEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +GLAPI void APIENTRY glBindBufferBaseEXT (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryingsEXT (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +GLAPI void APIENTRY glGetTransformFeedbackVaryingEXT (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +#endif +#endif /* GL_EXT_transform_feedback */ + +#ifndef GL_EXT_vertex_array +#define GL_EXT_vertex_array 1 +#define GL_VERTEX_ARRAY_EXT 0x8074 +#define GL_NORMAL_ARRAY_EXT 0x8075 +#define GL_COLOR_ARRAY_EXT 0x8076 +#define GL_INDEX_ARRAY_EXT 0x8077 +#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 +#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 +#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A +#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B +#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C +#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D +#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E +#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F +#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 +#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 +#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 +#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 +#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 +#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 +#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 +#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 +#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 +#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 +#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A +#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B +#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C +#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D +#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E +#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F +#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 +#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 +#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 +#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 +typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC) (GLint i); +typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer); +typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC) (GLenum pname, void **params); +typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const void *pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const void *pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glArrayElementEXT (GLint i); +GLAPI void APIENTRY glColorPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +GLAPI void APIENTRY glDrawArraysEXT (GLenum mode, GLint first, GLsizei count); +GLAPI void APIENTRY glEdgeFlagPointerEXT (GLsizei stride, GLsizei count, const GLboolean *pointer); +GLAPI void APIENTRY glGetPointervEXT (GLenum pname, void **params); +GLAPI void APIENTRY glIndexPointerEXT (GLenum type, GLsizei stride, GLsizei count, const void *pointer); +GLAPI void APIENTRY glNormalPointerEXT (GLenum type, GLsizei stride, GLsizei count, const void *pointer); +GLAPI void APIENTRY glTexCoordPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +GLAPI void APIENTRY glVertexPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +#endif +#endif /* GL_EXT_vertex_array */ + +#ifndef GL_EXT_vertex_array_bgra +#define GL_EXT_vertex_array_bgra 1 +#endif /* GL_EXT_vertex_array_bgra */ + +#ifndef GL_EXT_vertex_attrib_64bit +#define GL_EXT_vertex_attrib_64bit 1 +#define GL_DOUBLE_VEC2_EXT 0x8FFC +#define GL_DOUBLE_VEC3_EXT 0x8FFD +#define GL_DOUBLE_VEC4_EXT 0x8FFE +#define GL_DOUBLE_MAT2_EXT 0x8F46 +#define GL_DOUBLE_MAT3_EXT 0x8F47 +#define GL_DOUBLE_MAT4_EXT 0x8F48 +#define GL_DOUBLE_MAT2x3_EXT 0x8F49 +#define GL_DOUBLE_MAT2x4_EXT 0x8F4A +#define GL_DOUBLE_MAT3x2_EXT 0x8F4B +#define GL_DOUBLE_MAT3x4_EXT 0x8F4C +#define GL_DOUBLE_MAT4x2_EXT 0x8F4D +#define GL_DOUBLE_MAT4x3_EXT 0x8F4E +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DEXTPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DEXTPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVEXTPROC) (GLuint index, GLenum pname, GLdouble *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribL1dEXT (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttribL2dEXT (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttribL3dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttribL4dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttribL1dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL2dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL3dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL4dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribLPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glGetVertexAttribLdvEXT (GLuint index, GLenum pname, GLdouble *params); +#endif +#endif /* GL_EXT_vertex_attrib_64bit */ + +#ifndef GL_EXT_vertex_shader +#define GL_EXT_vertex_shader 1 +#define GL_VERTEX_SHADER_EXT 0x8780 +#define GL_VERTEX_SHADER_BINDING_EXT 0x8781 +#define GL_OP_INDEX_EXT 0x8782 +#define GL_OP_NEGATE_EXT 0x8783 +#define GL_OP_DOT3_EXT 0x8784 +#define GL_OP_DOT4_EXT 0x8785 +#define GL_OP_MUL_EXT 0x8786 +#define GL_OP_ADD_EXT 0x8787 +#define GL_OP_MADD_EXT 0x8788 +#define GL_OP_FRAC_EXT 0x8789 +#define GL_OP_MAX_EXT 0x878A +#define GL_OP_MIN_EXT 0x878B +#define GL_OP_SET_GE_EXT 0x878C +#define GL_OP_SET_LT_EXT 0x878D +#define GL_OP_CLAMP_EXT 0x878E +#define GL_OP_FLOOR_EXT 0x878F +#define GL_OP_ROUND_EXT 0x8790 +#define GL_OP_EXP_BASE_2_EXT 0x8791 +#define GL_OP_LOG_BASE_2_EXT 0x8792 +#define GL_OP_POWER_EXT 0x8793 +#define GL_OP_RECIP_EXT 0x8794 +#define GL_OP_RECIP_SQRT_EXT 0x8795 +#define GL_OP_SUB_EXT 0x8796 +#define GL_OP_CROSS_PRODUCT_EXT 0x8797 +#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 +#define GL_OP_MOV_EXT 0x8799 +#define GL_OUTPUT_VERTEX_EXT 0x879A +#define GL_OUTPUT_COLOR0_EXT 0x879B +#define GL_OUTPUT_COLOR1_EXT 0x879C +#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D +#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E +#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F +#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 +#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 +#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 +#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 +#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 +#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 +#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 +#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 +#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 +#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 +#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA +#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB +#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC +#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD +#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE +#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF +#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 +#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 +#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 +#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 +#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 +#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 +#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 +#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 +#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 +#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 +#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA +#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB +#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC +#define GL_OUTPUT_FOG_EXT 0x87BD +#define GL_SCALAR_EXT 0x87BE +#define GL_VECTOR_EXT 0x87BF +#define GL_MATRIX_EXT 0x87C0 +#define GL_VARIANT_EXT 0x87C1 +#define GL_INVARIANT_EXT 0x87C2 +#define GL_LOCAL_CONSTANT_EXT 0x87C3 +#define GL_LOCAL_EXT 0x87C4 +#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 +#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 +#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 +#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 +#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE +#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF +#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 +#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 +#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 +#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 +#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 +#define GL_X_EXT 0x87D5 +#define GL_Y_EXT 0x87D6 +#define GL_Z_EXT 0x87D7 +#define GL_W_EXT 0x87D8 +#define GL_NEGATIVE_X_EXT 0x87D9 +#define GL_NEGATIVE_Y_EXT 0x87DA +#define GL_NEGATIVE_Z_EXT 0x87DB +#define GL_NEGATIVE_W_EXT 0x87DC +#define GL_ZERO_EXT 0x87DD +#define GL_ONE_EXT 0x87DE +#define GL_NEGATIVE_ONE_EXT 0x87DF +#define GL_NORMALIZED_RANGE_EXT 0x87E0 +#define GL_FULL_RANGE_EXT 0x87E1 +#define GL_CURRENT_VERTEX_EXT 0x87E2 +#define GL_MVP_MATRIX_EXT 0x87E3 +#define GL_VARIANT_VALUE_EXT 0x87E4 +#define GL_VARIANT_DATATYPE_EXT 0x87E5 +#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 +#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 +#define GL_VARIANT_ARRAY_EXT 0x87E8 +#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 +#define GL_INVARIANT_VALUE_EXT 0x87EA +#define GL_INVARIANT_DATATYPE_EXT 0x87EB +#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC +#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED +typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); +typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); +typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); +typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); +typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); +typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const void *addr); +typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const void *addr); +typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr); +typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr); +typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr); +typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr); +typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr); +typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr); +typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr); +typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr); +typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const void *addr); +typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC) (GLenum value); +typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); +typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, void **data); +typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginVertexShaderEXT (void); +GLAPI void APIENTRY glEndVertexShaderEXT (void); +GLAPI void APIENTRY glBindVertexShaderEXT (GLuint id); +GLAPI GLuint APIENTRY glGenVertexShadersEXT (GLuint range); +GLAPI void APIENTRY glDeleteVertexShaderEXT (GLuint id); +GLAPI void APIENTRY glShaderOp1EXT (GLenum op, GLuint res, GLuint arg1); +GLAPI void APIENTRY glShaderOp2EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2); +GLAPI void APIENTRY glShaderOp3EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); +GLAPI void APIENTRY glSwizzleEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +GLAPI void APIENTRY glWriteMaskEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +GLAPI void APIENTRY glInsertComponentEXT (GLuint res, GLuint src, GLuint num); +GLAPI void APIENTRY glExtractComponentEXT (GLuint res, GLuint src, GLuint num); +GLAPI GLuint APIENTRY glGenSymbolsEXT (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); +GLAPI void APIENTRY glSetInvariantEXT (GLuint id, GLenum type, const void *addr); +GLAPI void APIENTRY glSetLocalConstantEXT (GLuint id, GLenum type, const void *addr); +GLAPI void APIENTRY glVariantbvEXT (GLuint id, const GLbyte *addr); +GLAPI void APIENTRY glVariantsvEXT (GLuint id, const GLshort *addr); +GLAPI void APIENTRY glVariantivEXT (GLuint id, const GLint *addr); +GLAPI void APIENTRY glVariantfvEXT (GLuint id, const GLfloat *addr); +GLAPI void APIENTRY glVariantdvEXT (GLuint id, const GLdouble *addr); +GLAPI void APIENTRY glVariantubvEXT (GLuint id, const GLubyte *addr); +GLAPI void APIENTRY glVariantusvEXT (GLuint id, const GLushort *addr); +GLAPI void APIENTRY glVariantuivEXT (GLuint id, const GLuint *addr); +GLAPI void APIENTRY glVariantPointerEXT (GLuint id, GLenum type, GLuint stride, const void *addr); +GLAPI void APIENTRY glEnableVariantClientStateEXT (GLuint id); +GLAPI void APIENTRY glDisableVariantClientStateEXT (GLuint id); +GLAPI GLuint APIENTRY glBindLightParameterEXT (GLenum light, GLenum value); +GLAPI GLuint APIENTRY glBindMaterialParameterEXT (GLenum face, GLenum value); +GLAPI GLuint APIENTRY glBindTexGenParameterEXT (GLenum unit, GLenum coord, GLenum value); +GLAPI GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum unit, GLenum value); +GLAPI GLuint APIENTRY glBindParameterEXT (GLenum value); +GLAPI GLboolean APIENTRY glIsVariantEnabledEXT (GLuint id, GLenum cap); +GLAPI void APIENTRY glGetVariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); +GLAPI void APIENTRY glGetVariantIntegervEXT (GLuint id, GLenum value, GLint *data); +GLAPI void APIENTRY glGetVariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); +GLAPI void APIENTRY glGetVariantPointervEXT (GLuint id, GLenum value, void **data); +GLAPI void APIENTRY glGetInvariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); +GLAPI void APIENTRY glGetInvariantIntegervEXT (GLuint id, GLenum value, GLint *data); +GLAPI void APIENTRY glGetInvariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); +GLAPI void APIENTRY glGetLocalConstantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); +GLAPI void APIENTRY glGetLocalConstantIntegervEXT (GLuint id, GLenum value, GLint *data); +GLAPI void APIENTRY glGetLocalConstantFloatvEXT (GLuint id, GLenum value, GLfloat *data); +#endif +#endif /* GL_EXT_vertex_shader */ + +#ifndef GL_EXT_vertex_weighting +#define GL_EXT_vertex_weighting 1 +#define GL_MODELVIEW0_STACK_DEPTH_EXT 0x0BA3 +#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 +#define GL_MODELVIEW0_MATRIX_EXT 0x0BA6 +#define GL_MODELVIEW1_MATRIX_EXT 0x8506 +#define GL_VERTEX_WEIGHTING_EXT 0x8509 +#define GL_MODELVIEW0_EXT 0x1700 +#define GL_MODELVIEW1_EXT 0x850A +#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B +#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C +#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D +#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E +#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F +#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexWeightfEXT (GLfloat weight); +GLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *weight); +GLAPI void APIENTRY glVertexWeightPointerEXT (GLint size, GLenum type, GLsizei stride, const void *pointer); +#endif +#endif /* GL_EXT_vertex_weighting */ + +#ifndef GL_EXT_win32_keyed_mutex +#define GL_EXT_win32_keyed_mutex 1 +typedef GLboolean (APIENTRYP PFNGLACQUIREKEYEDMUTEXWIN32EXTPROC) (GLuint memory, GLuint64 key, GLuint timeout); +typedef GLboolean (APIENTRYP PFNGLRELEASEKEYEDMUTEXWIN32EXTPROC) (GLuint memory, GLuint64 key); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAcquireKeyedMutexWin32EXT (GLuint memory, GLuint64 key, GLuint timeout); +GLAPI GLboolean APIENTRY glReleaseKeyedMutexWin32EXT (GLuint memory, GLuint64 key); +#endif +#endif /* GL_EXT_win32_keyed_mutex */ + +#ifndef GL_EXT_window_rectangles +#define GL_EXT_window_rectangles 1 +#define GL_INCLUSIVE_EXT 0x8F10 +#define GL_EXCLUSIVE_EXT 0x8F11 +#define GL_WINDOW_RECTANGLE_EXT 0x8F12 +#define GL_WINDOW_RECTANGLE_MODE_EXT 0x8F13 +#define GL_MAX_WINDOW_RECTANGLES_EXT 0x8F14 +#define GL_NUM_WINDOW_RECTANGLES_EXT 0x8F15 +typedef void (APIENTRYP PFNGLWINDOWRECTANGLESEXTPROC) (GLenum mode, GLsizei count, const GLint *box); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowRectanglesEXT (GLenum mode, GLsizei count, const GLint *box); +#endif +#endif /* GL_EXT_window_rectangles */ + +#ifndef GL_EXT_x11_sync_object +#define GL_EXT_x11_sync_object 1 +#define GL_SYNC_X11_FENCE_EXT 0x90E1 +typedef GLsync (APIENTRYP PFNGLIMPORTSYNCEXTPROC) (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLsync APIENTRY glImportSyncEXT (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); +#endif +#endif /* GL_EXT_x11_sync_object */ + +#ifndef GL_GREMEDY_frame_terminator +#define GL_GREMEDY_frame_terminator 1 +typedef void (APIENTRYP PFNGLFRAMETERMINATORGREMEDYPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFrameTerminatorGREMEDY (void); +#endif +#endif /* GL_GREMEDY_frame_terminator */ + +#ifndef GL_GREMEDY_string_marker +#define GL_GREMEDY_string_marker 1 +typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const void *string); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStringMarkerGREMEDY (GLsizei len, const void *string); +#endif +#endif /* GL_GREMEDY_string_marker */ + +#ifndef GL_HP_convolution_border_modes +#define GL_HP_convolution_border_modes 1 +#define GL_IGNORE_BORDER_HP 0x8150 +#define GL_CONSTANT_BORDER_HP 0x8151 +#define GL_REPLICATE_BORDER_HP 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR_HP 0x8154 +#endif /* GL_HP_convolution_border_modes */ + +#ifndef GL_HP_image_transform +#define GL_HP_image_transform 1 +#define GL_IMAGE_SCALE_X_HP 0x8155 +#define GL_IMAGE_SCALE_Y_HP 0x8156 +#define GL_IMAGE_TRANSLATE_X_HP 0x8157 +#define GL_IMAGE_TRANSLATE_Y_HP 0x8158 +#define GL_IMAGE_ROTATE_ANGLE_HP 0x8159 +#define GL_IMAGE_ROTATE_ORIGIN_X_HP 0x815A +#define GL_IMAGE_ROTATE_ORIGIN_Y_HP 0x815B +#define GL_IMAGE_MAG_FILTER_HP 0x815C +#define GL_IMAGE_MIN_FILTER_HP 0x815D +#define GL_IMAGE_CUBIC_WEIGHT_HP 0x815E +#define GL_CUBIC_HP 0x815F +#define GL_AVERAGE_HP 0x8160 +#define GL_IMAGE_TRANSFORM_2D_HP 0x8161 +#define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162 +#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163 +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImageTransformParameteriHP (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glImageTransformParameterfHP (GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glImageTransformParameterivHP (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glImageTransformParameterfvHP (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetImageTransformParameterivHP (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetImageTransformParameterfvHP (GLenum target, GLenum pname, GLfloat *params); +#endif +#endif /* GL_HP_image_transform */ + +#ifndef GL_HP_occlusion_test +#define GL_HP_occlusion_test 1 +#define GL_OCCLUSION_TEST_HP 0x8165 +#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 +#endif /* GL_HP_occlusion_test */ + +#ifndef GL_HP_texture_lighting +#define GL_HP_texture_lighting 1 +#define GL_TEXTURE_LIGHTING_MODE_HP 0x8167 +#define GL_TEXTURE_POST_SPECULAR_HP 0x8168 +#define GL_TEXTURE_PRE_SPECULAR_HP 0x8169 +#endif /* GL_HP_texture_lighting */ + +#ifndef GL_IBM_cull_vertex +#define GL_IBM_cull_vertex 1 +#define GL_CULL_VERTEX_IBM 103050 +#endif /* GL_IBM_cull_vertex */ + +#ifndef GL_IBM_multimode_draw_arrays +#define GL_IBM_multimode_draw_arrays 1 +typedef void (APIENTRYP PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); +typedef void (APIENTRYP PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount, GLint modestride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiModeDrawArraysIBM (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); +GLAPI void APIENTRY glMultiModeDrawElementsIBM (const GLenum *mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount, GLint modestride); +#endif +#endif /* GL_IBM_multimode_draw_arrays */ + +#ifndef GL_IBM_rasterpos_clip +#define GL_IBM_rasterpos_clip 1 +#define GL_RASTER_POSITION_UNCLIPPED_IBM 0x19262 +#endif /* GL_IBM_rasterpos_clip */ + +#ifndef GL_IBM_static_data +#define GL_IBM_static_data 1 +#define GL_ALL_STATIC_DATA_IBM 103060 +#define GL_STATIC_VERTEX_ARRAY_IBM 103061 +typedef void (APIENTRYP PFNGLFLUSHSTATICDATAIBMPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushStaticDataIBM (GLenum target); +#endif +#endif /* GL_IBM_static_data */ + +#ifndef GL_IBM_texture_mirrored_repeat +#define GL_IBM_texture_mirrored_repeat 1 +#define GL_MIRRORED_REPEAT_IBM 0x8370 +#endif /* GL_IBM_texture_mirrored_repeat */ + +#ifndef GL_IBM_vertex_array_lists +#define GL_IBM_vertex_array_lists 1 +#define GL_VERTEX_ARRAY_LIST_IBM 103070 +#define GL_NORMAL_ARRAY_LIST_IBM 103071 +#define GL_COLOR_ARRAY_LIST_IBM 103072 +#define GL_INDEX_ARRAY_LIST_IBM 103073 +#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 +#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 +#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 +#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 +#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 +#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 +#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 +#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 +#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 +#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 +#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 +#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 +typedef void (APIENTRYP PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +GLAPI void APIENTRY glSecondaryColorPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +GLAPI void APIENTRY glEdgeFlagPointerListIBM (GLint stride, const GLboolean **pointer, GLint ptrstride); +GLAPI void APIENTRY glFogCoordPointerListIBM (GLenum type, GLint stride, const void **pointer, GLint ptrstride); +GLAPI void APIENTRY glIndexPointerListIBM (GLenum type, GLint stride, const void **pointer, GLint ptrstride); +GLAPI void APIENTRY glNormalPointerListIBM (GLenum type, GLint stride, const void **pointer, GLint ptrstride); +GLAPI void APIENTRY glTexCoordPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +GLAPI void APIENTRY glVertexPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +#endif +#endif /* GL_IBM_vertex_array_lists */ + +#ifndef GL_INGR_blend_func_separate +#define GL_INGR_blend_func_separate 1 +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif +#endif /* GL_INGR_blend_func_separate */ + +#ifndef GL_INGR_color_clamp +#define GL_INGR_color_clamp 1 +#define GL_RED_MIN_CLAMP_INGR 0x8560 +#define GL_GREEN_MIN_CLAMP_INGR 0x8561 +#define GL_BLUE_MIN_CLAMP_INGR 0x8562 +#define GL_ALPHA_MIN_CLAMP_INGR 0x8563 +#define GL_RED_MAX_CLAMP_INGR 0x8564 +#define GL_GREEN_MAX_CLAMP_INGR 0x8565 +#define GL_BLUE_MAX_CLAMP_INGR 0x8566 +#define GL_ALPHA_MAX_CLAMP_INGR 0x8567 +#endif /* GL_INGR_color_clamp */ + +#ifndef GL_INGR_interlace_read +#define GL_INGR_interlace_read 1 +#define GL_INTERLACE_READ_INGR 0x8568 +#endif /* GL_INGR_interlace_read */ + +#ifndef GL_INTEL_blackhole_render +#define GL_INTEL_blackhole_render 1 +#define GL_BLACKHOLE_RENDER_INTEL 0x83FC +#endif /* GL_INTEL_blackhole_render */ + +#ifndef GL_INTEL_conservative_rasterization +#define GL_INTEL_conservative_rasterization 1 +#define GL_CONSERVATIVE_RASTERIZATION_INTEL 0x83FE +#endif /* GL_INTEL_conservative_rasterization */ + +#ifndef GL_INTEL_fragment_shader_ordering +#define GL_INTEL_fragment_shader_ordering 1 +#endif /* GL_INTEL_fragment_shader_ordering */ + +#ifndef GL_INTEL_framebuffer_CMAA +#define GL_INTEL_framebuffer_CMAA 1 +typedef void (APIENTRYP PFNGLAPPLYFRAMEBUFFERATTACHMENTCMAAINTELPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glApplyFramebufferAttachmentCMAAINTEL (void); +#endif +#endif /* GL_INTEL_framebuffer_CMAA */ + +#ifndef GL_INTEL_map_texture +#define GL_INTEL_map_texture 1 +#define GL_TEXTURE_MEMORY_LAYOUT_INTEL 0x83FF +#define GL_LAYOUT_DEFAULT_INTEL 0 +#define GL_LAYOUT_LINEAR_INTEL 1 +#define GL_LAYOUT_LINEAR_CPU_CACHED_INTEL 2 +typedef void (APIENTRYP PFNGLSYNCTEXTUREINTELPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLUNMAPTEXTURE2DINTELPROC) (GLuint texture, GLint level); +typedef void *(APIENTRYP PFNGLMAPTEXTURE2DINTELPROC) (GLuint texture, GLint level, GLbitfield access, GLint *stride, GLenum *layout); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSyncTextureINTEL (GLuint texture); +GLAPI void APIENTRY glUnmapTexture2DINTEL (GLuint texture, GLint level); +GLAPI void *APIENTRY glMapTexture2DINTEL (GLuint texture, GLint level, GLbitfield access, GLint *stride, GLenum *layout); +#endif +#endif /* GL_INTEL_map_texture */ + +#ifndef GL_INTEL_parallel_arrays +#define GL_INTEL_parallel_arrays 1 +#define GL_PARALLEL_ARRAYS_INTEL 0x83F4 +#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 +#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 +#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 +#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 +typedef void (APIENTRYP PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const void **pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const void **pointer); +typedef void (APIENTRYP PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const void **pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const void **pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexPointervINTEL (GLint size, GLenum type, const void **pointer); +GLAPI void APIENTRY glNormalPointervINTEL (GLenum type, const void **pointer); +GLAPI void APIENTRY glColorPointervINTEL (GLint size, GLenum type, const void **pointer); +GLAPI void APIENTRY glTexCoordPointervINTEL (GLint size, GLenum type, const void **pointer); +#endif +#endif /* GL_INTEL_parallel_arrays */ + +#ifndef GL_INTEL_performance_query +#define GL_INTEL_performance_query 1 +#define GL_PERFQUERY_SINGLE_CONTEXT_INTEL 0x00000000 +#define GL_PERFQUERY_GLOBAL_CONTEXT_INTEL 0x00000001 +#define GL_PERFQUERY_WAIT_INTEL 0x83FB +#define GL_PERFQUERY_FLUSH_INTEL 0x83FA +#define GL_PERFQUERY_DONOT_FLUSH_INTEL 0x83F9 +#define GL_PERFQUERY_COUNTER_EVENT_INTEL 0x94F0 +#define GL_PERFQUERY_COUNTER_DURATION_NORM_INTEL 0x94F1 +#define GL_PERFQUERY_COUNTER_DURATION_RAW_INTEL 0x94F2 +#define GL_PERFQUERY_COUNTER_THROUGHPUT_INTEL 0x94F3 +#define GL_PERFQUERY_COUNTER_RAW_INTEL 0x94F4 +#define GL_PERFQUERY_COUNTER_TIMESTAMP_INTEL 0x94F5 +#define GL_PERFQUERY_COUNTER_DATA_UINT32_INTEL 0x94F8 +#define GL_PERFQUERY_COUNTER_DATA_UINT64_INTEL 0x94F9 +#define GL_PERFQUERY_COUNTER_DATA_FLOAT_INTEL 0x94FA +#define GL_PERFQUERY_COUNTER_DATA_DOUBLE_INTEL 0x94FB +#define GL_PERFQUERY_COUNTER_DATA_BOOL32_INTEL 0x94FC +#define GL_PERFQUERY_QUERY_NAME_LENGTH_MAX_INTEL 0x94FD +#define GL_PERFQUERY_COUNTER_NAME_LENGTH_MAX_INTEL 0x94FE +#define GL_PERFQUERY_COUNTER_DESC_LENGTH_MAX_INTEL 0x94FF +#define GL_PERFQUERY_GPA_EXTENDED_COUNTERS_INTEL 0x9500 +typedef void (APIENTRYP PFNGLBEGINPERFQUERYINTELPROC) (GLuint queryHandle); +typedef void (APIENTRYP PFNGLCREATEPERFQUERYINTELPROC) (GLuint queryId, GLuint *queryHandle); +typedef void (APIENTRYP PFNGLDELETEPERFQUERYINTELPROC) (GLuint queryHandle); +typedef void (APIENTRYP PFNGLENDPERFQUERYINTELPROC) (GLuint queryHandle); +typedef void (APIENTRYP PFNGLGETFIRSTPERFQUERYIDINTELPROC) (GLuint *queryId); +typedef void (APIENTRYP PFNGLGETNEXTPERFQUERYIDINTELPROC) (GLuint queryId, GLuint *nextQueryId); +typedef void (APIENTRYP PFNGLGETPERFCOUNTERINFOINTELPROC) (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); +typedef void (APIENTRYP PFNGLGETPERFQUERYDATAINTELPROC) (GLuint queryHandle, GLuint flags, GLsizei dataSize, void *data, GLuint *bytesWritten); +typedef void (APIENTRYP PFNGLGETPERFQUERYIDBYNAMEINTELPROC) (GLchar *queryName, GLuint *queryId); +typedef void (APIENTRYP PFNGLGETPERFQUERYINFOINTELPROC) (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginPerfQueryINTEL (GLuint queryHandle); +GLAPI void APIENTRY glCreatePerfQueryINTEL (GLuint queryId, GLuint *queryHandle); +GLAPI void APIENTRY glDeletePerfQueryINTEL (GLuint queryHandle); +GLAPI void APIENTRY glEndPerfQueryINTEL (GLuint queryHandle); +GLAPI void APIENTRY glGetFirstPerfQueryIdINTEL (GLuint *queryId); +GLAPI void APIENTRY glGetNextPerfQueryIdINTEL (GLuint queryId, GLuint *nextQueryId); +GLAPI void APIENTRY glGetPerfCounterInfoINTEL (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); +GLAPI void APIENTRY glGetPerfQueryDataINTEL (GLuint queryHandle, GLuint flags, GLsizei dataSize, void *data, GLuint *bytesWritten); +GLAPI void APIENTRY glGetPerfQueryIdByNameINTEL (GLchar *queryName, GLuint *queryId); +GLAPI void APIENTRY glGetPerfQueryInfoINTEL (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); +#endif +#endif /* GL_INTEL_performance_query */ + +#ifndef GL_MESAX_texture_stack +#define GL_MESAX_texture_stack 1 +#define GL_TEXTURE_1D_STACK_MESAX 0x8759 +#define GL_TEXTURE_2D_STACK_MESAX 0x875A +#define GL_PROXY_TEXTURE_1D_STACK_MESAX 0x875B +#define GL_PROXY_TEXTURE_2D_STACK_MESAX 0x875C +#define GL_TEXTURE_1D_STACK_BINDING_MESAX 0x875D +#define GL_TEXTURE_2D_STACK_BINDING_MESAX 0x875E +#endif /* GL_MESAX_texture_stack */ + +#ifndef GL_MESA_framebuffer_flip_x +#define GL_MESA_framebuffer_flip_x 1 +#define GL_FRAMEBUFFER_FLIP_X_MESA 0x8BBC +#endif /* GL_MESA_framebuffer_flip_x */ + +#ifndef GL_MESA_framebuffer_flip_y +#define GL_MESA_framebuffer_flip_y 1 +#define GL_FRAMEBUFFER_FLIP_Y_MESA 0x8BBB +typedef void (APIENTRYP PFNGLFRAMEBUFFERPARAMETERIMESAPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVMESAPROC) (GLenum target, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferParameteriMESA (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glGetFramebufferParameterivMESA (GLenum target, GLenum pname, GLint *params); +#endif +#endif /* GL_MESA_framebuffer_flip_y */ + +#ifndef GL_MESA_framebuffer_swap_xy +#define GL_MESA_framebuffer_swap_xy 1 +#define GL_FRAMEBUFFER_SWAP_XY_MESA 0x8BBD +#endif /* GL_MESA_framebuffer_swap_xy */ + +#ifndef GL_MESA_pack_invert +#define GL_MESA_pack_invert 1 +#define GL_PACK_INVERT_MESA 0x8758 +#endif /* GL_MESA_pack_invert */ + +#ifndef GL_MESA_program_binary_formats +#define GL_MESA_program_binary_formats 1 +#define GL_PROGRAM_BINARY_FORMAT_MESA 0x875F +#endif /* GL_MESA_program_binary_formats */ + +#ifndef GL_MESA_resize_buffers +#define GL_MESA_resize_buffers 1 +typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glResizeBuffersMESA (void); +#endif +#endif /* GL_MESA_resize_buffers */ + +#ifndef GL_MESA_shader_integer_functions +#define GL_MESA_shader_integer_functions 1 +#endif /* GL_MESA_shader_integer_functions */ + +#ifndef GL_MESA_tile_raster_order +#define GL_MESA_tile_raster_order 1 +#define GL_TILE_RASTER_ORDER_FIXED_MESA 0x8BB8 +#define GL_TILE_RASTER_ORDER_INCREASING_X_MESA 0x8BB9 +#define GL_TILE_RASTER_ORDER_INCREASING_Y_MESA 0x8BBA +#endif /* GL_MESA_tile_raster_order */ + +#ifndef GL_MESA_window_pos +#define GL_MESA_window_pos 1 +typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowPos2dMESA (GLdouble x, GLdouble y); +GLAPI void APIENTRY glWindowPos2dvMESA (const GLdouble *v); +GLAPI void APIENTRY glWindowPos2fMESA (GLfloat x, GLfloat y); +GLAPI void APIENTRY glWindowPos2fvMESA (const GLfloat *v); +GLAPI void APIENTRY glWindowPos2iMESA (GLint x, GLint y); +GLAPI void APIENTRY glWindowPos2ivMESA (const GLint *v); +GLAPI void APIENTRY glWindowPos2sMESA (GLshort x, GLshort y); +GLAPI void APIENTRY glWindowPos2svMESA (const GLshort *v); +GLAPI void APIENTRY glWindowPos3dMESA (GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glWindowPos3dvMESA (const GLdouble *v); +GLAPI void APIENTRY glWindowPos3fMESA (GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glWindowPos3fvMESA (const GLfloat *v); +GLAPI void APIENTRY glWindowPos3iMESA (GLint x, GLint y, GLint z); +GLAPI void APIENTRY glWindowPos3ivMESA (const GLint *v); +GLAPI void APIENTRY glWindowPos3sMESA (GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glWindowPos3svMESA (const GLshort *v); +GLAPI void APIENTRY glWindowPos4dMESA (GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glWindowPos4dvMESA (const GLdouble *v); +GLAPI void APIENTRY glWindowPos4fMESA (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glWindowPos4fvMESA (const GLfloat *v); +GLAPI void APIENTRY glWindowPos4iMESA (GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glWindowPos4ivMESA (const GLint *v); +GLAPI void APIENTRY glWindowPos4sMESA (GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *v); +#endif +#endif /* GL_MESA_window_pos */ + +#ifndef GL_MESA_ycbcr_texture +#define GL_MESA_ycbcr_texture 1 +#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB +#define GL_YCBCR_MESA 0x8757 +#endif /* GL_MESA_ycbcr_texture */ + +#ifndef GL_NVX_blend_equation_advanced_multi_draw_buffers +#define GL_NVX_blend_equation_advanced_multi_draw_buffers 1 +#endif /* GL_NVX_blend_equation_advanced_multi_draw_buffers */ + +#ifndef GL_NVX_conditional_render +#define GL_NVX_conditional_render 1 +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVXPROC) (GLuint id); +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVXPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginConditionalRenderNVX (GLuint id); +GLAPI void APIENTRY glEndConditionalRenderNVX (void); +#endif +#endif /* GL_NVX_conditional_render */ + +#ifndef GL_NVX_gpu_memory_info +#define GL_NVX_gpu_memory_info 1 +#define GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX 0x9047 +#define GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX 0x9048 +#define GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX 0x9049 +#define GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX 0x904A +#define GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX 0x904B +#endif /* GL_NVX_gpu_memory_info */ + +#ifndef GL_NVX_gpu_multicast2 +#define GL_NVX_gpu_multicast2 1 +#define GL_UPLOAD_GPU_MASK_NVX 0x954A +typedef void (APIENTRYP PFNGLUPLOADGPUMASKNVXPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLMULTICASTVIEWPORTARRAYVNVXPROC) (GLuint gpu, GLuint first, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTICASTVIEWPORTPOSITIONWSCALENVXPROC) (GLuint gpu, GLuint index, GLfloat xcoeff, GLfloat ycoeff); +typedef void (APIENTRYP PFNGLMULTICASTSCISSORARRAYVNVXPROC) (GLuint gpu, GLuint first, GLsizei count, const GLint *v); +typedef GLuint (APIENTRYP PFNGLASYNCCOPYBUFFERSUBDATANVXPROC) (GLsizei waitSemaphoreCount, const GLuint *waitSemaphoreArray, const GLuint64 *fenceValueArray, GLuint readGPU, GLbitfield writeGPUMask, GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size, GLsizei signalSemaphoreCount, const GLuint *signalSemaphoreArray, const GLuint64 *signalValueArray); +typedef GLuint (APIENTRYP PFNGLASYNCCOPYIMAGESUBDATANVXPROC) (GLsizei waitSemaphoreCount, const GLuint *waitSemaphoreArray, const GLuint64 *waitValueArray, GLuint srcGPU, GLbitfield dstGPUMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth, GLsizei signalSemaphoreCount, const GLuint *signalSemaphoreArray, const GLuint64 *signalValueArray); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUploadGPUMaskNVX (GLbitfield mask); +GLAPI void APIENTRY glMulticastViewportArrayvNVX (GLuint gpu, GLuint first, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glMulticastViewportPositionWScaleNVX (GLuint gpu, GLuint index, GLfloat xcoeff, GLfloat ycoeff); +GLAPI void APIENTRY glMulticastScissorArrayvNVX (GLuint gpu, GLuint first, GLsizei count, const GLint *v); +GLAPI GLuint APIENTRY glAsyncCopyBufferSubDataNVX (GLsizei waitSemaphoreCount, const GLuint *waitSemaphoreArray, const GLuint64 *fenceValueArray, GLuint readGPU, GLbitfield writeGPUMask, GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size, GLsizei signalSemaphoreCount, const GLuint *signalSemaphoreArray, const GLuint64 *signalValueArray); +GLAPI GLuint APIENTRY glAsyncCopyImageSubDataNVX (GLsizei waitSemaphoreCount, const GLuint *waitSemaphoreArray, const GLuint64 *waitValueArray, GLuint srcGPU, GLbitfield dstGPUMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth, GLsizei signalSemaphoreCount, const GLuint *signalSemaphoreArray, const GLuint64 *signalValueArray); +#endif +#endif /* GL_NVX_gpu_multicast2 */ + +#ifndef GL_NVX_linked_gpu_multicast +#define GL_NVX_linked_gpu_multicast 1 +#define GL_LGPU_SEPARATE_STORAGE_BIT_NVX 0x0800 +#define GL_MAX_LGPU_GPUS_NVX 0x92BA +typedef void (APIENTRYP PFNGLLGPUNAMEDBUFFERSUBDATANVXPROC) (GLbitfield gpuMask, GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +typedef void (APIENTRYP PFNGLLGPUCOPYIMAGESUBDATANVXPROC) (GLuint sourceGPU, GLbitfield destinationGPUMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srxY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLLGPUINTERLOCKNVXPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLGPUNamedBufferSubDataNVX (GLbitfield gpuMask, GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +GLAPI void APIENTRY glLGPUCopyImageSubDataNVX (GLuint sourceGPU, GLbitfield destinationGPUMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srxY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glLGPUInterlockNVX (void); +#endif +#endif /* GL_NVX_linked_gpu_multicast */ + +#ifndef GL_NVX_progress_fence +#define GL_NVX_progress_fence 1 +typedef GLuint (APIENTRYP PFNGLCREATEPROGRESSFENCENVXPROC) (void); +typedef void (APIENTRYP PFNGLSIGNALSEMAPHOREUI64NVXPROC) (GLuint signalGPU, GLsizei fenceObjectCount, const GLuint *semaphoreArray, const GLuint64 *fenceValueArray); +typedef void (APIENTRYP PFNGLWAITSEMAPHOREUI64NVXPROC) (GLuint waitGPU, GLsizei fenceObjectCount, const GLuint *semaphoreArray, const GLuint64 *fenceValueArray); +typedef void (APIENTRYP PFNGLCLIENTWAITSEMAPHOREUI64NVXPROC) (GLsizei fenceObjectCount, const GLuint *semaphoreArray, const GLuint64 *fenceValueArray); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glCreateProgressFenceNVX (void); +GLAPI void APIENTRY glSignalSemaphoreui64NVX (GLuint signalGPU, GLsizei fenceObjectCount, const GLuint *semaphoreArray, const GLuint64 *fenceValueArray); +GLAPI void APIENTRY glWaitSemaphoreui64NVX (GLuint waitGPU, GLsizei fenceObjectCount, const GLuint *semaphoreArray, const GLuint64 *fenceValueArray); +GLAPI void APIENTRY glClientWaitSemaphoreui64NVX (GLsizei fenceObjectCount, const GLuint *semaphoreArray, const GLuint64 *fenceValueArray); +#endif +#endif /* GL_NVX_progress_fence */ + +#ifndef GL_NV_alpha_to_coverage_dither_control +#define GL_NV_alpha_to_coverage_dither_control 1 +#define GL_ALPHA_TO_COVERAGE_DITHER_DEFAULT_NV 0x934D +#define GL_ALPHA_TO_COVERAGE_DITHER_ENABLE_NV 0x934E +#define GL_ALPHA_TO_COVERAGE_DITHER_DISABLE_NV 0x934F +#define GL_ALPHA_TO_COVERAGE_DITHER_MODE_NV 0x92BF +typedef void (APIENTRYP PFNGLALPHATOCOVERAGEDITHERCONTROLNVPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glAlphaToCoverageDitherControlNV (GLenum mode); +#endif +#endif /* GL_NV_alpha_to_coverage_dither_control */ + +#ifndef GL_NV_bindless_multi_draw_indirect +#define GL_NV_bindless_multi_draw_indirect 1 +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTBINDLESSNVPROC) (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTBINDLESSNVPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysIndirectBindlessNV (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); +GLAPI void APIENTRY glMultiDrawElementsIndirectBindlessNV (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); +#endif +#endif /* GL_NV_bindless_multi_draw_indirect */ + +#ifndef GL_NV_bindless_multi_draw_indirect_count +#define GL_NV_bindless_multi_draw_indirect_count 1 +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTBINDLESSCOUNTNVPROC) (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTBINDLESSCOUNTNVPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysIndirectBindlessCountNV (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount); +GLAPI void APIENTRY glMultiDrawElementsIndirectBindlessCountNV (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount); +#endif +#endif /* GL_NV_bindless_multi_draw_indirect_count */ + +#ifndef GL_NV_bindless_texture +#define GL_NV_bindless_texture 1 +typedef GLuint64 (APIENTRYP PFNGLGETTEXTUREHANDLENVPROC) (GLuint texture); +typedef GLuint64 (APIENTRYP PFNGLGETTEXTURESAMPLERHANDLENVPROC) (GLuint texture, GLuint sampler); +typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTNVPROC) (GLuint64 handle); +typedef GLuint64 (APIENTRYP PFNGLGETIMAGEHANDLENVPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle, GLenum access); +typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTNVPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64NVPROC) (GLint location, GLuint64 value); +typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64VNVPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64NVPROC) (GLuint program, GLint location, GLuint64 value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); +typedef GLboolean (APIENTRYP PFNGLISIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint64 APIENTRY glGetTextureHandleNV (GLuint texture); +GLAPI GLuint64 APIENTRY glGetTextureSamplerHandleNV (GLuint texture, GLuint sampler); +GLAPI void APIENTRY glMakeTextureHandleResidentNV (GLuint64 handle); +GLAPI void APIENTRY glMakeTextureHandleNonResidentNV (GLuint64 handle); +GLAPI GLuint64 APIENTRY glGetImageHandleNV (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +GLAPI void APIENTRY glMakeImageHandleResidentNV (GLuint64 handle, GLenum access); +GLAPI void APIENTRY glMakeImageHandleNonResidentNV (GLuint64 handle); +GLAPI void APIENTRY glUniformHandleui64NV (GLint location, GLuint64 value); +GLAPI void APIENTRY glUniformHandleui64vNV (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glProgramUniformHandleui64NV (GLuint program, GLint location, GLuint64 value); +GLAPI void APIENTRY glProgramUniformHandleui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +GLAPI GLboolean APIENTRY glIsTextureHandleResidentNV (GLuint64 handle); +GLAPI GLboolean APIENTRY glIsImageHandleResidentNV (GLuint64 handle); +#endif +#endif /* GL_NV_bindless_texture */ + +#ifndef GL_NV_blend_equation_advanced +#define GL_NV_blend_equation_advanced 1 +#define GL_BLEND_OVERLAP_NV 0x9281 +#define GL_BLEND_PREMULTIPLIED_SRC_NV 0x9280 +#define GL_BLUE_NV 0x1905 +#define GL_COLORBURN_NV 0x929A +#define GL_COLORDODGE_NV 0x9299 +#define GL_CONJOINT_NV 0x9284 +#define GL_CONTRAST_NV 0x92A1 +#define GL_DARKEN_NV 0x9297 +#define GL_DIFFERENCE_NV 0x929E +#define GL_DISJOINT_NV 0x9283 +#define GL_DST_ATOP_NV 0x928F +#define GL_DST_IN_NV 0x928B +#define GL_DST_NV 0x9287 +#define GL_DST_OUT_NV 0x928D +#define GL_DST_OVER_NV 0x9289 +#define GL_EXCLUSION_NV 0x92A0 +#define GL_GREEN_NV 0x1904 +#define GL_HARDLIGHT_NV 0x929B +#define GL_HARDMIX_NV 0x92A9 +#define GL_HSL_COLOR_NV 0x92AF +#define GL_HSL_HUE_NV 0x92AD +#define GL_HSL_LUMINOSITY_NV 0x92B0 +#define GL_HSL_SATURATION_NV 0x92AE +#define GL_INVERT_OVG_NV 0x92B4 +#define GL_INVERT_RGB_NV 0x92A3 +#define GL_LIGHTEN_NV 0x9298 +#define GL_LINEARBURN_NV 0x92A5 +#define GL_LINEARDODGE_NV 0x92A4 +#define GL_LINEARLIGHT_NV 0x92A7 +#define GL_MINUS_CLAMPED_NV 0x92B3 +#define GL_MINUS_NV 0x929F +#define GL_MULTIPLY_NV 0x9294 +#define GL_OVERLAY_NV 0x9296 +#define GL_PINLIGHT_NV 0x92A8 +#define GL_PLUS_CLAMPED_ALPHA_NV 0x92B2 +#define GL_PLUS_CLAMPED_NV 0x92B1 +#define GL_PLUS_DARKER_NV 0x9292 +#define GL_PLUS_NV 0x9291 +#define GL_RED_NV 0x1903 +#define GL_SCREEN_NV 0x9295 +#define GL_SOFTLIGHT_NV 0x929C +#define GL_SRC_ATOP_NV 0x928E +#define GL_SRC_IN_NV 0x928A +#define GL_SRC_NV 0x9286 +#define GL_SRC_OUT_NV 0x928C +#define GL_SRC_OVER_NV 0x9288 +#define GL_UNCORRELATED_NV 0x9282 +#define GL_VIVIDLIGHT_NV 0x92A6 +#define GL_XOR_NV 0x1506 +typedef void (APIENTRYP PFNGLBLENDPARAMETERINVPROC) (GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLBLENDBARRIERNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendParameteriNV (GLenum pname, GLint value); +GLAPI void APIENTRY glBlendBarrierNV (void); +#endif +#endif /* GL_NV_blend_equation_advanced */ + +#ifndef GL_NV_blend_equation_advanced_coherent +#define GL_NV_blend_equation_advanced_coherent 1 +#define GL_BLEND_ADVANCED_COHERENT_NV 0x9285 +#endif /* GL_NV_blend_equation_advanced_coherent */ + +#ifndef GL_NV_blend_minmax_factor +#define GL_NV_blend_minmax_factor 1 +#endif /* GL_NV_blend_minmax_factor */ + +#ifndef GL_NV_blend_square +#define GL_NV_blend_square 1 +#endif /* GL_NV_blend_square */ + +#ifndef GL_NV_clip_space_w_scaling +#define GL_NV_clip_space_w_scaling 1 +#define GL_VIEWPORT_POSITION_W_SCALE_NV 0x937C +#define GL_VIEWPORT_POSITION_W_SCALE_X_COEFF_NV 0x937D +#define GL_VIEWPORT_POSITION_W_SCALE_Y_COEFF_NV 0x937E +typedef void (APIENTRYP PFNGLVIEWPORTPOSITIONWSCALENVPROC) (GLuint index, GLfloat xcoeff, GLfloat ycoeff); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glViewportPositionWScaleNV (GLuint index, GLfloat xcoeff, GLfloat ycoeff); +#endif +#endif /* GL_NV_clip_space_w_scaling */ + +#ifndef GL_NV_command_list +#define GL_NV_command_list 1 +#define GL_TERMINATE_SEQUENCE_COMMAND_NV 0x0000 +#define GL_NOP_COMMAND_NV 0x0001 +#define GL_DRAW_ELEMENTS_COMMAND_NV 0x0002 +#define GL_DRAW_ARRAYS_COMMAND_NV 0x0003 +#define GL_DRAW_ELEMENTS_STRIP_COMMAND_NV 0x0004 +#define GL_DRAW_ARRAYS_STRIP_COMMAND_NV 0x0005 +#define GL_DRAW_ELEMENTS_INSTANCED_COMMAND_NV 0x0006 +#define GL_DRAW_ARRAYS_INSTANCED_COMMAND_NV 0x0007 +#define GL_ELEMENT_ADDRESS_COMMAND_NV 0x0008 +#define GL_ATTRIBUTE_ADDRESS_COMMAND_NV 0x0009 +#define GL_UNIFORM_ADDRESS_COMMAND_NV 0x000A +#define GL_BLEND_COLOR_COMMAND_NV 0x000B +#define GL_STENCIL_REF_COMMAND_NV 0x000C +#define GL_LINE_WIDTH_COMMAND_NV 0x000D +#define GL_POLYGON_OFFSET_COMMAND_NV 0x000E +#define GL_ALPHA_REF_COMMAND_NV 0x000F +#define GL_VIEWPORT_COMMAND_NV 0x0010 +#define GL_SCISSOR_COMMAND_NV 0x0011 +#define GL_FRONT_FACE_COMMAND_NV 0x0012 +typedef void (APIENTRYP PFNGLCREATESTATESNVPROC) (GLsizei n, GLuint *states); +typedef void (APIENTRYP PFNGLDELETESTATESNVPROC) (GLsizei n, const GLuint *states); +typedef GLboolean (APIENTRYP PFNGLISSTATENVPROC) (GLuint state); +typedef void (APIENTRYP PFNGLSTATECAPTURENVPROC) (GLuint state, GLenum mode); +typedef GLuint (APIENTRYP PFNGLGETCOMMANDHEADERNVPROC) (GLenum tokenID, GLuint size); +typedef GLushort (APIENTRYP PFNGLGETSTAGEINDEXNVPROC) (GLenum shadertype); +typedef void (APIENTRYP PFNGLDRAWCOMMANDSNVPROC) (GLenum primitiveMode, GLuint buffer, const GLintptr *indirects, const GLsizei *sizes, GLuint count); +typedef void (APIENTRYP PFNGLDRAWCOMMANDSADDRESSNVPROC) (GLenum primitiveMode, const GLuint64 *indirects, const GLsizei *sizes, GLuint count); +typedef void (APIENTRYP PFNGLDRAWCOMMANDSSTATESNVPROC) (GLuint buffer, const GLintptr *indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); +typedef void (APIENTRYP PFNGLDRAWCOMMANDSSTATESADDRESSNVPROC) (const GLuint64 *indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); +typedef void (APIENTRYP PFNGLCREATECOMMANDLISTSNVPROC) (GLsizei n, GLuint *lists); +typedef void (APIENTRYP PFNGLDELETECOMMANDLISTSNVPROC) (GLsizei n, const GLuint *lists); +typedef GLboolean (APIENTRYP PFNGLISCOMMANDLISTNVPROC) (GLuint list); +typedef void (APIENTRYP PFNGLLISTDRAWCOMMANDSSTATESCLIENTNVPROC) (GLuint list, GLuint segment, const void **indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); +typedef void (APIENTRYP PFNGLCOMMANDLISTSEGMENTSNVPROC) (GLuint list, GLuint segments); +typedef void (APIENTRYP PFNGLCOMPILECOMMANDLISTNVPROC) (GLuint list); +typedef void (APIENTRYP PFNGLCALLCOMMANDLISTNVPROC) (GLuint list); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCreateStatesNV (GLsizei n, GLuint *states); +GLAPI void APIENTRY glDeleteStatesNV (GLsizei n, const GLuint *states); +GLAPI GLboolean APIENTRY glIsStateNV (GLuint state); +GLAPI void APIENTRY glStateCaptureNV (GLuint state, GLenum mode); +GLAPI GLuint APIENTRY glGetCommandHeaderNV (GLenum tokenID, GLuint size); +GLAPI GLushort APIENTRY glGetStageIndexNV (GLenum shadertype); +GLAPI void APIENTRY glDrawCommandsNV (GLenum primitiveMode, GLuint buffer, const GLintptr *indirects, const GLsizei *sizes, GLuint count); +GLAPI void APIENTRY glDrawCommandsAddressNV (GLenum primitiveMode, const GLuint64 *indirects, const GLsizei *sizes, GLuint count); +GLAPI void APIENTRY glDrawCommandsStatesNV (GLuint buffer, const GLintptr *indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); +GLAPI void APIENTRY glDrawCommandsStatesAddressNV (const GLuint64 *indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); +GLAPI void APIENTRY glCreateCommandListsNV (GLsizei n, GLuint *lists); +GLAPI void APIENTRY glDeleteCommandListsNV (GLsizei n, const GLuint *lists); +GLAPI GLboolean APIENTRY glIsCommandListNV (GLuint list); +GLAPI void APIENTRY glListDrawCommandsStatesClientNV (GLuint list, GLuint segment, const void **indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); +GLAPI void APIENTRY glCommandListSegmentsNV (GLuint list, GLuint segments); +GLAPI void APIENTRY glCompileCommandListNV (GLuint list); +GLAPI void APIENTRY glCallCommandListNV (GLuint list); +#endif +#endif /* GL_NV_command_list */ + +#ifndef GL_NV_compute_program5 +#define GL_NV_compute_program5 1 +#define GL_COMPUTE_PROGRAM_NV 0x90FB +#define GL_COMPUTE_PROGRAM_PARAMETER_BUFFER_NV 0x90FC +#endif /* GL_NV_compute_program5 */ + +#ifndef GL_NV_compute_shader_derivatives +#define GL_NV_compute_shader_derivatives 1 +#endif /* GL_NV_compute_shader_derivatives */ + +#ifndef GL_NV_conditional_render +#define GL_NV_conditional_render 1 +#define GL_QUERY_WAIT_NV 0x8E13 +#define GL_QUERY_NO_WAIT_NV 0x8E14 +#define GL_QUERY_BY_REGION_WAIT_NV 0x8E15 +#define GL_QUERY_BY_REGION_NO_WAIT_NV 0x8E16 +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVPROC) (GLuint id, GLenum mode); +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginConditionalRenderNV (GLuint id, GLenum mode); +GLAPI void APIENTRY glEndConditionalRenderNV (void); +#endif +#endif /* GL_NV_conditional_render */ + +#ifndef GL_NV_conservative_raster +#define GL_NV_conservative_raster 1 +#define GL_CONSERVATIVE_RASTERIZATION_NV 0x9346 +#define GL_SUBPIXEL_PRECISION_BIAS_X_BITS_NV 0x9347 +#define GL_SUBPIXEL_PRECISION_BIAS_Y_BITS_NV 0x9348 +#define GL_MAX_SUBPIXEL_PRECISION_BIAS_BITS_NV 0x9349 +typedef void (APIENTRYP PFNGLSUBPIXELPRECISIONBIASNVPROC) (GLuint xbits, GLuint ybits); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSubpixelPrecisionBiasNV (GLuint xbits, GLuint ybits); +#endif +#endif /* GL_NV_conservative_raster */ + +#ifndef GL_NV_conservative_raster_dilate +#define GL_NV_conservative_raster_dilate 1 +#define GL_CONSERVATIVE_RASTER_DILATE_NV 0x9379 +#define GL_CONSERVATIVE_RASTER_DILATE_RANGE_NV 0x937A +#define GL_CONSERVATIVE_RASTER_DILATE_GRANULARITY_NV 0x937B +typedef void (APIENTRYP PFNGLCONSERVATIVERASTERPARAMETERFNVPROC) (GLenum pname, GLfloat value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glConservativeRasterParameterfNV (GLenum pname, GLfloat value); +#endif +#endif /* GL_NV_conservative_raster_dilate */ + +#ifndef GL_NV_conservative_raster_pre_snap +#define GL_NV_conservative_raster_pre_snap 1 +#define GL_CONSERVATIVE_RASTER_MODE_PRE_SNAP_NV 0x9550 +#endif /* GL_NV_conservative_raster_pre_snap */ + +#ifndef GL_NV_conservative_raster_pre_snap_triangles +#define GL_NV_conservative_raster_pre_snap_triangles 1 +#define GL_CONSERVATIVE_RASTER_MODE_NV 0x954D +#define GL_CONSERVATIVE_RASTER_MODE_POST_SNAP_NV 0x954E +#define GL_CONSERVATIVE_RASTER_MODE_PRE_SNAP_TRIANGLES_NV 0x954F +typedef void (APIENTRYP PFNGLCONSERVATIVERASTERPARAMETERINVPROC) (GLenum pname, GLint param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glConservativeRasterParameteriNV (GLenum pname, GLint param); +#endif +#endif /* GL_NV_conservative_raster_pre_snap_triangles */ + +#ifndef GL_NV_conservative_raster_underestimation +#define GL_NV_conservative_raster_underestimation 1 +#endif /* GL_NV_conservative_raster_underestimation */ + +#ifndef GL_NV_copy_depth_to_color +#define GL_NV_copy_depth_to_color 1 +#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E +#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F +#endif /* GL_NV_copy_depth_to_color */ + +#ifndef GL_NV_copy_image +#define GL_NV_copy_image 1 +typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATANVPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCopyImageSubDataNV (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#endif +#endif /* GL_NV_copy_image */ + +#ifndef GL_NV_deep_texture3D +#define GL_NV_deep_texture3D 1 +#define GL_MAX_DEEP_3D_TEXTURE_WIDTH_HEIGHT_NV 0x90D0 +#define GL_MAX_DEEP_3D_TEXTURE_DEPTH_NV 0x90D1 +#endif /* GL_NV_deep_texture3D */ + +#ifndef GL_NV_depth_buffer_float +#define GL_NV_depth_buffer_float 1 +#define GL_DEPTH_COMPONENT32F_NV 0x8DAB +#define GL_DEPTH32F_STENCIL8_NV 0x8DAC +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV 0x8DAD +#define GL_DEPTH_BUFFER_FLOAT_MODE_NV 0x8DAF +typedef void (APIENTRYP PFNGLDEPTHRANGEDNVPROC) (GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLCLEARDEPTHDNVPROC) (GLdouble depth); +typedef void (APIENTRYP PFNGLDEPTHBOUNDSDNVPROC) (GLdouble zmin, GLdouble zmax); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthRangedNV (GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glClearDepthdNV (GLdouble depth); +GLAPI void APIENTRY glDepthBoundsdNV (GLdouble zmin, GLdouble zmax); +#endif +#endif /* GL_NV_depth_buffer_float */ + +#ifndef GL_NV_depth_clamp +#define GL_NV_depth_clamp 1 +#define GL_DEPTH_CLAMP_NV 0x864F +#endif /* GL_NV_depth_clamp */ + +#ifndef GL_NV_draw_texture +#define GL_NV_draw_texture 1 +typedef void (APIENTRYP PFNGLDRAWTEXTURENVPROC) (GLuint texture, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawTextureNV (GLuint texture, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); +#endif +#endif /* GL_NV_draw_texture */ + +#ifndef GL_NV_draw_vulkan_image +#define GL_NV_draw_vulkan_image 1 +typedef void (APIENTRY *GLVULKANPROCNV)(void); +typedef void (APIENTRYP PFNGLDRAWVKIMAGENVPROC) (GLuint64 vkImage, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); +typedef GLVULKANPROCNV (APIENTRYP PFNGLGETVKPROCADDRNVPROC) (const GLchar *name); +typedef void (APIENTRYP PFNGLWAITVKSEMAPHORENVPROC) (GLuint64 vkSemaphore); +typedef void (APIENTRYP PFNGLSIGNALVKSEMAPHORENVPROC) (GLuint64 vkSemaphore); +typedef void (APIENTRYP PFNGLSIGNALVKFENCENVPROC) (GLuint64 vkFence); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawVkImageNV (GLuint64 vkImage, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); +GLAPI GLVULKANPROCNV APIENTRY glGetVkProcAddrNV (const GLchar *name); +GLAPI void APIENTRY glWaitVkSemaphoreNV (GLuint64 vkSemaphore); +GLAPI void APIENTRY glSignalVkSemaphoreNV (GLuint64 vkSemaphore); +GLAPI void APIENTRY glSignalVkFenceNV (GLuint64 vkFence); +#endif +#endif /* GL_NV_draw_vulkan_image */ + +#ifndef GL_NV_evaluators +#define GL_NV_evaluators 1 +#define GL_EVAL_2D_NV 0x86C0 +#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 +#define GL_MAP_TESSELLATION_NV 0x86C2 +#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 +#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 +#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 +#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 +#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 +#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 +#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 +#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA +#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB +#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC +#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD +#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE +#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF +#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 +#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 +#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 +#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 +#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 +#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 +#define GL_MAX_MAP_TESSELLATION_NV 0x86D6 +#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 +typedef void (APIENTRYP PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const void *points); +typedef void (APIENTRYP PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, void *points); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const void *points); +GLAPI void APIENTRY glMapParameterivNV (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMapParameterfvNV (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, void *points); +GLAPI void APIENTRY glGetMapParameterivNV (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMapParameterfvNV (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMapAttribParameterivNV (GLenum target, GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMapAttribParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glEvalMapsNV (GLenum target, GLenum mode); +#endif +#endif /* GL_NV_evaluators */ + +#ifndef GL_NV_explicit_multisample +#define GL_NV_explicit_multisample 1 +#define GL_SAMPLE_POSITION_NV 0x8E50 +#define GL_SAMPLE_MASK_NV 0x8E51 +#define GL_SAMPLE_MASK_VALUE_NV 0x8E52 +#define GL_TEXTURE_BINDING_RENDERBUFFER_NV 0x8E53 +#define GL_TEXTURE_RENDERBUFFER_DATA_STORE_BINDING_NV 0x8E54 +#define GL_TEXTURE_RENDERBUFFER_NV 0x8E55 +#define GL_SAMPLER_RENDERBUFFER_NV 0x8E56 +#define GL_INT_SAMPLER_RENDERBUFFER_NV 0x8E57 +#define GL_UNSIGNED_INT_SAMPLER_RENDERBUFFER_NV 0x8E58 +#define GL_MAX_SAMPLE_MASK_WORDS_NV 0x8E59 +typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVNVPROC) (GLenum pname, GLuint index, GLfloat *val); +typedef void (APIENTRYP PFNGLSAMPLEMASKINDEXEDNVPROC) (GLuint index, GLbitfield mask); +typedef void (APIENTRYP PFNGLTEXRENDERBUFFERNVPROC) (GLenum target, GLuint renderbuffer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetMultisamplefvNV (GLenum pname, GLuint index, GLfloat *val); +GLAPI void APIENTRY glSampleMaskIndexedNV (GLuint index, GLbitfield mask); +GLAPI void APIENTRY glTexRenderbufferNV (GLenum target, GLuint renderbuffer); +#endif +#endif /* GL_NV_explicit_multisample */ + +#ifndef GL_NV_fence +#define GL_NV_fence 1 +#define GL_ALL_COMPLETED_NV 0x84F2 +#define GL_FENCE_STATUS_NV 0x84F3 +#define GL_FENCE_CONDITION_NV 0x84F4 +typedef void (APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); +typedef GLboolean (APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeleteFencesNV (GLsizei n, const GLuint *fences); +GLAPI void APIENTRY glGenFencesNV (GLsizei n, GLuint *fences); +GLAPI GLboolean APIENTRY glIsFenceNV (GLuint fence); +GLAPI GLboolean APIENTRY glTestFenceNV (GLuint fence); +GLAPI void APIENTRY glGetFenceivNV (GLuint fence, GLenum pname, GLint *params); +GLAPI void APIENTRY glFinishFenceNV (GLuint fence); +GLAPI void APIENTRY glSetFenceNV (GLuint fence, GLenum condition); +#endif +#endif /* GL_NV_fence */ + +#ifndef GL_NV_fill_rectangle +#define GL_NV_fill_rectangle 1 +#define GL_FILL_RECTANGLE_NV 0x933C +#endif /* GL_NV_fill_rectangle */ + +#ifndef GL_NV_float_buffer +#define GL_NV_float_buffer 1 +#define GL_FLOAT_R_NV 0x8880 +#define GL_FLOAT_RG_NV 0x8881 +#define GL_FLOAT_RGB_NV 0x8882 +#define GL_FLOAT_RGBA_NV 0x8883 +#define GL_FLOAT_R16_NV 0x8884 +#define GL_FLOAT_R32_NV 0x8885 +#define GL_FLOAT_RG16_NV 0x8886 +#define GL_FLOAT_RG32_NV 0x8887 +#define GL_FLOAT_RGB16_NV 0x8888 +#define GL_FLOAT_RGB32_NV 0x8889 +#define GL_FLOAT_RGBA16_NV 0x888A +#define GL_FLOAT_RGBA32_NV 0x888B +#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C +#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D +#define GL_FLOAT_RGBA_MODE_NV 0x888E +#endif /* GL_NV_float_buffer */ + +#ifndef GL_NV_fog_distance +#define GL_NV_fog_distance 1 +#define GL_FOG_DISTANCE_MODE_NV 0x855A +#define GL_EYE_RADIAL_NV 0x855B +#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C +#endif /* GL_NV_fog_distance */ + +#ifndef GL_NV_fragment_coverage_to_color +#define GL_NV_fragment_coverage_to_color 1 +#define GL_FRAGMENT_COVERAGE_TO_COLOR_NV 0x92DD +#define GL_FRAGMENT_COVERAGE_COLOR_NV 0x92DE +typedef void (APIENTRYP PFNGLFRAGMENTCOVERAGECOLORNVPROC) (GLuint color); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFragmentCoverageColorNV (GLuint color); +#endif +#endif /* GL_NV_fragment_coverage_to_color */ + +#ifndef GL_NV_fragment_program +#define GL_NV_fragment_program 1 +#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 +#define GL_FRAGMENT_PROGRAM_NV 0x8870 +#define GL_MAX_TEXTURE_COORDS_NV 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 +#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 +#define GL_PROGRAM_ERROR_STRING_NV 0x8874 +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); +GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); +GLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); +GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); +#endif +#endif /* GL_NV_fragment_program */ + +#ifndef GL_NV_fragment_program2 +#define GL_NV_fragment_program2 1 +#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 +#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 +#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6 +#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 +#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 +#endif /* GL_NV_fragment_program2 */ + +#ifndef GL_NV_fragment_program4 +#define GL_NV_fragment_program4 1 +#endif /* GL_NV_fragment_program4 */ + +#ifndef GL_NV_fragment_program_option +#define GL_NV_fragment_program_option 1 +#endif /* GL_NV_fragment_program_option */ + +#ifndef GL_NV_fragment_shader_barycentric +#define GL_NV_fragment_shader_barycentric 1 +#endif /* GL_NV_fragment_shader_barycentric */ + +#ifndef GL_NV_fragment_shader_interlock +#define GL_NV_fragment_shader_interlock 1 +#endif /* GL_NV_fragment_shader_interlock */ + +#ifndef GL_NV_framebuffer_mixed_samples +#define GL_NV_framebuffer_mixed_samples 1 +#define GL_COVERAGE_MODULATION_TABLE_NV 0x9331 +#define GL_COLOR_SAMPLES_NV 0x8E20 +#define GL_DEPTH_SAMPLES_NV 0x932D +#define GL_STENCIL_SAMPLES_NV 0x932E +#define GL_MIXED_DEPTH_SAMPLES_SUPPORTED_NV 0x932F +#define GL_MIXED_STENCIL_SAMPLES_SUPPORTED_NV 0x9330 +#define GL_COVERAGE_MODULATION_NV 0x9332 +#define GL_COVERAGE_MODULATION_TABLE_SIZE_NV 0x9333 +typedef void (APIENTRYP PFNGLCOVERAGEMODULATIONTABLENVPROC) (GLsizei n, const GLfloat *v); +typedef void (APIENTRYP PFNGLGETCOVERAGEMODULATIONTABLENVPROC) (GLsizei bufSize, GLfloat *v); +typedef void (APIENTRYP PFNGLCOVERAGEMODULATIONNVPROC) (GLenum components); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCoverageModulationTableNV (GLsizei n, const GLfloat *v); +GLAPI void APIENTRY glGetCoverageModulationTableNV (GLsizei bufSize, GLfloat *v); +GLAPI void APIENTRY glCoverageModulationNV (GLenum components); +#endif +#endif /* GL_NV_framebuffer_mixed_samples */ + +#ifndef GL_NV_framebuffer_multisample_coverage +#define GL_NV_framebuffer_multisample_coverage 1 +#define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB +#define GL_RENDERBUFFER_COLOR_SAMPLES_NV 0x8E10 +#define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11 +#define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12 +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderbufferStorageMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +#endif +#endif /* GL_NV_framebuffer_multisample_coverage */ + +#ifndef GL_NV_geometry_program4 +#define GL_NV_geometry_program4 1 +#define GL_GEOMETRY_PROGRAM_NV 0x8C26 +#define GL_MAX_PROGRAM_OUTPUT_VERTICES_NV 0x8C27 +#define GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV 0x8C28 +typedef void (APIENTRYP PFNGLPROGRAMVERTEXLIMITNVPROC) (GLenum target, GLint limit); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramVertexLimitNV (GLenum target, GLint limit); +GLAPI void APIENTRY glFramebufferTextureEXT (GLenum target, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTextureFaceEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif +#endif /* GL_NV_geometry_program4 */ + +#ifndef GL_NV_geometry_shader4 +#define GL_NV_geometry_shader4 1 +#endif /* GL_NV_geometry_shader4 */ + +#ifndef GL_NV_geometry_shader_passthrough +#define GL_NV_geometry_shader_passthrough 1 +#endif /* GL_NV_geometry_shader_passthrough */ + +#ifndef GL_NV_gpu_multicast +#define GL_NV_gpu_multicast 1 +#define GL_PER_GPU_STORAGE_BIT_NV 0x0800 +#define GL_MULTICAST_GPUS_NV 0x92BA +#define GL_RENDER_GPU_MASK_NV 0x9558 +#define GL_PER_GPU_STORAGE_NV 0x9548 +#define GL_MULTICAST_PROGRAMMABLE_SAMPLE_LOCATION_NV 0x9549 +typedef void (APIENTRYP PFNGLRENDERGPUMASKNVPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLMULTICASTBUFFERSUBDATANVPROC) (GLbitfield gpuMask, GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +typedef void (APIENTRYP PFNGLMULTICASTCOPYBUFFERSUBDATANVPROC) (GLuint readGPU, GLbitfield writeGPUMask, GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLMULTICASTCOPYIMAGESUBDATANVPROC) (GLuint srcGPU, GLbitfield dstGPUMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +typedef void (APIENTRYP PFNGLMULTICASTBLITFRAMEBUFFERNVPROC) (GLuint srcGPU, GLuint dstGPU, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef void (APIENTRYP PFNGLMULTICASTFRAMEBUFFERSAMPLELOCATIONSFVNVPROC) (GLuint gpu, GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTICASTBARRIERNVPROC) (void); +typedef void (APIENTRYP PFNGLMULTICASTWAITSYNCNVPROC) (GLuint signalGPU, GLbitfield waitGPUMask); +typedef void (APIENTRYP PFNGLMULTICASTGETQUERYOBJECTIVNVPROC) (GLuint gpu, GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLMULTICASTGETQUERYOBJECTUIVNVPROC) (GLuint gpu, GLuint id, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLMULTICASTGETQUERYOBJECTI64VNVPROC) (GLuint gpu, GLuint id, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLMULTICASTGETQUERYOBJECTUI64VNVPROC) (GLuint gpu, GLuint id, GLenum pname, GLuint64 *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderGPUMaskNV (GLbitfield mask); +GLAPI void APIENTRY glMulticastBufferSubDataNV (GLbitfield gpuMask, GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +GLAPI void APIENTRY glMulticastCopyBufferSubDataNV (GLuint readGPU, GLbitfield writeGPUMask, GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GLAPI void APIENTRY glMulticastCopyImageSubDataNV (GLuint srcGPU, GLbitfield dstGPUMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +GLAPI void APIENTRY glMulticastBlitFramebufferNV (GLuint srcGPU, GLuint dstGPU, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +GLAPI void APIENTRY glMulticastFramebufferSampleLocationsfvNV (GLuint gpu, GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glMulticastBarrierNV (void); +GLAPI void APIENTRY glMulticastWaitSyncNV (GLuint signalGPU, GLbitfield waitGPUMask); +GLAPI void APIENTRY glMulticastGetQueryObjectivNV (GLuint gpu, GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glMulticastGetQueryObjectuivNV (GLuint gpu, GLuint id, GLenum pname, GLuint *params); +GLAPI void APIENTRY glMulticastGetQueryObjecti64vNV (GLuint gpu, GLuint id, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glMulticastGetQueryObjectui64vNV (GLuint gpu, GLuint id, GLenum pname, GLuint64 *params); +#endif +#endif /* GL_NV_gpu_multicast */ + +#ifndef GL_NV_gpu_program4 +#define GL_NV_gpu_program4 1 +#define GL_MIN_PROGRAM_TEXEL_OFFSET_NV 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET_NV 0x8905 +#define GL_PROGRAM_ATTRIB_COMPONENTS_NV 0x8906 +#define GL_PROGRAM_RESULT_COMPONENTS_NV 0x8907 +#define GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV 0x8908 +#define GL_MAX_PROGRAM_RESULT_COMPONENTS_NV 0x8909 +#define GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV 0x8DA5 +#define GL_MAX_PROGRAM_GENERIC_RESULTS_NV 0x8DA6 +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramLocalParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glProgramLocalParameterI4ivNV (GLenum target, GLuint index, const GLint *params); +GLAPI void APIENTRY glProgramLocalParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glProgramLocalParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glProgramLocalParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); +GLAPI void APIENTRY glProgramLocalParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glProgramEnvParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glProgramEnvParameterI4ivNV (GLenum target, GLuint index, const GLint *params); +GLAPI void APIENTRY glProgramEnvParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glProgramEnvParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glProgramEnvParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); +GLAPI void APIENTRY glProgramEnvParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glGetProgramLocalParameterIivNV (GLenum target, GLuint index, GLint *params); +GLAPI void APIENTRY glGetProgramLocalParameterIuivNV (GLenum target, GLuint index, GLuint *params); +GLAPI void APIENTRY glGetProgramEnvParameterIivNV (GLenum target, GLuint index, GLint *params); +GLAPI void APIENTRY glGetProgramEnvParameterIuivNV (GLenum target, GLuint index, GLuint *params); +#endif +#endif /* GL_NV_gpu_program4 */ + +#ifndef GL_NV_gpu_program5 +#define GL_NV_gpu_program5 1 +#define GL_MAX_GEOMETRY_PROGRAM_INVOCATIONS_NV 0x8E5A +#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5B +#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5C +#define GL_FRAGMENT_PROGRAM_INTERPOLATION_OFFSET_BITS_NV 0x8E5D +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5F +#define GL_MAX_PROGRAM_SUBROUTINE_PARAMETERS_NV 0x8F44 +#define GL_MAX_PROGRAM_SUBROUTINE_NUM_NV 0x8F45 +typedef void (APIENTRYP PFNGLPROGRAMSUBROUTINEPARAMETERSUIVNVPROC) (GLenum target, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSUBROUTINEPARAMETERUIVNVPROC) (GLenum target, GLuint index, GLuint *param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramSubroutineParametersuivNV (GLenum target, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glGetProgramSubroutineParameteruivNV (GLenum target, GLuint index, GLuint *param); +#endif +#endif /* GL_NV_gpu_program5 */ + +#ifndef GL_NV_gpu_program5_mem_extended +#define GL_NV_gpu_program5_mem_extended 1 +#endif /* GL_NV_gpu_program5_mem_extended */ + +#ifndef GL_NV_gpu_shader5 +#define GL_NV_gpu_shader5 1 +#endif /* GL_NV_gpu_shader5 */ + +#ifndef GL_NV_half_float +#define GL_NV_half_float 1 +typedef unsigned short GLhalfNV; +#define GL_HALF_FLOAT_NV 0x140B +typedef void (APIENTRYP PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); +typedef void (APIENTRYP PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); +typedef void (APIENTRYP PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD1HNVPROC) (GLhalfNV s); +typedef void (APIENTRYP PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLFOGCOORDHNVPROC) (GLhalfNV fog); +typedef void (APIENTRYP PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertex2hNV (GLhalfNV x, GLhalfNV y); +GLAPI void APIENTRY glVertex2hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glVertex3hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z); +GLAPI void APIENTRY glVertex3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glVertex4hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +GLAPI void APIENTRY glVertex4hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glNormal3hNV (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); +GLAPI void APIENTRY glNormal3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +GLAPI void APIENTRY glColor3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glColor4hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); +GLAPI void APIENTRY glColor4hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord1hNV (GLhalfNV s); +GLAPI void APIENTRY glTexCoord1hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord2hNV (GLhalfNV s, GLhalfNV t); +GLAPI void APIENTRY glTexCoord2hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord3hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r); +GLAPI void APIENTRY glTexCoord3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord4hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +GLAPI void APIENTRY glTexCoord4hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord1hNV (GLenum target, GLhalfNV s); +GLAPI void APIENTRY glMultiTexCoord1hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord2hNV (GLenum target, GLhalfNV s, GLhalfNV t); +GLAPI void APIENTRY glMultiTexCoord2hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord3hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); +GLAPI void APIENTRY glMultiTexCoord3hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord4hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +GLAPI void APIENTRY glMultiTexCoord4hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glFogCoordhNV (GLhalfNV fog); +GLAPI void APIENTRY glFogCoordhvNV (const GLhalfNV *fog); +GLAPI void APIENTRY glSecondaryColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +GLAPI void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glVertexWeighthNV (GLhalfNV weight); +GLAPI void APIENTRY glVertexWeighthvNV (const GLhalfNV *weight); +GLAPI void APIENTRY glVertexAttrib1hNV (GLuint index, GLhalfNV x); +GLAPI void APIENTRY glVertexAttrib1hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttrib2hNV (GLuint index, GLhalfNV x, GLhalfNV y); +GLAPI void APIENTRY glVertexAttrib2hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttrib3hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); +GLAPI void APIENTRY glVertexAttrib3hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttrib4hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +GLAPI void APIENTRY glVertexAttrib4hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs1hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs2hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs3hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs4hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +#endif +#endif /* GL_NV_half_float */ + +#ifndef GL_NV_internalformat_sample_query +#define GL_NV_internalformat_sample_query 1 +#define GL_MULTISAMPLES_NV 0x9371 +#define GL_SUPERSAMPLE_SCALE_X_NV 0x9372 +#define GL_SUPERSAMPLE_SCALE_Y_NV 0x9373 +#define GL_CONFORMANT_NV 0x9374 +typedef void (APIENTRYP PFNGLGETINTERNALFORMATSAMPLEIVNVPROC) (GLenum target, GLenum internalformat, GLsizei samples, GLenum pname, GLsizei count, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetInternalformatSampleivNV (GLenum target, GLenum internalformat, GLsizei samples, GLenum pname, GLsizei count, GLint *params); +#endif +#endif /* GL_NV_internalformat_sample_query */ + +#ifndef GL_NV_light_max_exponent +#define GL_NV_light_max_exponent 1 +#define GL_MAX_SHININESS_NV 0x8504 +#define GL_MAX_SPOT_EXPONENT_NV 0x8505 +#endif /* GL_NV_light_max_exponent */ + +#ifndef GL_NV_memory_attachment +#define GL_NV_memory_attachment 1 +#define GL_ATTACHED_MEMORY_OBJECT_NV 0x95A4 +#define GL_ATTACHED_MEMORY_OFFSET_NV 0x95A5 +#define GL_MEMORY_ATTACHABLE_ALIGNMENT_NV 0x95A6 +#define GL_MEMORY_ATTACHABLE_SIZE_NV 0x95A7 +#define GL_MEMORY_ATTACHABLE_NV 0x95A8 +#define GL_DETACHED_MEMORY_INCARNATION_NV 0x95A9 +#define GL_DETACHED_TEXTURES_NV 0x95AA +#define GL_DETACHED_BUFFERS_NV 0x95AB +#define GL_MAX_DETACHED_TEXTURES_NV 0x95AC +#define GL_MAX_DETACHED_BUFFERS_NV 0x95AD +typedef void (APIENTRYP PFNGLGETMEMORYOBJECTDETACHEDRESOURCESUIVNVPROC) (GLuint memory, GLenum pname, GLint first, GLsizei count, GLuint *params); +typedef void (APIENTRYP PFNGLRESETMEMORYOBJECTPARAMETERNVPROC) (GLuint memory, GLenum pname); +typedef void (APIENTRYP PFNGLTEXATTACHMEMORYNVPROC) (GLenum target, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLBUFFERATTACHMEMORYNVPROC) (GLenum target, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXTUREATTACHMEMORYNVPROC) (GLuint texture, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLNAMEDBUFFERATTACHMEMORYNVPROC) (GLuint buffer, GLuint memory, GLuint64 offset); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetMemoryObjectDetachedResourcesuivNV (GLuint memory, GLenum pname, GLint first, GLsizei count, GLuint *params); +GLAPI void APIENTRY glResetMemoryObjectParameterNV (GLuint memory, GLenum pname); +GLAPI void APIENTRY glTexAttachMemoryNV (GLenum target, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glBufferAttachMemoryNV (GLenum target, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTextureAttachMemoryNV (GLuint texture, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glNamedBufferAttachMemoryNV (GLuint buffer, GLuint memory, GLuint64 offset); +#endif +#endif /* GL_NV_memory_attachment */ + +#ifndef GL_NV_memory_object_sparse +#define GL_NV_memory_object_sparse 1 +typedef void (APIENTRYP PFNGLBUFFERPAGECOMMITMENTMEMNVPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLuint memory, GLuint64 memOffset, GLboolean commit); +typedef void (APIENTRYP PFNGLTEXPAGECOMMITMENTMEMNVPROC) (GLenum target, GLint layer, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset, GLboolean commit); +typedef void (APIENTRYP PFNGLNAMEDBUFFERPAGECOMMITMENTMEMNVPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLuint memory, GLuint64 memOffset, GLboolean commit); +typedef void (APIENTRYP PFNGLTEXTUREPAGECOMMITMENTMEMNVPROC) (GLuint texture, GLint layer, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset, GLboolean commit); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferPageCommitmentMemNV (GLenum target, GLintptr offset, GLsizeiptr size, GLuint memory, GLuint64 memOffset, GLboolean commit); +GLAPI void APIENTRY glTexPageCommitmentMemNV (GLenum target, GLint layer, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset, GLboolean commit); +GLAPI void APIENTRY glNamedBufferPageCommitmentMemNV (GLuint buffer, GLintptr offset, GLsizeiptr size, GLuint memory, GLuint64 memOffset, GLboolean commit); +GLAPI void APIENTRY glTexturePageCommitmentMemNV (GLuint texture, GLint layer, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset, GLboolean commit); +#endif +#endif /* GL_NV_memory_object_sparse */ + +#ifndef GL_NV_mesh_shader +#define GL_NV_mesh_shader 1 +#define GL_MESH_SHADER_NV 0x9559 +#define GL_TASK_SHADER_NV 0x955A +#define GL_MAX_MESH_UNIFORM_BLOCKS_NV 0x8E60 +#define GL_MAX_MESH_TEXTURE_IMAGE_UNITS_NV 0x8E61 +#define GL_MAX_MESH_IMAGE_UNIFORMS_NV 0x8E62 +#define GL_MAX_MESH_UNIFORM_COMPONENTS_NV 0x8E63 +#define GL_MAX_MESH_ATOMIC_COUNTER_BUFFERS_NV 0x8E64 +#define GL_MAX_MESH_ATOMIC_COUNTERS_NV 0x8E65 +#define GL_MAX_MESH_SHADER_STORAGE_BLOCKS_NV 0x8E66 +#define GL_MAX_COMBINED_MESH_UNIFORM_COMPONENTS_NV 0x8E67 +#define GL_MAX_TASK_UNIFORM_BLOCKS_NV 0x8E68 +#define GL_MAX_TASK_TEXTURE_IMAGE_UNITS_NV 0x8E69 +#define GL_MAX_TASK_IMAGE_UNIFORMS_NV 0x8E6A +#define GL_MAX_TASK_UNIFORM_COMPONENTS_NV 0x8E6B +#define GL_MAX_TASK_ATOMIC_COUNTER_BUFFERS_NV 0x8E6C +#define GL_MAX_TASK_ATOMIC_COUNTERS_NV 0x8E6D +#define GL_MAX_TASK_SHADER_STORAGE_BLOCKS_NV 0x8E6E +#define GL_MAX_COMBINED_TASK_UNIFORM_COMPONENTS_NV 0x8E6F +#define GL_MAX_MESH_WORK_GROUP_INVOCATIONS_NV 0x95A2 +#define GL_MAX_TASK_WORK_GROUP_INVOCATIONS_NV 0x95A3 +#define GL_MAX_MESH_TOTAL_MEMORY_SIZE_NV 0x9536 +#define GL_MAX_TASK_TOTAL_MEMORY_SIZE_NV 0x9537 +#define GL_MAX_MESH_OUTPUT_VERTICES_NV 0x9538 +#define GL_MAX_MESH_OUTPUT_PRIMITIVES_NV 0x9539 +#define GL_MAX_TASK_OUTPUT_COUNT_NV 0x953A +#define GL_MAX_DRAW_MESH_TASKS_COUNT_NV 0x953D +#define GL_MAX_MESH_VIEWS_NV 0x9557 +#define GL_MESH_OUTPUT_PER_VERTEX_GRANULARITY_NV 0x92DF +#define GL_MESH_OUTPUT_PER_PRIMITIVE_GRANULARITY_NV 0x9543 +#define GL_MAX_MESH_WORK_GROUP_SIZE_NV 0x953B +#define GL_MAX_TASK_WORK_GROUP_SIZE_NV 0x953C +#define GL_MESH_WORK_GROUP_SIZE_NV 0x953E +#define GL_TASK_WORK_GROUP_SIZE_NV 0x953F +#define GL_MESH_VERTICES_OUT_NV 0x9579 +#define GL_MESH_PRIMITIVES_OUT_NV 0x957A +#define GL_MESH_OUTPUT_TYPE_NV 0x957B +#define GL_UNIFORM_BLOCK_REFERENCED_BY_MESH_SHADER_NV 0x959C +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TASK_SHADER_NV 0x959D +#define GL_REFERENCED_BY_MESH_SHADER_NV 0x95A0 +#define GL_REFERENCED_BY_TASK_SHADER_NV 0x95A1 +#define GL_MESH_SHADER_BIT_NV 0x00000040 +#define GL_TASK_SHADER_BIT_NV 0x00000080 +#define GL_MESH_SUBROUTINE_NV 0x957C +#define GL_TASK_SUBROUTINE_NV 0x957D +#define GL_MESH_SUBROUTINE_UNIFORM_NV 0x957E +#define GL_TASK_SUBROUTINE_UNIFORM_NV 0x957F +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_MESH_SHADER_NV 0x959E +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TASK_SHADER_NV 0x959F +typedef void (APIENTRYP PFNGLDRAWMESHTASKSNVPROC) (GLuint first, GLuint count); +typedef void (APIENTRYP PFNGLDRAWMESHTASKSINDIRECTNVPROC) (GLintptr indirect); +typedef void (APIENTRYP PFNGLMULTIDRAWMESHTASKSINDIRECTNVPROC) (GLintptr indirect, GLsizei drawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWMESHTASKSINDIRECTCOUNTNVPROC) (GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawMeshTasksNV (GLuint first, GLuint count); +GLAPI void APIENTRY glDrawMeshTasksIndirectNV (GLintptr indirect); +GLAPI void APIENTRY glMultiDrawMeshTasksIndirectNV (GLintptr indirect, GLsizei drawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawMeshTasksIndirectCountNV (GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +#endif +#endif /* GL_NV_mesh_shader */ + +#ifndef GL_NV_multisample_coverage +#define GL_NV_multisample_coverage 1 +#endif /* GL_NV_multisample_coverage */ + +#ifndef GL_NV_multisample_filter_hint +#define GL_NV_multisample_filter_hint 1 +#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 +#endif /* GL_NV_multisample_filter_hint */ + +#ifndef GL_NV_occlusion_query +#define GL_NV_occlusion_query 1 +#define GL_PIXEL_COUNTER_BITS_NV 0x8864 +#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 +#define GL_PIXEL_COUNT_NV 0x8866 +#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 +typedef void (APIENTRYP PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLENDOCCLUSIONQUERYNVPROC) (void); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenOcclusionQueriesNV (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteOcclusionQueriesNV (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsOcclusionQueryNV (GLuint id); +GLAPI void APIENTRY glBeginOcclusionQueryNV (GLuint id); +GLAPI void APIENTRY glEndOcclusionQueryNV (void); +GLAPI void APIENTRY glGetOcclusionQueryivNV (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetOcclusionQueryuivNV (GLuint id, GLenum pname, GLuint *params); +#endif +#endif /* GL_NV_occlusion_query */ + +#ifndef GL_NV_packed_depth_stencil +#define GL_NV_packed_depth_stencil 1 +#define GL_DEPTH_STENCIL_NV 0x84F9 +#define GL_UNSIGNED_INT_24_8_NV 0x84FA +#endif /* GL_NV_packed_depth_stencil */ + +#ifndef GL_NV_parameter_buffer_object +#define GL_NV_parameter_buffer_object 1 +#define GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV 0x8DA0 +#define GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV 0x8DA1 +#define GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV 0x8DA2 +#define GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV 0x8DA3 +#define GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV 0x8DA4 +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramBufferParametersfvNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glProgramBufferParametersIivNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLint *params); +GLAPI void APIENTRY glProgramBufferParametersIuivNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLuint *params); +#endif +#endif /* GL_NV_parameter_buffer_object */ + +#ifndef GL_NV_parameter_buffer_object2 +#define GL_NV_parameter_buffer_object2 1 +#endif /* GL_NV_parameter_buffer_object2 */ + +#ifndef GL_NV_path_rendering +#define GL_NV_path_rendering 1 +#define GL_PATH_FORMAT_SVG_NV 0x9070 +#define GL_PATH_FORMAT_PS_NV 0x9071 +#define GL_STANDARD_FONT_NAME_NV 0x9072 +#define GL_SYSTEM_FONT_NAME_NV 0x9073 +#define GL_FILE_NAME_NV 0x9074 +#define GL_PATH_STROKE_WIDTH_NV 0x9075 +#define GL_PATH_END_CAPS_NV 0x9076 +#define GL_PATH_INITIAL_END_CAP_NV 0x9077 +#define GL_PATH_TERMINAL_END_CAP_NV 0x9078 +#define GL_PATH_JOIN_STYLE_NV 0x9079 +#define GL_PATH_MITER_LIMIT_NV 0x907A +#define GL_PATH_DASH_CAPS_NV 0x907B +#define GL_PATH_INITIAL_DASH_CAP_NV 0x907C +#define GL_PATH_TERMINAL_DASH_CAP_NV 0x907D +#define GL_PATH_DASH_OFFSET_NV 0x907E +#define GL_PATH_CLIENT_LENGTH_NV 0x907F +#define GL_PATH_FILL_MODE_NV 0x9080 +#define GL_PATH_FILL_MASK_NV 0x9081 +#define GL_PATH_FILL_COVER_MODE_NV 0x9082 +#define GL_PATH_STROKE_COVER_MODE_NV 0x9083 +#define GL_PATH_STROKE_MASK_NV 0x9084 +#define GL_COUNT_UP_NV 0x9088 +#define GL_COUNT_DOWN_NV 0x9089 +#define GL_PATH_OBJECT_BOUNDING_BOX_NV 0x908A +#define GL_CONVEX_HULL_NV 0x908B +#define GL_BOUNDING_BOX_NV 0x908D +#define GL_TRANSLATE_X_NV 0x908E +#define GL_TRANSLATE_Y_NV 0x908F +#define GL_TRANSLATE_2D_NV 0x9090 +#define GL_TRANSLATE_3D_NV 0x9091 +#define GL_AFFINE_2D_NV 0x9092 +#define GL_AFFINE_3D_NV 0x9094 +#define GL_TRANSPOSE_AFFINE_2D_NV 0x9096 +#define GL_TRANSPOSE_AFFINE_3D_NV 0x9098 +#define GL_UTF8_NV 0x909A +#define GL_UTF16_NV 0x909B +#define GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV 0x909C +#define GL_PATH_COMMAND_COUNT_NV 0x909D +#define GL_PATH_COORD_COUNT_NV 0x909E +#define GL_PATH_DASH_ARRAY_COUNT_NV 0x909F +#define GL_PATH_COMPUTED_LENGTH_NV 0x90A0 +#define GL_PATH_FILL_BOUNDING_BOX_NV 0x90A1 +#define GL_PATH_STROKE_BOUNDING_BOX_NV 0x90A2 +#define GL_SQUARE_NV 0x90A3 +#define GL_ROUND_NV 0x90A4 +#define GL_TRIANGULAR_NV 0x90A5 +#define GL_BEVEL_NV 0x90A6 +#define GL_MITER_REVERT_NV 0x90A7 +#define GL_MITER_TRUNCATE_NV 0x90A8 +#define GL_SKIP_MISSING_GLYPH_NV 0x90A9 +#define GL_USE_MISSING_GLYPH_NV 0x90AA +#define GL_PATH_ERROR_POSITION_NV 0x90AB +#define GL_ACCUM_ADJACENT_PAIRS_NV 0x90AD +#define GL_ADJACENT_PAIRS_NV 0x90AE +#define GL_FIRST_TO_REST_NV 0x90AF +#define GL_PATH_GEN_MODE_NV 0x90B0 +#define GL_PATH_GEN_COEFF_NV 0x90B1 +#define GL_PATH_GEN_COMPONENTS_NV 0x90B3 +#define GL_PATH_STENCIL_FUNC_NV 0x90B7 +#define GL_PATH_STENCIL_REF_NV 0x90B8 +#define GL_PATH_STENCIL_VALUE_MASK_NV 0x90B9 +#define GL_PATH_STENCIL_DEPTH_OFFSET_FACTOR_NV 0x90BD +#define GL_PATH_STENCIL_DEPTH_OFFSET_UNITS_NV 0x90BE +#define GL_PATH_COVER_DEPTH_FUNC_NV 0x90BF +#define GL_PATH_DASH_OFFSET_RESET_NV 0x90B4 +#define GL_MOVE_TO_RESETS_NV 0x90B5 +#define GL_MOVE_TO_CONTINUES_NV 0x90B6 +#define GL_CLOSE_PATH_NV 0x00 +#define GL_MOVE_TO_NV 0x02 +#define GL_RELATIVE_MOVE_TO_NV 0x03 +#define GL_LINE_TO_NV 0x04 +#define GL_RELATIVE_LINE_TO_NV 0x05 +#define GL_HORIZONTAL_LINE_TO_NV 0x06 +#define GL_RELATIVE_HORIZONTAL_LINE_TO_NV 0x07 +#define GL_VERTICAL_LINE_TO_NV 0x08 +#define GL_RELATIVE_VERTICAL_LINE_TO_NV 0x09 +#define GL_QUADRATIC_CURVE_TO_NV 0x0A +#define GL_RELATIVE_QUADRATIC_CURVE_TO_NV 0x0B +#define GL_CUBIC_CURVE_TO_NV 0x0C +#define GL_RELATIVE_CUBIC_CURVE_TO_NV 0x0D +#define GL_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0E +#define GL_RELATIVE_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0F +#define GL_SMOOTH_CUBIC_CURVE_TO_NV 0x10 +#define GL_RELATIVE_SMOOTH_CUBIC_CURVE_TO_NV 0x11 +#define GL_SMALL_CCW_ARC_TO_NV 0x12 +#define GL_RELATIVE_SMALL_CCW_ARC_TO_NV 0x13 +#define GL_SMALL_CW_ARC_TO_NV 0x14 +#define GL_RELATIVE_SMALL_CW_ARC_TO_NV 0x15 +#define GL_LARGE_CCW_ARC_TO_NV 0x16 +#define GL_RELATIVE_LARGE_CCW_ARC_TO_NV 0x17 +#define GL_LARGE_CW_ARC_TO_NV 0x18 +#define GL_RELATIVE_LARGE_CW_ARC_TO_NV 0x19 +#define GL_RESTART_PATH_NV 0xF0 +#define GL_DUP_FIRST_CUBIC_CURVE_TO_NV 0xF2 +#define GL_DUP_LAST_CUBIC_CURVE_TO_NV 0xF4 +#define GL_RECT_NV 0xF6 +#define GL_CIRCULAR_CCW_ARC_TO_NV 0xF8 +#define GL_CIRCULAR_CW_ARC_TO_NV 0xFA +#define GL_CIRCULAR_TANGENT_ARC_TO_NV 0xFC +#define GL_ARC_TO_NV 0xFE +#define GL_RELATIVE_ARC_TO_NV 0xFF +#define GL_BOLD_BIT_NV 0x01 +#define GL_ITALIC_BIT_NV 0x02 +#define GL_GLYPH_WIDTH_BIT_NV 0x01 +#define GL_GLYPH_HEIGHT_BIT_NV 0x02 +#define GL_GLYPH_HORIZONTAL_BEARING_X_BIT_NV 0x04 +#define GL_GLYPH_HORIZONTAL_BEARING_Y_BIT_NV 0x08 +#define GL_GLYPH_HORIZONTAL_BEARING_ADVANCE_BIT_NV 0x10 +#define GL_GLYPH_VERTICAL_BEARING_X_BIT_NV 0x20 +#define GL_GLYPH_VERTICAL_BEARING_Y_BIT_NV 0x40 +#define GL_GLYPH_VERTICAL_BEARING_ADVANCE_BIT_NV 0x80 +#define GL_GLYPH_HAS_KERNING_BIT_NV 0x100 +#define GL_FONT_X_MIN_BOUNDS_BIT_NV 0x00010000 +#define GL_FONT_Y_MIN_BOUNDS_BIT_NV 0x00020000 +#define GL_FONT_X_MAX_BOUNDS_BIT_NV 0x00040000 +#define GL_FONT_Y_MAX_BOUNDS_BIT_NV 0x00080000 +#define GL_FONT_UNITS_PER_EM_BIT_NV 0x00100000 +#define GL_FONT_ASCENDER_BIT_NV 0x00200000 +#define GL_FONT_DESCENDER_BIT_NV 0x00400000 +#define GL_FONT_HEIGHT_BIT_NV 0x00800000 +#define GL_FONT_MAX_ADVANCE_WIDTH_BIT_NV 0x01000000 +#define GL_FONT_MAX_ADVANCE_HEIGHT_BIT_NV 0x02000000 +#define GL_FONT_UNDERLINE_POSITION_BIT_NV 0x04000000 +#define GL_FONT_UNDERLINE_THICKNESS_BIT_NV 0x08000000 +#define GL_FONT_HAS_KERNING_BIT_NV 0x10000000 +#define GL_ROUNDED_RECT_NV 0xE8 +#define GL_RELATIVE_ROUNDED_RECT_NV 0xE9 +#define GL_ROUNDED_RECT2_NV 0xEA +#define GL_RELATIVE_ROUNDED_RECT2_NV 0xEB +#define GL_ROUNDED_RECT4_NV 0xEC +#define GL_RELATIVE_ROUNDED_RECT4_NV 0xED +#define GL_ROUNDED_RECT8_NV 0xEE +#define GL_RELATIVE_ROUNDED_RECT8_NV 0xEF +#define GL_RELATIVE_RECT_NV 0xF7 +#define GL_FONT_GLYPHS_AVAILABLE_NV 0x9368 +#define GL_FONT_TARGET_UNAVAILABLE_NV 0x9369 +#define GL_FONT_UNAVAILABLE_NV 0x936A +#define GL_FONT_UNINTELLIGIBLE_NV 0x936B +#define GL_CONIC_CURVE_TO_NV 0x1A +#define GL_RELATIVE_CONIC_CURVE_TO_NV 0x1B +#define GL_FONT_NUM_GLYPH_INDICES_BIT_NV 0x20000000 +#define GL_STANDARD_FONT_FORMAT_NV 0x936C +#define GL_2_BYTES_NV 0x1407 +#define GL_3_BYTES_NV 0x1408 +#define GL_4_BYTES_NV 0x1409 +#define GL_EYE_LINEAR_NV 0x2400 +#define GL_OBJECT_LINEAR_NV 0x2401 +#define GL_CONSTANT_NV 0x8576 +#define GL_PATH_FOG_GEN_MODE_NV 0x90AC +#define GL_PRIMARY_COLOR_NV 0x852C +#define GL_SECONDARY_COLOR_NV 0x852D +#define GL_PATH_GEN_COLOR_FORMAT_NV 0x90B2 +#define GL_PATH_PROJECTION_NV 0x1701 +#define GL_PATH_MODELVIEW_NV 0x1700 +#define GL_PATH_MODELVIEW_STACK_DEPTH_NV 0x0BA3 +#define GL_PATH_MODELVIEW_MATRIX_NV 0x0BA6 +#define GL_PATH_MAX_MODELVIEW_STACK_DEPTH_NV 0x0D36 +#define GL_PATH_TRANSPOSE_MODELVIEW_MATRIX_NV 0x84E3 +#define GL_PATH_PROJECTION_STACK_DEPTH_NV 0x0BA4 +#define GL_PATH_PROJECTION_MATRIX_NV 0x0BA7 +#define GL_PATH_MAX_PROJECTION_STACK_DEPTH_NV 0x0D38 +#define GL_PATH_TRANSPOSE_PROJECTION_MATRIX_NV 0x84E4 +#define GL_FRAGMENT_INPUT_NV 0x936D +typedef GLuint (APIENTRYP PFNGLGENPATHSNVPROC) (GLsizei range); +typedef void (APIENTRYP PFNGLDELETEPATHSNVPROC) (GLuint path, GLsizei range); +typedef GLboolean (APIENTRYP PFNGLISPATHNVPROC) (GLuint path); +typedef void (APIENTRYP PFNGLPATHCOMMANDSNVPROC) (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); +typedef void (APIENTRYP PFNGLPATHCOORDSNVPROC) (GLuint path, GLsizei numCoords, GLenum coordType, const void *coords); +typedef void (APIENTRYP PFNGLPATHSUBCOMMANDSNVPROC) (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); +typedef void (APIENTRYP PFNGLPATHSUBCOORDSNVPROC) (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const void *coords); +typedef void (APIENTRYP PFNGLPATHSTRINGNVPROC) (GLuint path, GLenum format, GLsizei length, const void *pathString); +typedef void (APIENTRYP PFNGLPATHGLYPHSNVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const void *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef void (APIENTRYP PFNGLPATHGLYPHRANGENVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef void (APIENTRYP PFNGLWEIGHTPATHSNVPROC) (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); +typedef void (APIENTRYP PFNGLCOPYPATHNVPROC) (GLuint resultPath, GLuint srcPath); +typedef void (APIENTRYP PFNGLINTERPOLATEPATHSNVPROC) (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); +typedef void (APIENTRYP PFNGLTRANSFORMPATHNVPROC) (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, const GLint *value); +typedef void (APIENTRYP PFNGLPATHPARAMETERINVPROC) (GLuint path, GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, const GLfloat *value); +typedef void (APIENTRYP PFNGLPATHPARAMETERFNVPROC) (GLuint path, GLenum pname, GLfloat value); +typedef void (APIENTRYP PFNGLPATHDASHARRAYNVPROC) (GLuint path, GLsizei dashCount, const GLfloat *dashArray); +typedef void (APIENTRYP PFNGLPATHSTENCILFUNCNVPROC) (GLenum func, GLint ref, GLuint mask); +typedef void (APIENTRYP PFNGLPATHSTENCILDEPTHOFFSETNVPROC) (GLfloat factor, GLfloat units); +typedef void (APIENTRYP PFNGLSTENCILFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLPATHCOVERDEPTHFUNCNVPROC) (GLenum func); +typedef void (APIENTRYP PFNGLCOVERFILLPATHNVPROC) (GLuint path, GLenum coverMode); +typedef void (APIENTRYP PFNGLCOVERSTROKEPATHNVPROC) (GLuint path, GLenum coverMode); +typedef void (APIENTRYP PFNGLCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLGETPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, GLint *value); +typedef void (APIENTRYP PFNGLGETPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, GLfloat *value); +typedef void (APIENTRYP PFNGLGETPATHCOMMANDSNVPROC) (GLuint path, GLubyte *commands); +typedef void (APIENTRYP PFNGLGETPATHCOORDSNVPROC) (GLuint path, GLfloat *coords); +typedef void (APIENTRYP PFNGLGETPATHDASHARRAYNVPROC) (GLuint path, GLfloat *dashArray); +typedef void (APIENTRYP PFNGLGETPATHMETRICSNVPROC) (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); +typedef void (APIENTRYP PFNGLGETPATHMETRICRANGENVPROC) (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); +typedef void (APIENTRYP PFNGLGETPATHSPACINGNVPROC) (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); +typedef GLboolean (APIENTRYP PFNGLISPOINTINFILLPATHNVPROC) (GLuint path, GLuint mask, GLfloat x, GLfloat y); +typedef GLboolean (APIENTRYP PFNGLISPOINTINSTROKEPATHNVPROC) (GLuint path, GLfloat x, GLfloat y); +typedef GLfloat (APIENTRYP PFNGLGETPATHLENGTHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments); +typedef GLboolean (APIENTRYP PFNGLPOINTALONGPATHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); +typedef void (APIENTRYP PFNGLMATRIXLOAD3X2FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXLOAD3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSE3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULT3X2FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULT3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSE3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (APIENTRYP PFNGLSTENCILTHENCOVERFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask, GLenum coverMode); +typedef void (APIENTRYP PFNGLSTENCILTHENCOVERSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask, GLenum coverMode); +typedef void (APIENTRYP PFNGLSTENCILTHENCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLSTENCILTHENCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef GLenum (APIENTRYP PFNGLPATHGLYPHINDEXRANGENVPROC) (GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint pathParameterTemplate, GLfloat emScale, GLuint *baseAndCount); +typedef GLenum (APIENTRYP PFNGLPATHGLYPHINDEXARRAYNVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef GLenum (APIENTRYP PFNGLPATHMEMORYGLYPHINDEXARRAYNVPROC) (GLuint firstPathName, GLenum fontTarget, GLsizeiptr fontSize, const void *fontData, GLsizei faceIndex, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef void (APIENTRYP PFNGLPROGRAMPATHFRAGMENTINPUTGENNVPROC) (GLuint program, GLint location, GLenum genMode, GLint components, const GLfloat *coeffs); +typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCEFVNVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei count, GLsizei *length, GLfloat *params); +typedef void (APIENTRYP PFNGLPATHCOLORGENNVPROC) (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs); +typedef void (APIENTRYP PFNGLPATHTEXGENNVPROC) (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs); +typedef void (APIENTRYP PFNGLPATHFOGGENNVPROC) (GLenum genMode); +typedef void (APIENTRYP PFNGLGETPATHCOLORGENIVNVPROC) (GLenum color, GLenum pname, GLint *value); +typedef void (APIENTRYP PFNGLGETPATHCOLORGENFVNVPROC) (GLenum color, GLenum pname, GLfloat *value); +typedef void (APIENTRYP PFNGLGETPATHTEXGENIVNVPROC) (GLenum texCoordSet, GLenum pname, GLint *value); +typedef void (APIENTRYP PFNGLGETPATHTEXGENFVNVPROC) (GLenum texCoordSet, GLenum pname, GLfloat *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glGenPathsNV (GLsizei range); +GLAPI void APIENTRY glDeletePathsNV (GLuint path, GLsizei range); +GLAPI GLboolean APIENTRY glIsPathNV (GLuint path); +GLAPI void APIENTRY glPathCommandsNV (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); +GLAPI void APIENTRY glPathCoordsNV (GLuint path, GLsizei numCoords, GLenum coordType, const void *coords); +GLAPI void APIENTRY glPathSubCommandsNV (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); +GLAPI void APIENTRY glPathSubCoordsNV (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const void *coords); +GLAPI void APIENTRY glPathStringNV (GLuint path, GLenum format, GLsizei length, const void *pathString); +GLAPI void APIENTRY glPathGlyphsNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const void *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GLAPI void APIENTRY glPathGlyphRangeNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GLAPI void APIENTRY glWeightPathsNV (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); +GLAPI void APIENTRY glCopyPathNV (GLuint resultPath, GLuint srcPath); +GLAPI void APIENTRY glInterpolatePathsNV (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); +GLAPI void APIENTRY glTransformPathNV (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glPathParameterivNV (GLuint path, GLenum pname, const GLint *value); +GLAPI void APIENTRY glPathParameteriNV (GLuint path, GLenum pname, GLint value); +GLAPI void APIENTRY glPathParameterfvNV (GLuint path, GLenum pname, const GLfloat *value); +GLAPI void APIENTRY glPathParameterfNV (GLuint path, GLenum pname, GLfloat value); +GLAPI void APIENTRY glPathDashArrayNV (GLuint path, GLsizei dashCount, const GLfloat *dashArray); +GLAPI void APIENTRY glPathStencilFuncNV (GLenum func, GLint ref, GLuint mask); +GLAPI void APIENTRY glPathStencilDepthOffsetNV (GLfloat factor, GLfloat units); +GLAPI void APIENTRY glStencilFillPathNV (GLuint path, GLenum fillMode, GLuint mask); +GLAPI void APIENTRY glStencilStrokePathNV (GLuint path, GLint reference, GLuint mask); +GLAPI void APIENTRY glStencilFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glStencilStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glPathCoverDepthFuncNV (GLenum func); +GLAPI void APIENTRY glCoverFillPathNV (GLuint path, GLenum coverMode); +GLAPI void APIENTRY glCoverStrokePathNV (GLuint path, GLenum coverMode); +GLAPI void APIENTRY glCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glCoverStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glGetPathParameterivNV (GLuint path, GLenum pname, GLint *value); +GLAPI void APIENTRY glGetPathParameterfvNV (GLuint path, GLenum pname, GLfloat *value); +GLAPI void APIENTRY glGetPathCommandsNV (GLuint path, GLubyte *commands); +GLAPI void APIENTRY glGetPathCoordsNV (GLuint path, GLfloat *coords); +GLAPI void APIENTRY glGetPathDashArrayNV (GLuint path, GLfloat *dashArray); +GLAPI void APIENTRY glGetPathMetricsNV (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); +GLAPI void APIENTRY glGetPathMetricRangeNV (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); +GLAPI void APIENTRY glGetPathSpacingNV (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); +GLAPI GLboolean APIENTRY glIsPointInFillPathNV (GLuint path, GLuint mask, GLfloat x, GLfloat y); +GLAPI GLboolean APIENTRY glIsPointInStrokePathNV (GLuint path, GLfloat x, GLfloat y); +GLAPI GLfloat APIENTRY glGetPathLengthNV (GLuint path, GLsizei startSegment, GLsizei numSegments); +GLAPI GLboolean APIENTRY glPointAlongPathNV (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); +GLAPI void APIENTRY glMatrixLoad3x2fNV (GLenum matrixMode, const GLfloat *m); +GLAPI void APIENTRY glMatrixLoad3x3fNV (GLenum matrixMode, const GLfloat *m); +GLAPI void APIENTRY glMatrixLoadTranspose3x3fNV (GLenum matrixMode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMult3x2fNV (GLenum matrixMode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMult3x3fNV (GLenum matrixMode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMultTranspose3x3fNV (GLenum matrixMode, const GLfloat *m); +GLAPI void APIENTRY glStencilThenCoverFillPathNV (GLuint path, GLenum fillMode, GLuint mask, GLenum coverMode); +GLAPI void APIENTRY glStencilThenCoverStrokePathNV (GLuint path, GLint reference, GLuint mask, GLenum coverMode); +GLAPI void APIENTRY glStencilThenCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glStencilThenCoverStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GLAPI GLenum APIENTRY glPathGlyphIndexRangeNV (GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint pathParameterTemplate, GLfloat emScale, GLuint *baseAndCount); +GLAPI GLenum APIENTRY glPathGlyphIndexArrayNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GLAPI GLenum APIENTRY glPathMemoryGlyphIndexArrayNV (GLuint firstPathName, GLenum fontTarget, GLsizeiptr fontSize, const void *fontData, GLsizei faceIndex, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GLAPI void APIENTRY glProgramPathFragmentInputGenNV (GLuint program, GLint location, GLenum genMode, GLint components, const GLfloat *coeffs); +GLAPI void APIENTRY glGetProgramResourcefvNV (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei count, GLsizei *length, GLfloat *params); +GLAPI void APIENTRY glPathColorGenNV (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs); +GLAPI void APIENTRY glPathTexGenNV (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs); +GLAPI void APIENTRY glPathFogGenNV (GLenum genMode); +GLAPI void APIENTRY glGetPathColorGenivNV (GLenum color, GLenum pname, GLint *value); +GLAPI void APIENTRY glGetPathColorGenfvNV (GLenum color, GLenum pname, GLfloat *value); +GLAPI void APIENTRY glGetPathTexGenivNV (GLenum texCoordSet, GLenum pname, GLint *value); +GLAPI void APIENTRY glGetPathTexGenfvNV (GLenum texCoordSet, GLenum pname, GLfloat *value); +#endif +#endif /* GL_NV_path_rendering */ + +#ifndef GL_NV_path_rendering_shared_edge +#define GL_NV_path_rendering_shared_edge 1 +#define GL_SHARED_EDGE_NV 0xC0 +#endif /* GL_NV_path_rendering_shared_edge */ + +#ifndef GL_NV_pixel_data_range +#define GL_NV_pixel_data_range 1 +#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 +#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 +#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A +#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B +#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C +#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D +typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, const void *pointer); +typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelDataRangeNV (GLenum target, GLsizei length, const void *pointer); +GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum target); +#endif +#endif /* GL_NV_pixel_data_range */ + +#ifndef GL_NV_point_sprite +#define GL_NV_point_sprite 1 +#define GL_POINT_SPRITE_NV 0x8861 +#define GL_COORD_REPLACE_NV 0x8862 +#define GL_POINT_SPRITE_R_MODE_NV 0x8863 +typedef void (APIENTRYP PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameteriNV (GLenum pname, GLint param); +GLAPI void APIENTRY glPointParameterivNV (GLenum pname, const GLint *params); +#endif +#endif /* GL_NV_point_sprite */ + +#ifndef GL_NV_present_video +#define GL_NV_present_video 1 +#define GL_FRAME_NV 0x8E26 +#define GL_FIELDS_NV 0x8E27 +#define GL_CURRENT_TIME_NV 0x8E28 +#define GL_NUM_FILL_STREAMS_NV 0x8E29 +#define GL_PRESENT_TIME_NV 0x8E2A +#define GL_PRESENT_DURATION_NV 0x8E2B +typedef void (APIENTRYP PFNGLPRESENTFRAMEKEYEDNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); +typedef void (APIENTRYP PFNGLPRESENTFRAMEDUALFILLNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); +typedef void (APIENTRYP PFNGLGETVIDEOIVNVPROC) (GLuint video_slot, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVIDEOUIVNVPROC) (GLuint video_slot, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLGETVIDEOI64VNVPROC) (GLuint video_slot, GLenum pname, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETVIDEOUI64VNVPROC) (GLuint video_slot, GLenum pname, GLuint64EXT *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPresentFrameKeyedNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); +GLAPI void APIENTRY glPresentFrameDualFillNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); +GLAPI void APIENTRY glGetVideoivNV (GLuint video_slot, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVideouivNV (GLuint video_slot, GLenum pname, GLuint *params); +GLAPI void APIENTRY glGetVideoi64vNV (GLuint video_slot, GLenum pname, GLint64EXT *params); +GLAPI void APIENTRY glGetVideoui64vNV (GLuint video_slot, GLenum pname, GLuint64EXT *params); +#endif +#endif /* GL_NV_present_video */ + +#ifndef GL_NV_primitive_restart +#define GL_NV_primitive_restart 1 +#define GL_PRIMITIVE_RESTART_NV 0x8558 +#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTNVPROC) (void); +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPrimitiveRestartNV (void); +GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint index); +#endif +#endif /* GL_NV_primitive_restart */ + +#ifndef GL_NV_primitive_shading_rate +#define GL_NV_primitive_shading_rate 1 +#define GL_SHADING_RATE_IMAGE_PER_PRIMITIVE_NV 0x95B1 +#define GL_SHADING_RATE_IMAGE_PALETTE_COUNT_NV 0x95B2 +#endif /* GL_NV_primitive_shading_rate */ + +#ifndef GL_NV_query_resource +#define GL_NV_query_resource 1 +#define GL_QUERY_RESOURCE_TYPE_VIDMEM_ALLOC_NV 0x9540 +#define GL_QUERY_RESOURCE_MEMTYPE_VIDMEM_NV 0x9542 +#define GL_QUERY_RESOURCE_SYS_RESERVED_NV 0x9544 +#define GL_QUERY_RESOURCE_TEXTURE_NV 0x9545 +#define GL_QUERY_RESOURCE_RENDERBUFFER_NV 0x9546 +#define GL_QUERY_RESOURCE_BUFFEROBJECT_NV 0x9547 +typedef GLint (APIENTRYP PFNGLQUERYRESOURCENVPROC) (GLenum queryType, GLint tagId, GLuint count, GLint *buffer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLint APIENTRY glQueryResourceNV (GLenum queryType, GLint tagId, GLuint count, GLint *buffer); +#endif +#endif /* GL_NV_query_resource */ + +#ifndef GL_NV_query_resource_tag +#define GL_NV_query_resource_tag 1 +typedef void (APIENTRYP PFNGLGENQUERYRESOURCETAGNVPROC) (GLsizei n, GLint *tagIds); +typedef void (APIENTRYP PFNGLDELETEQUERYRESOURCETAGNVPROC) (GLsizei n, const GLint *tagIds); +typedef void (APIENTRYP PFNGLQUERYRESOURCETAGNVPROC) (GLint tagId, const GLchar *tagString); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueryResourceTagNV (GLsizei n, GLint *tagIds); +GLAPI void APIENTRY glDeleteQueryResourceTagNV (GLsizei n, const GLint *tagIds); +GLAPI void APIENTRY glQueryResourceTagNV (GLint tagId, const GLchar *tagString); +#endif +#endif /* GL_NV_query_resource_tag */ + +#ifndef GL_NV_register_combiners +#define GL_NV_register_combiners 1 +#define GL_REGISTER_COMBINERS_NV 0x8522 +#define GL_VARIABLE_A_NV 0x8523 +#define GL_VARIABLE_B_NV 0x8524 +#define GL_VARIABLE_C_NV 0x8525 +#define GL_VARIABLE_D_NV 0x8526 +#define GL_VARIABLE_E_NV 0x8527 +#define GL_VARIABLE_F_NV 0x8528 +#define GL_VARIABLE_G_NV 0x8529 +#define GL_CONSTANT_COLOR0_NV 0x852A +#define GL_CONSTANT_COLOR1_NV 0x852B +#define GL_SPARE0_NV 0x852E +#define GL_SPARE1_NV 0x852F +#define GL_DISCARD_NV 0x8530 +#define GL_E_TIMES_F_NV 0x8531 +#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 +#define GL_UNSIGNED_IDENTITY_NV 0x8536 +#define GL_UNSIGNED_INVERT_NV 0x8537 +#define GL_EXPAND_NORMAL_NV 0x8538 +#define GL_EXPAND_NEGATE_NV 0x8539 +#define GL_HALF_BIAS_NORMAL_NV 0x853A +#define GL_HALF_BIAS_NEGATE_NV 0x853B +#define GL_SIGNED_IDENTITY_NV 0x853C +#define GL_SIGNED_NEGATE_NV 0x853D +#define GL_SCALE_BY_TWO_NV 0x853E +#define GL_SCALE_BY_FOUR_NV 0x853F +#define GL_SCALE_BY_ONE_HALF_NV 0x8540 +#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 +#define GL_COMBINER_INPUT_NV 0x8542 +#define GL_COMBINER_MAPPING_NV 0x8543 +#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 +#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 +#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 +#define GL_COMBINER_MUX_SUM_NV 0x8547 +#define GL_COMBINER_SCALE_NV 0x8548 +#define GL_COMBINER_BIAS_NV 0x8549 +#define GL_COMBINER_AB_OUTPUT_NV 0x854A +#define GL_COMBINER_CD_OUTPUT_NV 0x854B +#define GL_COMBINER_SUM_OUTPUT_NV 0x854C +#define GL_MAX_GENERAL_COMBINERS_NV 0x854D +#define GL_NUM_GENERAL_COMBINERS_NV 0x854E +#define GL_COLOR_SUM_CLAMP_NV 0x854F +#define GL_COMBINER0_NV 0x8550 +#define GL_COMBINER1_NV 0x8551 +#define GL_COMBINER2_NV 0x8552 +#define GL_COMBINER3_NV 0x8553 +#define GL_COMBINER4_NV 0x8554 +#define GL_COMBINER5_NV 0x8555 +#define GL_COMBINER6_NV 0x8556 +#define GL_COMBINER7_NV 0x8557 +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); +typedef void (APIENTRYP PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerParameterfvNV (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glCombinerParameterfNV (GLenum pname, GLfloat param); +GLAPI void APIENTRY glCombinerParameterivNV (GLenum pname, const GLint *params); +GLAPI void APIENTRY glCombinerParameteriNV (GLenum pname, GLint param); +GLAPI void APIENTRY glCombinerInputNV (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +GLAPI void APIENTRY glCombinerOutputNV (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); +GLAPI void APIENTRY glFinalCombinerInputNV (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +GLAPI void APIENTRY glGetCombinerInputParameterfvNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetCombinerInputParameterivNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetCombinerOutputParameterfvNV (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetCombinerOutputParameterivNV (GLenum stage, GLenum portion, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum variable, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum variable, GLenum pname, GLint *params); +#endif +#endif /* GL_NV_register_combiners */ + +#ifndef GL_NV_register_combiners2 +#define GL_NV_register_combiners2 1 +#define GL_PER_STAGE_CONSTANTS_NV 0x8535 +typedef void (APIENTRYP PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerStageParameterfvNV (GLenum stage, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum stage, GLenum pname, GLfloat *params); +#endif +#endif /* GL_NV_register_combiners2 */ + +#ifndef GL_NV_representative_fragment_test +#define GL_NV_representative_fragment_test 1 +#define GL_REPRESENTATIVE_FRAGMENT_TEST_NV 0x937F +#endif /* GL_NV_representative_fragment_test */ + +#ifndef GL_NV_robustness_video_memory_purge +#define GL_NV_robustness_video_memory_purge 1 +#define GL_PURGED_CONTEXT_RESET_NV 0x92BB +#endif /* GL_NV_robustness_video_memory_purge */ + +#ifndef GL_NV_sample_locations +#define GL_NV_sample_locations 1 +#define GL_SAMPLE_LOCATION_SUBPIXEL_BITS_NV 0x933D +#define GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_NV 0x933E +#define GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_NV 0x933F +#define GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_NV 0x9340 +#define GL_SAMPLE_LOCATION_NV 0x8E50 +#define GL_PROGRAMMABLE_SAMPLE_LOCATION_NV 0x9341 +#define GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOCATIONS_NV 0x9342 +#define GL_FRAMEBUFFER_SAMPLE_LOCATION_PIXEL_GRID_NV 0x9343 +typedef void (APIENTRYP PFNGLFRAMEBUFFERSAMPLELOCATIONSFVNVPROC) (GLenum target, GLuint start, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVNVPROC) (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLRESOLVEDEPTHVALUESNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferSampleLocationsfvNV (GLenum target, GLuint start, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glNamedFramebufferSampleLocationsfvNV (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glResolveDepthValuesNV (void); +#endif +#endif /* GL_NV_sample_locations */ + +#ifndef GL_NV_sample_mask_override_coverage +#define GL_NV_sample_mask_override_coverage 1 +#endif /* GL_NV_sample_mask_override_coverage */ + +#ifndef GL_NV_scissor_exclusive +#define GL_NV_scissor_exclusive 1 +#define GL_SCISSOR_TEST_EXCLUSIVE_NV 0x9555 +#define GL_SCISSOR_BOX_EXCLUSIVE_NV 0x9556 +typedef void (APIENTRYP PFNGLSCISSOREXCLUSIVENVPROC) (GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLSCISSOREXCLUSIVEARRAYVNVPROC) (GLuint first, GLsizei count, const GLint *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glScissorExclusiveNV (GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glScissorExclusiveArrayvNV (GLuint first, GLsizei count, const GLint *v); +#endif +#endif /* GL_NV_scissor_exclusive */ + +#ifndef GL_NV_shader_atomic_counters +#define GL_NV_shader_atomic_counters 1 +#endif /* GL_NV_shader_atomic_counters */ + +#ifndef GL_NV_shader_atomic_float +#define GL_NV_shader_atomic_float 1 +#endif /* GL_NV_shader_atomic_float */ + +#ifndef GL_NV_shader_atomic_float64 +#define GL_NV_shader_atomic_float64 1 +#endif /* GL_NV_shader_atomic_float64 */ + +#ifndef GL_NV_shader_atomic_fp16_vector +#define GL_NV_shader_atomic_fp16_vector 1 +#endif /* GL_NV_shader_atomic_fp16_vector */ + +#ifndef GL_NV_shader_atomic_int64 +#define GL_NV_shader_atomic_int64 1 +#endif /* GL_NV_shader_atomic_int64 */ + +#ifndef GL_NV_shader_buffer_load +#define GL_NV_shader_buffer_load 1 +#define GL_BUFFER_GPU_ADDRESS_NV 0x8F1D +#define GL_GPU_ADDRESS_NV 0x8F34 +#define GL_MAX_SHADER_BUFFER_ADDRESS_NV 0x8F35 +typedef void (APIENTRYP PFNGLMAKEBUFFERRESIDENTNVPROC) (GLenum target, GLenum access); +typedef void (APIENTRYP PFNGLMAKEBUFFERNONRESIDENTNVPROC) (GLenum target); +typedef GLboolean (APIENTRYP PFNGLISBUFFERRESIDENTNVPROC) (GLenum target); +typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERRESIDENTNVPROC) (GLuint buffer, GLenum access); +typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC) (GLuint buffer); +typedef GLboolean (APIENTRYP PFNGLISNAMEDBUFFERRESIDENTNVPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERUI64VNVPROC) (GLenum target, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC) (GLuint buffer, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLGETINTEGERUI64VNVPROC) (GLenum value, GLuint64EXT *result); +typedef void (APIENTRYP PFNGLUNIFORMUI64NVPROC) (GLint location, GLuint64EXT value); +typedef void (APIENTRYP PFNGLUNIFORMUI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64NVPROC) (GLuint program, GLint location, GLuint64EXT value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMakeBufferResidentNV (GLenum target, GLenum access); +GLAPI void APIENTRY glMakeBufferNonResidentNV (GLenum target); +GLAPI GLboolean APIENTRY glIsBufferResidentNV (GLenum target); +GLAPI void APIENTRY glMakeNamedBufferResidentNV (GLuint buffer, GLenum access); +GLAPI void APIENTRY glMakeNamedBufferNonResidentNV (GLuint buffer); +GLAPI GLboolean APIENTRY glIsNamedBufferResidentNV (GLuint buffer); +GLAPI void APIENTRY glGetBufferParameterui64vNV (GLenum target, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glGetNamedBufferParameterui64vNV (GLuint buffer, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glGetIntegerui64vNV (GLenum value, GLuint64EXT *result); +GLAPI void APIENTRY glUniformui64NV (GLint location, GLuint64EXT value); +GLAPI void APIENTRY glUniformui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniformui64NV (GLuint program, GLint location, GLuint64EXT value); +GLAPI void APIENTRY glProgramUniformui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif +#endif /* GL_NV_shader_buffer_load */ + +#ifndef GL_NV_shader_buffer_store +#define GL_NV_shader_buffer_store 1 +#define GL_SHADER_GLOBAL_ACCESS_BARRIER_BIT_NV 0x00000010 +#endif /* GL_NV_shader_buffer_store */ + +#ifndef GL_NV_shader_storage_buffer_object +#define GL_NV_shader_storage_buffer_object 1 +#endif /* GL_NV_shader_storage_buffer_object */ + +#ifndef GL_NV_shader_subgroup_partitioned +#define GL_NV_shader_subgroup_partitioned 1 +#define GL_SUBGROUP_FEATURE_PARTITIONED_BIT_NV 0x00000100 +#endif /* GL_NV_shader_subgroup_partitioned */ + +#ifndef GL_NV_shader_texture_footprint +#define GL_NV_shader_texture_footprint 1 +#endif /* GL_NV_shader_texture_footprint */ + +#ifndef GL_NV_shader_thread_group +#define GL_NV_shader_thread_group 1 +#define GL_WARP_SIZE_NV 0x9339 +#define GL_WARPS_PER_SM_NV 0x933A +#define GL_SM_COUNT_NV 0x933B +#endif /* GL_NV_shader_thread_group */ + +#ifndef GL_NV_shader_thread_shuffle +#define GL_NV_shader_thread_shuffle 1 +#endif /* GL_NV_shader_thread_shuffle */ + +#ifndef GL_NV_shading_rate_image +#define GL_NV_shading_rate_image 1 +#define GL_SHADING_RATE_IMAGE_NV 0x9563 +#define GL_SHADING_RATE_NO_INVOCATIONS_NV 0x9564 +#define GL_SHADING_RATE_1_INVOCATION_PER_PIXEL_NV 0x9565 +#define GL_SHADING_RATE_1_INVOCATION_PER_1X2_PIXELS_NV 0x9566 +#define GL_SHADING_RATE_1_INVOCATION_PER_2X1_PIXELS_NV 0x9567 +#define GL_SHADING_RATE_1_INVOCATION_PER_2X2_PIXELS_NV 0x9568 +#define GL_SHADING_RATE_1_INVOCATION_PER_2X4_PIXELS_NV 0x9569 +#define GL_SHADING_RATE_1_INVOCATION_PER_4X2_PIXELS_NV 0x956A +#define GL_SHADING_RATE_1_INVOCATION_PER_4X4_PIXELS_NV 0x956B +#define GL_SHADING_RATE_2_INVOCATIONS_PER_PIXEL_NV 0x956C +#define GL_SHADING_RATE_4_INVOCATIONS_PER_PIXEL_NV 0x956D +#define GL_SHADING_RATE_8_INVOCATIONS_PER_PIXEL_NV 0x956E +#define GL_SHADING_RATE_16_INVOCATIONS_PER_PIXEL_NV 0x956F +#define GL_SHADING_RATE_IMAGE_BINDING_NV 0x955B +#define GL_SHADING_RATE_IMAGE_TEXEL_WIDTH_NV 0x955C +#define GL_SHADING_RATE_IMAGE_TEXEL_HEIGHT_NV 0x955D +#define GL_SHADING_RATE_IMAGE_PALETTE_SIZE_NV 0x955E +#define GL_MAX_COARSE_FRAGMENT_SAMPLES_NV 0x955F +#define GL_SHADING_RATE_SAMPLE_ORDER_DEFAULT_NV 0x95AE +#define GL_SHADING_RATE_SAMPLE_ORDER_PIXEL_MAJOR_NV 0x95AF +#define GL_SHADING_RATE_SAMPLE_ORDER_SAMPLE_MAJOR_NV 0x95B0 +typedef void (APIENTRYP PFNGLBINDSHADINGRATEIMAGENVPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLGETSHADINGRATEIMAGEPALETTENVPROC) (GLuint viewport, GLuint entry, GLenum *rate); +typedef void (APIENTRYP PFNGLGETSHADINGRATESAMPLELOCATIONIVNVPROC) (GLenum rate, GLuint samples, GLuint index, GLint *location); +typedef void (APIENTRYP PFNGLSHADINGRATEIMAGEBARRIERNVPROC) (GLboolean synchronize); +typedef void (APIENTRYP PFNGLSHADINGRATEIMAGEPALETTENVPROC) (GLuint viewport, GLuint first, GLsizei count, const GLenum *rates); +typedef void (APIENTRYP PFNGLSHADINGRATESAMPLEORDERNVPROC) (GLenum order); +typedef void (APIENTRYP PFNGLSHADINGRATESAMPLEORDERCUSTOMNVPROC) (GLenum rate, GLuint samples, const GLint *locations); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindShadingRateImageNV (GLuint texture); +GLAPI void APIENTRY glGetShadingRateImagePaletteNV (GLuint viewport, GLuint entry, GLenum *rate); +GLAPI void APIENTRY glGetShadingRateSampleLocationivNV (GLenum rate, GLuint samples, GLuint index, GLint *location); +GLAPI void APIENTRY glShadingRateImageBarrierNV (GLboolean synchronize); +GLAPI void APIENTRY glShadingRateImagePaletteNV (GLuint viewport, GLuint first, GLsizei count, const GLenum *rates); +GLAPI void APIENTRY glShadingRateSampleOrderNV (GLenum order); +GLAPI void APIENTRY glShadingRateSampleOrderCustomNV (GLenum rate, GLuint samples, const GLint *locations); +#endif +#endif /* GL_NV_shading_rate_image */ + +#ifndef GL_NV_stereo_view_rendering +#define GL_NV_stereo_view_rendering 1 +#endif /* GL_NV_stereo_view_rendering */ + +#ifndef GL_NV_tessellation_program5 +#define GL_NV_tessellation_program5 1 +#define GL_MAX_PROGRAM_PATCH_ATTRIBS_NV 0x86D8 +#define GL_TESS_CONTROL_PROGRAM_NV 0x891E +#define GL_TESS_EVALUATION_PROGRAM_NV 0x891F +#define GL_TESS_CONTROL_PROGRAM_PARAMETER_BUFFER_NV 0x8C74 +#define GL_TESS_EVALUATION_PROGRAM_PARAMETER_BUFFER_NV 0x8C75 +#endif /* GL_NV_tessellation_program5 */ + +#ifndef GL_NV_texgen_emboss +#define GL_NV_texgen_emboss 1 +#define GL_EMBOSS_LIGHT_NV 0x855D +#define GL_EMBOSS_CONSTANT_NV 0x855E +#define GL_EMBOSS_MAP_NV 0x855F +#endif /* GL_NV_texgen_emboss */ + +#ifndef GL_NV_texgen_reflection +#define GL_NV_texgen_reflection 1 +#define GL_NORMAL_MAP_NV 0x8511 +#define GL_REFLECTION_MAP_NV 0x8512 +#endif /* GL_NV_texgen_reflection */ + +#ifndef GL_NV_texture_barrier +#define GL_NV_texture_barrier 1 +typedef void (APIENTRYP PFNGLTEXTUREBARRIERNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureBarrierNV (void); +#endif +#endif /* GL_NV_texture_barrier */ + +#ifndef GL_NV_texture_compression_vtc +#define GL_NV_texture_compression_vtc 1 +#endif /* GL_NV_texture_compression_vtc */ + +#ifndef GL_NV_texture_env_combine4 +#define GL_NV_texture_env_combine4 1 +#define GL_COMBINE4_NV 0x8503 +#define GL_SOURCE3_RGB_NV 0x8583 +#define GL_SOURCE3_ALPHA_NV 0x858B +#define GL_OPERAND3_RGB_NV 0x8593 +#define GL_OPERAND3_ALPHA_NV 0x859B +#endif /* GL_NV_texture_env_combine4 */ + +#ifndef GL_NV_texture_expand_normal +#define GL_NV_texture_expand_normal 1 +#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F +#endif /* GL_NV_texture_expand_normal */ + +#ifndef GL_NV_texture_multisample +#define GL_NV_texture_multisample 1 +#define GL_TEXTURE_COVERAGE_SAMPLES_NV 0x9045 +#define GL_TEXTURE_COLOR_SAMPLES_NV 0x9046 +typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage2DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTexImage3DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage2DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage3DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage2DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage3DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +#endif +#endif /* GL_NV_texture_multisample */ + +#ifndef GL_NV_texture_rectangle +#define GL_NV_texture_rectangle 1 +#define GL_TEXTURE_RECTANGLE_NV 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 +#endif /* GL_NV_texture_rectangle */ + +#ifndef GL_NV_texture_rectangle_compressed +#define GL_NV_texture_rectangle_compressed 1 +#endif /* GL_NV_texture_rectangle_compressed */ + +#ifndef GL_NV_texture_shader +#define GL_NV_texture_shader 1 +#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C +#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D +#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E +#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 +#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA +#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB +#define GL_DSDT_MAG_INTENSITY_NV 0x86DC +#define GL_SHADER_CONSISTENT_NV 0x86DD +#define GL_TEXTURE_SHADER_NV 0x86DE +#define GL_SHADER_OPERATION_NV 0x86DF +#define GL_CULL_MODES_NV 0x86E0 +#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 +#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 +#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 +#define GL_OFFSET_TEXTURE_2D_MATRIX_NV 0x86E1 +#define GL_OFFSET_TEXTURE_2D_SCALE_NV 0x86E2 +#define GL_OFFSET_TEXTURE_2D_BIAS_NV 0x86E3 +#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 +#define GL_CONST_EYE_NV 0x86E5 +#define GL_PASS_THROUGH_NV 0x86E6 +#define GL_CULL_FRAGMENT_NV 0x86E7 +#define GL_OFFSET_TEXTURE_2D_NV 0x86E8 +#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 +#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA +#define GL_DOT_PRODUCT_NV 0x86EC +#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED +#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE +#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 +#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 +#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 +#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 +#define GL_HILO_NV 0x86F4 +#define GL_DSDT_NV 0x86F5 +#define GL_DSDT_MAG_NV 0x86F6 +#define GL_DSDT_MAG_VIB_NV 0x86F7 +#define GL_HILO16_NV 0x86F8 +#define GL_SIGNED_HILO_NV 0x86F9 +#define GL_SIGNED_HILO16_NV 0x86FA +#define GL_SIGNED_RGBA_NV 0x86FB +#define GL_SIGNED_RGBA8_NV 0x86FC +#define GL_SIGNED_RGB_NV 0x86FE +#define GL_SIGNED_RGB8_NV 0x86FF +#define GL_SIGNED_LUMINANCE_NV 0x8701 +#define GL_SIGNED_LUMINANCE8_NV 0x8702 +#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 +#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 +#define GL_SIGNED_ALPHA_NV 0x8705 +#define GL_SIGNED_ALPHA8_NV 0x8706 +#define GL_SIGNED_INTENSITY_NV 0x8707 +#define GL_SIGNED_INTENSITY8_NV 0x8708 +#define GL_DSDT8_NV 0x8709 +#define GL_DSDT8_MAG8_NV 0x870A +#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B +#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C +#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D +#define GL_HI_SCALE_NV 0x870E +#define GL_LO_SCALE_NV 0x870F +#define GL_DS_SCALE_NV 0x8710 +#define GL_DT_SCALE_NV 0x8711 +#define GL_MAGNITUDE_SCALE_NV 0x8712 +#define GL_VIBRANCE_SCALE_NV 0x8713 +#define GL_HI_BIAS_NV 0x8714 +#define GL_LO_BIAS_NV 0x8715 +#define GL_DS_BIAS_NV 0x8716 +#define GL_DT_BIAS_NV 0x8717 +#define GL_MAGNITUDE_BIAS_NV 0x8718 +#define GL_VIBRANCE_BIAS_NV 0x8719 +#define GL_TEXTURE_BORDER_VALUES_NV 0x871A +#define GL_TEXTURE_HI_SIZE_NV 0x871B +#define GL_TEXTURE_LO_SIZE_NV 0x871C +#define GL_TEXTURE_DS_SIZE_NV 0x871D +#define GL_TEXTURE_DT_SIZE_NV 0x871E +#define GL_TEXTURE_MAG_SIZE_NV 0x871F +#endif /* GL_NV_texture_shader */ + +#ifndef GL_NV_texture_shader2 +#define GL_NV_texture_shader2 1 +#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF +#endif /* GL_NV_texture_shader2 */ + +#ifndef GL_NV_texture_shader3 +#define GL_NV_texture_shader3 1 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 +#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 +#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 +#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 +#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 +#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A +#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B +#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C +#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D +#define GL_HILO8_NV 0x885E +#define GL_SIGNED_HILO8_NV 0x885F +#define GL_FORCE_BLUE_TO_ONE_NV 0x8860 +#endif /* GL_NV_texture_shader3 */ + +#ifndef GL_NV_timeline_semaphore +#define GL_NV_timeline_semaphore 1 +#define GL_TIMELINE_SEMAPHORE_VALUE_NV 0x9595 +#define GL_SEMAPHORE_TYPE_NV 0x95B3 +#define GL_SEMAPHORE_TYPE_BINARY_NV 0x95B4 +#define GL_SEMAPHORE_TYPE_TIMELINE_NV 0x95B5 +#define GL_MAX_TIMELINE_SEMAPHORE_VALUE_DIFFERENCE_NV 0x95B6 +typedef void (APIENTRYP PFNGLCREATESEMAPHORESNVPROC) (GLsizei n, GLuint *semaphores); +typedef void (APIENTRYP PFNGLSEMAPHOREPARAMETERIVNVPROC) (GLuint semaphore, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETSEMAPHOREPARAMETERIVNVPROC) (GLuint semaphore, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCreateSemaphoresNV (GLsizei n, GLuint *semaphores); +GLAPI void APIENTRY glSemaphoreParameterivNV (GLuint semaphore, GLenum pname, const GLint *params); +GLAPI void APIENTRY glGetSemaphoreParameterivNV (GLuint semaphore, GLenum pname, GLint *params); +#endif +#endif /* GL_NV_timeline_semaphore */ + +#ifndef GL_NV_transform_feedback +#define GL_NV_transform_feedback 1 +#define GL_BACK_PRIMARY_COLOR_NV 0x8C77 +#define GL_BACK_SECONDARY_COLOR_NV 0x8C78 +#define GL_TEXTURE_COORD_NV 0x8C79 +#define GL_CLIP_DISTANCE_NV 0x8C7A +#define GL_VERTEX_ID_NV 0x8C7B +#define GL_PRIMITIVE_ID_NV 0x8C7C +#define GL_GENERIC_ATTRIB_NV 0x8C7D +#define GL_TRANSFORM_FEEDBACK_ATTRIBS_NV 0x8C7E +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV 0x8C80 +#define GL_ACTIVE_VARYINGS_NV 0x8C81 +#define GL_ACTIVE_VARYING_MAX_LENGTH_NV 0x8C82 +#define GL_TRANSFORM_FEEDBACK_VARYINGS_NV 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START_NV 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV 0x8C85 +#define GL_TRANSFORM_FEEDBACK_RECORD_NV 0x8C86 +#define GL_PRIMITIVES_GENERATED_NV 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV 0x8C88 +#define GL_RASTERIZER_DISCARD_NV 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_NV 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV 0x8C8B +#define GL_INTERLEAVED_ATTRIBS_NV 0x8C8C +#define GL_SEPARATE_ATTRIBS_NV 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER_NV 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV 0x8C8F +#define GL_LAYER_NV 0x8DAA +#define GL_NEXT_BUFFER_NV -2 +#define GL_SKIP_COMPONENTS4_NV -3 +#define GL_SKIP_COMPONENTS3_NV -4 +#define GL_SKIP_COMPONENTS2_NV -5 +#define GL_SKIP_COMPONENTS1_NV -6 +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKNVPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC) (GLsizei count, const GLint *attribs, GLenum bufferMode); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGENVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETNVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +typedef void (APIENTRYP PFNGLBINDBUFFERBASENVPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC) (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); +typedef void (APIENTRYP PFNGLACTIVEVARYINGNVPROC) (GLuint program, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETVARYINGLOCATIONNVPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVEVARYINGNVPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC) (GLuint program, GLuint index, GLint *location); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKSTREAMATTRIBSNVPROC) (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginTransformFeedbackNV (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedbackNV (void); +GLAPI void APIENTRY glTransformFeedbackAttribsNV (GLsizei count, const GLint *attribs, GLenum bufferMode); +GLAPI void APIENTRY glBindBufferRangeNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferOffsetNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +GLAPI void APIENTRY glBindBufferBaseNV (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryingsNV (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); +GLAPI void APIENTRY glActiveVaryingNV (GLuint program, const GLchar *name); +GLAPI GLint APIENTRY glGetVaryingLocationNV (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetActiveVaryingNV (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetTransformFeedbackVaryingNV (GLuint program, GLuint index, GLint *location); +GLAPI void APIENTRY glTransformFeedbackStreamAttribsNV (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); +#endif +#endif /* GL_NV_transform_feedback */ + +#ifndef GL_NV_transform_feedback2 +#define GL_NV_transform_feedback2 1 +#define GL_TRANSFORM_FEEDBACK_NV 0x8E22 +#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED_NV 0x8E23 +#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE_NV 0x8E24 +#define GL_TRANSFORM_FEEDBACK_BINDING_NV 0x8E25 +typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKNVPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSNVPROC) (GLsizei n, const GLuint *ids); +typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSNVPROC) (GLsizei n, GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKNVPROC) (GLenum mode, GLuint id); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindTransformFeedbackNV (GLenum target, GLuint id); +GLAPI void APIENTRY glDeleteTransformFeedbacksNV (GLsizei n, const GLuint *ids); +GLAPI void APIENTRY glGenTransformFeedbacksNV (GLsizei n, GLuint *ids); +GLAPI GLboolean APIENTRY glIsTransformFeedbackNV (GLuint id); +GLAPI void APIENTRY glPauseTransformFeedbackNV (void); +GLAPI void APIENTRY glResumeTransformFeedbackNV (void); +GLAPI void APIENTRY glDrawTransformFeedbackNV (GLenum mode, GLuint id); +#endif +#endif /* GL_NV_transform_feedback2 */ + +#ifndef GL_NV_uniform_buffer_unified_memory +#define GL_NV_uniform_buffer_unified_memory 1 +#define GL_UNIFORM_BUFFER_UNIFIED_NV 0x936E +#define GL_UNIFORM_BUFFER_ADDRESS_NV 0x936F +#define GL_UNIFORM_BUFFER_LENGTH_NV 0x9370 +#endif /* GL_NV_uniform_buffer_unified_memory */ + +#ifndef GL_NV_vdpau_interop +#define GL_NV_vdpau_interop 1 +typedef GLintptr GLvdpauSurfaceNV; +#define GL_SURFACE_STATE_NV 0x86EB +#define GL_SURFACE_REGISTERED_NV 0x86FD +#define GL_SURFACE_MAPPED_NV 0x8700 +#define GL_WRITE_DISCARD_NV 0x88BE +typedef void (APIENTRYP PFNGLVDPAUINITNVPROC) (const void *vdpDevice, const void *getProcAddress); +typedef void (APIENTRYP PFNGLVDPAUFININVPROC) (void); +typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTERVIDEOSURFACENVPROC) (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC) (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +typedef GLboolean (APIENTRYP PFNGLVDPAUISSURFACENVPROC) (GLvdpauSurfaceNV surface); +typedef void (APIENTRYP PFNGLVDPAUUNREGISTERSURFACENVPROC) (GLvdpauSurfaceNV surface); +typedef void (APIENTRYP PFNGLVDPAUGETSURFACEIVNVPROC) (GLvdpauSurfaceNV surface, GLenum pname, GLsizei count, GLsizei *length, GLint *values); +typedef void (APIENTRYP PFNGLVDPAUSURFACEACCESSNVPROC) (GLvdpauSurfaceNV surface, GLenum access); +typedef void (APIENTRYP PFNGLVDPAUMAPSURFACESNVPROC) (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); +typedef void (APIENTRYP PFNGLVDPAUUNMAPSURFACESNVPROC) (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVDPAUInitNV (const void *vdpDevice, const void *getProcAddress); +GLAPI void APIENTRY glVDPAUFiniNV (void); +GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterVideoSurfaceNV (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterOutputSurfaceNV (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +GLAPI GLboolean APIENTRY glVDPAUIsSurfaceNV (GLvdpauSurfaceNV surface); +GLAPI void APIENTRY glVDPAUUnregisterSurfaceNV (GLvdpauSurfaceNV surface); +GLAPI void APIENTRY glVDPAUGetSurfaceivNV (GLvdpauSurfaceNV surface, GLenum pname, GLsizei count, GLsizei *length, GLint *values); +GLAPI void APIENTRY glVDPAUSurfaceAccessNV (GLvdpauSurfaceNV surface, GLenum access); +GLAPI void APIENTRY glVDPAUMapSurfacesNV (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); +GLAPI void APIENTRY glVDPAUUnmapSurfacesNV (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); +#endif +#endif /* GL_NV_vdpau_interop */ + +#ifndef GL_NV_vdpau_interop2 +#define GL_NV_vdpau_interop2 1 +typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTERVIDEOSURFACEWITHPICTURESTRUCTURENVPROC) (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames, GLboolean isFrameStructure); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterVideoSurfaceWithPictureStructureNV (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames, GLboolean isFrameStructure); +#endif +#endif /* GL_NV_vdpau_interop2 */ + +#ifndef GL_NV_vertex_array_range +#define GL_NV_vertex_array_range 1 +#define GL_VERTEX_ARRAY_RANGE_NV 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E +#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F +#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 +#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushVertexArrayRangeNV (void); +GLAPI void APIENTRY glVertexArrayRangeNV (GLsizei length, const void *pointer); +#endif +#endif /* GL_NV_vertex_array_range */ + +#ifndef GL_NV_vertex_array_range2 +#define GL_NV_vertex_array_range2 1 +#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 +#endif /* GL_NV_vertex_array_range2 */ + +#ifndef GL_NV_vertex_attrib_integer_64bit +#define GL_NV_vertex_attrib_integer_64bit 1 +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64NVPROC) (GLuint index, GLint64EXT x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64NVPROC) (GLuint index, GLuint64EXT x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLI64VNVPROC) (GLuint index, GLenum pname, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLUI64VNVPROC) (GLuint index, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribL1i64NV (GLuint index, GLint64EXT x); +GLAPI void APIENTRY glVertexAttribL2i64NV (GLuint index, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glVertexAttribL3i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glVertexAttribL4i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glVertexAttribL1i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL2i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL3i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL4i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL1ui64NV (GLuint index, GLuint64EXT x); +GLAPI void APIENTRY glVertexAttribL2ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glVertexAttribL3ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glVertexAttribL4ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glVertexAttribL1ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL2ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL3ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL4ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glGetVertexAttribLi64vNV (GLuint index, GLenum pname, GLint64EXT *params); +GLAPI void APIENTRY glGetVertexAttribLui64vNV (GLuint index, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glVertexAttribLFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); +#endif +#endif /* GL_NV_vertex_attrib_integer_64bit */ + +#ifndef GL_NV_vertex_buffer_unified_memory +#define GL_NV_vertex_buffer_unified_memory 1 +#define GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV 0x8F1E +#define GL_ELEMENT_ARRAY_UNIFIED_NV 0x8F1F +#define GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV 0x8F20 +#define GL_VERTEX_ARRAY_ADDRESS_NV 0x8F21 +#define GL_NORMAL_ARRAY_ADDRESS_NV 0x8F22 +#define GL_COLOR_ARRAY_ADDRESS_NV 0x8F23 +#define GL_INDEX_ARRAY_ADDRESS_NV 0x8F24 +#define GL_TEXTURE_COORD_ARRAY_ADDRESS_NV 0x8F25 +#define GL_EDGE_FLAG_ARRAY_ADDRESS_NV 0x8F26 +#define GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV 0x8F27 +#define GL_FOG_COORD_ARRAY_ADDRESS_NV 0x8F28 +#define GL_ELEMENT_ARRAY_ADDRESS_NV 0x8F29 +#define GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV 0x8F2A +#define GL_VERTEX_ARRAY_LENGTH_NV 0x8F2B +#define GL_NORMAL_ARRAY_LENGTH_NV 0x8F2C +#define GL_COLOR_ARRAY_LENGTH_NV 0x8F2D +#define GL_INDEX_ARRAY_LENGTH_NV 0x8F2E +#define GL_TEXTURE_COORD_ARRAY_LENGTH_NV 0x8F2F +#define GL_EDGE_FLAG_ARRAY_LENGTH_NV 0x8F30 +#define GL_SECONDARY_COLOR_ARRAY_LENGTH_NV 0x8F31 +#define GL_FOG_COORD_ARRAY_LENGTH_NV 0x8F32 +#define GL_ELEMENT_ARRAY_LENGTH_NV 0x8F33 +#define GL_DRAW_INDIRECT_UNIFIED_NV 0x8F40 +#define GL_DRAW_INDIRECT_ADDRESS_NV 0x8F41 +#define GL_DRAW_INDIRECT_LENGTH_NV 0x8F42 +typedef void (APIENTRYP PFNGLBUFFERADDRESSRANGENVPROC) (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); +typedef void (APIENTRYP PFNGLVERTEXFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLNORMALFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLINDEXFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLTEXCOORDFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLEDGEFLAGFORMATNVPROC) (GLsizei stride); +typedef void (APIENTRYP PFNGLSECONDARYCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLFOGCOORDFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLGETINTEGERUI64I_VNVPROC) (GLenum value, GLuint index, GLuint64EXT *result); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferAddressRangeNV (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); +GLAPI void APIENTRY glVertexFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glNormalFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glColorFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glIndexFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glTexCoordFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glEdgeFlagFormatNV (GLsizei stride); +GLAPI void APIENTRY glSecondaryColorFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glFogCoordFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glVertexAttribFormatNV (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); +GLAPI void APIENTRY glVertexAttribIFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glGetIntegerui64i_vNV (GLenum value, GLuint index, GLuint64EXT *result); +#endif +#endif /* GL_NV_vertex_buffer_unified_memory */ + +#ifndef GL_NV_vertex_program +#define GL_NV_vertex_program 1 +#define GL_VERTEX_PROGRAM_NV 0x8620 +#define GL_VERTEX_STATE_PROGRAM_NV 0x8621 +#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 +#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 +#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 +#define GL_CURRENT_ATTRIB_NV 0x8626 +#define GL_PROGRAM_LENGTH_NV 0x8627 +#define GL_PROGRAM_STRING_NV 0x8628 +#define GL_MODELVIEW_PROJECTION_NV 0x8629 +#define GL_IDENTITY_NV 0x862A +#define GL_INVERSE_NV 0x862B +#define GL_TRANSPOSE_NV 0x862C +#define GL_INVERSE_TRANSPOSE_NV 0x862D +#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E +#define GL_MAX_TRACK_MATRICES_NV 0x862F +#define GL_MATRIX0_NV 0x8630 +#define GL_MATRIX1_NV 0x8631 +#define GL_MATRIX2_NV 0x8632 +#define GL_MATRIX3_NV 0x8633 +#define GL_MATRIX4_NV 0x8634 +#define GL_MATRIX5_NV 0x8635 +#define GL_MATRIX6_NV 0x8636 +#define GL_MATRIX7_NV 0x8637 +#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 +#define GL_CURRENT_MATRIX_NV 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 +#define GL_PROGRAM_PARAMETER_NV 0x8644 +#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 +#define GL_PROGRAM_TARGET_NV 0x8646 +#define GL_PROGRAM_RESIDENT_NV 0x8647 +#define GL_TRACK_MATRIX_NV 0x8648 +#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 +#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A +#define GL_PROGRAM_ERROR_POSITION_NV 0x864B +#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 +#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 +#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 +#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 +#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 +#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 +#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 +#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 +#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 +#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 +#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A +#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B +#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C +#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D +#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E +#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F +#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 +#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 +#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 +#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 +#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 +#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 +#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 +#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 +#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 +#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 +#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A +#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B +#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C +#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D +#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E +#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F +#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 +#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 +#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 +#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 +#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 +#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 +#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 +#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 +#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 +#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 +#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A +#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B +#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C +#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D +#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E +#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F +typedef GLboolean (APIENTRYP PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint *programs, GLboolean *residences); +typedef void (APIENTRYP PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat *params); +typedef void (APIENTRYP PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte *program); +typedef void (APIENTRYP PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, void **pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte *program); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei count, const GLubyte *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAreProgramsResidentNV (GLsizei n, const GLuint *programs, GLboolean *residences); +GLAPI void APIENTRY glBindProgramNV (GLenum target, GLuint id); +GLAPI void APIENTRY glDeleteProgramsNV (GLsizei n, const GLuint *programs); +GLAPI void APIENTRY glExecuteProgramNV (GLenum target, GLuint id, const GLfloat *params); +GLAPI void APIENTRY glGenProgramsNV (GLsizei n, GLuint *programs); +GLAPI void APIENTRY glGetProgramParameterdvNV (GLenum target, GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetProgramParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetProgramivNV (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramStringNV (GLuint id, GLenum pname, GLubyte *program); +GLAPI void APIENTRY glGetTrackMatrixivNV (GLenum target, GLuint address, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribdvNV (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfvNV (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribivNV (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointervNV (GLuint index, GLenum pname, void **pointer); +GLAPI GLboolean APIENTRY glIsProgramNV (GLuint id); +GLAPI void APIENTRY glLoadProgramNV (GLenum target, GLuint id, GLsizei len, const GLubyte *program); +GLAPI void APIENTRY glProgramParameter4dNV (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramParameter4dvNV (GLenum target, GLuint index, const GLdouble *v); +GLAPI void APIENTRY glProgramParameter4fNV (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramParameter4fvNV (GLenum target, GLuint index, const GLfloat *v); +GLAPI void APIENTRY glProgramParameters4dvNV (GLenum target, GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glProgramParameters4fvNV (GLenum target, GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei n, const GLuint *programs); +GLAPI void APIENTRY glTrackMatrixNV (GLenum target, GLuint address, GLenum matrix, GLenum transform); +GLAPI void APIENTRY glVertexAttribPointerNV (GLuint index, GLint fsize, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glVertexAttrib1dNV (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1fNV (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1sNV (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2dNV (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2fNV (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2sNV (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3sNV (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4sNV (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubNV (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4ubvNV (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribs1dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs1fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs1svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs2dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs2fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs2svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs3dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs3fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs3svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs4dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs4fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs4svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs4ubvNV (GLuint index, GLsizei count, const GLubyte *v); +#endif +#endif /* GL_NV_vertex_program */ + +#ifndef GL_NV_vertex_program1_1 +#define GL_NV_vertex_program1_1 1 +#endif /* GL_NV_vertex_program1_1 */ + +#ifndef GL_NV_vertex_program2 +#define GL_NV_vertex_program2 1 +#endif /* GL_NV_vertex_program2 */ + +#ifndef GL_NV_vertex_program2_option +#define GL_NV_vertex_program2_option 1 +#endif /* GL_NV_vertex_program2_option */ + +#ifndef GL_NV_vertex_program3 +#define GL_NV_vertex_program3 1 +#endif /* GL_NV_vertex_program3 */ + +#ifndef GL_NV_vertex_program4 +#define GL_NV_vertex_program4 1 +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_NV 0x88FD +#endif /* GL_NV_vertex_program4 */ + +#ifndef GL_NV_video_capture +#define GL_NV_video_capture 1 +#define GL_VIDEO_BUFFER_NV 0x9020 +#define GL_VIDEO_BUFFER_BINDING_NV 0x9021 +#define GL_FIELD_UPPER_NV 0x9022 +#define GL_FIELD_LOWER_NV 0x9023 +#define GL_NUM_VIDEO_CAPTURE_STREAMS_NV 0x9024 +#define GL_NEXT_VIDEO_CAPTURE_BUFFER_STATUS_NV 0x9025 +#define GL_VIDEO_CAPTURE_TO_422_SUPPORTED_NV 0x9026 +#define GL_LAST_VIDEO_CAPTURE_STATUS_NV 0x9027 +#define GL_VIDEO_BUFFER_PITCH_NV 0x9028 +#define GL_VIDEO_COLOR_CONVERSION_MATRIX_NV 0x9029 +#define GL_VIDEO_COLOR_CONVERSION_MAX_NV 0x902A +#define GL_VIDEO_COLOR_CONVERSION_MIN_NV 0x902B +#define GL_VIDEO_COLOR_CONVERSION_OFFSET_NV 0x902C +#define GL_VIDEO_BUFFER_INTERNAL_FORMAT_NV 0x902D +#define GL_PARTIAL_SUCCESS_NV 0x902E +#define GL_SUCCESS_NV 0x902F +#define GL_FAILURE_NV 0x9030 +#define GL_YCBYCR8_422_NV 0x9031 +#define GL_YCBAYCR8A_4224_NV 0x9032 +#define GL_Z6Y10Z6CB10Z6Y10Z6CR10_422_NV 0x9033 +#define GL_Z6Y10Z6CB10Z6A10Z6Y10Z6CR10Z6A10_4224_NV 0x9034 +#define GL_Z4Y12Z4CB12Z4Y12Z4CR12_422_NV 0x9035 +#define GL_Z4Y12Z4CB12Z4A12Z4Y12Z4CR12Z4A12_4224_NV 0x9036 +#define GL_Z4Y12Z4CB12Z4CR12_444_NV 0x9037 +#define GL_VIDEO_CAPTURE_FRAME_WIDTH_NV 0x9038 +#define GL_VIDEO_CAPTURE_FRAME_HEIGHT_NV 0x9039 +#define GL_VIDEO_CAPTURE_FIELD_UPPER_HEIGHT_NV 0x903A +#define GL_VIDEO_CAPTURE_FIELD_LOWER_HEIGHT_NV 0x903B +#define GL_VIDEO_CAPTURE_SURFACE_ORIGIN_NV 0x903C +typedef void (APIENTRYP PFNGLBEGINVIDEOCAPTURENVPROC) (GLuint video_capture_slot); +typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); +typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMTEXTURENVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLENDVIDEOCAPTURENVPROC) (GLuint video_capture_slot); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTUREIVNVPROC) (GLuint video_capture_slot, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params); +typedef GLenum (APIENTRYP PFNGLVIDEOCAPTURENVPROC) (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time); +typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginVideoCaptureNV (GLuint video_capture_slot); +GLAPI void APIENTRY glBindVideoCaptureStreamBufferNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); +GLAPI void APIENTRY glBindVideoCaptureStreamTextureNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); +GLAPI void APIENTRY glEndVideoCaptureNV (GLuint video_capture_slot); +GLAPI void APIENTRY glGetVideoCaptureivNV (GLuint video_capture_slot, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVideoCaptureStreamivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVideoCaptureStreamfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVideoCaptureStreamdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params); +GLAPI GLenum APIENTRY glVideoCaptureNV (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time); +GLAPI void APIENTRY glVideoCaptureStreamParameterivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params); +GLAPI void APIENTRY glVideoCaptureStreamParameterfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glVideoCaptureStreamParameterdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); +#endif +#endif /* GL_NV_video_capture */ + +#ifndef GL_NV_viewport_array2 +#define GL_NV_viewport_array2 1 +#endif /* GL_NV_viewport_array2 */ + +#ifndef GL_NV_viewport_swizzle +#define GL_NV_viewport_swizzle 1 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_X_NV 0x9350 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_X_NV 0x9351 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_Y_NV 0x9352 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_Y_NV 0x9353 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_Z_NV 0x9354 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_Z_NV 0x9355 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_W_NV 0x9356 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_W_NV 0x9357 +#define GL_VIEWPORT_SWIZZLE_X_NV 0x9358 +#define GL_VIEWPORT_SWIZZLE_Y_NV 0x9359 +#define GL_VIEWPORT_SWIZZLE_Z_NV 0x935A +#define GL_VIEWPORT_SWIZZLE_W_NV 0x935B +typedef void (APIENTRYP PFNGLVIEWPORTSWIZZLENVPROC) (GLuint index, GLenum swizzlex, GLenum swizzley, GLenum swizzlez, GLenum swizzlew); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glViewportSwizzleNV (GLuint index, GLenum swizzlex, GLenum swizzley, GLenum swizzlez, GLenum swizzlew); +#endif +#endif /* GL_NV_viewport_swizzle */ + +#ifndef GL_OML_interlace +#define GL_OML_interlace 1 +#define GL_INTERLACE_OML 0x8980 +#define GL_INTERLACE_READ_OML 0x8981 +#endif /* GL_OML_interlace */ + +#ifndef GL_OML_resample +#define GL_OML_resample 1 +#define GL_PACK_RESAMPLE_OML 0x8984 +#define GL_UNPACK_RESAMPLE_OML 0x8985 +#define GL_RESAMPLE_REPLICATE_OML 0x8986 +#define GL_RESAMPLE_ZERO_FILL_OML 0x8987 +#define GL_RESAMPLE_AVERAGE_OML 0x8988 +#define GL_RESAMPLE_DECIMATE_OML 0x8989 +#endif /* GL_OML_resample */ + +#ifndef GL_OML_subsample +#define GL_OML_subsample 1 +#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 +#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 +#endif /* GL_OML_subsample */ + +#ifndef GL_OVR_multiview +#define GL_OVR_multiview 1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_NUM_VIEWS_OVR 0x9630 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_BASE_VIEW_INDEX_OVR 0x9632 +#define GL_MAX_VIEWS_OVR 0x9631 +#define GL_FRAMEBUFFER_INCOMPLETE_VIEW_TARGETS_OVR 0x9633 +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVRPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint baseViewIndex, GLsizei numViews); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferTextureMultiviewOVR (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint baseViewIndex, GLsizei numViews); +#endif +#endif /* GL_OVR_multiview */ + +#ifndef GL_OVR_multiview2 +#define GL_OVR_multiview2 1 +#endif /* GL_OVR_multiview2 */ + +#ifndef GL_PGI_misc_hints +#define GL_PGI_misc_hints 1 +#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 0x1A1F8 +#define GL_CONSERVE_MEMORY_HINT_PGI 0x1A1FD +#define GL_RECLAIM_MEMORY_HINT_PGI 0x1A1FE +#define GL_NATIVE_GRAPHICS_HANDLE_PGI 0x1A202 +#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203 +#define GL_NATIVE_GRAPHICS_END_HINT_PGI 0x1A204 +#define GL_ALWAYS_FAST_HINT_PGI 0x1A20C +#define GL_ALWAYS_SOFT_HINT_PGI 0x1A20D +#define GL_ALLOW_DRAW_OBJ_HINT_PGI 0x1A20E +#define GL_ALLOW_DRAW_WIN_HINT_PGI 0x1A20F +#define GL_ALLOW_DRAW_FRG_HINT_PGI 0x1A210 +#define GL_ALLOW_DRAW_MEM_HINT_PGI 0x1A211 +#define GL_STRICT_DEPTHFUNC_HINT_PGI 0x1A216 +#define GL_STRICT_LIGHTING_HINT_PGI 0x1A217 +#define GL_STRICT_SCISSOR_HINT_PGI 0x1A218 +#define GL_FULL_STIPPLE_HINT_PGI 0x1A219 +#define GL_CLIP_NEAR_HINT_PGI 0x1A220 +#define GL_CLIP_FAR_HINT_PGI 0x1A221 +#define GL_WIDE_LINE_HINT_PGI 0x1A222 +#define GL_BACK_NORMALS_HINT_PGI 0x1A223 +typedef void (APIENTRYP PFNGLHINTPGIPROC) (GLenum target, GLint mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glHintPGI (GLenum target, GLint mode); +#endif +#endif /* GL_PGI_misc_hints */ + +#ifndef GL_PGI_vertex_hints +#define GL_PGI_vertex_hints 1 +#define GL_VERTEX_DATA_HINT_PGI 0x1A22A +#define GL_VERTEX_CONSISTENT_HINT_PGI 0x1A22B +#define GL_MATERIAL_SIDE_HINT_PGI 0x1A22C +#define GL_MAX_VERTEX_HINT_PGI 0x1A22D +#define GL_COLOR3_BIT_PGI 0x00010000 +#define GL_COLOR4_BIT_PGI 0x00020000 +#define GL_EDGEFLAG_BIT_PGI 0x00040000 +#define GL_INDEX_BIT_PGI 0x00080000 +#define GL_MAT_AMBIENT_BIT_PGI 0x00100000 +#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 +#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000 +#define GL_MAT_EMISSION_BIT_PGI 0x00800000 +#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 +#define GL_MAT_SHININESS_BIT_PGI 0x02000000 +#define GL_MAT_SPECULAR_BIT_PGI 0x04000000 +#define GL_NORMAL_BIT_PGI 0x08000000 +#define GL_TEXCOORD1_BIT_PGI 0x10000000 +#define GL_TEXCOORD2_BIT_PGI 0x20000000 +#define GL_TEXCOORD3_BIT_PGI 0x40000000 +#define GL_TEXCOORD4_BIT_PGI 0x80000000 +#define GL_VERTEX23_BIT_PGI 0x00000004 +#define GL_VERTEX4_BIT_PGI 0x00000008 +#endif /* GL_PGI_vertex_hints */ + +#ifndef GL_REND_screen_coordinates +#define GL_REND_screen_coordinates 1 +#define GL_SCREEN_COORDINATES_REND 0x8490 +#define GL_INVERTED_SCREEN_W_REND 0x8491 +#endif /* GL_REND_screen_coordinates */ + +#ifndef GL_S3_s3tc +#define GL_S3_s3tc 1 +#define GL_RGB_S3TC 0x83A0 +#define GL_RGB4_S3TC 0x83A1 +#define GL_RGBA_S3TC 0x83A2 +#define GL_RGBA4_S3TC 0x83A3 +#define GL_RGBA_DXT5_S3TC 0x83A4 +#define GL_RGBA4_DXT5_S3TC 0x83A5 +#endif /* GL_S3_s3tc */ + +#ifndef GL_SGIS_detail_texture +#define GL_SGIS_detail_texture 1 +#define GL_DETAIL_TEXTURE_2D_SGIS 0x8095 +#define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096 +#define GL_LINEAR_DETAIL_SGIS 0x8097 +#define GL_LINEAR_DETAIL_ALPHA_SGIS 0x8098 +#define GL_LINEAR_DETAIL_COLOR_SGIS 0x8099 +#define GL_DETAIL_TEXTURE_LEVEL_SGIS 0x809A +#define GL_DETAIL_TEXTURE_MODE_SGIS 0x809B +#define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C +typedef void (APIENTRYP PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDetailTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); +GLAPI void APIENTRY glGetDetailTexFuncSGIS (GLenum target, GLfloat *points); +#endif +#endif /* GL_SGIS_detail_texture */ + +#ifndef GL_SGIS_fog_function +#define GL_SGIS_fog_function 1 +#define GL_FOG_FUNC_SGIS 0x812A +#define GL_FOG_FUNC_POINTS_SGIS 0x812B +#define GL_MAX_FOG_FUNC_POINTS_SGIS 0x812C +typedef void (APIENTRYP PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETFOGFUNCSGISPROC) (GLfloat *points); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogFuncSGIS (GLsizei n, const GLfloat *points); +GLAPI void APIENTRY glGetFogFuncSGIS (GLfloat *points); +#endif +#endif /* GL_SGIS_fog_function */ + +#ifndef GL_SGIS_generate_mipmap +#define GL_SGIS_generate_mipmap 1 +#define GL_GENERATE_MIPMAP_SGIS 0x8191 +#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 +#endif /* GL_SGIS_generate_mipmap */ + +#ifndef GL_SGIS_multisample +#define GL_SGIS_multisample 1 +#define GL_MULTISAMPLE_SGIS 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F +#define GL_SAMPLE_MASK_SGIS 0x80A0 +#define GL_1PASS_SGIS 0x80A1 +#define GL_2PASS_0_SGIS 0x80A2 +#define GL_2PASS_1_SGIS 0x80A3 +#define GL_4PASS_0_SGIS 0x80A4 +#define GL_4PASS_1_SGIS 0x80A5 +#define GL_4PASS_2_SGIS 0x80A6 +#define GL_4PASS_3_SGIS 0x80A7 +#define GL_SAMPLE_BUFFERS_SGIS 0x80A8 +#define GL_SAMPLES_SGIS 0x80A9 +#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA +#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB +#define GL_SAMPLE_PATTERN_SGIS 0x80AC +typedef void (APIENTRYP PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleMaskSGIS (GLclampf value, GLboolean invert); +GLAPI void APIENTRY glSamplePatternSGIS (GLenum pattern); +#endif +#endif /* GL_SGIS_multisample */ + +#ifndef GL_SGIS_pixel_texture +#define GL_SGIS_pixel_texture 1 +#define GL_PIXEL_TEXTURE_SGIS 0x8353 +#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354 +#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355 +#define GL_PIXEL_GROUP_COLOR_SGIS 0x8356 +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTexGenParameteriSGIS (GLenum pname, GLint param); +GLAPI void APIENTRY glPixelTexGenParameterivSGIS (GLenum pname, const GLint *params); +GLAPI void APIENTRY glPixelTexGenParameterfSGIS (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPixelTexGenParameterfvSGIS (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum pname, GLint *params); +GLAPI void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum pname, GLfloat *params); +#endif +#endif /* GL_SGIS_pixel_texture */ + +#ifndef GL_SGIS_point_line_texgen +#define GL_SGIS_point_line_texgen 1 +#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0 +#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1 +#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2 +#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3 +#define GL_EYE_POINT_SGIS 0x81F4 +#define GL_OBJECT_POINT_SGIS 0x81F5 +#define GL_EYE_LINE_SGIS 0x81F6 +#define GL_OBJECT_LINE_SGIS 0x81F7 +#endif /* GL_SGIS_point_line_texgen */ + +#ifndef GL_SGIS_point_parameters +#define GL_SGIS_point_parameters 1 +#define GL_POINT_SIZE_MIN_SGIS 0x8126 +#define GL_POINT_SIZE_MAX_SGIS 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128 +#define GL_DISTANCE_ATTENUATION_SGIS 0x8129 +typedef void (APIENTRYP PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfSGIS (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfvSGIS (GLenum pname, const GLfloat *params); +#endif +#endif /* GL_SGIS_point_parameters */ + +#ifndef GL_SGIS_sharpen_texture +#define GL_SGIS_sharpen_texture 1 +#define GL_LINEAR_SHARPEN_SGIS 0x80AD +#define GL_LINEAR_SHARPEN_ALPHA_SGIS 0x80AE +#define GL_LINEAR_SHARPEN_COLOR_SGIS 0x80AF +#define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0 +typedef void (APIENTRYP PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSharpenTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); +GLAPI void APIENTRY glGetSharpenTexFuncSGIS (GLenum target, GLfloat *points); +#endif +#endif /* GL_SGIS_sharpen_texture */ + +#ifndef GL_SGIS_texture4D +#define GL_SGIS_texture4D 1 +#define GL_PACK_SKIP_VOLUMES_SGIS 0x8130 +#define GL_PACK_IMAGE_DEPTH_SGIS 0x8131 +#define GL_UNPACK_SKIP_VOLUMES_SGIS 0x8132 +#define GL_UNPACK_IMAGE_DEPTH_SGIS 0x8133 +#define GL_TEXTURE_4D_SGIS 0x8134 +#define GL_PROXY_TEXTURE_4D_SGIS 0x8135 +#define GL_TEXTURE_4DSIZE_SGIS 0x8136 +#define GL_TEXTURE_WRAP_Q_SGIS 0x8137 +#define GL_MAX_4D_TEXTURE_SIZE_SGIS 0x8138 +#define GL_TEXTURE_4D_BINDING_SGIS 0x814F +typedef void (APIENTRYP PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const void *pixels); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage4DSGIS (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTexSubImage4DSGIS (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const void *pixels); +#endif +#endif /* GL_SGIS_texture4D */ + +#ifndef GL_SGIS_texture_border_clamp +#define GL_SGIS_texture_border_clamp 1 +#define GL_CLAMP_TO_BORDER_SGIS 0x812D +#endif /* GL_SGIS_texture_border_clamp */ + +#ifndef GL_SGIS_texture_color_mask +#define GL_SGIS_texture_color_mask 1 +#define GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF +typedef void (APIENTRYP PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureColorMaskSGIS (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +#endif +#endif /* GL_SGIS_texture_color_mask */ + +#ifndef GL_SGIS_texture_edge_clamp +#define GL_SGIS_texture_edge_clamp 1 +#define GL_CLAMP_TO_EDGE_SGIS 0x812F +#endif /* GL_SGIS_texture_edge_clamp */ + +#ifndef GL_SGIS_texture_filter4 +#define GL_SGIS_texture_filter4 1 +#define GL_FILTER4_SGIS 0x8146 +#define GL_TEXTURE_FILTER4_SIZE_SGIS 0x8147 +typedef void (APIENTRYP PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights); +typedef void (APIENTRYP PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetTexFilterFuncSGIS (GLenum target, GLenum filter, GLfloat *weights); +GLAPI void APIENTRY glTexFilterFuncSGIS (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); +#endif +#endif /* GL_SGIS_texture_filter4 */ + +#ifndef GL_SGIS_texture_lod +#define GL_SGIS_texture_lod 1 +#define GL_TEXTURE_MIN_LOD_SGIS 0x813A +#define GL_TEXTURE_MAX_LOD_SGIS 0x813B +#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C +#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D +#endif /* GL_SGIS_texture_lod */ + +#ifndef GL_SGIS_texture_select +#define GL_SGIS_texture_select 1 +#define GL_DUAL_ALPHA4_SGIS 0x8110 +#define GL_DUAL_ALPHA8_SGIS 0x8111 +#define GL_DUAL_ALPHA12_SGIS 0x8112 +#define GL_DUAL_ALPHA16_SGIS 0x8113 +#define GL_DUAL_LUMINANCE4_SGIS 0x8114 +#define GL_DUAL_LUMINANCE8_SGIS 0x8115 +#define GL_DUAL_LUMINANCE12_SGIS 0x8116 +#define GL_DUAL_LUMINANCE16_SGIS 0x8117 +#define GL_DUAL_INTENSITY4_SGIS 0x8118 +#define GL_DUAL_INTENSITY8_SGIS 0x8119 +#define GL_DUAL_INTENSITY12_SGIS 0x811A +#define GL_DUAL_INTENSITY16_SGIS 0x811B +#define GL_DUAL_LUMINANCE_ALPHA4_SGIS 0x811C +#define GL_DUAL_LUMINANCE_ALPHA8_SGIS 0x811D +#define GL_QUAD_ALPHA4_SGIS 0x811E +#define GL_QUAD_ALPHA8_SGIS 0x811F +#define GL_QUAD_LUMINANCE4_SGIS 0x8120 +#define GL_QUAD_LUMINANCE8_SGIS 0x8121 +#define GL_QUAD_INTENSITY4_SGIS 0x8122 +#define GL_QUAD_INTENSITY8_SGIS 0x8123 +#define GL_DUAL_TEXTURE_SELECT_SGIS 0x8124 +#define GL_QUAD_TEXTURE_SELECT_SGIS 0x8125 +#endif /* GL_SGIS_texture_select */ + +#ifndef GL_SGIX_async +#define GL_SGIX_async 1 +#define GL_ASYNC_MARKER_SGIX 0x8329 +typedef void (APIENTRYP PFNGLASYNCMARKERSGIXPROC) (GLuint marker); +typedef GLint (APIENTRYP PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp); +typedef GLint (APIENTRYP PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp); +typedef GLuint (APIENTRYP PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); +typedef void (APIENTRYP PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); +typedef GLboolean (APIENTRYP PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glAsyncMarkerSGIX (GLuint marker); +GLAPI GLint APIENTRY glFinishAsyncSGIX (GLuint *markerp); +GLAPI GLint APIENTRY glPollAsyncSGIX (GLuint *markerp); +GLAPI GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei range); +GLAPI void APIENTRY glDeleteAsyncMarkersSGIX (GLuint marker, GLsizei range); +GLAPI GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint marker); +#endif +#endif /* GL_SGIX_async */ + +#ifndef GL_SGIX_async_histogram +#define GL_SGIX_async_histogram 1 +#define GL_ASYNC_HISTOGRAM_SGIX 0x832C +#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D +#endif /* GL_SGIX_async_histogram */ + +#ifndef GL_SGIX_async_pixel +#define GL_SGIX_async_pixel 1 +#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C +#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D +#define GL_ASYNC_READ_PIXELS_SGIX 0x835E +#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F +#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 +#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 +#endif /* GL_SGIX_async_pixel */ + +#ifndef GL_SGIX_blend_alpha_minmax +#define GL_SGIX_blend_alpha_minmax 1 +#define GL_ALPHA_MIN_SGIX 0x8320 +#define GL_ALPHA_MAX_SGIX 0x8321 +#endif /* GL_SGIX_blend_alpha_minmax */ + +#ifndef GL_SGIX_calligraphic_fragment +#define GL_SGIX_calligraphic_fragment 1 +#define GL_CALLIGRAPHIC_FRAGMENT_SGIX 0x8183 +#endif /* GL_SGIX_calligraphic_fragment */ + +#ifndef GL_SGIX_clipmap +#define GL_SGIX_clipmap 1 +#define GL_LINEAR_CLIPMAP_LINEAR_SGIX 0x8170 +#define GL_TEXTURE_CLIPMAP_CENTER_SGIX 0x8171 +#define GL_TEXTURE_CLIPMAP_FRAME_SGIX 0x8172 +#define GL_TEXTURE_CLIPMAP_OFFSET_SGIX 0x8173 +#define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174 +#define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175 +#define GL_TEXTURE_CLIPMAP_DEPTH_SGIX 0x8176 +#define GL_MAX_CLIPMAP_DEPTH_SGIX 0x8177 +#define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178 +#define GL_NEAREST_CLIPMAP_NEAREST_SGIX 0x844D +#define GL_NEAREST_CLIPMAP_LINEAR_SGIX 0x844E +#define GL_LINEAR_CLIPMAP_NEAREST_SGIX 0x844F +#endif /* GL_SGIX_clipmap */ + +#ifndef GL_SGIX_convolution_accuracy +#define GL_SGIX_convolution_accuracy 1 +#define GL_CONVOLUTION_HINT_SGIX 0x8316 +#endif /* GL_SGIX_convolution_accuracy */ + +#ifndef GL_SGIX_depth_pass_instrument +#define GL_SGIX_depth_pass_instrument 1 +#endif /* GL_SGIX_depth_pass_instrument */ + +#ifndef GL_SGIX_depth_texture +#define GL_SGIX_depth_texture 1 +#define GL_DEPTH_COMPONENT16_SGIX 0x81A5 +#define GL_DEPTH_COMPONENT24_SGIX 0x81A6 +#define GL_DEPTH_COMPONENT32_SGIX 0x81A7 +#endif /* GL_SGIX_depth_texture */ + +#ifndef GL_SGIX_flush_raster +#define GL_SGIX_flush_raster 1 +typedef void (APIENTRYP PFNGLFLUSHRASTERSGIXPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushRasterSGIX (void); +#endif +#endif /* GL_SGIX_flush_raster */ + +#ifndef GL_SGIX_fog_offset +#define GL_SGIX_fog_offset 1 +#define GL_FOG_OFFSET_SGIX 0x8198 +#define GL_FOG_OFFSET_VALUE_SGIX 0x8199 +#endif /* GL_SGIX_fog_offset */ + +#ifndef GL_SGIX_fragment_lighting +#define GL_SGIX_fragment_lighting 1 +#define GL_FRAGMENT_LIGHTING_SGIX 0x8400 +#define GL_FRAGMENT_COLOR_MATERIAL_SGIX 0x8401 +#define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402 +#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403 +#define GL_MAX_FRAGMENT_LIGHTS_SGIX 0x8404 +#define GL_MAX_ACTIVE_LIGHTS_SGIX 0x8405 +#define GL_CURRENT_RASTER_NORMAL_SGIX 0x8406 +#define GL_LIGHT_ENV_MODE_SGIX 0x8407 +#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408 +#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409 +#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A +#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B +#define GL_FRAGMENT_LIGHT0_SGIX 0x840C +#define GL_FRAGMENT_LIGHT1_SGIX 0x840D +#define GL_FRAGMENT_LIGHT2_SGIX 0x840E +#define GL_FRAGMENT_LIGHT3_SGIX 0x840F +#define GL_FRAGMENT_LIGHT4_SGIX 0x8410 +#define GL_FRAGMENT_LIGHT5_SGIX 0x8411 +#define GL_FRAGMENT_LIGHT6_SGIX 0x8412 +#define GL_FRAGMENT_LIGHT7_SGIX 0x8413 +typedef void (APIENTRYP PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFragmentColorMaterialSGIX (GLenum face, GLenum mode); +GLAPI void APIENTRY glFragmentLightfSGIX (GLenum light, GLenum pname, GLfloat param); +GLAPI void APIENTRY glFragmentLightfvSGIX (GLenum light, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glFragmentLightiSGIX (GLenum light, GLenum pname, GLint param); +GLAPI void APIENTRY glFragmentLightivSGIX (GLenum light, GLenum pname, const GLint *params); +GLAPI void APIENTRY glFragmentLightModelfSGIX (GLenum pname, GLfloat param); +GLAPI void APIENTRY glFragmentLightModelfvSGIX (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glFragmentLightModeliSGIX (GLenum pname, GLint param); +GLAPI void APIENTRY glFragmentLightModelivSGIX (GLenum pname, const GLint *params); +GLAPI void APIENTRY glFragmentMaterialfSGIX (GLenum face, GLenum pname, GLfloat param); +GLAPI void APIENTRY glFragmentMaterialfvSGIX (GLenum face, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glFragmentMaterialiSGIX (GLenum face, GLenum pname, GLint param); +GLAPI void APIENTRY glFragmentMaterialivSGIX (GLenum face, GLenum pname, const GLint *params); +GLAPI void APIENTRY glGetFragmentLightfvSGIX (GLenum light, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetFragmentLightivSGIX (GLenum light, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetFragmentMaterialfvSGIX (GLenum face, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetFragmentMaterialivSGIX (GLenum face, GLenum pname, GLint *params); +GLAPI void APIENTRY glLightEnviSGIX (GLenum pname, GLint param); +#endif +#endif /* GL_SGIX_fragment_lighting */ + +#ifndef GL_SGIX_framezoom +#define GL_SGIX_framezoom 1 +#define GL_FRAMEZOOM_SGIX 0x818B +#define GL_FRAMEZOOM_FACTOR_SGIX 0x818C +#define GL_MAX_FRAMEZOOM_FACTOR_SGIX 0x818D +typedef void (APIENTRYP PFNGLFRAMEZOOMSGIXPROC) (GLint factor); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFrameZoomSGIX (GLint factor); +#endif +#endif /* GL_SGIX_framezoom */ + +#ifndef GL_SGIX_igloo_interface +#define GL_SGIX_igloo_interface 1 +typedef void (APIENTRYP PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const void *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIglooInterfaceSGIX (GLenum pname, const void *params); +#endif +#endif /* GL_SGIX_igloo_interface */ + +#ifndef GL_SGIX_instruments +#define GL_SGIX_instruments 1 +#define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180 +#define GL_INSTRUMENT_MEASUREMENTS_SGIX 0x8181 +typedef GLint (APIENTRYP PFNGLGETINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer); +typedef GLint (APIENTRYP PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p); +typedef void (APIENTRYP PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker); +typedef void (APIENTRYP PFNGLSTARTINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLint APIENTRY glGetInstrumentsSGIX (void); +GLAPI void APIENTRY glInstrumentsBufferSGIX (GLsizei size, GLint *buffer); +GLAPI GLint APIENTRY glPollInstrumentsSGIX (GLint *marker_p); +GLAPI void APIENTRY glReadInstrumentsSGIX (GLint marker); +GLAPI void APIENTRY glStartInstrumentsSGIX (void); +GLAPI void APIENTRY glStopInstrumentsSGIX (GLint marker); +#endif +#endif /* GL_SGIX_instruments */ + +#ifndef GL_SGIX_interlace +#define GL_SGIX_interlace 1 +#define GL_INTERLACE_SGIX 0x8094 +#endif /* GL_SGIX_interlace */ + +#ifndef GL_SGIX_ir_instrument1 +#define GL_SGIX_ir_instrument1 1 +#define GL_IR_INSTRUMENT1_SGIX 0x817F +#endif /* GL_SGIX_ir_instrument1 */ + +#ifndef GL_SGIX_list_priority +#define GL_SGIX_list_priority 1 +#define GL_LIST_PRIORITY_SGIX 0x8182 +typedef void (APIENTRYP PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetListParameterfvSGIX (GLuint list, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetListParameterivSGIX (GLuint list, GLenum pname, GLint *params); +GLAPI void APIENTRY glListParameterfSGIX (GLuint list, GLenum pname, GLfloat param); +GLAPI void APIENTRY glListParameterfvSGIX (GLuint list, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glListParameteriSGIX (GLuint list, GLenum pname, GLint param); +GLAPI void APIENTRY glListParameterivSGIX (GLuint list, GLenum pname, const GLint *params); +#endif +#endif /* GL_SGIX_list_priority */ + +#ifndef GL_SGIX_pixel_texture +#define GL_SGIX_pixel_texture 1 +#define GL_PIXEL_TEX_GEN_SGIX 0x8139 +#define GL_PIXEL_TEX_GEN_MODE_SGIX 0x832B +typedef void (APIENTRYP PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTexGenSGIX (GLenum mode); +#endif +#endif /* GL_SGIX_pixel_texture */ + +#ifndef GL_SGIX_pixel_tiles +#define GL_SGIX_pixel_tiles 1 +#define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E +#define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F +#define GL_PIXEL_TILE_WIDTH_SGIX 0x8140 +#define GL_PIXEL_TILE_HEIGHT_SGIX 0x8141 +#define GL_PIXEL_TILE_GRID_WIDTH_SGIX 0x8142 +#define GL_PIXEL_TILE_GRID_HEIGHT_SGIX 0x8143 +#define GL_PIXEL_TILE_GRID_DEPTH_SGIX 0x8144 +#define GL_PIXEL_TILE_CACHE_SIZE_SGIX 0x8145 +#endif /* GL_SGIX_pixel_tiles */ + +#ifndef GL_SGIX_polynomial_ffd +#define GL_SGIX_polynomial_ffd 1 +#define GL_TEXTURE_DEFORMATION_BIT_SGIX 0x00000001 +#define GL_GEOMETRY_DEFORMATION_BIT_SGIX 0x00000002 +#define GL_GEOMETRY_DEFORMATION_SGIX 0x8194 +#define GL_TEXTURE_DEFORMATION_SGIX 0x8195 +#define GL_DEFORMATIONS_MASK_SGIX 0x8196 +#define GL_MAX_DEFORMATION_ORDER_SGIX 0x8197 +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); +typedef void (APIENTRYP PFNGLDEFORMSGIXPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeformationMap3dSGIX (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); +GLAPI void APIENTRY glDeformationMap3fSGIX (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); +GLAPI void APIENTRY glDeformSGIX (GLbitfield mask); +GLAPI void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield mask); +#endif +#endif /* GL_SGIX_polynomial_ffd */ + +#ifndef GL_SGIX_reference_plane +#define GL_SGIX_reference_plane 1 +#define GL_REFERENCE_PLANE_SGIX 0x817D +#define GL_REFERENCE_PLANE_EQUATION_SGIX 0x817E +typedef void (APIENTRYP PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *equation); +#endif +#endif /* GL_SGIX_reference_plane */ + +#ifndef GL_SGIX_resample +#define GL_SGIX_resample 1 +#define GL_PACK_RESAMPLE_SGIX 0x842E +#define GL_UNPACK_RESAMPLE_SGIX 0x842F +#define GL_RESAMPLE_REPLICATE_SGIX 0x8433 +#define GL_RESAMPLE_ZERO_FILL_SGIX 0x8434 +#define GL_RESAMPLE_DECIMATE_SGIX 0x8430 +#endif /* GL_SGIX_resample */ + +#ifndef GL_SGIX_scalebias_hint +#define GL_SGIX_scalebias_hint 1 +#define GL_SCALEBIAS_HINT_SGIX 0x8322 +#endif /* GL_SGIX_scalebias_hint */ + +#ifndef GL_SGIX_shadow +#define GL_SGIX_shadow 1 +#define GL_TEXTURE_COMPARE_SGIX 0x819A +#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B +#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C +#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D +#endif /* GL_SGIX_shadow */ + +#ifndef GL_SGIX_shadow_ambient +#define GL_SGIX_shadow_ambient 1 +#define GL_SHADOW_AMBIENT_SGIX 0x80BF +#endif /* GL_SGIX_shadow_ambient */ + +#ifndef GL_SGIX_sprite +#define GL_SGIX_sprite 1 +#define GL_SPRITE_SGIX 0x8148 +#define GL_SPRITE_MODE_SGIX 0x8149 +#define GL_SPRITE_AXIS_SGIX 0x814A +#define GL_SPRITE_TRANSLATION_SGIX 0x814B +#define GL_SPRITE_AXIAL_SGIX 0x814C +#define GL_SPRITE_OBJECT_ALIGNED_SGIX 0x814D +#define GL_SPRITE_EYE_ALIGNED_SGIX 0x814E +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSpriteParameterfSGIX (GLenum pname, GLfloat param); +GLAPI void APIENTRY glSpriteParameterfvSGIX (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glSpriteParameteriSGIX (GLenum pname, GLint param); +GLAPI void APIENTRY glSpriteParameterivSGIX (GLenum pname, const GLint *params); +#endif +#endif /* GL_SGIX_sprite */ + +#ifndef GL_SGIX_subsample +#define GL_SGIX_subsample 1 +#define GL_PACK_SUBSAMPLE_RATE_SGIX 0x85A0 +#define GL_UNPACK_SUBSAMPLE_RATE_SGIX 0x85A1 +#define GL_PIXEL_SUBSAMPLE_4444_SGIX 0x85A2 +#define GL_PIXEL_SUBSAMPLE_2424_SGIX 0x85A3 +#define GL_PIXEL_SUBSAMPLE_4242_SGIX 0x85A4 +#endif /* GL_SGIX_subsample */ + +#ifndef GL_SGIX_tag_sample_buffer +#define GL_SGIX_tag_sample_buffer 1 +typedef void (APIENTRYP PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTagSampleBufferSGIX (void); +#endif +#endif /* GL_SGIX_tag_sample_buffer */ + +#ifndef GL_SGIX_texture_add_env +#define GL_SGIX_texture_add_env 1 +#define GL_TEXTURE_ENV_BIAS_SGIX 0x80BE +#endif /* GL_SGIX_texture_add_env */ + +#ifndef GL_SGIX_texture_coordinate_clamp +#define GL_SGIX_texture_coordinate_clamp 1 +#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 +#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A +#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B +#endif /* GL_SGIX_texture_coordinate_clamp */ + +#ifndef GL_SGIX_texture_lod_bias +#define GL_SGIX_texture_lod_bias 1 +#define GL_TEXTURE_LOD_BIAS_S_SGIX 0x818E +#define GL_TEXTURE_LOD_BIAS_T_SGIX 0x818F +#define GL_TEXTURE_LOD_BIAS_R_SGIX 0x8190 +#endif /* GL_SGIX_texture_lod_bias */ + +#ifndef GL_SGIX_texture_multi_buffer +#define GL_SGIX_texture_multi_buffer 1 +#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E +#endif /* GL_SGIX_texture_multi_buffer */ + +#ifndef GL_SGIX_texture_scale_bias +#define GL_SGIX_texture_scale_bias 1 +#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 +#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A +#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B +#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C +#endif /* GL_SGIX_texture_scale_bias */ + +#ifndef GL_SGIX_vertex_preclip +#define GL_SGIX_vertex_preclip 1 +#define GL_VERTEX_PRECLIP_SGIX 0x83EE +#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF +#endif /* GL_SGIX_vertex_preclip */ + +#ifndef GL_SGIX_ycrcb +#define GL_SGIX_ycrcb 1 +#define GL_YCRCB_422_SGIX 0x81BB +#define GL_YCRCB_444_SGIX 0x81BC +#endif /* GL_SGIX_ycrcb */ + +#ifndef GL_SGIX_ycrcb_subsample +#define GL_SGIX_ycrcb_subsample 1 +#endif /* GL_SGIX_ycrcb_subsample */ + +#ifndef GL_SGIX_ycrcba +#define GL_SGIX_ycrcba 1 +#define GL_YCRCB_SGIX 0x8318 +#define GL_YCRCBA_SGIX 0x8319 +#endif /* GL_SGIX_ycrcba */ + +#ifndef GL_SGI_color_matrix +#define GL_SGI_color_matrix 1 +#define GL_COLOR_MATRIX_SGI 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB +#endif /* GL_SGI_color_matrix */ + +#ifndef GL_SGI_color_table +#define GL_SGI_color_table 1 +#define GL_COLOR_TABLE_SGI 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 +#define GL_PROXY_COLOR_TABLE_SGI 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 +#define GL_COLOR_TABLE_SCALE_SGI 0x80D6 +#define GL_COLOR_TABLE_BIAS_SGI 0x80D7 +#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 +#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF +typedef void (APIENTRYP PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, void *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTableSGI (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); +GLAPI void APIENTRY glColorTableParameterfvSGI (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glColorTableParameterivSGI (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyColorTableSGI (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glGetColorTableSGI (GLenum target, GLenum format, GLenum type, void *table); +GLAPI void APIENTRY glGetColorTableParameterfvSGI (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetColorTableParameterivSGI (GLenum target, GLenum pname, GLint *params); +#endif +#endif /* GL_SGI_color_table */ + +#ifndef GL_SGI_texture_color_table +#define GL_SGI_texture_color_table 1 +#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC +#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD +#endif /* GL_SGI_texture_color_table */ + +#ifndef GL_SUNX_constant_data +#define GL_SUNX_constant_data 1 +#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 +#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 +typedef void (APIENTRYP PFNGLFINISHTEXTURESUNXPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFinishTextureSUNX (void); +#endif +#endif /* GL_SUNX_constant_data */ + +#ifndef GL_SUN_convolution_border_modes +#define GL_SUN_convolution_border_modes 1 +#define GL_WRAP_BORDER_SUN 0x81D4 +#endif /* GL_SUN_convolution_border_modes */ + +#ifndef GL_SUN_global_alpha +#define GL_SUN_global_alpha 1 +#define GL_GLOBAL_ALPHA_SUN 0x81D9 +#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGlobalAlphaFactorbSUN (GLbyte factor); +GLAPI void APIENTRY glGlobalAlphaFactorsSUN (GLshort factor); +GLAPI void APIENTRY glGlobalAlphaFactoriSUN (GLint factor); +GLAPI void APIENTRY glGlobalAlphaFactorfSUN (GLfloat factor); +GLAPI void APIENTRY glGlobalAlphaFactordSUN (GLdouble factor); +GLAPI void APIENTRY glGlobalAlphaFactorubSUN (GLubyte factor); +GLAPI void APIENTRY glGlobalAlphaFactorusSUN (GLushort factor); +GLAPI void APIENTRY glGlobalAlphaFactoruiSUN (GLuint factor); +#endif +#endif /* GL_SUN_global_alpha */ + +#ifndef GL_SUN_mesh_array +#define GL_SUN_mesh_array 1 +#define GL_QUAD_MESH_SUN 0x8614 +#define GL_TRIANGLE_MESH_SUN 0x8615 +typedef void (APIENTRYP PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawMeshArraysSUN (GLenum mode, GLint first, GLsizei count, GLsizei width); +#endif +#endif /* GL_SUN_mesh_array */ + +#ifndef GL_SUN_slice_accum +#define GL_SUN_slice_accum 1 +#define GL_SLICE_ACCUM_SUN 0x85CC +#endif /* GL_SUN_slice_accum */ + +#ifndef GL_SUN_triangle_list +#define GL_SUN_triangle_list 1 +#define GL_RESTART_SUN 0x0001 +#define GL_REPLACE_MIDDLE_SUN 0x0002 +#define GL_REPLACE_OLDEST_SUN 0x0003 +#define GL_TRIANGLE_LIST_SUN 0x81D7 +#define GL_REPLACEMENT_CODE_SUN 0x81D8 +#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 +#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 +#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 +#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 +#define GL_R1UI_V3F_SUN 0x85C4 +#define GL_R1UI_C4UB_V3F_SUN 0x85C5 +#define GL_R1UI_C3F_V3F_SUN 0x85C6 +#define GL_R1UI_N3F_V3F_SUN 0x85C7 +#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 +#define GL_R1UI_T2F_V3F_SUN 0x85C9 +#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA +#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const void **pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReplacementCodeuiSUN (GLuint code); +GLAPI void APIENTRY glReplacementCodeusSUN (GLushort code); +GLAPI void APIENTRY glReplacementCodeubSUN (GLubyte code); +GLAPI void APIENTRY glReplacementCodeuivSUN (const GLuint *code); +GLAPI void APIENTRY glReplacementCodeusvSUN (const GLushort *code); +GLAPI void APIENTRY glReplacementCodeubvSUN (const GLubyte *code); +GLAPI void APIENTRY glReplacementCodePointerSUN (GLenum type, GLsizei stride, const void **pointer); +#endif +#endif /* GL_SUN_triangle_list */ + +#ifndef GL_SUN_vertex +#define GL_SUN_vertex 1 +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColor4ubVertex2fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); +GLAPI void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glColor4ubVertex3fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glColor3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor3fVertex3fvSUN (const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glNormal3fVertex3fSUN (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fVertex3fSUN (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glTexCoord4fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *tc, const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint rc, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *rc, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *rc, const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +#endif +#endif /* GL_SUN_vertex */ + +#ifndef GL_WIN_phong_shading +#define GL_WIN_phong_shading 1 +#define GL_PHONG_WIN 0x80EA +#define GL_PHONG_HINT_WIN 0x80EB +#endif /* GL_WIN_phong_shading */ + +#ifndef GL_WIN_specular_fog +#define GL_WIN_specular_fog 1 +#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC +#endif /* GL_WIN_specular_fog */ + +#ifdef __cplusplus +} +#endif + +#endif diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_opengles.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_opengles.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,38 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* + * This is a simple file to encapsulate the OpenGL ES 1.X API headers. + */ + +#include + +#ifdef SDL_PLATFORM_IOS +#include +#include +#else +#include +#include +#endif + +#ifndef APIENTRY +#define APIENTRY +#endif diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_opengles2.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_opengles2.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,51 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* + * This is a simple file to encapsulate the OpenGL ES 2.0 API headers. + */ + +#include + +#if !defined(_MSC_VER) && !defined(SDL_USE_BUILTIN_OPENGL_DEFINITIONS) + +#ifdef SDL_PLATFORM_IOS +#include +#include +#else +#include +#include +#include +#endif + +#else /* _MSC_VER */ + +/* OpenGL ES2 headers for Visual Studio */ +#include +#include +#include +#include + +#endif /* _MSC_VER */ + +#ifndef APIENTRY +#define APIENTRY GL_APIENTRY +#endif diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_opengles2_gl2.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_opengles2_gl2.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,656 @@ +#ifndef __gles2_gl2_h_ +#define __gles2_gl2_h_ 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Copyright 2013-2020 The Khronos Group Inc. +** SPDX-License-Identifier: MIT +** +** This header is generated from the Khronos OpenGL / OpenGL ES XML +** API Registry. The current version of the Registry, generator scripts +** used to make the header, and the header can be found at +** https://github.com/KhronosGroup/OpenGL-Registry +*/ + +/*#include */ + +#ifndef GL_APIENTRYP +#define GL_APIENTRYP GL_APIENTRY* +#endif + +#ifndef GL_GLES_PROTOTYPES +#define GL_GLES_PROTOTYPES 1 +#endif + +/* Generated on date 20220530 */ + +/* Generated C header for: + * API: gles2 + * Profile: common + * Versions considered: 2\.[0-9] + * Versions emitted: .* + * Default extensions included: None + * Additional extensions included: _nomatch_^ + * Extensions removed: _nomatch_^ + */ + +#ifndef GL_ES_VERSION_2_0 +#define GL_ES_VERSION_2_0 1 +/*#include */ +typedef khronos_int8_t GLbyte; +typedef khronos_float_t GLclampf; +typedef khronos_int32_t GLfixed; +typedef khronos_int16_t GLshort; +typedef khronos_uint16_t GLushort; +typedef void GLvoid; +typedef struct __GLsync *GLsync; +typedef khronos_int64_t GLint64; +typedef khronos_uint64_t GLuint64; +typedef unsigned int GLenum; +typedef unsigned int GLuint; +typedef char GLchar; +typedef khronos_float_t GLfloat; +typedef khronos_ssize_t GLsizeiptr; +typedef khronos_intptr_t GLintptr; +typedef unsigned int GLbitfield; +typedef int GLint; +typedef unsigned char GLboolean; +typedef int GLsizei; +typedef khronos_uint8_t GLubyte; +#define GL_DEPTH_BUFFER_BIT 0x00000100 +#define GL_STENCIL_BUFFER_BIT 0x00000400 +#define GL_COLOR_BUFFER_BIT 0x00004000 +#define GL_FALSE 0 +#define GL_TRUE 1 +#define GL_POINTS 0x0000 +#define GL_LINES 0x0001 +#define GL_LINE_LOOP 0x0002 +#define GL_LINE_STRIP 0x0003 +#define GL_TRIANGLES 0x0004 +#define GL_TRIANGLE_STRIP 0x0005 +#define GL_TRIANGLE_FAN 0x0006 +#define GL_ZERO 0 +#define GL_ONE 1 +#define GL_SRC_COLOR 0x0300 +#define GL_ONE_MINUS_SRC_COLOR 0x0301 +#define GL_SRC_ALPHA 0x0302 +#define GL_ONE_MINUS_SRC_ALPHA 0x0303 +#define GL_DST_ALPHA 0x0304 +#define GL_ONE_MINUS_DST_ALPHA 0x0305 +#define GL_DST_COLOR 0x0306 +#define GL_ONE_MINUS_DST_COLOR 0x0307 +#define GL_SRC_ALPHA_SATURATE 0x0308 +#define GL_FUNC_ADD 0x8006 +#define GL_BLEND_EQUATION 0x8009 +#define GL_BLEND_EQUATION_RGB 0x8009 +#define GL_BLEND_EQUATION_ALPHA 0x883D +#define GL_FUNC_SUBTRACT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_BLEND_COLOR 0x8005 +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#define GL_STREAM_DRAW 0x88E0 +#define GL_STATIC_DRAW 0x88E4 +#define GL_DYNAMIC_DRAW 0x88E8 +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 +#define GL_FRONT 0x0404 +#define GL_BACK 0x0405 +#define GL_FRONT_AND_BACK 0x0408 +#define GL_TEXTURE_2D 0x0DE1 +#define GL_CULL_FACE 0x0B44 +#define GL_BLEND 0x0BE2 +#define GL_DITHER 0x0BD0 +#define GL_STENCIL_TEST 0x0B90 +#define GL_DEPTH_TEST 0x0B71 +#define GL_SCISSOR_TEST 0x0C11 +#define GL_POLYGON_OFFSET_FILL 0x8037 +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_COVERAGE 0x80A0 +#define GL_NO_ERROR 0 +#define GL_INVALID_ENUM 0x0500 +#define GL_INVALID_VALUE 0x0501 +#define GL_INVALID_OPERATION 0x0502 +#define GL_OUT_OF_MEMORY 0x0505 +#define GL_CW 0x0900 +#define GL_CCW 0x0901 +#define GL_LINE_WIDTH 0x0B21 +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#define GL_CULL_FACE_MODE 0x0B45 +#define GL_FRONT_FACE 0x0B46 +#define GL_DEPTH_RANGE 0x0B70 +#define GL_DEPTH_WRITEMASK 0x0B72 +#define GL_DEPTH_CLEAR_VALUE 0x0B73 +#define GL_DEPTH_FUNC 0x0B74 +#define GL_STENCIL_CLEAR_VALUE 0x0B91 +#define GL_STENCIL_FUNC 0x0B92 +#define GL_STENCIL_FAIL 0x0B94 +#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 +#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 +#define GL_STENCIL_REF 0x0B97 +#define GL_STENCIL_VALUE_MASK 0x0B93 +#define GL_STENCIL_WRITEMASK 0x0B98 +#define GL_STENCIL_BACK_FUNC 0x8800 +#define GL_STENCIL_BACK_FAIL 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#define GL_STENCIL_BACK_REF 0x8CA3 +#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 +#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 +#define GL_VIEWPORT 0x0BA2 +#define GL_SCISSOR_BOX 0x0C10 +#define GL_COLOR_CLEAR_VALUE 0x0C22 +#define GL_COLOR_WRITEMASK 0x0C23 +#define GL_UNPACK_ALIGNMENT 0x0CF5 +#define GL_PACK_ALIGNMENT 0x0D05 +#define GL_MAX_TEXTURE_SIZE 0x0D33 +#define GL_MAX_VIEWPORT_DIMS 0x0D3A +#define GL_SUBPIXEL_BITS 0x0D50 +#define GL_RED_BITS 0x0D52 +#define GL_GREEN_BITS 0x0D53 +#define GL_BLUE_BITS 0x0D54 +#define GL_ALPHA_BITS 0x0D55 +#define GL_DEPTH_BITS 0x0D56 +#define GL_STENCIL_BITS 0x0D57 +#define GL_POLYGON_OFFSET_UNITS 0x2A00 +#define GL_POLYGON_OFFSET_FACTOR 0x8038 +#define GL_TEXTURE_BINDING_2D 0x8069 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +#define GL_DONT_CARE 0x1100 +#define GL_FASTEST 0x1101 +#define GL_NICEST 0x1102 +#define GL_GENERATE_MIPMAP_HINT 0x8192 +#define GL_BYTE 0x1400 +#define GL_UNSIGNED_BYTE 0x1401 +#define GL_SHORT 0x1402 +#define GL_UNSIGNED_SHORT 0x1403 +#define GL_INT 0x1404 +#define GL_UNSIGNED_INT 0x1405 +#define GL_FLOAT 0x1406 +#define GL_FIXED 0x140C +#define GL_DEPTH_COMPONENT 0x1902 +#define GL_ALPHA 0x1906 +#define GL_RGB 0x1907 +#define GL_RGBA 0x1908 +#define GL_LUMINANCE 0x1909 +#define GL_LUMINANCE_ALPHA 0x190A +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_VERTEX_SHADER 0x8B31 +#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB +#define GL_MAX_VARYING_VECTORS 0x8DFC +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C +#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 +#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD +#define GL_SHADER_TYPE 0x8B4F +#define GL_DELETE_STATUS 0x8B80 +#define GL_LINK_STATUS 0x8B82 +#define GL_VALIDATE_STATUS 0x8B83 +#define GL_ATTACHED_SHADERS 0x8B85 +#define GL_ACTIVE_UNIFORMS 0x8B86 +#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 +#define GL_ACTIVE_ATTRIBUTES 0x8B89 +#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A +#define GL_SHADING_LANGUAGE_VERSION 0x8B8C +#define GL_CURRENT_PROGRAM 0x8B8D +#define GL_NEVER 0x0200 +#define GL_LESS 0x0201 +#define GL_EQUAL 0x0202 +#define GL_LEQUAL 0x0203 +#define GL_GREATER 0x0204 +#define GL_NOTEQUAL 0x0205 +#define GL_GEQUAL 0x0206 +#define GL_ALWAYS 0x0207 +#define GL_KEEP 0x1E00 +#define GL_REPLACE 0x1E01 +#define GL_INCR 0x1E02 +#define GL_DECR 0x1E03 +#define GL_INVERT 0x150A +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 +#define GL_VENDOR 0x1F00 +#define GL_RENDERER 0x1F01 +#define GL_VERSION 0x1F02 +#define GL_EXTENSIONS 0x1F03 +#define GL_NEAREST 0x2600 +#define GL_LINEAR 0x2601 +#define GL_NEAREST_MIPMAP_NEAREST 0x2700 +#define GL_LINEAR_MIPMAP_NEAREST 0x2701 +#define GL_NEAREST_MIPMAP_LINEAR 0x2702 +#define GL_LINEAR_MIPMAP_LINEAR 0x2703 +#define GL_TEXTURE_MAG_FILTER 0x2800 +#define GL_TEXTURE_MIN_FILTER 0x2801 +#define GL_TEXTURE_WRAP_S 0x2802 +#define GL_TEXTURE_WRAP_T 0x2803 +#define GL_TEXTURE 0x1702 +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_REPEAT 0x2901 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_MIRRORED_REPEAT 0x8370 +#define GL_FLOAT_VEC2 0x8B50 +#define GL_FLOAT_VEC3 0x8B51 +#define GL_FLOAT_VEC4 0x8B52 +#define GL_INT_VEC2 0x8B53 +#define GL_INT_VEC3 0x8B54 +#define GL_INT_VEC4 0x8B55 +#define GL_BOOL 0x8B56 +#define GL_BOOL_VEC2 0x8B57 +#define GL_BOOL_VEC3 0x8B58 +#define GL_BOOL_VEC4 0x8B59 +#define GL_FLOAT_MAT2 0x8B5A +#define GL_FLOAT_MAT3 0x8B5B +#define GL_FLOAT_MAT4 0x8B5C +#define GL_SAMPLER_2D 0x8B5E +#define GL_SAMPLER_CUBE 0x8B60 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F +#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B +#define GL_COMPILE_STATUS 0x8B81 +#define GL_INFO_LOG_LENGTH 0x8B84 +#define GL_SHADER_SOURCE_LENGTH 0x8B88 +#define GL_SHADER_COMPILER 0x8DFA +#define GL_SHADER_BINARY_FORMATS 0x8DF8 +#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 +#define GL_LOW_FLOAT 0x8DF0 +#define GL_MEDIUM_FLOAT 0x8DF1 +#define GL_HIGH_FLOAT 0x8DF2 +#define GL_LOW_INT 0x8DF3 +#define GL_MEDIUM_INT 0x8DF4 +#define GL_HIGH_INT 0x8DF5 +#define GL_FRAMEBUFFER 0x8D40 +#define GL_RENDERBUFFER 0x8D41 +#define GL_RGBA4 0x8056 +#define GL_RGB5_A1 0x8057 +#define GL_RGB565 0x8D62 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_STENCIL_INDEX8 0x8D48 +#define GL_RENDERBUFFER_WIDTH 0x8D42 +#define GL_RENDERBUFFER_HEIGHT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 +#define GL_RENDERBUFFER_RED_SIZE 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 +#define GL_COLOR_ATTACHMENT0 0x8CE0 +#define GL_DEPTH_ATTACHMENT 0x8D00 +#define GL_STENCIL_ATTACHMENT 0x8D20 +#define GL_NONE 0 +#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9 +#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD +#define GL_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_RENDERBUFFER_BINDING 0x8CA7 +#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 +#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 +typedef void (GL_APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); +typedef void (GL_APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (GL_APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); +typedef void (GL_APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); +typedef void (GL_APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer); +typedef void (GL_APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer); +typedef void (GL_APIENTRYP PFNGLBINDTEXTUREPROC) (GLenum target, GLuint texture); +typedef void (GL_APIENTRYP PFNGLBLENDCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); +typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); +typedef void (GL_APIENTRYP PFNGLBLENDFUNCPROC) (GLenum sfactor, GLenum dfactor); +typedef void (GL_APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +typedef void (GL_APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const void *data, GLenum usage); +typedef void (GL_APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); +typedef GLenum (GL_APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); +typedef void (GL_APIENTRYP PFNGLCLEARPROC) (GLbitfield mask); +typedef void (GL_APIENTRYP PFNGLCLEARCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void (GL_APIENTRYP PFNGLCLEARDEPTHFPROC) (GLfloat d); +typedef void (GL_APIENTRYP PFNGLCLEARSTENCILPROC) (GLint s); +typedef void (GL_APIENTRYP PFNGLCOLORMASKPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +typedef void (GL_APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); +typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +typedef void (GL_APIENTRYP PFNGLCOPYTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef GLuint (GL_APIENTRYP PFNGLCREATEPROGRAMPROC) (void); +typedef GLuint (GL_APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); +typedef void (GL_APIENTRYP PFNGLCULLFACEPROC) (GLenum mode); +typedef void (GL_APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); +typedef void (GL_APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (GL_APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); +typedef void (GL_APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (GL_APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); +typedef void (GL_APIENTRYP PFNGLDELETETEXTURESPROC) (GLsizei n, const GLuint *textures); +typedef void (GL_APIENTRYP PFNGLDEPTHFUNCPROC) (GLenum func); +typedef void (GL_APIENTRYP PFNGLDEPTHMASKPROC) (GLboolean flag); +typedef void (GL_APIENTRYP PFNGLDEPTHRANGEFPROC) (GLfloat n, GLfloat f); +typedef void (GL_APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (GL_APIENTRYP PFNGLDISABLEPROC) (GLenum cap); +typedef void (GL_APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (GL_APIENTRYP PFNGLDRAWARRAYSPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices); +typedef void (GL_APIENTRYP PFNGLENABLEPROC) (GLenum cap); +typedef void (GL_APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (GL_APIENTRYP PFNGLFINISHPROC) (void); +typedef void (GL_APIENTRYP PFNGLFLUSHPROC) (void); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (GL_APIENTRYP PFNGLFRONTFACEPROC) (GLenum mode); +typedef void (GL_APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); +typedef void (GL_APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target); +typedef void (GL_APIENTRYP PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); +typedef void (GL_APIENTRYP PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (GL_APIENTRYP PFNGLGENTEXTURESPROC) (GLsizei n, GLuint *textures); +typedef void (GL_APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (GL_APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (GL_APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); +typedef GLint (GL_APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (GL_APIENTRYP PFNGLGETBOOLEANVPROC) (GLenum pname, GLboolean *data); +typedef void (GL_APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLenum (GL_APIENTRYP PFNGLGETERRORPROC) (void); +typedef void (GL_APIENTRYP PFNGLGETFLOATVPROC) (GLenum pname, GLfloat *data); +typedef void (GL_APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETINTEGERVPROC) (GLenum pname, GLint *data); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (GL_APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (GL_APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +typedef void (GL_APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +typedef const GLubyte *(GL_APIENTRYP PFNGLGETSTRINGPROC) (GLenum name); +typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); +typedef void (GL_APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); +typedef GLint (GL_APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (GL_APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (GL_APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, void **pointer); +typedef void (GL_APIENTRYP PFNGLHINTPROC) (GLenum target, GLenum mode); +typedef GLboolean (GL_APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); +typedef GLboolean (GL_APIENTRYP PFNGLISENABLEDPROC) (GLenum cap); +typedef GLboolean (GL_APIENTRYP PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer); +typedef GLboolean (GL_APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); +typedef GLboolean (GL_APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer); +typedef GLboolean (GL_APIENTRYP PFNGLISSHADERPROC) (GLuint shader); +typedef GLboolean (GL_APIENTRYP PFNGLISTEXTUREPROC) (GLuint texture); +typedef void (GL_APIENTRYP PFNGLLINEWIDTHPROC) (GLfloat width); +typedef void (GL_APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); +typedef void (GL_APIENTRYP PFNGLPIXELSTOREIPROC) (GLenum pname, GLint param); +typedef void (GL_APIENTRYP PFNGLPOLYGONOFFSETPROC) (GLfloat factor, GLfloat units); +typedef void (GL_APIENTRYP PFNGLREADPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels); +typedef void (GL_APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void); +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLfloat value, GLboolean invert); +typedef void (GL_APIENTRYP PFNGLSCISSORPROC) (GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryFormat, const void *binary, GLsizei length); +typedef void (GL_APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); +typedef void (GL_APIENTRYP PFNGLSTENCILFUNCPROC) (GLenum func, GLint ref, GLuint mask); +typedef void (GL_APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum face, GLenum func, GLint ref, GLuint mask); +typedef void (GL_APIENTRYP PFNGLSTENCILMASKPROC) (GLuint mask); +typedef void (GL_APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); +typedef void (GL_APIENTRYP PFNGLSTENCILOPPROC) (GLenum fail, GLenum zfail, GLenum zpass); +typedef void (GL_APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (GL_APIENTRYP PFNGLTEXIMAGE2DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (GL_APIENTRYP PFNGLTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +typedef void (GL_APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); +typedef void (GL_APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); +typedef void (GL_APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (GL_APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); +typedef void (GL_APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (GL_APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (GL_APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (GL_APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (GL_APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); +typedef void (GL_APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +typedef void (GL_APIENTRYP PFNGLVIEWPORTPROC) (GLint x, GLint y, GLsizei width, GLsizei height); +#if GL_GLES_PROTOTYPES +GL_APICALL void GL_APIENTRY glActiveTexture (GLenum texture); +GL_APICALL void GL_APIENTRY glAttachShader (GLuint program, GLuint shader); +GL_APICALL void GL_APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar *name); +GL_APICALL void GL_APIENTRY glBindBuffer (GLenum target, GLuint buffer); +GL_APICALL void GL_APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); +GL_APICALL void GL_APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); +GL_APICALL void GL_APIENTRY glBindTexture (GLenum target, GLuint texture); +GL_APICALL void GL_APIENTRY glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GL_APICALL void GL_APIENTRY glBlendEquation (GLenum mode); +GL_APICALL void GL_APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); +GL_APICALL void GL_APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor); +GL_APICALL void GL_APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +GL_APICALL void GL_APIENTRY glBufferData (GLenum target, GLsizeiptr size, const void *data, GLenum usage); +GL_APICALL void GL_APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); +GL_APICALL GLenum GL_APIENTRY glCheckFramebufferStatus (GLenum target); +GL_APICALL void GL_APIENTRY glClear (GLbitfield mask); +GL_APICALL void GL_APIENTRY glClearColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GL_APICALL void GL_APIENTRY glClearDepthf (GLfloat d); +GL_APICALL void GL_APIENTRY glClearStencil (GLint s); +GL_APICALL void GL_APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +GL_APICALL void GL_APIENTRY glCompileShader (GLuint shader); +GL_APICALL void GL_APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +GL_APICALL void GL_APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +GL_APICALL void GL_APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GL_APICALL void GL_APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL GLuint GL_APIENTRY glCreateProgram (void); +GL_APICALL GLuint GL_APIENTRY glCreateShader (GLenum type); +GL_APICALL void GL_APIENTRY glCullFace (GLenum mode); +GL_APICALL void GL_APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers); +GL_APICALL void GL_APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers); +GL_APICALL void GL_APIENTRY glDeleteProgram (GLuint program); +GL_APICALL void GL_APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers); +GL_APICALL void GL_APIENTRY glDeleteShader (GLuint shader); +GL_APICALL void GL_APIENTRY glDeleteTextures (GLsizei n, const GLuint *textures); +GL_APICALL void GL_APIENTRY glDepthFunc (GLenum func); +GL_APICALL void GL_APIENTRY glDepthMask (GLboolean flag); +GL_APICALL void GL_APIENTRY glDepthRangef (GLfloat n, GLfloat f); +GL_APICALL void GL_APIENTRY glDetachShader (GLuint program, GLuint shader); +GL_APICALL void GL_APIENTRY glDisable (GLenum cap); +GL_APICALL void GL_APIENTRY glDisableVertexAttribArray (GLuint index); +GL_APICALL void GL_APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count); +GL_APICALL void GL_APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const void *indices); +GL_APICALL void GL_APIENTRY glEnable (GLenum cap); +GL_APICALL void GL_APIENTRY glEnableVertexAttribArray (GLuint index); +GL_APICALL void GL_APIENTRY glFinish (void); +GL_APICALL void GL_APIENTRY glFlush (void); +GL_APICALL void GL_APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GL_APICALL void GL_APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GL_APICALL void GL_APIENTRY glFrontFace (GLenum mode); +GL_APICALL void GL_APIENTRY glGenBuffers (GLsizei n, GLuint *buffers); +GL_APICALL void GL_APIENTRY glGenerateMipmap (GLenum target); +GL_APICALL void GL_APIENTRY glGenFramebuffers (GLsizei n, GLuint *framebuffers); +GL_APICALL void GL_APIENTRY glGenRenderbuffers (GLsizei n, GLuint *renderbuffers); +GL_APICALL void GL_APIENTRY glGenTextures (GLsizei n, GLuint *textures); +GL_APICALL void GL_APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GL_APICALL void GL_APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GL_APICALL void GL_APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); +GL_APICALL GLint GL_APIENTRY glGetAttribLocation (GLuint program, const GLchar *name); +GL_APICALL void GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean *data); +GL_APICALL void GL_APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params); +GL_APICALL GLenum GL_APIENTRY glGetError (void); +GL_APICALL void GL_APIENTRY glGetFloatv (GLenum pname, GLfloat *data); +GL_APICALL void GL_APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetIntegerv (GLenum pname, GLint *data); +GL_APICALL void GL_APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GL_APICALL void GL_APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GL_APICALL void GL_APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +GL_APICALL void GL_APIENTRY glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +GL_APICALL const GLubyte *GL_APIENTRY glGetString (GLenum name); +GL_APICALL void GL_APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat *params); +GL_APICALL void GL_APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat *params); +GL_APICALL void GL_APIENTRY glGetUniformiv (GLuint program, GLint location, GLint *params); +GL_APICALL GLint GL_APIENTRY glGetUniformLocation (GLuint program, const GLchar *name); +GL_APICALL void GL_APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat *params); +GL_APICALL void GL_APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, void **pointer); +GL_APICALL void GL_APIENTRY glHint (GLenum target, GLenum mode); +GL_APICALL GLboolean GL_APIENTRY glIsBuffer (GLuint buffer); +GL_APICALL GLboolean GL_APIENTRY glIsEnabled (GLenum cap); +GL_APICALL GLboolean GL_APIENTRY glIsFramebuffer (GLuint framebuffer); +GL_APICALL GLboolean GL_APIENTRY glIsProgram (GLuint program); +GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer (GLuint renderbuffer); +GL_APICALL GLboolean GL_APIENTRY glIsShader (GLuint shader); +GL_APICALL GLboolean GL_APIENTRY glIsTexture (GLuint texture); +GL_APICALL void GL_APIENTRY glLineWidth (GLfloat width); +GL_APICALL void GL_APIENTRY glLinkProgram (GLuint program); +GL_APICALL void GL_APIENTRY glPixelStorei (GLenum pname, GLint param); +GL_APICALL void GL_APIENTRY glPolygonOffset (GLfloat factor, GLfloat units); +GL_APICALL void GL_APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels); +GL_APICALL void GL_APIENTRY glReleaseShaderCompiler (void); +GL_APICALL void GL_APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glSampleCoverage (GLfloat value, GLboolean invert); +GL_APICALL void GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryFormat, const void *binary, GLsizei length); +GL_APICALL void GL_APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); +GL_APICALL void GL_APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask); +GL_APICALL void GL_APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); +GL_APICALL void GL_APIENTRY glStencilMask (GLuint mask); +GL_APICALL void GL_APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); +GL_APICALL void GL_APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass); +GL_APICALL void GL_APIENTRY glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +GL_APICALL void GL_APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +GL_APICALL void GL_APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param); +GL_APICALL void GL_APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat *params); +GL_APICALL void GL_APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param); +GL_APICALL void GL_APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint *params); +GL_APICALL void GL_APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +GL_APICALL void GL_APIENTRY glUniform1f (GLint location, GLfloat v0); +GL_APICALL void GL_APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniform1i (GLint location, GLint v0); +GL_APICALL void GL_APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1); +GL_APICALL void GL_APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniform2i (GLint location, GLint v0, GLint v1); +GL_APICALL void GL_APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GL_APICALL void GL_APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2); +GL_APICALL void GL_APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GL_APICALL void GL_APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GL_APICALL void GL_APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUseProgram (GLuint program); +GL_APICALL void GL_APIENTRY glValidateProgram (GLuint program); +GL_APICALL void GL_APIENTRY glVertexAttrib1f (GLuint index, GLfloat x); +GL_APICALL void GL_APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v); +GL_APICALL void GL_APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y); +GL_APICALL void GL_APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v); +GL_APICALL void GL_APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GL_APICALL void GL_APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v); +GL_APICALL void GL_APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GL_APICALL void GL_APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v); +GL_APICALL void GL_APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +GL_APICALL void GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height); +#endif +#endif /* GL_ES_VERSION_2_0 */ + +#ifdef __cplusplus +} +#endif + +#endif diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_opengles2_gl2ext.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_opengles2_gl2ext.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,4033 @@ +#ifndef __gles2_gl2ext_h_ +#define __gles2_gl2ext_h_ 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Copyright 2013-2020 The Khronos Group Inc. +** SPDX-License-Identifier: MIT +** +** This header is generated from the Khronos OpenGL / OpenGL ES XML +** API Registry. The current version of the Registry, generator scripts +** used to make the header, and the header can be found at +** https://github.com/KhronosGroup/OpenGL-Registry +*/ + +#ifndef GL_APIENTRYP +#define GL_APIENTRYP GL_APIENTRY* +#endif + +/* Generated on date 20220530 */ + +/* Generated C header for: + * API: gles2 + * Profile: common + * Versions considered: 2\.[0-9] + * Versions emitted: _nomatch_^ + * Default extensions included: gles2 + * Additional extensions included: _nomatch_^ + * Extensions removed: _nomatch_^ + */ + +#ifndef GL_KHR_blend_equation_advanced +#define GL_KHR_blend_equation_advanced 1 +#define GL_MULTIPLY_KHR 0x9294 +#define GL_SCREEN_KHR 0x9295 +#define GL_OVERLAY_KHR 0x9296 +#define GL_DARKEN_KHR 0x9297 +#define GL_LIGHTEN_KHR 0x9298 +#define GL_COLORDODGE_KHR 0x9299 +#define GL_COLORBURN_KHR 0x929A +#define GL_HARDLIGHT_KHR 0x929B +#define GL_SOFTLIGHT_KHR 0x929C +#define GL_DIFFERENCE_KHR 0x929E +#define GL_EXCLUSION_KHR 0x92A0 +#define GL_HSL_HUE_KHR 0x92AD +#define GL_HSL_SATURATION_KHR 0x92AE +#define GL_HSL_COLOR_KHR 0x92AF +#define GL_HSL_LUMINOSITY_KHR 0x92B0 +typedef void (GL_APIENTRYP PFNGLBLENDBARRIERKHRPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glBlendBarrierKHR (void); +#endif +#endif /* GL_KHR_blend_equation_advanced */ + +#ifndef GL_KHR_blend_equation_advanced_coherent +#define GL_KHR_blend_equation_advanced_coherent 1 +#define GL_BLEND_ADVANCED_COHERENT_KHR 0x9285 +#endif /* GL_KHR_blend_equation_advanced_coherent */ + +#ifndef GL_KHR_context_flush_control +#define GL_KHR_context_flush_control 1 +#define GL_CONTEXT_RELEASE_BEHAVIOR_KHR 0x82FB +#define GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR 0x82FC +#endif /* GL_KHR_context_flush_control */ + +#ifndef GL_KHR_debug +#define GL_KHR_debug 1 +typedef void (GL_APIENTRY *GLDEBUGPROCKHR)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); +#define GL_SAMPLER 0x82E6 +#define GL_DEBUG_OUTPUT_SYNCHRONOUS_KHR 0x8242 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_KHR 0x8243 +#define GL_DEBUG_CALLBACK_FUNCTION_KHR 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM_KHR 0x8245 +#define GL_DEBUG_SOURCE_API_KHR 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_KHR 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER_KHR 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY_KHR 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION_KHR 0x824A +#define GL_DEBUG_SOURCE_OTHER_KHR 0x824B +#define GL_DEBUG_TYPE_ERROR_KHR 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_KHR 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_KHR 0x824E +#define GL_DEBUG_TYPE_PORTABILITY_KHR 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE_KHR 0x8250 +#define GL_DEBUG_TYPE_OTHER_KHR 0x8251 +#define GL_DEBUG_TYPE_MARKER_KHR 0x8268 +#define GL_DEBUG_TYPE_PUSH_GROUP_KHR 0x8269 +#define GL_DEBUG_TYPE_POP_GROUP_KHR 0x826A +#define GL_DEBUG_SEVERITY_NOTIFICATION_KHR 0x826B +#define GL_MAX_DEBUG_GROUP_STACK_DEPTH_KHR 0x826C +#define GL_DEBUG_GROUP_STACK_DEPTH_KHR 0x826D +#define GL_BUFFER_KHR 0x82E0 +#define GL_SHADER_KHR 0x82E1 +#define GL_PROGRAM_KHR 0x82E2 +#define GL_VERTEX_ARRAY_KHR 0x8074 +#define GL_QUERY_KHR 0x82E3 +#define GL_PROGRAM_PIPELINE_KHR 0x82E4 +#define GL_SAMPLER_KHR 0x82E6 +#define GL_MAX_LABEL_LENGTH_KHR 0x82E8 +#define GL_MAX_DEBUG_MESSAGE_LENGTH_KHR 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES_KHR 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES_KHR 0x9145 +#define GL_DEBUG_SEVERITY_HIGH_KHR 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM_KHR 0x9147 +#define GL_DEBUG_SEVERITY_LOW_KHR 0x9148 +#define GL_DEBUG_OUTPUT_KHR 0x92E0 +#define GL_CONTEXT_FLAG_DEBUG_BIT_KHR 0x00000002 +#define GL_STACK_OVERFLOW_KHR 0x0503 +#define GL_STACK_UNDERFLOW_KHR 0x0504 +typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGECONTROLKHRPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGEINSERTKHRPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGECALLBACKKHRPROC) (GLDEBUGPROCKHR callback, const void *userParam); +typedef GLuint (GL_APIENTRYP PFNGLGETDEBUGMESSAGELOGKHRPROC) (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +typedef void (GL_APIENTRYP PFNGLPUSHDEBUGGROUPKHRPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message); +typedef void (GL_APIENTRYP PFNGLPOPDEBUGGROUPKHRPROC) (void); +typedef void (GL_APIENTRYP PFNGLOBJECTLABELKHRPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +typedef void (GL_APIENTRYP PFNGLGETOBJECTLABELKHRPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +typedef void (GL_APIENTRYP PFNGLOBJECTPTRLABELKHRPROC) (const void *ptr, GLsizei length, const GLchar *label); +typedef void (GL_APIENTRYP PFNGLGETOBJECTPTRLABELKHRPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +typedef void (GL_APIENTRYP PFNGLGETPOINTERVKHRPROC) (GLenum pname, void **params); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDebugMessageControlKHR (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GL_APICALL void GL_APIENTRY glDebugMessageInsertKHR (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +GL_APICALL void GL_APIENTRY glDebugMessageCallbackKHR (GLDEBUGPROCKHR callback, const void *userParam); +GL_APICALL GLuint GL_APIENTRY glGetDebugMessageLogKHR (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +GL_APICALL void GL_APIENTRY glPushDebugGroupKHR (GLenum source, GLuint id, GLsizei length, const GLchar *message); +GL_APICALL void GL_APIENTRY glPopDebugGroupKHR (void); +GL_APICALL void GL_APIENTRY glObjectLabelKHR (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +GL_APICALL void GL_APIENTRY glGetObjectLabelKHR (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +GL_APICALL void GL_APIENTRY glObjectPtrLabelKHR (const void *ptr, GLsizei length, const GLchar *label); +GL_APICALL void GL_APIENTRY glGetObjectPtrLabelKHR (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +GL_APICALL void GL_APIENTRY glGetPointervKHR (GLenum pname, void **params); +#endif +#endif /* GL_KHR_debug */ + +#ifndef GL_KHR_no_error +#define GL_KHR_no_error 1 +#define GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR 0x00000008 +#endif /* GL_KHR_no_error */ + +#ifndef GL_KHR_parallel_shader_compile +#define GL_KHR_parallel_shader_compile 1 +#define GL_MAX_SHADER_COMPILER_THREADS_KHR 0x91B0 +#define GL_COMPLETION_STATUS_KHR 0x91B1 +typedef void (GL_APIENTRYP PFNGLMAXSHADERCOMPILERTHREADSKHRPROC) (GLuint count); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glMaxShaderCompilerThreadsKHR (GLuint count); +#endif +#endif /* GL_KHR_parallel_shader_compile */ + +#ifndef GL_KHR_robust_buffer_access_behavior +#define GL_KHR_robust_buffer_access_behavior 1 +#endif /* GL_KHR_robust_buffer_access_behavior */ + +#ifndef GL_KHR_robustness +#define GL_KHR_robustness 1 +#define GL_CONTEXT_ROBUST_ACCESS_KHR 0x90F3 +#define GL_LOSE_CONTEXT_ON_RESET_KHR 0x8252 +#define GL_GUILTY_CONTEXT_RESET_KHR 0x8253 +#define GL_INNOCENT_CONTEXT_RESET_KHR 0x8254 +#define GL_UNKNOWN_CONTEXT_RESET_KHR 0x8255 +#define GL_RESET_NOTIFICATION_STRATEGY_KHR 0x8256 +#define GL_NO_RESET_NOTIFICATION_KHR 0x8261 +#define GL_CONTEXT_LOST_KHR 0x0507 +typedef GLenum (GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSKHRPROC) (void); +typedef void (GL_APIENTRYP PFNGLREADNPIXELSKHRPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); +typedef void (GL_APIENTRYP PFNGLGETNUNIFORMFVKHRPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +typedef void (GL_APIENTRYP PFNGLGETNUNIFORMIVKHRPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETNUNIFORMUIVKHRPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL GLenum GL_APIENTRY glGetGraphicsResetStatusKHR (void); +GL_APICALL void GL_APIENTRY glReadnPixelsKHR (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); +GL_APICALL void GL_APIENTRY glGetnUniformfvKHR (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +GL_APICALL void GL_APIENTRY glGetnUniformivKHR (GLuint program, GLint location, GLsizei bufSize, GLint *params); +GL_APICALL void GL_APIENTRY glGetnUniformuivKHR (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +#endif +#endif /* GL_KHR_robustness */ + +#ifndef GL_KHR_shader_subgroup +#define GL_KHR_shader_subgroup 1 +#define GL_SUBGROUP_SIZE_KHR 0x9532 +#define GL_SUBGROUP_SUPPORTED_STAGES_KHR 0x9533 +#define GL_SUBGROUP_SUPPORTED_FEATURES_KHR 0x9534 +#define GL_SUBGROUP_QUAD_ALL_STAGES_KHR 0x9535 +#define GL_SUBGROUP_FEATURE_BASIC_BIT_KHR 0x00000001 +#define GL_SUBGROUP_FEATURE_VOTE_BIT_KHR 0x00000002 +#define GL_SUBGROUP_FEATURE_ARITHMETIC_BIT_KHR 0x00000004 +#define GL_SUBGROUP_FEATURE_BALLOT_BIT_KHR 0x00000008 +#define GL_SUBGROUP_FEATURE_SHUFFLE_BIT_KHR 0x00000010 +#define GL_SUBGROUP_FEATURE_SHUFFLE_RELATIVE_BIT_KHR 0x00000020 +#define GL_SUBGROUP_FEATURE_CLUSTERED_BIT_KHR 0x00000040 +#define GL_SUBGROUP_FEATURE_QUAD_BIT_KHR 0x00000080 +#endif /* GL_KHR_shader_subgroup */ + +#ifndef GL_KHR_texture_compression_astc_hdr +#define GL_KHR_texture_compression_astc_hdr 1 +#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 +#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 +#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 +#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 +#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 +#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 +#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 +#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 +#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 +#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 +#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA +#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB +#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC +#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD +#endif /* GL_KHR_texture_compression_astc_hdr */ + +#ifndef GL_KHR_texture_compression_astc_ldr +#define GL_KHR_texture_compression_astc_ldr 1 +#endif /* GL_KHR_texture_compression_astc_ldr */ + +#ifndef GL_KHR_texture_compression_astc_sliced_3d +#define GL_KHR_texture_compression_astc_sliced_3d 1 +#endif /* GL_KHR_texture_compression_astc_sliced_3d */ + +#ifndef GL_OES_EGL_image +#define GL_OES_EGL_image 1 +typedef void *GLeglImageOES; +typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, GLeglImageOES image); +typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLeglImageOES image); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glEGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image); +GL_APICALL void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES (GLenum target, GLeglImageOES image); +#endif +#endif /* GL_OES_EGL_image */ + +#ifndef GL_OES_EGL_image_external +#define GL_OES_EGL_image_external 1 +#define GL_TEXTURE_EXTERNAL_OES 0x8D65 +#define GL_TEXTURE_BINDING_EXTERNAL_OES 0x8D67 +#define GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES 0x8D68 +#define GL_SAMPLER_EXTERNAL_OES 0x8D66 +#endif /* GL_OES_EGL_image_external */ + +#ifndef GL_OES_EGL_image_external_essl3 +#define GL_OES_EGL_image_external_essl3 1 +#endif /* GL_OES_EGL_image_external_essl3 */ + +#ifndef GL_OES_compressed_ETC1_RGB8_sub_texture +#define GL_OES_compressed_ETC1_RGB8_sub_texture 1 +#endif /* GL_OES_compressed_ETC1_RGB8_sub_texture */ + +#ifndef GL_OES_compressed_ETC1_RGB8_texture +#define GL_OES_compressed_ETC1_RGB8_texture 1 +#define GL_ETC1_RGB8_OES 0x8D64 +#endif /* GL_OES_compressed_ETC1_RGB8_texture */ + +#ifndef GL_OES_compressed_paletted_texture +#define GL_OES_compressed_paletted_texture 1 +#define GL_PALETTE4_RGB8_OES 0x8B90 +#define GL_PALETTE4_RGBA8_OES 0x8B91 +#define GL_PALETTE4_R5_G6_B5_OES 0x8B92 +#define GL_PALETTE4_RGBA4_OES 0x8B93 +#define GL_PALETTE4_RGB5_A1_OES 0x8B94 +#define GL_PALETTE8_RGB8_OES 0x8B95 +#define GL_PALETTE8_RGBA8_OES 0x8B96 +#define GL_PALETTE8_R5_G6_B5_OES 0x8B97 +#define GL_PALETTE8_RGBA4_OES 0x8B98 +#define GL_PALETTE8_RGB5_A1_OES 0x8B99 +#endif /* GL_OES_compressed_paletted_texture */ + +#ifndef GL_OES_copy_image +#define GL_OES_copy_image 1 +typedef void (GL_APIENTRYP PFNGLCOPYIMAGESUBDATAOESPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glCopyImageSubDataOES (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +#endif +#endif /* GL_OES_copy_image */ + +#ifndef GL_OES_depth24 +#define GL_OES_depth24 1 +#define GL_DEPTH_COMPONENT24_OES 0x81A6 +#endif /* GL_OES_depth24 */ + +#ifndef GL_OES_depth32 +#define GL_OES_depth32 1 +#define GL_DEPTH_COMPONENT32_OES 0x81A7 +#endif /* GL_OES_depth32 */ + +#ifndef GL_OES_depth_texture +#define GL_OES_depth_texture 1 +#endif /* GL_OES_depth_texture */ + +#ifndef GL_OES_draw_buffers_indexed +#define GL_OES_draw_buffers_indexed 1 +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +typedef void (GL_APIENTRYP PFNGLENABLEIOESPROC) (GLenum target, GLuint index); +typedef void (GL_APIENTRYP PFNGLDISABLEIOESPROC) (GLenum target, GLuint index); +typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONIOESPROC) (GLuint buf, GLenum mode); +typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONSEPARATEIOESPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +typedef void (GL_APIENTRYP PFNGLBLENDFUNCIOESPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (GL_APIENTRYP PFNGLBLENDFUNCSEPARATEIOESPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +typedef void (GL_APIENTRYP PFNGLCOLORMASKIOESPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +typedef GLboolean (GL_APIENTRYP PFNGLISENABLEDIOESPROC) (GLenum target, GLuint index); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glEnableiOES (GLenum target, GLuint index); +GL_APICALL void GL_APIENTRY glDisableiOES (GLenum target, GLuint index); +GL_APICALL void GL_APIENTRY glBlendEquationiOES (GLuint buf, GLenum mode); +GL_APICALL void GL_APIENTRY glBlendEquationSeparateiOES (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +GL_APICALL void GL_APIENTRY glBlendFunciOES (GLuint buf, GLenum src, GLenum dst); +GL_APICALL void GL_APIENTRY glBlendFuncSeparateiOES (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +GL_APICALL void GL_APIENTRY glColorMaskiOES (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +GL_APICALL GLboolean GL_APIENTRY glIsEnablediOES (GLenum target, GLuint index); +#endif +#endif /* GL_OES_draw_buffers_indexed */ + +#ifndef GL_OES_draw_elements_base_vertex +#define GL_OES_draw_elements_base_vertex 1 +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXOESPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); +typedef void (GL_APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXOESPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXOESPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); +typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount, const GLint *basevertex); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawElementsBaseVertexOES (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); +GL_APICALL void GL_APIENTRY glDrawRangeElementsBaseVertexOES (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); +GL_APICALL void GL_APIENTRY glDrawElementsInstancedBaseVertexOES (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); +GL_APICALL void GL_APIENTRY glMultiDrawElementsBaseVertexEXT (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount, const GLint *basevertex); +#endif +#endif /* GL_OES_draw_elements_base_vertex */ + +#ifndef GL_OES_element_index_uint +#define GL_OES_element_index_uint 1 +#endif /* GL_OES_element_index_uint */ + +#ifndef GL_OES_fbo_render_mipmap +#define GL_OES_fbo_render_mipmap 1 +#endif /* GL_OES_fbo_render_mipmap */ + +#ifndef GL_OES_fragment_precision_high +#define GL_OES_fragment_precision_high 1 +#endif /* GL_OES_fragment_precision_high */ + +#ifndef GL_OES_geometry_point_size +#define GL_OES_geometry_point_size 1 +#endif /* GL_OES_geometry_point_size */ + +#ifndef GL_OES_geometry_shader +#define GL_OES_geometry_shader 1 +#define GL_GEOMETRY_SHADER_OES 0x8DD9 +#define GL_GEOMETRY_SHADER_BIT_OES 0x00000004 +#define GL_GEOMETRY_LINKED_VERTICES_OUT_OES 0x8916 +#define GL_GEOMETRY_LINKED_INPUT_TYPE_OES 0x8917 +#define GL_GEOMETRY_LINKED_OUTPUT_TYPE_OES 0x8918 +#define GL_GEOMETRY_SHADER_INVOCATIONS_OES 0x887F +#define GL_LAYER_PROVOKING_VERTEX_OES 0x825E +#define GL_LINES_ADJACENCY_OES 0x000A +#define GL_LINE_STRIP_ADJACENCY_OES 0x000B +#define GL_TRIANGLES_ADJACENCY_OES 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_OES 0x000D +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_OES 0x8DDF +#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS_OES 0x8A2C +#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS_OES 0x8A32 +#define GL_MAX_GEOMETRY_INPUT_COMPONENTS_OES 0x9123 +#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS_OES 0x9124 +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_OES 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_OES 0x8DE1 +#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS_OES 0x8E5A +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_OES 0x8C29 +#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS_OES 0x92CF +#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS_OES 0x92D5 +#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS_OES 0x90CD +#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS_OES 0x90D7 +#define GL_FIRST_VERTEX_CONVENTION_OES 0x8E4D +#define GL_LAST_VERTEX_CONVENTION_OES 0x8E4E +#define GL_UNDEFINED_VERTEX_OES 0x8260 +#define GL_PRIMITIVES_GENERATED_OES 0x8C87 +#define GL_FRAMEBUFFER_DEFAULT_LAYERS_OES 0x9312 +#define GL_MAX_FRAMEBUFFER_LAYERS_OES 0x9317 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_OES 0x8DA8 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_OES 0x8DA7 +#define GL_REFERENCED_BY_GEOMETRY_SHADER_OES 0x9309 +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTUREOESPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glFramebufferTextureOES (GLenum target, GLenum attachment, GLuint texture, GLint level); +#endif +#endif /* GL_OES_geometry_shader */ + +#ifndef GL_OES_get_program_binary +#define GL_OES_get_program_binary 1 +#define GL_PROGRAM_BINARY_LENGTH_OES 0x8741 +#define GL_NUM_PROGRAM_BINARY_FORMATS_OES 0x87FE +#define GL_PROGRAM_BINARY_FORMATS_OES 0x87FF +typedef void (GL_APIENTRYP PFNGLGETPROGRAMBINARYOESPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); +typedef void (GL_APIENTRYP PFNGLPROGRAMBINARYOESPROC) (GLuint program, GLenum binaryFormat, const void *binary, GLint length); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGetProgramBinaryOES (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); +GL_APICALL void GL_APIENTRY glProgramBinaryOES (GLuint program, GLenum binaryFormat, const void *binary, GLint length); +#endif +#endif /* GL_OES_get_program_binary */ + +#ifndef GL_OES_gpu_shader5 +#define GL_OES_gpu_shader5 1 +#endif /* GL_OES_gpu_shader5 */ + +#ifndef GL_OES_mapbuffer +#define GL_OES_mapbuffer 1 +#define GL_WRITE_ONLY_OES 0x88B9 +#define GL_BUFFER_ACCESS_OES 0x88BB +#define GL_BUFFER_MAPPED_OES 0x88BC +#define GL_BUFFER_MAP_POINTER_OES 0x88BD +typedef void *(GL_APIENTRYP PFNGLMAPBUFFEROESPROC) (GLenum target, GLenum access); +typedef GLboolean (GL_APIENTRYP PFNGLUNMAPBUFFEROESPROC) (GLenum target); +typedef void (GL_APIENTRYP PFNGLGETBUFFERPOINTERVOESPROC) (GLenum target, GLenum pname, void **params); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void *GL_APIENTRY glMapBufferOES (GLenum target, GLenum access); +GL_APICALL GLboolean GL_APIENTRY glUnmapBufferOES (GLenum target); +GL_APICALL void GL_APIENTRY glGetBufferPointervOES (GLenum target, GLenum pname, void **params); +#endif +#endif /* GL_OES_mapbuffer */ + +#ifndef GL_OES_packed_depth_stencil +#define GL_OES_packed_depth_stencil 1 +#define GL_DEPTH_STENCIL_OES 0x84F9 +#define GL_UNSIGNED_INT_24_8_OES 0x84FA +#define GL_DEPTH24_STENCIL8_OES 0x88F0 +#endif /* GL_OES_packed_depth_stencil */ + +#ifndef GL_OES_primitive_bounding_box +#define GL_OES_primitive_bounding_box 1 +#define GL_PRIMITIVE_BOUNDING_BOX_OES 0x92BE +typedef void (GL_APIENTRYP PFNGLPRIMITIVEBOUNDINGBOXOESPROC) (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glPrimitiveBoundingBoxOES (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW); +#endif +#endif /* GL_OES_primitive_bounding_box */ + +#ifndef GL_OES_required_internalformat +#define GL_OES_required_internalformat 1 +#define GL_ALPHA8_OES 0x803C +#define GL_DEPTH_COMPONENT16_OES 0x81A5 +#define GL_LUMINANCE4_ALPHA4_OES 0x8043 +#define GL_LUMINANCE8_ALPHA8_OES 0x8045 +#define GL_LUMINANCE8_OES 0x8040 +#define GL_RGBA4_OES 0x8056 +#define GL_RGB5_A1_OES 0x8057 +#define GL_RGB565_OES 0x8D62 +#define GL_RGB8_OES 0x8051 +#define GL_RGBA8_OES 0x8058 +#define GL_RGB10_EXT 0x8052 +#define GL_RGB10_A2_EXT 0x8059 +#endif /* GL_OES_required_internalformat */ + +#ifndef GL_OES_rgb8_rgba8 +#define GL_OES_rgb8_rgba8 1 +#endif /* GL_OES_rgb8_rgba8 */ + +#ifndef GL_OES_sample_shading +#define GL_OES_sample_shading 1 +#define GL_SAMPLE_SHADING_OES 0x8C36 +#define GL_MIN_SAMPLE_SHADING_VALUE_OES 0x8C37 +typedef void (GL_APIENTRYP PFNGLMINSAMPLESHADINGOESPROC) (GLfloat value); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glMinSampleShadingOES (GLfloat value); +#endif +#endif /* GL_OES_sample_shading */ + +#ifndef GL_OES_sample_variables +#define GL_OES_sample_variables 1 +#endif /* GL_OES_sample_variables */ + +#ifndef GL_OES_shader_image_atomic +#define GL_OES_shader_image_atomic 1 +#endif /* GL_OES_shader_image_atomic */ + +#ifndef GL_OES_shader_io_blocks +#define GL_OES_shader_io_blocks 1 +#endif /* GL_OES_shader_io_blocks */ + +#ifndef GL_OES_shader_multisample_interpolation +#define GL_OES_shader_multisample_interpolation 1 +#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_OES 0x8E5B +#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_OES 0x8E5C +#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS_OES 0x8E5D +#endif /* GL_OES_shader_multisample_interpolation */ + +#ifndef GL_OES_standard_derivatives +#define GL_OES_standard_derivatives 1 +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES 0x8B8B +#endif /* GL_OES_standard_derivatives */ + +#ifndef GL_OES_stencil1 +#define GL_OES_stencil1 1 +#define GL_STENCIL_INDEX1_OES 0x8D46 +#endif /* GL_OES_stencil1 */ + +#ifndef GL_OES_stencil4 +#define GL_OES_stencil4 1 +#define GL_STENCIL_INDEX4_OES 0x8D47 +#endif /* GL_OES_stencil4 */ + +#ifndef GL_OES_surfaceless_context +#define GL_OES_surfaceless_context 1 +#define GL_FRAMEBUFFER_UNDEFINED_OES 0x8219 +#endif /* GL_OES_surfaceless_context */ + +#ifndef GL_OES_tessellation_point_size +#define GL_OES_tessellation_point_size 1 +#endif /* GL_OES_tessellation_point_size */ + +#ifndef GL_OES_tessellation_shader +#define GL_OES_tessellation_shader 1 +#define GL_PATCHES_OES 0x000E +#define GL_PATCH_VERTICES_OES 0x8E72 +#define GL_TESS_CONTROL_OUTPUT_VERTICES_OES 0x8E75 +#define GL_TESS_GEN_MODE_OES 0x8E76 +#define GL_TESS_GEN_SPACING_OES 0x8E77 +#define GL_TESS_GEN_VERTEX_ORDER_OES 0x8E78 +#define GL_TESS_GEN_POINT_MODE_OES 0x8E79 +#define GL_ISOLINES_OES 0x8E7A +#define GL_QUADS_OES 0x0007 +#define GL_FRACTIONAL_ODD_OES 0x8E7B +#define GL_FRACTIONAL_EVEN_OES 0x8E7C +#define GL_MAX_PATCH_VERTICES_OES 0x8E7D +#define GL_MAX_TESS_GEN_LEVEL_OES 0x8E7E +#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS_OES 0x8E7F +#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS_OES 0x8E80 +#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS_OES 0x8E81 +#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS_OES 0x8E82 +#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS_OES 0x8E83 +#define GL_MAX_TESS_PATCH_COMPONENTS_OES 0x8E84 +#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS_OES 0x8E85 +#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS_OES 0x8E86 +#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS_OES 0x8E89 +#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS_OES 0x8E8A +#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS_OES 0x886C +#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS_OES 0x886D +#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS_OES 0x8E1E +#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS_OES 0x8E1F +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS_OES 0x92CD +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS_OES 0x92CE +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS_OES 0x92D3 +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS_OES 0x92D4 +#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS_OES 0x90CB +#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS_OES 0x90CC +#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS_OES 0x90D8 +#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS_OES 0x90D9 +#define GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED_OES 0x8221 +#define GL_IS_PER_PATCH_OES 0x92E7 +#define GL_REFERENCED_BY_TESS_CONTROL_SHADER_OES 0x9307 +#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER_OES 0x9308 +#define GL_TESS_CONTROL_SHADER_OES 0x8E88 +#define GL_TESS_EVALUATION_SHADER_OES 0x8E87 +#define GL_TESS_CONTROL_SHADER_BIT_OES 0x00000008 +#define GL_TESS_EVALUATION_SHADER_BIT_OES 0x00000010 +typedef void (GL_APIENTRYP PFNGLPATCHPARAMETERIOESPROC) (GLenum pname, GLint value); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glPatchParameteriOES (GLenum pname, GLint value); +#endif +#endif /* GL_OES_tessellation_shader */ + +#ifndef GL_OES_texture_3D +#define GL_OES_texture_3D 1 +#define GL_TEXTURE_WRAP_R_OES 0x8072 +#define GL_TEXTURE_3D_OES 0x806F +#define GL_TEXTURE_BINDING_3D_OES 0x806A +#define GL_MAX_3D_TEXTURE_SIZE_OES 0x8073 +#define GL_SAMPLER_3D_OES 0x8B5F +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES 0x8CD4 +typedef void (GL_APIENTRYP PFNGLTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (GL_APIENTRYP PFNGLTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +typedef void (GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DOESPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glTexImage3DOES (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +GL_APICALL void GL_APIENTRY glTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +GL_APICALL void GL_APIENTRY glCopyTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glCompressedTexImage3DOES (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +GL_APICALL void GL_APIENTRY glCompressedTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +GL_APICALL void GL_APIENTRY glFramebufferTexture3DOES (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +#endif +#endif /* GL_OES_texture_3D */ + +#ifndef GL_OES_texture_border_clamp +#define GL_OES_texture_border_clamp 1 +#define GL_TEXTURE_BORDER_COLOR_OES 0x1004 +#define GL_CLAMP_TO_BORDER_OES 0x812D +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIIVOESPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIUIVOESPROC) (GLenum target, GLenum pname, const GLuint *params); +typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERIIVOESPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERIUIVOESPROC) (GLenum target, GLenum pname, GLuint *params); +typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERIIVOESPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERIUIVOESPROC) (GLuint sampler, GLenum pname, const GLuint *param); +typedef void (GL_APIENTRYP PFNGLGETSAMPLERPARAMETERIIVOESPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVOESPROC) (GLuint sampler, GLenum pname, GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glTexParameterIivOES (GLenum target, GLenum pname, const GLint *params); +GL_APICALL void GL_APIENTRY glTexParameterIuivOES (GLenum target, GLenum pname, const GLuint *params); +GL_APICALL void GL_APIENTRY glGetTexParameterIivOES (GLenum target, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetTexParameterIuivOES (GLenum target, GLenum pname, GLuint *params); +GL_APICALL void GL_APIENTRY glSamplerParameterIivOES (GLuint sampler, GLenum pname, const GLint *param); +GL_APICALL void GL_APIENTRY glSamplerParameterIuivOES (GLuint sampler, GLenum pname, const GLuint *param); +GL_APICALL void GL_APIENTRY glGetSamplerParameterIivOES (GLuint sampler, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetSamplerParameterIuivOES (GLuint sampler, GLenum pname, GLuint *params); +#endif +#endif /* GL_OES_texture_border_clamp */ + +#ifndef GL_OES_texture_buffer +#define GL_OES_texture_buffer 1 +#define GL_TEXTURE_BUFFER_OES 0x8C2A +#define GL_TEXTURE_BUFFER_BINDING_OES 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_OES 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_OES 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_OES 0x8C2D +#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT_OES 0x919F +#define GL_SAMPLER_BUFFER_OES 0x8DC2 +#define GL_INT_SAMPLER_BUFFER_OES 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER_OES 0x8DD8 +#define GL_IMAGE_BUFFER_OES 0x9051 +#define GL_INT_IMAGE_BUFFER_OES 0x905C +#define GL_UNSIGNED_INT_IMAGE_BUFFER_OES 0x9067 +#define GL_TEXTURE_BUFFER_OFFSET_OES 0x919D +#define GL_TEXTURE_BUFFER_SIZE_OES 0x919E +typedef void (GL_APIENTRYP PFNGLTEXBUFFEROESPROC) (GLenum target, GLenum internalformat, GLuint buffer); +typedef void (GL_APIENTRYP PFNGLTEXBUFFERRANGEOESPROC) (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glTexBufferOES (GLenum target, GLenum internalformat, GLuint buffer); +GL_APICALL void GL_APIENTRY glTexBufferRangeOES (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +#endif +#endif /* GL_OES_texture_buffer */ + +#ifndef GL_OES_texture_compression_astc +#define GL_OES_texture_compression_astc 1 +#define GL_COMPRESSED_RGBA_ASTC_3x3x3_OES 0x93C0 +#define GL_COMPRESSED_RGBA_ASTC_4x3x3_OES 0x93C1 +#define GL_COMPRESSED_RGBA_ASTC_4x4x3_OES 0x93C2 +#define GL_COMPRESSED_RGBA_ASTC_4x4x4_OES 0x93C3 +#define GL_COMPRESSED_RGBA_ASTC_5x4x4_OES 0x93C4 +#define GL_COMPRESSED_RGBA_ASTC_5x5x4_OES 0x93C5 +#define GL_COMPRESSED_RGBA_ASTC_5x5x5_OES 0x93C6 +#define GL_COMPRESSED_RGBA_ASTC_6x5x5_OES 0x93C7 +#define GL_COMPRESSED_RGBA_ASTC_6x6x5_OES 0x93C8 +#define GL_COMPRESSED_RGBA_ASTC_6x6x6_OES 0x93C9 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES 0x93E0 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x3x3_OES 0x93E1 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x3_OES 0x93E2 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x4_OES 0x93E3 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4x4_OES 0x93E4 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x4_OES 0x93E5 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x5_OES 0x93E6 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5x5_OES 0x93E7 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5_OES 0x93E8 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES 0x93E9 +#endif /* GL_OES_texture_compression_astc */ + +#ifndef GL_OES_texture_cube_map_array +#define GL_OES_texture_cube_map_array 1 +#define GL_TEXTURE_CUBE_MAP_ARRAY_OES 0x9009 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_OES 0x900A +#define GL_SAMPLER_CUBE_MAP_ARRAY_OES 0x900C +#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_OES 0x900D +#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_OES 0x900E +#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_OES 0x900F +#define GL_IMAGE_CUBE_MAP_ARRAY_OES 0x9054 +#define GL_INT_IMAGE_CUBE_MAP_ARRAY_OES 0x905F +#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_OES 0x906A +#endif /* GL_OES_texture_cube_map_array */ + +#ifndef GL_OES_texture_float +#define GL_OES_texture_float 1 +#endif /* GL_OES_texture_float */ + +#ifndef GL_OES_texture_float_linear +#define GL_OES_texture_float_linear 1 +#endif /* GL_OES_texture_float_linear */ + +#ifndef GL_OES_texture_half_float +#define GL_OES_texture_half_float 1 +#define GL_HALF_FLOAT_OES 0x8D61 +#endif /* GL_OES_texture_half_float */ + +#ifndef GL_OES_texture_half_float_linear +#define GL_OES_texture_half_float_linear 1 +#endif /* GL_OES_texture_half_float_linear */ + +#ifndef GL_OES_texture_npot +#define GL_OES_texture_npot 1 +#endif /* GL_OES_texture_npot */ + +#ifndef GL_OES_texture_stencil8 +#define GL_OES_texture_stencil8 1 +#define GL_STENCIL_INDEX_OES 0x1901 +#define GL_STENCIL_INDEX8_OES 0x8D48 +#endif /* GL_OES_texture_stencil8 */ + +#ifndef GL_OES_texture_storage_multisample_2d_array +#define GL_OES_texture_storage_multisample_2d_array 1 +#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES 0x9102 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY_OES 0x9105 +#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY_OES 0x910B +#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY_OES 0x910C +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY_OES 0x910D +typedef void (GL_APIENTRYP PFNGLTEXSTORAGE3DMULTISAMPLEOESPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glTexStorage3DMultisampleOES (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +#endif +#endif /* GL_OES_texture_storage_multisample_2d_array */ + +#ifndef GL_OES_texture_view +#define GL_OES_texture_view 1 +#define GL_TEXTURE_VIEW_MIN_LEVEL_OES 0x82DB +#define GL_TEXTURE_VIEW_NUM_LEVELS_OES 0x82DC +#define GL_TEXTURE_VIEW_MIN_LAYER_OES 0x82DD +#define GL_TEXTURE_VIEW_NUM_LAYERS_OES 0x82DE +#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF +typedef void (GL_APIENTRYP PFNGLTEXTUREVIEWOESPROC) (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glTextureViewOES (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); +#endif +#endif /* GL_OES_texture_view */ + +#ifndef GL_OES_vertex_array_object +#define GL_OES_vertex_array_object 1 +#define GL_VERTEX_ARRAY_BINDING_OES 0x85B5 +typedef void (GL_APIENTRYP PFNGLBINDVERTEXARRAYOESPROC) (GLuint array); +typedef void (GL_APIENTRYP PFNGLDELETEVERTEXARRAYSOESPROC) (GLsizei n, const GLuint *arrays); +typedef void (GL_APIENTRYP PFNGLGENVERTEXARRAYSOESPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (GL_APIENTRYP PFNGLISVERTEXARRAYOESPROC) (GLuint array); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glBindVertexArrayOES (GLuint array); +GL_APICALL void GL_APIENTRY glDeleteVertexArraysOES (GLsizei n, const GLuint *arrays); +GL_APICALL void GL_APIENTRY glGenVertexArraysOES (GLsizei n, GLuint *arrays); +GL_APICALL GLboolean GL_APIENTRY glIsVertexArrayOES (GLuint array); +#endif +#endif /* GL_OES_vertex_array_object */ + +#ifndef GL_OES_vertex_half_float +#define GL_OES_vertex_half_float 1 +#endif /* GL_OES_vertex_half_float */ + +#ifndef GL_OES_vertex_type_10_10_10_2 +#define GL_OES_vertex_type_10_10_10_2 1 +#define GL_UNSIGNED_INT_10_10_10_2_OES 0x8DF6 +#define GL_INT_10_10_10_2_OES 0x8DF7 +#endif /* GL_OES_vertex_type_10_10_10_2 */ + +#ifndef GL_OES_viewport_array +#define GL_OES_viewport_array 1 +#define GL_MAX_VIEWPORTS_OES 0x825B +#define GL_VIEWPORT_SUBPIXEL_BITS_OES 0x825C +#define GL_VIEWPORT_BOUNDS_RANGE_OES 0x825D +#define GL_VIEWPORT_INDEX_PROVOKING_VERTEX_OES 0x825F +typedef void (GL_APIENTRYP PFNGLVIEWPORTARRAYVOESPROC) (GLuint first, GLsizei count, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLVIEWPORTINDEXEDFOESPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +typedef void (GL_APIENTRYP PFNGLVIEWPORTINDEXEDFVOESPROC) (GLuint index, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLSCISSORARRAYVOESPROC) (GLuint first, GLsizei count, const GLint *v); +typedef void (GL_APIENTRYP PFNGLSCISSORINDEXEDOESPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLSCISSORINDEXEDVOESPROC) (GLuint index, const GLint *v); +typedef void (GL_APIENTRYP PFNGLDEPTHRANGEARRAYFVOESPROC) (GLuint first, GLsizei count, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLDEPTHRANGEINDEXEDFOESPROC) (GLuint index, GLfloat n, GLfloat f); +typedef void (GL_APIENTRYP PFNGLGETFLOATI_VOESPROC) (GLenum target, GLuint index, GLfloat *data); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glViewportArrayvOES (GLuint first, GLsizei count, const GLfloat *v); +GL_APICALL void GL_APIENTRY glViewportIndexedfOES (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +GL_APICALL void GL_APIENTRY glViewportIndexedfvOES (GLuint index, const GLfloat *v); +GL_APICALL void GL_APIENTRY glScissorArrayvOES (GLuint first, GLsizei count, const GLint *v); +GL_APICALL void GL_APIENTRY glScissorIndexedOES (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glScissorIndexedvOES (GLuint index, const GLint *v); +GL_APICALL void GL_APIENTRY glDepthRangeArrayfvOES (GLuint first, GLsizei count, const GLfloat *v); +GL_APICALL void GL_APIENTRY glDepthRangeIndexedfOES (GLuint index, GLfloat n, GLfloat f); +GL_APICALL void GL_APIENTRY glGetFloati_vOES (GLenum target, GLuint index, GLfloat *data); +#endif +#endif /* GL_OES_viewport_array */ + +#ifndef GL_AMD_compressed_3DC_texture +#define GL_AMD_compressed_3DC_texture 1 +#define GL_3DC_X_AMD 0x87F9 +#define GL_3DC_XY_AMD 0x87FA +#endif /* GL_AMD_compressed_3DC_texture */ + +#ifndef GL_AMD_compressed_ATC_texture +#define GL_AMD_compressed_ATC_texture 1 +#define GL_ATC_RGB_AMD 0x8C92 +#define GL_ATC_RGBA_EXPLICIT_ALPHA_AMD 0x8C93 +#define GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD 0x87EE +#endif /* GL_AMD_compressed_ATC_texture */ + +#ifndef GL_AMD_framebuffer_multisample_advanced +#define GL_AMD_framebuffer_multisample_advanced 1 +#define GL_RENDERBUFFER_STORAGE_SAMPLES_AMD 0x91B2 +#define GL_MAX_COLOR_FRAMEBUFFER_SAMPLES_AMD 0x91B3 +#define GL_MAX_COLOR_FRAMEBUFFER_STORAGE_SAMPLES_AMD 0x91B4 +#define GL_MAX_DEPTH_STENCIL_FRAMEBUFFER_SAMPLES_AMD 0x91B5 +#define GL_NUM_SUPPORTED_MULTISAMPLE_MODES_AMD 0x91B6 +#define GL_SUPPORTED_MULTISAMPLE_MODES_AMD 0x91B7 +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEADVANCEDAMDPROC) (GLenum target, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEADVANCEDAMDPROC) (GLuint renderbuffer, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleAdvancedAMD (GLenum target, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glNamedRenderbufferStorageMultisampleAdvancedAMD (GLuint renderbuffer, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); +#endif +#endif /* GL_AMD_framebuffer_multisample_advanced */ + +#ifndef GL_AMD_performance_monitor +#define GL_AMD_performance_monitor 1 +#define GL_COUNTER_TYPE_AMD 0x8BC0 +#define GL_COUNTER_RANGE_AMD 0x8BC1 +#define GL_UNSIGNED_INT64_AMD 0x8BC2 +#define GL_PERCENTAGE_AMD 0x8BC3 +#define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4 +#define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5 +#define GL_PERFMON_RESULT_AMD 0x8BC6 +typedef void (GL_APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups); +typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); +typedef void (GL_APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); +typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); +typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, void *data); +typedef void (GL_APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); +typedef void (GL_APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); +typedef void (GL_APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); +typedef void (GL_APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor); +typedef void (GL_APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor); +typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGetPerfMonitorGroupsAMD (GLint *numGroups, GLsizei groupsSize, GLuint *groups); +GL_APICALL void GL_APIENTRY glGetPerfMonitorCountersAMD (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); +GL_APICALL void GL_APIENTRY glGetPerfMonitorGroupStringAMD (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); +GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterStringAMD (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); +GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, void *data); +GL_APICALL void GL_APIENTRY glGenPerfMonitorsAMD (GLsizei n, GLuint *monitors); +GL_APICALL void GL_APIENTRY glDeletePerfMonitorsAMD (GLsizei n, GLuint *monitors); +GL_APICALL void GL_APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); +GL_APICALL void GL_APIENTRY glBeginPerfMonitorAMD (GLuint monitor); +GL_APICALL void GL_APIENTRY glEndPerfMonitorAMD (GLuint monitor); +GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); +#endif +#endif /* GL_AMD_performance_monitor */ + +#ifndef GL_AMD_program_binary_Z400 +#define GL_AMD_program_binary_Z400 1 +#define GL_Z400_BINARY_AMD 0x8740 +#endif /* GL_AMD_program_binary_Z400 */ + +#ifndef GL_ANDROID_extension_pack_es31a +#define GL_ANDROID_extension_pack_es31a 1 +#endif /* GL_ANDROID_extension_pack_es31a */ + +#ifndef GL_ANGLE_depth_texture +#define GL_ANGLE_depth_texture 1 +#endif /* GL_ANGLE_depth_texture */ + +#ifndef GL_ANGLE_framebuffer_blit +#define GL_ANGLE_framebuffer_blit 1 +#define GL_READ_FRAMEBUFFER_ANGLE 0x8CA8 +#define GL_DRAW_FRAMEBUFFER_ANGLE 0x8CA9 +#define GL_DRAW_FRAMEBUFFER_BINDING_ANGLE 0x8CA6 +#define GL_READ_FRAMEBUFFER_BINDING_ANGLE 0x8CAA +typedef void (GL_APIENTRYP PFNGLBLITFRAMEBUFFERANGLEPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glBlitFramebufferANGLE (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif +#endif /* GL_ANGLE_framebuffer_blit */ + +#ifndef GL_ANGLE_framebuffer_multisample +#define GL_ANGLE_framebuffer_multisample 1 +#define GL_RENDERBUFFER_SAMPLES_ANGLE 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE 0x8D56 +#define GL_MAX_SAMPLES_ANGLE 0x8D57 +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEANGLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleANGLE (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#endif +#endif /* GL_ANGLE_framebuffer_multisample */ + +#ifndef GL_ANGLE_instanced_arrays +#define GL_ANGLE_instanced_arrays 1 +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE 0x88FE +typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDANGLEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDANGLEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBDIVISORANGLEPROC) (GLuint index, GLuint divisor); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawArraysInstancedANGLE (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +GL_APICALL void GL_APIENTRY glDrawElementsInstancedANGLE (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +GL_APICALL void GL_APIENTRY glVertexAttribDivisorANGLE (GLuint index, GLuint divisor); +#endif +#endif /* GL_ANGLE_instanced_arrays */ + +#ifndef GL_ANGLE_pack_reverse_row_order +#define GL_ANGLE_pack_reverse_row_order 1 +#define GL_PACK_REVERSE_ROW_ORDER_ANGLE 0x93A4 +#endif /* GL_ANGLE_pack_reverse_row_order */ + +#ifndef GL_ANGLE_program_binary +#define GL_ANGLE_program_binary 1 +#define GL_PROGRAM_BINARY_ANGLE 0x93A6 +#endif /* GL_ANGLE_program_binary */ + +#ifndef GL_ANGLE_texture_compression_dxt3 +#define GL_ANGLE_texture_compression_dxt3 1 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE 0x83F2 +#endif /* GL_ANGLE_texture_compression_dxt3 */ + +#ifndef GL_ANGLE_texture_compression_dxt5 +#define GL_ANGLE_texture_compression_dxt5 1 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE 0x83F3 +#endif /* GL_ANGLE_texture_compression_dxt5 */ + +#ifndef GL_ANGLE_texture_usage +#define GL_ANGLE_texture_usage 1 +#define GL_TEXTURE_USAGE_ANGLE 0x93A2 +#define GL_FRAMEBUFFER_ATTACHMENT_ANGLE 0x93A3 +#endif /* GL_ANGLE_texture_usage */ + +#ifndef GL_ANGLE_translated_shader_source +#define GL_ANGLE_translated_shader_source 1 +#define GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE 0x93A0 +typedef void (GL_APIENTRYP PFNGLGETTRANSLATEDSHADERSOURCEANGLEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGetTranslatedShaderSourceANGLE (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +#endif +#endif /* GL_ANGLE_translated_shader_source */ + +#ifndef GL_APPLE_clip_distance +#define GL_APPLE_clip_distance 1 +#define GL_MAX_CLIP_DISTANCES_APPLE 0x0D32 +#define GL_CLIP_DISTANCE0_APPLE 0x3000 +#define GL_CLIP_DISTANCE1_APPLE 0x3001 +#define GL_CLIP_DISTANCE2_APPLE 0x3002 +#define GL_CLIP_DISTANCE3_APPLE 0x3003 +#define GL_CLIP_DISTANCE4_APPLE 0x3004 +#define GL_CLIP_DISTANCE5_APPLE 0x3005 +#define GL_CLIP_DISTANCE6_APPLE 0x3006 +#define GL_CLIP_DISTANCE7_APPLE 0x3007 +#endif /* GL_APPLE_clip_distance */ + +#ifndef GL_APPLE_color_buffer_packed_float +#define GL_APPLE_color_buffer_packed_float 1 +#endif /* GL_APPLE_color_buffer_packed_float */ + +#ifndef GL_APPLE_copy_texture_levels +#define GL_APPLE_copy_texture_levels 1 +typedef void (GL_APIENTRYP PFNGLCOPYTEXTURELEVELSAPPLEPROC) (GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glCopyTextureLevelsAPPLE (GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount); +#endif +#endif /* GL_APPLE_copy_texture_levels */ + +#ifndef GL_APPLE_framebuffer_multisample +#define GL_APPLE_framebuffer_multisample 1 +#define GL_RENDERBUFFER_SAMPLES_APPLE 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_APPLE 0x8D56 +#define GL_MAX_SAMPLES_APPLE 0x8D57 +#define GL_READ_FRAMEBUFFER_APPLE 0x8CA8 +#define GL_DRAW_FRAMEBUFFER_APPLE 0x8CA9 +#define GL_DRAW_FRAMEBUFFER_BINDING_APPLE 0x8CA6 +#define GL_READ_FRAMEBUFFER_BINDING_APPLE 0x8CAA +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEAPPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLRESOLVEMULTISAMPLEFRAMEBUFFERAPPLEPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleAPPLE (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glResolveMultisampleFramebufferAPPLE (void); +#endif +#endif /* GL_APPLE_framebuffer_multisample */ + +#ifndef GL_APPLE_rgb_422 +#define GL_APPLE_rgb_422 1 +#define GL_RGB_422_APPLE 0x8A1F +#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB +#define GL_RGB_RAW_422_APPLE 0x8A51 +#endif /* GL_APPLE_rgb_422 */ + +#ifndef GL_APPLE_sync +#define GL_APPLE_sync 1 +#define GL_SYNC_OBJECT_APPLE 0x8A53 +#define GL_MAX_SERVER_WAIT_TIMEOUT_APPLE 0x9111 +#define GL_OBJECT_TYPE_APPLE 0x9112 +#define GL_SYNC_CONDITION_APPLE 0x9113 +#define GL_SYNC_STATUS_APPLE 0x9114 +#define GL_SYNC_FLAGS_APPLE 0x9115 +#define GL_SYNC_FENCE_APPLE 0x9116 +#define GL_SYNC_GPU_COMMANDS_COMPLETE_APPLE 0x9117 +#define GL_UNSIGNALED_APPLE 0x9118 +#define GL_SIGNALED_APPLE 0x9119 +#define GL_ALREADY_SIGNALED_APPLE 0x911A +#define GL_TIMEOUT_EXPIRED_APPLE 0x911B +#define GL_CONDITION_SATISFIED_APPLE 0x911C +#define GL_WAIT_FAILED_APPLE 0x911D +#define GL_SYNC_FLUSH_COMMANDS_BIT_APPLE 0x00000001 +#define GL_TIMEOUT_IGNORED_APPLE 0xFFFFFFFFFFFFFFFFull +typedef GLsync (GL_APIENTRYP PFNGLFENCESYNCAPPLEPROC) (GLenum condition, GLbitfield flags); +typedef GLboolean (GL_APIENTRYP PFNGLISSYNCAPPLEPROC) (GLsync sync); +typedef void (GL_APIENTRYP PFNGLDELETESYNCAPPLEPROC) (GLsync sync); +typedef GLenum (GL_APIENTRYP PFNGLCLIENTWAITSYNCAPPLEPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (GL_APIENTRYP PFNGLWAITSYNCAPPLEPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (GL_APIENTRYP PFNGLGETINTEGER64VAPPLEPROC) (GLenum pname, GLint64 *params); +typedef void (GL_APIENTRYP PFNGLGETSYNCIVAPPLEPROC) (GLsync sync, GLenum pname, GLsizei count, GLsizei *length, GLint *values); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL GLsync GL_APIENTRY glFenceSyncAPPLE (GLenum condition, GLbitfield flags); +GL_APICALL GLboolean GL_APIENTRY glIsSyncAPPLE (GLsync sync); +GL_APICALL void GL_APIENTRY glDeleteSyncAPPLE (GLsync sync); +GL_APICALL GLenum GL_APIENTRY glClientWaitSyncAPPLE (GLsync sync, GLbitfield flags, GLuint64 timeout); +GL_APICALL void GL_APIENTRY glWaitSyncAPPLE (GLsync sync, GLbitfield flags, GLuint64 timeout); +GL_APICALL void GL_APIENTRY glGetInteger64vAPPLE (GLenum pname, GLint64 *params); +GL_APICALL void GL_APIENTRY glGetSyncivAPPLE (GLsync sync, GLenum pname, GLsizei count, GLsizei *length, GLint *values); +#endif +#endif /* GL_APPLE_sync */ + +#ifndef GL_APPLE_texture_format_BGRA8888 +#define GL_APPLE_texture_format_BGRA8888 1 +#define GL_BGRA_EXT 0x80E1 +#define GL_BGRA8_EXT 0x93A1 +#endif /* GL_APPLE_texture_format_BGRA8888 */ + +#ifndef GL_APPLE_texture_max_level +#define GL_APPLE_texture_max_level 1 +#define GL_TEXTURE_MAX_LEVEL_APPLE 0x813D +#endif /* GL_APPLE_texture_max_level */ + +#ifndef GL_APPLE_texture_packed_float +#define GL_APPLE_texture_packed_float 1 +#define GL_UNSIGNED_INT_10F_11F_11F_REV_APPLE 0x8C3B +#define GL_UNSIGNED_INT_5_9_9_9_REV_APPLE 0x8C3E +#define GL_R11F_G11F_B10F_APPLE 0x8C3A +#define GL_RGB9_E5_APPLE 0x8C3D +#endif /* GL_APPLE_texture_packed_float */ + +#ifndef GL_ARM_mali_program_binary +#define GL_ARM_mali_program_binary 1 +#define GL_MALI_PROGRAM_BINARY_ARM 0x8F61 +#endif /* GL_ARM_mali_program_binary */ + +#ifndef GL_ARM_mali_shader_binary +#define GL_ARM_mali_shader_binary 1 +#define GL_MALI_SHADER_BINARY_ARM 0x8F60 +#endif /* GL_ARM_mali_shader_binary */ + +#ifndef GL_ARM_rgba8 +#define GL_ARM_rgba8 1 +#endif /* GL_ARM_rgba8 */ + +#ifndef GL_ARM_shader_framebuffer_fetch +#define GL_ARM_shader_framebuffer_fetch 1 +#define GL_FETCH_PER_SAMPLE_ARM 0x8F65 +#define GL_FRAGMENT_SHADER_FRAMEBUFFER_FETCH_MRT_ARM 0x8F66 +#endif /* GL_ARM_shader_framebuffer_fetch */ + +#ifndef GL_ARM_shader_framebuffer_fetch_depth_stencil +#define GL_ARM_shader_framebuffer_fetch_depth_stencil 1 +#endif /* GL_ARM_shader_framebuffer_fetch_depth_stencil */ + +#ifndef GL_ARM_texture_unnormalized_coordinates +#define GL_ARM_texture_unnormalized_coordinates 1 +#define GL_TEXTURE_UNNORMALIZED_COORDINATES_ARM 0x8F6A +#endif /* GL_ARM_texture_unnormalized_coordinates */ + +#ifndef GL_DMP_program_binary +#define GL_DMP_program_binary 1 +#define GL_SMAPHS30_PROGRAM_BINARY_DMP 0x9251 +#define GL_SMAPHS_PROGRAM_BINARY_DMP 0x9252 +#define GL_DMP_PROGRAM_BINARY_DMP 0x9253 +#endif /* GL_DMP_program_binary */ + +#ifndef GL_DMP_shader_binary +#define GL_DMP_shader_binary 1 +#define GL_SHADER_BINARY_DMP 0x9250 +#endif /* GL_DMP_shader_binary */ + +#ifndef GL_EXT_EGL_image_array +#define GL_EXT_EGL_image_array 1 +#endif /* GL_EXT_EGL_image_array */ + +#ifndef GL_EXT_EGL_image_storage +#define GL_EXT_EGL_image_storage 1 +typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXSTORAGEEXTPROC) (GLenum target, GLeglImageOES image, const GLint* attrib_list); +typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXTURESTORAGEEXTPROC) (GLuint texture, GLeglImageOES image, const GLint* attrib_list); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glEGLImageTargetTexStorageEXT (GLenum target, GLeglImageOES image, const GLint* attrib_list); +GL_APICALL void GL_APIENTRY glEGLImageTargetTextureStorageEXT (GLuint texture, GLeglImageOES image, const GLint* attrib_list); +#endif +#endif /* GL_EXT_EGL_image_storage */ + +#ifndef GL_EXT_EGL_image_storage_compression +#define GL_EXT_EGL_image_storage_compression 1 +#define GL_SURFACE_COMPRESSION_EXT 0x96C0 +#define GL_SURFACE_COMPRESSION_FIXED_RATE_NONE_EXT 0x96C1 +#define GL_SURFACE_COMPRESSION_FIXED_RATE_DEFAULT_EXT 0x96C2 +#endif /* GL_EXT_EGL_image_storage_compression */ + +#ifndef GL_EXT_YUV_target +#define GL_EXT_YUV_target 1 +#define GL_SAMPLER_EXTERNAL_2D_Y2Y_EXT 0x8BE7 +#endif /* GL_EXT_YUV_target */ + +#ifndef GL_EXT_base_instance +#define GL_EXT_base_instance 1 +typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEEXTPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawArraysInstancedBaseInstanceEXT (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); +GL_APICALL void GL_APIENTRY glDrawElementsInstancedBaseInstanceEXT (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); +GL_APICALL void GL_APIENTRY glDrawElementsInstancedBaseVertexBaseInstanceEXT (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); +#endif +#endif /* GL_EXT_base_instance */ + +#ifndef GL_EXT_blend_func_extended +#define GL_EXT_blend_func_extended 1 +#define GL_SRC1_COLOR_EXT 0x88F9 +#define GL_SRC1_ALPHA_EXT 0x8589 +#define GL_ONE_MINUS_SRC1_COLOR_EXT 0x88FA +#define GL_ONE_MINUS_SRC1_ALPHA_EXT 0x88FB +#define GL_SRC_ALPHA_SATURATE_EXT 0x0308 +#define GL_LOCATION_INDEX_EXT 0x930F +#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS_EXT 0x88FC +typedef void (GL_APIENTRYP PFNGLBINDFRAGDATALOCATIONINDEXEDEXTPROC) (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); +typedef void (GL_APIENTRYP PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name); +typedef GLint (GL_APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONINDEXEXTPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef GLint (GL_APIENTRYP PFNGLGETFRAGDATAINDEXEXTPROC) (GLuint program, const GLchar *name); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glBindFragDataLocationIndexedEXT (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); +GL_APICALL void GL_APIENTRY glBindFragDataLocationEXT (GLuint program, GLuint color, const GLchar *name); +GL_APICALL GLint GL_APIENTRY glGetProgramResourceLocationIndexEXT (GLuint program, GLenum programInterface, const GLchar *name); +GL_APICALL GLint GL_APIENTRY glGetFragDataIndexEXT (GLuint program, const GLchar *name); +#endif +#endif /* GL_EXT_blend_func_extended */ + +#ifndef GL_EXT_blend_minmax +#define GL_EXT_blend_minmax 1 +#define GL_MIN_EXT 0x8007 +#define GL_MAX_EXT 0x8008 +#endif /* GL_EXT_blend_minmax */ + +#ifndef GL_EXT_buffer_storage +#define GL_EXT_buffer_storage 1 +#define GL_MAP_READ_BIT 0x0001 +#define GL_MAP_WRITE_BIT 0x0002 +#define GL_MAP_PERSISTENT_BIT_EXT 0x0040 +#define GL_MAP_COHERENT_BIT_EXT 0x0080 +#define GL_DYNAMIC_STORAGE_BIT_EXT 0x0100 +#define GL_CLIENT_STORAGE_BIT_EXT 0x0200 +#define GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT_EXT 0x00004000 +#define GL_BUFFER_IMMUTABLE_STORAGE_EXT 0x821F +#define GL_BUFFER_STORAGE_FLAGS_EXT 0x8220 +typedef void (GL_APIENTRYP PFNGLBUFFERSTORAGEEXTPROC) (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glBufferStorageEXT (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags); +#endif +#endif /* GL_EXT_buffer_storage */ + +#ifndef GL_EXT_clear_texture +#define GL_EXT_clear_texture 1 +typedef void (GL_APIENTRYP PFNGLCLEARTEXIMAGEEXTPROC) (GLuint texture, GLint level, GLenum format, GLenum type, const void *data); +typedef void (GL_APIENTRYP PFNGLCLEARTEXSUBIMAGEEXTPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glClearTexImageEXT (GLuint texture, GLint level, GLenum format, GLenum type, const void *data); +GL_APICALL void GL_APIENTRY glClearTexSubImageEXT (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); +#endif +#endif /* GL_EXT_clear_texture */ + +#ifndef GL_EXT_clip_control +#define GL_EXT_clip_control 1 +#define GL_LOWER_LEFT_EXT 0x8CA1 +#define GL_UPPER_LEFT_EXT 0x8CA2 +#define GL_NEGATIVE_ONE_TO_ONE_EXT 0x935E +#define GL_ZERO_TO_ONE_EXT 0x935F +#define GL_CLIP_ORIGIN_EXT 0x935C +#define GL_CLIP_DEPTH_MODE_EXT 0x935D +typedef void (GL_APIENTRYP PFNGLCLIPCONTROLEXTPROC) (GLenum origin, GLenum depth); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glClipControlEXT (GLenum origin, GLenum depth); +#endif +#endif /* GL_EXT_clip_control */ + +#ifndef GL_EXT_clip_cull_distance +#define GL_EXT_clip_cull_distance 1 +#define GL_MAX_CLIP_DISTANCES_EXT 0x0D32 +#define GL_MAX_CULL_DISTANCES_EXT 0x82F9 +#define GL_MAX_COMBINED_CLIP_AND_CULL_DISTANCES_EXT 0x82FA +#define GL_CLIP_DISTANCE0_EXT 0x3000 +#define GL_CLIP_DISTANCE1_EXT 0x3001 +#define GL_CLIP_DISTANCE2_EXT 0x3002 +#define GL_CLIP_DISTANCE3_EXT 0x3003 +#define GL_CLIP_DISTANCE4_EXT 0x3004 +#define GL_CLIP_DISTANCE5_EXT 0x3005 +#define GL_CLIP_DISTANCE6_EXT 0x3006 +#define GL_CLIP_DISTANCE7_EXT 0x3007 +#endif /* GL_EXT_clip_cull_distance */ + +#ifndef GL_EXT_color_buffer_float +#define GL_EXT_color_buffer_float 1 +#endif /* GL_EXT_color_buffer_float */ + +#ifndef GL_EXT_color_buffer_half_float +#define GL_EXT_color_buffer_half_float 1 +#define GL_RGBA16F_EXT 0x881A +#define GL_RGB16F_EXT 0x881B +#define GL_RG16F_EXT 0x822F +#define GL_R16F_EXT 0x822D +#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT 0x8211 +#define GL_UNSIGNED_NORMALIZED_EXT 0x8C17 +#endif /* GL_EXT_color_buffer_half_float */ + +#ifndef GL_EXT_conservative_depth +#define GL_EXT_conservative_depth 1 +#endif /* GL_EXT_conservative_depth */ + +#ifndef GL_EXT_copy_image +#define GL_EXT_copy_image 1 +typedef void (GL_APIENTRYP PFNGLCOPYIMAGESUBDATAEXTPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glCopyImageSubDataEXT (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +#endif +#endif /* GL_EXT_copy_image */ + +#ifndef GL_EXT_debug_label +#define GL_EXT_debug_label 1 +#define GL_PROGRAM_PIPELINE_OBJECT_EXT 0x8A4F +#define GL_PROGRAM_OBJECT_EXT 0x8B40 +#define GL_SHADER_OBJECT_EXT 0x8B48 +#define GL_BUFFER_OBJECT_EXT 0x9151 +#define GL_QUERY_OBJECT_EXT 0x9153 +#define GL_VERTEX_ARRAY_OBJECT_EXT 0x9154 +#define GL_TRANSFORM_FEEDBACK 0x8E22 +typedef void (GL_APIENTRYP PFNGLLABELOBJECTEXTPROC) (GLenum type, GLuint object, GLsizei length, const GLchar *label); +typedef void (GL_APIENTRYP PFNGLGETOBJECTLABELEXTPROC) (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glLabelObjectEXT (GLenum type, GLuint object, GLsizei length, const GLchar *label); +GL_APICALL void GL_APIENTRY glGetObjectLabelEXT (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label); +#endif +#endif /* GL_EXT_debug_label */ + +#ifndef GL_EXT_debug_marker +#define GL_EXT_debug_marker 1 +typedef void (GL_APIENTRYP PFNGLINSERTEVENTMARKEREXTPROC) (GLsizei length, const GLchar *marker); +typedef void (GL_APIENTRYP PFNGLPUSHGROUPMARKEREXTPROC) (GLsizei length, const GLchar *marker); +typedef void (GL_APIENTRYP PFNGLPOPGROUPMARKEREXTPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glInsertEventMarkerEXT (GLsizei length, const GLchar *marker); +GL_APICALL void GL_APIENTRY glPushGroupMarkerEXT (GLsizei length, const GLchar *marker); +GL_APICALL void GL_APIENTRY glPopGroupMarkerEXT (void); +#endif +#endif /* GL_EXT_debug_marker */ + +#ifndef GL_EXT_depth_clamp +#define GL_EXT_depth_clamp 1 +#define GL_DEPTH_CLAMP_EXT 0x864F +#endif /* GL_EXT_depth_clamp */ + +#ifndef GL_EXT_discard_framebuffer +#define GL_EXT_discard_framebuffer 1 +#define GL_COLOR_EXT 0x1800 +#define GL_DEPTH_EXT 0x1801 +#define GL_STENCIL_EXT 0x1802 +typedef void (GL_APIENTRYP PFNGLDISCARDFRAMEBUFFEREXTPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDiscardFramebufferEXT (GLenum target, GLsizei numAttachments, const GLenum *attachments); +#endif +#endif /* GL_EXT_discard_framebuffer */ + +#ifndef GL_EXT_disjoint_timer_query +#define GL_EXT_disjoint_timer_query 1 +#define GL_QUERY_COUNTER_BITS_EXT 0x8864 +#define GL_CURRENT_QUERY_EXT 0x8865 +#define GL_QUERY_RESULT_EXT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE_EXT 0x8867 +#define GL_TIME_ELAPSED_EXT 0x88BF +#define GL_TIMESTAMP_EXT 0x8E28 +#define GL_GPU_DISJOINT_EXT 0x8FBB +typedef void (GL_APIENTRYP PFNGLGENQUERIESEXTPROC) (GLsizei n, GLuint *ids); +typedef void (GL_APIENTRYP PFNGLDELETEQUERIESEXTPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (GL_APIENTRYP PFNGLISQUERYEXTPROC) (GLuint id); +typedef void (GL_APIENTRYP PFNGLBEGINQUERYEXTPROC) (GLenum target, GLuint id); +typedef void (GL_APIENTRYP PFNGLENDQUERYEXTPROC) (GLenum target); +typedef void (GL_APIENTRYP PFNGLQUERYCOUNTEREXTPROC) (GLuint id, GLenum target); +typedef void (GL_APIENTRYP PFNGLGETQUERYIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTIVEXTPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTUIVEXTPROC) (GLuint id, GLenum pname, GLuint *params); +typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64 *params); +typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64 *params); +typedef void (GL_APIENTRYP PFNGLGETINTEGER64VEXTPROC) (GLenum pname, GLint64 *data); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGenQueriesEXT (GLsizei n, GLuint *ids); +GL_APICALL void GL_APIENTRY glDeleteQueriesEXT (GLsizei n, const GLuint *ids); +GL_APICALL GLboolean GL_APIENTRY glIsQueryEXT (GLuint id); +GL_APICALL void GL_APIENTRY glBeginQueryEXT (GLenum target, GLuint id); +GL_APICALL void GL_APIENTRY glEndQueryEXT (GLenum target); +GL_APICALL void GL_APIENTRY glQueryCounterEXT (GLuint id, GLenum target); +GL_APICALL void GL_APIENTRY glGetQueryivEXT (GLenum target, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetQueryObjectivEXT (GLuint id, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetQueryObjectuivEXT (GLuint id, GLenum pname, GLuint *params); +GL_APICALL void GL_APIENTRY glGetQueryObjecti64vEXT (GLuint id, GLenum pname, GLint64 *params); +GL_APICALL void GL_APIENTRY glGetQueryObjectui64vEXT (GLuint id, GLenum pname, GLuint64 *params); +GL_APICALL void GL_APIENTRY glGetInteger64vEXT (GLenum pname, GLint64 *data); +#endif +#endif /* GL_EXT_disjoint_timer_query */ + +#ifndef GL_EXT_draw_buffers +#define GL_EXT_draw_buffers 1 +#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF +#define GL_MAX_DRAW_BUFFERS_EXT 0x8824 +#define GL_DRAW_BUFFER0_EXT 0x8825 +#define GL_DRAW_BUFFER1_EXT 0x8826 +#define GL_DRAW_BUFFER2_EXT 0x8827 +#define GL_DRAW_BUFFER3_EXT 0x8828 +#define GL_DRAW_BUFFER4_EXT 0x8829 +#define GL_DRAW_BUFFER5_EXT 0x882A +#define GL_DRAW_BUFFER6_EXT 0x882B +#define GL_DRAW_BUFFER7_EXT 0x882C +#define GL_DRAW_BUFFER8_EXT 0x882D +#define GL_DRAW_BUFFER9_EXT 0x882E +#define GL_DRAW_BUFFER10_EXT 0x882F +#define GL_DRAW_BUFFER11_EXT 0x8830 +#define GL_DRAW_BUFFER12_EXT 0x8831 +#define GL_DRAW_BUFFER13_EXT 0x8832 +#define GL_DRAW_BUFFER14_EXT 0x8833 +#define GL_DRAW_BUFFER15_EXT 0x8834 +#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 +#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 +#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 +#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 +#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 +#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 +#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 +#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 +#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 +#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 +#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA +#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB +#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC +#define GL_COLOR_ATTACHMENT13_EXT 0x8CED +#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE +#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF +typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSEXTPROC) (GLsizei n, const GLenum *bufs); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawBuffersEXT (GLsizei n, const GLenum *bufs); +#endif +#endif /* GL_EXT_draw_buffers */ + +#ifndef GL_EXT_draw_buffers_indexed +#define GL_EXT_draw_buffers_indexed 1 +typedef void (GL_APIENTRYP PFNGLENABLEIEXTPROC) (GLenum target, GLuint index); +typedef void (GL_APIENTRYP PFNGLDISABLEIEXTPROC) (GLenum target, GLuint index); +typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONIEXTPROC) (GLuint buf, GLenum mode); +typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONSEPARATEIEXTPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +typedef void (GL_APIENTRYP PFNGLBLENDFUNCIEXTPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (GL_APIENTRYP PFNGLBLENDFUNCSEPARATEIEXTPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +typedef void (GL_APIENTRYP PFNGLCOLORMASKIEXTPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +typedef GLboolean (GL_APIENTRYP PFNGLISENABLEDIEXTPROC) (GLenum target, GLuint index); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glEnableiEXT (GLenum target, GLuint index); +GL_APICALL void GL_APIENTRY glDisableiEXT (GLenum target, GLuint index); +GL_APICALL void GL_APIENTRY glBlendEquationiEXT (GLuint buf, GLenum mode); +GL_APICALL void GL_APIENTRY glBlendEquationSeparateiEXT (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +GL_APICALL void GL_APIENTRY glBlendFunciEXT (GLuint buf, GLenum src, GLenum dst); +GL_APICALL void GL_APIENTRY glBlendFuncSeparateiEXT (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +GL_APICALL void GL_APIENTRY glColorMaskiEXT (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +GL_APICALL GLboolean GL_APIENTRY glIsEnablediEXT (GLenum target, GLuint index); +#endif +#endif /* GL_EXT_draw_buffers_indexed */ + +#ifndef GL_EXT_draw_elements_base_vertex +#define GL_EXT_draw_elements_base_vertex 1 +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); +typedef void (GL_APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawElementsBaseVertexEXT (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); +GL_APICALL void GL_APIENTRY glDrawRangeElementsBaseVertexEXT (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); +GL_APICALL void GL_APIENTRY glDrawElementsInstancedBaseVertexEXT (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); +#endif +#endif /* GL_EXT_draw_elements_base_vertex */ + +#ifndef GL_EXT_draw_instanced +#define GL_EXT_draw_instanced 1 +typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount); +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawArraysInstancedEXT (GLenum mode, GLint start, GLsizei count, GLsizei primcount); +GL_APICALL void GL_APIENTRY glDrawElementsInstancedEXT (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#endif +#endif /* GL_EXT_draw_instanced */ + +#ifndef GL_EXT_draw_transform_feedback +#define GL_EXT_draw_transform_feedback 1 +typedef void (GL_APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKEXTPROC) (GLenum mode, GLuint id); +typedef void (GL_APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDEXTPROC) (GLenum mode, GLuint id, GLsizei instancecount); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawTransformFeedbackEXT (GLenum mode, GLuint id); +GL_APICALL void GL_APIENTRY glDrawTransformFeedbackInstancedEXT (GLenum mode, GLuint id, GLsizei instancecount); +#endif +#endif /* GL_EXT_draw_transform_feedback */ + +#ifndef GL_EXT_external_buffer +#define GL_EXT_external_buffer 1 +typedef void *GLeglClientBufferEXT; +typedef void (GL_APIENTRYP PFNGLBUFFERSTORAGEEXTERNALEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); +typedef void (GL_APIENTRYP PFNGLNAMEDBUFFERSTORAGEEXTERNALEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glBufferStorageExternalEXT (GLenum target, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); +GL_APICALL void GL_APIENTRY glNamedBufferStorageExternalEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); +#endif +#endif /* GL_EXT_external_buffer */ + +#ifndef GL_EXT_float_blend +#define GL_EXT_float_blend 1 +#endif /* GL_EXT_float_blend */ + +#ifndef GL_EXT_fragment_shading_rate +#define GL_EXT_fragment_shading_rate 1 +#define GL_SHADING_RATE_1X1_PIXELS_EXT 0x96A6 +#define GL_SHADING_RATE_1X2_PIXELS_EXT 0x96A7 +#define GL_SHADING_RATE_2X1_PIXELS_EXT 0x96A8 +#define GL_SHADING_RATE_2X2_PIXELS_EXT 0x96A9 +#define GL_SHADING_RATE_1X4_PIXELS_EXT 0x96AA +#define GL_SHADING_RATE_4X1_PIXELS_EXT 0x96AB +#define GL_SHADING_RATE_4X2_PIXELS_EXT 0x96AC +#define GL_SHADING_RATE_2X4_PIXELS_EXT 0x96AD +#define GL_SHADING_RATE_4X4_PIXELS_EXT 0x96AE +#define GL_SHADING_RATE_EXT 0x96D0 +#define GL_SHADING_RATE_ATTACHMENT_EXT 0x96D1 +#define GL_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_EXT 0x96D2 +#define GL_FRAGMENT_SHADING_RATE_COMBINER_OP_REPLACE_EXT 0x96D3 +#define GL_FRAGMENT_SHADING_RATE_COMBINER_OP_MIN_EXT 0x96D4 +#define GL_FRAGMENT_SHADING_RATE_COMBINER_OP_MAX_EXT 0x96D5 +#define GL_FRAGMENT_SHADING_RATE_COMBINER_OP_MUL_EXT 0x96D6 +#define GL_MIN_FRAGMENT_SHADING_RATE_ATTACHMENT_TEXEL_WIDTH_EXT 0x96D7 +#define GL_MAX_FRAGMENT_SHADING_RATE_ATTACHMENT_TEXEL_WIDTH_EXT 0x96D8 +#define GL_MIN_FRAGMENT_SHADING_RATE_ATTACHMENT_TEXEL_HEIGHT_EXT 0x96D9 +#define GL_MAX_FRAGMENT_SHADING_RATE_ATTACHMENT_TEXEL_HEIGHT_EXT 0x96DA +#define GL_MAX_FRAGMENT_SHADING_RATE_ATTACHMENT_TEXEL_ASPECT_RATIO_EXT 0x96DB +#define GL_MAX_FRAGMENT_SHADING_RATE_ATTACHMENT_LAYERS_EXT 0x96DC +#define GL_FRAGMENT_SHADING_RATE_WITH_SHADER_DEPTH_STENCIL_WRITES_SUPPORTED_EXT 0x96DD +#define GL_FRAGMENT_SHADING_RATE_WITH_SAMPLE_MASK_SUPPORTED_EXT 0x96DE +#define GL_FRAGMENT_SHADING_RATE_ATTACHMENT_WITH_DEFAULT_FRAMEBUFFER_SUPPORTED_EXT 0x96DF +#define GL_FRAGMENT_SHADING_RATE_NON_TRIVIAL_COMBINERS_SUPPORTED_EXT 0x8F6F +typedef void (GL_APIENTRYP PFNGLGETFRAGMENTSHADINGRATESEXTPROC) (GLsizei samples, GLsizei maxCount, GLsizei *count, GLenum *shadingRates); +typedef void (GL_APIENTRYP PFNGLSHADINGRATEEXTPROC) (GLenum rate); +typedef void (GL_APIENTRYP PFNGLSHADINGRATECOMBINEROPSEXTPROC) (GLenum combinerOp0, GLenum combinerOp1); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERSHADINGRATEEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint baseLayer, GLsizei numLayers, GLsizei texelWidth, GLsizei texelHeight); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGetFragmentShadingRatesEXT (GLsizei samples, GLsizei maxCount, GLsizei *count, GLenum *shadingRates); +GL_APICALL void GL_APIENTRY glShadingRateEXT (GLenum rate); +GL_APICALL void GL_APIENTRY glShadingRateCombinerOpsEXT (GLenum combinerOp0, GLenum combinerOp1); +GL_APICALL void GL_APIENTRY glFramebufferShadingRateEXT (GLenum target, GLenum attachment, GLuint texture, GLint baseLayer, GLsizei numLayers, GLsizei texelWidth, GLsizei texelHeight); +#endif +#endif /* GL_EXT_fragment_shading_rate */ + +#ifndef GL_EXT_geometry_point_size +#define GL_EXT_geometry_point_size 1 +#endif /* GL_EXT_geometry_point_size */ + +#ifndef GL_EXT_geometry_shader +#define GL_EXT_geometry_shader 1 +#define GL_GEOMETRY_SHADER_EXT 0x8DD9 +#define GL_GEOMETRY_SHADER_BIT_EXT 0x00000004 +#define GL_GEOMETRY_LINKED_VERTICES_OUT_EXT 0x8916 +#define GL_GEOMETRY_LINKED_INPUT_TYPE_EXT 0x8917 +#define GL_GEOMETRY_LINKED_OUTPUT_TYPE_EXT 0x8918 +#define GL_GEOMETRY_SHADER_INVOCATIONS_EXT 0x887F +#define GL_LAYER_PROVOKING_VERTEX_EXT 0x825E +#define GL_LINES_ADJACENCY_EXT 0x000A +#define GL_LINE_STRIP_ADJACENCY_EXT 0x000B +#define GL_TRIANGLES_ADJACENCY_EXT 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0x000D +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF +#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS_EXT 0x8A2C +#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8A32 +#define GL_MAX_GEOMETRY_INPUT_COMPONENTS_EXT 0x9123 +#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS_EXT 0x9124 +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1 +#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS_EXT 0x8E5A +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29 +#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS_EXT 0x92CF +#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS_EXT 0x92D5 +#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS_EXT 0x90CD +#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS_EXT 0x90D7 +#define GL_FIRST_VERTEX_CONVENTION_EXT 0x8E4D +#define GL_LAST_VERTEX_CONVENTION_EXT 0x8E4E +#define GL_UNDEFINED_VERTEX_EXT 0x8260 +#define GL_PRIMITIVES_GENERATED_EXT 0x8C87 +#define GL_FRAMEBUFFER_DEFAULT_LAYERS_EXT 0x9312 +#define GL_MAX_FRAMEBUFFER_LAYERS_EXT 0x9317 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7 +#define GL_REFERENCED_BY_GEOMETRY_SHADER_EXT 0x9309 +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glFramebufferTextureEXT (GLenum target, GLenum attachment, GLuint texture, GLint level); +#endif +#endif /* GL_EXT_geometry_shader */ + +#ifndef GL_EXT_gpu_shader5 +#define GL_EXT_gpu_shader5 1 +#endif /* GL_EXT_gpu_shader5 */ + +#ifndef GL_EXT_instanced_arrays +#define GL_EXT_instanced_arrays 1 +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_EXT 0x88FE +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBDIVISOREXTPROC) (GLuint index, GLuint divisor); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glVertexAttribDivisorEXT (GLuint index, GLuint divisor); +#endif +#endif /* GL_EXT_instanced_arrays */ + +#ifndef GL_EXT_map_buffer_range +#define GL_EXT_map_buffer_range 1 +#define GL_MAP_READ_BIT_EXT 0x0001 +#define GL_MAP_WRITE_BIT_EXT 0x0002 +#define GL_MAP_INVALIDATE_RANGE_BIT_EXT 0x0004 +#define GL_MAP_INVALIDATE_BUFFER_BIT_EXT 0x0008 +#define GL_MAP_FLUSH_EXPLICIT_BIT_EXT 0x0010 +#define GL_MAP_UNSYNCHRONIZED_BIT_EXT 0x0020 +typedef void *(GL_APIENTRYP PFNGLMAPBUFFERRANGEEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (GL_APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr length); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void *GL_APIENTRY glMapBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +GL_APICALL void GL_APIENTRY glFlushMappedBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length); +#endif +#endif /* GL_EXT_map_buffer_range */ + +#ifndef GL_EXT_memory_object +#define GL_EXT_memory_object 1 +#define GL_TEXTURE_TILING_EXT 0x9580 +#define GL_DEDICATED_MEMORY_OBJECT_EXT 0x9581 +#define GL_PROTECTED_MEMORY_OBJECT_EXT 0x959B +#define GL_NUM_TILING_TYPES_EXT 0x9582 +#define GL_TILING_TYPES_EXT 0x9583 +#define GL_OPTIMAL_TILING_EXT 0x9584 +#define GL_LINEAR_TILING_EXT 0x9585 +#define GL_NUM_DEVICE_UUIDS_EXT 0x9596 +#define GL_DEVICE_UUID_EXT 0x9597 +#define GL_DRIVER_UUID_EXT 0x9598 +#define GL_UUID_SIZE_EXT 16 +typedef void (GL_APIENTRYP PFNGLGETUNSIGNEDBYTEVEXTPROC) (GLenum pname, GLubyte *data); +typedef void (GL_APIENTRYP PFNGLGETUNSIGNEDBYTEI_VEXTPROC) (GLenum target, GLuint index, GLubyte *data); +typedef void (GL_APIENTRYP PFNGLDELETEMEMORYOBJECTSEXTPROC) (GLsizei n, const GLuint *memoryObjects); +typedef GLboolean (GL_APIENTRYP PFNGLISMEMORYOBJECTEXTPROC) (GLuint memoryObject); +typedef void (GL_APIENTRYP PFNGLCREATEMEMORYOBJECTSEXTPROC) (GLsizei n, GLuint *memoryObjects); +typedef void (GL_APIENTRYP PFNGLMEMORYOBJECTPARAMETERIVEXTPROC) (GLuint memoryObject, GLenum pname, const GLint *params); +typedef void (GL_APIENTRYP PFNGLGETMEMORYOBJECTPARAMETERIVEXTPROC) (GLuint memoryObject, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLTEXSTORAGEMEM2DEXTPROC) (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); +typedef void (GL_APIENTRYP PFNGLTEXSTORAGEMEM2DMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +typedef void (GL_APIENTRYP PFNGLTEXSTORAGEMEM3DEXTPROC) (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); +typedef void (GL_APIENTRYP PFNGLTEXSTORAGEMEM3DMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +typedef void (GL_APIENTRYP PFNGLBUFFERSTORAGEMEMEXTPROC) (GLenum target, GLsizeiptr size, GLuint memory, GLuint64 offset); +typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGEMEM2DEXTPROC) (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); +typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGEMEM2DMULTISAMPLEEXTPROC) (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGEMEM3DEXTPROC) (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); +typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGEMEM3DMULTISAMPLEEXTPROC) (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +typedef void (GL_APIENTRYP PFNGLNAMEDBUFFERSTORAGEMEMEXTPROC) (GLuint buffer, GLsizeiptr size, GLuint memory, GLuint64 offset); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGetUnsignedBytevEXT (GLenum pname, GLubyte *data); +GL_APICALL void GL_APIENTRY glGetUnsignedBytei_vEXT (GLenum target, GLuint index, GLubyte *data); +GL_APICALL void GL_APIENTRY glDeleteMemoryObjectsEXT (GLsizei n, const GLuint *memoryObjects); +GL_APICALL GLboolean GL_APIENTRY glIsMemoryObjectEXT (GLuint memoryObject); +GL_APICALL void GL_APIENTRY glCreateMemoryObjectsEXT (GLsizei n, GLuint *memoryObjects); +GL_APICALL void GL_APIENTRY glMemoryObjectParameterivEXT (GLuint memoryObject, GLenum pname, const GLint *params); +GL_APICALL void GL_APIENTRY glGetMemoryObjectParameterivEXT (GLuint memoryObject, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glTexStorageMem2DEXT (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); +GL_APICALL void GL_APIENTRY glTexStorageMem2DMultisampleEXT (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +GL_APICALL void GL_APIENTRY glTexStorageMem3DEXT (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); +GL_APICALL void GL_APIENTRY glTexStorageMem3DMultisampleEXT (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +GL_APICALL void GL_APIENTRY glBufferStorageMemEXT (GLenum target, GLsizeiptr size, GLuint memory, GLuint64 offset); +GL_APICALL void GL_APIENTRY glTextureStorageMem2DEXT (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); +GL_APICALL void GL_APIENTRY glTextureStorageMem2DMultisampleEXT (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +GL_APICALL void GL_APIENTRY glTextureStorageMem3DEXT (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); +GL_APICALL void GL_APIENTRY glTextureStorageMem3DMultisampleEXT (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +GL_APICALL void GL_APIENTRY glNamedBufferStorageMemEXT (GLuint buffer, GLsizeiptr size, GLuint memory, GLuint64 offset); +#endif +#endif /* GL_EXT_memory_object */ + +#ifndef GL_EXT_memory_object_fd +#define GL_EXT_memory_object_fd 1 +#define GL_HANDLE_TYPE_OPAQUE_FD_EXT 0x9586 +typedef void (GL_APIENTRYP PFNGLIMPORTMEMORYFDEXTPROC) (GLuint memory, GLuint64 size, GLenum handleType, GLint fd); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glImportMemoryFdEXT (GLuint memory, GLuint64 size, GLenum handleType, GLint fd); +#endif +#endif /* GL_EXT_memory_object_fd */ + +#ifndef GL_EXT_memory_object_win32 +#define GL_EXT_memory_object_win32 1 +#define GL_HANDLE_TYPE_OPAQUE_WIN32_EXT 0x9587 +#define GL_HANDLE_TYPE_OPAQUE_WIN32_KMT_EXT 0x9588 +#define GL_DEVICE_LUID_EXT 0x9599 +#define GL_DEVICE_NODE_MASK_EXT 0x959A +#define GL_LUID_SIZE_EXT 8 +#define GL_HANDLE_TYPE_D3D12_TILEPOOL_EXT 0x9589 +#define GL_HANDLE_TYPE_D3D12_RESOURCE_EXT 0x958A +#define GL_HANDLE_TYPE_D3D11_IMAGE_EXT 0x958B +#define GL_HANDLE_TYPE_D3D11_IMAGE_KMT_EXT 0x958C +typedef void (GL_APIENTRYP PFNGLIMPORTMEMORYWIN32HANDLEEXTPROC) (GLuint memory, GLuint64 size, GLenum handleType, void *handle); +typedef void (GL_APIENTRYP PFNGLIMPORTMEMORYWIN32NAMEEXTPROC) (GLuint memory, GLuint64 size, GLenum handleType, const void *name); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glImportMemoryWin32HandleEXT (GLuint memory, GLuint64 size, GLenum handleType, void *handle); +GL_APICALL void GL_APIENTRY glImportMemoryWin32NameEXT (GLuint memory, GLuint64 size, GLenum handleType, const void *name); +#endif +#endif /* GL_EXT_memory_object_win32 */ + +#ifndef GL_EXT_multi_draw_arrays +#define GL_EXT_multi_draw_arrays 1 +typedef void (GL_APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glMultiDrawArraysEXT (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +GL_APICALL void GL_APIENTRY glMultiDrawElementsEXT (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount); +#endif +#endif /* GL_EXT_multi_draw_arrays */ + +#ifndef GL_EXT_multi_draw_indirect +#define GL_EXT_multi_draw_indirect 1 +typedef void (GL_APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTEXTPROC) (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); +typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTEXTPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glMultiDrawArraysIndirectEXT (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); +GL_APICALL void GL_APIENTRY glMultiDrawElementsIndirectEXT (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); +#endif +#endif /* GL_EXT_multi_draw_indirect */ + +#ifndef GL_EXT_multisampled_compatibility +#define GL_EXT_multisampled_compatibility 1 +#define GL_MULTISAMPLE_EXT 0x809D +#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F +#endif /* GL_EXT_multisampled_compatibility */ + +#ifndef GL_EXT_multisampled_render_to_texture +#define GL_EXT_multisampled_render_to_texture 1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT 0x8D6C +#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 +#define GL_MAX_SAMPLES_EXT 0x8D57 +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleEXT (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glFramebufferTexture2DMultisampleEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); +#endif +#endif /* GL_EXT_multisampled_render_to_texture */ + +#ifndef GL_EXT_multisampled_render_to_texture2 +#define GL_EXT_multisampled_render_to_texture2 1 +#endif /* GL_EXT_multisampled_render_to_texture2 */ + +#ifndef GL_EXT_multiview_draw_buffers +#define GL_EXT_multiview_draw_buffers 1 +#define GL_COLOR_ATTACHMENT_EXT 0x90F0 +#define GL_MULTIVIEW_EXT 0x90F1 +#define GL_DRAW_BUFFER_EXT 0x0C01 +#define GL_READ_BUFFER_EXT 0x0C02 +#define GL_MAX_MULTIVIEW_BUFFERS_EXT 0x90F2 +typedef void (GL_APIENTRYP PFNGLREADBUFFERINDEXEDEXTPROC) (GLenum src, GLint index); +typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSINDEXEDEXTPROC) (GLint n, const GLenum *location, const GLint *indices); +typedef void (GL_APIENTRYP PFNGLGETINTEGERI_VEXTPROC) (GLenum target, GLuint index, GLint *data); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glReadBufferIndexedEXT (GLenum src, GLint index); +GL_APICALL void GL_APIENTRY glDrawBuffersIndexedEXT (GLint n, const GLenum *location, const GLint *indices); +GL_APICALL void GL_APIENTRY glGetIntegeri_vEXT (GLenum target, GLuint index, GLint *data); +#endif +#endif /* GL_EXT_multiview_draw_buffers */ + +#ifndef GL_EXT_multiview_tessellation_geometry_shader +#define GL_EXT_multiview_tessellation_geometry_shader 1 +#endif /* GL_EXT_multiview_tessellation_geometry_shader */ + +#ifndef GL_EXT_multiview_texture_multisample +#define GL_EXT_multiview_texture_multisample 1 +#endif /* GL_EXT_multiview_texture_multisample */ + +#ifndef GL_EXT_multiview_timer_query +#define GL_EXT_multiview_timer_query 1 +#endif /* GL_EXT_multiview_timer_query */ + +#ifndef GL_EXT_occlusion_query_boolean +#define GL_EXT_occlusion_query_boolean 1 +#define GL_ANY_SAMPLES_PASSED_EXT 0x8C2F +#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT 0x8D6A +#endif /* GL_EXT_occlusion_query_boolean */ + +#ifndef GL_EXT_polygon_offset_clamp +#define GL_EXT_polygon_offset_clamp 1 +#define GL_POLYGON_OFFSET_CLAMP_EXT 0x8E1B +typedef void (GL_APIENTRYP PFNGLPOLYGONOFFSETCLAMPEXTPROC) (GLfloat factor, GLfloat units, GLfloat clamp); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glPolygonOffsetClampEXT (GLfloat factor, GLfloat units, GLfloat clamp); +#endif +#endif /* GL_EXT_polygon_offset_clamp */ + +#ifndef GL_EXT_post_depth_coverage +#define GL_EXT_post_depth_coverage 1 +#endif /* GL_EXT_post_depth_coverage */ + +#ifndef GL_EXT_primitive_bounding_box +#define GL_EXT_primitive_bounding_box 1 +#define GL_PRIMITIVE_BOUNDING_BOX_EXT 0x92BE +typedef void (GL_APIENTRYP PFNGLPRIMITIVEBOUNDINGBOXEXTPROC) (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glPrimitiveBoundingBoxEXT (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW); +#endif +#endif /* GL_EXT_primitive_bounding_box */ + +#ifndef GL_EXT_protected_textures +#define GL_EXT_protected_textures 1 +#define GL_CONTEXT_FLAG_PROTECTED_CONTENT_BIT_EXT 0x00000010 +#define GL_TEXTURE_PROTECTED_EXT 0x8BFA +#endif /* GL_EXT_protected_textures */ + +#ifndef GL_EXT_pvrtc_sRGB +#define GL_EXT_pvrtc_sRGB 1 +#define GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT 0x8A54 +#define GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT 0x8A55 +#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT 0x8A56 +#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT 0x8A57 +#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV2_IMG 0x93F0 +#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV2_IMG 0x93F1 +#endif /* GL_EXT_pvrtc_sRGB */ + +#ifndef GL_EXT_raster_multisample +#define GL_EXT_raster_multisample 1 +#define GL_RASTER_MULTISAMPLE_EXT 0x9327 +#define GL_RASTER_SAMPLES_EXT 0x9328 +#define GL_MAX_RASTER_SAMPLES_EXT 0x9329 +#define GL_RASTER_FIXED_SAMPLE_LOCATIONS_EXT 0x932A +#define GL_MULTISAMPLE_RASTERIZATION_ALLOWED_EXT 0x932B +#define GL_EFFECTIVE_RASTER_SAMPLES_EXT 0x932C +typedef void (GL_APIENTRYP PFNGLRASTERSAMPLESEXTPROC) (GLuint samples, GLboolean fixedsamplelocations); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glRasterSamplesEXT (GLuint samples, GLboolean fixedsamplelocations); +#endif +#endif /* GL_EXT_raster_multisample */ + +#ifndef GL_EXT_read_format_bgra +#define GL_EXT_read_format_bgra 1 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT 0x8365 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT 0x8366 +#endif /* GL_EXT_read_format_bgra */ + +#ifndef GL_EXT_render_snorm +#define GL_EXT_render_snorm 1 +#define GL_R8_SNORM 0x8F94 +#define GL_RG8_SNORM 0x8F95 +#define GL_RGBA8_SNORM 0x8F97 +#define GL_R16_SNORM_EXT 0x8F98 +#define GL_RG16_SNORM_EXT 0x8F99 +#define GL_RGBA16_SNORM_EXT 0x8F9B +#endif /* GL_EXT_render_snorm */ + +#ifndef GL_EXT_robustness +#define GL_EXT_robustness 1 +#define GL_GUILTY_CONTEXT_RESET_EXT 0x8253 +#define GL_INNOCENT_CONTEXT_RESET_EXT 0x8254 +#define GL_UNKNOWN_CONTEXT_RESET_EXT 0x8255 +#define GL_CONTEXT_ROBUST_ACCESS_EXT 0x90F3 +#define GL_RESET_NOTIFICATION_STRATEGY_EXT 0x8256 +#define GL_LOSE_CONTEXT_ON_RESET_EXT 0x8252 +#define GL_NO_RESET_NOTIFICATION_EXT 0x8261 +typedef GLenum (GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSEXTPROC) (void); +typedef void (GL_APIENTRYP PFNGLREADNPIXELSEXTPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); +typedef void (GL_APIENTRYP PFNGLGETNUNIFORMFVEXTPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +typedef void (GL_APIENTRYP PFNGLGETNUNIFORMIVEXTPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL GLenum GL_APIENTRY glGetGraphicsResetStatusEXT (void); +GL_APICALL void GL_APIENTRY glReadnPixelsEXT (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); +GL_APICALL void GL_APIENTRY glGetnUniformfvEXT (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +GL_APICALL void GL_APIENTRY glGetnUniformivEXT (GLuint program, GLint location, GLsizei bufSize, GLint *params); +#endif +#endif /* GL_EXT_robustness */ + +#ifndef GL_EXT_sRGB +#define GL_EXT_sRGB 1 +#define GL_SRGB_EXT 0x8C40 +#define GL_SRGB_ALPHA_EXT 0x8C42 +#define GL_SRGB8_ALPHA8_EXT 0x8C43 +#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT 0x8210 +#endif /* GL_EXT_sRGB */ + +#ifndef GL_EXT_sRGB_write_control +#define GL_EXT_sRGB_write_control 1 +#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 +#endif /* GL_EXT_sRGB_write_control */ + +#ifndef GL_EXT_semaphore +#define GL_EXT_semaphore 1 +#define GL_LAYOUT_GENERAL_EXT 0x958D +#define GL_LAYOUT_COLOR_ATTACHMENT_EXT 0x958E +#define GL_LAYOUT_DEPTH_STENCIL_ATTACHMENT_EXT 0x958F +#define GL_LAYOUT_DEPTH_STENCIL_READ_ONLY_EXT 0x9590 +#define GL_LAYOUT_SHADER_READ_ONLY_EXT 0x9591 +#define GL_LAYOUT_TRANSFER_SRC_EXT 0x9592 +#define GL_LAYOUT_TRANSFER_DST_EXT 0x9593 +#define GL_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_EXT 0x9530 +#define GL_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_EXT 0x9531 +typedef void (GL_APIENTRYP PFNGLGENSEMAPHORESEXTPROC) (GLsizei n, GLuint *semaphores); +typedef void (GL_APIENTRYP PFNGLDELETESEMAPHORESEXTPROC) (GLsizei n, const GLuint *semaphores); +typedef GLboolean (GL_APIENTRYP PFNGLISSEMAPHOREEXTPROC) (GLuint semaphore); +typedef void (GL_APIENTRYP PFNGLSEMAPHOREPARAMETERUI64VEXTPROC) (GLuint semaphore, GLenum pname, const GLuint64 *params); +typedef void (GL_APIENTRYP PFNGLGETSEMAPHOREPARAMETERUI64VEXTPROC) (GLuint semaphore, GLenum pname, GLuint64 *params); +typedef void (GL_APIENTRYP PFNGLWAITSEMAPHOREEXTPROC) (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *srcLayouts); +typedef void (GL_APIENTRYP PFNGLSIGNALSEMAPHOREEXTPROC) (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *dstLayouts); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGenSemaphoresEXT (GLsizei n, GLuint *semaphores); +GL_APICALL void GL_APIENTRY glDeleteSemaphoresEXT (GLsizei n, const GLuint *semaphores); +GL_APICALL GLboolean GL_APIENTRY glIsSemaphoreEXT (GLuint semaphore); +GL_APICALL void GL_APIENTRY glSemaphoreParameterui64vEXT (GLuint semaphore, GLenum pname, const GLuint64 *params); +GL_APICALL void GL_APIENTRY glGetSemaphoreParameterui64vEXT (GLuint semaphore, GLenum pname, GLuint64 *params); +GL_APICALL void GL_APIENTRY glWaitSemaphoreEXT (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *srcLayouts); +GL_APICALL void GL_APIENTRY glSignalSemaphoreEXT (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *dstLayouts); +#endif +#endif /* GL_EXT_semaphore */ + +#ifndef GL_EXT_semaphore_fd +#define GL_EXT_semaphore_fd 1 +typedef void (GL_APIENTRYP PFNGLIMPORTSEMAPHOREFDEXTPROC) (GLuint semaphore, GLenum handleType, GLint fd); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glImportSemaphoreFdEXT (GLuint semaphore, GLenum handleType, GLint fd); +#endif +#endif /* GL_EXT_semaphore_fd */ + +#ifndef GL_EXT_semaphore_win32 +#define GL_EXT_semaphore_win32 1 +#define GL_HANDLE_TYPE_D3D12_FENCE_EXT 0x9594 +#define GL_D3D12_FENCE_VALUE_EXT 0x9595 +typedef void (GL_APIENTRYP PFNGLIMPORTSEMAPHOREWIN32HANDLEEXTPROC) (GLuint semaphore, GLenum handleType, void *handle); +typedef void (GL_APIENTRYP PFNGLIMPORTSEMAPHOREWIN32NAMEEXTPROC) (GLuint semaphore, GLenum handleType, const void *name); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glImportSemaphoreWin32HandleEXT (GLuint semaphore, GLenum handleType, void *handle); +GL_APICALL void GL_APIENTRY glImportSemaphoreWin32NameEXT (GLuint semaphore, GLenum handleType, const void *name); +#endif +#endif /* GL_EXT_semaphore_win32 */ + +#ifndef GL_EXT_separate_depth_stencil +#define GL_EXT_separate_depth_stencil 1 +#endif /* GL_EXT_separate_depth_stencil */ + +#ifndef GL_EXT_separate_shader_objects +#define GL_EXT_separate_shader_objects 1 +#define GL_ACTIVE_PROGRAM_EXT 0x8259 +#define GL_VERTEX_SHADER_BIT_EXT 0x00000001 +#define GL_FRAGMENT_SHADER_BIT_EXT 0x00000002 +#define GL_ALL_SHADER_BITS_EXT 0xFFFFFFFF +#define GL_PROGRAM_SEPARABLE_EXT 0x8258 +#define GL_PROGRAM_PIPELINE_BINDING_EXT 0x825A +typedef void (GL_APIENTRYP PFNGLACTIVESHADERPROGRAMEXTPROC) (GLuint pipeline, GLuint program); +typedef void (GL_APIENTRYP PFNGLBINDPROGRAMPIPELINEEXTPROC) (GLuint pipeline); +typedef GLuint (GL_APIENTRYP PFNGLCREATESHADERPROGRAMVEXTPROC) (GLenum type, GLsizei count, const GLchar **strings); +typedef void (GL_APIENTRYP PFNGLDELETEPROGRAMPIPELINESEXTPROC) (GLsizei n, const GLuint *pipelines); +typedef void (GL_APIENTRYP PFNGLGENPROGRAMPIPELINESEXTPROC) (GLsizei n, GLuint *pipelines); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGEXTPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMPIPELINEIVEXTPROC) (GLuint pipeline, GLenum pname, GLint *params); +typedef GLboolean (GL_APIENTRYP PFNGLISPROGRAMPIPELINEEXTPROC) (GLuint pipeline); +typedef void (GL_APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat v0); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint v0); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUSEPROGRAMSTAGESEXTPROC) (GLuint pipeline, GLbitfield stages, GLuint program); +typedef void (GL_APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEEXTPROC) (GLuint pipeline); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1UIEXTPROC) (GLuint program, GLint location, GLuint v0); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glActiveShaderProgramEXT (GLuint pipeline, GLuint program); +GL_APICALL void GL_APIENTRY glBindProgramPipelineEXT (GLuint pipeline); +GL_APICALL GLuint GL_APIENTRY glCreateShaderProgramvEXT (GLenum type, GLsizei count, const GLchar **strings); +GL_APICALL void GL_APIENTRY glDeleteProgramPipelinesEXT (GLsizei n, const GLuint *pipelines); +GL_APICALL void GL_APIENTRY glGenProgramPipelinesEXT (GLsizei n, GLuint *pipelines); +GL_APICALL void GL_APIENTRY glGetProgramPipelineInfoLogEXT (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GL_APICALL void GL_APIENTRY glGetProgramPipelineivEXT (GLuint pipeline, GLenum pname, GLint *params); +GL_APICALL GLboolean GL_APIENTRY glIsProgramPipelineEXT (GLuint pipeline); +GL_APICALL void GL_APIENTRY glProgramParameteriEXT (GLuint program, GLenum pname, GLint value); +GL_APICALL void GL_APIENTRY glProgramUniform1fEXT (GLuint program, GLint location, GLfloat v0); +GL_APICALL void GL_APIENTRY glProgramUniform1fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniform1iEXT (GLuint program, GLint location, GLint v0); +GL_APICALL void GL_APIENTRY glProgramUniform1ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glProgramUniform2fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1); +GL_APICALL void GL_APIENTRY glProgramUniform2fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniform2iEXT (GLuint program, GLint location, GLint v0, GLint v1); +GL_APICALL void GL_APIENTRY glProgramUniform2ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glProgramUniform3fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GL_APICALL void GL_APIENTRY glProgramUniform3fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniform3iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +GL_APICALL void GL_APIENTRY glProgramUniform3ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glProgramUniform4fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GL_APICALL void GL_APIENTRY glProgramUniform4fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniform4iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GL_APICALL void GL_APIENTRY glProgramUniform4ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUseProgramStagesEXT (GLuint pipeline, GLbitfield stages, GLuint program); +GL_APICALL void GL_APIENTRY glValidateProgramPipelineEXT (GLuint pipeline); +GL_APICALL void GL_APIENTRY glProgramUniform1uiEXT (GLuint program, GLint location, GLuint v0); +GL_APICALL void GL_APIENTRY glProgramUniform2uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1); +GL_APICALL void GL_APIENTRY glProgramUniform3uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +GL_APICALL void GL_APIENTRY glProgramUniform4uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GL_APICALL void GL_APIENTRY glProgramUniform1uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glProgramUniform2uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glProgramUniform3uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glProgramUniform4uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix2x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix3x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix2x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix4x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix3x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix4x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#endif +#endif /* GL_EXT_separate_shader_objects */ + +#ifndef GL_EXT_shader_framebuffer_fetch +#define GL_EXT_shader_framebuffer_fetch 1 +#define GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT 0x8A52 +#endif /* GL_EXT_shader_framebuffer_fetch */ + +#ifndef GL_EXT_shader_framebuffer_fetch_non_coherent +#define GL_EXT_shader_framebuffer_fetch_non_coherent 1 +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERFETCHBARRIEREXTPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glFramebufferFetchBarrierEXT (void); +#endif +#endif /* GL_EXT_shader_framebuffer_fetch_non_coherent */ + +#ifndef GL_EXT_shader_group_vote +#define GL_EXT_shader_group_vote 1 +#endif /* GL_EXT_shader_group_vote */ + +#ifndef GL_EXT_shader_implicit_conversions +#define GL_EXT_shader_implicit_conversions 1 +#endif /* GL_EXT_shader_implicit_conversions */ + +#ifndef GL_EXT_shader_integer_mix +#define GL_EXT_shader_integer_mix 1 +#endif /* GL_EXT_shader_integer_mix */ + +#ifndef GL_EXT_shader_io_blocks +#define GL_EXT_shader_io_blocks 1 +#endif /* GL_EXT_shader_io_blocks */ + +#ifndef GL_EXT_shader_non_constant_global_initializers +#define GL_EXT_shader_non_constant_global_initializers 1 +#endif /* GL_EXT_shader_non_constant_global_initializers */ + +#ifndef GL_EXT_shader_pixel_local_storage +#define GL_EXT_shader_pixel_local_storage 1 +#define GL_MAX_SHADER_PIXEL_LOCAL_STORAGE_FAST_SIZE_EXT 0x8F63 +#define GL_MAX_SHADER_PIXEL_LOCAL_STORAGE_SIZE_EXT 0x8F67 +#define GL_SHADER_PIXEL_LOCAL_STORAGE_EXT 0x8F64 +#endif /* GL_EXT_shader_pixel_local_storage */ + +#ifndef GL_EXT_shader_pixel_local_storage2 +#define GL_EXT_shader_pixel_local_storage2 1 +#define GL_MAX_SHADER_COMBINED_LOCAL_STORAGE_FAST_SIZE_EXT 0x9650 +#define GL_MAX_SHADER_COMBINED_LOCAL_STORAGE_SIZE_EXT 0x9651 +#define GL_FRAMEBUFFER_INCOMPLETE_INSUFFICIENT_SHADER_COMBINED_LOCAL_STORAGE_EXT 0x9652 +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERPIXELLOCALSTORAGESIZEEXTPROC) (GLuint target, GLsizei size); +typedef GLsizei (GL_APIENTRYP PFNGLGETFRAMEBUFFERPIXELLOCALSTORAGESIZEEXTPROC) (GLuint target); +typedef void (GL_APIENTRYP PFNGLCLEARPIXELLOCALSTORAGEUIEXTPROC) (GLsizei offset, GLsizei n, const GLuint *values); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glFramebufferPixelLocalStorageSizeEXT (GLuint target, GLsizei size); +GL_APICALL GLsizei GL_APIENTRY glGetFramebufferPixelLocalStorageSizeEXT (GLuint target); +GL_APICALL void GL_APIENTRY glClearPixelLocalStorageuiEXT (GLsizei offset, GLsizei n, const GLuint *values); +#endif +#endif /* GL_EXT_shader_pixel_local_storage2 */ + +#ifndef GL_EXT_shader_samples_identical +#define GL_EXT_shader_samples_identical 1 +#endif /* GL_EXT_shader_samples_identical */ + +#ifndef GL_EXT_shader_texture_lod +#define GL_EXT_shader_texture_lod 1 +#endif /* GL_EXT_shader_texture_lod */ + +#ifndef GL_EXT_shadow_samplers +#define GL_EXT_shadow_samplers 1 +#define GL_TEXTURE_COMPARE_MODE_EXT 0x884C +#define GL_TEXTURE_COMPARE_FUNC_EXT 0x884D +#define GL_COMPARE_REF_TO_TEXTURE_EXT 0x884E +#define GL_SAMPLER_2D_SHADOW_EXT 0x8B62 +#endif /* GL_EXT_shadow_samplers */ + +#ifndef GL_EXT_sparse_texture +#define GL_EXT_sparse_texture 1 +#define GL_TEXTURE_SPARSE_EXT 0x91A6 +#define GL_VIRTUAL_PAGE_SIZE_INDEX_EXT 0x91A7 +#define GL_NUM_SPARSE_LEVELS_EXT 0x91AA +#define GL_NUM_VIRTUAL_PAGE_SIZES_EXT 0x91A8 +#define GL_VIRTUAL_PAGE_SIZE_X_EXT 0x9195 +#define GL_VIRTUAL_PAGE_SIZE_Y_EXT 0x9196 +#define GL_VIRTUAL_PAGE_SIZE_Z_EXT 0x9197 +#define GL_TEXTURE_2D_ARRAY 0x8C1A +#define GL_TEXTURE_3D 0x806F +#define GL_MAX_SPARSE_TEXTURE_SIZE_EXT 0x9198 +#define GL_MAX_SPARSE_3D_TEXTURE_SIZE_EXT 0x9199 +#define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS_EXT 0x919A +#define GL_SPARSE_TEXTURE_FULL_ARRAY_CUBE_MIPMAPS_EXT 0x91A9 +typedef void (GL_APIENTRYP PFNGLTEXPAGECOMMITMENTEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glTexPageCommitmentEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); +#endif +#endif /* GL_EXT_sparse_texture */ + +#ifndef GL_EXT_sparse_texture2 +#define GL_EXT_sparse_texture2 1 +#endif /* GL_EXT_sparse_texture2 */ + +#ifndef GL_EXT_tessellation_point_size +#define GL_EXT_tessellation_point_size 1 +#endif /* GL_EXT_tessellation_point_size */ + +#ifndef GL_EXT_tessellation_shader +#define GL_EXT_tessellation_shader 1 +#define GL_PATCHES_EXT 0x000E +#define GL_PATCH_VERTICES_EXT 0x8E72 +#define GL_TESS_CONTROL_OUTPUT_VERTICES_EXT 0x8E75 +#define GL_TESS_GEN_MODE_EXT 0x8E76 +#define GL_TESS_GEN_SPACING_EXT 0x8E77 +#define GL_TESS_GEN_VERTEX_ORDER_EXT 0x8E78 +#define GL_TESS_GEN_POINT_MODE_EXT 0x8E79 +#define GL_ISOLINES_EXT 0x8E7A +#define GL_QUADS_EXT 0x0007 +#define GL_FRACTIONAL_ODD_EXT 0x8E7B +#define GL_FRACTIONAL_EVEN_EXT 0x8E7C +#define GL_MAX_PATCH_VERTICES_EXT 0x8E7D +#define GL_MAX_TESS_GEN_LEVEL_EXT 0x8E7E +#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS_EXT 0x8E7F +#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS_EXT 0x8E80 +#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS_EXT 0x8E81 +#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS_EXT 0x8E82 +#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS_EXT 0x8E83 +#define GL_MAX_TESS_PATCH_COMPONENTS_EXT 0x8E84 +#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS_EXT 0x8E85 +#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS_EXT 0x8E86 +#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS_EXT 0x8E89 +#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS_EXT 0x8E8A +#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS_EXT 0x886C +#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS_EXT 0x886D +#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS_EXT 0x8E1E +#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS_EXT 0x8E1F +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS_EXT 0x92CD +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS_EXT 0x92CE +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS_EXT 0x92D3 +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS_EXT 0x92D4 +#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS_EXT 0x90CB +#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS_EXT 0x90CC +#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS_EXT 0x90D8 +#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS_EXT 0x90D9 +#define GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED 0x8221 +#define GL_IS_PER_PATCH_EXT 0x92E7 +#define GL_REFERENCED_BY_TESS_CONTROL_SHADER_EXT 0x9307 +#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER_EXT 0x9308 +#define GL_TESS_CONTROL_SHADER_EXT 0x8E88 +#define GL_TESS_EVALUATION_SHADER_EXT 0x8E87 +#define GL_TESS_CONTROL_SHADER_BIT_EXT 0x00000008 +#define GL_TESS_EVALUATION_SHADER_BIT_EXT 0x00000010 +typedef void (GL_APIENTRYP PFNGLPATCHPARAMETERIEXTPROC) (GLenum pname, GLint value); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glPatchParameteriEXT (GLenum pname, GLint value); +#endif +#endif /* GL_EXT_tessellation_shader */ + +#ifndef GL_EXT_texture_border_clamp +#define GL_EXT_texture_border_clamp 1 +#define GL_TEXTURE_BORDER_COLOR_EXT 0x1004 +#define GL_CLAMP_TO_BORDER_EXT 0x812D +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params); +typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params); +typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERIIVEXTPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERIUIVEXTPROC) (GLuint sampler, GLenum pname, const GLuint *param); +typedef void (GL_APIENTRYP PFNGLGETSAMPLERPARAMETERIIVEXTPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVEXTPROC) (GLuint sampler, GLenum pname, GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glTexParameterIivEXT (GLenum target, GLenum pname, const GLint *params); +GL_APICALL void GL_APIENTRY glTexParameterIuivEXT (GLenum target, GLenum pname, const GLuint *params); +GL_APICALL void GL_APIENTRY glGetTexParameterIivEXT (GLenum target, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetTexParameterIuivEXT (GLenum target, GLenum pname, GLuint *params); +GL_APICALL void GL_APIENTRY glSamplerParameterIivEXT (GLuint sampler, GLenum pname, const GLint *param); +GL_APICALL void GL_APIENTRY glSamplerParameterIuivEXT (GLuint sampler, GLenum pname, const GLuint *param); +GL_APICALL void GL_APIENTRY glGetSamplerParameterIivEXT (GLuint sampler, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetSamplerParameterIuivEXT (GLuint sampler, GLenum pname, GLuint *params); +#endif +#endif /* GL_EXT_texture_border_clamp */ + +#ifndef GL_EXT_texture_buffer +#define GL_EXT_texture_buffer 1 +#define GL_TEXTURE_BUFFER_EXT 0x8C2A +#define GL_TEXTURE_BUFFER_BINDING_EXT 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D +#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT_EXT 0x919F +#define GL_SAMPLER_BUFFER_EXT 0x8DC2 +#define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8 +#define GL_IMAGE_BUFFER_EXT 0x9051 +#define GL_INT_IMAGE_BUFFER_EXT 0x905C +#define GL_UNSIGNED_INT_IMAGE_BUFFER_EXT 0x9067 +#define GL_TEXTURE_BUFFER_OFFSET_EXT 0x919D +#define GL_TEXTURE_BUFFER_SIZE_EXT 0x919E +typedef void (GL_APIENTRYP PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer); +typedef void (GL_APIENTRYP PFNGLTEXBUFFERRANGEEXTPROC) (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glTexBufferEXT (GLenum target, GLenum internalformat, GLuint buffer); +GL_APICALL void GL_APIENTRY glTexBufferRangeEXT (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +#endif +#endif /* GL_EXT_texture_buffer */ + +#ifndef GL_EXT_texture_compression_astc_decode_mode +#define GL_EXT_texture_compression_astc_decode_mode 1 +#define GL_TEXTURE_ASTC_DECODE_PRECISION_EXT 0x8F69 +#endif /* GL_EXT_texture_compression_astc_decode_mode */ + +#ifndef GL_EXT_texture_compression_bptc +#define GL_EXT_texture_compression_bptc 1 +#define GL_COMPRESSED_RGBA_BPTC_UNORM_EXT 0x8E8C +#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT 0x8E8D +#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT 0x8E8E +#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT 0x8E8F +#endif /* GL_EXT_texture_compression_bptc */ + +#ifndef GL_EXT_texture_compression_dxt1 +#define GL_EXT_texture_compression_dxt1 1 +#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 +#endif /* GL_EXT_texture_compression_dxt1 */ + +#ifndef GL_EXT_texture_compression_rgtc +#define GL_EXT_texture_compression_rgtc 1 +#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC +#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD +#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE +#endif /* GL_EXT_texture_compression_rgtc */ + +#ifndef GL_EXT_texture_compression_s3tc +#define GL_EXT_texture_compression_s3tc 1 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 +#endif /* GL_EXT_texture_compression_s3tc */ + +#ifndef GL_EXT_texture_compression_s3tc_srgb +#define GL_EXT_texture_compression_s3tc_srgb 1 +#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F +#endif /* GL_EXT_texture_compression_s3tc_srgb */ + +#ifndef GL_EXT_texture_cube_map_array +#define GL_EXT_texture_cube_map_array 1 +#define GL_TEXTURE_CUBE_MAP_ARRAY_EXT 0x9009 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_EXT 0x900A +#define GL_SAMPLER_CUBE_MAP_ARRAY_EXT 0x900C +#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_EXT 0x900D +#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_EXT 0x900E +#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_EXT 0x900F +#define GL_IMAGE_CUBE_MAP_ARRAY_EXT 0x9054 +#define GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x905F +#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x906A +#endif /* GL_EXT_texture_cube_map_array */ + +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_EXT_texture_filter_anisotropic 1 +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF +#endif /* GL_EXT_texture_filter_anisotropic */ + +#ifndef GL_EXT_texture_filter_minmax +#define GL_EXT_texture_filter_minmax 1 +#define GL_TEXTURE_REDUCTION_MODE_EXT 0x9366 +#define GL_WEIGHTED_AVERAGE_EXT 0x9367 +#endif /* GL_EXT_texture_filter_minmax */ + +#ifndef GL_EXT_texture_format_BGRA8888 +#define GL_EXT_texture_format_BGRA8888 1 +#endif /* GL_EXT_texture_format_BGRA8888 */ + +#ifndef GL_EXT_texture_format_sRGB_override +#define GL_EXT_texture_format_sRGB_override 1 +#define GL_TEXTURE_FORMAT_SRGB_OVERRIDE_EXT 0x8FBF +#endif /* GL_EXT_texture_format_sRGB_override */ + +#ifndef GL_EXT_texture_mirror_clamp_to_edge +#define GL_EXT_texture_mirror_clamp_to_edge 1 +#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 +#endif /* GL_EXT_texture_mirror_clamp_to_edge */ + +#ifndef GL_EXT_texture_norm16 +#define GL_EXT_texture_norm16 1 +#define GL_R16_EXT 0x822A +#define GL_RG16_EXT 0x822C +#define GL_RGBA16_EXT 0x805B +#define GL_RGB16_EXT 0x8054 +#define GL_RGB16_SNORM_EXT 0x8F9A +#endif /* GL_EXT_texture_norm16 */ + +#ifndef GL_EXT_texture_query_lod +#define GL_EXT_texture_query_lod 1 +#endif /* GL_EXT_texture_query_lod */ + +#ifndef GL_EXT_texture_rg +#define GL_EXT_texture_rg 1 +#define GL_RED_EXT 0x1903 +#define GL_RG_EXT 0x8227 +#define GL_R8_EXT 0x8229 +#define GL_RG8_EXT 0x822B +#endif /* GL_EXT_texture_rg */ + +#ifndef GL_EXT_texture_sRGB_R8 +#define GL_EXT_texture_sRGB_R8 1 +#define GL_SR8_EXT 0x8FBD +#endif /* GL_EXT_texture_sRGB_R8 */ + +#ifndef GL_EXT_texture_sRGB_RG8 +#define GL_EXT_texture_sRGB_RG8 1 +#define GL_SRG8_EXT 0x8FBE +#endif /* GL_EXT_texture_sRGB_RG8 */ + +#ifndef GL_EXT_texture_sRGB_decode +#define GL_EXT_texture_sRGB_decode 1 +#define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48 +#define GL_DECODE_EXT 0x8A49 +#define GL_SKIP_DECODE_EXT 0x8A4A +#endif /* GL_EXT_texture_sRGB_decode */ + +#ifndef GL_EXT_texture_shadow_lod +#define GL_EXT_texture_shadow_lod 1 +#endif /* GL_EXT_texture_shadow_lod */ + +#ifndef GL_EXT_texture_storage +#define GL_EXT_texture_storage 1 +#define GL_TEXTURE_IMMUTABLE_FORMAT_EXT 0x912F +#define GL_ALPHA8_EXT 0x803C +#define GL_LUMINANCE8_EXT 0x8040 +#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 +#define GL_RGBA32F_EXT 0x8814 +#define GL_RGB32F_EXT 0x8815 +#define GL_ALPHA32F_EXT 0x8816 +#define GL_LUMINANCE32F_EXT 0x8818 +#define GL_LUMINANCE_ALPHA32F_EXT 0x8819 +#define GL_ALPHA16F_EXT 0x881C +#define GL_LUMINANCE16F_EXT 0x881E +#define GL_LUMINANCE_ALPHA16F_EXT 0x881F +#define GL_R32F_EXT 0x822E +#define GL_RG32F_EXT 0x8230 +typedef void (GL_APIENTRYP PFNGLTEXSTORAGE1DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (GL_APIENTRYP PFNGLTEXSTORAGE2DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLTEXSTORAGE3DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glTexStorage1DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +GL_APICALL void GL_APIENTRY glTexStorage2DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glTexStorage3DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +GL_APICALL void GL_APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +GL_APICALL void GL_APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +#endif +#endif /* GL_EXT_texture_storage */ + +#ifndef GL_EXT_texture_storage_compression +#define GL_EXT_texture_storage_compression 1 +#define GL_NUM_SURFACE_COMPRESSION_FIXED_RATES_EXT 0x8F6E +#define GL_SURFACE_COMPRESSION_FIXED_RATE_1BPC_EXT 0x96C4 +#define GL_SURFACE_COMPRESSION_FIXED_RATE_2BPC_EXT 0x96C5 +#define GL_SURFACE_COMPRESSION_FIXED_RATE_3BPC_EXT 0x96C6 +#define GL_SURFACE_COMPRESSION_FIXED_RATE_4BPC_EXT 0x96C7 +#define GL_SURFACE_COMPRESSION_FIXED_RATE_5BPC_EXT 0x96C8 +#define GL_SURFACE_COMPRESSION_FIXED_RATE_6BPC_EXT 0x96C9 +#define GL_SURFACE_COMPRESSION_FIXED_RATE_7BPC_EXT 0x96CA +#define GL_SURFACE_COMPRESSION_FIXED_RATE_8BPC_EXT 0x96CB +#define GL_SURFACE_COMPRESSION_FIXED_RATE_9BPC_EXT 0x96CC +#define GL_SURFACE_COMPRESSION_FIXED_RATE_10BPC_EXT 0x96CD +#define GL_SURFACE_COMPRESSION_FIXED_RATE_11BPC_EXT 0x96CE +#define GL_SURFACE_COMPRESSION_FIXED_RATE_12BPC_EXT 0x96CF +typedef void (GL_APIENTRYP PFNGLTEXSTORAGEATTRIBS2DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, const GLint* attrib_list); +typedef void (GL_APIENTRYP PFNGLTEXSTORAGEATTRIBS3DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, const GLint* attrib_list); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glTexStorageAttribs2DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, const GLint* attrib_list); +GL_APICALL void GL_APIENTRY glTexStorageAttribs3DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, const GLint* attrib_list); +#endif +#endif /* GL_EXT_texture_storage_compression */ + +#ifndef GL_EXT_texture_type_2_10_10_10_REV +#define GL_EXT_texture_type_2_10_10_10_REV 1 +#define GL_UNSIGNED_INT_2_10_10_10_REV_EXT 0x8368 +#endif /* GL_EXT_texture_type_2_10_10_10_REV */ + +#ifndef GL_EXT_texture_view +#define GL_EXT_texture_view 1 +#define GL_TEXTURE_VIEW_MIN_LEVEL_EXT 0x82DB +#define GL_TEXTURE_VIEW_NUM_LEVELS_EXT 0x82DC +#define GL_TEXTURE_VIEW_MIN_LAYER_EXT 0x82DD +#define GL_TEXTURE_VIEW_NUM_LAYERS_EXT 0x82DE +typedef void (GL_APIENTRYP PFNGLTEXTUREVIEWEXTPROC) (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glTextureViewEXT (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); +#endif +#endif /* GL_EXT_texture_view */ + +#ifndef GL_EXT_unpack_subimage +#define GL_EXT_unpack_subimage 1 +#define GL_UNPACK_ROW_LENGTH_EXT 0x0CF2 +#define GL_UNPACK_SKIP_ROWS_EXT 0x0CF3 +#define GL_UNPACK_SKIP_PIXELS_EXT 0x0CF4 +#endif /* GL_EXT_unpack_subimage */ + +#ifndef GL_EXT_win32_keyed_mutex +#define GL_EXT_win32_keyed_mutex 1 +typedef GLboolean (GL_APIENTRYP PFNGLACQUIREKEYEDMUTEXWIN32EXTPROC) (GLuint memory, GLuint64 key, GLuint timeout); +typedef GLboolean (GL_APIENTRYP PFNGLRELEASEKEYEDMUTEXWIN32EXTPROC) (GLuint memory, GLuint64 key); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL GLboolean GL_APIENTRY glAcquireKeyedMutexWin32EXT (GLuint memory, GLuint64 key, GLuint timeout); +GL_APICALL GLboolean GL_APIENTRY glReleaseKeyedMutexWin32EXT (GLuint memory, GLuint64 key); +#endif +#endif /* GL_EXT_win32_keyed_mutex */ + +#ifndef GL_EXT_window_rectangles +#define GL_EXT_window_rectangles 1 +#define GL_INCLUSIVE_EXT 0x8F10 +#define GL_EXCLUSIVE_EXT 0x8F11 +#define GL_WINDOW_RECTANGLE_EXT 0x8F12 +#define GL_WINDOW_RECTANGLE_MODE_EXT 0x8F13 +#define GL_MAX_WINDOW_RECTANGLES_EXT 0x8F14 +#define GL_NUM_WINDOW_RECTANGLES_EXT 0x8F15 +typedef void (GL_APIENTRYP PFNGLWINDOWRECTANGLESEXTPROC) (GLenum mode, GLsizei count, const GLint *box); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glWindowRectanglesEXT (GLenum mode, GLsizei count, const GLint *box); +#endif +#endif /* GL_EXT_window_rectangles */ + +#ifndef GL_FJ_shader_binary_GCCSO +#define GL_FJ_shader_binary_GCCSO 1 +#define GL_GCCSO_SHADER_BINARY_FJ 0x9260 +#endif /* GL_FJ_shader_binary_GCCSO */ + +#ifndef GL_IMG_bindless_texture +#define GL_IMG_bindless_texture 1 +typedef GLuint64 (GL_APIENTRYP PFNGLGETTEXTUREHANDLEIMGPROC) (GLuint texture); +typedef GLuint64 (GL_APIENTRYP PFNGLGETTEXTURESAMPLERHANDLEIMGPROC) (GLuint texture, GLuint sampler); +typedef void (GL_APIENTRYP PFNGLUNIFORMHANDLEUI64IMGPROC) (GLint location, GLuint64 value); +typedef void (GL_APIENTRYP PFNGLUNIFORMHANDLEUI64VIMGPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64IMGPROC) (GLuint program, GLint location, GLuint64 value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VIMGPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL GLuint64 GL_APIENTRY glGetTextureHandleIMG (GLuint texture); +GL_APICALL GLuint64 GL_APIENTRY glGetTextureSamplerHandleIMG (GLuint texture, GLuint sampler); +GL_APICALL void GL_APIENTRY glUniformHandleui64IMG (GLint location, GLuint64 value); +GL_APICALL void GL_APIENTRY glUniformHandleui64vIMG (GLint location, GLsizei count, const GLuint64 *value); +GL_APICALL void GL_APIENTRY glProgramUniformHandleui64IMG (GLuint program, GLint location, GLuint64 value); +GL_APICALL void GL_APIENTRY glProgramUniformHandleui64vIMG (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +#endif +#endif /* GL_IMG_bindless_texture */ + +#ifndef GL_IMG_framebuffer_downsample +#define GL_IMG_framebuffer_downsample 1 +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_AND_DOWNSAMPLE_IMG 0x913C +#define GL_NUM_DOWNSAMPLE_SCALES_IMG 0x913D +#define GL_DOWNSAMPLE_SCALES_IMG 0x913E +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SCALE_IMG 0x913F +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DDOWNSAMPLEIMGPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint xscale, GLint yscale); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERDOWNSAMPLEIMGPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer, GLint xscale, GLint yscale); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glFramebufferTexture2DDownsampleIMG (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint xscale, GLint yscale); +GL_APICALL void GL_APIENTRY glFramebufferTextureLayerDownsampleIMG (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer, GLint xscale, GLint yscale); +#endif +#endif /* GL_IMG_framebuffer_downsample */ + +#ifndef GL_IMG_multisampled_render_to_texture +#define GL_IMG_multisampled_render_to_texture 1 +#define GL_RENDERBUFFER_SAMPLES_IMG 0x9133 +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG 0x9134 +#define GL_MAX_SAMPLES_IMG 0x9135 +#define GL_TEXTURE_SAMPLES_IMG 0x9136 +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMGPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMGPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleIMG (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glFramebufferTexture2DMultisampleIMG (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); +#endif +#endif /* GL_IMG_multisampled_render_to_texture */ + +#ifndef GL_IMG_program_binary +#define GL_IMG_program_binary 1 +#define GL_SGX_PROGRAM_BINARY_IMG 0x9130 +#endif /* GL_IMG_program_binary */ + +#ifndef GL_IMG_read_format +#define GL_IMG_read_format 1 +#define GL_BGRA_IMG 0x80E1 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV_IMG 0x8365 +#endif /* GL_IMG_read_format */ + +#ifndef GL_IMG_shader_binary +#define GL_IMG_shader_binary 1 +#define GL_SGX_BINARY_IMG 0x8C0A +#endif /* GL_IMG_shader_binary */ + +#ifndef GL_IMG_texture_compression_pvrtc +#define GL_IMG_texture_compression_pvrtc 1 +#define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00 +#define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01 +#define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02 +#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03 +#endif /* GL_IMG_texture_compression_pvrtc */ + +#ifndef GL_IMG_texture_compression_pvrtc2 +#define GL_IMG_texture_compression_pvrtc2 1 +#define GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG 0x9137 +#define GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG 0x9138 +#endif /* GL_IMG_texture_compression_pvrtc2 */ + +#ifndef GL_IMG_texture_filter_cubic +#define GL_IMG_texture_filter_cubic 1 +#define GL_CUBIC_IMG 0x9139 +#define GL_CUBIC_MIPMAP_NEAREST_IMG 0x913A +#define GL_CUBIC_MIPMAP_LINEAR_IMG 0x913B +#endif /* GL_IMG_texture_filter_cubic */ + +#ifndef GL_INTEL_blackhole_render +#define GL_INTEL_blackhole_render 1 +#define GL_BLACKHOLE_RENDER_INTEL 0x83FC +#endif /* GL_INTEL_blackhole_render */ + +#ifndef GL_INTEL_conservative_rasterization +#define GL_INTEL_conservative_rasterization 1 +#define GL_CONSERVATIVE_RASTERIZATION_INTEL 0x83FE +#endif /* GL_INTEL_conservative_rasterization */ + +#ifndef GL_INTEL_framebuffer_CMAA +#define GL_INTEL_framebuffer_CMAA 1 +typedef void (GL_APIENTRYP PFNGLAPPLYFRAMEBUFFERATTACHMENTCMAAINTELPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glApplyFramebufferAttachmentCMAAINTEL (void); +#endif +#endif /* GL_INTEL_framebuffer_CMAA */ + +#ifndef GL_INTEL_performance_query +#define GL_INTEL_performance_query 1 +#define GL_PERFQUERY_SINGLE_CONTEXT_INTEL 0x00000000 +#define GL_PERFQUERY_GLOBAL_CONTEXT_INTEL 0x00000001 +#define GL_PERFQUERY_WAIT_INTEL 0x83FB +#define GL_PERFQUERY_FLUSH_INTEL 0x83FA +#define GL_PERFQUERY_DONOT_FLUSH_INTEL 0x83F9 +#define GL_PERFQUERY_COUNTER_EVENT_INTEL 0x94F0 +#define GL_PERFQUERY_COUNTER_DURATION_NORM_INTEL 0x94F1 +#define GL_PERFQUERY_COUNTER_DURATION_RAW_INTEL 0x94F2 +#define GL_PERFQUERY_COUNTER_THROUGHPUT_INTEL 0x94F3 +#define GL_PERFQUERY_COUNTER_RAW_INTEL 0x94F4 +#define GL_PERFQUERY_COUNTER_TIMESTAMP_INTEL 0x94F5 +#define GL_PERFQUERY_COUNTER_DATA_UINT32_INTEL 0x94F8 +#define GL_PERFQUERY_COUNTER_DATA_UINT64_INTEL 0x94F9 +#define GL_PERFQUERY_COUNTER_DATA_FLOAT_INTEL 0x94FA +#define GL_PERFQUERY_COUNTER_DATA_DOUBLE_INTEL 0x94FB +#define GL_PERFQUERY_COUNTER_DATA_BOOL32_INTEL 0x94FC +#define GL_PERFQUERY_QUERY_NAME_LENGTH_MAX_INTEL 0x94FD +#define GL_PERFQUERY_COUNTER_NAME_LENGTH_MAX_INTEL 0x94FE +#define GL_PERFQUERY_COUNTER_DESC_LENGTH_MAX_INTEL 0x94FF +#define GL_PERFQUERY_GPA_EXTENDED_COUNTERS_INTEL 0x9500 +typedef void (GL_APIENTRYP PFNGLBEGINPERFQUERYINTELPROC) (GLuint queryHandle); +typedef void (GL_APIENTRYP PFNGLCREATEPERFQUERYINTELPROC) (GLuint queryId, GLuint *queryHandle); +typedef void (GL_APIENTRYP PFNGLDELETEPERFQUERYINTELPROC) (GLuint queryHandle); +typedef void (GL_APIENTRYP PFNGLENDPERFQUERYINTELPROC) (GLuint queryHandle); +typedef void (GL_APIENTRYP PFNGLGETFIRSTPERFQUERYIDINTELPROC) (GLuint *queryId); +typedef void (GL_APIENTRYP PFNGLGETNEXTPERFQUERYIDINTELPROC) (GLuint queryId, GLuint *nextQueryId); +typedef void (GL_APIENTRYP PFNGLGETPERFCOUNTERINFOINTELPROC) (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); +typedef void (GL_APIENTRYP PFNGLGETPERFQUERYDATAINTELPROC) (GLuint queryHandle, GLuint flags, GLsizei dataSize, void *data, GLuint *bytesWritten); +typedef void (GL_APIENTRYP PFNGLGETPERFQUERYIDBYNAMEINTELPROC) (GLchar *queryName, GLuint *queryId); +typedef void (GL_APIENTRYP PFNGLGETPERFQUERYINFOINTELPROC) (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glBeginPerfQueryINTEL (GLuint queryHandle); +GL_APICALL void GL_APIENTRY glCreatePerfQueryINTEL (GLuint queryId, GLuint *queryHandle); +GL_APICALL void GL_APIENTRY glDeletePerfQueryINTEL (GLuint queryHandle); +GL_APICALL void GL_APIENTRY glEndPerfQueryINTEL (GLuint queryHandle); +GL_APICALL void GL_APIENTRY glGetFirstPerfQueryIdINTEL (GLuint *queryId); +GL_APICALL void GL_APIENTRY glGetNextPerfQueryIdINTEL (GLuint queryId, GLuint *nextQueryId); +GL_APICALL void GL_APIENTRY glGetPerfCounterInfoINTEL (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); +GL_APICALL void GL_APIENTRY glGetPerfQueryDataINTEL (GLuint queryHandle, GLuint flags, GLsizei dataSize, void *data, GLuint *bytesWritten); +GL_APICALL void GL_APIENTRY glGetPerfQueryIdByNameINTEL (GLchar *queryName, GLuint *queryId); +GL_APICALL void GL_APIENTRY glGetPerfQueryInfoINTEL (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); +#endif +#endif /* GL_INTEL_performance_query */ + +#ifndef GL_MESA_bgra +#define GL_MESA_bgra 1 +#define GL_BGR_EXT 0x80E0 +#endif /* GL_MESA_bgra */ + +#ifndef GL_MESA_framebuffer_flip_x +#define GL_MESA_framebuffer_flip_x 1 +#define GL_FRAMEBUFFER_FLIP_X_MESA 0x8BBC +#endif /* GL_MESA_framebuffer_flip_x */ + +#ifndef GL_MESA_framebuffer_flip_y +#define GL_MESA_framebuffer_flip_y 1 +#define GL_FRAMEBUFFER_FLIP_Y_MESA 0x8BBB +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERPARAMETERIMESAPROC) (GLenum target, GLenum pname, GLint param); +typedef void (GL_APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVMESAPROC) (GLenum target, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glFramebufferParameteriMESA (GLenum target, GLenum pname, GLint param); +GL_APICALL void GL_APIENTRY glGetFramebufferParameterivMESA (GLenum target, GLenum pname, GLint *params); +#endif +#endif /* GL_MESA_framebuffer_flip_y */ + +#ifndef GL_MESA_framebuffer_swap_xy +#define GL_MESA_framebuffer_swap_xy 1 +#define GL_FRAMEBUFFER_SWAP_XY_MESA 0x8BBD +#endif /* GL_MESA_framebuffer_swap_xy */ + +#ifndef GL_MESA_program_binary_formats +#define GL_MESA_program_binary_formats 1 +#define GL_PROGRAM_BINARY_FORMAT_MESA 0x875F +#endif /* GL_MESA_program_binary_formats */ + +#ifndef GL_MESA_shader_integer_functions +#define GL_MESA_shader_integer_functions 1 +#endif /* GL_MESA_shader_integer_functions */ + +#ifndef GL_NVX_blend_equation_advanced_multi_draw_buffers +#define GL_NVX_blend_equation_advanced_multi_draw_buffers 1 +#endif /* GL_NVX_blend_equation_advanced_multi_draw_buffers */ + +#ifndef GL_NV_bindless_texture +#define GL_NV_bindless_texture 1 +typedef GLuint64 (GL_APIENTRYP PFNGLGETTEXTUREHANDLENVPROC) (GLuint texture); +typedef GLuint64 (GL_APIENTRYP PFNGLGETTEXTURESAMPLERHANDLENVPROC) (GLuint texture, GLuint sampler); +typedef void (GL_APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); +typedef void (GL_APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTNVPROC) (GLuint64 handle); +typedef GLuint64 (GL_APIENTRYP PFNGLGETIMAGEHANDLENVPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +typedef void (GL_APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle, GLenum access); +typedef void (GL_APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTNVPROC) (GLuint64 handle); +typedef void (GL_APIENTRYP PFNGLUNIFORMHANDLEUI64NVPROC) (GLint location, GLuint64 value); +typedef void (GL_APIENTRYP PFNGLUNIFORMHANDLEUI64VNVPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64NVPROC) (GLuint program, GLint location, GLuint64 value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +typedef GLboolean (GL_APIENTRYP PFNGLISTEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); +typedef GLboolean (GL_APIENTRYP PFNGLISIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL GLuint64 GL_APIENTRY glGetTextureHandleNV (GLuint texture); +GL_APICALL GLuint64 GL_APIENTRY glGetTextureSamplerHandleNV (GLuint texture, GLuint sampler); +GL_APICALL void GL_APIENTRY glMakeTextureHandleResidentNV (GLuint64 handle); +GL_APICALL void GL_APIENTRY glMakeTextureHandleNonResidentNV (GLuint64 handle); +GL_APICALL GLuint64 GL_APIENTRY glGetImageHandleNV (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +GL_APICALL void GL_APIENTRY glMakeImageHandleResidentNV (GLuint64 handle, GLenum access); +GL_APICALL void GL_APIENTRY glMakeImageHandleNonResidentNV (GLuint64 handle); +GL_APICALL void GL_APIENTRY glUniformHandleui64NV (GLint location, GLuint64 value); +GL_APICALL void GL_APIENTRY glUniformHandleui64vNV (GLint location, GLsizei count, const GLuint64 *value); +GL_APICALL void GL_APIENTRY glProgramUniformHandleui64NV (GLuint program, GLint location, GLuint64 value); +GL_APICALL void GL_APIENTRY glProgramUniformHandleui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +GL_APICALL GLboolean GL_APIENTRY glIsTextureHandleResidentNV (GLuint64 handle); +GL_APICALL GLboolean GL_APIENTRY glIsImageHandleResidentNV (GLuint64 handle); +#endif +#endif /* GL_NV_bindless_texture */ + +#ifndef GL_NV_blend_equation_advanced +#define GL_NV_blend_equation_advanced 1 +#define GL_BLEND_OVERLAP_NV 0x9281 +#define GL_BLEND_PREMULTIPLIED_SRC_NV 0x9280 +#define GL_BLUE_NV 0x1905 +#define GL_COLORBURN_NV 0x929A +#define GL_COLORDODGE_NV 0x9299 +#define GL_CONJOINT_NV 0x9284 +#define GL_CONTRAST_NV 0x92A1 +#define GL_DARKEN_NV 0x9297 +#define GL_DIFFERENCE_NV 0x929E +#define GL_DISJOINT_NV 0x9283 +#define GL_DST_ATOP_NV 0x928F +#define GL_DST_IN_NV 0x928B +#define GL_DST_NV 0x9287 +#define GL_DST_OUT_NV 0x928D +#define GL_DST_OVER_NV 0x9289 +#define GL_EXCLUSION_NV 0x92A0 +#define GL_GREEN_NV 0x1904 +#define GL_HARDLIGHT_NV 0x929B +#define GL_HARDMIX_NV 0x92A9 +#define GL_HSL_COLOR_NV 0x92AF +#define GL_HSL_HUE_NV 0x92AD +#define GL_HSL_LUMINOSITY_NV 0x92B0 +#define GL_HSL_SATURATION_NV 0x92AE +#define GL_INVERT_OVG_NV 0x92B4 +#define GL_INVERT_RGB_NV 0x92A3 +#define GL_LIGHTEN_NV 0x9298 +#define GL_LINEARBURN_NV 0x92A5 +#define GL_LINEARDODGE_NV 0x92A4 +#define GL_LINEARLIGHT_NV 0x92A7 +#define GL_MINUS_CLAMPED_NV 0x92B3 +#define GL_MINUS_NV 0x929F +#define GL_MULTIPLY_NV 0x9294 +#define GL_OVERLAY_NV 0x9296 +#define GL_PINLIGHT_NV 0x92A8 +#define GL_PLUS_CLAMPED_ALPHA_NV 0x92B2 +#define GL_PLUS_CLAMPED_NV 0x92B1 +#define GL_PLUS_DARKER_NV 0x9292 +#define GL_PLUS_NV 0x9291 +#define GL_RED_NV 0x1903 +#define GL_SCREEN_NV 0x9295 +#define GL_SOFTLIGHT_NV 0x929C +#define GL_SRC_ATOP_NV 0x928E +#define GL_SRC_IN_NV 0x928A +#define GL_SRC_NV 0x9286 +#define GL_SRC_OUT_NV 0x928C +#define GL_SRC_OVER_NV 0x9288 +#define GL_UNCORRELATED_NV 0x9282 +#define GL_VIVIDLIGHT_NV 0x92A6 +#define GL_XOR_NV 0x1506 +typedef void (GL_APIENTRYP PFNGLBLENDPARAMETERINVPROC) (GLenum pname, GLint value); +typedef void (GL_APIENTRYP PFNGLBLENDBARRIERNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glBlendParameteriNV (GLenum pname, GLint value); +GL_APICALL void GL_APIENTRY glBlendBarrierNV (void); +#endif +#endif /* GL_NV_blend_equation_advanced */ + +#ifndef GL_NV_blend_equation_advanced_coherent +#define GL_NV_blend_equation_advanced_coherent 1 +#define GL_BLEND_ADVANCED_COHERENT_NV 0x9285 +#endif /* GL_NV_blend_equation_advanced_coherent */ + +#ifndef GL_NV_blend_minmax_factor +#define GL_NV_blend_minmax_factor 1 +#define GL_FACTOR_MIN_AMD 0x901C +#define GL_FACTOR_MAX_AMD 0x901D +#endif /* GL_NV_blend_minmax_factor */ + +#ifndef GL_NV_clip_space_w_scaling +#define GL_NV_clip_space_w_scaling 1 +#define GL_VIEWPORT_POSITION_W_SCALE_NV 0x937C +#define GL_VIEWPORT_POSITION_W_SCALE_X_COEFF_NV 0x937D +#define GL_VIEWPORT_POSITION_W_SCALE_Y_COEFF_NV 0x937E +typedef void (GL_APIENTRYP PFNGLVIEWPORTPOSITIONWSCALENVPROC) (GLuint index, GLfloat xcoeff, GLfloat ycoeff); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glViewportPositionWScaleNV (GLuint index, GLfloat xcoeff, GLfloat ycoeff); +#endif +#endif /* GL_NV_clip_space_w_scaling */ + +#ifndef GL_NV_compute_shader_derivatives +#define GL_NV_compute_shader_derivatives 1 +#endif /* GL_NV_compute_shader_derivatives */ + +#ifndef GL_NV_conditional_render +#define GL_NV_conditional_render 1 +#define GL_QUERY_WAIT_NV 0x8E13 +#define GL_QUERY_NO_WAIT_NV 0x8E14 +#define GL_QUERY_BY_REGION_WAIT_NV 0x8E15 +#define GL_QUERY_BY_REGION_NO_WAIT_NV 0x8E16 +typedef void (GL_APIENTRYP PFNGLBEGINCONDITIONALRENDERNVPROC) (GLuint id, GLenum mode); +typedef void (GL_APIENTRYP PFNGLENDCONDITIONALRENDERNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glBeginConditionalRenderNV (GLuint id, GLenum mode); +GL_APICALL void GL_APIENTRY glEndConditionalRenderNV (void); +#endif +#endif /* GL_NV_conditional_render */ + +#ifndef GL_NV_conservative_raster +#define GL_NV_conservative_raster 1 +#define GL_CONSERVATIVE_RASTERIZATION_NV 0x9346 +#define GL_SUBPIXEL_PRECISION_BIAS_X_BITS_NV 0x9347 +#define GL_SUBPIXEL_PRECISION_BIAS_Y_BITS_NV 0x9348 +#define GL_MAX_SUBPIXEL_PRECISION_BIAS_BITS_NV 0x9349 +typedef void (GL_APIENTRYP PFNGLSUBPIXELPRECISIONBIASNVPROC) (GLuint xbits, GLuint ybits); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glSubpixelPrecisionBiasNV (GLuint xbits, GLuint ybits); +#endif +#endif /* GL_NV_conservative_raster */ + +#ifndef GL_NV_conservative_raster_pre_snap +#define GL_NV_conservative_raster_pre_snap 1 +#define GL_CONSERVATIVE_RASTER_MODE_PRE_SNAP_NV 0x9550 +#endif /* GL_NV_conservative_raster_pre_snap */ + +#ifndef GL_NV_conservative_raster_pre_snap_triangles +#define GL_NV_conservative_raster_pre_snap_triangles 1 +#define GL_CONSERVATIVE_RASTER_MODE_NV 0x954D +#define GL_CONSERVATIVE_RASTER_MODE_POST_SNAP_NV 0x954E +#define GL_CONSERVATIVE_RASTER_MODE_PRE_SNAP_TRIANGLES_NV 0x954F +typedef void (GL_APIENTRYP PFNGLCONSERVATIVERASTERPARAMETERINVPROC) (GLenum pname, GLint param); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glConservativeRasterParameteriNV (GLenum pname, GLint param); +#endif +#endif /* GL_NV_conservative_raster_pre_snap_triangles */ + +#ifndef GL_NV_copy_buffer +#define GL_NV_copy_buffer 1 +#define GL_COPY_READ_BUFFER_NV 0x8F36 +#define GL_COPY_WRITE_BUFFER_NV 0x8F37 +typedef void (GL_APIENTRYP PFNGLCOPYBUFFERSUBDATANVPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glCopyBufferSubDataNV (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +#endif +#endif /* GL_NV_copy_buffer */ + +#ifndef GL_NV_coverage_sample +#define GL_NV_coverage_sample 1 +#define GL_COVERAGE_COMPONENT_NV 0x8ED0 +#define GL_COVERAGE_COMPONENT4_NV 0x8ED1 +#define GL_COVERAGE_ATTACHMENT_NV 0x8ED2 +#define GL_COVERAGE_BUFFERS_NV 0x8ED3 +#define GL_COVERAGE_SAMPLES_NV 0x8ED4 +#define GL_COVERAGE_ALL_FRAGMENTS_NV 0x8ED5 +#define GL_COVERAGE_EDGE_FRAGMENTS_NV 0x8ED6 +#define GL_COVERAGE_AUTOMATIC_NV 0x8ED7 +#define GL_COVERAGE_BUFFER_BIT_NV 0x00008000 +typedef void (GL_APIENTRYP PFNGLCOVERAGEMASKNVPROC) (GLboolean mask); +typedef void (GL_APIENTRYP PFNGLCOVERAGEOPERATIONNVPROC) (GLenum operation); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glCoverageMaskNV (GLboolean mask); +GL_APICALL void GL_APIENTRY glCoverageOperationNV (GLenum operation); +#endif +#endif /* GL_NV_coverage_sample */ + +#ifndef GL_NV_depth_nonlinear +#define GL_NV_depth_nonlinear 1 +#define GL_DEPTH_COMPONENT16_NONLINEAR_NV 0x8E2C +#endif /* GL_NV_depth_nonlinear */ + +#ifndef GL_NV_draw_buffers +#define GL_NV_draw_buffers 1 +#define GL_MAX_DRAW_BUFFERS_NV 0x8824 +#define GL_DRAW_BUFFER0_NV 0x8825 +#define GL_DRAW_BUFFER1_NV 0x8826 +#define GL_DRAW_BUFFER2_NV 0x8827 +#define GL_DRAW_BUFFER3_NV 0x8828 +#define GL_DRAW_BUFFER4_NV 0x8829 +#define GL_DRAW_BUFFER5_NV 0x882A +#define GL_DRAW_BUFFER6_NV 0x882B +#define GL_DRAW_BUFFER7_NV 0x882C +#define GL_DRAW_BUFFER8_NV 0x882D +#define GL_DRAW_BUFFER9_NV 0x882E +#define GL_DRAW_BUFFER10_NV 0x882F +#define GL_DRAW_BUFFER11_NV 0x8830 +#define GL_DRAW_BUFFER12_NV 0x8831 +#define GL_DRAW_BUFFER13_NV 0x8832 +#define GL_DRAW_BUFFER14_NV 0x8833 +#define GL_DRAW_BUFFER15_NV 0x8834 +#define GL_COLOR_ATTACHMENT0_NV 0x8CE0 +#define GL_COLOR_ATTACHMENT1_NV 0x8CE1 +#define GL_COLOR_ATTACHMENT2_NV 0x8CE2 +#define GL_COLOR_ATTACHMENT3_NV 0x8CE3 +#define GL_COLOR_ATTACHMENT4_NV 0x8CE4 +#define GL_COLOR_ATTACHMENT5_NV 0x8CE5 +#define GL_COLOR_ATTACHMENT6_NV 0x8CE6 +#define GL_COLOR_ATTACHMENT7_NV 0x8CE7 +#define GL_COLOR_ATTACHMENT8_NV 0x8CE8 +#define GL_COLOR_ATTACHMENT9_NV 0x8CE9 +#define GL_COLOR_ATTACHMENT10_NV 0x8CEA +#define GL_COLOR_ATTACHMENT11_NV 0x8CEB +#define GL_COLOR_ATTACHMENT12_NV 0x8CEC +#define GL_COLOR_ATTACHMENT13_NV 0x8CED +#define GL_COLOR_ATTACHMENT14_NV 0x8CEE +#define GL_COLOR_ATTACHMENT15_NV 0x8CEF +typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSNVPROC) (GLsizei n, const GLenum *bufs); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawBuffersNV (GLsizei n, const GLenum *bufs); +#endif +#endif /* GL_NV_draw_buffers */ + +#ifndef GL_NV_draw_instanced +#define GL_NV_draw_instanced 1 +typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDNVPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDNVPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawArraysInstancedNV (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +GL_APICALL void GL_APIENTRY glDrawElementsInstancedNV (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#endif +#endif /* GL_NV_draw_instanced */ + +#ifndef GL_NV_draw_vulkan_image +#define GL_NV_draw_vulkan_image 1 +typedef void (GL_APIENTRY *GLVULKANPROCNV)(void); +typedef void (GL_APIENTRYP PFNGLDRAWVKIMAGENVPROC) (GLuint64 vkImage, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); +typedef GLVULKANPROCNV (GL_APIENTRYP PFNGLGETVKPROCADDRNVPROC) (const GLchar *name); +typedef void (GL_APIENTRYP PFNGLWAITVKSEMAPHORENVPROC) (GLuint64 vkSemaphore); +typedef void (GL_APIENTRYP PFNGLSIGNALVKSEMAPHORENVPROC) (GLuint64 vkSemaphore); +typedef void (GL_APIENTRYP PFNGLSIGNALVKFENCENVPROC) (GLuint64 vkFence); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawVkImageNV (GLuint64 vkImage, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); +GL_APICALL GLVULKANPROCNV GL_APIENTRY glGetVkProcAddrNV (const GLchar *name); +GL_APICALL void GL_APIENTRY glWaitVkSemaphoreNV (GLuint64 vkSemaphore); +GL_APICALL void GL_APIENTRY glSignalVkSemaphoreNV (GLuint64 vkSemaphore); +GL_APICALL void GL_APIENTRY glSignalVkFenceNV (GLuint64 vkFence); +#endif +#endif /* GL_NV_draw_vulkan_image */ + +#ifndef GL_NV_explicit_attrib_location +#define GL_NV_explicit_attrib_location 1 +#endif /* GL_NV_explicit_attrib_location */ + +#ifndef GL_NV_fbo_color_attachments +#define GL_NV_fbo_color_attachments 1 +#define GL_MAX_COLOR_ATTACHMENTS_NV 0x8CDF +#endif /* GL_NV_fbo_color_attachments */ + +#ifndef GL_NV_fence +#define GL_NV_fence 1 +#define GL_ALL_COMPLETED_NV 0x84F2 +#define GL_FENCE_STATUS_NV 0x84F3 +#define GL_FENCE_CONDITION_NV 0x84F4 +typedef void (GL_APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); +typedef void (GL_APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); +typedef GLboolean (GL_APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); +typedef GLboolean (GL_APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); +typedef void (GL_APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); +typedef void (GL_APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDeleteFencesNV (GLsizei n, const GLuint *fences); +GL_APICALL void GL_APIENTRY glGenFencesNV (GLsizei n, GLuint *fences); +GL_APICALL GLboolean GL_APIENTRY glIsFenceNV (GLuint fence); +GL_APICALL GLboolean GL_APIENTRY glTestFenceNV (GLuint fence); +GL_APICALL void GL_APIENTRY glGetFenceivNV (GLuint fence, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glFinishFenceNV (GLuint fence); +GL_APICALL void GL_APIENTRY glSetFenceNV (GLuint fence, GLenum condition); +#endif +#endif /* GL_NV_fence */ + +#ifndef GL_NV_fill_rectangle +#define GL_NV_fill_rectangle 1 +#define GL_FILL_RECTANGLE_NV 0x933C +#endif /* GL_NV_fill_rectangle */ + +#ifndef GL_NV_fragment_coverage_to_color +#define GL_NV_fragment_coverage_to_color 1 +#define GL_FRAGMENT_COVERAGE_TO_COLOR_NV 0x92DD +#define GL_FRAGMENT_COVERAGE_COLOR_NV 0x92DE +typedef void (GL_APIENTRYP PFNGLFRAGMENTCOVERAGECOLORNVPROC) (GLuint color); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glFragmentCoverageColorNV (GLuint color); +#endif +#endif /* GL_NV_fragment_coverage_to_color */ + +#ifndef GL_NV_fragment_shader_barycentric +#define GL_NV_fragment_shader_barycentric 1 +#endif /* GL_NV_fragment_shader_barycentric */ + +#ifndef GL_NV_fragment_shader_interlock +#define GL_NV_fragment_shader_interlock 1 +#endif /* GL_NV_fragment_shader_interlock */ + +#ifndef GL_NV_framebuffer_blit +#define GL_NV_framebuffer_blit 1 +#define GL_READ_FRAMEBUFFER_NV 0x8CA8 +#define GL_DRAW_FRAMEBUFFER_NV 0x8CA9 +#define GL_DRAW_FRAMEBUFFER_BINDING_NV 0x8CA6 +#define GL_READ_FRAMEBUFFER_BINDING_NV 0x8CAA +typedef void (GL_APIENTRYP PFNGLBLITFRAMEBUFFERNVPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glBlitFramebufferNV (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif +#endif /* GL_NV_framebuffer_blit */ + +#ifndef GL_NV_framebuffer_mixed_samples +#define GL_NV_framebuffer_mixed_samples 1 +#define GL_COVERAGE_MODULATION_TABLE_NV 0x9331 +#define GL_COLOR_SAMPLES_NV 0x8E20 +#define GL_DEPTH_SAMPLES_NV 0x932D +#define GL_STENCIL_SAMPLES_NV 0x932E +#define GL_MIXED_DEPTH_SAMPLES_SUPPORTED_NV 0x932F +#define GL_MIXED_STENCIL_SAMPLES_SUPPORTED_NV 0x9330 +#define GL_COVERAGE_MODULATION_NV 0x9332 +#define GL_COVERAGE_MODULATION_TABLE_SIZE_NV 0x9333 +typedef void (GL_APIENTRYP PFNGLCOVERAGEMODULATIONTABLENVPROC) (GLsizei n, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLGETCOVERAGEMODULATIONTABLENVPROC) (GLsizei bufSize, GLfloat *v); +typedef void (GL_APIENTRYP PFNGLCOVERAGEMODULATIONNVPROC) (GLenum components); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glCoverageModulationTableNV (GLsizei n, const GLfloat *v); +GL_APICALL void GL_APIENTRY glGetCoverageModulationTableNV (GLsizei bufSize, GLfloat *v); +GL_APICALL void GL_APIENTRY glCoverageModulationNV (GLenum components); +#endif +#endif /* GL_NV_framebuffer_mixed_samples */ + +#ifndef GL_NV_framebuffer_multisample +#define GL_NV_framebuffer_multisample 1 +#define GL_RENDERBUFFER_SAMPLES_NV 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_NV 0x8D56 +#define GL_MAX_SAMPLES_NV 0x8D57 +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLENVPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleNV (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#endif +#endif /* GL_NV_framebuffer_multisample */ + +#ifndef GL_NV_generate_mipmap_sRGB +#define GL_NV_generate_mipmap_sRGB 1 +#endif /* GL_NV_generate_mipmap_sRGB */ + +#ifndef GL_NV_geometry_shader_passthrough +#define GL_NV_geometry_shader_passthrough 1 +#endif /* GL_NV_geometry_shader_passthrough */ + +#ifndef GL_NV_gpu_shader5 +#define GL_NV_gpu_shader5 1 +typedef khronos_int64_t GLint64EXT; +typedef khronos_uint64_t GLuint64EXT; +#define GL_INT64_NV 0x140E +#define GL_UNSIGNED_INT64_NV 0x140F +#define GL_INT8_NV 0x8FE0 +#define GL_INT8_VEC2_NV 0x8FE1 +#define GL_INT8_VEC3_NV 0x8FE2 +#define GL_INT8_VEC4_NV 0x8FE3 +#define GL_INT16_NV 0x8FE4 +#define GL_INT16_VEC2_NV 0x8FE5 +#define GL_INT16_VEC3_NV 0x8FE6 +#define GL_INT16_VEC4_NV 0x8FE7 +#define GL_INT64_VEC2_NV 0x8FE9 +#define GL_INT64_VEC3_NV 0x8FEA +#define GL_INT64_VEC4_NV 0x8FEB +#define GL_UNSIGNED_INT8_NV 0x8FEC +#define GL_UNSIGNED_INT8_VEC2_NV 0x8FED +#define GL_UNSIGNED_INT8_VEC3_NV 0x8FEE +#define GL_UNSIGNED_INT8_VEC4_NV 0x8FEF +#define GL_UNSIGNED_INT16_NV 0x8FF0 +#define GL_UNSIGNED_INT16_VEC2_NV 0x8FF1 +#define GL_UNSIGNED_INT16_VEC3_NV 0x8FF2 +#define GL_UNSIGNED_INT16_VEC4_NV 0x8FF3 +#define GL_UNSIGNED_INT64_VEC2_NV 0x8FF5 +#define GL_UNSIGNED_INT64_VEC3_NV 0x8FF6 +#define GL_UNSIGNED_INT64_VEC4_NV 0x8FF7 +#define GL_FLOAT16_NV 0x8FF8 +#define GL_FLOAT16_VEC2_NV 0x8FF9 +#define GL_FLOAT16_VEC3_NV 0x8FFA +#define GL_FLOAT16_VEC4_NV 0x8FFB +#define GL_PATCHES 0x000E +typedef void (GL_APIENTRYP PFNGLUNIFORM1I64NVPROC) (GLint location, GLint64EXT x); +typedef void (GL_APIENTRYP PFNGLUNIFORM2I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y); +typedef void (GL_APIENTRYP PFNGLUNIFORM3I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (GL_APIENTRYP PFNGLUNIFORM4I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (GL_APIENTRYP PFNGLUNIFORM1I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM2I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM3I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM4I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM1UI64NVPROC) (GLint location, GLuint64EXT x); +typedef void (GL_APIENTRYP PFNGLUNIFORM2UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y); +typedef void (GL_APIENTRYP PFNGLUNIFORM3UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (GL_APIENTRYP PFNGLUNIFORM4UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (GL_APIENTRYP PFNGLUNIFORM1UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM2UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM3UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM4UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (GL_APIENTRYP PFNGLGETUNIFORMI64VNVPROC) (GLuint program, GLint location, GLint64EXT *params); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1I64NVPROC) (GLuint program, GLint location, GLint64EXT x); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glUniform1i64NV (GLint location, GLint64EXT x); +GL_APICALL void GL_APIENTRY glUniform2i64NV (GLint location, GLint64EXT x, GLint64EXT y); +GL_APICALL void GL_APIENTRY glUniform3i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GL_APICALL void GL_APIENTRY glUniform4i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GL_APICALL void GL_APIENTRY glUniform1i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GL_APICALL void GL_APIENTRY glUniform2i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GL_APICALL void GL_APIENTRY glUniform3i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GL_APICALL void GL_APIENTRY glUniform4i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GL_APICALL void GL_APIENTRY glUniform1ui64NV (GLint location, GLuint64EXT x); +GL_APICALL void GL_APIENTRY glUniform2ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y); +GL_APICALL void GL_APIENTRY glUniform3ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GL_APICALL void GL_APIENTRY glUniform4ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GL_APICALL void GL_APIENTRY glUniform1ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GL_APICALL void GL_APIENTRY glUniform2ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GL_APICALL void GL_APIENTRY glUniform3ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GL_APICALL void GL_APIENTRY glUniform4ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GL_APICALL void GL_APIENTRY glGetUniformi64vNV (GLuint program, GLint location, GLint64EXT *params); +GL_APICALL void GL_APIENTRY glProgramUniform1i64NV (GLuint program, GLint location, GLint64EXT x); +GL_APICALL void GL_APIENTRY glProgramUniform2i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); +GL_APICALL void GL_APIENTRY glProgramUniform3i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GL_APICALL void GL_APIENTRY glProgramUniform4i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GL_APICALL void GL_APIENTRY glProgramUniform1i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GL_APICALL void GL_APIENTRY glProgramUniform2i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GL_APICALL void GL_APIENTRY glProgramUniform3i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GL_APICALL void GL_APIENTRY glProgramUniform4i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GL_APICALL void GL_APIENTRY glProgramUniform1ui64NV (GLuint program, GLint location, GLuint64EXT x); +GL_APICALL void GL_APIENTRY glProgramUniform2ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); +GL_APICALL void GL_APIENTRY glProgramUniform3ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GL_APICALL void GL_APIENTRY glProgramUniform4ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GL_APICALL void GL_APIENTRY glProgramUniform1ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GL_APICALL void GL_APIENTRY glProgramUniform2ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GL_APICALL void GL_APIENTRY glProgramUniform3ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GL_APICALL void GL_APIENTRY glProgramUniform4ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif +#endif /* GL_NV_gpu_shader5 */ + +#ifndef GL_NV_image_formats +#define GL_NV_image_formats 1 +#endif /* GL_NV_image_formats */ + +#ifndef GL_NV_instanced_arrays +#define GL_NV_instanced_arrays 1 +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_NV 0x88FE +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBDIVISORNVPROC) (GLuint index, GLuint divisor); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glVertexAttribDivisorNV (GLuint index, GLuint divisor); +#endif +#endif /* GL_NV_instanced_arrays */ + +#ifndef GL_NV_internalformat_sample_query +#define GL_NV_internalformat_sample_query 1 +#define GL_TEXTURE_2D_MULTISAMPLE 0x9100 +#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 +#define GL_MULTISAMPLES_NV 0x9371 +#define GL_SUPERSAMPLE_SCALE_X_NV 0x9372 +#define GL_SUPERSAMPLE_SCALE_Y_NV 0x9373 +#define GL_CONFORMANT_NV 0x9374 +typedef void (GL_APIENTRYP PFNGLGETINTERNALFORMATSAMPLEIVNVPROC) (GLenum target, GLenum internalformat, GLsizei samples, GLenum pname, GLsizei count, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGetInternalformatSampleivNV (GLenum target, GLenum internalformat, GLsizei samples, GLenum pname, GLsizei count, GLint *params); +#endif +#endif /* GL_NV_internalformat_sample_query */ + +#ifndef GL_NV_memory_attachment +#define GL_NV_memory_attachment 1 +#define GL_ATTACHED_MEMORY_OBJECT_NV 0x95A4 +#define GL_ATTACHED_MEMORY_OFFSET_NV 0x95A5 +#define GL_MEMORY_ATTACHABLE_ALIGNMENT_NV 0x95A6 +#define GL_MEMORY_ATTACHABLE_SIZE_NV 0x95A7 +#define GL_MEMORY_ATTACHABLE_NV 0x95A8 +#define GL_DETACHED_MEMORY_INCARNATION_NV 0x95A9 +#define GL_DETACHED_TEXTURES_NV 0x95AA +#define GL_DETACHED_BUFFERS_NV 0x95AB +#define GL_MAX_DETACHED_TEXTURES_NV 0x95AC +#define GL_MAX_DETACHED_BUFFERS_NV 0x95AD +typedef void (GL_APIENTRYP PFNGLGETMEMORYOBJECTDETACHEDRESOURCESUIVNVPROC) (GLuint memory, GLenum pname, GLint first, GLsizei count, GLuint *params); +typedef void (GL_APIENTRYP PFNGLRESETMEMORYOBJECTPARAMETERNVPROC) (GLuint memory, GLenum pname); +typedef void (GL_APIENTRYP PFNGLTEXATTACHMEMORYNVPROC) (GLenum target, GLuint memory, GLuint64 offset); +typedef void (GL_APIENTRYP PFNGLBUFFERATTACHMEMORYNVPROC) (GLenum target, GLuint memory, GLuint64 offset); +typedef void (GL_APIENTRYP PFNGLTEXTUREATTACHMEMORYNVPROC) (GLuint texture, GLuint memory, GLuint64 offset); +typedef void (GL_APIENTRYP PFNGLNAMEDBUFFERATTACHMEMORYNVPROC) (GLuint buffer, GLuint memory, GLuint64 offset); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGetMemoryObjectDetachedResourcesuivNV (GLuint memory, GLenum pname, GLint first, GLsizei count, GLuint *params); +GL_APICALL void GL_APIENTRY glResetMemoryObjectParameterNV (GLuint memory, GLenum pname); +GL_APICALL void GL_APIENTRY glTexAttachMemoryNV (GLenum target, GLuint memory, GLuint64 offset); +GL_APICALL void GL_APIENTRY glBufferAttachMemoryNV (GLenum target, GLuint memory, GLuint64 offset); +GL_APICALL void GL_APIENTRY glTextureAttachMemoryNV (GLuint texture, GLuint memory, GLuint64 offset); +GL_APICALL void GL_APIENTRY glNamedBufferAttachMemoryNV (GLuint buffer, GLuint memory, GLuint64 offset); +#endif +#endif /* GL_NV_memory_attachment */ + +#ifndef GL_NV_memory_object_sparse +#define GL_NV_memory_object_sparse 1 +typedef void (GL_APIENTRYP PFNGLBUFFERPAGECOMMITMENTMEMNVPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLuint memory, GLuint64 memOffset, GLboolean commit); +typedef void (GL_APIENTRYP PFNGLTEXPAGECOMMITMENTMEMNVPROC) (GLenum target, GLint layer, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset, GLboolean commit); +typedef void (GL_APIENTRYP PFNGLNAMEDBUFFERPAGECOMMITMENTMEMNVPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLuint memory, GLuint64 memOffset, GLboolean commit); +typedef void (GL_APIENTRYP PFNGLTEXTUREPAGECOMMITMENTMEMNVPROC) (GLuint texture, GLint layer, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset, GLboolean commit); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glBufferPageCommitmentMemNV (GLenum target, GLintptr offset, GLsizeiptr size, GLuint memory, GLuint64 memOffset, GLboolean commit); +GL_APICALL void GL_APIENTRY glTexPageCommitmentMemNV (GLenum target, GLint layer, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset, GLboolean commit); +GL_APICALL void GL_APIENTRY glNamedBufferPageCommitmentMemNV (GLuint buffer, GLintptr offset, GLsizeiptr size, GLuint memory, GLuint64 memOffset, GLboolean commit); +GL_APICALL void GL_APIENTRY glTexturePageCommitmentMemNV (GLuint texture, GLint layer, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset, GLboolean commit); +#endif +#endif /* GL_NV_memory_object_sparse */ + +#ifndef GL_NV_mesh_shader +#define GL_NV_mesh_shader 1 +#define GL_MESH_SHADER_NV 0x9559 +#define GL_TASK_SHADER_NV 0x955A +#define GL_MAX_MESH_UNIFORM_BLOCKS_NV 0x8E60 +#define GL_MAX_MESH_TEXTURE_IMAGE_UNITS_NV 0x8E61 +#define GL_MAX_MESH_IMAGE_UNIFORMS_NV 0x8E62 +#define GL_MAX_MESH_UNIFORM_COMPONENTS_NV 0x8E63 +#define GL_MAX_MESH_ATOMIC_COUNTER_BUFFERS_NV 0x8E64 +#define GL_MAX_MESH_ATOMIC_COUNTERS_NV 0x8E65 +#define GL_MAX_MESH_SHADER_STORAGE_BLOCKS_NV 0x8E66 +#define GL_MAX_COMBINED_MESH_UNIFORM_COMPONENTS_NV 0x8E67 +#define GL_MAX_TASK_UNIFORM_BLOCKS_NV 0x8E68 +#define GL_MAX_TASK_TEXTURE_IMAGE_UNITS_NV 0x8E69 +#define GL_MAX_TASK_IMAGE_UNIFORMS_NV 0x8E6A +#define GL_MAX_TASK_UNIFORM_COMPONENTS_NV 0x8E6B +#define GL_MAX_TASK_ATOMIC_COUNTER_BUFFERS_NV 0x8E6C +#define GL_MAX_TASK_ATOMIC_COUNTERS_NV 0x8E6D +#define GL_MAX_TASK_SHADER_STORAGE_BLOCKS_NV 0x8E6E +#define GL_MAX_COMBINED_TASK_UNIFORM_COMPONENTS_NV 0x8E6F +#define GL_MAX_MESH_WORK_GROUP_INVOCATIONS_NV 0x95A2 +#define GL_MAX_TASK_WORK_GROUP_INVOCATIONS_NV 0x95A3 +#define GL_MAX_MESH_TOTAL_MEMORY_SIZE_NV 0x9536 +#define GL_MAX_TASK_TOTAL_MEMORY_SIZE_NV 0x9537 +#define GL_MAX_MESH_OUTPUT_VERTICES_NV 0x9538 +#define GL_MAX_MESH_OUTPUT_PRIMITIVES_NV 0x9539 +#define GL_MAX_TASK_OUTPUT_COUNT_NV 0x953A +#define GL_MAX_DRAW_MESH_TASKS_COUNT_NV 0x953D +#define GL_MAX_MESH_VIEWS_NV 0x9557 +#define GL_MESH_OUTPUT_PER_VERTEX_GRANULARITY_NV 0x92DF +#define GL_MESH_OUTPUT_PER_PRIMITIVE_GRANULARITY_NV 0x9543 +#define GL_MAX_MESH_WORK_GROUP_SIZE_NV 0x953B +#define GL_MAX_TASK_WORK_GROUP_SIZE_NV 0x953C +#define GL_MESH_WORK_GROUP_SIZE_NV 0x953E +#define GL_TASK_WORK_GROUP_SIZE_NV 0x953F +#define GL_MESH_VERTICES_OUT_NV 0x9579 +#define GL_MESH_PRIMITIVES_OUT_NV 0x957A +#define GL_MESH_OUTPUT_TYPE_NV 0x957B +#define GL_UNIFORM_BLOCK_REFERENCED_BY_MESH_SHADER_NV 0x959C +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TASK_SHADER_NV 0x959D +#define GL_REFERENCED_BY_MESH_SHADER_NV 0x95A0 +#define GL_REFERENCED_BY_TASK_SHADER_NV 0x95A1 +#define GL_MESH_SHADER_BIT_NV 0x00000040 +#define GL_TASK_SHADER_BIT_NV 0x00000080 +#define GL_MESH_SUBROUTINE_NV 0x957C +#define GL_TASK_SUBROUTINE_NV 0x957D +#define GL_MESH_SUBROUTINE_UNIFORM_NV 0x957E +#define GL_TASK_SUBROUTINE_UNIFORM_NV 0x957F +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_MESH_SHADER_NV 0x959E +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TASK_SHADER_NV 0x959F +typedef void (GL_APIENTRYP PFNGLDRAWMESHTASKSNVPROC) (GLuint first, GLuint count); +typedef void (GL_APIENTRYP PFNGLDRAWMESHTASKSINDIRECTNVPROC) (GLintptr indirect); +typedef void (GL_APIENTRYP PFNGLMULTIDRAWMESHTASKSINDIRECTNVPROC) (GLintptr indirect, GLsizei drawcount, GLsizei stride); +typedef void (GL_APIENTRYP PFNGLMULTIDRAWMESHTASKSINDIRECTCOUNTNVPROC) (GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawMeshTasksNV (GLuint first, GLuint count); +GL_APICALL void GL_APIENTRY glDrawMeshTasksIndirectNV (GLintptr indirect); +GL_APICALL void GL_APIENTRY glMultiDrawMeshTasksIndirectNV (GLintptr indirect, GLsizei drawcount, GLsizei stride); +GL_APICALL void GL_APIENTRY glMultiDrawMeshTasksIndirectCountNV (GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +#endif +#endif /* GL_NV_mesh_shader */ + +#ifndef GL_NV_non_square_matrices +#define GL_NV_non_square_matrices 1 +#define GL_FLOAT_MAT2x3_NV 0x8B65 +#define GL_FLOAT_MAT2x4_NV 0x8B66 +#define GL_FLOAT_MAT3x2_NV 0x8B67 +#define GL_FLOAT_MAT3x4_NV 0x8B68 +#define GL_FLOAT_MAT4x2_NV 0x8B69 +#define GL_FLOAT_MAT4x3_NV 0x8B6A +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX2X3FVNVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX3X2FVNVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX2X4FVNVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX4X2FVNVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX3X4FVNVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX4X3FVNVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glUniformMatrix2x3fvNV (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix3x2fvNV (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix2x4fvNV (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix4x2fvNV (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix3x4fvNV (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix4x3fvNV (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#endif +#endif /* GL_NV_non_square_matrices */ + +#ifndef GL_NV_path_rendering +#define GL_NV_path_rendering 1 +typedef double GLdouble; +#define GL_PATH_FORMAT_SVG_NV 0x9070 +#define GL_PATH_FORMAT_PS_NV 0x9071 +#define GL_STANDARD_FONT_NAME_NV 0x9072 +#define GL_SYSTEM_FONT_NAME_NV 0x9073 +#define GL_FILE_NAME_NV 0x9074 +#define GL_PATH_STROKE_WIDTH_NV 0x9075 +#define GL_PATH_END_CAPS_NV 0x9076 +#define GL_PATH_INITIAL_END_CAP_NV 0x9077 +#define GL_PATH_TERMINAL_END_CAP_NV 0x9078 +#define GL_PATH_JOIN_STYLE_NV 0x9079 +#define GL_PATH_MITER_LIMIT_NV 0x907A +#define GL_PATH_DASH_CAPS_NV 0x907B +#define GL_PATH_INITIAL_DASH_CAP_NV 0x907C +#define GL_PATH_TERMINAL_DASH_CAP_NV 0x907D +#define GL_PATH_DASH_OFFSET_NV 0x907E +#define GL_PATH_CLIENT_LENGTH_NV 0x907F +#define GL_PATH_FILL_MODE_NV 0x9080 +#define GL_PATH_FILL_MASK_NV 0x9081 +#define GL_PATH_FILL_COVER_MODE_NV 0x9082 +#define GL_PATH_STROKE_COVER_MODE_NV 0x9083 +#define GL_PATH_STROKE_MASK_NV 0x9084 +#define GL_COUNT_UP_NV 0x9088 +#define GL_COUNT_DOWN_NV 0x9089 +#define GL_PATH_OBJECT_BOUNDING_BOX_NV 0x908A +#define GL_CONVEX_HULL_NV 0x908B +#define GL_BOUNDING_BOX_NV 0x908D +#define GL_TRANSLATE_X_NV 0x908E +#define GL_TRANSLATE_Y_NV 0x908F +#define GL_TRANSLATE_2D_NV 0x9090 +#define GL_TRANSLATE_3D_NV 0x9091 +#define GL_AFFINE_2D_NV 0x9092 +#define GL_AFFINE_3D_NV 0x9094 +#define GL_TRANSPOSE_AFFINE_2D_NV 0x9096 +#define GL_TRANSPOSE_AFFINE_3D_NV 0x9098 +#define GL_UTF8_NV 0x909A +#define GL_UTF16_NV 0x909B +#define GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV 0x909C +#define GL_PATH_COMMAND_COUNT_NV 0x909D +#define GL_PATH_COORD_COUNT_NV 0x909E +#define GL_PATH_DASH_ARRAY_COUNT_NV 0x909F +#define GL_PATH_COMPUTED_LENGTH_NV 0x90A0 +#define GL_PATH_FILL_BOUNDING_BOX_NV 0x90A1 +#define GL_PATH_STROKE_BOUNDING_BOX_NV 0x90A2 +#define GL_SQUARE_NV 0x90A3 +#define GL_ROUND_NV 0x90A4 +#define GL_TRIANGULAR_NV 0x90A5 +#define GL_BEVEL_NV 0x90A6 +#define GL_MITER_REVERT_NV 0x90A7 +#define GL_MITER_TRUNCATE_NV 0x90A8 +#define GL_SKIP_MISSING_GLYPH_NV 0x90A9 +#define GL_USE_MISSING_GLYPH_NV 0x90AA +#define GL_PATH_ERROR_POSITION_NV 0x90AB +#define GL_ACCUM_ADJACENT_PAIRS_NV 0x90AD +#define GL_ADJACENT_PAIRS_NV 0x90AE +#define GL_FIRST_TO_REST_NV 0x90AF +#define GL_PATH_GEN_MODE_NV 0x90B0 +#define GL_PATH_GEN_COEFF_NV 0x90B1 +#define GL_PATH_GEN_COMPONENTS_NV 0x90B3 +#define GL_PATH_STENCIL_FUNC_NV 0x90B7 +#define GL_PATH_STENCIL_REF_NV 0x90B8 +#define GL_PATH_STENCIL_VALUE_MASK_NV 0x90B9 +#define GL_PATH_STENCIL_DEPTH_OFFSET_FACTOR_NV 0x90BD +#define GL_PATH_STENCIL_DEPTH_OFFSET_UNITS_NV 0x90BE +#define GL_PATH_COVER_DEPTH_FUNC_NV 0x90BF +#define GL_PATH_DASH_OFFSET_RESET_NV 0x90B4 +#define GL_MOVE_TO_RESETS_NV 0x90B5 +#define GL_MOVE_TO_CONTINUES_NV 0x90B6 +#define GL_CLOSE_PATH_NV 0x00 +#define GL_MOVE_TO_NV 0x02 +#define GL_RELATIVE_MOVE_TO_NV 0x03 +#define GL_LINE_TO_NV 0x04 +#define GL_RELATIVE_LINE_TO_NV 0x05 +#define GL_HORIZONTAL_LINE_TO_NV 0x06 +#define GL_RELATIVE_HORIZONTAL_LINE_TO_NV 0x07 +#define GL_VERTICAL_LINE_TO_NV 0x08 +#define GL_RELATIVE_VERTICAL_LINE_TO_NV 0x09 +#define GL_QUADRATIC_CURVE_TO_NV 0x0A +#define GL_RELATIVE_QUADRATIC_CURVE_TO_NV 0x0B +#define GL_CUBIC_CURVE_TO_NV 0x0C +#define GL_RELATIVE_CUBIC_CURVE_TO_NV 0x0D +#define GL_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0E +#define GL_RELATIVE_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0F +#define GL_SMOOTH_CUBIC_CURVE_TO_NV 0x10 +#define GL_RELATIVE_SMOOTH_CUBIC_CURVE_TO_NV 0x11 +#define GL_SMALL_CCW_ARC_TO_NV 0x12 +#define GL_RELATIVE_SMALL_CCW_ARC_TO_NV 0x13 +#define GL_SMALL_CW_ARC_TO_NV 0x14 +#define GL_RELATIVE_SMALL_CW_ARC_TO_NV 0x15 +#define GL_LARGE_CCW_ARC_TO_NV 0x16 +#define GL_RELATIVE_LARGE_CCW_ARC_TO_NV 0x17 +#define GL_LARGE_CW_ARC_TO_NV 0x18 +#define GL_RELATIVE_LARGE_CW_ARC_TO_NV 0x19 +#define GL_RESTART_PATH_NV 0xF0 +#define GL_DUP_FIRST_CUBIC_CURVE_TO_NV 0xF2 +#define GL_DUP_LAST_CUBIC_CURVE_TO_NV 0xF4 +#define GL_RECT_NV 0xF6 +#define GL_CIRCULAR_CCW_ARC_TO_NV 0xF8 +#define GL_CIRCULAR_CW_ARC_TO_NV 0xFA +#define GL_CIRCULAR_TANGENT_ARC_TO_NV 0xFC +#define GL_ARC_TO_NV 0xFE +#define GL_RELATIVE_ARC_TO_NV 0xFF +#define GL_BOLD_BIT_NV 0x01 +#define GL_ITALIC_BIT_NV 0x02 +#define GL_GLYPH_WIDTH_BIT_NV 0x01 +#define GL_GLYPH_HEIGHT_BIT_NV 0x02 +#define GL_GLYPH_HORIZONTAL_BEARING_X_BIT_NV 0x04 +#define GL_GLYPH_HORIZONTAL_BEARING_Y_BIT_NV 0x08 +#define GL_GLYPH_HORIZONTAL_BEARING_ADVANCE_BIT_NV 0x10 +#define GL_GLYPH_VERTICAL_BEARING_X_BIT_NV 0x20 +#define GL_GLYPH_VERTICAL_BEARING_Y_BIT_NV 0x40 +#define GL_GLYPH_VERTICAL_BEARING_ADVANCE_BIT_NV 0x80 +#define GL_GLYPH_HAS_KERNING_BIT_NV 0x100 +#define GL_FONT_X_MIN_BOUNDS_BIT_NV 0x00010000 +#define GL_FONT_Y_MIN_BOUNDS_BIT_NV 0x00020000 +#define GL_FONT_X_MAX_BOUNDS_BIT_NV 0x00040000 +#define GL_FONT_Y_MAX_BOUNDS_BIT_NV 0x00080000 +#define GL_FONT_UNITS_PER_EM_BIT_NV 0x00100000 +#define GL_FONT_ASCENDER_BIT_NV 0x00200000 +#define GL_FONT_DESCENDER_BIT_NV 0x00400000 +#define GL_FONT_HEIGHT_BIT_NV 0x00800000 +#define GL_FONT_MAX_ADVANCE_WIDTH_BIT_NV 0x01000000 +#define GL_FONT_MAX_ADVANCE_HEIGHT_BIT_NV 0x02000000 +#define GL_FONT_UNDERLINE_POSITION_BIT_NV 0x04000000 +#define GL_FONT_UNDERLINE_THICKNESS_BIT_NV 0x08000000 +#define GL_FONT_HAS_KERNING_BIT_NV 0x10000000 +#define GL_ROUNDED_RECT_NV 0xE8 +#define GL_RELATIVE_ROUNDED_RECT_NV 0xE9 +#define GL_ROUNDED_RECT2_NV 0xEA +#define GL_RELATIVE_ROUNDED_RECT2_NV 0xEB +#define GL_ROUNDED_RECT4_NV 0xEC +#define GL_RELATIVE_ROUNDED_RECT4_NV 0xED +#define GL_ROUNDED_RECT8_NV 0xEE +#define GL_RELATIVE_ROUNDED_RECT8_NV 0xEF +#define GL_RELATIVE_RECT_NV 0xF7 +#define GL_FONT_GLYPHS_AVAILABLE_NV 0x9368 +#define GL_FONT_TARGET_UNAVAILABLE_NV 0x9369 +#define GL_FONT_UNAVAILABLE_NV 0x936A +#define GL_FONT_UNINTELLIGIBLE_NV 0x936B +#define GL_CONIC_CURVE_TO_NV 0x1A +#define GL_RELATIVE_CONIC_CURVE_TO_NV 0x1B +#define GL_FONT_NUM_GLYPH_INDICES_BIT_NV 0x20000000 +#define GL_STANDARD_FONT_FORMAT_NV 0x936C +#define GL_PATH_PROJECTION_NV 0x1701 +#define GL_PATH_MODELVIEW_NV 0x1700 +#define GL_PATH_MODELVIEW_STACK_DEPTH_NV 0x0BA3 +#define GL_PATH_MODELVIEW_MATRIX_NV 0x0BA6 +#define GL_PATH_MAX_MODELVIEW_STACK_DEPTH_NV 0x0D36 +#define GL_PATH_TRANSPOSE_MODELVIEW_MATRIX_NV 0x84E3 +#define GL_PATH_PROJECTION_STACK_DEPTH_NV 0x0BA4 +#define GL_PATH_PROJECTION_MATRIX_NV 0x0BA7 +#define GL_PATH_MAX_PROJECTION_STACK_DEPTH_NV 0x0D38 +#define GL_PATH_TRANSPOSE_PROJECTION_MATRIX_NV 0x84E4 +#define GL_FRAGMENT_INPUT_NV 0x936D +typedef GLuint (GL_APIENTRYP PFNGLGENPATHSNVPROC) (GLsizei range); +typedef void (GL_APIENTRYP PFNGLDELETEPATHSNVPROC) (GLuint path, GLsizei range); +typedef GLboolean (GL_APIENTRYP PFNGLISPATHNVPROC) (GLuint path); +typedef void (GL_APIENTRYP PFNGLPATHCOMMANDSNVPROC) (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); +typedef void (GL_APIENTRYP PFNGLPATHCOORDSNVPROC) (GLuint path, GLsizei numCoords, GLenum coordType, const void *coords); +typedef void (GL_APIENTRYP PFNGLPATHSUBCOMMANDSNVPROC) (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); +typedef void (GL_APIENTRYP PFNGLPATHSUBCOORDSNVPROC) (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const void *coords); +typedef void (GL_APIENTRYP PFNGLPATHSTRINGNVPROC) (GLuint path, GLenum format, GLsizei length, const void *pathString); +typedef void (GL_APIENTRYP PFNGLPATHGLYPHSNVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const void *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef void (GL_APIENTRYP PFNGLPATHGLYPHRANGENVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef void (GL_APIENTRYP PFNGLWEIGHTPATHSNVPROC) (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); +typedef void (GL_APIENTRYP PFNGLCOPYPATHNVPROC) (GLuint resultPath, GLuint srcPath); +typedef void (GL_APIENTRYP PFNGLINTERPOLATEPATHSNVPROC) (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); +typedef void (GL_APIENTRYP PFNGLTRANSFORMPATHNVPROC) (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); +typedef void (GL_APIENTRYP PFNGLPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, const GLint *value); +typedef void (GL_APIENTRYP PFNGLPATHPARAMETERINVPROC) (GLuint path, GLenum pname, GLint value); +typedef void (GL_APIENTRYP PFNGLPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPATHPARAMETERFNVPROC) (GLuint path, GLenum pname, GLfloat value); +typedef void (GL_APIENTRYP PFNGLPATHDASHARRAYNVPROC) (GLuint path, GLsizei dashCount, const GLfloat *dashArray); +typedef void (GL_APIENTRYP PFNGLPATHSTENCILFUNCNVPROC) (GLenum func, GLint ref, GLuint mask); +typedef void (GL_APIENTRYP PFNGLPATHSTENCILDEPTHOFFSETNVPROC) (GLfloat factor, GLfloat units); +typedef void (GL_APIENTRYP PFNGLSTENCILFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask); +typedef void (GL_APIENTRYP PFNGLSTENCILSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask); +typedef void (GL_APIENTRYP PFNGLSTENCILFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); +typedef void (GL_APIENTRYP PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); +typedef void (GL_APIENTRYP PFNGLPATHCOVERDEPTHFUNCNVPROC) (GLenum func); +typedef void (GL_APIENTRYP PFNGLCOVERFILLPATHNVPROC) (GLuint path, GLenum coverMode); +typedef void (GL_APIENTRYP PFNGLCOVERSTROKEPATHNVPROC) (GLuint path, GLenum coverMode); +typedef void (GL_APIENTRYP PFNGLCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef void (GL_APIENTRYP PFNGLCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef void (GL_APIENTRYP PFNGLGETPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, GLint *value); +typedef void (GL_APIENTRYP PFNGLGETPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, GLfloat *value); +typedef void (GL_APIENTRYP PFNGLGETPATHCOMMANDSNVPROC) (GLuint path, GLubyte *commands); +typedef void (GL_APIENTRYP PFNGLGETPATHCOORDSNVPROC) (GLuint path, GLfloat *coords); +typedef void (GL_APIENTRYP PFNGLGETPATHDASHARRAYNVPROC) (GLuint path, GLfloat *dashArray); +typedef void (GL_APIENTRYP PFNGLGETPATHMETRICSNVPROC) (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); +typedef void (GL_APIENTRYP PFNGLGETPATHMETRICRANGENVPROC) (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); +typedef void (GL_APIENTRYP PFNGLGETPATHSPACINGNVPROC) (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); +typedef GLboolean (GL_APIENTRYP PFNGLISPOINTINFILLPATHNVPROC) (GLuint path, GLuint mask, GLfloat x, GLfloat y); +typedef GLboolean (GL_APIENTRYP PFNGLISPOINTINSTROKEPATHNVPROC) (GLuint path, GLfloat x, GLfloat y); +typedef GLfloat (GL_APIENTRYP PFNGLGETPATHLENGTHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments); +typedef GLboolean (GL_APIENTRYP PFNGLPOINTALONGPATHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); +typedef void (GL_APIENTRYP PFNGLMATRIXLOAD3X2FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (GL_APIENTRYP PFNGLMATRIXLOAD3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (GL_APIENTRYP PFNGLMATRIXLOADTRANSPOSE3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (GL_APIENTRYP PFNGLMATRIXMULT3X2FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (GL_APIENTRYP PFNGLMATRIXMULT3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (GL_APIENTRYP PFNGLMATRIXMULTTRANSPOSE3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (GL_APIENTRYP PFNGLSTENCILTHENCOVERFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask, GLenum coverMode); +typedef void (GL_APIENTRYP PFNGLSTENCILTHENCOVERSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask, GLenum coverMode); +typedef void (GL_APIENTRYP PFNGLSTENCILTHENCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef void (GL_APIENTRYP PFNGLSTENCILTHENCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef GLenum (GL_APIENTRYP PFNGLPATHGLYPHINDEXRANGENVPROC) (GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint pathParameterTemplate, GLfloat emScale, GLuint *baseAndCount); +typedef GLenum (GL_APIENTRYP PFNGLPATHGLYPHINDEXARRAYNVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef GLenum (GL_APIENTRYP PFNGLPATHMEMORYGLYPHINDEXARRAYNVPROC) (GLuint firstPathName, GLenum fontTarget, GLsizeiptr fontSize, const void *fontData, GLsizei faceIndex, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef void (GL_APIENTRYP PFNGLPROGRAMPATHFRAGMENTINPUTGENNVPROC) (GLuint program, GLint location, GLenum genMode, GLint components, const GLfloat *coeffs); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMRESOURCEFVNVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei count, GLsizei *length, GLfloat *params); +typedef void (GL_APIENTRYP PFNGLMATRIXFRUSTUMEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef void (GL_APIENTRYP PFNGLMATRIXLOADIDENTITYEXTPROC) (GLenum mode); +typedef void (GL_APIENTRYP PFNGLMATRIXLOADTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (GL_APIENTRYP PFNGLMATRIXLOADTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (GL_APIENTRYP PFNGLMATRIXLOADFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (GL_APIENTRYP PFNGLMATRIXLOADDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (GL_APIENTRYP PFNGLMATRIXMULTTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (GL_APIENTRYP PFNGLMATRIXMULTTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (GL_APIENTRYP PFNGLMATRIXMULTFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (GL_APIENTRYP PFNGLMATRIXMULTDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (GL_APIENTRYP PFNGLMATRIXORTHOEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef void (GL_APIENTRYP PFNGLMATRIXPOPEXTPROC) (GLenum mode); +typedef void (GL_APIENTRYP PFNGLMATRIXPUSHEXTPROC) (GLenum mode); +typedef void (GL_APIENTRYP PFNGLMATRIXROTATEFEXTPROC) (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +typedef void (GL_APIENTRYP PFNGLMATRIXROTATEDEXTPROC) (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +typedef void (GL_APIENTRYP PFNGLMATRIXSCALEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +typedef void (GL_APIENTRYP PFNGLMATRIXSCALEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +typedef void (GL_APIENTRYP PFNGLMATRIXTRANSLATEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +typedef void (GL_APIENTRYP PFNGLMATRIXTRANSLATEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL GLuint GL_APIENTRY glGenPathsNV (GLsizei range); +GL_APICALL void GL_APIENTRY glDeletePathsNV (GLuint path, GLsizei range); +GL_APICALL GLboolean GL_APIENTRY glIsPathNV (GLuint path); +GL_APICALL void GL_APIENTRY glPathCommandsNV (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); +GL_APICALL void GL_APIENTRY glPathCoordsNV (GLuint path, GLsizei numCoords, GLenum coordType, const void *coords); +GL_APICALL void GL_APIENTRY glPathSubCommandsNV (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); +GL_APICALL void GL_APIENTRY glPathSubCoordsNV (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const void *coords); +GL_APICALL void GL_APIENTRY glPathStringNV (GLuint path, GLenum format, GLsizei length, const void *pathString); +GL_APICALL void GL_APIENTRY glPathGlyphsNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const void *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GL_APICALL void GL_APIENTRY glPathGlyphRangeNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GL_APICALL void GL_APIENTRY glWeightPathsNV (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); +GL_APICALL void GL_APIENTRY glCopyPathNV (GLuint resultPath, GLuint srcPath); +GL_APICALL void GL_APIENTRY glInterpolatePathsNV (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); +GL_APICALL void GL_APIENTRY glTransformPathNV (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); +GL_APICALL void GL_APIENTRY glPathParameterivNV (GLuint path, GLenum pname, const GLint *value); +GL_APICALL void GL_APIENTRY glPathParameteriNV (GLuint path, GLenum pname, GLint value); +GL_APICALL void GL_APIENTRY glPathParameterfvNV (GLuint path, GLenum pname, const GLfloat *value); +GL_APICALL void GL_APIENTRY glPathParameterfNV (GLuint path, GLenum pname, GLfloat value); +GL_APICALL void GL_APIENTRY glPathDashArrayNV (GLuint path, GLsizei dashCount, const GLfloat *dashArray); +GL_APICALL void GL_APIENTRY glPathStencilFuncNV (GLenum func, GLint ref, GLuint mask); +GL_APICALL void GL_APIENTRY glPathStencilDepthOffsetNV (GLfloat factor, GLfloat units); +GL_APICALL void GL_APIENTRY glStencilFillPathNV (GLuint path, GLenum fillMode, GLuint mask); +GL_APICALL void GL_APIENTRY glStencilStrokePathNV (GLuint path, GLint reference, GLuint mask); +GL_APICALL void GL_APIENTRY glStencilFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); +GL_APICALL void GL_APIENTRY glStencilStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); +GL_APICALL void GL_APIENTRY glPathCoverDepthFuncNV (GLenum func); +GL_APICALL void GL_APIENTRY glCoverFillPathNV (GLuint path, GLenum coverMode); +GL_APICALL void GL_APIENTRY glCoverStrokePathNV (GLuint path, GLenum coverMode); +GL_APICALL void GL_APIENTRY glCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GL_APICALL void GL_APIENTRY glCoverStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GL_APICALL void GL_APIENTRY glGetPathParameterivNV (GLuint path, GLenum pname, GLint *value); +GL_APICALL void GL_APIENTRY glGetPathParameterfvNV (GLuint path, GLenum pname, GLfloat *value); +GL_APICALL void GL_APIENTRY glGetPathCommandsNV (GLuint path, GLubyte *commands); +GL_APICALL void GL_APIENTRY glGetPathCoordsNV (GLuint path, GLfloat *coords); +GL_APICALL void GL_APIENTRY glGetPathDashArrayNV (GLuint path, GLfloat *dashArray); +GL_APICALL void GL_APIENTRY glGetPathMetricsNV (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); +GL_APICALL void GL_APIENTRY glGetPathMetricRangeNV (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); +GL_APICALL void GL_APIENTRY glGetPathSpacingNV (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); +GL_APICALL GLboolean GL_APIENTRY glIsPointInFillPathNV (GLuint path, GLuint mask, GLfloat x, GLfloat y); +GL_APICALL GLboolean GL_APIENTRY glIsPointInStrokePathNV (GLuint path, GLfloat x, GLfloat y); +GL_APICALL GLfloat GL_APIENTRY glGetPathLengthNV (GLuint path, GLsizei startSegment, GLsizei numSegments); +GL_APICALL GLboolean GL_APIENTRY glPointAlongPathNV (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); +GL_APICALL void GL_APIENTRY glMatrixLoad3x2fNV (GLenum matrixMode, const GLfloat *m); +GL_APICALL void GL_APIENTRY glMatrixLoad3x3fNV (GLenum matrixMode, const GLfloat *m); +GL_APICALL void GL_APIENTRY glMatrixLoadTranspose3x3fNV (GLenum matrixMode, const GLfloat *m); +GL_APICALL void GL_APIENTRY glMatrixMult3x2fNV (GLenum matrixMode, const GLfloat *m); +GL_APICALL void GL_APIENTRY glMatrixMult3x3fNV (GLenum matrixMode, const GLfloat *m); +GL_APICALL void GL_APIENTRY glMatrixMultTranspose3x3fNV (GLenum matrixMode, const GLfloat *m); +GL_APICALL void GL_APIENTRY glStencilThenCoverFillPathNV (GLuint path, GLenum fillMode, GLuint mask, GLenum coverMode); +GL_APICALL void GL_APIENTRY glStencilThenCoverStrokePathNV (GLuint path, GLint reference, GLuint mask, GLenum coverMode); +GL_APICALL void GL_APIENTRY glStencilThenCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GL_APICALL void GL_APIENTRY glStencilThenCoverStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GL_APICALL GLenum GL_APIENTRY glPathGlyphIndexRangeNV (GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint pathParameterTemplate, GLfloat emScale, GLuint *baseAndCount); +GL_APICALL GLenum GL_APIENTRY glPathGlyphIndexArrayNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GL_APICALL GLenum GL_APIENTRY glPathMemoryGlyphIndexArrayNV (GLuint firstPathName, GLenum fontTarget, GLsizeiptr fontSize, const void *fontData, GLsizei faceIndex, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GL_APICALL void GL_APIENTRY glProgramPathFragmentInputGenNV (GLuint program, GLint location, GLenum genMode, GLint components, const GLfloat *coeffs); +GL_APICALL void GL_APIENTRY glGetProgramResourcefvNV (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei count, GLsizei *length, GLfloat *params); +GL_APICALL void GL_APIENTRY glMatrixFrustumEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GL_APICALL void GL_APIENTRY glMatrixLoadIdentityEXT (GLenum mode); +GL_APICALL void GL_APIENTRY glMatrixLoadTransposefEXT (GLenum mode, const GLfloat *m); +GL_APICALL void GL_APIENTRY glMatrixLoadTransposedEXT (GLenum mode, const GLdouble *m); +GL_APICALL void GL_APIENTRY glMatrixLoadfEXT (GLenum mode, const GLfloat *m); +GL_APICALL void GL_APIENTRY glMatrixLoaddEXT (GLenum mode, const GLdouble *m); +GL_APICALL void GL_APIENTRY glMatrixMultTransposefEXT (GLenum mode, const GLfloat *m); +GL_APICALL void GL_APIENTRY glMatrixMultTransposedEXT (GLenum mode, const GLdouble *m); +GL_APICALL void GL_APIENTRY glMatrixMultfEXT (GLenum mode, const GLfloat *m); +GL_APICALL void GL_APIENTRY glMatrixMultdEXT (GLenum mode, const GLdouble *m); +GL_APICALL void GL_APIENTRY glMatrixOrthoEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GL_APICALL void GL_APIENTRY glMatrixPopEXT (GLenum mode); +GL_APICALL void GL_APIENTRY glMatrixPushEXT (GLenum mode); +GL_APICALL void GL_APIENTRY glMatrixRotatefEXT (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +GL_APICALL void GL_APIENTRY glMatrixRotatedEXT (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +GL_APICALL void GL_APIENTRY glMatrixScalefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +GL_APICALL void GL_APIENTRY glMatrixScaledEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +GL_APICALL void GL_APIENTRY glMatrixTranslatefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +GL_APICALL void GL_APIENTRY glMatrixTranslatedEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +#endif +#endif /* GL_NV_path_rendering */ + +#ifndef GL_NV_path_rendering_shared_edge +#define GL_NV_path_rendering_shared_edge 1 +#define GL_SHARED_EDGE_NV 0xC0 +#endif /* GL_NV_path_rendering_shared_edge */ + +#ifndef GL_NV_pixel_buffer_object +#define GL_NV_pixel_buffer_object 1 +#define GL_PIXEL_PACK_BUFFER_NV 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_NV 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_NV 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_NV 0x88EF +#endif /* GL_NV_pixel_buffer_object */ + +#ifndef GL_NV_polygon_mode +#define GL_NV_polygon_mode 1 +#define GL_POLYGON_MODE_NV 0x0B40 +#define GL_POLYGON_OFFSET_POINT_NV 0x2A01 +#define GL_POLYGON_OFFSET_LINE_NV 0x2A02 +#define GL_POINT_NV 0x1B00 +#define GL_LINE_NV 0x1B01 +#define GL_FILL_NV 0x1B02 +typedef void (GL_APIENTRYP PFNGLPOLYGONMODENVPROC) (GLenum face, GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glPolygonModeNV (GLenum face, GLenum mode); +#endif +#endif /* GL_NV_polygon_mode */ + +#ifndef GL_NV_primitive_shading_rate +#define GL_NV_primitive_shading_rate 1 +#define GL_SHADING_RATE_IMAGE_PER_PRIMITIVE_NV 0x95B1 +#define GL_SHADING_RATE_IMAGE_PALETTE_COUNT_NV 0x95B2 +#endif /* GL_NV_primitive_shading_rate */ + +#ifndef GL_NV_read_buffer +#define GL_NV_read_buffer 1 +#define GL_READ_BUFFER_NV 0x0C02 +typedef void (GL_APIENTRYP PFNGLREADBUFFERNVPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glReadBufferNV (GLenum mode); +#endif +#endif /* GL_NV_read_buffer */ + +#ifndef GL_NV_read_buffer_front +#define GL_NV_read_buffer_front 1 +#endif /* GL_NV_read_buffer_front */ + +#ifndef GL_NV_read_depth +#define GL_NV_read_depth 1 +#endif /* GL_NV_read_depth */ + +#ifndef GL_NV_read_depth_stencil +#define GL_NV_read_depth_stencil 1 +#endif /* GL_NV_read_depth_stencil */ + +#ifndef GL_NV_read_stencil +#define GL_NV_read_stencil 1 +#endif /* GL_NV_read_stencil */ + +#ifndef GL_NV_representative_fragment_test +#define GL_NV_representative_fragment_test 1 +#define GL_REPRESENTATIVE_FRAGMENT_TEST_NV 0x937F +#endif /* GL_NV_representative_fragment_test */ + +#ifndef GL_NV_sRGB_formats +#define GL_NV_sRGB_formats 1 +#define GL_SLUMINANCE_NV 0x8C46 +#define GL_SLUMINANCE_ALPHA_NV 0x8C44 +#define GL_SRGB8_NV 0x8C41 +#define GL_SLUMINANCE8_NV 0x8C47 +#define GL_SLUMINANCE8_ALPHA8_NV 0x8C45 +#define GL_COMPRESSED_SRGB_S3TC_DXT1_NV 0x8C4C +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_NV 0x8C4D +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_NV 0x8C4E +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_NV 0x8C4F +#define GL_ETC1_SRGB8_NV 0x88EE +#endif /* GL_NV_sRGB_formats */ + +#ifndef GL_NV_sample_locations +#define GL_NV_sample_locations 1 +#define GL_SAMPLE_LOCATION_SUBPIXEL_BITS_NV 0x933D +#define GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_NV 0x933E +#define GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_NV 0x933F +#define GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_NV 0x9340 +#define GL_SAMPLE_LOCATION_NV 0x8E50 +#define GL_PROGRAMMABLE_SAMPLE_LOCATION_NV 0x9341 +#define GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOCATIONS_NV 0x9342 +#define GL_FRAMEBUFFER_SAMPLE_LOCATION_PIXEL_GRID_NV 0x9343 +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERSAMPLELOCATIONSFVNVPROC) (GLenum target, GLuint start, GLsizei count, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVNVPROC) (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLRESOLVEDEPTHVALUESNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glFramebufferSampleLocationsfvNV (GLenum target, GLuint start, GLsizei count, const GLfloat *v); +GL_APICALL void GL_APIENTRY glNamedFramebufferSampleLocationsfvNV (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +GL_APICALL void GL_APIENTRY glResolveDepthValuesNV (void); +#endif +#endif /* GL_NV_sample_locations */ + +#ifndef GL_NV_sample_mask_override_coverage +#define GL_NV_sample_mask_override_coverage 1 +#endif /* GL_NV_sample_mask_override_coverage */ + +#ifndef GL_NV_scissor_exclusive +#define GL_NV_scissor_exclusive 1 +#define GL_SCISSOR_TEST_EXCLUSIVE_NV 0x9555 +#define GL_SCISSOR_BOX_EXCLUSIVE_NV 0x9556 +typedef void (GL_APIENTRYP PFNGLSCISSOREXCLUSIVENVPROC) (GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLSCISSOREXCLUSIVEARRAYVNVPROC) (GLuint first, GLsizei count, const GLint *v); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glScissorExclusiveNV (GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glScissorExclusiveArrayvNV (GLuint first, GLsizei count, const GLint *v); +#endif +#endif /* GL_NV_scissor_exclusive */ + +#ifndef GL_NV_shader_atomic_fp16_vector +#define GL_NV_shader_atomic_fp16_vector 1 +#endif /* GL_NV_shader_atomic_fp16_vector */ + +#ifndef GL_NV_shader_noperspective_interpolation +#define GL_NV_shader_noperspective_interpolation 1 +#endif /* GL_NV_shader_noperspective_interpolation */ + +#ifndef GL_NV_shader_subgroup_partitioned +#define GL_NV_shader_subgroup_partitioned 1 +#define GL_SUBGROUP_FEATURE_PARTITIONED_BIT_NV 0x00000100 +#endif /* GL_NV_shader_subgroup_partitioned */ + +#ifndef GL_NV_shader_texture_footprint +#define GL_NV_shader_texture_footprint 1 +#endif /* GL_NV_shader_texture_footprint */ + +#ifndef GL_NV_shading_rate_image +#define GL_NV_shading_rate_image 1 +#define GL_SHADING_RATE_IMAGE_NV 0x9563 +#define GL_SHADING_RATE_NO_INVOCATIONS_NV 0x9564 +#define GL_SHADING_RATE_1_INVOCATION_PER_PIXEL_NV 0x9565 +#define GL_SHADING_RATE_1_INVOCATION_PER_1X2_PIXELS_NV 0x9566 +#define GL_SHADING_RATE_1_INVOCATION_PER_2X1_PIXELS_NV 0x9567 +#define GL_SHADING_RATE_1_INVOCATION_PER_2X2_PIXELS_NV 0x9568 +#define GL_SHADING_RATE_1_INVOCATION_PER_2X4_PIXELS_NV 0x9569 +#define GL_SHADING_RATE_1_INVOCATION_PER_4X2_PIXELS_NV 0x956A +#define GL_SHADING_RATE_1_INVOCATION_PER_4X4_PIXELS_NV 0x956B +#define GL_SHADING_RATE_2_INVOCATIONS_PER_PIXEL_NV 0x956C +#define GL_SHADING_RATE_4_INVOCATIONS_PER_PIXEL_NV 0x956D +#define GL_SHADING_RATE_8_INVOCATIONS_PER_PIXEL_NV 0x956E +#define GL_SHADING_RATE_16_INVOCATIONS_PER_PIXEL_NV 0x956F +#define GL_SHADING_RATE_IMAGE_BINDING_NV 0x955B +#define GL_SHADING_RATE_IMAGE_TEXEL_WIDTH_NV 0x955C +#define GL_SHADING_RATE_IMAGE_TEXEL_HEIGHT_NV 0x955D +#define GL_SHADING_RATE_IMAGE_PALETTE_SIZE_NV 0x955E +#define GL_MAX_COARSE_FRAGMENT_SAMPLES_NV 0x955F +#define GL_SHADING_RATE_SAMPLE_ORDER_DEFAULT_NV 0x95AE +#define GL_SHADING_RATE_SAMPLE_ORDER_PIXEL_MAJOR_NV 0x95AF +#define GL_SHADING_RATE_SAMPLE_ORDER_SAMPLE_MAJOR_NV 0x95B0 +typedef void (GL_APIENTRYP PFNGLBINDSHADINGRATEIMAGENVPROC) (GLuint texture); +typedef void (GL_APIENTRYP PFNGLGETSHADINGRATEIMAGEPALETTENVPROC) (GLuint viewport, GLuint entry, GLenum *rate); +typedef void (GL_APIENTRYP PFNGLGETSHADINGRATESAMPLELOCATIONIVNVPROC) (GLenum rate, GLuint samples, GLuint index, GLint *location); +typedef void (GL_APIENTRYP PFNGLSHADINGRATEIMAGEBARRIERNVPROC) (GLboolean synchronize); +typedef void (GL_APIENTRYP PFNGLSHADINGRATEIMAGEPALETTENVPROC) (GLuint viewport, GLuint first, GLsizei count, const GLenum *rates); +typedef void (GL_APIENTRYP PFNGLSHADINGRATESAMPLEORDERNVPROC) (GLenum order); +typedef void (GL_APIENTRYP PFNGLSHADINGRATESAMPLEORDERCUSTOMNVPROC) (GLenum rate, GLuint samples, const GLint *locations); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glBindShadingRateImageNV (GLuint texture); +GL_APICALL void GL_APIENTRY glGetShadingRateImagePaletteNV (GLuint viewport, GLuint entry, GLenum *rate); +GL_APICALL void GL_APIENTRY glGetShadingRateSampleLocationivNV (GLenum rate, GLuint samples, GLuint index, GLint *location); +GL_APICALL void GL_APIENTRY glShadingRateImageBarrierNV (GLboolean synchronize); +GL_APICALL void GL_APIENTRY glShadingRateImagePaletteNV (GLuint viewport, GLuint first, GLsizei count, const GLenum *rates); +GL_APICALL void GL_APIENTRY glShadingRateSampleOrderNV (GLenum order); +GL_APICALL void GL_APIENTRY glShadingRateSampleOrderCustomNV (GLenum rate, GLuint samples, const GLint *locations); +#endif +#endif /* GL_NV_shading_rate_image */ + +#ifndef GL_NV_shadow_samplers_array +#define GL_NV_shadow_samplers_array 1 +#define GL_SAMPLER_2D_ARRAY_SHADOW_NV 0x8DC4 +#endif /* GL_NV_shadow_samplers_array */ + +#ifndef GL_NV_shadow_samplers_cube +#define GL_NV_shadow_samplers_cube 1 +#define GL_SAMPLER_CUBE_SHADOW_NV 0x8DC5 +#endif /* GL_NV_shadow_samplers_cube */ + +#ifndef GL_NV_stereo_view_rendering +#define GL_NV_stereo_view_rendering 1 +#endif /* GL_NV_stereo_view_rendering */ + +#ifndef GL_NV_texture_border_clamp +#define GL_NV_texture_border_clamp 1 +#define GL_TEXTURE_BORDER_COLOR_NV 0x1004 +#define GL_CLAMP_TO_BORDER_NV 0x812D +#endif /* GL_NV_texture_border_clamp */ + +#ifndef GL_NV_texture_compression_s3tc_update +#define GL_NV_texture_compression_s3tc_update 1 +#endif /* GL_NV_texture_compression_s3tc_update */ + +#ifndef GL_NV_texture_npot_2D_mipmap +#define GL_NV_texture_npot_2D_mipmap 1 +#endif /* GL_NV_texture_npot_2D_mipmap */ + +#ifndef GL_NV_timeline_semaphore +#define GL_NV_timeline_semaphore 1 +#define GL_TIMELINE_SEMAPHORE_VALUE_NV 0x9595 +#define GL_SEMAPHORE_TYPE_NV 0x95B3 +#define GL_SEMAPHORE_TYPE_BINARY_NV 0x95B4 +#define GL_SEMAPHORE_TYPE_TIMELINE_NV 0x95B5 +#define GL_MAX_TIMELINE_SEMAPHORE_VALUE_DIFFERENCE_NV 0x95B6 +typedef void (GL_APIENTRYP PFNGLCREATESEMAPHORESNVPROC) (GLsizei n, GLuint *semaphores); +typedef void (GL_APIENTRYP PFNGLSEMAPHOREPARAMETERIVNVPROC) (GLuint semaphore, GLenum pname, const GLint *params); +typedef void (GL_APIENTRYP PFNGLGETSEMAPHOREPARAMETERIVNVPROC) (GLuint semaphore, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glCreateSemaphoresNV (GLsizei n, GLuint *semaphores); +GL_APICALL void GL_APIENTRY glSemaphoreParameterivNV (GLuint semaphore, GLenum pname, const GLint *params); +GL_APICALL void GL_APIENTRY glGetSemaphoreParameterivNV (GLuint semaphore, GLenum pname, GLint *params); +#endif +#endif /* GL_NV_timeline_semaphore */ + +#ifndef GL_NV_viewport_array +#define GL_NV_viewport_array 1 +#define GL_MAX_VIEWPORTS_NV 0x825B +#define GL_VIEWPORT_SUBPIXEL_BITS_NV 0x825C +#define GL_VIEWPORT_BOUNDS_RANGE_NV 0x825D +#define GL_VIEWPORT_INDEX_PROVOKING_VERTEX_NV 0x825F +typedef void (GL_APIENTRYP PFNGLVIEWPORTARRAYVNVPROC) (GLuint first, GLsizei count, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLVIEWPORTINDEXEDFNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +typedef void (GL_APIENTRYP PFNGLVIEWPORTINDEXEDFVNVPROC) (GLuint index, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLSCISSORARRAYVNVPROC) (GLuint first, GLsizei count, const GLint *v); +typedef void (GL_APIENTRYP PFNGLSCISSORINDEXEDNVPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLSCISSORINDEXEDVNVPROC) (GLuint index, const GLint *v); +typedef void (GL_APIENTRYP PFNGLDEPTHRANGEARRAYFVNVPROC) (GLuint first, GLsizei count, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLDEPTHRANGEINDEXEDFNVPROC) (GLuint index, GLfloat n, GLfloat f); +typedef void (GL_APIENTRYP PFNGLGETFLOATI_VNVPROC) (GLenum target, GLuint index, GLfloat *data); +typedef void (GL_APIENTRYP PFNGLENABLEINVPROC) (GLenum target, GLuint index); +typedef void (GL_APIENTRYP PFNGLDISABLEINVPROC) (GLenum target, GLuint index); +typedef GLboolean (GL_APIENTRYP PFNGLISENABLEDINVPROC) (GLenum target, GLuint index); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glViewportArrayvNV (GLuint first, GLsizei count, const GLfloat *v); +GL_APICALL void GL_APIENTRY glViewportIndexedfNV (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +GL_APICALL void GL_APIENTRY glViewportIndexedfvNV (GLuint index, const GLfloat *v); +GL_APICALL void GL_APIENTRY glScissorArrayvNV (GLuint first, GLsizei count, const GLint *v); +GL_APICALL void GL_APIENTRY glScissorIndexedNV (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glScissorIndexedvNV (GLuint index, const GLint *v); +GL_APICALL void GL_APIENTRY glDepthRangeArrayfvNV (GLuint first, GLsizei count, const GLfloat *v); +GL_APICALL void GL_APIENTRY glDepthRangeIndexedfNV (GLuint index, GLfloat n, GLfloat f); +GL_APICALL void GL_APIENTRY glGetFloati_vNV (GLenum target, GLuint index, GLfloat *data); +GL_APICALL void GL_APIENTRY glEnableiNV (GLenum target, GLuint index); +GL_APICALL void GL_APIENTRY glDisableiNV (GLenum target, GLuint index); +GL_APICALL GLboolean GL_APIENTRY glIsEnablediNV (GLenum target, GLuint index); +#endif +#endif /* GL_NV_viewport_array */ + +#ifndef GL_NV_viewport_array2 +#define GL_NV_viewport_array2 1 +#endif /* GL_NV_viewport_array2 */ + +#ifndef GL_NV_viewport_swizzle +#define GL_NV_viewport_swizzle 1 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_X_NV 0x9350 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_X_NV 0x9351 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_Y_NV 0x9352 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_Y_NV 0x9353 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_Z_NV 0x9354 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_Z_NV 0x9355 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_W_NV 0x9356 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_W_NV 0x9357 +#define GL_VIEWPORT_SWIZZLE_X_NV 0x9358 +#define GL_VIEWPORT_SWIZZLE_Y_NV 0x9359 +#define GL_VIEWPORT_SWIZZLE_Z_NV 0x935A +#define GL_VIEWPORT_SWIZZLE_W_NV 0x935B +typedef void (GL_APIENTRYP PFNGLVIEWPORTSWIZZLENVPROC) (GLuint index, GLenum swizzlex, GLenum swizzley, GLenum swizzlez, GLenum swizzlew); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glViewportSwizzleNV (GLuint index, GLenum swizzlex, GLenum swizzley, GLenum swizzlez, GLenum swizzlew); +#endif +#endif /* GL_NV_viewport_swizzle */ + +#ifndef GL_OVR_multiview +#define GL_OVR_multiview 1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_NUM_VIEWS_OVR 0x9630 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_BASE_VIEW_INDEX_OVR 0x9632 +#define GL_MAX_VIEWS_OVR 0x9631 +#define GL_FRAMEBUFFER_INCOMPLETE_VIEW_TARGETS_OVR 0x9633 +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVRPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint baseViewIndex, GLsizei numViews); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glFramebufferTextureMultiviewOVR (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint baseViewIndex, GLsizei numViews); +#endif +#endif /* GL_OVR_multiview */ + +#ifndef GL_OVR_multiview2 +#define GL_OVR_multiview2 1 +#endif /* GL_OVR_multiview2 */ + +#ifndef GL_OVR_multiview_multisampled_render_to_texture +#define GL_OVR_multiview_multisampled_render_to_texture 1 +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTUREMULTISAMPLEMULTIVIEWOVRPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLsizei samples, GLint baseViewIndex, GLsizei numViews); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glFramebufferTextureMultisampleMultiviewOVR (GLenum target, GLenum attachment, GLuint texture, GLint level, GLsizei samples, GLint baseViewIndex, GLsizei numViews); +#endif +#endif /* GL_OVR_multiview_multisampled_render_to_texture */ + +#ifndef GL_QCOM_YUV_texture_gather +#define GL_QCOM_YUV_texture_gather 1 +#endif /* GL_QCOM_YUV_texture_gather */ + +#ifndef GL_QCOM_alpha_test +#define GL_QCOM_alpha_test 1 +#define GL_ALPHA_TEST_QCOM 0x0BC0 +#define GL_ALPHA_TEST_FUNC_QCOM 0x0BC1 +#define GL_ALPHA_TEST_REF_QCOM 0x0BC2 +typedef void (GL_APIENTRYP PFNGLALPHAFUNCQCOMPROC) (GLenum func, GLclampf ref); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glAlphaFuncQCOM (GLenum func, GLclampf ref); +#endif +#endif /* GL_QCOM_alpha_test */ + +#ifndef GL_QCOM_binning_control +#define GL_QCOM_binning_control 1 +#define GL_BINNING_CONTROL_HINT_QCOM 0x8FB0 +#define GL_CPU_OPTIMIZED_QCOM 0x8FB1 +#define GL_GPU_OPTIMIZED_QCOM 0x8FB2 +#define GL_RENDER_DIRECT_TO_FRAMEBUFFER_QCOM 0x8FB3 +#endif /* GL_QCOM_binning_control */ + +#ifndef GL_QCOM_driver_control +#define GL_QCOM_driver_control 1 +typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSQCOMPROC) (GLint *num, GLsizei size, GLuint *driverControls); +typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSTRINGQCOMPROC) (GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString); +typedef void (GL_APIENTRYP PFNGLENABLEDRIVERCONTROLQCOMPROC) (GLuint driverControl); +typedef void (GL_APIENTRYP PFNGLDISABLEDRIVERCONTROLQCOMPROC) (GLuint driverControl); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGetDriverControlsQCOM (GLint *num, GLsizei size, GLuint *driverControls); +GL_APICALL void GL_APIENTRY glGetDriverControlStringQCOM (GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString); +GL_APICALL void GL_APIENTRY glEnableDriverControlQCOM (GLuint driverControl); +GL_APICALL void GL_APIENTRY glDisableDriverControlQCOM (GLuint driverControl); +#endif +#endif /* GL_QCOM_driver_control */ + +#ifndef GL_QCOM_extended_get +#define GL_QCOM_extended_get 1 +#define GL_TEXTURE_WIDTH_QCOM 0x8BD2 +#define GL_TEXTURE_HEIGHT_QCOM 0x8BD3 +#define GL_TEXTURE_DEPTH_QCOM 0x8BD4 +#define GL_TEXTURE_INTERNAL_FORMAT_QCOM 0x8BD5 +#define GL_TEXTURE_FORMAT_QCOM 0x8BD6 +#define GL_TEXTURE_TYPE_QCOM 0x8BD7 +#define GL_TEXTURE_IMAGE_VALID_QCOM 0x8BD8 +#define GL_TEXTURE_NUM_LEVELS_QCOM 0x8BD9 +#define GL_TEXTURE_TARGET_QCOM 0x8BDA +#define GL_TEXTURE_OBJECT_VALID_QCOM 0x8BDB +#define GL_STATE_RESTORE 0x8BDC +typedef void (GL_APIENTRYP PFNGLEXTGETTEXTURESQCOMPROC) (GLuint *textures, GLint maxTextures, GLint *numTextures); +typedef void (GL_APIENTRYP PFNGLEXTGETBUFFERSQCOMPROC) (GLuint *buffers, GLint maxBuffers, GLint *numBuffers); +typedef void (GL_APIENTRYP PFNGLEXTGETRENDERBUFFERSQCOMPROC) (GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers); +typedef void (GL_APIENTRYP PFNGLEXTGETFRAMEBUFFERSQCOMPROC) (GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers); +typedef void (GL_APIENTRYP PFNGLEXTGETTEXLEVELPARAMETERIVQCOMPROC) (GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLEXTTEXOBJECTSTATEOVERRIDEIQCOMPROC) (GLenum target, GLenum pname, GLint param); +typedef void (GL_APIENTRYP PFNGLEXTGETTEXSUBIMAGEQCOMPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, void *texels); +typedef void (GL_APIENTRYP PFNGLEXTGETBUFFERPOINTERVQCOMPROC) (GLenum target, void **params); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glExtGetTexturesQCOM (GLuint *textures, GLint maxTextures, GLint *numTextures); +GL_APICALL void GL_APIENTRY glExtGetBuffersQCOM (GLuint *buffers, GLint maxBuffers, GLint *numBuffers); +GL_APICALL void GL_APIENTRY glExtGetRenderbuffersQCOM (GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers); +GL_APICALL void GL_APIENTRY glExtGetFramebuffersQCOM (GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers); +GL_APICALL void GL_APIENTRY glExtGetTexLevelParameterivQCOM (GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glExtTexObjectStateOverrideiQCOM (GLenum target, GLenum pname, GLint param); +GL_APICALL void GL_APIENTRY glExtGetTexSubImageQCOM (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, void *texels); +GL_APICALL void GL_APIENTRY glExtGetBufferPointervQCOM (GLenum target, void **params); +#endif +#endif /* GL_QCOM_extended_get */ + +#ifndef GL_QCOM_extended_get2 +#define GL_QCOM_extended_get2 1 +typedef void (GL_APIENTRYP PFNGLEXTGETSHADERSQCOMPROC) (GLuint *shaders, GLint maxShaders, GLint *numShaders); +typedef void (GL_APIENTRYP PFNGLEXTGETPROGRAMSQCOMPROC) (GLuint *programs, GLint maxPrograms, GLint *numPrograms); +typedef GLboolean (GL_APIENTRYP PFNGLEXTISPROGRAMBINARYQCOMPROC) (GLuint program); +typedef void (GL_APIENTRYP PFNGLEXTGETPROGRAMBINARYSOURCEQCOMPROC) (GLuint program, GLenum shadertype, GLchar *source, GLint *length); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glExtGetShadersQCOM (GLuint *shaders, GLint maxShaders, GLint *numShaders); +GL_APICALL void GL_APIENTRY glExtGetProgramsQCOM (GLuint *programs, GLint maxPrograms, GLint *numPrograms); +GL_APICALL GLboolean GL_APIENTRY glExtIsProgramBinaryQCOM (GLuint program); +GL_APICALL void GL_APIENTRY glExtGetProgramBinarySourceQCOM (GLuint program, GLenum shadertype, GLchar *source, GLint *length); +#endif +#endif /* GL_QCOM_extended_get2 */ + +#ifndef GL_QCOM_frame_extrapolation +#define GL_QCOM_frame_extrapolation 1 +typedef void (GL_APIENTRYP PFNGLEXTRAPOLATETEX2DQCOMPROC) (GLuint src1, GLuint src2, GLuint output, GLfloat scaleFactor); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glExtrapolateTex2DQCOM (GLuint src1, GLuint src2, GLuint output, GLfloat scaleFactor); +#endif +#endif /* GL_QCOM_frame_extrapolation */ + +#ifndef GL_QCOM_framebuffer_foveated +#define GL_QCOM_framebuffer_foveated 1 +#define GL_FOVEATION_ENABLE_BIT_QCOM 0x00000001 +#define GL_FOVEATION_SCALED_BIN_METHOD_BIT_QCOM 0x00000002 +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERFOVEATIONCONFIGQCOMPROC) (GLuint framebuffer, GLuint numLayers, GLuint focalPointsPerLayer, GLuint requestedFeatures, GLuint *providedFeatures); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERFOVEATIONPARAMETERSQCOMPROC) (GLuint framebuffer, GLuint layer, GLuint focalPoint, GLfloat focalX, GLfloat focalY, GLfloat gainX, GLfloat gainY, GLfloat foveaArea); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glFramebufferFoveationConfigQCOM (GLuint framebuffer, GLuint numLayers, GLuint focalPointsPerLayer, GLuint requestedFeatures, GLuint *providedFeatures); +GL_APICALL void GL_APIENTRY glFramebufferFoveationParametersQCOM (GLuint framebuffer, GLuint layer, GLuint focalPoint, GLfloat focalX, GLfloat focalY, GLfloat gainX, GLfloat gainY, GLfloat foveaArea); +#endif +#endif /* GL_QCOM_framebuffer_foveated */ + +#ifndef GL_QCOM_motion_estimation +#define GL_QCOM_motion_estimation 1 +#define GL_MOTION_ESTIMATION_SEARCH_BLOCK_X_QCOM 0x8C90 +#define GL_MOTION_ESTIMATION_SEARCH_BLOCK_Y_QCOM 0x8C91 +typedef void (GL_APIENTRYP PFNGLTEXESTIMATEMOTIONQCOMPROC) (GLuint ref, GLuint target, GLuint output); +typedef void (GL_APIENTRYP PFNGLTEXESTIMATEMOTIONREGIONSQCOMPROC) (GLuint ref, GLuint target, GLuint output, GLuint mask); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glTexEstimateMotionQCOM (GLuint ref, GLuint target, GLuint output); +GL_APICALL void GL_APIENTRY glTexEstimateMotionRegionsQCOM (GLuint ref, GLuint target, GLuint output, GLuint mask); +#endif +#endif /* GL_QCOM_motion_estimation */ + +#ifndef GL_QCOM_perfmon_global_mode +#define GL_QCOM_perfmon_global_mode 1 +#define GL_PERFMON_GLOBAL_MODE_QCOM 0x8FA0 +#endif /* GL_QCOM_perfmon_global_mode */ + +#ifndef GL_QCOM_render_shared_exponent +#define GL_QCOM_render_shared_exponent 1 +#endif /* GL_QCOM_render_shared_exponent */ + +#ifndef GL_QCOM_shader_framebuffer_fetch_noncoherent +#define GL_QCOM_shader_framebuffer_fetch_noncoherent 1 +#define GL_FRAMEBUFFER_FETCH_NONCOHERENT_QCOM 0x96A2 +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERFETCHBARRIERQCOMPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glFramebufferFetchBarrierQCOM (void); +#endif +#endif /* GL_QCOM_shader_framebuffer_fetch_noncoherent */ + +#ifndef GL_QCOM_shader_framebuffer_fetch_rate +#define GL_QCOM_shader_framebuffer_fetch_rate 1 +#endif /* GL_QCOM_shader_framebuffer_fetch_rate */ + +#ifndef GL_QCOM_shading_rate +#define GL_QCOM_shading_rate 1 +#define GL_SHADING_RATE_QCOM 0x96A4 +#define GL_SHADING_RATE_PRESERVE_ASPECT_RATIO_QCOM 0x96A5 +#define GL_SHADING_RATE_1X1_PIXELS_QCOM 0x96A6 +#define GL_SHADING_RATE_1X2_PIXELS_QCOM 0x96A7 +#define GL_SHADING_RATE_2X1_PIXELS_QCOM 0x96A8 +#define GL_SHADING_RATE_2X2_PIXELS_QCOM 0x96A9 +#define GL_SHADING_RATE_4X2_PIXELS_QCOM 0x96AC +#define GL_SHADING_RATE_4X4_PIXELS_QCOM 0x96AE +typedef void (GL_APIENTRYP PFNGLSHADINGRATEQCOMPROC) (GLenum rate); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glShadingRateQCOM (GLenum rate); +#endif +#endif /* GL_QCOM_shading_rate */ + +#ifndef GL_QCOM_texture_foveated +#define GL_QCOM_texture_foveated 1 +#define GL_TEXTURE_FOVEATED_FEATURE_BITS_QCOM 0x8BFB +#define GL_TEXTURE_FOVEATED_MIN_PIXEL_DENSITY_QCOM 0x8BFC +#define GL_TEXTURE_FOVEATED_FEATURE_QUERY_QCOM 0x8BFD +#define GL_TEXTURE_FOVEATED_NUM_FOCAL_POINTS_QUERY_QCOM 0x8BFE +#define GL_FRAMEBUFFER_INCOMPLETE_FOVEATION_QCOM 0x8BFF +typedef void (GL_APIENTRYP PFNGLTEXTUREFOVEATIONPARAMETERSQCOMPROC) (GLuint texture, GLuint layer, GLuint focalPoint, GLfloat focalX, GLfloat focalY, GLfloat gainX, GLfloat gainY, GLfloat foveaArea); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glTextureFoveationParametersQCOM (GLuint texture, GLuint layer, GLuint focalPoint, GLfloat focalX, GLfloat focalY, GLfloat gainX, GLfloat gainY, GLfloat foveaArea); +#endif +#endif /* GL_QCOM_texture_foveated */ + +#ifndef GL_QCOM_texture_foveated2 +#define GL_QCOM_texture_foveated2 1 +#define GL_TEXTURE_FOVEATED_CUTOFF_DENSITY_QCOM 0x96A0 +#endif /* GL_QCOM_texture_foveated2 */ + +#ifndef GL_QCOM_texture_foveated_subsampled_layout +#define GL_QCOM_texture_foveated_subsampled_layout 1 +#define GL_FOVEATION_SUBSAMPLED_LAYOUT_METHOD_BIT_QCOM 0x00000004 +#define GL_MAX_SHADER_SUBSAMPLED_IMAGE_UNITS_QCOM 0x8FA1 +#endif /* GL_QCOM_texture_foveated_subsampled_layout */ + +#ifndef GL_QCOM_tiled_rendering +#define GL_QCOM_tiled_rendering 1 +#define GL_COLOR_BUFFER_BIT0_QCOM 0x00000001 +#define GL_COLOR_BUFFER_BIT1_QCOM 0x00000002 +#define GL_COLOR_BUFFER_BIT2_QCOM 0x00000004 +#define GL_COLOR_BUFFER_BIT3_QCOM 0x00000008 +#define GL_COLOR_BUFFER_BIT4_QCOM 0x00000010 +#define GL_COLOR_BUFFER_BIT5_QCOM 0x00000020 +#define GL_COLOR_BUFFER_BIT6_QCOM 0x00000040 +#define GL_COLOR_BUFFER_BIT7_QCOM 0x00000080 +#define GL_DEPTH_BUFFER_BIT0_QCOM 0x00000100 +#define GL_DEPTH_BUFFER_BIT1_QCOM 0x00000200 +#define GL_DEPTH_BUFFER_BIT2_QCOM 0x00000400 +#define GL_DEPTH_BUFFER_BIT3_QCOM 0x00000800 +#define GL_DEPTH_BUFFER_BIT4_QCOM 0x00001000 +#define GL_DEPTH_BUFFER_BIT5_QCOM 0x00002000 +#define GL_DEPTH_BUFFER_BIT6_QCOM 0x00004000 +#define GL_DEPTH_BUFFER_BIT7_QCOM 0x00008000 +#define GL_STENCIL_BUFFER_BIT0_QCOM 0x00010000 +#define GL_STENCIL_BUFFER_BIT1_QCOM 0x00020000 +#define GL_STENCIL_BUFFER_BIT2_QCOM 0x00040000 +#define GL_STENCIL_BUFFER_BIT3_QCOM 0x00080000 +#define GL_STENCIL_BUFFER_BIT4_QCOM 0x00100000 +#define GL_STENCIL_BUFFER_BIT5_QCOM 0x00200000 +#define GL_STENCIL_BUFFER_BIT6_QCOM 0x00400000 +#define GL_STENCIL_BUFFER_BIT7_QCOM 0x00800000 +#define GL_MULTISAMPLE_BUFFER_BIT0_QCOM 0x01000000 +#define GL_MULTISAMPLE_BUFFER_BIT1_QCOM 0x02000000 +#define GL_MULTISAMPLE_BUFFER_BIT2_QCOM 0x04000000 +#define GL_MULTISAMPLE_BUFFER_BIT3_QCOM 0x08000000 +#define GL_MULTISAMPLE_BUFFER_BIT4_QCOM 0x10000000 +#define GL_MULTISAMPLE_BUFFER_BIT5_QCOM 0x20000000 +#define GL_MULTISAMPLE_BUFFER_BIT6_QCOM 0x40000000 +#define GL_MULTISAMPLE_BUFFER_BIT7_QCOM 0x80000000 +typedef void (GL_APIENTRYP PFNGLSTARTTILINGQCOMPROC) (GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask); +typedef void (GL_APIENTRYP PFNGLENDTILINGQCOMPROC) (GLbitfield preserveMask); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glStartTilingQCOM (GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask); +GL_APICALL void GL_APIENTRY glEndTilingQCOM (GLbitfield preserveMask); +#endif +#endif /* GL_QCOM_tiled_rendering */ + +#ifndef GL_QCOM_writeonly_rendering +#define GL_QCOM_writeonly_rendering 1 +#define GL_WRITEONLY_RENDERING_QCOM 0x8823 +#endif /* GL_QCOM_writeonly_rendering */ + +#ifndef GL_VIV_shader_binary +#define GL_VIV_shader_binary 1 +#define GL_SHADER_BINARY_VIV 0x8FC4 +#endif /* GL_VIV_shader_binary */ + +#ifdef __cplusplus +} +#endif + +#endif diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_opengles2_gl2platform.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_opengles2_gl2platform.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,27 @@ +#ifndef __gl2platform_h_ +#define __gl2platform_h_ + +/* +** Copyright 2017-2020 The Khronos Group Inc. +** SPDX-License-Identifier: Apache-2.0 +*/ + +/* Platform-specific types and definitions for OpenGL ES 2.X gl2.h + * + * Adopters may modify khrplatform.h and this file to suit their platform. + * Please contribute modifications back to Khronos as pull requests on the + * public github repository: + * https://github.com/KhronosGroup/OpenGL-Registry + */ + +/*#include */ + +#ifndef GL_APICALL +#define GL_APICALL KHRONOS_APICALL +#endif + +#ifndef GL_APIENTRY +#define GL_APIENTRY KHRONOS_APIENTRY +#endif + +#endif /* __gl2platform_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_opengles2_khrplatform.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_opengles2_khrplatform.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,311 @@ +#ifndef __khrplatform_h_ +#define __khrplatform_h_ + +/* +** Copyright (c) 2008-2018 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +/* Khronos platform-specific types and definitions. + * + * The master copy of khrplatform.h is maintained in the Khronos EGL + * Registry repository at https://github.com/KhronosGroup/EGL-Registry + * The last semantic modification to khrplatform.h was at commit ID: + * 67a3e0864c2d75ea5287b9f3d2eb74a745936692 + * + * Adopters may modify this file to suit their platform. Adopters are + * encouraged to submit platform specific modifications to the Khronos + * group so that they can be included in future versions of this file. + * Please submit changes by filing pull requests or issues on + * the EGL Registry repository linked above. + * + * + * See the Implementer's Guidelines for information about where this file + * should be located on your system and for more details of its use: + * http://www.khronos.org/registry/implementers_guide.pdf + * + * This file should be included as + * #include + * by Khronos client API header files that use its types and defines. + * + * The types in khrplatform.h should only be used to define API-specific types. + * + * Types defined in khrplatform.h: + * khronos_int8_t signed 8 bit + * khronos_uint8_t unsigned 8 bit + * khronos_int16_t signed 16 bit + * khronos_uint16_t unsigned 16 bit + * khronos_int32_t signed 32 bit + * khronos_uint32_t unsigned 32 bit + * khronos_int64_t signed 64 bit + * khronos_uint64_t unsigned 64 bit + * khronos_intptr_t signed same number of bits as a pointer + * khronos_uintptr_t unsigned same number of bits as a pointer + * khronos_ssize_t signed size + * khronos_usize_t unsigned size + * khronos_float_t signed 32 bit floating point + * khronos_time_ns_t unsigned 64 bit time in nanoseconds + * khronos_utime_nanoseconds_t unsigned time interval or absolute time in + * nanoseconds + * khronos_stime_nanoseconds_t signed time interval in nanoseconds + * khronos_boolean_enum_t enumerated boolean type. This should + * only be used as a base type when a client API's boolean type is + * an enum. Client APIs which use an integer or other type for + * booleans cannot use this as the base type for their boolean. + * + * Tokens defined in khrplatform.h: + * + * KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values. + * + * KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0. + * KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0. + * + * Calling convention macros defined in this file: + * KHRONOS_APICALL + * KHRONOS_APIENTRY + * KHRONOS_APIATTRIBUTES + * + * These may be used in function prototypes as: + * + * KHRONOS_APICALL void KHRONOS_APIENTRY funcname( + * int arg1, + * int arg2) KHRONOS_APIATTRIBUTES; + */ + +#if defined(__SCITECH_SNAP__) && !defined(KHRONOS_STATIC) +# define KHRONOS_STATIC 1 +#endif + +/*------------------------------------------------------------------------- + * Definition of KHRONOS_APICALL + *------------------------------------------------------------------------- + * This precedes the return type of the function in the function prototype. + */ +#if defined(KHRONOS_STATIC) + /* If the preprocessor constant KHRONOS_STATIC is defined, make the + * header compatible with static linking. */ +# define KHRONOS_APICALL +#elif defined(_WIN32) +# define KHRONOS_APICALL __declspec(dllimport) +#elif defined (__SYMBIAN32__) +# define KHRONOS_APICALL IMPORT_C +#elif defined(__ANDROID__) +# define KHRONOS_APICALL __attribute__((visibility("default"))) +#else +# define KHRONOS_APICALL +#endif + +/*------------------------------------------------------------------------- + * Definition of KHRONOS_APIENTRY + *------------------------------------------------------------------------- + * This follows the return type of the function and precedes the function + * name in the function prototype. + */ +#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__) + /* Win32 but not WinCE */ +# define KHRONOS_APIENTRY __stdcall +#else +# define KHRONOS_APIENTRY +#endif + +/*------------------------------------------------------------------------- + * Definition of KHRONOS_APIATTRIBUTES + *------------------------------------------------------------------------- + * This follows the closing parenthesis of the function prototype arguments. + */ +#if defined (__ARMCC_2__) +#define KHRONOS_APIATTRIBUTES __softfp +#else +#define KHRONOS_APIATTRIBUTES +#endif + +/*------------------------------------------------------------------------- + * basic type definitions + *-----------------------------------------------------------------------*/ +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__) + + +/* + * Using + */ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 +/* + * To support platform where unsigned long cannot be used interchangeably with + * inptr_t (e.g. CHERI-extended ISAs), we can use the stdint.h intptr_t. + * Ideally, we could just use (u)intptr_t everywhere, but this could result in + * ABI breakage if khronos_uintptr_t is changed from unsigned long to + * unsigned long long or similar (this results in different C++ name mangling). + * To avoid changes for existing platforms, we restrict usage of intptr_t to + * platforms where the size of a pointer is larger than the size of long. + */ +#if defined(__SIZEOF_LONG__) && defined(__SIZEOF_POINTER__) +#if __SIZEOF_POINTER__ > __SIZEOF_LONG__ +#define KHRONOS_USE_INTPTR_T +#endif +#endif + +#elif defined(__VMS ) || defined(__sgi) + +/* + * Using + */ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(_WIN32) && !defined(__SCITECH_SNAP__) + +/* + * Win32 + */ +typedef __int32 khronos_int32_t; +typedef unsigned __int32 khronos_uint32_t; +typedef __int64 khronos_int64_t; +typedef unsigned __int64 khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(__sun__) || defined(__digital__) + +/* + * Sun or Digital + */ +typedef int khronos_int32_t; +typedef unsigned int khronos_uint32_t; +#if defined(__arch64__) || defined(_LP64) +typedef long int khronos_int64_t; +typedef unsigned long int khronos_uint64_t; +#else +typedef long long int khronos_int64_t; +typedef unsigned long long int khronos_uint64_t; +#endif /* __arch64__ */ +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif 0 + +/* + * Hypothetical platform with no float or int64 support + */ +typedef int khronos_int32_t; +typedef unsigned int khronos_uint32_t; +#define KHRONOS_SUPPORT_INT64 0 +#define KHRONOS_SUPPORT_FLOAT 0 + +#else + +/* + * Generic fallback + */ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#endif + + +/* + * Types that are (so far) the same on all platforms + */ +typedef signed char khronos_int8_t; +typedef unsigned char khronos_uint8_t; +typedef signed short int khronos_int16_t; +typedef unsigned short int khronos_uint16_t; + +/* + * Types that differ between LLP64 and LP64 architectures - in LLP64, + * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears + * to be the only LLP64 architecture in current use. + */ +#ifdef KHRONOS_USE_INTPTR_T +typedef intptr_t khronos_intptr_t; +typedef uintptr_t khronos_uintptr_t; +#elif defined(_WIN64) +typedef signed long long int khronos_intptr_t; +typedef unsigned long long int khronos_uintptr_t; +#else +typedef signed long int khronos_intptr_t; +typedef unsigned long int khronos_uintptr_t; +#endif + +#if defined(_WIN64) +typedef signed long long int khronos_ssize_t; +typedef unsigned long long int khronos_usize_t; +#else +typedef signed long int khronos_ssize_t; +typedef unsigned long int khronos_usize_t; +#endif + +#if KHRONOS_SUPPORT_FLOAT +/* + * Float type + */ +typedef float khronos_float_t; +#endif + +#if KHRONOS_SUPPORT_INT64 +/* Time types + * + * These types can be used to represent a time interval in nanoseconds or + * an absolute Unadjusted System Time. Unadjusted System Time is the number + * of nanoseconds since some arbitrary system event (e.g. since the last + * time the system booted). The Unadjusted System Time is an unsigned + * 64 bit value that wraps back to 0 every 584 years. Time intervals + * may be either signed or unsigned. + */ +typedef khronos_uint64_t khronos_utime_nanoseconds_t; +typedef khronos_int64_t khronos_stime_nanoseconds_t; +#endif + +/* + * Dummy value used to pad enum types to 32 bits. + */ +#ifndef KHRONOS_MAX_ENUM +#define KHRONOS_MAX_ENUM 0x7FFFFFFF +#endif + +/* + * Enumerated boolean type + * + * Values other than zero should be considered to be true. Therefore + * comparisons should not be made against KHRONOS_TRUE. + */ +typedef enum { + KHRONOS_FALSE = 0, + KHRONOS_TRUE = 1, + KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM +} khronos_boolean_enum_t; + +#endif /* __khrplatform_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_pen.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_pen.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,198 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * # CategoryPen + * + * SDL pen event handling. + * + * SDL provides an API for pressure-sensitive pen (stylus and/or eraser) + * handling, e.g., for input and drawing tablets or suitably equipped mobile / + * tablet devices. + * + * To get started with pens, simply handle pen events: + * + * - SDL_EVENT_PEN_PROXIMITY_IN, SDL_EVENT_PEN_PROXIMITY_OUT + * (SDL_PenProximityEvent) + * - SDL_EVENT_PEN_DOWN, SDL_EVENT_PEN_UP (SDL_PenTouchEvent) + * - SDL_EVENT_PEN_MOTION (SDL_PenMotionEvent) + * - SDL_EVENT_PEN_BUTTON_DOWN, SDL_EVENT_PEN_BUTTON_UP (SDL_PenButtonEvent) + * - SDL_EVENT_PEN_AXIS (SDL_PenAxisEvent) + * + * Pens may provide more than simple touch input; they might have other axes, + * such as pressure, tilt, rotation, etc. + * + * When a pen starts providing input, SDL will assign it a unique SDL_PenID, + * which will remain for the life of the process, as long as the pen stays + * connected. A pen leaving proximity (being taken far enough away from the + * digitizer tablet that it no longer reponds) and then coming back should + * fire proximity events, but the SDL_PenID should remain consistent. + * Unplugging the digitizer and reconnecting may cause future input to have a + * new SDL_PenID, as SDL may not know that this is the same hardware. + * + * Please note that various platforms vary wildly in how (and how well) they + * support pen input. If your pen supports some piece of functionality but SDL + * doesn't seem to, it might actually be the operating system's fault. For + * example, some platforms can manage multiple devices at the same time, but + * others will make any connected pens look like a single logical device, much + * how all USB mice connected to a computer will move the same system cursor. + * cursor. Other platforms might not support pen buttons, or the distance + * axis, etc. Very few platforms can even report _what_ functionality the pen + * supports in the first place, so best practices is to either build UI to let + * the user configure their pens, or be prepared to handle new functionality + * for a pen the first time an event is reported. + */ + +#ifndef SDL_pen_h_ +#define SDL_pen_h_ + +#include +#include +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * SDL pen instance IDs. + * + * Zero is used to signify an invalid/null device. + * + * These show up in pen events when SDL sees input from them. They remain + * consistent as long as SDL can recognize a tool to be the same pen; but if a + * pen's digitizer table is physically detached from the computer, it might + * get a new ID when reconnected, as SDL won't know it's the same device. + * + * These IDs are only stable within a single run of a program; the next time a + * program is run, the pen's ID will likely be different, even if the hardware + * hasn't been disconnected, etc. + * + * \since This datatype is available since SDL 3.2.0. + */ +typedef Uint32 SDL_PenID; + +/** + * The SDL_MouseID for mouse events simulated with pen input. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PEN_MOUSEID ((SDL_MouseID)-2) + +/** + * The SDL_TouchID for touch events simulated with pen input. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PEN_TOUCHID ((SDL_TouchID)-2) + +/** + * Pen input flags, as reported by various pen events' `pen_state` field. + * + * \since This datatype is available since SDL 3.2.0. + */ +typedef Uint32 SDL_PenInputFlags; + +#define SDL_PEN_INPUT_DOWN (1u << 0) /**< pen is pressed down */ +#define SDL_PEN_INPUT_BUTTON_1 (1u << 1) /**< button 1 is pressed */ +#define SDL_PEN_INPUT_BUTTON_2 (1u << 2) /**< button 2 is pressed */ +#define SDL_PEN_INPUT_BUTTON_3 (1u << 3) /**< button 3 is pressed */ +#define SDL_PEN_INPUT_BUTTON_4 (1u << 4) /**< button 4 is pressed */ +#define SDL_PEN_INPUT_BUTTON_5 (1u << 5) /**< button 5 is pressed */ +#define SDL_PEN_INPUT_ERASER_TIP (1u << 30) /**< eraser tip is used */ +#define SDL_PEN_INPUT_IN_PROXIMITY (1u << 31) /**< pen is in proximity (since SDL 3.4.0) */ + +/** + * Pen axis indices. + * + * These are the valid values for the `axis` field in SDL_PenAxisEvent. All + * axes are either normalised to 0..1 or report a (positive or negative) angle + * in degrees, with 0.0 representing the centre. Not all pens/backends support + * all axes: unsupported axes are always zero. + * + * To convert angles for tilt and rotation into vector representation, use + * SDL_sinf on the XTILT, YTILT, or ROTATION component, for example: + * + * `SDL_sinf(xtilt * SDL_PI_F / 180.0)`. + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_PenAxis +{ + SDL_PEN_AXIS_PRESSURE, /**< Pen pressure. Unidirectional: 0 to 1.0 */ + SDL_PEN_AXIS_XTILT, /**< Pen horizontal tilt angle. Bidirectional: -90.0 to 90.0 (left-to-right). */ + SDL_PEN_AXIS_YTILT, /**< Pen vertical tilt angle. Bidirectional: -90.0 to 90.0 (top-to-down). */ + SDL_PEN_AXIS_DISTANCE, /**< Pen distance to drawing surface. Unidirectional: 0.0 to 1.0 */ + SDL_PEN_AXIS_ROTATION, /**< Pen barrel rotation. Bidirectional: -180 to 179.9 (clockwise, 0 is facing up, -180.0 is facing down). */ + SDL_PEN_AXIS_SLIDER, /**< Pen finger wheel or slider (e.g., Airbrush Pen). Unidirectional: 0 to 1.0 */ + SDL_PEN_AXIS_TANGENTIAL_PRESSURE, /**< Pressure from squeezing the pen ("barrel pressure"). */ + SDL_PEN_AXIS_COUNT /**< Total known pen axis types in this version of SDL. This number may grow in future releases! */ +} SDL_PenAxis; + +/** + * An enum that describes the type of a pen device. + * + * A "direct" device is a pen that touches a graphic display (like an Apple + * Pencil on an iPad's screen). "Indirect" devices touch an external tablet + * surface that is connected to the machine but is not a display (like a + * lower-end Wacom tablet connected over USB). + * + * Apps may use this information to decide if they should draw a cursor; if + * the pen is touching the screen directly, a cursor doesn't make sense and + * can be in the way, but becomes necessary for indirect devices to know where + * on the display they are interacting. + * + * \since This enum is available since SDL 3.4.0. + */ +typedef enum SDL_PenDeviceType +{ + SDL_PEN_DEVICE_TYPE_INVALID = -1, /**< Not a valid pen device. */ + SDL_PEN_DEVICE_TYPE_UNKNOWN, /**< Don't know specifics of this pen. */ + SDL_PEN_DEVICE_TYPE_DIRECT, /**< Pen touches display. */ + SDL_PEN_DEVICE_TYPE_INDIRECT /**< Pen touches something that isn't the display. */ +} SDL_PenDeviceType; + +/** + * Get the device type of the given pen. + * + * Many platforms do not supply this information, so an app must always be + * prepared to get an SDL_PEN_DEVICE_TYPE_UNKNOWN result. + * + * \param instance_id the pen instance ID. + * \returns the device type of the given pen, or SDL_PEN_DEVICE_TYPE_INVALID + * on failure; call SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.4.0. + */ +extern SDL_DECLSPEC SDL_PenDeviceType SDLCALL SDL_GetPenDeviceType(SDL_PenID instance_id); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_pen_h_ */ + diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_pixels.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_pixels.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,1441 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * # CategoryPixels + * + * SDL offers facilities for pixel management. + * + * Largely these facilities deal with pixel _format_: what does this set of + * bits represent? + * + * If you mostly want to think of a pixel as some combination of red, green, + * blue, and maybe alpha intensities, this is all pretty straightforward, and + * in many cases, is enough information to build a perfectly fine game. + * + * However, the actual definition of a pixel is more complex than that: + * + * Pixels are a representation of a color in a particular color space. + * + * The first characteristic of a color space is the color type. SDL + * understands two different color types, RGB and YCbCr, or in SDL also + * referred to as YUV. + * + * RGB colors consist of red, green, and blue channels of color that are added + * together to represent the colors we see on the screen. + * + * https://en.wikipedia.org/wiki/RGB_color_model + * + * YCbCr colors represent colors as a Y luma brightness component and red and + * blue chroma color offsets. This color representation takes advantage of the + * fact that the human eye is more sensitive to brightness than the color in + * an image. The Cb and Cr components are often compressed and have lower + * resolution than the luma component. + * + * https://en.wikipedia.org/wiki/YCbCr + * + * When the color information in YCbCr is compressed, the Y pixels are left at + * full resolution and each Cr and Cb pixel represents an average of the color + * information in a block of Y pixels. The chroma location determines where in + * that block of pixels the color information is coming from. + * + * The color range defines how much of the pixel to use when converting a + * pixel into a color on the display. When the full color range is used, the + * entire numeric range of the pixel bits is significant. When narrow color + * range is used, for historical reasons, the pixel uses only a portion of the + * numeric range to represent colors. + * + * The color primaries and white point are a definition of the colors in the + * color space relative to the standard XYZ color space. + * + * https://en.wikipedia.org/wiki/CIE_1931_color_space + * + * The transfer characteristic, or opto-electrical transfer function (OETF), + * is the way a color is converted from mathematically linear space into a + * non-linear output signals. + * + * https://en.wikipedia.org/wiki/Rec._709#Transfer_characteristics + * + * The matrix coefficients are used to convert between YCbCr and RGB colors. + */ + +#ifndef SDL_pixels_h_ +#define SDL_pixels_h_ + +#include +#include +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * A fully opaque 8-bit alpha value. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_ALPHA_TRANSPARENT + */ +#define SDL_ALPHA_OPAQUE 255 + +/** + * A fully opaque floating point alpha value. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_ALPHA_TRANSPARENT_FLOAT + */ +#define SDL_ALPHA_OPAQUE_FLOAT 1.0f + +/** + * A fully transparent 8-bit alpha value. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_ALPHA_OPAQUE + */ +#define SDL_ALPHA_TRANSPARENT 0 + +/** + * A fully transparent floating point alpha value. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_ALPHA_OPAQUE_FLOAT + */ +#define SDL_ALPHA_TRANSPARENT_FLOAT 0.0f + +/** + * Pixel type. + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_PixelType +{ + SDL_PIXELTYPE_UNKNOWN, + SDL_PIXELTYPE_INDEX1, + SDL_PIXELTYPE_INDEX4, + SDL_PIXELTYPE_INDEX8, + SDL_PIXELTYPE_PACKED8, + SDL_PIXELTYPE_PACKED16, + SDL_PIXELTYPE_PACKED32, + SDL_PIXELTYPE_ARRAYU8, + SDL_PIXELTYPE_ARRAYU16, + SDL_PIXELTYPE_ARRAYU32, + SDL_PIXELTYPE_ARRAYF16, + SDL_PIXELTYPE_ARRAYF32, + /* appended at the end for compatibility with sdl2-compat: */ + SDL_PIXELTYPE_INDEX2 +} SDL_PixelType; + +/** + * Bitmap pixel order, high bit -> low bit. + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_BitmapOrder +{ + SDL_BITMAPORDER_NONE, + SDL_BITMAPORDER_4321, + SDL_BITMAPORDER_1234 +} SDL_BitmapOrder; + +/** + * Packed component order, high bit -> low bit. + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_PackedOrder +{ + SDL_PACKEDORDER_NONE, + SDL_PACKEDORDER_XRGB, + SDL_PACKEDORDER_RGBX, + SDL_PACKEDORDER_ARGB, + SDL_PACKEDORDER_RGBA, + SDL_PACKEDORDER_XBGR, + SDL_PACKEDORDER_BGRX, + SDL_PACKEDORDER_ABGR, + SDL_PACKEDORDER_BGRA +} SDL_PackedOrder; + +/** + * Array component order, low byte -> high byte. + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_ArrayOrder +{ + SDL_ARRAYORDER_NONE, + SDL_ARRAYORDER_RGB, + SDL_ARRAYORDER_RGBA, + SDL_ARRAYORDER_ARGB, + SDL_ARRAYORDER_BGR, + SDL_ARRAYORDER_BGRA, + SDL_ARRAYORDER_ABGR +} SDL_ArrayOrder; + +/** + * Packed component layout. + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_PackedLayout +{ + SDL_PACKEDLAYOUT_NONE, + SDL_PACKEDLAYOUT_332, + SDL_PACKEDLAYOUT_4444, + SDL_PACKEDLAYOUT_1555, + SDL_PACKEDLAYOUT_5551, + SDL_PACKEDLAYOUT_565, + SDL_PACKEDLAYOUT_8888, + SDL_PACKEDLAYOUT_2101010, + SDL_PACKEDLAYOUT_1010102 +} SDL_PackedLayout; + +/** + * A macro for defining custom FourCC pixel formats. + * + * For example, defining SDL_PIXELFORMAT_YV12 looks like this: + * + * ```c + * SDL_DEFINE_PIXELFOURCC('Y', 'V', '1', '2') + * ``` + * + * \param A the first character of the FourCC code. + * \param B the second character of the FourCC code. + * \param C the third character of the FourCC code. + * \param D the fourth character of the FourCC code. + * \returns a format value in the style of SDL_PixelFormat. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_DEFINE_PIXELFOURCC(A, B, C, D) SDL_FOURCC(A, B, C, D) + +/** + * A macro for defining custom non-FourCC pixel formats. + * + * For example, defining SDL_PIXELFORMAT_RGBA8888 looks like this: + * + * ```c + * SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBA, SDL_PACKEDLAYOUT_8888, 32, 4) + * ``` + * + * \param type the type of the new format, probably a SDL_PixelType value. + * \param order the order of the new format, probably a SDL_BitmapOrder, + * SDL_PackedOrder, or SDL_ArrayOrder value. + * \param layout the layout of the new format, probably an SDL_PackedLayout + * value or zero. + * \param bits the number of bits per pixel of the new format. + * \param bytes the number of bytes per pixel of the new format. + * \returns a format value in the style of SDL_PixelFormat. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_DEFINE_PIXELFORMAT(type, order, layout, bits, bytes) \ + ((1 << 28) | ((type) << 24) | ((order) << 20) | ((layout) << 16) | \ + ((bits) << 8) | ((bytes) << 0)) + +/** + * A macro to retrieve the flags of an SDL_PixelFormat. + * + * This macro is generally not needed directly by an app, which should use + * specific tests, like SDL_ISPIXELFORMAT_FOURCC, instead. + * + * \param format an SDL_PixelFormat to check. + * \returns the flags of `format`. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PIXELFLAG(format) (((format) >> 28) & 0x0F) + +/** + * A macro to retrieve the type of an SDL_PixelFormat. + * + * This is usually a value from the SDL_PixelType enumeration. + * + * \param format an SDL_PixelFormat to check. + * \returns the type of `format`. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PIXELTYPE(format) (((format) >> 24) & 0x0F) + +/** + * A macro to retrieve the order of an SDL_PixelFormat. + * + * This is usually a value from the SDL_BitmapOrder, SDL_PackedOrder, or + * SDL_ArrayOrder enumerations, depending on the format type. + * + * \param format an SDL_PixelFormat to check. + * \returns the order of `format`. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PIXELORDER(format) (((format) >> 20) & 0x0F) + +/** + * A macro to retrieve the layout of an SDL_PixelFormat. + * + * This is usually a value from the SDL_PackedLayout enumeration, or zero if a + * layout doesn't make sense for the format type. + * + * \param format an SDL_PixelFormat to check. + * \returns the layout of `format`. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PIXELLAYOUT(format) (((format) >> 16) & 0x0F) + +/** + * A macro to determine an SDL_PixelFormat's bits per pixel. + * + * Note that this macro double-evaluates its parameter, so do not use + * expressions with side-effects here. + * + * FourCC formats will report zero here, as it rarely makes sense to measure + * them per-pixel. + * + * \param format an SDL_PixelFormat to check. + * \returns the bits-per-pixel of `format`. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_BYTESPERPIXEL + */ +#define SDL_BITSPERPIXEL(format) \ + (SDL_ISPIXELFORMAT_FOURCC(format) ? 0 : (((format) >> 8) & 0xFF)) + +/** + * A macro to determine an SDL_PixelFormat's bytes per pixel. + * + * Note that this macro double-evaluates its parameter, so do not use + * expressions with side-effects here. + * + * FourCC formats do their best here, but many of them don't have a meaningful + * measurement of bytes per pixel. + * + * \param format an SDL_PixelFormat to check. + * \returns the bytes-per-pixel of `format`. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_BITSPERPIXEL + */ +#define SDL_BYTESPERPIXEL(format) \ + (SDL_ISPIXELFORMAT_FOURCC(format) ? \ + ((((format) == SDL_PIXELFORMAT_YUY2) || \ + ((format) == SDL_PIXELFORMAT_UYVY) || \ + ((format) == SDL_PIXELFORMAT_YVYU) || \ + ((format) == SDL_PIXELFORMAT_P010)) ? 2 : 1) : (((format) >> 0) & 0xFF)) + + +/** + * A macro to determine if an SDL_PixelFormat is an indexed format. + * + * Note that this macro double-evaluates its parameter, so do not use + * expressions with side-effects here. + * + * \param format an SDL_PixelFormat to check. + * \returns true if the format is indexed, false otherwise. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_ISPIXELFORMAT_INDEXED(format) \ + (!SDL_ISPIXELFORMAT_FOURCC(format) && \ + ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX1) || \ + (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX2) || \ + (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX4) || \ + (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX8))) + +/** + * A macro to determine if an SDL_PixelFormat is a packed format. + * + * Note that this macro double-evaluates its parameter, so do not use + * expressions with side-effects here. + * + * \param format an SDL_PixelFormat to check. + * \returns true if the format is packed, false otherwise. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_ISPIXELFORMAT_PACKED(format) \ + (!SDL_ISPIXELFORMAT_FOURCC(format) && \ + ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_PACKED8) || \ + (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_PACKED16) || \ + (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_PACKED32))) + +/** + * A macro to determine if an SDL_PixelFormat is an array format. + * + * Note that this macro double-evaluates its parameter, so do not use + * expressions with side-effects here. + * + * \param format an SDL_PixelFormat to check. + * \returns true if the format is an array, false otherwise. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_ISPIXELFORMAT_ARRAY(format) \ + (!SDL_ISPIXELFORMAT_FOURCC(format) && \ + ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYU8) || \ + (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYU16) || \ + (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYU32) || \ + (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYF16) || \ + (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYF32))) + +/** + * A macro to determine if an SDL_PixelFormat is a 10-bit format. + * + * Note that this macro double-evaluates its parameter, so do not use + * expressions with side-effects here. + * + * \param format an SDL_PixelFormat to check. + * \returns true if the format is 10-bit, false otherwise. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_ISPIXELFORMAT_10BIT(format) \ + (!SDL_ISPIXELFORMAT_FOURCC(format) && \ + ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_PACKED32) && \ + (SDL_PIXELLAYOUT(format) == SDL_PACKEDLAYOUT_2101010))) + +/** + * A macro to determine if an SDL_PixelFormat is a floating point format. + * + * Note that this macro double-evaluates its parameter, so do not use + * expressions with side-effects here. + * + * \param format an SDL_PixelFormat to check. + * \returns true if the format is a floating point, false otherwise. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_ISPIXELFORMAT_FLOAT(format) \ + (!SDL_ISPIXELFORMAT_FOURCC(format) && \ + ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYF16) || \ + (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYF32))) + +/** + * A macro to determine if an SDL_PixelFormat has an alpha channel. + * + * Note that this macro double-evaluates its parameter, so do not use + * expressions with side-effects here. + * + * \param format an SDL_PixelFormat to check. + * \returns true if the format has alpha, false otherwise. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_ISPIXELFORMAT_ALPHA(format) \ + ((SDL_ISPIXELFORMAT_PACKED(format) && \ + ((SDL_PIXELORDER(format) == SDL_PACKEDORDER_ARGB) || \ + (SDL_PIXELORDER(format) == SDL_PACKEDORDER_RGBA) || \ + (SDL_PIXELORDER(format) == SDL_PACKEDORDER_ABGR) || \ + (SDL_PIXELORDER(format) == SDL_PACKEDORDER_BGRA))) || \ + (SDL_ISPIXELFORMAT_ARRAY(format) && \ + ((SDL_PIXELORDER(format) == SDL_ARRAYORDER_ARGB) || \ + (SDL_PIXELORDER(format) == SDL_ARRAYORDER_RGBA) || \ + (SDL_PIXELORDER(format) == SDL_ARRAYORDER_ABGR) || \ + (SDL_PIXELORDER(format) == SDL_ARRAYORDER_BGRA)))) + + +/** + * A macro to determine if an SDL_PixelFormat is a "FourCC" format. + * + * This covers custom and other unusual formats. + * + * Note that this macro double-evaluates its parameter, so do not use + * expressions with side-effects here. + * + * \param format an SDL_PixelFormat to check. + * \returns true if the format has alpha, false otherwise. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_ISPIXELFORMAT_FOURCC(format) /* The flag is set to 1 because 0x1? is not in the printable ASCII range */ \ + ((format) && (SDL_PIXELFLAG(format) != 1)) + +/* Note: If you modify this enum, update SDL_GetPixelFormatName() */ + +/** + * Pixel format. + * + * SDL's pixel formats have the following naming convention: + * + * - Names with a list of components and a single bit count, such as RGB24 and + * ABGR32, define a platform-independent encoding into bytes in the order + * specified. For example, in RGB24 data, each pixel is encoded in 3 bytes + * (red, green, blue) in that order, and in ABGR32 data, each pixel is + * encoded in 4 bytes (alpha, blue, green, red) in that order. Use these + * names if the property of a format that is important to you is the order + * of the bytes in memory or on disk. + * - Names with a bit count per component, such as ARGB8888 and XRGB1555, are + * "packed" into an appropriately-sized integer in the platform's native + * endianness. For example, ARGB8888 is a sequence of 32-bit integers; in + * each integer, the most significant bits are alpha, and the least + * significant bits are blue. On a little-endian CPU such as x86, the least + * significant bits of each integer are arranged first in memory, but on a + * big-endian CPU such as s390x, the most significant bits are arranged + * first. Use these names if the property of a format that is important to + * you is the meaning of each bit position within a native-endianness + * integer. + * - In indexed formats such as INDEX4LSB, each pixel is represented by + * encoding an index into the palette into the indicated number of bits, + * with multiple pixels packed into each byte if appropriate. In LSB + * formats, the first (leftmost) pixel is stored in the least-significant + * bits of the byte; in MSB formats, it's stored in the most-significant + * bits. INDEX8 does not need LSB/MSB variants, because each pixel exactly + * fills one byte. + * + * The 32-bit byte-array encodings such as RGBA32 are aliases for the + * appropriate 8888 encoding for the current platform. For example, RGBA32 is + * an alias for ABGR8888 on little-endian CPUs like x86, or an alias for + * RGBA8888 on big-endian CPUs. + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_PixelFormat +{ + SDL_PIXELFORMAT_UNKNOWN = 0, + SDL_PIXELFORMAT_INDEX1LSB = 0x11100100u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_4321, 0, 1, 0), */ + SDL_PIXELFORMAT_INDEX1MSB = 0x11200100u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_1234, 0, 1, 0), */ + SDL_PIXELFORMAT_INDEX2LSB = 0x1c100200u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX2, SDL_BITMAPORDER_4321, 0, 2, 0), */ + SDL_PIXELFORMAT_INDEX2MSB = 0x1c200200u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX2, SDL_BITMAPORDER_1234, 0, 2, 0), */ + SDL_PIXELFORMAT_INDEX4LSB = 0x12100400u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_4321, 0, 4, 0), */ + SDL_PIXELFORMAT_INDEX4MSB = 0x12200400u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_1234, 0, 4, 0), */ + SDL_PIXELFORMAT_INDEX8 = 0x13000801u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX8, 0, 0, 8, 1), */ + SDL_PIXELFORMAT_RGB332 = 0x14110801u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED8, SDL_PACKEDORDER_XRGB, SDL_PACKEDLAYOUT_332, 8, 1), */ + SDL_PIXELFORMAT_XRGB4444 = 0x15120c02u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB, SDL_PACKEDLAYOUT_4444, 12, 2), */ + SDL_PIXELFORMAT_XBGR4444 = 0x15520c02u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR, SDL_PACKEDLAYOUT_4444, 12, 2), */ + SDL_PIXELFORMAT_XRGB1555 = 0x15130f02u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB, SDL_PACKEDLAYOUT_1555, 15, 2), */ + SDL_PIXELFORMAT_XBGR1555 = 0x15530f02u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR, SDL_PACKEDLAYOUT_1555, 15, 2), */ + SDL_PIXELFORMAT_ARGB4444 = 0x15321002u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ARGB, SDL_PACKEDLAYOUT_4444, 16, 2), */ + SDL_PIXELFORMAT_RGBA4444 = 0x15421002u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_RGBA, SDL_PACKEDLAYOUT_4444, 16, 2), */ + SDL_PIXELFORMAT_ABGR4444 = 0x15721002u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ABGR, SDL_PACKEDLAYOUT_4444, 16, 2), */ + SDL_PIXELFORMAT_BGRA4444 = 0x15821002u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_BGRA, SDL_PACKEDLAYOUT_4444, 16, 2), */ + SDL_PIXELFORMAT_ARGB1555 = 0x15331002u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ARGB, SDL_PACKEDLAYOUT_1555, 16, 2), */ + SDL_PIXELFORMAT_RGBA5551 = 0x15441002u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_RGBA, SDL_PACKEDLAYOUT_5551, 16, 2), */ + SDL_PIXELFORMAT_ABGR1555 = 0x15731002u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ABGR, SDL_PACKEDLAYOUT_1555, 16, 2), */ + SDL_PIXELFORMAT_BGRA5551 = 0x15841002u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_BGRA, SDL_PACKEDLAYOUT_5551, 16, 2), */ + SDL_PIXELFORMAT_RGB565 = 0x15151002u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB, SDL_PACKEDLAYOUT_565, 16, 2), */ + SDL_PIXELFORMAT_BGR565 = 0x15551002u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR, SDL_PACKEDLAYOUT_565, 16, 2), */ + SDL_PIXELFORMAT_RGB24 = 0x17101803u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_RGB, 0, 24, 3), */ + SDL_PIXELFORMAT_BGR24 = 0x17401803u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_BGR, 0, 24, 3), */ + SDL_PIXELFORMAT_XRGB8888 = 0x16161804u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XRGB, SDL_PACKEDLAYOUT_8888, 24, 4), */ + SDL_PIXELFORMAT_RGBX8888 = 0x16261804u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBX, SDL_PACKEDLAYOUT_8888, 24, 4), */ + SDL_PIXELFORMAT_XBGR8888 = 0x16561804u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XBGR, SDL_PACKEDLAYOUT_8888, 24, 4), */ + SDL_PIXELFORMAT_BGRX8888 = 0x16661804u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_BGRX, SDL_PACKEDLAYOUT_8888, 24, 4), */ + SDL_PIXELFORMAT_ARGB8888 = 0x16362004u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ARGB, SDL_PACKEDLAYOUT_8888, 32, 4), */ + SDL_PIXELFORMAT_RGBA8888 = 0x16462004u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBA, SDL_PACKEDLAYOUT_8888, 32, 4), */ + SDL_PIXELFORMAT_ABGR8888 = 0x16762004u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ABGR, SDL_PACKEDLAYOUT_8888, 32, 4), */ + SDL_PIXELFORMAT_BGRA8888 = 0x16862004u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_BGRA, SDL_PACKEDLAYOUT_8888, 32, 4), */ + SDL_PIXELFORMAT_XRGB2101010 = 0x16172004u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XRGB, SDL_PACKEDLAYOUT_2101010, 32, 4), */ + SDL_PIXELFORMAT_XBGR2101010 = 0x16572004u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XBGR, SDL_PACKEDLAYOUT_2101010, 32, 4), */ + SDL_PIXELFORMAT_ARGB2101010 = 0x16372004u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ARGB, SDL_PACKEDLAYOUT_2101010, 32, 4), */ + SDL_PIXELFORMAT_ABGR2101010 = 0x16772004u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ABGR, SDL_PACKEDLAYOUT_2101010, 32, 4), */ + SDL_PIXELFORMAT_RGB48 = 0x18103006u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU16, SDL_ARRAYORDER_RGB, 0, 48, 6), */ + SDL_PIXELFORMAT_BGR48 = 0x18403006u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU16, SDL_ARRAYORDER_BGR, 0, 48, 6), */ + SDL_PIXELFORMAT_RGBA64 = 0x18204008u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU16, SDL_ARRAYORDER_RGBA, 0, 64, 8), */ + SDL_PIXELFORMAT_ARGB64 = 0x18304008u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU16, SDL_ARRAYORDER_ARGB, 0, 64, 8), */ + SDL_PIXELFORMAT_BGRA64 = 0x18504008u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU16, SDL_ARRAYORDER_BGRA, 0, 64, 8), */ + SDL_PIXELFORMAT_ABGR64 = 0x18604008u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU16, SDL_ARRAYORDER_ABGR, 0, 64, 8), */ + SDL_PIXELFORMAT_RGB48_FLOAT = 0x1a103006u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF16, SDL_ARRAYORDER_RGB, 0, 48, 6), */ + SDL_PIXELFORMAT_BGR48_FLOAT = 0x1a403006u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF16, SDL_ARRAYORDER_BGR, 0, 48, 6), */ + SDL_PIXELFORMAT_RGBA64_FLOAT = 0x1a204008u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF16, SDL_ARRAYORDER_RGBA, 0, 64, 8), */ + SDL_PIXELFORMAT_ARGB64_FLOAT = 0x1a304008u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF16, SDL_ARRAYORDER_ARGB, 0, 64, 8), */ + SDL_PIXELFORMAT_BGRA64_FLOAT = 0x1a504008u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF16, SDL_ARRAYORDER_BGRA, 0, 64, 8), */ + SDL_PIXELFORMAT_ABGR64_FLOAT = 0x1a604008u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF16, SDL_ARRAYORDER_ABGR, 0, 64, 8), */ + SDL_PIXELFORMAT_RGB96_FLOAT = 0x1b10600cu, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF32, SDL_ARRAYORDER_RGB, 0, 96, 12), */ + SDL_PIXELFORMAT_BGR96_FLOAT = 0x1b40600cu, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF32, SDL_ARRAYORDER_BGR, 0, 96, 12), */ + SDL_PIXELFORMAT_RGBA128_FLOAT = 0x1b208010u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF32, SDL_ARRAYORDER_RGBA, 0, 128, 16), */ + SDL_PIXELFORMAT_ARGB128_FLOAT = 0x1b308010u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF32, SDL_ARRAYORDER_ARGB, 0, 128, 16), */ + SDL_PIXELFORMAT_BGRA128_FLOAT = 0x1b508010u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF32, SDL_ARRAYORDER_BGRA, 0, 128, 16), */ + SDL_PIXELFORMAT_ABGR128_FLOAT = 0x1b608010u, + /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF32, SDL_ARRAYORDER_ABGR, 0, 128, 16), */ + + SDL_PIXELFORMAT_YV12 = 0x32315659u, /**< Planar mode: Y + V + U (3 planes) */ + /* SDL_DEFINE_PIXELFOURCC('Y', 'V', '1', '2'), */ + SDL_PIXELFORMAT_IYUV = 0x56555949u, /**< Planar mode: Y + U + V (3 planes) */ + /* SDL_DEFINE_PIXELFOURCC('I', 'Y', 'U', 'V'), */ + SDL_PIXELFORMAT_YUY2 = 0x32595559u, /**< Packed mode: Y0+U0+Y1+V0 (1 plane) */ + /* SDL_DEFINE_PIXELFOURCC('Y', 'U', 'Y', '2'), */ + SDL_PIXELFORMAT_UYVY = 0x59565955u, /**< Packed mode: U0+Y0+V0+Y1 (1 plane) */ + /* SDL_DEFINE_PIXELFOURCC('U', 'Y', 'V', 'Y'), */ + SDL_PIXELFORMAT_YVYU = 0x55595659u, /**< Packed mode: Y0+V0+Y1+U0 (1 plane) */ + /* SDL_DEFINE_PIXELFOURCC('Y', 'V', 'Y', 'U'), */ + SDL_PIXELFORMAT_NV12 = 0x3231564eu, /**< Planar mode: Y + U/V interleaved (2 planes) */ + /* SDL_DEFINE_PIXELFOURCC('N', 'V', '1', '2'), */ + SDL_PIXELFORMAT_NV21 = 0x3132564eu, /**< Planar mode: Y + V/U interleaved (2 planes) */ + /* SDL_DEFINE_PIXELFOURCC('N', 'V', '2', '1'), */ + SDL_PIXELFORMAT_P010 = 0x30313050u, /**< Planar mode: Y + U/V interleaved (2 planes) */ + /* SDL_DEFINE_PIXELFOURCC('P', '0', '1', '0'), */ + SDL_PIXELFORMAT_EXTERNAL_OES = 0x2053454fu, /**< Android video texture format */ + /* SDL_DEFINE_PIXELFOURCC('O', 'E', 'S', ' ') */ + + SDL_PIXELFORMAT_MJPG = 0x47504a4du, /**< Motion JPEG */ + /* SDL_DEFINE_PIXELFOURCC('M', 'J', 'P', 'G') */ + + /* Aliases for RGBA byte arrays of color data, for the current platform */ + #if SDL_BYTEORDER == SDL_BIG_ENDIAN + SDL_PIXELFORMAT_RGBA32 = SDL_PIXELFORMAT_RGBA8888, + SDL_PIXELFORMAT_ARGB32 = SDL_PIXELFORMAT_ARGB8888, + SDL_PIXELFORMAT_BGRA32 = SDL_PIXELFORMAT_BGRA8888, + SDL_PIXELFORMAT_ABGR32 = SDL_PIXELFORMAT_ABGR8888, + SDL_PIXELFORMAT_RGBX32 = SDL_PIXELFORMAT_RGBX8888, + SDL_PIXELFORMAT_XRGB32 = SDL_PIXELFORMAT_XRGB8888, + SDL_PIXELFORMAT_BGRX32 = SDL_PIXELFORMAT_BGRX8888, + SDL_PIXELFORMAT_XBGR32 = SDL_PIXELFORMAT_XBGR8888 + #else + SDL_PIXELFORMAT_RGBA32 = SDL_PIXELFORMAT_ABGR8888, + SDL_PIXELFORMAT_ARGB32 = SDL_PIXELFORMAT_BGRA8888, + SDL_PIXELFORMAT_BGRA32 = SDL_PIXELFORMAT_ARGB8888, + SDL_PIXELFORMAT_ABGR32 = SDL_PIXELFORMAT_RGBA8888, + SDL_PIXELFORMAT_RGBX32 = SDL_PIXELFORMAT_XBGR8888, + SDL_PIXELFORMAT_XRGB32 = SDL_PIXELFORMAT_BGRX8888, + SDL_PIXELFORMAT_BGRX32 = SDL_PIXELFORMAT_XRGB8888, + SDL_PIXELFORMAT_XBGR32 = SDL_PIXELFORMAT_RGBX8888 + #endif +} SDL_PixelFormat; + +/** + * Colorspace color type. + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_ColorType +{ + SDL_COLOR_TYPE_UNKNOWN = 0, + SDL_COLOR_TYPE_RGB = 1, + SDL_COLOR_TYPE_YCBCR = 2 +} SDL_ColorType; + +/** + * Colorspace color range, as described by + * https://www.itu.int/rec/R-REC-BT.2100-2-201807-I/en + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_ColorRange +{ + SDL_COLOR_RANGE_UNKNOWN = 0, + SDL_COLOR_RANGE_LIMITED = 1, /**< Narrow range, e.g. 16-235 for 8-bit RGB and luma, and 16-240 for 8-bit chroma */ + SDL_COLOR_RANGE_FULL = 2 /**< Full range, e.g. 0-255 for 8-bit RGB and luma, and 1-255 for 8-bit chroma */ +} SDL_ColorRange; + +/** + * Colorspace color primaries, as described by + * https://www.itu.int/rec/T-REC-H.273-201612-S/en + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_ColorPrimaries +{ + SDL_COLOR_PRIMARIES_UNKNOWN = 0, + SDL_COLOR_PRIMARIES_BT709 = 1, /**< ITU-R BT.709-6 */ + SDL_COLOR_PRIMARIES_UNSPECIFIED = 2, + SDL_COLOR_PRIMARIES_BT470M = 4, /**< ITU-R BT.470-6 System M */ + SDL_COLOR_PRIMARIES_BT470BG = 5, /**< ITU-R BT.470-6 System B, G / ITU-R BT.601-7 625 */ + SDL_COLOR_PRIMARIES_BT601 = 6, /**< ITU-R BT.601-7 525, SMPTE 170M */ + SDL_COLOR_PRIMARIES_SMPTE240 = 7, /**< SMPTE 240M, functionally the same as SDL_COLOR_PRIMARIES_BT601 */ + SDL_COLOR_PRIMARIES_GENERIC_FILM = 8, /**< Generic film (color filters using Illuminant C) */ + SDL_COLOR_PRIMARIES_BT2020 = 9, /**< ITU-R BT.2020-2 / ITU-R BT.2100-0 */ + SDL_COLOR_PRIMARIES_XYZ = 10, /**< SMPTE ST 428-1 */ + SDL_COLOR_PRIMARIES_SMPTE431 = 11, /**< SMPTE RP 431-2 */ + SDL_COLOR_PRIMARIES_SMPTE432 = 12, /**< SMPTE EG 432-1 / DCI P3 */ + SDL_COLOR_PRIMARIES_EBU3213 = 22, /**< EBU Tech. 3213-E */ + SDL_COLOR_PRIMARIES_CUSTOM = 31 +} SDL_ColorPrimaries; + +/** + * Colorspace transfer characteristics. + * + * These are as described by https://www.itu.int/rec/T-REC-H.273-201612-S/en + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_TransferCharacteristics +{ + SDL_TRANSFER_CHARACTERISTICS_UNKNOWN = 0, + SDL_TRANSFER_CHARACTERISTICS_BT709 = 1, /**< Rec. ITU-R BT.709-6 / ITU-R BT1361 */ + SDL_TRANSFER_CHARACTERISTICS_UNSPECIFIED = 2, + SDL_TRANSFER_CHARACTERISTICS_GAMMA22 = 4, /**< ITU-R BT.470-6 System M / ITU-R BT1700 625 PAL & SECAM */ + SDL_TRANSFER_CHARACTERISTICS_GAMMA28 = 5, /**< ITU-R BT.470-6 System B, G */ + SDL_TRANSFER_CHARACTERISTICS_BT601 = 6, /**< SMPTE ST 170M / ITU-R BT.601-7 525 or 625 */ + SDL_TRANSFER_CHARACTERISTICS_SMPTE240 = 7, /**< SMPTE ST 240M */ + SDL_TRANSFER_CHARACTERISTICS_LINEAR = 8, + SDL_TRANSFER_CHARACTERISTICS_LOG100 = 9, + SDL_TRANSFER_CHARACTERISTICS_LOG100_SQRT10 = 10, + SDL_TRANSFER_CHARACTERISTICS_IEC61966 = 11, /**< IEC 61966-2-4 */ + SDL_TRANSFER_CHARACTERISTICS_BT1361 = 12, /**< ITU-R BT1361 Extended Colour Gamut */ + SDL_TRANSFER_CHARACTERISTICS_SRGB = 13, /**< IEC 61966-2-1 (sRGB or sYCC) */ + SDL_TRANSFER_CHARACTERISTICS_BT2020_10BIT = 14, /**< ITU-R BT2020 for 10-bit system */ + SDL_TRANSFER_CHARACTERISTICS_BT2020_12BIT = 15, /**< ITU-R BT2020 for 12-bit system */ + SDL_TRANSFER_CHARACTERISTICS_PQ = 16, /**< SMPTE ST 2084 for 10-, 12-, 14- and 16-bit systems */ + SDL_TRANSFER_CHARACTERISTICS_SMPTE428 = 17, /**< SMPTE ST 428-1 */ + SDL_TRANSFER_CHARACTERISTICS_HLG = 18, /**< ARIB STD-B67, known as "hybrid log-gamma" (HLG) */ + SDL_TRANSFER_CHARACTERISTICS_CUSTOM = 31 +} SDL_TransferCharacteristics; + +/** + * Colorspace matrix coefficients. + * + * These are as described by https://www.itu.int/rec/T-REC-H.273-201612-S/en + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_MatrixCoefficients +{ + SDL_MATRIX_COEFFICIENTS_IDENTITY = 0, + SDL_MATRIX_COEFFICIENTS_BT709 = 1, /**< ITU-R BT.709-6 */ + SDL_MATRIX_COEFFICIENTS_UNSPECIFIED = 2, + SDL_MATRIX_COEFFICIENTS_FCC = 4, /**< US FCC Title 47 */ + SDL_MATRIX_COEFFICIENTS_BT470BG = 5, /**< ITU-R BT.470-6 System B, G / ITU-R BT.601-7 625, functionally the same as SDL_MATRIX_COEFFICIENTS_BT601 */ + SDL_MATRIX_COEFFICIENTS_BT601 = 6, /**< ITU-R BT.601-7 525 */ + SDL_MATRIX_COEFFICIENTS_SMPTE240 = 7, /**< SMPTE 240M */ + SDL_MATRIX_COEFFICIENTS_YCGCO = 8, + SDL_MATRIX_COEFFICIENTS_BT2020_NCL = 9, /**< ITU-R BT.2020-2 non-constant luminance */ + SDL_MATRIX_COEFFICIENTS_BT2020_CL = 10, /**< ITU-R BT.2020-2 constant luminance */ + SDL_MATRIX_COEFFICIENTS_SMPTE2085 = 11, /**< SMPTE ST 2085 */ + SDL_MATRIX_COEFFICIENTS_CHROMA_DERIVED_NCL = 12, + SDL_MATRIX_COEFFICIENTS_CHROMA_DERIVED_CL = 13, + SDL_MATRIX_COEFFICIENTS_ICTCP = 14, /**< ITU-R BT.2100-0 ICTCP */ + SDL_MATRIX_COEFFICIENTS_CUSTOM = 31 +} SDL_MatrixCoefficients; + +/** + * Colorspace chroma sample location. + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_ChromaLocation +{ + SDL_CHROMA_LOCATION_NONE = 0, /**< RGB, no chroma sampling */ + SDL_CHROMA_LOCATION_LEFT = 1, /**< In MPEG-2, MPEG-4, and AVC, Cb and Cr are taken on midpoint of the left-edge of the 2x2 square. In other words, they have the same horizontal location as the top-left pixel, but is shifted one-half pixel down vertically. */ + SDL_CHROMA_LOCATION_CENTER = 2, /**< In JPEG/JFIF, H.261, and MPEG-1, Cb and Cr are taken at the center of the 2x2 square. In other words, they are offset one-half pixel to the right and one-half pixel down compared to the top-left pixel. */ + SDL_CHROMA_LOCATION_TOPLEFT = 3 /**< In HEVC for BT.2020 and BT.2100 content (in particular on Blu-rays), Cb and Cr are sampled at the same location as the group's top-left Y pixel ("co-sited", "co-located"). */ +} SDL_ChromaLocation; + + +/* Colorspace definition */ + +/** + * A macro for defining custom SDL_Colorspace formats. + * + * For example, defining SDL_COLORSPACE_SRGB looks like this: + * + * ```c + * SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_RGB, + * SDL_COLOR_RANGE_FULL, + * SDL_COLOR_PRIMARIES_BT709, + * SDL_TRANSFER_CHARACTERISTICS_SRGB, + * SDL_MATRIX_COEFFICIENTS_IDENTITY, + * SDL_CHROMA_LOCATION_NONE) + * ``` + * + * \param type the type of the new format, probably an SDL_ColorType value. + * \param range the range of the new format, probably a SDL_ColorRange value. + * \param primaries the primaries of the new format, probably an + * SDL_ColorPrimaries value. + * \param transfer the transfer characteristics of the new format, probably an + * SDL_TransferCharacteristics value. + * \param matrix the matrix coefficients of the new format, probably an + * SDL_MatrixCoefficients value. + * \param chroma the chroma sample location of the new format, probably an + * SDL_ChromaLocation value. + * \returns a format value in the style of SDL_Colorspace. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_DEFINE_COLORSPACE(type, range, primaries, transfer, matrix, chroma) \ + (((Uint32)(type) << 28) | ((Uint32)(range) << 24) | ((Uint32)(chroma) << 20) | \ + ((Uint32)(primaries) << 10) | ((Uint32)(transfer) << 5) | ((Uint32)(matrix) << 0)) + +/** + * A macro to retrieve the type of an SDL_Colorspace. + * + * \param cspace an SDL_Colorspace to check. + * \returns the SDL_ColorType for `cspace`. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_COLORSPACETYPE(cspace) (SDL_ColorType)(((cspace) >> 28) & 0x0F) + +/** + * A macro to retrieve the range of an SDL_Colorspace. + * + * \param cspace an SDL_Colorspace to check. + * \returns the SDL_ColorRange of `cspace`. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_COLORSPACERANGE(cspace) (SDL_ColorRange)(((cspace) >> 24) & 0x0F) + +/** + * A macro to retrieve the chroma sample location of an SDL_Colorspace. + * + * \param cspace an SDL_Colorspace to check. + * \returns the SDL_ChromaLocation of `cspace`. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_COLORSPACECHROMA(cspace) (SDL_ChromaLocation)(((cspace) >> 20) & 0x0F) + +/** + * A macro to retrieve the primaries of an SDL_Colorspace. + * + * \param cspace an SDL_Colorspace to check. + * \returns the SDL_ColorPrimaries of `cspace`. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_COLORSPACEPRIMARIES(cspace) (SDL_ColorPrimaries)(((cspace) >> 10) & 0x1F) + +/** + * A macro to retrieve the transfer characteristics of an SDL_Colorspace. + * + * \param cspace an SDL_Colorspace to check. + * \returns the SDL_TransferCharacteristics of `cspace`. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_COLORSPACETRANSFER(cspace) (SDL_TransferCharacteristics)(((cspace) >> 5) & 0x1F) + +/** + * A macro to retrieve the matrix coefficients of an SDL_Colorspace. + * + * \param cspace an SDL_Colorspace to check. + * \returns the SDL_MatrixCoefficients of `cspace`. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_COLORSPACEMATRIX(cspace) (SDL_MatrixCoefficients)((cspace) & 0x1F) + +/** + * A macro to determine if an SDL_Colorspace uses BT601 (or BT470BG) matrix + * coefficients. + * + * Note that this macro double-evaluates its parameter, so do not use + * expressions with side-effects here. + * + * \param cspace an SDL_Colorspace to check. + * \returns true if BT601 or BT470BG, false otherwise. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_ISCOLORSPACE_MATRIX_BT601(cspace) (SDL_COLORSPACEMATRIX(cspace) == SDL_MATRIX_COEFFICIENTS_BT601 || SDL_COLORSPACEMATRIX(cspace) == SDL_MATRIX_COEFFICIENTS_BT470BG) + +/** + * A macro to determine if an SDL_Colorspace uses BT709 matrix coefficients. + * + * \param cspace an SDL_Colorspace to check. + * \returns true if BT709, false otherwise. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_ISCOLORSPACE_MATRIX_BT709(cspace) (SDL_COLORSPACEMATRIX(cspace) == SDL_MATRIX_COEFFICIENTS_BT709) + +/** + * A macro to determine if an SDL_Colorspace uses BT2020_NCL matrix + * coefficients. + * + * \param cspace an SDL_Colorspace to check. + * \returns true if BT2020_NCL, false otherwise. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_ISCOLORSPACE_MATRIX_BT2020_NCL(cspace) (SDL_COLORSPACEMATRIX(cspace) == SDL_MATRIX_COEFFICIENTS_BT2020_NCL) + +/** + * A macro to determine if an SDL_Colorspace has a limited range. + * + * \param cspace an SDL_Colorspace to check. + * \returns true if limited range, false otherwise. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_ISCOLORSPACE_LIMITED_RANGE(cspace) (SDL_COLORSPACERANGE(cspace) != SDL_COLOR_RANGE_FULL) + +/** + * A macro to determine if an SDL_Colorspace has a full range. + * + * \param cspace an SDL_Colorspace to check. + * \returns true if full range, false otherwise. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_ISCOLORSPACE_FULL_RANGE(cspace) (SDL_COLORSPACERANGE(cspace) == SDL_COLOR_RANGE_FULL) + +/** + * Colorspace definitions. + * + * Since similar colorspaces may vary in their details (matrix, transfer + * function, etc.), this is not an exhaustive list, but rather a + * representative sample of the kinds of colorspaces supported in SDL. + * + * \since This enum is available since SDL 3.2.0. + * + * \sa SDL_ColorPrimaries + * \sa SDL_ColorRange + * \sa SDL_ColorType + * \sa SDL_MatrixCoefficients + * \sa SDL_TransferCharacteristics + */ +typedef enum SDL_Colorspace +{ + SDL_COLORSPACE_UNKNOWN = 0, + + /* sRGB is a gamma corrected colorspace, and the default colorspace for SDL rendering and 8-bit RGB surfaces */ + SDL_COLORSPACE_SRGB = 0x120005a0u, /**< Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709 */ + /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_RGB, + SDL_COLOR_RANGE_FULL, + SDL_COLOR_PRIMARIES_BT709, + SDL_TRANSFER_CHARACTERISTICS_SRGB, + SDL_MATRIX_COEFFICIENTS_IDENTITY, + SDL_CHROMA_LOCATION_NONE), */ + + /* This is a linear colorspace and the default colorspace for floating point surfaces. On Windows this is the scRGB colorspace, and on Apple platforms this is kCGColorSpaceExtendedLinearSRGB for EDR content */ + SDL_COLORSPACE_SRGB_LINEAR = 0x12000500u, /**< Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G10_NONE_P709 */ + /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_RGB, + SDL_COLOR_RANGE_FULL, + SDL_COLOR_PRIMARIES_BT709, + SDL_TRANSFER_CHARACTERISTICS_LINEAR, + SDL_MATRIX_COEFFICIENTS_IDENTITY, + SDL_CHROMA_LOCATION_NONE), */ + + /* HDR10 is a non-linear HDR colorspace and the default colorspace for 10-bit surfaces */ + SDL_COLORSPACE_HDR10 = 0x12002600u, /**< Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020 */ + /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_RGB, + SDL_COLOR_RANGE_FULL, + SDL_COLOR_PRIMARIES_BT2020, + SDL_TRANSFER_CHARACTERISTICS_PQ, + SDL_MATRIX_COEFFICIENTS_IDENTITY, + SDL_CHROMA_LOCATION_NONE), */ + + SDL_COLORSPACE_JPEG = 0x220004c6u, /**< Equivalent to DXGI_COLOR_SPACE_YCBCR_FULL_G22_NONE_P709_X601 */ + /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_YCBCR, + SDL_COLOR_RANGE_FULL, + SDL_COLOR_PRIMARIES_BT709, + SDL_TRANSFER_CHARACTERISTICS_BT601, + SDL_MATRIX_COEFFICIENTS_BT601, + SDL_CHROMA_LOCATION_NONE), */ + + SDL_COLORSPACE_BT601_LIMITED = 0x211018c6u, /**< Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601 */ + /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_YCBCR, + SDL_COLOR_RANGE_LIMITED, + SDL_COLOR_PRIMARIES_BT601, + SDL_TRANSFER_CHARACTERISTICS_BT601, + SDL_MATRIX_COEFFICIENTS_BT601, + SDL_CHROMA_LOCATION_LEFT), */ + + SDL_COLORSPACE_BT601_FULL = 0x221018c6u, /**< Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601 */ + /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_YCBCR, + SDL_COLOR_RANGE_FULL, + SDL_COLOR_PRIMARIES_BT601, + SDL_TRANSFER_CHARACTERISTICS_BT601, + SDL_MATRIX_COEFFICIENTS_BT601, + SDL_CHROMA_LOCATION_LEFT), */ + + SDL_COLORSPACE_BT709_LIMITED = 0x21100421u, /**< Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709 */ + /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_YCBCR, + SDL_COLOR_RANGE_LIMITED, + SDL_COLOR_PRIMARIES_BT709, + SDL_TRANSFER_CHARACTERISTICS_BT709, + SDL_MATRIX_COEFFICIENTS_BT709, + SDL_CHROMA_LOCATION_LEFT), */ + + SDL_COLORSPACE_BT709_FULL = 0x22100421u, /**< Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709 */ + /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_YCBCR, + SDL_COLOR_RANGE_FULL, + SDL_COLOR_PRIMARIES_BT709, + SDL_TRANSFER_CHARACTERISTICS_BT709, + SDL_MATRIX_COEFFICIENTS_BT709, + SDL_CHROMA_LOCATION_LEFT), */ + + SDL_COLORSPACE_BT2020_LIMITED = 0x21102609u, /**< Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P2020 */ + /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_YCBCR, + SDL_COLOR_RANGE_LIMITED, + SDL_COLOR_PRIMARIES_BT2020, + SDL_TRANSFER_CHARACTERISTICS_PQ, + SDL_MATRIX_COEFFICIENTS_BT2020_NCL, + SDL_CHROMA_LOCATION_LEFT), */ + + SDL_COLORSPACE_BT2020_FULL = 0x22102609u, /**< Equivalent to DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P2020 */ + /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_YCBCR, + SDL_COLOR_RANGE_FULL, + SDL_COLOR_PRIMARIES_BT2020, + SDL_TRANSFER_CHARACTERISTICS_PQ, + SDL_MATRIX_COEFFICIENTS_BT2020_NCL, + SDL_CHROMA_LOCATION_LEFT), */ + + SDL_COLORSPACE_RGB_DEFAULT = SDL_COLORSPACE_SRGB, /**< The default colorspace for RGB surfaces if no colorspace is specified */ + SDL_COLORSPACE_YUV_DEFAULT = SDL_COLORSPACE_BT601_LIMITED /**< The default colorspace for YUV surfaces if no colorspace is specified */ +} SDL_Colorspace; + +/** + * A structure that represents a color as RGBA components. + * + * The bits of this structure can be directly reinterpreted as an + * integer-packed color which uses the SDL_PIXELFORMAT_RGBA32 format + * (SDL_PIXELFORMAT_ABGR8888 on little-endian systems and + * SDL_PIXELFORMAT_RGBA8888 on big-endian systems). + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_Color +{ + Uint8 r; + Uint8 g; + Uint8 b; + Uint8 a; +} SDL_Color; + +/** + * The bits of this structure can be directly reinterpreted as a float-packed + * color which uses the SDL_PIXELFORMAT_RGBA128_FLOAT format + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_FColor +{ + float r; + float g; + float b; + float a; +} SDL_FColor; + +/** + * A set of indexed colors representing a palette. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_SetPaletteColors + */ +typedef struct SDL_Palette +{ + int ncolors; /**< number of elements in `colors`. */ + SDL_Color *colors; /**< an array of colors, `ncolors` long. */ + Uint32 version; /**< internal use only, do not touch. */ + int refcount; /**< internal use only, do not touch. */ +} SDL_Palette; + +/** + * Details about the format of a pixel. + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_PixelFormatDetails +{ + SDL_PixelFormat format; + Uint8 bits_per_pixel; + Uint8 bytes_per_pixel; + Uint8 padding[2]; + Uint32 Rmask; + Uint32 Gmask; + Uint32 Bmask; + Uint32 Amask; + Uint8 Rbits; + Uint8 Gbits; + Uint8 Bbits; + Uint8 Abits; + Uint8 Rshift; + Uint8 Gshift; + Uint8 Bshift; + Uint8 Ashift; +} SDL_PixelFormatDetails; + +/** + * Get the human readable name of a pixel format. + * + * \param format the pixel format to query. + * \returns the human readable name of the specified pixel format or + * "SDL_PIXELFORMAT_UNKNOWN" if the format isn't recognized. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetPixelFormatName(SDL_PixelFormat format); + +/** + * Convert one of the enumerated pixel formats to a bpp value and RGBA masks. + * + * \param format one of the SDL_PixelFormat values. + * \param bpp a bits per pixel value; usually 15, 16, or 32. + * \param Rmask a pointer filled in with the red mask for the format. + * \param Gmask a pointer filled in with the green mask for the format. + * \param Bmask a pointer filled in with the blue mask for the format. + * \param Amask a pointer filled in with the alpha mask for the format. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetPixelFormatForMasks + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetMasksForPixelFormat(SDL_PixelFormat format, int *bpp, Uint32 *Rmask, Uint32 *Gmask, Uint32 *Bmask, Uint32 *Amask); + +/** + * Convert a bpp value and RGBA masks to an enumerated pixel format. + * + * This will return `SDL_PIXELFORMAT_UNKNOWN` if the conversion wasn't + * possible. + * + * \param bpp a bits per pixel value; usually 15, 16, or 32. + * \param Rmask the red mask for the format. + * \param Gmask the green mask for the format. + * \param Bmask the blue mask for the format. + * \param Amask the alpha mask for the format. + * \returns the SDL_PixelFormat value corresponding to the format masks, or + * SDL_PIXELFORMAT_UNKNOWN if there isn't a match. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetMasksForPixelFormat + */ +extern SDL_DECLSPEC SDL_PixelFormat SDLCALL SDL_GetPixelFormatForMasks(int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask); + +/** + * Create an SDL_PixelFormatDetails structure corresponding to a pixel format. + * + * Returned structure may come from a shared global cache (i.e. not newly + * allocated), and hence should not be modified, especially the palette. Weird + * errors such as `Blit combination not supported` may occur. + * + * \param format one of the SDL_PixelFormat values. + * \returns a pointer to a SDL_PixelFormatDetails structure or NULL on + * failure; call SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC const SDL_PixelFormatDetails * SDLCALL SDL_GetPixelFormatDetails(SDL_PixelFormat format); + +/** + * Create a palette structure with the specified number of color entries. + * + * The palette entries are initialized to white. + * + * \param ncolors represents the number of color entries in the color palette. + * \returns a new SDL_Palette structure on success or NULL on failure (e.g. if + * there wasn't enough memory); call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_DestroyPalette + * \sa SDL_SetPaletteColors + * \sa SDL_SetSurfacePalette + */ +extern SDL_DECLSPEC SDL_Palette * SDLCALL SDL_CreatePalette(int ncolors); + +/** + * Set a range of colors in a palette. + * + * \param palette the SDL_Palette structure to modify. + * \param colors an array of SDL_Color structures to copy into the palette. + * \param firstcolor the index of the first palette entry to modify. + * \param ncolors the number of entries to modify. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread, as long as + * the palette is not modified or destroyed in another thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetPaletteColors(SDL_Palette *palette, const SDL_Color *colors, int firstcolor, int ncolors); + +/** + * Free a palette created with SDL_CreatePalette(). + * + * \param palette the SDL_Palette structure to be freed. + * + * \threadsafety It is safe to call this function from any thread, as long as + * the palette is not modified or destroyed in another thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreatePalette + */ +extern SDL_DECLSPEC void SDLCALL SDL_DestroyPalette(SDL_Palette *palette); + +/** + * Map an RGB triple to an opaque pixel value for a given pixel format. + * + * This function maps the RGB color value to the specified pixel format and + * returns the pixel value best approximating the given RGB color value for + * the given pixel format. + * + * If the format has a palette (8-bit) the index of the closest matching color + * in the palette will be returned. + * + * If the specified pixel format has an alpha component it will be returned as + * all 1 bits (fully opaque). + * + * If the pixel format bpp (color depth) is less than 32-bpp then the unused + * upper bits of the return value can safely be ignored (e.g., with a 16-bpp + * format the return value can be assigned to a Uint16, and similarly a Uint8 + * for an 8-bpp format). + * + * \param format a pointer to SDL_PixelFormatDetails describing the pixel + * format. + * \param palette an optional palette for indexed formats, may be NULL. + * \param r the red component of the pixel in the range 0-255. + * \param g the green component of the pixel in the range 0-255. + * \param b the blue component of the pixel in the range 0-255. + * \returns a pixel value. + * + * \threadsafety It is safe to call this function from any thread, as long as + * the palette is not modified. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetPixelFormatDetails + * \sa SDL_GetRGB + * \sa SDL_MapRGBA + * \sa SDL_MapSurfaceRGB + */ +extern SDL_DECLSPEC Uint32 SDLCALL SDL_MapRGB(const SDL_PixelFormatDetails *format, const SDL_Palette *palette, Uint8 r, Uint8 g, Uint8 b); + +/** + * Map an RGBA quadruple to a pixel value for a given pixel format. + * + * This function maps the RGBA color value to the specified pixel format and + * returns the pixel value best approximating the given RGBA color value for + * the given pixel format. + * + * If the specified pixel format has no alpha component the alpha value will + * be ignored (as it will be in formats with a palette). + * + * If the format has a palette (8-bit) the index of the closest matching color + * in the palette will be returned. + * + * If the pixel format bpp (color depth) is less than 32-bpp then the unused + * upper bits of the return value can safely be ignored (e.g., with a 16-bpp + * format the return value can be assigned to a Uint16, and similarly a Uint8 + * for an 8-bpp format). + * + * \param format a pointer to SDL_PixelFormatDetails describing the pixel + * format. + * \param palette an optional palette for indexed formats, may be NULL. + * \param r the red component of the pixel in the range 0-255. + * \param g the green component of the pixel in the range 0-255. + * \param b the blue component of the pixel in the range 0-255. + * \param a the alpha component of the pixel in the range 0-255. + * \returns a pixel value. + * + * \threadsafety It is safe to call this function from any thread, as long as + * the palette is not modified. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetPixelFormatDetails + * \sa SDL_GetRGBA + * \sa SDL_MapRGB + * \sa SDL_MapSurfaceRGBA + */ +extern SDL_DECLSPEC Uint32 SDLCALL SDL_MapRGBA(const SDL_PixelFormatDetails *format, const SDL_Palette *palette, Uint8 r, Uint8 g, Uint8 b, Uint8 a); + +/** + * Get RGB values from a pixel in the specified format. + * + * This function uses the entire 8-bit [0..255] range when converting color + * components from pixel formats with less than 8-bits per RGB component + * (e.g., a completely white pixel in 16-bit RGB565 format would return [0xff, + * 0xff, 0xff] not [0xf8, 0xfc, 0xf8]). + * + * \param pixelvalue a pixel value. + * \param format a pointer to SDL_PixelFormatDetails describing the pixel + * format. + * \param palette an optional palette for indexed formats, may be NULL. + * \param r a pointer filled in with the red component, may be NULL. + * \param g a pointer filled in with the green component, may be NULL. + * \param b a pointer filled in with the blue component, may be NULL. + * + * \threadsafety It is safe to call this function from any thread, as long as + * the palette is not modified. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetPixelFormatDetails + * \sa SDL_GetRGBA + * \sa SDL_MapRGB + * \sa SDL_MapRGBA + */ +extern SDL_DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixelvalue, const SDL_PixelFormatDetails *format, const SDL_Palette *palette, Uint8 *r, Uint8 *g, Uint8 *b); + +/** + * Get RGBA values from a pixel in the specified format. + * + * This function uses the entire 8-bit [0..255] range when converting color + * components from pixel formats with less than 8-bits per RGB component + * (e.g., a completely white pixel in 16-bit RGB565 format would return [0xff, + * 0xff, 0xff] not [0xf8, 0xfc, 0xf8]). + * + * If the surface has no alpha component, the alpha will be returned as 0xff + * (100% opaque). + * + * \param pixelvalue a pixel value. + * \param format a pointer to SDL_PixelFormatDetails describing the pixel + * format. + * \param palette an optional palette for indexed formats, may be NULL. + * \param r a pointer filled in with the red component, may be NULL. + * \param g a pointer filled in with the green component, may be NULL. + * \param b a pointer filled in with the blue component, may be NULL. + * \param a a pointer filled in with the alpha component, may be NULL. + * + * \threadsafety It is safe to call this function from any thread, as long as + * the palette is not modified. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetPixelFormatDetails + * \sa SDL_GetRGB + * \sa SDL_MapRGB + * \sa SDL_MapRGBA + */ +extern SDL_DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixelvalue, const SDL_PixelFormatDetails *format, const SDL_Palette *palette, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_pixels_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_platform.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_platform.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,64 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * # CategoryPlatform + * + * SDL provides a means to identify the app's platform, both at compile time + * and runtime. + */ + +#ifndef SDL_platform_h_ +#define SDL_platform_h_ + +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Get the name of the platform. + * + * Here are the names returned for some (but not all) supported platforms: + * + * - "Windows" + * - "macOS" + * - "Linux" + * - "iOS" + * - "Android" + * + * \returns the name of the platform. If the correct platform name is not + * available, returns a string beginning with the text "Unknown". + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetPlatform(void); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_platform_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_platform_defines.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_platform_defines.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,497 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* WIKI CATEGORY: Platform */ + +/* + * SDL_platform_defines.h tries to get a standard set of platform defines. + */ + +#ifndef SDL_platform_defines_h_ +#define SDL_platform_defines_h_ + +#ifdef _AIX + +/** + * A preprocessor macro that is only defined if compiling for AIX. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PLATFORM_AIX 1 +#endif + +#ifdef __HAIKU__ + +/** + * A preprocessor macro that is only defined if compiling for Haiku OS. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PLATFORM_HAIKU 1 +#endif + +#if defined(bsdi) || defined(__bsdi) || defined(__bsdi__) + +/** + * A preprocessor macro that is only defined if compiling for BSDi + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PLATFORM_BSDI 1 +#endif + +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) + +/** + * A preprocessor macro that is only defined if compiling for FreeBSD. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PLATFORM_FREEBSD 1 +#endif + +#if defined(hpux) || defined(__hpux) || defined(__hpux__) + +/** + * A preprocessor macro that is only defined if compiling for HP-UX. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PLATFORM_HPUX 1 +#endif + +#if defined(sgi) || defined(__sgi) || defined(__sgi__) || defined(_SGI_SOURCE) + +/** + * A preprocessor macro that is only defined if compiling for IRIX. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PLATFORM_IRIX 1 +#endif + +#if (defined(linux) || defined(__linux) || defined(__linux__)) + +/** + * A preprocessor macro that is only defined if compiling for Linux. + * + * Note that Android, although ostensibly a Linux-based system, will not + * define this. It defines SDL_PLATFORM_ANDROID instead. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PLATFORM_LINUX 1 +#endif + +#if defined(ANDROID) || defined(__ANDROID__) + +/** + * A preprocessor macro that is only defined if compiling for Android. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PLATFORM_ANDROID 1 +#undef SDL_PLATFORM_LINUX +#endif + +#if defined(__unix__) || defined(__unix) || defined(unix) + +/** + * A preprocessor macro that is only defined if compiling for a Unix-like + * system. + * + * Other platforms, like Linux, might define this in addition to their primary + * define. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PLATFORM_UNIX 1 +#endif + +#ifdef __APPLE__ + +/** + * A preprocessor macro that is only defined if compiling for Apple platforms. + * + * iOS, macOS, etc will additionally define a more specific platform macro. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_PLATFORM_MACOS + * \sa SDL_PLATFORM_IOS + * \sa SDL_PLATFORM_TVOS + * \sa SDL_PLATFORM_VISIONOS + */ +#define SDL_PLATFORM_APPLE 1 + +/* lets us know what version of macOS we're compiling on */ +#include +#ifndef __has_extension /* Older compilers don't support this */ + #define __has_extension(x) 0 + #include + #undef __has_extension +#else + #include +#endif + +/* Fix building with older SDKs that don't define these + See this for more information: + https://stackoverflow.com/questions/12132933/preprocessor-macro-for-os-x-targets +*/ +#ifndef TARGET_OS_MACCATALYST + #define TARGET_OS_MACCATALYST 0 +#endif +#ifndef TARGET_OS_IOS + #define TARGET_OS_IOS 0 +#endif +#ifndef TARGET_OS_IPHONE + #define TARGET_OS_IPHONE 0 +#endif +#ifndef TARGET_OS_TV + #define TARGET_OS_TV 0 +#endif +#ifndef TARGET_OS_SIMULATOR + #define TARGET_OS_SIMULATOR 0 +#endif +#ifndef TARGET_OS_VISION + #define TARGET_OS_VISION 0 +#endif + +#if TARGET_OS_TV + +/** + * A preprocessor macro that is only defined if compiling for tvOS. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_PLATFORM_APPLE + */ +#define SDL_PLATFORM_TVOS 1 +#endif + +#if TARGET_OS_VISION + +/** + * A preprocessor macro that is only defined if compiling for visionOS. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_PLATFORM_APPLE + */ +#define SDL_PLATFORM_VISIONOS 1 +#endif + +#if TARGET_OS_IPHONE + +/** + * A preprocessor macro that is only defined if compiling for iOS or visionOS. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_PLATFORM_APPLE + */ +#define SDL_PLATFORM_IOS 1 + +#else + +/** + * A preprocessor macro that is only defined if compiling for macOS. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_PLATFORM_APPLE + */ +#define SDL_PLATFORM_MACOS 1 + +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 + #error SDL for macOS only supports deploying on 10.7 and above. +#endif /* MAC_OS_X_VERSION_MIN_REQUIRED < 1070 */ +#endif /* TARGET_OS_IPHONE */ +#endif /* defined(__APPLE__) */ + +#ifdef __EMSCRIPTEN__ + +/** + * A preprocessor macro that is only defined if compiling for Emscripten. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PLATFORM_EMSCRIPTEN 1 +#endif + +#ifdef __NetBSD__ + +/** + * A preprocessor macro that is only defined if compiling for NetBSD. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PLATFORM_NETBSD 1 +#endif + +#ifdef __OpenBSD__ + +/** + * A preprocessor macro that is only defined if compiling for OpenBSD. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PLATFORM_OPENBSD 1 +#endif + +#if defined(__OS2__) || defined(__EMX__) + +/** + * A preprocessor macro that is only defined if compiling for OS/2. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PLATFORM_OS2 1 +#endif + +#if defined(osf) || defined(__osf) || defined(__osf__) || defined(_OSF_SOURCE) + +/** + * A preprocessor macro that is only defined if compiling for Tru64 (OSF/1). + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PLATFORM_OSF 1 +#endif + +#ifdef __QNXNTO__ + +/** + * A preprocessor macro that is only defined if compiling for QNX Neutrino. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PLATFORM_QNXNTO 1 +#endif + +#if defined(riscos) || defined(__riscos) || defined(__riscos__) + +/** + * A preprocessor macro that is only defined if compiling for RISC OS. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PLATFORM_RISCOS 1 +#endif + +#if defined(__sun) && defined(__SVR4) + +/** + * A preprocessor macro that is only defined if compiling for SunOS/Solaris. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PLATFORM_SOLARIS 1 +#endif + +#if defined(__CYGWIN__) + +/** + * A preprocessor macro that is only defined if compiling for Cygwin. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PLATFORM_CYGWIN 1 +#endif + +#if (defined(_WIN32) || defined(SDL_PLATFORM_CYGWIN)) && !defined(__NGAGE__) + +/** + * A preprocessor macro that is only defined if compiling for Windows. + * + * This also covers several other platforms, like Microsoft GDK, Xbox, WinRT, + * etc. Each will have their own more-specific platform macros, too. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_PLATFORM_WIN32 + * \sa SDL_PLATFORM_XBOXONE + * \sa SDL_PLATFORM_XBOXSERIES + * \sa SDL_PLATFORM_WINGDK + * \sa SDL_PLATFORM_GDK + */ +#define SDL_PLATFORM_WINDOWS 1 + +/* Try to find out if we're compiling for WinRT, GDK or non-WinRT/GDK */ +#if defined(_MSC_VER) && defined(__has_include) + #if __has_include() + #define HAVE_WINAPIFAMILY_H 1 + #else + #define HAVE_WINAPIFAMILY_H 0 + #endif + + /* If _USING_V110_SDK71_ is defined it means we are using the Windows XP toolset. */ +#elif defined(_MSC_VER) && (_MSC_VER >= 1700 && !_USING_V110_SDK71_) /* _MSC_VER == 1700 for Visual Studio 2012 */ + #define HAVE_WINAPIFAMILY_H 1 +#else + #define HAVE_WINAPIFAMILY_H 0 +#endif + +#if HAVE_WINAPIFAMILY_H + #include + #define WINAPI_FAMILY_WINRT (!WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)) +#else + #define WINAPI_FAMILY_WINRT 0 +#endif /* HAVE_WINAPIFAMILY_H */ + +#ifdef SDL_WIKI_DOCUMENTATION_SECTION + +/** + * A preprocessor macro that defined to 1 if compiling for Windows Phone. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_WINAPI_FAMILY_PHONE (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) + +#elif defined(HAVE_WINAPIFAMILY_H) && HAVE_WINAPIFAMILY_H + #define SDL_WINAPI_FAMILY_PHONE (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) +#else + #define SDL_WINAPI_FAMILY_PHONE 0 +#endif + +#if WINAPI_FAMILY_WINRT +#error Windows RT/UWP is no longer supported in SDL + +#elif defined(_GAMING_DESKTOP) /* GDK project configuration always defines _GAMING_XXX */ + +/** + * A preprocessor macro that is only defined if compiling for Microsoft GDK + * for Windows. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PLATFORM_WINGDK 1 + +#elif defined(_GAMING_XBOX_XBOXONE) + +/** + * A preprocessor macro that is only defined if compiling for Xbox One. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PLATFORM_XBOXONE 1 + +#elif defined(_GAMING_XBOX_SCARLETT) + +/** + * A preprocessor macro that is only defined if compiling for Xbox Series. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PLATFORM_XBOXSERIES 1 + +#else + +/** + * A preprocessor macro that is only defined if compiling for desktop Windows. + * + * Despite the "32", this also covers 64-bit Windows; as an informal + * convention, its system layer tends to still be referred to as "the Win32 + * API." + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PLATFORM_WIN32 1 + +#endif +#endif /* defined(_WIN32) || defined(SDL_PLATFORM_CYGWIN) */ + + +/* This is to support generic "any GDK" separate from a platform-specific GDK */ +#if defined(SDL_PLATFORM_WINGDK) || defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) + +/** + * A preprocessor macro that is only defined if compiling for Microsoft GDK on + * any platform. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PLATFORM_GDK 1 +#endif + +#if defined(__PSP__) || defined(__psp__) + +/** + * A preprocessor macro that is only defined if compiling for Sony PSP. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PLATFORM_PSP 1 +#endif + +#if defined(__PS2__) || defined(PS2) + +/** + * A preprocessor macro that is only defined if compiling for Sony PlayStation + * 2. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PLATFORM_PS2 1 +#endif + +#if defined(__vita__) || defined(__psp2__) + +/** + * A preprocessor macro that is only defined if compiling for Sony Vita. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PLATFORM_VITA 1 +#endif + +#ifdef __3DS__ + +/** + * A preprocessor macro that is only defined if compiling for Nintendo 3DS. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PLATFORM_3DS 1 +#endif + +#ifdef __NGAGE__ + +/** + * A preprocessor macro that is only defined if compiling for the Nokia + * N-Gage. + * + * \since This macro is available since SDL 3.4.0. + */ +#define SDL_PLATFORM_NGAGE 1 +#endif + +#ifdef __GNU__ + +/** + * A preprocessor macro that is only defined if compiling for GNU/Hurd. + * + * \since This macro is available since SDL 3.4.0. + */ +#define SDL_PLATFORM_HURD 1 +#endif + +#endif /* SDL_platform_defines_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_power.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_power.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,106 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_power_h_ +#define SDL_power_h_ + +/** + * # CategoryPower + * + * SDL power management routines. + * + * There is a single function in this category: SDL_GetPowerInfo(). + * + * This function is useful for games on the go. This allows an app to know if + * it's running on a draining battery, which can be useful if the app wants to + * reduce processing, or perhaps framerate, to extend the duration of the + * battery's charge. Perhaps the app just wants to show a battery meter when + * fullscreen, or alert the user when the power is getting extremely low, so + * they can save their game. + */ + +#include +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * The basic state for the system's power supply. + * + * These are results returned by SDL_GetPowerInfo(). + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_PowerState +{ + SDL_POWERSTATE_ERROR = -1, /**< error determining power status */ + SDL_POWERSTATE_UNKNOWN, /**< cannot determine power status */ + SDL_POWERSTATE_ON_BATTERY, /**< Not plugged in, running on the battery */ + SDL_POWERSTATE_NO_BATTERY, /**< Plugged in, no battery available */ + SDL_POWERSTATE_CHARGING, /**< Plugged in, charging battery */ + SDL_POWERSTATE_CHARGED /**< Plugged in, battery charged */ +} SDL_PowerState; + +/** + * Get the current power supply details. + * + * You should never take a battery status as absolute truth. Batteries + * (especially failing batteries) are delicate hardware, and the values + * reported here are best estimates based on what that hardware reports. It's + * not uncommon for older batteries to lose stored power much faster than it + * reports, or completely drain when reporting it has 20 percent left, etc. + * + * Battery status can change at any time; if you are concerned with power + * state, you should call this function frequently, and perhaps ignore changes + * until they seem to be stable for a few seconds. + * + * It's possible a platform can only report battery percentage or time left + * but not both. + * + * On some platforms, retrieving power supply details might be expensive. If + * you want to display continuous status you could call this function every + * minute or so. + * + * \param seconds a pointer filled in with the seconds of battery life left, + * or NULL to ignore. This will be filled in with -1 if we + * can't determine a value or there is no battery. + * \param percent a pointer filled in with the percentage of battery life + * left, between 0 and 100, or NULL to ignore. This will be + * filled in with -1 when we can't determine a value or there + * is no battery. + * \returns the current battery state or `SDL_POWERSTATE_ERROR` on failure; + * call SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_PowerState SDLCALL SDL_GetPowerInfo(int *seconds, int *percent); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_power_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_process.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_process.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,441 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * # CategoryProcess + * + * Process control support. + * + * These functions provide a cross-platform way to spawn and manage OS-level + * processes. + * + * You can create a new subprocess with SDL_CreateProcess() and optionally + * read and write to it using SDL_ReadProcess() or SDL_GetProcessInput() and + * SDL_GetProcessOutput(). If more advanced functionality like chaining input + * between processes is necessary, you can use + * SDL_CreateProcessWithProperties(). + * + * You can get the status of a created process with SDL_WaitProcess(), or + * terminate the process with SDL_KillProcess(). + * + * Don't forget to call SDL_DestroyProcess() to clean up, whether the process + * process was killed, terminated on its own, or is still running! + */ + +#ifndef SDL_process_h_ +#define SDL_process_h_ + +#include +#include +#include +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * An opaque handle representing a system process. + * + * \since This datatype is available since SDL 3.2.0. + * + * \sa SDL_CreateProcess + */ +typedef struct SDL_Process SDL_Process; + +/** + * Create a new process. + * + * The path to the executable is supplied in args[0]. args[1..N] are + * additional arguments passed on the command line of the new process, and the + * argument list should be terminated with a NULL, e.g.: + * + * ```c + * const char *args[] = { "myprogram", "argument", NULL }; + * ``` + * + * Setting pipe_stdio to true is equivalent to setting + * `SDL_PROP_PROCESS_CREATE_STDIN_NUMBER` and + * `SDL_PROP_PROCESS_CREATE_STDOUT_NUMBER` to `SDL_PROCESS_STDIO_APP`, and + * will allow the use of SDL_ReadProcess() or SDL_GetProcessInput() and + * SDL_GetProcessOutput(). + * + * See SDL_CreateProcessWithProperties() for more details. + * + * \param args the path and arguments for the new process. + * \param pipe_stdio true to create pipes to the process's standard input and + * from the process's standard output, false for the process + * to have no input and inherit the application's standard + * output. + * \returns the newly created and running process, or NULL if the process + * couldn't be created. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateProcessWithProperties + * \sa SDL_GetProcessProperties + * \sa SDL_ReadProcess + * \sa SDL_GetProcessInput + * \sa SDL_GetProcessOutput + * \sa SDL_KillProcess + * \sa SDL_WaitProcess + * \sa SDL_DestroyProcess + */ +extern SDL_DECLSPEC SDL_Process * SDLCALL SDL_CreateProcess(const char * const *args, bool pipe_stdio); + +/** + * Description of where standard I/O should be directed when creating a + * process. + * + * If a standard I/O stream is set to SDL_PROCESS_STDIO_INHERITED, it will go + * to the same place as the application's I/O stream. This is the default for + * standard output and standard error. + * + * If a standard I/O stream is set to SDL_PROCESS_STDIO_NULL, it is connected + * to `NUL:` on Windows and `/dev/null` on POSIX systems. This is the default + * for standard input. + * + * If a standard I/O stream is set to SDL_PROCESS_STDIO_APP, it is connected + * to a new SDL_IOStream that is available to the application. Standard input + * will be available as `SDL_PROP_PROCESS_STDIN_POINTER` and allows + * SDL_GetProcessInput(), standard output will be available as + * `SDL_PROP_PROCESS_STDOUT_POINTER` and allows SDL_ReadProcess() and + * SDL_GetProcessOutput(), and standard error will be available as + * `SDL_PROP_PROCESS_STDERR_POINTER` in the properties for the created + * process. + * + * If a standard I/O stream is set to SDL_PROCESS_STDIO_REDIRECT, it is + * connected to an existing SDL_IOStream provided by the application. Standard + * input is provided using `SDL_PROP_PROCESS_CREATE_STDIN_POINTER`, standard + * output is provided using `SDL_PROP_PROCESS_CREATE_STDOUT_POINTER`, and + * standard error is provided using `SDL_PROP_PROCESS_CREATE_STDERR_POINTER` + * in the creation properties. These existing streams should be closed by the + * application once the new process is created. + * + * In order to use an SDL_IOStream with SDL_PROCESS_STDIO_REDIRECT, it must + * have `SDL_PROP_IOSTREAM_WINDOWS_HANDLE_POINTER` or + * `SDL_PROP_IOSTREAM_FILE_DESCRIPTOR_NUMBER` set. This is true for streams + * representing files and process I/O. + * + * \since This enum is available since SDL 3.2.0. + * + * \sa SDL_CreateProcessWithProperties + * \sa SDL_GetProcessProperties + * \sa SDL_ReadProcess + * \sa SDL_GetProcessInput + * \sa SDL_GetProcessOutput + */ +typedef enum SDL_ProcessIO +{ + SDL_PROCESS_STDIO_INHERITED, /**< The I/O stream is inherited from the application. */ + SDL_PROCESS_STDIO_NULL, /**< The I/O stream is ignored. */ + SDL_PROCESS_STDIO_APP, /**< The I/O stream is connected to a new SDL_IOStream that the application can read or write */ + SDL_PROCESS_STDIO_REDIRECT /**< The I/O stream is redirected to an existing SDL_IOStream. */ +} SDL_ProcessIO; + +/** + * Create a new process with the specified properties. + * + * These are the supported properties: + * + * - `SDL_PROP_PROCESS_CREATE_ARGS_POINTER`: an array of strings containing + * the program to run, any arguments, and a NULL pointer, e.g. const char + * *args[] = { "myprogram", "argument", NULL }. This is a required property. + * - `SDL_PROP_PROCESS_CREATE_ENVIRONMENT_POINTER`: an SDL_Environment + * pointer. If this property is set, it will be the entire environment for + * the process, otherwise the current environment is used. + * - `SDL_PROP_PROCESS_CREATE_WORKING_DIRECTORY_STRING`: a UTF-8 encoded + * string representing the working directory for the process, defaults to + * the current working directory. + * - `SDL_PROP_PROCESS_CREATE_STDIN_NUMBER`: an SDL_ProcessIO value describing + * where standard input for the process comes from, defaults to + * `SDL_PROCESS_STDIO_NULL`. + * - `SDL_PROP_PROCESS_CREATE_STDIN_POINTER`: an SDL_IOStream pointer used for + * standard input when `SDL_PROP_PROCESS_CREATE_STDIN_NUMBER` is set to + * `SDL_PROCESS_STDIO_REDIRECT`. + * - `SDL_PROP_PROCESS_CREATE_STDOUT_NUMBER`: an SDL_ProcessIO value + * describing where standard output for the process goes to, defaults to + * `SDL_PROCESS_STDIO_INHERITED`. + * - `SDL_PROP_PROCESS_CREATE_STDOUT_POINTER`: an SDL_IOStream pointer used + * for standard output when `SDL_PROP_PROCESS_CREATE_STDOUT_NUMBER` is set + * to `SDL_PROCESS_STDIO_REDIRECT`. + * - `SDL_PROP_PROCESS_CREATE_STDERR_NUMBER`: an SDL_ProcessIO value + * describing where standard error for the process goes to, defaults to + * `SDL_PROCESS_STDIO_INHERITED`. + * - `SDL_PROP_PROCESS_CREATE_STDERR_POINTER`: an SDL_IOStream pointer used + * for standard error when `SDL_PROP_PROCESS_CREATE_STDERR_NUMBER` is set to + * `SDL_PROCESS_STDIO_REDIRECT`. + * - `SDL_PROP_PROCESS_CREATE_STDERR_TO_STDOUT_BOOLEAN`: true if the error + * output of the process should be redirected into the standard output of + * the process. This property has no effect if + * `SDL_PROP_PROCESS_CREATE_STDERR_NUMBER` is set. + * - `SDL_PROP_PROCESS_CREATE_BACKGROUND_BOOLEAN`: true if the process should + * run in the background. In this case the default input and output is + * `SDL_PROCESS_STDIO_NULL` and the exitcode of the process is not + * available, and will always be 0. + * - `SDL_PROP_PROCESS_CREATE_CMDLINE_STRING`: a string containing the program + * to run and any parameters. This string is passed directly to + * `CreateProcess` on Windows, and does nothing on other platforms. This + * property is only important if you want to start programs that does + * non-standard command-line processing, and in most cases using + * `SDL_PROP_PROCESS_CREATE_ARGS_POINTER` is sufficient. + * + * On POSIX platforms, wait() and waitpid(-1, ...) should not be called, and + * SIGCHLD should not be ignored or handled because those would prevent SDL + * from properly tracking the lifetime of the underlying process. You should + * use SDL_WaitProcess() instead. + * + * \param props the properties to use. + * \returns the newly created and running process, or NULL if the process + * couldn't be created. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateProcess + * \sa SDL_GetProcessProperties + * \sa SDL_ReadProcess + * \sa SDL_GetProcessInput + * \sa SDL_GetProcessOutput + * \sa SDL_KillProcess + * \sa SDL_WaitProcess + * \sa SDL_DestroyProcess + */ +extern SDL_DECLSPEC SDL_Process * SDLCALL SDL_CreateProcessWithProperties(SDL_PropertiesID props); + +#define SDL_PROP_PROCESS_CREATE_ARGS_POINTER "SDL.process.create.args" +#define SDL_PROP_PROCESS_CREATE_ENVIRONMENT_POINTER "SDL.process.create.environment" +#define SDL_PROP_PROCESS_CREATE_WORKING_DIRECTORY_STRING "SDL.process.create.working_directory" +#define SDL_PROP_PROCESS_CREATE_STDIN_NUMBER "SDL.process.create.stdin_option" +#define SDL_PROP_PROCESS_CREATE_STDIN_POINTER "SDL.process.create.stdin_source" +#define SDL_PROP_PROCESS_CREATE_STDOUT_NUMBER "SDL.process.create.stdout_option" +#define SDL_PROP_PROCESS_CREATE_STDOUT_POINTER "SDL.process.create.stdout_source" +#define SDL_PROP_PROCESS_CREATE_STDERR_NUMBER "SDL.process.create.stderr_option" +#define SDL_PROP_PROCESS_CREATE_STDERR_POINTER "SDL.process.create.stderr_source" +#define SDL_PROP_PROCESS_CREATE_STDERR_TO_STDOUT_BOOLEAN "SDL.process.create.stderr_to_stdout" +#define SDL_PROP_PROCESS_CREATE_BACKGROUND_BOOLEAN "SDL.process.create.background" +#define SDL_PROP_PROCESS_CREATE_CMDLINE_STRING "SDL.process.create.cmdline" + +/** + * Get the properties associated with a process. + * + * The following read-only properties are provided by SDL: + * + * - `SDL_PROP_PROCESS_PID_NUMBER`: the process ID of the process. + * - `SDL_PROP_PROCESS_STDIN_POINTER`: an SDL_IOStream that can be used to + * write input to the process, if it was created with + * `SDL_PROP_PROCESS_CREATE_STDIN_NUMBER` set to `SDL_PROCESS_STDIO_APP`. + * - `SDL_PROP_PROCESS_STDOUT_POINTER`: a non-blocking SDL_IOStream that can + * be used to read output from the process, if it was created with + * `SDL_PROP_PROCESS_CREATE_STDOUT_NUMBER` set to `SDL_PROCESS_STDIO_APP`. + * - `SDL_PROP_PROCESS_STDERR_POINTER`: a non-blocking SDL_IOStream that can + * be used to read error output from the process, if it was created with + * `SDL_PROP_PROCESS_CREATE_STDERR_NUMBER` set to `SDL_PROCESS_STDIO_APP`. + * - `SDL_PROP_PROCESS_BACKGROUND_BOOLEAN`: true if the process is running in + * the background. + * + * \param process the process to query. + * \returns a valid property ID on success or 0 on failure; call + * SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateProcess + * \sa SDL_CreateProcessWithProperties + */ +extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetProcessProperties(SDL_Process *process); + +#define SDL_PROP_PROCESS_PID_NUMBER "SDL.process.pid" +#define SDL_PROP_PROCESS_STDIN_POINTER "SDL.process.stdin" +#define SDL_PROP_PROCESS_STDOUT_POINTER "SDL.process.stdout" +#define SDL_PROP_PROCESS_STDERR_POINTER "SDL.process.stderr" +#define SDL_PROP_PROCESS_BACKGROUND_BOOLEAN "SDL.process.background" + +/** + * Read all the output from a process. + * + * If a process was created with I/O enabled, you can use this function to + * read the output. This function blocks until the process is complete, + * capturing all output, and providing the process exit code. + * + * The data is allocated with a zero byte at the end (null terminated) for + * convenience. This extra byte is not included in the value reported via + * `datasize`. + * + * The data should be freed with SDL_free(). + * + * \param process The process to read. + * \param datasize a pointer filled in with the number of bytes read, may be + * NULL. + * \param exitcode a pointer filled in with the process exit code if the + * process has exited, may be NULL. + * \returns the data or NULL on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function is not thread safe. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateProcess + * \sa SDL_CreateProcessWithProperties + * \sa SDL_DestroyProcess + */ +extern SDL_DECLSPEC void * SDLCALL SDL_ReadProcess(SDL_Process *process, size_t *datasize, int *exitcode); + +/** + * Get the SDL_IOStream associated with process standard input. + * + * The process must have been created with SDL_CreateProcess() and pipe_stdio + * set to true, or with SDL_CreateProcessWithProperties() and + * `SDL_PROP_PROCESS_CREATE_STDIN_NUMBER` set to `SDL_PROCESS_STDIO_APP`. + * + * Writing to this stream can return less data than expected if the process + * hasn't read its input. It may be blocked waiting for its output to be read, + * if so you may need to call SDL_GetProcessOutput() and read the output in + * parallel with writing input. + * + * \param process The process to get the input stream for. + * \returns the input stream or NULL on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateProcess + * \sa SDL_CreateProcessWithProperties + * \sa SDL_GetProcessOutput + */ +extern SDL_DECLSPEC SDL_IOStream * SDLCALL SDL_GetProcessInput(SDL_Process *process); + +/** + * Get the SDL_IOStream associated with process standard output. + * + * The process must have been created with SDL_CreateProcess() and pipe_stdio + * set to true, or with SDL_CreateProcessWithProperties() and + * `SDL_PROP_PROCESS_CREATE_STDOUT_NUMBER` set to `SDL_PROCESS_STDIO_APP`. + * + * Reading from this stream can return 0 with SDL_GetIOStatus() returning + * SDL_IO_STATUS_NOT_READY if no output is available yet. + * + * \param process The process to get the output stream for. + * \returns the output stream or NULL on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateProcess + * \sa SDL_CreateProcessWithProperties + * \sa SDL_GetProcessInput + */ +extern SDL_DECLSPEC SDL_IOStream * SDLCALL SDL_GetProcessOutput(SDL_Process *process); + +/** + * Stop a process. + * + * \param process The process to stop. + * \param force true to terminate the process immediately, false to try to + * stop the process gracefully. In general you should try to stop + * the process gracefully first as terminating a process may + * leave it with half-written data or in some other unstable + * state. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function is not thread safe. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateProcess + * \sa SDL_CreateProcessWithProperties + * \sa SDL_WaitProcess + * \sa SDL_DestroyProcess + */ +extern SDL_DECLSPEC bool SDLCALL SDL_KillProcess(SDL_Process *process, bool force); + +/** + * Wait for a process to finish. + * + * This can be called multiple times to get the status of a process. + * + * The exit code will be the exit code of the process if it terminates + * normally, a negative signal if it terminated due to a signal, or -255 + * otherwise. It will not be changed if the process is still running. + * + * If you create a process with standard output piped to the application + * (`pipe_stdio` being true) then you should read all of the process output + * before calling SDL_WaitProcess(). If you don't do this the process might be + * blocked indefinitely waiting for output to be read and SDL_WaitProcess() + * will never return true; + * + * \param process The process to wait for. + * \param block If true, block until the process finishes; otherwise, report + * on the process' status. + * \param exitcode a pointer filled in with the process exit code if the + * process has exited, may be NULL. + * \returns true if the process exited, false otherwise. + * + * \threadsafety This function is not thread safe. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateProcess + * \sa SDL_CreateProcessWithProperties + * \sa SDL_KillProcess + * \sa SDL_DestroyProcess + */ +extern SDL_DECLSPEC bool SDLCALL SDL_WaitProcess(SDL_Process *process, bool block, int *exitcode); + +/** + * Destroy a previously created process object. + * + * Note that this does not stop the process, just destroys the SDL object used + * to track it. If you want to stop the process you should use + * SDL_KillProcess(). + * + * \param process The process object to destroy. + * + * \threadsafety This function is not thread safe. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateProcess + * \sa SDL_CreateProcessWithProperties + * \sa SDL_KillProcess + */ +extern SDL_DECLSPEC void SDLCALL SDL_DestroyProcess(SDL_Process *process); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_process_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_properties.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_properties.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,570 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * # CategoryProperties + * + * A property is a variable that can be created and retrieved by name at + * runtime. + * + * All properties are part of a property group (SDL_PropertiesID). A property + * group can be created with the SDL_CreateProperties function and destroyed + * with the SDL_DestroyProperties function. + * + * Properties can be added to and retrieved from a property group through the + * following functions: + * + * - SDL_SetPointerProperty and SDL_GetPointerProperty operate on `void*` + * pointer types. + * - SDL_SetStringProperty and SDL_GetStringProperty operate on string types. + * - SDL_SetNumberProperty and SDL_GetNumberProperty operate on signed 64-bit + * integer types. + * - SDL_SetFloatProperty and SDL_GetFloatProperty operate on floating point + * types. + * - SDL_SetBooleanProperty and SDL_GetBooleanProperty operate on boolean + * types. + * + * Properties can be removed from a group by using SDL_ClearProperty. + */ + + +#ifndef SDL_properties_h_ +#define SDL_properties_h_ + +#include +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * An ID that represents a properties set. + * + * \since This datatype is available since SDL 3.2.0. + */ +typedef Uint32 SDL_PropertiesID; + +/** + * SDL property type + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_PropertyType +{ + SDL_PROPERTY_TYPE_INVALID, + SDL_PROPERTY_TYPE_POINTER, + SDL_PROPERTY_TYPE_STRING, + SDL_PROPERTY_TYPE_NUMBER, + SDL_PROPERTY_TYPE_FLOAT, + SDL_PROPERTY_TYPE_BOOLEAN +} SDL_PropertyType; + +/** + * A generic property for naming things. + * + * This property is intended to be added to any SDL_PropertiesID that needs a + * generic name associated with the property set. It is not guaranteed that + * any property set will include this key, but it is convenient to have a + * standard key that any piece of code could reasonably agree to use. + * + * For example, the properties associated with an SDL_Texture might have a + * name string of "player sprites", or an SDL_AudioStream might have + * "background music", etc. This might also be useful for an SDL_IOStream to + * list the path to its asset. + * + * There is no format for the value set with this key; it is expected to be + * human-readable and informational in nature, possibly for logging or + * debugging purposes. + * + * SDL does not currently set this property on any objects it creates, but + * this may change in later versions; it is currently expected that apps and + * external libraries will take advantage of it, when appropriate. + * + * \since This macro is available since SDL 3.4.0. + */ +#define SDL_PROP_NAME_STRING "SDL.name" + +/** + * Get the global SDL properties. + * + * \returns a valid property ID on success or 0 on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetGlobalProperties(void); + +/** + * Create a group of properties. + * + * All properties are automatically destroyed when SDL_Quit() is called. + * + * \returns an ID for a new group of properties, or 0 on failure; call + * SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_DestroyProperties + */ +extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_CreateProperties(void); + +/** + * Copy a group of properties. + * + * Copy all the properties from one group of properties to another, with the + * exception of properties requiring cleanup (set using + * SDL_SetPointerPropertyWithCleanup()), which will not be copied. Any + * property that already exists on `dst` will be overwritten. + * + * \param src the properties to copy. + * \param dst the destination properties. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. This + * function acquires simultaneous mutex locks on both the source + * and destination property sets. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_CopyProperties(SDL_PropertiesID src, SDL_PropertiesID dst); + +/** + * Lock a group of properties. + * + * Obtain a multi-threaded lock for these properties. Other threads will wait + * while trying to lock these properties until they are unlocked. Properties + * must be unlocked before they are destroyed. + * + * The lock is automatically taken when setting individual properties, this + * function is only needed when you want to set several properties atomically + * or want to guarantee that properties being queried aren't freed in another + * thread. + * + * \param props the properties to lock. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_UnlockProperties + */ +extern SDL_DECLSPEC bool SDLCALL SDL_LockProperties(SDL_PropertiesID props); + +/** + * Unlock a group of properties. + * + * \param props the properties to unlock. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_LockProperties + */ +extern SDL_DECLSPEC void SDLCALL SDL_UnlockProperties(SDL_PropertiesID props); + +/** + * A callback used to free resources when a property is deleted. + * + * This should release any resources associated with `value` that are no + * longer needed. + * + * This callback is set per-property. Different properties in the same group + * can have different cleanup callbacks. + * + * This callback will be called _during_ SDL_SetPointerPropertyWithCleanup if + * the function fails for any reason. + * + * \param userdata an app-defined pointer passed to the callback. + * \param value the pointer assigned to the property to clean up. + * + * \threadsafety This callback may fire without any locks held; if this is a + * concern, the app should provide its own locking. + * + * \since This datatype is available since SDL 3.2.0. + * + * \sa SDL_SetPointerPropertyWithCleanup + */ +typedef void (SDLCALL *SDL_CleanupPropertyCallback)(void *userdata, void *value); + +/** + * Set a pointer property in a group of properties with a cleanup function + * that is called when the property is deleted. + * + * The cleanup function is also called if setting the property fails for any + * reason. + * + * For simply setting basic data types, like numbers, bools, or strings, use + * SDL_SetNumberProperty, SDL_SetBooleanProperty, or SDL_SetStringProperty + * instead, as those functions will handle cleanup on your behalf. This + * function is only for more complex, custom data. + * + * \param props the properties to modify. + * \param name the name of the property to modify. + * \param value the new value of the property, or NULL to delete the property. + * \param cleanup the function to call when this property is deleted, or NULL + * if no cleanup is necessary. + * \param userdata a pointer that is passed to the cleanup function. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetPointerProperty + * \sa SDL_SetPointerProperty + * \sa SDL_CleanupPropertyCallback + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetPointerPropertyWithCleanup(SDL_PropertiesID props, const char *name, void *value, SDL_CleanupPropertyCallback cleanup, void *userdata); + +/** + * Set a pointer property in a group of properties. + * + * \param props the properties to modify. + * \param name the name of the property to modify. + * \param value the new value of the property, or NULL to delete the property. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetPointerProperty + * \sa SDL_HasProperty + * \sa SDL_SetBooleanProperty + * \sa SDL_SetFloatProperty + * \sa SDL_SetNumberProperty + * \sa SDL_SetPointerPropertyWithCleanup + * \sa SDL_SetStringProperty + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetPointerProperty(SDL_PropertiesID props, const char *name, void *value); + +/** + * Set a string property in a group of properties. + * + * This function makes a copy of the string; the caller does not have to + * preserve the data after this call completes. + * + * \param props the properties to modify. + * \param name the name of the property to modify. + * \param value the new value of the property, or NULL to delete the property. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetStringProperty + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetStringProperty(SDL_PropertiesID props, const char *name, const char *value); + +/** + * Set an integer property in a group of properties. + * + * \param props the properties to modify. + * \param name the name of the property to modify. + * \param value the new value of the property. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetNumberProperty + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetNumberProperty(SDL_PropertiesID props, const char *name, Sint64 value); + +/** + * Set a floating point property in a group of properties. + * + * \param props the properties to modify. + * \param name the name of the property to modify. + * \param value the new value of the property. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetFloatProperty + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetFloatProperty(SDL_PropertiesID props, const char *name, float value); + +/** + * Set a boolean property in a group of properties. + * + * \param props the properties to modify. + * \param name the name of the property to modify. + * \param value the new value of the property. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetBooleanProperty + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetBooleanProperty(SDL_PropertiesID props, const char *name, bool value); + +/** + * Return whether a property exists in a group of properties. + * + * \param props the properties to query. + * \param name the name of the property to query. + * \returns true if the property exists, or false if it doesn't. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetPropertyType + */ +extern SDL_DECLSPEC bool SDLCALL SDL_HasProperty(SDL_PropertiesID props, const char *name); + +/** + * Get the type of a property in a group of properties. + * + * \param props the properties to query. + * \param name the name of the property to query. + * \returns the type of the property, or SDL_PROPERTY_TYPE_INVALID if it is + * not set. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_HasProperty + */ +extern SDL_DECLSPEC SDL_PropertyType SDLCALL SDL_GetPropertyType(SDL_PropertiesID props, const char *name); + +/** + * Get a pointer property from a group of properties. + * + * By convention, the names of properties that SDL exposes on objects will + * start with "SDL.", and properties that SDL uses internally will start with + * "SDL.internal.". These should be considered read-only and should not be + * modified by applications. + * + * \param props the properties to query. + * \param name the name of the property to query. + * \param default_value the default value of the property. + * \returns the value of the property, or `default_value` if it is not set or + * not a pointer property. + * + * \threadsafety It is safe to call this function from any thread, although + * the data returned is not protected and could potentially be + * freed if you call SDL_SetPointerProperty() or + * SDL_ClearProperty() on these properties from another thread. + * If you need to avoid this, use SDL_LockProperties() and + * SDL_UnlockProperties(). + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetBooleanProperty + * \sa SDL_GetFloatProperty + * \sa SDL_GetNumberProperty + * \sa SDL_GetPropertyType + * \sa SDL_GetStringProperty + * \sa SDL_HasProperty + * \sa SDL_SetPointerProperty + */ +extern SDL_DECLSPEC void * SDLCALL SDL_GetPointerProperty(SDL_PropertiesID props, const char *name, void *default_value); + +/** + * Get a string property from a group of properties. + * + * \param props the properties to query. + * \param name the name of the property to query. + * \param default_value the default value of the property. + * \returns the value of the property, or `default_value` if it is not set or + * not a string property. + * + * \threadsafety It is safe to call this function from any thread, although + * the data returned is not protected and could potentially be + * freed if you call SDL_SetStringProperty() or + * SDL_ClearProperty() on these properties from another thread. + * If you need to avoid this, use SDL_LockProperties() and + * SDL_UnlockProperties(). + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetPropertyType + * \sa SDL_HasProperty + * \sa SDL_SetStringProperty + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetStringProperty(SDL_PropertiesID props, const char *name, const char *default_value); + +/** + * Get a number property from a group of properties. + * + * You can use SDL_GetPropertyType() to query whether the property exists and + * is a number property. + * + * \param props the properties to query. + * \param name the name of the property to query. + * \param default_value the default value of the property. + * \returns the value of the property, or `default_value` if it is not set or + * not a number property. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetPropertyType + * \sa SDL_HasProperty + * \sa SDL_SetNumberProperty + */ +extern SDL_DECLSPEC Sint64 SDLCALL SDL_GetNumberProperty(SDL_PropertiesID props, const char *name, Sint64 default_value); + +/** + * Get a floating point property from a group of properties. + * + * You can use SDL_GetPropertyType() to query whether the property exists and + * is a floating point property. + * + * \param props the properties to query. + * \param name the name of the property to query. + * \param default_value the default value of the property. + * \returns the value of the property, or `default_value` if it is not set or + * not a float property. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetPropertyType + * \sa SDL_HasProperty + * \sa SDL_SetFloatProperty + */ +extern SDL_DECLSPEC float SDLCALL SDL_GetFloatProperty(SDL_PropertiesID props, const char *name, float default_value); + +/** + * Get a boolean property from a group of properties. + * + * You can use SDL_GetPropertyType() to query whether the property exists and + * is a boolean property. + * + * \param props the properties to query. + * \param name the name of the property to query. + * \param default_value the default value of the property. + * \returns the value of the property, or `default_value` if it is not set or + * not a boolean property. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetPropertyType + * \sa SDL_HasProperty + * \sa SDL_SetBooleanProperty + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetBooleanProperty(SDL_PropertiesID props, const char *name, bool default_value); + +/** + * Clear a property from a group of properties. + * + * \param props the properties to modify. + * \param name the name of the property to clear. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_ClearProperty(SDL_PropertiesID props, const char *name); + +/** + * A callback used to enumerate all the properties in a group of properties. + * + * This callback is called from SDL_EnumerateProperties(), and is called once + * per property in the set. + * + * \param userdata an app-defined pointer passed to the callback. + * \param props the SDL_PropertiesID that is being enumerated. + * \param name the next property name in the enumeration. + * + * \threadsafety SDL_EnumerateProperties holds a lock on `props` during this + * callback. + * + * \since This datatype is available since SDL 3.2.0. + * + * \sa SDL_EnumerateProperties + */ +typedef void (SDLCALL *SDL_EnumeratePropertiesCallback)(void *userdata, SDL_PropertiesID props, const char *name); + +/** + * Enumerate the properties contained in a group of properties. + * + * The callback function is called for each property in the group of + * properties. The properties are locked during enumeration. + * + * \param props the properties to query. + * \param callback the function to call for each property. + * \param userdata a pointer that is passed to `callback`. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_EnumerateProperties(SDL_PropertiesID props, SDL_EnumeratePropertiesCallback callback, void *userdata); + +/** + * Destroy a group of properties. + * + * All properties are deleted and their cleanup functions will be called, if + * any. + * + * \param props the properties to destroy. + * + * \threadsafety This function should not be called while these properties are + * locked or other threads might be setting or getting values + * from these properties. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateProperties + */ +extern SDL_DECLSPEC void SDLCALL SDL_DestroyProperties(SDL_PropertiesID props); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_properties_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_rect.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_rect.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,510 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * # CategoryRect + * + * Some helper functions for managing rectangles and 2D points, in both + * integer and floating point versions. + */ + +#ifndef SDL_rect_h_ +#define SDL_rect_h_ + +#include +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * The structure that defines a point (using integers). + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_GetRectEnclosingPoints + * \sa SDL_PointInRect + */ +typedef struct SDL_Point +{ + int x; + int y; +} SDL_Point; + +/** + * The structure that defines a point (using floating point values). + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_GetRectEnclosingPointsFloat + * \sa SDL_PointInRectFloat + */ +typedef struct SDL_FPoint +{ + float x; + float y; +} SDL_FPoint; + + +/** + * A rectangle, with the origin at the upper left (using integers). + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_RectEmpty + * \sa SDL_RectsEqual + * \sa SDL_HasRectIntersection + * \sa SDL_GetRectIntersection + * \sa SDL_GetRectAndLineIntersection + * \sa SDL_GetRectUnion + * \sa SDL_GetRectEnclosingPoints + */ +typedef struct SDL_Rect +{ + int x, y; + int w, h; +} SDL_Rect; + + +/** + * A rectangle stored using floating point values. + * + * The origin of the coordinate space is in the top-left, with increasing + * values moving down and right. The properties `x` and `y` represent the + * coordinates of the top-left corner of the rectangle. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_RectEmptyFloat + * \sa SDL_RectsEqualFloat + * \sa SDL_RectsEqualEpsilon + * \sa SDL_HasRectIntersectionFloat + * \sa SDL_GetRectIntersectionFloat + * \sa SDL_GetRectAndLineIntersectionFloat + * \sa SDL_GetRectUnionFloat + * \sa SDL_GetRectEnclosingPointsFloat + * \sa SDL_PointInRectFloat + */ +typedef struct SDL_FRect +{ + float x; + float y; + float w; + float h; +} SDL_FRect; + + +/** + * Convert an SDL_Rect to SDL_FRect + * + * \param rect a pointer to an SDL_Rect. + * \param frect a pointer filled in with the floating point representation of + * `rect`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +SDL_FORCE_INLINE void SDL_RectToFRect(const SDL_Rect *rect, SDL_FRect *frect) +{ + frect->x = SDL_static_cast(float, rect->x); + frect->y = SDL_static_cast(float, rect->y); + frect->w = SDL_static_cast(float, rect->w); + frect->h = SDL_static_cast(float, rect->h); +} + +/** + * Determine whether a point resides inside a rectangle. + * + * A point is considered part of a rectangle if both `p` and `r` are not NULL, + * and `p`'s x and y coordinates are >= to the rectangle's top left corner, + * and < the rectangle's x+w and y+h. So a 1x1 rectangle considers point (0,0) + * as "inside" and (0,1) as not. + * + * Note that this is a forced-inline function in a header, and not a public + * API function available in the SDL library (which is to say, the code is + * embedded in the calling program and the linker and dynamic loader will not + * be able to find this function inside SDL itself). + * + * \param p the point to test. + * \param r the rectangle to test. + * \returns true if `p` is contained by `r`, false otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +SDL_FORCE_INLINE bool SDL_PointInRect(const SDL_Point *p, const SDL_Rect *r) +{ + return ( p && r && (p->x >= r->x) && (p->x < (r->x + r->w)) && + (p->y >= r->y) && (p->y < (r->y + r->h)) ) ? true : false; +} + +/** + * Determine whether a rectangle has no area. + * + * A rectangle is considered "empty" for this function if `r` is NULL, or if + * `r`'s width and/or height are <= 0. + * + * Note that this is a forced-inline function in a header, and not a public + * API function available in the SDL library (which is to say, the code is + * embedded in the calling program and the linker and dynamic loader will not + * be able to find this function inside SDL itself). + * + * \param r the rectangle to test. + * \returns true if the rectangle is "empty", false otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +SDL_FORCE_INLINE bool SDL_RectEmpty(const SDL_Rect *r) +{ + return ((!r) || (r->w <= 0) || (r->h <= 0)) ? true : false; +} + +/** + * Determine whether two rectangles are equal. + * + * Rectangles are considered equal if both are not NULL and each of their x, + * y, width and height match. + * + * Note that this is a forced-inline function in a header, and not a public + * API function available in the SDL library (which is to say, the code is + * embedded in the calling program and the linker and dynamic loader will not + * be able to find this function inside SDL itself). + * + * \param a the first rectangle to test. + * \param b the second rectangle to test. + * \returns true if the rectangles are equal, false otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +SDL_FORCE_INLINE bool SDL_RectsEqual(const SDL_Rect *a, const SDL_Rect *b) +{ + return (a && b && (a->x == b->x) && (a->y == b->y) && + (a->w == b->w) && (a->h == b->h)) ? true : false; +} + +/** + * Determine whether two rectangles intersect. + * + * If either pointer is NULL the function will return false. + * + * \param A an SDL_Rect structure representing the first rectangle. + * \param B an SDL_Rect structure representing the second rectangle. + * \returns true if there is an intersection, false otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetRectIntersection + */ +extern SDL_DECLSPEC bool SDLCALL SDL_HasRectIntersection(const SDL_Rect *A, const SDL_Rect *B); + +/** + * Calculate the intersection of two rectangles. + * + * If `result` is NULL then this function will return false. + * + * \param A an SDL_Rect structure representing the first rectangle. + * \param B an SDL_Rect structure representing the second rectangle. + * \param result an SDL_Rect structure filled in with the intersection of + * rectangles `A` and `B`. + * \returns true if there is an intersection, false otherwise. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_HasRectIntersection + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetRectIntersection(const SDL_Rect *A, const SDL_Rect *B, SDL_Rect *result); + +/** + * Calculate the union of two rectangles. + * + * \param A an SDL_Rect structure representing the first rectangle. + * \param B an SDL_Rect structure representing the second rectangle. + * \param result an SDL_Rect structure filled in with the union of rectangles + * `A` and `B`. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetRectUnion(const SDL_Rect *A, const SDL_Rect *B, SDL_Rect *result); + +/** + * Calculate a minimal rectangle enclosing a set of points. + * + * If `clip` is not NULL then only points inside of the clipping rectangle are + * considered. + * + * \param points an array of SDL_Point structures representing points to be + * enclosed. + * \param count the number of structures in the `points` array. + * \param clip an SDL_Rect used for clipping or NULL to enclose all points. + * \param result an SDL_Rect structure filled in with the minimal enclosing + * rectangle. + * \returns true if any points were enclosed or false if all the points were + * outside of the clipping rectangle. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetRectEnclosingPoints(const SDL_Point *points, int count, const SDL_Rect *clip, SDL_Rect *result); + +/** + * Calculate the intersection of a rectangle and line segment. + * + * This function is used to clip a line segment to a rectangle. A line segment + * contained entirely within the rectangle or that does not intersect will + * remain unchanged. A line segment that crosses the rectangle at either or + * both ends will be clipped to the boundary of the rectangle and the new + * coordinates saved in `X1`, `Y1`, `X2`, and/or `Y2` as necessary. + * + * \param rect an SDL_Rect structure representing the rectangle to intersect. + * \param X1 a pointer to the starting X-coordinate of the line. + * \param Y1 a pointer to the starting Y-coordinate of the line. + * \param X2 a pointer to the ending X-coordinate of the line. + * \param Y2 a pointer to the ending Y-coordinate of the line. + * \returns true if there is an intersection, false otherwise. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetRectAndLineIntersection(const SDL_Rect *rect, int *X1, int *Y1, int *X2, int *Y2); + + +/* SDL_FRect versions... */ + +/** + * Determine whether a point resides inside a floating point rectangle. + * + * A point is considered part of a rectangle if both `p` and `r` are not NULL, + * and `p`'s x and y coordinates are >= to the rectangle's top left corner, + * and <= the rectangle's x+w and y+h. So a 1x1 rectangle considers point + * (0,0) and (0,1) as "inside" and (0,2) as not. + * + * Note that this is a forced-inline function in a header, and not a public + * API function available in the SDL library (which is to say, the code is + * embedded in the calling program and the linker and dynamic loader will not + * be able to find this function inside SDL itself). + * + * \param p the point to test. + * \param r the rectangle to test. + * \returns true if `p` is contained by `r`, false otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +SDL_FORCE_INLINE bool SDL_PointInRectFloat(const SDL_FPoint *p, const SDL_FRect *r) +{ + return ( p && r && (p->x >= r->x) && (p->x <= (r->x + r->w)) && + (p->y >= r->y) && (p->y <= (r->y + r->h)) ) ? true : false; +} + +/** + * Determine whether a floating point rectangle takes no space. + * + * A rectangle is considered "empty" for this function if `r` is NULL, or if + * `r`'s width and/or height are < 0.0f. + * + * Note that this is a forced-inline function in a header, and not a public + * API function available in the SDL library (which is to say, the code is + * embedded in the calling program and the linker and dynamic loader will not + * be able to find this function inside SDL itself). + * + * \param r the rectangle to test. + * \returns true if the rectangle is "empty", false otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +SDL_FORCE_INLINE bool SDL_RectEmptyFloat(const SDL_FRect *r) +{ + return ((!r) || (r->w < 0.0f) || (r->h < 0.0f)) ? true : false; +} + +/** + * Determine whether two floating point rectangles are equal, within some + * given epsilon. + * + * Rectangles are considered equal if both are not NULL and each of their x, + * y, width and height are within `epsilon` of each other. If you don't know + * what value to use for `epsilon`, you should call the SDL_RectsEqualFloat + * function instead. + * + * Note that this is a forced-inline function in a header, and not a public + * API function available in the SDL library (which is to say, the code is + * embedded in the calling program and the linker and dynamic loader will not + * be able to find this function inside SDL itself). + * + * \param a the first rectangle to test. + * \param b the second rectangle to test. + * \param epsilon the epsilon value for comparison. + * \returns true if the rectangles are equal, false otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_RectsEqualFloat + */ +SDL_FORCE_INLINE bool SDL_RectsEqualEpsilon(const SDL_FRect *a, const SDL_FRect *b, float epsilon) +{ + return (a && b && ((a == b) || + ((SDL_fabsf(a->x - b->x) <= epsilon) && + (SDL_fabsf(a->y - b->y) <= epsilon) && + (SDL_fabsf(a->w - b->w) <= epsilon) && + (SDL_fabsf(a->h - b->h) <= epsilon)))) + ? true : false; +} + +/** + * Determine whether two floating point rectangles are equal, within a default + * epsilon. + * + * Rectangles are considered equal if both are not NULL and each of their x, + * y, width and height are within SDL_FLT_EPSILON of each other. This is often + * a reasonable way to compare two floating point rectangles and deal with the + * slight precision variations in floating point calculations that tend to pop + * up. + * + * Note that this is a forced-inline function in a header, and not a public + * API function available in the SDL library (which is to say, the code is + * embedded in the calling program and the linker and dynamic loader will not + * be able to find this function inside SDL itself). + * + * \param a the first rectangle to test. + * \param b the second rectangle to test. + * \returns true if the rectangles are equal, false otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_RectsEqualEpsilon + */ +SDL_FORCE_INLINE bool SDL_RectsEqualFloat(const SDL_FRect *a, const SDL_FRect *b) +{ + return SDL_RectsEqualEpsilon(a, b, SDL_FLT_EPSILON); +} + +/** + * Determine whether two rectangles intersect with float precision. + * + * If either pointer is NULL the function will return false. + * + * \param A an SDL_FRect structure representing the first rectangle. + * \param B an SDL_FRect structure representing the second rectangle. + * \returns true if there is an intersection, false otherwise. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetRectIntersection + */ +extern SDL_DECLSPEC bool SDLCALL SDL_HasRectIntersectionFloat(const SDL_FRect *A, const SDL_FRect *B); + +/** + * Calculate the intersection of two rectangles with float precision. + * + * If `result` is NULL then this function will return false. + * + * \param A an SDL_FRect structure representing the first rectangle. + * \param B an SDL_FRect structure representing the second rectangle. + * \param result an SDL_FRect structure filled in with the intersection of + * rectangles `A` and `B`. + * \returns true if there is an intersection, false otherwise. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_HasRectIntersectionFloat + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetRectIntersectionFloat(const SDL_FRect *A, const SDL_FRect *B, SDL_FRect *result); + +/** + * Calculate the union of two rectangles with float precision. + * + * \param A an SDL_FRect structure representing the first rectangle. + * \param B an SDL_FRect structure representing the second rectangle. + * \param result an SDL_FRect structure filled in with the union of rectangles + * `A` and `B`. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetRectUnionFloat(const SDL_FRect *A, const SDL_FRect *B, SDL_FRect *result); + +/** + * Calculate a minimal rectangle enclosing a set of points with float + * precision. + * + * If `clip` is not NULL then only points inside of the clipping rectangle are + * considered. + * + * \param points an array of SDL_FPoint structures representing points to be + * enclosed. + * \param count the number of structures in the `points` array. + * \param clip an SDL_FRect used for clipping or NULL to enclose all points. + * \param result an SDL_FRect structure filled in with the minimal enclosing + * rectangle. + * \returns true if any points were enclosed or false if all the points were + * outside of the clipping rectangle. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetRectEnclosingPointsFloat(const SDL_FPoint *points, int count, const SDL_FRect *clip, SDL_FRect *result); + +/** + * Calculate the intersection of a rectangle and line segment with float + * precision. + * + * This function is used to clip a line segment to a rectangle. A line segment + * contained entirely within the rectangle or that does not intersect will + * remain unchanged. A line segment that crosses the rectangle at either or + * both ends will be clipped to the boundary of the rectangle and the new + * coordinates saved in `X1`, `Y1`, `X2`, and/or `Y2` as necessary. + * + * \param rect an SDL_FRect structure representing the rectangle to intersect. + * \param X1 a pointer to the starting X-coordinate of the line. + * \param Y1 a pointer to the starting Y-coordinate of the line. + * \param X2 a pointer to the ending X-coordinate of the line. + * \param Y2 a pointer to the ending Y-coordinate of the line. + * \returns true if there is an intersection, false otherwise. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetRectAndLineIntersectionFloat(const SDL_FRect *rect, float *X1, float *Y1, float *X2, float *Y2); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_rect_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_render.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_render.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,3026 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * # CategoryRender + * + * Header file for SDL 2D rendering functions. + * + * This API supports the following features: + * + * - single pixel points + * - single pixel lines + * - filled rectangles + * - texture images + * - 2D polygons + * + * The primitives may be drawn in opaque, blended, or additive modes. + * + * The texture images may be drawn in opaque, blended, or additive modes. They + * can have an additional color tint or alpha modulation applied to them, and + * may also be stretched with linear interpolation. + * + * This API is designed to accelerate simple 2D operations. You may want more + * functionality such as 3D polygons and particle effects, and in that case + * you should use SDL's OpenGL/Direct3D support, the SDL3 GPU API, or one of + * the many good 3D engines. + * + * These functions must be called from the main thread. See this bug for + * details: https://github.com/libsdl-org/SDL/issues/986 + */ + +#ifndef SDL_render_h_ +#define SDL_render_h_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * The name of the software renderer. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_SOFTWARE_RENDERER "software" + +/** + * The name of the GPU renderer. + * + * \since This macro is available since SDL 3.4.0. + */ +#define SDL_GPU_RENDERER "gpu" + +/** + * Vertex structure. + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_Vertex +{ + SDL_FPoint position; /**< Vertex position, in SDL_Renderer coordinates */ + SDL_FColor color; /**< Vertex color */ + SDL_FPoint tex_coord; /**< Normalized texture coordinates, if needed */ +} SDL_Vertex; + +/** + * The access pattern allowed for a texture. + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_TextureAccess +{ + SDL_TEXTUREACCESS_STATIC, /**< Changes rarely, not lockable */ + SDL_TEXTUREACCESS_STREAMING, /**< Changes frequently, lockable */ + SDL_TEXTUREACCESS_TARGET /**< Texture can be used as a render target */ +} SDL_TextureAccess; + +/** + * The addressing mode for a texture when used in SDL_RenderGeometry(). + * + * This affects how texture coordinates are interpreted outside of [0, 1] + * + * Texture wrapping is always supported for power of two texture sizes, and is + * supported for other texture sizes if + * SDL_PROP_RENDERER_TEXTURE_WRAPPING_BOOLEAN is set to true. + * + * \since This enum is available since SDL 3.4.0. + */ +typedef enum SDL_TextureAddressMode +{ + SDL_TEXTURE_ADDRESS_INVALID = -1, + SDL_TEXTURE_ADDRESS_AUTO, /**< Wrapping is enabled if texture coordinates are outside [0, 1], this is the default */ + SDL_TEXTURE_ADDRESS_CLAMP, /**< Texture coordinates are clamped to the [0, 1] range */ + SDL_TEXTURE_ADDRESS_WRAP /**< The texture is repeated (tiled) */ +} SDL_TextureAddressMode; + +/** + * How the logical size is mapped to the output. + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_RendererLogicalPresentation +{ + SDL_LOGICAL_PRESENTATION_DISABLED, /**< There is no logical size in effect */ + SDL_LOGICAL_PRESENTATION_STRETCH, /**< The rendered content is stretched to the output resolution */ + SDL_LOGICAL_PRESENTATION_LETTERBOX, /**< The rendered content is fit to the largest dimension and the other dimension is letterboxed with the clear color */ + SDL_LOGICAL_PRESENTATION_OVERSCAN, /**< The rendered content is fit to the smallest dimension and the other dimension extends beyond the output bounds */ + SDL_LOGICAL_PRESENTATION_INTEGER_SCALE /**< The rendered content is scaled up by integer multiples to fit the output resolution */ +} SDL_RendererLogicalPresentation; + +/** + * A structure representing rendering state + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_Renderer SDL_Renderer; + +#ifndef SDL_INTERNAL + +/** + * An efficient driver-specific representation of pixel data + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_CreateTexture + * \sa SDL_CreateTextureFromSurface + * \sa SDL_CreateTextureWithProperties + * \sa SDL_DestroyTexture + */ +struct SDL_Texture +{ + SDL_PixelFormat format; /**< The format of the texture, read-only */ + int w; /**< The width of the texture, read-only. */ + int h; /**< The height of the texture, read-only. */ + + int refcount; /**< Application reference count, used when freeing texture */ +}; +#endif /* !SDL_INTERNAL */ + +typedef struct SDL_Texture SDL_Texture; + +/* Function prototypes */ + +/** + * Get the number of 2D rendering drivers available for the current display. + * + * A render driver is a set of code that handles rendering and texture + * management on a particular display. Normally there is only one, but some + * drivers may have several available with different capabilities. + * + * There may be none if SDL was compiled without render support. + * + * \returns the number of built in render drivers. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateRenderer + * \sa SDL_GetRenderDriver + */ +extern SDL_DECLSPEC int SDLCALL SDL_GetNumRenderDrivers(void); + +/** + * Use this function to get the name of a built in 2D rendering driver. + * + * The list of rendering drivers is given in the order that they are normally + * initialized by default; the drivers that seem more reasonable to choose + * first (as far as the SDL developers believe) are earlier in the list. + * + * The names of drivers are all simple, low-ASCII identifiers, like "opengl", + * "direct3d12" or "metal". These never have Unicode characters, and are not + * meant to be proper names. + * + * \param index the index of the rendering driver; the value ranges from 0 to + * SDL_GetNumRenderDrivers() - 1. + * \returns the name of the rendering driver at the requested index, or NULL + * if an invalid index was specified. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetNumRenderDrivers + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetRenderDriver(int index); + +/** + * Create a window and default renderer. + * + * \param title the title of the window, in UTF-8 encoding. + * \param width the width of the window. + * \param height the height of the window. + * \param window_flags the flags used to create the window (see + * SDL_CreateWindow()). + * \param window a pointer filled with the window, or NULL on error. + * \param renderer a pointer filled with the renderer, or NULL on error. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateRenderer + * \sa SDL_CreateWindow + */ +extern SDL_DECLSPEC bool SDLCALL SDL_CreateWindowAndRenderer(const char *title, int width, int height, SDL_WindowFlags window_flags, SDL_Window **window, SDL_Renderer **renderer); + +/** + * Create a 2D rendering context for a window. + * + * If you want a specific renderer, you can specify its name here. A list of + * available renderers can be obtained by calling SDL_GetRenderDriver() + * multiple times, with indices from 0 to SDL_GetNumRenderDrivers()-1. If you + * don't need a specific renderer, specify NULL and SDL will attempt to choose + * the best option for you, based on what is available on the user's system. + * + * If `name` is a comma-separated list, SDL will try each name, in the order + * listed, until one succeeds or all of them fail. + * + * By default the rendering size matches the window size in pixels, but you + * can call SDL_SetRenderLogicalPresentation() to change the content size and + * scaling options. + * + * \param window the window where rendering is displayed. + * \param name the name of the rendering driver to initialize, or NULL to let + * SDL choose one. + * \returns a valid rendering context or NULL if there was an error; call + * SDL_GetError() for more information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateRendererWithProperties + * \sa SDL_CreateSoftwareRenderer + * \sa SDL_DestroyRenderer + * \sa SDL_GetNumRenderDrivers + * \sa SDL_GetRenderDriver + * \sa SDL_GetRendererName + */ +extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRenderer(SDL_Window *window, const char *name); + +/** + * Create a 2D rendering context for a window, with the specified properties. + * + * These are the supported properties: + * + * - `SDL_PROP_RENDERER_CREATE_NAME_STRING`: the name of the rendering driver + * to use, if a specific one is desired + * - `SDL_PROP_RENDERER_CREATE_WINDOW_POINTER`: the window where rendering is + * displayed, required if this isn't a software renderer using a surface + * - `SDL_PROP_RENDERER_CREATE_SURFACE_POINTER`: the surface where rendering + * is displayed, if you want a software renderer without a window + * - `SDL_PROP_RENDERER_CREATE_OUTPUT_COLORSPACE_NUMBER`: an SDL_Colorspace + * value describing the colorspace for output to the display, defaults to + * SDL_COLORSPACE_SRGB. The direct3d11, direct3d12, and metal renderers + * support SDL_COLORSPACE_SRGB_LINEAR, which is a linear color space and + * supports HDR output. If you select SDL_COLORSPACE_SRGB_LINEAR, drawing + * still uses the sRGB colorspace, but values can go beyond 1.0 and float + * (linear) format textures can be used for HDR content. + * - `SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_NUMBER`: non-zero if you want + * present synchronized with the refresh rate. This property can take any + * value that is supported by SDL_SetRenderVSync() for the renderer. + * + * With the SDL GPU renderer (since SDL 3.4.0): + * + * - `SDL_PROP_RENDERER_CREATE_GPU_DEVICE_POINTER`: the device to use with the + * renderer, optional. + * - `SDL_PROP_RENDERER_CREATE_GPU_SHADERS_SPIRV_BOOLEAN`: the app is able to + * provide SPIR-V shaders to SDL_GPURenderState, optional. + * - `SDL_PROP_RENDERER_CREATE_GPU_SHADERS_DXIL_BOOLEAN`: the app is able to + * provide DXIL shaders to SDL_GPURenderState, optional. + * - `SDL_PROP_RENDERER_CREATE_GPU_SHADERS_MSL_BOOLEAN`: the app is able to + * provide MSL shaders to SDL_GPURenderState, optional. + * + * With the vulkan renderer: + * + * - `SDL_PROP_RENDERER_CREATE_VULKAN_INSTANCE_POINTER`: the VkInstance to use + * with the renderer, optional. + * - `SDL_PROP_RENDERER_CREATE_VULKAN_SURFACE_NUMBER`: the VkSurfaceKHR to use + * with the renderer, optional. + * - `SDL_PROP_RENDERER_CREATE_VULKAN_PHYSICAL_DEVICE_POINTER`: the + * VkPhysicalDevice to use with the renderer, optional. + * - `SDL_PROP_RENDERER_CREATE_VULKAN_DEVICE_POINTER`: the VkDevice to use + * with the renderer, optional. + * - `SDL_PROP_RENDERER_CREATE_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER`: the + * queue family index used for rendering. + * - `SDL_PROP_RENDERER_CREATE_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER`: the + * queue family index used for presentation. + * + * \param props the properties to use. + * \returns a valid rendering context or NULL if there was an error; call + * SDL_GetError() for more information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateProperties + * \sa SDL_CreateRenderer + * \sa SDL_CreateSoftwareRenderer + * \sa SDL_DestroyRenderer + * \sa SDL_GetRendererName + */ +extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRendererWithProperties(SDL_PropertiesID props); + +#define SDL_PROP_RENDERER_CREATE_NAME_STRING "SDL.renderer.create.name" +#define SDL_PROP_RENDERER_CREATE_WINDOW_POINTER "SDL.renderer.create.window" +#define SDL_PROP_RENDERER_CREATE_SURFACE_POINTER "SDL.renderer.create.surface" +#define SDL_PROP_RENDERER_CREATE_OUTPUT_COLORSPACE_NUMBER "SDL.renderer.create.output_colorspace" +#define SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_NUMBER "SDL.renderer.create.present_vsync" +#define SDL_PROP_RENDERER_CREATE_GPU_DEVICE_POINTER "SDL.renderer.create.gpu.device" +#define SDL_PROP_RENDERER_CREATE_GPU_SHADERS_SPIRV_BOOLEAN "SDL.renderer.create.gpu.shaders_spirv" +#define SDL_PROP_RENDERER_CREATE_GPU_SHADERS_DXIL_BOOLEAN "SDL.renderer.create.gpu.shaders_dxil" +#define SDL_PROP_RENDERER_CREATE_GPU_SHADERS_MSL_BOOLEAN "SDL.renderer.create.gpu.shaders_msl" +#define SDL_PROP_RENDERER_CREATE_VULKAN_INSTANCE_POINTER "SDL.renderer.create.vulkan.instance" +#define SDL_PROP_RENDERER_CREATE_VULKAN_SURFACE_NUMBER "SDL.renderer.create.vulkan.surface" +#define SDL_PROP_RENDERER_CREATE_VULKAN_PHYSICAL_DEVICE_POINTER "SDL.renderer.create.vulkan.physical_device" +#define SDL_PROP_RENDERER_CREATE_VULKAN_DEVICE_POINTER "SDL.renderer.create.vulkan.device" +#define SDL_PROP_RENDERER_CREATE_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER "SDL.renderer.create.vulkan.graphics_queue_family_index" +#define SDL_PROP_RENDERER_CREATE_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER "SDL.renderer.create.vulkan.present_queue_family_index" + +/** + * Create a 2D GPU rendering context. + * + * The GPU device to use is passed in as a parameter. If this is NULL, then a + * device will be created normally and can be retrieved using + * SDL_GetGPURendererDevice(). + * + * The window to use is passed in as a parameter. If this is NULL, then this + * will become an offscreen renderer. In that case, you should call + * SDL_SetRenderTarget() to setup rendering to a texture, and then call + * SDL_RenderPresent() normally to complete drawing a frame. + * + * \param device the GPU device to use with the renderer, or NULL to create a + * device. + * \param window the window where rendering is displayed, or NULL to create an + * offscreen renderer. + * \returns a valid rendering context or NULL if there was an error; call + * SDL_GetError() for more information. + * + * \threadsafety If this function is called with a valid GPU device, it should + * be called on the thread that created the device. If this + * function is called with a valid window, it should be called + * on the thread that created the window. + * + * \since This function is available since SDL 3.4.0. + * + * \sa SDL_CreateRendererWithProperties + * \sa SDL_GetGPURendererDevice + * \sa SDL_CreateGPUShader + * \sa SDL_CreateGPURenderState + * \sa SDL_SetGPURenderState + */ +extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_CreateGPURenderer(SDL_GPUDevice *device, SDL_Window *window); + +/** + * Return the GPU device used by a renderer. + * + * \param renderer the rendering context. + * \returns the GPU device used by the renderer, or NULL if the renderer is + * not a GPU renderer; call SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.4.0. + */ +extern SDL_DECLSPEC SDL_GPUDevice * SDLCALL SDL_GetGPURendererDevice(SDL_Renderer *renderer); + +/** + * Create a 2D software rendering context for a surface. + * + * Two other API which can be used to create SDL_Renderer: + * SDL_CreateRenderer() and SDL_CreateWindowAndRenderer(). These can _also_ + * create a software renderer, but they are intended to be used with an + * SDL_Window as the final destination and not an SDL_Surface. + * + * \param surface the SDL_Surface structure representing the surface where + * rendering is done. + * \returns a valid rendering context or NULL if there was an error; call + * SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_DestroyRenderer + */ +extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_CreateSoftwareRenderer(SDL_Surface *surface); + +/** + * Get the renderer associated with a window. + * + * \param window the window to query. + * \returns the rendering context on success or NULL on failure; call + * SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_GetRenderer(SDL_Window *window); + +/** + * Get the window associated with a renderer. + * + * \param renderer the renderer to query. + * \returns the window on success or NULL on failure; call SDL_GetError() for + * more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetRenderWindow(SDL_Renderer *renderer); + +/** + * Get the name of a renderer. + * + * \param renderer the rendering context. + * \returns the name of the selected renderer, or NULL on failure; call + * SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateRenderer + * \sa SDL_CreateRendererWithProperties + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetRendererName(SDL_Renderer *renderer); + +/** + * Get the properties associated with a renderer. + * + * The following read-only properties are provided by SDL: + * + * - `SDL_PROP_RENDERER_NAME_STRING`: the name of the rendering driver + * - `SDL_PROP_RENDERER_WINDOW_POINTER`: the window where rendering is + * displayed, if any + * - `SDL_PROP_RENDERER_SURFACE_POINTER`: the surface where rendering is + * displayed, if this is a software renderer without a window + * - `SDL_PROP_RENDERER_VSYNC_NUMBER`: the current vsync setting + * - `SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER`: the maximum texture width + * and height + * - `SDL_PROP_RENDERER_TEXTURE_FORMATS_POINTER`: a (const SDL_PixelFormat *) + * array of pixel formats, terminated with SDL_PIXELFORMAT_UNKNOWN, + * representing the available texture formats for this renderer. + * - `SDL_PROP_RENDERER_TEXTURE_WRAPPING_BOOLEAN`: true if the renderer + * supports SDL_TEXTURE_ADDRESS_WRAP on non-power-of-two textures. + * - `SDL_PROP_RENDERER_OUTPUT_COLORSPACE_NUMBER`: an SDL_Colorspace value + * describing the colorspace for output to the display, defaults to + * SDL_COLORSPACE_SRGB. + * - `SDL_PROP_RENDERER_HDR_ENABLED_BOOLEAN`: true if the output colorspace is + * SDL_COLORSPACE_SRGB_LINEAR and the renderer is showing on a display with + * HDR enabled. This property can change dynamically when + * SDL_EVENT_WINDOW_HDR_STATE_CHANGED is sent. + * - `SDL_PROP_RENDERER_SDR_WHITE_POINT_FLOAT`: the value of SDR white in the + * SDL_COLORSPACE_SRGB_LINEAR colorspace. When HDR is enabled, this value is + * automatically multiplied into the color scale. This property can change + * dynamically when SDL_EVENT_WINDOW_HDR_STATE_CHANGED is sent. + * - `SDL_PROP_RENDERER_HDR_HEADROOM_FLOAT`: the additional high dynamic range + * that can be displayed, in terms of the SDR white point. When HDR is not + * enabled, this will be 1.0. This property can change dynamically when + * SDL_EVENT_WINDOW_HDR_STATE_CHANGED is sent. + * + * With the direct3d renderer: + * + * - `SDL_PROP_RENDERER_D3D9_DEVICE_POINTER`: the IDirect3DDevice9 associated + * with the renderer + * + * With the direct3d11 renderer: + * + * - `SDL_PROP_RENDERER_D3D11_DEVICE_POINTER`: the ID3D11Device associated + * with the renderer + * - `SDL_PROP_RENDERER_D3D11_SWAPCHAIN_POINTER`: the IDXGISwapChain1 + * associated with the renderer. This may change when the window is resized. + * + * With the direct3d12 renderer: + * + * - `SDL_PROP_RENDERER_D3D12_DEVICE_POINTER`: the ID3D12Device associated + * with the renderer + * - `SDL_PROP_RENDERER_D3D12_SWAPCHAIN_POINTER`: the IDXGISwapChain4 + * associated with the renderer. + * - `SDL_PROP_RENDERER_D3D12_COMMAND_QUEUE_POINTER`: the ID3D12CommandQueue + * associated with the renderer + * + * With the vulkan renderer: + * + * - `SDL_PROP_RENDERER_VULKAN_INSTANCE_POINTER`: the VkInstance associated + * with the renderer + * - `SDL_PROP_RENDERER_VULKAN_SURFACE_NUMBER`: the VkSurfaceKHR associated + * with the renderer + * - `SDL_PROP_RENDERER_VULKAN_PHYSICAL_DEVICE_POINTER`: the VkPhysicalDevice + * associated with the renderer + * - `SDL_PROP_RENDERER_VULKAN_DEVICE_POINTER`: the VkDevice associated with + * the renderer + * - `SDL_PROP_RENDERER_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER`: the queue + * family index used for rendering + * - `SDL_PROP_RENDERER_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER`: the queue + * family index used for presentation + * - `SDL_PROP_RENDERER_VULKAN_SWAPCHAIN_IMAGE_COUNT_NUMBER`: the number of + * swapchain images, or potential frames in flight, used by the Vulkan + * renderer + * + * With the gpu renderer: + * + * - `SDL_PROP_RENDERER_GPU_DEVICE_POINTER`: the SDL_GPUDevice associated with + * the renderer + * + * \param renderer the rendering context. + * \returns a valid property ID on success or 0 on failure; call + * SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetRendererProperties(SDL_Renderer *renderer); + +#define SDL_PROP_RENDERER_NAME_STRING "SDL.renderer.name" +#define SDL_PROP_RENDERER_WINDOW_POINTER "SDL.renderer.window" +#define SDL_PROP_RENDERER_SURFACE_POINTER "SDL.renderer.surface" +#define SDL_PROP_RENDERER_VSYNC_NUMBER "SDL.renderer.vsync" +#define SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER "SDL.renderer.max_texture_size" +#define SDL_PROP_RENDERER_TEXTURE_FORMATS_POINTER "SDL.renderer.texture_formats" +#define SDL_PROP_RENDERER_TEXTURE_WRAPPING_BOOLEAN "SDL.renderer.texture_wrapping" +#define SDL_PROP_RENDERER_OUTPUT_COLORSPACE_NUMBER "SDL.renderer.output_colorspace" +#define SDL_PROP_RENDERER_HDR_ENABLED_BOOLEAN "SDL.renderer.HDR_enabled" +#define SDL_PROP_RENDERER_SDR_WHITE_POINT_FLOAT "SDL.renderer.SDR_white_point" +#define SDL_PROP_RENDERER_HDR_HEADROOM_FLOAT "SDL.renderer.HDR_headroom" +#define SDL_PROP_RENDERER_D3D9_DEVICE_POINTER "SDL.renderer.d3d9.device" +#define SDL_PROP_RENDERER_D3D11_DEVICE_POINTER "SDL.renderer.d3d11.device" +#define SDL_PROP_RENDERER_D3D11_SWAPCHAIN_POINTER "SDL.renderer.d3d11.swap_chain" +#define SDL_PROP_RENDERER_D3D12_DEVICE_POINTER "SDL.renderer.d3d12.device" +#define SDL_PROP_RENDERER_D3D12_SWAPCHAIN_POINTER "SDL.renderer.d3d12.swap_chain" +#define SDL_PROP_RENDERER_D3D12_COMMAND_QUEUE_POINTER "SDL.renderer.d3d12.command_queue" +#define SDL_PROP_RENDERER_VULKAN_INSTANCE_POINTER "SDL.renderer.vulkan.instance" +#define SDL_PROP_RENDERER_VULKAN_SURFACE_NUMBER "SDL.renderer.vulkan.surface" +#define SDL_PROP_RENDERER_VULKAN_PHYSICAL_DEVICE_POINTER "SDL.renderer.vulkan.physical_device" +#define SDL_PROP_RENDERER_VULKAN_DEVICE_POINTER "SDL.renderer.vulkan.device" +#define SDL_PROP_RENDERER_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER "SDL.renderer.vulkan.graphics_queue_family_index" +#define SDL_PROP_RENDERER_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER "SDL.renderer.vulkan.present_queue_family_index" +#define SDL_PROP_RENDERER_VULKAN_SWAPCHAIN_IMAGE_COUNT_NUMBER "SDL.renderer.vulkan.swapchain_image_count" +#define SDL_PROP_RENDERER_GPU_DEVICE_POINTER "SDL.renderer.gpu.device" + +/** + * Get the output size in pixels of a rendering context. + * + * This returns the true output size in pixels, ignoring any render targets or + * logical size and presentation. + * + * For the output size of the current rendering target, with logical size + * adjustments, use SDL_GetCurrentRenderOutputSize() instead. + * + * \param renderer the rendering context. + * \param w a pointer filled in with the width in pixels. + * \param h a pointer filled in with the height in pixels. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetCurrentRenderOutputSize + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderOutputSize(SDL_Renderer *renderer, int *w, int *h); + +/** + * Get the current output size in pixels of a rendering context. + * + * If a rendering target is active, this will return the size of the rendering + * target in pixels, otherwise return the value of SDL_GetRenderOutputSize(). + * + * Rendering target or not, the output will be adjusted by the current logical + * presentation state, dictated by SDL_SetRenderLogicalPresentation(). + * + * \param renderer the rendering context. + * \param w a pointer filled in with the current width. + * \param h a pointer filled in with the current height. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetRenderOutputSize + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetCurrentRenderOutputSize(SDL_Renderer *renderer, int *w, int *h); + +/** + * Create a texture for a rendering context. + * + * The contents of a texture when first created are not defined. + * + * \param renderer the rendering context. + * \param format one of the enumerated values in SDL_PixelFormat. + * \param access one of the enumerated values in SDL_TextureAccess. + * \param w the width of the texture in pixels. + * \param h the height of the texture in pixels. + * \returns the created texture or NULL on failure; call SDL_GetError() for + * more information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateTextureFromSurface + * \sa SDL_CreateTextureWithProperties + * \sa SDL_DestroyTexture + * \sa SDL_GetTextureSize + * \sa SDL_UpdateTexture + */ +extern SDL_DECLSPEC SDL_Texture * SDLCALL SDL_CreateTexture(SDL_Renderer *renderer, SDL_PixelFormat format, SDL_TextureAccess access, int w, int h); + +/** + * Create a texture from an existing surface. + * + * The surface is not modified or freed by this function. + * + * The SDL_TextureAccess hint for the created texture is + * `SDL_TEXTUREACCESS_STATIC`. + * + * The pixel format of the created texture may be different from the pixel + * format of the surface, and can be queried using the + * SDL_PROP_TEXTURE_FORMAT_NUMBER property. + * + * \param renderer the rendering context. + * \param surface the SDL_Surface structure containing pixel data used to fill + * the texture. + * \returns the created texture or NULL on failure; call SDL_GetError() for + * more information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateTexture + * \sa SDL_CreateTextureWithProperties + * \sa SDL_DestroyTexture + */ +extern SDL_DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *surface); + +/** + * Create a texture for a rendering context with the specified properties. + * + * These are the supported properties: + * + * - `SDL_PROP_TEXTURE_CREATE_COLORSPACE_NUMBER`: an SDL_Colorspace value + * describing the texture colorspace, defaults to SDL_COLORSPACE_SRGB_LINEAR + * for floating point textures, SDL_COLORSPACE_HDR10 for 10-bit textures, + * SDL_COLORSPACE_SRGB for other RGB textures and SDL_COLORSPACE_JPEG for + * YUV textures. + * - `SDL_PROP_TEXTURE_CREATE_FORMAT_NUMBER`: one of the enumerated values in + * SDL_PixelFormat, defaults to the best RGBA format for the renderer + * - `SDL_PROP_TEXTURE_CREATE_ACCESS_NUMBER`: one of the enumerated values in + * SDL_TextureAccess, defaults to SDL_TEXTUREACCESS_STATIC + * - `SDL_PROP_TEXTURE_CREATE_WIDTH_NUMBER`: the width of the texture in + * pixels, required + * - `SDL_PROP_TEXTURE_CREATE_HEIGHT_NUMBER`: the height of the texture in + * pixels, required + * - `SDL_PROP_TEXTURE_CREATE_PALETTE_POINTER`: an SDL_Palette to use with + * palettized texture formats. This can be set later with + * SDL_SetTexturePalette() + * - `SDL_PROP_TEXTURE_CREATE_SDR_WHITE_POINT_FLOAT`: for HDR10 and floating + * point textures, this defines the value of 100% diffuse white, with higher + * values being displayed in the High Dynamic Range headroom. This defaults + * to 100 for HDR10 textures and 1.0 for floating point textures. + * - `SDL_PROP_TEXTURE_CREATE_HDR_HEADROOM_FLOAT`: for HDR10 and floating + * point textures, this defines the maximum dynamic range used by the + * content, in terms of the SDR white point. This would be equivalent to + * maxCLL / SDL_PROP_TEXTURE_CREATE_SDR_WHITE_POINT_FLOAT for HDR10 content. + * If this is defined, any values outside the range supported by the display + * will be scaled into the available HDR headroom, otherwise they are + * clipped. + * + * With the direct3d11 renderer: + * + * - `SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_POINTER`: the ID3D11Texture2D + * associated with the texture, if you want to wrap an existing texture. + * - `SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_U_POINTER`: the ID3D11Texture2D + * associated with the U plane of a YUV texture, if you want to wrap an + * existing texture. + * - `SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_V_POINTER`: the ID3D11Texture2D + * associated with the V plane of a YUV texture, if you want to wrap an + * existing texture. + * + * With the direct3d12 renderer: + * + * - `SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_POINTER`: the ID3D12Resource + * associated with the texture, if you want to wrap an existing texture. + * - `SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_U_POINTER`: the ID3D12Resource + * associated with the U plane of a YUV texture, if you want to wrap an + * existing texture. + * - `SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_V_POINTER`: the ID3D12Resource + * associated with the V plane of a YUV texture, if you want to wrap an + * existing texture. + * + * With the metal renderer: + * + * - `SDL_PROP_TEXTURE_CREATE_METAL_PIXELBUFFER_POINTER`: the CVPixelBufferRef + * associated with the texture, if you want to create a texture from an + * existing pixel buffer. + * + * With the opengl renderer: + * + * - `SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_NUMBER`: the GLuint texture + * associated with the texture, if you want to wrap an existing texture. + * - `SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_UV_NUMBER`: the GLuint texture + * associated with the UV plane of an NV12 texture, if you want to wrap an + * existing texture. + * - `SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_U_NUMBER`: the GLuint texture + * associated with the U plane of a YUV texture, if you want to wrap an + * existing texture. + * - `SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_V_NUMBER`: the GLuint texture + * associated with the V plane of a YUV texture, if you want to wrap an + * existing texture. + * + * With the opengles2 renderer: + * + * - `SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_NUMBER`: the GLuint texture + * associated with the texture, if you want to wrap an existing texture. + * - `SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_NUMBER`: the GLuint texture + * associated with the texture, if you want to wrap an existing texture. + * - `SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_UV_NUMBER`: the GLuint texture + * associated with the UV plane of an NV12 texture, if you want to wrap an + * existing texture. + * - `SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_U_NUMBER`: the GLuint texture + * associated with the U plane of a YUV texture, if you want to wrap an + * existing texture. + * - `SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_V_NUMBER`: the GLuint texture + * associated with the V plane of a YUV texture, if you want to wrap an + * existing texture. + * + * With the vulkan renderer: + * + * - `SDL_PROP_TEXTURE_CREATE_VULKAN_TEXTURE_NUMBER`: the VkImage associated + * with the texture, if you want to wrap an existing texture. + * - `SDL_PROP_TEXTURE_CREATE_VULKAN_LAYOUT_NUMBER`: the VkImageLayout for the + * VkImage, defaults to VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL. + * + * With the GPU renderer: + * + * - `SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_POINTER`: the SDL_GPUTexture + * associated with the texture, if you want to wrap an existing texture. + * - `SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_UV_NUMBER`: the SDL_GPUTexture + * associated with the UV plane of an NV12 texture, if you want to wrap an + * existing texture. + * - `SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_U_NUMBER`: the SDL_GPUTexture + * associated with the U plane of a YUV texture, if you want to wrap an + * existing texture. + * - `SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_V_NUMBER`: the SDL_GPUTexture + * associated with the V plane of a YUV texture, if you want to wrap an + * existing texture. + * + * \param renderer the rendering context. + * \param props the properties to use. + * \returns the created texture or NULL on failure; call SDL_GetError() for + * more information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateProperties + * \sa SDL_CreateTexture + * \sa SDL_CreateTextureFromSurface + * \sa SDL_DestroyTexture + * \sa SDL_GetTextureSize + * \sa SDL_UpdateTexture + */ +extern SDL_DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureWithProperties(SDL_Renderer *renderer, SDL_PropertiesID props); + +#define SDL_PROP_TEXTURE_CREATE_COLORSPACE_NUMBER "SDL.texture.create.colorspace" +#define SDL_PROP_TEXTURE_CREATE_FORMAT_NUMBER "SDL.texture.create.format" +#define SDL_PROP_TEXTURE_CREATE_ACCESS_NUMBER "SDL.texture.create.access" +#define SDL_PROP_TEXTURE_CREATE_WIDTH_NUMBER "SDL.texture.create.width" +#define SDL_PROP_TEXTURE_CREATE_HEIGHT_NUMBER "SDL.texture.create.height" +#define SDL_PROP_TEXTURE_CREATE_PALETTE_POINTER "SDL.texture.create.palette" +#define SDL_PROP_TEXTURE_CREATE_SDR_WHITE_POINT_FLOAT "SDL.texture.create.SDR_white_point" +#define SDL_PROP_TEXTURE_CREATE_HDR_HEADROOM_FLOAT "SDL.texture.create.HDR_headroom" +#define SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_POINTER "SDL.texture.create.d3d11.texture" +#define SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_U_POINTER "SDL.texture.create.d3d11.texture_u" +#define SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_V_POINTER "SDL.texture.create.d3d11.texture_v" +#define SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_POINTER "SDL.texture.create.d3d12.texture" +#define SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_U_POINTER "SDL.texture.create.d3d12.texture_u" +#define SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_V_POINTER "SDL.texture.create.d3d12.texture_v" +#define SDL_PROP_TEXTURE_CREATE_METAL_PIXELBUFFER_POINTER "SDL.texture.create.metal.pixelbuffer" +#define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_NUMBER "SDL.texture.create.opengl.texture" +#define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_UV_NUMBER "SDL.texture.create.opengl.texture_uv" +#define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_U_NUMBER "SDL.texture.create.opengl.texture_u" +#define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_V_NUMBER "SDL.texture.create.opengl.texture_v" +#define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_NUMBER "SDL.texture.create.opengles2.texture" +#define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_UV_NUMBER "SDL.texture.create.opengles2.texture_uv" +#define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_U_NUMBER "SDL.texture.create.opengles2.texture_u" +#define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_V_NUMBER "SDL.texture.create.opengles2.texture_v" +#define SDL_PROP_TEXTURE_CREATE_VULKAN_TEXTURE_NUMBER "SDL.texture.create.vulkan.texture" +#define SDL_PROP_TEXTURE_CREATE_VULKAN_LAYOUT_NUMBER "SDL.texture.create.vulkan.layout" +#define SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_POINTER "SDL.texture.create.gpu.texture" +#define SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_UV_POINTER "SDL.texture.create.gpu.texture_uv" +#define SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_U_POINTER "SDL.texture.create.gpu.texture_u" +#define SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_V_POINTER "SDL.texture.create.gpu.texture_v" + +/** + * Get the properties associated with a texture. + * + * The following read-only properties are provided by SDL: + * + * - `SDL_PROP_TEXTURE_COLORSPACE_NUMBER`: an SDL_Colorspace value describing + * the texture colorspace. + * - `SDL_PROP_TEXTURE_FORMAT_NUMBER`: one of the enumerated values in + * SDL_PixelFormat. + * - `SDL_PROP_TEXTURE_ACCESS_NUMBER`: one of the enumerated values in + * SDL_TextureAccess. + * - `SDL_PROP_TEXTURE_WIDTH_NUMBER`: the width of the texture in pixels. + * - `SDL_PROP_TEXTURE_HEIGHT_NUMBER`: the height of the texture in pixels. + * - `SDL_PROP_TEXTURE_SDR_WHITE_POINT_FLOAT`: for HDR10 and floating point + * textures, this defines the value of 100% diffuse white, with higher + * values being displayed in the High Dynamic Range headroom. This defaults + * to 100 for HDR10 textures and 1.0 for other textures. + * - `SDL_PROP_TEXTURE_HDR_HEADROOM_FLOAT`: for HDR10 and floating point + * textures, this defines the maximum dynamic range used by the content, in + * terms of the SDR white point. If this is defined, any values outside the + * range supported by the display will be scaled into the available HDR + * headroom, otherwise they are clipped. This defaults to 1.0 for SDR + * textures, 4.0 for HDR10 textures, and no default for floating point + * textures. + * + * With the direct3d11 renderer: + * + * - `SDL_PROP_TEXTURE_D3D11_TEXTURE_POINTER`: the ID3D11Texture2D associated + * with the texture + * - `SDL_PROP_TEXTURE_D3D11_TEXTURE_U_POINTER`: the ID3D11Texture2D + * associated with the U plane of a YUV texture + * - `SDL_PROP_TEXTURE_D3D11_TEXTURE_V_POINTER`: the ID3D11Texture2D + * associated with the V plane of a YUV texture + * + * With the direct3d12 renderer: + * + * - `SDL_PROP_TEXTURE_D3D12_TEXTURE_POINTER`: the ID3D12Resource associated + * with the texture + * - `SDL_PROP_TEXTURE_D3D12_TEXTURE_U_POINTER`: the ID3D12Resource associated + * with the U plane of a YUV texture + * - `SDL_PROP_TEXTURE_D3D12_TEXTURE_V_POINTER`: the ID3D12Resource associated + * with the V plane of a YUV texture + * + * With the vulkan renderer: + * + * - `SDL_PROP_TEXTURE_VULKAN_TEXTURE_NUMBER`: the VkImage associated with the + * texture + * + * With the opengl renderer: + * + * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_NUMBER`: the GLuint texture associated + * with the texture + * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_UV_NUMBER`: the GLuint texture + * associated with the UV plane of an NV12 texture + * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_U_NUMBER`: the GLuint texture associated + * with the U plane of a YUV texture + * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_V_NUMBER`: the GLuint texture associated + * with the V plane of a YUV texture + * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_TARGET_NUMBER`: the GLenum for the + * texture target (`GL_TEXTURE_2D`, `GL_TEXTURE_RECTANGLE_ARB`, etc) + * - `SDL_PROP_TEXTURE_OPENGL_TEX_W_FLOAT`: the texture coordinate width of + * the texture (0.0 - 1.0) + * - `SDL_PROP_TEXTURE_OPENGL_TEX_H_FLOAT`: the texture coordinate height of + * the texture (0.0 - 1.0) + * + * With the opengles2 renderer: + * + * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_NUMBER`: the GLuint texture + * associated with the texture + * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_UV_NUMBER`: the GLuint texture + * associated with the UV plane of an NV12 texture + * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_U_NUMBER`: the GLuint texture + * associated with the U plane of a YUV texture + * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_V_NUMBER`: the GLuint texture + * associated with the V plane of a YUV texture + * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_TARGET_NUMBER`: the GLenum for the + * texture target (`GL_TEXTURE_2D`, `GL_TEXTURE_EXTERNAL_OES`, etc) + * + * With the gpu renderer: + * + * - `SDL_PROP_TEXTURE_GPU_TEXTURE_POINTER`: the SDL_GPUTexture associated + * with the texture + * - `SDL_PROP_TEXTURE_GPU_TEXTURE_UV_POINTER`: the SDL_GPUTexture associated + * with the UV plane of an NV12 texture + * - `SDL_PROP_TEXTURE_GPU_TEXTURE_U_POINTER`: the SDL_GPUTexture associated + * with the U plane of a YUV texture + * - `SDL_PROP_TEXTURE_GPU_TEXTURE_V_POINTER`: the SDL_GPUTexture associated + * with the V plane of a YUV texture + * + * \param texture the texture to query. + * \returns a valid property ID on success or 0 on failure; call + * SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetTextureProperties(SDL_Texture *texture); + +#define SDL_PROP_TEXTURE_COLORSPACE_NUMBER "SDL.texture.colorspace" +#define SDL_PROP_TEXTURE_FORMAT_NUMBER "SDL.texture.format" +#define SDL_PROP_TEXTURE_ACCESS_NUMBER "SDL.texture.access" +#define SDL_PROP_TEXTURE_WIDTH_NUMBER "SDL.texture.width" +#define SDL_PROP_TEXTURE_HEIGHT_NUMBER "SDL.texture.height" +#define SDL_PROP_TEXTURE_SDR_WHITE_POINT_FLOAT "SDL.texture.SDR_white_point" +#define SDL_PROP_TEXTURE_HDR_HEADROOM_FLOAT "SDL.texture.HDR_headroom" +#define SDL_PROP_TEXTURE_D3D11_TEXTURE_POINTER "SDL.texture.d3d11.texture" +#define SDL_PROP_TEXTURE_D3D11_TEXTURE_U_POINTER "SDL.texture.d3d11.texture_u" +#define SDL_PROP_TEXTURE_D3D11_TEXTURE_V_POINTER "SDL.texture.d3d11.texture_v" +#define SDL_PROP_TEXTURE_D3D12_TEXTURE_POINTER "SDL.texture.d3d12.texture" +#define SDL_PROP_TEXTURE_D3D12_TEXTURE_U_POINTER "SDL.texture.d3d12.texture_u" +#define SDL_PROP_TEXTURE_D3D12_TEXTURE_V_POINTER "SDL.texture.d3d12.texture_v" +#define SDL_PROP_TEXTURE_OPENGL_TEXTURE_NUMBER "SDL.texture.opengl.texture" +#define SDL_PROP_TEXTURE_OPENGL_TEXTURE_UV_NUMBER "SDL.texture.opengl.texture_uv" +#define SDL_PROP_TEXTURE_OPENGL_TEXTURE_U_NUMBER "SDL.texture.opengl.texture_u" +#define SDL_PROP_TEXTURE_OPENGL_TEXTURE_V_NUMBER "SDL.texture.opengl.texture_v" +#define SDL_PROP_TEXTURE_OPENGL_TEXTURE_TARGET_NUMBER "SDL.texture.opengl.target" +#define SDL_PROP_TEXTURE_OPENGL_TEX_W_FLOAT "SDL.texture.opengl.tex_w" +#define SDL_PROP_TEXTURE_OPENGL_TEX_H_FLOAT "SDL.texture.opengl.tex_h" +#define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_NUMBER "SDL.texture.opengles2.texture" +#define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_UV_NUMBER "SDL.texture.opengles2.texture_uv" +#define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_U_NUMBER "SDL.texture.opengles2.texture_u" +#define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_V_NUMBER "SDL.texture.opengles2.texture_v" +#define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_TARGET_NUMBER "SDL.texture.opengles2.target" +#define SDL_PROP_TEXTURE_VULKAN_TEXTURE_NUMBER "SDL.texture.vulkan.texture" +#define SDL_PROP_TEXTURE_GPU_TEXTURE_POINTER "SDL.texture.gpu.texture" +#define SDL_PROP_TEXTURE_GPU_TEXTURE_UV_POINTER "SDL.texture.gpu.texture_uv" +#define SDL_PROP_TEXTURE_GPU_TEXTURE_U_POINTER "SDL.texture.gpu.texture_u" +#define SDL_PROP_TEXTURE_GPU_TEXTURE_V_POINTER "SDL.texture.gpu.texture_v" + +/** + * Get the renderer that created an SDL_Texture. + * + * \param texture the texture to query. + * \returns a pointer to the SDL_Renderer that created the texture, or NULL on + * failure; call SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_GetRendererFromTexture(SDL_Texture *texture); + +/** + * Get the size of a texture, as floating point values. + * + * \param texture the texture to query. + * \param w a pointer filled in with the width of the texture in pixels. This + * argument can be NULL if you don't need this information. + * \param h a pointer filled in with the height of the texture in pixels. This + * argument can be NULL if you don't need this information. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureSize(SDL_Texture *texture, float *w, float *h); + +/** + * Set the palette used by a texture. + * + * Setting the palette keeps an internal reference to the palette, which can + * be safely destroyed afterwards. + * + * A single palette can be shared with many textures. + * + * \param texture the texture to update. + * \param palette the SDL_Palette structure to use. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.4.0. + * + * \sa SDL_CreatePalette + * \sa SDL_GetTexturePalette + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetTexturePalette(SDL_Texture *texture, SDL_Palette *palette); + +/** + * Get the palette used by a texture. + * + * \param texture the texture to query. + * \returns a pointer to the palette used by the texture, or NULL if there is + * no palette used. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.4.0. + * + * \sa SDL_SetTexturePalette + */ +extern SDL_DECLSPEC SDL_Palette * SDLCALL SDL_GetTexturePalette(SDL_Texture *texture); + +/** + * Set an additional color value multiplied into render copy operations. + * + * When this texture is rendered, during the copy operation each source color + * channel is modulated by the appropriate color value according to the + * following formula: + * + * `srcC = srcC * (color / 255)` + * + * Color modulation is not always supported by the renderer; it will return + * false if color modulation is not supported. + * + * \param texture the texture to update. + * \param r the red color value multiplied into copy operations. + * \param g the green color value multiplied into copy operations. + * \param b the blue color value multiplied into copy operations. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetTextureColorMod + * \sa SDL_SetTextureAlphaMod + * \sa SDL_SetTextureColorModFloat + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureColorMod(SDL_Texture *texture, Uint8 r, Uint8 g, Uint8 b); + + +/** + * Set an additional color value multiplied into render copy operations. + * + * When this texture is rendered, during the copy operation each source color + * channel is modulated by the appropriate color value according to the + * following formula: + * + * `srcC = srcC * color` + * + * Color modulation is not always supported by the renderer; it will return + * false if color modulation is not supported. + * + * \param texture the texture to update. + * \param r the red color value multiplied into copy operations. + * \param g the green color value multiplied into copy operations. + * \param b the blue color value multiplied into copy operations. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetTextureColorModFloat + * \sa SDL_SetTextureAlphaModFloat + * \sa SDL_SetTextureColorMod + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureColorModFloat(SDL_Texture *texture, float r, float g, float b); + + +/** + * Get the additional color value multiplied into render copy operations. + * + * \param texture the texture to query. + * \param r a pointer filled in with the current red color value. + * \param g a pointer filled in with the current green color value. + * \param b a pointer filled in with the current blue color value. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetTextureAlphaMod + * \sa SDL_GetTextureColorModFloat + * \sa SDL_SetTextureColorMod + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureColorMod(SDL_Texture *texture, Uint8 *r, Uint8 *g, Uint8 *b); + +/** + * Get the additional color value multiplied into render copy operations. + * + * \param texture the texture to query. + * \param r a pointer filled in with the current red color value. + * \param g a pointer filled in with the current green color value. + * \param b a pointer filled in with the current blue color value. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetTextureAlphaModFloat + * \sa SDL_GetTextureColorMod + * \sa SDL_SetTextureColorModFloat + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureColorModFloat(SDL_Texture *texture, float *r, float *g, float *b); + +/** + * Set an additional alpha value multiplied into render copy operations. + * + * When this texture is rendered, during the copy operation the source alpha + * value is modulated by this alpha value according to the following formula: + * + * `srcA = srcA * (alpha / 255)` + * + * Alpha modulation is not always supported by the renderer; it will return + * false if alpha modulation is not supported. + * + * \param texture the texture to update. + * \param alpha the source alpha value multiplied into copy operations. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetTextureAlphaMod + * \sa SDL_SetTextureAlphaModFloat + * \sa SDL_SetTextureColorMod + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureAlphaMod(SDL_Texture *texture, Uint8 alpha); + +/** + * Set an additional alpha value multiplied into render copy operations. + * + * When this texture is rendered, during the copy operation the source alpha + * value is modulated by this alpha value according to the following formula: + * + * `srcA = srcA * alpha` + * + * Alpha modulation is not always supported by the renderer; it will return + * false if alpha modulation is not supported. + * + * \param texture the texture to update. + * \param alpha the source alpha value multiplied into copy operations. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetTextureAlphaModFloat + * \sa SDL_SetTextureAlphaMod + * \sa SDL_SetTextureColorModFloat + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureAlphaModFloat(SDL_Texture *texture, float alpha); + +/** + * Get the additional alpha value multiplied into render copy operations. + * + * \param texture the texture to query. + * \param alpha a pointer filled in with the current alpha value. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetTextureAlphaModFloat + * \sa SDL_GetTextureColorMod + * \sa SDL_SetTextureAlphaMod + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureAlphaMod(SDL_Texture *texture, Uint8 *alpha); + +/** + * Get the additional alpha value multiplied into render copy operations. + * + * \param texture the texture to query. + * \param alpha a pointer filled in with the current alpha value. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetTextureAlphaMod + * \sa SDL_GetTextureColorModFloat + * \sa SDL_SetTextureAlphaModFloat + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureAlphaModFloat(SDL_Texture *texture, float *alpha); + +/** + * Set the blend mode for a texture, used by SDL_RenderTexture(). + * + * If the blend mode is not supported, the closest supported mode is chosen + * and this function returns false. + * + * \param texture the texture to update. + * \param blendMode the SDL_BlendMode to use for texture blending. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetTextureBlendMode + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureBlendMode(SDL_Texture *texture, SDL_BlendMode blendMode); + +/** + * Get the blend mode used for texture copy operations. + * + * \param texture the texture to query. + * \param blendMode a pointer filled in with the current SDL_BlendMode. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetTextureBlendMode + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureBlendMode(SDL_Texture *texture, SDL_BlendMode *blendMode); + +/** + * Set the scale mode used for texture scale operations. + * + * The default texture scale mode is SDL_SCALEMODE_LINEAR. + * + * If the scale mode is not supported, the closest supported mode is chosen. + * + * \param texture the texture to update. + * \param scaleMode the SDL_ScaleMode to use for texture scaling. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetTextureScaleMode + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureScaleMode(SDL_Texture *texture, SDL_ScaleMode scaleMode); + +/** + * Get the scale mode used for texture scale operations. + * + * \param texture the texture to query. + * \param scaleMode a pointer filled in with the current scale mode. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetTextureScaleMode + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureScaleMode(SDL_Texture *texture, SDL_ScaleMode *scaleMode); + +/** + * Update the given texture rectangle with new pixel data. + * + * The pixel data must be in the pixel format of the texture, which can be + * queried using the SDL_PROP_TEXTURE_FORMAT_NUMBER property. + * + * This is a fairly slow function, intended for use with static textures that + * do not change often. + * + * If the texture is intended to be updated often, it is preferred to create + * the texture as streaming and use the locking functions referenced below. + * While this function will work with streaming textures, for optimization + * reasons you may not get the pixels back if you lock the texture afterward. + * + * \param texture the texture to update. + * \param rect an SDL_Rect structure representing the area to update, or NULL + * to update the entire texture. + * \param pixels the raw pixel data in the format of the texture. + * \param pitch the number of bytes in a row of pixel data, including padding + * between lines. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_LockTexture + * \sa SDL_UnlockTexture + * \sa SDL_UpdateNVTexture + * \sa SDL_UpdateYUVTexture + */ +extern SDL_DECLSPEC bool SDLCALL SDL_UpdateTexture(SDL_Texture *texture, const SDL_Rect *rect, const void *pixels, int pitch); + +/** + * Update a rectangle within a planar YV12 or IYUV texture with new pixel + * data. + * + * You can use SDL_UpdateTexture() as long as your pixel data is a contiguous + * block of Y and U/V planes in the proper order, but this function is + * available if your pixel data is not contiguous. + * + * \param texture the texture to update. + * \param rect a pointer to the rectangle of pixels to update, or NULL to + * update the entire texture. + * \param Yplane the raw pixel data for the Y plane. + * \param Ypitch the number of bytes between rows of pixel data for the Y + * plane. + * \param Uplane the raw pixel data for the U plane. + * \param Upitch the number of bytes between rows of pixel data for the U + * plane. + * \param Vplane the raw pixel data for the V plane. + * \param Vpitch the number of bytes between rows of pixel data for the V + * plane. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_UpdateNVTexture + * \sa SDL_UpdateTexture + */ +extern SDL_DECLSPEC bool SDLCALL SDL_UpdateYUVTexture(SDL_Texture *texture, + const SDL_Rect *rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch); + +/** + * Update a rectangle within a planar NV12 or NV21 texture with new pixels. + * + * You can use SDL_UpdateTexture() as long as your pixel data is a contiguous + * block of NV12/21 planes in the proper order, but this function is available + * if your pixel data is not contiguous. + * + * \param texture the texture to update. + * \param rect a pointer to the rectangle of pixels to update, or NULL to + * update the entire texture. + * \param Yplane the raw pixel data for the Y plane. + * \param Ypitch the number of bytes between rows of pixel data for the Y + * plane. + * \param UVplane the raw pixel data for the UV plane. + * \param UVpitch the number of bytes between rows of pixel data for the UV + * plane. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_UpdateTexture + * \sa SDL_UpdateYUVTexture + */ +extern SDL_DECLSPEC bool SDLCALL SDL_UpdateNVTexture(SDL_Texture *texture, + const SDL_Rect *rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *UVplane, int UVpitch); + +/** + * Lock a portion of the texture for **write-only** pixel access. + * + * As an optimization, the pixels made available for editing don't necessarily + * contain the old texture data. This is a write-only operation, and if you + * need to keep a copy of the texture data you should do that at the + * application level. + * + * You must use SDL_UnlockTexture() to unlock the pixels and apply any + * changes. + * + * \param texture the texture to lock for access, which was created with + * `SDL_TEXTUREACCESS_STREAMING`. + * \param rect an SDL_Rect structure representing the area to lock for access; + * NULL to lock the entire texture. + * \param pixels this is filled in with a pointer to the locked pixels, + * appropriately offset by the locked area. + * \param pitch this is filled in with the pitch of the locked pixels; the + * pitch is the length of one row in bytes. + * \returns true on success or false if the texture is not valid or was not + * created with `SDL_TEXTUREACCESS_STREAMING`; call SDL_GetError() + * for more information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_LockTextureToSurface + * \sa SDL_UnlockTexture + */ +extern SDL_DECLSPEC bool SDLCALL SDL_LockTexture(SDL_Texture *texture, + const SDL_Rect *rect, + void **pixels, int *pitch); + +/** + * Lock a portion of the texture for **write-only** pixel access, and expose + * it as a SDL surface. + * + * Besides providing an SDL_Surface instead of raw pixel data, this function + * operates like SDL_LockTexture. + * + * As an optimization, the pixels made available for editing don't necessarily + * contain the old texture data. This is a write-only operation, and if you + * need to keep a copy of the texture data you should do that at the + * application level. + * + * You must use SDL_UnlockTexture() to unlock the pixels and apply any + * changes. + * + * The returned surface is freed internally after calling SDL_UnlockTexture() + * or SDL_DestroyTexture(). The caller should not free it. + * + * \param texture the texture to lock for access, which must be created with + * `SDL_TEXTUREACCESS_STREAMING`. + * \param rect a pointer to the rectangle to lock for access. If the rect is + * NULL, the entire texture will be locked. + * \param surface a pointer to an SDL surface of size **rect**. Don't assume + * any specific pixel content. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_LockTexture + * \sa SDL_UnlockTexture + */ +extern SDL_DECLSPEC bool SDLCALL SDL_LockTextureToSurface(SDL_Texture *texture, const SDL_Rect *rect, SDL_Surface **surface); + +/** + * Unlock a texture, uploading the changes to video memory, if needed. + * + * **Warning**: Please note that SDL_LockTexture() is intended to be + * write-only; it will not guarantee the previous contents of the texture will + * be provided. You must fully initialize any area of a texture that you lock + * before unlocking it, as the pixels might otherwise be uninitialized memory. + * + * Which is to say: locking and immediately unlocking a texture can result in + * corrupted textures, depending on the renderer in use. + * + * \param texture a texture locked by SDL_LockTexture(). + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_LockTexture + */ +extern SDL_DECLSPEC void SDLCALL SDL_UnlockTexture(SDL_Texture *texture); + +/** + * Set a texture as the current rendering target. + * + * The default render target is the window for which the renderer was created. + * To stop rendering to a texture and render to the window again, call this + * function with a NULL `texture`. + * + * Viewport, cliprect, scale, and logical presentation are unique to each + * render target. Get and set functions for these states apply to the current + * render target set by this function, and those states persist on each target + * when the current render target changes. + * + * \param renderer the rendering context. + * \param texture the targeted texture, which must be created with the + * `SDL_TEXTUREACCESS_TARGET` flag, or NULL to render to the + * window instead of a texture. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetRenderTarget + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture); + +/** + * Get the current render target. + * + * The default render target is the window for which the renderer was created, + * and is reported a NULL here. + * + * \param renderer the rendering context. + * \returns the current render target or NULL for the default render target. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetRenderTarget + */ +extern SDL_DECLSPEC SDL_Texture * SDLCALL SDL_GetRenderTarget(SDL_Renderer *renderer); + +/** + * Set a device-independent resolution and presentation mode for rendering. + * + * This function sets the width and height of the logical rendering output. + * The renderer will act as if the current render target is always the + * requested dimensions, scaling to the actual resolution as necessary. + * + * This can be useful for games that expect a fixed size, but would like to + * scale the output to whatever is available, regardless of how a user resizes + * a window, or if the display is high DPI. + * + * Logical presentation can be used with both render target textures and the + * renderer's window; the state is unique to each render target, and this + * function sets the state for the current render target. It might be useful + * to draw to a texture that matches the window dimensions with logical + * presentation enabled, and then draw that texture across the entire window + * with logical presentation disabled. Be careful not to render both with + * logical presentation enabled, however, as this could produce + * double-letterboxing, etc. + * + * You can disable logical coordinates by setting the mode to + * SDL_LOGICAL_PRESENTATION_DISABLED, and in that case you get the full pixel + * resolution of the render target; it is safe to toggle logical presentation + * during the rendering of a frame: perhaps most of the rendering is done to + * specific dimensions but to make fonts look sharp, the app turns off logical + * presentation while drawing text, for example. + * + * You can convert coordinates in an event into rendering coordinates using + * SDL_ConvertEventToRenderCoordinates(). + * + * \param renderer the rendering context. + * \param w the width of the logical resolution. + * \param h the height of the logical resolution. + * \param mode the presentation mode used. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_ConvertEventToRenderCoordinates + * \sa SDL_GetRenderLogicalPresentation + * \sa SDL_GetRenderLogicalPresentationRect + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderLogicalPresentation(SDL_Renderer *renderer, int w, int h, SDL_RendererLogicalPresentation mode); + +/** + * Get device independent resolution and presentation mode for rendering. + * + * This function gets the width and height of the logical rendering output, or + * 0 if a logical resolution is not enabled. + * + * Each render target has its own logical presentation state. This function + * gets the state for the current render target. + * + * \param renderer the rendering context. + * \param w an int filled with the logical presentation width. + * \param h an int filled with the logical presentation height. + * \param mode a variable filled with the logical presentation mode being + * used. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetRenderLogicalPresentation + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderLogicalPresentation(SDL_Renderer *renderer, int *w, int *h, SDL_RendererLogicalPresentation *mode); + +/** + * Get the final presentation rectangle for rendering. + * + * This function returns the calculated rectangle used for logical + * presentation, based on the presentation mode and output size. If logical + * presentation is disabled, it will fill the rectangle with the output size, + * in pixels. + * + * Each render target has its own logical presentation state. This function + * gets the rectangle for the current render target. + * + * \param renderer the rendering context. + * \param rect a pointer filled in with the final presentation rectangle, may + * be NULL. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetRenderLogicalPresentation + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderLogicalPresentationRect(SDL_Renderer *renderer, SDL_FRect *rect); + +/** + * Get a point in render coordinates when given a point in window coordinates. + * + * This takes into account several states: + * + * - The window dimensions. + * - The logical presentation settings (SDL_SetRenderLogicalPresentation) + * - The scale (SDL_SetRenderScale) + * - The viewport (SDL_SetRenderViewport) + * + * \param renderer the rendering context. + * \param window_x the x coordinate in window coordinates. + * \param window_y the y coordinate in window coordinates. + * \param x a pointer filled with the x coordinate in render coordinates. + * \param y a pointer filled with the y coordinate in render coordinates. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetRenderLogicalPresentation + * \sa SDL_SetRenderScale + */ +extern SDL_DECLSPEC bool SDLCALL SDL_RenderCoordinatesFromWindow(SDL_Renderer *renderer, float window_x, float window_y, float *x, float *y); + +/** + * Get a point in window coordinates when given a point in render coordinates. + * + * This takes into account several states: + * + * - The window dimensions. + * - The logical presentation settings (SDL_SetRenderLogicalPresentation) + * - The scale (SDL_SetRenderScale) + * - The viewport (SDL_SetRenderViewport) + * + * \param renderer the rendering context. + * \param x the x coordinate in render coordinates. + * \param y the y coordinate in render coordinates. + * \param window_x a pointer filled with the x coordinate in window + * coordinates. + * \param window_y a pointer filled with the y coordinate in window + * coordinates. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetRenderLogicalPresentation + * \sa SDL_SetRenderScale + * \sa SDL_SetRenderViewport + */ +extern SDL_DECLSPEC bool SDLCALL SDL_RenderCoordinatesToWindow(SDL_Renderer *renderer, float x, float y, float *window_x, float *window_y); + +/** + * Convert the coordinates in an event to render coordinates. + * + * This takes into account several states: + * + * - The window dimensions. + * - The logical presentation settings (SDL_SetRenderLogicalPresentation) + * - The scale (SDL_SetRenderScale) + * - The viewport (SDL_SetRenderViewport) + * + * Various event types are converted with this function: mouse, touch, pen, + * etc. + * + * Touch coordinates are converted from normalized coordinates in the window + * to non-normalized rendering coordinates. + * + * Relative mouse coordinates (xrel and yrel event fields) are _also_ + * converted. Applications that do not want these fields converted should use + * SDL_RenderCoordinatesFromWindow() on the specific event fields instead of + * converting the entire event structure. + * + * Once converted, coordinates may be outside the rendering area. + * + * \param renderer the rendering context. + * \param event the event to modify. + * \returns true if the event is converted or doesn't need conversion, or + * false on failure; call SDL_GetError() for more information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_RenderCoordinatesFromWindow + */ +extern SDL_DECLSPEC bool SDLCALL SDL_ConvertEventToRenderCoordinates(SDL_Renderer *renderer, SDL_Event *event); + +/** + * Set the drawing area for rendering on the current target. + * + * Drawing will clip to this area (separately from any clipping done with + * SDL_SetRenderClipRect), and the top left of the area will become coordinate + * (0, 0) for future drawing commands. + * + * The area's width and height must be >= 0. + * + * Each render target has its own viewport. This function sets the viewport + * for the current render target. + * + * \param renderer the rendering context. + * \param rect the SDL_Rect structure representing the drawing area, or NULL + * to set the viewport to the entire target. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetRenderViewport + * \sa SDL_RenderViewportSet + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderViewport(SDL_Renderer *renderer, const SDL_Rect *rect); + +/** + * Get the drawing area for the current target. + * + * Each render target has its own viewport. This function gets the viewport + * for the current render target. + * + * \param renderer the rendering context. + * \param rect an SDL_Rect structure filled in with the current drawing area. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_RenderViewportSet + * \sa SDL_SetRenderViewport + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderViewport(SDL_Renderer *renderer, SDL_Rect *rect); + +/** + * Return whether an explicit rectangle was set as the viewport. + * + * This is useful if you're saving and restoring the viewport and want to know + * whether you should restore a specific rectangle or NULL. + * + * Each render target has its own viewport. This function checks the viewport + * for the current render target. + * + * \param renderer the rendering context. + * \returns true if the viewport was set to a specific rectangle, or false if + * it was set to NULL (the entire target). + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetRenderViewport + * \sa SDL_SetRenderViewport + */ +extern SDL_DECLSPEC bool SDLCALL SDL_RenderViewportSet(SDL_Renderer *renderer); + +/** + * Get the safe area for rendering within the current viewport. + * + * Some devices have portions of the screen which are partially obscured or + * not interactive, possibly due to on-screen controls, curved edges, camera + * notches, TV overscan, etc. This function provides the area of the current + * viewport which is safe to have interactible content. You should continue + * rendering into the rest of the render target, but it should not contain + * visually important or interactible content. + * + * \param renderer the rendering context. + * \param rect a pointer filled in with the area that is safe for interactive + * content. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderSafeArea(SDL_Renderer *renderer, SDL_Rect *rect); + +/** + * Set the clip rectangle for rendering on the specified target. + * + * Each render target has its own clip rectangle. This function sets the + * cliprect for the current render target. + * + * \param renderer the rendering context. + * \param rect an SDL_Rect structure representing the clip area, relative to + * the viewport, or NULL to disable clipping. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetRenderClipRect + * \sa SDL_RenderClipEnabled + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderClipRect(SDL_Renderer *renderer, const SDL_Rect *rect); + +/** + * Get the clip rectangle for the current target. + * + * Each render target has its own clip rectangle. This function gets the + * cliprect for the current render target. + * + * \param renderer the rendering context. + * \param rect an SDL_Rect structure filled in with the current clipping area + * or an empty rectangle if clipping is disabled. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_RenderClipEnabled + * \sa SDL_SetRenderClipRect + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderClipRect(SDL_Renderer *renderer, SDL_Rect *rect); + +/** + * Get whether clipping is enabled on the given render target. + * + * Each render target has its own clip rectangle. This function checks the + * cliprect for the current render target. + * + * \param renderer the rendering context. + * \returns true if clipping is enabled or false if not; call SDL_GetError() + * for more information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetRenderClipRect + * \sa SDL_SetRenderClipRect + */ +extern SDL_DECLSPEC bool SDLCALL SDL_RenderClipEnabled(SDL_Renderer *renderer); + +/** + * Set the drawing scale for rendering on the current target. + * + * The drawing coordinates are scaled by the x/y scaling factors before they + * are used by the renderer. This allows resolution independent drawing with a + * single coordinate system. + * + * If this results in scaling or subpixel drawing by the rendering backend, it + * will be handled using the appropriate quality hints. For best results use + * integer scaling factors. + * + * Each render target has its own scale. This function sets the scale for the + * current render target. + * + * \param renderer the rendering context. + * \param scaleX the horizontal scaling factor. + * \param scaleY the vertical scaling factor. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetRenderScale + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderScale(SDL_Renderer *renderer, float scaleX, float scaleY); + +/** + * Get the drawing scale for the current target. + * + * Each render target has its own scale. This function gets the scale for the + * current render target. + * + * \param renderer the rendering context. + * \param scaleX a pointer filled in with the horizontal scaling factor. + * \param scaleY a pointer filled in with the vertical scaling factor. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetRenderScale + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderScale(SDL_Renderer *renderer, float *scaleX, float *scaleY); + +/** + * Set the color used for drawing operations. + * + * Set the color for drawing or filling rectangles, lines, and points, and for + * SDL_RenderClear(). + * + * \param renderer the rendering context. + * \param r the red value used to draw on the rendering target. + * \param g the green value used to draw on the rendering target. + * \param b the blue value used to draw on the rendering target. + * \param a the alpha value used to draw on the rendering target; usually + * `SDL_ALPHA_OPAQUE` (255). Use SDL_SetRenderDrawBlendMode to + * specify how the alpha channel is used. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetRenderDrawColor + * \sa SDL_SetRenderDrawColorFloat + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderDrawColor(SDL_Renderer *renderer, Uint8 r, Uint8 g, Uint8 b, Uint8 a); + +/** + * Set the color used for drawing operations (Rect, Line and Clear). + * + * Set the color for drawing or filling rectangles, lines, and points, and for + * SDL_RenderClear(). + * + * \param renderer the rendering context. + * \param r the red value used to draw on the rendering target. + * \param g the green value used to draw on the rendering target. + * \param b the blue value used to draw on the rendering target. + * \param a the alpha value used to draw on the rendering target. Use + * SDL_SetRenderDrawBlendMode to specify how the alpha channel is + * used. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetRenderDrawColorFloat + * \sa SDL_SetRenderDrawColor + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderDrawColorFloat(SDL_Renderer *renderer, float r, float g, float b, float a); + +/** + * Get the color used for drawing operations (Rect, Line and Clear). + * + * \param renderer the rendering context. + * \param r a pointer filled in with the red value used to draw on the + * rendering target. + * \param g a pointer filled in with the green value used to draw on the + * rendering target. + * \param b a pointer filled in with the blue value used to draw on the + * rendering target. + * \param a a pointer filled in with the alpha value used to draw on the + * rendering target; usually `SDL_ALPHA_OPAQUE` (255). + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetRenderDrawColorFloat + * \sa SDL_SetRenderDrawColor + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderDrawColor(SDL_Renderer *renderer, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a); + +/** + * Get the color used for drawing operations (Rect, Line and Clear). + * + * \param renderer the rendering context. + * \param r a pointer filled in with the red value used to draw on the + * rendering target. + * \param g a pointer filled in with the green value used to draw on the + * rendering target. + * \param b a pointer filled in with the blue value used to draw on the + * rendering target. + * \param a a pointer filled in with the alpha value used to draw on the + * rendering target. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetRenderDrawColorFloat + * \sa SDL_GetRenderDrawColor + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderDrawColorFloat(SDL_Renderer *renderer, float *r, float *g, float *b, float *a); + +/** + * Set the color scale used for render operations. + * + * The color scale is an additional scale multiplied into the pixel color + * value while rendering. This can be used to adjust the brightness of colors + * during HDR rendering, or changing HDR video brightness when playing on an + * SDR display. + * + * The color scale does not affect the alpha channel, only the color + * brightness. + * + * \param renderer the rendering context. + * \param scale the color scale value. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetRenderColorScale + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderColorScale(SDL_Renderer *renderer, float scale); + +/** + * Get the color scale used for render operations. + * + * \param renderer the rendering context. + * \param scale a pointer filled in with the current color scale value. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetRenderColorScale + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderColorScale(SDL_Renderer *renderer, float *scale); + +/** + * Set the blend mode used for drawing operations (Fill and Line). + * + * If the blend mode is not supported, the closest supported mode is chosen. + * + * \param renderer the rendering context. + * \param blendMode the SDL_BlendMode to use for blending. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetRenderDrawBlendMode + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderDrawBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode); + +/** + * Get the blend mode used for drawing operations. + * + * \param renderer the rendering context. + * \param blendMode a pointer filled in with the current SDL_BlendMode. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetRenderDrawBlendMode + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderDrawBlendMode(SDL_Renderer *renderer, SDL_BlendMode *blendMode); + +/** + * Clear the current rendering target with the drawing color. + * + * This function clears the entire rendering target, ignoring the viewport and + * the clip rectangle. Note, that clearing will also set/fill all pixels of + * the rendering target to current renderer draw color, so make sure to invoke + * SDL_SetRenderDrawColor() when needed. + * + * \param renderer the rendering context. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetRenderDrawColor + */ +extern SDL_DECLSPEC bool SDLCALL SDL_RenderClear(SDL_Renderer *renderer); + +/** + * Draw a point on the current rendering target at subpixel precision. + * + * \param renderer the renderer which should draw a point. + * \param x the x coordinate of the point. + * \param y the y coordinate of the point. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_RenderPoints + */ +extern SDL_DECLSPEC bool SDLCALL SDL_RenderPoint(SDL_Renderer *renderer, float x, float y); + +/** + * Draw multiple points on the current rendering target at subpixel precision. + * + * \param renderer the renderer which should draw multiple points. + * \param points the points to draw. + * \param count the number of points to draw. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_RenderPoint + */ +extern SDL_DECLSPEC bool SDLCALL SDL_RenderPoints(SDL_Renderer *renderer, const SDL_FPoint *points, int count); + +/** + * Draw a line on the current rendering target at subpixel precision. + * + * \param renderer the renderer which should draw a line. + * \param x1 the x coordinate of the start point. + * \param y1 the y coordinate of the start point. + * \param x2 the x coordinate of the end point. + * \param y2 the y coordinate of the end point. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_RenderLines + */ +extern SDL_DECLSPEC bool SDLCALL SDL_RenderLine(SDL_Renderer *renderer, float x1, float y1, float x2, float y2); + +/** + * Draw a series of connected lines on the current rendering target at + * subpixel precision. + * + * \param renderer the renderer which should draw multiple lines. + * \param points the points along the lines. + * \param count the number of points, drawing count-1 lines. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_RenderLine + */ +extern SDL_DECLSPEC bool SDLCALL SDL_RenderLines(SDL_Renderer *renderer, const SDL_FPoint *points, int count); + +/** + * Draw a rectangle on the current rendering target at subpixel precision. + * + * \param renderer the renderer which should draw a rectangle. + * \param rect a pointer to the destination rectangle, or NULL to outline the + * entire rendering target. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_RenderRects + */ +extern SDL_DECLSPEC bool SDLCALL SDL_RenderRect(SDL_Renderer *renderer, const SDL_FRect *rect); + +/** + * Draw some number of rectangles on the current rendering target at subpixel + * precision. + * + * \param renderer the renderer which should draw multiple rectangles. + * \param rects a pointer to an array of destination rectangles. + * \param count the number of rectangles. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_RenderRect + */ +extern SDL_DECLSPEC bool SDLCALL SDL_RenderRects(SDL_Renderer *renderer, const SDL_FRect *rects, int count); + +/** + * Fill a rectangle on the current rendering target with the drawing color at + * subpixel precision. + * + * \param renderer the renderer which should fill a rectangle. + * \param rect a pointer to the destination rectangle, or NULL for the entire + * rendering target. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_RenderFillRects + */ +extern SDL_DECLSPEC bool SDLCALL SDL_RenderFillRect(SDL_Renderer *renderer, const SDL_FRect *rect); + +/** + * Fill some number of rectangles on the current rendering target with the + * drawing color at subpixel precision. + * + * \param renderer the renderer which should fill multiple rectangles. + * \param rects a pointer to an array of destination rectangles. + * \param count the number of rectangles. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_RenderFillRect + */ +extern SDL_DECLSPEC bool SDLCALL SDL_RenderFillRects(SDL_Renderer *renderer, const SDL_FRect *rects, int count); + +/** + * Copy a portion of the texture to the current rendering target at subpixel + * precision. + * + * \param renderer the renderer which should copy parts of a texture. + * \param texture the source texture. + * \param srcrect a pointer to the source rectangle, or NULL for the entire + * texture. + * \param dstrect a pointer to the destination rectangle, or NULL for the + * entire rendering target. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_RenderTextureRotated + * \sa SDL_RenderTextureTiled + */ +extern SDL_DECLSPEC bool SDLCALL SDL_RenderTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_FRect *srcrect, const SDL_FRect *dstrect); + +/** + * Copy a portion of the source texture to the current rendering target, with + * rotation and flipping, at subpixel precision. + * + * \param renderer the renderer which should copy parts of a texture. + * \param texture the source texture. + * \param srcrect a pointer to the source rectangle, or NULL for the entire + * texture. + * \param dstrect a pointer to the destination rectangle, or NULL for the + * entire rendering target. + * \param angle an angle in degrees that indicates the rotation that will be + * applied to dstrect, rotating it in a clockwise direction. + * \param center a pointer to a point indicating the point around which + * dstrect will be rotated (if NULL, rotation will be done + * around dstrect.w/2, dstrect.h/2). + * \param flip an SDL_FlipMode value stating which flipping actions should be + * performed on the texture. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_RenderTexture + */ +extern SDL_DECLSPEC bool SDLCALL SDL_RenderTextureRotated(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_FRect *srcrect, const SDL_FRect *dstrect, + double angle, const SDL_FPoint *center, + SDL_FlipMode flip); + +/** + * Copy a portion of the source texture to the current rendering target, with + * affine transform, at subpixel precision. + * + * \param renderer the renderer which should copy parts of a texture. + * \param texture the source texture. + * \param srcrect a pointer to the source rectangle, or NULL for the entire + * texture. + * \param origin a pointer to a point indicating where the top-left corner of + * srcrect should be mapped to, or NULL for the rendering + * target's origin. + * \param right a pointer to a point indicating where the top-right corner of + * srcrect should be mapped to, or NULL for the rendering + * target's top-right corner. + * \param down a pointer to a point indicating where the bottom-left corner of + * srcrect should be mapped to, or NULL for the rendering target's + * bottom-left corner. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety You may only call this function from the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_RenderTexture + */ +extern SDL_DECLSPEC bool SDLCALL SDL_RenderTextureAffine(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_FRect *srcrect, const SDL_FPoint *origin, + const SDL_FPoint *right, const SDL_FPoint *down); + +/** + * Tile a portion of the texture to the current rendering target at subpixel + * precision. + * + * The pixels in `srcrect` will be repeated as many times as needed to + * completely fill `dstrect`. + * + * \param renderer the renderer which should copy parts of a texture. + * \param texture the source texture. + * \param srcrect a pointer to the source rectangle, or NULL for the entire + * texture. + * \param scale the scale used to transform srcrect into the destination + * rectangle, e.g. a 32x32 texture with a scale of 2 would fill + * 64x64 tiles. + * \param dstrect a pointer to the destination rectangle, or NULL for the + * entire rendering target. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_RenderTexture + */ +extern SDL_DECLSPEC bool SDLCALL SDL_RenderTextureTiled(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_FRect *srcrect, float scale, const SDL_FRect *dstrect); + +/** + * Perform a scaled copy using the 9-grid algorithm to the current rendering + * target at subpixel precision. + * + * The pixels in the texture are split into a 3x3 grid, using the different + * corner sizes for each corner, and the sides and center making up the + * remaining pixels. The corners are then scaled using `scale` and fit into + * the corners of the destination rectangle. The sides and center are then + * stretched into place to cover the remaining destination rectangle. + * + * \param renderer the renderer which should copy parts of a texture. + * \param texture the source texture. + * \param srcrect the SDL_Rect structure representing the rectangle to be used + * for the 9-grid, or NULL to use the entire texture. + * \param left_width the width, in pixels, of the left corners in `srcrect`. + * \param right_width the width, in pixels, of the right corners in `srcrect`. + * \param top_height the height, in pixels, of the top corners in `srcrect`. + * \param bottom_height the height, in pixels, of the bottom corners in + * `srcrect`. + * \param scale the scale used to transform the corner of `srcrect` into the + * corner of `dstrect`, or 0.0f for an unscaled copy. + * \param dstrect a pointer to the destination rectangle, or NULL for the + * entire rendering target. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_RenderTexture + * \sa SDL_RenderTexture9GridTiled + */ +extern SDL_DECLSPEC bool SDLCALL SDL_RenderTexture9Grid(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_FRect *srcrect, float left_width, float right_width, float top_height, float bottom_height, float scale, const SDL_FRect *dstrect); + +/** + * Perform a scaled copy using the 9-grid algorithm to the current rendering + * target at subpixel precision. + * + * The pixels in the texture are split into a 3x3 grid, using the different + * corner sizes for each corner, and the sides and center making up the + * remaining pixels. The corners are then scaled using `scale` and fit into + * the corners of the destination rectangle. The sides and center are then + * tiled into place to cover the remaining destination rectangle. + * + * \param renderer the renderer which should copy parts of a texture. + * \param texture the source texture. + * \param srcrect the SDL_Rect structure representing the rectangle to be used + * for the 9-grid, or NULL to use the entire texture. + * \param left_width the width, in pixels, of the left corners in `srcrect`. + * \param right_width the width, in pixels, of the right corners in `srcrect`. + * \param top_height the height, in pixels, of the top corners in `srcrect`. + * \param bottom_height the height, in pixels, of the bottom corners in + * `srcrect`. + * \param scale the scale used to transform the corner of `srcrect` into the + * corner of `dstrect`, or 0.0f for an unscaled copy. + * \param dstrect a pointer to the destination rectangle, or NULL for the + * entire rendering target. + * \param tileScale the scale used to transform the borders and center of + * `srcrect` into the borders and middle of `dstrect`, or + * 1.0f for an unscaled copy. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.4.0. + * + * \sa SDL_RenderTexture + * \sa SDL_RenderTexture9Grid + */ +extern SDL_DECLSPEC bool SDLCALL SDL_RenderTexture9GridTiled(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_FRect *srcrect, float left_width, float right_width, float top_height, float bottom_height, float scale, const SDL_FRect *dstrect, float tileScale); + +/** + * Render a list of triangles, optionally using a texture and indices into the + * vertex array Color and alpha modulation is done per vertex + * (SDL_SetTextureColorMod and SDL_SetTextureAlphaMod are ignored). + * + * \param renderer the rendering context. + * \param texture (optional) The SDL texture to use. + * \param vertices vertices. + * \param num_vertices number of vertices. + * \param indices (optional) An array of integer indices into the 'vertices' + * array, if NULL all vertices will be rendered in sequential + * order. + * \param num_indices number of indices. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_RenderGeometryRaw + * \sa SDL_SetRenderTextureAddressMode + */ +extern SDL_DECLSPEC bool SDLCALL SDL_RenderGeometry(SDL_Renderer *renderer, + SDL_Texture *texture, + const SDL_Vertex *vertices, int num_vertices, + const int *indices, int num_indices); + +/** + * Render a list of triangles, optionally using a texture and indices into the + * vertex arrays Color and alpha modulation is done per vertex + * (SDL_SetTextureColorMod and SDL_SetTextureAlphaMod are ignored). + * + * \param renderer the rendering context. + * \param texture (optional) The SDL texture to use. + * \param xy vertex positions. + * \param xy_stride byte size to move from one element to the next element. + * \param color vertex colors (as SDL_FColor). + * \param color_stride byte size to move from one element to the next element. + * \param uv vertex normalized texture coordinates. + * \param uv_stride byte size to move from one element to the next element. + * \param num_vertices number of vertices. + * \param indices (optional) An array of indices into the 'vertices' arrays, + * if NULL all vertices will be rendered in sequential order. + * \param num_indices number of indices. + * \param size_indices index size: 1 (byte), 2 (short), 4 (int). + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_RenderGeometry + * \sa SDL_SetRenderTextureAddressMode + */ +extern SDL_DECLSPEC bool SDLCALL SDL_RenderGeometryRaw(SDL_Renderer *renderer, + SDL_Texture *texture, + const float *xy, int xy_stride, + const SDL_FColor *color, int color_stride, + const float *uv, int uv_stride, + int num_vertices, + const void *indices, int num_indices, int size_indices); + +/** + * Set the texture addressing mode used in SDL_RenderGeometry(). + * + * \param renderer the rendering context. + * \param u_mode the SDL_TextureAddressMode to use for horizontal texture + * coordinates in SDL_RenderGeometry(). + * \param v_mode the SDL_TextureAddressMode to use for vertical texture + * coordinates in SDL_RenderGeometry(). + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.4.0. + * + * \sa SDL_RenderGeometry + * \sa SDL_RenderGeometryRaw + * \sa SDL_GetRenderTextureAddressMode + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderTextureAddressMode(SDL_Renderer *renderer, SDL_TextureAddressMode u_mode, SDL_TextureAddressMode v_mode); + +/** + * Get the texture addressing mode used in SDL_RenderGeometry(). + * + * \param renderer the rendering context. + * \param u_mode a pointer filled in with the SDL_TextureAddressMode to use + * for horizontal texture coordinates in SDL_RenderGeometry(), + * may be NULL. + * \param v_mode a pointer filled in with the SDL_TextureAddressMode to use + * for vertical texture coordinates in SDL_RenderGeometry(), may + * be NULL. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.4.0. + * + * \sa SDL_SetRenderTextureAddressMode + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderTextureAddressMode(SDL_Renderer *renderer, SDL_TextureAddressMode *u_mode, SDL_TextureAddressMode *v_mode); + +/** + * Read pixels from the current rendering target. + * + * The returned surface contains pixels inside the desired area clipped to the + * current viewport, and should be freed with SDL_DestroySurface(). + * + * Note that this returns the actual pixels on the screen, so if you are using + * logical presentation you should use SDL_GetRenderLogicalPresentationRect() + * to get the area containing your content. + * + * **WARNING**: This is a very slow operation, and should not be used + * frequently. If you're using this on the main rendering target, it should be + * called after rendering and before SDL_RenderPresent(). + * + * \param renderer the rendering context. + * \param rect an SDL_Rect structure representing the area to read, which will + * be clipped to the current viewport, or NULL for the entire + * viewport. + * \returns a new SDL_Surface on success or NULL on failure; call + * SDL_GetError() for more information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect); + +/** + * Update the screen with any rendering performed since the previous call. + * + * SDL's rendering functions operate on a backbuffer; that is, calling a + * rendering function such as SDL_RenderLine() does not directly put a line on + * the screen, but rather updates the backbuffer. As such, you compose your + * entire scene and *present* the composed backbuffer to the screen as a + * complete picture. + * + * Therefore, when using SDL's rendering API, one does all drawing intended + * for the frame, and then calls this function once per frame to present the + * final drawing to the user. + * + * The backbuffer should be considered invalidated after each present; do not + * assume that previous contents will exist between frames. You are strongly + * encouraged to call SDL_RenderClear() to initialize the backbuffer before + * starting each new frame's drawing, even if you plan to overwrite every + * pixel. + * + * Please note, that in case of rendering to a texture - there is **no need** + * to call `SDL_RenderPresent` after drawing needed objects to a texture, and + * should not be done; you are only required to change back the rendering + * target to default via `SDL_SetRenderTarget(renderer, NULL)` afterwards, as + * textures by themselves do not have a concept of backbuffers. Calling + * SDL_RenderPresent while rendering to a texture will fail. + * + * \param renderer the rendering context. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateRenderer + * \sa SDL_RenderClear + * \sa SDL_RenderFillRect + * \sa SDL_RenderFillRects + * \sa SDL_RenderLine + * \sa SDL_RenderLines + * \sa SDL_RenderPoint + * \sa SDL_RenderPoints + * \sa SDL_RenderRect + * \sa SDL_RenderRects + * \sa SDL_SetRenderDrawBlendMode + * \sa SDL_SetRenderDrawColor + */ +extern SDL_DECLSPEC bool SDLCALL SDL_RenderPresent(SDL_Renderer *renderer); + +/** + * Destroy the specified texture. + * + * Passing NULL or an otherwise invalid texture will set the SDL error message + * to "Invalid texture". + * + * \param texture the texture to destroy. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateTexture + * \sa SDL_CreateTextureFromSurface + */ +extern SDL_DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture *texture); + +/** + * Destroy the rendering context for a window and free all associated + * textures. + * + * This should be called before destroying the associated window. + * + * \param renderer the rendering context. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateRenderer + */ +extern SDL_DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_Renderer *renderer); + +/** + * Force the rendering context to flush any pending commands and state. + * + * You do not need to (and in fact, shouldn't) call this function unless you + * are planning to call into OpenGL/Direct3D/Metal/whatever directly, in + * addition to using an SDL_Renderer. + * + * This is for a very-specific case: if you are using SDL's render API, and + * you plan to make OpenGL/D3D/whatever calls in addition to SDL render API + * calls. If this applies, you should call this function between calls to + * SDL's render API and the low-level API you're using in cooperation. + * + * In all other cases, you can ignore this function. + * + * This call makes SDL flush any pending rendering work it was queueing up to + * do later in a single batch, and marks any internal cached state as invalid, + * so it'll prepare all its state again later, from scratch. + * + * This means you do not need to save state in your rendering code to protect + * the SDL renderer. However, there lots of arbitrary pieces of Direct3D and + * OpenGL state that can confuse things; you should use your best judgment and + * be prepared to make changes if specific state needs to be protected. + * + * \param renderer the rendering context. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_FlushRenderer(SDL_Renderer *renderer); + +/** + * Get the CAMetalLayer associated with the given Metal renderer. + * + * This function returns `void *`, so SDL doesn't have to include Metal's + * headers, but it can be safely cast to a `CAMetalLayer *`. + * + * \param renderer the renderer to query. + * \returns a `CAMetalLayer *` on success, or NULL if the renderer isn't a + * Metal renderer. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetRenderMetalCommandEncoder + */ +extern SDL_DECLSPEC void * SDLCALL SDL_GetRenderMetalLayer(SDL_Renderer *renderer); + +/** + * Get the Metal command encoder for the current frame. + * + * This function returns `void *`, so SDL doesn't have to include Metal's + * headers, but it can be safely cast to an `id`. + * + * This will return NULL if Metal refuses to give SDL a drawable to render to, + * which might happen if the window is hidden/minimized/offscreen. This + * doesn't apply to command encoders for render targets, just the window's + * backbuffer. Check your return values! + * + * \param renderer the renderer to query. + * \returns an `id` on success, or NULL if the + * renderer isn't a Metal renderer or there was an error. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetRenderMetalLayer + */ +extern SDL_DECLSPEC void * SDLCALL SDL_GetRenderMetalCommandEncoder(SDL_Renderer *renderer); + + +/** + * Add a set of synchronization semaphores for the current frame. + * + * The Vulkan renderer will wait for `wait_semaphore` before submitting + * rendering commands and signal `signal_semaphore` after rendering commands + * are complete for this frame. + * + * This should be called each frame that you want semaphore synchronization. + * The Vulkan renderer may have multiple frames in flight on the GPU, so you + * should have multiple semaphores that are used for synchronization. Querying + * SDL_PROP_RENDERER_VULKAN_SWAPCHAIN_IMAGE_COUNT_NUMBER will give you the + * maximum number of semaphores you'll need. + * + * \param renderer the rendering context. + * \param wait_stage_mask the VkPipelineStageFlags for the wait. + * \param wait_semaphore a VkSempahore to wait on before rendering the current + * frame, or 0 if not needed. + * \param signal_semaphore a VkSempahore that SDL will signal when rendering + * for the current frame is complete, or 0 if not + * needed. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is **NOT** safe to call this function from two threads at + * once. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_AddVulkanRenderSemaphores(SDL_Renderer *renderer, Uint32 wait_stage_mask, Sint64 wait_semaphore, Sint64 signal_semaphore); + +/** + * Toggle VSync of the given renderer. + * + * When a renderer is created, vsync defaults to SDL_RENDERER_VSYNC_DISABLED. + * + * The `vsync` parameter can be 1 to synchronize present with every vertical + * refresh, 2 to synchronize present with every second vertical refresh, etc., + * SDL_RENDERER_VSYNC_ADAPTIVE for late swap tearing (adaptive vsync), or + * SDL_RENDERER_VSYNC_DISABLED to disable. Not every value is supported by + * every driver, so you should check the return value to see whether the + * requested setting is supported. + * + * \param renderer the renderer to toggle. + * \param vsync the vertical refresh sync interval. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetRenderVSync + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderVSync(SDL_Renderer *renderer, int vsync); + +#define SDL_RENDERER_VSYNC_DISABLED 0 +#define SDL_RENDERER_VSYNC_ADAPTIVE (-1) + +/** + * Get VSync of the given renderer. + * + * \param renderer the renderer to toggle. + * \param vsync an int filled with the current vertical refresh sync interval. + * See SDL_SetRenderVSync() for the meaning of the value. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetRenderVSync + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderVSync(SDL_Renderer *renderer, int *vsync); + +/** + * The size, in pixels, of a single SDL_RenderDebugText() character. + * + * The font is monospaced and square, so this applies to all characters. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_RenderDebugText + */ +#define SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE 8 + +/** + * Draw debug text to an SDL_Renderer. + * + * This function will render a string of text to an SDL_Renderer. Note that + * this is a convenience function for debugging, with severe limitations, and + * not intended to be used for production apps and games. + * + * Among these limitations: + * + * - It accepts UTF-8 strings, but will only renders ASCII characters. + * - It has a single, tiny size (8x8 pixels). You can use logical presentation + * or SDL_SetRenderScale() to adjust it. + * - It uses a simple, hardcoded bitmap font. It does not allow different font + * selections and it does not support truetype, for proper scaling. + * - It does no word-wrapping and does not treat newline characters as a line + * break. If the text goes out of the window, it's gone. + * + * For serious text rendering, there are several good options, such as + * SDL_ttf, stb_truetype, or other external libraries. + * + * On first use, this will create an internal texture for rendering glyphs. + * This texture will live until the renderer is destroyed. + * + * The text is drawn in the color specified by SDL_SetRenderDrawColor(). + * + * \param renderer the renderer which should draw a line of text. + * \param x the x coordinate where the top-left corner of the text will draw. + * \param y the y coordinate where the top-left corner of the text will draw. + * \param str the string to render. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_RenderDebugTextFormat + * \sa SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE + */ +extern SDL_DECLSPEC bool SDLCALL SDL_RenderDebugText(SDL_Renderer *renderer, float x, float y, const char *str); + +/** + * Draw debug text to an SDL_Renderer. + * + * This function will render a printf()-style format string to a renderer. + * Note that this is a convenience function for debugging, with severe + * limitations, and is not intended to be used for production apps and games. + * + * For the full list of limitations and other useful information, see + * SDL_RenderDebugText. + * + * \param renderer the renderer which should draw the text. + * \param x the x coordinate where the top-left corner of the text will draw. + * \param y the y coordinate where the top-left corner of the text will draw. + * \param fmt the format string to draw. + * \param ... additional parameters matching % tokens in the `fmt` string, if + * any. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_RenderDebugText + * \sa SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE + */ +extern SDL_DECLSPEC bool SDLCALL SDL_RenderDebugTextFormat(SDL_Renderer *renderer, float x, float y, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(4); + +/** + * Set default scale mode for new textures for given renderer. + * + * When a renderer is created, scale_mode defaults to SDL_SCALEMODE_LINEAR. + * + * \param renderer the renderer to update. + * \param scale_mode the scale mode to change to for new textures. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.4.0. + * + * \sa SDL_GetDefaultTextureScaleMode + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetDefaultTextureScaleMode(SDL_Renderer *renderer, SDL_ScaleMode scale_mode); + +/** + * Get default texture scale mode of the given renderer. + * + * \param renderer the renderer to get data from. + * \param scale_mode a SDL_ScaleMode filled with current default scale mode. + * See SDL_SetDefaultTextureScaleMode() for the meaning of + * the value. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.4.0. + * + * \sa SDL_SetDefaultTextureScaleMode + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetDefaultTextureScaleMode(SDL_Renderer *renderer, SDL_ScaleMode *scale_mode); + +/** + * A structure specifying the parameters of a GPU render state. + * + * \since This struct is available since SDL 3.4.0. + * + * \sa SDL_CreateGPURenderState + */ +typedef struct SDL_GPURenderStateCreateInfo +{ + SDL_GPUShader *fragment_shader; /**< The fragment shader to use when this render state is active */ + + Sint32 num_sampler_bindings; /**< The number of additional fragment samplers to bind when this render state is active */ + const SDL_GPUTextureSamplerBinding *sampler_bindings; /**< Additional fragment samplers to bind when this render state is active */ + + Sint32 num_storage_textures; /**< The number of storage textures to bind when this render state is active */ + SDL_GPUTexture *const *storage_textures; /**< Storage textures to bind when this render state is active */ + + Sint32 num_storage_buffers; /**< The number of storage buffers to bind when this render state is active */ + SDL_GPUBuffer *const *storage_buffers; /**< Storage buffers to bind when this render state is active */ + + SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */ +} SDL_GPURenderStateCreateInfo; + +/** + * A custom GPU render state. + * + * \since This struct is available since SDL 3.4.0. + * + * \sa SDL_CreateGPURenderState + * \sa SDL_SetGPURenderStateFragmentUniforms + * \sa SDL_SetGPURenderState + * \sa SDL_DestroyGPURenderState + */ +typedef struct SDL_GPURenderState SDL_GPURenderState; + +/** + * Create custom GPU render state. + * + * \param renderer the renderer to use. + * \param createinfo a struct describing the GPU render state to create. + * \returns a custom GPU render state or NULL on failure; call SDL_GetError() + * for more information. + * + * \threadsafety This function should be called on the thread that created the + * renderer. + * + * \since This function is available since SDL 3.4.0. + * + * \sa SDL_SetGPURenderStateFragmentUniforms + * \sa SDL_SetGPURenderState + * \sa SDL_DestroyGPURenderState + */ +extern SDL_DECLSPEC SDL_GPURenderState * SDLCALL SDL_CreateGPURenderState(SDL_Renderer *renderer, SDL_GPURenderStateCreateInfo *createinfo); + +/** + * Set fragment shader uniform variables in a custom GPU render state. + * + * The data is copied and will be pushed using + * SDL_PushGPUFragmentUniformData() during draw call execution. + * + * \param state the state to modify. + * \param slot_index the fragment uniform slot to push data to. + * \param data client data to write. + * \param length the length of the data to write. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should be called on the thread that created the + * renderer. + * + * \since This function is available since SDL 3.4.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetGPURenderStateFragmentUniforms(SDL_GPURenderState *state, Uint32 slot_index, const void *data, Uint32 length); + +/** + * Set custom GPU render state. + * + * This function sets custom GPU render state for subsequent draw calls. This + * allows using custom shaders with the GPU renderer. + * + * \param renderer the renderer to use. + * \param state the state to to use, or NULL to clear custom GPU render state. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should be called on the thread that created the + * renderer. + * + * \since This function is available since SDL 3.4.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetGPURenderState(SDL_Renderer *renderer, SDL_GPURenderState *state); + +/** + * Destroy custom GPU render state. + * + * \param state the state to destroy. + * + * \threadsafety This function should be called on the thread that created the + * renderer. + * + * \since This function is available since SDL 3.4.0. + * + * \sa SDL_CreateGPURenderState + */ +extern SDL_DECLSPEC void SDLCALL SDL_DestroyGPURenderState(SDL_GPURenderState *state); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_render_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_revision.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_revision.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,41 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* WIKI CATEGORY: Version */ + +/* + * SDL_revision.h contains the SDL revision, which might be defined on the + * compiler command line, or generated right into the header itself by the + * build system. + */ + +#ifndef SDL_revision_h_ +#define SDL_revision_h_ + +#define SDL_VENDOR_INFO "libsdl.org" + +#if defined(SDL_VENDOR_INFO) +#define SDL_REVISION "SDL-release-3.4.0-0-ga962f40bb (" SDL_VENDOR_INFO ")" +#else +#define SDL_REVISION "SDL-release-3.4.0-0-ga962f40bb" +#endif + +#endif /* SDL_revision_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_scancode.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_scancode.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,429 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * # CategoryScancode + * + * Defines keyboard scancodes. + * + * Please refer to the Best Keyboard Practices document for details on what + * this information means and how best to use it. + * + * https://wiki.libsdl.org/SDL3/BestKeyboardPractices + */ + +#ifndef SDL_scancode_h_ +#define SDL_scancode_h_ + +#include + +/** + * The SDL keyboard scancode representation. + * + * An SDL scancode is the physical representation of a key on the keyboard, + * independent of language and keyboard mapping. + * + * Values of this type are used to represent keyboard keys, among other places + * in the `scancode` field of the SDL_KeyboardEvent structure. + * + * The values in this enumeration are based on the USB usage page standard: + * https://usb.org/sites/default/files/hut1_5.pdf + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_Scancode +{ + SDL_SCANCODE_UNKNOWN = 0, + + /** + * \name Usage page 0x07 + * + * These values are from usage page 0x07 (USB keyboard page). + */ + /* @{ */ + + SDL_SCANCODE_A = 4, + SDL_SCANCODE_B = 5, + SDL_SCANCODE_C = 6, + SDL_SCANCODE_D = 7, + SDL_SCANCODE_E = 8, + SDL_SCANCODE_F = 9, + SDL_SCANCODE_G = 10, + SDL_SCANCODE_H = 11, + SDL_SCANCODE_I = 12, + SDL_SCANCODE_J = 13, + SDL_SCANCODE_K = 14, + SDL_SCANCODE_L = 15, + SDL_SCANCODE_M = 16, + SDL_SCANCODE_N = 17, + SDL_SCANCODE_O = 18, + SDL_SCANCODE_P = 19, + SDL_SCANCODE_Q = 20, + SDL_SCANCODE_R = 21, + SDL_SCANCODE_S = 22, + SDL_SCANCODE_T = 23, + SDL_SCANCODE_U = 24, + SDL_SCANCODE_V = 25, + SDL_SCANCODE_W = 26, + SDL_SCANCODE_X = 27, + SDL_SCANCODE_Y = 28, + SDL_SCANCODE_Z = 29, + + SDL_SCANCODE_1 = 30, + SDL_SCANCODE_2 = 31, + SDL_SCANCODE_3 = 32, + SDL_SCANCODE_4 = 33, + SDL_SCANCODE_5 = 34, + SDL_SCANCODE_6 = 35, + SDL_SCANCODE_7 = 36, + SDL_SCANCODE_8 = 37, + SDL_SCANCODE_9 = 38, + SDL_SCANCODE_0 = 39, + + SDL_SCANCODE_RETURN = 40, + SDL_SCANCODE_ESCAPE = 41, + SDL_SCANCODE_BACKSPACE = 42, + SDL_SCANCODE_TAB = 43, + SDL_SCANCODE_SPACE = 44, + + SDL_SCANCODE_MINUS = 45, + SDL_SCANCODE_EQUALS = 46, + SDL_SCANCODE_LEFTBRACKET = 47, + SDL_SCANCODE_RIGHTBRACKET = 48, + SDL_SCANCODE_BACKSLASH = 49, /**< Located at the lower left of the return + * key on ISO keyboards and at the right end + * of the QWERTY row on ANSI keyboards. + * Produces REVERSE SOLIDUS (backslash) and + * VERTICAL LINE in a US layout, REVERSE + * SOLIDUS and VERTICAL LINE in a UK Mac + * layout, NUMBER SIGN and TILDE in a UK + * Windows layout, DOLLAR SIGN and POUND SIGN + * in a Swiss German layout, NUMBER SIGN and + * APOSTROPHE in a German layout, GRAVE + * ACCENT and POUND SIGN in a French Mac + * layout, and ASTERISK and MICRO SIGN in a + * French Windows layout. + */ + SDL_SCANCODE_NONUSHASH = 50, /**< ISO USB keyboards actually use this code + * instead of 49 for the same key, but all + * OSes I've seen treat the two codes + * identically. So, as an implementor, unless + * your keyboard generates both of those + * codes and your OS treats them differently, + * you should generate SDL_SCANCODE_BACKSLASH + * instead of this code. As a user, you + * should not rely on this code because SDL + * will never generate it with most (all?) + * keyboards. + */ + SDL_SCANCODE_SEMICOLON = 51, + SDL_SCANCODE_APOSTROPHE = 52, + SDL_SCANCODE_GRAVE = 53, /**< Located in the top left corner (on both ANSI + * and ISO keyboards). Produces GRAVE ACCENT and + * TILDE in a US Windows layout and in US and UK + * Mac layouts on ANSI keyboards, GRAVE ACCENT + * and NOT SIGN in a UK Windows layout, SECTION + * SIGN and PLUS-MINUS SIGN in US and UK Mac + * layouts on ISO keyboards, SECTION SIGN and + * DEGREE SIGN in a Swiss German layout (Mac: + * only on ISO keyboards), CIRCUMFLEX ACCENT and + * DEGREE SIGN in a German layout (Mac: only on + * ISO keyboards), SUPERSCRIPT TWO and TILDE in a + * French Windows layout, COMMERCIAL AT and + * NUMBER SIGN in a French Mac layout on ISO + * keyboards, and LESS-THAN SIGN and GREATER-THAN + * SIGN in a Swiss German, German, or French Mac + * layout on ANSI keyboards. + */ + SDL_SCANCODE_COMMA = 54, + SDL_SCANCODE_PERIOD = 55, + SDL_SCANCODE_SLASH = 56, + + SDL_SCANCODE_CAPSLOCK = 57, + + SDL_SCANCODE_F1 = 58, + SDL_SCANCODE_F2 = 59, + SDL_SCANCODE_F3 = 60, + SDL_SCANCODE_F4 = 61, + SDL_SCANCODE_F5 = 62, + SDL_SCANCODE_F6 = 63, + SDL_SCANCODE_F7 = 64, + SDL_SCANCODE_F8 = 65, + SDL_SCANCODE_F9 = 66, + SDL_SCANCODE_F10 = 67, + SDL_SCANCODE_F11 = 68, + SDL_SCANCODE_F12 = 69, + + SDL_SCANCODE_PRINTSCREEN = 70, + SDL_SCANCODE_SCROLLLOCK = 71, + SDL_SCANCODE_PAUSE = 72, + SDL_SCANCODE_INSERT = 73, /**< insert on PC, help on some Mac keyboards (but + does send code 73, not 117) */ + SDL_SCANCODE_HOME = 74, + SDL_SCANCODE_PAGEUP = 75, + SDL_SCANCODE_DELETE = 76, + SDL_SCANCODE_END = 77, + SDL_SCANCODE_PAGEDOWN = 78, + SDL_SCANCODE_RIGHT = 79, + SDL_SCANCODE_LEFT = 80, + SDL_SCANCODE_DOWN = 81, + SDL_SCANCODE_UP = 82, + + SDL_SCANCODE_NUMLOCKCLEAR = 83, /**< num lock on PC, clear on Mac keyboards + */ + SDL_SCANCODE_KP_DIVIDE = 84, + SDL_SCANCODE_KP_MULTIPLY = 85, + SDL_SCANCODE_KP_MINUS = 86, + SDL_SCANCODE_KP_PLUS = 87, + SDL_SCANCODE_KP_ENTER = 88, + SDL_SCANCODE_KP_1 = 89, + SDL_SCANCODE_KP_2 = 90, + SDL_SCANCODE_KP_3 = 91, + SDL_SCANCODE_KP_4 = 92, + SDL_SCANCODE_KP_5 = 93, + SDL_SCANCODE_KP_6 = 94, + SDL_SCANCODE_KP_7 = 95, + SDL_SCANCODE_KP_8 = 96, + SDL_SCANCODE_KP_9 = 97, + SDL_SCANCODE_KP_0 = 98, + SDL_SCANCODE_KP_PERIOD = 99, + + SDL_SCANCODE_NONUSBACKSLASH = 100, /**< This is the additional key that ISO + * keyboards have over ANSI ones, + * located between left shift and Z. + * Produces GRAVE ACCENT and TILDE in a + * US or UK Mac layout, REVERSE SOLIDUS + * (backslash) and VERTICAL LINE in a + * US or UK Windows layout, and + * LESS-THAN SIGN and GREATER-THAN SIGN + * in a Swiss German, German, or French + * layout. */ + SDL_SCANCODE_APPLICATION = 101, /**< windows contextual menu, compose */ + SDL_SCANCODE_POWER = 102, /**< The USB document says this is a status flag, + * not a physical key - but some Mac keyboards + * do have a power key. */ + SDL_SCANCODE_KP_EQUALS = 103, + SDL_SCANCODE_F13 = 104, + SDL_SCANCODE_F14 = 105, + SDL_SCANCODE_F15 = 106, + SDL_SCANCODE_F16 = 107, + SDL_SCANCODE_F17 = 108, + SDL_SCANCODE_F18 = 109, + SDL_SCANCODE_F19 = 110, + SDL_SCANCODE_F20 = 111, + SDL_SCANCODE_F21 = 112, + SDL_SCANCODE_F22 = 113, + SDL_SCANCODE_F23 = 114, + SDL_SCANCODE_F24 = 115, + SDL_SCANCODE_EXECUTE = 116, + SDL_SCANCODE_HELP = 117, /**< AL Integrated Help Center */ + SDL_SCANCODE_MENU = 118, /**< Menu (show menu) */ + SDL_SCANCODE_SELECT = 119, + SDL_SCANCODE_STOP = 120, /**< AC Stop */ + SDL_SCANCODE_AGAIN = 121, /**< AC Redo/Repeat */ + SDL_SCANCODE_UNDO = 122, /**< AC Undo */ + SDL_SCANCODE_CUT = 123, /**< AC Cut */ + SDL_SCANCODE_COPY = 124, /**< AC Copy */ + SDL_SCANCODE_PASTE = 125, /**< AC Paste */ + SDL_SCANCODE_FIND = 126, /**< AC Find */ + SDL_SCANCODE_MUTE = 127, + SDL_SCANCODE_VOLUMEUP = 128, + SDL_SCANCODE_VOLUMEDOWN = 129, +/* not sure whether there's a reason to enable these */ +/* SDL_SCANCODE_LOCKINGCAPSLOCK = 130, */ +/* SDL_SCANCODE_LOCKINGNUMLOCK = 131, */ +/* SDL_SCANCODE_LOCKINGSCROLLLOCK = 132, */ + SDL_SCANCODE_KP_COMMA = 133, + SDL_SCANCODE_KP_EQUALSAS400 = 134, + + SDL_SCANCODE_INTERNATIONAL1 = 135, /**< used on Asian keyboards, see + footnotes in USB doc */ + SDL_SCANCODE_INTERNATIONAL2 = 136, + SDL_SCANCODE_INTERNATIONAL3 = 137, /**< Yen */ + SDL_SCANCODE_INTERNATIONAL4 = 138, + SDL_SCANCODE_INTERNATIONAL5 = 139, + SDL_SCANCODE_INTERNATIONAL6 = 140, + SDL_SCANCODE_INTERNATIONAL7 = 141, + SDL_SCANCODE_INTERNATIONAL8 = 142, + SDL_SCANCODE_INTERNATIONAL9 = 143, + SDL_SCANCODE_LANG1 = 144, /**< Hangul/English toggle */ + SDL_SCANCODE_LANG2 = 145, /**< Hanja conversion */ + SDL_SCANCODE_LANG3 = 146, /**< Katakana */ + SDL_SCANCODE_LANG4 = 147, /**< Hiragana */ + SDL_SCANCODE_LANG5 = 148, /**< Zenkaku/Hankaku */ + SDL_SCANCODE_LANG6 = 149, /**< reserved */ + SDL_SCANCODE_LANG7 = 150, /**< reserved */ + SDL_SCANCODE_LANG8 = 151, /**< reserved */ + SDL_SCANCODE_LANG9 = 152, /**< reserved */ + + SDL_SCANCODE_ALTERASE = 153, /**< Erase-Eaze */ + SDL_SCANCODE_SYSREQ = 154, + SDL_SCANCODE_CANCEL = 155, /**< AC Cancel */ + SDL_SCANCODE_CLEAR = 156, + SDL_SCANCODE_PRIOR = 157, + SDL_SCANCODE_RETURN2 = 158, + SDL_SCANCODE_SEPARATOR = 159, + SDL_SCANCODE_OUT = 160, + SDL_SCANCODE_OPER = 161, + SDL_SCANCODE_CLEARAGAIN = 162, + SDL_SCANCODE_CRSEL = 163, + SDL_SCANCODE_EXSEL = 164, + + SDL_SCANCODE_KP_00 = 176, + SDL_SCANCODE_KP_000 = 177, + SDL_SCANCODE_THOUSANDSSEPARATOR = 178, + SDL_SCANCODE_DECIMALSEPARATOR = 179, + SDL_SCANCODE_CURRENCYUNIT = 180, + SDL_SCANCODE_CURRENCYSUBUNIT = 181, + SDL_SCANCODE_KP_LEFTPAREN = 182, + SDL_SCANCODE_KP_RIGHTPAREN = 183, + SDL_SCANCODE_KP_LEFTBRACE = 184, + SDL_SCANCODE_KP_RIGHTBRACE = 185, + SDL_SCANCODE_KP_TAB = 186, + SDL_SCANCODE_KP_BACKSPACE = 187, + SDL_SCANCODE_KP_A = 188, + SDL_SCANCODE_KP_B = 189, + SDL_SCANCODE_KP_C = 190, + SDL_SCANCODE_KP_D = 191, + SDL_SCANCODE_KP_E = 192, + SDL_SCANCODE_KP_F = 193, + SDL_SCANCODE_KP_XOR = 194, + SDL_SCANCODE_KP_POWER = 195, + SDL_SCANCODE_KP_PERCENT = 196, + SDL_SCANCODE_KP_LESS = 197, + SDL_SCANCODE_KP_GREATER = 198, + SDL_SCANCODE_KP_AMPERSAND = 199, + SDL_SCANCODE_KP_DBLAMPERSAND = 200, + SDL_SCANCODE_KP_VERTICALBAR = 201, + SDL_SCANCODE_KP_DBLVERTICALBAR = 202, + SDL_SCANCODE_KP_COLON = 203, + SDL_SCANCODE_KP_HASH = 204, + SDL_SCANCODE_KP_SPACE = 205, + SDL_SCANCODE_KP_AT = 206, + SDL_SCANCODE_KP_EXCLAM = 207, + SDL_SCANCODE_KP_MEMSTORE = 208, + SDL_SCANCODE_KP_MEMRECALL = 209, + SDL_SCANCODE_KP_MEMCLEAR = 210, + SDL_SCANCODE_KP_MEMADD = 211, + SDL_SCANCODE_KP_MEMSUBTRACT = 212, + SDL_SCANCODE_KP_MEMMULTIPLY = 213, + SDL_SCANCODE_KP_MEMDIVIDE = 214, + SDL_SCANCODE_KP_PLUSMINUS = 215, + SDL_SCANCODE_KP_CLEAR = 216, + SDL_SCANCODE_KP_CLEARENTRY = 217, + SDL_SCANCODE_KP_BINARY = 218, + SDL_SCANCODE_KP_OCTAL = 219, + SDL_SCANCODE_KP_DECIMAL = 220, + SDL_SCANCODE_KP_HEXADECIMAL = 221, + + SDL_SCANCODE_LCTRL = 224, + SDL_SCANCODE_LSHIFT = 225, + SDL_SCANCODE_LALT = 226, /**< alt, option */ + SDL_SCANCODE_LGUI = 227, /**< windows, command (apple), meta */ + SDL_SCANCODE_RCTRL = 228, + SDL_SCANCODE_RSHIFT = 229, + SDL_SCANCODE_RALT = 230, /**< alt gr, option */ + SDL_SCANCODE_RGUI = 231, /**< windows, command (apple), meta */ + + SDL_SCANCODE_MODE = 257, /**< I'm not sure if this is really not covered + * by any of the above, but since there's a + * special SDL_KMOD_MODE for it I'm adding it here + */ + + /* @} *//* Usage page 0x07 */ + + /** + * \name Usage page 0x0C + * + * These values are mapped from usage page 0x0C (USB consumer page). + * + * There are way more keys in the spec than we can represent in the + * current scancode range, so pick the ones that commonly come up in + * real world usage. + */ + /* @{ */ + + SDL_SCANCODE_SLEEP = 258, /**< Sleep */ + SDL_SCANCODE_WAKE = 259, /**< Wake */ + + SDL_SCANCODE_CHANNEL_INCREMENT = 260, /**< Channel Increment */ + SDL_SCANCODE_CHANNEL_DECREMENT = 261, /**< Channel Decrement */ + + SDL_SCANCODE_MEDIA_PLAY = 262, /**< Play */ + SDL_SCANCODE_MEDIA_PAUSE = 263, /**< Pause */ + SDL_SCANCODE_MEDIA_RECORD = 264, /**< Record */ + SDL_SCANCODE_MEDIA_FAST_FORWARD = 265, /**< Fast Forward */ + SDL_SCANCODE_MEDIA_REWIND = 266, /**< Rewind */ + SDL_SCANCODE_MEDIA_NEXT_TRACK = 267, /**< Next Track */ + SDL_SCANCODE_MEDIA_PREVIOUS_TRACK = 268, /**< Previous Track */ + SDL_SCANCODE_MEDIA_STOP = 269, /**< Stop */ + SDL_SCANCODE_MEDIA_EJECT = 270, /**< Eject */ + SDL_SCANCODE_MEDIA_PLAY_PAUSE = 271, /**< Play / Pause */ + SDL_SCANCODE_MEDIA_SELECT = 272, /* Media Select */ + + SDL_SCANCODE_AC_NEW = 273, /**< AC New */ + SDL_SCANCODE_AC_OPEN = 274, /**< AC Open */ + SDL_SCANCODE_AC_CLOSE = 275, /**< AC Close */ + SDL_SCANCODE_AC_EXIT = 276, /**< AC Exit */ + SDL_SCANCODE_AC_SAVE = 277, /**< AC Save */ + SDL_SCANCODE_AC_PRINT = 278, /**< AC Print */ + SDL_SCANCODE_AC_PROPERTIES = 279, /**< AC Properties */ + + SDL_SCANCODE_AC_SEARCH = 280, /**< AC Search */ + SDL_SCANCODE_AC_HOME = 281, /**< AC Home */ + SDL_SCANCODE_AC_BACK = 282, /**< AC Back */ + SDL_SCANCODE_AC_FORWARD = 283, /**< AC Forward */ + SDL_SCANCODE_AC_STOP = 284, /**< AC Stop */ + SDL_SCANCODE_AC_REFRESH = 285, /**< AC Refresh */ + SDL_SCANCODE_AC_BOOKMARKS = 286, /**< AC Bookmarks */ + + /* @} *//* Usage page 0x0C */ + + + /** + * \name Mobile keys + * + * These are values that are often used on mobile phones. + */ + /* @{ */ + + SDL_SCANCODE_SOFTLEFT = 287, /**< Usually situated below the display on phones and + used as a multi-function feature key for selecting + a software defined function shown on the bottom left + of the display. */ + SDL_SCANCODE_SOFTRIGHT = 288, /**< Usually situated below the display on phones and + used as a multi-function feature key for selecting + a software defined function shown on the bottom right + of the display. */ + SDL_SCANCODE_CALL = 289, /**< Used for accepting phone calls. */ + SDL_SCANCODE_ENDCALL = 290, /**< Used for rejecting phone calls. */ + + /* @} *//* Mobile keys */ + + /* Add any other keys here. */ + + SDL_SCANCODE_RESERVED = 400, /**< 400-500 reserved for dynamic keycodes */ + + SDL_SCANCODE_COUNT = 512 /**< not a key, just marks the number of scancodes for array bounds */ + +} SDL_Scancode; + +#endif /* SDL_scancode_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_sensor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_sensor.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,321 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * # CategorySensor + * + * SDL sensor management. + * + * These APIs grant access to gyros and accelerometers on various platforms. + * + * In order to use these functions, SDL_Init() must have been called with the + * SDL_INIT_SENSOR flag. This causes SDL to scan the system for sensors, and + * load appropriate drivers. + */ + +#ifndef SDL_sensor_h_ +#define SDL_sensor_h_ + +#include +#include +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +/* *INDENT-OFF* */ +extern "C" { +/* *INDENT-ON* */ +#endif + +/** + * The opaque structure used to identify an opened SDL sensor. + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_Sensor SDL_Sensor; + +/** + * This is a unique ID for a sensor for the time it is connected to the + * system, and is never reused for the lifetime of the application. + * + * The value 0 is an invalid ID. + * + * \since This datatype is available since SDL 3.2.0. + */ +typedef Uint32 SDL_SensorID; + +/** + * A constant to represent standard gravity for accelerometer sensors. + * + * The accelerometer returns the current acceleration in SI meters per second + * squared. This measurement includes the force of gravity, so a device at + * rest will have an value of SDL_STANDARD_GRAVITY away from the center of the + * earth, which is a positive Y value. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_STANDARD_GRAVITY 9.80665f + +/** + * The different sensors defined by SDL. + * + * Additional sensors may be available, using platform dependent semantics. + * + * Here are the additional Android sensors: + * + * https://developer.android.com/reference/android/hardware/SensorEvent.html#values + * + * Accelerometer sensor notes: + * + * The accelerometer returns the current acceleration in SI meters per second + * squared. This measurement includes the force of gravity, so a device at + * rest will have an value of SDL_STANDARD_GRAVITY away from the center of the + * earth, which is a positive Y value. + * + * - `values[0]`: Acceleration on the x axis + * - `values[1]`: Acceleration on the y axis + * - `values[2]`: Acceleration on the z axis + * + * For phones and tablets held in natural orientation and game controllers + * held in front of you, the axes are defined as follows: + * + * - -X ... +X : left ... right + * - -Y ... +Y : bottom ... top + * - -Z ... +Z : farther ... closer + * + * The accelerometer axis data is not changed when the device is rotated. + * + * Gyroscope sensor notes: + * + * The gyroscope returns the current rate of rotation in radians per second. + * The rotation is positive in the counter-clockwise direction. That is, an + * observer looking from a positive location on one of the axes would see + * positive rotation on that axis when it appeared to be rotating + * counter-clockwise. + * + * - `values[0]`: Angular speed around the x axis (pitch) + * - `values[1]`: Angular speed around the y axis (yaw) + * - `values[2]`: Angular speed around the z axis (roll) + * + * For phones and tablets held in natural orientation and game controllers + * held in front of you, the axes are defined as follows: + * + * - -X ... +X : left ... right + * - -Y ... +Y : bottom ... top + * - -Z ... +Z : farther ... closer + * + * The gyroscope axis data is not changed when the device is rotated. + * + * \since This enum is available since SDL 3.2.0. + * + * \sa SDL_GetCurrentDisplayOrientation + */ +typedef enum SDL_SensorType +{ + SDL_SENSOR_INVALID = -1, /**< Returned for an invalid sensor */ + SDL_SENSOR_UNKNOWN, /**< Unknown sensor type */ + SDL_SENSOR_ACCEL, /**< Accelerometer */ + SDL_SENSOR_GYRO, /**< Gyroscope */ + SDL_SENSOR_ACCEL_L, /**< Accelerometer for left Joy-Con controller and Wii nunchuk */ + SDL_SENSOR_GYRO_L, /**< Gyroscope for left Joy-Con controller */ + SDL_SENSOR_ACCEL_R, /**< Accelerometer for right Joy-Con controller */ + SDL_SENSOR_GYRO_R, /**< Gyroscope for right Joy-Con controller */ + SDL_SENSOR_COUNT +} SDL_SensorType; + + +/* Function prototypes */ + +/** + * Get a list of currently connected sensors. + * + * \param count a pointer filled in with the number of sensors returned, may + * be NULL. + * \returns a 0 terminated array of sensor instance IDs or NULL on failure; + * call SDL_GetError() for more information. This should be freed + * with SDL_free() when it is no longer needed. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_SensorID * SDLCALL SDL_GetSensors(int *count); + +/** + * Get the implementation dependent name of a sensor. + * + * This can be called before any sensors are opened. + * + * \param instance_id the sensor instance ID. + * \returns the sensor name, or NULL if `instance_id` is not valid. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetSensorNameForID(SDL_SensorID instance_id); + +/** + * Get the type of a sensor. + * + * This can be called before any sensors are opened. + * + * \param instance_id the sensor instance ID. + * \returns the SDL_SensorType, or `SDL_SENSOR_INVALID` if `instance_id` is + * not valid. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_SensorType SDLCALL SDL_GetSensorTypeForID(SDL_SensorID instance_id); + +/** + * Get the platform dependent type of a sensor. + * + * This can be called before any sensors are opened. + * + * \param instance_id the sensor instance ID. + * \returns the sensor platform dependent type, or -1 if `instance_id` is not + * valid. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_GetSensorNonPortableTypeForID(SDL_SensorID instance_id); + +/** + * Open a sensor for use. + * + * \param instance_id the sensor instance ID. + * \returns an SDL_Sensor object or NULL on failure; call SDL_GetError() for + * more information. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_Sensor * SDLCALL SDL_OpenSensor(SDL_SensorID instance_id); + +/** + * Return the SDL_Sensor associated with an instance ID. + * + * \param instance_id the sensor instance ID. + * \returns an SDL_Sensor object or NULL on failure; call SDL_GetError() for + * more information. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_Sensor * SDLCALL SDL_GetSensorFromID(SDL_SensorID instance_id); + +/** + * Get the properties associated with a sensor. + * + * \param sensor the SDL_Sensor object. + * \returns a valid property ID on success or 0 on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetSensorProperties(SDL_Sensor *sensor); + +/** + * Get the implementation dependent name of a sensor. + * + * \param sensor the SDL_Sensor object. + * \returns the sensor name or NULL on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetSensorName(SDL_Sensor *sensor); + +/** + * Get the type of a sensor. + * + * \param sensor the SDL_Sensor object to inspect. + * \returns the SDL_SensorType type, or `SDL_SENSOR_INVALID` if `sensor` is + * NULL. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_SensorType SDLCALL SDL_GetSensorType(SDL_Sensor *sensor); + +/** + * Get the platform dependent type of a sensor. + * + * \param sensor the SDL_Sensor object to inspect. + * \returns the sensor platform dependent type, or -1 if `sensor` is NULL. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_GetSensorNonPortableType(SDL_Sensor *sensor); + +/** + * Get the instance ID of a sensor. + * + * \param sensor the SDL_Sensor object to inspect. + * \returns the sensor instance ID, or 0 on failure; call SDL_GetError() for + * more information. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_SensorID SDLCALL SDL_GetSensorID(SDL_Sensor *sensor); + +/** + * Get the current state of an opened sensor. + * + * The number of values and interpretation of the data is sensor dependent. + * + * \param sensor the SDL_Sensor object to query. + * \param data a pointer filled with the current sensor state. + * \param num_values the number of values to write to data. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetSensorData(SDL_Sensor *sensor, float *data, int num_values); + +/** + * Close a sensor previously opened with SDL_OpenSensor(). + * + * \param sensor the SDL_Sensor object to close. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_CloseSensor(SDL_Sensor *sensor); + +/** + * Update the current state of the open sensors. + * + * This is called automatically by the event loop if sensor events are + * enabled. + * + * This needs to be called from the thread that initialized the sensor + * subsystem. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_UpdateSensors(void); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +/* *INDENT-OFF* */ +} +/* *INDENT-ON* */ +#endif +#include + +#endif /* SDL_sensor_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_stdinc.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_stdinc.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,6168 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * # CategoryStdinc + * + * SDL provides its own implementation of some of the most important C runtime + * functions. + * + * Using these functions allows an app to have access to common C + * functionality without depending on a specific C runtime (or a C runtime at + * all). More importantly, the SDL implementations work identically across + * platforms, so apps can avoid surprises like snprintf() behaving differently + * between Windows and Linux builds, or itoa() only existing on some + * platforms. + * + * For many of the most common functions, like SDL_memcpy, SDL might just call + * through to the usual C runtime behind the scenes, if it makes sense to do + * so (if it's faster and always available/reliable on a given platform), + * reducing library size and offering the most optimized option. + * + * SDL also offers other C-runtime-adjacent functionality in this header that + * either isn't, strictly speaking, part of any C runtime standards, like + * SDL_crc32() and SDL_reinterpret_cast, etc. It also offers a few better + * options, like SDL_strlcpy(), which functions as a safer form of strcpy(). + */ + +#ifndef SDL_stdinc_h_ +#define SDL_stdinc_h_ + +#include + +#include +#include +#include + +/* Most everything except Visual Studio 2008 and earlier has stdint.h now */ +#if defined(_MSC_VER) && (_MSC_VER < 1600) +typedef signed __int8 int8_t; +typedef unsigned __int8 uint8_t; +typedef signed __int16 int16_t; +typedef unsigned __int16 uint16_t; +typedef signed __int32 int32_t; +typedef unsigned __int32 uint32_t; +typedef signed __int64 int64_t; +typedef unsigned __int64 uint64_t; +#ifndef _INTPTR_T_DEFINED +#ifdef _WIN64 +typedef __int64 intptr_t; +#else +typedef int intptr_t; +#endif +#endif +#ifndef _UINTPTR_T_DEFINED +#ifdef _WIN64 +typedef unsigned __int64 uintptr_t; +#else +typedef unsigned int uintptr_t; +#endif +#endif +#else +#include +#endif + +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \ + defined(SDL_INCLUDE_INTTYPES_H) +#include +#endif + +#ifndef __cplusplus +#if defined(__has_include) && !defined(SDL_INCLUDE_STDBOOL_H) +#if __has_include() +#define SDL_INCLUDE_STDBOOL_H +#endif +#endif +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \ + (defined(_MSC_VER) && (_MSC_VER >= 1910 /* Visual Studio 2017 */)) || \ + defined(SDL_INCLUDE_STDBOOL_H) +#include +#elif !defined(__bool_true_false_are_defined) && !defined(bool) +#define bool unsigned char +#define false 0 +#define true 1 +#define __bool_true_false_are_defined 1 +#endif +#endif /* !__cplusplus */ + +#ifndef SDL_DISABLE_ALLOCA +# ifndef alloca +# ifdef HAVE_ALLOCA_H +# include +# elif defined(SDL_PLATFORM_NETBSD) +# if defined(__STRICT_ANSI__) +# define SDL_DISABLE_ALLOCA +# else +# include +# endif +# elif defined(__GNUC__) +# define alloca __builtin_alloca +# elif defined(_MSC_VER) +# include +# define alloca _alloca +# elif defined(__WATCOMC__) +# include +# elif defined(__BORLANDC__) +# include +# elif defined(__DMC__) +# include +# elif defined(SDL_PLATFORM_AIX) +# pragma alloca +# elif defined(__MRC__) +void *alloca(unsigned); +# else +void *alloca(size_t); +# endif +# endif +#endif + + +#ifdef SDL_WIKI_DOCUMENTATION_SECTION + +/** + * Don't let SDL use "long long" C types. + * + * SDL will define this if it believes the compiler doesn't understand the + * "long long" syntax for C datatypes. This can happen on older compilers. + * + * If _your_ compiler doesn't support "long long" but SDL doesn't know it, it + * is safe to define this yourself to build against the SDL headers. + * + * If this is defined, it will remove access to some C runtime support + * functions, like SDL_ulltoa and SDL_strtoll that refer to this datatype + * explicitly. The rest of SDL will still be available. + * + * SDL's own source code cannot be built with a compiler that has this + * defined, for various technical reasons. + */ +#define SDL_NOLONGLONG 1 + +#elif defined(_MSC_VER) && (_MSC_VER < 1310) /* long long introduced in Visual Studio.NET 2003 */ +# define SDL_NOLONGLONG 1 +#endif + + +#ifdef SDL_WIKI_DOCUMENTATION_SECTION + +/** + * The largest value that a `size_t` can hold for the target platform. + * + * `size_t` is generally the same size as a pointer in modern times, but this + * can get weird on very old and very esoteric machines. For example, on a + * 16-bit Intel 286, you might have a 32-bit "far" pointer (16-bit segment + * plus 16-bit offset), but `size_t` is 16 bits, because it can only deal with + * the offset into an individual segment. + * + * In modern times, it's generally expected to cover an entire linear address + * space. But be careful! + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_SIZE_MAX SIZE_MAX + +#elif defined(SIZE_MAX) +# define SDL_SIZE_MAX SIZE_MAX +#else +# define SDL_SIZE_MAX ((size_t) -1) +#endif + +#ifndef SDL_COMPILE_TIME_ASSERT +#ifdef SDL_WIKI_DOCUMENTATION_SECTION + +/** + * A compile-time assertion. + * + * This can check constant values _known to the compiler at build time_ for + * correctness, and end the compile with the error if they fail. + * + * Often times these are used to verify basic truths, like the size of a + * datatype is what is expected: + * + * ```c + * SDL_COMPILE_TIME_ASSERT(uint32_size, sizeof(Uint32) == 4); + * ``` + * + * The `name` parameter must be a valid C symbol, and must be unique across + * all compile-time asserts in the same compilation unit (one run of the + * compiler), or the build might fail with cryptic errors on some targets. + * This is used with a C language trick that works on older compilers that + * don't support better assertion techniques. + * + * If you need an assertion that operates at runtime, on variable data, you + * should try SDL_assert instead. + * + * \param name a unique identifier for this assertion. + * \param x the value to test. Must be a boolean value. + * + * \threadsafety This macro doesn't generate any code to run. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_assert + */ +#define SDL_COMPILE_TIME_ASSERT(name, x) FailToCompileIf_x_IsFalse(x) +#elif defined(__cplusplus) +/* Keep C++ case alone: Some versions of gcc will define __STDC_VERSION__ even when compiling in C++ mode. */ +#if (__cplusplus >= 201103L) +#define SDL_COMPILE_TIME_ASSERT(name, x) static_assert(x, #x) +#endif +#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202311L) +#define SDL_COMPILE_TIME_ASSERT(name, x) static_assert(x, #x) +#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) +#define SDL_COMPILE_TIME_ASSERT(name, x) _Static_assert(x, #x) +#endif +#endif /* !SDL_COMPILE_TIME_ASSERT */ + +#ifndef SDL_COMPILE_TIME_ASSERT +/* universal, but may trigger -Wunused-local-typedefs */ +#define SDL_COMPILE_TIME_ASSERT(name, x) \ + typedef int SDL_compile_time_assert_ ## name[(x) * 2 - 1] +#endif + +/** + * The number of elements in a static array. + * + * This will compile but return incorrect results for a pointer to an array; + * it has to be an array the compiler knows the size of. + * + * This macro looks like it double-evaluates the argument, but it does so + * inside of `sizeof`, so there are no side-effects here, as expressions do + * not actually run any code in these cases. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_arraysize(array) (sizeof(array)/sizeof(array[0])) + +/** + * Macro useful for building other macros with strings in them. + * + * For example: + * + * ```c + * #define LOG_ERROR(X) OutputDebugString(SDL_STRINGIFY_ARG(__FUNCTION__) ": " X "\n")` + * ``` + * + * \param arg the text to turn into a string literal. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_STRINGIFY_ARG(arg) #arg + +/** + * \name Cast operators + * + * Use proper C++ casts when compiled as C++ to be compatible with the option + * -Wold-style-cast of GCC (and -Werror=old-style-cast in GCC 4.2 and above). + */ +/* @{ */ + +#ifdef SDL_WIKI_DOCUMENTATION_SECTION + +/** + * Handle a Reinterpret Cast properly whether using C or C++. + * + * If compiled as C++, this macro offers a proper C++ reinterpret_cast<>. + * + * If compiled as C, this macro does a normal C-style cast. + * + * This is helpful to avoid compiler warnings in C++. + * + * \param type the type to cast the expression to. + * \param expression the expression to cast to a different type. + * \returns `expression`, cast to `type`. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_static_cast + * \sa SDL_const_cast + */ +#define SDL_reinterpret_cast(type, expression) reinterpret_cast(expression) /* or `((type)(expression))` in C */ + +/** + * Handle a Static Cast properly whether using C or C++. + * + * If compiled as C++, this macro offers a proper C++ static_cast<>. + * + * If compiled as C, this macro does a normal C-style cast. + * + * This is helpful to avoid compiler warnings in C++. + * + * \param type the type to cast the expression to. + * \param expression the expression to cast to a different type. + * \returns `expression`, cast to `type`. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_reinterpret_cast + * \sa SDL_const_cast + */ +#define SDL_static_cast(type, expression) static_cast(expression) /* or `((type)(expression))` in C */ + +/** + * Handle a Const Cast properly whether using C or C++. + * + * If compiled as C++, this macro offers a proper C++ const_cast<>. + * + * If compiled as C, this macro does a normal C-style cast. + * + * This is helpful to avoid compiler warnings in C++. + * + * \param type the type to cast the expression to. + * \param expression the expression to cast to a different type. + * \returns `expression`, cast to `type`. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_reinterpret_cast + * \sa SDL_static_cast + */ +#define SDL_const_cast(type, expression) const_cast(expression) /* or `((type)(expression))` in C */ + +#elif defined(__cplusplus) +#define SDL_reinterpret_cast(type, expression) reinterpret_cast(expression) +#define SDL_static_cast(type, expression) static_cast(expression) +#define SDL_const_cast(type, expression) const_cast(expression) +#else +#define SDL_reinterpret_cast(type, expression) ((type)(expression)) +#define SDL_static_cast(type, expression) ((type)(expression)) +#define SDL_const_cast(type, expression) ((type)(expression)) +#endif + +/* @} *//* Cast operators */ + +/** + * Define a four character code as a Uint32. + * + * \param A the first ASCII character. + * \param B the second ASCII character. + * \param C the third ASCII character. + * \param D the fourth ASCII character. + * \returns the four characters converted into a Uint32, one character + * per-byte. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_FOURCC(A, B, C, D) \ + ((SDL_static_cast(Uint32, SDL_static_cast(Uint8, (A))) << 0) | \ + (SDL_static_cast(Uint32, SDL_static_cast(Uint8, (B))) << 8) | \ + (SDL_static_cast(Uint32, SDL_static_cast(Uint8, (C))) << 16) | \ + (SDL_static_cast(Uint32, SDL_static_cast(Uint8, (D))) << 24)) + +#ifdef SDL_WIKI_DOCUMENTATION_SECTION + +/** + * Append the 64 bit integer suffix to a signed integer literal. + * + * This helps compilers that might believe a integer literal larger than + * 0xFFFFFFFF is overflowing a 32-bit value. Use `SDL_SINT64_C(0xFFFFFFFF1)` + * instead of `0xFFFFFFFF1` by itself. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_UINT64_C + */ +#define SDL_SINT64_C(c) c ## LL /* or whatever the current compiler uses. */ + +/** + * Append the 64 bit integer suffix to an unsigned integer literal. + * + * This helps compilers that might believe a integer literal larger than + * 0xFFFFFFFF is overflowing a 32-bit value. Use `SDL_UINT64_C(0xFFFFFFFF1)` + * instead of `0xFFFFFFFF1` by itself. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_SINT64_C + */ +#define SDL_UINT64_C(c) c ## ULL /* or whatever the current compiler uses. */ + +#else /* !SDL_WIKI_DOCUMENTATION_SECTION */ + +#ifndef SDL_SINT64_C +#if defined(INT64_C) +#define SDL_SINT64_C(c) INT64_C(c) +#elif defined(_MSC_VER) +#define SDL_SINT64_C(c) c ## i64 +#elif defined(__LP64__) || defined(_LP64) +#define SDL_SINT64_C(c) c ## L +#else +#define SDL_SINT64_C(c) c ## LL +#endif +#endif /* !SDL_SINT64_C */ + +#ifndef SDL_UINT64_C +#if defined(UINT64_C) +#define SDL_UINT64_C(c) UINT64_C(c) +#elif defined(_MSC_VER) +#define SDL_UINT64_C(c) c ## ui64 +#elif defined(__LP64__) || defined(_LP64) +#define SDL_UINT64_C(c) c ## UL +#else +#define SDL_UINT64_C(c) c ## ULL +#endif +#endif /* !SDL_UINT64_C */ + +#endif /* !SDL_WIKI_DOCUMENTATION_SECTION */ + +/** + * \name Basic data types + */ +/* @{ */ + +/** + * A signed 8-bit integer type. + * + * \since This macro is available since SDL 3.2.0. + */ +typedef int8_t Sint8; +#define SDL_MAX_SINT8 ((Sint8)0x7F) /* 127 */ +#define SDL_MIN_SINT8 ((Sint8)(~0x7F)) /* -128 */ + +/** + * An unsigned 8-bit integer type. + * + * \since This macro is available since SDL 3.2.0. + */ +typedef uint8_t Uint8; +#define SDL_MAX_UINT8 ((Uint8)0xFF) /* 255 */ +#define SDL_MIN_UINT8 ((Uint8)0x00) /* 0 */ + +/** + * A signed 16-bit integer type. + * + * \since This macro is available since SDL 3.2.0. + */ +typedef int16_t Sint16; +#define SDL_MAX_SINT16 ((Sint16)0x7FFF) /* 32767 */ +#define SDL_MIN_SINT16 ((Sint16)(~0x7FFF)) /* -32768 */ + +/** + * An unsigned 16-bit integer type. + * + * \since This macro is available since SDL 3.2.0. + */ +typedef uint16_t Uint16; +#define SDL_MAX_UINT16 ((Uint16)0xFFFF) /* 65535 */ +#define SDL_MIN_UINT16 ((Uint16)0x0000) /* 0 */ + +/** + * A signed 32-bit integer type. + * + * \since This macro is available since SDL 3.2.0. + */ +typedef int32_t Sint32; +#define SDL_MAX_SINT32 ((Sint32)0x7FFFFFFF) /* 2147483647 */ +#define SDL_MIN_SINT32 ((Sint32)(~0x7FFFFFFF)) /* -2147483648 */ + +/** + * An unsigned 32-bit integer type. + * + * \since This macro is available since SDL 3.2.0. + */ +typedef uint32_t Uint32; +#define SDL_MAX_UINT32 ((Uint32)0xFFFFFFFFu) /* 4294967295 */ +#define SDL_MIN_UINT32 ((Uint32)0x00000000) /* 0 */ + +/** + * A signed 64-bit integer type. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_SINT64_C + */ +typedef int64_t Sint64; +#define SDL_MAX_SINT64 SDL_SINT64_C(0x7FFFFFFFFFFFFFFF) /* 9223372036854775807 */ +#define SDL_MIN_SINT64 ~SDL_SINT64_C(0x7FFFFFFFFFFFFFFF) /* -9223372036854775808 */ + +/** + * An unsigned 64-bit integer type. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_UINT64_C + */ +typedef uint64_t Uint64; +#define SDL_MAX_UINT64 SDL_UINT64_C(0xFFFFFFFFFFFFFFFF) /* 18446744073709551615 */ +#define SDL_MIN_UINT64 SDL_UINT64_C(0x0000000000000000) /* 0 */ + +/** + * SDL times are signed, 64-bit integers representing nanoseconds since the + * Unix epoch (Jan 1, 1970). + * + * They can be converted between POSIX time_t values with SDL_NS_TO_SECONDS() + * and SDL_SECONDS_TO_NS(), and between Windows FILETIME values with + * SDL_TimeToWindows() and SDL_TimeFromWindows(). + * + * \since This datatype is available since SDL 3.2.0. + * + * \sa SDL_MAX_SINT64 + * \sa SDL_MIN_SINT64 + */ +typedef Sint64 SDL_Time; +#define SDL_MAX_TIME SDL_MAX_SINT64 +#define SDL_MIN_TIME SDL_MIN_SINT64 + +/* @} *//* Basic data types */ + +/** + * \name Floating-point constants + */ +/* @{ */ + +#ifdef FLT_EPSILON +#define SDL_FLT_EPSILON FLT_EPSILON +#else + +/** + * Epsilon constant, used for comparing floating-point numbers. + * + * Equals by default to platform-defined `FLT_EPSILON`, or + * `1.1920928955078125e-07F` if that's not available. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_FLT_EPSILON 1.1920928955078125e-07F /* 0x0.000002p0 */ +#endif + +/* @} *//* Floating-point constants */ + +#ifdef SDL_WIKI_DOCUMENTATION_SECTION + +/** + * A printf-formatting string for an Sint64 value. + * + * Use it like this: + * + * ```c + * SDL_Log("There are %" SDL_PRIs64 " bottles of beer on the wall.", bottles); + * ``` + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PRIs64 "lld" + +/** + * A printf-formatting string for a Uint64 value. + * + * Use it like this: + * + * ```c + * SDL_Log("There are %" SDL_PRIu64 " bottles of beer on the wall.", bottles); + * ``` + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PRIu64 "llu" + +/** + * A printf-formatting string for a Uint64 value as lower-case hexadecimal. + * + * Use it like this: + * + * ```c + * SDL_Log("There are %" SDL_PRIx64 " bottles of beer on the wall.", bottles); + * ``` + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PRIx64 "llx" + +/** + * A printf-formatting string for a Uint64 value as upper-case hexadecimal. + * + * Use it like this: + * + * ```c + * SDL_Log("There are %" SDL_PRIX64 " bottles of beer on the wall.", bottles); + * ``` + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PRIX64 "llX" + +/** + * A printf-formatting string for an Sint32 value. + * + * Use it like this: + * + * ```c + * SDL_Log("There are %" SDL_PRIs32 " bottles of beer on the wall.", bottles); + * ``` + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PRIs32 "d" + +/** + * A printf-formatting string for a Uint32 value. + * + * Use it like this: + * + * ```c + * SDL_Log("There are %" SDL_PRIu32 " bottles of beer on the wall.", bottles); + * ``` + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PRIu32 "u" + +/** + * A printf-formatting string for a Uint32 value as lower-case hexadecimal. + * + * Use it like this: + * + * ```c + * SDL_Log("There are %" SDL_PRIx32 " bottles of beer on the wall.", bottles); + * ``` + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PRIx32 "x" + +/** + * A printf-formatting string for a Uint32 value as upper-case hexadecimal. + * + * Use it like this: + * + * ```c + * SDL_Log("There are %" SDL_PRIX32 " bottles of beer on the wall.", bottles); + * ``` + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PRIX32 "X" + +/** + * A printf-formatting string prefix for a `long long` value. + * + * This is just the prefix! You probably actually want SDL_PRILLd, SDL_PRILLu, + * SDL_PRILLx, or SDL_PRILLX instead. + * + * Use it like this: + * + * ```c + * SDL_Log("There are %" SDL_PRILL_PREFIX "d bottles of beer on the wall.", bottles); + * ``` + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PRILL_PREFIX "ll" + +/** + * A printf-formatting string for a `long long` value. + * + * Use it like this: + * + * ```c + * SDL_Log("There are %" SDL_PRILLd " bottles of beer on the wall.", bottles); + * ``` + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PRILLd SDL_PRILL_PREFIX "d" + +/** + * A printf-formatting string for a `unsigned long long` value. + * + * Use it like this: + * + * ```c + * SDL_Log("There are %" SDL_PRILLu " bottles of beer on the wall.", bottles); + * ``` + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PRILLu SDL_PRILL_PREFIX "u" + +/** + * A printf-formatting string for an `unsigned long long` value as lower-case + * hexadecimal. + * + * Use it like this: + * + * ```c + * SDL_Log("There are %" SDL_PRILLx " bottles of beer on the wall.", bottles); + * ``` + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PRILLx SDL_PRILL_PREFIX "x" + +/** + * A printf-formatting string for an `unsigned long long` value as upper-case + * hexadecimal. + * + * Use it like this: + * + * ```c + * SDL_Log("There are %" SDL_PRILLX " bottles of beer on the wall.", bottles); + * ``` + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PRILLX SDL_PRILL_PREFIX "X" +#endif /* SDL_WIKI_DOCUMENTATION_SECTION */ + +/* Make sure we have macros for printing width-based integers. + * should define these but this is not true all platforms. + * (for example win32) */ +#ifndef SDL_PRIs64 +#if defined(SDL_PLATFORM_WINDOWS) +#define SDL_PRIs64 "I64d" +#elif defined(PRId64) +#define SDL_PRIs64 PRId64 +#elif defined(__LP64__) && !defined(SDL_PLATFORM_APPLE) && !defined(__EMSCRIPTEN__) +#define SDL_PRIs64 "ld" +#else +#define SDL_PRIs64 "lld" +#endif +#endif +#ifndef SDL_PRIu64 +#if defined(SDL_PLATFORM_WINDOWS) +#define SDL_PRIu64 "I64u" +#elif defined(PRIu64) +#define SDL_PRIu64 PRIu64 +#elif defined(__LP64__) && !defined(SDL_PLATFORM_APPLE) && !defined(__EMSCRIPTEN__) +#define SDL_PRIu64 "lu" +#else +#define SDL_PRIu64 "llu" +#endif +#endif +#ifndef SDL_PRIx64 +#if defined(SDL_PLATFORM_WINDOWS) +#define SDL_PRIx64 "I64x" +#elif defined(PRIx64) +#define SDL_PRIx64 PRIx64 +#elif defined(__LP64__) && !defined(SDL_PLATFORM_APPLE) +#define SDL_PRIx64 "lx" +#else +#define SDL_PRIx64 "llx" +#endif +#endif +#ifndef SDL_PRIX64 +#if defined(SDL_PLATFORM_WINDOWS) +#define SDL_PRIX64 "I64X" +#elif defined(PRIX64) +#define SDL_PRIX64 PRIX64 +#elif defined(__LP64__) && !defined(SDL_PLATFORM_APPLE) +#define SDL_PRIX64 "lX" +#else +#define SDL_PRIX64 "llX" +#endif +#endif +#ifndef SDL_PRIs32 +#ifdef PRId32 +#define SDL_PRIs32 PRId32 +#else +#define SDL_PRIs32 "d" +#endif +#endif +#ifndef SDL_PRIu32 +#ifdef PRIu32 +#define SDL_PRIu32 PRIu32 +#else +#define SDL_PRIu32 "u" +#endif +#endif +#ifndef SDL_PRIx32 +#ifdef PRIx32 +#define SDL_PRIx32 PRIx32 +#else +#define SDL_PRIx32 "x" +#endif +#endif +#ifndef SDL_PRIX32 +#ifdef PRIX32 +#define SDL_PRIX32 PRIX32 +#else +#define SDL_PRIX32 "X" +#endif +#endif +/* Specifically for the `long long` -- SDL-specific. */ +#ifdef SDL_PLATFORM_WINDOWS +#ifndef SDL_NOLONGLONG +SDL_COMPILE_TIME_ASSERT(longlong_size64, sizeof(long long) == 8); /* using I64 for windows - make sure `long long` is 64 bits. */ +#endif +#define SDL_PRILL_PREFIX "I64" +#else +#define SDL_PRILL_PREFIX "ll" +#endif +#ifndef SDL_PRILLd +#define SDL_PRILLd SDL_PRILL_PREFIX "d" +#endif +#ifndef SDL_PRILLu +#define SDL_PRILLu SDL_PRILL_PREFIX "u" +#endif +#ifndef SDL_PRILLx +#define SDL_PRILLx SDL_PRILL_PREFIX "x" +#endif +#ifndef SDL_PRILLX +#define SDL_PRILLX SDL_PRILL_PREFIX "X" +#endif + +/* Annotations to help code analysis tools */ +#ifdef SDL_WIKI_DOCUMENTATION_SECTION + +/** + * Macro that annotates function params with input buffer size. + * + * If we were to annotate `memcpy`: + * + * ```c + * void *memcpy(void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len); + * ``` + * + * This notes that `src` should be `len` bytes in size and is only read by the + * function. The compiler or other analysis tools can warn when this doesn't + * appear to be the case. + * + * On compilers without this annotation mechanism, this is defined to nothing. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_IN_BYTECAP(x) _In_bytecount_(x) + +/** + * Macro that annotates function params with input/output string buffer size. + * + * If we were to annotate `strlcat`: + * + * ```c + * size_t strlcat(SDL_INOUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen); + * ``` + * + * This notes that `dst` is a null-terminated C string, should be `maxlen` + * bytes in size, and is both read from and written to by the function. The + * compiler or other analysis tools can warn when this doesn't appear to be + * the case. + * + * On compilers without this annotation mechanism, this is defined to nothing. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_INOUT_Z_CAP(x) _Inout_z_cap_(x) + +/** + * Macro that annotates function params with output string buffer size. + * + * If we were to annotate `snprintf`: + * + * ```c + * int snprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, const char *fmt, ...); + * ``` + * + * This notes that `text` is a null-terminated C string, should be `maxlen` + * bytes in size, and is only written to by the function. The compiler or + * other analysis tools can warn when this doesn't appear to be the case. + * + * On compilers without this annotation mechanism, this is defined to nothing. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_OUT_Z_CAP(x) _Out_z_cap_(x) + +/** + * Macro that annotates function params with output buffer size. + * + * If we were to annotate `wcsncpy`: + * + * ```c + * char *wcscpy(SDL_OUT_CAP(bufsize) wchar_t *dst, const wchar_t *src, size_t bufsize); + * ``` + * + * This notes that `dst` should have a capacity of `bufsize` wchar_t in size, + * and is only written to by the function. The compiler or other analysis + * tools can warn when this doesn't appear to be the case. + * + * This operates on counts of objects, not bytes. Use SDL_OUT_BYTECAP for + * bytes. + * + * On compilers without this annotation mechanism, this is defined to nothing. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_OUT_CAP(x) _Out_cap_(x) + +/** + * Macro that annotates function params with output buffer size. + * + * If we were to annotate `memcpy`: + * + * ```c + * void *memcpy(SDL_OUT_BYTECAP(bufsize) void *dst, const void *src, size_t bufsize); + * ``` + * + * This notes that `dst` should have a capacity of `bufsize` bytes in size, + * and is only written to by the function. The compiler or other analysis + * tools can warn when this doesn't appear to be the case. + * + * On compilers without this annotation mechanism, this is defined to nothing. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_OUT_BYTECAP(x) _Out_bytecap_(x) + +/** + * Macro that annotates function params with output buffer string size. + * + * If we were to annotate `strcpy`: + * + * ```c + * char *strcpy(SDL_OUT_Z_BYTECAP(bufsize) char *dst, const char *src, size_t bufsize); + * ``` + * + * This notes that `dst` should have a capacity of `bufsize` bytes in size, + * and a zero-terminated string is written to it by the function. The compiler + * or other analysis tools can warn when this doesn't appear to be the case. + * + * On compilers without this annotation mechanism, this is defined to nothing. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_OUT_Z_BYTECAP(x) _Out_z_bytecap_(x) + +/** + * Macro that annotates function params as printf-style format strings. + * + * If we were to annotate `fprintf`: + * + * ```c + * int fprintf(FILE *f, SDL_PRINTF_FORMAT_STRING const char *fmt, ...); + * ``` + * + * This notes that `fmt` should be a printf-style format string. The compiler + * or other analysis tools can warn when this doesn't appear to be the case. + * + * On compilers without this annotation mechanism, this is defined to nothing. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PRINTF_FORMAT_STRING _Printf_format_string_ + +/** + * Macro that annotates function params as scanf-style format strings. + * + * If we were to annotate `fscanf`: + * + * ```c + * int fscanf(FILE *f, SDL_SCANF_FORMAT_STRING const char *fmt, ...); + * ``` + * + * This notes that `fmt` should be a scanf-style format string. The compiler + * or other analysis tools can warn when this doesn't appear to be the case. + * + * On compilers without this annotation mechanism, this is defined to nothing. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_SCANF_FORMAT_STRING _Scanf_format_string_impl_ + +/** + * Macro that annotates a vararg function that operates like printf. + * + * If we were to annotate `fprintf`: + * + * ```c + * int fprintf(FILE *f, const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); + * ``` + * + * This notes that the second parameter should be a printf-style format + * string, followed by `...`. The compiler or other analysis tools can warn + * when this doesn't appear to be the case. + * + * On compilers without this annotation mechanism, this is defined to nothing. + * + * This can (and should) be used with SDL_PRINTF_FORMAT_STRING as well, which + * between them will cover at least Visual Studio, GCC, and Clang. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PRINTF_VARARG_FUNC( fmtargnumber ) __attribute__ (( format( __printf__, fmtargnumber, fmtargnumber+1 ))) + +/** + * Macro that annotates a va_list function that operates like printf. + * + * If we were to annotate `vfprintf`: + * + * ```c + * int vfprintf(FILE *f, const char *fmt, va_list ap) SDL_PRINTF_VARARG_FUNCV(2); + * ``` + * + * This notes that the second parameter should be a printf-style format + * string, followed by a va_list. The compiler or other analysis tools can + * warn when this doesn't appear to be the case. + * + * On compilers without this annotation mechanism, this is defined to nothing. + * + * This can (and should) be used with SDL_PRINTF_FORMAT_STRING as well, which + * between them will cover at least Visual Studio, GCC, and Clang. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PRINTF_VARARG_FUNCV( fmtargnumber ) __attribute__(( format( __printf__, fmtargnumber, 0 ))) + +/** + * Macro that annotates a vararg function that operates like scanf. + * + * If we were to annotate `fscanf`: + * + * ```c + * int fscanf(FILE *f, const char *fmt, ...) SDL_PRINTF_VARARG_FUNCV(2); + * ``` + * + * This notes that the second parameter should be a scanf-style format string, + * followed by `...`. The compiler or other analysis tools can warn when this + * doesn't appear to be the case. + * + * On compilers without this annotation mechanism, this is defined to nothing. + * + * This can (and should) be used with SDL_SCANF_FORMAT_STRING as well, which + * between them will cover at least Visual Studio, GCC, and Clang. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_SCANF_VARARG_FUNC( fmtargnumber ) __attribute__ (( format( __scanf__, fmtargnumber, fmtargnumber+1 ))) + +/** + * Macro that annotates a va_list function that operates like scanf. + * + * If we were to annotate `vfscanf`: + * + * ```c + * int vfscanf(FILE *f, const char *fmt, va_list ap) SDL_PRINTF_VARARG_FUNCV(2); + * ``` + * + * This notes that the second parameter should be a scanf-style format string, + * followed by a va_list. The compiler or other analysis tools can warn when + * this doesn't appear to be the case. + * + * On compilers without this annotation mechanism, this is defined to nothing. + * + * This can (and should) be used with SDL_SCANF_FORMAT_STRING as well, which + * between them will cover at least Visual Studio, GCC, and Clang. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_SCANF_VARARG_FUNCV( fmtargnumber ) __attribute__(( format( __scanf__, fmtargnumber, 0 ))) + +/** + * Macro that annotates a vararg function that operates like wprintf. + * + * If we were to annotate `fwprintf`: + * + * ```c + * int fwprintf(FILE *f, const wchar_t *fmt, ...) SDL_WPRINTF_VARARG_FUNC(2); + * ``` + * + * This notes that the second parameter should be a wprintf-style format wide + * string, followed by `...`. The compiler or other analysis tools can warn + * when this doesn't appear to be the case. + * + * On compilers without this annotation mechanism, this is defined to nothing. + * + * This can (and should) be used with SDL_PRINTF_FORMAT_STRING as well, which + * between them will cover at least Visual Studio, GCC, and Clang. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_WPRINTF_VARARG_FUNC( fmtargnumber ) /* __attribute__ (( format( __wprintf__, fmtargnumber, fmtargnumber+1 ))) */ + +/** + * Macro that annotates a va_list function that operates like wprintf. + * + * If we were to annotate `vfwprintf`: + * + * ```c + * int vfwprintf(FILE *f, const wchar_t *fmt, va_list ap) SDL_WPRINTF_VARARG_FUNC(2); + * ``` + * + * This notes that the second parameter should be a wprintf-style format wide + * string, followed by a va_list. The compiler or other analysis tools can + * warn when this doesn't appear to be the case. + * + * On compilers without this annotation mechanism, this is defined to nothing. + * + * This can (and should) be used with SDL_PRINTF_FORMAT_STRING as well, which + * between them will cover at least Visual Studio, GCC, and Clang. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_WPRINTF_VARARG_FUNCV( fmtargnumber ) /* __attribute__ (( format( __wprintf__, fmtargnumber, 0 ))) */ + +#elif defined(SDL_DISABLE_ANALYZE_MACROS) +#define SDL_IN_BYTECAP(x) +#define SDL_INOUT_Z_CAP(x) +#define SDL_OUT_Z_CAP(x) +#define SDL_OUT_CAP(x) +#define SDL_OUT_BYTECAP(x) +#define SDL_OUT_Z_BYTECAP(x) +#define SDL_PRINTF_FORMAT_STRING +#define SDL_SCANF_FORMAT_STRING +#define SDL_PRINTF_VARARG_FUNC( fmtargnumber ) +#define SDL_PRINTF_VARARG_FUNCV( fmtargnumber ) +#define SDL_SCANF_VARARG_FUNC( fmtargnumber ) +#define SDL_SCANF_VARARG_FUNCV( fmtargnumber ) +#define SDL_WPRINTF_VARARG_FUNC( fmtargnumber ) +#define SDL_WPRINTF_VARARG_FUNCV( fmtargnumber ) +#else +#if defined(_MSC_VER) && (_MSC_VER >= 1600) /* VS 2010 and above */ +#include + +#define SDL_IN_BYTECAP(x) _In_bytecount_(x) +#define SDL_INOUT_Z_CAP(x) _Inout_z_cap_(x) +#define SDL_OUT_Z_CAP(x) _Out_z_cap_(x) +#define SDL_OUT_CAP(x) _Out_cap_(x) +#define SDL_OUT_BYTECAP(x) _Out_bytecap_(x) +#define SDL_OUT_Z_BYTECAP(x) _Out_z_bytecap_(x) + +#define SDL_PRINTF_FORMAT_STRING _Printf_format_string_ +#define SDL_SCANF_FORMAT_STRING _Scanf_format_string_impl_ +#else +#define SDL_IN_BYTECAP(x) +#define SDL_INOUT_Z_CAP(x) +#define SDL_OUT_Z_CAP(x) +#define SDL_OUT_CAP(x) +#define SDL_OUT_BYTECAP(x) +#define SDL_OUT_Z_BYTECAP(x) +#define SDL_PRINTF_FORMAT_STRING +#define SDL_SCANF_FORMAT_STRING +#endif +#if defined(__GNUC__) || defined(__clang__) +#define SDL_PRINTF_VARARG_FUNC( fmtargnumber ) __attribute__ (( format( __printf__, fmtargnumber, fmtargnumber+1 ))) +#define SDL_PRINTF_VARARG_FUNCV( fmtargnumber ) __attribute__(( format( __printf__, fmtargnumber, 0 ))) +#define SDL_SCANF_VARARG_FUNC( fmtargnumber ) __attribute__ (( format( __scanf__, fmtargnumber, fmtargnumber+1 ))) +#define SDL_SCANF_VARARG_FUNCV( fmtargnumber ) __attribute__(( format( __scanf__, fmtargnumber, 0 ))) +#define SDL_WPRINTF_VARARG_FUNC( fmtargnumber ) /* __attribute__ (( format( __wprintf__, fmtargnumber, fmtargnumber+1 ))) */ +#define SDL_WPRINTF_VARARG_FUNCV( fmtargnumber ) /* __attribute__ (( format( __wprintf__, fmtargnumber, 0 ))) */ +#else +#define SDL_PRINTF_VARARG_FUNC( fmtargnumber ) +#define SDL_PRINTF_VARARG_FUNCV( fmtargnumber ) +#define SDL_SCANF_VARARG_FUNC( fmtargnumber ) +#define SDL_SCANF_VARARG_FUNCV( fmtargnumber ) +#define SDL_WPRINTF_VARARG_FUNC( fmtargnumber ) +#define SDL_WPRINTF_VARARG_FUNCV( fmtargnumber ) +#endif +#endif /* SDL_DISABLE_ANALYZE_MACROS */ + +/** \cond */ +#ifndef DOXYGEN_SHOULD_IGNORE_THIS +SDL_COMPILE_TIME_ASSERT(bool_size, sizeof(bool) == 1); +SDL_COMPILE_TIME_ASSERT(uint8_size, sizeof(Uint8) == 1); +SDL_COMPILE_TIME_ASSERT(sint8_size, sizeof(Sint8) == 1); +SDL_COMPILE_TIME_ASSERT(uint16_size, sizeof(Uint16) == 2); +SDL_COMPILE_TIME_ASSERT(sint16_size, sizeof(Sint16) == 2); +SDL_COMPILE_TIME_ASSERT(uint32_size, sizeof(Uint32) == 4); +SDL_COMPILE_TIME_ASSERT(sint32_size, sizeof(Sint32) == 4); +SDL_COMPILE_TIME_ASSERT(uint64_size, sizeof(Uint64) == 8); +SDL_COMPILE_TIME_ASSERT(sint64_size, sizeof(Sint64) == 8); +#ifndef SDL_NOLONGLONG +SDL_COMPILE_TIME_ASSERT(uint64_longlong, sizeof(Uint64) <= sizeof(unsigned long long)); +SDL_COMPILE_TIME_ASSERT(size_t_longlong, sizeof(size_t) <= sizeof(unsigned long long)); +#endif +typedef struct SDL_alignment_test +{ + Uint8 a; + void *b; +} SDL_alignment_test; +SDL_COMPILE_TIME_ASSERT(struct_alignment, sizeof(SDL_alignment_test) == (2 * sizeof(void *))); +SDL_COMPILE_TIME_ASSERT(two_s_complement, SDL_static_cast(int, ~SDL_static_cast(int, 0)) == SDL_static_cast(int, -1)); +#endif /* DOXYGEN_SHOULD_IGNORE_THIS */ +/** \endcond */ + +/* Check to make sure enums are the size of ints, for structure packing. + For both Watcom C/C++ and Borland C/C++ the compiler option that makes + enums having the size of an int must be enabled. + This is "-b" for Borland C/C++ and "-ei" for Watcom C/C++ (v11). +*/ + +/** \cond */ +#ifndef DOXYGEN_SHOULD_IGNORE_THIS +#if !defined(SDL_PLATFORM_VITA) && !defined(SDL_PLATFORM_3DS) +/* TODO: include/SDL_stdinc.h:390: error: size of array 'SDL_dummy_enum' is negative */ +typedef enum SDL_DUMMY_ENUM +{ + DUMMY_ENUM_VALUE +} SDL_DUMMY_ENUM; + +SDL_COMPILE_TIME_ASSERT(enum, sizeof(SDL_DUMMY_ENUM) == sizeof(int)); +#endif +#endif /* DOXYGEN_SHOULD_IGNORE_THIS */ +/** \endcond */ + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * A macro to initialize an SDL interface. + * + * This macro will initialize an SDL interface structure and should be called + * before you fill out the fields with your implementation. + * + * You can use it like this: + * + * ```c + * SDL_IOStreamInterface iface; + * + * SDL_INIT_INTERFACE(&iface); + * + * // Fill in the interface function pointers with your implementation + * iface.seek = ... + * + * stream = SDL_OpenIO(&iface, NULL); + * ``` + * + * If you are using designated initializers, you can use the size of the + * interface as the version, e.g. + * + * ```c + * SDL_IOStreamInterface iface = { + * .version = sizeof(iface), + * .seek = ... + * }; + * stream = SDL_OpenIO(&iface, NULL); + * ``` + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_IOStreamInterface + * \sa SDL_StorageInterface + * \sa SDL_VirtualJoystickDesc + */ +#define SDL_INIT_INTERFACE(iface) \ + do { \ + SDL_zerop(iface); \ + (iface)->version = sizeof(*(iface)); \ + } while (0) + + +#ifdef SDL_WIKI_DOCUMENTATION_SECTION + +/** + * Allocate memory on the stack (maybe). + * + * If SDL knows how to access alloca() on the current platform, it will use it + * to stack-allocate memory here. If it doesn't, it will use SDL_malloc() to + * heap-allocate memory. + * + * Since this might not be stack memory at all, it's important that you check + * the returned pointer for NULL, and that you call SDL_stack_free on the + * memory when done with it. Since this might be stack memory, it's important + * that you don't allocate large amounts of it, or allocate in a loop without + * returning from the function, so the stack doesn't overflow. + * + * \param type the datatype of the memory to allocate. + * \param count the number of `type` objects to allocate. + * \returns newly-allocated memory, or NULL on failure. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_stack_free + */ +#define SDL_stack_alloc(type, count) (type*)alloca(sizeof(type)*(count)) + +/** + * Free memory previously allocated with SDL_stack_alloc. + * + * If SDL used alloca() to allocate this memory, this macro does nothing and + * the allocated memory will be automatically released when the function that + * called SDL_stack_alloc() returns. If SDL used SDL_malloc(), it will + * SDL_free the memory immediately. + * + * \param data the pointer, from SDL_stack_alloc(), to free. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_stack_alloc + */ +#define SDL_stack_free(data) +#elif !defined(SDL_DISABLE_ALLOCA) +#define SDL_stack_alloc(type, count) (type*)alloca(sizeof(type)*(count)) +#define SDL_stack_free(data) +#else +#define SDL_stack_alloc(type, count) (type*)SDL_malloc(sizeof(type)*(count)) +#define SDL_stack_free(data) SDL_free(data) +#endif + +/** + * Allocate uninitialized memory. + * + * The allocated memory returned by this function must be freed with + * SDL_free(). + * + * If `size` is 0, it will be set to 1. + * + * If the allocation is successful, the returned pointer is guaranteed to be + * aligned to either the *fundamental alignment* (`alignof(max_align_t)` in + * C11 and later) or `2 * sizeof(void *)`, whichever is smaller. Use + * SDL_aligned_alloc() if you need to allocate memory aligned to an alignment + * greater than this guarantee. + * + * \param size the size to allocate. + * \returns a pointer to the allocated memory, or NULL if allocation failed. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_free + * \sa SDL_calloc + * \sa SDL_realloc + * \sa SDL_aligned_alloc + */ +extern SDL_DECLSPEC SDL_MALLOC void * SDLCALL SDL_malloc(size_t size); + +/** + * Allocate a zero-initialized array. + * + * The memory returned by this function must be freed with SDL_free(). + * + * If either of `nmemb` or `size` is 0, they will both be set to 1. + * + * If the allocation is successful, the returned pointer is guaranteed to be + * aligned to either the *fundamental alignment* (`alignof(max_align_t)` in + * C11 and later) or `2 * sizeof(void *)`, whichever is smaller. + * + * \param nmemb the number of elements in the array. + * \param size the size of each element of the array. + * \returns a pointer to the allocated array, or NULL if allocation failed. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_free + * \sa SDL_malloc + * \sa SDL_realloc + */ +extern SDL_DECLSPEC SDL_MALLOC SDL_ALLOC_SIZE2(1, 2) void * SDLCALL SDL_calloc(size_t nmemb, size_t size); + +/** + * Change the size of allocated memory. + * + * The memory returned by this function must be freed with SDL_free(). + * + * If `size` is 0, it will be set to 1. Note that this is unlike some other C + * runtime `realloc` implementations, which may treat `realloc(mem, 0)` the + * same way as `free(mem)`. + * + * If `mem` is NULL, the behavior of this function is equivalent to + * SDL_malloc(). Otherwise, the function can have one of three possible + * outcomes: + * + * - If it returns the same pointer as `mem`, it means that `mem` was resized + * in place without freeing. + * - If it returns a different non-NULL pointer, it means that `mem` was freed + * and cannot be dereferenced anymore. + * - If it returns NULL (indicating failure), then `mem` will remain valid and + * must still be freed with SDL_free(). + * + * If the allocation is successfully resized, the returned pointer is + * guaranteed to be aligned to either the *fundamental alignment* + * (`alignof(max_align_t)` in C11 and later) or `2 * sizeof(void *)`, + * whichever is smaller. + * + * \param mem a pointer to allocated memory to reallocate, or NULL. + * \param size the new size of the memory. + * \returns a pointer to the newly allocated memory, or NULL if allocation + * failed. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_free + * \sa SDL_malloc + * \sa SDL_calloc + */ +extern SDL_DECLSPEC SDL_ALLOC_SIZE(2) void * SDLCALL SDL_realloc(void *mem, size_t size); + +/** + * Free allocated memory. + * + * The pointer is no longer valid after this call and cannot be dereferenced + * anymore. + * + * If `mem` is NULL, this function does nothing. + * + * \param mem a pointer to allocated memory, or NULL. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_malloc + * \sa SDL_calloc + * \sa SDL_realloc + */ +extern SDL_DECLSPEC void SDLCALL SDL_free(void *mem); + +/** + * A callback used to implement SDL_malloc(). + * + * SDL will always ensure that the passed `size` is greater than 0. + * + * \param size the size to allocate. + * \returns a pointer to the allocated memory, or NULL if allocation failed. + * + * \threadsafety It should be safe to call this callback from any thread. + * + * \since This datatype is available since SDL 3.2.0. + * + * \sa SDL_malloc + * \sa SDL_GetOriginalMemoryFunctions + * \sa SDL_GetMemoryFunctions + * \sa SDL_SetMemoryFunctions + */ +typedef void *(SDLCALL *SDL_malloc_func)(size_t size); + +/** + * A callback used to implement SDL_calloc(). + * + * SDL will always ensure that the passed `nmemb` and `size` are both greater + * than 0. + * + * \param nmemb the number of elements in the array. + * \param size the size of each element of the array. + * \returns a pointer to the allocated array, or NULL if allocation failed. + * + * \threadsafety It should be safe to call this callback from any thread. + * + * \since This datatype is available since SDL 3.2.0. + * + * \sa SDL_calloc + * \sa SDL_GetOriginalMemoryFunctions + * \sa SDL_GetMemoryFunctions + * \sa SDL_SetMemoryFunctions + */ +typedef void *(SDLCALL *SDL_calloc_func)(size_t nmemb, size_t size); + +/** + * A callback used to implement SDL_realloc(). + * + * SDL will always ensure that the passed `size` is greater than 0. + * + * \param mem a pointer to allocated memory to reallocate, or NULL. + * \param size the new size of the memory. + * \returns a pointer to the newly allocated memory, or NULL if allocation + * failed. + * + * \threadsafety It should be safe to call this callback from any thread. + * + * \since This datatype is available since SDL 3.2.0. + * + * \sa SDL_realloc + * \sa SDL_GetOriginalMemoryFunctions + * \sa SDL_GetMemoryFunctions + * \sa SDL_SetMemoryFunctions + */ +typedef void *(SDLCALL *SDL_realloc_func)(void *mem, size_t size); + +/** + * A callback used to implement SDL_free(). + * + * SDL will always ensure that the passed `mem` is a non-NULL pointer. + * + * \param mem a pointer to allocated memory. + * + * \threadsafety It should be safe to call this callback from any thread. + * + * \since This datatype is available since SDL 3.2.0. + * + * \sa SDL_free + * \sa SDL_GetOriginalMemoryFunctions + * \sa SDL_GetMemoryFunctions + * \sa SDL_SetMemoryFunctions + */ +typedef void (SDLCALL *SDL_free_func)(void *mem); + +/** + * Get the original set of SDL memory functions. + * + * This is what SDL_malloc and friends will use by default, if there has been + * no call to SDL_SetMemoryFunctions. This is not necessarily using the C + * runtime's `malloc` functions behind the scenes! Different platforms and + * build configurations might do any number of unexpected things. + * + * \param malloc_func filled with malloc function. + * \param calloc_func filled with calloc function. + * \param realloc_func filled with realloc function. + * \param free_func filled with free function. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_GetOriginalMemoryFunctions(SDL_malloc_func *malloc_func, + SDL_calloc_func *calloc_func, + SDL_realloc_func *realloc_func, + SDL_free_func *free_func); + +/** + * Get the current set of SDL memory functions. + * + * \param malloc_func filled with malloc function. + * \param calloc_func filled with calloc function. + * \param realloc_func filled with realloc function. + * \param free_func filled with free function. + * + * \threadsafety This does not hold a lock, so do not call this in the + * unlikely event of a background thread calling + * SDL_SetMemoryFunctions simultaneously. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetMemoryFunctions + * \sa SDL_GetOriginalMemoryFunctions + */ +extern SDL_DECLSPEC void SDLCALL SDL_GetMemoryFunctions(SDL_malloc_func *malloc_func, + SDL_calloc_func *calloc_func, + SDL_realloc_func *realloc_func, + SDL_free_func *free_func); + +/** + * Replace SDL's memory allocation functions with a custom set. + * + * It is not safe to call this function once any allocations have been made, + * as future calls to SDL_free will use the new allocator, even if they came + * from an SDL_malloc made with the old one! + * + * If used, usually this needs to be the first call made into the SDL library, + * if not the very first thing done at program startup time. + * + * \param malloc_func custom malloc function. + * \param calloc_func custom calloc function. + * \param realloc_func custom realloc function. + * \param free_func custom free function. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread, but one + * should not replace the memory functions once any allocations + * are made! + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetMemoryFunctions + * \sa SDL_GetOriginalMemoryFunctions + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetMemoryFunctions(SDL_malloc_func malloc_func, + SDL_calloc_func calloc_func, + SDL_realloc_func realloc_func, + SDL_free_func free_func); + +/** + * Allocate memory aligned to a specific alignment. + * + * The memory returned by this function must be freed with SDL_aligned_free(), + * _not_ SDL_free(). + * + * If `alignment` is less than the size of `void *`, it will be increased to + * match that. + * + * The returned memory address will be a multiple of the alignment value, and + * the size of the memory allocated will be a multiple of the alignment value. + * + * \param alignment the alignment of the memory. + * \param size the size to allocate. + * \returns a pointer to the aligned memory, or NULL if allocation failed. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_aligned_free + */ +extern SDL_DECLSPEC SDL_MALLOC void * SDLCALL SDL_aligned_alloc(size_t alignment, size_t size); + +/** + * Free memory allocated by SDL_aligned_alloc(). + * + * The pointer is no longer valid after this call and cannot be dereferenced + * anymore. + * + * If `mem` is NULL, this function does nothing. + * + * \param mem a pointer previously returned by SDL_aligned_alloc(), or NULL. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_aligned_alloc + */ +extern SDL_DECLSPEC void SDLCALL SDL_aligned_free(void *mem); + +/** + * Get the number of outstanding (unfreed) allocations. + * + * \returns the number of allocations or -1 if allocation counting is + * disabled. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_GetNumAllocations(void); + +/** + * A thread-safe set of environment variables + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_GetEnvironment + * \sa SDL_CreateEnvironment + * \sa SDL_GetEnvironmentVariable + * \sa SDL_GetEnvironmentVariables + * \sa SDL_SetEnvironmentVariable + * \sa SDL_UnsetEnvironmentVariable + * \sa SDL_DestroyEnvironment + */ +typedef struct SDL_Environment SDL_Environment; + +/** + * Get the process environment. + * + * This is initialized at application start and is not affected by setenv() + * and unsetenv() calls after that point. Use SDL_SetEnvironmentVariable() and + * SDL_UnsetEnvironmentVariable() if you want to modify this environment, or + * SDL_setenv_unsafe() or SDL_unsetenv_unsafe() if you want changes to persist + * in the C runtime environment after SDL_Quit(). + * + * \returns a pointer to the environment for the process or NULL on failure; + * call SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetEnvironmentVariable + * \sa SDL_GetEnvironmentVariables + * \sa SDL_SetEnvironmentVariable + * \sa SDL_UnsetEnvironmentVariable + */ +extern SDL_DECLSPEC SDL_Environment * SDLCALL SDL_GetEnvironment(void); + +/** + * Create a set of environment variables + * + * \param populated true to initialize it from the C runtime environment, + * false to create an empty environment. + * \returns a pointer to the new environment or NULL on failure; call + * SDL_GetError() for more information. + * + * \threadsafety If `populated` is false, it is safe to call this function + * from any thread, otherwise it is safe if no other threads are + * calling setenv() or unsetenv() + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetEnvironmentVariable + * \sa SDL_GetEnvironmentVariables + * \sa SDL_SetEnvironmentVariable + * \sa SDL_UnsetEnvironmentVariable + * \sa SDL_DestroyEnvironment + */ +extern SDL_DECLSPEC SDL_Environment * SDLCALL SDL_CreateEnvironment(bool populated); + +/** + * Get the value of a variable in the environment. + * + * \param env the environment to query. + * \param name the name of the variable to get. + * \returns a pointer to the value of the variable or NULL if it can't be + * found. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetEnvironment + * \sa SDL_CreateEnvironment + * \sa SDL_GetEnvironmentVariables + * \sa SDL_SetEnvironmentVariable + * \sa SDL_UnsetEnvironmentVariable + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetEnvironmentVariable(SDL_Environment *env, const char *name); + +/** + * Get all variables in the environment. + * + * \param env the environment to query. + * \returns a NULL terminated array of pointers to environment variables in + * the form "variable=value" or NULL on failure; call SDL_GetError() + * for more information. This is a single allocation that should be + * freed with SDL_free() when it is no longer needed. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetEnvironment + * \sa SDL_CreateEnvironment + * \sa SDL_GetEnvironmentVariables + * \sa SDL_SetEnvironmentVariable + * \sa SDL_UnsetEnvironmentVariable + */ +extern SDL_DECLSPEC char ** SDLCALL SDL_GetEnvironmentVariables(SDL_Environment *env); + +/** + * Set the value of a variable in the environment. + * + * \param env the environment to modify. + * \param name the name of the variable to set. + * \param value the value of the variable to set. + * \param overwrite true to overwrite the variable if it exists, false to + * return success without setting the variable if it already + * exists. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetEnvironment + * \sa SDL_CreateEnvironment + * \sa SDL_GetEnvironmentVariable + * \sa SDL_GetEnvironmentVariables + * \sa SDL_UnsetEnvironmentVariable + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetEnvironmentVariable(SDL_Environment *env, const char *name, const char *value, bool overwrite); + +/** + * Clear a variable from the environment. + * + * \param env the environment to modify. + * \param name the name of the variable to unset. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetEnvironment + * \sa SDL_CreateEnvironment + * \sa SDL_GetEnvironmentVariable + * \sa SDL_GetEnvironmentVariables + * \sa SDL_SetEnvironmentVariable + * \sa SDL_UnsetEnvironmentVariable + */ +extern SDL_DECLSPEC bool SDLCALL SDL_UnsetEnvironmentVariable(SDL_Environment *env, const char *name); + +/** + * Destroy a set of environment variables. + * + * \param env the environment to destroy. + * + * \threadsafety It is safe to call this function from any thread, as long as + * the environment is no longer in use. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateEnvironment + */ +extern SDL_DECLSPEC void SDLCALL SDL_DestroyEnvironment(SDL_Environment *env); + +/** + * Get the value of a variable in the environment. + * + * This function uses SDL's cached copy of the environment and is thread-safe. + * + * \param name the name of the variable to get. + * \returns a pointer to the value of the variable or NULL if it can't be + * found. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_getenv(const char *name); + +/** + * Get the value of a variable in the environment. + * + * This function bypasses SDL's cached copy of the environment and is not + * thread-safe. + * + * \param name the name of the variable to get. + * \returns a pointer to the value of the variable or NULL if it can't be + * found. + * + * \threadsafety This function is not thread safe, consider using SDL_getenv() + * instead. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_getenv + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_getenv_unsafe(const char *name); + +/** + * Set the value of a variable in the environment. + * + * \param name the name of the variable to set. + * \param value the value of the variable to set. + * \param overwrite 1 to overwrite the variable if it exists, 0 to return + * success without setting the variable if it already exists. + * \returns 0 on success, -1 on error. + * + * \threadsafety This function is not thread safe, consider using + * SDL_SetEnvironmentVariable() instead. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetEnvironmentVariable + */ +extern SDL_DECLSPEC int SDLCALL SDL_setenv_unsafe(const char *name, const char *value, int overwrite); + +/** + * Clear a variable from the environment. + * + * \param name the name of the variable to unset. + * \returns 0 on success, -1 on error. + * + * \threadsafety This function is not thread safe, consider using + * SDL_UnsetEnvironmentVariable() instead. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_UnsetEnvironmentVariable + */ +extern SDL_DECLSPEC int SDLCALL SDL_unsetenv_unsafe(const char *name); + +/** + * A callback used with SDL sorting and binary search functions. + * + * \param a a pointer to the first element being compared. + * \param b a pointer to the second element being compared. + * \returns -1 if `a` should be sorted before `b`, 1 if `b` should be sorted + * before `a`, 0 if they are equal. If two elements are equal, their + * order in the sorted array is undefined. + * + * \since This callback is available since SDL 3.2.0. + * + * \sa SDL_bsearch + * \sa SDL_qsort + */ +typedef int (SDLCALL *SDL_CompareCallback)(const void *a, const void *b); + +/** + * Sort an array. + * + * For example: + * + * ```c + * typedef struct { + * int key; + * const char *string; + * } data; + * + * int SDLCALL compare(const void *a, const void *b) + * { + * const data *A = (const data *)a; + * const data *B = (const data *)b; + * + * if (A->n < B->n) { + * return -1; + * } else if (B->n < A->n) { + * return 1; + * } else { + * return 0; + * } + * } + * + * data values[] = { + * { 3, "third" }, { 1, "first" }, { 2, "second" } + * }; + * + * SDL_qsort(values, SDL_arraysize(values), sizeof(values[0]), compare); + * ``` + * + * \param base a pointer to the start of the array. + * \param nmemb the number of elements in the array. + * \param size the size of the elements in the array. + * \param compare a function used to compare elements in the array. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_bsearch + * \sa SDL_qsort_r + */ +extern SDL_DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size, SDL_CompareCallback compare); + +/** + * Perform a binary search on a previously sorted array. + * + * For example: + * + * ```c + * typedef struct { + * int key; + * const char *string; + * } data; + * + * int SDLCALL compare(const void *a, const void *b) + * { + * const data *A = (const data *)a; + * const data *B = (const data *)b; + * + * if (A->n < B->n) { + * return -1; + * } else if (B->n < A->n) { + * return 1; + * } else { + * return 0; + * } + * } + * + * data values[] = { + * { 1, "first" }, { 2, "second" }, { 3, "third" } + * }; + * data key = { 2, NULL }; + * + * data *result = SDL_bsearch(&key, values, SDL_arraysize(values), sizeof(values[0]), compare); + * ``` + * + * \param key a pointer to a key equal to the element being searched for. + * \param base a pointer to the start of the array. + * \param nmemb the number of elements in the array. + * \param size the size of the elements in the array. + * \param compare a function used to compare elements in the array. + * \returns a pointer to the matching element in the array, or NULL if not + * found. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_bsearch_r + * \sa SDL_qsort + */ +extern SDL_DECLSPEC void * SDLCALL SDL_bsearch(const void *key, const void *base, size_t nmemb, size_t size, SDL_CompareCallback compare); + +/** + * A callback used with SDL sorting and binary search functions. + * + * \param userdata the `userdata` pointer passed to the sort function. + * \param a a pointer to the first element being compared. + * \param b a pointer to the second element being compared. + * \returns -1 if `a` should be sorted before `b`, 1 if `b` should be sorted + * before `a`, 0 if they are equal. If two elements are equal, their + * order in the sorted array is undefined. + * + * \since This callback is available since SDL 3.2.0. + * + * \sa SDL_qsort_r + * \sa SDL_bsearch_r + */ +typedef int (SDLCALL *SDL_CompareCallback_r)(void *userdata, const void *a, const void *b); + +/** + * Sort an array, passing a userdata pointer to the compare function. + * + * For example: + * + * ```c + * typedef enum { + * sort_increasing, + * sort_decreasing, + * } sort_method; + * + * typedef struct { + * int key; + * const char *string; + * } data; + * + * int SDLCALL compare(const void *userdata, const void *a, const void *b) + * { + * sort_method method = (sort_method)(uintptr_t)userdata; + * const data *A = (const data *)a; + * const data *B = (const data *)b; + * + * if (A->key < B->key) { + * return (method == sort_increasing) ? -1 : 1; + * } else if (B->key < A->key) { + * return (method == sort_increasing) ? 1 : -1; + * } else { + * return 0; + * } + * } + * + * data values[] = { + * { 3, "third" }, { 1, "first" }, { 2, "second" } + * }; + * + * SDL_qsort_r(values, SDL_arraysize(values), sizeof(values[0]), compare, (const void *)(uintptr_t)sort_increasing); + * ``` + * + * \param base a pointer to the start of the array. + * \param nmemb the number of elements in the array. + * \param size the size of the elements in the array. + * \param compare a function used to compare elements in the array. + * \param userdata a pointer to pass to the compare function. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_bsearch_r + * \sa SDL_qsort + */ +extern SDL_DECLSPEC void SDLCALL SDL_qsort_r(void *base, size_t nmemb, size_t size, SDL_CompareCallback_r compare, void *userdata); + +/** + * Perform a binary search on a previously sorted array, passing a userdata + * pointer to the compare function. + * + * For example: + * + * ```c + * typedef enum { + * sort_increasing, + * sort_decreasing, + * } sort_method; + * + * typedef struct { + * int key; + * const char *string; + * } data; + * + * int SDLCALL compare(const void *userdata, const void *a, const void *b) + * { + * sort_method method = (sort_method)(uintptr_t)userdata; + * const data *A = (const data *)a; + * const data *B = (const data *)b; + * + * if (A->key < B->key) { + * return (method == sort_increasing) ? -1 : 1; + * } else if (B->key < A->key) { + * return (method == sort_increasing) ? 1 : -1; + * } else { + * return 0; + * } + * } + * + * data values[] = { + * { 1, "first" }, { 2, "second" }, { 3, "third" } + * }; + * data key = { 2, NULL }; + * + * data *result = SDL_bsearch_r(&key, values, SDL_arraysize(values), sizeof(values[0]), compare, (const void *)(uintptr_t)sort_increasing); + * ``` + * + * \param key a pointer to a key equal to the element being searched for. + * \param base a pointer to the start of the array. + * \param nmemb the number of elements in the array. + * \param size the size of the elements in the array. + * \param compare a function used to compare elements in the array. + * \param userdata a pointer to pass to the compare function. + * \returns a pointer to the matching element in the array, or NULL if not + * found. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_bsearch + * \sa SDL_qsort_r + */ +extern SDL_DECLSPEC void * SDLCALL SDL_bsearch_r(const void *key, const void *base, size_t nmemb, size_t size, SDL_CompareCallback_r compare, void *userdata); + +/** + * Compute the absolute value of `x`. + * + * \param x an integer value. + * \returns the absolute value of x. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_abs(int x); + +/** + * Return the lesser of two values. + * + * This is a helper macro that might be more clear than writing out the + * comparisons directly, and works with any type that can be compared with the + * `<` operator. However, it double-evaluates both its parameters, so do not + * use expressions with side-effects here. + * + * \param x the first value to compare. + * \param y the second value to compare. + * \returns the lesser of `x` and `y`. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_min(x, y) (((x) < (y)) ? (x) : (y)) + +/** + * Return the greater of two values. + * + * This is a helper macro that might be more clear than writing out the + * comparisons directly, and works with any type that can be compared with the + * `>` operator. However, it double-evaluates both its parameters, so do not + * use expressions with side-effects here. + * + * \param x the first value to compare. + * \param y the second value to compare. + * \returns the greater of `x` and `y`. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_max(x, y) (((x) > (y)) ? (x) : (y)) + +/** + * Return a value clamped to a range. + * + * If `x` is outside the range a values between `a` and `b`, the returned + * value will be `a` or `b` as appropriate. Otherwise, `x` is returned. + * + * This macro will produce incorrect results if `b` is less than `a`. + * + * This is a helper macro that might be more clear than writing out the + * comparisons directly, and works with any type that can be compared with the + * `<` and `>` operators. However, it double-evaluates all its parameters, so + * do not use expressions with side-effects here. + * + * \param x the value to compare. + * \param a the low end value. + * \param b the high end value. + * \returns x, clamped between a and b. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_clamp(x, a, b) (((x) < (a)) ? (a) : (((x) > (b)) ? (b) : (x))) + +/** + * Query if a character is alphabetic (a letter). + * + * **WARNING**: Regardless of system locale, this will only treat ASCII values + * for English 'a-z' and 'A-Z' as true. + * + * \param x character value to check. + * \returns non-zero if x falls within the character class, zero otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_isalpha(int x); + +/** + * Query if a character is alphabetic (a letter) or a number. + * + * **WARNING**: Regardless of system locale, this will only treat ASCII values + * for English 'a-z', 'A-Z', and '0-9' as true. + * + * \param x character value to check. + * \returns non-zero if x falls within the character class, zero otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_isalnum(int x); + +/** + * Report if a character is blank (a space or tab). + * + * **WARNING**: Regardless of system locale, this will only treat ASCII values + * 0x20 (space) or 0x9 (tab) as true. + * + * \param x character value to check. + * \returns non-zero if x falls within the character class, zero otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_isblank(int x); + +/** + * Report if a character is a control character. + * + * **WARNING**: Regardless of system locale, this will only treat ASCII values + * 0 through 0x1F, and 0x7F, as true. + * + * \param x character value to check. + * \returns non-zero if x falls within the character class, zero otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_iscntrl(int x); + +/** + * Report if a character is a numeric digit. + * + * **WARNING**: Regardless of system locale, this will only treat ASCII values + * '0' (0x30) through '9' (0x39), as true. + * + * \param x character value to check. + * \returns non-zero if x falls within the character class, zero otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_isdigit(int x); + +/** + * Report if a character is a hexadecimal digit. + * + * **WARNING**: Regardless of system locale, this will only treat ASCII values + * 'A' through 'F', 'a' through 'f', and '0' through '9', as true. + * + * \param x character value to check. + * \returns non-zero if x falls within the character class, zero otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_isxdigit(int x); + +/** + * Report if a character is a punctuation mark. + * + * **WARNING**: Regardless of system locale, this is equivalent to + * `((SDL_isgraph(x)) && (!SDL_isalnum(x)))`. + * + * \param x character value to check. + * \returns non-zero if x falls within the character class, zero otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_isgraph + * \sa SDL_isalnum + */ +extern SDL_DECLSPEC int SDLCALL SDL_ispunct(int x); + +/** + * Report if a character is whitespace. + * + * **WARNING**: Regardless of system locale, this will only treat the + * following ASCII values as true: + * + * - space (0x20) + * - tab (0x09) + * - newline (0x0A) + * - vertical tab (0x0B) + * - form feed (0x0C) + * - return (0x0D) + * + * \param x character value to check. + * \returns non-zero if x falls within the character class, zero otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_isspace(int x); + +/** + * Report if a character is upper case. + * + * **WARNING**: Regardless of system locale, this will only treat ASCII values + * 'A' through 'Z' as true. + * + * \param x character value to check. + * \returns non-zero if x falls within the character class, zero otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_isupper(int x); + +/** + * Report if a character is lower case. + * + * **WARNING**: Regardless of system locale, this will only treat ASCII values + * 'a' through 'z' as true. + * + * \param x character value to check. + * \returns non-zero if x falls within the character class, zero otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_islower(int x); + +/** + * Report if a character is "printable". + * + * Be advised that "printable" has a definition that goes back to text + * terminals from the dawn of computing, making this a sort of special case + * function that is not suitable for Unicode (or most any) text management. + * + * **WARNING**: Regardless of system locale, this will only treat ASCII values + * ' ' (0x20) through '~' (0x7E) as true. + * + * \param x character value to check. + * \returns non-zero if x falls within the character class, zero otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_isprint(int x); + +/** + * Report if a character is any "printable" except space. + * + * Be advised that "printable" has a definition that goes back to text + * terminals from the dawn of computing, making this a sort of special case + * function that is not suitable for Unicode (or most any) text management. + * + * **WARNING**: Regardless of system locale, this is equivalent to + * `(SDL_isprint(x)) && ((x) != ' ')`. + * + * \param x character value to check. + * \returns non-zero if x falls within the character class, zero otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_isprint + */ +extern SDL_DECLSPEC int SDLCALL SDL_isgraph(int x); + +/** + * Convert low-ASCII English letters to uppercase. + * + * **WARNING**: Regardless of system locale, this will only convert ASCII + * values 'a' through 'z' to uppercase. + * + * This function returns the uppercase equivalent of `x`. If a character + * cannot be converted, or is already uppercase, this function returns `x`. + * + * \param x character value to check. + * \returns capitalized version of x, or x if no conversion available. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_toupper(int x); + +/** + * Convert low-ASCII English letters to lowercase. + * + * **WARNING**: Regardless of system locale, this will only convert ASCII + * values 'A' through 'Z' to lowercase. + * + * This function returns the lowercase equivalent of `x`. If a character + * cannot be converted, or is already lowercase, this function returns `x`. + * + * \param x character value to check. + * \returns lowercase version of x, or x if no conversion available. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_tolower(int x); + +/** + * Calculate a CRC-16 value. + * + * https://en.wikipedia.org/wiki/Cyclic_redundancy_check + * + * This function can be called multiple times, to stream data to be + * checksummed in blocks. Each call must provide the previous CRC-16 return + * value to be updated with the next block. The first call to this function + * for a set of blocks should pass in a zero CRC value. + * + * \param crc the current checksum for this data set, or 0 for a new data set. + * \param data a new block of data to add to the checksum. + * \param len the size, in bytes, of the new block of data. + * \returns a CRC-16 checksum value of all blocks in the data set. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC Uint16 SDLCALL SDL_crc16(Uint16 crc, const void *data, size_t len); + +/** + * Calculate a CRC-32 value. + * + * https://en.wikipedia.org/wiki/Cyclic_redundancy_check + * + * This function can be called multiple times, to stream data to be + * checksummed in blocks. Each call must provide the previous CRC-32 return + * value to be updated with the next block. The first call to this function + * for a set of blocks should pass in a zero CRC value. + * + * \param crc the current checksum for this data set, or 0 for a new data set. + * \param data a new block of data to add to the checksum. + * \param len the size, in bytes, of the new block of data. + * \returns a CRC-32 checksum value of all blocks in the data set. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC Uint32 SDLCALL SDL_crc32(Uint32 crc, const void *data, size_t len); + +/** + * Calculate a 32-bit MurmurHash3 value for a block of data. + * + * https://en.wikipedia.org/wiki/MurmurHash + * + * A seed may be specified, which changes the final results consistently, but + * this does not work like SDL_crc16 and SDL_crc32: you can't feed a previous + * result from this function back into itself as the next seed value to + * calculate a hash in chunks; it won't produce the same hash as it would if + * the same data was provided in a single call. + * + * If you aren't sure what to provide for a seed, zero is fine. Murmur3 is not + * cryptographically secure, so it shouldn't be used for hashing top-secret + * data. + * + * \param data the data to be hashed. + * \param len the size of data, in bytes. + * \param seed a value that alters the final hash value. + * \returns a Murmur3 32-bit hash value. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC Uint32 SDLCALL SDL_murmur3_32(const void *data, size_t len, Uint32 seed); + +/** + * Copy non-overlapping memory. + * + * The memory regions must not overlap. If they do, use SDL_memmove() instead. + * + * \param dst The destination memory region. Must not be NULL, and must not + * overlap with `src`. + * \param src The source memory region. Must not be NULL, and must not overlap + * with `dst`. + * \param len The length in bytes of both `dst` and `src`. + * \returns `dst`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_memmove + */ +extern SDL_DECLSPEC void * SDLCALL SDL_memcpy(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len); + +/* Take advantage of compiler optimizations for memcpy */ +#ifndef SDL_SLOW_MEMCPY +#ifdef SDL_memcpy +#undef SDL_memcpy +#endif +#define SDL_memcpy memcpy +#endif + + +/** + * A macro to copy memory between objects, with basic type checking. + * + * SDL_memcpy and SDL_memmove do not care where you copy memory to and from, + * which can lead to bugs. This macro aims to avoid most of those bugs by + * making sure that the source and destination are both pointers to objects + * that are the same size. It does not check that the objects are the same + * _type_, just that the copy will not overflow either object. + * + * The size check happens at compile time, and the compiler will throw an + * error if the objects are different sizes. + * + * Generally this is intended to copy a single object, not an array. + * + * This macro looks like it double-evaluates its parameters, but the extras + * them are in `sizeof` sections, which generate no code nor side-effects. + * + * \param dst a pointer to the destination object. Must not be NULL. + * \param src a pointer to the source object. Must not be NULL. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +#define SDL_copyp(dst, src) \ + { SDL_COMPILE_TIME_ASSERT(SDL_copyp, sizeof (*(dst)) == sizeof (*(src))); } \ + SDL_memcpy((dst), (src), sizeof(*(src))) + +/** + * Copy memory ranges that might overlap. + * + * It is okay for the memory regions to overlap. If you are confident that the + * regions never overlap, using SDL_memcpy() may improve performance. + * + * \param dst The destination memory region. Must not be NULL. + * \param src The source memory region. Must not be NULL. + * \param len The length in bytes of both `dst` and `src`. + * \returns `dst`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_memcpy + */ +extern SDL_DECLSPEC void * SDLCALL SDL_memmove(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len); + +/* Take advantage of compiler optimizations for memmove */ +#ifndef SDL_SLOW_MEMMOVE +#ifdef SDL_memmove +#undef SDL_memmove +#endif +#define SDL_memmove memmove +#endif + +/** + * Initialize all bytes of buffer of memory to a specific value. + * + * This function will set `len` bytes, pointed to by `dst`, to the value + * specified in `c`. + * + * Despite `c` being an `int` instead of a `char`, this only operates on + * bytes; `c` must be a value between 0 and 255, inclusive. + * + * \param dst the destination memory region. Must not be NULL. + * \param c the byte value to set. + * \param len the length, in bytes, to set in `dst`. + * \returns `dst`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void * SDLCALL SDL_memset(SDL_OUT_BYTECAP(len) void *dst, int c, size_t len); + +/** + * Initialize all 32-bit words of buffer of memory to a specific value. + * + * This function will set a buffer of `dwords` Uint32 values, pointed to by + * `dst`, to the value specified in `val`. + * + * Unlike SDL_memset, this sets 32-bit values, not bytes, so it's not limited + * to a range of 0-255. + * + * \param dst the destination memory region. Must not be NULL. + * \param val the Uint32 value to set. + * \param dwords the number of Uint32 values to set in `dst`. + * \returns `dst`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void * SDLCALL SDL_memset4(void *dst, Uint32 val, size_t dwords); + +/* Take advantage of compiler optimizations for memset */ +#ifndef SDL_SLOW_MEMSET +#ifdef SDL_memset +#undef SDL_memset +#endif +#define SDL_memset memset +#endif + +/** + * Clear an object's memory to zero. + * + * This is wrapper over SDL_memset that handles calculating the object size, + * so there's no chance of copy/paste errors, and the code is cleaner. + * + * This requires an object, not a pointer to an object, nor an array. + * + * \param x the object to clear. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_zerop + * \sa SDL_zeroa + */ +#define SDL_zero(x) SDL_memset(&(x), 0, sizeof((x))) + +/** + * Clear an object's memory to zero, using a pointer. + * + * This is wrapper over SDL_memset that handles calculating the object size, + * so there's no chance of copy/paste errors, and the code is cleaner. + * + * This requires a pointer to an object, not an object itself, nor an array. + * + * \param x a pointer to the object to clear. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_zero + * \sa SDL_zeroa + */ +#define SDL_zerop(x) SDL_memset((x), 0, sizeof(*(x))) + +/** + * Clear an array's memory to zero. + * + * This is wrapper over SDL_memset that handles calculating the array size, so + * there's no chance of copy/paste errors, and the code is cleaner. + * + * This requires an array, not an object, nor a pointer to an object. + * + * \param x an array to clear. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_zero + * \sa SDL_zerop + */ +#define SDL_zeroa(x) SDL_memset((x), 0, sizeof((x))) + + +/** + * Compare two buffers of memory. + * + * \param s1 the first buffer to compare. NULL is not permitted! + * \param s2 the second buffer to compare. NULL is not permitted! + * \param len the number of bytes to compare between the buffers. + * \returns less than zero if s1 is "less than" s2, greater than zero if s1 is + * "greater than" s2, and zero if the buffers match exactly for `len` + * bytes. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2, size_t len); + +/** + * This works exactly like wcslen() but doesn't require access to a C runtime. + * + * Counts the number of wchar_t values in `wstr`, excluding the null + * terminator. + * + * Like SDL_strlen only counts bytes and not codepoints in a UTF-8 string, + * this counts wchar_t values in a string, even if the string's encoding is of + * variable width, like UTF-16. + * + * Also be aware that wchar_t is different sizes on different platforms (4 + * bytes on Linux, 2 on Windows, etc). + * + * \param wstr The null-terminated wide string to read. Must not be NULL. + * \returns the length (in wchar_t values, excluding the null terminator) of + * `wstr`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_wcsnlen + * \sa SDL_utf8strlen + * \sa SDL_utf8strnlen + */ +extern SDL_DECLSPEC size_t SDLCALL SDL_wcslen(const wchar_t *wstr); + +/** + * This works exactly like wcsnlen() but doesn't require access to a C + * runtime. + * + * Counts up to a maximum of `maxlen` wchar_t values in `wstr`, excluding the + * null terminator. + * + * Like SDL_strnlen only counts bytes and not codepoints in a UTF-8 string, + * this counts wchar_t values in a string, even if the string's encoding is of + * variable width, like UTF-16. + * + * Also be aware that wchar_t is different sizes on different platforms (4 + * bytes on Linux, 2 on Windows, etc). + * + * Also, `maxlen` is a count of wide characters, not bytes! + * + * \param wstr The null-terminated wide string to read. Must not be NULL. + * \param maxlen The maximum amount of wide characters to count. + * \returns the length (in wide characters, excluding the null terminator) of + * `wstr` but never more than `maxlen`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_wcslen + * \sa SDL_utf8strlen + * \sa SDL_utf8strnlen + */ +extern SDL_DECLSPEC size_t SDLCALL SDL_wcsnlen(const wchar_t *wstr, size_t maxlen); + +/** + * Copy a wide string. + * + * This function copies `maxlen` - 1 wide characters from `src` to `dst`, then + * appends a null terminator. + * + * `src` and `dst` must not overlap. + * + * If `maxlen` is 0, no wide characters are copied and no null terminator is + * written. + * + * \param dst The destination buffer. Must not be NULL, and must not overlap + * with `src`. + * \param src The null-terminated wide string to copy. Must not be NULL, and + * must not overlap with `dst`. + * \param maxlen The length (in wide characters) of the destination buffer. + * \returns the length (in wide characters, excluding the null terminator) of + * `src`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_wcslcat + */ +extern SDL_DECLSPEC size_t SDLCALL SDL_wcslcpy(SDL_OUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t maxlen); + +/** + * Concatenate wide strings. + * + * This function appends up to `maxlen` - SDL_wcslen(dst) - 1 wide characters + * from `src` to the end of the wide string in `dst`, then appends a null + * terminator. + * + * `src` and `dst` must not overlap. + * + * If `maxlen` - SDL_wcslen(dst) - 1 is less than or equal to 0, then `dst` is + * unmodified. + * + * \param dst The destination buffer already containing the first + * null-terminated wide string. Must not be NULL and must not + * overlap with `src`. + * \param src The second null-terminated wide string. Must not be NULL, and + * must not overlap with `dst`. + * \param maxlen The length (in wide characters) of the destination buffer. + * \returns the length (in wide characters, excluding the null terminator) of + * the string in `dst` plus the length of `src`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_wcslcpy + */ +extern SDL_DECLSPEC size_t SDLCALL SDL_wcslcat(SDL_INOUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t maxlen); + +/** + * Allocate a copy of a wide string. + * + * This allocates enough space for a null-terminated copy of `wstr`, using + * SDL_malloc, and then makes a copy of the string into this space. + * + * The returned string is owned by the caller, and should be passed to + * SDL_free when no longer needed. + * + * \param wstr the string to copy. + * \returns a pointer to the newly-allocated wide string. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC wchar_t * SDLCALL SDL_wcsdup(const wchar_t *wstr); + +/** + * Search a wide string for the first instance of a specific substring. + * + * The search ends once it finds the requested substring, or a null terminator + * byte to end the string. + * + * Note that this looks for strings of _wide characters_, not _codepoints_, so + * it's legal to search for malformed and incomplete UTF-16 sequences. + * + * \param haystack the wide string to search. Must not be NULL. + * \param needle the wide string to search for. Must not be NULL. + * \returns a pointer to the first instance of `needle` in the string, or NULL + * if not found. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC wchar_t * SDLCALL SDL_wcsstr(const wchar_t *haystack, const wchar_t *needle); + +/** + * Search a wide string, up to n wide chars, for the first instance of a + * specific substring. + * + * The search ends once it finds the requested substring, or a null terminator + * value to end the string, or `maxlen` wide character have been examined. It + * is possible to use this function on a wide string without a null + * terminator. + * + * Note that this looks for strings of _wide characters_, not _codepoints_, so + * it's legal to search for malformed and incomplete UTF-16 sequences. + * + * \param haystack the wide string to search. Must not be NULL. + * \param needle the wide string to search for. Must not be NULL. + * \param maxlen the maximum number of wide characters to search in + * `haystack`. + * \returns a pointer to the first instance of `needle` in the string, or NULL + * if not found. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC wchar_t * SDLCALL SDL_wcsnstr(const wchar_t *haystack, const wchar_t *needle, size_t maxlen); + +/** + * Compare two null-terminated wide strings. + * + * This only compares wchar_t values until it hits a null-terminating + * character; it does not care if the string is well-formed UTF-16 (or UTF-32, + * depending on your platform's wchar_t size), or uses valid Unicode values. + * + * \param str1 the first string to compare. NULL is not permitted! + * \param str2 the second string to compare. NULL is not permitted! + * \returns less than zero if str1 is "less than" str2, greater than zero if + * str1 is "greater than" str2, and zero if the strings match + * exactly. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_wcscmp(const wchar_t *str1, const wchar_t *str2); + +/** + * Compare two wide strings up to a number of wchar_t values. + * + * This only compares wchar_t values; it does not care if the string is + * well-formed UTF-16 (or UTF-32, depending on your platform's wchar_t size), + * or uses valid Unicode values. + * + * Note that while this function is intended to be used with UTF-16 (or + * UTF-32, depending on your platform's definition of wchar_t), it is + * comparing raw wchar_t values and not Unicode codepoints: `maxlen` specifies + * a wchar_t limit! If the limit lands in the middle of a multi-wchar UTF-16 + * sequence, it will only compare a portion of the final character. + * + * `maxlen` specifies a maximum number of wchar_t to compare; if the strings + * match to this number of wide chars (or both have matched to a + * null-terminator character before this count), they will be considered + * equal. + * + * \param str1 the first string to compare. NULL is not permitted! + * \param str2 the second string to compare. NULL is not permitted! + * \param maxlen the maximum number of wchar_t to compare. + * \returns less than zero if str1 is "less than" str2, greater than zero if + * str1 is "greater than" str2, and zero if the strings match + * exactly. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_wcsncmp(const wchar_t *str1, const wchar_t *str2, size_t maxlen); + +/** + * Compare two null-terminated wide strings, case-insensitively. + * + * This will work with Unicode strings, using a technique called + * "case-folding" to handle the vast majority of case-sensitive human + * languages regardless of system locale. It can deal with expanding values: a + * German Eszett character can compare against two ASCII 's' chars and be + * considered a match, for example. A notable exception: it does not handle + * the Turkish 'i' character; human language is complicated! + * + * Depending on your platform, "wchar_t" might be 2 bytes, and expected to be + * UTF-16 encoded (like Windows), or 4 bytes in UTF-32 format. Since this + * handles Unicode, it expects the string to be well-formed and not a + * null-terminated string of arbitrary bytes. Characters that are not valid + * UTF-16 (or UTF-32) are treated as Unicode character U+FFFD (REPLACEMENT + * CHARACTER), which is to say two strings of random bits may turn out to + * match if they convert to the same amount of replacement characters. + * + * \param str1 the first string to compare. NULL is not permitted! + * \param str2 the second string to compare. NULL is not permitted! + * \returns less than zero if str1 is "less than" str2, greater than zero if + * str1 is "greater than" str2, and zero if the strings match + * exactly. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_wcscasecmp(const wchar_t *str1, const wchar_t *str2); + +/** + * Compare two wide strings, case-insensitively, up to a number of wchar_t. + * + * This will work with Unicode strings, using a technique called + * "case-folding" to handle the vast majority of case-sensitive human + * languages regardless of system locale. It can deal with expanding values: a + * German Eszett character can compare against two ASCII 's' chars and be + * considered a match, for example. A notable exception: it does not handle + * the Turkish 'i' character; human language is complicated! + * + * Depending on your platform, "wchar_t" might be 2 bytes, and expected to be + * UTF-16 encoded (like Windows), or 4 bytes in UTF-32 format. Since this + * handles Unicode, it expects the string to be well-formed and not a + * null-terminated string of arbitrary bytes. Characters that are not valid + * UTF-16 (or UTF-32) are treated as Unicode character U+FFFD (REPLACEMENT + * CHARACTER), which is to say two strings of random bits may turn out to + * match if they convert to the same amount of replacement characters. + * + * Note that while this function might deal with variable-sized characters, + * `maxlen` specifies a _wchar_ limit! If the limit lands in the middle of a + * multi-byte UTF-16 sequence, it may convert a portion of the final character + * to one or more Unicode character U+FFFD (REPLACEMENT CHARACTER) so as not + * to overflow a buffer. + * + * `maxlen` specifies a maximum number of wchar_t values to compare; if the + * strings match to this number of wchar_t (or both have matched to a + * null-terminator character before this number of bytes), they will be + * considered equal. + * + * \param str1 the first string to compare. NULL is not permitted! + * \param str2 the second string to compare. NULL is not permitted! + * \param maxlen the maximum number of wchar_t values to compare. + * \returns less than zero if str1 is "less than" str2, greater than zero if + * str1 is "greater than" str2, and zero if the strings match + * exactly. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_wcsncasecmp(const wchar_t *str1, const wchar_t *str2, size_t maxlen); + +/** + * Parse a `long` from a wide string. + * + * If `str` starts with whitespace, then those whitespace characters are + * skipped before attempting to parse the number. + * + * If the parsed number does not fit inside a `long`, the result is clamped to + * the minimum and maximum representable `long` values. + * + * \param str The null-terminated wide string to read. Must not be NULL. + * \param endp If not NULL, the address of the first invalid wide character + * (i.e. the next character after the parsed number) will be + * written to this pointer. + * \param base The base of the integer to read. Supported values are 0 and 2 + * to 36 inclusive. If 0, the base will be inferred from the + * number's prefix (0x for hexadecimal, 0 for octal, decimal + * otherwise). + * \returns the parsed `long`, or 0 if no number could be parsed. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_strtol + */ +extern SDL_DECLSPEC long SDLCALL SDL_wcstol(const wchar_t *str, wchar_t **endp, int base); + +/** + * This works exactly like strlen() but doesn't require access to a C runtime. + * + * Counts the bytes in `str`, excluding the null terminator. + * + * If you need the length of a UTF-8 string, consider using SDL_utf8strlen(). + * + * \param str The null-terminated string to read. Must not be NULL. + * \returns the length (in bytes, excluding the null terminator) of `src`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_strnlen + * \sa SDL_utf8strlen + * \sa SDL_utf8strnlen + */ +extern SDL_DECLSPEC size_t SDLCALL SDL_strlen(const char *str); + +/** + * This works exactly like strnlen() but doesn't require access to a C + * runtime. + * + * Counts up to a maximum of `maxlen` bytes in `str`, excluding the null + * terminator. + * + * If you need the length of a UTF-8 string, consider using SDL_utf8strnlen(). + * + * \param str The null-terminated string to read. Must not be NULL. + * \param maxlen The maximum amount of bytes to count. + * \returns the length (in bytes, excluding the null terminator) of `src` but + * never more than `maxlen`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_strlen + * \sa SDL_utf8strlen + * \sa SDL_utf8strnlen + */ +extern SDL_DECLSPEC size_t SDLCALL SDL_strnlen(const char *str, size_t maxlen); + +/** + * Copy a string. + * + * This function copies up to `maxlen` - 1 characters from `src` to `dst`, + * then appends a null terminator. + * + * If `maxlen` is 0, no characters are copied and no null terminator is + * written. + * + * If you want to copy an UTF-8 string but need to ensure that multi-byte + * sequences are not truncated, consider using SDL_utf8strlcpy(). + * + * \param dst The destination buffer. Must not be NULL, and must not overlap + * with `src`. + * \param src The null-terminated string to copy. Must not be NULL, and must + * not overlap with `dst`. + * \param maxlen The length (in characters) of the destination buffer. + * \returns the length (in characters, excluding the null terminator) of + * `src`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_strlcat + * \sa SDL_utf8strlcpy + */ +extern SDL_DECLSPEC size_t SDLCALL SDL_strlcpy(SDL_OUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen); + +/** + * Copy an UTF-8 string. + * + * This function copies up to `dst_bytes` - 1 bytes from `src` to `dst` while + * also ensuring that the string written to `dst` does not end in a truncated + * multi-byte sequence. Finally, it appends a null terminator. + * + * `src` and `dst` must not overlap. + * + * Note that unlike SDL_strlcpy(), this function returns the number of bytes + * written, not the length of `src`. + * + * \param dst The destination buffer. Must not be NULL, and must not overlap + * with `src`. + * \param src The null-terminated UTF-8 string to copy. Must not be NULL, and + * must not overlap with `dst`. + * \param dst_bytes The length (in bytes) of the destination buffer. Must not + * be 0. + * \returns the number of bytes written, excluding the null terminator. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_strlcpy + */ +extern SDL_DECLSPEC size_t SDLCALL SDL_utf8strlcpy(SDL_OUT_Z_CAP(dst_bytes) char *dst, const char *src, size_t dst_bytes); + +/** + * Concatenate strings. + * + * This function appends up to `maxlen` - SDL_strlen(dst) - 1 characters from + * `src` to the end of the string in `dst`, then appends a null terminator. + * + * `src` and `dst` must not overlap. + * + * If `maxlen` - SDL_strlen(dst) - 1 is less than or equal to 0, then `dst` is + * unmodified. + * + * \param dst The destination buffer already containing the first + * null-terminated string. Must not be NULL and must not overlap + * with `src`. + * \param src The second null-terminated string. Must not be NULL, and must + * not overlap with `dst`. + * \param maxlen The length (in characters) of the destination buffer. + * \returns the length (in characters, excluding the null terminator) of the + * string in `dst` plus the length of `src`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_strlcpy + */ +extern SDL_DECLSPEC size_t SDLCALL SDL_strlcat(SDL_INOUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen); + +/** + * Allocate a copy of a string. + * + * This allocates enough space for a null-terminated copy of `str`, using + * SDL_malloc, and then makes a copy of the string into this space. + * + * The returned string is owned by the caller, and should be passed to + * SDL_free when no longer needed. + * + * \param str the string to copy. + * \returns a pointer to the newly-allocated string. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_MALLOC char * SDLCALL SDL_strdup(const char *str); + +/** + * Allocate a copy of a string, up to n characters. + * + * This allocates enough space for a null-terminated copy of `str`, up to + * `maxlen` bytes, using SDL_malloc, and then makes a copy of the string into + * this space. + * + * If the string is longer than `maxlen` bytes, the returned string will be + * `maxlen` bytes long, plus a null-terminator character that isn't included + * in the count. + * + * The returned string is owned by the caller, and should be passed to + * SDL_free when no longer needed. + * + * \param str the string to copy. + * \param maxlen the maximum length of the copied string, not counting the + * null-terminator character. + * \returns a pointer to the newly-allocated string. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_MALLOC char * SDLCALL SDL_strndup(const char *str, size_t maxlen); + +/** + * Reverse a string's contents. + * + * This reverses a null-terminated string in-place. Only the content of the + * string is reversed; the null-terminator character remains at the end of the + * reversed string. + * + * **WARNING**: This function reverses the _bytes_ of the string, not the + * codepoints. If `str` is a UTF-8 string with Unicode codepoints > 127, this + * will ruin the string data. You should only use this function on strings + * that are completely comprised of low ASCII characters. + * + * \param str the string to reverse. + * \returns `str`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC char * SDLCALL SDL_strrev(char *str); + +/** + * Convert a string to uppercase. + * + * **WARNING**: Regardless of system locale, this will only convert ASCII + * values 'A' through 'Z' to uppercase. + * + * This function operates on a null-terminated string of bytes--even if it is + * malformed UTF-8!--and converts ASCII characters 'a' through 'z' to their + * uppercase equivalents in-place, returning the original `str` pointer. + * + * \param str the string to convert in-place. Can not be NULL. + * \returns the `str` pointer passed into this function. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_strlwr + */ +extern SDL_DECLSPEC char * SDLCALL SDL_strupr(char *str); + +/** + * Convert a string to lowercase. + * + * **WARNING**: Regardless of system locale, this will only convert ASCII + * values 'A' through 'Z' to lowercase. + * + * This function operates on a null-terminated string of bytes--even if it is + * malformed UTF-8!--and converts ASCII characters 'A' through 'Z' to their + * lowercase equivalents in-place, returning the original `str` pointer. + * + * \param str the string to convert in-place. Can not be NULL. + * \returns the `str` pointer passed into this function. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_strupr + */ +extern SDL_DECLSPEC char * SDLCALL SDL_strlwr(char *str); + +/** + * Search a string for the first instance of a specific byte. + * + * The search ends once it finds the requested byte value, or a null + * terminator byte to end the string. + * + * Note that this looks for _bytes_, not _characters_, so you cannot match + * against a Unicode codepoint > 255, regardless of character encoding. + * + * \param str the string to search. Must not be NULL. + * \param c the byte value to search for. + * \returns a pointer to the first instance of `c` in the string, or NULL if + * not found. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC char * SDLCALL SDL_strchr(const char *str, int c); + +/** + * Search a string for the last instance of a specific byte. + * + * The search must go until it finds a null terminator byte to end the string. + * + * Note that this looks for _bytes_, not _characters_, so you cannot match + * against a Unicode codepoint > 255, regardless of character encoding. + * + * \param str the string to search. Must not be NULL. + * \param c the byte value to search for. + * \returns a pointer to the last instance of `c` in the string, or NULL if + * not found. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC char * SDLCALL SDL_strrchr(const char *str, int c); + +/** + * Search a string for the first instance of a specific substring. + * + * The search ends once it finds the requested substring, or a null terminator + * byte to end the string. + * + * Note that this looks for strings of _bytes_, not _characters_, so it's + * legal to search for malformed and incomplete UTF-8 sequences. + * + * \param haystack the string to search. Must not be NULL. + * \param needle the string to search for. Must not be NULL. + * \returns a pointer to the first instance of `needle` in the string, or NULL + * if not found. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC char * SDLCALL SDL_strstr(const char *haystack, const char *needle); + +/** + * Search a string, up to n bytes, for the first instance of a specific + * substring. + * + * The search ends once it finds the requested substring, or a null terminator + * byte to end the string, or `maxlen` bytes have been examined. It is + * possible to use this function on a string without a null terminator. + * + * Note that this looks for strings of _bytes_, not _characters_, so it's + * legal to search for malformed and incomplete UTF-8 sequences. + * + * \param haystack the string to search. Must not be NULL. + * \param needle the string to search for. Must not be NULL. + * \param maxlen the maximum number of bytes to search in `haystack`. + * \returns a pointer to the first instance of `needle` in the string, or NULL + * if not found. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC char * SDLCALL SDL_strnstr(const char *haystack, const char *needle, size_t maxlen); + +/** + * Search a UTF-8 string for the first instance of a specific substring, + * case-insensitively. + * + * This will work with Unicode strings, using a technique called + * "case-folding" to handle the vast majority of case-sensitive human + * languages regardless of system locale. It can deal with expanding values: a + * German Eszett character can compare against two ASCII 's' chars and be + * considered a match, for example. A notable exception: it does not handle + * the Turkish 'i' character; human language is complicated! + * + * Since this handles Unicode, it expects the strings to be well-formed UTF-8 + * and not a null-terminated string of arbitrary bytes. Bytes that are not + * valid UTF-8 are treated as Unicode character U+FFFD (REPLACEMENT + * CHARACTER), which is to say two strings of random bits may turn out to + * match if they convert to the same amount of replacement characters. + * + * \param haystack the string to search. Must not be NULL. + * \param needle the string to search for. Must not be NULL. + * \returns a pointer to the first instance of `needle` in the string, or NULL + * if not found. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC char * SDLCALL SDL_strcasestr(const char *haystack, const char *needle); + +/** + * This works exactly like strtok_r() but doesn't require access to a C + * runtime. + * + * Break a string up into a series of tokens. + * + * To start tokenizing a new string, `str` should be the non-NULL address of + * the string to start tokenizing. Future calls to get the next token from the + * same string should specify a NULL. + * + * Note that this function will overwrite pieces of `str` with null chars to + * split it into tokens. This function cannot be used with const/read-only + * strings! + * + * `saveptr` just needs to point to a `char *` that can be overwritten; SDL + * will use this to save tokenizing state between calls. It is initialized if + * `str` is non-NULL, and used to resume tokenizing when `str` is NULL. + * + * \param str the string to tokenize, or NULL to continue tokenizing. + * \param delim the delimiter string that separates tokens. + * \param saveptr pointer to a char *, used for ongoing state. + * \returns A pointer to the next token, or NULL if no tokens remain. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC char * SDLCALL SDL_strtok_r(char *str, const char *delim, char **saveptr); + +/** + * Count the number of codepoints in a UTF-8 string. + * + * Counts the _codepoints_, not _bytes_, in `str`, excluding the null + * terminator. + * + * If you need to count the bytes in a string instead, consider using + * SDL_strlen(). + * + * Since this handles Unicode, it expects the strings to be well-formed UTF-8 + * and not a null-terminated string of arbitrary bytes. Bytes that are not + * valid UTF-8 are treated as Unicode character U+FFFD (REPLACEMENT + * CHARACTER), so a malformed or incomplete UTF-8 sequence might increase the + * count by several replacement characters. + * + * \param str The null-terminated UTF-8 string to read. Must not be NULL. + * \returns The length (in codepoints, excluding the null terminator) of + * `src`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_utf8strnlen + * \sa SDL_strlen + */ +extern SDL_DECLSPEC size_t SDLCALL SDL_utf8strlen(const char *str); + +/** + * Count the number of codepoints in a UTF-8 string, up to n bytes. + * + * Counts the _codepoints_, not _bytes_, in `str`, excluding the null + * terminator. + * + * If you need to count the bytes in a string instead, consider using + * SDL_strnlen(). + * + * The counting stops at `bytes` bytes (not codepoints!). This seems + * counterintuitive, but makes it easy to express the total size of the + * string's buffer. + * + * Since this handles Unicode, it expects the strings to be well-formed UTF-8 + * and not a null-terminated string of arbitrary bytes. Bytes that are not + * valid UTF-8 are treated as Unicode character U+FFFD (REPLACEMENT + * CHARACTER), so a malformed or incomplete UTF-8 sequence might increase the + * count by several replacement characters. + * + * \param str The null-terminated UTF-8 string to read. Must not be NULL. + * \param bytes The maximum amount of bytes to count. + * \returns The length (in codepoints, excluding the null terminator) of `src` + * but never more than `maxlen`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_utf8strlen + * \sa SDL_strnlen + */ +extern SDL_DECLSPEC size_t SDLCALL SDL_utf8strnlen(const char *str, size_t bytes); + +/** + * Convert an integer into a string. + * + * This requires a radix to specified for string format. Specifying 10 + * produces a decimal number, 16 hexadecimal, etc. Must be in the range of 2 + * to 36. + * + * Note that this function will overflow a buffer if `str` is not large enough + * to hold the output! It may be safer to use SDL_snprintf to clamp output, or + * SDL_asprintf to allocate a buffer. Otherwise, it doesn't hurt to allocate + * much more space than you expect to use (and don't forget possible negative + * signs, null terminator bytes, etc). + * + * \param value the integer to convert. + * \param str the buffer to write the string into. + * \param radix the radix to use for string generation. + * \returns `str`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_uitoa + * \sa SDL_ltoa + * \sa SDL_lltoa + */ +extern SDL_DECLSPEC char * SDLCALL SDL_itoa(int value, char *str, int radix); + +/** + * Convert an unsigned integer into a string. + * + * This requires a radix to specified for string format. Specifying 10 + * produces a decimal number, 16 hexadecimal, etc. Must be in the range of 2 + * to 36. + * + * Note that this function will overflow a buffer if `str` is not large enough + * to hold the output! It may be safer to use SDL_snprintf to clamp output, or + * SDL_asprintf to allocate a buffer. Otherwise, it doesn't hurt to allocate + * much more space than you expect to use (and don't forget null terminator + * bytes, etc). + * + * \param value the unsigned integer to convert. + * \param str the buffer to write the string into. + * \param radix the radix to use for string generation. + * \returns `str`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_itoa + * \sa SDL_ultoa + * \sa SDL_ulltoa + */ +extern SDL_DECLSPEC char * SDLCALL SDL_uitoa(unsigned int value, char *str, int radix); + +/** + * Convert a long integer into a string. + * + * This requires a radix to specified for string format. Specifying 10 + * produces a decimal number, 16 hexadecimal, etc. Must be in the range of 2 + * to 36. + * + * Note that this function will overflow a buffer if `str` is not large enough + * to hold the output! It may be safer to use SDL_snprintf to clamp output, or + * SDL_asprintf to allocate a buffer. Otherwise, it doesn't hurt to allocate + * much more space than you expect to use (and don't forget possible negative + * signs, null terminator bytes, etc). + * + * \param value the long integer to convert. + * \param str the buffer to write the string into. + * \param radix the radix to use for string generation. + * \returns `str`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_ultoa + * \sa SDL_itoa + * \sa SDL_lltoa + */ +extern SDL_DECLSPEC char * SDLCALL SDL_ltoa(long value, char *str, int radix); + +/** + * Convert an unsigned long integer into a string. + * + * This requires a radix to specified for string format. Specifying 10 + * produces a decimal number, 16 hexadecimal, etc. Must be in the range of 2 + * to 36. + * + * Note that this function will overflow a buffer if `str` is not large enough + * to hold the output! It may be safer to use SDL_snprintf to clamp output, or + * SDL_asprintf to allocate a buffer. Otherwise, it doesn't hurt to allocate + * much more space than you expect to use (and don't forget null terminator + * bytes, etc). + * + * \param value the unsigned long integer to convert. + * \param str the buffer to write the string into. + * \param radix the radix to use for string generation. + * \returns `str`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_ltoa + * \sa SDL_uitoa + * \sa SDL_ulltoa + */ +extern SDL_DECLSPEC char * SDLCALL SDL_ultoa(unsigned long value, char *str, int radix); + +#ifndef SDL_NOLONGLONG + +/** + * Convert a long long integer into a string. + * + * This requires a radix to specified for string format. Specifying 10 + * produces a decimal number, 16 hexadecimal, etc. Must be in the range of 2 + * to 36. + * + * Note that this function will overflow a buffer if `str` is not large enough + * to hold the output! It may be safer to use SDL_snprintf to clamp output, or + * SDL_asprintf to allocate a buffer. Otherwise, it doesn't hurt to allocate + * much more space than you expect to use (and don't forget possible negative + * signs, null terminator bytes, etc). + * + * \param value the long long integer to convert. + * \param str the buffer to write the string into. + * \param radix the radix to use for string generation. + * \returns `str`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_ulltoa + * \sa SDL_itoa + * \sa SDL_ltoa + */ +extern SDL_DECLSPEC char * SDLCALL SDL_lltoa(long long value, char *str, int radix); + +/** + * Convert an unsigned long long integer into a string. + * + * This requires a radix to specified for string format. Specifying 10 + * produces a decimal number, 16 hexadecimal, etc. Must be in the range of 2 + * to 36. + * + * Note that this function will overflow a buffer if `str` is not large enough + * to hold the output! It may be safer to use SDL_snprintf to clamp output, or + * SDL_asprintf to allocate a buffer. Otherwise, it doesn't hurt to allocate + * much more space than you expect to use (and don't forget null terminator + * bytes, etc). + * + * \param value the unsigned long long integer to convert. + * \param str the buffer to write the string into. + * \param radix the radix to use for string generation. + * \returns `str`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_lltoa + * \sa SDL_uitoa + * \sa SDL_ultoa + */ +extern SDL_DECLSPEC char * SDLCALL SDL_ulltoa(unsigned long long value, char *str, int radix); +#endif + +/** + * Parse an `int` from a string. + * + * The result of calling `SDL_atoi(str)` is equivalent to + * `(int)SDL_strtol(str, NULL, 10)`. + * + * \param str The null-terminated string to read. Must not be NULL. + * \returns the parsed `int`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_atof + * \sa SDL_strtol + * \sa SDL_strtoul + * \sa SDL_strtoll + * \sa SDL_strtoull + * \sa SDL_strtod + * \sa SDL_itoa + */ +extern SDL_DECLSPEC int SDLCALL SDL_atoi(const char *str); + +/** + * Parse a `double` from a string. + * + * The result of calling `SDL_atof(str)` is equivalent to `SDL_strtod(str, + * NULL)`. + * + * \param str The null-terminated string to read. Must not be NULL. + * \returns the parsed `double`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_atoi + * \sa SDL_strtol + * \sa SDL_strtoul + * \sa SDL_strtoll + * \sa SDL_strtoull + * \sa SDL_strtod + */ +extern SDL_DECLSPEC double SDLCALL SDL_atof(const char *str); + +/** + * Parse a `long` from a string. + * + * If `str` starts with whitespace, then those whitespace characters are + * skipped before attempting to parse the number. + * + * If the parsed number does not fit inside a `long`, the result is clamped to + * the minimum and maximum representable `long` values. + * + * \param str The null-terminated string to read. Must not be NULL. + * \param endp If not NULL, the address of the first invalid character (i.e. + * the next character after the parsed number) will be written to + * this pointer. + * \param base The base of the integer to read. Supported values are 0 and 2 + * to 36 inclusive. If 0, the base will be inferred from the + * number's prefix (0x for hexadecimal, 0 for octal, decimal + * otherwise). + * \returns the parsed `long`, or 0 if no number could be parsed. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_atoi + * \sa SDL_atof + * \sa SDL_strtoul + * \sa SDL_strtoll + * \sa SDL_strtoull + * \sa SDL_strtod + * \sa SDL_ltoa + * \sa SDL_wcstol + */ +extern SDL_DECLSPEC long SDLCALL SDL_strtol(const char *str, char **endp, int base); + +/** + * Parse an `unsigned long` from a string. + * + * If `str` starts with whitespace, then those whitespace characters are + * skipped before attempting to parse the number. + * + * If the parsed number does not fit inside an `unsigned long`, the result is + * clamped to the maximum representable `unsigned long` value. + * + * \param str The null-terminated string to read. Must not be NULL. + * \param endp If not NULL, the address of the first invalid character (i.e. + * the next character after the parsed number) will be written to + * this pointer. + * \param base The base of the integer to read. Supported values are 0 and 2 + * to 36 inclusive. If 0, the base will be inferred from the + * number's prefix (0x for hexadecimal, 0 for octal, decimal + * otherwise). + * \returns the parsed `unsigned long`, or 0 if no number could be parsed. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_atoi + * \sa SDL_atof + * \sa SDL_strtol + * \sa SDL_strtoll + * \sa SDL_strtoull + * \sa SDL_strtod + * \sa SDL_ultoa + */ +extern SDL_DECLSPEC unsigned long SDLCALL SDL_strtoul(const char *str, char **endp, int base); + +#ifndef SDL_NOLONGLONG + +/** + * Parse a `long long` from a string. + * + * If `str` starts with whitespace, then those whitespace characters are + * skipped before attempting to parse the number. + * + * If the parsed number does not fit inside a `long long`, the result is + * clamped to the minimum and maximum representable `long long` values. + * + * \param str The null-terminated string to read. Must not be NULL. + * \param endp If not NULL, the address of the first invalid character (i.e. + * the next character after the parsed number) will be written to + * this pointer. + * \param base The base of the integer to read. Supported values are 0 and 2 + * to 36 inclusive. If 0, the base will be inferred from the + * number's prefix (0x for hexadecimal, 0 for octal, decimal + * otherwise). + * \returns the parsed `long long`, or 0 if no number could be parsed. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_atoi + * \sa SDL_atof + * \sa SDL_strtol + * \sa SDL_strtoul + * \sa SDL_strtoull + * \sa SDL_strtod + * \sa SDL_lltoa + */ +extern SDL_DECLSPEC long long SDLCALL SDL_strtoll(const char *str, char **endp, int base); + +/** + * Parse an `unsigned long long` from a string. + * + * If `str` starts with whitespace, then those whitespace characters are + * skipped before attempting to parse the number. + * + * If the parsed number does not fit inside an `unsigned long long`, the + * result is clamped to the maximum representable `unsigned long long` value. + * + * \param str The null-terminated string to read. Must not be NULL. + * \param endp If not NULL, the address of the first invalid character (i.e. + * the next character after the parsed number) will be written to + * this pointer. + * \param base The base of the integer to read. Supported values are 0 and 2 + * to 36 inclusive. If 0, the base will be inferred from the + * number's prefix (0x for hexadecimal, 0 for octal, decimal + * otherwise). + * \returns the parsed `unsigned long long`, or 0 if no number could be + * parsed. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_atoi + * \sa SDL_atof + * \sa SDL_strtol + * \sa SDL_strtoll + * \sa SDL_strtoul + * \sa SDL_strtod + * \sa SDL_ulltoa + */ +extern SDL_DECLSPEC unsigned long long SDLCALL SDL_strtoull(const char *str, char **endp, int base); +#endif + +/** + * Parse a `double` from a string. + * + * This function makes fewer guarantees than the C runtime `strtod`: + * + * - Only decimal notation is guaranteed to be supported. The handling of + * scientific and hexadecimal notation is unspecified. + * - Whether or not INF and NAN can be parsed is unspecified. + * - The precision of the result is unspecified. + * + * \param str the null-terminated string to read. Must not be NULL. + * \param endp if not NULL, the address of the first invalid character (i.e. + * the next character after the parsed number) will be written to + * this pointer. + * \returns the parsed `double`, or 0 if no number could be parsed. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_atoi + * \sa SDL_atof + * \sa SDL_strtol + * \sa SDL_strtoll + * \sa SDL_strtoul + * \sa SDL_strtoull + */ +extern SDL_DECLSPEC double SDLCALL SDL_strtod(const char *str, char **endp); + +/** + * Compare two null-terminated UTF-8 strings. + * + * Due to the nature of UTF-8 encoding, this will work with Unicode strings, + * since effectively this function just compares bytes until it hits a + * null-terminating character. Also due to the nature of UTF-8, this can be + * used with SDL_qsort() to put strings in (roughly) alphabetical order. + * + * \param str1 the first string to compare. NULL is not permitted! + * \param str2 the second string to compare. NULL is not permitted! + * \returns less than zero if str1 is "less than" str2, greater than zero if + * str1 is "greater than" str2, and zero if the strings match + * exactly. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_strcmp(const char *str1, const char *str2); + +/** + * Compare two UTF-8 strings up to a number of bytes. + * + * Due to the nature of UTF-8 encoding, this will work with Unicode strings, + * since effectively this function just compares bytes until it hits a + * null-terminating character. Also due to the nature of UTF-8, this can be + * used with SDL_qsort() to put strings in (roughly) alphabetical order. + * + * Note that while this function is intended to be used with UTF-8, it is + * doing a bytewise comparison, and `maxlen` specifies a _byte_ limit! If the + * limit lands in the middle of a multi-byte UTF-8 sequence, it will only + * compare a portion of the final character. + * + * `maxlen` specifies a maximum number of bytes to compare; if the strings + * match to this number of bytes (or both have matched to a null-terminator + * character before this number of bytes), they will be considered equal. + * + * \param str1 the first string to compare. NULL is not permitted! + * \param str2 the second string to compare. NULL is not permitted! + * \param maxlen the maximum number of _bytes_ to compare. + * \returns less than zero if str1 is "less than" str2, greater than zero if + * str1 is "greater than" str2, and zero if the strings match + * exactly. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2, size_t maxlen); + +/** + * Compare two null-terminated UTF-8 strings, case-insensitively. + * + * This will work with Unicode strings, using a technique called + * "case-folding" to handle the vast majority of case-sensitive human + * languages regardless of system locale. It can deal with expanding values: a + * German Eszett character can compare against two ASCII 's' chars and be + * considered a match, for example. A notable exception: it does not handle + * the Turkish 'i' character; human language is complicated! + * + * Since this handles Unicode, it expects the string to be well-formed UTF-8 + * and not a null-terminated string of arbitrary bytes. Bytes that are not + * valid UTF-8 are treated as Unicode character U+FFFD (REPLACEMENT + * CHARACTER), which is to say two strings of random bits may turn out to + * match if they convert to the same amount of replacement characters. + * + * \param str1 the first string to compare. NULL is not permitted! + * \param str2 the second string to compare. NULL is not permitted! + * \returns less than zero if str1 is "less than" str2, greater than zero if + * str1 is "greater than" str2, and zero if the strings match + * exactly. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1, const char *str2); + + +/** + * Compare two UTF-8 strings, case-insensitively, up to a number of bytes. + * + * This will work with Unicode strings, using a technique called + * "case-folding" to handle the vast majority of case-sensitive human + * languages regardless of system locale. It can deal with expanding values: a + * German Eszett character can compare against two ASCII 's' chars and be + * considered a match, for example. A notable exception: it does not handle + * the Turkish 'i' character; human language is complicated! + * + * Since this handles Unicode, it expects the string to be well-formed UTF-8 + * and not a null-terminated string of arbitrary bytes. Bytes that are not + * valid UTF-8 are treated as Unicode character U+FFFD (REPLACEMENT + * CHARACTER), which is to say two strings of random bits may turn out to + * match if they convert to the same amount of replacement characters. + * + * Note that while this function is intended to be used with UTF-8, `maxlen` + * specifies a _byte_ limit! If the limit lands in the middle of a multi-byte + * UTF-8 sequence, it may convert a portion of the final character to one or + * more Unicode character U+FFFD (REPLACEMENT CHARACTER) so as not to overflow + * a buffer. + * + * `maxlen` specifies a maximum number of bytes to compare; if the strings + * match to this number of bytes (or both have matched to a null-terminator + * character before this number of bytes), they will be considered equal. + * + * \param str1 the first string to compare. NULL is not permitted! + * \param str2 the second string to compare. NULL is not permitted! + * \param maxlen the maximum number of bytes to compare. + * \returns less than zero if str1 is "less than" str2, greater than zero if + * str1 is "greater than" str2, and zero if the strings match + * exactly. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_strncasecmp(const char *str1, const char *str2, size_t maxlen); + +/** + * Searches a string for the first occurrence of any character contained in a + * breakset, and returns a pointer from the string to that character. + * + * \param str The null-terminated string to be searched. Must not be NULL, and + * must not overlap with `breakset`. + * \param breakset A null-terminated string containing the list of characters + * to look for. Must not be NULL, and must not overlap with + * `str`. + * \returns A pointer to the location, in str, of the first occurrence of a + * character present in the breakset, or NULL if none is found. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC char * SDLCALL SDL_strpbrk(const char *str, const char *breakset); + +/** + * The Unicode REPLACEMENT CHARACTER codepoint. + * + * SDL_StepUTF8() and SDL_StepBackUTF8() report this codepoint when they + * encounter a UTF-8 string with encoding errors. + * + * This tends to render as something like a question mark in most places. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_StepBackUTF8 + * \sa SDL_StepUTF8 + */ +#define SDL_INVALID_UNICODE_CODEPOINT 0xFFFD + +/** + * Decode a UTF-8 string, one Unicode codepoint at a time. + * + * This will return the first Unicode codepoint in the UTF-8 encoded string in + * `*pstr`, and then advance `*pstr` past any consumed bytes before returning. + * + * It will not access more than `*pslen` bytes from the string. `*pslen` will + * be adjusted, as well, subtracting the number of bytes consumed. + * + * `pslen` is allowed to be NULL, in which case the string _must_ be + * NULL-terminated, as the function will blindly read until it sees the NULL + * char. + * + * if `*pslen` is zero, it assumes the end of string is reached and returns a + * zero codepoint regardless of the contents of the string buffer. + * + * If the resulting codepoint is zero (a NULL terminator), or `*pslen` is + * zero, it will not advance `*pstr` or `*pslen` at all. + * + * Generally this function is called in a loop until it returns zero, + * adjusting its parameters each iteration. + * + * If an invalid UTF-8 sequence is encountered, this function returns + * SDL_INVALID_UNICODE_CODEPOINT and advances the string/length by one byte + * (which is to say, a multibyte sequence might produce several + * SDL_INVALID_UNICODE_CODEPOINT returns before it syncs to the next valid + * UTF-8 sequence). + * + * Several things can generate invalid UTF-8 sequences, including overlong + * encodings, the use of UTF-16 surrogate values, and truncated data. Please + * refer to + * [RFC3629](https://www.ietf.org/rfc/rfc3629.txt) + * for details. + * + * \param pstr a pointer to a UTF-8 string pointer to be read and adjusted. + * \param pslen a pointer to the number of bytes in the string, to be read and + * adjusted. NULL is allowed. + * \returns the first Unicode codepoint in the string. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC Uint32 SDLCALL SDL_StepUTF8(const char **pstr, size_t *pslen); + +/** + * Decode a UTF-8 string in reverse, one Unicode codepoint at a time. + * + * This will go to the start of the previous Unicode codepoint in the string, + * move `*pstr` to that location and return that codepoint. + * + * If `*pstr` is already at the start of the string), it will not advance + * `*pstr` at all. + * + * Generally this function is called in a loop until it returns zero, + * adjusting its parameter each iteration. + * + * If an invalid UTF-8 sequence is encountered, this function returns + * SDL_INVALID_UNICODE_CODEPOINT. + * + * Several things can generate invalid UTF-8 sequences, including overlong + * encodings, the use of UTF-16 surrogate values, and truncated data. Please + * refer to + * [RFC3629](https://www.ietf.org/rfc/rfc3629.txt) + * for details. + * + * \param start a pointer to the beginning of the UTF-8 string. + * \param pstr a pointer to a UTF-8 string pointer to be read and adjusted. + * \returns the previous Unicode codepoint in the string. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC Uint32 SDLCALL SDL_StepBackUTF8(const char *start, const char **pstr); + +/** + * Convert a single Unicode codepoint to UTF-8. + * + * The buffer pointed to by `dst` must be at least 4 bytes long, as this + * function may generate between 1 and 4 bytes of output. + * + * This function returns the first byte _after_ the newly-written UTF-8 + * sequence, which is useful for encoding multiple codepoints in a loop, or + * knowing where to write a NULL-terminator character to end the string (in + * either case, plan to have a buffer of _more_ than 4 bytes!). + * + * If `codepoint` is an invalid value (outside the Unicode range, or a UTF-16 + * surrogate value, etc), this will use U+FFFD (REPLACEMENT CHARACTER) for the + * codepoint instead, and not set an error. + * + * If `dst` is NULL, this returns NULL immediately without writing to the + * pointer and without setting an error. + * + * \param codepoint a Unicode codepoint to convert to UTF-8. + * \param dst the location to write the encoded UTF-8. Must point to at least + * 4 bytes! + * \returns the first byte past the newly-written UTF-8 sequence. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC char * SDLCALL SDL_UCS4ToUTF8(Uint32 codepoint, char *dst); + +/** + * This works exactly like sscanf() but doesn't require access to a C runtime. + * + * Scan a string, matching a format string, converting each '%' item and + * storing it to pointers provided through variable arguments. + * + * \param text the string to scan. Must not be NULL. + * \param fmt a printf-style format string. Must not be NULL. + * \param ... a list of pointers to values to be filled in with scanned items. + * \returns the number of items that matched the format string. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_sscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, ...) SDL_SCANF_VARARG_FUNC(2); + +/** + * This works exactly like vsscanf() but doesn't require access to a C + * runtime. + * + * Functions identically to SDL_sscanf(), except it takes a `va_list` instead + * of using `...` variable arguments. + * + * \param text the string to scan. Must not be NULL. + * \param fmt a printf-style format string. Must not be NULL. + * \param ap a `va_list` of pointers to values to be filled in with scanned + * items. + * \returns the number of items that matched the format string. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_vsscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, va_list ap) SDL_SCANF_VARARG_FUNCV(2); + +/** + * This works exactly like snprintf() but doesn't require access to a C + * runtime. + * + * Format a string of up to `maxlen`-1 bytes, converting each '%' item with + * values provided through variable arguments. + * + * While some C runtimes differ on how to deal with too-large strings, this + * function null-terminates the output, by treating the null-terminator as + * part of the `maxlen` count. Note that if `maxlen` is zero, however, no + * bytes will be written at all. + * + * This function returns the number of _bytes_ (not _characters_) that should + * be written, excluding the null-terminator character. If this returns a + * number >= `maxlen`, it means the output string was truncated. A negative + * return value means an error occurred. + * + * Referencing the output string's pointer with a format item is undefined + * behavior. + * + * \param text the buffer to write the string into. Must not be NULL. + * \param maxlen the maximum bytes to write, including the null-terminator. + * \param fmt a printf-style format string. Must not be NULL. + * \param ... a list of values to be used with the format string. + * \returns the number of bytes that should be written, not counting the + * null-terminator char, or a negative value on error. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_snprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(3); + +/** + * This works exactly like swprintf() but doesn't require access to a C + * runtime. + * + * Format a wide string of up to `maxlen`-1 wchar_t values, converting each + * '%' item with values provided through variable arguments. + * + * While some C runtimes differ on how to deal with too-large strings, this + * function null-terminates the output, by treating the null-terminator as + * part of the `maxlen` count. Note that if `maxlen` is zero, however, no wide + * characters will be written at all. + * + * This function returns the number of _wide characters_ (not _codepoints_) + * that should be written, excluding the null-terminator character. If this + * returns a number >= `maxlen`, it means the output string was truncated. A + * negative return value means an error occurred. + * + * Referencing the output string's pointer with a format item is undefined + * behavior. + * + * \param text the buffer to write the wide string into. Must not be NULL. + * \param maxlen the maximum wchar_t values to write, including the + * null-terminator. + * \param fmt a printf-style format string. Must not be NULL. + * \param ... a list of values to be used with the format string. + * \returns the number of wide characters that should be written, not counting + * the null-terminator char, or a negative value on error. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_swprintf(SDL_OUT_Z_CAP(maxlen) wchar_t *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const wchar_t *fmt, ...) SDL_WPRINTF_VARARG_FUNC(3); + +/** + * This works exactly like vsnprintf() but doesn't require access to a C + * runtime. + * + * Functions identically to SDL_snprintf(), except it takes a `va_list` + * instead of using `...` variable arguments. + * + * \param text the buffer to write the string into. Must not be NULL. + * \param maxlen the maximum bytes to write, including the null-terminator. + * \param fmt a printf-style format string. Must not be NULL. + * \param ap a `va_list` values to be used with the format string. + * \returns the number of bytes that should be written, not counting the + * null-terminator char, or a negative value on error. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap) SDL_PRINTF_VARARG_FUNCV(3); + +/** + * This works exactly like vswprintf() but doesn't require access to a C + * runtime. + * + * Functions identically to SDL_swprintf(), except it takes a `va_list` + * instead of using `...` variable arguments. + * + * \param text the buffer to write the string into. Must not be NULL. + * \param maxlen the maximum wide characters to write, including the + * null-terminator. + * \param fmt a printf-style format wide string. Must not be NULL. + * \param ap a `va_list` values to be used with the format string. + * \returns the number of wide characters that should be written, not counting + * the null-terminator char, or a negative value on error. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_vswprintf(SDL_OUT_Z_CAP(maxlen) wchar_t *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const wchar_t *fmt, va_list ap) SDL_WPRINTF_VARARG_FUNCV(3); + +/** + * This works exactly like asprintf() but doesn't require access to a C + * runtime. + * + * Functions identically to SDL_snprintf(), except it allocates a buffer large + * enough to hold the output string on behalf of the caller. + * + * On success, this function returns the number of bytes (not characters) + * comprising the output string, not counting the null-terminator character, + * and sets `*strp` to the newly-allocated string. + * + * On error, this function returns a negative number, and the value of `*strp` + * is undefined. + * + * The returned string is owned by the caller, and should be passed to + * SDL_free when no longer needed. + * + * \param strp on output, is set to the new string. Must not be NULL. + * \param fmt a printf-style format string. Must not be NULL. + * \param ... a list of values to be used with the format string. + * \returns the number of bytes in the newly-allocated string, not counting + * the null-terminator char, or a negative value on error. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_asprintf(char **strp, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); + +/** + * This works exactly like vasprintf() but doesn't require access to a C + * runtime. + * + * Functions identically to SDL_asprintf(), except it takes a `va_list` + * instead of using `...` variable arguments. + * + * \param strp on output, is set to the new string. Must not be NULL. + * \param fmt a printf-style format string. Must not be NULL. + * \param ap a `va_list` values to be used with the format string. + * \returns the number of bytes in the newly-allocated string, not counting + * the null-terminator char, or a negative value on error. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_vasprintf(char **strp, SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap) SDL_PRINTF_VARARG_FUNCV(2); + +/** + * Seeds the pseudo-random number generator. + * + * Reusing the seed number will cause SDL_rand() to repeat the same stream of + * 'random' numbers. + * + * \param seed the value to use as a random number seed, or 0 to use + * SDL_GetPerformanceCounter(). + * + * \threadsafety This should be called on the same thread that calls + * SDL_rand() + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_rand + * \sa SDL_rand_bits + * \sa SDL_randf + */ +extern SDL_DECLSPEC void SDLCALL SDL_srand(Uint64 seed); + +/** + * Generate a pseudo-random number less than n for positive n + * + * The method used is faster and of better quality than `rand() % n`. Odds are + * roughly 99.9% even for n = 1 million. Evenness is better for smaller n, and + * much worse as n gets bigger. + * + * Example: to simulate a d6 use `SDL_rand(6) + 1` The +1 converts 0..5 to + * 1..6 + * + * If you want to generate a pseudo-random number in the full range of Sint32, + * you should use: (Sint32)SDL_rand_bits() + * + * If you want reproducible output, be sure to initialize with SDL_srand() + * first. + * + * There are no guarantees as to the quality of the random sequence produced, + * and this should not be used for security (cryptography, passwords) or where + * money is on the line (loot-boxes, casinos). There are many random number + * libraries available with different characteristics and you should pick one + * of those to meet any serious needs. + * + * \param n the number of possible outcomes. n must be positive. + * \returns a random value in the range of [0 .. n-1]. + * + * \threadsafety All calls should be made from a single thread + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_srand + * \sa SDL_randf + */ +extern SDL_DECLSPEC Sint32 SDLCALL SDL_rand(Sint32 n); + +/** + * Generate a uniform pseudo-random floating point number less than 1.0 + * + * If you want reproducible output, be sure to initialize with SDL_srand() + * first. + * + * There are no guarantees as to the quality of the random sequence produced, + * and this should not be used for security (cryptography, passwords) or where + * money is on the line (loot-boxes, casinos). There are many random number + * libraries available with different characteristics and you should pick one + * of those to meet any serious needs. + * + * \returns a random value in the range of [0.0, 1.0). + * + * \threadsafety All calls should be made from a single thread + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_srand + * \sa SDL_rand + */ +extern SDL_DECLSPEC float SDLCALL SDL_randf(void); + +/** + * Generate 32 pseudo-random bits. + * + * You likely want to use SDL_rand() to get a psuedo-random number instead. + * + * There are no guarantees as to the quality of the random sequence produced, + * and this should not be used for security (cryptography, passwords) or where + * money is on the line (loot-boxes, casinos). There are many random number + * libraries available with different characteristics and you should pick one + * of those to meet any serious needs. + * + * \returns a random value in the range of [0-SDL_MAX_UINT32]. + * + * \threadsafety All calls should be made from a single thread + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_rand + * \sa SDL_randf + * \sa SDL_srand + */ +extern SDL_DECLSPEC Uint32 SDLCALL SDL_rand_bits(void); + +/** + * Generate a pseudo-random number less than n for positive n + * + * The method used is faster and of better quality than `rand() % n`. Odds are + * roughly 99.9% even for n = 1 million. Evenness is better for smaller n, and + * much worse as n gets bigger. + * + * Example: to simulate a d6 use `SDL_rand_r(state, 6) + 1` The +1 converts + * 0..5 to 1..6 + * + * If you want to generate a pseudo-random number in the full range of Sint32, + * you should use: (Sint32)SDL_rand_bits_r(state) + * + * There are no guarantees as to the quality of the random sequence produced, + * and this should not be used for security (cryptography, passwords) or where + * money is on the line (loot-boxes, casinos). There are many random number + * libraries available with different characteristics and you should pick one + * of those to meet any serious needs. + * + * \param state a pointer to the current random number state, this may not be + * NULL. + * \param n the number of possible outcomes. n must be positive. + * \returns a random value in the range of [0 .. n-1]. + * + * \threadsafety This function is thread-safe, as long as the state pointer + * isn't shared between threads. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_rand + * \sa SDL_rand_bits_r + * \sa SDL_randf_r + */ +extern SDL_DECLSPEC Sint32 SDLCALL SDL_rand_r(Uint64 *state, Sint32 n); + +/** + * Generate a uniform pseudo-random floating point number less than 1.0 + * + * If you want reproducible output, be sure to initialize with SDL_srand() + * first. + * + * There are no guarantees as to the quality of the random sequence produced, + * and this should not be used for security (cryptography, passwords) or where + * money is on the line (loot-boxes, casinos). There are many random number + * libraries available with different characteristics and you should pick one + * of those to meet any serious needs. + * + * \param state a pointer to the current random number state, this may not be + * NULL. + * \returns a random value in the range of [0.0, 1.0). + * + * \threadsafety This function is thread-safe, as long as the state pointer + * isn't shared between threads. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_rand_bits_r + * \sa SDL_rand_r + * \sa SDL_randf + */ +extern SDL_DECLSPEC float SDLCALL SDL_randf_r(Uint64 *state); + +/** + * Generate 32 pseudo-random bits. + * + * You likely want to use SDL_rand_r() to get a psuedo-random number instead. + * + * There are no guarantees as to the quality of the random sequence produced, + * and this should not be used for security (cryptography, passwords) or where + * money is on the line (loot-boxes, casinos). There are many random number + * libraries available with different characteristics and you should pick one + * of those to meet any serious needs. + * + * \param state a pointer to the current random number state, this may not be + * NULL. + * \returns a random value in the range of [0-SDL_MAX_UINT32]. + * + * \threadsafety This function is thread-safe, as long as the state pointer + * isn't shared between threads. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_rand_r + * \sa SDL_randf_r + */ +extern SDL_DECLSPEC Uint32 SDLCALL SDL_rand_bits_r(Uint64 *state); + +#ifndef SDL_PI_D + +/** + * The value of Pi, as a double-precision floating point literal. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_PI_F + */ +#define SDL_PI_D 3.141592653589793238462643383279502884 /**< pi (double) */ +#endif + +#ifndef SDL_PI_F + +/** + * The value of Pi, as a single-precision floating point literal. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_PI_D + */ +#define SDL_PI_F 3.141592653589793238462643383279502884F /**< pi (float) */ +#endif + +/** + * Compute the arc cosine of `x`. + * + * The definition of `y = acos(x)` is `x = cos(y)`. + * + * Domain: `-1 <= x <= 1` + * + * Range: `0 <= y <= Pi` + * + * This function operates on double-precision floating point values, use + * SDL_acosf for single-precision floats. + * + * This function may use a different approximation across different versions, + * platforms and configurations. i.e, it can return a different value given + * the same input on different machines or operating systems, or if SDL is + * updated. + * + * \param x floating point value. + * \returns arc cosine of `x`, in radians. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_acosf + * \sa SDL_asin + * \sa SDL_cos + */ +extern SDL_DECLSPEC double SDLCALL SDL_acos(double x); + +/** + * Compute the arc cosine of `x`. + * + * The definition of `y = acos(x)` is `x = cos(y)`. + * + * Domain: `-1 <= x <= 1` + * + * Range: `0 <= y <= Pi` + * + * This function operates on single-precision floating point values, use + * SDL_acos for double-precision floats. + * + * This function may use a different approximation across different versions, + * platforms and configurations. i.e, it can return a different value given + * the same input on different machines or operating systems, or if SDL is + * updated. + * + * \param x floating point value. + * \returns arc cosine of `x`, in radians. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_acos + * \sa SDL_asinf + * \sa SDL_cosf + */ +extern SDL_DECLSPEC float SDLCALL SDL_acosf(float x); + +/** + * Compute the arc sine of `x`. + * + * The definition of `y = asin(x)` is `x = sin(y)`. + * + * Domain: `-1 <= x <= 1` + * + * Range: `-Pi/2 <= y <= Pi/2` + * + * This function operates on double-precision floating point values, use + * SDL_asinf for single-precision floats. + * + * This function may use a different approximation across different versions, + * platforms and configurations. i.e, it can return a different value given + * the same input on different machines or operating systems, or if SDL is + * updated. + * + * \param x floating point value. + * \returns arc sine of `x`, in radians. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_asinf + * \sa SDL_acos + * \sa SDL_sin + */ +extern SDL_DECLSPEC double SDLCALL SDL_asin(double x); + +/** + * Compute the arc sine of `x`. + * + * The definition of `y = asin(x)` is `x = sin(y)`. + * + * Domain: `-1 <= x <= 1` + * + * Range: `-Pi/2 <= y <= Pi/2` + * + * This function operates on single-precision floating point values, use + * SDL_asin for double-precision floats. + * + * This function may use a different approximation across different versions, + * platforms and configurations. i.e, it can return a different value given + * the same input on different machines or operating systems, or if SDL is + * updated. + * + * \param x floating point value. + * \returns arc sine of `x`, in radians. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_asin + * \sa SDL_acosf + * \sa SDL_sinf + */ +extern SDL_DECLSPEC float SDLCALL SDL_asinf(float x); + +/** + * Compute the arc tangent of `x`. + * + * The definition of `y = atan(x)` is `x = tan(y)`. + * + * Domain: `-INF <= x <= INF` + * + * Range: `-Pi/2 <= y <= Pi/2` + * + * This function operates on double-precision floating point values, use + * SDL_atanf for single-precision floats. + * + * To calculate the arc tangent of y / x, use SDL_atan2. + * + * This function may use a different approximation across different versions, + * platforms and configurations. i.e, it can return a different value given + * the same input on different machines or operating systems, or if SDL is + * updated. + * + * \param x floating point value. + * \returns arc tangent of of `x` in radians, or 0 if `x = 0`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_atanf + * \sa SDL_atan2 + * \sa SDL_tan + */ +extern SDL_DECLSPEC double SDLCALL SDL_atan(double x); + +/** + * Compute the arc tangent of `x`. + * + * The definition of `y = atan(x)` is `x = tan(y)`. + * + * Domain: `-INF <= x <= INF` + * + * Range: `-Pi/2 <= y <= Pi/2` + * + * This function operates on single-precision floating point values, use + * SDL_atan for dboule-precision floats. + * + * To calculate the arc tangent of y / x, use SDL_atan2f. + * + * This function may use a different approximation across different versions, + * platforms and configurations. i.e, it can return a different value given + * the same input on different machines or operating systems, or if SDL is + * updated. + * + * \param x floating point value. + * \returns arc tangent of of `x` in radians, or 0 if `x = 0`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_atan + * \sa SDL_atan2f + * \sa SDL_tanf + */ +extern SDL_DECLSPEC float SDLCALL SDL_atanf(float x); + +/** + * Compute the arc tangent of `y / x`, using the signs of x and y to adjust + * the result's quadrant. + * + * The definition of `z = atan2(x, y)` is `y = x tan(z)`, where the quadrant + * of z is determined based on the signs of x and y. + * + * Domain: `-INF <= x <= INF`, `-INF <= y <= INF` + * + * Range: `-Pi <= y <= Pi` + * + * This function operates on double-precision floating point values, use + * SDL_atan2f for single-precision floats. + * + * To calculate the arc tangent of a single value, use SDL_atan. + * + * This function may use a different approximation across different versions, + * platforms and configurations. i.e, it can return a different value given + * the same input on different machines or operating systems, or if SDL is + * updated. + * + * \param y floating point value of the numerator (y coordinate). + * \param x floating point value of the denominator (x coordinate). + * \returns arc tangent of of `y / x` in radians, or, if `x = 0`, either + * `-Pi/2`, `0`, or `Pi/2`, depending on the value of `y`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_atan2f + * \sa SDL_atan + * \sa SDL_tan + */ +extern SDL_DECLSPEC double SDLCALL SDL_atan2(double y, double x); + +/** + * Compute the arc tangent of `y / x`, using the signs of x and y to adjust + * the result's quadrant. + * + * The definition of `z = atan2(x, y)` is `y = x tan(z)`, where the quadrant + * of z is determined based on the signs of x and y. + * + * Domain: `-INF <= x <= INF`, `-INF <= y <= INF` + * + * Range: `-Pi <= y <= Pi` + * + * This function operates on single-precision floating point values, use + * SDL_atan2 for double-precision floats. + * + * To calculate the arc tangent of a single value, use SDL_atanf. + * + * This function may use a different approximation across different versions, + * platforms and configurations. i.e, it can return a different value given + * the same input on different machines or operating systems, or if SDL is + * updated. + * + * \param y floating point value of the numerator (y coordinate). + * \param x floating point value of the denominator (x coordinate). + * \returns arc tangent of of `y / x` in radians, or, if `x = 0`, either + * `-Pi/2`, `0`, or `Pi/2`, depending on the value of `y`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_atan2 + * \sa SDL_atan + * \sa SDL_tan + */ +extern SDL_DECLSPEC float SDLCALL SDL_atan2f(float y, float x); + +/** + * Compute the ceiling of `x`. + * + * The ceiling of `x` is the smallest integer `y` such that `y >= x`, i.e `x` + * rounded up to the nearest integer. + * + * Domain: `-INF <= x <= INF` + * + * Range: `-INF <= y <= INF`, y integer + * + * This function operates on double-precision floating point values, use + * SDL_ceilf for single-precision floats. + * + * \param x floating point value. + * \returns the ceiling of `x`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_ceilf + * \sa SDL_floor + * \sa SDL_trunc + * \sa SDL_round + * \sa SDL_lround + */ +extern SDL_DECLSPEC double SDLCALL SDL_ceil(double x); + +/** + * Compute the ceiling of `x`. + * + * The ceiling of `x` is the smallest integer `y` such that `y >= x`, i.e `x` + * rounded up to the nearest integer. + * + * Domain: `-INF <= x <= INF` + * + * Range: `-INF <= y <= INF`, y integer + * + * This function operates on single-precision floating point values, use + * SDL_ceil for double-precision floats. + * + * \param x floating point value. + * \returns the ceiling of `x`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_ceil + * \sa SDL_floorf + * \sa SDL_truncf + * \sa SDL_roundf + * \sa SDL_lroundf + */ +extern SDL_DECLSPEC float SDLCALL SDL_ceilf(float x); + +/** + * Copy the sign of one floating-point value to another. + * + * The definition of copysign is that ``copysign(x, y) = abs(x) * sign(y)``. + * + * Domain: `-INF <= x <= INF`, ``-INF <= y <= f`` + * + * Range: `-INF <= z <= INF` + * + * This function operates on double-precision floating point values, use + * SDL_copysignf for single-precision floats. + * + * \param x floating point value to use as the magnitude. + * \param y floating point value to use as the sign. + * \returns the floating point value with the sign of y and the magnitude of + * x. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_copysignf + * \sa SDL_fabs + */ +extern SDL_DECLSPEC double SDLCALL SDL_copysign(double x, double y); + +/** + * Copy the sign of one floating-point value to another. + * + * The definition of copysign is that ``copysign(x, y) = abs(x) * sign(y)``. + * + * Domain: `-INF <= x <= INF`, ``-INF <= y <= f`` + * + * Range: `-INF <= z <= INF` + * + * This function operates on single-precision floating point values, use + * SDL_copysign for double-precision floats. + * + * \param x floating point value to use as the magnitude. + * \param y floating point value to use as the sign. + * \returns the floating point value with the sign of y and the magnitude of + * x. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_copysign + * \sa SDL_fabsf + */ +extern SDL_DECLSPEC float SDLCALL SDL_copysignf(float x, float y); + +/** + * Compute the cosine of `x`. + * + * Domain: `-INF <= x <= INF` + * + * Range: `-1 <= y <= 1` + * + * This function operates on double-precision floating point values, use + * SDL_cosf for single-precision floats. + * + * This function may use a different approximation across different versions, + * platforms and configurations. i.e, it can return a different value given + * the same input on different machines or operating systems, or if SDL is + * updated. + * + * \param x floating point value, in radians. + * \returns cosine of `x`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_cosf + * \sa SDL_acos + * \sa SDL_sin + */ +extern SDL_DECLSPEC double SDLCALL SDL_cos(double x); + +/** + * Compute the cosine of `x`. + * + * Domain: `-INF <= x <= INF` + * + * Range: `-1 <= y <= 1` + * + * This function operates on single-precision floating point values, use + * SDL_cos for double-precision floats. + * + * This function may use a different approximation across different versions, + * platforms and configurations. i.e, it can return a different value given + * the same input on different machines or operating systems, or if SDL is + * updated. + * + * \param x floating point value, in radians. + * \returns cosine of `x`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_cos + * \sa SDL_acosf + * \sa SDL_sinf + */ +extern SDL_DECLSPEC float SDLCALL SDL_cosf(float x); + +/** + * Compute the exponential of `x`. + * + * The definition of `y = exp(x)` is `y = e^x`, where `e` is the base of the + * natural logarithm. The inverse is the natural logarithm, SDL_log. + * + * Domain: `-INF <= x <= INF` + * + * Range: `0 <= y <= INF` + * + * The output will overflow if `exp(x)` is too large to be represented. + * + * This function operates on double-precision floating point values, use + * SDL_expf for single-precision floats. + * + * This function may use a different approximation across different versions, + * platforms and configurations. i.e, it can return a different value given + * the same input on different machines or operating systems, or if SDL is + * updated. + * + * \param x floating point value. + * \returns value of `e^x`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_expf + * \sa SDL_log + */ +extern SDL_DECLSPEC double SDLCALL SDL_exp(double x); + +/** + * Compute the exponential of `x`. + * + * The definition of `y = exp(x)` is `y = e^x`, where `e` is the base of the + * natural logarithm. The inverse is the natural logarithm, SDL_logf. + * + * Domain: `-INF <= x <= INF` + * + * Range: `0 <= y <= INF` + * + * The output will overflow if `exp(x)` is too large to be represented. + * + * This function operates on single-precision floating point values, use + * SDL_exp for double-precision floats. + * + * This function may use a different approximation across different versions, + * platforms and configurations. i.e, it can return a different value given + * the same input on different machines or operating systems, or if SDL is + * updated. + * + * \param x floating point value. + * \returns value of `e^x`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_exp + * \sa SDL_logf + */ +extern SDL_DECLSPEC float SDLCALL SDL_expf(float x); + +/** + * Compute the absolute value of `x` + * + * Domain: `-INF <= x <= INF` + * + * Range: `0 <= y <= INF` + * + * This function operates on double-precision floating point values, use + * SDL_fabsf for single-precision floats. + * + * \param x floating point value to use as the magnitude. + * \returns the absolute value of `x`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_fabsf + */ +extern SDL_DECLSPEC double SDLCALL SDL_fabs(double x); + +/** + * Compute the absolute value of `x` + * + * Domain: `-INF <= x <= INF` + * + * Range: `0 <= y <= INF` + * + * This function operates on single-precision floating point values, use + * SDL_fabs for double-precision floats. + * + * \param x floating point value to use as the magnitude. + * \returns the absolute value of `x`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_fabs + */ +extern SDL_DECLSPEC float SDLCALL SDL_fabsf(float x); + +/** + * Compute the floor of `x`. + * + * The floor of `x` is the largest integer `y` such that `y <= x`, i.e `x` + * rounded down to the nearest integer. + * + * Domain: `-INF <= x <= INF` + * + * Range: `-INF <= y <= INF`, y integer + * + * This function operates on double-precision floating point values, use + * SDL_floorf for single-precision floats. + * + * \param x floating point value. + * \returns the floor of `x`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_floorf + * \sa SDL_ceil + * \sa SDL_trunc + * \sa SDL_round + * \sa SDL_lround + */ +extern SDL_DECLSPEC double SDLCALL SDL_floor(double x); + +/** + * Compute the floor of `x`. + * + * The floor of `x` is the largest integer `y` such that `y <= x`, i.e `x` + * rounded down to the nearest integer. + * + * Domain: `-INF <= x <= INF` + * + * Range: `-INF <= y <= INF`, y integer + * + * This function operates on single-precision floating point values, use + * SDL_floor for double-precision floats. + * + * \param x floating point value. + * \returns the floor of `x`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_floor + * \sa SDL_ceilf + * \sa SDL_truncf + * \sa SDL_roundf + * \sa SDL_lroundf + */ +extern SDL_DECLSPEC float SDLCALL SDL_floorf(float x); + +/** + * Truncate `x` to an integer. + * + * Rounds `x` to the next closest integer to 0. This is equivalent to removing + * the fractional part of `x`, leaving only the integer part. + * + * Domain: `-INF <= x <= INF` + * + * Range: `-INF <= y <= INF`, y integer + * + * This function operates on double-precision floating point values, use + * SDL_truncf for single-precision floats. + * + * \param x floating point value. + * \returns `x` truncated to an integer. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_truncf + * \sa SDL_fmod + * \sa SDL_ceil + * \sa SDL_floor + * \sa SDL_round + * \sa SDL_lround + */ +extern SDL_DECLSPEC double SDLCALL SDL_trunc(double x); + +/** + * Truncate `x` to an integer. + * + * Rounds `x` to the next closest integer to 0. This is equivalent to removing + * the fractional part of `x`, leaving only the integer part. + * + * Domain: `-INF <= x <= INF` + * + * Range: `-INF <= y <= INF`, y integer + * + * This function operates on single-precision floating point values, use + * SDL_trunc for double-precision floats. + * + * \param x floating point value. + * \returns `x` truncated to an integer. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_trunc + * \sa SDL_fmodf + * \sa SDL_ceilf + * \sa SDL_floorf + * \sa SDL_roundf + * \sa SDL_lroundf + */ +extern SDL_DECLSPEC float SDLCALL SDL_truncf(float x); + +/** + * Return the floating-point remainder of `x / y` + * + * Divides `x` by `y`, and returns the remainder. + * + * Domain: `-INF <= x <= INF`, `-INF <= y <= INF`, `y != 0` + * + * Range: `-y <= z <= y` + * + * This function operates on double-precision floating point values, use + * SDL_fmodf for single-precision floats. + * + * \param x the numerator. + * \param y the denominator. Must not be 0. + * \returns the remainder of `x / y`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_fmodf + * \sa SDL_modf + * \sa SDL_trunc + * \sa SDL_ceil + * \sa SDL_floor + * \sa SDL_round + * \sa SDL_lround + */ +extern SDL_DECLSPEC double SDLCALL SDL_fmod(double x, double y); + +/** + * Return the floating-point remainder of `x / y` + * + * Divides `x` by `y`, and returns the remainder. + * + * Domain: `-INF <= x <= INF`, `-INF <= y <= INF`, `y != 0` + * + * Range: `-y <= z <= y` + * + * This function operates on single-precision floating point values, use + * SDL_fmod for double-precision floats. + * + * \param x the numerator. + * \param y the denominator. Must not be 0. + * \returns the remainder of `x / y`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_fmod + * \sa SDL_truncf + * \sa SDL_modff + * \sa SDL_ceilf + * \sa SDL_floorf + * \sa SDL_roundf + * \sa SDL_lroundf + */ +extern SDL_DECLSPEC float SDLCALL SDL_fmodf(float x, float y); + +/** + * Return whether the value is infinity. + * + * \param x double-precision floating point value. + * \returns non-zero if the value is infinity, 0 otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_isinff + */ +extern SDL_DECLSPEC int SDLCALL SDL_isinf(double x); + +/** + * Return whether the value is infinity. + * + * \param x floating point value. + * \returns non-zero if the value is infinity, 0 otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_isinf + */ +extern SDL_DECLSPEC int SDLCALL SDL_isinff(float x); + +/** + * Return whether the value is NaN. + * + * \param x double-precision floating point value. + * \returns non-zero if the value is NaN, 0 otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_isnanf + */ +extern SDL_DECLSPEC int SDLCALL SDL_isnan(double x); + +/** + * Return whether the value is NaN. + * + * \param x floating point value. + * \returns non-zero if the value is NaN, 0 otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_isnan + */ +extern SDL_DECLSPEC int SDLCALL SDL_isnanf(float x); + +/** + * Compute the natural logarithm of `x`. + * + * Domain: `0 < x <= INF` + * + * Range: `-INF <= y <= INF` + * + * It is an error for `x` to be less than or equal to 0. + * + * This function operates on double-precision floating point values, use + * SDL_logf for single-precision floats. + * + * This function may use a different approximation across different versions, + * platforms and configurations. i.e, it can return a different value given + * the same input on different machines or operating systems, or if SDL is + * updated. + * + * \param x floating point value. Must be greater than 0. + * \returns the natural logarithm of `x`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_logf + * \sa SDL_log10 + * \sa SDL_exp + */ +extern SDL_DECLSPEC double SDLCALL SDL_log(double x); + +/** + * Compute the natural logarithm of `x`. + * + * Domain: `0 < x <= INF` + * + * Range: `-INF <= y <= INF` + * + * It is an error for `x` to be less than or equal to 0. + * + * This function operates on single-precision floating point values, use + * SDL_log for double-precision floats. + * + * This function may use a different approximation across different versions, + * platforms and configurations. i.e, it can return a different value given + * the same input on different machines or operating systems, or if SDL is + * updated. + * + * \param x floating point value. Must be greater than 0. + * \returns the natural logarithm of `x`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_log + * \sa SDL_expf + */ +extern SDL_DECLSPEC float SDLCALL SDL_logf(float x); + +/** + * Compute the base-10 logarithm of `x`. + * + * Domain: `0 < x <= INF` + * + * Range: `-INF <= y <= INF` + * + * It is an error for `x` to be less than or equal to 0. + * + * This function operates on double-precision floating point values, use + * SDL_log10f for single-precision floats. + * + * This function may use a different approximation across different versions, + * platforms and configurations. i.e, it can return a different value given + * the same input on different machines or operating systems, or if SDL is + * updated. + * + * \param x floating point value. Must be greater than 0. + * \returns the logarithm of `x`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_log10f + * \sa SDL_log + * \sa SDL_pow + */ +extern SDL_DECLSPEC double SDLCALL SDL_log10(double x); + +/** + * Compute the base-10 logarithm of `x`. + * + * Domain: `0 < x <= INF` + * + * Range: `-INF <= y <= INF` + * + * It is an error for `x` to be less than or equal to 0. + * + * This function operates on single-precision floating point values, use + * SDL_log10 for double-precision floats. + * + * This function may use a different approximation across different versions, + * platforms and configurations. i.e, it can return a different value given + * the same input on different machines or operating systems, or if SDL is + * updated. + * + * \param x floating point value. Must be greater than 0. + * \returns the logarithm of `x`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_log10 + * \sa SDL_logf + * \sa SDL_powf + */ +extern SDL_DECLSPEC float SDLCALL SDL_log10f(float x); + +/** + * Split `x` into integer and fractional parts + * + * This function operates on double-precision floating point values, use + * SDL_modff for single-precision floats. + * + * \param x floating point value. + * \param y output pointer to store the integer part of `x`. + * \returns the fractional part of `x`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_modff + * \sa SDL_trunc + * \sa SDL_fmod + */ +extern SDL_DECLSPEC double SDLCALL SDL_modf(double x, double *y); + +/** + * Split `x` into integer and fractional parts + * + * This function operates on single-precision floating point values, use + * SDL_modf for double-precision floats. + * + * \param x floating point value. + * \param y output pointer to store the integer part of `x`. + * \returns the fractional part of `x`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_modf + * \sa SDL_truncf + * \sa SDL_fmodf + */ +extern SDL_DECLSPEC float SDLCALL SDL_modff(float x, float *y); + +/** + * Raise `x` to the power `y` + * + * Domain: `-INF <= x <= INF`, `-INF <= y <= INF` + * + * Range: `-INF <= z <= INF` + * + * If `y` is the base of the natural logarithm (e), consider using SDL_exp + * instead. + * + * This function operates on double-precision floating point values, use + * SDL_powf for single-precision floats. + * + * This function may use a different approximation across different versions, + * platforms and configurations. i.e, it can return a different value given + * the same input on different machines or operating systems, or if SDL is + * updated. + * + * \param x the base. + * \param y the exponent. + * \returns `x` raised to the power `y`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_powf + * \sa SDL_exp + * \sa SDL_log + */ +extern SDL_DECLSPEC double SDLCALL SDL_pow(double x, double y); + +/** + * Raise `x` to the power `y` + * + * Domain: `-INF <= x <= INF`, `-INF <= y <= INF` + * + * Range: `-INF <= z <= INF` + * + * If `y` is the base of the natural logarithm (e), consider using SDL_exp + * instead. + * + * This function operates on single-precision floating point values, use + * SDL_pow for double-precision floats. + * + * This function may use a different approximation across different versions, + * platforms and configurations. i.e, it can return a different value given + * the same input on different machines or operating systems, or if SDL is + * updated. + * + * \param x the base. + * \param y the exponent. + * \returns `x` raised to the power `y`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_pow + * \sa SDL_expf + * \sa SDL_logf + */ +extern SDL_DECLSPEC float SDLCALL SDL_powf(float x, float y); + +/** + * Round `x` to the nearest integer. + * + * Rounds `x` to the nearest integer. Values halfway between integers will be + * rounded away from zero. + * + * Domain: `-INF <= x <= INF` + * + * Range: `-INF <= y <= INF`, y integer + * + * This function operates on double-precision floating point values, use + * SDL_roundf for single-precision floats. To get the result as an integer + * type, use SDL_lround. + * + * \param x floating point value. + * \returns the nearest integer to `x`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_roundf + * \sa SDL_lround + * \sa SDL_floor + * \sa SDL_ceil + * \sa SDL_trunc + */ +extern SDL_DECLSPEC double SDLCALL SDL_round(double x); + +/** + * Round `x` to the nearest integer. + * + * Rounds `x` to the nearest integer. Values halfway between integers will be + * rounded away from zero. + * + * Domain: `-INF <= x <= INF` + * + * Range: `-INF <= y <= INF`, y integer + * + * This function operates on single-precision floating point values, use + * SDL_round for double-precision floats. To get the result as an integer + * type, use SDL_lroundf. + * + * \param x floating point value. + * \returns the nearest integer to `x`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_round + * \sa SDL_lroundf + * \sa SDL_floorf + * \sa SDL_ceilf + * \sa SDL_truncf + */ +extern SDL_DECLSPEC float SDLCALL SDL_roundf(float x); + +/** + * Round `x` to the nearest integer representable as a long + * + * Rounds `x` to the nearest integer. Values halfway between integers will be + * rounded away from zero. + * + * Domain: `-INF <= x <= INF` + * + * Range: `MIN_LONG <= y <= MAX_LONG` + * + * This function operates on double-precision floating point values, use + * SDL_lroundf for single-precision floats. To get the result as a + * floating-point type, use SDL_round. + * + * \param x floating point value. + * \returns the nearest integer to `x`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_lroundf + * \sa SDL_round + * \sa SDL_floor + * \sa SDL_ceil + * \sa SDL_trunc + */ +extern SDL_DECLSPEC long SDLCALL SDL_lround(double x); + +/** + * Round `x` to the nearest integer representable as a long + * + * Rounds `x` to the nearest integer. Values halfway between integers will be + * rounded away from zero. + * + * Domain: `-INF <= x <= INF` + * + * Range: `MIN_LONG <= y <= MAX_LONG` + * + * This function operates on single-precision floating point values, use + * SDL_lround for double-precision floats. To get the result as a + * floating-point type, use SDL_roundf. + * + * \param x floating point value. + * \returns the nearest integer to `x`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_lround + * \sa SDL_roundf + * \sa SDL_floorf + * \sa SDL_ceilf + * \sa SDL_truncf + */ +extern SDL_DECLSPEC long SDLCALL SDL_lroundf(float x); + +/** + * Scale `x` by an integer power of two. + * + * Multiplies `x` by the `n`th power of the floating point radix (always 2). + * + * Domain: `-INF <= x <= INF`, `n` integer + * + * Range: `-INF <= y <= INF` + * + * This function operates on double-precision floating point values, use + * SDL_scalbnf for single-precision floats. + * + * \param x floating point value to be scaled. + * \param n integer exponent. + * \returns `x * 2^n`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_scalbnf + * \sa SDL_pow + */ +extern SDL_DECLSPEC double SDLCALL SDL_scalbn(double x, int n); + +/** + * Scale `x` by an integer power of two. + * + * Multiplies `x` by the `n`th power of the floating point radix (always 2). + * + * Domain: `-INF <= x <= INF`, `n` integer + * + * Range: `-INF <= y <= INF` + * + * This function operates on single-precision floating point values, use + * SDL_scalbn for double-precision floats. + * + * \param x floating point value to be scaled. + * \param n integer exponent. + * \returns `x * 2^n`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_scalbn + * \sa SDL_powf + */ +extern SDL_DECLSPEC float SDLCALL SDL_scalbnf(float x, int n); + +/** + * Compute the sine of `x`. + * + * Domain: `-INF <= x <= INF` + * + * Range: `-1 <= y <= 1` + * + * This function operates on double-precision floating point values, use + * SDL_sinf for single-precision floats. + * + * This function may use a different approximation across different versions, + * platforms and configurations. i.e, it can return a different value given + * the same input on different machines or operating systems, or if SDL is + * updated. + * + * \param x floating point value, in radians. + * \returns sine of `x`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_sinf + * \sa SDL_asin + * \sa SDL_cos + */ +extern SDL_DECLSPEC double SDLCALL SDL_sin(double x); + +/** + * Compute the sine of `x`. + * + * Domain: `-INF <= x <= INF` + * + * Range: `-1 <= y <= 1` + * + * This function operates on single-precision floating point values, use + * SDL_sin for double-precision floats. + * + * This function may use a different approximation across different versions, + * platforms and configurations. i.e, it can return a different value given + * the same input on different machines or operating systems, or if SDL is + * updated. + * + * \param x floating point value, in radians. + * \returns sine of `x`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_sin + * \sa SDL_asinf + * \sa SDL_cosf + */ +extern SDL_DECLSPEC float SDLCALL SDL_sinf(float x); + +/** + * Compute the square root of `x`. + * + * Domain: `0 <= x <= INF` + * + * Range: `0 <= y <= INF` + * + * This function operates on double-precision floating point values, use + * SDL_sqrtf for single-precision floats. + * + * This function may use a different approximation across different versions, + * platforms and configurations. i.e, it can return a different value given + * the same input on different machines or operating systems, or if SDL is + * updated. + * + * \param x floating point value. Must be greater than or equal to 0. + * \returns square root of `x`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_sqrtf + */ +extern SDL_DECLSPEC double SDLCALL SDL_sqrt(double x); + +/** + * Compute the square root of `x`. + * + * Domain: `0 <= x <= INF` + * + * Range: `0 <= y <= INF` + * + * This function operates on single-precision floating point values, use + * SDL_sqrt for double-precision floats. + * + * This function may use a different approximation across different versions, + * platforms and configurations. i.e, it can return a different value given + * the same input on different machines or operating systems, or if SDL is + * updated. + * + * \param x floating point value. Must be greater than or equal to 0. + * \returns square root of `x`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_sqrt + */ +extern SDL_DECLSPEC float SDLCALL SDL_sqrtf(float x); + +/** + * Compute the tangent of `x`. + * + * Domain: `-INF <= x <= INF` + * + * Range: `-INF <= y <= INF` + * + * This function operates on double-precision floating point values, use + * SDL_tanf for single-precision floats. + * + * This function may use a different approximation across different versions, + * platforms and configurations. i.e, it can return a different value given + * the same input on different machines or operating systems, or if SDL is + * updated. + * + * \param x floating point value, in radians. + * \returns tangent of `x`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_tanf + * \sa SDL_sin + * \sa SDL_cos + * \sa SDL_atan + * \sa SDL_atan2 + */ +extern SDL_DECLSPEC double SDLCALL SDL_tan(double x); + +/** + * Compute the tangent of `x`. + * + * Domain: `-INF <= x <= INF` + * + * Range: `-INF <= y <= INF` + * + * This function operates on single-precision floating point values, use + * SDL_tan for double-precision floats. + * + * This function may use a different approximation across different versions, + * platforms and configurations. i.e, it can return a different value given + * the same input on different machines or operating systems, or if SDL is + * updated. + * + * \param x floating point value, in radians. + * \returns tangent of `x`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_tan + * \sa SDL_sinf + * \sa SDL_cosf + * \sa SDL_atanf + * \sa SDL_atan2f + */ +extern SDL_DECLSPEC float SDLCALL SDL_tanf(float x); + +/** + * An opaque handle representing string encoding conversion state. + * + * \since This datatype is available since SDL 3.2.0. + * + * \sa SDL_iconv_open + */ +typedef struct SDL_iconv_data_t *SDL_iconv_t; + +/** + * This function allocates a context for the specified character set + * conversion. + * + * \param tocode The target character encoding, must not be NULL. + * \param fromcode The source character encoding, must not be NULL. + * \returns a handle that must be freed with SDL_iconv_close, or + * SDL_ICONV_ERROR on failure. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_iconv + * \sa SDL_iconv_close + * \sa SDL_iconv_string + */ +extern SDL_DECLSPEC SDL_iconv_t SDLCALL SDL_iconv_open(const char *tocode, + const char *fromcode); + +/** + * This function frees a context used for character set conversion. + * + * \param cd The character set conversion handle. + * \returns 0 on success, or -1 on failure. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_iconv + * \sa SDL_iconv_open + * \sa SDL_iconv_string + */ +extern SDL_DECLSPEC int SDLCALL SDL_iconv_close(SDL_iconv_t cd); + +/** + * This function converts text between encodings, reading from and writing to + * a buffer. + * + * It returns the number of successful conversions on success. On error, + * SDL_ICONV_E2BIG is returned when the output buffer is too small, or + * SDL_ICONV_EILSEQ is returned when an invalid input sequence is encountered, + * or SDL_ICONV_EINVAL is returned when an incomplete input sequence is + * encountered. + * + * On exit: + * + * - inbuf will point to the beginning of the next multibyte sequence. On + * error, this is the location of the problematic input sequence. On + * success, this is the end of the input sequence. + * - inbytesleft will be set to the number of bytes left to convert, which + * will be 0 on success. + * - outbuf will point to the location where to store the next output byte. + * - outbytesleft will be set to the number of bytes left in the output + * buffer. + * + * \param cd The character set conversion context, created in + * SDL_iconv_open(). + * \param inbuf Address of variable that points to the first character of the + * input sequence. + * \param inbytesleft The number of bytes in the input buffer. + * \param outbuf Address of variable that points to the output buffer. + * \param outbytesleft The number of bytes in the output buffer. + * \returns the number of conversions on success, or a negative error code. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_iconv_open + * \sa SDL_iconv_close + * \sa SDL_iconv_string + */ +extern SDL_DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, const char **inbuf, + size_t *inbytesleft, char **outbuf, + size_t *outbytesleft); + +#define SDL_ICONV_ERROR (size_t)-1 /**< Generic error. Check SDL_GetError()? */ +#define SDL_ICONV_E2BIG (size_t)-2 /**< Output buffer was too small. */ +#define SDL_ICONV_EILSEQ (size_t)-3 /**< Invalid input sequence was encountered. */ +#define SDL_ICONV_EINVAL (size_t)-4 /**< Incomplete input sequence was encountered. */ + + +/** + * Helper function to convert a string's encoding in one call. + * + * This function converts a buffer or string between encodings in one pass. + * + * The string does not need to be NULL-terminated; this function operates on + * the number of bytes specified in `inbytesleft` whether there is a NULL + * character anywhere in the buffer. + * + * The returned string is owned by the caller, and should be passed to + * SDL_free when no longer needed. + * + * \param tocode the character encoding of the output string. Examples are + * "UTF-8", "UCS-4", etc. + * \param fromcode the character encoding of data in `inbuf`. + * \param inbuf the string to convert to a different encoding. + * \param inbytesleft the size of the input string _in bytes_. + * \returns a new string, converted to the new encoding, or NULL on error. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_iconv_open + * \sa SDL_iconv_close + * \sa SDL_iconv + */ +extern SDL_DECLSPEC char * SDLCALL SDL_iconv_string(const char *tocode, + const char *fromcode, + const char *inbuf, + size_t inbytesleft); + +/* Some helper macros for common SDL_iconv_string cases... */ + +/** + * Convert a UTF-8 string to the current locale's character encoding. + * + * This is a helper macro that might be more clear than calling + * SDL_iconv_string directly. However, it double-evaluates its parameter, so + * do not use an expression with side-effects here. + * + * \param S the string to convert. + * \returns a new string, converted to the new encoding, or NULL on error. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_iconv_utf8_locale(S) SDL_iconv_string("", "UTF-8", S, SDL_strlen(S)+1) + +/** + * Convert a UTF-8 string to UCS-2. + * + * This is a helper macro that might be more clear than calling + * SDL_iconv_string directly. However, it double-evaluates its parameter, so + * do not use an expression with side-effects here. + * + * \param S the string to convert. + * \returns a new string, converted to the new encoding, or NULL on error. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_iconv_utf8_ucs2(S) SDL_reinterpret_cast(Uint16 *, SDL_iconv_string("UCS-2", "UTF-8", S, SDL_strlen(S)+1)) + +/** + * Convert a UTF-8 string to UCS-4. + * + * This is a helper macro that might be more clear than calling + * SDL_iconv_string directly. However, it double-evaluates its parameter, so + * do not use an expression with side-effects here. + * + * \param S the string to convert. + * \returns a new string, converted to the new encoding, or NULL on error. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_iconv_utf8_ucs4(S) SDL_reinterpret_cast(Uint32 *, SDL_iconv_string("UCS-4", "UTF-8", S, SDL_strlen(S)+1)) + +/** + * Convert a wchar_t string to UTF-8. + * + * This is a helper macro that might be more clear than calling + * SDL_iconv_string directly. However, it double-evaluates its parameter, so + * do not use an expression with side-effects here. + * + * \param S the string to convert. + * \returns a new string, converted to the new encoding, or NULL on error. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_iconv_wchar_utf8(S) SDL_iconv_string("UTF-8", "WCHAR_T", SDL_reinterpret_cast(const char *, S), (SDL_wcslen(S)+1)*sizeof(wchar_t)) + + +/* force builds using Clang's static analysis tools to use literal C runtime + here, since there are possibly tests that are ineffective otherwise. */ +#if defined(__clang_analyzer__) && !defined(SDL_DISABLE_ANALYZE_MACROS) + +/* The analyzer knows about strlcpy even when the system doesn't provide it */ +#if !defined(HAVE_STRLCPY) && !defined(strlcpy) +size_t strlcpy(char *dst, const char *src, size_t size); +#endif + +/* The analyzer knows about strlcat even when the system doesn't provide it */ +#if !defined(HAVE_STRLCAT) && !defined(strlcat) +size_t strlcat(char *dst, const char *src, size_t size); +#endif + +#if !defined(HAVE_WCSLCPY) && !defined(wcslcpy) +size_t wcslcpy(wchar_t *dst, const wchar_t *src, size_t size); +#endif + +#if !defined(HAVE_WCSLCAT) && !defined(wcslcat) +size_t wcslcat(wchar_t *dst, const wchar_t *src, size_t size); +#endif + +#if !defined(HAVE_STRTOK_R) && !defined(strtok_r) +char *strtok_r(char *str, const char *delim, char **saveptr); +#endif + +#ifndef _WIN32 +/* strdup is not ANSI but POSIX, and its prototype might be hidden... */ +/* not for windows: might conflict with string.h where strdup may have + * dllimport attribute: https://github.com/libsdl-org/SDL/issues/12948 */ +char *strdup(const char *str); +#endif + +/* Starting LLVM 16, the analyser errors out if these functions do not have + their prototype defined (clang-diagnostic-implicit-function-declaration) */ +#include +#include + +#define SDL_malloc malloc +#define SDL_calloc calloc +#define SDL_realloc realloc +#define SDL_free free +#ifndef SDL_memcpy +#define SDL_memcpy memcpy +#endif +#ifndef SDL_memmove +#define SDL_memmove memmove +#endif +#ifndef SDL_memset +#define SDL_memset memset +#endif +#define SDL_memcmp memcmp +#define SDL_strlcpy strlcpy +#define SDL_strlcat strlcat +#define SDL_strlen strlen +#define SDL_wcslen wcslen +#define SDL_wcslcpy wcslcpy +#define SDL_wcslcat wcslcat +#define SDL_strdup strdup +#define SDL_wcsdup wcsdup +#define SDL_strchr strchr +#define SDL_strrchr strrchr +#define SDL_strstr strstr +#define SDL_wcsstr wcsstr +#define SDL_strtok_r strtok_r +#define SDL_strcmp strcmp +#define SDL_wcscmp wcscmp +#define SDL_strncmp strncmp +#define SDL_wcsncmp wcsncmp +#define SDL_strcasecmp strcasecmp +#define SDL_strncasecmp strncasecmp +#define SDL_strpbrk strpbrk +#define SDL_sscanf sscanf +#define SDL_vsscanf vsscanf +#define SDL_snprintf snprintf +#define SDL_vsnprintf vsnprintf +#endif + +/** + * Multiply two integers, checking for overflow. + * + * If `a * b` would overflow, return false. + * + * Otherwise store `a * b` via ret and return true. + * + * \param a the multiplicand. + * \param b the multiplier. + * \param ret on non-overflow output, stores the multiplication result, may + * not be NULL. + * \returns false on overflow, true if result is multiplied without overflow. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +SDL_FORCE_INLINE bool SDL_size_mul_check_overflow(size_t a, size_t b, size_t *ret) +{ + if (a != 0 && b > SDL_SIZE_MAX / a) { + return false; + } + *ret = a * b; + return true; +} + +#ifndef SDL_WIKI_DOCUMENTATION_SECTION +#if SDL_HAS_BUILTIN(__builtin_mul_overflow) +/* This needs to be wrapped in an inline rather than being a direct #define, + * because __builtin_mul_overflow() is type-generic, but we want to be + * consistent about interpreting a and b as size_t. */ +SDL_FORCE_INLINE bool SDL_size_mul_check_overflow_builtin(size_t a, size_t b, size_t *ret) +{ + return (__builtin_mul_overflow(a, b, ret) == 0); +} +#define SDL_size_mul_check_overflow(a, b, ret) SDL_size_mul_check_overflow_builtin(a, b, ret) +#endif +#endif + +/** + * Add two integers, checking for overflow. + * + * If `a + b` would overflow, return false. + * + * Otherwise store `a + b` via ret and return true. + * + * \param a the first addend. + * \param b the second addend. + * \param ret on non-overflow output, stores the addition result, may not be + * NULL. + * \returns false on overflow, true if result is added without overflow. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +SDL_FORCE_INLINE bool SDL_size_add_check_overflow(size_t a, size_t b, size_t *ret) +{ + if (b > SDL_SIZE_MAX - a) { + return false; + } + *ret = a + b; + return true; +} + +#ifndef SDL_WIKI_DOCUMENTATION_SECTION +#if SDL_HAS_BUILTIN(__builtin_add_overflow) +/* This needs to be wrapped in an inline rather than being a direct #define, + * the same as the call to __builtin_mul_overflow() above. */ +SDL_FORCE_INLINE bool SDL_size_add_check_overflow_builtin(size_t a, size_t b, size_t *ret) +{ + return (__builtin_add_overflow(a, b, ret) == 0); +} +#define SDL_size_add_check_overflow(a, b, ret) SDL_size_add_check_overflow_builtin(a, b, ret) +#endif +#endif + +/* This is a generic function pointer which should be cast to the type you expect */ +#ifdef SDL_WIKI_DOCUMENTATION_SECTION + +/** + * A generic function pointer. + * + * In theory, generic function pointers should use this, instead of `void *`, + * since some platforms could treat code addresses differently than data + * addresses. Although in current times no popular platforms make this + * distinction, it is more correct and portable to use the correct type for a + * generic pointer. + * + * If for some reason you need to force this typedef to be an actual `void *`, + * perhaps to work around a compiler or existing code, you can define + * `SDL_FUNCTION_POINTER_IS_VOID_POINTER` before including any SDL headers. + * + * \since This datatype is available since SDL 3.2.0. + */ +typedef void (*SDL_FunctionPointer)(void); +#elif defined(SDL_FUNCTION_POINTER_IS_VOID_POINTER) +typedef void *SDL_FunctionPointer; +#else +typedef void (*SDL_FunctionPointer)(void); +#endif + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_stdinc_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_storage.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_storage.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,686 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * # CategoryStorage + * + * The storage API is a high-level API designed to abstract away the + * portability issues that come up when using something lower-level (in SDL's + * case, this sits on top of the [Filesystem](CategoryFilesystem) and + * [IOStream](CategoryIOStream) subsystems). It is significantly more + * restrictive than a typical filesystem API, for a number of reasons: + * + * 1. **What to Access:** A common pitfall with existing filesystem APIs is + * the assumption that all storage is monolithic. However, many other + * platforms (game consoles in particular) are more strict about what _type_ + * of filesystem is being accessed; for example, game content and user data + * are usually two separate storage devices with entirely different + * characteristics (and possibly different low-level APIs altogether!). + * + * 2. **How to Access:** Another common mistake is applications assuming that + * all storage is universally writeable - again, many platforms treat game + * content and user data as two separate storage devices, and only user data + * is writeable while game content is read-only. + * + * 3. **When to Access:** The most common portability issue with filesystem + * access is _timing_ - you cannot always assume that the storage device is + * always accessible all of the time, nor can you assume that there are no + * limits to how long you have access to a particular device. + * + * Consider the following example: + * + * ```c + * void ReadGameData(void) + * { + * extern char** fileNames; + * extern size_t numFiles; + * for (size_t i = 0; i < numFiles; i += 1) { + * FILE *data = fopen(fileNames[i], "rwb"); + * if (data == NULL) { + * // Something bad happened! + * } else { + * // A bunch of stuff happens here + * fclose(data); + * } + * } + * } + * + * void ReadSave(void) + * { + * FILE *save = fopen("saves/save0.sav", "rb"); + * if (save == NULL) { + * // Something bad happened! + * } else { + * // A bunch of stuff happens here + * fclose(save); + * } + * } + * + * void WriteSave(void) + * { + * FILE *save = fopen("saves/save0.sav", "wb"); + * if (save == NULL) { + * // Something bad happened! + * } else { + * // A bunch of stuff happens here + * fclose(save); + * } + * } + * ``` + * + * Going over the bullet points again: + * + * 1. **What to Access:** This code accesses a global filesystem; game data + * and saves are all presumed to be in the current working directory (which + * may or may not be the game's installation folder!). + * + * 2. **How to Access:** This code assumes that content paths are writeable, + * and that save data is also writeable despite being in the same location as + * the game data. + * + * 3. **When to Access:** This code assumes that they can be called at any + * time, since the filesystem is always accessible and has no limits on how + * long the filesystem is being accessed. + * + * Due to these assumptions, the filesystem code is not portable and will fail + * under these common scenarios: + * + * - The game is installed on a device that is read-only, both content loading + * and game saves will fail or crash outright + * - Game/User storage is not implicitly mounted, so no files will be found + * for either scenario when a platform requires explicitly mounting + * filesystems + * - Save data may not be safe since the I/O is not being flushed or + * validated, so an error occurring elsewhere in the program may result in + * missing/corrupted save data + * + * When using SDL_Storage, these types of problems are virtually impossible to + * trip over: + * + * ```c + * void ReadGameData(void) + * { + * extern char** fileNames; + * extern size_t numFiles; + * + * SDL_Storage *title = SDL_OpenTitleStorage(NULL, 0); + * if (title == NULL) { + * // Something bad happened! + * } + * while (!SDL_StorageReady(title)) { + * SDL_Delay(1); + * } + * + * for (size_t i = 0; i < numFiles; i += 1) { + * void* dst; + * Uint64 dstLen = 0; + * + * if (SDL_GetStorageFileSize(title, fileNames[i], &dstLen) && dstLen > 0) { + * dst = SDL_malloc(dstLen); + * if (SDL_ReadStorageFile(title, fileNames[i], dst, dstLen)) { + * // A bunch of stuff happens here + * } else { + * // Something bad happened! + * } + * SDL_free(dst); + * } else { + * // Something bad happened! + * } + * } + * + * SDL_CloseStorage(title); + * } + * + * void ReadSave(void) + * { + * SDL_Storage *user = SDL_OpenUserStorage("libsdl", "Storage Example", 0); + * if (user == NULL) { + * // Something bad happened! + * } + * while (!SDL_StorageReady(user)) { + * SDL_Delay(1); + * } + * + * Uint64 saveLen = 0; + * if (SDL_GetStorageFileSize(user, "save0.sav", &saveLen) && saveLen > 0) { + * void* dst = SDL_malloc(saveLen); + * if (SDL_ReadStorageFile(user, "save0.sav", dst, saveLen)) { + * // A bunch of stuff happens here + * } else { + * // Something bad happened! + * } + * SDL_free(dst); + * } else { + * // Something bad happened! + * } + * + * SDL_CloseStorage(user); + * } + * + * void WriteSave(void) + * { + * SDL_Storage *user = SDL_OpenUserStorage("libsdl", "Storage Example", 0); + * if (user == NULL) { + * // Something bad happened! + * } + * while (!SDL_StorageReady(user)) { + * SDL_Delay(1); + * } + * + * extern void *saveData; // A bunch of stuff happened here... + * extern Uint64 saveLen; + * if (!SDL_WriteStorageFile(user, "save0.sav", saveData, saveLen)) { + * // Something bad happened! + * } + * + * SDL_CloseStorage(user); + * } + * ``` + * + * Note the improvements that SDL_Storage makes: + * + * 1. **What to Access:** This code explicitly reads from a title or user + * storage device based on the context of the function. + * + * 2. **How to Access:** This code explicitly uses either a read or write + * function based on the context of the function. + * + * 3. **When to Access:** This code explicitly opens the device when it needs + * to, and closes it when it is finished working with the filesystem. + * + * The result is an application that is significantly more robust against the + * increasing demands of platforms and their filesystems! + * + * A publicly available example of an SDL_Storage backend is the + * [Steam Cloud](https://partner.steamgames.com/doc/features/cloud) + * backend - you can initialize Steamworks when starting the program, and then + * SDL will recognize that Steamworks is initialized and automatically use + * ISteamRemoteStorage when the application opens user storage. More + * importantly, when you _open_ storage it knows to begin a "batch" of + * filesystem operations, and when you _close_ storage it knows to end and + * flush the batch. This is used by Steam to support + * [Dynamic Cloud Sync](https://steamcommunity.com/groups/steamworks/announcements/detail/3142949576401813670) + * ; users can save data on one PC, put the device to sleep, and then continue + * playing on another PC (and vice versa) with the save data fully + * synchronized across all devices, allowing for a seamless experience without + * having to do full restarts of the program. + * + * ## Notes on valid paths + * + * All paths in the Storage API use Unix-style path separators ('/'). Using a + * different path separator will not work, even if the underlying platform + * would otherwise accept it. This is to keep code using the Storage API + * portable between platforms and Storage implementations and simplify app + * code. + * + * Paths with relative directories ("." and "..") are forbidden by the Storage + * API. + * + * All valid UTF-8 strings (discounting the NULL terminator character and the + * '/' path separator) are usable for filenames, however, an underlying + * Storage implementation may not support particularly strange sequences and + * refuse to create files with those names, etc. + */ + +#ifndef SDL_storage_h_ +#define SDL_storage_h_ + +#include +#include +#include +#include + +#include + +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Function interface for SDL_Storage. + * + * Apps that want to supply a custom implementation of SDL_Storage will fill + * in all the functions in this struct, and then pass it to SDL_OpenStorage to + * create a custom SDL_Storage object. + * + * It is not usually necessary to do this; SDL provides standard + * implementations for many things you might expect to do with an SDL_Storage. + * + * This structure should be initialized using SDL_INIT_INTERFACE() + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_INIT_INTERFACE + */ +typedef struct SDL_StorageInterface +{ + /* The version of this interface */ + Uint32 version; + + /* Called when the storage is closed */ + bool (SDLCALL *close)(void *userdata); + + /* Optional, returns whether the storage is currently ready for access */ + bool (SDLCALL *ready)(void *userdata); + + /* Enumerate a directory, optional for write-only storage */ + bool (SDLCALL *enumerate)(void *userdata, const char *path, SDL_EnumerateDirectoryCallback callback, void *callback_userdata); + + /* Get path information, optional for write-only storage */ + bool (SDLCALL *info)(void *userdata, const char *path, SDL_PathInfo *info); + + /* Read a file from storage, optional for write-only storage */ + bool (SDLCALL *read_file)(void *userdata, const char *path, void *destination, Uint64 length); + + /* Write a file to storage, optional for read-only storage */ + bool (SDLCALL *write_file)(void *userdata, const char *path, const void *source, Uint64 length); + + /* Create a directory, optional for read-only storage */ + bool (SDLCALL *mkdir)(void *userdata, const char *path); + + /* Remove a file or empty directory, optional for read-only storage */ + bool (SDLCALL *remove)(void *userdata, const char *path); + + /* Rename a path, optional for read-only storage */ + bool (SDLCALL *rename)(void *userdata, const char *oldpath, const char *newpath); + + /* Copy a file, optional for read-only storage */ + bool (SDLCALL *copy)(void *userdata, const char *oldpath, const char *newpath); + + /* Get the space remaining, optional for read-only storage */ + Uint64 (SDLCALL *space_remaining)(void *userdata); +} SDL_StorageInterface; + +/* Check the size of SDL_StorageInterface + * + * If this assert fails, either the compiler is padding to an unexpected size, + * or the interface has been updated and this should be updated to match and + * the code using this interface should be updated to handle the old version. + */ +SDL_COMPILE_TIME_ASSERT(SDL_StorageInterface_SIZE, + (sizeof(void *) == 4 && sizeof(SDL_StorageInterface) == 48) || + (sizeof(void *) == 8 && sizeof(SDL_StorageInterface) == 96)); + +/** + * An abstract interface for filesystem access. + * + * This is an opaque datatype. One can create this object using standard SDL + * functions like SDL_OpenTitleStorage or SDL_OpenUserStorage, etc, or create + * an object with a custom implementation using SDL_OpenStorage. + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_Storage SDL_Storage; + +/** + * Opens up a read-only container for the application's filesystem. + * + * By default, SDL_OpenTitleStorage uses the generic storage implementation. + * When the path override is not provided, the generic implementation will use + * the output of SDL_GetBasePath as the base path. + * + * \param override a path to override the backend's default title root. + * \param props a property list that may contain backend-specific information. + * \returns a title storage container on success or NULL on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CloseStorage + * \sa SDL_GetStorageFileSize + * \sa SDL_OpenUserStorage + * \sa SDL_ReadStorageFile + */ +extern SDL_DECLSPEC SDL_Storage * SDLCALL SDL_OpenTitleStorage(const char *override, SDL_PropertiesID props); + +/** + * Opens up a container for a user's unique read/write filesystem. + * + * While title storage can generally be kept open throughout runtime, user + * storage should only be opened when the client is ready to read/write files. + * This allows the backend to properly batch file operations and flush them + * when the container has been closed; ensuring safe and optimal save I/O. + * + * \param org the name of your organization. + * \param app the name of your application. + * \param props a property list that may contain backend-specific information. + * \returns a user storage container on success or NULL on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CloseStorage + * \sa SDL_GetStorageFileSize + * \sa SDL_GetStorageSpaceRemaining + * \sa SDL_OpenTitleStorage + * \sa SDL_ReadStorageFile + * \sa SDL_StorageReady + * \sa SDL_WriteStorageFile + */ +extern SDL_DECLSPEC SDL_Storage * SDLCALL SDL_OpenUserStorage(const char *org, const char *app, SDL_PropertiesID props); + +/** + * Opens up a container for local filesystem storage. + * + * This is provided for development and tools. Portable applications should + * use SDL_OpenTitleStorage() for access to game data and + * SDL_OpenUserStorage() for access to user data. + * + * \param path the base path prepended to all storage paths, or NULL for no + * base path. + * \returns a filesystem storage container on success or NULL on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CloseStorage + * \sa SDL_GetStorageFileSize + * \sa SDL_GetStorageSpaceRemaining + * \sa SDL_OpenTitleStorage + * \sa SDL_OpenUserStorage + * \sa SDL_ReadStorageFile + * \sa SDL_WriteStorageFile + */ +extern SDL_DECLSPEC SDL_Storage * SDLCALL SDL_OpenFileStorage(const char *path); + +/** + * Opens up a container using a client-provided storage interface. + * + * Applications do not need to use this function unless they are providing + * their own SDL_Storage implementation. If you just need an SDL_Storage, you + * should use the built-in implementations in SDL, like SDL_OpenTitleStorage() + * or SDL_OpenUserStorage(). + * + * This function makes a copy of `iface` and the caller does not need to keep + * it around after this call. + * + * \param iface the interface that implements this storage, initialized using + * SDL_INIT_INTERFACE(). + * \param userdata the pointer that will be passed to the interface functions. + * \returns a storage container on success or NULL on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CloseStorage + * \sa SDL_GetStorageFileSize + * \sa SDL_GetStorageSpaceRemaining + * \sa SDL_INIT_INTERFACE + * \sa SDL_ReadStorageFile + * \sa SDL_StorageReady + * \sa SDL_WriteStorageFile + */ +extern SDL_DECLSPEC SDL_Storage * SDLCALL SDL_OpenStorage(const SDL_StorageInterface *iface, void *userdata); + +/** + * Closes and frees a storage container. + * + * \param storage a storage container to close. + * \returns true if the container was freed with no errors, false otherwise; + * call SDL_GetError() for more information. Even if the function + * returns an error, the container data will be freed; the error is + * only for informational purposes. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_OpenFileStorage + * \sa SDL_OpenStorage + * \sa SDL_OpenTitleStorage + * \sa SDL_OpenUserStorage + */ +extern SDL_DECLSPEC bool SDLCALL SDL_CloseStorage(SDL_Storage *storage); + +/** + * Checks if the storage container is ready to use. + * + * This function should be called in regular intervals until it returns true - + * however, it is not recommended to spinwait on this call, as the backend may + * depend on a synchronous message loop. You might instead poll this in your + * game's main loop while processing events and drawing a loading screen. + * + * \param storage a storage container to query. + * \returns true if the container is ready, false otherwise. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_StorageReady(SDL_Storage *storage); + +/** + * Query the size of a file within a storage container. + * + * \param storage a storage container to query. + * \param path the relative path of the file to query. + * \param length a pointer to be filled with the file's length. + * \returns true if the file could be queried or false on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_ReadStorageFile + * \sa SDL_StorageReady + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetStorageFileSize(SDL_Storage *storage, const char *path, Uint64 *length); + +/** + * Synchronously read a file from a storage container into a client-provided + * buffer. + * + * The value of `length` must match the length of the file exactly; call + * SDL_GetStorageFileSize() to get this value. This behavior may be relaxed in + * a future release. + * + * \param storage a storage container to read from. + * \param path the relative path of the file to read. + * \param destination a client-provided buffer to read the file into. + * \param length the length of the destination buffer. + * \returns true if the file was read or false on failure; call SDL_GetError() + * for more information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetStorageFileSize + * \sa SDL_StorageReady + * \sa SDL_WriteStorageFile + */ +extern SDL_DECLSPEC bool SDLCALL SDL_ReadStorageFile(SDL_Storage *storage, const char *path, void *destination, Uint64 length); + +/** + * Synchronously write a file from client memory into a storage container. + * + * \param storage a storage container to write to. + * \param path the relative path of the file to write. + * \param source a client-provided buffer to write from. + * \param length the length of the source buffer. + * \returns true if the file was written or false on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetStorageSpaceRemaining + * \sa SDL_ReadStorageFile + * \sa SDL_StorageReady + */ +extern SDL_DECLSPEC bool SDLCALL SDL_WriteStorageFile(SDL_Storage *storage, const char *path, const void *source, Uint64 length); + +/** + * Create a directory in a writable storage container. + * + * \param storage a storage container. + * \param path the path of the directory to create. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_StorageReady + */ +extern SDL_DECLSPEC bool SDLCALL SDL_CreateStorageDirectory(SDL_Storage *storage, const char *path); + +/** + * Enumerate a directory in a storage container through a callback function. + * + * This function provides every directory entry through an app-provided + * callback, called once for each directory entry, until all results have been + * provided or the callback returns either SDL_ENUM_SUCCESS or + * SDL_ENUM_FAILURE. + * + * This will return false if there was a system problem in general, or if a + * callback returns SDL_ENUM_FAILURE. A successful return means a callback + * returned SDL_ENUM_SUCCESS to halt enumeration, or all directory entries + * were enumerated. + * + * If `path` is NULL, this is treated as a request to enumerate the root of + * the storage container's tree. An empty string also works for this. + * + * \param storage a storage container. + * \param path the path of the directory to enumerate, or NULL for the root. + * \param callback a function that is called for each entry in the directory. + * \param userdata a pointer that is passed to `callback`. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_StorageReady + */ +extern SDL_DECLSPEC bool SDLCALL SDL_EnumerateStorageDirectory(SDL_Storage *storage, const char *path, SDL_EnumerateDirectoryCallback callback, void *userdata); + +/** + * Remove a file or an empty directory in a writable storage container. + * + * \param storage a storage container. + * \param path the path of the directory to enumerate. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_StorageReady + */ +extern SDL_DECLSPEC bool SDLCALL SDL_RemoveStoragePath(SDL_Storage *storage, const char *path); + +/** + * Rename a file or directory in a writable storage container. + * + * \param storage a storage container. + * \param oldpath the old path. + * \param newpath the new path. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_StorageReady + */ +extern SDL_DECLSPEC bool SDLCALL SDL_RenameStoragePath(SDL_Storage *storage, const char *oldpath, const char *newpath); + +/** + * Copy a file in a writable storage container. + * + * \param storage a storage container. + * \param oldpath the old path. + * \param newpath the new path. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_StorageReady + */ +extern SDL_DECLSPEC bool SDLCALL SDL_CopyStorageFile(SDL_Storage *storage, const char *oldpath, const char *newpath); + +/** + * Get information about a filesystem path in a storage container. + * + * \param storage a storage container. + * \param path the path to query. + * \param info a pointer filled in with information about the path, or NULL to + * check for the existence of a file. + * \returns true on success or false if the file doesn't exist, or another + * failure; call SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_StorageReady + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetStoragePathInfo(SDL_Storage *storage, const char *path, SDL_PathInfo *info); + +/** + * Queries the remaining space in a storage container. + * + * \param storage a storage container to query. + * \returns the amount of remaining space, in bytes. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_StorageReady + * \sa SDL_WriteStorageFile + */ +extern SDL_DECLSPEC Uint64 SDLCALL SDL_GetStorageSpaceRemaining(SDL_Storage *storage); + +/** + * Enumerate a directory tree, filtered by pattern, and return a list. + * + * Files are filtered out if they don't match the string in `pattern`, which + * may contain wildcard characters `*` (match everything) and `?` (match one + * character). If pattern is NULL, no filtering is done and all results are + * returned. Subdirectories are permitted, and are specified with a path + * separator of '/'. Wildcard characters `*` and `?` never match a path + * separator. + * + * `flags` may be set to SDL_GLOB_CASEINSENSITIVE to make the pattern matching + * case-insensitive. + * + * The returned array is always NULL-terminated, for your iterating + * convenience, but if `count` is non-NULL, on return it will contain the + * number of items in the array, not counting the NULL terminator. + * + * If `path` is NULL, this is treated as a request to enumerate the root of + * the storage container's tree. An empty string also works for this. + * + * \param storage a storage container. + * \param path the path of the directory to enumerate, or NULL for the root. + * \param pattern the pattern that files in the directory must match. Can be + * NULL. + * \param flags `SDL_GLOB_*` bitflags that affect this search. + * \param count on return, will be set to the number of items in the returned + * array. Can be NULL. + * \returns an array of strings on success or NULL on failure; call + * SDL_GetError() for more information. The caller should pass the + * returned pointer to SDL_free when done with it. This is a single + * allocation that should be freed with SDL_free() when it is no + * longer needed. + * + * \threadsafety It is safe to call this function from any thread, assuming + * the `storage` object is thread-safe. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC char ** SDLCALL SDL_GlobStorageDirectory(SDL_Storage *storage, const char *path, const char *pattern, SDL_GlobFlags flags, int *count); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_storage_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_surface.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_surface.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,1769 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * # CategorySurface + * + * SDL surfaces are buffers of pixels in system RAM. These are useful for + * passing around and manipulating images that are not stored in GPU memory. + * + * SDL_Surface makes serious efforts to manage images in various formats, and + * provides a reasonable toolbox for transforming the data, including copying + * between surfaces, filling rectangles in the image data, etc. + * + * There is also a simple .bmp loader, SDL_LoadBMP(), and a simple .png + * loader, SDL_LoadPNG(). SDL itself does not provide loaders for other file + * formats, but there are several excellent external libraries that do, + * including its own satellite library, + * [SDL_image](https://wiki.libsdl.org/SDL3_image) + * . + * + * In general these functions are thread-safe in that they can be called on + * different threads with different surfaces. You should not try to modify any + * surface from two threads simultaneously. + */ + +#ifndef SDL_surface_h_ +#define SDL_surface_h_ + +#include +#include +#include +#include +#include +#include +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * The flags on an SDL_Surface. + * + * These are generally considered read-only. + * + * \since This datatype is available since SDL 3.2.0. + */ +typedef Uint32 SDL_SurfaceFlags; + +#define SDL_SURFACE_PREALLOCATED 0x00000001u /**< Surface uses preallocated pixel memory */ +#define SDL_SURFACE_LOCK_NEEDED 0x00000002u /**< Surface needs to be locked to access pixels */ +#define SDL_SURFACE_LOCKED 0x00000004u /**< Surface is currently locked */ +#define SDL_SURFACE_SIMD_ALIGNED 0x00000008u /**< Surface uses pixel memory allocated with SDL_aligned_alloc() */ + +/** + * Evaluates to true if the surface needs to be locked before access. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_MUSTLOCK(S) (((S)->flags & SDL_SURFACE_LOCK_NEEDED) == SDL_SURFACE_LOCK_NEEDED) + +/** + * The scaling mode. + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_ScaleMode +{ + SDL_SCALEMODE_INVALID = -1, + SDL_SCALEMODE_NEAREST, /**< nearest pixel sampling */ + SDL_SCALEMODE_LINEAR, /**< linear filtering */ + SDL_SCALEMODE_PIXELART /**< nearest pixel sampling with improved scaling for pixel art, available since SDL 3.4.0 */ +} SDL_ScaleMode; + +/** + * The flip mode. + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_FlipMode +{ + SDL_FLIP_NONE, /**< Do not flip */ + SDL_FLIP_HORIZONTAL, /**< flip horizontally */ + SDL_FLIP_VERTICAL, /**< flip vertically */ + SDL_FLIP_HORIZONTAL_AND_VERTICAL = (SDL_FLIP_HORIZONTAL | SDL_FLIP_VERTICAL) /**< flip horizontally and vertically (not a diagonal flip) */ +} SDL_FlipMode; + +#ifndef SDL_INTERNAL + +/** + * A collection of pixels used in software blitting. + * + * Pixels are arranged in memory in rows, with the top row first. Each row + * occupies an amount of memory given by the pitch (sometimes known as the row + * stride in non-SDL APIs). + * + * Within each row, pixels are arranged from left to right until the width is + * reached. Each pixel occupies a number of bits appropriate for its format, + * with most formats representing each pixel as one or more whole bytes (in + * some indexed formats, instead multiple pixels are packed into each byte), + * and a byte order given by the format. After encoding all pixels, any + * remaining bytes to reach the pitch are used as padding to reach a desired + * alignment, and have undefined contents. + * + * When a surface holds YUV format data, the planes are assumed to be + * contiguous without padding between them, e.g. a 32x32 surface in NV12 + * format with a pitch of 32 would consist of 32x32 bytes of Y plane followed + * by 32x16 bytes of UV plane. + * + * When a surface holds MJPG format data, pixels points at the compressed JPEG + * image and pitch is the length of that data. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_CreateSurface + * \sa SDL_DestroySurface + */ +struct SDL_Surface +{ + SDL_SurfaceFlags flags; /**< The flags of the surface, read-only */ + SDL_PixelFormat format; /**< The format of the surface, read-only */ + int w; /**< The width of the surface, read-only. */ + int h; /**< The height of the surface, read-only. */ + int pitch; /**< The distance in bytes between rows of pixels, read-only */ + void *pixels; /**< A pointer to the pixels of the surface, the pixels are writeable if non-NULL */ + + int refcount; /**< Application reference count, used when freeing surface */ + + void *reserved; /**< Reserved for internal use */ +}; +#endif /* !SDL_INTERNAL */ + +typedef struct SDL_Surface SDL_Surface; + +/** + * Allocate a new surface with a specific pixel format. + * + * The pixels of the new surface are initialized to zero. + * + * \param width the width of the surface. + * \param height the height of the surface. + * \param format the SDL_PixelFormat for the new surface's pixel format. + * \returns the new SDL_Surface structure that is created or NULL on failure; + * call SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateSurfaceFrom + * \sa SDL_DestroySurface + */ +extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_CreateSurface(int width, int height, SDL_PixelFormat format); + +/** + * Allocate a new surface with a specific pixel format and existing pixel + * data. + * + * No copy is made of the pixel data. Pixel data is not managed automatically; + * you must free the surface before you free the pixel data. + * + * Pitch is the offset in bytes from one row of pixels to the next, e.g. + * `width*4` for `SDL_PIXELFORMAT_RGBA8888`. + * + * You may pass NULL for pixels and 0 for pitch to create a surface that you + * will fill in with valid values later. + * + * \param width the width of the surface. + * \param height the height of the surface. + * \param format the SDL_PixelFormat for the new surface's pixel format. + * \param pixels a pointer to existing pixel data. + * \param pitch the number of bytes between each row, including padding. + * \returns the new SDL_Surface structure that is created or NULL on failure; + * call SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateSurface + * \sa SDL_DestroySurface + */ +extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_CreateSurfaceFrom(int width, int height, SDL_PixelFormat format, void *pixels, int pitch); + +/** + * Free a surface. + * + * It is safe to pass NULL to this function. + * + * \param surface the SDL_Surface to free. + * + * \threadsafety No other thread should be using the surface when it is freed. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateSurface + * \sa SDL_CreateSurfaceFrom + */ +extern SDL_DECLSPEC void SDLCALL SDL_DestroySurface(SDL_Surface *surface); + +/** + * Get the properties associated with a surface. + * + * The following properties are understood by SDL: + * + * - `SDL_PROP_SURFACE_SDR_WHITE_POINT_FLOAT`: for HDR10 and floating point + * surfaces, this defines the value of 100% diffuse white, with higher + * values being displayed in the High Dynamic Range headroom. This defaults + * to 203 for HDR10 surfaces and 1.0 for floating point surfaces. + * - `SDL_PROP_SURFACE_HDR_HEADROOM_FLOAT`: for HDR10 and floating point + * surfaces, this defines the maximum dynamic range used by the content, in + * terms of the SDR white point. This defaults to 0.0, which disables tone + * mapping. + * - `SDL_PROP_SURFACE_TONEMAP_OPERATOR_STRING`: the tone mapping operator + * used when compressing from a surface with high dynamic range to another + * with lower dynamic range. Currently this supports "chrome", which uses + * the same tone mapping that Chrome uses for HDR content, the form "*=N", + * where N is a floating point scale factor applied in linear space, and + * "none", which disables tone mapping. This defaults to "chrome". + * - `SDL_PROP_SURFACE_HOTSPOT_X_NUMBER`: the hotspot pixel offset from the + * left edge of the image, if this surface is being used as a cursor. + * - `SDL_PROP_SURFACE_HOTSPOT_Y_NUMBER`: the hotspot pixel offset from the + * top edge of the image, if this surface is being used as a cursor. + * - `SDL_PROP_SURFACE_ROTATION_FLOAT`: the number of degrees a surface's data + * is meant to be rotated clockwise to make the image right-side up. Default + * 0. This is used by the camera API, if a mobile device is oriented + * differently than what its camera provides (i.e. - the camera always + * provides portrait images but the phone is being held in landscape + * orientation). Since SDL 3.4.0. + * + * \param surface the SDL_Surface structure to query. + * \returns a valid property ID on success or 0 on failure; call + * SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetSurfaceProperties(SDL_Surface *surface); + +#define SDL_PROP_SURFACE_SDR_WHITE_POINT_FLOAT "SDL.surface.SDR_white_point" +#define SDL_PROP_SURFACE_HDR_HEADROOM_FLOAT "SDL.surface.HDR_headroom" +#define SDL_PROP_SURFACE_TONEMAP_OPERATOR_STRING "SDL.surface.tonemap" +#define SDL_PROP_SURFACE_HOTSPOT_X_NUMBER "SDL.surface.hotspot.x" +#define SDL_PROP_SURFACE_HOTSPOT_Y_NUMBER "SDL.surface.hotspot.y" +#define SDL_PROP_SURFACE_ROTATION_FLOAT "SDL.surface.rotation" + +/** + * Set the colorspace used by a surface. + * + * Setting the colorspace doesn't change the pixels, only how they are + * interpreted in color operations. + * + * \param surface the SDL_Surface structure to update. + * \param colorspace an SDL_Colorspace value describing the surface + * colorspace. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function can be called on different threads with + * different surfaces. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetSurfaceColorspace + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetSurfaceColorspace(SDL_Surface *surface, SDL_Colorspace colorspace); + +/** + * Get the colorspace used by a surface. + * + * The colorspace defaults to SDL_COLORSPACE_SRGB_LINEAR for floating point + * formats, SDL_COLORSPACE_HDR10 for 10-bit formats, SDL_COLORSPACE_SRGB for + * other RGB surfaces and SDL_COLORSPACE_BT709_FULL for YUV textures. + * + * \param surface the SDL_Surface structure to query. + * \returns the colorspace used by the surface, or SDL_COLORSPACE_UNKNOWN if + * the surface is NULL. + * + * \threadsafety This function can be called on different threads with + * different surfaces. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetSurfaceColorspace + */ +extern SDL_DECLSPEC SDL_Colorspace SDLCALL SDL_GetSurfaceColorspace(SDL_Surface *surface); + +/** + * Create a palette and associate it with a surface. + * + * This function creates a palette compatible with the provided surface. The + * palette is then returned for you to modify, and the surface will + * automatically use the new palette in future operations. You do not need to + * destroy the returned palette, it will be freed when the reference count + * reaches 0, usually when the surface is destroyed. + * + * Bitmap surfaces (with format SDL_PIXELFORMAT_INDEX1LSB or + * SDL_PIXELFORMAT_INDEX1MSB) will have the palette initialized with 0 as + * white and 1 as black. Other surfaces will get a palette initialized with + * white in every entry. + * + * If this function is called for a surface that already has a palette, a new + * palette will be created to replace it. + * + * \param surface the SDL_Surface structure to update. + * \returns a new SDL_Palette structure on success or NULL on failure (e.g. if + * the surface didn't have an index format); call SDL_GetError() for + * more information. + * + * \threadsafety This function can be called on different threads with + * different surfaces. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetPaletteColors + */ +extern SDL_DECLSPEC SDL_Palette * SDLCALL SDL_CreateSurfacePalette(SDL_Surface *surface); + +/** + * Set the palette used by a surface. + * + * Setting the palette keeps an internal reference to the palette, which can + * be safely destroyed afterwards. + * + * A single palette can be shared with many surfaces. + * + * \param surface the SDL_Surface structure to update. + * \param palette the SDL_Palette structure to use. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function can be called on different threads with + * different surfaces. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreatePalette + * \sa SDL_GetSurfacePalette + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetSurfacePalette(SDL_Surface *surface, SDL_Palette *palette); + +/** + * Get the palette used by a surface. + * + * \param surface the SDL_Surface structure to query. + * \returns a pointer to the palette used by the surface, or NULL if there is + * no palette used. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetSurfacePalette + */ +extern SDL_DECLSPEC SDL_Palette * SDLCALL SDL_GetSurfacePalette(SDL_Surface *surface); + +/** + * Add an alternate version of a surface. + * + * This function adds an alternate version of this surface, usually used for + * content with high DPI representations like cursors or icons. The size, + * format, and content do not need to match the original surface, and these + * alternate versions will not be updated when the original surface changes. + * + * This function adds a reference to the alternate version, so you should call + * SDL_DestroySurface() on the image after this call. + * + * \param surface the SDL_Surface structure to update. + * \param image a pointer to an alternate SDL_Surface to associate with this + * surface. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function can be called on different threads with + * different surfaces. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_RemoveSurfaceAlternateImages + * \sa SDL_GetSurfaceImages + * \sa SDL_SurfaceHasAlternateImages + */ +extern SDL_DECLSPEC bool SDLCALL SDL_AddSurfaceAlternateImage(SDL_Surface *surface, SDL_Surface *image); + +/** + * Return whether a surface has alternate versions available. + * + * \param surface the SDL_Surface structure to query. + * \returns true if alternate versions are available or false otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_AddSurfaceAlternateImage + * \sa SDL_RemoveSurfaceAlternateImages + * \sa SDL_GetSurfaceImages + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SurfaceHasAlternateImages(SDL_Surface *surface); + +/** + * Get an array including all versions of a surface. + * + * This returns all versions of a surface, with the surface being queried as + * the first element in the returned array. + * + * Freeing the array of surfaces does not affect the surfaces in the array. + * They are still referenced by the surface being queried and will be cleaned + * up normally. + * + * \param surface the SDL_Surface structure to query. + * \param count a pointer filled in with the number of surface pointers + * returned, may be NULL. + * \returns a NULL terminated array of SDL_Surface pointers or NULL on + * failure; call SDL_GetError() for more information. This should be + * freed with SDL_free() when it is no longer needed. + * + * \threadsafety This function can be called on different threads with + * different surfaces. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_AddSurfaceAlternateImage + * \sa SDL_RemoveSurfaceAlternateImages + * \sa SDL_SurfaceHasAlternateImages + */ +extern SDL_DECLSPEC SDL_Surface ** SDLCALL SDL_GetSurfaceImages(SDL_Surface *surface, int *count); + +/** + * Remove all alternate versions of a surface. + * + * This function removes a reference from all the alternative versions, + * destroying them if this is the last reference to them. + * + * \param surface the SDL_Surface structure to update. + * + * \threadsafety This function can be called on different threads with + * different surfaces. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_AddSurfaceAlternateImage + * \sa SDL_GetSurfaceImages + * \sa SDL_SurfaceHasAlternateImages + */ +extern SDL_DECLSPEC void SDLCALL SDL_RemoveSurfaceAlternateImages(SDL_Surface *surface); + +/** + * Set up a surface for directly accessing the pixels. + * + * Between calls to SDL_LockSurface() / SDL_UnlockSurface(), you can write to + * and read from `surface->pixels`, using the pixel format stored in + * `surface->format`. Once you are done accessing the surface, you should use + * SDL_UnlockSurface() to release it. + * + * Not all surfaces require locking. If `SDL_MUSTLOCK(surface)` evaluates to + * 0, then you can read and write to the surface at any time, and the pixel + * format of the surface will not change. + * + * \param surface the SDL_Surface structure to be locked. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function can be called on different threads with + * different surfaces. The locking referred to by this function + * is making the pixels available for direct access, not + * thread-safe locking. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_MUSTLOCK + * \sa SDL_UnlockSurface + */ +extern SDL_DECLSPEC bool SDLCALL SDL_LockSurface(SDL_Surface *surface); + +/** + * Release a surface after directly accessing the pixels. + * + * \param surface the SDL_Surface structure to be unlocked. + * + * \threadsafety This function is not thread safe. The locking referred to by + * this function is making the pixels available for direct + * access, not thread-safe locking. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_LockSurface + */ +extern SDL_DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface *surface); + +/** + * Load a BMP or PNG image from a seekable SDL data stream. + * + * The new surface should be freed with SDL_DestroySurface(). Not doing so + * will result in a memory leak. + * + * \param src the data stream for the surface. + * \param closeio if true, calls SDL_CloseIO() on `src` before returning, even + * in the case of an error. + * \returns a pointer to a new SDL_Surface structure or NULL on failure; call + * SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.4.0. + * + * \sa SDL_DestroySurface + * \sa SDL_LoadSurface + */ +extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_LoadSurface_IO(SDL_IOStream *src, bool closeio); + +/** + * Load a BMP or PNG image from a file. + * + * The new surface should be freed with SDL_DestroySurface(). Not doing so + * will result in a memory leak. + * + * \param file the file to load. + * \returns a pointer to a new SDL_Surface structure or NULL on failure; call + * SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.4.0. + * + * \sa SDL_DestroySurface + * \sa SDL_LoadSurface_IO + */ +extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_LoadSurface(const char *file); + +/** + * Load a BMP image from a seekable SDL data stream. + * + * The new surface should be freed with SDL_DestroySurface(). Not doing so + * will result in a memory leak. + * + * \param src the data stream for the surface. + * \param closeio if true, calls SDL_CloseIO() on `src` before returning, even + * in the case of an error. + * \returns a pointer to a new SDL_Surface structure or NULL on failure; call + * SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_DestroySurface + * \sa SDL_LoadBMP + * \sa SDL_SaveBMP_IO + */ +extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_LoadBMP_IO(SDL_IOStream *src, bool closeio); + +/** + * Load a BMP image from a file. + * + * The new surface should be freed with SDL_DestroySurface(). Not doing so + * will result in a memory leak. + * + * \param file the BMP file to load. + * \returns a pointer to a new SDL_Surface structure or NULL on failure; call + * SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_DestroySurface + * \sa SDL_LoadBMP_IO + * \sa SDL_SaveBMP + */ +extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_LoadBMP(const char *file); + +/** + * Save a surface to a seekable SDL data stream in BMP format. + * + * Surfaces with a 24-bit, 32-bit and paletted 8-bit format get saved in the + * BMP directly. Other RGB formats with 8-bit or higher get converted to a + * 24-bit surface or, if they have an alpha mask or a colorkey, to a 32-bit + * surface before they are saved. YUV and paletted 1-bit and 4-bit formats are + * not supported. + * + * \param surface the SDL_Surface structure containing the image to be saved. + * \param dst a data stream to save to. + * \param closeio if true, calls SDL_CloseIO() on `dst` before returning, even + * in the case of an error. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function can be called on different threads with + * different surfaces. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_LoadBMP_IO + * \sa SDL_SaveBMP + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStream *dst, bool closeio); + +/** + * Save a surface to a file in BMP format. + * + * Surfaces with a 24-bit, 32-bit and paletted 8-bit format get saved in the + * BMP directly. Other RGB formats with 8-bit or higher get converted to a + * 24-bit surface or, if they have an alpha mask or a colorkey, to a 32-bit + * surface before they are saved. YUV and paletted 1-bit and 4-bit formats are + * not supported. + * + * \param surface the SDL_Surface structure containing the image to be saved. + * \param file a file to save to. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function can be called on different threads with + * different surfaces. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_LoadBMP + * \sa SDL_SaveBMP_IO + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SaveBMP(SDL_Surface *surface, const char *file); + +/** + * Load a PNG image from a seekable SDL data stream. + * + * This is intended as a convenience function for loading images from trusted + * sources. If you want to load arbitrary images you should use libpng or + * another image loading library designed with security in mind. + * + * The new surface should be freed with SDL_DestroySurface(). Not doing so + * will result in a memory leak. + * + * \param src the data stream for the surface. + * \param closeio if true, calls SDL_CloseIO() on `src` before returning, even + * in the case of an error. + * \returns a pointer to a new SDL_Surface structure or NULL on failure; call + * SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.4.0. + * + * \sa SDL_DestroySurface + * \sa SDL_LoadPNG + * \sa SDL_SavePNG_IO + */ +extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_LoadPNG_IO(SDL_IOStream *src, bool closeio); + +/** + * Load a PNG image from a file. + * + * This is intended as a convenience function for loading images from trusted + * sources. If you want to load arbitrary images you should use libpng or + * another image loading library designed with security in mind. + * + * The new surface should be freed with SDL_DestroySurface(). Not doing so + * will result in a memory leak. + * + * \param file the PNG file to load. + * \returns a pointer to a new SDL_Surface structure or NULL on failure; call + * SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.4.0. + * + * \sa SDL_DestroySurface + * \sa SDL_LoadPNG_IO + * \sa SDL_SavePNG + */ +extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_LoadPNG(const char *file); + +/** + * Save a surface to a seekable SDL data stream in PNG format. + * + * \param surface the SDL_Surface structure containing the image to be saved. + * \param dst a data stream to save to. + * \param closeio if true, calls SDL_CloseIO() on `dst` before returning, even + * in the case of an error. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function can be called on different threads with + * different surfaces. + * + * \since This function is available since SDL 3.4.0. + * + * \sa SDL_LoadPNG_IO + * \sa SDL_SavePNG + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SavePNG_IO(SDL_Surface *surface, SDL_IOStream *dst, bool closeio); + +/** + * Save a surface to a file in PNG format. + * + * \param surface the SDL_Surface structure containing the image to be saved. + * \param file a file to save to. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function can be called on different threads with + * different surfaces. + * + * \since This function is available since SDL 3.4.0. + * + * \sa SDL_LoadPNG + * \sa SDL_SavePNG_IO + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SavePNG(SDL_Surface *surface, const char *file); + +/** + * Set the RLE acceleration hint for a surface. + * + * If RLE is enabled, color key and alpha blending blits are much faster, but + * the surface must be locked before directly accessing the pixels. + * + * \param surface the SDL_Surface structure to optimize. + * \param enabled true to enable RLE acceleration, false to disable it. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function can be called on different threads with + * different surfaces. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_BlitSurface + * \sa SDL_LockSurface + * \sa SDL_UnlockSurface + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetSurfaceRLE(SDL_Surface *surface, bool enabled); + +/** + * Returns whether the surface is RLE enabled. + * + * It is safe to pass a NULL `surface` here; it will return false. + * + * \param surface the SDL_Surface structure to query. + * \returns true if the surface is RLE enabled, false otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetSurfaceRLE + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SurfaceHasRLE(SDL_Surface *surface); + +/** + * Set the color key (transparent pixel) in a surface. + * + * The color key defines a pixel value that will be treated as transparent in + * a blit. For example, one can use this to specify that cyan pixels should be + * considered transparent, and therefore not rendered. + * + * It is a pixel of the format used by the surface, as generated by + * SDL_MapRGB(). + * + * \param surface the SDL_Surface structure to update. + * \param enabled true to enable color key, false to disable color key. + * \param key the transparent pixel. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function can be called on different threads with + * different surfaces. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetSurfaceColorKey + * \sa SDL_SetSurfaceRLE + * \sa SDL_SurfaceHasColorKey + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetSurfaceColorKey(SDL_Surface *surface, bool enabled, Uint32 key); + +/** + * Returns whether the surface has a color key. + * + * It is safe to pass a NULL `surface` here; it will return false. + * + * \param surface the SDL_Surface structure to query. + * \returns true if the surface has a color key, false otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetSurfaceColorKey + * \sa SDL_GetSurfaceColorKey + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SurfaceHasColorKey(SDL_Surface *surface); + +/** + * Get the color key (transparent pixel) for a surface. + * + * The color key is a pixel of the format used by the surface, as generated by + * SDL_MapRGB(). + * + * If the surface doesn't have color key enabled this function returns false. + * + * \param surface the SDL_Surface structure to query. + * \param key a pointer filled in with the transparent pixel. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetSurfaceColorKey + * \sa SDL_SurfaceHasColorKey + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetSurfaceColorKey(SDL_Surface *surface, Uint32 *key); + +/** + * Set an additional color value multiplied into blit operations. + * + * When this surface is blitted, during the blit operation each source color + * channel is modulated by the appropriate color value according to the + * following formula: + * + * `srcC = srcC * (color / 255)` + * + * \param surface the SDL_Surface structure to update. + * \param r the red color value multiplied into blit operations. + * \param g the green color value multiplied into blit operations. + * \param b the blue color value multiplied into blit operations. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function can be called on different threads with + * different surfaces. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetSurfaceColorMod + * \sa SDL_SetSurfaceAlphaMod + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetSurfaceColorMod(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b); + + +/** + * Get the additional color value multiplied into blit operations. + * + * \param surface the SDL_Surface structure to query. + * \param r a pointer filled in with the current red color value. + * \param g a pointer filled in with the current green color value. + * \param b a pointer filled in with the current blue color value. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function can be called on different threads with + * different surfaces. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetSurfaceAlphaMod + * \sa SDL_SetSurfaceColorMod + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetSurfaceColorMod(SDL_Surface *surface, Uint8 *r, Uint8 *g, Uint8 *b); + +/** + * Set an additional alpha value used in blit operations. + * + * When this surface is blitted, during the blit operation the source alpha + * value is modulated by this alpha value according to the following formula: + * + * `srcA = srcA * (alpha / 255)` + * + * \param surface the SDL_Surface structure to update. + * \param alpha the alpha value multiplied into blit operations. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function can be called on different threads with + * different surfaces. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetSurfaceAlphaMod + * \sa SDL_SetSurfaceColorMod + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetSurfaceAlphaMod(SDL_Surface *surface, Uint8 alpha); + +/** + * Get the additional alpha value used in blit operations. + * + * \param surface the SDL_Surface structure to query. + * \param alpha a pointer filled in with the current alpha value. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetSurfaceColorMod + * \sa SDL_SetSurfaceAlphaMod + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetSurfaceAlphaMod(SDL_Surface *surface, Uint8 *alpha); + +/** + * Set the blend mode used for blit operations. + * + * To copy a surface to another surface (or texture) without blending with the + * existing data, the blendmode of the SOURCE surface should be set to + * `SDL_BLENDMODE_NONE`. + * + * \param surface the SDL_Surface structure to update. + * \param blendMode the SDL_BlendMode to use for blit blending. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function can be called on different threads with + * different surfaces. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetSurfaceBlendMode + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode blendMode); + +/** + * Get the blend mode used for blit operations. + * + * \param surface the SDL_Surface structure to query. + * \param blendMode a pointer filled in with the current SDL_BlendMode. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetSurfaceBlendMode + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode *blendMode); + +/** + * Set the clipping rectangle for a surface. + * + * When `surface` is the destination of a blit, only the area within the clip + * rectangle is drawn into. + * + * Note that blits are automatically clipped to the edges of the source and + * destination surfaces. + * + * \param surface the SDL_Surface structure to be clipped. + * \param rect the SDL_Rect structure representing the clipping rectangle, or + * NULL to disable clipping. + * \returns true if the rectangle intersects the surface, otherwise false and + * blits will be completely clipped. + * + * \threadsafety This function can be called on different threads with + * different surfaces. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetSurfaceClipRect + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetSurfaceClipRect(SDL_Surface *surface, const SDL_Rect *rect); + +/** + * Get the clipping rectangle for a surface. + * + * When `surface` is the destination of a blit, only the area within the clip + * rectangle is drawn into. + * + * \param surface the SDL_Surface structure representing the surface to be + * clipped. + * \param rect an SDL_Rect structure filled in with the clipping rectangle for + * the surface. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function can be called on different threads with + * different surfaces. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetSurfaceClipRect + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetSurfaceClipRect(SDL_Surface *surface, SDL_Rect *rect); + +/** + * Flip a surface vertically or horizontally. + * + * \param surface the surface to flip. + * \param flip the direction to flip. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function can be called on different threads with + * different surfaces. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_FlipSurface(SDL_Surface *surface, SDL_FlipMode flip); + +/** + * Return a copy of a surface rotated clockwise a number of degrees. + * + * The angle of rotation can be negative for counter-clockwise rotation. + * + * When the rotation isn't a multiple of 90 degrees, the resulting surface is + * larger than the original, with the background filled in with the colorkey, + * if available, or RGBA 255/255/255/0 if not. + * + * If `surface` has the SDL_PROP_SURFACE_ROTATION_FLOAT property set on it, + * the new copy will have the adjusted value set: if the rotation property is + * 90 and `angle` was 30, the new surface will have a property value of 60 + * (that is: to be upright vs gravity, this surface needs to rotate 60 more + * degrees). However, note that further rotations on the new surface in this + * example will produce unexpected results, since the image will have resized + * and padded to accommodate the not-90 degree angle. + * + * \param surface the surface to rotate. + * \param angle the rotation angle, in degrees. + * \returns a rotated copy of the surface or NULL on failure; call + * SDL_GetError() for more information. + * + * \threadsafety This function can be called on different threads with + * different surfaces. + * + * \since This function is available since SDL 3.4.0. + */ +extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_RotateSurface(SDL_Surface *surface, float angle); + +/** + * Creates a new surface identical to the existing surface. + * + * If the original surface has alternate images, the new surface will have a + * reference to them as well. + * + * The returned surface should be freed with SDL_DestroySurface(). + * + * \param surface the surface to duplicate. + * \returns a copy of the surface or NULL on failure; call SDL_GetError() for + * more information. + * + * \threadsafety This function can be called on different threads with + * different surfaces. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_DestroySurface + */ +extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_DuplicateSurface(SDL_Surface *surface); + +/** + * Creates a new surface identical to the existing surface, scaled to the + * desired size. + * + * The returned surface should be freed with SDL_DestroySurface(). + * + * \param surface the surface to duplicate and scale. + * \param width the width of the new surface. + * \param height the height of the new surface. + * \param scaleMode the SDL_ScaleMode to be used. + * \returns a copy of the surface or NULL on failure; call SDL_GetError() for + * more information. + * + * \threadsafety This function can be called on different threads with + * different surfaces. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_DestroySurface + */ +extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_ScaleSurface(SDL_Surface *surface, int width, int height, SDL_ScaleMode scaleMode); + +/** + * Copy an existing surface to a new surface of the specified format. + * + * This function is used to optimize images for faster *repeat* blitting. This + * is accomplished by converting the original and storing the result as a new + * surface. The new, optimized surface can then be used as the source for + * future blits, making them faster. + * + * If you are converting to an indexed surface and want to map colors to a + * palette, you can use SDL_ConvertSurfaceAndColorspace() instead. + * + * If the original surface has alternate images, the new surface will have a + * reference to them as well. + * + * \param surface the existing SDL_Surface structure to convert. + * \param format the new pixel format. + * \returns the new SDL_Surface structure that is created or NULL on failure; + * call SDL_GetError() for more information. + * + * \threadsafety This function can be called on different threads with + * different surfaces. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_ConvertSurfaceAndColorspace + * \sa SDL_DestroySurface + */ +extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_ConvertSurface(SDL_Surface *surface, SDL_PixelFormat format); + +/** + * Copy an existing surface to a new surface of the specified format and + * colorspace. + * + * This function converts an existing surface to a new format and colorspace + * and returns the new surface. This will perform any pixel format and + * colorspace conversion needed. + * + * If the original surface has alternate images, the new surface will have a + * reference to them as well. + * + * \param surface the existing SDL_Surface structure to convert. + * \param format the new pixel format. + * \param palette an optional palette to use for indexed formats, may be NULL. + * \param colorspace the new colorspace. + * \param props an SDL_PropertiesID with additional color properties, or 0. + * \returns the new SDL_Surface structure that is created or NULL on failure; + * call SDL_GetError() for more information. + * + * \threadsafety This function can be called on different threads with + * different surfaces. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_ConvertSurface + * \sa SDL_DestroySurface + */ +extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_ConvertSurfaceAndColorspace(SDL_Surface *surface, SDL_PixelFormat format, SDL_Palette *palette, SDL_Colorspace colorspace, SDL_PropertiesID props); + +/** + * Copy a block of pixels of one format to another format. + * + * \param width the width of the block to copy, in pixels. + * \param height the height of the block to copy, in pixels. + * \param src_format an SDL_PixelFormat value of the `src` pixels format. + * \param src a pointer to the source pixels. + * \param src_pitch the pitch of the source pixels, in bytes. + * \param dst_format an SDL_PixelFormat value of the `dst` pixels format. + * \param dst a pointer to be filled in with new pixel data. + * \param dst_pitch the pitch of the destination pixels, in bytes. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety The same destination pixels should not be used from two + * threads at once. It is safe to use the same source pixels + * from multiple threads. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_ConvertPixelsAndColorspace + */ +extern SDL_DECLSPEC bool SDLCALL SDL_ConvertPixels(int width, int height, SDL_PixelFormat src_format, const void *src, int src_pitch, SDL_PixelFormat dst_format, void *dst, int dst_pitch); + +/** + * Copy a block of pixels of one format and colorspace to another format and + * colorspace. + * + * \param width the width of the block to copy, in pixels. + * \param height the height of the block to copy, in pixels. + * \param src_format an SDL_PixelFormat value of the `src` pixels format. + * \param src_colorspace an SDL_Colorspace value describing the colorspace of + * the `src` pixels. + * \param src_properties an SDL_PropertiesID with additional source color + * properties, or 0. + * \param src a pointer to the source pixels. + * \param src_pitch the pitch of the source pixels, in bytes. + * \param dst_format an SDL_PixelFormat value of the `dst` pixels format. + * \param dst_colorspace an SDL_Colorspace value describing the colorspace of + * the `dst` pixels. + * \param dst_properties an SDL_PropertiesID with additional destination color + * properties, or 0. + * \param dst a pointer to be filled in with new pixel data. + * \param dst_pitch the pitch of the destination pixels, in bytes. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety The same destination pixels should not be used from two + * threads at once. It is safe to use the same source pixels + * from multiple threads. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_ConvertPixels + */ +extern SDL_DECLSPEC bool SDLCALL SDL_ConvertPixelsAndColorspace(int width, int height, SDL_PixelFormat src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch, SDL_PixelFormat dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch); + +/** + * Premultiply the alpha on a block of pixels. + * + * This is safe to use with src == dst, but not for other overlapping areas. + * + * \param width the width of the block to convert, in pixels. + * \param height the height of the block to convert, in pixels. + * \param src_format an SDL_PixelFormat value of the `src` pixels format. + * \param src a pointer to the source pixels. + * \param src_pitch the pitch of the source pixels, in bytes. + * \param dst_format an SDL_PixelFormat value of the `dst` pixels format. + * \param dst a pointer to be filled in with premultiplied pixel data. + * \param dst_pitch the pitch of the destination pixels, in bytes. + * \param linear true to convert from sRGB to linear space for the alpha + * multiplication, false to do multiplication in sRGB space. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety The same destination pixels should not be used from two + * threads at once. It is safe to use the same source pixels + * from multiple threads. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_PremultiplyAlpha(int width, int height, SDL_PixelFormat src_format, const void *src, int src_pitch, SDL_PixelFormat dst_format, void *dst, int dst_pitch, bool linear); + +/** + * Premultiply the alpha in a surface. + * + * This is safe to use with src == dst, but not for other overlapping areas. + * + * \param surface the surface to modify. + * \param linear true to convert from sRGB to linear space for the alpha + * multiplication, false to do multiplication in sRGB space. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function can be called on different threads with + * different surfaces. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_PremultiplySurfaceAlpha(SDL_Surface *surface, bool linear); + +/** + * Clear a surface with a specific color, with floating point precision. + * + * This function handles all surface formats, and ignores any clip rectangle. + * + * If the surface is YUV, the color is assumed to be in the sRGB colorspace, + * otherwise the color is assumed to be in the colorspace of the surface. + * + * \param surface the SDL_Surface to clear. + * \param r the red component of the pixel, normally in the range 0-1. + * \param g the green component of the pixel, normally in the range 0-1. + * \param b the blue component of the pixel, normally in the range 0-1. + * \param a the alpha component of the pixel, normally in the range 0-1. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function can be called on different threads with + * different surfaces. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_ClearSurface(SDL_Surface *surface, float r, float g, float b, float a); + +/** + * Perform a fast fill of a rectangle with a specific color. + * + * `color` should be a pixel of the format used by the surface, and can be + * generated by SDL_MapRGB() or SDL_MapRGBA(). If the color value contains an + * alpha component then the destination is simply filled with that alpha + * information, no blending takes place. + * + * If there is a clip rectangle set on the destination (set via + * SDL_SetSurfaceClipRect()), then this function will fill based on the + * intersection of the clip rectangle and `rect`. + * + * \param dst the SDL_Surface structure that is the drawing target. + * \param rect the SDL_Rect structure representing the rectangle to fill, or + * NULL to fill the entire surface. + * \param color the color to fill with. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function can be called on different threads with + * different surfaces. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_FillSurfaceRects + */ +extern SDL_DECLSPEC bool SDLCALL SDL_FillSurfaceRect(SDL_Surface *dst, const SDL_Rect *rect, Uint32 color); + +/** + * Perform a fast fill of a set of rectangles with a specific color. + * + * `color` should be a pixel of the format used by the surface, and can be + * generated by SDL_MapRGB() or SDL_MapRGBA(). If the color value contains an + * alpha component then the destination is simply filled with that alpha + * information, no blending takes place. + * + * If there is a clip rectangle set on the destination (set via + * SDL_SetSurfaceClipRect()), then this function will fill based on the + * intersection of the clip rectangle and `rect`. + * + * \param dst the SDL_Surface structure that is the drawing target. + * \param rects an array of SDL_Rects representing the rectangles to fill. + * \param count the number of rectangles in the array. + * \param color the color to fill with. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function can be called on different threads with + * different surfaces. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_FillSurfaceRect + */ +extern SDL_DECLSPEC bool SDLCALL SDL_FillSurfaceRects(SDL_Surface *dst, const SDL_Rect *rects, int count, Uint32 color); + +/** + * Performs a fast blit from the source surface to the destination surface + * with clipping. + * + * If either `srcrect` or `dstrect` are NULL, the entire surface (`src` or + * `dst`) is copied while ensuring clipping to `dst->clip_rect`. + * + * The blit function should not be called on a locked surface. + * + * The blit semantics for surfaces with and without blending and colorkey are + * defined as follows: + * + * ``` + * RGBA->RGB: + * Source surface blend mode set to SDL_BLENDMODE_BLEND: + * alpha-blend (using the source alpha-channel and per-surface alpha) + * SDL_SRCCOLORKEY ignored. + * Source surface blend mode set to SDL_BLENDMODE_NONE: + * copy RGB. + * if SDL_SRCCOLORKEY set, only copy the pixels that do not match the + * RGB values of the source color key, ignoring alpha in the + * comparison. + * + * RGB->RGBA: + * Source surface blend mode set to SDL_BLENDMODE_BLEND: + * alpha-blend (using the source per-surface alpha) + * Source surface blend mode set to SDL_BLENDMODE_NONE: + * copy RGB, set destination alpha to source per-surface alpha value. + * both: + * if SDL_SRCCOLORKEY set, only copy the pixels that do not match the + * source color key. + * + * RGBA->RGBA: + * Source surface blend mode set to SDL_BLENDMODE_BLEND: + * alpha-blend (using the source alpha-channel and per-surface alpha) + * SDL_SRCCOLORKEY ignored. + * Source surface blend mode set to SDL_BLENDMODE_NONE: + * copy all of RGBA to the destination. + * if SDL_SRCCOLORKEY set, only copy the pixels that do not match the + * RGB values of the source color key, ignoring alpha in the + * comparison. + * + * RGB->RGB: + * Source surface blend mode set to SDL_BLENDMODE_BLEND: + * alpha-blend (using the source per-surface alpha) + * Source surface blend mode set to SDL_BLENDMODE_NONE: + * copy RGB. + * both: + * if SDL_SRCCOLORKEY set, only copy the pixels that do not match the + * source color key. + * ``` + * + * \param src the SDL_Surface structure to be copied from. + * \param srcrect the SDL_Rect structure representing the rectangle to be + * copied, or NULL to copy the entire surface. + * \param dst the SDL_Surface structure that is the blit target. + * \param dstrect the SDL_Rect structure representing the x and y position in + * the destination surface, or NULL for (0,0). The width and + * height are ignored, and are copied from `srcrect`. If you + * want a specific width and height, you should use + * SDL_BlitSurfaceScaled(). + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety Only one thread should be using the `src` and `dst` surfaces + * at any given time. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_BlitSurfaceScaled + */ +extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurface(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect); + +/** + * Perform low-level surface blitting only. + * + * This is a semi-private blit function and it performs low-level surface + * blitting, assuming the input rectangles have already been clipped. + * + * \param src the SDL_Surface structure to be copied from. + * \param srcrect the SDL_Rect structure representing the rectangle to be + * copied, may not be NULL. + * \param dst the SDL_Surface structure that is the blit target. + * \param dstrect the SDL_Rect structure representing the target rectangle in + * the destination surface, may not be NULL. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety Only one thread should be using the `src` and `dst` surfaces + * at any given time. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_BlitSurface + */ +extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurfaceUnchecked(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect); + +/** + * Perform a scaled blit to a destination surface, which may be of a different + * format. + * + * \param src the SDL_Surface structure to be copied from. + * \param srcrect the SDL_Rect structure representing the rectangle to be + * copied, or NULL to copy the entire surface. + * \param dst the SDL_Surface structure that is the blit target. + * \param dstrect the SDL_Rect structure representing the target rectangle in + * the destination surface, or NULL to fill the entire + * destination surface. + * \param scaleMode the SDL_ScaleMode to be used. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety Only one thread should be using the `src` and `dst` surfaces + * at any given time. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_BlitSurface + */ +extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurfaceScaled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect, SDL_ScaleMode scaleMode); + +/** + * Perform low-level surface scaled blitting only. + * + * This is a semi-private function and it performs low-level surface blitting, + * assuming the input rectangles have already been clipped. + * + * \param src the SDL_Surface structure to be copied from. + * \param srcrect the SDL_Rect structure representing the rectangle to be + * copied, may not be NULL. + * \param dst the SDL_Surface structure that is the blit target. + * \param dstrect the SDL_Rect structure representing the target rectangle in + * the destination surface, may not be NULL. + * \param scaleMode the SDL_ScaleMode to be used. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety Only one thread should be using the `src` and `dst` surfaces + * at any given time. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_BlitSurfaceScaled + */ +extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurfaceUncheckedScaled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect, SDL_ScaleMode scaleMode); + +/** + * Perform a stretched pixel copy from one surface to another. + * + * \param src the SDL_Surface structure to be copied from. + * \param srcrect the SDL_Rect structure representing the rectangle to be + * copied, or NULL to copy the entire surface. + * \param dst the SDL_Surface structure that is the blit target. + * \param dstrect the SDL_Rect structure representing the target rectangle in + * the destination surface, or NULL to fill the entire + * destination surface. + * \param scaleMode the SDL_ScaleMode to be used. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety Only one thread should be using the `src` and `dst` surfaces + * at any given time. + * + * \since This function is available since SDL 3.4.0. + * + * \sa SDL_BlitSurfaceScaled + */ +extern SDL_DECLSPEC bool SDLCALL SDL_StretchSurface(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect, SDL_ScaleMode scaleMode); + +/** + * Perform a tiled blit to a destination surface, which may be of a different + * format. + * + * The pixels in `srcrect` will be repeated as many times as needed to + * completely fill `dstrect`. + * + * \param src the SDL_Surface structure to be copied from. + * \param srcrect the SDL_Rect structure representing the rectangle to be + * copied, or NULL to copy the entire surface. + * \param dst the SDL_Surface structure that is the blit target. + * \param dstrect the SDL_Rect structure representing the target rectangle in + * the destination surface, or NULL to fill the entire surface. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety Only one thread should be using the `src` and `dst` surfaces + * at any given time. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_BlitSurface + */ +extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurfaceTiled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect); + +/** + * Perform a scaled and tiled blit to a destination surface, which may be of a + * different format. + * + * The pixels in `srcrect` will be scaled and repeated as many times as needed + * to completely fill `dstrect`. + * + * \param src the SDL_Surface structure to be copied from. + * \param srcrect the SDL_Rect structure representing the rectangle to be + * copied, or NULL to copy the entire surface. + * \param scale the scale used to transform srcrect into the destination + * rectangle, e.g. a 32x32 texture with a scale of 2 would fill + * 64x64 tiles. + * \param scaleMode scale algorithm to be used. + * \param dst the SDL_Surface structure that is the blit target. + * \param dstrect the SDL_Rect structure representing the target rectangle in + * the destination surface, or NULL to fill the entire surface. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety Only one thread should be using the `src` and `dst` surfaces + * at any given time. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_BlitSurface + */ +extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurfaceTiledWithScale(SDL_Surface *src, const SDL_Rect *srcrect, float scale, SDL_ScaleMode scaleMode, SDL_Surface *dst, const SDL_Rect *dstrect); + +/** + * Perform a scaled blit using the 9-grid algorithm to a destination surface, + * which may be of a different format. + * + * The pixels in the source surface are split into a 3x3 grid, using the + * different corner sizes for each corner, and the sides and center making up + * the remaining pixels. The corners are then scaled using `scale` and fit + * into the corners of the destination rectangle. The sides and center are + * then stretched into place to cover the remaining destination rectangle. + * + * \param src the SDL_Surface structure to be copied from. + * \param srcrect the SDL_Rect structure representing the rectangle to be used + * for the 9-grid, or NULL to use the entire surface. + * \param left_width the width, in pixels, of the left corners in `srcrect`. + * \param right_width the width, in pixels, of the right corners in `srcrect`. + * \param top_height the height, in pixels, of the top corners in `srcrect`. + * \param bottom_height the height, in pixels, of the bottom corners in + * `srcrect`. + * \param scale the scale used to transform the corner of `srcrect` into the + * corner of `dstrect`, or 0.0f for an unscaled blit. + * \param scaleMode scale algorithm to be used. + * \param dst the SDL_Surface structure that is the blit target. + * \param dstrect the SDL_Rect structure representing the target rectangle in + * the destination surface, or NULL to fill the entire surface. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety Only one thread should be using the `src` and `dst` surfaces + * at any given time. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_BlitSurface + */ +extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurface9Grid(SDL_Surface *src, const SDL_Rect *srcrect, int left_width, int right_width, int top_height, int bottom_height, float scale, SDL_ScaleMode scaleMode, SDL_Surface *dst, const SDL_Rect *dstrect); + +/** + * Map an RGB triple to an opaque pixel value for a surface. + * + * This function maps the RGB color value to the specified pixel format and + * returns the pixel value best approximating the given RGB color value for + * the given pixel format. + * + * If the surface has a palette, the index of the closest matching color in + * the palette will be returned. + * + * If the surface pixel format has an alpha component it will be returned as + * all 1 bits (fully opaque). + * + * If the pixel format bpp (color depth) is less than 32-bpp then the unused + * upper bits of the return value can safely be ignored (e.g., with a 16-bpp + * format the return value can be assigned to a Uint16, and similarly a Uint8 + * for an 8-bpp format). + * + * \param surface the surface to use for the pixel format and palette. + * \param r the red component of the pixel in the range 0-255. + * \param g the green component of the pixel in the range 0-255. + * \param b the blue component of the pixel in the range 0-255. + * \returns a pixel value. + * + * \threadsafety This function can be called on different threads with + * different surfaces. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_MapSurfaceRGBA + */ +extern SDL_DECLSPEC Uint32 SDLCALL SDL_MapSurfaceRGB(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b); + +/** + * Map an RGBA quadruple to a pixel value for a surface. + * + * This function maps the RGBA color value to the specified pixel format and + * returns the pixel value best approximating the given RGBA color value for + * the given pixel format. + * + * If the surface pixel format has no alpha component the alpha value will be + * ignored (as it will be in formats with a palette). + * + * If the surface has a palette, the index of the closest matching color in + * the palette will be returned. + * + * If the pixel format bpp (color depth) is less than 32-bpp then the unused + * upper bits of the return value can safely be ignored (e.g., with a 16-bpp + * format the return value can be assigned to a Uint16, and similarly a Uint8 + * for an 8-bpp format). + * + * \param surface the surface to use for the pixel format and palette. + * \param r the red component of the pixel in the range 0-255. + * \param g the green component of the pixel in the range 0-255. + * \param b the blue component of the pixel in the range 0-255. + * \param a the alpha component of the pixel in the range 0-255. + * \returns a pixel value. + * + * \threadsafety This function can be called on different threads with + * different surfaces. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_MapSurfaceRGB + */ +extern SDL_DECLSPEC Uint32 SDLCALL SDL_MapSurfaceRGBA(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b, Uint8 a); + +/** + * Retrieves a single pixel from a surface. + * + * This function prioritizes correctness over speed: it is suitable for unit + * tests, but is not intended for use in a game engine. + * + * Like SDL_GetRGBA, this uses the entire 0..255 range when converting color + * components from pixel formats with less than 8 bits per RGB component. + * + * \param surface the surface to read. + * \param x the horizontal coordinate, 0 <= x < width. + * \param y the vertical coordinate, 0 <= y < height. + * \param r a pointer filled in with the red channel, 0-255, or NULL to ignore + * this channel. + * \param g a pointer filled in with the green channel, 0-255, or NULL to + * ignore this channel. + * \param b a pointer filled in with the blue channel, 0-255, or NULL to + * ignore this channel. + * \param a a pointer filled in with the alpha channel, 0-255, or NULL to + * ignore this channel. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function can be called on different threads with + * different surfaces. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_ReadSurfacePixel(SDL_Surface *surface, int x, int y, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a); + +/** + * Retrieves a single pixel from a surface. + * + * This function prioritizes correctness over speed: it is suitable for unit + * tests, but is not intended for use in a game engine. + * + * \param surface the surface to read. + * \param x the horizontal coordinate, 0 <= x < width. + * \param y the vertical coordinate, 0 <= y < height. + * \param r a pointer filled in with the red channel, normally in the range + * 0-1, or NULL to ignore this channel. + * \param g a pointer filled in with the green channel, normally in the range + * 0-1, or NULL to ignore this channel. + * \param b a pointer filled in with the blue channel, normally in the range + * 0-1, or NULL to ignore this channel. + * \param a a pointer filled in with the alpha channel, normally in the range + * 0-1, or NULL to ignore this channel. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function can be called on different threads with + * different surfaces. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_ReadSurfacePixelFloat(SDL_Surface *surface, int x, int y, float *r, float *g, float *b, float *a); + +/** + * Writes a single pixel to a surface. + * + * This function prioritizes correctness over speed: it is suitable for unit + * tests, but is not intended for use in a game engine. + * + * Like SDL_MapRGBA, this uses the entire 0..255 range when converting color + * components from pixel formats with less than 8 bits per RGB component. + * + * \param surface the surface to write. + * \param x the horizontal coordinate, 0 <= x < width. + * \param y the vertical coordinate, 0 <= y < height. + * \param r the red channel value, 0-255. + * \param g the green channel value, 0-255. + * \param b the blue channel value, 0-255. + * \param a the alpha channel value, 0-255. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function can be called on different threads with + * different surfaces. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_WriteSurfacePixel(SDL_Surface *surface, int x, int y, Uint8 r, Uint8 g, Uint8 b, Uint8 a); + +/** + * Writes a single pixel to a surface. + * + * This function prioritizes correctness over speed: it is suitable for unit + * tests, but is not intended for use in a game engine. + * + * \param surface the surface to write. + * \param x the horizontal coordinate, 0 <= x < width. + * \param y the vertical coordinate, 0 <= y < height. + * \param r the red channel value, normally in the range 0-1. + * \param g the green channel value, normally in the range 0-1. + * \param b the blue channel value, normally in the range 0-1. + * \param a the alpha channel value, normally in the range 0-1. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function can be called on different threads with + * different surfaces. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_WriteSurfacePixelFloat(SDL_Surface *surface, int x, int y, float r, float g, float b, float a); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_surface_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_system.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_system.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,818 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * # CategorySystem + * + * Platform-specific SDL API functions. These are functions that deal with + * needs of specific operating systems, that didn't make sense to offer as + * platform-independent, generic APIs. + * + * Most apps can make do without these functions, but they can be useful for + * integrating with other parts of a specific system, adding platform-specific + * polish to an app, or solving problems that only affect one target. + */ + +#ifndef SDL_system_h_ +#define SDL_system_h_ + +#include +#include +#include +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + + +/* + * Platform specific functions for Windows + */ +#if defined(SDL_PLATFORM_WINDOWS) + +typedef struct tagMSG MSG; + +/** + * A callback to be used with SDL_SetWindowsMessageHook. + * + * This callback may modify the message, and should return true if the message + * should continue to be processed, or false to prevent further processing. + * + * As this is processing a message directly from the Windows event loop, this + * callback should do the minimum required work and return quickly. + * + * \param userdata the app-defined pointer provided to + * SDL_SetWindowsMessageHook. + * \param msg a pointer to a Win32 event structure to process. + * \returns true to let event continue on, false to drop it. + * + * \threadsafety This may only be called (by SDL) from the thread handling the + * Windows event loop. + * + * \since This datatype is available since SDL 3.2.0. + * + * \sa SDL_SetWindowsMessageHook + * \sa SDL_HINT_WINDOWS_ENABLE_MESSAGELOOP + */ +typedef bool (SDLCALL *SDL_WindowsMessageHook)(void *userdata, MSG *msg); + +/** + * Set a callback for every Windows message, run before TranslateMessage(). + * + * The callback may modify the message, and should return true if the message + * should continue to be processed, or false to prevent further processing. + * + * \param callback the SDL_WindowsMessageHook function to call. + * \param userdata a pointer to pass to every iteration of `callback`. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_WindowsMessageHook + * \sa SDL_HINT_WINDOWS_ENABLE_MESSAGELOOP + */ +extern SDL_DECLSPEC void SDLCALL SDL_SetWindowsMessageHook(SDL_WindowsMessageHook callback, void *userdata); + +#endif /* defined(SDL_PLATFORM_WINDOWS) */ + +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) + +/** + * Get the D3D9 adapter index that matches the specified display. + * + * The returned adapter index can be passed to `IDirect3D9::CreateDevice` and + * controls on which monitor a full screen application will appear. + * + * \param displayID the instance of the display to query. + * \returns the D3D9 adapter index on success or -1 on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_GetDirect3D9AdapterIndex(SDL_DisplayID displayID); + +/** + * Get the DXGI Adapter and Output indices for the specified display. + * + * The DXGI Adapter and Output indices can be passed to `EnumAdapters` and + * `EnumOutputs` respectively to get the objects required to create a DX10 or + * DX11 device and swap chain. + * + * \param displayID the instance of the display to query. + * \param adapterIndex a pointer to be filled in with the adapter index. + * \param outputIndex a pointer to be filled in with the output index. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetDXGIOutputInfo(SDL_DisplayID displayID, int *adapterIndex, int *outputIndex); + +#endif /* defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) */ + + +/* + * Platform specific functions for UNIX + */ + +/* this is defined in Xlib's headers, just need a simple declaration here. */ +typedef union _XEvent XEvent; + +/** + * A callback to be used with SDL_SetX11EventHook. + * + * This callback may modify the event, and should return true if the event + * should continue to be processed, or false to prevent further processing. + * + * As this is processing an event directly from the X11 event loop, this + * callback should do the minimum required work and return quickly. + * + * \param userdata the app-defined pointer provided to SDL_SetX11EventHook. + * \param xevent a pointer to an Xlib XEvent union to process. + * \returns true to let event continue on, false to drop it. + * + * \threadsafety This may only be called (by SDL) from the thread handling the + * X11 event loop. + * + * \since This datatype is available since SDL 3.2.0. + * + * \sa SDL_SetX11EventHook + */ +typedef bool (SDLCALL *SDL_X11EventHook)(void *userdata, XEvent *xevent); + +/** + * Set a callback for every X11 event. + * + * The callback may modify the event, and should return true if the event + * should continue to be processed, or false to prevent further processing. + * + * \param callback the SDL_X11EventHook function to call. + * \param userdata a pointer to pass to every iteration of `callback`. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_SetX11EventHook(SDL_X11EventHook callback, void *userdata); + +/* Platform specific functions for Linux*/ +#ifdef SDL_PLATFORM_LINUX + +/** + * Sets the UNIX nice value for a thread. + * + * This uses setpriority() if possible, and RealtimeKit if available. + * + * \param threadID the Unix thread ID to change priority of. + * \param priority the new, Unix-specific, priority value. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetLinuxThreadPriority(Sint64 threadID, int priority); + +/** + * Sets the priority (not nice level) and scheduling policy for a thread. + * + * This uses setpriority() if possible, and RealtimeKit if available. + * + * \param threadID the Unix thread ID to change priority of. + * \param sdlPriority the new SDL_ThreadPriority value. + * \param schedPolicy the new scheduling policy (SCHED_FIFO, SCHED_RR, + * SCHED_OTHER, etc...). + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetLinuxThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int schedPolicy); + +#endif /* SDL_PLATFORM_LINUX */ + +/* + * Platform specific functions for iOS + */ +#ifdef SDL_PLATFORM_IOS + +/** + * The prototype for an Apple iOS animation callback. + * + * This datatype is only useful on Apple iOS. + * + * After passing a function pointer of this type to + * SDL_SetiOSAnimationCallback, the system will call that function pointer at + * a regular interval. + * + * \param userdata what was passed as `callbackParam` to + * SDL_SetiOSAnimationCallback as `callbackParam`. + * + * \since This datatype is available since SDL 3.2.0. + * + * \sa SDL_SetiOSAnimationCallback + */ +typedef void (SDLCALL *SDL_iOSAnimationCallback)(void *userdata); + +/** + * Use this function to set the animation callback on Apple iOS. + * + * The function prototype for `callback` is: + * + * ```c + * void callback(void *callbackParam); + * ``` + * + * Where its parameter, `callbackParam`, is what was passed as `callbackParam` + * to SDL_SetiOSAnimationCallback(). + * + * This function is only available on Apple iOS. + * + * For more information see: + * + * https://wiki.libsdl.org/SDL3/README-ios + * + * Note that if you use the "main callbacks" instead of a standard C `main` + * function, you don't have to use this API, as SDL will manage this for you. + * + * Details on main callbacks are here: + * + * https://wiki.libsdl.org/SDL3/README-main-functions + * + * \param window the window for which the animation callback should be set. + * \param interval the number of frames after which **callback** will be + * called. + * \param callback the function to call for every frame. + * \param callbackParam a pointer that is passed to `callback`. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetiOSEventPump + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetiOSAnimationCallback(SDL_Window *window, int interval, SDL_iOSAnimationCallback callback, void *callbackParam); + +/** + * Use this function to enable or disable the SDL event pump on Apple iOS. + * + * This function is only available on Apple iOS. + * + * \param enabled true to enable the event pump, false to disable it. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetiOSAnimationCallback + */ +extern SDL_DECLSPEC void SDLCALL SDL_SetiOSEventPump(bool enabled); + +#endif /* SDL_PLATFORM_IOS */ + + +/* + * Platform specific functions for Android + */ +#ifdef SDL_PLATFORM_ANDROID + +/** + * Get the Android Java Native Interface Environment of the current thread. + * + * This is the JNIEnv one needs to access the Java virtual machine from native + * code, and is needed for many Android APIs to be usable from C. + * + * The prototype of the function in SDL's code actually declare a void* return + * type, even if the implementation returns a pointer to a JNIEnv. The + * rationale being that the SDL headers can avoid including jni.h. + * + * \returns a pointer to Java native interface object (JNIEnv) to which the + * current thread is attached, or NULL on failure; call + * SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetAndroidActivity + */ +extern SDL_DECLSPEC void * SDLCALL SDL_GetAndroidJNIEnv(void); + +/** + * Retrieve the Java instance of the Android activity class. + * + * The prototype of the function in SDL's code actually declares a void* + * return type, even if the implementation returns a jobject. The rationale + * being that the SDL headers can avoid including jni.h. + * + * The jobject returned by the function is a local reference and must be + * released by the caller. See the PushLocalFrame() and PopLocalFrame() or + * DeleteLocalRef() functions of the Java native interface: + * + * https://docs.oracle.com/javase/1.5.0/docs/guide/jni/spec/functions.html + * + * \returns the jobject representing the instance of the Activity class of the + * Android application, or NULL on failure; call SDL_GetError() for + * more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetAndroidJNIEnv + */ +extern SDL_DECLSPEC void * SDLCALL SDL_GetAndroidActivity(void); + +/** + * Query Android API level of the current device. + * + * - API level 35: Android 15 (VANILLA_ICE_CREAM) + * - API level 34: Android 14 (UPSIDE_DOWN_CAKE) + * - API level 33: Android 13 (TIRAMISU) + * - API level 32: Android 12L (S_V2) + * - API level 31: Android 12 (S) + * - API level 30: Android 11 (R) + * - API level 29: Android 10 (Q) + * - API level 28: Android 9 (P) + * - API level 27: Android 8.1 (O_MR1) + * - API level 26: Android 8.0 (O) + * - API level 25: Android 7.1 (N_MR1) + * - API level 24: Android 7.0 (N) + * - API level 23: Android 6.0 (M) + * - API level 22: Android 5.1 (LOLLIPOP_MR1) + * - API level 21: Android 5.0 (LOLLIPOP, L) + * - API level 20: Android 4.4W (KITKAT_WATCH) + * - API level 19: Android 4.4 (KITKAT) + * - API level 18: Android 4.3 (JELLY_BEAN_MR2) + * - API level 17: Android 4.2 (JELLY_BEAN_MR1) + * - API level 16: Android 4.1 (JELLY_BEAN) + * - API level 15: Android 4.0.3 (ICE_CREAM_SANDWICH_MR1) + * - API level 14: Android 4.0 (ICE_CREAM_SANDWICH) + * - API level 13: Android 3.2 (HONEYCOMB_MR2) + * - API level 12: Android 3.1 (HONEYCOMB_MR1) + * - API level 11: Android 3.0 (HONEYCOMB) + * - API level 10: Android 2.3.3 (GINGERBREAD_MR1) + * + * \returns the Android API level. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_GetAndroidSDKVersion(void); + +/** + * Query if the application is running on a Chromebook. + * + * \returns true if this is a Chromebook, false otherwise. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_IsChromebook(void); + +/** + * Query if the application is running on a Samsung DeX docking station. + * + * \returns true if this is a DeX docking station, false otherwise. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_IsDeXMode(void); + +/** + * Trigger the Android system back button behavior. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_SendAndroidBackButton(void); + +/** + * See the official Android developer guide for more information: + * http://developer.android.com/guide/topics/data/data-storage.html + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_ANDROID_EXTERNAL_STORAGE_READ 0x01 + +/** + * See the official Android developer guide for more information: + * http://developer.android.com/guide/topics/data/data-storage.html + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_ANDROID_EXTERNAL_STORAGE_WRITE 0x02 + +/** + * Get the path used for internal storage for this Android application. + * + * This path is unique to your application and cannot be written to by other + * applications. + * + * Your internal storage path is typically: + * `/data/data/your.app.package/files`. + * + * This is a C wrapper over `android.content.Context.getFilesDir()`: + * + * https://developer.android.com/reference/android/content/Context#getFilesDir() + * + * \returns the path used for internal storage or NULL on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetAndroidExternalStoragePath + * \sa SDL_GetAndroidCachePath + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetAndroidInternalStoragePath(void); + +/** + * Get the current state of external storage for this Android application. + * + * The current state of external storage, a bitmask of these values: + * `SDL_ANDROID_EXTERNAL_STORAGE_READ`, `SDL_ANDROID_EXTERNAL_STORAGE_WRITE`. + * + * If external storage is currently unavailable, this will return 0. + * + * \returns the current state of external storage, or 0 if external storage is + * currently unavailable. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetAndroidExternalStoragePath + */ +extern SDL_DECLSPEC Uint32 SDLCALL SDL_GetAndroidExternalStorageState(void); + +/** + * Get the path used for external storage for this Android application. + * + * This path is unique to your application, but is public and can be written + * to by other applications. + * + * Your external storage path is typically: + * `/storage/sdcard0/Android/data/your.app.package/files`. + * + * This is a C wrapper over `android.content.Context.getExternalFilesDir()`: + * + * https://developer.android.com/reference/android/content/Context#getExternalFilesDir() + * + * \returns the path used for external storage for this application on success + * or NULL on failure; call SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetAndroidExternalStorageState + * \sa SDL_GetAndroidInternalStoragePath + * \sa SDL_GetAndroidCachePath + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetAndroidExternalStoragePath(void); + +/** + * Get the path used for caching data for this Android application. + * + * This path is unique to your application, but is public and can be written + * to by other applications. + * + * Your cache path is typically: `/data/data/your.app.package/cache/`. + * + * This is a C wrapper over `android.content.Context.getCacheDir()`: + * + * https://developer.android.com/reference/android/content/Context#getCacheDir() + * + * \returns the path used for caches for this application on success or NULL + * on failure; call SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetAndroidInternalStoragePath + * \sa SDL_GetAndroidExternalStoragePath + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetAndroidCachePath(void); + +/** + * Callback that presents a response from a SDL_RequestAndroidPermission call. + * + * \param userdata an app-controlled pointer that is passed to the callback. + * \param permission the Android-specific permission name that was requested. + * \param granted true if permission is granted, false if denied. + * + * \since This datatype is available since SDL 3.2.0. + * + * \sa SDL_RequestAndroidPermission + */ +typedef void (SDLCALL *SDL_RequestAndroidPermissionCallback)(void *userdata, const char *permission, bool granted); + +/** + * Request permissions at runtime, asynchronously. + * + * You do not need to call this for built-in functionality of SDL; recording + * from a microphone or reading images from a camera, using standard SDL APIs, + * will manage permission requests for you. + * + * This function never blocks. Instead, the app-supplied callback will be + * called when a decision has been made. This callback may happen on a + * different thread, and possibly much later, as it might wait on a user to + * respond to a system dialog. If permission has already been granted for a + * specific entitlement, the callback will still fire, probably on the current + * thread and before this function returns. + * + * If the request submission fails, this function returns -1 and the callback + * will NOT be called, but this should only happen in catastrophic conditions, + * like memory running out. Normally there will be a yes or no to the request + * through the callback. + * + * For the `permission` parameter, choose a value from here: + * + * https://developer.android.com/reference/android/Manifest.permission + * + * \param permission the permission to request. + * \param cb the callback to trigger when the request has a response. + * \param userdata an app-controlled pointer that is passed to the callback. + * \returns true if the request was submitted, false if there was an error + * submitting. The result of the request is only ever reported + * through the callback, not this return value. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_RequestAndroidPermission(const char *permission, SDL_RequestAndroidPermissionCallback cb, void *userdata); + +/** + * Shows an Android toast notification. + * + * Toasts are a sort of lightweight notification that are unique to Android. + * + * https://developer.android.com/guide/topics/ui/notifiers/toasts + * + * Shows toast in UI thread. + * + * For the `gravity` parameter, choose a value from here, or -1 if you don't + * have a preference: + * + * https://developer.android.com/reference/android/view/Gravity + * + * \param message text message to be shown. + * \param duration 0=short, 1=long. + * \param gravity where the notification should appear on the screen. + * \param xoffset set this parameter only when gravity >=0. + * \param yoffset set this parameter only when gravity >=0. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_ShowAndroidToast(const char *message, int duration, int gravity, int xoffset, int yoffset); + +/** + * Send a user command to SDLActivity. + * + * Override "boolean onUnhandledMessage(Message msg)" to handle the message. + * + * \param command user command that must be greater or equal to 0x8000. + * \param param user parameter. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SendAndroidMessage(Uint32 command, int param); + +#endif /* SDL_PLATFORM_ANDROID */ + +/** + * Query if the current device is a tablet. + * + * If SDL can't determine this, it will return false. + * + * \returns true if the device is a tablet, false otherwise. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_IsTablet(void); + +/** + * Query if the current device is a TV. + * + * If SDL can't determine this, it will return false. + * + * \returns true if the device is a TV, false otherwise. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_IsTV(void); + +/** + * Application sandbox environment. + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_Sandbox +{ + SDL_SANDBOX_NONE = 0, + SDL_SANDBOX_UNKNOWN_CONTAINER, + SDL_SANDBOX_FLATPAK, + SDL_SANDBOX_SNAP, + SDL_SANDBOX_MACOS +} SDL_Sandbox; + +/** + * Get the application sandbox environment, if any. + * + * \returns the application sandbox environment or SDL_SANDBOX_NONE if the + * application is not running in a sandbox environment. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_Sandbox SDLCALL SDL_GetSandbox(void); + + +/* Functions used by iOS app delegates to notify SDL about state changes. */ + +/** + * Let iOS apps with external event handling report + * onApplicationWillTerminate. + * + * This functions allows iOS apps that have their own event handling to hook + * into SDL to generate SDL events. This maps directly to an iOS-specific + * event, but since it doesn't do anything iOS-specific internally, it is + * available on all platforms, in case it might be useful for some specific + * paradigm. Most apps do not need to use this directly; SDL's internal event + * code will handle all this for windows created by SDL_CreateWindow! + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_OnApplicationWillTerminate(void); + +/** + * Let iOS apps with external event handling report + * onApplicationDidReceiveMemoryWarning. + * + * This functions allows iOS apps that have their own event handling to hook + * into SDL to generate SDL events. This maps directly to an iOS-specific + * event, but since it doesn't do anything iOS-specific internally, it is + * available on all platforms, in case it might be useful for some specific + * paradigm. Most apps do not need to use this directly; SDL's internal event + * code will handle all this for windows created by SDL_CreateWindow! + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_OnApplicationDidReceiveMemoryWarning(void); + +/** + * Let iOS apps with external event handling report + * onApplicationWillResignActive. + * + * This functions allows iOS apps that have their own event handling to hook + * into SDL to generate SDL events. This maps directly to an iOS-specific + * event, but since it doesn't do anything iOS-specific internally, it is + * available on all platforms, in case it might be useful for some specific + * paradigm. Most apps do not need to use this directly; SDL's internal event + * code will handle all this for windows created by SDL_CreateWindow! + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_OnApplicationWillEnterBackground(void); + +/** + * Let iOS apps with external event handling report + * onApplicationDidEnterBackground. + * + * This functions allows iOS apps that have their own event handling to hook + * into SDL to generate SDL events. This maps directly to an iOS-specific + * event, but since it doesn't do anything iOS-specific internally, it is + * available on all platforms, in case it might be useful for some specific + * paradigm. Most apps do not need to use this directly; SDL's internal event + * code will handle all this for windows created by SDL_CreateWindow! + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_OnApplicationDidEnterBackground(void); + +/** + * Let iOS apps with external event handling report + * onApplicationWillEnterForeground. + * + * This functions allows iOS apps that have their own event handling to hook + * into SDL to generate SDL events. This maps directly to an iOS-specific + * event, but since it doesn't do anything iOS-specific internally, it is + * available on all platforms, in case it might be useful for some specific + * paradigm. Most apps do not need to use this directly; SDL's internal event + * code will handle all this for windows created by SDL_CreateWindow! + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_OnApplicationWillEnterForeground(void); + +/** + * Let iOS apps with external event handling report + * onApplicationDidBecomeActive. + * + * This functions allows iOS apps that have their own event handling to hook + * into SDL to generate SDL events. This maps directly to an iOS-specific + * event, but since it doesn't do anything iOS-specific internally, it is + * available on all platforms, in case it might be useful for some specific + * paradigm. Most apps do not need to use this directly; SDL's internal event + * code will handle all this for windows created by SDL_CreateWindow! + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_OnApplicationDidEnterForeground(void); + +#ifdef SDL_PLATFORM_IOS + +/** + * Let iOS apps with external event handling report + * onApplicationDidChangeStatusBarOrientation. + * + * This functions allows iOS apps that have their own event handling to hook + * into SDL to generate SDL events. This maps directly to an iOS-specific + * event, but since it doesn't do anything iOS-specific internally, it is + * available on all platforms, in case it might be useful for some specific + * paradigm. Most apps do not need to use this directly; SDL's internal event + * code will handle all this for windows created by SDL_CreateWindow! + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_OnApplicationDidChangeStatusBarOrientation(void); +#endif + +/* + * Functions used only by GDK + */ +#ifdef SDL_PLATFORM_GDK +typedef struct XTaskQueueObject *XTaskQueueHandle; +typedef struct XUser *XUserHandle; + +/** + * Gets a reference to the global async task queue handle for GDK, + * initializing if needed. + * + * Once you are done with the task queue, you should call + * XTaskQueueCloseHandle to reduce the reference count to avoid a resource + * leak. + * + * \param outTaskQueue a pointer to be filled in with task queue handle. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetGDKTaskQueue(XTaskQueueHandle *outTaskQueue); + +/** + * Gets a reference to the default user handle for GDK. + * + * This is effectively a synchronous version of XUserAddAsync, which always + * prefers the default user and allows a sign-in UI. + * + * \param outUserHandle a pointer to be filled in with the default user + * handle. + * \returns true if success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetGDKDefaultUser(XUserHandle *outUserHandle); + +#endif + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_system_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_test.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_test.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,63 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * Include file for SDL test framework. + * + * This code is a part of the SDL test library, not the main SDL library. + */ + +#ifndef SDL_test_h_ +#define SDL_test_h_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Global definitions */ + +/* + * Note: Maximum size of SDLTest log message is less than SDL's limit + * to ensure we can fit additional information such as the timestamp. + */ +#define SDLTEST_MAX_LOGMESSAGE_LENGTH 3584 + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_test_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_test_assert.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_test_assert.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,98 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * Assertion functions of SDL test framework. + * + * This code is a part of the SDL test library, not the main SDL library. + */ + +/* + * + * Assert API for test code and test cases + * + */ + +#ifndef SDL_test_assert_h_ +#define SDL_test_assert_h_ + +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Fails the assert. */ +#define ASSERT_FAIL 0 + +/* Passes the assert. */ +#define ASSERT_PASS 1 + +/* + * Assert that logs and break execution flow on failures. + * + * \param assertCondition Evaluated condition or variable to assert; fail (==0) or pass (!=0). + * \param assertDescription Message to log with the assert describing it. + */ +void SDLCALL SDLTest_Assert(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription, ...) SDL_PRINTF_VARARG_FUNC(2); + +/* + * Assert for test cases that logs but does not break execution flow on failures. Updates assertion counters. + * + * \param assertCondition Evaluated condition or variable to assert; fail (==0) or pass (!=0). + * \param assertDescription Message to log with the assert describing it. + * + * \returns the assertCondition so it can be used to externally to break execution flow if desired. + */ +int SDLCALL SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription, ...) SDL_PRINTF_VARARG_FUNC(2); + +/* + * Explicitly pass without checking an assertion condition. Updates assertion counter. + * + * \param assertDescription Message to log with the assert describing it. + */ +void SDLCALL SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription, ...) SDL_PRINTF_VARARG_FUNC(1); + +/* + * Resets the assert summary counters to zero. + */ +void SDLCALL SDLTest_ResetAssertSummary(void); + +/* + * Logs summary of all assertions (total, pass, fail) since last reset as INFO or ERROR. + */ +void SDLCALL SDLTest_LogAssertSummary(void); + +/* + * Converts the current assert summary state to a test result. + * + * \returns TEST_RESULT_PASSED, TEST_RESULT_FAILED, or TEST_RESULT_NO_ASSERT + */ +int SDLCALL SDLTest_AssertSummaryToTestResult(void); + +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_test_assert_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_test_common.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_test_common.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,293 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * Common functions of SDL test framework. + * + * This code is a part of the SDL test library, not the main SDL library. + */ + +/* Ported from original test/common.h file. */ + +#ifndef SDL_test_common_h_ +#define SDL_test_common_h_ + +#include + +#ifdef SDL_PLATFORM_PSP +#define DEFAULT_WINDOW_WIDTH 480 +#define DEFAULT_WINDOW_HEIGHT 272 +#elif defined(SDL_PLATFORM_VITA) +#define DEFAULT_WINDOW_WIDTH 960 +#define DEFAULT_WINDOW_HEIGHT 544 +#else +#define DEFAULT_WINDOW_WIDTH 640 +#define DEFAULT_WINDOW_HEIGHT 480 +#endif + +typedef Uint32 SDLTest_VerboseFlags; +#define VERBOSE_VIDEO 0x00000001 +#define VERBOSE_MODES 0x00000002 +#define VERBOSE_RENDER 0x00000004 +#define VERBOSE_EVENT 0x00000008 +#define VERBOSE_AUDIO 0x00000010 +#define VERBOSE_MOTION 0x00000020 + +/* !< Function pointer parsing one argument at argv[index], returning the number of parsed arguments, + * or a negative value when the argument is invalid */ +typedef int (SDLCALL *SDLTest_ParseArgumentsFp)(void *data, char **argv, int index); + +/* !< Finalize the argument parser. */ +typedef void (SDLCALL *SDLTest_FinalizeArgumentParserFp)(void *arg); + +typedef struct SDLTest_ArgumentParser +{ + /* !< Parse an argument. */ + SDLTest_ParseArgumentsFp parse_arguments; + /* !< Finalize this argument parser. Called once before parsing the first argument. */ + SDLTest_FinalizeArgumentParserFp finalize; + /* !< Null-terminated array of arguments. Printed when running with --help. */ + const char **usage; + /* !< User data, passed to all callbacks. */ + void *data; + /* !< Next argument parser. */ + struct SDLTest_ArgumentParser *next; +} SDLTest_ArgumentParser; + +typedef struct +{ + /* SDL init flags */ + char **argv; + SDL_InitFlags flags; + SDLTest_VerboseFlags verbose; + + /* Video info */ + const char *videodriver; + int display_index; + SDL_DisplayID displayID; + const char *window_title; + const char *window_icon; + SDL_WindowFlags window_flags; + bool flash_on_focus_loss; + int window_x; + int window_y; + int window_w; + int window_h; + int window_minW; + int window_minH; + int window_maxW; + int window_maxH; + float window_min_aspect; + float window_max_aspect; + int logical_w; + int logical_h; + bool auto_scale_content; + SDL_RendererLogicalPresentation logical_presentation; + float scale; + int depth; + float refresh_rate; + bool fill_usable_bounds; + bool fullscreen_exclusive; + SDL_DisplayMode fullscreen_mode; + int num_windows; + SDL_Window **windows; + const char *gpudriver; + + /* Renderer info */ + const char *renderdriver; + int render_vsync; + bool skip_renderer; + SDL_Renderer **renderers; + SDL_Texture **targets; + + /* Audio info */ + const char *audiodriver; + SDL_AudioFormat audio_format; + int audio_channels; + int audio_freq; + SDL_AudioDeviceID audio_id; + + /* GL settings */ + int gl_red_size; + int gl_green_size; + int gl_blue_size; + int gl_alpha_size; + int gl_buffer_size; + int gl_depth_size; + int gl_stencil_size; + int gl_double_buffer; + int gl_accum_red_size; + int gl_accum_green_size; + int gl_accum_blue_size; + int gl_accum_alpha_size; + int gl_stereo; + int gl_release_behavior; + int gl_multisamplebuffers; + int gl_multisamplesamples; + int gl_retained_backing; + int gl_accelerated; + int gl_major_version; + int gl_minor_version; + int gl_debug; + int gl_profile_mask; + + /* Mouse info */ + SDL_Rect confine; + bool hide_cursor; + + /* Misc. */ + int quit_after_ms_interval; + SDL_TimerID quit_after_ms_timer; + + /* Options info */ + SDLTest_ArgumentParser common_argparser; + SDLTest_ArgumentParser video_argparser; + SDLTest_ArgumentParser audio_argparser; + + SDLTest_ArgumentParser *argparser; +} SDLTest_CommonState; + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Function prototypes */ + +/** + * Parse command line parameters and create common state. + * + * \param argv Array of command line parameters + * \param flags Flags indicating which subsystem to initialize (i.e. SDL_INIT_VIDEO | SDL_INIT_AUDIO) + * + * \returns a newly allocated common state object. + */ +SDLTest_CommonState * SDLCALL SDLTest_CommonCreateState(char **argv, SDL_InitFlags flags); + +/** + * Free the common state object. + * + * You should call SDL_Quit() before calling this function. + * + * \param state The common state object to destroy + */ +void SDLCALL SDLTest_CommonDestroyState(SDLTest_CommonState *state); + +/** + * Process one common argument. + * + * \param state The common state describing the test window to create. + * \param index The index of the argument to process in argv[]. + * + * \returns the number of arguments processed (i.e. 1 for --fullscreen, 2 for --video [videodriver], or -1 on error. + */ +int SDLCALL SDLTest_CommonArg(SDLTest_CommonState *state, int index); + + +/** + * Logs command line usage info. + * + * This logs the appropriate command line options for the subsystems in use + * plus other common options, and then any application-specific options. + * This uses the SDL_Log() function and splits up output to be friendly to + * 80-character-wide terminals. + * + * \param state The common state describing the test window for the app. + * \param argv0 argv[0], as passed to main/SDL_main. + * \param options an array of strings for application specific options. The last element of the array should be NULL. + */ +void SDLCALL SDLTest_CommonLogUsage(SDLTest_CommonState *state, const char *argv0, const char **options); + +/** + * Open test window. + * + * \param state The common state describing the test window to create. + * + * \returns true if initialization succeeded, false otherwise + */ +bool SDLCALL SDLTest_CommonInit(SDLTest_CommonState *state); + +/** + * Easy argument handling when test app doesn't need any custom args. + * + * \param state The common state describing the test window to create. + * \param argc argc, as supplied to SDL_main + * \param argv argv, as supplied to SDL_main + * + * \returns false if app should quit, true otherwise. + */ +bool SDLCALL SDLTest_CommonDefaultArgs(SDLTest_CommonState *state, int argc, char **argv); + +/** + * Print the details of an event. + * + * This is automatically called by SDLTest_CommonEvent() as needed. + * + * \param event The event to print. + */ +void SDLCALL SDLTest_PrintEvent(const SDL_Event *event); + +/** + * Common event handler for test windows if you use a standard SDL_main. + * + * \param state The common state used to create test window. + * \param event The event to handle. + * \param done Flag indicating we are done. + */ +void SDLCALL SDLTest_CommonEvent(SDLTest_CommonState *state, SDL_Event *event, int *done); + +/** + * Common event handler for test windows if you use SDL_AppEvent. + * + * This does _not_ free anything in `event`. + * + * \param state The common state used to create test window. + * \param event The event to handle. + * \returns Value suitable for returning from SDL_AppEvent(). + */ +SDL_AppResult SDLCALL SDLTest_CommonEventMainCallbacks(SDLTest_CommonState *state, const SDL_Event *event); + +/** + * Close test window. + * + * \param state The common state used to create test window. + * + */ +void SDLCALL SDLTest_CommonQuit(SDLTest_CommonState *state); + +/** + * Draws various window information (position, size, etc.) to the renderer. + * + * \param renderer The renderer to draw to. + * \param window The window whose information should be displayed. + * \param usedHeight Returns the height used, so the caller can draw more below. + * + */ +void SDLCALL SDLTest_CommonDrawWindowInfo(SDL_Renderer *renderer, SDL_Window *window, float *usedHeight); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_test_common_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_test_compare.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_test_compare.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,77 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * Comparison function of SDL test framework. + * + * This code is a part of the SDL test library, not the main SDL library. + */ + +/* + + Defines comparison functions (i.e. for surfaces). + +*/ + +#ifndef SDL_test_compare_h_ +#define SDL_test_compare_h_ + +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Compares a surface and with reference image data for equality + * + * \param surface Surface used in comparison + * \param referenceSurface Test Surface used in comparison + * \param allowable_error Allowable difference (=sum of squared difference for each RGB component) in blending accuracy. + * + * \returns 0 if comparison succeeded, >0 (=number of pixels for which the comparison failed) if comparison failed, -1 if any of the surfaces were NULL, -2 if the surface sizes differ. + */ +int SDLCALL SDLTest_CompareSurfaces(SDL_Surface *surface, SDL_Surface *referenceSurface, int allowable_error); +int SDLCALL SDLTest_CompareSurfacesIgnoreTransparentPixels(SDL_Surface *surface, SDL_Surface *referenceSurface, int allowable_error); + +/** + * Compares 2 memory blocks for equality + * + * \param actual Memory used in comparison, displayed on the left + * \param size_actual Size of actual in bytes + * \param reference Reference memory, displayed on the right + * \param size_reference Size of reference in bytes + * + * \returns 0 if the left and right memory block are equal, non-zero if they are non-equal. + * + * \since This function is available since SDL 3.2.0. + */ +int SDLCALL SDLTest_CompareMemory(const void *actual, size_t size_actual, const void *reference, size_t size_reference); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_test_compare_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_test_crc32.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_test_crc32.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,121 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * CRC32 functions of SDL test framework. + * + * This code is a part of the SDL test library, not the main SDL library. + */ + +/* + + Implements CRC32 calculations (default output is Perl String::CRC32 compatible). + +*/ + +#ifndef SDL_test_crc32_h_ +#define SDL_test_crc32_h_ + +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* ------------ Definitions --------- */ + +/* Definition shared by all CRC routines */ + +#ifndef CrcUint32 + #define CrcUint32 unsigned int +#endif +#ifndef CrcUint8 + #define CrcUint8 unsigned char +#endif + +#ifdef ORIGINAL_METHOD + #define CRC32_POLY 0x04c11db7 /* AUTODIN II, Ethernet, & FDDI */ +#else + #define CRC32_POLY 0xEDB88320 /* Perl String::CRC32 compatible */ +#endif + +/* + * Data structure for CRC32 (checksum) computation + */ + typedef struct SDLTest_Crc32Context { + CrcUint32 crc32_table[256]; /* CRC table */ + } SDLTest_Crc32Context; + +/* ---------- Function Prototypes ------------- */ + +/* + * Initialize the CRC context + * + * Note: The function initializes the crc table required for all crc calculations. + * + * \param crcContext pointer to context variable + * + * \returns true on success or false on failure; call SDL_GetError() + * for more information. + * + */ +bool SDLCALL SDLTest_Crc32Init(SDLTest_Crc32Context *crcContext); + +/* + * calculate a crc32 from a data block + * + * \param crcContext pointer to context variable + * \param inBuf input buffer to checksum + * \param inLen length of input buffer + * \param crc32 pointer to Uint32 to store the final CRC into + * + * \returns true on success or false on failure; call SDL_GetError() + * for more information. + * + */ +bool SDLCALL SDLTest_Crc32Calc(SDLTest_Crc32Context *crcContext, CrcUint8 *inBuf, CrcUint32 inLen, CrcUint32 *crc32); + +/* Same routine broken down into three steps */ +bool SDLCALL SDLTest_Crc32CalcStart(SDLTest_Crc32Context *crcContext, CrcUint32 *crc32); +bool SDLCALL SDLTest_Crc32CalcEnd(SDLTest_Crc32Context *crcContext, CrcUint32 *crc32); +bool SDLCALL SDLTest_Crc32CalcBuffer(SDLTest_Crc32Context *crcContext, CrcUint8 *inBuf, CrcUint32 inLen, CrcUint32 *crc32); + +/* + * clean up CRC context + * + * \param crcContext pointer to context variable + * + * \returns true on success or false on failure; call SDL_GetError() + * for more information. + * +*/ + +bool SDLCALL SDLTest_Crc32Done(SDLTest_Crc32Context *crcContext); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_test_crc32_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_test_font.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_test_font.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,169 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* + * Font related functions of SDL test framework. + * + * This code is a part of the SDL test library, not the main SDL library. + */ + +#ifndef SDL_test_font_h_ +#define SDL_test_font_h_ + +#include +#include +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Function prototypes */ + +extern int FONT_CHARACTER_SIZE; + +#define FONT_LINE_HEIGHT (FONT_CHARACTER_SIZE + 2) + +/* + * Draw a string in the currently set font. + * + * \param renderer The renderer to draw on. + * \param x The X coordinate of the upper left corner of the character. + * \param y The Y coordinate of the upper left corner of the character. + * \param c The character to draw. + * + * \returns true on success, false on failure. + */ +bool SDLCALL SDLTest_DrawCharacter(SDL_Renderer *renderer, float x, float y, Uint32 c); + +/* + * Draw a UTF-8 string in the currently set font. + * + * The font currently only supports characters in the Basic Latin and Latin-1 Supplement sets. + * + * \param renderer The renderer to draw on. + * \param x The X coordinate of the upper left corner of the string. + * \param y The Y coordinate of the upper left corner of the string. + * \param s The string to draw. + * + * \returns true on success, false on failure. + */ +bool SDLCALL SDLTest_DrawString(SDL_Renderer *renderer, float x, float y, const char *s); + +/* + * Data used for multi-line text output + */ +typedef struct SDLTest_TextWindow +{ + SDL_FRect rect; + int current; + int numlines; + char **lines; +} SDLTest_TextWindow; + +/* + * Create a multi-line text output window + * + * \param x The X coordinate of the upper left corner of the window. + * \param y The Y coordinate of the upper left corner of the window. + * \param w The width of the window (currently ignored) + * \param h The height of the window (currently ignored) + * + * \returns the new window, or NULL on failure. + * + * \since This function is available since SDL 3.2.0. + */ +SDLTest_TextWindow * SDLCALL SDLTest_TextWindowCreate(float x, float y, float w, float h); + +/* + * Display a multi-line text output window + * + * This function should be called every frame to display the text + * + * \param textwin The text output window + * \param renderer The renderer to use for display + * + * \since This function is available since SDL 3.2.0. + */ +void SDLCALL SDLTest_TextWindowDisplay(SDLTest_TextWindow *textwin, SDL_Renderer *renderer); + +/* + * Add text to a multi-line text output window + * + * Adds UTF-8 text to the end of the current text. The newline character starts a + * new line of text. The backspace character deletes the last character or, if the + * line is empty, deletes the line and goes to the end of the previous line. + * + * \param textwin The text output window + * \param fmt A printf() style format string + * \param ... additional parameters matching % tokens in the `fmt` string, if any + * + * \since This function is available since SDL 3.2.0. + */ +void SDLCALL SDLTest_TextWindowAddText(SDLTest_TextWindow *textwin, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); + +/* + * Add text to a multi-line text output window + * + * Adds UTF-8 text to the end of the current text. The newline character starts a + * new line of text. The backspace character deletes the last character or, if the + * line is empty, deletes the line and goes to the end of the previous line. + * + * \param textwin The text output window + * \param text The text to add to the window + * \param len The length, in bytes, of the text to add to the window + * + * \since This function is available since SDL 3.2.0. + */ +void SDLCALL SDLTest_TextWindowAddTextWithLength(SDLTest_TextWindow *textwin, const char *text, size_t len); + +/* + * Clear the text in a multi-line text output window + * + * \param textwin The text output window + * + * \since This function is available since SDL 3.2.0. + */ +void SDLCALL SDLTest_TextWindowClear(SDLTest_TextWindow *textwin); + +/* + * Free the storage associated with a multi-line text output window + * + * \param textwin The text output window + * + * \since This function is available since SDL 3.2.0. + */ +void SDLCALL SDLTest_TextWindowDestroy(SDLTest_TextWindow *textwin); + +/* + * Cleanup textures used by font drawing functions. + */ +void SDLCALL SDLTest_CleanupTextDrawing(void); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_test_font_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_test_fuzzer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_test_fuzzer.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,371 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * Fuzzer functions of SDL test framework. + * + * This code is a part of the SDL test library, not the main SDL library. + */ + +/* + + Data generators for fuzzing test data in a reproducible way. + +*/ + +#ifndef SDL_test_fuzzer_h_ +#define SDL_test_fuzzer_h_ + +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* + Based on GSOC code by Markus Kauppila +*/ + +/** + * Note: The fuzzer implementation uses a static instance of random context + * internally which makes it thread-UNsafe. + */ + +/** + * Initializes the fuzzer for a test + * + * \param execKey Execution "Key" that initializes the random number generator uniquely for the test. + * + */ +void SDLCALL SDLTest_FuzzerInit(Uint64 execKey); + +/** + * Returns a random Uint8 + * + * \returns a generated integer + */ +Uint8 SDLCALL SDLTest_RandomUint8(void); + +/** + * Returns a random Sint8 + * + * \returns a generated signed integer + */ +Sint8 SDLCALL SDLTest_RandomSint8(void); + +/** + * Returns a random Uint16 + * + * \returns a generated integer + */ +Uint16 SDLCALL SDLTest_RandomUint16(void); + +/** + * Returns a random Sint16 + * + * \returns a generated signed integer + */ +Sint16 SDLCALL SDLTest_RandomSint16(void); + +/** + * Returns a random integer + * + * \returns a generated integer + */ +Sint32 SDLCALL SDLTest_RandomSint32(void); + +/** + * Returns a random positive integer + * + * \returns a generated integer + */ +Uint32 SDLCALL SDLTest_RandomUint32(void); + +/** + * Returns random Uint64. + * + * \returns a generated integer + */ +Uint64 SDLTest_RandomUint64(void); + +/** + * Returns random Sint64. + * + * \returns a generated signed integer + */ +Sint64 SDLCALL SDLTest_RandomSint64(void); + +/** + * \returns a random float in range [0.0 - 1.0] + */ +float SDLCALL SDLTest_RandomUnitFloat(void); + +/** + * \returns a random double in range [0.0 - 1.0] + */ +double SDLCALL SDLTest_RandomUnitDouble(void); + +/** + * \returns a random float. + * + */ +float SDLCALL SDLTest_RandomFloat(void); + +/** + * \returns a random double. + * + */ +double SDLCALL SDLTest_RandomDouble(void); + +/** + * Returns a random boundary value for Uint8 within the given boundaries. + * Boundaries are inclusive, see the usage examples below. If validDomain + * is true, the function will only return valid boundaries, otherwise non-valid + * boundaries are also possible. + * If boundary1 > boundary2, the values are swapped + * + * Usage examples: + * RandomUint8BoundaryValue(10, 20, true) returns 10, 11, 19 or 20 + * RandomUint8BoundaryValue(1, 20, false) returns 0 or 21 + * RandomUint8BoundaryValue(0, 99, false) returns 100 + * RandomUint8BoundaryValue(0, 255, false) returns 0 (error set) + * + * \param boundary1 Lower boundary limit + * \param boundary2 Upper boundary limit + * \param validDomain Should the generated boundary be valid (=within the bounds) or not? + * + * \returns a random boundary value for the given range and domain or 0 with error set + */ +Uint8 SDLCALL SDLTest_RandomUint8BoundaryValue(Uint8 boundary1, Uint8 boundary2, bool validDomain); + +/** + * Returns a random boundary value for Uint16 within the given boundaries. + * Boundaries are inclusive, see the usage examples below. If validDomain + * is true, the function will only return valid boundaries, otherwise non-valid + * boundaries are also possible. + * If boundary1 > boundary2, the values are swapped + * + * Usage examples: + * RandomUint16BoundaryValue(10, 20, true) returns 10, 11, 19 or 20 + * RandomUint16BoundaryValue(1, 20, false) returns 0 or 21 + * RandomUint16BoundaryValue(0, 99, false) returns 100 + * RandomUint16BoundaryValue(0, 0xFFFF, false) returns 0 (error set) + * + * \param boundary1 Lower boundary limit + * \param boundary2 Upper boundary limit + * \param validDomain Should the generated boundary be valid (=within the bounds) or not? + * + * \returns a random boundary value for the given range and domain or 0 with error set + */ +Uint16 SDLCALL SDLTest_RandomUint16BoundaryValue(Uint16 boundary1, Uint16 boundary2, bool validDomain); + +/** + * Returns a random boundary value for Uint32 within the given boundaries. + * Boundaries are inclusive, see the usage examples below. If validDomain + * is true, the function will only return valid boundaries, otherwise non-valid + * boundaries are also possible. + * If boundary1 > boundary2, the values are swapped + * + * Usage examples: + * RandomUint32BoundaryValue(10, 20, true) returns 10, 11, 19 or 20 + * RandomUint32BoundaryValue(1, 20, false) returns 0 or 21 + * RandomUint32BoundaryValue(0, 99, false) returns 100 + * RandomUint32BoundaryValue(0, 0xFFFFFFFF, false) returns 0 (with error set) + * + * \param boundary1 Lower boundary limit + * \param boundary2 Upper boundary limit + * \param validDomain Should the generated boundary be valid (=within the bounds) or not? + * + * \returns a random boundary value for the given range and domain or 0 with error set + */ +Uint32 SDLCALL SDLTest_RandomUint32BoundaryValue(Uint32 boundary1, Uint32 boundary2, bool validDomain); + +/** + * Returns a random boundary value for Uint64 within the given boundaries. + * Boundaries are inclusive, see the usage examples below. If validDomain + * is true, the function will only return valid boundaries, otherwise non-valid + * boundaries are also possible. + * If boundary1 > boundary2, the values are swapped + * + * Usage examples: + * RandomUint64BoundaryValue(10, 20, true) returns 10, 11, 19 or 20 + * RandomUint64BoundaryValue(1, 20, false) returns 0 or 21 + * RandomUint64BoundaryValue(0, 99, false) returns 100 + * RandomUint64BoundaryValue(0, 0xFFFFFFFFFFFFFFFF, false) returns 0 (with error set) + * + * \param boundary1 Lower boundary limit + * \param boundary2 Upper boundary limit + * \param validDomain Should the generated boundary be valid (=within the bounds) or not? + * + * \returns a random boundary value for the given range and domain or 0 with error set + */ +Uint64 SDLCALL SDLTest_RandomUint64BoundaryValue(Uint64 boundary1, Uint64 boundary2, bool validDomain); + +/** + * Returns a random boundary value for Sint8 within the given boundaries. + * Boundaries are inclusive, see the usage examples below. If validDomain + * is true, the function will only return valid boundaries, otherwise non-valid + * boundaries are also possible. + * If boundary1 > boundary2, the values are swapped + * + * Usage examples: + * RandomSint8BoundaryValue(-10, 20, true) returns -11, -10, 19 or 20 + * RandomSint8BoundaryValue(-100, -10, false) returns -101 or -9 + * RandomSint8BoundaryValue(SINT8_MIN, 99, false) returns 100 + * RandomSint8BoundaryValue(SINT8_MIN, SINT8_MAX, false) returns SINT8_MIN (== error value) with error set + * + * \param boundary1 Lower boundary limit + * \param boundary2 Upper boundary limit + * \param validDomain Should the generated boundary be valid (=within the bounds) or not? + * + * \returns a random boundary value for the given range and domain or SINT8_MIN with error set + */ +Sint8 SDLCALL SDLTest_RandomSint8BoundaryValue(Sint8 boundary1, Sint8 boundary2, bool validDomain); + +/** + * Returns a random boundary value for Sint16 within the given boundaries. + * Boundaries are inclusive, see the usage examples below. If validDomain + * is true, the function will only return valid boundaries, otherwise non-valid + * boundaries are also possible. + * If boundary1 > boundary2, the values are swapped + * + * Usage examples: + * RandomSint16BoundaryValue(-10, 20, true) returns -11, -10, 19 or 20 + * RandomSint16BoundaryValue(-100, -10, false) returns -101 or -9 + * RandomSint16BoundaryValue(SINT16_MIN, 99, false) returns 100 + * RandomSint16BoundaryValue(SINT16_MIN, SINT16_MAX, false) returns SINT16_MIN (== error value) with error set + * + * \param boundary1 Lower boundary limit + * \param boundary2 Upper boundary limit + * \param validDomain Should the generated boundary be valid (=within the bounds) or not? + * + * \returns a random boundary value for the given range and domain or SINT16_MIN with error set + */ +Sint16 SDLCALL SDLTest_RandomSint16BoundaryValue(Sint16 boundary1, Sint16 boundary2, bool validDomain); + +/** + * Returns a random boundary value for Sint32 within the given boundaries. + * Boundaries are inclusive, see the usage examples below. If validDomain + * is true, the function will only return valid boundaries, otherwise non-valid + * boundaries are also possible. + * If boundary1 > boundary2, the values are swapped + * + * Usage examples: + * RandomSint32BoundaryValue(-10, 20, true) returns -11, -10, 19 or 20 + * RandomSint32BoundaryValue(-100, -10, false) returns -101 or -9 + * RandomSint32BoundaryValue(SINT32_MIN, 99, false) returns 100 + * RandomSint32BoundaryValue(SINT32_MIN, SINT32_MAX, false) returns SINT32_MIN (== error value) + * + * \param boundary1 Lower boundary limit + * \param boundary2 Upper boundary limit + * \param validDomain Should the generated boundary be valid (=within the bounds) or not? + * + * \returns a random boundary value for the given range and domain or SINT32_MIN with error set + */ +Sint32 SDLCALL SDLTest_RandomSint32BoundaryValue(Sint32 boundary1, Sint32 boundary2, bool validDomain); + +/** + * Returns a random boundary value for Sint64 within the given boundaries. + * Boundaries are inclusive, see the usage examples below. If validDomain + * is true, the function will only return valid boundaries, otherwise non-valid + * boundaries are also possible. + * If boundary1 > boundary2, the values are swapped + * + * Usage examples: + * RandomSint64BoundaryValue(-10, 20, true) returns -11, -10, 19 or 20 + * RandomSint64BoundaryValue(-100, -10, false) returns -101 or -9 + * RandomSint64BoundaryValue(SINT64_MIN, 99, false) returns 100 + * RandomSint64BoundaryValue(SINT64_MIN, SINT64_MAX, false) returns SINT64_MIN (== error value) and error set + * + * \param boundary1 Lower boundary limit + * \param boundary2 Upper boundary limit + * \param validDomain Should the generated boundary be valid (=within the bounds) or not? + * + * \returns a random boundary value for the given range and domain or SINT64_MIN with error set + */ +Sint64 SDLCALL SDLTest_RandomSint64BoundaryValue(Sint64 boundary1, Sint64 boundary2, bool validDomain); + +/** + * Returns integer in range [min, max] (inclusive). + * Min and max values can be negative values. + * If Max in smaller than min, then the values are swapped. + * Min and max are the same value, that value will be returned. + * + * \param min Minimum inclusive value of returned random number + * \param max Maximum inclusive value of returned random number + * + * \returns a generated random integer in range + */ +Sint32 SDLCALL SDLTest_RandomIntegerInRange(Sint32 min, Sint32 max); + +/** + * Generates random null-terminated string. The minimum length for + * the string is 1 character, maximum length for the string is 255 + * characters and it can contain ASCII characters from 32 to 126. + * + * Note: Returned string needs to be deallocated. + * + * \returns a newly allocated random string; or NULL if length was invalid or string could not be allocated. + */ +char * SDLCALL SDLTest_RandomAsciiString(void); + +/** + * Generates random null-terminated string. The maximum length for + * the string is defined by the maxLength parameter. + * String can contain ASCII characters from 32 to 126. + * + * Note: Returned string needs to be deallocated. + * + * \param maxLength The maximum length of the generated string. + * + * \returns a newly allocated random string; or NULL if maxLength was invalid or string could not be allocated. + */ +char * SDLCALL SDLTest_RandomAsciiStringWithMaximumLength(int maxLength); + +/** + * Generates random null-terminated string. The length for + * the string is defined by the size parameter. + * String can contain ASCII characters from 32 to 126. + * + * Note: Returned string needs to be deallocated. + * + * \param size The length of the generated string + * + * \returns a newly allocated random string; or NULL if size was invalid or string could not be allocated. + */ +char * SDLCALL SDLTest_RandomAsciiStringOfSize(int size); + +/** + * Get the invocation count for the fuzzer since last ...FuzzerInit. + * + * \returns the invocation count. + */ +int SDLCALL SDLTest_GetFuzzerInvocationCount(void); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_test_fuzzer_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_test_harness.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_test_harness.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,151 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * Test suite related functions of SDL test framework. + * + * This code is a part of the SDL test library, not the main SDL library. + */ + +/* + Defines types for test case definitions and the test execution harness API. + + Based on original GSOC code by Markus Kauppila +*/ + +#ifndef SDL_test_h_arness_h +#define SDL_test_h_arness_h + +#include +#include /* SDLTest_CommonState */ + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* ! Definitions for test case structures */ +#define TEST_ENABLED 1 +#define TEST_DISABLED 0 + +/* ! Definition of all the possible test return values of the test case method */ +#define TEST_ABORTED -1 +#define TEST_STARTED 0 +#define TEST_COMPLETED 1 +#define TEST_SKIPPED 2 + +/* ! Definition of all the possible test results for the harness */ +#define TEST_RESULT_PASSED 0 +#define TEST_RESULT_FAILED 1 +#define TEST_RESULT_NO_ASSERT 2 +#define TEST_RESULT_SKIPPED 3 +#define TEST_RESULT_SETUP_FAILURE 4 + +/* !< Function pointer to a test case setup function (run before every test) */ +typedef void (SDLCALL *SDLTest_TestCaseSetUpFp)(void **arg); + +/* !< Function pointer to a test case function */ +typedef int (SDLCALL *SDLTest_TestCaseFp)(void *arg); + +/* !< Function pointer to a test case teardown function (run after every test) */ +typedef void (SDLCALL *SDLTest_TestCaseTearDownFp)(void *arg); + +/* + * Holds information about a single test case. + */ +typedef struct SDLTest_TestCaseReference { + /* !< Func2Stress */ + SDLTest_TestCaseFp testCase; + /* !< Short name (or function name) "Func2Stress" */ + const char *name; + /* !< Long name or full description "This test pushes func2() to the limit." */ + const char *description; + /* !< Set to TEST_ENABLED or TEST_DISABLED (test won't be run) */ + int enabled; +} SDLTest_TestCaseReference; + +/* + * Holds information about a test suite (multiple test cases). + */ +typedef struct SDLTest_TestSuiteReference { + /* !< "PlatformSuite" */ + const char *name; + /* !< The function that is run before each test. NULL skips. */ + SDLTest_TestCaseSetUpFp testSetUp; + /* !< The test cases that are run as part of the suite. Last item should be NULL. */ + const SDLTest_TestCaseReference **testCases; + /* !< The function that is run after each test. NULL skips. */ + SDLTest_TestCaseTearDownFp testTearDown; +} SDLTest_TestSuiteReference; + + +/* + * Generates a random run seed string for the harness. The generated seed + * will contain alphanumeric characters (0-9A-Z). + * + * \param buffer Buffer in which to generate the random seed. Must have a capacity of at least length + 1 characters. + * \param length Number of alphanumeric characters to write to buffer, must be >0 + * + * \returns A null-terminated seed string and equal to the in put buffer on success, NULL on failure + */ +char * SDLCALL SDLTest_GenerateRunSeed(char *buffer, int length); + +/* + * Holds information about the execution of test suites. + * */ +typedef struct SDLTest_TestSuiteRunner SDLTest_TestSuiteRunner; + +/* + * Create a new test suite runner, that will execute the given test suites. + * It will register the harness cli arguments to the common SDL state. + * + * \param state Common SDL state on which to register CLI arguments. + * \param testSuites NULL-terminated test suites containing test cases. + * + * \returns the test run result: 0 when all tests passed, 1 if any tests failed. + */ +SDLTest_TestSuiteRunner * SDLCALL SDLTest_CreateTestSuiteRunner(SDLTest_CommonState *state, SDLTest_TestSuiteReference *testSuites[]); + +/* + * Destroy a test suite runner. + * It will unregister the harness cli arguments to the common SDL state. + * + * \param runner The runner that should be destroyed. + */ +void SDLCALL SDLTest_DestroyTestSuiteRunner(SDLTest_TestSuiteRunner *runner); + +/* + * Execute a test suite, using the configured run seed, execution key, filter, etc. + * + * \param runner The runner that should be executed. + * + * \returns the test run result: 0 when all tests passed, 1 if any tests failed. + */ +int SDLCALL SDLTest_ExecuteTestSuiteRunner(SDLTest_TestSuiteRunner *runner); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_test_h_arness_h */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_test_log.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_test_log.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,83 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * Logging related functions of SDL test framework. + * + * This code is a part of the SDL test library, not the main SDL library. + */ + +/* + * + * Wrapper to log in the TEST category + * + */ + +#ifndef SDL_test_log_h_ +#define SDL_test_log_h_ + +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Prints given message with a timestamp in the TEST category and given priority. + * + * \param priority Priority of the message + * \param fmt Message to be logged + */ +void SDLCALL SDLTest_LogMessage(SDL_LogPriority priority, SDL_PRINTF_FORMAT_STRING const char *fmt, ...); + +/** + * Prints given message with a timestamp in the TEST category and INFO priority. + * + * \param fmt Message to be logged + */ +void SDLCALL SDLTest_Log(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1); + +/** + * Prints given prefix and buffer. + * Non-printible characters in the raw data are substituted by printible alternatives. + * + * \param prefix Prefix message. + * \param buffer Raw data to be escaped. + * \param size Number of bytes in buffer. + */ +void SDLCALL SDLTest_LogEscapedString(const char *prefix, const void *buffer, size_t size); + +/** + * Prints given message with a timestamp in the TEST category and the ERROR priority. + * + * \param fmt Message to be logged + */ +void SDLCALL SDLTest_LogError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_test_log_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_test_md5.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_test_md5.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,122 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * MD5 related functions of SDL test framework. + * + * This code is a part of the SDL test library, not the main SDL library. + */ + +/* + *********************************************************************** + ** Header file for implementation of MD5 ** + ** RSA Data Security, Inc. MD5 Message-Digest Algorithm ** + ** Created: 2/17/90 RLR ** + ** Revised: 12/27/90 SRD,AJ,BSK,JT Reference C version ** + ** Revised (for MD5): RLR 4/27/91 ** + ** -- G modified to have y&~z instead of y&z ** + ** -- FF, GG, HH modified to add in last register done ** + ** -- Access pattern: round 2 works mod 5, round 3 works mod 3 ** + ** -- distinct additive constant for each step ** + ** -- round 4 added, working mod 7 ** + *********************************************************************** +*/ + +/* + *********************************************************************** + ** Message-digest routines: ** + ** To form the message digest for a message M ** + ** (1) Initialize a context buffer mdContext using MD5Init ** + ** (2) Call MD5Update on mdContext and M ** + ** (3) Call MD5Final on mdContext ** + ** The message digest is now in mdContext->digest[0...15] ** + *********************************************************************** +*/ + +#ifndef SDL_test_md5_h_ +#define SDL_test_md5_h_ + +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* ------------ Definitions --------- */ + +/* typedef a 32-bit type */ +typedef Uint32 MD5UINT4; + +/* Data structure for MD5 (Message-Digest) computation */ +typedef struct SDLTest_Md5Context { + MD5UINT4 i[2]; /* number of _bits_ handled mod 2^64 */ + MD5UINT4 buf[4]; /* scratch buffer */ + unsigned char in[64]; /* input buffer */ + unsigned char digest[16]; /* actual digest after Md5Final call */ +} SDLTest_Md5Context; + +/* ---------- Function Prototypes ------------- */ + +/** + * initialize the context + * + * \param mdContext pointer to context variable + * + * Note: The function initializes the message-digest context + * mdContext. Call before each new use of the context - + * all fields are set to zero. + */ +void SDLCALL SDLTest_Md5Init(SDLTest_Md5Context *mdContext); + +/** + * update digest from variable length data + * + * \param mdContext pointer to context variable + * \param inBuf pointer to data array/string + * \param inLen length of data array/string + * + * Note: The function updates the message-digest context to account + * for the presence of each of the characters inBuf[0..inLen-1] + * in the message whose digest is being computed. + */ +void SDLCALL SDLTest_Md5Update(SDLTest_Md5Context *mdContext, unsigned char *inBuf, + unsigned int inLen); + +/** + * complete digest computation + * + * \param mdContext pointer to context variable + * + * Note: The function terminates the message-digest computation and + * ends with the desired message digest in mdContext.digest[0..15]. + * Always call before using the digest[] variable. + */ +void SDLCALL SDLTest_Md5Final(SDLTest_Md5Context *mdContext); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_test_md5_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_test_memory.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_test_memory.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,66 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * Memory tracking related functions of SDL test framework. + * + * This code is a part of the SDL test library, not the main SDL library. + */ + +#ifndef SDL_test_memory_h_ +#define SDL_test_memory_h_ + +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Start tracking SDL memory allocations + * + * \note This should be called before any other SDL functions for complete tracking coverage + */ +void SDLCALL SDLTest_TrackAllocations(void); + +/** + * Fill allocations with random data + * + * \note This implicitly calls SDLTest_TrackAllocations() + */ +void SDLCALL SDLTest_RandFillAllocations(void); + +/** + * Print a log of any outstanding allocations + * + * \note This can be called after SDL_Quit() + */ +void SDLCALL SDLTest_LogAllocations(void); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_test_memory_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_thread.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_thread.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,579 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_thread_h_ +#define SDL_thread_h_ + +/** + * # CategoryThread + * + * SDL offers cross-platform thread management functions. These are mostly + * concerned with starting threads, setting their priority, and dealing with + * their termination. + * + * In addition, there is support for Thread Local Storage (data that is unique + * to each thread, but accessed from a single key). + * + * On platforms without thread support (such as Emscripten when built without + * pthreads), these functions still exist, but things like SDL_CreateThread() + * will report failure without doing anything. + * + * If you're going to work with threads, you almost certainly need to have a + * good understanding of thread safety measures: locking and synchronization + * mechanisms are handled by the functions in SDL_mutex.h. + */ + +#include +#include +#include + +/* Thread synchronization primitives */ +#include + +#if defined(SDL_PLATFORM_WINDOWS) +#include /* _beginthreadex() and _endthreadex() */ +#endif + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * The SDL thread object. + * + * These are opaque data. + * + * \since This datatype is available since SDL 3.2.0. + * + * \sa SDL_CreateThread + * \sa SDL_WaitThread + */ +typedef struct SDL_Thread SDL_Thread; + +/** + * A unique numeric ID that identifies a thread. + * + * These are different from SDL_Thread objects, which are generally what an + * application will operate on, but having a way to uniquely identify a thread + * can be useful at times. + * + * \since This datatype is available since SDL 3.2.0. + * + * \sa SDL_GetThreadID + * \sa SDL_GetCurrentThreadID + */ +typedef Uint64 SDL_ThreadID; + +/** + * Thread local storage ID. + * + * 0 is the invalid ID. An app can create these and then set data for these + * IDs that is unique to each thread. + * + * \since This datatype is available since SDL 3.2.0. + * + * \sa SDL_GetTLS + * \sa SDL_SetTLS + */ +typedef SDL_AtomicInt SDL_TLSID; + +/** + * The SDL thread priority. + * + * SDL will make system changes as necessary in order to apply the thread + * priority. Code which attempts to control thread state related to priority + * should be aware that calling SDL_SetCurrentThreadPriority may alter such + * state. SDL_HINT_THREAD_PRIORITY_POLICY can be used to control aspects of + * this behavior. + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_ThreadPriority { + SDL_THREAD_PRIORITY_LOW, + SDL_THREAD_PRIORITY_NORMAL, + SDL_THREAD_PRIORITY_HIGH, + SDL_THREAD_PRIORITY_TIME_CRITICAL +} SDL_ThreadPriority; + +/** + * The SDL thread state. + * + * The current state of a thread can be checked by calling SDL_GetThreadState. + * + * \since This enum is available since SDL 3.2.0. + * + * \sa SDL_GetThreadState + */ +typedef enum SDL_ThreadState +{ + SDL_THREAD_UNKNOWN, /**< The thread is not valid */ + SDL_THREAD_ALIVE, /**< The thread is currently running */ + SDL_THREAD_DETACHED, /**< The thread is detached and can't be waited on */ + SDL_THREAD_COMPLETE /**< The thread has finished and should be cleaned up with SDL_WaitThread() */ +} SDL_ThreadState; + +/** + * The function passed to SDL_CreateThread() as the new thread's entry point. + * + * \param data what was passed as `data` to SDL_CreateThread(). + * \returns a value that can be reported through SDL_WaitThread(). + * + * \since This datatype is available since SDL 3.2.0. + */ +typedef int (SDLCALL *SDL_ThreadFunction) (void *data); + + +#ifdef SDL_WIKI_DOCUMENTATION_SECTION + +/* + * Note that these aren't the correct function signatures in this block, but + * this is what the API reference manual should look like for all intents and + * purposes. + * + * Technical details, not for the wiki (hello, header readers!)... + * + * On Windows (and maybe other platforms), a program might use a different + * C runtime than its libraries. Or, in SDL's case, it might use a C runtime + * while SDL uses none at all. + * + * C runtimes expect to initialize thread-specific details when a new thread + * is created, but to do this in SDL_CreateThread would require SDL to know + * intimate details about the caller's C runtime, which is not possible. + * + * So SDL_CreateThread has two extra parameters, which are + * hidden at compile time by macros: the C runtime's `_beginthreadex` and + * `_endthreadex` entry points. If these are not NULL, they are used to spin + * and terminate the new thread; otherwise the standard Win32 `CreateThread` + * function is used. When `SDL_CreateThread` is called from a compiler that + * needs this C runtime thread init function, macros insert the appropriate + * function pointers for SDL_CreateThread's caller (which might be a different + * compiler with a different runtime in different calls to SDL_CreateThread!). + * + * SDL_BeginThreadFunction defaults to `_beginthreadex` on Windows (and NULL + * everywhere else), but apps that have extremely specific special needs can + * define this to something else and the SDL headers will use it, passing the + * app-defined value to SDL_CreateThread calls. Redefine this with caution! + * + * Platforms that don't need _beginthread stuff (most everything) will fail + * SDL_CreateThread with an error if these pointers _aren't_ NULL. + * + * Unless you are doing something extremely complicated, like perhaps a + * language binding, **you should never deal with this directly**. Let SDL's + * macros handle this platform-specific detail transparently! + */ + +/** + * Create a new thread with a default stack size. + * + * This is a convenience function, equivalent to calling + * SDL_CreateThreadWithProperties with the following properties set: + * + * - `SDL_PROP_THREAD_CREATE_ENTRY_FUNCTION_POINTER`: `fn` + * - `SDL_PROP_THREAD_CREATE_NAME_STRING`: `name` + * - `SDL_PROP_THREAD_CREATE_USERDATA_POINTER`: `data` + * + * Note that this "function" is actually a macro that calls an internal + * function with two extra parameters not listed here; they are hidden through + * preprocessor macros and are needed to support various C runtimes at the + * point of the function call. Language bindings that aren't using the C + * headers will need to deal with this. + * + * Usually, apps should just call this function the same way on every platform + * and let the macros hide the details. + * + * \param fn the SDL_ThreadFunction function to call in the new thread. + * \param name the name of the thread. + * \param data a pointer that is passed to `fn`. + * \returns an opaque pointer to the new thread object on success, NULL if the + * new thread could not be created; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateThreadWithProperties + * \sa SDL_WaitThread + */ +extern SDL_DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data); + +/** + * Create a new thread with with the specified properties. + * + * These are the supported properties: + * + * - `SDL_PROP_THREAD_CREATE_ENTRY_FUNCTION_POINTER`: an SDL_ThreadFunction + * value that will be called at the start of the new thread's life. + * Required. + * - `SDL_PROP_THREAD_CREATE_NAME_STRING`: the name of the new thread, which + * might be available to debuggers. Optional, defaults to NULL. + * - `SDL_PROP_THREAD_CREATE_USERDATA_POINTER`: an arbitrary app-defined + * pointer, which is passed to the entry function on the new thread, as its + * only parameter. Optional, defaults to NULL. + * - `SDL_PROP_THREAD_CREATE_STACKSIZE_NUMBER`: the size, in bytes, of the new + * thread's stack. Optional, defaults to 0 (system-defined default). + * + * SDL makes an attempt to report `SDL_PROP_THREAD_CREATE_NAME_STRING` to the + * system, so that debuggers can display it. Not all platforms support this. + * + * Thread naming is a little complicated: Most systems have very small limits + * for the string length (Haiku has 32 bytes, Linux currently has 16, Visual + * C++ 6.0 has _nine_!), and possibly other arbitrary rules. You'll have to + * see what happens with your system's debugger. The name should be UTF-8 (but + * using the naming limits of C identifiers is a better bet). There are no + * requirements for thread naming conventions, so long as the string is + * null-terminated UTF-8, but these guidelines are helpful in choosing a name: + * + * https://stackoverflow.com/questions/149932/naming-conventions-for-threads + * + * If a system imposes requirements, SDL will try to munge the string for it + * (truncate, etc), but the original string contents will be available from + * SDL_GetThreadName(). + * + * The size (in bytes) of the new stack can be specified with + * `SDL_PROP_THREAD_CREATE_STACKSIZE_NUMBER`. Zero means "use the system + * default" which might be wildly different between platforms. x86 Linux + * generally defaults to eight megabytes, an embedded device might be a few + * kilobytes instead. You generally need to specify a stack that is a multiple + * of the system's page size (in many cases, this is 4 kilobytes, but check + * your system documentation). + * + * Note that this "function" is actually a macro that calls an internal + * function with two extra parameters not listed here; they are hidden through + * preprocessor macros and are needed to support various C runtimes at the + * point of the function call. Language bindings that aren't using the C + * headers will need to deal with this. + * + * The actual symbol in SDL is `SDL_CreateThreadWithPropertiesRuntime`, so + * there is no symbol clash, but trying to load an SDL shared library and look + * for "SDL_CreateThreadWithProperties" will fail. + * + * Usually, apps should just call this function the same way on every platform + * and let the macros hide the details. + * + * \param props the properties to use. + * \returns an opaque pointer to the new thread object on success, NULL if the + * new thread could not be created; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateThread + * \sa SDL_WaitThread + */ +extern SDL_DECLSPEC SDL_Thread * SDLCALL SDL_CreateThreadWithProperties(SDL_PropertiesID props); + +#define SDL_PROP_THREAD_CREATE_ENTRY_FUNCTION_POINTER "SDL.thread.create.entry_function" +#define SDL_PROP_THREAD_CREATE_NAME_STRING "SDL.thread.create.name" +#define SDL_PROP_THREAD_CREATE_USERDATA_POINTER "SDL.thread.create.userdata" +#define SDL_PROP_THREAD_CREATE_STACKSIZE_NUMBER "SDL.thread.create.stacksize" + +/* end wiki documentation for macros that are meant to look like functions. */ +#endif + + +/* The real implementation, hidden from the wiki, so it can show this as real functions that don't have macro magic. */ +#ifndef SDL_WIKI_DOCUMENTATION_SECTION +# if defined(SDL_PLATFORM_WINDOWS) +# ifndef SDL_BeginThreadFunction +# define SDL_BeginThreadFunction _beginthreadex +# endif +# ifndef SDL_EndThreadFunction +# define SDL_EndThreadFunction _endthreadex +# endif +# endif +#endif + +/* currently no other platforms than Windows use _beginthreadex/_endthreadex things. */ +#ifndef SDL_WIKI_DOCUMENTATION_SECTION +# ifndef SDL_BeginThreadFunction +# define SDL_BeginThreadFunction NULL +# endif +#endif + +#ifndef SDL_WIKI_DOCUMENTATION_SECTION +# ifndef SDL_EndThreadFunction +# define SDL_EndThreadFunction NULL +# endif +#endif + +#ifndef SDL_WIKI_DOCUMENTATION_SECTION +/* These are the actual functions exported from SDL! Don't use them directly! Use the SDL_CreateThread and SDL_CreateThreadWithProperties macros! */ +/** + * The actual entry point for SDL_CreateThread. + * + * \param fn the SDL_ThreadFunction function to call in the new thread + * \param name the name of the thread + * \param data a pointer that is passed to `fn` + * \param pfnBeginThread the C runtime's _beginthreadex (or whatnot). Can be NULL. + * \param pfnEndThread the C runtime's _endthreadex (or whatnot). Can be NULL. + * \returns an opaque pointer to the new thread object on success, NULL if the + * new thread could not be created; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_Thread * SDLCALL SDL_CreateThreadRuntime(SDL_ThreadFunction fn, const char *name, void *data, SDL_FunctionPointer pfnBeginThread, SDL_FunctionPointer pfnEndThread); + +/** + * The actual entry point for SDL_CreateThreadWithProperties. + * + * \param props the properties to use + * \param pfnBeginThread the C runtime's _beginthreadex (or whatnot). Can be NULL. + * \param pfnEndThread the C runtime's _endthreadex (or whatnot). Can be NULL. + * \returns an opaque pointer to the new thread object on success, NULL if the + * new thread could not be created; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_Thread * SDLCALL SDL_CreateThreadWithPropertiesRuntime(SDL_PropertiesID props, SDL_FunctionPointer pfnBeginThread, SDL_FunctionPointer pfnEndThread); + +#define SDL_CreateThread(fn, name, data) SDL_CreateThreadRuntime((fn), (name), (data), (SDL_FunctionPointer) (SDL_BeginThreadFunction), (SDL_FunctionPointer) (SDL_EndThreadFunction)) +#define SDL_CreateThreadWithProperties(props) SDL_CreateThreadWithPropertiesRuntime((props), (SDL_FunctionPointer) (SDL_BeginThreadFunction), (SDL_FunctionPointer) (SDL_EndThreadFunction)) +#define SDL_PROP_THREAD_CREATE_ENTRY_FUNCTION_POINTER "SDL.thread.create.entry_function" +#define SDL_PROP_THREAD_CREATE_NAME_STRING "SDL.thread.create.name" +#define SDL_PROP_THREAD_CREATE_USERDATA_POINTER "SDL.thread.create.userdata" +#define SDL_PROP_THREAD_CREATE_STACKSIZE_NUMBER "SDL.thread.create.stacksize" +#endif + + +/** + * Get the thread name as it was specified in SDL_CreateThread(). + * + * \param thread the thread to query. + * \returns a pointer to a UTF-8 string that names the specified thread, or + * NULL if it doesn't have a name. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetThreadName(SDL_Thread *thread); + +/** + * Get the thread identifier for the current thread. + * + * This thread identifier is as reported by the underlying operating system. + * If SDL is running on a platform that does not support threads the return + * value will always be zero. + * + * This function also returns a valid thread ID when called from the main + * thread. + * + * \returns the ID of the current thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetThreadID + */ +extern SDL_DECLSPEC SDL_ThreadID SDLCALL SDL_GetCurrentThreadID(void); + +/** + * Get the thread identifier for the specified thread. + * + * This thread identifier is as reported by the underlying operating system. + * If SDL is running on a platform that does not support threads the return + * value will always be zero. + * + * \param thread the thread to query. + * \returns the ID of the specified thread, or the ID of the current thread if + * `thread` is NULL. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetCurrentThreadID + */ +extern SDL_DECLSPEC SDL_ThreadID SDLCALL SDL_GetThreadID(SDL_Thread *thread); + +/** + * Set the priority for the current thread. + * + * Note that some platforms will not let you alter the priority (or at least, + * promote the thread to a higher priority) at all, and some require you to be + * an administrator account. Be prepared for this to fail. + * + * \param priority the SDL_ThreadPriority to set. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetCurrentThreadPriority(SDL_ThreadPriority priority); + +/** + * Wait for a thread to finish. + * + * Threads that haven't been detached will remain until this function cleans + * them up. Not doing so is a resource leak. + * + * Once a thread has been cleaned up through this function, the SDL_Thread + * that references it becomes invalid and should not be referenced again. As + * such, only one thread may call SDL_WaitThread() on another. + * + * The return code from the thread function is placed in the area pointed to + * by `status`, if `status` is not NULL. + * + * You may not wait on a thread that has been used in a call to + * SDL_DetachThread(). Use either that function or this one, but not both, or + * behavior is undefined. + * + * It is safe to pass a NULL thread to this function; it is a no-op. + * + * Note that the thread pointer is freed by this function and is not valid + * afterward. + * + * \param thread the SDL_Thread pointer that was returned from the + * SDL_CreateThread() call that started this thread. + * \param status a pointer filled in with the value returned from the thread + * function by its 'return', or -1 if the thread has been + * detached or isn't valid, may be NULL. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateThread + * \sa SDL_DetachThread + */ +extern SDL_DECLSPEC void SDLCALL SDL_WaitThread(SDL_Thread *thread, int *status); + +/** + * Get the current state of a thread. + * + * \param thread the thread to query. + * \returns the current state of a thread, or SDL_THREAD_UNKNOWN if the thread + * isn't valid. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_ThreadState + */ +extern SDL_DECLSPEC SDL_ThreadState SDLCALL SDL_GetThreadState(SDL_Thread *thread); + +/** + * Let a thread clean up on exit without intervention. + * + * A thread may be "detached" to signify that it should not remain until + * another thread has called SDL_WaitThread() on it. Detaching a thread is + * useful for long-running threads that nothing needs to synchronize with or + * further manage. When a detached thread is done, it simply goes away. + * + * There is no way to recover the return code of a detached thread. If you + * need this, don't detach the thread and instead use SDL_WaitThread(). + * + * Once a thread is detached, you should usually assume the SDL_Thread isn't + * safe to reference again, as it will become invalid immediately upon the + * detached thread's exit, instead of remaining until someone has called + * SDL_WaitThread() to finally clean it up. As such, don't detach the same + * thread more than once. + * + * If a thread has already exited when passed to SDL_DetachThread(), it will + * stop waiting for a call to SDL_WaitThread() and clean up immediately. It is + * not safe to detach a thread that might be used with SDL_WaitThread(). + * + * You may not call SDL_WaitThread() on a thread that has been detached. Use + * either that function or this one, but not both, or behavior is undefined. + * + * It is safe to pass NULL to this function; it is a no-op. + * + * \param thread the SDL_Thread pointer that was returned from the + * SDL_CreateThread() call that started this thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateThread + * \sa SDL_WaitThread + */ +extern SDL_DECLSPEC void SDLCALL SDL_DetachThread(SDL_Thread *thread); + +/** + * Get the current thread's value associated with a thread local storage ID. + * + * \param id a pointer to the thread local storage ID, may not be NULL. + * \returns the value associated with the ID for the current thread or NULL if + * no value has been set; call SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetTLS + */ +extern SDL_DECLSPEC void * SDLCALL SDL_GetTLS(SDL_TLSID *id); + +/** + * The callback used to cleanup data passed to SDL_SetTLS. + * + * This is called when a thread exits, to allow an app to free any resources. + * + * \param value a pointer previously handed to SDL_SetTLS. + * + * \since This datatype is available since SDL 3.2.0. + * + * \sa SDL_SetTLS + */ +typedef void (SDLCALL *SDL_TLSDestructorCallback)(void *value); + +/** + * Set the current thread's value associated with a thread local storage ID. + * + * If the thread local storage ID is not initialized (the value is 0), a new + * ID will be created in a thread-safe way, so all calls using a pointer to + * the same ID will refer to the same local storage. + * + * Note that replacing a value from a previous call to this function on the + * same thread does _not_ call the previous value's destructor! + * + * `destructor` can be NULL; it is assumed that `value` does not need to be + * cleaned up if so. + * + * \param id a pointer to the thread local storage ID, may not be NULL. + * \param value the value to associate with the ID for the current thread. + * \param destructor a function called when the thread exits, to free the + * value, may be NULL. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetTLS + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetTLS(SDL_TLSID *id, const void *value, SDL_TLSDestructorCallback destructor); + +/** + * Cleanup all TLS data for this thread. + * + * If you are creating your threads outside of SDL and then calling SDL + * functions, you should call this function before your thread exits, to + * properly clean up SDL memory. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_CleanupTLS(void); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_thread_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_time.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_time.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,231 @@ +/* +Simple DirectMedia Layer +Copyright (C) 1997-2025 Sam Lantinga + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_time_h_ +#define SDL_time_h_ + +/** + * # CategoryTime + * + * SDL realtime clock and date/time routines. + * + * There are two data types that are used in this category: SDL_Time, which + * represents the nanoseconds since a specific moment (an "epoch"), and + * SDL_DateTime, which breaks time down into human-understandable components: + * years, months, days, hours, etc. + * + * Much of the functionality is involved in converting those two types to + * other useful forms. + */ + +#include +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * A structure holding a calendar date and time broken down into its + * components. + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_DateTime +{ + int year; /**< Year */ + int month; /**< Month [01-12] */ + int day; /**< Day of the month [01-31] */ + int hour; /**< Hour [0-23] */ + int minute; /**< Minute [0-59] */ + int second; /**< Seconds [0-60] */ + int nanosecond; /**< Nanoseconds [0-999999999] */ + int day_of_week; /**< Day of the week [0-6] (0 being Sunday) */ + int utc_offset; /**< Seconds east of UTC */ +} SDL_DateTime; + +/** + * The preferred date format of the current system locale. + * + * \since This enum is available since SDL 3.2.0. + * + * \sa SDL_GetDateTimeLocalePreferences + */ +typedef enum SDL_DateFormat +{ + SDL_DATE_FORMAT_YYYYMMDD = 0, /**< Year/Month/Day */ + SDL_DATE_FORMAT_DDMMYYYY = 1, /**< Day/Month/Year */ + SDL_DATE_FORMAT_MMDDYYYY = 2 /**< Month/Day/Year */ +} SDL_DateFormat; + +/** + * The preferred time format of the current system locale. + * + * \since This enum is available since SDL 3.2.0. + * + * \sa SDL_GetDateTimeLocalePreferences + */ +typedef enum SDL_TimeFormat +{ + SDL_TIME_FORMAT_24HR = 0, /**< 24 hour time */ + SDL_TIME_FORMAT_12HR = 1 /**< 12 hour time */ +} SDL_TimeFormat; + +/** + * Gets the current preferred date and time format for the system locale. + * + * This might be a "slow" call that has to query the operating system. It's + * best to ask for this once and save the results. However, the preferred + * formats can change, usually because the user has changed a system + * preference outside of your program. + * + * \param dateFormat a pointer to the SDL_DateFormat to hold the returned date + * format, may be NULL. + * \param timeFormat a pointer to the SDL_TimeFormat to hold the returned time + * format, may be NULL. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetDateTimeLocalePreferences(SDL_DateFormat *dateFormat, SDL_TimeFormat *timeFormat); + +/** + * Gets the current value of the system realtime clock in nanoseconds since + * Jan 1, 1970 in Universal Coordinated Time (UTC). + * + * \param ticks the SDL_Time to hold the returned tick count. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetCurrentTime(SDL_Time *ticks); + +/** + * Converts an SDL_Time in nanoseconds since the epoch to a calendar time in + * the SDL_DateTime format. + * + * \param ticks the SDL_Time to be converted. + * \param dt the resulting SDL_DateTime. + * \param localTime the resulting SDL_DateTime will be expressed in local time + * if true, otherwise it will be in Universal Coordinated + * Time (UTC). + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_TimeToDateTime(SDL_Time ticks, SDL_DateTime *dt, bool localTime); + +/** + * Converts a calendar time to an SDL_Time in nanoseconds since the epoch. + * + * This function ignores the day_of_week member of the SDL_DateTime struct, so + * it may remain unset. + * + * \param dt the source SDL_DateTime. + * \param ticks the resulting SDL_Time. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_DateTimeToTime(const SDL_DateTime *dt, SDL_Time *ticks); + +/** + * Converts an SDL time into a Windows FILETIME (100-nanosecond intervals + * since January 1, 1601). + * + * This function fills in the two 32-bit values of the FILETIME structure. + * + * \param ticks the time to convert. + * \param dwLowDateTime a pointer filled in with the low portion of the + * Windows FILETIME value. + * \param dwHighDateTime a pointer filled in with the high portion of the + * Windows FILETIME value. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_TimeToWindows(SDL_Time ticks, Uint32 *dwLowDateTime, Uint32 *dwHighDateTime); + +/** + * Converts a Windows FILETIME (100-nanosecond intervals since January 1, + * 1601) to an SDL time. + * + * This function takes the two 32-bit values of the FILETIME structure as + * parameters. + * + * \param dwLowDateTime the low portion of the Windows FILETIME value. + * \param dwHighDateTime the high portion of the Windows FILETIME value. + * \returns the converted SDL time. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_Time SDLCALL SDL_TimeFromWindows(Uint32 dwLowDateTime, Uint32 dwHighDateTime); + +/** + * Get the number of days in a month for a given year. + * + * \param year the year. + * \param month the month [1-12]. + * \returns the number of days in the requested month or -1 on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_GetDaysInMonth(int year, int month); + +/** + * Get the day of year for a calendar date. + * + * \param year the year component of the date. + * \param month the month component of the date. + * \param day the day component of the date. + * \returns the day of year [0-365] if the date is valid or -1 on failure; + * call SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_GetDayOfYear(int year, int month, int day); + +/** + * Get the day of week for a calendar date. + * + * \param year the year component of the date. + * \param month the month component of the date. + * \param day the day component of the date. + * \returns a value between 0 and 6 (0 being Sunday) if the date is valid or + * -1 on failure; call SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_GetDayOfWeek(int year, int month, int day); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_time_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_timer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_timer.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,454 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_timer_h_ +#define SDL_timer_h_ + +/** + * # CategoryTimer + * + * SDL provides time management functionality. It is useful for dealing with + * (usually) small durations of time. + * + * This is not to be confused with _calendar time_ management, which is + * provided by [CategoryTime](CategoryTime). + * + * This category covers measuring time elapsed (SDL_GetTicks(), + * SDL_GetPerformanceCounter()), putting a thread to sleep for a certain + * amount of time (SDL_Delay(), SDL_DelayNS(), SDL_DelayPrecise()), and firing + * a callback function after a certain amount of time has elapsed + * (SDL_AddTimer(), etc). + * + * There are also useful macros to convert between time units, like + * SDL_SECONDS_TO_NS() and such. + */ + +#include +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* SDL time constants */ + +/** + * Number of milliseconds in a second. + * + * This is always 1000. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_MS_PER_SECOND 1000 + +/** + * Number of microseconds in a second. + * + * This is always 1000000. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_US_PER_SECOND 1000000 + +/** + * Number of nanoseconds in a second. + * + * This is always 1000000000. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_NS_PER_SECOND 1000000000LL + +/** + * Number of nanoseconds in a millisecond. + * + * This is always 1000000. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_NS_PER_MS 1000000 + +/** + * Number of nanoseconds in a microsecond. + * + * This is always 1000. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_NS_PER_US 1000 + +/** + * Convert seconds to nanoseconds. + * + * This only converts whole numbers, not fractional seconds. + * + * \param S the number of seconds to convert. + * \returns S, expressed in nanoseconds. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_SECONDS_TO_NS(S) (((Uint64)(S)) * SDL_NS_PER_SECOND) + +/** + * Convert nanoseconds to seconds. + * + * This performs a division, so the results can be dramatically different if + * `NS` is an integer or floating point value. + * + * \param NS the number of nanoseconds to convert. + * \returns NS, expressed in seconds. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_NS_TO_SECONDS(NS) ((NS) / SDL_NS_PER_SECOND) + +/** + * Convert milliseconds to nanoseconds. + * + * This only converts whole numbers, not fractional milliseconds. + * + * \param MS the number of milliseconds to convert. + * \returns MS, expressed in nanoseconds. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_MS_TO_NS(MS) (((Uint64)(MS)) * SDL_NS_PER_MS) + +/** + * Convert nanoseconds to milliseconds. + * + * This performs a division, so the results can be dramatically different if + * `NS` is an integer or floating point value. + * + * \param NS the number of nanoseconds to convert. + * \returns NS, expressed in milliseconds. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_NS_TO_MS(NS) ((NS) / SDL_NS_PER_MS) + +/** + * Convert microseconds to nanoseconds. + * + * This only converts whole numbers, not fractional microseconds. + * + * \param US the number of microseconds to convert. + * \returns US, expressed in nanoseconds. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_US_TO_NS(US) (((Uint64)(US)) * SDL_NS_PER_US) + +/** + * Convert nanoseconds to microseconds. + * + * This performs a division, so the results can be dramatically different if + * `NS` is an integer or floating point value. + * + * \param NS the number of nanoseconds to convert. + * \returns NS, expressed in microseconds. + * + * \threadsafety It is safe to call this macro from any thread. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_NS_TO_US(NS) ((NS) / SDL_NS_PER_US) + +/** + * Get the number of milliseconds that have elapsed since the SDL library + * initialization. + * + * \returns an unsigned 64‑bit integer that represents the number of + * milliseconds that have elapsed since the SDL library was + * initialized (typically via a call to SDL_Init). + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetTicksNS + */ +extern SDL_DECLSPEC Uint64 SDLCALL SDL_GetTicks(void); + +/** + * Get the number of nanoseconds since SDL library initialization. + * + * \returns an unsigned 64-bit value representing the number of nanoseconds + * since the SDL library initialized. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC Uint64 SDLCALL SDL_GetTicksNS(void); + +/** + * Get the current value of the high resolution counter. + * + * This function is typically used for profiling. + * + * The counter values are only meaningful relative to each other. Differences + * between values can be converted to times by using + * SDL_GetPerformanceFrequency(). + * + * \returns the current counter value. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetPerformanceFrequency + */ +extern SDL_DECLSPEC Uint64 SDLCALL SDL_GetPerformanceCounter(void); + +/** + * Get the count per second of the high resolution counter. + * + * \returns a platform-specific count per second. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetPerformanceCounter + */ +extern SDL_DECLSPEC Uint64 SDLCALL SDL_GetPerformanceFrequency(void); + +/** + * Wait a specified number of milliseconds before returning. + * + * This function waits a specified number of milliseconds before returning. It + * waits at least the specified time, but possibly longer due to OS + * scheduling. + * + * \param ms the number of milliseconds to delay. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_DelayNS + * \sa SDL_DelayPrecise + */ +extern SDL_DECLSPEC void SDLCALL SDL_Delay(Uint32 ms); + +/** + * Wait a specified number of nanoseconds before returning. + * + * This function waits a specified number of nanoseconds before returning. It + * waits at least the specified time, but possibly longer due to OS + * scheduling. + * + * \param ns the number of nanoseconds to delay. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_Delay + * \sa SDL_DelayPrecise + */ +extern SDL_DECLSPEC void SDLCALL SDL_DelayNS(Uint64 ns); + +/** + * Wait a specified number of nanoseconds before returning. + * + * This function waits a specified number of nanoseconds before returning. It + * will attempt to wait as close to the requested time as possible, busy + * waiting if necessary, but could return later due to OS scheduling. + * + * \param ns the number of nanoseconds to delay. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_Delay + * \sa SDL_DelayNS + */ +extern SDL_DECLSPEC void SDLCALL SDL_DelayPrecise(Uint64 ns); + +/** + * Definition of the timer ID type. + * + * \since This datatype is available since SDL 3.2.0. + */ +typedef Uint32 SDL_TimerID; + +/** + * Function prototype for the millisecond timer callback function. + * + * The callback function is passed the current timer interval and returns the + * next timer interval, in milliseconds. If the returned value is the same as + * the one passed in, the periodic alarm continues, otherwise a new alarm is + * scheduled. If the callback returns 0, the periodic alarm is canceled and + * will be removed. + * + * \param userdata an arbitrary pointer provided by the app through + * SDL_AddTimer, for its own use. + * \param timerID the current timer being processed. + * \param interval the current callback time interval. + * \returns the new callback time interval, or 0 to disable further runs of + * the callback. + * + * \threadsafety SDL may call this callback at any time from a background + * thread; the application is responsible for locking resources + * the callback touches that need to be protected. + * + * \since This datatype is available since SDL 3.2.0. + * + * \sa SDL_AddTimer + */ +typedef Uint32 (SDLCALL *SDL_TimerCallback)(void *userdata, SDL_TimerID timerID, Uint32 interval); + +/** + * Call a callback function at a future time. + * + * The callback function is passed the current timer interval and the user + * supplied parameter from the SDL_AddTimer() call and should return the next + * timer interval. If the value returned from the callback is 0, the timer is + * canceled and will be removed. + * + * The callback is run on a separate thread, and for short timeouts can + * potentially be called before this function returns. + * + * Timers take into account the amount of time it took to execute the + * callback. For example, if the callback took 250 ms to execute and returned + * 1000 (ms), the timer would only wait another 750 ms before its next + * iteration. + * + * Timing may be inexact due to OS scheduling. Be sure to note the current + * time with SDL_GetTicksNS() or SDL_GetPerformanceCounter() in case your + * callback needs to adjust for variances. + * + * \param interval the timer delay, in milliseconds, passed to `callback`. + * \param callback the SDL_TimerCallback function to call when the specified + * `interval` elapses. + * \param userdata a pointer that is passed to `callback`. + * \returns a timer ID or 0 on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_AddTimerNS + * \sa SDL_RemoveTimer + */ +extern SDL_DECLSPEC SDL_TimerID SDLCALL SDL_AddTimer(Uint32 interval, SDL_TimerCallback callback, void *userdata); + +/** + * Function prototype for the nanosecond timer callback function. + * + * The callback function is passed the current timer interval and returns the + * next timer interval, in nanoseconds. If the returned value is the same as + * the one passed in, the periodic alarm continues, otherwise a new alarm is + * scheduled. If the callback returns 0, the periodic alarm is canceled and + * will be removed. + * + * \param userdata an arbitrary pointer provided by the app through + * SDL_AddTimer, for its own use. + * \param timerID the current timer being processed. + * \param interval the current callback time interval. + * \returns the new callback time interval, or 0 to disable further runs of + * the callback. + * + * \threadsafety SDL may call this callback at any time from a background + * thread; the application is responsible for locking resources + * the callback touches that need to be protected. + * + * \since This datatype is available since SDL 3.2.0. + * + * \sa SDL_AddTimerNS + */ +typedef Uint64 (SDLCALL *SDL_NSTimerCallback)(void *userdata, SDL_TimerID timerID, Uint64 interval); + +/** + * Call a callback function at a future time. + * + * The callback function is passed the current timer interval and the user + * supplied parameter from the SDL_AddTimerNS() call and should return the + * next timer interval. If the value returned from the callback is 0, the + * timer is canceled and will be removed. + * + * The callback is run on a separate thread, and for short timeouts can + * potentially be called before this function returns. + * + * Timers take into account the amount of time it took to execute the + * callback. For example, if the callback took 250 ns to execute and returned + * 1000 (ns), the timer would only wait another 750 ns before its next + * iteration. + * + * Timing may be inexact due to OS scheduling. Be sure to note the current + * time with SDL_GetTicksNS() or SDL_GetPerformanceCounter() in case your + * callback needs to adjust for variances. + * + * \param interval the timer delay, in nanoseconds, passed to `callback`. + * \param callback the SDL_TimerCallback function to call when the specified + * `interval` elapses. + * \param userdata a pointer that is passed to `callback`. + * \returns a timer ID or 0 on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_AddTimer + * \sa SDL_RemoveTimer + */ +extern SDL_DECLSPEC SDL_TimerID SDLCALL SDL_AddTimerNS(Uint64 interval, SDL_NSTimerCallback callback, void *userdata); + +/** + * Remove a timer created with SDL_AddTimer(). + * + * \param id the ID of the timer to remove. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_AddTimer + */ +extern SDL_DECLSPEC bool SDLCALL SDL_RemoveTimer(SDL_TimerID id); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_timer_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_touch.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_touch.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,184 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * # CategoryTouch + * + * SDL offers touch input, on platforms that support it. It can manage + * multiple touch devices and track multiple fingers on those devices. + * + * Touches are mostly dealt with through the event system, in the + * SDL_EVENT_FINGER_DOWN, SDL_EVENT_FINGER_MOTION, and SDL_EVENT_FINGER_UP + * events, but there are also functions to query for hardware details, etc. + * + * The touch system, by default, will also send virtual mouse events; this can + * be useful for making a some desktop apps work on a phone without + * significant changes. For apps that care about mouse and touch input + * separately, they should ignore mouse events that have a `which` field of + * SDL_TOUCH_MOUSEID. + */ + +#ifndef SDL_touch_h_ +#define SDL_touch_h_ + +#include +#include +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * A unique ID for a touch device. + * + * This ID is valid for the time the device is connected to the system, and is + * never reused for the lifetime of the application. + * + * The value 0 is an invalid ID. + * + * \since This datatype is available since SDL 3.2.0. + */ +typedef Uint64 SDL_TouchID; + +/** + * A unique ID for a single finger on a touch device. + * + * This ID is valid for the time the finger (stylus, etc) is touching and will + * be unique for all fingers currently in contact, so this ID tracks the + * lifetime of a single continuous touch. This value may represent an index, a + * pointer, or some other unique ID, depending on the platform. + * + * The value 0 is an invalid ID. + * + * \since This datatype is available since SDL 3.2.0. + */ +typedef Uint64 SDL_FingerID; + +/** + * An enum that describes the type of a touch device. + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_TouchDeviceType +{ + SDL_TOUCH_DEVICE_INVALID = -1, + SDL_TOUCH_DEVICE_DIRECT, /**< touch screen with window-relative coordinates */ + SDL_TOUCH_DEVICE_INDIRECT_ABSOLUTE, /**< trackpad with absolute device coordinates */ + SDL_TOUCH_DEVICE_INDIRECT_RELATIVE /**< trackpad with screen cursor-relative coordinates */ +} SDL_TouchDeviceType; + +/** + * Data about a single finger in a multitouch event. + * + * Each touch event is a collection of fingers that are simultaneously in + * contact with the touch device (so a "touch" can be a "multitouch," in + * reality), and this struct reports details of the specific fingers. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_GetTouchFingers + */ +typedef struct SDL_Finger +{ + SDL_FingerID id; /**< the finger ID */ + float x; /**< the x-axis location of the touch event, normalized (0...1) */ + float y; /**< the y-axis location of the touch event, normalized (0...1) */ + float pressure; /**< the quantity of pressure applied, normalized (0...1) */ +} SDL_Finger; + +/** + * The SDL_MouseID for mouse events simulated with touch input. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_TOUCH_MOUSEID ((SDL_MouseID)-1) + +/** + * The SDL_TouchID for touch events simulated with mouse input. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_MOUSE_TOUCHID ((SDL_TouchID)-1) + + +/** + * Get a list of registered touch devices. + * + * On some platforms SDL first sees the touch device if it was actually used. + * Therefore the returned list might be empty, although devices are available. + * After using all devices at least once the number will be correct. + * + * \param count a pointer filled in with the number of devices returned, may + * be NULL. + * \returns a 0 terminated array of touch device IDs or NULL on failure; call + * SDL_GetError() for more information. This should be freed with + * SDL_free() when it is no longer needed. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_TouchID * SDLCALL SDL_GetTouchDevices(int *count); + +/** + * Get the touch device name as reported from the driver. + * + * \param touchID the touch device instance ID. + * \returns touch device name, or NULL on failure; call SDL_GetError() for + * more information. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetTouchDeviceName(SDL_TouchID touchID); + +/** + * Get the type of the given touch device. + * + * \param touchID the ID of a touch device. + * \returns touch device type. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_TouchDeviceType SDLCALL SDL_GetTouchDeviceType(SDL_TouchID touchID); + +/** + * Get a list of active fingers for a given touch device. + * + * \param touchID the ID of a touch device. + * \param count a pointer filled in with the number of fingers returned, can + * be NULL. + * \returns a NULL terminated array of SDL_Finger pointers or NULL on failure; + * call SDL_GetError() for more information. This is a single + * allocation that should be freed with SDL_free() when it is no + * longer needed. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_Finger ** SDLCALL SDL_GetTouchFingers(SDL_TouchID touchID, int *count); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_touch_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_tray.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_tray.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,544 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * # CategoryTray + * + * SDL offers a way to add items to the "system tray" (more correctly called + * the "notification area" on Windows). On platforms that offer this concept, + * an SDL app can add a tray icon, submenus, checkboxes, and clickable + * entries, and register a callback that is fired when the user clicks on + * these pieces. + */ + +#ifndef SDL_tray_h_ +#define SDL_tray_h_ + +#include +#include +#include +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * An opaque handle representing a toplevel system tray object. + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_Tray SDL_Tray; + +/** + * An opaque handle representing a menu/submenu on a system tray object. + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_TrayMenu SDL_TrayMenu; + +/** + * An opaque handle representing an entry on a system tray object. + * + * \since This struct is available since SDL 3.2.0. + */ +typedef struct SDL_TrayEntry SDL_TrayEntry; + +/** + * Flags that control the creation of system tray entries. + * + * Some of these flags are required; exactly one of them must be specified at + * the time a tray entry is created. Other flags are optional; zero or more of + * those can be OR'ed together with the required flag. + * + * \since This datatype is available since SDL 3.2.0. + * + * \sa SDL_InsertTrayEntryAt + */ +typedef Uint32 SDL_TrayEntryFlags; + +#define SDL_TRAYENTRY_BUTTON 0x00000001u /**< Make the entry a simple button. Required. */ +#define SDL_TRAYENTRY_CHECKBOX 0x00000002u /**< Make the entry a checkbox. Required. */ +#define SDL_TRAYENTRY_SUBMENU 0x00000004u /**< Prepare the entry to have a submenu. Required */ +#define SDL_TRAYENTRY_DISABLED 0x80000000u /**< Make the entry disabled. Optional. */ +#define SDL_TRAYENTRY_CHECKED 0x40000000u /**< Make the entry checked. This is valid only for checkboxes. Optional. */ + +/** + * A callback that is invoked when a tray entry is selected. + * + * \param userdata an optional pointer to pass extra data to the callback when + * it will be invoked. + * \param entry the tray entry that was selected. + * + * \since This datatype is available since SDL 3.2.0. + * + * \sa SDL_SetTrayEntryCallback + */ +typedef void (SDLCALL *SDL_TrayCallback)(void *userdata, SDL_TrayEntry *entry); + +/** + * Create an icon to be placed in the operating system's tray, or equivalent. + * + * Many platforms advise not using a system tray unless persistence is a + * necessary feature. Avoid needlessly creating a tray icon, as the user may + * feel like it clutters their interface. + * + * Using tray icons require the video subsystem. + * + * \param icon a surface to be used as icon. May be NULL. + * \param tooltip a tooltip to be displayed when the mouse hovers the icon in + * UTF-8 encoding. Not supported on all platforms. May be NULL. + * \returns The newly created system tray icon. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateTrayMenu + * \sa SDL_GetTrayMenu + * \sa SDL_DestroyTray + */ +extern SDL_DECLSPEC SDL_Tray * SDLCALL SDL_CreateTray(SDL_Surface *icon, const char *tooltip); + +/** + * Updates the system tray icon's icon. + * + * \param tray the tray icon to be updated. + * \param icon the new icon. May be NULL. + * + * \threadsafety This function should be called on the thread that created the + * tray. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateTray + */ +extern SDL_DECLSPEC void SDLCALL SDL_SetTrayIcon(SDL_Tray *tray, SDL_Surface *icon); + +/** + * Updates the system tray icon's tooltip. + * + * \param tray the tray icon to be updated. + * \param tooltip the new tooltip in UTF-8 encoding. May be NULL. + * + * \threadsafety This function should be called on the thread that created the + * tray. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateTray + */ +extern SDL_DECLSPEC void SDLCALL SDL_SetTrayTooltip(SDL_Tray *tray, const char *tooltip); + +/** + * Create a menu for a system tray. + * + * This should be called at most once per tray icon. + * + * This function does the same thing as SDL_CreateTraySubmenu(), except that + * it takes a SDL_Tray instead of a SDL_TrayEntry. + * + * A menu does not need to be destroyed; it will be destroyed with the tray. + * + * \param tray the tray to bind the menu to. + * \returns the newly created menu. + * + * \threadsafety This function should be called on the thread that created the + * tray. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateTray + * \sa SDL_GetTrayMenu + * \sa SDL_GetTrayMenuParentTray + */ +extern SDL_DECLSPEC SDL_TrayMenu * SDLCALL SDL_CreateTrayMenu(SDL_Tray *tray); + +/** + * Create a submenu for a system tray entry. + * + * This should be called at most once per tray entry. + * + * This function does the same thing as SDL_CreateTrayMenu, except that it + * takes a SDL_TrayEntry instead of a SDL_Tray. + * + * A menu does not need to be destroyed; it will be destroyed with the tray. + * + * \param entry the tray entry to bind the menu to. + * \returns the newly created menu. + * + * \threadsafety This function should be called on the thread that created the + * tray. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_InsertTrayEntryAt + * \sa SDL_GetTraySubmenu + * \sa SDL_GetTrayMenuParentEntry + */ +extern SDL_DECLSPEC SDL_TrayMenu * SDLCALL SDL_CreateTraySubmenu(SDL_TrayEntry *entry); + +/** + * Gets a previously created tray menu. + * + * You should have called SDL_CreateTrayMenu() on the tray object. This + * function allows you to fetch it again later. + * + * This function does the same thing as SDL_GetTraySubmenu(), except that it + * takes a SDL_Tray instead of a SDL_TrayEntry. + * + * A menu does not need to be destroyed; it will be destroyed with the tray. + * + * \param tray the tray entry to bind the menu to. + * \returns the newly created menu. + * + * \threadsafety This function should be called on the thread that created the + * tray. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateTray + * \sa SDL_CreateTrayMenu + */ +extern SDL_DECLSPEC SDL_TrayMenu * SDLCALL SDL_GetTrayMenu(SDL_Tray *tray); + +/** + * Gets a previously created tray entry submenu. + * + * You should have called SDL_CreateTraySubmenu() on the entry object. This + * function allows you to fetch it again later. + * + * This function does the same thing as SDL_GetTrayMenu(), except that it + * takes a SDL_TrayEntry instead of a SDL_Tray. + * + * A menu does not need to be destroyed; it will be destroyed with the tray. + * + * \param entry the tray entry to bind the menu to. + * \returns the newly created menu. + * + * \threadsafety This function should be called on the thread that created the + * tray. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_InsertTrayEntryAt + * \sa SDL_CreateTraySubmenu + */ +extern SDL_DECLSPEC SDL_TrayMenu * SDLCALL SDL_GetTraySubmenu(SDL_TrayEntry *entry); + +/** + * Returns a list of entries in the menu, in order. + * + * \param menu The menu to get entries from. + * \param count An optional pointer to obtain the number of entries in the + * menu. + * \returns a NULL-terminated list of entries within the given menu. The + * pointer becomes invalid when any function that inserts or deletes + * entries in the menu is called. + * + * \threadsafety This function should be called on the thread that created the + * tray. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_RemoveTrayEntry + * \sa SDL_InsertTrayEntryAt + */ +extern SDL_DECLSPEC const SDL_TrayEntry ** SDLCALL SDL_GetTrayEntries(SDL_TrayMenu *menu, int *count); + +/** + * Removes a tray entry. + * + * \param entry The entry to be deleted. + * + * \threadsafety This function should be called on the thread that created the + * tray. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetTrayEntries + * \sa SDL_InsertTrayEntryAt + */ +extern SDL_DECLSPEC void SDLCALL SDL_RemoveTrayEntry(SDL_TrayEntry *entry); + +/** + * Insert a tray entry at a given position. + * + * If label is NULL, the entry will be a separator. Many functions won't work + * for an entry that is a separator. + * + * An entry does not need to be destroyed; it will be destroyed with the tray. + * + * \param menu the menu to append the entry to. + * \param pos the desired position for the new entry. Entries at or following + * this place will be moved. If pos is -1, the entry is appended. + * \param label the text to be displayed on the entry, in UTF-8 encoding, or + * NULL for a separator. + * \param flags a combination of flags, some of which are mandatory. + * \returns the newly created entry, or NULL if pos is out of bounds. + * + * \threadsafety This function should be called on the thread that created the + * tray. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_TrayEntryFlags + * \sa SDL_GetTrayEntries + * \sa SDL_RemoveTrayEntry + * \sa SDL_GetTrayEntryParent + */ +extern SDL_DECLSPEC SDL_TrayEntry * SDLCALL SDL_InsertTrayEntryAt(SDL_TrayMenu *menu, int pos, const char *label, SDL_TrayEntryFlags flags); + +/** + * Sets the label of an entry. + * + * An entry cannot change between a separator and an ordinary entry; that is, + * it is not possible to set a non-NULL label on an entry that has a NULL + * label (separators), or to set a NULL label to an entry that has a non-NULL + * label. The function will silently fail if that happens. + * + * \param entry the entry to be updated. + * \param label the new label for the entry in UTF-8 encoding. + * + * \threadsafety This function should be called on the thread that created the + * tray. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetTrayEntries + * \sa SDL_InsertTrayEntryAt + * \sa SDL_GetTrayEntryLabel + */ +extern SDL_DECLSPEC void SDLCALL SDL_SetTrayEntryLabel(SDL_TrayEntry *entry, const char *label); + +/** + * Gets the label of an entry. + * + * If the returned value is NULL, the entry is a separator. + * + * \param entry the entry to be read. + * \returns the label of the entry in UTF-8 encoding. + * + * \threadsafety This function should be called on the thread that created the + * tray. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetTrayEntries + * \sa SDL_InsertTrayEntryAt + * \sa SDL_SetTrayEntryLabel + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetTrayEntryLabel(SDL_TrayEntry *entry); + +/** + * Sets whether or not an entry is checked. + * + * The entry must have been created with the SDL_TRAYENTRY_CHECKBOX flag. + * + * \param entry the entry to be updated. + * \param checked true if the entry should be checked; false otherwise. + * + * \threadsafety This function should be called on the thread that created the + * tray. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetTrayEntries + * \sa SDL_InsertTrayEntryAt + * \sa SDL_GetTrayEntryChecked + */ +extern SDL_DECLSPEC void SDLCALL SDL_SetTrayEntryChecked(SDL_TrayEntry *entry, bool checked); + +/** + * Gets whether or not an entry is checked. + * + * The entry must have been created with the SDL_TRAYENTRY_CHECKBOX flag. + * + * \param entry the entry to be read. + * \returns true if the entry is checked; false otherwise. + * + * \threadsafety This function should be called on the thread that created the + * tray. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetTrayEntries + * \sa SDL_InsertTrayEntryAt + * \sa SDL_SetTrayEntryChecked + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetTrayEntryChecked(SDL_TrayEntry *entry); + +/** + * Sets whether or not an entry is enabled. + * + * \param entry the entry to be updated. + * \param enabled true if the entry should be enabled; false otherwise. + * + * \threadsafety This function should be called on the thread that created the + * tray. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetTrayEntries + * \sa SDL_InsertTrayEntryAt + * \sa SDL_GetTrayEntryEnabled + */ +extern SDL_DECLSPEC void SDLCALL SDL_SetTrayEntryEnabled(SDL_TrayEntry *entry, bool enabled); + +/** + * Gets whether or not an entry is enabled. + * + * \param entry the entry to be read. + * \returns true if the entry is enabled; false otherwise. + * + * \threadsafety This function should be called on the thread that created the + * tray. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetTrayEntries + * \sa SDL_InsertTrayEntryAt + * \sa SDL_SetTrayEntryEnabled + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetTrayEntryEnabled(SDL_TrayEntry *entry); + +/** + * Sets a callback to be invoked when the entry is selected. + * + * \param entry the entry to be updated. + * \param callback a callback to be invoked when the entry is selected. + * \param userdata an optional pointer to pass extra data to the callback when + * it will be invoked. + * + * \threadsafety This function should be called on the thread that created the + * tray. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetTrayEntries + * \sa SDL_InsertTrayEntryAt + */ +extern SDL_DECLSPEC void SDLCALL SDL_SetTrayEntryCallback(SDL_TrayEntry *entry, SDL_TrayCallback callback, void *userdata); + +/** + * Simulate a click on a tray entry. + * + * \param entry The entry to activate. + * + * \threadsafety This function should be called on the thread that created the + * tray. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_ClickTrayEntry(SDL_TrayEntry *entry); + +/** + * Destroys a tray object. + * + * This also destroys all associated menus and entries. + * + * \param tray the tray icon to be destroyed. + * + * \threadsafety This function should be called on the thread that created the + * tray. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateTray + */ +extern SDL_DECLSPEC void SDLCALL SDL_DestroyTray(SDL_Tray *tray); + +/** + * Gets the menu containing a certain tray entry. + * + * \param entry the entry for which to get the parent menu. + * \returns the parent menu. + * + * \threadsafety This function should be called on the thread that created the + * tray. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_InsertTrayEntryAt + */ +extern SDL_DECLSPEC SDL_TrayMenu * SDLCALL SDL_GetTrayEntryParent(SDL_TrayEntry *entry); + +/** + * Gets the entry for which the menu is a submenu, if the current menu is a + * submenu. + * + * Either this function or SDL_GetTrayMenuParentTray() will return non-NULL + * for any given menu. + * + * \param menu the menu for which to get the parent entry. + * \returns the parent entry, or NULL if this menu is not a submenu. + * + * \threadsafety This function should be called on the thread that created the + * tray. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateTraySubmenu + * \sa SDL_GetTrayMenuParentTray + */ +extern SDL_DECLSPEC SDL_TrayEntry * SDLCALL SDL_GetTrayMenuParentEntry(SDL_TrayMenu *menu); + +/** + * Gets the tray for which this menu is the first-level menu, if the current + * menu isn't a submenu. + * + * Either this function or SDL_GetTrayMenuParentEntry() will return non-NULL + * for any given menu. + * + * \param menu the menu for which to get the parent enttrayry. + * \returns the parent tray, or NULL if this menu is a submenu. + * + * \threadsafety This function should be called on the thread that created the + * tray. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateTrayMenu + * \sa SDL_GetTrayMenuParentEntry + */ +extern SDL_DECLSPEC SDL_Tray * SDLCALL SDL_GetTrayMenuParentTray(SDL_TrayMenu *menu); + +/** + * Update the trays. + * + * This is called automatically by the event loop and is only needed if you're + * using trays but aren't handling SDL events. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_UpdateTrays(void); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_tray_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_version.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_version.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,184 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * # CategoryVersion + * + * Functionality to query the current SDL version, both as headers the app was + * compiled against, and a library the app is linked to. + */ + +#ifndef SDL_version_h_ +#define SDL_version_h_ + +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * The current major version of SDL headers. + * + * If this were SDL version 3.2.1, this value would be 3. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_MAJOR_VERSION 3 + +/** + * The current minor version of the SDL headers. + * + * If this were SDL version 3.2.1, this value would be 2. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_MINOR_VERSION 4 + +/** + * The current micro (or patchlevel) version of the SDL headers. + * + * If this were SDL version 3.2.1, this value would be 1. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_MICRO_VERSION 0 + +/** + * This macro turns the version numbers into a numeric value. + * + * (1,2,3) becomes 1002003. + * + * \param major the major version number. + * \param minor the minorversion number. + * \param patch the patch version number. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_VERSIONNUM(major, minor, patch) \ + ((major) * 1000000 + (minor) * 1000 + (patch)) + +/** + * This macro extracts the major version from a version number + * + * 1002003 becomes 1. + * + * \param version the version number. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_VERSIONNUM_MAJOR(version) ((version) / 1000000) + +/** + * This macro extracts the minor version from a version number + * + * 1002003 becomes 2. + * + * \param version the version number. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_VERSIONNUM_MINOR(version) (((version) / 1000) % 1000) + +/** + * This macro extracts the micro version from a version number + * + * 1002003 becomes 3. + * + * \param version the version number. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_VERSIONNUM_MICRO(version) ((version) % 1000) + +/** + * This is the version number macro for the current SDL version. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_GetVersion + */ +#define SDL_VERSION \ + SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_MICRO_VERSION) + +/** + * This macro will evaluate to true if compiled with SDL at least X.Y.Z. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_VERSION_ATLEAST(X, Y, Z) \ + (SDL_VERSION >= SDL_VERSIONNUM(X, Y, Z)) + +/** + * Get the version of SDL that is linked against your program. + * + * If you are linking to SDL dynamically, then it is possible that the current + * version will be different than the version you compiled against. This + * function returns the current version, while SDL_VERSION is the version you + * compiled with. + * + * This function may be called safely at any time, even before SDL_Init(). + * + * \returns the version of the linked library. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetRevision + */ +extern SDL_DECLSPEC int SDLCALL SDL_GetVersion(void); + +/** + * Get the code revision of the SDL library that is linked against your + * program. + * + * This value is the revision of the code you are linking against and may be + * different from the code you are compiling with, which is found in the + * constant SDL_REVISION if you explicitly include SDL_revision.h + * + * The revision is an arbitrary string (a hash value) uniquely identifying the + * exact revision of the SDL library in use, and is only useful in comparing + * against other revisions. It is NOT an incrementing number. + * + * If SDL wasn't built from a git repository with the appropriate tools, this + * will return an empty string. + * + * You shouldn't use this function for anything but logging it for debugging + * purposes. The string is not intended to be reliable in any way. + * + * \returns an arbitrary string, uniquely identifying the exact revision of + * the SDL library in use. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetVersion + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetRevision(void); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_version_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_video.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_video.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,3497 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * # CategoryVideo + * + * SDL's video subsystem is largely interested in abstracting window + * management from the underlying operating system. You can create windows, + * manage them in various ways, set them fullscreen, and get events when + * interesting things happen with them, such as the mouse or keyboard + * interacting with a window. + * + * The video subsystem is also interested in abstracting away some + * platform-specific differences in OpenGL: context creation, swapping + * buffers, etc. This may be crucial to your app, but also you are not + * required to use OpenGL at all. In fact, SDL can provide rendering to those + * windows as well, either with an easy-to-use + * [2D API](https://wiki.libsdl.org/SDL3/CategoryRender) + * or with a more-powerful + * [GPU API](https://wiki.libsdl.org/SDL3/CategoryGPU) + * . Of course, it can simply get out of your way and give you the window + * handles you need to use Vulkan, Direct3D, Metal, or whatever else you like + * directly, too. + * + * The video subsystem covers a lot of functionality, out of necessity, so it + * is worth perusing the list of functions just to see what's available, but + * most apps can get by with simply creating a window and listening for + * events, so start with SDL_CreateWindow() and SDL_PollEvent(). + */ + +#ifndef SDL_video_h_ +#define SDL_video_h_ + +#include +#include +#include +#include +#include +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * This is a unique ID for a display for the time it is connected to the + * system, and is never reused for the lifetime of the application. + * + * If the display is disconnected and reconnected, it will get a new ID. + * + * The value 0 is an invalid ID. + * + * \since This datatype is available since SDL 3.2.0. + */ +typedef Uint32 SDL_DisplayID; + +/** + * This is a unique ID for a window. + * + * The value 0 is an invalid ID. + * + * \since This datatype is available since SDL 3.2.0. + */ +typedef Uint32 SDL_WindowID; + +/* Global video properties... */ + +/** + * The pointer to the global `wl_display` object used by the Wayland video + * backend. + * + * Can be set before the video subsystem is initialized to import an external + * `wl_display` object from an application or toolkit for use in SDL, or read + * after initialization to export the `wl_display` used by the Wayland video + * backend. Setting this property after the video subsystem has been + * initialized has no effect, and reading it when the video subsystem is + * uninitialized will either return the user provided value, if one was set + * prior to initialization, or NULL. See docs/README-wayland.md for more + * information. + * + * \since This macro is available since SDL 3.2.0. + */ +#define SDL_PROP_GLOBAL_VIDEO_WAYLAND_WL_DISPLAY_POINTER "SDL.video.wayland.wl_display" + +/** + * System theme. + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_SystemTheme +{ + SDL_SYSTEM_THEME_UNKNOWN, /**< Unknown system theme */ + SDL_SYSTEM_THEME_LIGHT, /**< Light colored system theme */ + SDL_SYSTEM_THEME_DARK /**< Dark colored system theme */ +} SDL_SystemTheme; + +/** + * Internal display mode data. + * + * This lives as a field in SDL_DisplayMode, as opaque data. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_DisplayMode + */ +typedef struct SDL_DisplayModeData SDL_DisplayModeData; + +/** + * The structure that defines a display mode. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_GetFullscreenDisplayModes + * \sa SDL_GetDesktopDisplayMode + * \sa SDL_GetCurrentDisplayMode + * \sa SDL_SetWindowFullscreenMode + * \sa SDL_GetWindowFullscreenMode + */ +typedef struct SDL_DisplayMode +{ + SDL_DisplayID displayID; /**< the display this mode is associated with */ + SDL_PixelFormat format; /**< pixel format */ + int w; /**< width */ + int h; /**< height */ + float pixel_density; /**< scale converting size to pixels (e.g. a 1920x1080 mode with 2.0 scale would have 3840x2160 pixels) */ + float refresh_rate; /**< refresh rate (or 0.0f for unspecified) */ + int refresh_rate_numerator; /**< precise refresh rate numerator (or 0 for unspecified) */ + int refresh_rate_denominator; /**< precise refresh rate denominator */ + + SDL_DisplayModeData *internal; /**< Private */ + +} SDL_DisplayMode; + +/** + * Display orientation values; the way a display is rotated. + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_DisplayOrientation +{ + SDL_ORIENTATION_UNKNOWN, /**< The display orientation can't be determined */ + SDL_ORIENTATION_LANDSCAPE, /**< The display is in landscape mode, with the right side up, relative to portrait mode */ + SDL_ORIENTATION_LANDSCAPE_FLIPPED, /**< The display is in landscape mode, with the left side up, relative to portrait mode */ + SDL_ORIENTATION_PORTRAIT, /**< The display is in portrait mode */ + SDL_ORIENTATION_PORTRAIT_FLIPPED /**< The display is in portrait mode, upside down */ +} SDL_DisplayOrientation; + +/** + * The struct used as an opaque handle to a window. + * + * \since This struct is available since SDL 3.2.0. + * + * \sa SDL_CreateWindow + */ +typedef struct SDL_Window SDL_Window; + +/** + * The flags on a window. + * + * These cover a lot of true/false, or on/off, window state. Some of it is + * immutable after being set through SDL_CreateWindow(), some of it can be + * changed on existing windows by the app, and some of it might be altered by + * the user or system outside of the app's control. + * + * When creating windows with `SDL_WINDOW_RESIZABLE`, SDL will constrain + * resizable windows to the dimensions recommended by the compositor to fit it + * within the usable desktop space, although some compositors will do this + * automatically without intervention as well. Use `SDL_SetWindowResizable` + * after creation instead if you wish to create a window with a specific size. + * + * \since This datatype is available since SDL 3.2.0. + * + * \sa SDL_GetWindowFlags + */ +typedef Uint64 SDL_WindowFlags; + +#define SDL_WINDOW_FULLSCREEN SDL_UINT64_C(0x0000000000000001) /**< window is in fullscreen mode */ +#define SDL_WINDOW_OPENGL SDL_UINT64_C(0x0000000000000002) /**< window usable with OpenGL context */ +#define SDL_WINDOW_OCCLUDED SDL_UINT64_C(0x0000000000000004) /**< window is occluded */ +#define SDL_WINDOW_HIDDEN SDL_UINT64_C(0x0000000000000008) /**< window is neither mapped onto the desktop nor shown in the taskbar/dock/window list; SDL_ShowWindow() is required for it to become visible */ +#define SDL_WINDOW_BORDERLESS SDL_UINT64_C(0x0000000000000010) /**< no window decoration */ +#define SDL_WINDOW_RESIZABLE SDL_UINT64_C(0x0000000000000020) /**< window can be resized */ +#define SDL_WINDOW_MINIMIZED SDL_UINT64_C(0x0000000000000040) /**< window is minimized */ +#define SDL_WINDOW_MAXIMIZED SDL_UINT64_C(0x0000000000000080) /**< window is maximized */ +#define SDL_WINDOW_MOUSE_GRABBED SDL_UINT64_C(0x0000000000000100) /**< window has grabbed mouse input */ +#define SDL_WINDOW_INPUT_FOCUS SDL_UINT64_C(0x0000000000000200) /**< window has input focus */ +#define SDL_WINDOW_MOUSE_FOCUS SDL_UINT64_C(0x0000000000000400) /**< window has mouse focus */ +#define SDL_WINDOW_EXTERNAL SDL_UINT64_C(0x0000000000000800) /**< window not created by SDL */ +#define SDL_WINDOW_MODAL SDL_UINT64_C(0x0000000000001000) /**< window is modal */ +#define SDL_WINDOW_HIGH_PIXEL_DENSITY SDL_UINT64_C(0x0000000000002000) /**< window uses high pixel density back buffer if possible */ +#define SDL_WINDOW_MOUSE_CAPTURE SDL_UINT64_C(0x0000000000004000) /**< window has mouse captured (unrelated to MOUSE_GRABBED) */ +#define SDL_WINDOW_MOUSE_RELATIVE_MODE SDL_UINT64_C(0x0000000000008000) /**< window has relative mode enabled */ +#define SDL_WINDOW_ALWAYS_ON_TOP SDL_UINT64_C(0x0000000000010000) /**< window should always be above others */ +#define SDL_WINDOW_UTILITY SDL_UINT64_C(0x0000000000020000) /**< window should be treated as a utility window, not showing in the task bar and window list */ +#define SDL_WINDOW_TOOLTIP SDL_UINT64_C(0x0000000000040000) /**< window should be treated as a tooltip and does not get mouse or keyboard focus, requires a parent window */ +#define SDL_WINDOW_POPUP_MENU SDL_UINT64_C(0x0000000000080000) /**< window should be treated as a popup menu, requires a parent window */ +#define SDL_WINDOW_KEYBOARD_GRABBED SDL_UINT64_C(0x0000000000100000) /**< window has grabbed keyboard input */ +#define SDL_WINDOW_FILL_DOCUMENT SDL_UINT64_C(0x0000000000200000) /**< window is in fill-document mode (Emscripten only), since SDL 3.4.0 */ +#define SDL_WINDOW_VULKAN SDL_UINT64_C(0x0000000010000000) /**< window usable for Vulkan surface */ +#define SDL_WINDOW_METAL SDL_UINT64_C(0x0000000020000000) /**< window usable for Metal view */ +#define SDL_WINDOW_TRANSPARENT SDL_UINT64_C(0x0000000040000000) /**< window with transparent buffer */ +#define SDL_WINDOW_NOT_FOCUSABLE SDL_UINT64_C(0x0000000080000000) /**< window should not be focusable */ + + +/** + * A magic value used with SDL_WINDOWPOS_UNDEFINED. + * + * Generally this macro isn't used directly, but rather through + * SDL_WINDOWPOS_UNDEFINED or SDL_WINDOWPOS_UNDEFINED_DISPLAY. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_SetWindowPosition + */ +#define SDL_WINDOWPOS_UNDEFINED_MASK 0x1FFF0000u + +/** + * Used to indicate that you don't care what the window position is. + * + * If you _really_ don't care, SDL_WINDOWPOS_UNDEFINED is the same, but always + * uses the primary display instead of specifying one. + * + * \param X the SDL_DisplayID of the display to use. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_SetWindowPosition + */ +#define SDL_WINDOWPOS_UNDEFINED_DISPLAY(X) (SDL_WINDOWPOS_UNDEFINED_MASK|(X)) + +/** + * Used to indicate that you don't care what the window position/display is. + * + * This always uses the primary display. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_SetWindowPosition + */ +#define SDL_WINDOWPOS_UNDEFINED SDL_WINDOWPOS_UNDEFINED_DISPLAY(0) + +/** + * A macro to test if the window position is marked as "undefined." + * + * \param X the window position value. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_SetWindowPosition + */ +#define SDL_WINDOWPOS_ISUNDEFINED(X) (((X)&0xFFFF0000) == SDL_WINDOWPOS_UNDEFINED_MASK) + +/** + * A magic value used with SDL_WINDOWPOS_CENTERED. + * + * Generally this macro isn't used directly, but rather through + * SDL_WINDOWPOS_CENTERED or SDL_WINDOWPOS_CENTERED_DISPLAY. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_SetWindowPosition + */ +#define SDL_WINDOWPOS_CENTERED_MASK 0x2FFF0000u + +/** + * Used to indicate that the window position should be centered. + * + * SDL_WINDOWPOS_CENTERED is the same, but always uses the primary display + * instead of specifying one. + * + * \param X the SDL_DisplayID of the display to use. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_SetWindowPosition + */ +#define SDL_WINDOWPOS_CENTERED_DISPLAY(X) (SDL_WINDOWPOS_CENTERED_MASK|(X)) + +/** + * Used to indicate that the window position should be centered. + * + * This always uses the primary display. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_SetWindowPosition + */ +#define SDL_WINDOWPOS_CENTERED SDL_WINDOWPOS_CENTERED_DISPLAY(0) + +/** + * A macro to test if the window position is marked as "centered." + * + * \param X the window position value. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_GetWindowPosition + */ +#define SDL_WINDOWPOS_ISCENTERED(X) \ + (((X)&0xFFFF0000) == SDL_WINDOWPOS_CENTERED_MASK) + + +/** + * Window flash operation. + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_FlashOperation +{ + SDL_FLASH_CANCEL, /**< Cancel any window flash state */ + SDL_FLASH_BRIEFLY, /**< Flash the window briefly to get attention */ + SDL_FLASH_UNTIL_FOCUSED /**< Flash the window until it gets focus */ +} SDL_FlashOperation; + +/** + * Window progress state + * + * \since This enum is available since SDL 3.2.8. + */ +typedef enum SDL_ProgressState +{ + SDL_PROGRESS_STATE_INVALID = -1, /**< An invalid progress state indicating an error; check SDL_GetError() */ + SDL_PROGRESS_STATE_NONE, /**< No progress bar is shown */ + SDL_PROGRESS_STATE_INDETERMINATE, /**< The progress bar is shown in a indeterminate state */ + SDL_PROGRESS_STATE_NORMAL, /**< The progress bar is shown in a normal state */ + SDL_PROGRESS_STATE_PAUSED, /**< The progress bar is shown in a paused state */ + SDL_PROGRESS_STATE_ERROR /**< The progress bar is shown in a state indicating the application had an error */ +} SDL_ProgressState; + +/** + * An opaque handle to an OpenGL context. + * + * \since This datatype is available since SDL 3.2.0. + * + * \sa SDL_GL_CreateContext + * \sa SDL_GL_SetAttribute + * \sa SDL_GL_MakeCurrent + * \sa SDL_GL_DestroyContext + */ +typedef struct SDL_GLContextState *SDL_GLContext; + +/** + * Opaque type for an EGL display. + * + * \since This datatype is available since SDL 3.2.0. + */ +typedef void *SDL_EGLDisplay; + +/** + * Opaque type for an EGL config. + * + * \since This datatype is available since SDL 3.2.0. + */ +typedef void *SDL_EGLConfig; + +/** + * Opaque type for an EGL surface. + * + * \since This datatype is available since SDL 3.2.0. + */ +typedef void *SDL_EGLSurface; + +/** + * An EGL attribute, used when creating an EGL context. + * + * \since This datatype is available since SDL 3.2.0. + */ +typedef intptr_t SDL_EGLAttrib; + +/** + * An EGL integer attribute, used when creating an EGL surface. + * + * \since This datatype is available since SDL 3.2.0. + */ +typedef int SDL_EGLint; + +/** + * EGL platform attribute initialization callback. + * + * This is called when SDL is attempting to create an EGL context, to let the + * app add extra attributes to its eglGetPlatformDisplay() call. + * + * The callback should return a pointer to an EGL attribute array terminated + * with `EGL_NONE`. If this function returns NULL, the SDL_CreateWindow + * process will fail gracefully. + * + * The returned pointer should be allocated with SDL_malloc() and will be + * passed to SDL_free(). + * + * The arrays returned by each callback will be appended to the existing + * attribute arrays defined by SDL. + * + * \param userdata an app-controlled pointer that is passed to the callback. + * \returns a newly-allocated array of attributes, terminated with `EGL_NONE`. + * + * \since This datatype is available since SDL 3.2.0. + * + * \sa SDL_EGL_SetAttributeCallbacks + */ +typedef SDL_EGLAttrib *(SDLCALL *SDL_EGLAttribArrayCallback)(void *userdata); + +/** + * EGL surface/context attribute initialization callback types. + * + * This is called when SDL is attempting to create an EGL surface, to let the + * app add extra attributes to its eglCreateWindowSurface() or + * eglCreateContext calls. + * + * For convenience, the EGLDisplay and EGLConfig to use are provided to the + * callback. + * + * The callback should return a pointer to an EGL attribute array terminated + * with `EGL_NONE`. If this function returns NULL, the SDL_CreateWindow + * process will fail gracefully. + * + * The returned pointer should be allocated with SDL_malloc() and will be + * passed to SDL_free(). + * + * The arrays returned by each callback will be appended to the existing + * attribute arrays defined by SDL. + * + * \param userdata an app-controlled pointer that is passed to the callback. + * \param display the EGL display to be used. + * \param config the EGL config to be used. + * \returns a newly-allocated array of attributes, terminated with `EGL_NONE`. + * + * \since This datatype is available since SDL 3.2.0. + * + * \sa SDL_EGL_SetAttributeCallbacks + */ +typedef SDL_EGLint *(SDLCALL *SDL_EGLIntArrayCallback)(void *userdata, SDL_EGLDisplay display, SDL_EGLConfig config); + +/** + * An enumeration of OpenGL configuration attributes. + * + * While you can set most OpenGL attributes normally, the attributes listed + * above must be known before SDL creates the window that will be used with + * the OpenGL context. These attributes are set and read with + * SDL_GL_SetAttribute() and SDL_GL_GetAttribute(). + * + * In some cases, these attributes are minimum requests; the GL does not + * promise to give you exactly what you asked for. It's possible to ask for a + * 16-bit depth buffer and get a 24-bit one instead, for example, or to ask + * for no stencil buffer and still have one available. Context creation should + * fail if the GL can't provide your requested attributes at a minimum, but + * you should check to see exactly what you got. + * + * \since This enum is available since SDL 3.2.0. + */ +typedef enum SDL_GLAttr +{ + SDL_GL_RED_SIZE, /**< the minimum number of bits for the red channel of the color buffer; defaults to 8. */ + SDL_GL_GREEN_SIZE, /**< the minimum number of bits for the green channel of the color buffer; defaults to 8. */ + SDL_GL_BLUE_SIZE, /**< the minimum number of bits for the blue channel of the color buffer; defaults to 8. */ + SDL_GL_ALPHA_SIZE, /**< the minimum number of bits for the alpha channel of the color buffer; defaults to 8. */ + SDL_GL_BUFFER_SIZE, /**< the minimum number of bits for frame buffer size; defaults to 0. */ + SDL_GL_DOUBLEBUFFER, /**< whether the output is single or double buffered; defaults to double buffering on. */ + SDL_GL_DEPTH_SIZE, /**< the minimum number of bits in the depth buffer; defaults to 16. */ + SDL_GL_STENCIL_SIZE, /**< the minimum number of bits in the stencil buffer; defaults to 0. */ + SDL_GL_ACCUM_RED_SIZE, /**< the minimum number of bits for the red channel of the accumulation buffer; defaults to 0. */ + SDL_GL_ACCUM_GREEN_SIZE, /**< the minimum number of bits for the green channel of the accumulation buffer; defaults to 0. */ + SDL_GL_ACCUM_BLUE_SIZE, /**< the minimum number of bits for the blue channel of the accumulation buffer; defaults to 0. */ + SDL_GL_ACCUM_ALPHA_SIZE, /**< the minimum number of bits for the alpha channel of the accumulation buffer; defaults to 0. */ + SDL_GL_STEREO, /**< whether the output is stereo 3D; defaults to off. */ + SDL_GL_MULTISAMPLEBUFFERS, /**< the number of buffers used for multisample anti-aliasing; defaults to 0. */ + SDL_GL_MULTISAMPLESAMPLES, /**< the number of samples used around the current pixel used for multisample anti-aliasing. */ + SDL_GL_ACCELERATED_VISUAL, /**< set to 1 to require hardware acceleration, set to 0 to force software rendering; defaults to allow either. */ + SDL_GL_RETAINED_BACKING, /**< not used (deprecated). */ + SDL_GL_CONTEXT_MAJOR_VERSION, /**< OpenGL context major version. */ + SDL_GL_CONTEXT_MINOR_VERSION, /**< OpenGL context minor version. */ + SDL_GL_CONTEXT_FLAGS, /**< some combination of 0 or more of elements of the SDL_GLContextFlag enumeration; defaults to 0. */ + SDL_GL_CONTEXT_PROFILE_MASK, /**< type of GL context (Core, Compatibility, ES). See SDL_GLProfile; default value depends on platform. */ + SDL_GL_SHARE_WITH_CURRENT_CONTEXT, /**< OpenGL context sharing; defaults to 0. */ + SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, /**< requests sRGB-capable visual if 1. Defaults to -1 ("don't care"). This is a request; GL drivers might not comply! */ + SDL_GL_CONTEXT_RELEASE_BEHAVIOR, /**< sets context the release behavior. See SDL_GLContextReleaseFlag; defaults to FLUSH. */ + SDL_GL_CONTEXT_RESET_NOTIFICATION, /**< set context reset notification. See SDL_GLContextResetNotification; defaults to NO_NOTIFICATION. */ + SDL_GL_CONTEXT_NO_ERROR, + SDL_GL_FLOATBUFFERS, + SDL_GL_EGL_PLATFORM +} SDL_GLAttr; + +/** + * Possible values to be set for the SDL_GL_CONTEXT_PROFILE_MASK attribute. + * + * \since This datatype is available since SDL 3.2.0. + */ +typedef Uint32 SDL_GLProfile; + +#define SDL_GL_CONTEXT_PROFILE_CORE 0x0001 /**< OpenGL Core Profile context */ +#define SDL_GL_CONTEXT_PROFILE_COMPATIBILITY 0x0002 /**< OpenGL Compatibility Profile context */ +#define SDL_GL_CONTEXT_PROFILE_ES 0x0004 /**< GLX_CONTEXT_ES2_PROFILE_BIT_EXT */ + + +/** + * Possible flags to be set for the SDL_GL_CONTEXT_FLAGS attribute. + * + * \since This datatype is available since SDL 3.2.0. + */ +typedef Uint32 SDL_GLContextFlag; + +#define SDL_GL_CONTEXT_DEBUG_FLAG 0x0001 +#define SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG 0x0002 +#define SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG 0x0004 +#define SDL_GL_CONTEXT_RESET_ISOLATION_FLAG 0x0008 + + +/** + * Possible values to be set for the SDL_GL_CONTEXT_RELEASE_BEHAVIOR + * attribute. + * + * \since This datatype is available since SDL 3.2.0. + */ +typedef Uint32 SDL_GLContextReleaseFlag; + +#define SDL_GL_CONTEXT_RELEASE_BEHAVIOR_NONE 0x0000 +#define SDL_GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH 0x0001 + + +/** + * Possible values to be set SDL_GL_CONTEXT_RESET_NOTIFICATION attribute. + * + * \since This datatype is available since SDL 3.2.0. + */ +typedef Uint32 SDL_GLContextResetNotification; + +#define SDL_GL_CONTEXT_RESET_NO_NOTIFICATION 0x0000 +#define SDL_GL_CONTEXT_RESET_LOSE_CONTEXT 0x0001 + + +/* Function prototypes */ + +/** + * Get the number of video drivers compiled into SDL. + * + * \returns the number of built in video drivers. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetVideoDriver + */ +extern SDL_DECLSPEC int SDLCALL SDL_GetNumVideoDrivers(void); + +/** + * Get the name of a built in video driver. + * + * The video drivers are presented in the order in which they are normally + * checked during initialization. + * + * The names of drivers are all simple, low-ASCII identifiers, like "cocoa", + * "x11" or "windows". These never have Unicode characters, and are not meant + * to be proper names. + * + * \param index the index of a video driver. + * \returns the name of the video driver with the given **index**, or NULL if + * index is out of bounds. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetNumVideoDrivers + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetVideoDriver(int index); + +/** + * Get the name of the currently initialized video driver. + * + * The names of drivers are all simple, low-ASCII identifiers, like "cocoa", + * "x11" or "windows". These never have Unicode characters, and are not meant + * to be proper names. + * + * \returns the name of the current video driver or NULL if no driver has been + * initialized. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetNumVideoDrivers + * \sa SDL_GetVideoDriver + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetCurrentVideoDriver(void); + +/** + * Get the current system theme. + * + * \returns the current system theme, light, dark, or unknown. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_SystemTheme SDLCALL SDL_GetSystemTheme(void); + +/** + * Get a list of currently connected displays. + * + * \param count a pointer filled in with the number of displays returned, may + * be NULL. + * \returns a 0 terminated array of display instance IDs or NULL on failure; + * call SDL_GetError() for more information. This should be freed + * with SDL_free() when it is no longer needed. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_DisplayID * SDLCALL SDL_GetDisplays(int *count); + +/** + * Return the primary display. + * + * \returns the instance ID of the primary display on success or 0 on failure; + * call SDL_GetError() for more information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetDisplays + */ +extern SDL_DECLSPEC SDL_DisplayID SDLCALL SDL_GetPrimaryDisplay(void); + +/** + * Get the properties associated with a display. + * + * The following read-only properties are provided by SDL: + * + * - `SDL_PROP_DISPLAY_HDR_ENABLED_BOOLEAN`: true if the display has HDR + * headroom above the SDR white point. This is for informational and + * diagnostic purposes only, as not all platforms provide this information + * at the display level. + * + * On KMS/DRM: + * + * - `SDL_PROP_DISPLAY_KMSDRM_PANEL_ORIENTATION_NUMBER`: the "panel + * orientation" property for the display in degrees of clockwise rotation. + * Note that this is provided only as a hint, and the application is + * responsible for any coordinate transformations needed to conform to the + * requested display orientation. + * + * On Wayland: + * + * - `SDL_PROP_DISPLAY_WAYLAND_WL_OUTPUT_POINTER`: the wl_output associated + * with the display + * + * On Windows: + * + * - `SDL_PROP_DISPLAY_WINDOWS_HMONITOR_POINTER`: the monitor handle + * (HMONITOR) associated with the display + * + * \param displayID the instance ID of the display to query. + * \returns a valid property ID on success or 0 on failure; call + * SDL_GetError() for more information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetDisplayProperties(SDL_DisplayID displayID); + +#define SDL_PROP_DISPLAY_HDR_ENABLED_BOOLEAN "SDL.display.HDR_enabled" +#define SDL_PROP_DISPLAY_KMSDRM_PANEL_ORIENTATION_NUMBER "SDL.display.KMSDRM.panel_orientation" +#define SDL_PROP_DISPLAY_WAYLAND_WL_OUTPUT_POINTER "SDL.display.wayland.wl_output" +#define SDL_PROP_DISPLAY_WINDOWS_HMONITOR_POINTER "SDL.display.windows.hmonitor" + +/** + * Get the name of a display in UTF-8 encoding. + * + * \param displayID the instance ID of the display to query. + * \returns the name of a display or NULL on failure; call SDL_GetError() for + * more information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetDisplays + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetDisplayName(SDL_DisplayID displayID); + +/** + * Get the desktop area represented by a display. + * + * The primary display is often located at (0,0), but may be placed at a + * different location depending on monitor layout. + * + * \param displayID the instance ID of the display to query. + * \param rect the SDL_Rect structure filled in with the display bounds. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetDisplayUsableBounds + * \sa SDL_GetDisplays + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetDisplayBounds(SDL_DisplayID displayID, SDL_Rect *rect); + +/** + * Get the usable desktop area represented by a display, in screen + * coordinates. + * + * This is the same area as SDL_GetDisplayBounds() reports, but with portions + * reserved by the system removed. For example, on Apple's macOS, this + * subtracts the area occupied by the menu bar and dock. + * + * Setting a window to be fullscreen generally bypasses these unusable areas, + * so these are good guidelines for the maximum space available to a + * non-fullscreen window. + * + * \param displayID the instance ID of the display to query. + * \param rect the SDL_Rect structure filled in with the display bounds. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetDisplayBounds + * \sa SDL_GetDisplays + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetDisplayUsableBounds(SDL_DisplayID displayID, SDL_Rect *rect); + +/** + * Get the orientation of a display when it is unrotated. + * + * \param displayID the instance ID of the display to query. + * \returns the SDL_DisplayOrientation enum value of the display, or + * `SDL_ORIENTATION_UNKNOWN` if it isn't available. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetDisplays + */ +extern SDL_DECLSPEC SDL_DisplayOrientation SDLCALL SDL_GetNaturalDisplayOrientation(SDL_DisplayID displayID); + +/** + * Get the orientation of a display. + * + * \param displayID the instance ID of the display to query. + * \returns the SDL_DisplayOrientation enum value of the display, or + * `SDL_ORIENTATION_UNKNOWN` if it isn't available. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetDisplays + */ +extern SDL_DECLSPEC SDL_DisplayOrientation SDLCALL SDL_GetCurrentDisplayOrientation(SDL_DisplayID displayID); + +/** + * Get the content scale of a display. + * + * The content scale is the expected scale for content based on the DPI + * settings of the display. For example, a 4K display might have a 2.0 (200%) + * display scale, which means that the user expects UI elements to be twice as + * big on this display, to aid in readability. + * + * After window creation, SDL_GetWindowDisplayScale() should be used to query + * the content scale factor for individual windows instead of querying the + * display for a window and calling this function, as the per-window content + * scale factor may differ from the base value of the display it is on, + * particularly on high-DPI and/or multi-monitor desktop configurations. + * + * \param displayID the instance ID of the display to query. + * \returns the content scale of the display, or 0.0f on failure; call + * SDL_GetError() for more information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetWindowDisplayScale + * \sa SDL_GetDisplays + */ +extern SDL_DECLSPEC float SDLCALL SDL_GetDisplayContentScale(SDL_DisplayID displayID); + +/** + * Get a list of fullscreen display modes available on a display. + * + * The display modes are sorted in this priority: + * + * - w -> largest to smallest + * - h -> largest to smallest + * - bits per pixel -> more colors to fewer colors + * - packed pixel layout -> largest to smallest + * - refresh rate -> highest to lowest + * - pixel density -> lowest to highest + * + * \param displayID the instance ID of the display to query. + * \param count a pointer filled in with the number of display modes returned, + * may be NULL. + * \returns a NULL terminated array of display mode pointers or NULL on + * failure; call SDL_GetError() for more information. This is a + * single allocation that should be freed with SDL_free() when it is + * no longer needed. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetDisplays + */ +extern SDL_DECLSPEC SDL_DisplayMode ** SDLCALL SDL_GetFullscreenDisplayModes(SDL_DisplayID displayID, int *count); + +/** + * Get the closest match to the requested display mode. + * + * The available display modes are scanned and `closest` is filled in with the + * closest mode matching the requested mode and returned. The mode format and + * refresh rate default to the desktop mode if they are set to 0. The modes + * are scanned with size being first priority, format being second priority, + * and finally checking the refresh rate. If all the available modes are too + * small, then false is returned. + * + * \param displayID the instance ID of the display to query. + * \param w the width in pixels of the desired display mode. + * \param h the height in pixels of the desired display mode. + * \param refresh_rate the refresh rate of the desired display mode, or 0.0f + * for the desktop refresh rate. + * \param include_high_density_modes boolean to include high density modes in + * the search. + * \param closest a pointer filled in with the closest display mode equal to + * or larger than the desired mode. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetDisplays + * \sa SDL_GetFullscreenDisplayModes + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetClosestFullscreenDisplayMode(SDL_DisplayID displayID, int w, int h, float refresh_rate, bool include_high_density_modes, SDL_DisplayMode *closest); + +/** + * Get information about the desktop's display mode. + * + * There's a difference between this function and SDL_GetCurrentDisplayMode() + * when SDL runs fullscreen and has changed the resolution. In that case this + * function will return the previous native display mode, and not the current + * display mode. + * + * \param displayID the instance ID of the display to query. + * \returns a pointer to the desktop display mode or NULL on failure; call + * SDL_GetError() for more information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetCurrentDisplayMode + * \sa SDL_GetDisplays + */ +extern SDL_DECLSPEC const SDL_DisplayMode * SDLCALL SDL_GetDesktopDisplayMode(SDL_DisplayID displayID); + +/** + * Get information about the current display mode. + * + * There's a difference between this function and SDL_GetDesktopDisplayMode() + * when SDL runs fullscreen and has changed the resolution. In that case this + * function will return the current display mode, and not the previous native + * display mode. + * + * \param displayID the instance ID of the display to query. + * \returns a pointer to the desktop display mode or NULL on failure; call + * SDL_GetError() for more information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetDesktopDisplayMode + * \sa SDL_GetDisplays + */ +extern SDL_DECLSPEC const SDL_DisplayMode * SDLCALL SDL_GetCurrentDisplayMode(SDL_DisplayID displayID); + +/** + * Get the display containing a point. + * + * \param point the point to query. + * \returns the instance ID of the display containing the point or 0 on + * failure; call SDL_GetError() for more information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetDisplayBounds + * \sa SDL_GetDisplays + */ +extern SDL_DECLSPEC SDL_DisplayID SDLCALL SDL_GetDisplayForPoint(const SDL_Point *point); + +/** + * Get the display primarily containing a rect. + * + * \param rect the rect to query. + * \returns the instance ID of the display entirely containing the rect or + * closest to the center of the rect on success or 0 on failure; call + * SDL_GetError() for more information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetDisplayBounds + * \sa SDL_GetDisplays + */ +extern SDL_DECLSPEC SDL_DisplayID SDLCALL SDL_GetDisplayForRect(const SDL_Rect *rect); + +/** + * Get the display associated with a window. + * + * \param window the window to query. + * \returns the instance ID of the display containing the center of the window + * on success or 0 on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetDisplayBounds + * \sa SDL_GetDisplays + */ +extern SDL_DECLSPEC SDL_DisplayID SDLCALL SDL_GetDisplayForWindow(SDL_Window *window); + +/** + * Get the pixel density of a window. + * + * This is a ratio of pixel size to window size. For example, if the window is + * 1920x1080 and it has a high density back buffer of 3840x2160 pixels, it + * would have a pixel density of 2.0. + * + * \param window the window to query. + * \returns the pixel density or 0.0f on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetWindowDisplayScale + */ +extern SDL_DECLSPEC float SDLCALL SDL_GetWindowPixelDensity(SDL_Window *window); + +/** + * Get the content display scale relative to a window's pixel size. + * + * This is a combination of the window pixel density and the display content + * scale, and is the expected scale for displaying content in this window. For + * example, if a 3840x2160 window had a display scale of 2.0, the user expects + * the content to take twice as many pixels and be the same physical size as + * if it were being displayed in a 1920x1080 window with a display scale of + * 1.0. + * + * Conceptually this value corresponds to the scale display setting, and is + * updated when that setting is changed, or the window moves to a display with + * a different scale setting. + * + * \param window the window to query. + * \returns the display scale, or 0.0f on failure; call SDL_GetError() for + * more information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC float SDLCALL SDL_GetWindowDisplayScale(SDL_Window *window); + +/** + * Set the display mode to use when a window is visible and fullscreen. + * + * This only affects the display mode used when the window is fullscreen. To + * change the window size when the window is not fullscreen, use + * SDL_SetWindowSize(). + * + * If the window is currently in the fullscreen state, this request is + * asynchronous on some windowing systems and the new mode dimensions may not + * be applied immediately upon the return of this function. If an immediate + * change is required, call SDL_SyncWindow() to block until the changes have + * taken effect. + * + * When the new mode takes effect, an SDL_EVENT_WINDOW_RESIZED and/or an + * SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED event will be emitted with the new mode + * dimensions. + * + * \param window the window to affect. + * \param mode a pointer to the display mode to use, which can be NULL for + * borderless fullscreen desktop mode, or one of the fullscreen + * modes returned by SDL_GetFullscreenDisplayModes() to set an + * exclusive fullscreen mode. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetWindowFullscreenMode + * \sa SDL_SetWindowFullscreen + * \sa SDL_SyncWindow + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowFullscreenMode(SDL_Window *window, const SDL_DisplayMode *mode); + +/** + * Query the display mode to use when a window is visible at fullscreen. + * + * \param window the window to query. + * \returns a pointer to the exclusive fullscreen mode to use or NULL for + * borderless fullscreen desktop mode. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetWindowFullscreenMode + * \sa SDL_SetWindowFullscreen + */ +extern SDL_DECLSPEC const SDL_DisplayMode * SDLCALL SDL_GetWindowFullscreenMode(SDL_Window *window); + +/** + * Get the raw ICC profile data for the screen the window is currently on. + * + * \param window the window to query. + * \param size the size of the ICC profile. + * \returns the raw ICC profile data on success or NULL on failure; call + * SDL_GetError() for more information. This should be freed with + * SDL_free() when it is no longer needed. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void * SDLCALL SDL_GetWindowICCProfile(SDL_Window *window, size_t *size); + +/** + * Get the pixel format associated with the window. + * + * \param window the window to query. + * \returns the pixel format of the window on success or + * SDL_PIXELFORMAT_UNKNOWN on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_PixelFormat SDLCALL SDL_GetWindowPixelFormat(SDL_Window *window); + +/** + * Get a list of valid windows. + * + * \param count a pointer filled in with the number of windows returned, may + * be NULL. + * \returns a NULL terminated array of SDL_Window pointers or NULL on failure; + * call SDL_GetError() for more information. This is a single + * allocation that should be freed with SDL_free() when it is no + * longer needed. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_Window ** SDLCALL SDL_GetWindows(int *count); + +/** + * Create a window with the specified dimensions and flags. + * + * The window size is a request and may be different than expected based on + * the desktop layout and window manager policies. Your application should be + * prepared to handle a window of any size. + * + * `flags` may be any of the following OR'd together: + * + * - `SDL_WINDOW_FULLSCREEN`: fullscreen window at desktop resolution + * - `SDL_WINDOW_OPENGL`: window usable with an OpenGL context + * - `SDL_WINDOW_HIDDEN`: window is not visible + * - `SDL_WINDOW_BORDERLESS`: no window decoration + * - `SDL_WINDOW_RESIZABLE`: window can be resized + * - `SDL_WINDOW_MINIMIZED`: window is minimized + * - `SDL_WINDOW_MAXIMIZED`: window is maximized + * - `SDL_WINDOW_MOUSE_GRABBED`: window has grabbed mouse focus + * - `SDL_WINDOW_INPUT_FOCUS`: window has input focus + * - `SDL_WINDOW_MOUSE_FOCUS`: window has mouse focus + * - `SDL_WINDOW_EXTERNAL`: window not created by SDL + * - `SDL_WINDOW_MODAL`: window is modal + * - `SDL_WINDOW_HIGH_PIXEL_DENSITY`: window uses high pixel density back + * buffer if possible + * - `SDL_WINDOW_MOUSE_CAPTURE`: window has mouse captured (unrelated to + * MOUSE_GRABBED) + * - `SDL_WINDOW_ALWAYS_ON_TOP`: window should always be above others + * - `SDL_WINDOW_UTILITY`: window should be treated as a utility window, not + * showing in the task bar and window list + * - `SDL_WINDOW_TOOLTIP`: window should be treated as a tooltip and does not + * get mouse or keyboard focus, requires a parent window + * - `SDL_WINDOW_POPUP_MENU`: window should be treated as a popup menu, + * requires a parent window + * - `SDL_WINDOW_KEYBOARD_GRABBED`: window has grabbed keyboard input + * - `SDL_WINDOW_VULKAN`: window usable with a Vulkan instance + * - `SDL_WINDOW_METAL`: window usable with a Metal instance + * - `SDL_WINDOW_TRANSPARENT`: window with transparent buffer + * - `SDL_WINDOW_NOT_FOCUSABLE`: window should not be focusable + * + * The SDL_Window will be shown if SDL_WINDOW_HIDDEN is not set. If hidden at + * creation time, SDL_ShowWindow() can be used to show it later. + * + * On Apple's macOS, you **must** set the NSHighResolutionCapable Info.plist + * property to YES, otherwise you will not receive a High-DPI OpenGL canvas. + * + * The window pixel size may differ from its window coordinate size if the + * window is on a high pixel density display. Use SDL_GetWindowSize() to query + * the client area's size in window coordinates, and + * SDL_GetWindowSizeInPixels() or SDL_GetRenderOutputSize() to query the + * drawable size in pixels. Note that the drawable size can vary after the + * window is created and should be queried again if you get an + * SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED event. + * + * If the window is created with any of the SDL_WINDOW_OPENGL or + * SDL_WINDOW_VULKAN flags, then the corresponding LoadLibrary function + * (SDL_GL_LoadLibrary or SDL_Vulkan_LoadLibrary) is called and the + * corresponding UnloadLibrary function is called by SDL_DestroyWindow(). + * + * If SDL_WINDOW_VULKAN is specified and there isn't a working Vulkan driver, + * SDL_CreateWindow() will fail, because SDL_Vulkan_LoadLibrary() will fail. + * + * If SDL_WINDOW_METAL is specified on an OS that does not support Metal, + * SDL_CreateWindow() will fail. + * + * If you intend to use this window with an SDL_Renderer, you should use + * SDL_CreateWindowAndRenderer() instead of this function, to avoid window + * flicker. + * + * On non-Apple devices, SDL requires you to either not link to the Vulkan + * loader or link to a dynamic library version. This limitation may be removed + * in a future version of SDL. + * + * \param title the title of the window, in UTF-8 encoding. + * \param w the width of the window. + * \param h the height of the window. + * \param flags 0, or one or more SDL_WindowFlags OR'd together. + * \returns the window that was created or NULL on failure; call + * SDL_GetError() for more information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateWindowAndRenderer + * \sa SDL_CreatePopupWindow + * \sa SDL_CreateWindowWithProperties + * \sa SDL_DestroyWindow + */ +extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_CreateWindow(const char *title, int w, int h, SDL_WindowFlags flags); + +/** + * Create a child popup window of the specified parent window. + * + * The window size is a request and may be different than expected based on + * the desktop layout and window manager policies. Your application should be + * prepared to handle a window of any size. + * + * The flags parameter **must** contain at least one of the following: + * + * - `SDL_WINDOW_TOOLTIP`: The popup window is a tooltip and will not pass any + * input events. + * - `SDL_WINDOW_POPUP_MENU`: The popup window is a popup menu. The topmost + * popup menu will implicitly gain the keyboard focus. + * + * The following flags are not relevant to popup window creation and will be + * ignored: + * + * - `SDL_WINDOW_MINIMIZED` + * - `SDL_WINDOW_MAXIMIZED` + * - `SDL_WINDOW_FULLSCREEN` + * - `SDL_WINDOW_BORDERLESS` + * + * The following flags are incompatible with popup window creation and will + * cause it to fail: + * + * - `SDL_WINDOW_UTILITY` + * - `SDL_WINDOW_MODAL` + * + * The parent parameter **must** be non-null and a valid window. The parent of + * a popup window can be either a regular, toplevel window, or another popup + * window. + * + * Popup windows cannot be minimized, maximized, made fullscreen, raised, + * flash, be made a modal window, be the parent of a toplevel window, or grab + * the mouse and/or keyboard. Attempts to do so will fail. + * + * Popup windows implicitly do not have a border/decorations and do not appear + * on the taskbar/dock or in lists of windows such as alt-tab menus. + * + * By default, popup window positions will automatically be constrained to + * keep the entire window within display bounds. This can be overridden with + * the `SDL_PROP_WINDOW_CREATE_CONSTRAIN_POPUP_BOOLEAN` property. + * + * By default, popup menus will automatically grab keyboard focus from the + * parent when shown. This behavior can be overridden by setting the + * `SDL_WINDOW_NOT_FOCUSABLE` flag, setting the + * `SDL_PROP_WINDOW_CREATE_FOCUSABLE_BOOLEAN` property to false, or toggling + * it after creation via the `SDL_SetWindowFocusable()` function. + * + * If a parent window is hidden or destroyed, any child popup windows will be + * recursively hidden or destroyed as well. Child popup windows not explicitly + * hidden will be restored when the parent is shown. + * + * \param parent the parent of the window, must not be NULL. + * \param offset_x the x position of the popup window relative to the origin + * of the parent. + * \param offset_y the y position of the popup window relative to the origin + * of the parent window. + * \param w the width of the window. + * \param h the height of the window. + * \param flags SDL_WINDOW_TOOLTIP or SDL_WINDOW_POPUP_MENU, and zero or more + * additional SDL_WindowFlags OR'd together. + * \returns the window that was created or NULL on failure; call + * SDL_GetError() for more information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateWindow + * \sa SDL_CreateWindowWithProperties + * \sa SDL_DestroyWindow + * \sa SDL_GetWindowParent + */ +extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_CreatePopupWindow(SDL_Window *parent, int offset_x, int offset_y, int w, int h, SDL_WindowFlags flags); + +/** + * Create a window with the specified properties. + * + * The window size is a request and may be different than expected based on + * the desktop layout and window manager policies. Your application should be + * prepared to handle a window of any size. + * + * These are the supported properties: + * + * - `SDL_PROP_WINDOW_CREATE_ALWAYS_ON_TOP_BOOLEAN`: true if the window should + * be always on top + * - `SDL_PROP_WINDOW_CREATE_BORDERLESS_BOOLEAN`: true if the window has no + * window decoration + * - `SDL_PROP_WINDOW_CREATE_CONSTRAIN_POPUP_BOOLEAN`: true if the "tooltip" + * and "menu" window types should be automatically constrained to be + * entirely within display bounds (default), false if no constraints on the + * position are desired. + * - `SDL_PROP_WINDOW_CREATE_EXTERNAL_GRAPHICS_CONTEXT_BOOLEAN`: true if the + * window will be used with an externally managed graphics context. + * - `SDL_PROP_WINDOW_CREATE_FOCUSABLE_BOOLEAN`: true if the window should + * accept keyboard input (defaults true) + * - `SDL_PROP_WINDOW_CREATE_FULLSCREEN_BOOLEAN`: true if the window should + * start in fullscreen mode at desktop resolution + * - `SDL_PROP_WINDOW_CREATE_HEIGHT_NUMBER`: the height of the window + * - `SDL_PROP_WINDOW_CREATE_HIDDEN_BOOLEAN`: true if the window should start + * hidden + * - `SDL_PROP_WINDOW_CREATE_HIGH_PIXEL_DENSITY_BOOLEAN`: true if the window + * uses a high pixel density buffer if possible + * - `SDL_PROP_WINDOW_CREATE_MAXIMIZED_BOOLEAN`: true if the window should + * start maximized + * - `SDL_PROP_WINDOW_CREATE_MENU_BOOLEAN`: true if the window is a popup menu + * - `SDL_PROP_WINDOW_CREATE_METAL_BOOLEAN`: true if the window will be used + * with Metal rendering + * - `SDL_PROP_WINDOW_CREATE_MINIMIZED_BOOLEAN`: true if the window should + * start minimized + * - `SDL_PROP_WINDOW_CREATE_MODAL_BOOLEAN`: true if the window is modal to + * its parent + * - `SDL_PROP_WINDOW_CREATE_MOUSE_GRABBED_BOOLEAN`: true if the window starts + * with grabbed mouse focus + * - `SDL_PROP_WINDOW_CREATE_OPENGL_BOOLEAN`: true if the window will be used + * with OpenGL rendering + * - `SDL_PROP_WINDOW_CREATE_PARENT_POINTER`: an SDL_Window that will be the + * parent of this window, required for windows with the "tooltip", "menu", + * and "modal" properties + * - `SDL_PROP_WINDOW_CREATE_RESIZABLE_BOOLEAN`: true if the window should be + * resizable + * - `SDL_PROP_WINDOW_CREATE_TITLE_STRING`: the title of the window, in UTF-8 + * encoding + * - `SDL_PROP_WINDOW_CREATE_TRANSPARENT_BOOLEAN`: true if the window show + * transparent in the areas with alpha of 0 + * - `SDL_PROP_WINDOW_CREATE_TOOLTIP_BOOLEAN`: true if the window is a tooltip + * - `SDL_PROP_WINDOW_CREATE_UTILITY_BOOLEAN`: true if the window is a utility + * window, not showing in the task bar and window list + * - `SDL_PROP_WINDOW_CREATE_VULKAN_BOOLEAN`: true if the window will be used + * with Vulkan rendering + * - `SDL_PROP_WINDOW_CREATE_WIDTH_NUMBER`: the width of the window + * - `SDL_PROP_WINDOW_CREATE_X_NUMBER`: the x position of the window, or + * `SDL_WINDOWPOS_CENTERED`, defaults to `SDL_WINDOWPOS_UNDEFINED`. This is + * relative to the parent for windows with the "tooltip" or "menu" property + * set. + * - `SDL_PROP_WINDOW_CREATE_Y_NUMBER`: the y position of the window, or + * `SDL_WINDOWPOS_CENTERED`, defaults to `SDL_WINDOWPOS_UNDEFINED`. This is + * relative to the parent for windows with the "tooltip" or "menu" property + * set. + * + * These are additional supported properties on macOS: + * + * - `SDL_PROP_WINDOW_CREATE_COCOA_WINDOW_POINTER`: the + * `(__unsafe_unretained)` NSWindow associated with the window, if you want + * to wrap an existing window. + * - `SDL_PROP_WINDOW_CREATE_COCOA_VIEW_POINTER`: the `(__unsafe_unretained)` + * NSView associated with the window, defaults to `[window contentView]` + * + * These are additional supported properties on iOS, tvOS, and visionOS: + * + * - `SDL_PROP_WINDOW_CREATE_WINDOWSCENE_POINTER`: the `(__unsafe_unretained)` + * UIWindowScene associated with the window, defaults to the active window + * scene. + * + * These are additional supported properties on Wayland: + * + * - `SDL_PROP_WINDOW_CREATE_WAYLAND_SURFACE_ROLE_CUSTOM_BOOLEAN` - true if + * the application wants to use the Wayland surface for a custom role and + * does not want it attached to an XDG toplevel window. See + * [README-wayland](README-wayland) for more information on using custom + * surfaces. + * - `SDL_PROP_WINDOW_CREATE_WAYLAND_CREATE_EGL_WINDOW_BOOLEAN` - true if the + * application wants an associated `wl_egl_window` object to be created and + * attached to the window, even if the window does not have the OpenGL + * property or `SDL_WINDOW_OPENGL` flag set. + * - `SDL_PROP_WINDOW_CREATE_WAYLAND_WL_SURFACE_POINTER` - the wl_surface + * associated with the window, if you want to wrap an existing window. See + * [README-wayland](README-wayland) for more information. + * + * These are additional supported properties on Windows: + * + * - `SDL_PROP_WINDOW_CREATE_WIN32_HWND_POINTER`: the HWND associated with the + * window, if you want to wrap an existing window. + * - `SDL_PROP_WINDOW_CREATE_WIN32_PIXEL_FORMAT_HWND_POINTER`: optional, + * another window to share pixel format with, useful for OpenGL windows + * + * These are additional supported properties with X11: + * + * - `SDL_PROP_WINDOW_CREATE_X11_WINDOW_NUMBER`: the X11 Window associated + * with the window, if you want to wrap an existing window. + * + * The window is implicitly shown if the "hidden" property is not set. + * + * These are additional supported properties with Emscripten: + * + * - `SDL_PROP_WINDOW_CREATE_EMSCRIPTEN_CANVAS_ID_STRING`: the id given to the + * canvas element. This should start with a '#' sign + * - `SDL_PROP_WINDOW_CREATE_EMSCRIPTEN_KEYBOARD_ELEMENT_STRING`: override the + * binding element for keyboard inputs for this canvas. The variable can be + * one of: + * - "#window": the javascript window object (default) + * - "#document": the javascript document object + * - "#screen": the javascript window.screen object + * - "#canvas": the WebGL canvas element + * - "#none": Don't bind anything at all + * - any other string without a leading # sign applies to the element on the + * page with that ID. Windows with the "tooltip" and "menu" properties are + * popup windows and have the behaviors and guidelines outlined in + * SDL_CreatePopupWindow(). + * + * If this window is being created to be used with an SDL_Renderer, you should + * not add a graphics API specific property + * (`SDL_PROP_WINDOW_CREATE_OPENGL_BOOLEAN`, etc), as SDL will handle that + * internally when it chooses a renderer. However, SDL might need to recreate + * your window at that point, which may cause the window to appear briefly, + * and then flicker as it is recreated. The correct approach to this is to + * create the window with the `SDL_PROP_WINDOW_CREATE_HIDDEN_BOOLEAN` property + * set to true, then create the renderer, then show the window with + * SDL_ShowWindow(). + * + * \param props the properties to use. + * \returns the window that was created or NULL on failure; call + * SDL_GetError() for more information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateProperties + * \sa SDL_CreateWindow + * \sa SDL_DestroyWindow + */ +extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_CreateWindowWithProperties(SDL_PropertiesID props); + +#define SDL_PROP_WINDOW_CREATE_ALWAYS_ON_TOP_BOOLEAN "SDL.window.create.always_on_top" +#define SDL_PROP_WINDOW_CREATE_BORDERLESS_BOOLEAN "SDL.window.create.borderless" +#define SDL_PROP_WINDOW_CREATE_CONSTRAIN_POPUP_BOOLEAN "SDL.window.create.constrain_popup" +#define SDL_PROP_WINDOW_CREATE_FOCUSABLE_BOOLEAN "SDL.window.create.focusable" +#define SDL_PROP_WINDOW_CREATE_EXTERNAL_GRAPHICS_CONTEXT_BOOLEAN "SDL.window.create.external_graphics_context" +#define SDL_PROP_WINDOW_CREATE_FLAGS_NUMBER "SDL.window.create.flags" +#define SDL_PROP_WINDOW_CREATE_FULLSCREEN_BOOLEAN "SDL.window.create.fullscreen" +#define SDL_PROP_WINDOW_CREATE_HEIGHT_NUMBER "SDL.window.create.height" +#define SDL_PROP_WINDOW_CREATE_HIDDEN_BOOLEAN "SDL.window.create.hidden" +#define SDL_PROP_WINDOW_CREATE_HIGH_PIXEL_DENSITY_BOOLEAN "SDL.window.create.high_pixel_density" +#define SDL_PROP_WINDOW_CREATE_MAXIMIZED_BOOLEAN "SDL.window.create.maximized" +#define SDL_PROP_WINDOW_CREATE_MENU_BOOLEAN "SDL.window.create.menu" +#define SDL_PROP_WINDOW_CREATE_METAL_BOOLEAN "SDL.window.create.metal" +#define SDL_PROP_WINDOW_CREATE_MINIMIZED_BOOLEAN "SDL.window.create.minimized" +#define SDL_PROP_WINDOW_CREATE_MODAL_BOOLEAN "SDL.window.create.modal" +#define SDL_PROP_WINDOW_CREATE_MOUSE_GRABBED_BOOLEAN "SDL.window.create.mouse_grabbed" +#define SDL_PROP_WINDOW_CREATE_OPENGL_BOOLEAN "SDL.window.create.opengl" +#define SDL_PROP_WINDOW_CREATE_PARENT_POINTER "SDL.window.create.parent" +#define SDL_PROP_WINDOW_CREATE_RESIZABLE_BOOLEAN "SDL.window.create.resizable" +#define SDL_PROP_WINDOW_CREATE_TITLE_STRING "SDL.window.create.title" +#define SDL_PROP_WINDOW_CREATE_TRANSPARENT_BOOLEAN "SDL.window.create.transparent" +#define SDL_PROP_WINDOW_CREATE_TOOLTIP_BOOLEAN "SDL.window.create.tooltip" +#define SDL_PROP_WINDOW_CREATE_UTILITY_BOOLEAN "SDL.window.create.utility" +#define SDL_PROP_WINDOW_CREATE_VULKAN_BOOLEAN "SDL.window.create.vulkan" +#define SDL_PROP_WINDOW_CREATE_WIDTH_NUMBER "SDL.window.create.width" +#define SDL_PROP_WINDOW_CREATE_X_NUMBER "SDL.window.create.x" +#define SDL_PROP_WINDOW_CREATE_Y_NUMBER "SDL.window.create.y" +#define SDL_PROP_WINDOW_CREATE_COCOA_WINDOW_POINTER "SDL.window.create.cocoa.window" +#define SDL_PROP_WINDOW_CREATE_COCOA_VIEW_POINTER "SDL.window.create.cocoa.view" +#define SDL_PROP_WINDOW_CREATE_WINDOWSCENE_POINTER "SDL.window.create.uikit.windowscene" +#define SDL_PROP_WINDOW_CREATE_WAYLAND_SURFACE_ROLE_CUSTOM_BOOLEAN "SDL.window.create.wayland.surface_role_custom" +#define SDL_PROP_WINDOW_CREATE_WAYLAND_CREATE_EGL_WINDOW_BOOLEAN "SDL.window.create.wayland.create_egl_window" +#define SDL_PROP_WINDOW_CREATE_WAYLAND_WL_SURFACE_POINTER "SDL.window.create.wayland.wl_surface" +#define SDL_PROP_WINDOW_CREATE_WIN32_HWND_POINTER "SDL.window.create.win32.hwnd" +#define SDL_PROP_WINDOW_CREATE_WIN32_PIXEL_FORMAT_HWND_POINTER "SDL.window.create.win32.pixel_format_hwnd" +#define SDL_PROP_WINDOW_CREATE_X11_WINDOW_NUMBER "SDL.window.create.x11.window" +#define SDL_PROP_WINDOW_CREATE_EMSCRIPTEN_CANVAS_ID_STRING "SDL.window.create.emscripten.canvas_id" +#define SDL_PROP_WINDOW_CREATE_EMSCRIPTEN_KEYBOARD_ELEMENT_STRING "SDL.window.create.emscripten.keyboard_element" + +/** + * Get the numeric ID of a window. + * + * The numeric ID is what SDL_WindowEvent references, and is necessary to map + * these events to specific SDL_Window objects. + * + * \param window the window to query. + * \returns the ID of the window on success or 0 on failure; call + * SDL_GetError() for more information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetWindowFromID + */ +extern SDL_DECLSPEC SDL_WindowID SDLCALL SDL_GetWindowID(SDL_Window *window); + +/** + * Get a window from a stored ID. + * + * The numeric ID is what SDL_WindowEvent references, and is necessary to map + * these events to specific SDL_Window objects. + * + * \param id the ID of the window. + * \returns the window associated with `id` or NULL if it doesn't exist; call + * SDL_GetError() for more information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetWindowID + */ +extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetWindowFromID(SDL_WindowID id); + +/** + * Get parent of a window. + * + * \param window the window to query. + * \returns the parent of the window on success or NULL if the window has no + * parent. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreatePopupWindow + */ +extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetWindowParent(SDL_Window *window); + +/** + * Get the properties associated with a window. + * + * The following read-only properties are provided by SDL: + * + * - `SDL_PROP_WINDOW_SHAPE_POINTER`: the surface associated with a shaped + * window + * - `SDL_PROP_WINDOW_HDR_ENABLED_BOOLEAN`: true if the window has HDR + * headroom above the SDR white point. This property can change dynamically + * when SDL_EVENT_WINDOW_HDR_STATE_CHANGED is sent. + * - `SDL_PROP_WINDOW_SDR_WHITE_LEVEL_FLOAT`: the value of SDR white in the + * SDL_COLORSPACE_SRGB_LINEAR colorspace. On Windows this corresponds to the + * SDR white level in scRGB colorspace, and on Apple platforms this is + * always 1.0 for EDR content. This property can change dynamically when + * SDL_EVENT_WINDOW_HDR_STATE_CHANGED is sent. + * - `SDL_PROP_WINDOW_HDR_HEADROOM_FLOAT`: the additional high dynamic range + * that can be displayed, in terms of the SDR white point. When HDR is not + * enabled, this will be 1.0. This property can change dynamically when + * SDL_EVENT_WINDOW_HDR_STATE_CHANGED is sent. + * + * On Android: + * + * - `SDL_PROP_WINDOW_ANDROID_WINDOW_POINTER`: the ANativeWindow associated + * with the window + * - `SDL_PROP_WINDOW_ANDROID_SURFACE_POINTER`: the EGLSurface associated with + * the window + * + * On iOS: + * + * - `SDL_PROP_WINDOW_UIKIT_WINDOW_POINTER`: the `(__unsafe_unretained)` + * UIWindow associated with the window + * - `SDL_PROP_WINDOW_UIKIT_METAL_VIEW_TAG_NUMBER`: the NSInteger tag + * associated with metal views on the window + * - `SDL_PROP_WINDOW_UIKIT_OPENGL_FRAMEBUFFER_NUMBER`: the OpenGL view's + * framebuffer object. It must be bound when rendering to the screen using + * OpenGL. + * - `SDL_PROP_WINDOW_UIKIT_OPENGL_RENDERBUFFER_NUMBER`: the OpenGL view's + * renderbuffer object. It must be bound when SDL_GL_SwapWindow is called. + * - `SDL_PROP_WINDOW_UIKIT_OPENGL_RESOLVE_FRAMEBUFFER_NUMBER`: the OpenGL + * view's resolve framebuffer, when MSAA is used. + * + * On KMS/DRM: + * + * - `SDL_PROP_WINDOW_KMSDRM_DEVICE_INDEX_NUMBER`: the device index associated + * with the window (e.g. the X in /dev/dri/cardX) + * - `SDL_PROP_WINDOW_KMSDRM_DRM_FD_NUMBER`: the DRM FD associated with the + * window + * - `SDL_PROP_WINDOW_KMSDRM_GBM_DEVICE_POINTER`: the GBM device associated + * with the window + * + * On macOS: + * + * - `SDL_PROP_WINDOW_COCOA_WINDOW_POINTER`: the `(__unsafe_unretained)` + * NSWindow associated with the window + * - `SDL_PROP_WINDOW_COCOA_METAL_VIEW_TAG_NUMBER`: the NSInteger tag + * associated with metal views on the window + * + * On OpenVR: + * + * - `SDL_PROP_WINDOW_OPENVR_OVERLAY_ID_NUMBER`: the OpenVR Overlay Handle ID + * for the associated overlay window. + * + * On Vivante: + * + * - `SDL_PROP_WINDOW_VIVANTE_DISPLAY_POINTER`: the EGLNativeDisplayType + * associated with the window + * - `SDL_PROP_WINDOW_VIVANTE_WINDOW_POINTER`: the EGLNativeWindowType + * associated with the window + * - `SDL_PROP_WINDOW_VIVANTE_SURFACE_POINTER`: the EGLSurface associated with + * the window + * + * On Windows: + * + * - `SDL_PROP_WINDOW_WIN32_HWND_POINTER`: the HWND associated with the window + * - `SDL_PROP_WINDOW_WIN32_HDC_POINTER`: the HDC associated with the window + * - `SDL_PROP_WINDOW_WIN32_INSTANCE_POINTER`: the HINSTANCE associated with + * the window + * + * On Wayland: + * + * Note: The `xdg_*` window objects do not internally persist across window + * show/hide calls. They will be null if the window is hidden and must be + * queried each time it is shown. + * + * - `SDL_PROP_WINDOW_WAYLAND_DISPLAY_POINTER`: the wl_display associated with + * the window + * - `SDL_PROP_WINDOW_WAYLAND_SURFACE_POINTER`: the wl_surface associated with + * the window + * - `SDL_PROP_WINDOW_WAYLAND_VIEWPORT_POINTER`: the wp_viewport associated + * with the window + * - `SDL_PROP_WINDOW_WAYLAND_EGL_WINDOW_POINTER`: the wl_egl_window + * associated with the window + * - `SDL_PROP_WINDOW_WAYLAND_XDG_SURFACE_POINTER`: the xdg_surface associated + * with the window + * - `SDL_PROP_WINDOW_WAYLAND_XDG_TOPLEVEL_POINTER`: the xdg_toplevel role + * associated with the window + * - 'SDL_PROP_WINDOW_WAYLAND_XDG_TOPLEVEL_EXPORT_HANDLE_STRING': the export + * handle associated with the window + * - `SDL_PROP_WINDOW_WAYLAND_XDG_POPUP_POINTER`: the xdg_popup role + * associated with the window + * - `SDL_PROP_WINDOW_WAYLAND_XDG_POSITIONER_POINTER`: the xdg_positioner + * associated with the window, in popup mode + * + * On X11: + * + * - `SDL_PROP_WINDOW_X11_DISPLAY_POINTER`: the X11 Display associated with + * the window + * - `SDL_PROP_WINDOW_X11_SCREEN_NUMBER`: the screen number associated with + * the window + * - `SDL_PROP_WINDOW_X11_WINDOW_NUMBER`: the X11 Window associated with the + * window + * + * On Emscripten: + * + * - `SDL_PROP_WINDOW_EMSCRIPTEN_CANVAS_ID_STRING`: the id the canvas element + * will have + * - `SDL_PROP_WINDOW_EMSCRIPTEN_KEYBOARD_ELEMENT_STRING`: the keyboard + * element that associates keyboard events to this window + * + * \param window the window to query. + * \returns a valid property ID on success or 0 on failure; call + * SDL_GetError() for more information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetWindowProperties(SDL_Window *window); + +#define SDL_PROP_WINDOW_SHAPE_POINTER "SDL.window.shape" +#define SDL_PROP_WINDOW_HDR_ENABLED_BOOLEAN "SDL.window.HDR_enabled" +#define SDL_PROP_WINDOW_SDR_WHITE_LEVEL_FLOAT "SDL.window.SDR_white_level" +#define SDL_PROP_WINDOW_HDR_HEADROOM_FLOAT "SDL.window.HDR_headroom" +#define SDL_PROP_WINDOW_ANDROID_WINDOW_POINTER "SDL.window.android.window" +#define SDL_PROP_WINDOW_ANDROID_SURFACE_POINTER "SDL.window.android.surface" +#define SDL_PROP_WINDOW_UIKIT_WINDOW_POINTER "SDL.window.uikit.window" +#define SDL_PROP_WINDOW_UIKIT_METAL_VIEW_TAG_NUMBER "SDL.window.uikit.metal_view_tag" +#define SDL_PROP_WINDOW_UIKIT_OPENGL_FRAMEBUFFER_NUMBER "SDL.window.uikit.opengl.framebuffer" +#define SDL_PROP_WINDOW_UIKIT_OPENGL_RENDERBUFFER_NUMBER "SDL.window.uikit.opengl.renderbuffer" +#define SDL_PROP_WINDOW_UIKIT_OPENGL_RESOLVE_FRAMEBUFFER_NUMBER "SDL.window.uikit.opengl.resolve_framebuffer" +#define SDL_PROP_WINDOW_KMSDRM_DEVICE_INDEX_NUMBER "SDL.window.kmsdrm.dev_index" +#define SDL_PROP_WINDOW_KMSDRM_DRM_FD_NUMBER "SDL.window.kmsdrm.drm_fd" +#define SDL_PROP_WINDOW_KMSDRM_GBM_DEVICE_POINTER "SDL.window.kmsdrm.gbm_dev" +#define SDL_PROP_WINDOW_COCOA_WINDOW_POINTER "SDL.window.cocoa.window" +#define SDL_PROP_WINDOW_COCOA_METAL_VIEW_TAG_NUMBER "SDL.window.cocoa.metal_view_tag" +#define SDL_PROP_WINDOW_OPENVR_OVERLAY_ID_NUMBER "SDL.window.openvr.overlay_id" +#define SDL_PROP_WINDOW_VIVANTE_DISPLAY_POINTER "SDL.window.vivante.display" +#define SDL_PROP_WINDOW_VIVANTE_WINDOW_POINTER "SDL.window.vivante.window" +#define SDL_PROP_WINDOW_VIVANTE_SURFACE_POINTER "SDL.window.vivante.surface" +#define SDL_PROP_WINDOW_WIN32_HWND_POINTER "SDL.window.win32.hwnd" +#define SDL_PROP_WINDOW_WIN32_HDC_POINTER "SDL.window.win32.hdc" +#define SDL_PROP_WINDOW_WIN32_INSTANCE_POINTER "SDL.window.win32.instance" +#define SDL_PROP_WINDOW_WAYLAND_DISPLAY_POINTER "SDL.window.wayland.display" +#define SDL_PROP_WINDOW_WAYLAND_SURFACE_POINTER "SDL.window.wayland.surface" +#define SDL_PROP_WINDOW_WAYLAND_VIEWPORT_POINTER "SDL.window.wayland.viewport" +#define SDL_PROP_WINDOW_WAYLAND_EGL_WINDOW_POINTER "SDL.window.wayland.egl_window" +#define SDL_PROP_WINDOW_WAYLAND_XDG_SURFACE_POINTER "SDL.window.wayland.xdg_surface" +#define SDL_PROP_WINDOW_WAYLAND_XDG_TOPLEVEL_POINTER "SDL.window.wayland.xdg_toplevel" +#define SDL_PROP_WINDOW_WAYLAND_XDG_TOPLEVEL_EXPORT_HANDLE_STRING "SDL.window.wayland.xdg_toplevel_export_handle" +#define SDL_PROP_WINDOW_WAYLAND_XDG_POPUP_POINTER "SDL.window.wayland.xdg_popup" +#define SDL_PROP_WINDOW_WAYLAND_XDG_POSITIONER_POINTER "SDL.window.wayland.xdg_positioner" +#define SDL_PROP_WINDOW_X11_DISPLAY_POINTER "SDL.window.x11.display" +#define SDL_PROP_WINDOW_X11_SCREEN_NUMBER "SDL.window.x11.screen" +#define SDL_PROP_WINDOW_X11_WINDOW_NUMBER "SDL.window.x11.window" +#define SDL_PROP_WINDOW_EMSCRIPTEN_CANVAS_ID_STRING "SDL.window.emscripten.canvas_id" +#define SDL_PROP_WINDOW_EMSCRIPTEN_KEYBOARD_ELEMENT_STRING "SDL.window.emscripten.keyboard_element" + +/** + * Get the window flags. + * + * \param window the window to query. + * \returns a mask of the SDL_WindowFlags associated with `window`. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateWindow + * \sa SDL_HideWindow + * \sa SDL_MaximizeWindow + * \sa SDL_MinimizeWindow + * \sa SDL_SetWindowFullscreen + * \sa SDL_SetWindowMouseGrab + * \sa SDL_SetWindowFillDocument + * \sa SDL_ShowWindow + */ +extern SDL_DECLSPEC SDL_WindowFlags SDLCALL SDL_GetWindowFlags(SDL_Window *window); + +/** + * Set the title of a window. + * + * This string is expected to be in UTF-8 encoding. + * + * \param window the window to change. + * \param title the desired window title in UTF-8 format. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetWindowTitle + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowTitle(SDL_Window *window, const char *title); + +/** + * Get the title of a window. + * + * \param window the window to query. + * \returns the title of the window in UTF-8 format or "" if there is no + * title. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetWindowTitle + */ +extern SDL_DECLSPEC const char * SDLCALL SDL_GetWindowTitle(SDL_Window *window); + +/** + * Set the icon for a window. + * + * If this function is passed a surface with alternate representations added + * using SDL_AddSurfaceAlternateImage(), the surface will be interpreted as + * the content to be used for 100% display scale, and the alternate + * representations will be used for high DPI situations. For example, if the + * original surface is 32x32, then on a 2x macOS display or 200% display scale + * on Windows, a 64x64 version of the image will be used, if available. If a + * matching version of the image isn't available, the closest larger size + * image will be downscaled to the appropriate size and be used instead, if + * available. Otherwise, the closest smaller image will be upscaled and be + * used instead. + * + * \param window the window to change. + * \param icon an SDL_Surface structure containing the icon for the window. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_AddSurfaceAlternateImage + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowIcon(SDL_Window *window, SDL_Surface *icon); + +/** + * Request that the window's position be set. + * + * If the window is in an exclusive fullscreen or maximized state, this + * request has no effect. + * + * This can be used to reposition fullscreen-desktop windows onto a different + * display, however, as exclusive fullscreen windows are locked to a specific + * display, they can only be repositioned programmatically via + * SDL_SetWindowFullscreenMode(). + * + * On some windowing systems this request is asynchronous and the new + * coordinates may not have have been applied immediately upon the return of + * this function. If an immediate change is required, call SDL_SyncWindow() to + * block until the changes have taken effect. + * + * When the window position changes, an SDL_EVENT_WINDOW_MOVED event will be + * emitted with the window's new coordinates. Note that the new coordinates + * may not match the exact coordinates requested, as some windowing systems + * can restrict the position of the window in certain scenarios (e.g. + * constraining the position so the window is always within desktop bounds). + * Additionally, as this is just a request, it can be denied by the windowing + * system. + * + * \param window the window to reposition. + * \param x the x coordinate of the window, or `SDL_WINDOWPOS_CENTERED` or + * `SDL_WINDOWPOS_UNDEFINED`. + * \param y the y coordinate of the window, or `SDL_WINDOWPOS_CENTERED` or + * `SDL_WINDOWPOS_UNDEFINED`. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetWindowPosition + * \sa SDL_SyncWindow + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowPosition(SDL_Window *window, int x, int y); + +/** + * Get the position of a window. + * + * This is the current position of the window as last reported by the + * windowing system. + * + * If you do not need the value for one of the positions a NULL may be passed + * in the `x` or `y` parameter. + * + * \param window the window to query. + * \param x a pointer filled in with the x position of the window, may be + * NULL. + * \param y a pointer filled in with the y position of the window, may be + * NULL. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetWindowPosition + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetWindowPosition(SDL_Window *window, int *x, int *y); + +/** + * Request that the size of a window's client area be set. + * + * If the window is in a fullscreen or maximized state, this request has no + * effect. + * + * To change the exclusive fullscreen mode of a window, use + * SDL_SetWindowFullscreenMode(). + * + * On some windowing systems, this request is asynchronous and the new window + * size may not have have been applied immediately upon the return of this + * function. If an immediate change is required, call SDL_SyncWindow() to + * block until the changes have taken effect. + * + * When the window size changes, an SDL_EVENT_WINDOW_RESIZED event will be + * emitted with the new window dimensions. Note that the new dimensions may + * not match the exact size requested, as some windowing systems can restrict + * the window size in certain scenarios (e.g. constraining the size of the + * content area to remain within the usable desktop bounds). Additionally, as + * this is just a request, it can be denied by the windowing system. + * + * \param window the window to change. + * \param w the width of the window, must be > 0. + * \param h the height of the window, must be > 0. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetWindowSize + * \sa SDL_SetWindowFullscreenMode + * \sa SDL_SyncWindow + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowSize(SDL_Window *window, int w, int h); + +/** + * Get the size of a window's client area. + * + * The window pixel size may differ from its window coordinate size if the + * window is on a high pixel density display. Use SDL_GetWindowSizeInPixels() + * or SDL_GetRenderOutputSize() to get the real client area size in pixels. + * + * \param window the window to query the width and height from. + * \param w a pointer filled in with the width of the window, may be NULL. + * \param h a pointer filled in with the height of the window, may be NULL. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetRenderOutputSize + * \sa SDL_GetWindowSizeInPixels + * \sa SDL_SetWindowSize + * \sa SDL_EVENT_WINDOW_RESIZED + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetWindowSize(SDL_Window *window, int *w, int *h); + +/** + * Get the safe area for this window. + * + * Some devices have portions of the screen which are partially obscured or + * not interactive, possibly due to on-screen controls, curved edges, camera + * notches, TV overscan, etc. This function provides the area of the window + * which is safe to have interactable content. You should continue rendering + * into the rest of the window, but it should not contain visually important + * or interactable content. + * + * \param window the window to query. + * \param rect a pointer filled in with the client area that is safe for + * interactive content. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetWindowSafeArea(SDL_Window *window, SDL_Rect *rect); + +/** + * Request that the aspect ratio of a window's client area be set. + * + * The aspect ratio is the ratio of width divided by height, e.g. 2560x1600 + * would be 1.6. Larger aspect ratios are wider and smaller aspect ratios are + * narrower. + * + * If, at the time of this request, the window in a fixed-size state, such as + * maximized or fullscreen, the request will be deferred until the window + * exits this state and becomes resizable again. + * + * On some windowing systems, this request is asynchronous and the new window + * aspect ratio may not have have been applied immediately upon the return of + * this function. If an immediate change is required, call SDL_SyncWindow() to + * block until the changes have taken effect. + * + * When the window size changes, an SDL_EVENT_WINDOW_RESIZED event will be + * emitted with the new window dimensions. Note that the new dimensions may + * not match the exact aspect ratio requested, as some windowing systems can + * restrict the window size in certain scenarios (e.g. constraining the size + * of the content area to remain within the usable desktop bounds). + * Additionally, as this is just a request, it can be denied by the windowing + * system. + * + * \param window the window to change. + * \param min_aspect the minimum aspect ratio of the window, or 0.0f for no + * limit. + * \param max_aspect the maximum aspect ratio of the window, or 0.0f for no + * limit. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetWindowAspectRatio + * \sa SDL_SyncWindow + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowAspectRatio(SDL_Window *window, float min_aspect, float max_aspect); + +/** + * Get the aspect ratio of a window's client area. + * + * \param window the window to query the width and height from. + * \param min_aspect a pointer filled in with the minimum aspect ratio of the + * window, may be NULL. + * \param max_aspect a pointer filled in with the maximum aspect ratio of the + * window, may be NULL. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetWindowAspectRatio + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetWindowAspectRatio(SDL_Window *window, float *min_aspect, float *max_aspect); + +/** + * Get the size of a window's borders (decorations) around the client area. + * + * Note: If this function fails (returns false), the size values will be + * initialized to 0, 0, 0, 0 (if a non-NULL pointer is provided), as if the + * window in question was borderless. + * + * Note: This function may fail on systems where the window has not yet been + * decorated by the display server (for example, immediately after calling + * SDL_CreateWindow). It is recommended that you wait at least until the + * window has been presented and composited, so that the window system has a + * chance to decorate the window and provide the border dimensions to SDL. + * + * This function also returns false if getting the information is not + * supported. + * + * \param window the window to query the size values of the border + * (decorations) from. + * \param top pointer to variable for storing the size of the top border; NULL + * is permitted. + * \param left pointer to variable for storing the size of the left border; + * NULL is permitted. + * \param bottom pointer to variable for storing the size of the bottom + * border; NULL is permitted. + * \param right pointer to variable for storing the size of the right border; + * NULL is permitted. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetWindowSize + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetWindowBordersSize(SDL_Window *window, int *top, int *left, int *bottom, int *right); + +/** + * Get the size of a window's client area, in pixels. + * + * \param window the window from which the drawable size should be queried. + * \param w a pointer to variable for storing the width in pixels, may be + * NULL. + * \param h a pointer to variable for storing the height in pixels, may be + * NULL. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreateWindow + * \sa SDL_GetWindowSize + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetWindowSizeInPixels(SDL_Window *window, int *w, int *h); + +/** + * Set the minimum size of a window's client area. + * + * \param window the window to change. + * \param min_w the minimum width of the window, or 0 for no limit. + * \param min_h the minimum height of the window, or 0 for no limit. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetWindowMinimumSize + * \sa SDL_SetWindowMaximumSize + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowMinimumSize(SDL_Window *window, int min_w, int min_h); + +/** + * Get the minimum size of a window's client area. + * + * \param window the window to query. + * \param w a pointer filled in with the minimum width of the window, may be + * NULL. + * \param h a pointer filled in with the minimum height of the window, may be + * NULL. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetWindowMaximumSize + * \sa SDL_SetWindowMinimumSize + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetWindowMinimumSize(SDL_Window *window, int *w, int *h); + +/** + * Set the maximum size of a window's client area. + * + * \param window the window to change. + * \param max_w the maximum width of the window, or 0 for no limit. + * \param max_h the maximum height of the window, or 0 for no limit. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetWindowMaximumSize + * \sa SDL_SetWindowMinimumSize + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowMaximumSize(SDL_Window *window, int max_w, int max_h); + +/** + * Get the maximum size of a window's client area. + * + * \param window the window to query. + * \param w a pointer filled in with the maximum width of the window, may be + * NULL. + * \param h a pointer filled in with the maximum height of the window, may be + * NULL. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetWindowMinimumSize + * \sa SDL_SetWindowMaximumSize + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetWindowMaximumSize(SDL_Window *window, int *w, int *h); + +/** + * Set the border state of a window. + * + * This will add or remove the window's `SDL_WINDOW_BORDERLESS` flag and add + * or remove the border from the actual window. This is a no-op if the + * window's border already matches the requested state. + * + * You can't change the border state of a fullscreen window. + * + * \param window the window of which to change the border state. + * \param bordered false to remove border, true to add border. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetWindowFlags + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowBordered(SDL_Window *window, bool bordered); + +/** + * Set the user-resizable state of a window. + * + * This will add or remove the window's `SDL_WINDOW_RESIZABLE` flag and + * allow/disallow user resizing of the window. This is a no-op if the window's + * resizable state already matches the requested state. + * + * You can't change the resizable state of a fullscreen window. + * + * \param window the window of which to change the resizable state. + * \param resizable true to allow resizing, false to disallow. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetWindowFlags + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowResizable(SDL_Window *window, bool resizable); + +/** + * Set the window to always be above the others. + * + * This will add or remove the window's `SDL_WINDOW_ALWAYS_ON_TOP` flag. This + * will bring the window to the front and keep the window above the rest. + * + * \param window the window of which to change the always on top state. + * \param on_top true to set the window always on top, false to disable. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetWindowFlags + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowAlwaysOnTop(SDL_Window *window, bool on_top); + +/** + * Set the window to fill the current document space (Emscripten only). + * + * This will add or remove the window's `SDL_WINDOW_FILL_DOCUMENT` flag. + * + * Currently this flag only applies to the Emscripten target. + * + * When enabled, the canvas element fills the entire document. Resize events + * will be generated as the browser window is resized, as that will adjust the + * canvas size as well. The canvas will cover anything else on the page, + * including any controls provided by Emscripten in its generated HTML file + * (in fact, any elements on the page that aren't the canvas will be moved + * into a hidden `div` element). + * + * Often times this is desirable for a browser-based game, but it means + * several things that we expect of an SDL window on other platforms might not + * work as expected, such as minimum window sizes and aspect ratios. + * + * \param window the window of which to change the fill-document state. + * \param fill true to set the window to fill the document, false to disable. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.4.0. + * + * \sa SDL_GetWindowFlags + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowFillDocument(SDL_Window *window, bool fill); + +/** + * Show a window. + * + * \param window the window to show. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_HideWindow + * \sa SDL_RaiseWindow + */ +extern SDL_DECLSPEC bool SDLCALL SDL_ShowWindow(SDL_Window *window); + +/** + * Hide a window. + * + * \param window the window to hide. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_ShowWindow + * \sa SDL_WINDOW_HIDDEN + */ +extern SDL_DECLSPEC bool SDLCALL SDL_HideWindow(SDL_Window *window); + +/** + * Request that a window be raised above other windows and gain the input + * focus. + * + * The result of this request is subject to desktop window manager policy, + * particularly if raising the requested window would result in stealing focus + * from another application. If the window is successfully raised and gains + * input focus, an SDL_EVENT_WINDOW_FOCUS_GAINED event will be emitted, and + * the window will have the SDL_WINDOW_INPUT_FOCUS flag set. + * + * \param window the window to raise. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_RaiseWindow(SDL_Window *window); + +/** + * Request that the window be made as large as possible. + * + * Non-resizable windows can't be maximized. The window must have the + * SDL_WINDOW_RESIZABLE flag set, or this will have no effect. + * + * On some windowing systems this request is asynchronous and the new window + * state may not have have been applied immediately upon the return of this + * function. If an immediate change is required, call SDL_SyncWindow() to + * block until the changes have taken effect. + * + * When the window state changes, an SDL_EVENT_WINDOW_MAXIMIZED event will be + * emitted. Note that, as this is just a request, the windowing system can + * deny the state change. + * + * When maximizing a window, whether the constraints set via + * SDL_SetWindowMaximumSize() are honored depends on the policy of the window + * manager. Win32 and macOS enforce the constraints when maximizing, while X11 + * and Wayland window managers may vary. + * + * \param window the window to maximize. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_MinimizeWindow + * \sa SDL_RestoreWindow + * \sa SDL_SyncWindow + */ +extern SDL_DECLSPEC bool SDLCALL SDL_MaximizeWindow(SDL_Window *window); + +/** + * Request that the window be minimized to an iconic representation. + * + * If the window is in a fullscreen state, this request has no direct effect. + * It may alter the state the window is returned to when leaving fullscreen. + * + * On some windowing systems this request is asynchronous and the new window + * state may not have been applied immediately upon the return of this + * function. If an immediate change is required, call SDL_SyncWindow() to + * block until the changes have taken effect. + * + * When the window state changes, an SDL_EVENT_WINDOW_MINIMIZED event will be + * emitted. Note that, as this is just a request, the windowing system can + * deny the state change. + * + * \param window the window to minimize. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_MaximizeWindow + * \sa SDL_RestoreWindow + * \sa SDL_SyncWindow + */ +extern SDL_DECLSPEC bool SDLCALL SDL_MinimizeWindow(SDL_Window *window); + +/** + * Request that the size and position of a minimized or maximized window be + * restored. + * + * If the window is in a fullscreen state, this request has no direct effect. + * It may alter the state the window is returned to when leaving fullscreen. + * + * On some windowing systems this request is asynchronous and the new window + * state may not have have been applied immediately upon the return of this + * function. If an immediate change is required, call SDL_SyncWindow() to + * block until the changes have taken effect. + * + * When the window state changes, an SDL_EVENT_WINDOW_RESTORED event will be + * emitted. Note that, as this is just a request, the windowing system can + * deny the state change. + * + * \param window the window to restore. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_MaximizeWindow + * \sa SDL_MinimizeWindow + * \sa SDL_SyncWindow + */ +extern SDL_DECLSPEC bool SDLCALL SDL_RestoreWindow(SDL_Window *window); + +/** + * Request that the window's fullscreen state be changed. + * + * By default a window in fullscreen state uses borderless fullscreen desktop + * mode, but a specific exclusive display mode can be set using + * SDL_SetWindowFullscreenMode(). + * + * On some windowing systems this request is asynchronous and the new + * fullscreen state may not have have been applied immediately upon the return + * of this function. If an immediate change is required, call SDL_SyncWindow() + * to block until the changes have taken effect. + * + * When the window state changes, an SDL_EVENT_WINDOW_ENTER_FULLSCREEN or + * SDL_EVENT_WINDOW_LEAVE_FULLSCREEN event will be emitted. Note that, as this + * is just a request, it can be denied by the windowing system. + * + * \param window the window to change. + * \param fullscreen true for fullscreen mode, false for windowed mode. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetWindowFullscreenMode + * \sa SDL_SetWindowFullscreenMode + * \sa SDL_SyncWindow + * \sa SDL_WINDOW_FULLSCREEN + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowFullscreen(SDL_Window *window, bool fullscreen); + +/** + * Block until any pending window state is finalized. + * + * On asynchronous windowing systems, this acts as a synchronization barrier + * for pending window state. It will attempt to wait until any pending window + * state has been applied and is guaranteed to return within finite time. Note + * that for how long it can potentially block depends on the underlying window + * system, as window state changes may involve somewhat lengthy animations + * that must complete before the window is in its final requested state. + * + * On windowing systems where changes are immediate, this does nothing. + * + * \param window the window for which to wait for the pending state to be + * applied. + * \returns true on success or false if the operation timed out before the + * window was in the requested state. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetWindowSize + * \sa SDL_SetWindowPosition + * \sa SDL_SetWindowFullscreen + * \sa SDL_MinimizeWindow + * \sa SDL_MaximizeWindow + * \sa SDL_RestoreWindow + * \sa SDL_HINT_VIDEO_SYNC_WINDOW_OPERATIONS + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SyncWindow(SDL_Window *window); + +/** + * Return whether the window has a surface associated with it. + * + * \param window the window to query. + * \returns true if there is a surface associated with the window, or false + * otherwise. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetWindowSurface + */ +extern SDL_DECLSPEC bool SDLCALL SDL_WindowHasSurface(SDL_Window *window); + +/** + * Get the SDL surface associated with the window. + * + * A new surface will be created with the optimal format for the window, if + * necessary. This surface will be freed when the window is destroyed. Do not + * free this surface. + * + * This surface will be invalidated if the window is resized. After resizing a + * window this function must be called again to return a valid surface. + * + * You may not combine this with 3D or the rendering API on this window. + * + * This function is affected by `SDL_HINT_FRAMEBUFFER_ACCELERATION`. + * + * \param window the window to query. + * \returns the surface associated with the window, or NULL on failure; call + * SDL_GetError() for more information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_DestroyWindowSurface + * \sa SDL_WindowHasSurface + * \sa SDL_UpdateWindowSurface + * \sa SDL_UpdateWindowSurfaceRects + */ +extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_GetWindowSurface(SDL_Window *window); + +/** + * Toggle VSync for the window surface. + * + * When a window surface is created, vsync defaults to + * SDL_WINDOW_SURFACE_VSYNC_DISABLED. + * + * The `vsync` parameter can be 1 to synchronize present with every vertical + * refresh, 2 to synchronize present with every second vertical refresh, etc., + * SDL_WINDOW_SURFACE_VSYNC_ADAPTIVE for late swap tearing (adaptive vsync), + * or SDL_WINDOW_SURFACE_VSYNC_DISABLED to disable. Not every value is + * supported by every driver, so you should check the return value to see + * whether the requested setting is supported. + * + * \param window the window. + * \param vsync the vertical refresh sync interval. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetWindowSurfaceVSync + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowSurfaceVSync(SDL_Window *window, int vsync); + +#define SDL_WINDOW_SURFACE_VSYNC_DISABLED 0 +#define SDL_WINDOW_SURFACE_VSYNC_ADAPTIVE (-1) + +/** + * Get VSync for the window surface. + * + * \param window the window to query. + * \param vsync an int filled with the current vertical refresh sync interval. + * See SDL_SetWindowSurfaceVSync() for the meaning of the value. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetWindowSurfaceVSync + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetWindowSurfaceVSync(SDL_Window *window, int *vsync); + +/** + * Copy the window surface to the screen. + * + * This is the function you use to reflect any changes to the surface on the + * screen. + * + * This function is equivalent to the SDL 1.2 API SDL_Flip(). + * + * \param window the window to update. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetWindowSurface + * \sa SDL_UpdateWindowSurfaceRects + */ +extern SDL_DECLSPEC bool SDLCALL SDL_UpdateWindowSurface(SDL_Window *window); + +/** + * Copy areas of the window surface to the screen. + * + * This is the function you use to reflect changes to portions of the surface + * on the screen. + * + * This function is equivalent to the SDL 1.2 API SDL_UpdateRects(). + * + * Note that this function will update _at least_ the rectangles specified, + * but this is only intended as an optimization; in practice, this might + * update more of the screen (or all of the screen!), depending on what method + * SDL uses to send pixels to the system. + * + * \param window the window to update. + * \param rects an array of SDL_Rect structures representing areas of the + * surface to copy, in pixels. + * \param numrects the number of rectangles. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetWindowSurface + * \sa SDL_UpdateWindowSurface + */ +extern SDL_DECLSPEC bool SDLCALL SDL_UpdateWindowSurfaceRects(SDL_Window *window, const SDL_Rect *rects, int numrects); + +/** + * Destroy the surface associated with the window. + * + * \param window the window to update. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetWindowSurface + * \sa SDL_WindowHasSurface + */ +extern SDL_DECLSPEC bool SDLCALL SDL_DestroyWindowSurface(SDL_Window *window); + +/** + * Set a window's keyboard grab mode. + * + * Keyboard grab enables capture of system keyboard shortcuts like Alt+Tab or + * the Meta/Super key. Note that not all system keyboard shortcuts can be + * captured by applications (one example is Ctrl+Alt+Del on Windows). + * + * This is primarily intended for specialized applications such as VNC clients + * or VM frontends. Normal games should not use keyboard grab. + * + * When keyboard grab is enabled, SDL will continue to handle Alt+Tab when the + * window is full-screen to ensure the user is not trapped in your + * application. If you have a custom keyboard shortcut to exit fullscreen + * mode, you may suppress this behavior with + * `SDL_HINT_ALLOW_ALT_TAB_WHILE_GRABBED`. + * + * If the caller enables a grab while another window is currently grabbed, the + * other window loses its grab in favor of the caller's window. + * + * \param window the window for which the keyboard grab mode should be set. + * \param grabbed this is true to grab keyboard, and false to release. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetWindowKeyboardGrab + * \sa SDL_SetWindowMouseGrab + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowKeyboardGrab(SDL_Window *window, bool grabbed); + +/** + * Set a window's mouse grab mode. + * + * Mouse grab confines the mouse cursor to the window. + * + * \param window the window for which the mouse grab mode should be set. + * \param grabbed this is true to grab mouse, and false to release. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetWindowMouseRect + * \sa SDL_SetWindowMouseRect + * \sa SDL_SetWindowKeyboardGrab + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowMouseGrab(SDL_Window *window, bool grabbed); + +/** + * Get a window's keyboard grab mode. + * + * \param window the window to query. + * \returns true if keyboard is grabbed, and false otherwise. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetWindowKeyboardGrab + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetWindowKeyboardGrab(SDL_Window *window); + +/** + * Get a window's mouse grab mode. + * + * \param window the window to query. + * \returns true if mouse is grabbed, and false otherwise. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetWindowMouseRect + * \sa SDL_SetWindowMouseRect + * \sa SDL_SetWindowMouseGrab + * \sa SDL_SetWindowKeyboardGrab + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetWindowMouseGrab(SDL_Window *window); + +/** + * Get the window that currently has an input grab enabled. + * + * \returns the window if input is grabbed or NULL otherwise. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetWindowMouseGrab + * \sa SDL_SetWindowKeyboardGrab + */ +extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetGrabbedWindow(void); + +/** + * Confines the cursor to the specified area of a window. + * + * Note that this does NOT grab the cursor, it only defines the area a cursor + * is restricted to when the window has mouse focus. + * + * \param window the window that will be associated with the barrier. + * \param rect a rectangle area in window-relative coordinates. If NULL the + * barrier for the specified window will be destroyed. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetWindowMouseRect + * \sa SDL_GetWindowMouseGrab + * \sa SDL_SetWindowMouseGrab + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowMouseRect(SDL_Window *window, const SDL_Rect *rect); + +/** + * Get the mouse confinement rectangle of a window. + * + * \param window the window to query. + * \returns a pointer to the mouse confinement rectangle of a window, or NULL + * if there isn't one. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetWindowMouseRect + * \sa SDL_GetWindowMouseGrab + * \sa SDL_SetWindowMouseGrab + */ +extern SDL_DECLSPEC const SDL_Rect * SDLCALL SDL_GetWindowMouseRect(SDL_Window *window); + +/** + * Set the opacity for a window. + * + * The parameter `opacity` will be clamped internally between 0.0f + * (transparent) and 1.0f (opaque). + * + * This function also returns false if setting the opacity isn't supported. + * + * \param window the window which will be made transparent or opaque. + * \param opacity the opacity value (0.0f - transparent, 1.0f - opaque). + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetWindowOpacity + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowOpacity(SDL_Window *window, float opacity); + +/** + * Get the opacity of a window. + * + * If transparency isn't supported on this platform, opacity will be returned + * as 1.0f without error. + * + * \param window the window to get the current opacity value from. + * \returns the opacity, (0.0f - transparent, 1.0f - opaque), or -1.0f on + * failure; call SDL_GetError() for more information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetWindowOpacity + */ +extern SDL_DECLSPEC float SDLCALL SDL_GetWindowOpacity(SDL_Window *window); + +/** + * Set the window as a child of a parent window. + * + * If the window is already the child of an existing window, it will be + * reparented to the new owner. Setting the parent window to NULL unparents + * the window and removes child window status. + * + * If a parent window is hidden or destroyed, the operation will be + * recursively applied to child windows. Child windows hidden with the parent + * that did not have their hidden status explicitly set will be restored when + * the parent is shown. + * + * Attempting to set the parent of a window that is currently in the modal + * state will fail. Use SDL_SetWindowModal() to cancel the modal status before + * attempting to change the parent. + * + * Popup windows cannot change parents and attempts to do so will fail. + * + * Setting a parent window that is currently the sibling or descendent of the + * child window results in undefined behavior. + * + * \param window the window that should become the child of a parent. + * \param parent the new parent window for the child window. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetWindowModal + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowParent(SDL_Window *window, SDL_Window *parent); + +/** + * Toggle the state of the window as modal. + * + * To enable modal status on a window, the window must currently be the child + * window of a parent, or toggling modal status on will fail. + * + * \param window the window on which to set the modal state. + * \param modal true to toggle modal status on, false to toggle it off. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetWindowParent + * \sa SDL_WINDOW_MODAL + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowModal(SDL_Window *window, bool modal); + +/** + * Set whether the window may have input focus. + * + * \param window the window to set focusable state. + * \param focusable true to allow input focus, false to not allow input focus. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowFocusable(SDL_Window *window, bool focusable); + + +/** + * Display the system-level window menu. + * + * This default window menu is provided by the system and on some platforms + * provides functionality for setting or changing privileged state on the + * window, such as moving it between workspaces or displays, or toggling the + * always-on-top property. + * + * On platforms or desktops where this is unsupported, this function does + * nothing. + * + * \param window the window for which the menu will be displayed. + * \param x the x coordinate of the menu, relative to the origin (top-left) of + * the client area. + * \param y the y coordinate of the menu, relative to the origin (top-left) of + * the client area. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_ShowWindowSystemMenu(SDL_Window *window, int x, int y); + +/** + * Possible return values from the SDL_HitTest callback. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This enum is available since SDL 3.2.0. + * + * \sa SDL_HitTest + */ +typedef enum SDL_HitTestResult +{ + SDL_HITTEST_NORMAL, /**< Region is normal. No special properties. */ + SDL_HITTEST_DRAGGABLE, /**< Region can drag entire window. */ + SDL_HITTEST_RESIZE_TOPLEFT, /**< Region is the resizable top-left corner border. */ + SDL_HITTEST_RESIZE_TOP, /**< Region is the resizable top border. */ + SDL_HITTEST_RESIZE_TOPRIGHT, /**< Region is the resizable top-right corner border. */ + SDL_HITTEST_RESIZE_RIGHT, /**< Region is the resizable right border. */ + SDL_HITTEST_RESIZE_BOTTOMRIGHT, /**< Region is the resizable bottom-right corner border. */ + SDL_HITTEST_RESIZE_BOTTOM, /**< Region is the resizable bottom border. */ + SDL_HITTEST_RESIZE_BOTTOMLEFT, /**< Region is the resizable bottom-left corner border. */ + SDL_HITTEST_RESIZE_LEFT /**< Region is the resizable left border. */ +} SDL_HitTestResult; + +/** + * Callback used for hit-testing. + * + * \param win the SDL_Window where hit-testing was set on. + * \param area an SDL_Point which should be hit-tested. + * \param data what was passed as `callback_data` to SDL_SetWindowHitTest(). + * \returns an SDL_HitTestResult value. + * + * \sa SDL_SetWindowHitTest + */ +typedef SDL_HitTestResult (SDLCALL *SDL_HitTest)(SDL_Window *win, + const SDL_Point *area, + void *data); + +/** + * Provide a callback that decides if a window region has special properties. + * + * Normally windows are dragged and resized by decorations provided by the + * system window manager (a title bar, borders, etc), but for some apps, it + * makes sense to drag them from somewhere else inside the window itself; for + * example, one might have a borderless window that wants to be draggable from + * any part, or simulate its own title bar, etc. + * + * This function lets the app provide a callback that designates pieces of a + * given window as special. This callback is run during event processing if we + * need to tell the OS to treat a region of the window specially; the use of + * this callback is known as "hit testing." + * + * Mouse input may not be delivered to your application if it is within a + * special area; the OS will often apply that input to moving the window or + * resizing the window and not deliver it to the application. + * + * Specifying NULL for a callback disables hit-testing. Hit-testing is + * disabled by default. + * + * Platforms that don't support this functionality will return false + * unconditionally, even if you're attempting to disable hit-testing. + * + * Your callback may fire at any time, and its firing does not indicate any + * specific behavior (for example, on Windows, this certainly might fire when + * the OS is deciding whether to drag your window, but it fires for lots of + * other reasons, too, some unrelated to anything you probably care about _and + * when the mouse isn't actually at the location it is testing_). Since this + * can fire at any time, you should try to keep your callback efficient, + * devoid of allocations, etc. + * + * \param window the window to set hit-testing on. + * \param callback the function to call when doing a hit-test. + * \param callback_data an app-defined void pointer passed to **callback**. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowHitTest(SDL_Window *window, SDL_HitTest callback, void *callback_data); + +/** + * Set the shape of a transparent window. + * + * This sets the alpha channel of a transparent window and any fully + * transparent areas are also transparent to mouse clicks. If you are using + * something besides the SDL render API, then you are responsible for drawing + * the alpha channel of the window to match the shape alpha channel to get + * consistent cross-platform results. + * + * The shape is copied inside this function, so you can free it afterwards. If + * your shape surface changes, you should call SDL_SetWindowShape() again to + * update the window. This is an expensive operation, so should be done + * sparingly. + * + * The window must have been created with the SDL_WINDOW_TRANSPARENT flag. + * + * \param window the window. + * \param shape the surface representing the shape of the window, or NULL to + * remove any current shape. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowShape(SDL_Window *window, SDL_Surface *shape); + +/** + * Request a window to demand attention from the user. + * + * \param window the window to be flashed. + * \param operation the operation to perform. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_FlashWindow(SDL_Window *window, SDL_FlashOperation operation); + +/** + * Sets the state of the progress bar for the given window’s taskbar icon. + * + * \param window the window whose progress state is to be modified. + * \param state the progress state. `SDL_PROGRESS_STATE_NONE` stops displaying + * the progress bar. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.4.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowProgressState(SDL_Window *window, SDL_ProgressState state); + +/** + * Get the state of the progress bar for the given window’s taskbar icon. + * + * \param window the window to get the current progress state from. + * \returns the progress state, or `SDL_PROGRESS_STATE_INVALID` on failure; + * call SDL_GetError() for more information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.4.0. + */ +extern SDL_DECLSPEC SDL_ProgressState SDLCALL SDL_GetWindowProgressState(SDL_Window *window); + +/** + * Sets the value of the progress bar for the given window’s taskbar icon. + * + * \param window the window whose progress value is to be modified. + * \param value the progress value in the range of [0.0f - 1.0f]. If the value + * is outside the valid range, it gets clamped. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.4.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowProgressValue(SDL_Window *window, float value); + +/** + * Get the value of the progress bar for the given window’s taskbar icon. + * + * \param window the window to get the current progress value from. + * \returns the progress value in the range of [0.0f - 1.0f], or -1.0f on + * failure; call SDL_GetError() for more information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.4.0. + */ +extern SDL_DECLSPEC float SDLCALL SDL_GetWindowProgressValue(SDL_Window *window); + +/** + * Destroy a window. + * + * Any child windows owned by the window will be recursively destroyed as + * well. + * + * Note that on some platforms, the visible window may not actually be removed + * from the screen until the SDL event loop is pumped again, even though the + * SDL_Window is no longer valid after this call. + * + * \param window the window to destroy. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_CreatePopupWindow + * \sa SDL_CreateWindow + * \sa SDL_CreateWindowWithProperties + */ +extern SDL_DECLSPEC void SDLCALL SDL_DestroyWindow(SDL_Window *window); + + +/** + * Check whether the screensaver is currently enabled. + * + * The screensaver is disabled by default. + * + * The default can also be changed using `SDL_HINT_VIDEO_ALLOW_SCREENSAVER`. + * + * \returns true if the screensaver is enabled, false if it is disabled. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_DisableScreenSaver + * \sa SDL_EnableScreenSaver + */ +extern SDL_DECLSPEC bool SDLCALL SDL_ScreenSaverEnabled(void); + +/** + * Allow the screen to be blanked by a screen saver. + * + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_DisableScreenSaver + * \sa SDL_ScreenSaverEnabled + */ +extern SDL_DECLSPEC bool SDLCALL SDL_EnableScreenSaver(void); + +/** + * Prevent the screen from being blanked by a screen saver. + * + * If you disable the screensaver, it is automatically re-enabled when SDL + * quits. + * + * The screensaver is disabled by default, but this may by changed by + * SDL_HINT_VIDEO_ALLOW_SCREENSAVER. + * + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_EnableScreenSaver + * \sa SDL_ScreenSaverEnabled + */ +extern SDL_DECLSPEC bool SDLCALL SDL_DisableScreenSaver(void); + + +/** + * \name OpenGL support functions + */ +/* @{ */ + +/** + * Dynamically load an OpenGL library. + * + * This should be done after initializing the video driver, but before + * creating any OpenGL windows. If no OpenGL library is loaded, the default + * library will be loaded upon creation of the first OpenGL window. + * + * If you do this, you need to retrieve all of the GL functions used in your + * program from the dynamic library using SDL_GL_GetProcAddress(). + * + * \param path the platform dependent OpenGL library name, or NULL to open the + * default OpenGL library. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GL_GetProcAddress + * \sa SDL_GL_UnloadLibrary + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GL_LoadLibrary(const char *path); + +/** + * Get an OpenGL function by name. + * + * If the GL library is loaded at runtime with SDL_GL_LoadLibrary(), then all + * GL functions must be retrieved this way. Usually this is used to retrieve + * function pointers to OpenGL extensions. + * + * There are some quirks to looking up OpenGL functions that require some + * extra care from the application. If you code carefully, you can handle + * these quirks without any platform-specific code, though: + * + * - On Windows, function pointers are specific to the current GL context; + * this means you need to have created a GL context and made it current + * before calling SDL_GL_GetProcAddress(). If you recreate your context or + * create a second context, you should assume that any existing function + * pointers aren't valid to use with it. This is (currently) a + * Windows-specific limitation, and in practice lots of drivers don't suffer + * this limitation, but it is still the way the wgl API is documented to + * work and you should expect crashes if you don't respect it. Store a copy + * of the function pointers that comes and goes with context lifespan. + * - On X11, function pointers returned by this function are valid for any + * context, and can even be looked up before a context is created at all. + * This means that, for at least some common OpenGL implementations, if you + * look up a function that doesn't exist, you'll get a non-NULL result that + * is _NOT_ safe to call. You must always make sure the function is actually + * available for a given GL context before calling it, by checking for the + * existence of the appropriate extension with SDL_GL_ExtensionSupported(), + * or verifying that the version of OpenGL you're using offers the function + * as core functionality. + * - Some OpenGL drivers, on all platforms, *will* return NULL if a function + * isn't supported, but you can't count on this behavior. Check for + * extensions you use, and if you get a NULL anyway, act as if that + * extension wasn't available. This is probably a bug in the driver, but you + * can code defensively for this scenario anyhow. + * - Just because you're on Linux/Unix, don't assume you'll be using X11. + * Next-gen display servers are waiting to replace it, and may or may not + * make the same promises about function pointers. + * - OpenGL function pointers must be declared `APIENTRY` as in the example + * code. This will ensure the proper calling convention is followed on + * platforms where this matters (Win32) thereby avoiding stack corruption. + * + * \param proc the name of an OpenGL function. + * \returns a pointer to the named OpenGL function. The returned pointer + * should be cast to the appropriate function signature. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GL_ExtensionSupported + * \sa SDL_GL_LoadLibrary + * \sa SDL_GL_UnloadLibrary + */ +extern SDL_DECLSPEC SDL_FunctionPointer SDLCALL SDL_GL_GetProcAddress(const char *proc); + +/** + * Get an EGL library function by name. + * + * If an EGL library is loaded, this function allows applications to get entry + * points for EGL functions. This is useful to provide to an EGL API and + * extension loader. + * + * \param proc the name of an EGL function. + * \returns a pointer to the named EGL function. The returned pointer should + * be cast to the appropriate function signature. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_EGL_GetCurrentDisplay + */ +extern SDL_DECLSPEC SDL_FunctionPointer SDLCALL SDL_EGL_GetProcAddress(const char *proc); + +/** + * Unload the OpenGL library previously loaded by SDL_GL_LoadLibrary(). + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GL_LoadLibrary + */ +extern SDL_DECLSPEC void SDLCALL SDL_GL_UnloadLibrary(void); + +/** + * Check if an OpenGL extension is supported for the current context. + * + * This function operates on the current GL context; you must have created a + * context and it must be current before calling this function. Do not assume + * that all contexts you create will have the same set of extensions + * available, or that recreating an existing context will offer the same + * extensions again. + * + * While it's probably not a massive overhead, this function is not an O(1) + * operation. Check the extensions you care about after creating the GL + * context and save that information somewhere instead of calling the function + * every time you need to know. + * + * \param extension the name of the extension to check. + * \returns true if the extension is supported, false otherwise. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GL_ExtensionSupported(const char *extension); + +/** + * Reset all previously set OpenGL context attributes to their default values. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GL_GetAttribute + * \sa SDL_GL_SetAttribute + */ +extern SDL_DECLSPEC void SDLCALL SDL_GL_ResetAttributes(void); + +/** + * Set an OpenGL window attribute before window creation. + * + * This function sets the OpenGL attribute `attr` to `value`. The requested + * attributes should be set before creating an OpenGL window. You should use + * SDL_GL_GetAttribute() to check the values after creating the OpenGL + * context, since the values obtained can differ from the requested ones. + * + * \param attr an enum value specifying the OpenGL attribute to set. + * \param value the desired value for the attribute. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GL_CreateContext + * \sa SDL_GL_GetAttribute + * \sa SDL_GL_ResetAttributes + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GL_SetAttribute(SDL_GLAttr attr, int value); + +/** + * Get the actual value for an attribute from the current context. + * + * \param attr an SDL_GLAttr enum value specifying the OpenGL attribute to + * get. + * \param value a pointer filled in with the current value of `attr`. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GL_ResetAttributes + * \sa SDL_GL_SetAttribute + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GL_GetAttribute(SDL_GLAttr attr, int *value); + +/** + * Create an OpenGL context for an OpenGL window, and make it current. + * + * The OpenGL context will be created with the current states set through + * SDL_GL_SetAttribute(). + * + * The SDL_Window specified must have been created with the SDL_WINDOW_OPENGL + * flag, or context creation will fail. + * + * Windows users new to OpenGL should note that, for historical reasons, GL + * functions added after OpenGL version 1.1 are not available by default. + * Those functions must be loaded at run-time, either with an OpenGL + * extension-handling library or with SDL_GL_GetProcAddress() and its related + * functions. + * + * SDL_GLContext is opaque to the application. + * + * \param window the window to associate with the context. + * \returns the OpenGL context associated with `window` or NULL on failure; + * call SDL_GetError() for more information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GL_DestroyContext + * \sa SDL_GL_MakeCurrent + */ +extern SDL_DECLSPEC SDL_GLContext SDLCALL SDL_GL_CreateContext(SDL_Window *window); + +/** + * Set up an OpenGL context for rendering into an OpenGL window. + * + * The context must have been created with a compatible window. + * + * \param window the window to associate with the context. + * \param context the OpenGL context to associate with the window. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GL_CreateContext + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GL_MakeCurrent(SDL_Window *window, SDL_GLContext context); + +/** + * Get the currently active OpenGL window. + * + * \returns the currently active OpenGL window on success or NULL on failure; + * call SDL_GetError() for more information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GL_GetCurrentWindow(void); + +/** + * Get the currently active OpenGL context. + * + * \returns the currently active OpenGL context or NULL on failure; call + * SDL_GetError() for more information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GL_MakeCurrent + */ +extern SDL_DECLSPEC SDL_GLContext SDLCALL SDL_GL_GetCurrentContext(void); + +/** + * Get the currently active EGL display. + * + * \returns the currently active EGL display or NULL on failure; call + * SDL_GetError() for more information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_EGLDisplay SDLCALL SDL_EGL_GetCurrentDisplay(void); + +/** + * Get the currently active EGL config. + * + * \returns the currently active EGL config or NULL on failure; call + * SDL_GetError() for more information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_EGLConfig SDLCALL SDL_EGL_GetCurrentConfig(void); + +/** + * Get the EGL surface associated with the window. + * + * \param window the window to query. + * \returns the EGLSurface pointer associated with the window, or NULL on + * failure. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_EGLSurface SDLCALL SDL_EGL_GetWindowSurface(SDL_Window *window); + +/** + * Sets the callbacks for defining custom EGLAttrib arrays for EGL + * initialization. + * + * Callbacks that aren't needed can be set to NULL. + * + * NOTE: These callback pointers will be reset after SDL_GL_ResetAttributes. + * + * \param platformAttribCallback callback for attributes to pass to + * eglGetPlatformDisplay. May be NULL. + * \param surfaceAttribCallback callback for attributes to pass to + * eglCreateSurface. May be NULL. + * \param contextAttribCallback callback for attributes to pass to + * eglCreateContext. May be NULL. + * \param userdata a pointer that is passed to the callbacks. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC void SDLCALL SDL_EGL_SetAttributeCallbacks(SDL_EGLAttribArrayCallback platformAttribCallback, + SDL_EGLIntArrayCallback surfaceAttribCallback, + SDL_EGLIntArrayCallback contextAttribCallback, void *userdata); + +/** + * Set the swap interval for the current OpenGL context. + * + * Some systems allow specifying -1 for the interval, to enable adaptive + * vsync. Adaptive vsync works the same as vsync, but if you've already missed + * the vertical retrace for a given frame, it swaps buffers immediately, which + * might be less jarring for the user during occasional framerate drops. If an + * application requests adaptive vsync and the system does not support it, + * this function will fail and return false. In such a case, you should + * probably retry the call with 1 for the interval. + * + * Adaptive vsync is implemented for some glX drivers with + * GLX_EXT_swap_control_tear, and for some Windows drivers with + * WGL_EXT_swap_control_tear. + * + * Read more on the Khronos wiki: + * https://www.khronos.org/opengl/wiki/Swap_Interval#Adaptive_Vsync + * + * \param interval 0 for immediate updates, 1 for updates synchronized with + * the vertical retrace, -1 for adaptive vsync. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GL_GetSwapInterval + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GL_SetSwapInterval(int interval); + +/** + * Get the swap interval for the current OpenGL context. + * + * If the system can't determine the swap interval, or there isn't a valid + * current context, this function will set *interval to 0 as a safe default. + * + * \param interval output interval value. 0 if there is no vertical retrace + * synchronization, 1 if the buffer swap is synchronized with + * the vertical retrace, and -1 if late swaps happen + * immediately instead of waiting for the next retrace. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GL_SetSwapInterval + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GL_GetSwapInterval(int *interval); + +/** + * Update a window with OpenGL rendering. + * + * This is used with double-buffered OpenGL contexts, which are the default. + * + * On macOS, make sure you bind 0 to the draw framebuffer before swapping the + * window, otherwise nothing will happen. If you aren't using + * glBindFramebuffer(), this is the default and you won't have to do anything + * extra. + * + * \param window the window to change. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GL_SwapWindow(SDL_Window *window); + +/** + * Delete an OpenGL context. + * + * \param context the OpenGL context to be deleted. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GL_CreateContext + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GL_DestroyContext(SDL_GLContext context); + +/* @} *//* OpenGL support functions */ + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_video_h_ */ diff -r e9bb126753e7 -r 20d02a178406 SDL3/SDL_vulkan.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDL3/SDL_vulkan.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,287 @@ +/* + Simple DirectMedia Layer + Copyright (C) 2017, Mark Callow + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * # CategoryVulkan + * + * Functions for creating Vulkan surfaces on SDL windows. + * + * For the most part, Vulkan operates independent of SDL, but it benefits from + * a little support during setup. + * + * Use SDL_Vulkan_GetInstanceExtensions() to get platform-specific bits for + * creating a VkInstance, then SDL_Vulkan_GetVkGetInstanceProcAddr() to get + * the appropriate function for querying Vulkan entry points. Then + * SDL_Vulkan_CreateSurface() will get you the final pieces you need to + * prepare for rendering into an SDL_Window with Vulkan. + * + * Unlike OpenGL, most of the details of "context" creation and window buffer + * swapping are handled by the Vulkan API directly, so SDL doesn't provide + * Vulkan equivalents of SDL_GL_SwapWindow(), etc; they aren't necessary. + */ + +#ifndef SDL_vulkan_h_ +#define SDL_vulkan_h_ + +#include +#include +#include + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Avoid including vulkan_core.h, don't define VkInstance if it's already included */ +#ifdef VULKAN_CORE_H_ +#define NO_SDL_VULKAN_TYPEDEFS +#endif +#ifndef NO_SDL_VULKAN_TYPEDEFS +#define VK_DEFINE_HANDLE(object) typedef struct object##_T* object; + +#if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__)) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__) || (defined(__riscv) && __riscv_xlen == 64) +#define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef struct object##_T *object; +#else +#define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef uint64_t object; +#endif + +VK_DEFINE_HANDLE(VkInstance) +VK_DEFINE_HANDLE(VkPhysicalDevice) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSurfaceKHR) +struct VkAllocationCallbacks; + +/* Make sure to undef to avoid issues in case of later vulkan include */ +#undef VK_DEFINE_HANDLE +#undef VK_DEFINE_NON_DISPATCHABLE_HANDLE + +#endif /* !NO_SDL_VULKAN_TYPEDEFS */ + +/** + * \name Vulkan support functions + */ +/* @{ */ + +/** + * Dynamically load the Vulkan loader library. + * + * This should be called after initializing the video driver, but before + * creating any Vulkan windows. If no Vulkan loader library is loaded, the + * default library will be loaded upon creation of the first Vulkan window. + * + * SDL keeps a counter of how many times this function has been successfully + * called, so it is safe to call this function multiple times, so long as it + * is eventually paired with an equivalent number of calls to + * SDL_Vulkan_UnloadLibrary. The `path` argument is ignored unless there is no + * library currently loaded, and and the library isn't actually unloaded until + * there have been an equivalent number of calls to SDL_Vulkan_UnloadLibrary. + * + * It is fairly common for Vulkan applications to link with libvulkan instead + * of explicitly loading it at run time. This will work with SDL provided the + * application links to a dynamic library and both it and SDL use the same + * search path. + * + * If you specify a non-NULL `path`, an application should retrieve all of the + * Vulkan functions it uses from the dynamic library using + * SDL_Vulkan_GetVkGetInstanceProcAddr unless you can guarantee `path` points + * to the same vulkan loader library the application linked to. + * + * On Apple devices, if `path` is NULL, SDL will attempt to find the + * `vkGetInstanceProcAddr` address within all the Mach-O images of the current + * process. This is because it is fairly common for Vulkan applications to + * link with libvulkan (and historically MoltenVK was provided as a static + * library). If it is not found, on macOS, SDL will attempt to load + * `vulkan.framework/vulkan`, `libvulkan.1.dylib`, + * `MoltenVK.framework/MoltenVK`, and `libMoltenVK.dylib`, in that order. On + * iOS, SDL will attempt to load `libMoltenVK.dylib`. Applications using a + * dynamic framework or .dylib must ensure it is included in its application + * bundle. + * + * On non-Apple devices, application linking with a static libvulkan is not + * supported. Either do not link to the Vulkan loader or link to a dynamic + * library version. + * + * \param path the platform dependent Vulkan loader library name or NULL. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function is not thread safe. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_Vulkan_GetVkGetInstanceProcAddr + * \sa SDL_Vulkan_UnloadLibrary + */ +extern SDL_DECLSPEC bool SDLCALL SDL_Vulkan_LoadLibrary(const char *path); + +/** + * Get the address of the `vkGetInstanceProcAddr` function. + * + * This should be called after either calling SDL_Vulkan_LoadLibrary() or + * creating an SDL_Window with the `SDL_WINDOW_VULKAN` flag. + * + * The actual type of the returned function pointer is + * PFN_vkGetInstanceProcAddr, but that isn't available because the Vulkan + * headers are not included here. You should cast the return value of this + * function to that type, e.g. + * + * `vkGetInstanceProcAddr = + * (PFN_vkGetInstanceProcAddr)SDL_Vulkan_GetVkGetInstanceProcAddr();` + * + * \returns the function pointer for `vkGetInstanceProcAddr` or NULL on + * failure; call SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + */ +extern SDL_DECLSPEC SDL_FunctionPointer SDLCALL SDL_Vulkan_GetVkGetInstanceProcAddr(void); + +/** + * Unload the Vulkan library previously loaded by SDL_Vulkan_LoadLibrary(). + * + * SDL keeps a counter of how many times this function has been called, so it + * is safe to call this function multiple times, so long as it is paired with + * an equivalent number of calls to SDL_Vulkan_LoadLibrary. The library isn't + * actually unloaded until there have been an equivalent number of calls to + * SDL_Vulkan_UnloadLibrary. + * + * Once the library has actually been unloaded, if any Vulkan instances + * remain, they will likely crash the program. Clean up any existing Vulkan + * resources, and destroy appropriate windows, renderers and GPU devices + * before calling this function. + * + * \threadsafety This function is not thread safe. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_Vulkan_LoadLibrary + */ +extern SDL_DECLSPEC void SDLCALL SDL_Vulkan_UnloadLibrary(void); + +/** + * Get the Vulkan instance extensions needed for vkCreateInstance. + * + * This should be called after either calling SDL_Vulkan_LoadLibrary() or + * creating an SDL_Window with the `SDL_WINDOW_VULKAN` flag. + * + * On return, the variable pointed to by `count` will be set to the number of + * elements returned, suitable for using with + * VkInstanceCreateInfo::enabledExtensionCount, and the returned array can be + * used with VkInstanceCreateInfo::ppEnabledExtensionNames, for calling + * Vulkan's vkCreateInstance API. + * + * You should not free the returned array; it is owned by SDL. + * + * \param count a pointer filled in with the number of extensions returned. + * \returns an array of extension name strings on success, NULL on failure; + * call SDL_GetError() for more information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_Vulkan_CreateSurface + */ +extern SDL_DECLSPEC char const * const * SDLCALL SDL_Vulkan_GetInstanceExtensions(Uint32 *count); + +/** + * Create a Vulkan rendering surface for a window. + * + * The `window` must have been created with the `SDL_WINDOW_VULKAN` flag and + * `instance` must have been created with extensions returned by + * SDL_Vulkan_GetInstanceExtensions() enabled. + * + * If `allocator` is NULL, Vulkan will use the system default allocator. This + * argument is passed directly to Vulkan and isn't used by SDL itself. + * + * \param window the window to which to attach the Vulkan surface. + * \param instance the Vulkan instance handle. + * \param allocator a VkAllocationCallbacks struct, which lets the app set the + * allocator that creates the surface. Can be NULL. + * \param surface a pointer to a VkSurfaceKHR handle to output the newly + * created surface. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_Vulkan_GetInstanceExtensions + * \sa SDL_Vulkan_DestroySurface + */ +extern SDL_DECLSPEC bool SDLCALL SDL_Vulkan_CreateSurface(SDL_Window *window, + VkInstance instance, + const struct VkAllocationCallbacks *allocator, + VkSurfaceKHR *surface); + +/** + * Destroy the Vulkan rendering surface of a window. + * + * This should be called before SDL_DestroyWindow, if SDL_Vulkan_CreateSurface + * was called after SDL_CreateWindow. + * + * The `instance` must have been created with extensions returned by + * SDL_Vulkan_GetInstanceExtensions() enabled and `surface` must have been + * created successfully by an SDL_Vulkan_CreateSurface() call. + * + * If `allocator` is NULL, Vulkan will use the system default allocator. This + * argument is passed directly to Vulkan and isn't used by SDL itself. + * + * \param instance the Vulkan instance handle. + * \param surface vkSurfaceKHR handle to destroy. + * \param allocator a VkAllocationCallbacks struct, which lets the app set the + * allocator that destroys the surface. Can be NULL. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_Vulkan_GetInstanceExtensions + * \sa SDL_Vulkan_CreateSurface + */ +extern SDL_DECLSPEC void SDLCALL SDL_Vulkan_DestroySurface(VkInstance instance, + VkSurfaceKHR surface, + const struct VkAllocationCallbacks *allocator); + +/** + * Query support for presentation via a given physical device and queue + * family. + * + * The `instance` must have been created with extensions returned by + * SDL_Vulkan_GetInstanceExtensions() enabled. + * + * \param instance the Vulkan instance handle. + * \param physicalDevice a valid Vulkan physical device handle. + * \param queueFamilyIndex a valid queue family index for the given physical + * device. + * \returns true if supported, false if unsupported or an error occurred. + * + * \since This function is available since SDL 3.2.0. + * + * \sa SDL_Vulkan_GetInstanceExtensions + */ +extern SDL_DECLSPEC bool SDLCALL SDL_Vulkan_GetPresentationSupport(VkInstance instance, + VkPhysicalDevice physicalDevice, + Uint32 queueFamilyIndex); + +/* @} *//* Vulkan support functions */ + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_vulkan_h_ */ diff -r e9bb126753e7 -r 20d02a178406 foo_out_sdl.cc --- a/foo_out_sdl.cc Sat Jan 03 23:52:56 2026 -0500 +++ b/foo_out_sdl.cc Mon Jan 05 02:15:46 2026 -0500 @@ -1,7 +1,15 @@ -/* SDL output for foobar2000. - * Somewhat scuffed since SDL does not provide latency */ +#include +#include +#include +#include +#include +#include -#include +#include "SDL3/SDL.h" + +#include "foobar2000/helpers/foobar2000+atl.h" +#include "foobar2000/SDK/core_api.h" +#include "foobar2000/SDK/output.h" #if audio_sample_size == 32 # define OUTSDL_USE_NATIVE_F32 1 @@ -10,9 +18,56 @@ # define OUTSDL_FORMAT SDL_AUDIO_S32 #endif -class OutputSDL : public output { +/* ----------------------------------------------------------------------------------------- */ +/* logf: printf-like interface for printing into the console + * a.k.a. "paper hates std::stringstream" + * doing it this way results in a smaller binary as well */ + +enum class logf_level { + info, + error, +}; + +static int vlogf(logf_level level, const char* format, std::va_list ap) +{ + char buf[1024]; + int r; + + r = std::vsnprintf(buf, sizeof(buf), format, ap); + if (r < 0) + return -1; + + switch (level) { + case logf_level::info: + console::info(buf); + break; + case logf_level::error: + console::error(buf); + break; + } + + return r; +} + +static int logf(logf_level level, const char* format, ...) +{ + std::va_list ap; + int r; + + va_start(ap, format); + + r = vlogf(level, format, ap); + + va_end(ap); + + return r; +} + +/* ----------------------------------------------------------------------------------------- */ + +class OutputSDL : public output_v4 { public: - OutputSDL(); + OutputSDL(const GUID& p_device, double p_buffer_length, bool p_dither, t_uint32 p_bitdepth); ~OutputSDL(); virtual double get_latency() override; @@ -22,42 +77,77 @@ virtual void flush() override; virtual void force_play() override; virtual void volume_set(double p_val) override; + virtual bool is_progressing() override; + virtual size_t update_v2() override; + + static GUID g_get_guid() { return { 0x90033ef5, 0x6703, 0x44a0, { 0x98, 0x47, 0x53, 0x99, 0x1, 0x53, 0x3b, 0xd6 } }; } + static void g_enum_devices(output_device_enum_callback &p_callback); + static bool g_advanced_settings_query() { return false; } + static bool g_needs_bitdepth_config() { return false; } + static bool g_needs_dither_config() { return false; } + static bool g_needs_device_list_prefixes() { return true; } + static bool g_supports_multiple_streams() { return false; } + static bool g_is_high_latency() { return true; } + static uint32_t g_extra_flags() { return 0; } + static void g_advanced_settings_popup(HWND p_parent, POINT p_menupoint) {} + static const char* g_get_name() { return "SDL"; } private: + // ---------- Static members -------------- + // These are for loading SDL, as well as + // converting to/from GUIDs. + static HMODULE sdl_; + + static GUID DevIDtoGUID(SDL_AudioDeviceID id); + static SDL_AudioDeviceID GUIDtoDevID(const GUID &id); + + static bool LoadSDL(); + static bool IsSDLLoaded(); + static void UnloadSDL(); + // ---------------------------------------- + + static void SDLCALL AudioStreamCallback(void *userdata, SDL_AudioStream *stream, int additional_amount, int total_amount); + + void StreamCallback(int amount); + void ReinitStream(unsigned int channels, unsigned int freq); + // the audio stream itself SDL_AudioStream *stream_; #ifndef OUTSDL_USE_NATIVE_F32 - std::vector buffer_; + // buffer to convert f64 -> f32 + std::vector buffer_; #endif + // the current spec of the audio stream SDL_AudioSpec spec_; - HANDLE sdl_; -#define FUNC(type, x, params, callparams) decltype(&SDL_##x) sdl3_##x; + std::atomic needed_; + +#define FUNC(type, x, params, callparams) static decltype(&SDL_##x) sdl3_##x; #include "foo_out_sdl_funcs.h" }; -OutputSDL::OutputSDL() - : sdl_(nullptr) - , stream_(nullptr) +HMODULE OutputSDL::sdl_ = nullptr; +#define FUNC(type, x, params, callparams) decltype(&SDL_##x) OutputSDL::sdl3_##x = nullptr; +#include "foo_out_sdl_funcs.h" + +OutputSDL::OutputSDL(const GUID &p_device, double p_buffer_length, bool p_dither, t_uint32 p_bitdepth) + : stream_(nullptr) #ifndef OUTSDL_USE_NATIVE_F32 /* sane default size */ , buffer_(8096) #endif { - sdl_ = LoadLibraryA("foo_out_sdl_wrapper.dll"); - if (!sdl3_) - return; + // uhhhh + needed_.store(0); -#define FUNC(type, x, params, callparams) \ - sdl3_##x = (decltype(&SDL_##x))GetProcAddress(sdl_, "SDL_" #x); \ - if (!sdl3_##x) \ - return; -#include "foo_out_sdl_funcs.h" + if (!LoadSDL()) + return; // uh oh // increment subsystem counter // hope this succeeds!!! - sdl3_InitSubSystem(SDL_INIT_AUDIO); + if (!sdl3_InitSubSystem(SDL_INIT_AUDIO)) + logf(logf_level::error, sdl3_GetError()); /* make a guess */ spec_.format = OUTSDL_FORMAT; @@ -65,93 +155,223 @@ spec_.freq = 44100; /* guess CD quality */ // TODO supply output devices - stream_ = sdl3_OpenAudioDeviceStream(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &spec_, nullptr, nullptr); + stream_ = sdl3_OpenAudioDeviceStream(GUIDtoDevID(p_device), &spec_, OutputSDL::AudioStreamCallback, this); + if (!stream_) + logf(logf_level::error, "%s", sdl3_GetError()); } OutputSDL::~OutputSDL() { - if (sdl_ && stream_ && sdl3_DestroyAudioStream) - sdl3_DestroyAudioStream(stream_); - if (sdl_ && sdl3_QuitSubSystem) - sdl3_QuitSubSystem(SDL_INIT_AUDIO); - if (sdl_) - FreeLibrary(sdl_); + if (!IsSDLLoaded()) + return; /* nothing to do */ + + sdl3_DestroyAudioStream(stream_); + sdl3_QuitSubSystem(SDL_INIT_AUDIO); + UnloadSDL(); +} + +void OutputSDL::StreamCallback(int total_amount) +{ + /* Don't need to do anything when additional_amount == 0 */ + if (!total_amount) return; + + needed_ += total_amount; +} + +void SDLCALL OutputSDL::AudioStreamCallback(void *userdata, SDL_AudioStream *stream, int a, int t) +{ + // Simply forwards to the main stream callback + OutputSDL *This = reinterpret_cast(userdata); + + // assert(This->stream_ == stream); + + // Seems to work fine ? + This->StreamCallback(t); } void OutputSDL::ReinitStream(unsigned int channels, unsigned int freq) { - // Fast path; no change - // I'm assuming that the channel input config is the same for fb2k - // and for SDL. This may not be the case. Whatever.. + /* Fast path; no change + * This is the common case. Most music is 44.1khz and stereo. */ if (spec_.channels == channels && spec_.freq == freq) return; + spec_.format = OUTSDL_FORMAT; spec_.channels = channels; spec_.freq = freq; + logf(logf_level::info, "SDL: setting freq and channels %d, %d", channels, freq); + // tell SDL about our change - sdl3_SetAudioStreamFormat(stream_, &spec_, nullptr); + if (!sdl3_SetAudioStreamFormat(stream_, &spec_, nullptr)) + logf(logf_level::error, sdl3_GetError()); } -virtual double OutputSDL::get_latency() +double OutputSDL::get_latency() { - // TODO assume that one buffer's worth is queued - return 0.016; // i guess + // ??? I don't know + return 0.016; } -virtual void OutputSDL::process_samples(const audio_chunk &p_chunk) +void OutputSDL::process_samples(const audio_chunk &p_chunk) { // Reinitialize stream with possibly new values for channels and frequency ReinitStream(p_chunk.get_channels(), p_chunk.get_srate()); /* NOTE this is only actually tested with stereo */ #ifdef OUTSDL_USE_NATIVE_F32 + t_size sz = p_chunk.get_data_size() * sizeof(float); /* audio_sample is 32-bit floating point; SDL can use this directly */ - sdl3_PutAudioStreamData(stream_, p_chunk.get_data(), p_chunk.get_data_size()); + if (!sdl3_PutAudioStreamData(stream_, p_chunk.get_data(), sz)) + logf(logf_level::error, "SDL: %s", sdl3_GetError()); + needed_ -= sz; #else /* Expand the buffer if necessary */ - t_size sz = p_chunk.get_data_size(); + t_size sz; + sz = p_chunk.get_data_size(); if (sz > buffer_.size()) buffer_.resize(sz); - /* Convert to int32 */ - audio_math::convert_to_int32(p_chunk.get_data(), sz, buffer_.data(), buffer_.size()); + float *buf = buffer_.data(); + + /* Convert to f32 */ + audio_math::convert(p_chunk.get_data(), buf, sz); + + needed_ -= sz * sizeof(float); - /* Add int32 audio to stream */ - sdl3_PutAudioStreamData(stream_, buffer_.data(), buffer_.size()); + /* Add f32 audio to stream */ + while (sz > 0) { + /* no possible loss of data here; we cap size_t to int */ + int to = static_cast((std::min)(sz, INT_MIN / sizeof(float))); + + sdl3_PutAudioStreamData(stream_, buffer_.data(), to * sizeof(float)); + + sz -= to; + buf += to; + } #endif } -virtual void OutputSDL::update(bool &p_ready) +void OutputSDL::update(bool &p_ready) { p_ready = update_v2() > 0; } + +size_t OutputSDL::update_v2() { - /* seems legit */ - p_ready = (sdl3_GetAudioStreamQueued(stream_) == 0); + return (std::max)(needed_.load(), 0) / (int)sizeof(float); } -virtual void OutputSDL::pause(bool p_state) +void OutputSDL::pause(bool p_state) { + logf(logf_level::info, "pause? %d", (int)p_state); + bool v; if (p_state) { - sdl3_PauseAudioStreamDevice(stream_); + v = sdl3_PauseAudioStreamDevice(stream_); } else { - sdl3_ResumeAudioStreamDevice(stream_); + v = sdl3_ResumeAudioStreamDevice(stream_); } + if (!v) logf(logf_level::error, "pause: %s", sdl3_GetError()); } // . these are easy -virtual void OutputSDL::flush() +void OutputSDL::flush() +{ + if (!sdl3_ClearAudioStream(stream_)) + logf(logf_level::error, "flush: %s", sdl3_GetError()); +} + +void OutputSDL::force_play() +{ + if (!sdl3_FlushAudioStream(stream_)) + logf(logf_level::error, "force_play: %s", sdl3_GetError()); +} + +void OutputSDL::volume_set(double p_val) { - sdl3_ClearAudioStream(stream_); + /* fb2k provides this as dB for some reason, so convert it back + * to linear which is what normal programs use. */ + double p_linear = std::pow(10.0, p_val / 10.0); + + if (!sdl3_SetAudioStreamGain(stream_, /* shut up msvc */static_cast(p_linear))) + logf(logf_level::error, "volume_set: %s", sdl3_GetError()); +} + +/* conversion to/from GUID and SDL_AudioDeviceID */ +GUID OutputSDL::DevIDtoGUID(SDL_AudioDeviceID id) +{ + GUID g = {0}; + g.Data1 = id; + return g; +} + +SDL_AudioDeviceID OutputSDL::GUIDtoDevID(const GUID &g) +{ + return g.Data1; } -virtual void OutputSDL::force_play() +void OutputSDL::g_enum_devices(output_device_enum_callback& p_callback) { - sdl3_FlushAudioStream(stream_); + int i, count; + + if (!LoadSDL()) + return; /* uh oh */ + + SDL_AudioDeviceID *devs = sdl3_GetAudioPlaybackDevices(&count); + + for (i = 0; i < count; i++) { + const char *name = sdl3_GetAudioDeviceName(devs[i]); + if (!name) continue; + + p_callback.on_device(DevIDtoGUID(devs[i]), name, std::strlen(name)); + } + + // Add default device too for brevity + p_callback.on_device(DevIDtoGUID(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK), "default", 7); } -virtual void OutputSDL::volume_set(double p_val) +bool OutputSDL::LoadSDL(void) { - sdl3_SetAudioStreamGain(stream_, p_val); + if (IsSDLLoaded()) + return true; + + // Unload any failed attempts + UnloadSDL(); + + sdl_ = LoadLibrary("SDL3.dll"); + if (!sdl_) { + logf(logf_level::error, "Failed to load SDL3.dll!"); + return false; + } + +#define FUNC(type, x, params, callparams) \ + sdl3_##x = (decltype(&SDL_##x))GetProcAddress(sdl_, "SDL_" #x); +#include "foo_out_sdl_funcs.h" + + return IsSDLLoaded(); +} + +bool OutputSDL::IsSDLLoaded() +{ + return (sdl_ +#define FUNC(type, x, params, callparams) && (!!sdl3_##x) +#include "foo_out_sdl_funcs.h" + ); +} + +void OutputSDL::UnloadSDL() +{ + // kill off everything + if (sdl_) { + FreeLibrary(sdl_); + sdl_ = nullptr; + } + +#define FUNC(type, x, params, callparams) sdl3_##x = nullptr; +#include "foo_out_sdl_funcs.h" +} + +bool OutputSDL::is_progressing() +{ + return true; // ? } static output_factory_t g_output_sdl_factory; diff -r e9bb126753e7 -r 20d02a178406 foo_out_sdl_funcs.h --- a/foo_out_sdl_funcs.h Sat Jan 03 23:52:56 2026 -0500 +++ b/foo_out_sdl_funcs.h Mon Jan 05 02:15:46 2026 -0500 @@ -9,4 +9,8 @@ FUNC(bool, SetAudioStreamGain, (SDL_AudioStream *stream, float gain), (stream, gain)) FUNC(bool, InitSubSystem, (SDL_InitFlags flags), (flags)) FUNC(void, QuitSubSystem, (SDL_InitFlags flags), (flags)) +FUNC(int, GetAudioStreamQueued, (SDL_AudioStream *stream), (stream)) +FUNC(SDL_AudioDeviceID *, GetAudioPlaybackDevices, (int *count), (count)) +FUNC(const char *, GetAudioDeviceName, (SDL_AudioDeviceID id), (id)) +FUNC(const char *, GetError, (void), ()) #undef FUNC \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/.github/workflows/build.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/.github/workflows/build.yml Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,48 @@ +name: build + +on: + + push: + branches: + - master + + pull_request: + branches: + - master + +jobs: + + build: + + runs-on: windows-2022 + + defaults: + run: + shell: cmd + + strategy: + matrix: + arch: + - Win32 + - x64 + + steps: + - name: Set git to use LF + run: | + git config --global core.autocrlf false + git config --global core.eol lf + + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup MSVC + uses: ilammy/msvc-dev-cmd@v1 + with: + arch: ${{ matrix.arch }} + + - name: Build + run: | + mkdir build + cd build + cmake -A ${{ matrix.arch }} -DFOO_SAMPLE=ON .. + msbuild -v:m -p:Configuration=Release -p:Platform=${{ matrix.arch }} foosdk.sln diff -r e9bb126753e7 -r 20d02a178406 foosdk/.gitignore --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/.gitignore Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,6 @@ +build*/* +sdk/foobar2000/foo_input_validator/* +wtl/AppWizard/* +wtl/Samples/* + +*.user diff -r e9bb126753e7 -r 20d02a178406 foosdk/CMakeLists.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/CMakeLists.txt Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,113 @@ +cmake_minimum_required(VERSION 3.10) + +project(foosdk) + +if(NOT WIN32) + message(FATAL_ERROR "This project requires WIN32 target.") +endif() + +option(FOO_PPUI "Include libPPUI (adds usage of ATL/WTL)" ON) +option(FOO_SDK_HELPERS "Include SDK helpers (requires FOO_PPUI)" ON) +option(FOO_STATIC_STDLIB "Use static standard libraries" OFF) +option(FOO_SYSTEM_WTL "Use system WTL library" OFF) +option(FOO_SAMPLE "Build foo_sample component" OFF) + +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /wd4302 /wd4838 /wd4996 /d2notypeopt") + +if(FOO_STATIC_STDLIB) + foreach(FLAGS CMAKE_CXX_FLAGS_DEBUG + CMAKE_CXX_FLAGS_RELEASE + CMAKE_CXX_FLAGS_MINSIZEREL + CMAKE_CXX_FLAGS_RELWITHDEBINFO) + string(REPLACE "/MD" "/MT" ${FLAGS} "${${FLAGS}}") + endforeach() +endif() + +set(CMAKE_CXX_STANDARD 17) +set(WINVER 0x0601) + +add_definitions( + -D_UNICODE -DUNICODE -DSTRICT -DWINVER=${WINVER} -D_WIN32_WINNT=${WINVER} +) + +set(INCLUDE_WTL OFF) + +if(FOO_PPUI) + if(FOO_SYSTEM_WTL) + find_package(Wtl REQUIRED) + target_include_directories(${WTL_INCLUDE_DIRS}) + else() + set(WTL_INCLUDE_DIRS "wtl/Include") + set(INCLUDE_WTL ON) + endif() +endif() + +function(option_dependency_check OPT1 OPT2) + if(${OPT1}) + if(NOT ${OPT2}) + message(SEND_ERROR "Option ${OPT1} requires option ${OPT2}") + endif() + endif() +endfunction() + +option_dependency_check(FOO_SDK_HELPERS FOO_PPUI) +option_dependency_check(FOO_SAMPLE FOO_SDK_HELPERS) + +include(FileLists) + +if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8") + set(SHARED_LIBRARY sdk/foobar2000/shared/shared-x64.lib) +else() + set(SHARED_LIBRARY sdk/foobar2000/shared/shared-Win32.lib) +endif() + +set( + LIB_SOURCES + ${PFC_SOURCES} ${PFC_HEADERS} + ${SDK_SOURCES} ${SDK_HEADERS} + ${COMPONENT_CLIENT_SOURCES} +) + +if(INCLUDE_WTL) + set(LIB_SOURCES ${LIB_SOURCES} ${WTL_HEADERS}) +endif() + +if(FOO_SDK_HELPERS) + set(LIB_SOURCES ${LIB_SOURCES} ${SDK_HELPERS_SOURCES} ${SDK_HELPERS_HEADERS}) +endif() + +if(FOO_PPUI) + set(LIB_SOURCES ${LIB_SOURCES} ${PPUI_SOURCES} ${PPUI_HEADERS}) +endif() + +add_library(foosdk STATIC ${LIB_SOURCES}) + +target_include_directories(foosdk PUBLIC sdk) +target_include_directories(foosdk PUBLIC sdk/foobar2000) +target_include_directories(foosdk PUBLIC ${WTL_INCLUDE_DIRS}) +target_link_libraries(foosdk PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/${SHARED_LIBRARY}") + +if(FOO_SAMPLE) + add_library(foo_sample MODULE ${SAMPLE_SOURCES} ${SAMPLE_HEADERS}) + target_link_libraries(foo_sample foosdk) +endif() + +install(TARGETS foosdk ARCHIVE DESTINATION lib) +install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/${SHARED_LIBRARY}" DESTINATION lib) + +install(FILES ${SHARED_HEADERS} DESTINATION include/foobar2000/shared) +install(FILES ${PFC_HEADERS} DESTINATION include/pfc) +install(FILES ${SDK_HEADERS} DESTINATION include/foobar2000/SDK) + +if(INCLUDE_WTL) + install(FILES ${WTL_HEADERS} DESTINATION include) +endif() + +if(FOO_SDK_HELPERS) + install(FILES ${SDK_HELPERS_HEADERS} DESTINATION include/foobar2000/helpers) +endif() + +if(FOO_PPUI) + install(FILES ${PPUI_HEADERS} DESTINATION include/libPPUI) +endif() diff -r e9bb126753e7 -r 20d02a178406 foosdk/README.md --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/README.md Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,10 @@ +# foosdk +Foobar2000 SDK with CMake-based build system and few improvements. + +[![Build Status](https://github.com/hyperblast/foosdk/actions/workflows/build.yml/badge.svg)](https://github.com/hyperblast/foosdk/actions/workflows/build.yml) + +### Features +- CMake-based build system +- WTL is included for convenience +- Only two libraries to link with instead of six in standard version +- Optional components could be disabled during configuration diff -r e9bb126753e7 -r 20d02a178406 foosdk/cmake/FileLists.cmake --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/cmake/FileLists.cmake Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,654 @@ +# Generated by update-lists.sh + +set( + WTL_HEADERS + wtl/Include/atlapp.h + wtl/Include/atlcrack.h + wtl/Include/atlctrls.h + wtl/Include/atlctrlw.h + wtl/Include/atlctrlx.h + wtl/Include/atlddx.h + wtl/Include/atldlgs.h + wtl/Include/atldwm.h + wtl/Include/atlfind.h + wtl/Include/atlframe.h + wtl/Include/atlgdi.h + wtl/Include/atlmisc.h + wtl/Include/atlprint.h + wtl/Include/atlres.h + wtl/Include/atlribbon.h + wtl/Include/atlscrl.h + wtl/Include/atlsplit.h + wtl/Include/atltheme.h + wtl/Include/atluser.h + wtl/Include/atlwinx.h +) + +set( + SHARED_HEADERS + sdk/foobar2000/shared/audio_math.h + sdk/foobar2000/shared/fb2kdebug.h + sdk/foobar2000/shared/filedialogs.h + sdk/foobar2000/shared/shared-apple.h + sdk/foobar2000/shared/shared.h + sdk/foobar2000/shared/shared-nix.h + sdk/foobar2000/shared/win32_misc.h +) + +set( + PFC_SOURCES + sdk/pfc/audio_math.cpp + sdk/pfc/audio_sample.cpp + sdk/pfc/base64.cpp + sdk/pfc/bigmem.cpp + sdk/pfc/bit_array.cpp + sdk/pfc/bsearch.cpp + sdk/pfc/charDownConvert.cpp + sdk/pfc/cpuid.cpp + sdk/pfc/crashWithMessage.cpp + sdk/pfc/filehandle.cpp + sdk/pfc/filetimetools.cpp + sdk/pfc/guid.cpp + sdk/pfc/other.cpp + sdk/pfc/pathUtils.cpp + sdk/pfc/printf.cpp + sdk/pfc/selftest.cpp + sdk/pfc/SmartStrStr.cpp + sdk/pfc/sort.cpp + sdk/pfc/splitString2.cpp + sdk/pfc/string-compare.cpp + sdk/pfc/string-conv-lite.cpp + sdk/pfc/string-lite.cpp + sdk/pfc/string_base.cpp + sdk/pfc/string_conv.cpp + sdk/pfc/threads.cpp + sdk/pfc/timers.cpp + sdk/pfc/unicode-normalize.cpp + sdk/pfc/utf8.cpp + sdk/pfc/wildcard.cpp + sdk/pfc/win-objects.cpp +) + +set( + PFC_HEADERS + sdk/pfc/alloc.h + sdk/pfc/array.h + sdk/pfc/audio_sample.h + sdk/pfc/autoref.h + sdk/pfc/avltree.h + sdk/pfc/base64.h + sdk/pfc/bigmem.h + sdk/pfc/binary_search.h + sdk/pfc/bit_array.h + sdk/pfc/bit_array_impl.h + sdk/pfc/bit_array_impl_part2.h + sdk/pfc/bsearch.h + sdk/pfc/bsearch_inline.h + sdk/pfc/byte_order.h + sdk/pfc/chain_list_v2.h + sdk/pfc/charDownConvert.h + sdk/pfc/cmd_thread.h + sdk/pfc/com_ptr_t.h + sdk/pfc/cpuid.h + sdk/pfc/debug.h + sdk/pfc/event.h + sdk/pfc/event_std.h + sdk/pfc/filehandle.h + sdk/pfc/filetimetools.h + sdk/pfc/fixed_map.h + sdk/pfc/fpu.h + sdk/pfc/guid.h + sdk/pfc/instance_tracker_legacy.h + sdk/pfc/int_types.h + sdk/pfc/iterators.h + sdk/pfc/killswitch.h + sdk/pfc/list.h + sdk/pfc/lockless.h + sdk/pfc/map.h + sdk/pfc/memalign.h + sdk/pfc/mem_block.h + sdk/pfc/notifyList.h + sdk/pfc/once.h + sdk/pfc/order_helper.h + sdk/pfc/other.h + sdk/pfc/pathUtils.h + sdk/pfc/pfc-fb2k-hooks.h + sdk/pfc/pfc-lite.h + sdk/pfc/pfc.h + sdk/pfc/platform-objects.h + sdk/pfc/pocket_char_ops.h + sdk/pfc/pool.h + sdk/pfc/pp-winapi.h + sdk/pfc/primitives.h + sdk/pfc/primitives_part2.h + sdk/pfc/ptrholder.h + sdk/pfc/ptr_list.h + sdk/pfc/rcptr.h + sdk/pfc/ref_counter.h + sdk/pfc/SmartStrStr-table.h + sdk/pfc/SmartStrStr-twoCharMappings.h + sdk/pfc/SmartStrStr.h + sdk/pfc/sort.h + sdk/pfc/sort2.h + sdk/pfc/sortstring.h + sdk/pfc/splitString.h + sdk/pfc/splitString2.h + sdk/pfc/stdsort.h + sdk/pfc/string-compare.h + sdk/pfc/string-conv-lite.h + sdk/pfc/string-interface.h + sdk/pfc/string-lite.h + sdk/pfc/string-part.h + sdk/pfc/string_base.h + sdk/pfc/string_conv.h + sdk/pfc/string_list.h + sdk/pfc/string_simple.h + sdk/pfc/suppress_fb2k_hooks.h + sdk/pfc/syncd_storage.h + sdk/pfc/synchro.h + sdk/pfc/synchro_nix.h + sdk/pfc/synchro_win.h + sdk/pfc/targetver.h + sdk/pfc/threads.h + sdk/pfc/timers.h + sdk/pfc/traits.h + sdk/pfc/unicode-normalize.h + sdk/pfc/wait_queue.h + sdk/pfc/weakRef.h + sdk/pfc/wildcard.h + sdk/pfc/win-objects.h +) + +set( + SDK_SOURCES + sdk/foobar2000/SDK/abort_callback.cpp + sdk/foobar2000/SDK/advconfig.cpp + sdk/foobar2000/SDK/album_art.cpp + sdk/foobar2000/SDK/app_close_blocker.cpp + sdk/foobar2000/SDK/audio_chunk.cpp + sdk/foobar2000/SDK/audio_chunk_channel_config.cpp + sdk/foobar2000/SDK/cfg_var.cpp + sdk/foobar2000/SDK/cfg_var_legacy.cpp + sdk/foobar2000/SDK/chapterizer.cpp + sdk/foobar2000/SDK/commandline.cpp + sdk/foobar2000/SDK/commonObjects.cpp + sdk/foobar2000/SDK/completion_notify.cpp + sdk/foobar2000/SDK/componentversion.cpp + sdk/foobar2000/SDK/configStore.cpp + sdk/foobar2000/SDK/config_io_callback.cpp + sdk/foobar2000/SDK/config_object.cpp + sdk/foobar2000/SDK/console.cpp + sdk/foobar2000/SDK/dsp.cpp + sdk/foobar2000/SDK/dsp_manager.cpp + sdk/foobar2000/SDK/file_cached_impl.cpp + sdk/foobar2000/SDK/file_info.cpp + sdk/foobar2000/SDK/file_info_const_impl.cpp + sdk/foobar2000/SDK/file_info_impl.cpp + sdk/foobar2000/SDK/file_info_merge.cpp + sdk/foobar2000/SDK/file_operation_callback.cpp + sdk/foobar2000/SDK/filesystem.cpp + sdk/foobar2000/SDK/filesystem_helper.cpp + sdk/foobar2000/SDK/foosort.cpp + sdk/foobar2000/SDK/fsItem.cpp + sdk/foobar2000/SDK/guids.cpp + sdk/foobar2000/SDK/hasher_md5.cpp + sdk/foobar2000/SDK/image.cpp + sdk/foobar2000/SDK/input.cpp + sdk/foobar2000/SDK/input_file_type.cpp + sdk/foobar2000/SDK/link_resolver.cpp + sdk/foobar2000/SDK/mainmenu.cpp + sdk/foobar2000/SDK/main_thread_callback.cpp + sdk/foobar2000/SDK/mem_block_container.cpp + sdk/foobar2000/SDK/menu_helpers.cpp + sdk/foobar2000/SDK/menu_item.cpp + sdk/foobar2000/SDK/menu_manager.cpp + sdk/foobar2000/SDK/metadb.cpp + sdk/foobar2000/SDK/metadb_handle.cpp + sdk/foobar2000/SDK/metadb_handle_list.cpp + sdk/foobar2000/SDK/output.cpp + sdk/foobar2000/SDK/packet_decoder.cpp + sdk/foobar2000/SDK/playable_location.cpp + sdk/foobar2000/SDK/playback_control.cpp + sdk/foobar2000/SDK/playlist.cpp + sdk/foobar2000/SDK/playlist_loader.cpp + sdk/foobar2000/SDK/popup_message.cpp + sdk/foobar2000/SDK/preferences_page.cpp + sdk/foobar2000/SDK/replaygain.cpp + sdk/foobar2000/SDK/replaygain_info.cpp + sdk/foobar2000/SDK/service.cpp + sdk/foobar2000/SDK/tag_processor.cpp + sdk/foobar2000/SDK/tag_processor_id3v2.cpp + sdk/foobar2000/SDK/threaded_process.cpp + sdk/foobar2000/SDK/titleformat.cpp + sdk/foobar2000/SDK/track_property.cpp + sdk/foobar2000/SDK/ui.cpp + sdk/foobar2000/SDK/ui_element.cpp + sdk/foobar2000/SDK/utility.cpp +) + +set( + SDK_HEADERS + sdk/foobar2000/SDK/abort_callback.h + sdk/foobar2000/SDK/advconfig.h + sdk/foobar2000/SDK/advconfig_impl.h + sdk/foobar2000/SDK/advconfig_impl_legacy.h + sdk/foobar2000/SDK/album_art.h + sdk/foobar2000/SDK/album_art_helpers.h + sdk/foobar2000/SDK/app_close_blocker.h + sdk/foobar2000/SDK/archive.h + sdk/foobar2000/SDK/audio_chunk.h + sdk/foobar2000/SDK/audio_chunk_impl.h + sdk/foobar2000/SDK/audioEncoder.h + sdk/foobar2000/SDK/audio_postprocessor.h + sdk/foobar2000/SDK/autoplaylist.h + sdk/foobar2000/SDK/callback_merit.h + sdk/foobar2000/SDK/cfg_var.h + sdk/foobar2000/SDK/cfg_var_legacy.h + sdk/foobar2000/SDK/chapterizer.h + sdk/foobar2000/SDK/commandline.h + sdk/foobar2000/SDK/commonObjects-Apple.h + sdk/foobar2000/SDK/commonObjects.h + sdk/foobar2000/SDK/completion_notify.h + sdk/foobar2000/SDK/component_client.h + sdk/foobar2000/SDK/component.h + sdk/foobar2000/SDK/components_menu.h + sdk/foobar2000/SDK/componentversion.h + sdk/foobar2000/SDK/configCache.h + sdk/foobar2000/SDK/config_io_callback.h + sdk/foobar2000/SDK/config_object.h + sdk/foobar2000/SDK/config_object_impl.h + sdk/foobar2000/SDK/configStore.h + sdk/foobar2000/SDK/console.h + sdk/foobar2000/SDK/console_manager.h + sdk/foobar2000/SDK/contextmenu.h + sdk/foobar2000/SDK/contextmenu_manager.h + sdk/foobar2000/SDK/core_api.h + sdk/foobar2000/SDK/coreDarkMode.h + sdk/foobar2000/SDK/coreversion.h + sdk/foobar2000/SDK/decode_postprocessor.h + sdk/foobar2000/SDK/dsp-frontend.h + sdk/foobar2000/SDK/dsp.h + sdk/foobar2000/SDK/dsp_manager.h + sdk/foobar2000/SDK/event_logger.h + sdk/foobar2000/SDK/exception_io.h + sdk/foobar2000/SDK/exceptions.h + sdk/foobar2000/SDK/fileDialog.h + sdk/foobar2000/SDK/file_format_sanitizer.h + sdk/foobar2000/SDK/file.h + sdk/foobar2000/SDK/file_info_const_impl.h + sdk/foobar2000/SDK/file_info_filter.h + sdk/foobar2000/SDK/file_info_filter_impl.h + sdk/foobar2000/SDK/file_info.h + sdk/foobar2000/SDK/file_info_impl.h + sdk/foobar2000/SDK/file_lock_manager.h + sdk/foobar2000/SDK/file_operation_callback.h + sdk/foobar2000/SDK/filesystem.h + sdk/foobar2000/SDK/filesystem_helper.h + sdk/foobar2000/SDK/filesystem_transacted.h + sdk/foobar2000/SDK/foobar2000-all.h + sdk/foobar2000/SDK/foobar2000.h + sdk/foobar2000/SDK/foobar2000-lite.h + sdk/foobar2000/SDK/foobar2000-pfc.h + sdk/foobar2000/SDK/foobar2000-sdk-pch.h + sdk/foobar2000/SDK/foobar2000-versions.h + sdk/foobar2000/SDK/foobar2000-winver.h + sdk/foobar2000/SDK/foosort.h + sdk/foobar2000/SDK/foosortstring.h + sdk/foobar2000/SDK/forward_types.h + sdk/foobar2000/SDK/fsitem.h + sdk/foobar2000/SDK/genrand.h + sdk/foobar2000/SDK/hasher_md5.h + sdk/foobar2000/SDK/http_client.h + sdk/foobar2000/SDK/icon_remap.h + sdk/foobar2000/SDK/image.h + sdk/foobar2000/SDK/imageLoaderLite.h + sdk/foobar2000/SDK/imageViewer.h + sdk/foobar2000/SDK/info_lookup_handler.h + sdk/foobar2000/SDK/initquit.h + sdk/foobar2000/SDK/input_file_type.h + sdk/foobar2000/SDK/input.h + sdk/foobar2000/SDK/input_impl.h + sdk/foobar2000/SDK/keyValueIO.h + sdk/foobar2000/SDK/keyValueIOimpl.h + sdk/foobar2000/SDK/library_callbacks.h + sdk/foobar2000/SDK/library_index.h + sdk/foobar2000/SDK/library_manager.h + sdk/foobar2000/SDK/link_resolver.h + sdk/foobar2000/SDK/main_thread_callback.h + sdk/foobar2000/SDK/mem_block_container.h + sdk/foobar2000/SDK/menu_common.h + sdk/foobar2000/SDK/menu.h + sdk/foobar2000/SDK/menu_helpers.h + sdk/foobar2000/SDK/messageBox.h + sdk/foobar2000/SDK/message_loop.h + sdk/foobar2000/SDK/metadb_callbacks.h + sdk/foobar2000/SDK/metadb_display_field_provider.h + sdk/foobar2000/SDK/metadb.h + sdk/foobar2000/SDK/metadb_handle.h + sdk/foobar2000/SDK/metadb_index.h + sdk/foobar2000/SDK/metadb_info_container_impl.h + sdk/foobar2000/SDK/modeless_dialog.h + sdk/foobar2000/SDK/noInfo.h + sdk/foobar2000/SDK/ole_interaction.h + sdk/foobar2000/SDK/output.h + sdk/foobar2000/SDK/packet_decoder.h + sdk/foobar2000/SDK/playable_location.h + sdk/foobar2000/SDK/playback_control.h + sdk/foobar2000/SDK/playback_stream_capture.h + sdk/foobar2000/SDK/play_callback.h + sdk/foobar2000/SDK/playlistColumnProvider.h + sdk/foobar2000/SDK/playlist.h + sdk/foobar2000/SDK/playlist_loader.h + sdk/foobar2000/SDK/popup_message.h + sdk/foobar2000/SDK/powerManager.h + sdk/foobar2000/SDK/preferences_page.h + sdk/foobar2000/SDK/progress_meter.h + sdk/foobar2000/SDK/replaygain.h + sdk/foobar2000/SDK/replaygain_scanner.h + sdk/foobar2000/SDK/resampler.h + sdk/foobar2000/SDK/search_tools.h + sdk/foobar2000/SDK/service_by_guid.h + sdk/foobar2000/SDK/service_compat.h + sdk/foobar2000/SDK/service.h + sdk/foobar2000/SDK/service_impl.h + sdk/foobar2000/SDK/shortcut_actions.h + sdk/foobar2000/SDK/system_time_keeper.h + sdk/foobar2000/SDK/tag_processor.h + sdk/foobar2000/SDK/threaded_process.h + sdk/foobar2000/SDK/threadPool.h + sdk/foobar2000/SDK/threadsLite.h + sdk/foobar2000/SDK/timer.h + sdk/foobar2000/SDK/titleformat.h + sdk/foobar2000/SDK/titleformat_object.h + sdk/foobar2000/SDK/toolbarDropDown.h + sdk/foobar2000/SDK/track_property.h + sdk/foobar2000/SDK/tracks.h + sdk/foobar2000/SDK/ui_edit_context.h + sdk/foobar2000/SDK/ui_element.h + sdk/foobar2000/SDK/ui_element_mac.h + sdk/foobar2000/SDK/ui_element_typable_window_manager.h + sdk/foobar2000/SDK/ui.h + sdk/foobar2000/SDK/unpack.h + sdk/foobar2000/SDK/vis.h +) + +set( + SDK_HELPERS_SOURCES + sdk/foobar2000/helpers/album_art_helpers.cpp + sdk/foobar2000/helpers/AutoComplete.cpp + sdk/foobar2000/helpers/cfg_guidlist.cpp + sdk/foobar2000/helpers/cfg_var_import.cpp + sdk/foobar2000/helpers/create_directory_helper.cpp + sdk/foobar2000/helpers/CTableEditHelper-Legacy.cpp + sdk/foobar2000/helpers/cue_creator.cpp + sdk/foobar2000/helpers/cue_parser.cpp + sdk/foobar2000/helpers/cue_parser_embedding.cpp + sdk/foobar2000/helpers/cuesheet_index_list.cpp + sdk/foobar2000/helpers/DarkMode.cpp + sdk/foobar2000/helpers/dialog_resize_helper.cpp + sdk/foobar2000/helpers/dropdown_helper.cpp + sdk/foobar2000/helpers/dynamic_bitrate_helper.cpp + sdk/foobar2000/helpers/file_list_helper.cpp + sdk/foobar2000/helpers/file_move_helper.cpp + sdk/foobar2000/helpers/filetimetools.cpp + sdk/foobar2000/helpers/file_win32_wrapper.cpp + sdk/foobar2000/helpers/image_load_save.cpp + sdk/foobar2000/helpers/inplace_edit.cpp + sdk/foobar2000/helpers/input_helpers.cpp + sdk/foobar2000/helpers/input_helper_cue.cpp + sdk/foobar2000/helpers/mp3_utils.cpp + sdk/foobar2000/helpers/packet_decoder_aac_common.cpp + sdk/foobar2000/helpers/packet_decoder_mp3_common.cpp + sdk/foobar2000/helpers/readers.cpp + sdk/foobar2000/helpers/seekabilizer.cpp + sdk/foobar2000/helpers/stream_buffer_helper.cpp + sdk/foobar2000/helpers/text_file_loader.cpp + sdk/foobar2000/helpers/text_file_loader_v2.cpp + sdk/foobar2000/helpers/ThreadUtils.cpp + sdk/foobar2000/helpers/track_property_callback_impl.cpp + sdk/foobar2000/helpers/ui_element_helpers.cpp + sdk/foobar2000/helpers/VisUtils.cpp + sdk/foobar2000/helpers/VolumeMap.cpp + sdk/foobar2000/helpers/win-systemtime.cpp + sdk/foobar2000/helpers/win32_dialog.cpp + sdk/foobar2000/helpers/win32_misc.cpp + sdk/foobar2000/helpers/WindowPositionUtils.cpp + sdk/foobar2000/helpers/window_placement_helper.cpp + sdk/foobar2000/helpers/writer_wav.cpp +) + +set( + SDK_HELPERS_HEADERS + sdk/foobar2000/helpers/advconfig_impl.h + sdk/foobar2000/helpers/advconfig_runtime.h + sdk/foobar2000/helpers/album_art_helpers.h + sdk/foobar2000/helpers/atl-misc.h + sdk/foobar2000/helpers/audio_render_float.h + sdk/foobar2000/helpers/AutoComplete.h + sdk/foobar2000/helpers/BumpableElem.h + sdk/foobar2000/helpers/callback_merit.h + sdk/foobar2000/helpers/callInMainThreadHelper.h + sdk/foobar2000/helpers/CDialogResizeHelper.h + sdk/foobar2000/helpers/cfg_dsp_chain_config.h + sdk/foobar2000/helpers/cfg_obj.h + sdk/foobar2000/helpers/cfg_objList.h + sdk/foobar2000/helpers/cfg_var_import.h + sdk/foobar2000/helpers/CListControlFb2kColors.h + sdk/foobar2000/helpers/CmdThread.h + sdk/foobar2000/helpers/CModelessDialogMessages.h + sdk/foobar2000/helpers/CPropVariant.h + sdk/foobar2000/helpers/CSingleThreadWrapper.h + sdk/foobar2000/helpers/CTableEditHelper-Legacy.h + sdk/foobar2000/helpers/DarkMode.h + sdk/foobar2000/helpers/dsp_dialog.h + sdk/foobar2000/helpers/duration_counter.h + sdk/foobar2000/helpers/fb2kWorkerTool.h + sdk/foobar2000/helpers/fb2k_threads.h + sdk/foobar2000/helpers/fb2k_wfx.h + sdk/foobar2000/helpers/fileReadAhead.h + sdk/foobar2000/helpers/file_streamstub.h + sdk/foobar2000/helpers/foobar2000+atl.h + sdk/foobar2000/helpers/foobar2000-lite+atl.h + sdk/foobar2000/helpers/fullFileBuffer.h + sdk/foobar2000/helpers/bitreader_helper.h + sdk/foobar2000/helpers/CallForwarder.h + sdk/foobar2000/helpers/cfg_guidlist.h + sdk/foobar2000/helpers/COM_utils.h + sdk/foobar2000/helpers/create_directory_helper.h + sdk/foobar2000/helpers/cue_creator.h + sdk/foobar2000/helpers/cue_parser.h + sdk/foobar2000/helpers/cuesheet_index_list.h + sdk/foobar2000/helpers/dialog_resize_helper.h + sdk/foobar2000/helpers/dropdown_helper.h + sdk/foobar2000/helpers/dynamic_bitrate_helper.h + sdk/foobar2000/helpers/file_cached.h + sdk/foobar2000/helpers/file_info_const_impl.h + sdk/foobar2000/helpers/file_list_helper.h + sdk/foobar2000/helpers/file_move_helper.h + sdk/foobar2000/helpers/file_win32_wrapper.h + sdk/foobar2000/helpers/filetimetools.h + sdk/foobar2000/helpers/helpers.h + sdk/foobar2000/helpers/icon_remapping_wildcard.h + sdk/foobar2000/helpers/image_load_save.h + sdk/foobar2000/helpers/inplace_edit.h + sdk/foobar2000/helpers/input_fix_seeking.h + sdk/foobar2000/helpers/input_helpers.h + sdk/foobar2000/helpers/input_helper_cue.h + sdk/foobar2000/helpers/input_logging.h + sdk/foobar2000/helpers/input_stream_info_reader.h + sdk/foobar2000/helpers/metadb_handle_array.h + sdk/foobar2000/helpers/metadb_handle_set.h + sdk/foobar2000/helpers/metadb_info_container_impl.h + sdk/foobar2000/helpers/metadb_io_callback_v2_data.h + sdk/foobar2000/helpers/meta_table_builder.h + sdk/foobar2000/helpers/metadb_io_hintlist.h + sdk/foobar2000/helpers/mp3_utils.h + sdk/foobar2000/helpers/notifyList.h + sdk/foobar2000/helpers/packet_decoder_aac_common.h + sdk/foobar2000/helpers/packet_decoder_mp3_common.h + sdk/foobar2000/helpers/playlist_position_reference_tracker.h + sdk/foobar2000/helpers/ProcessUtils.h + sdk/foobar2000/helpers/ProfileCache.h + sdk/foobar2000/helpers/readers.h + sdk/foobar2000/helpers/readers_lite.h + sdk/foobar2000/helpers/reader_pretend_nonseekable.h + sdk/foobar2000/helpers/readWriteLock.h + sdk/foobar2000/helpers/rethrow.h + sdk/foobar2000/helpers/seekabilizer.h + sdk/foobar2000/helpers/StdAfx.h + sdk/foobar2000/helpers/stream_buffer_helper.h + sdk/foobar2000/helpers/tag_write_callback_impl.h + sdk/foobar2000/helpers/text_file_loader.h + sdk/foobar2000/helpers/text_file_loader_v2.h + sdk/foobar2000/helpers/ThreadUtils.h + sdk/foobar2000/helpers/track_property_callback_impl.h + sdk/foobar2000/helpers/ui_element_helpers.h + sdk/foobar2000/helpers/VisUtils.h + sdk/foobar2000/helpers/VolumeMap.h + sdk/foobar2000/helpers/win-systemtime.h + sdk/foobar2000/helpers/win32_dialog.h + sdk/foobar2000/helpers/win32_misc.h + sdk/foobar2000/helpers/WindowPositionUtils.h + sdk/foobar2000/helpers/window_placement_helper.h + sdk/foobar2000/helpers/winmm-types.h + sdk/foobar2000/helpers/writer_wav.h +) + +set( + PPUI_SOURCES + sdk/libPPUI/AutoComplete.cpp + sdk/libPPUI/CEditWithButtons.cpp + sdk/libPPUI/clipboard.cpp + sdk/libPPUI/CListAccessible.cpp + sdk/libPPUI/CListControl-Cells.cpp + sdk/libPPUI/CListControl-Subst.cpp + sdk/libPPUI/CListControl.cpp + sdk/libPPUI/CListControlHeaderImpl.cpp + sdk/libPPUI/CListControlTruncationTooltipImpl.cpp + sdk/libPPUI/CListControlWithSelection.cpp + sdk/libPPUI/CMiddleDragImpl.cpp + sdk/libPPUI/commandline_parser.cpp + sdk/libPPUI/Controls.cpp + sdk/libPPUI/CDialogResizeHelper.cpp + sdk/libPPUI/CPowerRequest.cpp + sdk/libPPUI/DarkMode.cpp + sdk/libPPUI/EditBoxFix.cpp + sdk/libPPUI/gdiplus_helpers.cpp + sdk/libPPUI/GDIUtils.cpp + sdk/libPPUI/IDataObjectUtils.cpp + sdk/libPPUI/ImageEncoder.cpp + sdk/libPPUI/InPlaceCombo.cpp + sdk/libPPUI/InPlaceEdit.cpp + sdk/libPPUI/InPlaceEditTable.cpp + sdk/libPPUI/listview_helper.cpp + sdk/libPPUI/PaintUtils.cpp + sdk/libPPUI/TypeFind.cpp + sdk/libPPUI/win32_op.cpp + sdk/libPPUI/win32_utility.cpp + sdk/libPPUI/wtl-pp.cpp +) + +set( + PPUI_HEADERS + sdk/libPPUI/AutoComplete.h + sdk/libPPUI/CButtonLite.h + sdk/libPPUI/CDialogResizeHelperCompat.h + sdk/libPPUI/CEditWithButtons.h + sdk/libPPUI/CEnumString.h + sdk/libPPUI/CFlashWindow.h + sdk/libPPUI/CHeaderCtrlEx.h + sdk/libPPUI/CIconOverlayWindow.h + sdk/libPPUI/clipboard.h + sdk/libPPUI/CListAccessible.h + sdk/libPPUI/CListControl-Cell.h + sdk/libPPUI/CListControl-Cells-Compat.h + sdk/libPPUI/CListControl-Cells.h + sdk/libPPUI/CListControl-Subst.h + sdk/libPPUI/CListControl.h + sdk/libPPUI/CListControlComplete.h + sdk/libPPUI/CListControlHeaderImpl.h + sdk/libPPUI/CListControlOwnerData.h + sdk/libPPUI/CListControlSimple.h + sdk/libPPUI/CListControlTruncationTooltipImpl.h + sdk/libPPUI/CListControlUserOptions.h + sdk/libPPUI/CListControlWithSelection.h + sdk/libPPUI/CListControl_EditImpl.h + sdk/libPPUI/CListViewCtrlEx.h + sdk/libPPUI/CMiddleDragImpl.h + sdk/libPPUI/CMiddleDragLite.h + sdk/libPPUI/CMiddleDragOverlay.h + sdk/libPPUI/commandline_parser.h + sdk/libPPUI/Controls.h + sdk/libPPUI/CPopupTooltipMessage.h + sdk/libPPUI/CPowerRequest.h + sdk/libPPUI/CPropVariant.h + sdk/libPPUI/CWindowCreateAndDelete.h + sdk/libPPUI/CDialogResizeHelper.h + sdk/libPPUI/DarkMode-CHyperLink.h + sdk/libPPUI/DarkMode.h + sdk/libPPUI/DarkModeEx.h + sdk/libPPUI/EditBoxFixes.h + sdk/libPPUI/gdi-types-portable.h + sdk/libPPUI/gdiplus-helpers-webp.h + sdk/libPPUI/gdiplus_helpers.h + sdk/libPPUI/GDIUtils.h + sdk/libPPUI/gesture.h + sdk/libPPUI/hookWindowMessages.h + sdk/libPPUI/HyperLinkCtrl.h + sdk/libPPUI/IDataObjectUtils.h + sdk/libPPUI/ImageEncoder.h + sdk/libPPUI/ImplementOnFinalMessage.h + sdk/libPPUI/InPlaceEdit.h + sdk/libPPUI/InPlaceEditTable.h + sdk/libPPUI/link-CommonControls6.h + sdk/libPPUI/listview_helper.h + sdk/libPPUI/PaintUtils.h + sdk/libPPUI/pp-COM-macros.h + sdk/libPPUI/ReStyleWnd.h + sdk/libPPUI/SmartStrStr.h + sdk/libPPUI/stdafx.h + sdk/libPPUI/targetver.h + sdk/libPPUI/TreeMultiSel.h + sdk/libPPUI/TypeFind.h + sdk/libPPUI/win32_op.h + sdk/libPPUI/win32_utility.h + sdk/libPPUI/windowLifetime.h + sdk/libPPUI/wtl-pp.h +) + +set( + COMPONENT_CLIENT_SOURCES + sdk/foobar2000/foobar2000_component_client/component_client.cpp +) + +set( + SAMPLE_SOURCES + sdk/foobar2000/foo_sample/contextmenu.cpp + sdk/foobar2000/foo_sample/decode.cpp + sdk/foobar2000/foo_sample/dsp_sample.cpp + sdk/foobar2000/foo_sample/initquit.cpp + sdk/foobar2000/foo_sample/input_raw.cpp + sdk/foobar2000/foo_sample/listcontrol-advanced.cpp + sdk/foobar2000/foo_sample/listcontrol-ownerdata.cpp + sdk/foobar2000/foo_sample/listcontrol-simple.cpp + sdk/foobar2000/foo_sample/main.cpp + sdk/foobar2000/foo_sample/mainmenu-dynamic.cpp + sdk/foobar2000/foo_sample/mainmenu.cpp + sdk/foobar2000/foo_sample/IO.cpp + sdk/foobar2000/foo_sample/playback_state.cpp + sdk/foobar2000/foo_sample/playback_stream_capture.cpp + sdk/foobar2000/foo_sample/preferences.cpp + sdk/foobar2000/foo_sample/rating.cpp + sdk/foobar2000/foo_sample/ui_and_threads.cpp + sdk/foobar2000/foo_sample/ui_element.cpp + sdk/foobar2000/foo_sample/ui_element_dialog.cpp + sdk/foobar2000/foo_sample/foo_sample.rc +) + +set( + SAMPLE_HEADERS + sdk/foobar2000/foo_sample/dsp_sample.h + sdk/foobar2000/foo_sample/playback_stream_capture.h + sdk/foobar2000/foo_sample/resource.h + sdk/foobar2000/foo_sample/stdafx.h +) diff -r e9bb126753e7 -r 20d02a178406 foosdk/cmake/FindWtl.cmake --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/cmake/FindWtl.cmake Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,13 @@ +find_path( + WTL_INCLUDE_DIRS + NAMES atlapp.h + DOC "WTL include directories" +) + +include(FindPackageHandleStandardArgs) + +find_package_handle_standard_args( + WTL REQUIRED_VARS WTL_INCLUDE_DIRS +) + +mark_as_advanced(WTL_INCLUDE_DIRS) diff -r e9bb126753e7 -r 20d02a178406 foosdk/scripts/dump-vcxproj.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/scripts/dump-vcxproj.sh Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,60 @@ +#!/bin/bash + +set -e + +target_prefix=$1 +project_file=$2 + +if [ -z "$target_prefix" ] || [ -z "$project_file" ]; then + echo "usage: $(basename $0) project_file target_prefix" + exit 1 +fi + +xmlns='http://schemas.microsoft.com/developer/msbuild/2003' +compile_xpath='//x:Project/x:ItemGroup/x:ClCompile/@Include' +resource_xpath='//x:Project/x:ItemGroup/x:ResourceCompile/@Include' +include_xpath='//x:Project/x:ItemGroup/x:ClInclude/@Include' + +project_dir="$(dirname $project_file)" + +if [ "$project_dir" = "." ]; then + path_prefix="" +else + path_prefix="$project_dir/" +fi + +if [ -n "$VCXPROJ_IGNORE" ]; then + ignore_pattern="$VCXPROJ_IGNORE" +else + ignore_pattern='$^' +fi + +function write_header() +{ + printf '\nset(\n %s_%s\n' "$target_prefix" "$1" +} + +function write_footer() +{ + printf ')\n' +} + +function write_nodes() +{ + xmlstarlet sel -N x="$xmlns" -t -v "$1" "$project_file" | \ + grep -viE "$ignore_pattern" | \ + xargs -n1 --no-run-if-empty printf ' %s%s\n' "$path_prefix" +} + +test -f "$project_file" + +write_header SOURCES +write_nodes $compile_xpath +write_nodes $resource_xpath +write_footer + +if [ "$3" != "--skip-headers" ]; then + write_header HEADERS + write_nodes $include_xpath + write_footer +fi diff -r e9bb126753e7 -r 20d02a178406 foosdk/scripts/update-lists.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/scripts/update-lists.sh Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,63 @@ +#!/bin/bash + +set -e + +script_dir="$(dirname $(readlink -f $0))" +out_file="cmake/FileLists.cmake" + +function write_prologue() +{ + echo "# Generated by $(basename $0)" >> "$out_file" +} + +function dump_dir() +{ + ( + printf '\nset(\n %s\n' "$1" + ls $2 | grep -viE "$IGNORE$" | xargs -n1 --no-run-if-empty printf ' %s\n' + printf ')\n' + ) >> "$out_file" +} + +function dump_vcxproj() +{ + export VCXPROJ_IGNORE="$IGNORE$" + + "$script_dir/dump-vcxproj.sh" $1 $2 $3 >> "$out_file" +} + +IGNORE="stdafx\\.cpp" + +cd "$script_dir/.." +rm -f $out_file || true +mkdir -p $(dirname $out_file) + +write_prologue + +dump_dir WTL_HEADERS 'wtl/Include/*.h' +dump_dir SHARED_HEADERS 'sdk/foobar2000/shared/*.h' + +IGNORE="($IGNORE)|(pfc-fb2k-hooks\\.cpp)|(nix-objects\\.(cpp|h))" \ + dump_vcxproj PFC \ + sdk/pfc/pfc.vcxproj + +dump_vcxproj SDK \ + sdk/foobar2000/SDK/foobar2000_SDK.vcxproj \ + --skip-headers + +dump_dir SDK_HEADERS \ + 'sdk/foobar2000/SDK/*.h' + +IGNORE="($IGNORE)|(TypeFind\\.h)" \ + dump_vcxproj SDK_HELPERS \ + sdk/foobar2000/helpers/foobar2000_sdk_helpers.vcxproj + +dump_vcxproj PPUI \ + sdk/libPPUI/libPPUI.vcxproj + +dump_vcxproj COMPONENT_CLIENT \ + sdk/foobar2000/foobar2000_component_client/foobar2000_component_client.vcxproj \ + --skip-headers + +IGNORE="($IGNORE)|(PCH\\.cpp)" dump_vcxproj SAMPLE \ + sdk/foobar2000/foo_sample/foo_sample.vcxproj diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/abort_callback.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/abort_callback.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,74 @@ +#include "foobar2000-sdk-pch.h" + +#include "abort_callback.h" + +void abort_callback::check() const { + if (is_aborting()) { + throw exception_aborted(); + } +} + +void abort_callback::sleep(double p_timeout_seconds) const { + if (!sleep_ex(p_timeout_seconds)) { + throw exception_aborted(); + } +} + +bool abort_callback::sleep_ex(double p_timeout_seconds) const { + // return true IF NOT SET (timeout), false if set + return !pfc::event::g_wait_for(get_abort_event(),p_timeout_seconds); +} + +bool abort_callback::waitForEvent( pfc::eventHandle_t evtHandle, double timeOut ) const { + int status = pfc::event::g_twoEventWait( this->get_abort_event(), evtHandle, timeOut ); + switch(status) { + case 1: throw exception_aborted(); + case 2: return true; + case 0: return false; + default: uBugCheck(); + } +} + +bool abort_callback_usehandle::is_aborting() const { + return pfc::event::g_wait_for( get_abort_event(), 0 ); +} + +bool abort_callback::waitForEvent(pfc::event& evt, double timeOut) const { + return waitForEvent(evt.get_handle(), timeOut); +} + +void abort_callback::waitForEvent(pfc::eventHandle_t evtHandle) const { + bool status = waitForEvent(evtHandle, -1); (void)status; + PFC_ASSERT(status); // should never return false +} + +void abort_callback::waitForEvent(pfc::event& evt) const { + bool status = waitForEvent(evt, -1); (void)status; + PFC_ASSERT(status); // should never return false +} + +bool abort_callback::waitForEventNoThrow(pfc::eventHandle_t evtHandle) const { + int status = pfc::event::g_twoEventWait(this->get_abort_event(), evtHandle, -1); + switch (status) { + case 1: return false; + case 2: return true; + default: uBugCheck(); + } +} + +bool abort_callback::waitForEventNoThrow(pfc::event& evt) const { + return waitForEventNoThrow(evt.get_handle()); +} + +namespace fb2k { + abort_callback_dummy noAbort; +} + +abort_callback_event abort_callback_clone::clone(abort_callback_event arg) { + return pfc::fileHandleDup(arg); +} + +void abort_callback_clone::close(abort_callback_event arg) { + return pfc::fileHandleClose(arg); +} + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/abort_callback.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/abort_callback.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,140 @@ +#pragma once + +namespace foobar2000_io { + +PFC_DECLARE_EXCEPTION(exception_aborted,pfc::exception,"User abort"); + +typedef pfc::eventHandle_t abort_callback_event; + +#ifdef check +#undef check +#endif +//! This class is used to signal underlying worker code whether user has decided to abort a potentially time-consuming operation. \n +//! It is commonly required by all filesystem related or decoding-related operations. \n +//! Code that receives an abort_callback object should periodically check it and abort any operations being performed if it is signaled, typically throwing exception_aborted. \n +//! See abort_callback_impl for an implementation. +class NOVTABLE abort_callback +{ +public: + //! Returns whether user has requested the operation to be aborted. + virtual bool is_aborting() const = 0; + + inline bool is_set() const {return is_aborting();} + + //! Retrieves event object that can be used with some OS calls. The even object becomes signaled when abort is triggered. On win32, this is equivalent to win32 event handle (see: CreateEvent). \n + //! You must not close this handle or call any methods that change this handle's state (SetEvent() or ResetEvent()), you can only wait for it. + virtual abort_callback_event get_abort_event() const = 0; + + inline abort_callback_event get_handle() const {return get_abort_event();} + + //! Checks if user has requested the operation to be aborted, and throws exception_aborted if so. + void check() const; + + //! For compatibility with old code. Do not call. + inline void check_e() const {check();} + + + //! Sleeps p_timeout_seconds or less when aborted, throws exception_aborted on abort. + void sleep(double p_timeout_seconds) const; + //! Sleeps p_timeout_seconds or less when aborted, returns true when execution should continue, false when not. + bool sleep_ex(double p_timeout_seconds) const; + bool sleepNoThrow(double p_timeout_seconds) const { return sleep_ex(p_timeout_seconds); } + + //! Waits for an event. Returns true if event is now signaled, false if the specified period has elapsed and the event did not become signaled. \n + //! Throws exception_aborted if aborted. + bool waitForEvent( pfc::eventHandle_t evtHandle, double timeOut ) const; + //! Waits for an event. Returns true if event is now signaled, false if the specified period has elapsed and the event did not become signaled. \n + //! Throws exception_aborted if aborted. + bool waitForEvent(pfc::event& evt, double timeOut) const; + + //! Waits for an event. Returns once the event became signaled; throw exception_aborted if abort occurred first. + void waitForEvent(pfc::eventHandle_t evtHandle) const; + //! Waits for an event. Returns once the event became signaled; throw exception_aborted if abort occurred first. + void waitForEvent(pfc::event& evt) const; + + bool waitForEventNoThrow(pfc::eventHandle_t evt) const; + bool waitForEventNoThrow(pfc::event& evt) const; + + abort_callback( const abort_callback & ) = delete; + void operator=( const abort_callback & ) = delete; +protected: + abort_callback() {} + ~abort_callback() {} +}; + + + +//! Standard implementation of abort_callback interface. +class abort_callback_impl : public abort_callback { +public: + abort_callback_impl() {} + inline void abort() {set_state(true);} + inline void set() {set_state(true);} + inline void reset() {set_state(false);} + + void set_state(bool p_state) {m_aborting = p_state; m_event.set_state(p_state);} + + bool is_aborting() const override {return m_aborting;} + + abort_callback_event get_abort_event() const override {return m_event.get_handle();} + +private: + abort_callback_impl(const abort_callback_impl &) = delete; + const abort_callback_impl & operator=(const abort_callback_impl&) = delete; + + volatile bool m_aborting = false; + pfc::event m_event; +}; + +//! Alternate abort_callback implementation, supply your own event handle to signal abort. \n +//! Slightly less efficient (is_aborting() polls the event instead of reading a bool variable). +class abort_callback_usehandle : public abort_callback { +public: + abort_callback_usehandle( abort_callback_event handle ) : m_handle(handle) {} + + bool is_aborting() const override; + abort_callback_event get_abort_event() const override { return m_handle; } +protected: + const abort_callback_event m_handle; +}; + +class abort_callback_clone : public abort_callback_usehandle { +public: + abort_callback_clone(abort_callback_event handle) : abort_callback_usehandle(clone(handle)) {} + abort_callback_clone(abort_callback & arg) : abort_callback_usehandle(clone(arg.get_handle())) {} + ~abort_callback_clone() { close(m_handle); } + + static abort_callback_event clone(abort_callback_event); + static void close(abort_callback_event); +}; + +//! Dummy abort_callback that never gets aborted. \n +//! Note that there's no need to create instances of it, use shared fb2k::noAbort object instead. +class abort_callback_dummy : public abort_callback { +public: + bool is_aborting() const override { return false; } + + abort_callback_event get_abort_event() const override { return m_event;} +private: + const abort_callback_event m_event = GetInfiniteWaitEvent(); +}; + +} +typedef foobar2000_io::abort_callback_event fb2k_event_handle; +typedef foobar2000_io::abort_callback fb2k_event; +typedef foobar2000_io::abort_callback_impl fb2k_event_impl; + +using namespace foobar2000_io; + +#define FB2K_PFCv2_ABORTER_SCOPE( abortObj ) \ + (abortObj).check(); \ + PP::waitableReadRef_t aborterRef = {(abortObj).get_abort_event()}; \ + PP::aborter aborter_pfcv2( aborterRef ); \ + PP::aborterScope l_aborterScope( aborter_pfcv2 ); + + +namespace fb2k { + //! A shared abort_callback_dummy instance. \n + //! Use when some function requires an abort_callback& and you don't have one: somefunc(fb2k::noAbort); + extern abort_callback_dummy noAbort; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/advconfig.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/advconfig.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,104 @@ +#include "foobar2000-sdk-pch.h" +#include "advconfig.h" +#include "advconfig_impl.h" + +bool advconfig_entry::is_branch() { + advconfig_branch::ptr branch; + return branch &= this; +} + +bool advconfig_entry::g_find(service_ptr_t& out, const GUID & id) { + for (auto ptr : advconfig_entry::enumerate()) { + if (ptr->get_guid() == id) { out = ptr; return true; } + } + return false; +} + +t_uint32 advconfig_entry::get_preferences_flags_() { + { + advconfig_entry_string_v2::ptr ex; + if (service_query_t(ex)) return ex->get_preferences_flags(); + } + { + advconfig_entry_checkbox_v2::ptr ex; + if (service_query_t(ex)) return ex->get_preferences_flags(); + } + return 0; +} + +bool advconfig_entry_checkbox::get_default_state_() { + { + advconfig_entry_checkbox_v2::ptr ex; + if (service_query_t(ex)) return ex->get_default_state(); + } + + bool backup = get_state(); + reset(); + bool rv = get_state(); + set_state(backup); + return rv; +} + +void advconfig_entry_string::get_default_state_(pfc::string_base & out) { + { + advconfig_entry_string_v2::ptr ex; + if (service_query_t(ex)) {ex->get_default_state(out); return;} + } + pfc::string8 backup; + get_state(backup); + reset(); + get_state(out); + set_state(backup); +} + + +#if FOOBAR2000_TARGET_VERSION >= 81 +// advconfig_impl.h functionality + +void advconfig_entry_checkbox_impl::reset() { + fb2k::configStore::get()->deleteConfigBool(m_varName); +} + +void advconfig_entry_checkbox_impl::set_state(bool p_state) { + fb2k::configStore::get()->setConfigBool(m_varName, p_state); +} + +bool advconfig_entry_checkbox_impl::get_state_() const { + return fb2k::configStore::get()->getConfigBool(m_varName, m_initialstate); +} + +#ifdef FOOBAR2000_HAVE_CFG_VAR_LEGACY +void advconfig_entry_checkbox_impl::set_data_raw(stream_reader* p_stream, t_size p_sizehint, abort_callback& p_abort) { + (void)p_sizehint; + uint8_t v; + if (p_stream->read(&v, 1, p_abort) == 1) { + set_state(v != 0); + } +} +#endif + +void advconfig_entry_string_impl::reset() { + fb2k::configStore::get()->deleteConfigString(m_varName); +} +void advconfig_entry_string_impl::get_state(pfc::string_base& p_out) { + p_out = fb2k::configStore::get()->getConfigString(m_varName, m_initialstate)->c_str(); +} +void advconfig_entry_string_impl::set_state(const char* p_string, t_size p_length) { + pfc::string8 asdf; + if (p_length != SIZE_MAX) { + asdf.set_string(p_string, p_length); + p_string = asdf; + } + fb2k::configStore::get()->setConfigString(m_varName, p_string); +} + +#ifdef FOOBAR2000_HAVE_CFG_VAR_LEGACY +void advconfig_entry_string_impl::set_data_raw(stream_reader* p_stream, t_size p_sizehint, abort_callback& p_abort) { + (void)p_sizehint; + pfc::string8_fastalloc temp; + p_stream->read_string_raw(temp, p_abort); + this->set_state(temp); +} +#endif + +#endif // FOOBAR2000_TARGET_VERSION >= 81 diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/advconfig.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/advconfig.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,93 @@ +#pragma once + +//! Entrypoint class for adding items to Advanced Preferences page. \n +//! Implementations must derive from one of subclasses: advconfig_branch, advconfig_entry_checkbox, advconfig_entry_string. \n +//! Implementations are typically registered using static service_factory_single_t, or using provided helper classes in case of standard implementations declared in this header. +class NOVTABLE advconfig_entry : public service_base { +public: + virtual void get_name(pfc::string_base & p_out) = 0; + virtual GUID get_guid() = 0; + virtual GUID get_parent() = 0; + virtual void reset() = 0; + virtual double get_sort_priority() = 0; + + bool is_branch(); + t_uint32 get_preferences_flags_(); + + static bool g_find(service_ptr_t& out, const GUID & id); + + template static bool g_find_t(outptr & out, const GUID & id) { + service_ptr_t temp; + if (!g_find(temp, id)) return false; + return temp->service_query_t(out); + } + + static const GUID guid_root; + static const GUID guid_branch_tagging,guid_branch_decoding,guid_branch_tools,guid_branch_playback,guid_branch_display,guid_branch_debug, guid_branch_tagging_general, guid_branch_converter; + + + // \since 2.0 + static const GUID guid_branch_vis, guid_branch_general; + + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(advconfig_entry); +}; + +//! Declares a new branch in Advanced Preferences. \n +//! Implementation: see advconfig_branch_impl / advconfig_branch_factory. +class NOVTABLE advconfig_branch : public advconfig_entry { +public: + FB2K_MAKE_SERVICE_INTERFACE(advconfig_branch,advconfig_entry); +}; + +//! Declares a checkbox/radiocheckbox entry in Advanced Preferences. \n +//! The difference between checkboxes and radiocheckboxes is different icon (obviously) and that checking a radiocheckbox unchecks all other radiocheckboxes in the same branch. \n +//! Implementation: see advconfig_entry_checkbox_impl / advconfig_checkbox_factory_t. +class NOVTABLE advconfig_entry_checkbox : public advconfig_entry { +public: + virtual bool get_state() = 0; + virtual void set_state(bool p_state) = 0; + virtual bool is_radio() = 0; + + bool get_default_state_(); + + FB2K_MAKE_SERVICE_INTERFACE(advconfig_entry_checkbox,advconfig_entry); +}; + +//! Extension to advconfig_entry_checkbox, adds default state and preferences flags. +class NOVTABLE advconfig_entry_checkbox_v2 : public advconfig_entry_checkbox { + FB2K_MAKE_SERVICE_INTERFACE(advconfig_entry_checkbox_v2, advconfig_entry_checkbox) +public: + virtual bool get_default_state() = 0; + virtual t_uint32 get_preferences_flags() {return 0;} //signals whether changing this setting should trigger playback restart or app restart; see: preferences_state::* constants +}; + +//! Declares a string/integer editbox entry in Advanced Preferences.\n +//! Implementation: see advconfig_entry_string_impl / advconfig_string_factory. +class NOVTABLE advconfig_entry_string : public advconfig_entry { +public: + virtual void get_state(pfc::string_base & p_out) = 0; + virtual void set_state(const char * p_string,t_size p_length = SIZE_MAX) = 0; + virtual t_uint32 get_flags() = 0; + + void get_default_state_(pfc::string_base & out); + + static constexpr uint32_t + flag_is_integer = 1 << 0, + flag_is_signed = 1 << 1, + // Since 2.2: hint to treat these fields as file/folder paths, providing hints if suitable + flag_is_file_path = 1 << 2, + flag_is_folder_path = 1 << 3, + // Since 2.2: multiple values, semicolon delimited + flag_semicolon_delimited = 1 << 4; + + FB2K_MAKE_SERVICE_INTERFACE(advconfig_entry_string,advconfig_entry); +}; + +//! Extension to advconfig_entry_string, adds default state, validation and preferences flags. +class NOVTABLE advconfig_entry_string_v2 : public advconfig_entry_string { + FB2K_MAKE_SERVICE_INTERFACE(advconfig_entry_string_v2, advconfig_entry_string) +public: + virtual void get_default_state(pfc::string_base & out) = 0; + virtual void validate(pfc::string_base& val) { (void)val; } + virtual t_uint32 get_preferences_flags() {return 0;} //signals whether changing this setting should trigger playback restart or app restart; see: preferences_state::* constants +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/advconfig_impl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/advconfig_impl.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,278 @@ +#pragma once + +// advconfig_impl.h : mainline (foobar2000 v2.0) implementation of advconfig objects + +#include "advconfig.h" + +//! Standard implementation of advconfig_branch. \n +//! Usage: no need to use this class directly - use advconfig_branch_factory instead. +class advconfig_branch_impl : public advconfig_branch { +public: + advconfig_branch_impl(const char* p_name, const GUID& p_guid, const GUID& p_parent, double p_priority) : m_name(p_name), m_guid(p_guid), m_parent(p_parent), m_priority(p_priority) {} + void get_name(pfc::string_base& p_out) override { p_out = m_name; } + GUID get_guid() override { return m_guid; } + GUID get_parent() override { return m_parent; } + void reset() override {} + double get_sort_priority() override { return m_priority; } +private: + pfc::string8 m_name; + GUID m_guid, m_parent; + const double m_priority; +}; + + +#if FOOBAR2000_TARGET_VERSION < 81 +#include "advconfig_impl_legacy.h" +#else + +#include "configStore.h" +#include "configCache.h" +#include "cfg_var_legacy.h" // cfg_var_reader + +namespace fb2k { + pfc::string8 advconfig_autoName(const GUID& id); + pfc::string8 advconfig_autoName(const GUID& id, const char * specified); +} + + +//! Standard implementation of advconfig_entry_checkbox. \n +class advconfig_entry_checkbox_impl : public advconfig_entry_checkbox_v2, private cfg_var_legacy::cfg_var_reader { +public: + advconfig_entry_checkbox_impl(const char* p_name, const char * varName, const GUID& p_guid, const GUID& p_parent, double p_priority, bool p_initialstate, bool isRadio = false, uint32_t flags = 0) + : cfg_var_reader(p_guid), m_name(p_name), m_varName(varName), m_guid(p_guid), m_initialstate(p_initialstate), m_parent(p_parent), m_priority(p_priority), m_isRadio(isRadio), m_flags(flags) {} + + void get_name(pfc::string_base& p_out) override { p_out = m_name; } + GUID get_guid() override { return m_guid; } + GUID get_parent() override { return m_parent; } + void reset() override; + bool get_state() override { return get_state_(); } + void set_state(bool p_state) override; + bool is_radio() override { return m_isRadio; } + double get_sort_priority() override { return m_priority; } + bool get_default_state() override { return m_initialstate; } + t_uint32 get_preferences_flags() override { return m_flags; } + + bool get_state_() const; + bool get_default_state_() const { return m_initialstate; } + + const char* varName() const { return m_varName; } +private: +#ifdef FOOBAR2000_HAVE_CFG_VAR_LEGACY + // cfg_var_reader + void set_data_raw(stream_reader* p_stream, t_size p_sizehint, abort_callback& p_abort) override; +#endif + + const pfc::string8 m_name, m_varName; + const GUID m_guid; + const bool m_initialstate; + const bool m_isRadio; + const uint32_t m_flags; + + const GUID m_parent; + const double m_priority; +}; + +//! Service factory helper around standard advconfig_branch implementation. Use this class to register your own Advanced Preferences branches. \n +//! Usage: static advconfig_branch_factory mybranch(name, branchID, parentBranchID, priority); +class advconfig_branch_factory : public service_factory_single_t { +public: + advconfig_branch_factory(const char* p_name, const GUID& p_guid, const GUID& p_parent, double p_priority) + : service_factory_single_t(p_name, p_guid, p_parent, p_priority) {} +}; + +template +class advconfig_checkbox_factory_ : public service_factory_single_t { +public: + advconfig_checkbox_factory_(const char* name, const GUID& guid, const GUID& parent, double priority, bool initialstate, uint32_t flags = 0) : service_factory_single_t(name, fb2k::advconfig_autoName(guid), guid, parent, priority, initialstate, is_radio, flags) {} + advconfig_checkbox_factory_(const char* name, const char* varName, const GUID& guid, const GUID& parent, double priority, bool initial, uint32_t flags = 0) : service_factory_single_t(name, varName, guid, parent, priority, initial, is_radio, flags) {} + + bool get() const { return this->get_static_instance().get_state_(); } + void set(bool val) { this->get_static_instance().set_state(val); } + operator bool() const { return get(); } + bool operator=(bool val) { set(val); return val; } + const char* varName() const { return this->get_static_instance().varName(); } +}; + +typedef advconfig_checkbox_factory_ advconfig_checkbox_factory; +typedef advconfig_checkbox_factory_ advconfig_radio_factory; + +#if 0 +// OBSOLETE, use advconfig_checkbox_factory / advconfig_radio_factory +template +class advconfig_checkbox_factory_t : public advconfig_checkbox_factory_ { +public: + advconfig_checkbox_factory_t(const char* p_name, const GUID& p_guid, const GUID& p_parent, double p_priority, bool p_initialstate) : advconfig_checkbox_factory_(p_name, fb2k::advconfig_autoName(p_guid), p_guid, p_parent, p_priority, p_initialstate, prefFlags) {} +}; +#endif + +struct advconfig_entry_string_desc { const char* name; const char* varName; GUID guid, parent; double priority = 0; const char* initial = ""; uint32_t prefsFlags = 0; uint32_t flags = 0; }; + +//! Standard advconfig_entry_string implementation. Use advconfig_string_factory to register your own string entries in Advanced Preferences instead of using this class directly. +class advconfig_entry_string_impl : public advconfig_entry_string_v2, private cfg_var_legacy::cfg_var_reader { +public: + advconfig_entry_string_impl(advconfig_entry_string_desc const& arg) : cfg_var_reader(arg.guid), m_name(arg.name), m_varName(fb2k::advconfig_autoName(arg.guid, arg.varName)), m_guid(arg.guid), m_parent(arg.parent), m_priority(arg.priority), m_initialstate(arg.initial), m_prefFlags(arg.prefsFlags), m_flags(arg.flags) {} + advconfig_entry_string_impl(const char* p_name, const char * p_varName, const GUID& p_guid, const GUID& p_parent, double p_priority, const char* p_initialstate, t_uint32 p_prefFlags) + : cfg_var_reader(p_guid), m_name(p_name), m_varName(p_varName), m_guid(p_guid), m_parent(p_parent), m_initialstate(p_initialstate), m_priority(p_priority), m_prefFlags(p_prefFlags) {} + void get_name(pfc::string_base& p_out) override { p_out = m_name; } + GUID get_guid() override { return m_guid; } + GUID get_parent() override { return m_parent; } + void reset() override; + double get_sort_priority() override { return m_priority; } + void get_state(pfc::string_base& p_out) override; + void set_state(const char* p_string, t_size p_length = SIZE_MAX) override; + t_uint32 get_flags() override { return m_flags; } + void get_default_state(pfc::string_base& out) override{ out = m_initialstate; } + t_uint32 get_preferences_flags() override { return m_prefFlags; } +private: +#ifdef FOOBAR2000_HAVE_CFG_VAR_LEGACY + // cfg_var_reader + void set_data_raw(stream_reader* p_stream, t_size p_sizehint, abort_callback& p_abort) override; +#endif + + const pfc::string8 m_initialstate, m_name, m_varName; + const GUID m_guid, m_parent; + + const double m_priority; + const t_uint32 m_prefFlags; + const uint32_t m_flags = 0; +}; + +//! Service factory helper around standard advconfig_entry_string implementation. Use this class to register your own string entries in Advanced Preferences. \n +//! Usage: static advconfig_string_factory mystring(name, itemID, branchID, priority, initialValue); +class advconfig_string_factory : public service_factory_single_t { +public: + advconfig_string_factory(const char* p_name, const char * varName, const GUID& p_guid, const GUID& p_parent, double p_priority, const char* p_initialstate, t_uint32 p_prefFlags = 0) : service_factory_single_t(p_name, varName, p_guid, p_parent, p_priority, p_initialstate, p_prefFlags) {} + advconfig_string_factory(const char* p_name, const GUID& p_guid, const GUID& p_parent, double p_priority, const char* p_initialstate, t_uint32 p_prefFlags = 0) : service_factory_single_t(p_name, fb2k::advconfig_autoName(p_guid), p_guid, p_parent, p_priority, p_initialstate, p_prefFlags) {} + advconfig_string_factory(advconfig_entry_string_desc const& arg) : service_factory_single_t(arg) {} + + void get(pfc::string_base& out) { get_static_instance().get_state(out); } + pfc::string8 get() { pfc::string8 temp; get(temp); return temp; } + void set(const char* in) { get_static_instance().set_state(in); } +}; + +// Thread hacks no longer needed +typedef advconfig_string_factory advconfig_string_factory_MT; + +//! Special advconfig_entry_string implementation - implements integer entries. Use advconfig_integer_factory to register your own integer entries in Advanced Preferences instead of using this class directly. +template +class advconfig_entry_integer_impl_ : public advconfig_entry_string_v2, private cfg_var_legacy::cfg_var_reader { +public: + typedef int_t_ int_t; + advconfig_entry_integer_impl_(const char* p_name, const char * p_varName, const GUID& p_guid, const GUID& p_parent, double p_priority, int_t p_initialstate, int_t p_min, int_t p_max, t_uint32 p_prefFlags) + : cfg_var_reader(p_guid), m_name(p_name), m_varName(p_varName), m_guid(p_guid), m_parent(p_parent), m_priority(p_priority), m_initval(p_initialstate), m_min(p_min), m_max(p_max), m_prefFlags(p_prefFlags) { + PFC_ASSERT(p_min < p_max); + } + void get_name(pfc::string_base& p_out) override { p_out = m_name; } + GUID get_guid() override { return m_guid; } + GUID get_parent() override { return m_parent; } + void reset() override {fb2k::configStore::get()->deleteConfigBool(m_varName);} + double get_sort_priority() override { return m_priority; } + void get_state(pfc::string_base& p_out) override { p_out = pfc::format_int( get_state_int() ); } + void set_state(const char* p_string, t_size p_length) override {set_state_int(pfc::atoi64_ex(p_string, p_length));} + t_uint32 get_flags() override { return advconfig_entry_string::flag_is_integer | (is_signed() ? flag_is_signed : 0); } + + int_t get_state_int() const {return fb2k::configStore::get()->getConfigInt(m_varName, m_initval);} + void set_state_int(int_t val) { val = pfc::clip_t(val, m_min, m_max); fb2k::configStore::get()->setConfigInt(m_varName, val); } + + void get_default_state(pfc::string_base& out) override { + format(out, m_initval); + } + void validate(pfc::string_base& val) override { + format(val, pfc::clip_t(pfc::atoi64_ex(val, SIZE_MAX), m_min, m_max)); + } + t_uint32 get_preferences_flags() override { return m_prefFlags; } +private: +#ifdef FOOBAR2000_HAVE_CFG_VAR_LEGACY + // cfg_var_reader + void set_data_raw(stream_reader* p_stream, t_size p_sizehint, abort_callback& p_abort) override { + switch (p_sizehint) { + case 4: + { int32_t v; p_stream->read_lendian_t(v, p_abort); this->set_state_int(v); } break; + case 8: + { int64_t v; p_stream->read_lendian_t(v, p_abort); this->set_state_int(v); } break; + } + } + +#endif + + void format(pfc::string_base& out, int_t v) const { + if (is_signed()) out = pfc::format_int(v); + else out = pfc::format_uint(v); + } + bool is_signed() const { + return m_min < 0; + } + + const double m_priority; + const int_t m_initval, m_min, m_max; + const GUID m_guid, m_parent; + const pfc::string8 m_name, m_varName; + const t_uint32 m_prefFlags; +}; + +typedef advconfig_entry_integer_impl_ advconfig_entry_integer_impl; + +//! Service factory helper around integer-specialized advconfig_entry_string implementation. Use this class to register your own integer entries in Advanced Preferences. \n +//! Usage: static advconfig_integer_factory myint(name, itemID, parentID, priority, initialValue, minValue, maxValue); +template +class advconfig_integer_factory_ : public service_factory_single_t> { +public: + typedef int_t_ int_t; + advconfig_integer_factory_(const char* p_name, const GUID& p_guid, const GUID& p_parent, double p_priority, t_uint64 p_initialstate, t_uint64 p_min, t_uint64 p_max, t_uint32 p_prefFlags = 0) : service_factory_single_t(p_name, fb2k::advconfig_autoName(p_guid), p_guid, p_parent, p_priority, p_initialstate, p_min, p_max, p_prefFlags) {} + advconfig_integer_factory_(const char* p_name, const char * p_varName, const GUID& p_guid, const GUID& p_parent, double p_priority, int_t p_initialstate, int_t p_min, int_t p_max, t_uint32 p_prefFlags = 0) : service_factory_single_t >(p_name, p_varName, p_guid, p_parent, p_priority, p_initialstate, p_min, p_max, p_prefFlags) {} + + int_t get() const { return this->get_static_instance().get_state_int(); } + void set(int_t val) { this->get_static_instance().set_state_int(val); } + + operator int_t() const { return get(); } + int_t operator=(int_t val) { set(val); return val; } +}; + +typedef advconfig_integer_factory_ advconfig_integer_factory; +typedef advconfig_integer_factory_ advconfig_signed_integer_factory; + + +class advconfig_integer_factory_cached : public advconfig_integer_factory { +public: + using advconfig_integer_factory::int_t; + advconfig_integer_factory_cached(const char* p_name, const char* p_varName, const GUID& p_guid, const GUID& p_parent, double p_priority, int_t p_initialstate, int_t p_min, int_t p_max, t_uint32 p_prefFlags = 0) + : advconfig_integer_factory(p_name, p_varName, p_guid, p_parent, p_priority, p_initialstate, p_min, p_max, p_prefFlags), + m_cache(p_varName, p_initialstate) {} + + int_t get() { return m_cache.get(); } + void set(int_t v) { m_cache.set(v); } + operator int_t() { return get(); } +private: + fb2k::configIntCache m_cache; +}; + +template +class advconfig_checkbox_factory_cached_ : public advconfig_checkbox_factory_ { +public: + advconfig_checkbox_factory_cached_(const char* name, const char* varName, const GUID& guid, const GUID& parent, double priority, bool initial, uint32_t flags = 0) + : advconfig_checkbox_factory_(name, varName, guid, parent, priority, initial, flags), + m_cache(varName, initial) {} + + bool get() { return m_cache.get(); } + void set(bool v) { m_cache.set(v); } + operator bool() { return get(); } +private: + fb2k::configBoolCache m_cache; +}; + +typedef advconfig_checkbox_factory_cached_ advconfig_checkbox_factory_cached; +typedef advconfig_checkbox_factory_cached_ advconfig_radio_factory_cached; + +/* + Advanced Preferences variable declaration examples + + static advconfig_string_factory mystring("name goes here","configStore var name goes here", myguid,parentguid,0,"asdf"); + to retrieve state: pfc::string8 val; mystring.get(val); + + static advconfig_checkbox_factory mycheckbox("name goes here","configStore var name goes here", myguid,parentguid,0,false); + to retrieve state: mycheckbox.get(); + + static advconfig_integer_factory myint("name goes here","configStore var name goes herE", myguid,parentguid,0,initialValue,minimumValue,maximumValue); + to retrieve state: myint.get(); +*/ +#endif diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/advconfig_impl_legacy.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/advconfig_impl_legacy.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,262 @@ +#pragma once + +// advconfig_impl_legacy.h : legacy (foobar2000 v1.x compatible) implementation of advconfig objects + +#include "cfg_var_legacy.h" +using namespace cfg_var_legacy; + +namespace fb2k { + pfc::string8 advconfig_autoName(const GUID&); +} + +#if FOOBAR2000_SUPPORT_CFG_VAR_DOWNGRADE +#define ADVCONFIG_DOWNGRADE { this->get_static_instance().downgrade_set_name(configStoreName); } +#define ADVCONFIG_DOWNGRADE_AUTO { this->get_static_instance().downgrade_set_name( fb2k::advconfig_autoName(p_guid) ); } +#else +#define ADVCONFIG_DOWNGRADE {(void)configStoreName;} +#define ADVCONFIG_DOWNGRADE_AUTO +#endif + +//! Standard implementation of advconfig_entry_checkbox. \n +class advconfig_entry_checkbox_impl : public advconfig_entry_checkbox_v2 { +public: + advconfig_entry_checkbox_impl(const char* p_name, const GUID& p_guid, const GUID& p_parent, double p_priority, bool p_initialstate, bool isRadio = false, uint32_t flags = 0) + : m_name(p_name), m_initialstate(p_initialstate), m_state(p_guid, p_initialstate), m_parent(p_parent), m_priority(p_priority), m_isRadio(isRadio), m_flags(flags) {} + + void get_name(pfc::string_base& p_out) override { p_out = m_name; } + GUID get_guid() override { return m_state.get_guid(); } + GUID get_parent() override { return m_parent; } + void reset() override { m_state = m_initialstate; } + bool get_state() override { return m_state; } + void set_state(bool p_state) override { m_state = p_state; } + bool is_radio() override { return m_isRadio; } + double get_sort_priority() override { return m_priority; } + bool get_default_state() override { return m_initialstate; } + t_uint32 get_preferences_flags() override { return m_flags; } + + bool get_state_() const { return m_state; } + bool get_default_state_() const { return m_initialstate; } +#if FOOBAR2000_SUPPORT_CFG_VAR_DOWNGRADE + void downgrade_set_name(const char * arg) { m_state.downgrade_set_name(arg); } +#endif +private: + const pfc::string8 m_name; + const bool m_initialstate; + const bool m_isRadio; + const uint32_t m_flags; + cfg_bool m_state; + const GUID m_parent; + const double m_priority; +}; + +//! Service factory helper around standard advconfig_branch implementation. Use this class to register your own Advanced Preferences branches. \n +//! Usage: static advconfig_branch_factory mybranch(name, branchID, parentBranchID, priority); +class advconfig_branch_factory : public service_factory_single_t { +public: + advconfig_branch_factory(const char* p_name, const GUID& p_guid, const GUID& p_parent, double p_priority) + : service_factory_single_t(p_name, p_guid, p_parent, p_priority) {} +}; + +class advconfig_checkbox_factory_common : public service_factory_single_t { +public: + template advconfig_checkbox_factory_common(args_t && ... args) : service_factory_single_t(std::forward(args) ...) {} + + bool get() const { return this->get_static_instance().get_state_(); } + void set(bool val) { this->get_static_instance().set_state(val); } + operator bool() const { return get(); } + bool operator=(bool val) { set(val); return val; } +}; + +class advconfig_checkbox_factory : public advconfig_checkbox_factory_common { +public: + advconfig_checkbox_factory(const char* p_name, const GUID& p_guid, const GUID& p_parent, double p_priority, bool p_initialstate, uint32_t flags = 0) + : advconfig_checkbox_factory_common(p_name, p_guid, p_parent, p_priority, p_initialstate, false /* not radio */, flags) { + ADVCONFIG_DOWNGRADE_AUTO; + } + advconfig_checkbox_factory(const char* p_name, const char * configStoreName, const GUID& p_guid, const GUID& p_parent, double p_priority, bool p_initialstate, uint32_t flags = 0) + : advconfig_checkbox_factory_common(p_name, p_guid, p_parent, p_priority, p_initialstate, false /* not radio */, flags) { + ADVCONFIG_DOWNGRADE; + } + +}; + +class advconfig_radio_factory : public advconfig_checkbox_factory_common { +public: + advconfig_radio_factory(const char* p_name, const GUID& p_guid, const GUID& p_parent, double p_priority, bool p_initialstate, uint32_t flags = 0) + : advconfig_checkbox_factory_common(p_name, p_guid, p_parent, p_priority, p_initialstate, true /* radio */, flags) { + ADVCONFIG_DOWNGRADE_AUTO; + } + advconfig_radio_factory(const char* p_name, const char * configStoreName, const GUID& p_guid, const GUID& p_parent, double p_priority, bool p_initialstate, uint32_t flags = 0) + : advconfig_checkbox_factory_common(p_name, p_guid, p_parent, p_priority, p_initialstate, true /* radio */, flags) { + ADVCONFIG_DOWNGRADE; + } +}; + +// OBSOLETE, use advconfig_checkbox_factory / advconfig_radio_factory +template +class advconfig_checkbox_factory_t : public advconfig_checkbox_factory_common { +public: + advconfig_checkbox_factory_t(const char* p_name, const GUID& p_guid, const GUID& p_parent, double p_priority, bool p_initialstate) + : advconfig_checkbox_factory_common(p_name, p_guid, p_parent, p_priority, p_initialstate, p_is_radio, prefFlags) { + ADVCONFIG_DOWNGRADE_AUTO; + } + advconfig_checkbox_factory_t(const char* p_name, const char * configStoreName, const GUID& p_guid, const GUID& p_parent, double p_priority, bool p_initialstate) + : advconfig_checkbox_factory_common(p_name, p_guid, p_parent, p_priority, p_initialstate, p_is_radio, prefFlags) { + ADVCONFIG_DOWNGRADE; + } +}; + +//! Special advconfig_entry_string implementation - implements integer entries. Use advconfig_integer_factory to register your own integer entries in Advanced Preferences instead of using this class directly. +template +class advconfig_entry_integer_impl_ : public advconfig_entry_string_v2 { +public: + typedef int_t_ int_t; + advconfig_entry_integer_impl_(const char* p_name, const GUID& p_guid, const GUID& p_parent, double p_priority, int_t p_initialstate, int_t p_min, int_t p_max, t_uint32 p_prefFlags) + : m_name(p_name), m_parent(p_parent), m_priority(p_priority), m_initval(p_initialstate), m_min(p_min), m_max(p_max), m_state(p_guid, p_initialstate), m_prefFlags(p_prefFlags) { + PFC_ASSERT(p_min < p_max); + } + void get_name(pfc::string_base& p_out) { p_out = m_name; } + GUID get_guid() { return m_state.get_guid(); } + GUID get_parent() { return m_parent; } + void reset() { m_state = m_initval; } + double get_sort_priority() { return m_priority; } + void get_state(pfc::string_base& p_out) { format(p_out, m_state.get_value()); } + void set_state(const char* p_string, t_size p_length) { set_state_int(myATOI(p_string, p_length)); } + t_uint32 get_flags() { return advconfig_entry_string::flag_is_integer | (is_signed() ? flag_is_signed : 0); } + + int_t get_state_int() const { return m_state; } + void set_state_int(int_t val) { m_state = pfc::clip_t(val, m_min, m_max); } + + void get_default_state(pfc::string_base& out) { + format(out, m_initval); + } + void validate(pfc::string_base& val) { + format(val, pfc::clip_t(myATOI(val, SIZE_MAX), m_min, m_max)); + } + t_uint32 get_preferences_flags() { return m_prefFlags; } +#if FOOBAR2000_SUPPORT_CFG_VAR_DOWNGRADE + void downgrade_set_name(const char * arg) { m_state.downgrade_set_name(arg); } +#endif +private: + static void format(pfc::string_base& out, int_t v) { + if (is_signed()) out = pfc::format_int(v).get_ptr(); + else out = pfc::format_uint(v).get_ptr(); + } + static int_t myATOI(const char* s, size_t l) { + if (is_signed()) return pfc::atoi64_ex(s, l); + else return pfc::atoui64_ex(s, l); + } + static bool is_signed() { + return ((int_t)-1) < ((int_t)0); + } + cfg_int_t m_state; + const double m_priority; + const int_t m_initval, m_min, m_max; + const GUID m_parent; + const pfc::string8 m_name; + const t_uint32 m_prefFlags; +}; + +typedef advconfig_entry_integer_impl_ advconfig_entry_integer_impl; + +//! Service factory helper around integer-specialized advconfig_entry_string implementation. Use this class to register your own integer entries in Advanced Preferences. \n +//! Usage: static advconfig_integer_factory myint(name, itemID, parentID, priority, initialValue, minValue, maxValue); +template +class advconfig_integer_factory_ : public service_factory_single_t > { +public: + typedef int_t_ int_t; + advconfig_integer_factory_(const char* p_name, const GUID& p_guid, const GUID& p_parent, double p_priority, t_uint64 p_initialstate, t_uint64 p_min, t_uint64 p_max, t_uint32 p_prefFlags = 0) + : service_factory_single_t >(p_name, p_guid, p_parent, p_priority, p_initialstate, p_min, p_max, p_prefFlags) { + ADVCONFIG_DOWNGRADE_AUTO; + } + + advconfig_integer_factory_(const char* p_name, const char * configStoreName, const GUID& p_guid, const GUID& p_parent, double p_priority, t_uint64 p_initialstate, t_uint64 p_min, t_uint64 p_max, t_uint32 p_prefFlags = 0) + : service_factory_single_t >(p_name, p_guid, p_parent, p_priority, p_initialstate, p_min, p_max, p_prefFlags) { + ADVCONFIG_DOWNGRADE; + } + + int_t get() const { return this->get_static_instance().get_state_int(); } + void set(int_t val) { this->get_static_instance().set_state_int(val); } + + operator int_t() const { return get(); } + int_t operator=(int_t val) { set(val); return val; } +}; + +typedef advconfig_integer_factory_ advconfig_integer_factory; +typedef advconfig_integer_factory_ advconfig_signed_integer_factory; + + +//! Standard advconfig_entry_string implementation +class advconfig_entry_string_impl : public advconfig_entry_string_v2 { +public: + advconfig_entry_string_impl(const char* p_name, const GUID& p_guid, const GUID& p_parent, double p_priority, const char* p_initialstate, t_uint32 p_prefFlags) + : m_name(p_name), m_parent(p_parent), m_priority(p_priority), m_initialstate(p_initialstate), m_state(p_guid, p_initialstate), m_prefFlags(p_prefFlags) {} + void get_name(pfc::string_base& p_out) { p_out = m_name; } + GUID get_guid() { return m_state.get_guid(); } + GUID get_parent() { return m_parent; } + void reset() { + inWriteSync(m_sync); + m_state = m_initialstate; + } + double get_sort_priority() { return m_priority; } + void get_state(pfc::string_base& p_out) { + inReadSync(m_sync); + p_out = m_state; + } + void set_state(const char* p_string, t_size p_length = SIZE_MAX) { + inWriteSync(m_sync); + m_state.set_string(p_string, p_length); + } + t_uint32 get_flags() { return 0; } + void get_default_state(pfc::string_base& out) { out = m_initialstate; } + t_uint32 get_preferences_flags() { return m_prefFlags; } +#if FOOBAR2000_SUPPORT_CFG_VAR_DOWNGRADE + void downgrade_set_name(const char * arg) { m_state.downgrade_set_name(arg); } +#endif +private: + const pfc::string8 m_initialstate, m_name; + cfg_string m_state; + pfc::readWriteLock m_sync; + const double m_priority; + const GUID m_parent; + const t_uint32 m_prefFlags; +}; + +//! Service factory helper around standard advconfig_entry_string implementation. Use this class to register your own string entries in Advanced Preferences. \n +//! Usage: static advconfig_string_factory mystring(name, itemID, branchID, priority, initialValue); +class advconfig_string_factory : public service_factory_single_t { +public: + advconfig_string_factory(const char* p_name, const GUID& p_guid, const GUID& p_parent, double p_priority, const char* p_initialstate, t_uint32 p_prefFlags = 0) + : service_factory_single_t(p_name, p_guid, p_parent, p_priority, p_initialstate, p_prefFlags) { + ADVCONFIG_DOWNGRADE_AUTO; + } + advconfig_string_factory(const char* p_name, const char * configStoreName, const GUID& p_guid, const GUID& p_parent, double p_priority, const char* p_initialstate, t_uint32 p_prefFlags = 0) + : service_factory_single_t(p_name, p_guid, p_parent, p_priority, p_initialstate, p_prefFlags) { + ADVCONFIG_DOWNGRADE; + } + + void get(pfc::string_base& out) { get_static_instance().get_state(out); } + void set(const char* in) { get_static_instance().set_state(in); } +}; + +// No more separate _MT versions, readWriteLock overhead is irrelevant +typedef advconfig_entry_string_impl advconfig_entry_string_impl_MT; +typedef advconfig_string_factory advconfig_string_factory_MT; + + +/* + Advanced Preferences variable declaration examples + + static advconfig_string_factory mystring("name goes here",myguid,parentguid,0,"asdf"); + to retrieve state: pfc::string8 val; mystring.get(val); + + static advconfig_checkbox_factory mycheckbox("name goes here",myguid,parentguid,0,false); + to retrieve state: mycheckbox.get(); + + static advconfig_integer_factory myint("name goes here",myguid,parentguid,0,initialValue,minimumValue,maximumValue); + to retrieve state: myint.get(); +*/ + + +#undef ADVCONFIG_DOWNGRADE +#undef ADVCONFIG_DOWNGRADE_AUTO diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/album_art.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/album_art.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,221 @@ +#include "foobar2000-sdk-pch.h" +#include "image.h" +#include "album_art.h" +#include "album_art_helpers.h" +#include "input.h" + +GUID album_art_extractor::get_guid() { + album_art_extractor_v2::ptr v2; + if ( v2 &= this ) return v2->get_guid(); + return pfc::guid_null; +} + +GUID album_art_editor::get_guid() { + album_art_editor_v2::ptr v2; + if ( v2 &= this ) return v2->get_guid(); + return pfc::guid_null; +} + +bool album_art_extractor_instance::query(const GUID & what, album_art_data::ptr & out, abort_callback & abort) { + try { out = query(what, abort); return true; } catch (exception_album_art_not_found const &) { return false; } +} + +service_ptr_t album_art_extractor_instance::query_image_(const GUID & what, abort_callback& a) { + auto data = this->query(what, a); + return fb2k::imageCreator::get()->loadImageData( data); +} + +bool album_art_extractor_instance::have_entry(const GUID & what, abort_callback & abort) { + try { query(what, abort); return true; } catch(exception_album_art_not_found const &) { return false; } +} + +void album_art_editor_instance::remove_all_() { + album_art_editor_instance_v2::ptr v2; + if ( v2 &= this ) { + v2->remove_all(); + } else { + for( size_t walk = 0; walk < album_art_ids::num_types(); ++ walk ) { + try { + this->remove( album_art_ids::query_type( walk ) ); + } catch(exception_io_data const &) {} + catch(exception_album_art_not_found const &) {} + } + } +} + +bool album_art_editor::g_get_interface(service_ptr_t & out,const char * path) { + auto ext = pfc::string_extension(path); + for (auto ptr : enumerate()) { + if (ptr->is_our_path(path, ext)) { out = ptr; return true; } + } + return false; +} + +bool album_art_editor::g_is_supported_path(const char * path) { + ptr ptr; return g_get_interface(ptr,path); +} + +album_art_editor_instance_ptr album_art_editor::g_open(file_ptr p_filehint,const char * p_path,abort_callback & p_abort) { + +#ifdef FOOBAR2000_DESKTOP + { + input_manager_v2::ptr m; + if (fb2k::std_api_try_get(m)) { + album_art_editor_instance::ptr ret; + ret ^= m->open_v2(album_art_editor_instance::class_guid, p_filehint, p_path, false, nullptr, p_abort); + return ret; + } + } +#endif + + album_art_editor::ptr obj; + if (!g_get_interface(obj, p_path)) throw exception_album_art_unsupported_format(); + return obj->open(p_filehint, p_path, p_abort); +} + + +bool album_art_extractor::g_get_interface(service_ptr_t & out,const char * path) { + + auto ext = pfc::string_extension(path); + for (auto ptr : enumerate()) { + if (ptr->is_our_path(path, ext)) { out = ptr; return true; } + } + return false; +} + +bool album_art_extractor::g_is_supported_path(const char * path) { + ptr ptr; return g_get_interface(ptr,path); +} +album_art_extractor_instance_ptr album_art_extractor::g_open(file_ptr p_filehint,const char * p_path,abort_callback & p_abort) { +#ifdef FOOBAR2000_DESKTOP + { + input_manager_v2::ptr m; + if (fb2k::std_api_try_get(m)) { + album_art_extractor_instance::ptr ret; + ret ^= m->open_v2(album_art_extractor_instance::class_guid, p_filehint, p_path, false, nullptr, p_abort); + return ret; + } + } +#endif + + album_art_extractor::ptr obj; + if (!g_get_interface(obj, p_path)) throw exception_album_art_unsupported_format(); + return obj->open(p_filehint, p_path, p_abort); +} + + +album_art_extractor_instance_ptr album_art_extractor::g_open_allowempty(file_ptr p_filehint,const char * p_path,abort_callback & p_abort) { + try { + return g_open(p_filehint, p_path, p_abort); + } catch(exception_album_art_not_found const &) { + return new service_impl_t(); + } +} + +namespace { + class now_playing_album_art_notify_lambda : public now_playing_album_art_notify { + public: + void on_album_art(album_art_data::ptr data) { + f(data); + } + std::function f; + }; +} + +now_playing_album_art_notify * now_playing_album_art_notify_manager::add(std::function f ) { + PFC_ASSERT ( f != nullptr ); + auto obj = new now_playing_album_art_notify_lambda; + obj->f = f; + add(obj); + return obj; +} + +namespace { + struct aa_t { + GUID type; const char * name; + }; + static const GUID guids[] = { + album_art_ids::cover_front, + album_art_ids::cover_back, + album_art_ids::artist, + album_art_ids::disc, + album_art_ids::icon, + }; + static const char * const names[] = { + "front cover", + "back cover", + "artist", + "disc", + "icon" + }; + static const char * const names2[] = { + "Front Cover", + "Back Cover", + "Artist", + "Disc", + "Icon" + }; +} + +size_t album_art_ids::num_types() { + PFC_STATIC_ASSERT( PFC_TABSIZE( guids ) == PFC_TABSIZE( names ) ); + PFC_STATIC_ASSERT( PFC_TABSIZE( guids ) == PFC_TABSIZE( names2 ) ); + return PFC_TABSIZE( guids ); +} + +GUID album_art_ids::query_type(size_t idx) { + PFC_ASSERT( idx < PFC_TABSIZE( guids ) ); + return guids[idx]; +} + +const char * album_art_ids::query_name(size_t idx) { + PFC_ASSERT( idx < PFC_TABSIZE( names ) ); + return names[idx]; +} + +const char* album_art_ids::name_of_ex(const GUID& id, const char* def) { + auto ret = name_of(id); + if ( ret == nullptr ) ret = def; + return ret; +} + +const char * album_art_ids::name_of(const GUID & id) { + for( size_t w = 0; w < num_types(); ++w ) { + if ( query_type(w) == id ) return query_name(w); + } + return nullptr; +} + +const char * album_art_ids::query_capitalized_name( size_t idx ) { + PFC_ASSERT( idx < PFC_TABSIZE( names2 ) ); + return names2[idx]; +} + +const char * album_art_ids::capitalized_name_of( const GUID & id) { + for( size_t w = 0; w < num_types(); ++w ) { + if ( query_type(w) == id ) return query_capitalized_name(w); + } + return nullptr; +} + +GUID album_art_ids::by_name(const char* arg) { + for (size_t w = 0; w < num_types(); ++w) { + if (pfc::stringEqualsI_ascii(query_name(w), arg)) return query_type(w); + } + return pfc::guid_null; +} + +bool album_art_path_list::equals(album_art_path_list const& v1, album_art_path_list const& v2) { + const size_t n = v1.get_count(); + if (n != v2.get_count()) return false; + for (size_t w = 0; w < n; ++w) { + if (playable_location::path_compare(v1.get_path(w), v2.get_path(w)) != 0) return false; + } + return true; +} + +bool album_art_path_list::equals(ptr const& v1, ptr const& v2) { + if (v1.is_valid() != v2.is_valid()) return false; + if (v1.is_empty() && v2.is_empty()) return true; + return equals(*v1, *v2); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/album_art.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/album_art.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,272 @@ +#pragma once + +#include +#include "commonObjects.h" +#include "exception_io.h" +#include "filesystem.h" +#include "metadb.h" + +namespace fb2k { + class image; +} +//! Namespace containing identifiers of album art types. +namespace album_art_ids { + //! Front cover. + static constexpr GUID cover_front = { 0xf1e66f4e, 0xfe09, 0x4b94, { 0x91, 0xa3, 0x67, 0xc2, 0x3e, 0xd1, 0x44, 0x5e } }; + //! Back cover. + static constexpr GUID cover_back = { 0xcb552d19, 0x86d5, 0x434c, { 0xac, 0x77, 0xbb, 0x24, 0xed, 0x56, 0x7e, 0xe4 } }; + //! Picture of a disc or other storage media. + static constexpr GUID disc = { 0x3dba9f36, 0xf928, 0x4fa4, { 0x87, 0x9c, 0xd3, 0x40, 0x47, 0x59, 0x58, 0x7e } }; + //! Album-specific icon (NOT a file type icon). + static constexpr GUID icon = { 0x74cdf5b4, 0x7053, 0x4b3d, { 0x9a, 0x3c, 0x54, 0x69, 0xf5, 0x82, 0x6e, 0xec } }; + //! Artist picture. + static constexpr GUID artist = { 0x9a654042, 0xacd1, 0x43f7, { 0xbf, 0xcf, 0xd3, 0xec, 0xf, 0xfe, 0x40, 0xfa } }; + + size_t num_types(); + GUID query_type( size_t ); + // returns lowercase name + const char * query_name( size_t ); + const char * name_of( const GUID & ); + const char * name_of_ex( const GUID &, const char * def = "undefined"); + // returns Capitalized name + const char * query_capitalized_name( size_t ); + const char * capitalized_name_of( const GUID & ); + + GUID by_name(const char*); +}; + +PFC_DECLARE_EXCEPTION(exception_album_art_not_found,exception_io_not_found,"Attached picture not found"); +PFC_DECLARE_EXCEPTION(exception_album_art_unsupported_entry,exception_io_data,"Unsupported attached picture entry"); + +PFC_DECLARE_EXCEPTION(exception_album_art_unsupported_format,exception_io_data,"Attached picture operations not supported for this file format"); + +//! Class encapsulating access to album art stored in a media file. Use album_art_extractor class obtain album_art_extractor_instance referring to specified media file. +class NOVTABLE album_art_extractor_instance : public service_base { + FB2K_MAKE_SERVICE_INTERFACE(album_art_extractor_instance,service_base); +public: + //! Throws exception_album_art_not_found when the requested album art entry could not be found in the referenced media file. + virtual album_art_data_ptr query(const GUID & p_what,abort_callback & p_abort) = 0; + + bool have_entry( const GUID & what, abort_callback & abort ); + bool query(const GUID & what, album_art_data::ptr & out, abort_callback & abort); + + //! Future compatiblity, load directly to fb2k::image + //! Might be eventually specialized for operating system supported formats + service_ptr_t query_image_(const GUID &, abort_callback&); +}; + +//! Class encapsulating access to album art stored in a media file. Use album_art_editor class to obtain album_art_editor_instance referring to specified media file. +class NOVTABLE album_art_editor_instance : public album_art_extractor_instance { + FB2K_MAKE_SERVICE_INTERFACE(album_art_editor_instance,album_art_extractor_instance); +public: + //! Throws exception_album_art_unsupported_entry when the file format we're dealing with does not support specific entry. + virtual void set(const GUID & p_what,album_art_data_ptr p_data,abort_callback & p_abort) = 0; + + //! Removes the requested entry. Fails silently when the entry doesn't exist. + virtual void remove(const GUID & p_what) = 0; + + //! Finalizes file tag update operation. + virtual void commit(abort_callback & p_abort) = 0; + + //! Helper; see album_art_editor_instance_v2::remove_all(); + void remove_all_(); +}; + +//! Extension to album_art_editor_instance, adds remove_all(). +class NOVTABLE album_art_editor_instance_v2 : public album_art_editor_instance { + FB2K_MAKE_SERVICE_INTERFACE(album_art_editor_instance_v2, album_art_editor_instance); +public: + //! Tells the editor to remove all entries, including unsupported picture types that do not translate to fb2k ids. + virtual void remove_all() = 0; +}; + +typedef service_ptr_t album_art_extractor_instance_ptr; +typedef service_ptr_t album_art_editor_instance_ptr; + +//! Entrypoint class for accessing album art extraction functionality. Register your own implementation to allow album art extraction from your media file format. \n +//! If you want to extract album art from a media file, it's recommended that you use album_art_manager API instead of calling album_art_extractor directly. +class NOVTABLE album_art_extractor : public service_base { + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(album_art_extractor); +public: + //! Returns whether the specified file is one of formats supported by our album_art_extractor implementation. + //! @param p_path Path to file being queried. + //! @param p_extension Extension of file being queried (also present in p_path parameter) - provided as a separate parameter for performance reasons. + virtual bool is_our_path(const char * p_path,const char * p_extension) = 0; + + //! Instantiates album_art_extractor_instance providing access to album art stored in a specified media file. \n + //! Throws one of I/O exceptions on failure; exception_album_art_not_found when the file has no album art record at all. + //! @param p_filehint Optional; specifies a file interface to use for accessing the specified file; can be null - in that case, the implementation will open and close the file internally. + virtual album_art_extractor_instance_ptr open(file_ptr p_filehint,const char * p_path,abort_callback & p_abort) = 0; + + static bool g_get_interface(service_ptr_t & out,const char * path); + static bool g_is_supported_path(const char * path); + static album_art_extractor_instance_ptr g_open(file_ptr p_filehint,const char * p_path,abort_callback & p_abort); + static album_art_extractor_instance_ptr g_open_allowempty(file_ptr p_filehint,const char * p_path,abort_callback & p_abort); + + //! Returns GUID of the corresponding input class. Null GUID if none. + GUID get_guid(); +}; + +//! \since 1.5 +class NOVTABLE album_art_extractor_v2 : public album_art_extractor { + FB2K_MAKE_SERVICE_INTERFACE(album_art_extractor_v2 , album_art_extractor); +public: + //! Returns GUID of the corresponding input class. Null GUID if none. + virtual GUID get_guid() = 0; +}; + +//! Entrypoint class for accessing album art editing functionality. Register your own implementation to allow album art editing on your media file format. +class NOVTABLE album_art_editor : public service_base { + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(album_art_editor); +public: + //! Returns whether the specified file is one of formats supported by our album_art_editor implementation. + //! @param p_path Path to file being queried. + //! @param p_extension Extension of file being queried (also present in p_path parameter) - provided as a separate parameter for performance reasons. + virtual bool is_our_path(const char * p_path,const char * p_extension) = 0; + + //! Instantiates album_art_editor_instance providing access to album art stored in a specified media file. \n + //! @param p_filehint Optional; specifies a file interface to use for accessing the specified file; can be null - in that case, the implementation will open and close the file internally. + virtual album_art_editor_instance_ptr open(file_ptr p_filehint,const char * p_path,abort_callback & p_abort) = 0; + + //! Helper; attempts to retrieve an album_art_editor service pointer that supports the specified file. + //! @returns True on success, false on failure (no registered album_art_editor supports this file type). + static bool g_get_interface(service_ptr_t & out,const char * path); + //! Helper; returns whether one of registered album_art_editor implementations is capable of opening the specified file. + static bool g_is_supported_path(const char * path); + + static album_art_editor_instance_ptr g_open(file_ptr p_filehint,const char * p_path,abort_callback & p_abort); + + //! Returns GUID of the corresponding input class. Null GUID if none. + GUID get_guid(); +}; + +//! \since 1.5 +class NOVTABLE album_art_editor_v2 : public album_art_editor { + FB2K_MAKE_SERVICE_INTERFACE( album_art_editor_v2, album_art_editor ) +public: + //! Returns GUID of the corresponding input class. Null GUID if none. + virtual GUID get_guid() = 0; +}; + +//! \since 0.9.5 +//! Helper API for extracting album art from APEv2 tags. +class NOVTABLE tag_processor_album_art_utils : public service_base { + FB2K_MAKE_SERVICE_COREAPI(tag_processor_album_art_utils) +public: + + //! Throws one of I/O exceptions on failure; exception_album_art_not_found when the file has no album art record at all. + virtual album_art_extractor_instance_ptr open(file_ptr p_file,abort_callback & p_abort) = 0; + + //! \since 1.1.6 + //! Throws exception_not_implemented on earlier than 1.1.6. + virtual album_art_editor_instance_ptr edit(file_ptr p_file,abort_callback & p_abort) = 0; +}; + + +//! Album art path list - see album_art_extractor_instance_v2 +class NOVTABLE album_art_path_list : public service_base { + FB2K_MAKE_SERVICE_INTERFACE(album_art_path_list, service_base) +public: + virtual const char * get_path(t_size index) const = 0; + virtual t_size get_count() const = 0; + + static bool equals(album_art_path_list const& v1, album_art_path_list const& v2); + static bool equals(ptr const& v1, ptr const& v2); +}; + +//! album_art_extractor_instance extension; lets the frontend query referenced file paths (eg. when using external album art). +class NOVTABLE album_art_extractor_instance_v2 : public album_art_extractor_instance { + FB2K_MAKE_SERVICE_INTERFACE(album_art_extractor_instance_v2, album_art_extractor_instance) +public: + virtual album_art_path_list::ptr query_paths(const GUID & p_what, abort_callback & p_abort) = 0; +}; + + +//! \since 1.0 +//! Provides methods for interfacing with the foobar2000 core album art loader. \n +//! Use this when you need to load album art for a specific group of tracks. +class NOVTABLE album_art_manager_v2 : public service_base { + FB2K_MAKE_SERVICE_COREAPI(album_art_manager_v2) +public: + //! Instantiates an album art extractor object for the specified group of items. + virtual album_art_extractor_instance_v2::ptr open(metadb_handle_list_cref items, pfc::list_base_const_t const & ids, abort_callback & abort) = 0; + + //! Instantiates an album art extractor object that retrieves stub images. + virtual album_art_extractor_instance_v2::ptr open_stub(abort_callback & abort) = 0; +}; + + +//! \since 1.0 +//! Called when no other album art source (internal, external, other registered fallbacks) returns relevant data for the specified items. \n +//! Can be used to implement online lookup and such. +class NOVTABLE album_art_fallback : public service_base { + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(album_art_fallback) +public: + virtual album_art_extractor_instance_v2::ptr open(metadb_handle_list_cref items, pfc::list_base_const_t const & ids, abort_callback & abort) = 0; +}; + +//! \since 1.1.7 +class NOVTABLE album_art_manager_config : public service_base { + FB2K_MAKE_SERVICE_INTERFACE(album_art_manager_config, service_base) +public: + virtual bool get_external_pattern(pfc::string_base & out, const GUID & type) = 0; + virtual bool use_embedded_pictures() = 0; + virtual bool use_fallbacks() = 0; +}; + +//! \since 1.1.7 +class NOVTABLE album_art_manager_v3 : public album_art_manager_v2 { + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(album_art_manager_v3, album_art_manager_v2) +public: + //! @param config An optional album_art_manager_config object to override global settings. Pass null to use global settings. + virtual album_art_extractor_instance_v2::ptr open_v3(metadb_handle_list_cref items, pfc::list_base_const_t const & ids, album_art_manager_config::ptr config, abort_callback & abort) = 0; +}; + +//! \since 1.4 +//! A notification about a newly loaded album art being ready to display. \n +//! See: now_playing_album_art_notify_manager. +class NOVTABLE now_playing_album_art_notify { +public: + //! Called when album art has finished loading for the now playing track. + //! @param data The newly loaded album art. Never a null object - the callbacks are simply not called when there is nothing to show. + virtual void on_album_art( album_art_data::ptr data ) = 0; +}; + +//! \since 1.4 +//! Since various components require the album art of the now-playing track, a centralized loader has been provided, so the file isn't hammered independently by different components. \n +//! Use this in conjunction with play_callback notifications to render now-playing track information. +class NOVTABLE now_playing_album_art_notify_manager : public service_base { + FB2K_MAKE_SERVICE_COREAPI(now_playing_album_art_notify_manager) +public: + //! Register a notification to be told when the album art has been loaded. + virtual void add(now_playing_album_art_notify*) = 0; + //! Unregister a previously registered notification. + virtual void remove(now_playing_album_art_notify*) = 0; + //! Retrieves the album art for the currently playing track. + //! @returns The current album art (front cover), or null if there is no art or the art is being loaded and is not yet available. + virtual album_art_data::ptr current() = 0; + + //! Helper; register a lambda notification. Pass the returned obejct to remove() to unregister. + now_playing_album_art_notify* add( std::function ); +}; + +//! \since 1.6.6 +class NOVTABLE now_playing_album_art_notify_manager_v2 : public now_playing_album_art_notify_manager { + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(now_playing_album_art_notify_manager_v2, now_playing_album_art_notify_manager); +public: + struct info_t { + album_art_data::ptr data; + album_art_path_list::ptr paths; + + static bool equals(const info_t& v1, const info_t& v2) { + return album_art_data::equals(v1.data, v2.data) && album_art_path_list::equals(v1.paths, v2.paths); + } + bool operator==(const info_t& other) const { return equals(*this, other); } + bool operator!=(const info_t& other) const { return !equals(*this, other); } + + void clear() { *this = {}; } + bool is_valid() const { return data.is_valid(); } + operator bool() const { return is_valid(); } + }; + virtual info_t current_v2() = 0; +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/album_art_helpers.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/album_art_helpers.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,169 @@ +#pragma once +#include "album_art.h" + +//! Implements album_art_data. +class album_art_data_impl : public album_art_data { +public: + const void * data() const override {return m_content.get_ptr();} + size_t size() const override {return m_content.get_size();} + + const void * get_data() const { return m_content.get_ptr(); } + size_t sizeget_() const { return m_content.get_size(); } + + void * get_ptr() {return m_content.get_ptr();} + void set_size(t_size p_size) {m_content.set_size(p_size);} + + //! Reads picture data from the specified stream object. + void from_stream(stream_reader * p_stream,t_size p_bytes,abort_callback & p_abort) { + set_size(p_bytes); p_stream->read_object(get_ptr(),p_bytes,p_abort); + } + + //! Creates an album_art_data object from picture data contained in a memory buffer. + static album_art_data_ptr g_create(const void * p_buffer,t_size p_bytes) { + service_ptr_t instance = new service_impl_t(); + instance->set_size(p_bytes); + memcpy(instance->get_ptr(),p_buffer,p_bytes); + return instance; + } + //! Creates an album_art_data object from picture data contained in a stream. + static album_art_data_ptr g_create(stream_reader * p_stream,t_size p_bytes,abort_callback & p_abort) { + service_ptr_t instance = new service_impl_t(); + instance->from_stream(p_stream,p_bytes,p_abort); + return instance; + } + +private: + pfc::array_t m_content; +}; + + +//! Helper - simple implementation of album_art_extractor_instance. +class album_art_extractor_instance_simple : public album_art_extractor_instance { +public: + void set(const GUID & p_what,album_art_data_ptr p_content) {m_content.set(p_what,p_content);} + bool have_item(const GUID & p_what) {return m_content.have_item(p_what);} + album_art_data_ptr query(const GUID & p_what,abort_callback & p_abort) { + p_abort.check(); + album_art_data_ptr temp; + if (!m_content.query(p_what,temp)) throw exception_album_art_not_found(); + return temp; + } + bool is_empty() const {return m_content.get_count() == 0;} + bool remove(const GUID & p_what) { + return m_content.remove(p_what); + } + void remove_all() { + m_content.remove_all(); + } +private: + pfc::map_t m_content; +}; + +//! Helper implementation of album_art_extractor - reads album art from arbitrary file formats that comply with APEv2 tagging specification. +class album_art_extractor_impl_stdtags : public album_art_extractor_v2 { +public: + //! @param exts Semicolon-separated list of file format extensions to support. + album_art_extractor_impl_stdtags(const char * exts, const GUID & guid) : m_guid(guid) { + pfc::splitStringSimple_toList(m_extensions,';',exts); + } + + bool is_our_path(const char * p_path,const char * p_extension) override { + (void)p_path; + return m_extensions.have_item(p_extension); + } + + album_art_extractor_instance_ptr open(file_ptr p_filehint,const char * p_path,abort_callback & p_abort) override { + PFC_ASSERT( is_our_path(p_path, pfc::string_extension(p_path) ) ); + file_ptr l_file ( p_filehint ); + if (l_file.is_empty()) filesystem::g_open_read(l_file, p_path, p_abort); + return tag_processor_album_art_utils::get()->open( l_file, p_abort ); + } + + GUID get_guid() override { + return m_guid; + } +private: + pfc::avltree_t m_extensions; + const GUID m_guid; +}; + +//! Helper implementation of album_art_editor - edits album art from arbitrary file formats that comply with APEv2 tagging specification. +class album_art_editor_impl_stdtags : public album_art_editor_v2 { +public: + //! @param exts Semicolon-separated list of file format extensions to support. + album_art_editor_impl_stdtags(const char * exts, const GUID & guid) : m_guid(guid) { + pfc::splitStringSimple_toList(m_extensions,';',exts); + } + + bool is_our_path(const char * p_path,const char * p_extension) override { + (void)p_path; + return m_extensions.have_item(p_extension); + } + + album_art_editor_instance_ptr open(file_ptr p_filehint,const char * p_path,abort_callback & p_abort) override { + PFC_ASSERT( is_our_path(p_path, pfc::string_extension(p_path) ) ); + file_ptr l_file ( p_filehint ); + if (l_file.is_empty()) filesystem::g_open(l_file, p_path, filesystem::open_mode_write_existing, p_abort); + return tag_processor_album_art_utils::get()->edit( l_file, p_abort ); + } + GUID get_guid() override { + return m_guid; + } +private: + pfc::avltree_t m_extensions; + const GUID m_guid; + +}; + +//! Helper - a more advanced implementation of album_art_extractor_instance. +class album_art_extractor_instance_fileref : public album_art_extractor_instance { +public: + album_art_extractor_instance_fileref(file::ptr f) : m_file(f) {} + + void set(const GUID & p_what,t_filesize p_offset, t_filesize p_size) { + const t_fileref ref = {p_offset, p_size}; + m_data.set(p_what, ref); + m_cache.remove(p_what); + } + + bool have_item(const GUID & p_what) { + return m_data.have_item(p_what); + } + + album_art_data_ptr query(const GUID & p_what,abort_callback & p_abort) { + album_art_data_ptr item; + if (m_cache.query(p_what,item)) return item; + t_fileref ref; + if (!m_data.query(p_what, ref)) throw exception_album_art_not_found(); + m_file->seek(ref.m_offset, p_abort); + item = album_art_data_impl::g_create(m_file.get_ptr(), pfc::downcast_guarded(ref.m_size), p_abort); + m_cache.set(p_what, item); + return item; + } + bool is_empty() const {return m_data.get_count() == 0;} +private: + struct t_fileref { + t_filesize m_offset, m_size; + }; + const file::ptr m_file; + pfc::map_t m_data; + pfc::map_t m_cache; +}; + +//! album_art_path_list implementation helper +class album_art_path_list_impl : public album_art_path_list { +public: + album_art_path_list_impl(const char* single) { m_data.set_size(1); m_data[0] = single; } + template album_art_path_list_impl(const t_in & in) {pfc::list_to_array(m_data, in);} + const char * get_path(t_size index) const {return m_data[index];} + t_size get_count() const {return m_data.get_size();} +private: + pfc::array_t m_data; +}; + +//! album_art_path_list implementation helper +class album_art_path_list_dummy : public album_art_path_list { +public: + const char * get_path(t_size) const override {FB2K_BugCheck();} + t_size get_count() const override {return 0;} +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/app_close_blocker.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/app_close_blocker.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,72 @@ +#include "foobar2000-sdk-pch.h" +#include "app_close_blocker.h" + +bool app_close_blocker::g_query() +{ + for (auto ptr : enumerate()) { + if (!ptr->query()) return false; + } + return true; +} + +service_ptr async_task_manager::g_acquire() { +#if FOOBAR2000_TARGET_VERSION >= 80 + return get()->acquire(); +#else + ptr obj; + if ( tryGet(obj) ) return obj->acquire(); + return nullptr; +#endif +} + +void fb2k::splitTask( std::function f) { + auto taskref = async_task_manager::g_acquire(); + pfc::splitThread( [f,taskref] { + f(); + (void)taskref; // retain until here + } ); +} + +void fb2k::splitTask( pfc::thread::arg_t const & arg, std::function f) { + auto taskref = async_task_manager::g_acquire(); + pfc::splitThread( arg, [f,taskref] { + f(); + (void)taskref; // retain until here + } ); +} + +abort_callback& fb2k::mainAborter() { + return async_task_manager::get()->get_aborter(); +} + +app_close_blocking_task_impl::app_close_blocking_task_impl(const char * name) : m_name(name) { + PFC_ASSERT( core_api::is_main_thread() ); + app_close_blocking_task_manager::get()->register_task(this); +} +app_close_blocking_task_impl::app_close_blocking_task_impl(pfc::string8&& name) : m_name(std::move(name)) { + PFC_ASSERT(core_api::is_main_thread()); + app_close_blocking_task_manager::get()->register_task(this); +} + +app_close_blocking_task_impl::~app_close_blocking_task_impl() { + PFC_ASSERT( core_api::is_main_thread() ); + app_close_blocking_task_manager::get()->unregister_task(this); +} + +void app_close_blocking_task_impl::query_task_name(pfc::string_base & out) { + out = m_name; +} + +void app_close_blocking_task_impl_dynamic::toggle_blocking(bool state) { + PFC_ASSERT( core_api::is_main_thread() ); + if (state != m_taskActive) { + auto api = app_close_blocking_task_manager::get(); + if (state) api->register_task(this); + else api->unregister_task(this); + m_taskActive = state; + } +} + +void app_close_blocking_task_impl_dynamic::query_task_name(pfc::string_base& out) { + out = m_name; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/app_close_blocker.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/app_close_blocker.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,93 @@ +#pragma once + +#include + +//! (DEPRECATED) This service is used to signal whether something is currently preventing main window from being closed and app from being shut down. +class NOVTABLE app_close_blocker : public service_base +{ +public: + //! Checks whether this service is currently preventing main window from being closed and app from being shut down. + virtual bool query() = 0; + + //! Static helper function, checks whether any of registered app_close_blocker services is currently preventing main window from being closed and app from being shut down. + static bool g_query(); + + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(app_close_blocker); +}; + +//! An interface encapsulating a task preventing the foobar2000 application from being closed. Instances of this class need to be registered using app_close_blocking_task_manager methods. \n +//! Implementation: it's recommended that you derive from app_close_blocking_task_impl class instead of deriving from app_close_blocking_task directly, it manages registration/unregistration behind-the-scenes. +class NOVTABLE app_close_blocking_task { +public: + //! Retrieves user-friendly name of the task to be shown to the user, should the user try to close foobar2000 while the task is active. \n + //! Implementation note: this will NOT be called from register_task() or unregister_task(), only in response to user attempting to close foobar2000. \n + //! Common helper implementations of app_close_blocking_task register from base class constructor while intended query_task_name() override is not yet in place. + virtual void query_task_name(pfc::string_base & out) = 0; + +protected: + app_close_blocking_task() {} + ~app_close_blocking_task() {} + + PFC_CLASS_NOT_COPYABLE_EX(app_close_blocking_task); +}; + +//! Entrypoint class for registering app_close_blocking_task instances. \n +//! You can use app_close_blocking_task_impl to call this automatically with your object. +class NOVTABLE app_close_blocking_task_manager : public service_base { + FB2K_MAKE_SERVICE_COREAPI(app_close_blocking_task_manager); +public: + //! Registers a task object. \n + //! Main thread only. + virtual void register_task(app_close_blocking_task * task) = 0; + //! Unregisters a task object. \n + //! Main thread only. + virtual void unregister_task(app_close_blocking_task * task) = 0; +}; + +//! Helper; implements standard functionality required by app_close_blocking_task implementations - registers/unregisters the task on construction/destruction. +class app_close_blocking_task_impl : public app_close_blocking_task { +public: + app_close_blocking_task_impl(const char * name = ""); + app_close_blocking_task_impl(pfc::string8&& name); + ~app_close_blocking_task_impl(); + + //! Override me, or provide name to constructor + void query_task_name(pfc::string_base & out) override; + + app_close_blocking_task_impl( const app_close_blocking_task_impl & ) = delete; + void operator=(const app_close_blocking_task_impl & ) = delete; +private: + const pfc::string8 m_name; +}; + +class app_close_blocking_task_impl_dynamic : public app_close_blocking_task { +public: + app_close_blocking_task_impl_dynamic(const char * name = "") : m_name(name) {} + ~app_close_blocking_task_impl_dynamic() { toggle_blocking(false); } + + //! Override me, or provide name to constructor + void query_task_name(pfc::string_base & out) override; + + void toggle_blocking(bool state); +private: + bool m_taskActive = false; + const pfc::string8 m_name; +}; + + +//! \since 1.4.5 +//! Provides means for async tasks - running detached from any UI - to reliably finish before the app terminates. \n +//! During a late phase of app shutdown, past initquit ops, when no worker code should be still running - a core-managed instance of abort_callback is signaled, \n +//! then main thread stalls until all objects created with acquire() have been released. \n +//! As this API was introduced out-of-band with 1.4.5, you should use tryGet() to obtain it with FOOBAR2000_TARGET_VERSION < 80, but can safely use ::get() with FOOBAR2000_TARGET_VERSION >= 80. +class async_task_manager : public service_base { + FB2K_MAKE_SERVICE_COREAPI( async_task_manager ); +public: + virtual abort_callback & get_aborter() = 0; + virtual service_ptr acquire() = 0; + + //! acquire() helper; returns nullptr if the API isn't available due to old fb2k + static service_ptr g_acquire(); +}; + +// fb2k::spltiTask() moved to threadsLite.h diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/archive.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/archive.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,115 @@ +#pragma once +#include +#include "filesystem.h" + +namespace foobar2000_io { + class archive; + + //! Callback passed to archive listing methods. \n + //! For backwards compatibility, this inherits with abort_callback as well. \n + //! When implementiong, you must override abort_callback methods redirecting them to your abort_callback. \n + //! It is recommended to use lambda-based archive_list helper instead of implementing this interface. + class NOVTABLE archive_callback : public abort_callback { + public: + virtual bool on_entry(archive * owner,const char * url,const t_filestats & p_stats,const service_ptr_t & p_reader) = 0; + }; + + //! Interface for archive reader services. When implementing, derive from archive_impl rather than from deriving from archive directly. + class NOVTABLE archive : public filesystem { + FB2K_MAKE_SERVICE_INTERFACE(archive,filesystem); + public: + typedef std::function list_func_t; + + //! Lists archive contents. \n + //! May be called with any path, not only path accepted by is_our_archive. \n + //! It is strongly recommended to use the lambda_based archive_list() helper instead of calling this directly. + //! @param p_reader Optional reader to use, if the caller already has one. Implementation will open the file if no reader is supplied. + //! @param p_want_readers Flag to tell if the callback wants a reader object for each file in the archive, or just wants to list contents. + virtual void archive_list(const char * p_path,const service_ptr_t & p_reader,archive_callback & p_callback,bool p_want_readers) = 0; + + //! Helper implemented on top of the other archive_list, uses lambda instead of callback, avoids having to implement archive_callback. + void archive_list(const char * path, file::ptr, list_func_t, bool wantReaders, abort_callback&); + + //! Optional method to weed out unsupported formats prior to calling archive_list. \n + //! Use this to suppress calls to archive_list() to avoid spurious exceptions being thrown. \n + //! Implemented via archive_v2. + bool is_our_archive( const char * path ); + }; + + //! \since 1.5 + //! New 1.5 series API, though allowed to implement/call in earlier versions. \n + //! Suppresses spurious C++ exceptions on all files not recognized as archives by this instance. + class NOVTABLE archive_v2 : public archive { + FB2K_MAKE_SERVICE_INTERFACE(archive_v2, archive) + public: + + //! Optional method to weed out unsupported formats prior to calling archive_list. \n + //! Use this to suppress calls to archive_list() to avoid spurious exceptions being thrown. + virtual bool is_our_archive( const char * path ) = 0; + }; + + //! \since 1.6 + //! New 1.6 series API, though allowed to implement/call in earlier versions. + class NOVTABLE archive_v3 : public archive_v2 { + FB2K_MAKE_SERVICE_INTERFACE(archive_v3, archive_v2) + public: + //! Determine supported archive file types. \n + //! Returns a list of extensions, colon delimited, e.g.: "zip,rar,7z" + virtual void list_extensions(pfc::string_base & out) = 0; + }; + //! \since 2.1 + class NOVTABLE archive_v4 : public archive_v3 { + FB2K_MAKE_SERVICE_INTERFACE(archive_v4, archive_v3) + public: + virtual fb2k::arrayRef archive_list_v4( fsItemFilePtr item, file::ptr readerOptional, abort_callback & a) = 0; + }; + + //! Root class for archive implementations. Derive from this instead of from archive directly. + class NOVTABLE archive_impl : public service_multi_inherit { + protected: + //do not override these + bool get_canonical_path(const char * path,pfc::string_base & out) override; + bool is_our_path(const char * path) override; + bool get_display_path(const char * path,pfc::string_base & out) override; + void remove(const char * path,abort_callback & p_abort) override; + void move(const char * src,const char * dst,abort_callback & p_abort) override; + void move_overwrite(const char* src, const char* dst, abort_callback& abort) override; + bool is_remote(const char * src) override; + bool relative_path_create(const char * file_path,const char * playlist_path,pfc::string_base & out) override; + bool relative_path_parse(const char * relative_path,const char * playlist_path,pfc::string_base & out) override; + void open(service_ptr_t & p_out,const char * path, t_open_mode mode,abort_callback & p_abort) override; + void create_directory(const char * path,abort_callback &) override; + void make_directory(const char* path, abort_callback& abort, bool* didCreate = nullptr) override; + void list_directory(const char* p_path, directory_callback& p_out, abort_callback& p_abort) override; + void list_directory_ex(const char* p_path, directory_callback& p_out, unsigned listMode, abort_callback& p_abort) override; + void list_directory_v3(const char* path, directory_callback_v3& callback, unsigned listMode, abort_callback& p_abort) override; + t_filestats2 get_stats2(const char* p_path, uint32_t s2flags, abort_callback& p_abort) override; + virtual void get_stats(const char* p_path, t_filestats& p_stats, bool& p_is_writeable, abort_callback& p_abort) override; + void list_extensions(pfc::string_base & out) override { out = get_archive_type(); } + bool supports_content_types() override { return false; } + char pathSeparator() override { return '/'; } + void extract_filename_ext(const char * path, pfc::string_base & outFN) override; + bool get_display_name_short(const char* in, pfc::string_base& out) override; + fb2k::arrayRef archive_list_v4( fsItemFilePtr item, file::ptr readerOptional, abort_callback & a ) override; + protected: + //override these + virtual const char * get_archive_type()=0;//eg. "zip", must be lowercase + virtual t_filestats2 get_stats2_in_archive(const char * p_archive,const char * p_file,unsigned s2flags,abort_callback & p_abort) = 0; + virtual void open_archive(service_ptr_t & p_out,const char * archive,const char * file, abort_callback & p_abort) = 0;//opens for reading + public: + //override these + // virtual void archive_list(const char * path,const service_ptr_t & p_reader,archive_callback & p_out,bool p_want_readers) = 0; + // virtual bool is_our_archive( const char * path ) = 0; + + static bool g_is_unpack_path(const char * path); + static bool g_parse_unpack_path(const char * path,pfc::string_base & archive,pfc::string_base & file); + static bool g_parse_unpack_path_ex(const char * path,pfc::string_base & archive,pfc::string_base & file, pfc::string_base & type); + static void g_make_unpack_path(pfc::string_base & path,const char * archive,const char * file,const char * type); + void make_unpack_path(pfc::string_base & path,const char * archive,const char * file); + + + }; + + template + class archive_factory_t : public service_factory_single_t {}; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/audioEncoder.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/audioEncoder.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,27 @@ +#pragma once + +namespace fb2k { + //! \since 2.0 + struct audioEncoderSetup_t { + audio_chunk::spec_t spec; + uint32_t bps; + double durationHint; // Optional; if > 0 signals the encoder expected PCM stream length in advance to avoid rewriting headers + }; + //! \since 2.0 + class audioEncoderInstance : public service_base { + FB2K_MAKE_SERVICE_INTERFACE( audioEncoderInstance, service_base); + public: + virtual void addChunk( const audio_chunk & chunk, abort_callback & aborter ) = 0; + virtual void finalize( abort_callback & aborter ) = 0; + }; + + //! \since 2.0 + class audioEncoder : public service_base { + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT( audioEncoder ); + public: + virtual const char * formatExtension() = 0; + virtual audioEncoderInstance::ptr open( file::ptr outFile, audioEncoderSetup_t const & spec, abort_callback & aborter ) = 0; + + static audioEncoderInstance::ptr g_open( const char * targetPath, file::ptr fileHint, audioEncoderSetup_t const & spec, abort_callback & aborter ); + }; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/audio_chunk.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/audio_chunk.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,740 @@ +#include "foobar2000-sdk-pch.h" +#include "mem_block_container.h" +#include "audio_chunk.h" + +void audio_chunk::allocate(size_t size, bool bQuicker) { + if (bQuicker) { + const size_t before = this->get_data_size(); + const size_t allow_waste = pfc::max_t(size, 4096); + const size_t upper = (size + allow_waste > size) ? size + allow_waste : SIZE_MAX; + if (before >= size && before <= upper) return; + } + this->set_data_size(size); +} + +void audio_chunk::set_data(const audio_sample* src, size_t samples, spec_t const & spec, bool bQuicker) { + t_size size = samples * spec.chanCount; + allocate(size, bQuicker); + if (src) + pfc::memcpy_t(get_data(), src, size); + else + pfc::memset_t(get_data(), (audio_sample)0, size); + set_sample_count(samples); + set_spec(spec); +} + +void audio_chunk::set_data(const audio_sample* src, size_t samples, unsigned nch, unsigned srate, unsigned channel_config) +{ + set_data(src, samples, makeSpec(srate, nch, channel_config)); +} + +void audio_chunk::set_data(const audio_sample* src, size_t samples, unsigned nch, unsigned srate) { + + set_data(src, samples, makeSpec(srate, nch)); +} + +inline bool check_exclusive(unsigned val, unsigned mask) +{ + return (val&mask)!=0 && (val&mask)!=mask; +} + +static void _import8u(uint8_t const * in, audio_sample * out, size_t count) { + for(size_t walk = 0; walk < count; ++walk) { + uint32_t i = *(in++); + i -= 0x80; // to signed + *(out++) = (audio_sample) (int32_t) i / (float) 0x80; + } +} + +static void _import8s(uint8_t const * in, audio_sample * out, size_t count) { + for(size_t walk = 0; walk < count; ++walk) { + int32_t i = (int8_t) *(in++); + *(out++) = (audio_sample) i / (float) 0x80; + } +} + +static audio_sample _import24s(uint32_t i) { + i ^= 0x800000; // to unsigned + i -= 0x800000; // and back to signed / fill MSBs proper + return (audio_sample) (int32_t) i / (audio_sample) 0x800000; +} + +static void _import24(const void * in_, audio_sample * out, size_t count) { + const uint8_t * in = (const uint8_t*) in_; +#if 1 + while(count > 0 && !pfc::is_ptr_aligned_t<4>(in)) { + uint32_t i = *(in++); + i |= (uint32_t) *(in++) << 8; + i |= (uint32_t) *(in++) << 16; + *(out++) = _import24s(i); + --count; + } + { + for(size_t loop = count >> 2; loop; --loop) { + uint32_t i1 = * (uint32_t*) in; in += 4; + uint32_t i2 = * (uint32_t*) in; in += 4; + uint32_t i3 = * (uint32_t*) in; in += 4; + *out++ = _import24s( i1 & 0xFFFFFF ); + *out++ = _import24s( (i1 >> 24) | ((i2 & 0xFFFF) << 8) ); + *out++ = _import24s( (i2 >> 16) | ((i3 & 0xFF) << 16) ); + *out++ = _import24s( i3 >> 8 ); + } + count &= 3; + } + for( ; count ; --count) { + uint32_t i = *(in++); + i |= (uint32_t) *(in++) << 8; + i |= (uint32_t) *(in++) << 16; + *(out++) = _import24s(i); + } +#else + if (count > 0) { + int32_t i = *(in++); + i |= (int32_t) *(in++) << 8; + i |= (int32_t) (int8_t) *in << 16; + *out++ = (audio_sample) i / (audio_sample) 0x800000; + --count; + + // Now we have in ptr at offset_of_next - 1 and we can read as int32 then discard the LSBs + for(;count;--count) { + int32_t i = *( int32_t*) in; in += 3; + *out++ = (audio_sample) (i >> 8) / (audio_sample) 0x800000; + } + } +#endif +} + +template static void _import16any(const void * in, audio_sample * out, size_t count) { + uint16_t const * inPtr = (uint16_t const*) in; + const audio_sample factor = 1.0f / (audio_sample) 0x8000; + for(size_t walk = 0; walk < count; ++walk) { + uint16_t v = *inPtr++; + if (byteSwap) v = pfc::byteswap_t(v); + if (!isSigned) v ^= 0x8000; // to signed + *out++ = (audio_sample) (int16_t) v * factor; + } +} + +template static void _import32any(const void * in, audio_sample * out, size_t count) { + uint32_t const * inPtr = (uint32_t const*) in; + const audio_sample factor = 1.0f / (audio_sample) 0x80000000ul; + for(size_t walk = 0; walk < count; ++walk) { + uint32_t v = *inPtr++; + if (byteSwap) v = pfc::byteswap_t(v); + if (!isSigned) v ^= 0x80000000u; // to signed + *out++ = (audio_sample) (int32_t) v * factor; + } +} + +template static void _import24any(const void * in, audio_sample * out, size_t count) { + uint8_t const * inPtr = (uint8_t const*) in; + const audio_sample factor = 1.0f / (audio_sample) 0x800000; + for(size_t walk = 0; walk < count; ++walk) { + uint32_t v; + if (byteSwap) v = (uint32_t) inPtr[2] | ( (uint32_t) inPtr[1] << 8 ) | ( (uint32_t) inPtr[0] << 16 ); + else v = (uint32_t) inPtr[0] | ( (uint32_t) inPtr[1] << 8 ) | ( (uint32_t) inPtr[2] << 16 ); + inPtr += 3; + if (isSigned) v ^= 0x800000; // to unsigned + v -= 0x800000; // then subtract to get proper MSBs + *out++ = (audio_sample) (int32_t) v * factor; + } +} + +void audio_chunk::set_data_fixedpoint_ex(const void * source,t_size size,unsigned srate,unsigned nch,unsigned bps,unsigned flags,unsigned p_channel_config) +{ + PFC_ASSERT( check_exclusive(flags,FLAG_SIGNED|FLAG_UNSIGNED) ); + PFC_ASSERT( check_exclusive(flags,FLAG_LITTLE_ENDIAN|FLAG_BIG_ENDIAN) ); + + bool byteSwap = !!(flags & FLAG_BIG_ENDIAN); + if (pfc::byte_order_is_big_endian) byteSwap = !byteSwap; + + t_size count = size / (bps/8); + set_data_size(count); + audio_sample * buffer = get_data(); + bool isSigned = !!(flags & FLAG_SIGNED); + + switch(bps) + { + case 8: + // byte order irrelevant + if (isSigned) _import8s( (const uint8_t*) source , buffer, count); + else _import8u( (const uint8_t*) source , buffer, count); + break; + case 16: + if (byteSwap) { + if (isSigned) { + _import16any( source, buffer, count ); + } else { + _import16any( source, buffer, count ); + } + } else { + if (isSigned) { + //_import16any( source, buffer, count ); + audio_math::convert_from_int16((const int16_t*)source,count,buffer,1.0); + } else { + _import16any( source, buffer, count); + } + } + break; + case 24: + if (byteSwap) { + if (isSigned) { + _import24any( source, buffer, count ); + } else { + _import24any( source, buffer, count ); + } + } else { + if (isSigned) { + //_import24any( source, buffer, count); + _import24( source, buffer, count); + } else { + _import24any( source, buffer, count); + } + } + break; + case 32: + if (byteSwap) { + if (isSigned) { + _import32any( source, buffer, count ); + } else { + _import32any( source, buffer, count ); + } + } else { + if (isSigned) { + audio_math::convert_from_int32((const int32_t*)source,count,buffer,1.0); + } else { + _import32any( source, buffer, count); + } + } + break; + default: + //unknown size, cant convert + pfc::memset_t(buffer,(audio_sample)0,count); + break; + } + set_sample_count(count/nch); + set_srate(srate); + set_channels(nch,p_channel_config); +} + +void audio_chunk::set_data_fixedpoint_ms(const void * ptr, size_t bytes, unsigned sampleRate, unsigned channels, unsigned bps, unsigned channelConfig) { + //set_data_fixedpoint_ex(ptr,bytes,sampleRate,channels,bps,(bps==8 ? FLAG_UNSIGNED : FLAG_SIGNED) | flags_autoendian(), channelConfig); + PFC_ASSERT( bps != 0 ); + size_t count = bytes / (bps/8); + this->set_data_size( count ); + audio_sample * buffer = this->get_data(); + switch(bps) { + case 8: + _import8u((const uint8_t*)ptr, buffer, count); + break; + case 16: + audio_math::convert_from_int16((const int16_t*) ptr, count, buffer, 1.0); + break; + case 24: + _import24( ptr, buffer, count); + break; + case 32: + audio_math::convert_from_int32((const int32_t*) ptr, count, buffer, 1.0); + break; + default: + PFC_ASSERT(!"Unknown bit depth!"); + memset(buffer, 0, sizeof(audio_sample) * count); + break; + } + set_sample_count(count/channels); + set_srate(sampleRate); + set_channels(channels,channelConfig); +} + +void audio_chunk::set_data_fixedpoint_signed(const void * ptr,t_size bytes,unsigned sampleRate,unsigned channels,unsigned bps,unsigned channelConfig) { + PFC_ASSERT( bps != 0 ); + size_t count = bytes / (bps/8); + this->set_data_size( count ); + audio_sample * buffer = this->get_data(); + switch(bps) { + case 8: + _import8s((const uint8_t*)ptr, buffer, count); + break; + case 16: + audio_math::convert_from_int16((const int16_t*) ptr, count, buffer, 1.0); + break; + case 24: + _import24( ptr, buffer, count); + break; + case 32: + audio_math::convert_from_int32((const int32_t*) ptr, count, buffer, 1.0); + break; + default: + PFC_ASSERT(!"Unknown bit depth!"); + memset(buffer, 0, sizeof(audio_sample) * count); + break; + } + set_sample_count(count/channels); + set_srate(sampleRate); + set_channels(channels,channelConfig); +} + +void audio_chunk::set_data_int16(const int16_t * src,t_size samples,unsigned nch,unsigned srate,unsigned channel_config) { + const size_t count = samples * nch; + this->set_data_size( count ); + audio_sample * buffer = this->get_data(); + audio_math::convert_from_int16(src, count, buffer, 1.0); + set_sample_count(samples); + set_srate(srate); + set_channels(nch,channel_config); +} + +template +static void process_float_multi(audio_sample * p_out,const t_float * p_in,const t_size p_count) +{ + audio_math::convert(p_in, p_out, p_count); +} + +template +static void process_float_multi_swap(audio_sample * p_out,const t_float * p_in,const t_size p_count) +{ + for(size_t n=0;n(ptr),count); + else + process_float_multi(out,reinterpret_cast(ptr),count); + } + else if (bps == 64) + { + if (use_swap) + process_float_multi_swap(out,reinterpret_cast(ptr),count); + else + process_float_multi(out,reinterpret_cast(ptr),count); + } else if (bps == 16) { + const uint16_t * in = reinterpret_cast(ptr); + if (use_swap) { + for(size_t walk = 0; walk < count; ++walk) out[walk] = audio_math::decodeFloat16(pfc::byteswap_t(in[walk])); + } else { + for(size_t walk = 0; walk < count; ++walk) out[walk] = audio_math::decodeFloat16(in[walk]); + } + } else if (bps == 24) { + const uint8_t * in = reinterpret_cast(ptr); + if (use_swap) { + for(size_t walk = 0; walk < count; ++walk) out[walk] = audio_math::decodeFloat24ptrbs(&in[walk*3]); + } else { + for(size_t walk = 0; walk < count; ++walk) out[walk] = audio_math::decodeFloat24ptr(&in[walk*3]); + } + } else pfc::throw_exception_with_message< exception_io_data >("invalid bit depth"); + + set_sample_count(count/nch); + set_srate(srate); + set_channels(nch,p_channel_config); +} + +pfc::string8 audio_chunk::formatChunkSpec() const { + pfc::string8 msg; + msg << get_sample_rate() << " Hz, " << get_channels() << ":0x" << pfc::format_hex(get_channel_config(), 2) << " channels, " << get_sample_count() << " samples"; + return msg; +} + +void audio_chunk::debugChunkSpec() const { + FB2K_DebugLog() << "Chunk: " << this->formatChunkSpec(); +} + +#if PFC_DEBUG +void audio_chunk::assert_valid(const char * ctx) const { + if (!is_valid()) { + FB2K_DebugLog() << "audio_chunk::assert_valid failure in " << ctx; + debugChunkSpec(); + uBugCheck(); + } +} +#endif +bool audio_chunk::is_valid() const +{ + unsigned nch = get_channels(); + if (nch == 0 || nch > 32) return false; + if (!g_is_valid_sample_rate(get_srate())) return false; + t_size samples = get_sample_count(); + if (samples==0 || samples >= 0x80000000ul / (sizeof(audio_sample) * nch) ) return false; + t_size size = get_data_size(); + if (samples * nch > size) return false; + if (!get_data()) return false; + return true; +} + +bool audio_chunk::is_spec_valid() const { + return this->get_spec().is_valid(); +} + +void audio_chunk::pad_with_silence_ex(t_size samples,unsigned hint_nch,unsigned hint_srate) { + if (is_empty()) + { + if (hint_srate && hint_nch) { + return set_data(0,samples,hint_nch,hint_srate); + } else throw exception_io_data(); + } + else + { + if (hint_srate && hint_srate != get_srate()) samples = MulDiv_Size(samples,get_srate(),hint_srate); + if (samples > get_sample_count()) + { + t_size old_size = get_sample_count() * get_channels(); + t_size new_size = samples * get_channels(); + set_data_size(new_size); + pfc::memset_t(get_data() + old_size,(audio_sample)0,new_size - old_size); + set_sample_count(samples); + } + } +} + +void audio_chunk::pad_with_silence(t_size samples) { + if (samples > get_sample_count()) + { + t_size old_size = get_sample_count() * get_channels(); + t_size new_size = pfc::multiply_guarded(samples,(size_t)get_channels()); + set_data_size(new_size); + pfc::memset_t(get_data() + old_size,(audio_sample)0,new_size - old_size); + set_sample_count(samples); + } +} + +void audio_chunk::set_silence(t_size samples) { + t_size items = samples * get_channels(); + set_data_size(items); + pfc::memset_null_t(get_data(), items); + set_sample_count(samples); +} + +void audio_chunk::set_silence_seconds( double seconds ) { + set_silence( (size_t) audio_math::time_to_samples( seconds, this->get_sample_rate() ) ); +} + +void audio_chunk::insert_silence_fromstart(t_size samples) { + t_size old_size = get_sample_count() * get_channels(); + t_size delta = samples * get_channels(); + t_size new_size = old_size + delta; + set_data_size(new_size); + audio_sample * ptr = get_data(); + pfc::memmove_t(ptr+delta,ptr,old_size); + pfc::memset_t(ptr,(audio_sample)0,delta); + set_sample_count(get_sample_count() + samples); +} + +bool audio_chunk::process_skip(double & skipDuration) { + t_uint64 skipSamples = audio_math::time_to_samples(skipDuration, get_sample_rate()); + if (skipSamples == 0) {skipDuration = 0; return true;} + const t_size mySamples = get_sample_count(); + if (skipSamples < mySamples) { + skip_first_samples((t_size)skipSamples); + skipDuration = 0; + return true; + } + if (skipSamples == mySamples) { + skipDuration = 0; + return false; + } + skipDuration -= audio_math::samples_to_time(mySamples, get_sample_rate()); + return false; +} + +t_size audio_chunk::skip_first_samples(t_size samples_delta) +{ + t_size samples_old = get_sample_count(); + if (samples_delta >= samples_old) + { + set_sample_count(0); + set_data_size(0); + return samples_old; + } + else + { + t_size samples_new = samples_old - samples_delta; + unsigned nch = get_channels(); + audio_sample * ptr = get_data(); + pfc::memmove_t(ptr,ptr+nch*samples_delta,nch*samples_new); + set_sample_count(samples_new); + set_data_size(nch*samples_new); + return samples_delta; + } +} + +audio_sample audio_chunk::get_peak(audio_sample p_peak) const { + return pfc::max_t(p_peak, get_peak()); +} + +audio_sample audio_chunk::get_peak() const { + return audio_math::calculate_peak(get_data(),get_sample_count() * get_channels()); +} + +void audio_chunk::scale(audio_sample p_value) +{ + audio_sample * ptr = get_data(); + audio_math::scale(ptr,get_sample_count() * get_channels(),ptr,p_value); +} + + +namespace { + +struct sampleToIntDesc { + unsigned bps, bpsValid; + bool useUpperBits; + audio_sample scale; +}; +template class sampleToInt { +public: + sampleToInt(sampleToIntDesc const & d) { + clipLo = - ( (int_t) 1 << (d.bpsValid-1)); + clipHi = ( (int_t) 1 << (d.bpsValid-1)) - 1; + scale = (float) ( (int64_t) 1 << (d.bpsValid - 1) ) * d.scale; + if (d.useUpperBits) { + shift = (int8_t)( d.bps - d.bpsValid ); + } else { + shift = 0; + } + } + inline int_t operator() (audio_sample s) const { + int_t v; + if constexpr (sizeof(int_t) > 4) v = (int_t) audio_math::rint64( s * scale ); + else v = (int_t)audio_math::rint32( s * scale ); + return pfc::clip_t( v, clipLo, clipHi) << shift; + } +private: + int_t clipLo, clipHi; + int8_t shift; + audio_sample scale; +}; +} +static void render_24bit(const audio_sample * in, t_size inLen, void * out, sampleToIntDesc const & d) { + t_uint8 * outWalk = reinterpret_cast(out); + sampleToInt gen(d); + for(t_size walk = 0; walk < inLen; ++walk) { + int32_t v = gen(in[walk]); + *(outWalk ++) = (t_uint8) (v & 0xFF); + *(outWalk ++) = (t_uint8) ((v >> 8) & 0xFF); + *(outWalk ++) = (t_uint8) ((v >> 16) & 0xFF); + } +} +static void render_8bit(const audio_sample * in, t_size inLen, void * out, sampleToIntDesc const & d) { + sampleToInt gen(d); + t_int8 * outWalk = reinterpret_cast(out); + for(t_size walk = 0; walk < inLen; ++walk) { + *outWalk++ = (t_int8)gen(in[walk]); + } +} +static void render_16bit(const audio_sample * in, t_size inLen, void * out, sampleToIntDesc const & d) { + sampleToInt gen(d); + int16_t * outWalk = reinterpret_cast(out); + for(t_size walk = 0; walk < inLen; ++walk) { + *outWalk++ = (int16_t)gen(in[walk]); + } +} + +template +static void render_32bit_(const audio_sample * in, t_size inLen, void * out, sampleToIntDesc const & d) { + sampleToInt gen(d); // must use int64 for clipping + int32_t * outWalk = reinterpret_cast(out); + for(t_size walk = 0; walk < inLen; ++walk) { + *outWalk++ = (int32_t)gen(in[walk]); + } +} + +bool audio_chunk::g_toFixedPoint(const audio_sample * in, void * out, size_t count, uint32_t bps, uint32_t bpsValid, bool useUpperBits, audio_sample scale) { + const sampleToIntDesc d = {bps, bpsValid, useUpperBits, scale}; + if (bps == 0) { + PFC_ASSERT(!"How did we get here?"); + return false; + } else if (bps <= 8) { + render_8bit(in, count, out, d); + } else if (bps <= 16) { + render_16bit(in, count, out, d); + } else if (bps <= 24) { + render_24bit(in, count, out, d); + } else if (bps <= 32) { + if (bpsValid <= 28) { // for speed + render_32bit_(in, count, out, d); + } else { + render_32bit_(in, count, out, d); + } + } else { + PFC_ASSERT(!"How did we get here?"); + return false; + } + + return true; +} + +bool audio_chunk::toFixedPoint(class mem_block_container & out, uint32_t bps, uint32_t bpsValid, bool useUpperBits, audio_sample scale) const { + bps = (bps + 7) & ~7; + if (bps < bpsValid) return false; + const size_t count = get_sample_count() * get_channel_count(); + out.set_size( count * (bps/8) ); + return g_toFixedPoint(get_data(), out.get_ptr(), count, bps, bpsValid, useUpperBits, scale); +} + +bool audio_chunk::to_raw_data(mem_block_container & out, t_uint32 bps, bool useUpperBits, audio_sample scale) const { + uint32_t bpsValid = bps; + bps = (bps + 7) & ~7; + const size_t count = get_sample_count() * get_channel_count(); + out.set_size( count * (bps/8) ); + void * outPtr = out.get_ptr(); + audio_sample const * inPtr = get_data(); + if (bps == 32) { + float * f = (float*) outPtr; + audio_math::convert(inPtr, f, count, scale); + return true; + } else { + return g_toFixedPoint(inPtr, outPtr, count, bps, bpsValid, useUpperBits, scale); + } +} + +audio_chunk::spec_t audio_chunk::makeSpec(uint32_t rate, uint32_t channels) { + return makeSpec( rate, channels, g_guess_channel_config(channels) ); +} + +audio_chunk::spec_t audio_chunk::makeSpec(uint32_t rate, uint32_t channels, uint32_t mask) { + PFC_ASSERT(mask == 0 || pfc::countBits32(mask) == channels); + spec_t spec = {}; + spec.sampleRate = rate; spec.chanCount = channels; spec.chanMask = mask; + return spec; +} + +bool audio_chunk::spec_t::equals( const spec_t & v1, const spec_t & v2 ) { + return v1.sampleRate == v2.sampleRate && v1.chanCount == v2.chanCount && v1.chanMask == v2.chanMask; +} + +pfc::string8 audio_chunk::spec_t::toString(const char * delim) const { + pfc::string_formatter temp; + if ( sampleRate > 0 ) temp << sampleRate << "Hz"; + if (chanCount > 0) { + if ( temp.length() > 0 ) temp << delim; + temp << chanCount << "ch"; + } + + if ( chanMask != audio_chunk::channel_config_mono && chanMask != audio_chunk::channel_config_stereo ) { + pfc::string8 strMask; + audio_chunk::g_formatChannelMaskDesc( chanMask, strMask ); + if ( temp.length() > 0) temp << delim; + temp << strMask; + } + return temp; +} + +audio_chunk::spec_t audio_chunk::get_spec() const { + spec_t spec = {}; + spec.sampleRate = this->get_sample_rate(); + spec.chanCount = this->get_channel_count(); + spec.chanMask = this->get_channel_config(); + return spec; +} +void audio_chunk::set_spec(const spec_t & spec) { + set_sample_rate(spec.sampleRate); + set_channels( spec.chanCount, spec.chanMask ); +} + +bool audio_chunk::spec_t::is_valid() const { + if (this->chanCount==0 || this->chanCount>256) return false; + if (!audio_chunk::g_is_valid_sample_rate(this->sampleRate)) return false; + return true; +} + +#ifdef _WIN32 + +WAVEFORMATEX audio_chunk::spec_t::toWFX() const { + const uint32_t sampleWidth = sizeof(audio_sample); + + WAVEFORMATEX wfx = {}; + wfx.wFormatTag = WAVE_FORMAT_IEEE_FLOAT; + wfx.nChannels = (WORD) chanCount; + wfx.nSamplesPerSec = sampleRate; + wfx.nAvgBytesPerSec = sampleRate * chanCount * sampleWidth; + wfx.nBlockAlign = (WORD)( chanCount * sampleWidth ); + wfx.wBitsPerSample = sampleWidth * 8; + return wfx; +} + +WAVEFORMATEXTENSIBLE audio_chunk::spec_t::toWFXEX() const { + const uint32_t sampleWidth = sizeof(audio_sample); + const bool isFloat = true; + + WAVEFORMATEXTENSIBLE wfxe; + wfxe.Format = toWFX(); + wfxe.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE; + wfxe.Format.cbSize = sizeof(wfxe) - sizeof(wfxe.Format); + wfxe.Samples.wValidBitsPerSample = sampleWidth * 8; + wfxe.dwChannelMask = audio_chunk::g_channel_config_to_wfx(this->chanMask); + wfxe.SubFormat = isFloat ? KSDATAFORMAT_SUBTYPE_IEEE_FLOAT : KSDATAFORMAT_SUBTYPE_PCM; + + return wfxe; +} + +WAVEFORMATEX audio_chunk::spec_t::toWFXWithBPS(uint32_t bps) const { + const uint32_t sampleWidth = (bps+7)/8; + + WAVEFORMATEX wfx = {}; + wfx.wFormatTag = WAVE_FORMAT_PCM; + wfx.nChannels = (WORD)chanCount; + wfx.nSamplesPerSec = sampleRate; + wfx.nAvgBytesPerSec = sampleRate * chanCount * sampleWidth; + wfx.nBlockAlign = (WORD)( chanCount * sampleWidth ); + wfx.wBitsPerSample = (WORD)( sampleWidth * 8 ); + return wfx; +} + +WAVEFORMATEXTENSIBLE audio_chunk::spec_t::toWFXEXWithBPS(uint32_t bps) const { + const uint32_t sampleWidth = (bps + 7) / 8; + const bool isFloat = false; + + WAVEFORMATEXTENSIBLE wfxe; + wfxe.Format = toWFXWithBPS(bps); + wfxe.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE; + wfxe.Format.cbSize = sizeof(wfxe) - sizeof(wfxe.Format); + wfxe.Samples.wValidBitsPerSample = (WORD)( sampleWidth * 8 ); + wfxe.dwChannelMask = audio_chunk::g_channel_config_to_wfx(this->chanMask); + wfxe.SubFormat = isFloat ? KSDATAFORMAT_SUBTYPE_IEEE_FLOAT : KSDATAFORMAT_SUBTYPE_PCM; + + return wfxe; +} +#endif // _WIN32 + +void audio_chunk::append(const audio_chunk& other) { + if (other.get_spec() != this->get_spec()) { + throw pfc::exception_invalid_params(); + } + + this->grow_data_size(get_used_size() + other.get_used_size()); + audio_sample* p = this->get_data() + get_used_size(); + memcpy(p, other.get_data(), other.get_used_size() * sizeof(audio_sample)); + set_sample_count(get_sample_count() + other.get_sample_count()); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/audio_chunk.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/audio_chunk.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,395 @@ +#pragma once + +#include +#include +#include "exception_io.h" + +#ifdef _WIN32 +#include +#endif +//! Thrown when audio_chunk sample rate or channel mapping changes in mid-stream and the code receiving audio_chunks can't deal with that scenario. +PFC_DECLARE_EXCEPTION(exception_unexpected_audio_format_change, exception_io_data, "Unexpected audio format change" ); + +//! Interface to container of a chunk of audio data. See audio_chunk_impl for an implementation. +class NOVTABLE audio_chunk { +public: + struct spec_t; // forward decl + + enum { + sample_rate_min = 1000, sample_rate_max = 20000000 + }; + static bool g_is_valid_sample_rate(t_uint32 p_val) {return p_val >= sample_rate_min && p_val <= sample_rate_max;} + + //! Channel map flag declarations. Note that order of interleaved channel data in the stream is same as order of these flags. + enum + { + channel_front_left = 1<<0, + channel_front_right = 1<<1, + channel_front_center = 1<<2, + channel_lfe = 1<<3, + channel_back_left = 1<<4, + channel_back_right = 1<<5, + channel_front_center_left = 1<<6, + channel_front_center_right = 1<<7, + channel_back_center = 1<<8, + channel_side_left = 1<<9, + channel_side_right = 1<<10, + channel_top_center = 1<<11, + channel_top_front_left = 1<<12, + channel_top_front_center = 1<<13, + channel_top_front_right = 1<<14, + channel_top_back_left = 1<<15, + channel_top_back_center = 1<<16, + channel_top_back_right = 1<<17, + + channels_back_left_right = channel_back_left | channel_back_right, + channels_side_left_right = channel_side_left | channel_side_right, + + channel_config_mono = channel_front_center, + channel_config_stereo = channel_front_left | channel_front_right, + channel_config_2point1 = channel_config_stereo | channel_lfe, + channel_config_3point0 = channel_config_stereo | channel_front_center, + channel_config_4point0 = channel_config_stereo | channels_back_left_right, + channel_config_4point0_side = channel_config_stereo | channels_side_left_right, + channel_config_4point1 = channel_config_4point0 | channel_lfe, + channel_config_5point0 = channel_config_4point0 | channel_front_center, + channel_config_6point0 = channel_config_4point0 | channels_side_left_right, + channel_config_5point1 = channel_config_4point0 | channel_front_center | channel_lfe, + channel_config_5point1_side = channel_config_4point0_side | channel_front_center | channel_lfe, + channel_config_7point1 = channel_config_5point1 | channels_side_left_right, + + + defined_channel_count = 18, + }; + + //! Helper function; guesses default channel map for the specified channel count. Returns 0 on failure. + static unsigned g_guess_channel_config(unsigned count); + //! Helper function; determines channel map for the specified channel count according to Xiph specs. Throws exception_io_data on failure. + static unsigned g_guess_channel_config_xiph(unsigned count); + + //! Helper function; translates audio_chunk channel map to WAVEFORMATEXTENSIBLE channel map. + static constexpr uint32_t g_channel_config_to_wfx(unsigned p_config) { return p_config;} + //! Helper function; translates WAVEFORMATEXTENSIBLE channel map to audio_chunk channel map. + static constexpr unsigned g_channel_config_from_wfx(uint32_t p_wfx) { return p_wfx;} + + //! Extracts flag describing Nth channel from specified map. Usable to figure what specific channel in a stream means. + static unsigned g_extract_channel_flag(unsigned p_config,unsigned p_index); + //! Counts channels specified by channel map. + static constexpr unsigned g_count_channels(unsigned p_config) { return pfc::countBits32(p_config); } + //! Calculates index of a channel specified by p_flag in a stream where channel map is described by p_config. + static unsigned g_channel_index_from_flag(unsigned p_config,unsigned p_flag); + + static const char * g_channel_name(unsigned p_flag); + static const char * g_channel_name_byidx(unsigned p_index); + static unsigned g_find_channel_idx(unsigned p_flag); + static void g_formatChannelMaskDesc(unsigned flags, pfc::string_base & out); + static pfc::string8 g_formatChannelMaskDesc(unsigned flags); + static const char* g_channelMaskName(unsigned flags); + + + + //! Retrieves audio data buffer pointer (non-const version). Returned pointer is for temporary use only; it is valid until next set_data_size call, or until the object is destroyed. \n + //! Size of returned buffer is equal to get_data_size() return value (in audio_samples). Amount of actual data may be smaller, depending on sample count and channel count. Conditions where sample count * channel count are greater than data size should not be possible. + virtual audio_sample * get_data() = 0; + //! Retrieves audio data buffer pointer (const version). Returned pointer is for temporary use only; it is valid until next set_data_size call, or until the object is destroyed. \n + //! Size of returned buffer is equal to get_data_size() return value (in audio_samples). Amount of actual data may be smaller, depending on sample count and channel count. Conditions where sample count * channel count are greater than data size should not be possible. + virtual const audio_sample * get_data() const = 0; + //! Retrieves size of allocated buffer space, in audio_samples. + virtual t_size get_data_size() const = 0; + //! Resizes audio data buffer to specified size. Throws std::bad_alloc on failure. + virtual void set_data_size(t_size p_new_size) = 0; + //! Sanity helper, same as set_data_size. + //! @param bQuicker Avoid memory allocation, permit up to 2x memory used + void allocate(size_t size, bool bQuicker = false); + + //! Retrieves sample rate of contained audio data. + virtual unsigned get_srate() const = 0; + //! Sets sample rate of contained audio data. + virtual void set_srate(unsigned val) = 0; + //! Retrieves channel count of contained audio data. + virtual unsigned get_channels() const = 0; + //! Helper - for consistency - same as get_channels(). + inline unsigned get_channel_count() const {return get_channels();} + //! Retrieves channel map of contained audio data. Conditions where number of channels specified by channel map don't match get_channels() return value should not be possible. + virtual unsigned get_channel_config() const = 0; + //! Sets channel count / channel map. + virtual void set_channels(unsigned p_count,unsigned p_config) = 0; + + //! Retrieves number of valid samples in the buffer. \n + //! Note that a "sample" means a unit of interleaved PCM data representing states of each channel at given point of time, not a single PCM value. \n + //! For an example, duration of contained audio data is equal to sample count / sample rate, while actual size of contained data is equal to sample count * channel count. + virtual t_size get_sample_count() const = 0; + + //! Sets number of valid samples in the buffer. WARNING: sample count * channel count should never be above allocated buffer size. + virtual void set_sample_count(t_size val) = 0; + + //! Helper, same as get_srate(). + inline unsigned get_sample_rate() const {return get_srate();} + //! Helper, same as set_srate(). + inline void set_sample_rate(unsigned val) {set_srate(val);} + + //! Helper; sets channel count to specified value and uses default channel map for this channel count. + void set_channels(unsigned val) {set_channels(val,g_guess_channel_config(val));} + + + //! Helper; resizes audio data buffer when its current size is smaller than requested. + inline void grow_data_size(t_size p_requested) {if (p_requested > get_data_size()) set_data_size(p_requested);} + + + //! Retrieves duration of contained audio data, in seconds. + inline double get_duration() const + { + double rv = 0; + t_size srate = get_srate (), samples = get_sample_count(); + if (srate>0 && samples>0) rv = (double)samples/(double)srate; + return rv; + } + + //! Returns whether the chunk is empty (contains no audio data). + inline bool is_empty() const {return get_channels()==0 || get_srate()==0 || get_sample_count()==0;} + + //! Returns whether the chunk contents are valid (for bug check purposes). + bool is_valid() const; + + void debugChunkSpec() const; + pfc::string8 formatChunkSpec() const; +#if PFC_DEBUG + void assert_valid(const char * ctx) const; +#else + void assert_valid(const char* ctx) const { (void)ctx; } +#endif + + + //! Returns whether the chunk contains valid sample rate & channel info (but allows an empty chunk). + bool is_spec_valid() const; + + //! Returns actual amount of audio data contained in the buffer (sample count * channel count). Must not be greater than data size (see get_data_size()). + size_t get_used_size() const {return get_sample_count() * get_channels();} + //! Same as get_used_size(); old confusingly named version. + size_t get_data_length() const {return get_sample_count() * get_channels();} + + //! Resets all audio_chunk data. + inline void reset() { + set_sample_count(0); + set_srate(0); + set_channels(0,0); + set_data_size(0); + } + + //! Helper, sets chunk data to contents of specified buffer, with specified number of channels / sample rate / channel map. + void set_data(const audio_sample * src,size_t samples,unsigned nch,unsigned srate,unsigned channel_config); + void set_data(const audio_sample* src, size_t samples, spec_t const& spec, bool bQucker = false); + void set_data(const audio_sample* src, t_size samples, unsigned nch, unsigned srate); + + void set_data_int16(const int16_t * src,t_size samples,unsigned nch,unsigned srate,unsigned channel_config); + + //! Helper, sets chunk data to contents of specified buffer, using default win32/wav conventions for signed/unsigned switch. + inline void set_data_fixedpoint(const void * ptr,t_size bytes,unsigned srate,unsigned nch,unsigned bps,unsigned channel_config) { + this->set_data_fixedpoint_ms(ptr, bytes, srate, nch, bps, channel_config); + } + + void set_data_fixedpoint_signed(const void * ptr,t_size bytes,unsigned srate,unsigned nch,unsigned bps,unsigned channel_config); + + enum + { + FLAG_LITTLE_ENDIAN = 1, + FLAG_BIG_ENDIAN = 2, + FLAG_SIGNED = 4, + FLAG_UNSIGNED = 8, + }; + + inline static unsigned flags_autoendian() { + return pfc::byte_order_is_big_endian ? FLAG_BIG_ENDIAN : FLAG_LITTLE_ENDIAN; + } + + void set_data_fixedpoint_ex(const void * ptr,t_size bytes,unsigned p_sample_rate,unsigned p_channels,unsigned p_bits_per_sample,unsigned p_flags,unsigned p_channel_config);//p_flags - see FLAG_* above + + void set_data_fixedpoint_ms(const void * ptr, size_t bytes, unsigned sampleRate, unsigned channels, unsigned bps, unsigned channelConfig); + + void set_data_floatingpoint_ex(const void * ptr,t_size bytes,unsigned p_sample_rate,unsigned p_channels,unsigned p_bits_per_sample,unsigned p_flags,unsigned p_channel_config);//signed/unsigned flags dont apply + static bool is_supported_floatingpoint(unsigned bps) { return bps == 32 || bps == 64 || bps == 16 || bps == 24; } + + void set_data_32(const float* src, t_size samples, unsigned nch, unsigned srate); + void set_data_32(const float* src, t_size samples, spec_t const & spec ); + + //! Appends silent samples at the end of the chunk. \n + //! The chunk may be empty prior to this call, its sample rate & channel count will be set to the specified values then. \n + //! The chunk may have different sample rate than requested; silent sample count will be recalculated to the used sample rate retaining actual duration. + //! @param samples Number of silent samples to append. + //! @param hint_nch If no channel count is set on this chunk, it will be set to this value. + //! @param hint_srate The sample rate of silent samples being inserted. If no sampler ate is set on this chunk, it will be set to this value.\n + //! Otherwise if chunk's sample rate doesn't match hint_srate, sample count will be recalculated to chunk's actual sample rate. + void pad_with_silence_ex(t_size samples,unsigned hint_nch,unsigned hint_srate); + //! Appends silent samples at the end of the chunk. \n + //! The chunk must have valid sample rate & channel count prior to this call. + //! @param samples Number of silent samples to append. + void pad_with_silence(t_size samples); + //! Inserts silence at the beginning of the audio chunk. + //! @param samples Number of silent samples to insert. + void insert_silence_fromstart(t_size samples); + //! Helper; removes N first samples from the chunk. \n + //! If the chunk contains fewer samples than requested, it becomes empty. + //! @returns Number of samples actually removed. + t_size skip_first_samples(t_size samples); + //! Produces a chunk of silence, with the specified duration. \n + //! Any existing audio sdata will be discarded. \n + //! Expects sample rate and channel count to be set first. \n + //! Also allocates memory for the requested amount of data see: set_data_size(). + //! @param samples Desired number of samples. + void set_silence(t_size samples); + //! Produces a chunk of silence, with the specified duration. \n + //! Any existing audio sdata will be discarded. \n + //! Expects sample rate and channel count to be set first. \n + //! Also allocates memory for the requested amount of data see: set_data_size(). + //! @param seconds Desired duration in seconds. + void set_silence_seconds( double seconds ); + + //! Helper; skips first samples of the chunk updating a remaining to-skip counter. + //! @param skipDuration Reference to the duration of audio remining to be skipped, in seconds. Updated by each call. + //! @returns False if the chunk became empty, true otherwise. + bool process_skip(double & skipDuration); + + //! Simple function to get original PCM stream back. Assumes host's endianness, integers are signed - including the 8bit mode; 32bit mode assumed to be float. + //! @returns false when the conversion could not be performed because of unsupported bit depth etc. + bool to_raw_data(class mem_block_container & out, t_uint32 bps, bool useUpperBits = true, audio_sample scale = 1.0) const; + + //! Convert audio_chunk contents to fixed-point PCM format. + //! @param useUpperBits relevant if bps != bpsValid, signals whether upper or lower bits of each sample should be used. + bool toFixedPoint(class mem_block_container & out, uint32_t bps, uint32_t bpsValid, bool useUpperBits = true, audio_sample scale = 1.0) const; + + //! Convert a buffer of audio_samples to fixed-point PCM format. + //! @param useUpperBits relevant if bps != bpsValid, signals whether upper or lower bits of each sample should be used. + static bool g_toFixedPoint(const audio_sample * in, void * out, size_t count, uint32_t bps, uint32_t bpsValid, bool useUpperBits = true, audio_sample scale = 1.0); + + + //! Helper, calculates peak value of data in the chunk. The optional parameter specifies initial peak value, to simplify calling code. + audio_sample get_peak(audio_sample p_peak) const; + audio_sample get_peak() const; + + //! Helper function; scales entire chunk content by specified value. + void scale(audio_sample p_value); + + //! Helper; copies content of another audio chunk to this chunk. + //! @param bQuicker Avoid memory allocation, permit up to 2x memory used + void copy(const audio_chunk & p_source, bool bQuicker = false) { + set_data(p_source.get_data(),p_source.get_sample_count(),p_source.get_spec(), bQuicker); + } + + const audio_chunk & operator=(const audio_chunk & p_source) { + copy(p_source); + return *this; + } + + struct spec_t { + uint32_t sampleRate = 0; + uint32_t chanCount = 0, chanMask = 0; + + static bool equals( const spec_t & v1, const spec_t & v2 ); + bool operator==(const spec_t & other) const { return equals(*this, other);} + bool operator!=(const spec_t & other) const { return !equals(*this, other);} + bool is_valid() const; + void clear() { sampleRate = 0; chanCount = 0; chanMask = 0; } + +#ifdef _WIN32 + //! Creates WAVE_FORMAT_IEEE_FLOAT WAVEFORMATEX structure + WAVEFORMATEX toWFX() const; + //! Creates WAVE_FORMAT_IEEE_FLOAT WAVEFORMATEXTENSIBLE structure + WAVEFORMATEXTENSIBLE toWFXEX() const; + //! Creates WAVE_FORMAT_PCM WAVEFORMATEX structure + WAVEFORMATEX toWFXWithBPS(uint32_t bps) const; + //! Creates WAVE_FORMAT_PCM WAVEFORMATEXTENSIBLE structure + WAVEFORMATEXTENSIBLE toWFXEXWithBPS(uint32_t bps) const; +#endif + + pfc::string8 toString( const char * delim = " " ) const; + }; + static spec_t makeSpec(uint32_t rate, uint32_t channels); + static spec_t makeSpec(uint32_t rate, uint32_t channels, uint32_t chanMask); + static spec_t emptySpec() { return makeSpec(0, 0, 0); } + + spec_t get_spec() const; + void set_spec(const spec_t &); + + void append(const audio_chunk& other); +protected: + audio_chunk() {} + ~audio_chunk() {} +}; + +//! Implementation of audio_chunk. Takes pfc allocator template as template parameter. +template > +class audio_chunk_impl_t : public audio_chunk { + typedef audio_chunk_impl_t t_self; + container_t m_data; + unsigned m_srate = 0, m_nch = 0, m_setup = 0; + t_size m_samples = 0; + +public: + audio_chunk_impl_t() {} + audio_chunk_impl_t(const audio_sample * src,unsigned samples,unsigned nch,unsigned srate) {set_data(src,samples,nch,srate);} + audio_chunk_impl_t(const audio_chunk & p_source) {copy(p_source);} + + + virtual audio_sample * get_data() {return m_data.get_ptr();} + virtual const audio_sample * get_data() const {return m_data.get_ptr();} + virtual t_size get_data_size() const {return m_data.get_size();} + virtual void set_data_size(t_size new_size) {m_data.set_size(new_size);} + + virtual unsigned get_srate() const {return m_srate;} + virtual void set_srate(unsigned val) {m_srate=val;} + virtual unsigned get_channels() const {return m_nch;} + virtual unsigned get_channel_config() const {return m_setup;} + virtual void set_channels(unsigned val,unsigned setup) {m_nch = val;m_setup = setup;} + void set_channels(unsigned val) {set_channels(val,g_guess_channel_config(val));} + + virtual t_size get_sample_count() const {return m_samples;} + virtual void set_sample_count(t_size val) {m_samples = val;} + + const t_self & operator=(const audio_chunk & p_source) {copy(p_source);return *this;} +}; + +typedef audio_chunk_impl_t<> audio_chunk_impl; +typedef audio_chunk_impl_t > audio_chunk_fast_impl; + +//! Implements const methods of audio_chunk only, referring to an external buffer. For temporary use only (does not maintain own storage), e.g.: somefunc( audio_chunk_temp_impl(mybuffer,....) ); +class audio_chunk_memref_impl : public audio_chunk { +public: + audio_chunk_memref_impl(const audio_sample * p_data,t_size p_samples,t_uint32 p_sample_rate,t_uint32 p_channels,t_uint32 p_channel_config) : + m_samples(p_samples), m_sample_rate(p_sample_rate), m_channels(p_channels), m_channel_config(p_channel_config), m_data(p_data) + { +#if PFC_DEBUG + assert_valid(__FUNCTION__); +#endif + } + + audio_sample * get_data() {throw pfc::exception_not_implemented();} + const audio_sample * get_data() const {return m_data;} + t_size get_data_size() const {return m_samples * m_channels;} + void set_data_size(t_size) {throw pfc::exception_not_implemented();} + + unsigned get_srate() const {return m_sample_rate;} + void set_srate(unsigned) {throw pfc::exception_not_implemented();} + unsigned get_channels() const {return m_channels;} + unsigned get_channel_config() const {return m_channel_config;} + void set_channels(unsigned,unsigned) {throw pfc::exception_not_implemented();} + + t_size get_sample_count() const {return m_samples;} + + void set_sample_count(t_size) {throw pfc::exception_not_implemented();} + +private: + t_size m_samples; + t_uint32 m_sample_rate,m_channels,m_channel_config; + const audio_sample * m_data; +}; + + +// Compatibility typedefs. +typedef audio_chunk_fast_impl audio_chunk_impl_temporary; +typedef audio_chunk_impl audio_chunk_i; +typedef audio_chunk_memref_impl audio_chunk_temp_impl; + +class audio_chunk_partial_ref : public audio_chunk_temp_impl { +public: + audio_chunk_partial_ref(const audio_chunk & chunk, t_size base, t_size count) : audio_chunk_temp_impl(chunk.get_data() + base * chunk.get_channels(), count, chunk.get_sample_rate(), chunk.get_channels(), chunk.get_channel_config()) {} +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/audio_chunk_channel_config.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/audio_chunk_channel_config.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,233 @@ +#include "foobar2000-sdk-pch.h" +#include "audio_chunk.h" + +#ifdef _WIN32 +#include +#include + +#if 0 +#define SPEAKER_FRONT_LEFT 0x1 +#define SPEAKER_FRONT_RIGHT 0x2 +#define SPEAKER_FRONT_CENTER 0x4 +#define SPEAKER_LOW_FREQUENCY 0x8 +#define SPEAKER_BACK_LEFT 0x10 +#define SPEAKER_BACK_RIGHT 0x20 +#define SPEAKER_FRONT_LEFT_OF_CENTER 0x40 +#define SPEAKER_FRONT_RIGHT_OF_CENTER 0x80 +#define SPEAKER_BACK_CENTER 0x100 +#define SPEAKER_SIDE_LEFT 0x200 +#define SPEAKER_SIDE_RIGHT 0x400 +#define SPEAKER_TOP_CENTER 0x800 +#define SPEAKER_TOP_FRONT_LEFT 0x1000 +#define SPEAKER_TOP_FRONT_CENTER 0x2000 +#define SPEAKER_TOP_FRONT_RIGHT 0x4000 +#define SPEAKER_TOP_BACK_LEFT 0x8000 +#define SPEAKER_TOP_BACK_CENTER 0x10000 +#define SPEAKER_TOP_BACK_RIGHT 0x20000 + +static struct {DWORD m_wfx; unsigned m_native; } const g_translation_table[] = +{ + {SPEAKER_FRONT_LEFT, audio_chunk::channel_front_left}, + {SPEAKER_FRONT_RIGHT, audio_chunk::channel_front_right}, + {SPEAKER_FRONT_CENTER, audio_chunk::channel_front_center}, + {SPEAKER_LOW_FREQUENCY, audio_chunk::channel_lfe}, + {SPEAKER_BACK_LEFT, audio_chunk::channel_back_left}, + {SPEAKER_BACK_RIGHT, audio_chunk::channel_back_right}, + {SPEAKER_FRONT_LEFT_OF_CENTER, audio_chunk::channel_front_center_left}, + {SPEAKER_FRONT_RIGHT_OF_CENTER, audio_chunk::channel_front_center_right}, + {SPEAKER_BACK_CENTER, audio_chunk::channel_back_center}, + {SPEAKER_SIDE_LEFT, audio_chunk::channel_side_left}, + {SPEAKER_SIDE_RIGHT, audio_chunk::channel_side_right}, + {SPEAKER_TOP_CENTER, audio_chunk::channel_top_center}, + {SPEAKER_TOP_FRONT_LEFT, audio_chunk::channel_top_front_left}, + {SPEAKER_TOP_FRONT_CENTER, audio_chunk::channel_top_front_center}, + {SPEAKER_TOP_FRONT_RIGHT, audio_chunk::channel_top_front_right}, + {SPEAKER_TOP_BACK_LEFT, audio_chunk::channel_top_back_left}, + {SPEAKER_TOP_BACK_CENTER, audio_chunk::channel_top_back_center}, + {SPEAKER_TOP_BACK_RIGHT, audio_chunk::channel_top_back_right}, +}; + +#endif +#endif + + + +static constexpr unsigned g_audio_channel_config_table[] = +{ + 0, + audio_chunk::channel_config_mono, + audio_chunk::channel_config_stereo, + audio_chunk::channel_front_left | audio_chunk::channel_front_right | audio_chunk::channel_lfe, + audio_chunk::channel_front_left | audio_chunk::channel_front_right | audio_chunk::channel_back_left | audio_chunk::channel_back_right, + audio_chunk::channel_front_left | audio_chunk::channel_front_right | audio_chunk::channel_back_left | audio_chunk::channel_back_right | audio_chunk::channel_lfe, + audio_chunk::channel_config_5point1, + audio_chunk::channel_config_5point1_side | audio_chunk::channel_back_center, + audio_chunk::channel_config_7point1, + 0, + audio_chunk::channel_config_7point1 | audio_chunk::channel_front_center_right | audio_chunk::channel_front_center_left, +}; + +unsigned audio_chunk::g_guess_channel_config(unsigned count) +{ + if (count == 0) return 0; + if (count > 32) throw exception_io_data(); + unsigned ret = 0; + if (count < PFC_TABSIZE(g_audio_channel_config_table)) ret = g_audio_channel_config_table[count]; + if (ret == 0) { + // Warning: 1u<<32u behaves stupidly + ret = (unsigned)( (1ull << count) - 1 ); + } + PFC_ASSERT(g_count_channels(ret) == count); + return ret; +} + +unsigned audio_chunk::g_guess_channel_config_xiph(unsigned count) { + switch (count) { + case 3: + return audio_chunk::channel_front_left | audio_chunk::channel_front_center | audio_chunk::channel_front_right; + case 5: + return audio_chunk::channel_front_left | audio_chunk::channel_front_center | audio_chunk::channel_front_right | audio_chunk::channel_back_left | audio_chunk::channel_back_right; + case 7: + return audio_chunk::channel_config_5point1 | audio_chunk::channel_back_center; + default: + return g_guess_channel_config(count); + } +} + +unsigned audio_chunk::g_channel_index_from_flag(unsigned p_config,unsigned p_flag) { + if (p_config & p_flag) { + unsigned index = 0; + + for (unsigned walk = 0; walk < 32; walk++) { + unsigned query = 1 << walk; + if (p_flag & query) return index; + if (p_config & query) index++; + } + } + return (unsigned)(-1); +} + +unsigned audio_chunk::g_extract_channel_flag(unsigned p_config,unsigned p_index) +{ + unsigned toskip = p_index; + unsigned flag = 1; + while(flag) + { + if (p_config & flag) + { + if (toskip == 0) break; + toskip--; + } + flag <<= 1; + } + return flag; +} + + +static const char * const chanNames[] = { + "FL", //channel_front_left = 1<<0, + "FR", //channel_front_right = 1<<1, + "FC", //channel_front_center = 1<<2, + "LFE", //channel_lfe = 1<<3, + "BL", //channel_back_left = 1<<4, + "BR", //channel_back_right = 1<<5, + "FCL", //channel_front_center_left = 1<<6, + "FCR", //channel_front_center_right = 1<<7, + "BC", //channel_back_center = 1<<8, + "SL", //channel_side_left = 1<<9, + "SR", //channel_side_right = 1<<10, + "TC", //channel_top_center = 1<<11, + "TFL", //channel_top_front_left = 1<<12, + "TFC", //channel_top_front_center = 1<<13, + "TFR", //channel_top_front_right = 1<<14, + "TBL", //channel_top_back_left = 1<<15, + "TBC", //channel_top_back_center = 1<<16, + "TBR", //channel_top_back_right = 1<<17, +}; + +unsigned audio_chunk::g_find_channel_idx(unsigned p_flag) { + unsigned rv = 0; + if ((p_flag & 0xFFFF) == 0) { + rv += 16; p_flag >>= 16; + } + if ((p_flag & 0xFF) == 0) { + rv += 8; p_flag >>= 8; + } + if ((p_flag & 0xF) == 0) { + rv += 4; p_flag >>= 4; + } + if ((p_flag & 0x3) == 0) { + rv += 2; p_flag >>= 2; + } + if ((p_flag & 0x1) == 0) { + rv += 1; p_flag >>= 1; + } + PFC_ASSERT( p_flag & 1 ); + return rv; +} + +const char * audio_chunk::g_channel_name(unsigned p_flag) { + return g_channel_name_byidx(g_find_channel_idx(p_flag)); +} + +const char * audio_chunk::g_channel_name_byidx(unsigned p_index) { + if (p_index < PFC_TABSIZE(chanNames)) return chanNames[p_index]; + else return "?"; +} + +pfc::string8 audio_chunk::g_formatChannelMaskDesc(unsigned flags) { + pfc::string8 temp; g_formatChannelMaskDesc(flags, temp); return temp; +} +void audio_chunk::g_formatChannelMaskDesc(unsigned flags, pfc::string_base & out) { + out.reset(); + unsigned idx = 0; + while(flags) { + if (flags & 1) { + if (!out.is_empty()) out << " "; + out << g_channel_name_byidx(idx); + } + flags >>= 1; + ++idx; + } +} + +namespace { + struct maskDesc_t { + const char* name; + unsigned mask; + }; + static constexpr maskDesc_t maskDesc[] = { + {"mono", audio_chunk::channel_config_mono}, + {"stereo", audio_chunk::channel_config_stereo}, + {"stereo (rear)", audio_chunk::channel_back_left | audio_chunk::channel_back_right}, + {"stereo (side)", audio_chunk::channel_side_left | audio_chunk::channel_side_right}, + {"2.1", audio_chunk::channel_config_2point1}, + {"3.0", audio_chunk::channel_config_3point0}, + {"4.0", audio_chunk::channel_config_4point0}, + {"4.1", audio_chunk::channel_config_4point1}, + {"5.0", audio_chunk::channel_config_5point0}, + {"5.1", audio_chunk::channel_config_5point1}, + {"5.1 (side)", audio_chunk::channel_config_5point1_side}, + {"6.1", audio_chunk::channel_config_5point1 | audio_chunk::channel_back_center}, + {"6.1 (side)", audio_chunk::channel_config_5point1_side | audio_chunk::channel_back_center}, + {"7.1", audio_chunk::channel_config_7point1}, + }; +} + +const char* audio_chunk::g_channelMaskName(unsigned flags) { + for (auto& walk : maskDesc) { + if (flags == walk.mask) return walk.name; + } + return nullptr; +} + +static_assert( pfc::countBits32(audio_chunk::channel_config_mono) == 1 ); +static_assert( pfc::countBits32(audio_chunk::channel_config_stereo) == 2 ); +static_assert( pfc::countBits32(audio_chunk::channel_config_4point0) == 4 ); +static_assert( pfc::countBits32(audio_chunk::channel_config_4point0_side) == 4 ); +static_assert( pfc::countBits32(audio_chunk::channel_config_4point1) == 5 ); +static_assert( pfc::countBits32(audio_chunk::channel_config_5point0) == 5 ); +static_assert( pfc::countBits32(audio_chunk::channel_config_5point1) == 6 ); +static_assert( pfc::countBits32(audio_chunk::channel_config_5point1_side) == 6 ); +static_assert( pfc::countBits32(audio_chunk::channel_config_6point0) == 6); +static_assert( pfc::countBits32(audio_chunk::channel_config_7point1) == 8 ); diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/audio_chunk_impl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/audio_chunk_impl.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,3 @@ +#pragma once + +// header added for fb2k mobile compatibility \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/audio_postprocessor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/audio_postprocessor.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,29 @@ +#pragma once + +#include "audio_chunk.h" +#include "mem_block_container.h" + +//! This class handles conversion of audio data (audio_chunk) to various linear PCM types, with optional dithering. +class NOVTABLE audio_postprocessor : public service_base +{ +public: + //! Processes one chunk of audio data. + //! @param p_chunk Chunk of audio data to process. + //! @param p_output Receives output linear signed PCM data. + //! @param p_out_bps Desired bit depth of output. + //! @param p_out_bps_physical Desired physical word width of output. Must be either 8, 16, 24 or 32, greater or equal to p_out_bps. This is typically set to same value as p_out_bps. + //! @param p_dither Indicates whether dithering should be used. Note that dithering is CPU-heavy. + //! @param p_prescale Value to scale all audio samples by when converting. Set to 1.0 to do nothing. + + virtual void run(const audio_chunk & p_chunk, + mem_block_container & p_output, + t_uint32 p_out_bps, + t_uint32 p_out_bps_physical, + bool p_dither, + audio_sample p_prescale + ) = 0; + + + + FB2K_MAKE_SERVICE_COREAPI(audio_postprocessor); +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/autoplaylist.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/autoplaylist.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,131 @@ +#pragma once +#include "playlist.h" +/* + Autoplaylist APIs + These APIs were introduced in foobar2000 0.9.5, to reduce amount of code required to create your own autoplaylists. Creation of autoplaylists is was also possible before through playlist lock APIs. + In most cases, you'll want to turn regular playlists into autoplaylists using the following code: + autoplaylist_manager::get()->add_client_simple(querypattern, sortpattern, playlistindex, forceSort ? autoplaylist_flag_sort : 0); + If you require more advanced functionality, such as using your own code to filter which part of user's Media Library should be placed in specific autoplaylist, you must implement autoplaylist_client (to let autoplaylist manager invoke your handlers when needed) / autoplaylist_client_factory (to re-instantiate your autoplaylist_client after a foobar2000 restart cycle). +*/ + +enum { + //! When set, core will keep the autoplaylist sorted and prevent user from reordering it. + autoplaylist_flag_sort = 1 << 0, +}; +//! Main class controlling autoplaylist behaviors. Implemented by autoplaylist client in scenarios where simple query/sort strings are not enough (core provides a standard implementation for simple queries). +class NOVTABLE autoplaylist_client : public service_base { + FB2K_MAKE_SERVICE_INTERFACE(autoplaylist_client,service_base) +public: + virtual GUID get_guid() = 0; + //! Provides a boolean mask of which items from the specified list should appear in this autoplaylist. + virtual void filter(metadb_handle_list_cref data, bool * out) = 0; + //! Return true when you have filled p_orderbuffer with a permutation to apply to p_items, false when you don't support sorting (core's own sort scheme will be applied). + virtual bool sort(metadb_handle_list_cref p_items,t_size * p_orderbuffer) = 0; + //! Retrieves your configuration data to be used later when re-instantiating your autoplaylist_client after a restart. + virtual void get_configuration(stream_writer * p_stream,abort_callback & p_abort) = 0; + + virtual void show_ui(t_size p_source_playlist) = 0; + + //! See: autoplaylist_client_v3::supports_async() + bool supports_async_(); + + //! See: autoplaylist_client_v3::supports_get_contents() + bool supports_get_contents_(); + + //! Helper. + template void get_configuration(t_array & p_out) { + PFC_STATIC_ASSERT( sizeof(p_out[0]) == 1 ); + typedef pfc::array_t t_temp; t_temp temp; + { + stream_writer_buffer_append_ref_t writer(temp); + get_configuration(&writer,fb2k::noAbort); + } + p_out = temp; + } +}; + +typedef service_ptr_t autoplaylist_client_ptr; + +//! \since 0.9.5.3 +class NOVTABLE autoplaylist_client_v2 : public autoplaylist_client { + FB2K_MAKE_SERVICE_INTERFACE(autoplaylist_client_v2, autoplaylist_client); +public: + //! Sets a completion_notify object that the autoplaylist_client implementation should call when its filtering behaviors have changed so the whole playlist needs to be rebuilt. \n + //! completion_notify::on_completion() status parameter meaning: \n + //! 0.9.5.3 : ignored. \n + //! 0.9.5.4 and newer: set to 1 to indicate that your configuration has changed as well (for an example as a result of user edits) to get a get_configuration() call as well as cause the playlist to be rebuilt; set to zero otherwise - when the configuration hasn't changed but the playlist needs to be rebuilt as a result of some other event. + virtual void set_full_refresh_notify(completion_notify::ptr notify) = 0; + + //! Returns whether the show_ui() method is available / does anything useful with our implementation (not everyone implements show_ui). + virtual bool show_ui_available() = 0; + + //! Returns a human-readable autoplaylist implementer's label to display in playlist's context menu / description / etc. + virtual void get_display_name(pfc::string_base & out) = 0; +}; + +//! \since 2.0 +class NOVTABLE autoplaylist_client_v3 : public autoplaylist_client_v2 { + FB2K_MAKE_SERVICE_INTERFACE(autoplaylist_client_v3, autoplaylist_client_v2); +public: + //! Returns true if this object supports off-main-thread filter() and sort(). + virtual bool supports_async() = 0; + + //! Provides a boolean mask of which items from the specified list should appear in this autoplaylist. + virtual void filter_v2(metadb_handle_list_cref items, metadb_io_callback_v2_data* dataIfAvailable, bool* out, abort_callback & abort) = 0; + //! Return true when you have filled p_orderbuffer with a permutation to apply to p_items, false when you don't support sorting (core's own sort scheme will be applied). + virtual bool sort_v2(metadb_handle_list_cref p_items, t_size* p_orderbuffer, abort_callback & abort) = 0; + + virtual bool supports_get_contents() = 0; + virtual fb2k::arrayRef get_contents(abort_callback & a) = 0; + + void filter(metadb_handle_list_cref data, bool * out) override; + bool sort(metadb_handle_list_cref p_items,t_size * p_orderbuffer) override; +}; + +//! Class needed to re-instantiate autoplaylist_client after a restart. Not directly needed to set up an autoplaylist_client, but without it, your autoplaylist will be lost after a restart. +class NOVTABLE autoplaylist_client_factory : public service_base { + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(autoplaylist_client_factory) +public: + //! Must return same GUID as your autoplaylist_client::get_guid() + virtual GUID get_guid() = 0; + //! Instantiates your autoplaylist_client with specified configuration. + virtual autoplaylist_client_ptr instantiate(stream_reader * p_stream,t_size p_sizehint,abort_callback & p_abort) = 0; +}; + +PFC_DECLARE_EXCEPTION(exception_autoplaylist,pfc::exception,"Autoplaylist error") + +PFC_DECLARE_EXCEPTION(exception_autoplaylist_already_owned,exception_autoplaylist,"This playlist is already an autoplaylist") +PFC_DECLARE_EXCEPTION(exception_autoplaylist_not_owned,exception_autoplaylist,"This playlist is not an autoplaylist") +PFC_DECLARE_EXCEPTION(exception_autoplaylist_lock_failure,exception_autoplaylist,"Playlist could not be locked") + + +//! Primary class for managing autoplaylists. Implemented by core, do not reimplement; instantiate using autoplaylist_manager::get(). +class NOVTABLE autoplaylist_manager : public service_base { + FB2K_MAKE_SERVICE_COREAPI(autoplaylist_manager) +public: + //! Throws exception_autoplaylist or one of its subclasses on failure. + //! @param p_flags See autoplaylist_flag_* constants. + virtual void add_client(autoplaylist_client_ptr p_client,t_size p_playlist,t_uint32 p_flags) = 0; + virtual bool is_client_present(t_size p_playlist) = 0; + //! Throws exception_autoplaylist or one of its subclasses on failure (eg. not an autoplaylist). + virtual autoplaylist_client_ptr query_client(t_size p_playlist) = 0; + virtual void remove_client(t_size p_playlist) = 0; + //! Helper; sets up an autoplaylist using standard autoplaylist_client implementation based on simple query/sort strings. When using this, you don't need to maintain own autoplaylist_client/autoplaylist_client_factory implementations, and autoplaylists that you create will not be lost when your DLL is removed, as opposed to using add_client() directly. + //! Throws exception_autoplaylist or one of its subclasses on failure. + //! @param p_flags See autoplaylist_flag_* constants. + virtual void add_client_simple(const char * p_query,const char * p_sort,t_size p_playlist,t_uint32 p_flags) = 0; +}; + +//! \since 0.9.5.4 +//! Extended version of autoplaylist_manager, available from 0.9.5.4 up, with methods allowing modification of autoplaylist flags. +class NOVTABLE autoplaylist_manager_v2 : public autoplaylist_manager { + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(autoplaylist_manager_v2, autoplaylist_manager) +public: + virtual t_uint32 get_client_flags(t_size playlist) = 0; + virtual void set_client_flags(t_size playlist, t_uint32 newFlags) = 0; + + //! For use with autoplaylist client configuration dialogs. It's recommended not to call this from anything else. + virtual t_uint32 get_client_flags(autoplaylist_client::ptr client) = 0; + //! For use with autoplaylist client configuration dialogs. It's recommended not to call this from anything else. + virtual void set_client_flags(autoplaylist_client::ptr client, t_uint32 newFlags) = 0; +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/callback_merit.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/callback_merit.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,24 @@ +#pragma once + +namespace fb2k { + // callback_merit_t controls in what order callbacks are executed. \n + // In specific corner cases, you want your callback executed before other callbacks of the same kind. + typedef double callback_merit_t; + + // Note REVERSE sort. HIGHER merit called first. + static constexpr callback_merit_t callback_merit_default = 0; + static constexpr callback_merit_t callback_merit_indexer = 1000; // indexer: does nothing else than updating internal state, called early before UI updates, in case UI updates might rely on indexed data. + static constexpr callback_merit_t callback_merit_serializer = 2000; // serializer: does nothing else than saving new state, called early. + + //! Special class that can be optionally implemented by 'static' callbacks, such as library_callback, to control callback merit. \n + //! See also: callback_merit_t \n + //! Some callback classes support get_callback_merit() natively, such as metadb_io_callback_v2. \n + //! With callbacks registered dynamically, other means of controlling merit are provided. + class callback_with_merit : public service_base { + FB2K_MAKE_SERVICE_INTERFACE(callback_with_merit, service_base); + public: + virtual callback_merit_t get_callback_merit() = 0; + }; + + callback_merit_t callback_merit_of(service_ptr obj); +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/cfg_var.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/cfg_var.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,180 @@ +#include "foobar2000-sdk-pch.h" +#include "cfg_var.h" +#include "configStore.h" + +namespace fb2k { + pfc::string8 formatCfgVarName(const GUID& guid) { + return pfc::format("cfg_var.", pfc::print_guid(guid)); + } + pfc::string8 advconfig_autoName(const GUID& id) { + return pfc::format("advconfig.unnamed.", pfc::print_guid(id)); + } + pfc::string8 advconfig_autoName(const GUID& id, const char* specified) { + if (specified) return specified; + return advconfig_autoName(id); + } +} +namespace cfg_var_modern { + +#ifdef FOOBAR2000_HAVE_CFG_VAR_LEGACY + void cfg_string::set_data_raw(stream_reader* p_stream, t_size p_sizehint, abort_callback& p_abort) { + (void)p_sizehint; + pfc::string8_fastalloc temp; + p_stream->read_string_raw(temp, p_abort); + this->set(temp); + } + + void cfg_int::set_data_raw(stream_reader* p_stream, t_size p_sizehint, abort_callback& p_abort) { + switch (p_sizehint) { + case 4: + { int32_t v; p_stream->read_lendian_t(v, p_abort); set(v); } + break; + case 8: + { int64_t v; p_stream->read_lendian_t(v, p_abort); set(v); } + break; + } + } + + void cfg_bool::set_data_raw(stream_reader* p_stream, t_size p_sizehint, abort_callback& p_abort) { + (void)p_sizehint; + uint8_t b; + if (p_stream->read(&b, 1, p_abort) == 1) { + this->set(b != 0); + } + } +#endif + + int64_t cfg_int::get() { + std::call_once(m_init, [this] { + m_val = fb2k::configStore::get()->getConfigInt(formatName(), m_initVal); + }); + return m_val; + } + + void cfg_int::set(int64_t v) { + if (v != get()) { + m_val = v; + fb2k::configStore::get()->setConfigInt(formatName(), v); + } + } + + bool cfg_bool::get() { + std::call_once(m_init, [this] { + m_val = fb2k::configStore::get()->getConfigBool(formatName(), m_initVal); + }); + return m_val; + } + + void cfg_bool::set(bool v) { + if (v != get()) { + m_val = v; + fb2k::configStore::get()->setConfigBool(formatName(), v); + } + } + + void cfg_string::set(const char* v) { + if (strcmp(v, get()) != 0) { + pfc::string8 obj = v; + + { + PFC_INSYNC_WRITE(m_valueGuard); + m_value = std::move(obj); + } + + fb2k::configStore::get()->setConfigString(formatName(), v); + } + } + + void cfg_string::get(pfc::string_base& out) { + std::call_once(m_init, [this] { + pfc::string8 v = fb2k::configStore::get()->getConfigString(formatName(), m_initVal)->c_str(); + PFC_INSYNC_WRITE(m_valueGuard); + m_value = std::move(v); + }); + + PFC_INSYNC_READ(m_valueGuard); + out = m_value; + } + + pfc::string8 cfg_string::get() { + pfc::string8 ret; get(ret); return ret; + } + + + pfc::string8 cfg_var_common::formatVarName(const GUID& guid) { + return fb2k::formatCfgVarName( guid ); + } + + pfc::string8 cfg_var_common::formatName() const { + return formatVarName(this->m_guid); + } + + fb2k::memBlockRef cfg_blob::get() { + std::call_once(m_init, [this] { + auto v = fb2k::configStore::get()->getConfigBlob(formatName(), m_initVal); + PFC_INSYNC_WRITE(m_dataGuard); + m_data = std::move(v); + }); + PFC_INSYNC_READ(m_dataGuard); + return m_data; + } + + void cfg_blob::set_(fb2k::memBlockRef arg) { + { + PFC_INSYNC_WRITE(m_dataGuard); + m_data = arg; + } + + auto api = fb2k::configStore::get(); + auto name = formatName(); + if (arg.is_valid()) api->setConfigBlob(name, arg); + else api->deleteConfigBlob(name); + } + + void cfg_blob::set(fb2k::memBlockRef arg) { + auto old = get(); + if (!fb2k::memBlock::equals(old, arg)) { + set_(arg); + } + } + + void cfg_blob::set(const void* ptr, size_t size) { + set(fb2k::makeMemBlock(ptr, size)); + } + +#ifdef FOOBAR2000_HAVE_CFG_VAR_LEGACY + void cfg_blob::set_data_raw(stream_reader* p_stream, t_size p_sizehint, abort_callback& p_abort) { + pfc::mem_block block; + block.resize(p_sizehint); + p_stream->read_object(block.ptr(), p_sizehint, p_abort); + set(fb2k::memBlock::blockWithData(std::move(block))); + } +#endif + + double cfg_float::get() { + std::call_once(m_init, [this] { + m_val = fb2k::configStore::get()->getConfigFloat(formatName(), m_initVal); + }); + return m_val; + } + + void cfg_float::set(double v) { + if (v != get()) { + m_val = v; + fb2k::configStore::get()->setConfigFloat(formatName(), v); + } + } + +#ifdef FOOBAR2000_HAVE_CFG_VAR_LEGACY + void cfg_float::set_data_raw(stream_reader* p_stream, t_size p_sizehint, abort_callback& p_abort) { + switch (p_sizehint) { + case 4: + { float v; if (p_stream->read(&v, 4, p_abort) == 4) set(v); } + break; + case 8: + { double v; if (p_stream->read(&v, 8, p_abort) == 8) set(v); } + break; + } + } +#endif +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/cfg_var.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/cfg_var.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,157 @@ +#pragma once +#include "cfg_var_legacy.h" + +using cfg_var_legacy::cfg_var_reader; + +#include +#include +#include + +namespace cfg_var_modern { + class cfg_var_common : public cfg_var_reader { + protected: + cfg_var_common(const GUID& id) : cfg_var_reader(id) {} + pfc::string8 formatName() const; + public: + static pfc::string8 formatVarName(const GUID&); + cfg_var_common(const cfg_var_common&) = delete; + void operator=(const cfg_var_common&) = delete; + }; + + class cfg_string : private cfg_var_common { + public: + cfg_string(const GUID& id, const char* initVal) : cfg_var_common(id), m_initVal(initVal) {} + + void set(const char* v); + pfc::string8 get(); + void get(pfc::string_base& out); + + void operator=(const char* v) { set(v); } + + pfc::string8 get_value() { return get(); } + + operator pfc::string8() { return get(); } + private: +#ifdef FOOBAR2000_HAVE_CFG_VAR_LEGACY + void set_data_raw(stream_reader* p_stream, t_size p_sizehint, abort_callback& p_abort) override; +#endif + + const pfc::string8 m_initVal; + pfc::readWriteLock m_valueGuard; + pfc::string8 m_value; + std::once_flag m_init; + }; + + typedef cfg_string cfg_string_mt; + + class cfg_int : private cfg_var_common { + public: + cfg_int(const GUID& id, int64_t initVal) : cfg_var_common(id), m_initVal(initVal) {} + + int64_t get(); + void set(int64_t v); + operator int64_t() { return get(); } + void operator=(int64_t v) { set(v); } + + int64_t get_value() { return get(); } + private: +#ifdef FOOBAR2000_HAVE_CFG_VAR_LEGACY + void set_data_raw(stream_reader* p_stream, t_size p_sizehint, abort_callback& p_abort) override; +#endif + + const int64_t m_initVal; + std::atomic_int64_t m_val = { 0 }; + std::once_flag m_init; + }; + + typedef cfg_int cfg_uint; + + class cfg_bool : private cfg_var_common { + public: + cfg_bool(const GUID& id, bool initVal) : cfg_var_common(id), m_initVal(initVal) {} + + bool get(); + void set(bool v); + operator bool() { return get(); } + void operator=(bool v) { set(v); } + private: +#ifdef FOOBAR2000_HAVE_CFG_VAR_LEGACY + void set_data_raw(stream_reader* p_stream, t_size p_sizehint, abort_callback& p_abort) override; +#endif + + const bool m_initVal; + std::atomic_bool m_val = { false }; + std::once_flag m_init; + }; + + class cfg_blob : private cfg_var_common { + public: + cfg_blob(const GUID& id) : cfg_var_common(id) {} + cfg_blob(const GUID& id, const void* ptr, size_t size) : cfg_var_common(id) { + m_initVal = fb2k::makeMemBlock(ptr, size); + } + + fb2k::memBlockRef get(); + void set(fb2k::memBlockRef ref); + void set(const void* ptr, size_t size); + private: + void set_(fb2k::memBlockRef); +#ifdef FOOBAR2000_HAVE_CFG_VAR_LEGACY + void set_data_raw(stream_reader* p_stream, t_size p_sizehint, abort_callback& p_abort) override; +#endif + + fb2k::memBlockRef m_data, m_initVal; + pfc::readWriteLock m_dataGuard; + std::once_flag m_init; + }; + + template class cfg_struct_t : private cfg_blob { + public: + cfg_struct_t(const GUID& id) : cfg_blob(id) {} + cfg_struct_t(const GUID& id, const struct_t& init) : cfg_blob(id, &init, sizeof(init)) {} + + struct_t get() { + struct_t data = {}; + auto v = cfg_blob::get(); + if (v.is_valid() && v->size() == sizeof(data)) { + memcpy(&data, v->get_ptr(), sizeof(data)); + } + return data; + } + operator struct_t() { return get(); } + + void set(const struct_t& data) { cfg_blob::set(&data, sizeof(data)); } + void operator=(const struct_t& data) { set(data); } + + struct_t get_value() { return get(); } + }; + + typedef cfg_struct_t cfg_guid; + + class cfg_float : private cfg_var_common { + public: + cfg_float(const GUID& id, double initVal) : cfg_var_common(id), m_initVal(initVal) {} + + double get(); + void set(double v); + operator double() { return get(); } + void operator=(double v) { set(v); } + + double get_value() { return get(); } + private: +#ifdef FOOBAR2000_HAVE_CFG_VAR_LEGACY + void set_data_raw(stream_reader* p_stream, t_size p_sizehint, abort_callback& p_abort) override; +#endif + + const double m_initVal; + std::atomic m_val = { 0 }; + std::once_flag m_init; + }; +} + +#if FOOBAR2000_TARGET_VERSION < 81 +using namespace cfg_var_legacy; +#else +using namespace cfg_var_modern; +#endif + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/cfg_var_legacy.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/cfg_var_legacy.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,158 @@ +#include "foobar2000-sdk-pch.h" +#include "cfg_var_legacy.h" +#if FOOBAR2000_SUPPORT_CFG_VAR_DOWNGRADE +#include "configStore.h" +#include +#endif + + +#ifdef FOOBAR2000_HAVE_CFG_VAR_LEGACY +#if FOOBAR2000_SUPPORT_CFG_VAR_DOWNGRADE +namespace fb2k { + pfc::string8 formatCfgVarName(const GUID&); +} +#endif // FOOBAR2000_SUPPORT_CFG_VAR_DOWNGRADE +namespace cfg_var_legacy { + cfg_var_reader* cfg_var_reader::g_list = NULL; + cfg_var_writer* cfg_var_writer::g_list = NULL; + + void cfg_var_reader::config_read_file(stream_reader* p_stream, abort_callback& p_abort) + { + pfc::map_t vars; + for (cfg_var_reader* walk = g_list; walk != NULL; walk = walk->m_next) { + vars.set(walk->m_guid, walk); + } + for (;;) { + + GUID guid; + t_uint32 size; + + if (p_stream->read(&guid, sizeof(guid), p_abort) != sizeof(guid)) break; + guid = pfc::byteswap_if_be_t(guid); + p_stream->read_lendian_t(size, p_abort); + + auto iter = vars.find(guid); + if ( iter.is_valid() ) { + stream_reader_limited_ref wrapper(p_stream, size); + try { + iter->m_value->set_data_raw(&wrapper, size, p_abort); + } catch (exception_io_data const&) {} + wrapper.flush_remaining(p_abort); + } else { + p_stream->skip_object(size, p_abort); + } + } + } +#if FOOBAR2000_SUPPORT_CFG_VAR_DOWNGRADE + static std::once_flag downgrade_once; + void cfg_var_reader::downgrade_main() { + std::call_once(downgrade_once, [] { + auto api = fb2k::configStore::tryGet(); + if (api.is_valid()) { + for (cfg_var_reader* walk = g_list; walk != NULL; walk = walk->m_next) { + walk->downgrade_check(api); + } + } + }); + } +#endif + void cfg_var_writer::config_write_file(stream_writer* p_stream, abort_callback& p_abort) { + cfg_var_writer* ptr; + pfc::array_t temp; + for (ptr = g_list; ptr; ptr = ptr->m_next) { + temp.set_size(0); + { + stream_writer_buffer_append_ref_t > stream(temp); + ptr->get_data_raw(&stream, p_abort); + } + p_stream->write_lendian_t(ptr->m_guid, p_abort); + p_stream->write_lendian_t(pfc::downcast_guarded(temp.get_size()), p_abort); + if (temp.get_size() > 0) { + p_stream->write_object(temp.get_ptr(), temp.get_size(), p_abort); + } + } + } + + + void cfg_string::get_data_raw(stream_writer* p_stream, abort_callback& p_abort) { + p_stream->write_object(get_ptr(), length(), p_abort); + } + + void cfg_string::set_data_raw(stream_reader* p_stream, t_size p_sizehint, abort_callback& p_abort) { + (void)p_sizehint; + pfc::string8_fastalloc temp; + p_stream->read_string_raw(temp, p_abort); + set_string(temp); + } + + +#if FOOBAR2000_SUPPORT_CFG_VAR_DOWNGRADE + int64_t downgrade_this(fb2k::configStore::ptr api, const char * name, int64_t current) { + int64_t v = api->getConfigInt(name, INT64_MAX); + if (v == INT64_MAX) { + v = api->getConfigInt(name, INT64_MIN); + if ( v == INT64_MIN ) return current; + } + api->deleteConfigInt(name); + return v; + } + uint64_t downgrade_this(fb2k::configStore::ptr api, const char * name, uint64_t current) { + return (uint64_t) downgrade_this(api, name, (int64_t) current); + } + int32_t downgrade_this(fb2k::configStore::ptr api, const char * name, int32_t current) { + return (int32_t) downgrade_this(api, name, (int64_t) current); + } + uint32_t downgrade_this(fb2k::configStore::ptr api, const char * name, uint32_t current) { + return (uint32_t) downgrade_this(api, name, (int64_t) current); + } + bool downgrade_this(fb2k::configStore::ptr api, const char * name, bool current) { + return downgrade_this(api, name, (int64_t)(current?1:0)) != 0; + } + double downgrade_this(fb2k::configStore::ptr api, const char * name, double current) { + double v = api->getConfigFloat(name, -1); + if (v == -1) { + v = api->getConfigFloat(name, 0); + if ( v == 0 ) return current; + } + api->deleteConfigFloat(name); + return v; + } + GUID downgrade_this(fb2k::configStore::ptr api, const char * name, GUID current) { + auto blob = api->getConfigBlob( name ); + if (blob.is_valid() && blob->size() == sizeof(GUID)) { + GUID ret; + memcpy(&ret, blob->get_ptr(), sizeof(ret)); + api->deleteConfigBlob( name ); + return ret; + } + return current; + } + + void cfg_string::downgrade_check(fb2k::configStore::ptr api) { + const auto name = this->downgrade_name(); + auto v = api->getConfigString(name, nullptr); + if (v.is_valid()) { + this->set(v->c_str()); + api->deleteConfigString(name); + } + } + void cfg_string_mt::downgrade_check(fb2k::configStore::ptr api) { + const auto name = this->downgrade_name(); + auto v = api->getConfigString(name, nullptr); + if (v.is_valid()) { + this->set(v->c_str()); + api->deleteConfigString(name); + } + } + + pfc::string8 cfg_var_reader::downgrade_name() const { + if (m_downgrade_name.length() > 0) { + return m_downgrade_name; + } else { + return fb2k::formatCfgVarName(this->m_guid); + } + } +#endif + +} +#endif // FOOBAR2000_HAVE_CFG_VAR_LEGACY diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/cfg_var_legacy.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/cfg_var_legacy.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,376 @@ +#pragma once + +#ifdef FOOBAR2000_HAVE_CFG_VAR_LEGACY +#include +#include "filesystem.h" // stream_reader, stream_writer + +#if FOOBAR2000_SUPPORT_CFG_VAR_DOWNGRADE +#include "configStore.h" +#include "initquit.h" +#endif + +namespace cfg_var_legacy { +#define CFG_VAR_ASSERT_SAFEINIT PFC_ASSERT(!core_api::are_services_available());/*imperfect check for nonstatic instantiation*/ + + //! Reader part of cfg_var object. In most cases, you should use cfg_var instead of using cfg_var_reader directly. + class NOVTABLE cfg_var_reader { + public: + //! @param p_guid GUID of the variable, used to identify variable implementations owning specific configuration file entries when reading the configuration file back. You must generate a new GUID every time you declare a new cfg_var. + cfg_var_reader(const GUID& guid) : m_guid(guid) { CFG_VAR_ASSERT_SAFEINIT; m_next = g_list; g_list = this; } + ~cfg_var_reader() { CFG_VAR_ASSERT_SAFEINIT; } + + //! Sets state of the variable. Called only from main thread, when reading configuration file. + //! @param p_stream Stream containing new state of the variable. + //! @param p_sizehint Number of bytes contained in the stream; reading past p_sizehint bytes will fail (EOF). + virtual void set_data_raw(stream_reader* p_stream, t_size p_sizehint, abort_callback& p_abort) = 0; + +#if FOOBAR2000_SUPPORT_CFG_VAR_DOWNGRADE + private: + pfc::string8 m_downgrade_name; + public: + pfc::string8 downgrade_name() const; + void downgrade_set_name( const char * arg ) { m_downgrade_name = arg; } + + //! Implementation of config downgrade for this var, see FOOBAR2000_SUPPORT_CFG_VAR_DOWNGRADE for more info. \n + //! Most components should not use this. + virtual void downgrade_check(fb2k::configStore::ptr api) {} + //! Config downgrade main for your component, see FOOBAR2000_SUPPORT_CFG_VAR_DOWNGRADE for more info. \n + //! Put FOOBAR2000_IMPLEMENT_CFG_VAR_DOWNGRADE somewhere in your component to call on startup, or call from your code as early as possible after config read. \n + //! If you call it more than once, spurious calls will be ignored. + static void downgrade_main(); +#endif + + //! For internal use only, do not call. + static void config_read_file(stream_reader* p_stream, abort_callback& p_abort); + + const GUID m_guid; + private: + static cfg_var_reader* g_list; + cfg_var_reader* m_next; + + PFC_CLASS_NOT_COPYABLE_EX(cfg_var_reader) + }; + + //! Writer part of cfg_var object. In most cases, you should use cfg_var instead of using cfg_var_writer directly. + class NOVTABLE cfg_var_writer { + public: + //! @param p_guid GUID of the variable, used to identify variable implementations owning specific configuration file entries when reading the configuration file back. You must generate a new GUID every time you declare a new cfg_var. + cfg_var_writer(const GUID& guid) : m_guid(guid) { CFG_VAR_ASSERT_SAFEINIT; m_next = g_list; g_list = this; } + ~cfg_var_writer() { CFG_VAR_ASSERT_SAFEINIT; } + + //! Retrieves state of the variable. Called only from main thread, when writing configuration file. + //! @param p_stream Stream receiving state of the variable. + virtual void get_data_raw(stream_writer* p_stream, abort_callback& p_abort) = 0; + + //! For internal use only, do not call. + static void config_write_file(stream_writer* p_stream, abort_callback& p_abort); + + const GUID m_guid; + private: + static cfg_var_writer* g_list; + cfg_var_writer* m_next; + + PFC_CLASS_NOT_COPYABLE_EX(cfg_var_writer) + }; + + //! Base class for configuration variable classes; provides self-registration mechaisms and methods to set/retrieve configuration data; those methods are automatically called for all registered instances by backend when configuration file is being read or written.\n + //! Note that cfg_var class and its derivatives may be only instantiated statically (as static objects or members of other static objects), NEVER dynamically (operator new, local variables, members of objects instantiated as such). + class NOVTABLE cfg_var : public cfg_var_reader, public cfg_var_writer { + protected: + //! @param p_guid GUID of the variable, used to identify variable implementations owning specific configuration file entries when reading the configuration file back. You must generate a new GUID every time you declare a new cfg_var. + cfg_var(const GUID& p_guid) : cfg_var_reader(p_guid), cfg_var_writer(p_guid) {} + public: + GUID get_guid() const { return cfg_var_reader::m_guid; } + }; + +#if FOOBAR2000_SUPPORT_CFG_VAR_DOWNGRADE + int64_t downgrade_this( fb2k::configStore::ptr api, const char*, int64_t current); + uint64_t downgrade_this( fb2k::configStore::ptr api, const char*, uint64_t current); + int32_t downgrade_this( fb2k::configStore::ptr api, const char*, int32_t current); + uint32_t downgrade_this( fb2k::configStore::ptr api, const char*, uint32_t current); + bool downgrade_this( fb2k::configStore::ptr api, const char*, bool current); + double downgrade_this( fb2k::configStore::ptr api, const char*, double current); + GUID downgrade_this( fb2k::configStore::ptr api, const char*, GUID current); +#endif + + //! Generic integer config variable class. Template parameter can be used to specify integer type to use.\n + //! Note that cfg_var class and its derivatives may be only instantiated statically (as static objects or members of other static objects), NEVER dynamically (operator new, local variables, members of objects instantiated as such). + template + class cfg_int_t : public cfg_var { + private: + t_inttype m_val; + protected: + void get_data_raw(stream_writer* p_stream, abort_callback& p_abort) override { p_stream->write_lendian_t(m_val, p_abort); } + void set_data_raw(stream_reader* p_stream, t_size, abort_callback& p_abort) override { + t_inttype temp; + p_stream->read_lendian_t(temp, p_abort);//alter member data only on success, this will throw an exception when something isn't right + m_val = temp; + } +#if FOOBAR2000_SUPPORT_CFG_VAR_DOWNGRADE + void downgrade_check(fb2k::configStore::ptr api) override { + m_val = downgrade_this(api, this->downgrade_name(), m_val); + } +#endif + public: + //! @param p_guid GUID of the variable, used to identify variable implementations owning specific configuration file entries when reading the configuration file back. You must generate a new GUID every time you declare a new cfg_var. + //! @param p_default Default value of the variable. + explicit inline cfg_int_t(const GUID& p_guid, t_inttype p_default) : cfg_var(p_guid), m_val(p_default) {} + + inline const cfg_int_t& operator=(const cfg_int_t& p_val) { m_val = p_val.m_val; return *this; } + inline t_inttype operator=(t_inttype p_val) { m_val = p_val; return m_val; } + + inline operator t_inttype() const { return m_val; } + + inline t_inttype get_value() const { return m_val; } + inline t_inttype get() const { return m_val; } + }; + + typedef cfg_int_t cfg_int; + typedef cfg_int_t cfg_uint; + typedef cfg_int_t cfg_guid; // ANNOYING OLD DESIGN. THIS DOESN'T BELONG HERE BUT CANNOT BE CHANGED WITHOUT BREAKING PEOPLE'S STUFF. BLARFGH. + typedef cfg_int_t cfg_bool; // See above. + typedef cfg_int_t cfg_float; // See above %$!@#$ + typedef cfg_int_t cfg_double; // .... + + //! String config variable. Stored in the stream with int32 header containing size in bytes, followed by non-null-terminated UTF-8 data.\n + //! Note that cfg_var class and its derivatives may be only instantiated statically (as static objects or members of other static objects), NEVER dynamically (operator new, local variables, members of objects instantiated as such). + class cfg_string : public cfg_var, public pfc::string8 { + protected: + void get_data_raw(stream_writer* p_stream, abort_callback& p_abort) override; + void set_data_raw(stream_reader* p_stream, t_size p_sizehint, abort_callback& p_abort) override; + +#if FOOBAR2000_SUPPORT_CFG_VAR_DOWNGRADE + void downgrade_check(fb2k::configStore::ptr) override; +#endif + public: + //! @param p_guid GUID of the variable, used to identify variable implementations owning specific configuration file entries when reading the configuration file back. You must generate a new GUID every time you declare a new cfg_var. + //! @param p_defaultval Default/initial value of the variable. + explicit inline cfg_string(const GUID& p_guid, const char* p_defaultval) : cfg_var(p_guid), pfc::string8(p_defaultval) {} + + const cfg_string& operator=(const cfg_string& p_val) { set_string(p_val); return *this; } + const cfg_string& operator=(const char* p_val) { set_string(p_val); return *this; } + const cfg_string& operator=(pfc::string8 && p_val) { set(std::move(p_val)); return *this; } + + + inline operator const char* () const { return get_ptr(); } + const pfc::string8& get() const { return *this; } + void set( const char * arg ) { this->set_string(arg); } + void set(pfc::string8&& arg) { pfc::string8 * pThis = this; *pThis = std::move(arg); } + }; + + + class cfg_string_mt : public cfg_var { + protected: + void get_data_raw(stream_writer* p_stream, abort_callback& p_abort) override { + pfc::string8 temp; + get(temp); + p_stream->write_object(temp.get_ptr(), temp.length(), p_abort); + } + void set_data_raw(stream_reader* p_stream, t_size, abort_callback& p_abort) override { + pfc::string8_fastalloc temp; + p_stream->read_string_raw(temp, p_abort); + set(temp); + } +#if FOOBAR2000_SUPPORT_CFG_VAR_DOWNGRADE + void downgrade_check(fb2k::configStore::ptr) override; +#endif + public: + cfg_string_mt(const GUID& id, const char* defVal) : cfg_var(id), m_val(defVal) {} + void get(pfc::string_base& out) const { inReadSync(m_sync); out = m_val; } + pfc::string8 get() const { inReadSync(m_sync); return m_val; } + void set(const char* val, t_size valLen = SIZE_MAX) { inWriteSync(m_sync); m_val.set_string(val, valLen); } + void set( pfc::string8 && val ) { inWriteSync(m_sync); m_val = std::move(val); } + private: + mutable pfc::readWriteLock m_sync; + pfc::string8 m_val; + }; + + //! Struct config variable template. Warning: not endian safe, should be used only for nonportable code.\n + //! Note that cfg_var class and its derivatives may be only instantiated statically (as static objects or members of other static objects), NEVER dynamically (operator new, local variables, members of objects instantiated as such). + template + class cfg_struct_t : public cfg_var { + private: + t_struct m_val = {}; + protected: + + void get_data_raw(stream_writer* p_stream, abort_callback& p_abort) { p_stream->write_object(&m_val, sizeof(m_val), p_abort); } + void set_data_raw(stream_reader* p_stream, t_size p_sizehint, abort_callback& p_abort) { + t_struct temp; + p_stream->read_object(&temp, sizeof(temp), p_abort); + m_val = temp; + } + public: + //! @param p_guid GUID of the variable, used to identify variable implementations owning specific configuration file entries when reading the configuration file back. You must generate a new GUID every time you declare a new cfg_var. + inline cfg_struct_t(const GUID& p_guid, const t_struct& p_val) : cfg_var(p_guid), m_val(p_val) {} + //! @param p_guid GUID of the variable, used to identify variable implementations owning specific configuration file entries when reading the configuration file back. You must generate a new GUID every time you declare a new cfg_var. + inline cfg_struct_t(const GUID& p_guid, int filler) : cfg_var(p_guid) { memset(&m_val, filler, sizeof(t_struct)); } + //! @param p_guid GUID of the variable, used to identify variable implementations owning specific configuration file entries when reading the configuration file back. You must generate a new GUID every time you declare a new cfg_var. + inline cfg_struct_t(const GUID& p_guid) : cfg_var(p_guid) {} + + inline const cfg_struct_t& operator=(const cfg_struct_t& p_val) { m_val = p_val.get_value(); return *this; } + inline const cfg_struct_t& operator=(const t_struct& p_val) { m_val = p_val; return *this; } + + inline const t_struct& get_value() const { return m_val; } + inline t_struct& get_value() { return m_val; } + inline operator t_struct() const { return m_val; } + + void set(t_struct&& arg) { m_val = std::move(arg); } + void set(t_struct const& arg) { m_val = arg; } + t_struct get() const { return m_val; } + }; + + + template + class cfg_objList : public cfg_var, public pfc::list_t { + public: + typedef TObj item_t; + typedef cfg_objList t_self; + cfg_objList(const GUID& guid) : cfg_var(guid) {} + template cfg_objList(const GUID& guid, const TSource(&source)[Count]) : cfg_var(guid) { + reset(source); + } + template void reset(const TSource(&source)[Count]) { + this->set_size(Count); for (t_size walk = 0; walk < Count; ++walk) (*this)[walk] = source[walk]; + } + void get_data_raw(stream_writer* p_stream, abort_callback& p_abort) { + stream_writer_formatter<> out(*p_stream, p_abort); + out << pfc::downcast_guarded(this->get_size()); + for (t_size walk = 0; walk < this->get_size(); ++walk) out << (*this)[walk]; + } + void set_data_raw(stream_reader* p_stream, t_size p_sizehint, abort_callback& p_abort) { + try { + stream_reader_formatter<> in(*p_stream, p_abort); + t_uint32 count; in >> count; + this->set_count(count); + for (t_uint32 walk = 0; walk < count; ++walk) in >> (*this)[walk]; + } catch (...) { + this->remove_all(); + throw; + } + } + template t_self& operator=(t_in const& source) { this->remove_all(); this->add_items(source); return *this; } + template t_self& operator+=(t_in const& p_source) { this->add_item(p_source); return *this; } + template t_self& operator|=(t_in const& p_source) { this->add_items(p_source); return *this; } + + + std::vector get() const { + std::vector ret; ret.reserve(this->size()); + for (auto& item : *this) ret.push_back(item); + return ret; + } + template void set(arg_t&& arg) { + this->remove_all(); + this->prealloc(std::size(arg)); + for (auto& item : arg) { + this->add_item(item); + } + } + }; + template + class cfg_objListEx : public cfg_var, public TList { + public: + typedef cfg_objListEx t_self; + cfg_objListEx(const GUID& guid) : cfg_var(guid) {} + void get_data_raw(stream_writer* p_stream, abort_callback& p_abort) { + stream_writer_formatter<> out(*p_stream, p_abort); + out << pfc::downcast_guarded(this->get_count()); + for (typename TList::const_iterator walk = this->first(); walk.is_valid(); ++walk) out << *walk; + } + void set_data_raw(stream_reader* p_stream, t_size p_sizehint, abort_callback& p_abort) { + this->remove_all(); + stream_reader_formatter<> in(*p_stream, p_abort); + t_uint32 count; in >> count; + for (t_uint32 walk = 0; walk < count; ++walk) { + typename TList::t_item item; in >> item; this->add_item(item); + } + } + template t_self& operator=(t_in const& source) { this->remove_all(); this->add_items(source); return *this; } + template t_self& operator+=(t_in const& p_source) { this->add_item(p_source); return *this; } + template t_self& operator|=(t_in const& p_source) { this->add_items(p_source); return *this; } + }; + + template + class cfg_obj : public cfg_var, public TObj { + public: + cfg_obj(const GUID& guid) : cfg_var(guid), TObj() {} + template cfg_obj(const GUID& guid, const TInitData& initData) : cfg_var(guid), TObj(initData) {} + + TObj& val() { return *this; } + TObj const& val() const { return *this; } + TObj get() const { return val(); } + template void set(arg_t&& arg) { val() = std::forward(arg); } + + void get_data_raw(stream_writer* p_stream, abort_callback& p_abort) { + stream_writer_formatter<> out(*p_stream, p_abort); + const TObj* ptr = this; + out << *ptr; + } + void set_data_raw(stream_reader* p_stream, t_size p_sizehint, abort_callback& p_abort) { + stream_reader_formatter<> in(*p_stream, p_abort); + TObj* ptr = this; + in >> *ptr; + } + }; + + template class cfg_objListImporter : private cfg_var_reader { + public: + typedef cfg_objList TMasterVar; + cfg_objListImporter(TMasterVar& var, const GUID& guid) : m_var(var), cfg_var_reader(guid) {} + + private: + void set_data_raw(stream_reader* p_stream, t_size p_sizehint, abort_callback& p_abort) { + TImport temp; + try { + stream_reader_formatter<> in(*p_stream, p_abort); + t_uint32 count; in >> count; + m_var.set_count(count); + for (t_uint32 walk = 0; walk < count; ++walk) { + in >> temp; + m_var[walk] = temp; + } + } catch (...) { + m_var.remove_all(); + throw; + } + } + TMasterVar& m_var; + }; + template class cfg_objMap : private cfg_var, public TMap { + public: + cfg_objMap(const GUID& id) : cfg_var(id) {} + private: + void get_data_raw(stream_writer* p_stream, abort_callback& p_abort) { + stream_writer_formatter<> out(*p_stream, p_abort); + out << pfc::downcast_guarded(this->get_count()); + for (typename TMap::const_iterator walk = this->first(); walk.is_valid(); ++walk) { + out << walk->m_key << walk->m_value; + } + } + void set_data_raw(stream_reader* p_stream, t_size p_sizehint, abort_callback& p_abort) { + this->remove_all(); + stream_reader_formatter<> in(*p_stream, p_abort); + t_uint32 count; in >> count; + for (t_uint32 walk = 0; walk < count; ++walk) { + typename TMap::t_key key; in >> key; PFC_ASSERT(!this->have_item(key)); + try { in >> this->find_or_add(key); } catch (...) { this->remove(key); throw; } + } + } + }; +#if FOOBAR2000_SUPPORT_CFG_VAR_DOWNGRADE +#define FOOBAR2000_IMPLEMENT_CFG_VAR_DOWNGRADE FB2K_RUN_ON_INIT(cfg_var_reader::downgrade_main) +#endif // FOOBAR2000_SUPPORT_CFG_VAR_DOWNGRADE +} // cfg_var_legacy +#else +namespace cfg_var_legacy { + // Dummy class + class cfg_var_reader { + public: + cfg_var_reader(const GUID& id) : m_guid(id) {} + const GUID m_guid; + }; +} +#endif + +#ifndef FOOBAR2000_IMPLEMENT_CFG_VAR_DOWNGRADE +#define FOOBAR2000_IMPLEMENT_CFG_VAR_DOWNGRADE +#endif \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/chapterizer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/chapterizer.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,39 @@ +#include "foobar2000-sdk-pch.h" +#include "chapterizer.h" + +void chapter_list::copy(const chapter_list & p_source) +{ + t_size n, count = p_source.get_chapter_count(); + set_chapter_count(count); + for(n=0;n & p_out,const char * p_path) +{ + for (auto ptr : enumerate()) { + if (ptr->is_our_path(p_path)) { + p_out = ptr; + return true; + } + } + return false; +} + +bool chapterizer::g_is_pregap_capable(const char * p_path) { + for (auto ptr : enumerate()) { + if (ptr->supports_pregaps() && ptr->is_our_path(p_path)) { + return true; + } + } + return false; +} + +#endif + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/chapterizer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/chapterizer.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,95 @@ +#pragma once +#include "file_info_impl.h" + +// Not everything is on #ifdef FOOBAR2000_HAVE_CHAPTERIZER +// Some things use chapter_list internally even if chapterizer is disabled + +//! Interface for object storing list of chapters. +class NOVTABLE chapter_list { +public: + //! Returns number of chapters. + virtual t_size get_chapter_count() const = 0; + //! Queries description of specified chapter. + //! @param p_chapter Index of chapter to query, greater or equal zero and less than get_chapter_count() value. If p_chapter value is out of valid range, results are undefined (e.g. crash). + //! @returns reference to file_info object describing specified chapter (length part of file_info indicates distance between beginning of this chapter and next chapter mark). Returned reference value for temporary use only, becomes invalid after any non-const operation on the chapter_list object. + virtual const file_info & get_info(t_size p_chapter) const = 0; + + //! Sets number of chapters. + virtual void set_chapter_count(t_size p_count) = 0; + //! Modifies description of specified chapter. + //! @param p_chapter Index of chapter to modify, greater or equal zero and less than get_chapter_count() value. If p_chapter value is out of valid range, results are undefined (e.g. crash). + //! @param p_info New chapter description. Note that length part of file_info is used to calculate chapter marks. + virtual void set_info(t_size p_chapter,const file_info & p_info) = 0; + + //! Gets first track pregap - offset into audio at which first track begins. + //! Not every chapterizer supports this, see chapterizer::supports_pregaps() + virtual double get_pregap() const = 0; + //! Sets first track pregap - offset into audio at which first track begins. + //! Not every chapterizer supports this, see chapterizer::supports_pregaps() + virtual void set_pregap(double val) = 0; + + //! Copies contents of specified chapter_list object to this object. + void copy(const chapter_list & p_source); + + inline const chapter_list & operator=(const chapter_list & p_source) {copy(p_source); return *this;} + +protected: + chapter_list() {} + ~chapter_list() {} +}; + +//! Implements chapter_list. +template +class chapter_list_impl_t : public chapter_list { +public: + chapter_list_impl_t() {} + typedef chapter_list_impl_t t_self; + chapter_list_impl_t(const chapter_list & p_source) : m_pregap() {copy(p_source);} + const t_self & operator=(const chapter_list & p_source) {copy(p_source); return *this;} + + t_size get_chapter_count() const {return m_infos.get_size();} + const file_info & get_info(t_size p_chapter) const {return m_infos[p_chapter];} + + void set_chapter_count(t_size p_count) {m_infos.set_size(p_count);} + void set_info(t_size p_chapter,const file_info & p_info) {m_infos[p_chapter] = p_info;} + file_info_ & get_info_(t_size p_chapter) {return m_infos[p_chapter];} + + double get_pregap() const {return m_pregap;} + void set_pregap(double val) {PFC_ASSERT(val >= 0); m_pregap = val;} +private: + pfc::array_t m_infos; + double m_pregap = 0; +}; + +typedef chapter_list_impl_t<> chapter_list_impl; + +#ifdef FOOBAR2000_HAVE_CHAPTERIZER + +//! This service implements chapter list editing operations for various file formats, e.g. for MP4 chapters or CD images with embedded cuesheets. Used by converter "encode single file with chapters" feature. +class NOVTABLE chapterizer : public service_base { + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(chapterizer); +public: + //! Tests whether specified path is supported by this implementation. + virtual bool is_our_path(const char * p_path) = 0; + + //! Writes new chapter list to specified file. + //! @param p_path Path of file to modify. + //! @param p_list New chapter list to write. + //! @param p_abort abort_callback object signaling user aborting the operation. + virtual void set_chapters(const char * p_path,chapter_list const & p_list,abort_callback & p_abort) = 0; + //! Retrieves chapter list from specified file. + //! @param p_path Path of file to examine. + //! @param p_list Object receiving chapter list. + //! @param p_abort abort_callback object signaling user aborting the operation. + virtual void get_chapters(const char * p_path,chapter_list & p_list,abort_callback & p_abort) = 0; + + //! @returns Whether this chapterizer supports altering pregap before first track, see chapter_list::get_pregap() & set_pregap() + virtual bool supports_pregaps() = 0; + + //! Static helper, tries to find chapterizer interface that supports specified file. + static bool g_find(service_ptr_t & p_out,const char * p_path); + + static bool g_is_pregap_capable(const char * p_path); +}; + +#endif diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/commandline.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/commandline.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,16 @@ +#include "foobar2000-sdk-pch.h" + +#include "commandline.h" +#include "metadb.h" +#include "console.h" + +void commandline_handler_metadb_handle::on_file(const char * url) { + metadb_handle_list handles; + try { + metadb_io::get()->path_to_handles_simple(url, handles); + } catch(std::exception const & e) { + console::complain("Path evaluation failure", e); + return; + } + for(t_size walk = 0; walk < handles.get_size(); ++walk) on_file(handles[walk]); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/commandline.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/commandline.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,46 @@ +#pragma once + +//! Service for handling commandline arguments passed to foobar2000.exe +class NOVTABLE commandline_handler : public service_base +{ +public: + enum result + { + RESULT_NOT_OURS,//not our command + RESULT_PROCESSED,//command processed + RESULT_PROCESSED_EXPECT_FILES,//command processed, we want to takeover file urls after this command + }; + virtual result on_token(const char * token)=0; + virtual void on_file(const char* url) { (void)url; };//optional + virtual void on_files_done() {};//optional + virtual bool want_directories() {return false;} + + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(commandline_handler); +}; + +//! Helper automatically turning passed file locations into metadb_handle objects (audio track references) +class commandline_handler_metadb_handle : public commandline_handler { +protected: + void on_file(const char * url) override final; + bool want_directories() override {return true;} +public: + //! Override me + virtual result on_token(const char * token) override = 0; + //! Override me + virtual void on_files_done() override {}; + //! Override me + virtual void on_file(const metadb_handle_ptr & ptr) = 0; +}; + +/* + +how commandline_handler is used: + + scenario #1: + creation => on_token() => deletion + scenario #2: + creation => on_token() returning RESULT_PROCESSED_EXPECT_FILES => on_file(), on_file().... => on_files_done() => deletion +*/ + +template +class commandline_handler_factory_t : public service_factory_t {}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/commonObjects-Apple.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/commonObjects-Apple.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,21 @@ +#pragma once + +#ifdef __APPLE__ + +namespace fb2k { + class NSObjectWrapper : public service_base { + FB2K_MAKE_SERVICE_INTERFACE(NSObjectWrapper, service_base); + public: + virtual void * get_() = 0; +#ifdef __OBJC__ + id get() { return (__bridge id) get_(); } +#endif + + }; +#ifdef __OBJC__ + service_ptr wrapNSObject(id); + id unwrapNSObject(service_ptr); +#endif +} + +#endif diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/commonObjects-Apple.mm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/commonObjects-Apple.mm Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,29 @@ +#include "foobar2000-sdk-pch.h" +#include "commonObjects-Apple.h" +#include + +namespace { + class NSObjectWrapperImpl : public fb2k::NSObjectWrapper { + public: + id obj; + void * get_() override { + return (__bridge void*) obj; + } + }; +} +namespace fb2k { + service_ptr wrapNSObject(id arg) { + if (!arg) return nullptr; + auto ret = fb2k::service_new(); + ret->obj = arg; + return ret; + } + id unwrapNSObject(service_ptr arg) { + id ret = nil; + fb2k::NSObjectWrapper::ptr obj; + if ( obj &= arg ) { + ret = obj->get(); + } + return ret; + } +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/commonObjects.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/commonObjects.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,456 @@ +#include "foobar2000-sdk-pch.h" + +#include +#include +#include +#ifdef FOOBAR2000_MOBILE +#include "browseTree.h" +#endif +#include + +namespace { + class arrayImpl : public fb2k::array { + public: + arrayImpl() {} + arrayImpl(std::initializer_list const& arg) { + m_content.set_size_discard(arg.size()); + size_t walk = 0; + for (auto& obj : arg) m_content[walk++] = obj; + } + arrayImpl( array::ptr in ) { + const size_t count = in->count(); + m_content.set_size_discard( count ); + for(size_t w = 0; w < count; ++w) m_content[w] = in->itemAt(w); + } + arrayImpl( array::ptr in, size_t const * order, size_t count ) { + if (count != in->count()) uBugCheck(); + m_content.set_size_discard(count); + for(size_t w = 0; w < count; ++w) m_content[w] = in->itemAt( order[w] ); + } + arrayImpl( fb2k::objRef in ) { + m_content.set_size_discard( 1 ) ; + m_content[0] = in; + } + arrayImpl( fb2k::objRef const * in, size_t inCount) { + m_content.set_data_fromptr( in, inCount ); + } + size_t count() const { return m_content.get_size(); } + service_ptr itemAt(size_t idx) const { return m_content[idx]; } + + private: + pfc::array_staticsize_t< service_ptr > m_content; + }; + class arrayMutableImpl : public fb2k::arrayMutable { + public: + arrayMutableImpl() {} + arrayMutableImpl( array::ptr in ) { + const size_t count = in->count(); + m_content.set_size_discard( count ); + for(size_t w = 0; w < count; ++w) { + m_content[w] = in->itemAt( w ); + } + } + arrayMutableImpl( fb2k::objRef in ) { + m_content.set_size_discard( 1 ); + m_content[0] = in; + } + size_t count() const { return m_content.get_size(); } + fb2k::objRef itemAt( size_t idx ) const { return m_content[idx]; } + void remove( pfc::bit_array const & mask ) { + pfc::remove_mask_t( m_content, mask ); + } + void insert( fb2k::objRef obj, size_t at ) { + pfc::insert_t( m_content, obj, at ); + } + void insertFrom( array::ptr objects, size_t at ) { + if (objects.get_ptr() == this) { + objects = arrayWithArray( objects ); + } + pfc::insert_multi_t( m_content, *objects, objects->count(), at ); + } + void reorder( const size_t * order, size_t count ) { + if (count != m_content.get_size()) uBugCheck(); + pfc::reorder_t( m_content, order, count ); + } + + void resize( size_t newSize ) { + m_content.set_size( newSize ); + } + void setItem( fb2k::objRef obj, size_t atIndex ) { + if (atIndex > m_content.get_size()) uBugCheck(); + m_content[atIndex] = obj; + } + void prealloc(size_t capacity) { + m_content.prealloc(capacity); + } + private: + pfc::array_t< fb2k::objRef, pfc::alloc_fast > m_content; + }; + + class stringImpl : public fb2k::string { + public: + stringImpl( const wchar_t * str, size_t len = pfc_infinite ) { + size_t n = pfc::stringcvt::estimate_wide_to_utf8( str, len ); + m_str = (char*) malloc( n ); + pfc::stringcvt::convert_wide_to_utf8( m_str, n, str, len ); + } + stringImpl( const char * str ) { + m_str = pfc::strDup(str); + if (m_str == nullptr) throw std::bad_alloc(); + } + stringImpl( const char * str, size_t len ) { + len = pfc::strlen_max( str, len ); + m_str = (char*)malloc( len + 1 ); + if (m_str == nullptr) throw std::bad_alloc(); + memcpy (m_str, str, len ); + m_str[len] = 0; + } + + ~stringImpl() { + free(m_str); + } + const char * c_str() const {return m_str;} + private: + char * m_str; + }; + + + + class memBlockImpl : public fb2k::memBlock { + public: + memBlockImpl( const void * inData, size_t inDataSize ) { + m_data.set_data_fromptr( (const uint8_t*) inData, inDataSize ); + } + const void * data() const { + return m_data.get_ptr(); + } + size_t size() const { + return m_data.get_size(); + } + private: + pfc::array_staticsize_t< uint8_t > m_data; + }; + + class memBlockImpl_takeOwnership : public fb2k::memBlock { + public: + memBlockImpl_takeOwnership(void * data, size_t size) : m_data(data), m_size(size) {} + ~memBlockImpl_takeOwnership() { free(m_data); } + const void * data() const { return m_data; } + size_t size() const { return m_size; } + private: + void * const m_data; + const size_t m_size; + }; + + class memBlockMutableImpl : public fb2k::memBlockMutable { + public: + memBlockMutableImpl( size_t initSize ) { m_data.set_size_discard( initSize ); } + memBlockMutableImpl( const void * inData, size_t inSize) { + m_data.set_data_fromptr( (const uint8_t*) inData, inSize ); + } + memBlockMutableImpl() {} + + const void * data() const { return m_data.get_ptr(); } + void * dataMutable() { return m_data.get_ptr(); } + + size_t size() const { return m_data.get_size(); } + void resize( size_t size ) { m_data.set_size( size ); } + void resizeDiscard( size_t size ) { m_data.set_size_discard( size ); } + + private: + pfc::array_t< uint8_t > m_data; + }; +} + +namespace fb2k { + FOOGUIDDECL const GUID array::class_guid = { 0x3f2c5273, 0x6cea, 0x427d, { 0x8c, 0x74, 0x34, 0x79, 0xc7, 0x22, 0x6a, 0x1 } }; + FOOGUIDDECL const GUID arrayMutable::class_guid = { 0x142709d1, 0x9cef, 0x42c4, { 0xb5, 0x63, 0xbc, 0x3a, 0xee, 0x8, 0xdc, 0xe3 } }; + FOOGUIDDECL const GUID string::class_guid = { 0xb3572de3, 0xdc77, 0x4494, { 0xa3, 0x90, 0xb1, 0xff, 0xd9, 0x17, 0x38, 0x77 } }; + // ! Old GUID of album_art_data ! + FOOGUIDDECL const GUID memBlock::class_guid = { 0x9ddce05c, 0xaa3f, 0x4565, { 0xb3, 0x3a, 0xbd, 0x6a, 0xdc, 0xdd, 0x90, 0x37 } }; + FOOGUIDDECL const GUID memBlockMutable::class_guid = { 0x481ab64c, 0xa28, 0x435b, { 0x85, 0xdc, 0x9e, 0x20, 0xfe, 0x92, 0x15, 0x61 } }; + FOOGUIDDECL const GUID objReceiver::class_guid = { 0x1b60d9fa, 0xcb9d, 0x45a4, { 0x90, 0x4e, 0xa, 0xa8, 0xaa, 0xe7, 0x99, 0x7c } }; + + array::ptr array::arrayReordered( size_t const * order, size_t count ) { + return new service_impl_t< arrayImpl > ( this, order, count ); + } + array::ptr array::copy() const { + return arrayWithArray( const_cast( this ) ); + } + + array::ptr array::empty() { + return new service_impl_t< arrayImpl >(); + } + + array::ptr array::arrayWithArray( array::ptr source ) { + return new service_impl_t< arrayImpl > ( source ); + } + array::ptr array::arrayWithObject( objRef source ) { + return new service_impl_t< arrayImpl > ( source ); + } + array::ptr array::arrayWithObjects( objRef const * source, size_t count ) { + return new service_impl_t( source, count ); + } + array::ptr array::arrayWithObjects(std::initializer_list< objRef > const& arg) { + return new service_impl_t(arg); + } + arrayMutable::ptr arrayMutable::arrayWithCapacity(size_t capacity) { + auto ret = fb2k::service_new< arrayMutableImpl >(); + ret->prealloc(capacity); + return ret; + } + arrayMutable::ptr arrayMutable::empty() { + return new service_impl_t< arrayMutableImpl > (); + } + arrayMutable::ptr arrayMutable::arrayWithArray( array::ptr source ) { + return new service_impl_t< arrayMutableImpl > ( source ); + } + arrayMutable::ptr arrayMutable::arrayWithObject( objRef source ) { + return new service_impl_t< arrayMutableImpl > ( source ); + } + arrayMutable::ptr arrayMutable::copy() const { + return arrayWithArray( const_cast(this) ); + } + array::ptr array::makeConst() const { + arrayMutableRef mut; + if (mut &= const_cast(this)) return mut->copyConst(); + return const_cast(this); + } + array::ptr arrayMutable::copyConst() const { + return array::arrayWithArray( const_cast(this) ); + } + + string::ptr string::stringWithString( const char * str ) { + return new service_impl_t< stringImpl > (str); + } + string::ptr string::stringWithString( const char * str, size_t len ) { + return new service_impl_t< stringImpl > (str, len); + } + string::ptr string::stringWithString( string::ptr str ) { + return new service_impl_t< stringImpl > (str->c_str() ); + } + bool string::equalsNullSafe( string::ptr v1, string::ptr v2 ) { + if (v1.is_empty() && v2.is_empty()) return true; + if (v1.is_empty() || v2.is_empty()) return false; + return v1->equals( v2 ); + } + + memBlock::ptr memBlock::empty() { + return blockWithData(NULL, 0); + } + memBlock::ptr memBlock::blockWithDataTakeOwnership(void * inData, size_t inSize) { + return new service_impl_t< memBlockImpl_takeOwnership >(inData, inSize); + } + memBlock::ptr memBlock::blockWithData( const void * inData, size_t inSize) { + return new service_impl_t< memBlockImpl > ( inData, inSize ); + } + memBlock::ptr memBlock::blockWithData(pfc::mem_block const& b) { + return blockWithData(b.ptr(), b.size()); + } + memBlock::ptr memBlock::blockWithData(pfc::mem_block&& b) { + auto ret = blockWithDataTakeOwnership(b.ptr(), b.size()); + b.detach(); + return ret; + } + memBlock::ptr memBlock::copy() const { + return blockWithBlock( const_cast( this ) ); + } + + memBlockMutable::ptr memBlockMutable::copy() const { + return blockWithBlock( const_cast( this ) ); + } + memBlock::ptr memBlockMutable::copyConst() const { + return memBlock::blockWithBlock( const_cast(this) ); + } + + memBlockMutableRef memBlockMutable::empty() { + return new service_impl_t< memBlockMutableImpl >; + } + memBlockMutableRef memBlockMutable::blockWithSize(size_t initSize) { + return new service_impl_t< memBlockMutableImpl >( initSize ); + } + + memBlockRef memBlock::blockWithBlock(memBlock::ptr block) { + return blockWithData( block->data(), block->size() ); + } + memBlockMutableRef memBlockMutable::blockWithData( const void * inData, size_t inSize ) { + return new service_impl_t< memBlockMutableImpl >( inData, inSize ); + } + + memBlockMutableRef memBlockMutable::blockWithBlock(memBlock::ptr block) { + return blockWithData( block->data(), block->size() ); + } + + void describe( objRef obj, pfc::string_formatter & output, unsigned indent) { + output.add_chars( ' ', indent * 2 ); + { + stringRef str; + if (obj->cast(str)) { + output << "string: " << str->c_str() << "\n"; + return; + } + } + { + arrayRef arr; + if (obj->cast(arr)) { + arrayMutableRef mut; + if (obj->cast(mut)) { + output << "arrayMutable"; + } else { + output << "array"; + } + const size_t count = arr->count(); + output << " (" << count << " items):\n"; + for(size_t w = 0; w < count; ++w) { + describe( arr->itemAt(w), output, indent + 1); + } + return; + } + } + { + memBlockRef block; + if (obj->cast(block)) { + memBlockMutableRef mut; + if (obj->cast(mut)) { + output << "memBlockMutable"; + } else { + output << "memBlock"; + } + output << " (" << block->size() << " bytes)\n"; + return; + } + } +#ifdef FOOBAR2000_MOBILE + { + browseTreeItem::ptr item; + if (obj->cast(item)) { + output << "browseTreeItem\n"; + return; + } + } +#endif + + output << "[unknown]\n"; + } + + void describeDebug( objRef obj ) { + console::formatter temp; + describe( obj, temp, 0 ); + } + + void arrayMutable::removeAt( size_t idx ) { + remove(pfc::bit_array_one (idx) ) ; + } + + stringRef makeString( const wchar_t * str ) { + return new service_impl_t(str); + } + + stringRef makeString( const wchar_t * str, size_t len ) { + return new service_impl_t(str, len); + } +} + +namespace { + using namespace fb2k; + class objReceiverImpl : public objReceiver { + public: + objReceiverImpl( const objReceiverFunc_t & f ) : m_func(f) {} + void receiveObj(objRef obj) { + m_func(obj); + } + + objReceiverFunc_t m_func; + }; + + class callOnReleaseImpl : public service_base { + public: + callOnReleaseImpl( std::function f_) : f(f_) {} + std::function f; + + ~callOnReleaseImpl () { + try { + f(); + } catch(...) {} + } + }; + + class arrayDeferred : public array { + public: + arrayDeferred( std::function f ) : m_func(f) {} + size_t count() const { + init(); + return m_chain->count(); + } + objRef itemAt( size_t index ) const { + init(); + return m_chain->itemAt( index ); + } + private: + mutable std::once_flag m_once; + mutable std::function< arrayRef () > m_func; + mutable arrayRef m_chain; + void init() const { + std::call_once( m_once, [this] { + m_chain = m_func(); + } ); + } + }; +} + +namespace fb2k { + + objReceiverRef makeObjReceiver( objReceiverFunc_t f ) { + return new service_impl_t< objReceiverImpl > ( f ); + } + + objRef callOnRelease( std::function< void () > f) { + return new service_impl_t< callOnReleaseImpl > (f); + } + objRef callOnReleaseInMainThread( std::function< void () > f) { + return callOnRelease( [f] { + fb2k::inMainThread2( f ); + }); + } + arrayRef makeArrayDeferred( std::function< arrayRef () > f ) { + return new service_impl_t ( f ); + } +} + +namespace fb2k { + objRef array::firstItem() const { + size_t n = this->count(); + if ( n == 0 ) return nullptr; + return this->itemAt( 0 ); + } + + objRef array::lastItem() const { + size_t n = this->count(); + if ( n == 0 ) return nullptr; + return this->itemAt( n - 1 ); + } + + size_t array::indexOfItem(objRef item) { + const size_t m = this->count(); + for( size_t n = 0; n < m; ++n ) { + auto obj = this->itemAt( n ); + if ( obj == item ) return n; + } + return SIZE_MAX; + } + + array::ptr array::subset( pfc::bit_array const & mask ) const { + auto out = arrayMutable::empty(); + mask.walk( this->size(), [=] ( size_t w ) { + out->add( this->itemAt( w ) ); + } ); + return out->makeConst(); + } + + array::ptr array::subsetExcluding(const pfc::bit_array & mask) const { + return subset(pfc::bit_array_not(mask) ); + } + array::ptr array::subsetExcludingSingle( size_t index ) const { + return subsetExcluding(pfc::bit_array_one(index ) ); + } +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/commonObjects.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/commonObjects.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,298 @@ +#pragma once + +#include +#include +#include +#include "completion_notify.h" + +namespace fb2k { + typedef service_ptr objRef; + + template class array_typed; + template class array_soft_typed; + + class NOVTABLE array : public service_base, public pfc::list_base_const_t { + FB2K_MAKE_SERVICE_INTERFACE( array, service_base ); + public: + virtual size_t count() const = 0; + size_t size() const {return count();} + virtual objRef itemAt( size_t index ) const = 0; + + objRef firstItem( ) const; + objRef lastItem( ) const; + + objRef operator[] (size_t idx) const {return itemAt(idx);} + + array::ptr arrayReordered( size_t const * order, size_t count ); + + array::ptr copy() const; + //! If this is a mutable array, creates a const copy of it. \n + //! Otherwise returns this object. + array::ptr makeConst() const; + + static array::ptr empty(); + static array::ptr arrayWithArray( array::ptr source ); + static array::ptr arrayWithObject( objRef source ); + static array::ptr arrayWithObjects( objRef const * source, size_t count ); + static array::ptr arrayWithObjects(std::initializer_list< objRef > const&); + + size_t indexOfItem( objRef item ); + + array::ptr subset( pfc::bit_array const & mask ) const; + array::ptr subsetExcluding( pfc::bit_array const & mask ) const; + array::ptr subsetExcludingSingle( size_t index ) const; + + // UNSAFE CAST HELPER + // Use only when documented as allowed + template + const pfc::list_base_const_t< service_ptr_t< interface_t > >& as_list_of() const { + const pfc::list_base_const_t * temp = this; + return *reinterpret_cast > * > (temp); + } + + // TYPED ARRAY HELPER + // Usage: for( auto obj : myArray->typed() ) { ... } + // Expects ALL objects in the array to implement the interface - causes runtime bugcheck if they don't + template + const array_typed& typed() const { return *reinterpret_cast< const array_typed * > (this); } + + // SOFT TYPED ARRAY HELPER + // Usage: for( auto obj : myArray->softTyped() ) { ... } + // Skips objects not implementing the interface. + template + const array_soft_typed& softTyped() const { return *reinterpret_cast *> (this); } + + + // pfc::list_base_const_t<> + t_size get_count() const override {return this->count();} + void get_item_ex(service_ptr& p_out, t_size n) const override { p_out = this->itemAt(n); } + }; + + template class array_typed : public array { + public: + typedef service_ptr_t ptr_t; + class iterator { + public: + static iterator _make(const array* arr, size_t index) { iterator ret; ret.m_arr = arr; ret.m_index = index; return ret; } + void operator++() { ++m_index; } + bool operator==(const iterator& other) const { PFC_ASSERT(m_arr == other.m_arr); return m_index == other.m_index; } + bool operator!=(const iterator& other) const { PFC_ASSERT(m_arr == other.m_arr); return m_index != other.m_index; } + + ptr_t operator*() const { + ptr_t ret; + ret ^= m_arr->itemAt(m_index); + return ret; + } + private: + const array* m_arr; + size_t m_index; + }; + typedef iterator const_iterator; + iterator begin() const { return iterator::_make(this, 0); } + iterator end() const { return iterator::_make(this, this->count()); } + }; + + template class array_soft_typed : public array { + public: + typedef service_ptr_t ptr_t; + class iterator { + public: + static iterator _make(const array* arr, size_t index) { + iterator ret; + ret.m_arr = arr; ret.m_index = index; + ret.m_max = arr->count(); + ret.fetch(); + return ret; + } + void operator++() { ++m_index; fetch(); } + bool operator==(const iterator& other) const { PFC_ASSERT(m_arr == other.m_arr); return m_index == other.m_index; } + bool operator!=(const iterator& other) const { PFC_ASSERT(m_arr == other.m_arr); return m_index != other.m_index; } + + ptr_t operator*() const { + PFC_ASSERT(m_ptr.is_valid()); + return m_ptr; + } + private: + void fetch() { + m_ptr.reset(); + while (m_index < m_max) { + if (m_ptr &= m_arr->itemAt(m_index)) break; + ++m_index; + } + } + const array* m_arr; + size_t m_index, m_max; + ptr_t m_ptr; + }; + typedef iterator const_iterator; + iterator begin() const { return iterator::_make(this, 0); } + iterator end() const { return iterator::_make(this, this->count()); } + }; + + class NOVTABLE arrayMutable : public array { + FB2K_MAKE_SERVICE_INTERFACE( arrayMutable, array ); + public: + virtual void remove( pfc::bit_array const & mask ) = 0; + virtual void insert( objRef obj, size_t at ) = 0; + virtual void insertFrom( array::ptr objects, size_t at ) = 0; + virtual void reorder( const size_t * order, size_t count ) = 0; + + virtual void resize( size_t newSize ) = 0; + virtual void setItem( objRef obj, size_t atIndex ) = 0; + + arrayMutable::ptr copy() const; + array::ptr copyConst() const; + + void removeAt( size_t idx ); + void add( objRef obj ) {insert( obj, (size_t)(-1) ) ; } + void addFrom( array::ptr obj ) {insertFrom( obj, (size_t)(-1) ) ; } + static arrayMutable::ptr empty(); + static arrayMutable::ptr arrayWithArray( array::ptr source ); + static arrayMutable::ptr arrayWithObject( objRef source ); + static arrayMutable::ptr arrayWithCapacity(size_t capacity); + }; + + class NOVTABLE string : public service_base { + FB2K_MAKE_SERVICE_INTERFACE( string, service_base ); + public: + virtual const char * c_str() const = 0; + + size_t length() const { return strlen(c_str()); } + bool isEmpty() const { return *c_str() == 0; } + bool equals( const char * other ) const { return strcmp(c_str(), other) == 0; } + bool equals( string::ptr other ) const { return equals(other->c_str()); } + + static string::ptr stringWithString( const char * str ); + static string::ptr stringWithString( string::ptr str ); + static string::ptr stringWithString( const char * str, size_t len ); + static bool equalsNullSafe( string::ptr v1, string::ptr v2 ); + }; + + class NOVTABLE memBlock : public service_base { + FB2K_MAKE_SERVICE_INTERFACE( memBlock, service_base ); + public: + virtual const void * data() const = 0; + virtual size_t size() const = 0; + + const uint8_t * begin() const { return (const uint8_t*) data(); } + const uint8_t * end() const { return begin() + size(); } + + //! Album_art_data compatibility + size_t get_size() { return size(); } + //! Album_art_data compatibility + const void * get_ptr() { return data(); } + + memBlock::ptr copy() const; + + static memBlock::ptr empty(); + static memBlock::ptr blockWithData( const void * inData, size_t inSize); + static memBlock::ptr blockWithBlock( memBlock::ptr block ); + template + static memBlock::ptr blockWithVector(const vec_t & vec) { + auto size = vec.size(); + if (size == 0) return empty(); + return blockWithData(&vec[0], size * sizeof(vec[0])); + } + + //! Create an object that takes ownership of this memory, without copying it; will call free() when done. + static memBlock::ptr blockWithDataTakeOwnership(void * inData, size_t inSize); + static memBlock::ptr blockWithData(pfc::mem_block const &); + static memBlock::ptr blockWithData(pfc::mem_block && ); + + //! Determine whether two memBlock objects store the same content. + static bool equals(memBlock const & v1, memBlock const & v2) { + const t_size s = v1.size(); + if (s != v2.size()) return false; + return memcmp(v1.data(), v2.data(),s) == 0; + } + static bool equals(ptr const& v1, ptr const& v2) { + if (v1.is_valid() != v2.is_valid()) return false; + if (v1.is_empty() && v2.is_empty()) return true; + return equals(*v1, *v2); + } + + bool operator==(const memBlock & other) const {return equals(*this,other);} + bool operator!=(const memBlock & other) const {return !equals(*this,other);} + + }; + + class NOVTABLE memBlockMutable : public memBlock { + FB2K_MAKE_SERVICE_INTERFACE( memBlockMutable, memBlock ); + public: + virtual void * dataMutable() = 0; + + //! Resizes preserving content. When expanding, contents of newly allocated area are undefined. + virtual void resize( size_t size ) = 0; + //! Resizes without preserving content. Contents undefined afterwards. + virtual void resizeDiscard( size_t size ) { resize( size ); } + + memBlockMutable::ptr copy() const; + memBlock::ptr copyConst() const; + static memBlockMutable::ptr empty(); + static memBlockMutable::ptr blockWithSize( size_t initSize ); + static memBlockMutable::ptr blockWithData( const void * inData, size_t inSize ); + static memBlockMutable::ptr blockWithBlock( memBlock::ptr block ); + + bool operator==(const memBlockMutable & other) const {return equals(*this,other);} + bool operator!=(const memBlockMutable & other) const {return !equals(*this,other);} + }; + + + //! Asynchronous object return helper. \n + //! If the operation has failed for some reason, receiveObj() will be called with null object. + class objReceiver : public service_base { + FB2K_MAKE_SERVICE_INTERFACE( objReceiver, service_base ); + public: + virtual void receiveObj( objRef obj ) = 0; + }; + + typedef objReceiver::ptr objReceiverRef; + + + typedef ::completion_notify completionNotify; + typedef completionNotify::ptr completionNotifyRef; + typedef array::ptr arrayRef; + typedef arrayMutable::ptr arrayMutableRef; + typedef string::ptr stringRef; + typedef memBlock::ptr memBlockRef; + typedef memBlockMutable::ptr memBlockMutableRef; + + stringRef makeString( const wchar_t * str ); + stringRef makeString( const wchar_t * str, size_t len ); + + inline stringRef makeString( const char * str ) { + return string::stringWithString ( str ); + } + inline stringRef makeString( const char * str, size_t len) { + return string::stringWithString ( str, len ); + } + inline arrayRef makeArray( std::initializer_list const & arg ) { + return array::arrayWithObjects( arg ); + } + inline memBlockRef makeMemBlock( const void * data, size_t size ) { + return memBlock::blockWithData( data, size ); + } + + void describe( objRef obj, pfc::string_formatter & output, unsigned indent); + void describeDebug( objRef obj ); + + + typedef std::function< void (objRef) > objReceiverFunc_t; + + objReceiverRef makeObjReceiver( objReceiverFunc_t ); + + template objReceiverRef makeObjReceiverTyped(std::function< void(service_ptr_t) > func) { + return makeObjReceiver([=](objRef obj) { + if (obj.is_empty()) func(nullptr); + else { + service_ptr_t temp; temp ^= obj; func(temp); + } + }); + } + + objRef callOnRelease( std::function< void () > ); + objRef callOnReleaseInMainThread( std::function< void () > ); + + arrayRef makeArrayDeferred( std::function< arrayRef () > f ); +} +inline pfc::string_base & operator<<(pfc::string_base & p_fmt, fb2k::stringRef str) { p_fmt.add_string(str->c_str()); return p_fmt; } diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/completion_notify.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/completion_notify.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,75 @@ +#include "foobar2000-sdk-pch.h" +#include "completion_notify.h" +#include "main_thread_callback.h" + +void completion_notify::g_signal_completion_async(completion_notify_ptr p_notify,unsigned p_code) { + if (p_notify.is_valid()) { + fb2k::inMainThread([p_notify, p_code] { p_notify->on_completion(p_code); }); + } +} + +void completion_notify::on_completion_async(unsigned p_code) { + g_signal_completion_async(this, p_code); +} + + +completion_notify::ptr completion_notify_receiver::create_or_get_task(unsigned p_id) { + completion_notify_orphanable_ptr ptr; + if (!m_tasks.query(p_id,ptr)) { + ptr = completion_notify_create(this,p_id); + m_tasks.set(p_id,ptr); + } + return ptr; +} + +completion_notify_ptr completion_notify_receiver::create_task(unsigned p_id) { + completion_notify_orphanable_ptr ptr; + if (m_tasks.query(p_id,ptr)) ptr->orphan(); + ptr = completion_notify_create(this,p_id); + m_tasks.set(p_id,ptr); + return ptr; +} + +bool completion_notify_receiver::have_task(unsigned p_id) const { + return m_tasks.have_item(p_id); +} + +void completion_notify_receiver::orphan_task(unsigned p_id) { + completion_notify_orphanable_ptr ptr; + if (m_tasks.query(p_id,ptr)) { + ptr->orphan(); + m_tasks.remove(p_id); + } +} + +completion_notify_receiver::~completion_notify_receiver() { + orphan_all_tasks(); +} + +void completion_notify_receiver::orphan_all_tasks() { + m_tasks.enumerate(orphanfunc); + m_tasks.remove_all(); +} + +namespace { + using namespace fb2k; + + class completion_notify_func : public completion_notify { + public: + void on_completion(unsigned p_code) noexcept override { + m_func(p_code); + } + + completionNotifyFunc_t m_func; + }; +} + +namespace fb2k { + + completion_notify::ptr makeCompletionNotify( completionNotifyFunc_t func ) { + auto n = fb2k::service_new< completion_notify_func >(); + n->m_func = func; + return n; + } + +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/completion_notify.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/completion_notify.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,86 @@ +#pragma once + +#include + +//! Generic service for receiving notifications about async operation completion. Used by various other services. +class completion_notify : public service_base { +public: + //! Called when an async operation has been completed. Note that on_completion is always called from main thread. You can use on_completion_async() helper if you need to signal completion while your context is in another thread.\n + //! IMPLEMENTATION WARNING: If process being completed creates a window taking caller's window as parent, you must not destroy the parent window inside on_completion(). If you need to do so, use PostMessage() or main_thread_callback to delay the deletion. + //! IMPLEMENTATION NOTE: on_completion() couldn't be declared noexcept in base class for historical reasons, but it's recommended that your overrides of on_completion() are noexcept. + //! @param p_code Context-specific status code. Possible values depend on the operation being performed. + virtual void on_completion(unsigned p_code) = 0; + + //! Helper. Queues a notification, using main_thread_callback. + void on_completion_async(unsigned p_code); + + //! Helper. Checks for null ptr and calls on_completion_async when the ptr is not null. + static void g_signal_completion_async(service_ptr_t p_notify,unsigned p_code); + + FB2K_MAKE_SERVICE_INTERFACE(completion_notify,service_base); +}; + +//! Implementation helper. +class completion_notify_dummy : public completion_notify { +public: + void on_completion(unsigned) override {} +}; + +//! Implementation helper. +class completion_notify_orphanable : public completion_notify { +public: + virtual void orphan() = 0; +}; + +//! Helper implementation. +//! IMPLEMENTATION WARNING: If process being completed creates a window taking caller's window as parent, you must not destroy the parent window inside on_task_completion(). If you need to do so, use PostMessage() or main_thread_callback to delay the deletion. +template +class completion_notify_impl : public completion_notify_orphanable { +public: + void on_completion(unsigned p_code) { + if (m_receiver != NULL) { + m_receiver->on_task_completion(m_taskid,p_code); + } + } + void setup(t_receiver * p_receiver, unsigned p_task_id) {m_receiver = p_receiver; m_taskid = p_task_id;} + void orphan() {m_receiver = NULL; m_taskid = 0;} +private: + t_receiver * m_receiver; + unsigned m_taskid; +}; + +template +service_nnptr_t completion_notify_create(t_receiver * p_receiver,unsigned p_taskid) { + service_nnptr_t > instance = new service_impl_t >(); + instance->setup(p_receiver,p_taskid); + return instance; +} + +typedef service_ptr_t completion_notify_ptr; +typedef service_ptr_t completion_notify_orphanable_ptr; +typedef service_nnptr_t completion_notify_nnptr; +typedef service_nnptr_t completion_notify_orphanable_nnptr; + +//! Helper base class for classes that manage nonblocking tasks and get notified back thru completion_notify interface. +class completion_notify_receiver { +public: + completion_notify::ptr create_or_get_task(unsigned p_id); + completion_notify_ptr create_task(unsigned p_id); + bool have_task(unsigned p_id) const; + void orphan_task(unsigned p_id); + ~completion_notify_receiver(); + void orphan_all_tasks(); + + virtual void on_task_completion(unsigned p_id,unsigned p_status) {(void)p_id;(void)p_status;} +private: + static void orphanfunc(unsigned,completion_notify_orphanable_nnptr p_item) {p_item->orphan();} + pfc::map_t m_tasks; +}; + +namespace fb2k { + + typedef std::function completionNotifyFunc_t; + + //! Modern completion_notify helper + completion_notify::ptr makeCompletionNotify( completionNotifyFunc_t ); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/component.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/component.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,56 @@ +#include "foobar2000.h" + +// This is a helper class that gets reliably static-instantiated in all components so any special code that must be executed on startup can be shoved into its constructor. +class foobar2000_component_globals { +public: + foobar2000_component_globals() { +#if defined(_MSC_VER) && !defined(_DEBUG) && !defined(_DLL) + // only with MSVC, non release build, static runtime + ::OverrideCrtAbort(); +#endif + } +}; + +class NOVTABLE foobar2000_client +{ +public: + typedef service_factory_base* pservice_factory_base; + + enum { + FOOBAR2000_CLIENT_VERSION_COMPATIBLE = FOOBAR2000_TARGET_VERSION_COMPATIBLE, + FOOBAR2000_CLIENT_VERSION = FOOBAR2000_TARGET_VERSION, + }; + virtual t_uint32 get_version() = 0; + virtual pservice_factory_base get_service_list() = 0; + + virtual void get_config(stream_writer * p_stream,abort_callback & p_abort) = 0; + virtual void set_config(stream_reader * p_stream,abort_callback & p_abort) = 0; + virtual void set_library_path(const char * path,const char * name) = 0; + virtual void services_init(bool val) = 0; + virtual bool is_debug() = 0; +protected: + foobar2000_client() {} + ~foobar2000_client() {} +}; + +class NOVTABLE foobar2000_api { +public: + virtual service_class_ref service_enum_find_class(const GUID & p_guid) = 0; + virtual bool service_enum_create(service_ptr_t & p_out,service_class_ref p_class,t_size p_index) = 0; + virtual t_size service_enum_get_count(service_class_ref p_class) = 0; + virtual fb2k::hwnd_t get_main_window()=0; + virtual bool assert_main_thread()=0; + virtual bool is_main_thread()=0; + virtual bool is_shutting_down()=0; + virtual const char * get_profile_path()=0; + virtual bool is_initializing() = 0; + + //New in 0.9.6 + virtual bool is_portable_mode_enabled() = 0; + virtual bool is_quiet_mode_enabled() = 0; +protected: + foobar2000_api() {} + ~foobar2000_api() {} +}; + +extern foobar2000_api * g_foobar2000_api; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/component_client.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/component_client.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,6 @@ +#ifndef _COMPONENT_CLIENT_H_ +#define _COMPONENT_CLIENT_H_ + + + +#endif //_COMPONENT_CLIENT_H_ \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/components_menu.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/components_menu.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,7 @@ +#ifndef _COMPONENTS_MENU_H_ +#define _COMPONENTS_MENU_H_ + +#error deprecated, see menu_item.h + + +#endif \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/componentversion.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/componentversion.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,46 @@ +#include "foobar2000-sdk-pch.h" + +#ifdef _WIN32 +#include "componentversion.h" +#include "filesystem.h" +#include "console.h" + +bool component_installation_validator::test_my_name(const char * fn) { + const char * path = core_api::get_my_full_path(); + path += pfc::scan_filename(path); + bool retVal = ( strcmp(path, fn) == 0 ); + PFC_ASSERT( retVal ); + if (!retVal) uAddDebugEvent(pfc::format("Component rename detected: ", fn, " >> ", path)); + return retVal; +} +bool component_installation_validator::have_other_file(const char * fn) { + for(int retry = 0;;) { + pfc::string_formatter path = core_api::get_my_full_path(); + path.truncate(path.scan_filename()); + path << fn; + try { + try { + bool v = filesystem::g_exists(path, fb2k::noAbort); + PFC_ASSERT( v ); + return v; + } catch(std::exception const & e) { + FB2K_console_formatter() << "Component integrity check error: " << e << " (on: " << fn << ")"; + throw; + } + } catch(exception_io_denied const &) { + + } catch(exception_io_sharing_violation const &) { + + } catch(exception_io_file_corrupted const &) { // happens + return false; + } catch(...) { + uBugCheck(); + } + if (++retry == 10) uBugCheck(); + + Sleep(100); + } +} + +#endif // _WIN32 + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/componentversion.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/componentversion.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,103 @@ +#pragma once + +//! Entrypoint interface for declaring component's version information. Instead of implementing this directly, use DECLARE_COMPONENT_VERSION(). +class NOVTABLE componentversion : public service_base { +public: + virtual void get_file_name(pfc::string_base & out)=0; + virtual void get_component_name(pfc::string_base & out)=0; + virtual void get_component_version(pfc::string_base & out)=0; + virtual void get_about_message(pfc::string_base & out)=0;//about message uses "\n" for line separators + + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(componentversion); +}; + +//! Implementation helper. You typically want to use DECLARE_COMPONENT_VERSION() instead. +class componentversion_impl_simple : public componentversion { + const char * name,*version,*about; +public: + //do not derive/override + virtual void get_file_name(pfc::string_base & out) {out.set_string(core_api::get_my_file_name());} + virtual void get_component_name(pfc::string_base & out) {out.set_string(name?name:"");} + virtual void get_component_version(pfc::string_base & out) {out.set_string(version?version:"");} + virtual void get_about_message(pfc::string_base & out) {out.set_string(about?about:"");} + explicit componentversion_impl_simple(const char * p_name,const char * p_version,const char * p_about) : name(p_name), version(p_version), about(p_about ? p_about : "") {} +}; + +//! Implementation helper. You typically want to use DECLARE_COMPONENT_VERSION() instead. +class componentversion_impl_copy : public componentversion { + pfc::string8 name,version,about; +public: + //do not derive/override + virtual void get_file_name(pfc::string_base & out) {out.set_string(core_api::get_my_file_name());} + virtual void get_component_name(pfc::string_base & out) {out.set_string(name);} + virtual void get_component_version(pfc::string_base & out) {out.set_string(version);} + virtual void get_about_message(pfc::string_base & out) {out.set_string(about);} + explicit componentversion_impl_copy(const char * p_name,const char * p_version,const char * p_about) : name(p_name), version(p_version), about(p_about ? p_about : "") {} +}; + +typedef service_factory_single_transparent_t __componentversion_impl_simple_factory; +typedef service_factory_single_transparent_t __componentversion_impl_copy_factory; + +class componentversion_impl_simple_factory : public __componentversion_impl_simple_factory { +public: + componentversion_impl_simple_factory(const char * p_name,const char * p_version,const char * p_about) : __componentversion_impl_simple_factory(p_name,p_version,p_about) {} +}; + +class componentversion_impl_copy_factory : public __componentversion_impl_copy_factory { +public: + componentversion_impl_copy_factory(const char * p_name,const char * p_version,const char * p_about) : __componentversion_impl_copy_factory(p_name,p_version,p_about) {} +}; + +//! Use this to declare your component's version information. Parameters must ba plain const char * string constants. \n +//! You should have only one DECLARE_COMPONENT_VERSION() per component DLL. Having more than one will confuse component updater's version matching. \n +//! Please keep your version numbers formatted as: N[.N[.N....]][ alpha|beta|RC[ N[.N...]] \n +//! Sample version numbers, in ascending order: 0.9 < 0.10 < 1.0 alpha 1 < 1.0 alpha 2 < 1.0 beta 1 < 1.0 RC < 1.0 RC1 < 1.0 < 1.1 < 1.10 \n +//! For a working sample of how foobar2000 sorts version numbers, see http://www.foobar2000.org/versionator.php \n +//! Example: DECLARE_COMPONENT_VERSION("blah","1.3.3.7","") +#define DECLARE_COMPONENT_VERSION(NAME,VERSION,ABOUT) \ + namespace {class componentversion_myimpl : public componentversion { public: componentversion_myimpl() {PFC_ASSERT( ABOUT );} \ + void get_file_name(pfc::string_base & out) {out = core_api::get_my_file_name();} \ + void get_component_name(pfc::string_base & out) {out = NAME;} \ + void get_component_version(pfc::string_base & out) {out = VERSION;} \ + void get_about_message(pfc::string_base & out) {out = ABOUT;} \ + }; static service_factory_single_t g_componentversion_myimpl_factory; } + // static componentversion_impl_simple_factory g_componentversion_service(NAME,VERSION,ABOUT); + +//! Same as DECLARE_COMPONENT_VERSION(), but parameters can be dynamically generated strings rather than compile-time constants. +#define DECLARE_COMPONENT_VERSION_COPY(NAME,VERSION,ABOUT) \ + static componentversion_impl_copy_factory g_componentversion_service(NAME,VERSION,ABOUT); + + +//! \since 1.0 +//! Allows components to cleanly abort app startup in case the installation appears to have become corrupted. +class component_installation_validator : public service_base { +public: + virtual bool is_installed_correctly() = 0; + + static bool test_my_name(const char * fn); + static bool have_other_file(const char * fn); + + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(component_installation_validator) +}; + +#ifdef _WIN32 +//! Simple implementation of component_installation_validator that makes sure that our component DLL has not been renamed around by idiot users. +class component_installation_validator_filename : public component_installation_validator { +public: + component_installation_validator_filename(const char * dllName) : m_dllName(dllName) {} + bool is_installed_correctly() { + return test_my_name(m_dllName); + } +private: + const char * const m_dllName; +}; + +#define VALIDATE_COMPONENT_FILENAME(FN) \ + static service_factory_single_t g_component_installation_validator_filename(FN); + +#else // _WIN32 + +#define VALIDATE_COMPONENT_FILENAME(FN) + +#endif // _WIN32 + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/configCache.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/configCache.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,41 @@ +#pragma once +#include +#include + +namespace fb2k { + // cache of config values + // STATIC USE ONLY + class configBoolCache { + public: + configBoolCache(const char* var, bool def = false) : m_var(var), m_def(def) {} + bool get(); + operator bool() { return get(); } + void set(bool); + void operator=(bool v) { set(v); } + + configBoolCache(const configBoolCache&) = delete; + void operator=(const configBoolCache&) = delete; + private: + const char* const m_var; + const bool m_def; + std::atomic_bool m_value = { false }; + std::once_flag m_init; + }; + + class configIntCache { + public: + configIntCache(const char* var, int64_t def = 0) : m_var(var), m_def(def) {} + int64_t get(); + operator int64_t() { return get(); } + void set(int64_t); + void operator=(int64_t v) { set(v); } + + configIntCache(const configIntCache&) = delete; + void operator=(const configIntCache&) = delete; + private: + const char* const m_var; + const int64_t m_def; + std::atomic_int64_t m_value = { 0 }; + std::once_flag m_init; + }; +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/configStore.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/configStore.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,164 @@ +#include "foobar2000-sdk-pch.h" +#include "configStore.h" +#ifdef FOOBAR2000_MOBILE +#include "appearance.h" +#endif + +using namespace fb2k; + +namespace { + class configStoreNotifyImpl : public configStoreNotify { + public: + void onVarChange() { f(); } + std::function< void() > f; + }; +} + +objRef configStore::addNotify( const char * name, std::function f ) { + auto nameRef = makeString(name); + ptr self = this; + auto obj = new configStoreNotifyImpl; + obj->f = f; + this->addNotify(name, obj ); + return callOnRelease([self, nameRef, obj] { + self->removeNotify( nameRef->c_str(), obj ); + delete obj; + }); +} +void configStore::addPermanentNotify( const char * name, std::function f ) { + auto obj = new configStoreNotifyImpl; + obj->f = f; + this->addNotify(name, obj ); +} + +bool configStore::getConfigBool( const char * name, bool defVal ) { + return this->getConfigInt( name, defVal ? 1 : 0) != 0; +} + +bool configStore::toggleConfigBool (const char * name, bool defVal ) { + bool newVal = ! getConfigBool(name, defVal); + setConfigBool( name, newVal ); + return newVal; +} + +void configStore::setConfigBool( const char * name, bool val ) { + this->setConfigInt( name, val ? 1 : 0 ); +} +void configStore::deleteConfigBool( const char * name ) { + this->deleteConfigInt( name ); +} + +GUID configStore::getConfigGUID(const char* name, const GUID& defVal) { + auto str = this->getConfigString(name, nullptr); + if (str.is_empty()) return defVal; + try { + return pfc::GUID_from_text(str->c_str()); + } catch (...) { + return defVal; + } +} + +void configStore::setConfigGUID(const char* name, const GUID& val) { + this->setConfigString(name, pfc::print_guid(val)); +} + +void configStore::deleteConfigGUID(const char* name) { + this->deleteConfigString(name); +} + + +configEventHandle_t configEvent::operator+=(std::function< void() > f) const { + auto obj = new configStoreNotifyImpl; + obj->f = f; + try { + static_api_ptr_t()->addNotify(m_name, obj); + } catch (...) { + delete obj; throw; + } + return reinterpret_cast(obj); +} + +void configEvent::operator-=(configEventHandle_t h) const { + auto obj = reinterpret_cast(h); + if ( core_api::are_services_available() ) { + static_api_ptr_t()->removeNotify(m_name, obj); + } + delete obj; +} + +configEventRef & configEventRef::operator<< ( const char * name ) { m_name = name; return *this; } + +configEventRef & configEventRef::operator<< ( std::function f ) { + setFunction(f); + return *this; +} + +configEventRef::~configEventRef() { + try { + clear(); + } catch(...) { + // corner case: called from worker while app is shutting down, don't crash + } +} + +void configEventRef::clear() { + if (m_handle != nullptr) { + configEvent( m_name ) -= m_handle; + m_handle = nullptr; + } +} +void configEventRef::set( const char * name, std::function f ) { + clear(); + m_name = name; + m_handle = configEvent( m_name ) += f; +} + +void configEventRef::setName( const char * name ) { + clear(); + m_name = name; +} + +void configEventRef::setFunction(std::function f) { + clear(); + PFC_ASSERT( m_name.length() > 0 ); + m_handle = configEvent( m_name ) += f; +} + +#ifdef FOOBAR2000_MOBILE +namespace { + class appearanceChangeNoitfyImpl : public appearanceChangeNoitfy { + public: + + void onAppearanceChange() { + f(); + } + + std::function f; + }; +} + +appearance::notifyHandle_t appearance::addNotify2( std::function f) { + auto ret = new appearanceChangeNoitfyImpl(); + ret->f = f; + addNotify(ret); + return reinterpret_cast(ret); +} +void appearance::removeNotify2( appearance::notifyHandle_t h ) { + auto obj = reinterpret_cast(h); + removeNotify(obj); + delete obj; +} + +void appearanceChangeNotifyRef::set( std::function f ) { + clear(); + handle = static_api_ptr_t()->addNotify2(f); +} +void appearanceChangeNotifyRef::clear() { + if (isSet()) { + if ( core_api::are_services_available() ) { + static_api_ptr_t()->removeNotify2(handle); + } + handle = nullptr; + } +} +#endif diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/configStore.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/configStore.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,177 @@ +#pragma once + +#define FOOBAR2000_HAVE_CONFIGSTORE FOOBAR2020 + +#include +#include "commonObjects.h" + +namespace fb2k { + +class configStoreNotify { +public: + virtual void onVarChange() = 0; +}; + +typedef void * configStoreNotifyHandle_t; + +//! \since 2.0 +//! Interface to access foobar2000's configuration store, backed by SQLite database. \n +//! get* methods can be called at any time. set*/delete* \n +//! set*/delete* methods will trigger immediate commit when invoked without a transaction scope. \n +//! Use commitBlocking() to commit synchronously to be sure that the data has been flushed before continuing execution. +class configStore : public service_base { + FB2K_MAKE_SERVICE_COREAPI( configStore ); +public: + //! Causes multiple writes to be chained together. \n + //! Use of this is no longer essential since late foobar2000 v2.0 betas, as delay-write cache is always used. \n + //! You can still use it to guarantee that multiple updates are written together, that is either all or none are saved, should the system or application crash. + virtual fb2k::objRef acquireTransactionScope() = 0; + + //! Synchronously flushes changes to disk. Doesn't return until changes have actually been written. \n + //! Use of this is strongly recommended against. + virtual void commitBlocking() = 0; + + virtual int64_t getConfigInt( const char * name, int64_t defVal = 0 ) = 0; + virtual void setConfigInt( const char * name, int64_t val ) = 0; + virtual void deleteConfigInt(const char * name) = 0; + + virtual fb2k::stringRef getConfigString( const char * name, fb2k::stringRef defaVal = fb2k::string::stringWithString("")) = 0; + virtual void setConfigString( const char * name, const char * value ) = 0; + virtual void deleteConfigString(const char * name) = 0; + + virtual fb2k::memBlockRef getConfigBlob( const char * name, fb2k::memBlockRef defVal = fb2k::memBlock::empty()) = 0; + virtual void setConfigBlob(const char* name, const void* ptr, size_t bytes) = 0; + virtual void setConfigBlob(const char* name, fb2k::memBlockRef val) = 0; + virtual void deleteConfigBlob(const char * name) = 0; + + virtual double getConfigFloat( const char * name, double defVal = 0) = 0; + virtual void setConfigFloat( const char * name, double val ) = 0; + virtual void deleteConfigFloat( const char * name ) = 0; + + virtual void addNotify(const char * name, configStoreNotify * notify) = 0; + virtual void removeNotify(const char * name, configStoreNotify * notify) = 0; + + //! Lists values of any type in the specified domain. + //! For an example, calling with domain "foo" will return all foo.* keys, such as: foo.bar, foo.bar.2000, foo.asdf. Will not return "foobar". + virtual fb2k::arrayRef listDomainValues(const char* domain, bool withSubdomains) = 0; + + objRef addNotify( const char * name, std::function f ); + void addPermanentNotify( const char * name, std::function f ); + + //! Helper around getConfigInt. + bool getConfigBool( const char * name, bool defVal = false ); + //! Helper around setConfigInt. + void setConfigBool( const char * name, bool val ); + //! Helper around setConfigInt. + bool toggleConfigBool (const char * name, bool defVal = false ); + //! Helper around deleteConfigInt. + void deleteConfigBool( const char * name ); + + //! Helper around getConfigString. + GUID getConfigGUID(const char* name, const GUID& defVal = pfc::guid_null); + //! Helper around setConfigString. + void setConfigGUID(const char* name, const GUID& val); + //! Helper around deleteConfigString. + void deleteConfigGUID(const char* name); + + //! For internal core use, notifies everyone interested about off-process change to configuration data. + virtual void callNotify(const char * name) = 0; + + fb2k::stringRef getConfigString( const char * name, const char * defVal ) { return getConfigString(name, defVal ? fb2k::makeString(defVal) : nullptr); } + fb2k::stringRef getConfigString( const char * name, std::nullptr_t ) { return getConfigString(name, fb2k::stringRef ( nullptr ) ); } +}; + +struct configEventHandle_; +typedef configEventHandle_ * configEventHandle_t; + +class configEvent { +public: + configEvent(const char * name) : m_name(name) {} + configEventHandle_t operator+=(std::function< void() >) const; + void operator-=(configEventHandle_t) const; +private: + const char * const m_name; +}; + +class configEventRef { +public: + configEventRef() : m_name(), m_handle() {} + ~configEventRef(); + configEventRef & operator<< ( const char * name ); + configEventRef & operator<< ( std::function f ); + void clear(); + void set( const char * name, std::function f ); + void setName( const char * name ); + void setFunction( std::function f); + bool isActive() const { return m_handle != nullptr; } +private: + pfc::string8 m_name; + configEventHandle_t m_handle; + + configEventRef( const configEventRef & ) = delete; + void operator=( const configEventRef & ) = delete; +}; +/* +Usage example: +using namespace fb2k; +static_api_ptr_t api; +stringRef val = api->getConfigString( "myComponent.foo", "defaultVal" ); + + { + auto scope = api->acquireTransactionScope(); + int64_t v = api->getConfigInt("myComponent.somevar" ); + v ++; + api->setConfigInt("myComponent.somevar", v); + api->setConfigString("myComponent.foo", "bar" ); + // commit is triggered when leaving scope + + // If you want to deterministically ensure that the data has been written before leaving scope, + // for an example when another process is about to read it, + // use api->commitBlocking() + } +*/ + + +//! \since 2.2 +class configStore2 : public configStore { + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(configStore2, configStore); +public: + // Use flagSuppressCache to prevent value from being cached. Prevents memory usage creep if querying lots of uniquely named variables. + static constexpr uint32_t flagSuppressCache = 1; + + virtual int64_t getConfigInt2( const char * name, int64_t defVal = 0, uint32_t flags = 0 ) = 0; + virtual void setConfigInt2( const char * name, int64_t val, uint32_t flags = 0 ) = 0; + virtual void deleteConfigInt2(const char * name, uint32_t flags = 0) = 0; + + virtual fb2k::stringRef getConfigString2( const char * name, fb2k::stringRef defaVal = fb2k::string::stringWithString(""), uint32_t flags = 0) = 0; + virtual void setConfigString2( const char * name, const char * value, uint32_t flags = 0 ) = 0; + virtual void deleteConfigString2(const char * name, uint32_t flags = 0) = 0; + + virtual fb2k::memBlockRef getConfigBlob2( const char * name, fb2k::memBlockRef defVal = fb2k::memBlock::empty(), uint32_t flags = 0) = 0; + virtual void setConfigBlob2(const char* name, const void* ptr, size_t bytes, uint32_t flags = 0) = 0; + virtual void setConfigBlob2(const char* name, fb2k::memBlockRef val, uint32_t flags = 0) = 0; + virtual void deleteConfigBlob2(const char * name, uint32_t flags = 0) = 0; + + virtual double getConfigFloat2( const char * name, double defVal = 0, uint32_t flags = 0) = 0; + virtual void setConfigFloat2( const char * name, double val, uint32_t flags = 0) = 0; + virtual void deleteConfigFloat2( const char * name, uint32_t flags = 0) = 0; + + + int64_t getConfigInt( const char * name, int64_t defVal ) override final { return getConfigInt2(name, defVal); } + void setConfigInt( const char * name, int64_t val ) override final { setConfigInt2(name, val); } + void deleteConfigInt(const char * name) override final { deleteConfigInt2(name); } + + fb2k::stringRef getConfigString( const char * name, fb2k::stringRef defaVal) override final { return getConfigString2(name, defaVal); } + void setConfigString( const char * name, const char * value ) override final { setConfigString2(name, value); } + void deleteConfigString(const char * name) override final { deleteConfigString2(name); } + + fb2k::memBlockRef getConfigBlob( const char * name, fb2k::memBlockRef defVal ) override final { return getConfigBlob2(name, defVal); } + void setConfigBlob(const char* name, const void* ptr, size_t bytes) override final { setConfigBlob2(name, ptr, bytes); } + void setConfigBlob(const char* name, fb2k::memBlockRef val) override final { setConfigBlob2(name, val); } + void deleteConfigBlob(const char * name) override final { deleteConfigBlob2(name); } + + double getConfigFloat( const char * name, double defVal ) override final { return getConfigFloat2(name, defVal); } + void setConfigFloat( const char * name, double val ) override final { setConfigFloat2(name, val); } + void deleteConfigFloat( const char * name ) override final { deleteConfigFloat2(name); } +}; +} // namespace fb2k diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/config_io_callback.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/config_io_callback.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,16 @@ +#include "foobar2000-sdk-pch.h" +#include "filesystem.h" +#include "config_io_callback.h" + +static filesystem::ptr defaultFS() { + return filesystem::get( core_api::get_profile_path() ); +} + +void config_io_callback_v3::on_quicksave() { + this->on_quicksave_v3(defaultFS()); +} +void config_io_callback_v3::on_write(bool bReset) { + auto fs = defaultFS(); + if (bReset) this->on_reset_v3(fs); + else this->on_write_v3(fs); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/config_io_callback.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/config_io_callback.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,45 @@ +#pragma once + +//! Implementing this interface lets you maintain your own configuration files rather than depending on the cfg_var system. \n +//! Note that you must not make assumptions about what happens first: config_io_callback::on_read(), initialization of cfg_var values or config_io_callback::on_read() in other components. Order of these things is undefined and will change with each run. \n +//! Use service_factory_single_t to register your implementations. Do not call other people's implementations, core is responsible for doing that when appropriate. +class NOVTABLE config_io_callback : public service_base { +public: + //! Called on startup. You can read your configuration file from here. \n + //! Hint: use core_api::get_profile_path() to retrieve the path of the folder where foobar2000 configuration files are stored. + virtual void on_read() = 0; + //! Called typically on shutdown but you should expect a call at any point after on_read(). You can write your configuration file from here. + //! Hint: use core_api::get_profile_path() to retrieve the path of the folder where foobar2000 configuration files are stored. + //! @param reset If set to true, our configuration is being reset, so you should wipe your files rather than rewrite them with current configuration. + //! Since foobar2000 v2.0, reset is never issued - profile folder is cleared instead. + virtual void on_write(bool reset) = 0; + + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(config_io_callback); +}; + +//! \since 1.0 +class NOVTABLE config_io_callback_v2 : public config_io_callback { + FB2K_MAKE_SERVICE_INTERFACE(config_io_callback_v2, config_io_callback) +public: + //! Implement optionally. Called to quickly flush recent configuration changes. If your instance of config_io_callback needs to perform timeconsuming tasks when saving, you should skip implementing this method entirely. + virtual void on_quicksave() = 0; +}; + +//! \since 1.4 +//! New methods take a filesystem object that should be used for the update, so the whole config update can be performed as one transacted filesystem operation. \n +//! The core performs necessary checks to ensure that the volume where our profile resides is supports transacted operations. \n +//! However there are odd cases of people junctioning the profile folder and such. We cannot guarantee that your code won't run into such cases. \n +//! If you get a exception_io_transactions_unsupported, let the caller deal with it - your call will be retried with a regular filesystem instead of a transacted one. +class NOVTABLE config_io_callback_v3 : public config_io_callback_v2 { + FB2K_MAKE_SERVICE_INTERFACE(config_io_callback_v3, config_io_callback_v2); +public: + void on_quicksave(); + void on_write(bool bReset); + //! Since foobar2000 v2.0, reset is never issued - profile folder is cleared instead. + virtual void on_reset_v3( filesystem::ptr fs ) = 0; + virtual void on_write_v3( filesystem::ptr fs ) = 0; + virtual void on_quicksave_v3( filesystem::ptr fs ) = 0; +}; + +// For internal use in fb2k core +#define FB2K_PROFILE_CONFIG_READS_WRITES 0 \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/config_object.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/config_object.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,251 @@ +#include "foobar2000-sdk-pch.h" +#include "config_object_impl.h" +#include "configStore.h" + +void config_object_notify_manager::g_on_changed(const service_ptr_t & p_object) +{ + if (core_api::assert_main_thread()) + { + for (auto ptr : enumerate()) { + ptr->on_changed(p_object); + } + } +} + +bool config_object::g_find(service_ptr_t & p_out,const GUID & p_guid) +{ + for (auto ptr : enumerate()) { + if (ptr->get_guid() == p_guid) { + p_out = ptr; + return true; + } + } + return false; +} + +void config_object::g_get_data_string(const GUID & p_guid,pfc::string_base & p_out) +{ + service_ptr_t ptr; + if (!g_find(ptr,p_guid)) throw exception_service_not_found(); + ptr->get_data_string(p_out); +} + +void config_object::g_set_data_string(const GUID & p_guid,const char * p_data,t_size p_length) +{ + service_ptr_t ptr; + if (!g_find(ptr,p_guid)) throw exception_service_not_found(); + ptr->set_data_string(p_data,p_length); +} + +void config_object::get_data_int32(t_int32 & p_out) +{ + t_int32 temp; + get_data_struct_t(temp); + byte_order::order_le_to_native_t(temp); + p_out = temp; +} + +void config_object::set_data_int32(t_int32 p_val) +{ + t_int32 temp = p_val; + byte_order::order_native_to_le_t(temp); + set_data_struct_t(temp); +} + +bool config_object::get_data_bool_simple(bool p_default) { + try { + bool ret = p_default; + get_data_bool(ret); + return ret; + } catch(...) {return p_default;} +} + +t_int32 config_object::get_data_int32_simple(t_int32 p_default) { + try { + t_int32 ret = p_default; + get_data_int32(ret); + return ret; + } catch(...) {return p_default;} +} + +void config_object::g_get_data_int32(const GUID & p_guid,t_int32 & p_out) { + service_ptr_t ptr; + if (!g_find(ptr,p_guid)) throw exception_service_not_found(); + ptr->get_data_int32(p_out); +} + +void config_object::g_set_data_int32(const GUID & p_guid,t_int32 p_val) { + service_ptr_t ptr; + if (!g_find(ptr,p_guid)) throw exception_service_not_found(); + ptr->set_data_int32(p_val); +} + +bool config_object::g_get_data_bool_simple(const GUID & p_guid,bool p_default) +{ + service_ptr_t ptr; + if (!g_find(ptr,p_guid)) throw exception_service_not_found(); + return ptr->get_data_bool_simple(p_default); +} + +t_int32 config_object::g_get_data_int32_simple(const GUID & p_guid,t_int32 p_default) +{ + service_ptr_t ptr; + if (!g_find(ptr,p_guid)) throw exception_service_not_found(); + return ptr->get_data_int32_simple(p_default); +} + +void config_object::get_data_bool(bool & p_out) {get_data_struct_t(p_out);} +void config_object::set_data_bool(bool p_val) {set_data_struct_t(p_val);} + +void config_object::g_get_data_bool(const GUID & p_guid,bool & p_out) {g_get_data_struct_t(p_guid,p_out);} +void config_object::g_set_data_bool(const GUID & p_guid,bool p_val) {g_set_data_struct_t(p_guid,p_val);} + +namespace { + class stream_writer_string : public stream_writer { + public: + void write(const void * p_buffer,t_size p_bytes,abort_callback & p_abort) { + p_abort.check(); + m_out.add_string((const char*)p_buffer,p_bytes); + } + stream_writer_string(pfc::string_base & p_out) : m_out(p_out) {m_out.reset();} + private: + pfc::string_base & m_out; + }; + + class stream_writer_fixedbuffer : public stream_writer { + public: + void write(const void * p_buffer,t_size p_bytes,abort_callback & p_abort) { + p_abort.check(); + if (p_bytes > 0) { + if (p_bytes > m_bytes - m_bytes_read) throw pfc::exception_overflow(); + memcpy((t_uint8*)m_out,p_buffer,p_bytes); + m_bytes_read += p_bytes; + } + } + stream_writer_fixedbuffer(void * p_out,t_size p_bytes,t_size & p_bytes_read) : m_out(p_out), m_bytes(p_bytes), m_bytes_read(p_bytes_read) {m_bytes_read = 0;} + private: + void * m_out; + t_size m_bytes; + t_size & m_bytes_read; + }; + + + + class stream_writer_get_length : public stream_writer { + public: + void write(const void * ,t_size p_bytes,abort_callback & p_abort) override { + p_abort.check(); + m_length += p_bytes; + } + stream_writer_get_length(t_size & p_length) : m_length(p_length) {m_length = 0;} + private: + t_size & m_length; + }; +}; + +t_size config_object::get_data_raw(void * p_out,t_size p_bytes) { + t_size ret = 0; + stream_writer_fixedbuffer stream(p_out,p_bytes,ret); + get_data(&stream,fb2k::noAbort); + return ret; +} + +t_size config_object::get_data_raw_length() { + t_size ret = 0; + stream_writer_get_length stream(ret); + get_data(&stream,fb2k::noAbort); + return ret; +} + +void config_object::set_data_raw(const void * p_data,t_size p_bytes, bool p_notify) { + stream_reader_memblock_ref stream(p_data,p_bytes); + set_data(&stream,fb2k::noAbort,p_notify); +} + +void config_object::set_data_string(const char * p_data,t_size p_length) { + set_data_raw(p_data,pfc::strlen_max(p_data,p_length)); +} + +void config_object::get_data_string(pfc::string_base & p_out) { + stream_writer_string stream(p_out); + get_data(&stream,fb2k::noAbort); +} + + +//config_object_impl stuff + +#if FOOBAR2020 +pfc::string8 config_object_impl::formatName() const { + return pfc::format("config_object.", pfc::print_guid(get_guid())); +} + +void config_object_impl::get_data(stream_writer * p_stream,abort_callback & p_abort) const { + auto blob = fb2k::configStore::get()->getConfigBlob(formatName(), m_initial); + if (blob.is_valid()) p_stream->write(blob->data(), blob->size(), p_abort); +} + +void config_object_impl::set_data(stream_reader * p_stream,abort_callback & p_abort,bool p_notify) { + core_api::ensure_main_thread(); + + { + pfc::mem_block data; + enum {delta = 1024}; + t_uint8 buffer[delta]; + for(;;) + { + t_size delta_done = p_stream->read(buffer,delta,p_abort); + + if (delta_done > 0) + { + data.append_fromptr(buffer,delta_done); + } + + if (delta_done != delta) break; + } + + auto blob = fb2k::memBlock::blockWithData(std::move(data)); + fb2k::configStore::get()->setConfigBlob(formatName(), blob); + } + + if (p_notify) config_object_notify_manager::g_on_changed(this); +} + +config_object_impl::config_object_impl(const GUID & p_guid,const void * p_data,t_size p_bytes) : cfg_var_reader(p_guid) +{ + if (p_bytes > 0) m_initial = fb2k::makeMemBlock(p_data, p_bytes); +} +#else // FOOBAR2020 +void config_object_impl::get_data(stream_writer* p_stream, abort_callback& p_abort) const { + inReadSync(m_sync); + p_stream->write_object(m_data.get_ptr(), m_data.get_size(), p_abort); +} + +void config_object_impl::set_data(stream_reader* p_stream, abort_callback& p_abort, bool p_notify) { + core_api::ensure_main_thread(); + + { + inWriteSync(m_sync); + m_data.set_size(0); + enum { delta = 1024 }; + t_uint8 buffer[delta]; + for (;;) + { + t_size delta_done = p_stream->read(buffer, delta, p_abort); + + if (delta_done > 0) + { + m_data.append_fromptr(buffer, delta_done); + } + + if (delta_done != delta) break; + } + } + + if (p_notify) config_object_notify_manager::g_on_changed(this); +} + +config_object_impl::config_object_impl(const GUID& p_guid, const void* p_data, t_size p_bytes) : cfg_var(p_guid) +{ + m_data.set_data_fromptr((const t_uint8*)p_data, p_bytes); +} +#endif diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/config_object.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/config_object.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,85 @@ +#ifndef _CONFIG_OBJECT_H_ +#define _CONFIG_OBJECT_H_ + +class config_object; + +class NOVTABLE config_object_notify_manager : public service_base +{ +public: + virtual void on_changed(const service_ptr_t & p_object) = 0; + static void g_on_changed(const service_ptr_t & p_object); + + + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(config_object_notify_manager); +}; + +class NOVTABLE config_object : public service_base +{ +public: + //interface + virtual GUID get_guid() const = 0; + virtual void get_data(stream_writer * p_stream,abort_callback & p_abort) const = 0; + virtual void set_data(stream_reader * p_stream,abort_callback & p_abort,bool p_sendnotify = true) = 0; + + //helpers + static bool g_find(service_ptr_t & p_out,const GUID & p_guid); + + void set_data_raw(const void * p_data,t_size p_bytes,bool p_sendnotify = true); + t_size get_data_raw(void * p_out,t_size p_bytes); + t_size get_data_raw_length(); + + template void get_data_struct_t(T& p_out); + template void set_data_struct_t(const T& p_in); + template static void g_get_data_struct_t(const GUID & p_guid,T & p_out); + template static void g_set_data_struct_t(const GUID & p_guid,const T & p_in); + + void set_data_string(const char * p_data,t_size p_length); + void get_data_string(pfc::string_base & p_out); + + void get_data_bool(bool & p_out); + void set_data_bool(bool p_val); + void get_data_int32(t_int32 & p_out); + void set_data_int32(t_int32 p_val); + bool get_data_bool_simple(bool p_default); + t_int32 get_data_int32_simple(t_int32 p_default); + + static void g_get_data_string(const GUID & p_guid,pfc::string_base & p_out); + static void g_set_data_string(const GUID & p_guid,const char * p_data,t_size p_length = ~0); + + static void g_get_data_bool(const GUID & p_guid,bool & p_out); + static void g_set_data_bool(const GUID & p_guid,bool p_val); + static void g_get_data_int32(const GUID & p_guid,t_int32 & p_out); + static void g_set_data_int32(const GUID & p_guid,t_int32 p_val); + static bool g_get_data_bool_simple(const GUID & p_guid,bool p_default); + static t_int32 g_get_data_int32_simple(const GUID & p_guid,t_int32 p_default); + + + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(config_object); +}; + +class standard_config_objects +{ +public: + static const GUID bool_remember_window_positions, bool_ui_always_on_top,bool_playlist_stop_after_current; + static const GUID bool_playback_follows_cursor, bool_cursor_follows_playback; + static const GUID bool_show_keyboard_shortcuts_in_menus; + static const GUID string_gui_last_directory_media,string_gui_last_directory_playlists; + static const GUID int32_dynamic_bitrate_display_rate; + + + inline static bool query_show_keyboard_shortcuts_in_menus() {return config_object::g_get_data_bool_simple(standard_config_objects::bool_show_keyboard_shortcuts_in_menus,true);} + inline static bool query_remember_window_positions() {return config_object::g_get_data_bool_simple(standard_config_objects::bool_remember_window_positions,true);} + +}; + +class config_object_notify : public service_base +{ +public: + virtual t_size get_watched_object_count() = 0; + virtual GUID get_watched_object(t_size p_index) = 0; + virtual void on_watched_object_changed(const service_ptr_t & p_object) = 0; + + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(config_object_notify); +}; + +#endif // _CONFIG_OBJECT_H_ diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/config_object_impl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/config_object_impl.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,97 @@ +#pragma once + +#include "config_object.h" +#include "cfg_var_legacy.h" +//template function bodies from config_object class + +template +void config_object::get_data_struct_t(T& p_out) { + if (get_data_raw(&p_out,sizeof(T)) != sizeof(T)) throw exception_io_data_truncation(); +} + +template +void config_object::set_data_struct_t(const T& p_in) { + return set_data_raw(&p_in,sizeof(T)); +} + +template +void config_object::g_get_data_struct_t(const GUID & p_guid,T & p_out) { + service_ptr_t ptr; + if (!g_find(ptr,p_guid)) throw exception_service_not_found(); + return ptr->get_data_struct_t(p_out); +} + +template +void config_object::g_set_data_struct_t(const GUID & p_guid,const T & p_in) { + service_ptr_t ptr; + if (!g_find(ptr,p_guid)) throw exception_service_not_found(); + return ptr->set_data_struct_t(p_in); +} + +#if FOOBAR2020 +class config_object_impl : public config_object, private cfg_var_legacy::cfg_var_reader +{ +public: + GUID get_guid() const override {return cfg_var_reader::m_guid;} + void get_data(stream_writer * p_stream,abort_callback & p_abort) const override; + void set_data(stream_reader * p_stream,abort_callback & p_abort,bool p_notify) override; + + config_object_impl(const GUID & p_guid,const void * p_data,t_size p_bytes); +private: +#ifdef FOOBAR2000_HAVE_CFG_VAR_LEGACY + void set_data_raw(stream_reader * p_stream,t_size,abort_callback & p_abort) override {set_data(p_stream,p_abort,false);} +#endif + + pfc::string8 formatName() const; + + fb2k::memBlockRef m_initial; +}; +#else +class config_object_impl : public config_object, private cfg_var_legacy::cfg_var +{ +public: + GUID get_guid() const { return cfg_var::get_guid(); } + void get_data(stream_writer* p_stream, abort_callback& p_abort) const; + void set_data(stream_reader* p_stream, abort_callback& p_abort, bool p_notify); + + config_object_impl(const GUID& p_guid, const void* p_data, t_size p_bytes); +private: + + //cfg_var methods + void get_data_raw(stream_writer* p_stream, abort_callback& p_abort) { get_data(p_stream, p_abort); } + void set_data_raw(stream_reader* p_stream, t_size p_sizehint, abort_callback& p_abort) { set_data(p_stream, p_abort, false); } + + mutable pfc::readWriteLock m_sync; + pfc::array_t m_data; +}; +#endif + +typedef service_factory_single_transparent_t config_object_factory; + +class config_object_bool_factory : public config_object_factory { +public: + config_object_bool_factory(const GUID& id, bool def) : config_object_factory(id, &def, 1) {} +}; + +class config_object_string_factory : public config_object_factory { +public: + config_object_string_factory(const GUID& id, const char * def) : config_object_factory(id, def, strlen(def)) {} +}; + + +class config_object_notify_impl_simple : public config_object_notify +{ +public: + t_size get_watched_object_count() override {return 1;} + GUID get_watched_object(t_size) override {return m_guid;} + void on_watched_object_changed(const service_ptr_t & p_object) override {m_func(p_object);} + + typedef void (*t_func)(const service_ptr_t &); + + config_object_notify_impl_simple(const GUID & p_guid,t_func p_func) : m_guid(p_guid), m_func(p_func) {} +private: + GUID m_guid; + t_func m_func; +}; + +typedef service_factory_single_transparent_t config_object_notify_simple_factory; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/console.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/console.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,107 @@ +#include "foobar2000-sdk-pch.h" +#include "console_manager.h" +#include "console.h" +#include "metadb_handle.h" +#include "event_logger.h" + +void console::info(const char * p_message) {print(p_message);} +void console::error(const char * p_message) {complain("Error", p_message);} +void console::warning(const char * p_message) {complain("Warning", p_message);} + +void console::info_location(const playable_location & src) {print_location(src);} +void console::info_location(const metadb_handle_ptr & src) {print_location(src);} + +void console::print_location(const metadb_handle_ptr & src) +{ + print_location(src->get_location()); +} + +void console::print_location(const playable_location & src) +{ + FB2K_console_formatter() << src; +} + +void console::complain(const char * what, const char * msg) { + FB2K_console_formatter() << what << ": " << msg; +} +void console::complain(const char * what, std::exception const & e) { + complain(what, e.what()); +} + +void console::print(const char* p_message) +{ + if (core_api::are_services_available()) { + for (auto p : console_receiver::enumerate()) { + p->print(p_message, SIZE_MAX); + } + } +} + +void console::printf(const char* p_format,...) +{ + va_list list; + va_start(list,p_format); + printfv(p_format,list); + va_end(list); +} + +void console::printfv(const char* p_format,va_list p_arglist) +{ + pfc::string8_fastalloc temp; + uPrintfV(temp,p_format,p_arglist); + print(temp); +} + + + +namespace { + + class event_logger_recorder_impl : public event_logger_recorder { + public: + void playback( event_logger::ptr playTo ) { + for(auto i = m_entries.first(); i.is_valid(); ++i ) { + playTo->log_entry( i->line.get_ptr(), i->severity ); + } + } + + void log_entry( const char * line, unsigned severity ) { + auto rec = m_entries.insert_last(); + rec->line = line; + rec->severity = severity; + } + private: + + struct entry_t { + pfc::string_simple line; + unsigned severity; + }; + pfc::chain_list_v2_t< entry_t > m_entries; + }; + +} + +event_logger_recorder::ptr event_logger_recorder::create() { + return new service_impl_t(); +} + + + + +namespace console { + void addNotify(fb2k::console_notify* n) { + static_api_ptr_t()->addNotify(n); + } + void removeNotify(fb2k::console_notify* n) { + static_api_ptr_t()->removeNotify(n); + } + fb2k::arrayRef getLines() { + return static_api_ptr_t()->getLines(); + } + void clearBacklog() { + static_api_ptr_t()->clearBacklog(); + } + + bool isVerbose() { + return static_api_ptr_t()->isVerbose(); + } +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/console.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/console.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,70 @@ +#pragma once + + +//! Namespace with functions for sending text to console. All functions are fully multi-thread safe, though they must not be called during dll initialization or deinitialization (e.g. static object constructors or destructors) when service system is not available. +namespace console +{ + void info(const char * p_message); + void error(const char * p_message); + void warning(const char * p_message); + void info_location(const playable_location & src); + void info_location(const metadb_handle_ptr & src); + void print_location(const playable_location & src); + void print_location(const metadb_handle_ptr & src); + + void print(const char*); + void printf(const char*,...); + void printfv(const char*,va_list p_arglist); + + //! New console print method, based on pfc::print(). \n + //! Example: console::print("foo", "bar", 2000) \ n + //! See also: FB2K_console_print(...) + template void print(args_t && ... args) {print(pfc::format(std::forward(args) ... ).c_str()); } + + class lineWriter { + public: + const lineWriter & operator<<( const char * msg ) const {print(msg);return *this;} + }; + + //! Usage: console::formatter() << "blah " << somenumber << " asdf" << somestring; + class formatter : public pfc::string_formatter { + public: + ~formatter() {if (!is_empty()) console::print(get_ptr());} + }; +#define FB2K_console_formatter() ::console::formatter()._formatter() +#define FB2K_console_formatter1() ::console::lineWriter() + +//! New console print macro, based on pfc::print(). \n +//! Example: FB2K_console_print("foo", "bar", 2000) \n +//! Note that this macro is convenient for conditionally enabling logging in specific modules - \n +//! instead of putting console formatter lines on #ifdef, #define MY_CONSOLE_LOG(...) FB2K_console_print(__VA_ARGS__) if enabled, or #define to blank if not. +#define FB2K_console_print(...) ::console::print(__VA_ARGS__) + + void complain(const char * what, const char * msg); + void complain(const char * what, std::exception const & e); + + class timer_scope { + public: + timer_scope(const char * name) : m_name(name) {m_timer.start();} + ~timer_scope() { + try { + FB2K_console_formatter() << m_name << ": " << pfc::format_time_ex(m_timer.query(), 6); + } catch(...) {} + } + private: + pfc::hires_timer m_timer; + const char * const m_name; + }; +}; + +//! Interface receiving console output. Do not call directly; use console namespace functions instead. +class NOVTABLE console_receiver : public service_base { +public: + virtual void print(const char * p_message,t_size p_message_length) = 0; + + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(console_receiver); +}; + + + + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/console_manager.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/console_manager.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,32 @@ +#pragma once +#include "commonObjects.h" + +namespace fb2k { + //! \since 2.0 + class NOVTABLE console_notify { + public: + virtual void onConsoleRefresh() = 0; + virtual void onConsoleLines(size_t oldLinesGone, arrayRef newLines, arrayRef newLinesTS) { (void)oldLinesGone; (void)newLines; (void)newLinesTS; onConsoleRefresh(); } + }; + //! \since 2.0 + class NOVTABLE console_manager : public service_base { + FB2K_MAKE_SERVICE_COREAPI(console_manager); + public: + virtual void clearBacklog() = 0; + virtual fb2k::arrayRef getLines() = 0; + virtual fb2k::arrayRef getLinesTimestamped() = 0; + virtual void addNotify(console_notify* notify) = 0; + virtual void removeNotify(console_notify* notify) = 0; + //! Obsolete, done implicitly by toggling logging, do not use. + virtual void saveBacklog() = 0; + //! Always true, reserved for future use. + virtual bool isVerbose() = 0; + }; +} // namespace fb2k + +namespace console { + void addNotify(fb2k::console_notify*); + void removeNotify(fb2k::console_notify*); + fb2k::arrayRef getLines(); + void clearBacklog(); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/contextmenu.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/contextmenu.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,376 @@ +#pragma once +#include "metadb_handle.h" +#include + +//! Reserved for future use. +typedef void * t_glyph; + + +class NOVTABLE contextmenu_item_node { +public: + enum t_flags { + FLAG_CHECKED = 1, + FLAG_DISABLED = 2, + FLAG_GRAYED = 4, + FLAG_DISABLED_GRAYED = FLAG_DISABLED|FLAG_GRAYED, + FLAG_RADIOCHECKED = 8, //new in 0.9.5.2 - overrides FLAG_CHECKED, set together with FLAG_CHECKED for backwards compatibility. + }; + + enum t_type { + type_group, + type_command, + type_separator, + + //for compatibility + TYPE_POPUP = type_group,TYPE_COMMAND = type_command,TYPE_SEPARATOR = type_separator, + }; + + virtual bool get_display_data(pfc::string_base & p_out,unsigned & p_displayflags,metadb_handle_list_cref p_data,const GUID & p_caller) = 0; + virtual t_type get_type() = 0; + virtual void execute(metadb_handle_list_cref p_data,const GUID & p_caller) = 0; + virtual t_glyph get_glyph(metadb_handle_list_cref p_data, const GUID& p_caller) { (void)p_data; (void)p_caller; return 0; }//RESERVED + virtual t_size get_children_count() = 0; + virtual contextmenu_item_node * get_child(t_size p_index) = 0; + virtual bool get_description(pfc::string_base & p_out) = 0; + virtual GUID get_guid() = 0; + virtual bool is_mappable_shortcut() = 0; + +protected: + contextmenu_item_node() {} + ~contextmenu_item_node() {} +}; + +class NOVTABLE contextmenu_item_node_root : public contextmenu_item_node +{ +public: + virtual ~contextmenu_item_node_root() {} +}; + +class NOVTABLE contextmenu_item_node_leaf : public contextmenu_item_node +{ +public: + t_type get_type() {return TYPE_COMMAND;} + t_size get_children_count() {return 0;} + contextmenu_item_node * get_child(t_size) {return NULL;} +}; + +class NOVTABLE contextmenu_item_node_root_leaf : public contextmenu_item_node_root +{ +public: + t_type get_type() {return TYPE_COMMAND;} + t_size get_children_count() {return 0;} + contextmenu_item_node * get_child(t_size) {return NULL;} +}; + +class NOVTABLE contextmenu_item_node_popup : public contextmenu_item_node +{ +public: + t_type get_type() override {return TYPE_POPUP;} + void execute(metadb_handle_list_cref data, const GUID& caller) override { (void)data; (void)caller; } + bool get_description(pfc::string_base& p_out) override { (void)p_out; return false; } +}; + +class NOVTABLE contextmenu_item_node_root_popup : public contextmenu_item_node_root +{ +public: + t_type get_type() override {return TYPE_POPUP;} + void execute(metadb_handle_list_cref data, const GUID& caller) override { (void)data; (void)caller; } + bool get_description(pfc::string_base& p_out) override { (void)p_out; return false; } +}; + +class contextmenu_item_node_separator : public contextmenu_item_node +{ +public: + t_type get_type() override {return TYPE_SEPARATOR;} + void execute(metadb_handle_list_cref data, const GUID& caller) override { (void)data; (void)caller; } + bool get_description(pfc::string_base& p_out) override { (void)p_out; return false; } + t_size get_children_count() override {return 0;} + bool get_display_data(pfc::string_base & p_out,unsigned & p_displayflags,metadb_handle_list_cref p_data,const GUID & p_caller) override + { + (void)p_data; (void)p_caller; + p_displayflags = 0; + p_out = "---"; + return true; + } + contextmenu_item_node * get_child(t_size) override {return NULL;} + GUID get_guid() override {return pfc::guid_null;} + bool is_mappable_shortcut() override {return false;} +}; + +/*! +Service class for declaring context menu commands.\n +See contextmenu_item_simple for implementation helper without dynamic menu generation features.\n +All methods are valid from main app thread only. +*/ +class NOVTABLE contextmenu_item : public service_base { +public: + enum t_enabled_state { + FORCE_OFF, + DEFAULT_OFF, + DEFAULT_ON, + }; + + //! Retrieves number of menu items provided by this contextmenu_item implementation. + virtual unsigned get_num_items() = 0; + //! Instantiates a context menu item (including sub-node tree for items that contain dynamically-generated sub-items). + virtual contextmenu_item_node_root * instantiate_item(unsigned p_index,metadb_handle_list_cref p_data,const GUID & p_caller) = 0; + //! Retrieves GUID of the context menu item. + virtual GUID get_item_guid(unsigned p_index) = 0; + //! Retrieves human-readable name of the context menu item. + virtual void get_item_name(unsigned p_index,pfc::string_base & p_out) = 0; + //! Obsolete since v1.0, don't use or override in new components. + virtual void get_item_default_path(unsigned p_index, pfc::string_base& p_out) { (void)p_index; p_out = ""; } + //! Retrieves item's description to show in the status bar. Set p_out to the string to be displayed and return true if you provide a description, return false otherwise. + virtual bool get_item_description(unsigned p_index,pfc::string_base & p_out) = 0; + //! Controls default state of context menu preferences for this item: \n + //! Return DEFAULT_ON to show this item in the context menu by default - useful for most cases. \n + //! Return DEFAULT_OFF to hide this item in the context menu by default - useful for rarely used utility commands. \n + //! Return FORCE_OFF to hide this item by default and prevent the user from making it visible (very rarely used). \n + //! foobar2000 v1.6 and newer: FORCE_OFF items are meant for being shown only in the keyboard shortcut list, not anywhere else. \n + //! Values returned by this method should be constant for this context menu item and not change later. Do not use this to conditionally hide the item - return false from get_display_data() instead. + virtual t_enabled_state get_enabled_state(unsigned p_index) = 0; + //! Executes the menu item command without going thru the instantiate_item path. For items with dynamically-generated sub-items, p_node is identifies of the sub-item command to execute. + virtual void item_execute_simple(unsigned p_index,const GUID & p_node,metadb_handle_list_cref p_data,const GUID & p_caller) = 0; + + bool item_get_display_data_root(pfc::string_base & p_out,unsigned & displayflags,unsigned p_index,metadb_handle_list_cref p_data,const GUID & p_caller); + bool item_get_display_data(pfc::string_base & p_out,unsigned & displayflags,unsigned p_index,const GUID & p_node,metadb_handle_list_cref p_data,const GUID & p_caller); + + GUID get_parent_fallback(); + GUID get_parent_(); + + //! Deprecated - use caller_active_playlist_selection instead. + static const GUID caller_playlist; + + static const GUID caller_active_playlist_selection, caller_active_playlist, caller_playlist_manager, caller_now_playing, caller_keyboard_shortcut_list, caller_media_library_viewer; + static const GUID caller_undefined; + + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(contextmenu_item); +}; + +//! \since 1.0 +class NOVTABLE contextmenu_item_v2 : public contextmenu_item { + FB2K_MAKE_SERVICE_INTERFACE(contextmenu_item_v2, contextmenu_item) +public: + virtual double get_sort_priority() {return 0;} + virtual GUID get_parent() {return get_parent_fallback();} +}; + +//! contextmenu_item implementation helper for implementing non-dynamically-generated context menu items; derive from this instead of from contextmenu_item directly if your menu items are static. +class NOVTABLE contextmenu_item_simple : public contextmenu_item_v2 { +private: +public: + //! Same as contextmenu_item_node::t_flags. + enum t_flags + { + FLAG_CHECKED = 1, + FLAG_DISABLED = 2, + FLAG_GRAYED = 4, + FLAG_DISABLED_GRAYED = FLAG_DISABLED|FLAG_GRAYED, + FLAG_RADIOCHECKED = 8, //new in 0.9.5.2 - overrides FLAG_CHECKED, set together with FLAG_CHECKED for backwards compatibility. + }; + + + // Functions to be overridden by implementers (some are not mandatory). + virtual t_enabled_state get_enabled_state(unsigned p_index) { (void)p_index; return contextmenu_item::DEFAULT_ON; } + virtual unsigned get_num_items() = 0; + virtual void get_item_name(unsigned p_index,pfc::string_base & p_out) = 0; + virtual void context_command(unsigned p_index,metadb_handle_list_cref p_data,const GUID& p_caller) = 0; + virtual bool context_get_display(unsigned p_index,metadb_handle_list_cref p_data,pfc::string_base & p_out,unsigned & p_displayflags,const GUID & p_caller) { + (void)p_caller; (void)p_data; (void)p_displayflags; + PFC_ASSERT(p_index>=0 && p_indexget_display_data(m_index,p_data,p_out,p_displayflags,p_caller);} + void execute(metadb_handle_list_cref p_data,const GUID & p_caller) {m_owner->context_command(m_index,p_data,p_caller);} + bool get_description(pfc::string_base & p_out) {return m_owner->get_item_description(m_index,p_out);} + GUID get_guid() {return pfc::guid_null;} + bool is_mappable_shortcut() {return m_owner->item_is_mappable_shortcut(m_index);} + private: + service_ptr_t m_owner; + unsigned m_index; + }; + + contextmenu_item_node_root * instantiate_item(unsigned p_index,metadb_handle_list_cref p_data,const GUID & p_caller) + { + (void)p_data; (void)p_caller; + return new contextmenu_item_node_impl(this,p_index); + } + + + void item_execute_simple(unsigned p_index,const GUID & p_node,metadb_handle_list_cref p_data,const GUID & p_caller) + { + if (p_node == pfc::guid_null) + context_command(p_index,p_data,p_caller); + } + + virtual bool item_is_mappable_shortcut(unsigned p_index) + { + (void)p_index; + return true; + } + + + virtual bool get_display_data(unsigned n,metadb_handle_list_cref data,pfc::string_base & p_out,unsigned & displayflags,const GUID & caller) + { + bool rv = false; + assert(n>=0 && n0) + { + rv = context_get_display(n,data,p_out,displayflags,caller); + } + return rv; + } + +}; + + +//! Helper. +template +class contextmenu_item_factory_t : public service_factory_single_t {}; + + +//! Helper. +#define DECLARE_CONTEXT_MENU_ITEM(P_CLASSNAME,P_NAME,P_DEFAULTPATH,P_FUNC,P_GUID,P_DESCRIPTION) \ + namespace { \ + class P_CLASSNAME : public contextmenu_item_simple { \ + public: \ + unsigned get_num_items() {return 1;} \ + void get_item_name(unsigned p_index,pfc::string_base & p_out) {p_out = P_NAME;} \ + void get_item_default_path(unsigned p_index,pfc::string_base & p_out) {p_out = P_DEFAULTPATH;} \ + void context_command(unsigned p_index,metadb_handle_list_cref p_data,const GUID& p_caller) {P_FUNC(p_data);} \ + GUID get_item_guid(unsigned p_index) {return P_GUID;} \ + bool get_item_description(unsigned p_index,pfc::string_base & p_out) {if (P_DESCRIPTION[0] == 0) return false;p_out = P_DESCRIPTION; return true;} \ + }; \ + static contextmenu_item_factory_t g_##P_CLASSNAME##_factory; \ + } + + + + +//! New in 0.9.5.1. Static methods safe to use in prior versions as it will use slow fallback mode when the service isn't present. \n +//! Functionality provided by menu_item_resolver methods isn't much different from just walking all registered contextmenu_item / mainmenu_commands implementations to find the command we want, but it uses a hint map to locate the service we're looking for without walking all of them which may be significantly faster in certain scenarios. +class menu_item_resolver : public service_base { + FB2K_MAKE_SERVICE_COREAPI(menu_item_resolver) +public: + virtual bool resolve_context_command(const GUID & id, service_ptr_t & out, t_uint32 & out_index) = 0; + virtual bool resolve_main_command(const GUID & id, service_ptr_t & out, t_uint32 & out_index) = 0; + + static bool g_resolve_context_command(const GUID & id, service_ptr_t & out, t_uint32 & out_index); + static bool g_resolve_main_command(const GUID & id, service_ptr_t & out, t_uint32 & out_index); + + +}; + +//! \since 1.0 +class NOVTABLE contextmenu_group : public service_base { + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(contextmenu_group); +public: + virtual GUID get_guid() = 0; + virtual GUID get_parent() = 0; + virtual double get_sort_priority() = 0; +}; + +//! \since 1.0 +class NOVTABLE contextmenu_group_popup : public contextmenu_group { + FB2K_MAKE_SERVICE_INTERFACE(contextmenu_group_popup, contextmenu_group) +public: + virtual void get_display_string(pfc::string_base & out) = 0; + void get_name(pfc::string_base & out) {get_display_string(out);} +}; + +class contextmenu_groups { +public: + static const GUID root, utilities, tagging, tagging_pictures, replaygain, fileoperations, playbackstatistics, properties, convert, legacy; +}; + +class contextmenu_group_impl : public contextmenu_group { +public: + contextmenu_group_impl(const GUID & guid, const GUID & parent, double sortPriority = 0) : m_guid(guid), m_parent(parent), m_sortPriority(sortPriority) {} + GUID get_guid() {return m_guid;} + GUID get_parent() {return m_parent;} + double get_sort_priority() {return m_sortPriority;} +private: + const GUID m_guid, m_parent; + const double m_sortPriority; +}; + +class contextmenu_group_popup_impl : public contextmenu_group_popup { +public: + contextmenu_group_popup_impl(const GUID & guid, const GUID & parent, const char * name, double sortPriority = 0) : m_guid(guid), m_parent(parent), m_sortPriority(sortPriority), m_name(name) {} + GUID get_guid() {return m_guid;} + GUID get_parent() {return m_parent;} + double get_sort_priority() {return m_sortPriority;} + void get_display_string(pfc::string_base & out) {out = m_name;} +private: + const GUID m_guid, m_parent; + const double m_sortPriority; + const char * const m_name; +}; + + + +namespace contextmenu_priorities { + enum { + root_queue = -100, + root_main = -50, + root_tagging, + root_fileoperations, + root_convert, + root_utilities, + root_replaygain, + root_playbackstatistics, + root_legacy = 99, + root_properties = 100, + tagging_pictures = 100, + }; +}; + + + +class contextmenu_group_factory : public service_factory_single_t { +public: + contextmenu_group_factory(const GUID & guid, const GUID & parent, double sortPriority = 0) : service_factory_single_t(guid, parent, sortPriority) {} +}; + +class contextmenu_group_popup_factory : public service_factory_single_t { +public: + contextmenu_group_popup_factory(const GUID & guid, const GUID & parent, const char * name, double sortPriority = 0) : service_factory_single_t(guid, parent, name, sortPriority) {} +}; + + + +class contextmenu_item_lambda : public contextmenu_item_simple { +public: + typedef std::function func_t; + contextmenu_item_lambda(func_t f, const char* n, const GUID& g, const GUID& pg, const char* d = nullptr, double sp = 0) : m_func(f), m_name(n), m_guid(g), m_parentGuid(pg), m_desc(d), m_sortPriority(sp) {} + + unsigned get_num_items() override { return 1; } + void get_item_name(unsigned p_index, pfc::string_base& p_out) override { (void)p_index; p_out = m_name; } + void context_command(unsigned p_index, metadb_handle_list_cref p_data, const GUID& p_caller) override { (void)p_index; (void)p_caller; m_func(p_data); } + GUID get_item_guid(unsigned p_index) override { (void)p_index; return m_guid; } + bool get_item_description(unsigned p_index, pfc::string_base& p_out) override { + (void)p_index; + if (m_desc == nullptr) return false; + p_out = m_desc; + return true; + } + double get_sort_priority() override { return m_sortPriority; } + GUID get_parent() override { return m_parentGuid; } +private: + const std::function m_func; + const char* const m_name; + const GUID m_guid, m_parentGuid; + const char* const m_desc; + const double m_sortPriority; +}; + +#define FB2K_DECLARE_CONTEXT_MENU_ITEM(func, name, guid, parent, desc, sort) FB2K_SERVICE_FACTORY_PARAMS(contextmenu_item_lambda, func, name, guid, parent, desc, sort) diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/contextmenu_manager.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/contextmenu_manager.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,148 @@ +#pragma once + +#include "menu_common.h" +#include "metadb.h" +#include "contextmenu.h" + +#ifdef FOOBAR2000_HAVE_KEYBOARD_SHORTCUTS +class NOVTABLE keyboard_shortcut_manager : public service_base { +public: + enum shortcut_type + { + TYPE_MAIN, + TYPE_CONTEXT, + TYPE_CONTEXT_PLAYLIST, + TYPE_CONTEXT_NOW_PLAYING, + }; + + + virtual bool process_keydown(shortcut_type type,metadb_handle_list_cref data,unsigned keycode)=0; + virtual bool process_keydown_ex(shortcut_type type,metadb_handle_list_cref data,unsigned keycode,const GUID & caller)=0; + +#ifdef _WIN32 + bool on_keydown(shortcut_type type,WPARAM wp); + bool on_keydown_context(const pfc::list_base_const_t & data,WPARAM wp,const GUID & caller); + + bool on_keydown_auto(WPARAM wp); + bool on_keydown_auto_playlist(WPARAM wp); + bool on_keydown_auto_context(const pfc::list_base_const_t & data,WPARAM wp,const GUID & caller); + + bool on_keydown_restricted_auto(WPARAM wp); + bool on_keydown_restricted_auto_playlist(WPARAM wp); + bool on_keydown_restricted_auto_context(const pfc::list_base_const_t & data,WPARAM wp,const GUID & caller); +#endif + virtual bool get_key_description_for_action(const GUID & p_command,const GUID & p_subcommand, pfc::string_base & out, shortcut_type type, bool is_global)=0; + +#ifdef _WIN32 + static bool is_text_key(t_uint32 vkCode); + static bool is_typing_key(t_uint32 vkCode); + static bool is_typing_key_combo(t_uint32 vkCode, t_uint32 modifiers); + static bool is_typing_modifier(t_uint32 flags); + static bool is_typing_message(HWND editbox, const MSG * msg); + static bool is_typing_message(const MSG * msg); +#endif + + FB2K_MAKE_SERVICE_COREAPI(keyboard_shortcut_manager); +}; + + +//! New in 0.9.5. +class keyboard_shortcut_manager_v2 : public keyboard_shortcut_manager { +public: + //! Deprecates old keyboard_shortcut_manager methods. If the action requires selected items, they're obtained from ui_selection_manager API automatically. + virtual bool process_keydown_simple(t_uint32 keycode) = 0; + +#ifdef _WIN32 + //! Helper for use with message filters. + bool pretranslate_message(const MSG * msg, HWND thisPopupWnd); +#endif + + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(keyboard_shortcut_manager_v2,keyboard_shortcut_manager); +}; +#endif + +class NOVTABLE contextmenu_node { +public: + virtual contextmenu_item_node::t_type get_type()=0; + virtual const char * get_name()=0; + virtual t_size get_num_children()=0;//TYPE_POPUP only + virtual contextmenu_node * get_child(t_size n)=0;//TYPE_POPUP only + virtual unsigned get_display_flags()=0;//TYPE_COMMAND/TYPE_POPUP only, see contextmenu_item::FLAG_* + virtual unsigned get_id()=0;//TYPE_COMMAND only, returns zero-based index (helpful for win32 menu command ids) + virtual void execute()=0;//TYPE_COMMAND only + virtual bool get_description(pfc::string_base & out)=0;//TYPE_COMMAND only + virtual bool get_full_name(pfc::string_base & out)=0;//TYPE_COMMAND only + virtual void * get_glyph()=0;//RESERVED, do not use +protected: + contextmenu_node() {} + ~contextmenu_node() {} +}; + + + +class NOVTABLE contextmenu_manager : public service_base +{ +public: + enum + { + flag_show_shortcuts = 1 << 0, + flag_show_shortcuts_global = 1 << 1, + //! \since 1.0 + //! To control which commands are shown, you should specify either flag_view_reduced or flag_view_full. If neither is specified, the implementation will decide automatically based on shift key being pressed, for backwards compatibility. + flag_view_reduced = 1 << 2, + //! \since 1.0 + //! To control which commands are shown, you should specify either flag_view_reduced or flag_view_full. If neither is specified, the implementation will decide automatically based on shift key being pressed, for backwards compatibility. + flag_view_full = 1 << 3, + + //for compatibility + FLAG_SHOW_SHORTCUTS = 1, + FLAG_SHOW_SHORTCUTS_GLOBAL = 2, + }; + + virtual void init_context(metadb_handle_list_cref data,unsigned flags) = 0; + virtual void init_context_playlist(unsigned flags) = 0; + virtual contextmenu_node * get_root() = 0;//releasing contextmenu_manager service releaases nodes; root may be null in case of error or something + virtual contextmenu_node * find_by_id(unsigned id)=0; +#ifdef _WIN32 + virtual void set_shortcut_preference(const keyboard_shortcut_manager::shortcut_type * data,unsigned count)=0; +#endif + + static void g_create(service_ptr_t& p_out); + static service_ptr_t g_create(); + +#ifdef WIN32 + static void win32_build_menu(HMENU menu,contextmenu_node * parent,int base_id,int max_id);//menu item identifiers are base_id<=NaddCtrlAuto(wnd); + } + void AddDialog(HWND wnd) { + if (is_valid()) m_obj->addDialog(wnd); + } + void AddControls(HWND wnd) { + if (is_valid()) m_obj->addControls(wnd); + } + void AddDialogWithControls(HWND wnd) { + AddDialog(wnd); AddControls(wnd); + } + + void SetDark(bool v) { + if (is_valid()) m_obj->setDarkMode(v); + } + operator bool() const { + return is_valid() && m_obj->isDark(); + } + + + CCoreDarkModeHooks() { + fb2k::coreDarkMode::ptr api; + if (core_api::are_services_available()) api = fb2k::coreDarkMode::tryGet(); + if (!api.is_valid()) return; + m_obj = api->createAuto(); + } + CCoreDarkModeHooks(bool v) { + fb2k::coreDarkMode::ptr api; + if (core_api::are_services_available()) api = fb2k::coreDarkMode::tryGet(); + if (!api.is_valid()) return; + m_obj = api->create(v); + } + CCoreDarkModeHooks(const CCoreDarkModeHooks&) = delete; + void operator=(const CCoreDarkModeHooks&) = delete; + private: + bool is_valid() const { + return m_obj.is_valid(); + } + fb2k::coreDarkModeObj::ptr m_obj; + }; +} + +#endif // _WIN32 + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/core_api.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/core_api.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,52 @@ +#pragma once + +namespace core_api { + +#ifdef _WIN32 + //! Retrieves HINSTANCE of calling DLL. + HINSTANCE get_my_instance(); +#endif + //! Retrieves filename of calling dll, excluding extension, e.g. "foo_asdf" + const char * get_my_file_name(); + //! Retrieves full path of calling dll, e.g. c:\blah\foobar2000\foo_asdf.dll . No file:// prefix, this path can interop with win32 API calls. + const char * get_my_full_path(); + //! Retrieves main app window. WARNING: this is provided for parent of dialog windows and such only; using it for anything else (such as hooking windowproc to alter app behaviors) is absolutely illegal. \n + //! Becomes valid when main window has been fully initialized. Returns NULL during creation of main window's embedded elements. + fb2k::hwnd_t get_main_window(); + //! Tests whether services are available at this time. They are not available only during DLL startup or shutdown (e.g. inside static object constructors or destructors). + bool are_services_available(); + //! Tests whether calling thread is main app thread, and shows diagnostic message in debugger output if it's not. + bool assert_main_thread(); + //! Triggers a bug check if the calling thread is not the main app thread. + void ensure_main_thread(); + //! Returns true if calling thread is main app thread, false otherwise. + bool is_main_thread(); + //! Returns whether the app is currently shutting down. + bool is_shutting_down(); + //! Returns whether the app is currently initializing. + bool is_initializing(); + //! Returns filesystem path to directory with user settings, e.g. file://c:\documents_and_settings\username\blah\foobar2000 + const char * get_profile_path(); + + //! Returns a path to in fb2k profile folder. + inline pfc::string8 pathInProfile(const char * fileName) { pfc::string8 p( core_api::get_profile_path() ); p.add_filename( fileName ); return p; } + + //! Returns whether foobar2000 has been installed in "portable" mode. + bool is_portable_mode_enabled(); + + //! Returns whether foobar2000 is currently running in quiet mode. \n + //! Quiet mode bypasses all GUI features, disables Media Library and does not save any changes to app configuration. \n + //! Your component should not display any forms of user interface when running in quiet mode, as well as avoid saving configuration on its own (no need to worry if you only rely on cfg_vars or config_io_callback, they will simply be ignored on shutdown). + bool is_quiet_mode_enabled(); +}; + +#define FB2K_SUPPORT_LOW_MEM_MODE (SIZE_MAX <= UINT32_MAX) + +namespace fb2k { + bool isDebugModeActive(); +#if FB2K_SUPPORT_LOW_MEM_MODE + bool isLowMemModeActive(); +#else + inline constexpr bool isLowMemModeActive() { return false; } +#endif +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/coreversion.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/coreversion.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,39 @@ +#pragma once + +class NOVTABLE core_version_info : public service_base { + FB2K_MAKE_SERVICE_COREAPI(core_version_info); +public: + virtual const char * get_version_string() = 0; + static const char * g_get_version_string() {return core_version_info::get()->get_version_string();} + +}; + +struct t_core_version_data { + t_uint32 m_major, m_minor1, m_minor2, m_minor3; +}; + +//! New (0.9.4.2) +class NOVTABLE core_version_info_v2 : public core_version_info { + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(core_version_info_v2, core_version_info); +public: + virtual const char * get_name() = 0;//"foobar2000" + virtual const char * get_version_as_text() = 0;//"N.N.N.N" + virtual t_core_version_data get_version() = 0; + + //! Determine whether running foobar2000 version is newer or equal to the specified version, eg. test_version(0,9,5,0) for 0.9.5. + bool test_version(t_uint32 major, t_uint32 minor1, t_uint32 minor2, t_uint32 minor3) { + const t_core_version_data v = get_version(); + if (v.m_major < major) return false; + else if (v.m_major > major) return true; + // major version matches + else if (v.m_minor1 < minor1) return false; + else if (v.m_minor1 > minor1) return true; + // minor1 version matches + else if (v.m_minor2 < minor2) return false; + else if (v.m_minor2 > minor2) return true; + // minor2 version matches + else if (v.m_minor3 < minor3) return false; + else return true; + } + +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/decode_postprocessor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/decode_postprocessor.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,174 @@ +#pragma once + +#ifdef FOOBAR2000_HAVE_DSP +#include "dsp.h" +#include "file_info_impl.h" +#include "input.h" + +//! \since 1.1 +//! This service is essentially a special workaround to easily decode DTS/HDCD content stored in files pretending to contain plain PCM data. \n +//! Callers: Instead of calling this directly, you probably want to use input_postprocessed template. \n +//! Implementers: This service is called only by specific decoders, not by all of them! Implementing your own to provide additional functionality is not recommended! +class decode_postprocessor_instance : public service_base { + FB2K_MAKE_SERVICE_INTERFACE(decode_postprocessor_instance, service_base); +public: + enum { + //! End of stream. Flush any buffered data during this call. + flag_eof = 1 << 0, + //! Stream has already been altered by another instance. + flag_altered = 1 << 1, + }; + //! @returns True if the chunk list has been altered by the call, false if not - to tell possible other running instances whether the stream has already been altered or not. + virtual bool run(dsp_chunk_list & p_chunk_list,t_uint32 p_flags,abort_callback & p_abort) = 0; + //! Manipulate live info (bit depth, bitrate, whatever) that might be altered by us. + virtual bool get_dynamic_info(file_info & p_out) = 0; + //! Called after seek. + virtual void flush() = 0; + //! Return >0 to signal that, after each flush(), you require of audio before your output becomes valid. \n + //! This causes decoder to seek to position- instead of then discard first of your output. + virtual double get_buffer_ahead() = 0; +}; + +//! \since 1.1 +//! Entrypoint class for instantiating decode_postprocessor_instance. See decode_postprocessor_instance documentation for more information. \n +//! Instead of calling this directly, you probably want to use input_postprocessed template. +class decode_postprocessor_entry : public service_base { + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(decode_postprocessor_entry) +public: + virtual bool instantiate(const file_info & info, decode_postprocessor_instance::ptr & out) = 0; +}; + + +//! Helper class for managing decode_postprocessor_instance objects. See also: input_postprocessed. +class decode_postprocessor { +public: + typedef decode_postprocessor_instance::ptr item; + void initialize(const file_info & info) { + m_items.remove_all(); + for (auto ptr : decode_postprocessor_entry::enumerate()) { + item i; + if (ptr->instantiate(info, i)) m_items += i; + } + } + void run(dsp_chunk_list & p_chunk_list,bool p_eof,abort_callback & p_abort) { + t_uint32 flags = p_eof ? decode_postprocessor_instance::flag_eof : 0; + for (auto& item : m_items) { + if (item->run(p_chunk_list, flags, p_abort)) flags |= decode_postprocessor_instance::flag_altered; + } + } + void flush() { + for (auto& item : m_items) item->flush(); + } + static bool should_bother() { + return service_factory_base::is_service_present(decode_postprocessor_entry::class_guid); + } + bool is_active() const { + return m_items.get_size() > 0; + } + bool get_dynamic_info(file_info & p_out) { + bool rv = false; + for (auto& item : m_items) { + if (item->get_dynamic_info(p_out)) rv = true; + } + return rv; + } + void close() { + m_items.remove_all(); + } + double get_buffer_ahead() { + double acc = 0; + for (auto& item : m_items) { + pfc::max_acc(acc, item->get_buffer_ahead()); + } + return acc; + } +private: + pfc::list_t m_items; +}; + +//! Generic template to add decode_postprocessor support to your input class. Works with both single-track and multi-track inputs. +template class input_postprocessed : public baseclass { +public: + void decode_initialize(t_uint32 p_subsong,unsigned p_flags,abort_callback & p_abort) { + m_chunks.remove_all(); + m_haveEOF = false; + m_toSkip = 0; + m_postproc.close(); + if ((p_flags & input_flag_no_postproc) == 0 && m_postproc.should_bother()) { + file_info_impl info; + this->get_info(p_subsong, info, p_abort); + m_postproc.initialize(info); + } + baseclass::decode_initialize(p_subsong, p_flags, p_abort); + } + void decode_initialize(unsigned p_flags,abort_callback & p_abort) { + m_chunks.remove_all(); + m_haveEOF = false; + m_toSkip = 0; + m_postproc.close(); + if ((p_flags & input_flag_no_postproc) == 0 && m_postproc.should_bother()) { + file_info_impl info; + this->get_info(info, p_abort); + m_postproc.initialize(info); + } + baseclass::decode_initialize(p_flags, p_abort); + } + bool decode_run(audio_chunk & p_chunk,abort_callback & p_abort) { + if (m_postproc.is_active()) { + for(;;) { + p_abort.check(); + if (m_chunks.get_count() > 0) { + audio_chunk * c = m_chunks.get_item(0); + if (m_toSkip > 0) { + if (!c->process_skip(m_toSkip)) { + m_chunks.remove_by_idx(0); + continue; + } + } + p_chunk = *c; + m_chunks.remove_by_idx(0); + return true; + } + if (m_haveEOF) return false; + if (!baseclass::decode_run(*m_chunks.insert_item(0), p_abort)) { + m_haveEOF = true; + m_chunks.remove_by_idx(0); + } + m_postproc.run(m_chunks, m_haveEOF, p_abort); + } + } else { + return baseclass::decode_run(p_chunk, p_abort); + } + } + bool decode_run_raw(audio_chunk & p_chunk, mem_block_container & p_raw, abort_callback & p_abort) { + if (m_postproc.is_active()) { + throw pfc::exception_not_implemented(); + } else { + return baseclass::decode_run_raw(p_chunk, p_raw, p_abort); + } + } + bool decode_get_dynamic_info(file_info & p_out, double & p_timestamp_delta) { + bool rv = baseclass::decode_get_dynamic_info(p_out, p_timestamp_delta); + if (m_postproc.get_dynamic_info(p_out)) rv = true; + return rv; + } + void decode_seek(double p_seconds,abort_callback & p_abort) { + m_chunks.remove_all(); + m_haveEOF = false; + m_postproc.flush(); + double target = pfc::max_t(0, p_seconds - m_postproc.get_buffer_ahead()); + m_toSkip = p_seconds - target; + baseclass::decode_seek(target, p_abort); + } +private: + dsp_chunk_list_impl m_chunks; + bool m_haveEOF; + double m_toSkip; + decode_postprocessor m_postproc; +}; + +#else // FOOBAR2000_HAVE_DSP + +template class input_postprocessed : public baseclass {}; + +#endif // FOOBAR2000_HAVE_DSP diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/dsp-frontend.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/dsp-frontend.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,8 @@ +#pragma once +#include "keyValueIO.h" + +typedef fb2k::keyValueIO dsp_preset_edit_callback_v3; + +namespace fb2k { + static const double dsp_slider_lag = 0.2; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/dsp.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/dsp.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,761 @@ +#include "foobar2000-sdk-pch.h" +#include "dsp.h" +#include "resampler.h" + +#ifdef FOOBAR2000_HAVE_DSP + +#include + +audio_chunk * dsp_chunk_list::add_item(t_size hint_size) { return insert_item(get_count(), hint_size); } + +void dsp_chunk_list::remove_all() { remove_mask(pfc::bit_array_true()); } + +double dsp_chunk_list::get_duration() { + double rv = 0; + t_size n, m = get_count(); + for (n = 0; nget_duration(); + return rv; +} + +void dsp_chunk_list::add_chunk(const audio_chunk * chunk) { + audio_chunk * dst = insert_item(get_count(), chunk->get_used_size()); + if (dst) dst->copy(*chunk); +} + +t_size dsp_chunk_list_impl::get_count() const {return m_data.size();} + +audio_chunk * dsp_chunk_list_impl::get_item(t_size n) const {return nmax) idx = max; + chunk_ptr_t ret; + if (!m_recycled.empty()) + { + t_size best; + if (hint_size > 0) + { + best = 0; + t_size best_found = m_recycled[0]->get_data_size(), n, total = m_recycled.size(); + for (n = 1; n < total; n++) + { + if (best_found == hint_size) break; + t_size size = m_recycled[n]->get_data_size(); + int delta_old = abs((int)best_found - (int)hint_size), delta_new = abs((int)size - (int)hint_size); + if (delta_new < delta_old) + { + best_found = size; + best = n; + } + } + } else best = m_recycled.size() - 1; + + ret = std::move(m_recycled[best]); + m_recycled.erase(m_recycled.begin() + best); + ret->set_sample_count(0); + ret->set_channels(0); + ret->set_srate(0); + } else ret = std::make_unique(); + auto pRet = &*ret; + if (idx == max) m_data.push_back(std::move(ret)); + else m_data.insert(m_data.begin() + idx, std::move(ret)); + return pRet; +} + +void dsp_chunk_list::remove_bad_chunks() +{ + bool blah = false; + t_size idx; + for(idx=0;idxis_valid()) + { +#if PFC_DEBUG + FB2K_console_formatter() << "Removing bad chunk: " << chunk->formatChunkSpec(); +#endif + chunk->reset(); + remove_by_idx(idx); + blah = true; + } + else idx++; + } + if (blah) console::info("one or more bad chunks removed from dsp chunk list"); +} + +bool dsp_entry_hidden::g_dsp_exists(const GUID & p_guid) { + dsp_entry_hidden::ptr p; + return g_get_interface(p, p_guid); +} + +bool dsp_entry_hidden::g_get_interface( dsp_entry_hidden::ptr & out, const GUID & guid ) { + for (auto p : enumerate()) { + if (p->get_guid() == guid) { + out = p; return true; + } + } + return false; +} + +bool dsp_entry_hidden::g_instantiate( dsp::ptr & out, const dsp_preset & preset ) { + dsp_entry_hidden::ptr i; + if (!g_get_interface(i, preset.get_owner())) return false; + return i->instantiate(out, preset); +} + +bool dsp_entry::g_instantiate(service_ptr_t & p_out,const dsp_preset & p_preset, unsigned flags ) +{ + service_ptr_t ptr; + if (!g_get_interface(ptr,p_preset.get_owner())) return false; + if ( flags != 0 ) { + dsp_entry_v4::ptr v4; + if (v4 &= ptr) { + p_out = v4->instantiate_v4(p_preset, flags); + return true; + } + } + return ptr->instantiate(p_out,p_preset); +} + +bool dsp_entry::g_instantiate_default(service_ptr_t & p_out,const GUID & p_guid) +{ + service_ptr_t ptr; + if (!g_get_interface(ptr,p_guid)) return false; + dsp_preset_impl preset; + if (!ptr->get_default_preset(preset)) return false; + return ptr->instantiate(p_out,preset); +} + +bool dsp_entry::g_name_from_guid(pfc::string_base & p_out,const GUID & p_guid) +{ + service_ptr_t ptr; + if (!g_get_interface(ptr,p_guid)) return false; + ptr->get_name(p_out); + return true; +} + +bool dsp_entry::g_dsp_exists(const GUID & p_guid) +{ + service_ptr_t blah; + return g_get_interface(blah,p_guid); +} + +bool dsp_entry::g_get_default_preset(dsp_preset & p_out,const GUID & p_guid) +{ + service_ptr_t ptr; + if (!g_get_interface(ptr,p_guid)) return false; + return ptr->get_default_preset(p_out); +} + +void dsp_chain_config::contents_to_stream(stream_writer * p_stream,abort_callback & p_abort) const { + uint32_t n, count = pfc::downcast_guarded( get_count() ); + p_stream->write_lendian_t(count,p_abort); + for(n=0;ncontents_to_stream(&out, fb2k::noAbort); + return fb2k::memBlock::blockWithVector(out.m_buffer); +} + +void dsp_chain_config::from_blob(const void* p, size_t size) { + if (size == 0) { + remove_all(); return; + } + stream_reader_memblock_ref reader(p, size); + this->contents_from_stream(&reader, fb2k::noAbort); +} + +void dsp_chain_config::from_blob(fb2k::memBlock::ptr b) { + if (b.is_valid()) { + from_blob(b->data(), b->size()); + } else { + this->remove_all(); + } +} + +void dsp_chain_config::contents_from_stream(stream_reader * p_stream,abort_callback & p_abort) { + t_uint32 n,count; + + remove_all(); + + p_stream->read_lendian_t(count,p_abort); + + dsp_preset_impl temp; + + for(n=0;nget_count(); + for(size_t w = 0; w < count; ++w) { + if (this->get_item(w).get_owner() == dspID) return w; + } + return SIZE_MAX; +} + +bool dsp_chain_config::contains_dsp( const GUID & dspID ) const { + return find_first_of_type( dspID ) != pfc_infinite; +} + +bool dsp_chain_config::enable_dsp( const GUID & dspID ) { + if (this->contains_dsp( dspID )) return false; + dsp_preset_impl preset; + dsp_entry::g_get_default_preset( preset, dspID ); + insert_item( preset, 0 ); + return true; +} + +bool dsp_chain_config::disable_dsp( const GUID & dspID ) { + const size_t count = this->get_count(); + if (count == 0) return false; + bool rv = false; + pfc::bit_array_bittable mask( count ); + for(size_t w = 0; w < count; ++ w) { + if (this->get_item(w).get_owner() == dspID ) { + rv = true; + mask.set(w, true); + } + } + if (rv) this->remove_mask( mask ); + return rv; +} + +bool dsp_chain_config::enable_dsp( const dsp_preset & preset ) { + dsp_chain_config & cfg = *this; + bool found = false; + bool changed = false; + t_size n,m = cfg.get_count(); + for(n=0;ndata; +} + +void dsp_chain_config_impl::replace_item(const dsp_preset & p_data,t_size p_index) +{ + auto& obj = *m_data[p_index]; + if (p_data.get_owner() != obj.data.get_owner()) { + obj.dspName = p_data.get_owner_name(); + } + obj.data = p_data; +} + +void dsp_chain_config_impl::insert_item(const dsp_preset & p_data,t_size p_index) +{ + this->insert_item_v2(p_data, nullptr, p_index); +} + +void dsp_chain_config_impl::remove_mask(const bit_array & p_mask) +{ + m_data.delete_mask(p_mask); +} + +dsp_chain_config_impl::~dsp_chain_config_impl() +{ + m_data.delete_all(); +} + +const char* dsp_chain_config_impl::get_dsp_name(size_t idx) const { + auto& n = m_data[idx]->dspName; + if (n.is_empty()) return nullptr; + return n.c_str(); +} + +void dsp_chain_config_impl::insert_item_v2(const dsp_preset& data, const char* dspName_, size_t index) { + pfc::string8 dspName; + if (dspName_) dspName = dspName_; + if (dspName.length() == 0) dspName = data.get_owner_name(); + m_data.insert_item(new entry_t{ data, std::move(dspName) }, index); +} + +const char* dsp_chain_config_impl::find_dsp_name(const GUID& guid) const { + for (size_t walk = 0; walk < m_data.get_size(); ++walk) { + auto& obj = *m_data[walk]; + if (obj.data.get_owner() == guid && obj.dspName.length() > 0) { + return obj.dspName.c_str(); + } + } + return nullptr; +} + +pfc::string8 dsp_preset::get_owner_name() const { + pfc::string8 ret; + dsp_entry::ptr obj; + if (dsp_entry::g_get_interface(obj, this->get_owner())) { + obj->get_name(ret); + } + return ret; +} + +pfc::string8 dsp_preset::get_owner_name_debug() const { + pfc::string8 ret; + dsp_entry::ptr obj; + if (dsp_entry::g_get_interface(obj, this->get_owner())) { + obj->get_name(ret); + } else { + ret = "[unknown]"; + } + return ret; +} + +pfc::string8 dsp_preset::debug(const char * knownName) const { + pfc::string8 name; + if (knownName) name = knownName; + else name = this->get_owner_name_debug(); + pfc::string8 ret; + ret << name << " :: " << pfc::print_guid(this->get_owner()) << " :: " << pfc::format_hexdump(this->get_data(), this->get_data_size()); + return ret; +} + +pfc::string8 dsp_chain_config::debug() const { + const size_t count = get_count(); + pfc::string8 ret; + ret << "dsp_chain_config: " << count << " items"; + for (size_t walk = 0; walk < count; ++walk) { + ret << "\n" << get_item(walk).debug(); + } + return ret; +} + +void dsp_chain_config_impl::add_item_v2(const dsp_preset& data, const char* dspName) { + insert_item_v2(data, dspName, get_count()); +} + +void dsp_chain_config_impl::copy_v2(dsp_chain_config_impl const& p_source) { + remove_all(); + t_size n, m = p_source.get_count(); + for (n = 0; n < m; n++) + add_item_v2(p_source.get_item(n), p_source.get_dsp_name(n)); +} + +pfc::string8 dsp_chain_config_impl::debug() const { + const size_t count = get_count(); + pfc::string8 ret; + ret << "dsp_chain_config_impl: " << count << " items"; + for (size_t walk = 0; walk < count; ++walk) { + ret << "\n" << get_item(walk).debug( this->get_dsp_name(walk) ); + } + return ret; +} + +void dsp_preset::contents_to_stream(stream_writer * p_stream,abort_callback & p_abort) const { + t_uint32 size = pfc::downcast_guarded(get_data_size()); + p_stream->write_lendian_t(get_owner(),p_abort); + p_stream->write_lendian_t(size,p_abort); + if (size > 0) { + p_stream->write_object(get_data(),size,p_abort); + } +} + +void dsp_preset::contents_from_stream(stream_reader * p_stream,abort_callback & p_abort) { + t_uint32 size; + GUID guid; + p_stream->read_lendian_t(guid,p_abort); + set_owner(guid); + p_stream->read_lendian_t(size,p_abort); + if (size > 1024*1024*32) throw exception_io_data(); + set_data_from_stream(p_stream,size,p_abort); +} + +void dsp_preset::g_contents_from_stream_skip(stream_reader * p_stream,abort_callback & p_abort) { + t_uint32 size; + GUID guid; + p_stream->read_lendian_t(guid,p_abort); + p_stream->read_lendian_t(size,p_abort); + if (size > 1024*1024*32) throw exception_io_data(); + p_stream->skip_object(size,p_abort); +} + +void dsp_preset_impl::set_data_from_stream(stream_reader * p_stream,t_size p_bytes,abort_callback & p_abort) { + m_data.resize(p_bytes); + if (p_bytes > 0) p_stream->read_object(m_data.ptr(),p_bytes,p_abort); +} + +void dsp_chain_config::add_items(const dsp_chain_config & p_source) { + t_size n, m = p_source.get_count(); + for(n=0;n entry; + if (!g_get_interface(entry,p_guid)) return false; + return entry->have_config_popup(); +} + +bool dsp_entry::g_have_config_popup(const dsp_preset & p_preset) +{ + return g_have_config_popup(p_preset.get_owner()); +} + +#ifdef _WIN32 +bool dsp_entry::g_show_config_popup(dsp_preset & p_preset,fb2k::hwnd_t p_parent) +{ + service_ptr_t entry; + if (!g_get_interface(entry,p_preset.get_owner())) return false; + return entry->show_config_popup(p_preset,p_parent); +} + +bool dsp_entry::show_config_popup_v2_(const dsp_preset& p_preset, fb2k::hwnd_t p_parent, dsp_preset_edit_callback& p_callback) { + PFC_ASSERT(p_preset.get_owner() == this->get_guid()); + try { + service_ptr_t entry_v2; + if (entry_v2 &= this) { + entry_v2->show_config_popup_v2(p_preset, p_parent, p_callback); + return true; + } + } catch (pfc::exception_not_implemented const&) {} + + dsp_preset_impl temp(p_preset); + bool rv = this->show_config_popup(temp, p_parent); + if (rv) p_callback.on_preset_changed(temp); + return rv; +} +namespace { + class dsp_preset_edit_callback_callV2 : public dsp_preset_edit_callback { + public: + dsp_preset_edit_callback_v2::ptr chain; + void on_preset_changed(const dsp_preset& arg) override { chain->set_preset(arg); } + }; +} +service_ptr dsp_entry::show_config_popup_v3_(fb2k::hwnd_t parent, dsp_preset_edit_callback_v2::ptr callback) { + dsp_entry_v3::ptr v3; + if (v3 &= this) { + try { + return v3->show_config_popup_v3(parent, callback); + } catch (pfc::exception_not_implemented const &) { + } + } + + dsp_preset_edit_callback_callV2 cb; + cb.chain = callback; + + dsp_preset_impl initPreset; callback->get_preset(initPreset); + bool status = this->show_config_popup_v2_(initPreset, parent, cb); + callback->dsp_dialog_done(status); + return nullptr; + +} +void dsp_entry::g_show_config_popup_v2(const dsp_preset & p_preset,fb2k::hwnd_t p_parent,dsp_preset_edit_callback & p_callback) { + auto api = g_get_interface(p_preset.get_owner()); + if (api.is_valid()) api->show_config_popup_v2_(p_preset, p_parent, p_callback); +} +#endif + +service_ptr_t dsp_entry::g_get_interface(const GUID& guid) { + for (auto ptr : enumerate()) { + if (ptr->get_guid() == guid) return ptr; + } + return nullptr; +} + +bool dsp_entry::g_get_interface(service_ptr_t & p_out,const GUID & p_guid) +{ + for (auto ptr : enumerate()) { + if (ptr->get_guid() == p_guid) { + p_out = ptr; + return true; + } + } + return false; +} + +bool resampler_entry::g_get_interface(service_ptr_t & p_out,unsigned p_srate_from,unsigned p_srate_to) +{ +#if defined(FOOBAR2000_DESKTOP) && FOOBAR2000_TARGET_VERSION >= 79 + auto r = resampler_manager::get()->get_resampler( p_srate_from, p_srate_to ); + bool v = r.is_valid(); + if ( v ) p_out = std::move(r); + return v; +#else + +#ifdef FOOBAR2000_DESKTOP + { + resampler_manager::ptr api; + if ( resampler_manager::tryGet(api) ) { + auto r = api->get_resampler( p_srate_from, p_srate_to ); + bool v = r.is_valid(); + if (v) p_out = std::move(r); + return v; + } + } +#endif + + resampler_entry::ptr ptr_resampler; + service_enum_t e; + float found_priority = 0; + resampler_entry::ptr found; + while(e.next(ptr_resampler)) + { + if (p_srate_from == 0 || ptr_resampler->is_conversion_supported(p_srate_from,p_srate_to)) + { + float priority = ptr_resampler->get_priority(); + if (found.is_empty() || priority > found_priority) + { + found = ptr_resampler; + found_priority = priority; + } + } + } + if (found.is_empty()) return false; + p_out = found; + return true; +#endif +} + +bool resampler_entry::g_create_preset(dsp_preset & p_out,unsigned p_srate_from,unsigned p_srate_to,float p_qualityscale) +{ + service_ptr_t entry; + if (!g_get_interface(entry,p_srate_from,p_srate_to)) return false; + return entry->create_preset(p_out,p_srate_to,p_qualityscale); +} + +bool resampler_entry::g_create(service_ptr_t & p_out,unsigned p_srate_from,unsigned p_srate_to,float p_qualityscale) +{ + service_ptr_t entry; + if (!g_get_interface(entry,p_srate_from,p_srate_to)) return false; + dsp_preset_impl preset; + if (!entry->create_preset(preset,p_srate_to,p_qualityscale)) return false; + return entry->instantiate(p_out,preset); +} + + +bool dsp_chain_config::equals(dsp_chain_config const & v1, dsp_chain_config const & v2) { + const t_size count = v1.get_count(); + if (count != v2.get_count()) return false; + for(t_size walk = 0; walk < count; ++walk) { + if (v1.get_item(walk) != v2.get_item(walk)) return false; + } + return true; +} +bool dsp_chain_config::equals_debug(dsp_chain_config const& v1, dsp_chain_config const& v2) { + FB2K_DebugLog() << "Comparing DSP chains"; + const t_size count = v1.get_count(); + if (count != v2.get_count()) { + FB2K_DebugLog() << "Count mismatch, " << count << " vs " << v2.get_count(); + return false; + } + for (t_size walk = 0; walk < count; ++walk) { + if (v1.get_item(walk) != v2.get_item(walk)) { + FB2K_DebugLog() << "Item " << (walk+1) << " mismatch"; + FB2K_DebugLog() << "Item 1: " << v1.get_item(walk).debug(); + FB2K_DebugLog() << "Item 2: " << v2.get_item(walk).debug(); + return false; + } + } + FB2K_DebugLog() << "DSP chains are identical"; + return true; +} + +void dsp_chain_config::get_name_list(pfc::string_base & p_out) const { + p_out = get_name_list(); +} + +pfc::string8 dsp_chain_config::get_name_list() const { + const size_t count = get_count(); + pfc::string8 output; output.prealloc(1024); + for (size_t n = 0; n < count; n++) + { + const auto& preset = get_item(n); + service_ptr_t ptr; + if (dsp_entry::g_get_interface(ptr, preset.get_owner())) + { + pfc::string8 temp; + ptr->get_display_name_(preset, temp); + if (temp.length() > 0) { + if (output.length() > 0) output += ", "; + output += temp; + } + } + } + + return output; +} + +void dsp::run_abortable(dsp_chunk_list * p_chunk_list,const dsp_track_t & p_cur_file,int p_flags,abort_callback & p_abort) { + service_ptr_t this_v2; + if (this->service_query_t(this_v2)) this_v2->run_v2(p_chunk_list,p_cur_file,p_flags,p_abort); + else run(p_chunk_list,p_cur_file,p_flags); +} + +bool dsp::apply_preset_(const dsp_preset& arg) { + dsp_v3::ptr v3; + if (v3 &= this) return v3->apply_preset(arg); + return false; +} + +namespace { + class dsp_preset_edit_callback_impl : public dsp_preset_edit_callback { + public: + dsp_preset_edit_callback_impl(dsp_preset & p_data) : m_data(p_data) {} + void on_preset_changed(const dsp_preset & p_data) {m_data = p_data;} + private: + dsp_preset & m_data; + }; +}; + +#ifdef _WIN32 +bool dsp_entry_v2::show_config_popup(dsp_preset & p_data,fb2k::hwnd_t p_parent) { + PFC_ASSERT(p_data.get_owner() == get_guid()); + dsp_preset_impl temp(p_data); + + { + dsp_preset_edit_callback_impl cb(temp); + show_config_popup_v2(p_data,p_parent,cb); + } + PFC_ASSERT(temp.get_owner() == get_guid()); + if (temp == p_data) return false; + p_data = temp; + return true; +} +#endif + +#ifdef FOOBAR2000_MOBILE +void dsp_entry::g_show_config_popup( menu_context_ptr ctx, dsp_preset_edit_callback_v2::ptr callback) { + GUID dspID; + { + dsp_preset_impl temp; + callback->get_preset( temp ); + dspID = temp.get_owner(); + } + + dsp_entry::ptr entry; + if (!g_get_interface( entry, dspID)) return; + if (!entry->have_config_popup()) return; + entry->show_config_popup( ctx, callback ); +} +#endif // FOOBAR2000_MOBILE + +#ifdef FOOBAR2000_DESKTOP +void resampler_manager::make_chain_(dsp_chain_config& outChain, unsigned rateFrom, unsigned rateTo, float qualityScale) { + resampler_manager_v2::ptr v2; + if (v2 &= this) { + v2->make_chain(outChain, rateFrom, rateTo, qualityScale); + } else { + outChain.remove_all(); + auto obj = this->get_resampler(rateFrom, rateTo); + if (obj.is_valid()) { + dsp_preset_impl p; + if (obj->create_preset(p, rateTo, qualityScale)) { + outChain.add_item(p); + } + } + } +} +#endif + +void dsp_preset_edit_callback_v2::reset() { + dsp_preset_impl temp; get_preset( temp ); + GUID id = temp.get_owner(); temp.set_data(nullptr, 0); + if (dsp_entry::g_get_default_preset( temp, id )) { + this->set_preset( temp ); + } else { + PFC_ASSERT(!"Should not get here - no such DSP"); + } +} + +bool dsp_entry::get_display_name_supported() { + dsp_entry_v3::ptr v3; + return v3 &= this; +} + +void dsp_entry::get_display_name_(const dsp_preset& arg, pfc::string_base& out) { + PFC_ASSERT(arg.get_owner() == this->get_guid()); + dsp_entry_v3::ptr v3; + if (v3 &= this) { + v3->get_display_name(arg, out); return; + } + get_name(out); +} + +bool dsp_entry::enumerate_default_presets_(dsp_chain_config& ret) { + ret.remove_all(); + dsp_entry_v5::ptr v5; + if (v5 &= this) { + bool rv = v5->enumerate_default_presets(ret); +#if PFC_DEBUG + for (size_t walk = 0; walk < ret.get_count(); ++walk) { + PFC_ASSERT(ret.get_item(walk).get_owner() == get_guid()); + } +#endif + return rv; + } + return false; +} + +bool dsp_entry::match_preset_subclass_(dsp_preset const& x, dsp_preset const& y) { + dsp_entry_v5::ptr v5; + if (v5 &= this) return v5->match_preset_subclass(x, y); + return true; +} + +#endif // FOOBAR2000_HAVE_DSP diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/dsp.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/dsp.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,737 @@ +#pragma once +#include "audio_chunk.h" +#include "filesystem.h" + +#ifdef FOOBAR2000_HAVE_DSP + +#ifdef FOOBAR2000_MOBILE +#include "dsp-context.h" +#endif + +#include +#include + +class dsp_preset; class dsp_chain_config; // forward declaration + +#ifdef FOOBAR2000_HAVE_METADB +typedef metadb_handle_ptr dsp_track_t; +#else +typedef trackRef dsp_track_t; +#endif + +//! Interface to a DSP chunk list. A DSP chunk list object is passed to the DSP chain each time, since DSPs are allowed to remove processed chunks or insert new ones. +class NOVTABLE dsp_chunk_list { +public: + virtual t_size get_count() const = 0; + virtual audio_chunk * get_item(t_size n) const = 0; + virtual void remove_by_idx(t_size idx) = 0; + virtual void remove_mask(const bit_array & mask) = 0; + virtual audio_chunk * insert_item(t_size idx,t_size hint_size=0) = 0; + + audio_chunk * add_item(t_size hint_size=0); + + void remove_all(); + + double get_duration(); + + void add_chunk(const audio_chunk * chunk); + + void remove_bad_chunks(); +protected: + dsp_chunk_list() {} + ~dsp_chunk_list() {} +}; + +class dsp_chunk_list_impl : public dsp_chunk_list//implementation +{ + typedef std::unique_ptr chunk_ptr_t; + std::vector m_data, m_recycled; +public: + dsp_chunk_list_impl() {} + dsp_chunk_list_impl(const dsp_chunk_list_impl&) = delete; + void operator=(const dsp_chunk_list_impl&) = delete; + t_size get_count() const; + audio_chunk * get_item(t_size n) const; + void remove_by_idx(t_size idx); + void remove_mask(const bit_array & mask); + audio_chunk * insert_item(t_size idx,t_size hint_size=0); + + audio_chunk_impl* get_item_(size_t n) const { return m_data[n].get(); } +}; + +//! Instance of a DSP.\n +//! Implementation: Derive from dsp_impl_base instead of deriving from dsp directly.\n +//! Instantiation: Use dsp_entry static helper methods to instantiate DSPs, or dsp_chain_config / dsp_manager to deal with entire DSP chains. +class NOVTABLE dsp : public service_base { +public: + enum { + //! Flush whatever you need to when tracks change. + END_OF_TRACK = 1, + //! Flush everything. + FLUSH = 2 + }; + + //! @param p_chunk_list List of chunks to process. The implementation may alter the list in any way, inserting chunks of different sample rate / channel configuration etc. + //! @param p_cur_file Optional, location of currently decoded file. May be null. + //! @param p_flags Flags. Can be null, or a combination of END_OF_TRACK and FLUSH constants. + virtual void run(dsp_chunk_list * p_chunk_list,const dsp_track_t & p_cur_file,int p_flags)=0; + + //! Flushes the DSP (reinitializes / drops any buffered data). Called after seeking, etc. + virtual void flush() = 0; + + //! Retrieves amount of data buffered by the DSP, for syncing visualisation. + //! @returns Amount of buffered audio data, in seconds. + virtual double get_latency() = 0; + //! Returns true if DSP needs to know exact track change point (eg. for crossfading, removing silence).\n + //! Signaling this will force-flush any DSPs placed before this DSP so when it gets END_OF_TRACK, relevant chunks contain last samples of the track.\n + //! Signaling this will often break regular gapless playback so don't use it unless you have reasons to. + virtual bool need_track_change_mark() = 0; + + void run_abortable(dsp_chunk_list * p_chunk_list,const dsp_track_t & p_cur_file,int p_flags,abort_callback & p_abort); + + //! Attempts to apply preset without recreating the DSP, if supported. + //! @returns True on success, false if not supported (DSP needs re-creating). + bool apply_preset_(const dsp_preset&); + + FB2K_MAKE_SERVICE_INTERFACE(dsp,service_base); +}; + +//! Backwards-compatible extension to dsp interface, allows abortable operation. Introduced in 0.9.2. +class NOVTABLE dsp_v2 : public dsp { +public: + //! Abortable version of dsp::run(). See dsp::run() for descriptions of parameters. + virtual void run_v2(dsp_chunk_list * p_chunk_list,const dsp_track_t & p_cur_file,int p_flags,abort_callback & p_abort) = 0; +private: + void run(dsp_chunk_list * p_chunk_list,const dsp_track_t & p_cur_file,int p_flags) { + run_v2(p_chunk_list,p_cur_file,p_flags,fb2k::noAbort); + } + + FB2K_MAKE_SERVICE_INTERFACE(dsp_v2,dsp); +}; + +//! Extended version allowing live changes in configuration without reinitialization. +class NOVTABLE dsp_v3 : public dsp_v2 { + FB2K_MAKE_SERVICE_INTERFACE(dsp_v3, dsp_v2); +public: + //! Live change of DSP settings. Return true if accepted, false if not (DSP will be destroyed and recreated). + virtual bool apply_preset(const dsp_preset&) = 0; +}; + +//! Helper class for implementing dsps. You should derive from dsp_impl_base instead of from dsp directly.\n +//! The dsp_impl_base_t template allows you to use a custom interface class as a base class for your implementation, in case you provide extended functionality.\n +//! Use dsp_factory_t<> template to register your dsp implementation. +//! The implementation - as required by dsp_factory_t<> template - must also provide following methods:\n +//! A constructor taking const dsp_preset&, initializing the DSP with specified preset data.\n +//! static void g_get_name(pfc::string_base &); - retrieving human-readable name of the DSP to display.\n +//! static bool g_get_default_preset(dsp_preset &); - retrieving default preset for this DSP. Return value is reserved for future use and should always be true.\n +//! static GUID g_get_guid(); - retrieving GUID of your DSP implementation, to be used to identify it when storing DSP chain configuration.\n +//! static bool g_have_config_popup(); - retrieving whether your DSP implementation supplies a popup dialog for configuring it.\n +//! static void g_show_config_popup(const dsp_preset & p_data,HWND p_parent, dsp_preset_edit_callback & p_callback); - displaying your DSP's settings dialog; called only when g_have_config_popup() returns true; call p_callback.on_preset_changed() whenever user has made adjustments to the preset data.\n +template +class dsp_impl_base_t : public t_baseclass { +private: + typedef dsp_impl_base_t t_self; + dsp_chunk_list * m_list = nullptr; + t_size m_chunk_ptr = 0; + dsp_track_t m_cur_file = nullptr; + void run_v2(dsp_chunk_list * p_list,const dsp_track_t & p_cur_file,int p_flags,abort_callback & p_abort) override; +protected: + //! Call only from on_chunk / on_endoftrack (on_endoftrack will give info on track being finished).\n + //! May return false when there's no known track and the metadb_handle ptr will be empty/null. + bool get_cur_file(dsp_track_t & p_out) const {p_out = m_cur_file; return p_out.is_valid();} + dsp_track_t get_cur_file() const { return m_cur_file; } + + dsp_impl_base_t() {} + + //! Inserts a new chunk of audio data. \n + //! You can call this only from on_chunk(), on_endofplayback() and on_endoftrack(). You're NOT allowed to call this from flush() which should just drop any queued data. + //! @param p_hint_size Optional, amount of buffer space that you require (in audio_samples). This is just a hint for memory allocation logic and will not cause the framework to allocate the chunk for you. + //! @returns A pointer to the newly allocated chunk. Pass the audio data you want to insert to this chunk object. The chunk is owned by the framework, you can't delete it etc. + audio_chunk * insert_chunk(t_size p_hint_size = 0) { + PFC_ASSERT(m_list != NULL); + return m_list->insert_item(m_chunk_ptr++,p_hint_size); + } + audio_chunk * insert_chunk( const audio_chunk & sourceCopy ) { + audio_chunk * c = insert_chunk( sourceCopy.get_used_size() ); + c->copy( sourceCopy ); + return c; + } + + + //! To be overridden by a DSP implementation.\n + //! Called on track change. You can use insert_chunk() to dump any data you have to flush. \n + //! Note that you must implement need_track_change_mark() to return true if you need this method called. + virtual void on_endoftrack(abort_callback & p_abort) = 0; + //! To be overridden by a DSP implementation.\n + //! Called at the end of played stream, typically at the end of last played track, to allow the DSP to return all data it has buffered-ahead.\n + //! Use insert_chunk() to return any data you have buffered.\n + //! Note that this call does not imply that the DSP will be destroyed next. \n + //! This is also called on track changes if some DSP placed after your DSP requests track change marks. + virtual void on_endofplayback(abort_callback & p_abort) = 0; + //! To be overridden by a DSP implementation.\n + //! Processes a chunk of audio data.\n + //! You can call insert_chunk() from inside on_chunk() to insert any audio data before currently processed chunk.\n + //! @param p_chunk Current chunk being processed. You can alter it in any way you like. + //! @returns True to keep p_chunk (with alterations made inside on_chunk()) in the stream, false to remove it. + virtual bool on_chunk(audio_chunk * p_chunk,abort_callback & p_abort) = 0; + +public: + //! To be overridden by a DSP implementation.\n + //! Flushes the DSP (drops any buffered data). The implementation should reset the DSP to the same state it was in before receiving any audio data. \n + //! Called after seeking, etc. + virtual void flush() override = 0; + //! To be overridden by a DSP implementation.\n + //! Retrieves amount of data buffered by the DSP, for syncing visualisation. + //! @returns Amount of buffered audio data, in seconds. + virtual double get_latency() override = 0; + //! To be overridden by a DSP implementation.\n + //! Returns true if DSP needs to know exact track change point (eg. for crossfading, removing silence).\n + //! Signaling this will force-flush any DSPs placed before this DSP so when it gets on_endoftrack(), relevant chunks contain last samples of the track.\n + //! Signaling this may interfere with gapless playback in certain scenarios (forces flush of DSPs placed before you) so don't use it unless you have reasons to. + virtual bool need_track_change_mark() override = 0; +private: + dsp_impl_base_t(const t_self&) = delete; + const t_self & operator=(const t_self &) = delete; +}; + +template +void dsp_impl_base_t::run_v2(dsp_chunk_list * p_list,const dsp_track_t & p_cur_file,int p_flags,abort_callback & p_abort) { + pfc::vartoggle_t l_list_toggle(m_list,p_list); + auto track_toggle = pfc::autoToggle(m_cur_file, p_cur_file); + + for(m_chunk_ptr = 0;m_chunk_ptrget_count();m_chunk_ptr++) { + audio_chunk * c = m_list->get_item(m_chunk_ptr); + if (c->is_empty() || !on_chunk(c,p_abort)) + m_list->remove_by_idx(m_chunk_ptr--); + } + + if (p_flags & dsp::FLUSH) { + on_endofplayback(p_abort); + } else if (p_flags & dsp::END_OF_TRACK) { + if (need_track_change_mark()) on_endoftrack(p_abort); + } +} + + +typedef dsp_impl_base_t dsp_impl_base; + +class NOVTABLE dsp_preset { +public: + virtual GUID get_owner() const = 0; + virtual void set_owner(const GUID & p_owner) = 0; + virtual const void * get_data() const = 0; + virtual t_size get_data_size() const = 0; + virtual void set_data(const void * p_data,t_size p_data_size) = 0; + virtual void set_data_from_stream(stream_reader * p_stream,t_size p_bytes,abort_callback & p_abort) = 0; + + const dsp_preset & operator=(const dsp_preset & p_source) {copy(p_source); return *this;} + + void copy(const dsp_preset & p_source) {set_owner(p_source.get_owner());set_data(p_source.get_data(),p_source.get_data_size());} + + void contents_to_stream(stream_writer * p_stream,abort_callback & p_abort) const; + void contents_from_stream(stream_reader * p_stream,abort_callback & p_abort); + static void g_contents_from_stream_skip(stream_reader * p_stream,abort_callback & p_abort); + + bool operator==(const dsp_preset & p_other) const { + if (get_owner() != p_other.get_owner()) return false; + if (get_data_size() != p_other.get_data_size()) return false; + if (memcmp(get_data(),p_other.get_data(),get_data_size()) != 0) return false; + return true; + } + bool operator!=(const dsp_preset & p_other) const { + return !(*this == p_other); + } + + pfc::string8 get_owner_name() const; + pfc::string8 get_owner_name_debug() const; + pfc::string8 debug(const char * knownName = nullptr) const; +protected: + dsp_preset() {} + ~dsp_preset() {} +}; + +class dsp_preset_writer : public stream_writer { +public: + void write(const void * p_buffer,t_size p_bytes,abort_callback & p_abort) { + p_abort.check(); + m_data.append_fromptr((const t_uint8 *) p_buffer,p_bytes); + } + void flush(dsp_preset & p_preset) { + p_preset.set_data(m_data.get_ptr(),m_data.get_size()); + m_data.set_size(0); + } +private: + pfc::array_t m_data; +}; + +class dsp_preset_reader : public stream_reader { +public: + dsp_preset_reader() : m_walk(0) {} + dsp_preset_reader(const dsp_preset_reader & p_source) : m_walk(0) {*this = p_source;} + void init(const dsp_preset & p_preset) { + m_data.set_data_fromptr( (const t_uint8*) p_preset.get_data(), p_preset.get_data_size() ); + m_walk = 0; + } + t_size read(void * p_buffer,t_size p_bytes,abort_callback & p_abort) { + p_abort.check(); + t_size todo = pfc::min_t(p_bytes,m_data.get_size()-m_walk); + memcpy(p_buffer,m_data.get_ptr()+m_walk,todo); + m_walk += todo; + return todo; + } + bool is_finished() {return m_walk == m_data.get_size();} +private: + t_size m_walk; + pfc::array_t m_data; +}; + +class dsp_preset_impl : public dsp_preset +{ +public: + dsp_preset_impl() {} + dsp_preset_impl(const dsp_preset_impl & p_source) {copy(p_source);} + dsp_preset_impl(const dsp_preset & p_source) {copy(p_source);} + dsp_preset_impl(dsp_preset_impl && p_source) noexcept {move(p_source);} + void clear() {m_owner = pfc::guid_null; m_data.clear();} + bool is_valid() const { return m_owner != pfc::guid_null; } + + const dsp_preset_impl& operator=(const dsp_preset_impl & p_source) {copy(p_source); return *this;} + const dsp_preset_impl& operator=(const dsp_preset & p_source) {copy(p_source); return *this;} + const dsp_preset_impl& operator=(dsp_preset_impl&& p_source) noexcept { move(p_source); return *this; } + + GUID get_owner() const {return m_owner;} + void set_owner(const GUID & p_owner) {m_owner = p_owner;} + const void * get_data() const {return m_data.ptr();} + t_size get_data_size() const {return m_data.size();} + void set_data(const void * p_data,t_size p_data_size) {m_data.set_data_fromptr((const t_uint8*)p_data,p_data_size);} + void set_data_from_stream(stream_reader * p_stream,t_size p_bytes,abort_callback & p_abort); + + void move(dsp_preset_impl& source) noexcept { + m_owner = source.m_owner; + m_data = std::move(source.m_data); + } + + void set_data(pfc::mem_block&& data) { m_data = std::move(data); } +private: + GUID m_owner = {}; + pfc::mem_block m_data; +}; + +class NOVTABLE dsp_preset_edit_callback { +public: + virtual void on_preset_changed(const dsp_preset &) = 0; +private: + dsp_preset_edit_callback(const dsp_preset_edit_callback&) = delete; + const dsp_preset_edit_callback & operator=(const dsp_preset_edit_callback &) = delete; +protected: + dsp_preset_edit_callback() {} + ~dsp_preset_edit_callback() {} +}; + +class NOVTABLE dsp_preset_edit_callback_v2 : public service_base { + FB2K_MAKE_SERVICE_INTERFACE(dsp_preset_edit_callback_v2, service_base); +public: + virtual void get_preset( dsp_preset & outPreset ) = 0; + virtual void set_preset( const dsp_preset & inPreset ) = 0; + virtual void dsp_dialog_done( bool bOK ) = 0; + void reset(); +}; + + +class NOVTABLE dsp_entry : public service_base { +public: + virtual void get_name(pfc::string_base & p_out) = 0; + virtual bool get_default_preset(dsp_preset & p_out) = 0; + virtual bool instantiate(service_ptr_t & p_out,const dsp_preset & p_preset) = 0; + virtual GUID get_guid() = 0; + virtual bool have_config_popup() = 0; + +#ifdef FOOBAR2000_MOBILE + virtual void show_config_popup( fb2k::dspConfigContext_t parent, dsp_preset_edit_callback_v2::ptr callback ) {} +#endif + +#ifdef FOOBAR2000_DESKTOP +#ifdef _WIN32 + //! Shows configuration popup. Call from main thread only! \n + //! Blocks until done. Returns true if preset has been altered, false otherwise. + //! Legacy method, replaced in dsp_entry_v2 and newer. + virtual bool show_config_popup(dsp_preset& p_data, fb2k::hwnd_t p_parent) { (void)p_data; (void)p_parent; return false; } +#else // non-Windows desktop + //! Shows configuration popup. Main thread only! \n + //! Mac: returns NSObjectWrapper holding NSViewController + virtual service_ptr show_config_popup(fb2k::hwnd_t parent, dsp_preset_edit_callback_v2::ptr callback) { (void)parent; (void)callback; throw pfc::exception_not_implemented(); } +#endif +#endif // FOOBAR2000_DESKTOP + + //! Obsolete method, hidden DSPs now use a different entry class. + bool is_user_accessible() { return true; } + + static constexpr unsigned flag_playback = 1 << 0, + flag_conversion = 1 << 1; + + static bool g_get_interface(service_ptr_t & p_out,const GUID & p_guid); + static service_ptr_t g_get_interface(const GUID&); + static bool g_instantiate(service_ptr_t & p_out,const dsp_preset & p_preset, unsigned flags = 0); + static bool g_instantiate_default(service_ptr_t & p_out,const GUID & p_guid); + static bool g_name_from_guid(pfc::string_base & p_out,const GUID & p_guid); + static bool g_dsp_exists(const GUID & p_guid); + static bool g_get_default_preset(dsp_preset & p_out,const GUID & p_guid); + static bool g_have_config_popup(const GUID & p_guid); + static bool g_have_config_popup(const dsp_preset & p_preset); +#ifdef _WIN32 + //! Shows configuration popup. Main thread only! \n + //! Blocks until done. Returns true if preset has been altered, false otherwise. + static bool g_show_config_popup(dsp_preset & p_preset,fb2k::hwnd_t p_parent); + //! Shows configuration popup. Main thread only! + //! Blocks until done. Uses callback to notify host about preset change. + static void g_show_config_popup_v2(const dsp_preset & p_preset,fb2k::hwnd_t p_parent,dsp_preset_edit_callback & p_callback); + + //! Shows configuration popup. Main thread only! \n + //! Blocks until done. Uses callback to notify host about preset change. \n + //! Implements a fallback using legacy methods if show_config_popup_v2() is not available. \n + //! @returns OK/cancel status (true/false), if the dialog supports it; otherwise always true. + bool show_config_popup_v2_(const dsp_preset& p_preset, fb2k::hwnd_t p_parent, dsp_preset_edit_callback& p_callback); + + //! Shows configuration popup. Main thread only! \n + //! May either block until done and return null, or run asynchronously and return an object to release to cancel the dialog. \n + //! Implements a fallback using legacy methods if show_config_popup_v3() is not available. + service_ptr show_config_popup_v3_(fb2k::hwnd_t parent, dsp_preset_edit_callback_v2::ptr callback); +#endif + +#ifdef FOOBAR2000_MOBILE + static void g_show_config_popup( fb2k::dspConfigContext_t parent, dsp_preset_edit_callback_v2::ptr callback); +#endif + + bool get_display_name_supported(); + void get_display_name_(const dsp_preset& arg, pfc::string_base& out); + bool enumerate_default_presets_(dsp_chain_config& ret); + bool match_preset_subclass_(dsp_preset const& x, dsp_preset const& y); + + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(dsp_entry); +}; + +class NOVTABLE dsp_entry_v2 : public dsp_entry { +public: +#ifdef _WIN32 + //! Shows configuration popup. Main thread only! + virtual void show_config_popup_v2(const dsp_preset & p_data,fb2k::hwnd_t p_parent,dsp_preset_edit_callback & p_callback) = 0; + // Obsolete method, redirected to show_config_popup_v2() by default, no need to implement. + bool show_config_popup(dsp_preset& p_data, fb2k::hwnd_t p_parent) override; +#endif +private: + + FB2K_MAKE_SERVICE_INTERFACE(dsp_entry_v2,dsp_entry); +}; + +//! \since Late 1.6.x +class NOVTABLE dsp_entry_v3 : public dsp_entry_v2 { + FB2K_MAKE_SERVICE_INTERFACE(dsp_entry_v3, dsp_entry_v2); +public: + //! Returns the text to show in DSP list, for this specific preset. + virtual void get_display_name(const dsp_preset& arg, pfc::string_base& out) = 0; + +#ifdef _WIN32 + //! Shows configuration popup, asynchronous version - creates dialog then returns immediately. \n + //! Since not every DSP implements this, caller must be prepared to call legacy blocking show_config_popup methods instead. \n + //! show_config_popup_v3() may throw pfc::exception_not_implemented() to signal host that this DSP doesn't support this method yet. \n + //! Main thread only! \n + //! @returns Object to retain by host, to be released to request the dialog to be closed. + virtual service_ptr show_config_popup_v3(fb2k::hwnd_t parent, dsp_preset_edit_callback_v2::ptr callback) = 0; +#endif +}; + +//! \since 2.1 +class NOVTABLE dsp_entry_v4 : public dsp_entry_v3 { + FB2K_MAKE_SERVICE_INTERFACE(dsp_entry_v4, dsp_entry_v3); +public: + virtual dsp::ptr instantiate_v4( const dsp_preset & arg, unsigned flags ) = 0; +}; + +//! \since 2.2 +class NOVTABLE dsp_entry_v5 : public dsp_entry_v4 { + FB2K_MAKE_SERVICE_INTERFACE(dsp_entry_v5, dsp_entry_v4); +public: + //! If your DSP implementation is meant to preset as multiple item in available DSP list, implement this method. \n + //! @returns True if preset list has been returned (your DSP will be hidden if blank), false if your DSP is meant to be shown as just one item. + virtual bool enumerate_default_presets(dsp_chain_config& ret) { (void)ret; return false; } + //! Can possibly reach state Y by editing state X, and vice versa? \n + //! If this DSP has no configuration UI, this should just test if the presets are identical. + //! Frontend will use this to pin running presets to one of available DSP list items. + virtual bool match_preset_subclass(dsp_preset const& x, dsp_preset const& y) { (void)x; (void)y; return true; } +}; + +class NOVTABLE dsp_entry_hidden : public service_base { + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(dsp_entry_hidden); +public: + //! Obsolete method, hidden DSPs now use a different entry class from ordinary ones. + bool is_user_accessible() {return false; } + + static bool g_get_interface( dsp_entry_hidden::ptr & out, const GUID & guid ); + static bool g_instantiate( dsp::ptr & out, const dsp_preset & preset ); + static bool g_dsp_exists(const GUID & p_guid); + + virtual bool instantiate(service_ptr_t & p_out,const dsp_preset & p_preset) = 0; + virtual GUID get_guid() = 0; +}; + +template +class dsp_entry_impl_nopreset_t : public t_entry { +public: + void get_name(pfc::string_base & p_out) override {T::g_get_name(p_out);} + bool get_default_preset(dsp_preset & p_out) override + { + p_out.set_owner(T::g_get_guid()); + p_out.set_data(0,0); + return true; + } + bool instantiate(service_ptr_t & p_out,const dsp_preset & p_preset) override + { + if (p_preset.get_owner() == T::g_get_guid() && p_preset.get_data_size() == 0) + { + p_out = new service_impl_t(); + return p_out.is_valid(); + } + else return false; + } + GUID get_guid() override {return T::g_get_guid();} + + bool have_config_popup() override {return false;} +}; + +template +class dsp_entry_common_t : public interface_t { +public: + void get_name(pfc::string_base& p_out) override { T::g_get_name(p_out); } + bool get_default_preset(dsp_preset& p_out) override { return T::g_get_default_preset(p_out); } + bool instantiate(service_ptr_t& p_out, const dsp_preset& p_preset) override { + if (p_preset.get_owner() == T::g_get_guid()) { + p_out = new service_impl_t(p_preset); + return true; + } else return false; + } + GUID get_guid() override { return T::g_get_guid(); } + + bool have_config_popup() override { return T::g_have_config_popup(); } +#ifdef FOOBAR2000_MOBILE + void show_config_popup( fb2k::dspConfigContext_t parent, dsp_preset_edit_callback_v2::ptr callback ) override { T::g_show_config_popup(parent, callback); } +#endif +#if defined(FOOBAR2000_DESKTOP) && !defined(_WIN32) + service_ptr show_config_popup( fb2k::hwnd_t parent, dsp_preset_edit_callback_v2::ptr callback ) override { + return T::g_show_config_popup(parent, callback); + } +#endif +}; + +template +class dsp_entry_impl_t : public dsp_entry_common_t { +public: +#ifdef _WIN32 + bool show_config_popup(dsp_preset & p_data,fb2k::hwnd_t p_parent) override {return T::g_show_config_popup(p_data,p_parent);} +#endif +}; + +template +class dsp_entry_v2_impl_t : public dsp_entry_common_t { +public: +#ifdef _WIN32 + void show_config_popup_v2(const dsp_preset & p_data,fb2k::hwnd_t p_parent,dsp_preset_edit_callback & p_callback) override {T::g_show_config_popup(p_data,p_parent,p_callback);} +#endif +}; + +template +class dsp_entry_v3_impl_t : public dsp_entry_v2_impl_t { +public: + void get_display_name(const dsp_preset& arg, pfc::string_base& out) override { + T::g_get_display_name(arg, out); + } + +#ifdef _WIN32 + service_ptr show_config_popup_v3(fb2k::hwnd_t parent, dsp_preset_edit_callback_v2::ptr callback) override { + return T::g_show_config_popup_v3(parent, callback); + } +#endif +}; + +template +class dsp_entry_v4_impl_t : public dsp_entry_v3_impl_t< dsp_t, entry_t > { +public: + dsp::ptr instantiate_v4( const dsp_preset & arg, unsigned flags ) override { + PFC_ASSERT( arg.get_owner() == dsp_t::g_get_guid() ); + return new service_impl_t< dsp_t > ( arg, flags ); + } +}; + +template +class dsp_entry_v5_impl_t : public dsp_entry_v4_impl_t< dsp_t, entry_t > { +public: + bool enumerate_default_presets(dsp_chain_config& ret) { + return dsp_t::g_enumerate_default_presets(ret); + } + bool match_preset_subclass(dsp_preset const& x, dsp_preset const& y) { + return dsp_t::g_match_preset_subclass(x, y); + } +}; + +template +class dsp_entry_hidden_t : public dsp_entry_hidden { +public: + bool instantiate(service_ptr_t & p_out,const dsp_preset & p_preset) override { + if (p_preset.get_owner() == dsp_t::g_get_guid()) { + p_out = new service_impl_t(p_preset); + return true; + } else return false; + } + GUID get_guid() override {return dsp_t::g_get_guid();} +}; + +template +class implement_dsp_entry; + +template class implement_dsp_entry : public dsp_entry_impl_t {}; +template class implement_dsp_entry : public dsp_entry_v2_impl_t {}; +template class implement_dsp_entry : public dsp_entry_v3_impl_t {}; +template class implement_dsp_entry : public dsp_entry_v4_impl_t {}; +template class implement_dsp_entry : public dsp_entry_v5_impl_t {}; +template class implement_dsp_entry : public dsp_entry_hidden_t {}; + +template +class dsp_factory_nopreset_t : public service_factory_single_t > {}; + +template +class dsp_factory_t : public service_factory_single_t > {}; + +template +class dsp_factory_hidden_t : public service_factory_single_t< dsp_entry_hidden_t > {}; + +class NOVTABLE dsp_chain_config +{ +public: + virtual t_size get_count() const = 0; + virtual const dsp_preset & get_item(t_size p_index) const = 0; + virtual void replace_item(const dsp_preset & p_data,t_size p_index) = 0; + virtual void insert_item(const dsp_preset & p_data,t_size p_index) = 0; + virtual void remove_mask(const bit_array & p_mask) = 0; + + void remove_item(t_size p_index); + void remove_all(); + void add_item(const dsp_preset & p_data); + void copy(const dsp_chain_config & p_source); + void add_items(const dsp_chain_config & p_source); + + const dsp_chain_config & operator=(const dsp_chain_config & p_source) {copy(p_source); return *this;} + + void contents_to_stream(stream_writer * p_stream,abort_callback & p_abort) const; + void contents_from_stream(stream_reader * p_stream,abort_callback & p_abort); + fb2k::memBlock::ptr to_blob() const; + void from_blob(const void* p, size_t size); + void from_blob(fb2k::memBlock::ptr); + + pfc::string8 get_name_list() const; + void get_name_list(pfc::string_base & p_out) const; + + static bool equals(dsp_chain_config const & v1, dsp_chain_config const & v2); + static bool equals_debug(dsp_chain_config const& v1, dsp_chain_config const& v2); + + //! Helpers to enable/disable specific DSP in this chain. Return true if the chain has been altered, false otherwise. + bool enable_dsp( const GUID & dspID ); + //! Helpers to enable/disable specific DSP in this chain. Return true if the chain has been altered, false otherwise. + bool disable_dsp( const GUID & dspID ); + //! Helpers to enable/disable specific DSP in this chain. Return true if the chain has been altered, false otherwise. + bool enable_dsp( const dsp_preset & preset ); + + size_t find_first_of_type( const GUID & dspID ) const; + bool contains_dsp( const GUID & dspID ) const; + + pfc::string8 debug() const; + + bool operator==(const dsp_chain_config & other) const {return equals(*this, other);} + bool operator!=(const dsp_chain_config & other) const {return !equals(*this, other);} +}; + +FB2K_STREAM_READER_OVERLOAD(dsp_chain_config) { + value.contents_from_stream(&stream.m_stream, stream.m_abort); return stream; +} + +FB2K_STREAM_WRITER_OVERLOAD(dsp_chain_config) { + value.contents_to_stream(&stream.m_stream, stream.m_abort); return stream; +} + +class dsp_chain_config_impl : public dsp_chain_config +{ +public: + dsp_chain_config_impl() {} + dsp_chain_config_impl(const dsp_chain_config & p_source) {copy(p_source);} + dsp_chain_config_impl(const dsp_chain_config_impl & p_source) { copy_v2(p_source);} + dsp_chain_config_impl(dsp_chain_config_impl&& p_source) noexcept : m_data(std::move(p_source.m_data)) {} + t_size get_count() const override; + const dsp_preset & get_item(t_size p_index) const override; + void replace_item(const dsp_preset & p_data,t_size p_index) override; + void insert_item(const dsp_preset & p_data,t_size p_index) override; + void remove_mask(const bit_array & p_mask) override; + + const char* get_dsp_name(size_t idx) const; + void insert_item_v2(const dsp_preset& data, const char* dspName, size_t index); + void add_item_v2(const dsp_preset& data, const char* dspName); + void copy_v2(dsp_chain_config_impl const&); + pfc::string8 debug() const; + + const dsp_chain_config_impl & operator=(const dsp_chain_config & p_source) {copy(p_source); return *this;} + const dsp_chain_config_impl & operator=(const dsp_chain_config_impl & p_source) {copy_v2(p_source); return *this;} + const dsp_chain_config_impl & operator=(dsp_chain_config_impl&& p_source) noexcept { m_data = std::move(p_source.m_data); p_source.m_data.remove_all(); return *this; } + + ~dsp_chain_config_impl(); + + void reorder( const size_t * order, size_t count ); + + void supply_name(size_t idx, pfc::string8 && name) { m_data[idx]->dspName = std::move(name); } + const char* find_dsp_name(const GUID& guid) const; +private: + + struct entry_t { + dsp_preset_impl data; + pfc::string8 dspName; + }; + + + pfc::ptr_list_t m_data; +}; + +//! Helper. +class dsp_preset_parser : public stream_reader_formatter<> { +public: + dsp_preset_parser(const dsp_preset& in) : stream_reader_formatter(_m_stream, fb2k::noAbort), m_data(in), _m_stream(in.get_data(), in.get_data_size()) {} + + void reset() { _m_stream.reset(); } + t_size get_remaining() const { return _m_stream.get_remaining(); } + + void assume_empty() const { + if (get_remaining() != 0) throw exception_io_data(); + } + + GUID get_owner() const { return m_data.get_owner(); } +private: + const dsp_preset& m_data; + stream_reader_memblock_ref _m_stream; +}; + +//! Helper. +class dsp_preset_builder : public stream_writer_formatter<> { +public: + dsp_preset_builder() : stream_writer_formatter(_m_stream, fb2k::noAbort) {} + void finish(const GUID& id, dsp_preset& out) { + out.set_owner(id); + out.set_data(_m_stream.m_buffer.get_ptr(), _m_stream.m_buffer.get_size()); + } + void reset() { + _m_stream.m_buffer.set_size(0); + } +private: + stream_writer_buffer_simple _m_stream; +}; + +#ifdef __APPLE__ +// NSObjectWrapper +#include "commonObjects-Apple.h" +#endif + +#endif diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/dsp_manager.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/dsp_manager.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,210 @@ +#include "foobar2000-sdk-pch.h" +#include "dsp_manager.h" + +#ifdef FOOBAR2000_HAVE_DSP + +void dsp_manager::close() { + m_chain.remove_all(); + m_config_changed = true; +} + +void dsp_manager::set_config( const dsp_chain_config & p_data ) +{ + //dsp_chain_config::g_instantiate(m_dsp_list,p_data); + m_config.copy(p_data); + m_config_changed = true; +} + +bool dsp_manager::need_track_change_mark() const { + for ( auto i = this->m_chain.first(); i.is_valid(); ++ i ) { + if ( i->m_dsp->need_track_change_mark() ) return true; + } + return false; +} + +void dsp_manager::dsp_run(t_dsp_chain::const_iterator p_iter,dsp_chunk_list * p_list,const dsp_track_t & cur_file,unsigned flags,double & latency,abort_callback & p_abort) +{ + p_list->remove_bad_chunks(); + + TRACK_CODE("dsp::run",p_iter->m_dsp->run_abortable(p_list,cur_file,flags,p_abort)); + TRACK_CODE("dsp::get_latency",latency += p_iter->m_dsp->get_latency()); +} + +double dsp_manager::run(dsp_chunk_list * p_list,const dsp_track_t & p_cur_file,unsigned p_flags,abort_callback & p_abort) { + TRACK_CALL_TEXT("dsp_manager::run"); + + try { +#if defined(_MSC_VER) && defined(_M_IX86) + fpu_control_default l_fpu_control; +#endif + double latency=0; + bool done = false; + + t_dsp_chain::const_iterator flush_mark; + if ((p_flags & dsp::END_OF_TRACK) && ! (p_flags & dsp::FLUSH)) { + for(t_dsp_chain::const_iterator iter = m_chain.first(); iter.is_valid(); ++iter) { + if (iter->m_dsp->need_track_change_mark()) flush_mark = iter; + } + } + + if (m_config_changed) + { + t_dsp_chain newchain; + bool recycle_available = true; + + for(t_size n=0;n temp; + + const dsp_preset & preset = m_config.get_item(n); + const GUID owner = preset.get_owner(); + if (dsp_entry::g_dsp_exists(owner) || dsp_entry_hidden::g_dsp_exists(owner)) { + t_dsp_chain::iterator iter = newchain.insert_last(); + iter->m_preset = m_config.get_item(n); + iter->m_recycle_flag = false; + } + } + + + // Recycle existing DSPs in a special case when user has apparently only altered settings of one of DSPs. + if (newchain.get_count() == m_chain.get_count()) { + t_size data_mismatch_count = 0; + t_size owner_mismatch_count = 0; + t_dsp_chain::iterator iter_src, iter_dst; + iter_src = m_chain.first(); iter_dst = newchain.first(); + while(iter_src.is_valid() && iter_dst.is_valid()) { + if (iter_src->m_preset.get_owner() != iter_dst->m_preset.get_owner()) { + owner_mismatch_count++; + } else if (iter_src->m_preset != iter_dst->m_preset) { + data_mismatch_count++; + } + ++iter_src; ++iter_dst; + } + recycle_available = (owner_mismatch_count == 0 && data_mismatch_count <= 1); + } else { + recycle_available = false; + } + + if (recycle_available) { + t_dsp_chain::iterator iter_src, iter_dst; + iter_src = m_chain.first(); iter_dst = newchain.first(); + while(iter_src.is_valid() && iter_dst.is_valid()) { + if (iter_src->m_preset == iter_dst->m_preset) { + iter_src->m_recycle_flag = true; + iter_dst->m_dsp = iter_src->m_dsp; + } + ++iter_src; ++iter_dst; + } + } + + for( auto & iter : newchain ) { + if (iter.m_dsp.is_empty()) { + if (!dsp_entry::g_instantiate(iter.m_dsp,iter.m_preset, m_creationFlags) && !dsp_entry_hidden::g_instantiate(iter.m_dsp, iter.m_preset)) uBugCheck(); + } + } + + if (m_chain.get_count()>0) { + bool flushflag = flush_mark.is_valid(); + for(t_dsp_chain::const_iterator iter = m_chain.first(); iter.is_valid(); ++iter) { + unsigned flags2 = p_flags; + if (iter == flush_mark) flushflag = false; + if (flushflag || !iter->m_recycle_flag) flags2|=dsp::FLUSH; + dsp_run(iter,p_list,p_cur_file,flags2,latency,p_abort); + } + done = true; + } + + m_chain = newchain; + m_config_changed = false; + } + + if (!done) + { + bool flushflag = flush_mark.is_valid(); + for(t_dsp_chain::const_iterator iter = m_chain.first(); iter.is_valid(); ++iter) { + unsigned flags2 = p_flags; + if (iter == flush_mark) flushflag = false; + if (flushflag) flags2|=dsp::FLUSH; + dsp_run(iter,p_list,p_cur_file,flags2,latency,p_abort); + } + done = true; + } + + p_list->remove_bad_chunks(); + + return latency; + } catch(...) { + p_list->remove_all(); + throw; + } +} + +void dsp_manager::flush() +{ + for(t_dsp_chain::const_iterator iter = m_chain.first(); iter.is_valid(); ++iter) { + TRACK_CODE("dsp::flush",iter->m_dsp->flush()); + } +} + + +bool dsp_manager::is_active() const {return m_config.get_count()>0;} + +void dsp_config_manager::core_enable_dsp(const dsp_preset & preset, default_insert_t insertWhere ) { + dsp_chain_config_impl cfg; + get_core_settings(cfg); + + bool found = false; + bool changed = false; + t_size n,m = cfg.get_count(); + for(n=0;n m_dsp; + dsp_preset_impl m_preset; + bool m_recycle_flag; + }; + typedef pfc::chain_list_v2_t t_dsp_chain; + + t_dsp_chain m_chain; + dsp_chain_config_impl m_config; + bool m_config_changed = false; + + void dsp_run(t_dsp_chain::const_iterator p_iter,dsp_chunk_list * list,const dsp_track_t & cur_file,unsigned flags,double & latency,abort_callback&); + + dsp_manager(const dsp_manager &) = delete; + const dsp_manager & operator=(const dsp_manager&) = delete; +}; + +//! Core API for accessing core playback DSP settings as well as spawning DSP configuration dialogs. \n +//! Use dsp_config_manager::get() to obtain an instance. +class dsp_config_manager : public service_base { + FB2K_MAKE_SERVICE_COREAPI(dsp_config_manager); +public: + //! Retrieves current core playback DSP settings. + virtual void get_core_settings(dsp_chain_config & p_out) = 0; + //! Changes current core playback DSP settings. + virtual void set_core_settings(const dsp_chain_config & p_data) = 0; + +#ifdef _WIN32 + //! Runs a modal DSP settings dialog. + //! @param p_data DSP chain configuration to edit - contains initial configuration to put in the dialog when called, receives the new configuration on successful edit. + //! @returns True when user approved DSP configuration changes (pressed the "OK" button), false when the user cancelled them ("Cancel" button). + virtual bool configure_popup(dsp_chain_config & p_data,fb2k::hwnd_t p_parent,const char * p_title) = 0; + + //! Spawns an embedded DSP settings dialog. + //! @param p_initdata Initial DSP chain configuration to put in the dialog. + //! @param p_parent Parent window to contain the embedded dialog. + //! @param p_id Control ID of the embedded dialog. The parent window will receive a WM_COMMAND with BN_CLICKED and this identifier when user changes settings in the embedded dialog. + //! @param p_from_modal Must be set to true when the parent window is a modal dialog, false otherwise. + virtual fb2k::hwnd_t configure_embedded(const dsp_chain_config & p_initdata,fb2k::hwnd_t p_parent,unsigned p_id,bool p_from_modal) = 0; + //! Retrieves current settings from an embedded DSP settings dialog. See also: configure_embedded(). + virtual void configure_embedded_retrieve(fb2k::hwnd_t wnd,dsp_chain_config & p_data) = 0; + //! Changes current settings in an embedded DSP settings dialog. See also: configure_embedded(). + virtual void configure_embedded_change(fb2k::hwnd_t wnd,const dsp_chain_config & p_data) = 0; +#endif + + enum default_insert_t { + default_insert_last, + default_insert_first, + }; + //! Helper - enables a DSP in core playback settings. + void core_enable_dsp(const dsp_preset & preset, default_insert_t insertWhere = default_insert_first ); + //! Helper - disables a DSP in core playback settings. + void core_disable_dsp(const GUID & id); + //! Helper - if a DSP with the specified identifier is present in playback settings, retrieves its configuration and returns true, otherwise returns false. + bool core_query_dsp(const GUID & id, dsp_preset & out); +}; + +//! \since 1.4 +//! Allows manipulation of DSP presets saved by user. \n +//! Note that there's no multi thread safety implemented, all methods are valid from main thread only. +class dsp_config_manager_v2 : public dsp_config_manager { + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(dsp_config_manager_v2, dsp_config_manager) +public: + virtual size_t get_preset_count() = 0; + virtual void get_preset_name( size_t index, pfc::string_base & out ) = 0; + virtual void get_preset_data( size_t index, dsp_chain_config & out ) = 0; + virtual void select_preset( size_t which ) = 0; + virtual size_t get_selected_preset() = 0; +}; + +//! Callback class for getting notified about core playback DSP settings getting altered. \n +//! Register your implementations with static service_factory_single_t g_myclass_factory; +class NOVTABLE dsp_config_callback : public service_base { + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(dsp_config_callback); +public: + //! Called when core playback DSP settings change. \n + //! Note: you must not try to alter core playback DSP settings inside this callback, or call anything else that possibly alters core playback DSP settings. + virtual void on_core_settings_change(const dsp_chain_config & p_newdata) = 0; +}; + +#endif // FOOBAR2000_HAVE_DSP diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/event_logger.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/event_logger.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,50 @@ +#pragma once + +#if defined(FOOBAR2000_DESKTOP) || PFC_DEBUG +// RATIONALE +// Mobile target doesn't really care about event logging, logger interface exists there only for source compat +// We can use macros to suppress all PFC_string_formatter bloat for targets that do not care about any of this +#define FB2K_HAVE_EVENT_LOGGER +#endif + +class NOVTABLE event_logger : public service_base { + FB2K_MAKE_SERVICE_INTERFACE(event_logger, service_base); +public: + enum { + severity_status, + severity_warning, + severity_error + }; + void log_status(const char * line) {log_entry(line, severity_status);} + void log_warning(const char * line) {log_entry(line, severity_warning);} + void log_error(const char * line) {log_entry(line, severity_error);} + + virtual void log_entry(const char * line, unsigned severity) = 0; +}; + +class event_logger_fallback : public event_logger { +public: + void log_entry(const char * line, unsigned) {console::print(line);} +}; + +class NOVTABLE event_logger_recorder : public event_logger { + FB2K_MAKE_SERVICE_INTERFACE( event_logger_recorder , event_logger ); +public: + virtual void playback( event_logger::ptr playTo ) = 0; + + static event_logger_recorder::ptr create(); +}; + +#ifdef FB2K_HAVE_EVENT_LOGGER + +#define FB2K_LOG_STATUS(X,Y) (X)->log_status(Y) +#define FB2K_LOG_WARNING(X,Y) (X)->log_warning(Y) +#define FB2K_LOG_ERROR(X,Y) (X)->log_error(Y) + +#else + +#define FB2K_LOG_STATUS(X,Y) ((void)0) +#define FB2K_LOG_WARNING(X,Y) ((void)0) +#define FB2K_LOG_ERROR(X,Y) ((void)0) + +#endif diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/exception_io.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/exception_io.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,77 @@ +#pragma once + + +namespace foobar2000_io +{ + //! Generic I/O error. Root class for I/O failure exception. See relevant default message for description of each derived exception class. + PFC_DECLARE_EXCEPTION(exception_io, pfc::exception, "I/O error"); + //! Object not found. + PFC_DECLARE_EXCEPTION(exception_io_not_found, exception_io, "Object not found"); + //! Access denied. \n + //! Special Windows note: this MAY be thrown instead of exception_io_sharing_violation by operations that rename/move files due to Win32 MoveFile() bugs. + PFC_DECLARE_EXCEPTION(exception_io_denied, exception_io, "Access denied"); + //! Access denied. + PFC_DECLARE_EXCEPTION(exception_io_denied_readonly, exception_io_denied, "File is read-only"); + //! Unsupported format or corrupted file (unexpected data encountered). + PFC_DECLARE_EXCEPTION(exception_io_data, exception_io, "Unsupported format or corrupted file"); + //! Unsupported format or corrupted file (truncation encountered). + PFC_DECLARE_EXCEPTION(exception_io_data_truncation, exception_io_data, "Unsupported format or corrupted file"); + //! Unsupported format (a subclass of "unsupported format or corrupted file" exception). + PFC_DECLARE_EXCEPTION(exception_io_unsupported_format, exception_io_data, "Unsupported file format"); + //! Decode error - subsong index out of expected range + PFC_DECLARE_EXCEPTION(exception_io_bad_subsong_index, exception_io_data, "Unexpected subsong index"); + //! Object is remote, while specific operation is supported only for local objects. + PFC_DECLARE_EXCEPTION(exception_io_object_is_remote, exception_io, "This operation is not supported on remote objects"); + //! Sharing violation. + PFC_DECLARE_EXCEPTION(exception_io_sharing_violation, exception_io, "File is already in use"); + //! Device full. + PFC_DECLARE_EXCEPTION(exception_io_device_full, exception_io, "Device full"); + //! Attempt to seek outside valid range. + PFC_DECLARE_EXCEPTION(exception_io_seek_out_of_range, exception_io, "Seek offset out of range"); + //! This operation requires a seekable object. + PFC_DECLARE_EXCEPTION(exception_io_object_not_seekable, exception_io, "Object is not seekable"); + //! This operation requires an object with known length. + PFC_DECLARE_EXCEPTION(exception_io_no_length, exception_io, "Length of object is unknown"); + //! Invalid path. + PFC_DECLARE_EXCEPTION(exception_io_no_handler_for_path, exception_io, "Invalid path"); + //! Object already exists. + PFC_DECLARE_EXCEPTION(exception_io_already_exists, exception_io, "Object already exists"); + //! Pipe error. + PFC_DECLARE_EXCEPTION(exception_io_no_data, exception_io, "The process receiving or sending data has terminated"); + //! Network not reachable. + PFC_DECLARE_EXCEPTION(exception_io_network_not_reachable, exception_io, "Network not reachable"); + //! Media is write protected. + PFC_DECLARE_EXCEPTION(exception_io_write_protected, exception_io_denied, "The media is write protected"); + //! File is corrupted. This indicates filesystem call failure, not actual invalid data being read by the app. + PFC_DECLARE_EXCEPTION(exception_io_file_corrupted, exception_io, "The file is corrupted"); + //! The disc required for requested operation is not available. + PFC_DECLARE_EXCEPTION(exception_io_disk_change, exception_io, "Disc not available"); + //! The directory is not empty. + PFC_DECLARE_EXCEPTION(exception_io_directory_not_empty, exception_io, "Directory not empty"); + //! A network connectivity error + PFC_DECLARE_EXCEPTION(exception_io_net, exception_io, "Network error"); + //! A network security error + PFC_DECLARE_EXCEPTION(exception_io_net_security, exception_io_net, "Network security error"); + //! A network connectivity error, specifically a DNS query failure + PFC_DECLARE_EXCEPTION(exception_io_dns, exception_io_net, "DNS error"); + //! The path does not point to a directory. + PFC_DECLARE_EXCEPTION(exception_io_not_directory, exception_io, "Not a directory"); + //! Functionality not supported by this device or file system. + PFC_DECLARE_EXCEPTION(exception_io_unsupported_feature, exception_io, "Unsupported feature"); + +#ifdef _WIN32 + PFC_NORETURN void exception_io_from_win32(DWORD p_code); +#define WIN32_IO_OP(X) {SetLastError(NO_ERROR); if (!(X)) exception_io_from_win32(GetLastError());} + + // SPECIAL WORKAROUND: throw "file is read-only" rather than "access denied" where appropriate + PFC_NORETURN void win32_file_write_failure(DWORD p_code, const char* path); +#else + + PFC_NORETURN void exception_io_from_nix(int code); + PFC_NORETURN void nix_io_op_fail(); + void nix_pre_io_op(); +#define NIX_IO_OP(X) { if (!(X)) nix_io_op_fail();} + +#endif + +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/exceptions.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/exceptions.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,13 @@ +#pragma once +//! Base class for exceptions that should show a human readable message when caught in app entrypoint function rather than crash and send a crash report. +PFC_DECLARE_EXCEPTION(exception_messagebox,pfc::exception,"Internal Error"); + +//! Base class for exceptions that should result in a quiet app shutdown. +PFC_DECLARE_EXCEPTION(exception_shutdownrequest,pfc::exception,"Shutdown Request"); + + +PFC_DECLARE_EXCEPTION(exception_installdamaged, exception_messagebox, "Internal error - one or more of the installed components have been damaged; please run the foobar2000 installer again."); +PFC_DECLARE_EXCEPTION(exception_osfailure, exception_messagebox, "Internal error - broken Windows installation?"); +PFC_DECLARE_EXCEPTION(exception_out_of_resources, exception_messagebox, "Not enough system resources available."); + +PFC_DECLARE_EXCEPTION(exception_configdamaged, exception_messagebox, "Internal error - configuration files are unreadable."); diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/file.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/file.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,510 @@ +#pragma once + +#include "exception_io.h" + +class file_info; +class mem_block_container; + +//! Contains various I/O related structures and interfaces. +namespace foobar2000_io +{ + //! Type used for file size related variables. + typedef t_uint64 t_filesize; + //! Type used for file size related variables when a signed value is needed. + typedef t_int64 t_sfilesize; + //! Type used for file timestamp related variables. 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601; 0 for invalid/unknown time. + typedef t_uint64 t_filetimestamp; + //! Invalid/unknown file timestamp constant. Also see: t_filetimestamp. + const t_filetimestamp filetimestamp_invalid = 0; + //! Invalid/unknown file size constant. Also see: t_filesize. + static constexpr t_filesize filesize_invalid = (t_filesize)(UINT64_MAX); + + static constexpr t_filetimestamp filetimestamp_1second_increment = 10000000; + + //! Stores file stats (size and timestamp). + struct t_filestats { + //! Size of the file. + t_filesize m_size = filesize_invalid; + //! Time of last file modification. + t_filetimestamp m_timestamp = filetimestamp_invalid; + + inline bool operator==(const t_filestats& param) const { return m_size == param.m_size && m_timestamp == param.m_timestamp; } + inline bool operator!=(const t_filestats& param) const { return m_size != param.m_size || m_timestamp != param.m_timestamp; } + + pfc::string8 describe() const; + pfc::string8 debug() const { return describe(); } + }; + + struct t_filestats2 { + //! Size of the file. + t_filesize m_size = filesize_invalid; + //! Time of last file modification. + t_filetimestamp m_timestamp = filetimestamp_invalid; + t_filetimestamp m_timestampCreate = filetimestamp_invalid; + uint32_t m_attribs = 0; + uint32_t m_attribsValid = 0; + + t_filestats const& as_legacy() const { return *reinterpret_cast(this); } + t_filestats to_legacy() const { return { m_size, m_timestamp }; } + static t_filestats2 from_legacy(t_filestats const& in) { return { in.m_size, in.m_timestamp }; } + + enum { + attr_readonly = 1 << 0, + attr_folder = 1 << 1, + attr_hidden = 1 << 2, + attr_system = 1 << 3, + attr_remote = 1 << 4, + }; + bool is_set(uint32_t attr) const { + PFC_ASSERT(m_attribsValid & attr); + return (m_attribs & attr) != 0; + } + bool is_readonly() const { return is_set(attr_readonly); } + bool is_folder() const { return is_set(attr_folder); } + bool is_file() const { return !is_folder(); } + bool is_hidden() const { return is_set(attr_hidden); } + bool can_write() const { return !is_readonly(); } + bool is_system() const { return is_set(attr_system); } + bool is_remote() const { return is_set(attr_remote); } + + void set_attrib(uint32_t f, bool v) { + if (v) m_attribs |= f; + else m_attribs &= ~f; + m_attribsValid |= f; + } + void set_file(bool v = true) { set_folder(!v); } + void set_folder(bool v = true) { set_attrib(attr_folder, v); } + void set_readonly(bool v) { set_attrib(attr_readonly, v); } + void set_hidden(bool v) { set_attrib(attr_hidden, v); } + void set_system(bool v) { set_attrib(attr_system, v); } + void set_remote(bool v = true) { set_attrib(attr_remote, v); } + + static pfc::string8 format_attribs(uint32_t flags, const char* delim = ", "); + pfc::string8 format_attribs(const char* delim = ", ") const { return format_attribs(m_attribs, delim); } + + static bool equals(t_filestats2 const& v1, t_filestats2 const& v2) { + return v1.m_size == v2.m_size && v1.m_timestamp == v2.m_timestamp && v1.m_timestampCreate == v2.m_timestampCreate && v1.m_attribsValid == v2.m_attribsValid && v1.m_attribs == v2.m_attribs; + } + bool operator==(const t_filestats2& other) const { return equals(*this, other); } + bool operator!=(const t_filestats2& other) const { return !equals(*this, other); } + + pfc::string8 describe() const; + pfc::string8 debug() const { return describe(); } + + bool haveSize() const { return m_size != filesize_invalid; } + bool haveTimestamp() const { return m_timestamp != filetimestamp_invalid; } + bool haveTimestampCreate() const { return m_timestampCreate != filetimestamp_invalid; } + }; + static constexpr uint32_t + stats2_size = 1 << 0, + stats2_timestamp = 1 << 1, + stats2_timestampCreate = 1 << 2, + stats2_fileOrFolder = 1 << 3, + stats2_readOnly = 1 << 4, + stats2_canWrite = stats2_readOnly, + stats2_hidden = 1 << 5, + stats2_remote = 1 << 6, + stats2_flags = (stats2_fileOrFolder | stats2_readOnly | stats2_hidden | stats2_remote), + stats2_legacy = (stats2_size | stats2_timestamp), + stats2_all = 0xFFFFFFFF; + + //! Invalid/unknown file stats constant. See: t_filestats. + static constexpr t_filestats filestats_invalid = t_filestats(); + static constexpr t_filestats2 filestats2_invalid = t_filestats2(); + + //! Struct to be used with guid_getFileTimes / guid_setFileTimes. + struct filetimes_t { + t_filetimestamp creation = filetimestamp_invalid; + t_filetimestamp lastAccess = filetimestamp_invalid; + t_filetimestamp lastWrite = filetimestamp_invalid; + }; + + //! Generic interface to read data from a nonseekable stream. Also see: stream_writer, file. \n + //! Error handling: all methods may throw exception_io or one of derivatives on failure; exception_aborted when abort_callback is signaled. + class NOVTABLE stream_reader { + public: + //! Attempts to reads specified number of bytes from the stream. + //! @param p_buffer Receives data being read. Must have at least p_bytes bytes of space allocated. + //! @param p_bytes Number of bytes to read. + //! @param p_abort abort_callback object signaling user aborting the operation. + //! @returns Number of bytes actually read. May be less than requested when EOF was reached. + virtual t_size read(void* p_buffer, t_size p_bytes, abort_callback& p_abort) = 0; + //! Reads specified number of bytes from the stream. If requested amount of bytes can't be read (e.g. EOF), throws exception_io_data_truncation. + //! @param p_buffer Receives data being read. Must have at least p_bytes bytes of space allocated. + //! @param p_bytes Number of bytes to read. + //! @param p_abort abort_callback object signaling user aborting the operation. + virtual void read_object(void* p_buffer, t_size p_bytes, abort_callback& p_abort); + //! Attempts to skip specified number of bytes in the stream. + //! @param p_bytes Number of bytes to skip. + //! @param p_abort abort_callback object signaling user aborting the operation. + //! @returns Number of bytes actually skipped, May be less than requested when EOF was reached. + virtual t_filesize skip(t_filesize p_bytes, abort_callback& p_abort); + //! Skips specified number of bytes in the stream. If requested amount of bytes can't be skipped (e.g. EOF), throws exception_io_data_truncation. + //! @param p_bytes Number of bytes to skip. + //! @param p_abort abort_callback object signaling user aborting the operation. + virtual void skip_object(t_filesize p_bytes, abort_callback& p_abort); + + //! Helper template built around read_object. Reads single raw object from the stream. + //! @param p_object Receives object read from the stream on success. + //! @param p_abort abort_callback object signaling user aborting the operation. + template inline void read_object_t(T& p_object, abort_callback& p_abort) { pfc::assert_raw_type(); read_object(&p_object, sizeof(p_object), p_abort); } + template inline T read_object_t(abort_callback& a) { T val; this->read_object_t(val, a); return val; } + //! Helper template built around read_object. Reads single raw object from the stream; corrects byte order assuming stream uses little endian order. + //! @param p_object Receives object read from the stream on success. + //! @param p_abort abort_callback object signaling user aborting the operation. + template inline void read_lendian_t(T& p_object, abort_callback& p_abort) { read_object_t(p_object, p_abort); byte_order::order_le_to_native_t(p_object); } + template inline T read_lendian_t(abort_callback& a) { T val; this->read_lendian_t(val, a); return val; } + //! Helper template built around read_object. Reads single raw object from the stream; corrects byte order assuming stream uses big endian order. + //! @param p_object Receives object read from the stream on success. + //! @param p_abort abort_callback object signaling user aborting the operation. + template inline void read_bendian_t(T& p_object, abort_callback& p_abort) { read_object_t(p_object, p_abort); byte_order::order_be_to_native_t(p_object); } + template inline T read_bendian_t(abort_callback& a) { T val; this->read_bendian_t(val, a); return val; } + + //! Helper function; reads a string (with a 32-bit header indicating length in bytes followed by UTF-8 encoded data without a null terminator). + void read_string(pfc::string_base& p_out, abort_callback& p_abort); + //! Helper function; alternate way of storing strings; assumes string takes space up to end of stream. + void read_string_raw(pfc::string_base& p_out, abort_callback& p_abort, size_t sanity = SIZE_MAX); + //! Helper function; reads a string (with a 32-bit header indicating length in bytes followed by UTF-8 encoded data without a null terminator). + pfc::string read_string(abort_callback& p_abort); + + //! Helper function; reads a string of specified length from the stream. + void read_string_ex(pfc::string_base& p_out, t_size p_bytes, abort_callback& p_abort); + //! Helper function; reads a string of specified length from the stream. + pfc::string read_string_ex(t_size p_len, abort_callback& p_abort); + + void read_string_nullterm(pfc::string_base& out, abort_callback& abort); + + t_filesize skip_till_eof(abort_callback& abort); + + template + void read_till_eof(t_outArray& out, abort_callback& abort) { + pfc::assert_raw_type(); + const t_size itemWidth = sizeof(typename t_outArray::t_item); + out.set_size(pfc::max_t(1, 256 / itemWidth)); t_size done = 0; + for (;;) { + t_size delta = out.get_size() - done; + t_size delta2 = read(out.get_ptr() + done, delta * itemWidth, abort) / itemWidth; + done += delta2; + if (delta2 != delta) break; + out.set_size(out.get_size() << 1); + } + out.set_size(done); + } + + uint8_t read_byte(abort_callback& abort); + protected: + stream_reader() {} + ~stream_reader() {} + }; + + + //! Generic interface to write data to a nonseekable stream. Also see: stream_reader, file. \n + //! Error handling: all methods may throw exception_io or one of derivatives on failure; exception_aborted when abort_callback is signaled. + class NOVTABLE stream_writer { + public: + //! Writes specified number of bytes from specified buffer to the stream. + //! @param p_buffer Buffer with data to write. Must contain at least p_bytes bytes. + //! @param p_bytes Number of bytes to write. + //! @param p_abort abort_callback object signaling user aborting the operation. + virtual void write(const void* p_buffer, t_size p_bytes, abort_callback& p_abort) = 0; + + //! Helper. Same as write(), provided for consistency. + inline void write_object(const void* p_buffer, t_size p_bytes, abort_callback& p_abort) { write(p_buffer, p_bytes, p_abort); } + + //! Helper template. Writes single raw object to the stream. + //! @param p_object Object to write. + //! @param p_abort abort_callback object signaling user aborting the operation. + template inline void write_object_t(const T& p_object, abort_callback& p_abort) { pfc::assert_raw_type(); write_object(&p_object, sizeof(p_object), p_abort); } + //! Helper template. Writes single raw object to the stream; corrects byte order assuming stream uses little endian order. + //! @param p_object Object to write. + //! @param p_abort abort_callback object signaling user aborting the operation. + template inline void write_lendian_t(const T& p_object, abort_callback& p_abort) { T temp = p_object; byte_order::order_native_to_le_t(temp); write_object_t(temp, p_abort); } + //! Helper template. Writes single raw object to the stream; corrects byte order assuming stream uses big endian order. + //! @param p_object Object to write. + //! @param p_abort abort_callback object signaling user aborting the operation. + template inline void write_bendian_t(const T& p_object, abort_callback& p_abort) { T temp = p_object; byte_order::order_native_to_be_t(temp); write_object_t(temp, p_abort); } + + //! Helper function; writes string (with 32-bit header indicating length in bytes followed by UTF-8 encoded data without null terminator). + void write_string(const char* p_string, abort_callback& p_abort); + void write_string(const char* p_string, t_size p_len, abort_callback& p_abort); + + template + void write_string(const T& val, abort_callback& p_abort) { write_string(pfc::stringToPtr(val), p_abort); } + + //! Helper function; writes raw string to the stream, with no length info or null terminators. + void write_string_raw(const char* p_string, abort_callback& p_abort); + + void write_string_nullterm(const char* p_string, abort_callback& p_abort) { this->write(p_string, strlen(p_string) + 1, p_abort); } + protected: + stream_writer() {} + ~stream_writer() {} + }; + + //! A class providing abstraction for an open file object, with reading/writing/seeking methods. See also: stream_reader, stream_writer (which it inherits read/write methods from). \n + //! Error handling: all methods may throw exception_io or one of derivatives on failure; exception_aborted when abort_callback is signaled. + class NOVTABLE file : public service_base, public stream_reader, public stream_writer { + public: + + //! Seeking mode constants. Note: these are purposedly defined to same values as standard C SEEK_* constants + enum t_seek_mode { + //! Seek relative to beginning of file (same as seeking to absolute offset). + seek_from_beginning = 0, + //! Seek relative to current position. + seek_from_current = 1, + //! Seek relative to end of file. + seek_from_eof = 2, + }; + + //! Retrieves size of the file. + //! @param p_abort abort_callback object signaling user aborting the operation. + //! @returns File size on success; filesize_invalid if unknown (nonseekable stream etc). + virtual t_filesize get_size(abort_callback& p_abort) = 0; + + + //! Retrieves read/write cursor position in the file. In case of non-seekable stream, this should return number of bytes read so far since open/reopen call. + //! @param p_abort abort_callback object signaling user aborting the operation. + //! @returns Read/write cursor position + virtual t_filesize get_position(abort_callback& p_abort) = 0; + + //! Resizes file to the specified size in bytes. + //! @param p_abort abort_callback object signaling user aborting the operation. + virtual void resize(t_filesize p_size, abort_callback& p_abort) = 0; + + //! Sets read/write cursor position to the specified offset. Throws exception_io_seek_out_of_range if the specified offset is outside the valid range. + //! @param p_position position to seek to. + //! @param p_abort abort_callback object signaling user aborting the operation. + virtual void seek(t_filesize p_position, abort_callback& p_abort) = 0; + + //! Same as seek() but throws exception_io_data instead of exception_io_seek_out_of_range. + void seek_probe(t_filesize p_position, abort_callback& p_abort); + + //! Sets read/write cursor position to the specified offset; extended form allowing seeking relative to current position or to end of file. + //! @param p_position Position to seek to; interpretation of this value depends on p_mode parameter. + //! @param p_mode Seeking mode; see t_seek_mode enum values for further description. + //! @param p_abort abort_callback object signaling user aborting the operation. + virtual void seek_ex(t_sfilesize p_position, t_seek_mode p_mode, abort_callback& p_abort); + + //! Returns whether the file is seekable or not. If can_seek() returns false, all seek() or seek_ex() calls will fail; reopen() is still usable on nonseekable streams. + virtual bool can_seek() = 0; + + //! Retrieves mime type of the file. + //! @param p_out Receives content type string on success. + virtual bool get_content_type(pfc::string_base& p_out) = 0; + pfc::string8 get_content_type(); + + //! Hint, returns whether the file is already fully buffered into memory. + virtual bool is_in_memory() { return false; } + + //! Optional, called by owner thread before sleeping. + //! @param p_abort abort_callback object signaling user aborting the operation. + virtual void on_idle(abort_callback& p_abort) { (void)p_abort; } + + //! Retrieves last modification time of the file. + //! @param p_abort abort_callback object signaling user aborting the operation. + //! @returns Last modification time o fthe file; filetimestamp_invalid if N/A. + virtual t_filetimestamp get_timestamp(abort_callback& p_abort) { (void)p_abort; return filetimestamp_invalid; } + + //! Resets non-seekable stream, or seeks to zero on seekable file. + //! @param p_abort abort_callback object signaling user aborting the operation. + virtual void reopen(abort_callback& p_abort) = 0; + + //! Indicates whether the file is a remote resource and non-sequential access may be slowed down by lag. This is typically returns to true on non-seekable sources but may also return true on seekable sources indicating that seeking is supported but will be relatively slow. + virtual bool is_remote() = 0; + + //! Retrieves file stats structure. Uses get_size() and get_timestamp(). + t_filestats get_stats(abort_callback& p_abort); + + //! Returns whether read/write cursor position is at the end of file. + bool is_eof(abort_callback& p_abort); + + //! Truncates file to specified size (while preserving read/write cursor position if possible); uses set_eof(). + void truncate(t_filesize p_position, abort_callback& p_abort); + + //! Truncates the file at current read/write cursor position. + void set_eof(abort_callback& p_abort) { resize(get_position(p_abort), p_abort); } + + + //! Helper; retrieves size of the file. If size is not available (get_size() returns filesize_invalid), throws exception_io_no_length. + t_filesize get_size_ex(abort_callback& p_abort); + + //! Helper; retrieves amount of bytes between read/write cursor position and end of file. Fails when length can't be determined. + t_filesize get_remaining(abort_callback& p_abort); + + //! Security helper; fails early with exception_io_data_truncation if it is not possible to read this amount of bytes from this file at this position. + void probe_remaining(t_filesize bytes, abort_callback& p_abort); + bool probe_remaining_ex(t_filesize bytes, abort_callback& p_abort); + + //! Helper; throws exception_io_object_not_seekable if file is not seekable. + void ensure_seekable(); + + //! Helper; throws exception_io_object_is_remote if the file is remote. + void ensure_local(); + + //! Helper; transfers specified number of bytes between streams. + //! @returns number of bytes actually transferred. May be less than requested if e.g. EOF is reached. + static t_filesize g_transfer(stream_reader* src, stream_writer* dst, t_filesize bytes, abort_callback& p_abort); + //! Helper; transfers specified number of bytes between streams. Throws exception if requested number of bytes could not be read (EOF). + static void g_transfer_object(stream_reader* src, stream_writer* dst, t_filesize bytes, abort_callback& p_abort); + //! Helper; transfers entire file content from one file to another, erasing previous content. + static void g_transfer_file(const service_ptr_t& p_from, const service_ptr_t& p_to, abort_callback& p_abort); + //! Helper; transfers file modification times from one file to another, if supported by underlying objects. Returns true on success, false if the operation doesn't appear to be supported. + static bool g_copy_timestamps(service_ptr_t from, service_ptr_t to, abort_callback& abort); + static bool g_copy_creation_time(service_ptr_t from, service_ptr_t to, abort_callback& abort); + + //! Helper; improved performance over g_transfer on streams (avoids disk fragmentation when transferring large blocks). + static t_filesize g_transfer(service_ptr_t p_src, service_ptr_t p_dst, t_filesize p_bytes, abort_callback& p_abort); + //! Helper; improved performance over g_transfer_file on streams (avoids disk fragmentation when transferring large blocks). + static void g_transfer_object(service_ptr_t p_src, service_ptr_t p_dst, t_filesize p_bytes, abort_callback& p_abort); + + + //! file_v2 wrapper; + size_t lowLevelIO_(const GUID& guid, size_t arg1, void* arg2, size_t arg2size, abort_callback& abort); + + //! Helper + bool flushFileBuffers(abort_callback&); + bool flushFileBuffers_(abort_callback& a) { return flushFileBuffers(a); } + //! Helper + bool getFileTimes(filetimes_t& out, abort_callback&); + //! Helper + bool setFileTimes(filetimes_t const& in, abort_callback&); + + t_filesize skip(t_filesize p_bytes, abort_callback& p_abort); + t_filesize skip_seek(t_filesize p_bytes, abort_callback& p_abort); + + //! file_v2 wrapper. + service_ptr get_metadata_(abort_callback& a); + + //! file_v2 wrapper. + t_filestats2 get_stats2_(uint32_t f, abort_callback& a); + + //! file_v2 wrapper. + void set_stats(t_filestats2 const&, abort_callback&); + + //! file_v2 wrapper. + t_filetimestamp get_time_created(abort_callback& a); + + //! Alternate version of read() intended for network resources.\n + //! See: stream_receive::receive(); \n + //! If not implemented by this object, uses plain read(). + size_t receive(void*, size_t, abort_callback&); + + void commit(abort_callback& a) {flushFileBuffers(a);} + + FB2K_MAKE_SERVICE_INTERFACE(file, service_base); + }; + + typedef service_ptr_t file_ptr; + + //! Extension for shoutcast dynamic metadata handling. + class file_dynamicinfo : public file { + FB2K_MAKE_SERVICE_INTERFACE(file_dynamicinfo, file); + public: + //! Retrieves "static" info that doesn't change in the middle of stream, such as station names etc. Returns true on success; false when static info is not available. + virtual bool get_static_info(class file_info& p_out) = 0; + //! Returns whether dynamic info is available on this stream or not. + virtual bool is_dynamic_info_enabled() = 0; + //! Retrieves dynamic stream info (e.g. online stream track titles). Returns true on success, false when info has not changed since last call. + virtual bool get_dynamic_info(class file_info& p_out) = 0; + }; + + //! \since 1.4.1 + //! Extended version of file_dynamicinfo + class file_dynamicinfo_v2 : public file_dynamicinfo { + FB2K_MAKE_SERVICE_INTERFACE(file_dynamicinfo_v2, file_dynamicinfo); + public: + virtual bool get_dynamic_info_v2(class file_info& out, t_filesize& outOffset) = 0; + protected: + // Obsolete + bool get_dynamic_info(class file_info& p_out); + }; + + //! Extension for cached file access - allows callers to know that they're dealing with a cache layer, to prevent cache duplication. + class file_cached : public file { + FB2K_MAKE_SERVICE_INTERFACE(file_cached, file); + public: + virtual size_t get_cache_block_size() = 0; + virtual void suggest_grow_cache(size_t suggestSize) = 0; + + static file::ptr g_create(service_ptr_t p_base, abort_callback& p_abort, t_size blockSize); + static void g_create(service_ptr_t& p_out, service_ptr_t p_base, abort_callback& p_abort, t_size blockSize); + + static void g_decodeInitCache(file::ptr& theFile, abort_callback& abort, size_t blockSize); + }; + + //! \since 1.5 + //! Additional service implemented by standard file object providing access to low level OS specific APIs. \n + //! Obsolete, lowLevelIO() is now a part of file_v2 API. + class file_lowLevelIO : public service_base { + FB2K_MAKE_SERVICE_INTERFACE(file_lowLevelIO, service_base); + public: + //! @returns 0 if the command was not recognized, a command-defined non zero value otherwise. + virtual size_t lowLevelIO(const GUID& guid, size_t arg1, void* arg2, size_t arg2size, abort_callback& abort) = 0; + + //! Win32 FlushFileBuffers() wrapper. \n + //! Throws exception_io_denied on a file opened for reading. \n + //! No arguments are defined. \n + //! Returns 1 if handled, 0 if unsupported. + static const GUID guid_flushFileBuffers; + //! Retrieves file creation / last access / last write times. \n + //! Parameters: arg2 points to a filetimes_t struct to receive the data; arg2size must be set to sizeof(filetimes_t). \n + //! If the filesystem does not support a specific portion of the information, relevant struct member will be set to filetimestamp_invalid. \n + //! Returns 1 if handled, 0 if unsupported. + static const GUID guid_getFileTimes; + //! Sets file creation / last access / last write times. \n + //! Parameters: arg2 points to a filetimes_t struct holding the new data; arg2size must be set to sizeof(filetimes_t). \n + //! Individual members of the filetimes_t struct can be set to filetimestamp_invalid, if not all of the values are to be altered on the file. \n + //! Returns 1 if handled, 0 if unsupported. + static const GUID guid_setFileTimes; + + typedef ::foobar2000_io::filetimes_t filetimes_t; + }; + + //! Implementation helper - contains dummy implementations of methods that modify the file + template class file_readonly_t : public t_base { + public: + void resize(t_filesize p_size, abort_callback& p_abort) override { throw exception_io_denied(); } + void write(const void* p_buffer, t_size p_bytes, abort_callback& p_abort) override { throw exception_io_denied(); } + }; + typedef file_readonly_t file_readonly; + + //! \since 2.0 + class file_v2 : public file { + FB2K_MAKE_SERVICE_INTERFACE(file_v2, file); + public: + //! Returns an object with protocol specific metadata of the file. \n + //! It is essential that this object is made available to the caller by any wrappers working on top if a file object. \n + //! The returned object can be of any implementation-defined class; for http it's file_metdata_http. \n + //! Null return is allowed if no metadata is available. + virtual service_ptr get_metadata(abort_callback&) { return nullptr; } + + virtual t_filestats2 get_stats2(uint32_t s2flags, abort_callback&) = 0; + + virtual size_t lowLevelIO(const GUID& guid, size_t arg1, void* arg2, size_t arg2size, abort_callback& abort) { (void)guid; (void)arg1; (void)arg2; (void)arg2size; (void)abort; return 0; } + + // Old methods wrapped to get_stats2() + t_filetimestamp get_timestamp(abort_callback& p_abort) override; + bool is_remote() override; + t_filesize get_size(abort_callback& p_abort) override; + }; + + //! \since 1.6.7 + class file_metadata_http : public service_base { + FB2K_MAKE_SERVICE_INTERFACE(file_metadata_http, service_base); + public: + virtual bool get_http_header(const char* name, pfc::string_base& out) = 0; + virtual void get_connected_path(pfc::string_base& out) = 0; + }; + + + //! \since 2.1 + //! Extension to file object, implemented by network readers. Adds receive() method. + class stream_receive : public service_base { + FB2K_MAKE_SERVICE_INTERFACE(stream_receive, service_base); + public: + //! Alternate version of read() intended for network resources.\n + //! Returns as soon as any data is available (usually less than requested), or EOF has been reached (0 returned). + virtual size_t receive(void*, size_t, abort_callback&) = 0; + + size_t read_using_receive(void*, size_t, abort_callback&); + }; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/fileDialog.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/fileDialog.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,73 @@ +#pragma once + +#include + +namespace fb2k { + + typedef std::function fileDialogReply_t; + typedef std::function fileDialogGetPath_t; + + class NOVTABLE fileDialogNotify : public service_base { + FB2K_MAKE_SERVICE_INTERFACE( fileDialogNotify, service_base ); + public: + //! Called when user has cancelled the dialog. + virtual void dialogCancelled() = 0; + //! Called when the user has dismissed the dialog having selected some content. + //! @param items Array of fsItemBase objects or strings, depending on the platform. Should accept either form. Typically, file dialogs will handle fsItems but Add Location will handle path strings. Special case: playlist format chooser sends chosen format name as a string (one array item). + virtual void dialogOK2( arrayRef items ) = 0; + + static fileDialogNotify::ptr create( fileDialogReply_t recv ); + }; + + class NOVTABLE fileDialogSetup : public service_base { + FB2K_MAKE_SERVICE_INTERFACE( fileDialogSetup, service_base ); + public: + + virtual void setTitle( const char * title ) = 0; + virtual void setAllowsMultiple(bool bValue) = 0; + //! Sets allowed file types - in uGetOpenFileName format, eg. "Crash logs|*.txt" + virtual void setFileTypes( const char * fileTypeStr ) = 0; + virtual void setDefaultType( uint32_t indexInList ) = 0; + //! Helper, calls setFileTypes() with a mask matching all known file types + void setAudioFileTypes(); + //! Sets default extension, dot-less + virtual void setDefaultExtension( const char * defaultExt ) = 0; + virtual void setInitialDirectory( const char * initDirectory ) = 0; + + virtual void setInitialValue( const char * initValue ) = 0; + + virtual void setParent(fb2k::hwnd_t wndParent) = 0; + + + enum { + locNotSet = 0, + locComputer, + locDownloads, + locMusic, + locDocuments, + locPictures, + locVideos, + }; + virtual void setInitialLocation(unsigned identifier) = 0; + + //! Runs the dialog. \n + //! The dialog may run synchronously (block run() and the whole app UI) or asynchronously, depending on the platform. \n + //! For an example, on Windows most filedialogs work synchronously while on OSX all of them work asynchronously. + //! @param notify Notify object invoked upon dialog completion. + virtual void run(fileDialogNotify::ptr notify) = 0; + + //! Helper, creates fileDialogNotify for you. + void run (fileDialogReply_t reply); + void runSimple (fileDialogGetPath_t reply); + }; + + class NOVTABLE fileDialog : public service_base { + FB2K_MAKE_SERVICE_COREAPI( fileDialog ); + public: + virtual fileDialogSetup::ptr setupOpen() = 0; + virtual fileDialogSetup::ptr setupSave() = 0; + virtual fileDialogSetup::ptr setupOpenFolder() = 0; + virtual fileDialogSetup::ptr setupOpenURL() = 0; + virtual fileDialogSetup::ptr setupChoosePlaylistFormat() = 0; + }; +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/file_cached_impl.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/file_cached_impl.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,398 @@ +#include "foobar2000-sdk-pch.h" +#include "filesystem.h" +namespace { + +#define FILE_CACHED_DEBUG_LOG 0 + +class file_cached_impl_v2 : public service_multi_inherit< file_v2, service_multi_inherit< file_cached, file_lowLevelIO > > { +public: + enum {minBlockSize = 4096}; + enum {maxSkipSize = 128*1024}; + file_cached_impl_v2(size_t maxBlockSize) : m_maxBlockSize(maxBlockSize) { + //m_buffer.set_size(blocksize); + } + size_t get_cache_block_size() override {return m_maxBlockSize;} + void suggest_grow_cache(size_t suggestSize) override { + if (m_maxBlockSize < suggestSize) m_maxBlockSize = suggestSize; + } + + void initialize(service_ptr_t p_base,abort_callback & p_abort) { + m_base = p_base; + m_can_seek = m_base->can_seek(); + _reinit(p_abort); + } + t_filestats2 get_stats2(uint32_t f, abort_callback& a) override { + flush_buffer(); + return m_base->get_stats2_(f, a); + } + size_t lowLevelIO(const GUID & guid, size_t arg1, void * arg2, size_t arg2size, abort_callback & abort) override { + abort.check(); + file_lowLevelIO::ptr ll; + if ( ll &= m_base ) { + flush_buffer(); + return ll->lowLevelIO(guid, arg1, arg2, arg2size, abort ); + } + return 0; + } +private: + void _reinit(abort_callback & p_abort) { + m_position = 0; + + if (m_can_seek) { + m_position_base = m_base->get_position(p_abort); + } else { + m_position_base = 0; + } + + m_size = m_base->get_size(p_abort); + + flush_buffer(); + } +public: + + t_filesize skip(t_filesize p_bytes,abort_callback & p_abort) override { + if (p_bytes > maxSkipSize) { + const t_filesize size = get_size(p_abort); + if (size != filesize_invalid) { + const t_filesize position = get_position(p_abort); + const t_filesize toskip = pfc::min_t( p_bytes, size - position ); + seek(position + toskip,p_abort); + return toskip; + } + } + return skip_( p_bytes, p_abort ); + } + t_filesize skip_(t_filesize p_bytes,abort_callback & p_abort) { +#if FILE_CACHED_DEBUG_LOG + FB2K_DebugLog() << "Skipping bytes: " << p_bytes; +#endif + t_filesize todo = p_bytes; + for(;;) { + size_t inBuffer = this->bufferRemaining(); + size_t delta = (size_t) pfc::min_t(inBuffer, todo); + m_bufferReadPtr += delta; + m_position += delta; + todo -= delta; + if (todo == 0) break; + p_abort.check(); + this->m_bufferState = 0; // null it early to leave in a consistent state if base read fails + this->m_bufferReadPtr = 0; + baseSeek(m_position,p_abort); + m_readSize = pfc::min_t(m_readSize << 1, this->m_maxBlockSize); + if (m_readSize < minBlockSize) m_readSize = minBlockSize; +#if FILE_CACHED_DEBUG_LOG + FB2K_DebugLog() << "Growing read size: " << m_readSize; +#endif + m_buffer.grow_size(m_readSize); + m_bufferState = m_base->read(m_buffer.get_ptr(), m_readSize, p_abort); + if (m_bufferState == 0) break; + m_position_base += m_bufferState; + } + + return p_bytes - todo; + } + + t_size read(void * p_buffer,t_size p_bytes,abort_callback & p_abort) override { +#if FILE_CACHED_DEBUG_LOG + FB2K_DebugLog() << "Reading bytes: " << p_bytes; +#endif + t_uint8 * outptr = (t_uint8*)p_buffer; + size_t todo = p_bytes; + for(;;) { + size_t inBuffer = this->bufferRemaining(); + size_t delta = pfc::min_t(inBuffer, todo); + memcpy(outptr, this->m_buffer.get_ptr() + m_bufferReadPtr, delta); + m_bufferReadPtr += delta; + m_position += delta; + todo -= delta; + if (todo == 0) break; + p_abort.check(); + outptr += delta; + this->m_bufferState = 0; // null it early to leave in a consistent state if base read fails + this->m_bufferReadPtr = 0; + baseSeek(m_position,p_abort); + m_readSize = pfc::min_t(m_readSize << 1, this->m_maxBlockSize); + if (m_readSize < minBlockSize) m_readSize = minBlockSize; +#if FILE_CACHED_DEBUG_LOG + FB2K_DebugLog() << "Growing read size: " << m_readSize; +#endif + m_buffer.grow_size(m_readSize); + m_bufferState = m_base->read(m_buffer.get_ptr(), m_readSize, p_abort); + if (m_bufferState == 0) break; + m_position_base += m_bufferState; + } + + return p_bytes - todo; + } + + void write(const void * p_buffer,t_size p_bytes,abort_callback & p_abort) override { +#if FILE_CACHED_DEBUG_LOG + FB2K_DebugLog() << "Writing bytes: " << p_bytes; +#endif + p_abort.check(); + baseSeek(m_position,p_abort); + m_base->write(p_buffer,p_bytes,p_abort); + m_position_base = m_position = m_position + p_bytes; + if (m_size < m_position) m_size = m_position; + flush_buffer(); + } + + t_filesize get_size(abort_callback & p_abort) override { + p_abort.check(); + return m_size; + } + t_filesize get_position(abort_callback & p_abort) override { + p_abort.check(); + PFC_ASSERT( m_position <= m_size ); + return m_position; + } + void set_eof(abort_callback & p_abort) { + p_abort.check(); + baseSeek(m_position,p_abort); + m_base->set_eof(p_abort); + flush_buffer(); + } + void seek(t_filesize p_position,abort_callback & p_abort) override { +#if FILE_CACHED_DEBUG_LOG + FB2K_DebugLog() << "Seeking: " << p_position; +#endif + p_abort.check(); + if (!m_can_seek) throw exception_io_object_not_seekable(); + if (p_position > m_size) throw exception_io_seek_out_of_range(); + int64_t delta = p_position - m_position; + + // special case + if (delta >= 0 && delta <= this->minBlockSize) { +#if FILE_CACHED_DEBUG_LOG + FB2K_DebugLog() << "Skip-seeking: " << p_position; +#endif + t_filesize skipped = this->skip_( delta, p_abort ); + PFC_ASSERT( skipped == (t_filesize)delta ); (void) skipped; + return; + } + + m_position = p_position; + // within currently buffered data? + if ((delta >= 0 && (uint64_t) delta <= bufferRemaining()) || (delta < 0 && (uint64_t)(-delta) <= m_bufferReadPtr)) { +#if FILE_CACHED_DEBUG_LOG + FB2K_DebugLog() << "Quick-seeking: " << p_position; +#endif + m_bufferReadPtr += (ptrdiff_t)delta; + } else { +#if FILE_CACHED_DEBUG_LOG + FB2K_DebugLog() << "Slow-seeking: " << p_position; +#endif + this->flush_buffer(); + } + } + void reopen(abort_callback & p_abort) override { + if (this->m_can_seek) { + seek(0,p_abort); + } else { + this->m_base->reopen( p_abort ); + this->_reinit( p_abort ); + } + } + bool can_seek() override {return m_can_seek;} + bool get_content_type(pfc::string_base & out) override {return m_base->get_content_type(out);} + void on_idle(abort_callback & p_abort) override {p_abort.check();m_base->on_idle(p_abort);} + t_filetimestamp get_timestamp(abort_callback & p_abort) override {p_abort.check(); return m_base->get_timestamp(p_abort);} + bool is_remote() override {return m_base->is_remote();} + void resize(t_filesize p_size,abort_callback & p_abort) override { + flush_buffer(); + m_base->resize(p_size,p_abort); + m_size = p_size; + if (m_position > m_size) m_position = m_size; + if (m_position_base > m_size) m_position_base = m_size; + } +private: + size_t bufferRemaining() const {return m_bufferState - m_bufferReadPtr;} + void baseSeek(t_filesize p_target,abort_callback & p_abort) { + if (p_target != m_position_base) { + m_base->seek(p_target,p_abort); + m_position_base = p_target; + } + } + + void flush_buffer() { + m_bufferState = m_bufferReadPtr = 0; + m_readSize = 0; + } + + service_ptr_t m_base; + t_filesize m_position,m_position_base,m_size; + bool m_can_seek; + size_t m_bufferState, m_bufferReadPtr; + pfc::array_t m_buffer; + size_t m_maxBlockSize; + size_t m_readSize; +}; + +class file_cached_impl : public service_multi_inherit< file_v2, service_multi_inherit< file_cached, file_lowLevelIO > > { +public: + file_cached_impl(t_size blocksize) { + m_buffer.set_size(blocksize); + } + size_t get_cache_block_size() override {return m_buffer.get_size();} + void suggest_grow_cache(size_t) override {} + void initialize(service_ptr_t p_base,abort_callback & p_abort) { + m_base = p_base; + m_can_seek = m_base->can_seek(); + _reinit(p_abort); + } +private: + void _reinit(abort_callback & p_abort) { + m_position = 0; + + if (m_can_seek) { + m_position_base = m_base->get_position(p_abort); + } else { + m_position_base = 0; + } + + m_size = m_base->get_size(p_abort); + + flush_buffer(); + } +public: + t_filestats2 get_stats2(uint32_t f, abort_callback& a) override { + flush_buffer(); + return m_base->get_stats2_(f, a); + } + size_t lowLevelIO(const GUID & guid, size_t arg1, void * arg2, size_t arg2size, abort_callback & abort) override { + abort.check(); + file_lowLevelIO::ptr ll; + if ( ll &= m_base ) { + flush_buffer(); + return ll->lowLevelIO(guid, arg1, arg2, arg2size, abort); + } + return 0; + } + t_size read(void * p_buffer,t_size p_bytes,abort_callback & p_abort) override { + t_uint8 * outptr = (t_uint8*)p_buffer; + t_size done = 0; + while(done < p_bytes && m_position < m_size) { + p_abort.check(); + + if (m_position >= m_buffer_position && m_position < m_buffer_position + m_buffer_status) { + t_size delta = pfc::min_t((t_size)(m_buffer_position + m_buffer_status - m_position),p_bytes - done); + t_size bufptr = (t_size)(m_position - m_buffer_position); + memcpy(outptr+done,m_buffer.get_ptr()+bufptr,delta); + done += delta; + m_position += delta; + if (m_buffer_status != m_buffer.get_size() && done < p_bytes) break;//EOF before m_size is hit + } else { + m_buffer_position = m_position - m_position % m_buffer.get_size(); + baseSeek(m_buffer_position,p_abort); + + m_buffer_status = m_base->read(m_buffer.get_ptr(),m_buffer.get_size(),p_abort); + m_position_base += m_buffer_status; + + if (m_buffer_status <= (t_size)(m_position - m_buffer_position)) break; + } + } + + return done; + } + + void write(const void * p_buffer,t_size p_bytes,abort_callback & p_abort) override { + p_abort.check(); + baseSeek(m_position,p_abort); + m_base->write(p_buffer,p_bytes,p_abort); + m_position_base = m_position = m_position + p_bytes; + if (m_size < m_position) m_size = m_position; + flush_buffer(); + } + + t_filesize get_size(abort_callback & p_abort) override { + p_abort.check(); + return m_size; + } + t_filesize get_position(abort_callback & p_abort) override { + p_abort.check(); + return m_position; + } + void set_eof(abort_callback & p_abort) { + p_abort.check(); + baseSeek(m_position,p_abort); + m_base->set_eof(p_abort); + flush_buffer(); + } + void seek(t_filesize p_position,abort_callback & p_abort) override { + p_abort.check(); + if (!m_can_seek) throw exception_io_object_not_seekable(); + if (p_position > m_size) throw exception_io_seek_out_of_range(); + m_position = p_position; + } + void reopen(abort_callback & p_abort) override { + if (this->m_can_seek) { + seek(0,p_abort); + } else { + this->m_base->reopen( p_abort ); + this->_reinit( p_abort ); + } + } + bool can_seek() override {return m_can_seek;} + bool get_content_type(pfc::string_base & out) override {return m_base->get_content_type(out);} + void on_idle(abort_callback & p_abort) override {p_abort.check();m_base->on_idle(p_abort);} + t_filetimestamp get_timestamp(abort_callback & p_abort) override {p_abort.check(); return m_base->get_timestamp(p_abort);} + bool is_remote() override {return m_base->is_remote();} + void resize(t_filesize p_size,abort_callback & p_abort) override { + flush_buffer(); + m_base->resize(p_size,p_abort); + m_size = p_size; + if (m_position > m_size) m_position = m_size; + if (m_position_base > m_size) m_position_base = m_size; + } +private: + void baseSeek(t_filesize p_target,abort_callback & p_abort) { + if (p_target != m_position_base) { + m_base->seek(p_target,p_abort); + m_position_base = p_target; + } + } + + void flush_buffer() { + m_buffer_status = 0; + m_buffer_position = 0; + } + + service_ptr_t m_base; + t_filesize m_position,m_position_base,m_size; + bool m_can_seek; + t_filesize m_buffer_position; + t_size m_buffer_status; + pfc::array_t m_buffer; +}; + +} + +file::ptr file_cached::g_create(service_ptr_t p_base,abort_callback & p_abort, t_size blockSize) { + + if (p_base->is_in_memory()) { + return p_base; // do not want + } + + { // do not duplicate cache layers, check if the file we're being handed isn't already cached + file_cached::ptr c; + if (p_base->service_query_t(c)) { + c->suggest_grow_cache(blockSize); + return p_base; + } + } + + auto obj = fb2k::service_new< file_cached_impl_v2 >(blockSize); + obj->initialize(p_base,p_abort); + file_v2* asdf = obj.get_ptr(); + return asdf; +} + +void file_cached::g_create(service_ptr_t & p_out,service_ptr_t p_base,abort_callback & p_abort, t_size blockSize) { + p_out = g_create(p_base, p_abort, blockSize); +} + +void file_cached::g_decodeInitCache(file::ptr & theFile, abort_callback & abort, size_t blockSize) { + if (theFile->is_remote() || !theFile->can_seek()) return; + + g_create(theFile, theFile, abort, blockSize); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/file_format_sanitizer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/file_format_sanitizer.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,36 @@ +#pragma once + +#ifdef FOOBAR2000_HAVE_FILE_FORMAT_SANITIZER +//! Utility service to perform file format specific cleanup routines, optimize tags layout, remove padding, etc. +class NOVTABLE file_format_sanitizer : public service_base { + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT( file_format_sanitizer ); +public: + //! Returns whether the file path appears to be of a supported format. \n + //! Used for display purposes (menu command will be disabled when no selected file can be cleaned up). + virtual bool is_supported_format( const char * path, const char * ext ) = 0; + //! Performs file format specific cleanup of the file: \n + //! Strips excessive padding, optimizes file layout for network streaming (MP4). \n + //! @param path File path to clean up. The file must be writeable. \n + //! @param bMinimizeSize Set to true to throw away all padding. If set to false, some padding will be left to allow future tag updates without full file rewrite. + //! @returns True if the file has been successfully processed, false if we do not resupport this file format. + virtual bool sanitize_file( const char * path, bool bMinimizeSize, abort_callback & aborter ) = 0; +}; + +//! \since 1.6 series +class NOVTABLE file_format_sanitizer_v2 : public file_format_sanitizer { + FB2K_MAKE_SERVICE_INTERFACE(file_format_sanitizer_v2, file_format_sanitizer); +public: + //! Perform additional cleanups in the file after an encode pass has finished. \n + //! Mainly meant to mitigate extremely annoying design of FLAC encoder. + virtual void after_encode(const char* path, abort_callback& aborter) = 0; +}; + +//! Utility service to perform sanitization of generic ID3v2 tags. Called by format-specific implementations of file_format_sanitizer. +class NOVTABLE file_format_sanitizer_stdtags : public service_base { + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT( file_format_sanitizer_stdtags ); +public: + //! Similar to file_format_sanitizer method of the same name. Performs sanitization of generic ID3v2 tags. + virtual bool sanitize_file( const char * path, bool bMinimizeSize, abort_callback & aborter ) = 0; +}; + +#endif // FOOBAR2000_HAVE_FILE_FORMAT_SANITIZER \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/file_info.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/file_info.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,1016 @@ +#include "foobar2000-sdk-pch.h" +#include "file_info.h" +#include "console.h" +#include "filesystem.h" + +#include +#ifndef _MSC_VER +#define strcat_s strcat +#define _atoi64 atoll +#endif + +static constexpr char info_WAVEFORMATEXTENSIBLE_CHANNEL_MASK[] = "WAVEFORMATEXTENSIBLE_CHANNEL_MASK"; + +t_size file_info::meta_find_ex(const char * p_name,t_size p_name_length) const +{ + t_size n, m = meta_get_count(); + for(n=0;nmeta_find(name); + if ( idx != SIZE_MAX ) { + if (field_value_equals(*this, idx, source, walk)) continue; + } + + copy_meta_single(source, walk); + changed = true; + } + return changed; +} + +void file_info::copy_meta_single(const file_info & p_source,t_size p_index) +{ + copy_meta_single_rename(p_source,p_index,p_source.meta_enum_name(p_index)); +} + +void file_info::copy_meta_single_nocheck(const file_info & p_source,t_size p_index) +{ + const char * name = p_source.meta_enum_name(p_index); + t_size n, m = p_source.meta_enum_value_count(p_index); + t_size new_index = SIZE_MAX; + for(n=0;n= max) return 0; + return meta_enum_value(index,p_index); +} + +const char * file_info::info_get_ex(const char * p_name,t_size p_name_length) const +{ + auto index = info_find_ex(p_name,p_name_length); + if (index == SIZE_MAX) return 0; + return info_enum_value(index); +} + +t_int64 file_info::info_get_int(const char * name) const +{ + PFC_ASSERT(pfc::is_valid_utf8(name)); + const char * val = info_get(name); + if (val==0) return 0; + return _atoi64(val); +} + +t_int64 file_info::info_get_length_samples() const +{ + t_int64 ret = 0; + double len = get_length(); + t_int64 srate = info_get_int("samplerate"); + + if (srate>0 && len>0) + { + ret = audio_math::time_to_samples(len,(unsigned)srate); + } + return ret; +} + +double file_info::info_get_float(const char * name) const +{ + const char * ptr = info_get(name); + if (ptr) return pfc::string_to_float(ptr); + else return 0; +} + +void file_info::info_set_int(const char * name,t_int64 value) +{ + PFC_ASSERT(pfc::is_valid_utf8(name)); + info_set(name,pfc::format_int(value)); +} + +void file_info::info_set_float(const char * name,double value,unsigned precision,bool force_sign,const char * unit) +{ + PFC_ASSERT(pfc::is_valid_utf8(name)); + PFC_ASSERT(unit==0 || strlen(unit) <= 64); + char temp[128]; + pfc::float_to_string(temp,64,value,precision,force_sign); + temp[63] = 0; + if (unit) + { + strcat_s(temp," "); + strcat_s(temp,unit); + } + info_set(name,temp); +} + + +void file_info::info_set_replaygain_album_gain(float value) +{ + replaygain_info temp = get_replaygain(); + temp.m_album_gain = value; + set_replaygain(temp); +} + +void file_info::info_set_replaygain_album_peak(float value) +{ + replaygain_info temp = get_replaygain(); + temp.m_album_peak = value; + set_replaygain(temp); +} + +void file_info::info_set_replaygain_track_gain(float value) +{ + replaygain_info temp = get_replaygain(); + temp.m_track_gain = value; + set_replaygain(temp); +} + +void file_info::info_set_replaygain_track_peak(float value) +{ + replaygain_info temp = get_replaygain(); + temp.m_track_peak = value; + set_replaygain(temp); +} + + +static bool is_valid_bps(t_int64 val) +{ + return val>0 && val<=256; +} + +unsigned file_info::info_get_decoded_bps() const +{ + t_int64 val = info_get_int("decoded_bitspersample"); + if (is_valid_bps(val)) return (unsigned)val; + val = info_get_int("bitspersample"); + if (is_valid_bps(val)) return (unsigned)val; + return 0; +} + +bool file_info::info_get_codec_long(pfc::string_base& out, const char * delim) const { + const char * codec; + codec = this->info_get("codec_long"); + if (codec != nullptr) { + out = codec; return true; + } + codec = this->info_get("codec"); + if (codec != nullptr) { + out = codec; + const char * profile = this->info_get("codec_profile"); + if (profile != nullptr) { + out << delim << profile; + } + return true; + } + return false; +} + +void file_info::reset() +{ + info_remove_all(); + meta_remove_all(); + set_length(0); + reset_replaygain(); +} + +void file_info::reset_replaygain() +{ + replaygain_info temp; + temp.reset(); + set_replaygain(temp); +} + +void file_info::copy_meta_single_rename_ex(const file_info & p_source,t_size p_index,const char * p_new_name,t_size p_new_name_length) +{ + t_size n, m = p_source.meta_enum_value_count(p_index); + t_size new_index = SIZE_MAX; + for(n=0;nis_album_gain_present()) this->m_album_gain -= (float)deltaDB; + if (this->is_track_gain_present()) this->m_track_gain -= (float)deltaDB; + const auto scale = audio_math::gain_to_scale(deltaDB); + if (this->is_album_peak_present()) this->m_album_peak *= (float)scale; + if (this->is_track_peak_present()) this->m_track_peak *= (float)scale; +} + +bool file_info::are_meta_fields_identical(t_size p_index1,t_size p_index2) const +{ + const t_size count = meta_enum_value_count(p_index1); + if (count != meta_enum_value_count(p_index2)) return false; + t_size n; + for(n=0;n 0); + for(val=0;val 0) out += separator; + out += meta_enum_value(index,val); + } +} + +bool file_info::meta_format(const char * p_name,pfc::string_base & p_out, const char * separator) const { + p_out.reset(); + auto index = meta_find(p_name); + if (index == SIZE_MAX) return false; + meta_format_entry(index, p_out, separator); + return true; +} + +void file_info::info_calculate_bitrate(uint64_t p_filesize,double p_length) +{ + unsigned b = audio_math::bitrate_kbps( p_filesize, p_length ); + if ( b > 0 ) info_set_bitrate(b); +} + +void file_info::info_set_bitspersample(uint32_t val, bool isFloat) { + // Bits per sample semantics + // "bitspersample" is set to integer value of bits per sample + // "bitspersample_extra" is used for bps of 32 or 64, either "floating-point" or "fixed-point" + // bps other than 32 or 64 are implicitly fixed-point as floating-point for such makes no sense + + info_set_int("bitspersample", val); + if ( isFloat || val == 32 || val == 64 ) { + info_set("bitspersample_extra", isFloat ? "floating-point" : "fixed-point"); + } else { + info_remove("bitspersample_extra"); + } +} + +bool file_info::is_encoding_float() const { + auto bs = info_get_int("bitspersample"); + auto extra = info_get("bitspersample_extra"); + if (bs == 32 || bs == 64) { + if (extra == nullptr || strcmp(extra, "floating-point") == 0) return true; + } + return false; +} + +bool file_info::is_encoding_overkill() const { +#if audio_sample_size == 32 + auto bs = info_get_int("bitspersample"); + auto extra = info_get("bitspersample_extra"); + if ( bs <= 24 ) return false; // fixedpoint up to 24bit, OK + if ( bs > 32 ) return true; // fixed or float beyond 32bit, overkill + + if ( extra != nullptr ) { + if (strcmp(extra, "fixed-point") == 0) return true; // int32, overkill + } +#endif + return false; +} + +bool file_info::is_encoding_lossy() const { + const char * encoding = info_get("encoding"); + if (encoding != NULL) { + if (pfc::stricmp_ascii(encoding,"lossy") == 0 /*|| pfc::stricmp_ascii(encoding,"hybrid") == 0*/) return true; + } else { + //the old way + //disabled: don't whine if we're not sure what we're dealing with - might be a file with info not-yet-loaded in oddball cases or a mod file + //if (info_get("bitspersample") == NULL) return true; + } + return false; +} + +bool file_info::is_encoding_lossless() const { + const char* encoding = info_get("encoding"); + return encoding != nullptr && pfc::stringEqualsI_ascii(encoding, "lossless"); +} + +bool file_info::g_is_meta_equal(const file_info & p_item1,const file_info & p_item2) { + const t_size count = p_item1.meta_get_count(); + if (count != p_item2.meta_get_count()) { + //uDebugLog() << "meta count mismatch"; + return false; + } + pfc::map_t item2_meta_map; + for(t_size n=0; n item2_meta_map; + for(t_size n=0; n= 32 && p_char < 127 && p_char != '=' && p_char != '%' && p_char != '<' && p_char != '>'; +} + +bool file_info::g_is_valid_field_name(const char * p_name,t_size p_length) { + t_size walk; + for(walk = 0; walk < p_length && p_name[walk] != 0; walk++) { + if (!is_valid_field_name_char(p_name[walk])) return false; + } + return walk > 0; +} + +void file_info::to_formatter(pfc::string_formatter& out) const { + out << "File info dump:\n"; + if (get_length() > 0) out<< "Duration: " << pfc::format_time_ex(get_length(), 6) << "\n"; + pfc::string_formatter temp; + for(t_size metaWalk = 0; metaWalk < meta_get_count(); ++metaWalk) { + meta_format_entry(metaWalk, temp); + out << "Meta: " << meta_enum_name(metaWalk) << " = " << temp << "\n"; + } + for(t_size infoWalk = 0; infoWalk < info_get_count(); ++infoWalk) { + out << "Info: " << info_enum_name(infoWalk) << " = " << info_enum_value(infoWalk) << "\n"; + } + auto rg = this->get_replaygain(); + replaygain_info::t_text_buffer rgbuf; + if (rg.format_track_gain(rgbuf)) out << "RG track gain: " << rgbuf << "\n"; + if (rg.format_track_peak(rgbuf)) out << "RG track peak: " << rgbuf << "\n"; + if (rg.format_album_gain(rgbuf)) out << "RG album gain: " << rgbuf << "\n"; + if (rg.format_album_peak(rgbuf)) out << "RG album peak: " << rgbuf << "\n"; +} + +void file_info::to_console() const { + FB2K_console_formatter1() << "File info dump:"; + if (get_length() > 0) FB2K_console_formatter() << "Duration: " << pfc::format_time_ex(get_length(), 6); + pfc::string_formatter temp; + const auto numMeta = meta_get_count(), numInfo = info_get_count(); + if (numMeta == 0) { + FB2K_console_formatter() << "Meta is blank"; + } else for(t_size metaWalk = 0; metaWalk < numMeta; ++metaWalk) { + const char * name = meta_enum_name( metaWalk ); + const auto valCount = meta_enum_value_count( metaWalk ); + for ( size_t valWalk = 0; valWalk < valCount; ++valWalk ) { + FB2K_console_formatter() << "Meta: " << name << " = " << meta_enum_value( metaWalk, valWalk ); + } + + /* + meta_format_entry(metaWalk, temp); + FB2K_console_formatter() << "Meta: " << meta_enum_name(metaWalk) << " = " << temp; + */ + } + if (numInfo == 0) { + FB2K_console_formatter() << "Info is blank"; + } else for(t_size infoWalk = 0; infoWalk < numInfo; ++infoWalk) { + FB2K_console_formatter() << "Info: " << info_enum_name(infoWalk) << " = " << info_enum_value(infoWalk); + } +} + +void file_info::info_set_channels(uint32_t v) { + this->info_set_int("channels", v); +} + +void file_info::info_set_channels_ex(uint32_t channels, uint32_t mask) { + info_set_channels(channels); + info_set_wfx_chanMask(mask); +} + +static bool parse_wfx_chanMask(const char* str, uint32_t& out) { + try { + if (pfc::strcmp_partial(str, "0x") != 0) return false; + out = pfc::atohex(str + 2, strlen(str + 2)); + return true; + } catch (...) { return false; } +} + +void file_info::info_tidy_channels() { + const char * info = this->info_get(info_WAVEFORMATEXTENSIBLE_CHANNEL_MASK); + if (info != nullptr) { + bool keep = false; + uint32_t v; + if (parse_wfx_chanMask(info, v)) { + if (v != 0 && v != 3 && v != 4) { + // valid, not mono, not stereo + keep = true; + } + } + if (!keep) this->info_remove(info_WAVEFORMATEXTENSIBLE_CHANNEL_MASK); + } +} + +void file_info::info_set_wfx_chanMask(uint32_t val) { + switch(val) { + case 0: + case 4: + case 3: + this->info_remove(info_WAVEFORMATEXTENSIBLE_CHANNEL_MASK); + break; + default: + info_set (info_WAVEFORMATEXTENSIBLE_CHANNEL_MASK, pfc::format("0x", pfc::format_hex(val) ) ); + break; + } +} + +uint32_t file_info::info_get_wfx_chanMask() const { + const char * str = this->info_get(info_WAVEFORMATEXTENSIBLE_CHANNEL_MASK); + if (str == NULL) return 0; + uint32_t ret; + if (parse_wfx_chanMask(str, ret)) return ret; + return 0; +} + +bool file_info::field_is_person(const char * fieldName) { + return field_name_equals(fieldName, "artist") || + field_name_equals(fieldName, "album artist") || + field_name_equals(fieldName, "composer") || + field_name_equals(fieldName, "performer") || + field_name_equals(fieldName, "conductor") || + field_name_equals(fieldName, "orchestra") || + field_name_equals(fieldName, "ensemble") || + field_name_equals(fieldName, "engineer"); +} + +bool file_info::field_is_title(const char * fieldName) { + return field_name_equals(fieldName, "title") || field_name_equals(fieldName, "album"); +} + + +void file_info::to_stream( stream_writer * stream, abort_callback & abort ) const { + stream_writer_formatter<> out(* stream, abort ); + + out << this->get_length(); + + { + const auto rg = this->get_replaygain(); + out << rg.m_track_gain << rg.m_album_gain << rg.m_track_peak << rg.m_album_peak; + } + + + { + const uint32_t metaCount = pfc::downcast_guarded( this->meta_get_count() ); + for(uint32_t metaWalk = 0; metaWalk < metaCount; ++metaWalk) { + const char * name = this->meta_enum_name( metaWalk ); + if (*name) { + out.write_string_nullterm( this->meta_enum_name( metaWalk ) ); + const size_t valCount = this->meta_enum_value_count( metaWalk ); + for(size_t valWalk = 0; valWalk < valCount; ++valWalk) { + const char * value = this->meta_enum_value( metaWalk, valWalk ); + if (*value) { + out.write_string_nullterm( value ); + } + } + out.write_int(0); + } + } + out.write_int(0); + } + + { + const uint32_t infoCount = pfc::downcast_guarded( this->info_get_count() ); + for(uint32_t infoWalk = 0; infoWalk < infoCount; ++infoWalk) { + const char * name = this->info_enum_name( infoWalk ); + const char * value = this->info_enum_value( infoWalk ); + if (*name && *value) { + out.write_string_nullterm(name); out.write_string_nullterm(value); + } + } + out.write_int(0); + } +} + +void file_info::from_stream( stream_reader * stream, abort_callback & abort ) { + stream_reader_formatter<> in( *stream, abort ); + pfc::string_formatter tempName, tempValue; + { + double len; in >> len; this->set_length( len ); + } + { + replaygain_info rg; + in >> rg.m_track_gain >> rg.m_album_gain >> rg.m_track_peak >> rg.m_album_peak; + } + + { + this->meta_remove_all(); + for(;;) { + in.read_string_nullterm( tempName ); + if (tempName.length() == 0) break; + size_t metaIndex = SIZE_MAX; + for(;;) { + in.read_string_nullterm( tempValue ); + if (tempValue.length() == 0) break; + if (metaIndex == SIZE_MAX) metaIndex = this->meta_add( tempName, tempValue ); + else this->meta_add_value( metaIndex, tempValue ); + } + } + } + { + this->info_remove_all(); + for(;;) { + in.read_string_nullterm( tempName ); + if (tempName.length() == 0) break; + in.read_string_nullterm( tempValue ); + this->info_set( tempName, tempValue ); + } + } +} + +static const char * _readString( const uint8_t * & ptr, size_t & remaining ) { + const char * rv = (const char*)ptr; + for(;;) { + if (remaining == 0) throw exception_io_data(); + uint8_t byte = *ptr++; --remaining; + if (byte == 0) break; + } + return rv; +} + +template void _readInt( int_t & out, const uint8_t * &ptr, size_t & remaining) { + if (remaining < sizeof(out)) throw exception_io_data(); + pfc::decode_little_endian( out, ptr ); ptr += sizeof(out); remaining -= sizeof(out); +} + +template static void _readFloat(float_t & out, const uint8_t * &ptr, size_t & remaining) { + union { + typename pfc::sized_int_t::t_unsigned i; + float_t f; + } u; + _readInt(u.i, ptr, remaining); + out = u.f; +} + +void file_info::from_mem( const void * memPtr, size_t memSize ) { + size_t remaining = memSize; + const uint8_t * walk = (const uint8_t*) memPtr; + + { + double len; _readFloat(len, walk, remaining); + this->set_length( len ); + } + + { + replaygain_info rg; + _readFloat(rg.m_track_gain, walk, remaining ); + _readFloat(rg.m_album_gain, walk, remaining ); + _readFloat(rg.m_track_peak, walk, remaining ); + _readFloat(rg.m_album_peak, walk, remaining ); + this->set_replaygain( rg ); + } + + { + this->meta_remove_all(); + for(;;) { + const char * metaName = _readString( walk, remaining ); + if (*metaName == 0) break; + size_t metaIndex = SIZE_MAX; + for(;;) { + const char * metaValue = _readString( walk, remaining ); + if (*metaValue == 0) break; + if (metaIndex == SIZE_MAX) metaIndex = this->meta_add( metaName, metaValue ); + else this->meta_add_value( metaIndex, metaName ); + } + } + } + { + this->info_remove_all(); + for(;;) { + const char * infoName = _readString( walk, remaining ); + if (*infoName == 0) break; + const char * infoValue = _readString( walk, remaining ); + this->info_set( infoName, infoValue ); + } + } +} + +void file_info::set_audio_chunk_spec(audio_chunk::spec_t s) { + this->info_set_int("samplerate", s.sampleRate); + this->info_set_int("channels", s.chanCount); + uint32_t mask = 0; + if (audio_chunk::g_count_channels(s.chanMask) == s.chanCount) { + mask = s.chanMask; + } + this->info_set_wfx_chanMask(mask); // clears if zero or one of trivial values +} + +audio_chunk::spec_t file_info::audio_chunk_spec() const +{ + audio_chunk::spec_t rv = {}; + rv.sampleRate = (uint32_t)this->info_get_int("samplerate"); + rv.chanCount = (uint32_t)this->info_get_int("channels"); + rv.chanMask = (uint32_t)this->info_get_wfx_chanMask(); + if (audio_chunk::g_count_channels( rv.chanMask ) != rv.chanCount ) { + rv.chanMask = audio_chunk::g_guess_channel_config( rv.chanCount ); + } + return rv; +} + +bool file_info::field_value_equals(const file_info& i1, size_t meta1, const file_info& i2, size_t meta2) { + const size_t c = i1.meta_enum_value_count(meta1); + if (c != i2.meta_enum_value_count(meta2)) return false; + for (size_t walk = 0; walk < c; ++walk) { + if (strcmp(i1.meta_enum_value(meta1, walk), i2.meta_enum_value(meta2, walk)) != 0) return false; + } + return true; +} + +bool file_info::unicode_normalize_C() { + const size_t total = this->meta_get_count(); + bool changed = false; + for (size_t mwalk = 0; mwalk < total; ++mwalk) { + const size_t totalV = this->meta_enum_value_count(mwalk); + for (size_t vwalk = 0; vwalk < totalV; ++vwalk) { + const char* val = this->meta_enum_value(mwalk, vwalk); + if (pfc::stringContainsFormD(val)) { + auto norm = pfc::unicodeNormalizeC(val); + if (strcmp(norm, val) != 0) { + this->meta_modify_value(mwalk, vwalk, norm); + changed = true; + } + } + } + } + return changed; +} + +void file_info::meta_enumerate(meta_enumerate_t cb) const { + const size_t nMeta = this->meta_get_count(); + for (size_t metaWalk = 0; metaWalk < nMeta; ++metaWalk) { + const char* name = this->meta_enum_name(metaWalk); + const size_t nValue = this->meta_enum_value_count(metaWalk); + for (size_t valueWalk = 0; valueWalk < nValue; ++valueWalk) { + const char* value = this->meta_enum_value(metaWalk, valueWalk); + cb(name, value); + } + } +} + +bool file_info::meta_value_exists( const char * name, const char * findValue, bool insensitive ) const { + const auto idx = this->meta_find(name); + if ( idx != SIZE_MAX ) { + const auto count = this->meta_enum_value_count(idx); + for( size_t walk = 0; walk < count; ++ walk) { + auto value = this->meta_enum_value(idx, walk); + if ( insensitive ) { + if (pfc::stringEqualsI_utf8(value, findValue)) return true; + } else { + if ( strcmp(value, findValue) == 0 ) return true; + } + } + } + return false; +} + +const char * file_info::meta_get_title( const char * fallback) const { + auto ret = meta_get("title", 0); + return ret?ret:fallback; +} + +#ifdef FOOBAR2000_MOBILE +#include "album_art.h" +#include "hasher_md5.h" + +void file_info::info_set_pictures( const GUID * guids, size_t size ) { + this->info_set("pictures", album_art_ids::ids_to_string(guids, size) ); +} + +pfc::array_t file_info::info_get_pictures( ) const { + return album_art_ids::string_to_ids( this->info_get( "pictures" ) ); +} + +bool file_info::info_have_picture( const GUID & arg ) const { + for( auto & walk : info_get_pictures() ) { + if ( walk == arg ) return true; + } + return false; +} + +uint64_t file_info::makeMetaHash() const { + pfc::string_formatter temp; + + auto doMeta = [&] ( const char * meta ) { + const char * p = meta_get(meta, 0); + if (p != nullptr) temp << p; + temp << "\n"; + }; + auto doMetaInt = [&] ( const char * meta ) { + const char * p = meta_get(meta, 0); + if (p != nullptr) { + auto s = strchr(p, '/' ); if ( s != nullptr ) p = s+1; + while(*p == '0') ++p; + temp << p; + } + temp << "\n"; + }; + doMeta("title"); + doMeta("artist"); + doMeta("album"); + doMetaInt("tracknumber"); + doMetaInt("discnumber"); + + if (temp.length() == 5) return 0; + + return hasher_md5::get()->process_single( temp.c_str(), temp.length( ) ).xorHalve(); +} + +#endif // FOOBAR2000_MOBILE diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/file_info.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/file_info.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,351 @@ +#pragma once +#include "audio_chunk.h" +#include + +//! Structure containing ReplayGain scan results from some playable object, also providing various helper methods to manipulate those results. +struct replaygain_info +{ + static constexpr float peak_invalid = -1, gain_invalid = -1000; + + float m_album_gain = gain_invalid, m_track_gain = gain_invalid; + float m_album_peak = peak_invalid, m_track_peak = peak_invalid; + + enum {text_buffer_size = 16 }; + typedef char t_text_buffer[text_buffer_size]; + + + static bool g_format_gain(float p_value,char p_buffer[text_buffer_size]); + static bool g_format_peak(float p_value,char p_buffer[text_buffer_size]); + static bool g_format_peak_db(float p_value, char p_buffer[text_buffer_size]); + + inline bool format_album_gain(char p_buffer[text_buffer_size]) const {return g_format_gain(m_album_gain,p_buffer);} + inline bool format_track_gain(char p_buffer[text_buffer_size]) const {return g_format_gain(m_track_gain,p_buffer);} + inline bool format_album_peak(char p_buffer[text_buffer_size]) const {return g_format_peak(m_album_peak,p_buffer);} + inline bool format_track_peak(char p_buffer[text_buffer_size]) const {return g_format_peak(m_track_peak,p_buffer);} + + + typedef std::function for_each_t; + void for_each(for_each_t) const; + + static float g_parse_gain_text(const char * p_text, t_size p_text_len = SIZE_MAX); + void set_album_gain_text(const char * p_text,t_size p_text_len = SIZE_MAX); + void set_track_gain_text(const char * p_text,t_size p_text_len = SIZE_MAX); + void set_album_peak_text(const char * p_text,t_size p_text_len = SIZE_MAX); + void set_track_peak_text(const char * p_text,t_size p_text_len = SIZE_MAX); + + static bool g_is_meta_replaygain(const char * p_name,t_size p_name_len = SIZE_MAX); + bool set_from_meta_ex(const char * p_name,t_size p_name_len,const char * p_value,t_size p_value_len); + inline bool set_from_meta(const char * p_name,const char * p_value) {return set_from_meta_ex(p_name,SIZE_MAX,p_value,SIZE_MAX);} + + inline bool is_album_gain_present() const {return m_album_gain != gain_invalid;} + inline bool is_track_gain_present() const {return m_track_gain != gain_invalid;} + inline bool is_album_peak_present() const {return m_album_peak != peak_invalid;} + inline bool is_track_peak_present() const {return m_track_peak != peak_invalid;} + + inline void remove_album_gain() {m_album_gain = gain_invalid;} + inline void remove_track_gain() {m_track_gain = gain_invalid;} + inline void remove_album_peak() {m_album_peak = peak_invalid;} + inline void remove_track_peak() {m_track_peak = peak_invalid;} + + float anyGain(bool bPreferAlbum = false) const; + + t_size get_value_count(); + + static replaygain_info g_merge(replaygain_info r1,replaygain_info r2); + + static bool g_equalLoose( const replaygain_info & item1, const replaygain_info & item2); + static bool g_equal(const replaygain_info & item1,const replaygain_info & item2); + + void reset(); + void clear() { reset(); } + void clear_gain() { m_album_gain = m_track_gain = gain_invalid; } + void clear_peak() { m_album_peak = m_track_peak = peak_invalid; } + + // Alter gain/peak info, if available, by dB - after file gain has been altered by other means + void adjust(double deltaDB); +}; + +class format_rg_gain { +public: + format_rg_gain(float val) {replaygain_info::g_format_gain(val, m_buffer);} + + operator const char * () const {return m_buffer;} + const char * c_str() const { return m_buffer; } +private: + replaygain_info::t_text_buffer m_buffer; +}; + +class format_rg_peak { +public: + format_rg_peak(float val) {replaygain_info::g_format_peak(val, m_buffer);} + + operator const char * () const {return m_buffer;} + const char * c_str() const { return m_buffer; } +private: + replaygain_info::t_text_buffer m_buffer; +}; + +inline bool operator==(const replaygain_info & item1,const replaygain_info & item2) {return replaygain_info::g_equal(item1,item2);} +inline bool operator!=(const replaygain_info & item1,const replaygain_info & item2) {return !replaygain_info::g_equal(item1,item2);} + +static const replaygain_info replaygain_info_invalid = {replaygain_info::gain_invalid,replaygain_info::gain_invalid,replaygain_info::peak_invalid,replaygain_info::peak_invalid}; + + +//! Main interface class for information about some playable object. +class NOVTABLE file_info { +public: + //! Retrieves audio duration, in seconds. \n + //! Note that the reported duration should not be assumed to be the exact length of the track -\n + //! with many popular audio formats, exact duration is impossible to determine without performing a full decode pass;\n + //! with other formats, the decoded data may be shorter than reported due to truncation other damage. \n + //! Length of 0 indicates unknown or infinite (no seekbar shown). + virtual double get_length() const = 0; + //! Sets audio duration, in seconds. \n + //! Note that the reported duration should not be assumed to be the exact length of the track -\n + //! with many popular audio formats, exact duration is impossible to determine without performing a full decode pass;\n + //! with other formats, the decoded data may be shorter than reported due to truncation other damage. \n + //! Length of 0 indicates unknown or infinite (no seekbar shown). + virtual void set_length(double p_length) = 0; + + //! Sets ReplayGain information. + virtual void set_replaygain(const replaygain_info & p_info) = 0; + //! Retrieves ReplayGain information. + virtual replaygain_info get_replaygain() const = 0; + + //! Retrieves count of metadata entries. + virtual t_size meta_get_count() const = 0; + //! Retrieves the name of metadata entry of specified index. Return value is a null-terminated UTF-8 encoded string. + virtual const char* meta_enum_name(t_size p_index) const = 0; + //! Retrieves count of values in metadata entry of specified index. The value is always equal to or greater than 1. + virtual t_size meta_enum_value_count(t_size p_index) const = 0; + //! Retrieves specified value from specified metadata entry. Return value is a null-terminated UTF-8 encoded string. + virtual const char* meta_enum_value(t_size p_index,t_size p_value_number) const = 0; + //! Finds index of metadata entry of specified name. Returns infinite when not found. + virtual t_size meta_find_ex(const char * p_name,t_size p_name_length) const; + //! Creates a new metadata entry of specified name with specified value. If an entry of same name already exists, it is erased. Return value is the index of newly created metadata entry. + virtual t_size meta_set_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length) = 0; + //! Inserts a new value into specified metadata entry. + virtual void meta_insert_value_ex(t_size p_index,t_size p_value_index,const char * p_value,t_size p_value_length) = 0; + //! Removes metadata entries according to specified bit mask. + virtual void meta_remove_mask(const bit_array & p_mask) = 0; + //! Reorders metadata entries according to specified permutation. + virtual void meta_reorder(const t_size * p_order) = 0; + //! Removes values according to specified bit mask from specified metadata entry. If all values are removed, entire metadata entry is removed as well. + virtual void meta_remove_values(t_size p_index,const bit_array & p_mask) = 0; + //! Alters specified value in specified metadata entry. + virtual void meta_modify_value_ex(t_size p_index,t_size p_value_index,const char * p_value,t_size p_value_length) = 0; + + //! Retrieves number of technical info entries. + virtual t_size info_get_count() const = 0; + //! Retrieves the name of specified technical info entry. Return value is a null-terminated UTF-8 encoded string. + virtual const char* info_enum_name(t_size p_index) const = 0; + //! Retrieves the value of specified technical info entry. Return value is a null-terminated UTF-8 encoded string. + virtual const char* info_enum_value(t_size p_index) const = 0; + //! Creates a new technical info entry with specified name and specified value. If an entry of the same name already exists, it is erased. Return value is the index of newly created entry. + virtual t_size info_set_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length) = 0; + //! Removes technical info entries indicated by specified bit mask. + virtual void info_remove_mask(const bit_array & p_mask) = 0; + //! Finds technical info entry of specified name. Returns index of found entry on success, infinite on failure. + virtual t_size info_find_ex(const char * p_name,t_size p_name_length) const; + + //! Copies entire file_info contents from specified file_info object. + virtual void copy(const file_info & p_source);//virtualized for performance reasons, can be faster in two-pass + //! Copies metadata from specified file_info object. + virtual void copy_meta(const file_info & p_source);//virtualized for performance reasons, can be faster in two-pass + //! Copies technical info from specified file_info object. + virtual void copy_info(const file_info & p_source);//virtualized for performance reasons, can be faster in two-pass + + bool meta_exists_ex(const char * p_name,t_size p_name_length) const; + void meta_remove_field_ex(const char * p_name,t_size p_name_length); + void meta_remove_index(t_size p_index); + void meta_remove_all(); + void meta_remove_value(t_size p_index,t_size p_value); + const char * meta_get_ex(const char * p_name,t_size p_name_length,t_size p_index) const; + t_size meta_get_count_by_name_ex(const char * p_name,t_size p_name_length) const; + void meta_add_value_ex(t_size p_index,const char * p_value,t_size p_value_length); + t_size meta_add_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length); + t_size meta_calc_total_value_count() const; + bool meta_format(const char * p_name,pfc::string_base & p_out, const char * separator = ", ") const; + void meta_format_entry(t_size index, pfc::string_base & p_out, const char * separator = ", ") const;//same as meta_format but takes index instead of meta name. + + typedef std::function meta_enumerate_t; + void meta_enumerate(meta_enumerate_t) const; + + bool info_exists_ex(const char * p_name,t_size p_name_length) const; + void info_remove_index(t_size p_index); + void info_remove_all(); + bool info_remove_ex(const char * p_name,t_size p_name_length); + const char * info_get_ex(const char * p_name,t_size p_name_length) const; + + inline t_size meta_find(const char* p_name) const { PFC_ASSERT(p_name != nullptr); return meta_find_ex(p_name, SIZE_MAX); } + inline bool meta_exists(const char* p_name) const { PFC_ASSERT(p_name != nullptr); return meta_exists_ex(p_name, SIZE_MAX); } + bool meta_value_exists( const char * name, const char * value, bool insensitive = false ) const; + inline void meta_remove_field(const char* p_name) { PFC_ASSERT(p_name != nullptr); meta_remove_field_ex(p_name, SIZE_MAX); } + inline t_size meta_set(const char* p_name, const char* p_value) { PFC_ASSERT(p_name != nullptr && p_value != nullptr); return meta_set_ex(p_name, SIZE_MAX, p_value, SIZE_MAX); } + inline void meta_insert_value(t_size p_index,t_size p_value_index,const char * p_value) {meta_insert_value_ex(p_index,p_value_index,p_value,SIZE_MAX);} + inline void meta_add_value(t_size p_index,const char * p_value) {meta_add_value_ex(p_index,p_value,SIZE_MAX);} + inline const char* meta_get(const char* p_name, t_size p_index) const { PFC_ASSERT(p_name != nullptr); return meta_get_ex(p_name, SIZE_MAX, p_index); } + inline t_size meta_get_count_by_name(const char* p_name) const { PFC_ASSERT(p_name != nullptr); return meta_get_count_by_name_ex(p_name, SIZE_MAX); } + inline t_size meta_add(const char* p_name, const char* p_value) { PFC_ASSERT(p_name != nullptr && p_value != nullptr); return meta_add_ex(p_name, SIZE_MAX, p_value, SIZE_MAX); } + inline void meta_modify_value(t_size p_index,t_size p_value_index,const char * p_value) {meta_modify_value_ex(p_index,p_value_index,p_value,SIZE_MAX);} + + + + inline t_size info_set(const char * p_name,const char * p_value) {return info_set_ex(p_name,SIZE_MAX,p_value,SIZE_MAX);} + inline t_size info_find(const char * p_name) const {return info_find_ex(p_name,SIZE_MAX);} + inline bool info_exists(const char * p_name) const {return info_exists_ex(p_name,SIZE_MAX);} + inline bool info_remove(const char * p_name) {return info_remove_ex(p_name,SIZE_MAX);} + inline const char * info_get(const char * p_name) const {return info_get_ex(p_name,SIZE_MAX);} + + bool info_set_replaygain_ex(const char * p_name,t_size p_name_len,const char * p_value,t_size p_value_len); + inline bool info_set_replaygain(const char * p_name,const char * p_value) {return info_set_replaygain_ex(p_name,SIZE_MAX,p_value,SIZE_MAX);} + void info_set_replaygain_auto_ex(const char * p_name,t_size p_name_len,const char * p_value,t_size p_value_len); + inline void info_set_replaygain_auto(const char * p_name,const char * p_value) {info_set_replaygain_auto_ex(p_name,SIZE_MAX,p_value,SIZE_MAX);} + + + + void copy_meta_single(const file_info & p_source,t_size p_index); + void copy_info_single(const file_info & p_source,t_size p_index); + void copy_meta_single_by_name_ex(const file_info & p_source,const char * p_name,t_size p_name_length); + void copy_info_single_by_name_ex(const file_info & p_source,const char * p_name,t_size p_name_length); + inline void copy_meta_single_by_name(const file_info & p_source,const char * p_name) {copy_meta_single_by_name_ex(p_source,p_name,SIZE_MAX);} + inline void copy_info_single_by_name(const file_info & p_source,const char * p_name) {copy_info_single_by_name_ex(p_source,p_name,SIZE_MAX);} + void reset(); + void reset_replaygain(); + void copy_meta_single_rename_ex(const file_info & p_source,t_size p_index,const char * p_new_name,t_size p_new_name_length); + inline void copy_meta_single_rename(const file_info & p_source,t_size p_index,const char * p_new_name) {copy_meta_single_rename_ex(p_source,p_index,p_new_name,SIZE_MAX);} + void overwrite_info(const file_info & p_source); + void overwrite_meta(const file_info & p_source); + bool overwrite_meta_if_changed( const file_info & source ); + + t_int64 info_get_int(const char * name) const; + t_int64 info_get_length_samples() const; + double info_get_float(const char * name) const; + void info_set_int(const char * name,t_int64 value); + void info_set_float(const char * name,double value,unsigned precision,bool force_sign = false,const char * unit = 0); + void info_set_replaygain_track_gain(float value); + void info_set_replaygain_album_gain(float value); + void info_set_replaygain_track_peak(float value); + void info_set_replaygain_album_peak(float value); + + inline t_int64 info_get_bitrate_vbr() const {return info_get_int("bitrate_dynamic");} + inline void info_set_bitrate_vbr(t_int64 val_kbps) {info_set_int("bitrate_dynamic",val_kbps);} + inline t_int64 info_get_bitrate() const {return info_get_int("bitrate");} + inline void info_set_bitrate(t_int64 val_kbps) { PFC_ASSERT(val_kbps > 0); info_set_int("bitrate", val_kbps); } + + + //! Set number of channels + void info_set_channels(uint32_t); + //! Set number of channels and channel mask. Channel mask info will only be set if it's not plain mono or stereo. + void info_set_channels_ex(uint32_t channels, uint32_t mask); + + //! Tidy channel mask info. If channel mask is invalid or plain mono/stereo, it will be dropped. + void info_tidy_channels(); + + //! Set just channel mask info. Typically coupled with info_set_channels(). See also: info_set_channels_ex(). + void info_set_wfx_chanMask(uint32_t val); + //! Returns channel mask value. 0 if not set, use default for the channel count then. + uint32_t info_get_wfx_chanMask() const; + + //! Is a lossy codec? + bool is_encoding_lossy() const; + //! Is explicitly reported as lossless codec? + bool is_encoding_lossless() const; + //! Is lossless/PCM that can't be sanely represented in this fb2k build due to audio_sample limitations? \n + //! Always returns false in 64-bit fb2k. + bool is_encoding_overkill() const; + //! Floating-point PCM used? + bool is_encoding_float() const; + //! Helper; sets bit depth of lossless/PCM format. + void info_set_bitspersample(uint32_t val, bool isFloat = false); + + //! Sets bitrate value using file size in bytes and duration. + void info_calculate_bitrate(uint64_t p_filesize,double p_length); + + //! Returns decoder-output bit depth - what sample format is being converted to foobar2000 audio_sample. 0 if unknown. + unsigned info_get_decoded_bps() const; + + //! Foramts long codec name ( codec + profile ) + bool info_get_codec_long( pfc::string_base & out, const char * delim = " / ") const; + + //! Simplified title getter, returns fallback value if title not set, useful for debugging. + const char * meta_get_title( const char * fallback = "(untitled)") const; + +private: + void merge(const pfc::list_base_const_t & p_sources); +public: + + void _set_tag(const file_info & tag); + void _add_tag(const file_info & otherTag); + + void merge_fallback(const file_info & fallback); + + bool are_meta_fields_identical(t_size p_index1,t_size p_index2) const; + + inline const file_info & operator=(const file_info & p_source) {copy(p_source);return *this;} + + static bool g_is_meta_equal(const file_info & p_item1,const file_info & p_item2); + static bool g_is_meta_equal_debug(const file_info & p_item1,const file_info & p_item2); + static bool g_is_info_equal(const file_info & p_item1,const file_info & p_item2); + static bool g_is_meta_subset_debug(const file_info& superset, const file_info& subset); + + //! Unsafe - does not check whether the field already exists and will result in duplicates if it does - call only when appropriate checks have been applied externally. + t_size __meta_add_unsafe_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length) {return meta_set_nocheck_ex(p_name,p_name_length,p_value,p_value_length);} + //! Unsafe - does not check whether the field already exists and will result in duplicates if it does - call only when appropriate checks have been applied externally. + t_size __meta_add_unsafe(const char * p_name,const char * p_value) {return meta_set_nocheck_ex(p_name,SIZE_MAX,p_value,SIZE_MAX);} + + //! Unsafe - does not check whether the field already exists and will result in duplicates if it does - call only when appropriate checks have been applied externally. + t_size __info_add_unsafe_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length) {return info_set_nocheck_ex(p_name,p_name_length,p_value,p_value_length);} + //! Unsafe - does not check whether the field already exists and will result in duplicates if it does - call only when appropriate checks have been applied externally. + t_size __info_add_unsafe(const char * p_name,const char * p_value) {return info_set_nocheck_ex(p_name,SIZE_MAX,p_value,SIZE_MAX);} + + void _copy_meta_single_nocheck(const file_info & p_source,t_size p_index) {copy_meta_single_nocheck(p_source, p_index);} + + static bool g_is_valid_field_name(const char * p_name,t_size p_length = SIZE_MAX); + //typedef pfc::comparator_stricmp_ascii field_name_comparator; + typedef pfc::string::comparatorCaseInsensitiveASCII field_name_comparator; + + static bool field_name_equals(const char * n1, const char * n2) {return field_name_comparator::compare(n1, n2) == 0;} + static bool field_value_equals(const file_info& i1, size_t meta1, const file_info& i2, size_t meta2); + + void to_console() const; + void to_formatter(pfc::string_formatter&) const; + static bool field_is_person(const char * fieldName); + static bool field_is_title(const char * fieldName); + + void to_stream( stream_writer * stream, abort_callback & abort ) const; + void from_stream( stream_reader * stream, abort_callback & abort ); + void from_mem( const void * memPtr, size_t memSize); + + //! Returns ESTIMATED audio chunk spec from what has been put in the file_info. \n + //! Provided for convenience. Do not rely on it for processing decoded data. + audio_chunk::spec_t audio_chunk_spec() const; + + void set_audio_chunk_spec(audio_chunk::spec_t); + + //! Normalize values to Unicode form C + //! @returns true if changed, false otherwise + bool unicode_normalize_C(); + + +#ifdef FOOBAR2000_MOBILE + void info_set_pictures( const GUID * guids, size_t size ); + pfc::array_t info_get_pictures( ) const; + bool info_have_picture(const GUID&) const; + uint64_t makeMetaHash() const; +#endif +protected: + file_info() {} + ~file_info() {} + void copy_meta_single_nocheck(const file_info & p_source,t_size p_index); + void copy_info_single_nocheck(const file_info & p_source,t_size p_index); + void copy_meta_single_by_name_nocheck_ex(const file_info & p_source,const char * p_name,t_size p_name_length); + void copy_info_single_by_name_nocheck_ex(const file_info & p_source,const char * p_name,t_size p_name_length); + inline void copy_meta_single_by_name_nocheck(const file_info & p_source,const char * p_name) {copy_meta_single_by_name_nocheck_ex(p_source,p_name,SIZE_MAX);} + inline void copy_info_single_by_name_nocheck(const file_info & p_source,const char * p_name) {copy_info_single_by_name_nocheck_ex(p_source,p_name,SIZE_MAX);} + + virtual t_size meta_set_nocheck_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length) = 0; + virtual t_size info_set_nocheck_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length) = 0; + inline t_size meta_set_nocheck(const char * p_name,const char * p_value) {return meta_set_nocheck_ex(p_name,SIZE_MAX,p_value,SIZE_MAX);} + inline t_size info_set_nocheck(const char * p_name,const char * p_value) {return info_set_nocheck_ex(p_name,SIZE_MAX,p_value,SIZE_MAX);} +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/file_info_const_impl.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/file_info_const_impl.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,287 @@ +#include "foobar2000-sdk-pch.h" + +#include "file_info_const_impl.h" + +// presorted - do not change without a proper strcmp resort +static const char * const standard_fieldnames[] = { + "ALBUM","ALBUM ARTIST","ARTIST","Album","Album Artist","Artist","COMMENT","Comment","DATE","DISCNUMBER","Date", + "Discnumber","GENRE","Genre","TITLE","TOTALTRACKS","TRACKNUMBER","Title","TotalTracks","Totaltracks","TrackNumber", + "Tracknumber","album","album artist","artist","comment","date","discnumber","genre","title","totaltracks","tracknumber", +}; + +// presorted - do not change without a proper strcmp resort +static const char * const standard_infonames[] = { + "bitrate","bitspersample","channels","codec","codec_profile","encoding","samplerate","tagtype","tool", +}; + +static const char * optimize_fieldname(const char * p_string) { + t_size index; + if (!pfc::binarySearch::run(standard_fieldnames,0,PFC_TABSIZE(standard_fieldnames),p_string,index)) return NULL; + return standard_fieldnames[index]; +} + +static const char * optimize_infoname(const char * p_string) { + t_size index; + if (!pfc::binarySearch::run(standard_infonames,0,PFC_TABSIZE(standard_infonames),p_string,index)) return NULL; + return standard_infonames[index]; +} + +/* +order of things + + meta entries + meta value map + info entries + string buffer + +*/ + +inline static char* stringbuffer_append(char * & buffer,const char * value) +{ + char * ret = buffer; + while(*value) *(buffer++) = *(value++); + *(buffer++) = 0; + return ret; +} + +#ifdef __file_info_const_impl_have_hintmap__ + +namespace { + class sort_callback_hintmap_impl : public pfc::sort_callback + { + public: + sort_callback_hintmap_impl(const file_info_const_impl::meta_entry * p_meta,file_info_const_impl::t_index * p_hintmap) + : m_meta(p_meta), m_hintmap(p_hintmap) + { + } + + int compare(t_size p_index1, t_size p_index2) const + { +// profiler(sort_callback_hintmap_impl_compare); + return pfc::stricmp_ascii(m_meta[m_hintmap[p_index1]].m_name,m_meta[m_hintmap[p_index2]].m_name); + } + + void swap(t_size p_index1, t_size p_index2) + { + pfc::swap_t(m_hintmap[p_index1],m_hintmap[p_index2]); + } + private: + const file_info_const_impl::meta_entry * m_meta; + file_info_const_impl::t_index * m_hintmap; + }; + + class bsearch_callback_hintmap_impl// : public pfc::bsearch_callback + { + public: + bsearch_callback_hintmap_impl( + const file_info_const_impl::meta_entry * p_meta, + const file_info_const_impl::t_index * p_hintmap, + const char * p_name, + t_size p_name_length) + : m_meta(p_meta), m_hintmap(p_hintmap), m_name(p_name), m_name_length(p_name_length) + { + } + + inline int test(t_size p_index) const + { + return pfc::stricmp_ascii_ex(m_meta[m_hintmap[p_index]].m_name,SIZE_MAX,m_name,m_name_length); + } + + private: + const file_info_const_impl::meta_entry * m_meta; + const file_info_const_impl::t_index * m_hintmap; + const char * m_name; + t_size m_name_length; + }; +} + +#endif//__file_info_const_impl_have_hintmap__ + +void file_info_const_impl::copy(const file_info & p_source) +{ +// profiler(file_info_const_impl__copy); + t_size meta_size = 0; + t_size info_size = 0; + t_size valuemap_size = 0; + t_size stringbuffer_size = 0; +#ifdef __file_info_const_impl_have_hintmap__ + t_size hintmap_size = 0; +#endif + + const char * optbuf[64]; + size_t optwalk = 0; + + { +// profiler(file_info_const_impl__copy__pass1); + t_size index; + m_meta_count = pfc::downcast_guarded(p_source.meta_get_count()); + meta_size = m_meta_count * sizeof(meta_entry); +#ifdef __file_info_const_impl_have_hintmap__ + hintmap_size = (m_meta_count > hintmap_cutoff) ? m_meta_count * sizeof(t_index) : 0; +#endif//__file_info_const_impl_have_hintmap__ + for(index = 0; index < m_meta_count; index++ ) + { + { + const char * name = p_source.meta_enum_name(index); + const char * opt = optimize_fieldname(name); + if (optwalk < PFC_TABSIZE(optbuf)) optbuf[optwalk++] = opt; + if (opt == NULL) stringbuffer_size += strlen(name) + 1; + } + + t_size val; const t_size val_max = p_source.meta_enum_value_count(index); + + if (val_max == 1) + { + stringbuffer_size += strlen(p_source.meta_enum_value(index,0)) + 1; + } + else + { + valuemap_size += val_max * sizeof(char*); + + for(val = 0; val < val_max; val++ ) + { + stringbuffer_size += strlen(p_source.meta_enum_value(index,val)) + 1; + } + } + } + + m_info_count = pfc::downcast_guarded(p_source.info_get_count()); + info_size = m_info_count * sizeof(info_entry); + for(index = 0; index < m_info_count; index++ ) + { + const char * name = p_source.info_enum_name(index); + const char * opt = optimize_infoname(name); + if (optwalk < PFC_TABSIZE(optbuf)) optbuf[optwalk++] = opt; + if (opt == NULL) stringbuffer_size += strlen(name) + 1; + stringbuffer_size += strlen(p_source.info_enum_value(index)) + 1; + } + } + + + { +// profiler(file_info_const_impl__copy__alloc); + m_buffer.set_size( +#ifdef __file_info_const_impl_have_hintmap__ + hintmap_size + +#endif + meta_size + info_size + valuemap_size + stringbuffer_size); + } + + char * walk = m_buffer.get_ptr(); + +#ifdef __file_info_const_impl_have_hintmap__ + t_index* hintmap = (hintmap_size > 0) ? (t_index*) walk : NULL; + walk += hintmap_size; +#endif + meta_entry * meta = (meta_entry*) walk; + walk += meta_size; + char ** valuemap = (char**) walk; + walk += valuemap_size; + info_entry * info = (info_entry*) walk; + walk += info_size; + char * stringbuffer = walk; + + m_meta = meta; + m_info = info; +#ifdef __file_info_const_impl_have_hintmap__ + m_hintmap = hintmap; +#endif + + optwalk = 0; + { +// profiler(file_info_const_impl__copy__pass2); + t_size index; + for( index = 0; index < m_meta_count; index ++ ) + { + t_size val; const t_size val_max = p_source.meta_enum_value_count(index); + + { + const char * name = p_source.meta_enum_name(index); + const char * name_opt; + + if (optwalk < PFC_TABSIZE(optbuf)) name_opt = optbuf[optwalk++]; + else name_opt = optimize_fieldname(name); + + if (name_opt == NULL) + meta[index].m_name = stringbuffer_append(stringbuffer, name ); + else + meta[index].m_name = name_opt; + } + + meta[index].m_valuecount = val_max; + + if (val_max == 1) + { + meta[index].m_valuemap = reinterpret_cast(stringbuffer_append(stringbuffer, p_source.meta_enum_value(index,0) )); + } + else + { + meta[index].m_valuemap = valuemap; + for( val = 0; val < val_max ; val ++ ) + *(valuemap ++ ) = stringbuffer_append(stringbuffer, p_source.meta_enum_value(index,val) ); + } + } + + for( index = 0; index < m_info_count; index ++ ) + { + const char * name = p_source.info_enum_name(index); + const char * name_opt; + + if (optwalk < PFC_TABSIZE(optbuf)) name_opt = optbuf[optwalk++]; + else name_opt = optimize_infoname(name); + + if (name_opt == NULL) + info[index].m_name = stringbuffer_append(stringbuffer, name ); + else + info[index].m_name = name_opt; + info[index].m_value = stringbuffer_append(stringbuffer, p_source.info_enum_value(index) ); + } + } + + m_length = p_source.get_length(); + m_replaygain = p_source.get_replaygain(); +#ifdef __file_info_const_impl_have_hintmap__ + if (hintmap != NULL) { +// profiler(file_info_const_impl__copy__hintmap); + for(t_size n=0;n(entry.m_valuemap); + else + return entry.m_valuemap[p_value_number]; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/file_info_const_impl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/file_info_const_impl.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,85 @@ +#pragma once +#include "file_info.h" + +class file_info_readonly : public file_info { + [[noreturn]] static void verboten() { FB2K_BugCheck(); } +protected: + void set_length(double) override { verboten(); } + void set_replaygain(const replaygain_info &) override { verboten(); } + + + t_size meta_set_ex(const char *, t_size, const char *, t_size) override { verboten(); } + void meta_insert_value_ex(t_size, t_size, const char *, t_size) override { verboten(); } + void meta_remove_mask(const bit_array &) override { verboten(); } + void meta_reorder(const t_size *) override { verboten(); } + void meta_remove_values(t_size, const bit_array &) override { verboten(); } + void meta_modify_value_ex(t_size, t_size, const char *, t_size) override { verboten(); } + + t_size info_set_ex(const char *, t_size, const char *, t_size) override { verboten(); } + void info_remove_mask(const bit_array &) override { verboten(); } + + t_size meta_set_nocheck_ex(const char *, t_size, const char *, t_size) override { verboten(); } + t_size info_set_nocheck_ex(const char *, t_size, const char *, t_size) override { verboten(); } +}; + +#define __file_info_const_impl_have_hintmap__ + +//! Special implementation of file_info that implements only const and copy methods. The difference between this and regular file_info_impl is amount of resources used and speed of the copy operation. +class file_info_const_impl : public file_info_readonly +{ +public: + file_info_const_impl(const file_info & p_source) {copy(p_source);} + file_info_const_impl(const file_info_const_impl & p_source) {copy(p_source);} + file_info_const_impl() {m_meta_count = m_info_count = 0; m_length = 0; m_replaygain.reset();} + + double get_length() const {return m_length;} + + t_size meta_get_count() const {return m_meta_count;} + const char* meta_enum_name(t_size p_index) const {return m_meta[p_index].m_name;} + t_size meta_enum_value_count(t_size p_index) const; + const char* meta_enum_value(t_size p_index,t_size p_value_number) const; + t_size meta_find_ex(const char * p_name,t_size p_name_length) const; + + t_size info_get_count() const {return m_info_count;} + const char* info_enum_name(t_size p_index) const {return m_info[p_index].m_name;} + const char* info_enum_value(t_size p_index) const {return m_info[p_index].m_value;} + + + const file_info_const_impl & operator=(const file_info & p_source) {copy(p_source); return *this;} + const file_info_const_impl & operator=(const file_info_const_impl & p_source) {copy(p_source); return *this;} + void copy(const file_info & p_source); + void reset(); + + replaygain_info get_replaygain() const {return m_replaygain;} + +public: + struct meta_entry { + const char * m_name; + t_size m_valuecount; + const char * const * m_valuemap; + }; + + struct info_entry { + const char * m_name; + const char * m_value; + }; + +#ifdef __file_info_const_impl_have_hintmap__ + typedef t_uint32 t_index; + enum {hintmap_cutoff = 20}; +#endif//__file_info_const_impl_have_hintmap__ +private: + pfc::array_t m_buffer; + t_index m_meta_count; + t_index m_info_count; + + const meta_entry * m_meta; + const info_entry * m_info; + +#ifdef __file_info_const_impl_have_hintmap__ + const t_index * m_hintmap; +#endif + + double m_length; + replaygain_info m_replaygain; +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/file_info_filter.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/file_info_filter.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,46 @@ +#pragma once +#include "tracks.h" + +//! Implementing this class gives you direct control over which part of file_info gets altered during a tag update uperation. To be used with metadb_io_v2::update_info_async(). +class NOVTABLE file_info_filter : public service_base { + FB2K_MAKE_SERVICE_INTERFACE(file_info_filter, service_base); +public: + //! Alters specified file_info entry; called as a part of tag update process. Specified file_info has been read from a file, and will be written back.\n + //! WARNING: This will be typically called from another thread than main app thread (precisely, from thread created by tag updater). You should copy all relevant data to members of your file_info_filter instance in constructor and reference only member data in apply_filter() implementation. + //! @returns True when you have altered file_info and changes need to be written back to the file; false if no changes have been made. + virtual bool apply_filter(trackRef p_location, t_filestats p_stats, file_info & p_info) = 0; + + typedef std::function< bool (trackRef, t_filestats, file_info & ) > func_t; + static file_info_filter::ptr create( func_t f ); +}; + +//! Extended file_info_filter allowing the caller to do their own manipulation of the file before and after the metadata update takes place. \n +//! Respected by foobar2000 v1.5 and up; if metadb_io_v4 is supported, then file_info_filter_v2 is understood. +class NOVTABLE file_info_filter_v2 : public file_info_filter { + FB2K_MAKE_SERVICE_INTERFACE(file_info_filter_v2, file_info_filter); +public: + + enum filterStatus_t { + filterNoUpdate = 0, + filterProceed, + filterAlreadyUpdated + }; + //! Called after just before rewriting metadata. The file is not yet opened for writing, but a file_lock has already been granted (so don't call it on your own). \n + //! You can use this method to perform album art updates (via album_art_editor API) alongside metadata updates. \n + //! Return value can be used to stop fb2k from proceeding with metadata update on this file. \n + //! If your own operations on this file fail, just pass the exceptions to the caller and they will be reported just as other tag update errors. + //! @param fileIfAlreadyOpened Reference to an already opened file object, if already opened by the caller. May be null. + virtual filterStatus_t before_tag_update(const char * location, file::ptr fileIfAlreadyOpened, abort_callback & aborter) = 0; + + //! Called after metadata has been updated. \n + //! If you wish to alter the file on your own, use before_tag_update() for this instead. \n + //! If your own operations on this file fail, just pass the exceptions to the caller and they will be reported just as other tag update errors. \n + //! The passed reader object can be used to read the properties of the updated file back. In most cases it will be the writer that was used to update the tags. Do not call tag writing methods on it from this function. + virtual void after_tag_update(const char * location, service_ptr_t reader, abort_callback & aborter) = 0; + + virtual void after_all_tag_updates(abort_callback & aborter) = 0; + + //! Allows you to do your own error logging. + //! @returns True if the error has been noted by your code and does not need to be shown to the user. + virtual bool filter_error(const char * location, const char * msg) = 0; +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/file_info_filter_impl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/file_info_filter_impl.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,36 @@ +#pragma once +#include "file_info_filter.h" +#include "file_info_impl.h" + +//! Generic implementation of file_info_filter_impl. +class file_info_filter_impl : public file_info_filter { +public: + file_info_filter_impl(const pfc::list_base_const_t & p_list, const pfc::list_base_const_t & p_new_info) { + FB2K_DYNAMIC_ASSERT(p_list.get_count() == p_new_info.get_count()); + pfc::array_t order; + order.set_size(p_list.get_count()); + order_helper::g_fill(order.get_ptr(), order.get_size()); + p_list.sort_get_permutation_t(pfc::compare_t, order.get_ptr()); + m_handles.set_count(order.get_size()); + m_infos.set_size(order.get_size()); + for (t_size n = 0; n < order.get_size(); n++) { + m_handles[n] = p_list[order[n]]; + m_infos[n] = *p_new_info[order[n]]; + } + } + + bool apply_filter(metadb_handle_ptr p_location, t_filestats p_stats, file_info & p_info) { + (void)p_stats; + t_size index; + if (m_handles.bsearch_t(pfc::compare_t, p_location, index)) { + p_info = m_infos[index]; + return true; + } + else { + return false; + } + } +private: + metadb_handle_list m_handles; + pfc::array_t m_infos; +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/file_info_impl.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/file_info_impl.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,253 @@ +#include "foobar2000-sdk-pch.h" + +#include +#include + +#include "file_info_impl.h" + + +t_size file_info_impl::meta_get_count() const +{ + return m_meta.get_count(); +} + +const char* file_info_impl::meta_enum_name(t_size p_index) const +{ + return m_meta.get_name(p_index); +} + +t_size file_info_impl::meta_enum_value_count(t_size p_index) const +{ + return m_meta.get_value_count(p_index); +} + +const char* file_info_impl::meta_enum_value(t_size p_index,t_size p_value_number) const +{ + return m_meta.get_value(p_index,p_value_number); +} + +t_size file_info_impl::meta_set_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length) +{ + meta_remove_field_ex(p_name,p_name_length); + return meta_set_nocheck_ex(p_name,p_name_length,p_value,p_value_length); +} + +t_size file_info_impl::meta_set_nocheck_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length) +{ + return m_meta.add_entry(p_name,p_name_length,p_value,p_value_length); +} + +void file_info_impl::meta_insert_value_ex(t_size p_index,t_size p_value_index,const char * p_value,t_size p_value_length) +{ + m_meta.insert_value(p_index,p_value_index,p_value,p_value_length); +} + +void file_info_impl::meta_remove_mask(const bit_array & p_mask) +{ + m_meta.remove_mask(p_mask); +} + +void file_info_impl::meta_reorder(const t_size * p_order) +{ + m_meta.reorder(p_order); +} + +void file_info_impl::meta_remove_values(t_size p_index,const bit_array & p_mask) +{ + m_meta.remove_values(p_index,p_mask); + if (m_meta.get_value_count(p_index) == 0) + m_meta.remove_mask(pfc::bit_array_one(p_index)); +} + +t_size file_info_impl::info_get_count() const +{ + return m_info.get_count(); +} + +const char* file_info_impl::info_enum_name(t_size p_index) const +{ + return m_info.get_name(p_index); +} + +const char* file_info_impl::info_enum_value(t_size p_index) const +{ + return m_info.get_value(p_index); +} + +t_size file_info_impl::info_set_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length) +{ + info_remove_ex(p_name,p_name_length); + return info_set_nocheck_ex(p_name,p_name_length,p_value,p_value_length); +} + +t_size file_info_impl::info_set_nocheck_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length) +{ + return m_info.add_item(p_name,p_name_length,p_value,p_value_length); +} + +void file_info_impl::info_remove_mask(const bit_array & p_mask) +{ + m_info.remove_mask(p_mask); +} + + +file_info_impl::file_info_impl(const file_info & p_source) +{ + copy(p_source); +} + +file_info_impl::file_info_impl(const file_info_impl & p_source) +{ + copy(p_source); +} + +const file_info_impl & file_info_impl::operator=(const file_info_impl & p_source) +{ + copy(p_source); + return *this; +} + +file_info_impl::file_info_impl() {} + +double file_info_impl::get_length() const +{ + return m_length; +} + +void file_info_impl::set_length(double p_length) +{ + m_length = p_length; +} + +void file_info_impl::meta_modify_value_ex(t_size p_index,t_size p_value_index,const char * p_value,t_size p_value_length) +{ + m_meta.modify_value(p_index,p_value_index,p_value,p_value_length); +} + +replaygain_info file_info_impl::get_replaygain() const +{ + return m_replaygain; +} + +void file_info_impl::set_replaygain(const replaygain_info & p_info) +{ + m_replaygain = p_info; +} + + + + +file_info_impl::~file_info_impl() +{ +} + +t_size file_info_impl_utils::info_storage::add_item(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length) { + t_size index = m_info.get_size(); + m_info.set_size(index + 1); + m_info[index].init(p_name,p_name_length,p_value,p_value_length); + return index; +} + +void file_info_impl_utils::info_storage::remove_mask(const bit_array & p_mask) { + pfc::remove_mask_t(m_info,p_mask); +} + + +size_t file_info_impl_utils::meta_storage::add_blank(const char* name) { + meta_entry e; + e.m_name = name; + const auto ret = m_data.size(); + m_data.add_item(std::move(e)); + return ret; +} + +t_size file_info_impl_utils::meta_storage::add_entry(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length) +{ + const auto ret = m_data.size(); + m_data.add_item(meta_entry(p_name, p_name_length, p_value, p_value_length)); + return ret; +} + +void file_info_impl_utils::meta_storage::insert_value(t_size p_index,t_size p_value_index,const char * p_value,t_size p_value_length) +{ + m_data[p_index].insert_value(p_value_index,p_value,p_value_length); +} + +void file_info_impl_utils::meta_storage::modify_value(t_size p_index,t_size p_value_index,const char * p_value,t_size p_value_length) +{ + m_data[p_index].modify_value(p_value_index,p_value,p_value_length); +} + +void file_info_impl_utils::meta_storage::remove_values(t_size p_index,const bit_array & p_mask) +{ + m_data[p_index].remove_values(p_mask); +} + +void file_info_impl_utils::meta_storage::remove_mask(const bit_array & p_mask) +{ + pfc::remove_mask_t(m_data,p_mask); +} + + +file_info_impl_utils::meta_entry::meta_entry(const char * p_name,t_size p_name_len,const char * p_value,t_size p_value_len) +{ + m_name.set_string(p_name,p_name_len); + m_values.set_size(1); + m_values[0].set_string(p_value,p_value_len); +} + + +void file_info_impl_utils::meta_entry::remove_values(const bit_array & p_mask) +{ + pfc::remove_mask_t(m_values,p_mask); +} + +void file_info_impl_utils::meta_entry::insert_value(t_size p_value_index,const char * p_value,t_size p_value_length) +{ + pfc::string_simple temp; + temp.set_string(p_value,p_value_length); + pfc::insert_t(m_values,temp,p_value_index); +} + +void file_info_impl_utils::meta_entry::modify_value(t_size p_value_index,const char * p_value,t_size p_value_length) +{ + m_values[p_value_index].set_string(p_value,p_value_length); +} + +void file_info_impl_utils::meta_storage::reorder(const t_size * p_order) +{ + pfc::reorder_t(m_data,p_order,m_data.get_size()); +} + +void file_info_impl::copy_meta(const file_info & p_source) +{ + m_meta.copy_from(p_source); +} + +void file_info_impl::copy_info(const file_info & p_source) +{ + m_info.copy_from(p_source); +} + +void file_info_impl_utils::meta_storage::copy_from(const file_info & p_info) +{ + t_size meta_index,meta_count = p_info.meta_get_count(); + m_data.set_size(meta_count); + for(meta_index=0;meta_index +#include "file_info.h" + +namespace file_info_impl_utils { + + struct info_entry { + void init(const char * p_name,t_size p_name_len,const char * p_value,t_size p_value_len) { + m_name.set_string(p_name,p_name_len); + m_value.set_string(p_value,p_value_len); + } + + inline const char * get_name() const {return m_name;} + inline const char * get_value() const {return m_value;} + + pfc::string_simple m_name,m_value; + }; + + typedef pfc::array_t info_entry_array; + +} + +namespace pfc { + template<> class traits_t : public traits_t {}; +}; + + +namespace file_info_impl_utils { + class info_storage + { + public: + t_size add_item(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length); + void remove_mask(const bit_array & p_mask); + inline t_size get_count() const {return m_info.get_count();} + inline const char * get_name(t_size p_index) const {return m_info[p_index].get_name();} + inline const char * get_value(t_size p_index) const {return m_info[p_index].get_value();} + void copy_from(const file_info & p_info); + private: + info_entry_array m_info; + }; +} + + +namespace file_info_impl_utils { + typedef pfc::array_hybrid_t meta_value_array; + struct meta_entry { + meta_entry() {} + meta_entry(const char * p_name,t_size p_name_len,const char * p_value,t_size p_value_len); + + void remove_values(const bit_array & p_mask); + void insert_value(t_size p_value_index,const char * p_value,t_size p_value_length); + void modify_value(t_size p_value_index,const char * p_value,t_size p_value_length); + + inline const char * get_name() const {return m_name;} + inline const char * get_value(t_size p_index) const {return m_values[p_index];} + inline t_size get_value_count() const {return m_values.get_size();} + + + pfc::string_simple m_name; + meta_value_array m_values; + }; + typedef pfc::array_hybrid_t meta_entry_array; +} +namespace pfc { + template<> class traits_t : public pfc::traits_combined {}; +} + + +namespace file_info_impl_utils { + class meta_storage + { + public: + size_t add_blank(const char* name); + t_size add_entry(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length); + void insert_value(t_size p_index,t_size p_value_index,const char * p_value,t_size p_value_length); + void modify_value(t_size p_index,t_size p_value_index,const char * p_value,t_size p_value_length); + void remove_values(t_size p_index,const bit_array & p_mask); + void remove_mask(const bit_array & p_mask); + void copy_from(const file_info & p_info); + + inline void reorder(const t_size * p_order); + + inline t_size get_count() const {return m_data.get_size();} + + inline const char * get_name(t_size p_index) const {PFC_ASSERT(p_index < m_data.get_size()); return m_data[p_index].get_name();} + inline const char * get_value(t_size p_index,t_size p_value_index) const {PFC_ASSERT(p_index < m_data.get_size()); return m_data[p_index].get_value(p_value_index);} + inline t_size get_value_count(t_size p_index) const {PFC_ASSERT(p_index < m_data.get_size()); return m_data[p_index].get_value_count();} + + private: + meta_entry_array m_data; + }; +} + +//! Implements file_info. +class file_info_impl : public file_info +{ +public: + file_info_impl(const file_info_impl & p_source); + file_info_impl(const file_info & p_source); + file_info_impl(); + ~file_info_impl(); + + double get_length() const; + void set_length(double p_length); + + void copy_meta(const file_info & p_source);//virtualized for performance reasons, can be faster in two-pass + void copy_info(const file_info & p_source);//virtualized for performance reasons, can be faster in two-pass + + t_size meta_get_count() const; + const char* meta_enum_name(t_size p_index) const; + t_size meta_enum_value_count(t_size p_index) const; + const char* meta_enum_value(t_size p_index,t_size p_value_number) const; + t_size meta_set_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length); + void meta_insert_value_ex(t_size p_index,t_size p_value_index,const char * p_value,t_size p_value_length); + void meta_remove_mask(const bit_array & p_mask); + void meta_reorder(const t_size * p_order); + void meta_remove_values(t_size p_index,const bit_array & p_mask); + void meta_modify_value_ex(t_size p_index,t_size p_value_index,const char * p_value,t_size p_value_length); + + t_size info_get_count() const; + const char* info_enum_name(t_size p_index) const; + const char* info_enum_value(t_size p_index) const; + t_size info_set_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length); + void info_remove_mask(const bit_array & p_mask); + + const file_info_impl & operator=(const file_info_impl & p_source); + + replaygain_info get_replaygain() const; + void set_replaygain(const replaygain_info & p_info); + +protected: + t_size meta_set_nocheck_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length); + t_size info_set_nocheck_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length); + + file_info_impl_utils::meta_storage m_meta; + file_info_impl_utils::info_storage m_info; + + + double m_length = 0; + + replaygain_info m_replaygain; +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/file_info_merge.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/file_info_merge.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,205 @@ +#include "foobar2000-sdk-pch.h" +#include "file_info.h" + +static t_size merge_tags_calc_rating_by_index(const file_info & p_info,t_size p_index) { + t_size n,m = p_info.meta_enum_value_count(p_index); + t_size ret = 0; + for(n=0;ninfo_get(field); + if (val) to->info_set(field,val); +} +#endif + +namespace { + struct meta_merge_entry { + meta_merge_entry() : m_rating(0) {} + t_size m_rating; + pfc::array_t m_data; + }; + + class meta_merge_map_enumerator { + public: + meta_merge_map_enumerator(file_info & p_out) : m_out(p_out) { + m_out.meta_remove_all(); + } + void operator() (const char * p_name, const meta_merge_entry & p_entry) { + if (p_entry.m_data.get_size() > 0) { + t_size index = m_out.__meta_add_unsafe(p_name,p_entry.m_data[0]); + for(t_size walk = 1; walk < p_entry.m_data.get_size(); ++walk) { + m_out.meta_add_value(index,p_entry.m_data[walk]); + } + } + } + private: + file_info & m_out; + }; +} + +static void merge_meta(file_info & p_out,const pfc::list_base_const_t & p_in) { + pfc::map_t map; + for(t_size in_walk = 0; in_walk < p_in.get_count(); in_walk++) { + const file_info & in = * p_in[in_walk]; + for(t_size meta_walk = 0, meta_count = in.meta_get_count(); meta_walk < meta_count; meta_walk++ ) { + meta_merge_entry & entry = map.find_or_add(in.meta_enum_name(meta_walk)); + t_size rating = merge_tags_calc_rating_by_index(in,meta_walk); + if (rating > entry.m_rating) { + entry.m_rating = rating; + const t_size value_count = in.meta_enum_value_count(meta_walk); + entry.m_data.set_size(value_count); + for(t_size value_walk = 0; value_walk < value_count; value_walk++ ) { + entry.m_data[value_walk] = in.meta_enum_value(meta_walk,value_walk); + } + } + } + } + + meta_merge_map_enumerator en(p_out); + map.enumerate(en); +} + +void file_info::merge(const pfc::list_base_const_t & p_in) +{ + t_size in_count = p_in.get_count(); + if (in_count == 0) + { + meta_remove_all(); + return; + } + else if (in_count == 1) + { + const file_info * info = p_in[0]; + + copy_meta(*info); + + set_replaygain(replaygain_info::g_merge(get_replaygain(),info->get_replaygain())); + + overwrite_info(*info); + + //copy_info_single_by_name(*info,"tagtype"); + + return; + } + + merge_meta(*this,p_in); + + { + pfc::string8_fastalloc tagtype; + replaygain_info rg = get_replaygain(); + t_size in_ptr; + for(in_ptr = 0; in_ptr < in_count; in_ptr++ ) + { + const file_info * info = p_in[in_ptr]; + rg = replaygain_info::g_merge(rg, info->get_replaygain()); + t_size field_ptr, field_max = info->info_get_count(); + for(field_ptr = 0; field_ptr < field_max; field_ptr++ ) + { + const char * field_name = info->info_enum_name(field_ptr), * field_value = info->info_enum_value(field_ptr); + if (*field_value) + { + if (!pfc::stricmp_ascii(field_name,"tagtype")) + { + if (!tagtype.is_empty()) tagtype += "|"; + tagtype += field_value; + } + } + } + } + if (!tagtype.is_empty()) info_set("tagtype",tagtype); + set_replaygain(rg); + } +} + +void file_info::overwrite_info(const file_info & p_source) { + t_size count = p_source.info_get_count(); + for(t_size n=0;ncopy_meta(tag); + this->set_replaygain( replaygain_info::g_merge( this->get_replaygain(), tag.get_replaygain() ) ); + + const size_t iCount = tag.info_get_count(); + for( size_t iWalk = 0; iWalk < iCount; ++iWalk ) { + auto n = tag.info_enum_name(iWalk); + if ( pfc::stringEqualsI_ascii( n, _tagtype ) || isSC(n) ) { + this->info_set(n, tag.info_enum_value( iWalk ) ); + } + } + +#ifdef FOOBAR2000_FILE_INFO_PICTURES + { + auto p = tag.info_get("pictures"); + if ( p != nullptr ) this->info_set("pictures", p); + } +#endif +} + +void file_info::_add_tag(const file_info & otherTag) { + this->set_replaygain( replaygain_info::g_merge( this->get_replaygain(), otherTag.get_replaygain() ) ); + + const char * tt1 = this->info_get(_tagtype); + const char * tt2 = otherTag.info_get(_tagtype); + if (tt2) { + if (tt1) { + this->info_set(_tagtype, PFC_string_formatter() << tt1 << "|" << tt2); + } else { + this->info_set(_tagtype, tt2); + } + } + + { + const size_t iCount = otherTag.info_get_count(); + for( size_t w = 0; w < iCount; ++ w ) { + auto n = otherTag.info_enum_name(w); + if (isSC(n) && !this->info_get(n)) { + this->info_set( n, otherTag.info_enum_value(w) ); + } + } + } + +#ifdef FOOBAR2000_FILE_INFO_PICTURES + if (this->info_get("pictures") == nullptr) { + auto p = otherTag.info_get("pictures"); + if ( p != nullptr ) info_set("pictures", p); + } +#endif +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/file_lock_manager.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/file_lock_manager.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,77 @@ +#pragma once + +/* +File lock management API +Historical note: while this API was first published in a 2018 release of the SDK, it had been around for at least a decade and is supported in all fb2k versions from 0.9 up. +The semantics are similar to those of blocking POSIX flock(). +Since read locks are expected to be held for a long period of time - for an example, when playing an audio track, a holder of such lock can query whether someone else is waiting for this lock to be released. +Various audio file operations performed by fb2k core use file locks to synchronize access to the files - in particular, to allow graceful updates of tags on the currently playing track. + +Usage examples: +If you want to write tags to an audio file, using low level methods such as input or album_art_editor APIs- + Obtain a write lock before accessing your file and release it when done. +If you want to keep an audio file open for an extended period of time and allow others to write to it- + Obtain a read lock, check is_release_requested() on it periodically; when it returns true, close the file, release the lock, obtain a new lock (which will block you until the peding write operation has completed), reopen the file and resume decoding where you left. + +Final note: +Majority of the fb2k components will never need this API. +If you carry out tag updates via metadb_io, the locking is already dealt with by fb2k core. +*/ + +//! An instance of a file lock object. Use file_lock_manager to instantiate. +class NOVTABLE file_lock : public service_base { +public: + //! Returns whether we're blocking other attempts to access this file. A read lock does not block other read locks, but a write lock requires exclusive access.\n + //! Typically, time consuming read operations check this periodically and close the file / release the lock / reacquire the lock / reopen the file when signaled. + virtual bool is_release_requested() = 0; + + FB2K_MAKE_SERVICE_INTERFACE(file_lock, service_base); +}; + +typedef service_ptr_t file_lock_ptr; + +//! \since 1.5 +//! Modern version of file locking. \n +//! A read lock can be interrupted by a write lock request, from the thread that requested writing. \n +class NOVTABLE file_lock_interrupt : public service_base { + FB2K_MAKE_SERVICE_INTERFACE(file_lock_interrupt, service_base); +public: + //! Please note that interrupt() is called outside any sync scopes and may be called after lock reference has been released. \n + //! It is implementer's responsibility to safeguard against such. \n + //! The interrupt() function must *never* fail, unless aborted by calling context - which means that whoever asked for write access is aborting whatever they're doing. \n + //! This function may block for as long as it takes to release the owned resources, but must be able to abort cleanly if doing so. \n + //! If the function was aborted, it may be called again on the same object. \n + //! If the function succeeded, it will not be called again on the same object; the object will be released immediately after. + virtual void interrupt( abort_callback & aborter ) = 0; + + static file_lock_interrupt::ptr create( std::function< void (abort_callback&)> ); +}; + +//! Entry point class for obtaining file_lock objects. +class NOVTABLE file_lock_manager : public service_base { +public: + enum t_mode { + mode_read = 0, + mode_write + }; + //! Acquires a read or write lock for this file path. \n + //! If asked for read access, waits until nobody else holds a write lock for this path (but others may read at the same time). + //! If asked for write access, access until nobody else holds a read or write lock for this path. \n + //! The semantics are similar to those of blocking POSIX flock(). + virtual file_lock_ptr acquire(const char * p_path, t_mode p_mode, abort_callback & p_abort) = 0; + + //! Helper, calls acquire() with mode_read. + file_lock_ptr acquire_read(const char * p_path, abort_callback & p_abort) { return acquire(p_path, mode_read, p_abort); } + //! Helper, calls acquire() with mode_write. + file_lock_ptr acquire_write(const char * p_path, abort_callback & p_abort) { return acquire(p_path, mode_write, p_abort); } + + + FB2K_MAKE_SERVICE_COREAPI(file_lock_manager); +}; + +// \since 1.5 +class NOVTABLE file_lock_manager_v2 : public file_lock_manager { + FB2K_MAKE_SERVICE_COREAPI_EXTENSION( file_lock_manager_v2, file_lock_manager ); +public: + virtual fb2k::objRef acquire_read_v2(const char * p_path, file_lock_interrupt::ptr interruptHandler, abort_callback & p_abort) = 0; +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/file_operation_callback.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/file_operation_callback.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,134 @@ +#include "foobar2000-sdk-pch.h" +#include "file_operation_callback.h" +#include "playlist.h" +#include "metadb.h" + + +static void g_on_files_deleted_sorted(const pfc::list_base_const_t & p_items) +{ + //library_manager::get()->on_files_deleted_sorted(p_items); + playlist_manager::get()->on_files_deleted_sorted(p_items); + + FB2K_FOR_EACH_SERVICE(file_operation_callback, on_files_deleted_sorted(p_items)); +} + +static void g_on_files_moved_sorted(const pfc::list_base_const_t & p_from,const pfc::list_base_const_t & p_to) +{ + { + auto api = playlist_manager::get(); + api->on_files_moved_sorted(p_from,p_to); + api->on_files_deleted_sorted(p_from); + } + FB2K_FOR_EACH_SERVICE(file_operation_callback, on_files_moved_sorted(p_from,p_to)); +} + +static void g_on_files_copied_sorted(const pfc::list_base_const_t & p_from,const pfc::list_base_const_t & p_to) +{ + FB2K_FOR_EACH_SERVICE(file_operation_callback, on_files_copied_sorted(p_from,p_to)); +} + +void file_operation_callback::g_on_files_deleted(const pfc::list_base_const_t & p_items) +{ + core_api::ensure_main_thread(); + t_size count = p_items.get_count(); + if (count > 0) + { + if (count == 1) g_on_files_deleted_sorted(p_items); + else + { + pfc::array_t order; order.set_size(count); + order_helper::g_fill(order); + p_items.sort_get_permutation_t(metadb::path_compare,order.get_ptr()); + g_on_files_deleted_sorted(pfc::list_permutation_t(p_items,order.get_ptr(),count)); + } + } +} + +void file_operation_callback::g_on_files_moved(const pfc::list_base_const_t & p_from,const pfc::list_base_const_t & p_to) +{ + core_api::ensure_main_thread(); + pfc::dynamic_assert(p_from.get_count() == p_to.get_count()); + t_size count = p_from.get_count(); + if (count > 0) + { + if (count == 1) g_on_files_moved_sorted(p_from,p_to); + else + { + pfc::array_t order; order.set_size(count); + order_helper::g_fill(order); + p_from.sort_get_permutation_t(metadb::path_compare,order.get_ptr()); + g_on_files_moved_sorted(pfc::list_permutation_t(p_from,order.get_ptr(),count),pfc::list_permutation_t(p_to,order.get_ptr(),count)); + } + } +} + +void file_operation_callback::g_on_files_copied(const pfc::list_base_const_t & p_from,const pfc::list_base_const_t & p_to) +{ + if (core_api::assert_main_thread()) + { + assert(p_from.get_count() == p_to.get_count()); + t_size count = p_from.get_count(); + if (count > 0) + { + if (count == 1) g_on_files_copied_sorted(p_from,p_to); + else + { + pfc::array_t order; order.set_size(count); + order_helper::g_fill(order); + p_from.sort_get_permutation_t(metadb::path_compare,order.get_ptr()); + g_on_files_copied_sorted(pfc::list_permutation_t(p_from,order.get_ptr(),count),pfc::list_permutation_t(p_to,order.get_ptr(),count)); + } + } + } +} +bool file_operation_callback::g_search_sorted_list(const pfc::list_base_const_t & p_list,const char * p_string,t_size & p_index) { + return pfc::binarySearch::run(p_list,0,p_list.get_count(),p_string,p_index); +} + +bool file_operation_callback::g_update_list_on_moved_ex(metadb_handle_list_ref p_list,t_pathlist p_from,t_pathlist p_to, metadb_handle_list_ref itemsAdded, metadb_handle_list_ref itemsRemoved) { + auto api = metadb::get(); + bool changed = false; + itemsAdded.remove_all(); itemsRemoved.remove_all(); + for(t_size walk = 0; walk < p_list.get_count(); ++walk) { + metadb_handle_ptr item = p_list[walk]; + t_size index; + if (g_search_sorted_list(p_from,item->get_path(),index)) { + metadb_handle_ptr newItem; + api->handle_create_replace_path_canonical(newItem,item,p_to[index]); + p_list.replace_item(walk,newItem); + changed = true; + itemsAdded.add_item(newItem); itemsRemoved.add_item(item); + } + } + return changed; +} +bool file_operation_callback::g_update_list_on_moved(metadb_handle_list_ref p_list,const pfc::list_base_const_t & p_from,const pfc::list_base_const_t & p_to) { + auto api = metadb::get(); + bool changed = false; + for(t_size walk = 0; walk < p_list.get_count(); ++walk) { + metadb_handle_ptr item = p_list[walk]; + t_size index; + if (g_search_sorted_list(p_from,item->get_path(),index)) { + metadb_handle_ptr newItem; + api->handle_create_replace_path_canonical(newItem,item,p_to[index]); + p_list.replace_item(walk,newItem); + changed = true; + } + } + return changed; +} + + +bool file_operation_callback::g_mark_dead_entries(metadb_handle_list_cref items, bit_array_var & mask, t_pathlist deadPaths) { + bool found = false; + const t_size total = items.get_count(); + for(t_size walk = 0; walk < total; ++walk) { + t_size index; + if (g_search_sorted_list(deadPaths,items[walk]->get_path(),index)) { + mask.set(walk,true); found = true; + } else { + mask.set(walk,false); + } + } + return found; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/file_operation_callback.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/file_operation_callback.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,63 @@ +#pragma once +#include "metadb.h" + +//! Interface to notify component system about files being deleted or moved. Operates in app's main thread only. +class NOVTABLE file_operation_callback : public service_base { +public: + typedef const pfc::list_base_const_t & t_pathlist; + //! p_items is a metadb::path_compare sorted list of files that have been deleted. + virtual void on_files_deleted_sorted(t_pathlist p_items) = 0; + //! p_from is a metadb::path_compare sorted list of files that have been moved, p_to is a list of corresponding target locations. + virtual void on_files_moved_sorted(t_pathlist p_from,t_pathlist p_to) = 0; + //! p_from is a metadb::path_compare sorted list of files that have been copied, p_to is a list of corresponding target locations. + virtual void on_files_copied_sorted(t_pathlist p_from,t_pathlist p_to) = 0; + + static void g_on_files_deleted(const pfc::list_base_const_t & p_items); + static void g_on_files_moved(const pfc::list_base_const_t & p_from,const pfc::list_base_const_t & p_to); + static void g_on_files_copied(const pfc::list_base_const_t & p_from,const pfc::list_base_const_t & p_to); + + static bool g_search_sorted_list(const pfc::list_base_const_t & p_list,const char * p_string,t_size & p_index); + static bool g_update_list_on_moved(metadb_handle_list_ref p_list,t_pathlist p_from,t_pathlist p_to); + + static bool g_update_list_on_moved_ex(metadb_handle_list_ref p_list,t_pathlist p_from,t_pathlist p_to, metadb_handle_list_ref itemsAdded, metadb_handle_list_ref itemsRemoved); + + static bool g_mark_dead_entries(metadb_handle_list_cref items, bit_array_var & mask, t_pathlist deadPaths); + + + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(file_operation_callback); +}; + + + +//! New in 0.9.5. +class NOVTABLE file_operation_callback_dynamic { +public: + //! p_items is a metadb::path_compare sorted list of files that have been deleted. + virtual void on_files_deleted_sorted(const pfc::list_base_const_t & p_items) = 0; + //! p_from is a metadb::path_compare sorted list of files that have been moved, p_to is a list of corresponding target locations. + virtual void on_files_moved_sorted(const pfc::list_base_const_t & p_from,const pfc::list_base_const_t & p_to) = 0; + //! p_from is a metadb::path_compare sorted list of files that have been copied, p_to is a list of corresponding target locations. + virtual void on_files_copied_sorted(const pfc::list_base_const_t & p_from,const pfc::list_base_const_t & p_to) = 0; +}; + +//! New in 0.9.5. +class NOVTABLE file_operation_callback_dynamic_manager : public service_base { +public: + virtual void register_callback(file_operation_callback_dynamic * p_callback) = 0; + virtual void unregister_callback(file_operation_callback_dynamic * p_callback) = 0; + + FB2K_MAKE_SERVICE_COREAPI(file_operation_callback_dynamic_manager); +}; + +//! New in 0.9.5. +class file_operation_callback_dynamic_impl_base : public file_operation_callback_dynamic { +public: + file_operation_callback_dynamic_impl_base() {file_operation_callback_dynamic_manager::get()->register_callback(this);} + ~file_operation_callback_dynamic_impl_base() {file_operation_callback_dynamic_manager::get()->unregister_callback(this);} + + void on_files_deleted_sorted(const pfc::list_base_const_t& p_items) override { (void)p_items; } + void on_files_moved_sorted(const pfc::list_base_const_t& p_from, const pfc::list_base_const_t& p_to) override { (void)p_from; (void)p_to; } + void on_files_copied_sorted(const pfc::list_base_const_t& p_from, const pfc::list_base_const_t& p_to) override { (void)p_from; (void)p_to; } + + PFC_CLASS_NOT_COPYABLE_EX(file_operation_callback_dynamic_impl_base); +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/filesystem.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/filesystem.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,2519 @@ +#include "foobar2000-sdk-pch.h" +#include "filesystem.h" +#include "unpack.h" +#include "archive.h" +#include "hasher_md5.h" +#include "mem_block_container.h" +#include "filesystem_transacted.h" + +static constexpr char unpack_prefix[] = "unpack://"; +static constexpr unsigned unpack_prefix_len = 9; + + +#ifndef _WIN32 +#include +#include +#include +#endif + +void unpacker::g_open(service_ptr_t & p_out,const service_ptr_t & p,abort_callback & p_abort) +{ + for (auto ptr : enumerate()) { + p->reopen(p_abort); + try { + ptr->open(p_out, p, p_abort); + return; + } catch (exception_io_data const&) {} + } + throw exception_io_data(); +} + +void file::seek_probe(t_filesize p_position, abort_callback & p_abort) { + try { seek(p_position, p_abort); } catch(exception_io_seek_out_of_range const &) {throw exception_io_data();} +} + +void file::seek_ex(t_sfilesize p_position, file::t_seek_mode p_mode, abort_callback &p_abort) { + switch(p_mode) { + case seek_from_beginning: + seek(p_position,p_abort); + break; + case seek_from_current: + seek(p_position + get_position(p_abort),p_abort); + break; + case seek_from_eof: + seek(p_position + get_size_ex(p_abort),p_abort); + break; + default: + throw exception_io_data(); + } +} + +static void makeBuffer(pfc::array_t & buffer, size_t size) { + for(;;) {// Tolerant malloc - allocate a smaller buffer if we're unable to acquire the requested size. + try { + buffer.set_size_discard( size ); + return; + } catch(std::bad_alloc const &) { + if (size < 256) throw; + size >>= 1; + } + } +} + +t_filesize file::g_transfer(stream_reader * p_src,stream_writer * p_dst,t_filesize p_bytes,abort_callback & p_abort) { + pfc::array_t temp; + makeBuffer(temp, (t_size)pfc::min_t(1024*1024*8,p_bytes)); + void* ptr = temp.get_ptr(); + t_filesize done = 0; + while(done(temp.get_size(),p_bytes-done); + delta = p_src->read(ptr,delta,p_abort); + if (delta<=0) break; + p_dst->write(ptr,delta,p_abort); + done += delta; + } + return done; +} + +void file::g_transfer_object(stream_reader * p_src,stream_writer * p_dst,t_filesize p_bytes,abort_callback & p_abort) { + if (g_transfer(p_src,p_dst,p_bytes,p_abort) != p_bytes) + throw exception_io_data_truncation(); +} + + +void filesystem::g_get_canonical_path(const char * path,pfc::string_base & out) +{ + // TRACK_CALL_TEXT("filesystem::g_get_canonical_path"); + for (auto ptr : enumerate()) { + if (ptr->get_canonical_path(path, out)) return; + } + //no one wants to process this, let's copy over + out = path; +} + +void filesystem::g_get_display_path(const char* path, pfc::string_base& out, filesystem::ptr& reuseMe) { + + if (reuseMe.is_valid() && reuseMe->is_our_path(path)) { + if (!reuseMe->get_display_path(path, out)) { + // should not get here + out = path; + } + } else { + if (!g_get_interface(reuseMe, path)) { + out = path; + return; + } + if (!reuseMe->get_display_path(path, out)) { + // should not get here + out = path; + } + } +} + +void filesystem::g_get_display_path(const char * path,pfc::string_base & out) +{ + // TRACK_CALL_TEXT("filesystem::g_get_display_path"); + service_ptr_t ptr; + if (!g_get_interface(ptr,path)) + { + //no one wants to process this, let's copy over + out = path; + } + else + { + if (!ptr->get_display_path(path,out)) + out = path; + } +} + +pfc::string8 filesystem::g_get_native_path( const char * path, abort_callback & a ) { + pfc::string8 ret; + g_get_native_path( path, ret, a); + return ret; +} + +bool filesystem::g_get_native_path( const char * path, pfc::string_base & out, abort_callback & a) { + // Is proper file:// path? + if (foobar2000_io::extract_native_path( path, out ) ) return true; + + { + filesystem_v3::ptr fs; + if (fs &= tryGet(path)) { + auto n = fs->getNativePath(path, a); + if (n.is_valid()) { + out = n->c_str(); return true; + } + } + } + + // Set anyway + out = path; + + // Maybe just a file:// less local path? Check for other protocol markers + // If no :// present, return true anyway + return strstr( path, "://" ) == NULL; +} + +filesystem::ptr filesystem::getLocalFS() { + return get("file://dummy"); +} + +filesystem::ptr filesystem::tryGet(const char* path) { + filesystem::ptr rv; + g_get_interface(rv, path); + return rv; +} + +filesystem::ptr filesystem::g_get_interface(const char * path) { + filesystem::ptr rv; + if (!g_get_interface(rv, path)) throw exception_io_no_handler_for_path(); + return rv; + +} + +#define USE_FSCACHE 1 +#if USE_FSCACHE +#include + +static pfc::readWriteLock fsCacheGuard; + +typedef size_t protoHash_t; +static protoHash_t protoHash(const char * URL) { + const char* delim = strstr(URL, "://"); + if (delim == nullptr) return 0; + + union { + protoHash_t hash; + char chars[sizeof(protoHash_t)]; + } u; + u.hash = 0; + unsigned i = 0; + for (const char* walk = URL; walk != delim; ++walk) { + u.chars[i] ^= pfc::ascii_tolower_lookup(*walk); + i = (i + 1) % std::size(u.chars); + } + return u.hash; +} + +// Do not use service_ptr in static objects, do not try to release them in static object destructor +static std::unordered_multimap< protoHash_t, filesystem* > fsCache; + +static bool read_fs_cache(protoHash_t key, const char * path, filesystem::ptr& ret) { + auto range = fsCache.equal_range(key); + for (auto walk = range.first; walk != range.second; ++walk) { + if (walk->second->is_our_path(path)) { + ret = walk->second; + return true; + } + } + return false; +} + +bool filesystem::g_get_interface(service_ptr_t & p_out,const char * path) +{ + PFC_ASSERT( path != nullptr ); + PFC_ASSERT( path[0] != 0 ); + + const auto key = protoHash(path); + + { + PFC_INSYNC_READ(fsCacheGuard); + if (read_fs_cache(key, path, p_out)) return true; + } + + for (auto ptr : enumerate()) { + if (ptr->is_our_path(path)) { + { + PFC_INSYNC_WRITE(fsCacheGuard); + filesystem::ptr dummy; // make sure it didn't just get added + if (!read_fs_cache(key, path, dummy)) { + auto addref = ptr; + fsCache.insert({ key, addref.detach()}); + } + } + p_out = std::move(ptr); + return true; + } + } + return false; +} + + +#else +bool filesystem::g_get_interface(service_ptr_t& p_out, const char* path) +{ + PFC_ASSERT(path != nullptr); + PFC_ASSERT(path[0] != 0); + + for (auto ptr : enumerate()) { + if (ptr->is_our_path(path)) { + p_out = std::move(ptr); + return true; + } + } + return false; +} + +#endif + +void filesystem::g_open(service_ptr_t & p_out,const char * path,t_open_mode mode,abort_callback & p_abort) +{ + TRACK_CALL_TEXT("filesystem::g_open"); + g_get_interface(path)->open(p_out,path,mode,p_abort); +} + + +void filesystem::g_open_timeout(service_ptr_t & p_out,const char * p_path,t_open_mode p_mode,double p_timeout,abort_callback & p_abort) { + FB2K_RETRY_ON_SHARING_VIOLATION( g_open(p_out, p_path, p_mode, p_abort), p_abort, p_timeout); +} + +bool filesystem::g_exists(const char * p_path,abort_callback & p_abort) +{ + t_filestats stats; + bool dummy; + try { + g_get_stats(p_path,stats,dummy,p_abort); + } catch(exception_io_not_found const &) {return false;} + return true; +} + +bool filesystem::g_exists_writeable(const char * p_path,abort_callback & p_abort) +{ + t_filestats stats; + bool writeable; + try { + g_get_stats(p_path,stats,writeable,p_abort); + } catch(exception_io_not_found const &) {return false;} + return writeable; +} + +void filesystem::g_remove(const char * p_path,abort_callback & p_abort) { + g_get_interface(p_path)->remove(p_path,p_abort); +} + +void filesystem::g_remove_timeout(const char * p_path,double p_timeout,abort_callback & p_abort) { + FB2K_RETRY_FILE_MOVE( g_remove(p_path, p_abort), p_abort, p_timeout ); +} + +void filesystem::g_move_timeout(const char * p_src,const char * p_dst,double p_timeout,abort_callback & p_abort) { + FB2K_RETRY_FILE_MOVE( g_move(p_src, p_dst, p_abort), p_abort, p_timeout ); +} + +void filesystem::g_copy_timeout(const char * p_src,const char * p_dst,double p_timeout,abort_callback & p_abort) { + FB2K_RETRY_FILE_MOVE( g_copy(p_src, p_dst, p_abort), p_abort, p_timeout ); +} + +void filesystem::g_create_directory(const char * p_path,abort_callback & p_abort) +{ + g_get_interface(p_path)->create_directory(p_path,p_abort); +} + +void filesystem::g_move(const char * src,const char * dst,abort_callback & p_abort) { + for (auto ptr : enumerate()) { + if (ptr->is_our_path(src) && ptr->is_our_path(dst)) { + ptr->move(src, dst, p_abort); + return; + } + } + throw exception_io_no_handler_for_path(); +} + +void filesystem::g_link(const char * p_src,const char * p_dst,abort_callback & p_abort) { + p_abort.check(); + pfc::string8 srcN, dstN; + if (!extract_native_path(p_src, srcN) || !extract_native_path(p_dst, dstN)) throw exception_io_no_handler_for_path(); +#ifdef _WIN32 + WIN32_IO_OP( CreateHardLink( pfc::stringcvt::string_os_from_utf8( dstN ), pfc::stringcvt::string_os_from_utf8( srcN ), NULL) ); +#else + NIX_IO_OP( symlink( srcN, dstN ) == 0 ); +#endif +} + +void filesystem::g_link_timeout(const char * p_src,const char * p_dst,double p_timeout,abort_callback & p_abort) { + FB2K_RETRY_FILE_MOVE( g_link(p_src, p_dst, p_abort), p_abort, p_timeout ); +} + + +void filesystem::g_list_directory(const char * p_path,directory_callback & p_out,abort_callback & p_abort) +{ + TRACK_CALL_TEXT("filesystem::g_list_directory"); + g_get_interface(p_path)->list_directory(p_path,p_out,p_abort); +} + + +static void path_pack_string(pfc::string_base & out,const char * src) +{ + out.add_char('|'); + out << (unsigned) strlen(src); + out.add_char('|'); + out << src; + out.add_char('|'); +} + +static int path_unpack_string(pfc::string_base & out,const char * src) +{ + int ptr=0; + if (src[ptr++]!='|') return -1; + int len = atoi(src+ptr); + if (len<=0) return -1; + while(src[ptr]!=0 && src[ptr]!='|') ptr++; + if (src[ptr]!='|') return -1; + ptr++; + int start = ptr; + while(ptr-start & p_out,const char * p_path,abort_callback & p_abort) { + service_ptr_t fs = g_get_interface(p_path); + if (fs->is_remote(p_path)) throw exception_io_object_is_remote(); + fs->open(p_out,p_path,open_mode_read,p_abort); +} + +bool filesystem::g_is_remote(const char * p_path) { + return g_get_interface(p_path)->is_remote(p_path); +} + +bool filesystem::g_is_recognized_and_remote(const char * p_path) { + service_ptr_t fs; + if (g_get_interface(fs,p_path)) return fs->is_remote(p_path); + else return false; +} + +bool filesystem::g_is_remote_or_unrecognized(const char * p_path) { + service_ptr_t fs; + if (g_get_interface(fs,p_path)) return fs->is_remote(p_path); + else return true; +} + +bool filesystem::g_relative_path_create(const char * file_path,const char * playlist_path,pfc::string_base & out) +{ + + bool rv = false; + service_ptr_t fs; + + if (g_get_interface(fs,file_path)) + rv = fs->relative_path_create(file_path,playlist_path,out); + + return rv; +} + +bool filesystem::g_relative_path_parse(const char * relative_path,const char * playlist_path,pfc::string_base & out) +{ + for (auto ptr : enumerate()) { + if (ptr->relative_path_parse(relative_path, playlist_path, out)) return true; + } + return false; +} + +namespace { + class archive_callback_lambda : public archive_callback { + private: + abort_callback& m_abort; + public: + bool is_aborting() const override { return m_abort.is_aborting(); } + abort_callback_event get_abort_event() const override { return m_abort.get_abort_event(); } + + archive_callback_lambda(abort_callback& a) : m_abort(a) {} + bool on_entry(archive*, const char* url, const t_filestats& p_stats, const service_ptr_t& p_reader) override { + f(url, p_stats, p_reader); + return true; + } + + archive::list_func_t f; + }; +} + +void archive::archive_list(const char * path, file::ptr reader, list_func_t f, bool wantReaders, abort_callback& a ) { + archive_callback_lambda cb(a); + cb.f = f; + this->archive_list(path, reader, cb, wantReaders); +} + +bool archive::is_our_archive( const char * path ) { + archive_v2::ptr v2; + if ( v2 &= this ) return v2->is_our_archive( path ); + return true; // accept all files +} + +void archive_impl::extract_filename_ext(const char * path, pfc::string_base & outFN) { + pfc::string8 dummy, subpath; + if (archive_impl::g_parse_unpack_path(path, dummy, subpath)) { + outFN = pfc::filename_ext_v2( subpath ); + } else { + PFC_ASSERT(!"???"); + filesystem_v3::extract_filename_ext(path, outFN); + } +} + +bool archive_impl::get_display_name_short(const char* in, pfc::string_base& out) { + extract_filename_ext(in ,out); + return true; +} + +bool archive_impl::get_canonical_path(const char * path,pfc::string_base & out) +{ + if (is_our_path(path)) + { + pfc::string8 archive,file,archive_canonical; + if (g_parse_unpack_path(path,archive,file)) + { + g_get_canonical_path(archive,archive_canonical); + make_unpack_path(out,archive_canonical,file); + + return true; + } + else return false; + } + else return false; +} + +bool archive_impl::is_our_path(const char * path) +{ + if (!g_is_unpack_path(path)) return false; + const char * type = get_archive_type(); + path += 9; + while(*type) + { + if (*type!=*path) return false; + type++; + path++; + } + if (*path!='|') return false; + return true; +} + +bool archive_impl::get_display_path(const char * path,pfc::string_base & out) +{ + pfc::string8 archive,file; + if (g_parse_unpack_path(path,archive,file)) + { + g_get_display_path(archive,out); + out.add_string("|"); + out.add_string(file); + return true; + } + else return false; +} + +void archive_impl::open(service_ptr_t & p_out,const char * path,t_open_mode mode, abort_callback & p_abort) +{ + if (mode != open_mode_read) throw exception_io_denied(); + pfc::string8 archive,file; + if (!g_parse_unpack_path(path,archive,file)) throw exception_io_not_found(); + open_archive(p_out,archive,file,p_abort); +} + + +void archive_impl::remove(const char * path,abort_callback & p_abort) { + (void)p_abort; (void)path; + pfc::throw_exception_with_message< exception_io_denied> ("Cannot delete files within archives"); +} + +void archive_impl::move(const char * src,const char * dst,abort_callback & p_abort) { + (void)p_abort; (void)src; (void)dst; + pfc::throw_exception_with_message< exception_io_denied> ("Cannot move files within archives"); +} + +void archive_impl::move_overwrite(const char* src, const char* dst, abort_callback& abort) { + (void)abort; (void)src; (void)dst; + pfc::throw_exception_with_message< exception_io_denied> ("Cannot move files within archives"); +} + +bool archive_impl::is_remote(const char * src) { + pfc::string8 archive,file; + if (g_parse_unpack_path(src,archive,file)) return g_is_remote(archive); + else throw exception_io_not_found(); +} + +bool archive_impl::relative_path_create(const char * file_path,const char * playlist_path,pfc::string_base & out) { + pfc::string8 archive,file; + if (g_parse_unpack_path(file_path,archive,file)) + { + pfc::string8 archive_rel; + if (g_relative_path_create(archive,playlist_path,archive_rel)) + { + pfc::string8 out_path; + make_unpack_path(out_path,archive_rel,file); + out.set_string(out_path); + return true; + } + } + return false; +} + +bool archive_impl::relative_path_parse(const char * relative_path,const char * playlist_path,pfc::string_base & out) +{ + if (!is_our_path(relative_path)) return false; + pfc::string8 archive_rel,file; + if (g_parse_unpack_path(relative_path,archive_rel,file)) + { + pfc::string8 archive; + if (g_relative_path_parse(archive_rel,playlist_path,archive)) + { + pfc::string8 out_path; + make_unpack_path(out_path,archive,file); + out.set_string(out_path); + return true; + } + } + return false; +} + +bool archive_impl::g_parse_unpack_path_ex(const char * path,pfc::string_base & archive,pfc::string_base & file, pfc::string_base & type) { + PFC_ASSERT( g_is_unpack_path(path) ); + const char * base = path + unpack_prefix_len; // strstr(path, "//"); + const char * split = strchr(path,'|'); + if (base == NULL || split == NULL || base > split) return false; + // base += 2; + type.set_string( base, split - base ); + int delta = path_unpack_string(archive,split); + if (delta<0) return false; + split += delta; + file = split; + return true; +} +bool archive_impl::g_parse_unpack_path(const char * path,pfc::string_base & archive,pfc::string_base & file) { + PFC_ASSERT( g_is_unpack_path(path) ); + path = strchr(path,'|'); + if (!path) return false; + int delta = path_unpack_string(archive,path); + if (delta<0) return false; + path += delta; + file = path; + return true; +} + +bool archive_impl::g_is_unpack_path(const char * path) { + return strncmp(path,unpack_prefix,unpack_prefix_len) == 0; +} + +void archive_impl::g_make_unpack_path(pfc::string_base & path,const char * archive,const char * file,const char * name) +{ + path = unpack_prefix; + path += name; + path_pack_string(path,archive); + path += file; +} + +void archive_impl::make_unpack_path(pfc::string_base & path,const char * archive,const char * file) {g_make_unpack_path(path,archive,file,get_archive_type());} + +fb2k::arrayRef archive_impl::archive_list_v4( fsItemFilePtr item, file::ptr readerOptional, abort_callback & a ) { + + const auto baseStats = item->getStatsOpportunist(); + PFC_ASSERT( ! baseStats.is_folder() ); + auto ret = fb2k::arrayMutable::arrayWithCapacity(256); + + auto reader = readerOptional; + if ( reader.is_empty() ) reader = item->openRead(a); + try { + this->archive_list( item->canonicalPath()->c_str(), reader, [&] ( const char * URL, t_filestats const & stats, file::ptr ) { + t_filestats2 stats2 = t_filestats2::from_legacy( stats ); + stats2.set_file(); stats2.set_remote( baseStats.is_remote() ); stats2.set_readonly(true); + archive * blah = this; // multi inheritance fix, more than one path to filesystem which has makeItemFileStd() + ret->add(blah->makeItemFileStd(URL, stats2)); + }, false, a); + } catch( exception_io_data const & ) { + if ( ret->count() == 0 ) throw; + } + return ret->makeConst(); + +} + +namespace { + + class directory_callback_isempty : public directory_callback + { + bool m_isempty; + public: + directory_callback_isempty() : m_isempty(true) {} + bool on_entry(filesystem *,abort_callback &,const char *,bool,const t_filestats &) override + { + m_isempty = false; + return false; + } + bool isempty() {return m_isempty;} + }; + + class directory_callback_dummy : public directory_callback + { + public: + bool on_entry(filesystem *,abort_callback &,const char *,bool,const t_filestats &) override {return false;} + }; + +} + +bool filesystem::g_is_empty_directory(const char * path,abort_callback & p_abort) +{ + directory_callback_isempty callback; + try { + g_list_directory(path,callback,p_abort); + } catch(exception_io const &) {return false;} + return callback.isempty(); +} + +bool filesystem::g_is_valid_directory(const char * path,abort_callback & p_abort) { + if ( path == NULL || path[0] == 0 ) return false; + + return get(path)->directory_exists( path, p_abort ); +} + +bool directory_callback_impl::on_entry(filesystem * owner,abort_callback & p_abort,const char * url,bool is_subdirectory,const t_filestats & p_stats) { + p_abort.check_e(); + if (is_subdirectory) { + if (m_recur) { + try { + owner->list_directory(url,*this,p_abort); + } catch(exception_io const &) {} + } + } else { + m_data.add_item(pfc::rcnew_t(url,p_stats)); + } + return true; +} + +namespace { + class directory_callback_impl_copy : public directory_callback + { + public: + directory_callback_impl_copy(const char * p_target, filesystem::ptr fs) : m_fs(fs) + { + m_target = p_target; + m_target.fix_dir_separator(); + } + + bool on_entry(filesystem * owner,abort_callback & p_abort,const char * url,bool is_subdirectory,const t_filestats & p_stats) override { + (void)p_stats; + const char * fn = url + pfc::scan_filename(url); + t_size truncat = m_target.length(); + m_target += fn; + if (is_subdirectory) { + try { + m_fs->create_directory(m_target,p_abort); + } catch(exception_io_already_exists const &) {} + m_target.end_with_slash(); + owner->list_directory(url,*this,p_abort); + } else { + _copy(url, m_target, owner, p_abort); + } + m_target.truncate(truncat); + return true; + } + void _copy(const char * src, const char * dst, filesystem * srcFS, abort_callback & p_abort) { + service_ptr_t r_src,r_dst; + t_filesize size; + + srcFS->open(r_src,src,filesystem::open_mode_read,p_abort); + size = r_src->get_size_ex(p_abort); + m_fs->open(r_dst,dst,filesystem::open_mode_write_new,p_abort); + + if (size > 0) { + try { + file::g_transfer_object(r_src,r_dst,size,p_abort); + file::g_copy_timestamps(r_src, r_dst, p_abort); + } catch(...) { + r_dst.release(); + try {m_fs->remove(dst,fb2k::noAbort);} catch(...) {} + throw; + } + } + } + private: + pfc::string8_fastalloc m_target; + filesystem::ptr m_fs; + }; +} + +file::ptr filesystem::openEx(const char * path, filesystem::t_open_mode mode, abort_callback & abort, double timeout) { + file::ptr f; + retryOnSharingViolation([&] { + this->open(f, path, mode, abort); + }, timeout, abort); + return f; +} + +file::ptr filesystem::openRead(const char * path, abort_callback & abort, double timeout) { + return this->openEx(path, open_mode_read, abort, timeout); +} + +file::ptr filesystem::openWriteExisting(const char * path, abort_callback & abort, double timeout) { + return this->openEx(path, open_mode_write_existing, abort, timeout); +} + +file::ptr filesystem::openWriteNew(const char * path, abort_callback & abort, double timeout) { + return this->openEx( path, open_mode_write_new, abort, timeout ); +} + +void filesystem::remove_(const char* path, abort_callback& a, double timeout) { + retryOnSharingViolation(timeout, a, [&] { + this->remove(path, a); + }); +} + +void filesystem::copy_directory_contents(const char* p_src, const char* p_dst, abort_callback& p_abort) { + directory_callback_impl_copy cb(p_dst, this); + list_directory(p_src, cb, p_abort); +} + +void filesystem::copy_directory(const char * src, const char * dst, abort_callback & p_abort) { + try { + this->create_directory( dst, p_abort ); + } catch(exception_io_already_exists const &) {} + this->copy_directory_contents(src, dst, p_abort); +} + +void filesystem::g_copy_directory(const char * src,const char * dst,abort_callback & p_abort) { + filesystem::ptr dstFS = filesystem::g_get_interface(dst); + try { + dstFS->create_directory( dst, p_abort ); + } catch(exception_io_already_exists const &) {} + directory_callback_impl_copy cb(dst, dstFS); + g_list_directory(src,cb,p_abort); +} + +void filesystem::g_copy(const char * src,const char * dst,abort_callback & p_abort) { + service_ptr_t r_src,r_dst; + t_filesize size; + + g_open(r_src,src,open_mode_read,p_abort); + size = r_src->get_size_ex(p_abort); + g_open(r_dst,dst,open_mode_write_new,p_abort); + + if (size > 0) { + try { + file::g_transfer_object(r_src,r_dst,size,p_abort); + } catch(...) { + r_dst.release(); + try {g_remove(dst,fb2k::noAbort);} catch(...) {} + throw; + } + } + + try { + file::g_copy_timestamps(r_src, r_dst, p_abort); + } catch (exception_io const &) {} +} + +void stream_reader::read_object(void * p_buffer,t_size p_bytes,abort_callback & p_abort) { + if (read(p_buffer,p_bytes,p_abort) != p_bytes) throw exception_io_data_truncation(); +} + +t_filestats file::get_stats(abort_callback & p_abort) +{ + t_filestats temp; + temp.m_size = get_size(p_abort); + temp.m_timestamp = get_timestamp(p_abort); + return temp; +} + +t_filesize stream_reader::skip(t_filesize p_bytes,abort_callback & p_abort) +{ + t_uint8 temp[256]; + t_filesize todo = p_bytes, done = 0; + while(todo > 0) { + t_size delta,deltadone; + delta = sizeof(temp); + if (delta > todo) delta = (t_size) todo; + deltadone = read(temp,delta,p_abort); + done += deltadone; + todo -= deltadone; + if (deltadone < delta) break; + } + return done; +} + +void stream_reader::skip_object(t_filesize p_bytes,abort_callback & p_abort) { + if (skip(p_bytes,p_abort) != p_bytes) throw exception_io_data_truncation(); +} + +void filesystem::g_open_write_new(service_ptr_t & p_out,const char * p_path,abort_callback & p_abort) { + g_open(p_out,p_path,open_mode_write_new,p_abort); +} +void file::g_transfer_file(const service_ptr_t & p_from,const service_ptr_t & p_to,abort_callback & p_abort) { + t_filesize length = p_from->get_size(p_abort); + p_from->reopen( p_abort ); +// p_from->seek(0,p_abort); + p_to->seek(0,p_abort); + p_to->set_eof(p_abort); + if (length == filesize_invalid) { + g_transfer(p_from, p_to, filesize_invalid, p_abort); + } else if (length > 0) { + g_transfer_object(p_from,p_to,length,p_abort); + } +} + +void filesystem::g_open_temp(service_ptr_t & p_out,abort_callback & p_abort) { + g_open(p_out,"tempfile://",open_mode_write_new,p_abort); +} + +void filesystem::g_open_tempmem(service_ptr_t & p_out,abort_callback & p_abort) { + g_open(p_out,"tempmem://",open_mode_write_new,p_abort); +} + +file::ptr filesystem::g_open_tempmem() { + file::ptr f; g_open_tempmem(f, fb2k::noAbort); return f; +} + +void archive_impl::list_directory(const char * p_path,directory_callback & p_out,abort_callback & p_abort) { + (void)p_path; (void)p_out; (void)p_abort; + throw exception_io_not_found(); +} + +void archive_impl::list_directory_ex(const char* p_path, directory_callback& p_out, unsigned listMode, abort_callback& p_abort) { + (void)p_path; (void)p_out; (void)listMode; (void)p_abort; + throw exception_io_not_found(); +} + +void archive_impl::list_directory_v3(const char* path, directory_callback_v3& callback, unsigned listMode, abort_callback& p_abort) { + (void)path; (void)callback; (void)listMode; (void)p_abort; + throw exception_io_not_found(); +} + +void archive_impl::create_directory(const char *,abort_callback &) { + throw exception_io_denied(); +} + +void archive_impl::make_directory(const char*, abort_callback&, bool*) { + throw exception_io_denied(); +} + +void filesystem::g_get_stats(const char * p_path,t_filestats & p_stats,bool & p_is_writeable,abort_callback & p_abort) { + TRACK_CALL_TEXT("filesystem::g_get_stats"); + return g_get_interface(p_path)->get_stats(p_path,p_stats,p_is_writeable,p_abort); +} + +// Due to multi inheritance from archive and filesystem_v3, filesystem_v3's get_stats() isn't overriding archive's method. Fix that here. +void archive_impl::get_stats(const char* p_path, t_filestats& p_stats, bool& p_is_writeable, abort_callback& p_abort) { + filesystem_v3::get_stats(p_path, p_stats, p_is_writeable, p_abort); +} + +t_filestats2 archive_impl::get_stats2(const char * p_path,unsigned s2flags,abort_callback & p_abort) { + pfc::string8 archive,file; + if (g_parse_unpack_path(p_path,archive,file)) { + if (g_is_remote(archive)) throw exception_io_object_is_remote(); + t_filestats2 ret = get_stats2_in_archive(archive,file,s2flags,p_abort); + ret.set_readonly(true); + ret.set_folder(false); + ret.set_remote(false); + return ret; + } + else throw exception_io_not_found(); +} + + +bool file::is_eof(abort_callback & p_abort) { + t_filesize position,size; + position = get_position(p_abort); + size = get_size(p_abort); + if (size == filesize_invalid) return false; + return position >= size; +} + +t_filetimestamp foobar2000_io::filetimestamp_from_system_timer() +{ + return pfc::fileTimeNow(); +} + +void stream_reader::read_string_ex(pfc::string_base & p_out,t_size p_bytes,abort_callback & p_abort) { + const t_size expBase = 64*1024; + if (p_bytes > expBase) { + pfc::array_t temp; + t_size allocWalk = expBase; + t_size done = 0; + for(;;) { + const t_size target = pfc::min_t(allocWalk, p_bytes); + temp.set_size(target); + read_object(temp.get_ptr() + done, target - done, p_abort); + if (target == p_bytes) break; + done = target; + allocWalk <<= 1; + } + p_out.set_string(temp.get_ptr(), p_bytes); + } else { + pfc::string_buffer buf(p_out, p_bytes); + read_object(buf.get_ptr(),p_bytes,p_abort); + } +} +void stream_reader::read_string(pfc::string_base & p_out,abort_callback & p_abort) +{ + t_uint32 length; + read_lendian_t(length,p_abort); + read_string_ex(p_out,length,p_abort); +} + +void stream_reader::read_string_raw(pfc::string_base & p_out,abort_callback & p_abort, size_t sanity) { + enum {delta = 1024}; + char buffer[delta]; + p_out.reset(); + size_t didRead = 0; + for(;;) { + auto delta_done = read(buffer,delta,p_abort); + p_out.add_string(buffer,delta_done); + if (delta_done < delta) break; + didRead += delta; + if (didRead > sanity) throw exception_io_data(); + } +} + +void stream_writer::write_string(const char * p_string,t_size p_len,abort_callback & p_abort) { + t_uint32 len = pfc::downcast_guarded(pfc::strlen_max(p_string,p_len)); + write_lendian_t(len,p_abort); + write_object(p_string,len,p_abort); +} + +void stream_writer::write_string(const char * p_string,abort_callback & p_abort) { + write_string(p_string,SIZE_MAX,p_abort); +} + +void stream_writer::write_string_raw(const char * p_string,abort_callback & p_abort) { + write_object(p_string,strlen(p_string),p_abort); +} + +void file::truncate(t_uint64 p_position,abort_callback & p_abort) { + if (p_position < get_size(p_abort)) resize(p_position,p_abort); +} + + +#ifdef _WIN32 +namespace { + //rare/weird win32 errors that didn't make it to the main API + PFC_DECLARE_EXCEPTION(exception_io_device_not_ready, exception_io,"Device not ready"); + PFC_DECLARE_EXCEPTION(exception_io_invalid_drive, exception_io_not_found,"Drive not found"); + PFC_DECLARE_EXCEPTION(exception_io_win32, exception_io,"Generic win32 I/O error"); + PFC_DECLARE_EXCEPTION(exception_io_buffer_overflow, exception_io,"The file name is too long"); + PFC_DECLARE_EXCEPTION(exception_io_invalid_path_syntax, exception_io,"Invalid path syntax"); + + class exception_io_win32_ex : public exception_io_win32 { + public: + static pfc::string8 format(DWORD code) { + pfc::string8 ret; + ret << "I/O error (win32 "; + if (code & 0x80000000) { + ret << "0x" << pfc::format_hex(code, 8); + } else { + ret << "#" << (uint32_t)code; + } + ret << ")"; + return ret; + } + exception_io_win32_ex(DWORD p_code) : m_msg(format(p_code)) {} + exception_io_win32_ex(const exception_io_win32_ex & p_other) {*this = p_other;} + const char * what() const throw() {return m_msg;} + private: + pfc::string8 m_msg; + }; +} + +PFC_NORETURN void foobar2000_io::win32_file_write_failure(DWORD p_code, const char * path) { + if (p_code == ERROR_ACCESS_DENIED) { + const DWORD attr = uGetFileAttributes(path); + if (attr != ~0 && (attr & FILE_ATTRIBUTE_READONLY) != 0) throw exception_io_denied_readonly(); + } + exception_io_from_win32(p_code); +} + +PFC_NORETURN void foobar2000_io::exception_io_from_win32(DWORD p_code) { +#if PFC_DEBUG + PFC_DEBUGLOG << "exception_io_from_win32: " << p_code; +#endif + //pfc::string_fixed_t<32> debugMsg; debugMsg << "Win32 I/O error #" << (t_uint32)p_code; + //TRACK_CALL_TEXT(debugMsg); + switch(p_code) { + case ERROR_ALREADY_EXISTS: + case ERROR_FILE_EXISTS: + throw exception_io_already_exists(); + case ERROR_NETWORK_ACCESS_DENIED: + case ERROR_ACCESS_DENIED: + throw exception_io_denied(); + case ERROR_WRITE_PROTECT: + throw exception_io_write_protected(); + case ERROR_BUSY: + case ERROR_PATH_BUSY: + case ERROR_SHARING_VIOLATION: + case ERROR_LOCK_VIOLATION: + throw exception_io_sharing_violation(); + case ERROR_HANDLE_DISK_FULL: + case ERROR_DISK_FULL: + throw exception_io_device_full(); + case ERROR_FILE_NOT_FOUND: + case ERROR_PATH_NOT_FOUND: + throw exception_io_not_found(); + case ERROR_BROKEN_PIPE: + case ERROR_NO_DATA: + throw exception_io_no_data(); + case ERROR_NETWORK_UNREACHABLE: + case ERROR_NETNAME_DELETED: + throw exception_io_network_not_reachable(); + case ERROR_NOT_READY: + throw exception_io_device_not_ready(); + case ERROR_NO_SUCH_DEVICE: + case ERROR_INVALID_DRIVE: + throw exception_io_invalid_drive(); + case ERROR_CRC: + case ERROR_FILE_CORRUPT: + case ERROR_DISK_CORRUPT: + throw exception_io_file_corrupted(); + case ERROR_BUFFER_OVERFLOW: + throw exception_io_buffer_overflow(); + case ERROR_DISK_CHANGE: + throw exception_io_disk_change(); + case ERROR_DIR_NOT_EMPTY: + throw exception_io_directory_not_empty(); + case ERROR_INVALID_NAME: + throw exception_io_invalid_path_syntax(); + case ERROR_NO_SYSTEM_RESOURCES: + case ERROR_NONPAGED_SYSTEM_RESOURCES: + case ERROR_PAGED_SYSTEM_RESOURCES: + case ERROR_WORKING_SET_QUOTA: + case ERROR_PAGEFILE_QUOTA: + case ERROR_COMMITMENT_LIMIT: + throw exception_io("Insufficient system resources"); + case ERROR_IO_DEVICE: + throw exception_io("Device error"); + case ERROR_BAD_NETPATH: + // known to be inflicted by momentary net connectivity issues - NOT the same as exception_io_not_found + throw exception_io_network_not_reachable("Network path not found"); +#if FB2K_SUPPORT_TRANSACTED_FILESYSTEM + case ERROR_TRANSACTIONAL_OPEN_NOT_ALLOWED: + case ERROR_TRANSACTIONS_UNSUPPORTED_REMOTE: + case ERROR_RM_NOT_ACTIVE: + case ERROR_RM_METADATA_CORRUPT: + case ERROR_DIRECTORY_NOT_RM: + throw exception_io_transactions_unsupported(); + case ERROR_TRANSACTIONAL_CONFLICT: + throw exception_io_transactional_conflict(); + case ERROR_TRANSACTION_ALREADY_ABORTED: + throw exception_io_transaction_aborted(); + case ERROR_EFS_NOT_ALLOWED_IN_TRANSACTION: + throw exception_io("Transacted updates of encrypted content are not supported"); +#endif // FB2K_SUPPORT_TRANSACTED_FILESYSTEM + case ERROR_UNEXP_NET_ERR: + // QNAP threw this when messing with very long file paths and concurrent conversion, probably SMB daemon crashed + throw exception_io_network_not_reachable("Unexpected network error"); + case ERROR_NOT_SAME_DEVICE: + throw exception_io("Source and destination must be on the same device"); + case 0x80310000: + throw exception_io("Drive locked by BitLocker"); + case ERROR_INVALID_FUNCTION: + // Happens when trying to link files on FAT32 etc + throw exception_io_unsupported_feature(); +#if 0 + case ERROR_BAD_LENGTH: + FB2K_BugCheckEx("ERROR_BAD_LENGTH"); +#endif + default: + throw exception_io_win32_ex(p_code); + } +} +#else +PFC_NORETURN void foobar2000_io::exception_io_from_nix(int code) { + switch(code) { + case EPERM: + case EACCES: + throw exception_io_denied(); + case ENOENT: + case ENODEV: + throw exception_io_not_found(); + case EIO: + pfc::throw_exception_with_message("Generic I/O error (EIO)"); + case EBUSY: + throw exception_io_sharing_violation(); + case EEXIST: + throw exception_io_already_exists(); + case ENOSPC: + throw exception_io_device_full(); + case EROFS: + throw exception_io_denied_readonly(); + case ENOTEMPTY: + throw exception_io_directory_not_empty(); + case ESPIPE: + // Should not actually get here + PFC_ASSERT(!"Trying to seek a nonseekable stream"); + throw exception_io_object_not_seekable(); + case ENOTDIR: + throw exception_io_not_directory(); + case ENAMETOOLONG: + pfc::throw_exception_with_message("Name too long"); + default: + pfc::throw_exception_with_message< exception_io>( PFC_string_formatter() << "Unknown I/O error (#" << code << ")"); + } +} +void nix_pre_io_op() { + errno = 0; +} +PFC_NORETURN void foobar2000_io::nix_io_op_fail() { + exception_io_from_nix( errno ); +} +#endif + +t_filesize file::get_size_ex(abort_callback & p_abort) { + t_filesize temp = get_size(p_abort); + if (temp == filesize_invalid) throw exception_io_no_length(); + return temp; +} + +void file::ensure_local() { + if (is_remote()) throw exception_io_object_is_remote(); +} + +void file::ensure_seekable() { + if (!can_seek()) throw exception_io_object_not_seekable(); +} + +bool filesystem::g_is_recognized_path(const char * p_path) { + filesystem::ptr obj; + return g_get_interface(obj,p_path); +} + +t_filesize file::get_remaining(abort_callback & p_abort) { + t_filesize length = get_size_ex(p_abort); + t_filesize position = get_position(p_abort); + pfc::dynamic_assert(position <= length); + return length - position; +} + +bool file::probe_remaining_ex(t_filesize bytes, abort_callback& p_abort) { + t_filesize length = get_size(p_abort); + if (length != filesize_invalid) { + t_filesize remaining = length - get_position(p_abort); + if (remaining < bytes) return false; + } + return true; +} + +void file::probe_remaining(t_filesize bytes, abort_callback & p_abort) { + if (!probe_remaining_ex(bytes, p_abort)) throw exception_io_data_truncation(); +} + +t_filesize file::g_transfer(service_ptr_t p_src,service_ptr_t p_dst,t_filesize p_bytes,abort_callback & p_abort) { + return g_transfer(pfc::implicit_cast(p_src.get_ptr()),pfc::implicit_cast(p_dst.get_ptr()),p_bytes,p_abort); +} + +void file::g_transfer_object(service_ptr_t p_src,service_ptr_t p_dst,t_filesize p_bytes,abort_callback & p_abort) { + if (p_bytes > 1024) /* don't bother on small objects */ + { + t_filesize srcFileSize = p_src->get_size(p_abort); // detect truncation + if (srcFileSize != ~0) { + t_filesize remaining = srcFileSize - p_src->get_position(p_abort); + if (p_bytes > remaining) throw exception_io_data_truncation(); + } + + t_filesize oldsize = p_dst->get_size(p_abort); // pre-resize the target file + if (oldsize != filesize_invalid) { + t_filesize newpos = p_dst->get_position(p_abort) + p_bytes; + if (newpos > oldsize) p_dst->resize(newpos ,p_abort); + } + + } + g_transfer_object(pfc::implicit_cast(p_src.get_ptr()),pfc::implicit_cast(p_dst.get_ptr()),p_bytes,p_abort); +} + + +void foobar2000_io::generate_temp_location_for_file(pfc::string_base & p_out, const char * p_origpath,const char * p_extension,const char * p_magic) { + hasher_md5_result hash; + { + auto hasher = hasher_md5::get(); + hasher_md5_state state; + hasher->initialize(state); + hasher->process(state,p_origpath,strlen(p_origpath)); + hasher->process(state,p_extension,strlen(p_extension)); + hasher->process(state,p_magic,strlen(p_magic)); + hash = hasher->get_result(state); + } + + p_out = p_origpath; + p_out.truncate(p_out.scan_filename()); + p_out += "temp-"; + p_out += pfc::format_hexdump(hash.m_data,sizeof(hash.m_data),""); + p_out += "."; + p_out += p_extension; +} + +t_filesize file::skip_seek(t_filesize p_bytes,abort_callback & p_abort) { + const t_filesize size = get_size(p_abort); + if (size != filesize_invalid) { + const t_filesize position = get_position(p_abort); + const t_filesize toskip = pfc::min_t( p_bytes, size - position ); + seek(position + toskip,p_abort); + return toskip; + } else { + this->seek_ex( p_bytes, seek_from_current, p_abort ); + return p_bytes; + } +} + +t_filesize file::skip(t_filesize p_bytes,abort_callback & p_abort) { + if (p_bytes > 1024 && can_seek()) { + const t_filesize size = get_size(p_abort); + if (size != filesize_invalid) { + const t_filesize position = get_position(p_abort); + const t_filesize toskip = pfc::min_t( p_bytes, size - position ); + seek(position + toskip,p_abort); + return toskip; + } + } + return stream_reader::skip(p_bytes,p_abort); +} + +bool foobar2000_io::is_native_filesystem( const char * p_fspath ) { + return _extract_native_path_ptr( p_fspath ); +} + +bool foobar2000_io::_extract_native_path_ptr(const char * & p_fspath) { + static const char header[] = "file://"; static const t_size headerLen = 7; + if (strncmp(p_fspath,header,headerLen) != 0) return false; + p_fspath += headerLen; + return true; +} +bool foobar2000_io::extract_native_path(const char * p_fspath,pfc::string_base & p_native) { + if (strstr(p_fspath, "://") != nullptr) { + if (!_extract_native_path_ptr(p_fspath)) return false; + } + p_native = p_fspath; +#ifndef _WIN32 + expandHomeDir( p_native ); +#endif + return true; +} + +bool foobar2000_io::extract_native_path_ex(const char * p_fspath, pfc::string_base & p_native) { + if (!_extract_native_path_ptr(p_fspath)) return false; + if (p_fspath[0] != '\\' || p_fspath[1] != '\\') { + p_native = "\\\\?\\"; + p_native += p_fspath; + } else { + p_native = p_fspath; + } + return true; +} + +static bool extract_native_path_fsv3(const char* in, pfc::string_base& out, abort_callback& a) { + if (foobar2000_io::extract_native_path(in, out)) return true; + filesystem_v3::ptr v3; + if (v3 &= filesystem::tryGet(in)) { + auto n = v3->getNativePath(in, a); + if ( n.is_valid() ) { + out = n->c_str(); return true; + } + } + return false; +} + +bool foobar2000_io::extract_native_path_archive_aware_ex(const char* in, pfc::string_base& out, abort_callback& a) { + if (extract_native_path_fsv3(in, out, a)) return true; + + if (archive_impl::g_is_unpack_path(in)) { + pfc::string8 arc, dummy; + if (archive_impl::g_parse_unpack_path(in, arc, dummy)) { + return extract_native_path_fsv3(arc, out, a); + } + } + return false; +} + +bool foobar2000_io::extract_native_path_archive_aware(const char * in, pfc::string_base & out) { + if (foobar2000_io::extract_native_path(in, out)) return true; + if (archive_impl::g_is_unpack_path(in)) { + pfc::string8 arc, dummy; + if (archive_impl::g_parse_unpack_path(in, arc, dummy)) { + return foobar2000_io::extract_native_path(arc, out); + } + } + return false; +} + +pfc::string stream_reader::read_string(abort_callback & p_abort) { + t_uint32 len; + read_lendian_t(len,p_abort); + return read_string_ex(len,p_abort); +} +pfc::string stream_reader::read_string_ex(t_size p_len,abort_callback & p_abort) { + pfc::string temp; + this->read_string_ex(temp, p_len, p_abort); + return temp; +} + + +void filesystem::remove_directory_content(const char * path, abort_callback & abort) { + class myCallback : public directory_callback { + public: + bool on_entry(filesystem * p_owner,abort_callback & p_abort,const char * p_url,bool p_is_subdirectory,const t_filestats &) { + if (p_is_subdirectory) p_owner->list_directory(p_url, *this, p_abort); + try { + p_owner->remove(p_url, p_abort); + } catch(exception_io_not_found const &) {} + return true; + } + }; + myCallback cb; + list_directory(path, cb, abort); +} +void filesystem::remove_object_recur(const char * path, abort_callback & abort) { + filesystem_v3::ptr v3; + if (v3 &= this) { + // the new way + // fsItemFolder may implement removeRecur() more efficiently + auto item = v3->findItem(path, abort); + fsItemFolderPtr folder; + if (folder &= item) folder->removeRecur(abort); + else item->remove(abort); + return; + } + + // the classic way + try { + remove_directory_content(path, abort); + } catch(exception_io_not_found const &) {} + remove(path, abort); + +} + +void filesystem::g_remove_object_recur_timeout(const char * path, double timeout, abort_callback & abort) { + FB2K_RETRY_FILE_MOVE( g_remove_object_recur(path, abort), abort, timeout ); +} + +void filesystem::g_remove_object_recur(const char * path, abort_callback & abort) { + g_get_interface(path)->remove_object_recur(path, abort); +} + +void foobar2000_io::purgeOldFiles(const char * directory, t_filetimestamp period, abort_callback & abort) { + + class myCallback : public directory_callback { + public: + myCallback(t_filetimestamp period) : m_base(filetimestamp_from_system_timer() - period) {} + bool on_entry(filesystem *,abort_callback & p_abort,const char * p_url,bool p_is_subdirectory,const t_filestats & p_stats) { + if (!p_is_subdirectory && p_stats.m_timestamp < m_base) { + try { + filesystem::g_remove_timeout(p_url, 1, p_abort); + } catch(exception_io_not_found const &) {} + } + return true; + } + private: + const t_filetimestamp m_base; + }; + + myCallback cb(period); + filesystem::g_list_directory(directory, cb, abort); +} + +void stream_reader::read_string_nullterm( pfc::string_base & out, abort_callback & abort ) { + enum { bufCount = 256 }; + char buffer[bufCount]; + out.reset(); + size_t w = 0; + for(;;) { + char & c = buffer[w]; + this->read_object( &c, 1, abort ); + if (c == 0) { + out.add_string( buffer, w ); break; + } + if (++w == bufCount ) { + out.add_string( buffer, bufCount ); w = 0; + } + } +} + +t_filesize stream_reader::skip_till_eof(abort_callback & abort) { + t_filesize atOnce = 1024 * 1024; + t_filesize done = 0; + for (;; ) { + abort.check(); + t_filesize did = this->skip(atOnce, abort); + done += did; + if (did != atOnce) break; + } + return done; +} + +uint8_t stream_reader::read_byte( abort_callback & abort ) { + uint8_t b; + read_object(&b, 1, abort ); + return b; +} + +bool foobar2000_io::matchContentType(const char * fullString, const char * ourType) { + t_size lim = pfc::string_find_first(fullString, ';'); + if (lim != ~0) { + while(lim > 0 && fullString[lim-1] == ' ') --lim; + } + return pfc::stricmp_ascii_ex(fullString,lim, ourType, SIZE_MAX) == 0; +} + +const char * foobar2000_io::contentTypeFromExtension( const char * ext ) { + if ( pfc::stringEqualsI_ascii( ext, "mp3" ) ) return "audio/mpeg"; + if ( pfc::stringEqualsI_ascii( ext, "flac" ) ) return "audio/flac"; + if ( pfc::stringEqualsI_ascii( ext, "mp4" ) ) return "application/mp4"; // We don't know if it's audio-only or other. + if ( pfc::stringEqualsI_ascii( ext, "m4a" ) ) return "audio/mp4"; + if ( pfc::stringEqualsI_ascii( ext, "mpc" ) ) return "audio/musepack"; + if ( pfc::stringEqualsI_ascii( ext, "ogg" ) ) return "audio/ogg"; + if ( pfc::stringEqualsI_ascii( ext, "opus" ) ) return "audio/opus"; + if ( pfc::stringEqualsI_ascii( ext, "wav" ) ) return "audio/vnd.wave"; + if ( pfc::stringEqualsI_ascii( ext, "wv" ) ) return "audio/wavpack"; + if ( pfc::stringEqualsI_ascii( ext, "txt" ) || pfc::stringEqualsI_ascii( ext, "cue" ) || pfc::stringEqualsI_ascii( ext, "log" ) ) return "text/plain"; + return "application/binary"; +} + +const char * foobar2000_io::extensionFromContentType( const char * contentType ) { + if (matchContentType_MP3( contentType )) return "mp3"; + if (matchContentType_FLAC( contentType )) return "flac"; + if (matchContentType_MP4audio( contentType)) return "m4a"; + if (matchContentType_MP4( contentType)) return "mp4"; + if (matchContentType_Musepack( contentType )) return "mpc"; + if (matchContentType_Ogg( contentType )) return "ogg"; + if (matchContentType_Opus( contentType )) return "opus"; + if (matchContentType_WAV( contentType )) return "wav"; + if (matchContentType_WavPack( contentType )) return "wv"; + if (matchContentType(contentType, "image/jpeg")) return "jpg"; + if (matchContentType(contentType, "image/png")) return "png"; + return ""; +} + +bool foobar2000_io::matchContentType_MP3( const char * type) { + return matchContentType(type,"audio/mp3") || matchContentType(type,"audio/mpeg") || matchContentType(type,"audio/mpg") || matchContentType(type,"audio/x-mp3") || matchContentType(type,"audio/x-mpeg") || matchContentType(type,"audio/x-mpg"); +} +bool foobar2000_io::matchContentType_MP4( const char * type ) { + return matchContentType_MP4audio(type) + || matchContentType(type, "video/mp4") || matchContentType(type, "video/x-mp4") + || matchContentType(type, "application/mp4") || matchContentType(type, "application/x-mp4"); + +} +bool foobar2000_io::matchContentType_MP4audio( const char * type ) { + // Gerbera uses audio/x-m4a instead of audio/mp4 .... + return matchContentType(type, "audio/mp4") || matchContentType(type, "audio/x-mp4") || + matchContentType(type, "audio/m4a") || matchContentType(type, "audio/x-m4a"); +} +bool foobar2000_io::matchContentType_Ogg( const char * type) { + return matchContentType(type, "application/ogg") || matchContentType(type, "application/x-ogg") || matchContentType(type, "audio/ogg") || matchContentType(type, "audio/x-ogg"); +} +bool foobar2000_io::matchContentType_Opus( const char * type) { + return matchContentType(type, "audio/opus") || matchContentType(type, "audio/x-opus"); +} +bool foobar2000_io::matchContentType_WAV( const char * type ) { + return matchContentType(type, "audio/vnd.wave" ) || matchContentType(type, "audio/wav") || matchContentType(type, "audio/wave") || matchContentType(type, "audio/x-wav") || matchContentType(type, "audio/x-wave"); +} +bool foobar2000_io::matchContentType_FLAC( const char * type) { + return matchContentType(type, "audio/flac") || matchContentType(type, "audio/x-flac") || matchContentType(type, "application/flac") || matchContentType(type, "application/x-flac"); +} +bool foobar2000_io::matchContentType_WavPack( const char * type) { + return matchContentType( type, "audio/wavpack" ) || matchContentType( type, "audio/x-wavpack"); +} +bool foobar2000_io::matchContentType_Musepack( const char * type) { + return matchContentType(type,"audio/musepack") || matchContentType(type,"audio/x-musepack"); +} + +pfc::string8 foobar2000_io::getProtocol(const char* fullString) { + const char* s = strstr(fullString, "://"); + if (s == nullptr) throw exception_io_no_handler_for_path(); + pfc::string8 ret; + ret.set_string_nc(fullString, s - fullString); + return ret; +} +const char * foobar2000_io::afterProtocol( const char * fullString ) { + const char * s = strstr( fullString, "://" ); + if ( s != nullptr ) return s + 3; + s = strchr(fullString, ':' ); + if ( s != nullptr && s[1] != '\\' && s[1] != 0 ) return s + 1; + PFC_ASSERT(!"Should not get here"); + return fullString; +} + +bool foobar2000_io::testIfHasProtocol( const char * input ) { + // Take arbitrary untrusted string, return whether looks like foo:// + if ( pfc::char_is_ascii_alpha(input[0])) { + const char * walk = input+1; + while(pfc::char_is_ascii_alpha(*walk)) ++ walk; + if ( walk[0] == ':' && walk[1] == '/' && walk[2] == '/') return true; + } + return false; +} + +bool foobar2000_io::matchProtocol(const char * fullString, const char * protocolName) { + const t_size len = strlen(protocolName); + if (!pfc::stringEqualsI_ascii_ex(fullString, len, protocolName, len)) return false; + return fullString[len] == ':' && fullString[len+1] == '/' && fullString[len+2] == '/'; +} +void foobar2000_io::substituteProtocol(pfc::string_base & out, const char * fullString, const char * protocolName) { + const char * base = strstr(fullString, "://"); + if (base) { + out = protocolName; out << base; + } else { + PFC_ASSERT(!"Should not get here"); + out = fullString; + } +} + +void filesystem::move_overwrite(const char * src, const char * dst, abort_callback & abort) { + { + filesystem_v2::ptr v2; + if (v2 &= this) { + v2->move_overwrite(src, dst, abort); return; + } + } + try { + this->remove(dst, abort); + } catch (exception_io_not_found const &) {} + this->move(src, dst, abort); +} + +void filesystem::replace_file(const char * src, const char * dst, abort_callback & abort) { + filesystem_v2::ptr v2; + if ( v2 &= this ) { + v2->replace_file( src, dst, abort ); return; + } + move_overwrite( src, dst, abort ); +} + +void filesystem::make_directory(const char * path, abort_callback & abort, bool * didCreate) { + filesystem_v2::ptr v2; + if ( v2 &= this ) { + v2->make_directory( path, abort, didCreate ); + return; + } + bool rv = false; + try { + create_directory( path, abort ); + rv = true; + } catch(exception_io_already_exists const &) { + } + if (didCreate != nullptr) * didCreate = rv; +} + +bool filesystem::make_directory_check(const char * path, abort_callback & abort) { + bool rv = false; + make_directory(path, abort, &rv); + return rv; +} + +bool filesystem::directory_exists(const char * path, abort_callback & abort) { + filesystem_v2::ptr v2; + if ( v2 &= this ) { + return v2->directory_exists( path, abort ); + } + try { + directory_callback_dummy cb; + list_directory(path, cb, abort); + return true; + } catch (exception_io const &) { return false; } +} + +bool filesystem::exists(const char* path, abort_callback& a) { + // for rare cases of code test if EITHER FILE OR FOLDER exists at path + filesystem_v3::ptr v3; + if (v3 &= this) { + try { + v3->get_stats2(path, stats2_fileOrFolder, a); + return true; + } catch (exception_io_not_found const &) { return false; } + } + filesystem_v2::ptr v2; + if (v2 &= this) { + return v2->file_exists(path, a) || v2->directory_exists(path, a); + } + + try { + t_filestats stats; bool writable; + get_stats(path, stats, writable, a); + return true; + } catch (exception_io const &) { } + try { + directory_callback_dummy cb; + list_directory(path, cb, a); + return true; + } catch (exception_io const &) { } + return false; +} + +bool filesystem::file_exists(const char * path, abort_callback & abort) { + filesystem_v2::ptr v2; + if ( v2 &= this ) { + return v2->file_exists( path, abort ); + } + try { + t_filestats stats; bool writable; + get_stats(path, stats, writable, abort ); + return true; + } catch(exception_io const &) { return false; } +} + +char filesystem::pathSeparator() { + filesystem_v2::ptr v2; + if ( v2 &= this ) return v2->pathSeparator(); + return '/'; +} + +pfc::string8 filesystem::extract_filename_ext(const char* path) { + pfc::string8 ret; this->extract_filename_ext(path, ret); return ret; +} +pfc::string8 filesystem::get_extension(const char* path) { + return pfc::string_extension(this->extract_filename_ext(path)); +} +pfc::string8 filesystem::g_get_extension(const char* path) { + auto fs = tryGet(path); + if (fs.is_valid()) return fs->get_extension(path); + return pfc::string_extension(path); +} +void filesystem::extract_filename_ext(const char * path, pfc::string_base & outFN) { + filesystem_v2::ptr v2; + if ( v2 &= this ) { + v2->extract_filename_ext( path, outFN ); + return; + } + outFN = pfc::filename_ext_v2( path ); +} + +bool filesystem::get_parent_helper( const char * path, char separator, pfc::string_base & out ) { + auto proto = path; + path = afterProtocol(path); + + auto sep_ptr = strrchr( path, separator ); + if ( sep_ptr == path ) return false; + if ( sep_ptr >= path + 1 && sep_ptr[-1] == separator ) return false; + + out.set_string(proto, path - proto); + out.add_string(path, sep_ptr - path); + return true; +} + +fb2k::stringRef filesystem::parentPath(const char* path) { + pfc::string8 temp; + if (!get_parent_path(path, temp)) return nullptr; + return fb2k::makeString(temp); +} + +bool filesystem::get_parent_path(const char * path, pfc::string_base & out) { + filesystem_v2::ptr v2; + if ( v2 &= this ) { + return v2->get_parent_path(path, out); + } + return get_parent_helper( path, '/', out ); +} + +void filesystem::read_whole_file(const char * path, mem_block_container & out, pfc::string_base & outContentType, size_t maxBytes, abort_callback & abort) { + filesystem_v2::ptr v2; + if ( v2 &= this ) { + v2->read_whole_file( path, out, outContentType, maxBytes, abort ); + return; + } + read_whole_file_fallback(path, out, outContentType, maxBytes, abort); +} + +void filesystem::read_whole_file_fallback(const char * path, mem_block_container & out, pfc::string_base & outContentType, size_t maxBytes, abort_callback & abort) { + auto f = this->openRead( path, abort, 0 ); + if (!f->get_content_type(outContentType)) outContentType = ""; + auto s64 = f->get_size( abort ); + if ( s64 == filesize_invalid ) { + // unknown length, perform streamed read + size_t done = 0, alloc = 0; + + while(alloc < maxBytes ) { + if ( alloc == 0 ) alloc = 4096; + else { + size_t next = alloc * 2; + if ( next <= alloc ) throw exception_io_data(); + alloc = next; + } + if ( alloc > maxBytes ) alloc = maxBytes; + + out.set_size( alloc ); + size_t delta = alloc - done; + size_t deltaGot = f->read( (uint8_t*) out.get_ptr() + done, delta, abort ); + PFC_ASSERT( deltaGot <= delta ); + done += deltaGot; + if ( deltaGot != delta ) { + out.set_size( done ); return; + } + } + // maxbytes reached + PFC_ASSERT( done == maxBytes ); + // corner case check + if ( f->skip(1, abort) != 0 ) throw exception_io_data(); + } else if ( s64 > maxBytes ) { + throw exception_io_data(); + } else { + size_t s = (size_t) s64; + out.set_size( s ); + if (s > 0) f->read_object( out.get_ptr(), s, abort); + } +} + +bool filesystem::is_transacted() { +#if FB2K_SUPPORT_TRANSACTED_FILESYSTEM + filesystem_transacted::ptr p; + return ( p &= this ); +#else + return false; +#endif +} + +void filesystem::rewrite_file(const char* path, abort_callback& abort, double opTimeout, const void* payload, size_t bytes) { + this->rewrite_file(path, abort, opTimeout, [&](file::ptr f) { + f->write(payload, bytes, abort); + }); +} + +void filesystem::rewrite_file(const char * path, abort_callback & abort, double opTimeout, std::function worker) { + if ( this->is_transacted() ) { + auto f = this->openWriteNew( path, abort, opTimeout ); + worker(f); + } else { + pfc::string_formatter temp(path); temp << ".new.tmp"; + try { + { + auto f = this->openWriteNew( temp, abort, opTimeout ); + worker(f); + f->flushFileBuffers( abort ); + } + + retryOnSharingViolation(opTimeout, abort, [&] { + this->replace_file(temp, path, abort); + }); + + } catch(...) { + try { + retryOnSharingViolation(opTimeout, abort, [&] { this->remove(temp, fb2k::noAbort); } ); + } catch(...) {} + throw; + } + } +} + +void filesystem::rewrite_directory(const char * path, abort_callback & abort, double opTimeout, std::function worker) { + if ( this->is_transacted() ) { + // so simple + if ( ! this->make_directory_check( path, abort) ) { + retryFileDelete(opTimeout, abort, [&] { this->remove_directory_content(path, abort); }); + } + worker( path ); + } else { + // so complex + pfc::string8 fnNew( path ); fnNew += ".new.tmp"; + pfc::string8 fnOld( path ); fnOld += ".old.tmp"; + + if ( !this->make_directory_check( fnNew, abort ) ) { + // folder.new folder already existed? clear contents + try { + retryFileDelete(opTimeout, abort, [&] { this->remove_directory_content(fnNew, abort); }); + } catch(exception_io_not_found const &) {} + } + + // write to folder.new + worker( fnNew ); + + bool haveOld = false; + if ( directory_exists( path, abort ) ) { + // move folder to folder.old + if (this->directory_exists(fnOld, abort)) { + try { + retryFileDelete(opTimeout, abort, [&] { this->remove_object_recur(fnOld, abort); }); + } catch(exception_io_not_found const &) {} + } + try { + retryFileMove(opTimeout, abort, [&] { this->move( path, fnOld, abort ); } ) ; + haveOld = true; + } catch(exception_io_not_found const &) {} + } + + // move folder.new to folder + retryFileMove( opTimeout, abort, [&] { + this->move( fnNew, path, abort ); + } ); + + if ( haveOld ) { + // delete folder.old if we made one + try { + retryFileDelete( opTimeout, abort, [&] { this->remove_object_recur( fnOld, abort); } ); + } catch (exception_io_not_found const &) {} + } + } +} + +void filesystem_v2::list_directory(const char * p_path, directory_callback & p_out, abort_callback & p_abort) { + list_directory_ex(p_path, p_out, listMode::filesAndFolders | listMode::hidden, p_abort); +} + +void filesystem_v2::extract_filename_ext(const char * path, pfc::string_base & outFN) { + outFN = pfc::filename_ext_v2(path, this->pathSeparator() ); +} + +bool filesystem_v2::get_parent_path(const char * path, pfc::string_base & out) { + return get_parent_helper(path, pathSeparator(), out); +} + +void filesystem_v2::replace_file(const char * src, const char * dst, abort_callback & abort) { + this->move_overwrite( src, dst, abort ); +} + +void filesystem_v2::read_whole_file(const char * path, mem_block_container & out, pfc::string_base & outContentType, size_t maxBytes, abort_callback & abort) { + read_whole_file_fallback( path, out, outContentType, maxBytes, abort ); +} + +bool filesystem_v2::make_directory_check(const char * path, abort_callback & abort) { + bool rv = false; + make_directory(path, abort, &rv); + return rv; +} + +#if FB2K_SUPPORT_TRANSACTED_FILESYSTEM +filesystem_transacted::ptr filesystem_transacted::create( const char * pathFor ) { + service_enum_t e; + filesystem_transacted_entry::ptr p; + while(e.next(p)) { + if ( p->is_our_path( pathFor ) ) { + auto ret = p->create(pathFor); + if (ret.is_valid()) return ret; + } + } + return nullptr; +} +#endif + +bool filesystem::commit_if_transacted(abort_callback &abort) { + (void)abort; + bool rv = false; +#if FB2K_SUPPORT_TRANSACTED_FILESYSTEM + filesystem_transacted::ptr t; + if ( t &= this ) { + t->commit( abort ); rv = true; + } +#endif + return rv; +} + +t_filestats filesystem::get_stats(const char * path, abort_callback & abort) { + t_filestats s; bool dummy; + this->get_stats(path, s, dummy, abort); + return s; +} + +bool file_dynamicinfo_v2::get_dynamic_info(class file_info & p_out) { + t_filesize dummy = 0; + return this->get_dynamic_info_v2(p_out, dummy); +} + +size_t file::lowLevelIO_(const GUID & guid, size_t arg1, void * arg2, size_t arg2size, abort_callback & abort) { + { + file_v2::ptr f; + if (f &= this) return f->lowLevelIO(guid, arg1, arg2, arg2size, abort); + } + { + file_lowLevelIO::ptr f; + if (f &= this) return f->lowLevelIO(guid, arg1, arg2, arg2size, abort); + } + return 0; +} + +bool file::flushFileBuffers(abort_callback & abort) { + return this->lowLevelIO_(file_lowLevelIO::guid_flushFileBuffers, 0, nullptr, 0, abort) != 0; +} + +bool file::getFileTimes(filetimes_t & out, abort_callback & a) { + return this->lowLevelIO_(file_lowLevelIO::guid_getFileTimes, 0, &out, sizeof(out), a) != 0; +} + +bool file::setFileTimes(filetimes_t const & in, abort_callback & a) { + return this->lowLevelIO_(file_lowLevelIO::guid_setFileTimes, 0, (void*)&in, sizeof(in), a) != 0; +} + +bool file::g_copy_creation_time(service_ptr_t from, service_ptr_t to, abort_callback& a) { + bool rv = false; + auto ft = from->get_time_created(a); + if (ft != filetimestamp_invalid) { + filetimes_t ft2; + ft2.creation = ft; + rv = to->setFileTimes(ft2, a); + } + return rv; +} +bool file::g_copy_timestamps(file::ptr from, file::ptr to, abort_callback& a) { + { + filetimes_t filetimes = {}; + if (from->getFileTimes(filetimes, a)) { + return to->setFileTimes(filetimes, a); + } + } + filetimes_t filetimes = {}; + auto stats = from->get_stats2_(stats2_timestamp | stats2_timestampCreate, a); + if (stats.m_timestamp != filetimestamp_invalid || stats.m_timestampCreate != filetimestamp_invalid) { + filetimes.lastWrite = stats.m_timestamp; filetimes.creation = stats.m_timestampCreate; + return to->setFileTimes(filetimes, a); + } + return false; +} + +service_ptr file::get_metadata_(abort_callback& a) { + service_ptr ret; + file_v2::ptr getter; + if (getter &= this) ret = getter->get_metadata(a); + return ret; +} + +drivespace_t filesystem_v3::getDriveSpace(const char*, abort_callback&) { + throw pfc::exception_not_implemented(); +} + +t_filestats2 filesystem::get_stats2_(const char* p_path, uint32_t s2flags, abort_callback& p_abort) { + filesystem_v3::ptr api3; + t_filestats2 ret; + if (api3 &= this) { + ret = api3->get_stats2(p_path, s2flags, p_abort); + } else { + if (this->directory_exists(p_path, p_abort)) { + ret.set_folder(true); + } else if (s2flags & (stats2_size | stats2_timestamp | stats2_canWrite)) { + t_filestats temp; + bool canWrite = false; + this->get_stats(p_path, temp, canWrite, p_abort); + ret.m_size = temp.m_size; + ret.m_timestamp = temp.m_timestamp; + ret.set_file(); + ret.set_readonly(!canWrite); + } + if ( s2flags & stats2_remote ) ret.set_remote(this->is_remote(p_path)); + } + return ret; + +} + +t_filestats2 filesystem::g_get_stats2(const char* p_path, uint32_t s2flags, abort_callback& p_abort) { + return get(p_path)->get_stats2_(p_path, s2flags, p_abort); +} + +void filesystem_v3::get_stats(const char* p_path, t_filestats& p_stats, bool& p_is_writeable, abort_callback& p_abort) { + t_filestats2 s2 = this->get_stats2(p_path, stats2_canWrite | stats2_size | stats2_timestamp, p_abort); + p_stats = s2.to_legacy(); + p_is_writeable = s2.can_write(); +} + +t_filetimestamp file_v2::get_timestamp(abort_callback& p_abort) { + return this->get_stats2(stats2_timestamp, p_abort).m_timestamp; +} +bool file_v2::is_remote() { + return this->get_stats2(stats2_remote, fb2k::noAbort).is_remote(); +} + +t_filesize file_v2::get_size(abort_callback& p_abort) { + return this->get_stats2(stats2_size, p_abort).m_size; +} + +pfc::string8 file::get_content_type() { + pfc::string8 ret; + if (!this->get_content_type(ret)) ret.clear(); + return ret; + +} +t_filestats2 file::get_stats2_(uint32_t f, abort_callback& a) { + t_filestats2 ret; + + file_v2::ptr v2; + if (v2 &= this) { + ret = v2->get_stats2(f, a); + PFC_ASSERT(ret.is_file()); + } else { + if (f & stats2_size) ret.m_size = this->get_size(a); + if (f & stats2_timestamp) ret.m_timestamp = this->get_timestamp(a); + ret.set_file(); + ret.set_remote(this->is_remote()); + // we do not know if it's readonly or not, can_write() tells us if the file was open for writing, not if it can possibly be opened for writing + } + return ret; +} + +pfc::string8 t_filestats2::format_attribs(uint32_t attr, const char * delim) { + pfc::string8 ret; + if (attr != 0) { + const char* arr[5] = {}; + size_t w = 0; + ret.prealloc(64); + if (attr & attr_readonly) { + arr[w++] = "read-only"; + } + if (attr & attr_folder) { + arr[w++] = "folder"; + } + if (attr & attr_hidden) { + arr[w++] = "hidden"; + } + if (attr & attr_system) { + arr[w++] = "system"; + } + if (attr & attr_remote) { + arr[w++] = "remote"; + } + PFC_ASSERT(w <= PFC_TABSIZE(arr)); + for (size_t f = 0; f < w; ++f) { + if (f > 0) ret += delim; + ret += arr[f]; + } + } + return ret; +} + +t_filetimestamp file::get_time_created(abort_callback& a) { + t_filetimestamp ret; + ret = get_stats2_(stats2_timestampCreate, a).m_timestampCreate; + if (ret != filetimestamp_invalid) return ret; + + filetimes_t ft; + if (this->getFileTimes(ft, a)) return ft.creation; + return filetimestamp_invalid; +} + +bool filesystem::get_display_name_short_(const char* path, pfc::string_base& out) { + + try { + filesystem_v3::ptr v3; + if (v3 &= this) return v3->get_display_name_short(path, out); + } catch(...) {return false;} // handle nonsense path etc + + pfc::string8 temp; + extract_filename_ext(path, temp); + if (temp.length() == 0) return false; + out = temp; + return true; +} + +bool filesystem_v3::get_display_name_short(const char* path, pfc::string_base& out) { + pfc::string8 temp; + extract_filename_ext(path, temp); + if (temp.length() == 0) return false; + out = temp; + return true; +} + +fb2k::memBlockRef filesystem::readWholeFile(const char* path, size_t maxBytes, abort_callback& abort) { + mem_block_container_impl temp; + pfc::string8 contentType; + this->read_whole_file(path, temp, contentType, maxBytes, abort); + return fb2k::memBlock::blockWithData(std::move(temp.m_data)); +} + +fb2k::memBlockRef filesystem::g_readWholeFile(const char * path, size_t sizeSanity, abort_callback & aborter) { + return get(path)->readWholeFile(path, sizeSanity, aborter); +} + +namespace { + class directory_callback_v3_to_legacy : public directory_callback_v3 { + public: + directory_callback* m_chain = nullptr; + + bool on_entry(filesystem* owner, const char* URL, t_filestats2 const& stats, abort_callback& abort) override { + return m_chain->on_entry(owner, abort, URL, stats.is_folder(), stats.as_legacy()); + } + }; +} + +void filesystem_v3::list_directory_ex(const char* p_path, directory_callback& p_out, unsigned listMode, abort_callback& p_abort) { + directory_callback_v3_to_legacy wrap; + wrap.m_chain = &p_out; + this->list_directory_v3(p_path, wrap, listMode, p_abort); +} + +bool filesystem_v3::directory_exists(const char* path, abort_callback& abort) { + try { + return get_stats2(path, stats2_fileOrFolder, abort).is_folder(); + } catch (exception_io_not_found const &) { return false; } +} + +bool filesystem_v3::file_exists(const char* path, abort_callback& abort) { + try { + return get_stats2(path, stats2_fileOrFolder, abort).is_file(); + } catch (exception_io_not_found const &) { return false; } +} + + +namespace { + class directory_callback_v3_to_lambda : public directory_callback_v3 { + public: + filesystem::list_callback_t f; + bool on_entry(filesystem*, const char* URL, t_filestats2 const& stats, abort_callback&) override { + f(URL, stats); + return true; + } + }; + class directory_callback_to_lambda : public directory_callback { + public: + filesystem::list_callback_t f; + + bool m_enforceListMode = false; + unsigned m_listMode = 0; + + bool on_entry(filesystem* p_owner, abort_callback& p_abort, const char* p_url, bool p_is_subdirectory, const t_filestats& p_stats) override { + (void)p_owner; p_abort.check(); + if (m_enforceListMode) { + if (p_is_subdirectory) { + if ( (m_listMode & listMode::folders) == 0 ) return true; + } else { + if ((m_listMode & listMode::files) == 0) return true; + } + } + + t_filestats2 stats; + stats.set_folder(p_is_subdirectory); + stats.m_size = p_stats.m_size; + stats.m_timestamp = p_stats.m_timestamp; + f(p_url, stats); + return true; + } + }; +} + +void filesystem::list_directory_(const char* path, list_callback_t f, unsigned listMode, abort_callback& a) { + + { + filesystem_v3::ptr v3; + if (v3 &= this) { + directory_callback_v3_to_lambda cb; + cb.f = f; + v3->list_directory_v3(path, cb, listMode, a); + return; + } + } + + { + filesystem_v2::ptr v2; + if (v2 &= this) { + directory_callback_to_lambda cb; + cb.f = f; + v2->list_directory_ex(path, cb, listMode, a); + return; + } + } + + directory_callback_to_lambda cb; + cb.m_listMode = listMode; + cb.m_enforceListMode = true; + cb.f = f; + this->list_directory(path, cb, a); +} + + +fsItemBase::ptr filesystem_v3::findItem(const char* path, abort_callback& p_abort) { +#if PFC_DEBUG + try { +#endif + pfc::string8 canonical; + if (get_canonical_path(path, canonical)) { + auto stats = this->get_stats2(path, stats2_all, p_abort); + if ( stats.is_folder() ) { + return makeItemFolderStd(canonical, stats); + } else { + return makeItemFileStd(canonical, stats ); + } + } + throw exception_io_not_found(); +#if PFC_DEBUG + } catch (std::exception const& e) { + try { + FB2K_console_formatter() << "filesystem::findItem error: " << e; + FB2K_console_formatter() << "problem path: " << path; + } catch (...) {} + throw; + } +#endif +} +fsItemFile::ptr filesystem_v3::findItemFile(const char* path, abort_callback& p_abort) { +#if PFC_DEBUG + try { +#endif + pfc::string8 canonical; + if (get_canonical_path(path, canonical)) { + auto stats = this->get_stats2( canonical, stats2_all, p_abort); + if ( stats.is_file() ) { + return makeItemFileStd(canonical, stats ); + } + } + throw exception_io_not_found(); +#if PFC_DEBUG + } catch (std::exception const& e) { + try { + FB2K_console_formatter() << "filesystem::findItemFile error: " << e; + FB2K_console_formatter() << "problem path: " << path; + } catch (...) {} + throw; + } +#endif +} +fsItemFolder::ptr filesystem_v3::findItemFolder(const char* path, abort_callback& p_abort) { +#if PFC_DEBUG + try { +#endif + pfc::string8 canonical; + if (get_canonical_path(path, canonical)) { + auto stats = this->get_stats2( canonical, stats2_all, p_abort); + if ( stats.is_folder() ) { + return makeItemFolderStd(canonical, stats ); + } + } + throw exception_io_not_found(); +#if PFC_DEBUG + } catch (std::exception const& e) { + try { + FB2K_console_formatter() << "filesystem::findItemFolder error: " << e; + FB2K_console_formatter() << "problem path: " << path; + } catch (...) {} + throw; + } +#endif +} + +fsItemFolder::ptr filesystem_v3::findParentFolder(const char* path, abort_callback& p_abort) { + auto parent = parentPath(path); + if (parent == nullptr) { +#if PFC_DEBUG + FB2K_console_formatter() << "filesystem::findParentFolder error: cannot walk up from root path"; + FB2K_console_formatter() << "problem path: " << path; +#endif + throw exception_io_not_found(); + } + return findItemFolder(parent->c_str(), p_abort); +} + +fb2k::stringRef filesystem_v3::fileNameSanity(const char* fn) { + auto ret = fb2k::makeString(pfc::io::path::validateFileName(fn).c_str()); + if (ret->length() == 0) ret = fb2k::makeString("_"); + return ret; +} + +static void readStatsMultiStd(fb2k::arrayRef items, uint32_t s2flags, t_filestats2* outStats, abort_callback& abort) { + const size_t count = items->size(); + for (size_t w = 0; w < count; ++w) { + abort.check(); + auto& out = outStats[w]; + try { + fsItemPtr f; f ^= items->itemAt(w); + out = f->getStats2(s2flags, abort); + } catch (exception_aborted const &) { + throw; + } catch (exception_io const &) { + out = filestats2_invalid; + } + } +} + +void filesystem_v3::readStatsMulti(fb2k::arrayRef items, uint32_t s2flags, t_filestats2* outStats, abort_callback& abort) { + readStatsMultiStd(items, s2flags, outStats, abort); +} + +pfc::string8 t_filestats::describe() const { + pfc::string8 ret; + ret << "size: "; + if (m_size != filesize_invalid) ret << m_size; + else ret << "N/A"; + ret << "\n"; + ret << "last-modified: "; + if (m_timestamp != filetimestamp_invalid) ret << m_timestamp; + else ret << "N/A"; + ret << "\n"; + return ret; +} + +pfc::string8 t_filestats2::describe() const { + pfc::string8 ret; + ret << "size: "; + if (m_size != filesize_invalid) ret << m_size; + else ret << "N/A"; + ret << "\n"; + ret << "last-modified: "; + if (m_timestamp != filetimestamp_invalid) ret << m_timestamp; + else ret << "N/A"; + ret << "\n"; + ret << "created: "; + if (m_timestampCreate != filetimestamp_invalid) ret << m_timestampCreate; + else ret << "N/A"; + ret << "\n"; + ret << "attribs: " << format_attribs() << "\n"; + ret << "attribs valid: " << format_attribs(m_attribsValid) << "\n"; + return ret; +} + + +#ifndef _WIN32 +t_filestats foobar2000_io::nixMakeFileStats(const struct stat & st) { + t_filestats out = filestats_invalid; + out.m_size = st.st_size; +#ifdef __APPLE__ + out.m_timestamp = pfc::fileTimeUtoW(st.st_mtimespec); +#else // Linux + out.m_timestamp = pfc::fileTimeUtoW(st.st_mtim); +#endif + return out; +} + +bool foobar2000_io::nixQueryReadonly( const struct stat & st ) { + return (st.st_mode & 0222) == 0; +} + +bool foobar2000_io::nixQueryDirectory( const struct stat & st ) { + return (st.st_mode & S_IFDIR) != 0; +} + +t_filestats2 foobar2000_io::nixMakeFileStats2(const struct stat &st) { + t_filestats2 ret = t_filestats2::from_legacy( nixMakeFileStats( st ) ); +#ifdef __APPLE__ + ret.m_timestampCreate = pfc::fileTimeUtoW(st.st_birthtimespec); +#else // Linux + ret.m_timestampCreate = pfc::fileTimeUtoW(st.st_ctim); +#endif + ret.set_readonly(nixQueryReadonly(st)); + if ( st.st_mode & S_IFDIR ) ret.set_folder(); + else if (st.st_mode & S_IFREG ) ret.set_file(); + ret.set_remote(false); + return ret; +} + +bool foobar2000_io::compactHomeDir(pfc::string_base & str) { + const char * prefix = "file://"; + size_t base = 0; + if (pfc::strcmp_partial( str, prefix ) == 0) base = strlen(prefix); + const char * homedir = getenv("HOME"); + if (homedir == NULL) return false; + const char * strBase = str.get_ptr() + base; + if (pfc::strcmp_partial(strBase, homedir) == 0) { + const char * strPast = strBase + strlen(homedir); + if (*strPast == 0 || *strPast == '/') { + pfc::string8 temp ( strPast ); + str.truncate( base ); + str += "~"; + str += temp; + return true; + } + } + + return false; +} + +bool foobar2000_io::expandHomeDir(pfc::string_base & str) { + const char * prefix = "file://"; + size_t base = 0; + if (pfc::strcmp_partial( str, prefix ) == 0) base = strlen(prefix); + const char * strBase = str.get_ptr() + base; + if (strBase[0] == '~') { + if (strBase[1] == 0 || strBase[1] == '/') { + const char * homedir = getenv("HOME"); + if (homedir == NULL) return false; + pfc::string8 temp( strBase + 1 ); + str.truncate( base ); + str += homedir; + str += temp; + return true; + } + } + + return false; +} + +#endif // _WIN32 + +bool filesystem::g_get_display_name_short( const char * path, pfc::string_base & out ) { + auto i = tryGet( path ); + if ( i.is_valid() ) { + if (i->get_display_name_short_(path, out)) return true; + } + out = path; + return false; +} + + +bool filesystem::g_compare_paths(const char* p1, const char* p2, int& result) { + if (strcmp(p1, p2) == 0) { + result = 0; return true; + } + + { + auto s1 = strstr(p1, "://"); + auto s2 = strstr(p2, "://"); + if (s1 == nullptr || s2 == nullptr) { + PFC_ASSERT(!"Invalid arguments"); + return false; + } + size_t prefix = s1 - p1; + if (prefix != (size_t)(s2 - p2)) return false; // protocol mismatch + if (memcmp(p1, p2, prefix) != 0) return false; // protocol mismatch + } + + filesystem::ptr fs; + if (!g_get_interface(fs, p1)) { + PFC_ASSERT(!"Invalid arguments"); + return false; + } + pfc::string8 temp1(p1), temp2(p2); + auto delim = fs->pathSeparator(); + temp1.end_with(delim); temp2.end_with(delim); + if (strcmp(temp1, temp2) == 0) { result = 0; return true; } + + //result 1 if p2 is a subpath of p1, -1 if p1 is a subpath of p2 + if (pfc::string_has_prefix(temp1, temp2)) { + // temp1 starts with temp2 + // p1 a subfolder of p2 + result = -1; + return true; + } else if (pfc::string_has_prefix(temp2, temp1)) { + // temp2 starts with temp1 + // p2 a subfolder of p1 + result = 1; + return true; + } else { + return false; + } +} + +size_t file::receive(void* ptr, size_t bytes, abort_callback& a) { + stream_receive::ptr obj; + if (obj &= this) return obj->receive(ptr, bytes, a); + else return this->read(ptr, bytes, a); +} + +void filesystem::g_readStatsMulti(fb2k::arrayRef items, uint32_t s2flags, t_filestats2* outStats, abort_callback& abort) { + if (items->size() == 0) return; + fsItemPtr aFile; aFile ^= items->itemAt(0); + filesystem_v3::ptr fs; + if (fs &= aFile->getFS()) { + fs->readStatsMulti(items, s2flags, outStats, abort); + } else { + readStatsMultiStd(items, s2flags, outStats, abort); + } +} + +void file::set_stats(t_filestats2 const& stats, abort_callback& a) { + if (stats.haveTimestamp() || stats.haveTimestampCreate()) { + filetimes_t ft; + ft.creation = stats.m_timestampCreate; + ft.lastWrite = stats.m_timestamp; + this->setFileTimes(ft, a); + } +} + +fb2k::stringRef filesystem::fileNameSanity_(const char* fn) { + filesystem_v3::ptr v3; + if (v3 &= this) return v3->fileNameSanity(fn); + throw pfc::exception_not_implemented(); +} + +drivespace_t filesystem::getDriveSpace_(const char* pathAt, abort_callback& abort) { + filesystem_v3::ptr v3; + if (v3 &= this) return v3->getDriveSpace(pathAt, abort); + throw pfc::exception_not_implemented(); +} + +size_t stream_receive::read_using_receive(void* ptr_, size_t bytes, abort_callback& a) { + size_t walk = 0; + auto ptr = reinterpret_cast(ptr_); + while(walk < bytes) { + size_t want = bytes-walk; + size_t delta = this->receive(ptr+walk, want, a); + PFC_ASSERT( delta <= want ); + if ( delta == 0 ) break; + walk += delta; + } + return walk; +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/filesystem.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/filesystem.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,518 @@ +#pragma once + +#include "file.h" +#include "fsitem.h" +#include + +#ifndef _WIN32 +struct stat; +#endif + +//! Contains various I/O related structures and interfaces. +namespace foobar2000_io +{ + + //! Disk space info struct + struct drivespace_t { + //! Free space, in bytes + t_filesize m_free = filesize_invalid; + //! Total size, in bytes + t_filesize m_total = filesize_invalid; + //! Free space available to caller, in bytes \n + //! If not specifically supported by filesystem, same as m_free. + t_filesize m_avail = filesize_invalid; + }; + + + + class filesystem; + + class NOVTABLE directory_callback { + public: + //! @returns true to continue enumeration, false to abort. + virtual bool on_entry(filesystem * p_owner,abort_callback & p_abort,const char * p_url,bool p_is_subdirectory,const t_filestats & p_stats)=0; + }; + + class NOVTABLE directory_callback_v3 { + public: + virtual bool on_entry(filesystem* owner, const char* URL, t_filestats2 const& stats, abort_callback& abort) = 0; + }; + + //! Entrypoint service for all filesystem operations.\n + //! Implementation: standard implementations for local filesystem etc are provided by core.\n + //! Instantiation: use static helper functions rather than calling filesystem interface methods directly, e.g. filesystem::g_open() to open a file. + class NOVTABLE filesystem : public service_base { + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(filesystem); + public: + //! Enumeration specifying how to open a file. See: filesystem::open(), filesystem::g_open(). + typedef uint32_t t_open_mode; + enum { + //! Opens an existing file for reading; if the file does not exist, the operation will fail. + open_mode_read, + //! Opens an existing file for writing; if the file does not exist, the operation will fail. + open_mode_write_existing, + //! Opens a new file for writing; if the file exists, its contents will be wiped. + open_mode_write_new, + + open_mode_mask = 0xFF, + open_shareable = 0x100, + }; + + virtual bool get_canonical_path(const char * p_path,pfc::string_base & p_out)=0; + virtual bool is_our_path(const char * p_path)=0; + virtual bool get_display_path(const char * p_path,pfc::string_base & p_out)=0; + + virtual void open(service_ptr_t & p_out,const char * p_path, t_open_mode p_mode,abort_callback & p_abort)=0; + virtual void remove(const char * p_path,abort_callback & p_abort)=0; + //! Moves/renames a file. Will fail if the destination file already exists. \n + //! Note that this function may throw exception_io_denied instead of exception_io_sharing_violation when the file is momentarily in use, due to bugs in Windows MoveFile() API. There is no legitimate way for us to distinguish between the two scenarios. + virtual void move(const char * p_src,const char * p_dst,abort_callback & p_abort)=0; + //! Queries whether a file at specified path belonging to this filesystem is a remote object or not. + virtual bool is_remote(const char * p_src) = 0; + + //! Retrieves stats of a file at specified path. + virtual void get_stats(const char * p_path,t_filestats & p_stats,bool & p_is_writeable,abort_callback & p_abort) = 0; + //! Helper + t_filestats get_stats( const char * path, abort_callback & abort ); + + virtual bool relative_path_create(const char* file_path, const char* playlist_path, pfc::string_base& out) { (void)file_path; (void)playlist_path; (void)out; return false; } + virtual bool relative_path_parse(const char* relative_path, const char* playlist_path, pfc::string_base& out) { (void)relative_path; (void)playlist_path; (void)out; return false; } + + //! Creates a directory. + virtual void create_directory(const char * p_path,abort_callback & p_abort) = 0; + + virtual void list_directory(const char * p_path,directory_callback & p_out,abort_callback & p_abort)=0; + + //! Hint; returns whether this filesystem supports mime types. \n + //! When this returns false, all file::get_content_type() calls on files opened thru this filesystem implementation will return false; otherwise, file::get_content_type() calls may return true depending on the file. + virtual bool supports_content_types() = 0; + + static void g_get_canonical_path(const char * path,pfc::string_base & out); + static void g_get_display_path(const char * path,pfc::string_base & out); + static void g_get_display_path(const char* path, pfc::string_base& out, filesystem::ptr & reuseMe); + //! Retrieves a shortened display name for this file. By default this is implemented by returning filename.ext portion of the path. + static bool g_get_display_name_short( const char * path, pfc::string_base & out ); + //! Extracts the native filesystem path, sets out to the input path if native path cannot be extracted so the output is always set. + //! @returns True if native path was extracted successfully, false otherwise (but output is set anyway). + static bool g_get_native_path( const char * path, pfc::string_base & out, abort_callback & a = fb2k::noAbort); + static pfc::string8 g_get_native_path( const char * path, abort_callback & a = fb2k::noAbort ); + + static bool g_get_interface(service_ptr_t & p_out,const char * path);//path is AFTER get_canonical_path + static filesystem::ptr g_get_interface(const char * path);// throws exception_io_no_handler_for_path on failure + static filesystem::ptr get( const char * path ) { return g_get_interface(path); } // shortened; never returns null, throws on failure + static filesystem::ptr getLocalFS(); // returns local filesystem object + static filesystem::ptr tryGet(const char* path); // returns null if not found instead of throwing + static bool g_is_remote(const char * p_path);//path is AFTER get_canonical_path + static bool g_is_recognized_and_remote(const char * p_path);//path is AFTER get_canonical_path + static bool g_is_remote_safe(const char * p_path) {return g_is_recognized_and_remote(p_path);} + static bool g_is_remote_or_unrecognized(const char * p_path); + static bool g_is_recognized_path(const char * p_path); + + //! Opens file at specified path, with specified access privileges. + static void g_open(service_ptr_t & p_out,const char * p_path,t_open_mode p_mode,abort_callback & p_abort); + //! Attempts to open file at specified path; if the operation fails with sharing violation error, keeps retrying (with short sleep period between retries) for specified amount of time. + static void g_open_timeout(service_ptr_t & p_out,const char * p_path,t_open_mode p_mode,double p_timeout,abort_callback & p_abort); + static void g_open_write_new(service_ptr_t & p_out,const char * p_path,abort_callback & p_abort); + static void g_open_read(service_ptr_t & p_out,const char * path,abort_callback & p_abort) {return g_open(p_out,path,open_mode_read,p_abort);} + static void g_open_precache(service_ptr_t & p_out,const char * path,abort_callback & p_abort);//open only for precaching data (eg. will fail on http etc) + static bool g_exists(const char * p_path,abort_callback & p_abort); + static bool g_exists_writeable(const char * p_path,abort_callback & p_abort); + //! Removes file at specified path. + static void g_remove(const char * p_path,abort_callback & p_abort); + //! Attempts to remove file at specified path; if the operation fails with a sharing violation error, keeps retrying (with short sleep period between retries) for specified amount of time. + static void g_remove_timeout(const char * p_path,double p_timeout,abort_callback & p_abort); + //! Moves file from one path to another. + //! Note that this function may throw exception_io_denied instead of exception_io_sharing_violation when the file is momentarily in use, due to bugs in Windows MoveFile() API. There is no legitimate way for us to distinguish between the two scenarios. + static void g_move(const char * p_src,const char * p_dst,abort_callback & p_abort); + //! Attempts to move file from one path to another; if the operation fails with a sharing violation error, keeps retrying (with short sleep period between retries) for specified amount of time. + static void g_move_timeout(const char * p_src,const char * p_dst,double p_timeout,abort_callback & p_abort); + + static void g_link(const char * p_src,const char * p_dst,abort_callback & p_abort); + static void g_link_timeout(const char * p_src,const char * p_dst,double p_timeout,abort_callback & p_abort); + + static void g_copy(const char * p_src,const char * p_dst,abort_callback & p_abort);//needs canonical path + static void g_copy_timeout(const char * p_src,const char * p_dst,double p_timeout,abort_callback & p_abort);//needs canonical path + static void g_copy_directory(const char * p_src,const char * p_dst,abort_callback & p_abort);//needs canonical path + static void g_get_stats(const char * p_path,t_filestats & p_stats,bool & p_is_writeable,abort_callback & p_abort); + static bool g_relative_path_create(const char * p_file_path,const char * p_playlist_path,pfc::string_base & out); + static bool g_relative_path_parse(const char * p_relative_path,const char * p_playlist_path,pfc::string_base & out); + + static void g_create_directory(const char * p_path,abort_callback & p_abort); + + static void g_open_temp(service_ptr_t & p_out,abort_callback & p_abort); + static void g_open_tempmem(service_ptr_t & p_out,abort_callback & p_abort); + static file::ptr g_open_tempmem(); + + static void g_list_directory(const char * p_path,directory_callback & p_out,abort_callback & p_abort);// path must be canonical + + static bool g_is_valid_directory(const char * path,abort_callback & p_abort); + static bool g_is_empty_directory(const char * path,abort_callback & p_abort); + + void remove_object_recur(const char * path, abort_callback & abort); + void remove_directory_content(const char * path, abort_callback & abort); + static void g_remove_object_recur(const char * path, abort_callback & abort); + static void g_remove_object_recur_timeout(const char * path, double timeout, abort_callback & abort); + + // Presumes both source and destination belong to this filesystem. + void copy_directory(const char * p_src, const char * p_dst, abort_callback & p_abort); + void copy_directory_contents(const char* p_src, const char* p_dst, abort_callback& p_abort); + + //! Moves/renames a file, overwriting the destination atomically if exists. \n + //! Note that this function may throw exception_io_denied instead of exception_io_sharing_violation when the file is momentarily in use, due to bugs in Windows MoveFile() API. There is no legitimate way for us to distinguish between the two scenarios. + void move_overwrite( const char * src, const char * dst, abort_callback & abort); + //! Moves/renames a file, overwriting the destination atomically if exists. \n + //! Meant to retain destination attributes if feasible. Otherwise identical to move_overwrite(). \n + //! Note that this function may throw exception_io_denied instead of exception_io_sharing_violation when the file is momentarily in use, due to bugs in Windows MoveFile() API. There is no legitimate way for us to distinguish between the two scenarios. + void replace_file(const char * src, const char * dst, abort_callback & abort); + //! Create a directory, without throwing an exception if it already exists. + //! @param didCreate bool flag indicating whether a new directory was created or not. \n + //! This should be a retval, but because it's messy to obtain this information with certain APIs, the caller can opt out of receiving this information,. + void make_directory( const char * path, abort_callback & abort, bool * didCreate = nullptr ); + //! Bool retval version of make_directory(). + bool make_directory_check( const char * path, abort_callback & abort ); + + //! Returns whether a directory exists at path, false if doesn't exist or not a directory. + bool directory_exists(const char * path, abort_callback & abort); + //! Returns whether a file exists at path, false if doesn't exist or not a file. + bool file_exists( const char * path, abort_callback & abort ); + //! Returns whether either a file or a directory exists at path. Effectively directory_exists() || file_exists(), but somewhat more efficient. + bool exists(const char* path, abort_callback& a); + + char pathSeparator(); + //! Extracts the filename.ext portion of the path. \n + //! The filename is ready to be presented to the user - URL decoding and such (similar to get_display_path()) is applied. + void extract_filename_ext(const char * path, pfc::string_base & outFN); + pfc::string8 extract_filename_ext(const char* path); + pfc::string8 get_extension(const char* path); + static pfc::string8 g_get_extension(const char* path); + //! Retrieves the parent path. + bool get_parent_path(const char * path, pfc::string_base & out); + //! Retrieves the parent path, alternate version. + fb2k::stringRef parentPath(const char* path); + + file::ptr openWriteNew( const char * path, abort_callback & abort, double timeout ); + file::ptr openWriteExisting(const char * path, abort_callback & abort, double timeout); + file::ptr openRead( const char * path, abort_callback & abort, double timeout); + file::ptr openEx( const char * path, t_open_mode mode, abort_callback & abort, double timeout); + void remove_(const char* path, abort_callback& a, double timeout); + + //! Read whole file into a mem_block_container + void read_whole_file(const char * path, mem_block_container & out, pfc::string_base & outContentType, size_t maxBytes, abort_callback & abort ); + //! Alternate read whole file, fb2k mobile style + fb2k::memBlockRef readWholeFile(const char* path, size_t maxBytes, abort_callback& abort); + static fb2k::memBlockRef g_readWholeFile(const char * path, size_t sizeSanity, abort_callback & aborter); + + bool is_transacted(); + bool commit_if_transacted(abort_callback &abort); + + //! Full file rewrite helper that automatically does the right thing to ensure atomic update. \n + //! If this is a transacted filesystem, a simple in-place rewrite is performed. \n + //! If this is not a transacted filesystem, your content first goes to a temporary file, which then replaces the original. \n + //! See also: filesystem_transacted. \n + //! In order to perform transacted operations, you must obtain a transacted filesystem explicitly, or get one passed down from a higher level context (example: in config_io_callback_v3). + void rewrite_file( const char * path, abort_callback & abort, double opTimeout, std::function worker ); + void rewrite_file(const char* path, abort_callback& abort, double opTimeout, const void* payload, size_t bytes); + //! Full directory rewrite helper that automatically does the right thing to ensure atomic update. \n + //! If this is a transacted filesystem, a simple in-place rewrite is performed. \n + //! If this is not a transacted filesystem, your content first goes to a temporary folder, which then replaces the original. \n + //! It is encouraged to perform flushFileBuffers on all files accessed from within. \n + //! See also: filesystem_transacted. \n + //! In order to perform transacted operations, you must obtain a transacted filesystem explicitly, or get one passed down from a higher level context (example: in config_io_callback_v3). + void rewrite_directory(const char * path, abort_callback & abort, double opTimeout, std::function worker); + + t_filestats2 get_stats2_(const char* p_path, uint32_t s2flags, abort_callback& p_abort); + static t_filestats2 g_get_stats2(const char* p_path, uint32_t s2flags, abort_callback& p_abort); + + bool get_display_name_short_(const char* path, pfc::string_base& out); + + fsItemFolder::ptr makeItemFolderStd(const char* pathCanonical, t_filestats2 const& stats = filestats2_invalid ); + fsItemFile::ptr makeItemFileStd(const char* pathCanonical, t_filestats2 const& stats = filestats2_invalid ); + fsItemBase::ptr findItem_(const char* path, abort_callback& p_abort); + fsItemFile::ptr findItemFile_(const char* path, abort_callback& p_abort); + fsItemFolder::ptr findItemFolder_(const char* path, abort_callback& p_abort); + + + typedef std::function list_callback_t; + void list_directory_(const char* path, list_callback_t cb, unsigned listMode,abort_callback& a); + + //! Compares two paths determining if one is a subpath of another, + //! Returns false if the paths are unrelated. + //! Returns true if the paths are related, and then: result is set 0 if they are equal, 1 if p2 is a subpath of p1, -1 if p1 is a subpath of p2 + static bool g_compare_paths(const char* p1, const char* p2, int& result); + + //! Batch file stats read. Some filesystems provide an optimized implementation of this. + static void g_readStatsMulti(fb2k::arrayRef items, uint32_t s2flags, t_filestats2* outStats, abort_callback& abort); + + //! See filesystem_v3::fileNameSanity(). Throws pfc::exception_not_implemented() if not available. + fb2k::stringRef fileNameSanity_(const char* fn); + + //! See filesystem_v3::getDriveSpace(). Throws pfc::exception_not_implemented() if not available. + drivespace_t getDriveSpace_(const char* pathAt, abort_callback& abort); + + protected: + static bool get_parent_helper(const char * path, char separator, pfc::string_base & out); + void read_whole_file_fallback( const char * path, mem_block_container & out, pfc::string_base & outContentType, size_t maxBytes, abort_callback & abort ); + }; + + class filesystem_v2 : public filesystem { + FB2K_MAKE_SERVICE_INTERFACE( filesystem_v2, filesystem ) + public: + //! Moves/renames a file, overwriting the destination atomically if exists. \n + //! Note that this function may throw exception_io_denied instead of exception_io_sharing_violation when the file is momentarily in use, due to bugs in Windows MoveFile() API. There is no legitimate way for us to distinguish between the two scenarios. + virtual void move_overwrite(const char * src, const char * dst, abort_callback & abort) = 0; + //! Moves/renames a file, overwriting the destination atomically if exists. \n + //! Meant to retain destination attributes if feasible. Otherwise identical to move_overwrite(). \n + //! Note that this function may throw exception_io_denied instead of exception_io_sharing_violation when the file is momentarily in use, due to bugs in Windows MoveFile() API. There is no legitimate way for us to distinguish between the two scenarios. + virtual void replace_file(const char * src, const char * dst, abort_callback & abort); + //! Create a directory, without throwing an exception if it already exists. + //! @param didCreate bool flag indicating whether a new directory was created or not. \n + //! This should be a retval, but because it's messy to obtain this information with certain APIs, the caller can opt out of receiving this information,. + virtual void make_directory(const char * path, abort_callback & abort, bool * didCreate = nullptr) = 0; + virtual bool directory_exists(const char * path, abort_callback & abort) = 0; + virtual bool file_exists(const char * path, abort_callback & abort) = 0; + virtual char pathSeparator() = 0; + virtual void extract_filename_ext(const char * path, pfc::string_base & outFN); + virtual bool get_parent_path( const char * path, pfc::string_base & out); + virtual void list_directory_ex(const char * p_path, directory_callback & p_out, unsigned listMode, abort_callback & p_abort) = 0; + virtual void read_whole_file(const char * path, mem_block_container & out, pfc::string_base & outContentType, size_t maxBytes, abort_callback & abort); + + //! Wrapper to list_directory_ex + void list_directory( const char * p_path, directory_callback & p_out, abort_callback & p_abort ); + + bool make_directory_check(const char * path, abort_callback & abort); + }; + + //! \since 2.0 + class filesystem_v3 : public filesystem_v2 { + FB2K_MAKE_SERVICE_INTERFACE(filesystem_v3, filesystem_v2); + public: + //! Retrieves free space on the volume at the specified path. + //! Optional functionality, throws pfc::exception_not_implemented if n/a. + virtual drivespace_t getDriveSpace(const char* pathAt, abort_callback& abort); + + //! Retrieves stats of a file at specified path. + virtual t_filestats2 get_stats2(const char* p_path, uint32_t s2flags, abort_callback& p_abort) = 0; + + virtual bool get_display_name_short(const char* in, pfc::string_base& out); + + virtual void list_directory_v3(const char* path, directory_callback_v3& callback, unsigned listMode, abort_callback& p_abort) = 0; + + virtual fsItemBase::ptr findItem(const char* path, abort_callback& p_abort); + virtual fsItemFile::ptr findItemFile(const char* path, abort_callback& p_abort); + virtual fsItemFolder::ptr findItemFolder(const char* path, abort_callback& p_abort); + virtual fsItemFolder::ptr findParentFolder(const char* path, abort_callback& p_abort); + virtual fb2k::stringRef fileNameSanity(const char* fn); + virtual void readStatsMulti(fb2k::arrayRef items, uint32_t s2flags, t_filestats2* outStats, abort_callback& abort); + + //! Optional method to return a native filesystem path to this item, null if N/A. + //! Aborter provided for corner cases, normally not needed. + virtual fb2k::stringRef getNativePath(const char* in, abort_callback& a) { (void)in; (void)a; return nullptr; } + + // Old method wrapped to get_stats2() + void get_stats(const char* p_path, t_filestats& p_stats, bool& p_is_writeable, abort_callback& p_abort) override; + // Old method wrapped to list_directory_v3() + void list_directory_ex(const char* p_path, directory_callback& p_out, unsigned listMode, abort_callback& p_abort) override; + + // Old method wrapped to get_stats2() + bool directory_exists(const char* path, abort_callback& abort) override; + // Old method wrapped to get_stats2() + bool file_exists(const char* path, abort_callback& abort) override; + }; + + class directory_callback_impl : public directory_callback + { + struct t_entry + { + pfc::string_simple m_path; + t_filestats m_stats; + t_entry(const char * p_path, const t_filestats & p_stats) : m_path(p_path), m_stats(p_stats) {} + }; + + + pfc::list_t > m_data; + bool m_recur; + + static int sortfunc(const pfc::rcptr_t & p1, const pfc::rcptr_t & p2) {return pfc::io::path::compare(p1->m_path,p2->m_path);} + public: + bool on_entry(filesystem * owner,abort_callback & p_abort,const char * url,bool is_subdirectory,const t_filestats & p_stats); + + directory_callback_impl(bool p_recur) : m_recur(p_recur) {} + t_size get_count() {return m_data.get_count();} + const char * operator[](t_size n) const {return m_data[n]->m_path;} + const char * get_item(t_size n) const {return m_data[n]->m_path;} + const t_filestats & get_item_stats(t_size n) const {return m_data[n]->m_stats;} + void sort() {m_data.sort_t(sortfunc);} + }; + + + t_filetimestamp filetimestamp_from_system_timer(); + +#ifdef _WIN32 + inline t_filetimestamp import_filetimestamp(FILETIME ft) { + return *reinterpret_cast(&ft); + } +#endif + + void generate_temp_location_for_file(pfc::string_base & p_out, const char * p_origpath,const char * p_extension,const char * p_magic); + + + inline file_ptr fileOpen(const char * p_path,filesystem::t_open_mode p_mode,abort_callback & p_abort,double p_timeout) { + file_ptr temp; filesystem::g_open_timeout(temp,p_path,p_mode,p_timeout,p_abort); PFC_ASSERT(temp.is_valid()); return temp; + } + + inline file_ptr fileOpenReadExisting(const char * p_path,abort_callback & p_abort,double p_timeout = 0) { + return fileOpen(p_path,filesystem::open_mode_read,p_abort,p_timeout); + } + inline file_ptr fileOpenWriteExisting(const char * p_path,abort_callback & p_abort,double p_timeout = 0) { + return fileOpen(p_path,filesystem::open_mode_write_existing,p_abort,p_timeout); + } + inline file_ptr fileOpenWriteNew(const char * p_path,abort_callback & p_abort,double p_timeout = 0) { + return fileOpen(p_path,filesystem::open_mode_write_new,p_abort,p_timeout); + } + + template + class directory_callback_retrieveList : public directory_callback { + public: + directory_callback_retrieveList(t_list & p_list,bool p_getFiles,bool p_getSubDirectories) : m_list(p_list), m_getFiles(p_getFiles), m_getSubDirectories(p_getSubDirectories) {} + bool on_entry(filesystem * p_owner,abort_callback & p_abort,const char * p_url,bool p_is_subdirectory,const t_filestats & p_stats) { + p_abort.check(); + if (p_is_subdirectory ? m_getSubDirectories : m_getFiles) { + m_list.add_item(p_url); + } + return true; + } + private: + const bool m_getSubDirectories; + const bool m_getFiles; + t_list & m_list; + }; + template + class directory_callback_retrieveListEx : public directory_callback { + public: + directory_callback_retrieveListEx(t_list & p_files, t_list & p_directories) : m_files(p_files), m_directories(p_directories) {} + bool on_entry(filesystem * p_owner,abort_callback & p_abort,const char * p_url,bool p_is_subdirectory,const t_filestats & p_stats) { + p_abort.check(); + if (p_is_subdirectory) m_directories += p_url; + else m_files += p_url; + return true; + } + private: + t_list & m_files; + t_list & m_directories; + }; + template class directory_callback_retrieveListRecur : public directory_callback { + public: + directory_callback_retrieveListRecur(t_list & p_list) : m_list(p_list) {} + bool on_entry(filesystem * owner,abort_callback & p_abort,const char * path, bool isSubdir, const t_filestats&) { + if (isSubdir) { + try { owner->list_directory(path,*this,p_abort); } catch(exception_io const &) {} + } else { + m_list.add_item(path); + } + return true; + } + private: + t_list & m_list; + }; + + template + static void listFiles(const char * p_path,t_list & p_out,abort_callback & p_abort) { + directory_callback_retrieveList callback(p_out,true,false); + filesystem::g_list_directory(p_path,callback,p_abort); + } + template + static void listDirectories(const char * p_path,t_list & p_out,abort_callback & p_abort) { + directory_callback_retrieveList callback(p_out,false,true); + filesystem::g_list_directory(p_path,callback,p_abort); + } + template + static void listFilesAndDirectories(const char * p_path,t_list & p_files,t_list & p_directories,abort_callback & p_abort) { + directory_callback_retrieveListEx callback(p_files,p_directories); + filesystem::g_list_directory(p_path,callback,p_abort); + } + template + static void listFilesRecur(const char * p_path,t_list & p_out,abort_callback & p_abort) { + directory_callback_retrieveListRecur callback(p_out); + filesystem::g_list_directory(p_path,callback,p_abort); + } + + bool extract_native_path(const char * p_fspath,pfc::string_base & p_native); + bool _extract_native_path_ptr(const char * & p_fspath); + bool is_native_filesystem( const char * p_fspath ); + bool extract_native_path_ex(const char * p_fspath, pfc::string_base & p_native);//prepends \\?\ where needed + + bool extract_native_path_archive_aware( const char * fspatch, pfc::string_base & out ); + bool extract_native_path_archive_aware_ex( const char * fspatch, pfc::string_base & out, abort_callback & a ); + + template + pfc::string getPathDisplay(const T& source) { + const char * c = pfc::stringToPtr(source); + if ( *c == 0 ) return c; + pfc::string_formatter temp; + filesystem::g_get_display_path(c,temp); + return temp.toString(); + } + template + pfc::string getPathCanonical(const T& source) { + const char * c = pfc::stringToPtr(source); + if ( *c == 0 ) return c; + pfc::string_formatter temp; + filesystem::g_get_canonical_path(c,temp); + return temp.toString(); + } + + + bool matchContentType(const char * fullString, const char * ourType); + bool matchProtocol(const char * fullString, const char * protocolName); + bool testIfHasProtocol( const char * fullString ); + const char * afterProtocol( const char * fullString ); + pfc::string8 getProtocol(const char* fullString); + void substituteProtocol(pfc::string_base & out, const char * fullString, const char * protocolName); + + bool matchContentType_MP3( const char * fullString); + bool matchContentType_MP4audio( const char * fullString); + bool matchContentType_MP4( const char * fullString); + bool matchContentType_Ogg( const char * fullString); + bool matchContentType_Opus( const char * fullString); + bool matchContentType_FLAC( const char * fullString); + bool matchContentType_WavPack( const char * fullString); + bool matchContentType_WAV( const char * fullString); + bool matchContentType_Musepack( const char * fullString); + const char * extensionFromContentType( const char * contentType ); + const char * contentTypeFromExtension( const char * ext ); + + void purgeOldFiles(const char * directory, t_filetimestamp period, abort_callback & abort); + +#ifndef _WIN32 + // Struct stat to fb2k filestats converter + t_filestats nixMakeFileStats(const struct stat & st); + t_filestats2 nixMakeFileStats2(const struct stat & st); + bool nixQueryReadonly( const struct stat & st ); + bool nixQueryDirectory( const struct stat & st ); + bool compactHomeDir(pfc::string_base & str); + bool expandHomeDir(pfc::string_base & str); + + +#endif + + //! \since 1.6 + class read_ahead_tools : public service_base { + FB2K_MAKE_SERVICE_COREAPI(read_ahead_tools); + public: + //! Turn any file object into asynchronous read-ahead-buffered file. + //! @param f File object to wrap. Do not call this object's method after a successful call to add_read_ahead; new file object takes over the ownership of it. + //! @param size Requested read-ahead bytes. Pass 0 to use user settings for local/remote playback. + virtual file::ptr add_read_ahead(file::ptr f, size_t size, abort_callback & aborter) = 0; + + //! A helper method to use prior to opening decoders. \n + //! May open the file if needed or leave it blank for the decoder to open. + //! @param f File object to open if needed (buffering mandated by user settings). May be valid or null prior to call. May be valid or null (no buffering) after call. + //! @param path Path to open. May be null if f is not null. At least one of f and path must be valid prior to call. + virtual void open_file_helper(file::ptr & f, const char * path, abort_callback & aborter) = 0; + }; + +} + +using namespace foobar2000_io; + +#include "filesystem_helper.h" diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/filesystem_helper.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/filesystem_helper.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,298 @@ +#include "foobar2000-sdk-pch.h" +#include "filesystem_helper.h" + +void stream_writer_chunk::write(const void * p_buffer,t_size p_bytes,abort_callback & p_abort) { + t_size remaining = p_bytes, written = 0; + while(remaining > 0) { + t_size delta = sizeof(m_buffer) - m_buffer_state; + if (delta > remaining) delta = remaining; + memcpy(m_buffer,(const t_uint8*)p_buffer + written,delta); + written += delta; + remaining -= delta; + + if (m_buffer_state == sizeof(m_buffer)) { + m_writer->write_lendian_t((t_uint8)m_buffer_state,p_abort); + m_writer->write_object(m_buffer,m_buffer_state,p_abort); + m_buffer_state = 0; + } + } +} + +void stream_writer_chunk::flush(abort_callback & p_abort) +{ + m_writer->write_lendian_t((t_uint8)m_buffer_state,p_abort); + if (m_buffer_state > 0) { + m_writer->write_object(m_buffer,m_buffer_state,p_abort); + m_buffer_state = 0; + } +} + +/* + stream_writer * m_writer; + unsigned m_buffer_state; + unsigned char m_buffer[255]; +*/ + +t_size stream_reader_chunk::read(void * p_buffer,t_size p_bytes,abort_callback & p_abort) +{ + t_size todo = p_bytes, done = 0; + while(todo > 0) { + if (m_buffer_size == m_buffer_state) { + if (m_eof) break; + t_uint8 temp; + m_reader->read_lendian_t(temp,p_abort); + m_buffer_size = temp; + if (temp != sizeof(m_buffer)) m_eof = true; + m_buffer_state = 0; + if (m_buffer_size>0) { + m_reader->read_object(m_buffer,m_buffer_size,p_abort); + } + } + + + t_size delta = m_buffer_size - m_buffer_state; + if (delta > todo) delta = todo; + if (delta > 0) { + memcpy((unsigned char*)p_buffer + done,m_buffer + m_buffer_state,delta); + todo -= delta; + done += delta; + m_buffer_state += delta; + } + } + return done; +} + +void stream_reader_chunk::flush(abort_callback & p_abort) { + while(!m_eof) { + p_abort.check_e(); + t_uint8 temp; + m_reader->read_lendian_t(temp,p_abort); + m_buffer_size = temp; + if (temp != sizeof(m_buffer)) m_eof = true; + m_buffer_state = 0; + if (m_buffer_size>0) { + m_reader->skip_object(m_buffer_size,p_abort); + } + } +} + +/* + stream_reader * m_reader; + unsigned m_buffer_state, m_buffer_size; + bool m_eof; + unsigned char m_buffer[255]; +*/ + +void stream_reader_chunk::g_skip(stream_reader * p_stream,abort_callback & p_abort) { + stream_reader_chunk(p_stream).flush(p_abort); +} + + + +static void fileSanitySeek(file::ptr f, pfc::array_t const & content, size_t offset, abort_callback & aborter) { + const size_t readAmount = 64 * 1024; + pfc::array_staticsize_t buf; buf.set_size_discard(readAmount); + f->seek(offset, aborter); + t_filesize positionGot = f->get_position(aborter); + if (positionGot != offset) { + FB2K_console_formatter() << "File sanity: at " << offset << " reported position became " << positionGot; + throw std::runtime_error("Seek test failure"); + } + size_t did = f->read(buf.get_ptr(), readAmount, aborter); + size_t expected = pfc::min_t(readAmount, content.get_size() - offset); + if (expected != did) { + FB2K_console_formatter() << "File sanity: at " << offset << " bytes, expected read size of " << expected << ", got " << did; + if (did > expected) FB2K_console_formatter() << "Read past EOF"; + else FB2K_console_formatter() << "Premature EOF"; + throw std::runtime_error("Seek test failure"); + } + if (memcmp(buf.get_ptr(), content.get_ptr() + offset, did) != 0) { + FB2K_console_formatter() << "File sanity: data mismatch at " << offset << " - " << (offset + did) << " bytes"; + throw std::runtime_error("Seek test failure"); + } + positionGot = f->get_position(aborter); + if (positionGot != offset + did) { + FB2K_console_formatter() << "File sanity: at " << offset << "+" << did << "=" << (offset + did) << " reported position became " << positionGot; + throw std::runtime_error("Seek test failure"); + } +} + +bool fb2kFileSelfTest(file::ptr f, abort_callback & aborter) { + try { + pfc::array_t fileContent; + f->reopen(aborter); + f->read_till_eof(fileContent, aborter); + + { + t_filesize sizeClaimed = f->get_size(aborter); + if (sizeClaimed == filesize_invalid) { + FB2K_console_formatter() << "File sanity: file reports unknown size, actual size read is " << fileContent.get_size(); + } + else { + if (sizeClaimed != fileContent.get_size()) { + FB2K_console_formatter() << "File sanity: file reports size of " << sizeClaimed << ", actual size read is " << fileContent.get_size(); + throw std::runtime_error("File size mismatch"); + } + else { + FB2K_console_formatter() << "File sanity: file size check OK: " << sizeClaimed; + } + } + } + + { + FB2K_console_formatter() << "File sanity: testing N-first-bytes reads..."; + const size_t sizeUpTo = pfc::min_t(fileContent.get_size(), 1024 * 1024); + pfc::array_staticsize_t buf1; + buf1.set_size_discard(sizeUpTo); + + for (size_t w = 1; w <= sizeUpTo; w <<= 1) { + f->reopen(aborter); + size_t did = f->read(buf1.get_ptr(), w, aborter); + if (did != w) { + FB2K_console_formatter() << "File sanity: premature EOF reading first " << w << " bytes, got " << did; + throw std::runtime_error("Premature EOF"); + } + if (memcmp(fileContent.get_ptr(), buf1.get_ptr(), did) != 0) { + FB2K_console_formatter() << "File sanity: file content mismatch reading first " << w << " bytes"; + throw std::runtime_error("File content mismatch"); + } + } + } + if (f->can_seek()) { + FB2K_console_formatter() << "File sanity: testing random access..."; + + { + size_t sizeUpTo = pfc::min_t(fileContent.get_size(), 1024 * 1024); + for (size_t w = 1; w < sizeUpTo; w <<= 1) { + fileSanitySeek(f, fileContent, w, aborter); + } + fileSanitySeek(f, fileContent, fileContent.get_size(), aborter); + for (size_t w = 1; w < sizeUpTo; w <<= 1) { + fileSanitySeek(f, fileContent, fileContent.get_size() - w, aborter); + } + fileSanitySeek(f, fileContent, fileContent.get_size() / 2, aborter); + } + } + FB2K_console_formatter() << "File sanity test: all OK"; + return true; + } + catch (std::exception const & e) { + FB2K_console_formatter() << "File sanity test failure: " << e.what(); + return false; + } +} + + +namespace foobar2000_io { + void retryFileDelete(double timeout, abort_callback & a, std::function f) { + FB2K_RETRY_ON_EXCEPTION3(f(), a, timeout, exception_io_sharing_violation, exception_io_denied, exception_io_directory_not_empty); + } + void retryFileMove(double timeout, abort_callback & a, std::function f) { + FB2K_RETRY_FILE_MOVE( f(), a, timeout ); + } + void retryOnSharingViolation(double timeout, abort_callback & a, std::function f) { + FB2K_RETRY_ON_SHARING_VIOLATION(f(), a, timeout); + } + void retryOnSharingViolation(std::function f, double timeout, abort_callback & a) { + FB2K_RETRY_ON_SHARING_VIOLATION( f(), a, timeout ); + } + void listDirectory( const char * path, abort_callback & aborter, listDirectoryFunc_t func) { + listDirectoryCallbackImpl cb; cb.m_func = func; + filesystem::g_list_directory(path, cb, aborter); + } + + pfc::string8 stripParentFolders( const char * inPath ) { + PFC_ASSERT( strstr(inPath, "://" ) == nullptr || matchProtocol( inPath, "file" ) ); + + size_t prefixLen = pfc::string_find_first(inPath, "://"); + if ( prefixLen != pfc_infinite ) prefixLen += 3; + else prefixLen = 0; + + pfc::chain_list_v2_t segments; + + const char separator = + #ifdef _WIN32 + '\\' + #else + '/' + #endif + ; + const char strSeparator[] = {separator, 0}; + + pfc::splitStringByChar(segments, inPath + prefixLen, separator ); + for ( auto i = segments.first(); i.is_valid(); ) { + auto n = i; ++n; + if ( i->equals( "." ) ) { + segments.remove_single( i ); + } else if ( i->equals( ".." ) ) { + auto p = i; --p; + if ( p.is_valid() ) segments.remove_single( p ); + segments.remove_single( i ); + } + i = n; + } + pfc::string8 ret; + if ( prefixLen > 0 ) ret.add_string( inPath, prefixLen ); + bool bFirst = true; + for ( auto i = segments.first(); i.is_valid(); ++ i ) { + if (!bFirst) ret << strSeparator; + ret << *i; + bFirst = false; + } + return ret; + } +#ifdef _WIN32 + pfc::string8 winGetVolumePath(const char * fb2kPath) { + PFC_ASSERT(matchProtocol(fb2kPath, "file")); + pfc::string8 native; + if (!filesystem::g_get_native_path(fb2kPath, native)) throw pfc::exception_invalid_params(); + + TCHAR outBuffer[MAX_PATH+1] = {}; + WIN32_IO_OP( GetVolumePathName( pfc::stringcvt::string_os_from_utf8( native ), outBuffer, MAX_PATH ) ); + return pfc::stringcvt::string_utf8_from_os( outBuffer ).get_ptr(); + } + + DWORD winVolumeFlags( const char * fb2kPath ) { + PFC_ASSERT(matchProtocol(fb2kPath, "file")); + pfc::string8 native; + if (!filesystem::g_get_native_path(fb2kPath, native)) throw pfc::exception_invalid_params(); + + TCHAR outBuffer[MAX_PATH + 1] = {}; + WIN32_IO_OP(GetVolumePathName(pfc::stringcvt::string_os_from_utf8(native), outBuffer, MAX_PATH)); + + DWORD flags = 0; + WIN32_IO_OP(GetVolumeInformation(outBuffer, nullptr, 0, nullptr, nullptr, &flags, nullptr, 0)); + return flags; + } +#endif +} + +pfc::string8 file_path_canonical(const char* src) { + pfc::string8 ret; + filesystem::g_get_canonical_path(src, ret); + return ret; +} + +pfc::string8 file_path_display(const char* src) { + pfc::string8 ret; + filesystem::g_get_display_path(src, ret); + return ret; +} + +pfc::string8 fb2k::filename_ext( const char * path, filesystem::ptr & fs) { + if ( fs.is_empty() || ! fs->is_our_path( path ) ) { + fs = filesystem::tryGet( path ); + } + if ( fs.is_valid() ) return fs->extract_filename_ext( path ); + // UGLY FALLBACK + return pfc::string_filename_ext( path ); + +} +pfc::string8 fb2k::filename_ext( const char * path ) { + filesystem::ptr no_reuse; + return filename_ext( path, no_reuse ); +} + +pfc::string8 fb2k::filename( const char * path ) { + return pfc::remove_ext_v2( filename_ext( path ) ); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/filesystem_helper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/filesystem_helper.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,618 @@ +#pragma once + +#include +#include "filesystem.h" + +namespace foobar2000_io { + typedef std::function< void (const char *, t_filestats const & , bool ) > listDirectoryFunc_t; + void listDirectory( const char * path, abort_callback & aborter, listDirectoryFunc_t func); + +#ifdef _WIN32 + pfc::string8 stripParentFolders( const char * inPath ); +#endif + + void retryOnSharingViolation( std::function f, double timeout, abort_callback & a); + void retryOnSharingViolation( double timeout, abort_callback & a, std::function f); + + // **** WINDOWS SUCKS **** + // Special version of retryOnSharingViolation with workarounds for known MoveFile() bugs. + void retryFileMove( double timeout, abort_callback & a, std::function f); + + // **** WINDOWS SUCKS **** + // Special version of retryOnSharingViolation with workarounds for known idiotic problems with folder removal. + void retryFileDelete( double timeout, abort_callback & a, std::function f); + + class listDirectoryCallbackImpl : public directory_callback { + public: + listDirectoryCallbackImpl() {} + listDirectoryCallbackImpl( listDirectoryFunc_t f ) : m_func(f) {} + bool on_entry(filesystem *, abort_callback &, const char * p_url, bool p_is_subdirectory, const t_filestats & p_stats) override { + m_func(p_url, p_stats, p_is_subdirectory); + return true; + } + listDirectoryFunc_t m_func; + }; + +#ifdef _WIN32 + pfc::string8 winGetVolumePath(const char * fb2kPath ); + DWORD winVolumeFlags( const char * fb2kPath ); +#endif +} + + +pfc::string8 file_path_canonical(const char* src); +pfc::string8 file_path_display(const char* src); + +namespace fb2k { + //! Sane replacement for pfc::string_filename_ext(), which isn't safe to use in cross-platform code. + //! @returns Filename with extension extracted from path. + pfc::string8 filename_ext( const char * path ); + pfc::string8 filename_ext( const char * path, filesystem::ptr & fs_reuse); + //! Sane replacement for pfc::string_filename(), which isn't safe to use in cross-platform code + //! @returns Filename without extension extracted from path. + pfc::string8 filename( const char * path ); +} + +class stream_reader_memblock_ref : public stream_reader +{ +public: + template stream_reader_memblock_ref(const t_array & p_array) : m_data(p_array.get_ptr()), m_data_size(p_array.get_size()), m_pointer(0) { + pfc::assert_byte_type(); + } + stream_reader_memblock_ref(const void * p_data,t_size p_data_size) : m_data((const unsigned char*)p_data), m_data_size(p_data_size), m_pointer(0) {} + stream_reader_memblock_ref() : m_data(NULL), m_data_size(0), m_pointer(0) {} + + template void set_data(const t_array & data) { + pfc::assert_byte_type(); + set_data(data.get_ptr(), data.get_size()); + } + + void set_data(const void * data, t_size dataSize) { + m_pointer = 0; + m_data = reinterpret_cast(data); + m_data_size = dataSize; + } + + t_size read(void * p_buffer,t_size p_bytes,abort_callback & p_abort) { + p_abort.check(); + t_size delta = pfc::min_t(p_bytes, get_remaining()); + memcpy(p_buffer,m_data+m_pointer,delta); + m_pointer += delta; + return delta; + } + void read_object(void * p_buffer,t_size p_bytes,abort_callback & p_abort) { + p_abort.check(); + if (p_bytes > get_remaining()) throw exception_io_data_truncation(); + memcpy(p_buffer,m_data+m_pointer,p_bytes); + m_pointer += p_bytes; + } + t_filesize skip(t_filesize p_bytes,abort_callback & p_abort) { + p_abort.check(); + t_size remaining = get_remaining(); + if (p_bytes >= remaining) { + m_pointer = m_data_size; return remaining; + } else { + m_pointer += (t_size)p_bytes; return p_bytes; + } + } + void skip_object(t_filesize p_bytes,abort_callback & p_abort) { + p_abort.check(); + if (p_bytes > get_remaining()) { + throw exception_io_data_truncation(); + } else { + m_pointer += (t_size)p_bytes; + } + } + void seek_(t_size offset) { + PFC_ASSERT( offset <= m_data_size ); + m_pointer = offset; + } + const void * get_ptr_() const {return m_data + m_pointer;} + t_size get_remaining() const {return m_data_size - m_pointer;} + void reset() {m_pointer = 0;} +private: + const unsigned char * m_data; + t_size m_data_size,m_pointer; +}; + +template +class stream_writer_buffer_simple_t : public stream_writer { +public: + void write(const void * p_buffer, t_size p_bytes, abort_callback & p_abort) { + p_abort.check(); + t_size base = m_buffer.get_size(); + if (base + p_bytes < base) throw std::bad_alloc(); + m_buffer.set_size(base + p_bytes); + memcpy((t_uint8*)m_buffer.get_ptr() + base, p_buffer, p_bytes); + } + typedef buffer_t t_buffer; // other classes reference this + t_buffer m_buffer; +}; + +typedef stream_writer_buffer_simple_t< pfc::array_t > stream_writer_buffer_simple; + +template +class stream_writer_buffer_append_ref_t : public stream_writer +{ +public: + stream_writer_buffer_append_ref_t(t_storage & p_output) : m_output(p_output) {} + void write(const void * p_buffer,t_size p_bytes,abort_callback & p_abort) { + PFC_STATIC_ASSERT( sizeof(m_output[0]) == 1 ); + p_abort.check(); + t_size base = m_output.get_size(); + if (base + p_bytes < base) throw std::bad_alloc(); + m_output.set_size(base + p_bytes); + memcpy( (t_uint8*) m_output.get_ptr() + base, p_buffer, p_bytes ); + } +private: + t_storage & m_output; +}; + +class stream_reader_limited_ref : public stream_reader { +public: + stream_reader_limited_ref(stream_reader * p_reader,t_filesize p_limit) : m_reader(p_reader), m_remaining(p_limit) {} + + t_size read(void * p_buffer,t_size p_bytes,abort_callback & p_abort) { + if (p_bytes > m_remaining) p_bytes = (t_size)m_remaining; + + t_size done = m_reader->read(p_buffer,p_bytes,p_abort); + m_remaining -= done; + return done; + } + + inline t_filesize get_remaining() const {return m_remaining;} + + t_filesize skip(t_filesize p_bytes,abort_callback & p_abort) { + if (p_bytes > m_remaining) p_bytes = m_remaining; + t_filesize done = m_reader->skip(p_bytes,p_abort); + m_remaining -= done; + return done; + } + + void flush_remaining(abort_callback & p_abort) { + if (m_remaining > 0) skip_object(m_remaining,p_abort); + } + +private: + stream_reader * m_reader; + t_filesize m_remaining; +}; + +class stream_writer_chunk_dwordheader : public stream_writer +{ +public: + stream_writer_chunk_dwordheader(const service_ptr_t & p_writer) : m_writer(p_writer) {} + + void initialize(abort_callback & p_abort) { + m_headerposition = m_writer->get_position(p_abort); + m_written = 0; + m_writer->write_lendian_t((t_uint32)0,p_abort); + } + + void finalize(abort_callback & p_abort) { + t_filesize end_offset; + end_offset = m_writer->get_position(p_abort); + m_writer->seek(m_headerposition,p_abort); + m_writer->write_lendian_t(pfc::downcast_guarded(m_written),p_abort); + m_writer->seek(end_offset,p_abort); + } + + void write(const void * p_buffer,t_size p_bytes,abort_callback & p_abort) { + m_writer->write(p_buffer,p_bytes,p_abort); + m_written += p_bytes; + } + +private: + service_ptr_t m_writer; + t_filesize m_headerposition; + t_filesize m_written; +}; + +class stream_writer_chunk : public stream_writer +{ +public: + stream_writer_chunk(stream_writer * p_writer) : m_writer(p_writer), m_buffer_state(0) {} + + void write(const void * p_buffer,t_size p_bytes,abort_callback & p_abort); + + void flush(abort_callback & p_abort);//must be called after writing before object is destroyed + +private: + stream_writer * m_writer; + unsigned m_buffer_state; + unsigned char m_buffer[255]; +}; + +class stream_reader_chunk : public stream_reader +{ +public: + stream_reader_chunk(stream_reader * p_reader) : m_reader(p_reader), m_buffer_state(0), m_buffer_size(0), m_eof(false) {} + + t_size read(void * p_buffer,t_size p_bytes,abort_callback & p_abort); + + void flush(abort_callback & p_abort);//must be called after reading before object is destroyed + + static void g_skip(stream_reader * p_stream,abort_callback & p_abort); + +private: + stream_reader * m_reader; + t_size m_buffer_state, m_buffer_size; + bool m_eof; + unsigned char m_buffer[255]; +}; + +class stream_reader_dummy : public stream_reader { t_size read(void *,t_size,abort_callback &) override {return 0;} }; + + + + + + + + + + + + + + + + + + +template class stream_reader_formatter { +public: + stream_reader_formatter(stream_reader & p_stream,abort_callback & p_abort) : m_stream(p_stream), m_abort(p_abort) {} + + template void read_int(t_int & p_out) { + if (isBigEndian) m_stream.read_bendian_t(p_out,m_abort); + else m_stream.read_lendian_t(p_out,m_abort); + } + + void read_raw(void * p_buffer,t_size p_bytes) { + m_stream.read_object(p_buffer,p_bytes,m_abort); + } + + void skip(t_size p_bytes) {m_stream.skip_object(p_bytes,m_abort);} + + template void read_raw(TArray& data) { + pfc::assert_byte_type(); + read_raw(data.get_ptr(),data.get_size()); + } + template void read_byte_block(TArray & data) { + pfc::assert_byte_type(); + t_uint32 size; read_int(size); data.set_size(size); + read_raw(data); + } + template void read_array(TArray & data) { + t_uint32 size; *this >> size; data.set_size(size); + for(t_uint32 walk = 0; walk < size; ++walk) *this >> data[walk]; + } + void read_string_nullterm( pfc::string_base & ret ) { + m_stream.read_string_nullterm( ret, m_abort ); + } + pfc::string8 read_string_nullterm() { + pfc::string8 ret; this->read_string_nullterm(ret); return ret; + } + pfc::string8 read_string() { + return m_stream.read_string(m_abort); + } + stream_reader & m_stream; + abort_callback & m_abort; +}; + +template class stream_writer_formatter { +public: + stream_writer_formatter(stream_writer & p_stream,abort_callback & p_abort) : m_stream(p_stream), m_abort(p_abort) {} + + template void write_int(t_int p_int) { + if (isBigEndian) m_stream.write_bendian_t(p_int,m_abort); + else m_stream.write_lendian_t(p_int,m_abort); + } + + void write_raw(const void * p_buffer,t_size p_bytes) { + m_stream.write_object(p_buffer,p_bytes,m_abort); + } + template void write_raw(const TArray& data) { + pfc::assert_byte_type(); + write_raw(data.get_ptr(),data.get_size()); + } + + template void write_byte_block(const TArray& data) { + pfc::assert_byte_type(); + write_int( pfc::downcast_guarded(data.get_size()) ); + write_raw( data ); + } + template void write_array(const TArray& data) { + const t_uint32 size = pfc::downcast_guarded(data.get_size()); + *this << size; + for(t_uint32 walk = 0; walk < size; ++walk) *this << data[walk]; + } + + void write_string(const char * str) { + const t_size len = strlen(str); + *this << pfc::downcast_guarded(len); + write_raw(str, len); + } + void write_string(const char * str, t_size len_) { + const t_size len = pfc::strlen_max(str, len_); + *this << pfc::downcast_guarded(len); + write_raw(str, len); + } + void write_string_nullterm( const char * str ) { + this->write_raw( str, strlen(str)+1 ); + } + + stream_writer & m_stream; + abort_callback & m_abort; +}; + + +#define __DECLARE_INT_OVERLOADS(TYPE) \ + template inline stream_reader_formatter & operator>>(stream_reader_formatter & p_stream,TYPE & p_int) {typename pfc::sized_int_t::t_unsigned temp;p_stream.read_int(temp); p_int = (TYPE) temp; return p_stream;} \ + template inline stream_writer_formatter & operator<<(stream_writer_formatter & p_stream,TYPE p_int) {p_stream.write_int((typename pfc::sized_int_t::t_unsigned)p_int); return p_stream;} + +__DECLARE_INT_OVERLOADS(char); +__DECLARE_INT_OVERLOADS(signed char); +__DECLARE_INT_OVERLOADS(unsigned char); +__DECLARE_INT_OVERLOADS(signed short); +__DECLARE_INT_OVERLOADS(unsigned short); + +__DECLARE_INT_OVERLOADS(signed int); +__DECLARE_INT_OVERLOADS(unsigned int); + +__DECLARE_INT_OVERLOADS(signed long); +__DECLARE_INT_OVERLOADS(unsigned long); + +__DECLARE_INT_OVERLOADS(signed long long); +__DECLARE_INT_OVERLOADS(unsigned long long); + +__DECLARE_INT_OVERLOADS(wchar_t); + + +#undef __DECLARE_INT_OVERLOADS + +template class _IsTypeByte { +public: + enum {value = pfc::is_same_type::value || pfc::is_same_type::value || pfc::is_same_type::value}; +}; + +template stream_reader_formatter & operator>>(stream_reader_formatter & p_stream,TVal (& p_array)[Count]) { + if constexpr (_IsTypeByte::value) { + p_stream.read_raw(p_array,Count); + } else { + for(t_size walk = 0; walk < Count; ++walk) p_stream >> p_array[walk]; + } + return p_stream; +} + +template stream_writer_formatter & operator<<(stream_writer_formatter & p_stream,TVal const (& p_array)[Count]) { + if constexpr (_IsTypeByte::value) { + p_stream.write_raw(p_array,Count); + } else { + for(t_size walk = 0; walk < Count; ++walk) p_stream << p_array[walk]; + } + return p_stream; +} + +#define FB2K_STREAM_READER_OVERLOAD(type) \ + template stream_reader_formatter & operator>>(stream_reader_formatter & stream,type & value) + +#define FB2K_STREAM_WRITER_OVERLOAD(type) \ + template stream_writer_formatter & operator<<(stream_writer_formatter & stream,const type & value) + +FB2K_STREAM_READER_OVERLOAD(GUID) { + return stream >> value.Data1 >> value.Data2 >> value.Data3 >> value.Data4; +} + +FB2K_STREAM_WRITER_OVERLOAD(GUID) { + return stream << value.Data1 << value.Data2 << value.Data3 << value.Data4; +} + +FB2K_STREAM_READER_OVERLOAD(pfc::string) { + t_uint32 len; stream >> len; + value = stream.m_stream.read_string_ex(len,stream.m_abort); + return stream; +} + +FB2K_STREAM_WRITER_OVERLOAD(pfc::string) { + stream << pfc::downcast_guarded(value.length()); + stream.write_raw(value.ptr(),value.length()); + return stream; +} + +FB2K_STREAM_READER_OVERLOAD(pfc::string_base) { + stream.m_stream.read_string(value, stream.m_abort); + return stream; +} +FB2K_STREAM_WRITER_OVERLOAD(pfc::string_base) { + const char * val = value.get_ptr(); + const t_size len = strlen(val); + stream << pfc::downcast_guarded(len); + stream.write_raw(val,len); + return stream; +} + + +FB2K_STREAM_WRITER_OVERLOAD(float) { + union { + float f; t_uint32 i; + } u; u.f = value; + return stream << u.i; +} + +FB2K_STREAM_READER_OVERLOAD(float) { + union { float f; t_uint32 i;} u; + stream >> u.i; value = u.f; + return stream; +} + +FB2K_STREAM_WRITER_OVERLOAD(double) { + union { + double f; t_uint64 i; + } u; u.f = value; + return stream << u.i; +} + +FB2K_STREAM_READER_OVERLOAD(double) { + union { double f; t_uint64 i;} u; + stream >> u.i; value = u.f; + return stream; +} + +FB2K_STREAM_WRITER_OVERLOAD(bool) { + t_uint8 temp = value ? 1 : 0; + return stream << temp; +} +FB2K_STREAM_READER_OVERLOAD(bool) { + t_uint8 temp; stream >> temp; value = temp != 0; + return stream; +} + +template +class stream_writer_formatter_simple : public stream_writer_formatter { +public: + stream_writer_formatter_simple() : stream_writer_formatter(_m_stream,fb2k::noAbort), m_buffer(_m_stream.m_buffer) {} + + typedef stream_writer_buffer_simple::t_buffer t_buffer; + t_buffer & m_buffer; +private: + stream_writer_buffer_simple _m_stream; +}; + +template +class stream_reader_formatter_simple_ref : public stream_reader_formatter { +public: + stream_reader_formatter_simple_ref(const void * source, t_size sourceSize) : stream_reader_formatter(_m_stream,fb2k::noAbort), _m_stream(source,sourceSize) {} + template stream_reader_formatter_simple_ref(const TSource& source) : stream_reader_formatter(_m_stream,fb2k::noAbort), _m_stream(source) {} + stream_reader_formatter_simple_ref() : stream_reader_formatter(_m_stream,fb2k::noAbort) {} + + void set_data(const void * source, t_size sourceSize) {_m_stream.set_data(source,sourceSize);} + template void set_data(const TSource & source) {_m_stream.set_data(source);} + + void reset() {_m_stream.reset();} + t_size get_remaining() {return _m_stream.get_remaining();} + + const void * get_ptr_() const {return _m_stream.get_ptr_();} +private: + stream_reader_memblock_ref _m_stream; +}; + +template +class stream_reader_formatter_simple : public stream_reader_formatter_simple_ref { +public: + stream_reader_formatter_simple() {} + stream_reader_formatter_simple(const void * source, t_size sourceSize) {set_data(source,sourceSize);} + template stream_reader_formatter_simple(const TSource & source) {set_data(source);} + + void set_data(const void * source, t_size sourceSize) { + m_content.set_data_fromptr(reinterpret_cast(source), sourceSize); + onContentChange(); + } + template void set_data(const TSource & source) { + m_content = source; + onContentChange(); + } +private: + void onContentChange() { + stream_reader_formatter_simple_ref::set_data(m_content); + } + pfc::array_t m_content; +}; + + + + + + +template class _stream_reader_formatter_translator { +public: + _stream_reader_formatter_translator(stream_reader_formatter & stream) : m_stream(stream) {} + typedef _stream_reader_formatter_translator t_self; + template t_self & operator||(t_what & out) {m_stream >> out; return *this;} +private: + stream_reader_formatter & m_stream; +}; +template class _stream_writer_formatter_translator { +public: + _stream_writer_formatter_translator(stream_writer_formatter & stream) : m_stream(stream) {} + typedef _stream_writer_formatter_translator t_self; + template t_self & operator||(const t_what & in) {m_stream << in; return *this;} +private: + stream_writer_formatter & m_stream; +}; + +#define FB2K_STREAM_RECORD_OVERLOAD(type, code) \ + FB2K_STREAM_READER_OVERLOAD(type) { \ + _stream_reader_formatter_translator streamEx(stream); \ + streamEx || code; \ + return stream; \ + } \ + FB2K_STREAM_WRITER_OVERLOAD(type) { \ + _stream_writer_formatter_translator streamEx(stream); \ + streamEx || code; \ + return stream; \ + } + + + + +#define FB2K_RETRY_ON_EXCEPTION(OP, ABORT, TIMEOUT, EXCEPTION) \ + { \ + pfc::lores_timer timer; timer.start(); \ + for(;;) { \ + try { {OP;} break; } \ + catch(const EXCEPTION &) { if (timer.query() > TIMEOUT) throw;} \ + ABORT.sleep(0.05); \ + } \ + } + +#define FB2K_RETRY_ON_EXCEPTION2(OP, ABORT, TIMEOUT, EXCEPTION1, EXCEPTION2) \ + { \ + pfc::lores_timer timer; timer.start(); \ + for(;;) { \ + try { {OP;} break; } \ + catch(const EXCEPTION1 &) { if (timer.query() > TIMEOUT) throw;} \ + catch(const EXCEPTION2 &) { if (timer.query() > TIMEOUT) throw;} \ + ABORT.sleep(0.05); \ + } \ + } + +#define FB2K_RETRY_ON_EXCEPTION3(OP, ABORT, TIMEOUT, EXCEPTION1, EXCEPTION2, EXCEPTION3) \ + { \ + pfc::lores_timer timer; timer.start(); \ + for(;;) { \ + try { {OP;} break; } \ + catch(const EXCEPTION1 &) { if (timer.query() > TIMEOUT) throw;} \ + catch(const EXCEPTION2 &) { if (timer.query() > TIMEOUT) throw;} \ + catch(const EXCEPTION3 &) { if (timer.query() > TIMEOUT) throw;} \ + ABORT.sleep(0.05); \ + } \ + } + +#define FB2K_RETRY_ON_SHARING_VIOLATION(OP, ABORT, TIMEOUT) FB2K_RETRY_ON_EXCEPTION(OP, ABORT, TIMEOUT, exception_io_sharing_violation) + +// **** WINDOWS SUCKS **** +// File move ops must be retried on all these because you get access-denied when someone is holding open handles to something you're trying to move, or already-exists on something you just told Windows to move away +#define FB2K_RETRY_FILE_MOVE(OP, ABORT, TIMEOUT) FB2K_RETRY_ON_EXCEPTION3(OP, ABORT, TIMEOUT, exception_io_sharing_violation, exception_io_denied, exception_io_already_exists) + +class fileRestorePositionScope { +public: + fileRestorePositionScope(file::ptr f, abort_callback & a) : m_file(f), m_abort(a) { + m_offset = f->get_position(a); + } + ~fileRestorePositionScope() { + try { + if (!m_abort.is_aborting()) m_file->seek(m_offset, m_abort); + } catch(...) {} + } +private: + file::ptr m_file; + t_filesize m_offset; + abort_callback & m_abort; +}; + + +//! Debug self-test function for testing a file object implementation, performs various behavior validity checks, random access etc. Output goes to fb2k console. +//! Returns true on success, false on failure (buggy file object implementation). +bool fb2kFileSelfTest(file::ptr f, abort_callback & aborter); diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/filesystem_transacted.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/filesystem_transacted.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,8 @@ +#pragma once + +#include "filesystem.h" + +// Since 1.5, transacted filesystem is no longer supported +// as it adds extra complexity without actually solving any problems. +// Even Microsoft recommends not to use this API. +#define FB2K_SUPPORT_TRANSACTED_FILESYSTEM 0 diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/foobar2000-all.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/foobar2000-all.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,3 @@ +#pragma once +// Redirect to foobar2000.h +#include "foobar2000.h" diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/foobar2000-lite.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/foobar2000-lite.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,36 @@ +#pragma once + +#include "foobar2000-winver.h" + +#include "foobar2000-versions.h" + +#include "foobar2000-pfc.h" +#include "../shared/shared.h" + +#ifndef NOTHROW +#ifdef _MSC_VER +#define NOTHROW __declspec(nothrow) +#else +#define NOTHROW +#endif +#endif + +#define FB2KAPI /*NOTHROW*/ + +typedef const char* pcchar; + +#include "core_api.h" +#include "service.h" +#include "service_impl.h" +#include "service_by_guid.h" +#include "service_compat.h" + +#include "forward_types.h" + +#include "abort_callback.h" +#include "threadsLite.h" + +#include "playable_location.h" +#include "console.h" +#include "filesystem.h" +#include "metadb.h" diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/foobar2000-pfc.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/foobar2000-pfc.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,17 @@ +#pragma once + +#include "../../pfc/pfc.h" + +// These were in a global namespace before and are commonly referenced as such. +using pfc::bit_array; +using pfc::bit_array_var; +using pfc::bit_array_true; +using pfc::bit_array_false; +using pfc::bit_array_val; +using pfc::bit_array_bittable; +using pfc::bit_array_one; +using pfc::bit_array_range; +#ifdef _WIN32 +using pfc::LastErrorRevertScope; +#endif + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/foobar2000-sdk-pch.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/foobar2000-sdk-pch.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,2 @@ +#pragma once +#include "foobar2000-lite.h" diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/foobar2000-versions.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/foobar2000-versions.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,41 @@ +#pragma once +// foobar2000-versions.h +// foobar2000 SDK version and target API levels are declared in this header + +#ifdef _WIN32 +// Windows + +// This SDK does NOT SUPPORT targets older than API 80 / foobar2000 v1.5 +#define FOOBAR2000_TARGET_VERSION 80 // 1.5, 1.6 +// #define FOOBAR2000_TARGET_VERSION 81 // 2.0 + + +#ifdef _M_IX86 +#define FOOBAR2000_TARGET_VERSION_COMPATIBLE 72 +#else +// x64 & ARM64 targets +// Allow components made with special foobar2000 v1.6 SDK with x64 & ARM64 targets +#define FOOBAR2000_TARGET_VERSION_COMPATIBLE 80 +#endif + + +#else // _WIN32 +// Not Windows +#define FOOBAR2000_TARGET_VERSION 81 +#define FOOBAR2000_TARGET_VERSION_COMPATIBLE 81 +#endif // _WIN32 + +// Can safely use foobar2000 v2.0 features? +#define FOOBAR2020 (FOOBAR2000_TARGET_VERSION>=81) + + +// Use this to determine what foobar2000 SDK version is in use, undefined for releases older than 2018 +#define FOOBAR2000_SDK_VERSION 20241203 + +// cfg_var downgrade support, experimental, intended for specific components only. +// Allows new style configStore data to be imported back to old foobar2000 friendly cfg_vars. +// Intended to retain config when reverting FOOBAR2000_TARGET_VERSION value of 81 or newer to 80. +// Takes effect with FOOBAR2000_TARGET_VERSION 80 only. +// Place FOOBAR2000_IMPLEMENT_CFG_VAR_DOWNGRADE somewhere in your code to declare init calls for cfg_var downgrade. Or, if you wish to call manually, call cfg_var_reader::downgrade_main() before accessing your cfg_vars. +// Spurious calls to cfg_var_reader::downgrade_main() will be ignored, only first one will take effect. +#define FOOBAR2000_SUPPORT_CFG_VAR_DOWNGRADE 0 \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/foobar2000-winver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/foobar2000-winver.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,31 @@ +#pragma once + +#define FOOBAR2000_DESKTOP + +#define FOOBAR2000_HAVE_FILE_FORMAT_SANITIZER +#define FOOBAR2000_HAVE_CHAPTERIZER +#define FOOBAR2000_HAVE_ALBUM_ART +#define FOOBAR2000_DECLARE_FILE_TYPES +#define FOOBAR2000_HAVE_DSP +#define FOOBAR2000_HAVE_CONSOLE +#define FOOBAR2000_INTERACTIVE +#define FOOBAR2000_HAVE_METADB + + +#ifdef _WIN32 +#define FOOBAR2000_HAVE_CFG_VAR_LEGACY +#define FOOBAR2000_WINAPI_CLASSIC +#define FOOBAR2000_DESKTOP_WINDOWS +#define FOOBAR2000_DESKTOP_WINDOWS_OR_BOOM +#define FOOBAR2000_SUPPORT_DLLS 1 +#define FOOBAR2000_HAVE_KEYBOARD_SHORTCUTS +#endif + +#ifdef __APPLE__ +#define FOOBAR2000_SUPPORT_DLLS 1 +#define FOOBAR2000_MAC +#endif + +#ifndef FOOBAR2000_SUPPORT_DLLS +#define FOOBAR2000_SUPPORT_DLLS 0 +#endif diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/foobar2000.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/foobar2000.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,123 @@ +// This is the master foobar2000 SDK header file; it includes headers for all functionality exposed through the SDK project. +// For historical reasons, this #includes everything from the SDK. +// In new code, it is recommended to #include "foobar2000-lite.h" then any other headers on need-to-use basis. + +#ifndef _FOOBAR2000_H_ +#define _FOOBAR2000_H_ + +#include "foobar2000-lite.h" + +#include "completion_notify.h" +#include "abort_callback.h" +#include "componentversion.h" +#include "preferences_page.h" +#include "coreversion.h" +#include "filesystem.h" +#include "filesystem_transacted.h" +#include "archive.h" +#include "audio_chunk.h" +#include "mem_block_container.h" +#include "audio_postprocessor.h" +#include "playable_location.h" +#include "file_info.h" +#include "file_info_impl.h" +#include "hasher_md5.h" +#include "metadb_handle.h" +#include "metadb.h" +#include "metadb_index.h" +#include "metadb_display_field_provider.h" +#include "metadb_callbacks.h" +#include "file_info_filter.h" +#include "console.h" +#include "dsp.h" +#include "dsp_manager.h" +#include "initquit.h" +#include "event_logger.h" +#include "input.h" +#include "input_impl.h" +#include "menu.h" +#include "contextmenu.h" +#include "contextmenu_manager.h" +#include "menu_helpers.h" +#include "modeless_dialog.h" +#include "playback_control.h" +#include "play_callback.h" +#include "playlist.h" +#include "playlist_loader.h" +#include "replaygain.h" +#include "resampler.h" +#include "tag_processor.h" +#include "titleformat.h" +#include "ui.h" +#include "unpack.h" +#include "packet_decoder.h" +#include "commandline.h" +#include "genrand.h" +#include "file_operation_callback.h" +#include "library_manager.h" +#include "library_callbacks.h" +#include "config_io_callback.h" +#include "popup_message.h" +#include "app_close_blocker.h" +#include "config_object.h" +#include "threaded_process.h" +#include "input_file_type.h" +#include "main_thread_callback.h" +#include "advconfig.h" +#include "track_property.h" + +#include "album_art.h" +#include "album_art_helpers.h" +#include "icon_remap.h" +#include "search_tools.h" +#include "autoplaylist.h" +#include "replaygain_scanner.h" + +#include "system_time_keeper.h" +#include "http_client.h" +#include "exceptions.h" + +#include "progress_meter.h" + +#include "commonObjects.h" + +#include "file_lock_manager.h" + +#include "configStore.h" + +#include "timer.h" + +#include "cfg_var.h" +#include "advconfig_impl.h" + + +#include "playlistColumnProvider.h" +#include "threadPool.h" +#include "powerManager.h" +#include "keyValueIO.h" +#include "audioEncoder.h" +#include "decode_postprocessor.h" +#include "file_format_sanitizer.h" +#include "imageLoaderLite.h" +#include "imageViewer.h" +#include "playback_stream_capture.h" +#include "message_loop.h" +#include "chapterizer.h" +#include "info_lookup_handler.h" +#include "output.h" +#include "link_resolver.h" +#include "image.h" +#include "fileDialog.h" +#include "console_manager.h" +#include "vis.h" +#include "ole_interaction.h" +#include "library_index.h" +#include "ui_element.h" +#include "ui_edit_context.h" +#include "toolbarDropDown.h" + +#include "commonObjects-Apple.h" +#include "ui_element_mac.h" + +#endif //_FOOBAR2000_H_ + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/foobar2000_SDK.vcxproj --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/foobar2000_SDK.vcxproj Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,591 @@ + + + + + Debug + ARM64 + + + Debug + ARM64EC + + + Debug + Win32 + + + Debug + x64 + + + Release + ARM64 + + + Release + ARM64EC + + + Release + Win32 + + + Release + x64 + + + + {E8091321-D79D-4575-86EF-064EA1A4A20D} + foobar2000_SDK + 10.0 + + + + StaticLibrary + false + Unicode + true + v142 + + + StaticLibrary + false + Unicode + true + v142 + + + StaticLibrary + false + Unicode + true + v143 + + + StaticLibrary + false + Unicode + true + v143 + + + StaticLibrary + false + Unicode + v142 + + + StaticLibrary + false + Unicode + v142 + + + StaticLibrary + false + Unicode + v143 + + + StaticLibrary + false + Unicode + v143 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + + + + Disabled + EnableFastChecks + Use + foobar2000-sdk-pch.h + Level3 + true + ProgramDatabase + MultiThreadedDebugDLL + 4715 + true + ..;..\.. + true + stdcpp17 + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + + + + + Disabled + EnableFastChecks + Use + foobar2000-sdk-pch.h + Level3 + true + ProgramDatabase + MultiThreadedDebugDLL + 4715 + true + ..;..\.. + true + stdcpp17 + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + + + + + Disabled + EnableFastChecks + Use + foobar2000-sdk-pch.h + Level3 + true + ProgramDatabase + MultiThreadedDebugDLL + 4715 + true + ..;..\.. + true + stdcpp17 + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + + + + + Disabled + EnableFastChecks + Use + foobar2000-sdk-pch.h + Level3 + true + ProgramDatabase + MultiThreadedDebugDLL + 4715 + true + ..;..\.. + true + stdcpp17 + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + + + + + MinSpace + true + false + Fast + false + Use + foobar2000-sdk-pch.h + Level3 + true + ProgramDatabase + MultiThreadedDLL + /d2notypeopt %(AdditionalOptions) + 4715 + true + true + true + NDEBUG;_UNICODE;UNICODE;%(PreprocessorDefinitions) + ..;..\.. + true + stdcpp17 + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + + + + + MinSpace + true + false + Fast + false + Use + foobar2000-sdk-pch.h + Level3 + true + ProgramDatabase + MultiThreadedDLL + /d2notypeopt %(AdditionalOptions) + 4715 + true + true + true + NDEBUG;_UNICODE;UNICODE;%(PreprocessorDefinitions) + ..;..\.. + true + stdcpp17 + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + + + + + MinSpace + true + false + Fast + false + Use + foobar2000-sdk-pch.h + Level3 + true + ProgramDatabase + MultiThreadedDLL + /d2notypeopt %(AdditionalOptions) + 4715 + true + true + true + NDEBUG;_UNICODE;UNICODE;%(PreprocessorDefinitions) + ..;..\.. + true + stdcpp17 + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + + + + + MinSpace + true + false + Fast + false + Use + foobar2000-sdk-pch.h + Level3 + true + ProgramDatabase + MultiThreadedDLL + /d2notypeopt %(AdditionalOptions) + 4715 + true + true + true + NDEBUG;_UNICODE;UNICODE;%(PreprocessorDefinitions) + ..;..\.. + true + stdcpp17 + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Create + Create + Create + Create + Create + Create + Create + Create + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/foobar2000_SDK.vcxproj.filters --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/foobar2000_SDK.vcxproj.filters Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,608 @@ + + + + + {6c35c7a7-723a-401f-acdc-c63af942abae} + *.h + + + {3b2ccd60-8f0c-4241-830a-fda069a5d440} + *.cpp + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/foobar2000_SDK.xcodeproj/project.pbxproj --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/foobar2000_SDK.xcodeproj/project.pbxproj Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,1115 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 54; + objects = { + +/* Begin PBXBuildFile section */ + 0F75F4942A6B1CA800A45078 /* foosort.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F3C82A6B1CA000A45078 /* foosort.cpp */; }; + 0F75F4952A6B1CA800A45078 /* genrand.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F3C92A6B1CA000A45078 /* genrand.h */; }; + 0F75F4962A6B1CA800A45078 /* ui_element_typable_window_manager.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F3CA2A6B1CA000A45078 /* ui_element_typable_window_manager.h */; }; + 0F75F4972A6B1CA800A45078 /* titleformat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F3CB2A6B1CA000A45078 /* titleformat.cpp */; }; + 0F75F4982A6B1CA800A45078 /* file_info_merge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F3CC2A6B1CA000A45078 /* file_info_merge.cpp */; }; + 0F75F4992A6B1CA800A45078 /* audio_chunk.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F3CD2A6B1CA000A45078 /* audio_chunk.h */; }; + 0F75F49A2A6B1CA800A45078 /* output.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F3CE2A6B1CA000A45078 /* output.h */; }; + 0F75F49B2A6B1CA800A45078 /* file_operation_callback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F3CF2A6B1CA000A45078 /* file_operation_callback.cpp */; }; + 0F75F49C2A6B1CA800A45078 /* abort_callback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F3D02A6B1CA000A45078 /* abort_callback.cpp */; }; + 0F75F49D2A6B1CA800A45078 /* playlist_loader.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F3D12A6B1CA000A45078 /* playlist_loader.h */; }; + 0F75F49E2A6B1CA800A45078 /* threaded_process.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F3D22A6B1CA000A45078 /* threaded_process.h */; }; + 0F75F49F2A6B1CA800A45078 /* service_impl.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F3D32A6B1CA000A45078 /* service_impl.h */; }; + 0F75F4A02A6B1CA800A45078 /* main_thread_callback.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F3D42A6B1CA000A45078 /* main_thread_callback.h */; }; + 0F75F4A12A6B1CA800A45078 /* filesystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F3D52A6B1CA000A45078 /* filesystem.cpp */; }; + 0F75F4A22A6B1CA800A45078 /* stdafx.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F3D62A6B1CA000A45078 /* stdafx.cpp */; }; + 0F75F4A32A6B1CA800A45078 /* progress_meter.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F3D72A6B1CA000A45078 /* progress_meter.h */; }; + 0F75F4A42A6B1CA800A45078 /* app_close_blocker.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F3D82A6B1CA000A45078 /* app_close_blocker.h */; }; + 0F75F4A52A6B1CA800A45078 /* mem_block_container.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F3D92A6B1CA000A45078 /* mem_block_container.cpp */; }; + 0F75F4A62A6B1CA800A45078 /* filesystem.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F3DA2A6B1CA000A45078 /* filesystem.h */; }; + 0F75F4A72A6B1CA800A45078 /* commonObjects.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F3DB2A6B1CA000A45078 /* commonObjects.cpp */; }; + 0F75F4A82A6B1CA800A45078 /* threadPool.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F3DC2A6B1CA000A45078 /* threadPool.h */; }; + 0F75F4A92A6B1CA800A45078 /* noInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F3DD2A6B1CA000A45078 /* noInfo.h */; }; + 0F75F4AA2A6B1CA800A45078 /* unpack.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F3DE2A6B1CA000A45078 /* unpack.h */; }; + 0F75F4AB2A6B1CA800A45078 /* output.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F3DF2A6B1CA000A45078 /* output.cpp */; }; + 0F75F4AC2A6B1CA800A45078 /* menu_helpers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F3E02A6B1CA000A45078 /* menu_helpers.cpp */; }; + 0F75F4AD2A6B1CA800A45078 /* service.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F3E12A6B1CA000A45078 /* service.h */; }; + 0F75F4AE2A6B1CA800A45078 /* file_info_const_impl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F3E22A6B1CA100A45078 /* file_info_const_impl.cpp */; }; + 0F75F4AF2A6B1CA800A45078 /* chapterizer.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F3E32A6B1CA100A45078 /* chapterizer.h */; }; + 0F75F4B02A6B1CA800A45078 /* audio_chunk_impl.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F3E42A6B1CA100A45078 /* audio_chunk_impl.h */; }; + 0F75F4B12A6B1CA800A45078 /* audio_chunk_channel_config.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F3E52A6B1CA100A45078 /* audio_chunk_channel_config.cpp */; }; + 0F75F4B22A6B1CA800A45078 /* event_logger.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F3E62A6B1CA100A45078 /* event_logger.h */; }; + 0F75F4B32A6B1CA800A45078 /* foobar2000-pfc.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F3E72A6B1CA100A45078 /* foobar2000-pfc.h */; }; + 0F75F4B42A6B1CA800A45078 /* http_client.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F3E82A6B1CA100A45078 /* http_client.h */; }; + 0F75F4B52A6B1CA800A45078 /* hasher_md5.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F3E92A6B1CA100A45078 /* hasher_md5.h */; }; + 0F75F4B62A6B1CA800A45078 /* component.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F3EA2A6B1CA100A45078 /* component.h */; }; + 0F75F4B72A6B1CA800A45078 /* forward_types.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F3EB2A6B1CA100A45078 /* forward_types.h */; }; + 0F75F4B82A6B1CA800A45078 /* replaygain.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F3EC2A6B1CA100A45078 /* replaygain.h */; }; + 0F75F4B92A6B1CA800A45078 /* metadb.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F3ED2A6B1CA100A45078 /* metadb.h */; }; + 0F75F4BA2A6B1CA800A45078 /* menu_manager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F3EE2A6B1CA100A45078 /* menu_manager.cpp */; }; + 0F75F4BB2A6B1CA800A45078 /* resampler.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F3EF2A6B1CA100A45078 /* resampler.h */; }; + 0F75F4BC2A6B1CA800A45078 /* initquit.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F3F02A6B1CA100A45078 /* initquit.h */; }; + 0F75F4BD2A6B1CA800A45078 /* foobar2000-winver.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F3F12A6B1CA100A45078 /* foobar2000-winver.h */; }; + 0F75F4BE2A6B1CA800A45078 /* timer.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F3F22A6B1CA100A45078 /* timer.h */; }; + 0F75F4BF2A6B1CA800A45078 /* playlist.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F3F32A6B1CA100A45078 /* playlist.h */; }; + 0F75F4C02A6B1CA800A45078 /* track_property.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F3F42A6B1CA100A45078 /* track_property.cpp */; }; + 0F75F4C12A6B1CA800A45078 /* ui.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F3F52A6B1CA100A45078 /* ui.cpp */; }; + 0F75F4C22A6B1CA800A45078 /* titleformat.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F3F62A6B1CA100A45078 /* titleformat.h */; }; + 0F75F4C32A6B1CA800A45078 /* file_info_impl.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F3F72A6B1CA100A45078 /* file_info_impl.h */; }; + 0F75F4C42A6B1CA800A45078 /* filesystem_helper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F3F82A6B1CA100A45078 /* filesystem_helper.cpp */; }; + 0F75F4C52A6B1CA800A45078 /* filesystem_helper.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F3F92A6B1CA100A45078 /* filesystem_helper.h */; }; + 0F75F4C62A6B1CA800A45078 /* audio_chunk.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F3FA2A6B1CA100A45078 /* audio_chunk.cpp */; }; + 0F75F4C72A6B1CA800A45078 /* console_manager.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F3FB2A6B1CA100A45078 /* console_manager.h */; }; + 0F75F4C82A6B1CA800A45078 /* filesystem_transacted.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F3FC2A6B1CA100A45078 /* filesystem_transacted.h */; }; + 0F75F4C92A6B1CA800A45078 /* service.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F3FD2A6B1CA100A45078 /* service.cpp */; }; + 0F75F4CA2A6B1CA800A45078 /* threaded_process.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F3FE2A6B1CA200A45078 /* threaded_process.cpp */; }; + 0F75F4CB2A6B1CA800A45078 /* coreDarkMode.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F3FF2A6B1CA200A45078 /* coreDarkMode.h */; }; + 0F75F4CC2A6B1CA800A45078 /* cfg_var_legacy.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4002A6B1CA200A45078 /* cfg_var_legacy.h */; }; + 0F75F4CD2A6B1CA800A45078 /* menu.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4012A6B1CA200A45078 /* menu.h */; }; + 0F75F4CE2A6B1CA800A45078 /* file_info_filter_impl.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4022A6B1CA200A45078 /* file_info_filter_impl.h */; }; + 0F75F4CF2A6B1CA800A45078 /* advconfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F4032A6B1CA200A45078 /* advconfig.cpp */; }; + 0F75F4D02A6B1CA800A45078 /* packet_decoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4042A6B1CA200A45078 /* packet_decoder.h */; }; + 0F75F4D12A6B1CA800A45078 /* decode_postprocessor.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4052A6B1CA200A45078 /* decode_postprocessor.h */; }; + 0F75F4D22A6B1CA800A45078 /* exception_io.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4062A6B1CA200A45078 /* exception_io.h */; }; + 0F75F4D32A6B1CA800A45078 /* search_tools.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4072A6B1CA200A45078 /* search_tools.h */; }; + 0F75F4D42A6B1CA800A45078 /* metadb_callbacks.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4082A6B1CA200A45078 /* metadb_callbacks.h */; }; + 0F75F4D52A6B1CA800A45078 /* configStore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F4092A6B1CA200A45078 /* configStore.cpp */; }; + 0F75F4D62A6B1CA800A45078 /* modeless_dialog.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F40A2A6B1CA200A45078 /* modeless_dialog.h */; }; + 0F75F4D72A6B1CA800A45078 /* foosort.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F40B2A6B1CA200A45078 /* foosort.h */; }; + 0F75F4D82A6B1CA800A45078 /* console.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F40C2A6B1CA200A45078 /* console.cpp */; }; + 0F75F4D92A6B1CA800A45078 /* playback_control.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F40D2A6B1CA200A45078 /* playback_control.h */; }; + 0F75F4DA2A6B1CA800A45078 /* playback_stream_capture.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F40E2A6B1CA200A45078 /* playback_stream_capture.h */; }; + 0F75F4DB2A6B1CA800A45078 /* file_info.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F40F2A6B1CA200A45078 /* file_info.cpp */; }; + 0F75F4DC2A6B1CA800A45078 /* dsp.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4102A6B1CA200A45078 /* dsp.h */; }; + 0F75F4DD2A6B1CA800A45078 /* library_callbacks.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4112A6B1CA200A45078 /* library_callbacks.h */; }; + 0F75F4DE2A6B1CA800A45078 /* threadsLite.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4122A6B1CA200A45078 /* threadsLite.h */; }; + 0F75F4DF2A6B1CA800A45078 /* mem_block_container.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4132A6B1CA200A45078 /* mem_block_container.h */; }; + 0F75F4E02A6B1CA800A45078 /* foobar2000-all.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4142A6B1CA200A45078 /* foobar2000-all.h */; }; + 0F75F4E12A6B1CA800A45078 /* image.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F4152A6B1CA200A45078 /* image.cpp */; }; + 0F75F4E22A6B1CA800A45078 /* utility.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F4162A6B1CA200A45078 /* utility.cpp */; }; + 0F75F4E32A6B1CA800A45078 /* track_property.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4172A6B1CA200A45078 /* track_property.h */; }; + 0F75F4E42A6B1CA800A45078 /* cfg_var.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F4182A6B1CA200A45078 /* cfg_var.cpp */; }; + 0F75F4E52A6B1CA800A45078 /* shortcut_actions.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4192A6B1CA200A45078 /* shortcut_actions.h */; }; + 0F75F4E72A6B1CA800A45078 /* exceptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F41B2A6B1CA200A45078 /* exceptions.h */; }; + 0F75F4E82A6B1CA800A45078 /* component_client.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F41C2A6B1CA200A45078 /* component_client.h */; }; + 0F75F4E92A6B1CA800A45078 /* playable_location.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F41D2A6B1CA200A45078 /* playable_location.cpp */; }; + 0F75F4EA2A6B1CA800A45078 /* metadb.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F41E2A6B1CA200A45078 /* metadb.cpp */; }; + 0F75F4EB2A6B1CA800A45078 /* input_impl.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F41F2A6B1CA200A45078 /* input_impl.h */; }; + 0F75F4EC2A6B1CA800A45078 /* service_compat.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4202A6B1CA200A45078 /* service_compat.h */; }; + 0F75F4ED2A6B1CA800A45078 /* keyValueIO.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4212A6B1CA300A45078 /* keyValueIO.h */; }; + 0F75F4EE2A6B1CA800A45078 /* tracks.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4222A6B1CA300A45078 /* tracks.h */; }; + 0F75F4EF2A6B1CA800A45078 /* playlistColumnProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4232A6B1CA300A45078 /* playlistColumnProvider.h */; }; + 0F75F4F02A6B1CA800A45078 /* imageLoaderLite.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4242A6B1CA300A45078 /* imageLoaderLite.h */; }; + 0F75F4F12A6B1CA800A45078 /* playlist.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F4252A6B1CA300A45078 /* playlist.cpp */; }; + 0F75F4F22A6B1CA800A45078 /* preferences_page.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F4262A6B1CA300A45078 /* preferences_page.cpp */; }; + 0F75F4F32A6B1CA800A45078 /* config_io_callback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F4272A6B1CA300A45078 /* config_io_callback.cpp */; }; + 0F75F4F42A6B1CA800A45078 /* packet_decoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F4282A6B1CA300A45078 /* packet_decoder.cpp */; }; + 0F75F4F52A6B1CA800A45078 /* ole_interaction.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4292A6B1CA300A45078 /* ole_interaction.h */; }; + 0F75F4F62A6B1CA800A45078 /* info_lookup_handler.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F42A2A6B1CA300A45078 /* info_lookup_handler.h */; }; + 0F75F4F72A6B1CA800A45078 /* library_index.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F42B2A6B1CA300A45078 /* library_index.h */; }; + 0F75F4F82A6B1CA800A45078 /* audioEncoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F42C2A6B1CA300A45078 /* audioEncoder.h */; }; + 0F75F4F92A6B1CA800A45078 /* commandline.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F42D2A6B1CA300A45078 /* commandline.cpp */; }; + 0F75F4FA2A6B1CA800A45078 /* image.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F42E2A6B1CA300A45078 /* image.h */; }; + 0F75F4FB2A6B1CA800A45078 /* link_resolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F42F2A6B1CA300A45078 /* link_resolver.cpp */; }; + 0F75F4FC2A6B1CA800A45078 /* metadb_handle.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4302A6B1CA300A45078 /* metadb_handle.h */; }; + 0F75F4FD2A6B1CA800A45078 /* advconfig_impl.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4312A6B1CA300A45078 /* advconfig_impl.h */; }; + 0F75F4FE2A6B1CA800A45078 /* foobar2000-versions.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4322A6B1CA300A45078 /* foobar2000-versions.h */; }; + 0F75F4FF2A6B1CA800A45078 /* componentversion.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4332A6B1CA300A45078 /* componentversion.h */; }; + 0F75F5002A6B1CA800A45078 /* contextmenu.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4342A6B1CA300A45078 /* contextmenu.h */; }; + 0F75F5012A6B1CA800A45078 /* advconfig_impl_legacy.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4352A6B1CA300A45078 /* advconfig_impl_legacy.h */; }; + 0F75F5022A6B1CA800A45078 /* file.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4362A6B1CA300A45078 /* file.h */; }; + 0F75F5032A6B1CA800A45078 /* ui_element.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F4372A6B1CA300A45078 /* ui_element.cpp */; }; + 0F75F5042A6B1CA800A45078 /* guids.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F4382A6B1CA300A45078 /* guids.cpp */; }; + 0F75F5052A6B1CA800A45078 /* tag_processor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F4392A6B1CA300A45078 /* tag_processor.cpp */; }; + 0F75F5062A6B1CA800A45078 /* config_object.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F43A2A6B1CA300A45078 /* config_object.h */; }; + 0F75F5072A6B1CA800A45078 /* config_object.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F43B2A6B1CA300A45078 /* config_object.cpp */; }; + 0F75F5082A6B1CA800A45078 /* ui.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F43C2A6B1CA300A45078 /* ui.h */; }; + 0F75F5092A6B1CA800A45078 /* link_resolver.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F43D2A6B1CA300A45078 /* link_resolver.h */; }; + 0F75F50A2A6B1CA800A45078 /* playable_location.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F43E2A6B1CA300A45078 /* playable_location.h */; }; + 0F75F50B2A6B1CA800A45078 /* file_lock_manager.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F43F2A6B1CA300A45078 /* file_lock_manager.h */; }; + 0F75F50C2A6B1CA800A45078 /* configStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4402A6B1CA300A45078 /* configStore.h */; }; + 0F75F50D2A6B1CA800A45078 /* input.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F4412A6B1CA300A45078 /* input.cpp */; }; + 0F75F50E2A6B1CA800A45078 /* contextmenu_manager.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4422A6B1CA300A45078 /* contextmenu_manager.h */; }; + 0F75F50F2A6B1CA800A45078 /* config_io_callback.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4432A6B1CA400A45078 /* config_io_callback.h */; }; + 0F75F5102A6B1CA800A45078 /* menu_common.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4442A6B1CA400A45078 /* menu_common.h */; }; + 0F75F5112A6B1CA800A45078 /* completion_notify.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F4452A6B1CA400A45078 /* completion_notify.cpp */; }; + 0F75F5122A6B1CA800A45078 /* metadb_info_container_impl.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4462A6B1CA400A45078 /* metadb_info_container_impl.h */; }; + 0F75F5132A6B1CA800A45078 /* abort_callback.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4472A6B1CA400A45078 /* abort_callback.h */; }; + 0F75F5142A6B1CA800A45078 /* completion_notify.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4482A6B1CA400A45078 /* completion_notify.h */; }; + 0F75F5152A6B1CA800A45078 /* toolbarDropDown.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4492A6B1CA400A45078 /* toolbarDropDown.h */; }; + 0F75F5162A6B1CA800A45078 /* dsp_manager.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F44A2A6B1CA400A45078 /* dsp_manager.h */; }; + 0F75F5172A6B1CA800A45078 /* messageBox.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F44B2A6B1CA400A45078 /* messageBox.h */; }; + 0F75F5182A6B1CA800A45078 /* ui_edit_context.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F44C2A6B1CA400A45078 /* ui_edit_context.h */; }; + 0F75F5192A6B1CA800A45078 /* ui_element.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F44D2A6B1CA400A45078 /* ui_element.h */; }; + 0F75F51A2A6B1CA800A45078 /* menu_item.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F44E2A6B1CA400A45078 /* menu_item.cpp */; }; + 0F75F51B2A6B1CA800A45078 /* callback_merit.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F44F2A6B1CA400A45078 /* callback_merit.h */; }; + 0F75F51C2A6B1CA800A45078 /* foosortstring.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4502A6B1CA400A45078 /* foosortstring.h */; }; + 0F75F51D2A6B1CA800A45078 /* imageViewer.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4512A6B1CA400A45078 /* imageViewer.h */; }; + 0F75F51E2A6B1CA800A45078 /* popup_message.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F4522A6B1CA400A45078 /* popup_message.cpp */; }; + 0F75F51F2A6B1CA800A45078 /* fsItem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F4532A6B1CA400A45078 /* fsItem.cpp */; }; + 0F75F5202A6B1CA800A45078 /* cfg_var_legacy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F4542A6B1CA400A45078 /* cfg_var_legacy.cpp */; }; + 0F75F5212A6B1CA800A45078 /* vis.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4552A6B1CA500A45078 /* vis.h */; }; + 0F75F5222A6B1CA800A45078 /* console.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4562A6B1CA500A45078 /* console.h */; }; + 0F75F5232A6B1CA800A45078 /* componentversion.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F4572A6B1CA500A45078 /* componentversion.cpp */; }; + 0F75F5242A6B1CA800A45078 /* chapterizer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F4582A6B1CA500A45078 /* chapterizer.cpp */; }; + 0F75F5252A6B1CA800A45078 /* components_menu.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4592A6B1CA500A45078 /* components_menu.h */; }; + 0F75F5262A6B1CA800A45078 /* metadb_handle_list.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F45A2A6B1CA500A45078 /* metadb_handle_list.cpp */; }; + 0F75F5272A6B1CA800A45078 /* preferences_page.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F45B2A6B1CA500A45078 /* preferences_page.h */; }; + 0F75F5282A6B1CA800A45078 /* core_api.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F45C2A6B1CA500A45078 /* core_api.h */; }; + 0F75F5292A6B1CA800A45078 /* config_object_impl.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F45D2A6B1CA500A45078 /* config_object_impl.h */; }; + 0F75F52A2A6B1CA800A45078 /* configCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F45E2A6B1CA500A45078 /* configCache.h */; }; + 0F75F52B2A6B1CA800A45078 /* metadb_display_field_provider.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F45F2A6B1CA500A45078 /* metadb_display_field_provider.h */; }; + 0F75F52C2A6B1CA800A45078 /* dsp-frontend.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4602A6B1CA500A45078 /* dsp-frontend.h */; }; + 0F75F52D2A6B1CA800A45078 /* foobar2000-sdk-pch.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4612A6B1CA500A45078 /* foobar2000-sdk-pch.h */; }; + 0F75F52E2A6B1CA800A45078 /* file_cached_impl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F4622A6B1CA500A45078 /* file_cached_impl.cpp */; }; + 0F75F52F2A6B1CA800A45078 /* replaygain_info.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F4632A6B1CA500A45078 /* replaygain_info.cpp */; }; + 0F75F5302A6B1CA800A45078 /* metadb_index.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4642A6B1CA500A45078 /* metadb_index.h */; }; + 0F75F5312A6B1CA800A45078 /* mainmenu.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F4652A6B1CA500A45078 /* mainmenu.cpp */; }; + 0F75F5322A6B1CA800A45078 /* app_close_blocker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F4662A6B1CA500A45078 /* app_close_blocker.cpp */; }; + 0F75F5332A6B1CA800A45078 /* file_info_impl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F4672A6B1CA500A45078 /* file_info_impl.cpp */; }; + 0F75F5342A6B1CA800A45078 /* tag_processor_id3v2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F4682A6B1CA500A45078 /* tag_processor_id3v2.cpp */; }; + 0F75F5352A6B1CA800A45078 /* audio_postprocessor.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4692A6B1CA500A45078 /* audio_postprocessor.h */; }; + 0F75F5362A6B1CA800A45078 /* file_info.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F46A2A6B1CA500A45078 /* file_info.h */; }; + 0F75F5372A6B1CA800A45078 /* replaygain.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F46B2A6B1CA500A45078 /* replaygain.cpp */; }; + 0F75F5382A6B1CA800A45078 /* input.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F46C2A6B1CA500A45078 /* input.h */; }; + 0F75F5392A6B1CA800A45078 /* file_format_sanitizer.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F46D2A6B1CA600A45078 /* file_format_sanitizer.h */; }; + 0F75F53A2A6B1CA800A45078 /* commonObjects.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F46E2A6B1CA600A45078 /* commonObjects.h */; }; + 0F75F53B2A6B1CA800A45078 /* powerManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F46F2A6B1CA600A45078 /* powerManager.h */; }; + 0F75F53C2A6B1CA800A45078 /* popup_message.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4702A6B1CA600A45078 /* popup_message.h */; }; + 0F75F53D2A6B1CA800A45078 /* archive.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4712A6B1CA600A45078 /* archive.h */; }; + 0F75F53E2A6B1CA800A45078 /* system_time_keeper.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4722A6B1CA600A45078 /* system_time_keeper.h */; }; + 0F75F53F2A6B1CA800A45078 /* play_callback.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4732A6B1CA600A45078 /* play_callback.h */; }; + 0F75F5402A6B1CA800A45078 /* file_info_const_impl.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4742A6B1CA600A45078 /* file_info_const_impl.h */; }; + 0F75F5412A6B1CA800A45078 /* file_operation_callback.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4752A6B1CA600A45078 /* file_operation_callback.h */; }; + 0F75F5422A6B1CA800A45078 /* album_art.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F4762A6B1CA600A45078 /* album_art.cpp */; }; + 0F75F5432A6B1CA800A45078 /* main_thread_callback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F4772A6B1CA600A45078 /* main_thread_callback.cpp */; }; + 0F75F5442A6B1CA800A45078 /* replaygain_scanner.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4782A6B1CA600A45078 /* replaygain_scanner.h */; }; + 0F75F5452A6B1CA800A45078 /* tag_processor.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4792A6B1CA600A45078 /* tag_processor.h */; }; + 0F75F5462A6B1CA800A45078 /* input_file_type.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F47A2A6B1CA700A45078 /* input_file_type.cpp */; }; + 0F75F5472A6B1CA800A45078 /* album_art.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F47B2A6B1CA700A45078 /* album_art.h */; }; + 0F75F5482A6B1CA800A45078 /* advconfig.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F47C2A6B1CA700A45078 /* advconfig.h */; }; + 0F75F5492A6B1CA800A45078 /* fsitem.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F47D2A6B1CA700A45078 /* fsitem.h */; }; + 0F75F54A2A6B1CA800A45078 /* icon_remap.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F47E2A6B1CA700A45078 /* icon_remap.h */; }; + 0F75F54B2A6B1CA800A45078 /* keyValueIOimpl.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F47F2A6B1CA700A45078 /* keyValueIOimpl.h */; }; + 0F75F54C2A6B1CA800A45078 /* fileDialog.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4802A6B1CA700A45078 /* fileDialog.h */; }; + 0F75F54D2A6B1CA800A45078 /* autoplaylist.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4812A6B1CA700A45078 /* autoplaylist.h */; }; + 0F75F54E2A6B1CA800A45078 /* input_file_type.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4822A6B1CA700A45078 /* input_file_type.h */; }; + 0F75F54F2A6B1CA800A45078 /* album_art_helpers.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4832A6B1CA700A45078 /* album_art_helpers.h */; }; + 0F75F5502A6B1CA800A45078 /* hasher_md5.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F4842A6B1CA700A45078 /* hasher_md5.cpp */; }; + 0F75F5512A6B1CA800A45078 /* message_loop.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4852A6B1CA700A45078 /* message_loop.h */; }; + 0F75F5522A6B1CA800A45078 /* playlist_loader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F4862A6B1CA700A45078 /* playlist_loader.cpp */; }; + 0F75F5532A6B1CA800A45078 /* service_by_guid.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4872A6B1CA700A45078 /* service_by_guid.h */; }; + 0F75F5542A6B1CA800A45078 /* library_manager.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4882A6B1CA700A45078 /* library_manager.h */; }; + 0F75F5552A6B1CA800A45078 /* foobar2000-lite.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4892A6B1CA700A45078 /* foobar2000-lite.h */; }; + 0F75F5562A6B1CA800A45078 /* commandline.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F48A2A6B1CA700A45078 /* commandline.h */; }; + 0F75F5572A6B1CA800A45078 /* coreversion.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F48B2A6B1CA700A45078 /* coreversion.h */; }; + 0F75F5582A6B1CA800A45078 /* dsp_manager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F48C2A6B1CA700A45078 /* dsp_manager.cpp */; }; + 0F75F5592A6B1CA800A45078 /* playback_control.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F48D2A6B1CA700A45078 /* playback_control.cpp */; }; + 0F75F55A2A6B1CA800A45078 /* foobar2000.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F48E2A6B1CA700A45078 /* foobar2000.h */; }; + 0F75F55B2A6B1CA800A45078 /* file_info_filter.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F48F2A6B1CA700A45078 /* file_info_filter.h */; }; + 0F75F55C2A6B1CA800A45078 /* metadb_handle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F4902A6B1CA800A45078 /* metadb_handle.cpp */; }; + 0F75F55D2A6B1CA800A45078 /* dsp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F4912A6B1CA800A45078 /* dsp.cpp */; }; + 0F75F55E2A6B1CA800A45078 /* cfg_var.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4922A6B1CA800A45078 /* cfg_var.h */; }; + 0F75F55F2A6B1CA800A45078 /* menu_helpers.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F4932A6B1CA800A45078 /* menu_helpers.h */; }; + 0FCA711C2AA2210C001CB0F2 /* commonObjects-Apple.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0FCA711A2AA2210C001CB0F2 /* commonObjects-Apple.mm */; }; + 0FDB0DFC2CEB60A900178906 /* ui_element_mac.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FDB0DFB2CEB60A500178906 /* ui_element_mac.h */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 0F75F3C82A6B1CA000A45078 /* foosort.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = foosort.cpp; sourceTree = ""; }; + 0F75F3C92A6B1CA000A45078 /* genrand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = genrand.h; sourceTree = ""; }; + 0F75F3CA2A6B1CA000A45078 /* ui_element_typable_window_manager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ui_element_typable_window_manager.h; sourceTree = ""; }; + 0F75F3CB2A6B1CA000A45078 /* titleformat.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = titleformat.cpp; sourceTree = ""; }; + 0F75F3CC2A6B1CA000A45078 /* file_info_merge.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = file_info_merge.cpp; sourceTree = ""; }; + 0F75F3CD2A6B1CA000A45078 /* audio_chunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = audio_chunk.h; sourceTree = ""; }; + 0F75F3CE2A6B1CA000A45078 /* output.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = output.h; sourceTree = ""; }; + 0F75F3CF2A6B1CA000A45078 /* file_operation_callback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = file_operation_callback.cpp; sourceTree = ""; }; + 0F75F3D02A6B1CA000A45078 /* abort_callback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = abort_callback.cpp; sourceTree = ""; }; + 0F75F3D12A6B1CA000A45078 /* playlist_loader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = playlist_loader.h; sourceTree = ""; }; + 0F75F3D22A6B1CA000A45078 /* threaded_process.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = threaded_process.h; sourceTree = ""; }; + 0F75F3D32A6B1CA000A45078 /* service_impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = service_impl.h; sourceTree = ""; }; + 0F75F3D42A6B1CA000A45078 /* main_thread_callback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = main_thread_callback.h; sourceTree = ""; }; + 0F75F3D52A6B1CA000A45078 /* filesystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = filesystem.cpp; sourceTree = ""; }; + 0F75F3D62A6B1CA000A45078 /* stdafx.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = stdafx.cpp; sourceTree = ""; }; + 0F75F3D72A6B1CA000A45078 /* progress_meter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = progress_meter.h; sourceTree = ""; }; + 0F75F3D82A6B1CA000A45078 /* app_close_blocker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = app_close_blocker.h; sourceTree = ""; }; + 0F75F3D92A6B1CA000A45078 /* mem_block_container.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = mem_block_container.cpp; sourceTree = ""; }; + 0F75F3DA2A6B1CA000A45078 /* filesystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = filesystem.h; sourceTree = ""; }; + 0F75F3DB2A6B1CA000A45078 /* commonObjects.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = commonObjects.cpp; sourceTree = ""; }; + 0F75F3DC2A6B1CA000A45078 /* threadPool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = threadPool.h; sourceTree = ""; }; + 0F75F3DD2A6B1CA000A45078 /* noInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = noInfo.h; sourceTree = ""; }; + 0F75F3DE2A6B1CA000A45078 /* unpack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = unpack.h; sourceTree = ""; }; + 0F75F3DF2A6B1CA000A45078 /* output.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = output.cpp; sourceTree = ""; }; + 0F75F3E02A6B1CA000A45078 /* menu_helpers.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = menu_helpers.cpp; sourceTree = ""; }; + 0F75F3E12A6B1CA000A45078 /* service.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = service.h; sourceTree = ""; }; + 0F75F3E22A6B1CA100A45078 /* file_info_const_impl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = file_info_const_impl.cpp; sourceTree = ""; }; + 0F75F3E32A6B1CA100A45078 /* chapterizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = chapterizer.h; sourceTree = ""; }; + 0F75F3E42A6B1CA100A45078 /* audio_chunk_impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = audio_chunk_impl.h; sourceTree = ""; }; + 0F75F3E52A6B1CA100A45078 /* audio_chunk_channel_config.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = audio_chunk_channel_config.cpp; sourceTree = ""; }; + 0F75F3E62A6B1CA100A45078 /* event_logger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = event_logger.h; sourceTree = ""; }; + 0F75F3E72A6B1CA100A45078 /* foobar2000-pfc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "foobar2000-pfc.h"; sourceTree = ""; }; + 0F75F3E82A6B1CA100A45078 /* http_client.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = http_client.h; sourceTree = ""; }; + 0F75F3E92A6B1CA100A45078 /* hasher_md5.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = hasher_md5.h; sourceTree = ""; }; + 0F75F3EA2A6B1CA100A45078 /* component.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = component.h; sourceTree = ""; }; + 0F75F3EB2A6B1CA100A45078 /* forward_types.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = forward_types.h; sourceTree = ""; }; + 0F75F3EC2A6B1CA100A45078 /* replaygain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = replaygain.h; sourceTree = ""; }; + 0F75F3ED2A6B1CA100A45078 /* metadb.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = metadb.h; sourceTree = ""; }; + 0F75F3EE2A6B1CA100A45078 /* menu_manager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = menu_manager.cpp; sourceTree = ""; }; + 0F75F3EF2A6B1CA100A45078 /* resampler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = resampler.h; sourceTree = ""; }; + 0F75F3F02A6B1CA100A45078 /* initquit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = initquit.h; sourceTree = ""; }; + 0F75F3F12A6B1CA100A45078 /* foobar2000-winver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "foobar2000-winver.h"; sourceTree = ""; }; + 0F75F3F22A6B1CA100A45078 /* timer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = timer.h; sourceTree = ""; }; + 0F75F3F32A6B1CA100A45078 /* playlist.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = playlist.h; sourceTree = ""; }; + 0F75F3F42A6B1CA100A45078 /* track_property.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = track_property.cpp; sourceTree = ""; }; + 0F75F3F52A6B1CA100A45078 /* ui.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ui.cpp; sourceTree = ""; }; + 0F75F3F62A6B1CA100A45078 /* titleformat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = titleformat.h; sourceTree = ""; }; + 0F75F3F72A6B1CA100A45078 /* file_info_impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = file_info_impl.h; sourceTree = ""; }; + 0F75F3F82A6B1CA100A45078 /* filesystem_helper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = filesystem_helper.cpp; sourceTree = ""; }; + 0F75F3F92A6B1CA100A45078 /* filesystem_helper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = filesystem_helper.h; sourceTree = ""; }; + 0F75F3FA2A6B1CA100A45078 /* audio_chunk.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = audio_chunk.cpp; sourceTree = ""; }; + 0F75F3FB2A6B1CA100A45078 /* console_manager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = console_manager.h; sourceTree = ""; }; + 0F75F3FC2A6B1CA100A45078 /* filesystem_transacted.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = filesystem_transacted.h; sourceTree = ""; }; + 0F75F3FD2A6B1CA100A45078 /* service.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = service.cpp; sourceTree = ""; }; + 0F75F3FE2A6B1CA200A45078 /* threaded_process.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = threaded_process.cpp; sourceTree = ""; }; + 0F75F3FF2A6B1CA200A45078 /* coreDarkMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = coreDarkMode.h; sourceTree = ""; }; + 0F75F4002A6B1CA200A45078 /* cfg_var_legacy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cfg_var_legacy.h; sourceTree = ""; }; + 0F75F4012A6B1CA200A45078 /* menu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = menu.h; sourceTree = ""; }; + 0F75F4022A6B1CA200A45078 /* file_info_filter_impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = file_info_filter_impl.h; sourceTree = ""; }; + 0F75F4032A6B1CA200A45078 /* advconfig.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = advconfig.cpp; sourceTree = ""; }; + 0F75F4042A6B1CA200A45078 /* packet_decoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = packet_decoder.h; sourceTree = ""; }; + 0F75F4052A6B1CA200A45078 /* decode_postprocessor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = decode_postprocessor.h; sourceTree = ""; }; + 0F75F4062A6B1CA200A45078 /* exception_io.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = exception_io.h; sourceTree = ""; }; + 0F75F4072A6B1CA200A45078 /* search_tools.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = search_tools.h; sourceTree = ""; }; + 0F75F4082A6B1CA200A45078 /* metadb_callbacks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = metadb_callbacks.h; sourceTree = ""; }; + 0F75F4092A6B1CA200A45078 /* configStore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = configStore.cpp; sourceTree = ""; }; + 0F75F40A2A6B1CA200A45078 /* modeless_dialog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = modeless_dialog.h; sourceTree = ""; }; + 0F75F40B2A6B1CA200A45078 /* foosort.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = foosort.h; sourceTree = ""; }; + 0F75F40C2A6B1CA200A45078 /* console.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = console.cpp; sourceTree = ""; }; + 0F75F40D2A6B1CA200A45078 /* playback_control.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = playback_control.h; sourceTree = ""; }; + 0F75F40E2A6B1CA200A45078 /* playback_stream_capture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = playback_stream_capture.h; sourceTree = ""; }; + 0F75F40F2A6B1CA200A45078 /* file_info.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = file_info.cpp; sourceTree = ""; }; + 0F75F4102A6B1CA200A45078 /* dsp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dsp.h; sourceTree = ""; }; + 0F75F4112A6B1CA200A45078 /* library_callbacks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = library_callbacks.h; sourceTree = ""; }; + 0F75F4122A6B1CA200A45078 /* threadsLite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = threadsLite.h; sourceTree = ""; }; + 0F75F4132A6B1CA200A45078 /* mem_block_container.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mem_block_container.h; sourceTree = ""; }; + 0F75F4142A6B1CA200A45078 /* foobar2000-all.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "foobar2000-all.h"; sourceTree = ""; }; + 0F75F4152A6B1CA200A45078 /* image.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = image.cpp; sourceTree = ""; }; + 0F75F4162A6B1CA200A45078 /* utility.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = utility.cpp; sourceTree = ""; }; + 0F75F4172A6B1CA200A45078 /* track_property.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = track_property.h; sourceTree = ""; }; + 0F75F4182A6B1CA200A45078 /* cfg_var.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cfg_var.cpp; sourceTree = ""; }; + 0F75F4192A6B1CA200A45078 /* shortcut_actions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = shortcut_actions.h; sourceTree = ""; }; + 0F75F41B2A6B1CA200A45078 /* exceptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = exceptions.h; sourceTree = ""; }; + 0F75F41C2A6B1CA200A45078 /* component_client.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = component_client.h; sourceTree = ""; }; + 0F75F41D2A6B1CA200A45078 /* playable_location.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = playable_location.cpp; sourceTree = ""; }; + 0F75F41E2A6B1CA200A45078 /* metadb.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = metadb.cpp; sourceTree = ""; }; + 0F75F41F2A6B1CA200A45078 /* input_impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = input_impl.h; sourceTree = ""; }; + 0F75F4202A6B1CA200A45078 /* service_compat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = service_compat.h; sourceTree = ""; }; + 0F75F4212A6B1CA300A45078 /* keyValueIO.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = keyValueIO.h; sourceTree = ""; }; + 0F75F4222A6B1CA300A45078 /* tracks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tracks.h; sourceTree = ""; }; + 0F75F4232A6B1CA300A45078 /* playlistColumnProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = playlistColumnProvider.h; sourceTree = ""; }; + 0F75F4242A6B1CA300A45078 /* imageLoaderLite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = imageLoaderLite.h; sourceTree = ""; }; + 0F75F4252A6B1CA300A45078 /* playlist.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = playlist.cpp; sourceTree = ""; }; + 0F75F4262A6B1CA300A45078 /* preferences_page.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = preferences_page.cpp; sourceTree = ""; }; + 0F75F4272A6B1CA300A45078 /* config_io_callback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = config_io_callback.cpp; sourceTree = ""; }; + 0F75F4282A6B1CA300A45078 /* packet_decoder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = packet_decoder.cpp; sourceTree = ""; }; + 0F75F4292A6B1CA300A45078 /* ole_interaction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ole_interaction.h; sourceTree = ""; }; + 0F75F42A2A6B1CA300A45078 /* info_lookup_handler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = info_lookup_handler.h; sourceTree = ""; }; + 0F75F42B2A6B1CA300A45078 /* library_index.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = library_index.h; sourceTree = ""; }; + 0F75F42C2A6B1CA300A45078 /* audioEncoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = audioEncoder.h; sourceTree = ""; }; + 0F75F42D2A6B1CA300A45078 /* commandline.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = commandline.cpp; sourceTree = ""; }; + 0F75F42E2A6B1CA300A45078 /* image.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = image.h; sourceTree = ""; }; + 0F75F42F2A6B1CA300A45078 /* link_resolver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = link_resolver.cpp; sourceTree = ""; }; + 0F75F4302A6B1CA300A45078 /* metadb_handle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = metadb_handle.h; sourceTree = ""; }; + 0F75F4312A6B1CA300A45078 /* advconfig_impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = advconfig_impl.h; sourceTree = ""; }; + 0F75F4322A6B1CA300A45078 /* foobar2000-versions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "foobar2000-versions.h"; sourceTree = ""; }; + 0F75F4332A6B1CA300A45078 /* componentversion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = componentversion.h; sourceTree = ""; }; + 0F75F4342A6B1CA300A45078 /* contextmenu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = contextmenu.h; sourceTree = ""; }; + 0F75F4352A6B1CA300A45078 /* advconfig_impl_legacy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = advconfig_impl_legacy.h; sourceTree = ""; }; + 0F75F4362A6B1CA300A45078 /* file.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = file.h; sourceTree = ""; }; + 0F75F4372A6B1CA300A45078 /* ui_element.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ui_element.cpp; sourceTree = ""; }; + 0F75F4382A6B1CA300A45078 /* guids.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = guids.cpp; sourceTree = ""; }; + 0F75F4392A6B1CA300A45078 /* tag_processor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = tag_processor.cpp; sourceTree = ""; }; + 0F75F43A2A6B1CA300A45078 /* config_object.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = config_object.h; sourceTree = ""; }; + 0F75F43B2A6B1CA300A45078 /* config_object.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = config_object.cpp; sourceTree = ""; }; + 0F75F43C2A6B1CA300A45078 /* ui.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ui.h; sourceTree = ""; }; + 0F75F43D2A6B1CA300A45078 /* link_resolver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = link_resolver.h; sourceTree = ""; }; + 0F75F43E2A6B1CA300A45078 /* playable_location.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = playable_location.h; sourceTree = ""; }; + 0F75F43F2A6B1CA300A45078 /* file_lock_manager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = file_lock_manager.h; sourceTree = ""; }; + 0F75F4402A6B1CA300A45078 /* configStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = configStore.h; sourceTree = ""; }; + 0F75F4412A6B1CA300A45078 /* input.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = input.cpp; sourceTree = ""; }; + 0F75F4422A6B1CA300A45078 /* contextmenu_manager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = contextmenu_manager.h; sourceTree = ""; }; + 0F75F4432A6B1CA400A45078 /* config_io_callback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = config_io_callback.h; sourceTree = ""; }; + 0F75F4442A6B1CA400A45078 /* menu_common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = menu_common.h; sourceTree = ""; }; + 0F75F4452A6B1CA400A45078 /* completion_notify.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = completion_notify.cpp; sourceTree = ""; }; + 0F75F4462A6B1CA400A45078 /* metadb_info_container_impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = metadb_info_container_impl.h; sourceTree = ""; }; + 0F75F4472A6B1CA400A45078 /* abort_callback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = abort_callback.h; sourceTree = ""; }; + 0F75F4482A6B1CA400A45078 /* completion_notify.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = completion_notify.h; sourceTree = ""; }; + 0F75F4492A6B1CA400A45078 /* toolbarDropDown.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = toolbarDropDown.h; sourceTree = ""; }; + 0F75F44A2A6B1CA400A45078 /* dsp_manager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dsp_manager.h; sourceTree = ""; }; + 0F75F44B2A6B1CA400A45078 /* messageBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = messageBox.h; sourceTree = ""; }; + 0F75F44C2A6B1CA400A45078 /* ui_edit_context.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ui_edit_context.h; sourceTree = ""; }; + 0F75F44D2A6B1CA400A45078 /* ui_element.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ui_element.h; sourceTree = ""; }; + 0F75F44E2A6B1CA400A45078 /* menu_item.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = menu_item.cpp; sourceTree = ""; }; + 0F75F44F2A6B1CA400A45078 /* callback_merit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = callback_merit.h; sourceTree = ""; }; + 0F75F4502A6B1CA400A45078 /* foosortstring.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = foosortstring.h; sourceTree = ""; }; + 0F75F4512A6B1CA400A45078 /* imageViewer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = imageViewer.h; sourceTree = ""; }; + 0F75F4522A6B1CA400A45078 /* popup_message.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = popup_message.cpp; sourceTree = ""; }; + 0F75F4532A6B1CA400A45078 /* fsItem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = fsItem.cpp; sourceTree = ""; }; + 0F75F4542A6B1CA400A45078 /* cfg_var_legacy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cfg_var_legacy.cpp; sourceTree = ""; }; + 0F75F4552A6B1CA500A45078 /* vis.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = vis.h; sourceTree = ""; }; + 0F75F4562A6B1CA500A45078 /* console.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = console.h; sourceTree = ""; }; + 0F75F4572A6B1CA500A45078 /* componentversion.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = componentversion.cpp; sourceTree = ""; }; + 0F75F4582A6B1CA500A45078 /* chapterizer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = chapterizer.cpp; sourceTree = ""; }; + 0F75F4592A6B1CA500A45078 /* components_menu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = components_menu.h; sourceTree = ""; }; + 0F75F45A2A6B1CA500A45078 /* metadb_handle_list.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = metadb_handle_list.cpp; sourceTree = ""; }; + 0F75F45B2A6B1CA500A45078 /* preferences_page.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = preferences_page.h; sourceTree = ""; }; + 0F75F45C2A6B1CA500A45078 /* core_api.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = core_api.h; sourceTree = ""; }; + 0F75F45D2A6B1CA500A45078 /* config_object_impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = config_object_impl.h; sourceTree = ""; }; + 0F75F45E2A6B1CA500A45078 /* configCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = configCache.h; sourceTree = ""; }; + 0F75F45F2A6B1CA500A45078 /* metadb_display_field_provider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = metadb_display_field_provider.h; sourceTree = ""; }; + 0F75F4602A6B1CA500A45078 /* dsp-frontend.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "dsp-frontend.h"; sourceTree = ""; }; + 0F75F4612A6B1CA500A45078 /* foobar2000-sdk-pch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "foobar2000-sdk-pch.h"; sourceTree = ""; }; + 0F75F4622A6B1CA500A45078 /* file_cached_impl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = file_cached_impl.cpp; sourceTree = ""; }; + 0F75F4632A6B1CA500A45078 /* replaygain_info.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = replaygain_info.cpp; sourceTree = ""; }; + 0F75F4642A6B1CA500A45078 /* metadb_index.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = metadb_index.h; sourceTree = ""; }; + 0F75F4652A6B1CA500A45078 /* mainmenu.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = mainmenu.cpp; sourceTree = ""; }; + 0F75F4662A6B1CA500A45078 /* app_close_blocker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = app_close_blocker.cpp; sourceTree = ""; }; + 0F75F4672A6B1CA500A45078 /* file_info_impl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = file_info_impl.cpp; sourceTree = ""; }; + 0F75F4682A6B1CA500A45078 /* tag_processor_id3v2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = tag_processor_id3v2.cpp; sourceTree = ""; }; + 0F75F4692A6B1CA500A45078 /* audio_postprocessor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = audio_postprocessor.h; sourceTree = ""; }; + 0F75F46A2A6B1CA500A45078 /* file_info.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = file_info.h; sourceTree = ""; }; + 0F75F46B2A6B1CA500A45078 /* replaygain.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = replaygain.cpp; sourceTree = ""; }; + 0F75F46C2A6B1CA500A45078 /* input.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = input.h; sourceTree = ""; }; + 0F75F46D2A6B1CA600A45078 /* file_format_sanitizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = file_format_sanitizer.h; sourceTree = ""; }; + 0F75F46E2A6B1CA600A45078 /* commonObjects.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = commonObjects.h; sourceTree = ""; }; + 0F75F46F2A6B1CA600A45078 /* powerManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = powerManager.h; sourceTree = ""; }; + 0F75F4702A6B1CA600A45078 /* popup_message.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = popup_message.h; sourceTree = ""; }; + 0F75F4712A6B1CA600A45078 /* archive.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = archive.h; sourceTree = ""; }; + 0F75F4722A6B1CA600A45078 /* system_time_keeper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = system_time_keeper.h; sourceTree = ""; }; + 0F75F4732A6B1CA600A45078 /* play_callback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = play_callback.h; sourceTree = ""; }; + 0F75F4742A6B1CA600A45078 /* file_info_const_impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = file_info_const_impl.h; sourceTree = ""; }; + 0F75F4752A6B1CA600A45078 /* file_operation_callback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = file_operation_callback.h; sourceTree = ""; }; + 0F75F4762A6B1CA600A45078 /* album_art.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = album_art.cpp; sourceTree = ""; }; + 0F75F4772A6B1CA600A45078 /* main_thread_callback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main_thread_callback.cpp; sourceTree = ""; }; + 0F75F4782A6B1CA600A45078 /* replaygain_scanner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = replaygain_scanner.h; sourceTree = ""; }; + 0F75F4792A6B1CA600A45078 /* tag_processor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tag_processor.h; sourceTree = ""; }; + 0F75F47A2A6B1CA700A45078 /* input_file_type.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = input_file_type.cpp; sourceTree = ""; }; + 0F75F47B2A6B1CA700A45078 /* album_art.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = album_art.h; sourceTree = ""; }; + 0F75F47C2A6B1CA700A45078 /* advconfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = advconfig.h; sourceTree = ""; }; + 0F75F47D2A6B1CA700A45078 /* fsitem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fsitem.h; sourceTree = ""; }; + 0F75F47E2A6B1CA700A45078 /* icon_remap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = icon_remap.h; sourceTree = ""; }; + 0F75F47F2A6B1CA700A45078 /* keyValueIOimpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = keyValueIOimpl.h; sourceTree = ""; }; + 0F75F4802A6B1CA700A45078 /* fileDialog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fileDialog.h; sourceTree = ""; }; + 0F75F4812A6B1CA700A45078 /* autoplaylist.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = autoplaylist.h; sourceTree = ""; }; + 0F75F4822A6B1CA700A45078 /* input_file_type.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = input_file_type.h; sourceTree = ""; }; + 0F75F4832A6B1CA700A45078 /* album_art_helpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = album_art_helpers.h; sourceTree = ""; }; + 0F75F4842A6B1CA700A45078 /* hasher_md5.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = hasher_md5.cpp; sourceTree = ""; }; + 0F75F4852A6B1CA700A45078 /* message_loop.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = message_loop.h; sourceTree = ""; }; + 0F75F4862A6B1CA700A45078 /* playlist_loader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = playlist_loader.cpp; sourceTree = ""; }; + 0F75F4872A6B1CA700A45078 /* service_by_guid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = service_by_guid.h; sourceTree = ""; }; + 0F75F4882A6B1CA700A45078 /* library_manager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = library_manager.h; sourceTree = ""; }; + 0F75F4892A6B1CA700A45078 /* foobar2000-lite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "foobar2000-lite.h"; sourceTree = ""; }; + 0F75F48A2A6B1CA700A45078 /* commandline.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = commandline.h; sourceTree = ""; }; + 0F75F48B2A6B1CA700A45078 /* coreversion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = coreversion.h; sourceTree = ""; }; + 0F75F48C2A6B1CA700A45078 /* dsp_manager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = dsp_manager.cpp; sourceTree = ""; }; + 0F75F48D2A6B1CA700A45078 /* playback_control.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = playback_control.cpp; sourceTree = ""; }; + 0F75F48E2A6B1CA700A45078 /* foobar2000.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = foobar2000.h; sourceTree = ""; }; + 0F75F48F2A6B1CA700A45078 /* file_info_filter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = file_info_filter.h; sourceTree = ""; }; + 0F75F4902A6B1CA800A45078 /* metadb_handle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = metadb_handle.cpp; sourceTree = ""; }; + 0F75F4912A6B1CA800A45078 /* dsp.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = dsp.cpp; sourceTree = ""; }; + 0F75F4922A6B1CA800A45078 /* cfg_var.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cfg_var.h; sourceTree = ""; }; + 0F75F4932A6B1CA800A45078 /* menu_helpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = menu_helpers.h; sourceTree = ""; }; + 0FCA711A2AA2210C001CB0F2 /* commonObjects-Apple.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = "commonObjects-Apple.mm"; sourceTree = ""; }; + 0FCA711E2AA2715E001CB0F2 /* commonObjects-Apple.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "commonObjects-Apple.h"; sourceTree = ""; }; + 0FDB0DFB2CEB60A500178906 /* ui_element_mac.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ui_element_mac.h; sourceTree = ""; }; + B166962019ACC1450001728F /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + B166962E19ACC1450001728F /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; + B166963119ACC1450001728F /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; }; + B1DD3657198A721800EF7043 /* libfoobar2000_SDK.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libfoobar2000_SDK.a; sourceTree = BUILT_PRODUCTS_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + B1DD3654198A721800EF7043 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + B166961F19ACC1450001728F /* Frameworks */ = { + isa = PBXGroup; + children = ( + B166962019ACC1450001728F /* Foundation.framework */, + B166962E19ACC1450001728F /* XCTest.framework */, + B166963119ACC1450001728F /* UIKit.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + B1DD364E198A721800EF7043 = { + isa = PBXGroup; + children = ( + B1DD3670198A725100EF7043 /* Source */, + B166961F19ACC1450001728F /* Frameworks */, + B1DD3658198A721800EF7043 /* Products */, + ); + sourceTree = ""; + }; + B1DD3658198A721800EF7043 /* Products */ = { + isa = PBXGroup; + children = ( + B1DD3657198A721800EF7043 /* libfoobar2000_SDK.a */, + ); + name = Products; + sourceTree = ""; + }; + B1DD3670198A725100EF7043 /* Source */ = { + isa = PBXGroup; + children = ( + 0FDB0DFB2CEB60A500178906 /* ui_element_mac.h */, + 0F75F3D02A6B1CA000A45078 /* abort_callback.cpp */, + 0F75F4472A6B1CA400A45078 /* abort_callback.h */, + 0F75F4352A6B1CA300A45078 /* advconfig_impl_legacy.h */, + 0F75F4312A6B1CA300A45078 /* advconfig_impl.h */, + 0F75F4032A6B1CA200A45078 /* advconfig.cpp */, + 0F75F47C2A6B1CA700A45078 /* advconfig.h */, + 0F75F4832A6B1CA700A45078 /* album_art_helpers.h */, + 0F75F4762A6B1CA600A45078 /* album_art.cpp */, + 0F75F47B2A6B1CA700A45078 /* album_art.h */, + 0F75F4662A6B1CA500A45078 /* app_close_blocker.cpp */, + 0F75F3D82A6B1CA000A45078 /* app_close_blocker.h */, + 0F75F4712A6B1CA600A45078 /* archive.h */, + 0F75F3E52A6B1CA100A45078 /* audio_chunk_channel_config.cpp */, + 0F75F3E42A6B1CA100A45078 /* audio_chunk_impl.h */, + 0F75F3FA2A6B1CA100A45078 /* audio_chunk.cpp */, + 0F75F3CD2A6B1CA000A45078 /* audio_chunk.h */, + 0F75F4692A6B1CA500A45078 /* audio_postprocessor.h */, + 0F75F42C2A6B1CA300A45078 /* audioEncoder.h */, + 0F75F4812A6B1CA700A45078 /* autoplaylist.h */, + 0F75F44F2A6B1CA400A45078 /* callback_merit.h */, + 0F75F4542A6B1CA400A45078 /* cfg_var_legacy.cpp */, + 0F75F4002A6B1CA200A45078 /* cfg_var_legacy.h */, + 0F75F4182A6B1CA200A45078 /* cfg_var.cpp */, + 0F75F4922A6B1CA800A45078 /* cfg_var.h */, + 0F75F4582A6B1CA500A45078 /* chapterizer.cpp */, + 0F75F3E32A6B1CA100A45078 /* chapterizer.h */, + 0F75F42D2A6B1CA300A45078 /* commandline.cpp */, + 0F75F48A2A6B1CA700A45078 /* commandline.h */, + 0F75F3DB2A6B1CA000A45078 /* commonObjects.cpp */, + 0F75F46E2A6B1CA600A45078 /* commonObjects.h */, + 0F75F4452A6B1CA400A45078 /* completion_notify.cpp */, + 0F75F4482A6B1CA400A45078 /* completion_notify.h */, + 0F75F41C2A6B1CA200A45078 /* component_client.h */, + 0F75F3EA2A6B1CA100A45078 /* component.h */, + 0F75F4592A6B1CA500A45078 /* components_menu.h */, + 0F75F4572A6B1CA500A45078 /* componentversion.cpp */, + 0F75F4332A6B1CA300A45078 /* componentversion.h */, + 0F75F4272A6B1CA300A45078 /* config_io_callback.cpp */, + 0F75F4432A6B1CA400A45078 /* config_io_callback.h */, + 0F75F45D2A6B1CA500A45078 /* config_object_impl.h */, + 0F75F43B2A6B1CA300A45078 /* config_object.cpp */, + 0F75F43A2A6B1CA300A45078 /* config_object.h */, + 0F75F45E2A6B1CA500A45078 /* configCache.h */, + 0F75F4092A6B1CA200A45078 /* configStore.cpp */, + 0F75F4402A6B1CA300A45078 /* configStore.h */, + 0F75F3FB2A6B1CA100A45078 /* console_manager.h */, + 0F75F40C2A6B1CA200A45078 /* console.cpp */, + 0F75F4562A6B1CA500A45078 /* console.h */, + 0F75F4422A6B1CA300A45078 /* contextmenu_manager.h */, + 0F75F4342A6B1CA300A45078 /* contextmenu.h */, + 0F75F45C2A6B1CA500A45078 /* core_api.h */, + 0F75F3FF2A6B1CA200A45078 /* coreDarkMode.h */, + 0F75F48B2A6B1CA700A45078 /* coreversion.h */, + 0F75F4052A6B1CA200A45078 /* decode_postprocessor.h */, + 0F75F48C2A6B1CA700A45078 /* dsp_manager.cpp */, + 0F75F44A2A6B1CA400A45078 /* dsp_manager.h */, + 0F75F4602A6B1CA500A45078 /* dsp-frontend.h */, + 0F75F4912A6B1CA800A45078 /* dsp.cpp */, + 0F75F4102A6B1CA200A45078 /* dsp.h */, + 0F75F3E62A6B1CA100A45078 /* event_logger.h */, + 0F75F4062A6B1CA200A45078 /* exception_io.h */, + 0F75F41B2A6B1CA200A45078 /* exceptions.h */, + 0F75F4622A6B1CA500A45078 /* file_cached_impl.cpp */, + 0F75F46D2A6B1CA600A45078 /* file_format_sanitizer.h */, + 0F75F3E22A6B1CA100A45078 /* file_info_const_impl.cpp */, + 0F75F4742A6B1CA600A45078 /* file_info_const_impl.h */, + 0F75F4022A6B1CA200A45078 /* file_info_filter_impl.h */, + 0F75F48F2A6B1CA700A45078 /* file_info_filter.h */, + 0F75F4672A6B1CA500A45078 /* file_info_impl.cpp */, + 0F75F3F72A6B1CA100A45078 /* file_info_impl.h */, + 0F75F3CC2A6B1CA000A45078 /* file_info_merge.cpp */, + 0F75F40F2A6B1CA200A45078 /* file_info.cpp */, + 0F75F46A2A6B1CA500A45078 /* file_info.h */, + 0F75F43F2A6B1CA300A45078 /* file_lock_manager.h */, + 0F75F3CF2A6B1CA000A45078 /* file_operation_callback.cpp */, + 0F75F4752A6B1CA600A45078 /* file_operation_callback.h */, + 0F75F4362A6B1CA300A45078 /* file.h */, + 0F75F4802A6B1CA700A45078 /* fileDialog.h */, + 0F75F3F82A6B1CA100A45078 /* filesystem_helper.cpp */, + 0F75F3F92A6B1CA100A45078 /* filesystem_helper.h */, + 0F75F3FC2A6B1CA100A45078 /* filesystem_transacted.h */, + 0F75F3D52A6B1CA000A45078 /* filesystem.cpp */, + 0F75F3DA2A6B1CA000A45078 /* filesystem.h */, + 0F75F4142A6B1CA200A45078 /* foobar2000-all.h */, + 0F75F4892A6B1CA700A45078 /* foobar2000-lite.h */, + 0F75F3E72A6B1CA100A45078 /* foobar2000-pfc.h */, + 0F75F4612A6B1CA500A45078 /* foobar2000-sdk-pch.h */, + 0F75F4322A6B1CA300A45078 /* foobar2000-versions.h */, + 0F75F3F12A6B1CA100A45078 /* foobar2000-winver.h */, + 0F75F48E2A6B1CA700A45078 /* foobar2000.h */, + 0F75F3C82A6B1CA000A45078 /* foosort.cpp */, + 0F75F40B2A6B1CA200A45078 /* foosort.h */, + 0F75F4502A6B1CA400A45078 /* foosortstring.h */, + 0F75F3EB2A6B1CA100A45078 /* forward_types.h */, + 0F75F4532A6B1CA400A45078 /* fsItem.cpp */, + 0F75F47D2A6B1CA700A45078 /* fsitem.h */, + 0F75F3C92A6B1CA000A45078 /* genrand.h */, + 0F75F4382A6B1CA300A45078 /* guids.cpp */, + 0F75F4842A6B1CA700A45078 /* hasher_md5.cpp */, + 0F75F3E92A6B1CA100A45078 /* hasher_md5.h */, + 0F75F3E82A6B1CA100A45078 /* http_client.h */, + 0F75F47E2A6B1CA700A45078 /* icon_remap.h */, + 0F75F4152A6B1CA200A45078 /* image.cpp */, + 0F75F42E2A6B1CA300A45078 /* image.h */, + 0F75F4242A6B1CA300A45078 /* imageLoaderLite.h */, + 0F75F4512A6B1CA400A45078 /* imageViewer.h */, + 0F75F42A2A6B1CA300A45078 /* info_lookup_handler.h */, + 0F75F3F02A6B1CA100A45078 /* initquit.h */, + 0F75F47A2A6B1CA700A45078 /* input_file_type.cpp */, + 0F75F4822A6B1CA700A45078 /* input_file_type.h */, + 0F75F41F2A6B1CA200A45078 /* input_impl.h */, + 0F75F4412A6B1CA300A45078 /* input.cpp */, + 0F75F46C2A6B1CA500A45078 /* input.h */, + 0F75F4212A6B1CA300A45078 /* keyValueIO.h */, + 0F75F47F2A6B1CA700A45078 /* keyValueIOimpl.h */, + 0F75F4112A6B1CA200A45078 /* library_callbacks.h */, + 0F75F42B2A6B1CA300A45078 /* library_index.h */, + 0F75F4882A6B1CA700A45078 /* library_manager.h */, + 0F75F42F2A6B1CA300A45078 /* link_resolver.cpp */, + 0F75F43D2A6B1CA300A45078 /* link_resolver.h */, + 0F75F4772A6B1CA600A45078 /* main_thread_callback.cpp */, + 0F75F3D42A6B1CA000A45078 /* main_thread_callback.h */, + 0F75F4652A6B1CA500A45078 /* mainmenu.cpp */, + 0F75F3D92A6B1CA000A45078 /* mem_block_container.cpp */, + 0F75F4132A6B1CA200A45078 /* mem_block_container.h */, + 0F75F4442A6B1CA400A45078 /* menu_common.h */, + 0F75F3E02A6B1CA000A45078 /* menu_helpers.cpp */, + 0F75F4932A6B1CA800A45078 /* menu_helpers.h */, + 0F75F44E2A6B1CA400A45078 /* menu_item.cpp */, + 0F75F3EE2A6B1CA100A45078 /* menu_manager.cpp */, + 0F75F4012A6B1CA200A45078 /* menu.h */, + 0F75F4852A6B1CA700A45078 /* message_loop.h */, + 0F75F44B2A6B1CA400A45078 /* messageBox.h */, + 0F75F4082A6B1CA200A45078 /* metadb_callbacks.h */, + 0F75F45F2A6B1CA500A45078 /* metadb_display_field_provider.h */, + 0F75F45A2A6B1CA500A45078 /* metadb_handle_list.cpp */, + 0F75F4902A6B1CA800A45078 /* metadb_handle.cpp */, + 0F75F4302A6B1CA300A45078 /* metadb_handle.h */, + 0F75F4642A6B1CA500A45078 /* metadb_index.h */, + 0F75F4462A6B1CA400A45078 /* metadb_info_container_impl.h */, + 0F75F41E2A6B1CA200A45078 /* metadb.cpp */, + 0F75F3ED2A6B1CA100A45078 /* metadb.h */, + 0F75F40A2A6B1CA200A45078 /* modeless_dialog.h */, + 0F75F3DD2A6B1CA000A45078 /* noInfo.h */, + 0F75F4292A6B1CA300A45078 /* ole_interaction.h */, + 0F75F3DF2A6B1CA000A45078 /* output.cpp */, + 0F75F3CE2A6B1CA000A45078 /* output.h */, + 0F75F4282A6B1CA300A45078 /* packet_decoder.cpp */, + 0F75F4042A6B1CA200A45078 /* packet_decoder.h */, + 0F75F4732A6B1CA600A45078 /* play_callback.h */, + 0F75F41D2A6B1CA200A45078 /* playable_location.cpp */, + 0F75F43E2A6B1CA300A45078 /* playable_location.h */, + 0F75F48D2A6B1CA700A45078 /* playback_control.cpp */, + 0F75F40D2A6B1CA200A45078 /* playback_control.h */, + 0F75F40E2A6B1CA200A45078 /* playback_stream_capture.h */, + 0F75F4862A6B1CA700A45078 /* playlist_loader.cpp */, + 0F75F3D12A6B1CA000A45078 /* playlist_loader.h */, + 0F75F4252A6B1CA300A45078 /* playlist.cpp */, + 0F75F3F32A6B1CA100A45078 /* playlist.h */, + 0F75F4232A6B1CA300A45078 /* playlistColumnProvider.h */, + 0F75F4522A6B1CA400A45078 /* popup_message.cpp */, + 0F75F4702A6B1CA600A45078 /* popup_message.h */, + 0F75F46F2A6B1CA600A45078 /* powerManager.h */, + 0F75F4262A6B1CA300A45078 /* preferences_page.cpp */, + 0F75F45B2A6B1CA500A45078 /* preferences_page.h */, + 0F75F3D72A6B1CA000A45078 /* progress_meter.h */, + 0F75F4632A6B1CA500A45078 /* replaygain_info.cpp */, + 0F75F4782A6B1CA600A45078 /* replaygain_scanner.h */, + 0F75F46B2A6B1CA500A45078 /* replaygain.cpp */, + 0F75F3EC2A6B1CA100A45078 /* replaygain.h */, + 0F75F3EF2A6B1CA100A45078 /* resampler.h */, + 0F75F4072A6B1CA200A45078 /* search_tools.h */, + 0F75F4872A6B1CA700A45078 /* service_by_guid.h */, + 0F75F4202A6B1CA200A45078 /* service_compat.h */, + 0F75F3D32A6B1CA000A45078 /* service_impl.h */, + 0F75F3FD2A6B1CA100A45078 /* service.cpp */, + 0F75F3E12A6B1CA000A45078 /* service.h */, + 0F75F4192A6B1CA200A45078 /* shortcut_actions.h */, + 0F75F3D62A6B1CA000A45078 /* stdafx.cpp */, + 0F75F4722A6B1CA600A45078 /* system_time_keeper.h */, + 0F75F4682A6B1CA500A45078 /* tag_processor_id3v2.cpp */, + 0F75F4392A6B1CA300A45078 /* tag_processor.cpp */, + 0F75F4792A6B1CA600A45078 /* tag_processor.h */, + 0F75F3FE2A6B1CA200A45078 /* threaded_process.cpp */, + 0F75F3D22A6B1CA000A45078 /* threaded_process.h */, + 0F75F3DC2A6B1CA000A45078 /* threadPool.h */, + 0F75F4122A6B1CA200A45078 /* threadsLite.h */, + 0F75F3F22A6B1CA100A45078 /* timer.h */, + 0F75F3CB2A6B1CA000A45078 /* titleformat.cpp */, + 0F75F3F62A6B1CA100A45078 /* titleformat.h */, + 0F75F4492A6B1CA400A45078 /* toolbarDropDown.h */, + 0F75F3F42A6B1CA100A45078 /* track_property.cpp */, + 0F75F4172A6B1CA200A45078 /* track_property.h */, + 0F75F4222A6B1CA300A45078 /* tracks.h */, + 0F75F44C2A6B1CA400A45078 /* ui_edit_context.h */, + 0F75F3CA2A6B1CA000A45078 /* ui_element_typable_window_manager.h */, + 0F75F4372A6B1CA300A45078 /* ui_element.cpp */, + 0F75F44D2A6B1CA400A45078 /* ui_element.h */, + 0F75F3F52A6B1CA100A45078 /* ui.cpp */, + 0F75F43C2A6B1CA300A45078 /* ui.h */, + 0F75F3DE2A6B1CA000A45078 /* unpack.h */, + 0F75F4162A6B1CA200A45078 /* utility.cpp */, + 0F75F4552A6B1CA500A45078 /* vis.h */, + 0FCA711A2AA2210C001CB0F2 /* commonObjects-Apple.mm */, + 0FCA711E2AA2715E001CB0F2 /* commonObjects-Apple.h */, + ); + name = Source; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + B1DD3655198A721800EF7043 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 0F75F5092A6B1CA800A45078 /* link_resolver.h in Headers */, + 0F75F4D42A6B1CA800A45078 /* metadb_callbacks.h in Headers */, + 0F75F4D12A6B1CA800A45078 /* decode_postprocessor.h in Headers */, + 0F75F50E2A6B1CA800A45078 /* contextmenu_manager.h in Headers */, + 0F75F4D32A6B1CA800A45078 /* search_tools.h in Headers */, + 0F75F4C72A6B1CA800A45078 /* console_manager.h in Headers */, + 0F75F4C82A6B1CA800A45078 /* filesystem_transacted.h in Headers */, + 0F75F4CE2A6B1CA800A45078 /* file_info_filter_impl.h in Headers */, + 0F75F5222A6B1CA800A45078 /* console.h in Headers */, + 0F75F4EC2A6B1CA800A45078 /* service_compat.h in Headers */, + 0F75F4EF2A6B1CA800A45078 /* playlistColumnProvider.h in Headers */, + 0F75F4DF2A6B1CA800A45078 /* mem_block_container.h in Headers */, + 0F75F4D62A6B1CA800A45078 /* modeless_dialog.h in Headers */, + 0F75F5532A6B1CA800A45078 /* service_by_guid.h in Headers */, + 0F75F5182A6B1CA800A45078 /* ui_edit_context.h in Headers */, + 0F75F50B2A6B1CA800A45078 /* file_lock_manager.h in Headers */, + 0F75F54F2A6B1CA800A45078 /* album_art_helpers.h in Headers */, + 0F75F4D02A6B1CA800A45078 /* packet_decoder.h in Headers */, + 0F75F4B02A6B1CA800A45078 /* audio_chunk_impl.h in Headers */, + 0F75F4FD2A6B1CA800A45078 /* advconfig_impl.h in Headers */, + 0F75F53C2A6B1CA800A45078 /* popup_message.h in Headers */, + 0F75F4D22A6B1CA800A45078 /* exception_io.h in Headers */, + 0F75F52A2A6B1CA800A45078 /* configCache.h in Headers */, + 0F75F4992A6B1CA800A45078 /* audio_chunk.h in Headers */, + 0F75F4E72A6B1CA800A45078 /* exceptions.h in Headers */, + 0F75F4DC2A6B1CA800A45078 /* dsp.h in Headers */, + 0F75F54C2A6B1CA800A45078 /* fileDialog.h in Headers */, + 0F75F5102A6B1CA800A45078 /* menu_common.h in Headers */, + 0F75F4CB2A6B1CA800A45078 /* coreDarkMode.h in Headers */, + 0F75F5082A6B1CA800A45078 /* ui.h in Headers */, + 0F75F55B2A6B1CA800A45078 /* file_info_filter.h in Headers */, + 0F75F5292A6B1CA800A45078 /* config_object_impl.h in Headers */, + 0F75F54D2A6B1CA800A45078 /* autoplaylist.h in Headers */, + 0F75F4C32A6B1CA800A45078 /* file_info_impl.h in Headers */, + 0F75F4952A6B1CA800A45078 /* genrand.h in Headers */, + 0F75F4962A6B1CA800A45078 /* ui_element_typable_window_manager.h in Headers */, + 0F75F5062A6B1CA800A45078 /* config_object.h in Headers */, + 0F75F51C2A6B1CA800A45078 /* foosortstring.h in Headers */, + 0F75F55A2A6B1CA800A45078 /* foobar2000.h in Headers */, + 0F75F5002A6B1CA800A45078 /* contextmenu.h in Headers */, + 0F75F4CC2A6B1CA800A45078 /* cfg_var_legacy.h in Headers */, + 0F75F4BB2A6B1CA800A45078 /* resampler.h in Headers */, + 0F75F4DE2A6B1CA800A45078 /* threadsLite.h in Headers */, + 0F75F5282A6B1CA800A45078 /* core_api.h in Headers */, + 0F75F5152A6B1CA800A45078 /* toolbarDropDown.h in Headers */, + 0F75F5172A6B1CA800A45078 /* messageBox.h in Headers */, + 0F75F49E2A6B1CA800A45078 /* threaded_process.h in Headers */, + 0F75F4FA2A6B1CA800A45078 /* image.h in Headers */, + 0F75F4BF2A6B1CA800A45078 /* playlist.h in Headers */, + 0F75F4EB2A6B1CA800A45078 /* input_impl.h in Headers */, + 0F75F5012A6B1CA800A45078 /* advconfig_impl_legacy.h in Headers */, + 0F75F5412A6B1CA800A45078 /* file_operation_callback.h in Headers */, + 0F75F4B42A6B1CA800A45078 /* http_client.h in Headers */, + 0F75F4F82A6B1CA800A45078 /* audioEncoder.h in Headers */, + 0F75F4DA2A6B1CA800A45078 /* playback_stream_capture.h in Headers */, + 0F75F5512A6B1CA800A45078 /* message_loop.h in Headers */, + 0F75F55F2A6B1CA800A45078 /* menu_helpers.h in Headers */, + 0F75F4C22A6B1CA800A45078 /* titleformat.h in Headers */, + 0F75F4ED2A6B1CA800A45078 /* keyValueIO.h in Headers */, + 0F75F5212A6B1CA800A45078 /* vis.h in Headers */, + 0F75F51D2A6B1CA800A45078 /* imageViewer.h in Headers */, + 0F75F4F62A6B1CA800A45078 /* info_lookup_handler.h in Headers */, + 0F75F5302A6B1CA800A45078 /* metadb_index.h in Headers */, + 0F75F4B22A6B1CA800A45078 /* event_logger.h in Headers */, + 0F75F50A2A6B1CA800A45078 /* playable_location.h in Headers */, + 0F75F53E2A6B1CA800A45078 /* system_time_keeper.h in Headers */, + 0F75F4D92A6B1CA800A45078 /* playback_control.h in Headers */, + 0F75F4F02A6B1CA800A45078 /* imageLoaderLite.h in Headers */, + 0F75F5402A6B1CA800A45078 /* file_info_const_impl.h in Headers */, + 0F75F52C2A6B1CA800A45078 /* dsp-frontend.h in Headers */, + 0F75F5482A6B1CA800A45078 /* advconfig.h in Headers */, + 0F75F54B2A6B1CA800A45078 /* keyValueIOimpl.h in Headers */, + 0F75F53A2A6B1CA800A45078 /* commonObjects.h in Headers */, + 0F75F5492A6B1CA800A45078 /* fsitem.h in Headers */, + 0F75F4AF2A6B1CA800A45078 /* chapterizer.h in Headers */, + 0F75F5442A6B1CA800A45078 /* replaygain_scanner.h in Headers */, + 0F75F4A82A6B1CA800A45078 /* threadPool.h in Headers */, + 0F75F5142A6B1CA800A45078 /* completion_notify.h in Headers */, + 0F75F4A02A6B1CA800A45078 /* main_thread_callback.h in Headers */, + 0F75F5192A6B1CA800A45078 /* ui_element.h in Headers */, + 0F75F5272A6B1CA800A45078 /* preferences_page.h in Headers */, + 0F75F5542A6B1CA800A45078 /* library_manager.h in Headers */, + 0F75F4AA2A6B1CA800A45078 /* unpack.h in Headers */, + 0F75F4FE2A6B1CA800A45078 /* foobar2000-versions.h in Headers */, + 0F75F4A32A6B1CA800A45078 /* progress_meter.h in Headers */, + 0F75F5022A6B1CA800A45078 /* file.h in Headers */, + 0F75F4F52A6B1CA800A45078 /* ole_interaction.h in Headers */, + 0F75F5392A6B1CA800A45078 /* file_format_sanitizer.h in Headers */, + 0F75F5572A6B1CA800A45078 /* coreversion.h in Headers */, + 0F75F50C2A6B1CA800A45078 /* configStore.h in Headers */, + 0F75F53D2A6B1CA800A45078 /* archive.h in Headers */, + 0F75F4D72A6B1CA800A45078 /* foosort.h in Headers */, + 0F75F5122A6B1CA800A45078 /* metadb_info_container_impl.h in Headers */, + 0F75F4E32A6B1CA800A45078 /* track_property.h in Headers */, + 0F75F5162A6B1CA800A45078 /* dsp_manager.h in Headers */, + 0F75F53B2A6B1CA800A45078 /* powerManager.h in Headers */, + 0F75F4E82A6B1CA800A45078 /* component_client.h in Headers */, + 0F75F52D2A6B1CA800A45078 /* foobar2000-sdk-pch.h in Headers */, + 0F75F5562A6B1CA800A45078 /* commandline.h in Headers */, + 0F75F4B52A6B1CA800A45078 /* hasher_md5.h in Headers */, + 0F75F4A42A6B1CA800A45078 /* app_close_blocker.h in Headers */, + 0F75F4FF2A6B1CA800A45078 /* componentversion.h in Headers */, + 0F75F4B92A6B1CA800A45078 /* metadb.h in Headers */, + 0F75F54A2A6B1CA800A45078 /* icon_remap.h in Headers */, + 0F75F4FC2A6B1CA800A45078 /* metadb_handle.h in Headers */, + 0F75F4BD2A6B1CA800A45078 /* foobar2000-winver.h in Headers */, + 0F75F4BE2A6B1CA800A45078 /* timer.h in Headers */, + 0F75F4B72A6B1CA800A45078 /* forward_types.h in Headers */, + 0F75F4F72A6B1CA800A45078 /* library_index.h in Headers */, + 0F75F4EE2A6B1CA800A45078 /* tracks.h in Headers */, + 0F75F5552A6B1CA800A45078 /* foobar2000-lite.h in Headers */, + 0F75F49A2A6B1CA800A45078 /* output.h in Headers */, + 0F75F4CD2A6B1CA800A45078 /* menu.h in Headers */, + 0F75F4B32A6B1CA800A45078 /* foobar2000-pfc.h in Headers */, + 0F75F53F2A6B1CA800A45078 /* play_callback.h in Headers */, + 0F75F5132A6B1CA800A45078 /* abort_callback.h in Headers */, + 0F75F4BC2A6B1CA800A45078 /* initquit.h in Headers */, + 0F75F5472A6B1CA800A45078 /* album_art.h in Headers */, + 0F75F55E2A6B1CA800A45078 /* cfg_var.h in Headers */, + 0F75F49F2A6B1CA800A45078 /* service_impl.h in Headers */, + 0F75F4A62A6B1CA800A45078 /* filesystem.h in Headers */, + 0F75F4B62A6B1CA800A45078 /* component.h in Headers */, + 0F75F5352A6B1CA800A45078 /* audio_postprocessor.h in Headers */, + 0F75F52B2A6B1CA800A45078 /* metadb_display_field_provider.h in Headers */, + 0F75F5362A6B1CA800A45078 /* file_info.h in Headers */, + 0F75F4E52A6B1CA800A45078 /* shortcut_actions.h in Headers */, + 0F75F4C52A6B1CA800A45078 /* filesystem_helper.h in Headers */, + 0F75F4DD2A6B1CA800A45078 /* library_callbacks.h in Headers */, + 0F75F50F2A6B1CA800A45078 /* config_io_callback.h in Headers */, + 0F75F49D2A6B1CA800A45078 /* playlist_loader.h in Headers */, + 0F75F54E2A6B1CA800A45078 /* input_file_type.h in Headers */, + 0F75F5452A6B1CA800A45078 /* tag_processor.h in Headers */, + 0F75F5382A6B1CA800A45078 /* input.h in Headers */, + 0F75F4E02A6B1CA800A45078 /* foobar2000-all.h in Headers */, + 0F75F5252A6B1CA800A45078 /* components_menu.h in Headers */, + 0F75F51B2A6B1CA800A45078 /* callback_merit.h in Headers */, + 0F75F4AD2A6B1CA800A45078 /* service.h in Headers */, + 0FDB0DFC2CEB60A900178906 /* ui_element_mac.h in Headers */, + 0F75F4B82A6B1CA800A45078 /* replaygain.h in Headers */, + 0F75F4A92A6B1CA800A45078 /* noInfo.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + B1DD3656198A721800EF7043 /* foobar2000_SDK */ = { + isa = PBXNativeTarget; + buildConfigurationList = B1DD365B198A721800EF7043 /* Build configuration list for PBXNativeTarget "foobar2000_SDK" */; + buildPhases = ( + B1DD3653198A721800EF7043 /* Sources */, + B1DD3654198A721800EF7043 /* Frameworks */, + B1DD3655198A721800EF7043 /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = foobar2000_SDK; + productName = foobar2000_SDK; + productReference = B1DD3657198A721800EF7043 /* libfoobar2000_SDK.a */; + productType = "com.apple.product-type.library.static"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + B1DD364F198A721800EF7043 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 1250; + ORGANIZATIONNAME = "___FULLUSERNAME___"; + }; + buildConfigurationList = B1DD3652198A721800EF7043 /* Build configuration list for PBXProject "foobar2000_SDK" */; + compatibilityVersion = "Xcode 12.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = B1DD364E198A721800EF7043; + productRefGroup = B1DD3658198A721800EF7043 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + B1DD3656198A721800EF7043 /* foobar2000_SDK */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + B1DD3653198A721800EF7043 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 0F75F5042A6B1CA800A45078 /* guids.cpp in Sources */, + 0F75F5242A6B1CA800A45078 /* chapterizer.cpp in Sources */, + 0F75F50D2A6B1CA800A45078 /* input.cpp in Sources */, + 0F75F5372A6B1CA800A45078 /* replaygain.cpp in Sources */, + 0F75F5462A6B1CA800A45078 /* input_file_type.cpp in Sources */, + 0FCA711C2AA2210C001CB0F2 /* commonObjects-Apple.mm in Sources */, + 0F75F5332A6B1CA800A45078 /* file_info_impl.cpp in Sources */, + 0F75F4C62A6B1CA800A45078 /* audio_chunk.cpp in Sources */, + 0F75F4D82A6B1CA800A45078 /* console.cpp in Sources */, + 0F75F4C02A6B1CA800A45078 /* track_property.cpp in Sources */, + 0F75F4BA2A6B1CA800A45078 /* menu_manager.cpp in Sources */, + 0F75F5322A6B1CA800A45078 /* app_close_blocker.cpp in Sources */, + 0F75F5112A6B1CA800A45078 /* completion_notify.cpp in Sources */, + 0F75F49B2A6B1CA800A45078 /* file_operation_callback.cpp in Sources */, + 0F75F5422A6B1CA800A45078 /* album_art.cpp in Sources */, + 0F75F5262A6B1CA800A45078 /* metadb_handle_list.cpp in Sources */, + 0F75F5072A6B1CA800A45078 /* config_object.cpp in Sources */, + 0F75F5432A6B1CA800A45078 /* main_thread_callback.cpp in Sources */, + 0F75F4A72A6B1CA800A45078 /* commonObjects.cpp in Sources */, + 0F75F51E2A6B1CA800A45078 /* popup_message.cpp in Sources */, + 0F75F52F2A6B1CA800A45078 /* replaygain_info.cpp in Sources */, + 0F75F5232A6B1CA800A45078 /* componentversion.cpp in Sources */, + 0F75F5592A6B1CA800A45078 /* playback_control.cpp in Sources */, + 0F75F4E22A6B1CA800A45078 /* utility.cpp in Sources */, + 0F75F4942A6B1CA800A45078 /* foosort.cpp in Sources */, + 0F75F5052A6B1CA800A45078 /* tag_processor.cpp in Sources */, + 0F75F4E12A6B1CA800A45078 /* image.cpp in Sources */, + 0F75F5202A6B1CA800A45078 /* cfg_var_legacy.cpp in Sources */, + 0F75F51F2A6B1CA800A45078 /* fsItem.cpp in Sources */, + 0F75F4C12A6B1CA800A45078 /* ui.cpp in Sources */, + 0F75F4CF2A6B1CA800A45078 /* advconfig.cpp in Sources */, + 0F75F4F32A6B1CA800A45078 /* config_io_callback.cpp in Sources */, + 0F75F4F42A6B1CA800A45078 /* packet_decoder.cpp in Sources */, + 0F75F4DB2A6B1CA800A45078 /* file_info.cpp in Sources */, + 0F75F4AC2A6B1CA800A45078 /* menu_helpers.cpp in Sources */, + 0F75F4CA2A6B1CA800A45078 /* threaded_process.cpp in Sources */, + 0F75F5032A6B1CA800A45078 /* ui_element.cpp in Sources */, + 0F75F4A12A6B1CA800A45078 /* filesystem.cpp in Sources */, + 0F75F4A52A6B1CA800A45078 /* mem_block_container.cpp in Sources */, + 0F75F5312A6B1CA800A45078 /* mainmenu.cpp in Sources */, + 0F75F49C2A6B1CA800A45078 /* abort_callback.cpp in Sources */, + 0F75F52E2A6B1CA800A45078 /* file_cached_impl.cpp in Sources */, + 0F75F5522A6B1CA800A45078 /* playlist_loader.cpp in Sources */, + 0F75F4AE2A6B1CA800A45078 /* file_info_const_impl.cpp in Sources */, + 0F75F4982A6B1CA800A45078 /* file_info_merge.cpp in Sources */, + 0F75F4F22A6B1CA800A45078 /* preferences_page.cpp in Sources */, + 0F75F4C92A6B1CA800A45078 /* service.cpp in Sources */, + 0F75F4EA2A6B1CA800A45078 /* metadb.cpp in Sources */, + 0F75F4A22A6B1CA800A45078 /* stdafx.cpp in Sources */, + 0F75F51A2A6B1CA800A45078 /* menu_item.cpp in Sources */, + 0F75F4FB2A6B1CA800A45078 /* link_resolver.cpp in Sources */, + 0F75F4AB2A6B1CA800A45078 /* output.cpp in Sources */, + 0F75F4F12A6B1CA800A45078 /* playlist.cpp in Sources */, + 0F75F4E42A6B1CA800A45078 /* cfg_var.cpp in Sources */, + 0F75F55D2A6B1CA800A45078 /* dsp.cpp in Sources */, + 0F75F4B12A6B1CA800A45078 /* audio_chunk_channel_config.cpp in Sources */, + 0F75F4D52A6B1CA800A45078 /* configStore.cpp in Sources */, + 0F75F5342A6B1CA800A45078 /* tag_processor_id3v2.cpp in Sources */, + 0F75F4E92A6B1CA800A45078 /* playable_location.cpp in Sources */, + 0F75F5502A6B1CA800A45078 /* hasher_md5.cpp in Sources */, + 0F75F55C2A6B1CA800A45078 /* metadb_handle.cpp in Sources */, + 0F75F5582A6B1CA800A45078 /* dsp_manager.cpp in Sources */, + 0F75F4C42A6B1CA800A45078 /* filesystem_helper.cpp in Sources */, + 0F75F4F92A6B1CA800A45078 /* commandline.cpp in Sources */, + 0F75F4972A6B1CA800A45078 /* titleformat.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + B1DD3659198A721800EF7043 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "foobar2000-sdk-pch.h"; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + .., + ../.., + ); + IPHONEOS_DEPLOYMENT_TARGET = 12.1; + MACOSX_DEPLOYMENT_TARGET = 11.0; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SKIP_INSTALL = YES; + }; + name = Debug; + }; + B1DD365A198A721800EF7043 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_NO_COMMON_BLOCKS = YES; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "foobar2000-sdk-pch.h"; + GCC_PREPROCESSOR_DEFINITIONS = "NDEBUG=1"; + GCC_SYMBOLS_PRIVATE_EXTERN = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + .., + ../.., + ); + IPHONEOS_DEPLOYMENT_TARGET = 12.1; + MACOSX_DEPLOYMENT_TARGET = 11.0; + SDKROOT = macosx; + SKIP_INSTALL = YES; + }; + name = Release; + }; + B1DD365C198A721800EF7043 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + COMBINE_HIDPI_IMAGES = YES; + EXECUTABLE_PREFIX = lib; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + B1DD365D198A721800EF7043 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + COMBINE_HIDPI_IMAGES = YES; + EXECUTABLE_PREFIX = lib; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + B1DD3652198A721800EF7043 /* Build configuration list for PBXProject "foobar2000_SDK" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + B1DD3659198A721800EF7043 /* Debug */, + B1DD365A198A721800EF7043 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + B1DD365B198A721800EF7043 /* Build configuration list for PBXNativeTarget "foobar2000_SDK" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + B1DD365C198A721800EF7043 /* Debug */, + B1DD365D198A721800EF7043 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = B1DD364F198A721800EF7043 /* Project object */; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/foosort.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/foosort.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,162 @@ +#include "foobar2000-sdk-pch.h" +#include "foosort.h" +#include "threadPool.h" +#include "genrand.h" + +#define FOOSORT_PROFILING 0 + +namespace { +#if FOOSORT_PROFILING + typedef pfc::hires_timer foosort_timer; +#endif + + class foosort { + public: + foosort(pfc::sort_callback & cb, abort_callback & a) : m_abort(a), p_callback(cb) {} + + foosort fork() { + foosort ret ( * this ); + ret.genrand = genrand_service::g_create(); + return ret; + } + + size_t myrand(size_t cnt) { + PFC_ASSERT(cnt == (uint32_t)cnt); + return genrand->genrand((uint32_t)cnt); + } + + void squaresort(t_size const p_base, t_size const p_count) { + const t_size max = p_base + p_count; + for (t_size walk = p_base + 1; walk < max; ++walk) { + for (t_size prev = p_base; prev < walk; ++prev) { + p_callback.swap_check(prev, walk); + } + } + } + + + void _sort_2elem_helper(t_size & p_elem1, t_size & p_elem2) { + if (p_callback.compare(p_elem1, p_elem2) > 0) pfc::swap_t(p_elem1, p_elem2); + } + + t_size _pivot_helper(t_size const p_base, t_size const p_count) { + PFC_ASSERT(p_count > 2); + + //t_size val1 = p_base, val2 = p_base + (p_count / 2), val3 = p_base + (p_count - 1); + + t_size val1 = myrand(p_count), val2 = myrand(p_count - 1), val3 = myrand(p_count - 2); + if (val2 >= val1) val2++; + if (val3 >= val1) val3++; + if (val3 >= val2) val3++; + + val1 += p_base; val2 += p_base; val3 += p_base; + + _sort_2elem_helper(val1, val2); + _sort_2elem_helper(val1, val3); + _sort_2elem_helper(val2, val3); + + return val2; + } + + void newsort(t_size const p_base, t_size const p_count, size_t concurrency) { + if (p_count <= 4) { + squaresort(p_base, p_count); + return; + } + + this->m_abort.check(); +#if FOOSORT_PROFILING + foosort_timer t; + if ( concurrency > 1 ) t.start(); +#endif + + t_size pivot = _pivot_helper(p_base, p_count); + + { + const t_size target = p_base + p_count - 1; + if (pivot != target) { + p_callback.swap(pivot, target); pivot = target; + } + } + + + t_size partition = p_base; + { + bool asdf = false; + for (t_size walk = p_base; walk < pivot; ++walk) { + const int comp = p_callback.compare(walk, pivot); + bool trigger = false; + if (comp == 0) { + trigger = asdf; + asdf = !asdf; + } else if (comp < 0) { + trigger = true; + } + if (trigger) { + if (partition != walk) p_callback.swap(partition, walk); + partition++; + } + } + } + if (pivot != partition) { + p_callback.swap(pivot, partition); pivot = partition; + } + + const auto base1 = p_base, count1 = pivot - p_base; + const auto base2 = pivot + 1, count2 = p_count - (pivot + 1 - p_base); + + if (concurrency > 1) { + + size_t total = count1 + count2; + size_t con1 = (size_t)((uint64_t)count1 * (uint64_t)concurrency / (uint64_t)total); + if (con1 < 1) con1 = 1; + if (con1 > concurrency - 1) con1 = concurrency - 1; + size_t con2 = concurrency - con1; + +#if FOOSORT_PROFILING + FB2K_console_formatter() << "foosort pass: " << p_base << "+" << p_count << "(" << concurrency << ") took " << t.queryString(); + FB2K_console_formatter() << "foosort forking: " << base1 << "+" << count1 << "(" << con1 << ") + " << base2 << "+" << count2 << "(" << con2 << ")"; +#endif + pfc::counter cnt; + fb2k::cpuThreadPool::runMultiHelper([&] { + try { + switch (cnt++) { + case 0: + { foosort subsort = fork(); subsort.newsort(base1, count1, con1); } + break; + case 1: + newsort(base2, count2, con2); + break; + } + } catch (exception_aborted const &) {} + }, 2); + m_abort.check(); + } else { + newsort(base1, count1, 1); + newsort(base2, count2, 1); + } + } + private: + abort_callback & m_abort; + pfc::sort_callback & p_callback; + genrand_service::ptr genrand = genrand_service::g_create(); + }; + + + +} +namespace fb2k { + void sort(pfc::sort_callback & cb, size_t count, size_t concurrency, abort_callback & aborter) { +#ifdef FOOSORT_LIMIT_THREADS + if (concurrency > FOOSORT_LIMIT_THREADS) concurrency = FOOSORT_LIMIT_THREADS; +#endif +#if FOOSORT_PROFILING + foosort_timer t; t.start(); +#endif + foosort theFooSort(cb, aborter); + theFooSort.newsort(0, count, concurrency); +#if FOOSORT_PROFILING + FB2K_console_formatter() << "foosort took: " << t.queryString(); +#endif + } +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/foosort.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/foosort.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,13 @@ +#pragma once + +// #define FOOSORT_LIMIT_THREADS 1 + + +namespace fb2k { + + // foosort + // abortable multithreaded quicksort + // expects cb to handle concurrent calls as long as they do not touch the same items concurrently + void sort(pfc::sort_callback & cb, size_t count, size_t concurrency, abort_callback & aborter); + +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/foosortstring.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/foosortstring.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,12 @@ +#pragma once +#include + +#ifdef _WIN32 +#include // std::unique_ptr<> +#endif + +namespace fb2k { + using pfc::sortString_t; + using pfc::sortStringCompare; + using pfc::makeSortString; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/forward_types.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/forward_types.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,39 @@ +#pragma once + +namespace foobar2000_io +{ + class abort_callback; +} + +namespace fb2k { + class image; + typedef service_ptr_t imageRef; + + class memBlock; +} + +typedef fb2k::memBlock album_art_data; + +typedef service_ptr_t album_art_data_ptr; + +class file_info; +class playable_location; + +class titleformat_object; +class titleformat_hook; +class titleformat_text_filter; + +typedef service_ptr_t titleformat_object_ptr; + +class mem_block_container; + +class file_info_filter; + +class metadb_handle; +typedef service_ptr_t metadb_handle_ptr; + +namespace foobar2000_io { + class stream_reader; class stream_writer; +} + +class metadb_io_callback_v2_data; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/fsItem.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/fsItem.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,429 @@ +#include "foobar2000-sdk-pch.h" + + +t_filestats2 fsItemBase::getStatsOpportunist() { + return filestats2_invalid; +} + +void fsItemBase::remove(abort_callback& aborter) { + getFS()->remove(this->canonicalPath()->c_str(), aborter); +} + +fb2k::stringRef fsItemBase::shortName() { + return nameWithExt(); +} + +file::ptr fsItemFile::openRead(abort_callback& aborter) { + return open(filesystem::open_mode_read, aborter); +} +file::ptr fsItemFile::openWriteExisting(abort_callback& aborter) { + return open(filesystem::open_mode_write_existing, aborter); +} +file::ptr fsItemFile::openWriteNew(abort_callback& aborter) { + return open(filesystem::open_mode_write_new, aborter); +} + +void fsItemFolder::removeRecur(abort_callback& aborter) { + auto list = this->listContents(listMode::filesAndFolders | listMode::hidden | listMode::suppressStats, aborter); + for (auto i : list->typed< fsItemBase >()) { + fsItemFolderPtr f; + if (f &= i) f->removeRecur(aborter); + else i->remove(aborter); + } + + this->remove(aborter); +} + +void fsItemFile::copyToOther(fsItemFilePtr other, abort_callback& aborter) { + aborter.check(); + + auto fSource = this->openRead(aborter); + auto fTarget = other->openWriteNew(aborter); + file::g_transfer_file(fSource, fTarget, aborter); + + // fTarget->commit(aborter); + + // we cannot transfer other properties, this should be overridden for such +} + +fsItemPtr fsItemBase::copyTo(fsItemFolderPtr folder, const char* desiredName, unsigned createMode, abort_callback& aborter) { + aborter.check(); + { + fsItemFilePtr f; + if (f &= this) { + auto target = folder->createFile(desiredName, createMode, aborter); + f->copyToOther(target, aborter); + return std::move(target); + } + } + { + fsItemFolderPtr f; + if (f &= this) { + auto target = folder->createFolder(desiredName, createMode, aborter); + auto contents = f->listContents(listMode::filesAndFolders | listMode::hidden | listMode::suppressStats, aborter); + for (auto item : contents->typed()) { + item->copyTo(target, createMode, aborter); + } + return std::move(target); + } + } + PFC_ASSERT(!"Should not get here, bad fsItemBase object"); + return nullptr; +} + +fsItemPtr fsItemBase::copyTo(fsItemFolderPtr folder, unsigned createMode, abort_callback& aborter) { + auto temp = this->nameWithExt(); + return this->copyTo(folder, temp->c_str(), createMode, aborter); +} + +fsItemPtr fsItemBase::moveTo(fsItemFolderPtr folder, const char* desiredName, unsigned createMode, abort_callback& aborter) { + auto ret = this->copyTo(folder, desiredName, createMode, aborter); + fsItemFolder::ptr asFolder; + if (asFolder &= this) { + asFolder->removeRecur(aborter); + } else { + this->remove(aborter); + } + return ret; +} + +fsItemPtr fsItemBase::moveTo(fsItemFolderPtr folder, unsigned createMode, abort_callback& aborter) { + auto fn = this->nameWithExt(); + return this->moveTo(folder, fn->c_str(), createMode, aborter); +} +fb2k::memBlockRef fsItemFile::readWhole(size_t sizeSanity, abort_callback& aborter) { + auto file = this->openRead(aborter); + auto size64 = file->get_size_ex(aborter); + if (size64 > sizeSanity) throw exception_io_data(); + auto size = (size_t)size64; + pfc::mem_block block; + block.resize(size); + file->read_object(block.ptr(), size, aborter); + return fb2k::memBlock::blockWithData(std::move(block)); +} + +namespace { + static void uniqueFn(pfc::string8& fn, unsigned add) { + if (add > 0) { + pfc::string8 fnOnly = pfc::remove_ext_v2(fn); + pfc::string8 ext = pfc::extract_ext_v2(fn); + fn = std::move(fnOnly); + fn << " (" << add << ")"; + if (ext.length() > 0) fn << "." << ext; + } + } + + using namespace fb2k; + class fsItemFileStd : public fsItemFile { + public: + fsItemFileStd(filesystem::ptr fs, stringRef canonicalPath, t_filestats2 const & opportunistStats) : m_fs(fs), m_path(canonicalPath), m_opportunistStats(opportunistStats) { + m_opportunistStats.set_folder(false); + m_opportunistStats.set_remote(fs->is_remote(canonicalPath->c_str())); + } + + filesystem::ptr getFS() override { return m_fs; } + + bool isRemote() override { return m_fs->is_remote(m_path->c_str()); } + + t_filestats2 getStats2(uint32_t s2flags, abort_callback& a) override { + auto s = m_fs->get_stats2_(m_path->c_str(), s2flags, a); + PFC_ASSERT((s2flags & stats2_fileOrFolder) == 0 || !s.is_folder()); + return s; + } + + fb2k::stringRef canonicalPath() override { return m_path; } + + fb2k::stringRef nameWithExt() override { + pfc::string8 temp; + m_fs->extract_filename_ext(m_path->c_str(), temp); + return makeString(temp); + } + fb2k::stringRef shortName() override { + pfc::string8 temp; + if (m_fs->get_display_name_short_(m_path->c_str(), temp)) return makeString(temp); + return nameWithExt(); + } + t_filestats2 getStatsOpportunist() override { + return m_opportunistStats; + } + file::ptr open(uint32_t openMode, abort_callback& aborter) override { + file::ptr ret; + m_fs->open(ret, m_path->c_str(), openMode, aborter); + return ret; + } + fb2k::memBlockRef readWhole(size_t sizeSanity, abort_callback& aborter) override { + // Prefer fs->readWholeFile over fsItemFile methods as the fs object might implement it + return m_fs->readWholeFile(m_path->c_str(), sizeSanity, aborter); + } + fsItemPtr moveTo(fsItemFolderPtr folder, const char* desiredName, unsigned createMode, abort_callback& aborter) override { + for (unsigned add = 0; ; ++add) { + pfc::string8 fn(desiredName); uniqueFn(fn, add); + pfc::string8 dst(folder->canonicalPath()->c_str()); + dst.end_with(m_fs->pathSeparator()); + dst += fn; + bool bDidExist = false; + try { + if (createMode == createMode::allowExisting) m_fs->move_overwrite(m_path->c_str(), dst, aborter); + else m_fs->move(m_path->c_str(), dst, aborter); + } catch (exception_io_already_exists const &) { + bDidExist = true; + } + + switch (createMode) { + case createMode::allowExisting: + break; // OK + case createMode::failIfExists: + if (bDidExist) throw exception_io_already_exists(); + break; // OK + case createMode::generateUniqueName: + if (bDidExist) { + continue; // the for loop + } + break; // OK + default: + PFC_ASSERT(!"Should not get here"); + break; + } + auto stats = m_opportunistStats; + stats.set_file(); + return m_fs->makeItemFileStd(dst, stats); + } + } + private: + const filesystem::ptr m_fs; + const stringRef m_path; + t_filestats2 m_opportunistStats; + }; + class fsItemFolderStd : public fsItemFolder { + public: + fsItemFolderStd(filesystem::ptr fs, stringRef canonicalPath, t_filestats2 const & opportunistStats) : m_fs(fs), m_path(canonicalPath), m_opportunistStats(opportunistStats) { + m_opportunistStats.set_folder(true); + m_opportunistStats.set_remote(fs->is_remote(canonicalPath->c_str())); + } + + filesystem::ptr getFS() override { return m_fs; } + + t_filestats2 getStatsOpportunist() override { + return m_opportunistStats; + } + + bool isRemote() override { return m_fs->is_remote(m_path->c_str()); } + + t_filestats2 getStats2(uint32_t s2flags, abort_callback& a) override { + auto s = m_fs->get_stats2_(m_path->c_str(), s2flags, a); + PFC_ASSERT((s2flags & stats2_fileOrFolder) == 0 || s.is_folder() ); + return s; + } + + fb2k::stringRef canonicalPath() override { return m_path; } + + fb2k::stringRef nameWithExt() override { + pfc::string8 temp; + m_fs->extract_filename_ext(m_path->c_str(), temp); + return makeString(temp); + } + fb2k::stringRef shortName() override { + pfc::string8 temp; + if (m_fs->get_display_name_short_(m_path->c_str(), temp)) return makeString(temp); + return nameWithExt(); + } + fb2k::arrayRef listContents(unsigned listMode, abort_callback& aborter) override { + auto out = arrayMutable::empty(); + filesystem::list_callback_t cb = [&] ( const char * p, t_filestats2 const & stats ) { + if (stats.is_folder()) { + if (listMode & listMode::folders) out->add(new service_impl_t< fsItemFolderStd >(m_fs, makeString(p), stats)); + } else { + if (listMode & listMode::files) out->add(new service_impl_t< fsItemFileStd >(m_fs, makeString(p), stats)); + } + }; + m_fs->list_directory_(m_path->c_str(), cb, listMode, aborter); + return out->copyConst(); + } + + fsItemFile::ptr findChildFile(const char* fileName, abort_callback& aborter) override { + auto sub = subPath(fileName); + auto stats = m_fs->get_stats2_(sub->c_str(), stats2_fileOrFolder | foobar2000_io::stats2_remote, aborter); + if (!stats.is_folder()) { + return m_fs->makeItemFileStd(sub->c_str(), stats); + } + throw exception_io_not_found(); + } + fsItemFolder::ptr findChildFolder(const char* fileName, abort_callback& aborter) override { + auto sub = subPath(fileName); + auto stats = m_fs->get_stats2_(sub->c_str(), stats2_fileOrFolder | foobar2000_io::stats2_remote, aborter); + if (stats.is_folder()) { + return m_fs->makeItemFolderStd(sub->c_str(), stats); + } + throw exception_io_not_found(); + } + fsItemBase::ptr findChild(const char* fileName, abort_callback& aborter) override { + auto sub = subPath(fileName); + auto stats = m_fs->get_stats2_(sub->c_str(), stats2_fileOrFolder | foobar2000_io::stats2_remote, aborter); + if ( stats.is_folder() ) { + return m_fs->makeItemFileStd(sub->c_str(), stats ); + } else { + return m_fs->makeItemFolderStd(sub->c_str(), stats ); + } + } + fsItemFile::ptr createFile(const char* fileName, unsigned createMode, abort_callback& aborter) override { + for (unsigned add = 0; ; ++add) { + pfc::string8 fn(fileName); uniqueFn(fn, add); + auto sub = subPath(fn); + + t_filestats2 stats; + + bool bDidExist = false; + try { + stats = m_fs->get_stats2_( sub->c_str(), stats2_all, aborter ); + bDidExist = stats.is_file(); + } catch(exception_io_not_found const &) {} + switch (createMode) { + case createMode::allowExisting: + break; // OK + case createMode::failIfExists: + if (bDidExist) throw exception_io_already_exists(); + break; // OK + case createMode::generateUniqueName: + if (bDidExist) { + continue; // the for loop + } + break; + default: + PFC_ASSERT(!"Should not get here"); + break; + } + if (!bDidExist) { + // actually create an empty file if it did not yet exist + // FIX ME this should be atomic with exists() check + file::ptr creator; + m_fs->open(creator, sub->c_str(), filesystem::open_mode_write_new, aborter); + stats = creator->get_stats2_( stats2_all, aborter ); + } + return m_fs->makeItemFileStd(sub->c_str(), stats); + } + } + fsItemFolder::ptr createFolder(const char* fileName, unsigned createMode, abort_callback& aborter) override { + for (unsigned add = 0; ; ++add) { + pfc::string8 fn(fileName); uniqueFn(fn, add); + auto sub = subPath(fn); + bool bDidExist = false; + try { + m_fs->create_directory(sub->c_str(), aborter); + } catch (exception_io_already_exists const &) { + bDidExist = true; + } + switch (createMode) { + case createMode::allowExisting: + break; // OK + case createMode::failIfExists: + if (bDidExist) throw exception_io_already_exists(); + break; + case createMode::generateUniqueName: + if (bDidExist) { + continue; // the for loop + } + break; + default: + PFC_ASSERT(!"Should not get here"); + break; + } + // Inherit opportunist stats + return m_fs->makeItemFolderStd(sub->c_str(), this->m_opportunistStats); + } + } + fsItemPtr moveTo(fsItemFolderPtr folder, const char* desiredName, unsigned createMode, abort_callback& aborter) override { + for (unsigned add = 0; ; ++add) { + pfc::string8 fn(desiredName); uniqueFn(fn, add); + pfc::string8 dst(folder->canonicalPath()->c_str()); + dst.end_with(m_fs->pathSeparator()); + dst += fn; + bool bDidExist = false; + try { + if (createMode == createMode::allowExisting) m_fs->move_overwrite(m_path->c_str(), dst, aborter); + else m_fs->move(m_path->c_str(), dst, aborter); + } catch (exception_io_already_exists const &) { + bDidExist = true; + } + + switch (createMode) { + case createMode::allowExisting: + break; // OK + case createMode::failIfExists: + if (bDidExist) throw exception_io_already_exists(); + break; // OK + case createMode::generateUniqueName: + if (bDidExist) { + continue; // the for loop + } + break; // OK + default: + PFC_ASSERT(!"Should not get here"); + break; + } + + return m_fs->makeItemFolderStd(dst, m_opportunistStats); + + } + } + private: + stringRef subPath(const char* name) { + pfc::string8 temp(m_path->c_str()); + temp.add_filename(name); + return makeString(temp); + } + const filesystem::ptr m_fs; + const stringRef m_path; + t_filestats2 m_opportunistStats; + }; +} + +fsItemFolder::ptr filesystem::makeItemFolderStd(const char* pathCanonical, t_filestats2 const& opportunistStats) { + return new service_impl_t(this, makeString(pathCanonical), opportunistStats); +} + +fsItemFile::ptr filesystem::makeItemFileStd(const char* pathCanonical, t_filestats2 const & opportunistStats) { + return new service_impl_t(this, makeString(pathCanonical), opportunistStats); +} +fsItemBase::ptr filesystem::findItem_(const char* path, abort_callback& p_abort) { + filesystem_v3::ptr v3; + if (v3 &= this) { + return v3->findItem(path, p_abort); + } + auto stats = this->get_stats2_(path, stats2_fileOrFolder, p_abort); + if (stats.is_folder()) return this->makeItemFolderStd(path, stats); + else return this->makeItemFileStd(path, stats); + +} +fsItemFile::ptr filesystem::findItemFile_(const char* path, abort_callback& p_abort) { + filesystem_v3::ptr v3; + if (v3 &= this) return v3->findItemFile(path, p_abort); + + auto stats = this->get_stats2_(path, stats2_fileOrFolder, p_abort); + if (!stats.is_folder()) return this->makeItemFileStd(path, stats); + throw exception_io_not_found(); +} +fsItemFolder::ptr filesystem::findItemFolder_(const char* path, abort_callback& p_abort) { + filesystem_v3::ptr v3; + if (v3 &= this) return v3->findItemFolder(path, p_abort); + + auto stats = this->get_stats2_(path, stats2_fileOrFolder, p_abort); + if (stats.is_folder()) return this->makeItemFolderStd(path, stats); + throw exception_io_not_found(); +} + + +fsItemBase::ptr fsItemBase::fromPath(const char* path, abort_callback& aborter) { + return filesystem::get(path)->findItem_(path, aborter); +} + +fsItemFile::ptr fsItemFile::fromPath(const char* path, abort_callback& aborter) { + return filesystem::get(path)->findItemFile_(path, aborter); +} + +fsItemFolder::ptr fsItemFolder::fromPath(const char* path, abort_callback& aborter) { + return filesystem::get(path)->findItemFolder_(path, aborter); +} + +t_filestats fsItemBase::getStats(abort_callback& a) { + return getStats2(stats2_all, a).to_legacy(); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/fsitem.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/fsitem.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,134 @@ +#pragma once + +// fsItem API +// Alternate, object-based way of accessing the local filesystem. +// It is recommended to use fsItem methods to operate on user-specified media folders. +// In some cases, notably Android and WinPhone/UWP, accessing user's documents/media over paths requires expensive resolving of objects representing them. +// fsItem can cache platform specific resources necessary to manipulate the files, allowing efficient opening of files returned by directory enumeration. +// +// Note that as of 2023, fsItem is just a convenience API. +// WinPhone/UWP has been dropped; slow and buggy Android DocumentFile (*) wrapper is being abandoned. On neither of these platforms foobar2000 supports loading components. +// Nothing in current-generation foobar2000 gains performance from using fsItem methods over plain filesystem with paths. +// +// (*) Android DocumentFile is slow and buggy, not the wrapper. Google sucks. + +#include "file.h" +#include "commonObjects.h" + +namespace foobar2000_io { + + namespace createMode { + enum { + failIfExists = 0, + allowExisting, + generateUniqueName + }; + } + namespace listMode { + enum { + //! Return files + files = 1, + //! Return folders + folders = 2, + //! Return both files and flders + filesAndFolders = files | folders, + //! Return hidden files + hidden = 4, + //! Do not hand over filestats unless they come for free with folder enumeration + suppressStats = 8, + }; + } + + class fsItemBase; class fsItemFile; class fsItemFolder; + typedef service_ptr_t fsItemPtr; + typedef service_ptr_t fsItemFilePtr; + typedef service_ptr_t fsItemFolderPtr; + class filesystem; + + //! Base class for filesystem items, files or folders. All fsItemBase objects actually belong to one of the main subclasses fsItemFile or fsItemFolder. + class fsItemBase : public service_base { + FB2K_MAKE_SERVICE_INTERFACE(fsItemBase, service_base); + public: + //! Returns possibly incomplete or outdated stats that are readily available without blocking. \n + //! The stats may have been fetched at the the object is created (as a part of directory enumeration). + virtual t_filestats2 getStatsOpportunist(); + + //! Returns this item's canonical path. + virtual fb2k::stringRef canonicalPath() = 0; + + //! Returns filename+extension / last path component + virtual fb2k::stringRef nameWithExt() = 0; + + + //! Shortened display name. By default same as nameWithExt(). + virtual fb2k::stringRef shortName(); + + //! Copies this item to the specified folder. \n + //! If this is a folder, it will be copied recursively. \n + //! This may be overridden for a specific filesystem to provide an optimized version; the default implementation walks and copies files using regular file APIs. + virtual fsItemPtr copyTo(fsItemFolderPtr folder, const char* desiredName, unsigned createMode, abort_callback& aborter); + //! See copyTo(4) above. \n + //! Uses source item's name (last path component, filename+ext or foldername). + fsItemPtr copyTo(fsItemFolderPtr folder, unsigned createMode, abort_callback& aborter); + + //! Moves this item to the specified folder. \n + //! If this is a folder, it will be moved recursively. \n + //! This may be overridden for a specific filesystem to provide an optimized version; the default implementation walks and moves files using regular file APIs. + virtual fsItemPtr moveTo(fsItemFolderPtr folder, const char* desiredName, unsigned createMode, abort_callback& aborter); + //! See moveTo(4) above. \n + //! Uses source item's name (last path component, filename+ext or foldername). + fsItemPtr moveTo(fsItemFolderPtr folder, unsigned createMode, abort_callback& aborter); + + //! Removes this item. + virtual void remove(abort_callback& aborter); + + //! Does represent remote object or local? + virtual bool isRemote() = 0; + + virtual t_filestats2 getStats2(uint32_t s2flags, abort_callback& aborter) = 0; + + virtual service_ptr_t getFS() = 0; + + static fsItemBase::ptr fromPath(const char* path, abort_callback& aborter); + + t_filestats getStats(abort_callback& a); + }; + + class fsItemFile : public fsItemBase { + FB2K_MAKE_SERVICE_INTERFACE(fsItemFile, fsItemBase); + public: + virtual file::ptr open(uint32_t openMode, abort_callback& aborter) = 0; + + file::ptr openRead(abort_callback& aborter); + file::ptr openWriteExisting(abort_callback& aborter); + file::ptr openWriteNew(abort_callback& aborter); + + //! Transfer this file's content and properties to another file. + virtual void copyToOther(fsItemFilePtr other, abort_callback& aborter); + + //! Returns the file's content type, if provided by the filesystem. \n + //! Null if not provided by the filesystem. + virtual fb2k::stringRef getContentType(abort_callback&) { return nullptr; } + + static fsItemFile::ptr fromPath(const char* path, abort_callback& aborter); + + virtual fb2k::memBlockRef readWhole(size_t sizeSanity, abort_callback& aborter); + }; + + class fsItemFolder : public fsItemBase { + FB2K_MAKE_SERVICE_INTERFACE(fsItemFolder, fsItemBase); + public: + virtual fb2k::arrayRef listContents(unsigned listMode, abort_callback& aborter) = 0; + virtual fsItemBase::ptr findChild(const char* fileName, abort_callback& aborter) = 0; + virtual fsItemFile::ptr findChildFile(const char* fileName, abort_callback& aborter) = 0; + virtual fsItemFolder::ptr findChildFolder(const char* fileName, abort_callback& aborter) = 0; + virtual fsItemFile::ptr createFile(const char* fileName, unsigned createMode, abort_callback& aborter) = 0; + virtual fsItemFolder::ptr createFolder(const char* fileName, unsigned createMode, abort_callback& aborter) = 0; + + //! Removes this folder recursively. + virtual void removeRecur(abort_callback& aborter); + + static fsItemFolder::ptr fromPath(const char* path, abort_callback& aborter); + }; + +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/genrand.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/genrand.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,45 @@ +#pragma once +//! PRNG service. Implemented by the core, do not reimplement. Use g_create() helper function to instantiate. +class NOVTABLE genrand_service : public service_base +{ +public: + void seedAuto() {seed( 0 ) ;} + //! Seeds the PRNG with specified value. \n + //! Default value of zero seeds automatically using available system functions. + virtual void seed(unsigned val = 0) = 0; + //! Returns random value N, where 0 <= N < range. + virtual unsigned genrand(unsigned range)=0; + + double genrand_f() { return (double)genrand(0xFFFFFFFF) / (double)0xFFFFFFFF; } + + void genrand_blob( void * out, size_t bytes ) { + size_t dwords = bytes/4; + uint32_t * out32 = (uint32_t*) out; + for(size_t w = 0; w < dwords; ++w ) { + out32[w] = genrand32(); + } + size_t left = bytes % 4; + if (left > 0) { + auto leftptr = (uint8_t*) out + (bytes-left); + for( size_t w = 0; w < left; ++w) leftptr[w] = genrand8(); + } + } + + uint32_t genrand32() { + return (uint32_t) genrand(0xFFFFFFFF); + } + uint8_t genrand8() { + return (uint8_t) genrand(0x100); + } + + static service_ptr_t g_create() {return standard_api_create_t();} + + void generate_random_order(t_size * out, t_size count) { + unsigned genrandMax = (unsigned) pfc::min_t(count, 0xFFFFFFFF); + t_size n; + for(n=0;n= 80 +FOOGUIDDECL const GUID ui_control_v2::class_guid = { 0x6fc5d5c3, 0x13aa, 0x4f7f, { 0x97, 0x8d, 0x89, 0x6b, 0x9b, 0x90, 0x4a, 0x5 } }; +#endif // FOOBAR2000_TARGET_VERSION >= 80 + + +// {392B88DE-50FC-43b0-9F03-2D79B071CAF6} +FOOGUIDDECL const GUID ui_status_text_override::class_guid = +{ 0x392b88de, 0x50fc, 0x43b0, { 0x9f, 0x3, 0x2d, 0x79, 0xb0, 0x71, 0xca, 0xf6 } }; + +#ifdef _WIN32 +// {52BD7A17-540C-4a97-B812-72BC84EC4FF5} +FOOGUIDDECL const GUID ui_drop_item_callback::class_guid = +{ 0x52bd7a17, 0x540c, 0x4a97, { 0xb8, 0x12, 0x72, 0xbc, 0x84, 0xec, 0x4f, 0xf5 } }; +#endif + +// {550B3A19-42A4-4c0f-91F2-90550189CBFF} +FOOGUIDDECL const GUID commandline_handler::class_guid = +{ 0x550b3a19, 0x42a4, 0x4c0f, { 0x91, 0xf2, 0x90, 0x55, 0x1, 0x89, 0xcb, 0xff } }; + +#ifdef _WIN32 +// {C71B99BD-12C5-48fe-A9C0-469F6FEA88BF} +FOOGUIDDECL const GUID modeless_dialog_manager::class_guid = +{ 0xc71b99bd, 0x12c5, 0x48fe, { 0xa9, 0xc0, 0x46, 0x9f, 0x6f, 0xea, 0x88, 0xbf } }; +#endif + +// {78BCBFA1-DFB9-487f-AB16-CD82BF90CCF7} +FOOGUIDDECL const GUID play_callback_manager::class_guid = +{ 0x78bcbfa1, 0xdfb9, 0x487f, { 0xab, 0x16, 0xcd, 0x82, 0xbf, 0x90, 0xcc, 0xf7 } }; + +// {8E4EED7A-C6B8-49c7-99FE-97E04AAA63A8} +FOOGUIDDECL const GUID play_callback_static::class_guid = +{ 0x8e4eed7a, 0xc6b8, 0x49c7, { 0x99, 0xfe, 0x97, 0xe0, 0x4a, 0xaa, 0x63, 0xa8 } }; + +// {BF803668-2977-4c71-B9AB-5C77C338C970} +FOOGUIDDECL const GUID playback_control::class_guid = +{ 0xbf803668, 0x2977, 0x4c71, { 0xb9, 0xab, 0x5c, 0x77, 0xc3, 0x38, 0xc9, 0x70 } }; + +// {242D9341-211A-4637-A69F-F6684B52F9D6} +FOOGUIDDECL const GUID playlist_callback_static::class_guid = +{ 0x242d9341, 0x211a, 0x4637, { 0xa6, 0x9f, 0xf6, 0x68, 0x4b, 0x52, 0xf9, 0xd6 } }; + +// {95E9F11B-4C99-4d0a-AB9F-367196B10925} +FOOGUIDDECL const GUID playlist_callback_single_static::class_guid = +{ 0x95e9f11b, 0x4c99, 0x4d0a, { 0xab, 0x9f, 0x36, 0x71, 0x96, 0xb1, 0x9, 0x25 } }; + +// {88D7EDB1-A850-42a4-BBAB-49E955F4B81F} +FOOGUIDDECL const GUID playlist_lock::class_guid = +{ 0x88d7edb1, 0xa850, 0x42a4, { 0xbb, 0xab, 0x49, 0xe9, 0x55, 0xf4, 0xb8, 0x1f } }; + +// {2FBCE1E5-902E-49e0-B9CF-CE0FBA765348} +FOOGUIDDECL const GUID filesystem::class_guid = +{ 0x2fbce1e5, 0x902e, 0x49e0, { 0xb9, 0xcf, 0xce, 0xf, 0xba, 0x76, 0x53, 0x48 } }; + +// {9098AF12-61A3-4caa-8AA9-BB95C2EF8346} +FOOGUIDDECL const GUID unpacker::class_guid = +{ 0x9098af12, 0x61a3, 0x4caa, { 0x8a, 0xa9, 0xbb, 0x95, 0xc2, 0xef, 0x83, 0x46 } }; + +// {EC707440-FA3E-4d12-9876-FC369F04D4A4} +FOOGUIDDECL const GUID archive::class_guid = +{ 0xec707440, 0xfa3e, 0x4d12, { 0x98, 0x76, 0xfc, 0x36, 0x9f, 0x4, 0xd4, 0xa4 } }; + +// {69897890-90CB-4F7D-9969-1A9DCC5D9DDB} +FOOGUIDDECL const GUID archive_v2::class_guid = +{ 0x69897890, 0x90cb, 0x4f7d, { 0x99, 0x69, 0x1a, 0x9d, 0xcc, 0x5d, 0x9d, 0xdb } }; + +// {8D3F8B2D-A866-4F1F-9A4F-FF23929ED6DA} +FOOGUIDDECL const GUID archive_v3::class_guid = +{ 0x8d3f8b2d, 0xa866, 0x4f1f, { 0x9a, 0x4f, 0xff, 0x23, 0x92, 0x9e, 0xd6, 0xda } }; + +// {FD3AE540-4C46-43AD-A331-2337737A64C6} +FOOGUIDDECL const GUID archive_v4::class_guid = +{ 0xfd3ae540, 0x4c46, 0x43ad, { 0xa3, 0x31, 0x23, 0x37, 0x73, 0x7a, 0x64, 0xc6 } }; + +// {B2F9FC40-3E55-4b23-A2C9-22BAAD8795B1} +FOOGUIDDECL const GUID file::class_guid = +{ 0xb2f9fc40, 0x3e55, 0x4b23, { 0xa2, 0xc9, 0x22, 0xba, 0xad, 0x87, 0x95, 0xb1 } }; + +// {6374340F-82D4-4471-A24B-A754B1398285} +FOOGUIDDECL const GUID file_dynamicinfo::class_guid = +{ 0x6374340f, 0x82d4, 0x4471, { 0xa2, 0x4b, 0xa7, 0x54, 0xb1, 0x39, 0x82, 0x85 } }; + +// {E171F954-4D7D-4F6F-9CC4-8A5B580BD410} +FOOGUIDDECL const GUID file_dynamicinfo_v2::class_guid = +{ 0xe171f954, 0x4d7d, 0x4f6f, { 0x9c, 0xc4, 0x8a, 0x5b, 0x58, 0xb, 0xd4, 0x10 } }; + +// {89FC86C9-D3DB-4ABB-B3B7-705BE43C86DB} +FOOGUIDDECL const GUID file_cached::class_guid = +{ 0x67fc5d4c, 0x50ed, 0x4da3, { 0x95, 0x42, 0x9b, 0x30, 0xc4, 0xa4, 0x42, 0x9a } }; + +FOOGUIDDECL const GUID file_v2::class_guid = +{ 0x92853288, 0xbbaf, 0x46dc, { 0x81, 0xe2, 0xe9, 0x36, 0x4f, 0x5e, 0x1d, 0x77 } }; + +// {49F362C6-DAEA-4F3C-8431-CDF00FA4811E} +FOOGUIDDECL const GUID file_metadata_http::class_guid = +{ 0x49f362c6, 0xdaea, 0x4f3c, { 0x84, 0x31, 0xcd, 0xf0, 0xf, 0xa4, 0x81, 0x1e } }; + +// {A00CB77D-ED72-4031-806B-4E45AF995241} +FOOGUIDDECL const GUID replaygain_manager::class_guid = +{ 0xa00cb77d, 0xed72, 0x4031, { 0x80, 0x6b, 0x4e, 0x45, 0xaf, 0x99, 0x52, 0x41 } }; + +// {2DD58954-09E0-4B3B-AEE6-484E83111A73} +FOOGUIDDECL const GUID replaygain_manager_v2::class_guid = +{ 0x2dd58954, 0x9e0, 0x4b3b,{ 0xae, 0xe6, 0x48, 0x4e, 0x83, 0x11, 0x1a, 0x73 } }; + +// {3F7674AB-044C-4796-8801-6C443C244D88} +FOOGUIDDECL const GUID titleformat_compiler::class_guid = +{ 0x3f7674ab, 0x44c, 0x4796, { 0x88, 0x1, 0x6c, 0x44, 0x3c, 0x24, 0x4d, 0x88 } }; + +// {0A81DE54-8131-4C43-92EF-15C58BD4727A} +FOOGUIDDECL const GUID titleformat_compiler_v2::class_guid = +{ 0xa81de54, 0x8131, 0x4c43, { 0x92, 0xef, 0x15, 0xc5, 0x8b, 0xd4, 0x72, 0x7a } }; + +FOOGUIDDECL const GUID user_interface::class_guid = { 0x1add4dc4, 0xb278, 0x4a0c, { 0xa1, 0x5, 0x26, 0x29, 0xf4, 0xb3, 0x12, 0xf4 } }; +FOOGUIDDECL const GUID user_interface_v2::class_guid = { 0x5f5ac82b, 0x44a7, 0x4872,{ 0xb7, 0x86, 0x1c, 0x1f, 0xc6, 0x56, 0x6b, 0x60 } }; + +#ifdef _WIN32 +FOOGUIDDECL const GUID user_interface_v2::cap_suppress_core_shellhook = { 0xe5950632, 0x750d, 0x4265,{ 0x8c, 0xea, 0x6c, 0xf2, 0x77, 0x91, 0x44, 0x40 } }; +FOOGUIDDECL const GUID user_interface_v2::cap_suppress_core_uvc = { 0xe35156b2, 0xfbac, 0x450d,{ 0xa3, 0xf7, 0xf1, 0xda, 0x46, 0xb6, 0xdf, 0x8d } }; +#endif + +FOOGUIDDECL const GUID user_interface_v3::class_guid = { 0x4fa87b73, 0x7e4, 0x4814, { 0x8f, 0x70, 0x66, 0x28, 0x7a, 0x18, 0x8b, 0xaa } }; +FOOGUIDDECL const GUID user_interface_v4::class_guid = { 0xd9069882, 0x51ed, 0x4f05, { 0x82, 0x46, 0x9b, 0x50, 0x82, 0xe0, 0x25, 0x26 } }; + +// {994C0D0E-319E-45f3-92FC-518616E73ADC} +FOOGUIDDECL const GUID contextmenu_item::caller_now_playing = +{ 0x994c0d0e, 0x319e, 0x45f3, { 0x92, 0xfc, 0x51, 0x86, 0x16, 0xe7, 0x3a, 0xdc } }; + +// {47502BA1-816D-4a3e-ADE5-A7A9860A67DB} +FOOGUIDDECL const GUID contextmenu_item::caller_active_playlist_selection = +{ 0x47502ba1, 0x816d, 0x4a3e, { 0xad, 0xe5, 0xa7, 0xa9, 0x86, 0xa, 0x67, 0xdb } }; + +// Deprecated. +FOOGUIDDECL const GUID contextmenu_item::caller_playlist = caller_active_playlist_selection; + +// {B3CC1030-EF26-45cf-A84A-7FC169BC9FFB} +FOOGUIDDECL const GUID contextmenu_item::caller_active_playlist = +{ 0xb3cc1030, 0xef26, 0x45cf, { 0xa8, 0x4a, 0x7f, 0xc1, 0x69, 0xbc, 0x9f, 0xfb } }; + +// {5FDCD5E8-6EB2-4454-9EDA-527522893BED} +FOOGUIDDECL const GUID contextmenu_item::caller_playlist_manager = +{ 0x5fdcd5e8, 0x6eb2, 0x4454, { 0x9e, 0xda, 0x52, 0x75, 0x22, 0x89, 0x3b, 0xed } }; + +// {00000000-0000-0000-0000-000000000000} +FOOGUIDDECL const GUID contextmenu_item::caller_undefined = +{ 0x00000000, 0x0000, 0x0000, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }; + +// {FABEE3E9-8901-4df4-A2D7-B9898D86C39B} +FOOGUIDDECL const GUID contextmenu_item::caller_keyboard_shortcut_list = +{ 0xfabee3e9, 0x8901, 0x4df4, { 0xa2, 0xd7, 0xb9, 0x89, 0x8d, 0x86, 0xc3, 0x9b } }; + +// {FDA07C56-05D0-4b84-9FBD-A8BE556D474D} +FOOGUIDDECL const GUID contextmenu_item::caller_media_library_viewer = +{ 0xfda07c56, 0x5d0, 0x4b84, { 0x9f, 0xbd, 0xa8, 0xbe, 0x55, 0x6d, 0x47, 0x4d } }; + +#ifdef FOOBAR2000_HAVE_KEYBOARD_SHORTCUTS +// {95DE5842-30F5-4f72-B40C-191663782F80} +FOOGUIDDECL const GUID keyboard_shortcut_manager::class_guid = +{ 0x95de5842, 0x30f5, 0x4f72, { 0xb4, 0xc, 0x19, 0x16, 0x63, 0x78, 0x2f, 0x80 } }; + +// {CD19C870-DA6A-4b8a-A118-732A8102D07D} +FOOGUIDDECL const GUID keyboard_shortcut_manager_v2::class_guid = +{ 0xcd19c870, 0xda6a, 0x4b8a, { 0xa1, 0x18, 0x73, 0x2a, 0x81, 0x2, 0xd0, 0x7d } }; +#endif // FOOBAR2000_HAVE_KEYBOARD_SHORTCUTS + +// {30F95BEB-FDF4-4a75-B597-60CAF93B39C4} +FOOGUIDDECL const GUID packet_decoder::owner_MP4 = +{ 0x30f95beb, 0xfdf4, 0x4a75, { 0xb5, 0x97, 0x60, 0xca, 0xf9, 0x3b, 0x39, 0xc4 } }; + +// {8F450CB3-A083-4b83-8D85-ADCE5EA6D57F} +FOOGUIDDECL const GUID packet_decoder::owner_MP4_ALAC = +{ 0x8f450cb3, 0xa083, 0x4b83, { 0x8d, 0x85, 0xad, 0xce, 0x5e, 0xa6, 0xd5, 0x7f } }; + +// {62263199-48C2-4777-B33A-87ED161A1630} +FOOGUIDDECL const GUID packet_decoder::owner_MP4_AC3 = +{ 0x62263199, 0x48c2, 0x4777, { 0xb3, 0x3a, 0x87, 0xed, 0x16, 0x1a, 0x16, 0x30 } }; + +// {AE6325BE-6C65-4B8F-B60D-5C803763BFB5} +FOOGUIDDECL const GUID packet_decoder::owner_MP4_EAC3 = +{ 0xae6325be, 0x6c65, 0x4b8f, { 0xb6, 0xd, 0x5c, 0x80, 0x37, 0x63, 0xbf, 0xb5 } }; + + +// {40017871-50A9-48b6-BF60-BD181A227F9B} +FOOGUIDDECL const GUID packet_decoder::owner_MP4_AMR = +{ 0x40017871, 0x50a9, 0x48b6, { 0xbf, 0x60, 0xbd, 0x18, 0x1a, 0x22, 0x7f, 0x9b } }; + +// {2E729EA0-6BEB-4392-BF24-75C69B60166D} +FOOGUIDDECL const GUID packet_decoder::owner_MP4_AMR_WB = +{ 0x2e729ea0, 0x6beb, 0x4392, { 0xbf, 0x24, 0x75, 0xc6, 0x9b, 0x60, 0x16, 0x6d } }; + +// {73E5E053-662F-4A43-8DF2-09F977AC2D38} +FOOGUIDDECL const GUID packet_decoder::owner_MP4_FLAC = +{ 0x73e5e053, 0x662f, 0x4a43, { 0x8d, 0xf2, 0x9, 0xf9, 0x77, 0xac, 0x2d, 0x38 } }; + +// {595FF6B0-F860-43CF-A54C-6D8D29E12F62} +FOOGUIDDECL const GUID packet_decoder::owner_MP4_Opus = +{ 0x595ff6b0, 0xf860, 0x43cf, { 0xa5, 0x4c, 0x6d, 0x8d, 0x29, 0xe1, 0x2f, 0x62 } }; + +// {E10C6D93-3271-4AAA-B0E6-231AB14BEFFA} +FOOGUIDDECL const GUID packet_decoder::owner_MP4_MPEGH = +{ 0xe10c6d93, 0x3271, 0x4aaa, { 0xb0, 0xe6, 0x23, 0x1a, 0xb1, 0x4b, 0xef, 0xfa } }; + +// {AF5B7CB0-A08E-404a-A3C0-5C5EA1A8A05C} +FOOGUIDDECL const GUID packet_decoder::owner_ADTS = +{ 0xaf5b7cb0, 0xa08e, 0x404a, { 0xa3, 0xc0, 0x5c, 0x5e, 0xa1, 0xa8, 0xa0, 0x5c } }; + +// {F72D2EAE-835C-4dfb-97C6-624343EFAFB0} +FOOGUIDDECL const GUID packet_decoder::owner_ADIF = +{ 0xf72d2eae, 0x835c, 0x4dfb, { 0x97, 0xc6, 0x62, 0x43, 0x43, 0xef, 0xaf, 0xb0 } }; + +// {5C2DE804-EAEE-4b8e-8C14-9207A2549BBE} +FOOGUIDDECL const GUID packet_decoder::owner_matroska = +{ 0x5c2de804, 0xeaee, 0x4b8e, { 0x8c, 0x14, 0x92, 0x7, 0xa2, 0x54, 0x9b, 0xbe } }; + +// {7B741A69-1AC7-440d-A01D-88536DD4DE1C} +FOOGUIDDECL const GUID packet_decoder::owner_MP3 = +{ 0x7b741a69, 0x1ac7, 0x440d, { 0xa0, 0x1d, 0x88, 0x53, 0x6d, 0xd4, 0xde, 0x1c } }; + +// {17B300A0-3110-4400-A434-C18FBEEABA81} +FOOGUIDDECL const GUID packet_decoder::owner_MP2 = +{ 0x17b300a0, 0x3110, 0x4400, { 0xa4, 0x34, 0xc1, 0x8f, 0xbe, 0xea, 0xba, 0x81 } }; + +// {1C068E5E-DD65-4639-BF85-78B297C8FFAC} +FOOGUIDDECL const GUID packet_decoder::owner_MP1 = +{ 0x1c068e5e, 0xdd65, 0x4639, { 0xbf, 0x85, 0x78, 0xb2, 0x97, 0xc8, 0xff, 0xac } }; + +// {BC73F9FC-0107-480e-BF0E-BE58AF7AF328} +FOOGUIDDECL const GUID packet_decoder::property_samplerate = +{ 0xbc73f9fc, 0x107, 0x480e, { 0xbf, 0xe, 0xbe, 0x58, 0xaf, 0x7a, 0xf3, 0x28 } }; + +// {E5D19AAD-931B-48ac-AA6E-95E2C23BEC37} +FOOGUIDDECL const GUID packet_decoder::property_bitspersample = +{ 0xe5d19aad, 0x931b, 0x48ac, { 0xaa, 0x6e, 0x95, 0xe2, 0xc2, 0x3b, 0xec, 0x37 } }; + +// {1AFA1145-E774-4c26-91D6-3F5DD61E260E} +FOOGUIDDECL const GUID packet_decoder::property_channels = +{ 0x1afa1145, 0xe774, 0x4c26, { 0x91, 0xd6, 0x3f, 0x5d, 0xd6, 0x1e, 0x26, 0xe } }; + +// {29C556DA-065A-4d24-8A11-0F9DBC05A817} +FOOGUIDDECL const GUID packet_decoder::property_byteorder = +{ 0x29c556da, 0x65a, 0x4d24, { 0x8a, 0x11, 0xf, 0x9d, 0xbc, 0x5, 0xa8, 0x17 } }; + +// {0759C32F-E78E-4479-B0C0-B653DFA014D8} +FOOGUIDDECL const GUID packet_decoder::property_signed = +{ 0x759c32f, 0xe78e, 0x4479, { 0xb0, 0xc0, 0xb6, 0x53, 0xdf, 0xa0, 0x14, 0xd8 } }; + +// {BB31669E-0C30-4c5f-AAF0-20CD49D46058} +FOOGUIDDECL const GUID packet_decoder::property_channelmask = +{ 0xbb31669e, 0xc30, 0x4c5f, { 0xaa, 0xf0, 0x20, 0xcd, 0x49, 0xd4, 0x60, 0x58 } }; + +// {E2C734FD-D4C2-467E-B5D3-4C13D9BD300E} +FOOGUIDDECL const GUID packet_decoder::property_bufferpadding = +{ 0xe2c734fd, 0xd4c2, 0x467e, { 0xb5, 0xd3, 0x4c, 0x13, 0xd9, 0xbd, 0x30, 0xe } }; + +// {61FD52AD-5146-417E-8662-36152E60A7D0} +FOOGUIDDECL const GUID packet_decoder::property_checkingintegrity = +{ 0x61fd52ad, 0x5146, 0x417e, { 0x86, 0x62, 0x36, 0x15, 0x2e, 0x60, 0xa7, 0xd0 } }; + +// {C9B4570D-00EB-4FA4-99DC-4AC39BAEF94D} +FOOGUIDDECL const GUID packet_decoder::property_samples_per_frame = +{ 0xc9b4570d, 0xeb, 0x4fa4, { 0x99, 0xdc, 0x4a, 0xc3, 0x9b, 0xae, 0xf9, 0x4d } }; + +// {809A5B7F-99D3-4848-AFC9-7E02B287E33F} +FOOGUIDDECL const GUID packet_decoder::property_eventlogger = +{ 0x809a5b7f, 0x99d3, 0x4848, { 0xaf, 0xc9, 0x7e, 0x2, 0xb2, 0x87, 0xe3, 0x3f } }; + +// {7AD5E747-CBF3-487D-884F-D93CF8B86EB0} +FOOGUIDDECL const GUID packet_decoder::property_mp3_delayless = +{ 0x7ad5e747, 0xcbf3, 0x487d, { 0x88, 0x4f, 0xd9, 0x3c, 0xf8, 0xb8, 0x6e, 0xb0 } }; + +// {CC2741CF-B57F-43A7-83C9-01C8628E6FDC} +FOOGUIDDECL const GUID packet_decoder::property_query_delay_samples = +{ 0xcc2741cf, 0xb57f, 0x43a7, { 0x83, 0xc9, 0x1, 0xc8, 0x62, 0x8e, 0x6f, 0xdc } }; + +// {6F441057-1D18-4a58-9AC4-8F409CDA7DFD} +FOOGUIDDECL const GUID standard_commands::guid_context_file_properties = +{ 0x6f441057, 0x1d18, 0x4a58, { 0x9a, 0xc4, 0x8f, 0x40, 0x9c, 0xda, 0x7d, 0xfd } }; + +// {EFC1E9C8-EEEF-427a-8F42-E5781605846D} +FOOGUIDDECL const GUID standard_commands::guid_context_file_open_directory = +{ 0xefc1e9c8, 0xeeef, 0x427a, { 0x8f, 0x42, 0xe5, 0x78, 0x16, 0x5, 0x84, 0x6d } }; + +// {FFE18008-BCA2-4b29-AB88-8816B492C434} +FOOGUIDDECL const GUID standard_commands::guid_context_copy_names = +{ 0xffe18008, 0xbca2, 0x4b29, { 0xab, 0x88, 0x88, 0x16, 0xb4, 0x92, 0xc4, 0x34 } }; + +// {44B8F02B-5408-4361-8240-18DEC881B95E} +FOOGUIDDECL const GUID standard_commands::guid_context_send_to_playlist = +{ 0x44b8f02b, 0x5408, 0x4361, { 0x82, 0x40, 0x18, 0xde, 0xc8, 0x81, 0xb9, 0x5e } }; + +// {8C3BA2CB-BC4D-4752-8282-C6F9AED75A78} +FOOGUIDDECL const GUID standard_commands::guid_context_reload_info = +{ 0x8c3ba2cb, 0xbc4d, 0x4752, { 0x82, 0x82, 0xc6, 0xf9, 0xae, 0xd7, 0x5a, 0x78 } }; + +// {BD045EA4-E5E9-4206-8FF9-12AD9F5DCDE1} +FOOGUIDDECL const GUID standard_commands::guid_context_reload_info_if_changed = +{ 0xbd045ea4, 0xe5e9, 0x4206, { 0x8f, 0xf9, 0x12, 0xad, 0x9f, 0x5d, 0xcd, 0xe1 } }; + +// {684D9FBB-4383-44a2-9789-7EE1376209C6} +FOOGUIDDECL const GUID standard_commands::guid_context_rewrite_info = +{ 0x684d9fbb, 0x4383, 0x44a2, { 0x97, 0x89, 0x7e, 0xe1, 0x37, 0x62, 0x9, 0xc6 } }; + +// {860179B7-962F-4340-ACAD-0DDAF060A6B8} +FOOGUIDDECL const GUID standard_commands::guid_context_remove_tags = +{ 0x860179b7, 0x962f, 0x4340, { 0xac, 0xad, 0xd, 0xda, 0xf0, 0x60, 0xa6, 0xb8 } }; + +// {A7E7ECB7-1943-4907-83B3-60E92353C7FA} +FOOGUIDDECL const GUID standard_commands::guid_context_convert_run = +{ 0xa7e7ecb7, 0x1943, 0x4907, { 0x83, 0xb3, 0x60, 0xe9, 0x23, 0x53, 0xc7, 0xfa } }; + +// {BED4FB6E-C4F2-40dd-B528-1DE1450DDFE9} +FOOGUIDDECL const GUID standard_commands::guid_context_convert_run_withcue = +{ 0xbed4fb6e, 0xc4f2, 0x40dd, { 0xb5, 0x28, 0x1d, 0xe1, 0x45, 0xd, 0xdf, 0xe9 } }; + +// {A58AE6EA-A34F-4879-B25C-F31F2CBC4DA9} +FOOGUIDDECL const GUID standard_commands::guid_context_convert_run_singlefile = +{ 0xa58ae6ea, 0xa34f, 0x4879, { 0xb2, 0x5c, 0xf3, 0x1f, 0x2c, 0xbc, 0x4d, 0xa9 } }; + +// {A8EFA42D-76CB-42bc-8803-70516567B13D} +FOOGUIDDECL const GUID standard_commands::guid_context_write_cd = +{ 0xa8efa42d, 0x76cb, 0x42bc, { 0x88, 0x3, 0x70, 0x51, 0x65, 0x67, 0xb1, 0x3d } }; + +// {487DAED1-02FB-4336-A813-5E90317AB041} +FOOGUIDDECL const GUID standard_commands::guid_context_rg_scan_track = +{ 0x487daed1, 0x2fb, 0x4336, { 0xa8, 0x13, 0x5e, 0x90, 0x31, 0x7a, 0xb0, 0x41 } }; + +// {3850F34C-F619-4296-B8A0-26C617B1D16C} +FOOGUIDDECL const GUID standard_commands::guid_context_rg_scan_album = +{ 0x3850f34c, 0xf619, 0x4296, { 0xb8, 0xa0, 0x26, 0xc6, 0x17, 0xb1, 0xd1, 0x6c } }; + +// {6A2DBA02-260C-436f-8F41-0190A4298266} +FOOGUIDDECL const GUID standard_commands::guid_context_rg_scan_album_multi = +{ 0x6a2dba02, 0x260c, 0x436f, { 0x8f, 0x41, 0x1, 0x90, 0xa4, 0x29, 0x82, 0x66 } }; + +// {54C82A92-5824-4381-8D1B-79FBB1E2ABB8} +FOOGUIDDECL const GUID standard_commands::guid_context_rg_remove = +{ 0x54c82a92, 0x5824, 0x4381, { 0x8d, 0x1b, 0x79, 0xfb, 0xb1, 0xe2, 0xab, 0xb8 } }; + +// {69EAA594-13D9-4237-9BD7-11A39FDD1454} +FOOGUIDDECL const GUID standard_commands::guid_context_save_playlist = +{ 0x69eaa594, 0x13d9, 0x4237, { 0x9b, 0xd7, 0x11, 0xa3, 0x9f, 0xdd, 0x14, 0x54 } }; + +// {2BEB6836-C657-40ef-BB6E-D5B222AB89CE} +FOOGUIDDECL const GUID standard_commands::guid_context_masstag_edit = +{ 0x2beb6836, 0xc657, 0x40ef, { 0xbb, 0x6e, 0xd5, 0xb2, 0x22, 0xab, 0x89, 0xce } }; + +// {A579FF07-5D0B-48ed-A071-B6FCE4385AA9} +FOOGUIDDECL const GUID standard_commands::guid_context_masstag_rename = +{ 0xa579ff07, 0x5d0b, 0x48ed, { 0xa0, 0x71, 0xb6, 0xfc, 0xe4, 0x38, 0x5a, 0xa9 } }; + +// {77CFBCD0-98DC-4015-B327-D7142C664806} +FOOGUIDDECL const GUID standard_commands::guid_main_always_on_top = +{ 0x77cfbcd0, 0x98dc, 0x4015, { 0xb3, 0x27, 0xd7, 0x14, 0x2c, 0x66, 0x48, 0x6 } }; + +// {11213A01-9F36-4e69-A1BB-7A72F418DE3A} +FOOGUIDDECL const GUID standard_commands::guid_main_preferences = +{ 0x11213a01, 0x9f36, 0x4e69, { 0xa1, 0xbb, 0x7a, 0x72, 0xf4, 0x18, 0xde, 0x3a } }; + +// {EDA23441-5D38-4499-A22C-FE0CE0A987D9} +FOOGUIDDECL const GUID standard_commands::guid_main_about = +{ 0xeda23441, 0x5d38, 0x4499, { 0xa2, 0x2c, 0xfe, 0xc, 0xe0, 0xa9, 0x87, 0xd9 } }; + +// {6D38C73A-15D8-472c-8E68-6F946B82ECB4} +FOOGUIDDECL const GUID standard_commands::guid_main_exit = +{ 0x6d38c73a, 0x15d8, 0x472c, { 0x8e, 0x68, 0x6f, 0x94, 0x6b, 0x82, 0xec, 0xb4 } }; + +// {EF9B60FE-CB03-4c40-A8FD-3F1821020B37} +FOOGUIDDECL const GUID standard_commands::guid_main_restart = +{ 0xef9b60fe, 0xcb03, 0x4c40, { 0xa8, 0xfd, 0x3f, 0x18, 0x21, 0x2, 0xb, 0x37 } }; + +// {90500F09-F16F-415e-A047-AC5045C95FFE} +FOOGUIDDECL const GUID standard_commands::guid_main_activate = +{ 0x90500f09, 0xf16f, 0x415e, { 0xa0, 0x47, 0xac, 0x50, 0x45, 0xc9, 0x5f, 0xfe } }; + +// {13C17E8D-0D6F-41a4-B24A-59371043E925} +FOOGUIDDECL const GUID standard_commands::guid_main_hide = +{ 0x13c17e8d, 0xd6f, 0x41a4, { 0xb2, 0x4a, 0x59, 0x37, 0x10, 0x43, 0xe9, 0x25 } }; + +// {D9473FB2-BF11-4be0-972F-0E43F166A118} +FOOGUIDDECL const GUID standard_commands::guid_main_activate_or_hide = +{ 0xd9473fb2, 0xbf11, 0x4be0, { 0x97, 0x2f, 0xe, 0x43, 0xf1, 0x66, 0xa1, 0x18 } }; + +// {91E349DA-8800-42e5-BC8C-F3A92577AE84} +FOOGUIDDECL const GUID standard_commands::guid_main_titleformat_help = +{ 0x91e349da, 0x8800, 0x42e5, { 0xbc, 0x8c, 0xf3, 0xa9, 0x25, 0x77, 0xae, 0x84 } }; + +// {FBCFE01C-6C57-4e6a-A9F1-62334640DC91} +FOOGUIDDECL const GUID standard_commands::guid_main_playback_follows_cursor= +{ 0xfbcfe01c, 0x6c57, 0x4e6a, { 0xa9, 0xf1, 0x62, 0x33, 0x46, 0x40, 0xdc, 0x91 } }; + +// {0E1C730A-1EA9-41cc-9C30-25700ABDD9FA} +FOOGUIDDECL const GUID standard_commands::guid_main_cursor_follows_playback= +{ 0xe1c730a, 0x1ea9, 0x41cc, { 0x9c, 0x30, 0x25, 0x70, 0xa, 0xbd, 0xd9, 0xfa } }; + +// {E58895A0-A2F0-45b6-8799-1440E4DB7284} +FOOGUIDDECL const GUID standard_commands::guid_main_next = +{ 0xe58895a0, 0xa2f0, 0x45b6, { 0x87, 0x99, 0x14, 0x40, 0xe4, 0xdb, 0x72, 0x84 } }; + +// {059C4566-4708-4ebf-8139-6A8EA5A9DFC8} +FOOGUIDDECL const GUID standard_commands::guid_main_previous = +{ 0x59c4566, 0x4708, 0x4ebf, { 0x81, 0x39, 0x6a, 0x8e, 0xa5, 0xa9, 0xdf, 0xc8 } }; + +// {18B1278A-F1BB-4b48-BC3D-6EC9EF80AD19} +FOOGUIDDECL const GUID standard_commands::guid_main_next_or_random = +{ 0x18b1278a, 0xf1bb, 0x4b48, { 0xbc, 0x3d, 0x6e, 0xc9, 0xef, 0x80, 0xad, 0x19 } }; + +// {42BDA765-30A8-40fa-BFA4-6A4E2F2B2CE9} +FOOGUIDDECL const GUID standard_commands::guid_main_random = +{ 0x42bda765, 0x30a8, 0x40fa, { 0xbf, 0xa4, 0x6a, 0x4e, 0x2f, 0x2b, 0x2c, 0xe9 } }; + +// {FCEF5262-7FA5-452e-A527-C14E0CB582DE} +FOOGUIDDECL const GUID standard_commands::guid_main_pause = +{ 0xfcef5262, 0x7fa5, 0x452e, { 0xa5, 0x27, 0xc1, 0x4e, 0xc, 0xb5, 0x82, 0xde } }; + +// {D3F83B15-D4AF-4586-8BD0-4EA415E31FE1} +FOOGUIDDECL const GUID standard_commands::guid_main_play = +{ 0xd3f83b15, 0xd4af, 0x4586, { 0x8b, 0xd0, 0x4e, 0xa4, 0x15, 0xe3, 0x1f, 0xe1 } }; + +// {8DEBC44E-EDA2-48d4-8696-31FC29D1F383} +FOOGUIDDECL const GUID standard_commands::guid_main_play_or_pause = +{ 0x8debc44e, 0xeda2, 0x48d4, { 0x86, 0x96, 0x31, 0xfc, 0x29, 0xd1, 0xf3, 0x83 } }; + +// {2DF17F25-80B9-4a43-B21D-620458FDDE1E} +FOOGUIDDECL const GUID standard_commands::guid_main_rg_set_album = +{ 0x2df17f25, 0x80b9, 0x4a43, { 0xb2, 0x1d, 0x62, 0x4, 0x58, 0xfd, 0xde, 0x1e } }; + +// {C26F1955-5753-4836-887F-84A563DD6DD9} +FOOGUIDDECL const GUID standard_commands::guid_main_rg_set_track = +{ 0xc26f1955, 0x5753, 0x4836, { 0x88, 0x7f, 0x84, 0xa5, 0x63, 0xdd, 0x6d, 0xd9 } }; + +// {8D2D808E-6AA2-455b-A2F1-CDB019328140} +FOOGUIDDECL const GUID standard_commands::guid_main_rg_disable = +{ 0x8d2d808e, 0x6aa2, 0x455b, { 0xa2, 0xf1, 0xcd, 0xb0, 0x19, 0x32, 0x81, 0x40 } }; + +// {17D95800-D2B6-4160-A227-7E57A8069619} +FOOGUIDDECL const GUID standard_commands::guid_main_rg_byorder = +{ 0x17d95800, 0xd2b6, 0x4160, { 0xa2, 0x27, 0x7e, 0x57, 0xa8, 0x6, 0x96, 0x19 } }; + + +// {C3378028-165F-4374-966C-2FA2E0FCD3A8} +FOOGUIDDECL const GUID standard_commands::guid_main_stop = +{ 0xc3378028, 0x165f, 0x4374, { 0x96, 0x6c, 0x2f, 0xa2, 0xe0, 0xfc, 0xd3, 0xa8 } }; + +// {EE057982-22F9-4862-A986-859E463316FB} +FOOGUIDDECL const GUID standard_commands::guid_main_stop_after_current = +{ 0xee057982, 0x22f9, 0x4862, { 0xa9, 0x86, 0x85, 0x9e, 0x46, 0x33, 0x16, 0xfb } }; + +// {11DC6526-73C4-44f0-91B1-DE5C2D26B0C7} +FOOGUIDDECL const GUID standard_commands::guid_main_volume_down = +{ 0x11dc6526, 0x73c4, 0x44f0, { 0x91, 0xb1, 0xde, 0x5c, 0x2d, 0x26, 0xb0, 0xc7 } }; + +// {A313E630-A04A-4ae8-B5B4-0A944AC964FF} +FOOGUIDDECL const GUID standard_commands::guid_main_volume_up = +{ 0xa313e630, 0xa04a, 0x4ae8, { 0xb5, 0xb4, 0xa, 0x94, 0x4a, 0xc9, 0x64, 0xff } }; + +// {4A36285B-B4AF-46ed-A1AA-6333057F485B} +FOOGUIDDECL const GUID standard_commands::guid_main_volume_mute = +{ 0x4a36285b, 0xb4af, 0x46ed, { 0xa1, 0xaa, 0x63, 0x33, 0x5, 0x7f, 0x48, 0x5b } }; + +// {2DC43C22-CA09-4ef9-A61E-7A0C1DAAE21E} +FOOGUIDDECL const GUID standard_commands::guid_main_add_directory = +{ 0x2dc43c22, 0xca09, 0x4ef9, { 0xa6, 0x1e, 0x7a, 0xc, 0x1d, 0xaa, 0xe2, 0x1e } }; + +// {FC89C278-4475-4853-96C9-F7F05E8CC837} +FOOGUIDDECL const GUID standard_commands::guid_main_add_files = +{ 0xfc89c278, 0x4475, 0x4853, { 0x96, 0xc9, 0xf7, 0xf0, 0x5e, 0x8c, 0xc8, 0x37 } }; + +// {9CA39D38-AC9B-4cca-B0CE-C0F62D188114} +FOOGUIDDECL const GUID standard_commands::guid_main_add_location = +{ 0x9ca39d38, 0xac9b, 0x4cca, { 0xb0, 0xce, 0xc0, 0xf6, 0x2d, 0x18, 0x81, 0x14 } }; + +// {73D6E69D-0DC9-4d5c-A7EE-FF4BE3896B08} +FOOGUIDDECL const GUID standard_commands::guid_main_add_playlist = +{ 0x73d6e69d, 0xdc9, 0x4d5c, { 0xa7, 0xee, 0xff, 0x4b, 0xe3, 0x89, 0x6b, 0x8 } }; + +// {55559142-7AEA-4c20-9B72-1D48E970A274} +FOOGUIDDECL const GUID standard_commands::guid_main_clear_playlist = +{ 0x55559142, 0x7aea, 0x4c20, { 0x9b, 0x72, 0x1d, 0x48, 0xe9, 0x70, 0xa2, 0x74 } }; + +// {BF72488F-36AC-46b3-A36D-193E60C79BC5} +FOOGUIDDECL const GUID standard_commands::guid_main_create_playlist = +{ 0xbf72488f, 0x36ac, 0x46b3, { 0xa3, 0x6d, 0x19, 0x3e, 0x60, 0xc7, 0x9b, 0xc5 } }; + +// {59E99BEE-42A3-4526-B06D-56C0C49F0BC1} +FOOGUIDDECL const GUID standard_commands::guid_main_highlight_playing = +{ 0x59e99bee, 0x42a3, 0x4526, { 0xb0, 0x6d, 0x56, 0xc0, 0xc4, 0x9f, 0xb, 0xc1 } }; + +// {D94393D4-9DBB-4e5c-BE8C-BE9CA80E214D} +FOOGUIDDECL const GUID standard_commands::guid_main_load_playlist = +{ 0xd94393d4, 0x9dbb, 0x4e5c, { 0xbe, 0x8c, 0xbe, 0x9c, 0xa8, 0xe, 0x21, 0x4d } }; + +// {EE1308C5-EBD2-48f1-959D-2627069C2E0F} +FOOGUIDDECL const GUID standard_commands::guid_main_next_playlist = +{ 0xee1308c5, 0xebd2, 0x48f1, { 0x95, 0x9d, 0x26, 0x27, 0x6, 0x9c, 0x2e, 0xf } }; + +// {486ECDA3-7BA2-49e9-BB44-4DB9DF9320C7} +FOOGUIDDECL const GUID standard_commands::guid_main_previous_playlist = +{ 0x486ecda3, 0x7ba2, 0x49e9, { 0xbb, 0x44, 0x4d, 0xb9, 0xdf, 0x93, 0x20, 0xc7 } }; + +// {69C778AA-B836-40a0-89CD-7A2E50C102CB} +FOOGUIDDECL const GUID standard_commands::guid_main_open = +{ 0x69c778aa, 0xb836, 0x40a0, { 0x89, 0xcd, 0x7a, 0x2e, 0x50, 0xc1, 0x2, 0xcb } }; + +// {EB7FB5A4-5904-4d2c-B66C-D882A3B15277} +FOOGUIDDECL const GUID standard_commands::guid_main_remove_playlist = +{ 0xeb7fb5a4, 0x5904, 0x4d2c, { 0xb6, 0x6c, 0xd8, 0x82, 0xa3, 0xb1, 0x52, 0x77 } }; + +// {C297BADB-8098-45a9-A5E8-B53A0D780CE3} +FOOGUIDDECL const GUID standard_commands::guid_main_remove_dead_entries = +{ 0xc297badb, 0x8098, 0x45a9, { 0xa5, 0xe8, 0xb5, 0x3a, 0xd, 0x78, 0xc, 0xe3 } }; + +// {D08C2921-7750-4979-98F9-3A513A31FF96} +FOOGUIDDECL const GUID standard_commands::guid_main_remove_duplicates = +{ 0xd08c2921, 0x7750, 0x4979, { 0x98, 0xf9, 0x3a, 0x51, 0x3a, 0x31, 0xff, 0x96 } }; + +// {D3A25E47-BA98-4e6b-95AD-A7502919EB75} +FOOGUIDDECL const GUID standard_commands::guid_main_rename_playlist = +{ 0xd3a25e47, 0xba98, 0x4e6b, { 0x95, 0xad, 0xa7, 0x50, 0x29, 0x19, 0xeb, 0x75 } }; + +// {0FDCFC65-9B39-445a-AA88-4D245F217480} +FOOGUIDDECL const GUID standard_commands::guid_main_save_all_playlists = +{ 0xfdcfc65, 0x9b39, 0x445a, { 0xaa, 0x88, 0x4d, 0x24, 0x5f, 0x21, 0x74, 0x80 } }; + +// {370B720B-4CF7-465b-908C-2D2ADD027900} +FOOGUIDDECL const GUID standard_commands::guid_main_save_playlist = +{ 0x370b720b, 0x4cf7, 0x465b, { 0x90, 0x8c, 0x2d, 0x2a, 0xdd, 0x2, 0x79, 0x0 } }; + +// {A6CFC2A8-56B3-4d12-88E7-0237961AC47E} +FOOGUIDDECL const GUID standard_commands::guid_main_playlist_search = +{ 0xa6cfc2a8, 0x56b3, 0x4d12, { 0x88, 0xe7, 0x2, 0x37, 0x96, 0x1a, 0xc4, 0x7e } }; + +// {383D4E8D-7E30-4fb8-B5DD-8C975D89E58E} +FOOGUIDDECL const GUID standard_commands::guid_main_playlist_sel_crop = +{ 0x383d4e8d, 0x7e30, 0x4fb8, { 0xb5, 0xdd, 0x8c, 0x97, 0x5d, 0x89, 0xe5, 0x8e } }; + +// {E0EEA319-E282-4e6c-8B82-4DFD42A1D4ED} +FOOGUIDDECL const GUID standard_commands::guid_main_playlist_sel_remove = +{ 0xe0eea319, 0xe282, 0x4e6c, { 0x8b, 0x82, 0x4d, 0xfd, 0x42, 0xa1, 0xd4, 0xed } }; + +// {F0845920-7F6D-40ac-B2EB-3D00C2C8260B} +FOOGUIDDECL const GUID standard_commands::guid_main_playlist_sel_invert = +{ 0xf0845920, 0x7f6d, 0x40ac, { 0xb2, 0xeb, 0x3d, 0x0, 0xc2, 0xc8, 0x26, 0xb } }; + +// {29910B33-79E9-40da-992B-5A4AA4281F78} +FOOGUIDDECL const GUID standard_commands::guid_main_playlist_undo = +{ 0x29910b33, 0x79e9, 0x40da, { 0x99, 0x2b, 0x5a, 0x4a, 0xa4, 0x28, 0x1f, 0x78 } }; + +// {7A9D9450-A8BF-4a88-B44F-DCD83A49DD7A} +FOOGUIDDECL const GUID standard_commands::guid_main_playlist_redo = +{ 0x7a9d9450, 0xa8bf, 0x4a88, { 0xb4, 0x4f, 0xdc, 0xd8, 0x3a, 0x49, 0xdd, 0x7a } }; + +// {5b652d25-ce44-4737-99bb-a3cf2aeb35cc} +FOOGUIDDECL const GUID standard_commands::guid_main_show_console = +{ 0x5b652d25, 0xce44, 0x4737, { 0x99, 0xbb, 0xa3, 0xcf, 0x2a, 0xeb, 0x35, 0xcc } }; + +// {E6970E91-33BE-4288-AC01-4B02F07B5D38} +FOOGUIDDECL const GUID standard_commands::guid_main_play_cd = +{ 0xe6970e91, 0x33be, 0x4288, { 0xac, 0x1, 0x4b, 0x2, 0xf0, 0x7b, 0x5d, 0x38 } }; + +// {1073AB1D-38ED-4957-8B06-38BC878C1F40} +FOOGUIDDECL const GUID standard_commands::guid_main_restart_resetconfig = +{ 0x1073ab1d, 0x38ed, 0x4957, { 0x8b, 0x6, 0x38, 0xbc, 0x87, 0x8c, 0x1f, 0x40 } }; + +// {FDC8A1C2-93EF-4415-8C20-60B6517F0B5F} +FOOGUIDDECL const GUID standard_commands::guid_main_record = +{ 0xfdc8a1c2, 0x93ef, 0x4415, { 0x8c, 0x20, 0x60, 0xb6, 0x51, 0x7f, 0xb, 0x5f } }; + +// {45EB37D2-3CD9-4f0a-9B20-8EAE649D7A9F} +FOOGUIDDECL const GUID standard_commands::guid_main_playlist_moveback = +{ 0x45eb37d2, 0x3cd9, 0x4f0a, { 0x9b, 0x20, 0x8e, 0xae, 0x64, 0x9d, 0x7a, 0x9f } }; + +// {02298938-596A-41f7-A398-19766A06E6EB} +FOOGUIDDECL const GUID standard_commands::guid_main_playlist_moveforward = +{ 0x2298938, 0x596a, 0x41f7, { 0xa3, 0x98, 0x19, 0x76, 0x6a, 0x6, 0xe6, 0xeb } }; + +// {E910ACC6-A81A-4a20-9F62-19015BCD1013} +FOOGUIDDECL const GUID standard_commands::guid_main_saveconfig = +{ 0xe910acc6, 0xa81a, 0x4a20, { 0x9f, 0x62, 0x19, 0x1, 0x5b, 0xcd, 0x10, 0x13 } }; + +// {03445FCC-71D9-4e01-AE02-A557D30B4CD7} +FOOGUIDDECL const GUID standard_commands::guid_main_playlist_select_all = +{ 0x3445fcc, 0x71d9, 0x4e01, { 0xae, 0x2, 0xa5, 0x57, 0xd3, 0xb, 0x4c, 0xd7 } }; + +// {919FA72B-1DF9-49ee-A8F1-D8BA1DEAA7E9} +FOOGUIDDECL const GUID standard_commands::guid_main_show_now_playing = +{ 0x919fa72b, 0x1df9, 0x49ee, { 0xa8, 0xf1, 0xd8, 0xba, 0x1d, 0xea, 0xa7, 0xe9 } }; + +// {D8D51855-D79D-49b8-97A8-065785FA2426} +FOOGUIDDECL const GUID playlist_manager::class_guid= +{ 0xd8d51855, 0xd79d, 0x49b8, { 0x97, 0xa8, 0x6, 0x57, 0x85, 0xfa, 0x24, 0x26 } }; + +// {C303A0F1-8E88-4539-87E5-9E455B7D548C} +FOOGUIDDECL const GUID genrand_service::class_guid= +{ 0xc303a0f1, 0x8e88, 0x4539, { 0x87, 0xe5, 0x9e, 0x45, 0x5b, 0x7d, 0x54, 0x8c } }; + +// {EB8FA333-F365-46ad-8621-345671567BAA} +FOOGUIDDECL const GUID playlist_incoming_item_filter::class_guid= +{ 0xeb8fa333, 0xf365, 0x46ad, { 0x86, 0x21, 0x34, 0x56, 0x71, 0x56, 0x7b, 0xaa } }; + +// {FEBD85B5-C12D-45b5-B55D-0D3F432B0C6B} +FOOGUIDDECL const GUID library_manager::class_guid= +{ 0xfebd85b5, 0xc12d, 0x45b5, { 0xb5, 0x5d, 0xd, 0x3f, 0x43, 0x2b, 0xc, 0x6b } }; + +// {9A08B50F-E8C6-40c0-88C3-7530CF2C3115} +FOOGUIDDECL const GUID library_callback::class_guid= +{ 0x9a08b50f, 0xe8c6, 0x40c0, { 0x88, 0xc3, 0x75, 0x30, 0xcf, 0x2c, 0x31, 0x15 } }; + +// {D5CAC75A-3023-4dce-8B0D-B502BD056A7C} +FOOGUIDDECL const GUID popup_message::class_guid= +{ 0xd5cac75a, 0x3023, 0x4dce, { 0x8b, 0xd, 0xb5, 0x2, 0xbd, 0x5, 0x6a, 0x7c } }; + +// {13F9CB11-0EAE-4417-AF0C-8894DEB65E8B} +FOOGUIDDECL const GUID app_close_blocker::class_guid= +{ 0x13f9cb11, 0xeae, 0x4417, { 0xaf, 0xc, 0x88, 0x94, 0xde, 0xb6, 0x5e, 0x8b } }; + +// {5570A2D2-8F9E-48a7-AFAC-DAC00A3C1636} +FOOGUIDDECL const GUID file_operation_callback::class_guid= +{ 0x5570a2d2, 0x8f9e, 0x48a7, { 0xaf, 0xac, 0xda, 0xc0, 0xa, 0x3c, 0x16, 0x36 } }; + +// {340099D1-7BEC-4ac6-92A4-77FF01507891} +FOOGUIDDECL const GUID config_object::class_guid= +{ 0x340099d1, 0x7bec, 0x4ac6, { 0x92, 0xa4, 0x77, 0xff, 0x1, 0x50, 0x78, 0x91 } }; + +// {1BA04122-DE9A-4a90-9FC3-A6A7EC8F9626} +FOOGUIDDECL const GUID config_object_notify_manager::class_guid= +{ 0x1ba04122, 0xde9a, 0x4a90, { 0x9f, 0xc3, 0xa6, 0xa7, 0xec, 0x8f, 0x96, 0x26 } }; + +// {AD5138E6-CF8F-4482-89B2-B2EAAEDF3B4C} +FOOGUIDDECL const GUID standard_config_objects::bool_show_keyboard_shortcuts_in_menus= +{ 0xad5138e6, 0xcf8f, 0x4482, { 0x89, 0xb2, 0xb2, 0xea, 0xae, 0xdf, 0x3b, 0x4c } }; + +// {E91F618C-5741-470f-A178-21272C3ECA90} +FOOGUIDDECL const GUID standard_config_objects::bool_remember_window_positions= +{ 0xe91f618c, 0x5741, 0x470f, { 0xa1, 0x78, 0x21, 0x27, 0x2c, 0x3e, 0xca, 0x90 } }; + +// {5497FAA9-690C-4fb4-8BC0-678CEBCBBDC4} +FOOGUIDDECL const GUID standard_config_objects::bool_playback_follows_cursor= +{ 0x5497faa9, 0x690c, 0x4fb4, { 0x8b, 0xc0, 0x67, 0x8c, 0xeb, 0xcb, 0xbd, 0xc4 } }; + +// {58D3E2D6-DD6D-48dd-98EB-4EABF0ACFEB8} +FOOGUIDDECL const GUID standard_config_objects::bool_cursor_follows_playback= +{ 0x58d3e2d6, 0xdd6d, 0x48dd, { 0x98, 0xeb, 0x4e, 0xab, 0xf0, 0xac, 0xfe, 0xb8 } }; + +// {2DF7194D-86FC-4312-98DA-E820DA3E710D} +FOOGUIDDECL const GUID standard_config_objects::bool_ui_always_on_top= +{ 0x2df7194d, 0x86fc, 0x4312, { 0x98, 0xda, 0xe8, 0x20, 0xda, 0x3e, 0x71, 0xd } }; + +// {B572C86F-4206-40a0-8476-C7B27E74DB2D} +FOOGUIDDECL const GUID standard_config_objects::bool_playlist_stop_after_current= +{ 0xb572c86f, 0x4206, 0x40a0, { 0x84, 0x76, 0xc7, 0xb2, 0x7e, 0x74, 0xdb, 0x2d } }; + +// {FFDFDA96-699C-4617-A977-22DC2F039B00} +FOOGUIDDECL const GUID standard_config_objects::string_gui_last_directory_media= +{ 0xffdfda96, 0x699c, 0x4617, { 0xa9, 0x77, 0x22, 0xdc, 0x2f, 0x3, 0x9b, 0x0 } }; + +// {915D3B21-81CB-4b96-9762-1C90FBF371DF} +FOOGUIDDECL const GUID standard_config_objects::string_gui_last_directory_playlists= +{ 0x915d3b21, 0x81cb, 0x4b96, { 0x97, 0x62, 0x1c, 0x90, 0xfb, 0xf3, 0x71, 0xdf } }; + +// {338B6871-EB1F-4384-BF83-6BFACE5B66BC} +FOOGUIDDECL const GUID standard_config_objects::int32_dynamic_bitrate_display_rate= +{ 0x338b6871, 0xeb1f, 0x4384, { 0xbf, 0x83, 0x6b, 0xfa, 0xce, 0x5b, 0x66, 0xbc } }; + +// {3E35D949-DCDB-44e1-8013-9D1633C09756} +FOOGUIDDECL const GUID config_object_notify::class_guid= +{ 0x3e35d949, 0xdcdb, 0x44e1, { 0x80, 0x13, 0x9d, 0x16, 0x33, 0xc0, 0x97, 0x56 } }; + +// {4AC9408E-4D9C-4135-ACB5-2CAB35376FC9} +FOOGUIDDECL const GUID titleformat_object::class_guid= +{ 0x4ac9408e, 0x4d9c, 0x4135, { 0xac, 0xb5, 0x2c, 0xab, 0x35, 0x37, 0x6f, 0xc9 } }; + +// {581BCD47-DBFF-4FA6-97DE-0CA83174852F} +FOOGUIDDECL const GUID titleformat_object_v2::class_guid= +{ 0xf7713ecc, 0xccbc, 0x4c1f, { 0x88, 0x89, 0xb4, 0xa1, 0x14, 0x6b, 0x48, 0xba } }; + + +// {25B0D20D-9BA3-4a7b-8D0E-89FAF75F916F} +FOOGUIDDECL const GUID tag_processor_id3v2::class_guid= +{ 0x25b0d20d, 0x9ba3, 0x4a7b, { 0x8d, 0xe, 0x89, 0xfa, 0xf7, 0x5f, 0x91, 0x6f } }; + +// {AD537D40-499D-4c29-81D4-C0FA496DD58C} +FOOGUIDDECL const GUID tag_processor_trailing::class_guid= +{ 0xad537d40, 0x499d, 0x4c29, { 0x81, 0xd4, 0xc0, 0xfa, 0x49, 0x6d, 0xd5, 0x8c } }; + +// {160885C6-3AA3-4f60-8718-1240615E6414} +FOOGUIDDECL const GUID metadb_handle::class_guid= +{ 0x160885c6, 0x3aa3, 0x4f60, { 0x87, 0x18, 0x12, 0x40, 0x61, 0x5e, 0x64, 0x14 } }; + +// {4DABDE9B-CBB5-4A81-AAA3-36BB071EB622} +FOOGUIDDECL const GUID metadb_handle_v2::class_guid = +{ 0x4dabde9b, 0xcbb5, 0x4a81, { 0xaa, 0xa3, 0x36, 0xbb, 0x7, 0x1e, 0xb6, 0x22 } }; + +// {9DBC262F-4795-4292-824B-23A655011A3E} +FOOGUIDDECL const GUID threaded_process::class_guid= +{ 0x9dbc262f, 0x4795, 0x4292, { 0x82, 0x4b, 0x23, 0xa6, 0x55, 0x1, 0x1a, 0x3e } }; + +// {7B69141B-4271-4070-8998-10CD39249C12} +FOOGUIDDECL const GUID threaded_process_callback::class_guid= +{ 0x7b69141b, 0x4271, 0x4070, { 0x89, 0x98, 0x10, 0xcd, 0x39, 0x24, 0x9c, 0x12 } }; + + +// {64D18B80-5E97-40e4-A30C-A4640C60BCE5} +FOOGUIDDECL const GUID metadb_io::class_guid= +{ 0x64d18b80, 0x5e97, 0x40e4, { 0xa3, 0xc, 0xa4, 0x64, 0xc, 0x60, 0xbc, 0xe5 } }; + +FOOGUIDDECL const GUID preferences_page::guid_tagging = { 0x563107c3, 0xfc7d, 0x4022, { 0xa8, 0x72, 0xa8, 0x2a, 0x2b, 0x3f, 0xd5, 0x25 } }; +FOOGUIDDECL const GUID preferences_page::guid_root = { 0xb9218d23, 0xf73d, 0x4b61, { 0xa1, 0xd9, 0xbf, 0xd4, 0x20, 0xcd, 0xac, 0x77 } }; + +FOOGUIDDECL const GUID preferences_page::guid_hidden = { 0x2f0e2232, 0xa5fd, 0x43e4, { 0xb6, 0xab, 0x38, 0x39, 0xb8, 0xd1, 0xa7, 0x7 } }; +FOOGUIDDECL const GUID preferences_page::guid_tools = { 0x627c0767, 0x793, 0x44f8, { 0x80, 0x87, 0xbe, 0x49, 0x34, 0x31, 0x12, 0x82 } }; +FOOGUIDDECL const GUID preferences_page::guid_display = { 0x6aaa67b6, 0x732f, 0x4967, { 0x89, 0x9a, 0x18, 0xc5, 0xf8, 0xc7, 0x0, 0x17 } }; +FOOGUIDDECL const GUID preferences_page::guid_playback = { 0x67508677, 0xcfcc, 0x4a1c, { 0x92, 0x1c, 0x49, 0xb3, 0x9c, 0xc5, 0xb9, 0x86 } }; +FOOGUIDDECL const GUID preferences_page::guid_visualisations = { 0x494326c8, 0x88ff, 0x4265, { 0xb2, 0xb2, 0xe6, 0x47, 0xb, 0xee, 0x13, 0xb3 } }; +FOOGUIDDECL const GUID preferences_page::guid_input = { 0xfc01b529, 0x4bd7, 0x47cd, { 0xba, 0xf7, 0x2f, 0xb6, 0x32, 0xf0, 0xdb, 0xb6 } }; +FOOGUIDDECL const GUID preferences_page::guid_core = { 0x2e8e9647, 0x4174, 0x41b2, { 0x9e, 0xc4, 0x91, 0xb, 0xe1, 0x28, 0x8, 0x2e } }; +FOOGUIDDECL const GUID preferences_page::guid_tag_writing = { 0x7d0334e5, 0xadd7, 0x4ff5, { 0x9d, 0xb8, 0xa6, 0x18, 0xb4, 0x82, 0x40, 0x28 } }; +FOOGUIDDECL const GUID preferences_page::guid_media_library = { 0x2d269fa9, 0x6f78, 0x4cec, { 0x9f, 0x1f, 0xa, 0x17, 0x6e, 0xfc, 0xe7, 0x7a } }; +FOOGUIDDECL const GUID preferences_page::guid_output = { 0xa9038870, 0xdc08, 0x431d, { 0x8c, 0x91, 0x3b, 0x4e, 0x41, 0xd2, 0x43, 0x6d } }; +FOOGUIDDECL const GUID preferences_page::guid_advanced = { 0x56eb56ab, 0xedfe, 0x4853, { 0x90, 0xf7, 0xc6, 0xb8, 0x34, 0xfa, 0x2f, 0x6b } }; +FOOGUIDDECL const GUID preferences_page::guid_components = { 0xe966267, 0x7dfb, 0x433b, { 0xa0, 0x7c, 0x3f, 0x8c, 0xdd, 0x31, 0xa2, 0x58 } }; +FOOGUIDDECL const GUID preferences_page::guid_input_info_filter = { 0xf9de8ee1, 0x9a5b, 0x4bbd, { 0xb4, 0x62, 0xef, 0x7b, 0x3a, 0xa5, 0x0, 0x24 } }; +FOOGUIDDECL const GUID preferences_page::guid_dsp = { 0xeb1878c9, 0x4b31, 0x46e3, { 0x95, 0x2b, 0x6f, 0x7e, 0x1f, 0xd3, 0x63, 0xdd } }; +FOOGUIDDECL const GUID preferences_page::guid_shell = { 0x7a4426d8, 0xb282, 0x4aab, { 0xbd, 0xba, 0x45, 0xe0, 0x6, 0xb9, 0x7d, 0xdd } }; +FOOGUIDDECL const GUID preferences_page::guid_keyboard_shortcuts = { 0xa4dbfa19, 0xb39d, 0x430a, { 0xb8, 0x78, 0xbb, 0xd1, 0xb8, 0xbc, 0x21, 0x6c } }; + +FOOGUIDDECL const GUID preferences_page_v2::class_guid = { 0xce4ebc9e, 0xab20, 0x46f9, { 0x92, 0x5f, 0x88, 0x3b, 0x8, 0x4f, 0x5, 0x69 } }; +FOOGUIDDECL const GUID preferences_branch_v2::class_guid = { 0x167ebeb9, 0x8334, 0x4b21, { 0xaf, 0x58, 0xa7, 0x40, 0xa5, 0xd5, 0xb6, 0x66 } }; + +#ifdef _WIN32 +FOOGUIDDECL const GUID preferences_page_callback::class_guid = { 0x3d26e08e, 0x861c, 0x4599, { 0x9c, 0x89, 0xaa, 0xa7, 0x19, 0xaf, 0x50, 0x70 } }; +FOOGUIDDECL const GUID preferences_page_instance::class_guid = { 0x6893a996, 0xa816, 0x49fe, { 0x82, 0xce, 0xc, 0xb8, 0x4, 0xa4, 0xcf, 0xec } }; +#endif +FOOGUIDDECL const GUID preferences_page_v3::class_guid = { 0xd6d0f741, 0x9f17, 0x4df8, { 0x9d, 0x5c, 0x87, 0xf2, 0x8b, 0x1f, 0xe, 0x64 } }; +FOOGUIDDECL const GUID preferences_page_v4::class_guid = { 0x76227dab, 0xc740, 0x4d49, { 0xa2, 0xe2, 0x50, 0x80, 0x13, 0xe, 0xf6, 0xba } }; + +// {B8C5CEEA-A5F4-4278-AA2D-798E4403001F} +FOOGUIDDECL const GUID library_viewer::class_guid= +{ 0xb8c5ceea, 0xa5f4, 0x4278, { 0xaa, 0x2d, 0x79, 0x8e, 0x44, 0x3, 0x0, 0x1f } }; + +#ifdef _WIN32 +FOOGUIDDECL const GUID message_loop::class_guid = { 0x5cd49b5d, 0xd604, 0x4c07, { 0xa8, 0xfa, 0xff, 0xd8, 0x51, 0x2a, 0xfd, 0x2b } }; +FOOGUIDDECL const GUID message_loop_v2::class_guid = { 0x5d438080, 0xb269, 0x406d, { 0x94, 0xaf, 0xef, 0xd9, 0x29, 0x9f, 0x32, 0x5c } }; +#endif + +FOOGUIDDECL const GUID input_decoder::class_guid = { 0x7eb442cd, 0xfad7, 0x4a26, { 0xad, 0x7e, 0x16, 0xf6, 0xfc, 0x89, 0x20, 0x7b } }; +FOOGUIDDECL const GUID input_decoder_v2::class_guid = { 0x2c5489eb, 0xd3c1, 0x4ad4,{ 0xbe, 0xa3, 0xcf, 0x40, 0x8e, 0x16, 0x1b, 0x9b } }; +FOOGUIDDECL const GUID input_decoder_v3::class_guid = { 0x953c71ed, 0xd3a2, 0x43f4,{ 0xa3, 0x3a, 0x55, 0x94, 0xd6, 0x73, 0x96, 0xe5 } }; +FOOGUIDDECL const GUID input_decoder_v4::class_guid = { 0x7bbf10b5, 0x2064, 0x4da2,{ 0x8a, 0x72, 0xeb, 0x4c, 0xe9, 0xb3, 0xa0, 0xb4 } }; +FOOGUIDDECL const GUID input_params::seeking_expensive = { 0x10973582, 0x1aae, 0x4169, { 0xb9, 0x76, 0xb5, 0xbe, 0xf9, 0x4b, 0x7a, 0x71 } }; +FOOGUIDDECL const GUID input_params::set_preferred_sample_rate = { 0x7dc7f926, 0x9b9f, 0x4a73, { 0xa2, 0x37, 0x83, 0xe9, 0x93, 0x38, 0x41, 0x75 } }; +FOOGUIDDECL const GUID input_params::query_position = { 0xa9d79933, 0x5438, 0x480f, { 0x85, 0xf3, 0xb6, 0xb8, 0xee, 0x1e, 0xfa, 0xe9 } }; +FOOGUIDDECL const GUID input_params::is_tag_write_safe = { 0x9f44a346, 0x73f0, 0x459b, { 0x98, 0x47, 0xf4, 0x86, 0x9b, 0x29, 0xbc, 0x93 } }; +FOOGUIDDECL const GUID input_info_reader::class_guid = { 0x8e9bb1d4, 0xa52b, 0x4df6, { 0xa9, 0x29, 0x1a, 0xae, 0x40, 0x75, 0x38, 0x8a } }; +FOOGUIDDECL const GUID input_info_reader_v2::class_guid = { 0x42486bca, 0xd37, 0x4e02, { 0xb7, 0x72, 0x4d, 0x30, 0xd6, 0xf8, 0x50, 0xbe } }; +FOOGUIDDECL const GUID input_info_writer::class_guid = { 0xfe40ff66, 0x64c9, 0x4234, { 0xb6, 0x39, 0x2, 0x8d, 0xc8, 0x6, 0xc, 0xf7 } }; +FOOGUIDDECL const GUID input_entry::class_guid = { 0x436547fc, 0xc4ef, 0x4322, { 0xb5, 0x9e, 0xe6, 0x96, 0xa2, 0x5f, 0xab, 0x2c } }; +FOOGUIDDECL const GUID input_entry_v2::class_guid = { 0x7037df35, 0xd246, 0x4cdd,{ 0xb2, 0x24, 0x8, 0xcf, 0x44, 0x4c, 0xe4, 0xce } }; +FOOGUIDDECL const GUID input_entry_v3::class_guid = { 0x7099fac8, 0x10ee, 0x4906, { 0xa3, 0x13, 0xb9, 0x8c, 0x69, 0x74, 0xe7, 0xb9 } }; + +#ifdef FOOBAR2000_DESKTOP +FOOGUIDDECL const GUID input_manager::class_guid = { 0x291fccfd, 0xe7de, 0x4e08,{ 0x8d, 0xef, 0x6b, 0xe5, 0xf8, 0x23, 0xc4, 0x9a } }; +FOOGUIDDECL const GUID input_manager_v2::class_guid = { 0x81b36d9e, 0x4fb6, 0x4788, { 0xa1, 0x2c, 0x40, 0xc0, 0x64, 0x82, 0xe5, 0xc6 } }; +FOOGUIDDECL const GUID input_manager_v3::class_guid = { 0xc1c414be, 0x74f, 0x41f0, { 0xb8, 0x7f, 0x29, 0x2e, 0xad, 0x50, 0xc0, 0x76 } }; +FOOGUIDDECL const GUID input_stream_selector::class_guid = { 0x2a511979, 0x2e57, 0x438a,{ 0x9a, 0x6e, 0x37, 0x3c, 0x25, 0x2, 0xd7, 0x63 } }; +FOOGUIDDECL const GUID input_stream_info_reader::class_guid = { 0x934f1361, 0x9c18, 0x497a,{ 0xb6, 0xef, 0xc0, 0x4e, 0xa1, 0x66, 0x3e, 0xab } }; +FOOGUIDDECL const GUID input_stream_info_reader_entry::class_guid = { 0xb53b66f2, 0x7cd3, 0x4ce2,{ 0xbf, 0x63, 0x7b, 0xcf, 0xcf, 0xa1, 0xb2, 0x8f } }; +FOOGUIDDECL const GUID input_stream_manipulator::class_guid = { 0xc258aa65, 0x961a, 0x4e8e,{ 0x83, 0x98, 0xcc, 0x88, 0xd2, 0xba, 0xe0, 0x5d } }; +FOOGUIDDECL const GUID input_stream_manipulator_callback::class_guid = { 0x88ce44b6, 0x8721, 0x440f,{ 0x9e, 0xab, 0xbd, 0xc6, 0x63, 0xed, 0xe1, 0x73 } }; +FOOGUIDDECL const GUID input_info_filter::class_guid = { 0xd64af9aa, 0x1c0d, 0x4dd9, { 0xa3, 0x49, 0x2, 0xa3, 0x77, 0xbd, 0x7a, 0xf2 } }; +FOOGUIDDECL const GUID input_info_filter_v2::class_guid = { 0x7a2023cb, 0xfb7c, 0x4f04, { 0xa5, 0x45, 0x7f, 0xbd, 0x52, 0x92, 0x31, 0x92 } }; +FOOGUIDDECL const GUID input_stream_info_filter::class_guid = { 0xfd056bba, 0xc6a1, 0x40b5, { 0xa6, 0x17, 0x37, 0xb9, 0x71, 0x34, 0xb4, 0xc6 } }; +FOOGUIDDECL const GUID input_playback_shim::class_guid = { 0xaf8aea76, 0x144f, 0x4770, { 0x8d, 0x84, 0x7, 0x27, 0x22, 0x8f, 0x29, 0x8 } }; + +#endif + +// {3296219B-EBA5-4c32-A193-C9BB174801DA} +FOOGUIDDECL const GUID link_resolver::class_guid = +{ 0x3296219b, 0xeba5, 0x4c32, { 0xa1, 0x93, 0xc9, 0xbb, 0x17, 0x48, 0x1, 0xda } }; + +// {A49E087E-D064-4b2e-A08D-11264F691FFE} +FOOGUIDDECL const GUID playback_queue_callback::class_guid = +{ 0xa49e087e, 0xd064, 0x4b2e, { 0xa0, 0x8d, 0x11, 0x26, 0x4f, 0x69, 0x1f, 0xfe } }; + +// {1131D64B-04CB-43ee-95EB-24D18B753248} +FOOGUIDDECL const GUID main_thread_callback_manager::class_guid = +{ 0x1131d64b, 0x4cb, 0x43ee, { 0x95, 0xeb, 0x24, 0xd1, 0x8b, 0x75, 0x32, 0x48 } }; + +// {38986E70-A333-456D-8FEE-0AFBDFD4F919} +FOOGUIDDECL const GUID main_thread_callback_manager_v2::class_guid = +{ 0x38986e70, 0xa333, 0x456d, { 0x8f, 0xee, 0xa, 0xfb, 0xdf, 0xd4, 0xf9, 0x19 } }; + +// {87D2C583-7AFB-4e58-B21E-FBD3E6E8F5E7} +FOOGUIDDECL const GUID main_thread_callback::class_guid = +{ 0x87d2c583, 0x7afb, 0x4e58, { 0xb2, 0x1e, 0xfb, 0xd3, 0xe6, 0xe8, 0xf5, 0xe7 } }; + + + +// {21656AB9-0255-4f8c-8FB9-1A7748BCE93A} +FOOGUIDDECL const GUID mainmenu_group::class_guid = +{ 0x21656ab9, 0x255, 0x4f8c, { 0x8f, 0xb9, 0x1a, 0x77, 0x48, 0xbc, 0xe9, 0x3a } }; + +// {2E673A2E-A4EE-419c-94C8-9C838660414C} +FOOGUIDDECL const GUID mainmenu_group_popup::class_guid = +{ 0x2e673a2e, 0xa4ee, 0x419c, { 0x94, 0xc8, 0x9c, 0x83, 0x86, 0x60, 0x41, 0x4c } }; + +// {77D2B792-BF39-4B80-AE34-3BF69DA70160} +FOOGUIDDECL const GUID mainmenu_group_popup_v2::class_guid = +{ 0x77d2b792, 0xbf39, 0x4b80,{ 0xae, 0x34, 0x3b, 0xf6, 0x9d, 0xa7, 0x1, 0x60 } }; + +// {35077B8C-6E70-47ba-B9DD-D51500E12F2E} +FOOGUIDDECL const GUID mainmenu_commands::class_guid = +{ 0x35077b8c, 0x6e70, 0x47ba, { 0xb9, 0xdd, 0xd5, 0x15, 0x0, 0xe1, 0x2f, 0x2e } }; + +// {350B3EA8-6B3E-4346-B6D2-799E98EFC920} +FOOGUIDDECL const GUID mainmenu_manager::class_guid = +{ 0x350b3ea8, 0x6b3e, 0x4346, { 0xb6, 0xd2, 0x79, 0x9e, 0x98, 0xef, 0xc9, 0x20 } }; + + +// {8F487F1F-419F-47a7-8ECF-EC44AF4449A3} +FOOGUIDDECL const GUID mainmenu_groups::file = +{ 0x8f487f1f, 0x419f, 0x47a7, { 0x8e, 0xcf, 0xec, 0x44, 0xaf, 0x44, 0x49, 0xa3 } }; + +// {F8BE5604-165F-4bb9-B6A9-15E55E0E0D3A} +FOOGUIDDECL const GUID mainmenu_groups::view = +{ 0xf8be5604, 0x165f, 0x4bb9, { 0xb6, 0xa9, 0x15, 0xe5, 0x5e, 0xe, 0xd, 0x3a } }; + +// {8CDA6B10-0613-4cfd-8730-3B9CBF4C6A39} +FOOGUIDDECL const GUID mainmenu_groups::edit = +{ 0x8cda6b10, 0x613, 0x4cfd, { 0x87, 0x30, 0x3b, 0x9c, 0xbf, 0x4c, 0x6a, 0x39 } }; + +// {D8A4FC46-5E3D-47aa-97B7-947988228246} +FOOGUIDDECL const GUID mainmenu_groups::edit_part1 = +{ 0xd8a4fc46, 0x5e3d, 0x47aa, { 0x97, 0xb7, 0x94, 0x79, 0x88, 0x22, 0x82, 0x46 } }; + +// {007682CE-2A99-4b70-8F63-DE765D1C5555} +FOOGUIDDECL const GUID mainmenu_groups::edit_part2 = +{ 0x7682ce, 0x2a99, 0x4b70, { 0x8f, 0x63, 0xde, 0x76, 0x5d, 0x1c, 0x55, 0x55 } }; + +// {1F572090-D620-4940-85EC-0EFE499FAC03} +FOOGUIDDECL const GUID mainmenu_groups::edit_part3 = +{ 0x1f572090, 0xd620, 0x4940, { 0x85, 0xec, 0xe, 0xfe, 0x49, 0x9f, 0xac, 0x3 } }; + +// {65FA047A-1599-4b9c-B53D-C3FEB716339D} +FOOGUIDDECL const GUID mainmenu_groups::edit_part2_selection = +{ 0x65fa047a, 0x1599, 0x4b9c, { 0xb5, 0x3d, 0xc3, 0xfe, 0xb7, 0x16, 0x33, 0x9d } }; + +// {5B8AEF2C-6E1A-420d-B488-3E3A00E39E28} +FOOGUIDDECL const GUID mainmenu_groups::edit_part2_sort = +{ 0x5b8aef2c, 0x6e1a, 0x420d, { 0xb4, 0x88, 0x3e, 0x3a, 0x0, 0xe3, 0x9e, 0x28 } }; + +// {EE9D6F72-7BC7-4a60-8C28-B96DED252BD3} +FOOGUIDDECL const GUID mainmenu_groups::edit_part2_selection_sort = +{ 0xee9d6f72, 0x7bc7, 0x4a60, { 0x8c, 0x28, 0xb9, 0x6d, 0xed, 0x25, 0x2b, 0xd3 } }; + +// {53FA5B8A-FCBC-4296-B968-45BAE6888845} +FOOGUIDDECL const GUID mainmenu_groups::playback = +{ 0x53fa5b8a, 0xfcbc, 0x4296, { 0xb9, 0x68, 0x45, 0xba, 0xe6, 0x88, 0x88, 0x45 } }; + +// {15D22753-9D30-4929-AA14-5124016F7E68} +FOOGUIDDECL const GUID mainmenu_groups::library = +{ 0x15d22753, 0x9d30, 0x4929, { 0xaa, 0x14, 0x51, 0x24, 0x1, 0x6f, 0x7e, 0x68 } }; + +// {25DC3DB7-996A-4f48-AF53-712032EFA04F} +FOOGUIDDECL const GUID mainmenu_groups::help = +{ 0x25dc3db7, 0x996a, 0x4f48, { 0xaf, 0x53, 0x71, 0x20, 0x32, 0xef, 0xa0, 0x4f } }; + +// {8EED252D-0A0F-4fc9-9D81-8CF7209A8BF2} +FOOGUIDDECL const GUID mainmenu_groups::file_open = +{ 0x8eed252d, 0xa0f, 0x4fc9, { 0x9d, 0x81, 0x8c, 0xf7, 0x20, 0x9a, 0x8b, 0xf2 } }; + +// {9E650B8E-C3F3-4495-AF15-6B656060C3B9} +FOOGUIDDECL const GUID mainmenu_groups::file_add = +{ 0x9e650b8e, 0xc3f3, 0x4495, { 0xaf, 0x15, 0x6b, 0x65, 0x60, 0x60, 0xc3, 0xb9 } }; + +// {9995FAE6-B1C4-457f-A747-5BD120930210} +FOOGUIDDECL const GUID mainmenu_groups::file_playlist = +{ 0x9995fae6, 0xb1c4, 0x457f, { 0xa7, 0x47, 0x5b, 0xd1, 0x20, 0x93, 0x2, 0x10 } }; + +// {8A324F18-6173-42ec-A640-5E296AD446B3} +FOOGUIDDECL const GUID mainmenu_groups::file_etc = +{ 0x8a324f18, 0x6173, 0x42ec, { 0xa6, 0x40, 0x5e, 0x29, 0x6a, 0xd4, 0x46, 0xb3 } }; + +// {12F5E247-5A81-4734-8119-8F9BC114FE74} +FOOGUIDDECL const GUID mainmenu_groups::playback_controls = +{ 0x12f5e247, 0x5a81, 0x4734, { 0x81, 0x19, 0x8f, 0x9b, 0xc1, 0x14, 0xfe, 0x74 } }; + +// {1169B3EB-81B5-4199-8929-7D3EAFD4809F} +FOOGUIDDECL const GUID mainmenu_groups::playback_etc = +{ 0x1169b3eb, 0x81b5, 0x4199, { 0x89, 0x29, 0x7d, 0x3e, 0xaf, 0xd4, 0x80, 0x9f } }; + +// {29272FEC-21C7-4b00-A9A7-01A8CE675EBF} +FOOGUIDDECL const GUID mainmenu_groups::view_visualisations = +{ 0x29272fec, 0x21c7, 0x4b00, { 0xa9, 0xa7, 0x1, 0xa8, 0xce, 0x67, 0x5e, 0xbf } }; + +// {8AF6EE1A-18D5-4B1C-AA2D-E50EAE3DC117} +FOOGUIDDECL const GUID mainmenu_groups::view_dsp = +{ 0x8af6ee1a, 0x18d5, 0x4b1c,{ 0xaa, 0x2d, 0xe5, 0xe, 0xae, 0x3d, 0xc1, 0x17 } }; + +// {2DA055D4-0257-40b2-8281-7967866B485C} +FOOGUIDDECL const GUID mainmenu_groups::file_etc_preferences = +{ 0x2da055d4, 0x257, 0x40b2, { 0x82, 0x81, 0x79, 0x67, 0x86, 0x6b, 0x48, 0x5c } }; + +// {517BFAE8-A148-4cb2-8CCE-1AD2179FB910} +FOOGUIDDECL const GUID mainmenu_groups::file_etc_exit = +{ 0x517bfae8, 0xa148, 0x4cb2, { 0x8c, 0xce, 0x1a, 0xd2, 0x17, 0x9f, 0xb9, 0x10 } }; + +// {61190F78-3B3A-4fda-A431-2CF7DA1C96CE} +FOOGUIDDECL const GUID mainmenu_groups::view_alwaysontop = +{ 0x61190f78, 0x3b3a, 0x4fda, { 0xa4, 0x31, 0x2c, 0xf7, 0xda, 0x1c, 0x96, 0xce } }; + +// {E55F8D65-AE51-47bf-99F9-BB113421CB19} +FOOGUIDDECL const GUID mainmenu_groups::help_about = +{ 0xe55f8d65, 0xae51, 0x47bf, { 0x99, 0xf9, 0xbb, 0x11, 0x34, 0x21, 0xcb, 0x19 } }; + +// {696DF823-B7AE-4b73-95C8-C1E9A9410726} +FOOGUIDDECL const GUID mainmenu_groups::library_refresh= +{ 0x696df823, 0xb7ae, 0x4b73, { 0x95, 0xc8, 0xc1, 0xe9, 0xa9, 0x41, 0x7, 0x26 } }; + +// {004BF6ED-2F88-464f-BDC1-278F6E610C2F} +FOOGUIDDECL const GUID standard_commands::guid_seek_ahead_1s = +{ 0x4bf6ed, 0x2f88, 0x464f, { 0xbd, 0xc1, 0x27, 0x8f, 0x6e, 0x61, 0xc, 0x2f } }; + +// {5B56D124-2ECA-4b0f-9895-2A533B31D29E} +FOOGUIDDECL const GUID standard_commands::guid_seek_ahead_5s = +{ 0x5b56d124, 0x2eca, 0x4b0f, { 0x98, 0x95, 0x2a, 0x53, 0x3b, 0x31, 0xd2, 0x9e } }; + +// {B582E3CA-D86D-4568-8380-68BC9C93ED0E} +FOOGUIDDECL const GUID standard_commands::guid_seek_ahead_10s = +{ 0xb582e3ca, 0xd86d, 0x4568, { 0x83, 0x80, 0x68, 0xbc, 0x9c, 0x93, 0xed, 0xe } }; + +// {DE6B96B7-3074-4da9-A260-988E31CEE0F9} +FOOGUIDDECL const GUID standard_commands::guid_seek_ahead_30s = +{ 0xde6b96b7, 0x3074, 0x4da9, { 0xa2, 0x60, 0x98, 0x8e, 0x31, 0xce, 0xe0, 0xf9 } }; + +// {FEED4AD7-13D2-4846-8833-D91B5F8B4E94} +FOOGUIDDECL const GUID standard_commands::guid_seek_ahead_1min = +{ 0xfeed4ad7, 0x13d2, 0x4846, { 0x88, 0x33, 0xd9, 0x1b, 0x5f, 0x8b, 0x4e, 0x94 } }; + +// {ECCF4904-03CF-429a-9D99-7A87FA62FD10} +FOOGUIDDECL const GUID standard_commands::guid_seek_ahead_2min = +{ 0xeccf4904, 0x3cf, 0x429a, { 0x9d, 0x99, 0x7a, 0x87, 0xfa, 0x62, 0xfd, 0x10 } }; + +// {5F0F0AF7-F519-41e6-A8DB-04DF1390E69D} +FOOGUIDDECL const GUID standard_commands::guid_seek_ahead_5min = +{ 0x5f0f0af7, 0xf519, 0x41e6, { 0xa8, 0xdb, 0x4, 0xdf, 0x13, 0x90, 0xe6, 0x9d } }; + +// {9ABA4292-1B8F-42ac-93AC-34B2A74C6320} +FOOGUIDDECL const GUID standard_commands::guid_seek_ahead_10min = +{ 0x9aba4292, 0x1b8f, 0x42ac, { 0x93, 0xac, 0x34, 0xb2, 0xa7, 0x4c, 0x63, 0x20 } }; + +// {2F89AB1C-5646-4997-8E3F-92BEE0322A41} +FOOGUIDDECL const GUID standard_commands::guid_seek_back_1s = +{ 0x2f89ab1c, 0x5646, 0x4997, { 0x8e, 0x3f, 0x92, 0xbe, 0xe0, 0x32, 0x2a, 0x41 } }; + +// {0CE84538-2E21-4482-BFE1-BCEC471467CC} +FOOGUIDDECL const GUID standard_commands::guid_seek_back_5s = +{ 0xce84538, 0x2e21, 0x4482, { 0xbf, 0xe1, 0xbc, 0xec, 0x47, 0x14, 0x67, 0xcc } }; + +// {9F504218-AF5D-41a8-BCE3-26313FAE65EE} +FOOGUIDDECL const GUID standard_commands::guid_seek_back_10s = +{ 0x9f504218, 0xaf5d, 0x41a8, { 0xbc, 0xe3, 0x26, 0x31, 0x3f, 0xae, 0x65, 0xee } }; + +// {98239B89-F66E-4160-B650-D9B068C59E63} +FOOGUIDDECL const GUID standard_commands::guid_seek_back_30s = +{ 0x98239b89, 0xf66e, 0x4160, { 0xb6, 0x50, 0xd9, 0xb0, 0x68, 0xc5, 0x9e, 0x63 } }; + +// {6633226B-9AA9-4810-AFDA-185A281D9FE2} +FOOGUIDDECL const GUID standard_commands::guid_seek_back_1min = +{ 0x6633226b, 0x9aa9, 0x4810, { 0xaf, 0xda, 0x18, 0x5a, 0x28, 0x1d, 0x9f, 0xe2 } }; + +// {E2F8B8BB-C539-44f3-A300-13185DE52227} +FOOGUIDDECL const GUID standard_commands::guid_seek_back_2min = +{ 0xe2f8b8bb, 0xc539, 0x44f3, { 0xa3, 0x0, 0x13, 0x18, 0x5d, 0xe5, 0x22, 0x27 } }; + +// {7B41A130-01D2-4a1b-9CAD-6314633C61C4} +FOOGUIDDECL const GUID standard_commands::guid_seek_back_5min = +{ 0x7b41a130, 0x1d2, 0x4a1b, { 0x9c, 0xad, 0x63, 0x14, 0x63, 0x3c, 0x61, 0xc4 } }; + +// {0B012852-BAF9-4f6b-B947-FAB89AE76B79} +FOOGUIDDECL const GUID standard_commands::guid_seek_back_10min = +{ 0xb012852, 0xbaf9, 0x4f6b, { 0xb9, 0x47, 0xfa, 0xb8, 0x9a, 0xe7, 0x6b, 0x79 } }; + +FOOGUIDDECL const GUID standard_commands::guid_library_configure = { 0xa305602d, 0x4716, 0x4fc2, { 0x91, 0x57, 0xc6, 0x33, 0x9c, 0x4b, 0x1c, 0xe9 } }; +FOOGUIDDECL const GUID standard_commands::guid_library_rescan = { 0xb21d432e, 0xb14d, 0x4c8d, { 0xaf, 0xda, 0xf, 0x45, 0xc7, 0xb6, 0x22, 0x26 } }; + +FOOGUIDDECL const GUID standard_commands::guid_internet_radio = { 0x58712f87, 0x3d7b, 0x4f2e, { 0x88, 0xe5, 0x7d, 0xea, 0xe1, 0xa5, 0xf2, 0x3d } }; + +// {97215C5E-7228-4237-B52C-A2B5504EF726} +FOOGUIDDECL const GUID playback_statistics_collector::class_guid = +{ 0x97215c5e, 0x7228, 0x4237, { 0xb5, 0x2c, 0xa2, 0xb5, 0x50, 0x4e, 0xf7, 0x26 } }; + + +FOOGUIDDECL const GUID advconfig_entry::guid_root = { 0x34949f34, 0xe655, 0x4f09, { 0xba, 0x50, 0xfa, 0xeb, 0x4d, 0x9b, 0x77, 0x69 } }; +FOOGUIDDECL const GUID advconfig_entry::class_guid = { 0x7e84602e, 0xdc49, 0x4047, { 0xaa, 0xee, 0x63, 0x71, 0x8b, 0xbc, 0x5a, 0x1f } }; +FOOGUIDDECL const GUID advconfig_branch::class_guid = { 0x6a60b472, 0x91ac, 0x4681, { 0x9d, 0xc2, 0x76, 0xc9, 0x94, 0x0, 0x5b, 0x63 } }; +FOOGUIDDECL const GUID advconfig_entry_checkbox::class_guid = { 0x5243aba4, 0x2a3d, 0x4627, { 0x88, 0xef, 0xce, 0xe3, 0x76, 0x1c, 0x7, 0x9c } }; +FOOGUIDDECL const GUID advconfig_entry::guid_branch_tagging = { 0xe8fe273f, 0xdd00, 0x476e, { 0xa7, 0x90, 0xe5, 0x9d, 0xf6, 0xb8, 0xf8, 0xd4 } }; +FOOGUIDDECL const GUID advconfig_entry::guid_branch_decoding = { 0x904c272b, 0x2317, 0x4c3c, { 0xb2, 0xff, 0xc5, 0xa0, 0x12, 0x5e, 0x2c, 0xc2 } }; +FOOGUIDDECL const GUID advconfig_entry_string::class_guid = { 0x185d582d, 0xfbd8, 0x4db3, { 0xbe, 0x23, 0x47, 0xaa, 0xc6, 0x75, 0xfc, 0x11 } }; +FOOGUIDDECL const GUID advconfig_entry::guid_branch_tools = { 0x35365484, 0xcc58, 0x4926, { 0x97, 0xe1, 0x5e, 0x63, 0xf3, 0xab, 0xb9, 0xe2 } }; +FOOGUIDDECL const GUID advconfig_entry::guid_branch_playback = { 0xc48d430d, 0x112, 0x4922, { 0x97, 0x23, 0x28, 0x38, 0xc7, 0xd9, 0x7d, 0xd7 } }; +FOOGUIDDECL const GUID advconfig_entry::guid_branch_display = { 0x6c4bc1c8, 0xbaf4, 0x40c3, { 0x9d, 0xb1, 0x9, 0x50, 0x7f, 0xc, 0xc, 0xb9 } }; +FOOGUIDDECL const GUID advconfig_entry::guid_branch_vis = { 0xea1017c6, 0x298, 0x446c, { 0xb6, 0xc7, 0xbd, 0xf9, 0x1e, 0xd8, 0x12, 0xee } }; +FOOGUIDDECL const GUID advconfig_entry::guid_branch_general = { 0x534dc6e3, 0x29a2, 0x42f4, { 0xab, 0x49, 0x5a, 0x2, 0x71, 0x9b, 0x1d, 0xa } }; +FOOGUIDDECL const GUID advconfig_entry::guid_branch_debug = { 0xc375447d, 0x58e6, 0x4fd5, { 0xbd, 0xd8, 0x99, 0xfa, 0xef, 0x7b, 0x30, 0x9f } }; +FOOGUIDDECL const GUID advconfig_entry::guid_branch_tagging_general = { 0x1a7757de, 0x55bd, 0x4c25, { 0xb2, 0xf9, 0xc6, 0x3a, 0x85, 0x0, 0xba, 0xed } }; +FOOGUIDDECL const GUID advconfig_entry::guid_branch_converter = { 0x96ea6eae, 0xe848, 0x44d9, { 0x99, 0xd6, 0x4d, 0xa6, 0xeb, 0x39, 0x81, 0x8f } }; + + + +FOOGUIDDECL const GUID playback_control_v2::class_guid = { 0x1eb67bda, 0x1345, 0x49ae, { 0x8e, 0x89, 0x50, 0x5, 0xd9, 0x1, 0x62, 0x89 } }; + +FOOGUIDDECL const GUID info_lookup_handler::class_guid = { 0x4fcfdab7, 0x55b5, 0x47d6, { 0xb1, 0x9d, 0xa4, 0xdc, 0x9f, 0xd7, 0x69, 0x4c } }; +FOOGUIDDECL const GUID info_lookup_handler_v2::class_guid = { 0x3c9728a5, 0x89e5, 0x4560, { 0xb6, 0x8b, 0x9b, 0x9b, 0x90, 0x1f, 0x0, 0x7b } }; +FOOGUIDDECL const GUID info_lookup_handler_v3::class_guid = { 0x7d337e3c, 0x5f83, 0x4dee, { 0x9f, 0x39, 0xe4, 0x3b, 0xc1, 0x51, 0xe4, 0xa1 } }; + + +FOOGUIDDECL const GUID completion_notify::class_guid = { 0xdf26d586, 0xf7ec, 0x40c3, { 0x9f, 0xe8, 0x2e, 0xa0, 0x72, 0x5d, 0x76, 0xc0 } }; + +FOOGUIDDECL const GUID metadb_io_v2::class_guid = { 0x265c4ece, 0xffb2, 0x4299, { 0x91, 0xb5, 0x6c, 0xa6, 0x60, 0x3d, 0xa1, 0x53 } }; + +FOOGUIDDECL const GUID file_info_filter::class_guid = { 0x45d0b800, 0xde83, 0x4a77, { 0xad, 0x34, 0x3f, 0x84, 0x2d, 0x40, 0xe7, 0x95 } }; +FOOGUIDDECL const GUID file_info_filter_v2::class_guid = { 0x9bb4da92, 0xd334, 0x4f18, { 0x91, 0xc1, 0x91, 0x9f, 0xb2, 0xf4, 0x4f, 0x30 } }; + + + +FOOGUIDDECL const GUID metadb_hint_list::class_guid = { 0x719dc072, 0x8d4d, 0x4aa6, { 0xa6, 0xf3, 0x90, 0x73, 0x7, 0xe5, 0xbc, 0xee } }; + +FOOGUIDDECL const GUID playlist_incoming_item_filter_v2::class_guid = { 0xf335802b, 0xa522, 0x434d, { 0xbe, 0x89, 0xe8, 0x6d, 0x59, 0x56, 0x16, 0x48 } }; + +FOOGUIDDECL const GUID process_locations_notify::class_guid = { 0x7d7eddac, 0xf93e, 0x4707, { 0x96, 0x9b, 0xcf, 0x44, 0xa9, 0xe1, 0xfb, 0x78 } }; + +FOOGUIDDECL const GUID library_manager_v2::class_guid = { 0x900eae79, 0x68d0, 0x4900, { 0xa4, 0xd8, 0x18, 0x20, 0x5, 0xae, 0x33, 0x7e } }; + +FOOGUIDDECL const GUID packet_decoder::owner_Ogg = { 0x8fa27457, 0xa021, 0x43b9, { 0xad, 0x20, 0xa7, 0x96, 0xdb, 0x94, 0x7c, 0xd1 } }; + +FOOGUIDDECL const GUID packet_decoder::property_mp4_esds = { 0xe8504271, 0xaec0, 0x4805, { 0xbb, 0x69, 0x71, 0xcc, 0xa3, 0xbc, 0x2, 0xdd } }; + +FOOGUIDDECL const GUID packet_decoder::property_ogg_header = { 0xbeb22c78, 0xeb49, 0x4f9e, { 0x9e, 0x37, 0x57, 0xd8, 0x87, 0x40, 0xfb, 0x4c } }; + +FOOGUIDDECL const GUID packet_decoder::property_ogg_query_sample_rate = { 0x6226bf73, 0x1c37, 0x4aa1, { 0xae, 0xb1, 0x18, 0x8b, 0x4a, 0xf3, 0xae, 0xf7 } }; + +FOOGUIDDECL const GUID packet_decoder::property_ogg_packet = { 0xade740be, 0x8e2e, 0x4d0b, { 0xa4, 0x0, 0x3f, 0x6e, 0x8a, 0xf7, 0x71, 0xe4 } }; + +FOOGUIDDECL const GUID packet_decoder::property_ogg_query_preskip = { 0xfae837d4, 0xc396, 0x4ccd, { 0xa7, 0xa5, 0xeb, 0x1e, 0x7e, 0x86, 0x32, 0xfb } }; + +FOOGUIDDECL const GUID packet_decoder::property_allow_delayed_output = { 0x985b25a5, 0x5e79, 0x4dda, { 0x8b, 0xdd, 0x53, 0xb4, 0x25, 0x76, 0xe2, 0x2d } }; + +FOOGUIDDECL const GUID track_property_provider::class_guid = { 0xefcdd365, 0x81fc, 0x4c82, { 0x96, 0x1c, 0xa2, 0xb5, 0x76, 0x1a, 0xf8, 0xb7 } }; + +FOOGUIDDECL const GUID track_property_provider_v2::class_guid = { 0x78e86595, 0xcffd, 0x4d10, { 0x85, 0x66, 0xbc, 0xf6, 0x6c, 0x89, 0x11, 0x16 } }; + + +FOOGUIDDECL const GUID library_manager_v3::class_guid = { 0x33dc0f1f, 0x16f0, 0x4e27, { 0xa7, 0x3, 0x63, 0x57, 0x72, 0x35, 0xb0, 0x1c } }; + +FOOGUIDDECL const GUID metadb_io_v3::class_guid = { 0x10e80560, 0xb1ef, 0x4e5e, { 0xb4, 0xc, 0x5d, 0xfc, 0x2e, 0x9a, 0xf1, 0x11 } }; + +FOOGUIDDECL const GUID search_filter::class_guid = { 0x4134bb34, 0xed5, 0x49f3, { 0x9c, 0xef, 0x43, 0xe3, 0xa4, 0xa3, 0xa8, 0xae } }; + +FOOGUIDDECL const GUID search_filter_manager::class_guid = { 0xad0baa03, 0xebd4, 0x4a72, { 0xa0, 0xa7, 0x98, 0x3, 0xa9, 0xe1, 0xe4, 0xf4 } }; + +FOOGUIDDECL const GUID playlist_manager_v2::class_guid = { 0x7fe9052a, 0x8ec2, 0x4054, { 0xa8, 0xcf, 0x77, 0xef, 0xb5, 0x2f, 0xe4, 0x8 } }; + +FOOGUIDDECL const GUID playlist_manager_v3::class_guid = { 0x3b6575c8, 0x21a, 0x4474, { 0xbb, 0x60, 0x6c, 0xfc, 0xfe, 0x33, 0xc3, 0x4f } }; + +FOOGUIDDECL const GUID titleformat_common_methods::class_guid = { 0x432fe059, 0xf087, 0x4785, { 0xa5, 0x18, 0xcb, 0xc1, 0x8b, 0x84, 0x9a, 0xc1 } }; + +FOOGUIDDECL const GUID core_version_info_v2::class_guid = { 0x273704d7, 0x99ba, 0x4b58, { 0xa0, 0x60, 0x82, 0xab, 0x1, 0xb4, 0x92, 0x25 } }; + +FOOGUIDDECL const GUID visualisation_stream_v2::class_guid = { 0xeb5b35b5, 0x267b, 0x443c, { 0xbe, 0x37, 0xc, 0x25, 0x73, 0x81, 0xa8, 0x6a } }; + +FOOGUIDDECL const GUID visualisation_stream_v3::class_guid = { 0xe1fd8e8b, 0x68f1, 0x4cea, { 0xa0, 0xe6, 0x61, 0x91, 0x1d, 0x14, 0x65, 0x42 } }; + +FOOGUIDDECL const GUID album_art_extractor::class_guid = { 0xe19ca3d3, 0x6267, 0x4271, { 0xb7, 0x89, 0x6a, 0x3f, 0x87, 0xfb, 0x3e, 0xbf } }; +FOOGUIDDECL const GUID album_art_extractor_instance::class_guid = { 0xf673700e, 0x3b6e, 0x4f70, { 0xa1, 0x6, 0xab, 0x74, 0x5c, 0x20, 0x20, 0x60 } }; +FOOGUIDDECL const GUID album_art_editor::class_guid = { 0x36b34487, 0xd7b9, 0x4533, { 0xa7, 0x3f, 0x39, 0x6e, 0x2d, 0x9f, 0x41, 0x5e } }; +FOOGUIDDECL const GUID album_art_editor_instance::class_guid = { 0x642a2ae1, 0x2259, 0x48f5, { 0xab, 0xdc, 0x63, 0xed, 0x4e, 0xb5, 0x90, 0x76 } }; + + +FOOGUIDDECL const GUID icon_remapping::class_guid = { 0x7c6aea96, 0x4a19, 0x471b, { 0x92, 0x5a, 0xa7, 0xc8, 0xb2, 0x8a, 0x59, 0xe7 } }; + +FOOGUIDDECL const GUID file_operation_callback_dynamic_manager::class_guid = { 0x1cb3a4dc, 0x7d79, 0x45cf, { 0x82, 0x2e, 0xf8, 0x67, 0x7b, 0x8d, 0xde, 0x37 } }; + +FOOGUIDDECL const GUID ui_selection_holder::class_guid = { 0x2ec9b7a, 0x93a5, 0x434d, { 0x85, 0x46, 0xed, 0x1d, 0xbb, 0x24, 0x35, 0xd0 } }; +FOOGUIDDECL const GUID ui_selection_manager::class_guid = { 0xd8ee46c7, 0x27ad, 0x4881, { 0xb1, 0x33, 0x14, 0x96, 0xc0, 0xe7, 0xee, 0x67 } }; +FOOGUIDDECL const GUID ui_selection_manager_v2::class_guid = { 0x2740b6c1, 0x449d, 0x40cc, { 0x8a, 0x79, 0x38, 0xc, 0x77, 0xe8, 0xdf, 0xc2 } }; +FOOGUIDDECL const GUID ui_selection_manager_v3::class_guid = { 0x43810513, 0x4528, 0x4ccd, { 0x9b, 0xa9, 0xe0, 0xd0, 0xd, 0xd0, 0x3d, 0xab } }; + + +#ifdef _WIN32 +FOOGUIDDECL const GUID ole_interaction::class_guid = { 0xfbee40c9, 0xef36, 0x410b, { 0x9d, 0x52, 0x7e, 0x56, 0x39, 0x59, 0xf3, 0xd1 } }; +#endif + +FOOGUIDDECL const GUID tag_processor_album_art_utils::class_guid = { 0x58768713, 0xc13c, 0x4406, { 0x97, 0x98, 0x21, 0x47, 0xcb, 0x97, 0x33, 0x2a } }; + +FOOGUIDDECL const GUID playlist_incoming_item_filter_v3::class_guid = { 0xd3332054, 0xbccd, 0x45cb, { 0xbc, 0x2, 0x0, 0xa1, 0x3a, 0x80, 0x25, 0x9f } }; + +FOOGUIDDECL const GUID menu_item_resolver::class_guid = { 0xac70ecdc, 0xe1d, 0x4db2, { 0x9c, 0xd0, 0xc9, 0xb8, 0xa9, 0xcd, 0x28, 0xfa } }; + +FOOGUIDDECL const GUID app_close_blocking_task_manager::class_guid = { 0x213f1454, 0x8a62, 0x44b6, { 0xb0, 0xcb, 0xc1, 0xe1, 0x5d, 0xa7, 0x3b, 0xc8 } }; + + +FOOGUIDDECL const GUID autoplaylist_client::class_guid = { 0x7c90bda0, 0xf93d, 0x4a73, { 0x98, 0x51, 0xa0, 0x33, 0x6, 0x7, 0xcb, 0x28 } }; + +FOOGUIDDECL const GUID autoplaylist_client_factory::class_guid = { 0x764200cb, 0xe283, 0x4efd, { 0x88, 0xa5, 0x80, 0x38, 0xdd, 0xee, 0x77, 0xdb } }; + +FOOGUIDDECL const GUID autoplaylist_manager::class_guid = { 0x1571d0d, 0xc1e1, 0x44bf, { 0xb5, 0x29, 0x7a, 0xe, 0x4e, 0x89, 0x15, 0xbc } }; + + +FOOGUIDDECL const GUID replaygain_result::class_guid = { 0xe7f43102, 0xbc6e, 0x400b, { 0xbb, 0x81, 0x2d, 0x9b, 0xe4, 0x30, 0x3e, 0xcc } }; +FOOGUIDDECL const GUID replaygain_scanner::class_guid = { 0x2a40fcf9, 0xf1f7, 0x41da, { 0xad, 0x76, 0x29, 0xf7, 0x51, 0xed, 0xd3, 0x8a } }; +FOOGUIDDECL const GUID replaygain_scanner_entry::class_guid = { 0x278380f3, 0x6fc0, 0x4176, { 0x8a, 0x98, 0x1f, 0x66, 0x3a, 0x94, 0x79, 0xc5 } }; +FOOGUIDDECL const GUID replaygain_scanner_entry_v2::class_guid = { 0xb1ba75ca, 0xd600, 0x4b32,{ 0xa6, 0xeb, 0x93, 0xca, 0x73, 0xcd, 0xb4, 0x5c } }; + +#ifdef FOOBAR2000_DESKTOP +FOOGUIDDECL const GUID replaygain_alter_stream::class_guid = { 0x4141712a, 0xccd6, 0x45e4,{ 0x82, 0x70, 0x8c, 0xb2, 0x20, 0x26, 0x56, 0x8a } }; +FOOGUIDDECL const GUID replaygain_alter_stream_entry::class_guid = { 0x6e36b9cb, 0xb7d4, 0x4bde,{ 0xa4, 0xd1, 0xcc, 0xd2, 0x58, 0xa4, 0x7a, 0xcd } }; +#endif + +FOOGUIDDECL const GUID search_filter_manager_v2::class_guid = { 0xac62a380, 0x7771, 0x4dc9, { 0x8a, 0x26, 0x41, 0x41, 0x39, 0xb4, 0x3e, 0xe2 } }; +FOOGUIDDECL const GUID search_filter_v2::class_guid = { 0xb7ca3c8, 0xaf23, 0x4a52, { 0x82, 0x66, 0xfe, 0x5, 0x4c, 0x49, 0xeb, 0x23 } }; +FOOGUIDDECL const GUID search_filter_v3::class_guid = { 0xdd6bc035, 0x7e33, 0x425a, { 0x89, 0x32, 0x6, 0xb5, 0xea, 0xb0, 0x39, 0xbc } }; +FOOGUIDDECL const GUID search_filter_v4::class_guid = { 0x3a0575c7, 0xf94b, 0x4c55, { 0x83, 0x4b, 0xbf, 0x26, 0x5, 0x50, 0x18, 0xa3 } }; +FOOGUIDDECL const GUID search_filter_manager_v3::class_guid = { 0x9b156e01, 0xe9a5, 0x4709, { 0x9b, 0xa9, 0xb, 0xba, 0xe3, 0x39, 0x6f, 0xff } }; + + +FOOGUIDDECL const GUID autoplaylist_client_v2::class_guid = { 0xfaa716f7, 0xebb1, 0x473c, { 0xbc, 0xf1, 0xb0, 0x1b, 0x8c, 0x9f, 0x1b, 0x95 } }; +FOOGUIDDECL const GUID autoplaylist_client_v3::class_guid = { 0x6f5ad0b2, 0xe490, 0x4eaa, { 0x90, 0x73, 0x36, 0x11, 0x6e, 0xb4, 0xd, 0x7 } }; + + +FOOGUIDDECL const GUID library_search_ui::class_guid = { 0xe5eb14fa, 0xbb08, 0x4564, { 0xaf, 0xfa, 0x6f, 0x27, 0x3f, 0x37, 0xbd, 0x3d } }; + + +FOOGUIDDECL const GUID event_logger::class_guid = { 0x5d336782, 0x69d6, 0x4225, { 0x9e, 0xa8, 0xcc, 0x29, 0x35, 0x7, 0xf9, 0xfe } }; +FOOGUIDDECL const GUID event_logger_recorder::class_guid = { 0xdfcdc841, 0xa295, 0x46aa, { 0x85, 0x8c, 0xf2, 0x1f, 0xf8, 0x33, 0x8b, 0x78 } }; + + +FOOGUIDDECL const GUID playlist_manager_v4::class_guid = { 0xcea7b49e, 0xacf2, 0x4ea2, { 0x99, 0x86, 0x95, 0xa, 0x56, 0xa2, 0xc0, 0xef } }; + +#ifdef _WIN32 +FOOGUIDDECL const GUID ole_interaction_v2::class_guid = { 0x55738cab, 0x311d, 0x4dbe, { 0xa0, 0xbc, 0x51, 0xc1, 0xba, 0x27, 0xfe, 0x95 } }; +#endif + +FOOGUIDDECL const GUID autoplaylist_manager_v2::class_guid = { 0x67882220, 0xeea5, 0x4dbc, { 0x9a, 0xa3, 0x63, 0xde, 0x8c, 0xdd, 0x40, 0x82 } }; + +FOOGUIDDECL const GUID library_file_move_scope::class_guid = { 0x345fae5, 0x8093, 0x45f6, { 0x94, 0x2e, 0xd6, 0xe, 0xbf, 0x7, 0xe9, 0x52 } }; + +FOOGUIDDECL const GUID library_file_move_manager::class_guid = { 0xc4cd4818, 0xe3f8, 0x4061, { 0x99, 0xf1, 0x18, 0x66, 0x4e, 0x6c, 0x28, 0x57 } }; + +FOOGUIDDECL const GUID library_file_move_notify::class_guid = { 0xd8ae7613, 0x7577, 0x4192, { 0x8f, 0xa4, 0x2d, 0x8f, 0x7e, 0xc6, 0x6, 0x38 } }; + +#ifdef _WIN32 +FOOGUIDDECL const GUID library_meta_autocomplete::class_guid = { 0x4b976e34, 0xf05a, 0x4da4, { 0xad, 0x65, 0x71, 0x9c, 0xdf, 0xd, 0xed, 0xae } }; +FOOGUIDDECL const GUID library_meta_autocomplete_v2::class_guid = { 0xd60d585e, 0xb42e, 0x4a6e, { 0x8f, 0x24, 0x27, 0x50, 0x71, 0x1a, 0x87, 0x30 } }; +#endif + +FOOGUIDDECL const GUID library_index::class_guid = { 0x4ca8eeff, 0x162c, 0x4071, { 0x80, 0xa2, 0xf3, 0x46, 0x19, 0xb2, 0xe8, 0x14 } }; + +FOOGUIDDECL const GUID input_protocol_type::class_guid = { 0x6a03c4ee, 0xf87b, 0x49d7, { 0x81, 0xdb, 0x66, 0xb, 0xe8, 0xc1, 0x0, 0x7e } }; + +FOOGUIDDECL const GUID metadb_hint_list_v2::class_guid = { 0x983a971a, 0x596b, 0x478f, { 0x9c, 0x38, 0x36, 0xb0, 0x2b, 0xd6, 0x39, 0xd9 } }; + +#if FOOBAR2000_TARGET_VERSION >= 76 +FOOGUIDDECL const GUID playlist_loader::class_guid = { 0x7103cae9, 0x91c, 0x4d80, { 0xbc, 0x1d, 0x28, 0x4a, 0xc1, 0x3f, 0x1e, 0x8c } }; +FOOGUIDDECL const GUID playlist_loader_callback::class_guid = { 0x924470a0, 0x1478, 0x4141, { 0xa7, 0x5a, 0xc5, 0x2f, 0x1f, 0xfa, 0xef, 0xea } }; +FOOGUIDDECL const GUID playlist_loader_callback_v2::class_guid = { 0xcb5941bb, 0x9085, 0x4d7e, { 0x9b, 0xc2, 0x19, 0x71, 0xd3, 0x47, 0x96, 0x2a } }; +#endif + +FOOGUIDDECL const GUID album_art_manager_v2::class_guid = { 0xb420664f, 0x4033, 0x465e, { 0x81, 0xb1, 0xce, 0x42, 0x43, 0x89, 0x1f, 0x59 } }; +FOOGUIDDECL const GUID album_art_extractor_instance_v2::class_guid = { 0x951bbeb1, 0xa94a, 0x4d9a, { 0xa2, 0x85, 0xd6, 0x1e, 0xe4, 0x66, 0xe8, 0xcc } }; +FOOGUIDDECL const GUID album_art_path_list::class_guid = { 0xbb26233f, 0x1051, 0x4b01, { 0x9f, 0xd8, 0xf0, 0xe4, 0x20, 0x7, 0xd7, 0xe6 } }; +FOOGUIDDECL const GUID album_art_fallback::class_guid = { 0x45481581, 0x40b3, 0x4930, { 0xab, 0x6d, 0x4e, 0x6e, 0x56, 0x58, 0x6c, 0x82 } }; + + +FOOGUIDDECL const GUID advconfig_entry_string_v2::class_guid = { 0x2ec9b1fa, 0xe1e4, 0x42f0, { 0x87, 0x97, 0x4a, 0x63, 0x16, 0x94, 0x86, 0xbc } }; +FOOGUIDDECL const GUID advconfig_entry_checkbox_v2::class_guid = { 0xe29b37d0, 0xa957, 0x4a85, { 0x82, 0x40, 0x1e, 0x96, 0xc7, 0x29, 0xb6, 0x69 } }; + +FOOGUIDDECL const GUID config_io_callback_v2::class_guid = { 0xfe784bf0, 0x9504, 0x4e35, { 0x85, 0xe4, 0x72, 0x53, 0x82, 0x62, 0xa1, 0x99 } }; + +FOOGUIDDECL const GUID contextmenu_item_v2::class_guid = { 0x4bd830ca, 0xe3e6, 0x404e, { 0x95, 0x44, 0xc9, 0xb7, 0xd1, 0x5a, 0x3f, 0x49 } }; +FOOGUIDDECL const GUID contextmenu_group_manager::class_guid = { 0x92ba0c5, 0x5572, 0x48cd, { 0xa4, 0xca, 0x7b, 0x73, 0xde, 0xb, 0x2a, 0xec } }; +FOOGUIDDECL const GUID contextmenu_group::class_guid = { 0x9dcfc219, 0x779, 0x4669, { 0x98, 0xc1, 0x83, 0x6d, 0xf6, 0x7, 0xc5, 0xd4 } }; +FOOGUIDDECL const GUID contextmenu_group_popup::class_guid = { 0x97636ad5, 0x5b2d, 0x4ad6, { 0x9f, 0x79, 0xc9, 0x64, 0x63, 0x88, 0xc8, 0x29 } }; + +FOOGUIDDECL const GUID contextmenu_groups::root = { 0xe6e7dc71, 0x114b, 0x4848, { 0x92, 0x8c, 0x2a, 0xdc, 0x3f, 0x86, 0xbe, 0xb4 } }; +FOOGUIDDECL const GUID contextmenu_groups::tagging = { 0xc24b5125, 0xad58, 0x4dfd, { 0x99, 0x76, 0xff, 0xbe, 0xba, 0xad, 0xc9, 0x79 } }; +FOOGUIDDECL const GUID contextmenu_groups::tagging_pictures = { 0x7ba1a031, 0xe710, 0x48dc, { 0xbb, 0x11, 0xe0, 0xbe, 0xd8, 0x33, 0x66, 0x9e } }; + +FOOGUIDDECL const GUID contextmenu_groups::utilities = { 0xfb0a55d6, 0xe693, 0x4c4a, { 0x8c, 0x62, 0xf2, 0x4e, 0xa0, 0xce, 0xf8, 0xb7 } }; +FOOGUIDDECL const GUID contextmenu_groups::replaygain = { 0x9640f207, 0x9c98, 0x47b5, { 0x85, 0x7, 0x6c, 0x9c, 0x14, 0x3e, 0x64, 0x15 } }; +FOOGUIDDECL const GUID contextmenu_groups::fileoperations = { 0x62a0e2a4, 0x251d, 0x4315, { 0x88, 0x9b, 0x1, 0x8f, 0x30, 0x8c, 0x7, 0x7a } }; +FOOGUIDDECL const GUID contextmenu_groups::convert = { 0x70429638, 0x502b, 0x466d, { 0xbf, 0x24, 0x46, 0xd, 0xae, 0x23, 0x10, 0x91 } }; +FOOGUIDDECL const GUID contextmenu_groups::playbackstatistics = { 0x12ad3123, 0xd934, 0x4241, { 0xa7, 0x1, 0x92, 0x7e, 0x87, 0x7, 0xd1, 0xdc } }; +FOOGUIDDECL const GUID contextmenu_groups::properties = { 0xb38cb9f, 0xa92d, 0x4fa4, { 0xb4, 0x58, 0x70, 0xd2, 0xfd, 0x39, 0x25, 0xba } }; +FOOGUIDDECL const GUID contextmenu_groups::legacy = { 0xbebb1711, 0x20e, 0x46ed, { 0xa7, 0xf8, 0xa3, 0x26, 0x27, 0x18, 0x4a, 0x88 } }; + +FOOGUIDDECL const GUID mainmenu_commands_v2::class_guid = { 0xe682e810, 0x41f3, 0x434d, { 0xb0, 0xc7, 0xd4, 0x96, 0x90, 0xe6, 0x5f, 0x87 } }; +FOOGUIDDECL const GUID mainmenu_node::class_guid = { 0xabba6512, 0x377d, 0x414f, { 0x81, 0x3e, 0x68, 0x6, 0xc2, 0x2d, 0x4d, 0xb1 } }; + +FOOGUIDDECL const GUID system_time_keeper::class_guid = { 0xdc5d4938, 0x7927, 0x48ba, { 0xbf, 0x84, 0xda, 0x2f, 0xb1, 0xb, 0x36, 0xf2 } }; + +FOOGUIDDECL const GUID component_installation_validator::class_guid = { 0x639283e, 0x3004, 0x4e5c, { 0xb1, 0xb3, 0x6d, 0xff, 0x8, 0xa7, 0x92, 0x84 } }; + +FOOGUIDDECL const GUID playback_stream_capture::class_guid = { 0x9423439e, 0x8cd5, 0x45d7, { 0xaa, 0x6d, 0x4b, 0x98, 0xc, 0x22, 0x93, 0x3e } }; +FOOGUIDDECL const GUID playback_stream_capture_v2::class_guid = { 0x801e6865, 0x6040, 0x42a6, { 0x8c, 0x43, 0x57, 0x91, 0x8a, 0xdc, 0xee, 0xb7 } }; + +FOOGUIDDECL const GUID http_request::class_guid = { 0x48580056, 0x2c5f, 0x45a8, { 0xb8, 0x6e, 0x5, 0x83, 0x55, 0x3e, 0xaa, 0x4f } }; +FOOGUIDDECL const GUID http_request_post::class_guid = { 0xe254b804, 0xeac5, 0x4be0, { 0x99, 0x4d, 0x53, 0x1c, 0x17, 0xea, 0xfd, 0x37 } }; +FOOGUIDDECL const GUID http_request_post_v2::class_guid = { 0x95309335, 0xd301, 0x4946, { 0x99, 0x27, 0x2d, 0xb7, 0x9b, 0x22, 0x46, 0x9c } }; +FOOGUIDDECL const GUID http_client::class_guid = { 0x3b5ffe0c, 0xd75a, 0x491e, { 0xbb, 0x6f, 0x10, 0x3f, 0x73, 0x1e, 0x81, 0x84 } }; +FOOGUIDDECL const GUID http_reply::class_guid = { 0x7f02bf78, 0x5c98, 0x4d6d, { 0x83, 0x6b, 0xb7, 0x77, 0xa4, 0xa3, 0x3e, 0xe5 } }; + +FOOGUIDDECL const GUID popup_message_v2::class_guid = { 0x18b74f55, 0x10e1, 0x4645, { 0x91, 0xf6, 0xb0, 0xe0, 0x4c, 0x28, 0x21, 0xe9 } }; +FOOGUIDDECL const GUID metadb_index_client::class_guid = { 0x52637e7d, 0x7f3, 0x49bf, { 0x90, 0x19, 0x36, 0x20, 0x83, 0xcc, 0x7e, 0x59 } }; +FOOGUIDDECL const GUID metadb_index_manager::class_guid = { 0xb9633863, 0x2683, 0x4163, { 0xa5, 0x8d, 0x26, 0x47, 0x5d, 0xb0, 0xe7, 0x9b } }; +FOOGUIDDECL const GUID metadb_index_manager_v2::class_guid = { 0xfe0a0528, 0x5505, 0x4744, { 0x97, 0xed, 0xcf, 0xc9, 0x3, 0x7c, 0x8c, 0x14 } }; +FOOGUIDDECL const GUID metadb_index_transaction::class_guid = { 0xe4b7e77e, 0xbee3, 0x4d3d, { 0xae, 0x13, 0x3f, 0x79, 0x99, 0x2c, 0xd, 0x94 } }; + +FOOGUIDDECL const GUID init_stage_callback::class_guid = { 0xaf51c159, 0x6326, 0x4da5, { 0x90, 0xb0, 0xf1, 0x1f, 0x99, 0x64, 0xcc, 0x2e } }; +FOOGUIDDECL const GUID metadb_io_edit_callback::class_guid = { 0x2388a50f, 0x33d, 0x4b7c, { 0x91, 0xf2, 0x51, 0x53, 0x69, 0x43, 0xe9, 0xed } }; +FOOGUIDDECL const GUID metadb_io_edit_callback_v2::class_guid = { 0x8a4ac70, 0xaf77, 0x4a73, { 0xa6, 0xe9, 0xd5, 0xbc, 0x6, 0x9e, 0x6, 0x15 } }; + +FOOGUIDDECL const GUID progress_meter_instance::class_guid = { 0x13915b24, 0xefef, 0x42b5, { 0xae, 0x1d, 0x55, 0x24, 0x5e, 0x22, 0x22, 0xc5 } }; +FOOGUIDDECL const GUID progress_meter::class_guid = { 0x5e98da34, 0xa9c7, 0x4925, { 0xb0, 0xec, 0x90, 0x9d, 0xe0, 0x16, 0xfa, 0x68 } }; + +FOOGUIDDECL const GUID album_art_manager_config::class_guid = { 0xffa6f79b, 0x6e58, 0x459b, { 0xb7, 0x82, 0xc8, 0x61, 0xe6, 0x3d, 0xb0, 0x75 } }; +FOOGUIDDECL const GUID album_art_manager_v3::class_guid = { 0x125841a4, 0x9507, 0x4d93, { 0x98, 0x60, 0x15, 0xd3, 0xc3, 0x45, 0x47, 0xd6 } }; + +FOOGUIDDECL const GUID now_playing_album_art_notify_manager::class_guid = { 0x79a1aab7, 0xb1a1, 0x463c,{ 0xb8, 0x86, 0x32, 0xb6, 0x79, 0x56, 0xd9, 0xd2 } }; +FOOGUIDDECL const GUID now_playing_album_art_notify_manager_v2::class_guid = { 0x5f847cbc, 0xd3bc, 0x4f4d, { 0x82, 0x8e, 0x1c, 0xa1, 0x6, 0xf4, 0xf5, 0xde } }; + + +FOOGUIDDECL const GUID album_art_editor_instance_v2::class_guid = { 0xcf0f46ca, 0xe34a, 0x4be7, { 0xaf, 0x40, 0xf, 0x31, 0x5c, 0xa1, 0x23, 0x98 } }; + +FOOGUIDDECL const GUID input_info_writer_v2::class_guid = { 0x601c0b4c, 0xf915, 0x486c, { 0xa3, 0x77, 0x0, 0xe3, 0x9c, 0x4d, 0xb7, 0xe4 } }; + +FOOGUIDDECL const GUID playback_control_v3::class_guid = { 0x67008b05, 0x2792, 0x43b5, { 0x80, 0xbb, 0xf9, 0x41, 0xd7, 0xc3, 0xc9, 0x2 } }; + +FOOGUIDDECL const GUID metadb_info_container::class_guid = { 0xd1fdcc01, 0x1e84, 0x48e6, { 0xbf, 0x5f, 0x37, 0x74, 0xd1, 0xcd, 0xc0, 0xe } }; +FOOGUIDDECL const GUID metadb_info_container_v2::class_guid = { 0x3212f3cc, 0x7615, 0x42e2, { 0x80, 0x54, 0x41, 0xdf, 0xaf, 0xa4, 0x36, 0x57 } }; + + +FOOGUIDDECL const GUID metadb_hint_list_v3::class_guid = { 0x3e7d9438, 0x7be9, 0x437b, { 0x8a, 0xc8, 0x2b, 0xc2, 0x88, 0xce, 0x1e, 0x22 } }; +FOOGUIDDECL const GUID track_property_provider_v3::class_guid = { 0xdbbce29c, 0x6431, 0x464b, { 0x9c, 0x68, 0x7f, 0x38, 0xfc, 0x34, 0xaf, 0xe7 } }; + + +FOOGUIDDECL const GUID output::class_guid = { 0xb9632c4f, 0x596e, 0x43ee, { 0xb2, 0x14, 0x71, 0x4, 0x48, 0x4b, 0x65, 0xf1 } }; +FOOGUIDDECL const GUID output_entry::class_guid = { 0xe7480b4f, 0x4941, 0x4dd2, { 0xad, 0xbf, 0x96, 0x6c, 0x76, 0x63, 0x43, 0x92 } }; +FOOGUIDDECL const GUID output_entry_v2::class_guid = { 0xaacc17f3, 0xb7cc, 0x48c2, { 0x95, 0x6e, 0x52, 0xba, 0x72, 0x89, 0x42, 0xe5 } }; +FOOGUIDDECL const GUID output_entry_v3::class_guid = { 0xfa18060e, 0xfc84, 0x4f53, { 0xa8, 0xe3, 0x60, 0xc5, 0xf5, 0x22, 0x50, 0x7a } }; +FOOGUIDDECL const GUID volume_control::class_guid = { 0x39f9fc0c, 0x4dc9, 0x4a7a, { 0xb9, 0xad, 0x75, 0x8b, 0x78, 0x57, 0x78, 0xad } }; +FOOGUIDDECL const GUID output_v2::class_guid = { 0x4f679e4b, 0x79e0, 0x4fc9, { 0x90, 0x27, 0x55, 0x49, 0x85, 0x72, 0x26, 0xbf } }; +FOOGUIDDECL const GUID output_v3::class_guid = { 0x3b764d8e, 0x6c1c, 0x40bd, { 0x9a, 0x7e, 0xac, 0x3, 0x2a, 0x3e, 0x25, 0xf1 } }; +FOOGUIDDECL const GUID output_v4::class_guid = { 0x2c7a21a, 0xcc12, 0x48f3, { 0x89, 0x2e, 0xa7, 0x98, 0xb0, 0xc8, 0xaa, 0x49 } }; +FOOGUIDDECL const GUID output_v5::class_guid = { 0x735e6e3f, 0x95d8, 0x45ca, { 0xad, 0x1a, 0xca, 0x88, 0x1f, 0x1d, 0x5c, 0xfa } }; +FOOGUIDDECL const GUID output_v6::class_guid = { 0xcf632053, 0xd612, 0x4c33, { 0xa6, 0x90, 0xfe, 0x68, 0x64, 0x5b, 0x3b, 0xc9 } }; +FOOGUIDDECL const GUID output_v7::class_guid = { 0x6e7f41d9, 0x3143, 0x40c2, { 0xb7, 0xbf, 0xa4, 0xbd, 0xf9, 0x10, 0xbc, 0x1a } }; + + +FOOGUIDDECL const GUID output_manager::class_guid = { 0x6cc5827e, 0x2c89, 0x42ff, { 0x83, 0x51, 0x76, 0xa9, 0x2e, 0x2f, 0x34, 0x50 } }; +FOOGUIDDECL const GUID output_manager_v2::class_guid = { 0xcc8aa352, 0x7af1, 0x41d2, { 0x94, 0x7e, 0xa2, 0x65, 0x17, 0x5b, 0x68, 0x96 } }; + +FOOGUIDDECL const GUID ui_element_instance::class_guid = { 0xb55d4525, 0xddc8, 0x40d7,{ 0xb9, 0x19, 0x6d, 0x7c, 0x48, 0x38, 0xf2, 0xdb } }; +FOOGUIDDECL const GUID ui_element::class_guid = { 0xb52c703, 0x1586, 0x42f7,{ 0xa8, 0x4c, 0x70, 0x54, 0xcd, 0xc8, 0x22, 0x55 } }; +FOOGUIDDECL const GUID ui_element_v2::class_guid = { 0x2e1fe21e, 0x8e0f, 0x43be,{ 0x9f, 0xdb, 0xd5, 0xdd, 0xf4, 0xc9, 0xba, 0xba } }; +FOOGUIDDECL const GUID ui_element_instance_callback::class_guid = { 0xcd3647c6, 0x12d9, 0x4122,{ 0xa5, 0x28, 0x4a, 0xba, 0x34, 0x90, 0x89, 0x5c } }; +FOOGUIDDECL const GUID ui_element_instance_callback_v2::class_guid = { 0x5b11faa3, 0x48ee, 0x41a1,{ 0xb7, 0xf9, 0x16, 0x7a, 0xba, 0x6c, 0x60, 0x41 } }; +FOOGUIDDECL const GUID ui_element_children_enumerator::class_guid = { 0x6c7a3a46, 0xdc54, 0x4499,{ 0x98, 0x66, 0xae, 0x3, 0x55, 0xe, 0xf3, 0x1c } }; +FOOGUIDDECL const GUID ui_element_common_methods::class_guid = { 0xedee8cd9, 0x3072, 0x410e,{ 0xb2, 0x66, 0x37, 0x5d, 0x9f, 0x6f, 0xb0, 0x36 } }; +FOOGUIDDECL const GUID ui_element_common_methods_v2::class_guid = { 0x2dc90e34, 0x38fc, 0x4ad1,{ 0x92, 0x80, 0xff, 0x1f, 0xac, 0x14, 0x52, 0xd0 } }; +FOOGUIDDECL const GUID ui_element_common_methods_v3::class_guid = { 0xc911b54, 0xe6f9, 0x463c,{ 0x9b, 0xb1, 0xbd, 0xf3, 0xa, 0xec, 0xac, 0x97 } }; +FOOGUIDDECL const GUID ui_element_replace_dialog_notify::class_guid = { 0x95f9259e, 0x821e, 0x425f,{ 0x95, 0x57, 0x3b, 0xba, 0x63, 0x52, 0xf0, 0xc0 } }; +FOOGUIDDECL const GUID ui_element_popup_host::class_guid = { 0xfcc381e9, 0xe527, 0x4887,{ 0xae, 0x63, 0x27, 0xc0, 0x3f, 0x4, 0xd, 0x1 } }; +FOOGUIDDECL const GUID ui_element_popup_host_callback::class_guid = { 0x2993a043, 0x2e70, 0x4d8f,{ 0x81, 0xb, 0x41, 0x3, 0x37, 0x73, 0x97, 0xcd } }; +FOOGUIDDECL const GUID ui_element_config::class_guid = { 0xd34bba46, 0x1bad, 0x4547,{ 0xba, 0xb4, 0x17, 0xe2, 0x44, 0xd5, 0xeb, 0x94 } }; +FOOGUIDDECL const GUID ui_element_instance_callback_v3::class_guid = { 0x6d15c0c6, 0x90b6, 0x4c7e,{ 0xbf, 0x39, 0xe9, 0x39, 0xf2, 0xdf, 0x9b, 0x91 } }; +FOOGUIDDECL const GUID ui_element_popup_host_v2::class_guid = { 0x8caac11e, 0x52b6, 0x47f7,{ 0x97, 0xc9, 0x2c, 0x87, 0xdb, 0xdb, 0x2e, 0x5b } }; + +FOOGUIDDECL const GUID ui_config_manager::class_guid = { 0x199050a6, 0xd0fe, 0x47af, { 0x9b, 0xd7, 0xfc, 0x74, 0x59, 0x9e, 0x47, 0xbd } }; +FOOGUIDDECL const GUID ui_config_manager_v2::class_guid = { 0x2ed12611, 0xda05, 0x4ab9, { 0x87, 0x5b, 0xfb, 0x1b, 0x5c, 0x39, 0xcd, 0xc2 } }; + + +FOOGUIDDECL const GUID ui_edit_context::class_guid = { 0xf9ba651b, 0x52dd, 0x466f,{ 0xaa, 0x77, 0xa9, 0x7a, 0x74, 0x98, 0x80, 0x7e } }; +FOOGUIDDECL const GUID ui_edit_context_manager::class_guid = { 0x3807f161, 0xaa17, 0x47df,{ 0x80, 0xf1, 0xe, 0xfc, 0xd2, 0x19, 0xb7, 0xa1 } }; +FOOGUIDDECL const GUID ui_edit_context_playlist::class_guid = { 0x6dec364d, 0x29f2, 0x47c8,{ 0xaf, 0x93, 0xbd, 0x35, 0x56, 0x3f, 0xa2, 0x25 } }; + +#ifdef __APPLE__ +FOOGUIDDECL const GUID ui_element_mac::class_guid = { 0x4b00554f, 0xf457, 0x41b5, { 0xa8, 0x58, 0xa9, 0x33, 0x5d, 0x8e, 0x6, 0xa } }; +#endif + +#ifdef FOOBAR2000_HAVE_FILE_FORMAT_SANITIZER +FOOGUIDDECL const GUID file_format_sanitizer::class_guid = { 0x933dc1b8, 0xbce8, 0x4a0a, { 0xa4, 0x53, 0xbf, 0x4e, 0x6b, 0xcd, 0xb0, 0xf9 } }; +FOOGUIDDECL const GUID file_format_sanitizer_stdtags::class_guid = { 0x613bceb4, 0x54c5, 0x43e8, { 0x9e, 0xc, 0xb7, 0xec, 0x15, 0x9b, 0x85, 0x11 } }; +FOOGUIDDECL const GUID file_format_sanitizer_v2::class_guid = { 0xe61986b7, 0x1205, 0x4584, { 0x83, 0x2f, 0xda, 0xe1, 0x80, 0xa0, 0x8a, 0x42 } }; +#endif // FOOBAR2000_HAVE_FILE_FORMAT_SANITIZER + + +FOOGUIDDECL const GUID config_io_callback_v3::class_guid = { 0x8e633dd, 0x625e, 0x402c,{ 0xbe, 0xab, 0x74, 0x9, 0xd0, 0x1d, 0x41, 0xdf } }; +FOOGUIDDECL const GUID filesystem_v2::class_guid = { 0xdaf04ce2, 0x36a5, 0x4346,{ 0x80, 0x7f, 0x77, 0x8c, 0x5b, 0x5c, 0x26, 0xaa } }; +FOOGUIDDECL const GUID filesystem_v3::class_guid = { 0x7166094e, 0xbc64, 0x4c97, { 0xaa, 0x53, 0x62, 0xbd, 0x7a, 0x34, 0xb8, 0xf6 } }; + + +FOOGUIDDECL const GUID playlist_incoming_item_filter_v4::class_guid = { 0x9bd438f5, 0x91e9, 0x463f,{ 0xbd, 0xcc, 0x36, 0x30, 0xf6, 0x8e, 0xf0, 0x5 } }; + +FOOGUIDDECL const GUID file_lock::class_guid = { 0xb2f0b2f8, 0x1ccf, 0x438e, { 0xb9, 0x75, 0x9f, 0x5b, 0x75, 0x5a, 0xa3, 0x2e } }; +FOOGUIDDECL const GUID file_lock_manager::class_guid = { 0xa808fe53, 0xd36, 0x42fb, { 0xac, 0x2, 0x6a, 0xc8, 0x9c, 0xcb, 0x24, 0xbe } }; +FOOGUIDDECL const GUID file_lock_manager_v2::class_guid = { 0x30c07c6a, 0xde51, 0x4094, { 0x82, 0xe6, 0xf1, 0x57, 0xd1, 0xb2, 0x3a, 0xe8 } }; +FOOGUIDDECL const GUID file_lock_interrupt::class_guid = { 0x73ebabc8, 0xfe66, 0x4dae, { 0x95, 0x90, 0x3d, 0xa3, 0x9f, 0x17, 0x19, 0x15 } }; + +FOOGUIDDECL const GUID track_property_provider_v4::class_guid = { 0x707abb57, 0x35f7, 0x41c3, { 0xac, 0x43, 0xc9, 0xb6, 0xc, 0xc6, 0xa9, 0xae } }; +FOOGUIDDECL const GUID track_property_provider_v5::class_guid = { 0xd571eeff, 0x459c, 0x4c03, { 0x97, 0x65, 0xf6, 0x97, 0x5b, 0x32, 0xd, 0xe5 } }; + + +FOOGUIDDECL const GUID album_art_extractor_v2::class_guid = { 0x3aa31001, 0xaf5b, 0x497a, { 0xbd, 0xdc, 0xa9, 0x3f, 0x23, 0xb2, 0x1b, 0xc2 } }; +FOOGUIDDECL const GUID album_art_editor_v2::class_guid = { 0xf16827d3, 0xca20, 0x44fe, { 0x94, 0xe0, 0x56, 0xd7, 0x2d, 0x35, 0x81, 0x6 } }; + + +FOOGUIDDECL const GUID replaygain_scanner_config::class_guid = { 0x210970e1, 0xa478, 0x4d76, { 0xa5, 0x7c, 0x95, 0x9, 0xae, 0x82, 0xae, 0x41 } }; + +FOOGUIDDECL const GUID metadb_io_v4::class_guid = { 0x6ec07034, 0xd5c2, 0x4fb5, { 0xb7, 0x59, 0x7d, 0x12, 0x4f, 0xa7, 0x27, 0xf4 } }; +FOOGUIDDECL const GUID popup_message_v3::class_guid = { 0xef3c83fd, 0x1144, 0x4edb, { 0xb8, 0x43, 0xcf, 0xba, 0xc6, 0xe5, 0xe1, 0x8b } }; + +FOOGUIDDECL const GUID file_lowLevelIO::class_guid = { 0xbcacb272, 0x8e6c, 0x4d23, { 0x91, 0x9a, 0xe, 0xaa, 0x55, 0x2e, 0xc9, 0x70 } }; +FOOGUIDDECL const GUID file_lowLevelIO::guid_flushFileBuffers = { 0xace5356b, 0x8c72, 0x408a, { 0x8e, 0x32, 0x78, 0x1e, 0x7d, 0x7f, 0xe9, 0x97 } }; +FOOGUIDDECL const GUID file_lowLevelIO::guid_getFileTimes = { 0xb5a3cd80, 0x23ae, 0x4c51, { 0x83, 0x3b, 0xa5, 0x98, 0x6b, 0xe1, 0xec, 0x59 } }; +FOOGUIDDECL const GUID file_lowLevelIO::guid_setFileTimes = { 0x46501e0d, 0x644d, 0x4d00, { 0xaf, 0x8c, 0xc5, 0xc1, 0xb, 0x34, 0xae, 0x37 } }; + + +FOOGUIDDECL const GUID async_task_manager::class_guid = { 0xea055f49, 0x7c6d, 0x4695, { 0x8c, 0xf, 0xeb, 0xbd, 0x92, 0xdb, 0xa7, 0xa7 } }; + +FOOGUIDDECL const GUID fb2k::configStore::class_guid = { 0x97aad7fd, 0xb216, 0x4286, { 0x9e, 0xb3, 0x18, 0x8d, 0x35, 0xee, 0x84, 0x1c } }; +FOOGUIDDECL const GUID fb2k::configStore2::class_guid = { 0xd0c958db, 0x59c0, 0x4c5e, { 0x8c, 0xf2, 0xd, 0xb5, 0xd7, 0x9e, 0x9a, 0x1e } }; + +#if FOOBAR2020 +FOOGUIDDECL const GUID fb2k::timerManager::class_guid = { 0xa93c35e3, 0x3a61, 0x40b2, { 0xa5, 0x29, 0x26, 0x49, 0xd9, 0xab, 0x7d, 0x6 } }; +#endif // FOOBAR2020 + +FOOGUIDDECL const GUID read_ahead_tools::class_guid = { 0x709671bf, 0x449a, 0x4dc8, { 0x9f, 0xcf, 0x84, 0xb3, 0xbc, 0xec, 0x98, 0x4d } }; + +FOOGUIDDECL const GUID fb2k::imageLoaderLite::class_guid = { 0xbe06ead9, 0x1c9, 0x42e0, { 0x9f, 0x9f, 0x12, 0xb2, 0xde, 0x95, 0xca, 0x96 } }; +FOOGUIDDECL const GUID fb2k::imageViewer::class_guid = { 0xdbdaaa24, 0x2f90, 0x426c, { 0x86, 0x3, 0x1c, 0x5a, 0xe5, 0xf9, 0x82, 0x21 } }; + +FOOGUIDDECL const GUID fb2k::image::class_guid = { 0x93f81022, 0xd8f9, 0x499e, { 0x89, 0xd9, 0x1c, 0xd7, 0xd9, 0xb, 0x43, 0x16 } }; +FOOGUIDDECL const GUID fb2k::imageCreator::class_guid = { 0xc25cf6af, 0x5dc5, 0x4473, { 0xb6, 0xba, 0x7a, 0x24, 0x8a, 0xba, 0xfe, 0xe4 } }; +FOOGUIDDECL const GUID fb2k::imageLoader::class_guid = { 0x5d7e16c9, 0x498e, 0x4762, { 0xae, 0x86, 0x10, 0x99, 0xfb, 0x6b, 0xb8, 0x6e } }; + +FOOGUIDDECL const GUID fb2k::threadEntry::class_guid = { 0xac67b8cd, 0x1e1d, 0x47b0, { 0x8b, 0x5, 0xb3, 0xbf, 0x19, 0x93, 0x8c, 0x22 } }; +FOOGUIDDECL const GUID fb2k::cpuThreadPool::class_guid = { 0xc07f7a5a, 0x5003, 0x4381, { 0xb2, 0x1d, 0x86, 0x88, 0x4d, 0xfa, 0x8e, 0x52 } }; + +FOOGUIDDECL const GUID fsItemBase::class_guid = { 0xf5cf2a29, 0x3117, 0x49e9, { 0xb0, 0x6d, 0xe, 0x69, 0x39, 0x1c, 0x88, 0x14 } }; +FOOGUIDDECL const GUID fsItemFolder::class_guid = { 0x785b854a, 0xd72c, 0x4963, { 0xa4, 0x96, 0x7b, 0x13, 0xc1, 0xaa, 0xf4, 0x29 } }; +FOOGUIDDECL const GUID fsItemFile::class_guid = { 0xf2854c8f, 0xd2bb, 0x460c, { 0x80, 0x3b, 0x59, 0x32, 0xe1, 0x70, 0xa9, 0xb2 } }; + +FOOGUIDDECL const GUID fb2k::powerManager::class_guid = { 0xf09dd61f, 0x8dc9, 0x465e, { 0x83, 0x2c, 0xf0, 0x46, 0x3b, 0xeb, 0xe5, 0xc5 } }; + +FOOGUIDDECL const GUID fb2k::playlistColumnProvider::class_guid = { 0x4e75e324, 0xde05, 0x4bd8, { 0x81, 0xe5, 0x9f, 0xf7, 0x3a, 0xd3, 0x73, 0xdc } }; + +FOOGUIDDECL const GUID metadb_io_v5::class_guid = { 0x73e6dbc1, 0x2e33, 0x4bb7, { 0xb2, 0x3b, 0xe, 0x42, 0x3a, 0x53, 0xb1, 0x6 } }; +FOOGUIDDECL const GUID metadb_io_callback_v2::class_guid = { 0x7ee91836, 0x2dd0, 0x4103, { 0xa7, 0xc6, 0x4a, 0x62, 0x6b, 0x5f, 0x6b, 0x29 } }; + +FOOGUIDDECL const GUID library_manager_v4::class_guid = { 0xedf09b11, 0x7acf, 0x4229, { 0x97, 0x96, 0xad, 0x2e, 0xc1, 0x4c, 0x4b, 0x83 } }; +FOOGUIDDECL const GUID library_callback_v2::class_guid = { 0x301d64fb, 0xa353, 0x4652, { 0x8e, 0x33, 0xc7, 0xd7, 0xc0, 0x60, 0x25, 0x29 } }; +FOOGUIDDECL const GUID library_manager_v5::class_guid = { 0xa2a830ae, 0xe881, 0x448d, { 0xbc, 0x58, 0x37, 0x7f, 0x4, 0xd4, 0x4a, 0x4c } }; +FOOGUIDDECL const GUID library_manager_v5::status_current_callback_from_hook = { 0x43ca7276, 0x9acf, 0x4880, { 0xb2, 0xb3, 0x6c, 0xa2, 0x3e, 0x3, 0x62, 0x48 } }; + +FOOGUIDDECL const GUID mainmenu_commands_v3::class_guid = { 0x3a6a3de9, 0x5fc1, 0x4328, { 0x93, 0x55, 0x62, 0xa0, 0x79, 0x91, 0xae, 0xe3 } }; +FOOGUIDDECL const GUID input_entry_v4::class_guid = { 0x9630c70, 0x3c7, 0x4a66, { 0xa9, 0x36, 0x21, 0x7d, 0x80, 0x4e, 0xc9, 0xd4 } }; +FOOGUIDDECL const GUID input_stream_selector_v2::class_guid = { 0x99efd9de, 0x6b2, 0x49b2, { 0x8c, 0x49, 0xe2, 0x7f, 0xa3, 0x55, 0x49, 0xf1 } }; + +FOOGUIDDECL const GUID fb2k::audioEncoder::class_guid = { 0xf0ea7f10, 0xca11, 0x43d1, { 0xa0, 0xe9, 0x90, 0xb8, 0x26, 0x14, 0xfd, 0x5 } }; +FOOGUIDDECL const GUID fb2k::audioEncoderInstance::class_guid = { 0xdf137535, 0x148d, 0x47cc, { 0xaa, 0x3e, 0x47, 0xcf, 0xdc, 0x14, 0x99, 0x70 } }; + +FOOGUIDDECL const GUID fb2k::keyValueIO::class_guid = { 0xc789e9bb, 0x2105, 0x4749,{ 0xa5, 0x6e, 0x2a, 0x85, 0x9c, 0xcf, 0x32, 0x6e } }; + +FOOGUIDDECL const GUID fb2k::popup_toast::class_guid = { 0x85dc3944, 0x2088, 0x4c62, { 0xa3, 0x53, 0x5d, 0xf2, 0x6, 0xbd, 0xc5, 0xa } }; + +FOOGUIDDECL const GUID playlist_manager_v5::class_guid = { 0xb1e55754, 0x54f5, 0x4001, { 0x93, 0x34, 0x88, 0x78, 0xf7, 0xb5, 0xdd, 0x1 } }; + +FOOGUIDDECL const GUID menu_tree_item::class_guid = { 0x34ed0541, 0xadc8, 0x4384, { 0xad, 0xb, 0x2c, 0x4b, 0x2a, 0xbd, 0x30, 0x65 } }; + +FOOGUIDDECL const GUID mainmenu_manager_v2::class_guid = { 0x722fd952, 0x9159, 0x4c8e, { 0xb5, 0x6d, 0x61, 0x3e, 0x5c, 0x3e, 0x65, 0x82 } }; + +FOOGUIDDECL const GUID fb2k::fileDialogNotify::class_guid = { 0x3b90baba, 0x37d3, 0x4aa9, { 0x91, 0xb, 0x79, 0xc3, 0xb4, 0xa8, 0x2c, 0xcc } }; +FOOGUIDDECL const GUID fb2k::fileDialog::class_guid = { 0x3695a1b2, 0x2898, 0x4e66, { 0x9a, 0x82, 0xea, 0x59, 0xbc, 0x45, 0xb1, 0x5f } }; +FOOGUIDDECL const GUID fb2k::fileDialogSetup::class_guid = { 0x9a82082, 0xf01c, 0x4d6a, { 0x86, 0x8b, 0x69, 0xe, 0x8d, 0x46, 0xa, 0x7c } }; + +FOOGUIDDECL const GUID contextmenu_manager_v2::class_guid = { 0x8e56ee90, 0x37fb, 0x4c8e, { 0x92, 0x1a, 0xca, 0x8e, 0x8f, 0x9e, 0x1a, 0x2f } }; + +FOOGUIDDECL const GUID fb2k::console_manager::class_guid = { 0x39c3406b, 0xe2f, 0x43f3, { 0x87, 0xf2, 0xa6, 0xa3, 0x79, 0x2a, 0x98, 0x8 } }; + +FOOGUIDDECL const GUID fb2k::toolbarDropDown::class_guid = { 0x59aabce2, 0xce9f, 0x428b, { 0x8f, 0x10, 0xe, 0x24, 0xf3, 0xb6, 0xc7, 0x6d } }; + +FOOGUIDDECL const GUID search_index_manager::class_guid = { 0x281b998c, 0xb379, 0x4533, { 0x95, 0xe0, 0x90, 0xa2, 0x89, 0x30, 0x2a, 0x4a } }; +FOOGUIDDECL const GUID search_index::class_guid = { 0x581f032e, 0x8e4c, 0x4a46, { 0xbb, 0xa4, 0xef, 0xc, 0xc6, 0x5c, 0x98, 0xfa } }; + + +FOOGUIDDECL const GUID fb2k::callback_with_merit::class_guid = { 0x27c64500, 0x5481, 0x477a, { 0x9b, 0x22, 0x5d, 0x4c, 0x4d, 0xa6, 0x2, 0x88 } }; +FOOGUIDDECL const GUID playlist_manager_v6::class_guid = { 0x8fd46228, 0x9ba3, 0x4bb1, { 0xa0, 0x9c, 0xe8, 0x5b, 0x9e, 0x45, 0x8a, 0x58 } }; +FOOGUIDDECL const GUID library_manager_v6::class_guid = { 0x92eea180, 0x93d0, 0x44ef, { 0xbc, 0x43, 0xb6, 0x88, 0xae, 0x41, 0xb7, 0xad } }; +FOOGUIDDECL const GUID play_callback_manager_v2::class_guid = { 0x7e59a4e6, 0x810d, 0x433b, { 0xb6, 0x9, 0x12, 0xf4, 0xde, 0x7f, 0x7f, 0x47 } }; +FOOGUIDDECL const GUID metadb_hint_list_v4::class_guid = { 0xe7908ec9, 0xa26a, 0x418e, { 0xac, 0x13, 0xb4, 0x17, 0x67, 0x8c, 0xa, 0x4 } }; +FOOGUIDDECL const GUID metadb_pre_update_callback::class_guid = { 0xc81865af, 0x1da2, 0x4361, { 0x92, 0x88, 0xac, 0xf7, 0x83, 0x89, 0xe1, 0x9c } }; + +FOOGUIDDECL const GUID stream_receive::class_guid = { 0x1d36b5af, 0xaa6b, 0x450d, { 0xa4, 0x1f, 0x58, 0x19, 0x13, 0x4e, 0xdb, 0x57 } }; + +#ifdef __APPLE__ +FOOGUIDDECL const GUID fb2k::NSObjectWrapper::class_guid = { 0x6ec55805, 0x96f7, 0x4a8f, { 0x92, 0xb3, 0xbd, 0x33, 0xee, 0x10, 0x53, 0x17 } }; +#endif + +FOOGUIDDECL const GUID tag_processor_trailing_v2::class_guid = { 0x62b128c6, 0xc179, 0x4585, { 0x95, 0xfc, 0x30, 0x1, 0x95, 0xee, 0x99, 0x7a } }; +FOOGUIDDECL const GUID tag_processor_id3v2_v2::class_guid = { 0x9b7b982f, 0xbaf0, 0x4225, { 0xa5, 0x60, 0xa7, 0xac, 0x51, 0xd0, 0xce, 0xed } }; + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/hasher_md5.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/hasher_md5.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,48 @@ +#include "foobar2000-sdk-pch.h" +#include "hasher_md5.h" + +GUID hasher_md5::guid_from_result(const hasher_md5_result & param) +{ + static_assert(sizeof(GUID) == sizeof(hasher_md5_result), "sanity"); + GUID temp = * reinterpret_cast(¶m); + byte_order::order_le_to_native_t(temp); + return temp; +} + +GUID hasher_md5_result::asGUID() const { + return hasher_md5::guid_from_result( *this ); +} + +hasher_md5_result hasher_md5::process_single(const void * p_buffer,t_size p_bytes) +{ + hasher_md5_state state; + initialize(state); + process(state,p_buffer,p_bytes); + return get_result(state); +} + +GUID hasher_md5::process_single_guid(const void * p_buffer,t_size p_bytes) +{ + return guid_from_result(process_single(p_buffer,p_bytes)); +} + +t_uint64 hasher_md5_result::xorHalve() const { +#if PFC_BYTE_ORDER_IS_BIG_ENDIAN + t_uint64 ret = 0; + for(int walk = 0; walk < 8; ++walk) { + ret |= (t_uint64)((t_uint8)m_data[walk] ^ (t_uint8)m_data[walk+8]) << (walk * 8); + } + return ret; +#else + const t_uint64 * v = reinterpret_cast(&m_data); + return v[0] ^ v[1]; +#endif +} + +pfc::string8 hasher_md5_result::asString() const { + return pfc::format_hexdump( this->m_data, sizeof(m_data), ""); +} + +GUID hasher_md5_result::toGUID() const { + return hasher_md5::guid_from_result( *this ); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/hasher_md5.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/hasher_md5.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,101 @@ +#pragma once +#include "filesystem.h" // FB2K_STREAM_READER_OVERLOAD, FB2K_STREAM_WRITER_OVERLOAD + +struct hasher_md5_state { + char m_data[128]; +}; + +struct hasher_md5_result { + char m_data[16]; + + t_uint64 xorHalve() const; + GUID asGUID() const; + pfc::string8 asString() const; + pfc::string8 toString() const { return asString(); } + GUID toGUID() const; + + static hasher_md5_result null() {hasher_md5_result h = {}; return h;} + static int compare(hasher_md5_result const & h1, hasher_md5_result const & h2) { return memcmp(&h1, &h2, sizeof(hasher_md5_result)); } +}; + +FB2K_STREAM_READER_OVERLOAD(hasher_md5_result) { + stream.read_raw(&value, sizeof(value)); return stream; +} +FB2K_STREAM_WRITER_OVERLOAD(hasher_md5_result) { + stream.write_raw(&value, sizeof(value)); return stream; +} + +inline bool operator==(const hasher_md5_result & p_item1,const hasher_md5_result & p_item2) {return memcmp(&p_item1,&p_item2,sizeof(hasher_md5_result)) == 0;} +inline bool operator!=(const hasher_md5_result & p_item1,const hasher_md5_result & p_item2) {return memcmp(&p_item1,&p_item2,sizeof(hasher_md5_result)) != 0;} +inline bool operator>(const hasher_md5_result & p_item1, const hasher_md5_result & p_item2) { return memcmp(&p_item1, &p_item2, sizeof(hasher_md5_result)) > 0; } +inline bool operator<(const hasher_md5_result & p_item1, const hasher_md5_result & p_item2) { return memcmp(&p_item1, &p_item2, sizeof(hasher_md5_result)) < 0; } + +namespace pfc { + template<> class traits_t : public traits_rawobject {}; + template<> class traits_t : public traits_rawobject {}; + + template<> inline int compare_t(const hasher_md5_result & p_item1, const hasher_md5_result & p_item2) { + return memcmp(&p_item1, &p_item2, sizeof(hasher_md5_result)); + } + +} + +class NOVTABLE hasher_md5 : public service_base +{ +public: + + virtual void initialize(hasher_md5_state & p_state) = 0; + virtual void process(hasher_md5_state & p_state,const void * p_buffer,t_size p_bytes) = 0; + virtual hasher_md5_result get_result(const hasher_md5_state & p_state) = 0; + + + static GUID guid_from_result(const hasher_md5_result & param); + + hasher_md5_result process_single(const void * p_buffer,t_size p_bytes); + hasher_md5_result process_single_string(const char * str) {return process_single(str, strlen(str));} + GUID process_single_guid(const void * p_buffer,t_size p_bytes); + GUID get_result_guid(const hasher_md5_state & p_state) {return guid_from_result(get_result(p_state));} + + + //! Helper + void process_string(hasher_md5_state & p_state,const char * p_string,t_size p_length = ~0) {return process(p_state,p_string,pfc::strlen_max(p_string,p_length));} + hasher_md5_state initialize() { hasher_md5_state ret; initialize(ret); return ret; } + + FB2K_MAKE_SERVICE_COREAPI(hasher_md5); +}; + + +class stream_writer_hasher_md5 : public stream_writer { +public: + stream_writer_hasher_md5() { + m_hasher->initialize(m_state); + } + void write(const void * p_buffer,t_size p_bytes,abort_callback & p_abort) { + p_abort.check(); + m_hasher->process(m_state,p_buffer,p_bytes); + } + hasher_md5_result result() const { + return m_hasher->get_result(m_state); + } + GUID resultGuid() const { + return hasher_md5::guid_from_result(result()); + } +private: + hasher_md5_state m_state; + const hasher_md5::ptr m_hasher = hasher_md5::get(); +}; + +template +class stream_formatter_hasher_md5 : public stream_writer_formatter { +public: + stream_formatter_hasher_md5() : stream_writer_formatter(_m_stream,fb2k::noAbort) {} + + hasher_md5_result result() const { + return _m_stream.result(); + } + GUID resultGuid() const { + return hasher_md5::guid_from_result(result()); + } +private: + stream_writer_hasher_md5 _m_stream; +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/http_client.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/http_client.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,57 @@ +#pragma once + +//! Implemented by file object returned by http_request::run methods. Allows you to retrieve various additional information returned by the server. \n +//! Warning: reply status may change when seeking on the file object since seek operations often require a new HTTP request to be fired. +class NOVTABLE http_reply : public service_base { + FB2K_MAKE_SERVICE_INTERFACE(http_reply, service_base) +public: + //! Retrieves the status line, eg. "200 OK". + virtual void get_status(pfc::string_base & out) = 0; + //! Retrieves a HTTP header value, eg. "content-type". Note that get_http_header("content-type", out) is equivalent to get_content_type(out). If there are multiple matching header entries, value of the first one will be returned. + virtual bool get_http_header(const char * name, pfc::string_base & out) = 0; + //! Retrieves a HTTP header value, eg. "content-type". If there are multiple matching header entries, this will return all their values, delimited by \r\n. + virtual bool get_http_header_multi(const char * name, pfc::string_base & out) = 0; +}; + +class NOVTABLE http_request : public service_base { + FB2K_MAKE_SERVICE_INTERFACE(http_request, service_base) +public: + //! Adds a HTTP request header line. + //! @param line Request to be added, without trailing \r\n. + virtual void add_header(const char * line) = 0; + //! Runs the request on the specified URL. Throws an exception on failure (connection error, invalid response from the server, reply code other than 2XX), returns a file::ptr interface to the stream on success. + virtual file::ptr run(const char * url, abort_callback & abort) = 0; + //! Runs the request on the specified URL. Throws an exception on failure but returns normally if the HTTP server returned a valid response other than 2XX, so the caller can still parse the received data stream if the server has returned an error. + virtual file::ptr run_ex(const char * url, abort_callback & abort) = 0; + + void add_header(const char * name, const char * value) { + add_header(PFC_string_formatter() << name << ": " << value); + } +}; + +class NOVTABLE http_request_post : public http_request { + FB2K_MAKE_SERVICE_INTERFACE(http_request_post, http_request); +public: + //! Adds a HTTP POST field. + //! @param name Field name. + //! @param fileName File name to be included in the POST request; leave empty ("") not to send a file name. + //! @param contentType Content type of the entry; leave empty ("") not to send content type. + virtual void add_post_data(const char * name, const void * data, t_size dataSize, const char * fileName, const char * contentType) = 0; + + void add_post_data(const char * name, const char * value) { add_post_data(name, value, strlen(value), "", ""); } +}; + +//! \since 1.5 +class NOVTABLE http_request_post_v2 : public http_request_post { + FB2K_MAKE_SERVICE_INTERFACE(http_request_post_v2, http_request_post); +public: + virtual void set_post_data(const void* blob, size_t bytes, const char* contentType) = 0; +}; + +class NOVTABLE http_client : public service_base { + FB2K_MAKE_SERVICE_COREAPI(http_client) +public: + //! Creates a HTTP request object. + //! @param type Request type. Currently supported: "GET" and "POST". Throws pfc::exception_not_implemented for unsupported values. + virtual http_request::ptr create_request(const char * type) = 0; +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/icon_remap.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/icon_remap.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,28 @@ +#pragma once + +//! New in 0.9.5; allows your file format to use another icon than .ico when registering the file type with Windows shell. \n +//! Implementation: use icon_remapping_impl, or simply: static service_factory_single_t myicon("ext","iconname.ico"); +class icon_remapping : public service_base { +public: + //! @param p_extension File type extension being queried. + //! @param p_iconname Receives the icon name to use, including the .ico extension. + //! @returns True when p_iconname has been set, false if we don't recognize the specified extension. + virtual bool query(const char * p_extension,pfc::string_base & p_iconname) = 0; + + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(icon_remapping); +}; + +//! Standard implementation of icon_remapping. +class icon_remapping_impl : public icon_remapping { +public: + icon_remapping_impl(const char * p_extension,const char * p_iconname) : m_extension(p_extension), m_iconname(p_iconname) {} + bool query(const char * p_extension,pfc::string_base & p_iconname) { + if (pfc::stricmp_ascii(p_extension,m_extension) == 0) { + p_iconname = m_iconname; return true; + } else { + return false; + } + } +private: + pfc::string8 m_extension,m_iconname; +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/image.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/image.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,156 @@ +#include "foobar2000-sdk-pch.h" +#include "image.h" +#include "album_art.h" + +namespace fb2k { + bool imageSize_t::equals(imageSize_t const & v1, imageSize_t const & v2) { + return v1.width == v2.width && v1.height == v2.height; + } + bool imageSize_t::greater(const fb2k::imageSize_t &v1, const fb2k::imageSize_t &v2) { + // v1 > v2 + if (v1.width > v2.width) return true; + if (v1.width < v2.width) return false; + return v1.height > v2.height; + } + bool imageSize_t::isValid() const { + return width > 0 && height > 0; + } + + imageSize_t imageSize_t::fitIn( double longerEdge ) const { + if (!isValid() || longerEdge <= 0) return empty(); + + if (height <= longerEdge && width <= longerEdge) return *this; + + imageSize_t rv = {}; + if (width > height) { + rv.width = longerEdge; + rv.height = longerEdge * height / width; + } else { + rv.height = longerEdge; + rv.width = longerEdge * width / height; + } + return rv; + } + imageSize_t imageSize_t::fitIn( imageSize_t size ) const { + if (!isValid() || !size.isValid()) return empty(); + + if (width <= size.width && height <= size.height) return *this; + + imageSize_t rv = {}; + double ratio = size.width / size.height; + double ourRatio = width / height; + if (ratio < ourRatio) { + // fit width + rv.width = size.width; + rv.height = height * (size.width / width); + } else { + // fit height + rv.height = size.height; + rv.width = width * (size.height / height); + } + return rv; + } + + void imageSize_t::sanitize() { + if (width < 0) width = 0; + if (height < 0) height = 0; + width = pfc::rint32(width); + height = pfc::rint32(height); + } + image::ptr image::resizeToFit( imageSize_t fitInSize ) { + fitInSize.sanitize(); + imageSize_t ourSize = size(); + imageSize_t resizeTo = ourSize.fitIn(fitInSize); + if (resizeTo == ourSize || !resizeTo.isValid()) return this; + return resize( resizeTo ); + } + + + + static imageSize_t imageSizeSafe(imageRef img) { + if (img.is_valid()) return img->size(); + else return imageSize_t::empty(); + } + imageRef imageCreator::loadImageNamed2( const char * imgName, arg_t & arg ) { + auto ret = loadImageNamed( imgName, arg.inWantSize ); + arg.outRealSize = imageSizeSafe(ret); + return ret; + } + imageRef imageCreator::loadImageData2( const void * data, size_t size, stringRef sourceURL, arg_t & arg ) { + auto ret = loadImageData(data, size, sourceURL); + arg.outRealSize = imageSizeSafe(ret); + return ret; + } + imageRef imageCreator::loadImageData2(memBlockRef block, stringRef sourceURL, arg_t & arg) { + auto ret = loadImageData(block, sourceURL); + arg.outRealSize = imageSizeSafe(ret); + return ret; + } + imageRef imageCreator::loadImageFromFile2(const char * filePath, abort_callback & aborter, arg_t & arg) { + auto ret = loadImageFromFile(filePath, aborter); + arg.outRealSize = imageSizeSafe(ret); + return ret; + } + imageRef imageCreator::loadImageFromFile3( fsItemFile::ptr fsFile, abort_callback & aborter, arg_t & arg ) { + return loadImageFromFile2( fsFile->canonicalPath()->c_str(), aborter, arg); + } + + + void imageLocation_t::setPath( const char * path_ ) { + this->path = makeString(path_); + } + void imageLocation_t::setPath(stringRef path_) { + this->path = path_; + } + bool imageLocation_t::setTrack2( trackRef track ) { + return setTrack2( track, album_art_ids::cover_front ); + } + bool imageLocation_t::setTrack2( trackRef track, const GUID & albumArtID ) { + if (track.is_empty()) return false; + setPath( pfc::format("trackimage://", pfc::print_guid(albumArtID), ",", track->get_path())); + return true; + } + void imageLocation_t::setStock( const char * name ) { + setPath( pfc::format( "stockimage://", name ) ); + } + stringRef imageLocation_t::getStock( ) const { + if (path.is_valid()) { + if (matchProtocol( path->c_str(), "stockimage" ) ) { + return makeString( strstr( path->c_str(), "://" ) + 3 ); + } + } + return nullptr; + } + + void imageLocation_t::setEmbedded( const char * path_, const GUID & albumArtID ) { + setPath( PFC_string_formatter() << "embedded://" << pfc::print_guid(albumArtID) << "," << path_); + } + bool imageLocation_t::equals(const fb2k::imageLocation_t &l1, const fb2k::imageLocation_t &l2) { + if ( l1.path.is_empty() && l2.path.is_empty() ) return true; + if ( l1.path.is_empty() || l2.path.is_empty() ) return false; + return l1.path->equals( l2.path ); + } + bool imageLocation_t::operator==( imageLocation_t const & other) const { + return equals(*this, other); + } + bool imageLocation_t::operator!=( imageLocation_t const & other) const { + return !equals(*this, other); + } + + imageRef imageLoader::loadStock( const char * name, arg_t const & arg, abort_callback & aborter ) { + imageLocation_t loc; loc.setStock( name ); + return loadSynchronously(loc, arg, aborter); + } + +} + +pfc::string_base & operator<<(pfc::string_base & p_fmt,const fb2k::imageSize_t & imgSize) { + auto iw = pfc::rint32(imgSize.width); + auto ih = pfc::rint32(imgSize.height); + if (iw == imgSize.width && ih == imgSize.height) { + return p_fmt << "(" << iw << "x" << ih << ")"; + } else { + return p_fmt << "(" << imgSize.width << "x" << imgSize.height << ")"; + } +} + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/image.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/image.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,162 @@ +#pragma once +#include "imageLoaderLite.h" +#include "filesystem.h" +#include "tracks.h" + +namespace fb2k { + + //! \since 2.0 + struct imageSize_t { + double width, height; + static imageSize_t empty() { imageSize_t s = {}; return s; } + + static bool equals(imageSize_t const & v1, imageSize_t const & v2); + + bool isValid() const; + imageSize_t fitIn( double longerEdge ) const; + imageSize_t fitIn( imageSize_t size ) const; + bool operator==(const imageSize_t & other) const { return equals(*this, other); } + bool operator!=(const imageSize_t & other) const { return !equals(*this, other); } + + void sanitize(); + + //! Helper to allow imageSize_t objects to be used in various sorted contexts. + static bool greater(imageSize_t const & v1, imageSize_t const & v2); + bool operator>(const imageSize_t & other) const { return greater(*this, other); } + bool operator<(const imageSize_t & other) const { return greater(other, *this); } + }; + inline imageSize_t imageSizeMake(double w, double h) { imageSize_t s = { w, h }; return s; } + + //! \since 2.0 + class image : public service_base { + FB2K_MAKE_SERVICE_INTERFACE( image, service_base ); + public: + + //! Source URL of this image. May be null if not known or available. + virtual stringRef sourceURL() = 0; + //! Source data of this image. May be null if not known or available. + virtual memBlockRef sourceData() = 0; + //! Resize the image to the specified size. + virtual imageRef resize(imageSize_t toSize) = 0; + + //! Returns image size. + virtual imageSize_t size() = 0; + + image::ptr resizeToFit( imageSize_t fitInSize ); + + + //! Saves as PNG. + virtual void saveAsPNG( const char * pathSaveAt ) = 0; + //! Saves as JPEG. Quality represented in 0..1 scale + virtual void saveAsJPEG( const char * pathSaveAt, float jpegQuality) = 0; + + //! Returns if the image has alpha channel or not + virtual bool hasAlpha() { return false; } + + virtual bool isFileBacked() { return false; } + + //! Returns platform-specific native data. The data remains owned by this image object. + virtual nativeImage_t getNative() = 0; + //! Detaches platform-specific native data from this image object. The caller becomes the owner of the native data and is responsible for its deletion. + virtual nativeImage_t detachNative() = 0; + + static image::ptr empty() { return NULL; } + }; + + struct imageCreatorArg_t { + imageSize_t inWantSize; + imageSize_t outRealSize; + + static imageCreatorArg_t empty() { + imageCreatorArg_t arg = {}; + return arg; + } + }; + + //! \since 2.0 + //! Provides access to OS specific image object creation facilities. \n + //! By convention, imageCreator methods return nullptr when loading the image fails, rather than throw exceptions. + class imageCreator : public service_base { + FB2K_MAKE_SERVICE_COREAPI( imageCreator ); + public: + typedef imageCreatorArg_t arg_t; + + virtual imageRef loadImageNamed(const char * imgName, imageSize_t sizeHint = imageSize_t::empty()) = 0; + virtual imageRef loadImageData(const void * data, size_t size, stringRef sourceURL = nullptr) = 0; + virtual imageRef loadImageData(memBlockRef block, stringRef sourceURL = nullptr) = 0; + virtual imageRef loadImageFromFile(const char * filePath, abort_callback & aborter) = 0; + + //! Opportunistic image loader helper. Returns immediately without doing any file access and an existing instance of an image object is ready for reuse. Returns null if no such object is available at this time. + virtual imageRef tryReuseImageInstance( const char * filePath ) = 0; + + + virtual imageRef loadImageNamed2( const char * imgName, arg_t & arg ); + virtual imageRef loadImageData2( const void * data, size_t size, stringRef sourceURL, arg_t & arg ); + virtual imageRef loadImageData2(memBlockRef block, stringRef sourceURL, arg_t & arg); + virtual imageRef loadImageFromFile2(const char * filePath, abort_callback & aborter, arg_t & arg); + virtual imageRef loadImageFromFile3( fsItemFile::ptr fsFile, abort_callback & aborter, arg_t & arg ); + }; + + inline imageRef imageWithData( const void * data, size_t size ) {return imageCreator::get()->loadImageData( data, size ); } + inline imageRef imageWithData( memBlockRef data ) {return imageCreator::get()->loadImageData(data); } + + + struct imageLocation_t { + + bool isValid() const { return path.is_valid(); } + bool isEmpty() const { return path.is_empty(); } + void setPath( const char * path ); + void setPath( stringRef path ); + bool setTrack2( trackRef track ); + bool setTrack2( trackRef track, const GUID & albumArtID ); + void setStock( const char * name ); + void setEmbedded( const char * path, const GUID & albumArtID ); + + //! Returns stock image name if this is a stock image reference, nullptr otherwise. + stringRef getStock( ) const; + + static bool equals( const imageLocation_t & l1, const imageLocation_t & l2 ); + + bool operator==( imageLocation_t const & other) const; + bool operator!=( imageLocation_t const & other) const; + + stringRef path; + t_filetimestamp knownTimeStamp = filetimestamp_invalid;// hint + }; + + //! \since 2.0 + //! Image loader service. + class imageLoader : public service_base { + FB2K_MAKE_SERVICE_COREAPI( imageLoader ); + public: + + struct arg_t { + arg_t() { wantSize = imageSize_t::empty(); } + arg_t( imageSize_t const & size ) : wantSize(size) {} + imageSize_t wantSize; + imageRef bigImageHint; // optional, provide if you have big non resized version available + }; + + static arg_t defArg() { arg_t r; return r; } + + virtual imageRef tryLoadFromCache( imageLocation_t const & loc, arg_t const & arg ) = 0; + virtual imageRef loadSynchronously( imageLocation_t const & loc, arg_t const & arg, abort_callback & aborter ) = 0; + virtual objRef beginLoad( imageLocation_t const & loc, arg_t const & arg, objReceiverRef receiver ) = 0; + //! Retrieves image cache path for the specified location. The file at the returned path may or may not extist. \n + //! Caller must provide valid URL and timestamp in imageLocation_t. + virtual stringRef cacheLocation( imageLocation_t const & loc, arg_t const & arg) = 0; + + //! Similar to beginLoad; completes synchronously if the image is already in cache, passing the image to the receiver. + objRef beginLoadEx( imageLocation_t const & loc, arg_t const & arg, objReceiverRef receiver ); + + //! Helper; loads stock image synchronously. + imageRef loadStock( const char * name, arg_t const & arg, abort_callback & aborter ); + + //! Returns array of possible folder.jpg and alike file names to check for folder-pic. \n + //! Provided to avoid hardcoding the list (of folder.jpg, cover.jpg, etc) everywhere. \n + //! The returned strings are guaranteed lowercase. + virtual arrayRef folderPicNames() = 0; + }; +} + +pfc::string_base & operator<<(pfc::string_base & p_fmt,const fb2k::imageSize_t & imgSize); diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/imageLoaderLite.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/imageLoaderLite.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,55 @@ +#pragma once + +#include "commonObjects.h" + +#ifdef _WIN32 +namespace Gdiplus { + class Image; +} +#endif +namespace fb2k { +#ifdef _WIN32 + typedef Gdiplus::Image * nativeImage_t; +#else + typedef void * nativeImage_t; +#endif + + struct imageInfo_t { + uint32_t width, height, bitDepth; + bool haveAlpha; + const char * formatName; // MAY BE NULL IF UNKNOWN + const char * mime; // MAY BE NULL IF UNKNOWN + }; + + //! \since 1.6 + //! Interface to common image loader routines that turn a bytestream into a image that can be drawn in a window. \n + //! Windows: Using imageLoaderLite methods initializes gdiplus if necessary, leaving gdiplus initialized for the rest of app lifetime. \n + //! If your component supports running on foobar2000 older than 1.6, use tryGet() to gracefully fall back to your own image loader: \n + //! auto api = fb2k::imageLoaderLite::tryGet(); if (api.is_valid()) { do stuff with api; } else { use fallbacks; } + class imageLoaderLite : public service_base { + FB2K_MAKE_SERVICE_COREAPI(imageLoaderLite); + public: + //! Throws excpetions on failure, returns valid image otherwise.\n + //! Caller takes ownership of the returned object. \n + //! @param outInfo Optional struct to receive information about the loaded image. + virtual nativeImage_t load(const void * data, size_t bytes, imageInfo_t * outInfo = nullptr, abort_callback & aborter = fb2k::noAbort) = 0; + + //! Parses the image data just enough to hand over basic info about what's inside. \n + //! Much faster than load(). \n + //! Throws exceptions on failure. \n + //! Supports all formats recognized by load(). + virtual imageInfo_t getInfo(const void * data, size_t bytes, abort_callback & aborter = fb2k::noAbort) = 0; + + //! Helper - made virtual so it can be possibly specialized in the future + virtual nativeImage_t load(album_art_data_ptr data, imageInfo_t * outInfo = nullptr, abort_callback & aborter = fb2k::noAbort) { + return load(data->get_ptr(), data->get_size(), outInfo, aborter); + } + //! Helper - made virtual so it can be possibly specialized in the future + virtual imageInfo_t getInfo(album_art_data_ptr data, abort_callback & aborter = fb2k::noAbort) { + return getInfo(data->get_ptr(), data->get_size(), aborter); + } + }; +} + +#define FB2K_GETOPENFILENAME_PICTUREFILES "Picture files|*.jpg;*.jpeg;*.png;*.bmp;*.gif;*.webp" +#define FB2K_GETOPENFILENAME_PICTUREFILES_ALL FB2K_GETOPENFILENAME_PICTUREFILES "|All files|*.*" \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/imageViewer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/imageViewer.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,15 @@ +#pragma once + +namespace fb2k { + //! \since 1.6.2 + class imageViewer : public service_base { + FB2K_MAKE_SERVICE_COREAPI(imageViewer); + public: + //! Spawns an image viewer window, showing the specified picture already loaded into application memory. + virtual void show(fb2k::hwnd_t parent, fb2k::memBlockRef data) = 0; + //! Spawns an image viewer window, showing album art from the specified list of items. + //! @param aaType Type of picture to load, front cover, back cover or other. + //! @param pageno Reserved for future use, set to 0. + virtual void load_and_show(fb2k::hwnd_t parent, metadb_handle_list_cref items, const GUID & aaType, unsigned pageno = 0) = 0; + }; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/info_lookup_handler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/info_lookup_handler.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,45 @@ +#pragma once +//! Service used to access various external (online) track info lookup services, such as freedb, to update file tags with info retrieved from those services. +class NOVTABLE info_lookup_handler : public service_base { +public: + enum { + flag_album_lookup = 1 << 0, + flag_track_lookup = 1 << 1, + //! \since 2.2: supports lookup_noninteractive() call; before 2.2, lookup_noninteractive was assumed supported if info_lookup_handler_v2 was implemented. + flag_noninteractive = 1 << 2, + }; + + //! Retrieves human-readable name of the lookup handler to display in user interface. + virtual void get_name(pfc::string_base & p_out) = 0; + + //! Returns one or more of flag_track_lookup, flag_album_lookup, flag_noninteractive. + virtual t_uint32 get_flags() = 0; + + virtual fb2k::hicon_t get_icon(int p_width, int p_height) = 0; + + //! Performs a lookup. Creates a modeless dialog and returns immediately. + //! @param items Items to look up. + //! @param notify Callback to notify caller when the operation has completed. Call on_completion with status code 0 to signal failure/abort, or with code 1 to signal success / new infos in metadb. + //! @param parent Parent window for the lookup dialog. Caller will typically disable the window while lookup is in progress and enable it back when completion is signaled. + virtual void lookup(metadb_handle_list_cref items,completion_notify::ptr notify,fb2k::hwnd_t parent) = 0; + + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(info_lookup_handler); +}; + + +class NOVTABLE info_lookup_handler_v2 : public info_lookup_handler { + FB2K_MAKE_SERVICE_INTERFACE(info_lookup_handler_v2, info_lookup_handler); +public: + virtual double merit() {return 0;} + virtual void lookup_noninteractive(metadb_handle_list_cref items, completion_notify::ptr notify, fb2k::hwnd_t parent) = 0; +}; + +//! Since 2.2 +class NOVTABLE info_lookup_handler_v3 : public info_lookup_handler_v2 { + FB2K_MAKE_SERVICE_INTERFACE(info_lookup_handler_v3, info_lookup_handler_v2); +public: + //! Some handlers depend on user settings to access multiple actual online services. \n + //! Use this method to retrieve individual handlers for specific services, with proper name, icon, etc. + //! @returns Array of info_lookup_handler objects, null if there are no subhandlers and this object should be used. + virtual fb2k::arrayRef subhandlers() { return nullptr; } +}; \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/initquit.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/initquit.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,78 @@ +#pragma once +//! Basic callback startup/shutdown callback, on_init is called after the main window has been created, on_quit is called before the main window is destroyed. \n +//! To register: static initquit_factory_t myclass_factory; \n +//! Note that you should be careful with calling other components during on_init/on_quit or \n +//! initializing services that are possibly used by other components by on_init/on_quit - \n +//! initialization order of components is undefined. +//! If some other service that you publish is not properly functional before you receive an on_init() call, \n +//! someone else might call this service before >your< on_init is invoked. +class NOVTABLE initquit : public service_base { + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(initquit); +public: + virtual void on_init() {} + virtual void on_quit() {} +}; + +template +class initquit_factory_t : public service_factory_single_t {}; + + +//! \since 1.1 +namespace init_stages { + enum { + before_config_read = 10, + after_config_read = 20, + before_library_init = 30, + // Since foobar2000 v2.0, after_library_init is fired OUT OF ORDER with the rest, after ASYNCHRONOUS library init has completed. + after_library_init = 40, + before_ui_init = 50, + after_ui_init = 60, + }; +}; + +//! \since 1.1 +class NOVTABLE init_stage_callback : public service_base { + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(init_stage_callback) +public: + virtual void on_init_stage(t_uint32 stage) = 0; + + static void dispatch(t_uint32 stage) {FB2K_FOR_EACH_SERVICE(init_stage_callback, on_init_stage(stage));} +}; + +//! Helper for FB2K_RUN_ON_INIT_QUIT() +class initquit_lambda : public initquit { +public: + initquit_lambda(std::function i, std::function q) : m_init(i), m_quit(q) {} + void on_init() override { if (m_init) m_init(); } + void on_quit() override { if (m_quit) m_quit(); } +private: + const std::function m_init, m_quit; +}; + +//! Helper macros to skip implementing initquit.\n +//! Usage: \n +//! void myfunc() { ... } \n +//! FB2K_RUN_ON_INIT(myFunc); +#define FB2K_RUN_ON_INIT_QUIT(funcInit, funcQuit) FB2K_SERVICE_FACTORY_PARAMS(initquit_lambda, funcInit, funcQuit) +#define FB2K_RUN_ON_INIT(func) FB2K_RUN_ON_INIT_QUIT(func, nullptr) +#define FB2K_RUN_ON_QUIT(func) FB2K_RUN_ON_INIT_QUIT(nullptr, func) + +//! Helper for FB2K_ON_INIT_STAGE +class init_stage_callback_lambda : public init_stage_callback { +public: + init_stage_callback_lambda(std::function f, uint32_t stage) : m_func(f), m_stage(stage) {} + + void on_init_stage(t_uint32 stage) override { + PFC_ASSERT(m_func != nullptr); + if (stage == m_stage) m_func(); + } + + const std::function m_func; + const uint32_t m_stage; +}; + +//! Helper macro to skip implementing init_stage_callback.\n +//! Usage: \n +//! void myfunc() {...} \n +//! FB2K_ON_INIT_STAGE(myfunc, init_stages::after_ui_init); +#define FB2K_ON_INIT_STAGE(func, stage) FB2K_SERVICE_FACTORY_PARAMS(init_stage_callback_lambda, func, stage) diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/input.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/input.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,459 @@ +#include "foobar2000-sdk-pch.h" +#include +#include "input.h" +#include "input_impl.h" +#include "album_art.h" +#include "file_info_impl.h" + +service_ptr input_entry::open(const GUID & whatFor, file::ptr hint, const char * path, event_logger::ptr logger, abort_callback & aborter) { + +#ifdef FOOBAR2000_DESKTOP + if ( whatFor == input_stream_info_reader::class_guid ) { + input_entry_v2::ptr v2; + if ( v2 &= this ) { + GUID g = v2->get_guid(); + for (auto p : input_stream_info_reader_entry::enumerate()) { + if (p->get_guid() == g) { + return p->open(path, hint, aborter); + } + } + } + throw exception_io_unsupported_format(); + } +#endif + if ( whatFor == album_art_extractor_instance::class_guid ) { + input_entry_v2::ptr v2; + if (v2 &= this) { + GUID g = v2->get_guid(); + for (auto p : album_art_extractor::enumerate()) { + if (p->get_guid() == g) { + return p->open(hint, path, aborter); + } + } + } + throw exception_io_unsupported_format(); + } + if ( whatFor == album_art_editor_instance::class_guid ) { + input_entry_v2::ptr v2; + if (v2 &= this) { + GUID g = v2->get_guid(); + for (auto p : album_art_editor::enumerate()) { + if (p->get_guid() == g) { + return p->open(hint, path, aborter); + } + } + } + throw exception_io_unsupported_format(); + } + + input_entry_v3::ptr v3; + + if (v3 &= this) { + return v3->open_v3( whatFor, hint, path, logger, aborter ); + } else { + if (whatFor == input_decoder::class_guid) { + input_decoder::ptr obj; + open(obj, hint, path, aborter); + if ( logger.is_valid() ) { + input_decoder_v2::ptr v2; + if (v2 &= obj) v2->set_logger(logger); + } + return obj; + } + if (whatFor == input_info_reader::class_guid) { + input_info_reader::ptr obj; + open(obj, hint, path, aborter); + return obj; + } + if (whatFor == input_info_writer::class_guid) { + input_info_writer::ptr obj; + open(obj, hint, path, aborter); + return obj; + } + } + + throw pfc::exception_not_implemented(); +} + +bool input_entry::g_find_service_by_path(service_ptr_t & p_out,const char * p_path) +{ + auto ext = pfc::string_extension(p_path); + return g_find_service_by_path(p_out, p_path, ext ); +} + +bool input_entry::g_find_service_by_path(service_ptr_t & p_out,const char * p_path, const char * p_ext) +{ + for (auto ptr : enumerate()) { + if (ptr->is_our_path(p_path,p_ext)) { + p_out = ptr; + return true; + } + } + return false; +} + +bool input_entry::g_find_service_by_content_type(service_ptr_t & p_out,const char * p_content_type) +{ + for (auto ptr : enumerate()) { + if (ptr->is_our_content_type(p_content_type)) { + p_out = ptr; + return true; + } + } + return false; +} + + +#if 0 +static void prepare_for_open(service_ptr_t & p_service,service_ptr_t & p_file,const char * p_path,filesystem::t_open_mode p_open_mode,abort_callback & p_abort,bool p_from_redirect) +{ + if (p_file.is_empty()) + { + service_ptr_t fs; + if (filesystem::g_get_interface(fs,p_path)) { + if (fs->supports_content_types()) { + fs->open(p_file,p_path,p_open_mode,p_abort); + } + } + } + + if (p_file.is_valid()) + { + pfc::string8 content_type; + if (p_file->get_content_type(content_type)) + { + if (input_entry::g_find_service_by_content_type(p_service,content_type)) + return; + } + } + + if (input_entry::g_find_service_by_path(p_service,p_path)) + { + if (p_from_redirect && p_service->is_redirect()) throw exception_io_unsupported_format(); + return; + } + + throw exception_io_unsupported_format(); +} +#endif + +bool input_entry::g_find_inputs_by_content_type(pfc::list_base_t > & p_out, const char * p_content_type, bool p_from_redirect) { + auto filter = [=] (input_entry::ptr p) { + return !(p_from_redirect && p->is_redirect()); + }; + return g_find_inputs_by_content_type_ex(p_out, p_content_type, filter ); +} + +bool input_entry::g_find_inputs_by_path(pfc::list_base_t > & p_out, const char * p_path, bool p_from_redirect) { + auto filter = [=] (input_entry::ptr p) { + return !(p_from_redirect && p->is_redirect()); + }; + return g_find_inputs_by_path_ex(p_out, p_path, filter); +} + +bool input_entry::g_find_inputs_by_content_type_ex(pfc::list_base_t > & p_out, const char * p_content_type, input_filter_t filter ) { + bool ret = false; + for (auto ptr : enumerate()) { + if (filter(ptr)) { + if (ptr->is_our_content_type(p_content_type)) { p_out.add_item(ptr); ret = true; } + } + } + return ret; +} + +bool input_entry::g_find_inputs_by_path_ex(pfc::list_base_t > & p_out, const char * p_path, input_filter_t filter ) { + auto extension = pfc::string_extension(p_path); + bool ret = false; + for( auto ptr : enumerate()) { + GUID guid = pfc::guid_null; + input_entry_v3::ptr ex; + if ( ex &= ptr ) guid = ex->get_guid(); + if ( filter(ptr) ) { + if (ptr->is_our_path(p_path, extension)) { p_out.add_item(ptr); ret = true; } + } + } + return ret; +} + +static GUID input_get_guid( input_entry::ptr e ) { +#ifdef FOOBAR2000_DESKTOP + input_entry_v2::ptr p; + if ( p &= e ) return p->get_guid(); +#endif + return pfc::guid_null; +} + +service_ptr input_entry::g_open_from_list(input_entry_list_t const & p_list, const GUID & whatFor, service_ptr_t p_filehint, const char * p_path, event_logger::ptr logger, abort_callback & p_abort, GUID * outGUID) { + const t_size count = p_list.get_count(); + if ( count == 0 ) { + // sanity + throw exception_io_unsupported_format(); + } else if (count == 1) { + auto ret = p_list[0]->open(whatFor, p_filehint, p_path, logger, p_abort); + if ( outGUID != nullptr ) * outGUID = input_get_guid( p_list[0] ); + return ret; + } else { + std::exception_ptr errData, errUnsupported; + for (t_size n = 0; n < count; n++) { + try { + auto ret = p_list[n]->open(whatFor, p_filehint, p_path, logger, p_abort); + if (outGUID != nullptr) * outGUID = input_get_guid(p_list[n]); + return ret; + } catch (exception_io_no_handler_for_path const &) { + //do nothing, skip over + } catch(exception_io_unsupported_format const &) { + if (!errUnsupported) errUnsupported = std::current_exception(); + } catch (exception_io_data const &) { + if (!errData) errData = std::current_exception(); + } + } + if (errData) std::rethrow_exception(errData); + if (errUnsupported) std::rethrow_exception(errUnsupported); + throw exception_io_unsupported_format(); + } +} + +#ifdef FOOBAR2000_DESKTOP +service_ptr input_manager::open_v2(const GUID & whatFor, file::ptr hint, const char * path, bool fromRedirect, event_logger::ptr logger, abort_callback & aborter, GUID * outUsedEntry) { + // We're wrapping open_v2() on top of old open(). + // Assert on GUIDs that old open() is known to recognize. + PFC_ASSERT(whatFor == input_decoder::class_guid || whatFor == input_info_reader::class_guid || whatFor == input_info_writer::class_guid || whatFor == input_stream_selector::class_guid); + + { + input_manager_v2::ptr v2; + if ( v2 &= this ) { + return v2->open_v2( whatFor, hint, path, fromRedirect, logger, aborter, outUsedEntry ); + } + } + + auto ret = open( whatFor, hint, path, fromRedirect, aborter, outUsedEntry ); + +#ifdef FB2K_HAVE_EVENT_LOGGER + if ( logger.is_valid() ) { + input_decoder_v2::ptr dec; + if (dec &= ret) { + dec->set_logger(logger); + } + } +#endif + return ret; +} +#endif + +service_ptr input_entry::g_open(const GUID & whatFor, file::ptr p_filehint, const char * p_path, event_logger::ptr logger, abort_callback & p_abort, bool p_from_redirect) { + +#ifdef FOOBAR2000_DESKTOP + return input_manager_v2::get()->open_v2(whatFor, p_filehint, p_path, p_from_redirect, logger, p_abort); +#else // FOOBAR2000_DESKTOP or not + const bool needWriteAcecss = !!(whatFor == input_info_writer::class_guid); + + service_ptr_t l_file = p_filehint; + if (l_file.is_empty()) { + service_ptr_t fs; + if (filesystem::g_get_interface(fs, p_path)) { + if (fs->supports_content_types()) { + fs->open(l_file, p_path, needWriteAcecss ? filesystem::open_mode_write_existing : filesystem::open_mode_read, p_abort); + } + } + } + + if (l_file.is_valid()) { + pfc::string8 content_type; + if (l_file->get_content_type(content_type)) { + pfc::list_t< input_entry::ptr > list; +#if PFC_DEBUG + FB2K_DebugLog() << "attempting input open by content type: " << content_type; +#endif + if (g_find_inputs_by_content_type(list, content_type, p_from_redirect)) { + try { + return g_open_from_list(list, whatFor, l_file, p_path, logger, p_abort); + } catch (exception_io_unsupported_format const &) { +#if PFC_DEBUG + FB2K_DebugLog() << "Failed to open by content type, using fallback"; +#endif + } + } + } + } + +#if PFC_DEBUG + FB2K_DebugLog() << "attempting input open by path: " << p_path; +#endif + { + pfc::list_t< input_entry::ptr > list; + if (g_find_inputs_by_path(list, p_path, p_from_redirect)) { + return g_open_from_list(list, whatFor, l_file, p_path, logger, p_abort); + } + } + + throw exception_io_unsupported_format(); +#endif // not FOOBAR2000_DESKTOP +} + +void input_entry::g_open_for_decoding(service_ptr_t & p_instance,service_ptr_t p_filehint,const char * p_path,abort_callback & p_abort,bool p_from_redirect) { + TRACK_CALL_TEXT("input_entry::g_open_for_decoding"); + p_instance ^= g_open(input_decoder::class_guid, p_filehint, p_path, nullptr, p_abort, p_from_redirect); +} + +void input_entry::g_open_for_info_read(service_ptr_t & p_instance,service_ptr_t p_filehint,const char * p_path,abort_callback & p_abort,bool p_from_redirect) { + TRACK_CALL_TEXT("input_entry::g_open_for_info_read"); + p_instance ^= g_open(input_info_reader::class_guid, p_filehint, p_path, nullptr, p_abort, p_from_redirect); +} + +void input_entry::g_open_for_info_write(service_ptr_t & p_instance,service_ptr_t p_filehint,const char * p_path,abort_callback & p_abort,bool p_from_redirect) { + TRACK_CALL_TEXT("input_entry::g_open_for_info_write"); + p_instance ^= g_open(input_info_writer::class_guid, p_filehint, p_path, nullptr, p_abort, p_from_redirect); +} + +void input_entry::g_open_for_info_write_timeout(service_ptr_t & p_instance,service_ptr_t p_filehint,const char * p_path,abort_callback & p_abort,double p_timeout,bool p_from_redirect) { + pfc::lores_timer timer; + timer.start(); + for(;;) { + try { + g_open_for_info_write(p_instance,p_filehint,p_path,p_abort,p_from_redirect); + break; + } catch(exception_io_sharing_violation const &) { + if (timer.query() > p_timeout) throw; + p_abort.sleep(0.01); + } + } +} + +bool input_entry::g_is_supported_path(const char * p_path) +{ + auto ext = pfc::string_extension (p_path); + for( auto ptr : enumerate() ) { + if (ptr->is_our_path(p_path,ext)) return true; + } + return false; +} + + + +void input_open_file_helper(service_ptr_t & p_file,const char * p_path,t_input_open_reason p_reason,abort_callback & p_abort) +{ + if (p_file.is_empty()) { + switch(p_reason) { + default: + uBugCheck(); + case input_open_info_read: + case input_open_decode: + filesystem::g_open(p_file,p_path,filesystem::open_mode_read,p_abort); + break; + case input_open_info_write: + filesystem::g_open(p_file,p_path,filesystem::open_mode_write_existing,p_abort); + break; + } + } else { + p_file->reopen(p_abort); + } +} + +uint32_t input_entry::g_flags_for_path( const char * path, uint32_t mask ) { +#if defined(FOOBAR2000_DESKTOP) && FOOBAR2000_TARGET_VERSION >= 80 + return input_manager_v3::get()->flags_for_path(path, mask); +#else +#ifdef FOOBAR2000_DESKTOP + input_manager_v3::ptr api; + if ( input_manager_v3::tryGet(api) ) { + return api->flags_for_path(path, mask); + } +#endif + uint32_t ret = 0; + service_enum_t e; input_entry::ptr p; + auto ext = pfc::string_extension(path); + while(e.next(p)) { + uint32_t f = p->get_flags() & mask; + if ( f != 0 && p->is_our_path( path, ext ) ) ret |= f;; + } + return ret; +#endif +} +uint32_t input_entry::g_flags_for_content_type( const char * ct, uint32_t mask ) { +#if defined(FOOBAR2000_DESKTOP) && FOOBAR2000_TARGET_VERSION >= 80 + return input_manager_v3::get()->flags_for_content_type(ct, mask); +#else +#ifdef FOOBAR2000_DESKTOP + input_manager_v3::ptr api; + if ( input_manager_v3::tryGet(api) ) { + return api->flags_for_content_type( ct, mask ); + } +#endif + uint32_t ret = 0; + service_enum_t e; input_entry::ptr p; + while(e.next(p)) { + uint32_t f = p->get_flags() & mask; + if ( f != 0 && p->is_our_content_type(ct) ) ret |= f; + } + return ret; +#endif +} + +bool input_entry::g_are_parallel_reads_slow(const char * path) { + return g_flags_for_path(path, flag_parallel_reads_slow) != 0; +} + +void input_entry_v3::open_for_decoding(service_ptr_t & p_instance, service_ptr_t p_filehint, const char * p_path, abort_callback & p_abort) { + p_instance ^= open_v3( input_decoder::class_guid, p_filehint, p_path, nullptr, p_abort ); +} +void input_entry_v3::open_for_info_read(service_ptr_t & p_instance, service_ptr_t p_filehint, const char * p_path, abort_callback & p_abort) { + p_instance ^= open_v3(input_info_reader::class_guid, p_filehint, p_path, nullptr, p_abort); +} +void input_entry_v3::open_for_info_write(service_ptr_t & p_instance, service_ptr_t p_filehint, const char * p_path, abort_callback & p_abort) { + p_instance ^= open_v3(input_info_writer::class_guid, p_filehint, p_path, nullptr, p_abort); +} + +void input_info_writer::remove_tags_fallback(abort_callback & abort) { + uint32_t total = this->get_subsong_count(); + file_info_impl blank; + for( uint32_t walk = 0; walk < total; ++ walk ) { + this->set_info( this->get_subsong(walk), blank, abort ); + } + this->commit( abort ); +} + +t_filestats input_info_reader_v2::get_file_stats(abort_callback& a) { + return this->get_stats2(stats2_size | stats2_timestamp, a).to_legacy(); +} + +t_filestats2 input_info_reader::get_stats2_(const char* fallbackPath, uint32_t f, abort_callback& a) { + t_filestats2 ret; + input_info_reader_v2::ptr v2; + if (v2 &= this) { + ret = v2->get_stats2(f, a); + } else if ((f & ~stats2_legacy) == 0) { + t_filestats subset = this->get_file_stats(a); + ret.m_size = subset.m_size; + ret.m_timestamp = subset.m_timestamp; + } else { + try { + auto fs = filesystem::tryGet(fallbackPath); + if (fs.is_valid()) ret = fs->get_stats2_(fallbackPath, f, a); + } catch (exception_io const &) {} + } + return ret; +} + +GUID input_entry::get_guid_() { + auto ret = pfc::guid_null; + input_entry_v2::ptr v2; + if ( v2 &= this ) ret = v2->get_guid(); + return ret; +} + +const char* input_entry::get_name_() { + const char * ret = ""; + input_entry_v2::ptr v2; + if ( v2 &= this ) ret = v2->get_name(); + return ret; +} + +input_entry::ptr input_entry::g_find_by_guid(const GUID& guid) { + for (auto ptr : enumerate()) { + input_entry_v2::ptr v2; + if (v2 &= ptr) { + if ( guid == v2->get_guid() ) return v2; + } + } + return nullptr; +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/input.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/input.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,582 @@ +#pragma once +#include +#include "event_logger.h" +#include "audio_chunk.h" +#include "album_art.h" + +PFC_DECLARE_EXCEPTION(exception_tagging_unsupported, exception_io_data, "Tagging of this file format is not supported") + +enum { + // Seek commands won't be issued, can skip initializing seektables etc that sequential decode doesn't need. + input_flag_no_seeking = 1 << 0, + // Do not loop, also ignore user looping settings. + input_flag_no_looping = 1 << 1, + // Opening for actual playback, not for conversion/scan/test. + input_flag_playback = 1 << 2, + // Testing integrity, perform additional checks and report errors. Not mutually exlusive with input_flag_playback! + input_flag_testing_integrity = 1 << 3, + // OK to perform cheap but inaccurate seeking. + // Note that seeking should be ALWAYS sample accurate. This setting is a hint for decoding formats that are expensive to seek properly, indicating that no obvious harm will come from taking shortcuts. + input_flag_allow_inaccurate_seeking = 1 << 4, + // Suppress decode_postprocessor use. Handled by decode_postprocessor framework. + input_flag_no_postproc = 1 << 5, + // DSD decoders only: Send DSD as DoP. If not set, DSD should be decimated to PCM. + input_flag_dop = 1 << 6, + // Auotmated test suite running, disregard user options if possible + input_flag_canonical_decode = 1 << 7, + + input_flag_simpledecode = input_flag_no_seeking|input_flag_no_looping, +}; + +//! Class providing interface for retrieval of information (metadata, duration, replaygain, other tech infos) from files. Also see: file_info. \n +//! Instantiating: see input_entry.\n +//! Implementing: see input_impl. + +class NOVTABLE input_info_reader : public service_base { + FB2K_MAKE_SERVICE_INTERFACE(input_info_reader, service_base); +public: + //! Retrieves count of subsongs in the file. 1 for non-multisubsong-enabled inputs. + //! Note: multi-subsong handling is disabled for remote files (see: filesystem::is_remote) for performance reasons. Remote files are always assumed to be single-subsong, with null index. + virtual t_uint32 get_subsong_count() = 0; + + //! Retrieves identifier of specified subsong; this identifier is meant to be used in playable_location as well as a parameter for input_info_reader::get_info(). + //! @param p_index Index of subsong to query. Must be >=0 and < get_subsong_count(). + virtual t_uint32 get_subsong(t_uint32 p_index) = 0; + + //! Retrieves information about specified subsong. + //! @param p_subsong Identifier of the subsong to query. See: input_info_reader::get_subsong(), playable_location. + //! @param p_info file_info object to fill. Must be empty on entry. + //! @param p_abort abort_callback object signaling user aborting the operation. + virtual void get_info(t_uint32 p_subsong,file_info & p_info,abort_callback & p_abort) = 0; + + //! Retrieves file stats. Equivalent to calling get_stats() on file object. + virtual t_filestats get_file_stats(abort_callback & p_abort) = 0; + + t_filestats2 get_stats2_(const char* fallbackPath, uint32_t f, abort_callback& a); +}; + +class NOVTABLE input_info_reader_v2 : public input_info_reader { + FB2K_MAKE_SERVICE_INTERFACE(input_info_reader_v2, input_info_reader); +public: + virtual t_filestats2 get_stats2(uint32_t f, abort_callback& a) = 0; + + t_filestats get_file_stats(abort_callback& a) override; +}; + +//! Class providing interface for retrieval of PCM audio data from files.\n +//! Instantiating: see input_entry.\n +//! Implementing: see input_impl. + +class NOVTABLE input_decoder : public input_info_reader +{ +public: + //! Prepares to decode specified subsong; resets playback position to the beginning of specified subsong. This must be called first, before any other input_decoder methods (other than those inherited from input_info_reader). \n + //! It is legal to set initialize() more than once, with same or different subsong, to play either the same subsong again or another subsong from same file without full reopen.\n + //! Warning: this interface inherits from input_info_reader, it is legal to call any input_info_reader methods even during decoding! Call order is not defined, other than initialize() requirement before calling other input_decoder methods.\n + //! @param p_subsong Subsong to decode. Should always be 0 for non-multi-subsong-enabled inputs. + //! @param p_flags Specifies additional hints for decoding process. It can be null, or a combination of one or more following constants: \n + //! input_flag_no_seeking - Indicates that seek() will never be called. Can be used to avoid building potentially expensive seektables when only sequential reading is needed.\n + //! input_flag_no_looping - Certain input implementations can be configured to utilize looping info from file formats they process and keep playing single file forever, or keep repeating it specified number of times. This flag indicates that such features should be disabled, for e.g. ReplayGain scan or conversion.\n + //! input_flag_playback - Indicates that decoding process will be used for realtime playback rather than conversion. This can be used to reconfigure features that are relevant only for conversion and take a lot of resources, such as very slow secure CDDA reading. \n + //! input_flag_testing_integrity - Indicates that we're testing integrity of the file. Any recoverable problems where decoding would normally continue should cause decoder to fail with exception_io_data. + //! @param p_abort abort_callback object signaling user aborting the operation. + virtual void initialize(t_uint32 p_subsong,unsigned p_flags,abort_callback & p_abort) = 0; + + //! Reads/decodes one chunk of audio data. Use false return value to signal end of file (no more data to return). Before calling run(), decoding must be initialized by initialize() call. + //! @param p_chunk audio_chunk object receiving decoded data. Contents are valid only the method returns true. + //! @param p_abort abort_callback object signaling user aborting the operation. + //! @returns true on success (new data decoded), false on EOF. + virtual bool run(audio_chunk & p_chunk,abort_callback & p_abort) = 0; + + //! Seeks to specified time offset. Before seeking or other decoding calls, decoding must be initialized with initialize() call. + //! @param p_seconds Time to seek to, in seconds. If p_seconds exceeds length of the object being decoded, succeed, and then return false from next run() call. + //! @param p_abort abort_callback object signaling user aborting the operation. + virtual void seek(double p_seconds,abort_callback & p_abort) = 0; + + //! Queries whether resource being read/decoded is seekable. If p_value is set to false, all seek() calls will fail. Before calling can_seek() or other decoding calls, decoding must be initialized with initialize() call. + virtual bool can_seek() = 0; + + //! This function is used to signal dynamic VBR bitrate, etc. Called after each run() (or not called at all if caller doesn't care about dynamic info). + //! @param p_out Initially contains currently displayed info (either last get_dynamic_info result or current cached info), use this object to return changed info. + //! @param p_timestamp_delta Indicates when returned info should be displayed (in seconds, relative to first sample of last decoded chunk), initially set to 0. + //! @returns false to keep old info, or true to indicate that changes have been made to p_info and those should be displayed. + virtual bool get_dynamic_info(file_info & p_out, double & p_timestamp_delta) = 0; + + //! This function is used to signal dynamic live stream song titles etc. Called after each run() (or not called at all if caller doesn't care about dynamic info). The difference between this and get_dynamic_info() is frequency and relevance of dynamic info changes - get_dynamic_info_track() returns new info only on track change in the stream, returning new titles etc. + //! @param p_out Initially contains currently displayed info (either last get_dynamic_info_track result or current cached info), use this object to return changed info. + //! @param p_timestamp_delta Indicates when returned info should be displayed (in seconds, relative to first sample of last decoded chunk), initially set to 0. + //! @returns false to keep old info, or true to indicate that changes have been made to p_info and those should be displayed. + virtual bool get_dynamic_info_track(file_info & p_out, double & p_timestamp_delta) = 0; + + //! Obsolete, do not use, do not rely on. + virtual void on_idle(abort_callback & p_abort) = 0; + + + FB2K_MAKE_SERVICE_INTERFACE(input_decoder,input_info_reader); +}; + + +class NOVTABLE input_decoder_v2 : public input_decoder { + FB2K_MAKE_SERVICE_INTERFACE(input_decoder_v2, input_decoder) +public: + + //! OPTIONAL, throws pfc::exception_not_implemented() when not supported by this implementation. + //! Special version of run(). Returns an audio_chunk object as well as a raw data block containing original PCM stream. This is mainly used for MD5 checks on lossless formats. \n + //! If you set a "MD5" tech info entry in get_info(), you should make sure that run_raw() returns data stream that can be used to verify it. \n + //! Returned raw data should be possible to cut into individual samples; size in bytes should be divisible by audio_chunk's sample count for splitting in case partial output is needed (with cuesheets etc). + virtual bool run_raw(audio_chunk & out, mem_block_container & outRaw, abort_callback & abort) = 0; + + //! OBSOLETE since 1.5 \n + //! Specify logger when opening to reliably get info generated during input open operation. + virtual void set_logger(event_logger::ptr ptr) = 0; +}; + +class NOVTABLE input_decoder_v3 : public input_decoder_v2 { + FB2K_MAKE_SERVICE_INTERFACE(input_decoder_v3, input_decoder_v2); +public: + //! OBSOLETE, functionality implemented by core. + virtual void set_pause(bool paused) = 0; + //! OPTIONAL, should return false in most cases; return true to force playback buffer flush on unpause. Valid only after initialize() with input_flag_playback. + virtual bool flush_on_pause() = 0; +}; + +class NOVTABLE input_decoder_v4 : public input_decoder_v3 { + FB2K_MAKE_SERVICE_INTERFACE( input_decoder_v4, input_decoder_v3 ); +public: + //! OPTIONAL, return 0 if not implemented. \n + //! Provides means for communication of context specific data with the decoder. The decoder should do nothing and return 0 if it does not recognize the passed arguments. + virtual size_t extended_param( const GUID & type, size_t arg1, void * arg2, size_t arg2size) = 0; +}; + +//! Parameter GUIDs for input_decoder_v3::extended_param(). +class input_params { +public: + //! Signals whether unnecessary seeking should be avoided with this decoder for performance reasons. \n + //! Arguments disregarded, return value 1 or 0. + static const GUID seeking_expensive; + + //! Tells the decoder to output at this sample rate if the decoder's sample rate is adjustable. \n + //! Sample rate signaled in arg1. + static const GUID set_preferred_sample_rate; + + //! Retrieves logical decode position from the decoder. Implemented only in some rare cases where logical position does not match duration of returned data so far. + //! arg2 points to double position in seconds. + //! Return 1 if position was written to arg2, 0 if n/a. + static const GUID query_position; + + //! Asks whether it is OK to externally rewrite tags on this file without closing and reopening the decoder. \n + //! Return 1 if the decoder reads all relevant content in open() without leaving the file open afterwards, 0 otherwise (the default). + static const GUID is_tag_write_safe; +}; + +//! Class providing interface for writing metadata and replaygain info to files. Also see: file_info. \n +//! Instantiating: see input_entry.\n +//! Implementing: see input_impl. +class NOVTABLE input_info_writer : public input_info_reader +{ +public: + //! Tells the service to update file tags with new info for specified subsong. + //! @param p_subsong Subsong to update. Should be always 0 for non-multisubsong-enabled inputs. + //! @param p_info New info to write. Sometimes not all contents of p_info can be written. Caller will typically read info back after successful write, so e.g. tech infos that change with retag are properly maintained. + //! @param p_abort abort_callback object signaling user aborting the operation. WARNING: abort_callback object is provided for consistency; if writing tags actually gets aborted, user will be likely left with corrupted file. Anything calling this should make sure that aborting is either impossible, or gives appropriate warning to the user first. + virtual void set_info(t_uint32 p_subsong,const file_info & p_info,abort_callback & p_abort) = 0; + + //! Commits pending updates. In case of multisubsong inputs, set_info should queue the update and perform actual file access in commit(). Otherwise, actual writing can be done in set_info() and then commit() can just do nothing and always succeed. + //! @param p_abort abort_callback object signaling user aborting the operation. WARNING: abort_callback object is provided for consistency; if writing tags actually gets aborted, user will be likely left with corrupted file. Anything calling this should make sure that aborting is either impossible, or gives appropriate warning to the user first. + virtual void commit(abort_callback & p_abort) = 0; + + //! Helper for writers not implementing input_info_writer_v2::remove_tags(). + void remove_tags_fallback(abort_callback & abort); + + FB2K_MAKE_SERVICE_INTERFACE(input_info_writer,input_info_reader); +}; + +//! Extended input_info_writer. Not every input implements it. \n +//! Provides an explicit remove_tags(), which erases all supported tags from the file. +class NOVTABLE input_info_writer_v2 : public input_info_writer { +public: + //! Removes all tags from this file. Cancels any set_info() requests on this object. Does not require a commit() afterwards. + //! If no input_info_writer_v2 is provided, similar affect can be achieved by set_info()+commit() with blank file_info, but may not be as thorough; will typically result in blank tags rather than total removal fo tags. + virtual void remove_tags(abort_callback & abort) = 0; + + FB2K_MAKE_SERVICE_INTERFACE(input_info_writer_v2, input_info_writer); +}; + +class NOVTABLE input_entry : public service_base { + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(input_entry); +public: + //! Determines whether specified content type can be handled by this input. + //! @param p_type Content type string to test. + virtual bool is_our_content_type(const char * p_type)=0; + + //! Determines whether specified file type can be handled by this input. This must not use any kind of file access; the result should be only based on file path / extension. + //! @param p_full_path Full URL of file being tested. + //! @param p_extension Extension of file being tested, provided by caller for performance reasons. + virtual bool is_our_path(const char * p_full_path,const char * p_extension)=0; + + //! Opens specified resource for decoding. + //! @param p_instance Receives new input_decoder instance if successful. + //! @param p_filehint Optional; passes file object to use for the operation; if set to null, the service will handle opening file by itself. Note that not all inputs operate on physical files that can be reached through filesystem API, some of them require this parameter to be set to null (tone and silence generators for an example). + //! @param p_path URL of resource being opened. + //! @param p_abort abort_callback object signaling user aborting the operation. + virtual void open_for_decoding(service_ptr_t & p_instance,service_ptr_t p_filehint,const char * p_path,abort_callback & p_abort) = 0; + + //! Opens specified file for reading info. + //! @param p_instance Receives new input_info_reader instance if successful. + //! @param p_filehint Optional; passes file object to use for the operation; if set to null, the service will handle opening file by itself. Note that not all inputs operate on physical files that can be reached through filesystem API, some of them require this parameter to be set to null (tone and silence generators for an example). + //! @param p_path URL of resource being opened. + //! @param p_abort abort_callback object signaling user aborting the operation. + virtual void open_for_info_read(service_ptr_t & p_instance,service_ptr_t p_filehint,const char * p_path,abort_callback & p_abort) = 0; + + //! Opens specified file for writing info. + //! @param p_instance Receives new input_info_writer instance if successful. + //! @param p_filehint Optional; passes file object to use for the operation; if set to null, the service will handle opening file by itself. Note that not all inputs operate on physical files that can be reached through filesystem API, some of them require this parameter to be set to null (tone and silence generators for an example). + //! @param p_path URL of resource being opened. + //! @param p_abort abort_callback object signaling user aborting the operation. + virtual void open_for_info_write(service_ptr_t & p_instance,service_ptr_t p_filehint,const char * p_path,abort_callback & p_abort) = 0; + + //! Reserved for future use. Do nothing and return until specifications are finalized. + virtual void get_extended_data(service_ptr_t p_filehint,const playable_location & p_location,const GUID & p_guid,mem_block_container & p_out,abort_callback & p_abort) = 0; + + enum { + //! Indicates that this service implements some kind of redirector that opens another input for decoding, used to avoid circular call possibility. + flag_redirect = 1, + //! Indicates that multi-CPU optimizations should not be used. + flag_parallel_reads_slow = 2, + }; + //! See flag_* enums. + virtual unsigned get_flags() = 0; + + inline bool is_redirect() {return (get_flags() & flag_redirect) != 0;} + inline bool are_parallel_reads_slow() {return (get_flags() & flag_parallel_reads_slow) != 0;} + + static bool g_find_service_by_path(service_ptr_t & p_out,const char * p_path); + static bool g_find_service_by_path(service_ptr_t & p_out,const char * p_path, const char * p_ext); + static bool g_find_service_by_content_type(service_ptr_t & p_out,const char * p_content_type); + static void g_open_for_decoding(service_ptr_t & p_instance,service_ptr_t p_filehint,const char * p_path,abort_callback & p_abort,bool p_from_redirect = false); + static void g_open_for_info_read(service_ptr_t & p_instance,service_ptr_t p_filehint,const char * p_path,abort_callback & p_abort,bool p_from_redirect = false); + static void g_open_for_info_write(service_ptr_t & p_instance,service_ptr_t p_filehint,const char * p_path,abort_callback & p_abort,bool p_from_redirect = false); + static void g_open_for_info_write_timeout(service_ptr_t & p_instance,service_ptr_t p_filehint,const char * p_path,abort_callback & p_abort,double p_timeout,bool p_from_redirect = false); + static bool g_is_supported_path(const char * p_path); + typedef std::function input_filter_t; + static bool g_find_inputs_by_content_type(pfc::list_base_t > & p_out, const char * p_content_type, bool p_from_redirect); + static bool g_find_inputs_by_path(pfc::list_base_t > & p_out, const char * p_path, bool p_from_redirect ); + static bool g_find_inputs_by_content_type_ex(pfc::list_base_t > & p_out, const char * p_content_type, input_filter_t filter ); + static bool g_find_inputs_by_path_ex(pfc::list_base_t > & p_out, const char * p_path, input_filter_t filter ); + static service_ptr g_open(const GUID & whatFor, file::ptr hint, const char * path, event_logger::ptr logger, abort_callback & aborter, bool fromRedirect = false); + + void open(service_ptr_t & p_instance,service_ptr_t const & p_filehint,const char * p_path,abort_callback & p_abort) {open_for_decoding(p_instance,p_filehint,p_path,p_abort);} + void open(service_ptr_t & p_instance,service_ptr_t const & p_filehint,const char * p_path,abort_callback & p_abort) {open_for_info_read(p_instance,p_filehint,p_path,p_abort);} + void open(service_ptr_t & p_instance,service_ptr_t const & p_filehint,const char * p_path,abort_callback & p_abort) {open_for_info_write(p_instance,p_filehint,p_path,p_abort);} + service_ptr open(const GUID & whatFor, file::ptr hint, const char * path, event_logger::ptr logger, abort_callback & aborter); + + typedef pfc::list_base_const_t< input_entry::ptr > input_entry_list_t; + + static service_ptr g_open_from_list(input_entry_list_t const & list, const GUID & whatFor, file::ptr hint, const char * path, event_logger::ptr logger, abort_callback & aborter, GUID * outGUID = nullptr); + static bool g_are_parallel_reads_slow( const char * path ); + + static uint32_t g_flags_for_path( const char * pathFor, uint32_t mask = UINT32_MAX ); + static uint32_t g_flags_for_content_type( const char * ct, uint32_t mask = UINT32_MAX ); + + GUID get_guid_(); + const char * get_name_(); + static input_entry::ptr g_find_by_guid( const GUID & ); +}; + +//! \since 1.4 +//! Extended input_entry methods provided by decoders. \n +//! Can be implemented by 1.3-compatible components but will not be called in fb2k versions prior to 1.4. +class input_entry_v2 : public input_entry { + FB2K_MAKE_SERVICE_INTERFACE(input_entry_v2, input_entry); +public: + //! @returns GUID used to identify us among other decoders in the decoder priority table. + virtual GUID get_guid() = 0; + //! @returns Name to present to the user in the decoder priority table. + virtual const char * get_name() = 0; + //! @returns GUID of this decoder's preferences page (optional), null guid if there's no page to present + virtual GUID get_preferences_guid() = 0; + //! @returns true if the decoder should be put at the end of the list when it's first sighted, false otherwise (will be put at the beginning of the list). + virtual bool is_low_merit() = 0; +}; + +//! \since 1.5 +class input_entry_v3 : public input_entry_v2 { + FB2K_MAKE_SERVICE_INTERFACE(input_entry_v3, input_entry_v2); +public: + //! New unified open() function for all supported interfaces. Supports any future interfaces via alternate GUIDs, as well as allows the event logger to be set prior to the open() call. + //! @param whatFor The class GUID of the service we want. \n + //! Currently allowed are: input_decoder::class_guid, input_info_reader::class_guid, input_info_writer::class_guid. \n + //! This method must throw pfc::exception_not_implemented for any GUIDs it does not recognize. + virtual service_ptr open_v3( const GUID & whatFor, file::ptr hint, const char * path, event_logger::ptr logger, abort_callback & aborter ) = 0; + + + void open_for_decoding(service_ptr_t & p_instance, service_ptr_t p_filehint, const char * p_path, abort_callback & p_abort) ; + void open_for_info_read(service_ptr_t & p_instance, service_ptr_t p_filehint, const char * p_path, abort_callback & p_abort); + void open_for_info_write(service_ptr_t & p_instance, service_ptr_t p_filehint, const char * p_path, abort_callback & p_abort); +}; + +#ifdef FOOBAR2000_DESKTOP +//! \since 1.4 +//! Core API to perform input open operations respecting user settings for decoder priority. \n +//! Unavailable prior to 1.4. +class input_manager : public service_base { + FB2K_MAKE_SERVICE_COREAPI(input_manager); +public: + virtual service_ptr open(const GUID & whatFor, file::ptr hint, const char * path, bool fromRedirect, abort_callback & aborter, GUID * outUsedEntry = nullptr) = 0; + + //! input_manager_v2 wrapper. + service_ptr open_v2(const GUID & whatFor, file::ptr hint, const char * path, bool fromRedirect, event_logger::ptr logger, abort_callback & aborter, GUID * outUsedEntry = nullptr); +}; + +//! \since 1.5 +//! Extension of input_manager. \n +//! Extended open_v2() supports album_art_extractor and album_art_editor. It reliably throws pfc::exception_not_implemented() for unsupported GUIDs (old version would bugcheck). \n +//! It also allows event_logger to be specified in advance so open() implementation can already use it. +class input_manager_v2 : public input_manager { + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(input_manager_v2, input_manager) +public: + virtual service_ptr open_v2(const GUID & whatFor, file::ptr hint, const char * path, bool fromRedirect, event_logger::ptr logger, abort_callback & aborter, GUID * outUsedEntry = nullptr) = 0; +}; + +//! \since 1.5 +class input_manager_v3 : public input_manager_v2 { + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(input_manager_v3, input_manager_v2); +public: + //! Retrieves list of enabled inputs, in user-specified order. \n + //! This is rarely needed. If you need this function, consider redesigning your code to call input_manager open methods instead. + virtual void get_enabled_inputs( pfc::list_base_t & out ) = 0; + //! Returns input_entry get_flags() values for this path, as returned by enabled inputs. + virtual uint32_t flags_for_path( const char * pathFor, uint32_t mask = UINT32_MAX ) = 0; + //! Returns input_entry get_flags() values for this content type, as returned by enabled inputs. + virtual uint32_t flags_for_content_type( const char * ct, uint32_t mask = UINT32_MAX ) = 0; + + + enum { + flagFromRedirect = 1 << 0, + flagSuppressFilters = 1 << 1, + }; + + virtual service_ptr open_v3(const GUID & whatFor, file::ptr hint, const char * path, uint32_t flags, event_logger::ptr logger, abort_callback & aborter, GUID * outUsedEntry = nullptr) = 0; +}; + +//! \since 1.4 +//! Core API for determining which audio stream to decode, in a multi-stream enabled input. \n +//! Unavailable prior to 1.4 - decode the default stream if input_stream_selector isn't present. \n +//! In foobar2000 v1.4 and up, this API allows decoders to determine which stream the user opted to decode for a specific file. \n +//! Use input_stream_selector::tryGet() to safely instantiate. +class input_stream_selector : public service_base { + FB2K_MAKE_SERVICE_COREAPI(input_stream_selector); +public: + //! Returns index of stream that should be presented for this file. \n + //! If not set by user, 0xFFFFFFFF will be returned and the default stream should be presented. \n + //! @param guid GUID of the input asking for the stream. + virtual uint32_t select_stream( const GUID & guid, const char * path ) = 0; +}; + +//! \since 2.0 +class input_stream_selector_v2 : public input_stream_selector { + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(input_stream_selector_v2, input_stream_selector); +public: + //! Allows components to present their own user interface to alter stream preference settings. + //! Parameters same as select_stream() and its return value. + virtual void set_user_preference(const GUID& guid, const char* path, uint32_t index) = 0; +}; + +//! \since 1.4 +//! Interface provided by multi-stream enabled inputs to let the stream picker dialog show available streams. \n +//! Can be implemented by 1.3-compatible components but will not be called in fb2k versions prior to 1.4. +class input_stream_info_reader : public service_base { + FB2K_MAKE_SERVICE_INTERFACE(input_stream_info_reader, service_base); +public: + //! @returns Number of audio streams found. + virtual uint32_t get_stream_count() = 0; + //! Retrieves information about the specified stream; most importantly the codec name and bitrate. + virtual void get_stream_info(uint32_t index, file_info & out, abort_callback & aborter) = 0; + //! @returns Index of default stream to decode if there is no user preference. + virtual uint32_t get_default_stream() = 0; +}; + +//! \since 1.4 +//! Entrypoint interface for spawning input_stream_info_reader. \n +//! Can be implemented by 1.3-compatible components but will not be called in fb2k versions prior to 1.4. +class input_stream_info_reader_entry : public service_base { + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(input_stream_info_reader_entry); +public: + //! Open file for reading stream infos. + virtual input_stream_info_reader::ptr open( const char * path, file::ptr fileHint, abort_callback & abort ) = 0; + + //! Return GUID of the matching input_entry. + virtual GUID get_guid() = 0; + +}; + +//! \since 1.4 +//! Callback for input_stream_manipulator \n +//! Used for applying ReplayGain to encoded audio streams. +class input_stream_manipulator_callback : public service_base { + FB2K_MAKE_SERVICE_INTERFACE(input_stream_manipulator_callback, service_base); +public: + //! Called first before other methods. Throw an exception if the file cannot be processed. \n + //! The arguments are the same as packet_decoder open() arguments. + virtual void set_decode_info(const GUID & p_owner, t_size p_param1, const void * p_param2, t_size p_param2size ) = 0; + + virtual void first_frame( const void * data, size_t bytes ) = 0; + //! Called with progress value, in 0..1 range. + virtual void on_progress( float progress ) = 0; + //! @returns true if the frame has been altered and should be written back, false otherwise. + virtual bool process_frame( void * data, size_t size ) = 0; +}; + +//! \since 1.4 +//! Manipulate audio stream payload in files. \n +//! Used for applying ReplayGain to encoded audio streams. +class input_stream_manipulator : public service_base { + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(input_stream_manipulator); +public: + enum op_t { + //! Probe the file for codec information; calls set_decode_info() + first_frame() only. + op_probe = 0, + //! Read the entire stream - same as op_probe but then calls on_progress() + process_frame() with the entire file payload. \n + //! No writing to the file is performed - process_frame() results are disregarded. + op_read, + //! Rewrite the stream. Similar to op_read, but frames altered by process_frame() are written back to the file. + op_rewrite + }; + //! @param path Path of file to process. + //! @param fileHint optional file object, must be opened for read+write if bWalk is true. + //! @param callback Callback object for this operation. + //! @param opType Operation to perform, see op_t enum for details. + //! @param abort abort_callback object for this operating. Aborting with bWalk set to true will leave the file partially altered, use with caution! + virtual void process( const char * path, file::ptr fileHint, input_stream_manipulator_callback::ptr callback, op_t opType, abort_callback & abort ) = 0; + //! Return GUID of the matching input_entry. + virtual GUID get_guid() = 0; +}; + +//! \since 1.5 +//! An input_info_filter lets you hook into all performed tag read & write operations. \n +//! Your tag manipulations will be transparent to all fb2k components, as if the tags were read/written by relevant inputs. \n +//! Your input_info_filter needs to be enabled in Preferences in order to become active. Newly added ones are inactive by default. +class input_info_filter : public service_base { + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT( input_info_filter ); +public: + //! Tags are being read from a file. + virtual void filter_info_read( const playable_location & loc,file_info & info,abort_callback & abort ) = 0; + //! Tags are being written to a file. \n + //! Return true to continue, false to suppress writing of tags. + virtual bool filter_info_write( const playable_location & loc, file_info & info, abort_callback & abort ) = 0; + //! Tags are being removed from a file. + virtual void on_info_remove( const char * path, abort_callback & abort ) = 0; + //! Return GUID of your filter. + virtual GUID get_guid() = 0; + //! Return preferences page or advconfig branch GUID of your filter. + virtual GUID get_preferences_guid() = 0; + //! Return user-friendly name of your filter to be shown in preferences. + virtual const char * get_name() = 0; + //! Optional backwards compatibility method. \n + //! If you also provide input services for old foobar2000 versions which don't recognize input_info_filter, report their GUIDs here so they can be ignored. \n + //! @param outGUIDs empty on entry, contains GUIDs of ignored inputs (if any) on return. + virtual void get_suppressed_inputs( pfc::list_base_t & outGUIDs ) {outGUIDs.remove_all();} + //! write_fallback() supported or not? \n + //! Used if your filter can store tags for untaggable files. + virtual bool supports_fallback() = 0; + //! Optional; called when user attempted to tag an untaggable/readonly file. \n + //! Used if your filter can store tags for untaggable files. + virtual bool write_fallback( const playable_location & loc, file_info const & info, abort_callback & abort ) = 0; + //! Optional; called when user attempted to remove tags from an untaggable/readonly file.\ n + //! Used if your filter can store tags for untaggable files. + virtual void remove_tags_fallback( const char * path, abort_callback & abort ) = 0; +}; + +//! \since 1.5 +class input_stream_info_filter : public service_base { + FB2K_MAKE_SERVICE_INTERFACE( input_stream_info_filter, service_base ); +public: + virtual void filter_dynamic_info( file_info & info ) = 0; + virtual void filter_dynamic_info_track( file_info & info ) = 0; +}; + +//! \since 1.5 +//! Extended input_info_filter. +class input_info_filter_v2 : public input_info_filter { + FB2K_MAKE_SERVICE_INTERFACE( input_info_filter_v2, input_info_filter ); +public: + //! Creates an object which then can work with dynamic track titles etc of a decoded track. \n + //! Returning null to filter the info is allowed. + virtual input_stream_info_filter::ptr open_stream(playable_location const & loc, abort_callback & abort) = 0; + + + typedef service_ptr_t aaptr_t; + + //! Album art is being read from the file. \n + //! info may be null if file had no such picture. \n + //! Return passed info, altered info or null. + virtual aaptr_t filter_album_art_read( const char * path, const GUID & type, aaptr_t info, abort_callback & aborter ) = 0; + //! Album art is being written to the file. \n + //! Return passed info, altered info or null to suppress writing. + virtual aaptr_t filter_album_art_write( const char * path, const GUID & type, aaptr_t info, abort_callback & aborter ) = 0; + //! Specific album art is being removed from the file. \n + //! Return true to go on, false to suppress file update. + virtual bool filter_album_art_remove( const char * path, const GUID & type, abort_callback & aborter ) = 0; + //! All album art is being removed from the file. \n + //! Return true to go on, false to suppress file update. + virtual bool filter_album_art_remove_all( const char * path, abort_callback & aborter ) = 0; + + //! Valid with supports_fallback() = true \n + //! Album art is being written to an untaggable file. + virtual void write_album_art_fallback( const char * path, const GUID & type, aaptr_t info, abort_callback & aborter ) = 0; + //! Valid with supports_fallback() = true \n + //! Specific album art is being removed from an untaggable file. + virtual void remove_album_art_fallback( const char * path, const GUID & type, abort_callback & aborter ) = 0; + //! Valid with supports_fallback() = true \n + //! All album art is being removed from an untaggable file. + virtual void remove_all_album_art_fallback( const char * path, abort_callback & aborter ) = 0; +}; + +class dsp_preset; + +//! \since 1.5 +//! An input_playback_shim adds additional functionality to a DSP, allowing full control of the decoder. \n +//! Currently, input_playback_shim can only exist alongside a DSP, must have the same GUID as a DSP. \n +//! It will only be used in supported scenarios when the user has put your DSP in the chain. \n +//! Your DSP will be deactivated in such case when your input_playback_shim is active. \n +//! input_playback_shim is specifically intended to be instantiated for playback. Do not call this service from your component. \n/ +//! Implement this service ONLY IF NECESSARY. Very few tasks really need it, primarily DSPs that manipulate logical playback time & seeking. +class input_playback_shim : public service_base { + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT( input_playback_shim ); +public: + //! Same GUID as your DSP. + virtual GUID get_guid() = 0; + //! Preferences page / advconfig branch GUID of your shim, pfc::guid_null if none. \n + //! This is currently unused / reserved for future use. + virtual GUID get_preferences_guid() = 0; + //! Same as your DSP. \n + //! This is currently unused / reserved for future use. + virtual const char * get_name() = 0; + //! Instantiates your shim on top of existing input_decoder. \n + //! If you don't want to do anything with this specific decoder, just return the passed decoder. + virtual input_decoder::ptr shim( input_decoder::ptr dec, const char * path, dsp_preset const & preset, abort_callback & aborter ) = 0; + //! Optional backwards compatibility method. \n + //! If you also provide input services for old versions of foobar2000 which don't recognize input_playback_shim, report their GUIDs here so they can be ignored. \n + //! @param outGUIDs empty on entry, contains GUIDs of ignored inputs (if any) on return. + virtual void get_suppressed_inputs( pfc::list_base_t & outGUIDs ) {outGUIDs.remove_all();} +}; + +#endif // #ifdef FOOBAR2000_DESKTOP + + +typedef input_info_writer_v2 input_info_writer_vhighest; +typedef input_decoder_v4 input_decoder_vhighest; +typedef input_info_reader_v2 input_info_reader_vhighest; + +typedef input_info_writer input_info_writer_vrequired; +typedef input_decoder input_decoder_vrequired; +typedef input_info_reader_v2 input_info_reader_vrequired; + +//! \since 2.0 +class input_entry_v4 : public input_entry_v3 { + FB2K_MAKE_SERVICE_INTERFACE(input_entry_v4, input_entry_v3) +public: + //! Fallback method for detecting renamed files. \n + //! This gets called after normal means of opening this file failed. + virtual bool fallback_is_our_payload(const void* bytes, size_t bytesAvail, t_filesize bytesWhole) = 0; +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/input_file_type.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/input_file_type.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,149 @@ +#include "foobar2000-sdk-pch.h" +#include "input_file_type.h" +#include "componentversion.h" +#include "archive.h" +#include "playlist_loader.h" + +#if FOOBAR2000_TARGET_VERSION >= 76 + +typedef pfc::avltree_t t_fnList; + +static void formatMaskList(pfc::string_base & out, t_fnList const & in) { + auto walk = in.cfirst(); + if (walk.is_valid()) { + out << *walk; ++walk; + while(walk.is_valid()) { + out << ";" << *walk; ++walk; + } + } +} +static void formatMaskList(pfc::string_base & out, t_fnList const & in, const char * label) { + if (in.get_count() > 0) { + out << label << "|"; + formatMaskList(out,in); + out << "|"; + } +} + +void input_file_type::for_each_media_ext( std::function fn, bool bDotExt) { + for( auto p : input_file_type::enumerate()) { + const unsigned cnt = p->get_count(); + for (unsigned w = 0; w < cnt; ++w) { + pfc::string8 maskCombined; + p->get_mask(w, maskCombined); + + pfc::chain_list_v2_t masks; + pfc::splitStringByChar(masks, maskCombined, ';'); + for( auto i : masks ) { + const char * m = i.get_ptr(); + if (pfc::strcmp_partial(m, "*.") == 0) { + const char * ext = m + 1; // .ext + if (!bDotExt) ++ext; + fn(ext); + } + } + } + } +} +void input_file_type::make_filetype_support_fingerprint(pfc::string_base & str) { + pfc::string_formatter out; + pfc::avltree_t names; + + { + componentversion::ptr ptr; service_enum_t e; + pfc::string_formatter name; + while(e.next(ptr)) { + name = ""; + ptr->get_component_name(name); + if (strstr(name, "decoder") != NULL || strstr(name, "Decoder") != NULL) names += name; + } + } + + + make_extension_support_fingerprint(out); + for(auto walk = names.cfirst(); walk.is_valid(); ++walk) { + if (!out.is_empty()) str << "|"; + out << *walk; + } + str = out; +} +void input_file_type::make_extension_support_fingerprint(pfc::string_base & str) { + pfc::avltree_t masks; + { + pfc::string_formatter mask; + for( auto ptr : enumerate() ) { + const unsigned count = ptr->get_count(); + for(unsigned n=0;nget_mask(n,mask)) { + if (strchr(mask,'|') == NULL) masks += mask; + } + } + } + } + pfc::string_formatter out; + for(auto walk = masks.cfirst(); walk.is_valid(); ++walk) { + if (!out.is_empty()) out << "|"; + out << *walk; + } + str = out; +} + +void input_file_type::build_openfile_mask(pfc::string_base & out, bool b_include_playlists, bool b_include_archives) +{ + t_fnList extensionsAll, extensionsPl, extensionsArc; + + if (b_include_playlists) { + for( auto ptr : playlist_loader::enumerate()) { + if (ptr->is_associatable()) { + pfc::string_formatter temp; temp << "*." << ptr->get_extension(); + extensionsPl += temp; + extensionsAll += temp; + } + } + } + if (b_include_archives) { + service_enum_t e; + archive_v3::ptr p; + pfc::string_formatter temp; + while (e.next(p)) { + p->list_extensions(temp); + pfc::chain_list_v2_t lst; + pfc::splitStringByChar(lst, temp, ','); + for (auto iter = lst.first(); iter.is_valid(); ++iter) { + extensionsArc += pfc::format( "*.", *iter ); + } + } + } + + typedef pfc::map_t t_masks; + t_masks masks; + { + pfc::string_formatter name, mask; + for( auto ptr : enumerate() ) { + const unsigned count = ptr->get_count(); + for(unsigned n=0;nget_name(n,name) && ptr->get_mask(n,mask)) { + if (!strchr(name,'|') && !strchr(mask,'|')) { + masks.find_or_add(name) += mask; + extensionsAll += mask; + } + } + } + } + } + pfc::string_formatter outBuf; + outBuf << "All files|*.*|"; + formatMaskList(outBuf, extensionsAll, "All supported media types"); + formatMaskList(outBuf, extensionsPl, "Playlists"); + formatMaskList(outBuf, extensionsArc, "Archives"); + + + for(auto walk = masks.cfirst(); walk.is_valid(); ++walk) { + formatMaskList(outBuf,walk->m_value,walk->m_key); + } + out = outBuf; +} +#endif \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/input_file_type.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/input_file_type.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,110 @@ +#pragma once +#include + +//! Entrypoint interface for registering media file types that can be opened through "open file" dialogs or associated with foobar2000 application in Windows shell. \n +//! Instead of implementing this directly, use DECLARE_FILE_TYPE() / DECLARE_FILE_TYPE_EX() macros. +class input_file_type : public service_base { +public: + virtual unsigned get_count()=0; + virtual bool get_name(unsigned idx,pfc::string_base & out)=0;//eg. "MPEG files" + virtual bool get_mask(unsigned idx,pfc::string_base & out)=0;//eg. "*.MP3;*.MP2"; separate with semicolons + virtual bool is_associatable(unsigned idx) = 0; + + static void for_each_media_ext( std::function, bool bDotExt = false); + +#if FOOBAR2000_TARGET_VERSION >= 76 + static void build_openfile_mask(pfc::string_base & out,bool b_include_playlists=true, bool b_include_archives = false); + static void make_extension_support_fingerprint(pfc::string_base & str); + static void make_filetype_support_fingerprint(pfc::string_base & str); +#endif + + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(input_file_type); +}; + +//! Extended interface for registering media file types that can be associated with foobar2000 application in Windows shell. \n +//! Instead of implementing this directly, use DECLARE_FILE_TYPE() / DECLARE_FILE_TYPE_EX() macros. +class input_file_type_v2 : public input_file_type { +public: + virtual void get_format_name(unsigned idx, pfc::string_base & out, bool isPlural) = 0; + virtual void get_extensions(unsigned idx, pfc::string_base & out) = 0; + + //Deprecated input_file_type method implementations: + bool get_name(unsigned idx, pfc::string_base & out) {get_format_name(idx, out, true); return true;} + bool get_mask(unsigned idx, pfc::string_base & out) { + pfc::string_formatter temp; get_extensions(idx,temp); + pfc::chain_list_v2_t exts; pfc::splitStringSimple_toList(exts,";",temp); + if (exts.get_count() == 0) return false;//should not happen + temp.reset(); + for(auto walk = exts.cfirst(); walk.is_valid(); ++walk) { + if (!temp.is_empty()) temp << ";"; + temp << "*." << walk->get_ptr(); + } + out = temp; + return true; + } + + FB2K_MAKE_SERVICE_INTERFACE(input_file_type_v2,input_file_type) +}; + + +//! Implementation helper. +class input_file_type_impl : public input_file_type +{ + const char * name, * mask; + bool m_associatable; +public: + input_file_type_impl(const char * p_name, const char * p_mask,bool p_associatable) : name(p_name), mask(p_mask), m_associatable(p_associatable) {} + unsigned get_count() override {return 1;} + bool get_name(unsigned idx,pfc::string_base & out) override {if (idx==0) {out = name; return true;} else return false;} + bool get_mask(unsigned idx,pfc::string_base & out) override {if (idx==0) {out = mask; return true;} else return false;} + bool is_associatable(unsigned idx) override { (void)idx; return m_associatable; } +}; + + +//! Helper macro for registering our media file types. +//! Usage: DECLARE_FILE_TYPE("Blah files","*.blah;*.bleh"); +#define DECLARE_FILE_TYPE(NAME,MASK) FB2K_SERVICE_FACTORY_PARAMS(input_file_type_impl, NAME, MASK, true) + + +//! Implementation helper. +//! Usage: static input_file_type_factory mytype("blah type","*.bla;*.meh",true); +class input_file_type_factory : private service_factory_single_transparent_t +{ +public: + input_file_type_factory(const char * p_name,const char * p_mask,bool p_associatable) + : service_factory_single_transparent_t(p_name,p_mask,p_associatable) {} +}; + + + +class input_file_type_v2_impl : public input_file_type_v2 { +public: + input_file_type_v2_impl(const char * extensions,const char * name, const char * namePlural) : m_name(name), m_namePlural(namePlural), m_extensions(extensions) {} + unsigned get_count() override {return 1;} + bool is_associatable(unsigned idx) override { (void)idx; return true; } + void get_format_name(unsigned idx, pfc::string_base & out, bool isPlural) override { + (void)idx; + out = isPlural ? m_namePlural : m_name; + } + void get_extensions(unsigned idx, pfc::string_base & out) override { + (void)idx; + out = m_extensions; + } + +private: + const pfc::string8 m_name, m_namePlural, m_extensions; +}; + +//! Helper macro for registering our media file types, extended version providing separate singular/plural type names. +//! Usage: DECLARE_FILE_TYPE_EX("mp1;mp2;mp3","MPEG file","MPEG files") +#define DECLARE_FILE_TYPE_EX(extensions, name, namePlural) FB2K_SERVICE_FACTORY_PARAMS(input_file_type_v2_impl, extensions, name, namePlural) + +//! Service for registering protocol types that can be associated with foobar2000. +class input_protocol_type : public service_base { + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(input_protocol_type) +public: + //! Returns the name of the protocol, such as "ftp" or "http". + virtual void get_protocol_name(pfc::string_base & out) = 0; + //! Returns a human-readable description of the protocol. + virtual void get_description(pfc::string_base & out) = 0; +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/input_impl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/input_impl.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,511 @@ +#pragma once + +#include "input.h" +#include "mem_block_container.h" + +enum t_input_open_reason { + input_open_info_read, + input_open_decode, + input_open_info_write +}; + +//! Helper function for input implementation use; ensures that file is open with relevant access mode. This is typically called from input_impl::open() and such. +//! @param p_file File object pointer to process. If passed pointer is non-null, the function does nothing and always succeeds; otherwise it attempts to open the file using filesystem API methods. +//! @param p_path Path to the file. +//! @param p_reason Type of input operation requested. See: input_impl::open() parameters. +//! @param p_abort abort_callback object signaling user aborting the operation. +void input_open_file_helper(service_ptr_t & p_file,const char * p_path,t_input_open_reason p_reason,abort_callback & p_abort); + + +//! This is a class that just declares prototypes of functions that each input needs to implement. See input_decoder / input_info_reader / input_info_writer interfaces for full descriptions of member functions. Since input implementation class is instantiated using a template, you don't need to derive from input_impl as virtual functions are not used on implementation class level. Use input_factory_t template to register input class based on input_impl. +class input_impl +{ +public: + //! Opens specified file for info read / decoding / info write. This is called only once, immediately after object creation, before any other methods, and no other methods are called if open() fails. + //! @param p_filehint Optional; passes file object to use for the operation; if set to null, the implementation should handle opening file by itself. Note that not all inputs operate on physical files that can be reached through filesystem API, some of them require this parameter to be set to null (tone and silence generators for an example). Typically, an input implementation that requires file access calls input_open_file_helper() function to ensure that file is open with relevant access mode (read or read/write). + //! @param p_path URL of resource being opened. + //! @param p_reason Type of operation requested. Possible values are: \n + //! - input_open_info_read - info retrieval methods are valid; \n + //! - input_open_decode - info retrieval and decoding methods are valid; \n + //! - input_open_info_write - info retrieval and retagging methods are valid; \n + //! Note that info retrieval methods are valid in all cases, and they may be called at any point of decoding/retagging process. Results of info retrieval methods (other than get_subsong_count() / get_subsong()) between retag_set_info() and retag_commit() are undefined however; those should not be called during that period. \n + //! If your implementation does not support writing tags, throw exception_tagging_unsupported in response to input_open_info_write and do not implement other tag writing methods (they will not be called). + //! @param p_abort abort_callback object signaling user aborting the operation. + void open(service_ptr_t p_filehint,const char * p_path,t_input_open_reason p_reason,abort_callback & p_abort); + + //! See: input_info_reader::get_subsong_count(). Valid after open() with any reason. + unsigned get_subsong_count(); + //! See: input_info_reader::get_subsong(). Valid after open() with any reason. + t_uint32 get_subsong(unsigned p_index); + //! See: input_info_reader::get_info(). Valid after open() with any reason. + void get_info(t_uint32 p_subsong,file_info & p_info,abort_callback & p_abort); + //! See: input_info_reader_v2::get_stats2(). Valid after open() with any reason. + t_filestats2 get_stats2(uint32_t, abort_callback & p_abort); + + //! See: input_decoder::initialize(). Valid after open() with input_open_decode reason. + void decode_initialize(t_uint32 p_subsong,unsigned p_flags,abort_callback & p_abort); + //! See: input_decoder::run(). Valid after decode_initialize(). + bool decode_run(audio_chunk & p_chunk,abort_callback & p_abort); + //! See: input_decoder::seek(). Valid after decode_initialize(). + void decode_seek(double p_seconds,abort_callback & p_abort); + //! See: input_decoder::can_seek(). Valid after decode_initialize(). + bool decode_can_seek(); + //! See: input_decoder::get_dynamic_info(). Valid after decode_initialize(). + bool decode_get_dynamic_info(file_info & p_out, double & p_timestamp_delta); + //! See: input_decoder::get_dynamic_info_track(). Valid after decode_initialize(). + bool decode_get_dynamic_info_track(file_info & p_out, double & p_timestamp_delta); + //! Obsolete, do not use, do not rely on. + void decode_on_idle(abort_callback & p_abort); + + //! See: input_info_writer::set_info(). Valid after open() with input_open_info_write reason. \n + //! If your implementation does not support writing tags, throw exception_tagging_unsupported from open() and retag_* methods will never be called. + void retag_set_info(t_uint32 p_subsong,const file_info & p_info,abort_callback & p_abort); + //! See: input_info_writer::commit(). Valid after open() with input_open_info_write reason. \n + //! If your implementation does not support writing tags, throw exception_tagging_unsupported from open() and retag_* methods will never be called. + void retag_commit(abort_callback & p_abort); + + //! See: input_info_writer_v2::remove_tags(). Valid after open() with input_open_info_write reason. \n + //! If possible, entirely remove tags from the file (truncate ID3/APE tags away etc); otherwise set blank metadata. \n + //! If your implementation does not support writing tags, throw exception_tagging_unsupported from open() and remove_tags() will never be called. + void remove_tags(abort_callback & p_abort); + + //! See: input_entry::is_our_content_type(). + static bool g_is_our_content_type(const char * p_content_type); + //! See: input_entry::is_our_path(). + static bool g_is_our_path(const char * p_path,const char * p_extension); + + //! See: input_entry::get_guid(). + static GUID g_get_guid(); + //! See: input_entry::get_name(). + static const char * g_get_name(); + //! See: input_entry::get_preferences_guid(). + static GUID g_get_preferences_guid(); + //! See: input_entry::is_low_merit(). + static bool g_is_low_merit(); + + //! See: input_decoder_v2::run_raw(). Relevant only when implementing input_decoder_v2. Valid after decode_initialize(). + bool decode_run_raw(audio_chunk & p_chunk, mem_block_container & p_raw, abort_callback & p_abort); + + //! OLD way: may be called at any time from input_decoder_v2 \n + //! NEW way (1.5): called prior to open(). + void set_logger(event_logger::ptr ptr); +protected: + input_impl() {} + ~input_impl() {} +}; + +//! A base class that provides stub implementations of all optional input methods. \n +//! Inherit from this and you implement input_decoder_v4 without having to provide all the methods you don't actually need. +class input_stubs { +public: + bool decode_run_raw(audio_chunk& p_chunk, mem_block_container& p_raw, abort_callback& p_abort) { (void)p_chunk; (void)p_raw; (void)p_abort; throw pfc::exception_not_implemented(); } + void set_logger(event_logger::ptr ptr) { (void)ptr; } + void set_pause(bool paused) { (void)paused; } + bool flush_on_pause() { return false; } + size_t extended_param(const GUID& type, size_t arg1, void* arg2, size_t arg2size) { (void)type, (void)arg1; (void)arg2; (void)arg2size; return 0; } + static GUID g_get_preferences_guid() {return pfc::guid_null;} + static bool g_is_low_merit() { return false; } + static bool g_fallback_is_our_payload(const void* bytes, size_t bytesAvail, t_filesize bytesWhole) { (void)bytes; (void)bytesAvail; (void)bytes; (void)bytesWhole; return false; } + + bool decode_get_dynamic_info(file_info& p_out, double& p_timestamp_delta) { (void)p_out; (void)p_timestamp_delta; return false; } + bool decode_get_dynamic_info_track(file_info& p_out, double& p_timestamp_delta) { (void)p_out; (void)p_timestamp_delta; return false; } + void decode_on_idle(abort_callback& p_abort) { (void)p_abort; } + + + //! These typedefs indicate which interfaces your class actually supports. You can override them to support non default input API interfaces without specifying input_factory parameters. + typedef input_decoder_v4 interface_decoder_t; + typedef input_info_reader_v2 interface_info_reader_t; + typedef input_info_writer_v2 interface_info_writer_t; +}; + +//! This is a class that just declares prototypes of functions that each non-multitrack-enabled input needs to implement. See input_decoder / input_info_reader / input_info_writer interfaces for full descriptions of member functions. Since input implementation class is instantiated using a template, you don't need to derive from input_singletrack_impl as virtual functions are not used on implementation class level. Use input_singletrack_factory_t template to register input class based on input_singletrack_impl. +class input_singletrack_impl +{ +public: + //! Opens specified file for info read / decoding / info write. This is called only once, immediately after object creation, before any other methods, and no other methods are called if open() fails. + //! @param p_filehint Optional; passes file object to use for the operation; if set to null, the implementation should handle opening file by itself. Note that not all inputs operate on physical files that can be reached through filesystem API, some of them require this parameter to be set to null (tone and silence generators for an example). Typically, an input implementation that requires file access calls input_open_file_helper() function to ensure that file is open with relevant access mode (read or read/write). + //! @param p_path URL of resource being opened. + //! @param p_reason Type of operation requested. Possible values are: \n + //! - input_open_info_read - info retrieval methods are valid; \n + //! - input_open_decode - info retrieval and decoding methods are valid; \n + //! - input_open_info_write - info retrieval and retagging methods are valid; \n + //! Note that info retrieval methods are valid in all cases, and they may be called at any point of decoding/retagging process. Results of info retrieval methods (other than get_subsong_count() / get_subsong()) between retag_set_info() and retag_commit() are undefined however; those should not be called during that period. \n + //! If your implementation does not support writing tags, throw exception_tagging_unsupported in response to input_open_info_write and do not implement other tag writing methods (they will not be called). + //! @param p_abort abort_callback object signaling user aborting the operation. + void open(service_ptr_t p_filehint,const char * p_path,t_input_open_reason p_reason,abort_callback & p_abort); + + //! See: input_info_reader::get_info(). Valid after open() with any reason. \n + //! Implementation warning: this is typically also called immediately after tag update and should return newly written content then. + void get_info(file_info & p_info,abort_callback & p_abort); + //! See: input_info_reader_v2::get_stats2(). Valid after open() with any reason. \n + //! Implementation warning: this is typically also called immediately after tag update and should return new values then. + t_filestats2 get_stats2(uint32_t, abort_callback&); + + //! See: input_decoder::initialize(). Valid after open() with input_open_decode reason. + void decode_initialize(unsigned p_flags,abort_callback & p_abort); + //! See: input_decoder::run(). Valid after decode_initialize(). + bool decode_run(audio_chunk & p_chunk,abort_callback & p_abort); + //! See: input_decoder::seek(). Valid after decode_initialize(). + void decode_seek(double p_seconds,abort_callback & p_abort); + //! See: input_decoder::can_seek(). Valid after decode_initialize(). + bool decode_can_seek(); + //! See: input_decoder::get_dynamic_info(). Valid after decode_initialize(). + bool decode_get_dynamic_info(file_info & p_out, double & p_timestamp_delta); + //! See: input_decoder::get_dynamic_info_track(). Valid after decode_initialize(). + bool decode_get_dynamic_info_track(file_info & p_out, double & p_timestamp_delta); + //! Obsolete, do not use, do not rely on. + void decode_on_idle(abort_callback & p_abort); + + //! See: input_info_writer::set_info(). Note that input_info_writer::commit() call isn't forwarded because it's useless in case of non-multitrack-enabled inputs. Valid after open() with input_open_info_write reason. \n + //! If your implementation does not support writing tags, throw exception_tagging_unsupported from open() and retag() will never be called. + void retag(const file_info & p_info,abort_callback & p_abort); + + //! See: input_info_writer_v2::remove_tags(). Valid after open() with input_open_info_write reason. \n + //! If possible, entirely remove tags from the file (truncate ID3/APE tags away etc); otherwise set blank metadata. \n + //! If your implementation does not support writing tags, throw exception_tagging_unsupported from open() and remove_tags() will never be called. + void remove_tags(abort_callback & p_abort); + + //! See: input_entry::is_our_content_type(). + static bool g_is_our_content_type(const char * p_content_type); + //! See: input_entry::is_our_path(). + static bool g_is_our_path(const char * p_path,const char * p_extension); + +protected: + input_singletrack_impl() {} + ~input_singletrack_impl() {} +}; + + +//! Used internally by standard input_entry implementation; do not use directly. Translates input_decoder / input_info_reader / input_info_writer calls to input_impl calls. +template +class input_impl_interface_wrapper_t : public interface_t +{ +public: + template + void open( args_t && ... args) { + m_instance.open(std::forward(args) ... ); + } + + // input_info_reader methods + + t_uint32 get_subsong_count() { + return m_instance.get_subsong_count(); + } + + t_uint32 get_subsong(t_uint32 p_index) { + return m_instance.get_subsong(p_index); + } + + + void get_info(t_uint32 p_subsong,file_info & p_info,abort_callback & p_abort) { + m_instance.get_info(p_subsong,p_info,p_abort); + } + + t_filestats get_file_stats(abort_callback& p_abort) { + return get_stats2(stats2_legacy, p_abort).to_legacy(); + } + t_filestats2 get_stats2(uint32_t f, abort_callback& a) { + return m_instance.get_stats2(f, a); + } + + // input_decoder methods + + void initialize(t_uint32 p_subsong,unsigned p_flags,abort_callback & p_abort) { + m_instance.decode_initialize(p_subsong,p_flags,p_abort); +#if PFC_DEBUG + m_eof = false; + m_decoding = true; +#endif + } + + bool run(audio_chunk & p_chunk,abort_callback & p_abort) { +#if PFC_DEBUG + PFC_ASSERT( !m_eof ); + PFC_ASSERT(m_decoding); + // Complain if run()/run_raw() gets called again after having returned EOF, this means a logic error on caller's side +#endif + bool ret = m_instance.decode_run(p_chunk,p_abort); +#if PFC_DEBUG + if ( !ret ) m_eof = true; +#endif + return ret; + } + + bool run_raw(audio_chunk & p_chunk, mem_block_container & p_raw, abort_callback & p_abort) { +#if PFC_DEBUG + // Complain if run()/run_raw() gets called again after having returned EOF, this means a logic error on caller's side + PFC_ASSERT(!m_eof); + PFC_ASSERT(m_decoding); +#endif + bool ret = m_instance.decode_run_raw(p_chunk, p_raw, p_abort); +#if PFC_DEBUG + if ( !ret ) m_eof = true; +#endif + return ret; + } + + void seek(double p_seconds,abort_callback & p_abort) { +#if PFC_DEBUG + PFC_ASSERT(m_decoding); +#endif + m_instance.decode_seek(p_seconds,p_abort); +#if PFC_DEBUG + m_eof = false; +#endif + } + + bool can_seek() { + return m_instance.decode_can_seek(); + } + + bool get_dynamic_info(file_info & p_out, double & p_timestamp_delta) { + return m_instance.decode_get_dynamic_info(p_out,p_timestamp_delta); + } + + bool get_dynamic_info_track(file_info & p_out, double & p_timestamp_delta) { + return m_instance.decode_get_dynamic_info_track(p_out,p_timestamp_delta); + } + + void on_idle(abort_callback & p_abort) { + m_instance.decode_on_idle(p_abort); + } + + void set_logger(event_logger::ptr ptr) { + m_instance.set_logger(ptr); + } + + void set_pause(bool paused) { + // obsolete + // m_instance.set_pause(paused); + } + + bool flush_on_pause() { + return m_instance.flush_on_pause(); + } + + size_t extended_param(const GUID & type, size_t arg1, void * arg2, size_t arg2size) { + return m_instance.extended_param(type, arg1, arg2, arg2size); + } + + // input_info_writer methods + + void set_info(t_uint32 p_subsong,const file_info & p_info,abort_callback & p_abort) { + m_instance.retag_set_info(p_subsong,p_info,p_abort); + } + + void commit(abort_callback & p_abort) { + m_instance.retag_commit(p_abort); + } + void remove_tags(abort_callback & p_abort) { + m_instance.remove_tags(p_abort); + } + +private: + I m_instance; + +#if PFC_DEBUG + // Report illegal API calls in debug build + bool m_eof = false; + bool m_decoding = false; +#endif +}; + +template +class input_forward_static_methods : public input_stubs { +public: + static bool g_is_our_content_type(const char * p_content_type) { return input_t::g_is_our_content_type(p_content_type); } + static bool g_is_our_path(const char * p_path, const char * p_extension) { return input_t::g_is_our_path(p_path, p_extension); } + static GUID g_get_preferences_guid() { return input_t::g_get_preferences_guid(); } + static GUID g_get_guid() { return input_t::g_get_guid(); } + static const char * g_get_name() { return input_t::g_get_name(); } + static bool g_is_low_merit() { return input_t::g_is_low_merit(); } + static bool g_fallback_is_our_payload(const void* bytes, size_t bytesAvail, t_filesize bytesWhole) { return input_t::g_fallback_is_our_payload(bytes, bytesAvail, bytesWhole); } + + typedef typename input_t::interface_decoder_t interface_decoder_t; + typedef typename input_t::interface_info_reader_t interface_info_reader_t; + typedef typename input_t::interface_info_writer_t interface_info_writer_t; + +}; + +//! Helper used by input_singletrack_factory_t, do not use directly. Translates input_impl calls to input_singletrack_impl calls. +template +class input_wrapper_singletrack_t : public input_forward_static_methods +{ +public: + input_wrapper_singletrack_t() {} + + template + void open( args_t && ... args) { + m_instance.open(std::forward(args) ... ); + } + + void get_info(t_uint32 p_subsong,file_info & p_info,abort_callback & p_abort) { + if (p_subsong != 0) throw exception_io_bad_subsong_index(); + m_instance.get_info(p_info,p_abort); + } + + t_uint32 get_subsong_count() { + return 1; + } + + t_uint32 get_subsong(t_uint32 p_index) { + PFC_ASSERT(p_index == 0); + return 0; + } + + t_filestats get_file_stats(abort_callback& p_abort) { + return get_stats2(stats2_legacy, p_abort).to_legacy(); + } + t_filestats2 get_stats2(uint32_t f, abort_callback& a) { + return m_instance.get_stats2(f, a); + } + + void decode_initialize(t_uint32 p_subsong,unsigned p_flags,abort_callback & p_abort) { + if (p_subsong != 0) throw exception_io_bad_subsong_index(); + m_instance.decode_initialize(p_flags,p_abort); +#if PFC_DEBUG + m_decoding = true; m_eof = false; +#endif + } + + bool decode_run(audio_chunk & p_chunk,abort_callback & p_abort) { +#if PFC_DEBUG + PFC_ASSERT(!m_eof); + PFC_ASSERT(m_decoding); +#endif + bool rv = m_instance.decode_run(p_chunk,p_abort); +#if PFC_DEBUG + if (!rv) m_eof = true; +#endif + return rv; + } + void decode_seek(double p_seconds,abort_callback & p_abort) { +#if PFC_DEBUG + PFC_ASSERT(m_decoding); +#endif + m_instance.decode_seek(p_seconds,p_abort); +#if PFC_DEBUG + m_eof = false; +#endif + } + bool decode_can_seek() {return m_instance.decode_can_seek();} + bool decode_get_dynamic_info(file_info & p_out, double & p_timestamp_delta) {return m_instance.decode_get_dynamic_info(p_out,p_timestamp_delta);} + bool decode_get_dynamic_info_track(file_info & p_out, double & p_timestamp_delta) {return m_instance.decode_get_dynamic_info_track(p_out,p_timestamp_delta);} + void decode_on_idle(abort_callback & p_abort) {m_instance.decode_on_idle(p_abort);} + + void retag_set_info(t_uint32 p_subsong,const file_info & p_info,abort_callback & p_abort) { + if (p_subsong != 0) throw exception_io_bad_subsong_index(); + m_instance.retag(p_info,p_abort); + } + + bool decode_run_raw(audio_chunk & p_chunk, mem_block_container & p_raw, abort_callback & p_abort) { +#if PFC_DEBUG + PFC_ASSERT(!m_eof); + PFC_ASSERT(m_decoding); +#endif + bool rv = m_instance.decode_run_raw(p_chunk, p_raw, p_abort); +#if PFC_DEBUG + if (!rv) m_eof = true; +#endif + return rv; + } + + void set_logger(event_logger::ptr ptr) {m_instance.set_logger(ptr);} + + void set_pause(bool paused) { + // m_instance.set_pause(paused); + } + bool flush_on_pause() { + return m_instance.flush_on_pause(); + } + size_t extended_param(const GUID & type, size_t arg1, void * arg2, size_t arg2size) { + return m_instance.extended_param(type, arg1, arg2, arg2size); + } + void retag_commit(abort_callback & p_abort) {} + + void remove_tags(abort_callback & p_abort) { + m_instance.remove_tags(p_abort); + } +private: + I m_instance; + +#if PFC_DEBUG + // Report illegal API calls in debug build + bool m_eof = false; + bool m_decoding = false; +#endif +}; + +//! Helper; standard input_entry implementation. Do not instantiate this directly, use input_factory_t or one of other input_*_factory_t helpers instead. +template +class input_entry_impl_t : public input_entry_v4 +{ +public: + bool is_our_content_type(const char * p_type) override {return I::g_is_our_content_type(p_type);} + bool is_our_path(const char * p_full_path,const char * p_extension) override {return I::g_is_our_path(p_full_path,p_extension);} + + template + void open_ex(service_ptr_t & p_instance,args_t && ... args) + { + auto temp = fb2k::service_new >(); + temp->open(std::forward(args) ... ); + p_instance = temp.get_ptr(); + } + + service_ptr open_v3(const GUID & whatFor, file::ptr hint, const char * path, event_logger::ptr logger, abort_callback & aborter) override { + if ( whatFor == input_decoder::class_guid ) { + auto obj = fb2k::service_new< input_impl_interface_wrapper_t > > (); + if ( logger.is_valid() ) obj->set_logger(logger); + obj->open( hint, path, input_open_decode, aborter ); + input_decoder_vrequired* p = obj.get_ptr(); + return p; + } + if ( whatFor == input_info_reader::class_guid ) { + auto obj = fb2k::service_new < input_impl_interface_wrapper_t >(); + if (logger.is_valid()) obj->set_logger(logger); + obj->open(hint, path, input_open_info_read, aborter); + input_info_reader_vrequired* p = obj.get_ptr(); + return p; + } + if ( whatFor == input_info_writer::class_guid ) { + auto obj = fb2k::service_new < input_impl_interface_wrapper_t > >(); + if (logger.is_valid()) obj->set_logger(logger); + obj->open(hint, path, input_open_info_write, aborter); + input_info_writer_vrequired* p = obj.get_ptr(); + return p; + } + throw pfc::exception_not_implemented(); + } + + void get_extended_data(service_ptr_t p_filehint,const playable_location & p_location,const GUID & p_guid,mem_block_container & p_out,abort_callback & p_abort) override { + p_out.reset(); + } + + unsigned get_flags() override {return t_flags;} + + GUID get_guid() override { + return I::g_get_guid(); + } + const char * get_name() override { + return I::g_get_name(); + } + + GUID get_preferences_guid() override { + return I::g_get_preferences_guid(); + } + bool is_low_merit() override { + return I::g_is_low_merit(); + } + bool fallback_is_our_payload(const void* bytes, size_t bytesAvail, t_filesize bytesWhole) override { + return I::g_fallback_is_our_payload(bytes, bytesAvail, bytesWhole); + } +}; + + +//! Stardard input factory. For reference of functions that must be supported by registered class, see input_impl.\n Usage: static input_factory_t g_myinputclass_factory;\n Note that input classes can't be registered through service_factory_t template directly. +template +class input_factory_t : public service_factory_single_t > {}; + +//! Non-multitrack-enabled input factory (helper) - hides multitrack management functions from input implementation; use this for inputs that handle file types where each physical file can contain only one user-visible playable track. For reference of functions that must be supported by registered class, see input_singletrack_impl.\n Usage: static input_singletrack_factory_t g_myinputclass_factory;\n Note that input classes can't be registered through service_factory_t template directly.template +template +class input_singletrack_factory_t : public service_factory_single_t,t_flags> > {}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/keyValueIO.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/keyValueIO.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,18 @@ +#pragma once + +namespace fb2k { + // Generic interface for writing frontends in high level programming languages + class NOVTABLE keyValueIO : public service_base { + FB2K_MAKE_SERVICE_INTERFACE(keyValueIO, service_base); + public: + virtual fb2k::stringRef get(const char * name) = 0; + virtual void put(const char * name, const char * value) = 0; + virtual void commit() = 0; + virtual void reset() = 0; + virtual void dismiss(bool bOK) = 0; + + int getInt( const char * name ); + void putInt( const char * name, int val ); + }; +} + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/keyValueIOimpl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/keyValueIOimpl.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,28 @@ +#pragma once +#include "keyValueIO.h" + +#include +#include + +namespace fb2k { + class keyValueIOimpl : public keyValueIO { + public: + fb2k::stringRef get(const char * name) { + auto i = m_content.find(name); + if (i == m_content.end()) return fb2k::makeString(""); + return fb2k::makeString(i->second.c_str()); + } + void put(const char * name, const char * value) { + m_content[name] = value; + } + // OVERRIDE ME + void commit() {} + // OVERRIDE ME + void reset() {} + // OVERRIDE ME + void dismiss(bool bOK) {} + + protected: + std::map m_content; + }; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/library_callbacks.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/library_callbacks.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,94 @@ +#pragma once +#include "library_manager.h" +#include "metadb_callbacks.h" +#include "callback_merit.h" + +//! Callback service receiving notifications about Media Library content changes. Methods called only from main thread.\n +//! Use library_callback_factory_t template to register. +class NOVTABLE library_callback : public service_base { +public: + //! Called when new items are added to the Media Library. + virtual void on_items_added(metadb_handle_list_cref items) = 0; + //! Called when some items have been removed from the Media Library. + virtual void on_items_removed(metadb_handle_list_cref items) = 0; + //! Called when some items in the Media Library have been modified. \n + //! The list is sorted by pointer value for convenient matching by binary search. + virtual void on_items_modified(metadb_handle_list_cref items) = 0; + + //! Is current on_items_modified() cycle called due to actual tags changed or dispaly hook operations? \n + //! Supported since foobar2000 v2.0 beta 13 + static bool is_modified_from_hook(); + + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(library_callback); +}; + +//! \since 2.0 +class NOVTABLE library_callback_v2 : public library_callback { +public: + virtual void on_items_modified_v2(metadb_handle_list_cref items, metadb_io_callback_v2_data& data) = 0; + virtual void on_library_initialized() = 0; + + FB2K_MAKE_SERVICE_INTERFACE(library_callback_v2, library_callback); +}; + +template +class library_callback_factory_t : public service_factory_single_t {}; + +class NOVTABLE library_callback_dynamic { +public: + //! Called when new items are added to the Media Library. + virtual void on_items_added(metadb_handle_list_cref items) = 0; + //! Called when some items have been removed from the Media Library. + virtual void on_items_removed(metadb_handle_list_cref items) = 0; + //! Called when some items in the Media Library have been modified. + //! The list is sorted by pointer value for convenient matching by binary search. + virtual void on_items_modified(metadb_handle_list_cref items) = 0; + + void register_callback(); void unregister_callback(); +}; + +//! Base class for library_callback_dynamic implementations, manages register/unregister calls for you +class library_callback_dynamic_impl_base : public library_callback_dynamic { +public: + library_callback_dynamic_impl_base() { register_callback(); } + ~library_callback_dynamic_impl_base() { unregister_callback(); } + + //stub implementations - avoid pure virtual function call issues + void on_items_added(metadb_handle_list_cref) override {} + void on_items_removed(metadb_handle_list_cref) override {} + void on_items_modified(metadb_handle_list_cref) override {} + + PFC_CLASS_NOT_COPYABLE_EX(library_callback_dynamic_impl_base); +}; + +//! \since 2.0 +class NOVTABLE library_callback_v2_dynamic { +public: + //! Called when new items are added to the Media Library. + virtual void on_items_added(metadb_handle_list_cref items) = 0; + //! Called when some items have been removed from the Media Library. + virtual void on_items_removed(metadb_handle_list_cref items) = 0; + //! Called when some items in the Media Library have been modified. + //! The list is sorted by pointer value for convenient matching by binary search. + virtual void on_items_modified_v2(metadb_handle_list_cref items, metadb_io_callback_v2_data & data) = 0; + + virtual void on_library_initialized() = 0; + + void register_callback(); void unregister_callback(); +}; + +//! \since 2.0 +//! //! Base class for library_callback_v2_dynamic implementations, manages register/unregister calls for you +class library_callback_v2_dynamic_impl_base : public library_callback_v2_dynamic { +public: + library_callback_v2_dynamic_impl_base() { register_callback(); } + ~library_callback_v2_dynamic_impl_base() { unregister_callback(); } + + //stub implementations - avoid pure virtual function call issues + void on_items_added(metadb_handle_list_cref) override {} + void on_items_removed(metadb_handle_list_cref) override {} + void on_items_modified_v2(metadb_handle_list_cref, metadb_io_callback_v2_data&) override {} + void on_library_initialized() override {} + + PFC_CLASS_NOT_COPYABLE_EX(library_callback_v2_dynamic_impl_base); +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/library_index.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/library_index.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,17 @@ +#pragma once + +#include "search_tools.h" + +//! OBSOLETE, DO NOT USE \n +//! Please use search_index instead. +class NOVTABLE library_index : public service_base { + FB2K_MAKE_SERVICE_COREAPI(library_index); +public: + virtual void hit_test(search_filter::ptr pattern, metadb_handle_list_cref items, bool* out, abort_callback & a) = 0; + + enum { + flag_sort = 1 << 0, + }; + + virtual fb2k::arrayRef search(search_filter::ptr pattern, uint32_t flags, abort_callback& abort) = 0; +}; \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/library_manager.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/library_manager.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,208 @@ +#pragma once +#include "callback_merit.h" + +class library_callback_dynamic; class library_callback_v2_dynamic; + +/*! +This service implements methods allowing you to interact with the Media Library.\n +All methods are valid from main thread only, unless noted otherwise.\n +Usage: Use library_manager::get() to instantiate. +*/ + +class NOVTABLE library_manager : public service_base { + FB2K_MAKE_SERVICE_COREAPI(library_manager); +public: + //! Interface for use with library_manager::enum_items(). + class NOVTABLE enum_callback { + public: + //! Return true to continue enumeration, false to abort. + virtual bool on_item(const metadb_handle_ptr & p_item) = 0; + }; + + //! Returns whether the specified item is in the Media Library or not. + //! MAIN THREAD ONLY until foobar2000 v2.0; valid to call from anywhere since v2.0 + virtual bool is_item_in_library(const metadb_handle_ptr & p_item) = 0; + //! Returns whether current user settings allow the specified item to be added to the Media Library or not. + //! MAIN THREAD ONLY until foobar2000 v2.0; valid to call from anywhere since v2.0 + virtual bool is_item_addable(const metadb_handle_ptr & p_item) = 0; + //! Returns whether current user settings allow the specified item path to be added to the Media Library or not. + //! MAIN THREAD ONLY until foobar2000 v2.0; valid to call from anywhere since v2.0 + virtual bool is_path_addable(const char * p_path) = 0; + //! Retrieves path of the specified item relative to the Media Library folder it is in. Returns true on success, false when the item is not in the Media Library. + //! SPECIAL WARNING: to allow multi-CPU optimizations to parse relative track paths, this API works in threads other than the main app thread. Main thread MUST be blocked while working in such scenarios, it's NOT safe to call from worker threads while the Media Library content/configuration might be getting altered. + //! foobar2000 v2.0 and newer: legal to call from any thread with no restrictions. + virtual bool get_relative_path(const metadb_handle_ptr & p_item,pfc::string_base & p_out) = 0; + //! Calls callback method for every item in the Media Library. Note that order of items in Media Library is undefined. + virtual void enum_items(enum_callback & p_callback) = 0; +protected: + //! OBSOLETE, do not call, does nothing. + FB2K_DEPRECATED virtual void add_items(const pfc::list_base_const_t & p_data) = 0; + //! OBSOLETE, do not call, does nothing. + FB2K_DEPRECATED virtual void remove_items(const pfc::list_base_const_t & p_data) = 0; + //! OBSOLETE, do not call, does nothing. + FB2K_DEPRECATED virtual void add_items_async(const pfc::list_base_const_t & p_data) = 0; + + //! OBSOLETE, do not call, does nothing. + FB2K_DEPRECATED virtual void on_files_deleted_sorted(const pfc::list_base_const_t & p_data) = 0; +public: + //! Retrieves the entire Media Library content. + virtual void get_all_items(pfc::list_base_t & p_out) = 0; + + //! Returns whether Media Library functionality is enabled or not (to be exact: whether there's at least one Media Library folder present in settings), for e.g. notifying the user to change settings when trying to use a Media Library viewer without having configured the Media Library first. + virtual bool is_library_enabled() = 0; + //! Pops up the Media Library preferences page. + virtual void show_preferences() = 0; + + //! OBSOLETE, do not call. + virtual void rescan() = 0; + +protected: + //! OBSOLETE, do not call, does nothing. + FB2K_DEPRECATED virtual void check_dead_entries(const pfc::list_base_t & p_list) = 0; +public: + + +}; + +//! \since 0.9.3 +class NOVTABLE library_manager_v2 : public library_manager { + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(library_manager_v2,library_manager); +protected: + //! OBSOLETE, do not call, does nothing. + FB2K_DEPRECATED virtual bool is_rescan_running() = 0; + + //! OBSOLETE, do not call, does nothing. + FB2K_DEPRECATED virtual void rescan_async(fb2k::hwnd_t p_parent,completion_notify_ptr p_notify) = 0; + + //! OBSOLETE, do not call, does nothing. + FB2K_DEPRECATED virtual void check_dead_entries_async(const pfc::list_base_const_t & p_list,fb2k::hwnd_t p_parent,completion_notify_ptr p_notify) = 0; + + +}; + + +//! \since 0.9.5 +class NOVTABLE library_manager_v3 : public library_manager_v2 { +public: + //! Retrieves directory path and subdirectory/filename formatting scheme for newly encoded/copied/moved tracks. + //! @returns True on success, false when the feature has not been configured. + virtual bool get_new_file_pattern_tracks(pfc::string_base & p_directory,pfc::string_base & p_format) = 0; + //! Retrieves directory path and subdirectory/filename formatting scheme for newly encoded/copied/moved full album images. + //! @returns True on success, false when the feature has not been configured. + virtual bool get_new_file_pattern_images(pfc::string_base & p_directory,pfc::string_base & p_format) = 0; + + virtual void register_callback(library_callback_dynamic * p_callback) = 0; + virtual void unregister_callback(library_callback_dynamic * p_callback) = 0; + + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(library_manager_v3,library_manager_v2); +}; + +//! \since 2.0 +class NOVTABLE library_manager_v4 : public library_manager_v3 { +public: + virtual void register_callback_v2(library_callback_v2_dynamic*) = 0; + virtual void unregister_callback_v2(library_callback_v2_dynamic*) = 0; + virtual bool is_initialized() = 0; + + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(library_manager_v4, library_manager_v3); +}; + +//! \since 2.0 +class NOVTABLE library_manager_v5 : public library_manager_v4 { + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(library_manager_v5, library_manager_v4); +public: + //! foobar2000 v2.0 late addition: let callbacks know if the current notification comes from actual changed tags or a display hook operation. Returns 1 or 0 for true or false. + static const GUID status_current_callback_from_hook; + + //! Extensible status query method. Returns 0 for unrecognized commands. + virtual size_t library_status(const GUID& arg, size_t arg1, void* arg2, size_t arg2bytes) = 0; + + bool is_current_callback_from_hook() { return library_status(status_current_callback_from_hook, 0, nullptr, 0) != 0; } +}; + +//! \since 2.0 +class NOVTABLE library_manager_v6 : public library_manager_v5 { + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(library_manager_v6, library_manager_v5); +public: + virtual void set_callback_merit(library_callback_v2_dynamic*, fb2k::callback_merit_t) = 0; +}; + +//! Implement this service to appear on "library viewers" list in Media Library preferences page.\n +//! Use library_viewer_factory_t to register. +class NOVTABLE library_viewer : public service_base { +public: + //! Retrieves GUID of your preferences page (pfc::guid_null if you don't have one). + virtual GUID get_preferences_page() = 0; + //! Queries whether "activate" action is supported (relevant button will be disabled if it's not). + virtual bool have_activate() = 0; + //! Activates your Media Library viewer component (e.g. shows its window). + virtual void activate() = 0; + //! Retrieves GUID of your library_viewer implementation, for internal identification. Note that this not the same as preferences page GUID. + virtual GUID get_guid() = 0; + //! Retrieves name of your Media Library viewer, a null-terminated UTF-8 encoded string. + virtual const char * get_name() = 0; + + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(library_viewer); +}; + +template +class library_viewer_factory_t : public service_factory_single_t {}; + + +//! \since 0.9.5.4 +//! Allows you to spawn a popup Media Library Search window with any query string that you specify. \n +//! Usage: library_search_ui::get()->show("querygoeshere"); +class NOVTABLE library_search_ui : public service_base { +public: + virtual void show(const char * query) = 0; + + FB2K_MAKE_SERVICE_COREAPI(library_search_ui) +}; + +//! \since 0.9.6 +class NOVTABLE library_file_move_scope : public service_base { + FB2K_MAKE_SERVICE_INTERFACE(library_file_move_scope, service_base) +public: +}; + +//! \since 0.9.6 +class NOVTABLE library_file_move_manager : public service_base { + FB2K_MAKE_SERVICE_COREAPI(library_file_move_manager) +public: + virtual library_file_move_scope::ptr acquire_scope() = 0; + virtual bool is_move_in_progress() = 0; +}; + +//! \since 0.9.6 +class NOVTABLE library_file_move_notify_ { +public: + virtual void on_state_change(bool isMoving) = 0; +}; + +//! \since 0.9.6 +class NOVTABLE library_file_move_notify : public service_base, public library_file_move_notify_ { + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(library_file_move_notify) +public: +}; + + +#ifdef _WIN32 + +//! \since 0.9.6.1 +class NOVTABLE library_meta_autocomplete : public service_base { + FB2K_MAKE_SERVICE_COREAPI(library_meta_autocomplete) +public: + virtual bool get_value_list(const char * metaName, pfc::com_ptr_t & out) = 0; +}; + +//! \since 1.6.1 +//! Caching & asynchronous version. \n +//! Keep a reference to your library_meta_autocomplete_v2 object in your dialog class to cache the looked up values & speed up the operation. +class NOVTABLE library_meta_autocomplete_v2 : public service_base { + FB2K_MAKE_SERVICE_COREAPI(library_meta_autocomplete_v2) +public: + virtual bool get_value_list_async(const char* metaName, pfc::com_ptr_t& out) = 0; +}; + +#endif // _WIN32 + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/link_resolver.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/link_resolver.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,14 @@ +#include "foobar2000-sdk-pch.h" +#include "link_resolver.h" + +bool link_resolver::g_find(service_ptr_t & p_out,const char * p_path) +{ + const auto ext = pfc::string_extension(p_path); + for (auto ptr : enumerate()) { + if (ptr->is_our_path(p_path,ext)) { + p_out = ptr; + return true; + } + } + return false; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/link_resolver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/link_resolver.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,30 @@ +#pragma once + +//! Interface for resolving different sorts of link files. +//! Utilized by mechanisms that convert filesystem path into list of playable locations. +//! For security reasons, link may only point to playable object path, not to a playlist or another link. + +class NOVTABLE link_resolver : public service_base +{ +public: + + //! Tests whether specified file is supported by this link_resolver service. + //! @param p_path Path of file being queried. + //! @param p_extension Extension of file being queried. This is provided for performance reasons, path already includes it. + virtual bool is_our_path(const char * p_path,const char * p_extension) = 0; + + //! Resolves a link file. Before this is called, path must be accepted by is_our_path(). + //! @param p_filehint Optional file interface to use. If null/empty, implementation should open file by itself. + //! @param p_path Path of link file to resolve. + //! @param p_out Receives path the link is pointing to. + //! @param p_abort abort_callback object signaling user aborting the operation. + virtual void resolve(service_ptr_t p_filehint,const char * p_path,pfc::string_base & p_out,abort_callback & p_abort) = 0; + + //! Helper function; finds link_resolver interface that supports specified link file. + //! @param p_out Receives link_resolver interface on success. + //! @param p_path Path of file to query. + //! @returns True on success, false on failure (no interface that supports specified path could be found). + static bool g_find(service_ptr_t & p_out,const char * p_path); + + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(link_resolver); +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/main_thread_callback.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/main_thread_callback.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,74 @@ +#include "foobar2000-sdk-pch.h" +#include "main_thread_callback.h" +#include "abort_callback.h" +#include +#include + + +void main_thread_callback::callback_enqueue() { + main_thread_callback_manager::get()->add_callback(this); +} + +void main_thread_callback_add(main_thread_callback::ptr ptr) { + main_thread_callback_manager::get()->add_callback(ptr); +} + +namespace { + typedef std::function func_t; + class mtcallback_func : public main_thread_callback { + public: + mtcallback_func(func_t const& f) : m_f(f) {} + + void callback_run() noexcept override { + m_f(); + } + private: + func_t m_f; + }; +} + +void fb2k::inMainThread( std::function f ) { + main_thread_callback_add( new service_impl_t(f)); +} + +void fb2k::inMainThread(std::function f, abort_callback& a) { + auto abort = std::make_shared< abort_callback_clone >(a); + inMainThread([f, abort] { + if (!abort->is_set()) f(); + }); +} + +void fb2k::inMainThread2( std::function f ) { + if ( core_api::is_main_thread() ) { + f(); + } else { + inMainThread(f); + } +} + +void fb2k::inMainThreadSynchronous(std::function f, abort_callback & abort) { + abort.check(); + + if (core_api::is_main_thread()) { + f(); return; + } + + auto evt = std::make_shared(); + auto f2 = [f, evt] { + f(); + evt->set_state(true); + }; + inMainThread(f2); + abort.waitForEvent(*evt); +} + +void fb2k::inMainThreadSynchronous2(std::function f) { + // Have new API? + auto api = main_thread_callback_manager_v2::tryGet(); + if (api.is_valid()) { + api->run_synchronously( fb2k::service_new(f) ); + return; + } + + inMainThreadSynchronous(f, fb2k::noAbort); +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/main_thread_callback.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/main_thread_callback.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,66 @@ +#pragma once +#include + +// fb2k::inMainThread moved to threadsLite.h + + + +// ====================================================================================================== +// API declarations +// ====================================================================================================== + +//! Callback object class for main_thread_callback_manager service. \n +//! You do not need to implement this directly - simply use fb2k::inMainThread() with a lambda. +class NOVTABLE main_thread_callback : public service_base { +public: + //! Gets called from main app thread. See main_thread_callback_manager description for more info. + virtual void callback_run() = 0; + + void callback_enqueue(); // helper + + FB2K_MAKE_SERVICE_INTERFACE(main_thread_callback,service_base); +}; + +/*! +Allows you to queue a callback object to be called from main app thread. This is commonly used to trigger main-thread-only API calls from worker threads.\n +This can be also used from main app thread, to avoid race conditions when trying to use APIs that dispatch global callbacks from inside some other global callback, or using message loops / modal dialogs inside global callbacks. \n +There is no need to use this API directly - use fb2k::inMainThread() with a lambda. +*/ +class NOVTABLE main_thread_callback_manager : public service_base { +public: + //! Queues a callback object. This can be called from any thread, implementation ensures multithread safety. Implementation will call p_callback->callback_run() once later. To get it called repeatedly, you would need to add your callback again. \n + //! Queued callbacks will be called in the same order as they were queued (FIFO). + virtual void add_callback(service_ptr_t p_callback) = 0; + + FB2K_MAKE_SERVICE_COREAPI(main_thread_callback_manager); +}; + +//! \since 2.0 +//! Additional method added to help recovering from method-called-in-wrong-thread scenarios. +class NOVTABLE main_thread_callback_manager_v2 : public main_thread_callback_manager { + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(main_thread_callback_manager_v2, main_thread_callback_manager) +public: + //! Uses win32 SendMessage() to invoke your callback synchronously, blocks until done. \n + //! If multiple threads call this, order of callbacks is undefined. \n + //! Callbacks run_synchronously() callbacks take precedence over add_callback(). + virtual void run_synchronously( main_thread_callback::ptr ) = 0; +}; + +// ====================================================================================================== +// Obsolete helpers - they still work, but it's easier to just use fb2k::inMainThread(). +// ====================================================================================================== + +//! Helper, equivalent to main_thread_callback_manager::get()->add_callback(ptr) +void main_thread_callback_add(main_thread_callback::ptr ptr); + +template static void main_thread_callback_spawn() { + main_thread_callback_add(new service_impl_t); +} +template static void main_thread_callback_spawn(const t_param1 & p1) { + main_thread_callback_add(new service_impl_t(p1)); +} +template static void main_thread_callback_spawn(const t_param1 & p1, const t_param2 & p2) { + main_thread_callback_add(new service_impl_t(p1, p2)); +} + +// More legacy helper code moved to helpers/callInMainThreadHelper.h \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/mainmenu.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/mainmenu.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,70 @@ +#include "foobar2000-sdk-pch.h" +#include "menu_helpers.h" + +bool mainmenu_commands::g_execute_dynamic(const GUID & p_guid, const GUID & p_subGuid,service_ptr_t p_callback) { + mainmenu_commands::ptr ptr; t_uint32 index; + if (!menu_item_resolver::g_resolve_main_command(p_guid, ptr, index)) return false; + mainmenu_commands_v2::ptr v2; + if (!ptr->service_query_t(v2)) return false; + if (!v2->is_command_dynamic(index)) return false; + bool rv = false; + fb2k::crashOnException([&] { + rv = v2->dynamic_execute(index, p_subGuid, p_callback);; + }, "mainmenu_commands::dynamic_execute"); + return rv; +} +bool mainmenu_commands::g_execute(const GUID & p_guid,service_ptr_t p_callback) { + mainmenu_commands::ptr ptr; t_uint32 index; + if (!menu_item_resolver::g_resolve_main_command(p_guid, ptr, index)) return false; + fb2k::crashOnException( [&] { + ptr->execute(index, p_callback); + }, "mainmenu_commands::execute"); + return true; +} + +bool mainmenu_commands::g_find_by_name(const char * p_name,GUID & p_guid) { + pfc::string8_fastalloc temp; + for( auto ptr : enumerate() ) { + const t_uint32 count = ptr->get_command_count(); + for(t_uint32 n=0;nget_name(n,temp); + if (stricmp_utf8(temp,p_name) == 0) { + p_guid = ptr->get_command(n); + return true; + } + } + } + return false; + +} + + +static bool dynamic_execute_recur(mainmenu_node::ptr node, const GUID & subID, service_ptr_t callback) { + switch(node->get_type()) { + case mainmenu_node::type_command: + if (subID == node->get_guid()) { + node->execute(callback); return true; + } + break; + case mainmenu_node::type_group: + { + const t_size total = node->get_children_count(); + for(t_size walk = 0; walk < total; ++walk) { + if (dynamic_execute_recur(node->get_child(walk), subID, callback)) return true; + } + } + break; + } + return false; +} + +bool mainmenu_commands_v2::is_command_dynamic(t_uint32 index) { + (void)index; return false; +} +mainmenu_node::ptr mainmenu_commands_v2::dynamic_instantiate(t_uint32 index) { + (void)index; uBugCheck(); +} + +bool mainmenu_commands_v2::dynamic_execute(t_uint32 index, const GUID & subID, service_ptr_t callback) { + return dynamic_execute_recur(dynamic_instantiate(index), subID, callback); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/mem_block_container.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/mem_block_container.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,13 @@ +#include "foobar2000-sdk-pch.h" +#include "mem_block_container.h" + +void mem_block_container::from_stream(stream_reader * p_stream,t_size p_bytes,abort_callback & p_abort) { + if (p_bytes == 0) {set_size(0);} + set_size(p_bytes); + p_stream->read_object(get_ptr(),p_bytes,p_abort); +} + +void mem_block_container::set(const void * p_buffer,t_size p_size) { + set_size(p_size); + memcpy(get_ptr(),p_buffer,p_size); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/mem_block_container.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/mem_block_container.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,108 @@ +#pragma once + +#include "filesystem.h" + +//! Generic interface for a memory block; used by various other interfaces to return memory blocks while allowing caller to allocate. +class NOVTABLE mem_block_container { +public: + virtual const void * get_ptr() const = 0; + virtual void * get_ptr() = 0; + virtual t_size get_size() const = 0; + virtual void set_size(t_size p_size) = 0; + + void from_stream(stream_reader * p_stream,t_size p_bytes,abort_callback & p_abort); + + void set(const void * p_buffer,t_size p_size); + void set(const mem_block_container & source) {copy(source);} + template void set(const t_source & source) { + PFC_STATIC_ASSERT( sizeof(source[0]) == 1 ); + set(source.get_ptr(), source.get_size()); + } + + inline void copy(const mem_block_container & p_source) {set(p_source.get_ptr(),p_source.get_size());} + inline void reset() {set_size(0);} + + const mem_block_container & operator=(const mem_block_container & p_source) {copy(p_source);return *this;} + + void resize(size_t v) { set_size(v); } + size_t size() const { return get_size(); } +protected: + mem_block_container() {} + ~mem_block_container() {} +}; + +//! mem_block_container implementation. +template class t_alloc = pfc::alloc_standard> +class mem_block_container_impl_t : public mem_block_container { +public: + const void* get_ptr() const override { return m_data.get_ptr(); } + void* get_ptr() override { return m_data.get_ptr(); } + t_size get_size() const override { return m_data.get_size(); } + void set_size(t_size p_size) override { m_data.set_size(p_size); } +private: + pfc::array_t m_data; +}; + +class mem_block_container_impl : public mem_block_container { +public: + const void * get_ptr() const override {return m_data.ptr();} + void * get_ptr() override {return m_data.ptr();} + t_size get_size() const override {return m_data.size();} + void set_size(t_size p_size) override {m_data.resize(p_size);} + + pfc::mem_block m_data; +}; + + +template class mem_block_container_aligned_impl : public mem_block_container { +public: + const void * get_ptr() const {return m_data.get_ptr();} + void * get_ptr() {return m_data.get_ptr();} + t_size get_size() const {return m_data.get_size();} + void set_size(t_size p_size) {m_data.set_size(p_size);} +private: + pfc::mem_block_aligned<16> m_data; +}; + +template class mem_block_container_aligned_incremental_impl : public mem_block_container { +public: + mem_block_container_aligned_incremental_impl() : m_size() {} + const void * get_ptr() const {return m_data.get_ptr();} + void * get_ptr() {return m_data.get_ptr();} + t_size get_size() const {return m_size;} + void set_size(t_size p_size) { + if (m_data.size() < p_size) { + m_data.resize( pfc::multiply_guarded(p_size, 3) / 2 ); + } + m_size = p_size; + } +private: + pfc::mem_block_aligned<16> m_data; + size_t m_size; +}; + +class mem_block_container_temp_impl : public mem_block_container { +public: + mem_block_container_temp_impl(void * p_buffer,t_size p_size) : m_size(0), m_buffer_size(p_size), m_buffer(p_buffer) {} + const void * get_ptr() const {return m_buffer;} + void * get_ptr() {return m_buffer;} + t_size get_size() const {return m_size;} + void set_size(t_size p_size) {if (p_size > m_buffer_size) throw pfc::exception_overflow(); m_size = p_size;} +private: + t_size m_size,m_buffer_size; + void * m_buffer; +}; + +template +class mem_block_container_ref_impl : public mem_block_container { +public: + mem_block_container_ref_impl(t_ref & ref) : m_ref(ref) { + PFC_STATIC_ASSERT( sizeof(ref[0]) == 1 ); + } + const void * get_ptr() const {return m_ref.get_ptr();} + void * get_ptr() {return m_ref.get_ptr();} + t_size get_size() const {return m_ref.get_size();} + void set_size(t_size p_size) {m_ref.set_size(p_size);} +private: + t_ref & m_ref; +}; \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/menu.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/menu.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,260 @@ +#pragma once +#include "menu_common.h" + +class NOVTABLE mainmenu_group : public service_base { + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(mainmenu_group); +public: + virtual GUID get_guid() = 0; + virtual GUID get_parent() = 0; + virtual t_uint32 get_sort_priority() = 0; +}; + +class NOVTABLE mainmenu_group_popup : public mainmenu_group { + FB2K_MAKE_SERVICE_INTERFACE(mainmenu_group_popup, mainmenu_group); +public: + virtual void get_display_string(pfc::string_base & p_out) = 0; + void get_name(pfc::string_base & out) {get_display_string(out);} +}; + +//! \since 1.4 +//! Allows you to control whether to render the group as a popup or inline. +class NOVTABLE mainmenu_group_popup_v2 : public mainmenu_group_popup { + FB2K_MAKE_SERVICE_INTERFACE(mainmenu_group_popup_v2, mainmenu_group_popup); +public: + virtual bool popup_condition() = 0; +}; + +class NOVTABLE mainmenu_commands : public service_base { +public: + static constexpr uint32_t + flag_disabled = 1 << 0, + flag_checked = 1 << 1, + flag_radiochecked = 1 << 2, + //! \since 1.0 + //! Replaces the old return-false-from-get_display() behavior - use this to make your command hidden by default but accessible when holding shift. + flag_defaulthidden = 1 << 3, + sort_priority_base = 0x10000, + sort_priority_dontcare = 0x80000000u, + sort_priority_last = UINT32_MAX; + + + //! Retrieves number of implemented commands. Index parameter of other methods must be in 0....command_count-1 range. + virtual t_uint32 get_command_count() = 0; + //! Retrieves GUID of specified command. + virtual GUID get_command(t_uint32 p_index) = 0; + //! Retrieves name of item, for list of commands to assign keyboard shortcuts to etc. + virtual void get_name(t_uint32 p_index,pfc::string_base & p_out) = 0; + //! Retrieves item's description for statusbar etc. + virtual bool get_description(t_uint32 p_index,pfc::string_base & p_out) = 0; + //! Retrieves GUID of owning menu group. + virtual GUID get_parent() = 0; + //! Retrieves sorting priority of the command; the lower the number, the upper in the menu your commands will appear. Third party components should use sorting_priority_base and up (values below are reserved for internal use). In case of equal priority, order is undefined. + virtual t_uint32 get_sort_priority() {return sort_priority_dontcare;} + //! Retrieves display string and display flags to use when menu is about to be displayed. If returns false, menu item won't be displayed. You can create keyboard-shortcut-only commands by always returning false from get_display(). + virtual bool get_display(t_uint32 p_index,pfc::string_base & p_text,t_uint32 & p_flags) {p_flags = 0;get_name(p_index,p_text);return true;} + + typedef service_ptr ctx_t; + + //! Executes the command. p_callback parameter is reserved for future use and should be ignored / set to null pointer. + virtual void execute(t_uint32 p_index,ctx_t p_callback) = 0; + + static bool g_execute(const GUID & p_guid,service_ptr_t p_callback = NULL); + static bool g_execute_dynamic(const GUID & p_guid, const GUID & p_subGuid,service_ptr_t p_callback = NULL); + static bool g_find_by_name(const char * p_name,GUID & p_guid); + + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(mainmenu_commands); +}; + +class NOVTABLE mainmenu_manager : public service_base { +public: + enum { + flag_show_shortcuts = 1 << 0, + flag_show_shortcuts_global = 1 << 1, + //! \since 1.0 + //! To control which commands are shown, you should specify either flag_view_reduced or flag_view_full. If neither is specified, the implementation will decide automatically based on shift key being pressed, for backwards compatibility. + flag_view_reduced = 1 << 2, + //! \since 1.0 + //! To control which commands are shown, you should specify either flag_view_reduced or flag_view_full. If neither is specified, the implementation will decide automatically based on shift key being pressed, for backwards compatibility. + flag_view_full = 1 << 3, + }; + + virtual void instantiate(const GUID & p_root) = 0; + +#ifdef _WIN32 + virtual void generate_menu_win32(fb2k::hmenu_t p_menu,t_uint32 p_id_base,t_uint32 p_id_count,t_uint32 p_flags) = 0; +#endif // _WIN32 + + //@param p_id Identifier of command to execute, relative to p_id_base of generate_menu_*() + //@returns true if command was executed successfully, false if not (e.g. command with given identifier not found). + virtual bool execute_command(t_uint32 p_id,service_ptr_t p_callback = service_ptr_t()) = 0; + + virtual bool get_description(t_uint32 p_id,pfc::string_base & p_out) = 0; + + //! Safely prevent destruction from worker threads (some components attempt that). + static bool serviceRequiresMainThreadDestructor() { return true; } + + FB2K_MAKE_SERVICE_COREAPI(mainmenu_manager); +}; + +//! \since 2.0 +class mainmenu_manager_v2 : public mainmenu_manager { + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(mainmenu_manager_v2, mainmenu_manager) +public: + virtual menu_tree_item::ptr generate_menu(uint32_t flags) = 0; +}; + +class mainmenu_groups { +public: + static const GUID file,view,edit,playback,library,help; + static const GUID file_open,file_add,file_playlist,file_etc; + static const GUID playback_controls,playback_etc; + static const GUID view_visualisations, view_alwaysontop, view_dsp; + static const GUID edit_part1,edit_part2,edit_part3; + static const GUID edit_part2_selection,edit_part2_sort,edit_part2_selection_sort; + static const GUID file_etc_preferences, file_etc_exit; + static const GUID help_about; + static const GUID library_refresh; + + enum {priority_edit_part1,priority_edit_part2,priority_edit_part3}; + enum {priority_edit_part2_commands,priority_edit_part2_selection,priority_edit_part2_sort}; + enum {priority_edit_part2_selection_commands,priority_edit_part2_selection_sort}; + enum {priority_file_open,priority_file_add,priority_file_playlist,priority_file_etc = mainmenu_commands::sort_priority_last}; +}; + + +class mainmenu_group_impl : public mainmenu_group { +public: + mainmenu_group_impl(const GUID & p_guid,const GUID & p_parent,t_uint32 p_priority) : m_guid(p_guid), m_parent(p_parent), m_priority(p_priority) {} + GUID get_guid() {return m_guid;} + GUID get_parent() {return m_parent;} + t_uint32 get_sort_priority() {return m_priority;} +private: + GUID m_guid,m_parent; t_uint32 m_priority; +}; + +class mainmenu_group_popup_impl : public mainmenu_group_popup { +public: + mainmenu_group_popup_impl(const GUID & p_guid,const GUID & p_parent,t_uint32 p_priority,const char * p_name) : m_guid(p_guid), m_parent(p_parent), m_priority(p_priority), m_name(p_name) {} + GUID get_guid() {return m_guid;} + GUID get_parent() {return m_parent;} + t_uint32 get_sort_priority() {return m_priority;} + void get_display_string(pfc::string_base & p_out) {p_out = m_name;} +private: + GUID m_guid,m_parent; t_uint32 m_priority; pfc::string8 m_name; +}; + +typedef service_factory_single_t _mainmenu_group_factory; +typedef service_factory_single_t _mainmenu_group_popup_factory; + +class mainmenu_group_factory : public _mainmenu_group_factory { +public: + mainmenu_group_factory(const GUID & p_guid,const GUID & p_parent,t_uint32 p_priority) : _mainmenu_group_factory(p_guid,p_parent,p_priority) {} +}; + +class mainmenu_group_popup_factory : public _mainmenu_group_popup_factory { +public: + mainmenu_group_popup_factory(const GUID & p_guid,const GUID & p_parent,t_uint32 p_priority,const char * p_name) : _mainmenu_group_popup_factory(p_guid,p_parent,p_priority,p_name) {} +}; + +#define FB2K_DECLARE_MAINMENU_GROUP( guid, parent, priority, name ) FB2K_SERVICE_FACTORY_PARAMS(mainmenu_group_impl, guid, parent, priority, name ); +#define FB2K_DECLARE_MAINMENU_GROUP_POPUP( guid, parent, priority, name ) FB2K_SERVICE_FACTORY_PARAMS(mainmenu_group_popup_impl, guid, parent, priority, name ); + +template +class mainmenu_commands_factory_t : public service_factory_single_t {}; + + + + + + +//! \since 1.0 +class NOVTABLE mainmenu_node : public service_base { + FB2K_MAKE_SERVICE_INTERFACE(mainmenu_node, service_base) +public: + enum { //same as contextmenu_item_node::t_type + type_group,type_command,type_separator + }; + + virtual t_uint32 get_type() = 0; + virtual void get_display(pfc::string_base & text, t_uint32 & flags) = 0; + //! Valid only if type is type_group. + virtual t_size get_children_count() = 0; + //! Valid only if type is type_group. + virtual ptr get_child(t_size index) = 0; + //! Valid only if type is type_command. + virtual void execute(service_ptr_t callback) = 0; + //! Valid only if type is type_command. + virtual GUID get_guid() = 0; + //! Valid only if type is type_command. + virtual bool get_description(pfc::string_base& out) { (void)out; return false; } + +}; + +class mainmenu_node_separator : public mainmenu_node { +public: + t_uint32 get_type() override {return type_separator;} + void get_display(pfc::string_base & text, t_uint32 & flags) override {text = ""; flags = 0;} + t_size get_children_count() override {return 0;} + ptr get_child(t_size index) override { (void)index; throw pfc::exception_invalid_params(); } + void execute(service_ptr_t) override {} + GUID get_guid() override {return pfc::guid_null;} +}; + +class mainmenu_node_command : public mainmenu_node { +public: + t_uint32 get_type() override {return type_command;} + t_size get_children_count() override {return 0;} + ptr get_child(t_size index) override { (void)index; throw pfc::exception_invalid_params(); } +/* + void get_display(pfc::string_base & text, t_uint32 & flags); + void execute(service_ptr_t callback); + GUID get_guid(); + bool get_description(pfc::string_base & out) {return false;} +*/ +}; + +class mainmenu_node_group : public mainmenu_node { +public: + t_uint32 get_type() override {return type_group;} + void execute(service_ptr_t callback) override { (void)callback; } + GUID get_guid() override {return pfc::guid_null;} +/* + void get_display(pfc::string_base & text, t_uint32 & flags); + t_size get_children_count(); + ptr get_child(t_size index); +*/ +}; + + +//! \since 1.0 +class NOVTABLE mainmenu_commands_v2 : public mainmenu_commands { + FB2K_MAKE_SERVICE_INTERFACE(mainmenu_commands_v2, mainmenu_commands) +public: + virtual bool is_command_dynamic(t_uint32 index); + //! Valid only when is_command_dynamic() returns true. Behavior undefined otherwise. + virtual mainmenu_node::ptr dynamic_instantiate(t_uint32 index); + //! Default fallback implementation provided. + virtual bool dynamic_execute(t_uint32 index, const GUID & subID, service_ptr_t callback); +}; + +//! \since 2.0 +//! Introduces callbacks to monitor menu items that act like check boxes. +class NOVTABLE mainmenu_commands_v3 : public mainmenu_commands_v2 { + FB2K_MAKE_SERVICE_INTERFACE(mainmenu_commands_v3, mainmenu_commands_v2) +public: + class state_callback { + public: + //! @param main Command ID + //! @param sub Reserved for future use. + virtual void menu_state_changed(const GUID& main, const GUID& sub) { (void)main; (void)sub; } + state_callback() {} + state_callback(state_callback const&) = delete; + void operator=(state_callback const&) = delete; + }; + + //! Return POSSIBLE values of display flags for this item, specifically flag_checked and flag_radiochecked if this item ever uses such. + //! @param subCmd Subcommand ID reserved for future use. Dynamic commands aren't meant to fire callbacks. + virtual uint32_t allowed_check_flags(uint32_t idx, const GUID& subCmd) = 0; + virtual void add_state_callback(state_callback*) = 0; + virtual void remove_state_callback(state_callback*) = 0; +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/menu_common.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/menu_common.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,66 @@ +#pragma once +#include "image.h" + +class menu_flags { +public: + enum { + disabled = 1 << 0, + checked = 1 << 1, + radiochecked = 1 << 2, + defaulthidden = 1 << 3, + disclosure = 1 << 4, // mobile platform specific, indicates whether to show a disclosure mark next to a command + }; +}; + +//! Type referring to a combination of menu_flags::* values +typedef uint32_t menu_flags_t; + +typedef fb2k::image menu_glyph; + +//! \since 2.0 +//! Menu manager's tree item object; see mainmenu_manager and contextmenu_manager. +class menu_tree_item : public service_base { + FB2K_MAKE_SERVICE_INTERFACE(menu_tree_item, service_base); +public: + enum type_t { + itemSeparator = 0, + itemCommand, + itemSubmenu + }; + + + virtual type_t type() = 0; + virtual size_t childCount() = 0; + virtual menu_tree_item::ptr childAt(size_t at) = 0; + virtual uint32_t commandID() = 0; + virtual const char* name() = 0; + virtual menu_flags_t flags() = 0; // menu_flags::* + virtual void execute(service_ptr ctx) = 0; + virtual bool get_description(pfc::string_base& strOut) = 0; + //! Refreshes the item's state. Returns true if either of the following properties has changed: flags, name, glyph, description. Currently does not allow the item's children to change. + virtual bool refreshState() { return false; } + + //! Command GUID for registering yourself for menu refresh notifications. May be null GUID if this item has no valid command GUID. + virtual GUID commandGuid() { return pfc::guid_null; } + //! Sub-command GUID for dynamically created items. Typically null GUID as simple items do not have sub command GUIDs. + virtual GUID subCommandGuid() { return pfc::guid_null; } + + virtual bool get_icon(fb2k::imageLocation_t& outLoc) { (void)outLoc; return false; } + + bool isSeparator() { return type() == itemSeparator; } + bool isCommand() { return type() == itemCommand; } + bool isSubmenu() { return type() == itemSubmenu; } + bool isDisclosure() { return (flags() & menu_flags::disclosure) != 0; } +}; + + +typedef menu_tree_item mainmenu_tree_item; + +#define FB2K_MENU_CAPS_TITLE 1 +#define FB2K_MENU_CAPS_SENTENCE 2 + +#ifdef _WIN32 +#define FB2K_MENU_CAPS FB2K_MENU_CAPS_SENTENCE +#else +#define FB2K_MENU_CAPS FB2K_MENU_CAPS_TITLE +#endif diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/menu_helpers.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/menu_helpers.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,337 @@ +#include "foobar2000-sdk-pch.h" +#include "menu_helpers.h" +#include "metadb.h" +#include "playlist.h" + + +bool menu_helpers::context_get_description(const GUID& p_guid,pfc::string_base & out) { + service_ptr_t ptr; t_uint32 index; + if (!menu_item_resolver::g_resolve_context_command(p_guid, ptr, index)) return false; + bool rv = ptr->get_item_description(index, out); + if (!rv) out.reset(); + return rv; +} + +static bool run_context_command_internal(const GUID & p_command,const GUID & p_subcommand,const pfc::list_base_const_t & data,const GUID & caller) { + if (data.get_count() == 0) return false; + service_ptr_t ptr; t_uint32 index; + if (!menu_item_resolver::g_resolve_context_command(p_command, ptr, index)) return false; + + { + TRACK_CALL_TEXT("menu_helpers::run_command(), by GUID"); + ptr->item_execute_simple(index, p_subcommand, data, caller); + } + + return true; +} + +bool menu_helpers::run_command_context(const GUID & p_command,const GUID & p_subcommand,const pfc::list_base_const_t & data) +{ + return run_context_command_internal(p_command,p_subcommand,data,contextmenu_item::caller_undefined); +} + +bool menu_helpers::run_command_context_ex(const GUID & p_command,const GUID & p_subcommand,const pfc::list_base_const_t & data,const GUID & caller) +{ + return run_context_command_internal(p_command,p_subcommand,data,caller); +} + +bool menu_helpers::test_command_context(const GUID & p_guid) +{ + service_ptr_t ptr; t_uint32 index; + return menu_item_resolver::g_resolve_context_command(p_guid, ptr, index); +} + +static bool g_is_checked(const GUID & p_command,const GUID & p_subcommand,const pfc::list_base_const_t & data,const GUID & caller) +{ + service_ptr_t ptr; t_uint32 index; + if (!menu_item_resolver::g_resolve_context_command(p_command, ptr, index)) return false; + + unsigned displayflags = 0; + pfc::string_formatter dummystring; + if (!ptr->item_get_display_data(dummystring,displayflags,index,p_subcommand,data,caller)) return false; + return (displayflags & contextmenu_item_node::FLAG_CHECKED) != 0; + +} + +bool menu_helpers::is_command_checked_context(const GUID & p_command,const GUID & p_subcommand,const pfc::list_base_const_t & data) +{ + return g_is_checked(p_command,p_subcommand,data,contextmenu_item::caller_undefined); +} + +bool menu_helpers::is_command_checked_context_playlist(const GUID & p_command,const GUID & p_subcommand) +{ + metadb_handle_list temp; + playlist_manager::get()->activeplaylist_get_selected_items(temp); + return g_is_checked(p_command,p_subcommand,temp,contextmenu_item::caller_playlist); +} + + + + + + + +bool menu_helpers::run_command_context_playlist(const GUID & p_command,const GUID & p_subcommand) +{ + metadb_handle_list temp; + playlist_manager::get()->activeplaylist_get_selected_items(temp); + return run_command_context_ex(p_command,p_subcommand,temp,contextmenu_item::caller_playlist); +} + +bool menu_helpers::run_command_context_now_playing(const GUID & p_command,const GUID & p_subcommand) +{ + metadb_handle_ptr item; + if (!playback_control::get()->get_now_playing(item)) return false;//not playing + return run_command_context_ex(p_command,p_subcommand,pfc::list_single_ref_t(item),contextmenu_item::caller_now_playing); +} + + +bool menu_helpers::guid_from_name(const char * p_name,unsigned p_name_len,GUID & p_out) +{ + pfc::string8_fastalloc nametemp; + for( auto ptr : contextmenu_item::enumerate() ) { + unsigned n, m = ptr->get_num_items(); + for(n=0;nget_item_name(n,nametemp); + if (!strcmp_ex(nametemp,SIZE_MAX,p_name,p_name_len)) + { + p_out = ptr->get_item_guid(n); + return true; + } + } + } + return false; +} + +bool menu_helpers::name_from_guid(const GUID & p_guid,pfc::string_base & p_out) { + service_ptr_t ptr; t_uint32 index; + if (!menu_item_resolver::g_resolve_context_command(p_guid, ptr, index)) return false; + ptr->get_item_name(index, p_out); + return true; +} + + +static unsigned calc_total_action_count() +{ + unsigned ret = 0; + for( auto ptr : contextmenu_item::enumerate()) ret += ptr->get_num_items(); + return ret; +} + + +const char * menu_helpers::guid_to_name_table::search(const GUID & p_guid) +{ + if (!m_inited) + { + m_data.set_size(calc_total_action_count()); + t_size dataptr = 0; + pfc::string8_fastalloc nametemp; + + for( auto ptr : contextmenu_item::enumerate()) + { + unsigned n, m = ptr->get_num_items(); + for(n=0;nget_item_name(n,nametemp); + m_data[dataptr].m_name = pfc::strDup(nametemp); + m_data[dataptr].m_guid = ptr->get_item_guid(n); + dataptr++; + } + } + assert(dataptr == m_data.get_size()); + + pfc::sort_t(m_data,entry_compare,m_data.get_size()); + m_inited = true; + } + t_size index; + if (pfc::bsearch_t(m_data.get_size(),m_data,entry_compare_search,p_guid,index)) + return m_data[index].m_name; + else + return 0; +} + +int menu_helpers::guid_to_name_table::entry_compare_search(const entry & entry1,const GUID & entry2) +{ + return pfc::guid_compare(entry1.m_guid,entry2); +} + +int menu_helpers::guid_to_name_table::entry_compare(const entry & entry1,const entry & entry2) +{ + return pfc::guid_compare(entry1.m_guid,entry2.m_guid); +} + +menu_helpers::guid_to_name_table::guid_to_name_table() +{ + m_inited = false; +} + +menu_helpers::guid_to_name_table::~guid_to_name_table() +{ + t_size n, m = m_data.get_size(); + for(n=0;nget_num_items(); + for(n=0;nget_item_name(n,nametemp); + m_data[dataptr].m_name = pfc::strDup(nametemp); + m_data[dataptr].m_guid = ptr->get_item_guid(n); + dataptr++; + } + } + assert(dataptr == m_data.get_size()); + + pfc::sort_t(m_data,entry_compare,m_data.get_size()); + m_inited = true; + } + t_size index; + search_entry temp = {p_name,p_name_len}; + if (pfc::bsearch_t(m_data.get_size(),m_data,entry_compare_search,temp,index)) + { + p_out = m_data[index].m_guid; + return true; + } + else + return false; +} + +menu_helpers::name_to_guid_table::name_to_guid_table() +{ + m_inited = false; +} + +menu_helpers::name_to_guid_table::~name_to_guid_table() +{ + t_size n, m = m_data.get_size(); + for(n=0;n & p_item,unsigned & p_index) +{ + pfc::string8_fastalloc path,name; + + for (auto ptr : contextmenu_item::enumerate()) { + // if (ptr->get_type()==type) + { + unsigned action, num_actions = ptr->get_num_items(); + for (action = 0; action < num_actions; action++) + { + ptr->get_item_default_path(action, path); ptr->get_item_name(action, name); + if (!path.is_empty()) path += "/"; + path += name; + if (!stricmp_utf8(p_name, path)) + { + p_item = ptr; + p_index = action; + return true; + } + } + } + } + return false; + +} + +bool menu_helpers::find_command_by_name(const char * p_name,GUID & p_command) +{ + service_ptr_t item; + unsigned index; + bool ret = find_command_by_name(p_name,item,index); + if (ret) p_command = item->get_item_guid(index); + return ret; +} + + +bool standard_commands::run_main(const GUID & p_guid) { + t_uint32 index; + mainmenu_commands::ptr ptr; + if (!menu_item_resolver::g_resolve_main_command(p_guid, ptr, index)) return false; + ptr->execute(index,service_ptr_t()); + return true; +} + +bool menu_item_resolver::g_resolve_context_command(const GUID & id, contextmenu_item::ptr & out, t_uint32 & out_index) { + return menu_item_resolver::get()->resolve_context_command(id, out, out_index); +} +bool menu_item_resolver::g_resolve_main_command(const GUID & id, mainmenu_commands::ptr & out, t_uint32 & out_index) { + return menu_item_resolver::get()->resolve_main_command(id, out, out_index); +} + +static bool char_is_separator(char x) +{ + for( auto s : {' ', ',', '/', '-'}) { + if (x==s) return true; + } + return false; +} + +static bool capitalize_exception( const char * ptr, size_t len ) { + for( auto e : {"for", "to", "from", "with", "by", "in", "at", "and", "or", "on", "a", "of", "as" }) { + if ( len == strlen(e) && memcmp(ptr, e, len) == 0 ) return true; + } + return false; +} +#if FB2K_MENU_CAPS == FB2K_MENU_CAPS_TITLE +static pfc::string8 capitalizeThis( const char * arg ) { + pfc::string8 work; work.prealloc( 256 ); + auto base = arg; + while(*base) { + auto ptr = base; + while(*ptr && ! char_is_separator(*ptr) ) ++ptr; + if ( ptr > base ) { + if ( !capitalize_exception( base, ptr-base ) ) { + unsigned c = 0; + auto d = pfc::utf8_decode_char(base, c, ptr-base); + if ( d > 0 ) { + c = uCharUpper( c ); + work.add_char( c ); + base += d; + } + } + work.add_string_nc(base, ptr - base); + } + while(*ptr && char_is_separator(*ptr)) { + work.add_byte(*ptr++); + } + base = ptr; + } + return work; +} +#endif // #if FB2K_MENU_CAPS == FB2K_MENU_CAPS_TITLE + +void fb2k::capitalizeMenuLabel( pfc::string_base & inOut ) { +#if FB2K_MENU_CAPS == FB2K_MENU_CAPS_TITLE + inOut = capitalizeThis( inOut ); +#else + (void) inOut; +#endif +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/menu_helpers.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/menu_helpers.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,196 @@ +#pragma once +#include "menu.h" +#include "contextmenu.h" + +namespace menu_helpers { +#ifdef _WIN32 + void win32_auto_mnemonics(HMENU menu); +#endif + + bool run_command_context(const GUID & p_command,const GUID & p_subcommand,const pfc::list_base_const_t & data); + bool run_command_context_ex(const GUID & p_command,const GUID & p_subcommand,const pfc::list_base_const_t & data,const GUID & caller); + bool run_command_context_playlist(const GUID & p_command,const GUID & p_subcommand); + bool run_command_context_now_playing(const GUID & p_command,const GUID & p_subcommand); + + bool test_command_context(const GUID & p_guid); + + bool is_command_checked_context(const GUID & p_command,const GUID & p_subcommand,const pfc::list_base_const_t & data); + bool is_command_checked_context_playlist(const GUID & p_command,const GUID & p_subcommand); + + bool find_command_by_name(const char * p_name,service_ptr_t & p_item,unsigned & p_index); + bool find_command_by_name(const char * p_name,GUID & p_command); + + bool context_get_description(const GUID& p_guid,pfc::string_base & out); + + bool guid_from_name(const char * p_name,unsigned p_name_len,GUID & p_out); + bool name_from_guid(const GUID & p_guid,pfc::string_base & p_out); + + class guid_to_name_table + { + public: + guid_to_name_table(); + ~guid_to_name_table(); + const char * search(const GUID & p_guid); + private: + struct entry { + char* m_name; + GUID m_guid; + }; + pfc::array_t m_data; + bool m_inited; + + static int entry_compare_search(const entry & entry1,const GUID & entry2); + static int entry_compare(const entry & entry1,const entry & entry2); + }; + + class name_to_guid_table + { + public: + name_to_guid_table(); + ~name_to_guid_table(); + bool search(const char * p_name,unsigned p_name_len,GUID & p_out); + private: + struct entry { + char* m_name; + GUID m_guid; + }; + pfc::array_t m_data; + bool m_inited; + struct search_entry { + const char * m_name; unsigned m_name_len; + }; + + static int entry_compare_search(const entry & entry1,const search_entry & entry2); + static int entry_compare(const entry & entry1,const entry & entry2); + }; + +}; + + + +class standard_commands +{ +public: + static const GUID + guid_context_file_properties, guid_context_file_open_directory, guid_context_copy_names, + guid_context_send_to_playlist, guid_context_reload_info, guid_context_reload_info_if_changed, + guid_context_rewrite_info, guid_context_remove_tags, + guid_context_convert_run, guid_context_convert_run_singlefile,guid_context_convert_run_withcue, + guid_context_write_cd, + guid_context_rg_scan_track, guid_context_rg_scan_album, guid_context_rg_scan_album_multi, + guid_context_rg_remove, guid_context_save_playlist, guid_context_masstag_edit, + guid_context_masstag_rename, + guid_main_always_on_top, guid_main_preferences, guid_main_about, + guid_main_exit, guid_main_restart, guid_main_activate, + guid_main_hide, guid_main_activate_or_hide, guid_main_titleformat_help, + guid_main_next, guid_main_previous, + guid_main_next_or_random, guid_main_random, guid_main_pause, + guid_main_play, guid_main_play_or_pause, guid_main_rg_set_album, + guid_main_rg_set_track, guid_main_rg_disable, guid_main_rg_byorder, + guid_main_stop, + guid_main_stop_after_current, guid_main_volume_down, guid_main_volume_up, + guid_main_volume_mute, guid_main_add_directory, guid_main_add_files, + guid_main_add_location, guid_main_add_playlist, guid_main_clear_playlist, + guid_main_create_playlist, guid_main_highlight_playing, guid_main_load_playlist, + guid_main_next_playlist, guid_main_previous_playlist, guid_main_open, + guid_main_remove_playlist, guid_main_remove_dead_entries, guid_main_remove_duplicates, + guid_main_rename_playlist, guid_main_save_all_playlists, guid_main_save_playlist, + guid_main_playlist_search, guid_main_playlist_sel_crop, guid_main_playlist_sel_remove, + guid_main_playlist_sel_invert, guid_main_playlist_undo, guid_main_show_console, + guid_main_play_cd, guid_main_restart_resetconfig, guid_main_record, + guid_main_playlist_moveback, guid_main_playlist_moveforward, guid_main_playlist_redo, + guid_main_playback_follows_cursor, guid_main_cursor_follows_playback, guid_main_saveconfig, + guid_main_playlist_select_all, guid_main_show_now_playing, + + guid_seek_ahead_1s, guid_seek_ahead_5s, guid_seek_ahead_10s, guid_seek_ahead_30s, + guid_seek_ahead_1min, guid_seek_ahead_2min, guid_seek_ahead_5min, guid_seek_ahead_10min, + + guid_seek_back_1s, guid_seek_back_5s, guid_seek_back_10s, guid_seek_back_30s, + guid_seek_back_1min, guid_seek_back_2min, guid_seek_back_5min, guid_seek_back_10min, + + guid_library_configure, guid_library_rescan, + guid_internet_radio + ; + + static bool run_main(const GUID & guid); + static inline bool run_context(const GUID & guid,const pfc::list_base_const_t &data) {return menu_helpers::run_command_context(guid,pfc::guid_null,data);} + static inline bool run_context(const GUID & guid,const pfc::list_base_const_t &data,const GUID& caller) {return menu_helpers::run_command_context_ex(guid,pfc::guid_null,data,caller);} + + static inline bool context_file_properties(const pfc::list_base_const_t &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_file_properties,data,caller);} + static inline bool context_file_open_directory(const pfc::list_base_const_t &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_file_open_directory,data,caller);} + static inline bool context_copy_names(const pfc::list_base_const_t &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_copy_names,data,caller);} + static inline bool context_send_to_playlist(const pfc::list_base_const_t &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_send_to_playlist,data,caller);} + static inline bool context_reload_info(const pfc::list_base_const_t &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_reload_info,data,caller);} + static inline bool context_reload_info_if_changed(const pfc::list_base_const_t &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_reload_info_if_changed,data,caller);} + static inline bool context_rewrite_info(const pfc::list_base_const_t &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_rewrite_info,data,caller);} + static inline bool context_remove_tags(const pfc::list_base_const_t &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_remove_tags,data,caller);} + static inline bool context_convert_run(const pfc::list_base_const_t &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_convert_run,data,caller);} + static inline bool context_convert_run_singlefile(const pfc::list_base_const_t &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_convert_run_singlefile,data,caller);} + static inline bool context_write_cd(const pfc::list_base_const_t &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_write_cd,data,caller);} + static inline bool context_rg_scan_track(const pfc::list_base_const_t &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_rg_scan_track,data,caller);} + static inline bool context_rg_scan_album(const pfc::list_base_const_t &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_rg_scan_album,data,caller);} + static inline bool context_rg_scan_album_multi(const pfc::list_base_const_t &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_rg_scan_album_multi,data,caller);} + static inline bool context_rg_remove(const pfc::list_base_const_t &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_rg_remove,data,caller);} + static inline bool context_save_playlist(const pfc::list_base_const_t &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_save_playlist,data,caller);} + static inline bool context_masstag_edit(const pfc::list_base_const_t &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_masstag_edit,data,caller);} + static inline bool context_masstag_rename(const pfc::list_base_const_t &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_masstag_rename,data,caller);} + static inline bool main_always_on_top() {return run_main(guid_main_always_on_top);} + static inline bool main_preferences() {return run_main(guid_main_preferences);} + static inline bool main_about() {return run_main(guid_main_about);} + static inline bool main_exit() {return run_main(guid_main_exit);} + static inline bool main_restart() {return run_main(guid_main_restart);} + static inline bool main_activate() {return run_main(guid_main_activate);} + static inline bool main_hide() {return run_main(guid_main_hide);} + static inline bool main_activate_or_hide() {return run_main(guid_main_activate_or_hide);} + static inline bool main_titleformat_help() {return run_main(guid_main_titleformat_help);} + static inline bool main_playback_follows_cursor() {return run_main(guid_main_playback_follows_cursor);} + static inline bool main_next() {return run_main(guid_main_next);} + static inline bool main_previous() {return run_main(guid_main_previous);} + static inline bool main_next_or_random() {return run_main(guid_main_next_or_random);} + static inline bool main_random() {return run_main(guid_main_random);} + static inline bool main_pause() {return run_main(guid_main_pause);} + static inline bool main_play() {return run_main(guid_main_play);} + static inline bool main_play_or_pause() {return run_main(guid_main_play_or_pause);} + static inline bool main_rg_set_album() {return run_main(guid_main_rg_set_album);} + static inline bool main_rg_set_track() {return run_main(guid_main_rg_set_track);} + static inline bool main_rg_disable() {return run_main(guid_main_rg_disable);} + static inline bool main_stop() {return run_main(guid_main_stop);} + static inline bool main_stop_after_current() {return run_main(guid_main_stop_after_current);} + static inline bool main_volume_down() {return run_main(guid_main_volume_down);} + static inline bool main_volume_up() {return run_main(guid_main_volume_up);} + static inline bool main_volume_mute() {return run_main(guid_main_volume_mute);} + static inline bool main_add_directory() {return run_main(guid_main_add_directory);} + static inline bool main_add_files() {return run_main(guid_main_add_files);} + static inline bool main_add_location() {return run_main(guid_main_add_location);} + static inline bool main_add_playlist() {return run_main(guid_main_add_playlist);} + static inline bool main_clear_playlist() {return run_main(guid_main_clear_playlist);} + static inline bool main_create_playlist() {return run_main(guid_main_create_playlist);} + static inline bool main_highlight_playing() {return run_main(guid_main_highlight_playing);} + static inline bool main_load_playlist() {return run_main(guid_main_load_playlist);} + static inline bool main_next_playlist() {return run_main(guid_main_next_playlist);} + static inline bool main_previous_playlist() {return run_main(guid_main_previous_playlist);} + static inline bool main_open() {return run_main(guid_main_open);} + static inline bool main_remove_playlist() {return run_main(guid_main_remove_playlist);} + static inline bool main_remove_dead_entries() {return run_main(guid_main_remove_dead_entries);} + static inline bool main_remove_duplicates() {return run_main(guid_main_remove_duplicates);} + static inline bool main_rename_playlist() {return run_main(guid_main_rename_playlist);} + static inline bool main_save_all_playlists() {return run_main(guid_main_save_all_playlists);} + static inline bool main_save_playlist() {return run_main(guid_main_save_playlist);} + static inline bool main_playlist_search() {return run_main(guid_main_playlist_search);} + static inline bool main_playlist_sel_crop() {return run_main(guid_main_playlist_sel_crop);} + static inline bool main_playlist_sel_remove() {return run_main(guid_main_playlist_sel_remove);} + static inline bool main_playlist_sel_invert() {return run_main(guid_main_playlist_sel_invert);} + static inline bool main_playlist_undo() {return run_main(guid_main_playlist_undo);} + static inline bool main_show_console() {return run_main(guid_main_show_console);} + static inline bool main_play_cd() {return run_main(guid_main_play_cd);} + static inline bool main_restart_resetconfig() {return run_main(guid_main_restart_resetconfig);} + static inline bool main_playlist_moveback() {return run_main(guid_main_playlist_moveback);} + static inline bool main_playlist_moveforward() {return run_main(guid_main_playlist_moveforward);} + static inline bool main_saveconfig() {return run_main(guid_main_saveconfig);} +}; + +namespace fb2k { + // Turn sentence-capitalized into title-capitalized if needed + // No-op on systems using sentence capitalization + void capitalizeMenuLabel( pfc::string_base & inOut ); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/menu_item.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/menu_item.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,62 @@ +#include "foobar2000-sdk-pch.h" +#include "contextmenu.h" +#include "contextmenu_manager.h" +#include "metadb.h" + +bool contextmenu_item::item_get_display_data_root(pfc::string_base & p_out,unsigned & p_displayflags,unsigned p_index,const pfc::list_base_const_t & p_data,const GUID & p_caller) +{ + bool status = false; + pfc::ptrholder_t root ( instantiate_item(p_index,p_data,p_caller) ); + if (root.is_valid()) status = root->get_display_data(p_out,p_displayflags,p_data,p_caller); + return status; +} + + +static contextmenu_item_node * g_find_node(const GUID & p_guid,contextmenu_item_node * p_parent) +{ + if (p_parent->get_guid() == p_guid) return p_parent; + else if (p_parent->get_type() == contextmenu_item_node::TYPE_POPUP) + { + t_size n, m = p_parent->get_children_count(); + for(n=0;nget_child(n)); + if (temp) return temp; + } + return 0; + } + else return 0; +} + +bool contextmenu_item::item_get_display_data(pfc::string_base & p_out,unsigned & p_displayflags,unsigned p_index,const GUID & p_node,const pfc::list_base_const_t & p_data,const GUID & p_caller) +{ + bool status = false; + pfc::ptrholder_t root ( instantiate_item(p_index,p_data,p_caller) ); + if (root.is_valid()) + { + contextmenu_item_node * node = g_find_node(p_node,root.get_ptr()); + if (node) status = node->get_display_data(p_out,p_displayflags,p_data,p_caller); + } + return status; +} + + +GUID contextmenu_item::get_parent_fallback() { + unsigned total = get_num_items(); + if (total < 1) return pfc::guid_null; // hide the item + pfc::string_formatter path, base; this->get_item_default_path(0, base); + for(unsigned walk = 1; walk < total; ++walk) { + this->get_item_default_path(walk, path); + if (strcmp(path, base) != 0) return contextmenu_groups::legacy; + } + return contextmenu_group_manager::get()->path_to_group(base); +} + +GUID contextmenu_item::get_parent_() { + contextmenu_item_v2::ptr v2; + if (service_query_t(v2)) { + return v2->get_parent(); + } else { + return get_parent_fallback(); + } +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/menu_manager.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/menu_manager.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,425 @@ +#include "foobar2000-sdk-pch.h" + +#include "contextmenu_manager.h" +#include "menu_helpers.h" +#include "playlist.h" + +#ifdef WIN32 + +#include "ui_element_typable_window_manager.h" + +static void fix_ampersand(const char * src,pfc::string_base & out) +{ + out.reset(); + unsigned ptr = 0; + while(src[ptr]) + { + if (src[ptr]=='&') + { + out.add_string("&&"); + ptr++; + while(src[ptr]=='&') + { + out.add_string("&&"); + ptr++; + } + } + else out.add_byte(src[ptr++]); + } +} + +static unsigned flags_to_win32(unsigned flags) +{ + unsigned ret = 0; + if (flags & contextmenu_item_node::FLAG_RADIOCHECKED) {/* dealt with elsewhere */} + else if (flags & contextmenu_item_node::FLAG_CHECKED) ret |= MF_CHECKED; + if (flags & contextmenu_item_node::FLAG_DISABLED) ret |= MF_DISABLED; + if (flags & contextmenu_item_node::FLAG_GRAYED) ret |= MF_GRAYED; + return ret; +} + +void contextmenu_manager::win32_build_menu(HMENU menu,contextmenu_node * parent,int base_id,int max_id)//menu item identifiers are base_id<=Nget_type()==contextmenu_item_node::TYPE_POPUP) + { + pfc::string8_fastalloc temp; + t_size child_idx,child_num = parent->get_num_children(); + for(child_idx=0;child_idxget_child(child_idx); + if (child) + { + const char * name = child->get_name(); + if (strchr(name,'&')) {fix_ampersand(name,temp);name=temp;} + contextmenu_item_node::t_type type = child->get_type(); + if (type==contextmenu_item_node::TYPE_POPUP) + { + HMENU new_menu = CreatePopupMenu(); + uAppendMenu(menu,MF_STRING|MF_POPUP | flags_to_win32(child->get_display_flags()),(UINT_PTR)new_menu,name); + win32_build_menu(new_menu,child,base_id,max_id); + } + else if (type==contextmenu_item_node::TYPE_SEPARATOR) + { + uAppendMenu(menu,MF_SEPARATOR,0,0); + } + else if (type==contextmenu_item_node::TYPE_COMMAND) + { + int id = child->get_id(); + if (id>=0 && (max_id<0 || idget_display_flags(); + const UINT ID = base_id+id; + uAppendMenu(menu,MF_STRING | flags_to_win32(flags),ID,name); + if (flags & contextmenu_item_node::FLAG_RADIOCHECKED) CheckMenuRadioItem(menu,ID,ID,ID,MF_BYCOMMAND); + } + } + } + } + } +} + + +bool contextmenu_manager::get_description_by_id(unsigned id,pfc::string_base & out) { + contextmenu_node * ptr = find_by_id(id); + if (ptr == NULL) return false; + return ptr->get_description(out); +} + +void contextmenu_manager::win32_run_menu_popup(HWND parent,const POINT * pt) +{ + enum {ID_CUSTOM_BASE = 1}; + + int cmd; + + { + POINT p; + if (pt) p = *pt; + else GetCursorPos(&p); + + HMENU hmenu = CreatePopupMenu(); + try { + + win32_build_menu(hmenu,ID_CUSTOM_BASE,-1); + menu_helpers::win32_auto_mnemonics(hmenu); + + cmd = TrackPopupMenu(hmenu,TPM_RIGHTBUTTON|TPM_NONOTIFY|TPM_RETURNCMD,p.x,p.y,0,parent,0); + } catch(...) {DestroyMenu(hmenu); throw;} + + DestroyMenu(hmenu); + } + + if (cmd>0) + { + if (cmd>=ID_CUSTOM_BASE) + { + execute_by_id(cmd - ID_CUSTOM_BASE); + } + } +} + +void contextmenu_manager::win32_run_menu_context(HWND parent,const pfc::list_base_const_t & data,const POINT * pt,unsigned flags) +{ + service_ptr_t manager; + contextmenu_manager::g_create(manager); + manager->init_context(data,flags); + manager->win32_run_menu_popup(parent,pt); +} + +void contextmenu_manager::win32_run_menu_context_playlist(HWND parent,const POINT * pt,unsigned flags) +{ + service_ptr_t manager; + contextmenu_manager::g_create(manager); + manager->init_context_playlist(flags); + manager->win32_run_menu_popup(parent,pt); +} + + +namespace { + class mnemonic_manager + { + pfc::string8_fastalloc used; + bool is_used(unsigned c) + { + char temp[8]; + temp[pfc::utf8_encode_char(uCharLower(c),temp)]=0; + return !!strstr(used,temp); + } + + static bool is_alphanumeric(char c) + { + return (c>='a' && c<='z') || (c>='A' && c<='Z') || (c>='0' && c<='9'); + } + + + + + void insert(const char * src,unsigned idx,pfc::string_base & out) + { + out.reset(); + out.add_string(src,idx); + out.add_string("&"); + out.add_string(src+idx); + used.add_char(uCharLower(src[idx])); + } + public: + bool check_string(const char * src) + {//check for existing mnemonics + const char * ptr = src; + for( ;; ) { + ptr = strchr(ptr, '&'); + if (ptr == nullptr) break; + if (ptr[1]=='&') ptr+=2; + else + { + unsigned c = 0; + if (pfc::utf8_decode_char(ptr+1,c)>0) + { + if (!is_used(c)) used.add_char(uCharLower(c)); + } + return true; + } + } + return false; + } + bool process_string(const char * src,pfc::string_base & out)//returns if changed + { + if (check_string(src)) {out=src;return false;} + unsigned idx=0; + while(src[idx]==' ') idx++; + while(src[idx]) + { + if (is_alphanumeric(src[idx]) && !is_used(src[idx])) + { + insert(src,idx,out); + return true; + } + + while(src[idx] && src[idx]!=' ' && src[idx]!='\t') idx++; + if (src[idx]=='\t') break; + while(src[idx]==' ') idx++; + } + + //no success picking first letter of one of words + idx=0; + while(src[idx]) + { + if (src[idx]=='\t') break; + if (is_alphanumeric(src[idx]) && !is_used(src[idx])) + { + insert(src,idx,out); + return true; + } + idx++; + } + + //giving up + out = src; + return false; + } + }; +} + +void menu_helpers::win32_auto_mnemonics(HMENU menu) +{ + PFC_ASSERT(IsMenu(menu)); + mnemonic_manager mgr; + int n, m = GetMenuItemCount(menu); + PFC_ASSERT(m >= 0); + pfc::string8_fastalloc temp,temp2; + for(n=0;n & data,WPARAM wp,const GUID & caller) +{ + if (data.get_count()==0) return false; + return process_keydown_ex(TYPE_CONTEXT,data,get_key_code(wp),caller); +} + +bool keyboard_shortcut_manager::on_keydown_auto(WPARAM wp) +{ + if (on_keydown(TYPE_MAIN,wp)) return true; + if (on_keydown(TYPE_CONTEXT_PLAYLIST,wp)) return true; + if (on_keydown(TYPE_CONTEXT_NOW_PLAYING,wp)) return true; + return false; +} + +bool keyboard_shortcut_manager::on_keydown_auto_playlist(WPARAM wp) +{ + metadb_handle_list data; + playlist_manager::get()->activeplaylist_get_selected_items(data); + return on_keydown_auto_context(data,wp,contextmenu_item::caller_playlist); +} + +bool keyboard_shortcut_manager::on_keydown_auto_context(const pfc::list_base_const_t & data,WPARAM wp,const GUID & caller) +{ + if (on_keydown_context(data,wp,caller)) return true; + else return on_keydown_auto(wp); +} + +static bool should_relay_key_restricted(WPARAM p_key) { + switch(p_key) { + case VK_LEFT: + case VK_RIGHT: + case VK_UP: + case VK_DOWN: + return false; + default: + return (p_key >= VK_F1 && p_key <= VK_F24) || IsKeyPressed(VK_CONTROL) || IsKeyPressed(VK_LWIN) || IsKeyPressed(VK_RWIN); + } +} + +bool keyboard_shortcut_manager::on_keydown_restricted_auto(WPARAM wp) { + if (!should_relay_key_restricted(wp)) return false; + return on_keydown_auto(wp); +} +bool keyboard_shortcut_manager::on_keydown_restricted_auto_playlist(WPARAM wp) { + if (!should_relay_key_restricted(wp)) return false; + return on_keydown_auto_playlist(wp); +} +bool keyboard_shortcut_manager::on_keydown_restricted_auto_context(const pfc::list_base_const_t & data,WPARAM wp,const GUID & caller) { + if (!should_relay_key_restricted(wp)) return false; + return on_keydown_auto_context(data,wp,caller); +} + +static bool filterTypableWindowMessage(const MSG * msg, t_uint32 modifiers) { + if (keyboard_shortcut_manager::is_typing_key_combo((t_uint32)msg->wParam, modifiers)) { + const DWORD mask = DLGC_HASSETSEL | DLGC_WANTCHARS | DLGC_WANTARROWS; + auto status = ::SendMessage(msg->hwnd, WM_GETDLGCODE,0, 0); + if ( (status & mask) == mask ) return false; + + ui_element_typable_window_manager::ptr api; + if (ui_element_typable_window_manager::tryGet(api)) { + if (api->is_registered(msg->hwnd)) return false; + } + } + return true; +} + +bool keyboard_shortcut_manager_v2::pretranslate_message(const MSG * msg, HWND thisPopupWnd) { + switch(msg->message) { + case WM_KEYDOWN: + case WM_SYSKEYDOWN: + if (thisPopupWnd != NULL && FindOwningPopup(msg->hwnd) == thisPopupWnd) { + const t_uint32 modifiers = GetHotkeyModifierFlags(); + if (filterTypableWindowMessage(msg, modifiers)) { + if (process_keydown_simple(get_key_code(msg->wParam,modifiers))) return true; + } + } + return false; + default: + return false; + } +} + +bool keyboard_shortcut_manager::is_text_key(t_uint32 vkCode) { + return vkCode == VK_SPACE + || (vkCode >= '0' && vkCode < 0x40) + || (vkCode > 0x40 && vkCode < VK_LWIN) + || (vkCode >= VK_NUMPAD0 && vkCode <= VK_DIVIDE) + || (vkCode >= VK_OEM_1 && vkCode <= VK_OEM_3) + || (vkCode >= VK_OEM_4 && vkCode <= VK_OEM_8) + ; +} + +bool keyboard_shortcut_manager::is_typing_key(t_uint32 vkCode) { + return is_text_key(vkCode) + || vkCode == VK_BACK + || vkCode == VK_RETURN + || vkCode == VK_INSERT + || (vkCode > VK_SPACE && vkCode < '0'); +} + +bool keyboard_shortcut_manager::is_typing_key_combo(t_uint32 vkCode, t_uint32 modifiers) { + if (!is_typing_modifier(modifiers)) return false; + return is_typing_key(vkCode); +} + +bool keyboard_shortcut_manager::is_typing_modifier(t_uint32 flags) { + flags &= ~MOD_SHIFT; + return flags == 0 || flags == (MOD_ALT | MOD_CONTROL); +} + +bool keyboard_shortcut_manager::is_typing_message(HWND editbox, const MSG * msg) { + if (msg->hwnd != editbox) return false; + return is_typing_message(msg); +} +bool keyboard_shortcut_manager::is_typing_message(const MSG * msg) { + if (msg->message != WM_KEYDOWN && msg->message != WM_SYSKEYDOWN) return false; + return is_typing_key_combo((uint32_t)msg->wParam, GetHotkeyModifierFlags()); +} + +#endif // _WIN32 + +bool contextmenu_manager::execute_by_id(unsigned id) noexcept { + contextmenu_node * ptr = find_by_id(id); + if (ptr == NULL) return false; + ptr->execute(); + return true; +} + +void contextmenu_manager::g_create(service_ptr_t& p_out) { standard_api_create_t(p_out); } +service_ptr_t contextmenu_manager::g_create() { service_ptr_t ret; standard_api_create_t(ret); return ret; } diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/messageBox.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/messageBox.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,42 @@ +#pragma once + +#ifndef _WIN32 +#define IDOK 1 +#define IDCANCEL 2 +#define IDABORT 3 +#define IDRETRY 4 +#define IDIGNORE 5 +#define IDYES 6 +#define IDNO 7 + +#define MB_OK 0x00000000L +#define MB_OKCANCEL 0x00000001L +#define MB_ABORTRETRYIGNORE 0x00000002L +#define MB_YESNOCANCEL 0x00000003L +#define MB_YESNO 0x00000004L +#define MB_RETRYCANCEL 0x00000005L +#define MB_CANCELTRYCONTINUE 0x00000006L + +#define MB_ICONHAND 0x00000010L +#define MB_ICONQUESTION 0x00000020L +#define MB_ICONEXCLAMATION 0x00000030L +#define MB_ICONASTERISK 0x00000040L + +#define MB_DEFBUTTON1 0x00000000L +#define MB_DEFBUTTON2 0x00000100L +#define MB_DEFBUTTON3 0x00000200L +#define MB_DEFBUTTON4 0x00000300L + +#define MB_ICONWARNING MB_ICONEXCLAMATION +#define MB_ICONERROR MB_ICONHAND +#define MB_ICONINFORMATION MB_ICONASTERISK +#define MB_ICONSTOP MB_ICONHAND + +#endif // ! _WIN32 + +namespace fb2k { + // Minimalist MessageBox() drop-in replacement, calls popup_message_v3 method + // Works properly on non-Windows! + int messageBox(fb2k::hwnd_t, const char*, const char*, unsigned); + void messageBoxAsync(fb2k::hwnd_t, const char*, const char*, unsigned, std::function f = nullptr); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/message_loop.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/message_loop.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,86 @@ +#pragma once + +#ifdef _WIN32 +//! A message filter class. Allows you to filter incoming messages in main app loop. Use message_loop API to register/unregister, \n +//! or derive from message_filter_impl_base to have your class registered/deregistered automatically with lifetime. +//! //! Use with caution. Will not be executed during modal loops. +class NOVTABLE message_filter { +public: + //! Notifies you about incoming message. \n + //! You can alter the message (not generally recommended), let others handle it (return false) \n + //! or signal that you've handled it (return true) to suppress further processing. + virtual bool pretranslate_message(MSG * p_msg) = 0; +}; + +//! An idle handler class. Executed when main loop is about to enter idle state. \n +//! Use with caution. Will not be executed during modal loops. +class NOVTABLE idle_handler { +public: + virtual bool on_idle() = 0; +}; + +//! Entrypoint API for registering message_filter and idle_handler objects. \n +//! Usage: message_loop::get()->add_message_filter(myfilter); +class NOVTABLE message_loop : public service_base +{ +public: + virtual void add_message_filter(message_filter * ptr) = 0; + virtual void remove_message_filter(message_filter * ptr) = 0; + + virtual void add_idle_handler(idle_handler * ptr) = 0; + virtual void remove_idle_handler(idle_handler * ptr) = 0; + + FB2K_MAKE_SERVICE_COREAPI(message_loop); +}; + +class NOVTABLE message_loop_v2 : public message_loop { +public: + virtual void add_message_filter_ex(message_filter * ptr, t_uint32 lowest, t_uint32 highest) = 0; + + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(message_loop_v2, message_loop); +}; + +class message_filter_impl_base : public message_filter { +public: + message_filter_impl_base(); + message_filter_impl_base(t_uint32 lowest, t_uint32 highest); + ~message_filter_impl_base(); + + bool pretranslate_message(MSG * ) override {return false;} + + PFC_CLASS_NOT_COPYABLE(message_filter_impl_base,message_filter_impl_base); +}; + +class message_filter_impl_accel : public message_filter_impl_base { +protected: + bool pretranslate_message(MSG * p_msg) override; +public: + message_filter_impl_accel(HINSTANCE p_instance,const TCHAR * p_accel); + void set_wnd(HWND p_wnd) {m_wnd = p_wnd;} +private: + HWND m_wnd = NULL; + win32_accelerator m_accel; + + PFC_CLASS_NOT_COPYABLE(message_filter_impl_accel,message_filter_impl_accel); +}; + +class message_filter_remap_f1 : public message_filter_impl_base { +public: + bool pretranslate_message(MSG * p_msg) override; + void set_wnd(HWND wnd) {m_wnd = wnd;} +private: + static bool IsOurMsg(const MSG * msg) { + return msg->message == WM_KEYDOWN && msg->wParam == VK_F1; + } + HWND m_wnd = NULL; +}; + +class idle_handler_impl_base : public idle_handler { +public: + idle_handler_impl_base() {message_loop::get()->add_idle_handler(this);} + ~idle_handler_impl_base() { message_loop::get()->remove_idle_handler(this);} + bool on_idle() {return true;} + + PFC_CLASS_NOT_COPYABLE_EX(idle_handler_impl_base) +}; +#endif // _WIN32 diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/metadb.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/metadb.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,174 @@ +#include "foobar2000-sdk-pch.h" +#include "metadb.h" +#include "metadb_callbacks.h" +#include "file_info_filter_impl.h" +#include "playback_control.h" +#include "playlist.h" + +void metadb::handle_create_replace_path_canonical(metadb_handle_ptr & p_out,const metadb_handle_ptr & p_source,const char * p_new_path) { + handle_create(p_out,make_playable_location(p_new_path,p_source->get_subsong_index())); +} + +void metadb::handle_create_replace_path(metadb_handle_ptr & p_out,const metadb_handle_ptr & p_source,const char * p_new_path) { + pfc::string8 path; + filesystem::g_get_canonical_path(p_new_path,path); + handle_create_replace_path_canonical(p_out,p_source,path); +} + +void metadb::handle_replace_path_canonical(metadb_handle_ptr & p_out,const char * p_new_path) { + metadb_handle_ptr temp; + handle_create_replace_path_canonical(temp,p_out,p_new_path); + p_out = temp; +} + + +metadb_io::t_load_info_state metadb_io::load_info(metadb_handle_ptr p_item,t_load_info_type p_type,fb2k::hwnd_t p_parent_window,bool p_show_errors) { + return load_info_multi(pfc::list_single_ref_t(p_item),p_type,p_parent_window,p_show_errors); +} + +metadb_io::t_update_info_state metadb_io::update_info(metadb_handle_ptr p_item,file_info & p_info,fb2k::hwnd_t p_parent_window,bool p_show_errors) +{ + file_info * blah = &p_info; + return update_info_multi(pfc::list_single_ref_t(p_item),pfc::list_single_ref_t(blah),p_parent_window,p_show_errors); +} + + +void metadb_io::hint_async(metadb_handle_ptr p_item,const file_info & p_info,const t_filestats & p_stats,bool p_fresh) +{ + const file_info * blargh = &p_info; + hint_multi_async(pfc::list_single_ref_t(p_item),pfc::list_single_ref_t(blargh),pfc::list_single_ref_t(p_stats), pfc::bit_array_val(p_fresh)); +} + + +bool metadb::g_get_random_handle(metadb_handle_ptr & p_out) { + if (playback_control::get()->get_now_playing(p_out)) return true; + + { + auto api = playlist_manager::get(); + + t_size playlist_count = api->get_playlist_count(); + t_size active_playlist = api->get_active_playlist(); + if (active_playlist != ~0) { + if (api->playlist_get_focus_item_handle(p_out,active_playlist)) return true; + } + + for(t_size n = 0; n < playlist_count; n++) { + if (api->playlist_get_focus_item_handle(p_out,n)) return true; + } + + if (active_playlist != ~0) { + t_size item_count = api->playlist_get_item_count(active_playlist); + if (item_count > 0) { + if (api->playlist_get_item_handle(p_out,active_playlist,0)) return true; + } + } + + for(t_size n = 0; n < playlist_count; n++) { + t_size item_count = api->playlist_get_item_count(n); + if (item_count > 0) { + if (api->playlist_get_item_handle(p_out,n,0)) return true; + } + } + } + + return false; +} + + +void metadb_io_v2::update_info_async_simple(const pfc::list_base_const_t & p_list,const pfc::list_base_const_t & p_new_info, fb2k::hwnd_t p_parent_window,t_uint32 p_op_flags,completion_notify_ptr p_notify) { + update_info_async(p_list,new service_impl_t(p_list,p_new_info),p_parent_window,p_op_flags,p_notify); +} + +void metadb_io_v2::on_file_rechaptered( const char * path, metadb_handle_list_cref newItems ) { + PFC_ASSERT(core_api::is_main_thread()); + metadb_handle_list handles( newItems ); + pfc::string8 pathLocal( path ); + auto notify = fb2k::makeCompletionNotify( [handles, pathLocal] (unsigned) { + playlist_manager::get()->on_file_rechaptered( pathLocal, handles ); + } ); + + load_info_async( handles, metadb_io::load_info_force, core_api::get_main_window(), metadb_io_v3::op_flag_delay_ui, notify ); +} + +void metadb_io_v2::on_files_rechaptered( metadb_handle_list_cref newHandles ) { + PFC_ASSERT(core_api::is_main_thread()); + metadb_handle_list local ( newHandles ); + auto notify = fb2k::makeCompletionNotify( [local] (unsigned) { + playlist_manager::get()->on_files_rechaptered(local); + } ); + + load_info_async( newHandles, metadb_io::load_info_force, core_api::get_main_window(), metadb_io_v3::op_flag_delay_ui, notify ); +} + + +metadb_hint_list::ptr metadb_hint_list::create() { + return metadb_io_v2::get()->create_hint_list(); +} + +metadb_hint_list_v2::ptr metadb_hint_list_v2::create() { + metadb_hint_list_v2::ptr ret; + ret ^= metadb_hint_list::create(); + return ret; +} + +metadb_hint_list_v3::ptr metadb_hint_list_v3::create() { + metadb_hint_list_v3::ptr ret; + ret ^= metadb_hint_list::create(); + return ret; +} + +metadb_hint_list_v4::ptr metadb_hint_list_v4::create() { + metadb_hint_list_v4::ptr ret; + ret ^= metadb_hint_list::create(); + return ret; +} + +void metadb_io_callback_dynamic::register_callback() { + PFC_ASSERT(core_api::is_main_thread()); + metadb_io_v3::get()->register_callback(this); +} + +void metadb_io_callback_dynamic::unregister_callback() { + PFC_ASSERT(core_api::is_main_thread()); + metadb_io_v3::get()->unregister_callback(this); +} + +void metadb_io_callback_v2_dynamic::register_callback() { + PFC_ASSERT(core_api::is_main_thread()); + metadb_io_v5::get()->register_callback_v2(this); +} + +void metadb_io_callback_v2_dynamic::unregister_callback() { + PFC_ASSERT(core_api::is_main_thread()); + metadb_io_v5::get()->unregister_callback_v2(this); +} + +bool metadb_io_callback_v2_dynamic::try_register_callback() { + PFC_ASSERT(core_api::is_main_thread()); + auto api = metadb_io_v5::tryGet(); + if (api.is_empty()) return false; + api->register_callback_v2(this); + return true; +} + +void metadb_io_callback_v2_dynamic::try_unregister_callback() { + PFC_ASSERT(core_api::is_main_thread()); + auto api = metadb_io_v5::tryGet(); + if (api.is_valid()) api->unregister_callback_v2(this); +} + +metadb_io_callback_dynamic_impl_base::metadb_io_callback_dynamic_impl_base() { + register_callback(); +} + +metadb_io_callback_dynamic_impl_base::~metadb_io_callback_dynamic_impl_base() { + unregister_callback(); +} + +metadb_io_callback_v2_dynamic_impl_base::metadb_io_callback_v2_dynamic_impl_base() { + register_callback(); +} + +metadb_io_callback_v2_dynamic_impl_base::~metadb_io_callback_v2_dynamic_impl_base() { + unregister_callback(); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/metadb.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/metadb.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,415 @@ +#pragma once + +#include +#include "metadb_handle.h" + +class file_info_filter; // forward decl; file_info_filter moved to file_info_filter.h + +class metadb_io_callback_dynamic; class metadb_io_callback_v2_dynamic; + + +//! API for tag read/write operations. Legal to call from main thread only, except for hint_multi_async() / hint_async() / hint_reader().\n +//! Implemented only by core, do not reimplement.\n +//! Use static_api_ptr_t template to access metadb_io methods.\n +//! WARNING: Methods that perform file access (tag reads/writes) run a modal message loop. They SHOULD NOT be called from global callbacks and such. +class NOVTABLE metadb_io : public service_base +{ +public: + enum t_load_info_type { + load_info_default, + load_info_force, + load_info_check_if_changed + }; + + enum t_update_info_state { + update_info_success, + update_info_aborted, + update_info_errors, + }; + + enum t_load_info_state { + load_info_success, + load_info_aborted, + load_info_errors, + }; + + //! No longer used - returns false always. + FB2K_DEPRECATED virtual bool is_busy() = 0; + //! No longer used - returns false always. + FB2K_DEPRECATED virtual bool is_updating_disabled() = 0; + //! No longer used - returns false always. + FB2K_DEPRECATED virtual bool is_file_updating_blocked() = 0; + //! No longer used. + FB2K_DEPRECATED virtual void highlight_running_process() = 0; + //! Loads tags from multiple items. Use the async version in metadb_io_v2 instead if possible. + FB2K_DEPRECATED virtual t_load_info_state load_info_multi(metadb_handle_list_cref p_list,t_load_info_type p_type,fb2k::hwnd_t p_parent_window,bool p_show_errors) = 0; + //! Updates tags on multiple items. Use the async version in metadb_io_v2 instead if possible. + FB2K_DEPRECATED virtual t_update_info_state update_info_multi(metadb_handle_list_cref p_list,const pfc::list_base_const_t & p_new_info,fb2k::hwnd_t p_parent_window,bool p_show_errors) = 0; + //! Rewrites tags on multiple items. Use the async version in metadb_io_v2 instead if possible. + FB2K_DEPRECATED virtual t_update_info_state rewrite_info_multi(metadb_handle_list_cref p_list,fb2k::hwnd_t p_parent_window,bool p_show_errors) = 0; + //! Removes tags from multiple items. Use the async version in metadb_io_v2 instead if possible. + FB2K_DEPRECATED virtual t_update_info_state remove_info_multi(metadb_handle_list_cref p_list,fb2k::hwnd_t p_parent_window,bool p_show_errors) = 0; + + virtual void hint_multi(metadb_handle_list_cref p_list,const pfc::list_base_const_t & p_infos,const pfc::list_base_const_t & p_stats,const bit_array & p_fresh_mask) = 0; + + virtual void hint_multi_async(metadb_handle_list_cref p_list,const pfc::list_base_const_t & p_infos,const pfc::list_base_const_t & p_stats,const bit_array & p_fresh_mask) = 0; + + virtual void hint_reader(service_ptr_t p_reader,const char * p_path,abort_callback & p_abort) = 0; + + //! For internal use only. + virtual void path_to_handles_simple(const char * p_path, metadb_handle_list_ref p_out) = 0; + + //! Dispatches metadb_io_callback calls with specified items. To be used with metadb_display_field_provider when your component needs specified items refreshed. + virtual void dispatch_refresh(metadb_handle_list_cref p_list) = 0; + + void dispatch_refresh(metadb_handle_ptr const & handle) {dispatch_refresh(pfc::list_single_ref_t(handle));} + + void hint_async(metadb_handle_ptr p_item,const file_info & p_info,const t_filestats & p_stats,bool p_fresh); + + FB2K_DEPRECATED t_load_info_state load_info(metadb_handle_ptr p_item,t_load_info_type p_type,fb2k::hwnd_t p_parent_window,bool p_show_errors); + FB2K_DEPRECATED t_update_info_state update_info(metadb_handle_ptr p_item,file_info & p_info,fb2k::hwnd_t p_parent_window,bool p_show_errors); + + FB2K_MAKE_SERVICE_COREAPI(metadb_io); +}; + +//! Advanced interface for passing infos read from files to metadb backend. Use metadb_io_v2::create_hint_list() to instantiate. \n +//! Thread safety: all methods other than on_done() are intended for worker threads. Instantiate and use the object in a worker thread, call on_done() in main thread to finalize. \n +//! Typical usage pattern: create a hint list (in any thread), hand infos to it from files that you work with (in a worker thread), call on_done() in main thread. \n +class NOVTABLE metadb_hint_list : public service_base { + FB2K_MAKE_SERVICE_INTERFACE(metadb_hint_list,service_base); +public: + //! Helper. + static metadb_hint_list::ptr create(); + //! Adds a hint to the list. + //! @param p_location Location of the item the hint applies to. + //! @param p_info file_info object describing the item. + //! @param p_stats Information about the file containing item the hint applies to. + //! @param p_freshflag Set to true if the info has been directly read from the file, false if it comes from another source such as a playlist file. + virtual void add_hint(metadb_handle_ptr const & p_location,const file_info & p_info,const t_filestats & p_stats,bool p_freshflag) = 0; + //! Reads info from specified info reader instance and adds hints. May throw an exception in case info read has failed. \n + //! If the file has multiple subsongs, info from all the subsongs will be read and pssed to add_hint(). \n + //! Note that an input_info_writer is a subclass of input_info_reader - so any input_info_reader OR input_info_writer is a valid argument for add_hint_reader(). \n + //! This method is often called with your input_info_writer instance after committing tag updates, to notify metadb about altered tags. + virtual void add_hint_reader(const char * p_path,service_ptr_t const & p_reader,abort_callback & p_abort) = 0; + //! Call this when you're done working with this metadb_hint_list instance, to apply hints and dispatch callbacks. \n + //! If you don't call this, all added hints will be ignored. \n + //! As a general rule, you should add as many infos as possible - such as all the tracks involved in some operation that you perform - then call on_done() once. \n + //! on_done() is expensive because it not only updates the metadb, but tells all components about the changes made - refreshes playlists/autoplaylists, library viewers, etc. \n + //! Calling on_done() repeatedly is inefficient and should be avoided. + virtual void on_done() = 0; +}; + +//! \since 1.0 +//! To obtain metadb_hint_list_v2, use service_query on a metadb_hint_list object. \n +//! Simplified: metadb_hint_list_v2::ptr v2; v2 ^= myHintList; ( causes bugcheck if old fb2k / no interface ). +class NOVTABLE metadb_hint_list_v2 : public metadb_hint_list { + FB2K_MAKE_SERVICE_INTERFACE(metadb_hint_list_v2, metadb_hint_list); +public: + //! Helper. + static metadb_hint_list_v2::ptr create(); + //! Hint with browse info. \n + //! See: metadb_handle::get_browse_info() for browse info rationale. + //! @param p_location Location for which we're providing browse info. + //! @param p_info Browse info for this location. + //! @param browseTS timestamp of the browse info - such as last-modified time of the playlist file providing browse info. + virtual void add_hint_browse(metadb_handle_ptr const & p_location,const file_info & p_info, t_filetimestamp browseTS) = 0; +}; + +//! \since 1.3 +//! To obtain metadb_hint_list_v3, use service_query on a metadb_hint_list object. \n +//! Simplified: metadb_hint_list_v3::ptr v3; v3 ^= myHintList; ( causes bugcheck if old fb2k / no interface ). +class NOVTABLE metadb_hint_list_v3 : public metadb_hint_list_v2 { + FB2K_MAKE_SERVICE_INTERFACE(metadb_hint_list_v3, metadb_hint_list_v2); +public: + //! Helper. + static metadb_hint_list_v3::ptr create(); + //! Hint primary info with a metadb_info_container. + virtual void add_hint_v3(metadb_handle_ptr const & p_location, metadb_info_container::ptr info,bool p_freshflag) = 0; + //! Hint browse info with a metadb_info_container. + virtual void add_hint_browse_v3(metadb_handle_ptr const & p_location,metadb_info_container::ptr info) = 0; + + //! Add a forced hint.\n + //! A normal hint may or may not cause metadb update - metadb is not updated if the file has not changed according to last modified time. \n + //! A forced hint always updates metadb regardless of timestamps. + virtual void add_hint_forced(metadb_handle_ptr const & p_location, const file_info & p_info,const t_filestats & p_stats,bool p_freshflag) = 0; + //! Add a forced hint, with metadb_info_container. \n + //! Forced hint rationale - see add_hint_forced(). + virtual void add_hint_forced_v3(metadb_handle_ptr const & p_location, metadb_info_container::ptr info,bool p_freshflag) = 0; + //! Adds a forced hint, with an input_info_reader. \n + //! Forced hint rationale - see add_hint_forced(). \n + //! Info reader use rationale - see add_hint_reader(). + virtual void add_hint_forced_reader(const char * p_path,service_ptr_t const & p_reader,abort_callback & p_abort) = 0; +}; + +//! \since 2.0 +//! Allows dispatching of metadb_io_edit_callback from your code. +class NOVTABLE metadb_hint_list_v4 : public metadb_hint_list_v3 { + FB2K_MAKE_SERVICE_INTERFACE( metadb_hint_list_v4, metadb_hint_list_v3 ); +public: + static metadb_hint_list_v4::ptr create(); + + virtual void before_edit( const char * path, service_ptr_t reader, abort_callback & a ) = 0; + virtual void after_edit( const char * path, service_ptr_t reader, abort_callback & a ) = 0; + +}; + + +//! New in 0.9.3. Extends metadb_io functionality with nonblocking versions of tag read/write functions, and some other utility features. +class NOVTABLE metadb_io_v2 : public metadb_io { +public: + enum { + //! By default, when some part of requested operation could not be performed for reasons other than user abort, a popup dialog with description of the problem is spawned.\n + //! Set this flag to disable error notification. + op_flag_no_errors = 1 << 0, + //! Set this flag to make the progress dialog not steal focus on creation. + op_flag_background = 1 << 1, + //! Set this flag to delay the progress dialog becoming visible, so it does not appear at all during short operations. Also implies op_flag_background effect. + op_flag_delay_ui = 1 << 2, + + //! \since 1.3 + //! Indicates that the caller is aware of the metadb partial info feature introduced at v1.3. + //! When not specified, affected info will be quietly preserved when updating tags. + //! Obsolete in 2.0 + op_flag_partial_info_aware = 1 << 3, + + //! \since 2.0 + //! Do not show any user interface. + op_flag_silent = 1 << 4, + + //! \since 2.0 + op_flag_detect_rechapter = 1 << 5, + }; + + //! Preloads information from the specified tracks. \n + //! Use from main thread only (starts a threaded_process to show a progress dialog). + //! @param p_list List of items to process. + //! @param p_op_flags Can be null, or one or more of op_flag_* enum values combined, altering behaviors of the operation. + //! @param p_notify Called when the task is completed. Status code is one of t_load_info_state values. Can be null if caller doesn't care. + virtual void load_info_async(metadb_handle_list_cref p_list,t_load_info_type p_type,fb2k::hwnd_t p_parent_window,t_uint32 p_op_flags,completion_notify_ptr p_notify) = 0; + //! Updates tags of the specified tracks. \n + //! Use from main thread only (starts a threaded_process to show a progress dialog). + //! @param p_list List of items to process. + //! @param p_op_flags Can be null, or one or more of op_flag_* enum values combined, altering behaviors of the operation. + //! @param p_notify Called when the task is completed. Status code is one of t_update_info values. Can be null if caller doesn't care. + //! @param p_filter Callback handling actual file_info alterations. Typically used to replace entire meta part of file_info, or to alter something else such as ReplayGain while leaving meta intact. + virtual void update_info_async(metadb_handle_list_cref p_list,service_ptr_t p_filter,fb2k::hwnd_t p_parent_window,t_uint32 p_op_flags,completion_notify_ptr p_notify) = 0; + //! Rewrites tags of the specified tracks; similar to update_info_async() but using last known/cached file_info values rather than values passed by caller. \n + //! Use from main thread only (starts a threaded_process to show a progress dialog). + //! @param p_list List of items to process. + //! @param p_op_flags Can be null, or one or more of op_flag_* enum values combined, altering behaviors of the operation. + //! @param p_notify Called when the task is completed. Status code is one of t_update_info values. Can be null if caller doesn't care. + virtual void rewrite_info_async(metadb_handle_list_cref p_list,fb2k::hwnd_t p_parent_window,t_uint32 p_op_flags,completion_notify_ptr p_notify) = 0; + //! Strips all tags / metadata fields from the specified tracks. \n + //! Use from main thread only (starts a threaded_process to show a progress dialog). + //! @param p_list List of items to process. + //! @param p_op_flags Can be null, or one or more of op_flag_* enum values combined, altering behaviors of the operation. + //! @param p_notify Called when the task is completed. Status code is one of t_update_info values. Can be null if caller doesn't care. + virtual void remove_info_async(metadb_handle_list_cref p_list,fb2k::hwnd_t p_parent_window,t_uint32 p_op_flags,completion_notify_ptr p_notify) = 0; + + //! Creates a metadb_hint_list object. \n + //! Contrary to other metadb_io methods, this can be safely called in a worker thread. You only need to call the hint list's on_done() method in main thread to finalize. + virtual metadb_hint_list::ptr create_hint_list() = 0; + + //! Updates tags of the specified tracks. Helper; uses update_info_async internally. \n + //! Use from main thread only (starts a threaded_process to show a progress dialog). + //! @param p_list List of items to process. + //! @param p_op_flags Can be null, or one or more of op_flag_* enum values combined, altering behaviors of the operation. + //! @param p_notify Called when the task is completed. Status code is one of t_update_info values. Can be null if caller doesn't care. + //! @param p_new_info New infos to write to specified items. + void update_info_async_simple(metadb_handle_list_cref p_list,const pfc::list_base_const_t & p_new_info, fb2k::hwnd_t p_parent_window,t_uint32 p_op_flags,completion_notify_ptr p_notify); + + //! Helper to be called after a file has been rechaptered. \n + //! Forcibly reloads info then tells playlist_manager to update all affected playlists. \n + //! Call from main thread only. + void on_file_rechaptered( const char * path, metadb_handle_list_cref newItems ); + //! Helper to be called after a file has been rechaptered. \n + //! Forcibly reloads info then tells playlist_manager to update all affected playlists. \n + //! Call from main thread only. + void on_files_rechaptered( metadb_handle_list_cref newHandles ); + + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(metadb_io_v2,metadb_io); +}; + + +//! \since 0.9.5 +class NOVTABLE metadb_io_v3 : public metadb_io_v2 { +public: + //! Registers a callback object to receive notifications about metadb_io operations. \n + //! See: metadb_io_callback_dynamic \n + //! Call from main thread only. + virtual void register_callback(metadb_io_callback_dynamic * p_callback) = 0; + //! Unregisters a callback object to receive notifications about metadb_io operations. \n + //! See: metadb_io_callback_dynamic \n + //! Call from main thread only. + virtual void unregister_callback(metadb_io_callback_dynamic * p_callback) = 0; + + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(metadb_io_v3,metadb_io_v2); +}; + + +class threaded_process_callback; + +//! \since 1.5 +class NOVTABLE metadb_io_v4 : public metadb_io_v3 { + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(metadb_io_v4, metadb_io_v3); +public: + //! Creates an update-info task, that can be either fed to threaded_process API, or invoked by yourself respecting threaded_process semantics. \n + //! May return null pointer if the operation has been refused (by user settings or such). \n + //! Useful for performing the operation with your own in-dialog progress display instead of the generic progress popup. \n + //! Main thread only. + virtual service_ptr_t spawn_update_info( metadb_handle_list_cref items, service_ptr_t p_filter, uint32_t opFlags, completion_notify_ptr reply ) = 0; + //! Creates an remove-info task, that can be either fed to threaded_process API, or invoked by yourself respecting threaded_process semantics. \n + //! May return null pointer if the operation has been refused (by user settings or such). \n + //! Useful for performing the operation with your own in-dialog progress display instead of the generic progress popup. \n + //! Main thread only. + virtual service_ptr_t spawn_remove_info( metadb_handle_list_cref items, uint32_t opFlags, completion_notify_ptr reply) = 0; + //! Creates an load-info task, that can be either fed to threaded_process API, or invoked by yourself respecting threaded_process semantics. \n + //! May return null pointer if the operation has been refused (for an example no loading is needed for these items). \n + //! Useful for performing the operation with your own in-dialog progress display instead of the generic progress popup. \n + //! Main thread only. + virtual service_ptr_t spawn_load_info( metadb_handle_list_cref items, t_load_info_type opType, uint32_t opFlags, completion_notify_ptr reply) = 0; +}; + +// \since 2.0 +class NOVTABLE metadb_io_v5 : public metadb_io_v4 { + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(metadb_io_v5, metadb_io_v4); +public: + //! Register a metadb_io_callback_v2_dynamic object to receive notifications about metadb_io events. \n + //! Main thread only. + virtual void register_callback_v2(metadb_io_callback_v2_dynamic*) = 0; + //! Unregister a metadb_io_callback_v2_dynamic object. \n + //! Main thread only. + virtual void unregister_callback_v2(metadb_io_callback_v2_dynamic*) = 0; +}; + + +//! Entrypoint service for metadb_handle related operations.\n +//! Implemented only by core, do not reimplement.\n +//! Use metadb::get() to obtain an instance. +class NOVTABLE metadb : public service_base +{ +protected: + //! OBSOLETE, DO NOT CALL + virtual void database_lock()=0; + //! OBSOLETE, DO NOT CALL + virtual void database_unlock()=0; +public: + + //! Returns a metadb_handle object referencing the specified location. If one doesn't exist yet a new one is created. There can be only one metadb_handle object referencing specific location. \n + //! This function should never fail unless there's something critically wrong (can't allocate memory for the new object, etc). \n + //! Speed: O(log(n)) to total number of metadb_handles present. It's recommended to pass metadb_handles around whenever possible rather than pass playable_locations then retrieve metadb_handles on demand when needed. + //! @param p_out Receives the metadb_handle pointer. + //! @param p_location Location to create a metadb_handle for. + virtual void handle_create(metadb_handle_ptr & p_out,const playable_location & p_location)=0; + + void handle_create_replace_path_canonical(metadb_handle_ptr & p_out,const metadb_handle_ptr & p_source,const char * p_new_path); + void handle_replace_path_canonical(metadb_handle_ptr & p_out,const char * p_new_path); + void handle_create_replace_path(metadb_handle_ptr & p_out,const metadb_handle_ptr & p_source,const char * p_new_path); + + //! Helper function; attempts to retrieve a handle to any known playable location to be used for e.g. titleformatting script preview.\n + //! @returns True on success; false on failure (no known playable locations). + static bool g_get_random_handle(metadb_handle_ptr & p_out); + + enum {case_sensitive = playable_location::case_sensitive}; + typedef playable_location::path_comparator path_comparator; + + inline static int path_compare_ex(const char * p1,t_size len1,const char * p2,t_size len2) {return case_sensitive ? pfc::strcmp_ex(p1,len1,p2,len2) : stricmp_utf8_ex(p1,len1,p2,len2);} + inline static int path_compare_nc(const char * p1, size_t len1, const char * p2, size_t len2) {return case_sensitive ? pfc::strcmp_nc(p1,len1,p2,len2) : stricmp_utf8_ex(p1,len1,p2,len2);} + inline static int path_compare(const char * p1,const char * p2) {return case_sensitive ? strcmp(p1,p2) : stricmp_utf8(p1,p2);} + inline static int path_compare_metadb_handle(const metadb_handle_ptr & p1,const metadb_handle_ptr & p2) {return path_compare(p1->get_path(),p2->get_path());} + + metadb_handle_ptr handle_create(playable_location const & l) {metadb_handle_ptr temp; handle_create(temp, l); return temp;} + metadb_handle_ptr handle_create(const char * path, uint32_t subsong) {return handle_create(make_playable_location(path, subsong));} + + FB2K_MAKE_SERVICE_COREAPI(metadb); +}; + + + + +//! \since 2.0 +class metadb_v2 : public metadb { + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(metadb_v2, metadb); +public: + typedef metadb_v2_rec_t rec_t; + + //! Query info record by location, bypassing metadb_handle layer. + virtual rec_t query(playable_location const& loc) = 0; + + //! Callback class for queryMulti(). See metadb_v2::queryMulti(). + class queryMultiCallback_t { + public: + virtual void onInfo(size_t idx, const rec_t& rec) = 0; + }; + //! Callback class for queryMultiParallel(). See metadb_v2::queryMultiParallel(). + class queryMultiParallelCallback_t { + public: + virtual void* initThreadContext() { return nullptr; } + virtual void onInfo(size_t idx, const rec_t& rec, void * ctx) = 0; + virtual void clearThreadContext(void*) {} + }; + + //! Optimized multi-item metadb info query. Supply a callback to receive info records for all requested tracks. \n + //! This is considerably faster than reading info records one by one, batch database queries are used to speed operation up. \n + //! The infos may come in different order than requested - pay attention to idx argument of callback's onInfo(). \n + //! See also: queryMulti_(), using a lambda instead of a callback object. + virtual void queryMulti(metadb_handle_list_cref items, queryMultiCallback_t& cb) = 0; + + //! Multi-thread optimized version of queryMulti(). \n + //! Faster if used with thousands of items, needs the callback to handle concurrent calls from many threads. \n + //! See also: queryMultiParallel_() and queryMultiParallelEx_(), helpers using lambdas and classes to implement the callback for you. + virtual void queryMultiParallel(metadb_handle_list_cref items, queryMultiParallelCallback_t& cb) = 0; + + //! Format title without database access, use preloaded metadb v2 record. + virtual void formatTitle_v2( const metadb_handle_ptr & handle, const rec_t & rec, titleformat_hook* p_hook, pfc::string_base& p_out, const service_ptr_t& p_script, titleformat_text_filter* p_filter) = 0; + + //! Helper around queryMulti(). Implements callback for you using passed lambda. + void queryMulti_(metadb_handle_list_cref items, std::function< void(size_t idx, const rec_t& rec) > f) { + class qmc_impl : public queryMultiCallback_t { + public: + void onInfo(size_t idx, const rec_t& rec) override { m_f(idx, rec); } + decltype(f) m_f; + }; + qmc_impl cb; cb.m_f = f; + this->queryMulti(items, cb); + } + + //! Simplified helper around queryMultiParallel(). No per-thread data object used. Implements callback for you using passed labmda. + void queryMultiParallel_(metadb_handle_list_cref items, std::function< void(size_t, const rec_t&) > f) { + class qmc_impl : public queryMultiParallelCallback_t { + public: + void onInfo(size_t idx, const rec_t& rec, void*) override {m_f(idx, rec);} + + decltype(f) m_f; + }; + qmc_impl cb; cb.m_f = f; + this->queryMultiParallel(items, cb); + } + + //! Simplified helper around queryMultiParallel(). \n + //! instance_t implements per-thread context data, one will be created in each worker threads. \n + //! While lambda itself will be called from many threads at once, only one instance_t will be used in each thread, so instance_t can be accessed without thread safety measures. + template void queryMultiParallelEx_(metadb_handle_list_cref items, std::function f) { + class qmc_impl : public queryMultiParallelCallback_t { + public: + void* initThreadContext() override {return reinterpret_cast(new instance_t);} + void onInfo(size_t idx, const rec_t& rec, void* ctx) override { m_f(idx, rec, * reinterpret_cast(ctx)); } + void clearThreadContext(void* ctx) override { delete reinterpret_cast(ctx); } + + decltype(f) m_f; + }; + qmc_impl cb; cb.m_f = f; + this->queryMultiParallel(items, cb); + } + + //! Simplified helper for retrieving info of multiple tracks efficiently. \n + //! Uses the fastest way to pull info from thousands of tracks - queryMultiParallel(). \n + //! Keep in mind that it results in all affected info becoming loaded into application memory at once. \n + //! If possible, use methods with callbacks/lambdas instead and process info in callbacks instead of keeping it. + pfc::array_t queryMultiSimple(metadb_handle_list_cref items) { + pfc::array_t ret; + ret.resize(items.get_count()); + this->queryMultiParallel_(items, [&](size_t idx, const rec_t& rec) {ret[idx] = rec;}); + return ret; + } +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/metadb_callbacks.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/metadb_callbacks.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,105 @@ +#pragma once +#include "callback_merit.h" + +//! Callback service receiving notifications about metadb contents changes. +class NOVTABLE metadb_io_callback : public service_base { +public: + //! Called when metadb contents change. (Or, one of display hook component requests display update). \n + //! Main thread only. + //! @param p_items_sorted List of items that have been updated. The list is always sorted by pointer value, to allow fast bsearch to test whether specific item has changed. + //! @param p_fromhook Set to true when actual file contents haven't changed but one of metadb_display_field_provider implementations requested an update so output of metadb_handle::format_title() etc has changed. + virtual void on_changed_sorted(metadb_handle_list_cref p_items_sorted, bool p_fromhook) = 0; + + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(metadb_io_callback); +}; + +//! Dynamically-registered version of metadb_io_callback. See metadb_io_callback for documentation, register instances using metadb_io_v3::register_callback(). It's recommended that you use the metadb_io_callback_dynamic_impl_base helper class to manage registration/unregistration. +class NOVTABLE metadb_io_callback_dynamic { +public: + //! See metadb_io_callback::on_changed_sorted() + virtual void on_changed_sorted(metadb_handle_list_cref p_items_sorted, bool p_fromhook) = 0; + + void register_callback(); void unregister_callback(); + +}; + +//! metadb_io_callback_dynamic implementation helper. +class metadb_io_callback_dynamic_impl_base : public metadb_io_callback_dynamic { +public: + void on_changed_sorted(metadb_handle_list_cref p_items_sorted, bool p_fromhook) override { (void)p_items_sorted; (void)p_fromhook; } + + metadb_io_callback_dynamic_impl_base(); + ~metadb_io_callback_dynamic_impl_base(); + + PFC_CLASS_NOT_COPYABLE_EX(metadb_io_callback_dynamic_impl_base) +}; + +//! \since 1.1 +//! Callback service receiving notifications about user-triggered tag edits. \n +//! You want to use metadb_io_callback instead most of the time, unless you specifically want to track tag edits for purposes other than updating user interface. +class NOVTABLE metadb_io_edit_callback : public service_base { + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(metadb_io_edit_callback) +public: + //! Called after the user has edited tags on a set of files. + typedef const pfc::list_base_const_t& t_infosref; + virtual void on_edited(metadb_handle_list_cref items, t_infosref before, t_infosref after) = 0; +}; + +//! \since 2.0 +class NOVTABLE metadb_io_edit_callback_v2 : public metadb_io_edit_callback { + FB2K_MAKE_SERVICE_INTERFACE(metadb_io_edit_callback_v2, metadb_io_edit_callback) +public: + //! With original on_edited(), the implementation could not tell what the info in metadb was before, 'before' parameter being actual infos freshly read from the file prior to writing. \n + //! on_edited_v2() clarifies this, additional argument passes old metadb state to deal with cases where it was different than file contents. + virtual void on_edited_v2(metadb_handle_list_cref items, t_infosref before, t_infosref after, t_infosref beforeInMetadb) = 0; +}; + +//! \since 2.0 +//! Parameter for on_changed_sorted_v2() +class NOVTABLE metadb_io_callback_v2_data { +public: + virtual metadb_v2_rec_t get(size_t idxInList) = 0; + metadb_v2_rec_t operator[](size_t i) { return get(i); } +}; + +//! \since 2.0 +//! Extended version of metadb_io_callback. +class NOVTABLE metadb_io_callback_v2 : public metadb_io_callback { + FB2K_MAKE_SERVICE_INTERFACE(metadb_io_callback_v2, metadb_io_callback); +public: + virtual void on_changed_sorted_v2(metadb_handle_list_cref itemsSorted, metadb_io_callback_v2_data & data, bool bFromHook) = 0; + //! Controls callback merit, see: fb2k::callback_merit_t + virtual fb2k::callback_merit_t get_callback_merit() { return fb2k::callback_merit_default; } +}; + +//! \since 2.0 +//! NEW interface introduced in late 2.0. \n +//! Invoked *BEFORE* actual update, with incoming info. \n +//! Note that incoming info may be partial (either main info or browse info not set), in such cases the info will remain unchanged. +class NOVTABLE metadb_pre_update_callback : public service_base { + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT( metadb_pre_update_callback ); +public: + virtual void will_update( metadb_handle_list_cref itemsSorted, metadb_io_callback_v2_data & data) = 0; +}; + +//! \since 2.0 +//! Extended version of metadb_io_callback_dynamic. +class NOVTABLE metadb_io_callback_v2_dynamic { +public: + virtual void on_changed_sorted_v2(metadb_handle_list_cref itemsSorted, metadb_io_callback_v2_data & data, bool bFromHook) = 0; + //! Controls callback merit, see: fb2k::callback_merit_t + virtual fb2k::callback_merit_t get_callback_merit() { return fb2k::callback_merit_default; } + + bool try_register_callback(); void try_unregister_callback(); + void register_callback(); void unregister_callback(); +}; + +class metadb_io_callback_v2_dynamic_impl_base : public metadb_io_callback_v2_dynamic { +public: + void on_changed_sorted_v2(metadb_handle_list_cref itemsSorted, metadb_io_callback_v2_data& data, bool bFromHook) override { (void)itemsSorted; (void)data; (void)bFromHook; } + + metadb_io_callback_v2_dynamic_impl_base(); + ~metadb_io_callback_v2_dynamic_impl_base(); + + PFC_CLASS_NOT_COPYABLE_EX(metadb_io_callback_v2_dynamic_impl_base) +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/metadb_display_field_provider.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/metadb_display_field_provider.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,44 @@ +#pragma once + +class titleformat_text_out; +class titleformat_hook_function_params; + + +/*! + Implementing this service lets you provide your own title-formatting fields that are parsed globally with each call to metadb_handle::format_title methods. \n + Note that this API is meant to allow you to add your own component-specific fields - not to overlay your data over standard fields or over fields provided by other components. Any attempts to interfere with standard fields will have severe ill effects. \n + This should be implemented only where absolutely necessary, for safety and performance reasons. Any expensive operations inside the process_field() method may severely damage performance of affected title-formatting calls. \n + You must NEVER make any other foobar2000 API calls from inside process_field, other than possibly querying information from the passed metadb_handle pointer; you should read your own implementation-specific private data and return as soon as possible. You must not make any assumptions about calling context (threading etc). \n + It is guaranteed that process_field() is called only inside a metadb lock scope so you can safely call "locked" metadb_handle methods on the metadb_handle pointer you get. You must not lock metadb by yourself inside process_field() - while it is always called from inside a metadb lock scope, it may be called from another thread than the one maintaining the lock because of multi-CPU optimizations active. \n + If there are multiple metadb_display_field_provider services registered providing fields of the same name, the behavior is undefined. You must pick unique names for provided fields to ensure safe coexistence with other people's components. \n + IMPORTANT: Any components implementing metadb_display_field_provider MUST call metadb_io::dispatch_refresh() with affected metadb_handles whenever info that they present changes. Otherwise, anything rendering title-formatting strings that reference your data will not update properly, resulting in unreliable/broken output, repaint glitches, etc. \n + Do not expect a process_field() call each time somebody uses title formatting, calling code might perform its own caching of strings that you return, getting new ones only after metadb_io::dispatch_refresh() with relevant items. \n + If you can't reliably notify other components about changes of content of fields that you provide (such as when your fields provide some kind of global information and not information specific to item identified by passed metadb_handle), you should not be providing those fields in first place. You must not change returned values of your fields without dispatching appropriate notifications. \n + Use static service_factory_single_t to register your metadb_display_field_provider implementations. Do not call other people's metadb_display_field_provider services directly, they're meant to be called by backend only. \n + List of fields that you provide is expected to be fixed at run-time. The backend will enumerate your fields only once and refer to them by indexes later. \n +*/ + +class NOVTABLE metadb_display_field_provider : public service_base { +public: + //! Returns number of fields provided by this metadb_display_field_provider implementation. + virtual t_uint32 get_field_count() = 0; + //! Returns name of specified field provided by this metadb_display_field_provider implementation. Names are not case sensitive. It's strongly recommended that you keep your field names plain English / ASCII only. + virtual void get_field_name(t_uint32 index, pfc::string_base& out) = 0; + //! Evaluates the specified field. + //! @param index Index of field being processed : 0 <= index < get_field_count(). + //! @param handle Handle to item being processed. You can safely call "locked" methods on this handle to retrieve track information and such. + //! @param out Interface receiving your text output. + //! @returns Return true to indicate that the field is present so if it's enclosed in square brackets, contents of those brackets should not be skipped, false otherwise. + virtual bool process_field(t_uint32 index, metadb_handle* handle, titleformat_text_out* out) = 0; + + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(metadb_display_field_provider); +}; + + +//! \since 2.0 +//! metadb_display_field_provider with caller-supplied metadb record to reduce the number of database queries. +class metadb_display_field_provider_v2 : public metadb_display_field_provider { + FB2K_MAKE_SERVICE_INTERFACE(metadb_display_field_provider_v2, metadb_display_field_provider) +public: + virtual bool process_field_v2(t_uint32 index, metadb_handle* handle, metadb_v2::rec_t const& rec, titleformat_text_out* out) = 0; +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/metadb_handle.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/metadb_handle.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,193 @@ +#include "foobar2000-sdk-pch.h" +#include "titleformat.h" +#include "file_info_impl.h" +#include "input.h" + +double metadb_handle::get_length() +{ + return this->get_info_ref()->info().get_length(); +} + +t_filetimestamp metadb_handle::get_filetimestamp() +{ + return get_filestats().m_timestamp; +} + +t_filesize metadb_handle::get_filesize() +{ + return get_filestats().m_size; +} + +bool metadb_handle::format_title_legacy(titleformat_hook * p_hook,pfc::string_base & p_out,const char * p_spec,titleformat_text_filter * p_filter) +{ + service_ptr_t script; + if (titleformat_compiler::get()->compile(script,p_spec)) { + return format_title(p_hook,p_out,script,p_filter); + } else { + p_out.reset(); + return false; + } +} + + +bool metadb_handle::g_should_reload_ex(const t_filestats& p_old_stats, const t_filestats& p_new_stats, t_filetimestamp p_readtime) { + if (p_new_stats.m_timestamp == filetimestamp_invalid) { + return p_readtime != filetimestamp_invalid;//SNAFU: some locations don't have timestamps at all, let's always accept hints for those when readtime is valid + } else if (p_old_stats.m_timestamp == filetimestamp_invalid) { + return true; + } else if (p_new_stats.m_timestamp > p_old_stats.m_timestamp) { + return true; + } else if (p_new_stats.m_timestamp < p_old_stats.m_timestamp) { + //special case - file has possibly been replaced with older version - check read time + if (p_readtime == filetimestamp_invalid) return false; + else return p_readtime > p_old_stats.m_timestamp; + } else {//timestamps match + return false; + } +} +bool metadb_handle::g_should_reload(const t_filestats & p_old_stats,const t_filestats & p_new_stats,bool p_fresh) +{ + if (p_new_stats.m_timestamp == filetimestamp_invalid) return p_fresh; + else if (p_fresh) return p_old_stats!= p_new_stats; + else return p_old_stats.m_timestamp < p_new_stats.m_timestamp; +} + +bool metadb_handle::should_reload(const t_filestats & p_new_stats, bool p_fresh) const +{ + if (!is_info_loaded_async()) return true; + else return g_should_reload(get_filestats(),p_new_stats,p_fresh); +} + + +bool metadb_handle::get_browse_info_merged(file_info & infoMerged) const { + bool rv = true; + metadb_info_container::ptr info, browse; + this->get_browse_info_ref(info, browse); + if (info.is_valid() && browse.is_valid()) { + infoMerged = info->info(); + infoMerged.merge_fallback( browse->info() ); + } else if (info.is_valid()) { + infoMerged = info->info(); + } else if (browse.is_valid()) { + infoMerged = browse->info(); + } else { + infoMerged.reset(); + rv = false; + } + return rv; +} + +namespace { + class metadb_info_container_impl : public metadb_info_container { + public: + metadb_info_container_impl() : m_stats( filestats_invalid ), m_partial() {} + file_info const & info() { + return m_info; + } + t_filestats const & stats() { + return m_stats; + } + bool isInfoPartial() { + return m_partial; + } + + file_info_impl m_info; + t_filestats m_stats; + bool m_partial; + + }; +} + +metadb_info_container::ptr metadb_handle::get_full_info_ref( abort_callback & aborter ) const { + { + metadb_info_container::ptr info; + if (this->get_info_ref( info ) ) { + if (!info->isInfoPartial()) return info; + } + } + + + input_info_reader::ptr reader; + input_entry::g_open_for_info_read( reader, NULL, this->get_path(), aborter ); + + service_ptr_t< metadb_info_container_impl > obj = new service_impl_t(); + obj->m_stats = reader->get_file_stats( aborter ); + reader->get_info( this->get_subsong_index(), obj->m_info, aborter ); + return obj; +} + +t_filestats2 metadb_info_container::stats2_() { + t_filestats2 ret; + metadb_info_container_v2::ptr v2; + if (v2 &= this) ret = v2->stats2(); + else { + auto & s = this->stats(); + ret.m_size = s.m_size; + ret.m_timestamp = s.m_timestamp; + } + return ret; +} + +namespace fb2k { + pfc::string_formatter formatTrackList( metadb_handle_list_cref lst ) { + pfc::string_formatter ret; + auto cnt = lst.get_count(); + if ( cnt == 0 ) ret << "[Empty track list]\n"; + else { + if (cnt == 1) ret << "[Track list: 1 track]\n"; + else ret << "[Track list: " << cnt << " tracks]\n"; + for( size_t walk = 0; walk < cnt; ++ walk ) { + ret << " " << lst[walk]->get_location() << "\n"; + } + ret << "[Track list end]"; + } + return ret; + } + pfc::string_formatter formatTrackTitle(metadb_handle_ptr item, const char * script ) { + pfc::string_formatter ret; + item->format_title_legacy(NULL,ret,script,NULL); + return ret; + } + pfc::string_formatter formatTrackTitle(metadb_handle_ptr item,service_ptr_t script) { + pfc::string_formatter ret; + item->format_title(NULL,ret,script,NULL); + return ret; + } +} + +t_filestats2 metadb_handle::get_stats2_() const { + metadb_handle_v2::ptr v2; + if (v2 &= const_cast(this)) return v2->get_stats2(); + else return t_filestats2::from_legacy(this->get_filestats()); +} + +metadb_v2_rec_t metadb_handle::query_v2_() { +#if FOOBAR2000_TARGET_VERSION >= 81 + return static_cast(this)->query_v2(); +#else + metadb_handle_v2::ptr v2; + if (v2 &= this) return v2->query_v2(); + + metadb_v2_rec_t ret; + this->get_browse_info_ref(ret.info, ret.infoBrowse); + return ret; +#endif +} + +void metadb_handle::formatTitle_v2_(const metadb_v2_rec_t& rec, titleformat_hook* p_hook, pfc::string_base& p_out, const service_ptr_t& p_script, titleformat_text_filter* p_filter) { +#if FOOBAR2000_TARGET_VERSION >= 81 + static_cast(this)->formatTitle_v2(rec, p_hook, p_out, p_script, p_filter); +#else + metadb_handle_v2::ptr v2; + if (v2 &= this) { + v2->formatTitle_v2(rec, p_hook, p_out, p_script, p_filter); return; + } + + // closest approximate using old APIs + if (rec.info.is_valid()) { + this->format_title_from_external_info(rec.info->info(), p_hook, p_out, p_script, p_filter); + } else { + this->format_title(p_hook, p_out, p_script, p_filter); + } +#endif +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/metadb_handle.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/metadb_handle.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,315 @@ +#pragma once +#include "filesystem.h" // t_filestats +#include "playable_location.h" +#include "file_info.h" + +class titleformat_hook; +class titleformat_text_filter; +class titleformat_object; + + +class metadb_info_container : public service_base { + FB2K_MAKE_SERVICE_INTERFACE(metadb_info_container, service_base); +public: + virtual file_info const & info() = 0; + virtual t_filestats const & stats() = 0; + virtual bool isInfoPartial() = 0; + + t_filestats2 stats2_(); +}; + + +//! \since 2.0 +class metadb_info_container_v2 : public metadb_info_container { + FB2K_MAKE_SERVICE_INTERFACE(metadb_info_container_v2, metadb_info_container); +public: + virtual t_filestats2 const & stats2() = 0; +}; + +struct metadb_v2_rec_t { + metadb_info_container::ptr info, infoBrowse; + service_ptr reserved; +}; + + +//! A metadb_handle object represents interface to reference-counted file_info cache entry for the specified location.\n +//! To obtain a metadb_handle to specific location, use metadb::handle_create(). To obtain a list of metadb_handle objects corresponding to specific path (directory, playlist, multitrack file, etc), use relevant playlist_incoming_item_filter methods (recommended), or call playlist_loader methods directly.\n +//! A metadb_handle is also the most efficient way of passing playable object locations around because it provides fast access to both location and infos, and is reference counted so duplicating it is as fast as possible.\n +//! To retrieve a path of a file from a metadb_handle, use metadb_handle::get_path() function. Note that metadb_handle is NOT just file path, some formats support multiple subsongs per physical file, which are signaled using subsong indexes. +class NOVTABLE metadb_handle : public service_base +{ +public: + //! Retrieves location represented by this metadb_handle object. Returned reference is valid until calling context releases metadb_handle that returned it (metadb_handle_ptr is deallocated etc). + virtual const playable_location & get_location() const = 0;//never fails, returned pointer valid till the object is released + + + //! Renders information about item referenced by this metadb_handle object. + //! @param p_hook Optional callback object overriding fields and functions; set to NULL if not used. + //! @param p_out String receiving the output on success. + //! @param p_script Titleformat script to use. Use titleformat_compiler service to create one. + //! @param p_filter Optional callback object allowing input to be filtered according to context (i.e. removal of linebreak characters present in tags when rendering playlist lines). Set to NULL when not used. + //! @returns true on success, false when dummy file_info instance was used because actual info is was not (yet) known. + virtual bool format_title(titleformat_hook * p_hook,pfc::string_base & p_out,const service_ptr_t & p_script,titleformat_text_filter * p_filter) = 0; + + //! OBSOLETE, DO NOT CALL + FB2K_DEPRECATED virtual void metadb_lock() = 0; + //! OBSOLETE, DO NOT CALL + FB2K_DEPRECATED virtual void metadb_unlock() = 0; + + //! Returns last seen file stats, filestats_invalid if unknown. + virtual t_filestats get_filestats() const = 0; + + //! Obsolete, use get_info_ref() family of methods instead. \n + //! Queries whether cached info about item referenced by this metadb_handle object is already available. Note that this function causes the metadb to be temporarily locked; you can not use it in context that where locking is forbidden.\n + //! Note that state of cached info changes only inside main thread, so you can safely assume that it doesn't change while some block of your code inside main thread is being executed. + virtual bool is_info_loaded() const = 0; + //! Obsolete, use get_info_ref() instead. \n + //! Queries cached info about item referenced by this metadb_handle object. Returns true on success, false when info is not yet known. Note that this function causes the metadb to be temporarily locked; you can not use it in context that where locking is forbidden. \n + //! Note that state of cached info changes only inside main thread, so you can safely assume that it doesn't change while some block of your code inside main thread is being executed. + virtual bool get_info(file_info & p_info) const = 0; + + //! OBSOLETE, DO NOT CALL + FB2K_DEPRECATED virtual bool get_info_locked(const file_info * & p_info) const = 0; + + //! Obsolete, use get_info_ref() family of methods instead. \n + //! Queries whether cached info about item referenced by this metadb_handle object is already available.\n + //! This is intended for use in special cases when you need to immediately retrieve info sent by metadb_io hint from another thread; state of returned data can be altered by any thread, as opposed to non-async methods. + virtual bool is_info_loaded_async() const = 0; + //! Obsolete, use get_info_ref() family of methods instead. \n + //! Queries cached info about item referenced by this metadb_handle object. Returns true on success, false when info is not yet known. Note that this function causes the metadb to be temporarily locked; you can not use it in context that where locking is forbidden.\n + //! This is intended for use in special cases when you need to immediately retrieve info sent by metadb_io hint from another thread; state of returned data can be altered by any thread, as opposed to non-async methods. + virtual bool get_info_async(file_info & p_info) const = 0; + + //! OBSOLETE, DO NOT CALL + FB2K_DEPRECATED virtual bool get_info_async_locked(const file_info * & p_info) const = 0; + + //! Renders information about item referenced by this metadb_handle object, using external file_info data. + virtual void format_title_from_external_info(const file_info & p_info,titleformat_hook * p_hook,pfc::string_base & p_out,const service_ptr_t & p_script,titleformat_text_filter * p_filter) = 0; + + //! OBSOLETE, DO NOT CALL + FB2K_DEPRECATED virtual bool format_title_nonlocking(titleformat_hook * p_hook,pfc::string_base & p_out,const service_ptr_t & p_script,titleformat_text_filter * p_filter) = 0; + //! OBSOLETE, DO NOT CALL + FB2K_DEPRECATED virtual void format_title_from_external_info_nonlocking(const file_info & p_info,titleformat_hook * p_hook,pfc::string_base & p_out,const service_ptr_t & p_script,titleformat_text_filter * p_filter) = 0; + +#if FOOBAR2000_TARGET_VERSION >= 76 + //! \since 1.0 + //! Returns browse info for this track. \n + //! Browse info comes from an external source - such as internet playlist metadata - not from the media file itself, and is maintained separately. \n + //! When title formatting calls are invoked on for a track having browse info present, data for title formatting is sourced from both primary and browse info. \n + //! Example: internet radio stream provides no metadata but its playlist XML has title (radio station name), %title% resolves to the radio station name from the playlist. + virtual bool get_browse_info(file_info & info, t_filetimestamp & ts) const = 0; + + //! \since 1.0 + //! OBSOLETE, DO NOT CALL + FB2K_DEPRECATED virtual bool get_browse_info_locked(const file_info * & p_info, t_filetimestamp & ts) const = 0; +#endif +#if FOOBAR2000_TARGET_VERSION >= 78 + //! \since 1.3 + //! Retrieve a reference to the primary info. \n + //! You can hold the reference to the info as long as you like, call the method in any context you like with no lock semantics involved. The info held by the returned reference will remain constant even if the metadb content changes. \n + //! Returns true and sets outInfo to a reference to this item's primary info on success, returns false on failure (no info known at this time). + virtual bool get_info_ref(metadb_info_container::ptr & outInfo) const = 0; + + //! \since 1.3 + //! Retrieve a reference to the async info (pending info update). If async info isn't set, a reference to the primary info is returned.\n + //! You can hold the reference to the info as long as you like, call the method in any context you like with no lock semantics involved. The info held by the returned reference will remain constant even if the metadb content changes. \n + //! Returns true and sets outInfo to a reference to this item's async or primary info on success, returns false on failure (no info known at this time). + virtual bool get_async_info_ref(metadb_info_container::ptr & outInfo) const = 0; + + //! \since 1.3 + //! Retrieve references to the item's primary and browse infos. If no info is set, NULL pointers are returned. For most local files, browse info is not available and you get a NULL for it.\n + //! Since browse info is usually used along with the primary info (as a fallback for missing metas), you can get the two with one call for better performance. \n + //! You can hold the reference to the info as long as you like, call the method in any context you like with no lock semantics involved. The info held by the returned reference will remain constant even if the metadb content changes. \n + //! See also: get_browse_info(), for browse info rationale. + virtual void get_browse_info_ref(metadb_info_container::ptr & outInfo, metadb_info_container::ptr & outBrowse) const = 0; + + //! Simplified method, always returns non-null, dummy info if nothing to return. + virtual metadb_info_container::ptr get_info_ref() const = 0; + //! Simplified method, always returns non-null, dummy info if nothing to return. + virtual metadb_info_container::ptr get_async_info_ref() const = 0; + + //! \since 1.3 + //! Retrieve full info using available means - read actual file if not cached. \n + //! Throws exceptions on failure. + metadb_info_container::ptr get_full_info_ref( abort_callback & aborter ) const; +#endif + + t_filestats2 get_stats2_() const; + + //! \since 1.3 + //! Helper using get_browse_info_ref(). \n + //! Retrieves primary info + browse info merged together. \n + //! Returns true on success, false if neither info is available. \n + //! If neither info is avaialble, output data structure is emptied. \n + //! See also: get_browse_info() for browse info rationale. + bool get_browse_info_merged(file_info & infoMerged) const; + + + static bool g_should_reload(const t_filestats & p_old_stats,const t_filestats & p_new_stats,bool p_fresh); + static bool g_should_reload_ex(const t_filestats& p_old_stats, const t_filestats& p_new_stats, t_filetimestamp p_readtime); + bool should_reload(const t_filestats & p_new_stats,bool p_fresh) const; + + + //! Helper provided for backwards compatibility; takes formatting script as text string and calls relevant titleformat_compiler methods; returns false when the script could not be compiled.\n + //! See format_title() for descriptions of parameters.\n + //! Bottleneck warning: you should consider using precompiled titleformat script object and calling regular format_title() instead when processing large numbers of items. + bool format_title_legacy(titleformat_hook * p_hook,pfc::string_base & out,const char * p_spec,titleformat_text_filter * p_filter); + + //! Retrieves path of item described by this metadb_handle instance. Returned string is valid until calling context releases metadb_handle that returned it (metadb_handle_ptr is deallocated etc). + inline const char * get_path() const {return get_location().get_path();} + //! Retrieves subsong index of item described by this metadb_handle instance (used for multiple playable tracks within single physical file). + inline t_uint32 get_subsong_index() const {return get_location().get_subsong_index();} + + double get_length();//helper + + t_filetimestamp get_filetimestamp(); + t_filesize get_filesize(); + + //! Internal method, do not use + inline const char * _get_path() const { return get_path(); } + + metadb_v2_rec_t query_v2_(); + void formatTitle_v2_(const metadb_v2_rec_t& rec, titleformat_hook* p_hook, pfc::string_base& p_out, const service_ptr_t& p_script, titleformat_text_filter* p_filter); + + FB2K_MAKE_SERVICE_INTERFACE(metadb_handle,service_base); +}; + +//! \since 2.0 +class metadb_handle_v2 : public metadb_handle { + FB2K_MAKE_SERVICE_INTERFACE(metadb_handle_v2, metadb_handle); +public: + typedef metadb_v2_rec_t rec_t; + + virtual rec_t query_v2() const = 0; + virtual t_filestats2 get_stats2() const = 0; + virtual void formatTitle_v2(const rec_t& rec, titleformat_hook* p_hook, pfc::string_base& p_out, const service_ptr_t& p_script, titleformat_text_filter* p_filter) = 0; +}; + +typedef pfc::list_base_t* metadb_handle_list_ptr; +typedef pfc::list_base_const_t const * metadb_handle_list_cptr; + +typedef pfc::list_base_t & metadb_handle_list_ref; +typedef pfc::list_base_const_t const & metadb_handle_list_cref; + +namespace metadb_handle_list_helper { + void sort_by_format(metadb_handle_list_ref p_list,const char * spec,titleformat_hook * p_hook); + void sort_by_format_get_order(metadb_handle_list_cref p_list,t_size* order,const char * spec,titleformat_hook * p_hook); + void sort_by_format(metadb_handle_list_ref p_list,const service_ptr_t & p_script,titleformat_hook * p_hook, int direction = 1); + void sort_by_format_get_order(metadb_handle_list_cref p_list,t_size* order,const service_ptr_t & p_script,titleformat_hook * p_hook,int p_direction = 1); + + void sort_by_relative_path(metadb_handle_list_ref p_list); + void sort_by_relative_path_get_order(metadb_handle_list_cref p_list,t_size* order); + + void remove_duplicates(pfc::list_base_t & p_list); + void sort_by_pointer_remove_duplicates(pfc::list_base_t & p_list); + void sort_by_path_quick(pfc::list_base_t & p_list); + + void sort_by_pointer(pfc::list_base_t & p_list); + t_size bsearch_by_pointer(const pfc::list_base_const_t & p_list,const metadb_handle_ptr & val); + + double calc_total_duration(metadb_handle_list_cref p_list); + pfc::string8 format_total_size(metadb_handle_list_cref p_list); + + //! New method to deal with slower metadb in foobar2000 v2 + double calc_total_duration_v2(metadb_handle_list_cref p_list, unsigned maxThreads, abort_callback & aborter); + + + void sort_by_path(pfc::list_base_t & p_list); + + t_filesize calc_total_size(metadb_handle_list_cref list, bool skipUnknown = false); + t_filesize calc_total_size_ex(metadb_handle_list_cref list, bool & foundUnknown); + + bool extract_single_path(metadb_handle_list_cref list, const char * &path); + bool extract_folder_path(metadb_handle_list_cref list, pfc::string_base & path); + + void sort_by_format_get_order_v2( metadb_handle_list_cref p_list, size_t * order, const service_ptr_t & script, titleformat_hook * hook, int direction, abort_callback & aborter ); + void sort_by_format_v2(metadb_handle_list_ref p_list, const service_ptr_t & script, titleformat_hook * hook, int direction, abort_callback & aborter); + + struct sorter_t { + service_ptr_t < titleformat_object > obj; + int direction = 1; + titleformat_hook* hook = nullptr; + }; + + //! Late-2023 addition (new fb2k not required) \n + //! Multilayer stablesort using single info query pass, with multiple sort objects that can have different directions. + //! @param inOutOrder input & output order, please set to a valid permutration (such as identity) on input. + void sort_by_format_get_order_v3(metadb_handle_list_cref p_list, size_t* inOutOrder, sorter_t const * sorters, size_t nSorters, abort_callback& aborter); +}; + +template class t_alloc = pfc::alloc_fast > +class metadb_handle_list_t : public service_list_t { +private: + typedef metadb_handle_list_t t_self; + typedef pfc::list_base_const_t t_interface; +public: + inline void sort_by_format(const char * spec,titleformat_hook * p_hook) { + return metadb_handle_list_helper::sort_by_format(*this, spec, p_hook); + } + inline void sort_by_format_get_order(t_size* order,const char * spec,titleformat_hook * p_hook) const { + metadb_handle_list_helper::sort_by_format_get_order(*this, order, spec, p_hook); + } + + inline void sort_by_format(const service_ptr_t & p_script,titleformat_hook * p_hook, int direction = 1) { + metadb_handle_list_helper::sort_by_format(*this, p_script, p_hook, direction); + } + inline void sort_by_format_get_order(t_size* order,const service_ptr_t & p_script,titleformat_hook * p_hook) const { + metadb_handle_list_helper::sort_by_format_get_order(*this, order, p_script, p_hook); + } + + inline void sort_by_relative_path() { + metadb_handle_list_helper::sort_by_relative_path(*this); + } + inline void sort_by_relative_path_get_order(t_size* order) const { + metadb_handle_list_helper::sort_by_relative_path_get_order(*this,order); + } + + inline void remove_duplicates() {metadb_handle_list_helper::remove_duplicates(*this);} + inline void sort_by_pointer_remove_duplicates() {metadb_handle_list_helper::sort_by_pointer_remove_duplicates(*this);} + inline void sort_by_path_quick() {metadb_handle_list_helper::sort_by_path_quick(*this);} + + inline void sort_by_pointer() {metadb_handle_list_helper::sort_by_pointer(*this);} + inline t_size bsearch_by_pointer(const metadb_handle_ptr & val) const {return metadb_handle_list_helper::bsearch_by_pointer(*this,val);} + + inline double calc_total_duration() const {return metadb_handle_list_helper::calc_total_duration(*this);} + pfc::string8 format_total_size() const { return metadb_handle_list_helper::format_total_size(*this); } + + inline void sort_by_path() {metadb_handle_list_helper::sort_by_path(*this);} + + const t_self & operator=(const t_self & p_source) { this->remove_all(); this->add_items(p_source);return *this;} + const t_self & operator=(const t_interface & p_source) {this->remove_all(); this->add_items(p_source);return *this;} + const t_self & operator=(t_self && p_source) {this->move_from(p_source); return *this; } + metadb_handle_list_t(const t_self & p_source) { this->add_items(p_source);} + metadb_handle_list_t(const t_interface & p_source) { this->add_items(p_source);} + metadb_handle_list_t() {} + + metadb_handle_list_t(t_self && p_source) { this->move_from(p_source);} + + t_self & operator+=(const t_interface & source) { this->add_items(source); return *this;} + t_self & operator+=(const metadb_handle_ptr & source) { this->add_item(source); return *this;} + + bool extract_single_path(const char * &path) const {return metadb_handle_list_helper::extract_single_path(*this, path);} +}; + +typedef metadb_handle_list_t<> metadb_handle_list; + +namespace metadb_handle_list_helper { + void sorted_by_pointer_extract_difference(metadb_handle_list const & p_list_1,metadb_handle_list const & p_list_2,metadb_handle_list & p_list_1_specific,metadb_handle_list & p_list_2_specific); +}; + + +inline pfc::string_base & operator<<(pfc::string_base & p_fmt,const metadb_handle_ptr & p_location) { + if (p_location.is_valid()) + return p_fmt << p_location->get_location(); + else + return p_fmt << "[invalid location]"; +} + + + +namespace fb2k { + pfc::string_formatter formatTrackList( metadb_handle_list_cref ); + pfc::string_formatter formatTrackTitle(metadb_handle_ptr item, const char * script = "%title%" ); + pfc::string_formatter formatTrackTitle(metadb_handle_ptr item,service_ptr_t script); +} + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/metadb_handle_list.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/metadb_handle_list.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,569 @@ +#include "foobar2000-sdk-pch.h" +#include "foosort.h" +#include "threadPool.h" +#include "foosortstring.h" +#include +#include "titleformat.h" +#include "library_manager.h" +#include "genrand.h" + +namespace { + + struct custom_sort_data_multi { + static constexpr unsigned numLocal = 4; + void setup(size_t count) { + if (count > numLocal) texts2 = std::make_unique< fb2k::sortString_t[] >( count - numLocal ); + } + fb2k::sortString_t& operator[] (size_t which) { + return which < numLocal ? texts1[which] : texts2[which - numLocal]; + } + const fb2k::sortString_t& operator[] (size_t which) const { + return which < numLocal ? texts1[which] : texts2[which - numLocal]; + } + + fb2k::sortString_t texts1[numLocal]; + std::unique_ptr< fb2k::sortString_t[] > texts2; + size_t index; + }; + struct custom_sort_data { + fb2k::sortString_t text; + size_t index; + }; + template + static int custom_sort_compare(const custom_sort_data& elem1, const custom_sort_data& elem2) { + int ret = direction * fb2k::sortStringCompare(elem1.text, elem2.text); + if (ret == 0) ret = pfc::sgn_t((t_ssize)elem1.index - (t_ssize)elem2.index); + return ret; + } + +} + +void metadb_handle_list_helper::sort_by_format(metadb_handle_list_ref p_list,const char * spec,titleformat_hook * p_hook) +{ + service_ptr_t script; + if (titleformat_compiler::get()->compile(script,spec)) + sort_by_format(p_list,script,p_hook); +} + +void metadb_handle_list_helper::sort_by_format_get_order(metadb_handle_list_cref p_list,t_size* order,const char * spec,titleformat_hook * p_hook) +{ + service_ptr_t script; + if (titleformat_compiler::get()->compile(script,spec)) + sort_by_format_get_order(p_list,order,script,p_hook); +} + +void metadb_handle_list_helper::sort_by_format(metadb_handle_list_ref p_list,const service_ptr_t & p_script,titleformat_hook * p_hook, int direction) +{ + const t_size count = p_list.get_count(); + pfc::array_t order; order.set_size(count); + sort_by_format_get_order(p_list,order.get_ptr(),p_script,p_hook,direction); + p_list.reorder(order.get_ptr()); +} + +namespace { + + class tfhook_sort : public titleformat_hook { + public: + tfhook_sort() { + m_API->seed(); + } + bool process_field(titleformat_text_out *,const char *,t_size,bool &) override { + return false; + } + bool process_function(titleformat_text_out * p_out,const char * p_name,t_size p_name_length,titleformat_hook_function_params * p_params,bool & p_found_flag) override { + if (stricmp_utf8_ex(p_name, p_name_length, "rand", SIZE_MAX) == 0) { + t_size param_count = p_params->get_param_count(); + t_uint32 val; + if (param_count == 1) { + t_uint32 mod = (t_uint32)p_params->get_param_uint(0); + if (mod > 0) { + val = m_API->genrand(mod); + } else { + val = 0; + } + } else { + val = m_API->genrand(0xFFFFFFFF); + } + p_out->write_int(titleformat_inputtypes::unknown, val); + p_found_flag = true; + return true; + } else { + return false; + } + } + private: + genrand_service::ptr m_API = genrand_service::get(); + }; +} + +void metadb_handle_list_helper::sort_by_format_get_order(metadb_handle_list_cref p_list,t_size* order,const service_ptr_t & p_script,titleformat_hook * p_hook,int p_direction) +{ + sort_by_format_get_order_v2(p_list, order, p_script, p_hook, p_direction, fb2k::noAbort ); +} + +void metadb_handle_list_helper::sort_by_relative_path(metadb_handle_list_ref p_list) +{ + const t_size count = p_list.get_count(); + pfc::array_t order; order.set_size(count); + sort_by_relative_path_get_order(p_list,order.get_ptr()); + p_list.reorder(order.get_ptr()); +} + +void metadb_handle_list_helper::sort_by_relative_path_get_order(metadb_handle_list_cref p_list,t_size* order) +{ + const t_size count = p_list.get_count(); + t_size n; + std::vector data; + data.resize(count); + auto api = library_manager::get(); + + pfc::string8_fastalloc temp; + temp.prealloc(512); + for(n=0;nget_relative_path(item,temp)) temp = ""; + data[n].index = n; + data[n].text = fb2k::makeSortString(temp); + //data[n].subsong = item->get_subsong_index(); + } + + pfc::sort_t(data,custom_sort_compare<1>,count); + //qsort(data.get_ptr(),count,sizeof(custom_sort_data),(int (__cdecl *)(const void *elem1, const void *elem2 ))custom_sort_compare); + + for(n=0;n0) + { + pfc::bit_array_bittable mask(count); + pfc::array_t order; order.set_size(count); + order_helper::g_fill(order); + + p_list.sort_get_permutation_t(pfc::compare_t,order.get_ptr()); + + t_size n; + bool found = false; + for(n=0;n0) + { + sort_by_pointer(p_list); + bool b_found = false; + for(size_t n=0;n,val,blah)) return blah; + else return SIZE_MAX; +} + + +void metadb_handle_list_helper::sorted_by_pointer_extract_difference(metadb_handle_list const & p_list_1,metadb_handle_list const & p_list_2,metadb_handle_list & p_list_1_specific,metadb_handle_list & p_list_2_specific) +{ + t_size found_1, found_2; + const t_size count_1 = p_list_1.get_count(), count_2 = p_list_2.get_count(); + t_size ptr_1, ptr_2; + + found_1 = found_2 = 0; + ptr_1 = ptr_2 = 0; + while(ptr_1 < count_1 || ptr_2 < count_2) + { + while(ptr_1 < count_1 && (ptr_2 == count_2 || p_list_1[ptr_1] < p_list_2[ptr_2])) + { + found_1++; + t_size ptr_1_new = ptr_1 + 1; + while(ptr_1_new < count_1 && p_list_1[ptr_1_new] == p_list_1[ptr_1]) ptr_1_new++; + ptr_1 = ptr_1_new; + } + while(ptr_2 < count_2 && (ptr_1 == count_1 || p_list_2[ptr_2] < p_list_1[ptr_1])) + { + found_2++; + t_size ptr_2_new = ptr_2 + 1; + while(ptr_2_new < count_2 && p_list_2[ptr_2_new] == p_list_2[ptr_2]) ptr_2_new++; + ptr_2 = ptr_2_new; + } + while(ptr_1 < count_1 && ptr_2 < count_2 && p_list_1[ptr_1] == p_list_2[ptr_2]) {ptr_1++; ptr_2++;} + } + + + + p_list_1_specific.set_count(found_1); + p_list_2_specific.set_count(found_2); + if (found_1 > 0 || found_2 > 0) + { + found_1 = found_2 = 0; + ptr_1 = ptr_2 = 0; + + while(ptr_1 < count_1 || ptr_2 < count_2) + { + while(ptr_1 < count_1 && (ptr_2 == count_2 || p_list_1[ptr_1] < p_list_2[ptr_2])) + { + p_list_1_specific[found_1++] = p_list_1[ptr_1]; + t_size ptr_1_new = ptr_1 + 1; + while(ptr_1_new < count_1 && p_list_1[ptr_1_new] == p_list_1[ptr_1]) ptr_1_new++; + ptr_1 = ptr_1_new; + } + while(ptr_2 < count_2 && (ptr_1 == count_1 || p_list_2[ptr_2] < p_list_1[ptr_1])) + { + p_list_2_specific[found_2++] = p_list_2[ptr_2]; + t_size ptr_2_new = ptr_2 + 1; + while(ptr_2_new < count_2 && p_list_2[ptr_2_new] == p_list_2[ptr_2]) ptr_2_new++; + ptr_2 = ptr_2_new; + } + while(ptr_1 < count_1 && ptr_2 < count_2 && p_list_1[ptr_1] == p_list_2[ptr_2]) {ptr_1++; ptr_2++;} + } + + } +} + +double metadb_handle_list_helper::calc_total_duration_v2(metadb_handle_list_cref p_list, unsigned maxThreads, abort_callback & aborter) { + const size_t count = p_list.get_count(); + size_t numThreads = pfc::getOptimalWorkerThreadCountEx( pfc::min_t(maxThreads, count / 2000 )); + if (numThreads == 1) { + double ret = 0; + for (size_t n = 0; n < count; n++) + { + double temp = p_list.get_item(n)->get_length(); + if (temp > 0) ret += temp; + } + return ret; + } + + pfc::array_t sums; sums.resize(numThreads); sums.fill_null(); + + { + pfc::refcounter walk = 0, walkSums = 0; + + auto worker = [&] { + double ret = 0; + for (;;) { + size_t idx = walk++; + if (idx >= count || aborter.is_set()) break; + + double temp = p_list.get_item(idx)->get_length(); + if (temp > 0) ret += temp; + } + sums[walkSums++] = ret; + }; + + fb2k::cpuThreadPool::runMultiHelper(worker, numThreads); + } + aborter.check(); + double ret = 0; + for (size_t walk = 0; walk < numThreads; ++walk) ret += sums[walk]; + return ret; +} + +pfc::string8 metadb_handle_list_helper::format_total_size(metadb_handle_list_cref p_list) { + pfc::string8 temp; + bool unknown = false; + t_filesize val = metadb_handle_list_helper::calc_total_size_ex(p_list,unknown); + if (unknown) temp << "> "; + temp << pfc::format_file_size_short(val); + return temp; +} + +double metadb_handle_list_helper::calc_total_duration(metadb_handle_list_cref p_list) +{ + double ret = 0; + for (auto handle : p_list) { + double temp = handle->get_length(); + if (temp > 0) ret += temp; + } + return ret; +} + +void metadb_handle_list_helper::sort_by_path(metadb_handle_list_ref p_list) +{ + sort_by_format(p_list,"%path_sort%",NULL); +} + +void metadb_handle_list_helper::sort_by_format_v2(metadb_handle_list_ref p_list, const service_ptr_t & script, titleformat_hook * hook, int direction, abort_callback & aborter) { + pfc::array_t order; order.set_size( p_list.get_count() ); + sort_by_format_get_order_v2( p_list, order.get_ptr(), script, hook, direction, aborter ); + p_list.reorder( order.get_ptr() ); +} + +void metadb_handle_list_helper::sort_by_format_get_order_v2(metadb_handle_list_cref p_list, size_t * order, const service_ptr_t & p_script, titleformat_hook * p_hook, int p_direction, abort_callback & aborter) { + sorter_t s = { p_script, p_direction, p_hook }; + size_t total = p_list.get_count(); + for (size_t walk = 0; walk < total; ++walk) order[walk] = walk; + sort_by_format_get_order_v3(p_list, order, &s, 1, aborter); +} + +void metadb_handle_list_helper::sort_by_format_get_order_v3(metadb_handle_list_cref p_list, size_t* order,sorter_t const* sorters, size_t nSorters, abort_callback& aborter) { + // pfc::hires_timer timer; timer.start(); + + typedef custom_sort_data_multi data_t; + + const t_size count = p_list.get_count(); + if (count == 0) return; + + PFC_ASSERT(pfc::permutation_is_valid(order, count)); + + auto data = std::make_unique< data_t[] >(count); + +#if FOOBAR2000_TARGET_VERSION >= 81 + bool need_info = false; + for (size_t iSorter = 0; iSorter < nSorters; ++iSorter) { + auto& s = sorters[iSorter]; + PFC_ASSERT(s.direction == -1 || s.direction == 1); + if (s.obj->requires_metadb_info_()) { + need_info = true; break; + } + } + if (need_info) { + // FB2K_console_formatter() << "sorting with queryMultiParallelEx_<>"; + struct qmpc_context { + qmpc_context() { + temp.prealloc(512); + } + tfhook_sort myHook; + pfc::string8 temp; + }; + metadb_v2::get()->queryMultiParallelEx_< qmpc_context >(p_list, [&](size_t idx, metadb_v2::rec_t const& rec, qmpc_context& ctx) { + aborter.check(); + auto& out = data[idx]; + out.setup(nSorters); + out.index = order[idx]; + + auto h = p_list[idx]; + + for (size_t iSorter = 0; iSorter < nSorters; ++iSorter) { + auto& s = sorters[iSorter]; + if (s.hook) { + titleformat_hook_impl_splitter hookSplitter(&ctx.myHook, s.hook); + h->formatTitle_v2_(rec, &hookSplitter, ctx.temp, s.obj, nullptr); + } else { + h->formatTitle_v2_(rec, &ctx.myHook, ctx.temp, s.obj, nullptr); + } + out[iSorter] = fb2k::makeSortString(ctx.temp); + } + }); + } else { + // FB2K_console_formatter() << "sorting with blank metadb info"; + auto api = fb2k::cpuThreadPool::get(); + pfc::counter walk = 0; + api->runMulti_([&] { + pfc::string8 temp; + const metadb_v2_rec_t rec = {}; + tfhook_sort myHook; + for (;;) { + aborter.check(); + size_t idx = walk++; + if (idx >= count) return; + + auto& out = data[idx]; + out.setup(nSorters); + out.index = order[idx]; + + for (size_t iSorter = 0; iSorter < nSorters; ++iSorter) { + auto& s = sorters[iSorter]; + if (s.hook) { + titleformat_hook_impl_splitter hookSplitter(&myHook, s.hook); + p_list[idx]->formatTitle_v2_(rec, &hookSplitter, temp, s.obj, nullptr); + } else { + p_list[idx]->formatTitle_v2_(rec, &myHook, temp, s.obj, nullptr); + } + + out[iSorter] = fb2k::makeSortString(temp); + } + } + }, api->numRunsSanity((count + 1999) / 2000)); + + } +#else + { + pfc::counter counter(0); + + auto work = [&] { + tfhook_sort myHook; + + pfc::string8_fastalloc temp; temp.prealloc(512); + for (;; ) { + const t_size index = (counter)++; + if (index >= count || aborter.is_set()) break; + + auto& out = data[index]; + out.setup(nSorters); + out.index = order[index]; + + for (size_t iSorter = 0; iSorter < nSorters; ++iSorter) { + auto& s = sorters[iSorter]; + if (s.hook) { + titleformat_hook_impl_splitter hookSplitter(&myHook, s.hook); + p_list[index]->format_title(&hookSplitter, temp, s.obj, 0); + } else { + p_list[index]->format_title(&myHook, temp, s.obj, 0); + } + + out[iSorter] = fb2k::makeSortString(temp); + } + } + }; + + size_t nThreads = pfc::getOptimalWorkerThreadCountEx(count / 128); + if (nThreads == 1) { + work(); + } else { + fb2k::cpuThreadPool::runMultiHelper(work, nThreads); + } + } +#endif + aborter.check(); + // console::formatter() << "metadb_handle sort: prepared in " << pfc::format_time_ex(timer.query(),6); + + + { + auto compare = [&](data_t const& elem1, data_t const& elem2) -> int { + for (size_t iSorter = 0; iSorter < nSorters; ++iSorter) { + int v = fb2k::sortStringCompare(elem1[iSorter], elem2[iSorter]); + if (v) return v * sorters[iSorter].direction; + } + + return pfc::sgn_t((t_ssize)elem1.index - (t_ssize)elem2.index); + }; + + typedef decltype(data) container_t; + typedef decltype(compare) compare_t; + pfc::sort_callback_impl_simple_wrap_t cb(data, compare); + + size_t concurrency = pfc::getOptimalWorkerThreadCountEx(count / 4096); + fb2k::sort(cb, count, concurrency, aborter); + } + + //qsort(data.get_ptr(),count,sizeof(custom_sort_data),p_direction > 0 ? _custom_sort_compare<1> : _custom_sort_compare<-1>); + + + // console::formatter() << "metadb_handle sort: sorted in " << pfc::format_time_ex(timer.query(),6); + + for (t_size n = 0; n < count; n++) + { + order[n] = data[n].index; + } + + // FB2K_console_formatter() << "metadb_handle sort: finished in " << pfc::format_time_ex(timer.query(),6); + +} + +t_filesize metadb_handle_list_helper::calc_total_size(metadb_handle_list_cref p_list, bool skipUnknown) { + pfc::avltree_t< const char*, metadb::path_comparator > beenHere; +// metadb_handle_list list(p_list); +// list.sort_t(metadb::path_compare_metadb_handle); + + t_filesize ret = 0; + t_size n, m = p_list.get_count(); + for(n=0;nget_path(), isNew); + if (isNew) { + t_filesize t = h->get_filesize(); + if (t == filesize_invalid) { + if (!skipUnknown) return filesize_invalid; + } else { + ret += t; + } + } + } + return ret; +} + +t_filesize metadb_handle_list_helper::calc_total_size_ex(metadb_handle_list_cref p_list, bool & foundUnknown) { + foundUnknown = false; + metadb_handle_list list(p_list); + list.sort_t(metadb::path_compare_metadb_handle); + + t_filesize ret = 0; + t_size n, m = list.get_count(); + for(n=0;nget_path(),list[n]->get_path())) { + t_filesize t = list[n]->get_filesize(); + if (t == filesize_invalid) { + foundUnknown = true; + } else { + ret += t; + } + } + } + return ret; +} + +bool metadb_handle_list_helper::extract_folder_path(metadb_handle_list_cref list, pfc::string_base & folderOut) { + const t_size total = list.get_count(); + if (total == 0) return false; + pfc::string_formatter temp, folder; + folder = list[0]->get_path(); + folder.truncate_to_parent_path(); + for(size_t walk = 1; walk < total; ++walk) { + temp = list[walk]->get_path(); + temp.truncate_to_parent_path(); + if (metadb::path_compare(folder, temp) != 0) return false; + } + folderOut = folder; + return true; +} +bool metadb_handle_list_helper::extract_single_path(metadb_handle_list_cref list, const char * &pathOut) { + const t_size total = list.get_count(); + if (total == 0) return false; + const char * path = list[0]->get_path(); + for(t_size walk = 1; walk < total; ++walk) { + if (metadb::path_compare(path, list[walk]->get_path()) != 0) return false; + } + pathOut = path; + return true; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/metadb_index.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/metadb_index.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,117 @@ +#pragma once +#include "mem_block_container.h" + + +//! \since 1.1 +//! metadb_index_manager hash, currently a 64bit int, typically made from halving MD5 hash. +typedef t_uint64 metadb_index_hash; + + +//! \since 1.1 +//! A class that transforms track information (location+metadata) to a hash for metadb_index_manager. \n +//! You need to implement your own when using metadb_index_manager to pin your data to user's tracks. \n +//! Possible routes to take when implementing: \n +//! Rely on location only - pinning lost when user moves, but survives editing tags\n +//! Rely on metadata - pinning survives moving files, but lost when editing tags\n +//! If you do the latter, you can implement metadb_io_edit_callback to respond to tag edits and avoid data loss. +class NOVTABLE metadb_index_client : public service_base { + FB2K_MAKE_SERVICE_INTERFACE(metadb_index_client, service_base) +public: + virtual metadb_index_hash transform(const file_info& info, const playable_location& location) = 0; + + bool hashHandle(metadb_handle_ptr const& h, metadb_index_hash& out) { + metadb_info_container::ptr info; + if (!h->get_info_ref(info)) return false; + out = transform(info->info(), h->get_location()); + return true; + } + + static metadb_index_hash from_md5(hasher_md5_result const& in) { return in.xorHalve(); } +}; + +//! \since 1.1 +//! This service lets you pin your data to user's music library items, typically to be presented as title formatting %fields% via metadb_display_field_provider. \n +//! Implement metadb_index_client to define how your data gets pinned to the songs. +class NOVTABLE metadb_index_manager : public service_base { + FB2K_MAKE_SERVICE_COREAPI(metadb_index_manager) +public: + //! Install a metadb_index_client. \n + //! This is best done from init_stage_callback::on_init_stage(init_stages::before_config_read) to avoid hammering already loaded UI & playlists with refresh requests. \n + //! If you provide your own title formatting fields, call dispatch_global_refresh() after a successful add() to signal all components to refresh all tracks \n + //! - which is expensive, hence it should be done in early app init phase for minimal performance penalty. \n + //! Always put a try/catch around add() as it may fail with an exception in an unlikely scenario of corrupted files holding your previously saved data. \n + //! @param client your metadb_index_client object. + //! @param index_id Your GUID that you will pass to other methods when referring to your index. + //! @param userDataRetentionPeriod Time for which the data should be retained if no matching tracks are present. \n + //! If this was set to zero, the data could be lost immediately if a library folder disappers for some reason. \n + //! Hint: use system_time_periods::* constants, for an example, system_time_periods::week. + virtual void add(metadb_index_client::ptr client, const GUID& index_id, t_filetimestamp userDataRetentionPeriod) = 0; + //! Uninstalls a previously installed index. + virtual void remove(const GUID& index_id) = 0; + //! Sets your data for the specified index+hash. + virtual void set_user_data(const GUID& index_id, const metadb_index_hash& hash, const void* data, t_size dataSize) = 0; + //! Gets your data for the specified index+hash. + virtual void get_user_data(const GUID& index_id, const metadb_index_hash& hash, mem_block_container& out) = 0; + + + //! Helper + template void get_user_data_t(const GUID& index_id, const metadb_index_hash& hash, t_array& out) { + mem_block_container_ref_impl ref(out); + get_user_data(index_id, hash, ref); + } + + //! Helper + t_size get_user_data_here(const GUID& index_id, const metadb_index_hash& hash, void* out, t_size outSize) { + mem_block_container_temp_impl ref(out, outSize); + get_user_data(index_id, hash, ref); + return ref.get_size(); + } + + //! Signals all components that your data for the tracks matching the specified hashes has been altered; this will redraw the affected tracks in playlists and such. + virtual void dispatch_refresh(const GUID& index_id, const pfc::list_base_const_t& hashes) = 0; + + //! Helper + void dispatch_refresh(const GUID& index_id, const metadb_index_hash& hash) { + pfc::list_single_ref_t l(hash); + dispatch_refresh(index_id, l); + } + + //! Dispatches a global refresh, asks all components to refresh all tracks. To be calling after adding/removing indexes. Expensive! + virtual void dispatch_global_refresh() = 0; + + //! Efficiently retrieves metadb_handles of items present in the Media Library matching the specified index value. \n + //! This can be called from the app main thread only (interfaces with the library_manager API). + virtual void get_ML_handles(const GUID& index_id, const metadb_index_hash& hash, metadb_handle_list_ref out) = 0; + + //! Retrieves all known hash values for this index. + virtual void get_all_hashes(const GUID& index_id, pfc::list_base_t& out) = 0; + + //! Determines whether a no longer needed user data file for this index exists. \n + //! For use with index IDs that are not currently registered only. + virtual bool have_orphaned_data(const GUID& index_id) = 0; + + //! Deletes no longer needed index user data files. \n + //! For use with index IDs that are not currently registered only. + virtual void erase_orphaned_data(const GUID& index_id) = 0; + + //! Saves index user data file now. You normally don't need to call this; it's done automatically when saving foobar2000 configuration. \n + //! This will throw exceptions in case of a failure (out of disk space etc). + virtual void save_index_data(const GUID& index_id) = 0; +}; + +//! \since 2.0 +//! Call this instead of metadb_index_manager::set_user_data() for many updates in a row +class NOVTABLE metadb_index_transaction : public service_base { + FB2K_MAKE_SERVICE_INTERFACE(metadb_index_transaction, service_base) +public: + virtual void set_user_data(const GUID& index_id, const metadb_index_hash& hash, const void* data, t_size dataSize) = 0; + virtual void commit() = 0; +}; + +//! \since 2.0 +class NOVTABLE metadb_index_manager_v2 : public metadb_index_manager { + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(metadb_index_manager_v2, metadb_index_manager) +public: + //! Call this instead of metadb_index_manager::set_user_data() for many updates in a row + virtual metadb_index_transaction::ptr begin_transaction() = 0; +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/metadb_info_container_impl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/metadb_info_container_impl.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,13 @@ +#pragma once + +#include "file_info_const_impl.h" + +class metadb_info_container_const_impl : public metadb_info_container_v2 { +public: + file_info const& info() override { return m_info; } + t_filestats const& stats() override { return m_stats.as_legacy(); } + bool isInfoPartial() override { return false; } + t_filestats2 const& stats2() override { return m_stats; } + file_info_const_impl m_info; + t_filestats2 m_stats; +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/modeless_dialog.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/modeless_dialog.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,20 @@ +#pragma once +#ifdef _WIN32 +//! Service for plugging your nonmodal dialog windows into main app loop to receive IsDialogMessage()-translated messages.\n +//! Note that all methods are valid from main app thread only.\n +//! Usage: call the static methods - modeless_dialog_manager::g_add / modeless_dialog_manager::g_remove. +class NOVTABLE modeless_dialog_manager : public service_base { + FB2K_MAKE_SERVICE_COREAPI(modeless_dialog_manager); +public: + //! Adds specified window to global list of windows to receive IsDialogMessage(). + virtual void add(HWND p_wnd) = 0; + //! Removes specified window from global list of windows to receive IsDialogMessage(). + virtual void remove(HWND p_wnd) = 0; + + //! Static helper; see add(). + static void g_add(HWND p_wnd) {modeless_dialog_manager::get()->add(p_wnd);} + //! Static helper; see remove(). + static void g_remove(HWND p_wnd) {modeless_dialog_manager::get()->remove(p_wnd);} + +}; +#endif diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/noInfo.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/noInfo.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,46 @@ +#pragma once + +#include "file_info.h" + +namespace fb2k { + //! Helper: shared blank file_info object. See: file_info. + class noInfo_t : public file_info { + [[noreturn]] static void verboten() { FB2K_BugCheck(); } + public: + double get_length() const override { return 0; } + replaygain_info get_replaygain() const override { return replaygain_info_invalid; } + + t_size meta_get_count() const override { return 0; } + const char* meta_enum_name(t_size) const override { verboten(); } + t_size meta_enum_value_count(t_size) const override { verboten(); } + const char* meta_enum_value(t_size, t_size) const override { verboten(); } + t_size meta_find_ex(const char*, t_size) const override { return SIZE_MAX; } + + t_size info_get_count() const override { return 0; } + const char* info_enum_name(t_size) const override { verboten(); } + const char* info_enum_value(t_size) const override { verboten(); } + t_size info_find_ex(const char*, t_size) const override { return SIZE_MAX; } + + private: + void set_length(double) override { verboten(); } + void set_replaygain(const replaygain_info&) override { verboten(); } + + t_size info_set_ex(const char*, t_size, const char*, t_size) override { verboten(); } + void info_remove_mask(const bit_array&) override { verboten(); } + t_size meta_set_ex(const char*, t_size, const char*, t_size) override { verboten(); } + void meta_insert_value_ex(t_size, t_size, const char*, t_size) override { verboten(); } + void meta_remove_mask(const bit_array&) override { verboten(); } + void meta_reorder(const t_size*) override { verboten(); } + void meta_remove_values(t_size, const bit_array&) override { verboten(); } + void meta_modify_value_ex(t_size, t_size, const char*, t_size) override { verboten(); } + + void copy(const file_info&) override { verboten(); } + void copy_meta(const file_info&) override { verboten(); } + void copy_info(const file_info&) override { verboten(); } + t_size meta_set_nocheck_ex(const char*, t_size, const char*, t_size) override { verboten(); } + t_size info_set_nocheck_ex(const char*, t_size, const char*, t_size) override { verboten(); } + + }; + + extern noInfo_t noInfo; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/ole_interaction.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/ole_interaction.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,158 @@ +#pragma once + +#ifdef _WIN32 + +#include "mem_block_container.h" +#include "playlist.h" + +class NOVTABLE playlist_dataobject_desc { +public: + virtual t_size get_entry_count() const = 0; + virtual void get_entry_name(t_size which, pfc::string_base & out) const = 0; + virtual void get_entry_content(t_size which, metadb_handle_list_ref out) const = 0; + + virtual void set_entry_count(t_size count) = 0; + virtual void set_entry_name(t_size which, const char * name) = 0; + virtual void set_entry_content(t_size which, metadb_handle_list_cref content) = 0; + + void copy(playlist_dataobject_desc const & source) { + const t_size count = source.get_entry_count(); set_entry_count(count); + metadb_handle_list content; pfc::string8 name; + for(t_size walk = 0; walk < count; ++walk) { + source.get_entry_name(walk,name); source.get_entry_content(walk,content); + set_entry_name(walk,name); set_entry_content(walk,content); + } + } +protected: + ~playlist_dataobject_desc() {} +private: + const playlist_dataobject_desc & operator=(const playlist_dataobject_desc &) {return *this;} +}; + +class NOVTABLE playlist_dataobject_desc_v2 : public playlist_dataobject_desc { +public: + virtual void get_side_data(t_size which, mem_block_container & out) const = 0; + virtual void set_side_data(t_size which, const void * data, t_size size) = 0; + + void copy(playlist_dataobject_desc_v2 const & source) { + const t_size count = source.get_entry_count(); set_entry_count(count); + metadb_handle_list content; pfc::string8 name; + mem_block_container_impl_t sideData; + for(t_size walk = 0; walk < count; ++walk) { + source.get_entry_name(walk,name); source.get_entry_content(walk,content); source.get_side_data(walk, sideData); + set_entry_name(walk,name); set_entry_content(walk,content); set_side_data(walk, sideData.get_ptr(), sideData.get_size()); + } + } + + void set_from_playlist_manager(bit_array const & mask) { + auto api = playlist_manager_v4::get(); + const t_size pltotal = api->get_playlist_count(); + const t_size total = mask.calc_count(true,0,pltotal); + set_entry_count(total); + t_size done = 0; + pfc::string8 name; metadb_handle_list content; + for(t_size walk = 0; walk < pltotal; ++walk) if (mask[walk]) { + pfc::dynamic_assert( done < total ); + api->playlist_get_name(walk,name); api->playlist_get_all_items(walk,content); + set_entry_name(done,name); set_entry_content(done,content); + stream_writer_buffer_simple sideData; api->playlist_get_sideinfo(walk, &sideData, fb2k::noAbort); + set_side_data(done,sideData.m_buffer.get_ptr(), sideData.m_buffer.get_size()); + ++done; + } + pfc::dynamic_assert( done == total ); + } + + const playlist_dataobject_desc_v2 & operator=(const playlist_dataobject_desc_v2& source) {copy(source); return *this;} +protected: + ~playlist_dataobject_desc_v2() {} +}; + +class playlist_dataobject_desc_impl : public playlist_dataobject_desc_v2 { +public: + playlist_dataobject_desc_impl() {} + playlist_dataobject_desc_impl(const playlist_dataobject_desc_v2 & source) {copy(source);} + + t_size get_entry_count() const {return m_entries.get_size();} + void get_entry_name(t_size which, pfc::string_base & out) const { + if (which < m_entries.get_size()) out = m_entries[which].m_name; + else throw pfc::exception_invalid_params(); + } + void get_entry_content(t_size which, metadb_handle_list_ref out) const { + if (which < m_entries.get_size()) out = m_entries[which].m_content; + else throw pfc::exception_invalid_params(); + } + void set_entry_count(t_size count) { + m_entries.set_size(count); + } + void set_entry_name(t_size which, const char * name) { + if (which < m_entries.get_size()) m_entries[which].m_name = name; + else throw pfc::exception_invalid_params(); + } + void set_entry_content(t_size which, metadb_handle_list_cref content) { + if (which < m_entries.get_size()) m_entries[which].m_content = content; + else throw pfc::exception_invalid_params(); + } + void get_side_data(t_size which, mem_block_container & out) const { + if (which < m_entries.get_size()) out.set(m_entries[which].m_sideData); + else throw pfc::exception_invalid_params(); + } + void set_side_data(t_size which, const void * data, t_size size) { + if (which < m_entries.get_size()) m_entries[which].m_sideData.set_data_fromptr(reinterpret_cast(data), size); + else throw pfc::exception_invalid_params(); + } +private: + struct entry { metadb_handle_list m_content; pfc::string8 m_name; pfc::array_t m_sideData; }; + pfc::array_t m_entries; +}; + +//! \since 0.9.5 +//! Provides various methods for interaction between foobar2000 and OLE IDataObjects, Windows Clipboard, drag&drop and such. \n +//! To instantiate, use ole_interaction::get(). +class NOVTABLE ole_interaction : public service_base { + FB2K_MAKE_SERVICE_COREAPI(ole_interaction) +public: + enum { + KClipboardFormatSimpleLocations, + KClipboardFormatFPL, + KClipboardFormatMultiFPL, + KClipboardFormatTotal + }; + //! Retrieves clipboard format ID for one of foobar2000's internal data formats. + //! @param which One of KClipboardFormat* constants. + virtual t_uint32 get_clipboard_format(t_uint32 which) = 0; + + //! Creates an IDataObject from a group of tracks. + virtual pfc::com_ptr_t create_dataobject(metadb_handle_list_cref source) = 0; + + //! Creates an IDataObject from one or more playlists, including playlist name info for re-creating those playlists later. + virtual pfc::com_ptr_t create_dataobject(const playlist_dataobject_desc & source) = 0; + + //! Attempts to parse an IDataObject as playlists. + virtual HRESULT parse_dataobject_playlists(pfc::com_ptr_t obj, playlist_dataobject_desc & out) = 0; + + //! For internal use only. Will succeed only if the metadb_handle list can be generated immediately, without performing potentially timeconsuming tasks such as parsing media files (for an example when the specified IDataObject contains data in one of our internal formats). + virtual HRESULT parse_dataobject_immediate(pfc::com_ptr_t obj, metadb_handle_list_ref out) = 0; + + //! Attempts to parse an IDataObject into a dropped_files_data object (list of metadb_handles if immediately available, list of file paths otherwise). + virtual HRESULT parse_dataobject(pfc::com_ptr_t obj, dropped_files_data & out) = 0; + + //! Checks whether the specified IDataObject appears to be parsable by our parse_dataobject methods. + virtual HRESULT check_dataobject(pfc::com_ptr_t obj, DWORD & dropEffect, bool & isNative) = 0; + + //! Checks whether the specified IDataObject appears to be parsable as playlists (parse_dataobject_playlists method). + virtual HRESULT check_dataobject_playlists(pfc::com_ptr_t obj) = 0; +}; + +//! \since 0.9.5.4 +class NOVTABLE ole_interaction_v2 : public ole_interaction { + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(ole_interaction_v2, ole_interaction) +public: + //! Creates an IDataObject from one or more playlists, including playlist name info for re-creating those playlists later. + virtual pfc::com_ptr_t create_dataobject(const playlist_dataobject_desc_v2 & source) = 0; + + //! Attempts to parse an IDataObject as playlists. + virtual HRESULT parse_dataobject_playlists(pfc::com_ptr_t obj, playlist_dataobject_desc_v2 & out) = 0; +}; + +#endif // _WIN32 + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/output.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/output.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,298 @@ +#include "foobar2000-sdk-pch.h" +#include "output.h" +#include "audio_chunk_impl.h" +#include "dsp.h" +#include "resampler.h" + +pfc::string8 output_entry::get_device_name( const GUID & deviceID ) { + pfc::string8 temp; + if (!get_device_name(deviceID, temp)) temp = "[unknown device]"; + return temp; +} + +namespace { + class output_device_enum_callback_getname : public output_device_enum_callback { + public: + output_device_enum_callback_getname( const GUID & wantID, pfc::string_base & strOut ) : m_strOut(strOut), m_wantID(wantID) {} + void on_device(const GUID & p_guid,const char * p_name,unsigned p_name_length) { + if (!m_got && p_guid == m_wantID) { + m_strOut.set_string(p_name, p_name_length); + m_got = true; + } + } + bool m_got = false; + pfc::string_base & m_strOut; + const GUID m_wantID; + }; + +} + +bool output_entry::get_device_name( const GUID & deviceID, pfc::string_base & out ) { + output_device_enum_callback_getname cb(deviceID, out); + this->enum_devices(cb); + return cb.m_got; +} + +bool output_entry::g_find( const GUID & outputID, output_entry::ptr & outObj ) { + for (auto obj : enumerate()) { + if (obj->get_guid() == outputID) { + outObj = obj; return true; + } + } + return false; +} + +output_entry::ptr output_entry::g_find( const GUID & outputID ) { + output_entry::ptr ret; + if (!g_find( outputID, ret ) ) throw exception_output_module_not_found(); + return ret; +} + + +bool output::is_progressing_() { + output_v4::ptr v4; + if ( v4 &= this ) return v4->is_progressing(); + return true; +} + +size_t output::update_v2_() { + output_v4::ptr v4; + if ( v4 &= this ) return v4->update_v2(); + bool bReady = false; + this->update(bReady); + return bReady ? SIZE_MAX : 0; +} + +pfc::eventHandle_t output::get_trigger_event_() { + output_v4::ptr v4; + if ( v4 &= this ) return v4->get_trigger_event(); + return pfc::eventInvalid; +} + +size_t output::process_samples_v2_(const audio_chunk& c) { + output_v6::ptr v6; + if (v6 &= this) return v6->process_samples_v2(c); + this->process_samples(c); + return c.get_sample_count(); +} + +void output_impl::on_flush_internal() { + m_eos = false; m_sent_force_play = false; + m_incoming_ptr = 0; + m_incoming.set_size(0); +} + +void output_impl::flush() { + on_flush_internal(); + on_flush(); +} + +void output_impl::flush_changing_track() { + on_flush_internal(); + on_flush_changing_track(); +} + +void output_impl::update(bool & p_ready) { + p_ready = update_v2() > 0; +} +size_t output_impl::update_v2() { + + // Clear preemptively + m_can_write = 0; + + on_update(); + + // No data yet, nothing to do, want data, can't signal how much because we don't know the format + if (!m_incoming_spec.is_valid()) return SIZE_MAX; + + // First chunk in or format change + if (m_incoming_spec != m_active_spec) { + if (get_latency_samples() == 0) { + // Ready for new format + m_sent_force_play = false; + open(m_incoming_spec); + m_active_spec = m_incoming_spec; + } else { + // Previous format still playing, accept no more data + this->send_force_play(); + return 0; + } + } + + // opened for m_incoming_spec stream + + // Store & update m_can_write on our end + // We don't know what can_write_samples() actually does, could be expensive, avoid calling it repeatedly + m_can_write = this->can_write_samples(); + + if (m_incoming_ptr < m_incoming.get_size()) { + t_size delta = pfc::min_t(m_incoming.get_size() - m_incoming_ptr, m_can_write * m_incoming_spec.chanCount); + if (delta > 0) { + PFC_ASSERT(!m_sent_force_play); + write(audio_chunk_temp_impl(m_incoming.get_ptr() + m_incoming_ptr, delta / m_incoming_spec.chanCount, m_incoming_spec.sampleRate, m_incoming_spec.chanCount, m_incoming_spec.chanMask)); + m_incoming_ptr += delta; + if (m_eos && this->queue_empty()) { + this->send_force_play(); + } + } + + m_can_write -= delta / m_incoming_spec.chanCount; + } + return m_can_write; +} + +double output_impl::get_latency() { + double ret = 0; + if (m_incoming_spec.is_valid()) { + ret += audio_math::samples_to_time( (m_incoming.get_size() - m_incoming_ptr) / m_incoming_spec.chanCount, m_incoming_spec.sampleRate ); + } + if (m_active_spec.is_valid()) { + ret += audio_math::samples_to_time( get_latency_samples() , m_active_spec.sampleRate ); + } + return ret; +} + +void output_impl::force_play() { + if ( m_eos ) return; + m_eos = true; + if (queue_empty()) send_force_play(); +} +void output_impl::send_force_play() { + if (m_sent_force_play) return; + m_sent_force_play = true; + this->on_force_play(); +} + +static void spec_sanity(audio_chunk::spec_t const& spec) { + if (!spec.is_valid()) pfc::throw_exception_with_message< exception_io_data >("Invalid audio stream specifications"); +} + +size_t output_impl::process_samples_v2(const audio_chunk& p_chunk) { + PFC_ASSERT(queue_empty()); + PFC_ASSERT(!m_eos); + const auto spec = p_chunk.get_spec(); + if (m_incoming_spec != spec) { + spec_sanity(spec); + m_incoming_spec = spec; + return 0; + } + + auto in = p_chunk.get_sample_count(); + if (in > m_can_write) in = m_can_write; + if (in > 0) { + write(audio_chunk_partial_ref(p_chunk, 0, in)); + m_can_write -= in; + } + return in; +} + +void output_impl::process_samples(const audio_chunk & p_chunk) { + PFC_ASSERT(queue_empty()); + PFC_ASSERT( !m_eos ); + const auto spec = p_chunk.get_spec(); + size_t taken = 0; + if (m_incoming_spec == spec) { + // Try bypassing intermediate buffer + taken = this->process_samples_v2(p_chunk); + if (taken == p_chunk.get_sample_count()) return; // all written, success + taken *= spec.chanCount; + } else { + spec_sanity(spec); + m_incoming_spec = spec; + } + // Queue what's left for update() to eat later + m_incoming.set_data_fromptr(p_chunk.get_data() + taken, p_chunk.get_used_size() - taken); + m_incoming_ptr = 0; +} + +void output_v3::get_injected_dsps( dsp_chain_config & dsps ) { + dsps.remove_all(); +} + +size_t output_v4::update_v2() { + bool bReady = false; + update(bReady); + return bReady ? SIZE_MAX : 0; +} + +uint32_t output_entry::get_config_flags_compat() { + uint32_t ret = get_config_flags(); + if ((ret & (flag_low_latency | flag_high_latency)) == 0) { + // output predating flag_high_latency + flag_low_latency + // if it's old foo_out_upnp, report high latency, otherwise low latency. + static const GUID guid_foo_out_upnp = { 0x9900b4f6, 0x8431, 0x4b0a, { 0x95, 0x56, 0xa7, 0xfc, 0xb9, 0x5b, 0x74, 0x3 } }; + if (this->get_guid() == guid_foo_out_upnp) ret |= flag_high_latency; + else ret |= flag_low_latency; + } + return ret; +} + +bool output_entry::is_high_latency() { + return (this->get_config_flags_compat() & flag_high_latency) != 0; +} + +bool output_entry::is_low_latency() { + return (this->get_config_flags_compat() & flag_low_latency) != 0; +} + +// {EEEB07DE-C2C8-44c2-985C-C85856D96DA1} +const GUID output_id_null = +{ 0xeeeb07de, 0xc2c8, 0x44c2, { 0x98, 0x5c, 0xc8, 0x58, 0x56, 0xd9, 0x6d, 0xa1 } }; + +// {D41D2423-FBB0-4635-B233-7054F79814AB} +const GUID output_id_default = +{ 0xd41d2423, 0xfbb0, 0x4635, { 0xb2, 0x33, 0x70, 0x54, 0xf7, 0x98, 0x14, 0xab } }; + +outputCoreConfig_t outputCoreConfig_t::defaults() { + outputCoreConfig_t cfg = {}; + cfg.m_bitDepth = 16; + cfg.m_buffer_length = 1.0; + cfg.m_output = output_id_default; + // remaining fields nulled by {} + return cfg; +} +namespace { + class output_device_list_callback_impl : public output_device_list_callback { + public: + void onDevice( const char * fullName, const GUID & output, const GUID & device ) { + f(fullName, output, device); + } + std::function< void ( const char*, const GUID&, const GUID&) > f; + }; + + class output_config_change_callback_impl : public output_config_change_callback { + public: + void outputConfigChanged() { + f(); + } + std::function f; + }; +} +void output_manager_v2::listDevices( std::function< void ( const char*, const GUID&, const GUID&) > f ) { + output_device_list_callback_impl cb; cb.f = f; + this->listDevices( cb ); +} + +service_ptr output_manager_v2::addCallback( std::function f ) { + output_config_change_callback_impl * obj = new output_config_change_callback_impl(); + obj->f = f; + this->addCallback( obj ); + service_ptr_t selfRef ( this ); + return fb2k::callOnRelease( [obj, selfRef] { + selfRef->removeCallback( obj ); delete obj; + } ); +} + +void output_manager_v2::addCallbackPermanent( std::function f ) { + output_config_change_callback_impl * obj = new output_config_change_callback_impl(); + obj->f = f; + addCallback( obj ); +} + +void output_manager::getCoreConfig(outputCoreConfig_t& out) { + getCoreConfig(&out, sizeof(out)); +} + +outputCoreConfig_t output_manager::getCoreConfig() { + outputCoreConfig_t ret; getCoreConfig(ret); return ret; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/output.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/output.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,429 @@ +#pragma once + +#include + +PFC_DECLARE_EXCEPTION(exception_output_device_not_found, pfc::exception, "Audio device not found") +PFC_DECLARE_EXCEPTION(exception_output_module_not_found, exception_output_device_not_found, "Output module not found") +PFC_DECLARE_EXCEPTION(exception_output_invalidated, pfc::exception, "Audio device invalidated") +PFC_DECLARE_EXCEPTION(exception_output_device_in_use, pfc::exception, "Audio device in use") +PFC_DECLARE_EXCEPTION(exception_output_unsupported_stream_format, pfc::exception, "Unsupported audio stream format") + +//! Output interrupted due to another application taking exclusive access to the device - do not complain to user. +PFC_DECLARE_EXCEPTION(exception_output_interrupted, pfc::exception, "Output interrupted"); + +//! Structure describing PCM audio data format, with basic helper functions. +struct t_pcmspec +{ + unsigned m_sample_rate = 0; + unsigned m_bits_per_sample = 0; + unsigned m_channels = 0,m_channel_config = 0; + bool m_float = false; + + inline unsigned align() const {return (m_bits_per_sample / 8) * m_channels;} + + uint64_t time_to_bytes(double p_time) const {return audio_math::time_to_samples(p_time,m_sample_rate) * (m_bits_per_sample / 8) * m_channels;} + double bytes_to_time(uint64_t p_bytes) const {return (double) (p_bytes / ((m_bits_per_sample / 8) * m_channels)) / (double) m_sample_rate;} + + inline bool operator==(/*const t_pcmspec & p_spec1,*/const t_pcmspec & p_spec2) const + { + return /*p_spec1.*/m_sample_rate == p_spec2.m_sample_rate + && /*p_spec1.*/m_bits_per_sample == p_spec2.m_bits_per_sample + && /*p_spec1.*/m_channels == p_spec2.m_channels + && /*p_spec1.*/m_channel_config == p_spec2.m_channel_config + && /*p_spec1.*/m_float == p_spec2.m_float; + } + + inline bool operator!=(/*const t_pcmspec & p_spec1,*/const t_pcmspec & p_spec2) const + { + return !(*this == p_spec2); + } + + inline void reset() { *this = t_pcmspec(); } + inline bool is_valid() const + { + return m_sample_rate >= 1000 && m_sample_rate <= 1000000 && + m_channels > 0 && m_channels <= 256 && m_channel_config != 0 && + (m_bits_per_sample == 8 || m_bits_per_sample == 16 || m_bits_per_sample == 24 || m_bits_per_sample == 32); + } +}; + +class NOVTABLE output_device_enum_callback +{ +public: + virtual void on_device(const GUID & p_guid,const char * p_name,unsigned p_name_length) = 0; +}; + +class NOVTABLE output : public service_base { + FB2K_MAKE_SERVICE_INTERFACE(output,service_base); +public: + //! Retrieves amount of audio data queued for playback, in seconds. + virtual double get_latency() = 0; + //! Sends new samples to the device. Allowed to be called only when update() indicates that the device is ready. \n + //! update() should be called AGAIN after each process_samples() to know if the device is ready for more. \n + //! This method SHOULD NOT block, only copy passed chunk and return immediately. + virtual void process_samples(const audio_chunk & p_chunk) = 0; + //! Updates playback; queries whether the device is ready to receive new data. \n + //! This method SHOULD NOT block, only update internal state and return immediately. + //! @param p_ready On success, receives value indicating whether the device is ready for next process_samples() call. + virtual void update(bool & p_ready) = 0; + //! Pauses/unpauses playback. + virtual void pause(bool p_state) = 0; + //! Flushes queued audio data. Called after seeking. + virtual void flush() = 0; + //! Forces playback of queued data. Called when there's no more data to send, to prevent infinite waiting if output implementation starts actually playing after amount of data in internal buffer reaches some level. + virtual void force_play() = 0; + + //! Sets playback volume. + //! @p_val Volume level in dB. Value of 0 indicates full ("100%") volume, negative values indciate different attenuation levels. + virtual void volume_set(double p_val) = 0; + + //! Helper, see output_v4::is_progressing(). + bool is_progressing_(); + //! Helper, see output_v4::update_v2() + size_t update_v2_(); + //! Helper, see output_v4::get_trigger_event() + pfc::eventHandle_t get_trigger_event_(); + //! Helper, see output_v6::process_samples_v2() + size_t process_samples_v2_(const audio_chunk&); + + //! Helper for output_entry implementation. + static uint32_t g_extra_flags() { return 0; } + +}; + +class NOVTABLE output_v2 : public output { + FB2K_MAKE_SERVICE_INTERFACE(output_v2, output); +public: + //! Obsolete, do not use. + virtual bool want_track_marks() {return false;} + //! Obsolete, do not use. + virtual void on_track_mark() {} + //! Obsolete, do not use. + virtual void enable_fading(bool) { } + //! Called when flushing due to manual track change rather than seek-within-track + virtual void flush_changing_track() {flush();} +}; + +class dsp_chain_config; + +//! \since 1.4 +class NOVTABLE output_v3 : public output_v2 { + FB2K_MAKE_SERVICE_INTERFACE(output_v3, output_v2); +public: + //! Does this output require a specific sample rate? If yes, return the value, otherwise return zero. \n + //! Returning a nonzero will cause a resampler DSP to be injected. + virtual unsigned get_forced_sample_rate() { return 0; } + //! Allows the output to inject specific DSPs at the end of the used chain. \n + //! Default implementation queries get_forced_sample_rate() and injects a resampler. + virtual void get_injected_dsps( dsp_chain_config & ); +}; + +//! \since 1.6 +class NOVTABLE output_v4 : public output_v3 { + FB2K_MAKE_SERVICE_INTERFACE(output_v4, output_v3); +public: + //! Returns an event handle that becomes signaled once the output wants an update() call and possibly process_samples(). \n + //! Optional; may return pfc::eventInvalid if not available at this time or not supported. \n + //! Use the event only if update() signals that it cannot take any more data at this time. \n + virtual pfc::eventHandle_t get_trigger_event() {return pfc::eventInvalid;} + //! Returns whether the audio stream is currently being played or not. \n + //! Typically, for a short period of time, initially sent data is not played until a sufficient amount is queued to initiate playback without glitches. \n + //! For old outputs that do not implement this, the value can be assumed to be true. + virtual bool is_progressing() = 0; + + //! Improved version of update(); returns 0 if the output isn't ready to receive any new data, otherwise an advisory number of samples - at the current stream format - that the output expects to take now. \n + //! If the caller changes the stream format, the value is irrelevant. \n + //! The output may return SIZE_MAX to indicate that it can take data but does not currently have any hints to tell how much. \n + //! This method SHOULD NOT block, only update output state and return immediately. + virtual size_t update_v2(); +}; + +//! \since 1.6 +class output_v5 : public output_v4 { + FB2K_MAKE_SERVICE_INTERFACE(output_v5, output_v4); +public: + virtual unsigned get_forced_channel_mask() { return 0; } +}; + +//! \since 2.2 +class output_v6 : public output_v5 { + FB2K_MAKE_SERVICE_INTERFACE(output_v6, output_v5); +public: + //! Extended process_samples(), allowed to read only part of the chunk if out of buffer space to take whole. + //! @returns Number of samples actually taken. + virtual size_t process_samples_v2(const audio_chunk&) = 0; +}; + +//! \since 2.25 +//! foobar2000 v2.25 functionality draft, use only for testing live info delivery in v2.25 beta. +class output_v7 : public output_v6 { + FB2K_MAKE_SERVICE_INTERFACE(output_v7, output_v6); +public: + //! Optional, gets notified about current playback metadata. + //! @param audioSource can be any type (metadb_handle, metadb_info_container, possibly other), use operator &= to determine type. + virtual void hint_source(fb2k::objRef audioSource) { (void)audioSource; } +}; + +class NOVTABLE output_entry : public service_base { + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(output_entry); +public: + //! Instantiates output class. + virtual void instantiate(service_ptr_t & p_out,const GUID & p_device,double p_buffer_length,bool p_dither,t_uint32 p_bitdepth) = 0; + //! Enumerates devices supported by this output_entry implementation. + virtual void enum_devices(output_device_enum_callback & p_callback) = 0; + //! For internal use by backend. Each output_entry implementation must have its own guid. + virtual GUID get_guid() = 0; + //! For internal use by backend. Retrieves human-readable name of this output_entry implementation. + virtual const char * get_name() = 0; + +#ifdef _WIN32 + //! Obsolete, do not use. + virtual void advanced_settings_popup(HWND,POINT) {} +#endif + + enum { + flag_needs_bitdepth_config = 1 << 0, + flag_needs_dither_config = 1 << 1, + //! Obsolete, do not use. + flag_needs_advanced_config = 1 << 2, + flag_needs_device_list_prefixes = 1 << 3, + + //! Supports playing multiple simultaneous audio streams thru one device? + flag_supports_multiple_streams = 1 << 4, + + //! High latency operation (such as remote network playback), mutually exclusive with flag_low_latency + flag_high_latency = 1 << 5, + //! Low latency operation (local playback), mutually exclusive with flag_high_latency + flag_low_latency = 1 << 6, + //! When set, the output will be used in special compatibility mode: guaranteed regular update() calls, injected padding (silence) at the end of stream. + flag_needs_shims = 1 << 7, + }; + + virtual t_uint32 get_config_flags() = 0; + + uint32_t get_config_flags_compat(); + + bool is_high_latency(); + bool is_low_latency(); + + pfc::string8 get_device_name( const GUID & deviceID); + bool get_device_name( const GUID & deviceID, pfc::string_base & out ); + + static bool g_find( const GUID & outputID, output_entry::ptr & outObj ); + static output_entry::ptr g_find(const GUID & outputID ); +}; + +//! Helper; implements output_entry for specific output class implementation. output_entry methods are forwarded to static methods of your output class. Use output_factory_t instead of using this class directly. +template +class output_entry_impl_t : public E +{ +public: + void instantiate(service_ptr_t & p_out,const GUID & p_device,double p_buffer_length,bool p_dither,t_uint32 p_bitdepth) { + p_out = new service_impl_t(p_device,p_buffer_length,p_dither,p_bitdepth); + } + void enum_devices(output_device_enum_callback & p_callback) {T::g_enum_devices(p_callback);} + GUID get_guid() {return T::g_get_guid();} + const char * get_name() {return T::g_get_name();} + + t_uint32 get_config_flags() { + t_uint32 flags = 0; + if (T::g_advanced_settings_query()) flags |= output_entry::flag_needs_advanced_config; + if (T::g_needs_bitdepth_config()) flags |= output_entry::flag_needs_bitdepth_config; + if (T::g_needs_dither_config()) flags |= output_entry::flag_needs_dither_config; + if (T::g_needs_device_list_prefixes()) flags |= output_entry::flag_needs_device_list_prefixes; + if (T::g_supports_multiple_streams()) flags |= output_entry::flag_supports_multiple_streams; + if (T::g_is_high_latency()) flags |= output_entry::flag_high_latency; + else flags |= output_entry::flag_low_latency; + flags |= T::g_extra_flags(); + return flags; + } +}; + + +//! Use this to register your output implementation. +template +class output_factory_t : public service_factory_single_t > {}; + +//! Helper base class for output implementations. \n +//! This is the preferred way of implementing output. \n +//! This is NOT a public interface and its layout changes between foobar2000 SDK versions, do not assume other outputs to implement it. +class output_impl : public output_v7 { +protected: + output_impl() {} + + //! Called periodically. You can update your state in this method. Can do nothing if not needed. + virtual void on_update() = 0; + //! Writes an audio chunk to your output. \n + //! Will never get more than last can_write_samples() asked for. \n + //! Format being send will match last open(). + virtual void write(const audio_chunk & p_data) = 0; + //! @returns How many samples write() can take at this moment. \n + //! It's called immediately after on_update() and can reuse value calculated in last on_update(). + virtual t_size can_write_samples() = 0; + //! @returns Current latency, delay between last written sample and currently heard audio. + virtual t_size get_latency_samples() = 0; + //! Flush output, after seek etc. + virtual void on_flush() = 0; + //! Flush output due to manual track change in progress. \n + //! Same as on_flush() by default. + virtual void on_flush_changing_track() {on_flush();} + //! Called before first chunk and on stream format change. \n + //! Following write() calls will deliver chunks in the same format as specified here. + virtual void open(audio_chunk::spec_t const & p_spec) = 0; + + + //! Override this, not force_play(). \n + //! output_impl will defer call to on_force_play() until out of data in its buffer. + virtual void on_force_play() = 0; + + // base class virtual methods which derived class must also implement + // virtual void pause(bool p_state) = 0; + // virtual void volume_set(double p_val) = 0; + // virtual bool is_progressing() = 0; +protected: + void on_need_reopen() {m_active_spec.clear(); } +private: + void flush() override final; + void flush_changing_track() override final; + void update(bool & p_ready) override final; + size_t update_v2() override final; + double get_latency() override final; + void process_samples(const audio_chunk & p_chunk) override final; + size_t process_samples_v2(const audio_chunk&) override final; + void force_play() override final; + void on_flush_internal(); + void send_force_play(); + + bool queue_empty() const { return m_incoming_ptr == m_incoming.get_size(); } + + pfc::array_t m_incoming; + size_t m_incoming_ptr = 0, m_can_write = 0; + audio_chunk::spec_t m_incoming_spec,m_active_spec; + bool m_eos = false; // EOS issued by caller / no more data expected until a flush + bool m_sent_force_play = false; // set if sent on_force_play() +}; + + +class NOVTABLE volume_callback { +public: + virtual void on_volume_scale(float v) = 0; + virtual void on_volume_arbitrary(int v) = 0; +}; + +class NOVTABLE volume_control : public service_base { + FB2K_MAKE_SERVICE_INTERFACE(volume_control, service_base) +public: + virtual void add_callback(volume_callback * ptr) = 0; + virtual void remove_callback(volume_callback * ptr) = 0; + + enum style_t { + styleScale, + styleArbitrary + }; + + virtual style_t getStyle() = 0; + + virtual float scaleGet() = 0; + virtual void scaleSet(float v) = 0; + + virtual void arbitrarySet(int val) = 0; + virtual int arbitraryGet() = 0; + virtual int arbitraryGetMin() = 0; + virtual int arbitraryGetMax() = 0; + virtual bool arbitraryGetMute() = 0; + virtual void arbitrarySetMute(bool val) = 0; +}; + + +class NOVTABLE output_entry_v2 : public output_entry { + FB2K_MAKE_SERVICE_INTERFACE(output_entry_v2, output_entry) +public: + virtual bool get_volume_control(const GUID & id, volume_control::ptr & out) = 0; + virtual bool hasVisualisation() = 0; +}; + +//! \since 1.5 +class NOVTABLE output_devices_notify { +public: + virtual void output_devices_changed() = 0; +protected: + output_devices_notify() {} +private: + output_devices_notify(const output_devices_notify &) = delete; + void operator=(const output_devices_notify &) = delete; +}; + +//! \since 1.5 +class NOVTABLE output_entry_v3 : public output_entry_v2 { + FB2K_MAKE_SERVICE_INTERFACE(output_entry_v3, output_entry_v2) +public: + + //! Main thread only! + virtual void add_notify(output_devices_notify *) = 0; + //! Main thread only! + virtual void remove_notify(output_devices_notify *) = 0; + + //! Main thread only! + virtual void set_pinned_device(const GUID & guid) = 0; +}; + +#pragma pack(push, 1) +//! \since 1.3.5 +struct outputCoreConfig_t { + + static outputCoreConfig_t defaults(); + + GUID m_output; + GUID m_device; + double m_buffer_length; + uint32_t m_flags; + uint32_t m_bitDepth; + enum { flagUseDither = 1 << 0, flagUseFades = 1 << 1 }; +}; +#pragma pack(pop) + +//! \since 1.3.5 +//! Allows components to access foobar2000 core's output settings. +class NOVTABLE output_manager : public service_base { + FB2K_MAKE_SERVICE_COREAPI(output_manager); +public: + //! Instantiates an output instance with core settings. + //! @param overrideBufferLength Specify non zero to override user-configured buffer length in core settings. + //! @returns The new output instance. Throws exceptions on failure (invalid settings or other). + virtual output::ptr instantiateCoreDefault(double overrideBufferLength = 0) = 0; + virtual void getCoreConfig( void * out, size_t outSize ) = 0; + + void getCoreConfig(outputCoreConfig_t& out); + outputCoreConfig_t getCoreConfig(); +}; + +//! \since 1.3.16 +class NOVTABLE output_device_list_callback { +public: + virtual void onDevice( const char * fullName, const GUID & output, const GUID & device ) = 0; +}; + +//! \since 1.3.16 +class NOVTABLE output_config_change_callback { +public: + virtual void outputConfigChanged() = 0; +}; + +//! \since 1.4 +class NOVTABLE output_manager_v2 : public output_manager { + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(output_manager_v2, output_manager); +public: + virtual void setCoreConfig( const void * in, size_t inSize, bool bSuppressPlaybackRestart = false ) = 0; + void setCoreConfig( const outputCoreConfig_t & in ) { setCoreConfig(&in, sizeof(in) ); } + virtual void setCoreConfigDevice( const GUID & output, const GUID & device ) = 0; + virtual void listDevices( output_device_list_callback & callback ) = 0; + void listDevices( std::function< void ( const char*, const GUID&, const GUID&) > f ); + virtual void addCallback( output_config_change_callback * ) = 0; + virtual void removeCallback( output_config_change_callback * ) = 0; + + service_ptr addCallback( std::function f ); + void addCallbackPermanent( std::function f ); +}; + +extern const GUID output_id_null; +extern const GUID output_id_default; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/packet_decoder.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/packet_decoder.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,61 @@ +#include "foobar2000-sdk-pch.h" +#include "packet_decoder.h" +#include + +void packet_decoder::g_open(service_ptr_t & p_out,bool p_decode,const GUID & p_owner,t_size p_param1,const void * p_param2,t_size p_param2size,abort_callback & p_abort) +{ + std::exception_ptr rethrow; + bool havePartial = false, tryingPartial = false; + for ( ;; ) { + for (auto ptr : packet_decoder_entry::enumerate()) { + p_abort.check(); + if (ptr->is_our_setup(p_owner, p_param1, p_param2, p_param2size)) { + if (!tryingPartial && ptr->is_supported_partially_(p_owner, p_param1, p_param2, p_param2size)) { + havePartial = true; + } else { + try { + ptr->open(p_out, p_decode, p_owner, p_param1, p_param2, p_param2size, p_abort); + return; + } catch (exception_io_data const &) { + rethrow = std::current_exception(); + } + } + } + } + + if (!havePartial || tryingPartial) break; + tryingPartial = true; + } + + if (rethrow) std::rethrow_exception(rethrow); + throw exception_io_data(); +} + +size_t packet_decoder::initPadding() { + size_t v = this->set_stream_property(property_bufferpadding, 0, NULL, 0); + if (v > 0) { + this->set_stream_property(property_bufferpadding, v, NULL, 0); + } + return v; +} + +void packet_decoder::setEventLogger(event_logger::ptr logger) { + this->set_stream_property(property_eventlogger, 0, logger.get_ptr(), 0); +} + +void packet_decoder::setCheckingIntegrity(bool checkingIntegrity) { + this->set_stream_property(property_checkingintegrity, checkingIntegrity ? 1 : 0, NULL, 0); +} + +void packet_decoder::setAllowDelayed( bool bAllow ) { + this->set_stream_property( property_allow_delayed_output, bAllow ? 1 : 0, NULL, 0); +} + +bool packet_decoder_entry::is_supported_partially_(const GUID& p_owner, t_size p_param1, const void* p_param2, t_size p_param2size) { + bool ret = false; + packet_decoder_entry_v2::ptr v2; + if (v2 &= this) { + ret = v2->is_supported_partially(p_owner, p_param1, p_param2, p_param2size); + } + return ret; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/packet_decoder.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/packet_decoder.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,157 @@ +#pragma once +#include "event_logger.h" +#include "audio_chunk.h" + +//! Provides interface to decode various audio data types to PCM. Use packet_decoder_factory_t template to register. +class NOVTABLE packet_decoder : public service_base { +protected: + //! Prototype of function that must be implemented by packet_decoder implementation but is not accessible through packet_decoder interface itself. + //! Determines whether specific packet_decoder implementation supports specified decoder setup data. + static bool g_is_our_setup(const GUID& p_owner, t_size p_param1, const void* p_param2, t_size p_param2size) { (void)p_owner; (void)p_param1; (void)p_param2; (void)p_param2size; return false; } + + //! Prototype of function that must be implemented by packet_decoder implementation but is not accessible through packet_decoder interface itself. + //! Initializes packet decoder instance with specified decoder setup data. This is called only once, before any other methods. + //! @param p_decode If set to true, decode() and reset_after_seek() calls can be expected later. If set to false, those methods will not be called on this packet_decoder instance - for an example when caller is only retrieving information about the file rather than preparing to decode it. + void open(const GUID& p_owner, bool p_decode, t_size p_param1, const void* p_param2, t_size p_param2size, abort_callback& p_abort) { (void)p_owner; (void)p_decode; (void)p_param1; (void)p_param2; (void)p_param2size; (void)p_abort; throw exception_io_data(); } +public: + + //! Prototype of function that must be implemented by packet_decoder implementation but is not accessible through packet_decoder interface itself. + //! Returns true if this is not the preferred decoder for this format, another one should be used if found. + static bool g_is_supported_partially(const GUID& p_owner, t_size p_param1, const void* p_param2, t_size p_param2size) { (void)p_owner; (void)p_param1; (void)p_param2; (void)p_param2size; return false; } + + + //! Forwards additional information about stream being decoded. \n + //! Calling: this must be called immediately after packet_decoder object is created, before any other methods are called.\n + //! Implementation: this is called after open() (which is called by implementation framework immediately after creation), and before any other methods are called. + virtual t_size set_stream_property(const GUID & p_type,t_size p_param1,const void * p_param2,t_size p_param2size) = 0; + + + //! Retrieves additional user-readable tech infos that decoder can provide. + //! @param p_info Interface receiving information about the stream being decoded. Note that it already contains partial info about the file; existing info should not be erased, decoder-provided info should be merged with it. + virtual void get_info(file_info & p_info) = 0; + + //! Returns many frames back to start decoding when seeking. + virtual unsigned get_max_frame_dependency()=0; + //! Returns much time back to start decoding when seeking (for containers where going back by specified number of frames is not trivial). + virtual double get_max_frame_dependency_time()=0; + + //! Flushes decoder after seeking. + virtual void reset_after_seek()=0; + + //! Decodes a block of audio data.\n + //! It may return empty chunk even when successful (caused by encoder+decoder delay for an example), caller must check for it and handle it appropriately. + //! Called with 0 bytes at the end of stream - if the decoder introduces a delay between input/output, any buffered data should be passed back then. + virtual void decode(const void * p_buffer,t_size p_bytes,audio_chunk & p_chunk,abort_callback & p_abort)=0; + + //! Returns whether this packet decoder supports analyze_first_frame() function. + virtual bool analyze_first_frame_supported() = 0; + //! Optional. Some codecs need to analyze first frame of the stream to return additional info about the stream, such as encoding setup. This can be only called immediately after instantiation (and set_stream_property() if present), before any actual decoding or get_info(). Caller can determine whether this method is supported or not by calling analyze_first_frame_supported(), to avoid reading first frame when decoder won't utiilize the extra info for an example. If particular decoder can't utilize first frame info in any way (and analyze_first_frame_supported() returns false), this function should do nothing and succeed. + virtual void analyze_first_frame(const void * p_buffer,t_size p_bytes,abort_callback & p_abort) = 0; + + //! Static helper, creates a packet_decoder instance and initializes it with specific decoder setup data. + static void g_open(service_ptr_t & p_out,bool p_decode,const GUID & p_owner,t_size p_param1,const void * p_param2,t_size p_param2size,abort_callback & p_abort); + + static const GUID owner_MP4,owner_matroska,owner_MP3,owner_MP2,owner_MP1,owner_MP4_ALAC,owner_ADTS,owner_ADIF, owner_Ogg, owner_MP4_AMR, owner_MP4_AMR_WB, owner_MP4_AC3, owner_MP4_EAC3, owner_MP4_FLAC, owner_MP4_Opus, owner_MP4_MPEGH; + + struct matroska_setup + { + const char * codec_id; + uint32_t sample_rate,sample_rate_output; + uint32_t channels; + size_t codec_private_size; + const void * codec_private; + }; + //owner_MP4: param1 - codec ID (MP4 audio type), param2 - MP4 codec initialization data + //owner_MP3: raw MP3/MP2 file, parameters ignored + //owner_matroska: param2 = matroska_setup struct, param2size size must be equal to sizeof(matroska_setup) + + + //these are used to initialize PCM decoder + static const GUID property_samplerate,property_bitspersample,property_channels,property_byteorder,property_signed,property_channelmask, property_bufferpadding, property_eventlogger, property_checkingintegrity, property_samples_per_frame; + //property_samplerate : param1 == sample rate in hz + //property_bitspersample : param1 == bits per sample + //property_channels : param1 == channel count + //property_byteorder : if (param1) little_endian; else big_endian; + //property_signed : if (param1) signed; else unsigned; + //propery_bufferpadding : param1 == padding of each passed buffer in bytes; retval: decoder's preferred padding + //property_eventlogger : param2 = event logger ptr, NULL to disable, param2size 0 always + //property_checkingintegrity : param1 = checking integrity bool flag + //property_samples_per_frame : param1 = samples per frame + + + + //property_ogg_header : p_param1 = unused, p_param2 = ogg_packet structure, retval: 0 when more headers are wanted, 1 when done parsing headers + //property_ogg_query_sample_rate : returns sample rate, no parameters + //property_ogg_packet : p_param1 = unused, p_param2 = ogg_packet strucute + //property_ogg_qury_preskip : returns preskip samples (Opus) + static const GUID property_ogg_header, property_ogg_query_sample_rate, property_ogg_packet, property_ogg_query_preskip; + + //property_mp4_esds : p_param2 = MP4 ESDS chunk content as needed by some decoders + static const GUID property_mp4_esds; + + // DEPRECATED + static const GUID property_allow_delayed_output; + + // property_mp3_delayless : return non-zero if this codec drops MP3 delay by itself + static const GUID property_mp3_delayless; + + // property_query_delay_samples : + // Return non-zero if this codec has a decoder delay that the caller should deal with. + // Param1 signals sample rate used by input - should always match decoder's sample rate - return zero if it does not match. + static const GUID property_query_delay_samples; + + size_t initPadding(); + void setEventLogger(event_logger::ptr logger); + void setCheckingIntegrity(bool checkingIntegrity); + void setAllowDelayed( bool bAllow = true ); + + FB2K_MAKE_SERVICE_INTERFACE(packet_decoder,service_base); +}; + +class NOVTABLE packet_decoder_streamparse : public packet_decoder +{ +public: + virtual void decode_ex(const void * p_buffer,t_size p_bytes,t_size & p_bytes_processed,audio_chunk & p_chunk,abort_callback & p_abort) = 0; + virtual void analyze_first_frame_ex(const void * p_buffer,t_size p_bytes,t_size & p_bytes_processed,abort_callback & p_abort) = 0; + + FB2K_MAKE_SERVICE_INTERFACE(packet_decoder_streamparse,packet_decoder); +}; + +class NOVTABLE packet_decoder_entry : public service_base { + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(packet_decoder_entry); +public: + virtual bool is_our_setup(const GUID & p_owner,t_size p_param1,const void * p_param2,t_size p_param2size) = 0; + virtual void open(service_ptr_t & p_out,bool p_decode,const GUID & p_owner,t_size p_param1,const void * p_param2,t_size p_param2size,abort_callback & p_abort) = 0; + + //! Returns true if this is not the preferred decoder for this format, another one should be used if found. + bool is_supported_partially_(const GUID& p_owner, t_size p_param1, const void* p_param2, t_size p_param2size); +}; + +class NOVTABLE packet_decoder_entry_v2 : public packet_decoder_entry { + FB2K_MAKE_SERVICE_INTERFACE(packet_decoder_entry_v2, packet_decoder_entry); +public: + //! Returns true if this is not the preferred decoder for this format, another one should be used if found. + virtual bool is_supported_partially(const GUID& p_owner, t_size p_param1, const void* p_param2, t_size p_param2size) = 0; +}; + + +template +class packet_decoder_entry_impl_t : public packet_decoder_entry_v2 +{ +public: + bool is_our_setup(const GUID & p_owner,t_size p_param1,const void * p_param2,t_size p_param2size) override { + return T::g_is_our_setup(p_owner,p_param1,p_param2,p_param2size); + } + void open(service_ptr_t & p_out,bool p_decode,const GUID & p_owner,t_size p_param1,const void * p_param2,t_size p_param2size,abort_callback & p_abort) override { + PFC_ASSERT(is_our_setup(p_owner,p_param1,p_param2,p_param2size)); + service_ptr_t instance = new service_impl_t(); + instance->open(p_owner,p_decode,p_param1,p_param2,p_param2size,p_abort); + p_out = instance.get_ptr(); + } + bool is_supported_partially(const GUID& p_owner, t_size p_param1, const void* p_param2, t_size p_param2size) override { + return T::g_is_supported_partially(p_owner, p_param1, p_param2, p_param2size); + } +}; + +template +class packet_decoder_factory_t : public service_factory_single_t > {}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/play_callback.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/play_callback.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,164 @@ +#pragma once +#include "callback_merit.h" + +// IMPLEMENTATION NOTE: all callback methods declared here could not be declared noexcept for historical reasons, but it's strongly recommended that your overrides of these methods are noexcept. + +/*! +Class receiving notifications about playback events. Note that all methods are called only from app's main thread. +Use play_callback_manager to register your dynamically created instances. Statically registered version is available too - see play_callback_static. +*/ +class NOVTABLE play_callback { +public: + //! Playback process is being initialized. on_playback_new_track() should be called soon after this when first file is successfully opened for decoding. + virtual void on_playback_starting(play_control::t_track_command p_command,bool p_paused) = 0; + //! Playback advanced to new track. + virtual void on_playback_new_track(metadb_handle_ptr p_track) = 0; + //! Playback stopped. + virtual void on_playback_stop(play_control::t_stop_reason p_reason) = 0; + //! User has seeked to specific time. + virtual void on_playback_seek(double p_time) = 0; + //! Called on pause/unpause. + virtual void on_playback_pause(bool p_state) = 0; + //! Called when currently played file gets edited. + virtual void on_playback_edited(metadb_handle_ptr p_track) = 0; + //! Dynamic info (VBR bitrate etc) change. + virtual void on_playback_dynamic_info(const file_info & p_info) = 0; + //! Per-track dynamic info (stream track titles etc) change. Happens less often than on_playback_dynamic_info(). + virtual void on_playback_dynamic_info_track(const file_info & p_info) = 0; + //! Called every second, for time display + virtual void on_playback_time(double p_time) = 0; + //! User changed volume settings. Possibly called when not playing. + //! @param p_new_val new volume level in dB; 0 for full volume. + virtual void on_volume_change(float p_new_val) = 0; + + enum { + flag_on_playback_starting = 1 << 0, + flag_on_playback_new_track = 1 << 1, + flag_on_playback_stop = 1 << 2, + flag_on_playback_seek = 1 << 3, + flag_on_playback_pause = 1 << 4, + flag_on_playback_edited = 1 << 5, + flag_on_playback_dynamic_info = 1 << 6, + flag_on_playback_dynamic_info_track = 1 << 7, + flag_on_playback_time = 1 << 8, + flag_on_volume_change = 1 << 9, + + flag_on_playback_all = flag_on_playback_starting | flag_on_playback_new_track | + flag_on_playback_stop | flag_on_playback_seek | + flag_on_playback_pause | flag_on_playback_edited | + flag_on_playback_dynamic_info | flag_on_playback_dynamic_info_track | flag_on_playback_time, + }; +protected: + play_callback() {} + ~play_callback() {} +}; + +//! Standard API (always present); manages registrations of dynamic play_callbacks. \n +//! Usage: use play_callback_manager::get() to obtain on instance. \n +//! Do not reimplement. +class NOVTABLE play_callback_manager : public service_base { + FB2K_MAKE_SERVICE_COREAPI(play_callback_manager); +public: + //! Registers a play_callback object. + //! @param p_callback Interface to register. + //! @param p_flags Indicates which notifications are requested. + //! @param p_forward_status_on_register Set to true to have the callback immediately receive current playback status as notifications if playback is active (eg. to receive info about playback process that started before our callback was registered). + virtual void register_callback(play_callback * p_callback,unsigned p_flags,bool p_forward_status_on_register) = 0; + //! Unregisters a play_callback object. + //! @p_callback Previously registered interface to unregister. + virtual void unregister_callback(play_callback * p_callback) = 0; +}; + +//! \since 2.0 +class NOVTABLE play_callback_manager_v2 : public play_callback_manager { + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(play_callback_manager_v2, play_callback_manager); +public: + virtual void set_callback_merit(play_callback*, fb2k::callback_merit_t) = 0; +}; + +//! Implementation helper. +class play_callback_impl_base : public play_callback { +public: + play_callback_impl_base(unsigned p_flags = 0xFFFFFFFF) { + if (p_flags != 0) play_callback_manager::get()->register_callback(this,p_flags,false); + } + ~play_callback_impl_base() { + play_callback_manager::get()->unregister_callback(this); + } + void play_callback_reregister(unsigned flags, bool refresh = false) { + auto api = play_callback_manager::get(); + api->unregister_callback(this); + if (flags != 0) api->register_callback(this,flags,refresh); + } + void on_playback_starting(play_control::t_track_command p_command, bool p_paused) override { (void)p_command; (void)p_paused; } + void on_playback_new_track(metadb_handle_ptr p_track) override { (void)p_track; } + void on_playback_stop(play_control::t_stop_reason p_reason) override { (void)p_reason; } + void on_playback_seek(double p_time) override { (void)p_time; } + void on_playback_pause(bool p_state) override { (void)p_state; } + void on_playback_edited(metadb_handle_ptr p_track) override { (void)p_track; } + void on_playback_dynamic_info(const file_info& p_info) override { (void)p_info; } + void on_playback_dynamic_info_track(const file_info& p_info) override { (void)p_info; } + void on_playback_time(double p_time) override { (void)p_time; } + void on_volume_change(float p_new_val) override { (void)p_new_val; } + + PFC_CLASS_NOT_COPYABLE_EX(play_callback_impl_base) +}; + +//! Static (autoregistered) version of play_callback. Use play_callback_static_factory_t to register. +class play_callback_static : public service_base, public play_callback { + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(play_callback_static); +public: + //! Controls which methods your callback wants called; returned value should not change in run time, you should expect it to be queried only once (on startup). See play_callback::flag_* constants. + virtual unsigned get_flags() = 0; +}; + +template +class play_callback_static_factory_t : public service_factory_single_t {}; + + +//! Gets notified about tracks being played. Notification occurs when at least 60s of the track has been played, or the track has reached its end after at least 1/3 of it has been played through. +//! Use playback_statistics_collector_factory_t to register. +class NOVTABLE playback_statistics_collector : public service_base { + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(playback_statistics_collector); +public: + virtual void on_item_played(metadb_handle_ptr p_item) = 0; +}; + +template +class playback_statistics_collector_factory_t : public service_factory_single_t {}; + + + + +//! Helper providing a simplified interface for receiving playback events, in case your code does not care about the kind of playback event that has occurred; useful typically for GUI/rendering code that just refreshes some control whenever a playback state change occurs. +class playback_event_notify : private play_callback_impl_base { +public: + playback_event_notify(playback_control::t_display_level level = playback_control::display_level_all) : play_callback_impl_base(GrabCBFlags(level)) {} + + static t_uint32 GrabCBFlags(playback_control::t_display_level level) { + t_uint32 flags = flag_on_playback_starting | flag_on_playback_new_track | flag_on_playback_stop | flag_on_playback_pause | flag_on_playback_edited | flag_on_volume_change; + if (level >= playback_control::display_level_titles) flags |= flag_on_playback_dynamic_info_track; + if (level >= playback_control::display_level_all) flags |= flag_on_playback_seek | flag_on_playback_dynamic_info | flag_on_playback_time; + return flags; + } +protected: + virtual void on_playback_event() {} +private: + void on_playback_starting(play_control::t_track_command,bool) override {on_playback_event();} + void on_playback_new_track(metadb_handle_ptr) override {on_playback_event();} + void on_playback_stop(play_control::t_stop_reason) override {on_playback_event();} + void on_playback_seek(double) override {on_playback_event();} + void on_playback_pause(bool) override {on_playback_event();} + void on_playback_edited(metadb_handle_ptr) override {on_playback_event();} + void on_playback_dynamic_info(const file_info &) override {on_playback_event();} + void on_playback_dynamic_info_track(const file_info &) override {on_playback_event();} + void on_playback_time(double) override {on_playback_event();} + void on_volume_change(float) override {on_playback_event();} +}; + +class playback_volume_notify : private play_callback_impl_base { +public: + playback_volume_notify() : play_callback_impl_base(flag_on_volume_change) {} + // override me + void on_volume_change(float p_new_val) override { (void)p_new_val; } +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/playable_location.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/playable_location.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,76 @@ +#include "foobar2000-sdk-pch.h" + +int playable_location::g_compare(const playable_location & p_item1,const playable_location & p_item2) { + int ret = metadb::path_compare(p_item1.get_path(),p_item2.get_path()); + if (ret != 0) return ret; + return pfc::compare_t(p_item1.get_subsong(),p_item2.get_subsong()); +} +int playable_location::path_compare( const char * p1, const char * p2 ) { + return metadb::path_compare(p1, p2); +} + +bool playable_location::g_equals( const playable_location & p_item1, const playable_location & p_item2) { + return g_compare(p_item1, p_item2) == 0; +} + +pfc::string_base & operator<<(pfc::string_base & p_fmt,const playable_location & p_location) +{ + p_fmt << "\"" << file_path_display(p_location.get_path()) << "\""; + t_uint32 index = p_location.get_subsong_index(); + if (index != 0) p_fmt << " / index: " << p_location.get_subsong_index(); + return p_fmt; +} + + +bool playable_location::operator==(const playable_location & p_other) const { + return metadb::path_compare(get_path(),p_other.get_path()) == 0 && get_subsong() == p_other.get_subsong(); +} +bool playable_location::operator!=(const playable_location & p_other) const { + return !(*this == p_other); +} + +void playable_location::reset() { + set_path("");set_subsong(0); +} + +bool playable_location::is_empty() const { + return * get_path() == 0; +} + +bool playable_location::is_valid() const { + return !is_empty(); +} + +const char * playable_location_impl::get_path() const { + return m_path; +} + +void playable_location_impl::set_path(const char* p_path) { + m_path=p_path; +} + +t_uint32 playable_location_impl::get_subsong() const { + return m_subsong; +} + +void playable_location_impl::set_subsong(t_uint32 p_subsong) { + m_subsong=p_subsong; +} + +const playable_location_impl & playable_location_impl::operator=(const playable_location & src) { + copy(src);return *this; +} + +playable_location_impl::playable_location_impl() : m_subsong(0) {} +playable_location_impl::playable_location_impl(const char * p_path,t_uint32 p_subsong) : m_path(p_path), m_subsong(p_subsong) {} +playable_location_impl::playable_location_impl(const playable_location & src) {copy(src);} + + + +void make_playable_location::set_path(const char*) {throw pfc::exception_not_implemented();} +void make_playable_location::set_subsong(t_uint32) {throw pfc::exception_not_implemented();} + +const char * make_playable_location::get_path() const {return path;} +t_uint32 make_playable_location::get_subsong() const {return num;} + +make_playable_location::make_playable_location(const char * p_path,t_uint32 p_num) : path(p_path), num(p_num) {} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/playable_location.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/playable_location.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,92 @@ +#pragma once + +//playable_location stores location of a playable resource, currently implemented as file path and integer for indicating multiple playable "subsongs" per file +//also see: file_info.h +//for getting more info about resource referenced by a playable_location, see metadb.h + +//char* strings are all UTF-8 + +class NOVTABLE playable_location//interface (for passing around between DLLs) +{ +public: + virtual const char * get_path() const = 0; + virtual void set_path(const char*) = 0; + virtual t_uint32 get_subsong() const = 0; + virtual void set_subsong(t_uint32) = 0; + + void copy(const playable_location & p_other) { + set_path(p_other.get_path()); + set_subsong(p_other.get_subsong()); + } + + static int g_compare(const playable_location & p_item1,const playable_location & p_item2); + static bool g_equals( const playable_location & p_item1, const playable_location & p_item2); + + const playable_location & operator=(const playable_location & src) {copy(src);return *this;} + + bool operator==(const playable_location & p_other) const; + bool operator!=(const playable_location & p_other) const; + + void reset(); + + inline t_uint32 get_subsong_index() const {return get_subsong();} + inline void set_subsong_index(t_uint32 v) {set_subsong(v);} + + bool is_empty() const; + bool is_valid() const; + + + enum {case_sensitive = true}; + typedef pfc::comparator_strcmp path_comparator; + + class comparator { + public: + static int compare(const playable_location & v1, const playable_location & v2) {return g_compare(v1,v2);} + }; + static int path_compare( const char * p1, const char * p2 ); + +protected: + playable_location() {} + ~playable_location() {} +}; + +typedef playable_location * pplayable_location; +typedef playable_location const * pcplayable_location; +typedef playable_location & rplayable_location; +typedef playable_location const & rcplayable_location; + +class playable_location_impl : public playable_location//implementation +{ +public: + virtual const char * get_path() const; + virtual void set_path(const char* p_path); + virtual t_uint32 get_subsong() const; + virtual void set_subsong(t_uint32 p_subsong); + + const playable_location_impl & operator=(const playable_location & src); + + playable_location_impl(); + playable_location_impl(const char * p_path,t_uint32 p_subsong); + playable_location_impl(const playable_location & src); +private: + pfc::string_simple m_path; + t_uint32 m_subsong; +}; + +// usage: somefunction( make_playable_location("file://c:\blah.ogg",0) ); +// only for use as a parameter to a function taking const playable_location & +class make_playable_location : public playable_location +{ + const char * path; + t_uint32 num; + + virtual void set_path(const char*); + virtual void set_subsong(t_uint32); +public: + virtual const char * get_path() const; + virtual t_uint32 get_subsong() const; + + make_playable_location(const char * p_path,t_uint32 p_num); +}; + +pfc::string_base & operator<<(pfc::string_base & p_fmt,const playable_location & p_location); diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/playback_control.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/playback_control.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,141 @@ +#include "foobar2000-sdk-pch.h" +#include "playback_control.h" +#include "titleformat.h" + +static double parseFraction(const char * fraction) { + unsigned v = 0, d = 1; + while(pfc::char_is_numeric( *fraction) ) { + d *= 10; + v *= 10; + v += (unsigned) ( *fraction - '0' ); + ++fraction; + } + PFC_ASSERT( *fraction == 0 ); + return (double)v / (double)d; +} + +static double parse_time(const char * time) { + unsigned vTotal = 0, vCur = 0; + for(;;) { + char c = *time++; + if (c == 0) return (double) (vTotal + vCur); + else if (pfc::char_is_numeric( c ) ) { + vCur = vCur * 10 + (unsigned)(c-'0'); + } else if (c == ':') { + if (vCur >= 60) {PFC_ASSERT(!"Invalid input"); return 0; } + vTotal += vCur; vCur = 0; vTotal *= 60; + } else if (c == '.') { + return (double) (vTotal + vCur) + parseFraction(time); + } else { + PFC_ASSERT(!"Invalid input"); return 0; + } + } +} + +double playback_control::playback_get_length() +{ + double rv = 0; + metadb_handle_ptr ptr; + if (get_now_playing(ptr)) + { + rv = ptr->get_length(); + } + return rv; +} + +double playback_control::playback_get_length_ex() { + double rv = 0; + metadb_handle_ptr ptr; + if (get_now_playing(ptr)) + { + rv = ptr->get_length(); + if (rv <= 0) { + pfc::string8 temp; + titleformat_object::ptr script; + titleformat_compiler::get()->compile_force(script, "[%length_ex%]"); + this->playback_format_title(NULL, temp, script, NULL, display_level_titles); + if (temp.length() > 0) rv = parse_time(temp); + } + } + return rv; +} + + + + + + +void playback_control::userPrev() { + userActionHook(); + if (this->is_playing() && this->playback_can_seek() && this->playback_get_position() > 5) { + this->playback_seek(0); + } else { + this->previous(); + } +} + +void playback_control::userNext() { + userActionHook(); + this->start(track_command_next); +} + +void playback_control::userMute() { + userActionHook(); + this->volume_mute_toggle(); +} + +void playback_control::userStop() { + userActionHook(); + this->stop(); +} + +void playback_control::userPlay() { + userActionHook(); + this->play_or_pause(); +} + +void playback_control::userPause() { + userActionHook(); + nonUserPause(); +} + +void playback_control::nonUserPause() { + if (this->is_playing()) { + this->pause(true); + } +} + +void playback_control::userStart() { + userActionHook(); + if (this->is_playing()) { + this->pause(false); + } else { + this->start(); + } +} +static const double seekDelta = 30; +void playback_control::userFastForward() { + userActionHook(); + if (!this->playback_can_seek()) { + this->userNext(); return; + } + this->playback_seek_delta(seekDelta); +} + +void playback_control::userRewind() { + userActionHook(); + if (!this->playback_can_seek()) { + this->userPrev(); return; + } + double p = this->playback_get_position(); + if (p < 0) return; + if (p < seekDelta) { + if (p < seekDelta / 3) { + this->userPrev(); + } else { + this->playback_seek(0); + } + } else { + this->playback_seek_delta(-30); + } +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/playback_control.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/playback_control.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,205 @@ +#pragma once + +//! Provides control for various playback-related operations. \n +//! All methods provided by this interface work from main app thread only. Calling from another thread will do nothing or trigger an exception. If you need to trigger one of playback_control methods from another thread, see main_thread_callback. \n +//! Do not call playback_control methods from inside any kind of global callback (e.g. playlist callback), otherwise race conditions may occur. \n +//! Use playback_control::get() to obtain an instance. +class NOVTABLE playback_control : public service_base { + FB2K_MAKE_SERVICE_COREAPI(playback_control); +public: + + // Playback stop reason enum. + enum t_stop_reason { + stop_reason_user = 0, + stop_reason_eof, + stop_reason_starting_another, + stop_reason_shutting_down, + }; + + // Playback start mode enum. + enum t_track_command { + track_command_default = 0, + track_command_play, + //! Plays the next track from the current playlist according to the current playback order. + track_command_next, + //! Plays the previous track from the current playlist according to the current playback order. + track_command_prev, + //! For internal use only, do not use. + track_command_settrack, + //! Plays a random track from the current playlist. + track_command_rand, + + //! For internal use only, do not use. + track_command_resume, + }; + + //! Retrieves now playing item handle. + //! @returns true on success, false on failure (not playing). + virtual bool get_now_playing(metadb_handle_ptr & p_out) = 0; + //! Starts playback. If playback is already active, existing process is stopped first. + //! @param p_command Specifies what track to start playback from. See t_track_Command enum for more info. + //! @param p_paused Specifies whether playback should be started as paused. + virtual void start(t_track_command p_command = track_command_play,bool p_paused = false) = 0; + //! Stops playback. + virtual void stop() = 0; + //! Returns whether playback is active. + virtual bool is_playing() = 0; + //! Returns whether playback is active and in paused state. + virtual bool is_paused() = 0; + //! Toggles pause state if playback is active. + //! @param p_state set to true when pausing or to false when unpausing. + virtual void pause(bool p_state) = 0; + + //! Retrieves stop-after-current-track option state. + virtual bool get_stop_after_current() = 0; + //! Alters stop-after-current-track option state. + virtual void set_stop_after_current(bool p_state) = 0; + + //! Alters playback volume level. + //! @param p_value volume in dB; 0 for full volume. + virtual void set_volume(float p_value) = 0; + //! Retrieves playback volume level. + //! @returns current playback volume level, in dB; 0 for full volume. + virtual float get_volume() = 0; + //! Alters playback volume level one step up. + virtual void volume_up() = 0; + //! Alters playback volume level one step down. + virtual void volume_down() = 0; + //! Toggles playback mute state. + virtual void volume_mute_toggle() = 0; + //! Seeks in currenly played track to specified time. + //! @param p_time target time in seconds. + virtual void playback_seek(double p_time) = 0; + //! Seeks in currently played track by specified time forward or back. + //! @param p_delta time in seconds to seek by; can be positive to seek forward or negative to seek back. + virtual void playback_seek_delta(double p_delta) = 0; + //! Returns whether currently played track is seekable. If it's not, playback_seek/playback_seek_delta calls will be ignored. + virtual bool playback_can_seek() = 0; + //! Returns current playback position within currently played track, in seconds. + virtual double playback_get_position() = 0; + + //! Type used to indicate level of dynamic playback-related info displayed. Safe to use with <> opereators, e.g. level above N always includes information rendered by level N. + enum t_display_level { + //! No playback-related info + display_level_none, + //! Static info and is_playing/is_paused stats + display_level_basic, + //! display_level_basic + dynamic track titles on e.g. live streams + display_level_titles, + //! display_level_titles + timing + VBR bitrate display etc + display_level_all, + }; + + //! Renders information about currently playing item. + //! @param p_hook Optional callback object overriding fields and functions; set to NULL if not used. + //! @param p_out String receiving the output on success. + //! @param p_script Titleformat script to use. Use titleformat_compiler service to create one. + //! @param p_filter Optional callback object allowing input to be filtered according to context (i.e. removal of linebreak characters present in tags when rendering playlist lines). Set to NULL when not used. + //! @param p_level Indicates level of dynamic playback-related info displayed. See t_display_level enum for more details. + //! @returns true on success, false when no item is currently being played. + virtual bool playback_format_title(titleformat_hook * p_hook,pfc::string_base & p_out,const service_ptr_t & p_script,titleformat_text_filter * p_filter,t_display_level p_level) = 0; + + + + //! Helper; renders info about any item, including currently playing item info if the item is currently played. + bool playback_format_title_ex(metadb_handle_ptr p_item,titleformat_hook * p_hook,pfc::string_base & p_out,const service_ptr_t & p_script,titleformat_text_filter * p_filter,t_display_level p_level) { + if (p_item.is_empty()) return playback_format_title(p_hook,p_out,p_script,p_filter,p_level); + metadb_handle_ptr temp; + if (get_now_playing(temp)) { + if (temp == p_item) { + return playback_format_title(p_hook,p_out,p_script,p_filter,p_level); + } + } + p_item->format_title(p_hook,p_out,p_script,p_filter); + return true; + } + + //! Helper; retrieves length of currently playing item. + double playback_get_length(); + // Extended version: queries dynamic track info for the rare cases where that is different from static info. + double playback_get_length_ex(); + + //! Toggles stop-after-current state. + void toggle_stop_after_current() {set_stop_after_current(!get_stop_after_current());} + //! Toggles pause state. + void toggle_pause() {pause(!is_paused());} + + //! Starts playback if playback is inactive, otherwise toggles pause. + void play_or_pause() {if (is_playing()) toggle_pause(); else start();} + void play_or_unpause() { if (is_playing()) pause(false); else start();} + + void previous() { start(track_command_prev); } + void next() { start(track_command_next); } + + //deprecated + inline void play_start(t_track_command p_command = track_command_play,bool p_paused = false) {start(p_command,p_paused);} + //deprecated + inline void play_stop() {stop();} + + bool is_muted() {return get_volume() == volume_mute;} + + static const int volume_mute = -100; + + + + // new fb2k mobile specific user command handlers + void userPrev(); + void userNext(); + void userMute(); + void userStop(); + void userPlay(); + void userPause(); + void userStart(); + void userFastForward(); + void userRewind(); + void nonUserPause(); + + // #$@! FiiO hack $!#@ + void userActionHook() {} +}; + +class playback_control_v2 : public playback_control { + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(playback_control_v2,playback_control); +public: + //! Returns user-specified the step dB value for volume decrement/increment. + virtual float get_volume_step() = 0; +}; + +//! \since 1.2 +class playback_control_v3 : public playback_control_v2 { + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(playback_control_v3, playback_control_v2); +public: + //! Custom volume API - for use with specific output devices only. \n + //! Note that custom volume SHOULD NOT EVER be presented as a slider where the user can immediately go to the maximum value. \n + //! Custom volume mode dispatches on_volume_changed callbacks on change, though the passed value is meaningless; \n + //! the components should query the current value from playback_control_v3. \n + //! Note that custom volume mode makes set_volume() / get_volume() meaningless, \n + //! but volume_up() / volume_down() / volume_mute_toggle() still work like they should (increment/decrement by one unit). + //! @returns whether custom volume mode is active. + virtual bool custom_volume_is_active() = 0; + //! Retrieves the current volume value for the custom volume mode. \n + //! The volume units are arbitrary and specified by the device maker; see also: custom_volume_min(), custom_volume_max(). + virtual int custom_volume_get() = 0; + //! Sets the current volume value for the custom volume mode. \n + //! The volume units are arbitrary and specified by the device maker; see also: custom_volume_min(), custom_volume_max(). + //! CAUTION: you should NOT allow the user to easily go immediately to any value, it might blow their speakers out! + virtual void custom_volume_set(int val) = 0; + //! Returns the minimum custom volume value for the current output device. + virtual int custom_volume_min() = 0; + //! Returns the maximum custom volume value for the current output device. + virtual int custom_volume_max() = 0; + + virtual void restart() = 0; +}; + +//for compatibility with old code +typedef playback_control play_control; + +namespace fb2k { + metadb_handle_ptr nowPlaying(bool bAudible = false); + metadb_handle_ptr nowPlayingAudible(); + bool isNowPlaying(metadb_handle_ptr const&, bool bAudible = false); + bool isNowPlayingAudible(metadb_handle_ptr const&); + bool isNowPlaying(const playable_location&, bool bAudible = false); + bool isNowPlayingAudible(const playable_location&); +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/playback_stream_capture.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/playback_stream_capture.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,65 @@ +#pragma once + +//! \since 1.0 +//! Implemented by components - register with playback_stream_capture methods. +class NOVTABLE playback_stream_capture_callback { +public: + //! Delivers a real-time chunk of audio data. \n + //! Audio is roughly synchronized with what can currently be heard. This API is provided for utility purposes such as streaming; if you want to implement a visualisation, use the visualisation_manager API instead. \n + //! Contrary to visualisation methods, this guarantees that all played audio data is coming thru. \n + //! Called only from the main thread. \n + virtual void on_chunk(const audio_chunk &) = 0; +protected: + playback_stream_capture_callback() {} + ~playback_stream_capture_callback() {} +}; + +//! \since 1.0 +//! Implemented by core. +class NOVTABLE playback_stream_capture : public service_base { + FB2K_MAKE_SERVICE_COREAPI(playback_stream_capture) +public: + //! Register a playback_stream_capture_callback. \n + //! Possible to call only from the main thread. + virtual void add_callback(playback_stream_capture_callback * ) = 0; + //! Un-register a playback_stream_capture_callback. \n + //! Possible to call only from the main thread. + virtual void remove_callback(playback_stream_capture_callback * ) = 0; +}; + +//! \since 2.0. +//! Implemented by core. +class NOVTABLE playback_stream_capture_v2 : public playback_stream_capture { + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(playback_stream_capture_v2, playback_stream_capture); +public: + //! @param requestInterval Interval, in seconds, in which the callback expects to be called. \n + //! Set to -1 to use defaults. \n + //! Note that if many callbacks are registered, they all get called at once; one callback requesting lower interval lowers the interval for all. \n + //! Non negative values are clamped to allowed range, that is, request of zero results in lowest possible update interval. + virtual void add_callback_v2(playback_stream_capture_callback* cb, double requestInterval = -1) = 0; +}; + +class playback_stream_capture_callback_impl : public playback_stream_capture_callback { +public: + void on_chunk(const audio_chunk&) override {} + + //! @param interval requested update interval, see playback_stream_capture_v2::add_callback_v2() + playback_stream_capture_callback_impl(double interval = -1) { + PFC_ASSERT(core_api::is_main_thread()); +#if FOOBAR2020 + playback_stream_capture_v2::get()->add_callback_v2(this, interval); +#else + auto api = playback_stream_capture::get(); + playback_stream_capture_v2::ptr v2; + if (v2 &= api) v2->add_callback_v2(this, interval); + else api->add_callback(this); +#endif + } + ~playback_stream_capture_callback_impl() { + PFC_ASSERT(core_api::is_main_thread()); + playback_stream_capture::get()->remove_callback(this); + } + + playback_stream_capture_callback_impl(const playback_stream_capture_callback_impl&) = delete; + void operator=(const playback_stream_capture_callback_impl&) = delete; +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/playlist.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/playlist.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,1008 @@ +#include "foobar2000-sdk-pch.h" +#include "playlist.h" + +namespace { + class enum_items_callback_func : public playlist_manager::enum_items_callback { + public: + bool on_item(t_size p_index, const metadb_handle_ptr& p_location, bool b_selected) override { return f(p_index, p_location, b_selected); } + playlist_manager::enum_items_func f; + }; + class enum_items_callback_retrieve_item : public playlist_manager::enum_items_callback + { + metadb_handle_ptr m_item; + public: + enum_items_callback_retrieve_item() : m_item(0) {} + bool on_item(t_size p_index,const metadb_handle_ptr & p_location,bool b_selected) + { + (void)p_index; (void)b_selected; + PFC_ASSERT(m_item.is_empty()); + m_item = p_location; + return false; + } + inline const metadb_handle_ptr & get_item() {return m_item;} + }; + + class enum_items_callback_retrieve_selection : public playlist_manager::enum_items_callback + { + bool m_state; + public: + enum_items_callback_retrieve_selection() : m_state(false) {} + bool on_item(t_size p_index,const metadb_handle_ptr & p_location,bool b_selected) + { + (void)p_index; (void)p_location; + m_state = b_selected; + return false; + } + inline bool get_state() {return m_state;} + }; + + class enum_items_callback_retrieve_selection_mask : public playlist_manager::enum_items_callback + { + bit_array_var & m_out; + public: + enum_items_callback_retrieve_selection_mask(bit_array_var & p_out) : m_out(p_out) {} + bool on_item(t_size p_index,const metadb_handle_ptr & p_location,bool b_selected) + { + (void)p_location; + m_out.set(p_index,b_selected); + return true; + } + }; + + class enum_items_callback_retrieve_all_items : public playlist_manager::enum_items_callback + { + pfc::list_base_t & m_out; + public: + enum_items_callback_retrieve_all_items(pfc::list_base_t & p_out) : m_out(p_out) {m_out.remove_all();} + bool on_item(t_size p_index,const metadb_handle_ptr & p_location,bool b_selected) + { + (void)p_index; (void)b_selected; + m_out.add_item(p_location); + return true; + } + }; + + class enum_items_callback_retrieve_selected_items : public playlist_manager::enum_items_callback + { + pfc::list_base_t & m_out; + public: + enum_items_callback_retrieve_selected_items(pfc::list_base_t & p_out) : m_out(p_out) {m_out.remove_all();} + bool on_item(t_size p_index,const metadb_handle_ptr & p_location,bool b_selected) + { + (void)p_index; + if (b_selected) m_out.add_item(p_location); + return true; + } + }; + + class enum_items_callback_count_selection : public playlist_manager::enum_items_callback + { + t_size m_counter,m_max; + public: + enum_items_callback_count_selection(t_size p_max) : m_max(p_max), m_counter(0) {} + bool on_item(t_size p_index,const metadb_handle_ptr & p_location,bool b_selected) + { + (void)p_index; (void)p_location; + if (b_selected) + { + if (++m_counter >= m_max) return false; + } + return true; + } + + inline t_size get_count() {return m_counter;} + }; + +} + +void playlist_manager::playlist_get_all_items(t_size p_playlist,pfc::list_base_t & out) +{ + playlist_get_items(p_playlist,out, pfc::bit_array_true()); +} + +void playlist_manager::playlist_get_selected_items(t_size p_playlist,pfc::list_base_t & out) +{ + enum_items_callback_retrieve_selected_items cb(out); + playlist_enum_items(p_playlist,cb,pfc::bit_array_true()); +} + +void playlist_manager::playlist_get_selection_mask(t_size p_playlist,bit_array_var & out) +{ + enum_items_callback_retrieve_selection_mask cb(out); + playlist_enum_items(p_playlist,cb,pfc::bit_array_true()); +} + +bool playlist_manager::playlist_is_item_selected(t_size p_playlist,t_size p_item) +{ + enum_items_callback_retrieve_selection callback; + playlist_enum_items(p_playlist,callback,pfc::bit_array_one(p_item)); + return callback.get_state(); +} + +metadb_handle_ptr playlist_manager::playlist_get_item_handle(t_size playlist, t_size item) { + metadb_handle_ptr temp; + if (!playlist_get_item_handle(temp, playlist, item)) throw pfc::exception_invalid_params(); + PFC_ASSERT( temp.is_valid() ); + return temp; + +} +bool playlist_manager::playlist_get_item_handle(metadb_handle_ptr & p_out,t_size p_playlist,t_size p_item) +{ + enum_items_callback_retrieve_item callback; + playlist_enum_items(p_playlist,callback,pfc::bit_array_one(p_item)); + p_out = callback.get_item(); + return p_out.is_valid(); +} + +void playlist_manager::g_make_selection_move_permutation(t_size * p_output,t_size p_count,const bit_array & p_selection,int p_delta) { + pfc::create_move_items_permutation(p_output,p_count,p_selection,p_delta); +} + +bool playlist_manager::playlist_move_selection(t_size p_playlist,int p_delta) { + if (p_delta==0) return true; + + t_size count = playlist_get_item_count(p_playlist); + + pfc::array_t order; order.set_size(count); + pfc::array_t selection; selection.set_size(count); + + pfc::bit_array_var_table mask(selection.get_ptr(),selection.get_size()); + playlist_get_selection_mask(p_playlist, mask); + g_make_selection_move_permutation(order.get_ptr(),count,mask,p_delta); + return playlist_reorder_items(p_playlist,order.get_ptr(),count); +} + +//retrieving status +t_size playlist_manager::activeplaylist_get_item_count() +{ + t_size playlist = get_active_playlist(); + if (playlist == SIZE_MAX) return 0; + else return playlist_get_item_count(playlist); +} + +void playlist_manager::playlist_enum_items(size_t which, enum_items_func f, const bit_array& mask) { + enum_items_callback_func cb; cb.f = f; + this->playlist_enum_items(which, cb, mask); +} + +void playlist_manager::activeplaylist_enum_items(enum_items_callback & p_callback,const bit_array & p_mask) +{ + t_size playlist = get_active_playlist(); + if (playlist != SIZE_MAX) playlist_enum_items(playlist,p_callback,p_mask); +} +void playlist_manager::activeplaylist_enum_items(enum_items_func f, const bit_array& mask) { + size_t playlist = get_active_playlist(); + if (playlist != SIZE_MAX) playlist_enum_items(playlist, f, mask); +} +t_size playlist_manager::activeplaylist_get_focus_item() +{ + t_size playlist = get_active_playlist(); + if (playlist == SIZE_MAX) return SIZE_MAX; + else return playlist_get_focus_item(playlist); +} + +bool playlist_manager::activeplaylist_get_name(pfc::string_base & p_out) +{ + t_size playlist = get_active_playlist(); + if (playlist == SIZE_MAX) return false; + else return playlist_get_name(playlist,p_out); +} + +//modifying playlist +bool playlist_manager::activeplaylist_reorder_items(const t_size * order,t_size count) +{ + t_size playlist = get_active_playlist(); + if (playlist != SIZE_MAX) return playlist_reorder_items(playlist,order,count); + else return false; +} + +void playlist_manager::activeplaylist_set_selection(const bit_array & affected,const bit_array & status) +{ + t_size playlist = get_active_playlist(); + if (playlist != SIZE_MAX) playlist_set_selection(playlist,affected,status); +} + +bool playlist_manager::activeplaylist_remove_items(const bit_array & mask) +{ + t_size playlist = get_active_playlist(); + if (playlist != SIZE_MAX) return playlist_remove_items(playlist,mask); + else return false; +} + +bool playlist_manager::activeplaylist_replace_item(t_size p_item,const metadb_handle_ptr & p_new_item) +{ + t_size playlist = get_active_playlist(); + if (playlist != SIZE_MAX) return playlist_replace_item(playlist,p_item,p_new_item); + else return false; +} + +void playlist_manager::activeplaylist_set_focus_item(t_size p_item) +{ + t_size playlist = get_active_playlist(); + if (playlist != SIZE_MAX) playlist_set_focus_item(playlist,p_item); +} + +t_size playlist_manager::activeplaylist_insert_items(t_size p_base,const pfc::list_base_const_t & data,const bit_array & p_selection) +{ + t_size playlist = get_active_playlist(); + if (playlist != SIZE_MAX) return playlist_insert_items(playlist,p_base,data,p_selection); + else return SIZE_MAX; +} + +void playlist_manager::activeplaylist_ensure_visible(t_size p_item) +{ + t_size playlist = get_active_playlist(); + if (playlist != SIZE_MAX) playlist_ensure_visible(playlist,p_item); +} + +bool playlist_manager::activeplaylist_rename(const char * p_name,t_size p_name_len) +{ + t_size playlist = get_active_playlist(); + if (playlist != SIZE_MAX) return playlist_rename(playlist,p_name,p_name_len); + else return false; +} + +bool playlist_manager::activeplaylist_is_item_selected(t_size p_item) +{ + t_size playlist = get_active_playlist(); + if (playlist != pfc_infinite) return playlist_is_item_selected(playlist,p_item); + else return false; +} + +metadb_handle_ptr playlist_manager::activeplaylist_get_item_handle(t_size p_item) { + metadb_handle_ptr temp; + if (!activeplaylist_get_item_handle(temp, p_item)) throw pfc::exception_invalid_params(); + PFC_ASSERT( temp.is_valid() ); + return temp; +} +bool playlist_manager::activeplaylist_get_item_handle(metadb_handle_ptr & p_out,t_size p_item) +{ + t_size playlist = get_active_playlist(); + if (playlist != SIZE_MAX) return playlist_get_item_handle(p_out,playlist,p_item); + else return false; +} + +void playlist_manager::activeplaylist_move_selection(int p_delta) +{ + t_size playlist = get_active_playlist(); + if (playlist != SIZE_MAX) playlist_move_selection(playlist,p_delta); +} + +void playlist_manager::activeplaylist_get_selection_mask(bit_array_var & out) +{ + t_size playlist = get_active_playlist(); + if (playlist != SIZE_MAX) playlist_get_selection_mask(playlist,out); +} + +void playlist_manager::activeplaylist_get_all_items(pfc::list_base_t & out) +{ + t_size playlist = get_active_playlist(); + if (playlist != SIZE_MAX) playlist_get_all_items(playlist,out); +} + +void playlist_manager::activeplaylist_get_selected_items(pfc::list_base_t & out) +{ + t_size playlist = get_active_playlist(); + if (playlist != SIZE_MAX) playlist_get_selected_items(playlist,out); +} + +bool playlist_manager::remove_playlist(t_size idx) +{ + return remove_playlists(pfc::bit_array_one(idx)); +} + +bool playlist_incoming_item_filter::process_location(const char * url,pfc::list_base_t & out,bool filter,const char * p_mask,const char * p_exclude,fb2k::hwnd_t p_parentwnd) +{ + return process_locations(pfc::list_single_ref_t(url),out,filter,p_mask,p_exclude,p_parentwnd); +} + +void playlist_manager::playlist_clear(t_size p_playlist) +{ + playlist_remove_items(p_playlist, pfc::bit_array_true()); +} + +void playlist_manager::activeplaylist_clear() +{ + t_size playlist = get_active_playlist(); + if (playlist != SIZE_MAX) playlist_clear(playlist); +} + +bool playlist_manager::playlist_update_content(t_size playlist, metadb_handle_list_cref content, bool bUndoBackup) { + metadb_handle_list old; + playlist_get_all_items(playlist, old); + if (old.get_size() == 0) { + if (content.get_size() == 0) return false; + if (bUndoBackup) playlist_undo_backup(playlist); + playlist_add_items(playlist, content, pfc::bit_array_false()); + return true; + } + pfc::avltree_t itemsOld, itemsNew; + + for(t_size walk = 0; walk < old.get_size(); ++walk) itemsOld += old[walk]; + for(t_size walk = 0; walk < content.get_size(); ++walk) itemsNew += content[walk]; + pfc::bit_array_bittable removeMask(old.get_size()); + pfc::bit_array_bittable filterMask(content.get_size()); + bool gotNew = false, filterNew = false, gotRemove = false; + for(t_size walk = 0; walk < content.get_size(); ++walk) { + const bool state = !itemsOld.have_item(content[walk]); + if (state) gotNew = true; + else filterNew = true; + filterMask.set(walk, state); + } + for(t_size walk = 0; walk < old.get_size(); ++walk) { + const bool state = !itemsNew.have_item(old[walk]); + if (state) gotRemove = true; + removeMask.set(walk, state); + } + if (!gotNew && !gotRemove) return false; + if (bUndoBackup) playlist_undo_backup(playlist); + if (gotRemove) { + playlist_remove_items(playlist, removeMask); + } + if (gotNew) { + if (filterNew) { + metadb_handle_list temp(content); + temp.filter_mask(filterMask); + playlist_add_items(playlist, temp, pfc::bit_array_false()); + } else { + playlist_add_items(playlist, content, pfc::bit_array_false()); + } + } + + { + playlist_get_all_items(playlist, old); + pfc::array_t order; + if (pfc::guess_reorder_pattern >(order, old, content)) { + playlist_reorder_items(playlist, order.get_ptr(), order.get_size()); + } + } + return true; +} +bool playlist_manager::playlist_add_items(t_size playlist,const pfc::list_base_const_t & data,const bit_array & p_selection) +{ + return playlist_insert_items(playlist, SIZE_MAX, data, p_selection) != SIZE_MAX; +} + +bool playlist_manager::activeplaylist_add_items(const pfc::list_base_const_t & data,const bit_array & p_selection) +{ + t_size playlist = get_active_playlist(); + if (playlist != SIZE_MAX) return playlist_add_items(playlist,data,p_selection); + else return false; +} + +bool playlist_manager::playlist_insert_items_filter(t_size p_playlist,t_size p_base,const pfc::list_base_const_t & p_data,bool p_select) +{ + metadb_handle_list temp; + if (!playlist_incoming_item_filter::get()->filter_items(p_data,temp)) + return false; + return playlist_insert_items(p_playlist,p_base,temp, pfc::bit_array_val(p_select)) != SIZE_MAX; +} + +bool playlist_manager::activeplaylist_insert_items_filter(t_size p_base,const pfc::list_base_const_t & p_data,bool p_select) +{ + t_size playlist = get_active_playlist(); + if (playlist != SIZE_MAX) return playlist_insert_items_filter(playlist,p_base,p_data,p_select); + else return false; +} + +bool playlist_manager::playlist_insert_locations(t_size p_playlist,t_size p_base,const pfc::list_base_const_t & p_urls,bool p_select,fb2k::hwnd_t p_parentwnd) +{ + metadb_handle_list temp; + if (!playlist_incoming_item_filter::get()->process_locations(p_urls,temp,true,0,0,p_parentwnd)) return false; + return playlist_insert_items(p_playlist,p_base,temp, pfc::bit_array_val(p_select)) != SIZE_MAX; +} + +bool playlist_manager::activeplaylist_insert_locations(t_size p_base,const pfc::list_base_const_t & p_urls,bool p_select,fb2k::hwnd_t p_parentwnd) +{ + t_size playlist = get_active_playlist(); + if (playlist != SIZE_MAX) return playlist_insert_locations(playlist,p_base,p_urls,p_select,p_parentwnd); + else return false; +} + +bool playlist_manager::playlist_add_items_filter(t_size p_playlist,const pfc::list_base_const_t & p_data,bool p_select) +{ + return playlist_insert_items_filter(p_playlist,SIZE_MAX,p_data,p_select); +} + +bool playlist_manager::activeplaylist_add_items_filter(const pfc::list_base_const_t & p_data,bool p_select) +{ + return activeplaylist_insert_items_filter(SIZE_MAX,p_data,p_select); +} + +bool playlist_manager::playlist_add_locations(t_size p_playlist,const pfc::list_base_const_t & p_urls,bool p_select,fb2k::hwnd_t p_parentwnd) +{ + return playlist_insert_locations(p_playlist,SIZE_MAX,p_urls,p_select,p_parentwnd); +} +bool playlist_manager::activeplaylist_add_locations(const pfc::list_base_const_t & p_urls,bool p_select,fb2k::hwnd_t p_parentwnd) +{ + return activeplaylist_insert_locations(SIZE_MAX,p_urls,p_select,p_parentwnd); +} + +void playlist_manager::reset_playing_playlist() +{ + set_playing_playlist(get_active_playlist()); +} + +void playlist_manager::playlist_clear_selection(t_size p_playlist) +{ + playlist_set_selection(p_playlist, pfc::bit_array_true(), pfc::bit_array_false()); +} + +void playlist_manager::activeplaylist_clear_selection() +{ + t_size playlist = get_active_playlist(); + if (playlist != SIZE_MAX) playlist_clear_selection(playlist); +} + +void playlist_manager::activeplaylist_undo_backup() +{ + t_size playlist = get_active_playlist(); + if (playlist != SIZE_MAX) playlist_undo_backup(playlist); +} + +bool playlist_manager::activeplaylist_undo_restore() +{ + t_size playlist = get_active_playlist(); + if (playlist != SIZE_MAX) return playlist_undo_restore(playlist); + else return false; +} + +bool playlist_manager::activeplaylist_redo_restore() +{ + t_size playlist = get_active_playlist(); + if (playlist != SIZE_MAX) return playlist_redo_restore(playlist); + else return false; +} + +void playlist_manager::playlist_remove_selection(t_size p_playlist,bool p_crop) +{ + pfc::bit_array_bittable table(playlist_get_item_count(p_playlist)); + playlist_get_selection_mask(p_playlist,table); + if (p_crop) playlist_remove_items(p_playlist, pfc::bit_array_not(table)); + else playlist_remove_items(p_playlist,table); +} + +void playlist_manager::activeplaylist_remove_selection(bool p_crop) +{ + t_size playlist = get_active_playlist(); + if (playlist != SIZE_MAX) playlist_remove_selection(playlist,p_crop); +} + +void playlist_manager::activeplaylist_item_format_title(t_size p_item,titleformat_hook * p_hook,pfc::string_base & out,const service_ptr_t & p_script,titleformat_text_filter * p_filter,play_control::t_display_level p_playback_info_level) +{ + t_size playlist = get_active_playlist(); + if (playlist == SIZE_MAX) out = "NJET"; + else playlist_item_format_title(playlist,p_item,p_hook,out,p_script,p_filter,p_playback_info_level); +} + +void playlist_manager::playlist_set_selection_single(t_size p_playlist,t_size p_item,bool p_state) +{ + playlist_set_selection(p_playlist, pfc::bit_array_one(p_item), pfc::bit_array_val(p_state)); +} + +void playlist_manager::activeplaylist_set_selection_single(t_size p_item,bool p_state) +{ + t_size playlist = get_active_playlist(); + if (playlist != SIZE_MAX) playlist_set_selection_single(playlist,p_item,p_state); +} + +t_size playlist_manager::playlist_get_selection_count(t_size p_playlist,t_size p_max) +{ + enum_items_callback_count_selection callback(p_max); + playlist_enum_items(p_playlist,callback, pfc::bit_array_true()); + return callback.get_count(); +} + +t_size playlist_manager::activeplaylist_get_selection_count(t_size p_max) +{ + t_size playlist = get_active_playlist(); + if (playlist != SIZE_MAX) return playlist_get_selection_count(playlist,p_max); + else return 0; +} + +bool playlist_manager::playlist_get_focus_item_handle(metadb_handle_ptr & p_out,t_size p_playlist) +{ + t_size index = playlist_get_focus_item(p_playlist); + if (index == SIZE_MAX) return false; + return playlist_get_item_handle(p_out,p_playlist,index); +} + +bool playlist_manager::activeplaylist_get_focus_item_handle(metadb_handle_ptr & p_out) +{ + t_size playlist = get_active_playlist(); + if (playlist != SIZE_MAX) return playlist_get_focus_item_handle(p_out,playlist); + else return false; +} + +t_size playlist_manager::find_playlist(const char * p_name,t_size p_name_length) +{ + t_size n, m = get_playlist_count(); + pfc::string_formatter temp; + for(n=0;n namebuffer; + namebuffer << new_playlist_text << " (" << walk << ")"; + if (find_playlist(namebuffer, SIZE_MAX) == SIZE_MAX) return create_playlist(namebuffer,SIZE_MAX,p_index); + } +} + +bool playlist_manager::activeplaylist_sort_by_format(const char * spec,bool p_sel_only) +{ + t_size playlist = get_active_playlist(); + if (playlist != pfc_infinite) return playlist_sort_by_format(playlist,spec,p_sel_only); + else return false; +} + +bool playlist_manager::highlight_playing_item() +{ + t_size playlist,item; + if (!get_playing_item_location(&playlist,&item)) return false; + set_active_playlist(playlist); + playlist_set_focus_item(playlist,item); + playlist_set_selection(playlist, pfc::bit_array_true(), pfc::bit_array_one(item)); + playlist_ensure_visible(playlist,item); + return true; +} + +void playlist_manager::playlist_get_items(t_size p_playlist,pfc::list_base_t & out,const bit_array & p_mask) +{ + enum_items_callback_retrieve_all_items cb(out); + playlist_enum_items(p_playlist,cb,p_mask); +} + +void playlist_manager::activeplaylist_get_items(pfc::list_base_t & out,const bit_array & p_mask) +{ + t_size playlist = get_active_playlist(); + if (playlist != pfc_infinite) playlist_get_items(playlist,out,p_mask); + else out.remove_all(); +} + +void playlist_manager::active_playlist_fix() +{ + t_size playlist = get_active_playlist(); + if (playlist == pfc_infinite) + { + t_size max = get_playlist_count(); + if (max == 0) + { + create_playlist_autoname(); + } + set_active_playlist(0); + } +} + +namespace { + class enum_items_callback_remove_list : public playlist_manager::enum_items_callback + { + const metadb_handle_list & m_data; + bit_array_var & m_table; + t_size m_found; + public: + enum_items_callback_remove_list(const metadb_handle_list & p_data,bit_array_var & p_table) : m_data(p_data), m_table(p_table), m_found(0) {} + bool on_item(t_size p_index,const metadb_handle_ptr & p_location,bool b_selected) override + { + (void)b_selected; + bool found = m_data.bsearch_by_pointer(p_location) != pfc_infinite; + m_table.set(p_index,found); + if (found) m_found++; + return true; + } + + inline t_size get_found() const {return m_found;} + }; +} + +void playlist_manager::remove_items_from_all_playlists(const pfc::list_base_const_t & p_data) +{ + t_size playlist_num, playlist_max = get_playlist_count(); + if (playlist_max != pfc_infinite) + { + metadb_handle_list temp; + temp.add_items(p_data); + temp.sort_by_pointer(); + for(playlist_num = 0; playlist_num < playlist_max; playlist_num++ ) + { + t_size playlist_item_count = playlist_get_item_count(playlist_num); + if (playlist_item_count == pfc_infinite) break; + pfc::bit_array_bittable table(playlist_item_count); + enum_items_callback_remove_list callback(temp,table); + playlist_enum_items(playlist_num,callback, pfc::bit_array_true()); + if (callback.get_found()>0) + playlist_remove_items(playlist_num,table); + } + } +} + +bool playlist_manager::get_all_items(pfc::list_base_t & out) +{ + t_size n, m = get_playlist_count(); + if (m == pfc_infinite) return false; + enum_items_callback_retrieve_all_items callback(out); + for(n=0;nget_active_playlist(); + if (a == SIZE_MAX) { + // FIX ME implement toast +#ifdef _WIN32 + MessageBeep(0); +#endif + return false; + } + return this->remove_playlist_user(a); +} + +bool playlist_manager::remove_playlist_user(size_t which) { + if (this->get_playlist_count() == 1) { + // FIX ME implement toast +#ifdef _WIN32 + MessageBeep(0); +#endif + return false; + } + + if (!this->remove_playlist_switch(which)) { + // FIX ME implement toast +#ifdef _WIN32 + MessageBeep(0); +#endif + return false; + } + return true; +} + +bool playlist_manager::remove_playlist_switch(t_size idx) +{ + bool need_switch = get_active_playlist() == idx; + if (remove_playlist(idx)) + { + if (need_switch) + { + t_size total = get_playlist_count(); + if (total > 0) + { + if (idx >= total) idx = total-1; + set_active_playlist(idx); + } + } + return true; + } + else return false; +} + + + +bool t_playback_queue_item::operator==(const t_playback_queue_item & p_item) const +{ + return m_handle == p_item.m_handle && m_playlist == p_item.m_playlist && m_item == p_item.m_item; +} + +bool t_playback_queue_item::operator!=(const t_playback_queue_item & p_item) const +{ + return m_handle != p_item.m_handle || m_playlist != p_item.m_playlist || m_item != p_item.m_item; +} + + + +bool playlist_manager::activeplaylist_execute_default_action(t_size p_item) { + t_size idx = get_active_playlist(); + if (idx == pfc_infinite) return false; + else return playlist_execute_default_action(idx,p_item); +} + +namespace { + class completion_notify_dfd : public completion_notify { + public: + completion_notify_dfd(const pfc::list_base_const_t & p_data,service_ptr_t p_notify) : m_data(p_data), m_notify(p_notify) {} + void on_completion(unsigned p_code) { + switch(p_code) { + case metadb_io::load_info_aborted: + m_notify->on_aborted(); + break; + default: + m_notify->on_completion(m_data); + break; + } + } + private: + metadb_handle_list m_data; + service_ptr_t m_notify; + }; +}; + +void dropped_files_data_impl::to_handles_async_ex(t_uint32 p_op_flags,fb2k::hwnd_t p_parentwnd,service_ptr_t p_notify) { + if (m_is_paths) { + playlist_incoming_item_filter_v2::get()->process_locations_async( + m_paths, + p_op_flags, + NULL, + NULL, + p_parentwnd, + p_notify); + } else { + t_uint32 flags = 0; + if (p_op_flags & playlist_incoming_item_filter_v2::op_flag_background) flags |= metadb_io_v2::op_flag_background; + if (p_op_flags & playlist_incoming_item_filter_v2::op_flag_delay_ui) flags |= metadb_io_v2::op_flag_delay_ui; + metadb_io_v2::get()->load_info_async(m_handles,metadb_io::load_info_default,p_parentwnd,flags,new service_impl_t(m_handles,p_notify)); + } +} +void dropped_files_data_impl::to_handles_async(bool p_filter,fb2k::hwnd_t p_parentwnd,service_ptr_t p_notify) { + to_handles_async_ex(p_filter ? 0 : playlist_incoming_item_filter_v2::op_flag_no_filter,p_parentwnd,p_notify); +} + +bool dropped_files_data_impl::to_handles(pfc::list_base_t & p_out,bool p_filter,fb2k::hwnd_t p_parentwnd) { + if (m_is_paths) { + return playlist_incoming_item_filter::get()->process_locations(m_paths,p_out,p_filter,NULL,NULL,p_parentwnd); + } else { + if (metadb_io::get()->load_info_multi(m_handles,metadb_io::load_info_default,p_parentwnd,true) == metadb_io::load_info_aborted) return false; + p_out = m_handles; + return true; + } +} + +void playlist_manager::playlist_activate_delta(int p_delta) { + const t_size total = get_playlist_count(); + if (total > 0) { + t_size active = get_active_playlist(); + + //clip p_delta to -(total-1)...(total-1) range + if (p_delta < 0) { + p_delta = - ( (-p_delta) % (t_ssize)total ); + } else { + p_delta = p_delta % total; + } + if (p_delta != 0) { + if (active == pfc_infinite) { + //special case when no playlist is active + if (p_delta > 0) { + active = (t_size)(p_delta - 1); + } else { + active = (total + p_delta);//p_delta is negative + } + } else { + active = (t_size) (active + total + p_delta) % total; + } + set_active_playlist(active % total); + } + } +} +namespace { + class enum_items_callback_get_selected_count : public playlist_manager::enum_items_callback { + public: + enum_items_callback_get_selected_count() : m_found() {} + t_size get_count() const {return m_found;} + bool on_item(t_size p_index,const metadb_handle_ptr & p_location,bool b_selected) override { + (void)p_index; (void)p_location; + if (b_selected) m_found++; + return true; + } + private: + t_size m_found; + }; +} +t_size playlist_manager::playlist_get_selected_count(t_size p_playlist,bit_array const & p_mask) { + enum_items_callback_get_selected_count callback; + playlist_enum_items(p_playlist,callback,p_mask); + return callback.get_count(); +} + +namespace { + class enum_items_callback_find_item : public playlist_manager::enum_items_callback { + public: + enum_items_callback_find_item(metadb_handle_ptr p_lookingFor) : m_lookingFor(p_lookingFor) {} + t_size result() const {return m_result;} + bool on_item(t_size p_index,const metadb_handle_ptr & p_location,bool b_selected) override { + (void)b_selected; + if (p_location == m_lookingFor) { + m_result = p_index; + return false; + } else { + return true; + } + } + private: + metadb_handle_ptr m_lookingFor; + size_t m_result = SIZE_MAX; + }; + class enum_items_callback_find_item_selected : public playlist_manager::enum_items_callback { + public: + enum_items_callback_find_item_selected(metadb_handle_ptr p_lookingFor) : m_lookingFor(p_lookingFor) {} + t_size result() const {return m_result;} + bool on_item(t_size p_index,const metadb_handle_ptr & p_location,bool b_selected) { + if (b_selected && p_location == m_lookingFor) { + m_result = p_index; + return false; + } else { + return true; + } + } + private: + metadb_handle_ptr m_lookingFor; + size_t m_result = SIZE_MAX; + }; +} + +bool playlist_manager::playlist_find_item(t_size p_playlist,metadb_handle_ptr p_item,t_size & p_result) { + enum_items_callback_find_item callback(p_item); + playlist_enum_items(p_playlist,callback,pfc::bit_array_true()); + t_size result = callback.result(); + if (result == SIZE_MAX) return false; + p_result = result; + return true; +} +bool playlist_manager::playlist_find_item_selected(t_size p_playlist,metadb_handle_ptr p_item,t_size & p_result) { + enum_items_callback_find_item_selected callback(p_item); + playlist_enum_items(p_playlist,callback,pfc::bit_array_true()); + t_size result = callback.result(); + if (result == SIZE_MAX) return false; + p_result = result; + return true; +} +t_size playlist_manager::playlist_set_focus_by_handle(t_size p_playlist,metadb_handle_ptr p_item) { + t_size index; + if (!playlist_find_item(p_playlist,p_item,index)) index = SIZE_MAX; + playlist_set_focus_item(p_playlist,index); + return index; +} +bool playlist_manager::activeplaylist_find_item(metadb_handle_ptr p_item,t_size & p_result) { + t_size playlist = get_active_playlist(); + if (playlist == SIZE_MAX) return false; + return playlist_find_item(playlist,p_item,p_result); +} +t_size playlist_manager::activeplaylist_set_focus_by_handle(metadb_handle_ptr p_item) { + t_size playlist = get_active_playlist(); + if (playlist == SIZE_MAX) return SIZE_MAX; + return playlist_set_focus_by_handle(playlist,p_item); +} + +#ifdef _WIN32 +pfc::com_ptr_t playlist_incoming_item_filter::create_dataobject_ex(metadb_handle_list_cref data) { + pfc::com_ptr_t temp; temp.attach( create_dataobject(data) ); PFC_ASSERT( temp.is_valid() ); return temp; +} +#endif + +void playlist_manager_v3::recycler_restore_by_id(t_uint32 id) { + t_size which = recycler_find_by_id(id); + if (which != ~0) recycler_restore(which); +} + +t_size playlist_manager_v3::recycler_find_by_id(t_uint32 id) { + const t_size total = recycler_get_count(); + for(t_size walk = 0; walk < total; ++walk) { + if (id == recycler_get_id(walk)) return walk; + } + return SIZE_MAX; +} + + + +typedef pfc::map_t< const char*, metadb_handle_list, metadb::path_comparator > byPath_t; +static void rechapter_worker(playlist_manager* api, byPath_t const& byPath) { + if (byPath.get_count() == 0) return; + const size_t numPlaylists = api->get_playlist_count(); + for (size_t walkPlaylist = 0; walkPlaylist < numPlaylists; ++walkPlaylist) { + if (!api->playlist_lock_is_present(walkPlaylist)) { + auto itemCount = [=] { + return api->playlist_get_item_count(walkPlaylist); + }; + auto itemHandle = [=](size_t item) -> metadb_handle_ptr { + return api->playlist_get_item_handle(walkPlaylist, item); + }; + + for (size_t walkItem = 0; walkItem < itemCount(); ) { + auto item = itemHandle(walkItem); + auto itemPath = item->get_path(); + auto match = byPath.find(itemPath); + if (match.is_valid() ) { + pfc::avltree_t subsongs; + auto base = walkItem; + bool bSel = false; + for (++walkItem; walkItem < itemCount(); ++walkItem) { + auto handle = itemHandle(walkItem); + if (metadb::path_compare(itemPath, handle->get_path()) != 0) break; + if (!subsongs.add_item_check(handle->get_subsong_index())) break; + + bSel = bSel || api->playlist_is_item_selected(walkPlaylist, walkItem); + } + + const auto& newItems = match->m_value; + // REMOVE base ... walkItem range and insert newHandles at base + api->playlist_remove_items(walkPlaylist, pfc::bit_array_range(base, walkItem - base)); + api->playlist_insert_items(walkPlaylist, base, newItems, pfc::bit_array_val(bSel)); + walkItem = base + newItems.get_size(); + } + else { + ++walkItem; + } + } + } + } +} + +void playlist_manager::on_files_rechaptered( metadb_handle_list_cref newHandles ) { + pfc::map_t< const char*, metadb_handle_list, metadb::path_comparator > byPath; + + const size_t total = newHandles.get_count(); + for( size_t w = 0; w < total; ++w ) { + auto handle = newHandles[w]; + byPath[ handle->get_path() ] += handle; + } + + rechapter_worker(this, byPath); +} + +void playlist_manager::on_file_rechaptered(const char* path, metadb_handle_list_cref newItems) { + // obsolete method + (void)path; + on_files_rechaptered(newItems); +} + +namespace { + class process_locations_notify_lambda : public process_locations_notify { + public: + process_locations_notify::func_t f; + void on_completion(metadb_handle_list_cref p_items) override { + PFC_ASSERT(f != nullptr); + f(p_items); + } + void on_aborted() override {} + }; +} +process_locations_notify::ptr process_locations_notify::create(func_t arg) { + PFC_ASSERT(arg != nullptr); + auto ret = fb2k::service_new< process_locations_notify_lambda >(); + ret->f = arg; + return ret; +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/playlist.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/playlist.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,945 @@ +#pragma once + +#include "titleformat.h" +#include "playback_control.h" +#include +#include "callback_merit.h" + +//! This interface allows filtering of playlist modification operations.\n +//! Implemented by components "locking" playlists; use playlist_manager::playlist_lock_install() etc to takeover specific playlist with your instance of playlist_lock. +class NOVTABLE playlist_lock : public service_base { +public: + enum { + filter_add = 1 << 0, + filter_remove = 1 << 1, + filter_reorder = 1 << 2, + filter_replace = 1 << 3, + filter_rename = 1 << 4, + filter_remove_playlist = 1 << 5, + filter_default_action = 1 << 6, + }; + + //! Queries whether specified item insertiion operation is allowed in the locked playlist. + //! @param p_base Index from which the items are being inserted. + //! @param p_data Items being inserted. + //! @param p_selection Caller-requested selection state of items being inserted. + //! @returns True to allow the operation, false to block it. + virtual bool query_items_add(t_size p_base, const pfc::list_base_const_t & p_data,const bit_array & p_selection) = 0; + //! Queries whether specified item reorder operation is allowed in the locked playlist. + //! @param p_order Pointer to array containing permutation defining requested reorder operation. + //! @param p_count Number of items in array pointed to by p_order. This should always be equal to number of items on the locked playlist. + //! @returns True to allow the operation, false to block it. + virtual bool query_items_reorder(const t_size * p_order,t_size p_count) = 0; + //! Queries whether specified item removal operation is allowed in the locked playlist. + //! @param p_mask Specifies which items from locked playlist are being removed. + //! @param p_force If set to true, the call is made only for notification purpose and items are getting removed regardless (after e.g. they have been physically removed). + //! @returns True to allow the operation, false to block it. Note that return value is ignored if p_force is set to true. + virtual bool query_items_remove(const bit_array & p_mask,bool p_force) = 0; + //! Queries whether specified item replacement operation is allowed in the locked playlist. + //! @param p_index Index of the item being replaced. + //! @param p_old Old value of the item being replaced. + //! @param p_new New value of the item being replaced. + //! @returns True to allow the operation, false to block it. + virtual bool query_item_replace(t_size p_index,const metadb_handle_ptr & p_old,const metadb_handle_ptr & p_new)=0; + //! Queries whether renaming the locked playlist is allowed. + //! @param p_new_name Requested new name of the playlist; a UTF-8 encoded string. + //! @param p_new_name_len Length limit of the name string, in bytes (actual string may be shorter if null terminator is encountered before). Set this to infinite to use plain null-terminated strings. + //! @returns True to allow the operation, false to block it. + virtual bool query_playlist_rename(const char * p_new_name,t_size p_new_name_len) = 0; + //! Queries whether removal of the locked playlist is allowed. Note that the lock will be released when the playlist is removed. + //! @returns True to allow the operation, false to block it. + virtual bool query_playlist_remove() = 0; + //! Executes "default action" (doubleclick etc) for specified playlist item. When the playlist is not locked, default action starts playback of the item. + //! @returns True if custom default action was executed, false to fall-through to default one for non-locked playlists (start playback). + virtual bool execute_default_action(t_size p_item) = 0; + //! Notifies lock about changed index of the playlist, in result of user reordering playlists or removing other playlists. + virtual void on_playlist_index_change(t_size p_new_index) = 0; + //! Notifies lock about the locked playlist getting removed. + virtual void on_playlist_remove() = 0; + //! Retrieves human-readable name of playlist lock to display. + virtual void get_lock_name(pfc::string_base & p_out) = 0; + //! Requests user interface of component controlling the playlist lock to be shown. + virtual void show_ui() = 0; + //! Queries which actions the lock filters. The return value must not change while the lock is registered with playlist_manager. The return value is a combination of one or more filter_* constants. + virtual t_uint32 get_filter_mask() = 0; + + FB2K_MAKE_SERVICE_INTERFACE(playlist_lock,service_base); +}; + +struct t_playback_queue_item { + metadb_handle_ptr m_handle; + t_size m_playlist,m_item; + + bool operator==(const t_playback_queue_item & p_item) const; + bool operator!=(const t_playback_queue_item & p_item) const; +}; + + +//! This service provides methods for all sorts of playlist interaction.\n +//! All playlist_manager methods are valid only from main app thread.\n +//! Usage: playlist_manager::get() to obtain an instance. +class NOVTABLE playlist_manager : public service_base +{ +public: + + typedef std::function enum_items_func; + + //! Callback interface for playlist enumeration methods. + class NOVTABLE enum_items_callback { + public: + //! @returns True to continue enumeration, false to abort. + virtual bool on_item(t_size p_index,const metadb_handle_ptr & p_location,bool b_selected) = 0;//return false to stop + }; + + //! Retrieves number of playlists. + virtual t_size get_playlist_count() = 0; + //! Retrieves index of active playlist; infinite if no playlist is active. + virtual t_size get_active_playlist() = 0; + //! Sets active playlist (infinite to set no active playlist). + virtual void set_active_playlist(t_size p_index) = 0; + //! Retrieves playlist from which items to be played are taken from. + virtual t_size get_playing_playlist() = 0; + //! Sets playlist from which items to be played are taken from. + virtual void set_playing_playlist(t_size p_index) = 0; + //! Removes playlists according to specified mask. See also: bit_array. + virtual bool remove_playlists(const bit_array & p_mask) = 0; + //! Creates a new playlist. + //! @param p_name Name of playlist to create; a UTF-8 encoded string. + //! @param p_name_length Length limit of playlist name string, in bytes (actual string may be shorter if null terminator is encountered before). Set this to infinite to use plain null-terminated strings. + //! @param p_index Index at which to insert new playlist; set to infinite to put it at the end of playlist list. + //! @returns Actual index of newly inserted playlist, infinite on failure (call from invalid context). + virtual t_size create_playlist(const char * p_name,t_size p_name_length,t_size p_index) = 0; + //! Reorders the playlist list according to specified permutation. + //! @returns True on success, false on failure (call from invalid context). + virtual bool reorder(const t_size * p_order,t_size p_count) = 0; + + + //! Retrieves number of items on specified playlist. + virtual t_size playlist_get_item_count(t_size p_playlist) = 0; + //! Enumerates contents of specified playlist. + virtual void playlist_enum_items(t_size p_playlist,enum_items_callback & p_callback,const bit_array & p_mask) = 0; + void playlist_enum_items(size_t which, enum_items_func, const bit_array&); + //! Retrieves index of focus item on specified playlist; returns infinite when no item has focus. + virtual t_size playlist_get_focus_item(t_size p_playlist) = 0; + //! Retrieves name of specified playlist. Should never fail unless the parameters are invalid. + virtual bool playlist_get_name(t_size p_playlist,pfc::string_base & p_out) = 0; + + //! Reorders items in specified playlist according to specified permutation. + virtual bool playlist_reorder_items(t_size p_playlist,const t_size * p_order,t_size p_count) = 0; + //! Selects/deselects items on specified playlist. + //! @param p_playlist Index of playlist to alter. + //! @param p_affected Mask of items to alter. + //! @param p_status Mask of selected/deselected state to apply to items specified by p_affected. + virtual void playlist_set_selection(t_size p_playlist,const bit_array & p_affected,const bit_array & p_status) = 0; + //! Removes specified items from specified playlist. Returns true on success or false on failure (playlist locked). + virtual bool playlist_remove_items(t_size p_playlist,const bit_array & mask)=0; + //! Replaces specified item on specified playlist. Returns true on success or false on failure (playlist locked). + virtual bool playlist_replace_item(t_size p_playlist,t_size p_item,const metadb_handle_ptr & p_new_item) = 0; + //! Sets index of focus item on specified playlist; use infinite to set no focus item. + virtual void playlist_set_focus_item(t_size p_playlist,t_size p_item) = 0; + //! Inserts new items into specified playlist, at specified position. + virtual t_size playlist_insert_items(t_size p_playlist,t_size p_base,const pfc::list_base_const_t & data,const bit_array & p_selection) = 0; + //! Tells playlist renderers to make sure that specified item is visible. + virtual void playlist_ensure_visible(t_size p_playlist,t_size p_item) = 0; + //! Renames specified playlist. + //! @param p_name New name of playlist; a UTF-8 encoded string. + //! @param p_name_length Length limit of playlist name string, in bytes (actual string may be shorter if null terminator is encountered before). Set this to infinite to use plain null-terminated strings. + //! @returns True on success, false on failure (playlist locked). + virtual bool playlist_rename(t_size p_index,const char * p_name,t_size p_name_length) = 0; + + + //! Creates an undo restore point for specified playlist. + virtual void playlist_undo_backup(t_size p_playlist) = 0; + //! Reverts specified playlist to last undo restore point and generates a redo restore point. + //! @returns True on success, false on failure (playlist locked or no restore point available). + virtual bool playlist_undo_restore(t_size p_playlist) = 0; + //! Reverts specified playlist to next redo restore point and generates an undo restore point. + //! @returns True on success, false on failure (playlist locked or no restore point available). + virtual bool playlist_redo_restore(t_size p_playlist) = 0; + //! Returns whether an undo restore point is available for specified playlist. + virtual bool playlist_is_undo_available(t_size p_playlist) = 0; + //! Returns whether a redo restore point is available for specified playlist. + virtual bool playlist_is_redo_available(t_size p_playlist) = 0; + + //! Renders information about specified playlist item, using specified titleformatting script parameters. + //! @param p_playlist Index of playlist containing item being processed. + //! @param p_item Index of item being processed in the playlist containing it. + //! @param p_hook Titleformatting script hook to use; see titleformat_hook documentation for more info. Set to NULL when hook functionality is not needed. + //! @param p_out String object receiving results. + //! @param p_script Compiled titleformatting script to use; see titleformat_object cocumentation for more info. + //! @param p_filter Text filter to use; see titleformat_text_filter documentation for more info. Set to NULL when text filter functionality is not needed. + //! @param p_playback_info_level Level of playback related information requested. See playback_control::t_display_level documentation for more info. + virtual void playlist_item_format_title(t_size p_playlist,t_size p_item,titleformat_hook * p_hook,pfc::string_base & p_out,const service_ptr_t & p_script,titleformat_text_filter * p_filter,playback_control::t_display_level p_playback_info_level)=0; + + + //! Retrieves playlist position of currently playing item. + //! @param p_playlist Receives index of playlist containing currently playing item on success. + //! @param p_index Receives index of currently playing item in the playlist that contains it on success. + //! @returns True on success, false on failure (not playing or currently played item has been removed from the playlist it was on when starting). + virtual bool get_playing_item_location(t_size * p_playlist,t_size * p_index) = 0; + + //! Sorts specified playlist - entire playlist or selection only - by specified title formatting pattern, or randomizes the order. + //! @param p_playlist Index of playlist to alter. + //! @param p_pattern Title formatting pattern to sort by (an UTF-8 encoded null-termindated string). Set to NULL to randomize the order of items. + //! @param p_sel_only Set to false to sort/randomize whole playlist, or to true to sort/randomize only selection on the playlist. + //! @returns True on success, false on failure (playlist locked etc). + virtual bool playlist_sort_by_format(t_size p_playlist,const char * p_pattern,bool p_sel_only) = 0; + + //! For internal use only; p_items must be sorted by metadb::path_compare; use file_operation_callback static methods instead of calling this directly. + virtual void on_files_deleted_sorted(const pfc::list_base_const_t & p_items) = 0; + //! For internal use only; p_from must be sorted by metadb::path_compare; use file_operation_callback static methods instead of calling this directly. + virtual void on_files_moved_sorted(const pfc::list_base_const_t & p_from,const pfc::list_base_const_t & p_to) = 0; + + virtual bool playlist_lock_install(t_size p_playlist,const service_ptr_t & p_lock) = 0;//returns false when invalid playlist or already locked + virtual bool playlist_lock_uninstall(t_size p_playlist,const service_ptr_t & p_lock) = 0; + virtual bool playlist_lock_is_present(t_size p_playlist) = 0; + virtual bool playlist_lock_query_name(t_size p_playlist,pfc::string_base & p_out) = 0; + virtual bool playlist_lock_show_ui(t_size p_playlist) = 0; + virtual t_uint32 playlist_lock_get_filter_mask(t_size p_playlist) = 0; + + + //! Retrieves number of available playback order modes. + virtual t_size playback_order_get_count() = 0; + //! Retrieves name of specified playback order move. + //! @param p_index Index of playback order mode to query, from 0 to playback_order_get_count() return value - 1. + //! @returns Null-terminated UTF-8 encoded string containing name of the playback order mode. Returned pointer points to statically allocated string and can be safely stored without having to free it later. + virtual const char * playback_order_get_name(t_size p_index) = 0; + //! Retrieves GUID of specified playback order mode. Used for managing playback modes without relying on names. + //! @param p_index Index of playback order mode to query, from 0 to playback_order_get_count() return value - 1. + virtual GUID playback_order_get_guid(t_size p_index) = 0; + //! Retrieves index of active playback order mode. + virtual t_size playback_order_get_active() = 0; + //! Sets index of active playback order mode. + virtual void playback_order_set_active(t_size p_index) = 0; + + virtual void queue_remove_mask(bit_array const & p_mask) = 0; + virtual void queue_add_item_playlist(t_size p_playlist,t_size p_item) = 0; + virtual void queue_add_item(metadb_handle_ptr p_item) = 0; + virtual t_size queue_get_count() = 0; + virtual void queue_get_contents(pfc::list_base_t & p_out) = 0; + //! Returns index (0-based) on success, infinite on failure (item not in queue). + virtual t_size queue_find_index(t_playback_queue_item const & p_item) = 0; + + //! Registers a playlist callback; registered object receives notifications about any modifications of any of loaded playlists. + //! @param p_callback Callback interface to register. + //! @param p_flags Flags indicating which callback methods are requested. See playlist_callback::flag_* constants for more info. The main purpose of flags parameter is working set optimization by not calling methods that do nothing. + virtual void register_callback(class playlist_callback * p_callback,unsigned p_flags) = 0; + //! Registers a playlist callback; registered object receives notifications about any modifications of active playlist. + //! @param p_callback Callback interface to register. + //! @param p_flags Flags indicating which callback methods are requested. See playlist_callback_single::flag_* constants for more info. The main purpose of flags parameter is working set optimization by not calling methods that do nothing. + virtual void register_callback(class playlist_callback_single * p_callback,unsigned p_flags) = 0; + //! Unregisters a playlist callback (playlist_callback version). + virtual void unregister_callback(class playlist_callback * p_callback) = 0; + //! Unregisters a playlist callback (playlist_callback_single version). + virtual void unregister_callback(class playlist_callback_single * p_callback) = 0; + //! Modifies flags indicating which calback methods are requested (playlist_callback version). + virtual void modify_callback(class playlist_callback * p_callback,unsigned p_flags) = 0; + //! Modifies flags indicating which calback methods are requested (playlist_callback_single version). + virtual void modify_callback(class playlist_callback_single * p_callback,unsigned p_flags) = 0; + + //! Executes default doubleclick/enter action for specified item on specified playlist (starts playing the item unless overridden by a lock to do something else). + virtual bool playlist_execute_default_action(t_size p_playlist,t_size p_item) = 0; + + + //! Helper; removes all items from the playback queue. + void queue_flush() {queue_remove_mask(pfc::bit_array_true());} + //! Helper; returns whether there are items in the playback queue. + bool queue_is_active() {return queue_get_count() > 0;} + + //! Helper; highlights currently playing item; returns true on success or false on failure (not playing or currently played item has been removed from playlist since playback started). + bool highlight_playing_item(); + //! Helper; removes single playlist of specified index. + bool remove_playlist(t_size p_playlist); + //! Helper; removes single playlist of specified index, and switches to another playlist when possible. + bool remove_playlist_switch(t_size p_playlist); + //! Helper; removes a playlist switching to another; gracefully refuses to remove the only playlist. \n + //! It is recommended to call this as a result of user input requesting playlist removal. \n + //! Do not call MessageBeep() etc when it returns false, the function handles these for you. + bool remove_playlist_user(size_t which); + bool remove_playlist_user(); + + //! Helper; returns whether specified item on specified playlist is selected or not. + bool playlist_is_item_selected(t_size p_playlist,t_size p_item); + //! Helper; retrieves metadb_handle of the specified playlist item. Returns true on success, false on failure (invalid parameters). + bool playlist_get_item_handle(metadb_handle_ptr & p_out,t_size p_playlist,t_size p_item); + //! Helper; retrieves metadb_handle of the specified playlist item; throws pfc::exception_invalid_params() on failure. + metadb_handle_ptr playlist_get_item_handle(t_size playlist, t_size item); + + //! Moves selected items up/down in the playlist by specified offset. + //! @param p_playlist Index of playlist to alter. + //! @param p_delta Offset to move items by. Set it to a negative valuye to move up, or to a positive value to move down. + //! @returns True on success, false on failure (e.g. playlist locked). + bool playlist_move_selection(t_size p_playlist,int p_delta); + //! Retrieves selection map of specific playlist, using bit_array_var interface. + void playlist_get_selection_mask(t_size p_playlist,bit_array_var & out); + void playlist_get_items(t_size p_playlist,pfc::list_base_t & out,const bit_array & p_mask); + void playlist_get_all_items(t_size p_playlist,pfc::list_base_t & out); + void playlist_get_selected_items(t_size p_playlist,pfc::list_base_t & out); + + //! Clears contents of specified playlist (removes all items from it). + void playlist_clear(t_size p_playlist); + bool playlist_add_items(t_size playlist,const pfc::list_base_const_t & data,const bit_array & p_selection); + void playlist_clear_selection(t_size p_playlist); + void playlist_remove_selection(t_size p_playlist,bool p_crop = false); + + + //! Changes contents of the specified playlist to the specified items, trying to reuse existing playlist content as much as possible (preserving selection/focus/etc). Order of items in playlist not guaranteed to be the same as in the specified item list. + //! @returns true if the playlist has been altered, false if there was nothing to update. + bool playlist_update_content(t_size playlist, metadb_handle_list_cref content, bool bUndoBackup); + + //retrieving status + t_size activeplaylist_get_item_count(); + void activeplaylist_enum_items(enum_items_callback & p_callback,const bit_array & p_mask); + void activeplaylist_enum_items(enum_items_func, const bit_array&); + t_size activeplaylist_get_focus_item();//focus may be infinite if no item is focused + bool activeplaylist_get_name(pfc::string_base & p_out); + + //modifying playlist + bool activeplaylist_reorder_items(const t_size * order,t_size count); + void activeplaylist_set_selection(const bit_array & affected,const bit_array & status); + bool activeplaylist_remove_items(const bit_array & mask); + bool activeplaylist_replace_item(t_size p_item,const metadb_handle_ptr & p_new_item); + void activeplaylist_set_focus_item(t_size p_item); + t_size activeplaylist_insert_items(t_size p_base,const pfc::list_base_const_t & data,const bit_array & p_selection); + void activeplaylist_ensure_visible(t_size p_item); + bool activeplaylist_rename(const char * p_name,t_size p_name_len); + + void activeplaylist_undo_backup(); + bool activeplaylist_undo_restore(); + bool activeplaylist_redo_restore(); + + bool activeplaylist_is_item_selected(t_size p_item); + bool activeplaylist_get_item_handle(metadb_handle_ptr & item,t_size p_item); + metadb_handle_ptr activeplaylist_get_item_handle(t_size p_item); + void activeplaylist_move_selection(int p_delta); + void activeplaylist_get_selection_mask(bit_array_var & out); + void activeplaylist_get_items(pfc::list_base_t & out,const bit_array & p_mask); + void activeplaylist_get_all_items(pfc::list_base_t & out); + void activeplaylist_get_selected_items(pfc::list_base_t & out); + void activeplaylist_clear(); + + bool activeplaylist_add_items(const pfc::list_base_const_t & data,const bit_array & p_selection); + + bool playlist_insert_items_filter(t_size p_playlist,t_size p_base,const pfc::list_base_const_t & p_data,bool p_select); + bool activeplaylist_insert_items_filter(t_size p_base,const pfc::list_base_const_t & p_data,bool p_select); + + //! \deprecated (since 0.9.3) Use playlist_incoming_item_filter_v2::process_locations_async whenever possible + bool playlist_insert_locations(t_size p_playlist,t_size p_base,const pfc::list_base_const_t & p_urls,bool p_select,fb2k::hwnd_t p_parentwnd); + //! \deprecated (since 0.9.3) Use playlist_incoming_item_filter_v2::process_locations_async whenever possible + bool activeplaylist_insert_locations(t_size p_base,const pfc::list_base_const_t & p_urls,bool p_select,fb2k::hwnd_t p_parentwnd); + + bool playlist_add_items_filter(t_size p_playlist,const pfc::list_base_const_t & p_data,bool p_select); + bool activeplaylist_add_items_filter(const pfc::list_base_const_t & p_data,bool p_select); + + bool playlist_add_locations(t_size p_playlist,const pfc::list_base_const_t & p_urls,bool p_select,fb2k::hwnd_t p_parentwnd); + bool activeplaylist_add_locations(const pfc::list_base_const_t & p_urls,bool p_select,fb2k::hwnd_t p_parentwnd); + + void reset_playing_playlist(); + + void activeplaylist_clear_selection(); + void activeplaylist_remove_selection(bool p_crop = false); + + void activeplaylist_item_format_title(t_size p_item,titleformat_hook * p_hook,pfc::string_base & out,const service_ptr_t & p_script,titleformat_text_filter * p_filter,play_control::t_display_level p_playback_info_level); + + void playlist_set_selection_single(t_size p_playlist,t_size p_item,bool p_state); + void activeplaylist_set_selection_single(t_size p_item,bool p_state); + + t_size playlist_get_selection_count(t_size p_playlist,t_size p_max); + t_size activeplaylist_get_selection_count(t_size p_max); + + bool playlist_get_focus_item_handle(metadb_handle_ptr & p_item,t_size p_playlist); + bool activeplaylist_get_focus_item_handle(metadb_handle_ptr & item); + + t_size find_playlist(const char * p_name,t_size p_name_length = ~0); + t_size find_or_create_playlist(const char * p_name,t_size p_name_length = ~0); + t_size find_or_create_playlist_unlocked(const char * p_name,t_size p_name_length = ~0); + + t_size create_playlist_autoname(t_size p_index = ~0); + + bool activeplaylist_sort_by_format(const char * spec,bool p_sel_only); + + t_uint32 activeplaylist_lock_get_filter_mask(); + bool activeplaylist_is_undo_available(); + bool activeplaylist_is_redo_available(); + + bool activeplaylist_execute_default_action(t_size p_item); + + void remove_items_from_all_playlists(const pfc::list_base_const_t & p_data); + + void active_playlist_fix(); + + bool get_all_items(pfc::list_base_t & out); + + void playlist_activate_delta(int p_delta); + void playlist_activate_next() {playlist_activate_delta(1);} + void playlist_activate_previous() {playlist_activate_delta(-1);} + + + t_size playlist_get_selected_count(t_size p_playlist,bit_array const & p_mask); + t_size activeplaylist_get_selected_count(bit_array const & p_mask) {return playlist_get_selected_count(get_active_playlist(),p_mask);} + + bool playlist_find_item(t_size p_playlist,metadb_handle_ptr p_item,t_size & p_result);//inefficient, walks entire playlist + bool playlist_find_item_selected(t_size p_playlist,metadb_handle_ptr p_item,t_size & p_result);//inefficient, walks entire playlist + t_size playlist_set_focus_by_handle(t_size p_playlist,metadb_handle_ptr p_item); + bool activeplaylist_find_item(metadb_handle_ptr p_item,t_size & p_result);//inefficient, walks entire playlist + t_size activeplaylist_set_focus_by_handle(metadb_handle_ptr p_item); + + static void g_make_selection_move_permutation(t_size * p_output,t_size p_count,const bit_array & p_selection,int p_delta); + + //! Helper to update playlists after rechaptering a file. \n + //! You typically want to call metadb_io_v2::on_file_rechaptered() instead, as it will forcibly reload info first. + void on_file_rechaptered(const char * path, metadb_handle_list_cref items); + void on_files_rechaptered( metadb_handle_list_cref newHandles ); + + FB2K_MAKE_SERVICE_COREAPI(playlist_manager); +}; + +//! Extension of the playlist_manager service that manages playlist properties. +//! Playlist properties come in two flavors: persistent and runtime. +//! Persistent properties are blocks of binary that that will be preserved when the application is exited and restarted. +//! Runtime properties are service pointers that will be lost when the application exits. +//! \since 0.9.5 +class NOVTABLE playlist_manager_v2 : public playlist_manager { +public: + //! Write a persistent playlist property. + //! \param p_playlist Index of the playlist + //! \param p_property GUID that identifies the property + //! \param p_stream stream that contains the data that will be associated with the property + //! \param p_abort abort_callback that will be used when reading from p_stream + virtual void playlist_set_property(t_size p_playlist,const GUID & p_property,stream_reader * p_stream,t_size p_size_hint,abort_callback & p_abort) = 0; + //! Read a persistent playlist property. + //! \param p_playlist Index of the playlist + //! \param p_property GUID that identifies the property + //! \param p_stream stream that will receive the stored data + //! \param p_abort abort_callback that will be used when writing to p_stream + //! \return true if the property exists, false otherwise + virtual bool playlist_get_property(t_size p_playlist,const GUID & p_property,stream_writer * p_stream,abort_callback & p_abort) = 0; + //! Test existence of a persistent playlist property. + //! \param p_playlist Index of the playlist + //! \param p_property GUID that identifies the property + //! \return true if the property exists, false otherwise + virtual bool playlist_have_property(t_size p_playlist,const GUID & p_property) = 0; + //! Remove a persistent playlist property. + //! \param p_playlist Index of the playlist + //! \param p_property GUID that identifies the property + //! \return true if the property existed, false otherwise + virtual bool playlist_remove_property(t_size p_playlist,const GUID & p_property) = 0; + + //! Write a runtime playlist property. + //! \param p_playlist Index of the playlist + //! \param p_property GUID that identifies the property + //! \param p_data service pointer that will be associated with the property + virtual void playlist_set_runtime_property(t_size p_playlist,const GUID & p_property,service_ptr_t p_data) = 0; + //! Read a runtime playlist property. + //! \param p_playlist Index of the playlist + //! \param p_property GUID that identifies the property + //! \param p_data base service pointer reference that will receive the stored servive pointer + //! \return true if the property exists, false otherwise + virtual bool playlist_get_runtime_property(t_size p_playlist,const GUID & p_property,service_ptr_t & p_data) = 0; + //! Test existence of a runtime playlist property. + //! \param p_playlist Index of the playlist + //! \param p_property GUID that identifies the property + //! \return true if the property exists, false otherwise + virtual bool playlist_have_runtime_property(t_size p_playlist,const GUID & p_property) = 0; + //! Remove a runtime playlist property. + //! \param p_playlist Index of the playlist + //! \param p_property GUID that identifies the property + //! \return true if the property existed, false otherwise + virtual bool playlist_remove_runtime_property(t_size p_playlist,const GUID & p_property) = 0; + + //! Write a persistent playlist property. + //! \param p_playlist Index of the playlist + //! \param p_property GUID that identifies the property + //! \param p_data array that contains the data that will be associated with the property + template void playlist_set_property(t_size p_playlist,const GUID & p_property,const t_array & p_data) { + PFC_STATIC_ASSERT( sizeof(p_data[0]) == 1 ); + stream_reader_memblock_ref reader(p_data); + playlist_set_property(p_playlist,p_property,&reader,p_data.get_size(),fb2k::noAbort); + } + //! Read a persistent playlist property. + //! \param p_playlist Index of the playlist + //! \param p_property GUID that identifies the property + //! \param p_data array that will receive the stored data + //! \return true if the property exists, false otherwise + template bool playlist_get_property(t_size p_playlist,const GUID & p_property,t_array & p_data) { + PFC_STATIC_ASSERT( sizeof(p_data[0]) == 1 ); + typedef pfc::array_t t_temp; + t_temp temp; + { + stream_writer_buffer_append_ref_t reader(temp); + if (!playlist_get_property(p_playlist,p_property,&reader,fb2k::noAbort)) return false; + } + p_data = temp; + return true; + } + pfc::array_t playlist_get_property(t_size playlist, const GUID& prop) { + pfc::array_t ret; + this->playlist_get_property(playlist, prop, ret); + return ret; + } + //! Read a runtime playlist property. + //! \param p_playlist Index of the playlist + //! \param p_property GUID that identifies the property + //! \param p_data specific service pointer reference that will receive the stored servive pointer + //! \return true if the property exists and can be converted to the type of p_data, false otherwise + template bool playlist_get_runtime_property(t_size p_playlist,const GUID & p_property,service_ptr_t<_t_interface> & p_data) { + service_ptr_t ptr; + if (!playlist_get_runtime_property(p_playlist,p_property,ptr)) return false; + return ptr->service_query_t(p_data); + } + + //! Write a persistent playlist property. + //! \param p_playlist Index of the playlist + //! \param p_property GUID that identifies the property + //! \param p_value integer that will be associated with the property + template + void playlist_set_property_int(t_size p_playlist,const GUID & p_property,_t_int p_value) { + pfc::array_t temp; temp.set_size(sizeof(_t_int)); + pfc::encode_little_endian(temp.get_ptr(),p_value); + playlist_set_property(p_playlist,p_property,temp); + } + //! Read a persistent playlist property. + //! \param p_playlist Index of the playlist + //! \param p_property GUID that identifies the property + //! \param p_value integer reference that will receive the stored data + //! \return true if the property exists and if the data is compatible with p_value, false otherwise + template + bool playlist_get_property_int(t_size p_playlist,const GUID & p_property,_t_int & p_value) { + pfc::array_t temp; + if (!playlist_get_property(p_playlist,p_property,temp)) return false; + if (temp.get_size() != sizeof(_t_int)) return false; + pfc::decode_little_endian(p_value,temp.get_ptr()); + return true; + } + + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(playlist_manager_v2,playlist_manager) +}; + +//! \since 0.9.5 +class NOVTABLE playlist_manager_v3 : public playlist_manager_v2 { + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(playlist_manager_v3,playlist_manager_v2) +public: + virtual t_size recycler_get_count() = 0; + virtual void recycler_get_content(t_size which, metadb_handle_list_ref out) = 0; + virtual void recycler_get_name(t_size which, pfc::string_base & out) = 0; + virtual t_uint32 recycler_get_id(t_size which) = 0; + virtual void recycler_purge(const bit_array & mask) = 0; + virtual void recycler_restore(t_size which) = 0; + + void recycler_restore_by_id(t_uint32 id); + t_size recycler_find_by_id(t_uint32 id); +}; + +//! \since 0.9.5.4 +class NOVTABLE playlist_manager_v4 : public playlist_manager_v3 { + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(playlist_manager_v4, playlist_manager_v3) +public: + virtual void playlist_get_sideinfo(t_size which, stream_writer * stream, abort_callback & abort) = 0; + virtual t_size create_playlist_ex(const char * p_name,t_size p_name_length,t_size p_index, metadb_handle_list_cref content, stream_reader * sideInfo, abort_callback & abort) = 0; +}; + +//! \since 2.0 +class NOVTABLE playlist_manager_v5 : public playlist_manager_v4 { + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(playlist_manager_v5, playlist_manager_v4) +public: + virtual GUID playlist_get_guid(size_t idx) = 0; + virtual size_t find_playlist_by_guid(const GUID&) = 0; +}; + +//! \since 2.0 beta 8 +class NOVTABLE playlist_manager_v6 : public playlist_manager_v5 { + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(playlist_manager_v6, playlist_manager_v5); +public: + virtual void set_callback_merit(class playlist_callback*, fb2k::callback_merit_t) = 0; + virtual void set_callback_merit(class playlist_callback_single*, fb2k::callback_merit_t) = 0; + +}; + +// IMPLEMENTATION NOTE: all playlist_callback methods could not be declared noexcept for historical reasons, but it's strongly recommended that your overrides of these methods are noexcept. + +class NOVTABLE playlist_callback +{ +public: + virtual void on_items_added(t_size p_playlist,t_size p_start, const pfc::list_base_const_t & p_data,const bit_array & p_selection)=0;//inside any of these methods, you can call playlist APIs to get exact info about what happened (but only methods that read playlist state, not those that modify it) + virtual void on_items_reordered(t_size p_playlist,const t_size * p_order,t_size p_count)=0;//changes selection too; doesnt actually change set of items that are selected or item having focus, just changes their order + virtual void on_items_removing(t_size p_playlist,const bit_array & p_mask,t_size p_old_count,t_size p_new_count)=0;//called before actually removing them + virtual void on_items_removed(t_size p_playlist,const bit_array & p_mask,t_size p_old_count,t_size p_new_count)=0; + virtual void on_items_selection_change(t_size p_playlist,const bit_array & p_affected,const bit_array & p_state) = 0; + virtual void on_item_focus_change(t_size p_playlist,t_size p_from,t_size p_to)=0;//focus may be -1 when no item has focus; reminder: focus may also change on other callbacks + + virtual void on_items_modified(t_size p_playlist,const bit_array & p_mask)=0; + virtual void on_items_modified_fromplayback(t_size p_playlist,const bit_array & p_mask,play_control::t_display_level p_level)=0; + + struct t_on_items_replaced_entry + { + t_size m_index; + metadb_handle_ptr m_old,m_new; + }; + + virtual void on_items_replaced(t_size p_playlist,const bit_array & p_mask,const pfc::list_base_const_t & p_data)=0; + + virtual void on_item_ensure_visible(t_size p_playlist,t_size p_idx)=0; + + virtual void on_playlist_activate(t_size p_old,t_size p_new) = 0; + virtual void on_playlist_created(t_size p_index,const char * p_name,t_size p_name_len) = 0; + virtual void on_playlists_reorder(const t_size * p_order,t_size p_count) = 0; + virtual void on_playlists_removing(const bit_array & p_mask,t_size p_old_count,t_size p_new_count) = 0; + virtual void on_playlists_removed(const bit_array & p_mask,t_size p_old_count,t_size p_new_count) = 0; + virtual void on_playlist_renamed(t_size p_index,const char * p_new_name,t_size p_new_name_len) = 0; + + virtual void on_default_format_changed() = 0; + virtual void on_playback_order_changed(t_size p_new_index) = 0; + virtual void on_playlist_locked(t_size p_playlist,bool p_locked) = 0; + + enum { + flag_on_items_added = 1 << 0, + flag_on_items_reordered = 1 << 1, + flag_on_items_removing = 1 << 2, + flag_on_items_removed = 1 << 3, + flag_on_items_selection_change = 1 << 4, + flag_on_item_focus_change = 1 << 5, + flag_on_items_modified = 1 << 6, + flag_on_items_modified_fromplayback = 1 << 7, + flag_on_items_replaced = 1 << 8, + flag_on_item_ensure_visible = 1 << 9, + flag_on_playlist_activate = 1 << 10, + flag_on_playlist_created = 1 << 11, + flag_on_playlists_reorder = 1 << 12, + flag_on_playlists_removing = 1 << 13, + flag_on_playlists_removed = 1 << 14, + flag_on_playlist_renamed = 1 << 15, + flag_on_default_format_changed = 1 << 16, + flag_on_playback_order_changed = 1 << 17, + flag_on_playlist_locked = 1 << 18, + + flag_all = ~0, + flag_item_ops = flag_on_items_added | flag_on_items_reordered | flag_on_items_removing | flag_on_items_removed | flag_on_items_selection_change | flag_on_item_focus_change | flag_on_items_modified | flag_on_items_modified_fromplayback | flag_on_items_replaced | flag_on_item_ensure_visible, + flag_playlist_ops = flag_on_playlist_activate | flag_on_playlist_created | flag_on_playlists_reorder | flag_on_playlists_removing | flag_on_playlists_removed | flag_on_playlist_renamed | flag_on_playlist_locked, + }; +protected: + playlist_callback() {} + ~playlist_callback() {} +}; + +class NOVTABLE playlist_callback_static : public service_base, public playlist_callback +{ +public: + virtual unsigned get_flags() = 0; + + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(playlist_callback_static); +}; + +class NOVTABLE playlist_callback_single +{ +public: + virtual void on_items_added(t_size p_base, metadb_handle_list_cref p_data,const bit_array & p_selection)=0;//inside any of these methods, you can call playlist APIs to get exact info about what happened (but only methods that read playlist state, not those that modify it) + virtual void on_items_reordered(const t_size * p_order,t_size p_count)=0;//changes selection too; doesnt actually change set of items that are selected or item having focus, just changes their order + virtual void on_items_removing(const bit_array & p_mask,t_size p_old_count,t_size p_new_count)=0;//called before actually removing them + virtual void on_items_removed(const bit_array & p_mask,t_size p_old_count,t_size p_new_count)=0; + virtual void on_items_selection_change(const bit_array & p_affected,const bit_array & p_state) = 0; + virtual void on_item_focus_change(t_size p_from,t_size p_to)=0;//focus may be -1 when no item has focus; reminder: focus may also change on other callbacks + virtual void on_items_modified(const bit_array & p_mask)=0; + virtual void on_items_modified_fromplayback(const bit_array & p_mask,play_control::t_display_level p_level)=0; + virtual void on_items_replaced(const bit_array & p_mask,const pfc::list_base_const_t & p_data)=0; + virtual void on_item_ensure_visible(t_size p_idx)=0; + + virtual void on_playlist_switch() = 0; + virtual void on_playlist_renamed(const char * p_new_name,t_size p_new_name_len) = 0; + virtual void on_playlist_locked(bool p_locked) = 0; + + virtual void on_default_format_changed() = 0; + virtual void on_playback_order_changed(t_size p_new_index) = 0; + + enum { + flag_on_items_added = 1 << 0, + flag_on_items_reordered = 1 << 1, + flag_on_items_removing = 1 << 2, + flag_on_items_removed = 1 << 3, + flag_on_items_selection_change = 1 << 4, + flag_on_item_focus_change = 1 << 5, + flag_on_items_modified = 1 << 6, + flag_on_items_modified_fromplayback = 1 << 7, + flag_on_items_replaced = 1 << 8, + flag_on_item_ensure_visible = 1 << 9, + flag_on_playlist_switch = 1 << 10, + flag_on_playlist_renamed = 1 << 11, + flag_on_playlist_locked = 1 << 12, + flag_on_default_format_changed = 1 << 13, + flag_on_playback_order_changed = 1 << 14, + flag_all = ~0, + }; +protected: + playlist_callback_single() {} + ~playlist_callback_single() {} +}; + +//! playlist_callback implementation helper - registers itself on creation / unregisters on destruction. Must not be instantiated statically! +class playlist_callback_impl_base : public playlist_callback { +public: + playlist_callback_impl_base(t_uint32 p_flags = 0) { + playlist_manager::get()->register_callback(this,p_flags); + } + ~playlist_callback_impl_base() { + playlist_manager::get()->unregister_callback(this); + } + void set_callback_flags(t_uint32 p_flags) { + playlist_manager::get()->modify_callback(this,p_flags); + } + //dummy implementations - avoid possible pure virtual function calls! + void on_items_added(t_size p_playlist, t_size p_start, metadb_handle_list_cref p_data, const bit_array& p_selection) override { (void)p_playlist; (void)p_start; (void)p_data; (void)p_selection; } + void on_items_reordered(t_size p_playlist, const t_size* p_order, t_size p_count) override { (void)p_playlist; (void)p_order; (void)p_count; } + void on_items_removing(t_size p_playlist, const bit_array& p_mask, t_size p_old_count, t_size p_new_count) override { (void)p_playlist; (void)p_mask; (void)p_old_count; (void)p_new_count; } + void on_items_removed(t_size p_playlist,const bit_array & p_mask,t_size p_old_count,t_size p_new_count) override { (void)p_playlist; (void)p_mask; (void)p_old_count; (void)p_new_count; } + void on_items_selection_change(t_size p_playlist, const bit_array& p_affected, const bit_array& p_state) override { (void)p_playlist; (void)p_affected; (void)p_state; } + void on_item_focus_change(t_size p_playlist, t_size p_from, t_size p_to) override { (void)p_playlist; (void)p_from; (void)p_to; } + + void on_items_modified(t_size p_playlist, const bit_array& p_mask) override { (void)p_playlist; (void)p_mask; } + void on_items_modified_fromplayback(t_size p_playlist, const bit_array& p_mask, play_control::t_display_level p_level) override { (void)p_playlist; (void)p_mask; (void)p_level; } + + void on_items_replaced(t_size p_playlist, const bit_array& p_mask, const pfc::list_base_const_t& p_data) override { (void)p_playlist; (void)p_mask; (void)p_data; } + + void on_item_ensure_visible(t_size p_playlist, t_size p_idx) override { (void)p_playlist; (void)p_idx; } + + void on_playlist_activate(t_size p_old, t_size p_new) override { (void)p_old; (void)p_new; } + void on_playlist_created(t_size p_index, const char* p_name, t_size p_name_len) override { (void)p_index; (void)p_name; (void)p_name_len; } + void on_playlists_reorder(const t_size* p_order, t_size p_count) override { (void)p_order; (void)p_count; } + void on_playlists_removing(const bit_array& p_mask, t_size p_old_count, t_size p_new_count) override { (void)p_mask; (void)p_old_count; (void)p_new_count; } + void on_playlists_removed(const bit_array& p_mask, t_size p_old_count, t_size p_new_count) override { (void)p_mask; (void)p_old_count; (void)p_new_count; } + void on_playlist_renamed(t_size p_index, const char* p_new_name, t_size p_new_name_len) override { (void)p_index; (void)p_new_name; (void)p_new_name_len; } + + void on_default_format_changed() override {} + void on_playback_order_changed(t_size p_new_index) override { (void)p_new_index; } + void on_playlist_locked(t_size p_playlist, bool p_locked) override { (void)p_playlist; (void)p_locked; } +}; + +//! playlist_callback_single implementation helper - registers itself on creation / unregisters on destruction. Must not be instantiated statically! +class playlist_callback_single_impl_base : public playlist_callback_single { +protected: + playlist_callback_single_impl_base(t_uint32 p_flags = 0) { + playlist_manager::get()->register_callback(this,p_flags); + } + void set_callback_flags(t_uint32 p_flags) { + playlist_manager::get()->modify_callback(this,p_flags); + } + ~playlist_callback_single_impl_base() { + playlist_manager::get()->unregister_callback(this); + } + + //dummy implementations - avoid possible pure virtual function calls! + void on_items_added(t_size p_base, metadb_handle_list_cref p_data, const bit_array& p_selection) override { (void)p_base; (void)p_data; (void)p_selection; } + void on_items_reordered(const t_size* p_order, t_size p_count) override { (void)p_order; (void)p_count; } + void on_items_removing(const bit_array& p_mask, t_size p_old_count, t_size p_new_count) override { (void)p_mask; (void)p_old_count; (void)p_new_count; } + void on_items_removed(const bit_array& p_mask, t_size p_old_count, t_size p_new_count) override { (void)p_mask; (void)p_old_count; (void)p_new_count; } + void on_items_selection_change(const bit_array& p_affected, const bit_array& p_state) override { (void)p_affected; (void)p_state; } + void on_item_focus_change(t_size p_from, t_size p_to) override { (void)p_from; (void)p_to; } + void on_items_modified(const bit_array& p_mask) override { (void)p_mask; } + void on_items_modified_fromplayback(const bit_array& p_mask, play_control::t_display_level p_level) override { (void)p_mask; (void)p_level; } + void on_items_replaced(const bit_array& p_mask, const pfc::list_base_const_t& p_data) override { (void)p_mask; (void)p_data; } + void on_item_ensure_visible(t_size p_idx) override { (void)p_idx; } + + void on_playlist_switch() override {} + void on_playlist_renamed(const char* p_new_name, t_size p_new_name_len) override { (void)p_new_name; (void)p_new_name_len; } + void on_playlist_locked(bool p_locked) override { (void)p_locked; } + + void on_default_format_changed() override {} + void on_playback_order_changed(t_size p_new_index) override { (void)p_new_index; } + + PFC_CLASS_NOT_COPYABLE(playlist_callback_single_impl_base,playlist_callback_single_impl_base); +}; + +class playlist_callback_single_static : public service_base, public playlist_callback_single +{ +public: + virtual unsigned get_flags() = 0; + + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(playlist_callback_single_static); +}; + + +//! Class used for async processing of IDataObject. Content of IDataObject can be dumped into dropped_files_data without any time-consuming operations - won't block calling app when used inside drag&drop handler - and actual time-consuming processing (listing directories and reading infos) can be done later.\n +//! \deprecated In 0.9.3 and up, instead of going thru dropped_files_data, you can use playlist_incoming_item_filter_v2::process_dropped_files_async(). +class NOVTABLE dropped_files_data { +public: + virtual void set_paths(pfc::string_list_const const & p_paths) = 0; + virtual void set_handles(const pfc::list_base_const_t & p_handles) = 0; +protected: + dropped_files_data() {} + ~dropped_files_data() {} +}; + + +class NOVTABLE playlist_incoming_item_filter : public service_base { + FB2K_MAKE_SERVICE_COREAPI(playlist_incoming_item_filter); +public: + //! Pre-sorts incoming items according to user-configured settings, removes duplicates. \n + //! As of 1.4, this is the same as sort_by_pointer_remove_duplicates() + sort_by_format( get_incoming_item_sorter() ), see playlist_incoming_item_filter_v4 \n + //! This method is valid in main thread only. However, using playlist_incoming_item_filter_v4::get_incoming_item_sorter() lets you do the same off main thread. + //! @param in Items to process. + //! @param out Receives processed item list. \n + //! @returns True when there's one or more item in the output list, false when the output list is empty. + virtual bool filter_items(metadb_handle_list_cref in,metadb_handle_list_ref out) = 0; + + //! Converts one or more paths to a list of metadb_handles; displays a progress dialog.\n + //! Note that this function creates modal dialog and does not return until the operation has completed. + //! @returns True on success, false on user abort. + //! \deprecated Use playlist_incoming_item_filter_v2::process_locations_async() when possible. + virtual bool process_locations(const pfc::list_base_const_t & p_urls,pfc::list_base_t & p_out,bool p_filter,const char * p_restrict_mask_override, const char * p_exclude_mask_override,fb2k::hwnd_t p_parentwnd) = 0; + +#ifdef _WIN32 + //! Converts an IDataObject to a list of metadb_handles. + //! Using this function is strongly disrecommended as it implies blocking the drag&drop source app (as well as our app).\n + //! @returns True on success, false on user abort or unknown data format. + //! \deprecated Use playlist_incoming_item_filter_v2::process_dropped_files_async() when possible. + virtual bool process_dropped_files(interface IDataObject * pDataObject,pfc::list_base_t & p_out,bool p_filter,HWND p_parentwnd) = 0; + + //! Checks whether IDataObject contains one of known data formats that can be translated to a list of metadb_handles. + virtual bool process_dropped_files_check(interface IDataObject * pDataObject) = 0; + + //! Checks whether IDataObject contains our own private data format (drag&drop within the app etc). + virtual bool process_dropped_files_check_if_native(interface IDataObject * pDataObject) = 0; + + //! Creates an IDataObject from specified metadb_handle list. The caller is responsible for releasing the returned object. It is recommended that you use create_dataobject_ex() to get an autopointer that ensures proper deletion. + virtual interface IDataObject * create_dataobject(const pfc::list_base_const_t & p_data) = 0; + + //! Checks whether IDataObject contains one of known data formats that can be translated to a list of metadb_handles.\n + //! This function also returns drop effects to use (see: IDropTarget::DragEnter(), IDropTarget::DragOver() ). In certain cases, drag effects are necessary for drag&drop to work at all (such as dragging links from IE).\n + virtual bool process_dropped_files_check_ex(interface IDataObject * pDataObject, DWORD * p_effect) = 0; + + //! Dumps IDataObject content to specified dropped_files_data object, without any time-consuming processing.\n + //! Using this function instead of process_dropped_files() and processing dropped_files_data outside drop handler allows you to avoid blocking drop source app when processing large directories etc.\n + //! Note: since 0.9.3, it is recommended to use playlist_incoming_item_filter_v2::process_dropped_files_async() instead. + //! @returns True on success, false when IDataObject does not contain any of known data formats. + virtual bool process_dropped_files_delayed(dropped_files_data & p_out,interface IDataObject * pDataObject) = 0; +#endif // _WIN32 + //! Helper - calls process_locations() with a single URL. See process_locations() for more info. + bool process_location(const char * url,pfc::list_base_t & out,bool filter,const char * p_mask,const char * p_exclude,fb2k::hwnd_t p_parentwnd); + +#ifdef _WIN32 + //! Helper - returns a pfc::com_ptr_t<> rather than a raw pointer. + pfc::com_ptr_t create_dataobject_ex(metadb_handle_list_cref data); +#endif // _WIN32 +}; + +//! For use with playlist_incoming_item_filter_v2::process_locations_async(). +//! \since 0.9.3 +class NOVTABLE process_locations_notify : public service_base { + FB2K_MAKE_SERVICE_INTERFACE(process_locations_notify, service_base); +public: + virtual void on_completion(metadb_handle_list_cref p_items) = 0; + virtual void on_aborted() = 0; + + typedef std::function func_t; + static process_locations_notify::ptr create(func_t); +}; + +typedef service_ptr_t process_locations_notify_ptr; + +//! \since 0.9.3 +class NOVTABLE playlist_incoming_item_filter_v2 : public playlist_incoming_item_filter { + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(playlist_incoming_item_filter_v2, playlist_incoming_item_filter) +public: + enum { + //! Set this to disable presorting (according to user settings) and duplicate removal in output list. Should be unset in most cases. + op_flag_no_filter = 1 << 0, + //! Set this flag to make the progress dialog not steal focus on creation. + op_flag_background = 1 << 1, + //! Set this flag to delay the progress dialog becoming visible, so it does not appear at all during short operations. Also implies op_flag_background effect. + op_flag_delay_ui = 1 << 2, + }; + + //! Converts one or more paths to a list of metadb_handles. The function returns immediately; specified callback object receives results when the operation has completed. + //! @param p_urls List of paths to process. + //! @param p_op_flags Can be null, or one or more of op_flag_* enum values combined, altering behaviors of the operation. + //! @param p_restrict_mask_override Override of "restrict incoming items to" setting. Pass NULL to use the value from preferences. + //! @param p_exclude_mask_override Override of "exclude file types" setting. Pass NULL to use value from preferences. + //! @param p_parentwnd Parent window for spawned progress dialogs. + //! @param p_notify Callback receiving notifications about success/abort of the operation as well as output item list. + virtual void process_locations_async(const pfc::list_base_const_t & p_urls,t_uint32 p_op_flags,const char * p_restrict_mask_override, const char * p_exclude_mask_override,fb2k::hwnd_t p_parentwnd,process_locations_notify_ptr p_notify) = 0; + +#ifdef _WIN32 + //! Converts an IDataObject to a list of metadb_handles. The function returns immediately; specified callback object receives results when the operation has completed. + //! @param p_dataobject IDataObject to process. + //! @param p_op_flags Can be null, or one or more of op_flag_* enum values combined, altering behaviors of the operation. + //! @param p_parentwnd Parent window for spawned progress dialogs. + //! @param p_notify Callback receiving notifications about success/abort of the operation as well as output item list. + virtual void process_dropped_files_async(interface IDataObject * p_dataobject,t_uint32 p_op_flags,HWND p_parentwnd,process_locations_notify_ptr p_notify) = 0; +#endif // _WIN32 +}; + +//! \since 0.9.5 +class playlist_incoming_item_filter_v3 : public playlist_incoming_item_filter_v2 { + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(playlist_incoming_item_filter_v3, playlist_incoming_item_filter_v2) +public: + virtual bool auto_playlist_name(metadb_handle_list_cref data,pfc::string_base & out) = 0; +}; + +//! \since 1.4 +class playlist_incoming_item_filter_v4 : public playlist_incoming_item_filter_v3 { + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(playlist_incoming_item_filter_v4, playlist_incoming_item_filter_v3); +public: + //! Retrieves title formatting pattern for sorting incoming files. \n + //! Valid from main thread only - however you can use the value for off-main-thread operations. + virtual void get_incoming_item_sort_pattern( pfc::string_base & out ) = 0; + //! Retrieves shared title formatting object for sorting incoming files. \n + //! This is the same as compiling the string returned from get_incoming_item_sort_pattern, except the returned object is shared with others using this API. \n + //! Valid from main thread only - however you can use the returned object for off-main-thread operations. + virtual titleformat_object::ptr get_incoming_item_sorter() = 0; +}; + +//! Implementation of dropped_files_data. +class dropped_files_data_impl : public dropped_files_data { +public: + dropped_files_data_impl() : m_is_paths(false) {} + void set_paths(pfc::string_list_const const & p_paths) { + m_is_paths = true; + m_paths = p_paths; + } + void set_paths(pfc::string_list_impl && paths) { + m_paths = std::move(paths); + m_is_paths = true; + } + void set_handles(const pfc::list_base_const_t & p_handles) { + m_is_paths = false; + m_handles = p_handles; + } + + void to_handles_async(bool p_filter,fb2k::hwnd_t p_parentwnd,service_ptr_t p_notify); + //! @param p_op_flags Can be null, or one or more of playlist_incoming_item_filter_v2::op_flag_* enum values combined, altering behaviors of the operation. + void to_handles_async_ex(t_uint32 p_op_flags,fb2k::hwnd_t p_parentwnd,service_ptr_t p_notify); + bool to_handles(pfc::list_base_t & p_out,bool p_filter,fb2k::hwnd_t p_parentwnd); +private: + pfc::string_list_impl m_paths; + metadb_handle_list m_handles; + bool m_is_paths; +}; + + +class NOVTABLE playback_queue_callback : public service_base +{ +public: + enum t_change_origin { + changed_user_added, + changed_user_removed, + changed_playback_advance, + }; + virtual void on_changed(t_change_origin p_origin) = 0; + + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(playback_queue_callback); +}; + + +class playlist_lock_change_notify : private playlist_callback_single_impl_base { +public: + playlist_lock_change_notify() : playlist_callback_single_impl_base(flag_on_playlist_switch|flag_on_playlist_locked) {} +protected: + virtual void on_lock_state_change() {} + bool is_playlist_command_available(t_uint32 what) const { + auto api = playlist_manager::get(); + const t_size active = api->get_active_playlist(); + if (active == SIZE_MAX) return false; + return (api->playlist_lock_get_filter_mask(active) & what) == 0; + } +private: + void on_playlist_switch() override {on_lock_state_change();} + void on_playlist_locked(bool) override {on_lock_state_change();} +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/playlistColumnProvider.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/playlistColumnProvider.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,30 @@ +#pragma once + +namespace fb2k { + //! Declares a column to be made available in Default UI playlist view, \n + //! without user having to manually enter title formatting patterns. + class playlistColumnProvider : public service_base { + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(playlistColumnProvider); + public: + //! Number of columns published by this object. + virtual size_t numColumns() = 0; + //! Unique identifier of a column. + virtual GUID columnID(size_t col) = 0; + //! Formatting pattern used for displaying a column. + virtual fb2k::stringRef columnFormatSpec(size_t col) = 0; + //! Optional; sorting pattern used for this column. Return null to use display pattern for sorting. + virtual fb2k::stringRef columnSortScript(size_t col) = 0; + //! Name of the column shown to the user. + virtual fb2k::stringRef columnName(size_t col) = 0; + //! Display flags (alignment). \n + //! See flag_* constants. + virtual unsigned columnFlags(size_t col) = 0; + + static constexpr unsigned + flag_alignLeft = 0, flag_alignRight = 1 << 0, flag_alignCenter = 1 << 1, // alignment + flag_numeric = 1 << 2, // prefer fixed width font, not all renderers support this + flag_positionDependant = 1 << 3, // value changes with position in playlist, mainly used by list index etc + flag_glyphs = 1 << 4; // internal/reserved + static constexpr unsigned flag_alignMask = (flag_alignLeft|flag_alignRight|flag_alignCenter); + }; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/playlist_loader.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/playlist_loader.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,466 @@ +#include "foobar2000-sdk-pch.h" +#include "playlist_loader.h" +#include "link_resolver.h" +#include "archive.h" +#include "file_info_impl.h" +#include "input.h" +#include "advconfig.h" +#include +#include +#include + +constexpr unsigned allowRecurseBase = 2; // max. 2 archive levels - mitigate droste.zip stack overflow +static void process_path_internal(const char * p_path,const service_ptr_t & p_reader,playlist_loader_callback::ptr callback, abort_callback & abort,playlist_loader_callback::t_entry_type type,const t_filestats & p_stats, unsigned allowRecurse ); + +bool playlist_loader::g_try_load_playlist(file::ptr fileHint,const char * p_path,playlist_loader_callback::ptr p_callback, abort_callback & p_abort) { + // Determine if this file is a playlist or not (which usually means that it's a media file) + pfc::string8 filepath; + + filesystem::g_get_canonical_path(p_path,filepath); + + pfc::string8 extension = filesystem::g_get_extension(filepath); + + service_ptr_t l_file = fileHint; + + if (l_file.is_empty()) { + filesystem::ptr fs; + if (filesystem::g_get_interface(fs,filepath)) { + if (fs->supports_content_types()) { + try { + fs->open(l_file,filepath,filesystem::open_mode_read,p_abort); + } catch(exception_io const &) { return false; } // fall thru + } + } + } + + service_enum_t e; + + if (l_file.is_valid()) { + + // Important: in case of remote HTTP files, use actual connected path for matching file extensions, following any redirects. + // At least one internet radio station has been known to present .pls links that are 302 redirects to real streams, so they don't parse as playlists. + { + file_metadata_http::ptr meta; + if (meta &= l_file->get_metadata_(p_abort)) { + pfc::string8 realPath; + meta->get_connected_path(realPath); + extension = filesystem::g_get_extension(realPath); + } + } + + pfc::string8 content_type; + if (l_file->get_content_type(content_type)) { + for (auto l : e) { + if (l->is_our_content_type(content_type)) { + try { + TRACK_CODE("playlist_loader::open",l->open(filepath,l_file,p_callback, p_abort)); + return true; + } catch(exception_io_unsupported_format const &) { + l_file->reopen(p_abort); + } + } + } + } + } + + if (extension.length()>0) { + for (auto l : e) { + if (stricmp_utf8(l->get_extension(),extension) == 0) { + if (l_file.is_empty()) filesystem::g_open_read(l_file,filepath,p_abort); + try { + TRACK_CODE("playlist_loader::open",l->open(filepath,l_file,p_callback,p_abort)); + return true; + } catch(exception_io_unsupported_format const &) { + l_file->reopen(p_abort); + } + } + } + } + + return false; +} + +void playlist_loader::g_load_playlist_filehint(file::ptr fileHint,const char * p_path,playlist_loader_callback::ptr p_callback, abort_callback & p_abort) { + if (!g_try_load_playlist(fileHint, p_path, p_callback, p_abort)) throw exception_io_unsupported_format(); +} + +void playlist_loader::g_load_playlist(const char * p_path,playlist_loader_callback::ptr callback, abort_callback & abort) { + g_load_playlist_filehint(NULL,p_path,callback,abort); +} +namespace { + class MIC_impl : public metadb_info_container_v2 { + public: + t_filestats2 const& stats2() override { return m_stats; } + file_info const& info() override { return m_info; } + t_filestats const& stats() override { return m_stats.as_legacy(); } + bool isInfoPartial() override { return false; } + + file_info_impl m_info; + t_filestats2 m_stats; + }; +} +static void index_tracks_helper(const char * p_path,const service_ptr_t & p_reader,const t_filestats & p_stats,playlist_loader_callback::t_entry_type p_type,playlist_loader_callback::ptr p_callback, abort_callback & p_abort,bool & p_got_input) +{ + TRACK_CALL_TEXT("index_tracks_helper"); + if (p_reader.is_empty() && filesystem::g_is_remote_safe(p_path)) + { + TRACK_CALL_TEXT("remote"); + metadb_handle_ptr handle; + p_callback->handle_create(handle,make_playable_location(p_path,0)); + p_got_input = true; + p_callback->on_entry(handle,p_type,p_stats,true); + } else { + TRACK_CALL_TEXT("hintable"); + service_ptr_t instance; + try { + input_entry::g_open_for_info_read(instance,p_reader,p_path,p_abort); + } catch(exception_io_unsupported_format const &) { + // specifically bail + throw; + } catch(exception_io const &) { + // broken file or some other error, open() failed - show it anyway + metadb_handle_ptr handle; + p_callback->handle_create(handle, make_playable_location(p_path, 0)); + p_callback->on_entry(handle, p_type, p_stats, true); + return; + } + + const auto stats = instance->get_stats2_(p_path, stats2_all, p_abort); + + t_uint32 subsong,subsong_count = instance->get_subsong_count(); + bool bInfoGetError = false; + for(subsong=0;subsongget_subsong(subsong); + p_callback->handle_create(handle,make_playable_location(p_path,index)); + + p_got_input = true; + if (! bInfoGetError && p_callback->want_info(handle,p_type,stats.as_legacy(),true) ) + { + auto mic = fb2k::service_new(); + mic->m_stats = stats; + try { + TRACK_CODE("get_info",instance->get_info(index,mic->m_info,p_abort)); + } catch(...) { + bInfoGetError = true; + } + if (! bInfoGetError ) { + playlist_loader_callback_v2::ptr v2; + if (v2 &= p_callback) { + v2->on_entry_info_v2(handle, p_type, mic, true); + } else { + p_callback->on_entry_info(handle, p_type, stats.as_legacy(), mic->m_info, true); + } + + } + } + else + { + p_callback->on_entry(handle,p_type,stats.as_legacy(),true); + } + } + } +} + +static void track_indexer__g_get_tracks_wrap(const char * p_path,const service_ptr_t & p_reader,const t_filestats & p_stats,playlist_loader_callback::t_entry_type p_type,playlist_loader_callback::ptr p_callback, abort_callback & p_abort) { + bool got_input = false; + bool fail = false; + try { + index_tracks_helper(p_path,p_reader,p_stats,p_type,p_callback,p_abort, got_input); + } catch(exception_aborted const &) { + throw; + } catch(exception_io_unsupported_format const &) { + fail = true; + } catch(std::exception const & e) { + fail = true; + FB2K_console_formatter() << "could not enumerate tracks (" << e << ") on:\n" << file_path_display(p_path); + } + if (fail) { + if (!got_input && !p_abort.is_aborting()) { + if (p_type == playlist_loader_callback::entry_user_requested) + { + metadb_handle_ptr handle; + p_callback->handle_create(handle,make_playable_location(p_path,0)); + p_callback->on_entry(handle,p_type,p_stats,true); + } + } + } +} + +namespace { + + static bool queryAddHidden() { + // {2F9F4956-363F-4045-9531-603B1BF39BA8} + static const GUID guid_cfg_addhidden = + { 0x2f9f4956, 0x363f, 0x4045,{ 0x95, 0x31, 0x60, 0x3b, 0x1b, 0xf3, 0x9b, 0xa8 } }; + + advconfig_entry_checkbox::ptr ptr; + if (advconfig_entry::g_find_t(ptr, guid_cfg_addhidden)) { + return ptr->get_state(); + } + return false; + } + + class directory_callback_myimpl : public directory_callback + { + public: + void main(const char* folder, abort_callback& abort) { + visit(folder); + + abort.check(); + const uint32_t flags = listMode::filesAndFolders | (queryAddHidden() ? listMode::hidden : 0); + + auto workHere = [&] (folder_t const & f) { + filesystem_v2::ptr v2; + if (v2 &= f.m_fs) { + v2->list_directory_ex(f.m_folder.c_str(), *this, flags, abort); + } else { + f.m_fs->list_directory(f.m_folder.c_str(), *this, abort); + } + }; + + workHere( folder_t { folder, filesystem::get(folder) } ); + + for (;; ) { + abort.check(); + auto iter = m_foldersPending.begin(); + if ( iter == m_foldersPending.end() ) break; + auto f = std::move(*iter); m_foldersPending.erase(iter); + + try { + workHere( f ); + } catch (exception_io const & e) { + FB2K_console_formatter() << "Error walking directory (" << e << "): " << f.m_folder.c_str(); + } + } + } + + bool on_entry(filesystem * owner,abort_callback & p_abort,const char * url,bool is_subdirectory,const t_filestats & p_stats) { + p_abort.check(); + if (!visit(url)) return true; + + filesystem_v2::ptr v2; + v2 &= owner; + + if ( is_subdirectory ) { + m_foldersPending.emplace_back( folder_t { url, owner } ); + } else { + m_entries.emplace_back( entry_t { url, p_stats } ); + } + return true; + } + + struct entry_t { + std::string m_path; + t_filestats m_stats; + }; + std::list m_entries; + + bool visit(const char* path) { + return m_visited.insert( path ).second; + } + std::unordered_set m_visited; + + struct folder_t { + std::string m_folder; + filesystem::ptr m_fs; + }; + std::list m_foldersPending; + }; +} + + +static void process_path_internal(const char * p_path,const service_ptr_t & p_reader,playlist_loader_callback::ptr callback, abort_callback & abort,playlist_loader_callback::t_entry_type type,const t_filestats & p_stats, unsigned allowRecurse) +{ + if (allowRecurse == 0) return; + //p_path must be canonical + + abort.check(); + + callback->on_progress(p_path); + + + { + if (p_reader.is_empty() && type != playlist_loader_callback::entry_directory_enumerated) { + try { + directory_callback_myimpl results; + results.main( p_path, abort ); + for( auto & i : results.m_entries ) { + try { + process_path_internal(i.m_path.c_str(), 0, callback, abort, playlist_loader_callback::entry_directory_enumerated, i.m_stats, allowRecurse); + } catch (exception_aborted const &) { + throw; + } catch (std::exception const& e) { + FB2K_console_formatter() << "Error walking path (" << e << "): " << file_path_display(i.m_path.c_str()); + } catch (...) { + FB2K_console_formatter() << "Error walking path (bad exception): " << file_path_display(i.m_path.c_str()); + } + } + return; // successfully enumerated directory - go no further + } catch(exception_aborted const &) { + throw; + } catch (exception_io_not_directory const &) { + // disregard + } catch(exception_io_not_found const &) { + // disregard + } catch (std::exception const& e) { + FB2K_console_formatter() << "Error walking directory (" << e << "): " << p_path; + } catch (...) { + FB2K_console_formatter() << "Error walking directory (bad exception): " << p_path; + } + } + + if (allowRecurse > 1) { + for (auto f : filesystem::enumerate()) { + abort.check(); + service_ptr_t arch; + if ((arch &= f) && arch->is_our_archive(p_path)) { + if (p_reader.is_valid()) p_reader->reopen(abort); + + try { + archive::list_func_t archive_results = [callback, &abort, allowRecurse](const char* p_path, const t_filestats& p_stats, file::ptr p_reader) { + process_path_internal(p_path,p_reader,callback,abort,playlist_loader_callback::entry_directory_enumerated,p_stats,allowRecurse - 1); + }; + TRACK_CODE("archive::archive_list",arch->archive_list(p_path,p_reader,archive_results,/*want readers*/true, abort)); + return; + } catch(exception_aborted const &) {throw;} + catch(...) { + // Something failed hard + // Is is_our_archive() meaningful? + archive_v2::ptr arch2; + if (arch2 &= arch) { + // If yes, show errors + throw; + } + // Outdated archive implementation, preserve legacy behavior (try to open as non-archive) + } + } + } + } + } + + + + { + service_ptr_t ptr; + if (link_resolver::g_find(ptr,p_path)) + { + if (p_reader.is_valid()) p_reader->reopen(abort); + + pfc::string8 temp; + try { + TRACK_CODE("link_resolver::resolve",ptr->resolve(p_reader,p_path,temp,abort)); + + track_indexer__g_get_tracks_wrap(temp,0,filestats_invalid,playlist_loader_callback::entry_from_playlist,callback, abort); + return;//success + } catch(exception_aborted const &) {throw;} + catch(...) {} + } + } + + if (callback->is_path_wanted(p_path,type)) { + track_indexer__g_get_tracks_wrap(p_path,p_reader,p_stats,type,callback, abort); + } +} + +namespace { + class plcallback_simple : public playlist_loader_callback { + public: + void on_progress(const char* p_path) override { (void)p_path; } + + void on_entry(const metadb_handle_ptr& p_item, t_entry_type p_type, const t_filestats& p_stats, bool p_fresh) override { + (void)p_type; (void)p_stats; (void)p_fresh; + m_items += p_item; + } + bool want_info(const metadb_handle_ptr& p_item, t_entry_type p_type, const t_filestats& p_stats, bool p_fresh) override { + (void)p_type; (void)p_stats; (void)p_fresh; + return p_item->should_reload(p_stats, p_fresh); + } + + void on_entry_info(const metadb_handle_ptr& p_item, t_entry_type p_type, const t_filestats& p_stats, const file_info& p_info, bool p_fresh) override { + (void)p_type; + m_items += p_item; + m_hints->add_hint(p_item, p_info, p_stats, p_fresh); + } + + void handle_create(metadb_handle_ptr& p_out, const playable_location& p_location) override { + m_metadb->handle_create(p_out, p_location); + } + + bool is_path_wanted(const char* path, t_entry_type type) override { + (void)path; (void)type; + return true; + } + + bool want_browse_info(const metadb_handle_ptr& p_item, t_entry_type p_type, t_filetimestamp ts) override { + (void)p_item; (void)p_type; (void)ts; + return true; + } + void on_browse_info(const metadb_handle_ptr& p_item, t_entry_type p_type, const file_info& info, t_filetimestamp ts) override { + (void)p_type; + metadb_hint_list_v2::ptr v2; + if (v2 &= m_hints) v2->add_hint_browse(p_item, info, ts); + } + + ~plcallback_simple() { + m_hints->on_done(); + } + metadb_handle_list m_items; + private: + const metadb_hint_list::ptr m_hints = metadb_hint_list::create(); + const metadb::ptr m_metadb = metadb::get(); + }; +} +void playlist_loader::g_path_to_handles_simple(const char* p_path, pfc::list_base_t& p_out, abort_callback& p_abort) { + auto cb = fb2k::service_new(); + g_process_path(p_path, cb, p_abort); + p_out = cb->m_items; +} +void playlist_loader::g_process_path(const char * p_filename,playlist_loader_callback::ptr callback, abort_callback & abort,playlist_loader_callback::t_entry_type type) +{ + TRACK_CALL_TEXT("playlist_loader::g_process_path"); + + auto filename = file_path_canonical(p_filename); + + process_path_internal(filename,0,callback,abort, type,filestats_invalid, allowRecurseBase); +} + +void playlist_loader::g_save_playlist(const char * p_filename,const pfc::list_base_const_t & data,abort_callback & p_abort) +{ + TRACK_CALL_TEXT("playlist_loader::g_save_playlist"); + pfc::string8 filename; + filesystem::g_get_canonical_path(p_filename,filename); + try { + service_ptr_t r; + filesystem::g_open(r,filename,filesystem::open_mode_write_new,p_abort); + + auto ext = pfc::string_extension(filename); + + service_enum_t e; + service_ptr_t l; + if (e.first(l)) do { + if (l->can_write() && !stricmp_utf8(ext,l->get_extension())) { + try { + TRACK_CODE("playlist_loader::write",l->write(filename,r,data,p_abort)); + return; + } catch(exception_io_data const &) {} + } + } while(e.next(l)); + throw exception_io_data(); + } catch(...) { + try {filesystem::g_remove(filename,p_abort);} catch(...) {} + throw; + } +} + + +bool playlist_loader::g_process_path_ex(const char * filename,playlist_loader_callback::ptr callback, abort_callback & abort,playlist_loader_callback::t_entry_type type) +{ + if (g_try_load_playlist(NULL, filename, callback, abort)) return true; + //not a playlist format + g_process_path(filename,callback,abort,type); + return false; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/playlist_loader.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/playlist_loader.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,134 @@ +#pragma once + +//! Callback interface receiving item locations from playlist loader. \n +//! Typically, you call one of standard services such as playlist_incoming_item_filter instead of implementing this interface and calling playlist_loader methods directly. +class NOVTABLE playlist_loader_callback : public service_base { + FB2K_MAKE_SERVICE_INTERFACE(playlist_loader_callback, service_base) +public: + //! Enumeration type representing origin of item passed to playlist_loader_callback. + enum t_entry_type { + //! User-requested (such as directly dropped to window or picked in openfiledialog). + entry_user_requested, + //! From directory content enumeration. + entry_directory_enumerated, + //! Referenced by playlist file. + entry_from_playlist, + }; + //! Indicates specified path being processed; provided for updating GUI. Note that optimally GUI should not be updated every time this is called because that could introduce a bottleneck. + virtual void on_progress(const char * p_path) = 0; + + //! Receives an item from one of playlist_loader functions. + //! @param p_item Item location, in form of metadb_handle pointer. + //! @param p_type Origin of this item - see t_entry_type for more info. + //! @param p_stats File stats of this item; set to filestats_invalid if not available. + //! @param p_fresh Fresh flag; indicates whether stats are directly from filesystem (true) or as stored earlier in a playlist file (false). + virtual void on_entry(const metadb_handle_ptr & p_item,t_entry_type p_type,const t_filestats & p_stats,bool p_fresh) = 0; + //! Queries whether file_info for specified item is requested. In typical scenario, if want_info() returns false, on_entry() will be called with same parameters; otherwise caller will attempt to read info from the item and call on_entry_info() with same parameters and file_info read from the item. + //! @param p_item Item location, in form of metadb_handle pointer. + //! @param p_type Origin of this item - see t_entry_type for more info. + //! @param p_stats File stats of this item; set to filestats_invalid if not available. + //! @param p_fresh Fresh flag; indicates whether stats are directly from filesystem (true) or as stored earlier in a playlist file (false). + virtual bool want_info(const metadb_handle_ptr & p_item,t_entry_type p_type,const t_filestats & p_stats,bool p_fresh) = 0; + //! Receives an item from one of playlist_loader functions; including file_info data. Except for file_info to be typically used as hint for metadb backend, behavior of this method is same as on_entry(). + //! @param p_item Item location, in form of metadb_handle pointer. + //! @param p_type Origin of this item - see t_entry_type for more info. + //! @param p_stats File stats of this item; set to filestats_invalid if not available. + //! @param p_info Information about the item, read from the file directly (if p_fresh is set to true) or from e.g. playlist file (if p_fresh is set to false). + //! @param p_fresh Fresh flag; indicates whether stats are directly from filesystem (true) or as stored earlier in a playlist file (false). + virtual void on_entry_info(const metadb_handle_ptr & p_item,t_entry_type p_type,const t_filestats & p_stats,const file_info & p_info,bool p_fresh) = 0; + + //! Same as metadb::handle_create(); provided here to avoid repeated metadb instantiation bottleneck since calling code will need this function often. + virtual void handle_create(metadb_handle_ptr & p_out,const playable_location & p_location) = 0; + + //! Returns whether further on_entry() calls for this file are wanted. Typically always returns true, can be used to optimize cases when directories are searched for files matching specific pattern only so unwanted files aren't parsed unnecessarily. + //! @param path Canonical path to the media file being processed. + virtual bool is_path_wanted(const char * path, t_entry_type type) = 0; + + virtual bool want_browse_info(const metadb_handle_ptr & p_item,t_entry_type p_type,t_filetimestamp ts) = 0; + virtual void on_browse_info(const metadb_handle_ptr & p_item,t_entry_type p_type,const file_info & info, t_filetimestamp ts) = 0; +}; + +//! \since 1.3 +//! Extended version of playlist_loader_callback, allowing caller to pass pre-made metadb_info_container \n +class NOVTABLE playlist_loader_callback_v2 : public playlist_loader_callback { + FB2K_MAKE_SERVICE_INTERFACE(playlist_loader_callback_v2, playlist_loader_callback) +public: + virtual void on_entry_info_v2(const metadb_handle_ptr & p_item,t_entry_type p_type,metadb_info_container::ptr info,bool p_fresh) = 0; + virtual void on_browse_info_v2(const metadb_handle_ptr & p_item,t_entry_type p_type,metadb_info_container::ptr info) = 0; +private: +}; + + +//! Service handling playlist file operations. There are multiple implementations handling different playlist formats; you can add new implementations to allow new custom playlist file formats to be read or written.\n +//! Also provides static helper functions for turning a filesystem path into a list of playable item locations. \n +//! Note that you should typically call playlist_incoming_item_filter methods instead of calling playlist_loader methods directly to get a list of playable items from a specified path; this way you get a core-implemented threading and abortable dialog displaying progress.\n +//! To register your own implementation, use playlist_loader_factory_t template.\n +//! To call existing implementations, use static helper methods of playlist_loader class. +class NOVTABLE playlist_loader : public service_base { +public: + //! Parses specified playlist file into list of playable locations. Throws exception_io or derivatives on failure, exception_aborted on abort. If specified file is not a recognized playlist file, exception_io_unsupported_format is thrown. + //! @param p_path Path of playlist file to parse. Used for relative path handling purposes (p_file parameter is used for actual file access). + //! @param p_file File interface to use for reading. Read/write pointer must be set to beginning by caller before calling. + //! @param p_callback Callback object receiving enumerated playable item locations. + virtual void open(const char * p_path, const service_ptr_t & p_file,playlist_loader_callback::ptr p_callback, abort_callback & p_abort) = 0; + //! Writes a playlist file containing specific item list to specified file. Will fail (pfc::exception_not_implemented) if specified playlist_loader is read-only (can_write() returns false). + //! @param p_path Path of playlist file to write. Used for relative path handling purposes (p_file parameter is used for actual file access). + //! @param p_file File interface to use for writing. Caller should ensure that the file is empty (0 bytes long) before calling. + //! @param p_data List of items to save to playlist file. + //! @param p_abort abort_callback object signaling user aborting the operation. Note that aborting a save playlist operation will most likely leave user with corrupted/incomplete file. + virtual void write(const char * p_path, const service_ptr_t & p_file,metadb_handle_list_cref p_data,abort_callback & p_abort) = 0; + //! Returns extension of file format handled by this playlist_loader implementation (a UTF-8 encoded null-terminated string). + virtual const char * get_extension() = 0; + //! Returns whether this playlist_loader implementation supports writing. If can_write() returns false, all write() calls will fail. + virtual bool can_write() = 0; + //! Returns whether specified content type is one of playlist types supported by this playlist_loader implementation or not. + //! @param p_content_type Content type to query, a UTF-8 encoded null-terminated string. + virtual bool is_our_content_type(const char* p_content_type) = 0; + //! Returns whether playlist format extension supported by this implementation should be listed on file types associations page. + virtual bool is_associatable() = 0; + + //! Attempts to load a playlist file from specified filesystem path. Throws exception_io or derivatives on failure, exception_aborted on abort. If specified file is not a recognized playlist file, exception_io_unsupported_format is thrown. \n + //! Equivalent to g_load_playlist_filehint(NULL,p_path,p_callback). + //! @param p_path Filesystem path to load playlist from, a UTF-8 encoded null-terminated string. + //! @param p_callback Callback object receiving enumerated playable item locations as well as signaling user aborting the operation. + static void g_load_playlist(const char * p_path,playlist_loader_callback::ptr p_callback, abort_callback & p_abort); + + //! Attempts to load a playlist file from specified filesystem path. Throws exception_io or derivatives on failure, exception_aborted on abort. If specified file is not a recognized playlist file, exception_io_unsupported_format is thrown. + //! @param p_path Filesystem path to load playlist from, a UTF-8 encoded null-terminated string. + //! @param p_callback Callback object receiving enumerated playable item locations as well as signaling user aborting the operation. + //! @param fileHint File object to read from, can be NULL if not available. + static void g_load_playlist_filehint(file::ptr fileHint,const char * p_path,playlist_loader_callback::ptr p_callback, abort_callback & p_abort); + + //! Attempts to load a playlist file from specified filesystem path. Throws exception_io or derivatives on failure, exception_aborted on abort. If specified file is not a recognized playlist file, returns false; returns true upon successful playlist load. + //! @param p_path Filesystem path to load playlist from, a UTF-8 encoded null-terminated string. + //! @param p_callback Callback object receiving enumerated playable item locations as well as signaling user aborting the operation. + //! @param fileHint File object to read from, can be NULL if not available. + static bool g_try_load_playlist(file::ptr fileHint,const char * p_path,playlist_loader_callback::ptr p_callback, abort_callback & p_abort); + + //! Saves specified list of locations into a playlist file. Throws exception_io or derivatives on failure, exception_aborted on abort. + //! @param p_path Filesystem path to save playlist to, a UTF-8 encoded null-terminated string. + //! @param p_data List of items to save to playlist file. + //! @param p_abort abort_callback object signaling user aborting the operation. Note that aborting a save playlist operation will most likely leave user with corrupted/incomplete file. + static void g_save_playlist(const char * p_path,metadb_handle_list_cref p_data,abort_callback & p_abort); + + //! Processes specified path to generate list of playable items. Includes recursive directory/archive enumeration. \n + //! Does not touch playlist files encountered - use g_process_path_ex() if specified path is possibly a playlist file; playlist files found inside directories or archives are ignored regardless.\n + //! Warning: caller must handle exceptions which will occur in case of I/O failure. + //! @param p_path Filesystem path to process; a UTF-8 encoded null-terminated string. + //! @param p_callback Callback object receiving enumerated playable item locations as well as signaling user aborting the operation. + //! @param p_type Origin of p_path string. Reserved for internal use in recursive calls, should be left at default value; it controls various internal behaviors. + static void g_process_path(const char * p_path,playlist_loader_callback::ptr p_callback, abort_callback & p_abort,playlist_loader_callback::t_entry_type p_type = playlist_loader_callback::entry_user_requested); + + //! Calls attempts to process specified path as a playlist; if that fails (i.e. not a playlist), calls g_process_path with same parameters. See g_process_path for parameter descriptions. \n + //! Warning: caller must handle exceptions which will occur in case of I/O failure or playlist parsing failure. + //! @returns True if specified path was processed as a playlist file, false otherwise (relevant in some scenarios where output is sorted after loading, playlist file contents should not be sorted). + static bool g_process_path_ex(const char * p_path,playlist_loader_callback::ptr p_callback, abort_callback & p_abort,playlist_loader_callback::t_entry_type p_type = playlist_loader_callback::entry_user_requested); + + + static void g_path_to_handles_simple(const char* p_path, pfc::list_base_t& p_out, abort_callback& p_abort); + + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(playlist_loader); +}; + +template +class playlist_loader_factory_t : public service_factory_single_t {}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/popup_message.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/popup_message.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,152 @@ +#include "foobar2000-sdk-pch.h" +#include "popup_message.h" +#include "messageBox.h" + +void popup_message::g_show_ex(const char * p_msg,size_t p_msg_length,const char * p_title,size_t p_title_length,t_icon p_icon) +{ + get()->show_ex(p_msg, p_msg_length, p_title, p_title_length, p_icon); +} + + +void popup_message::g_complain(const char * what) { + g_show(what, "Information", icon_error); +} + +void popup_message::g_complain(const char * p_whatFailed, const std::exception & p_exception) { + g_complain(p_whatFailed,p_exception.what()); +} +void popup_message::g_complain(const char * p_whatFailed, const char * msg) { + g_complain( pfc::format(p_whatFailed, ": ", msg)); +} + +void popup_message_v3::show_query( const char * title, const char * msg, unsigned buttons, completion_notify::ptr reply) { + query_t q; + q.title = title; q.msg = msg; q.buttons = buttons; q.reply = reply; + this->show_query( q ); +} + +void popup_message_v3::query_t::show() { + popup_message_v3::get()->show_query(*this); +} + + +void popup_message_v2::g_show(fb2k::hwnd_t parent, const char * msg, const char * title) { + service_enum_t< popup_message_v2 > e; + service_ptr_t< popup_message_v2 > m; + if (e.first( m )) { + m->show(parent, msg, title); + } else { + popup_message::g_show( msg, title ); + } +} +void popup_message_v2::g_complain(fb2k::hwnd_t parent, const char * whatFailed, const char * msg) { + g_show(parent, pfc::format(whatFailed, ": ", msg)); +} +void popup_message_v2::g_complain(fb2k::hwnd_t parent, const char * whatFailed, const std::exception & e) { + g_complain(parent, whatFailed, e.what()); +} + +void fb2k::showToast( const char * msg ) { + fb2k::popup_toast::arg_t arg; + fb2k::popup_toast::get()->show_toast(msg, arg); +} + +void fb2k::showToastLongDuration( const char * msg ) { + fb2k::popup_toast::arg_t arg; + arg.longDuration = true; + fb2k::popup_toast::get()->show_toast(msg, arg); +} +void popup_message::g_showToast(const char * msg) { + fb2k::showToast( msg ); +} +void popup_message::g_showToastLongDuration(const char * msg) { + fb2k::showToastLongDuration( msg ); +} + +int fb2k::messageBox(fb2k::hwnd_t parent, const char* msg, const char* title, unsigned flags) { + return popup_message_v3::get()->messageBox(parent, msg, title, flags); +} +void fb2k::messageBoxAsync(fb2k::hwnd_t parent, const char* msg, const char* title, unsigned flags, std::function reply) { + return popup_message_v3::get()->messageBoxAsync(parent, msg, title, flags, reply); +} +popup_message_v3::query_t popup_message_v3::setupMessageBox(fb2k::hwnd_t parent, const char* msg, const char* title, unsigned flags) { + query_t q = {}; + q.title = title; + q.msg = msg; + q.wndParent = parent; + + switch (flags & 0xF) { + default: + case MB_OK: + q.buttons = buttonOK; + q.defButton = buttonOK; + break; + case MB_OKCANCEL: + q.buttons = buttonOK | buttonCancel; + q.defButton = (flags & MB_DEFBUTTON2) ? buttonCancel : buttonOK; + break; + case MB_ABORTRETRYIGNORE: + q.buttons = buttonAbort | buttonRetry | buttonIgnore; + if (flags & MB_DEFBUTTON3) q.defButton = buttonIgnore; + else if (flags & MB_DEFBUTTON2) q.defButton = buttonRetry; + else q.defButton = buttonAbort; + break; + case MB_YESNOCANCEL: + q.buttons = buttonYes | buttonNo | buttonCancel; + if (flags & MB_DEFBUTTON3) q.defButton = buttonCancel; + else if (flags & MB_DEFBUTTON2) q.defButton = buttonNo; + else q.defButton = buttonYes; + break; + case MB_YESNO: + q.buttons = buttonYes | buttonNo; + q.defButton = (flags & MB_DEFBUTTON2) ? buttonNo : buttonYes; + break; + case MB_RETRYCANCEL: + q.buttons = buttonRetry | buttonCancel; + q.defButton = (flags & MB_DEFBUTTON2) ? buttonCancel : buttonRetry; + break; + } + switch (flags & 0xF0) { + case MB_ICONHAND: + q.icon = iconError; + break; + case MB_ICONQUESTION: + q.icon = iconQuestion; + break; + case MB_ICONEXCLAMATION: + q.icon = iconWarning; + break; + case MB_ICONASTERISK: + q.icon = iconInformation; + break; + } + + return q; +} +int popup_message_v3::messageBoxReply(uint32_t status) { + if (status & buttonOK) return IDOK; + if (status & buttonCancel) return IDCANCEL; + if (status & buttonYes) return IDYES; + if (status & buttonNo) return IDNO; + if (status & buttonRetry) return IDRETRY; + if (status & buttonAbort) return IDABORT; + if (status & buttonIgnore) return IDIGNORE; + + return -1; +} +void popup_message_v3::messageBoxAsync(fb2k::hwnd_t parent, const char* msg, const char* title, unsigned flags, std::function reply) { + PFC_ASSERT( core_api::is_main_thread() ); + auto q = setupMessageBox(parent, msg, title, flags); + if (reply) { + q.reply = fb2k::makeCompletionNotify([reply](unsigned code) { + reply(messageBoxReply(code)); + }); + } + this->show_query(q); +} +int popup_message_v3::messageBox(fb2k::hwnd_t parent, const char* msg, const char* title, unsigned flags) { + PFC_ASSERT( core_api::is_main_thread() ); + auto q = setupMessageBox(parent, msg, title, flags); + uint32_t status = this->show_query_modal(q); + return messageBoxReply(status); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/popup_message.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/popup_message.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,144 @@ +#pragma once + +#include // UINT_MAX +#include +#include "completion_notify.h" + +//! This interface allows you to show generic nonmodal noninteractive dialog with a text message. This should be used instead of MessageBox where possible.\n +//! Usage: use popup_message::g_show / popup_message::g_show_ex static helpers, or popup_message::get() to obtain an instance.\n +//! Thread safety: OK to call from worker threads (will delegate UI ops to main thread automatically). \n +//! Note that all strings are UTF-8. +class NOVTABLE popup_message : public service_base { +public: + enum t_icon {icon_information, icon_error, icon_query}; + //! Activates the popup dialog; returns immediately (the dialog remains visible). + //! @param p_msg Message to show (UTF-8 encoded string). + //! @param p_msg_length Length limit of message string to show, in bytes (actual string may be shorter if null terminator is encountered before). Set this to infinite to use plain null-terminated strings. + //! @param p_title Title of dialog to show (UTF-8 encoded string). + //! @param p_title_length Length limit of the title string, in bytes (actual string may be shorter if null terminator is encountered before). Set this to infinite to use plain null-terminated strings. + //! @param p_icon Icon of the dialog - can be set to icon_information, icon_error or icon_query. + virtual void show_ex(const char * p_msg,size_t p_msg_length,const char * p_title,size_t p_title_length,t_icon p_icon = icon_information) = 0; + + //! Activates the popup dialog; returns immediately (the dialog remains visible); helper function built around show_ex(), takes null terminated strings with no length limit parameters. + //! @param p_msg Message to show (UTF-8 encoded string). + //! @param p_title Title of dialog to show (UTF-8 encoded string). + //! @param p_icon Icon of the dialog - can be set to icon_information, icon_error or icon_query. + inline void show(const char * p_msg,const char * p_title,t_icon p_icon = icon_information) {show_ex(p_msg,UINT_MAX,p_title,UINT_MAX,p_icon);} + + //! Static helper function instantiating the service and activating the message dialog. See show_ex() for description of parameters. + static void g_show_ex(const char * p_msg,size_t p_msg_length,const char * p_title,size_t p_title_length,t_icon p_icon = icon_information); + //! Static helper function instantiating the service and activating the message dialog. See show() for description of parameters. + static inline void g_show(const char * p_msg,const char * p_title,t_icon p_icon = icon_information) {g_show_ex(p_msg,UINT_MAX,p_title,UINT_MAX,p_icon);} + + //! Shows generic box with a failure message + static void g_complain(const char * what); + //! : + static void g_complain(const char * p_whatFailed, const std::exception & p_exception); + //! : + static void g_complain(const char * p_whatFailed, const char * msg); + + static void g_showToast(const char * msg); + static void g_showToastLongDuration(const char * msg); + + FB2K_MAKE_SERVICE_COREAPI(popup_message); +}; + +#define EXCEPTION_TO_POPUP_MESSAGE(CODE,LABEL) try { CODE; } catch(std::exception const & e) {popup_message::g_complain(LABEL,e);} + +//! \since 1.1 +//! Extendsion to popup_message API. \n +//! Thread safety: OK to call from worker threads (will delegate UI ops to main thread automatically). \n +//! Note that all strings are UTF-8. +class NOVTABLE popup_message_v2 : public service_base { + FB2K_MAKE_SERVICE_COREAPI(popup_message_v2); +public: + virtual void show(fb2k::hwnd_t parent, const char * msg, t_size msg_length, const char * title, t_size title_length) = 0; + void show(fb2k::hwnd_t parent, const char * msg, const char * title) {show(parent, msg, SIZE_MAX, title, SIZE_MAX);} + + static void g_show(fb2k::hwnd_t parent, const char * msg, const char * title = "Information"); + static void g_complain(fb2k::hwnd_t parent, const char * whatFailed, const char * msg); + static void g_complain(fb2k::hwnd_t parent, const char * whatFailed, const std::exception & e); +}; + +namespace fb2k { + //! \since 2.0 + //! Not really implemented for Windows yet. + class popup_toast : public service_base { + FB2K_MAKE_SERVICE_COREAPI( popup_toast ); + public: + struct arg_t { + bool longDuration = false; + }; + virtual void show_toast(const char * msg, arg_t const & arg) = 0; + }; + void showToast( const char * msg ); + void showToastLongDuration( const char * msg ); + + class toastFormatter : public pfc::string_formatter { + public: + ~toastFormatter() noexcept { + try { + if ( this->length() > 0 ) showToast( c_str() ); + } catch(...) {} + } + }; +} + +#define FB2K_Toast() ::fb2k::toastFormatter()._formatter() + + +//! \since 1.5 +//! MessageBox-like dialog, only non-blocking and with dark mode support under foobar2000 v2.0. \n +//! Call from main thread only (contrary to popup_message / popup_message_v2) !!! +class NOVTABLE popup_message_v3 : public service_base { + FB2K_MAKE_SERVICE_COREAPI(popup_message_v3); +public: + + //! show_query button codes. \n + //! Combine one or more of these to create a button mask to pass to show_query(). + enum { + buttonOK = 1 << 0, + buttonCancel = 1 << 1, + buttonYes = 1 << 2, + buttonNo = 1 << 3, + buttonRetry = 1 << 4, + buttonAbort = 1 << 5, + buttonIgnore = 1 << 6, + + flagDoNotAskAgain = 1 << 16, + + iconNone = 0, + iconInformation, + iconQuestion, + iconWarning, + iconError, + }; + + struct query_t { + const char * title = nullptr; + const char * msg = nullptr; + uint32_t buttons = 0; + uint32_t defButton = 0; + uint32_t icon = iconNone; + completion_notify::ptr reply; // optional + fb2k::hwnd_t wndParent = NULL; + const char * msgDoNotAskAgain = nullptr; + + void show(); + }; + + //! Shows an interactive query presenting the user with multiple actions to choose from. + virtual void show_query(query_t const &) = 0; + + //! Modal version of show_query. Reply part of the argument can be empty; the status code will be returned. + virtual uint32_t show_query_modal(query_t const &) = 0; + + // Minimalist MessageBox() reimplementation wrapper + int messageBox(fb2k::hwnd_t, const char*, const char*, unsigned); + void messageBoxAsync(fb2k::hwnd_t, const char*, const char*, unsigned, std::function reply = nullptr); + static query_t setupMessageBox(fb2k::hwnd_t parent, const char* msg, const char* title, unsigned flags); + static int messageBoxReply(uint32_t); + + //! Old method wrapper + void show_query( const char * title, const char * msg, unsigned buttons, completion_notify::ptr reply); +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/powerManager.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/powerManager.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,29 @@ +#pragma once + +namespace fb2k { + //! \since 2.0 + class powerManager : public service_base { + public: + enum { + flagStrong = 1 << 0, + flagPlayback = 1 << 1, + + flagDisplay = flagStrong + }; + + //! Blocks device sleep for the duration of returned object's lifetime. \n + //! By default we ask politely but can be still put to sleep by the OS. Specify flagStrong to force the device into awake state (possibly at cost of keeping the screen up). \n + //! Thread safety: OK to call from any thread. + virtual objRef makeTask(const char* name, unsigned flags) = 0; + + //! Returns whether we're running on AC power (not on battery). \n + //! Thread safety: OK to call from any thread. + virtual bool haveACPower() = 0; + + objRef makeTaskWeak(const char* name) { return makeTask(name, 0); } + objRef makeTaskStrong(const char* name) { return makeTask(name, flagStrong); } + objRef makePlaybackTask() { return makeTask("Playback", flagPlayback); } + + FB2K_MAKE_SERVICE_COREAPI(powerManager) + }; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/preferences_page.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/preferences_page.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,22 @@ +#include "foobar2000-sdk-pch.h" +#include "preferences_page.h" +#include "coreversion.h" + +void preferences_page::get_help_url_helper(pfc::string_base & out, const char * category, const GUID & id, const char * name) { + out = "https://help.foobar2000.org/"; + pfc::urlEncodeAppend(out, core_version_info::g_get_version_string()); + out << "/"; + pfc::urlEncodeAppend(out, category); + out << "/" << pfc::print_guid(id) << "/"; + pfc::urlEncodeAppend(out, name); +} +bool preferences_page::get_help_url(pfc::string_base & p_out) { + get_help_url_helper(p_out,"preferences",get_guid(), get_name()); + return true; +} + +double preferences_page::get_sort_priority_() { + preferences_page_v2::ptr v2; + if ( v2 &= this ) return v2->get_sort_priority(); + else return 0; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/preferences_page.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/preferences_page.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,163 @@ +#pragma once + +class preferences_state { +public: + enum { + changed = 1, + needs_restart = 2, + needs_restart_playback = 4, + resettable = 8, + + //! \since 1.1 + //! Indicates that the dialog is currently busy and cannot be applied or cancelled. Do not use without a good reason! \n + //! This flag was introduced in 1.1. It will not be respected in earlier foobar2000 versions. It is recommended not to use this flag unless you are absolutely sure that you need it and take appropriate precautions. \n + //! Note that this has no power to entirely prevent your preferences page from being destroyed/cancelled as a result of app shutdown if the user dismisses the warnings, but you won't be getting an "apply" call while this is set. + busy = 16, + + //! \since 1.4.1 + needs_rescan_library = 32, + + //! \since 2.0 + dark_mode_supported = 1 << 16, + }; +}; + +//! Implementing this service will generate a page in preferences dialog. Use preferences_page_factory_t template to register. \n +//! In 1.0 and newer you should always derive from preferences_page_v3 rather than from preferences_page directly. +class NOVTABLE preferences_page : public service_base { +public: +#ifdef _WIN32 + //! Obsolete. + virtual fb2k::hwnd_t create(fb2k::hwnd_t p_parent) { (void)p_parent; uBugCheck(); } +#endif + +#ifdef __APPLE__ + //! Returns fb2k::NSObjectWrapper holding your NSViewController + virtual service_ptr instantiate( ) = 0; +#endif + + //! Retrieves name of the preferences page to be displayed in preferences tree (static string). + virtual const char * get_name() = 0; + //! Retrieves GUID of the page. + virtual GUID get_guid() = 0; + //! Retrieves GUID of parent page/branch of this page. See preferences_page::guid_* constants for list of standard parent GUIDs. Can also be a GUID of another page or a branch (see: preferences_branch). + virtual GUID get_parent_guid() = 0; +#ifdef _WIN32 + //! Obsolete. + virtual bool reset_query() { return false; } + //! Obsolete. + virtual void reset() {} +#endif + //! Retrieves help URL. Without overriding it, it will redirect to foobar2000 wiki. + virtual bool get_help_url(pfc::string_base & p_out); + + static void get_help_url_helper(pfc::string_base & out, const char * category, const GUID & id, const char * name); + + static const GUID guid_root, guid_hidden, guid_tools,guid_core,guid_display,guid_playback,guid_visualisations,guid_input,guid_tag_writing,guid_media_library, guid_tagging, guid_output, guid_advanced, guid_components, guid_dsp, guid_shell, guid_keyboard_shortcuts; + //! \since 1.5 + static const GUID guid_input_info_filter; + + double get_sort_priority_(); + + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(preferences_page); +}; + +class NOVTABLE preferences_page_v2 : public preferences_page { +public: + //! Allows custom sorting order of preferences pages. Return lower value for higher priority (lower resulting index in the list). When sorting priority of two items matches, alphabetic sorting is used. Return 0 to use default alphabetic sorting without overriding priority. + virtual double get_sort_priority() {return 0;} + + FB2K_MAKE_SERVICE_INTERFACE(preferences_page_v2,preferences_page); +}; + +template +class preferences_page_factory_t : public service_factory_single_t {}; + +//! Creates a preferences branch - an empty page that only serves as a parent for other pages and is hidden when no child pages exist. Instead of implementing this, simply use preferences_branch_factory class to declare a preferences branch with specified parameters. +class NOVTABLE preferences_branch : public service_base { +public: + //! Retrieves name of the preferences branch. + virtual const char * get_name() = 0; + //! Retrieves GUID of the preferences branch. Use this GUID as parent GUID for pages/branches nested in this branch. + virtual GUID get_guid() = 0; + //! Retrieves GUID of parent page/branch of this branch. See preferences_page::guid_* constants for list of standard parent GUIDs. Can also be a GUID of another branch or a page. + virtual GUID get_parent_guid() = 0; + + + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(preferences_branch); +}; + +class preferences_branch_v2 : public preferences_branch { +public: + //! Allows custom sorting order of preferences pages. Return lower value for higher priority (lower resulting index in the list). When sorting priority of two items matches, alphabetic sorting is used. Return 0 to use default alphabetic sorting without overriding priority. + virtual double get_sort_priority() {return 0;} + + FB2K_MAKE_SERVICE_INTERFACE(preferences_branch_v2,preferences_branch); +}; + +class preferences_branch_impl : public preferences_branch_v2 { +public: + preferences_branch_impl(const GUID & p_guid,const GUID & p_parent,const char * p_name,double p_sort_priority = 0) : m_guid(p_guid), m_parent(p_parent), m_name(p_name), m_sort_priority(p_sort_priority) {} + const char * get_name() {return m_name;} + GUID get_guid() {return m_guid;} + GUID get_parent_guid() {return m_parent;} + double get_sort_priority() {return m_sort_priority;} +private: + const GUID m_guid,m_parent; + const pfc::string8 m_name; + const double m_sort_priority; +}; + +typedef service_factory_single_t _preferences_branch_factory; + +//! Instantiating this class declares a preferences branch with specified parameters.\n +//! Usage: static preferences_branch_factory g_mybranch(mybranchguid,parentbranchguid,"name of my preferences branch goes here"); +class preferences_branch_factory : public _preferences_branch_factory { +public: + preferences_branch_factory(const GUID & p_guid,const GUID & p_parent,const char * p_name,double p_sort_priority = 0) : _preferences_branch_factory(p_guid,p_parent,p_name,p_sort_priority) {} +}; + + +#ifdef _WIN32 +class preferences_page_callback : public service_base { + FB2K_MAKE_SERVICE_INTERFACE(preferences_page_callback, service_base) +public: + virtual void on_state_changed() = 0; +}; + +//! \since 1.0 +//! Implements a preferences page instance. \n +//! Instantiated through preferences_page_v3::instantiate(). \n +//! Note that the window will be destroyed by the caller before the last reference to the preferences_page_instance is released. \n +//! WARNING: misguided use of modal dialogs - or ANY windows APIs that might spawn such dialogs - may result in conditions when the owner dialog (along with your page) is destroyed somewhere inside your message handler, also releasing references to your object. \n +//! It is recommended to use window_service_impl_t<> from ATLHelpers to instantiate preferences_page_instances, or preferences_page_impl<> framework for your preferences_page code to cleanly workaround such cases. +class preferences_page_instance : public service_base { + FB2K_MAKE_SERVICE_INTERFACE(preferences_page_instance, service_base) +public: + //! @returns a combination of preferences_state constants. + virtual t_uint32 get_state() = 0; + //! @returns the window handle. + virtual fb2k::hwnd_t get_wnd() = 0; + //! Applies preferences changes. + virtual void apply() = 0; + //! Resets this page's content to the default values. Does not apply any changes - lets user preview the changes before hitting "apply". + virtual void reset() = 0; +}; +#endif + +//! \since 1.0 +//! Implements a preferences page. +class preferences_page_v3 : public preferences_page_v2 { + FB2K_MAKE_SERVICE_INTERFACE(preferences_page_v3, preferences_page_v2) +public: +#ifdef _WIN32 + virtual preferences_page_instance::ptr instantiate(fb2k::hwnd_t parent, preferences_page_callback::ptr callback) = 0; +#endif +}; + +//! \since 1.5 +class NOVTABLE preferences_page_v4 : public preferences_page_v3 { + FB2K_MAKE_SERVICE_INTERFACE(preferences_page_v4, preferences_page_v3); +public: + virtual bool is_hidden() { return false; } +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/progress_meter.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/progress_meter.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,22 @@ +#pragma once + +//! Interface for setting current operation progress state to be visible on Windows 7 taskbar. Use progress_meter::get()->acquire() to instantiate. +class NOVTABLE progress_meter_instance : public service_base { + FB2K_MAKE_SERVICE_INTERFACE(progress_meter_instance, service_base); +public: + //! Sets the current progress state. + //! @param value Progress state, in 0..1 range. + virtual void set_progress(float value) = 0; + //! Toggles paused state. + virtual void set_pause(bool isPaused) = 0; + + static bool serviceRequiresMainThreadDestructor() { return true; } +}; + +//! Entrypoint interface for instantiating progress_meter_instance objects. +class NOVTABLE progress_meter : public service_base { + FB2K_MAKE_SERVICE_COREAPI(progress_meter); +public: + //! Creates a progress_meter_instance object. + virtual progress_meter_instance::ptr acquire() = 0; +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/replaygain.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/replaygain.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,228 @@ +#include "foobar2000-sdk-pch.h" +#include "replaygain.h" +#include "replaygain_scanner.h" + +void t_replaygain_config::reset() +{ + m_source_mode = source_mode_none; + m_processing_mode = processing_mode_none; + m_preamp_without_rg = 0; + m_preamp_with_rg = 0; +} + +audio_sample t_replaygain_config::query_scale(const file_info & info) const +{ + return query_scale(info.get_replaygain()); +} + +audio_sample t_replaygain_config::query_scale(const replaygain_info & info) const { + const audio_sample peak_margin = 1.0;//used to be 0.999 but it must not trigger on lossless + + audio_sample peak = peak_margin; + audio_sample gain = 0; + + bool have_rg_gain = false, have_rg_peak = false; + + if (m_source_mode == source_mode_track || m_source_mode == source_mode_album) + { + if (m_source_mode == source_mode_track) + { + if (info.is_track_gain_present()) {gain = info.m_track_gain; have_rg_gain = true; } + else if (info.is_album_gain_present()) {gain = info.m_album_gain; have_rg_gain = true; } + if (info.is_track_peak_present()) {peak = info.m_track_peak; have_rg_peak = true; } + else if (info.is_album_peak_present()) {peak = info.m_album_peak; have_rg_peak = true; } + } + else + { + if (info.is_album_gain_present()) {gain = info.m_album_gain; have_rg_gain = true; } + else if (info.is_track_gain_present()) {gain = info.m_track_gain; have_rg_gain = true; } + if (info.is_album_peak_present()) {peak = info.m_album_peak; have_rg_peak = true; } + else if (info.is_track_peak_present()) {peak = info.m_track_peak; have_rg_peak = true; } + } + } + + gain += have_rg_gain ? m_preamp_with_rg : m_preamp_without_rg; + + audio_sample scale = 1.0; + + if (m_processing_mode == processing_mode_gain || m_processing_mode == processing_mode_gain_and_peak) + { + scale *= (audio_sample) audio_math::gain_to_scale(gain); + } + + if ((m_processing_mode == processing_mode_peak || m_processing_mode == processing_mode_gain_and_peak) && have_rg_peak) + { + if (scale * peak > peak_margin) + scale = (audio_sample)(peak_margin / peak); + } + + return scale; +} + +audio_sample t_replaygain_config::query_scale(const metadb_handle_ptr & p_object) const +{ + return query_scale(p_object->get_async_info_ref()->info()); +} + +audio_sample replaygain_manager::core_settings_query_scale(const file_info & p_info) +{ + t_replaygain_config temp; + get_core_settings(temp); + return temp.query_scale(p_info); +} + +audio_sample replaygain_manager::core_settings_query_scale(const metadb_handle_ptr & info) +{ + t_replaygain_config temp; + get_core_settings(temp); + return temp.query_scale(info); +} + +//enum t_source_mode {source_mode_none,source_mode_track,source_mode_album}; +//enum t_processing_mode {processing_mode_none,processing_mode_gain,processing_mode_gain_and_peak,processing_mode_peak}; + +static const char* querysign(int val) { + return val < 0 ? "-" : val>0 ? "+" : "\xc2\xb1"; +} + +static pfc::string_fixed_t<128> format_dbdelta(double p_val) { + pfc::string_fixed_t<128> ret; + int val = (int)pfc::rint32(p_val * 10); + ret << querysign(val) << (abs(val) / 10) << "." << (abs(val) % 10) << "dB"; + return ret; +} +void t_replaygain_config::print_preamp(double val, pfc::string_base & out) { + out = format_dbdelta(val); +} +void t_replaygain_config::format_name(pfc::string_base & p_out) const +{ + switch(m_processing_mode) + { + case processing_mode_none: + p_out = "None."; + break; + case processing_mode_gain: + switch(m_source_mode) + { + case source_mode_none: + if (m_preamp_without_rg == 0) p_out = "None."; + else p_out = PFC_string_formatter() << "Preamp : " << format_dbdelta(m_preamp_without_rg); + break; + case source_mode_track: + { + pfc::string_formatter fmt; + fmt << "Apply track gain"; + if (m_preamp_without_rg != 0 || m_preamp_with_rg != 0) fmt << ", with preamp"; + fmt << "."; + p_out = fmt; + } + break; + case source_mode_album: + { + pfc::string_formatter fmt; + fmt << "Apply album gain"; + if (m_preamp_without_rg != 0 || m_preamp_with_rg != 0) fmt << ", with preamp"; + fmt << "."; + p_out = fmt; + } + break; + }; + break; + case processing_mode_gain_and_peak: + switch(m_source_mode) + { + case source_mode_none: + if (m_preamp_without_rg >= 0) p_out = "None."; + else p_out = PFC_string_formatter() << "Preamp : " << format_dbdelta(m_preamp_without_rg); + break; + case source_mode_track: + { + pfc::string_formatter fmt; + fmt << "Apply track gain"; + if (m_preamp_without_rg != 0 || m_preamp_with_rg != 0) fmt << ", with preamp"; + fmt << ", prevent clipping according to track peak."; + p_out = fmt; + } + break; + case source_mode_album: + { + pfc::string_formatter fmt; + fmt << "Apply album gain"; + if (m_preamp_without_rg != 0 || m_preamp_with_rg != 0) fmt << ", with preamp"; + fmt << ", prevent clipping according to album peak."; + p_out = fmt; + } + break; + }; + break; + case processing_mode_peak: + switch(m_source_mode) + { + case source_mode_none: + p_out = "None."; + break; + case source_mode_track: + p_out = "Prevent clipping according to track peak."; + break; + case source_mode_album: + p_out = "Prevent clipping according to album peak."; + break; + }; + break; + } +} + +bool t_replaygain_config::is_active() const +{ + switch(m_processing_mode) + { + case processing_mode_none: + return false; + case processing_mode_gain: + switch(m_source_mode) + { + case source_mode_none: + return m_preamp_without_rg != 0; + case source_mode_track: + return true; + case source_mode_album: + return true; + }; + return false; + case processing_mode_gain_and_peak: + switch(m_source_mode) + { + case source_mode_none: + return m_preamp_without_rg < 0; + case source_mode_track: + return true; + case source_mode_album: + return true; + }; + return false; + case processing_mode_peak: + switch(m_source_mode) + { + case source_mode_none: + return false; + case source_mode_track: + return true; + case source_mode_album: + return true; + }; + return false; + default: + return false; + } +} + + +replaygain_scanner::ptr replaygain_scanner_entry::instantiate( uint32_t flags ) { + replaygain_scanner_entry_v2::ptr p2; + if ( p2 &= this ) return p2->instantiate( flags ); + else return instantiate(); +} + +t_replaygain_config replaygain_manager::get_core_settings() { + t_replaygain_config cfg; get_core_settings(cfg); return cfg; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/replaygain.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/replaygain.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,93 @@ +#pragma once +//! Structure storing ReplayGain configuration: album/track source data modes, gain/peak processing modes and preamp values. +struct t_replaygain_config +{ + enum /*t_source_mode*/ { + source_mode_none, + source_mode_track, + source_mode_album, + // New in 1.3.8 + // SPECIAL MODE valid only for playback settings; if set, track gain will be used for random & shuffle-tracks modes, album for shuffle albums & ordered playback. + source_mode_byPlaybackOrder + }; + enum /*t_processing_mode*/ {processing_mode_none,processing_mode_gain,processing_mode_gain_and_peak,processing_mode_peak}; + typedef t_uint32 t_source_mode; typedef t_uint32 t_processing_mode; + + t_replaygain_config() {reset();} + t_replaygain_config(t_source_mode p_source_mode,t_processing_mode p_processing_mode,float p_preamp_without_rg, float p_preamp_with_rg) + : m_source_mode(p_source_mode), m_processing_mode(p_processing_mode), m_preamp_without_rg(p_preamp_without_rg), m_preamp_with_rg(p_preamp_with_rg) {} + + + t_source_mode m_source_mode; + t_processing_mode m_processing_mode; + float m_preamp_without_rg, m_preamp_with_rg;//preamp values in dB + + void reset(); + audio_sample query_scale(const file_info & info) const; + audio_sample query_scale(const metadb_handle_ptr & info) const; + audio_sample query_scale(const replaygain_info & info) const; + + static void print_preamp(double val, pfc::string_base & out); + + void format_name(pfc::string_base & p_out) const; + bool is_active() const; + + static bool equals(const t_replaygain_config & v1, const t_replaygain_config & v2) { + return v1.m_source_mode == v2.m_source_mode && v1.m_processing_mode == v2.m_processing_mode && v1.m_preamp_without_rg == v2.m_preamp_without_rg && v1.m_preamp_with_rg == v2.m_preamp_with_rg; + } + bool operator==(const t_replaygain_config & other) const {return equals(*this, other);} + bool operator!=(const t_replaygain_config & other) const {return !equals(*this, other);} +}; + +FB2K_STREAM_READER_OVERLOAD(t_replaygain_config) { + return stream >> value.m_source_mode >> value.m_processing_mode >> value.m_preamp_with_rg >> value.m_preamp_without_rg; +} +FB2K_STREAM_WRITER_OVERLOAD(t_replaygain_config) { + return stream << value.m_source_mode << value.m_processing_mode << value.m_preamp_with_rg << value.m_preamp_without_rg; +} + +//! Core service providing methods to retrieve/alter playback ReplayGain settings, as well as use ReplayGain configuration dialog. +class NOVTABLE replaygain_manager : public service_base { +public: + //! Retrieves playback ReplayGain settings. + virtual void get_core_settings(t_replaygain_config & p_out) = 0; + t_replaygain_config get_core_settings(); + + //! Creates embedded version of ReplayGain settings dialog. Note that embedded dialog sends WM_COMMAND with id/BN_CLICKED to parent window when user makes changes to settings. + virtual fb2k::hwnd_t configure_embedded(const t_replaygain_config & p_initdata,fb2k::hwnd_t p_parent,unsigned p_id,bool p_from_modal) = 0; + //! Retrieves settings from embedded version of ReplayGain settings dialog. + virtual void configure_embedded_retrieve(fb2k::hwnd_t wnd,t_replaygain_config & p_data) = 0; + + //! Shows popup/modal version of ReplayGain settings dialog. Returns true when user changed the settings, false when user cancelled the operation. Title parameter can be null to use default one. + virtual bool configure_popup(t_replaygain_config & p_data,fb2k::hwnd_t p_parent,const char * p_title) = 0; + + //! Alters playback ReplayGain settings. + virtual void set_core_settings(const t_replaygain_config & p_config) = 0; + + //! New in 1.0 + virtual void configure_embedded_set(fb2k::hwnd_t wnd, t_replaygain_config const & p_data) = 0; + //! New in 1.0 + virtual void get_core_defaults(t_replaygain_config & out) = 0; + + //! Helper; queries scale value for specified item according to core playback settings. + audio_sample core_settings_query_scale(const file_info & p_info); + //! Helper; queries scale value for specified item according to core playback settings. + audio_sample core_settings_query_scale(const metadb_handle_ptr & info); + + FB2K_MAKE_SERVICE_COREAPI(replaygain_manager); +}; + +//! \since 1.4 +class NOVTABLE replaygain_core_settings_notify { +public: + virtual void on_changed( t_replaygain_config const & cfg ) = 0; +}; + +//! \since 1.4 +//! Adds new method for getting notified about core RG settings changing +class NOVTABLE replaygain_manager_v2 : public replaygain_manager { + FB2K_MAKE_SERVICE_COREAPI_EXTENSION( replaygain_manager_v2, replaygain_manager ); +public: + virtual void add_notify(replaygain_core_settings_notify *) = 0; + virtual void remove_notify(replaygain_core_settings_notify *) = 0; +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/replaygain_info.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/replaygain_info.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,172 @@ +#include "foobar2000-sdk-pch.h" + +#ifdef _MSC_VER +#include +#define RG_FPU() fpu_control_roundnearest bah; +#else +#define RG_FPU() +#endif + +bool replaygain_info::g_format_gain(float p_value,char p_buffer[text_buffer_size]) +{ + RG_FPU(); + if (p_value == gain_invalid) + { + p_buffer[0] = 0; + return false; + } + else + { + pfc::float_to_string(p_buffer,text_buffer_size - 4,p_value,2,true); +#ifdef _MSC_VER + strcat_s(p_buffer, text_buffer_size, " dB"); +#else + strcat(p_buffer, " dB"); +#endif + return true; + } +} + +bool replaygain_info::g_format_peak_db(float p_value, char p_buffer[text_buffer_size]) { + const float lo = 1.0 / (float)(1 << 24); + if ( p_value == peak_invalid || p_value < lo ) return false; + return g_format_gain((float)audio_math::scale_to_gain(p_value), p_buffer); + +} + +bool replaygain_info::g_format_peak(float p_value,char p_buffer[text_buffer_size]) +{ + RG_FPU(); + if (p_value == peak_invalid) + { + p_buffer[0] = 0; + return false; + } + else + { + pfc::float_to_string(p_buffer,text_buffer_size,p_value,6,false); + return true; + } +} + +void replaygain_info::reset() +{ + *this = replaygain_info(); +} + +#define meta_album_gain "replaygain_album_gain" +#define meta_album_peak "replaygain_album_peak" +#define meta_track_gain "replaygain_track_gain" +#define meta_track_peak "replaygain_track_peak" + +bool replaygain_info::g_is_meta_replaygain(const char * p_name,t_size p_name_len) +{ + return + stricmp_utf8_ex(p_name,p_name_len,meta_album_gain,SIZE_MAX) == 0 || + stricmp_utf8_ex(p_name,p_name_len,meta_album_peak,SIZE_MAX) == 0 || + stricmp_utf8_ex(p_name,p_name_len,meta_track_gain,SIZE_MAX) == 0 || + stricmp_utf8_ex(p_name,p_name_len,meta_track_peak,SIZE_MAX) == 0; +} + +bool replaygain_info::set_from_meta_ex(const char * p_name,t_size p_name_len,const char * p_value,t_size p_value_len) +{ + RG_FPU(); + if (stricmp_utf8_ex(p_name,p_name_len,meta_album_gain,SIZE_MAX) == 0) + { + m_album_gain = (float)pfc::string_to_float(p_value,p_value_len); + return true; + } + else if (stricmp_utf8_ex(p_name,p_name_len,meta_album_peak,SIZE_MAX) == 0) + { + m_album_peak = (float)pfc::string_to_float(p_value,p_value_len); + if (m_album_peak < 0) m_album_peak = 0; + return true; + } + else if (stricmp_utf8_ex(p_name,p_name_len,meta_track_gain,SIZE_MAX) == 0) + { + m_track_gain = (float)pfc::string_to_float(p_value,p_value_len); + return true; + } + else if (stricmp_utf8_ex(p_name,p_name_len,meta_track_peak,SIZE_MAX) == 0) + { + m_track_peak = (float)pfc::string_to_float(p_value,p_value_len); + if (m_track_peak < 0) m_track_peak = 0; + return true; + } + else return false; +} + + +t_size replaygain_info::get_value_count() +{ + t_size ret = 0; + if (is_album_gain_present()) ret++; + if (is_album_peak_present()) ret++; + if (is_track_gain_present()) ret++; + if (is_track_peak_present()) ret++; + return ret; +} + +float replaygain_info::anyGain(bool bPreferAlbum) const { + if ( bPreferAlbum ) { + if ( this->is_album_gain_present() ) return this->m_album_gain; + return this->m_track_gain; + } else { + if ( this->is_track_gain_present() ) return this->m_track_gain; + return this->m_album_gain; + } +} + +float replaygain_info::g_parse_gain_text(const char * p_text, t_size p_text_len) { + RG_FPU(); + if (p_text != 0 && p_text_len > 0 && *p_text != 0) + return (float)pfc::string_to_float(p_text, p_text_len); + else + return gain_invalid; +} + +void replaygain_info::set_album_gain_text(const char * p_text,t_size p_text_len) { + m_album_gain = g_parse_gain_text(p_text, p_text_len); +} + +void replaygain_info::set_track_gain_text(const char * p_text,t_size p_text_len) +{ + m_track_gain = g_parse_gain_text(p_text, p_text_len); +} + +void replaygain_info::set_album_peak_text(const char * p_text,t_size p_text_len) +{ + RG_FPU(); + if (p_text != 0 && p_text_len > 0 && *p_text != 0) + m_album_peak = (float)pfc::string_to_float(p_text,p_text_len); + else + remove_album_peak(); +} + +void replaygain_info::set_track_peak_text(const char * p_text,t_size p_text_len) +{ + RG_FPU(); + if (p_text != 0 && p_text_len > 0 && *p_text != 0) + m_track_peak = (float)pfc::string_to_float(p_text,p_text_len); + else + remove_track_peak(); +} + +replaygain_info replaygain_info::g_merge(replaygain_info r1,replaygain_info r2) +{ + replaygain_info ret = r1; + if (!ret.is_album_gain_present()) ret.m_album_gain = r2.m_album_gain; + if (!ret.is_album_peak_present()) ret.m_album_peak = r2.m_album_peak; + if (!ret.is_track_gain_present()) ret.m_track_gain = r2.m_track_gain; + if (!ret.is_track_peak_present()) ret.m_track_peak = r2.m_track_peak; + return ret; +} + + +void replaygain_info::for_each(for_each_t f) const { + t_text_buffer buffer; + if (format_track_gain(buffer)) f(meta_track_gain, buffer); + if (format_track_peak(buffer)) f(meta_track_peak, buffer); + if (format_album_gain(buffer)) f(meta_album_gain, buffer); + if (format_album_peak(buffer)) f(meta_album_peak, buffer); +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/replaygain_scanner.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/replaygain_scanner.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,112 @@ +#pragma once + +#include "replaygain.h" + +//! Container of ReplayGain scan results from one or more tracks. +class replaygain_result : public service_base { + FB2K_MAKE_SERVICE_INTERFACE(replaygain_result, service_base); +public: + //! Retrieves the gain value, in dB. + virtual float get_gain() = 0; + //! Retrieves the peak value, normalized to 0..1 range (audio_sample value). + virtual float get_peak() = 0; + //! Merges ReplayGain scan results from different tracks. Merge results from all tracks in an album to get album gain/peak values. \n + //! This function returns a newly created replaygain_result object. Existing replaygain_result objects remain unaltered. + virtual replaygain_result::ptr merge(replaygain_result::ptr other) = 0; + + replaygain_info make_track_info() { + replaygain_info ret = replaygain_info_invalid; ret.m_track_gain = this->get_gain(); ret.m_track_peak = this->get_peak(); return ret; + } +}; + +//! Instance of a ReplayGain scanner. \n +//! Use replaygain_scanner_entry::instantiate() to create a replaygain_scanner object; see replaygain_scanner_entry for more info. \n +//! Typical use: call process_chunk() with each chunk read from your track, call finalize() to obtain results for this track and reset replaygain_scanner's state for scanning another track; to obtain album gain/peak values, merge results (replaygain_result::merge) from all tracks. \n +class replaygain_scanner : public service_base { + FB2K_MAKE_SERVICE_INTERFACE(replaygain_scanner, service_base); +public: + //! Processes a PCM chunk. \n + //! May throw exception_io_data if the chunk contains something that can't be processed properly. + virtual void process_chunk(const audio_chunk & chunk) = 0; + //! Finalizes the scanning process; resets scanner's internal state and returns results for the track we've just scanned. \n + //! After calling finalize(), scanner's state becomes the same as after instantiation; you can continue with processing another track without creating a new scanner object. + virtual replaygain_result::ptr finalize() = 0; +}; + + +//! Entrypoint class for instantiating replaygain_scanner objects. \n +//! This service is OPTIONAL; it's available from foobar2000 0.9.5.3 up but only if the ReplayGain Scanner component is installed. \n +//! It is recommended that you use replaygain_scanner like this: \n +//! replaygain_scanner_entry::ptr theAPI; \n +//! if (replaygain_scanner_entry::tryGet(theAPI)) { \n +//! myInstance = theAPI->instantiate(); \n +//! } else { \n +//! no foo_rgscan installed - complain/fail/etc \n +//! } \n +//! Note that replaygain_scanner_entry::get() is provided for convenience - it WILL crash with no foo_rgscan present. Use it only after prior checks. +class replaygain_scanner_entry : public service_base { + FB2K_MAKE_SERVICE_COREAPI(replaygain_scanner_entry); +public: + //! Instantiates a replaygain_scanner object. + virtual replaygain_scanner::ptr instantiate() = 0; + + //! Helper; uses replaygain_scanner_entry_v2 if available; see replaygain_scanner_entry_v2. + replaygain_scanner::ptr instantiate( uint32_t flags ); +}; + +//! \since 1.4 +//! This service is OPTIONAL; it's available from foobar2000 v1.4 up but only if the ReplayGain Scanner component is installed. \n +//! Use tryGet() to instantiate - get() only after prior verification of availability. +class replaygain_scanner_entry_v2 : public replaygain_scanner_entry { + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(replaygain_scanner_entry_v2, replaygain_scanner_entry) +public: + enum { + flagScanPeak = 1 << 0, + flagScanGain = 1 << 1, + }; + + //! Extended instantiation method. \n + //! Allows you to declare which parts of the scanning process are relevant for you + //! so irrelevant parts of the processing can be skipped. + //! For an example, if you don't care about the peak, specify only flagScanGain - + //! as peak scan while normally cheap may be very expensive with extreme oversampling specified by user. + virtual replaygain_scanner::ptr instantiate(uint32_t flags) = 0; +}; + +//! Internal service introduced in 1.5. No guarantees about compatibility. May be changed or removed at any time. +class replaygain_scanner_config : public service_base { + FB2K_MAKE_SERVICE_COREAPI(replaygain_scanner_config); +public: + virtual void get_album_pattern( pfc::string_base & out ) = 0; + virtual uint64_t get_read_size_bytes() = 0; +}; + +#ifdef FOOBAR2000_DESKTOP +//! \since 1.4 +//! A class for applying gain to compressed audio packets such as MP3 or AAC. \n +//! Implemented by foo_rgscan for common formats. May be extended to allow foo_rgscan to manipulate more different codecs. +class replaygain_alter_stream : public service_base { + FB2K_MAKE_SERVICE_INTERFACE(replaygain_alter_stream, service_base) +public: + //! @returns The amount to which all adjustments are quantized for this format. Essential for caller to be able to correctly prevent clipping. + virtual float get_adjustment_step( ) = 0; + //! Sets the adjustment in decibels. Note that the actual applied adjustment will be quantized with nearest-rounding to a multiple of get_adjustment_step() value. + virtual void set_adjustment( float deltaDB ) = 0; + //! Passes the first frame playload. This serves as a hint and may be safely ignored for most formats. However in some cases - MP3 vs MP2 in particular - you do knot know what exact format you're dealing with until you've examined the first frame. \n + //! If you're calling this service, always feed the first frame before calling get_adjustment_step(). + virtual void on_first_frame( const void * frame, size_t bytes ) = 0; + //! Applies gain to the frame. \n + //! May throw exception_io_data if the frame payload is corrupted and cannot be altered. The user will be informed about bad frame statistics, however the operation will continue until EOF. + virtual void alter_frame( void * frame, size_t bytes ) = 0; +}; + +//! \since 1.4 +//! Entrypoint class for instantiating replaygain_alter_stream. Walk with service_enum_t<> to find one that supports specific format. +class replaygain_alter_stream_entry : public service_base { + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(replaygain_alter_stream_entry); +public: + //! @returns Newly created replaygain_alter_stream object. Null if this format is not supported by this implementation. + //! Arguments as per packet_decoder::g_open(). + virtual replaygain_alter_stream::ptr open(const GUID & p_owner, size_t p_param1, const void * p_param2, size_t p_param2size ) = 0; +}; +#endif diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/resampler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/resampler.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,77 @@ +#pragma once + +#ifdef FOOBAR2000_HAVE_DSP + +//! A resampler DSP entry. \n +//! It is STRICTLY REQUIRED that the output is: \n +//! (A) In the requested sample rate (specified when creating the preset), \n +//! (B) .. or untouched if the conversion cannot be performed / there's no conversion to be performed (input rate == output rate). \n +//! Not every resampler supports every possible sample rate conversion ratio. Bundled PPHS resampler (always installed since foobar2000 v1.6) does accept every possible conversion. +class NOVTABLE resampler_entry : public dsp_entry +{ +public: + virtual bool is_conversion_supported(unsigned p_srate_from,unsigned p_srate_to) = 0; + virtual bool create_preset(dsp_preset & p_out,unsigned p_target_srate,float p_qualityscale) = 0;//p_qualityscale is 0...1 + virtual float get_priority() = 0;//value is 0...1, where high-quality (SSRC etc) has 1 + + static bool g_get_interface(service_ptr_t & p_out,unsigned p_srate_from,unsigned p_srate_to); + static bool g_create(service_ptr_t & p_out,unsigned p_srate_from,unsigned p_srate_to,float p_qualityscale); + static bool g_create_preset(dsp_preset & p_out,unsigned p_srate_from,unsigned p_srate_to,float p_qualityscale); + + FB2K_MAKE_SERVICE_INTERFACE(resampler_entry,dsp_entry); +}; + +template +class implement_resampler_entry : public base_t { +public: + bool is_conversion_supported(unsigned p_srate_from, unsigned p_srate_to) override { return impl_t::g_is_conversion_supported(p_srate_from, p_srate_to); } + bool create_preset(dsp_preset& p_out, unsigned p_target_srate, float p_qualityscale) override { return impl_t::g_create_preset(p_out, p_target_srate, p_qualityscale); } + float get_priority() override { return impl_t::g_get_priority(); } +}; + +template +class resampler_entry_impl_t : public implement_resampler_entry > {}; + +template +class resampler_factory_t : public service_factory_single_t > {}; + +#ifdef FOOBAR2000_DESKTOP + +//! \since 1.4 +//! Supersedes resampler_entry::get_priority, allows the user to specify which resampler should be preferred when a component asks for one. +class resampler_manager : public service_base { + FB2K_MAKE_SERVICE_COREAPI(resampler_manager); +public: + //! Locate the preferred resampler that is capable of performing conversion from the source to destination rate. \n + //! If input sample rate is not known in advance or may change in mid-conversion, it's recommended to use make_chain() instead to full obey user settings. + virtual resampler_entry::ptr get_resampler( unsigned rateFrom, unsigned rateTo ) = 0; + + //! Compatibility wrapper, see resampler_manager_v2::make_chain(). + void make_chain_(dsp_chain_config& outChain, unsigned rateFrom, unsigned rateTo, float qualityScale); +}; + +class dsp_chain_config; + +//! \since 1.6 +class resampler_manager_v2 : public resampler_manager { + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(resampler_manager_v2, resampler_manager); +public: + //! Make a chain of resamplers. \n + //! Pass the intended sample rates for rateFrom & rateTo. Pass 0 rateFrom if it is not known in advance or may change in mid-conversion. + //! With rateFrom known in advance, the chain should hold only one DSP. \n + //! If rateFrom is not known in advance, multiple DSPs may be returned - a preferred one that accepts common conversion ratios but not all of them, and a fallback one that handles every scenario if the first one failed. \n + //! For an example, by default, SSRC (higher quality) is used, but PPHS (more compatible) is added to clean up odd sample rates that SSRC failed to process. \n + //! Note that it is required that resamplers pass untouched data if no resampling is performed, so additional DSPs have no effect on the audio coming thru, as just one resampler will actually do anything. + virtual void make_chain( dsp_chain_config & outChain, unsigned rateFrom, unsigned rateTo, float qualityScale) = 0; +}; + +//! \since 1.6.1 +class resampler_manager_v3 : public resampler_manager_v2 { + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(resampler_manager_v3, resampler_manager_v2); +public: + //! Extended make_chain that also manipulates channel layout. + virtual void make_chain_v3(dsp_chain_config& outChain, unsigned rateFrom, unsigned rateTo, float qualityScale, unsigned chmask) = 0; +}; +#endif + +#endif // FOOBAR2000_HAVE_DSP diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/search_tools.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/search_tools.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,145 @@ +#pragma once + +//! \since 0.9.5 +//! Instance of a search filter object. \n +//! This object contains a preprocessed search query; used to perform filtering similar to Media Library Search or Album List's "filter" box. \n +//! Use search_filter_manager API to instantiate search_filter objects. +class search_filter : public service_base { +public: +protected: + //! For backwards compatibility with older (0.9.5 alpha) revisions of this API. Do not call. + virtual bool test_locked(const metadb_handle_ptr & p_item,const file_info * p_info) = 0; +public: + + //! Use this to run this filter on a group of items. + //! @param data Items to test. + //! @param out Pointer to a buffer (size at least equal to number of items in the source list) receiving the results. + virtual void test_multi(metadb_handle_list_cref data, bool * out) = 0; + + FB2K_MAKE_SERVICE_INTERFACE(search_filter,service_base); +}; + +//! \since 0.9.5.3 +class search_filter_v2 : public search_filter { +public: + virtual bool get_sort_pattern(titleformat_object::ptr & out, int & direction) = 0; + + //! Abortable version of test_multi(). If the abort_callback object becomes signaled while the operation is being performed, contents of the output buffer are undefined and the operation will fail with exception_aborted. + virtual void test_multi_ex(metadb_handle_list_cref data, bool * out, abort_callback & abort) = 0; + + //! Helper; removes non-matching items from the list. + void test_multi_here(metadb_handle_list & ref, abort_callback & abort); + + FB2K_MAKE_SERVICE_INTERFACE(search_filter_v2, search_filter) +}; + +//! \since 0.9.5.4 +class search_filter_v3 : public search_filter_v2 { +public: + //! Returns whether the sort pattern returned by get_sort_pattern() was set by the user explicitly using "SORT BY" syntax or whether it was determined implicitly from some other part of the query. It's recommended to use this to determine whether to create a force-sorted autoplaylist or not. + virtual bool is_sort_explicit() = 0; + + FB2K_MAKE_SERVICE_INTERFACE(search_filter_v3, search_filter_v2) +}; + +//! \since 2.0 +class search_filter_v4 : public search_filter_v3 { +public: + enum { + flag_sort = 1 << 0, + }; + virtual void test_v4(metadb_handle_list_cref items, metadb_io_callback_v2_data* dataIfAvail, bool* out, abort_callback& abort) = 0; + + virtual fb2k::arrayRef /* of metadb_handle */ search_v4(metadb_handle_list_cref lst, uint32_t flags, metadb_io_callback_v2_data * dataIfAvail, abort_callback& a) = 0; + + FB2K_MAKE_SERVICE_INTERFACE(search_filter_v4, search_filter_v3); +}; + +//! \since 0.9.5 +//! Entrypoint class to instantiate search_filter objects. +class search_filter_manager : public service_base { +public: + //! Creates a search_filter object. Throws an exception on failure (such as an error in the query). It's recommended that you relay the exception message to the user if this function fails. + virtual search_filter::ptr create(const char * p_query) = 0; + + //! OBSOLETE, DO NOT CALL + virtual void get_manual(pfc::string_base & p_out) = 0; + + FB2K_MAKE_SERVICE_COREAPI(search_filter_manager); +}; + +//! \since 0.9.5.3. +class search_filter_manager_v2 : public search_filter_manager { +public: + enum { + KFlagAllowSort = 1 << 0, + KFlagSuppressNotify = 1 << 1, + }; + //! Creates a search_filter object. Throws an exception on failure (such as an error in the query). It's recommended that you relay the exception message to the user if this function fails. + //! @param changeNotify A completion_notify callback object that will get called each time the query's behavior changes as a result of some external event (such as system time change). The caller must refresh query results each time this callback is triggered. The status parameter of its on_completion() parameter is unused and always set to zero. + virtual search_filter_v2::ptr create_ex(const char * query, completion_notify::ptr changeNotify, t_uint32 flags) = 0; + + //! Opens the search query syntax reference document, typically an external HTML in user's default web browser. + virtual void show_manual() = 0; + + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(search_filter_manager_v2, search_filter_manager); +}; + +//! \since 2.0 +class search_filter_manager_v3 : public search_filter_manager_v2 { + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(search_filter_manager_v3, search_filter_manager_v2); +public: + enum combine_t { + combine_and, + combine_or + }; + //! Combine multiple search filters into one, using the specified logical operation. \n + //! This method INVALIDATES passed objects. Do not try to use them afterwards. + virtual search_filter_v4::ptr combine(pfc::list_base_const_t const & arg, combine_t how, completion_notify::ptr changeNotify, t_uint32 flags) = 0; +}; + +//! \since 2.0 +class search_index : public service_base { + FB2K_MAKE_SERVICE_INTERFACE(search_index, service_base) +public: + enum { + flag_sort = 1 << 0, + }; + + //! Searches Tracks in this index for tracks matching criteria. + //! @returns list of metadb_handles. Safe to use arr->as_list_of() to get a pfc::list_base_const_t + //! @param subset Optional: pass subset of tracks in this index to search - whole index is searched if nullptr is passed. + //! @param flags Optional: set flag_sort to sort output + //! Thread safety: call from any thread. + virtual fb2k::arrayRef search(search_filter::ptr pattern, metadb_handle_list_cptr subset, uint32_t flags, abort_callback& abort) = 0; + //! Performs hit test on a group of tracks that are a subset of tracks in this index. \n + //! Thread safety: call from any thread. + virtual void test(search_filter::ptr pattern, metadb_handle_list_cref items, bool* out, abort_callback& abort) = 0; + + //! Add tracks to a custom index. \n + //! Illegal to call on library or playlist indexes. \n + //! Thread safety: call from any thread. + virtual void add_tracks(metadb_handle_list_cref, metadb_io_callback_v2_data* dataIfAvail) = 0; + //! Remove tracks from a custom index. \n + //! Illegal to call on library or playlist indexes. \n + //! Thread safety: call from any thread. + virtual void remove_tracks(metadb_handle_list_cref) = 0; +}; + +//! \since 2.0 +class search_index_manager : public service_base { + FB2K_MAKE_SERVICE_COREAPI(search_index_manager); +public: + //! Create a custom index on any data set. \n + //! OK to call from any thread. + virtual search_index::ptr create_index(metadb_handle_list_cref items, metadb_io_callback_v2_data* dataIfAvail) = 0; + + //! Create a search index referencing a playlist. \n + //! Specify null GUID to follow active playlist (typical playlist search). \n + //! Call from main thread to obtain index, then can use obtained object from any thread. + virtual search_index::ptr create_playlist_index(const GUID& playlistID = pfc::guid_null) = 0; + + //! Returns a shared object indexing user's media library. \n + //! Call from main thread to obtain index, then can use obtained object from any thread. + virtual search_index::ptr get_library_index() = 0; +}; \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/service.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/service.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,68 @@ +#include "foobar2000-sdk-pch.h" +#include "component.h" + +foobar2000_api * g_foobar2000_api = NULL; + +service_class_ref service_factory_base::enum_find_class(const GUID & p_guid) +{ + PFC_ASSERT(core_api::are_services_available() && g_foobar2000_api); + return g_foobar2000_api->service_enum_find_class(p_guid); +} + +bool service_factory_base::enum_create(service_ptr_t & p_out,service_class_ref p_class,t_size p_index) +{ + PFC_ASSERT(core_api::are_services_available() && g_foobar2000_api); + return g_foobar2000_api->service_enum_create(p_out,p_class,p_index); +} + +t_size service_factory_base::enum_get_count(service_class_ref p_class) +{ + PFC_ASSERT(core_api::are_services_available() && g_foobar2000_api); + return g_foobar2000_api->service_enum_get_count(p_class); +} + +service_factory_base * service_factory_base::__internal__list = NULL; + + +namespace service_impl_helper { + void release_object_delayed(service_base * ptr) { + ptr->service_add_ref(); + fb2k::inMainThread( [ptr] { + try { ptr->service_release(); } catch(...) {} + } ); + } +}; + + +void _standard_api_create_internal(service_ptr & out, const GUID & classID) { + service_class_ref c = service_factory_base::enum_find_class(classID); + switch(service_factory_base::enum_get_count(c)) { + case 0: +#if PFC_DEBUG + if ( core_api::are_services_available() ) { + FB2K_DebugLog() << "Service not found of type: " << pfc::print_guid(classID); + } +#endif + throw exception_service_not_found(); + case 1: + PFC_ASSERT_SUCCESS( service_factory_base::enum_create(out, c, 0) ); + break; + default: + throw exception_service_duplicated(); + } +} + +bool _standard_api_try_get_internal(service_ptr & out, const GUID & classID) { + service_class_ref c = service_factory_base::enum_find_class(classID); + switch (service_factory_base::enum_get_count(c)) { + case 1: + PFC_ASSERT_SUCCESS(service_factory_base::enum_create(out, c, 0)); + return true; + default: + return false; + } +} + +void _standard_api_get_internal(service_ptr & out, const GUID & classID) { + if (!_standard_api_try_get_internal(out, classID) ) uBugCheck(); +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/service.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/service.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,854 @@ +#pragma once + +#include // std::forward + +typedef const void* service_class_ref; + +PFC_DECLARE_EXCEPTION(exception_service_not_found,pfc::exception,"Service not found"); +PFC_DECLARE_EXCEPTION(exception_service_extension_not_found,pfc::exception,"Service extension not found"); +PFC_DECLARE_EXCEPTION(exception_service_duplicated,pfc::exception,"Service duplicated"); + +#ifdef _MSC_VER +#define FOOGUIDDECL __declspec(selectany) +#else +#define FOOGUIDDECL +#endif + + +#define DECLARE_GUID(NAME,A,S,D,F,G,H,J,K,L,Z,X) FOOGUIDDECL const GUID NAME = {A,S,D,{F,G,H,J,K,L,Z,X}}; +#define DECLARE_CLASS_GUID(NAME,A,S,D,F,G,H,J,K,L,Z,X) FOOGUIDDECL const GUID NAME::class_guid = {A,S,D,{F,G,H,J,K,L,Z,X}}; + +//Must be templated instead of taking service_base* because of multiple inheritance issues. +template static void service_release_safe(T * p_ptr) throw() { + if (p_ptr != NULL) PFC_ASSERT_NO_EXCEPTION( p_ptr->service_release() ); +} + +//Must be templated instead of taking service_base* because of multiple inheritance issues. +template static void service_add_ref_safe(T * p_ptr) throw() { + if (p_ptr != NULL) PFC_ASSERT_NO_EXCEPTION( p_ptr->service_add_ref() ); +} + +class service_base; + +template +class service_ptr_base_t { + typedef service_ptr_base_t self_t; +public: + inline T* get_ptr() const throw() {return m_ptr;} + typedef T obj_t; + + + inline bool operator==(const self_t & other) const noexcept {return this->m_ptr == other.m_ptr;} + inline bool operator!=(const self_t & other) const noexcept {return this->m_ptr != other.m_ptr;} + + inline bool operator>(const self_t & other) const noexcept {return this->m_ptr > other.m_ptr;} + inline bool operator<(const self_t & other) const noexcept {return this->m_ptr < other.m_ptr;} + + inline bool operator==(T * other) const noexcept {return this->m_ptr == other;} + inline bool operator!=(T * other) const noexcept {return this->m_ptr != other;} + + inline bool operator>(T * other) const noexcept {return this->m_ptr > other;} + inline bool operator<(T * other) const noexcept {return this->m_ptr < other;} + +protected: + T * m_ptr; +}; + +// forward declaration +template class service_nnptr_t; + +template struct forced_cast_t { + T* ptr; +}; + +//! Autopointer class to be used with all services. Manages reference counter calls behind-the-scenes. +template +class service_ptr_t : public service_ptr_base_t { +private: + typedef service_ptr_t t_self; + + template void _init(t_source * in) throw() { + this->m_ptr = in; + if (this->m_ptr) this->m_ptr->service_add_ref(); + } + template void _init(t_source && in) throw() { + this->m_ptr = in.detach(); + } +public: + service_ptr_t() throw() {this->m_ptr = NULL;} + service_ptr_t(T * p_ptr) throw() {_init(p_ptr);} + service_ptr_t(const t_self & p_source) throw() {_init(p_source.get_ptr());} + service_ptr_t(t_self && p_source) throw() {_init(std::move(p_source));} + template service_ptr_t(t_source * p_ptr) throw() {_init(p_ptr);} + template service_ptr_t(const service_ptr_base_t & p_source) throw() {_init(p_source.get_ptr());} + template service_ptr_t(const service_nnptr_t & p_source) throw() { this->m_ptr = p_source.get_ptr(); this->m_ptr->service_add_ref(); } + template service_ptr_t(service_ptr_t && p_source) throw() { _init(std::move(p_source)); } + + ~service_ptr_t() throw() {service_release_safe(this->m_ptr);} + + template + void copy(t_source * p_ptr) throw() { + service_add_ref_safe(p_ptr); + service_release_safe(this->m_ptr); + this->m_ptr = pfc::safe_ptr_cast(p_ptr); + } + + template + void copy(const service_ptr_base_t & p_source) throw() {copy(p_source.get_ptr());} + + template + void copy(service_ptr_t && p_source) throw() {attach(p_source.detach());} + + + inline const t_self & operator=(const t_self & p_source) throw() {copy(p_source); return *this;} + inline const t_self & operator=(t_self && p_source) throw() {copy(std::move(p_source)); return *this;} + inline const t_self & operator=(T * p_ptr) throw() {copy(p_ptr); return *this;} + + template inline t_self & operator=(const service_ptr_base_t & p_source) throw() {copy(p_source); return *this;} + template inline t_self & operator=(service_ptr_t && p_source) throw() {copy(std::move(p_source)); return *this;} + template inline t_self & operator=(t_source * p_ptr) throw() {copy(p_ptr); return *this;} + + template inline t_self & operator=(const service_nnptr_t & p_ptr) throw() { + service_release_safe(this->m_ptr); + t_source * ptr = p_ptr.get_ptr(); + ptr->service_add_ref(); + this->m_ptr = ptr; + return *this; + } + + inline void reset() throw() { release(); } + + inline void release() throw() { + service_release_safe(this->m_ptr); + this->m_ptr = NULL; + } + + + inline T* operator->() const throw() { +#if PFC_DEBUG + if (this->m_ptr == NULL) { + FB2K_DebugLog() << "service_ptr operator-> on a null pointer, type: " << T::debugServiceName(); + uBugCheck(); + } +#endif + return this->m_ptr; + } + + inline T* get_ptr() const throw() {return this->m_ptr;} + + inline bool is_valid() const throw() {return this->m_ptr != NULL;} + inline bool is_empty() const throw() {return this->m_ptr == NULL;} + + template + inline t_self & operator<<(service_ptr_t & p_source) throw() {attach(p_source.detach());return *this;} + template + inline t_self & operator>>(service_ptr_t & p_dest) throw() {p_dest.attach(detach());return *this;} + + + inline T* _duplicate_ptr() const throw() {//should not be used ! temporary ! + service_add_ref_safe(this->m_ptr); + return this->m_ptr; + } + + inline T* detach() throw() { + return pfc::replace_null_t(this->m_ptr); + } + + template + inline void attach(t_source * p_ptr) throw() { + service_release_safe(this->m_ptr); + this->m_ptr = pfc::safe_ptr_cast(p_ptr); + } + + T & operator*() const throw() {return *this->m_ptr;} + + service_ptr_t & _as_base_ptr() { + PFC_ASSERT( _as_base_ptr_check() ); + return *reinterpret_cast*>(this); + } + static bool _as_base_ptr_check() { + return static_cast((T*)NULL) == reinterpret_cast((T*)NULL); + } + + //! Forced cast operator - obtains a valid service pointer to the expected class or crashes the app if such pointer cannot be obtained. + template + void operator ^= ( otherPtr_t other ) { + if (other.is_empty()) release(); + else forcedCastFrom(other); + } + template + void operator ^= ( otherObj_t * other ) { + if (other == nullptr) release(); + else forcedCastFrom( other ); + } + + bool testForInterface(const GUID & guid) const { + if (this->m_ptr == nullptr) return false; + service_ptr_t dummy; + return this->m_ptr->service_query(dummy, guid); + } + //! Conditional cast operator - attempts to obtain a vaild service pointer to the expected class; returns true on success, false on failure. + template + bool operator &= ( otherPtr_t other ) { + if (other.is_empty()) return false; + return other->cast(*this); + } + template + bool operator &= ( otherObj_t * other ) { + if (other == nullptr) return false; + return other->cast( *this ); + } + + template + void operator=(forced_cast_t other) { + if (other.ptr == NULL) release(); + else forcedCastFrom(other.ptr); + } + + //! Alternate forcedCast syntax, for contexts where operator^= fails to compile. \n + //! Usage: target = source.forcedCast(); + forced_cast_t forcedCast() const { + forced_cast_t r = { this->m_ptr }; + return r; + } + + template + void forcedCastFrom(source_t const & other) { + if (!other->cast(*this)) { + FB2K_BugCheckEx("forced cast failure"); + } + } +}; + +//! Autopointer class to be used with all services. Manages reference counter calls behind-the-scenes. \n +//! This assumes that the pointers are valid all the time (can't point to null). Mainly intended to be used for scenarios where null pointers are not valid and relevant code should crash ASAP if somebody passes invalid pointers around. \n +//! You want to use service_ptr_t<> rather than service_nnptr_t<> most of the time. +template +class service_nnptr_t : public service_ptr_base_t { +private: + typedef service_nnptr_t t_self; + + template void _init(t_source * in) { + this->m_ptr = in; + this->m_ptr->service_add_ref(); + } + service_nnptr_t() throw() {pfc::crash();} +public: + service_nnptr_t(T * p_ptr) throw() {_init(p_ptr);} + service_nnptr_t(const t_self & p_source) throw() {_init(p_source.get_ptr());} + template service_nnptr_t(t_source * p_ptr) throw() {_init(p_ptr);} + template service_nnptr_t(const service_ptr_base_t & p_source) throw() {_init(p_source.get_ptr());} + + template service_nnptr_t(service_ptr_t && p_source) throw() {this->m_ptr = p_source.detach();} + + ~service_nnptr_t() throw() {this->m_ptr->service_release();} + + template + void copy(t_source * p_ptr) throw() { + p_ptr->service_add_ref(); + this->m_ptr->service_release(); + this->m_ptr = pfc::safe_ptr_cast(p_ptr); + } + + template + void copy(const service_ptr_base_t & p_source) throw() {copy(p_source.get_ptr());} + + + inline const t_self & operator=(const t_self & p_source) throw() {copy(p_source); return *this;} + inline const t_self & operator=(T * p_ptr) throw() {copy(p_ptr); return *this;} + + template inline t_self & operator=(const service_ptr_base_t & p_source) throw() {copy(p_source); return *this;} + template inline t_self & operator=(t_source * p_ptr) throw() {copy(p_ptr); return *this;} + template inline t_self & operator=(service_ptr_t && p_source) throw() {this->m_ptr->service_release(); this->m_ptr = p_source.detach();} + + + inline T* operator->() const throw() {PFC_ASSERT(this->m_ptr != NULL);return this->m_ptr;} + + inline T* get_ptr() const throw() {return this->m_ptr;} + + inline bool is_valid() const throw() {return true;} + inline bool is_empty() const throw() {return false;} + + inline T* _duplicate_ptr() const throw() {//should not be used ! temporary ! + service_add_ref_safe(this->m_ptr); + return this->m_ptr; + } + + T & operator*() const throw() {return *this->m_ptr;} + + service_ptr_t & _as_base_ptr() { + PFC_ASSERT( _as_base_ptr_check() ); + return *reinterpret_cast*>(this); + } + static bool _as_base_ptr_check() { + return static_cast((T*)NULL) == reinterpret_cast((T*)NULL); + } + + forced_cast_t forcedCast() const { + forced_cast_t r = { this->m_ptr }; + return r; + } +}; + +namespace pfc { + class traits_service_ptr : public traits_default { + public: + enum { realloc_safe = true, constructor_may_fail = false}; + }; + + template class traits_t > : public traits_service_ptr {}; + template class traits_t > : public traits_service_ptr {}; +} + + +//! For internal use, see FB2K_MAKE_SERVICE_INTERFACE +#define FB2K_MAKE_SERVICE_INTERFACE_EX(THISCLASS,PARENTCLASS,IS_CORE_API) \ + public: \ + typedef THISCLASS t_interface; \ + typedef PARENTCLASS t_interface_parent; \ + \ + static const GUID class_guid; \ + \ + typedef service_ptr_t ptr; \ + typedef service_nnptr_t nnptr; \ + typedef ptr ref; \ + typedef nnptr nnref; \ + static const char * debugServiceName() { return #THISCLASS; } \ + enum { _is_core_api = IS_CORE_API }; \ + protected: \ + THISCLASS() {} \ + ~THISCLASS() {} \ + private: \ + const THISCLASS & operator=(const THISCLASS &) = delete; \ + THISCLASS(const THISCLASS &) = delete; \ + private: \ + void _private_service_declaration_selftest() { \ + static_assert( pfc::is_same_type::value, "t_interface sanity" ); \ + static_assert( ! pfc::is_same_type::value, "parent class sanity"); \ + static_assert( pfc::is_same_type::value || IS_CORE_API == PARENTCLASS::_is_core_api, "is_core_api sanity" ); \ + _validate_service_class_helper(); /*service_base must be reachable by walking t_interface_parent*/ \ + pfc::implicit_cast(this); /*this class must derive from service_base, directly or indirectly, and be implictly castable to it*/ \ + } + +#define FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT_EX(THISCLASS, IS_CORE_API) \ + public: \ + typedef THISCLASS t_interface_entrypoint; \ + static service_enum_t enumerate() { return service_enum_t(); } \ + FB2K_MAKE_SERVICE_INTERFACE_EX(THISCLASS,service_base, IS_CORE_API) + +//! Helper macro for use when defining a service class. Generates standard features of a service, without ability to register using service_factory / enumerate using service_enum_t. \n +//! This is used for declaring services that are meant to be instantiated by means other than service_enum_t (or non-entrypoint services), or extensions of services (including extension of entrypoint services). \n +//! Sample non-entrypoint declaration: class myclass : public service_base {...; FB2K_MAKE_SERVICE_INTERFACE(myclass, service_base); }; \n +//! Sample extension declaration: class myclass : public myotherclass {...; FB2K_MAKE_SERVICE_INTERFACE(myclass, myotherclass); }; \n +//! This macro is intended for use ONLY WITH INTERFACE CLASSES, not with implementation classes. +#define FB2K_MAKE_SERVICE_INTERFACE(THISCLASS, PARENTCLASS) FB2K_MAKE_SERVICE_INTERFACE_EX(THISCLASS, PARENTCLASS, false) + +//! Helper macro for use when defining an entrypoint service class. Generates standard features of a service, including ability to register using service_factory and enumerate using service_enum. \n +//! Sample declaration: class myclass : public service_base {...; FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(myclass); }; \n +//! Note that entrypoint service classes must directly derive from service_base, and not from another service class. +//! This macro is intended for use ONLY WITH INTERFACE CLASSES, not with implementation classes. +#define FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(THISCLASS) FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT_EX(THISCLASS, false) + + +#define FB2K_MAKE_SERVICE_COREAPI(THISCLASS) \ + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT_EX( THISCLASS, true ) \ +public: \ + static ptr get() { return fb2k::std_api_get(); } \ + static bool tryGet(ptr & out) { return fb2k::std_api_try_get(out); } \ + static ptr tryGet() { ptr ret; tryGet(ret); return ret; } + +#define FB2K_MAKE_SERVICE_COREAPI_EXTENSION(THISCLASS, BASECLASS) \ + FB2K_MAKE_SERVICE_INTERFACE_EX( THISCLASS, BASECLASS, true ) \ +public: \ + static ptr get() { return fb2k::std_api_get(); } \ + static bool tryGet(ptr & out) { return fb2k::std_api_try_get(out); } \ + static ptr tryGet() { ptr ret; tryGet(ret); return ret; } + + + +//! Alternate way of declaring services, begin/end macros wrapping the whole class declaration +#define FB2K_DECLARE_SERVICE_BEGIN(THISCLASS,BASECLASS) \ + class NOVTABLE THISCLASS : public BASECLASS { \ + FB2K_MAKE_SERVICE_INTERFACE(THISCLASS,BASECLASS); \ + public: + +//! Alternate way of declaring services, begin/end macros wrapping the whole class declaration +#define FB2K_DECLARE_SERVICE_END() \ + }; + +//! Alternate way of declaring services, begin/end macros wrapping the whole class declaration +#define FB2K_DECLARE_SERVICE_ENTRYPOINT_BEGIN(THISCLASS) \ + class NOVTABLE THISCLASS : public service_base { \ + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(THISCLASS) \ + public: + +class service_base; +typedef service_ptr_t service_ptr; +typedef service_nnptr_t service_nnptr; + +//! Base class for all service classes.\n +//! Provides interfaces for reference counter and querying for different interfaces supported by the object.\n +class NOVTABLE service_base +{ +public: + //! Decrements reference count; deletes the object if reference count reaches zero. This is normally not called directly but managed by service_ptr_t<> template. \n + //! Implemented by service_impl_* classes. + //! @returns New reference count. For debug purposes only, in certain conditions return values may be unreliable. + virtual int service_release() noexcept = 0; + //! Increments reference count. This is normally not called directly but managed by service_ptr_t<> template. \n + //! Implemented by service_impl_* classes. + //! @returns New reference count. For debug purposes only, in certain conditions return values may be unreliable. + virtual int service_add_ref() noexcept = 0; + //! Queries whether the object supports specific interface and retrieves a pointer to that interface. This is normally not called directly but managed by service_query_t<> function template. \n + //! Checks the parameter against GUIDs of interfaces supported by this object, if the GUID is one of supported interfaces, p_out is set to service_base pointer that can be static_cast<>'ed to queried interface and the method returns true; otherwise the method returns false. \n + //! Implemented by service_impl_* classes. \n + //! Note that service_query() implementation semantics (but not usage semantics) changed in SDK for foobar2000 1.4; they used to be auto-implemented by each service interface (via FB2K_MAKE_SERVICE_INTERFACE macro); they're now implemented in service_impl_* instead. See SDK readme for more details. \n + virtual bool service_query(service_ptr & p_out,const GUID & p_guid) = 0; + + //! Queries whether the object supports specific interface and retrieves a pointer to that interface. + //! @param p_out Receives pointer to queried interface on success. + //! returns true on success, false on failure (interface not supported by the object). + template + bool service_query_t(service_ptr_t & p_out) + { + pfc::assert_same_type(); + return service_query( *reinterpret_cast*>(&p_out),T::class_guid); + } + //! New shortened version, same as service_query_t. + template + bool cast( outPtr_t & outPtr ) { return service_query_t( outPtr ); } + + typedef service_base t_interface; + enum { _is_core_api = false }; + + static const char * debugServiceName() {return "service_base"; } + + static bool serviceRequiresMainThreadDestructor() { return false; } + + service_base * as_service_base() { return this; } +protected: + service_base() {} + ~service_base() {} + + static bool service_query_walk(service_ptr &, const GUID &, service_base *) { + return false; + } + + template static bool service_query_walk(service_ptr & out, const GUID & guid, interface_t * in) { + if (guid == interface_t::class_guid) { + out = in; return true; + } + typename interface_t::t_interface_parent * chain = in; + return service_query_walk(out, guid, chain); + } + template static bool handle_service_query(service_ptr & out, const GUID & guid, class_t * in) { + typename class_t::t_interface * in2 = in; + return service_query_walk( out, guid, in2 ); + } +private: + service_base(const service_base&) = delete; + const service_base & operator=(const service_base&) = delete; +}; + +template +inline void _validate_service_class_helper() { + _validate_service_class_helper(); +} + +template<> +inline void _validate_service_class_helper() {} + + +#include "service_impl.h" + +class NOVTABLE service_factory_base { +protected: + inline service_factory_base(const GUID & p_guid, service_factory_base * & factoryList = __internal__list) : m_guid(p_guid) { PFC_ASSERT(!core_api::are_services_available()); __internal__next = factoryList; factoryList = this; } +public: + inline const GUID & get_class_guid() const {return m_guid;} + + static service_class_ref enum_find_class(const GUID & p_guid); + static bool enum_create(service_ptr_t & p_out,service_class_ref p_class,t_size p_index); + static t_size enum_get_count(service_class_ref p_class); + + inline static bool is_service_present(const GUID & g) {return enum_get_count(enum_find_class(g))>0;} + + //! Throws std::bad_alloc or another exception on failure. + virtual void instance_create(service_ptr_t & p_out) = 0; + + //! FOR INTERNAL USE ONLY + static service_factory_base *__internal__list; + //! FOR INTERNAL USE ONLY + service_factory_base * __internal__next; +private: + const GUID & m_guid; +}; + +template +class service_factory_traits { +public: + static service_factory_base * & factory_list() {return service_factory_base::__internal__list;} +}; + +template +class service_factory_base_t : public service_factory_base { +public: + service_factory_base_t() : service_factory_base(B::class_guid, service_factory_traits::factory_list()) { + pfc::assert_same_type(); + } +protected: + template + static void pass_instance(service_ptr& out, in_t* in) { + // in_t could be multi inherited, fix multi inheritance issues here + // caller will static cast the returned service_base* to B* later on + // make sure that what we hand over supports such + service_ptr_t< B > temp; + temp ^= in->as_service_base(); + out.attach(temp.detach()); + } +}; + +template static void _validate_service_ptr(service_ptr_t const & ptr) { + PFC_ASSERT( ptr.is_valid() ); + service_ptr_t test; + PFC_ASSERT( ptr->service_query_t(test) ); +} + +#ifdef _DEBUG +#define FB2K_ASSERT_VALID_SERVICE_PTR(ptr) _validate_service_ptr(ptr) +#else +#define FB2K_ASSERT_VALID_SERVICE_PTR(ptr) +#endif + +template static bool service_enum_create_t(service_ptr_t & p_out,t_size p_index) { + pfc::assert_same_type(); + service_ptr_t ptr; + if (service_factory_base::enum_create(ptr,service_factory_base::enum_find_class(T::class_guid),p_index)) { + p_out = static_cast(ptr.get_ptr()); + return true; + } else { + p_out.release(); + return false; + } +} + +template static service_class_ref _service_find_class() { + pfc::assert_same_type(); + return service_factory_base::enum_find_class(T::class_guid); +} + +template +static bool _service_instantiate_helper(service_ptr_t & out, service_class_ref servClass, t_size index) { + /*if (out._as_base_ptr_check()) { + const bool state = service_factory_base::enum_create(out._as_base_ptr(), servClass, index); + if (state) { FB2K_ASSERT_VALID_SERVICE_PTR(out); } + return state; + } else */{ + service_ptr temp; + const bool state = service_factory_base::enum_create(temp, servClass, index); + if (state) { + out.attach( static_cast( temp.detach() ) ); + FB2K_ASSERT_VALID_SERVICE_PTR( out ); + } + return state; + } +} + +template class service_class_helper_t { +public: + service_class_helper_t() : m_class(service_factory_base::enum_find_class(T::class_guid)) { + pfc::assert_same_type(); + } + t_size get_count() const { + return service_factory_base::enum_get_count(m_class); + } + + bool create(service_ptr_t & p_out,t_size p_index) const { + return _service_instantiate_helper(p_out, m_class, p_index); + } + + service_ptr_t create(t_size p_index) const { + service_ptr_t temp; + if (!create(temp,p_index)) uBugCheck(); + return temp; + } + service_class_ref get_class() const {return m_class;} +private: + service_class_ref m_class; +}; + +void _standard_api_create_internal(service_ptr & out, const GUID & classID); +void _standard_api_get_internal(service_ptr & out, const GUID & classID); +bool _standard_api_try_get_internal(service_ptr & out, const GUID & classID); + +template inline void standard_api_create_t(service_ptr_t & p_out) { + if constexpr (pfc::is_same_type::value) { + _standard_api_create_internal(p_out._as_base_ptr(), T::class_guid); + FB2K_ASSERT_VALID_SERVICE_PTR(p_out); + } else { + service_ptr_t temp; + standard_api_create_t(temp); + if (!temp->service_query_t(p_out)) { +#if PFC_DEBUG + FB2K_DebugLog() << "Service extension not found: " << T::debugServiceName() << " (" << pfc::print_guid(T::class_guid) << ") of base type: " << T::t_interface_entrypoint::debugServiceName() << " (" << pfc::print_guid(T::t_interface_entrypoint::class_guid) << ")"; +#endif + throw exception_service_extension_not_found(); + } + } +} + +template inline void standard_api_create_t(T* & p_out) { + p_out = NULL; + standard_api_create_t( *reinterpret_cast< service_ptr_t * >( & p_out ) ); +} + +template inline service_ptr_t standard_api_create_t() { + service_ptr_t temp; + standard_api_create_t(temp); + return temp; +} + +template +inline bool static_api_test_t() { + typedef typename T::t_interface_entrypoint EP; + service_class_helper_t helper; + if (helper.get_count() != 1) return false; + if constexpr (!pfc::is_same_type::value) { + service_ptr_t t; + if (!helper.create(0)->service_query_t(t)) return false; + } + return true; +} + +#define FB2K_API_AVAILABLE(API) static_api_test_t() + +//! Helper template used to easily access core services. \n +//! Usage: static_api_ptr_t api; api->dosomething(); \n +//! Can be used at any point of code, WITH EXCEPTION of static objects that are initialized during the DLL loading process before the service system is initialized; such as static static_api_ptr_t objects or having static_api_ptr_t instances as members of statically created objects. \n +//! Throws exception_service_not_found if service could not be reached (which can be ignored for core APIs that are always present unless there is some kind of bug in the code). \n +//! This class is provided for backwards compatibility. The recommended way to do this stuff is now someclass::get() / someclass::tryGet(). +template +class static_api_ptr_t { +private: + typedef static_api_ptr_t t_self; +public: + static_api_ptr_t() { + standard_api_create_t(m_ptr); + } + t_interface* operator->() const {return m_ptr;} + t_interface * get_ptr() const {return m_ptr;} + ~static_api_ptr_t() {m_ptr->service_release();} + + static_api_ptr_t(const t_self & in) { + m_ptr = in.m_ptr; m_ptr->service_add_ref(); + } + const t_self & operator=(const t_self & in) {return *this;} //obsolete, each instance should carry the same pointer +private: + t_interface * m_ptr; +}; + +template +class service_enum_t { + typedef service_enum_t self_t; +public: + service_enum_t() : m_index(0) { + pfc::assert_same_type(); + } + void reset() {m_index = 0;} + + template + bool first(service_ptr_t & p_out) { + reset(); + return next(p_out); + } + + template + bool next(service_ptr_t & p_out) { + pfc::assert_same_type(); + if constexpr (pfc::is_same_type::value) { + return _next(reinterpret_cast&>(p_out)); + } else { + service_ptr_t temp; + while(_next(temp)) { + if (temp->service_query_t(p_out)) return true; + } + return false; + } + } + + service_ptr_t get() const { + PFC_ASSERT(!finished()); + return m_helper.create(m_index); + } + + void operator++() { + PFC_ASSERT(!finished()); + ++m_index; + } + void operator++(int) { + PFC_ASSERT(!finished()); + ++m_index; + } + + bool finished() const { + return m_index >= m_helper.get_count(); + } + + service_ptr_t operator*() const { + return get(); + } + + // ==== modern for loop support ==== + // Instead of using service_enum_t<> / service_ptr_t<>, use: + // for( auto ptr : someclass::enumerate() ) { ... } + self_t begin() const { + self_t ret = *this; + ret.m_index = 0; + return ret; + } + self_t end() const { + self_t ret = *this; + ret.m_index = ret.m_helper.get_count(); + return ret; + } + bool operator==(self_t const& other) const {return m_index == other.m_index;} + bool operator!=(self_t const& other) const { return m_index != other.m_index; } + + +private: + bool _next(service_ptr_t & p_out) { + return m_helper.create(p_out,m_index++); + } + size_t m_index; + service_class_helper_t m_helper; +}; + +namespace fb2k { + //! Modern get-std-api helper. \n + //! Does not throw exceptions, crashes on failure. \n + //! If failure is possible, use std_api_try_get() instead and handle false return value. + template + service_ptr_t std_api_get() { + typedef typename api_t::t_interface_entrypoint entrypoint_t; + service_ptr_t ret; + if constexpr (pfc::is_same_type::value) { + _standard_api_get_internal(ret._as_base_ptr(), api_t::class_guid); + } else { + ret ^= std_api_get(); + } + return ret; + } + + //! Modern get-std-api helper. \n + //! Returns true on success (ret ptr is valid), false on failure (API not found). + template + bool std_api_try_get( service_ptr_t & ret ) { + typedef typename api_t::t_interface_entrypoint entrypoint_t; + if constexpr (pfc::is_same_type::value) { + return _standard_api_try_get_internal(ret._as_base_ptr(), api_t::class_guid); + } else { + service_ptr_t temp; + if (! std_api_try_get( temp ) ) return false; + return ret &= temp; + } + } +} + + + +template +class service_factory_t : public service_factory_base_t { +public: + void instance_create(service_ptr_t & p_out) override { + this->pass_instance(p_out, new service_impl_t); + } +}; + + +template +class service_factory_singleton_t : public service_factory_base_t { +public: + void instance_create(service_ptr_t & p_out) override { + this->pass_instance(p_out, &FB2K_SERVICE_SINGLETON(T) ); + } + + inline T& get_static_instance() { return &FB2K_SERVICE_SINGLETON(T); } + inline const T& get_static_instance() const { return &FB2K_SERVICE_SINGLETON(T); } +}; + +template +class service_factory_single_t : public service_factory_base_t { + service_impl_single_t g_instance; +public: + template service_factory_single_t(arg_t && ... arg) : g_instance(std::forward(arg) ...) {} + + void instance_create(service_ptr_t & p_out) override { + this->pass_instance(p_out, &g_instance); + } + + inline T& get_static_instance() { return g_instance; } + inline const T& get_static_instance() const { return g_instance; } +}; + +//! Alternate service_factory_single, shared instance created on first access and never deallocated. \n +//! Addresses the problem of dangling references to our object getting invoked or plainly de-refcounted during late shutdown. +template +class service_factory_single_v2_t : public service_factory_base_t { +public: + T * get() { + static T * g_instance = new service_impl_single_t; + return g_instance; + } + void instance_create(service_ptr_t & p_out) override { + this->pass_instance(p_out, get()); + } +}; + +template +class service_factory_single_ref_t : public service_factory_base_t +{ +private: + T & instance; +public: + service_factory_single_ref_t(T& param) : instance(param) {} + + void instance_create(service_ptr_t & p_out) override { + this->pass_instance(p_out, &instance); + } + + inline T& get_static_instance() { return instance; } +}; + +template +class service_factory_single_transparent_t : public service_factory_base_t, public service_impl_single_t +{ +public: + template service_factory_single_transparent_t(arg_t && ... arg) : service_impl_single_t( std::forward(arg) ...) {} + + void instance_create(service_ptr_t & p_out) override { + this->pass_instance(p_out, pfc::implicit_cast(this)); + } + + inline T& get_static_instance() {return *(T*)this;} + inline const T& get_static_instance() const {return *(const T*)this;} +}; + + +#ifdef _MSC_VER +#define FB2K_SERVICE_FACTORY_ATTR +#else +#define FB2K_SERVICE_FACTORY_ATTR __attribute__ (( __used__ )) +#endif + +#define _FB2K_CONCAT(a, b) _FB2K_CONCAT_INNER(a, b) +#define _FB2K_CONCAT_INNER(a, b) a ## b + +#define _FB2K_UNIQUE_NAME(base) _FB2K_CONCAT(base, __COUNTER__) + +#define FB2K_SERVICE_FACTORY( TYPE ) static ::service_factory_singleton_t< TYPE > _FB2K_UNIQUE_NAME(g_factory_) FB2K_SERVICE_FACTORY_ATTR; +#define FB2K_SERVICE_FACTORY_LATEINIT( TYPE ) static ::service_factory_single_v2_t< TYPE > _FB2K_UNIQUE_NAME(g_factory_) FB2K_SERVICE_FACTORY_ATTR; +#define FB2K_SERVICE_FACTORY_PARAMS( TYPE, ... ) static ::service_factory_single_t< TYPE > _FB2K_UNIQUE_NAME(g_factory_) ( __VA_ARGS__ ); +#define FB2K_SERVICE_FACTORY_DYNAMIC( TYPE ) static ::service_factory_t< TYPE > _FB2K_UNIQUE_NAME(g_factory_) FB2K_SERVICE_FACTORY_ATTR; + + +#define FB2K_FOR_EACH_SERVICE(type, call) for( auto obj : type::enumerate() ) { obj->call; } diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/service_by_guid.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/service_by_guid.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,100 @@ +#pragma once +#include + + + +template +static bool service_by_guid_fallback(service_ptr_t & out, const GUID & id) { + for (auto ptr : what::enumerate()) { + if (ptr->get_guid() == id) { out = ptr; return true; } + } + return false; +} + +template +class service_by_guid_data { +public: + service_by_guid_data() : m_inited(), m_servClass() {} + + bool ready() const {return m_inited;} + + // Caller must ensure initialize call before create() as well as thread safety of initialize() calls. The rest of this class is thread safe (only reads member data). + void initialize() { + if (m_inited) return; + pfc::assert_same_type< what, typename what::t_interface_entrypoint >(); + m_servClass = service_factory_base::enum_find_class(what::class_guid); + const t_size servCount = service_factory_base::enum_get_count(m_servClass); + for(t_size walk = 0; walk < servCount; ++walk) { + service_ptr_t temp; + if (_service_instantiate_helper(temp, m_servClass, walk)) { + m_order.set(temp->get_guid(), walk); + } + } + m_inited = true; + } + + bool create(service_ptr_t & out, const GUID & theID) const { + PFC_ASSERT(m_inited); + t_size index; + if (!m_order.query(theID,index)) return false; + return _service_instantiate_helper(out, m_servClass, index); + } + service_ptr_t create(const GUID & theID) const { + service_ptr_t temp; if (!crete(temp,theID)) throw exception_service_not_found(); return temp; + } + +private: + volatile bool m_inited; + pfc::map_t m_order; + service_class_ref m_servClass; +}; + +template +class _service_by_guid_data_container { +public: + static service_by_guid_data data; +}; +template service_by_guid_data _service_by_guid_data_container::data; + + +template +static void service_by_guid_init() { + service_by_guid_data & data = _service_by_guid_data_container::data; + data.initialize(); +} +template +static bool service_by_guid(service_ptr_t & out, const GUID & theID) { + pfc::assert_same_type< what, typename what::t_interface_entrypoint >(); + service_by_guid_data & data = _service_by_guid_data_container::data; + if (data.ready()) { + //fall-thru + } else if (core_api::is_main_thread()) { + data.initialize(); + } else { +#if PFC_DEBUG + FB2K_DebugLog() << "Warning: service_by_guid() used in non-main thread without initialization, using fallback"; +#endif + return service_by_guid_fallback(out,theID); + } + return data.create(out,theID); +} +template +static service_ptr_t service_by_guid(const GUID & theID) { + service_ptr_t temp; + if (!service_by_guid(temp, theID)) { +#if PFC_DEBUG + FB2K_DebugLog() << "service_by_guid failure: " << what::debugServiceName() << " : " << pfc::print_guid( theID ); +#endif + throw exception_service_not_found(); + } + return temp; +} + + + + +class comparator_service_guid { +public: + template static int compare(const what & v1, const what & v2) { return pfc::compare_t(v1->get_guid(), v2->get_guid()); } +}; + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/service_compat.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/service_compat.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,38 @@ +#pragma once + +// Obsolete features + +//! Special hack to ensure errors when someone tries to ->service_add_ref()/->service_release() on a service_ptr_t +template class service_obscure_refcounting : public T { +private: + int service_add_ref() throw(); + int service_release() throw(); +}; + +//! Converts a service interface pointer to a pointer that obscures service counter functionality. +template static inline service_obscure_refcounting* service_obscure_refcounting_cast(T * p_source) throw() {return static_cast*>(p_source);} + +template class t_alloc = pfc::alloc_fast> +class service_list_t : public pfc::list_t, t_alloc > +{ +}; + +//! Helper; simulates array with instance of each available implementation of given service class. +template class service_instance_array_t { +public: + typedef service_ptr_t t_ptr; + service_instance_array_t() { + service_class_helper_t helper; + const t_size count = helper.get_count(); + m_data.set_size(count); + for(t_size n=0;n m_data; +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/service_impl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/service_impl.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,140 @@ +#pragma once + +// service_impl.h +// This header provides functionality for spawning your own service objects. +// Various service_impl_* classes implement service_base methods (reference counting, query for interface) on top of your class. +// service_impl_* are top level ("sealed" in C# terms) classes; they derive from your classes but you should never derive from them. + +#include + +namespace service_impl_helper { + //! Helper function to defer destruction of a service object. \n + //! Enqueues a main_thread_callback to release the object at a later time, escaping the current scope. \n + //! Important: this takes a raw service_base* - not an autoptr - to ensure that the last reference can be released in main thread. \n + void release_object_delayed(service_base* obj); +}; + +//! Multi inheritance helper. \n +//! Please note that use of multi inheritance is not recommended. Most components will never need this. \n +//! This class handles multi inherited service_query() for you. \n +//! Usage: class myclass : public service_multi_inherit {...}; \n +//! It's also legal to chain it: service_multi_inherit > and so on. +template +class service_multi_inherit : public class1_t, public class2_t { + typedef service_multi_inherit self_t; + + template + inline static bool service_query_this(service_ptr& out, const GUID& guid, service_multi_inherit* in) { + return service_multi_inherit::handle_service_query(out, guid, in); + } + + template + inline static bool service_query_this(service_ptr& out, const GUID& guid, class_t* in) { + return service_base::handle_service_query(out, guid, in); + } +public: + + // template + + + static bool handle_service_query(service_ptr & out, const GUID & guid, self_t * in) { + return service_query_this(out, guid, (class1_t*) in) || service_query_this(out, guid, (class2_t*) in); + } + + service_base * as_service_base() { return class1_t::as_service_base(); } + static const char * debugServiceName() { return "multi inherited service"; } + + // Obscure service_base methods from both so calling myclass->service_query() works like it should + virtual int service_release() throw() = 0; + virtual int service_add_ref() throw() = 0; + virtual bool service_query(service_ptr & p_out, const GUID & p_guid) = 0; + + static bool serviceRequiresMainThreadDestructor() { + return class1_t::serviceRequiresMainThreadDestructor() || class2_t::serviceRequiresMainThreadDestructor(); + } +}; + +//! Template implementing service_query walking the inheritance chain. \n +//! Do not use directly. Each service_impl_* template utilizes it implicitly. +template class implement_service_query : public class_t +{ + typedef class_t base_t; +public: + template implement_service_query( arg_t && ... arg ) : base_t( std::forward(arg) ... ) {} + + bool service_query(service_ptr_t & p_out, const GUID & p_guid) override { + return this->handle_service_query( p_out, p_guid, this ); + } +}; + +//! Template implementing reference-counting features of service_base. Intended for dynamic instantiation: "new service_impl_t(param1,param2);"; should not be instantiated otherwise (no local/static/member objects) because it does a "delete this;" when reference count reaches zero. \n +//! Note that there's no more need to use this direclty, see fb2k::service_new<>(). +template +class service_impl_t : public implement_service_query +{ + typedef implement_service_query base_t; +public: + int service_release() throw() { + int ret = (int) --m_counter; + if (ret == 0) { + if (!this->serviceRequiresMainThreadDestructor() || core_api::is_main_thread()) { + PFC_ASSERT_NO_EXCEPTION( delete this ); + } else { + // Pass to release_object_delayed() with zero ref count - a temporary single reference will be created there + service_impl_helper::release_object_delayed(this->as_service_base()); + } + } + return ret; + } + int service_add_ref() throw() {return (int) ++m_counter;} + + template service_impl_t( arg_t && ... arg ) : base_t( std::forward(arg) ... ) {} +private: + pfc::refcounter m_counter; +}; + +//! Alternate version of service_impl_t<> - calls this->service_shutdown() instead of delete this. \n +//! For special cases where selfdestruct on zero refcount is undesired. +template +class service_impl_explicitshutdown_t : public implement_service_query +{ + typedef implement_service_query base_t; +public: + int service_release() throw() { + int ret = --m_counter; + if (ret == 0) { + this->service_shutdown(); + } else { + return ret; + } + } + int service_add_ref() throw() {return ++m_counter;} + + template service_impl_explicitshutdown_t(arg_t && ... arg) : base_t(std::forward(arg) ...) {} +private: + pfc::refcounter m_counter; +}; + +//! Template implementing dummy version of reference-counting features of service_base. Intended for static/local/member instantiation: "static service_impl_single_t myvar(params);". Because reference counting features are disabled (dummy reference counter), code instantiating it is responsible for deleting it as well as ensuring that no references are active when the object gets deleted.\n +template +class service_impl_single_t : public implement_service_query +{ + typedef implement_service_query base_t; +public: + int service_release() throw() {return 1;} + int service_add_ref() throw() {return 1;} + + template service_impl_single_t(arg_t && ... arg) : base_t(std::forward(arg) ...) {} +}; + +namespace fb2k { + //! The new recommended way of spawning service objects, automatically implementing reference counting and service_query on top of your class. \n + //! Usage: auto myObj = fb2k::service_new(args); \n + //! Returned type is a service_ptr_t + template + service_ptr_t service_new(arg_t && ... arg) { + return new service_impl_t< obj_t > ( std::forward (arg) ... ); + } +} + +#define FB2K_SERVICE_SINGLETON(class_t) PFC_SINGLETON( service_impl_single_t< class_t> ) \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/shortcut_actions.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/shortcut_actions.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,1 @@ +#error DEPRECATED diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/stdafx.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/stdafx.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,2 @@ +//cpp used to generate precompiled header +#include "foobar2000-sdk-pch.h" \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/system_time_keeper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/system_time_keeper.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,50 @@ +#pragma once + +namespace system_time_periods { + static constexpr t_filetimestamp second = filetimestamp_1second_increment; + static constexpr t_filetimestamp minute = second * 60; + static constexpr t_filetimestamp hour = minute * 60; + static constexpr t_filetimestamp day = hour * 24; + static constexpr t_filetimestamp week = day * 7; +}; +class system_time_callback { +public: + virtual void on_time_changed(t_filetimestamp newVal) = 0; +}; +//! \since 0.9.6 +class system_time_keeper : public service_base { +public: + //! The callback object receives an on_changed() call with the current time inside the register_callback() call. + virtual void register_callback(system_time_callback * callback, t_filetimestamp resolution) = 0; + + virtual void unregister_callback(system_time_callback * callback) = 0; + + FB2K_MAKE_SERVICE_COREAPI(system_time_keeper) +}; + +class system_time_callback_impl : public system_time_callback { +public: + system_time_callback_impl() {} + ~system_time_callback_impl() {stop_timer();} + + void stop_timer() { + if (m_registered) { + system_time_keeper::get()->unregister_callback(this); + m_registered = false; + } + } + //! You get a on_changed() call inside the initialize_timer() call. + void initialize_timer(t_filetimestamp period) { + stop_timer(); + system_time_keeper::get()->register_callback(this, period); + m_registered = true; + } + + //! Override me + void on_time_changed(t_filetimestamp) override {} + + PFC_CLASS_NOT_COPYABLE_EX(system_time_callback_impl) +private: + bool m_registered = false; +}; + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/tag_processor.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/tag_processor.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,198 @@ +#include "foobar2000-sdk-pch.h" +#include "file_info_impl.h" +#include "tag_processor.h" + +void tag_processor_trailing::write_id3v1(const service_ptr_t & p_file,const file_info & p_info,abort_callback & p_abort) +{ + write(p_file,p_info,flag_id3v1,p_abort); +} + +void tag_processor_trailing::write_apev2(const service_ptr_t & p_file,const file_info & p_info,abort_callback & p_abort) +{ + write(p_file,p_info,flag_apev2,p_abort); +} + +void tag_processor_trailing::write_apev2_id3v1(const service_ptr_t & p_file,const file_info & p_info,abort_callback & p_abort) +{ + write(p_file,p_info,flag_id3v1|flag_apev2,p_abort); +} + + +t_filesize tag_processor_trailing::read_v2_(const file::ptr & file, file_info& outInfo, abort_callback& abort) { + { + tag_processor_trailing_v2::ptr v2; + if (v2 &= this) return v2->read_v2(file, outInfo, abort); + } + // no new API, emulate with old + try { + t_filesize ret = filesize_invalid; + this->read_ex(file, outInfo, ret, abort); + PFC_ASSERT(ret != filesize_invalid); + return ret; + } catch (exception_io_data const&) { + return filesize_invalid; + } +} + + +enum { + g_flag_id3v1 = 1<<0, + g_flag_id3v2 = 1<<1, + g_flag_apev2 = 1<<2 +}; + + +static void g_write_tags_ex(tag_write_callback & p_callback,unsigned p_flags,const service_ptr_t & p_file,const file_info * p_info,abort_callback & p_abort) { + PFC_ASSERT( p_flags == 0 || p_info != 0 ); + + + if (p_flags & (g_flag_id3v1 | g_flag_apev2)) { + switch(p_flags & (g_flag_id3v1 | g_flag_apev2)) { + case g_flag_id3v1 | g_flag_apev2: + tag_processor_trailing::get()->write_apev2_id3v1(p_file,*p_info,p_abort); + break; + case g_flag_id3v1: + tag_processor_trailing::get()->write_id3v1(p_file,*p_info,p_abort); + break; + case g_flag_apev2: + tag_processor_trailing::get()->write_apev2(p_file,*p_info,p_abort); + break; + default: + throw exception_io_data(); + } + } else { + tag_processor_trailing::get()->remove(p_file,p_abort); + } + + if (p_flags & g_flag_id3v2) + { + tag_processor_id3v2::get()->write_ex(p_callback,p_file,*p_info,p_abort); + } + else + { + t_uint64 dummy; + tag_processor_id3v2::g_remove_ex(p_callback,p_file,dummy,p_abort); + } +} + +static void g_write_tags(unsigned p_flags,const service_ptr_t & p_file,const file_info * p_info,abort_callback & p_abort) { + tag_write_callback_dummy cb; + g_write_tags_ex(cb,p_flags,p_file,p_info,p_abort); +} + + +void tag_processor::write_multi(const service_ptr_t & p_file,const file_info & p_info,abort_callback & p_abort,bool p_write_id3v1,bool p_write_id3v2,bool p_write_apev2) { + unsigned flags = 0; + if (p_write_id3v1) flags |= g_flag_id3v1; + if (p_write_id3v2) flags |= g_flag_id3v2; + if (p_write_apev2) flags |= g_flag_apev2; + g_write_tags(flags,p_file,&p_info,p_abort); +} + +void tag_processor::write_multi_ex(tag_write_callback & p_callback,const service_ptr_t & p_file,const file_info & p_info,abort_callback & p_abort,bool p_write_id3v1,bool p_write_id3v2,bool p_write_apev2) { + unsigned flags = 0; + if (p_write_id3v1) flags |= g_flag_id3v1; + if (p_write_id3v2) flags |= g_flag_id3v2; + if (p_write_apev2) flags |= g_flag_apev2; + g_write_tags_ex(p_callback,flags,p_file,&p_info,p_abort); +} + +void tag_processor::write_id3v1(const service_ptr_t & p_file,const file_info & p_info,abort_callback & p_abort) { + g_write_tags(g_flag_id3v1,p_file,&p_info,p_abort); +} + +void tag_processor::write_apev2(const service_ptr_t & p_file,const file_info & p_info,abort_callback & p_abort) { + g_write_tags(g_flag_apev2,p_file,&p_info,p_abort); +} + +void tag_processor::write_apev2_id3v1(const service_ptr_t & p_file,const file_info & p_info,abort_callback & p_abort) { + g_write_tags(g_flag_apev2|g_flag_id3v1,p_file,&p_info,p_abort); +} + +void tag_processor::write_id3v2(const service_ptr_t & p_file,const file_info & p_info,abort_callback & p_abort) { + g_write_tags(g_flag_id3v2,p_file,&p_info,p_abort); +} + +void tag_processor::write_id3v2_id3v1(const service_ptr_t & p_file,const file_info & p_info,abort_callback & p_abort) { + g_write_tags(g_flag_id3v2|g_flag_id3v1,p_file,&p_info,p_abort); +} + +void tag_processor::remove_trailing(const service_ptr_t & p_file,abort_callback & p_abort) { + return tag_processor_trailing::get()->remove(p_file,p_abort); +} + +bool tag_processor::remove_id3v2(const service_ptr_t & p_file,abort_callback & p_abort) { + t_uint64 dummy = 0; + tag_processor_id3v2::g_remove(p_file,dummy,p_abort); + return dummy > 0; +} + +void tag_processor::remove_id3v2_trailing(const service_ptr_t & p_file,abort_callback & p_abort) { + remove_id3v2(p_file,p_abort); + remove_trailing(p_file,p_abort); +} + +void tag_processor::read_trailing(const service_ptr_t & p_file,file_info & p_info,abort_callback & p_abort) { + tag_processor_trailing::get()->read(p_file,p_info,p_abort); +} + +void tag_processor::read_trailing_ex(const service_ptr_t & p_file,file_info & p_info,t_filesize & p_tagoffset,abort_callback & p_abort) { + tag_processor_trailing::get()->read_ex(p_file,p_info,p_tagoffset,p_abort); +} + +t_filesize tag_processor::read_trailing_nothrow(const service_ptr_t& p_file, file_info& p_info, abort_callback& p_abort) { + return tag_processor_trailing::get()->read_v2_(p_file, p_info, p_abort); +} + +void tag_processor::read_id3v2(const service_ptr_t & p_file,file_info & p_info,abort_callback & p_abort) { + tag_processor_id3v2::get()->read(p_file,p_info,p_abort); +} + +void tag_processor::read_id3v2_trailing(const service_ptr_t& p_file, file_info& p_info, abort_callback& p_abort) { + if (!read_id3v2_trailing_nothrow(p_file, p_info, p_abort)) throw exception_tag_not_found(); +} + +bool tag_processor::read_id3v2_trailing_nothrow(const service_ptr_t & p_file,file_info & p_info,abort_callback & p_abort) +{ + file_info_impl id3v2, trailing; + + const bool have_id3v2 = tag_processor_id3v2::get()->read_v2_(p_file, id3v2, p_abort); + const bool have_id3v2_text = have_id3v2 && id3v2.meta_get_count() > 0; + + bool have_trailing = false; + if (!have_id3v2_text || !p_file->is_remote()) { + have_trailing = tag_processor_trailing::get()->read_v2_(p_file, trailing, p_abort) != filesize_invalid; + } + + if (!have_id3v2 && !have_trailing) return false; + + if (have_id3v2) { + p_info._set_tag(id3v2); + if (have_trailing) p_info._add_tag(trailing); + if (! have_id3v2_text ) p_info.copy_meta(trailing); + } else { + p_info._set_tag(trailing); + } + + return true; +} + +void tag_processor::skip_id3v2(const service_ptr_t & p_file,t_filesize & p_size_skipped,abort_callback & p_abort) { + tag_processor_id3v2::g_skip(p_file,p_size_skipped,p_abort); +} + +t_filesize tag_processor::skip_id3v2(file::ptr const & f, abort_callback & a) { + t_filesize ret = 0; + skip_id3v2(f, ret, a); + return ret; +} + +bool tag_processor::is_id3v1_sufficient(const file_info & p_info) +{ + return tag_processor_trailing::get()->is_id3v1_sufficient(p_info); +} + +void tag_processor::truncate_to_id3v1(file_info & p_info) +{ + tag_processor_trailing::get()->truncate_to_id3v1(p_info); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/tag_processor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/tag_processor.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,129 @@ +#pragma once + +PFC_DECLARE_EXCEPTION(exception_tag_not_found,exception_io_data,"Tag not found"); + +//! Callback interface for write-tags-to-temp-file-and-swap scheme, used for ID3v2 tag updates and such where entire file needs to be rewritten. +//! As a speed optimization, file content can be copied to a temporary file in the same directory as the file being updated, and then source file can be swapped for the newly created file with updated tags. +//! This also gives better security against data loss on crash compared to rewriting the file in place and using memory or generic temporary file APIs to store content being rewritten. +class NOVTABLE tag_write_callback { +public: + //! Called only once per operation (or not called at all when operation being performed can be done in-place). + //! Requests a temporary file to be created in the same directory + virtual bool open_temp_file(service_ptr_t & p_out,abort_callback & p_abort) = 0; +protected: + tag_write_callback() {} + ~tag_write_callback() {} +private: + tag_write_callback(const tag_write_callback &) = delete; + void operator=(const tag_write_callback &) = delete; +}; + +class tag_write_callback_dummy : public tag_write_callback { +public: + bool open_temp_file(service_ptr_t& p_out, abort_callback& p_abort) override { (void)p_out; (void)p_abort; return false; } +}; + +//! For internal use - call tag_processor namespace methods instead. +class NOVTABLE tag_processor_id3v2 : public service_base +{ +public: + virtual void read(const service_ptr_t & p_file,file_info & p_info,abort_callback & p_abort) = 0; + virtual void write(const service_ptr_t & p_file,const file_info & p_info,abort_callback & p_abort) = 0; + virtual void write_ex(tag_write_callback & p_callback,const service_ptr_t & p_file,const file_info & p_info,abort_callback & p_abort) = 0; + + static bool g_get(service_ptr_t & p_out); + static void g_skip(const service_ptr_t & p_file,t_filesize & p_size_skipped,abort_callback & p_abort); + static void g_skip_at(const service_ptr_t & p_file,t_filesize p_base, t_filesize & p_size_skipped,abort_callback & p_abort); + static t_size g_multiskip(const service_ptr_t & p_file,t_filesize & p_size_skipped,abort_callback & p_abort); + static void g_remove(const service_ptr_t & p_file,t_filesize & p_size_removed,abort_callback & p_abort); + static void g_remove_ex(tag_write_callback & p_callback,const service_ptr_t & p_file,t_filesize & p_size_removed,abort_callback & p_abort); + static uint32_t g_tagsize(const void* pHeader10bytes); + + bool read_v2_(file::ptr const& file, file_info& outInfo, abort_callback& abort); + + FB2K_MAKE_SERVICE_COREAPI(tag_processor_id3v2); +}; + +//! \since 2.2 +class NOVTABLE tag_processor_id3v2_v2 : public tag_processor_id3v2 { + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(tag_processor_id3v2_v2, tag_processor_id3v2); +public: + //! Returns bool (valid tag found or not) instead of throwing exception_tag_not_found. + virtual bool read_v2(file::ptr const& file, file_info& outInfo, abort_callback& abort) = 0; +}; + +//! For internal use - call tag_processor namespace methods instead. +class NOVTABLE tag_processor_trailing : public service_base +{ +public: + enum { + flag_apev2 = 1, + flag_id3v1 = 2, + }; + + virtual void read(const service_ptr_t & p_file,file_info & p_info,abort_callback & p_abort) = 0; + virtual void write(const service_ptr_t & p_file,const file_info & p_info,unsigned p_flags,abort_callback & p_abort) = 0; + virtual void remove(const service_ptr_t & p_file,abort_callback & p_abort) = 0; + virtual bool is_id3v1_sufficient(const file_info & p_info) = 0; + virtual void truncate_to_id3v1(file_info & p_info) = 0; + virtual void read_ex(const service_ptr_t & p_file,file_info & p_info,t_filesize & p_tagoffset,abort_callback & p_abort) = 0; + + void write_id3v1(const service_ptr_t & p_file,const file_info & p_info,abort_callback & p_abort); + void write_apev2(const service_ptr_t & p_file,const file_info & p_info,abort_callback & p_abort); + void write_apev2_id3v1(const service_ptr_t & p_file,const file_info & p_info,abort_callback & p_abort); + + t_filesize read_v2_(const file::ptr & file, file_info& outInfo, abort_callback& abort); + + FB2K_MAKE_SERVICE_COREAPI(tag_processor_trailing); +}; + +//! \since 2.2 +class NOVTABLE tag_processor_trailing_v2 : public tag_processor_trailing { + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(tag_processor_trailing_v2, tag_processor_trailing); +public: + //! Returns tag offset, filesize_invalid if not found - does not throw exception_tag_not_found. + virtual t_filesize read_v2(const file::ptr & file, file_info& outInfo, abort_callback& abort) = 0; +}; + +namespace tag_processor { + //! Strips all recognized tags from the file and writes an ID3v1 tag with specified info. + void write_id3v1(const service_ptr_t & p_file,const file_info & p_info,abort_callback & p_abort); + //! Strips all recognized tags from the file and writes an APEv2 tag with specified info. + void write_apev2(const service_ptr_t & p_file,const file_info & p_info,abort_callback & p_abort); + //! Strips all recognized tags from the file and writes ID3v1+APEv2 tags with specified info. + void write_apev2_id3v1(const service_ptr_t & p_file,const file_info & p_info,abort_callback & p_abort); + //! Strips all recognized tags from the file and writes an ID3v2 tag with specified info. + void write_id3v2(const service_ptr_t & p_file,const file_info & p_info,abort_callback & p_abort); + //! Strips all recognized tags from the file and writes ID3v1+ID3v2 tags with specified info. + void write_id3v2_id3v1(const service_ptr_t & p_file,const file_info & p_info,abort_callback & p_abort); + //! Strips all recognized tags from the file and writes new tags with specified info according to parameters. + void write_multi(const service_ptr_t & p_file,const file_info & p_info,abort_callback & p_abort,bool p_write_id3v1,bool p_write_id3v2,bool p_write_apev2); + //! Strips all recognized tags from the file and writes new tags with specified info according to parameters. Extended to allow write-tags-to-temp-file-and-swap scheme. + void write_multi_ex(tag_write_callback & p_callback,const service_ptr_t & p_file,const file_info & p_info,abort_callback & p_abort,bool p_write_id3v1,bool p_write_id3v2,bool p_write_apev2); + //! Removes trailing tags from the file. + void remove_trailing(const service_ptr_t & p_file,abort_callback & p_abort); + //! Removes ID3v2 tags from the file. Returns true when a tag was removed, false when the file was not altered. + bool remove_id3v2(const service_ptr_t & p_file,abort_callback & p_abort); + //! Removes ID3v2 and trailing tags from specified file (not to be confused with trailing ID3v2 which are not supported). + void remove_id3v2_trailing(const service_ptr_t & p_file,abort_callback & p_abort); + //! Reads trailing tags from the file. Throws exception_tag_not_found if no tag was found. + void read_trailing(const service_ptr_t & p_file,file_info & p_info,abort_callback & p_abort); + //! Reads trailing tags from the file. Extended version, returns offset at which parsed tags start. Throws exception_tag_not_found if no tag was found. + //! p_tagoffset set to offset of found tags on success. + void read_trailing_ex(const service_ptr_t & p_file,file_info & p_info,t_filesize & p_tagoffset,abort_callback & p_abort); + //! Non-throwing version of read_trailing, returns offset at which tags begin, filesize_invalid if no tags found instead of throwing exception_tag_not_found. + t_filesize read_trailing_nothrow(const service_ptr_t& p_file, file_info& p_info, abort_callback& p_abort); + //! Reads ID3v2 tags from specified file. Throws exception_tag_not_found if no tag was found. + void read_id3v2(const service_ptr_t & p_file,file_info & p_info,abort_callback & p_abort); + //! Reads ID3v2 and trailing tags from specified file (not to be confused with trailing ID3v2 which are not supported). Throws exception_tag_not_found if neither tag type was found. + void read_id3v2_trailing(const service_ptr_t & p_file,file_info & p_info,abort_callback & p_abort); + //! Non-throwing version of read_id3v2_trailing, returns bool indicating whether any tag was read instead of throwing exception_tag_not_found. + bool read_id3v2_trailing_nothrow(const service_ptr_t& p_file, file_info& p_info, abort_callback& p_abort); + + void skip_id3v2(const service_ptr_t & p_file,t_filesize & p_size_skipped,abort_callback & p_abort); + t_filesize skip_id3v2(file::ptr const & f, abort_callback & a); + + bool is_id3v1_sufficient(const file_info & p_info); + void truncate_to_id3v1(file_info & p_info); + +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/tag_processor_id3v2.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/tag_processor_id3v2.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,127 @@ +#include "foobar2000-sdk-pch.h" +#include "tag_processor.h" + +bool tag_processor_id3v2::g_get(service_ptr_t & p_out) +{ + p_out = get(); + return true; +} + +void tag_processor_id3v2::g_remove(const service_ptr_t & p_file,t_uint64 & p_size_removed,abort_callback & p_abort) { + tag_write_callback_dummy cb; + g_remove_ex(cb,p_file,p_size_removed,p_abort); +} + +void tag_processor_id3v2::g_remove_ex(tag_write_callback & p_callback,const service_ptr_t & p_file,t_uint64 & p_size_removed,abort_callback & p_abort) +{ + p_file->ensure_seekable(); + + t_filesize len; + + len = p_file->get_size(p_abort); + + if (len == filesize_invalid) throw exception_io_no_length(); + + p_file->seek(0,p_abort); + + t_uint64 offset; + g_multiskip(p_file,offset,p_abort); + + if (offset>0 && offset temp; + if (p_callback.open_temp_file(temp,p_abort)) { + file::g_transfer_object(p_file,temp,len,p_abort); + } else { + if (len > 16*1024*1024) filesystem::g_open_temp(temp,p_abort); + else filesystem::g_open_tempmem(temp,p_abort); + file::g_transfer_object(p_file,temp,len,p_abort); + p_file->seek(0,p_abort); + p_file->set_eof(p_abort); + temp->seek(0,p_abort); + file::g_transfer_object(temp,p_file,len,p_abort); + } + } + p_size_removed = offset; +} + +t_size tag_processor_id3v2::g_multiskip(const service_ptr_t & p_file,t_filesize & p_size_skipped,abort_callback & p_abort) { + t_filesize offset = 0; + t_size count = 0; + for(;;) { + t_filesize delta; + g_skip_at(p_file, offset, delta, p_abort); + if (delta == 0) break; + offset += delta; + ++count; + } + p_size_skipped = offset; + return count; +} + +uint32_t tag_processor_id3v2::g_tagsize(const void* pHeader10bytes) { + const uint8_t* tmp = (const uint8_t*)pHeader10bytes; + if ( 0 != memcmp(tmp, "ID3", 3) || (tmp[5] & 0x0F) != 0 || ((tmp[6] | tmp[7] | tmp[8] | tmp[9]) & 0x80) != 0 ) { + return 0; + } + + int FooterPresent = tmp[5] & 0x10; + + uint32_t ret; + ret = tmp[6] << 21; + ret += tmp[7] << 14; + ret += tmp[8] << 7; + ret += tmp[9]; + ret += 10; + if (FooterPresent) ret += 10; + return ret; +} + +void tag_processor_id3v2::g_skip(const service_ptr_t & p_file,t_uint64 & p_size_skipped,abort_callback & p_abort) { + g_skip_at(p_file, 0, p_size_skipped, p_abort); +} + +void tag_processor_id3v2::g_skip_at(const service_ptr_t & p_file,t_filesize p_base, t_filesize & p_size_skipped,abort_callback & p_abort) { + + unsigned char tmp[10]; + + p_file->seek ( p_base, p_abort ); + + if (p_file->read( tmp, sizeof(tmp), p_abort) != sizeof(tmp)) { + p_file->seek ( p_base, p_abort ); + p_size_skipped = 0; + return; + } + + uint32_t ret = g_tagsize(tmp); + if (ret == 0) { + p_file->seek(p_base, p_abort); + p_size_skipped = 0; + return; + } + + try { + p_file->seek ( p_base + ret, p_abort ); + } catch(exception_io_seek_out_of_range const &) { + p_file->seek( p_base, p_abort ); + p_size_skipped = 0; + return; + } + + p_size_skipped = ret; +} + +bool tag_processor_id3v2::read_v2_(file::ptr const& file, file_info& outInfo, abort_callback& abort) { + { + tag_processor_id3v2_v2::ptr v2; + if (v2 &= this) return v2->read_v2(file, outInfo, abort); + } + // emulate new behavior with old API + try { + this->read(file, outInfo, abort); + return true; + } catch (exception_io_data const&) { + return false; + } +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/threadPool.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/threadPool.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,36 @@ +#pragma once + +#include +namespace fb2k { + void inWorkerThread(std::function f); + void inCpuWorkerThread(std::function f); + + //! \since 2.0 + class threadEntry : public service_base { + FB2K_MAKE_SERVICE_INTERFACE(threadEntry, service_base); + public: + virtual void run() = 0; + + static threadEntry::ptr make(std::function f); + }; + + //! \since 2.0 + //! A class interfacing with shared pool of threads intended for use with CPU bound tasks. \n + //! Use this instead of creating threads directly to avoid making the system unresponsive by creating too many CPU bound threads. + class cpuThreadPool : public service_base { + FB2K_MAKE_SERVICE_COREAPI(cpuThreadPool); + public: + //! Run one time task on a thread pool. Returns immediately. + virtual void runSingle(threadEntry::ptr trd) = 0; + //! Run the task multiple times concurrently. Optionally block until all done. \n + //! Exceptions: if nonblocking, they're discarded; if blocking; rethrown to caller. If multiple are thrown, one of them is rethrown, precedence undefined. + virtual void runMulti(threadEntry::ptr trd, size_t numRuns, bool blocking) = 0; + + virtual size_t numRunsSanity(size_t suggested) = 0; + + //! Helper around blocking runMulti(), with fallback for pre-v2.0 + static void runMultiHelper(std::function, size_t numRuns); + void runMulti_(std::function, size_t numRuns); + }; +} + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/threaded_process.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/threaded_process.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,124 @@ +#include "foobar2000-sdk-pch.h" +#include "threaded_process.h" +#include "advconfig.h" + +void threaded_process_status::set_progress(t_size p_state,t_size p_max) +{ + set_progress( progress_min + MulDiv_Size(p_state,progress_max-progress_min,p_max) ); +} + +void threaded_process_status::set_progress_secondary(t_size p_state,t_size p_max) +{ + set_progress_secondary( progress_min + MulDiv_Size(p_state,progress_max-progress_min,p_max) ); +} + +void threaded_process_status::set_progress_float(double p_state) +{ + if (p_state < 0.0) set_progress(progress_min); + else if (p_state < 1.0) set_progress( progress_min + (t_size)(p_state * (progress_max - progress_min))); + else set_progress(progress_max); +} + +void threaded_process_status::set_progress_secondary_float(double p_state) +{ + if (p_state < 0.0) set_progress_secondary(progress_min); + else if (p_state < 1.0) set_progress_secondary( progress_min + (t_size)(p_state * (progress_max - progress_min))); + else set_progress_secondary(progress_max); +} + + +bool threaded_process::g_run_modal(service_ptr_t p_callback,unsigned p_flags,fb2k::hwnd_t p_parent,const char * p_title,t_size p_title_len) +{ + PFC_ASSERT( core_api::is_main_thread() ); + return threaded_process::get()->run_modal(p_callback,p_flags,p_parent,p_title,p_title_len); +} + +bool threaded_process::g_run_modeless(service_ptr_t p_callback,unsigned p_flags,fb2k::hwnd_t p_parent,const char * p_title,t_size p_title_len) +{ + PFC_ASSERT( core_api::is_main_thread() ); + return threaded_process::get()->run_modeless(p_callback,p_flags,p_parent,p_title,p_title_len); +} + +bool threaded_process::g_query_preventStandby() { + static const GUID guid_preventStandby = { 0x7aafeffb, 0x5f11, 0x483f, { 0xac, 0x65, 0x61, 0xec, 0x9c, 0x70, 0x37, 0x4e } }; + advconfig_entry_checkbox::ptr obj; + if (advconfig_entry::g_find_t(obj, guid_preventStandby)) { + return obj->get_state(); + } else { + return false; + } +} + +enum { + set_items_max_characters = 80 +}; + +void threaded_process_status::set_items(pfc::list_base_const_t const & items) { + const size_t count = items.get_count(); + if (count == 0) return; + if (count == 1) { set_item_path(items[0]); } + pfc::string8 acc; + + filesystem::ptr fs; + for (size_t w = 0; w < count; ++w) { + pfc::string8 name = fb2k::filename_ext(items[w], fs); + if (w > 0 && acc.length() + name.length() > set_items_max_characters) { + acc << " and " << (count - w) << " more"; + break; + } + if (w > 0) acc << ", "; + acc << name; + } + + set_item(acc); +} + +void threaded_process_status::set_items(metadb_handle_list_cref items) { + const size_t count = items.get_count(); + if ( count == 0 ) return; + if ( count == 1 ) { set_item_path(items[0]->get_path()); } + pfc::string8 acc; + + filesystem::ptr fs; + for( size_t w = 0; w < count; ++w ) { + pfc::string8 name = fb2k::filename_ext(items[w]->get_path(), fs); + if ( w > 0 && acc.length() + name.length() > set_items_max_characters) { + acc << " and " << (count-w) << " more"; + break; + } + if (w > 0) acc << ", "; + acc << name; + } + + set_item(acc); +} + + +void threaded_process_callback_lambda::on_init(ctx_t p_ctx) { + if (m_on_init) m_on_init(p_ctx); +} + +void threaded_process_callback_lambda::run(threaded_process_status & p_status, abort_callback & p_abort) { + m_run(p_status, p_abort); +} + +void threaded_process_callback_lambda::on_done(ctx_t p_ctx, bool p_was_aborted) { + if (m_on_done) m_on_done(p_ctx, p_was_aborted); +} + +service_ptr_t threaded_process_callback_lambda::create() { + return new service_impl_t(); +} + +service_ptr_t threaded_process_callback_lambda::create(run_t f) { + auto obj = create(); + obj->m_run = f; + return obj; +} +service_ptr_t threaded_process_callback_lambda::create(on_init_t f1, run_t f2, on_done_t f3) { + auto obj = create(); + obj->m_on_init = f1; + obj->m_run = f2; + obj->m_on_done = f3; + return obj; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/threaded_process.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/threaded_process.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,158 @@ +#pragma once +#include + +//! Callback class passed to your threaded_process client code; allows you to give various visual feedback to the user. +class threaded_process_status { +public: + enum {progress_min = 0, progress_max = 5000}; + + //! Sets the primary progress bar state; scale from progress_min to progress_max. + virtual void set_progress(t_size p_state) { (void)p_state; } + //! Sets the secondary progress bar state; scale from progress_min to progress_max. + virtual void set_progress_secondary(t_size p_state) { (void)p_state; } + //! Sets the currently progressed item label. When working with files, you should use set_file_path() instead. + virtual void set_item(const char* p_item, t_size p_item_len = SIZE_MAX) { (void)p_item; (void)p_item_len; } + //! Sets the currently progressed item label; treats the label as a file path. + virtual void set_item_path(const char* p_item, t_size p_item_len = SIZE_MAX) { (void)p_item; (void)p_item_len; } + //! Sets the title of the dialog. You normally don't need this function unless you want to override the title you set when initializing the threaded_process. + virtual void set_title(const char* p_title, t_size p_title_len = SIZE_MAX) { (void)p_title; (void)p_title_len; } + //! Should not be used. + virtual void force_update() {} + //! Returns whether the process is paused. + virtual bool is_paused() {return false;} + + //! Checks if process is paused and sleeps if needed; returns false when process should be aborted, true on success. \n + //! You should use poll_pause() instead of calling this directly. + virtual bool process_pause() {return true;} + + //! Automatically sleeps if the process is paused. + void poll_pause() {if (!process_pause()) throw exception_aborted();} + + //! Helper; sets primary progress with a custom scale. + void set_progress(t_size p_state,t_size p_max); + //! Helper; sets secondary progress with a custom scale. + void set_progress_secondary(t_size p_state,t_size p_max); + //! Helper; sets primary progress with a float 0..1 scale. + void set_progress_float(double p_state); + //! Helper; sets secondary progress with a float 0..1 scale. + void set_progress_secondary_float(double p_state); + //! Helper; gracefully reports multiple items being concurrently worked on. + void set_items( metadb_handle_list_cref items ); + void set_items( pfc::list_base_const_t const & paths ); +}; + +//! Fb2k mobile compatibility +class threaded_process_context { +public: + static fb2k::hwnd_t g_default() { return core_api::get_main_window(); } +}; + +//! Callback class for the threaded_process API. You must implement this to create your own threaded_process client. +class NOVTABLE threaded_process_callback : public service_base { +public: + typedef fb2k::hwnd_t ctx_t; + + //! Called from the main thread before spawning the worker thread. \n + //! Note that you should not access the window handle passed to on_init() in the worker thread later on. + virtual void on_init(ctx_t p_wnd) { (void)p_wnd; } + //! Called from the worker thread. Do all the hard work here. + virtual void run(threaded_process_status & p_status,abort_callback & p_abort) = 0; + //! Called after the worker thread has finished executing. + virtual void on_done(ctx_t p_wnd, bool p_was_aborted) { (void)p_wnd; (void)p_was_aborted; } + + //! Safely prevent destruction from worker threads. + static bool serviceRequiresMainThreadDestructor() { return true; } + + FB2K_MAKE_SERVICE_INTERFACE(threaded_process_callback,service_base); +}; + + +//! The threaded_process API allows you to easily put timeconsuming tasks in worker threads, with progress dialog giving nice feedback to the user. \n +//! Thanks to this API you can perform such tasks with no user interface related programming at all. +class NOVTABLE threaded_process : public service_base { +public: + enum { + //! Shows the "abort" button. + flag_show_abort = 1, + //! Obsolete, do not use. + flag_show_minimize = 1 << 1, + //! Shows a progress bar. + flag_show_progress = 1 << 2, + //! Shows dual progress bars; implies flag_show_progress. + flag_show_progress_dual = 1 << 3, + //! Shows the item being currently processed. + flag_show_item = 1 << 4, + //! Shows the "pause" button. + flag_show_pause = 1 << 5, + //! Obsolete, do not use. + flag_high_priority = 1 << 6, + //! Make the dialog hidden by default and show it only if the operation could not be completed after 500ms. Implies flag_no_focus. Relevant only to modeless dialogs. + flag_show_delayed = 1 << 7, + //! Do not focus the dialog by default. + flag_no_focus = 1 << 8, + //! \since 2.0 + //! Do not show any user interface, just run the operation quietly. + flag_silent = 1 << 9, + }; + + //! Runs a synchronous threaded_process operation - the function does not return until the operation has completed, though the app UI is not frozen and the operation is abortable. \n + //! This API is obsolete and should not be used. Please use run_modeless() instead if possible. \n + //! Call from main thread only. + //! @param p_callback Interface to your threaded_process client. + //! @param p_flags Flags describing requested dialog functionality. See threaded_process::flag_* constants. + //! @param p_parent Parent window for the progress dialog - typically core_api::get_main_window(). + //! @param p_title Initial title of the dialog. + //! @returns True if the operation has completed normally, false if the user has aborted the operation. In case of a catastrophic failure such as dialog creation failure, exceptions will be thrown. + virtual bool run_modal(service_ptr_t p_callback,unsigned p_flags,fb2k::hwnd_t p_parent,const char * p_title,t_size p_title_len = SIZE_MAX) = 0; + //! Runs an asynchronous threaded_process operation. \n + //! Call from main thread only. + //! @param p_callback Interface to your threaded_process client. + //! @param p_flags Flags describing requested dialog functionality. See threaded_process::flag_* constants. + //! @param p_parent Parent window for the progress dialog - typically core_api::get_main_window(). + //! @param p_title Initial title of the dialog. + //! @returns True, always; the return value should be ignored. In case of a catastrophic failure such as dialog creation failure, exceptions will be thrown. + virtual bool run_modeless(service_ptr_t p_callback,unsigned p_flags,fb2k::hwnd_t p_parent,const char * p_title,t_size p_title_len = SIZE_MAX) = 0; + + + //! Helper invoking run_modal(). + static bool g_run_modal(service_ptr_t p_callback,unsigned p_flags,fb2k::hwnd_t p_parent,const char * p_title,t_size p_title_len = SIZE_MAX); + //! Helper invoking run_modeless(). + static bool g_run_modeless(service_ptr_t p_callback,unsigned p_flags,fb2k::hwnd_t p_parent,const char * p_title,t_size p_title_len = SIZE_MAX); + + //! Queries user settings; returns whether various timeconsuming tasks should be blocking machine standby. + static bool g_query_preventStandby(); + + FB2K_MAKE_SERVICE_COREAPI(threaded_process); +}; + + +//! Helper - forward threaded_process_callback calls to a service object that for whatever reason cannot publish threaded_process_callback API by itself. +template class threaded_process_callback_redir : public threaded_process_callback { +public: + threaded_process_callback_redir(TTarget * target) : m_target(target) {} + void on_init(ctx_t p_wnd) {m_target->tpc_on_init(p_wnd);} + void run(threaded_process_status & p_status,abort_callback & p_abort) {m_target->tpc_run(p_status, p_abort);} + void on_done(ctx_t p_wnd,bool p_was_aborted) {m_target->tpc_on_done(p_wnd, p_was_aborted); } +private: + const service_ptr_t m_target; +}; + +//! Helper - lambda based threaded_process_callback implementation +class threaded_process_callback_lambda : public threaded_process_callback { +public: + typedef std::function on_init_t; + typedef std::function run_t; + typedef std::function on_done_t; + + static service_ptr_t create(); + static service_ptr_t create(run_t f); + static service_ptr_t create(on_init_t f1, run_t f2, on_done_t f3); + + on_init_t m_on_init; + run_t m_run; + on_done_t m_on_done; + + void on_init(ctx_t p_ctx); + void run(threaded_process_status & p_status, abort_callback & p_abort); + void on_done(ctx_t p_ctx, bool p_was_aborted); +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/threadsLite.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/threadsLite.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,39 @@ +#pragma once +namespace fb2k { + //! pfc::splitThread() + async_task_manager::acquire + void splitTask(std::function); + void splitTask(pfc::thread::arg_t const&, std::function); + abort_callback& mainAborter(); + + void inCpuWorkerThread(std::function f); +} + + + +// ====================================================================================================== +// Most of main_thread_callback.h declares API internals and obsolete helpers. +// In modern code, simply use fb2k::inMainThread() declared below and disregard the rest. +// ====================================================================================================== +namespace fb2k { + //! Queue a call in main thread. Returns immediately. \n + //! You can call this from any thread, including main thread - to execute some code outside the current call stack / global fb2k callbacks / etc. \n + //! Guaranteed FIFO order of execution. See also: main_thread_callback::add_callback(). + void inMainThread(std::function f); + //! Call f synchronously if called from main thread, queue call if called from another. + void inMainThread2(std::function f); + + //! Clone abort_callback, suppress call if original abort_callback becomes set prior to reaching main thread. + void inMainThread(std::function f, abort_callback&); + + //! Synchronous / abortable version. May exit *before* f() finishes, if abort becomes set. + void inMainThreadSynchronous(std::function f, abort_callback& abort); + + //! Synchronous blocking version. \n + //! Uses new foobar2000 v2.0 methods if available, synchronizing to main thread via SendMessage(). \n + //! Introduced to help recovering from method-called-from-wrong-context scenarios. Does *not* guarentee FIFO execution order contrary to plain inMainThread(). + void inMainThreadSynchronous2(std::function f); + + //! Helper class for threads that call fb2k objects. Mainly needed for Android shims. You can safely ignore this. \n + //! Guaranteed to have startHere(), isActive() and waitTillDone() methods only. + typedef pfc::thread2 thread; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/timer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/timer.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,17 @@ +#pragma once +#include +#include "completion_notify.h" + +#if FOOBAR2020 +namespace fb2k { + //! \since 2.0 + class NOVTABLE timerManager : public service_base { + FB2K_MAKE_SERVICE_COREAPI(timerManager); + public: + virtual objRef addTimer( double interval, completion_notify::ptr callback ) = 0; + }; + + objRef registerTimer( double interval, std::function func ); + void callLater( double timeAfter, std::function< void () > func ); +} +#endif // FOOBAR2020 \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/titleformat.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/titleformat.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,221 @@ +#include "foobar2000-sdk-pch.h" +#include "titleformat.h" + + +#define tf_profiler(x) // profiler(x) + +void titleformat_compiler::remove_color_marks(const char * src,pfc::string_base & out)//helper +{ + out.reset(); + while(*src) + { + if (*src==3) + { + src++; + while(*src && *src!=3) src++; + if (*src==3) src++; + } + else out.add_byte(*src++); + } +} + +static bool test_for_bad_char(const char * source,t_size source_char_len,const char * reserved) +{ + return pfc::strstr_ex(reserved,(t_size)(-1),source,source_char_len) != (t_size)(-1); +} + +void titleformat_compiler::remove_forbidden_chars(titleformat_text_out * p_out,const GUID & p_inputtype,const char * p_source,t_size p_source_len,const char * p_reserved_chars) +{ + if (p_reserved_chars == 0 || *p_reserved_chars == 0) + { + p_out->write(p_inputtype,p_source,p_source_len); + } + else + { + p_source_len = pfc::strlen_max(p_source,p_source_len); + t_size index = 0; + t_size good_byte_count = 0; + while(index < p_source_len) + { + t_size delta = pfc::utf8_char_len(p_source + index,p_source_len - index); + if (delta == 0) break; + if (test_for_bad_char(p_source+index,delta,p_reserved_chars)) + { + if (good_byte_count > 0) {p_out->write(p_inputtype,p_source+index-good_byte_count,good_byte_count);good_byte_count=0;} + p_out->write(p_inputtype,"_",1); + } + else + { + good_byte_count += delta; + } + index += delta; + } + if (good_byte_count > 0) {p_out->write(p_inputtype,p_source+index-good_byte_count,good_byte_count);good_byte_count=0;} + } +} + +void titleformat_compiler::remove_forbidden_chars_string_append(pfc::string_receiver & p_out,const char * p_source,t_size p_source_len,const char * p_reserved_chars) +{ + titleformat_text_out_impl_string tfout(p_out); + remove_forbidden_chars(&tfout,pfc::guid_null,p_source,p_source_len,p_reserved_chars); +} + +void titleformat_compiler::remove_forbidden_chars_string(pfc::string_base & p_out,const char * p_source,t_size p_source_len,const char * p_reserved_chars) +{ + p_out.reset(); + remove_forbidden_chars_string_append(p_out,p_source,p_source_len,p_reserved_chars); +} + +bool titleformat_hook_impl_file_info::process_field(titleformat_text_out * p_out,const char * p_name,t_size p_name_length,bool & p_found_flag) { + return m_api->process_field(*m_info,m_location,p_out,p_name,p_name_length,p_found_flag); +} +bool titleformat_hook_impl_file_info::process_function(titleformat_text_out * p_out,const char * p_name,t_size p_name_length,titleformat_hook_function_params * p_params,bool & p_found_flag) { + return m_api->process_function(*m_info,m_location,p_out,p_name,p_name_length,p_params,p_found_flag); +} + +void titleformat_object::run_hook(const playable_location & p_location,const file_info * p_source,titleformat_hook * p_hook,pfc::string_base & p_out,titleformat_text_filter * p_filter) +{ + if (p_hook) + { + titleformat_hook_impl_file_info hook1(p_location, p_source); + titleformat_hook_impl_splitter hook2(p_hook, &hook1); + run(&hook2,p_out,p_filter); + } + else + { + titleformat_hook_impl_file_info hook(p_location, p_source); + run(&hook,p_out,p_filter); + } +} + +void titleformat_object::run_simple(const playable_location & p_location,const file_info * p_source,pfc::string_base & p_out) +{ + titleformat_hook_impl_file_info hook(p_location, p_source); + run(&hook,p_out,NULL); +} + +t_size titleformat_hook_function_params::get_param_uint(t_size index) +{ + const char * str; + t_size str_len; + get_param(index,str,str_len); + return pfc::atoui_ex(str,str_len); +} + + +void titleformat_text_out_impl_filter_chars::write(const GUID & p_inputtype,const char * p_data,t_size p_data_length) +{ + titleformat_compiler::remove_forbidden_chars(m_chain,p_inputtype,p_data,p_data_length,m_restricted_chars); +} + +bool titleformat_hook_impl_splitter::process_field(titleformat_text_out * p_out,const char * p_name,t_size p_name_length,bool & p_found_flag) +{ + p_found_flag = false; + if (m_hook1 && m_hook1->process_field(p_out,p_name,p_name_length,p_found_flag)) return true; + p_found_flag = false; + if (m_hook2 && m_hook2->process_field(p_out,p_name,p_name_length,p_found_flag)) return true; + p_found_flag = false; + return false; +} + +bool titleformat_hook_impl_splitter::process_function(titleformat_text_out * p_out,const char * p_name,t_size p_name_length,titleformat_hook_function_params * p_params,bool & p_found_flag) +{ + p_found_flag = false; + if (m_hook1 && m_hook1->process_function(p_out,p_name,p_name_length,p_params,p_found_flag)) return true; + p_found_flag = false; + if (m_hook2 && m_hook2->process_function(p_out,p_name,p_name_length,p_params,p_found_flag)) return true; + p_found_flag = false; + return false; +} + +void titleformat_text_out::write_int_padded(const GUID & p_inputtype,t_int64 val,t_int64 maxval) +{ + unsigned width = 0; + while(maxval > 0) {maxval/=10;width++;} + write(p_inputtype,pfc::format_int(val,width)); +} + +void titleformat_text_out::write_int(const GUID & p_inputtype,t_int64 val) +{ + write(p_inputtype,pfc::format_int(val)); +} +void titleformat_text_filter_impl_reserved_chars::write(const GUID & p_inputtype,pfc::string_receiver & p_out,const char * p_data,t_size p_data_length) +{ + if (p_inputtype == titleformat_inputtypes::meta) titleformat_compiler::remove_forbidden_chars_string_append(p_out,p_data,p_data_length,m_reserved_chars); + else p_out.add_string(p_data,p_data_length); +} + +void titleformat_compiler::run(titleformat_hook * p_source,pfc::string_base & p_out,const char * p_spec) +{ + service_ptr_t ptr; + if (!compile(ptr,p_spec)) p_out = "[COMPILATION ERROR]"; + else ptr->run(p_source,p_out,NULL); +} + +void titleformat_compiler::compile_safe(titleformat_object::ptr & p_out,const char * p_spec) +{ + compile_safe_ex(p_out, p_spec, "%filename%"); +} + + +namespace titleformat_inputtypes { + const GUID meta = { 0xcd839c8e, 0x5c66, 0x4ae1, { 0x8d, 0xad, 0x71, 0x1f, 0x86, 0x0, 0xa, 0xe3 } }; + const GUID unknown = { 0x673aa1cd, 0xa7a8, 0x40c8, { 0xbf, 0x9b, 0x34, 0x37, 0x99, 0x29, 0x16, 0x3b } }; +}; + +void titleformat_text_filter_impl_filename_chars::write(const GUID & p_inputType,pfc::string_receiver & p_out,const char * p_data,t_size p_dataLength) { + if (p_inputType == titleformat_inputtypes::meta) { + //slightly inefficient... + p_out.add_string( pfc::io::path::replaceIllegalNameChars(pfc::string(p_data,p_dataLength)).ptr()); + } else p_out.add_string(p_data,p_dataLength); +} + +void titleformat_compiler::compile_safe_ex(titleformat_object::ptr & p_out,const char * p_spec,const char * p_fallback) { + if (!compile(p_out,p_spec)) compile_force(p_out,p_fallback); +} + + +void titleformat_text_filter_nontext_chars::write(const GUID & p_inputtype,pfc::string_receiver & p_out,const char * p_data,t_size p_data_length) { + (void)p_inputtype; + for(t_size walk = 0;;) { + t_size base = walk; + while(walk < p_data_length && !isReserved(p_data[walk]) && p_data[walk] != 0) walk++; + p_out.add_string(p_data+base,walk-base); + if (walk >= p_data_length || p_data[walk] == 0) break; + p_out.add_byte('_'); walk++; + } +} + +titleformat_object::ptr titleformat_compiler::compile(const char* spec) { + titleformat_object::ptr ret; + this->compile(ret, spec); + return ret; +} +titleformat_object::ptr titleformat_compiler::compile_force(const char* spec) { + titleformat_object::ptr ret; + this->compile_force(ret, spec); + return ret; +} +titleformat_object::ptr titleformat_compiler::compile_fallback(const char* spec, const char* fallback) { + auto ret = compile(spec); + if (ret.is_empty()) ret = compile(fallback); + return ret; +} + +bool titleformat_object::requires_metadb_info_() { +#if FOOBAR2000_TARGET_VERSION >= 81 + return static_cast(this)->requires_metadb_info(); +#else + titleformat_object_v2::ptr v2; + if (v2 &= this) return v2->requires_metadb_info(); + return true; +#endif +} + +const char * titleformat_patterns::patternAlbumSplit() { + return "$if2(%album artist%,$directory_path(%path%))\t$if2(%album%,%title%)\t%discnumber%"; +} + +const char * titleformat_patterns::patternSortTracks() { + return "%album artist% | %album% | %discnumber% | %tracknumber% | %title% | %path%"; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/titleformat.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/titleformat.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,265 @@ +#pragma once + +#include "titleformat_object.h" + +namespace titleformat_inputtypes { + extern const GUID meta, unknown; +}; + +class NOVTABLE titleformat_text_out { +public: + virtual void write(const GUID & p_inputtype,const char * p_data,t_size p_data_length = SIZE_MAX) = 0; + void write_int(const GUID & p_inputtype,t_int64 val); + void write_int_padded(const GUID & p_inputtype,t_int64 val,t_int64 maxval); +protected: + titleformat_text_out() {} + ~titleformat_text_out() {} +}; + +//! This class allows custom processing of title formatting output, aware of whole substrings being passed, etc. +class NOVTABLE titleformat_text_filter { +public: + virtual void write(const GUID & p_inputtype,pfc::string_receiver & p_out,const char * p_data,t_size p_data_length) = 0; +protected: + titleformat_text_filter() {} + ~titleformat_text_filter() {} +}; + +class NOVTABLE titleformat_hook_function_params +{ +public: + virtual t_size get_param_count() = 0; + virtual void get_param(t_size index,const char * & p_string,t_size & p_string_len) = 0;//warning: not a null-terminated string + + //helper + t_size get_param_uint(t_size index); +}; + +class NOVTABLE titleformat_hook +{ +public: + virtual bool process_field(titleformat_text_out * p_out,const char * p_name,t_size p_name_length,bool & p_found_flag) = 0; + virtual bool process_function(titleformat_text_out * p_out,const char * p_name,t_size p_name_length,titleformat_hook_function_params * p_params,bool & p_found_flag) = 0; +}; + +//! \since 2.0 +class NOVTABLE titleformat_object_v2 : public titleformat_object { + FB2K_MAKE_SERVICE_INTERFACE(titleformat_object_v2, titleformat_object); +public: + //! Walk from idx=0 up until returns null. + virtual const char* enum_used_fields(size_t idx) = 0; + //! Walk from idx=0 up until returns null. + virtual const char* enum_used_functions(size_t idx) = 0; + //! Returns true if evaluation of this only references fields such as file path, which can be evaluated without accessing actual metadb data. + virtual bool requires_metadb_info() = 0; +}; + +//! Standard service for instantiating titleformat_object. Implemented by the core; do not reimplement. +//! To instantiate, use titleformat_compiler::get(). +class NOVTABLE titleformat_compiler : public service_base { + FB2K_MAKE_SERVICE_COREAPI(titleformat_compiler); +public: + //! Returns false in case of a compilation error. + virtual bool compile(titleformat_object::ptr & p_out,const char * p_spec) = 0; + //! Helper; + void run(titleformat_hook * p_source,pfc::string_base & p_out,const char * p_spec); + //! Should never fail, falls back to %filename% in case of failure. + void compile_safe(titleformat_object::ptr & p_out,const char * p_spec); + + //! Falls back to p_fallback in case of failure. + void compile_safe_ex(titleformat_object::ptr & p_out,const char * p_spec,const char * p_fallback = ""); + + //! Crashes when script can't be compiled. For use with hardcoded scripts only. + void compile_force(titleformat_object::ptr & p_out,const char * p_spec) {if (!compile(p_out,p_spec)) uBugCheck();} + + titleformat_object::ptr compile(const char* spec); + titleformat_object::ptr compile_force(const char* spec); + titleformat_object::ptr compile_fallback(const char* spec, const char* fallback); + + + static void remove_color_marks(const char * src,pfc::string_base & out);//helper + static void remove_forbidden_chars(titleformat_text_out * p_out,const GUID & p_inputtype,const char * p_source,t_size p_source_len,const char * p_forbidden_chars); + static void remove_forbidden_chars_string_append(pfc::string_receiver & p_out,const char * p_source,t_size p_source_len,const char * p_forbidden_chars); + static void remove_forbidden_chars_string(pfc::string_base & p_out,const char * p_source,t_size p_source_len,const char * p_forbidden_chars); +}; + +// \since 2.0 +class NOVTABLE titleformat_compiler_v2 : public titleformat_compiler { + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(titleformat_compiler_v2, titleformat_compiler); +public: + virtual titleformat_object::ptr concat(pfc::list_base_const_t const&) = 0; +}; + + +class titleformat_object_wrapper { +public: + titleformat_object_wrapper(const char * p_script) { + titleformat_compiler::get()->compile_force(m_script,p_script); + } + + operator const service_ptr_t &() const {return m_script;} + +private: + service_ptr_t m_script; +}; + + +//helpers + + +class titleformat_text_out_impl_filter_chars : public titleformat_text_out +{ +public: + inline titleformat_text_out_impl_filter_chars(titleformat_text_out * p_chain,const char * p_restricted_chars) + : m_chain(p_chain), m_restricted_chars(p_restricted_chars) {} + void write(const GUID & p_inputtype,const char * p_data,t_size p_data_length); +private: + titleformat_text_out * m_chain; + const char * m_restricted_chars; +}; + +class titleformat_text_out_impl_string : public titleformat_text_out { +public: + titleformat_text_out_impl_string(pfc::string_receiver & p_string) : m_string(p_string) {} + void write(const GUID &,const char * p_data,t_size p_data_length) override {m_string.add_string(p_data,p_data_length);} +private: + pfc::string_receiver & m_string; +}; + +class titleformat_common_methods : public service_base { +public: + virtual bool process_field(const file_info & p_info,const playable_location & p_location,titleformat_text_out * p_out,const char * p_name,t_size p_name_length,bool & p_found_flag) = 0; + virtual bool process_function(const file_info & p_info,const playable_location & p_location,titleformat_text_out * p_out,const char * p_name,t_size p_name_length,titleformat_hook_function_params * p_params,bool & p_found_flag) = 0; + virtual bool remap_meta(const file_info & p_info,t_size & p_index, const char * p_name, t_size p_name_length) = 0; + + FB2K_MAKE_SERVICE_COREAPI(titleformat_common_methods); +}; + +class titleformat_hook_impl_file_info : public titleformat_hook +{ +public: + titleformat_hook_impl_file_info(const playable_location & p_location,const file_info * p_info) : m_info(p_info), m_location(p_location) {}//caller must ensure that referenced file_info object is alive as long as the titleformat_hook_impl_file_info instance + bool process_field(titleformat_text_out * p_out,const char * p_name,t_size p_name_length,bool & p_found_flag); + bool process_function(titleformat_text_out * p_out,const char * p_name,t_size p_name_length,titleformat_hook_function_params * p_params,bool & p_found_flag); +protected: + bool remap_meta(t_size & p_index, const char * p_name, t_size p_name_length) {return m_api->remap_meta(*m_info,p_index,p_name,p_name_length);} + const file_info * m_info; +private: + const playable_location & m_location; + const titleformat_common_methods::ptr m_api = titleformat_common_methods::get(); +}; + +class titleformat_hook_impl_splitter : public titleformat_hook { +public: + inline titleformat_hook_impl_splitter(titleformat_hook * p_hook1,titleformat_hook * p_hook2) : m_hook1(p_hook1), m_hook2(p_hook2) {} + bool process_field(titleformat_text_out * p_out,const char * p_name,t_size p_name_length,bool & p_found_flag); + bool process_function(titleformat_text_out * p_out,const char * p_name,t_size p_name_length,titleformat_hook_function_params * p_params,bool & p_found_flag); +private: + titleformat_hook * m_hook1, * m_hook2; +}; + +class titleformat_text_filter_impl_reserved_chars : public titleformat_text_filter { +public: + titleformat_text_filter_impl_reserved_chars(const char * p_reserved_chars) : m_reserved_chars(p_reserved_chars) {} + void write(const GUID & p_inputtype,pfc::string_receiver & p_out,const char * p_data,t_size p_data_length) override; +private: + const char * m_reserved_chars; +}; + +class titleformat_text_filter_impl_filename_chars : public titleformat_text_filter { +public: + void write(const GUID & p_inputType,pfc::string_receiver & p_out,const char * p_data,t_size p_dataLength) override; +}; + +class titleformat_text_filter_nontext_chars : public titleformat_text_filter { +public: + inline static bool isReserved(char c) { return c >= 0 && c < 0x20; } + void write(const GUID & p_inputtype,pfc::string_receiver & p_out,const char * p_data,t_size p_data_length) override; +}; + + + + + + + +class titleformat_hook_impl_list : public titleformat_hook { +public: + titleformat_hook_impl_list(t_size p_index /* zero-based! */,t_size p_total) : m_index(p_index), m_total(p_total) {} + + bool process_field(titleformat_text_out * p_out,const char * p_name,t_size p_name_length,bool & p_found_flag) override { + if ( + pfc::stricmp_ascii_ex(p_name,p_name_length,"list_index",SIZE_MAX) == 0 + ) { + p_out->write_int_padded(titleformat_inputtypes::unknown,m_index+1, m_total); + p_found_flag = true; return true; + } else if ( + pfc::stricmp_ascii_ex(p_name,p_name_length,"list_total",SIZE_MAX) == 0 + ) { + p_out->write_int(titleformat_inputtypes::unknown,m_total); + p_found_flag = true; return true; + } else { + p_found_flag = false; return false; + } + } + + bool process_function(titleformat_text_out *,const char *,t_size,titleformat_hook_function_params *,bool &) override {return false;} + +private: + t_size m_index, m_total; +}; + +class string_formatter_tf : public pfc::string_base { + [[noreturn]] static void verboten() { FB2K_BugCheck(); } +public: + string_formatter_tf(titleformat_text_out * out, const GUID & inputType = titleformat_inputtypes::meta) : m_out(out), m_inputType(inputType) {} + + const char * get_ptr() const override { + verboten(); + } + void add_string(const char * p_string,t_size p_length) override { + m_out->write(m_inputType,p_string,p_length); + } + void set_string(const char *,t_size) override { + verboten(); + } + void truncate(t_size) override { + verboten(); + } + t_size get_length() const override { + verboten(); + } + char * lock_buffer(t_size) override { + verboten(); + } + void unlock_buffer() override { + verboten(); + } + +private: + titleformat_text_out * const m_out; + const GUID m_inputType; +}; + + +class titleformat_object_cache { +public: + titleformat_object_cache(const char * pattern) : m_pattern(pattern) {} + operator titleformat_object::ptr() { + PFC_ASSERT(core_api::assert_main_thread()); + if (m_obj.is_empty()) { + titleformat_compiler::get()->compile_force(m_obj, m_pattern); + } + return m_obj; + } +private: + const char * const m_pattern; + titleformat_object::ptr m_obj; +}; + + +class titleformat_patterns { +public: + static const char * patternAlbumSplit(); + static const char * patternSortTracks(); +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/titleformat_object.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/titleformat_object.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,20 @@ +#pragma once + +// titleformat_object extracted from titleformat.h as it's more commonly used than other titleformat.h stuff + +class file_info; class titleformat_hook; class titleformat_text_filter; + +//! Represents precompiled executable title-formatting script. Use titleformat_compiler to instantiate; do not reimplement. +class NOVTABLE titleformat_object : public service_base +{ +public: + virtual void run(titleformat_hook * p_source,pfc::string_base & p_out,titleformat_text_filter * p_filter)=0; + + void run_hook(const playable_location & p_location,const file_info * p_source,titleformat_hook * p_hook,pfc::string_base & p_out,titleformat_text_filter * p_filter); + void run_simple(const playable_location & p_location,const file_info * p_source,pfc::string_base & p_out); + + //! Helper, see titleformat_object_v2::requires_metadb_info() + bool requires_metadb_info_(); + + FB2K_MAKE_SERVICE_INTERFACE(titleformat_object,service_base); +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/toolbarDropDown.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/toolbarDropDown.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,29 @@ +#pragma once + +namespace fb2k { + + //! \since 2.0 + class toolbarDropDownNotify { + public: + virtual void contentChanged() = 0; + virtual void selectionChanged() = 0; + protected: + ~toolbarDropDownNotify() {} + }; + + //! \since 2.0 + class toolbarDropDown : public service_base { + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(toolbarDropDown) + public: + virtual GUID getGuid() = 0; + virtual void getShortName(pfc::string_base& out) = 0; // name to appear in toolbar + virtual void getLongName(pfc::string_base& out) = 0; // long descriptive name + virtual size_t getNumValues() = 0; + virtual void getValue(size_t idx, pfc::string_base& out) = 0; + virtual void setSelectedIndex(size_t) = 0; + virtual size_t getSelectedIndex() = 0; + virtual void addNotify(toolbarDropDownNotify*) = 0; + virtual void removeNotify(toolbarDropDownNotify*) = 0; + virtual void onDropDown() = 0; + }; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/track_property.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/track_property.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,161 @@ +#include "foobar2000-sdk-pch.h" + +#include "track_property.h" +#include "metadb_info_container_impl.h" + +namespace { + class track_property_provider_v3_info_source_impl : public track_property_provider_v3_info_source { + public: + track_property_provider_v3_info_source_impl(trackListRef items) : m_items(items) {} + trackInfoContainer::ptr get_info(size_t index) { + return trackGetInfoRef(m_items, index); + } + private: + trackListRef m_items; + }; + + class track_property_callback_v2_proxy : public track_property_callback_v2 { + public: + track_property_callback_v2_proxy(track_property_callback & callback) : m_callback(callback) {} + void set_property(const char * p_group, double p_sortpriority, const char * p_name, const char * p_value) { m_callback.set_property(p_group, p_sortpriority, p_name, p_value); } + bool is_group_wanted(const char*) { return true; } + + private: + track_property_callback & m_callback; + }; + + +} + +void track_property_provider_v3::enumerate_properties(trackListRef p_tracks, track_property_callback & p_out) { + track_property_provider_v3_info_source_impl src(p_tracks); track_property_callback_v2_proxy cb(p_out); enumerate_properties_v3(p_tracks, src, cb); +} + +void track_property_provider_v3::enumerate_properties_v2(trackListRef p_tracks, track_property_callback_v2 & p_out) { + track_property_provider_v3_info_source_impl src(p_tracks); enumerate_properties_v3(p_tracks, src, p_out); +} + +void track_property_provider_v4::enumerate_properties_v3(trackListRef items, track_property_provider_v3_info_source & info, track_property_callback_v2 & callback) { + this->enumerate_properties_v4(items, info, callback, fb2k::noAbort ); +} +namespace { + class track_property_provider_v5_info_source_wrap : public track_property_provider_v5_info_source { + public: + track_property_provider_v5_info_source_wrap(track_property_provider_v3_info_source& chain, trackListRef items) : m_chain(chain), m_items(items) {} + track_property_provider_v3_info_source & m_chain; + trackListRef m_items; + + // Not very efficient but gets the job done + metadb_v2_rec_t get_info(size_t index) override { + auto ret = m_items[index]->query_v2_(); + ret.info = m_chain.get_info(index); + return ret; + } + }; +} +void track_property_provider_v5::enumerate_properties_v4(trackListRef items, track_property_provider_v3_info_source& info, track_property_callback_v2& callback, abort_callback& abort) { + track_property_provider_v5_info_source_wrap wrap(info, items); + this->enumerate_properties_v5(items, wrap, callback, abort); +} + +namespace { + class track_property_provider_v3_info_source_wrap_v5 : public track_property_provider_v3_info_source { + public: + track_property_provider_v5_info_source* chain; + trackInfoContainer::ptr get_info(size_t index) override { + auto ret = chain->get_info(index).info; + if (ret.is_empty()) { + ret = m_blank; + } + return ret; + } + metadb_info_container::ptr m_blank = fb2k::service_new(); + }; +} +metadb_v2_rec_t track_property_provider_v5_info_source_impl::get_info(size_t index) { +#if FOOBAR2000_TARGET_VERSION >= 81 + return m_infos[index]; +#else + if (index < m_infos.get_size()) return m_infos[index]; + else if (index < m_tracks.get_size()) return m_tracks[index]->query_v2_(); + else uBugCheck(); +#endif +} + +track_property_provider_v5_info_source_impl::track_property_provider_v5_info_source_impl(trackListRef items, abort_callback & a) { + +#if FOOBAR2000_TARGET_VERSION >= 81 + m_infos.resize(items.get_count()); + metadb_v2::get()->queryMultiParallel_(items, [this, &a](size_t idx, metadb_v2_rec_t const& rec) {a.check(); this->m_infos[idx] = rec; }); +#else + auto api = metadb_v2::tryGet(); + if (api.is_valid()) { + m_infos.resize(items.get_count()); + api->queryMultiParallel_(items, [this](size_t idx, metadb_v2_rec_t const& rec) {this->m_infos[idx] = rec; }); + return; + } + // pre-2.0 metadb, talking to metadb directly is OK, no need to get info preemptively + m_tracks = items; +#endif +} + +void track_property_provider::enumerate_properties_helper(trackListRef items, track_property_provider_v5_info_source* info, track_property_callback_v2& callback, abort_callback& abort) { + + if (info == nullptr) { + this->enumerate_properties_helper(items, nullptr, callback, abort); + } else { + { + track_property_provider_v5::ptr v5; + if (v5 &= this) { + v5->enumerate_properties_v5(items, *info, callback, abort); + return; + } + } + + track_property_provider_v3_info_source_wrap_v5 wrap; + wrap.chain = info; + this->enumerate_properties_helper(items, &wrap, callback, abort); + } +} + +void track_property_provider::enumerate_properties_helper(trackListRef items, std::nullptr_t, track_property_callback_v2& callback, abort_callback& abort) { + track_property_provider_v5::ptr v5; + if (v5 &= this) { + track_property_provider_v5_info_source_impl infoImpl(items, abort); + v5->enumerate_properties_v5(items, infoImpl, callback, abort); + return; + } + track_property_provider_v3_info_source* dummy = nullptr; + this->enumerate_properties_helper(items, dummy, callback, abort); +} + +void track_property_provider::enumerate_properties_helper(trackListRef items, track_property_provider_v3_info_source * info, track_property_callback_v2 & callback, abort_callback & abort) { + + abort.check(); + + track_property_provider_v2::ptr v2; + if ( ! this->cast( v2 ) ) { + // no v2 + PFC_ASSERT(core_api::is_main_thread()); + this->enumerate_properties( items, callback ); return; + } + + track_property_provider_v3::ptr v3; + if ( ! (v3 &= v2 ) ) { + // no v3 + PFC_ASSERT(core_api::is_main_thread()); + v2->enumerate_properties_v2( items, callback ); return; + } + + track_property_provider_v3_info_source_impl infoFallback ( items ); + if ( info == nullptr ) info = & infoFallback; + + track_property_provider_v4::ptr v4; + if (! ( v4 &= v3 ) ) { + // no v4 + PFC_ASSERT( core_api::is_main_thread() ); + v3->enumerate_properties_v3( items, *info, callback ); + } else { + v4->enumerate_properties_v4( items, *info, callback, abort ); + } +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/track_property.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/track_property.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,131 @@ +#pragma once + +#include "tracks.h" + +class track_property_provider_v5_info_source; +class track_property_provider_v3_info_source; + +//! Callback interface for track_property_provider::enumerate_properties(). +class NOVTABLE track_property_callback { +public: + //! Sets a property list entry to display. Called by track_property_provider::enumerate_properties() implementation. + //! @param p_group Name of group to put the entry in, case-sensitive. Note that non-standard groups are sorted alphabetically. + //! @param p_sortpriority Sort priority of the property inside its group (smaller value means earlier in the list), pass 0 if you don't care (alphabetic order by name used when more than one item has same priority). + //! @param p_name Name of the property. + //! @param p_value Value of the property. + virtual void set_property(const char * p_group,double p_sortpriority,const char * p_name,const char * p_value) = 0; +protected: + track_property_callback() {} + ~track_property_callback() {} + track_property_callback(track_property_callback const &) {}; + void operator=(track_property_callback const &) {}; +}; + +//! Extended version of track_property_callback +class NOVTABLE track_property_callback_v2 : public track_property_callback { +public: + //! Returns a boolean value indicating whether the specified group is wanted; can be used to suppress expensive processing of information that will not be actually shown. \n + //! See also set_property() p_group parameter. + virtual bool is_group_wanted(const char * p_group) = 0; +protected: + ~track_property_callback_v2() {} +}; + +//! \since 1.3 +class NOVTABLE track_property_provider_v3_info_source { +public: + virtual trackInfoContainer::ptr get_info(size_t index) = 0; + +protected: + track_property_provider_v3_info_source() {} + ~track_property_provider_v3_info_source() {} + track_property_provider_v3_info_source( const track_property_provider_v3_info_source & ) {}; + void operator=( const track_property_provider_v3_info_source & ) {}; +}; + +//! Service for adding custom entries in "Properties" tab of the properties dialog. +class NOVTABLE track_property_provider : public service_base { +public: + //! Enumerates properties of specified track list. + //! @param p_tracks List of tracks to enumerate properties on. + //! @param p_out Callback interface receiving enumerated properties. + virtual void enumerate_properties(trackListRef p_tracks, track_property_callback & p_out) = 0; + //! Returns whether specified tech info filed is processed by our service and should not be displayed among unknown fields. + //! @param p_name Name of tech info field being queried. + //! @returns True if the field is among fields processed by this track_property_provider implementation and should not be displayed among unknown fields, false otherwise. + virtual bool is_our_tech_info(const char * p_name) = 0; + + + //! Helper; calls modern versions of this API where appropriate. + //! @param items List of tracks to enumerate properties on. + //! @param info Callback object to fetch info from. Pass null to use a generic implementation querying the metadb. + //! @param callback Callback interface receiving enumerated properties. + //! @param abort The aborter for this operation. + void enumerate_properties_helper(trackListRef items, track_property_provider_v3_info_source * info, track_property_callback_v2 & callback, abort_callback & abort); + void enumerate_properties_helper(trackListRef items, track_property_provider_v5_info_source* info, track_property_callback_v2& callback, abort_callback& abort); + void enumerate_properties_helper(trackListRef items, std::nullptr_t, track_property_callback_v2& callback, abort_callback& abort); + + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(track_property_provider); +}; + +class NOVTABLE track_property_provider_v2 : public track_property_provider { + FB2K_MAKE_SERVICE_INTERFACE(track_property_provider_v2,track_property_provider) +public: + virtual void enumerate_properties_v2(trackListRef p_tracks, track_property_callback_v2 & p_out) = 0; +}; + + +//! \since 1.3 +class NOVTABLE track_property_provider_v3 : public track_property_provider_v2 { + FB2K_MAKE_SERVICE_INTERFACE(track_property_provider_v3,track_property_provider_v2) +public: + virtual void enumerate_properties_v3(trackListRef items, track_property_provider_v3_info_source & info, track_property_callback_v2 & callback) = 0; + + void enumerate_properties(trackListRef p_tracks, track_property_callback & p_out) override; + void enumerate_properties_v2(trackListRef p_tracks, track_property_callback_v2 & p_out) override; +}; + +template +class track_property_provider_factory_t : public service_factory_single_t {}; + +//! \since 1.5 +//! Adds abortability on top of track_property_provider_v3 interface. \n +//! The previous revisions of this API were only legal to call from the main thread. \n +//! track_property_provider_v4 implementers should make NO ASSUMPTIONS about the thread they are in. \n +//! Implementing track_property_provider_v4 declares your class as safe to call from any thread. \n +//! If called via enumerate_properties_v4() method or off-main-thread, the implementation can assume the info source object to be thread-safe. +class NOVTABLE track_property_provider_v4 : public track_property_provider_v3 { + FB2K_MAKE_SERVICE_INTERFACE(track_property_provider_v4, track_property_provider_v3 ); +public: + void enumerate_properties_v3(trackListRef items, track_property_provider_v3_info_source & info, track_property_callback_v2 & callback) override; + + virtual void enumerate_properties_v4(trackListRef items, track_property_provider_v3_info_source & info, track_property_callback_v2 & callback, abort_callback & abort) = 0; +}; + +//! \since 2.0 +//! Allows metadb v2 info records to be handed over transparently. +class NOVTABLE track_property_provider_v5_info_source { +public: + virtual metadb_v2_rec_t get_info(size_t index) = 0; +}; + +//! \since 2.0 +//! Allows metadb v2 info records to be handed over transparently. +class NOVTABLE track_property_provider_v5 : public track_property_provider_v4 { + FB2K_MAKE_SERVICE_INTERFACE(track_property_provider_v5, track_property_provider_v4); +public: + void enumerate_properties_v4(trackListRef items, track_property_provider_v3_info_source& info, track_property_callback_v2& callback, abort_callback& abort) override; + + virtual void enumerate_properties_v5(trackListRef items, track_property_provider_v5_info_source& info, track_property_callback_v2& callback, abort_callback& abort) = 0; +}; + +class track_property_provider_v5_info_source_impl : public track_property_provider_v5_info_source { +public: + track_property_provider_v5_info_source_impl(trackListRef items, abort_callback &a); + metadb_v2_rec_t get_info(size_t index) override; +private: + pfc::array_t< metadb_v2_rec_t > m_infos; +#if FOOBAR2000_TARGET_VERSION < 81 + metadb_handle_list m_tracks; +#endif +}; \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/tracks.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/tracks.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,37 @@ +#pragma once + +// Special header with fb2k mobile metadb<=>trackList interop wrappers + +#include "metadb.h" +#include "titleformat.h" + +typedef metadb_handle_ptr trackRef; +typedef metadb_handle_list_cref trackListRef; +typedef metadb_handle_list trackListStore; +typedef metadb_info_container trackInfoContainer; + +inline size_t trackCount(trackListRef l) {return l.get_size();} +inline trackRef trackListGetTrack(trackListRef l, size_t n) { return l[n]; } + +// Returns blank info if no info is known, never null. +inline trackInfoContainer::ptr trackGetInfoRef(trackRef t) { return t->get_info_ref(); } +inline trackInfoContainer::ptr trackGetInfoRef(trackListRef l, size_t n) { return trackGetInfoRef(l[n]); } + +// Returns null info if no info is known, contrary to trackGetInfoRef +inline trackInfoContainer::ptr trackGetInfo(trackRef t) { trackInfoContainer::ptr ret; if(!t->get_info_ref(ret)) ret = nullptr; return ret; } +inline trackInfoContainer::ptr trackGetInfo(trackListRef l, size_t n) { return trackGetInfo(l[n]); } + +// Returns const char* or pfc::string8 depending on which fb2k! +inline const char * trackGetPath(trackListRef l, size_t n) { return l[n]->get_path(); } +inline const char * trackGetPath(trackRef t) { return t->get_path(); } + +// Returns const playable_location& or playable_location_impl depending on which fb2k! +inline playable_location const & trackGetLocation(trackListRef l, size_t n) { return l[n]->get_location(); } +inline playable_location const & trackGetLocation(trackRef t) { return t->get_location(); } + +inline double trackGetLength(trackListRef l, size_t n) { return l[n]->get_length(); } +inline double trackGetLength(trackRef t) { return t->get_length(); } + +inline void trackFormatTitle(trackRef trk, titleformat_hook * hook, pfc::string_base & out, service_ptr_t script, titleformat_text_filter * filter) { + trk->format_title(hook, out, script, filter); +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/ui.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/ui.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,99 @@ +#include "foobar2000-sdk-pch.h" +#include "ui_edit_context.h" +#include "ui.h" +#include "genrand.h" + +#ifdef _WIN32 +bool ui_drop_item_callback::g_on_drop(interface IDataObject * pDataObject) +{ + for (auto ptr : enumerate()) { + if (ptr->on_drop(pDataObject)) return true; + } + return false; +} + +bool ui_drop_item_callback::g_is_accepted_type(interface IDataObject * pDataObject, DWORD * p_effect) +{ + for (auto ptr : enumerate()) { + if (ptr->is_accepted_type(pDataObject, p_effect)) return true; + } + return false; +} +#endif // _WIN32 + +bool user_interface::g_find(service_ptr_t & p_out,const GUID & p_guid) +{ + for (auto ptr : enumerate()) { + if (ptr->get_guid() == p_guid) { + p_out = ptr; + return true; + } + } + return false; +} + +// ui_edit_context.h code + +void ui_edit_context::select_all() { update_selection(pfc::bit_array_true(), pfc::bit_array_true()); } +void ui_edit_context::select_none() { update_selection(pfc::bit_array_true(), pfc::bit_array_false()); } +void ui_edit_context::get_selected_items(metadb_handle_list_ref out) { pfc::bit_array_bittable mask(get_item_count()); get_selection_mask(mask); get_items(out, mask); } +void ui_edit_context::remove_selection() { pfc::bit_array_bittable mask(get_item_count()); get_selection_mask(mask); remove_items(mask); } +void ui_edit_context::crop_selection() { pfc::bit_array_bittable mask(get_item_count()); get_selection_mask(mask); remove_items(pfc::bit_array_not(mask)); } +void ui_edit_context::clear() { remove_items(pfc::bit_array_true()); } +void ui_edit_context::get_all_items(metadb_handle_list_ref out) { get_items(out, pfc::bit_array_true()); } + +void ui_edit_context::get_selection_mask(pfc::bit_array_var & out) { + const t_size count = get_item_count(); for (t_size walk = 0; walk < count; ++walk) out.set(walk, is_item_selected(walk)); +} + +t_size ui_edit_context::get_selection_count(t_size max) { + t_size count = 0; + const t_size total = get_item_count(); + for (t_size walk = 0; walk < total && count < max; ++walk) if (is_item_selected(walk)) ++count; + return count; +} + +void ui_edit_context::sort_by_format(const char * spec, bool onlySelection) { + const t_size count = get_item_count(); + pfc::array_t order; order.set_size(count); + pfc::array_t sel_map; + if (onlySelection) { + sel_map.set_size(count); + t_size sel_count = 0; + for (t_size n = 0; n order_temp; + if (onlySelection) { + get_selected_items(temp); + order_temp.set_size(count); + } else { + get_all_items(temp); + } + + + if (spec != NULL) { + temp.sort_by_format_get_order(onlySelection ? order_temp.get_ptr() : order.get_ptr(), spec, 0); + } else { + auto api = genrand_service::get(); api->seed(); + api->generate_random_order(onlySelection ? order_temp.get_ptr() : order.get_ptr(), temp.get_count()); + } + + if (onlySelection) { + t_size n, ptr; + for (n = 0, ptr = 0; n to register, e.g static user_interface_factory_t g_myclass_factory; +class NOVTABLE user_interface : public service_base { + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(user_interface); +public: +#ifdef _WIN32 + //!HookProc usage: \n + //! in your windowproc, call HookProc first, and if it returns true, return LRESULT value it passed to you + typedef BOOL (WINAPI * HookProc_t)(HWND wnd,UINT msg,WPARAM wp,LPARAM lp,LRESULT * ret); +#else + typedef void* HookProc_t; // RESERVED +#endif + //! Retrieves name (UTF-8 null-terminated string) of the UI module. + virtual const char * get_name()=0; + //! Initializes the UI module - creates the main app window, etc. Failure should be signaled by appropriate exception (std::exception or a derivative). \n + //! Mac OS: return NSWindow cast to hwnd_t + virtual fb2k::hwnd_t init(HookProc_t hook) = 0; + //! Deinitializes the UI module - destroys the main app window, etc. + virtual void shutdown()=0; + //! Activates main app window. + virtual void activate()=0; + //! Minimizes/hides main app window. + virtual void hide()=0; + //! Returns whether main window is visible / not minimized. Used for activate/hide command. + virtual bool is_visible() = 0; + //! Retrieves GUID of your implementation, to be stored in configuration file etc. + virtual GUID get_guid() = 0; + + //! Overrides statusbar text with specified string. The parameter is a null terminated UTF-8 string. The override is valid until another override_statusbar_text() call or revert_statusbar_text() call. + virtual void override_statusbar_text(const char * p_text) = 0; + //! Disables statusbar text override. + virtual void revert_statusbar_text() = 0; + + //! Shows now-playing item somehow (e.g. system tray popup). + virtual void show_now_playing() = 0; + + static bool g_find(service_ptr_t & p_out,const GUID & p_guid); +}; + +template +class user_interface_factory : public service_factory_single_t {}; + +//! \since 1.4 +//! Extended version to allow explicit control over certain app features. +class NOVTABLE user_interface_v2 : public user_interface { + FB2K_MAKE_SERVICE_INTERFACE( user_interface_v2, user_interface ); +public: + //! Allows the core to ask the UI module about a specific feature. + virtual bool query_capability( const GUID & cap ) = 0; + +#ifdef _WIN32 + //! Suppress core's shellhook window for intercepting systemwide WM_APPCOMMAND? \n + //! Recommended: false - return true only if your UI does this on its own. + static const GUID cap_suppress_core_shellhook; + //! Suppress coer's integration with with Win10 Universal Volume Control? \n + //! Recommended: false - return true only if your UI is explicitly incompatbile with Win10 UVC. \n + //! Note that cap_suppress_core_shellhook is queried first, as core can't use UVC if this UI does global WM_APPCOMMAND handling on its own. \n + //! Returning true from cap_suppress_core_shellhook implies the same from cap_suppress_core_uvc. + static const GUID cap_suppress_core_uvc; +#endif +}; + +class ui_config_manager; + +//! \since 2.0 +class NOVTABLE user_interface_v3 : public user_interface_v2 { + FB2K_MAKE_SERVICE_INTERFACE(user_interface_v3, user_interface_v2); +public: + virtual service_ptr_t< ui_config_manager > get_config_manager() = 0; +}; + +//! \since 2.1 +class NOVTABLE user_interface_v4 : public user_interface_v3 { + FB2K_MAKE_SERVICE_INTERFACE(user_interface_v4, user_interface_v3); +public: + static constexpr uint32_t flagHide = 1; + virtual fb2k::hwnd_t init_v4(HookProc_t hook, uint32_t flags) = 0; +}; + +//! Interface class allowing you to override UI statusbar text. There may be multiple callers trying to override statusbar text; backend decides which one succeeds so you will not always get what you want. Statusbar text override is automatically cancelled when the object is released.\n +//! Use ui_control::override_status_text_create() to instantiate. +//! Implemented by core. Do not reimplement. +class NOVTABLE ui_status_text_override : public service_base +{ +public: + //! Sets statusbar text to specified UTF-8 null-terminated string. + virtual void override_text(const char * p_message) = 0; + //! Cancels statusbar text override. + virtual void revert_text() = 0; + + FB2K_MAKE_SERVICE_INTERFACE(ui_status_text_override,service_base); +}; + +//! Serivce providing various UI-related commands. Implemented by core; do not reimplement. +//! Instantiation: use ui_control::get() to obtain an instance. +class NOVTABLE ui_control : public service_base { + FB2K_MAKE_SERVICE_COREAPI(ui_control); +public: + //! Returns whether primary UI is visible/unminimized. + virtual bool is_visible()=0; + //! Activates/unminimizes main UI. + virtual void activate()=0; + //! Hides/minimizese main UI. + virtual void hide()=0; + +#ifdef _WIN32 + //! Retrieves main GUI icon, to use as window icon etc. Returned handle does not need to be freed. + virtual fb2k::hicon_t get_main_icon()=0; + //! Loads main GUI icon, version with specified width/height. Returned handle needs to be freed with DestroyIcon when you are done using it. + virtual fb2k::hicon_t load_main_icon(unsigned width,unsigned height) = 0; +#endif + //! Activates preferences dialog and navigates to specified page. See also: preference_page API. \n + //! Since foobar2000 1.5, this can be used to show advanced preferences branches or settings, just pass GUID of the advconfig_entry you wish to show. + virtual void show_preferences(const GUID & p_page) = 0; + + //! Instantiates ui_status_text_override service, that can be used to display status messages. + //! @param p_out receives new ui_status_text_override instance. + //! @returns true on success, false on failure (out of memory / no GUI loaded / etc) + virtual bool override_status_text_create(service_ptr_t & p_out) = 0; +}; + +typedef ui_status_text_override ui_status_host; + +//! \since 1.5 +class NOVTABLE ui_control_v2 : public ui_control { + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(ui_control_v2, ui_control) +public: + virtual void register_status_host(fb2k::hwnd_t wndFor, ui_status_host::ptr obj) = 0; + virtual void unregister_status_host(fb2k::hwnd_t wndFor) = 0; +}; + +#ifdef _WIN32 +//! Service called from the UI when some object is dropped into the UI. Usable for modifying drag&drop behaviors such as adding custom handlers for object types other than supported media files.\n +//! Implement where needed; use ui_drop_item_callback_factory_t<> template to register, e.g. static ui_drop_item_callback_factory_t g_myclass_factory. +class NOVTABLE ui_drop_item_callback : public service_base { +public: + //! Called when an object was dropped; returns true if the object was processed and false if not. + virtual bool on_drop(interface IDataObject * pDataObject) = 0; + //! Tests whether specified object type is supported by this ui_drop_item_callback implementation. Returns true and sets p_effect when it's supported; returns false otherwise. \n + //! See IDropTarget::DragEnter() documentation for more information about p_effect values. + virtual bool is_accepted_type(interface IDataObject * pDataObject, DWORD * p_effect)=0; + + //! Static helper, calls all existing implementations appropriately. See on_drop(). + static bool g_on_drop(interface IDataObject * pDataObject); + //! Static helper, calls all existing implementations appropriately. See is_accepted_type(). + static bool g_is_accepted_type(interface IDataObject * pDataObject, DWORD * p_effect); + + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(ui_drop_item_callback); +}; + +template +class ui_drop_item_callback_factory_t : public service_factory_single_t {}; +#endif + +class ui_selection_callback; + +//! Write interface and reference counter for the shared selection. +//! The ui_selection_manager stores the selected items as a list. +//! The ui_selection_holder service allows components to modify this list. +//! It also serves as a reference count: the ui_selection_manager clears the stored +//! selection when no component holds a reference to a ui_selection_holder. +//! +//! When a window that uses the shared selection gets the focus, it should acquire +//! a ui_selection_holder from the ui_selection_manager. If it contains selectable items, +//! it should use the appropriate method to store its selected items as the shared selection. +//! If it just wants to preserve the selection - for example so it can display it - it should +//! merely store the acquired ui_selection_holder. +//! +//! When the window loses the focus, it should release its ui_selection_holder. +//! It should not use a set method to clear the selection +class NOVTABLE ui_selection_holder : public service_base { +public: + //! Sets selected items. + virtual void set_selection(metadb_handle_list_cref data) = 0; + //! Sets selected items to playlist selection and enables tracking. + //! When the playlist selection changes, the stored selection is automatically updated. + //! Tracking ends when a set method is called on any ui_selection_holder or when + //! the last reference to this ui_selection_holder is released. + virtual void set_playlist_selection_tracking() = 0; + //! Sets selected items to the contents of the active playlist and enables tracking. + //! When the active playlist or its contents changes, the stored selection is automatically updated. + //! Tracking ends when a set method is called on any ui_selection_holder or when + //! the last reference to this ui_selection_holder is released. + virtual void set_playlist_tracking() = 0; + + //! Sets selected items and type of selection holder. + //! @param type Specifies type of selection. Values same as contextmenu_item caller IDs. + virtual void set_selection_ex(metadb_handle_list_cref data, const GUID & type) = 0; + + FB2K_MAKE_SERVICE_INTERFACE(ui_selection_holder,service_base); +}; + +class NOVTABLE ui_selection_manager : public service_base { + FB2K_MAKE_SERVICE_COREAPI(ui_selection_manager); +public: + //! Retrieves the current selection. + virtual void get_selection(metadb_handle_list_ref p_selection) = 0; + //! Registers a callback. It is recommended to use ui_selection_callback_impl_base class instead of calling this directly. + virtual void register_callback(ui_selection_callback * p_callback) = 0; + //! Unregisters a callback. It is recommended to use ui_selection_callback_impl_base class instead of calling this directly. + virtual void unregister_callback(ui_selection_callback * p_callback) = 0; + + virtual ui_selection_holder::ptr acquire() = 0; + + //! Retrieves type of the active selection holder. Values same as contextmenu_item caller IDs. + virtual GUID get_selection_type() = 0; +}; + +//! \since 1.0 +class NOVTABLE ui_selection_manager_v2 : public ui_selection_manager { + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(ui_selection_manager_v2, ui_selection_manager) +public: + enum { flag_no_now_playing = 1 }; + virtual void get_selection(metadb_handle_list_ref out, t_uint32 flags) = 0; + virtual GUID get_selection_type(t_uint32 flags) = 0; + virtual void register_callback(ui_selection_callback * callback, t_uint32 flags) = 0; +}; + +//! \since 2.0 +class NOVTABLE ui_selection_manager_v3 : public ui_selection_manager_v2 { + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(ui_selection_manager_v3, ui_selection_manager_v2) +public: + virtual void add_callback_scope(ui_selection_callback* cb,const GUID & scope) = 0; + virtual bool is_scope_watched(const GUID& scope) = 0; +}; + +class ui_selection_callback { +public: + virtual void on_selection_changed(metadb_handle_list_cref p_selection) = 0; +protected: + ui_selection_callback() {} + ~ui_selection_callback() {} +}; + +//! ui_selection_callback implementation helper with autoregistration - do not instantiate statically +class ui_selection_callback_impl_base : public ui_selection_callback { +protected: + ui_selection_callback_impl_base(bool activate = true) : m_active() {ui_selection_callback_activate(activate);} + ~ui_selection_callback_impl_base() {ui_selection_callback_activate(false);} + + void ui_selection_callback_activate(bool state = true) { + if (state != m_active) { + m_active = state; + auto api = ui_selection_manager::get(); + if (state) api->register_callback(this); + else api->unregister_callback(this); + } + } + + //avoid pure virtual function calls in rare cases - provide a dummy implementation + void on_selection_changed(metadb_handle_list_cref p_selection) override { (void)p_selection; } + + PFC_CLASS_NOT_COPYABLE_EX(ui_selection_callback_impl_base); +private: + bool m_active; +}; + +//! \since 1.0 +//! ui_selection_callback implementation helper with autoregistration - do not instantiate statically +template +class ui_selection_callback_impl_base_ex : public ui_selection_callback { +protected: + enum { + ui_selection_flags = flags + }; + ui_selection_callback_impl_base_ex(bool activate = true) : m_active() {ui_selection_callback_activate(activate);} + ~ui_selection_callback_impl_base_ex() {ui_selection_callback_activate(false);} + + void ui_selection_callback_activate(bool state = true) { + if (state != m_active) { + m_active = state; + auto api = ui_selection_manager_v2::get(); + if (state) api->register_callback(this, flags); + else api->unregister_callback(this); + } + } + + //avoid pure virtual function calls in rare cases - provide a dummy implementation + void on_selection_changed(metadb_handle_list_cref p_selection) override {} + + PFC_CLASS_NOT_COPYABLE(ui_selection_callback_impl_base_ex, ui_selection_callback_impl_base_ex); +private: + bool m_active; +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/ui_edit_context.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/ui_edit_context.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,109 @@ +#pragma once + +//! A class used to redirect actions coming from the 'edit' menu, typically provided by the UI Element having focus. \n +//! Use ui_edit_context_manager to register and manipulate. +class NOVTABLE ui_edit_context : public service_base { + FB2K_MAKE_SERVICE_INTERFACE(ui_edit_context, service_base) +public: + //! Called by core only. + virtual void initialize() = 0; + //! Called by core only. \n + //! WARNING: you may get other methods called after shutdown() in case someone using ui_edit_context_manager has kept a reference to your service - for an example during an async operation. You should behave sanely in such case - either execute the operation if still possible or fail cleanly. + virtual void shutdown() = 0; + + enum { + flag_removable = 1, + flag_reorderable = 2, + flag_undoable = 4, + flag_redoable = 8, + flag_linearlist = 16, + flag_searchable = 32, + flag_insertable = 64, + }; + + virtual t_uint32 get_flags() = 0; + + bool can_remove() {return (get_flags() & flag_removable) != 0;} + bool test_flags(t_uint32 flags) {return (get_flags() & flags) == flags;} + bool can_remove_mask() {return test_flags(flag_removable | flag_linearlist);} + bool can_reorder() {return test_flags(flag_reorderable);} + bool can_search() {return test_flags(flag_searchable);} + + virtual void select_all(); + virtual void select_none(); + virtual void get_selected_items(metadb_handle_list_ref out); + virtual void remove_selection(); + virtual void crop_selection(); + virtual void clear(); + virtual void get_all_items(metadb_handle_list_ref out); + virtual GUID get_selection_type() = 0; + + // available if flag_linearlist is set + virtual void get_selection_mask(pfc::bit_array_var & out); + + virtual void update_selection(const pfc::bit_array & mask, const pfc::bit_array & newVals) = 0; + virtual t_size get_item_count(t_size max = ~0) = 0; + virtual metadb_handle_ptr get_item(t_size index) = 0; + virtual void get_items(metadb_handle_list_ref out, pfc::bit_array const & mask) = 0; + virtual bool is_item_selected(t_size item) = 0; + virtual void remove_items(pfc::bit_array const & mask) = 0; + virtual void reorder_items(const t_size * order, t_size count) = 0; + virtual t_size get_selection_count(t_size max = ~0); + + virtual void search() = 0; + + virtual void undo_backup() = 0; + virtual void undo_restore() = 0; + virtual void redo_restore() = 0; + + virtual void insert_items(t_size at, metadb_handle_list_cref items, pfc::bit_array const & selection) = 0; + + virtual t_size query_insert_mark() = 0; + + void sort_by_format(const char * spec, bool onlySelection); + + //! Safely prevent destruction from worker threads (some components attempt that). + static bool serviceRequiresMainThreadDestructor() { return true; } +}; + +//! Special case of ui_edit_context operating on a specific playlist (see playlist_manager). \n +//! Use this to let everyone know that your methods operate on a playlist, \n +//! in case some component wishes to provide additional functionality based on that. +class ui_edit_context_playlist : public ui_edit_context { + FB2K_MAKE_SERVICE_INTERFACE(ui_edit_context_playlist, ui_edit_context) +public: + virtual t_size get_playlist_number() = 0; +}; + +//! Entrypoint class for registering and manipulating ui_edit_context objects. \n +//! Implemented by core. +class NOVTABLE ui_edit_context_manager : public service_base { + FB2K_MAKE_SERVICE_COREAPI(ui_edit_context_manager) +public: + //! Sets the current edit context. \n + //! Typically called when a part of your UI receives focus. \n + //! @returns An identifier than can later be passed to unset_context when focus is lost. + virtual t_uint32 set_context(ui_edit_context::ptr context) = 0; + //! Removes an edit context. \n + //! @param id The value returned by matching set_context() call. + virtual void unset_context(t_uint32 id) = 0; + //! Retrieves the current context object. May return null when there's no context. + //! @returns The currently active context object, possibly null if none. + virtual ui_edit_context::ptr get_context() = 0; + //! Creates a context wrapping a specific playlist; see also playlist_manager. + //! @param playlist_number Number of wrapped playlist, per playlist_manager numbering. + //! @returns Newly creted context object. + virtual ui_edit_context::ptr create_playlist_context(t_size playlist_number) = 0; + //! By default, when no context is registered, \n + //! for an example, if the active user interface component is not ui_edit_context-aware, \n + //! a fallback context is automatically set; it follows the active playlist,\n + //! so the edit menu does something meaningful. \n + //! This method is intended to be called during initialiation of an user interface component; \n + //! it tells foobar2000 core to suppress the active playlist fallback-\n + //! but then entire edit menu becomes non-functional if no context is provided. + virtual void disable_autofallback() = 0; + //! Helper, sets the current context to an implemented-by-core context that tracks the active playlist. \n + //! Typically called when a part of your UI receives focus. + //! @returns Identifier value to pass to unset_context() when your focus is gone. + virtual t_uint32 set_context_active_playlist() = 0; +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/ui_element.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/ui_element.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,275 @@ +#include "foobar2000-sdk-pch.h" +#include "ui_element.h" + + +namespace { + class ui_element_config_impl : public ui_element_config { + public: + ui_element_config_impl(const GUID & guid) : m_guid(guid) {} + ui_element_config_impl(const GUID & guid, const void * buffer, t_size size) : m_guid(guid) { + m_content.set_data_fromptr(reinterpret_cast(buffer),size); + } + + void * get_data_var() {return m_content.get_ptr();} + void set_data_size(t_size size) {m_content.set_size(size);} + + GUID get_guid() const {return m_guid;} + const void * get_data() const {return m_content.get_ptr();} + t_size get_data_size() const {return m_content.get_size();} + private: + const GUID m_guid; + pfc::array_t m_content; + }; + +} + +service_ptr_t ui_element_config::g_create(const GUID& id, const void * data, t_size size) { + return new service_impl_t(id,data,size); +} + +service_ptr_t ui_element_config::g_create(const GUID & id, stream_reader * in, t_size bytes, abort_callback & abort) { + service_ptr_t data = new service_impl_t(id); + data->set_data_size(bytes); + in->read_object(data->get_data_var(),bytes,abort); + return data; +} + +service_ptr_t ui_element_config::g_create(stream_reader * in, t_size bytes, abort_callback & abort) { + if (bytes < sizeof(GUID)) throw exception_io_data_truncation(); + GUID id; + { stream_reader_formatter<> str(*in,abort); str >> id;} + return g_create(id,in,bytes - sizeof(GUID),abort); +} + +ui_element_config::ptr ui_element_config_parser::subelement(t_size size) { + return ui_element_config::g_create(&m_stream, size, m_abort); +} +ui_element_config::ptr ui_element_config_parser::subelement(const GUID & id, t_size dataSize) { + return ui_element_config::g_create(id, &m_stream, dataSize, m_abort); +} + +service_ptr_t ui_element_config::g_create(const void * data, t_size size) { + stream_reader_memblock_ref stream(data,size); + return g_create(&stream,size,fb2k::noAbort); +} + +#ifdef _WIN32 + +namespace { + struct sysColorMapping_t { + GUID guid; int idx; + }; + static const sysColorMapping_t sysColorMapping[] = { + { ui_color_text, COLOR_WINDOWTEXT }, + { ui_color_background, COLOR_WINDOW }, + { ui_color_highlight, COLOR_HOTLIGHT }, + {ui_color_selection, COLOR_HIGHLIGHT}, + }; +} +int ui_color_to_sys_color_index(const GUID & p_guid) { + for( unsigned i = 0; i < PFC_TABSIZE( sysColorMapping ); ++ i ) { + if ( p_guid == sysColorMapping[i].guid ) return sysColorMapping[i].idx; + } + return -1; +} +GUID ui_color_from_sys_color_index(int idx) { + for (unsigned i = 0; i < PFC_TABSIZE(sysColorMapping); ++i) { + if (idx == sysColorMapping[i].idx) return sysColorMapping[i].guid; + } + return pfc::guid_null; +} +#endif // _WIN32 + +bool ui_element_subclass_description(const GUID & id, pfc::string_base & p_out) { + if (id == ui_element_subclass_playlist_renderers) { + p_out = "Playlist Renderers"; return true; + } else if (id == ui_element_subclass_media_library_viewers) { + p_out = "Media Library Viewers"; return true; + } else if (id == ui_element_subclass_selection_information) { + p_out = "Selection Information"; return true; + } else if (id == ui_element_subclass_playback_visualisation) { + p_out = "Playback Visualization"; return true; + } else if (id == ui_element_subclass_playback_information) { + p_out = "Playback Information"; return true; + } else if (id == ui_element_subclass_utility) { + p_out = "Utility"; return true; + } else if (id == ui_element_subclass_containers) { + p_out = "Containers"; return true; + } else if ( id == ui_element_subclass_dsp ) { + p_out = "DSP"; return true; + } else { + return false; + } +} + +bool ui_element::get_element_group(pfc::string_base & p_out) { + return ui_element_subclass_description(get_subclass(),p_out); +} + +t_ui_color ui_element_instance_callback::query_std_color(const GUID & p_what) { +#ifdef _WIN32 + t_ui_color ret; + if (query_color(p_what,ret)) return ret; + int idx = ui_color_to_sys_color_index(p_what); + if (idx < 0) return 0;//should not be triggerable + return GetSysColor(idx); +#else + throw pfc::exception_not_implemented(); +#endif +} +#ifdef _WIN32 +t_ui_color ui_element_instance_callback::getSysColor(int sysColorIndex) { + GUID guid = ui_color_from_sys_color_index( sysColorIndex ); + if ( guid != pfc::guid_null ) return query_std_color(guid); + return GetSysColor(sysColorIndex); +} +#endif + +bool ui_element::g_find(service_ptr_t & out, const GUID & id) { + return service_by_guid(out, id); +} + +bool ui_element::g_get_name(pfc::string_base & p_out,const GUID & p_guid) { + ui_element::ptr ptr; if (!g_find(ptr,p_guid)) return false; + ptr->get_name(p_out); return true; +} + +bool ui_element_instance_callback::is_elem_visible_(service_ptr_t elem) { + ui_element_instance_callback_v2::ptr v2; + if (!this->service_query_t(v2)) { + PFC_ASSERT(!"Should not get here - somebody implemented ui_element_instance_callback but not ui_element_instance_callback_v2."); + return true; + } + return v2->is_elem_visible(elem); +} + +bool ui_element_instance_callback::set_elem_label(ui_element_instance * source, const char * label) { + return notify_(source, ui_element_host_notify_set_elem_label, 0, label, strlen(label)) != 0; +} + +t_uint32 ui_element_instance_callback::get_dialog_texture(ui_element_instance * source) { + return (t_uint32) notify_(source, ui_element_host_notify_get_dialog_texture, 0, NULL, 0); +} + +bool ui_element_instance_callback::is_border_needed(ui_element_instance * source) { + return notify_(source, ui_element_host_notify_is_border_needed, 0, NULL, 0) != 0; +} + +bool ui_element_instance_callback::is_dark_mode() { + t_ui_color clr = 0xFFFFFF; + if (this->query_color(ui_color_darkmode, clr)) return clr == 0; + return false; +} + +t_size ui_element_instance_callback::notify_(ui_element_instance * source, const GUID & what, t_size param1, const void * param2, t_size param2size) { + ui_element_instance_callback_v3::ptr v3; + if (!this->service_query_t(v3)) { PFC_ASSERT(!"Outdated UI Element host implementation"); return 0; } + return v3->notify(source, what, param1, param2, param2size); +} + + +#ifdef _WIN32 +const ui_element_min_max_info & ui_element_min_max_info::operator|=(const ui_element_min_max_info & p_other) { + m_min_width = pfc::max_t(m_min_width,p_other.m_min_width); + m_min_height = pfc::max_t(m_min_height,p_other.m_min_height); + m_max_width = pfc::min_t(m_max_width,p_other.m_max_width); + m_max_height = pfc::min_t(m_max_height,p_other.m_max_height); + return *this; +} +ui_element_min_max_info ui_element_min_max_info::operator|(const ui_element_min_max_info & p_other) const { + ui_element_min_max_info ret(*this); + ret |= p_other; + return ret; +} + +void ui_element_min_max_info::adjustForWindow(HWND wnd) { + RECT client = {0,0,10,10}; + RECT adjusted = client; + BOOL bMenu = FALSE; + const DWORD style = (DWORD) GetWindowLong( wnd, GWL_STYLE ); + if ( style & WS_POPUP ) { + bMenu = GetMenu( wnd ) != NULL; + } + if (AdjustWindowRectEx( &adjusted, style, bMenu, GetWindowLong(wnd, GWL_EXSTYLE) )) { + int dx = (adjusted.right - adjusted.left) - (client.right - client.left); + int dy = (adjusted.bottom - adjusted.top) - (client.bottom - client.top); + if ( dx < 0 ) dx = 0; + if ( dy < 0 ) dy = 0; + m_min_width += dx; + m_min_height += dy; + if ( m_max_width != ~0 ) m_max_width += dx; + if ( m_max_height != ~0 ) m_max_height += dy; + } +} +//! Retrieves element's minimum/maximum window size. Default implementation will fall back to WM_GETMINMAXINFO. +ui_element_min_max_info ui_element_instance::get_min_max_info() { + ui_element_min_max_info ret; + MINMAXINFO temp = {}; + temp.ptMaxTrackSize.x = 1024*1024;//arbitrary huge number + temp.ptMaxTrackSize.y = 1024*1024; + SendMessage(this->get_wnd(),WM_GETMINMAXINFO,0,(LPARAM)&temp); + if (temp.ptMinTrackSize.x >= 0) ret.m_min_width = temp.ptMinTrackSize.x; + if (temp.ptMaxTrackSize.x > 0) ret.m_max_width = temp.ptMaxTrackSize.x; + if (temp.ptMinTrackSize.y >= 0) ret.m_min_height = temp.ptMinTrackSize.y; + if (temp.ptMaxTrackSize.y > 0) ret.m_max_height = temp.ptMaxTrackSize.y; + return ret; +} +#else +ui_element_min_max_info ui_element_instance::get_min_max_info() { + return {}; +} +#endif + +namespace { + class ui_element_replace_dialog_notify_impl : public ui_element_replace_dialog_notify { + public: + void on_cancelled() { + reply(pfc::guid_null); + } + void on_ok(const GUID & guid) { + reply(guid); + } + std::function reply; + }; +} +ui_element_replace_dialog_notify::ptr ui_element_replace_dialog_notify::create(std::function reply) { + auto obj = fb2k::service_new(); + obj->reply = reply; + return obj; +} + +bool ui_config_manager::is_dark_mode() { + PFC_ASSERT(core_api::is_main_thread()); + t_ui_color clr = 0xFFFFFF; + if (this->query_color(ui_color_darkmode, clr)) return clr == 0; + return false; +} +bool ui_config_manager::g_is_dark_mode() { + PFC_ASSERT(core_api::is_main_thread()); + auto api = tryGet(); + if (api.is_valid()) return api->is_dark_mode(); + else return false; +} +#ifdef _WIN32 +t_ui_color ui_config_manager::getSysColor(int sysColorIndex) { + PFC_ASSERT(core_api::is_main_thread()); + GUID guid = ui_color_from_sys_color_index(sysColorIndex); + if (guid != pfc::guid_null) { + t_ui_color ret = 0; + if (query_color(guid, ret)) return ret; + } + return GetSysColor(sysColorIndex); +} +#endif + +ui_config_callback_impl::ui_config_callback_impl() { + PFC_ASSERT(core_api::is_main_thread()); + auto api = ui_config_manager::tryGet(); + if (api.is_valid()) api->add_callback(this); +} + +ui_config_callback_impl::~ui_config_callback_impl() { + PFC_ASSERT(core_api::is_main_thread()); + auto api = ui_config_manager::tryGet(); + if (api.is_valid()) api->remove_callback(this); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/ui_element.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/ui_element.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,662 @@ +#pragma once + +//! Configuration of a UI element instance. +class NOVTABLE ui_element_config : public service_base { +public: + //! Returns GUID of the UI element this configuration data belongs to. + virtual GUID get_guid() const = 0; + //! Returns raw configuration data pointer. + virtual const void * get_data() const = 0; + //! Returns raw configuration data size, in bytes. + virtual t_size get_data_size() const = 0; + + + //! Helper. + static service_ptr_t g_create(const GUID& id, const void * data, t_size size); + + template static service_ptr_t g_create(const GUID& id, t_source const & data) { + pfc::assert_byte_type(); + return g_create(id, data.get_ptr(), data.get_size()); + } + + static service_ptr_t g_create_empty(const GUID & id = pfc::guid_null) {return g_create(id,NULL,0);} + + static service_ptr_t g_create(const GUID & id, stream_reader * in, t_size bytes, abort_callback & abort); + static service_ptr_t g_create(stream_reader * in, t_size bytes, abort_callback & abort); + static service_ptr_t g_create(const void * data, t_size size); + service_ptr_t clone() const { + return g_create(get_guid(), get_data(), get_data_size()); + } + + FB2K_MAKE_SERVICE_INTERFACE(ui_element_config,service_base); +}; + +//! Helper for reading data from ui_element_config. +class ui_element_config_parser : public stream_reader_formatter<> { +public: + ui_element_config_parser(ui_element_config::ptr in) : stream_reader_formatter(_m_stream, fb2k::noAbort), m_data(in), _m_stream(in->get_data(),in->get_data_size()) {} + + void reset() {_m_stream.reset();} + t_size get_remaining() const {return _m_stream.get_remaining();} + + ui_element_config::ptr subelement(t_size size); + ui_element_config::ptr subelement(const GUID & id, t_size dataSize); +private: + const ui_element_config::ptr m_data; + stream_reader_memblock_ref _m_stream; +}; + +//! Helper creating ui_element_config from your data. +class ui_element_config_builder : public stream_writer_formatter<> { +public: + ui_element_config_builder() : stream_writer_formatter(_m_stream,fb2k::noAbort) {} + ui_element_config::ptr finish(const GUID & id) { + return ui_element_config::g_create(id,_m_stream.m_buffer); + } + void reset() { + _m_stream.m_buffer.set_size(0); + } +private: + stream_writer_buffer_simple _m_stream; +}; + + +FB2K_STREAM_WRITER_OVERLOAD(ui_element_config::ptr) { + stream << value->get_guid(); + t_size size = value->get_data_size(); + stream << pfc::downcast_guarded(size); + stream.write_raw(value->get_data(),size); + return stream; +} +FB2K_STREAM_READER_OVERLOAD(ui_element_config::ptr) { + GUID guid; + t_uint32 size; + stream >> guid >> size; + value = ui_element_config::g_create(guid,&stream.m_stream,size,stream.m_abort); + return stream; +} + + +typedef uint32_t t_ui_color; +typedef fb2k::hfont_t t_ui_font; +typedef fb2k::hicon_t t_ui_icon; + +constexpr GUID ui_color_text = { 0x5dd38be7, 0xff8a, 0x416f, { 0x88, 0x2d, 0xa4, 0x8e, 0x31, 0x87, 0x85, 0xb2 } }; +constexpr GUID ui_color_background = { 0x16fc40c1, 0x1cba, 0x4385, { 0x93, 0x3b, 0xe9, 0x32, 0x7f, 0x6e, 0x35, 0x1f } }; +constexpr GUID ui_color_highlight = { 0xd2f98042, 0x3e6a, 0x423a, { 0xb8, 0x66, 0x65, 0x1, 0xfe, 0xa9, 0x75, 0x93 } }; +constexpr GUID ui_color_selection = { 0xebe1a36b, 0x7e0a, 0x469a, { 0x8e, 0xc5, 0xcf, 0x3, 0x12, 0x90, 0x40, 0xb5 } }; +// Special pseudo-color - black or white depending on dark mode state, undefined in fb2k versions that don't recognize dark mode. +constexpr GUID ui_color_darkmode = { 0x9050bca9, 0x4ed, 0x40e9, { 0xb0, 0xfc, 0x9c, 0x67, 0x9c, 0xc2, 0x28, 0x6d } }; + + +constexpr GUID ui_font_default = { 0x9ef02cef, 0xe58a, 0x4f99, { 0x9f, 0xe3, 0x85, 0x39, 0xb, 0xed, 0xc5, 0xe0 } }; +constexpr GUID ui_font_tabs = { 0x65ffd7ac, 0x71ce, 0x495c, { 0xa5, 0x99, 0x48, 0x5b, 0xbf, 0x7a, 0x4, 0x7b } }; +constexpr GUID ui_font_lists = { 0xa86198b3, 0xb5d8, 0x40cf, { 0xac, 0x19, 0xf9, 0xda, 0xc, 0xb5, 0xd4, 0x24 } }; +constexpr GUID ui_font_playlists = { 0xd85b7b7e, 0xbf83, 0x41ed, { 0x88, 0xce, 0x1, 0x99, 0x31, 0x94, 0x3e, 0x2f } }; +constexpr GUID ui_font_statusbar = { 0xc7fd555b, 0xbd15, 0x4f74, { 0x93, 0xe, 0xba, 0x55, 0x52, 0x9d, 0xd9, 0x71 } }; +constexpr GUID ui_font_console = { 0xb08c619d, 0xd3d1, 0x4089, { 0x93, 0xb2, 0xd5, 0xb, 0x87, 0x2d, 0x1a, 0x25 } }; + + +#ifdef _WIN32 + +//! @returns -1 when the GUID is unknown / unmappable, index that can be passed over to GetSysColor() otherwise. +int ui_color_to_sys_color_index(const GUID & p_guid); +GUID ui_color_from_sys_color_index( int idx ); + +struct ui_element_min_max_info { + t_uint32 m_min_width = 0, m_max_width = UINT32_MAX, m_min_height = 0, m_max_height = UINT32_MAX; + + const ui_element_min_max_info & operator|=(const ui_element_min_max_info & p_other); + ui_element_min_max_info operator|(const ui_element_min_max_info & p_other) const; + void adjustForWindow(HWND wnd); +}; + +typedef SIZE ui_size; +typedef RECT ui_rect; +#else +struct ui_element_min_max_info {}; // dummy +struct ui_size { int cx = 0, cy = 0; }; +struct ui_rect { int l = 0, t = 0, r = 0, b = 0; }; +#endif + +//! Callback class passed by a UI element host to a UI element instance, allowing each UI element instance to communicate with its host. \n +//! Each ui_element_instance_callback implementation must also implement ui_element_instance_callback_v2. +class NOVTABLE ui_element_instance_callback : public service_base { + FB2K_MAKE_SERVICE_INTERFACE(ui_element_instance_callback,service_base); +public: + virtual void on_min_max_info_change() = 0; + //! Deprecated, does nothing. + virtual void on_alt_pressed(bool p_state) = 0; + //! Returns true on success, false when the color is undefined and defaults such as global windows settings should be used. + virtual bool query_color(const GUID & p_what,t_ui_color & p_out) = 0; + //! Tells the host that specified element wants to activate itself as a result of some kind of external user command (eg. menu command). Host should ensure that requesting child element's window is visible.\n + //! @returns True when relevant child element window has been properly made visible and requesting code should proceed to SetFocus their window etc, false when denied. + virtual bool request_activation(service_ptr_t p_item) = 0; + + //! Queries whether "edit mode" is enabled. Most of UI element editing functionality should be locked when it's not. + virtual bool is_edit_mode_enabled() = 0; + + //! Tells the host that the user has requested the element to be replaced with another one. + //! Note: this is generally used only when "edit mode" is enabled, but legal to call when it's not (eg. dummy element calls it regardless of settings when clicked). + virtual void request_replace(service_ptr_t p_item) = 0; + + //! Deprecated - use query_font_ex. Equivalent to query_font_ex(ui_font_default). + t_ui_font query_font() {return query_font_ex(ui_font_default);} + + //! Retrieves an user-configurable font to use for specified kind of display. See ui_font_* constant for possible parameters. + virtual t_ui_font query_font_ex(const GUID & p_what) = 0; + + //! Helper - a wrapper around query_color(), if the color is not user-overridden, returns relevant system color. + t_ui_color query_std_color(const GUID & p_what); +#ifdef _WIN32 + t_ui_color getSysColor( int sysColorIndex ); +#endif + + bool is_elem_visible_(service_ptr_t elem); + + t_size notify_(ui_element_instance * source, const GUID & what, t_size param1, const void * param2, t_size param2size); + bool set_elem_label(ui_element_instance * source, const char * label); + t_uint32 get_dialog_texture(ui_element_instance * source); + bool is_border_needed(ui_element_instance * source); + + bool is_dark_mode(); +}; + + +class NOVTABLE ui_element_instance_callback_v2 : public ui_element_instance_callback { + FB2K_MAKE_SERVICE_INTERFACE(ui_element_instance_callback_v2, ui_element_instance_callback); +public: + virtual bool is_elem_visible(service_ptr_t elem) = 0; +}; + +class NOVTABLE ui_element_instance_callback_v3 : public ui_element_instance_callback_v2 { + FB2K_MAKE_SERVICE_INTERFACE(ui_element_instance_callback_v3, ui_element_instance_callback_v2) +public: + //! Returns zero when the notification was not handled, return value depends on the notification otherwise. + virtual t_size notify(ui_element_instance * source, const GUID & what, t_size param1, const void * param2, t_size param2size) = 0; +}; + +typedef service_ptr_t ui_element_instance_callback_ptr; + +//! ui_element_instance_callback implementation helper. +template class ui_element_instance_callback_impl : public ui_element_instance_callback_v3 { +public: + ui_element_instance_callback_impl(t_receiver * p_receiver) : m_receiver(p_receiver) {} + void on_min_max_info_change() { + if (m_receiver != NULL) m_receiver->on_min_max_info_change(); + } + void on_alt_pressed(bool p_state) { (void)p_state; } + + bool query_color(const GUID & p_what,t_ui_color & p_out) { + if (m_receiver != NULL) return m_receiver->query_color(p_what,p_out); + else return false; + } + + bool request_activation(service_ptr_t p_item) { + if (m_receiver) return m_receiver->request_activation(p_item); + else return false; + } + + bool is_edit_mode_enabled() { + if (m_receiver) return m_receiver->is_edit_mode_enabled(); + else return false; + } + void request_replace(service_ptr_t p_item) { + if (m_receiver) m_receiver->request_replace(p_item); + } + + t_ui_font query_font_ex(const GUID & p_what) { + if (m_receiver) return m_receiver->query_font_ex(p_what); + else return NULL; + } + + void orphan() {m_receiver = NULL;} + + bool is_elem_visible(service_ptr_t elem) { + if (m_receiver) return m_receiver->is_elem_visible(elem); + else return false; + } + t_size notify(ui_element_instance * source, const GUID & what, t_size param1, const void * param2, t_size param2size) { + if (m_receiver) return m_receiver->host_notify(source, what, param1, param2, param2size); + else return 0; + } +private: + t_receiver * m_receiver; +}; + +//! ui_element_instance_callback implementation helper. +class ui_element_instance_callback_receiver { +public: + virtual void on_min_max_info_change() {} + virtual bool query_color(const GUID& p_what, t_ui_color& p_out) { (void)p_what; (void)p_out; return false; } + virtual bool request_activation(service_ptr_t p_item) { (void)p_item; return false; } + virtual bool is_edit_mode_enabled() {return false;} + virtual void request_replace(service_ptr_t p_item) {} + virtual t_ui_font query_font_ex(const GUID&) {return NULL;} + virtual bool is_elem_visible(service_ptr_t elem) {return true;} + virtual t_size host_notify(ui_element_instance* source, const GUID& what, t_size param1, const void* param2, t_size param2size) { (void)source; (void)what; (void)param1; (void)param2; (void)param2size; return 0; } + ui_element_instance_callback_ptr ui_element_instance_callback_get_ptr() { + if (m_callback.is_empty()) m_callback = new service_impl_t(this); + return m_callback; + } + void ui_element_instance_callback_release() { + if (m_callback.is_valid()) { + m_callback->orphan(); + m_callback.release(); + } + } +protected: + ~ui_element_instance_callback_receiver() { + ui_element_instance_callback_release(); + } + ui_element_instance_callback_receiver() {} + +private: + typedef ui_element_instance_callback_receiver t_self; + typedef ui_element_instance_callback_impl t_callback; + service_ptr_t m_callback; +}; + +//! Instance of a UI element. +class NOVTABLE ui_element_instance : public service_base { +public: + //! Returns ui_element_instance's window handle.\n + //! UI Element's window must be created when the ui_element_instance object is created. The window may or may not be destroyed by caller before the ui_element_instance itself is destroyed. If caller doesn't destroy the window before ui_element_instance destruction, ui_element_instance destructor should do it. + virtual fb2k::hwnd_t get_wnd() = 0; + + //! Alters element's current configuration. Specified ui_element_config's GUID must be the same as this element's GUID. + virtual void set_configuration(ui_element_config::ptr data) = 0; + //! Retrieves element's current configuration. Returned object's GUID must be set to your element's GUID so your element can be re-instantiated with stored settings. + virtual ui_element_config::ptr get_configuration() = 0; + + //! Returns GUID of the element. The return value must be the same as your ui_element::get_guid(). + virtual GUID get_guid() = 0; + //! Returns subclass GUID of the element. The return value must be the same as your ui_element::get_subclass(). + virtual GUID get_subclass() = 0; + + //! Returns element's focus priority. + virtual double get_focus_priority() {return 0;} + //! Elements that host other elements should pass the call to the child with the highest priority. Override for container elements. + virtual void set_default_focus() {set_default_focus_fallback();} + + //! Overridden by containers only. + virtual bool get_focus_priority_subclass(double & p_out,const GUID & p_subclass) { + if (p_subclass == get_subclass()) {p_out = get_focus_priority(); return true;} + else {return false;} + } + //! Overridden by containers only. + virtual bool set_default_focus_subclass(const GUID & p_subclass) { + if (p_subclass == get_subclass()) {set_default_focus(); return true;} + else {return false;} + } + + //! Retrieves element's minimum/maximum window size. Default implementation will fall back to WM_GETMINMAXINFO. + virtual ui_element_min_max_info get_min_max_info(); + + //! Used by host to notify the element about various events. See ui_element_notify_* GUIDs for possible p_what parameter; meaning of other parameters depends on p_what value. Container classes should dispatch all notifications to their children. + virtual void notify(const GUID& p_what, t_size p_param1, const void* p_param2, t_size p_param2size) { (void)p_what; (void)p_param1; (void)p_param2; (void)p_param2size; } + +#ifdef _WIN32 + //! @param p_point Context menu point in screen coordinates. Always within out window's rect. + //! @return True to request edit_mode_context_menu_build() call to add our own items to the menu, false if we can't supply a context menu for this point. + virtual bool edit_mode_context_menu_test(const POINT& p_point, bool p_fromkeyboard) { (void)p_point; (void)p_fromkeyboard; return false; } + virtual void edit_mode_context_menu_build(const POINT& p_point, bool p_fromkeyboard, HMENU p_menu, unsigned p_id_base) { (void)p_point; (void)p_fromkeyboard; (void)p_menu; (void)p_id_base; } + virtual void edit_mode_context_menu_command(const POINT& p_point, bool p_fromkeyboard, unsigned p_id, unsigned p_id_base) { (void)p_point; (void)p_fromkeyboard; (void)p_id; (void)p_id_base; } + //! @param p_point Receives the point to spawn context menu over when user has pressed the context menu key; in screen coordinates. + virtual bool edit_mode_context_menu_get_focus_point(POINT& p_point) { (void)p_point; return false; } + + virtual bool edit_mode_context_menu_get_description(unsigned p_id, unsigned p_id_base, pfc::string_base& p_out) { (void)p_id; (void)p_id_base; (void)p_out; return false; } +#endif // _WIN32 + + //! Helper. + void set_default_focus_fallback() { +#ifdef _WIN32 + const HWND thisWnd = this->get_wnd(); + if (thisWnd != NULL) ::SetFocus(thisWnd); +#endif + } + + + FB2K_MAKE_SERVICE_INTERFACE(ui_element_instance,service_base); +}; + +typedef service_ptr_t ui_element_instance_ptr; + + +//! Interface to enumerate and possibly alter children of a container element. Obtained from ui_element::enumerate_children(). +class NOVTABLE ui_element_children_enumerator : public service_base { +public: + //! Retrieves the container's children count. + virtual t_size get_count() = 0; + //! Retrieves the configuration of the child at specified index, 0 <= index < get_count(). + virtual ui_element_config::ptr get_item(t_size p_index) = 0; + + //! Returns whether children count can be altered. For certain containers, children count is fixed and this method returns false. + virtual bool can_set_count() = 0; + //! Alters container's children count (behavior is undefined when can_set_count() returns false). Newly allocated children get default empty element configuration. + virtual void set_count(t_size count) = 0; + //! Alters the selected item. + virtual void set_item(t_size p_index,ui_element_config::ptr cfg) = 0; + //! Creates a new ui_element_config for this container, with our changes (set_count(), set_item()) applied. + virtual ui_element_config::ptr commit() = 0; + + FB2K_MAKE_SERVICE_INTERFACE(ui_element_children_enumerator,service_base); +}; + + +typedef service_ptr_t ui_element_children_enumerator_ptr; + + +//! Entrypoint interface for each UI element implementation. +class NOVTABLE ui_element : public service_base { +public: + //! Retrieves GUID of the element. + virtual GUID get_guid() = 0; + + //! Retrieves subclass GUID of the element. Typically one of ui_element_subclass_* values, but you can create your own custom subclasses. Subclass GUIDs are used for various purposes such as focusing an UI element that provides specific functionality. + virtual GUID get_subclass() = 0; + + //! Retrieves a simple human-readable name of the element. + virtual void get_name(pfc::string_base & p_out) = 0; + + //! Instantiates the element using specified settings. + virtual ui_element_instance_ptr instantiate(fb2k::hwnd_t p_parent,ui_element_config::ptr cfg,ui_element_instance_callback_ptr p_callback) = 0; + + //! Retrieves default configuration of the element. + virtual ui_element_config::ptr get_default_configuration() = 0; + + //! Implemented by container elements only. Returns NULL for non-container elements. \n + //! Allows caller to parse and edit child element structure of container elements. + virtual ui_element_children_enumerator_ptr enumerate_children(ui_element_config::ptr cfg) = 0; + + + //! In certain cases, an UI element can import settings of another UI element (eg. vertical<=>horizontal splitter, tabs<=>splitters) when user directly replaces one of such elements with another. Overriding this function allows special handling of such cases. \n + //! Implementation hint: when implementing a multi-child container, you probably want to takeover child elements replacing another container element; use enumerate_children() on the element the configuration belongs to to grab those. + //! @returns A new ui_element_config on success, a null pointer when the input data could not be parsed / is in an unknown format. + virtual ui_element_config::ptr import(ui_element_config::ptr cfg) {return NULL;} + + //! Override this to return false when your element is for internal use only and should not be user-addable. + virtual bool is_user_addable() {return true;} + + //! Returns an icon to show in available UI element lists, etc. Returns NULL when there is no icon to display. + virtual t_ui_icon get_icon() {return NULL;} + + //! Retrieves a human-readable description of the element. + virtual bool get_description(pfc::string_base& p_out) { (void)p_out; return false; } + + //! Retrieves a human-readable description of the element's function to use for grouping in the element list. The default implementation relies on get_subclass() return value. + virtual bool get_element_group(pfc::string_base & p_out); + + static bool g_find(service_ptr_t & out, const GUID & id); + static bool g_get_name(pfc::string_base & p_out,const GUID & p_guid); + + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(ui_element); +}; + +//! Extended interface for a UI element implementation. +class NOVTABLE ui_element_v2 : public ui_element { +public: + enum { + //! Indicates that bump() method is supported. + KFlagSupportsBump = 1 << 0, + //! Tells UI backend to auto-generate a menu command activating your element - bumping an existing instance if possible, spawning a popup otherwise. + //! Currently menu commands are generated for ui_element_subclass_playback_visualisation, ui_element_subclass_media_library_viewers and ui_element_subclass_utility subclasses, in relevant menus. + KFlagHavePopupCommand = 1 << 1, + //! Tells backend that your element supports fullscreen mode (typically set only for visualisations). + KFlagHaveFullscreen = 1 << 2, + + KFlagPopupCommandHidden = 1 << 3, + + KFlagsVisualisation = KFlagHavePopupCommand | KFlagHaveFullscreen, + }; + virtual t_uint32 get_flags() = 0; + //! Called only when get_flags() return value has KFlagSupportsBump bit set. + //! Returns true when an existing instance of this element has been "bumped" - brought to user's attention in some way, false when there's no instance to bump or none of existing instances could be bumped for whatever reason. + virtual bool bump() = 0; + + //! Override to use another GUID for our menu command. Relevant only when KFlagHavePopupCommand is set. + virtual GUID get_menu_command_id() {return get_guid();} + + //! Override to use another description for our menu command. Relevant only when KFlagHavePopupCommand is set. + virtual bool get_menu_command_description(pfc::string_base & out) { + pfc::string8 name; get_name(name); + out = PFC_string_formatter() << "Activates " << name << " window."; + return true; + } + + //! Override to use another name for our menu command. Relevant only when KFlagHavePopupCommand is set. + virtual void get_menu_command_name(pfc::string_base & out) {get_name(out);} + + //! Relevant only when KFlagHavePopupCommand is set. + //! @param defSize Default window size @ 96DPI. If screen DPI is different, it will be rescaled appropriately. + //! @param title Window title to use. + //! @returns True when implemented, false when not - caller will automatically determine default size and window title then. + virtual bool get_popup_specs(ui_size& defSize, pfc::string_base& title) { (void)defSize; (void)title; return false; } + + + FB2K_MAKE_SERVICE_INTERFACE(ui_element_v2, ui_element) +}; + +class NOVTABLE ui_element_popup_host_callback : public service_base { +public: + virtual void on_resize(t_uint32 width, t_uint32 height) = 0; + virtual void on_close() = 0; + virtual void on_destroy() = 0; + + FB2K_MAKE_SERVICE_INTERFACE(ui_element_popup_host_callback,service_base); +}; + +class NOVTABLE ui_element_popup_host : public service_base { + FB2K_MAKE_SERVICE_INTERFACE(ui_element_popup_host,service_base); +public: + virtual ui_element_instance::ptr get_root_elem() = 0; + virtual fb2k::hwnd_t get_wnd() = 0; + virtual ui_element_config::ptr get_config() = 0; + virtual void set_config(ui_element_config::ptr cfg) = 0; + //! Sets edit mode on/off. Default: off. + virtual void set_edit_mode(bool state) = 0; +}; + +class NOVTABLE ui_element_popup_host_v2 : public ui_element_popup_host { + FB2K_MAKE_SERVICE_INTERFACE(ui_element_popup_host_v2, ui_element_popup_host); +public: + virtual void set_window_title(const char * title) = 0; + virtual void allow_element_specified_title(bool allow) = 0; +}; + +//! Shared implementation of common UI Element methods. Use ui_element_common_methods::get() to obtain an instance. +class NOVTABLE ui_element_common_methods : public service_base { + FB2K_MAKE_SERVICE_COREAPI(ui_element_common_methods); +public: + virtual void copy(ui_element_config::ptr cfg) = 0; + virtual void cut(ui_element_instance_ptr & p_instance,fb2k::hwnd_t p_parent,ui_element_instance_callback_ptr p_callback) = 0; + virtual bool paste(ui_element_instance_ptr & p_instance,fb2k::hwnd_t p_parent,ui_element_instance_callback_ptr p_callback) = 0; + virtual bool is_paste_available() = 0; + virtual bool paste(ui_element_config::ptr & out) = 0; + +#ifdef _WIN32 + virtual bool parse_dataobject_check(pfc::com_ptr_t in, DWORD & dropEffect) = 0; + virtual bool parse_dataobject(pfc::com_ptr_t in,ui_element_config::ptr & out, DWORD & dropEffect) = 0; + + virtual pfc::com_ptr_t create_dataobject(ui_element_config::ptr in) = 0; +#endif + + virtual fb2k::hwnd_t spawn_scratchbox(fb2k::hwnd_t parent,ui_element_config::ptr cfg) = 0; + + virtual ui_element_popup_host::ptr spawn_host(fb2k::hwnd_t parent, ui_element_config::ptr cfg, ui_element_popup_host_callback::ptr callback, ui_element::ptr elem = NULL +#ifdef _WIN32 + ,DWORD style = WS_POPUPWINDOW|WS_CAPTION|WS_THICKFRAME, DWORD styleEx = WS_EX_CONTROLPARENT +#endif + ) = 0; + + void copy(ui_element_instance_ptr p_instance) {copy(p_instance->get_configuration());} + + +}; + +//! Shared implementation of common UI Element methods. Use ui_element_common_methods_v2::get() to obtain an instance. +class NOVTABLE ui_element_common_methods_v2 : public ui_element_common_methods { + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(ui_element_common_methods_v2, ui_element_common_methods); +public: + virtual void spawn_host_simple(fb2k::hwnd_t parent, ui_element::ptr elem, bool fullScreenMode) = 0; + + void spawn_host_simple(fb2k::hwnd_t parent, const GUID & elem, bool fullScreenMode) { + spawn_host_simple(parent, service_by_guid(elem), fullScreenMode); + } + + virtual void toggle_fullscreen(ui_element::ptr elem, fb2k::hwnd_t parent) = 0; + + void toggle_fullscreen(const GUID & elem, fb2k::hwnd_t parent) { + toggle_fullscreen(service_by_guid(elem), parent); + } +}; + +//! \since 1.4 +//! Callback class for "Replace UI Element" dialog. +class NOVTABLE ui_element_replace_dialog_notify : public service_base { + FB2K_MAKE_SERVICE_INTERFACE(ui_element_replace_dialog_notify, service_base); +public: + virtual void on_cancelled() = 0; + virtual void on_ok( const GUID & guid ) = 0; + + //! Helper; reply is called with new elem GUID on OK and with a null GUID on cancel. + static ui_element_replace_dialog_notify::ptr create( std::function reply ); +}; + +//! \since 1.4 +class NOVTABLE ui_element_common_methods_v3 : public ui_element_common_methods_v2 { +public: + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(ui_element_common_methods_v3, ui_element_common_methods_v2); +public: + //! Creates a "Replace UI Element" or "Add New UI Element" dialog. + //! @param wndElem Parent *element* window handle, the dialog will be a child of its parent popup window but centered on top of the specified window. + //! @param elemReplacing GUID of element being replaced; specify null to show "Add UI Element" dialog. + //! @param notify Callback object receiving OK/Cancel notifications. + //! @returns Handle to the newly created dialog. You can just destroy this window if you need to abort the dialog programatically. + virtual fb2k::hwnd_t replace_element_dialog_start(fb2k::hwnd_t wndElem, const GUID & elemReplacing, ui_element_replace_dialog_notify::ptr notify) = 0; + + //! Highlights the element, creating an overlay window above it. Caller is responsible for destroying the overlay. + virtual fb2k::hwnd_t highlight_element( fb2k::hwnd_t wndElem ) = 0; +}; + +//! Dispatched through ui_element_instance::notify() when host changes color settings. Other parameters are not used and should be set to zero. +constexpr GUID ui_element_notify_colors_changed = { 0xeedda994, 0xe3d2, 0x441a, { 0xbe, 0x47, 0xa1, 0x63, 0x5b, 0x71, 0xab, 0x60 } }; +constexpr GUID ui_element_notify_font_changed = { 0x7a6964a8, 0xc797, 0x4737, { 0x90, 0x55, 0x7d, 0x84, 0xe7, 0x3d, 0x63, 0x6e } }; +constexpr GUID ui_element_notify_edit_mode_changed = { 0xf72f00af, 0xec76, 0x4251, { 0xb2, 0x67, 0x89, 0x4c, 0x52, 0x5f, 0x18, 0xc6 } }; + +//! Sent when a portion of the GUI is shown/hidden. First parameter is a bool flag indicating whether your UI Element is now visible. +constexpr GUID ui_element_notify_visibility_changed = { 0x313c22b9, 0x287a, 0x4804, { 0x8e, 0x6c, 0xff, 0xef, 0x4, 0x10, 0xcd, 0xea } }; + +//! Sent to retrieve areas occupied by elements to show overlay labels. Param1 is ignored, param2 is a pointer to ui_element_notify_get_element_labels_callback, param2size is ignored. +constexpr GUID ui_element_notify_get_element_labels = { 0x4850a2cb, 0x6cfc, 0x4d74, { 0x9a, 0x6d, 0xc, 0x7b, 0x29, 0x16, 0x5e, 0x69 } }; + + +//! Set to ui_element_instance_callback_v3 to set our element's label. Param1 is ignored, param2 is a pointer to a UTF-8 string containing the new label. Return value is 1 if the label is user-visible, 0 if the host does not support displaying overridden labels. +constexpr GUID ui_element_host_notify_set_elem_label = { 0x24598cb7, 0x9c5c, 0x488e, { 0xba, 0xff, 0xd, 0x2f, 0x11, 0x93, 0xe4, 0xf2 } }; +constexpr GUID ui_element_host_notify_get_dialog_texture = { 0xbb98eb99, 0x7b07, 0x42f3, { 0x8c, 0xd1, 0x12, 0xa2, 0xc2, 0x23, 0xb5, 0xbc } }; +constexpr GUID ui_element_host_notify_is_border_needed = { 0x2974f554, 0x2f31, 0x49c5, { 0xab, 0x4, 0x76, 0x4a, 0xf7, 0x94, 0x7c, 0x4f } }; + + + +class ui_element_notify_get_element_labels_callback { +public: + virtual void set_area_label(const ui_rect & rc, const char * name) = 0; + virtual void set_visible_element(ui_element_instance::ptr item) = 0; +protected: + ui_element_notify_get_element_labels_callback() {} + ~ui_element_notify_get_element_labels_callback() {} + + PFC_CLASS_NOT_COPYABLE_EX(ui_element_notify_get_element_labels_callback); +}; + + +constexpr GUID ui_element_subclass_playlist_renderers = { 0x3c4c68a0, 0xfc5, 0x400a, { 0xa3, 0x4a, 0x2e, 0x3a, 0xae, 0x6e, 0x90, 0x76 } }; +constexpr GUID ui_element_subclass_media_library_viewers = { 0x58455355, 0x289d, 0x459c, { 0x8f, 0x8a, 0xe1, 0x49, 0x6, 0xfc, 0x14, 0x56 } }; +constexpr GUID ui_element_subclass_containers = { 0x72dc5954, 0x1f26, 0x41be, { 0xae, 0xf2, 0x92, 0x9d, 0x25, 0xb5, 0x8d, 0xcf } }; +constexpr GUID ui_element_subclass_selection_information = { 0x68084e43, 0x7359, 0x46a5, { 0xb6, 0x84, 0x3c, 0xd7, 0x57, 0xf6, 0xde, 0xfd } }; +constexpr GUID ui_element_subclass_playback_visualisation = { 0x1f3c62f2, 0x8bb5, 0x4700, { 0x9e, 0x82, 0x8c, 0x48, 0x22, 0xf0, 0x18, 0x35 } }; +constexpr GUID ui_element_subclass_playback_information = { 0x84859f2d, 0xbb9c, 0x4e70, { 0x9d, 0x4, 0x14, 0x71, 0xb5, 0x63, 0x1f, 0x7f } }; +constexpr GUID ui_element_subclass_utility = { 0xffa4f4fc, 0xc169, 0x4766, { 0x9c, 0x94, 0xfa, 0xef, 0xae, 0xb2, 0x7e, 0xf } }; +constexpr GUID ui_element_subclass_dsp = { 0xa6a93251, 0xf0f8, 0x4bed,{ 0xb9, 0x5a, 0xf9, 0xe, 0x7e, 0x4f, 0xf2, 0xd0 } }; + + +bool ui_element_subclass_description(const GUID & id, pfc::string_base & out); + + +#define ReplaceUIElementCommand "Replace UI Element..." +#define ReplaceUIElementDescription "Replaces this UI Element with another one." + +#define CopyUIElementCommand "Copy UI Element" +#define CopyUIElementDescription "Copies this UI Element to Windows Clipboard." + +#define PasteUIElementCommand "Paste UI Element" +#define PasteUIElementDescription "Replaces this UI Element with Windows Clipboard content." + +#define CutUIElementCommand "Cut UI Element" +#define CutUIElementDescription "Copies this UI Element to Windows Clipboard and replaces it with an empty UI Element." + +#define AddNewUIElementCommand "Add New UI Element..." +#define AddNewUIElementDescription "Replaces the selected empty space with a new UI Element." + +//! \since 2.0 +class NOVTABLE ui_config_callback { +public: + //! Called when user changes configuration of fonts. + virtual void ui_fonts_changed() {} + //! Called when user changes configuration of colors (also as a result of toggling dark mode). \n + //! Note that for the duration of these callbacks, both old handles previously returned by query_font() as well as new ones are valid; old font objects are released when the callback cycle is complete. + virtual void ui_colors_changed() {} +}; + +//! \since 2.0 +class NOVTABLE ui_config_manager : public service_base { + FB2K_MAKE_SERVICE_COREAPI(ui_config_manager); +public: + //! Registers a callback to receive notifications about colors/fonts change. \n + //! Main thread only! + virtual void add_callback(ui_config_callback*) = 0; + //! Unregisters a callback to receive notifications about colors/fonts change. \n + //! Main thread only! + virtual void remove_callback(ui_config_callback*) = 0; + + //! Queries actual color to be used for the specified ui_color_* element. \n + //! Main thread only! \n + //! @returns True if color is user-overridden, false if system-default color should be used. + virtual bool query_color(const GUID& p_what, t_ui_color& p_out) = 0; + //! Queries font to be used for the specified ui_font_* element. \n + //! Main thread only! \n + //! The returned font handle is valid until the next font change callback cycle *completes*, that is, during a font change callback, both old and new handle are momentarily valid. + virtual t_ui_font query_font(const GUID& p_what) = 0; + + //! Helper using query_color(); returns true if dark mode is in effect, false otherwise. + bool is_dark_mode(); + +#ifdef _WIN32 + t_ui_color getSysColor(int sysColorIndex); +#endif + + //! Special method that's safe to call without checking if ui_config_manager exists, that is, it works on foobar2000 < 2.0. \n + //! Returns false if ui_conifg_manager doesn't exist and therefore dark mode isn't supported by this foobar2000 revision. \n + //! Main thread only! + static bool g_is_dark_mode(); +}; + +//! \since 2.0 +class NOVTABLE ui_config_manager_v2 : public ui_config_manager { + FB2K_MAKE_SERVICE_COREAPI_EXTENSION(ui_config_manager_v2, ui_config_manager) +public: + //! Tells ui_config_manager about system theme having changed. \n + //! Intended for keeping track of live dark mode toggle when foo_ui_std is not the active UI. Do not use. + virtual void notify_system_theme_changed() = 0; +}; + +//! \since 2.0 +//! Does nothing (fails to register quietly) if used in fb2k prior to 2.0 \n +//! Use in main thread only! +class ui_config_callback_impl : public ui_config_callback { +public: + ui_config_callback_impl(); + ~ui_config_callback_impl(); + ui_config_callback_impl(const ui_config_callback_impl&) = delete; + void operator=(const ui_config_callback_impl&) = delete; +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/ui_element_mac.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/ui_element_mac.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,18 @@ +#pragma once + +#ifdef __APPLE__ +// Mac UI element entrypoint +class ui_element_mac : public service_base { + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(ui_element_mac); +public: + //! @param arg wrapped NSDictionary*, see wrapNSObject + unwrapNSObject + //! @returns wrapped NSViewController, see wrapNSObject + unwrapNSObject + virtual service_ptr instantiate( service_ptr arg ) = 0; + //! Tests if this element matches specified name in user's view configuration. + virtual bool match_name( const char * name ) = 0; + //! Returns user-readable name. Reserved for future use. + virtual fb2k::stringRef get_name() = 0; + //! Returns GUID. Reserved for future use. + virtual GUID get_guid() = 0; +}; +#endif diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/ui_element_typable_window_manager.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/ui_element_typable_window_manager.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,14 @@ +#pragma once + +// API obsoleted in 1.5 and should no longer be used by anything +// Core-implemented to keep components that specifically rely on it working + +class NOVTABLE ui_element_typable_window_manager : public service_base { + FB2K_MAKE_SERVICE_COREAPI(ui_element_typable_window_manager); +public: + virtual void add(HWND wnd) = 0; + virtual void remove(HWND wnd) = 0; + virtual bool is_registered(HWND wnd) = 0; +}; + +FOOGUIDDECL const GUID ui_element_typable_window_manager::class_guid = { 0xbaa99ee2, 0xf770, 0x4981,{ 0x9e, 0x50, 0xf3, 0x4c, 0x5c, 0x6d, 0x98, 0x81 } }; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/unpack.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/unpack.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,24 @@ +#pragma once + +//! Service providing "unpacker" functionality - processes "packed" file (such as a zip file containing a single media file inside) to allow its contents to be accessed transparently.\n +//! To access existing unpacker implementations, use unpacker::g_open helper function.\n +//! To register your own implementation, use unpacker_factory_t template. +class NOVTABLE unpacker : public service_base { +public: + //! Attempts to open specified file for unpacking, creates interface to virtual file with uncompressed data on success. When examined file doesn't appear to be one of formats supported by this unpacker implementation, throws exception_io_data. + //! @param p_out Receives interface to virtual file with uncompressed data on success. + //! @param p_source Source file to process. + //! @param p_abort abort_callback object signaling user aborting the operation. + virtual void open(service_ptr_t & p_out,const service_ptr_t & p_source,abort_callback & p_abort) = 0; + + //! Static helper querying existing unpacker implementations until one that successfully opens specified file is found. Attempts to open specified file for unpacking, creates interface to virtual file with uncompressed data on success. When examined file doesn't appear to be one of formats supported by registered unpacker implementations, throws exception_io_data. + //! @param p_out Receives interface to virtual file with uncompressed data on success. + //! @param p_source Source file to process. + //! @param p_abort abort_callback object signaling user aborting the operation. + static void g_open(service_ptr_t & p_out,const service_ptr_t & p_source,abort_callback & p_abort); + + FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(unpacker); +}; + +template +class unpacker_factory_t : public service_factory_single_t {}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/utility.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/utility.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,405 @@ +#include "foobar2000-sdk-pch.h" +#include "foosort.h" +#include + +namespace pfc { + /* + Redirect PFC methods to shared.dll + If you're getting linker multiple-definition errors on these, change build configuration of PFC from "Debug" / "Release" to "Debug FB2K" / "Release FB2K" + */ +#ifdef _WIN32 + BOOL winFormatSystemErrorMessageHook(pfc::string_base & p_out, DWORD p_code) { + return uFormatSystemErrorMessage(p_out, p_code); + } +#endif + void crashHook() { + uBugCheck(); + } +} + + +// file_lock_manager.h functionality +#include "file_lock_manager.h" +namespace { + class file_lock_interrupt_impl : public file_lock_interrupt { + public: + void interrupt( abort_callback & a ) { f(a); } + std::function f; + }; +} + +file_lock_interrupt::ptr file_lock_interrupt::create( std::function< void (abort_callback&)> f ) { + service_ptr_t i = new service_impl_t(); + i->f = f; + return i; +} + +// file_info_filter.h functionality +#include "file_info_filter.h" +namespace { + class file_info_filter_lambda : public file_info_filter { + public: + bool apply_filter(trackRef p_track,t_filestats p_stats,file_info & p_info) override { + return f(p_track, p_stats, p_info); + } + func_t f; + }; +} + +file_info_filter::ptr file_info_filter::create(func_t f) { + auto o = fb2k::service_new(); + o->f = f; + return o; +} + +// threadPool.h functionality +#include "threadPool.h" +namespace fb2k { + void inWorkerThread(std::function f) { + fb2k::splitTask(f); + } + void inCpuWorkerThread(std::function f) { + cpuThreadPool::get()->runSingle(threadEntry::make(f)); + } +} +namespace { + class threadEntryImpl : public fb2k::threadEntry { + public: + void run() override { f(); } + std::function f; + }; +} +namespace fb2k { + threadEntry::ptr threadEntry::make(std::function f) { + auto ret = fb2k::service_new(); + ret->f = f; + return ret; + } + + void cpuThreadPool::runMulti_(std::function f, size_t numRuns) { + this->runMulti(threadEntry::make(f), numRuns, true); + } + + void cpuThreadPool::runMultiHelper(std::function f, size_t numRuns) { + if (numRuns == 0) return; +#if FOOBAR2000_TARGET_VERSION >= 81 + get()->runMulti_(f, numRuns); +#else + if (numRuns == 1) { + f(); + return; + } + + size_t numThreads = numRuns - 1; + struct rec_t { + pfc::thread2 trd; + std::exception_ptr ex; + }; + pfc::array_staticsize_t threads; + threads.set_size_discard(numThreads); + for (size_t walk = 0; walk < numThreads; ++walk) { + threads[walk].trd.startHere([f, &threads, walk] { + try { + f(); + } catch (...) { + threads[walk].ex = std::current_exception(); + } + }); + } + std::exception_ptr exMain; + try { + f(); + } catch (...) { + exMain = std::current_exception(); + } + + for (size_t walk = 0; walk < numThreads; ++walk) { + threads[walk].trd.waitTillDone(); + } + if (exMain) std::rethrow_exception(exMain); + for (size_t walk = 0; walk < numThreads; ++walk) { + auto & ex = threads[walk].ex; + if (ex) std::rethrow_exception(ex); + } +#endif + } +} + + +#if FOOBAR2020 +// timer.h functionality +#include "timer.h" +#include + +namespace fb2k { + void callLater(double timeAfter, std::function< void() > func) { + PFC_ASSERT( core_api::is_main_thread() ); + auto releaseMe = std::make_shared(); + *releaseMe = registerTimer(timeAfter, [=] { + if (releaseMe->is_valid()) { // ensure we get here once + func(); + releaseMe->release(); // warning: this should destroy objects that called us, hence func() call must go first + } + }); + } + objRef registerTimer(double interval, std::function func) { + PFC_ASSERT( core_api::is_main_thread() ); + return static_api_ptr_t()->addTimer(interval, makeCompletionNotify([func](unsigned) { func(); })); + } +} +#endif // FOOBAR2020 + +// autoplaylist.h functionality +#include "autoplaylist.h" + +bool autoplaylist_client::supports_async_() { + autoplaylist_client_v3::ptr v3; + bool rv = false; + if (v3 &= this) { + rv = v3->supports_async(); + } + return rv; +} + +bool autoplaylist_client::supports_get_contents_() { + autoplaylist_client_v3::ptr v3; + bool rv = false; + if (v3 &= this) { + rv = v3->supports_get_contents(); + } + return rv; +} + +void autoplaylist_client_v3::filter(metadb_handle_list_cref data, bool * out) { + filter_v2(data, nullptr, out, fb2k::noAbort); +} +bool autoplaylist_client_v3::sort(metadb_handle_list_cref p_items,t_size * p_orderbuffer) { + return sort_v2(p_items, p_orderbuffer, fb2k::noAbort); +} + + +#include "noInfo.h" +namespace fb2k { + noInfo_t noInfo; +} + + +// library_callbacks.h functionality +#include "library_callbacks.h" + +bool library_callback::is_modified_from_hook() { + auto api = library_manager_v5::tryGet(); + if (api.is_valid()) return api->library_status(library_manager_v5::status_current_callback_from_hook, 0, nullptr, 0) != 0; + else return false; +} + +void library_callback_dynamic::register_callback() { + library_manager_v3::get()->register_callback(this); +} +void library_callback_dynamic::unregister_callback() { + library_manager_v3::get()->unregister_callback(this); +} + +void library_callback_v2_dynamic::register_callback() { + library_manager_v4::get()->register_callback_v2(this); +} + +void library_callback_v2_dynamic::unregister_callback() { + library_manager_v4::get()->unregister_callback_v2(this); +} + + + +// configCache.h functionality +#include "configCache.h" +#include "configStore.h" + +bool fb2k::configBoolCache::get() { + std::call_once(m_init, [this] { + auto api = fb2k::configStore::get(); + auto refresh = [this, api] { m_value = api->getConfigBool(m_var, m_def); }; + api->addPermanentNotify(m_var, refresh); + refresh(); + }); + return m_value; +} + +int64_t fb2k::configIntCache::get() { + std::call_once(m_init, [this] { + auto api = fb2k::configStore::get(); + auto refresh = [this, api] { m_value = api->getConfigInt(m_var, m_def); }; + api->addPermanentNotify(m_var, refresh); + refresh(); + }); + return m_value; +} + +void fb2k::configBoolCache::set(bool v) { + m_value = v; + fb2k::configStore::get()->setConfigBool(m_var, v); +} + +void fb2k::configIntCache::set(int64_t v) { + m_value = v; + fb2k::configStore::get()->setConfigBool(m_var, v); +} + + +// keyValueIO.h functionality +#include "keyValueIO.h" + +int fb2k::keyValueIO::getInt( const char * name ) { + auto str = get(name); + if ( str.is_empty() ) return 0; + return (int) pfc::atoi64_ex( str->c_str(), str->length() ); +} + +void fb2k::keyValueIO::putInt( const char * name, int val ) { + put( name, pfc::format_int(val) ); +} + + +// fileDialog.h functionality +#include "fileDialog.h" +#include "fsitem.h" + +namespace { + using namespace fb2k; + class fileDialogNotifyImpl : public fileDialogNotify { + public: + void dialogCancelled() {} + void dialogOK2(arrayRef fsItems) { + recv(fsItems); + } + + std::function< void (arrayRef) > recv; + }; +} + +fb2k::fileDialogNotify::ptr fb2k::fileDialogNotify::create( std::function recv ) { + service_ptr_t obj = new service_impl_t< fileDialogNotifyImpl >(); + obj->recv = recv; + return obj; +} + +void fb2k::fileDialogSetup::run(fileDialogReply_t reply) { + this->run(fb2k::fileDialogNotify::create(reply)); +} +void fb2k::fileDialogSetup::runSimple(fileDialogGetPath_t reply) { + fb2k::fileDialogReply_t wrapper = [reply] (fb2k::arrayRef arg) { + if ( arg.is_empty() ) {PFC_ASSERT(!"???"); return; } + if ( arg->size() != 1 ) { PFC_ASSERT(!"???"); return; } + auto obj = arg->itemAt(0); + fsItemBase::ptr fsitem; + if ( fsitem &= obj ) { + reply( fsitem->canonicalPath() ); return; + } + fb2k::stringRef str; + if ( str &= obj ) { + reply(str); return; + } + PFC_ASSERT( !"???" ); + }; + this->run(wrapper); +} + +#include "input_file_type.h" + +void fb2k::fileDialogSetup::setAudioFileTypes() { + pfc::string8 temp; + input_file_type::build_openfile_mask(temp); + this->setFileTypes( temp ); +} + + +#include "search_tools.h" + +void search_filter_v2::test_multi_here(metadb_handle_list& ref, abort_callback& abort) { + pfc::array_t mask; mask.resize(ref.get_size()); + this->test_multi_ex(ref, mask.get_ptr(), abort); + ref.filter_mask(mask.get_ptr()); +} + + + +// core_api.h + +namespace fb2k { + bool isDebugModeActive() { +#if PFC_DEBUG + return true; +#else + auto api = fb2k::configStore::tryGet(); + if (api.is_empty()) return false; + return api->getConfigBool("core.debugMode"); +#endif + } + +#if FB2K_SUPPORT_LOW_MEM_MODE + static bool _isLowMemModeActive() { + auto api = fb2k::configStore::tryGet(); + if (api.is_empty()) return false; + return api->getConfigBool("core.lowMemMode"); + } + + bool isLowMemModeActive() { + static bool cached = _isLowMemModeActive(); + return cached; + } +#endif +} + +// callback_merit.h +namespace fb2k { + callback_merit_t callback_merit_of(service_ptr obj) { + { + callback_with_merit::ptr q; + if (q &= obj) return q->get_callback_merit(); + } + { + metadb_io_callback_v2::ptr q; + if (q &= obj) return q->get_callback_merit(); + } + return callback_merit_default; + } +} + +#ifdef _WIN32 +#include "message_loop.h" +message_filter_impl_base::message_filter_impl_base() { + PFC_ASSERT( core_api::is_main_thread() ); + message_loop::get()->add_message_filter(this); +} +message_filter_impl_base::message_filter_impl_base(t_uint32 lowest, t_uint32 highest) { + PFC_ASSERT( core_api::is_main_thread() ); + message_loop_v2::get()->add_message_filter_ex(this, lowest, highest); +} +message_filter_impl_base::~message_filter_impl_base() { + PFC_ASSERT( core_api::is_main_thread() ); + message_loop::get()->remove_message_filter(this); +} + +bool message_filter_impl_accel::pretranslate_message(MSG * p_msg) { + if (m_wnd != NULL) { + if (GetActiveWindow() == m_wnd) { + if (TranslateAccelerator(m_wnd,m_accel.get(),p_msg) != 0) { + return true; + } + } + } + return false; +} + +message_filter_impl_accel::message_filter_impl_accel(HINSTANCE p_instance,const TCHAR * p_accel) { + m_accel.load(p_instance,p_accel); +} + +bool message_filter_remap_f1::pretranslate_message(MSG * p_msg) { + if (IsOurMsg(p_msg) && m_wnd != NULL && GetActiveWindow() == m_wnd) { + ::PostMessage(m_wnd, WM_SYSCOMMAND, SC_CONTEXTHELP, -1); + return true; + } + return false; +} + +#endif diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/SDK/vis.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/vis.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,79 @@ +#pragma once + +//! This class provides abstraction for retrieving visualisation data. Instances of visualisation_stream being created/released serve as an indication for visualisation backend to process currently played audio data or shut down when there are no visualisation clients active.\n +//! Use visualisation_manager::create_stream to instantiate. +class NOVTABLE visualisation_stream : public service_base { +public: + //! Retrieves absolute playback time since last playback start or seek. You typically pass value retrieved by this function - optionally with offset added - to other visualisation_stream methods. + virtual bool get_absolute_time(double & p_value) = 0; + + //! Retrieves an audio chunk starting at specified offset (see get_absolute_time()), of specified length. + //! @returns False when requested timestamp is out of available range, true on success. + virtual bool get_chunk_absolute(audio_chunk & p_chunk,double p_offset,double p_requested_length) = 0; + //! Retrieves spectrum for audio data at specified offset (see get_absolute_time()), with specified FFT size. + //! @param p_chunk Receives spectrum data. audio_chunk type is used for consistency (since required functionality is identical to provided by audio_chunk), the data is *not* PCM. Returned sample count is equal to half of FFT size; channels and sample rate are as in audio stream the spectrum was generated from. + //! @param p_offset Timestamp of spectrum to retrieve. See get_absolute_time(). + //! @param p_fft_size FFT size to use for spectrum generation. Must be a power of 2. + //! @returns False when requested timestamp is out of available range, true on success. + virtual bool get_spectrum_absolute(audio_chunk & p_chunk,double p_offset,unsigned p_fft_size) = 0; + + //! Generates fake audio chunk to display when get_chunk_absolute() fails - e.g. shortly after visualisation_stream creation data for currently played audio might not be available yet. + //! Throws std::exception derivatives on failure. + virtual void make_fake_chunk_absolute(audio_chunk & p_chunk,double p_offset,double p_requested_length) = 0; + //! Generates fake spectrum to display when get_spectrum_absolute() fails - e.g. shortly after visualisation_stream creation data for currently played audio might not be available yet. + //! Throws std::exception derivatives on failure. + virtual void make_fake_spectrum_absolute(audio_chunk & p_chunk,double p_offset,unsigned p_fft_size) = 0; + + FB2K_MAKE_SERVICE_INTERFACE(visualisation_stream,service_base); +}; + +//! New in 0.9.5. +class NOVTABLE visualisation_stream_v2 : public visualisation_stream { +public: + virtual void request_backlog(double p_time) = 0; + virtual void set_channel_mode(t_uint32 p_mode) = 0; + + enum { + channel_mode_default = 0, + channel_mode_mono, + channel_mode_frontonly, + channel_mode_backonly, + }; + + FB2K_MAKE_SERVICE_INTERFACE(visualisation_stream_v2,visualisation_stream); +}; + +//! New in 0.9.5.2. +class NOVTABLE visualisation_stream_v3 : public visualisation_stream_v2 { +public: + virtual void chunk_to_spectrum(audio_chunk const & chunk, audio_chunk & spectrum, double centerOffset) = 0; + + FB2K_MAKE_SERVICE_INTERFACE(visualisation_stream_v3,visualisation_stream_v2); +}; + +//! Entrypoint service for visualisation processing; use this to create visualisation_stream objects that can be used to retrieve properties of currently played audio. \n +//! Implemented by core; do not reimplement.\n +//! Use visualisation_manager::get() to obtain an instance, e.g. visualisation_manager::get()->create_stream(mystream,0); +class NOVTABLE visualisation_manager : public service_base { + FB2K_MAKE_SERVICE_COREAPI(visualisation_manager); +public: + //! Creates a visualisation_stream object. See visualisation_stream for more info. + //! @param p_out Receives newly created visualisation_stream instance. + //! @param p_flags Combination of one or more KStreamFlag* values. Currently only KStreamFlagNewFFT is defined. + //! It's recommended that you set p_flags to KStreamFlagNewFFT to get the new FFT behavior (better quality and result normalization), the old behavior for null flags is preserved for compatibility with old components that rely on it. + virtual void create_stream(service_ptr_t & p_out,unsigned p_flags) = 0; + + enum { + //! New FFT behavior for spectrum-generating methods, available in 0.9.5.2 and newer: output normalized to 0..1, Gauss window used instead of rectangluar (better quality / less aliasing). + //! It's recommended to always set this flag. The old behavior is preserved for backwards compatibility. + KStreamFlagNewFFT = 1 << 0, + }; + + + //! Wrapper around non-template create_stream(); retrieves one of newer visualisation_stream_* interfaces rather than base visualisation_stream interface. Throws exception_service_extension_not_found() when running too old foobar2000 version for the requested interface. + template + void create_stream(t_streamptr & out, unsigned flags) { + visualisation_stream::ptr temp; create_stream(temp, flags); + if (!temp->service_query_t(out)) throw exception_service_extension_not_found(); + } +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/foo_sample/IO.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/foo_sample/IO.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,343 @@ +#include "stdafx.h" +#include +#include +#include + +void RunIOTest() { + try { + auto request = http_client::get()->create_request("GET"); + request->run("https://www.foobar2000.org", fb2k::noAbort); + } catch (std::exception const & e) { + popup_message::g_show( PFC_string_formatter() << "Network test failure:\n" << e, "Information"); + return; + } + popup_message::g_show(PFC_string_formatter() << "Network test OK", "Information"); +} + +namespace { // anon namespace local classes for good measure + class tpc_copyFiles : public threaded_process_callback { + public: + tpc_copyFiles ( metadb_handle_list_cref items, const char * pathTo ) : m_pathTo(pathTo), m_outFS(filesystem::get(pathTo)) { + m_lstFiles.init_from_list( items ); + } + + void on_init(ctx_t p_wnd) override { + // Main thread, called before run() gets started + } + void run(threaded_process_status & p_status, abort_callback & p_abort) override { + // Worker thread + for( size_t fileWalk = 0; fileWalk < m_lstFiles.get_size(); ++ fileWalk ) { + + // always do this in every timeconsuming loop + // will throw exception_aborted if the user pushed 'cancel' on us + p_abort.check(); + + const char * inPath = m_lstFiles[fileWalk]; + p_status.set_progress(fileWalk, m_lstFiles.get_size()); + p_status.set_item_path( inPath ); + + try { + workWithFile(inPath, p_abort); + } catch(exception_aborted) { + // User abort, just bail + throw; + } catch(std::exception const & e) { + m_errorLog << "Could not copy: " << file_path_display(inPath) << ", reason: " << e << "\n"; + } + + } + } + + void workWithFile( const char * inPath, abort_callback & abort ) { + FB2K_console_formatter() << "File: " << file_path_display(inPath); + + // Filesystem API for inPath + const filesystem::ptr inFS = filesystem::get( inPath ); + pfc::string8 inFN; + // Extract filename+extension according to this filesystem's rules + // If it's HTTP or so, there might be ?key=value that needs stripping + inFS->extract_filename_ext(inPath, inFN); + + pfc::string8 outPath = m_pathTo; + // Suffix with outFS path separator. On Windows local filesystem this is always a backslash. + outPath.end_with( m_outFS->pathSeparator() ); + outPath += inFN; + + const double openTimeout = 1.0; // wait and keep retrying for up to 1 second in case of a sharing violation error + + // Not strictly needed, but we do it anyway + // Acquire a read lock on the file, so anyone trying to acquire a write lock will just wait till we have finished + auto inLock = file_lock_manager::get()->acquire_read( inPath, abort ); + + auto inFile = inFS->openRead( inPath, abort, openTimeout ); + + // Let's toy around with inFile + { + auto stats = inFile->get_stats(abort); + + if ( stats.m_size != filesize_invalid ) { + FB2K_console_formatter() << "Size: " << pfc::format_file_size_short(stats.m_size); + } + if ( stats.m_timestamp != filetimestamp_invalid ) { + FB2K_console_formatter() << "Last modified: " << format_filetimestamp(stats.m_timestamp); + } + pfc::string8 contentType; + if ( inFile->get_content_type( contentType ) ) { + FB2K_console_formatter() << "Content type: " << contentType; + } + + uint8_t buffer[256]; + size_t got = inFile->read(buffer, sizeof(buffer), abort); + + if ( got > 0 ) { + FB2K_console_formatter() << "Header bytes: " << pfc::format_hexdump( buffer, got ); + } + + if ( inFile->is_remote() ) { + FB2K_console_formatter() << "File is remote"; + } else { + FB2K_console_formatter() << "File is local"; + } + + // For seekable files, reopen() seeks to the beginning. + // For nonseekable stream, reopen() restarts reading the stream. + inFile->reopen(abort); + } + + // This is a glorified strcmp() for file paths. + if ( metadb::path_compare( inPath, outPath ) == 0 ) { + // Same path, go no further. Specifically don't attempt acquiring a writelock because that will never complete, unless user aborted. + FB2K_console_formatter() << "Input and output paths are the same - not copying!"; + return; + } + + // Required to write to files being currently played. + // See file_lock_manager documentation for details. + auto outLock = file_lock_manager::get()->acquire_write( outPath, abort ); + + // WARNING : if a file exists at outPath prior to this, it will be reset to zero bytes (win32 CREATE_ALWAYS semantics) + auto outFile = m_outFS->openWriteNew(outPath, abort, openTimeout); + + + + try { + // Refer to g_transfer_file implementation details in the SDK for lowlevel reading & writing details + file::g_transfer_file(inFile, outFile, abort); + } catch(...) { + + if ( inFile->is_remote() ) { + // Remote file was being downloaded? Suppress deletion of incomplete output + throw; + } + // Failed for some reason + // Release our destination file hadnle + outFile.release(); + + // .. and delete the incomplete file + try { + auto & noAbort = fb2k::noAbort; // we might be being aborted, don't let that prevent deletion + m_outFS->remove( outPath, noAbort ); + } catch(...) { + // disregard errors - just report original copy error + } + + throw; // rethrow the original copy error + } + + } + + void on_done(ctx_t p_wnd, bool p_was_aborted) override { + // All done, main thread again + + if (! p_was_aborted && m_errorLog.length() > 0 ) { + popup_message::g_show(m_errorLog, "Information"); + } + + } + + + + // This is a helper class that generates a sorted list of unique file paths in this metadb_handle_list. + // The metadb_handle_list might contain duplicate tracks or multiple subsongs in the same file. m_lstFiles will list each file only once. + file_list_helper::file_list_from_metadb_handle_list m_lstFiles; + + // Destination path + const pfc::string8 m_pathTo; + // Destination filesystem API. Obtained via filesystem::get() with destination path. + const filesystem::ptr m_outFS; + + // Error log + pfc::string_formatter m_errorLog; + }; +} + +void RunCopyFilesHere(metadb_handle_list_cref data, const char * copyTo, fb2k::hwnd_t wndParent) { + + // Create worker object, a threaded_process_callback implementation. + auto worker = fb2k::service_new(data, copyTo); + const uint32_t flags = threaded_process::flag_show_abort | threaded_process::flag_show_progress | threaded_process::flag_show_item; + // Start the process asynchronously. + threaded_process::get()->run_modeless( worker, flags, wndParent, "Sample Component: Copying Files" ); + + // Our worker is now running. +} +void RunCopyFiles(metadb_handle_list_cref data) { + +#ifdef _WIN32 + // Detect modal dialog wars. + // If another modal dialog is active, bump it instead of allowing our modal dialog (uBrowseForFolder) to run. + // Suppress this if the relevant code is intended to be launched by a modal dialog. + if (!ModalDialogPrologue()) return; + + const HWND wndParent = core_api::get_main_window(); + pfc::string8 copyTo; + // shared.dll method + if (!uBrowseForFolder( wndParent, "Choose destination folder", copyTo )) return; + + // shared.dll methods are win32 API wrappers and return plain paths with no protocol prepended + // Prefix with file:// before passing to fb2k filesystem methods. + // Actually the standard fb2k filesystem implementation recognizes paths even without the prefix, but we enforce it here as a good practice. + pfc::string8 copyTo2 = PFC_string_formatter() << "file://" << copyTo; + + RunCopyFilesHere(data, copyTo2, wndParent); +#else + auto tracksCopy = std::make_shared( data ); + auto setup = fb2k::fileDialog::get()->setupOpenFolder(); + setup->setTitle("Choose destination folder"); + setup->runSimple( [tracksCopy] (fb2k::stringRef path) { + RunCopyFilesHere(*tracksCopy, path->c_str(), core_api::get_main_window()); + } ); + +#endif +} + + +namespace { + class processLLtags : public threaded_process_callback { + public: + processLLtags( metadb_handle_list_cref data ) : m_items(data) { + m_hints = metadb_io_v2::get()->create_hint_list(); + } + void on_init(ctx_t p_wnd) override { + // Main thread, called before run() gets started + } + void run(threaded_process_status & p_status, abort_callback & p_abort) override { + // Worker thread + + // Note: + // We should look for references to the same file (such as multiple subsongs) in the track list and update each file only once. + // But for the sake of simplicity we don't do this in a sample component. + for( size_t itemWalk = 0; itemWalk < m_items.get_size(); ++ itemWalk ) { + + // always do this in every timeconsuming loop + // will throw exception_aborted if the user pushed 'cancel' on us + p_abort.check(); + + auto item = m_items[ itemWalk ]; + p_status.set_progress( itemWalk, m_items.get_size() ); + p_status.set_item_path( item->get_path() ); + + try { + workWithTrack(item, p_abort); + } catch(exception_aborted) { + // User abort, just bail + throw; + } catch(std::exception const & e) { + m_errorLog << "Could not update: " << item << ", reason: " << e << "\n"; + } + } + } + void on_done(ctx_t p_wnd, bool p_was_aborted) override { + // All done, main thread again + if ( m_hints.is_valid() ) { + // This is the proper time to finalize the hint list + // All playlists showing these files and such will now be refreshed + m_hints->on_done(); + } + + if (!p_was_aborted && m_errorLog.length() > 0) { + popup_message::g_show(m_errorLog, "Information"); + } + } + + private: + void workWithTrack( metadb_handle_ptr item, abort_callback & abort ) { + + FB2K_console_formatter() << "foo_sample will update tags on: " << item; + + const auto subsong = item->get_subsong_index(); + const auto path = item->get_path(); + + const double openTimeout = 1.0; // wait and keep retrying for up to 1 second in case of a sharing violation error + + // Required to write to files being currently played. + // See file_lock_manager documentation for details. + auto lock = file_lock_manager::get()->acquire_write( path, abort ); + + input_info_writer::ptr writer; + input_entry::g_open_for_info_write_timeout(writer, nullptr, path, abort, openTimeout ); + + { // let's toy around with info that the writer can hand to us + auto stats = writer->get_file_stats( abort ); + if (stats.m_timestamp != filetimestamp_invalid) { + FB2K_console_formatter() << "Last-modified before tag update: " << format_filetimestamp_utc(stats.m_timestamp); + } + } + + file_info_impl info; + writer->get_info( subsong, info, abort ); + + info.meta_set("comment", "foo_sample lowlevel tags write demo was here"); + + // Touchy subject + // Should we let the user abort an incomplete tag write? + // Let's better not + auto & noAbort = fb2k::noAbort; + + // This can be called many times for files with multiple subsongs + writer->set_info( subsong, info, noAbort ); + + // This is called once - when we're done set_info()'ing + writer->commit( noAbort ); + + { // let's toy around with info that the writer can hand to us + auto stats = writer->get_file_stats(abort); + if (stats.m_timestamp != filetimestamp_invalid) { + FB2K_console_formatter() << "Last-modified after tag update: " << format_filetimestamp_utc(stats.m_timestamp); + } + } + + // Now send new info to metadb + // If we don't do this, old info may still be shown in playlists etc. + if ( true ) { + // Method #1: feed altered info directly to the hintlist. + // Makes sense here as we updated just one subsong. + auto stats = writer->get_file_stats(abort); + m_hints->add_hint(item, info, stats, true); + } else { + // Method #2: let metadb talk to our writer object (more commonly used). + // The writer is a subclass of input_info_reader and can therefore be legitimately fed to add_hint_reader() + // This will read info from all subsongs in the file and update metadb if appropriate. + m_hints->add_hint_reader(path, writer, abort); + } + } + metadb_hint_list::ptr m_hints; + const metadb_handle_list m_items; + pfc::string_formatter m_errorLog; + }; +} +void RunAlterTagsLL(metadb_handle_list_cref data) { + + const auto wndParent = core_api::get_main_window(); + + // Our worker object, a threaded_process_callback subclass. + auto worker = fb2k::service_new< processLLtags > ( data ); + + const uint32_t flags = threaded_process::flag_show_abort | threaded_process::flag_show_progress | threaded_process::flag_show_item; + + // Start the worker asynchronously. + threaded_process::get()->run_modeless(worker, flags, wndParent, "Sample Component: Updating Tags"); + + // The worker is now running. + +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/foo_sample/Mac/fooSampleDSPView.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/foo_sample/Mac/fooSampleDSPView.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,12 @@ +// +// fooSampleDSPView.h +// foo_sample +// +// Created by P on 01/09/2023. +// + +#import + + +@interface fooSampleDSPView : NSViewController +@end diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/foo_sample/Mac/fooSampleDSPView.mm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/foo_sample/Mac/fooSampleDSPView.mm Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,41 @@ +#import "stdafx.h" +#import "fooSampleDSPView.h" +#import "dsp_sample.h" + +@interface fooSampleDSPView () +@property (nonatomic) dsp_preset_edit_callback_v2::ptr callback; +@property (nonatomic) NSNumber * gain; +@end + +@implementation fooSampleDSPView + +- (instancetype)init { + // IMPORTANT: feed OUR NSBundle, bundleForClass works well for this + return [self initWithNibName: @"fooSampleDSPView" bundle:[NSBundle bundleForClass: [self class]]]; +} + +- (void)viewDidLoad { + [super viewDidLoad]; + // Do view setup here. + + dsp_preset_impl preset; + _callback->get_preset(preset); + self.gain = [NSNumber numberWithFloat: parse_preset(preset)]; +} + +- (IBAction)onEdit:(id)sender { + [self apply]; +} + +- (void) apply { + dsp_preset_impl preset; + make_preset( self.gain.floatValue , preset); + _callback->set_preset( preset ); +} +@end + +service_ptr ConfigureSampleDSP( fb2k::hwnd_t parent, dsp_preset_edit_callback_v2::ptr callback ) { + fooSampleDSPView * dialog = [fooSampleDSPView new]; + dialog.callback = callback; + return fb2k::wrapNSObject( dialog ); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/foo_sample/Mac/fooSampleDSPView.xib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/foo_sample/Mac/fooSampleDSPView.xib Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/foo_sample/Mac/fooSampleMacPreferences.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/foo_sample/Mac/fooSampleMacPreferences.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,12 @@ +// +// fooSampleMacPreferences.h +// foo_sample +// +// Created by P on 01/09/2023. +// + +#import + +@interface fooSampleMacPreferences : NSViewController + +@end diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/foo_sample/Mac/fooSampleMacPreferences.mm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/foo_sample/Mac/fooSampleMacPreferences.mm Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,58 @@ +#import "stdafx.h" +#import "fooSampleMacPreferences.h" + +namespace foo_sample { + extern cfg_uint cfg_bogoSetting1, cfg_bogoSetting2; +} + +@interface fooSampleMacPreferences () +@property (nonatomic) NSNumber* bogo1; +@property (nonatomic) NSNumber* bogo2; +@end + +@implementation fooSampleMacPreferences + +- (void)viewDidLoad { + [super viewDidLoad]; + // Do view setup here. +} +- (instancetype)init { + // IMPORTANT: feed OUR NSBundle, bundleForClass works well for this + self = [self initWithNibName: @"fooSampleMacPreferences" bundle:[NSBundle bundleForClass: [self class]]]; + [self loadSettings]; + return self; +} +- (void) loadSettings { + self.bogo1 = [NSNumber numberWithUnsignedLong: foo_sample::cfg_bogoSetting1]; + self.bogo2 = [NSNumber numberWithUnsignedLong: foo_sample::cfg_bogoSetting2]; +} +- (IBAction)onBogo1:(id)sender { + foo_sample::cfg_bogoSetting1 = self.bogo1.unsignedLongValue; +} +- (IBAction)onBogo2:(id)sender { + foo_sample::cfg_bogoSetting2 = self.bogo2.unsignedLongValue; +} + + +@end + + + + + +namespace { +class preferences_page_sample : public preferences_page { + public: + service_ptr instantiate() override { + return fb2k::wrapNSObject( [ fooSampleMacPreferences new ] ); + } + const char * get_name() override {return "Sample Component";} + GUID get_guid() override { + // This is our GUID. Replace with your own when reusing the code. + return GUID { 0x7702c93e, 0x24dc, 0x48ed, { 0x8d, 0xb1, 0x3f, 0x27, 0xb3, 0x8c, 0x7c, 0xc9 } }; + } + GUID get_parent_guid() override {return guid_tools;} + }; + + FB2K_SERVICE_FACTORY(preferences_page_sample); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/foo_sample/Mac/fooSampleMacPreferences.xib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/foo_sample/Mac/fooSampleMacPreferences.xib Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/foo_sample/PCH.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/foo_sample/PCH.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,3 @@ +#include "stdafx.h" + +// This is a dummy source code file that just generates the precompiled header (PCH) file for use when compiling the rest of the source code, to speed compilation up. \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/foo_sample/contextmenu.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/foo_sample/contextmenu.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,175 @@ +#include "stdafx.h" + + +// Identifier of our context menu group. Substitute with your own when reusing code. +static const GUID guid_mygroup = { 0x572de7f4, 0xcbdf, 0x479a, { 0x97, 0x26, 0xa, 0xb0, 0x97, 0x47, 0x69, 0xe3 } }; + + +// Switch to contextmenu_group_factory to embed your commands in the root menu but separated from other commands. + +//static contextmenu_group_factory g_mygroup(guid_mygroup, contextmenu_groups::root, 0); +static contextmenu_group_popup_factory g_mygroup(guid_mygroup, contextmenu_groups::root, "Sample component", 0); + +static void RunTestCommand(metadb_handle_list_cref data); +void RunCalculatePeak(metadb_handle_list_cref data); //decode.cpp + +void RunCopyFiles(metadb_handle_list_cref data); // IO.cpp +void RunAlterTagsLL(metadb_handle_list_cref data); // IO.cpp + +void RunUIAndThreads( metadb_handle_list_cref data ); // ui_and_threads.cpp + +namespace { // anon namespace local classes for good measure + class myFilter : public file_info_filter { + public: + bool apply_filter(metadb_handle_ptr p_location, t_filestats p_stats, file_info & p_info) { + p_info.meta_set("comment", "foo_sample was here"); + // return true to write changes tags to the file, false to suppress the update + return true; + } + }; +} + +static void RunAlterTags(metadb_handle_list_cref data) { + // Simple alter-file-tags functionality + + const auto wndParent = core_api::get_main_window(); + + // Filter object that applies our edits to the file tags + auto filter = fb2k::service_new(); + + auto notify = fb2k::makeCompletionNotify( [] (unsigned code) { + // Code values are metadb_io::t_update_info_state enum + FB2K_console_formatter() << "Tag update finished, code: " << code; + } ); + + // Flags + // Indicate that we're aware of fb2k 1.3+ partial info semantics + const uint32_t flags = metadb_io_v2::op_flag_partial_info_aware; + + metadb_io_v2::get()->update_info_async(data, filter, wndParent, flags, notify); +} + +// Simple context menu item class. +class myitem : public contextmenu_item_simple { + typedef contextmenu_item_simple super_t; +public: + enum { + cmd_test1 = 0, + cmd_peak, + cmd_copyFiles, + cmd_alterTags, + cmd_alterTagsLL, + cmd_uiAndThreads, + cmd_total + }; + GUID get_parent() {return guid_mygroup;} + unsigned get_num_items() {return cmd_total;} + void get_item_name(unsigned p_index,pfc::string_base & p_out) { + switch(p_index) { + case cmd_test1: p_out = "Test command"; break; + case cmd_peak: p_out = "Calculate peak"; break; + case cmd_copyFiles: p_out = "Copy files"; break; + case cmd_alterTags: p_out = "Alter tags"; break; + case cmd_alterTagsLL: p_out = "Alter tags (low level)"; break; + case cmd_uiAndThreads: p_out = "UI and threads demo"; break; + default: uBugCheck(); // should never happen unless somebody called us with invalid parameters - bail + } + } + void context_command(unsigned p_index,metadb_handle_list_cref p_data,const GUID& p_caller) { + switch(p_index) { + case cmd_test1: + RunTestCommand(p_data); + break; + case cmd_peak: + RunCalculatePeak(p_data); + break; + case cmd_copyFiles: + RunCopyFiles(p_data); + break; + case cmd_alterTags: + RunAlterTags(p_data); + break; + case cmd_alterTagsLL: + RunAlterTagsLL(p_data); + break; + case cmd_uiAndThreads: + RunUIAndThreads(p_data); + break; + default: + uBugCheck(); + } + } + // Overriding this is not mandatory. We're overriding it just to demonstrate stuff that you can do such as context-sensitive menu item labels. + bool context_get_display(unsigned p_index,metadb_handle_list_cref p_data,pfc::string_base & p_out,unsigned & p_displayflags,const GUID & p_caller) { + switch(p_index) { + case cmd_test1: + if (!super_t::context_get_display(p_index, p_data, p_out, p_displayflags, p_caller)) return false; + // Example context sensitive label: append the count of selected items to the label. + p_out << " : " << p_data.get_count() << " item"; + if (p_data.get_count() != 1) p_out << "s"; + p_out << " selected"; + return true; + default: + return super_t::context_get_display(p_index, p_data, p_out, p_displayflags, p_caller); + } + } + GUID get_item_guid(unsigned p_index) { + // These GUIDs identify our context menu items. Substitute with your own GUIDs when reusing code. + static const GUID guid_test1 = { 0x4021c80d, 0x9340, 0x423b, { 0xa3, 0xe2, 0x8e, 0x1e, 0xda, 0x87, 0x13, 0x7f } }; + static const GUID guid_peak = { 0xe629b5c3, 0x5af3, 0x4a1e, { 0xa0, 0xcd, 0x2d, 0x5b, 0xff, 0xa6, 0x4, 0x58 } }; + static const GUID guid_copyFiles = { 0x7f8a6569, 0xe46b, 0x4698, { 0xaa, 0x30, 0xc4, 0xc1, 0x44, 0xc9, 0xc8, 0x92 } }; + static const GUID guid_alterTags = { 0xdfb8182b, 0xf8f3, 0x4ce9, { 0xae, 0xf6, 0x8e, 0x4e, 0x51, 0x7c, 0x2d, 0x3 } }; + static const GUID guid_alterTagsLL = { 0x6b43324d, 0x6cb2, 0x42a6, { 0xbf, 0xc, 0xd9, 0x43, 0xfc, 0x83, 0x2f, 0x39 } }; + static const GUID guid_uiAndThreads = { 0x30dace2e, 0xcccf, 0x41d4, { 0x8c, 0x24, 0x57, 0xec, 0xf4, 0xa0, 0xd9, 0xc9 } }; + + switch(p_index) { + case cmd_test1: return guid_test1; + case cmd_peak: return guid_peak; + case cmd_copyFiles: return guid_copyFiles; + case cmd_alterTags: return guid_alterTags; + case cmd_alterTagsLL: return guid_alterTagsLL; + case cmd_uiAndThreads: return guid_uiAndThreads; + default: uBugCheck(); // should never happen unless somebody called us with invalid parameters - bail + } + + } + bool get_item_description(unsigned p_index,pfc::string_base & p_out) { + switch(p_index) { + case cmd_test1: + p_out = "This is a sample command."; + return true; + case cmd_peak: + p_out = "This is a sample command that decodes the selected tracks and reports the peak sample value."; + return true; + case cmd_copyFiles: + p_out = "This is a sample command that copies the selected tracks to another location."; + return true; + case cmd_alterTags: + p_out = "This is a sample command that performs tag manipulation on the files."; + return true; + case cmd_alterTagsLL: + p_out = "This is a sample command that performs low-level manipulation of tags on the files."; + return true; + case cmd_uiAndThreads: + p_out = "This is a smple command that runs UI and Threads demo."; + return true; + default: + uBugCheck(); // should never happen unless somebody called us with invalid parameters - bail + } + } +}; + +static contextmenu_item_factory_t g_myitem_factory; + + +static void RunTestCommand(metadb_handle_list_cref data) { + pfc::string_formatter message; + message << "This is a test command.\n"; + if (data.get_count() > 0) { + message << "Parameters:\n"; + for(t_size walk = 0; walk < data.get_count(); ++walk) { + message << data[walk] << "\n"; + } + } + popup_message::g_show(message, "Blah"); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/foo_sample/decode.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/foo_sample/decode.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,77 @@ +#include "stdafx.h" +#include + +class calculate_peak_process : public threaded_process_callback { +public: + calculate_peak_process(metadb_handle_list_cref items) : m_items(items), m_peak() {} + void on_init(ctx_t p_wnd) override {} + void run(threaded_process_status & p_status,abort_callback & p_abort) override { + try { + const t_uint32 decode_flags = input_flag_no_seeking | input_flag_no_looping; // tell the decoders that we won't seek and that we don't want looping on formats that support looping. + input_helper input; // this object manages lowlevel input_decoder calls for us. + for(t_size walk = 0; walk < m_items.get_size(); ++walk) { + p_abort.check(); // in case the input we're working with fails at doing this + p_status.set_progress(walk, m_items.get_size()); + p_status.set_progress_secondary(0); + p_status.set_item_path( m_items[walk]->get_path() ); + input.open(NULL, m_items[walk], decode_flags, p_abort); + + double length; + { // fetch the track length for proper dual progress display; + file_info_impl info; + // input.open should have preloaded relevant info, no need to query the input itself again. + // Regular get_info() may not retrieve freshly loaded info yet at this point (it will start giving the new info when relevant info change callbacks are dispatched); we need to use get_info_async. + if (m_items[walk]->get_info_async(info)) length = info.get_length(); + else length = 0; + } + + audio_chunk_impl_temporary l_chunk; + double decoded = 0; + while(input.run(l_chunk, p_abort)) { // main decode loop + m_peak = l_chunk.get_peak(m_peak); + if (length > 0) { // don't bother for unknown length tracks + decoded += l_chunk.get_duration(); + if (decoded > length) decoded = length; + p_status.set_progress_secondary_float(decoded / length); + } + p_abort.check(); // in case the input we're working with fails at doing this + } + } + } catch(std::exception const & e) { + m_failMsg = e.what(); + } + } + void on_done(ctx_t p_wnd,bool p_was_aborted) override { + if (!p_was_aborted) { + if (!m_failMsg.is_empty()) { + popup_message::g_complain("Peak scan failure", m_failMsg); + } else { + pfc::string_formatter result; + result << "Value: " << m_peak << "\n\n"; + result << "Scanned items:\n"; + for(t_size walk = 0; walk < m_items.get_size(); ++walk) { + result << m_items[walk] << "\n"; + } + popup_message::g_show(result,"Peak scan result"); + } + } + } +private: + audio_sample m_peak; + pfc::string8 m_failMsg; + const metadb_handle_list m_items; +}; + +void RunCalculatePeak(metadb_handle_list_cref data) { + try { + if (data.get_count() == 0) throw pfc::exception_invalid_params(); + service_ptr_t cb = new service_impl_t(data); + static_api_ptr_t()->run_modeless( + cb, + threaded_process::flag_show_progress_dual | threaded_process::flag_show_item | threaded_process::flag_show_abort, + core_api::get_main_window(), + "Sample component: peak scan"); + } catch(std::exception const & e) { + popup_message::g_complain("Could not start peak scan process", e); + } +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/foo_sample/dsp_sample.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/foo_sample/dsp_sample.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,163 @@ +#include "stdafx.h" +#include "dsp_sample.h" + +#ifdef _WIN32 +#include +#include "resource.h" + +static void RunDSPConfigPopup(const dsp_preset & p_data,HWND p_parent,dsp_preset_edit_callback & p_callback); +#endif + +#ifdef __APPLE__ +// fooSampleDSPView.mm +service_ptr ConfigureSampleDSP( fb2k::hwnd_t parent, dsp_preset_edit_callback_v2::ptr callback ); +#endif + +class dsp_sample : public dsp_impl_base +{ +public: + dsp_sample(dsp_preset const & in) : m_gain(parse_preset(in)) { + } + + static GUID g_get_guid() { + return dsp_sample_common::guid; + } + + static void g_get_name(pfc::string_base & p_out) { p_out = "Sample DSP";} + + bool on_chunk(audio_chunk * chunk,abort_callback &) { + // Perform any operations on the chunk here. + // The most simple DSPs can just alter the chunk in-place here and skip the following functions. + + + // trivial DSP code: apply our gain to the audio data. + chunk->scale( (audio_sample)audio_math::gain_to_scale( m_gain ) ); + + // To retrieve the currently processed track, use get_cur_file(). + // Warning: the track is not always known - it's up to the calling component to provide this data and in some situations we'll be working with data that doesn't originate from an audio file. + // If you rely on get_cur_file(), you should change need_track_change_mark() to return true to get accurate information when advancing between tracks. + + return true; //Return true to keep the chunk or false to drop it from the chain. + } + + void on_endofplayback(abort_callback &) { + // The end of playlist has been reached, we've already received the last decoded audio chunk. + // We need to finish any pending processing and output any buffered data through insert_chunk(). + } + void on_endoftrack(abort_callback &) { + // Should do nothing except for special cases where your DSP performs special operations when changing tracks. + // If this function does anything, you must change need_track_change_mark() to return true. + // If you have pending audio data that you wish to output, you can use insert_chunk() to do so. + } + + void flush() { + // If you have any audio data buffered, you should drop it immediately and reset the DSP to a freshly initialized state. + // Called after a seek etc. + } + + double get_latency() { + // If the DSP buffers some amount of audio data, it should return the duration of buffered data (in seconds) here. + return 0; + } + + bool need_track_change_mark() { + // Return true if you need on_endoftrack() or need to accurately know which track we're currently processing + // WARNING: If you return true, the DSP manager will fire on_endofplayback() at DSPs that are before us in the chain on track change to ensure that we get an accurate mark, so use it only when needed. + return false; + } + static bool g_get_default_preset(dsp_preset & p_out) { + make_preset(0, p_out); + return true; + } +#ifdef _WIN32 + static void g_show_config_popup(const dsp_preset & p_data,HWND p_parent,dsp_preset_edit_callback & p_callback) { + ::RunDSPConfigPopup(p_data, p_parent, p_callback); + } +#endif // _WIN32 +#ifdef __APPLE__ + static service_ptr g_show_config_popup( fb2k::hwnd_t parent, dsp_preset_edit_callback_v2::ptr callback ) { + return ConfigureSampleDSP( parent, callback ); + } +#endif // __APPLE__ + static bool g_have_config_popup() {return true;} +private: + float m_gain; +}; + +// Use dsp_factory_nopreset_t<> instead of dsp_factory_t<> if your DSP does not provide preset/configuration functionality. +static dsp_factory_t g_dsp_sample_factory; + +#ifdef _WIN32 + +class CMyDSPPopup : public CDialogImpl { +public: + CMyDSPPopup(const dsp_preset & initData, dsp_preset_edit_callback & callback) : m_initData(initData), m_callback(callback) {} + + enum { IDD = IDD_DSP }; + + enum { + RangeMin = -20, + RangeMax = 20, + + RangeTotal = RangeMax - RangeMin + }; + + BEGIN_MSG_MAP_EX(CMyDSPPopup) + MSG_WM_INITDIALOG(OnInitDialog) + COMMAND_HANDLER_EX(IDOK, BN_CLICKED, OnButton) + COMMAND_HANDLER_EX(IDCANCEL, BN_CLICKED, OnButton) + MSG_WM_HSCROLL(OnHScroll) + END_MSG_MAP() + +private: + + BOOL OnInitDialog(CWindow, LPARAM) { + m_dark.AddDialogWithControls(m_hWnd); + m_slider = GetDlgItem(IDC_SLIDER); + m_slider.SetRange(0, RangeTotal); + + { + float val = parse_preset(m_initData); + m_slider.SetPos( pfc::clip_t( pfc::rint32(val), RangeMin, RangeMax ) - RangeMin ); + RefreshLabel(val); + } + return TRUE; + } + + void OnButton(UINT, int id, CWindow) { + EndDialog(id); + } + + void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar pScrollBar) { + float val; + val = (float) ( m_slider.GetPos() + RangeMin ); + + { + dsp_preset_impl preset; + make_preset(val, preset); + m_callback.on_preset_changed(preset); + } + RefreshLabel(val); + } + + void RefreshLabel(float val) { + pfc::string_formatter msg; msg << pfc::format_float(val) << " dB"; + ::uSetDlgItemText(*this, IDC_SLIDER_LABEL, msg); + } + + const dsp_preset & m_initData; // modal dialog so we can reference this caller-owned object. + dsp_preset_edit_callback & m_callback; + + CTrackBarCtrl m_slider; + fb2k::CDarkModeHooks m_dark; +}; + +static void RunDSPConfigPopup(const dsp_preset & p_data,HWND p_parent,dsp_preset_edit_callback & p_callback) { + CMyDSPPopup popup(p_data, p_callback); + if (popup.DoModal(p_parent) != IDOK) { + // If the dialog exited with something else than IDOK,k + // tell host that the editing has been cancelled by sending it old preset data that we got initialized with + p_callback.on_preset_changed(p_data); + } +} +#endif diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/foo_sample/dsp_sample.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/foo_sample/dsp_sample.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,20 @@ +#pragma once + +namespace dsp_sample_common { + //This is our GUID. Generate your own one when reusing this code. + static constexpr GUID guid = { 0x890827b, 0x67df, 0x4c27, { 0xba, 0x1a, 0x4f, 0x95, 0x8d, 0xf, 0xb5, 0xd0 } }; + + static void make_preset(float gain, dsp_preset & out) { + dsp_preset_builder builder; builder << gain; builder.finish(guid, out); + } + static float parse_preset(const dsp_preset & in) { + try { + float gain; + dsp_preset_parser parser(in); parser >> gain; + return gain; + } catch(exception_io_data const &) {return 0;} + } + +} + +using namespace dsp_sample_common; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/foo_sample/foo_sample.rc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/foo_sample/foo_sample.rc Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,217 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (United States) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_MYPREFERENCES DIALOGEX 0, 0, 332, 288 +STYLE DS_SETFONT | WS_CHILD +FONT 8, "Microsoft Sans Serif", 400, 0, 0x0 +BEGIN + RTEXT "Bogo setting 1:",IDC_STATIC,44,60,59,8 + EDITTEXT IDC_BOGO1,104,58,40,12,ES_AUTOHSCROLL | ES_NUMBER + RTEXT "Bogo setting 2:",IDC_STATIC,44,82,59,8 + EDITTEXT IDC_BOGO2,104,80,40,12,ES_AUTOHSCROLL | ES_NUMBER + LTEXT "This is a sample preferences page with meaningless settings.",IDC_STATIC,52,24,204,8 +END + +IDD_PLAYBACK_STATE DIALOGEX 0, 0, 260, 95 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Playback State Demo" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + LTEXT "Pattern:",IDC_STATIC,12,8,28,8 + EDITTEXT IDC_PATTERN,8,16,244,12,ES_AUTOHSCROLL + LTEXT "State:",IDC_STATIC,12,36,21,8 + EDITTEXT IDC_STATE,8,44,244,12,ES_AUTOHSCROLL | ES_READONLY + PUSHBUTTON "Context menu test area - right click me",IDC_CONTEXTMENU,8,60,244,14 + PUSHBUTTON "Play",IDC_PLAY,12,76,36,14 + PUSHBUTTON "Pause",IDC_PAUSE,52,76,36,14 + PUSHBUTTON "Stop",IDC_STOP,92,76,36,14 + PUSHBUTTON "Prev",IDC_PREV,132,76,36,14 + PUSHBUTTON "Next",IDC_NEXT,172,76,36,14 + PUSHBUTTON "Rand",IDC_RAND,212,76,36,14 +END + +IDD_DSP DIALOGEX 0, 0, 284, 83 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Sample DSP Configuration" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + DEFPUSHBUTTON "OK",IDOK,172,64,50,14 + PUSHBUTTON "Cancel",IDCANCEL,226,64,50,14 + CONTROL "",IDC_SLIDER,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,12,12,260,24 + CTEXT "N dB",IDC_SLIDER_LABEL,120,44,44,8 +END + +IDD_UI_ELEMENT DIALOGEX 0, 0, 221, 113 +STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD | WS_SYSMENU +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + CONTROL "Lock min width @ 200 units",IDC_LOCK_MIN_WIDTH,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,20,104,10 + CONTROL "Lock min height @ 200 units",IDC_LOCK_MIN_HEIGHT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,32,107,10 + LTEXT "Current size: XXX x XXX units / XXX x XXX pixels",IDC_STATIC_SIZE,8,4,168,8 + CONTROL "Lock max width @ 400 units",IDC_LOCK_MAX_WIDTH,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,48,106,10 + CONTROL "Lock max height @ 400 units",IDC_LOCK_MAX_HEIGHT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,60,108,10 +END + +IDD_THREADS DIALOGEX 0, 0, 364, 232 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME +CAPTION "UI and Threads Demo" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + DEFPUSHBUTTON "Start",IDOK,252,200,50,14 + PUSHBUTTON "Cancel",IDCANCEL,306,200,50,14 + LISTBOX IDC_LIST,4,20,356,176,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP + LTEXT "Header",IDC_HEADER,8,4,348,8 +END + +IDD_LISTCONTROL_DEMO DIALOGEX 0, 0, 311, 177 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Dialog" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + CONTROL "",IDC_LIST1,"SysListView32",LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,12,12,288,156 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_MYPREFERENCES, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 325 + TOPMARGIN, 7 + BOTTOMMARGIN, 281 + END + + IDD_PLAYBACK_STATE, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 253 + TOPMARGIN, 7 + BOTTOMMARGIN, 88 + END + + IDD_DSP, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 277 + TOPMARGIN, 7 + BOTTOMMARGIN, 76 + END + + IDD_UI_ELEMENT, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 214 + TOPMARGIN, 7 + BOTTOMMARGIN, 106 + END + + IDD_THREADS, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 357 + TOPMARGIN, 7 + BOTTOMMARGIN, 225 + END + + IDD_LISTCONTROL_DEMO, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 304 + TOPMARGIN, 7 + BOTTOMMARGIN, 170 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// AFX_DIALOG_LAYOUT +// + +IDD_UI_ELEMENT AFX_DIALOG_LAYOUT +BEGIN + 0 +END + +IDD_THREADS AFX_DIALOG_LAYOUT +BEGIN + 0 +END + +IDD_LISTCONTROL_DEMO AFX_DIALOG_LAYOUT +BEGIN + 0 +END + +#endif // English (United States) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/foo_sample/foo_sample.sln --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/foo_sample/foo_sample.sln Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,55 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.27130.2027 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "foo_sample", "foo_sample.vcxproj", "{85FBFD09-0099-4FE9-9DB6-78DB6F60F817}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "foobar2000_SDK", "..\SDK\foobar2000_SDK.vcxproj", "{E8091321-D79D-4575-86EF-064EA1A4A20D}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pfc", "..\..\pfc\pfc.vcxproj", "{EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "foobar2000_sdk_helpers", "..\helpers\foobar2000_sdk_helpers.vcxproj", "{EE47764E-A202-4F85-A767-ABDAB4AFF35F}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "foobar2000_component_client", "..\foobar2000_component_client\foobar2000_component_client.vcxproj", "{71AD2674-065B-48F5-B8B0-E1F9D3892081}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libPPUI", "..\..\libPPUI\libPPUI.vcxproj", "{7729EB82-4069-4414-964B-AD399091A03F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x86 = Debug|x86 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {85FBFD09-0099-4FE9-9DB6-78DB6F60F817}.Debug|x86.ActiveCfg = Debug|Win32 + {85FBFD09-0099-4FE9-9DB6-78DB6F60F817}.Debug|x86.Build.0 = Debug|Win32 + {85FBFD09-0099-4FE9-9DB6-78DB6F60F817}.Release|x86.ActiveCfg = Release|Win32 + {85FBFD09-0099-4FE9-9DB6-78DB6F60F817}.Release|x86.Build.0 = Release|Win32 + {E8091321-D79D-4575-86EF-064EA1A4A20D}.Debug|x86.ActiveCfg = Debug|Win32 + {E8091321-D79D-4575-86EF-064EA1A4A20D}.Debug|x86.Build.0 = Debug|Win32 + {E8091321-D79D-4575-86EF-064EA1A4A20D}.Release|x86.ActiveCfg = Release|Win32 + {E8091321-D79D-4575-86EF-064EA1A4A20D}.Release|x86.Build.0 = Release|Win32 + {EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}.Debug|x86.ActiveCfg = Debug FB2K|Win32 + {EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}.Debug|x86.Build.0 = Debug FB2K|Win32 + {EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}.Release|x86.ActiveCfg = Release FB2K|Win32 + {EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}.Release|x86.Build.0 = Release FB2K|Win32 + {EE47764E-A202-4F85-A767-ABDAB4AFF35F}.Debug|x86.ActiveCfg = Debug|Win32 + {EE47764E-A202-4F85-A767-ABDAB4AFF35F}.Debug|x86.Build.0 = Debug|Win32 + {EE47764E-A202-4F85-A767-ABDAB4AFF35F}.Release|x86.ActiveCfg = Release|Win32 + {EE47764E-A202-4F85-A767-ABDAB4AFF35F}.Release|x86.Build.0 = Release|Win32 + {71AD2674-065B-48F5-B8B0-E1F9D3892081}.Debug|x86.ActiveCfg = Debug|Win32 + {71AD2674-065B-48F5-B8B0-E1F9D3892081}.Debug|x86.Build.0 = Debug|Win32 + {71AD2674-065B-48F5-B8B0-E1F9D3892081}.Release|x86.ActiveCfg = Release|Win32 + {71AD2674-065B-48F5-B8B0-E1F9D3892081}.Release|x86.Build.0 = Release|Win32 + {7729EB82-4069-4414-964B-AD399091A03F}.Debug|x86.ActiveCfg = Debug|Win32 + {7729EB82-4069-4414-964B-AD399091A03F}.Debug|x86.Build.0 = Debug|Win32 + {7729EB82-4069-4414-964B-AD399091A03F}.Release|x86.ActiveCfg = Release|Win32 + {7729EB82-4069-4414-964B-AD399091A03F}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {C30C2B27-E29B-4792-B392-ED729AF2CF49} + EndGlobalSection +EndGlobal diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/foo_sample/foo_sample.vcxproj --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/foo_sample/foo_sample.vcxproj Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,395 @@ + + + + + Debug + ARM64 + + + Debug + ARM64EC + + + Debug + Win32 + + + Debug + x64 + + + Release + ARM64 + + + Release + ARM64EC + + + Release + Win32 + + + Release + x64 + + + + {85FBFD09-0099-4FE9-9DB6-78DB6F60F817} + foo_input_raw + Win32Proj + 10.0 + + + + DynamicLibrary + Unicode + true + v142 + + + DynamicLibrary + Unicode + true + v142 + + + DynamicLibrary + Unicode + true + v143 + + + DynamicLibrary + Unicode + true + v143 + + + DynamicLibrary + Unicode + v142 + + + DynamicLibrary + Unicode + v142 + + + DynamicLibrary + Unicode + v143 + + + DynamicLibrary + Unicode + v143 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + true + true + true + true + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + false + false + false + false + + + + Disabled + EnableFastChecks + MultiThreadedDebugDLL + Use + stdafx.h + Level3 + ProgramDatabase + 4715 + ..;../.. + Fast + stdcpp17 + + + true + Windows + false + + + MachineX86 + ../shared/shared-$(Platform).lib + + + + + Disabled + EnableFastChecks + MultiThreadedDebugDLL + Use + stdafx.h + Level3 + ProgramDatabase + 4715 + ..;../.. + Fast + stdcpp17 + + + true + Windows + false + + + ../shared/shared-$(Platform).lib + + + + + Disabled + EnableFastChecks + MultiThreadedDebugDLL + Use + stdafx.h + Level3 + ProgramDatabase + 4715 + ..;../.. + Fast + stdcpp17 + + + true + Windows + + + ../shared/shared-$(Platform).lib + + + + + Disabled + EnableFastChecks + MultiThreadedDebugDLL + Use + stdafx.h + Level3 + ProgramDatabase + 4715 + ..;../.. + Fast + stdcpp17 + + + true + Windows + + + ../shared/shared-$(Platform).lib + + + + + MultiThreadedDLL + Use + stdafx.h + Level3 + ProgramDatabase + /d2notypeopt %(AdditionalOptions) + 4715 + false + true + true + ..;../.. + Fast + NDEBUG;_WINDLL;%(PreprocessorDefinitions) + stdcpp17 + + + true + Windows + true + true + false + + + MachineX86 + ../shared/shared-$(Platform).lib + + + + + MultiThreadedDLL + Use + stdafx.h + Level3 + ProgramDatabase + /d2notypeopt %(AdditionalOptions) + 4715 + false + true + true + ..;../.. + Fast + NDEBUG;_WINDLL;%(PreprocessorDefinitions) + stdcpp17 + + + true + Windows + true + true + false + + + ../shared/shared-$(Platform).lib + + + + + MultiThreadedDLL + Use + stdafx.h + Level3 + ProgramDatabase + /d2notypeopt %(AdditionalOptions) + 4715 + false + true + true + ..;../.. + Fast + NDEBUG;_WINDLL;%(PreprocessorDefinitions) + stdcpp17 + + + true + Windows + true + true + + + ../shared/shared-$(Platform).lib + + + + + MultiThreadedDLL + Use + stdafx.h + Level3 + ProgramDatabase + /d2notypeopt %(AdditionalOptions) + 4715 + false + true + true + ..;../.. + Fast + NDEBUG;_WINDLL;%(PreprocessorDefinitions) + stdcpp17 + + + true + Windows + true + true + + + ../shared/shared-$(Platform).lib + + + + + + + + + + + + + + + + + Create + Create + Create + Create + Create + Create + Create + Create + + + + + + + + + + + + + + + + + + + + + + + + {7729eb82-4069-4414-964b-ad399091a03f} + + + {ebfffb4e-261d-44d3-b89c-957b31a0bf9c} + + + {71ad2674-065b-48f5-b8b0-e1f9d3892081} + + + {ee47764e-a202-4f85-a767-abdab4aff35f} + + + {e8091321-d79d-4575-86ef-064ea1a4a20d} + + + + + \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/foo_sample/foo_sample.vcxproj.filters --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/foo_sample/foo_sample.vcxproj.filters Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,101 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Resource Files + + + + + + \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/foo_sample/foo_sample.xcodeproj/project.pbxproj --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/foo_sample/foo_sample.xcodeproj/project.pbxproj Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,450 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 54; + objects = { + +/* Begin PBXBuildFile section */ + 0F1FDDBA2AA0ADDF00DE8967 /* initquit.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F1FDDB62AA0ADDF00DE8967 /* initquit.cpp */; }; + 0F1FDDBB2AA0ADDF00DE8967 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F1FDDB72AA0ADDF00DE8967 /* main.cpp */; }; + 0F1FDDC02AA0AE1E00DE8967 /* libfoobar2000_SDK.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0F1FDDBD2AA0AE1E00DE8967 /* libfoobar2000_SDK.a */; }; + 0F1FDDC12AA0AE1E00DE8967 /* libfoobar2000_SDK_helpers.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0F1FDDBE2AA0AE1E00DE8967 /* libfoobar2000_SDK_helpers.a */; }; + 0F1FDDC22AA0AE1E00DE8967 /* libpfc-Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0F1FDDBF2AA0AE1E00DE8967 /* libpfc-Mac.a */; }; + 0F1FDDC82AA0B1F800DE8967 /* libshared.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0F1FDDC72AA0B1F800DE8967 /* libshared.a */; }; + 0F1FDDCA2AA0B1FE00DE8967 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0F1FDDC92AA0B1FE00DE8967 /* Cocoa.framework */; }; + 0F1FDDDE2AA0B34200DE8967 /* libfoobar2000_component_client.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0F1FDDDD2AA0B34200DE8967 /* libfoobar2000_component_client.a */; }; + 0F62440A2AA1E59E004FEC96 /* preferences.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F6244072AA1E4F4004FEC96 /* preferences.cpp */; }; + 0F6D10F12AA3C35C00774EED /* fooDecibelFormatter.m in Sources */ = {isa = PBXBuildFile; fileRef = 0F6D10EF2AA3C35C00774EED /* fooDecibelFormatter.m */; }; + 0FBE14512AA1E85F00B1F71E /* NSView+embed.m in Sources */ = {isa = PBXBuildFile; fileRef = 0FBE14452AA1E85F00B1F71E /* NSView+embed.m */; }; + 0FBE14552AA1E8C800B1F71E /* fooSampleMacPreferences.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0FBE14532AA1E8C800B1F71E /* fooSampleMacPreferences.mm */; }; + 0FBE14562AA1E8C800B1F71E /* fooSampleMacPreferences.xib in Resources */ = {isa = PBXBuildFile; fileRef = 0FBE14542AA1E8C800B1F71E /* fooSampleMacPreferences.xib */; }; + 0FBE14622AA1F74200B1F71E /* rating.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FBE14582AA1F74200B1F71E /* rating.cpp */; }; + 0FBE14632AA1F74200B1F71E /* contextmenu.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FBE14592AA1F74200B1F71E /* contextmenu.cpp */; }; + 0FBE14642AA1F74200B1F71E /* input_raw.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FBE145A2AA1F74200B1F71E /* input_raw.cpp */; }; + 0FBE14652AA1F74200B1F71E /* decode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FBE145B2AA1F74200B1F71E /* decode.cpp */; }; + 0FBE14662AA1F74200B1F71E /* dsp_sample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FBE145C2AA1F74200B1F71E /* dsp_sample.cpp */; }; + 0FBE14672AA1F74200B1F71E /* mainmenu-dynamic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FBE145D2AA1F74200B1F71E /* mainmenu-dynamic.cpp */; }; + 0FBE14692AA1F74200B1F71E /* IO.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FBE145F2AA1F74200B1F71E /* IO.cpp */; }; + 0FBE146A2AA1F74200B1F71E /* playback_stream_capture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FBE14602AA1F74200B1F71E /* playback_stream_capture.cpp */; }; + 0FBE146C2AA1FF1500B1F71E /* ui_and_threads.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FBE146B2AA1FF1500B1F71E /* ui_and_threads.cpp */; }; + 0FCA71142AA21F69001CB0F2 /* fooSampleDSPView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0FCA71122AA21F69001CB0F2 /* fooSampleDSPView.mm */; }; + 0FCA71152AA21F69001CB0F2 /* fooSampleDSPView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 0FCA71132AA21F69001CB0F2 /* fooSampleDSPView.xib */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 0F1FDDAD2AA0AD9B00DE8967 /* foo_sample.component */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = foo_sample.component; sourceTree = BUILT_PRODUCTS_DIR; }; + 0F1FDDB42AA0ADDF00DE8967 /* mainmenu.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = mainmenu.cpp; sourceTree = ""; }; + 0F1FDDB52AA0ADDF00DE8967 /* playback_state.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = playback_state.cpp; sourceTree = ""; }; + 0F1FDDB62AA0ADDF00DE8967 /* initquit.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = initquit.cpp; sourceTree = ""; }; + 0F1FDDB72AA0ADDF00DE8967 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; + 0F1FDDBD2AA0AE1E00DE8967 /* libfoobar2000_SDK.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libfoobar2000_SDK.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 0F1FDDBE2AA0AE1E00DE8967 /* libfoobar2000_SDK_helpers.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libfoobar2000_SDK_helpers.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 0F1FDDBF2AA0AE1E00DE8967 /* libpfc-Mac.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = "libpfc-Mac.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 0F1FDDC62AA0AF8400DE8967 /* stdafx.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = stdafx.h; sourceTree = ""; }; + 0F1FDDC72AA0B1F800DE8967 /* libshared.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libshared.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 0F1FDDC92AA0B1FE00DE8967 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; + 0F1FDDDD2AA0B34200DE8967 /* libfoobar2000_component_client.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libfoobar2000_component_client.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 0F6244072AA1E4F4004FEC96 /* preferences.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = preferences.cpp; sourceTree = ""; }; + 0F6D10EF2AA3C35C00774EED /* fooDecibelFormatter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = fooDecibelFormatter.m; sourceTree = ""; }; + 0F6D10F02AA3C35C00774EED /* fooDecibelFormatter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fooDecibelFormatter.h; sourceTree = ""; }; + 0F7F817F2AB87BA70051262F /* foobar2000-mac-class-suffix.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "foobar2000-mac-class-suffix.h"; sourceTree = ""; }; + 0FBE14402AA1E85F00B1F71E /* NSView+embed.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSView+embed.h"; sourceTree = ""; }; + 0FBE14452AA1E85F00B1F71E /* NSView+embed.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSView+embed.m"; sourceTree = ""; }; + 0FBE14522AA1E8C800B1F71E /* fooSampleMacPreferences.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = fooSampleMacPreferences.h; sourceTree = ""; }; + 0FBE14532AA1E8C800B1F71E /* fooSampleMacPreferences.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = fooSampleMacPreferences.mm; sourceTree = ""; }; + 0FBE14542AA1E8C800B1F71E /* fooSampleMacPreferences.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = fooSampleMacPreferences.xib; sourceTree = ""; }; + 0FBE14582AA1F74200B1F71E /* rating.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = rating.cpp; sourceTree = ""; }; + 0FBE14592AA1F74200B1F71E /* contextmenu.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = contextmenu.cpp; sourceTree = ""; }; + 0FBE145A2AA1F74200B1F71E /* input_raw.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = input_raw.cpp; sourceTree = ""; }; + 0FBE145B2AA1F74200B1F71E /* decode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = decode.cpp; sourceTree = ""; }; + 0FBE145C2AA1F74200B1F71E /* dsp_sample.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = dsp_sample.cpp; sourceTree = ""; }; + 0FBE145D2AA1F74200B1F71E /* mainmenu-dynamic.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "mainmenu-dynamic.cpp"; sourceTree = ""; }; + 0FBE145E2AA1F74200B1F71E /* readme.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = readme.txt; sourceTree = ""; }; + 0FBE145F2AA1F74200B1F71E /* IO.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IO.cpp; sourceTree = ""; }; + 0FBE14602AA1F74200B1F71E /* playback_stream_capture.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = playback_stream_capture.cpp; sourceTree = ""; }; + 0FBE14612AA1F74200B1F71E /* playback_stream_capture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = playback_stream_capture.h; sourceTree = ""; }; + 0FBE146B2AA1FF1500B1F71E /* ui_and_threads.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ui_and_threads.cpp; sourceTree = ""; }; + 0FCA71112AA21F69001CB0F2 /* fooSampleDSPView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = fooSampleDSPView.h; sourceTree = ""; }; + 0FCA71122AA21F69001CB0F2 /* fooSampleDSPView.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = fooSampleDSPView.mm; sourceTree = ""; }; + 0FCA71132AA21F69001CB0F2 /* fooSampleDSPView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = fooSampleDSPView.xib; sourceTree = ""; }; + 0FD323BF2AA3C45C00C0C2F7 /* dsp_sample.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = dsp_sample.h; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 0F1FDDAA2AA0AD9B00DE8967 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 0F1FDDDE2AA0B34200DE8967 /* libfoobar2000_component_client.a in Frameworks */, + 0F1FDDCA2AA0B1FE00DE8967 /* Cocoa.framework in Frameworks */, + 0F1FDDC82AA0B1F800DE8967 /* libshared.a in Frameworks */, + 0F1FDDC02AA0AE1E00DE8967 /* libfoobar2000_SDK.a in Frameworks */, + 0F1FDDC12AA0AE1E00DE8967 /* libfoobar2000_SDK_helpers.a in Frameworks */, + 0F1FDDC22AA0AE1E00DE8967 /* libpfc-Mac.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 0F1FDDA42AA0AD9B00DE8967 = { + isa = PBXGroup; + children = ( + 0F7F817F2AB87BA70051262F /* foobar2000-mac-class-suffix.h */, + 0FBE146B2AA1FF1500B1F71E /* ui_and_threads.cpp */, + 0FBE14592AA1F74200B1F71E /* contextmenu.cpp */, + 0FBE145B2AA1F74200B1F71E /* decode.cpp */, + 0FBE145C2AA1F74200B1F71E /* dsp_sample.cpp */, + 0FD323BF2AA3C45C00C0C2F7 /* dsp_sample.h */, + 0FBE145A2AA1F74200B1F71E /* input_raw.cpp */, + 0FBE145F2AA1F74200B1F71E /* IO.cpp */, + 0FBE145D2AA1F74200B1F71E /* mainmenu-dynamic.cpp */, + 0FBE14602AA1F74200B1F71E /* playback_stream_capture.cpp */, + 0FBE14612AA1F74200B1F71E /* playback_stream_capture.h */, + 0FBE14582AA1F74200B1F71E /* rating.cpp */, + 0FBE145E2AA1F74200B1F71E /* readme.txt */, + 0FBE14572AA1F41A00B1F71E /* Mac */, + 0F6244072AA1E4F4004FEC96 /* preferences.cpp */, + 0F1FDDC62AA0AF8400DE8967 /* stdafx.h */, + 0F1FDDB62AA0ADDF00DE8967 /* initquit.cpp */, + 0F1FDDB72AA0ADDF00DE8967 /* main.cpp */, + 0F1FDDB42AA0ADDF00DE8967 /* mainmenu.cpp */, + 0F1FDDB52AA0ADDF00DE8967 /* playback_state.cpp */, + 0FBE14362AA1E85F00B1F71E /* helpers-mac */, + 0F1FDDAE2AA0AD9B00DE8967 /* Products */, + 0F1FDDBC2AA0AE1E00DE8967 /* Frameworks */, + ); + sourceTree = ""; + }; + 0F1FDDAE2AA0AD9B00DE8967 /* Products */ = { + isa = PBXGroup; + children = ( + 0F1FDDAD2AA0AD9B00DE8967 /* foo_sample.component */, + ); + name = Products; + sourceTree = ""; + }; + 0F1FDDBC2AA0AE1E00DE8967 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 0F1FDDDD2AA0B34200DE8967 /* libfoobar2000_component_client.a */, + 0F1FDDC92AA0B1FE00DE8967 /* Cocoa.framework */, + 0F1FDDC72AA0B1F800DE8967 /* libshared.a */, + 0F1FDDBD2AA0AE1E00DE8967 /* libfoobar2000_SDK.a */, + 0F1FDDBE2AA0AE1E00DE8967 /* libfoobar2000_SDK_helpers.a */, + 0F1FDDBF2AA0AE1E00DE8967 /* libpfc-Mac.a */, + ); + name = Frameworks; + sourceTree = ""; + }; + 0FBE14362AA1E85F00B1F71E /* helpers-mac */ = { + isa = PBXGroup; + children = ( + 0F6D10F02AA3C35C00774EED /* fooDecibelFormatter.h */, + 0F6D10EF2AA3C35C00774EED /* fooDecibelFormatter.m */, + 0FBE14402AA1E85F00B1F71E /* NSView+embed.h */, + 0FBE14452AA1E85F00B1F71E /* NSView+embed.m */, + ); + name = "helpers-mac"; + path = "../helpers-mac"; + sourceTree = ""; + }; + 0FBE14572AA1F41A00B1F71E /* Mac */ = { + isa = PBXGroup; + children = ( + 0FBE14522AA1E8C800B1F71E /* fooSampleMacPreferences.h */, + 0FBE14532AA1E8C800B1F71E /* fooSampleMacPreferences.mm */, + 0FBE14542AA1E8C800B1F71E /* fooSampleMacPreferences.xib */, + 0FCA71112AA21F69001CB0F2 /* fooSampleDSPView.h */, + 0FCA71122AA21F69001CB0F2 /* fooSampleDSPView.mm */, + 0FCA71132AA21F69001CB0F2 /* fooSampleDSPView.xib */, + ); + path = Mac; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 0F1FDDAC2AA0AD9B00DE8967 /* foo_sample */ = { + isa = PBXNativeTarget; + buildConfigurationList = 0F1FDDB12AA0AD9B00DE8967 /* Build configuration list for PBXNativeTarget "foo_sample" */; + buildPhases = ( + 0F1FDDA92AA0AD9B00DE8967 /* Sources */, + 0F1FDDAA2AA0AD9B00DE8967 /* Frameworks */, + 0F1FDDAB2AA0AD9B00DE8967 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = foo_sample; + productName = foo_sample; + productReference = 0F1FDDAD2AA0AD9B00DE8967 /* foo_sample.component */; + productType = "com.apple.product-type.bundle"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 0F1FDDA52AA0AD9B00DE8967 /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastUpgradeCheck = 1500; + TargetAttributes = { + 0F1FDDAC2AA0AD9B00DE8967 = { + CreatedOnToolsVersion = 14.3.1; + }; + }; + }; + buildConfigurationList = 0F1FDDA82AA0AD9B00DE8967 /* Build configuration list for PBXProject "foo_sample" */; + compatibilityVersion = "Xcode 12.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 0F1FDDA42AA0AD9B00DE8967; + productRefGroup = 0F1FDDAE2AA0AD9B00DE8967 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 0F1FDDAC2AA0AD9B00DE8967 /* foo_sample */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 0F1FDDAB2AA0AD9B00DE8967 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 0FBE14562AA1E8C800B1F71E /* fooSampleMacPreferences.xib in Resources */, + 0FCA71152AA21F69001CB0F2 /* fooSampleDSPView.xib in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 0F1FDDA92AA0AD9B00DE8967 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 0FBE14692AA1F74200B1F71E /* IO.cpp in Sources */, + 0FBE14552AA1E8C800B1F71E /* fooSampleMacPreferences.mm in Sources */, + 0FBE14672AA1F74200B1F71E /* mainmenu-dynamic.cpp in Sources */, + 0FBE14512AA1E85F00B1F71E /* NSView+embed.m in Sources */, + 0FBE14632AA1F74200B1F71E /* contextmenu.cpp in Sources */, + 0FCA71142AA21F69001CB0F2 /* fooSampleDSPView.mm in Sources */, + 0FBE14652AA1F74200B1F71E /* decode.cpp in Sources */, + 0F6D10F12AA3C35C00774EED /* fooDecibelFormatter.m in Sources */, + 0FBE146C2AA1FF1500B1F71E /* ui_and_threads.cpp in Sources */, + 0FBE14662AA1F74200B1F71E /* dsp_sample.cpp in Sources */, + 0F1FDDBB2AA0ADDF00DE8967 /* main.cpp in Sources */, + 0FBE14642AA1F74200B1F71E /* input_raw.cpp in Sources */, + 0F62440A2AA1E59E004FEC96 /* preferences.cpp in Sources */, + 0F1FDDBA2AA0ADDF00DE8967 /* initquit.cpp in Sources */, + 0FBE14622AA1F74200B1F71E /* rating.cpp in Sources */, + 0FBE146A2AA1F74200B1F71E /* playback_stream_capture.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 0F1FDDAF2AA0AD9B00DE8967 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEAD_CODE_STRIPPING = YES; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = stdafx.h; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + .., + ../.., + ); + MACOSX_DEPLOYMENT_TARGET = 11.0; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + }; + name = Debug; + }; + 0F1FDDB02AA0AD9B00DE8967 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEAD_CODE_STRIPPING = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = stdafx.h; + GCC_PREPROCESSOR_DEFINITIONS = "NDEBUG=1"; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + .., + ../.., + ); + MACOSX_DEPLOYMENT_TARGET = 11.0; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = macosx; + }; + name = Release; + }; + 0F1FDDB22AA0AD9B00DE8967 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=macosx*]" = "-"; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + CURRENT_PROJECT_VERSION = 1; + DEAD_CODE_STRIPPING = YES; + DEVELOPMENT_TEAM = ""; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + INFOPLIST_KEY_NSPrincipalClass = ""; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Bundles"; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = "com.foobar2000.foo-sample"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + WRAPPER_EXTENSION = component; + }; + name = Debug; + }; + 0F1FDDB32AA0AD9B00DE8967 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=macosx*]" = "-"; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + CURRENT_PROJECT_VERSION = 1; + DEAD_CODE_STRIPPING = YES; + DEVELOPMENT_TEAM = ""; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + INFOPLIST_KEY_NSPrincipalClass = ""; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Bundles"; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = "com.foobar2000.foo-sample"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + WRAPPER_EXTENSION = component; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 0F1FDDA82AA0AD9B00DE8967 /* Build configuration list for PBXProject "foo_sample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 0F1FDDAF2AA0AD9B00DE8967 /* Debug */, + 0F1FDDB02AA0AD9B00DE8967 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 0F1FDDB12AA0AD9B00DE8967 /* Build configuration list for PBXNativeTarget "foo_sample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 0F1FDDB22AA0AD9B00DE8967 /* Debug */, + 0F1FDDB32AA0AD9B00DE8967 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 0F1FDDA52AA0AD9B00DE8967 /* Project object */; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/foo_sample/foo_sample.xcworkspace/contents.xcworkspacedata --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/foo_sample/foo_sample.xcworkspace/contents.xcworkspacedata Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/foo_sample/foobar2000-mac-class-suffix.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/foo_sample/foobar2000-mac-class-suffix.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,1 @@ +#define FOOBAR2000_MAC_CLASS_SUFFIX _foo_sample diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/foo_sample/initquit.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/foo_sample/initquit.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,17 @@ +#include "stdafx.h" + +namespace { + // Sample initquit implementation. See also: initquit class documentation in relevant header. + class myinitquit : public initquit { + public: + void on_init() { + console::print("Sample component: on_init()"); + } + void on_quit() { + console::print("Sample component: on_quit()"); + } + }; + + FB2K_SERVICE_FACTORY( myinitquit ); + +} // namespace diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/foo_sample/input_raw.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/foo_sample/input_raw.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,106 @@ +#include "stdafx.h" + +enum { + raw_bits_per_sample = 16, + raw_channels = 2, + raw_sample_rate = 44100, + + raw_bytes_per_sample = raw_bits_per_sample / 8, + raw_total_sample_width = raw_bytes_per_sample * raw_channels, +}; + +// Note that input class does *not* implement virtual methods or derive from interface classes. +// Our methods get called over input framework templates. See input_singletrack_impl for descriptions of what each method does. +// input_stubs just provides stub implementations of mundane methods that are irrelevant for most implementations. +class input_raw : public input_stubs { +public: + void open(service_ptr_t p_filehint,const char * p_path,t_input_open_reason p_reason,abort_callback & p_abort) { + if (p_reason == input_open_info_write) throw exception_tagging_unsupported();//our input does not support retagging. + m_file = p_filehint;//p_filehint may be null, hence next line + input_open_file_helper(m_file,p_path,p_reason,p_abort);//if m_file is null, opens file with appropriate privileges for our operation (read/write for writing tags, read-only otherwise). + } + + void get_info(file_info & p_info,abort_callback & p_abort) { + t_filesize size = m_file->get_size(p_abort); + //note that the file size is not always known, for an example, live streams and alike have no defined size and filesize_invalid is returned + if (size != filesize_invalid) { + //file size is known, let's set length + p_info.set_length(audio_math::samples_to_time( size / raw_total_sample_width, raw_sample_rate)); + } + //note that the values below should be based on contents of the file itself, NOT on user-configurable variables for an example. To report info that changes independently from file contents, use get_dynamic_info/get_dynamic_info_track instead. + p_info.info_set_int("samplerate",raw_sample_rate); + p_info.info_set_int("channels",raw_channels); + p_info.info_set_int("bitspersample",raw_bits_per_sample); + + // Indicate whether this is a fixedpoint or floatingpoint stream, when using bps >= 32 + // As 32bit fixedpoint can't be decoded losslessly by fb2k, does not fit in float32 audio_sample. + if ( raw_bits_per_sample >= 32 ) p_info.info_set("bitspersample_extra", "fixed-point"); + + p_info.info_set("encoding","lossless"); + p_info.info_set_bitrate((raw_bits_per_sample * raw_channels * raw_sample_rate + 500 /* rounding for bps to kbps*/ ) / 1000 /* bps to kbps */); + + } + t_filestats2 get_stats2(unsigned f, abort_callback& a) {return m_file->get_stats2_(f, a);} + t_filestats get_file_stats(abort_callback & p_abort) {return m_file->get_stats(p_abort);} + + void decode_initialize(unsigned p_flags,abort_callback & p_abort) { + m_file->reopen(p_abort);//equivalent to seek to zero, except it also works on nonseekable streams + } + bool decode_run(audio_chunk & p_chunk,abort_callback & p_abort) { + enum { + deltaread = 1024, + }; + + const size_t deltaReadBytes = deltaread * raw_total_sample_width; + // Prepare buffer + m_buffer.set_size(deltaReadBytes); + // Read bytes + size_t got = m_file->read(m_buffer.get_ptr(), deltaReadBytes,p_abort) / raw_total_sample_width; + + // EOF? + if (got == 0) return false; + + // This converts the data that we've read to the audio_chunk's internal format, audio_sample (float 32-bit). + // audio_sample is the audio data format that all fb2k code works with. + p_chunk.set_data_fixedpoint(m_buffer.get_ptr(), got * raw_total_sample_width,raw_sample_rate,raw_channels,raw_bits_per_sample,audio_chunk::g_guess_channel_config(raw_channels)); + + //processed successfully, no EOF + return true; + } + void decode_seek(double p_seconds,abort_callback & p_abort) { + m_file->ensure_seekable();//throw exceptions if someone called decode_seek() despite of our input having reported itself as nonseekable. + // IMPORTANT: convert time to sample offset with proper rounding! audio_math::time_to_samples does this properly for you. + t_filesize target = audio_math::time_to_samples(p_seconds,raw_sample_rate) * raw_total_sample_width; + + // get_size_ex fails (throws exceptions) if size is not known (where get_size would return filesize_invalid). Should never fail on seekable streams (if it does it's not our problem anymore). + t_filesize max = m_file->get_size_ex(p_abort); + if (target > max) target = max;//clip seek-past-eof attempts to legal range (next decode_run() call will just signal EOF). + + m_file->seek(target,p_abort); + } + bool decode_can_seek() {return m_file->can_seek();} + bool decode_get_dynamic_info(file_info & p_out, double & p_timestamp_delta) {return false;} // deals with dynamic information such as VBR bitrates + bool decode_get_dynamic_info_track(file_info & p_out, double & p_timestamp_delta) {return false;} // deals with dynamic information such as track changes in live streams + void decode_on_idle(abort_callback & p_abort) {m_file->on_idle(p_abort);} + + // Note that open() already rejects requests to open for tag writing, so these two should never get called. + void retag(const file_info & p_info,abort_callback & p_abort) {throw exception_tagging_unsupported();} + void remove_tags(abort_callback&) { throw exception_tagging_unsupported(); } + + static bool g_is_our_content_type(const char * p_content_type) {return false;} // match against supported mime types here + static bool g_is_our_path(const char * p_path,const char * p_extension) {return stricmp_utf8(p_extension,"raw") == 0;} + static const char * g_get_name() { return "foo_sample raw input"; } + static const GUID g_get_guid() { + // GUID of the decoder. Replace with your own when reusing code. + static const GUID I_am_foo_sample_and_this_is_my_decoder_GUID = { 0xd9c01c8d, 0x69c5, 0x4eec,{ 0xa2, 0x1c, 0x1d, 0x14, 0xef, 0x65, 0xbf, 0x8b } }; + return I_am_foo_sample_and_this_is_my_decoder_GUID; + } +public: + service_ptr_t m_file; + pfc::array_t m_buffer; +}; + +static input_singletrack_factory_t g_input_raw_factory; + +// Declare .RAW as a supported file type to make it show in "open file" dialog etc. +DECLARE_FILE_TYPE("Raw files","*.RAW"); diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/foo_sample/listcontrol-advanced.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/foo_sample/listcontrol-advanced.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,330 @@ +// Advanced CListControl use demo +// Subclasses a CListControl to use all its features + +#include "stdafx.h" +#include "resource.h" +#include +#include +#include +#include +#include +#include + +#include + +namespace { + struct listData_t { + std::string m_key, m_value; + bool m_checkState = false; + }; + static std::vector makeListData() { + std::vector data; + data.resize( 10 ); + for( size_t walk = 0; walk < data.size(); ++ walk ) { + auto & rec = data[walk]; + rec.m_key = (PFC_string_formatter() << "Item #" << (walk+1) ).c_str(); + rec.m_value = "edit me"; + } + return data; + } + + // See CListControlComplete.h for base class description + typedef CListControlComplete CListControlDemoParent; + + class CListControlDemo : public CListControlDemoParent { + typedef CListControlDemoParent parent_t; + public: + BEGIN_MSG_MAP_EX(CListControlDemo) + CHAIN_MSG_MAP( parent_t ); + MSG_WM_CREATE(OnCreate) + MSG_WM_CONTEXTMENU(OnContextMenu) + END_MSG_MAP() + + + // Context menu handler + void OnContextMenu(CWindow wnd, CPoint point) { + // did we get a (-1,-1) point due to context menu key rather than right click? + // GetContextMenuPoint fixes that, returning a proper point at which the menu should be shown + point = this->GetContextMenuPoint(point); + + CMenu menu; + // WIN32_OP_D() : debug build only return value check + // Used to check for obscure errors in debug builds, does nothing (ignores errors) in release build + WIN32_OP_D(menu.CreatePopupMenu()); + + enum { ID_TEST1 = 1, ID_TEST2, ID_SELECTALL, ID_SELECTNONE, ID_INVERTSEL }; + menu.AppendMenu(MF_STRING, ID_TEST1, L"Test 1"); + menu.AppendMenu(MF_STRING, ID_TEST2, L"Test 2"); + menu.AppendMenu(MF_SEPARATOR); + // Note: Ctrl+A handled automatically by CListControl, no need for us to catch it + menu.AppendMenu(MF_STRING, ID_SELECTALL, L"Select all\tCtrl+A"); + menu.AppendMenu(MF_STRING, ID_SELECTNONE, L"Select none"); + menu.AppendMenu(MF_STRING, ID_INVERTSEL, L"Invert selection"); + + int cmd; + { + // Callback object to show menu command descriptions in the status bar. + // it's actually a hidden window, needs a parent HWND, where we feed our control's HWND + CMenuDescriptionMap descriptions(m_hWnd); + + // Set descriptions of all our items + descriptions.Set(ID_TEST1, "This is a test item #1"); + descriptions.Set(ID_TEST2, "This is a test item #2"); + + descriptions.Set(ID_SELECTALL, "Selects all items"); + descriptions.Set(ID_SELECTNONE, "Deselects all items"); + descriptions.Set(ID_INVERTSEL, "Invert selection"); + + cmd = menu.TrackPopupMenuEx(TPM_RIGHTBUTTON | TPM_NONOTIFY | TPM_RETURNCMD, point.x, point.y, descriptions, nullptr); + } + switch(cmd) { + case ID_TEST1: + { + pfc::string_formatter msg; + msg << "Test command #1 triggered.\r\n"; + msg << this->GetSelectedCount() << " items selected."; + // popup_message : non-blocking MessageBox equivalent + popup_message::g_show(msg, "Information"); + } + break; + case ID_TEST2: + { + pfc::string_formatter msg; + msg << "Test command #1 triggered.\r\n"; + msg << "Selected items:\r\n"; + for( size_t walk = 0; walk < GetItemCount(); ++ walk) { + if ( this->IsItemSelected( walk ) ) { + msg << m_data[walk].m_key.c_str() << "\r\n"; + } + } + msg << "End selected items."; + // popup_message : non-blocking MessageBox equivalent + popup_message::g_show(msg, "Information"); + } + break; + case ID_SELECTALL: + this->SelectAll(); // trivial + break; + case ID_SELECTNONE: + this->SelectNone(); // trivial + break; + case ID_INVERTSEL: + { + auto mask = this->GetSelectionMask(); + this->SetSelection( + // Items which we alter - all of them + pfc::bit_array_true(), + // Selection values - NOT'd original selection mask + pfc::bit_array_not(mask) + ); + // Exclusion of footer item from selection handled via CanSelectItem() + } + break; + } + } + + int OnCreate(LPCREATESTRUCT lpCreateStruct) { + InitHeader(); // set up header control with columns + SetWindowText(L"List Control Demo"); // screen reader will see this + return 0; + } + void InitHeader() { + InitializeHeaderCtrl(HDS_FULLDRAG); + + // never hardcode values in pixels, always use screen DPI + auto DPI = m_dpi; + AddColumn( "Check", MulDiv(60, DPI.cx, 96 ) ); + AddColumn( "Name", MulDiv(100, DPI.cx, 96 ) ); + AddColumn( "Value", MulDiv(100, DPI.cx, 96 ) ); + } + + bool CanSelectItem( size_t row ) const override { + // can not select footer + return row != footerRow(); + } + size_t footerRow() const { + return m_data.size(); + } + t_size GetItemCount() const override { + return m_data.size() + 1; // footer + } + void onFooterClicked() { + SelectNone(); + listData_t obj = {}; + obj.m_key = "New item"; + size_t index = m_data.size(); + m_data.push_back( std::move(obj) ); + OnItemsInserted(index, 1, true); + } + void OnSubItemClicked(t_size item, t_size subItem, CPoint pt) override { + if ( item == footerRow() ) { + onFooterClicked(); return; + } + if ( subItem == 2 ) { + TableEdit_Start(item, subItem); return; + } + __super::OnSubItemClicked( item, subItem, pt ); + } + bool AllowScrollbar(bool vertical) const override { + return true; + } + t_size InsertIndexFromPointEx(const CPoint & pt, bool & bInside) const override { + // Drag&drop insertion point hook, for reordering only + auto ret = __super::InsertIndexFromPointEx(pt, bInside); + bInside = false; // never drop *into* an item, only between, as we only allow reorder + if ( ret > m_data.size() ) ret = m_data.size(); // never allow drop beyond footer + return ret; + } + void RequestReorder(size_t const * order, size_t count) override { + // we've been asked to reorder the items, by either drag&drop or cursors+modifiers + // we can either reorder as requested, reorder partially if some of the items aren't moveable, or reject the request + + PFC_ASSERT( count == GetItemCount() ); + + // Footer row cannot be moved + if ( order[footerRow()] != footerRow() ) return; + + pfc::reorder_t( m_data, order, count ); + this->OnItemsReordered( order, count ); + } + void RemoveMask( pfc::bit_array const & mask ) { + if ( mask.get(footerRow() ) ) return; // footer row cannot be removed + auto oldCount = GetItemCount(); + pfc::remove_mask_t( m_data, mask ); + this->OnItemsRemoved( mask, oldCount ); + } + void RequestRemoveSelection() override { + // Delete key etc + RemoveMask(GetSelectionMask()); + } + void ExecuteDefaultAction(t_size index) override { + // double click, enter key, etc + if ( index == footerRow() ) onFooterClicked(); + } + + bool GetSubItemText(t_size item, t_size subItem, pfc::string_base & out) const override { + if ( item == footerRow() ) { + if ( subItem == 0 ) { + out = "+ add new"; + return true; + } + return false; + } + auto & rec = m_data[item]; + switch(subItem) { + case 0: + // pass blank string or return false to create a checkbox only column + out = "check"; + return true; + case 1: + out = rec.m_key.c_str(); + return true; + case 2: + out = rec.m_value.c_str(); + return true; + default: + return false; + } + } + + size_t GetSubItemSpan(size_t row, size_t column) const override { + if ( row == footerRow() && column == 0 ) { + return GetColumnCount(); + } + return 1; + } + cellType_t GetCellType(size_t item, size_t subItem) const override { + // cellType_t is a pointer to a cell class object supplying cell behavior specification & rendering methods + // use PFC_SINGLETON to provide static instances of used cells + if ( item == footerRow() ) { + if ( subItem == 0 ) { + return & PFC_SINGLETON( CListCell_Button ); + } else { + return nullptr; + } + } + switch(subItem) { + case 0: + return & PFC_SINGLETON( CListCell_Checkbox ); + default: + return & PFC_SINGLETON( CListCell_Text ); + } + + } + bool GetCellTypeSupported() const override { + return true; + } + bool GetCellCheckState(size_t item, size_t subItem) const override { + if ( subItem == 0 ) { + auto & rec = m_data[item]; + return rec.m_checkState; + } + return false; + } + void SetCellCheckState(size_t item, size_t subItem, bool value) override { + if ( subItem == 0 ) { + auto & rec = m_data[item]; + if (rec.m_checkState != value) { + rec.m_checkState = value; + __super::SetCellCheckState(item, subItem, value); + } + } + } + + uint32_t QueryDragDropTypes() const override {return dragDrop_reorder;} + + // Inplace edit handlers + // Overrides of CTableEditHelperV2 methods + void TableEdit_SetField(t_size item, t_size subItem, const char * value) override { + if ( subItem == 2 ) { + m_data[item].m_value = value; + ReloadItem( item ); + } + } + bool TableEdit_IsColumnEditable(t_size subItem) const override { + return subItem == 2; + } + private: + std::vector< listData_t > m_data = makeListData(); + }; + + // Straightforward WTL dialog code + class CListControlAdvancedDemoDialog : public CDialogImpl { + public: + enum { IDD = IDD_LISTCONTROL_DEMO }; + + BEGIN_MSG_MAP_EX(CListControlAdvancedDemoDialog) + MSG_WM_INITDIALOG(OnInitDialog) + COMMAND_HANDLER_EX(IDCANCEL, BN_CLICKED, OnCancel) + END_MSG_MAP() + private: + void OnCancel(UINT, int, CWindow) { + DestroyWindow(); + } + + BOOL OnInitDialog(CWindow, LPARAM) { + + // Create replacing existing windows list control + // automatically initialize position, font, etc + m_list.CreateInDialog( *this, IDC_LIST1 ); + + // Do this AFTER creating CListControl, so dark mode hook talks to new CListControl rather than shortlived IDC_LIST1 placeholder + m_dark.AddDialogWithControls(*this); + + ShowWindow(SW_SHOW); + + return TRUE; // system should set focus + } + + CListControlDemo m_list; + + fb2k::CDarkModeHooks m_dark; + }; +} + +// Called from mainmenu.cpp +void RunListControlAdvancedDemo() { + // automatically creates the dialog with object lifetime management and modeless dialog registration + fb2k::newDialog(); +} + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/foo_sample/listcontrol-ownerdata.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/foo_sample/listcontrol-ownerdata.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,211 @@ +#include "stdafx.h" + +// Owner-data CListControl use demo +// CListControlOwnerData with callbacks + +#include "stdafx.h" +#include "resource.h" +#include +#include +#include +#include +#include + +#include + +namespace { + struct listData_t { + std::string m_key, m_value; + }; + static std::vector makeListData() { + std::vector data; + data.resize( 10 ); + for( size_t walk = 0; walk < data.size(); ++ walk ) { + auto & rec = data[walk]; + rec.m_key = (PFC_string_formatter() << "Item #" << (walk+1) ).c_str(); + rec.m_value = "edit me"; + } + return data; + } + + + class CListControlOwnerDataDemoDialog : public CDialogImpl, private IListControlOwnerDataSource { + public: + + // CListControlOwnerData constructor requires ptr to IListControlOwnerDataSource object + CListControlOwnerDataDemoDialog() : m_list(this) {} + + enum { IDD = IDD_LISTCONTROL_DEMO }; + + BEGIN_MSG_MAP_EX(CListControlOwnerDataDemoDialog) + MSG_WM_INITDIALOG(OnInitDialog) + COMMAND_HANDLER_EX(IDCANCEL, BN_CLICKED, OnCancel) + MSG_WM_CONTEXTMENU(OnContextMenu) + END_MSG_MAP() + private: + void OnCancel(UINT, int, CWindow) { + DestroyWindow(); + } + + BOOL OnInitDialog(CWindow, LPARAM) { + + // Create replacing existing windows list control + // automatically initialize position, font, etc + m_list.CreateInDialog( *this, IDC_LIST1 ); + + // Do this AFTER creating CListControl, so dark mode hook talks to new CListControl rather than shortlived IDC_LIST1 placeholder + m_dark.AddDialogWithControls(*this); + + // never hardcode values in pixels, always use screen DPI + auto DPI = m_list.GetDPI(); + m_list.AddColumn( "Name", MulDiv(100, DPI.cx, 96 ) ); + m_list.AddColumn( "Value", MulDiv(150, DPI.cx, 96 ) ); + + ShowWindow(SW_SHOW); + + return TRUE; // system should set focus + } + + // Context menu handler + void OnContextMenu(CWindow wnd, CPoint point) { + // did we get a (-1,-1) point due to context menu key rather than right click? + // GetContextMenuPoint fixes that, returning a proper point at which the menu should be shown + point = m_list.GetContextMenuPoint(point); + + CMenu menu; + // WIN32_OP_D() : debug build only return value check + // Used to check for obscure errors in debug builds, does nothing (ignores errors) in release build + WIN32_OP_D(menu.CreatePopupMenu()); + + enum { ID_TEST1 = 1, ID_TEST2, ID_SELECTALL, ID_SELECTNONE, ID_INVERTSEL }; + menu.AppendMenu(MF_STRING, ID_TEST1, L"Test 1"); + menu.AppendMenu(MF_STRING, ID_TEST2, L"Test 2"); + menu.AppendMenu(MF_SEPARATOR); + // Note: Ctrl+A handled automatically by CListControl, no need for us to catch it + menu.AppendMenu(MF_STRING, ID_SELECTALL, L"Select all\tCtrl+A"); + menu.AppendMenu(MF_STRING, ID_SELECTNONE, L"Select none"); + menu.AppendMenu(MF_STRING, ID_INVERTSEL, L"Invert selection"); + + int cmd; + { + // Callback object to show menu command descriptions in the status bar. + // it's actually a hidden window, needs a parent HWND, where we feed our control's HWND + CMenuDescriptionMap descriptions(m_hWnd); + + // Set descriptions of all our items + descriptions.Set(ID_TEST1, "This is a test item #1"); + descriptions.Set(ID_TEST2, "This is a test item #2"); + + descriptions.Set(ID_SELECTALL, "Selects all items"); + descriptions.Set(ID_SELECTNONE, "Deselects all items"); + descriptions.Set(ID_INVERTSEL, "Invert selection"); + + cmd = menu.TrackPopupMenuEx(TPM_RIGHTBUTTON | TPM_NONOTIFY | TPM_RETURNCMD, point.x, point.y, descriptions, nullptr); + } + switch(cmd) { + case ID_TEST1: + { + pfc::string_formatter msg; + msg << "Test command #1 triggered.\r\n"; + msg << m_list.GetSelectedCount() << " items selected."; + // popup_message : non-blocking MessageBox equivalent + popup_message::g_show(msg, "Information"); + } + break; + case ID_TEST2: + { + pfc::string_formatter msg; + msg << "Test command #1 triggered.\r\n"; + msg << "Selected items:\r\n"; + for( size_t walk = 0; walk < m_list.GetItemCount(); ++ walk) { + if ( m_list.IsItemSelected( walk ) ) { + msg << m_data[walk].m_key.c_str() << "\r\n"; + } + } + msg << "End selected items."; + // popup_message : non-blocking MessageBox equivalent + popup_message::g_show(msg, "Information"); + } + break; + case ID_SELECTALL: + m_list.SelectAll(); // trivial + break; + case ID_SELECTNONE: + m_list.SelectNone(); // trivial + break; + case ID_INVERTSEL: + { + auto mask = m_list.GetSelectionMask(); + m_list.SetSelection( + // Items which we alter - all of them + pfc::bit_array_true(), + // Selection values - NOT'd original selection mask + pfc::bit_array_not(mask) + ); + // Exclusion of footer item from selection handled via CanSelectItem() + } + break; + } + } + + private: + // IListControlOwnerDataSource methods + + size_t listGetItemCount( ctx_t ctx ) override { + PFC_ASSERT( ctx == &m_list ); // ctx is a pointer to the object calling us + return m_data.size(); + } + pfc::string8 listGetSubItemText( ctx_t, size_t item, size_t subItem ) override { + auto & rec = m_data[item]; + switch(subItem) { + case 0: + return rec.m_key.c_str(); + case 1: + return rec.m_value.c_str(); + default: + return ""; + } + + } + bool listCanReorderItems( ctx_t ) override { + return true; + } + bool listReorderItems( ctx_t, const size_t* order, size_t count) override { + PFC_ASSERT( count == m_data.size() ); + pfc::reorder_t( m_data, order, count ); + return true; + } + bool listRemoveItems( ctx_t, pfc::bit_array const & mask) override { + pfc::remove_mask_t( m_data, mask ); + return true; + } + void listItemAction(ctx_t, size_t item) override { + m_list.TableEdit_Start( item, 1 ); + } + void listSubItemClicked( ctx_t, size_t item, size_t subItem) override { + if ( subItem == 1 ) { + m_list.TableEdit_Start( item, subItem ); + } + } + void listSetEditField(ctx_t ctx, size_t item, size_t subItem, const char * val) override { + if ( subItem == 1 ) { + m_data[item].m_value = val; + } + } + bool listIsColumnEditable( ctx_t, size_t subItem ) override { + return subItem == 1; + } + + + std::vector< listData_t > m_data = makeListData(); + + CListControlOwnerData m_list; + + fb2k::CDarkModeHooks m_dark; + }; +} +// Called from mainmenu.cpp +void RunListControlOwnerDataDemo() { + // automatically creates the dialog with object lifetime management and modeless dialog registration + fb2k::newDialog(); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/foo_sample/listcontrol-simple.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/foo_sample/listcontrol-simple.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,170 @@ +#include "stdafx.h" + +// Simple CListControl use demo +// CListControlSimple + +#include "stdafx.h" +#include "resource.h" +#include +#include +#include +#include +#include + +#include + +namespace { + struct listData_t { + std::string m_key, m_value; + }; + static std::vector makeListData() { + std::vector data; + data.resize( 10 ); + for( size_t walk = 0; walk < data.size(); ++ walk ) { + auto & rec = data[walk]; + rec.m_key = (PFC_string_formatter() << "Item #" << (walk+1) ).c_str(); + rec.m_value = "sample value"; + } + return data; + } + + + class CListControlSimpleDemoDialog : public CDialogImpl { + public: + + enum { IDD = IDD_LISTCONTROL_DEMO }; + + BEGIN_MSG_MAP_EX(CListControlOwnerDataDemoDialog) + MSG_WM_INITDIALOG(OnInitDialog) + COMMAND_HANDLER_EX(IDCANCEL, BN_CLICKED, OnCancel) + MSG_WM_CONTEXTMENU(OnContextMenu) + END_MSG_MAP() + private: + void OnCancel(UINT, int, CWindow) { + DestroyWindow(); + } + + BOOL OnInitDialog(CWindow, LPARAM) { + + // Create replacing existing windows list control + // automatically initialize position, font, etc + m_list.CreateInDialog( *this, IDC_LIST1 ); + + // Do this AFTER creating CListControl, so dark mode hook talks to new CListControl rather than shortlived IDC_LIST1 placeholder + m_dark.AddDialogWithControls(*this); + + // never hardcode values in pixels, always use screen DPI + auto DPI = m_list.GetDPI(); + m_list.AddColumn( "Name", MulDiv(100, DPI.cx, 96 ) ); + m_list.AddColumn( "Value", MulDiv(150, DPI.cx, 96 ) ); + + { + auto data = makeListData(); + + m_list.SetItemCount( data.size( ) ); + for( size_t walk = 0; walk < data.size(); ++ walk ) { + auto & rec = data[walk]; + m_list.SetItemText( walk, 0, rec.m_key.c_str() ); + m_list.SetItemText( walk, 1, rec.m_value.c_str() ); + } + } + + ShowWindow(SW_SHOW); + + return TRUE; // system should set focus + } + + // Context menu handler + void OnContextMenu(CWindow wnd, CPoint point) { + // did we get a (-1,-1) point due to context menu key rather than right click? + // GetContextMenuPoint fixes that, returning a proper point at which the menu should be shown + point = m_list.GetContextMenuPoint(point); + + CMenu menu; + // WIN32_OP_D() : debug build only return value check + // Used to check for obscure errors in debug builds, does nothing (ignores errors) in release build + WIN32_OP_D(menu.CreatePopupMenu()); + + enum { ID_TEST1 = 1, ID_TEST2, ID_SELECTALL, ID_SELECTNONE, ID_INVERTSEL }; + menu.AppendMenu(MF_STRING, ID_TEST1, L"Test 1"); + menu.AppendMenu(MF_STRING, ID_TEST2, L"Test 2"); + menu.AppendMenu(MF_SEPARATOR); + // Note: Ctrl+A handled automatically by CListControl, no need for us to catch it + menu.AppendMenu(MF_STRING, ID_SELECTALL, L"Select all\tCtrl+A"); + menu.AppendMenu(MF_STRING, ID_SELECTNONE, L"Select none"); + menu.AppendMenu(MF_STRING, ID_INVERTSEL, L"Invert selection"); + + int cmd; + { + // Callback object to show menu command descriptions in the status bar. + // it's actually a hidden window, needs a parent HWND, where we feed our control's HWND + CMenuDescriptionMap descriptions(m_hWnd); + + // Set descriptions of all our items + descriptions.Set(ID_TEST1, "This is a test item #1"); + descriptions.Set(ID_TEST2, "This is a test item #2"); + + descriptions.Set(ID_SELECTALL, "Selects all items"); + descriptions.Set(ID_SELECTNONE, "Deselects all items"); + descriptions.Set(ID_INVERTSEL, "Invert selection"); + + cmd = menu.TrackPopupMenuEx(TPM_RIGHTBUTTON | TPM_NONOTIFY | TPM_RETURNCMD, point.x, point.y, descriptions, nullptr); + } + switch(cmd) { + case ID_TEST1: + { + pfc::string_formatter msg; + msg << "Test command #1 triggered.\r\n"; + msg << m_list.GetSelectedCount() << " items selected."; + // popup_message : non-blocking MessageBox equivalent + popup_message::g_show(msg, "Information"); + } + break; + case ID_TEST2: + { + pfc::string_formatter msg; + msg << "Test command #1 triggered.\r\n"; + msg << "Selected items:\r\n"; + for( size_t walk = 0; walk < m_list.GetItemCount(); ++ walk) { + if ( m_list.IsItemSelected( walk ) ) { + msg << "#" << (walk+1) << "\r\n"; + } + } + msg << "End selected items."; + // popup_message : non-blocking MessageBox equivalent + popup_message::g_show(msg, "Information"); + } + break; + case ID_SELECTALL: + m_list.SelectAll(); // trivial + break; + case ID_SELECTNONE: + m_list.SelectNone(); // trivial + break; + case ID_INVERTSEL: + { + auto mask = m_list.GetSelectionMask(); + m_list.SetSelection( + // Items which we alter - all of them + pfc::bit_array_true(), + // Selection values - NOT'd original selection mask + pfc::bit_array_not(mask) + ); + // Exclusion of footer item from selection handled via CanSelectItem() + } + break; + } + } + + private: + + CListControlSimple m_list; + + fb2k::CDarkModeHooks m_dark; + }; +} + +// Called from mainmenu.cpp +void RunListControlSimpleDemo() { + fb2k::newDialog(); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/foo_sample/main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/foo_sample/main.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,14 @@ +#include "stdafx.h" + +// Declaration of your component's version information +// Since foobar2000 v1.0 having at least one of these in your DLL is mandatory to let the troubleshooter tell different versions of your component apart. +// Note that it is possible to declare multiple components within one DLL, but it's strongly recommended to keep only one declaration per DLL. +// As for 1.1, the version numbers are used by the component update finder to find updates; for that to work, you must have ONLY ONE declaration per DLL. If there are multiple declarations, the component is assumed to be outdated and a version number of "0" is assumed, to overwrite the component with whatever is currently on the site assuming that it comes with proper version numbers. +DECLARE_COMPONENT_VERSION("Sample Component","1.0","about message goes here"); + + +// This will prevent users from renaming your component around (important for proper troubleshooter behaviors) or loading multiple instances of it. +VALIDATE_COMPONENT_FILENAME("foo_sample.dll"); + +// Activate cfg_var downgrade functionality if enabled. Relevant only when cycling from newer FOOBAR2000_TARGET_VERSION to older. +FOOBAR2000_IMPLEMENT_CFG_VAR_DOWNGRADE; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/foo_sample/mainmenu-dynamic.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/foo_sample/mainmenu-dynamic.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,121 @@ +#include "stdafx.h" +#include + +namespace { // anon namespace everything, it's not accessible by means other than the service factory + +// The command ID. +// Generate a new GUID when reusing code. +static const GUID guid_menucommand = { 0xab754b0b, 0x204, 0x4471, { 0xb5, 0x29, 0xff, 0x73, 0xae, 0x51, 0x5d, 0xe9 } }; + +// Shared with mainmenu.cpp +static const GUID guid_mainmenu_group_id = { 0x44963e7a, 0x4b2a, 0x4588, { 0xb0, 0x17, 0xa8, 0x69, 0x18, 0xcb, 0x8a, 0xa5 } }; + +class sample_command : public mainmenu_node_command { +public: + sample_command( size_t index ) : m_index(index) { + } + void get_display(pfc::string_base & text, t_uint32 & flags) override { + flags = 0; + text = PFC_string_formatter() << "Test dynamic item #" << m_index; + } + void execute(service_ptr_t callback) override { + popup_message::g_show(PFC_string_formatter() << "Invoked test menu item #" << m_index, "Information"); + } + GUID get_guid() override { + // This method returns our subcommand ID. + // Dynamic commands are identified by a pair of GUIDs: + // - command ID ( see: mainmenu_commands interface ) + // - subcommand ID ( identifier of one of the dynamic items ) + // Subcommand identifiers don't have to be actually globally unique, + // as long as they're unique among the subcommand identifiers for this command ID. + + // In our case, we'll just create a makeshift GUID from a hash of the index. + // This is perfectly okay for production code - as long as your command ID is a proper GUID! + + // Don't ever hash size_t which varies with CPU architecture + // Integer endianness intentionally disregarded + uint32_t hashme = (uint32_t) m_index; + + auto api = hasher_md5::get(); + hasher_md5_state state; + api->initialize( state ); + api->process( state, &hashme, sizeof(hashme) ); + + // fb2k hasher_md5 API even provides a convenient method to return MD5 hashes cast to GUIDs for this. + return api->get_result_guid( state ); + } + bool get_description(pfc::string_base & out) override { + out = PFC_string_formatter() << "This is a test menu item #" << m_index << "."; + return true; + } +private: + const size_t m_index; +}; +class sample_group : public mainmenu_node_group { +public: + sample_group() { + m_children.resize(11); + for( size_t walk = 0; walk < m_children.size(); ++ walk ) { + mainmenu_node::ptr node; + // Insert separators for odd items, commands for even + if ( walk % 2 ) { + node = fb2k::service_new(); + } else { + auto cmdIndex = walk/2 + 1; + node = fb2k::service_new( cmdIndex ); + } + m_children[walk] = std::move(node); + } + } + void get_display(pfc::string_base & text, t_uint32 & flags) override { + flags = 0; + text = "Dynamic menu test group"; + } + t_size get_children_count() override { + return m_children.size(); + } + mainmenu_node::ptr get_child(t_size index) override { + PFC_ASSERT( index < m_children.size() ); + return m_children[index]; + } +private: + std::vector m_children; + +}; + +class mainmenu_sample_dynamic : public mainmenu_commands_v2 { + typedef mainmenu_commands_v2 super_t; +public: + // mainmenu_commands_v2 methods + t_uint32 get_command_count() override { return 1; } + GUID get_command(t_uint32 p_index) override {return guid_menucommand;} + void get_name(t_uint32 p_index,pfc::string_base & p_out) override {p_out = "Dynamic menu test";} + + bool get_description(t_uint32 p_index,pfc::string_base & p_out) override { + // Should not get here much + p_out = "This is a dynamic menu command test."; + return true; + } + GUID get_parent() override {return guid_mainmenu_group_id; } + void execute(t_uint32 p_index,service_ptr_t p_callback) override { + // Should not get here, someone not aware of our dynamic status tried to invoke us? + } + + bool is_command_dynamic(t_uint32 index) override { return true; } + mainmenu_node::ptr dynamic_instantiate(t_uint32 index) override { + return fb2k::service_new(); + } + + bool dynamic_execute(t_uint32 index, const GUID & subID, service_ptr_t callback) override { + // If your component provides a more efficient way to execute the command, + // than doing full dynamic_instantiate() and walking all the dynamic items to find one with the matching identifier, + // please implement it here. + + // ... or just skip implementing this method entirely. + return super_t::dynamic_execute( index, subID, callback ); + } +}; + +static service_factory_single_t g_mainmenu_sample_dynamic; + +} // namespace diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/foo_sample/mainmenu.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/foo_sample/mainmenu.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,120 @@ +#include "stdafx.h" + +#include "playback_stream_capture.h" + +// I am foo_sample and these are *my* GUIDs +// Make your own when reusing code or else +static const GUID guid_mainmenu_group_id = { 0x44963e7a, 0x4b2a, 0x4588, { 0xb0, 0x17, 0xa8, 0x69, 0x18, 0xcb, 0x8a, 0xa5 } }; +static const GUID guid_test = { 0x7c4726df, 0x3b2d, 0x4c7c,{ 0xad, 0xe8, 0x43, 0xd8, 0x46, 0xbe, 0xce, 0xa8 } }; +static const GUID guid_playbackstate = { 0xbd880c51, 0xf0cc, 0x473f,{ 0x9d, 0x14, 0xa6, 0x6e, 0x8c, 0xed, 0x25, 0xae } }; +static const GUID guid_io = { 0xd380c333, 0xa72c, 0x4e1e,{ 0x97, 0xca, 0xed, 0x14, 0xeb, 0x93, 0x76, 0x23 } }; +static const GUID guid_listcontrol_advanced = { 0x27e29db0, 0x3079, 0x4ce0, { 0x8b, 0x4a, 0xa0, 0x78, 0xeb, 0x6, 0x56, 0x86 } }; +static const GUID guid_listcontrol_simple = { 0x34664996, 0x54cd, 0x48eb, { 0xa8, 0x20, 0x8f, 0x45, 0x7d, 0xcc, 0xff, 0xbb } }; +static const GUID guid_listcontrol_ownerdata = { 0xc6d23696, 0x4be5, 0x4daa, { 0xaf, 0xb2, 0x35, 0x14, 0xa, 0x47, 0xd2, 0xf9 } }; +static const GUID guid_playback_stream_capture = { 0x3d0f0f1a, 0x6b5f, 0x42e3, { 0xa4, 0x6d, 0x49, 0x1, 0x3, 0xf0, 0x54, 0xb2 } }; + + +static mainmenu_group_popup_factory g_mainmenu_group(guid_mainmenu_group_id, mainmenu_groups::file, mainmenu_commands::sort_priority_dontcare, "Sample component"); + +void RunPlaybackStateDemo(); //playback_state.cpp +void RunIOTest(); // IO.cpp +void RunListControlSimpleDemo(); // listcontrol-simple.cpp +void RunListControlOwnerDataDemo(); // listcontrol-ownerdata.cpp +void RunListControlAdvancedDemo(); // listcontrol-advanced.cpp + +class mainmenu_commands_sample : public mainmenu_commands { +public: + enum { + cmd_test = 0, + cmd_playbackstate, + cmd_io, + cmd_listcontrol_simple, + cmd_listcontrol_ownerdata, + cmd_listcontrol_advanced, + cmd_playback_stream_capture, + cmd_total + }; + t_uint32 get_command_count() override { + return cmd_total; + } + GUID get_command(t_uint32 p_index) override { + + switch(p_index) { + case cmd_test: return guid_test; + case cmd_playbackstate: return guid_playbackstate; + case cmd_io: return guid_io; + case cmd_listcontrol_simple: return guid_listcontrol_simple; + case cmd_listcontrol_ownerdata: return guid_listcontrol_ownerdata; + case cmd_listcontrol_advanced: return guid_listcontrol_advanced; + case cmd_playback_stream_capture: return guid_playback_stream_capture; + default: uBugCheck(); // should never happen unless somebody called us with invalid parameters - bail + } + } + void get_name(t_uint32 p_index,pfc::string_base & p_out) override { + switch(p_index) { + case cmd_test: p_out = "Test command"; break; + case cmd_playbackstate: p_out = "Playback state demo"; break; + case cmd_io: p_out = "I/O test"; break; + case cmd_listcontrol_simple: p_out = "Simple CListControl demo"; break; + case cmd_listcontrol_ownerdata: p_out = "Owner-data CListControl demo"; break; + case cmd_listcontrol_advanced: p_out = "Advanced CListControl demo"; break; + case cmd_playback_stream_capture: p_out = "Playback stream capture demo"; break; + default: uBugCheck(); // should never happen unless somebody called us with invalid parameters - bail + } + } + bool get_description(t_uint32 p_index,pfc::string_base & p_out) override { + switch(p_index) { + case cmd_test: p_out = "This is a sample menu command."; return true; + case cmd_playbackstate: p_out = "Opens the playback state demo dialog."; return true; + case cmd_io: p_out = "Runs I/O test."; return true; + case cmd_listcontrol_simple: p_out = "Runs Simple CListControl demo."; return true; + case cmd_listcontrol_ownerdata: p_out = "Runs Owner Data CListControl demo."; return true; + case cmd_listcontrol_advanced: p_out = "Runs Advanced CListControl demo."; return true; + case cmd_playback_stream_capture: p_out = "Toggles playback stream capture operation."; return true; + default: return false; + } + } + GUID get_parent() override { + return guid_mainmenu_group_id; + } + void execute(t_uint32 p_index,service_ptr_t p_callback) override { + switch(p_index) { + case cmd_test: + popup_message::g_show("This is a sample menu command.", "Blah"); + break; + case cmd_playbackstate: + RunPlaybackStateDemo(); + break; + case cmd_io: + RunIOTest(); + break; + case cmd_listcontrol_simple: + RunListControlSimpleDemo(); + break; + case cmd_listcontrol_ownerdata: + RunListControlOwnerDataDemo(); + break; + case cmd_listcontrol_advanced: + RunListControlAdvancedDemo(); + break; + case cmd_playback_stream_capture: + ToggleCapture(); + break; + default: + uBugCheck(); // should never happen unless somebody called us with invalid parameters - bail + } + } + bool get_display(t_uint32 p_index,pfc::string_base & p_text,t_uint32 & p_flags) override { + // OPTIONAL method + bool rv = mainmenu_commands::get_display(p_index, p_text, p_flags); + if (rv) switch(p_index) { + case cmd_playback_stream_capture: + // Add checkmark if capture is in progress + if ( IsCaptureRunning() ) p_flags |= flag_checked; + break; + } + return rv; + } +}; + +static mainmenu_commands_factory_t g_mainmenu_commands_sample_factory; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/foo_sample/playback_state.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/foo_sample/playback_state.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,155 @@ +#include "stdafx.h" +#include "resource.h" +#include +#include + +class CPlaybackStateDemo : public CDialogImpl, private play_callback_impl_base { +public: + enum {IDD = IDD_PLAYBACK_STATE}; + + BEGIN_MSG_MAP_EX(CPlaybackStateDemo) + MSG_WM_INITDIALOG(OnInitDialog) + COMMAND_HANDLER_EX(IDC_PATTERN, EN_CHANGE, OnPatternChange) + COMMAND_HANDLER_EX(IDCANCEL, BN_CLICKED, OnCancel) + COMMAND_HANDLER_EX(IDC_PLAY, BN_CLICKED, OnPlayClicked) + COMMAND_HANDLER_EX(IDC_PAUSE, BN_CLICKED, OnPauseClicked) + COMMAND_HANDLER_EX(IDC_STOP, BN_CLICKED, OnStopClicked) + COMMAND_HANDLER_EX(IDC_PREV, BN_CLICKED, OnPrevClicked) + COMMAND_HANDLER_EX(IDC_NEXT, BN_CLICKED, OnNextClicked) + COMMAND_HANDLER_EX(IDC_RAND, BN_CLICKED, OnRandClicked) + MSG_WM_CONTEXTMENU(OnContextMenu) + END_MSG_MAP() +private: + + // Playback callback methods. + void on_playback_starting(play_control::t_track_command p_command,bool p_paused) {update();} + void on_playback_new_track(metadb_handle_ptr p_track) {update();} + void on_playback_stop(play_control::t_stop_reason p_reason) {update();} + void on_playback_seek(double p_time) {update();} + void on_playback_pause(bool p_state) {update();} + void on_playback_edited(metadb_handle_ptr p_track) {update();} + void on_playback_dynamic_info(const file_info & p_info) {update();} + void on_playback_dynamic_info_track(const file_info & p_info) {update();} + void on_playback_time(double p_time) {update();} + void on_volume_change(float p_new_val) {} + + void update(); + + void OnPatternChange(UINT, int, CWindow); + void OnCancel(UINT, int, CWindow); + + void OnPlayClicked(UINT, int, CWindow) {m_playback_control->start();} + void OnStopClicked(UINT, int, CWindow) {m_playback_control->stop();} + void OnPauseClicked(UINT, int, CWindow) {m_playback_control->toggle_pause();} + void OnPrevClicked(UINT, int, CWindow) {m_playback_control->start(playback_control::track_command_prev);} + void OnNextClicked(UINT, int, CWindow) {m_playback_control->start(playback_control::track_command_next);} + void OnRandClicked(UINT, int, CWindow) {m_playback_control->start(playback_control::track_command_rand);} + + void OnContextMenu(CWindow wnd, CPoint point); + + BOOL OnInitDialog(CWindow, LPARAM); + + titleformat_object::ptr m_script; + + static_api_ptr_t m_playback_control; +}; + +void CPlaybackStateDemo::OnCancel(UINT, int, CWindow) { + DestroyWindow(); +} + +void CPlaybackStateDemo::OnPatternChange(UINT, int, CWindow) { + m_script.release(); // pattern has changed, force script recompilation + update(); +} + +BOOL CPlaybackStateDemo::OnInitDialog(CWindow, LPARAM) { + update(); + SetDlgItemText(IDC_PATTERN, _T("%codec% | %bitrate% kbps | %samplerate% Hz | %channels% | %playback_time%[ / %length%]$if(%ispaused%, | paused,)")); + ::ShowWindowCentered(*this,GetParent()); // Function declared in SDK helpers. + return TRUE; +} + +void CPlaybackStateDemo::update() { + if (m_script.is_empty()) { + pfc::string8 pattern; + uGetDlgItemText(*this, IDC_PATTERN, pattern); + static_api_ptr_t()->compile_safe_ex(m_script, pattern); + } + pfc::string_formatter state; + if (m_playback_control->playback_format_title(NULL, state, m_script, NULL, playback_control::display_level_all)) { + //Succeeded already. + } else if (m_playback_control->is_playing()) { + //Starting playback but not done opening the first track yet. + state = "Opening..."; + } else { + state = "Stopped."; + } + uSetDlgItemText(*this, IDC_STATE, state); +} + +void CPlaybackStateDemo::OnContextMenu(CWindow wnd, CPoint point) { + try { + if (wnd == GetDlgItem(IDC_CONTEXTMENU)) { + + // handle the context menu key case - center the menu + if (point == CPoint(-1, -1)) { + CRect rc; + WIN32_OP(wnd.GetWindowRect(&rc)); + point = rc.CenterPoint(); + } + + metadb_handle_list items; + + { // note: we would normally just use contextmenu_manager::init_context_now_playing(), but we go the "make the list ourselves" route to demonstrate how to invoke the menu for arbitrary items. + metadb_handle_ptr item; + if (m_playback_control->get_now_playing(item)) items += item; + } + + CMenuDescriptionHybrid menudesc(*this); //this class manages all the voodoo necessary for descriptions of our menu items to show in the status bar. + + static_api_ptr_t api; + CMenu menu; + WIN32_OP(menu.CreatePopupMenu()); + enum { + ID_TESTCMD = 1, + ID_CM_BASE, + }; + menu.AppendMenu(MF_STRING, ID_TESTCMD, _T("Test command")); + menudesc.Set(ID_TESTCMD, "This is a test command."); + menu.AppendMenu(MF_SEPARATOR); + + if (items.get_count() > 0) { + api->init_context(items, 0); + api->win32_build_menu(menu, ID_CM_BASE, ~0); + menudesc.SetCM(api.get_ptr(), ID_CM_BASE, ~0); + } else { + menu.AppendMenu(MF_STRING|MF_GRAYED|MF_DISABLED, (UINT_PTR)0, _T("No items selected")); + } + + int cmd = menu.TrackPopupMenu(TPM_RIGHTBUTTON|TPM_NONOTIFY|TPM_RETURNCMD,point.x,point.y,menudesc,0); + if (cmd > 0) { + if (cmd >= ID_CM_BASE) { + api->execute_by_id(cmd - ID_CM_BASE); + } else switch(cmd) { + case ID_TESTCMD: + popup_message::g_show("Blah!", "Test"); + break; + } + } + + } + } catch(std::exception const & e) { + console::complain("Context menu failure", e); //rare + } +} + +void RunPlaybackStateDemo() { + try { + // ImplementModelessTracking registers our dialog to receive dialog messages thru main app loop's IsDialogMessage(). + // CWindowAutoLifetime creates the window in the constructor (taking the parent window as a parameter) and deletes the object when the window has been destroyed (through WTL's OnFinalMessage). + new CWindowAutoLifetime >(core_api::get_main_window()); + } catch(std::exception const & e) { + popup_message::g_complain("Dialog creation failure", e); + } +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/foo_sample/playback_stream_capture.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/foo_sample/playback_stream_capture.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,149 @@ +#include "stdafx.h" +#include +#include + +namespace { + // private classes in anon namespace + + typedef CWavWriter wav_writer; + typedef wavWriterSetup_t wav_writer_setup; + + static pfc::string8 g_outputPath; + static wav_writer g_wav_writer; + + class playback_stream_capture_callback_impl : public playback_stream_capture_callback { + public: + void on_chunk(const audio_chunk & chunk) override { + PFC_ASSERT(core_api::is_main_thread()); + + try { + // writing files in main thread is not pretty, but good enough for our demo + + auto & abort = fb2k::noAbort; + + if (g_wav_writer.is_open() && g_wav_writer.get_spec() != chunk.get_spec()) { + g_wav_writer.finalize(abort); + } + if (!g_wav_writer.is_open() && ! core_api::is_shutting_down() ) { + wav_writer_setup setup; setup.initialize(chunk, 16, false, false); + + pfc::string_formatter fn; + fn << "capture-" << pfc::print_guid(pfc::createGUID()) << ".wav"; + pfc::string_formatter path = g_outputPath; + path.add_filename( fn ); // pretty method to add file path components with auto inserted delimiter + g_wav_writer.open(path, setup, abort); + } + g_wav_writer.write(chunk, abort); + } catch(std::exception const & e) { + FB2K_console_formatter() << "Playback stream capture error: " << e; + // FIX ME handle this in a pretty manner, likely inaccessible output folder or out of disk space + } + } + }; + static playback_stream_capture_callback_impl g_callback; + static bool g_active = false; + + static void FlushCapture() { + if (g_active) { + g_wav_writer.finalize(fb2k::noAbort); + } + } + static void StopCapture() { + if ( g_active ) { + g_active = false; + playback_stream_capture::get()->remove_callback(&g_callback); + g_wav_writer.finalize(fb2k::noAbort); + } + } + static void StartCapture() { + PFC_ASSERT( g_outputPath.length() > 0 ); + if (!g_active && !core_api::is_shutting_down()) { + g_active = true; + playback_stream_capture::get()->add_callback(&g_callback); + } + } + + // Forcibly stop capture when fb2k is shutting down + class initquit_psc : public initquit { + public: + void on_quit() override { + PFC_ASSERT( core_api::is_shutting_down() ); + StopCapture(); + } + }; + + // Handle playback stop events to split output WAV files + class play_callback_psc : public play_callback_static { + public: + unsigned get_flags() override { + return flag_on_playback_stop; + } + void on_playback_stop(play_control::t_stop_reason p_reason) override { + // Terminate the current stream + FlushCapture(); + } + void on_playback_starting(play_control::t_track_command p_command,bool p_paused) override {} + void on_playback_new_track(metadb_handle_ptr p_track) override {} + void on_playback_seek(double p_time) override {} + void on_playback_pause(bool p_state) override {} + void on_playback_edited(metadb_handle_ptr p_track) override {} + void on_playback_dynamic_info(const file_info & p_info) override {} + void on_playback_dynamic_info_track(const file_info & p_info) override {} + void on_playback_time(double p_time) override {} + void on_volume_change(float p_new_val) override {} + }; + + // pretty modern macro for service_factory_single_t<> + FB2K_SERVICE_FACTORY( initquit_psc ); + FB2K_SERVICE_FACTORY( play_callback_psc ); +} + +static void startCaptureDialogReply( fb2k::arrayRef location ) { + if ( g_active ) return; // already capturing + if ( location.is_empty() ) return; + if ( location->size() != 1 ) return; + auto obj = location->itemAt(0); + fsItemFolderPtr folder; + fb2k::stringRef strFolder; + if ( strFolder &= obj ) { + // OK + } else if ( folder &= obj ) { + strFolder = folder->canonicalPath(); + } + if ( strFolder.is_valid() ) { + g_outputPath = strFolder->c_str(); + StartCapture(); + } +} +void ToggleCapture() { +#ifdef _WIN32 + // Block modal dialog recursions. + // Folder picker below is a modal dialog, don't ever call it if there's another modal dialog in progress. + // Also prevents this function from recursing into itself if someone manages to hit the menu item while already picking folder. + // This will bump whatever modal dialog already exists, so the user has some idea why this was refused. + if ( !ModalDialogPrologue() ) return; + + if (g_active) { + StopCapture(); + } else { + const HWND wndParent = core_api::get_main_window(); + modal_dialog_scope scope(wndParent); // we can't have a handle to the modal dialog, but parent handle is good enough + if (uBrowseForFolder(wndParent, "Choose output folder", g_outputPath)) { + StartCapture(); + } + } +#else + if ( g_active ) { + StopCapture(); + } else { + auto dlg = fb2k::fileDialog::get()->setupOpenFolder(); + dlg->setTitle( "Choose output folder" ); + dlg->run( fb2k::fileDialogNotify::create( startCaptureDialogReply ) ); + } + +#endif +} + +bool IsCaptureRunning() { + return g_active; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/foo_sample/playback_stream_capture.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/foo_sample/playback_stream_capture.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,4 @@ +#pragma once + +void ToggleCapture(); +bool IsCaptureRunning(); \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/foo_sample/preferences.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/foo_sample/preferences.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,166 @@ +#include "stdafx.h" + +#include +#include + +#ifdef _WIN32 +#include "resource.h" +#include +#include +#endif // _WIN32 + +// Sample preferences interface: two meaningless configuration settings accessible through a preferences page and one accessible through advanced preferences. + +// Dark Mode: +// (1) Add fb2k::CDarkModeHooks member. +// (2) Initialize it in our WM_INITDIALOG handler. +// (3) Tell foobar2000 that this prefernces page supports dark mode, by returning correct get_state() flags. +// That's all. + + +// These GUIDs identify the variables within our component's configuration file. +static constexpr GUID guid_cfg_bogoSetting1 = { 0xbd5c777, 0x735c, 0x440d, { 0x8c, 0x71, 0x49, 0xb6, 0xac, 0xff, 0xce, 0xb8 } }; +static constexpr GUID guid_cfg_bogoSetting2 = { 0x752f1186, 0x9f61, 0x4f91, { 0xb3, 0xee, 0x2f, 0x25, 0xb1, 0x24, 0x83, 0x5d } }; + +// This GUID identifies our Advanced Preferences branch (replace with your own when reusing code). +static constexpr GUID guid_advconfig_branch = { 0x28564ced, 0x4abf, 0x4f0c, { 0xa4, 0x43, 0x98, 0xda, 0x88, 0xe2, 0xcd, 0x39 } }; +// This GUID identifies our Advanced Preferences setting (replace with your own when reusing code) as well as this setting's storage within our component's configuration file. +static constexpr GUID guid_cfg_bogoSetting3 = { 0xf7008963, 0xed60, 0x4084, { 0xa8, 0x5d, 0xd1, 0xcd, 0xc5, 0x51, 0x22, 0xca } }; +static constexpr GUID guid_cfg_bogoSetting4 = { 0x99e206f8, 0xd7be, 0x47e6, { 0xb5, 0xfe, 0xf4, 0x41, 0x5f, 0x6c, 0x16, 0xed } }; +static constexpr GUID guid_cfg_bogoSetting5 = { 0x7369ad25, 0x9e81, 0x4e2f, { 0x8b, 0xe7, 0x95, 0xcb, 0x81, 0x99, 0x9b, 0x1b } }; + +static constexpr GUID guid_cfg_bogoRadio = { 0x4c18b9ab, 0xf823, 0x4d05, { 0xb6, 0x18, 0x14, 0xb9, 0x4c, 0xad, 0xa2, 0xaa } }; +static constexpr GUID guid_cfg_bogoRadio1 = { 0xdd0a3a95, 0x1546, 0x4f25, { 0xa6, 0x8c, 0x23, 0xcf, 0x3d, 0xa5, 0x8f, 0x59 } }; +static constexpr GUID guid_cfg_bogoRadio2 = { 0xc35e1689, 0xb96f, 0x4bf4, { 0x95, 0xfb, 0xb7, 0x8e, 0x83, 0xc5, 0x2c, 0x7d } }; +static constexpr GUID guid_cfg_bogoRadio3 = { 0x790fe179, 0x9908, 0x47e2, { 0x9f, 0xde, 0xce, 0xe1, 0x3f, 0x9a, 0xfc, 0x5b } }; + +// defaults +constexpr int default_cfg_bogo1 = 1337, + default_cfg_bogo2 = 666, + default_cfg_bogo3 = 42; + +static constexpr char default_cfg_bogo4[] = "foobar"; +static constexpr bool default_cfg_bogo5 = false; + +// Advanced preferences order +enum { + order_bogo3, + order_bogo4, + order_bogo5, + order_bogoRadio +}; + +enum { + order_bogoRadio1, + order_bogoRadio2, + order_bogoRadio3, +}; + +namespace foo_sample { // accessed also from Mac specific code hence not static + cfg_uint cfg_bogoSetting1(guid_cfg_bogoSetting1, default_cfg_bogo1), cfg_bogoSetting2(guid_cfg_bogoSetting2, default_cfg_bogo2); +} +using namespace foo_sample; + +static advconfig_branch_factory g_advconfigBranch("Sample Component", guid_advconfig_branch, advconfig_branch::guid_branch_tools, 0); +static advconfig_integer_factory cfg_bogoSetting3("Bogo setting 3","foo_sample.bogo3", guid_cfg_bogoSetting3, guid_advconfig_branch, order_bogo3, default_cfg_bogo3, 0 /*minimum value*/, 9999 /*maximum value*/); +static advconfig_string_factory cfg_bogoSetting4("Bogo setting 4", "foo_sample.bogo4", guid_cfg_bogoSetting4, guid_advconfig_branch, order_bogo4, default_cfg_bogo4); +static advconfig_checkbox_factory cfg_bogoSetting5("Bogo setting 5", "foo_sample.bogo5", guid_cfg_bogoSetting5, guid_advconfig_branch, order_bogo5, default_cfg_bogo5); +static advconfig_branch_factory cfg_bogoRadioBranch("Bogo radio", guid_cfg_bogoRadio, guid_advconfig_branch, order_bogoRadio); +static advconfig_radio_factory cfg_bogoRadio1("Radio 1", "foo_sample.bogoRaidio.1", guid_cfg_bogoRadio1, guid_cfg_bogoRadio, order_bogoRadio1, true); +static advconfig_radio_factory cfg_bogoRadio2("Radio 2", "foo_sample.bogoRaidio.2", guid_cfg_bogoRadio2, guid_cfg_bogoRadio, order_bogoRadio2, false); +static advconfig_radio_factory cfg_bogoRadio3("Radio 3", "foo_sample.bogoRaidio.3", guid_cfg_bogoRadio3, guid_cfg_bogoRadio, order_bogoRadio3, false); + +#ifdef _WIN32 +class CMyPreferences : public CDialogImpl, public preferences_page_instance { +public: + //Constructor - invoked by preferences_page_impl helpers - don't do Create() in here, preferences_page_impl does this for us + CMyPreferences(preferences_page_callback::ptr callback) : m_callback(callback) {} + + //Note that we don't bother doing anything regarding destruction of our class. + //The host ensures that our dialog is destroyed first, then the last reference to our preferences_page_instance object is released, causing our object to be deleted. + + + //dialog resource ID + enum {IDD = IDD_MYPREFERENCES}; + // preferences_page_instance methods (not all of them - get_wnd() is supplied by preferences_page_impl helpers) + t_uint32 get_state(); + void apply(); + void reset(); + + //WTL message map + BEGIN_MSG_MAP_EX(CMyPreferences) + MSG_WM_INITDIALOG(OnInitDialog) + COMMAND_HANDLER_EX(IDC_BOGO1, EN_CHANGE, OnEditChange) + COMMAND_HANDLER_EX(IDC_BOGO2, EN_CHANGE, OnEditChange) + END_MSG_MAP() +private: + BOOL OnInitDialog(CWindow, LPARAM); + void OnEditChange(UINT, int, CWindow); + bool HasChanged(); + void OnChanged(); + + const preferences_page_callback::ptr m_callback; + + // Dark mode hooks object, must be a member of dialog class. + fb2k::CDarkModeHooks m_dark; +}; + +BOOL CMyPreferences::OnInitDialog(CWindow, LPARAM) { + + // Enable dark mode + // One call does it all, applies all relevant hacks automatically + m_dark.AddDialogWithControls(*this); + + SetDlgItemInt(IDC_BOGO1, (UINT) cfg_bogoSetting1, FALSE); + SetDlgItemInt(IDC_BOGO2, (UINT) cfg_bogoSetting2, FALSE); + return FALSE; +} + +void CMyPreferences::OnEditChange(UINT, int, CWindow) { + // not much to do here + OnChanged(); +} + +t_uint32 CMyPreferences::get_state() { + // IMPORTANT: Always return dark_mode_supported - tell foobar2000 that this preferences page is dark mode compliant. + t_uint32 state = preferences_state::resettable | preferences_state::dark_mode_supported; + if (HasChanged()) state |= preferences_state::changed; + return state; +} + +void CMyPreferences::reset() { + SetDlgItemInt(IDC_BOGO1, default_cfg_bogo1, FALSE); + SetDlgItemInt(IDC_BOGO2, default_cfg_bogo2, FALSE); + OnChanged(); +} + +void CMyPreferences::apply() { + cfg_bogoSetting1 = GetDlgItemInt(IDC_BOGO1, NULL, FALSE); + cfg_bogoSetting2 = GetDlgItemInt(IDC_BOGO2, NULL, FALSE); + + OnChanged(); //our dialog content has not changed but the flags have - our currently shown values now match the settings so the apply button can be disabled +} + +bool CMyPreferences::HasChanged() { + //returns whether our dialog content is different from the current configuration (whether the apply button should be enabled or not) + return GetDlgItemInt(IDC_BOGO1, NULL, FALSE) != cfg_bogoSetting1 || GetDlgItemInt(IDC_BOGO2, NULL, FALSE) != cfg_bogoSetting2; +} +void CMyPreferences::OnChanged() { + //tell the host that our state has changed to enable/disable the apply button appropriately. + m_callback->on_state_changed(); +} + +class preferences_page_myimpl : public preferences_page_impl { + // preferences_page_impl<> helper deals with instantiation of our dialog; inherits from preferences_page_v3. +public: + const char * get_name() {return "Sample Component";} + GUID get_guid() { + // This is our GUID. Replace with your own when reusing the code. + return GUID { 0x7702c93e, 0x24dc, 0x48ed, { 0x8d, 0xb1, 0x3f, 0x27, 0xb3, 0x8c, 0x7c, 0xc9 } }; + } + GUID get_parent_guid() {return guid_tools;} +}; + +static preferences_page_factory_t g_preferences_page_myimpl_factory; +#endif // _WIN32 + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/foo_sample/rating.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/foo_sample/rating.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,586 @@ +#include "stdafx.h" + + +/* +======================================================================== + Sample implementation of metadb_index_client and a rating database. +======================================================================== + +The rating data is all maintained by metadb backend, we only present and alter it when asked to. +Relevant classes: +metadb_index_client_impl - turns track info into a database key to which our data gets pinned. +init_stage_callback_impl - initializes ourselves at the proper moment of the app lifetime. +initquit_imp - clean up cached objects on app shutdown +metadb_display_field_provider_impl - publishes our %foo_sample_...% fields via title formatting. +contextmenu_rating - context menu command to cycle rating values. +mainmenu_rating - main menu command to show a dump of all present ratings. +track_property_provider_impl - serves info for the Properties dialog +*/ + +namespace { + + // I am foo_sample and these are *my* GUIDs. + // Replace with your own when reusing. + // Always recreate guid_foo_sample_rating_index if your metadb_index_client_impl hashing semantics changed or else you run into inconsistent/nonsensical data. + static const GUID guid_foo_sample_track_rating_index = { 0x88cf3f09, 0x26a8, 0x42ef,{ 0xb7, 0xb8, 0x42, 0x21, 0xb9, 0x62, 0x26, 0x78 } }; + static const GUID guid_foo_sample_album_rating_index = { 0xd94ba576, 0x7fab, 0x4f1b,{ 0xbe, 0x5e, 0x4f, 0x8e, 0x9d, 0x5f, 0x30, 0xf1 } }; + static const GUID guid_foo_sample_rating_contextmenu1 = { 0x5d71c93, 0x5d38, 0x4e63,{ 0x97, 0x66, 0x8f, 0xb7, 0x6d, 0xc7, 0xc5, 0x9e } }; + static const GUID guid_foo_sample_rating_contextmenu2 = { 0xf3972846, 0x7c32, 0x44fa,{ 0xbd, 0xa, 0x68, 0x86, 0x65, 0x69, 0x4b, 0x7d } }; + static const GUID guid_foo_sample_rating_contextmenu3 = { 0x67a6d984, 0xe499, 0x4f86,{ 0xb9, 0xcb, 0x66, 0x8e, 0x59, 0xb8, 0xd0, 0xe6 } }; + static const GUID guid_foo_sample_rating_contextmenu4 = { 0x4541dfa5, 0x7976, 0x43aa,{ 0xb9, 0x73, 0x10, 0xc3, 0x26, 0x55, 0x5a, 0x5c } }; + + static const GUID guid_foo_sample_contextmenu_group = { 0x572de7f4, 0xcbdf, 0x479a,{ 0x97, 0x26, 0xa, 0xb0, 0x97, 0x47, 0x69, 0xe3 } }; + static const GUID guid_foo_sample_rating_mainmenu = { 0x53327baa, 0xbaa4, 0x478e,{ 0x87, 0x24, 0xf7, 0x38, 0x4, 0x15, 0xf7, 0x27 } }; + static const GUID guid_foo_sample_mainmenu_group = { 0x44963e7a, 0x4b2a, 0x4588,{ 0xb0, 0x17, 0xa8, 0x69, 0x18, 0xcb, 0x8a, 0xa5 } }; + + // Patterns by which we pin our data to. + // If multiple songs in the library evaluate to the same string, they will be considered the same by our component, + // and data applied to one will also show up with the rest. + // Always recreate relevant index GUIDs if you change these + static const char strTrackRatingPinTo[] = "%artist% - %title%"; + static const char strAlbumRatingPinTo[] = "%album artist% - %album%"; + + + // Our group in Properties dialog / Details tab, see track_property_provider_impl + static const char strPropertiesGroup[] = "Sample Component"; + + // Retain pinned data for four weeks if there are no matching items in library + static const t_filetimestamp retentionPeriod = system_time_periods::week * 4; + + // A class that turns metadata + location info into hashes to which our data gets pinned by the backend. + class metadb_index_client_impl : public metadb_index_client { + public: + metadb_index_client_impl( const char * pinTo ) { + static_api_ptr_t()->compile_force(m_keyObj, pinTo); + } + + metadb_index_hash transform(const file_info & info, const playable_location & location) { + pfc::string_formatter str; + m_keyObj->run_simple( location, &info, str ); + // Make MD5 hash of the string, then reduce it to 64-bit metadb_index_hash + return static_api_ptr_t()->process_single_string( str ).xorHalve(); + } + private: + titleformat_object::ptr m_keyObj; + }; + + static metadb_index_client_impl * clientByGUID( const GUID & guid ) { + // Static instances, never destroyed (deallocated with the process), created first time we get here + // Using service_impl_single_t, reference counting disabled + // This is somewhat ugly, operating on raw pointers instead of service_ptr, but OK for this purpose + static metadb_index_client_impl * g_clientTrack = new service_impl_single_t(strTrackRatingPinTo); + static metadb_index_client_impl * g_clientAlbum = new service_impl_single_t(strAlbumRatingPinTo); + + PFC_ASSERT( guid == guid_foo_sample_album_rating_index || guid == guid_foo_sample_track_rating_index ); + return (guid == guid_foo_sample_album_rating_index ) ? g_clientAlbum : g_clientTrack; + } + + // Static cached ptr to metadb_index_manager + // Cached because we'll be calling it a lot on per-track basis, let's not pass it everywhere to low level functions + // Obtaining the pointer from core is reasonably efficient - log(n) to the number of known service classes, but not good enough for something potentially called hundreds of times + static metadb_index_manager::ptr theAPI() { + // Raw ptr instead service_ptr, don't release on DLL unload, would cause issues + static metadb_index_manager * cached = metadb_index_manager::get().detach(); + return cached; + } + + // An init_stage_callback to hook ourselves into the metadb + // We need to do this properly early to prevent dispatch_global_refresh() from new fields that we added from hammering playlists etc + class init_stage_callback_impl : public init_stage_callback { + public: + void on_init_stage(t_uint32 stage) { + if (stage == init_stages::before_config_read) { + auto api = theAPI(); + // Important, handle the exceptions here! + // This will fail if the files holding our data are somehow corrupted. + try { + api->add(clientByGUID(guid_foo_sample_track_rating_index), guid_foo_sample_track_rating_index, retentionPeriod); + api->add(clientByGUID(guid_foo_sample_album_rating_index), guid_foo_sample_album_rating_index, retentionPeriod); + } catch (std::exception const & e) { + api->remove(guid_foo_sample_track_rating_index); + api->remove(guid_foo_sample_album_rating_index); + FB2K_console_formatter() << "[foo_sample rating] Critical initialization failure: " << e; + return; + } + api->dispatch_global_refresh(); + } + } + }; + + static service_factory_single_t g_init_stage_callback_impl; + + typedef uint32_t rating_t; + static const rating_t rating_invalid = 0; + static const rating_t rating_max = 5; + + struct record_t { + rating_t m_rating = rating_invalid; + pfc::string8 m_comment; + }; + + static record_t record_get(const GUID & indexID, metadb_index_hash hash) { + mem_block_container_impl temp; // this will receive our BLOB + theAPI()->get_user_data( indexID, hash, temp ); + if ( temp.get_size() > 0 ) { + try { + // Parse the BLOB using stream formatters + stream_reader_formatter_simple_ref< /* using big endian data? nope */ false > reader(temp.get_ptr(), temp.get_size()); + + record_t ret; + reader >> ret.m_rating; // little endian uint32 got + + if ( reader.get_remaining() > 0 ) { + // more data left in the stream? + // note that this is a stream_reader_formatter_simple_ref method, regular stream formatters do not know the size or seek around, only read the stream sequentially + reader >> ret.m_comment; // this reads uint32 prefix indicating string size in bytes, then the actual string in UTF-8 characters } + } // otherwise we leave the string empty + + // if we attempted to read past the EOF, we'd land in the exception_io_data handler below + + return ret; + + } catch (exception_io_data const &) { + // we get here as a result of stream formatter data error + // fall thru to return a blank record + } + } + return record_t(); + } + + void record_set( const GUID & indexID, metadb_index_hash hash, const record_t & record) { + + stream_writer_formatter_simple< /* using bing endian data? nope */ false > writer; + writer << record.m_rating; + if ( record.m_comment.length() > 0 ) { + // bother with this only if the comment is not blank + writer << record.m_comment; // uint32 size + UTF-8 bytes + } + + theAPI()->set_user_data( indexID, hash, writer.m_buffer.get_ptr(), writer.m_buffer.get_size() ); + } + + static rating_t rating_get( const GUID & indexID, metadb_index_hash hash) { + return record_get(indexID, hash).m_rating; + } + + + // Returns true if the value was actually changed + static bool rating_set( const GUID & indexID, metadb_index_hash hash, rating_t rating) { + bool bChanged = false; + auto rec = record_get(indexID, hash); + if ( rec.m_rating != rating ) { + rec.m_rating = rating; + record_set( indexID, hash, rec); + bChanged = true; + } + return bChanged; + } + + static bool comment_set( const GUID & indexID, metadb_index_hash hash, const char * strComment ) { + auto rec = record_get(indexID, hash ); + bool bChanged = false; + if ( ! rec.m_comment.equals( strComment ) ) { + rec.m_comment = strComment; + record_set(indexID, hash, rec); + bChanged = true; + } + return bChanged; + } + + // Provider of our title formatting fields. + class metadb_display_field_provider_impl : public metadb_display_field_provider_v2 { + public: + t_uint32 get_field_count() override { + return 6; + } + void get_field_name(t_uint32 index, pfc::string_base & out) override { + PFC_ASSERT(index < get_field_count()); + switch(index) { + case 0: + out = "foo_sample_track_rating"; break; + case 1: + out = "foo_sample_album_rating"; break; + case 2: + out = "foo_sample_track_comment"; break; + case 3: + out = "foo_sample_album_comment"; break; + case 4: + out = "foo_sample_track_hash"; break; + case 5: + out = "foo_sample_album_hash"; break; + default: + PFC_ASSERT(!"Should never get here"); + } + } + + bool process_field(t_uint32 index, metadb_handle* handle, titleformat_text_out* out) override { + return process_field_v2(index, handle, handle->query_v2_(), out); + } + bool process_field_v2(t_uint32 index, metadb_handle * handle, metadb_v2::rec_t const& metarec, titleformat_text_out * out) override { + PFC_ASSERT( index < get_field_count() ); + + const GUID whichID = ((index%2) == 1) ? guid_foo_sample_album_rating_index : guid_foo_sample_track_rating_index; + + if (!metarec.info.is_valid()) return false; + + record_t rec; + const auto hash = clientByGUID(whichID)->transform(metarec.info->info(), handle->get_location()); + + if ( index < 4 ) { + rec = record_get(whichID, hash); + } + + + if ( index < 2 ) { + // rating + + if (rec.m_rating == rating_invalid) return false; + + out->write_int(titleformat_inputtypes::meta, rec.m_rating); + + return true; + } else if ( index < 4 ) { + // comment + + if ( rec.m_comment.length() == 0 ) return false; + + out->write( titleformat_inputtypes::meta, rec.m_comment.c_str() ); + + return true; + } else { + out->write(titleformat_inputtypes::meta, pfc::format_hex(hash,16) ); + return true; + } + } + }; + + static service_factory_single_t g_metadb_display_field_provider_impl; + + static void cycleRating( const GUID & whichID, metadb_handle_list_cref tracks) { + + const size_t count = tracks.get_count(); + if (count == 0) return; + + auto client = clientByGUID(whichID); + + rating_t rating = rating_invalid; + + // Sorted/dedup'd set of all hashes of p_data items. + // pfc::avltree_t<> is pfc equivalent of std::set<>. + // We go the avltree_t<> route because more than one track in p_data might produce the same hash value, see metadb_index_client_impl / strPinTo + pfc::avltree_t allHashes; + for (size_t w = 0; w < count; ++w) { + metadb_index_hash hash; + if (client->hashHandle(tracks[w], hash)) { + allHashes += hash; + + // Take original rating to increment from the first selected song + if (w == 0) rating = rating_get(whichID, hash); + } + } + + if (allHashes.get_count() == 0) { + FB2K_console_formatter() << "[foo_sample rating] Could not hash any of the tracks due to unavailable metadata, bailing"; + return; + } + + // Now cycle the rating value + if (rating == rating_invalid) rating = 1; + else if (rating >= rating_max) rating = rating_invalid; + else ++rating; + + // Now set the new rating + pfc::list_t lstChanged; // Linear list of hashes that actually changed + for (auto iter = allHashes.first(); iter.is_valid(); ++iter) { + const metadb_index_hash hash = *iter; + if (rating_set(whichID, hash, rating) ) { // rating_set returns true if the value actually changed, false if old equals new and no change was made + lstChanged += hash; + } + } + + FB2K_console_formatter() << "[foo_sample rating] " << lstChanged.get_count() << " entries updated"; + if (lstChanged.get_count() > 0) { + // This gracefully tells everyone about what just changed, in one pass regardless of how many items got altered + theAPI()->dispatch_refresh(whichID, lstChanged); + } + + } + + static void cycleComment( const GUID & whichID, metadb_handle_list_cref tracks ) { + const size_t count = tracks.get_count(); + if (count == 0) return; + + auto client = clientByGUID(whichID); + + pfc::string8 comment; + + // Sorted/dedup'd set of all hashes of p_data items. + // pfc::avltree_t<> is pfc equivalent of std::set<>. + // We go the avltree_t<> route because more than one track in p_data might produce the same hash value, see metadb_index_client_impl / strPinTo + pfc::avltree_t allHashes; + for (size_t w = 0; w < count; ++w) { + metadb_index_hash hash; + if (client->hashHandle(tracks[w], hash)) { + allHashes += hash; + + // Take original rating to increment from the first selected song + if (w == 0) comment = record_get(whichID, hash).m_comment; + } + } + + if (allHashes.get_count() == 0) { + FB2K_console_formatter() << "[foo_sample rating] Could not hash any of the tracks due to unavailable metadata, bailing"; + return; + } + + // Now cycle the comment value + if ( comment.equals("") ) comment = "foo"; + else if ( comment.equals("foo") ) comment = "bar"; + else comment = ""; + + // Now apply the new comment + pfc::list_t lstChanged; // Linear list of hashes that actually changed + for (auto iter = allHashes.first(); iter.is_valid(); ++iter) { + const metadb_index_hash hash = *iter; + + if ( comment_set(whichID, hash, comment) ) { + lstChanged += hash; + } + } + + FB2K_console_formatter() << "[foo_sample rating] " << lstChanged.get_count() << " entries updated"; + if (lstChanged.get_count() > 0) { + // This gracefully tells everyone about what just changed, in one pass regardless of how many items got altered + theAPI()->dispatch_refresh(whichID, lstChanged); + } + } + + class contextmenu_rating : public contextmenu_item_simple { + public: + GUID get_parent() { + return guid_foo_sample_contextmenu_group; + } + unsigned get_num_items() { + return 4; + } + void get_item_name(unsigned p_index, pfc::string_base & p_out) { + PFC_ASSERT( p_index < get_num_items() ); + switch(p_index) { + case 0: + p_out = "Cycle track rating"; break; + case 1: + p_out = "Cycle album rating"; break; + case 2: + p_out = "Cycle track comment"; break; + case 3: + p_out = "Cycle album comment"; break; + } + + } + void context_command(unsigned p_index, metadb_handle_list_cref p_data, const GUID& p_caller) { + PFC_ASSERT( p_index < get_num_items() ); + + const GUID whichID = ((p_index%2) == 1) ? guid_foo_sample_album_rating_index : guid_foo_sample_track_rating_index; + + if ( p_index < 2 ) { + // rating + cycleRating( whichID, p_data ); + } else { + cycleComment( whichID, p_data ); + + } + + } + GUID get_item_guid(unsigned p_index) { + switch(p_index) { + case 0: return guid_foo_sample_rating_contextmenu1; + case 1: return guid_foo_sample_rating_contextmenu2; + case 2: return guid_foo_sample_rating_contextmenu3; + case 3: return guid_foo_sample_rating_contextmenu4; + default: uBugCheck(); + } + } + bool get_item_description(unsigned p_index, pfc::string_base & p_out) { + PFC_ASSERT( p_index < get_num_items() ); + switch( p_index ) { + case 0: + p_out = "Alters foo_sample's track rating on one or more selected tracks. Use %foo_sample_track_rating% to display the rating."; + return true; + case 1: + p_out = "Alters foo_sample's album rating on one or more selected tracks. Use %foo_sample_album_rating% to display the rating."; + return true; + case 2: + p_out = "Alters foo_sample's track comment on one or more selected tracks. Use %foo_sample_track_comment% to display the comment."; + return true; + case 3: + p_out = "Alters foo_sample's album comment on one or more selected tracks. Use %foo_sample_album_comment% to display the comment."; + return true; + default: + PFC_ASSERT(!"Should not get here"); + return false; + } + } + }; + + static contextmenu_item_factory_t< contextmenu_rating > g_contextmenu_rating; + + static pfc::string_formatter formatRatingDump(const GUID & whichID) { + auto api = theAPI(); + pfc::list_t hashes; + api->get_all_hashes(whichID, hashes); + pfc::string_formatter message; + message << "The database contains " << hashes.get_count() << " hashes.\n"; + for( size_t hashWalk = 0; hashWalk < hashes.get_count(); ++ hashWalk ) { + auto hash = hashes[hashWalk]; + message << pfc::format_hex( hash, 8 ) << " : "; + auto rec = record_get(whichID, hash); + if ( rec.m_rating == rating_invalid ) message << "no rating"; + else message << "rating " << rec.m_rating; + if ( rec.m_comment.length() > 0 ) { + message << ", comment: " << rec.m_comment; + } + + metadb_handle_list tracks; + + // Note that this returns only handles present in the media library + + // Extra work is required if the user has no media library but only playlists, + // have to walk the playlists and match hashes by yourself instead of calling this method + api->get_ML_handles(whichID, hash, tracks); + + + if ( tracks.get_count() == 0 ) message << ", no matching tracks in Media Library\n"; + else { + message << ", " << tracks.get_count() << " matching track(s)\n"; + for( size_t w = 0; w < tracks.get_count(); ++ w ) { + // pfc string formatter operator<< for metadb_handle prints the location + message << tracks[w] << "\n"; + } + } + } + + return message; + } + + class mainmenu_rating : public mainmenu_commands { + public: + t_uint32 get_command_count() { + return 1; + } + GUID get_command(t_uint32 p_index) { + return guid_foo_sample_rating_mainmenu; + } + void get_name(t_uint32 p_index, pfc::string_base & p_out) { + PFC_ASSERT( p_index == 0 ); + p_out = "Dump rating database"; + } + bool get_description(t_uint32 p_index, pfc::string_base & p_out) { + PFC_ASSERT(p_index == 0); + p_out = "Shows a dump of the foo_sample rating database."; return true; + } + GUID get_parent() { + return guid_foo_sample_mainmenu_group; + } + void execute(t_uint32 p_index, service_ptr_t p_callback) { + PFC_ASSERT( p_index == 0 ); + + try { + + pfc::string_formatter dump; + dump << "==== TRACK RATING DUMP ====\n" << formatRatingDump( guid_foo_sample_track_rating_index ) << "\n\n"; + dump << "==== ALBUM RATING DUMP ====\n" << formatRatingDump( guid_foo_sample_album_rating_index ) << "\n\n"; + + popup_message::g_show(dump, "foo_sample rating dump"); + } catch(std::exception const & e) { + // should not really get here + popup_message::g_complain("Rating dump failed", e); + } + } + }; + static service_factory_single_t g_mainmenu_rating; + + + // This class provides our information for the properties dialog + class track_property_provider_impl : public track_property_provider_v2 { + public: + void workThisIndex(GUID const & whichID, const char * whichName, double priorityBase, metadb_handle_list_cref p_tracks, track_property_callback & p_out) { + auto client = clientByGUID( whichID ); + pfc::avltree_t hashes; + const size_t trackCount = p_tracks.get_count(); + for (size_t trackWalk = 0; trackWalk < trackCount; ++trackWalk) { + metadb_index_hash hash; + if (client->hashHandle(p_tracks[trackWalk], hash)) { + hashes += hash; + } + } + + pfc::string8 strAverage = "N/A", strMin = "N/A", strMax = "N/A"; + pfc::string8 strComment; + + { + size_t count = 0; + rating_t minval = rating_invalid; + rating_t maxval = rating_invalid; + uint64_t accum = 0; + bool bFirst = true; + bool bVarComments = false; + for (auto i = hashes.first(); i.is_valid(); ++i) { + auto rec = record_get(whichID, *i); + auto r = rec.m_rating; + if (r != rating_invalid) { + ++count; + accum += r; + + if (minval == rating_invalid || minval > r) minval = r; + if (maxval == rating_invalid || maxval < r) maxval = r; + } + + + if ( bFirst ) { + strComment = rec.m_comment; + } else if ( ! bVarComments ) { + if ( strComment != rec.m_comment ) { + bVarComments = true; + strComment = ""; + } + } + + bFirst = false; + } + + + if (count > 0) { + strMin = pfc::format_uint(minval); + strMax = pfc::format_uint(maxval); + strAverage = pfc::format_float((double)accum / (double)count, 0, 3); + } + } + + p_out.set_property(strPropertiesGroup, priorityBase + 0, PFC_string_formatter() << "Average " << whichName << " Rating", strAverage); + p_out.set_property(strPropertiesGroup, priorityBase + 1, PFC_string_formatter() << "Minimum " << whichName << " Rating", strMin); + p_out.set_property(strPropertiesGroup, priorityBase + 2, PFC_string_formatter() << "Maximum " << whichName << " Rating", strMax); + if ( strComment.length() > 0 ) { + p_out.set_property(strPropertiesGroup, priorityBase + 3, PFC_string_formatter() << whichName << " Comment", strComment); + } + } + void enumerate_properties(metadb_handle_list_cref p_tracks, track_property_callback & p_out) { + workThisIndex( guid_foo_sample_track_rating_index, "Track", 0, p_tracks, p_out ); + workThisIndex( guid_foo_sample_album_rating_index, "Album", 10, p_tracks, p_out); + } + void enumerate_properties_v2(metadb_handle_list_cref p_tracks, track_property_callback_v2 & p_out) { + if ( p_out.is_group_wanted( strPropertiesGroup ) ) { + enumerate_properties( p_tracks, p_out ); + } + } + + bool is_our_tech_info(const char * p_name) { + // If we do stuff with tech infos read from the file itself (see file_info::info_* methods), signal whether this field belongs to us + // We don't do any of this, hence false + return false; + } + + }; + + + static service_factory_single_t g_track_property_provider_impl; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/foo_sample/readme.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/foo_sample/readme.txt Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,32 @@ +This component demonstrates: +* main.cpp : + * Declaring your component's version information. +* input_raw.cpp : + * Declaring your own "input" classes for decoding additional audio file formats. + * Calling file system services. +* preferences.cpp : + * Declaring your configuration variables. + * Creating preferences pages using simple WTL dialogs. + * Declaring advanced preferences entries. +* initquit.cpp : + * Sample initialization/shutdown callback service. +* dsp.cpp : + * Sample DSP. +* contextmenu.cpp : + * Sample context menu command. +* decode.cpp : + * Getting PCM data from arbitrary audio files. + * Use of the threaded_process API to easily run time-consuming tasks in worker threads with progress dialogs. +* mainmenu.cpp : + * Sample main menu command +* playback_state.cpp : + * Use of playback callbacks. + * Use of playback control. +* ui_element.cpp : + * Simple UI Element implementation. +* rating.cpp + * Minimal rating+comment implementation using metadb_index_client. + * Present your data via title formatting using metadb_display_field_provider. + * Present your data in the properties dialog using track_property_provider. + * Utility menu items. + * Basic use of stream formatters. \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/foo_sample/resource.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/foo_sample/resource.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,45 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by foo_sample.rc +// +#define IDD_PLAYBACK_STATE 101 +#define IDD_DSP 102 +#define IDD_UI_ELEMENT 103 +#define IDD_THREADS 105 +#define IDD_LISTCONTROL_DEMO 107 +#define IDI_ICON1 109 +#define IDD_MYPREFERENCES 148 +#define IDC_BOGO1 1001 +#define IDC_BOGO2 1002 +#define IDC_PATTERN 1002 +#define IDC_STATE 1003 +#define IDC_PLAY 1004 +#define IDC_PAUSE 1005 +#define IDC_STOP 1006 +#define IDC_PREV 1007 +#define IDC_NEXT 1008 +#define IDC_RAND 1009 +#define IDC_CONTEXTMENU 1010 +#define IDC_SLIDER1 1012 +#define IDC_SLIDER 1012 +#define IDC_SLIDER_LABEL 1013 +#define IDC_LOCK_MIN_WIDTH 1014 +#define IDC_LOCK_MIN_HEIGHT 1015 +#define IDC_CHECK3 1016 +#define IDC_LOCK_MAX_WIDTH 1016 +#define IDC_LOCK_MAX_HEIGHT 1017 +#define IDC_STATIC_SIZE 1018 +#define IDC_LIST1 1019 +#define IDC_LIST 1019 +#define IDC_HEADER 1020 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 110 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1021 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/foo_sample/stdafx.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/foo_sample/stdafx.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,7 @@ +#ifdef __cplusplus +#include +#endif + +#ifdef __OBJC__ +#include +#endif diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/foo_sample/ui_and_threads.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/foo_sample/ui_and_threads.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,296 @@ +#include "stdafx.h" +#include "resource.h" + +// Modern multi threading with C++ +// Or: how I learned to stop worrying and love the lambdas + +#ifdef _WIN32 + +#include // shared_ptr +#include +#include +#include +#include + + + +namespace { // anon namespace local classes for good measure + + + class CDemoDialog; // forward declaration + + // This is kept a separate shared_ptr'd struct because it may outlive CDemoDialog instance. + struct sharedData_t { + metadb_handle_list items; + CDemoDialog * owner; // weak reference to the owning dialog; can be only used after checking the validity by other means. + }; + + static const CDialogResizeHelper::Param resizeData[] = { + // Dialog resize handling matrix, defines how the controls scale with the dialog + // L T R B + {IDOK, 1,1,1,1 }, + {IDCANCEL, 1,1,1,1 }, + {IDC_HEADER, 0,0,1,0 }, + {IDC_LIST, 0,0,1,1 }, + + // current position of a control is determined by initial_position + factor * (current_dialog_size - initial_dialog_size) + // where factor is the value from the table above + // applied to all four values - left, top, right, bottom + // 0,0,0,0 means that a control doesn't react to dialog resizing (aligned to top+left, no resize) + // 1,1,1,1 means that the control is aligned to bottom+right but doesn't resize + // 0,0,1,0 means that the control disregards vertical resize (aligned to top) and changes its width with the dialog + }; + + // Minimum/maximum size, in dialog box units; see MSDN MapDialogRect for more info about dialog box units. + // The values can be declared constant here and will be scaled appropriately depending on display DPI. + static const CRect resizeMinMax(150, 100, 1000, 1000); + + class CDemoDialog : public CDialogImpl { + public: + enum { IDD = IDD_THREADS }; + CDemoDialog( metadb_handle_list_cref items ) : m_resizer(resizeData, resizeMinMax) { + m_sharedData = std::make_shared< sharedData_t > (); + m_sharedData->items = items; + m_sharedData->owner = this; + } + + BEGIN_MSG_MAP_EX(CDemoDialog) + CHAIN_MSG_MAP_MEMBER(m_resizer) + MSG_WM_INITDIALOG(OnInitDialog) + COMMAND_HANDLER_EX(IDOK, BN_CLICKED, OnOK) + COMMAND_HANDLER_EX(IDCANCEL, BN_CLICKED, OnCancel) + MSG_WM_CLOSE(OnClose) + MSG_WM_DESTROY(OnDestroy) + MSG_WM_SIZE(OnSize) + END_MSG_MAP() + private: + BOOL OnInitDialog(CWindow, LPARAM) { + uSetDlgItemText(*this, IDC_HEADER, PFC_string_formatter() << "Selected: " << m_sharedData->items.get_size() << " tracks." ); + m_listBox = GetDlgItem(IDC_LIST); + + m_statusBar.Create(*this, NULL, TEXT(""), WS_CHILD | WS_VISIBLE); + + m_statusBar.SetWindowText(L"Ready"); + + ShowWindow(SW_SHOW); + + return TRUE; // system should set focus + } + void OnSize(UINT nType, CSize size) { + // Tell statusbar that we got resized. CDialogResizeHelper can't do this for us. + m_statusBar.SendMessage(WM_SIZE); + } + void OnDestroy() { + cancelTask(); + } + + void OnClose() { + // NOTE if we do not handle WM_CLOSE, WM_COMMAND with IDCANCEL will be invoked, executing our cancel handler. + // We provide our own WM_CLOSE handler to provide a different response to closing the window. + DestroyWindow(); + } + + void OnCancel(UINT, int, CWindow) { + // If a task is active, cancel it + // otherwise destroy the dialog + if (! cancelTask() ) { + DestroyWindow(); + } else { + // Refresh UI + taskCompleted(); + } + } + void OnOK(UINT, int, CWindow) { + startTask(); + } + void startTask() { + cancelTask(); // cancel any running task + + GetDlgItem(IDCANCEL).SetWindowText(L"Cancel"); + m_statusBar.SetWindowText(L"Working..."); + + auto shared = m_sharedData; + auto aborter = std::make_shared(); + m_aborter = aborter; + + // New in fb2k 1.4.5: async_task_manager & splitTask + // Use fb2k::splitTask() for starting detached threads. + // In fb2k < 1.4.5, it will fall back to just starting a detached thread. + // fb2k 1.4.5+ async_task_manager cleanly deals with user exiting foobar2000 while a detached async task is running. + // Shutdown of foobar2000 process will be stalled until your task completes. + // If you use other means to ensure that the thread has finished, such as waiting for the thread to exit in your dialog's destructor, there's no need for this. + + fb2k::splitTask( [aborter, shared] { + // In worker thread! + try { + work( shared, aborter ); + } catch(exception_aborted const &) { + return; // user abort? + } catch(std::exception const & e) { + // should not really get here + logLineProc( shared, aborter, PFC_string_formatter() << "Critical error: " << e); + } + try { + mainThreadOp( aborter, [shared] { + shared->owner->taskCompleted(); + } ); + } catch(...) {} // mainThreadOp may throw exception_aborted + } ); + } + void taskCompleted() { + m_aborter.reset(); + GetDlgItem(IDCANCEL).SetWindowText(L"Close"); + m_statusBar.SetWindowText(L"Finished, ready"); + } + + static void mainThreadOp(std::shared_ptr aborter, std::function op ) { + aborter->check(); // are we getting aborted? + fb2k::inMainThread( [=] { + if ( aborter->is_set() ) return; // final user abort check + // Past this, we're main thread, the task has not been cancelled by the user and the dialog is still alive + // and any dialog methods can be safely called + op(); + } ); + } + + static void logLineProc(std::shared_ptr shared, std::shared_ptr aborter, const char * line_ ) { + pfc::string8 line( line_ ); // can't hold to the const char* we got passed, we have no guarantees about its lifetime + mainThreadOp( aborter, [shared, line] { + shared->owner->logLine(line); + } ); + } + static void work( std::shared_ptr shared, std::shared_ptr aborter ) { + // clear the log + mainThreadOp(aborter, [shared] { + shared->owner->clearLog(); + } ); + + // A convenience wrapper that calls logLineProc() + auto log = [shared, aborter] ( const char * line ) { + logLineProc(shared, aborter, line); + }; + // Use log(X) instead of logLineProc(shared, aborter, X) + + for( size_t trackWalk = 0; trackWalk < shared->items.get_size(); ++ trackWalk ) { + aborter->check(); + auto track = shared->items[trackWalk]; + log( PFC_string_formatter() << "Track: " << track ); + + try { + const auto path = track->get_path(); + const auto subsong = track->get_subsong_index(); + + // Not strictly needed, but we do it anyway + // Acquire a read lock on the file, so anyone trying to acquire a write lock will just wait till we have finished + auto lock = file_lock_manager::get()->acquire_read(path, *aborter); + + { + input_decoder::ptr dec; + input_entry::g_open_for_decoding(dec, nullptr, path, *aborter); + + file_info_impl info; + dec->get_info( subsong, info, *aborter ); + auto title = info.meta_get("title",0); + if ( title == nullptr ) log("Untitled"); + else log(PFC_string_formatter() << "Title: " << title ); + if ( info.get_length() > 0 ) log(PFC_string_formatter() << "Duration: " << pfc::format_time_ex(info.get_length(),6) ); + auto stats = dec->get_file_stats( *aborter ); + if ( stats.m_size != filesize_invalid ) log( PFC_string_formatter() << "Size: " << pfc::format_file_size_short(stats.m_size) ); + if ( stats.m_timestamp != filetimestamp_invalid ) log( PFC_string_formatter() << "Last modified: " << format_filetimestamp( stats.m_timestamp ) ); + + + dec->initialize( subsong, input_flag_simpledecode, * aborter ); + audio_chunk_impl chunk; + uint64_t numChunks = 0, numSamples = 0; + // duration_counter tool is a strictly accurate audio duration counter retaining all sample counts passed to it, immune to floatingpoint accuracy errors + duration_counter duration; + bool firstChunk = true; + while(dec->run(chunk, *aborter) ) { + if ( firstChunk ) { + auto spec = chunk.get_spec(); + log(PFC_string_formatter() << "Audio sample rate: " << spec.sampleRate ); + log(PFC_string_formatter() << "Audio channels: " << audio_chunk::g_formatChannelMaskDesc( spec.chanMask ) ); + firstChunk = false; + } + ++ numChunks; + duration += chunk; + numSamples += chunk.get_sample_count(); + } + log(PFC_string_formatter() << "Decoded " << numChunks << " chunks"); + log(PFC_string_formatter() << "Exact duration decoded: " << pfc::format_time_ex(duration.query(), 6) << ", " << numSamples << " samples" ); + } + + try { + auto aa = album_art_extractor::g_open( nullptr, path, *aborter ); + + if ( aa->have_entry( album_art_ids::cover_front, *aborter ) ) { + log("Album art: front cover found"); + } + if ( aa->have_entry( album_art_ids::cover_back, *aborter ) ) { + log("Album art: back cover found"); + } + if (aa->have_entry( album_art_ids::artist, *aborter ) ) { + log("Album art: artist picture found"); + } + } catch(exception_album_art_not_found) { + } catch(exception_album_art_unsupported_format) { + } + + } catch(exception_aborted) { + throw; + } catch(std::exception const & e) { + log( PFC_string_formatter() << "Failure: " << e); + } + } + log("All done."); + } + + bool cancelTask() { + bool ret = false; + auto aborter = pfc::replace_null_t(m_aborter); + if (aborter) { + ret = true; + aborter->set(); + logLine("Aborted by user."); + } + return ret; + } + + void logLine( const char * line ) { + m_listBox.AddString( pfc::stringcvt::string_os_from_utf8(line) ); + } + + void clearLog() { + m_listBox.ResetContent(); + } + + + // Worker thread aborter. It's re-created with the thread. If the task is ran more than once, each time it gets a new one. + // A commonly used alternative is to have abort_callback_impl m_aborter, and a blocking cancelTask() that waits for the thread to exit, without all the shared_ptrs and recreation of aborters. + // However that approach will freeze the UI if the worker thread is taking a long time to exit, as well as require some other shared_ptr based means for fb2k::inMainThread() ops to verify that the task is not being aborted / the dialog still exists. + // Therefore we use a shared_ptr'd aborter, which is used both to abort worker threads, and for main thread callbacks to know if the task that sent them is still valid. + std::shared_ptr m_aborter; + + // Data shared with the worker thread. It is created only once per dialog lifetime. + std::shared_ptr< sharedData_t > m_sharedData; + + CListBox m_listBox; + + CStatusBarCtrl m_statusBar; + + CDialogResizeHelper m_resizer; + }; +} + +void RunUIAndThreads(metadb_handle_list_cref data) { + // Equivalent to new CDemoDialog(data), with modeless registration and auto lifetime + fb2k::newDialog( data ); +} + +#else + +void RunUIAndThreads(metadb_handle_list_cref data) { + popup_message::g_showToast("Not implemented for Mac OS yet"); +} + +#endif diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/foo_sample/ui_element.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/foo_sample/ui_element.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,82 @@ +#include "stdafx.h" + +#include +#include + + +namespace { + // Anonymous namespace : standard practice in fb2k components + // Nothing outside should have any reason to see these symbols, and we don't want funny results if another cpp has similarly named classes. + // service_factory at the bottom takes care of publishing our class. + + // This is our GUID. Substitute with your own when reusing code. + static const GUID guid_myelem = { 0xb46dc166, 0x88f3, 0x4b45, { 0x9f, 0x77, 0xab, 0x33, 0xf4, 0xc3, 0xf2, 0xe4 } }; + + class CMyElemWindow : public ui_element_instance, public CWindowImpl { + public: + // ATL window class declaration. Replace class name with your own when reusing code. + DECLARE_WND_CLASS_EX(TEXT("{DC2917D5-1288-4434-A28C-F16CFCE13C4B}"),CS_VREDRAW | CS_HREDRAW,(-1)); + + void initialize_window(HWND parent) {WIN32_OP(Create(parent) != NULL);} + + BEGIN_MSG_MAP_EX(CMyElemWindow) + MESSAGE_HANDLER(WM_LBUTTONDOWN,OnLButtonDown); + MSG_WM_ERASEBKGND(OnEraseBkgnd) + MSG_WM_PAINT(OnPaint) + END_MSG_MAP() + + CMyElemWindow(ui_element_config::ptr,ui_element_instance_callback_ptr p_callback); + HWND get_wnd() {return *this;} + void set_configuration(ui_element_config::ptr config) {m_config = config;} + ui_element_config::ptr get_configuration() {return m_config;} + static GUID g_get_guid() { + return guid_myelem; + } + static GUID g_get_subclass() {return ui_element_subclass_utility;} + static void g_get_name(pfc::string_base & out) {out = "Sample UI Element";} + static ui_element_config::ptr g_get_default_configuration() {return ui_element_config::g_create_empty(g_get_guid());} + static const char * g_get_description() {return "This is a sample UI Element.";} + + void notify(const GUID & p_what, t_size p_param1, const void * p_param2, t_size p_param2size); + private: + LRESULT OnLButtonDown(UINT,WPARAM,LPARAM,BOOL&) {m_callback->request_replace(this);return 0;} + void OnPaint(CDCHandle); + BOOL OnEraseBkgnd(CDCHandle); + ui_element_config::ptr m_config; + protected: + // this must be declared as protected for ui_element_impl_withpopup<> to work. + const ui_element_instance_callback_ptr m_callback; + }; + void CMyElemWindow::notify(const GUID & p_what, t_size p_param1, const void * p_param2, t_size p_param2size) { + if (p_what == ui_element_notify_colors_changed || p_what == ui_element_notify_font_changed) { + // we use global colors and fonts - trigger a repaint whenever these change. + Invalidate(); + } + } + CMyElemWindow::CMyElemWindow(ui_element_config::ptr config,ui_element_instance_callback_ptr p_callback) : m_callback(p_callback), m_config(config) { + } + + BOOL CMyElemWindow::OnEraseBkgnd(CDCHandle dc) { + CRect rc; WIN32_OP_D( GetClientRect(&rc) ); + CBrush brush; + WIN32_OP_D( brush.CreateSolidBrush( m_callback->query_std_color(ui_color_background) ) != NULL ); + WIN32_OP_D( dc.FillRect(&rc, brush) ); + return TRUE; + } + void CMyElemWindow::OnPaint(CDCHandle) { + CPaintDC dc(*this); + dc.SetTextColor( m_callback->query_std_color(ui_color_text) ); + dc.SetBkMode(TRANSPARENT); + SelectObjectScope fontScope(dc, (HGDIOBJ) m_callback->query_font_ex(ui_font_default) ); + const UINT format = DT_NOPREFIX | DT_CENTER | DT_VCENTER | DT_SINGLELINE; + CRect rc; + WIN32_OP_D( GetClientRect(&rc) ); + WIN32_OP_D( dc.DrawText(_T("This is a sample element."), -1, &rc, format) > 0 ); + } + + // ui_element_impl_withpopup autogenerates standalone version of our component and proper menu commands. Use ui_element_impl instead if you don't want that. + class ui_element_myimpl : public ui_element_impl_withpopup {}; + + static service_factory_single_t g_ui_element_myimpl_factory; + +} // namespace \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/foo_sample/ui_element_dialog.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/foo_sample/ui_element_dialog.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,205 @@ +#include "stdafx.h" + +#include "resource.h" + +#include +#include // WIN32_OP() +#include // CCheckBox +#include // ui_element_impl + +#include + +namespace { + // Anonymous namespace : standard practice in fb2k components + // Nothing outside should have any reason to see these symbols, and we don't want funny results if another cpp has similarly named classes. + // service_factory at the bottom takes care of publishing our class. + + + // I am Sample Component and this is *MY* GUID. + // Replace with your own when reusing code. Component authors with colliding GUIDs will be visited by Urdnot Wrex in person. + static const GUID guid_myelem = { 0x78ca1d7, 0x4e3a, 0x41d5, { 0xa5, 0xef, 0x9d, 0x1a, 0xf7, 0xd5, 0x79, 0xd0 } }; + + enum { + FlagLockMinWidth = 1 << 0, + FlagLockMinHeight = 1 << 1, + FlagLockMaxWidth = 1 << 2, + FlagLockMaxHeight = 1 << 3, + + FlagsDefault = 0 + }; + static const struct { + int btnID; + uint32_t flag; + } flagsAndButtons[] = { + { IDC_LOCK_MIN_WIDTH, FlagLockMinWidth }, + { IDC_LOCK_MIN_HEIGHT, FlagLockMinHeight }, + { IDC_LOCK_MAX_WIDTH, FlagLockMaxWidth }, + { IDC_LOCK_MAX_HEIGHT, FlagLockMaxHeight }, + }; + + class CDialogUIElem : public CDialogImpl, public ui_element_instance { + public: + CDialogUIElem( ui_element_config::ptr cfg, ui_element_instance_callback::ptr cb ) : m_callback(cb), m_flags( parseConfig(cfg) ) {} + + enum { IDD = IDD_UI_ELEMENT }; + + BEGIN_MSG_MAP_EX( CDialogUIElem ) + MSG_WM_INITDIALOG(OnInitDialog) + MSG_WM_SIZE(OnSize) + COMMAND_CODE_HANDLER_EX(BN_CLICKED, OnButtonClicked) + END_MSG_MAP() + + void initialize_window(HWND parent) {WIN32_OP(Create(parent) != NULL);} + HWND get_wnd() { return m_hWnd; } + void set_configuration(ui_element_config::ptr config) { + m_flags = parseConfig( config ); + if ( m_hWnd != NULL ) { + configToUI(); + } + m_callback->on_min_max_info_change(); + } + ui_element_config::ptr get_configuration() {return makeConfig(m_flags);} + static GUID g_get_guid() { + return guid_myelem; + } + static void g_get_name(pfc::string_base & out) {out = "Sample Dialog as UI Element";} + static ui_element_config::ptr g_get_default_configuration() { + return makeConfig( ); + } + static const char * g_get_description() {return "This is a sample UI Element using win32 dialog.";} + static GUID g_get_subclass() {return ui_element_subclass_utility;} + + ui_element_min_max_info get_min_max_info() { + ui_element_min_max_info ret; + + // Note that we play nicely with separate horizontal & vertical DPI. + // Such configurations have not been ever seen in circulation, but nothing stops us from supporting such. + CSize DPI = QueryScreenDPIEx( *this ); + + if ( DPI.cx <= 0 || DPI.cy <= 0 ) { // sanity + DPI = CSize(96, 96); + } + + if ( m_flags & FlagLockMinWidth ) { + ret.m_min_width = MulDiv( 200, DPI.cx, 96 ); + } + if ( m_flags & FlagLockMinHeight ) { + ret.m_min_height = MulDiv( 200, DPI.cy, 96 ); + } + if ( m_flags & FlagLockMaxWidth ) { + ret.m_max_width = MulDiv( 400, DPI.cx, 96 ); + } + if ( m_flags & FlagLockMaxHeight ) { + ret.m_max_height = MulDiv( 400, DPI.cy, 96 ); + } + + // Deal with WS_EX_STATICEDGE and alike that we might have picked from host + ret.adjustForWindow( *this ); + + return ret; + } + + void applyDark() { + t_ui_color color = 0; + if (m_callback->query_color(ui_color_darkmode, color)) { + m_dark.SetDark(color == 0); + } + } + void notify(const GUID& p_what, t_size p_param1, const void* p_param2, t_size p_param2size) override { + // Colors changed? Check dark mode config + if (p_what == ui_element_notify_colors_changed) { + applyDark(); + } + } + private: + static uint32_t parseConfig( ui_element_config::ptr cfg ) { + try { + ::ui_element_config_parser in ( cfg ); + uint32_t flags; in >> flags; + return flags; + } catch(exception_io_data) { + // If we got here, someone's feeding us nonsense, fall back to defaults + return FlagsDefault; + } + } + static ui_element_config::ptr makeConfig(uint32_t flags = FlagsDefault) { + ui_element_config_builder out; + out << flags; + return out.finish( g_get_guid() ); + } + void configToUI() { + for ( unsigned i = 0; i < PFC_TABSIZE( flagsAndButtons ); ++ i ) { + auto rec = flagsAndButtons[i]; + // CCheckBox: WTL-PP class overlaying ToggleCheck(bool) and bool IsChecked() over WTL CButton + CCheckBox cb ( GetDlgItem( rec.btnID ) ); + cb.ToggleCheck( (m_flags & rec.flag ) != 0 ); + } + } + void OnButtonClicked(UINT uNotifyCode, int nID, CWindow wndCtl) { + + uint32_t flagToFlip = 0; + for ( unsigned i = 0; i < PFC_TABSIZE( flagsAndButtons ); ++ i ) { + auto rec = flagsAndButtons[i]; + if ( rec.btnID == nID ) { + flagToFlip = rec.flag; + } + } + if ( flagToFlip != 0 ) { + uint32_t newFlags = m_flags; + CCheckBox cb ( wndCtl ); + if (cb.IsChecked()) { + newFlags |= flagToFlip; + } else { + newFlags &= ~flagToFlip; + } + if ( newFlags != m_flags ) { + m_flags = newFlags; + m_callback->on_min_max_info_change(); + } + } + } + + void OnSize(UINT, CSize s) { + auto DPI = QueryScreenDPIEx(*this); + + pfc::string_formatter msg; + msg << "Current size: "; + if ( DPI.cx > 0 && DPI.cy > 0 ) { + msg << MulDiv( s.cx, 96, DPI.cx ) << "x" << MulDiv( s.cy, 96, DPI.cy ) << " units, "; + } + msg << s.cx << "x" << s.cy << " pixels"; + + uSetDlgItemText( *this, IDC_STATIC_SIZE, msg ); + } + BOOL OnInitDialog(CWindow, LPARAM) { + + // First tell m_dark whether we're dark nor not + applyDark(); + // Then initialize it + m_dark.AddDialogWithControls(*this); + // The above two work in any order, though this way is slightly more efficient + + configToUI(); + { + CRect rc; + // WIN32_OP_D() - Debug build only retval check and assert + // For stuff that practically never fails + WIN32_OP_D( GetClientRect( &rc ) ); + OnSize( 0, rc.Size() ); + } + + return FALSE; + } + const ui_element_instance_callback::ptr m_callback; + uint32_t m_flags; + + // No fb2k::CDarkModeHooks. + // Politely ask our callback if we should render as dark or not, instead of using global settings. + // Though in real life it's all the same in the end. + DarkMode::CHooks m_dark; + }; + + + static service_factory_single_t< ui_element_impl< CDialogUIElem > > g_CDialogUIElem_factory; +} + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/foobar2000_component_client/component_client.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/foobar2000_component_client/component_client.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,137 @@ +#include +#include +#include + +#ifdef _WIN32 +static HINSTANCE g_hIns; +#endif +static pfc::string_simple g_name,g_full_path; + +static bool g_services_available = false, g_initialized = false; + + + +namespace core_api +{ + +#ifdef _WIN32 + HINSTANCE get_my_instance() + { + return g_hIns; + } +#endif + fb2k::hwnd_t get_main_window() + { + PFC_ASSERT( g_foobar2000_api != NULL ); + return g_foobar2000_api->get_main_window(); + } + const char* get_my_file_name() + { + return g_name; + } + + const char* get_my_full_path() + { + return g_full_path; + } + + bool are_services_available() + { + return g_services_available; + } + bool assert_main_thread() + { + return (g_services_available && g_foobar2000_api) ? g_foobar2000_api->assert_main_thread() : true; + } + + void ensure_main_thread() { + if (!is_main_thread()) FB2K_BugCheck(); + } + + bool is_main_thread() + { + return (g_services_available && g_foobar2000_api) ? g_foobar2000_api->is_main_thread() : true; + } + const char* get_profile_path() + { + PFC_ASSERT( g_foobar2000_api != NULL ); + return g_foobar2000_api->get_profile_path(); + } + + bool is_shutting_down() + { + return (g_services_available && g_foobar2000_api) ? g_foobar2000_api->is_shutting_down() : g_initialized; + } + bool is_initializing() + { + return (g_services_available && g_foobar2000_api) ? g_foobar2000_api->is_initializing() : !g_initialized; + } + bool is_portable_mode_enabled() { + PFC_ASSERT( g_foobar2000_api != NULL ); + return g_foobar2000_api->is_portable_mode_enabled(); + } + + bool is_quiet_mode_enabled() { + PFC_ASSERT( g_foobar2000_api != NULL ); + return g_foobar2000_api->is_quiet_mode_enabled(); + } +} + +namespace { + class foobar2000_client_impl : public foobar2000_client, private foobar2000_component_globals + { + public: + t_uint32 get_version() override {return FOOBAR2000_CLIENT_VERSION;} + pservice_factory_base get_service_list() override {return service_factory_base::__internal__list;} + + void get_config(stream_writer * p_stream,abort_callback & p_abort) override { +#ifdef FOOBAR2000_HAVE_CFG_VAR_LEGACY + cfg_var_legacy::cfg_var::config_write_file(p_stream,p_abort); +#endif + } + + void set_config(stream_reader * p_stream,abort_callback & p_abort) override { +#ifdef FOOBAR2000_HAVE_CFG_VAR_LEGACY + cfg_var_legacy::cfg_var::config_read_file(p_stream,p_abort); +#endif + } + + void set_library_path(const char * path,const char * name) override { + g_full_path = path; + g_name = name; + } + + void services_init(bool val) override { + if (val) g_initialized = true; + g_services_available = val; + } + + bool is_debug() override { + return PFC_DEBUG != 0; + } + }; +} + +static foobar2000_client_impl g_client; + +#ifdef _WIN32 +extern "C" +{ + __declspec(dllexport) foobar2000_client * _cdecl foobar2000_get_interface(foobar2000_api * p_api,HINSTANCE hIns) + { + g_hIns = hIns; + g_foobar2000_api = p_api; + + return &g_client; + } +} +#endif + +#ifdef __APPLE__ +extern "C" { + __attribute__ ((visibility ("default"))) foobar2000_client * foobar2000_get_interface(foobar2000_api * p_api, void * /*reserved*/) { + g_foobar2000_api = p_api; + return &g_client; + } +} +#endif diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/foobar2000_component_client/foobar2000_component_client.vcxproj --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/foobar2000_component_client/foobar2000_component_client.vcxproj Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,349 @@ + + + + + Debug + ARM64 + + + Debug + ARM64EC + + + Debug + Win32 + + + Debug + x64 + + + Release + ARM64 + + + Release + ARM64EC + + + Release + Win32 + + + Release + x64 + + + + {71AD2674-065B-48F5-B8B0-E1F9D3892081} + foobar2000_component_client + 10.0 + + + + StaticLibrary + false + Unicode + true + v142 + + + StaticLibrary + false + Unicode + true + v142 + + + StaticLibrary + false + Unicode + true + v143 + + + StaticLibrary + false + Unicode + true + v143 + + + StaticLibrary + false + Unicode + v142 + + + StaticLibrary + false + Unicode + v142 + + + StaticLibrary + false + Unicode + v143 + + + StaticLibrary + false + Unicode + v143 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(Configuration)\ + $(Configuration)\ + $(Configuration)\ + $(Configuration)\ + + + + Disabled + EnableFastChecks + + + Level3 + true + ProgramDatabase + MultiThreadedDebugDLL + 4715 + ..;../.. + true + stdcpp17 + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + + + + + Disabled + EnableFastChecks + + + Level3 + true + ProgramDatabase + MultiThreadedDebugDLL + 4715 + ..;../.. + true + stdcpp17 + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + + + + + Disabled + EnableFastChecks + + + Level3 + true + ProgramDatabase + MultiThreadedDebugDLL + 4715 + ..;../.. + true + stdcpp17 + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + + + + + Disabled + EnableFastChecks + + + Level3 + true + ProgramDatabase + MultiThreadedDebugDLL + 4715 + ..;../.. + true + stdcpp17 + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + + + + + MinSpace + true + false + Fast + false + Level3 + true + ProgramDatabase + MultiThreadedDLL + /d2notypeopt %(AdditionalOptions) + 4715 + true + NDEBUG;_UNICODE;UNICODE;%(PreprocessorDefinitions) + ..;../.. + true + stdcpp17 + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + + + + + MinSpace + true + false + Fast + false + Level3 + true + ProgramDatabase + MultiThreadedDLL + /d2notypeopt %(AdditionalOptions) + 4715 + true + NDEBUG;_UNICODE;UNICODE;%(PreprocessorDefinitions) + ..;../.. + true + stdcpp17 + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + + + + + MinSpace + true + false + Fast + false + Level3 + true + ProgramDatabase + MultiThreadedDLL + /d2notypeopt %(AdditionalOptions) + 4715 + true + NDEBUG;_UNICODE;UNICODE;%(PreprocessorDefinitions) + ..;../.. + true + stdcpp17 + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + + + + + MinSpace + true + false + Fast + false + Level3 + true + ProgramDatabase + MultiThreadedDLL + /d2notypeopt %(AdditionalOptions) + 4715 + true + NDEBUG;_UNICODE;UNICODE;%(PreprocessorDefinitions) + ..;../.. + true + stdcpp17 + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + + + + + Disabled + Disabled + Disabled + Disabled + EnableFastChecks + EnableFastChecks + EnableFastChecks + EnableFastChecks + MaxSpeed + MaxSpeed + MaxSpeed + MaxSpeed + + + + + + \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/foobar2000_component_client/foobar2000_component_client.xcodeproj/project.pbxproj --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/foobar2000_component_client/foobar2000_component_client.xcodeproj/project.pbxproj Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,282 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 54; + objects = { + +/* Begin PBXBuildFile section */ + 0F1FDDDC2AA0B33A00DE8967 /* component_client.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F1FDDDB2AA0B33A00DE8967 /* component_client.cpp */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 0F1FDDD42AA0B2FB00DE8967 /* libfoobar2000_component_client.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libfoobar2000_component_client.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 0F1FDDDB2AA0B33A00DE8967 /* component_client.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = component_client.cpp; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 0F1FDDD22AA0B2FB00DE8967 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 0F1FDDCB2AA0B2FB00DE8967 = { + isa = PBXGroup; + children = ( + 0F1FDDDB2AA0B33A00DE8967 /* component_client.cpp */, + 0F1FDDD52AA0B2FB00DE8967 /* Products */, + ); + sourceTree = ""; + }; + 0F1FDDD52AA0B2FB00DE8967 /* Products */ = { + isa = PBXGroup; + children = ( + 0F1FDDD42AA0B2FB00DE8967 /* libfoobar2000_component_client.a */, + ); + name = Products; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + 0F1FDDD02AA0B2FB00DE8967 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + 0F1FDDD32AA0B2FB00DE8967 /* foobar2000_component_client */ = { + isa = PBXNativeTarget; + buildConfigurationList = 0F1FDDD82AA0B2FB00DE8967 /* Build configuration list for PBXNativeTarget "foobar2000_component_client" */; + buildPhases = ( + 0F1FDDD02AA0B2FB00DE8967 /* Headers */, + 0F1FDDD12AA0B2FB00DE8967 /* Sources */, + 0F1FDDD22AA0B2FB00DE8967 /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = foobar2000_component_client; + productName = foobar2000_component_client; + productReference = 0F1FDDD42AA0B2FB00DE8967 /* libfoobar2000_component_client.a */; + productType = "com.apple.product-type.library.static"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 0F1FDDCC2AA0B2FB00DE8967 /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastUpgradeCheck = 1430; + TargetAttributes = { + 0F1FDDD32AA0B2FB00DE8967 = { + CreatedOnToolsVersion = 14.3.1; + }; + }; + }; + buildConfigurationList = 0F1FDDCF2AA0B2FB00DE8967 /* Build configuration list for PBXProject "foobar2000_component_client" */; + compatibilityVersion = "Xcode 12.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 0F1FDDCB2AA0B2FB00DE8967; + productRefGroup = 0F1FDDD52AA0B2FB00DE8967 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 0F1FDDD32AA0B2FB00DE8967 /* foobar2000_component_client */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 0F1FDDD12AA0B2FB00DE8967 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 0F1FDDDC2AA0B33A00DE8967 /* component_client.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 0F1FDDD62AA0B2FB00DE8967 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + .., + ../.., + ); + MACOSX_DEPLOYMENT_TARGET = 11.0; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + }; + name = Debug; + }; + 0F1FDDD72AA0B2FB00DE8967 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + .., + ../.., + ); + MACOSX_DEPLOYMENT_TARGET = 11.0; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = macosx; + }; + name = Release; + }; + 0F1FDDD92AA0B2FB00DE8967 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 4S876G9VCD; + EXECUTABLE_PREFIX = lib; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + }; + name = Debug; + }; + 0F1FDDDA2AA0B2FB00DE8967 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 4S876G9VCD; + EXECUTABLE_PREFIX = lib; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 0F1FDDCF2AA0B2FB00DE8967 /* Build configuration list for PBXProject "foobar2000_component_client" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 0F1FDDD62AA0B2FB00DE8967 /* Debug */, + 0F1FDDD72AA0B2FB00DE8967 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 0F1FDDD82AA0B2FB00DE8967 /* Build configuration list for PBXNativeTarget "foobar2000_component_client" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 0F1FDDD92AA0B2FB00DE8967 /* Debug */, + 0F1FDDDA2AA0B2FB00DE8967 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 0F1FDDCC2AA0B2FB00DE8967 /* Project object */; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers-mac/CFObject.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers-mac/CFObject.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,4 @@ +#pragma once +#include +using pfc::CFObject; + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers-mac/NSComboBox+fb2k.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers-mac/NSComboBox+fb2k.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,9 @@ +#import + +#import +#import + +namespace fb2k { + void comboSetupHistory(NSComboBox *, cfg_dropdown_history & var); + void comboAddToHistory(NSComboBox *, cfg_dropdown_history & var); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers-mac/NSComboBox+fb2k.mm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers-mac/NSComboBox+fb2k.mm Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,23 @@ +#import "NSComboBox+fb2k.h" + +namespace fb2k { + void comboSetupHistory(NSComboBox * box, cfg_dropdown_history & var) { + [box removeAllItems]; + pfc::string8 temp; var.get_state( temp ); + NSString * str = [NSString stringWithUTF8String: temp.c_str()]; + if ( str.length == 0 ) return; + NSArray * arr = [str componentsSeparatedByCharactersInSet: NSCharacterSet.newlineCharacterSet]; + if ( arr.count == 0 ) return; + for( NSString * str in arr ) { + if ( str.length > 0 ) [box addItemWithObjectValue: str]; + } + box.stringValue = arr.firstObject; + + [box.menu addItem: NSMenuItem.separatorItem]; + } + + void comboAddToHistory(NSComboBox * box, cfg_dropdown_history & var) { + NSString * str = box.stringValue; + if ( str.length > 0 ) var.add_item( str.UTF8String ); + } +} // namespace fb2k diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers-mac/NSEvent+ppstuff.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers-mac/NSEvent+ppstuff.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,13 @@ +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface NSEvent (ppstuff) + +@property (readonly) BOOL pp_isKeyDown; +@property (readonly) BOOL pp_isCmdKeyDown; +@property (readonly) BOOL pp_isShiftKeyDown; +@property (readonly) NSEventModifierFlags pp_modifierFlagsDI; +@end + +NS_ASSUME_NONNULL_END diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers-mac/NSEvent+ppstuff.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers-mac/NSEvent+ppstuff.m Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,17 @@ +#import "NSEvent+ppstuff.h" + +@implementation NSEvent (ppstuff) + +- (BOOL)pp_isKeyDown { + return self.type == NSEventTypeKeyDown; +} +- (BOOL)pp_isCmdKeyDown { + return self.pp_isKeyDown && self.pp_modifierFlagsDI == NSEventModifierFlagCommand; +} +- (BOOL)pp_isShiftKeyDown { + return self.pp_isKeyDown && self.pp_modifierFlagsDI == NSEventModifierFlagShift; +} +- (NSEventModifierFlags)pp_modifierFlagsDI { + return self.modifierFlags & NSEventModifierFlagDeviceIndependentFlagsMask; +} +@end diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers-mac/NSFont+pp.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers-mac/NSFont+pp.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,16 @@ +// +// NSFont+pp.h +// foobar2000 +// +// Created by Piotr Pawłowski on 30/06/2024. +// Copyright © 2024 Piotr Pawłowski. All rights reserved. +// + +#import + +@interface NSFont (pp) +// Recommended font for all text data, because default fixed-width digit behavior is horribly annoying +// PROTIP if NSTableView is ignoring font alterations, make sure row height is set explicitly +@property (class, readonly) NSFont* pp_monospacedDigitFont; +@property (class, readonly) NSFont* pp_monospacedFont; +@end diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers-mac/NSFont+pp.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers-mac/NSFont+pp.m Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,27 @@ +// +// NSFont+pp.m +// foobar2000 +// +// Created by Piotr Pawłowski on 30/06/2024. +// Copyright © 2024 Piotr Pawłowski. All rights reserved. +// + +#import "NSFont+pp.h" + +static NSFont * g_monospacedDigitFont; +static NSFont * g_monospacedFont; + +@implementation NSFont (pp) ++ (NSFont*) pp_monospacedDigitFont { + assert( NSThread.isMainThread ); + if ( g_monospacedDigitFont == nil ) g_monospacedDigitFont = [NSFont monospacedDigitSystemFontOfSize: NSFont.systemFontSize weight: NSFontWeightRegular]; + return g_monospacedDigitFont; +} ++ (NSFont*) pp_monospacedFont { + assert( NSThread.isMainThread ); + if ( g_monospacedFont == nil ) { + g_monospacedFont = [NSFont monospacedSystemFontOfSize: NSFont.systemFontSize weight: NSFontWeightRegular]; + } + return g_monospacedFont; +} +@end diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers-mac/NSMenu+ppaddons.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers-mac/NSMenu+ppaddons.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,10 @@ +#import + +@interface NSMenu (ppaddons) + +- (NSMenuItem*) pp_addItemWithTitle: (NSString*) title action: (SEL) action target: (id) target; +- (void) pp_addSeparator; +- (NSMenuItem*) pp_addSubMenu: (NSMenu*) menu withTitle: (NSString*) title; +- (void) pp_popUpForView:(NSView *)view; + +@end diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers-mac/NSMenu+ppaddons.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers-mac/NSMenu+ppaddons.m Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,39 @@ +#import "NSMenu+ppaddons.h" + +@implementation NSMenu (ppaddons) + +- (NSMenuItem*) pp_addItemWithTitle: (NSString*) title action: (SEL) action target: (id) target { + NSMenuItem * item = [[NSMenuItem alloc] initWithTitle: title action: action keyEquivalent: @""]; + item.target = target; + [self addItem: item]; + return item; +} + +- (void) pp_addSeparator { + [self addItem: [NSMenuItem separatorItem]]; +} + +- (NSMenuItem*) pp_addSubMenu: (NSMenu*) menu withTitle: (NSString*) title { + NSMenuItem * item = [[NSMenuItem alloc] init]; + item.title = title; + item.submenu = menu; + [self addItem: item]; + return item; +} + +- (void)pp_popUpForView:(NSView *)view { + BOOL pullsDown = YES; + NSMenu *popMenu = [self copy]; + NSRect frame = [view frame]; + frame.origin.x = 0.0; + frame.origin.y = 0.0; + + if (pullsDown) [popMenu insertItemWithTitle:@"" action:NULL keyEquivalent:@"" atIndex:0]; + + NSPopUpButtonCell *popUpButtonCell = [[NSPopUpButtonCell alloc] initTextCell:@"" pullsDown:pullsDown]; + [popUpButtonCell setMenu:popMenu]; + if (!pullsDown) [popUpButtonCell selectItem:nil]; + [popUpButtonCell performClickWithFrame:frame inView:view]; +} + +@end diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers-mac/NSView+embed.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers-mac/NSView+embed.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,19 @@ +#import + +#if 0 +@interface NSView (embed) +- (void) embedInView: (NSView*) superview; // uses autoresizingMask +- (void) embedInViewV2: (NSView*) superview; // adds autolayout constraints +@end +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +void NSViewEmbed( NSView * superview, NSView * childview ); +void NSViewEmbedConstraints( NSView * superview, NSView * childview ); + +#ifdef __cplusplus +} // extern "C" +#endif diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers-mac/NSView+embed.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers-mac/NSView+embed.m Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,35 @@ +#import "NSView+embed.h" + +#if 0 +@implementation NSView (embed) + +- (void)embedInView:(NSView *)superview { + NSViewEmbed( superview, self ); +} +- (void)embedInViewV2:(NSView *)superview { + NSViewEmbedConstraints( superview, self ); +} + +@end +#endif + +void NSViewEmbed( NSView * superview, NSView * childview ) { + if ( childview == nil || superview == nil ) return; + childview.autoresizingMask = NSViewHeightSizable | NSViewWidthSizable; + childview.frame = superview.bounds; + [superview addSubview: childview]; +} + +void NSViewEmbedConstraints( NSView * superview, NSView * childview ) { + if ( childview == nil || superview == nil ) return; + childview.autoresizingMask = 0; + [superview addSubview: childview]; + NSMutableArray * constraints = [NSMutableArray arrayWithCapacity: 4]; + static const NSLayoutAttribute params[4] = { NSLayoutAttributeLeft, NSLayoutAttributeRight, NSLayoutAttributeTop, NSLayoutAttributeBottom }; + for( unsigned i = 0; i < 4; ++ i) { + NSLayoutAttribute a = params[i]; + [constraints addObject: [NSLayoutConstraint constraintWithItem: childview attribute:a relatedBy:NSLayoutRelationEqual toItem:superview attribute:a multiplier:1 constant:0]]; + } + + [superview addConstraints: constraints]; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers-mac/NSView+ppsubviews.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers-mac/NSView+ppsubviews.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,24 @@ +#import + +#if 0 +@interface NSView (ppsubviews) +- (NSView*) recurFindSubViewOfClass: (Class) cls identifier: (NSString*) identifier; +- (NSView*) findSubViewOfClass: (Class) cls identifier: (NSString*) identifier; +- (NSView*) findSubViewOfClass: (Class) cls; +- (NSButton*) findButton; +- (NSTextView*) findTextView; +- (NSTextField*) findTextField; +- (NSImageView*) findImageView; +@end +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +__kindof NSView * NSViewFindSubView( NSView * parent, Class clsOrNull, NSUserInterfaceItemIdentifier idOrNull ); +__kindof NSView * NSViewFindSubViewRecursive( NSView * parent, Class clsOrNull, NSUserInterfaceItemIdentifier idOrNull ); + +#ifdef __cplusplus +} // extern "C" +#endif diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers-mac/NSView+ppsubviews.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers-mac/NSView+ppsubviews.m Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,59 @@ +#import "NSView+ppsubviews.h" + +#if 0 +@implementation NSView (ppsubviews) + +- (NSView*) recurFindSubViewOfClass: (Class) cls identifier: (NSString*) identifier { + return NSViewFindSubViewRecursive ( self, cls, identifier ); +} + +- (NSView*) findSubViewOfClass: (Class) cls identifier: (NSString*) identifier { + return NSViewFindSubView( self, cls, identifier ); +} +- (NSView *)findSubViewOfClass:(Class)cls { + return NSViewFindSubView( self, cls, nil ); +} +- (NSButton *)findButton { + return (NSButton*) [self findSubViewOfClass: [NSButton class]]; +} +- (NSTextView *)findTextView { + return (NSTextView*) [self findSubViewOfClass: [NSTextView class]]; +} +- (NSTextField *) findTextField { + return (NSTextField*) [self findSubViewOfClass: [NSTextField class]]; +} +- (NSImageView*) findImageView { + return (NSImageView*) [self findSubViewOfClass: [NSImageView class]]; +} +@end +#endif + +__kindof NSView * NSViewFindSubView( NSView * parent, Class cls, NSUserInterfaceItemIdentifier identifier ) { + for (__kindof NSView * v in parent.subviews) { + if ( (cls == nil || [v isKindOfClass: cls]) && ( identifier == nil || [ v.identifier isEqualToString: identifier ] ) ) { + return v; + } + } + return nil; +} + +__kindof NSView * NSViewFindSubViewRecursive( NSView * parent, Class cls, NSUserInterfaceItemIdentifier identifier ) { + @autoreleasepool { + NSMutableArray<__kindof NSView*> * arrAll = [NSMutableArray arrayWithArray: parent.subviews]; + + for ( NSUInteger w = 0; w < arrAll.count; ++ w ) { + __kindof NSView * thisView = arrAll[w]; + + if ( (cls == nil || [thisView isKindOfClass: cls]) && ( identifier == nil || [thisView.identifier isEqualToString: identifier] ) ) { + return thisView; + } + [arrAll addObjectsFromArray: thisView.subviews]; + + if ( w >= 200 ) { + [arrAll removeObjectsInRange: NSMakeRange(0, w) ]; + w = 0; + } + } + return nil; + } +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers-mac/fb2k-platform.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers-mac/fb2k-platform.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,43 @@ +#pragma once + +#import +#import + +namespace fb2k { + // May return null on bad input. + NSString * strToPlatform( const char * ); + // May return null on bad input. + NSString * strToPlatform( const char * , size_t ); + // May return null on bad input. + NSString * strToPlatform( stringRef ); + // Never returns null - returns passed string in case of failure + NSString * strToPlatform( const char *, NSString * returnIfError ); + + stringRef strFromPlatform( NSString * ); + + + stringRef urlFromPlatform( id url /* can be NSString or NSURL */ ); + NSURL * urlToPlatform(const char * arg); + + + typedef NSImage* platformImage_t; + platformImage_t imageToPlatform( fb2k::objRef ); + + + // These two functions do the same, openWebBrowser() was added for compatiblity with fb2k mobile + void openWebBrowser(const char * URL); + void openURL( const char * URL); + + NSFont * fontFromParams(NSDictionary *, NSFont * base = nil); + BOOL testFontParams(NSDictionary *); + CGFloat tableViewRowHeightForFont( NSFont * ); + void tableViewPrepareForFont( NSTableView * tableView, NSFont * font ); + +} + +namespace pfc { + string8 strFromPlatform(NSString*); + NSString * strToPlatform( const char * ); + NSString * strToPlatform(string8 const&); + string8 strFromPlatform(CFStringRef); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers-mac/fb2k-platform.mm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers-mac/fb2k-platform.mm Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,118 @@ +#include "fb2k-platform.h" +#include "NSFont+pp.h" + +namespace fb2k { + NSString * strToPlatform( const char * s, size_t len ) { + pfc::string8 temp( s, len ); + return strToPlatform( temp ); + } + NSString * strToPlatform( const char * arg, NSString * returnIfError ) { + if ( arg ) @try { + NSString * ret = [NSString stringWithUTF8String: arg]; + if ( ret ) return ret; + } @catch(NSException *) {} + return returnIfError; + } + NSString * strToPlatform( const char * s ) { + return [NSString stringWithUTF8String: s]; + } + NSString * strToPlatform( stringRef s ) { + if ( s.is_empty( ) ) return nil; + return strToPlatform( s->c_str() ); + } + stringRef strFromPlatform( NSString * s ) { + return makeString( s.UTF8String ); + } + + stringRef urlFromPlatform( id obj ) { + if ( [obj isKindOfClass: [NSURL class] ] ) { + NSURL * URL = obj; + obj = URL.absoluteString; + if ([obj hasPrefix:@"file://"]) + obj = URL.path; + } + if ( [obj respondsToSelector: @selector(UTF8String)]) { + pfc::string8 temp; + filesystem::g_get_canonical_path( [obj UTF8String], temp ); + return makeString( temp ); + } + return nullptr; + } + + NSURL * urlToPlatform(const char * arg) { + pfc::string8 native; + if (filesystem::g_get_native_path(arg, native)) { + return [NSURL fileURLWithPath: [NSString stringWithUTF8String: native ] ]; + } + return [NSURL URLWithString: [NSString stringWithUTF8String: arg]]; + } + + void openURL( const char * URL ) { + @autoreleasepool { + [[NSWorkspace sharedWorkspace] openURL: [NSURL URLWithString: [NSString stringWithUTF8String: URL]]]; + } + } + void openWebBrowser( const char * URL) { + openURL(URL); + } + + NSImage * imageToPlatform( fb2k::objRef obj ) { + fb2k::image::ptr img; + if ( img &= obj ) { + return (__bridge NSImage *) img->getNative(); + } + return nil; + } + BOOL testFontParams(NSDictionary * arg) { + return arg[@"font-name"] || arg[@"font-size"]; + } + NSFont * fontFromParams(NSDictionary * arg, NSFont * base) { + NSString * fontName = arg[@"font-name"]; + NSString * fontSize = arg[@"font-size"]; + NSFont * font = nil; + if ( fontName && fontSize ) { + font = [NSFont fontWithName: fontName size: fontSize.floatValue]; + } else if ( fontName ) { + font = [NSFont fontWithName: fontName size: base ? base.pointSize : NSFont.systemFontSize]; + } else if ( fontSize ) { + if ( base ) { + font = [ base fontWithSize: fontSize.floatValue ]; + } else { + font = [NSFont monospacedDigitSystemFontOfSize: fontSize.floatValue weight: NSFontWeightRegular]; + } + } + if ( font ) return font; + if ( base ) return base; + // Reuse shared font object + return [NSFont pp_monospacedDigitFont]; + } + void tableViewPrepareForFont( NSTableView * tableView, NSFont * font ) { + + // Must use NSTableViewRowSizeStyleCustom + // Other options either discard our font or break down with multiple cell templates used (autolayout) + // Height is fixed anyway, better precalculate it + assert( tableView.rowSizeStyle == NSTableViewRowSizeStyleCustom ); + + tableView.rowHeight = tableViewRowHeightForFont(font); + } + CGFloat tableViewRowHeightForFont( NSFont * f ) { + return (CGFloat) round( f.pointSize * 1.5 ); + } +} + +namespace pfc { + string8 strFromPlatform(NSString* str) { + string8 ret; + if ( str ) ret = str.UTF8String; + return ret; + } + NSString * strToPlatform( const char * str) { + return fb2k::strToPlatform( str ); + } + NSString * strToPlatform(string8 const& str) { + return fb2k::strToPlatform( str.c_str() ); + } + string8 strFromPlatform(CFStringRef str) { + return strFromPlatform( (__bridge NSString*) str ); + } +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers-mac/fooDecibelFormatter.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers-mac/fooDecibelFormatter.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,12 @@ +#import + +#import "foobar2000-mac-helpers.h" + +#define fooDecibelFormatter FB2K_OBJC_CLASS(fooDecibelFormatter) + +@interface fooDecibelFormatter : NSFormatter + +@property (nonatomic) NSNumber * minValue; +@property (nonatomic) NSNumber * maxValue; +@property (nonatomic) BOOL showSignAlways; +@end diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers-mac/fooDecibelFormatter.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers-mac/fooDecibelFormatter.m Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,58 @@ +#import "fooDecibelFormatter.h" + +@implementation fooDecibelFormatter + +- (NSString*) formatNumber: (id) obj { + + double v = [ obj doubleValue ]; + + if ( self.showSignAlways ) { + if (v == 0) return [NSString stringWithUTF8String: "\xc2\xb1" "0"]; + if ( v > 0 ) { + if (v == (double) (int) v) return [NSString stringWithFormat: @"+%i", (int)v]; + else return [NSString stringWithFormat: @"+%.02f", v]; + } + } + + if (v == (double) (int) v) return [NSString stringWithFormat: @"%i", (int)v]; + else return [NSString stringWithFormat: @"%.02f", v]; +} + +- (NSString *)stringForObjectValue:(id)obj { + return [NSString stringWithFormat: @"%@ dB", [self formatNumber: obj]]; +} + +- (NSAttributedString *)attributedStringForObjectValue:(id)obj withDefaultAttributes:(NSDictionary *)attrs { + return nil; +} + +- (NSString *)editingStringForObjectValue:(id)obj { + return [self stringForObjectValue: obj]; + // return [self formatNumber: obj]; +} + +- (BOOL)getObjectValue:(out __autoreleasing id *)obj forString:(NSString *)string errorDescription:(out NSString *__autoreleasing *)error { + if (error) *error = nil; + + { + NSMutableCharacterSet * trimMe = [NSMutableCharacterSet whitespaceAndNewlineCharacterSet]; + [trimMe addCharactersInString: [NSString stringWithUTF8String: "+\xc2\xb1" ]]; + string = [ string.lowercaseString stringByTrimmingCharactersInSet: trimMe ]; + } + + if ( [string hasSuffix: @"db"]) { + string = [ [string substringToIndex: string.length-2] stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceCharacterSet] ]; + } + + double v = string.doubleValue; + if (self.minValue) { + if (v < self.minValue.doubleValue) v = self.minValue.doubleValue; + } + if (self.maxValue) { + if (v > self.maxValue.doubleValue) v = self.maxValue.doubleValue; + } + *obj = [NSNumber numberWithDouble: v]; + return YES; +} + +@end diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers-mac/fooPreferencesCommon.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers-mac/fooPreferencesCommon.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,12 @@ +#import +#import + +typedef NSViewController fooPreferencesCommon; + +template +class preferences_mac_common : public preferences_page_v4 { +public: + service_ptr instantiate() override { + return fb2k::wrapNSObject( [obj_t new] ); + } +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers-mac/fooTimeFormatter.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers-mac/fooTimeFormatter.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,15 @@ +// +// fooTimeFormatter.h +// foo_abx +// +// Created by P on 06/09/2023. +// + +#import +#import "foobar2000-mac-helpers.h" + +#define fooTimeFormatter FB2K_OBJC_CLASS(fooTimeFormatter) + +@interface fooTimeFormatter : NSFormatter +@property (nonatomic) NSNumber * digits; +@end diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers-mac/fooTimeFormatter.mm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers-mac/fooTimeFormatter.mm Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,37 @@ +// +// fooTimeFormatter.m +// foo_abx +// +// Created by P on 06/09/2023. +// + +#import "stdafx.h" +#import "fooTimeFormatter.h" + +@implementation fooTimeFormatter + +- (NSString *)stringForObjectValue:(id)obj { + double v = 0; + if ( [obj respondsToSelector: @selector(doubleValue)]) v = [obj doubleValue]; + else if ( [obj respondsToSelector: @selector(longValue)]) v = [obj longValue]; + else if ( [obj respondsToSelector: @selector(intValue)]) v = [obj intValue]; + + unsigned digits = 3; + if ( _digits ) digits = _digits.unsignedIntValue; + return [NSString stringWithUTF8String: pfc::format_time_ex(v, digits)]; +} + +- (NSString *)editingStringForObjectValue:(id)obj { + return [self stringForObjectValue: obj]; +} +- (BOOL)getObjectValue:(out id _Nullable __autoreleasing *)obj forString:(NSString *)string errorDescription:(out NSString * _Nullable __autoreleasing *)error { + if ( string == nil ) return NO; + try { + double v = pfc::parse_timecode( string.UTF8String ); + *obj = [NSNumber numberWithDouble: v]; + return YES; + } catch(...) { + return NO; + } +} +@end diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers-mac/fooWindowWithCancel.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers-mac/fooWindowWithCancel.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,8 @@ +#import +#import "foobar2000-mac-helpers.h" + +#define fooWindowWithCancel FB2K_OBJC_CLASS(fooWindowWithCancel) + +@interface fooWindowWithCancel : NSWindow + +@end diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers-mac/fooWindowWithCancel.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers-mac/fooWindowWithCancel.m Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,10 @@ +#import "fooWindowWithCancel.h" + +@implementation fooWindowWithCancel +- (void) cancelOperation: (id) sender { + id d = self.delegate; + if ( [d respondsToSelector: @selector(cancelOperation:)]) { + [d cancelOperation: sender]; + } +} +@end diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers-mac/foobar2000-mac-helpers.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers-mac/foobar2000-mac-helpers.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,16 @@ +#pragma once + +// Mitigation for Objective-C class name clashes +// Your component must have its own foobar2000-mac-class-suffix.h, with a single line: +// #define FOOBAR2000_MAC_CLASS_SUFFIX _foo_mycomponentname +// This suffixes all common class names with _foo_mycomponentname preventing clashes + +#include "foobar2000-mac-class-suffix.h" + +#ifndef FOOBAR2000_MAC_CLASS_SUFFIX +#error PLEASE DECLARE FOOBAR2000_MAC_CLASS_SUFFIX PROPERLY +#endif + +#define FB2K_OBJC_CLASS(X) _FB2K_OBJC_CONCAT(X, FOOBAR2000_MAC_CLASS_SUFFIX) +#define _FB2K_OBJC_CONCAT(a, b) _FB2K_OBJC_CONCAT_INNER(a, b) +#define _FB2K_OBJC_CONCAT_INNER(a, b) a ## b diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/AutoComplete.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/AutoComplete.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,49 @@ +#include "stdafx.h" +#include "AutoComplete.h" +#include // CLSID_AutoComplete +#include "../helpers/COM_utils.h" +#include "../helpers/dropdown_helper.h" +#include + +using PP::CEnumString; + +namespace { + class CACList_History : public CEnumString { + public: + CACList_History(cfg_dropdown_history_mt * var) : m_var(var) { Reset(); } + typedef ImplementCOMRefCounter TImpl; + + HRESULT STDMETHODCALLTYPE Reset() { + /*if (core_api::assert_main_thread())*/ { + ResetStrings(); + pfc::string8 state; m_var->get_state(state); + for (const char * walk = state;;) { + const char * next = strchr(walk, cfg_dropdown_history_mt::separator); + t_size len = (next != NULL) ? next - walk : ~0; + AddStringU(walk, len); + if (next == NULL) break; + walk = next + 1; + } + } + return __super::Reset(); + } + + HRESULT STDMETHODCALLTYPE Clone(IEnumString **ppenum) { + *ppenum = new TImpl(*this); return S_OK; + } + + private: + cfg_dropdown_history_mt * const m_var; + }; +} + +HRESULT InitializeDropdownAC(HWND comboBox, cfg_dropdown_history_mt & var, const char * initVal) { + var.on_init(comboBox, initVal); + COMBOBOXINFO ci = {}; ci.cbSize = sizeof(ci); + if (!GetComboBoxInfo(comboBox, &ci)) { + PFC_ASSERT(!"Should not get here - GetComboBoxInfo fail!"); + return E_FAIL; + } + pfc::com_ptr_t acl = new CACList_History::TImpl(&var); + return InitializeSimpleAC(ci.hwndItem, acl.get_ptr(), ACO_AUTOAPPEND|ACO_AUTOSUGGEST); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/AutoComplete.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/AutoComplete.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,7 @@ +#pragma once + +#include + +#include "dropdown_helper.h" + +HRESULT InitializeDropdownAC(HWND comboBox, cfg_dropdown_history_mt & var, const char * initVal); diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/BumpableElem.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/BumpableElem.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,72 @@ +#pragma once + +#include +#include "atl-misc.h" + +#include + +template +class ImplementBumpableElem : public TClass { +private: + typedef ImplementBumpableElem TSelf; +public: + template ImplementBumpableElem( arg_t && ... arg ) : TClass(std::forward(arg) ... ) {_init(); } + + BEGIN_MSG_MAP_EX(ImplementBumpableElem) + MSG_WM_DESTROY(OnDestroy) + CHAIN_MSG_MAP(__super) + END_MSG_MAP_HOOK() + + void notify(const GUID & p_what, t_size p_param1, const void * p_param2, t_size p_param2size) override { + if (p_what == ui_element_notify_visibility_changed && p_param1 == 0 && m_flash.m_hWnd != NULL) m_flash.Deactivate(); + __super::notify(p_what, p_param1, p_param2, p_param2size); + } + + static bool Bump() { + for (auto& walk : instances) { + if (walk->_bump()) return true; + } + return false; + } + ~ImplementBumpableElem() throw() { + PFC_ASSERT(core_api::is_main_thread()); + instances -= this; + } +private: + void OnDestroy() throw() { + m_selfDestruct = true; + m_flash.CleanUp(); + SetMsgHandled(FALSE); + } + bool _bump() { + if (m_selfDestruct || this->m_hWnd == NULL) return false; + //PROBLEM: This assumes we're implementing service_base methods at this point. Explodes if called during constructors/destructors. + if (!this->m_callback->request_activation(this)) return false; + m_flash.Activate(*this); + this->set_default_focus(); + return true; + } + void _init() { + PFC_ASSERT(core_api::is_main_thread()); + instances += this; + } + static pfc::avltree_t instances; + bool m_selfDestruct = false; + CFlashWindow m_flash; +}; + +template +pfc::avltree_t *> ImplementBumpableElem::instances; + + +template class ui_element_impl_withpopup : public ui_element_impl, TInterface> { +public: + t_uint32 get_flags() {return ui_element_v2::KFlagHavePopupCommand | ui_element_v2::KFlagSupportsBump;} + bool bump() {return ImplementBumpableElem::Bump();} +}; + +template class ui_element_impl_visualisation : public ui_element_impl, TInterface> { +public: + t_uint32 get_flags() {return ui_element_v2::KFlagsVisualisation | ui_element_v2::KFlagSupportsBump;} + bool bump() {return ImplementBumpableElem::Bump();} +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/CDialogResizeHelper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/CDialogResizeHelper.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,24 @@ +#pragma once + +#include "WindowPositionUtils.h" + +#include + +template class CDialogResizeHelperTracking : public CDialogResizeHelper { +public: + template CDialogResizeHelperTracking(const TParam (& src)[paramCount],CRect const& minMaxRange, TCfgVar & cfgVar) : CDialogResizeHelper(src, minMaxRange), m_tracker(cfgVar) {} + + BEGIN_MSG_MAP_EX(CDialogResizeHelperST) + CHAIN_MSG_MAP(CDialogResizeHelper) + CHAIN_MSG_MAP_MEMBER(m_tracker) + END_MSG_MAP() + +private: + TTracker m_tracker; +}; + +typedef CDialogResizeHelperTracking CDialogResizeHelperST; +typedef CDialogResizeHelperTracking CDialogResizeHelperPT; +typedef CDialogResizeHelperTracking CDialogResizeHelperST2; + +#define REDRAW_DIALOG_ON_RESIZE() if (uMsg == WM_SIZE) RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_ALLCHILDREN); diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/CListControlFb2kColors.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/CListControlFb2kColors.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,45 @@ +#pragma once + +// foobar2000 v2.0+ only +#if FOOBAR2000_TARGET_VERSION >= 81 + +// One-line fix for UI colors in CListControl, use CListControlFb2kColors< myCListControSubClass > to use fb2k colors +template +class CListControlFb2kColors : public parent_t, protected ui_config_callback_impl { +public: + template + CListControlFb2kColors(arg_t && ... args) : parent_t(std::forward(args) ... ) { + this->SetDarkMode(m_uiConfig->is_dark_mode()); + } +protected: + void ui_colors_changed() override { + this->SetDarkMode(m_uiConfig->is_dark_mode()); + this->Invalidate(); + } + COLORREF GetSysColorHook(int colorIndex) const override { + return m_uiConfig->getSysColor(colorIndex); + } + const ui_config_manager::ptr m_uiConfig = ui_config_manager::get(); +}; + +#endif + +// For use in UI elements +// Not completely selfcontained, host must pass ui_element_instance_callback and call ui_colors_changed() +template +class CListControlFb2kColorsUIElem : public parent_t { +public: + template + CListControlFb2kColorsUIElem(ui_element_instance_callback::ptr callback, arg_t && ... args) : parent_t(std::forward(args) ...), m_callback(callback) { + this->SetDarkMode(m_callback->is_dark_mode()); + } + void ui_colors_changed() { // host must call this in response to notify() + this->SetDarkMode(m_callback->is_dark_mode()); + this->Invalidate(); + } +protected: + COLORREF GetSysColorHook(int colorIndex) const override { + return m_callback->getSysColor(colorIndex); + } + const ui_element_instance_callback_ptr m_callback; +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/CModelessDialogMessages.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/CModelessDialogMessages.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,17 @@ +#pragma once +#include + +class CModelessDialogMessages { +public: + static BOOL ProcessWindowMessage(HWND hWnd, UINT uMsg, WPARAM, LPARAM, LRESULT&) { + switch (uMsg) { + case WM_INITDIALOG: + modeless_dialog_manager::g_add(hWnd); break; + case WM_DESTROY: + modeless_dialog_manager::g_remove(hWnd); break; + } + return FALSE; + } +}; + +#define FB2K_MODELESS_DIALOG_MESSAGES() CHAIN_MSG_MAP(CModelessDialogMessages) diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/COM_utils.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/COM_utils.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,6 @@ +#pragma once + + +#include + +#define FB2K_COM_CATCH PP_COM_CATCH diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/CPropVariant.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/CPropVariant.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,3 @@ +#pragma once + +#include \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/CSingleThreadWrapper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/CSingleThreadWrapper.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,91 @@ +#pragma once + +#include "ThreadUtils.h" +#include "rethrow.h" + +namespace ThreadUtils { + + // OLD single thread wrapper class used only by old WMA input + // Modern code should use cmdThread which is all kinds of prettier + template + class CSingleThreadWrapper : protected CVerySimpleThread { + private: + protected: + class command { + protected: + command() : m_abort(), m_completionEvent() {} + virtual void executeImpl(TBase &) {} + virtual ~command() {} + public: + void execute(TBase & obj) { + m_rethrow.exec( [this, &obj] {executeImpl(obj); } ); + SetEvent(m_completionEvent); + } + void rethrow() const { + m_rethrow.rethrow(); + } + CRethrow m_rethrow; + HANDLE m_completionEvent; + abort_callback * m_abort; + }; + + typedef std::function func_t; + + class command2 : public command { + public: + command2( func_t f ) : m_func(f) {} + void executeImpl(TBase & obj) { + m_func(obj); + } + private: + + func_t m_func; + }; + + typedef pfc::rcptr_t command_ptr; + + CSingleThreadWrapper() { + m_completionEvent.create(true,false); + this->StartThread(); + //start(); + } + + ~CSingleThreadWrapper() { + m_threadAbort.abort(); + this->WaitTillThreadDone(); + } + + void invokeCommand2( func_t f, abort_callback & abort) { + auto c = pfc::rcnew_t(f); + invokeCommand( c, abort ); + } + void invokeCommand(command_ptr cmd, abort_callback & abort) { + abort.check(); + m_completionEvent.set_state(false); + pfc::vartoggle_t abortToggle(cmd->m_abort, &abort); + pfc::vartoggle_t eventToggle(cmd->m_completionEvent, m_completionEvent.get() ); + m_commands.Add(cmd); + m_completionEvent.wait_for(-1); + //WaitAbortable(m_completionEvent.get(), abort); + cmd->rethrow(); + } + + private: + void ThreadProc() { + TRACK_CALL_TEXT("CSingleThreadWrapper entry"); + try { + TBase instance; + for(;;) { + command_ptr cmd; + if (processMsgs) m_commands.Get_MsgLoop(cmd, m_threadAbort); + else m_commands.Get(cmd, m_threadAbort); + cmd->execute(instance); + } + } catch(...) {} + if (processMsgs) ProcessPendingMessages(); + } + win32_event m_completionEvent; + CObjectQueue m_commands; + abort_callback_impl m_threadAbort; + }; +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/CTableEditHelper-Legacy.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/CTableEditHelper-Legacy.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,80 @@ +#include "StdAfx.h" +#include "CTableEditHelper-Legacy.h" +#include + +namespace InPlaceEdit { + void CTableEditHelper::TableEdit_Start(HWND p_listview, unsigned p_item, unsigned p_column, unsigned p_itemcount, unsigned p_columncount, unsigned p_basecolumn, unsigned p_flags) { + if (m_notify.is_valid() || p_columncount == 0 || p_itemcount == 0 || p_item >= p_itemcount || p_column >= p_columncount) return; + m_listview = p_listview; + m_item = p_item; + m_column = p_column; + m_itemcount = p_itemcount; + m_columncount = p_columncount; + m_basecolumn = p_basecolumn; + m_flags = p_flags; + _Start(); + } + + void CTableEditHelper::TableEdit_Abort(bool p_forwardcontent) { + if (m_notify.is_valid()) { + m_notify->orphan(); + m_notify.release(); + + if (p_forwardcontent && (m_flags & KFlagReadOnly) == 0) { + if (m_content.is_valid()) { + pfc::string8 temp(*m_content); + m_content.release(); + TableEdit_SetItemText(m_item, m_column, temp); + } + } else { + m_content.release(); + } + SetFocus(NULL); + TableEdit_Finished(); + } + } + + bool CTableEditHelper::TableEdit_GetItemText(unsigned p_item, unsigned p_column, pfc::string_base & p_out, unsigned & p_linecount) { + listview_helper::get_item_text(m_listview, p_item, p_column + m_basecolumn, p_out); + p_linecount = pfc::is_multiline(p_out) ? 5 : 1; + return true; + } + void CTableEditHelper::TableEdit_SetItemText(unsigned p_item, unsigned p_column, const char * p_text) { + listview_helper::set_item_text(m_listview, p_item, p_column + m_basecolumn, p_text); + } + + void CTableEditHelper::on_task_completion(unsigned p_taskid, unsigned p_state) { + if (p_taskid == KTaskID) { + m_notify.release(); + if (m_content.is_valid()) { + if (p_state & InPlaceEdit::KEditFlagContentChanged) { + TableEdit_SetItemText(m_item, m_column, *m_content); + } + m_content.release(); + } + /*if (InPlaceEdit::TableEditAdvance(m_item,m_column,m_itemcount,m_columncount,p_state))*/ + if (TableEdit_OnEditCompleted(m_item, m_column, p_state) && + InPlaceEdit::TableEditAdvance_ListView(m_listview, m_basecolumn, m_item, m_column, m_itemcount, m_columncount, p_state)) { + _Start(); + } else { + TableEdit_Finished(); + } + } + } + + CTableEditHelper::~CTableEditHelper() { + if (m_notify.is_valid()) { + m_notify->orphan(); + m_notify.release(); + } + } + + void CTableEditHelper::_Start() { + listview_helper::select_single_item(m_listview, m_item); + m_content.new_t(); + unsigned linecount = 1; + if (!TableEdit_GetItemText(m_item, m_column, *m_content, linecount)) return; + m_notify = completion_notify_create(this, KTaskID); + InPlaceEdit::Start_FromListViewEx(m_listview, m_item, m_column + m_basecolumn, linecount, m_flags, m_content, m_notify); + } +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/CTableEditHelper-Legacy.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/CTableEditHelper-Legacy.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,35 @@ +#pragma once +#include "inplace_edit.h" +#include + +namespace InPlaceEdit { + class CTableEditHelper { + public: + void TableEdit_Start(HWND p_listview, unsigned p_item, unsigned p_column, unsigned p_itemcount, unsigned p_columncount, unsigned p_basecolumn, unsigned p_flags = 0); + void TableEdit_Abort(bool p_forwardcontent); + bool TableEdit_IsActive() const {return m_notify.is_valid();} + + virtual bool TableEdit_GetItemText(unsigned p_item, unsigned p_column, pfc::string_base & p_out, unsigned & p_linecount); + virtual void TableEdit_SetItemText(unsigned p_item, unsigned p_column, const char * p_text); + + virtual void TableEdit_Finished() {} + + void on_task_completion(unsigned p_taskid, unsigned p_state); + ~CTableEditHelper(); + protected: + HWND TableEdit_GetListView() const { return m_listview; } + //return false to abort + virtual bool TableEdit_OnEditCompleted(unsigned item, unsigned column, unsigned state) { return true; } + private: + void _Start(); + enum { + KTaskID = 0xc0ffee + }; + HWND m_listview; + unsigned m_item, m_column; + unsigned m_itemcount, m_columncount, m_basecolumn; + unsigned m_flags; + pfc::rcptr_t m_content; + service_ptr_t m_notify; + }; +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/CallForwarder.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/CallForwarder.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,60 @@ +#pragma once +#include "callInMainThreadHelper.h" +namespace CF { + template class _inMainThread : public main_thread_callback { + public: + _inMainThread(obj_t const & obj, const arg_t & arg) : m_obj(obj), m_arg(arg) {} + + void callback_run() { + if (m_obj.IsValid()) callInMainThread::callThis(&*m_obj, m_arg); + } + private: + obj_t m_obj; + arg_t m_arg; + }; + + template class CallForwarder { + private: + CallForwarder() = delete; + protected: + CallForwarder(TWhat * ptr) : m_ptr(pfc::rcnew_t(ptr)) {} + void Orphan() { + *m_ptr = NULL; + } + public: + bool IsValid() const { + PFC_ASSERT( m_ptr.is_valid() ); + return m_ptr.is_valid() && *m_ptr != NULL; + } + bool IsEmpty() const { return !IsValid(); } + + TWhat * operator->() const { + PFC_ASSERT( IsValid() ); + return *m_ptr; + } + + TWhat & operator*() const { + PFC_ASSERT( IsValid() ); + return **m_ptr; + } + + template + void callInMainThread(const arg_t & arg) { + main_thread_callback_add( new service_impl_t<_inMainThread< CallForwarder, arg_t> >(*this, arg) ); + } + private: + const pfc::rcptr_t m_ptr; + }; + + template class CallForwarderMaster : public CallForwarder { + public: + CallForwarderMaster(TWhat * ptr) : CallForwarder(ptr) {PFC_ASSERT(ptr!=NULL);} + ~CallForwarderMaster() { this->Orphan(); } + using CallForwarder::Orphan; + private: + CallForwarderMaster() = delete; + CallForwarderMaster( const CallForwarderMaster & ) = delete; + void operator=( const CallForwarderMaster & ) = delete; + }; + +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/CmdThread.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/CmdThread.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,136 @@ +#pragma once +#include +#include +#include +#include +#include "rethrow.h" +#include + +namespace ThreadUtils { + + typedef std::function waitFunc_t; + + // Serialize access to some resource to a single thread + // Execute blocking/nonabortable methods in with proper abortability (detach on abort and move on) + class cmdThread { + public: + typedef std::function func_t; + typedef pfc::waitQueue queue_t; + typedef std::function funcAbortable_t; + + protected: + std::function makeWorker(waitFunc_t wf = pfc::event::g_wait_for) { + auto q = m_queue; + auto x = m_atExit; + return [q, x, wf] { + for ( ;; ) { + func_t f; + wf(q->get_event_handle(), -1); + if (!q->get(f)) break; + try { f(); } catch(...) {} + } + // No guard for atExit access, as nobody is supposed to be still able to call host object methods by the time we get here + for( auto i = x->begin(); i != x->end(); ++ i ) { + auto f = *i; + try { f(); } catch(...) {} + } + }; + }; + std::function makeWorker2( std::function updater, double interval, waitFunc_t wf = pfc::event::g_wait_for) { + auto q = m_queue; + auto x = m_atExit; + return [=] { + pfc::lores_timer t; t.start(); + for ( ;; ) { + { + bool bWorkReady = false; + double left = interval - t.query(); + if ( left > 0 ) { + if (wf(q->get_event_handle(), left)) bWorkReady = true; + } + + if (!bWorkReady) { + updater(); + t.start(); + continue; + } + } + + func_t f; + wf(q->get_event_handle(), -1); + if (!q->get(f)) break; + try { f(); } catch(...) {} + } + // No guard for atExit access, as nobody is supposed to be still able to call host object methods by the time we get here + for( auto i = x->begin(); i != x->end(); ++ i ) { + auto f = *i; + try { f(); } catch(...) {} + } + }; + }; + + // For derived classes: create new instance without starting thread, supply thread using by yourself + class noCreate {}; + cmdThread( noCreate ) {} + public: + + cmdThread() { + pfc::splitThread( makeWorker() ); + } + + void atExit( func_t f ) { + m_atExit->push_back(f); + } + ~cmdThread() { + m_queue->set_eof(); + } + void runSynchronously( func_t f ) { runSynchronously_(f, nullptr); } + void runSynchronously_( func_t f, abort_callback * abortOrNull ) { + auto evt = m_eventPool.make(); + evt->set_state(false); + auto rethrow = std::make_shared(); + auto worker2 = [f, rethrow, evt] { + rethrow->exec(f); + evt->set_state( true ); + }; + + add ( worker2 ); + + if ( abortOrNull != nullptr ) { + abortOrNull->waitForEvent( * evt, -1 ); + } else { + evt->wait_for(-1); + } + + m_eventPool.put( evt ); + + rethrow->rethrow(); + } + void runSynchronously( func_t f, abort_callback & abort ) { + runSynchronously_(f, &abort); + } + void runSynchronously2( funcAbortable_t f, abort_callback & abort ) { + auto subAbort = m_abortPool.make(); + subAbort->reset(); + auto worker = [subAbort, f] { + f(*subAbort); + }; + + try { + runSynchronously( worker, abort ); + } catch(...) { + subAbort->set(); throw; + } + + m_abortPool.put( subAbort ); + } + + void add( func_t f ) { m_queue->put( f ); } + private: + pfc::objPool m_eventPool; + pfc::objPool m_abortPool; + std::shared_ptr m_queue = std::make_shared(); + typedef std::list atExit_t; + std::shared_ptr m_atExit = std::make_shared< atExit_t >(); + }; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/DarkMode.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/DarkMode.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,8 @@ +#include "StdAfx.h" +#include "DarkMode.h" + +bool fb2k::isDarkMode() { + auto api = ui_config_manager::tryGet(); + if (api.is_valid()) return api->is_dark_mode(); + else return false; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/DarkMode.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/DarkMode.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,34 @@ +#pragma once + +#ifdef _WIN32 + +#include +#include + +// fb2k::CDarkModeHooks +// foobar2000 specific helper on top of libPPUI DarkMode::CHooks +// Automatically determines whether dark mode should be on or off +// Keeps track of dark mode preference changes at runtime +// Does nothing if used in foobar2000 older than 2.0 + +// IMPORTANT +// See also: SDK/coreDarkMode.h +// Using CCoreDarkMode lets you invoke foobar2000's instance of this code instead of static linking it, resulting in much smaller component binary. +// Using CDarkModeHooks directly is good mainly for debugging or troubleshooting. + +namespace fb2k { + bool isDarkMode(); + +#ifndef CDarkModeHooks + class CDarkModeHooks : public DarkMode::CHooks, private ui_config_callback_impl { + public: + CDarkModeHooks() : CHooks(isDarkMode()) {} + + private: + void ui_fonts_changed() override {} + void ui_colors_changed() override { this->SetDark(isDarkMode()); } + }; +#endif +} + +#endif diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/ProcessUtils.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/ProcessUtils.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,279 @@ +#pragma once + +#ifdef FOOBAR2000_DESKTOP_WINDOWS + +#include + +namespace ProcessUtils { + class PipeIO : public stream_reader, public stream_writer { + public: + PFC_DECLARE_EXCEPTION(timeout, exception_io, "Timeout"); + PipeIO(HANDLE handle, HANDLE hEvent, bool processMessages, DWORD timeOut = INFINITE) : m_handle(handle), m_event(hEvent), m_processMessages(processMessages), m_timeOut(timeOut) { + } + ~PipeIO() { + } + + void write(const void * p_buffer,size_t p_bytes, abort_callback & abort) { + if (p_bytes == 0) return; + OVERLAPPED ol = {}; + ol.hEvent = m_event; + ResetEvent(m_event); + DWORD bytesWritten; + SetLastError(NO_ERROR); + if (WriteFile( m_handle, p_buffer, pfc::downcast_guarded(p_bytes), &bytesWritten, &ol)) { + // succeeded already? + if (bytesWritten != p_bytes) throw exception_io(); + return; + } + + { + const DWORD code = GetLastError(); + if (code != ERROR_IO_PENDING) exception_io_from_win32(code); + } + const HANDLE handles[] = {m_event, abort.get_abort_event()}; + SetLastError(NO_ERROR); + DWORD state = myWait(_countof(handles), handles); + if (state == WAIT_OBJECT_0) { + try { + WIN32_IO_OP( GetOverlappedResult(m_handle,&ol,&bytesWritten,TRUE) ); + } catch(...) { + _cancel(ol); + throw; + } + if (bytesWritten != p_bytes) throw exception_io(); + return; + } + _cancel(ol); + abort.check(); + throw timeout(); + } + size_t read(void * p_buffer,size_t p_bytes, abort_callback & abort) { + uint8_t * ptr = (uint8_t*) p_buffer; + size_t done = 0; + while(done < p_bytes) { + abort.check(); + size_t delta = readPass(ptr + done, p_bytes - done, abort); + if (delta == 0) break; + done += delta; + } + return done; + } + size_t readPass(void * p_buffer,size_t p_bytes, abort_callback & abort) { + if (p_bytes == 0) return 0; + OVERLAPPED ol = {}; + ol.hEvent = m_event; + ResetEvent(m_event); + DWORD bytesDone; + SetLastError(NO_ERROR); + if (ReadFile( m_handle, p_buffer, pfc::downcast_guarded(p_bytes), &bytesDone, &ol)) { + // succeeded already? + return bytesDone; + } + + { + const DWORD code = GetLastError(); + switch(code) { + case ERROR_HANDLE_EOF: + return 0; + case ERROR_IO_PENDING: + break; // continue + default: + exception_io_from_win32(code); + }; + } + + const HANDLE handles[] = {m_event, abort.get_abort_event()}; + SetLastError(NO_ERROR); + DWORD state = myWait(_countof(handles), handles); + if (state == WAIT_OBJECT_0) { + SetLastError(NO_ERROR); + if (!GetOverlappedResult(m_handle,&ol,&bytesDone,TRUE)) { + const DWORD code = GetLastError(); + if (code == ERROR_HANDLE_EOF) bytesDone = 0; + else { + _cancel(ol); + exception_io_from_win32(code); + } + } + return bytesDone; + } + _cancel(ol); + abort.check(); + throw timeout(); + } + private: + DWORD myWait(DWORD count, const HANDLE * handles) { + if (m_processMessages) { + for(;;) { + DWORD state = MsgWaitForMultipleObjects(count, handles, FALSE, m_timeOut, QS_ALLINPUT); + if (state == WAIT_OBJECT_0 + count) { + ProcessPendingMessages(); + } else { + return state; + } + } + } else { + return WaitForMultipleObjects(count, handles, FALSE, m_timeOut); + } + } + void _cancel(OVERLAPPED & ol) { + #if _WIN32_WINNT >= 0x600 + CancelIoEx(m_handle,&ol); + #else + CancelIo(m_handle); + #endif + } + static void ProcessPendingMessages() { + MSG msg = {}; + while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg); + } + + HANDLE m_handle; + HANDLE m_event; + const DWORD m_timeOut; + const bool m_processMessages; + }; + + class SubProcess : public stream_reader, public stream_writer { + public: + PFC_DECLARE_EXCEPTION(failure, std::exception, "Unexpected failure"); + + SubProcess(const char * exePath, DWORD timeOutMS = 60*1000) : ExePath(exePath), hStdIn(), hStdOut(), hProcess(), ProcessMessages(false), TimeOutMS(timeOutMS) { + HANDLE ev; + WIN32_OP( (ev = CreateEvent(NULL, TRUE, FALSE, NULL)) != NULL ); + hEventRead = ev; + WIN32_OP( (ev = CreateEvent(NULL, TRUE, FALSE, NULL)) != NULL ); + hEventWrite = ev; + Restart(); + } + void Restart() { + CleanUp(); + STARTUPINFO si = {}; + try { + si.cb = sizeof(si); + si.dwFlags = STARTF_USESTDHANDLES | STARTF_FORCEOFFFEEDBACK; + //si.wShowWindow = SW_HIDE; + + myCreatePipeOut(si.hStdInput, hStdIn); + myCreatePipeIn(hStdOut, si.hStdOutput); + si.hStdError = GetStdHandle(STD_ERROR_HANDLE); + + PROCESS_INFORMATION pi = {}; + try { + WIN32_OP( CreateProcess(pfc::stringcvt::string_os_from_utf8(ExePath), NULL, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi) ); + } catch(std::exception const & e) { + throw failure(PFC_string_formatter() << "Could not start the worker process - " << e); + } + hProcess = pi.hProcess; _Close(pi.hThread); + } catch(...) { + _Close(si.hStdInput); + _Close(si.hStdOutput); + CleanUp(); throw; + } + _Close(si.hStdInput); + _Close(si.hStdOutput); + } + ~SubProcess() { + CleanUp(); + CloseHandle(hEventRead); + CloseHandle(hEventWrite); + } + + bool IsRunning() const { + return hProcess != NULL; + } + void Detach() { + CleanUp(true); + } + bool ProcessMessages; + DWORD TimeOutMS; + + + void write(const void * p_buffer,size_t p_bytes, abort_callback & abort) { + PipeIO writer(hStdIn, hEventWrite, ProcessMessages, TimeOutMS); + writer.write(p_buffer, p_bytes, abort); + } + size_t read(void * p_buffer,size_t p_bytes, abort_callback & abort) { + PipeIO reader(hStdOut, hEventRead, ProcessMessages, TimeOutMS); + return reader.read(p_buffer, p_bytes, abort); + } + void SetPriority(DWORD val) { + SetPriorityClass(hProcess, val); + } + protected: + HANDLE hStdIn, hStdOut, hProcess, hEventRead, hEventWrite; + const pfc::string8 ExePath; + + void CleanUp(bool bDetach = false) { + _Close(hStdIn); _Close(hStdOut); + if (hProcess != NULL) { + if (!bDetach) { + if (WaitForSingleObject(hProcess, TimeOutMS) != WAIT_OBJECT_0) { + //PFC_ASSERT( !"Should not get here - worker stuck" ); + FB2K_console_formatter() << pfc::string_filename_ext(ExePath) << " unresponsive - terminating"; + TerminateProcess(hProcess, -1); + } + } + _Close(hProcess); + } + } + private: + static void _Close(HANDLE & h) { + if (h != NULL) {CloseHandle(h); h = NULL;} + } + + static void myCreatePipe(HANDLE & in, HANDLE & out) { + SECURITY_ATTRIBUTES Attributes = { sizeof(SECURITY_ATTRIBUTES), 0, true }; + WIN32_OP( CreatePipe( &in, &out, &Attributes, 0 ) ); + } + + static pfc::string_formatter makePipeName() { + GUID id; + CoCreateGuid (&id); + return pfc::format( "\\\\.\\pipe\\", pfc::print_guid(id)); + } + + static void myCreatePipeOut(HANDLE & in, HANDLE & out) { + SECURITY_ATTRIBUTES Attributes = { sizeof(SECURITY_ATTRIBUTES), 0, true }; + const pfc::stringcvt::string_os_from_utf8 pipeName( makePipeName() ); + SetLastError(NO_ERROR); + HANDLE pipe = CreateNamedPipe( + pipeName, + FILE_FLAG_FIRST_PIPE_INSTANCE | PIPE_ACCESS_OUTBOUND | FILE_FLAG_OVERLAPPED, + PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, + 1, + 1024*64, + 1024*64, + NMPWAIT_USE_DEFAULT_WAIT,&Attributes); + if (pipe == INVALID_HANDLE_VALUE) throw exception_win32(GetLastError()); + + in = CreateFile(pipeName,GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,&Attributes,OPEN_EXISTING,0,NULL); + DuplicateHandle ( GetCurrentProcess(), pipe, GetCurrentProcess(), &out, 0, FALSE, DUPLICATE_SAME_ACCESS ); + CloseHandle(pipe); + } + + static void myCreatePipeIn(HANDLE & in, HANDLE & out) { + SECURITY_ATTRIBUTES Attributes = { sizeof(SECURITY_ATTRIBUTES), 0, true }; + const pfc::stringcvt::string_os_from_utf8 pipeName( makePipeName() ); + SetLastError(NO_ERROR); + HANDLE pipe = CreateNamedPipe( + pipeName, + FILE_FLAG_FIRST_PIPE_INSTANCE | PIPE_ACCESS_INBOUND | FILE_FLAG_OVERLAPPED, + PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, + 1, + 1024*64, + 1024*64, + NMPWAIT_USE_DEFAULT_WAIT,&Attributes); + if (pipe == INVALID_HANDLE_VALUE) throw exception_win32(GetLastError()); + + out = CreateFile(pipeName,GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE,&Attributes,OPEN_EXISTING,0,NULL); + DuplicateHandle ( GetCurrentProcess(), pipe, GetCurrentProcess(), &in, 0, FALSE, DUPLICATE_SAME_ACCESS ); + CloseHandle(pipe); + } + + PFC_CLASS_NOT_COPYABLE_EX(SubProcess) + }; +} + +#endif // FOOBAR2000_DESKTOP_WINDOWS + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/ProfileCache.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/ProfileCache.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,39 @@ +#pragma once + +namespace ProfileCache { + inline file::ptr FetchFile(const char * context, const char * name, const char * webURL, t_filetimestamp acceptableAge, abort_callback & abort) { + const double timeoutVal = 5; + + auto path = core_api::pathInProfile( context ); + auto fsLocal = filesystem::get(path); + fsLocal->make_directory(path, abort); + path.add_filename( name ); + + bool fetch = false; + file::ptr fLocal; + + try { + fLocal = fsLocal->openWriteExisting(path, abort, timeoutVal ); + fetch = fLocal->get_timestamp(abort) < filetimestamp_from_system_timer() - acceptableAge; + } catch(exception_io_not_found const &) { + fLocal = fsLocal->openWriteNew(path, abort, timeoutVal); + fetch = true; + } + if (fetch) { + try { + fLocal->resize(0, abort); + file::ptr fRemote; + filesystem::g_open(fRemote, webURL, filesystem::open_mode_read, abort); + file::g_transfer_file(fRemote, fLocal, abort ); + } catch(exception_io const &) { + fLocal.release(); + try { + retryOnSharingViolation(timeoutVal, abort, [&] {fsLocal->remove(path, abort);} ); + } catch(...) {} + throw; + } + fLocal->seek(0, abort); + } + return fLocal; + } +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/StdAfx.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/StdAfx.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,6 @@ +// stdafx.cpp : source file that includes just the standard includes +// foobar2000_sdk_helpers.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "StdAfx.h" + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/StdAfx.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/StdAfx.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,20 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#if !defined(AFX_STDAFX_H__6356EC2B_6DD1_4BE8_935C_87ECBA8697E4__INCLUDED_) +#define AFX_STDAFX_H__6356EC2B_6DD1_4BE8_935C_87ECBA8697E4__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include "foobar2000+atl.h" + +// TODO: reference additional headers your program requires here + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_STDAFX_H__6356EC2B_6DD1_4BE8_935C_87ECBA8697E4__INCLUDED_) diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/ThreadUtils.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/ThreadUtils.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,161 @@ +#include "StdAfx.h" + +#include "ThreadUtils.h" +#include "rethrow.h" + +#include + +namespace ThreadUtils { + bool CRethrow::exec( std::function f ) throw() { + m_exception = nullptr; + bool rv = false; + try { + f(); + rv = true; + } catch( ... ) { + m_exception = std::current_exception(); + } + + return rv; + } + + void CRethrow::rethrow() const { + if (m_exception) std::rethrow_exception(m_exception); + } +} +#ifdef _WIN32 + +#include "win32_misc.h" + +#ifdef FOOBAR2000_MOBILE +#include +#endif + + +namespace ThreadUtils { + bool WaitAbortable(HANDLE ev, abort_callback & abort, DWORD timeout) { + const HANDLE handles[2] = {ev, abort.get_abort_event()}; + SetLastError(0); + const DWORD status = WaitForMultipleObjects(2, handles, FALSE, timeout); + switch(status) { + case WAIT_TIMEOUT: + PFC_ASSERT( timeout != INFINITE ); + return false; + case WAIT_OBJECT_0: + return true; + case WAIT_OBJECT_0 + 1: + throw exception_aborted(); + case WAIT_FAILED: + WIN32_OP_FAIL(); + default: + uBugCheck(); + } + } +#ifdef FOOBAR2000_DESKTOP_WINDOWS + void ProcessPendingMessagesWithDialog(HWND hDialog) { + MSG msg = {}; + while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { + if (!IsDialogMessage(hDialog, &msg)) { + DispatchMessage(&msg); + } + } + } + void ProcessPendingMessages() { + MSG msg = {}; + while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { + DispatchMessage(&msg); + } + } + void WaitAbortable_MsgLoop(HANDLE ev, abort_callback & abort) { + abort.check(); + const HANDLE handles[2] = {ev, abort.get_abort_event()}; + MultiWait_MsgLoop(handles, 2); + abort.check(); + + } + t_size MultiWaitAbortable_MsgLoop2(const HANDLE* ev, t_size evCount, abort_callback& abort) { + abort.check(); + const size_t evCountEx = evCount + 1; + HANDLE handles1[16]; + pfc::array_staticsize_t handles2; + HANDLE* pHandles = handles1; + if (evCountEx > 16) { + handles2.set_size_discard(evCountEx); + pHandles = handles2.get_ptr(); + } + pHandles[0] = abort.get_abort_event(); + pfc::memcpy_t(pHandles + 1, ev, evCount); + DWORD status = MultiWait_MsgLoop(pHandles, (DWORD) evCountEx); + abort.check(); + size_t ret = (size_t)(status - WAIT_OBJECT_0 - 1); + PFC_ASSERT(ret < evCount); + return ret; + } + + t_size MultiWaitAbortable_MsgLoop(const HANDLE * ev, t_size evCount, abort_callback & abort) { + // Retval is 1-based! + // Originally a bug, now kept for compatibility if someone relies on this + // Use MultiWaitAbortable_MsgLoop2() instead + return MultiWaitAbortable_MsgLoop2(ev, evCount, abort) + 1; + } + + void SleepAbortable_MsgLoop(abort_callback & abort, DWORD timeout) { + HANDLE handles[] = { abort.get_abort_event() }; + MultiWait_MsgLoop(handles, 1, timeout); + abort.check(); + } + + bool WaitAbortable_MsgLoop(HANDLE ev, abort_callback & abort, DWORD timeout) { + abort.check(); + HANDLE handles[2] = { abort.get_abort_event(), ev }; + DWORD status = MultiWait_MsgLoop(handles, 2, timeout); + abort.check(); + return status != WAIT_TIMEOUT; + } + + DWORD MultiWait_MsgLoop(const HANDLE* ev, DWORD evCount) { + for (;; ) { + SetLastError(0); + const DWORD status = MsgWaitForMultipleObjects((DWORD) evCount, ev, FALSE, INFINITE, QS_ALLINPUT); + if (status == WAIT_FAILED) WIN32_OP_FAIL(); + if (status == WAIT_OBJECT_0 + evCount) { + ProcessPendingMessages(); + } else if ( status >= WAIT_OBJECT_0 && status < WAIT_OBJECT_0 + evCount ) { + return status; + } else { + uBugCheck(); + } + } + } + + DWORD MultiWait_MsgLoop(const HANDLE* ev, DWORD evCount, DWORD timeout) { + if (timeout == INFINITE) return MultiWait_MsgLoop(ev, evCount); + const DWORD entry = GetTickCount(); + DWORD now = entry; + for (;;) { + const DWORD done = now - entry; + if (done >= timeout) return WAIT_TIMEOUT; + SetLastError(0); + const DWORD status = MsgWaitForMultipleObjects((DWORD)evCount, ev, FALSE, timeout - done, QS_ALLINPUT); + if (status == WAIT_FAILED) WIN32_OP_FAIL(); + if (status == WAIT_OBJECT_0 + evCount) { + ProcessPendingMessages(); + } else if (status == WAIT_TIMEOUT || (status >= WAIT_OBJECT_0 && status < WAIT_OBJECT_0 + evCount) ) { + return status; + } else { + uBugCheck(); + } + now = GetTickCount(); + } + } + + bool pfcWaitMsgLoop(HANDLE ev, double timeout) { + DWORD ms = pfc::event::g_calculate_wait_time(timeout); + DWORD status = MultiWait_MsgLoop(&ev, 1, ms); + return status == WAIT_OBJECT_0; + } + +#endif // FOOBAR2000_DESKTOP_WINDOWS + +} +#endif \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/ThreadUtils.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/ThreadUtils.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,66 @@ +#pragma once +#include "fb2k_threads.h" + +#ifdef _WIN32 +#include + +namespace ThreadUtils { + bool WaitAbortable(HANDLE ev, abort_callback & abort, DWORD timeout = INFINITE); + + void ProcessPendingMessages(); + void ProcessPendingMessagesWithDialog(HWND hDialog); + + void WaitAbortable_MsgLoop(HANDLE ev, abort_callback & abort); + + + // Throws an exception if aborted, returns index of triggered event otherwise. + t_size MultiWaitAbortable_MsgLoop2(const HANDLE* ev, t_size evCount, abort_callback& abort); + + // Do not use, broken version of MultiWaitAbortable_MsgLoop2 retained for compatibility (returns 1 based index) + t_size MultiWaitAbortable_MsgLoop(const HANDLE* ev, t_size evCount, abort_callback& abort); + + void SleepAbortable_MsgLoop(abort_callback & abort, DWORD timeoutMS); + bool WaitAbortable_MsgLoop(HANDLE ev, abort_callback & abort, DWORD timeoutMS); + + DWORD MultiWait_MsgLoop(const HANDLE* ev, DWORD evCount, DWORD timeoutMS); + DWORD MultiWait_MsgLoop(const HANDLE* ev, DWORD evCount); + + // Drop-in replacement for pfc::event::g_wait_for() + bool pfcWaitMsgLoop(HANDLE ev, double timeout); + + template + class CObjectQueue { + public: + CObjectQueue() { m_event.create(true,false); } + + template void Add(const TSource & source) { + insync(m_sync); + m_content.add_item(source); + if (m_content.get_count() == 1) m_event.set_state(true); + } + template void Get(TDestination & out, abort_callback & abort) { + WaitAbortable(m_event.get(), abort); + _Get(out); + } + + template void Get_MsgLoop(TDestination & out, abort_callback & abort) { + WaitAbortable_MsgLoop(m_event.get(), abort); + _Get(out); + } + + private: + template void _Get(TDestination & out) { + insync(m_sync); + auto iter = m_content.cfirst(); + FB2K_DYNAMIC_ASSERT( iter.is_valid() ); + out = *iter; + m_content.remove(iter); + if (m_content.get_count() == 0) m_event.set_state(false); + } + win32_event m_event; + critical_section m_sync; + pfc::chain_list_v2_t m_content; + }; + +} +#endif // _WIN32 diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/VisUtils.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/VisUtils.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,38 @@ +#include "StdAfx.h" + +#include "VisUtils.h" + +namespace VisUtils { + void PrepareFFTChunk(audio_chunk const & source, audio_chunk & out, double centerOffset) { + const t_uint32 channels = source.get_channel_count(); + const t_uint32 sampleRate = source.get_sample_rate(); + FB2K_DYNAMIC_ASSERT( sampleRate > 0 ); + out.set_channels(channels, source.get_channel_config()); + out.set_sample_rate(sampleRate); + const t_size inSize = source.get_sample_count(); + const t_size fftSize = MatchFFTSize(inSize); + out.set_sample_count(fftSize); + out.set_data_size(fftSize * channels); + if (fftSize >= inSize) { //rare case with *REALLY* small input + pfc::memcpy_t( out.get_data(), source.get_data(), inSize * channels ); + pfc::memset_null_t( out.get_data() + inSize * channels, (fftSize - inSize) * channels ); + } else { //inSize > fftSize, we're using a subset of source chunk for the job, pick a subset around centerOffset. + const double baseOffset = pfc::max_t(0, centerOffset - 0.5 * (double)fftSize / (double)sampleRate); + const t_size baseSample = pfc::min_t( (t_size) audio_math::time_to_samples(baseOffset, sampleRate), inSize - fftSize); + pfc::memcpy_t( out.get_data(), source.get_data() + baseSample * channels, fftSize * channels); + } + } + + bool IsValidFFTSize(t_size p_size) { + return p_size >= 2 && (p_size & (p_size - 1)) == 0; + } + + t_size MatchFFTSize(t_size samples) { + if (samples <= 2) return 2; + t_size mask = 1; + while(!IsValidFFTSize(samples)) { + samples &= ~mask; mask <<= 1; + } + return samples; + } +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/VisUtils.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/VisUtils.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,10 @@ +#pragma once + +namespace VisUtils { + //! Turns an arbitrary audio_chunk into a valid chunk to run FFT on, with proper sample count etc. + //! @param centerOffset Time offset (in seconds) inside the source chunk to center the output on, in case the FFT window is smaller than input data. + void PrepareFFTChunk(audio_chunk const & source, audio_chunk & out, double centerOffset); + + bool IsValidFFTSize(t_size size); + t_size MatchFFTSize(t_size samples); +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/VolumeMap.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/VolumeMap.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,22 @@ +#include "StdAfx.h" +#include "VolumeMap.h" + +static constexpr double powval = 2.0; +static constexpr double silence = -100.0; + +double VolumeMap::SliderToDB2(double slider) { + double v = SliderToDB(slider); + v = floor(v * 2.0 + 0.5) * 0.5; + return v; +} + +double VolumeMap::SliderToDB(double slider) { + if (slider > 0) { + return pfc::max_t(silence,10.0 * log(slider) / log(powval)); + } else { + return silence; + } +} +double VolumeMap::DBToSlider(double volumeDB) { + return pfc::clip_t(pow(powval,volumeDB / 10.0), 0, 1); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/VolumeMap.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/VolumeMap.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,7 @@ +#pragma once + +namespace VolumeMap { + double SliderToDB(double slider /*0..1 range*/); + double SliderToDB2(double slider); // rounds to 0.5dB + double DBToSlider(double volumeDB); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/WindowPositionUtils.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/WindowPositionUtils.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,228 @@ +#include "StdAfx.h" +#include "WindowPositionUtils.h" + +#define FB2K_WPU_DEBUG 0 +namespace { + static BOOL GetParentWndRect(CWindow wndParent, CRect& rc) { + if (!wndParent.IsIconic()) { + return wndParent.GetWindowRect(rc); + } + WINDOWPLACEMENT pl = { sizeof(pl) }; + if (!wndParent.GetWindowPlacement(&pl)) return FALSE; + rc = pl.rcNormalPosition; + return TRUE; + } + + struct DeOverlapState { + CWindow m_thisWnd; + CPoint m_topLeft; + bool m_match; + }; + static BOOL CALLBACK MyEnumChildProc(HWND wnd, LPARAM param) { + DeOverlapState* state = reinterpret_cast(param); + if (wnd != state->m_thisWnd && IsWindowVisible(wnd)) { + CRect rc; + if (GetWindowRect(wnd, rc)) { + if (rc.TopLeft() == state->m_topLeft) { + state->m_match = true; return FALSE; + } + } + } + return TRUE; + } + static bool DeOverlapTest(CWindow wnd, CPoint topLeft) { + DeOverlapState state = {}; + state.m_thisWnd = wnd; state.m_topLeft = topLeft; state.m_match = false; + EnumThreadWindows(GetCurrentThreadId(), MyEnumChildProc, reinterpret_cast(&state)); + return state.m_match; + } + static int DeOverlapDelta() { + return pfc::max_t(GetSystemMetrics(SM_CYCAPTION), 1); + } + static void DeOverlap(CWindow wnd, CRect& rc) { + const int delta = DeOverlapDelta(); + for (;;) { + if (!DeOverlapTest(wnd, rc.TopLeft())) break; + rc.OffsetRect(delta, delta); + } + } +} + +bool cfgDialogPositionData::grabFrom(CWindow wnd) { + CRect rc; + if (!GetClientRectAsSC(wnd, rc)) { + return false; + } + const CSize DPI = QueryScreenDPIEx(wnd); + m_dpiX = DPI.cx; m_dpiY = DPI.cy; + m_width = rc.Width(); m_height = rc.Height(); + m_posX = m_posY = posInvalid; + CWindow parent = wnd.GetParent(); + if (parent != NULL) { + CRect rcParent; + if (GetParentWndRect(parent, rcParent)) { + m_posX = rc.left - rcParent.left; + m_posY = rc.top - rcParent.top; + } + } else { + m_posX = rc.left; m_posY = rc.top; + } + return true; +} + +pfc::string8 cfgDialogPositionData::debug() const { + pfc::string_formatter ret; + if (m_width != sizeInvalid) ret << "W: " << m_width << "\n"; + if (m_height != sizeInvalid) ret << "H: " << m_height << "\n"; + if (m_posX != posInvalid) ret << "X: " << m_posX << "\n"; + if (m_posY != posInvalid) ret << "Y: " << m_posY << "\n"; + if (m_dpiX != dpiInvalid) ret << "DPI-X: " << m_dpiX << "\n"; + if (m_dpiY != dpiInvalid) ret << "DPI-Y: " << m_dpiY << "\n"; + return ret; +} + +cfgDialogPositionData cfgDialogPositionData::reDPI( CSize screenDPI ) const { + cfgDialogPositionData v = *this; + if (screenDPI.cx == 0 || screenDPI.cy == 0) { + PFC_ASSERT(!"Should not get here - something seriously wrong with the OS"); + return v; + } + if (v.m_dpiX != dpiInvalid && v.m_dpiX != screenDPI.cx) { + if (v.m_width != sizeInvalid) v.m_width = MulDiv(v.m_width, screenDPI.cx, v.m_dpiX); + if (v.m_posX != posInvalid) v.m_posX = MulDiv(v.m_posX, screenDPI.cx, v.m_dpiX); + } + if (v.m_dpiY != dpiInvalid && v.m_dpiY != screenDPI.cy) { + if (v.m_height != sizeInvalid) v.m_height = MulDiv(v.m_height, screenDPI.cy, v.m_dpiY); + if (v.m_posY != posInvalid) v.m_posY = MulDiv(v.m_posY, screenDPI.cy, v.m_dpiY); + } + v.m_dpiX = screenDPI.cx; + v.m_dpiY = screenDPI.cy; + return v; +} + + +bool cfgDialogPositionData::overrideDefaultSize(t_uint32 width, t_uint32 height) { + bool rv = false; + if (m_width == sizeInvalid && m_height == sizeInvalid) { + m_width = width; m_height = height; m_posX = m_posY = posInvalid; + m_dpiX = m_dpiY = 96; + rv = true; + } + return rv; +} + +bool cfgDialogPositionData::applyTo(CWindow wnd) const { +#if FB2K_WPU_DEBUG + FB2K_console_formatter() << "cfgDialogPositionData::applyTo(0x" << pfc::format_window( wnd ) << ")"; + FB2K_console_formatter() << "data:\n" << this->debug(); +#endif + const auto v = reDPI(QueryScreenDPIEx(wnd)); +#if FB2K_WPU_DEBUG + FB2K_console_formatter() << "after reDPI:\n" << v.debug(); +#endif + CWindow wndParent = wnd.GetParent(); + UINT flags = SWP_NOACTIVATE | SWP_NOZORDER; + CRect rc; + if (!GetClientRectAsSC(wnd, rc)) return false; + if (v.m_width != v.sizeInvalid && v.m_height != v.sizeInvalid && (wnd.GetWindowLong(GWL_STYLE) & WS_SIZEBOX) != 0) { + rc.right = rc.left + v.m_width; + rc.bottom = rc.top + v.m_height; + } else { + flags |= SWP_NOSIZE; + } + if (wndParent != NULL) { + CRect rcParent; + if (GetParentWndRect(wndParent, rcParent)) { + if (v.m_posX != v.posInvalid && v.m_posY != v.posInvalid) { + rc.MoveToXY(rcParent.TopLeft() + CPoint(v.m_posX, v.m_posY)); + } else { + CPoint center = rcParent.CenterPoint(); + rc.MoveToXY(center.x - rc.Width() / 2, center.y - rc.Height() / 2); + } + } + } else { + if (v.m_posX != v.posInvalid && v.m_posY != v.posInvalid ) { + rc.MoveToXY( v.m_posX, v.m_posY ); + } + } + if (!AdjustWindowRectHelper(wnd, rc)) return FALSE; + + DeOverlap(wnd, rc); + + { + CRect rcAdjust(0, 0, 1, 1); + if (wndParent != NULL) { + CRect temp; + if (wndParent.GetWindowRect(temp)) rcAdjust = temp; + } + AdjustRectToScreenArea(rc, rcAdjust); + } + + + return wnd.SetWindowPos(NULL, rc, flags); +} + +void cfgDialogPosition::read_from_window(HWND wnd) { + cfgDialogPositionData data; + if (data.grabFrom(wnd)) this->set(data); +} + +bool cfgDialogPosition::apply_to_window(HWND wnd) { + auto data = this->get(); + return data.applyTo(wnd); +} + +bool cfgWindowPositionData::grabFrom(CWindow wnd) { + WINDOWPLACEMENT wp = {sizeof(wp)}; + bool rv = !! wnd.GetWindowPlacement(&wp); + if (rv) { + if ( !wnd.IsWindowVisible() ) wp.showCmd = SW_HIDE; + this->m_wp = wp; + m_dpi = QueryScreenDPIEx(wnd); + PFC_ASSERT( m_dpi.cx > 0 && m_dpi.cy > 0 ); + } + return rv; +} + +static void reDPI(WINDOWPLACEMENT& wp, SIZE from, SIZE to) { + wp.rcNormalPosition.left = MulDiv(wp.rcNormalPosition.left, to.cx, from.cx); + wp.rcNormalPosition.right = MulDiv(wp.rcNormalPosition.right, to.cx, from.cx); + wp.rcNormalPosition.top = MulDiv(wp.rcNormalPosition.top, to.cy, from.cy); + wp.rcNormalPosition.bottom = MulDiv(wp.rcNormalPosition.bottom, to.cy, from.cy); +} + +bool applyWindowPlacement(HWND window, WINDOWPLACEMENT const& data, bool allowHidden); // window_placement_helper.cpp + +bool cfgWindowPositionData::applyTo(CWindow wnd, bool allowHidden) const { + WINDOWPLACEMENT wp = m_wp; + if ( wp.length == 0 ) return false; + auto dpi = QueryScreenDPIEx(wnd); + if (dpi.cx != m_dpi.cx || dpi.cy != m_dpi.cy) { + reDPI( wp, m_dpi, dpi ); + } + return applyWindowPlacement(wnd, wp, allowHidden); +} + +void cfgWindowPosition::read_from_window(HWND wnd) { + // grabFrom might work partially, fail to obtain size due to window being hidden, use last values + cfgWindowPositionData data = get(); + if ( data.grabFrom( wnd ) ) set(data); +} + +bool cfgWindowPosition::apply_to_window(HWND wnd, bool allowHidden) { + auto data = get(); + return data.applyTo( wnd, allowHidden ); +} + +void cfgWindowPosition::windowCreated(HWND wnd, bool allowHidden, DWORD showHow) { + auto data = get(); + switch (showHow) { + case SW_HIDE: + case SW_MINIMIZE: + data.m_wp.showCmd = showHow; + break; + } + if (!data.applyTo(wnd, allowHidden)) { + ::ShowWindow( wnd, showHow); + } +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/WindowPositionUtils.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/WindowPositionUtils.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,264 @@ +#pragma once + +#ifdef _WIN32 + +#include "win32_misc.h" +#include "../SDK/cfg_var.h" + +static BOOL AdjustWindowRectHelper(CWindow wnd, CRect & rc) { + const DWORD style = wnd.GetWindowLong(GWL_STYLE), exstyle = wnd.GetWindowLong(GWL_EXSTYLE); + return AdjustWindowRectEx(&rc,style,(style & WS_POPUP) ? wnd.GetMenu() != NULL : FALSE, exstyle); +} + +static void AdjustRectToScreenArea(CRect & rc, CRect rcParent) { + HMONITOR monitor = MonitorFromRect(rcParent,MONITOR_DEFAULTTONEAREST); + MONITORINFO mi = {sizeof(MONITORINFO)}; + if (GetMonitorInfo(monitor,&mi)) { + const CRect clip = mi.rcWork; + if (rc.right > clip.right) rc.OffsetRect(clip.right - rc.right, 0); + if (rc.bottom > clip.bottom) rc.OffsetRect(0, clip.bottom - rc.bottom); + if (rc.left < clip.left) rc.OffsetRect(clip.left - rc.left, 0); + if (rc.top < clip.top) rc.OffsetRect(0, clip.top - rc.top); + } +} + +static BOOL GetClientRectAsSC(CWindow wnd, CRect & rc) { + CRect temp; + if (!wnd.GetClientRect(temp)) return FALSE; + if (temp.IsRectNull()) return FALSE; + if (!wnd.ClientToScreen(temp)) return FALSE; + rc = temp; + return TRUE; +} + + +static BOOL CenterWindowGetRect(CWindow wnd, CWindow wndParent, CRect & out) { + CRect parent, child; + if (!wndParent.GetWindowRect(&parent) || !wnd.GetWindowRect(&child)) return FALSE; + { + CPoint origin = parent.CenterPoint(); + origin.Offset( - child.Width() / 2, - child.Height() / 2); + child.OffsetRect( origin - child.TopLeft() ); + } + AdjustRectToScreenArea(child, parent); + out = child; + return TRUE; +} + +static BOOL CenterWindowAbove(CWindow wnd, CWindow wndParent) { + CRect rc; + if (!CenterWindowGetRect(wnd, wndParent, rc)) return FALSE; + return wnd.SetWindowPos(NULL,rc,SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); +} + +static BOOL ShowWindowCentered(CWindow wnd,CWindow wndParent) { + CRect rc; + if (!CenterWindowGetRect(wnd, wndParent, rc)) return FALSE; + return wnd.SetWindowPos(HWND_TOP,rc,SWP_NOSIZE | SWP_SHOWWINDOW); +} + +typedef cfg_struct_t cfgWindowSize; + +class cfgWindowSizeTracker { +public: + cfgWindowSizeTracker(cfgWindowSize & p_var) : m_var(p_var) {} + + bool Apply(HWND p_wnd) { + bool retVal = false; + m_applied = false; + auto s = m_var.get(); + if (s.cx > 0 && s.cy > 0) { + CRect rect(0,0,s.cx,s.cy); + if (AdjustWindowRectHelper(p_wnd, rect)) { + SetWindowPos(p_wnd,NULL,0,0,rect.right-rect.left,rect.bottom-rect.top,SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER); + retVal = true; + } + } + m_applied = true; + return retVal; + } + + BOOL ProcessWindowMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT & lResult) { + if (uMsg == WM_SIZE && m_applied) { + if (lParam != 0) { + m_var.set({ (short)LOWORD(lParam), (short)HIWORD(lParam) }); + } + } + return FALSE; + } +private: + cfgWindowSize & m_var; + bool m_applied = false; +}; + +class cfgDialogSizeTracker : public cfgWindowSizeTracker { +public: + cfgDialogSizeTracker(cfgWindowSize & p_var) : cfgWindowSizeTracker(p_var) {} + BOOL ProcessWindowMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT & lResult) { + if (cfgWindowSizeTracker::ProcessWindowMessage(hWnd, uMsg, wParam, lParam, lResult)) return TRUE; + if (uMsg == WM_INITDIALOG) Apply(hWnd); + return FALSE; + } +}; + +struct cfgDialogPositionData { + static constexpr int32_t + posInvalid = 0x80000000; + static constexpr uint32_t + sizeInvalid = 0xFFFFFFFF, + dpiInvalid = 0; + + uint32_t m_width = sizeInvalid, m_height = sizeInvalid; + int32_t m_posX = posInvalid, m_posY = posInvalid; + uint32_t m_dpiX = dpiInvalid, m_dpiY = dpiInvalid; + + cfgDialogPositionData reDPI(CSize) const; + bool grabFrom(CWindow wnd); + bool applyTo(CWindow wnd) const; + + bool overrideDefaultSize(t_uint32 width, t_uint32 height); + + pfc::string8 debug() const; +}; + +struct cfgWindowPositionData { + WINDOWPLACEMENT m_wp = {}; + SIZE m_dpi = {}; + + bool grabFrom(CWindow wnd); + bool applyTo(CWindow wnd, bool allowHidden = false) const; +}; + +FB2K_STREAM_READER_OVERLOAD(cfgDialogPositionData) { + stream >> value.m_width >> value.m_height; + try { + stream >> value.m_posX >> value.m_posY >> value.m_dpiX >> value.m_dpiY; + } catch (exception_io_data const &) { + value.m_posX = value.m_posY = cfgDialogPositionData::posInvalid; + value.m_dpiX = value.m_dpiY = cfgDialogPositionData::dpiInvalid; + } + return stream; +} +FB2K_STREAM_WRITER_OVERLOAD(cfgDialogPositionData) { + return stream << value.m_width << value.m_height << value.m_posX << value.m_posY << value.m_dpiX << value.m_dpiY; +} + +class cfgDialogPosition : public cfg_struct_t { +public: + cfgDialogPosition(const GUID& id) : cfg_struct_t(id) {} + + //! Read and save size data from HWND. + void read_from_window(HWND); + //! Apply saved size data to HWND. + bool apply_to_window(HWND); + + void AddWindow(HWND wnd) { apply_to_window(wnd); } + void RemoveWindow(HWND wnd) { read_from_window(wnd); } +}; + +class cfgWindowPosition : public cfg_struct_t { +public: + cfgWindowPosition(const GUID & id) : cfg_struct_t(id) {} + + //! Read and save size data from HWND. + void read_from_window(HWND); + //! Apply saved size data to HWND. + bool apply_to_window(HWND, bool allowHidden = false); + //! New window created, show it with saved metrics. + void windowCreated(HWND, bool allowHidden = false, DWORD showHow = SW_SHOW); +}; + +class cfgDialogPositionTracker { +public: + cfgDialogPositionTracker(cfgDialogPosition & p_var) : m_var(p_var) {} + ~cfgDialogPositionTracker() {Cleanup();} + + BOOL ProcessWindowMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT & lResult) { + if (uMsg == WM_CREATE || uMsg == WM_INITDIALOG) { + Cleanup(); + m_wnd = hWnd; + m_var.AddWindow(m_wnd); + } else if (uMsg == WM_DESTROY) { + PFC_ASSERT( hWnd == m_wnd ); + Cleanup(); + } + return FALSE; + } + +private: + void Cleanup() { + if (m_wnd != NULL) { + m_var.RemoveWindow(m_wnd); + m_wnd = NULL; + } + } + cfgDialogPosition & m_var; + CWindow m_wnd; +}; + +//! DPI-safe window size var \n +//! Stores size in pixel and original DPI\n +//! Use with cfgWindowSizeTracker2 +struct cfgWindowSize2_data { + CSize m_size = CSize(0, 0), m_dpi = CSize(0, 0); +}; + +class cfgWindowSize2 : public cfg_struct_t< cfgWindowSize2_data > { +public: + cfgWindowSize2(const GUID & p_guid) : cfg_struct_t(p_guid) {} + + bool is_valid() { + auto v = cfg_struct_t::get(); + return v.m_size.cx > 0 && v.m_size.cy > 0; + } + + CSize get( CSize forDPI ) { + auto v = cfg_struct_t::get(); + if ( forDPI == v.m_dpi ) return v.m_size; + + CSize ret; + ret.cx = MulDiv( v.m_size.cx, forDPI.cx, v.m_dpi.cx ); + ret.cy = MulDiv( v.m_size.cy, forDPI.cy, v.m_dpi.cy ); + return ret; + } +}; + +//! Forward messages to this class to utilize cfgWindowSize2 +class cfgWindowSizeTracker2 : public CMessageMap { +public: + cfgWindowSizeTracker2( cfgWindowSize2 & var ) : m_var(var) {} + + BEGIN_MSG_MAP_EX(cfgWindowSizeTracker2) + if (uMsg == WM_CREATE || uMsg == WM_INITDIALOG) { + Apply(hWnd); + } + MSG_WM_SIZE( OnSize ) + END_MSG_MAP() + + bool Apply(HWND p_wnd) { + bool retVal = false; + m_applied = false; + if (m_var.is_valid()) { + CRect rect( CPoint(0,0), m_var.get( m_DPI ) ); + if (AdjustWindowRectHelper(p_wnd, rect)) { + SetWindowPos(p_wnd,NULL,0,0,rect.right-rect.left,rect.bottom-rect.top,SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER); + retVal = true; + } + } + m_applied = true; + return retVal; + } + +private: + void OnSize(UINT nType, CSize size) { + if ( m_applied && size.cx > 0 && size.cy > 0 ) { + m_var.set( { size, m_DPI } ); + } + SetMsgHandled(FALSE); + } + cfgWindowSize2 & m_var; + bool m_applied = false; + const CSize m_DPI = QueryScreenDPIEx(); +}; + +#endif // _WIN32 diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/advconfig_impl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/advconfig_impl.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,4 @@ +#pragma once + +// fb2k mobile compat +#include "../SDK/advconfig_impl.h" \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/advconfig_runtime.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/advconfig_runtime.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,45 @@ +#pragma once + +// Alternate advconfig var implementations that discard their state across app restarts - use for debug options that should not stick + +template +class advconfig_entry_checkbox_runtime_impl : public advconfig_entry_checkbox_v2 { +public: + advconfig_entry_checkbox_runtime_impl(const char * p_name,const GUID & p_guid,const GUID & p_parent,double p_priority,bool p_initialstate) + : m_name(p_name), m_initialstate(p_initialstate), m_state(p_initialstate), m_parent(p_parent), m_priority(p_priority), m_guid(p_guid) {} + + void get_name(pfc::string_base & p_out) {p_out = m_name;} + GUID get_guid() {return m_guid;} + GUID get_parent() {return m_parent;} + void reset() {m_state = m_initialstate;} + bool get_state() {return m_state;} + void set_state(bool p_state) {m_state = p_state;} + bool is_radio() {return p_is_radio;} + double get_sort_priority() {return m_priority;} + bool get_state_() const {return m_state;} + bool get_default_state() {return m_initialstate;} + bool get_default_state_() const {return m_initialstate;} + t_uint32 get_preferences_flags() {return prefFlags;} +private: + pfc::string8 m_name; + const bool m_initialstate; + bool m_state; + const GUID m_parent; + const GUID m_guid; + const double m_priority; +}; + +template +class advconfig_checkbox_factory_runtime_t : public service_factory_single_t > { +public: + advconfig_checkbox_factory_runtime_t(const char * p_name,const GUID & p_guid,const GUID & p_parent,double p_priority,bool p_initialstate) + : service_factory_single_t >(p_name,p_guid,p_parent,p_priority,p_initialstate) {} + + bool get() const {return this->get_static_instance().get_state_();} + void set(bool val) {this->get_static_instance().set_state(val);} + operator bool() const {return get();} + bool operator=(bool val) {set(val); return val;} +}; + +typedef advconfig_checkbox_factory_runtime_t advconfig_checkbox_factory_runtime; +typedef advconfig_checkbox_factory_runtime_t advconfig_radio_factory_runtime; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/albumArtCache.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/albumArtCache.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,77 @@ +#pragma once + +#include +#include +#include + +namespace fb2k { + class albumArtCache { + public: + albumArtCache( imageSize_t s = imageSizeMake(0,0) ) : m_tfSplit(titleformat_patterns::patternAlbumSplit()), imageSize(s), timeOut(0) { + } + bool isLoading() const { return m_imageLoader.is_valid(); } + bool isLoadingExpired() const { return timeOut > 0 && m_imageLoader.is_valid() && m_timeOutTimer.is_empty(); } + bool isLoadingNonExpired() const { return isLoading() && !isLoadingExpired(); } + pfc::string8 albumIDOfTrack( trackRef trk ) { + pfc::string8 pattern; + if (trk.is_valid()) { + trk->format_title(nullptr, pattern, m_tfSplit, nullptr); + } + + return pattern; + } + + std::function onLoaded; + imageSize_t imageSize; + double timeOut; + imageRef getImage( trackRef trk, std::function asyncRecv = nullptr ) { + auto key = albumIDOfTrack( trk ); + if (strcmp(key, m_imageKey) != 0) { + m_timeOutTimer.release(); + m_imageKey = key; + m_image.release(); + m_imageLoader.release(); + + imageLocation_t loc; + if (loc.setTrack2( trk ) ) { + auto recv = makeObjReceiver( [this, asyncRecv] (objRef obj) { + m_image ^= obj; + if (m_imageLoader.is_valid()) { + m_imageLoader.release(); + m_timeOutTimer.release(); + if (onLoaded) onLoaded(); + if (asyncRecv) asyncRecv(m_image); + } + } ); + m_imageLoader = imageLoader::get()->beginLoad(loc, this->imageSize, recv); + + if (m_imageLoader.is_valid() && timeOut > 0) { + m_timeOutTimer = fb2k::registerTimer( timeOut, [=, this] { + m_timeOutTimer.release(); + if (onLoaded) onLoaded(); + if (asyncRecv) asyncRecv(nullptr); + } ); + } + } + } + return m_image; + } + void getImage2( trackRef trk, std::function recv ) { + auto img = getImage( trk, recv ); + if (! this->isLoading() ) recv( img ); + } + void reset() { + m_imageKey = ""; + m_image.release(); + m_imageLoader.release(); + m_timeOutTimer.release(); + } + imageRef current() const { return m_image; } + private: + + titleformat_object_cache m_tfSplit; + pfc::string8 m_imageKey; + imageRef m_image; + objRef m_imageLoader, m_timeOutTimer; + }; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/album_art_helpers.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/album_art_helpers.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,108 @@ +#include "StdAfx.h" +#include "album_art_helpers.h" +#include +#include + +#ifdef _WIN32 +#include +using namespace Gdiplus; +static GdiplusErrorHandler EH; + +static int GetEncoderClsid(const WCHAR* format, CLSID* pClsid) +{ + UINT num = 0; // number of image encoders + UINT size = 0; // size of the image encoder array in bytes + + ImageCodecInfo* pImageCodecInfo = NULL; + + GetImageEncodersSize(&num, &size); + if (size == 0) + return -1; // Failure + + pImageCodecInfo = (ImageCodecInfo*)(malloc(size)); + if (pImageCodecInfo == NULL) + return -1; // Failure + + GetImageEncoders(num, size, pImageCodecInfo); + + for (UINT j = 0; j < num; ++j) + { + if (wcscmp(pImageCodecInfo[j].MimeType, format) == 0) + { + *pClsid = pImageCodecInfo[j].Clsid; + free(pImageCodecInfo); + return j; // Success + } + } + + free(pImageCodecInfo); + return -1; // Failure +} + +static void SaveImage(Gdiplus::Bitmap* image, const TCHAR* out, const TCHAR* format, ULONG quality) { + CLSID encoderClsid; + EncoderParameters encoderParameters; + + if (GetEncoderClsid(format, &encoderClsid) < 0) throw std::runtime_error("Encoder not found"); + + if (_tcscmp(format, _T("image/jpeg")) == 0) { + encoderParameters.Count = 1; + encoderParameters.Parameter[0].Guid = EncoderQuality; + encoderParameters.Parameter[0].Type = EncoderParameterValueTypeLong; + encoderParameters.Parameter[0].NumberOfValues = 1; + encoderParameters.Parameter[0].Value = &quality; + + EH << image->Save(out, &encoderClsid, &encoderParameters); + } else { + EH << image->Save(out, &encoderClsid, NULL); + } +} + +#endif + +namespace album_art_helpers { + bool isJPEG(album_art_data_ptr aa) { + if (aa->size() < 2) return false; + const uint8_t* p = (const uint8_t*)aa->data(); + return p[0] == 0xFF && p[1] == 0xD8; + } + + bool isPNG(album_art_data_ptr aa) { + if (aa->size() < 2) return false; + const uint8_t* p = (const uint8_t*)aa->data(); + return p[0] == 0x89 && p[1] == 0x50; + } + bool isWebP(album_art_data_ptr aa) { + if (aa->size() < 12) return false; + const uint8_t* p = (const uint8_t*)aa->data(); + return memcmp(p, "RIFF", 4) == 0 && memcmp(p + 8, "WEBP", 4) == 0; + } +#ifdef _WIN32 + album_art_data_ptr encodeJPEG(album_art_data_ptr aa, int quality1to100) { + GdiplusScope::Once(); + auto api = fb2k::imageLoaderLite::get(); + + std::unique_ptr< Gdiplus::Image > img(api->load(aa)); + + if (img->GetType() != Gdiplus::ImageTypeBitmap) throw std::runtime_error("Excepted a bitmap"); + + { + pfc::string8 temp_path, temp_file; + uGetTempPath(temp_path); + uGetTempFileName(temp_path, "img", 0, temp_file); + pfc::onLeaving scope([&] { + uDeleteFile(temp_file); + }); + SaveImage(static_cast(img.get()), pfc::stringcvt::string_os_from_utf8(temp_file), L"image/jpeg", quality1to100); + + file::ptr f = fileOpenReadExisting(temp_file, fb2k::noAbort); + uint64_t s = f->get_size_ex(fb2k::noAbort); + if (s > 1024 * 1024 * 64) throw exception_io_data(); + auto obj = fb2k::service_new(); + obj->from_stream(f.get_ptr(), (size_t)s, fb2k::noAbort); + return obj; + } + + } +#endif +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/album_art_helpers.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/album_art_helpers.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,11 @@ +#pragma once + +namespace album_art_helpers { + bool isJPEG(album_art_data_ptr p); + bool isPNG(album_art_data_ptr p); + bool isWebP(album_art_data_ptr p); + +#ifdef _WIN32 + album_art_data_ptr encodeJPEG(album_art_data_ptr source, int quality1to100); +#endif +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/atl-misc.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/atl-misc.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,344 @@ +#pragma once + +#include "win32_misc.h" + +#ifdef _WIN32 +#include +#include +#include +#include +#include +#include + +class CMenuSelectionReceiver : public CWindowImpl { +public: + CMenuSelectionReceiver(HWND p_parent) { + WIN32_OP( Create(p_parent) != NULL ); + } + ~CMenuSelectionReceiver() { + if (m_hWnd != NULL) DestroyWindow(); + } + typedef CWindowImpl _baseClass; + DECLARE_WND_CLASS_EX(TEXT("{DF0087DB-E765-4283-BBAB-6AB2E8AB64A1}"),0,0); + + BEGIN_MSG_MAP(CMenuSelectionReceiver) + MESSAGE_HANDLER(WM_MENUSELECT,OnMenuSelect) + END_MSG_MAP() +protected: + virtual bool QueryHint(unsigned p_id,pfc::string_base & p_out) { + return false; + } +private: + LRESULT OnMenuSelect(UINT,WPARAM p_wp,LPARAM p_lp,BOOL&) { + if (p_lp != 0) { + if (HIWORD(p_wp) & MF_POPUP) { + m_status.release(); + } else { + pfc::string8 msg; + UINT cmd = LOWORD(p_wp); + if ( cmd == 0 || !QueryHint(cmd,msg)) { + m_status.release(); + } else { + if (m_status.is_empty()) { + if (!static_api_ptr_t()->override_status_text_create(m_status)) m_status.release(); + } + if (m_status.is_valid()) { + m_status->override_text(msg); + } + } + } + } else { + m_status.release(); + } + return 0; + } + + service_ptr_t m_status; + + PFC_CLASS_NOT_COPYABLE(CMenuSelectionReceiver,CMenuSelectionReceiver); +}; + +class CMenuDescriptionMap : public CMenuSelectionReceiver { +public: + CMenuDescriptionMap(HWND p_parent) : CMenuSelectionReceiver(p_parent) {} + void Set(unsigned p_id,const char * p_description) {m_content.set(p_id,p_description);} +protected: + bool QueryHint(unsigned p_id,pfc::string_base & p_out) { + return m_content.query(p_id,p_out); + } +private: + pfc::map_t m_content; +}; + +class CMenuDescriptionHybrid : public CMenuSelectionReceiver { +public: + CMenuDescriptionHybrid(HWND parent) : CMenuSelectionReceiver(parent) {} + void Set(unsigned id, const char * desc) {m_content.set(id, desc);} + + void SetCM(contextmenu_manager::ptr mgr, unsigned base, unsigned max) { + m_cmMgr = mgr; m_cmMgr_base = base; m_cmMgr_max = max; + } +protected: + bool QueryHint(unsigned p_id,pfc::string_base & p_out) { + if (m_cmMgr.is_valid() && p_id >= m_cmMgr_base && p_id < m_cmMgr_max) { + return m_cmMgr->get_description_by_id(p_id - m_cmMgr_base,p_out); + } + return m_content.query(p_id,p_out); + } +private: + pfc::map_t m_content; + contextmenu_manager::ptr m_cmMgr; unsigned m_cmMgr_base, m_cmMgr_max; +}; + +inline pfc::string_base & operator<<(pfc::string_base & p_fmt,const CPoint & p_point) { + return p_fmt << "(" << p_point.x << "," << p_point.y << ")"; +} + +inline pfc::string_base & operator<<(pfc::string_base & p_fmt,const CRect & p_rect) { + return p_fmt << "(" << p_rect.left << "," << p_rect.top << "," << p_rect.right << "," << p_rect.bottom << ")"; +} + +template +class CAddDummyMessageMap : public TClass { +public: + BEGIN_MSG_MAP(CAddDummyMessageMap) + END_MSG_MAP() +}; + +template class CWindowFixSEH : public _parentClass { public: + BOOL ProcessWindowMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT& lResult, DWORD dwMsgMapID = 0) { + __try { + return _parentClass::ProcessWindowMessage(hWnd, uMsg, wParam, lParam, lResult, dwMsgMapID); + } __except(uExceptFilterProc(GetExceptionInformation())) { return FALSE; /* should not get here */ } + } + template CWindowFixSEH( arg_t && ... arg ) : _parentClass( std::forward(arg) ... ) {} +}; + +template +class CWindowAutoLifetime : public CWindowFixSEH { +public: + typedef CWindowFixSEH TBase; + template CWindowAutoLifetime(HWND parent, arg_t && ... arg) : TBase( std::forward(arg) ... ) {Init(parent);} +private: + void Init(HWND parent) {WIN32_OP(this->Create(parent) != NULL);} + void OnFinalMessage(HWND wnd) {PFC_ASSERT_NO_EXCEPTION( TBase::OnFinalMessage(wnd) ); PFC_ASSERT_NO_EXCEPTION(delete this);} +}; + +template +class ImplementModalTracking : public TClass { +public: + template ImplementModalTracking(arg_t && ... arg) : TClass(std::forward(arg) ...) {} + + BEGIN_MSG_MAP_EX(ImplementModalTracking) + MSG_WM_INITDIALOG(OnInitDialog) + MSG_WM_DESTROY(OnDestroy) + CHAIN_MSG_MAP(TClass) + END_MSG_MAP() +private: + void OnDestroy() { + m_modal.deinitialize(); + SetMsgHandled(FALSE); + } + BOOL OnInitDialog(CWindow, LPARAM) { + m_modal.initialize(this->m_hWnd); + SetMsgHandled(FALSE); + return FALSE; + } + modal_dialog_scope m_modal; + +}; + +template +class ImplementModelessTracking : public TClass { +public: + template ImplementModelessTracking(arg_t && ... arg ) : TClass(std::forward(arg) ... ) {} + + BEGIN_MSG_MAP_EX(ImplementModelessTracking) + MSG_WM_INITDIALOG(OnInitDialog) + MSG_WM_DESTROY(OnDestroy) + CHAIN_MSG_MAP(TClass) + END_MSG_MAP_HOOK() +private: + BOOL OnInitDialog(CWindow, LPARAM) {m_modeless.Set( this->m_hWnd ); SetMsgHandled(FALSE); return FALSE; } + void OnDestroy() {m_modeless.Set(NULL); SetMsgHandled(FALSE); } + CModelessDialogEntry m_modeless; +}; + +namespace fb2k { + template dialog_t * newDialogEx( HWND parent, arg_t && ... arg ) { + return new CWindowAutoLifetime > ( parent, std::forward(arg) ... ); + } + template dialog_t * newDialog(arg_t && ... arg) { + return new CWindowAutoLifetime > (core_api::get_main_window(), std::forward(arg) ...); + } +} + +class CMenuSelectionReceiver_UiElement : public CMenuSelectionReceiver { +public: + CMenuSelectionReceiver_UiElement(service_ptr_t p_owner,unsigned p_id_base) : CMenuSelectionReceiver(p_owner->get_wnd()), m_owner(p_owner), m_id_base(p_id_base) {} +protected: + bool QueryHint(unsigned p_id,pfc::string_base & p_out) { + return m_owner->edit_mode_context_menu_get_description(p_id,m_id_base,p_out); + } +private: + const unsigned m_id_base; + const service_ptr_t m_owner; +}; + +static bool window_service_trait_defer_destruction(const service_base *) {return true;} + + +//! Special service_impl_t replacement for service classes that also implement ATL/WTL windows. +template +class window_service_impl_t : public implement_service_query< CWindowFixSEH<_t_base> > { +private: + typedef window_service_impl_t<_t_base> t_self; + typedef implement_service_query< CWindowFixSEH<_t_base> > t_base; +public: + BEGIN_MSG_MAP_EX(window_service_impl_t) + MSG_WM_DESTROY(OnDestroyPassThru) + CHAIN_MSG_MAP(__super) + END_MSG_MAP_HOOK() + + int FB2KAPI service_release() throw() { + int ret = --m_counter; + if (ret == 0) { + if (window_service_trait_defer_destruction(this) && !InterlockedExchange(&m_delayedDestroyInProgress,1)) { + PFC_ASSERT_NO_EXCEPTION( service_impl_helper::release_object_delayed(this); ); + } else if (this->m_hWnd != NULL) { + if (!InterlockedExchange(&m_destroyWindowInProgress, 1)) {// don't double-destroy in weird scenarios + service_ptr_t bump(this); // prevent delete this from occurring in mid-DestroyWindow + PFC_ASSERT_NO_EXCEPTION(::DestroyWindow(this->m_hWnd)); + // We don't know what else happened inside DestroyWindow() due to message queue flush + // Safely retry destruction by bump object destructor + // m_hWnd doesn't have to be null here - we'll possibly get cleaned up by OnFinalMessage() instead + } + } else { // m_hWnd is NULL + PFC_ASSERT_NO_EXCEPTION( delete this ); + } + } + return ret; + } + int FB2KAPI service_add_ref() throw() {return ++m_counter;} + + template + window_service_impl_t( arg_t && ... arg ) : t_base( std::forward(arg) ... ) {}; + + ~window_service_impl_t() { + PFC_ASSERT(this->m_hWnd == NULL); + } +private: + void OnDestroyPassThru() { + SetMsgHandled(FALSE); m_destroyWindowInProgress = 1; + } + void OnFinalMessage(HWND p_wnd) override { + t_base::OnFinalMessage(p_wnd); + service_ptr_t bump(this); + } + volatile LONG m_destroyWindowInProgress = 0; + volatile LONG m_delayedDestroyInProgress = 0; + pfc::refcounter m_counter; +}; + +namespace fb2k { + template + service_ptr_t service_new_window(arg_t && ... arg) { + return new window_service_impl_t< obj_t > ( std::forward (arg) ... ); + } +} + +static void AppendMenuPopup(HMENU menu, UINT flags, CMenu & popup, const TCHAR * label) { + PFC_ASSERT( flags & MF_POPUP ); + WIN32_OP_D( CMenuHandle(menu).AppendMenu(flags, popup, label) ); + popup.Detach(); +} + +class CMessageMapDummy : public CMessageMap { +public: + BOOL ProcessWindowMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, + LRESULT& lResult, DWORD dwMsgMapID) {return FALSE;} +}; + + + + + + + +template class preferences_page_instance_impl : public TDialog { +public: + preferences_page_instance_impl(HWND parent, preferences_page_callback::ptr callback) : TDialog(callback) { + WIN32_OP(this->Create(parent) != NULL); + + // complain early if what we created isn't a child window + PFC_ASSERT( (this->GetStyle() & (WS_POPUP|WS_CHILD)) == WS_CHILD ); + } + HWND get_wnd() {return this->m_hWnd;} +}; +static bool window_service_trait_defer_destruction(const preferences_page_instance *) {return false;} +template class preferences_page_impl : public preferences_page_v3 { +public: + preferences_page_instance::ptr instantiate(HWND parent, preferences_page_callback::ptr callback) { + return fb2k::service_new_window >(parent, callback); + } +}; + +class CEmbeddedDialog : public CDialogImpl { +public: + CEmbeddedDialog(CMessageMap * owner, DWORD msgMapID, UINT dialogID) : m_owner(*owner), IDD(dialogID), m_msgMapID(msgMapID) {} + + BEGIN_MSG_MAP(CEmbeddedDialog) + CHAIN_MSG_MAP_ALT_MEMBER(m_owner, m_msgMapID) + END_MSG_MAP() + + const DWORD m_msgMapID; + const UINT IDD; + CMessageMap & m_owner; +}; + + +// ui_element stuff here because of window_service_impl_t + +template +class ui_element_instance_impl_helper : public instance_t { +public: + template + ui_element_instance_impl_helper(args_t && ... args) : instance_t(std::forward(args) ...) {} + + GUID get_guid() override { return instance_t::g_get_guid(); } + GUID get_subclass() override { return instance_t::g_get_subclass(); } + HWND get_wnd() override { return *this; } +}; + + +namespace fb2k { + template + ui_element_instance::ptr newUIElement(HWND parent, args_t && ... args) { + auto item = fb2k::service_new_window < ui_element_instance_impl_helper < TImpl > >(std::forward(args) ...); + item->initialize_window(parent); + return item; + } +} + +template class ui_element_impl : public TInterface { +public: + GUID get_guid() { return TImpl::g_get_guid(); } + GUID get_subclass() { return TImpl::g_get_subclass(); } + void get_name(pfc::string_base & out) { TImpl::g_get_name(out); } + + template + ui_element_instance::ptr instantiate_helper(HWND parent, args_t && ... args) { + return fb2k::newUIElement(parent, std::forward(args) ...); + } + + ui_element_instance::ptr instantiate(HWND parent, ui_element_config::ptr cfg, ui_element_instance_callback::ptr callback) { + PFC_ASSERT(cfg->get_guid() == get_guid()); + return instantiate_helper(parent, cfg, callback); + } + ui_element_config::ptr get_default_configuration() { return TImpl::g_get_default_configuration(); } + ui_element_children_enumerator_ptr enumerate_children(ui_element_config::ptr cfg) { return NULL; } + bool get_description(pfc::string_base & out) { out = TImpl::g_get_description(); return true; } +}; + + +#endif // _WIN32 diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/audio_render_float.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/audio_render_float.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,26 @@ +#pragma once + +template inline void render_float(float_t* out, const audio_sample* in, size_t count) { + audio_math::convert(in, out, count); +} + +template inline const float_t* render_float(mem_block_container& buffer, const audio_sample* in, size_t count) { + if (sizeof(float_t) == sizeof(audio_sample)) { + return reinterpret_cast(in); + } + buffer.set_size(sizeof(float_t) * count); + float_t* out = reinterpret_cast(buffer.get_ptr()); + render_float(out, in, count); + return out; +} + +inline const void* render_float_by_bps(unsigned bps, mem_block_container& buffer, const audio_sample* in, size_t count) { + switch (bps) { + case 32: + return render_float(buffer, in, count); + case 64: + return render_float(buffer, in, count); + default: + throw exception_io_data(); + } +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/bitreader_helper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/bitreader_helper.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,154 @@ +#pragma once + +namespace bitreader_helper { + + inline static size_t extract_bit(const uint8_t * p_stream,size_t p_offset) { + return (p_stream[p_offset>>3] >> (7-(p_offset&7)))&1; + } + + inline static size_t extract_int(const uint8_t * p_stream,size_t p_base,size_t p_width) { + size_t ret = 0; + size_t offset = p_base; + for(size_t bit=0;bit>3]; + b = (b & ~mask) | ((bit&1) << bshift); + } + inline static void write_int( uint8_t * p_stream, size_t p_base, size_t p_width, size_t p_value) { + size_t offset = p_base; + size_t val = p_value; + for( size_t bit = 0; bit < p_width; ++ bit ) { + write_bit( p_stream, offset++, val >> (p_width - bit - 1)); + } + } + +class bitreader +{ +public: + inline bitreader(const t_uint8 * p_ptr,t_size p_base) + : m_ptr(p_ptr), m_bitptr(p_base) + { + } + + inline void skip(t_size p_bits) + { + m_bitptr += p_bits; + } + + + template + t_ret peek_t(t_size p_bits) const { + size_t ptr = m_bitptr; + t_ret ret = 0; + for(t_size bit=0;bit>3] >> (7-(ptr &7)))&1; + ptr++; + } + return ret; + } + + template + t_ret read_t(t_size p_bits) { + t_ret ret = peek_t(p_bits); + skip(p_bits); + return ret; + } + + size_t peek(size_t bits) const { + return peek_t(bits); + } + + t_size read(t_size p_bits) {return read_t(p_bits);} + + inline t_size get_bitptr() const {return m_bitptr;} + + inline bool read_bit() { + bool state = ( (m_ptr[m_bitptr>>3] >> (7-(m_bitptr&7)))&1 ) != 0; + m_bitptr++; + return state; + } + +private: + + const t_uint8 * m_ptr; + t_size m_bitptr; +}; + +class bitreader_fromfile +{ +public: + inline bitreader_fromfile(service_ptr_t const& p_file) : m_file(p_file), m_buffer_ptr(0) {} + + t_size read(t_size p_bits,abort_callback & p_abort) { + t_size ret = 0; + for(t_size bit=0;bitread_object(&m_buffer,1,p_abort); + + ret <<= 1; + ret |= (m_buffer >> (7-m_buffer_ptr))&1; + m_buffer_ptr = (m_buffer_ptr+1) & 7; + } + return ret; + } + + void skip(t_size p_bits,abort_callback & p_abort) { + for(t_size bit=0;bitread_object(&m_buffer,1,p_abort); + m_buffer_ptr = (m_buffer_ptr+1) & 7; + } + } + + inline void byte_align() {m_buffer_ptr = 0;} + +private: + service_ptr_t m_file; + t_size m_buffer_ptr; + t_uint8 m_buffer; +}; + +class bitreader_limited +{ +public: + inline bitreader_limited(const t_uint8 * p_ptr,t_size p_base,t_size p_remaining) : m_reader(p_ptr,p_base), m_remaining(p_remaining) {} + + inline t_size get_bitptr() const {return m_reader.get_bitptr();} + + inline t_size get_remaining() const {return m_remaining;} + + inline void skip(t_size p_bits) { + if (p_bits > m_remaining) throw exception_io_data_truncation(); + m_remaining -= p_bits; + m_reader.skip(p_bits); + } + + size_t peek(size_t bits) { + if (bits > m_remaining) throw exception_io_data_truncation(); + return m_reader.peek(bits); + } + t_size read(t_size p_bits) + { + if (p_bits > m_remaining) throw exception_io_data_truncation(); + m_remaining -= p_bits; + return m_reader.read(p_bits); + } + +private: + bitreader m_reader; + t_size m_remaining; +}; + +inline static t_size extract_bits(const t_uint8 * p_buffer,t_size p_base,t_size p_count) { + return bitreader(p_buffer,p_base).read(p_count); +} + +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/callInMainThreadHelper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/callInMainThreadHelper.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,127 @@ +#pragma once +#include + +// ====================================================================================================== +// Obsolete helpers - they still work, but it's easier to just use fb2k::inMainThread(). +// ====================================================================================================== + + +// Proxy class - friend this to allow callInMainThread to access your private methods +class callInMainThread { +public: + template + static void callThis(host_t * host, param_t & param) { + host->inMainThread(param); + } + template + static void callThis( host_t * host ) { + host->inMainThread(); + } +}; + +// Internal class, do not use. +template +class _callInMainThreadSvc_t : public main_thread_callback { +public: + _callInMainThreadSvc_t(service_t * host, param_t const & param) : m_host(host), m_param(param) {} + void callback_run() { + callInMainThread::callThis(m_host.get_ptr(), m_param); + } +private: + service_ptr_t m_host; + param_t m_param; +}; + + +// Main thread callback helper. You can use this to easily invoke inMainThread(someparam) on your class without writing any wrapper code. +// Requires myservice_t to be a fb2k service class with reference counting. +template +static void callInMainThreadSvc(myservice_t * host, param_t const & param) { + typedef _callInMainThreadSvc_t impl_t; + service_ptr_t obj = new service_impl_t(host, param); + main_thread_callback_manager::get()->add_callback( obj ); +} + +//! Helper class to call methods of your class (host class) in main thread with convenience. \n +//! Deals with the otherwise ugly scenario of your class becoming invalid while a method is queued. \n +//! Have this as a member of your class, then use m_mthelper.add( this, somearg ) ; to defer a call to this->inMainThread(somearg). \n +//! If your class becomes invalid before inMainThread is executed, the pending callback is discarded. \n +//! You can optionally call shutdown() to invalidate all pending callbacks early (in a destructor of your class - without waiting for callInMainThreadHelper destructor to do the job. \n +//! In order to let callInMainThreadHelper access your private methods, declare friend class callInMainThread. \n +//! Note that callInMainThreadHelper is expected to be created and destroyed in main thread. +class callInMainThreadHelper { +public: + + typedef std::function< void () > func_t; + + typedef pfc::rcptr_t< bool > killswitch_t; + + class entryFunc : public main_thread_callback { + public: + entryFunc( func_t const & func, killswitch_t ks ) : m_ks(ks), m_func(func) {} + + void callback_run() { + if (!*m_ks) m_func(); + } + + private: + killswitch_t m_ks; + func_t m_func; + }; + + template + class entry : public main_thread_callback { + public: + entry( host_t * host, arg_t const & arg, killswitch_t ks ) : m_ks(ks), m_host(host), m_arg(arg) {} + void callback_run() { + if (!*m_ks) callInMainThread::callThis( m_host, m_arg ); + } + private: + killswitch_t m_ks; + host_t * m_host; + arg_t m_arg; + }; + template + class entryVoid : public main_thread_callback { + public: + entryVoid( host_t * host, killswitch_t ks ) : m_ks(ks), m_host(host) {} + void callback_run() { + if (!*m_ks) callInMainThread::callThis( m_host ); + } + private: + killswitch_t m_ks; + host_t * m_host; + }; + + void add(func_t f) { + add_( new service_impl_t< entryFunc > ( f, m_ks ) ); + } + + template + void add( host_t * host, arg_t const & arg) { + add_( new service_impl_t< entry >( host, arg, m_ks ) ); + } + template + void add( host_t * host ) { + add_( new service_impl_t< entryVoid >( host, m_ks ) ); + } + void add_( main_thread_callback::ptr cb ) { + main_thread_callback_add( cb ); + } + + callInMainThreadHelper() { + m_ks.new_t(); + * m_ks = false; + } + void shutdown() { + PFC_ASSERT( core_api::is_main_thread() ); + * m_ks = true; + } + ~callInMainThreadHelper() { + shutdown(); + } + +private: + killswitch_t m_ks; + +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/callback_merit.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/callback_merit.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,31 @@ +#pragma once +#include +#include +#include + +namespace fb2k { + // Call global callbacks in correct order + // INTENDED FOR CORE USE ONLY + // Not aware of dynamically registered callbacks, if there are such for the same event type + // Usage: for_each_callback_by_merit< metadb_io_edit_callback > ( [] ( metadb_io_edit_callback::ptr ) { ...} ); + template + void for_each_callback_by_merit(std::function)> f) { + struct rec_t { + class_t* obj; // non-autoptr INTENDED, avoid destruction order bugs on shutdown + fb2k::callback_merit_t merit; + }; + auto generator = [] { + std::vector ret; ret.reserve(64); + for (auto ptr : class_t::enumerate()) { + rec_t r; + r.merit = fb2k::callback_merit_of(ptr); + r.obj = ptr.detach(); + ret.push_back( std::move(r) ); + } + std::sort(ret.begin(), ret.end(), [](rec_t const& e1, rec_t const& e2) { return e1.merit > e2.merit; }); + return ret; + }; + static std::vector cache = generator(); + for (auto& walk : cache) f(walk.obj); + } +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/cfg_dsp_chain_config.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/cfg_dsp_chain_config.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,60 @@ +#pragma once +#include +#include + +#if FOOBAR2020 +class cfg_dsp_chain_config : public cfg_blob { +public: + void reset() { + cfg_blob::set(nullptr); + } + cfg_dsp_chain_config(const GUID& p_guid) : cfg_blob(p_guid) {} + + void get_data(dsp_chain_config& p_data) { + p_data.from_blob(cfg_blob::get()); + } + void set_data(const dsp_chain_config& p_data) { + cfg_blob::set(p_data.to_blob()); + } +}; + +typedef cfg_dsp_chain_config cfg_dsp_chain_config_mt; +#else +class cfg_dsp_chain_config : public cfg_var { +protected: + void get_data_raw(stream_writer * p_stream,abort_callback & p_abort) {m_data.contents_to_stream(p_stream,p_abort);} + void set_data_raw(stream_reader * p_stream,t_size p_sizehint,abort_callback & p_abort) {m_data.contents_from_stream(p_stream,p_abort);} +public: + void reset() { m_data.remove_all(); } + inline cfg_dsp_chain_config(const GUID & p_guid) : cfg_var(p_guid) {} + t_size get_count() const {return m_data.get_count();} + const dsp_preset & get_item(t_size p_index) const {return m_data.get_item(p_index);} + void get_data(dsp_chain_config & p_data) const {p_data.copy(m_data);} + void set_data(const dsp_chain_config & p_data) {m_data.copy(p_data);} + dsp_chain_config_impl & _data() {return m_data; } +private: + dsp_chain_config_impl m_data; +}; + +class cfg_dsp_chain_config_mt : private cfg_var { +public: + cfg_dsp_chain_config_mt( const GUID & id ) : cfg_var(id) {} + void reset() { dsp_chain_config_impl dummy; set_data(dummy); } + void get_data(dsp_chain_config & p_data) { inReadSync( m_sync ); p_data.copy(m_data); } + template + void set_data(arg_t && p_data) { inWriteSync( m_sync ); m_data = std::forward(p_data);} +protected: + void get_data_raw(stream_writer* p_stream, abort_callback& p_abort) { + dsp_chain_config_impl temp; + get_data( temp ); + temp.contents_to_stream( p_stream, p_abort ); + } + void set_data_raw(stream_reader* p_stream, t_size p_sizehint, abort_callback& p_abort) { + dsp_chain_config_impl temp; temp.contents_from_stream( p_stream, p_abort ); + set_data( temp ); + } +private: + pfc::readWriteLock m_sync; + dsp_chain_config_impl m_data; +}; +#endif diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/cfg_guidlist.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/cfg_guidlist.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,2 @@ +#include "StdAfx.h" +#include "cfg_guidlist.h" \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/cfg_guidlist.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/cfg_guidlist.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,27 @@ +#pragma once +#include "cfg_objList.h" +#include + +class cfg_guidlist : public cfg_objList { +public: + cfg_guidlist(const GUID& p_guid) : cfg_objList(p_guid) {} + + void sort() { + auto v = this->get(); + pfc::sort_t(v, pfc::guid_compare, v.size()); + set(std::move(v)); + } + + bool have_item_bsearch(const GUID & p_item) { + size_t dummy; + return pfc::bsearch_simple_inline_t(*this, size(), p_item, pfc::guid_compare, dummy); + } + bool bsearch(const GUID& item, size_t & idx) { + return pfc::bsearch_simple_inline_t(*this, size(), item, pfc::guid_compare, idx); + } + size_t bsearch(const GUID& item) { + size_t ret = SIZE_MAX; + pfc::bsearch_simple_inline_t(*this, size(), item, pfc::guid_compare, ret); + return ret; + } +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/cfg_obj.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/cfg_obj.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,72 @@ +#pragma once + +#include +#if FOOBAR2020 +#include +#include + +namespace cfg_var_modern { + template + class cfg_obj : public cfg_var_common { + public: + cfg_obj(const GUID& id) : cfg_var_common(id), m_initVal() {} + template + cfg_obj(const GUID& id, arg_t&& v) : cfg_var_common(id), m_initVal(std::forward(v)) {} + + obj_t get() { + init(); + PFC_INSYNC_READ(m_sync); + return m_val; + } + template + void set(arg_t&& arg) { + init(); + PFC_INSYNC_WRITE(m_sync); + m_val = std::forward(arg); + save(); + } + template + void operator=(arg_t&& arg) { + set(std::forward(arg)); + } + private: +#ifdef FOOBAR2000_HAVE_CFG_VAR_LEGACY + void set_data_raw(stream_reader* p_stream, t_size p_sizehint, abort_callback& p_abort) override { + obj_t o; + try { + stream_reader_formatter<> fmt(*p_stream, p_abort); + fmt >> o; + } catch (...) { return; } + set(std::move(o)); + } +#endif + void save() { + // already in write sync + stream_writer_formatter_simple<> out; + out << this->m_val; + fb2k::configStore::get()->setConfigBlob(formatName(), out.m_buffer.get_ptr(), out.m_buffer.get_size()); + } + void init() { + std::call_once(m_init, [this] { + obj_t v = m_initVal; + auto blob = fb2k::configStore::get()->getConfigBlob(formatName(), nullptr); + if (blob.is_valid()) { + try { + stream_reader_formatter_simple<> source(blob->data(), blob->size()); + source >> v; + } catch (...) { + v = m_initVal; // revert + } + } + PFC_INSYNC_WRITE(m_sync); + m_val = std::move(v); + }); + } + + pfc::readWriteLock m_sync; + obj_t m_val; + obj_t m_initVal; + std::once_flag m_init; + }; +} +#endif // FOOBAR2020 \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/cfg_objList.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/cfg_objList.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,160 @@ +#pragma once + +#include + +#if FOOBAR2020 +#include +namespace cfg_var_modern { + template + class cfg_objList : private cfg_var_common { + public: + cfg_objList(const GUID& guid) : cfg_var_common(guid) { } + template cfg_objList(const GUID& guid, const source_t(&source)[source_count]) : cfg_var_common(guid) { + m_defaults.resize(source_count); + for( unsigned walk = 0; walk < source_count; ++ walk) m_defaults[walk] = source[walk]; + } + + void clear() { set(std::vector()); } + void remove_all() { clear(); } + size_t remove_mask(pfc::bit_array const& arg) { + init(); + PFC_INSYNC_WRITE(m_listGuard); + size_t gone = pfc::remove_mask_t(m_list, arg); + if (gone > 0) save(); + return gone; + } + //! Returns number of items removed. + template size_t remove_if(pred_t&& p) { + init(); + PFC_INSYNC_WRITE(m_listGuard); + const auto nBefore = m_list.size(); + const size_t nAfter = pfc::remove_if_t(m_list, std::forward(p)); + const auto gone = nAfter - nBefore; + if (gone > 0) save(); + return gone; + } + bool remove_item(obj_t const& v) { + return remove_if([&v](const obj_t& arg) { return v == arg; }) != 0; + } + size_t size() { init(); PFC_INSYNC_READ(m_listGuard);return m_list.size(); } + size_t get_count() { return size(); } + size_t get_size() { return size(); } + + obj_t get(size_t idx) { init(); PFC_INSYNC_READ(m_listGuard); return m_list[idx]; } + + obj_t operator[] (size_t idx) { return get(idx); } + + template + void set(size_t idx, arg_t&& v) { + init(); + PFC_INSYNC_WRITE(m_listGuard); m_list[idx] = std::forward(v); save(); + } + bool have_item(obj_t const& arg) { + return find_item(arg) != SIZE_MAX; + } + size_t find_item(obj_t const& arg) { + init(); + PFC_INSYNC_READ(m_listGuard); + for (size_t idx = 0; idx < m_list.size(); ++idx) { + if (m_list[idx] == arg) return idx; + } + return SIZE_MAX; + } + template + void insert_item(size_t idx, arg_t&& arg) { + init(); + PFC_INSYNC_WRITE(m_listGuard); + m_list.insert(m_list.begin() + idx, std::forward(arg)); + save(); + } + template + void set_items(arg_t&& arg) { + init(); + PFC_INSYNC_WRITE(m_listGuard); + m_list.clear(); + for (auto& item : arg) m_list.push_back(item); + save(); + } + template + void insert_items(arg_t&& arg, size_t at) { + init(); + PFC_INSYNC_WRITE(m_listGuard); + m_list.insert(m_list.begin() + at, arg.begin(), arg.end()); + save(); + } + template + void add_items(arg_t&& arg) { + init(); + PFC_INSYNC_WRITE(m_listGuard); + + m_list.insert(m_list.end(), arg.begin(), arg.end()); + save(); + } + template + void add_item(arg_t&& arg) { + init(); + PFC_INSYNC_WRITE(m_listGuard); + m_list.push_back(std::forward(arg)); + save(); + } + template + void set(arg_t&& arg) { + init(); + set_(std::forward(arg)); + } + std::vector get() { + init(); + PFC_INSYNC_READ(m_listGuard); + return m_list; + } + + + private: + void init() { + std::call_once(m_init, [this] { + auto blob = fb2k::configStore::get()->getConfigBlob(formatName(), nullptr); + if (blob.is_valid()) try { + stream_reader_formatter_simple<> reader(blob->data(), blob->size()); + std::vector data; + uint32_t count; reader >> count; data.resize(count); + for (auto& v : data) reader >> v; + set_(std::move(data), false); + return; + } catch(...) {} // fall through, set defaults + set_(m_defaults, false); + }); + } + template + void set_(arg_t&& arg, bool bSave = true) { + PFC_INSYNC_WRITE(m_listGuard); + m_list = std::forward(arg); + if (bSave) save(); + } + void save() { + // assumes write sync + stream_writer_formatter_simple<> out; + out << (uint32_t)m_list.size(); + for (auto& v : m_list) out << v; + fb2k::configStore::get()->setConfigBlob(formatName(), out.m_buffer.get_ptr(), out.m_buffer.get_size()); + } +#ifdef FOOBAR2000_HAVE_CFG_VAR_LEGACY + void set_data_raw(stream_reader* p_stream, t_size p_sizehint, abort_callback& p_abort) override { + stream_reader_formatter<> reader(*p_stream, p_abort); + std::vector data; + uint32_t count; reader >> count; data.resize(count); + for (auto& v : data) reader >> v; + set(std::move(data)); + } +#endif + + std::vector m_list; + pfc::readWriteLock m_listGuard; + + std::once_flag m_init; + + std::vector m_defaults; + }; + +} +#endif // FOOBAR2020 + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/cfg_var_import.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/cfg_var_import.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,4 @@ +#include "StdAfx.h" +#include "cfg_var_import.h" + +// dummy C++ to get intellisense in cfg_var_import.h diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/cfg_var_import.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/cfg_var_import.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,150 @@ +#pragma once +#include "../SDK/cfg_var.h" +#ifdef FOOBAR2000_HAVE_CFG_VAR_LEGACY + +class cfg_var_import_common : public cfg_var_reader { +protected: + const char* const m_varName; +public: + cfg_var_import_common(const char* name, const GUID& guid) : cfg_var_reader(guid), m_varName(name) {} + + template + void importFloat(stream_reader* s, abort_callback& a) { + float_t f; + s->read_lendian_t(f, a); + fb2k::configStore::get()->setConfigFloat(m_varName, f); + } + template + void importInt(stream_reader* s, abort_callback& a) { + int_t i; + s->read_lendian_t(i, a); + fb2k::configStore::get()->setConfigInt(m_varName, (int64_t)i); + } + + void importBlob(stream_reader* p_stream, t_size p_sizehint, abort_callback& p_abort) { + pfc::mem_block temp; temp.resize(p_sizehint); + p_stream->read_object(temp.ptr(), p_sizehint, p_abort); + fb2k::configStore::get()->setConfigBlob(m_varName, fb2k::memBlock::blockWithData(std::move(temp))); + } +}; + +class cfg_var_import_blob_ : public cfg_var_import_common { +public: + cfg_var_import_blob_(const char* name, const GUID& guid) : cfg_var_import_common(name, guid) {} + + void set_data_raw(stream_reader* p_stream, t_size p_sizehint, abort_callback& p_abort) override { + importBlob(p_stream, p_sizehint, p_abort); + } +}; + +class cfg_var_import_int_ : public cfg_var_import_common { +public: + cfg_var_import_int_(const char* name, const GUID& guid) : cfg_var_import_common(name, guid) {} + + void set_data_raw(stream_reader* p_stream, t_size p_sizehint, abort_callback& p_abort) override { + switch (p_sizehint) { + case 1: + importInt(p_stream, p_abort); break; + case 2: + importInt(p_stream, p_abort); break; + case 4: + importInt(p_stream, p_abort); break; + case 8: + importInt(p_stream, p_abort); break; + default: + PFC_ASSERT(!"???"); + } + } +}; + +class cfg_var_import_uint_ : public cfg_var_import_common { +public: + cfg_var_import_uint_(const char* name, const GUID& guid) : cfg_var_import_common(name, guid) {} + + void set_data_raw(stream_reader* p_stream, t_size p_sizehint, abort_callback& p_abort) override { + switch (p_sizehint) { + case 1: + importInt(p_stream, p_abort); break; + case 2: + importInt(p_stream, p_abort); break; + case 4: + importInt(p_stream, p_abort); break; + case 8: + importInt(p_stream, p_abort); break; + default: + PFC_ASSERT(!"???"); + } + } +}; + +class cfg_var_import_string_ : public cfg_var_import_common { +public: + cfg_var_import_string_(const char* name, const GUID& guid) : cfg_var_import_common(name, guid) {} + + void set_data_raw(stream_reader* p_stream, t_size p_sizehint, abort_callback& p_abort) override { + pfc::string8_fastalloc temp; + p_stream->read_string_raw(temp, p_abort); + fb2k::configStore::get()->setConfigString(m_varName, temp); + } +}; + +class cfg_var_import_float_ : public cfg_var_import_common { +public: + cfg_var_import_float_(const char* name, const GUID& guid) : cfg_var_import_common(name, guid) {} + + void set_data_raw(stream_reader* p_stream, t_size p_sizehint, abort_callback& p_abort) override { + switch (p_sizehint) { + case 4: + importFloat(p_stream, p_abort); break; + case 8: + importFloat(p_stream, p_abort); break; + default: + PFC_ASSERT(!"???"); + } + } +}; + +class cfg_var_import_bool_ : public cfg_var_import_common { +public: + cfg_var_import_bool_(const char* name, const GUID& guid) : cfg_var_import_common(name, guid) {} + void set_data_raw(stream_reader* p_stream, t_size p_sizehint, abort_callback& p_abort) override { + uint8_t foo[8] = {}; + p_stream->read(foo, 8, p_abort); + uint8_t acc = 0; + for (auto b : foo) acc |= b; + fb2k::configStore::get()->setConfigBool(m_varName, acc != 0); + } +}; + +class cfg_var_import_guid_ : public cfg_var_import_common { +public: + cfg_var_import_guid_(const char* name, const GUID& guid) : cfg_var_import_common(name, guid) {} + + void set_data_raw(stream_reader* p_stream, t_size p_sizehint, abort_callback& p_abort) override { + GUID guid; + p_stream->read_lendian_t(guid, p_abort); + fb2k::configStore::get()->setConfigGUID(m_varName, guid); + } +}; + +#define FB2K_IMPORT__(name, guid, importer) static importer _FB2K_UNIQUE_NAME(g_cfg_var_import_) ( name, guid ); + +#define FB2K_IMPORT_INT(name, guid) FB2K_IMPORT__(name, guid, cfg_var_import_int_) +#define FB2K_IMPORT_UINT(name, guid) FB2K_IMPORT__(name, guid, cfg_var_import_uint_) +#define FB2K_IMPORT_BLOB(name, guid) FB2K_IMPORT__(name, guid, cfg_var_import_blob_) +#define FB2K_IMPORT_GUID(name, guid) FB2K_IMPORT__(name, guid, cfg_var_import_guid_) +#define FB2K_IMPORT_STRING(name, guid) FB2K_IMPORT__(name, guid, cfg_var_import_string_) +#define FB2K_IMPORT_BOOL(name, guid) FB2K_IMPORT__(name, guid, cfg_var_import_bool_) +#define FB2K_IMPORT_FLOAT(name, guid) FB2K_IMPORT__(name, guid, cfg_var_import_float_) + +#else // FOOBAR2000_HAVE_CFG_VAR_LEGACY + +#define FB2K_IMPORT_INT(name, guid) +#define FB2K_IMPORT_UINT(name, guid) +#define FB2K_IMPORT_BLOB(name, guid) +#define FB2K_IMPORT_GUID(name, guid) +#define FB2K_IMPORT_STRING(name, guid) +#define FB2K_IMPORT_BOOL(name, guid) +#define FB2K_IMPORT_FLOAT(name, guid) + +#endif // FOOBAR2000_HAVE_CFG_VAR_LEGACY diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/create_directory_helper.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/create_directory_helper.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,202 @@ +#include "StdAfx.h" +#include "create_directory_helper.h" +#include +#include + +namespace create_directory_helper +{ + static void create_path_internal(const char * p_path,t_size p_base,abort_callback & p_abort) { + pfc::string8_fastalloc temp; + auto fs = filesystem::get(p_path); + auto api_lock = file_lock_manager::get(); + for(t_size walk = p_base; p_path[walk]; walk++) { + if (p_path[walk] == '\\') { + temp.set_string(p_path,walk); + // 2024-03 Google Drive bug: + // Creating the same folder concurrently from multiple threads causes erratic behavior + // Thread that got here first behaves OK, others get "already exists" and return, but creating files in the folder fail with "path not found" + // Block other threads trying to do the same until we've finished + const auto lock = api_lock->acquire_write(temp, p_abort); + fs->make_directory(temp, p_abort); + } + } + } + + static bool is_valid_netpath_char(char p_char) { + return pfc::char_is_ascii_alphanumeric(p_char) || p_char == '_' || p_char == '-' || p_char == '.'; + } + + static bool test_localpath(const char * p_path) { + if (pfc::strcmp_partial(p_path,"file://") == 0) p_path += strlen("file://"); + return pfc::char_is_ascii_alpha(p_path[0]) && + p_path[1] == ':' && + p_path[2] == '\\'; + } + static bool test_netpath(const char * p_path) { + if (pfc::strcmp_partial(p_path,"file://") == 0) p_path += strlen("file://"); + if (*p_path != '\\') return false; + p_path++; + if (*p_path != '\\') return false; + p_path++; + if (!is_valid_netpath_char(*p_path)) return false; + p_path++; + while(is_valid_netpath_char(*p_path)) p_path++; + if (*p_path != '\\') return false; + return true; + } + + void create_path(const char * p_path,abort_callback & p_abort) { + if (test_localpath(p_path)) { + t_size walk = 0; + if (pfc::strcmp_partial(p_path,"file://") == 0) walk += strlen("file://"); + create_path_internal(p_path,walk + 3,p_abort); + } else if (test_netpath(p_path)) { + t_size walk = 0; + if (pfc::strcmp_partial(p_path,"file://") == 0) walk += strlen("file://"); + while(p_path[walk] == '\\') walk++; + while(p_path[walk] != 0 && p_path[walk] != '\\') walk++; + while(p_path[walk] == '\\') walk++; + while(p_path[walk] != 0 && p_path[walk] != '\\') walk++; + while(p_path[walk] == '\\') walk++; + create_path_internal(p_path,walk,p_abort); + } else { + pfc::throw_exception_with_message< exception_io > ("Could not create directory structure; unknown path format"); + } + } + +#ifdef _WIN32 + static bool is_bad_dirchar(char c) + { + return c==' ' || c=='.'; + } +#endif + + void make_path(const char * parent,const char * filename,const char * extension,bool allow_new_dirs,pfc::string8 & out,bool really_create_dirs,abort_callback & p_abort) + { + out.reset(); + if (parent && *parent) + { + out = parent; + out.fix_dir_separator('\\'); + } + bool last_char_is_dir_sep = true; + while(*filename) + { +#ifdef WIN32 + if (allow_new_dirs && is_bad_dirchar(*filename)) + { + const char * ptr = filename+1; + while(is_bad_dirchar(*ptr)) ptr++; + if (*ptr!='\\' && *ptr!='/') out.add_string(filename,ptr-filename); + filename = ptr; + if (*filename==0) break; + } +#endif + if (pfc::is_path_bad_char(*filename)) + { + if (allow_new_dirs && (*filename=='\\' || *filename=='/')) + { + if (!last_char_is_dir_sep) + { + if (really_create_dirs) try{filesystem::g_create_directory(out,p_abort);}catch(exception_io_already_exists const &){} + out.add_char('\\'); + last_char_is_dir_sep = true; + } + } + else + out.add_char('_'); + } + else + { + out.add_byte(*filename); + last_char_is_dir_sep = false; + } + filename++; + } + if (out.length()>0 && out[out.length()-1]=='\\') + { + out.add_string("noname"); + } + if (extension && *extension) + { + out.add_char('.'); + out.add_string(extension); + } + } +} + +pfc::string create_directory_helper::sanitize_formatted_path(pfc::stringp formatted, bool allowWC) { + return sanitize_formatted_path_ex(formatted, allowWC, pfc::io::path::charReplaceDefault); +}; + +pfc::string create_directory_helper::sanitize_formatted_path_ex(pfc::stringp formatted, bool allowWC, charReplace_t replace) { + pfc::string out; + t_size curSegBase = 0; + for (t_size walk = 0; ; ++walk) { + const char c = formatted[walk]; + const bool end = (c == 0); + if (end || pfc::io::path::isSeparator(c)) { + if (curSegBase < walk) { + pfc::string seg(formatted + curSegBase, walk - curSegBase); + out = pfc::io::path::combine(out, pfc::io::path::validateFileName(seg, allowWC, end /*preserve ext*/, replace)); + } + if (end) break; + curSegBase = walk + 1; + } + } + return out; +} + +void create_directory_helper::format_filename_ex(const metadb_handle_ptr & handle, titleformat_hook * p_hook, titleformat_object::ptr spec, const char * suffix, pfc::string_base & out) { + format_filename_ex(handle, p_hook, spec, suffix, out, pfc::io::path::charReplaceDefault); +} + +void create_directory_helper::format_filename_ex(const metadb_handle_ptr & handle,titleformat_hook * p_hook,titleformat_object::ptr spec,const char * suffix, pfc::string_base & out, charReplace_t replace) { + pfc::string_formatter formatted; + titleformat_text_filter_myimpl filter; + filter.m_replace = replace; + handle->format_title(p_hook,formatted,spec,&filter); + formatted << suffix; + out = sanitize_formatted_path_ex(formatted, false, replace).ptr(); +} +void create_directory_helper::format_filename(const metadb_handle_ptr & handle,titleformat_hook * p_hook,titleformat_object::ptr spec,pfc::string_base & out) { + format_filename_ex(handle, p_hook, spec, "", out); +} +void create_directory_helper::format_filename(const metadb_handle_ptr & handle,titleformat_hook * p_hook,const char * spec,pfc::string_base & out) +{ + service_ptr_t script; + if (titleformat_compiler::get()->compile(script,spec)) { + format_filename(handle, p_hook, script, out); + } else { + out.reset(); + } +} + +static bool substSanity(const char * subst) { + if (subst == nullptr) return false; + for (size_t w = 0; subst[w]; ++w) { + if (pfc::io::path::isSeparator(subst[w])) return false; + } + return true; +} + +void create_directory_helper::titleformat_text_filter_myimpl::write(const GUID & p_inputType,pfc::string_receiver & p_out,const char * p_data,t_size p_dataLength) { + if (p_inputType == titleformat_inputtypes::meta) { + pfc::string_formatter temp; + for(t_size walk = 0; walk < p_dataLength; ++walk) { + char c = p_data[walk]; + if (c == 0) break; + const char * subst = nullptr; + if (pfc::io::path::isSeparator(c)) { + if (m_replace) { + const char * proposed = m_replace(c); + if (substSanity(proposed)) subst = proposed; + } + if (subst == nullptr) subst = "-"; + } + if (subst != nullptr) temp.add_string(subst); + else temp.add_byte(c); + } + p_out.add_string(temp); + } else p_out.add_string(p_data,p_dataLength); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/create_directory_helper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/create_directory_helper.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,26 @@ +#pragma once + +#include +#include + +namespace create_directory_helper { + typedef std::function charReplace_t; + + void create_path(const char * p_path,abort_callback & p_abort); + void make_path(const char * parent,const char * filename,const char * extension,bool allow_new_dirs,pfc::string8 & out,bool b_really_create_dirs,abort_callback & p_dir_create_abort); + void format_filename(const metadb_handle_ptr & handle,titleformat_hook * p_hook,const char * spec,pfc::string_base & out); + void format_filename(const metadb_handle_ptr & handle,titleformat_hook * p_hook,titleformat_object::ptr spec,pfc::string_base & out); + void format_filename_ex(const metadb_handle_ptr & handle,titleformat_hook * p_hook,titleformat_object::ptr spec,const char * suffix, pfc::string_base & out); + void format_filename_ex(const metadb_handle_ptr & handle, titleformat_hook * p_hook, titleformat_object::ptr spec, const char * suffix, pfc::string_base & out, charReplace_t replace); + + + pfc::string sanitize_formatted_path(pfc::stringp str, bool allowWC = false); + pfc::string sanitize_formatted_path_ex(pfc::stringp str, bool allowWC, charReplace_t replace); + + class titleformat_text_filter_myimpl : public titleformat_text_filter { + public: + charReplace_t m_replace; + void write(const GUID & p_inputType,pfc::string_receiver & p_out,const char * p_data,t_size p_dataLength); + }; + +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/cue_creator.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/cue_creator.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,209 @@ +#include "StdAfx.h" +#include "cue_creator.h" +#include "../SDK/chapterizer.h" + +static pfc::string8 format_meta(const file_info& p_source, const char* p_name, bool p_allow_space = true) { + pfc::string8 temp, ret; + p_source.meta_format(p_name, temp); + temp.replace_byte('\"', '\''); + uReplaceString(ret, temp, pfc_infinite, "\x0d\x0a", 2, "\\", 1, false); + if (!p_allow_space) ret.replace_byte(' ', '_'); + ret.replace_nontext_chars(); + return ret; +} + +static bool is_meta_same_everywhere(const cue_creator::t_entry_list & p_list,const char * p_meta) +{ + pfc::string8_fastalloc reference,temp; + + bool first = true; + for(auto & iter : p_list) { + if ( ! iter.isTrackAudio() ) continue; + + if ( first ) { + first = false; + if (!iter.m_infos.meta_format(p_meta,reference)) return false; + } else { + if (!iter.m_infos.meta_format(p_meta,temp)) return false; + if (strcmp(temp,reference)!=0) return false; + } + } + + return true; +} + +#define g_eol "\r\n" + +namespace cue_creator +{ + pfc::string_formatter create(const t_entry_list& p_list) { + pfc::string_formatter ret; create(ret, p_list); return ret; + } + void create(pfc::string_formatter & p_out,const t_entry_list & p_data) + { + if (p_data.get_count() == 0) return; + bool album_artist_global = is_meta_same_everywhere(p_data,"album artist"), + artist_global = is_meta_same_everywhere(p_data,"artist"), + album_global = is_meta_same_everywhere(p_data,"album"), + genre_global = is_meta_same_everywhere(p_data,"genre"), + date_global = is_meta_same_everywhere(p_data,"date"), + discid_global = is_meta_same_everywhere(p_data,"discid"), + comment_global = is_meta_same_everywhere(p_data,"comment"), + catalog_global = is_meta_same_everywhere(p_data,"catalog"), + songwriter_global = is_meta_same_everywhere(p_data,"songwriter"); + + { + auto firstTrack = p_data.first(); + while( firstTrack.is_valid() && ! firstTrack->isTrackAudio() ) ++ firstTrack; + if ( firstTrack.is_valid() ) { + if (genre_global) { + p_out << "REM GENRE " << format_meta(firstTrack->m_infos,"genre") << g_eol; + } + if (date_global) { + p_out << "REM DATE " << format_meta(firstTrack->m_infos,"date") << g_eol; + } + if (discid_global) { + p_out << "REM DISCID " << format_meta(firstTrack->m_infos,"discid") << g_eol; + } + if (comment_global) { + p_out << "REM COMMENT " << format_meta(firstTrack->m_infos,"comment") << g_eol; + } + if (is_meta_same_everywhere(p_data, "discnumber")) { + p_out << "REM DISCNUMBER " << format_meta(firstTrack->m_infos, "discnumber") << g_eol; + } + if (is_meta_same_everywhere(p_data, "totaldiscs")) { + p_out << "REM TOTALDISCS " << format_meta(firstTrack->m_infos, "totaldiscs") << g_eol; + } + if (catalog_global) { + p_out << "CATALOG " << format_meta(firstTrack->m_infos,"catalog") << g_eol; + } + if (songwriter_global) { + p_out << "SONGWRITER \"" << format_meta(firstTrack->m_infos,"songwriter") << "\"" << g_eol; + } + + if (album_artist_global) + { + p_out << "PERFORMER \"" << format_meta(firstTrack->m_infos,"album artist") << "\"" << g_eol; + artist_global = false; + } + else if (artist_global) + { + p_out << "PERFORMER \"" << format_meta(firstTrack->m_infos,"artist") << "\"" << g_eol; + } + if (album_global) + { + p_out << "TITLE \"" << format_meta(firstTrack->m_infos,"album") << "\"" << g_eol; + } + + { + replaygain_info::t_text_buffer rgbuffer; + replaygain_info rg = firstTrack->m_infos.get_replaygain(); + if (rg.format_album_gain(rgbuffer)) + p_out << "REM REPLAYGAIN_ALBUM_GAIN " << rgbuffer << g_eol; + if (rg.format_album_peak(rgbuffer)) + p_out << "REM REPLAYGAIN_ALBUM_PEAK " << rgbuffer << g_eol; + } + + } + } + + pfc::string8 last_file; + + for(t_entry_list::const_iterator iter = p_data.first();iter.is_valid();++iter) + { + if (strcmp(last_file,iter->m_file) != 0) + { + auto fileType = iter->m_fileType; + if ( fileType.length() == 0 ) fileType = "WAVE"; + p_out << "FILE \"" << iter->m_file << "\" " << fileType << g_eol; + last_file = iter->m_file; + } + + { + auto trackType = iter->m_trackType; + if (trackType.length() == 0) trackType = "AUDIO"; + p_out << " TRACK " << pfc::format_int(iter->m_track_number,2) << " " << trackType << g_eol; + } + + + + if (iter->m_infos.meta_find("title") != pfc_infinite) + p_out << " TITLE \"" << format_meta(iter->m_infos,"title") << "\"" << g_eol; + + const bool bHaveArtist = iter->m_infos.meta_exists("artist"); + if (!artist_global && bHaveArtist) { + p_out << " PERFORMER \"" << format_meta(iter->m_infos,"artist") << "\"" << g_eol; + } else if (album_artist_global && !bHaveArtist) { + // special case: album artist set, track artist not set + p_out << " PERFORMER \"\"" << g_eol; + } + + if (!songwriter_global && iter->m_infos.meta_find("songwriter") != pfc_infinite) { + p_out << " SONGWRITER \"" << format_meta(iter->m_infos,"songwriter") << "\"" << g_eol; + } + + if (iter->m_infos.meta_find("isrc") != pfc_infinite) { + p_out << " ISRC " << format_meta(iter->m_infos,"isrc") << g_eol; + } + + if (!date_global && iter->m_infos.meta_find("date") != pfc_infinite) { + p_out << " REM DATE " << format_meta(iter->m_infos,"date") << g_eol; + } + if (!comment_global && iter->m_infos.meta_exists("comment")) { + p_out << " REM COMMENT " << format_meta(iter->m_infos, "comment") << g_eol; + } + + + { + replaygain_info::t_text_buffer rgbuffer; + replaygain_info rg = iter->m_infos.get_replaygain(); + if (rg.format_track_gain(rgbuffer)) + p_out << " REM REPLAYGAIN_TRACK_GAIN " << rgbuffer << g_eol; + if (rg.format_track_peak(rgbuffer)) + p_out << " REM REPLAYGAIN_TRACK_PEAK " << rgbuffer << g_eol; + } + + if (!iter->m_flags.is_empty()) { + p_out << " FLAGS " << iter->m_flags << g_eol; + } + + if (iter->m_index_list.m_positions[0] < iter->m_index_list.m_positions[1]) + { + if (iter->m_index_list.m_positions[0] < 0) + p_out << " PREGAP " << cuesheet_format_index_time(iter->m_index_list.m_positions[1] - iter->m_index_list.m_positions[0]) << g_eol; + else + p_out << " INDEX 00 " << cuesheet_format_index_time(iter->m_index_list.m_positions[0]) << g_eol; + } + + p_out << " INDEX 01 " << cuesheet_format_index_time(iter->m_index_list.m_positions[1]) << g_eol; + + for(unsigned n=2;nm_index_list.m_positions[n] > 0;n++) + { + p_out << " INDEX " << pfc::format_uint(n,2) << " " << cuesheet_format_index_time(iter->m_index_list.m_positions[n]) << g_eol; + } + + // p_out << " INDEX 01 " << cuesheet_format_index_time(iter->m_offset) << g_eol; + } + } + + + void t_entry::set_simple_index(double p_time) + { + m_index_list.reset(); + m_index_list.m_positions[0] = m_index_list.m_positions[1] = p_time; + } + void t_entry::set_index01(double index0, double index1) { + PFC_ASSERT( index0 <= index1 ); + m_index_list.reset(); + m_index_list.m_positions[0] = index0; + m_index_list.m_positions[1] = index1; + } + + bool t_entry::isTrackAudio() const { + PFC_ASSERT( m_trackType.length() > 0 ); + return pfc::stringEqualsI_ascii( m_trackType, "AUDIO" ); + } +} + + + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/cue_creator.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/cue_creator.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,26 @@ +#pragma once + +#include "cuesheet_index_list.h" +#include + +namespace cue_creator +{ + struct t_entry + { + file_info_impl m_infos; + pfc::string8 m_file, m_fileType, m_flags, m_trackType = "AUDIO"; + unsigned m_track_number; + + bool isTrackAudio() const; + + t_cuesheet_index_list m_index_list; + + void set_simple_index(double p_time); + void set_index01(double index0, double index1); + }; + + typedef pfc::chain_list_v2_t t_entry_list; + + void create(pfc::string_formatter & p_out,const t_entry_list & p_list); + pfc::string_formatter create(const t_entry_list& p_list); +}; \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/cue_parser.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/cue_parser.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,874 @@ +#include "StdAfx.h" +#include "cue_parser.h" + + +#define maximumCueTrackNumber 999 + +namespace { + PFC_DECLARE_EXCEPTION(exception_cue,pfc::exception,"Invalid cuesheet"); + PFC_DECLARE_EXCEPTION(exception_cue_tracktype, exception_cue, "Not an audio track") +} + +[[noreturn]] static void cue_fail(const char* msg) { + pfc::throw_exception_with_message< exception_cue >(msg); +} + +static bool is_numeric(char c) {return c>='0' && c<='9';} + + +static bool is_spacing(char c) +{ + return c == ' ' || c == '\t'; +} + +static bool is_linebreak(char c) +{ + return c == '\n' || c == '\r'; +} + +static void validate_file_type(const char * p_type,t_size p_type_length) { + const char* const allowedTypes[] = { + "WAVE", "MP3", "AIFF", // standard typers + "APE", "FLAC", "WV", "WAVPACK", "MP4", // common user-entered types + "BINARY" // BINARY + }; + for (auto walk : allowedTypes) { + if (pfc::stringEqualsI_ascii_ex(p_type, p_type_length, walk, SIZE_MAX)) return; + } + pfc::throw_exception_with_message< exception_cue >(PFC_string_formatter() << "expected WAVE, MP3 or AIFF, got : \"" << pfc::string_part(p_type,p_type_length) << "\""); +} + +namespace { + + class NOVTABLE cue_parser_callback + { + public: + virtual void on_file(const char * p_file,t_size p_file_length,const char * p_type,t_size p_type_length) = 0; + virtual void on_track(unsigned p_index,const char * p_type,t_size p_type_length) = 0; + virtual void on_pregap(unsigned p_value) = 0; + virtual void on_index(unsigned p_index,unsigned p_value) = 0; + virtual void on_title(const char * p_title,t_size p_title_length) = 0; + virtual void on_performer(const char * p_performer,t_size p_performer_length) = 0; + virtual void on_songwriter(const char * p_songwriter,t_size p_songwriter_length) = 0; + virtual void on_isrc(const char * p_isrc,t_size p_isrc_length) = 0; + virtual void on_catalog(const char * p_catalog,t_size p_catalog_length) = 0; + virtual void on_comment(const char * p_comment,t_size p_comment_length) = 0; + virtual void on_flags(const char * p_flags,t_size p_flags_length) = 0; + }; + + class NOVTABLE cue_parser_callback_meta : public cue_parser_callback + { + public: + virtual void on_file(const char * p_file,t_size p_file_length,const char * p_type,t_size p_type_length) = 0; + virtual void on_track(unsigned p_index,const char * p_type,t_size p_type_length) = 0; + virtual void on_pregap(unsigned p_value) = 0; + virtual void on_index(unsigned p_index,unsigned p_value) = 0; + virtual void on_meta(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length) = 0; + protected: + static bool is_known_meta(const char * p_name,t_size p_length) + { + static const char * metas[] = {"genre","date","discid","comment","replaygain_track_gain","replaygain_track_peak","replaygain_album_gain","replaygain_album_peak", "discnumber", "totaldiscs"}; + for (const char* m : metas) { + if (!stricmp_utf8_ex(p_name, p_length, m, SIZE_MAX)) return true; + } + return false; + } + + void on_comment(const char * p_comment,t_size p_comment_length) + { + unsigned ptr = 0; + while(ptr < p_comment_length && !is_spacing(p_comment[ptr])) ptr++; + if (is_known_meta(p_comment, ptr)) + { + unsigned name_length = ptr; + while(ptr < p_comment_length && is_spacing(p_comment[ptr])) ptr++; + if (ptr < p_comment_length) + { + if (p_comment[ptr] == '\"') + { + ptr++; + unsigned value_base = ptr; + while(ptr < p_comment_length && p_comment[ptr] != '\"') ptr++; + if (ptr == p_comment_length) pfc::throw_exception_with_message("invalid REM syntax"); + if (ptr > value_base) on_meta(p_comment,name_length,p_comment + value_base,ptr - value_base); + } + else + { + unsigned value_base = ptr; + while(ptr < p_comment_length /*&& !is_spacing(p_comment[ptr])*/) ptr++; + if (ptr > value_base) on_meta(p_comment,name_length,p_comment + value_base,ptr - value_base); + } + } + } + } + void on_title(const char * p_title,t_size p_title_length) + { + on_meta("title",pfc_infinite,p_title,p_title_length); + } + void on_songwriter(const char * p_songwriter,t_size p_songwriter_length) { + on_meta("songwriter",pfc_infinite,p_songwriter,p_songwriter_length); + } + void on_performer(const char * p_performer,t_size p_performer_length) + { + on_meta("artist",pfc_infinite,p_performer,p_performer_length); + } + + void on_isrc(const char * p_isrc,t_size p_isrc_length) + { + on_meta("isrc",pfc_infinite,p_isrc,p_isrc_length); + } + void on_catalog(const char * p_catalog,t_size p_catalog_length) + { + on_meta("catalog",pfc_infinite,p_catalog,p_catalog_length); + } + void on_flags(const char * p_flags,t_size p_flags_length) {} + }; + + + class cue_parser_callback_retrievelist : public cue_parser_callback + { + public: + cue_parser_callback_retrievelist(cue_parser::t_cue_entry_list& p_out) : m_out(p_out) {} + + void on_file(const char * p_file,t_size p_file_length,const char * p_type,t_size p_type_length) + { + validate_file_type(p_type,p_type_length); + m_file.set_string(p_file,p_file_length); + m_fileType.set_string(p_type, p_type_length); + } + + void on_track(unsigned p_index,const char * p_type,t_size p_type_length) + { + finalize_track(); // finalize previous track + + m_trackIsAudio = stricmp_utf8_ex(p_type,p_type_length,"audio",pfc_infinite) == 0; + if (m_file.is_empty()) pfc::throw_exception_with_message("declaring a track with no file set"); + m_trackfile = m_file; + m_trackFileType = m_fileType; + m_track = p_index; + } + + void on_pregap(unsigned p_value) {m_pregap = (double) p_value / 75.0;} + + void on_index(unsigned p_index,unsigned p_value) + { + if (p_index < t_cuesheet_index_list::count) + { + switch(p_index) + { + case 0: m_index0_set = true; break; + case 1: m_index1_set = true; break; + } + m_index_list.m_positions[p_index] = (double) p_value / 75.0; + } + } + + void on_title(const char * p_title,t_size p_title_length) {} + void on_performer(const char * p_performer,t_size p_performer_length) {} + void on_songwriter(const char * p_songwriter,t_size p_songwriter_length) {} + void on_isrc(const char * p_isrc,t_size p_isrc_length) {} + void on_catalog(const char * p_catalog,t_size p_catalog_length) {} + void on_comment(const char * p_comment,t_size p_comment_length) {} + void on_flags(const char * p_flags,t_size p_flags_length) {} + + void finalize() + { + finalize_track(); // finalize last track + sanity(); + } + + private: + void sanity() { + int trk = 0; + for (auto& iter : m_out) { + int i = iter.m_track_number; + if (i <= trk) cue_fail("incorrect track numbering"); + trk = i; + } + } + void finalize_track() + { + if ( m_track != 0 && m_trackIsAudio ) { + if (!m_index1_set) cue_fail("INDEX 01 not set"); + if (!m_index0_set) m_index_list.m_positions[0] = m_index_list.m_positions[1] - m_pregap; + if (!m_index_list.is_valid()) cue_fail("invalid index list"); + + cue_parser::t_cue_entry_list::iterator iter; + iter = m_out.insert_last(); + if (m_trackfile.is_empty()) cue_fail("track has no file assigned"); + iter->m_file = m_trackfile; + iter->m_fileType = m_trackFileType; + iter->m_track_number = m_track; + iter->m_indexes = m_index_list; + } + + m_index_list.reset(); + m_index0_set = false; + m_index1_set = false; + m_pregap = 0; + + m_track = 0; m_trackIsAudio = false; + } + + bool m_index0_set = false,m_index1_set = false; + t_cuesheet_index_list m_index_list; + double m_pregap = 0; + unsigned m_track = 0; + bool m_trackIsAudio = false; + pfc::string8 m_file,m_fileType,m_trackfile,m_trackFileType; + cue_parser::t_cue_entry_list & m_out; + }; + + class cue_parser_callback_retrieveinfo : public cue_parser_callback_meta + { + public: + cue_parser_callback_retrieveinfo(file_info & p_out,unsigned p_wanted_track) : m_out(p_out), m_wanted_track(p_wanted_track), m_track(0), m_is_va(false), m_index0_set(false), m_index1_set(false), m_pregap(0), m_totaltracks(0) {} + + void on_file(const char * p_file,t_size p_file_length,const char * p_type,t_size p_type_length) {} + + void on_track(unsigned p_index,const char * p_type,t_size p_type_length) + { + if (p_index == 0) cue_fail("invalid TRACK index"); + if (p_index == m_wanted_track) + { + if (stricmp_utf8_ex(p_type,p_type_length,"audio",pfc_infinite)) throw exception_cue_tracktype(); + } + m_track = p_index; + m_totaltracks++; + } + + void on_pregap(unsigned p_value) {if (m_track == m_wanted_track) m_pregap = (double) p_value / 75.0;} + + void on_index(unsigned p_index,unsigned p_value) + { + if (m_track == m_wanted_track && p_index < t_cuesheet_index_list::count) + { + switch(p_index) + { + case 0: m_index0_set = true; break; + case 1: m_index1_set = true; break; + } + m_indexes.m_positions[p_index] = (double) p_value / 75.0; + } + } + + + void on_meta(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length) + { + t_meta_list::iterator iter; + if (m_track == 0) //globals + { + //convert global title to album + if (!stricmp_utf8_ex(p_name,p_name_length,"title",pfc_infinite)) + { + p_name = "album"; + p_name_length = 5; + } + else if (!stricmp_utf8_ex(p_name,p_name_length,"artist",pfc_infinite)) + { + m_album_artist.set_string(p_value,p_value_length); + } + + iter = m_globals.insert_last(); + } + else + { + if (!m_is_va) + { + if (!stricmp_utf8_ex(p_name,p_name_length,"artist",pfc_infinite)) + { + if (!m_album_artist.is_empty()) + { + if (stricmp_utf8_ex(p_value,p_value_length,m_album_artist,m_album_artist.length())) m_is_va = true; + } + } + } + + if (m_track == m_wanted_track) //locals + { + iter = m_locals.insert_last(); + } + } + if (iter.is_valid()) + { + iter->m_name.set_string(p_name,p_name_length); + iter->m_value.set_string(p_value,p_value_length); + } + } + + void _meta_set(const char* key, const pfc::string8 & value) { + if ( value.length() > 0 ) m_out.meta_set( key, value ); + } + + void finalize() + { + if (!m_index1_set) pfc::throw_exception_with_message< exception_cue > ("INDEX 01 not set"); + if (!m_index0_set) m_indexes.m_positions[0] = m_indexes.m_positions[1] - m_pregap; + m_indexes.to_infos(m_out); + + replaygain_info rg; + rg.reset(); + t_meta_list::const_iterator iter; + + if (m_is_va) + { + //clean up VA mess + + t_meta_list::const_iterator iter_global,iter_local; + + iter_global = find_first_field(m_globals,"artist"); + iter_local = find_first_field(m_locals,"artist"); + if (iter_global.is_valid()) + { + _meta_set("album artist",iter_global->m_value); + if (iter_local.is_valid()) { + _meta_set("artist",iter_local->m_value); + } else { + _meta_set("artist",iter_global->m_value); + } + } + else + { + if (iter_local.is_valid()) _meta_set("artist",iter_local->m_value); + } + + + wipe_field(m_globals,"artist"); + wipe_field(m_locals,"artist"); + + } + + for(iter=m_globals.first();iter.is_valid();iter++) + { + if (!rg.set_from_meta(iter->m_name,iter->m_value)) + _meta_set(iter->m_name,iter->m_value); + } + for(iter=m_locals.first();iter.is_valid();iter++) + { + if (!rg.set_from_meta(iter->m_name,iter->m_value)) + _meta_set(iter->m_name,iter->m_value); + } + m_out.meta_set("tracknumber",PFC_string_formatter() << m_wanted_track); + m_out.meta_set("totaltracks", PFC_string_formatter() << m_totaltracks); + m_out.set_replaygain(rg); + + } + private: + struct t_meta_entry { + pfc::string8 m_name,m_value; + }; + typedef pfc::chain_list_v2_t t_meta_list; + + static t_meta_list::const_iterator find_first_field(t_meta_list const & p_list,const char * p_field) + { + t_meta_list::const_iterator iter; + for(iter=p_list.first();iter.is_valid();++iter) + { + if (!stricmp_utf8(p_field,iter->m_name)) return iter; + } + return t_meta_list::const_iterator();//null iterator + } + + static void wipe_field(t_meta_list & p_list,const char * p_field) + { + t_meta_list::iterator iter; + for(iter=p_list.first();iter.is_valid();) + { + if (!stricmp_utf8(p_field,iter->m_name)) + { + t_meta_list::iterator temp = iter; + ++temp; + p_list.remove_single(iter); + iter = temp; + } + else + { + ++iter; + } + } + } + + t_meta_list m_globals,m_locals; + file_info & m_out; + unsigned m_wanted_track, m_track,m_totaltracks; + pfc::string8 m_album_artist; + bool m_is_va; + t_cuesheet_index_list m_indexes; + bool m_index0_set,m_index1_set; + double m_pregap; + }; + +}; + +static pfc::string_part_ref cue_line_argument( const char * base, size_t length ) { + const char * end = base + length; + while(base < end && is_spacing(base[0]) ) ++base; + while(base < end && is_spacing(end[-1]) ) --end; + if ( base + 1 < end ) { + if ( base[0] == '\"' && end[-1] == '\"' ) { + ++base; --end; + } + } + return pfc::string_part(base, end-base); +} + +static void g_parse_cue_line(const char * p_line,t_size p_line_length,cue_parser_callback & p_callback) +{ + t_size ptr = 0; + while(ptr < p_line_length && !is_spacing(p_line[ptr])) ptr++; + if (!stricmp_utf8_ex(p_line,ptr,"file",pfc_infinite)) + { + while(ptr < p_line_length && is_spacing(p_line[ptr])) ptr++; + t_size file_base,file_length, type_base,type_length; + + if (p_line[ptr] == '\"') + { + ptr++; + file_base = ptr; + while(ptr < p_line_length && p_line[ptr] != '\"') ptr++; + if (ptr == p_line_length) pfc::throw_exception_with_message< exception_cue > ("invalid FILE syntax"); + file_length = ptr - file_base; + ptr++; + while(ptr < p_line_length && is_spacing(p_line[ptr])) ptr++; + } + else + { + file_base = ptr; + while(ptr < p_line_length && !is_spacing(p_line[ptr])) ptr++; + file_length = ptr - file_base; + while(ptr < p_line_length && is_spacing(p_line[ptr])) ptr++; + } + + type_base = ptr; + while(ptr < p_line_length && !is_spacing(p_line[ptr])) ptr++; + type_length = ptr - type_base; + while(ptr < p_line_length && is_spacing(p_line[ptr])) ptr++; + + if (ptr != p_line_length || file_length == 0 || type_length == 0) pfc::throw_exception_with_message< exception_cue > ("invalid FILE syntax"); + + p_callback.on_file(p_line + file_base, file_length, p_line + type_base, type_length); + } + else if (!stricmp_utf8_ex(p_line,ptr,"track",pfc_infinite)) + { + while(ptr < p_line_length && is_spacing(p_line[ptr])) ptr++; + + t_size track_base = ptr, track_length; + while(ptr < p_line_length && !is_spacing(p_line[ptr])) + { + if (!is_numeric(p_line[ptr])) pfc::throw_exception_with_message< exception_cue > ("invalid TRACK syntax"); + ptr++; + } + track_length = ptr - track_base; + while(ptr < p_line_length && is_spacing(p_line[ptr])) ptr++; + + t_size type_base = ptr, type_length; + while(ptr < p_line_length && !is_spacing(p_line[ptr])) ptr++; + type_length = ptr - type_base; + + while(ptr < p_line_length && is_spacing(p_line[ptr])) ptr++; + if (ptr != p_line_length || type_length == 0) pfc::throw_exception_with_message< exception_cue > ("invalid TRACK syntax"); + unsigned track = pfc::atoui_ex(p_line+track_base,track_length); + if (track < 1 || track > maximumCueTrackNumber) pfc::throw_exception_with_message< exception_cue > ("invalid track number"); + + p_callback.on_track(track,p_line + type_base, type_length); + } + else if (!stricmp_utf8_ex(p_line,ptr,"index",pfc_infinite)) + { + while(ptr < p_line_length && is_spacing(p_line[ptr])) ptr++; + + t_size index_base,index_length, time_base,time_length; + index_base = ptr; + while(ptr < p_line_length && !is_spacing(p_line[ptr])) + { + if (!is_numeric(p_line[ptr])) pfc::throw_exception_with_message< exception_cue > ("invalid INDEX syntax" ); + ptr++; + } + index_length = ptr - index_base; + + while(ptr < p_line_length && is_spacing(p_line[ptr])) ptr++; + time_base = ptr; + while(ptr < p_line_length && !is_spacing(p_line[ptr])) + { + if (!is_numeric(p_line[ptr]) && p_line[ptr] != ':') + pfc::throw_exception_with_message< exception_cue > ("invalid INDEX syntax"); + ptr++; + } + time_length = ptr - time_base; + + while(ptr < p_line_length && is_spacing(p_line[ptr])) ptr++; + + if (ptr != p_line_length || index_length == 0 || time_length == 0) + pfc::throw_exception_with_message< exception_cue > ("invalid INDEX syntax"); + + unsigned index = pfc::atoui_ex(p_line+index_base,index_length); + if (index > maximumCueTrackNumber) pfc::throw_exception_with_message< exception_cue > ("invalid INDEX syntax"); + unsigned time = cuesheet_parse_index_time_ticks_e(p_line + time_base,time_length); + + p_callback.on_index(index,time); + } + else if (!stricmp_utf8_ex(p_line,ptr,"pregap",pfc_infinite)) + { + while(ptr < p_line_length && is_spacing(p_line[ptr])) ptr++; + + t_size time_base, time_length; + time_base = ptr; + while(ptr < p_line_length && !is_spacing(p_line[ptr])) + { + if (!is_numeric(p_line[ptr]) && p_line[ptr] != ':') + pfc::throw_exception_with_message< exception_cue > ("invalid PREGAP syntax"); + ptr++; + } + time_length = ptr - time_base; + + while(ptr < p_line_length && is_spacing(p_line[ptr])) ptr++; + + if (ptr != p_line_length || time_length == 0) + pfc::throw_exception_with_message< exception_cue > ("invalid PREGAP syntax"); + + unsigned time = cuesheet_parse_index_time_ticks_e(p_line + time_base,time_length); + + p_callback.on_pregap(time); + } + else if (!stricmp_utf8_ex(p_line,ptr,"title",pfc_infinite)) + { + auto arg = cue_line_argument(p_line+ptr, p_line_length-ptr); + if ( arg.m_len > 0 ) p_callback.on_title( arg.m_ptr, arg.m_len ); + } + else if (!stricmp_utf8_ex(p_line,ptr,"performer",pfc_infinite)) + { + auto arg = cue_line_argument(p_line + ptr, p_line_length - ptr); + // 2021-01 fix: allow blank performer + /*if (arg.m_len > 0)*/ p_callback.on_performer(arg.m_ptr, arg.m_len); + } + else if (!stricmp_utf8_ex(p_line,ptr,"songwriter",pfc_infinite)) + { + auto arg = cue_line_argument(p_line + ptr, p_line_length - ptr); + if (arg.m_len > 0) p_callback.on_songwriter(arg.m_ptr, arg.m_len); + } + else if (!stricmp_utf8_ex(p_line,ptr,"isrc",pfc_infinite)) + { + while(ptr < p_line_length && is_spacing(p_line[ptr])) ptr++; + t_size length = p_line_length - ptr; + if (length == 0) pfc::throw_exception_with_message< exception_cue > ("invalid ISRC syntax"); + p_callback.on_isrc(p_line+ptr,length); + } + else if (!stricmp_utf8_ex(p_line,ptr,"catalog",pfc_infinite)) + { + while(ptr < p_line_length && is_spacing(p_line[ptr])) ptr++; + t_size length = p_line_length - ptr; + if (length == 0) pfc::throw_exception_with_message< exception_cue > ("invalid CATALOG syntax"); + p_callback.on_catalog(p_line+ptr,length); + } + else if (!stricmp_utf8_ex(p_line,ptr,"flags",pfc_infinite)) + { + while(ptr < p_line_length && is_spacing(p_line[ptr])) ptr++; + if (ptr < p_line_length) + p_callback.on_flags(p_line + ptr, p_line_length - ptr); + } + else if (!stricmp_utf8_ex(p_line,ptr,"rem",pfc_infinite)) + { + while(ptr < p_line_length && is_spacing(p_line[ptr])) ptr++; + if (ptr < p_line_length) + p_callback.on_comment(p_line + ptr, p_line_length - ptr); + } + else if (!stricmp_utf8_ex(p_line,ptr,"postgap",pfc_infinite)) { + pfc::throw_exception_with_message< exception_cue > ("POSTGAP is not supported"); + } else if (!stricmp_utf8_ex(p_line,ptr,"cdtextfile",pfc_infinite)) { + //do nothing + } + else pfc::throw_exception_with_message< exception_cue > ("unknown cuesheet item"); +} + +static void g_parse_cue(const char * p_cuesheet,cue_parser_callback & p_callback) +{ + const char * parseptr = p_cuesheet; + t_size lineidx = 1; + while(*parseptr) + { + while(is_spacing(*parseptr)) parseptr++; + if (*parseptr) + { + t_size length = 0; + while(parseptr[length] && !is_linebreak(parseptr[length])) length++; + if (length > 0) { + try { + g_parse_cue_line(parseptr,length,p_callback); + } catch(exception_cue const & e) {//rethrow with line info + pfc::throw_exception_with_message< exception_cue > (PFC_string_formatter() << e.what() << " (line " << (unsigned)lineidx << ")"); + } + } + parseptr += length; + while(is_linebreak(*parseptr)) { + if (*parseptr == '\n') lineidx++; + parseptr++; + } + } + } +} + +void cue_parser::parse(const char *p_cuesheet,t_cue_entry_list & p_out) { + try { + cue_parser_callback_retrievelist callback(p_out); + g_parse_cue(p_cuesheet,callback); + callback.finalize(); + } catch(exception_cue const & e) { + pfc::throw_exception_with_message(PFC_string_formatter() << "Error parsing cuesheet: " << e.what()); + } +} +void cue_parser::parse_info(const char * p_cuesheet,file_info & p_info,unsigned p_index) { + try { + cue_parser_callback_retrieveinfo callback(p_info,p_index); + g_parse_cue(p_cuesheet,callback); + callback.finalize(); + } catch(exception_cue const & e) { + pfc::throw_exception_with_message< exception_bad_cuesheet > (PFC_string_formatter() << "Error parsing cuesheet: " << e.what()); + } +} + +namespace { + + class cue_parser_callback_retrievecount : public cue_parser_callback + { + public: + cue_parser_callback_retrievecount() : m_count(0) {} + unsigned get_count() const {return m_count;} + void on_file(const char * p_file,t_size p_file_length,const char * p_type,t_size p_type_length) {} + void on_track(unsigned p_index,const char * p_type,t_size p_type_length) {m_count++;} + void on_pregap(unsigned p_value) {} + void on_index(unsigned p_index,unsigned p_value) {} + void on_title(const char * p_title,t_size p_title_length) {} + void on_performer(const char * p_performer,t_size p_performer_length) {} + void on_isrc(const char * p_isrc,t_size p_isrc_length) {} + void on_catalog(const char * p_catalog,t_size p_catalog_length) {} + void on_comment(const char * p_comment,t_size p_comment_length) {} + void on_flags(const char * p_flags,t_size p_flags_length) {} + private: + unsigned m_count; + }; + + class cue_parser_callback_retrievecreatorentries : public cue_parser_callback + { + public: + cue_parser_callback_retrievecreatorentries(cue_creator::t_entry_list & p_out) : m_out(p_out), m_track(0), m_pregap(0), m_index0_set(false), m_index1_set(false) {} + + void on_file(const char * p_file,t_size p_file_length,const char * p_type,t_size p_type_length) { + validate_file_type(p_type,p_type_length); + m_file.set_string(p_file,p_file_length); + m_fileType.set_string(p_type, p_type_length); + } + + void on_track(unsigned p_index,const char * p_type,t_size p_type_length) + { + finalize_track(); + + m_trackType.set_string( p_type, p_type_length ); + + //if (p_index != m_track + 1) throw exception_cue("cuesheet tracks out of order",0); + + if (m_file.is_empty()) pfc::throw_exception_with_message< exception_cue > ("declaring a track with no file set"); + m_trackfile = m_file; + m_trackFileType = m_fileType; + m_track = p_index; + } + + void on_pregap(unsigned p_value) + { + m_pregap = (double) p_value / 75.0; + } + + void on_index(unsigned p_index,unsigned p_value) + { + if (p_index < t_cuesheet_index_list::count) + { + switch(p_index) + { + case 0: m_index0_set = true; break; + case 1: m_index1_set = true; break; + } + m_indexes.m_positions[p_index] = (double) p_value / 75.0; + } + } + void on_title(const char * p_title,t_size p_title_length) {} + void on_performer(const char * p_performer,t_size p_performer_length) {} + void on_songwriter(const char * p_performer,t_size p_performer_length) {} + void on_isrc(const char * p_isrc,t_size p_isrc_length) {} + void on_catalog(const char * p_catalog,t_size p_catalog_length) {} + void on_comment(const char * p_comment,t_size p_comment_length) {} + void finalize() + { + finalize_track(); + } + void on_flags(const char * p_flags,t_size p_flags_length) { + m_flags.set_string(p_flags,p_flags_length); + } + private: + void finalize_track() + { + if ( m_track != 0 ) { + if (m_track < 1 || m_track > maximumCueTrackNumber) pfc::throw_exception_with_message< exception_cue > ("track number out of range"); + if (!m_index1_set) pfc::throw_exception_with_message< exception_cue > ("INDEX 01 not set"); + if (!m_index0_set) m_indexes.m_positions[0] = m_indexes.m_positions[1] - m_pregap; + if (!m_indexes.is_valid()) pfc::throw_exception_with_message< exception_cue > ("invalid index list"); + + cue_creator::t_entry_list::iterator iter; + iter = m_out.insert_last(); + iter->m_track_number = m_track; + iter->m_file = m_trackfile; + iter->m_fileType = m_trackFileType; + iter->m_index_list = m_indexes; + iter->m_flags = m_flags; + iter->m_trackType = m_trackType; + } + m_pregap = 0; + m_indexes.reset(); + m_index0_set = m_index1_set = false; + m_flags.reset(); + m_trackType.reset(); + } + + bool m_index0_set,m_index1_set; + double m_pregap; + unsigned m_track; + cue_creator::t_entry_list & m_out; + pfc::string8 m_file, m_fileType,m_trackfile, m_trackFileType, m_flags, m_trackType; + t_cuesheet_index_list m_indexes; + }; +} + +void cue_parser::parse_full(const char * p_cuesheet,cue_creator::t_entry_list & p_out) { + try { + { + cue_parser_callback_retrievecreatorentries callback(p_out); + g_parse_cue(p_cuesheet,callback); + callback.finalize(); + } + + { + cue_creator::t_entry_list::iterator iter; + for(iter=p_out.first();iter.is_valid();++iter) { + if ( iter->isTrackAudio() ) { + cue_parser_callback_retrieveinfo callback(iter->m_infos,iter->m_track_number); + g_parse_cue(p_cuesheet,callback); + callback.finalize(); + } + } + } + } catch(exception_cue const & e) { + pfc::throw_exception_with_message< exception_bad_cuesheet > (PFC_string_formatter() << "Error parsing cuesheet: " << e.what()); + } +} + +namespace file_info_record_helper { + namespace { + class __file_info_record__info__enumerator { + public: + __file_info_record__info__enumerator(file_info & p_out) : m_out(p_out) {} + void operator() (const char * p_name, const char * p_value) { m_out.__info_add_unsafe(p_name, p_value); } + private: + file_info & m_out; + }; + + class __file_info_record__meta__enumerator { + public: + __file_info_record__meta__enumerator(file_info & p_out) : m_out(p_out) {} + template void operator() (const char * p_name, const t_value & p_value) { + t_size index = ~0; + for (typename t_value::const_iterator iter = p_value.first(); iter.is_valid(); ++iter) { + if (index == ~0) index = m_out.__meta_add_unsafe(p_name, *iter); + else m_out.meta_add_value(index, *iter); + } + } + private: + file_info & m_out; + }; + } + + void file_info_record::from_info(const file_info & p_info) { + reset(); + m_length = p_info.get_length(); + m_replaygain = p_info.get_replaygain(); + from_info_overwrite_meta(p_info); + from_info_overwrite_info(p_info); + } + void file_info_record::to_info(file_info & p_info) const { + p_info.reset(); + p_info.set_length(m_length); + p_info.set_replaygain(m_replaygain); + + { + __file_info_record__info__enumerator e(p_info); + m_info.enumerate(e); + } + { + __file_info_record__meta__enumerator e(p_info); + m_meta.enumerate(e); + } + } + + void file_info_record::reset() { + m_meta.remove_all(); m_info.remove_all(); + m_length = 0; + m_replaygain = replaygain_info_invalid; + } + + void file_info_record::from_info_overwrite_info(const file_info & p_info) { + for (t_size infowalk = 0, infocount = p_info.info_get_count(); infowalk < infocount; ++infowalk) { + m_info.set(p_info.info_enum_name(infowalk), p_info.info_enum_value(infowalk)); + } + } + void file_info_record::from_info_overwrite_meta(const file_info & p_info) { + for (t_size metawalk = 0, metacount = p_info.meta_get_count(); metawalk < metacount; ++metawalk) { + const t_size valuecount = p_info.meta_enum_value_count(metawalk); + if (valuecount > 0) { + t_meta_value & entry = m_meta.find_or_add(p_info.meta_enum_name(metawalk)); + entry.remove_all(); + for (t_size valuewalk = 0; valuewalk < valuecount; ++valuewalk) { + entry.add_item(p_info.meta_enum_value(metawalk, valuewalk)); + } + } + } + } + + void file_info_record::from_info_overwrite_rg(const file_info & p_info) { + m_replaygain = replaygain_info::g_merge(m_replaygain, p_info.get_replaygain()); + } + + void file_info_record::merge_overwrite(const file_info & p_info) { + from_info_overwrite_info(p_info); + from_info_overwrite_meta(p_info); + from_info_overwrite_rg(p_info); + } + + void file_info_record::transfer_meta_entry(const char * p_name, const file_info & p_info, t_size p_index) { + const t_size count = p_info.meta_enum_value_count(p_index); + if (count == 0) { + m_meta.remove(p_name); + } else { + t_meta_value & val = m_meta.find_or_add(p_name); + val.remove_all(); + for (t_size walk = 0; walk < count; ++walk) { + val.add_item(p_info.meta_enum_value(p_index, walk)); + } + } + } + + void file_info_record::meta_set(const char * p_name, const char * p_value) { + m_meta.find_or_add(p_name).set_single(p_value); + } + + const file_info_record::t_meta_value * file_info_record::meta_query_ptr(const char * p_name) const { + return m_meta.query_ptr(p_name); + } + size_t file_info_record::meta_value_count(const char* name) const { + auto v = meta_query_ptr(name); + if (v == nullptr) return 0; + return v->get_count(); + } + + + void file_info_record::from_info_set_meta(const file_info & p_info) { + m_meta.remove_all(); + from_info_overwrite_meta(p_info); + } + +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/cue_parser.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/cue_parser.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,403 @@ +#pragma once + +#include "cue_creator.h" +#include +#include + +//HINT: for info on how to generate an embedded cuesheet enabled input, see the end of this header. + + + +namespace file_info_record_helper { + + class file_info_record { + public: + typedef pfc::chain_list_v2_t t_meta_value; + typedef pfc::map_t t_meta_map; + typedef pfc::map_t t_info_map; + + file_info_record() : m_replaygain(replaygain_info_invalid), m_length(0) {} + + replaygain_info get_replaygain() const {return m_replaygain;} + void set_replaygain(const replaygain_info & p_replaygain) {m_replaygain = p_replaygain;} + double get_length() const {return m_length;} + void set_length(double p_length) {m_length = p_length;} + + void reset(); + void from_info_overwrite_info(const file_info & p_info); + void from_info_overwrite_meta(const file_info & p_info); + void from_info_overwrite_rg(const file_info & p_info); + + template + void overwrite_meta(const t_source & p_meta) { + m_meta.overwrite(p_meta); + } + template + void overwrite_info(const t_source & p_info) { + m_info.overwrite(p_info); + } + + void merge_overwrite(const file_info & p_info); + void transfer_meta_entry(const char * p_name,const file_info & p_info,t_size p_index); + + void meta_set(const char * p_name,const char * p_value); + const t_meta_value * meta_query_ptr(const char * p_name) const; + + void from_info_set_meta(const file_info & p_info); + + void from_info(const file_info & p_info); + void to_info(file_info & p_info) const; + + template void enumerate_meta(t_callback & p_callback) const {m_meta.enumerate(p_callback);} + template void enumerate_meta(t_callback & p_callback) {m_meta.enumerate(p_callback);} + + size_t meta_value_count(const char* name) const; + + //private: + t_meta_map m_meta; + t_info_map m_info; + replaygain_info m_replaygain; + double m_length; + }; + +}//namespace file_info_record_helper + + +namespace cue_parser +{ + struct cue_entry { + pfc::string8 m_file, m_fileType; + unsigned m_track_number; + t_cuesheet_index_list m_indexes; + bool isFileBinary() const {return pfc::stringEqualsI_ascii(m_fileType, "BINARY");} + }; + + typedef pfc::chain_list_v2_t t_cue_entry_list; + + + PFC_DECLARE_EXCEPTION(exception_bad_cuesheet,exception_io_data,"Invalid cuesheet"); + + //! Throws exception_bad_cuesheet on failure. + void parse(const char *p_cuesheet,t_cue_entry_list & p_out); + //! Throws exception_bad_cuesheet on failure. + void parse_info(const char *p_cuesheet,file_info & p_info,unsigned p_index); + //! Throws exception_bad_cuesheet on failure. + void parse_full(const char * p_cuesheet,cue_creator::t_entry_list & p_out); + + + + struct track_record { + file_info_record_helper::file_info_record m_info; + pfc::string8 m_file,m_flags; + t_cuesheet_index_list m_index_list; + }; + + typedef pfc::map_t track_record_list; + + class embeddedcue_metadata_manager { + public: + // Named get_tag() for backwards compat - it doesn't just get tag, it builds the intended tag from current metadata + void get_tag(file_info & p_info) const; + // Imports tag read from file + void set_tag(file_info const & p_info); + + void get_track_info(unsigned p_track,file_info & p_info) const; + void set_track_info(unsigned p_track,file_info const & p_info); + void query_track_offsets(unsigned p_track,double & p_begin,double & p_length) const; + bool have_cuesheet() const; + unsigned remap_trackno(unsigned p_index) const; + t_size get_cue_track_count() const; + pfc::string8 build_minimal_cuesheet() const; + private: + track_record_list m_content; + }; + + + + + + template + class input_wrapper_cue_t : public input_forward_static_methods { + public: + typedef input_info_writer_v2 interface_info_writer_t; // remove_tags supplied + void open(service_ptr_t p_filehint,const char * p_path,t_input_open_reason p_reason,abort_callback & p_abort) { + m_remote = filesystem::g_is_recognized_and_remote( p_path ); + if (m_remote && p_reason == input_open_info_write) throw exception_io_object_is_remote(); + m_impl.open( p_filehint, p_path, p_reason, p_abort ); + if (!m_remote) { + file_info_impl info; + m_impl.get_info(info, p_abort); + m_meta.set_tag(info); + } + } + + t_uint32 get_subsong_count() { + return this->expose_cuesheet() ? (uint32_t) m_meta.get_cue_track_count() : 1; + } + + t_uint32 get_subsong(t_uint32 p_index) { + return this->expose_cuesheet() ? m_meta.remap_trackno(p_index) : 0; + } + + void get_info(t_uint32 p_subsong,file_info & p_info,abort_callback & p_abort) { + if (m_remote) { + PFC_ASSERT(p_subsong == 0); + m_impl.get_info(p_info, p_abort); + } else { + m_meta.get_track_info(p_subsong,p_info); + } + } + + t_filestats get_file_stats(abort_callback& p_abort) { return get_stats2(stats2_legacy, p_abort).to_legacy(); } + t_filestats2 get_stats2(uint32_t f, abort_callback& a) { return m_impl.get_stats2(f, a); } + + void decode_initialize(t_uint32 p_subsong,unsigned p_flags,abort_callback & p_abort) { + if (p_subsong == 0) { + m_impl.decode_initialize(p_flags, p_abort); + m_decodeFrom = 0; m_decodeLength = -1; m_decodePos = 0; + } else { + double start, length; + _query_track_offsets(p_subsong,start,length); + unsigned flags2 = p_flags; + if (start > 0) flags2 &= ~input_flag_no_seeking; + flags2 &= ~input_flag_allow_inaccurate_seeking; + m_impl.decode_initialize(flags2, p_abort); + m_impl.decode_seek(start, p_abort); + m_decodeFrom = start; m_decodeLength = length; m_decodePos = 0; + } + } + + bool decode_run(audio_chunk & p_chunk,abort_callback & p_abort) { + return _run(p_chunk, NULL, p_abort); + } + + void decode_seek(double p_seconds,abort_callback & p_abort) { + if (this->m_decodeLength >= 0 && p_seconds > m_decodeLength) p_seconds = m_decodeLength; + m_impl.decode_seek(m_decodeFrom + p_seconds,p_abort); + m_decodePos = p_seconds; + } + + bool decode_can_seek() {return m_impl.decode_can_seek();} + + bool decode_run_raw(audio_chunk & p_chunk, mem_block_container & p_raw, abort_callback & p_abort) { + return _run(p_chunk, &p_raw, p_abort); + } + void set_logger(event_logger::ptr ptr) { + m_impl.set_logger(ptr); + } + bool flush_on_pause() { + return m_impl.flush_on_pause(); + } + void set_pause(bool) {} // obsolete + size_t extended_param(const GUID & type, size_t arg1, void * arg2, size_t arg2size) { + return m_impl.extended_param(type, arg1, arg2, arg2size); + } + + bool decode_get_dynamic_info(file_info & p_out, double & p_timestamp_delta) { + return m_impl.decode_get_dynamic_info(p_out, p_timestamp_delta); + } + + bool decode_get_dynamic_info_track(file_info & p_out, double & p_timestamp_delta) { + return m_impl.decode_get_dynamic_info_track(p_out, p_timestamp_delta); + } + + void decode_on_idle(abort_callback & p_abort) { + m_impl.decode_on_idle(p_abort); + } + + void remove_tags(abort_callback & abort) { + PFC_ASSERT(!m_remote); + + pfc::string8 restoreCuesheet; + if (this->expose_cuesheet()) { + restoreCuesheet = m_meta.build_minimal_cuesheet(); + } + + m_impl.remove_tags( abort ); + + if (restoreCuesheet.length() > 0) { + // restore minimal tag + file_info_impl infoMinimal; infoMinimal.meta_set("cuesheet", restoreCuesheet); + m_impl.retag(infoMinimal, abort); + } + + file_info_impl info; + m_impl.get_info(info, abort); + m_meta.set_tag( info ); + } + + void retag_set_info(t_uint32 p_subsong,const file_info & p_info,abort_callback & p_abort) { + PFC_ASSERT(!m_remote); + if (p_subsong == 0) { + // Special case: Only subsong zero altered + m_retag0 = p_info; m_retag0_pending = true; + } else { + if (m_retag0_pending) { + m_meta.set_tag(m_retag0); m_retag0.reset(); + m_retag0_pending = false; + } + m_meta.set_track_info(p_subsong,p_info); + } + m_retag_pending = true; + } + void _retag(const file_info& info, abort_callback& abort) { + m_impl.retag(info, abort); + } + void retag_commit(abort_callback & p_abort) { + PFC_ASSERT(!m_remote); + if (!m_retag_pending) return; + + if (m_retag0_pending) { + // Special case: Only subsong zero altered + _retag(m_retag0, p_abort); m_retag0.reset(); + m_retag0_pending = false; + } else { + file_info_impl info; + m_meta.get_tag(info); + _retag(info, p_abort); + } + + file_info_impl info; + m_impl.get_info(info, p_abort); + m_meta.set_tag( info ); + + m_retag_pending = false; + + } + void _query_track_offsets(unsigned p_subsong, double& start, double& length) const { + m_meta.query_track_offsets(p_subsong,start,length); + } + bool expose_cuesheet() const { + return !m_remote && m_meta.have_cuesheet(); + } + private: + bool _run(audio_chunk & chunk, mem_block_container * raw, abort_callback & aborter) { + if (m_decodeLength >= 0 && m_decodePos >= m_decodeLength) return false; + if (raw == NULL) { + if (!m_impl.decode_run(chunk, aborter)) return false; + } else { + if (!m_impl.decode_run_raw(chunk, *raw, aborter)) return false; + } + + if (m_decodeLength >= 0) { + const uint64_t remaining = audio_math::time_to_samples( m_decodeLength - m_decodePos, chunk.get_sample_rate() ); + const size_t samplesGot = chunk.get_sample_count(); + if (remaining < samplesGot) { + m_decodePos = m_decodeLength; + if (remaining == 0) { // rare but possible as a result of rounding SNAFU - we're EOF but we didn't notice earlier + return false; + } + + chunk.set_sample_count( (size_t) remaining ); + if (raw != NULL) { + const t_size rawSize = raw->get_size(); + PFC_ASSERT( rawSize % samplesGot == 0 ); + raw->set_size( (t_size) ( (t_uint64) rawSize * remaining / samplesGot ) ); + } + } else { + m_decodePos += chunk.get_duration(); + } + } else { + m_decodePos += chunk.get_duration(); + } + return true; + } + t_base m_impl; + double m_decodeFrom, m_decodeLength, m_decodePos; + bool m_remote = false; + embeddedcue_metadata_manager m_meta; + + file_info_impl m_retag0; + bool m_retag0_pending = false; + bool m_retag_pending = false; + }; +#ifdef FOOBAR2000_HAVE_CHAPTERIZER + template + class chapterizer_impl_t : public chapterizer + { + public: + bool is_our_path(const char * p_path) { + return I::g_is_our_path(p_path, pfc::string_extension(p_path)); + } + + void set_chapters(const char * p_path,chapter_list const & p_list,abort_callback & p_abort) { + input_wrapper_cue_t instance; + instance.open(0,p_path,input_open_info_write,p_abort); + + //stamp the cuesheet first + { + file_info_impl info; + instance.get_info(0,info,p_abort); + + pfc::string_formatter cuesheet; + + { + cue_creator::t_entry_list entries; + t_size n, m = p_list.get_chapter_count(); + const double pregap = p_list.get_pregap(); + double offset_acc = pregap; + for(n=0;nm_infos = p_list.get_info(n); + entry->m_file = "CDImage.wav"; + entry->m_track_number = (unsigned)(n+1); + entry->m_index_list.from_infos(entry->m_infos,offset_acc); + if (n == 0) entry->m_index_list.m_positions[0] = 0; + offset_acc += entry->m_infos.get_length(); + } + cue_creator::create(cuesheet,entries); + } + + info.meta_set("cuesheet",cuesheet); + + instance.retag_set_info(0,info,p_abort); + } + //stamp per-chapter infos + for(t_size walk = 0, total = p_list.get_chapter_count(); walk < total; ++walk) { + instance.retag_set_info( (uint32_t)( walk + 1 ), p_list.get_info(walk),p_abort); + } + + instance.retag_commit(p_abort); + } + + void get_chapters(const char * p_path,chapter_list & p_list,abort_callback & p_abort) { + + input_wrapper_cue_t instance; + instance.open(0,p_path,input_open_info_read,p_abort); + const t_uint32 total = instance.get_subsong_count(); + + if (instance.expose_cuesheet()) { + double start, len; + instance._query_track_offsets(1, start, len); + p_list.set_pregap( start ); + } + + + p_list.set_chapter_count(total); + for(t_uint32 walk = 0; walk < total; ++walk) { + file_info_impl info; + instance.get_info(instance.get_subsong(walk),info,p_abort); + p_list.set_info(walk,info); + } + } + + bool supports_pregaps() { + return true; + } + }; +#endif +}; + +//! Wrapper template for generating embedded cuesheet enabled inputs. +//! t_input_impl is a singletrack input implementation (see input_singletrack_impl for method declarations). +//! To declare an embedded cuesheet enabled input, change your input declaration from input_singletrack_factory_t to input_cuesheet_factory_t. +template +class input_cuesheet_factory_t { +public: + input_factory_t,t_flags > m_input_factory; +#ifdef FOOBAR2000_HAVE_CHAPTERIZER + service_factory_single_t > m_chapterizer_factory; +#endif +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/cue_parser_embedding.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/cue_parser_embedding.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,419 @@ +#include "StdAfx.h" +#include "cue_parser.h" + +using namespace cue_parser; +using namespace file_info_record_helper; + +#define CUE_EMBED_DEBUG 0 + +#if CUE_EMBED_DEBUG +static void DEBUG_INFO(file_info const& p_info, const char* what) { + FB2K_console_formatter() << "embeddedcue_metadata_manager : " << what << " >>>>"; + p_info.to_console(); + FB2K_console_formatter() << "<<<<\n"; +} +static void DEBUG_INFO(const track_record_list& content, const char* what) { + FB2K_console_formatter() << "embeddedcue_metadata_manager : " << what << " >>>>"; + for (auto iter = content.first(); iter.is_valid(); ++iter) { + FB2K_console_formatter() << "track " << iter->m_key << " >>>>"; + file_info_impl temp; iter->m_value.m_info.to_info(temp); temp.to_console(); + } + FB2K_console_formatter() << "<<<<\n"; +} +#else +#define DEBUG_INFO(info, what) +#endif + +static void build_cue_meta_name(const char * p_name,unsigned p_tracknumber,pfc::string_base & p_out) { + p_out.reset(); + p_out << "cue_track" << pfc::format_uint(p_tracknumber % 100,2) << "_" << p_name; +} + +static bool is_reserved_meta_entry(const char * p_name) { + return file_info::field_name_comparator::compare(p_name,"cuesheet") == 0; +} + +static bool is_global_meta_entry(const char * p_name) { + static const char header[] = "cue_track"; + return pfc::stricmp_ascii_ex(p_name,strlen(header),header,~0) != 0; +} +static bool is_allowed_field(const char * p_name) { + return !is_reserved_meta_entry(p_name) && is_global_meta_entry(p_name); +} +namespace { + + typedef pfc::avltree_t field_name_list; + + class __get_tag__enum_fields_enumerator { + public: + __get_tag__enum_fields_enumerator(field_name_list & p_out) : m_out(p_out) {} + void operator() (unsigned p_trackno,const track_record & p_record) { + if (p_trackno > 0) p_record.m_info.enumerate_meta(*this); + } + template void operator() (const char * p_name,const t_value & p_value) { + m_out.add(p_name); + } + private: + field_name_list & m_out; + }; + + + class __get_tag__is_field_global_check { + private: + typedef file_info_record::t_meta_value t_value; + public: + __get_tag__is_field_global_check(const char * p_field) : m_field(p_field), m_value(NULL), m_state(true) {} + + void operator() (unsigned p_trackno,const track_record & p_record) { + if (p_trackno > 0 && m_state) { + const t_value * val = p_record.m_info.meta_query_ptr(m_field); + if (val == NULL) {m_state = false; return;} + if (m_value == NULL) { + m_value = val; + } else { + if (pfc::comparator_list::compare(*m_value,*val) != 0) { + m_state = false; return; + } + } + } + } + void finalize(file_info_record::t_meta_map & p_globals) { + if (m_state && m_value != NULL) { + p_globals.set(m_field,*m_value); + } + } + private: + const char * const m_field; + const t_value * m_value; + bool m_state; + }; + + class __get_tag__filter_globals { + public: + __get_tag__filter_globals(track_record_list const & p_tracks,file_info_record::t_meta_map & p_globals) : m_tracks(p_tracks), m_globals(p_globals) {} + + void operator() (const char * p_field) { + if (is_allowed_field(p_field)) { + __get_tag__is_field_global_check wrapper(p_field); + m_tracks.enumerate(wrapper); + wrapper.finalize(m_globals); + } + } + private: + const track_record_list & m_tracks; + file_info_record::t_meta_map & m_globals; + }; + + class __get_tag__local_field_filter { + public: + __get_tag__local_field_filter(const file_info_record::t_meta_map & p_globals,file_info_record::t_meta_map & p_output) : m_globals(p_globals), m_output(p_output), m_currenttrack(0) {} + void operator() (unsigned p_trackno,const track_record & p_track) { + if (p_trackno > 0) { + m_currenttrack = p_trackno; + p_track.m_info.enumerate_meta(*this); + } + } + void operator() (const char * p_name,const file_info_record::t_meta_value & p_value) { + PFC_ASSERT(m_currenttrack > 0); + if (!m_globals.have_item(p_name)) { + build_cue_meta_name(p_name,m_currenttrack,m_buffer); + m_output.set(m_buffer,p_value); + } + } + private: + unsigned m_currenttrack; + pfc::string8_fastalloc m_buffer; + const file_info_record::t_meta_map & m_globals; + file_info_record::t_meta_map & m_output; + }; +}; + +static bool meta_value_equals(const char* v1, const char* v2, bool asNumber) { + if (asNumber) { + // Special fix: leading zeros on track numbers + while( *v1 == '0' ) ++ v1; + while( *v2 == '0' ) ++ v2; + } + return strcmp(v1,v2) == 0; +} + +static void strip_redundant_track_meta(unsigned p_tracknumber,const file_info & p_cueinfo,file_info_record::t_meta_map & p_meta,const char * p_metaname, bool asNumber) { + const size_t metaindex = p_cueinfo.meta_find(p_metaname); + if (metaindex == SIZE_MAX) return; + pfc::string_formatter namelocal; + build_cue_meta_name(p_metaname,p_tracknumber,namelocal); + { + const file_info_record::t_meta_value * val = p_meta.query_ptr(namelocal); + if (val == NULL) return; + file_info_record::t_meta_value::const_iterator iter = val->first(); + for(t_size valwalk = 0, valcount = p_cueinfo.meta_enum_value_count(metaindex); valwalk < valcount; ++valwalk) { + if (iter.is_empty()) return; + + if (!meta_value_equals(*iter,p_cueinfo.meta_enum_value(metaindex,valwalk), asNumber)) return; + ++iter; + } + if (!iter.is_empty()) return; + } + //success + p_meta.remove(namelocal); +} + +// Named get_tag() for backwards compat - it doesn't just get tag, it builds the intended tag from current metadata +// Called prior to file update +void embeddedcue_metadata_manager::get_tag(file_info & p_info) const { + if (!have_cuesheet()) { + m_content.query_ptr(0u)->m_info.to_info(p_info); + p_info.meta_remove_field("cuesheet"); + return; + } + + cue_creator::t_entry_list entries; + m_content.enumerate([&entries] (unsigned p_trackno,const track_record & p_record) { + if (p_trackno > 0) { + cue_creator::t_entry_list::iterator iter = entries.insert_last(); + iter->m_trackType = "AUDIO"; + iter->m_file = p_record.m_file; + iter->m_flags = p_record.m_flags; + iter->m_index_list = p_record.m_index_list; + iter->m_track_number = p_trackno; + p_record.m_info.to_info(iter->m_infos); + } + } ); + pfc::string_formatter cuesheet; + cue_creator::create(cuesheet,entries); + entries.remove_all(); + //parse it back to see what info got stored in the cuesheet and what needs to be stored outside cuesheet in the tags + cue_parser::parse_full(cuesheet,entries); + file_info_record output; + + { + file_info_record::t_meta_map globals; + //1. find global infos and forward them + { + field_name_list fields; + { __get_tag__enum_fields_enumerator e(fields); m_content.enumerate(e);} + { __get_tag__filter_globals e(m_content,globals); fields.enumerate(e); } + } + + output.overwrite_meta(globals); + + //2. find local infos + {__get_tag__local_field_filter e(globals,output.m_meta); m_content.enumerate(e);} + } + + + //strip redundant titles, artists and tracknumbers that the cuesheet already contains + for(cue_creator::t_entry_list::const_iterator iter = entries.first(); iter.is_valid(); ++iter) { + strip_redundant_track_meta(iter->m_track_number,iter->m_infos,output.m_meta,"tracknumber", true); + strip_redundant_track_meta(iter->m_track_number,iter->m_infos,output.m_meta,"title", false); + strip_redundant_track_meta(iter->m_track_number,iter->m_infos,output.m_meta,"artist", false); + } + + + //add tech infos etc + + { + const track_record * rec = m_content.query_ptr((unsigned)0); + if (rec != NULL) { + output.set_length(rec->m_info.get_length()); + output.set_replaygain(rec->m_info.get_replaygain()); + output.overwrite_info(rec->m_info.m_info); + } + } + output.meta_set("cuesheet",cuesheet); + output.to_info(p_info); + + DEBUG_INFO( p_info, "get_tag" ); +} + +static bool resolve_cue_meta_name(const char * p_name,pfc::string_base & p_outname,unsigned & p_tracknumber) { + //"cue_trackNN_fieldname" + static const char header[] = "cue_track"; + if (pfc::stricmp_ascii_ex(p_name,strlen(header),header,~0) != 0) return false; + p_name += strlen(header); + if (!pfc::char_is_numeric(p_name[0]) || !pfc::char_is_numeric(p_name[1]) || p_name[2] != '_') return false; + unsigned tracknumber = pfc::atoui_ex(p_name,2); + if (tracknumber == 0) return false; + p_name += 3; + p_tracknumber = tracknumber; + p_outname = p_name; + return true; +} + +void embeddedcue_metadata_manager::set_tag(file_info const & p_info) { + + DEBUG_INFO( p_info, "set_tag" ); + + m_content.remove_all(); + + { + track_record & track0 = m_content.find_or_add((unsigned)0); + track0.m_info.from_info(p_info); + track0.m_info.m_info.set("cue_embedded","no"); + } + + + + const char * cuesheet = p_info.meta_get("cuesheet",0); + if (cuesheet == NULL) { + return; + } + + //processing order + //1. cuesheet content + //2. supplement with global metadata from the tag + //3. overwrite with local metadata from the tag + + { + cue_creator::t_entry_list entries; + try { + cue_parser::parse_full(cuesheet,entries); + } catch(exception_io_data const & e) { + console::complain("Attempting to embed an invalid cuesheet", e.what()); + return; + } + + { + const double length = p_info.get_length(); + for(cue_creator::t_entry_list::const_iterator iter = entries.first(); iter.is_valid(); ++iter ) { + if (iter->m_index_list.start() > length) { + console::info("Invalid cuesheet - index outside allowed range"); + return; + } + } + } + + for(cue_creator::t_entry_list::const_iterator iter = entries.first(); iter.is_valid(); ) { + cue_creator::t_entry_list::const_iterator next = iter; + ++next; + track_record & entry = m_content.find_or_add(iter->m_track_number); + entry.m_file = iter->m_file; + entry.m_flags = iter->m_flags; + entry.m_index_list = iter->m_index_list; + entry.m_info.from_info(iter->m_infos); + DEBUG_INFO(iter->m_infos, "set_tag cue track info" ); + entry.m_info.from_info_overwrite_info(p_info); + entry.m_info.m_info.set("cue_embedded","yes"); + double begin = entry.m_index_list.start(), end = next.is_valid() ? next->m_index_list.start() : p_info.get_length(); + if (end <= begin) throw exception_io_data(); + entry.m_info.set_length(end - begin); + iter = next; + } + } + + DEBUG_INFO( m_content, "set_tag part 1"); + + // == GLOBALS == + for(t_size metawalk = 0, metacount = p_info.meta_get_count(); metawalk < metacount; ++metawalk) { + const char * name = p_info.meta_enum_name(metawalk); + const t_size valuecount = p_info.meta_enum_value_count(metawalk); + if (valuecount > 0 && !is_reserved_meta_entry(name) && is_global_meta_entry(name)) { + m_content.enumerate( [&p_info, metawalk, name, valuecount] ( unsigned p_trackno, track_record & p_record ) { + if (p_trackno > 0) { + // Supplement, not overwrite + // 2021-02-12 fix: prefer whatever has more values + if (valuecount > p_record.m_info.meta_value_count(name)) { + p_record.m_info.transfer_meta_entry(name, p_info, metawalk); + } + } + } ); + } + } + + DEBUG_INFO( m_content, "set_tag part 2"); + + // == TRACK LOCALS == + { + pfc::string8_fastalloc namebuffer; + for(t_size metawalk = 0, metacount = p_info.meta_get_count(); metawalk < metacount; ++metawalk) { + const char * name = p_info.meta_enum_name(metawalk); + const t_size valuecount = p_info.meta_enum_value_count(metawalk); + unsigned trackno; + if (valuecount > 0 && !is_reserved_meta_entry(name) && resolve_cue_meta_name(name,namebuffer,trackno)) { + track_record * rec = m_content.query_ptr(trackno); + if (rec != NULL) { + rec->m_info.transfer_meta_entry(namebuffer,p_info,metawalk); + } + } + } + } + + DEBUG_INFO( m_content, "set_tag part 3"); +} + +void embeddedcue_metadata_manager::get_track_info(unsigned p_track,file_info & p_info) const { + const track_record * rec = m_content.query_ptr(p_track); + if (rec == NULL) throw exception_io_data(); + rec->m_info.to_info(p_info); + DEBUG_INFO( p_info, pfc::format("get_track_info(", p_track, ")" )); +} + +void embeddedcue_metadata_manager::set_track_info(unsigned p_track,file_info const & p_info) { + DEBUG_INFO( p_info, pfc::format("set_track_info(", p_track, ")" )); + track_record * rec = m_content.query_ptr(p_track); + if (rec == NULL) throw exception_io_data(); + rec->m_info.from_info_set_meta(p_info); + rec->m_info.set_replaygain(p_info.get_replaygain()); +} + +void embeddedcue_metadata_manager::query_track_offsets(unsigned p_track,double & p_begin,double & p_length) const { + const track_record * rec = m_content.query_ptr(p_track); + if (rec == NULL) throw exception_io_data(); + p_begin = rec->m_index_list.start(); + p_length = rec->m_info.get_length(); +} + +bool embeddedcue_metadata_manager::have_cuesheet() const { + return m_content.get_count() > 1; +} + +namespace { + class _remap_trackno_enumerator { + public: + _remap_trackno_enumerator(unsigned p_index) : m_countdown(p_index), m_result(0) {} + template void operator() (unsigned p_trackno,const t_blah&) { + if (p_trackno > 0 && m_result == 0) { + if (m_countdown == 0) { + m_result = p_trackno; + } else { + --m_countdown; + } + } + } + unsigned result() const {return m_result;} + private: + unsigned m_countdown; + unsigned m_result; + }; +}; + +unsigned embeddedcue_metadata_manager::remap_trackno(unsigned p_index) const { + if (have_cuesheet()) { + _remap_trackno_enumerator wrapper(p_index); + m_content.enumerate(wrapper); + return wrapper.result(); + } else { + return 0; + } +} + +t_size embeddedcue_metadata_manager::get_cue_track_count() const { + return m_content.get_count() - 1; +} + +pfc::string8 embeddedcue_metadata_manager::build_minimal_cuesheet() const { + cue_creator::t_entry_list entries; + m_content.enumerate([&entries](unsigned p_trackno, const track_record& p_record) { + if (p_trackno > 0) { + cue_creator::t_entry_list::iterator iter = entries.insert_last(); + iter->m_trackType = "AUDIO"; + iter->m_file = "Image.wav"; + iter->m_flags = p_record.m_flags; + iter->m_index_list = p_record.m_index_list; + iter->m_track_number = p_trackno; + } + }); + pfc::string_formatter cuesheet; + cue_creator::create(cuesheet, entries); + return cuesheet; +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/cuesheet_index_list.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/cuesheet_index_list.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,145 @@ +#include "StdAfx.h" +#include "cuesheet_index_list.h" + +#include "cue_parser.h" // exception_bad_cuesheet + +bool t_cuesheet_index_list::is_valid() const { + if (m_positions[1] < m_positions[0]) return false; + for(t_size n = 2; n < count && m_positions[n] > 0; n++) { + if (m_positions[n] < m_positions[n-1]) return false; + } + return true; +} + +void t_cuesheet_index_list::to_infos(file_info & p_out) const +{ + double base = m_positions[1]; + + if (base > 0) { + p_out.info_set("referenced_offset",cuesheet_format_index_time(base)); + } + + if (m_positions[0] < base) + p_out.info_set("pregap",cuesheet_format_index_time(base - m_positions[0])); + else + p_out.info_remove("pregap"); + + p_out.info_remove("index 00"); + p_out.info_remove("index 01"); + + for(unsigned n=2;n 0) + p_out.info_set(namebuffer,cuesheet_format_index_time(position)); + else + p_out.info_remove(namebuffer); + } +} + +static bool parse_value(const char * p_name,double & p_out) +{ + if (p_name == NULL) return false; + try { + p_out = cuesheet_parse_index_time_e(p_name,strlen(p_name)); + } catch(std::exception const &) {return false;} + return true; +} + +bool t_cuesheet_index_list::from_infos(file_info const & p_in,double p_base) +{ + double pregap; + bool found = false; + if (!parse_value(p_in.info_get("pregap"),pregap)) pregap = 0; + else found = true; + m_positions[0] = p_base - pregap; + m_positions[1] = p_base; + for(unsigned n=2;n= 2) + pfc::throw_exception_with_message< cue_parser::exception_bad_cuesheet >("invalid INDEX time syntax"); + splitmarks[splitptr++] = ptr; + } + else if (!pfc::char_is_numeric(p_string[ptr])) + pfc::throw_exception_with_message< cue_parser::exception_bad_cuesheet >("invalid INDEX time syntax"); + } + + t_size minutes_base = 0, minutes_length = 0, seconds_base = 0, seconds_length = 0, frames_base = 0, frames_length = 0; + + switch(splitptr) + { + case 0: + frames_base = 0; + frames_length = p_length; + break; + case 1: + seconds_base = 0; + seconds_length = splitmarks[0]; + frames_base = splitmarks[0] + 1; + frames_length = p_length - frames_base; + break; + case 2: + minutes_base = 0; + minutes_length = splitmarks[0]; + seconds_base = splitmarks[0] + 1; + seconds_length = splitmarks[1] - seconds_base; + frames_base = splitmarks[1] + 1; + frames_length = p_length - frames_base; + break; + } + + unsigned ret = 0; + + if (frames_length > 0) ret += pfc::atoui_ex(p_string + frames_base,frames_length); + if (seconds_length > 0) ret += 75 * pfc::atoui_ex(p_string + seconds_base,seconds_length); + if (minutes_length > 0) ret += 60 * 75 * pfc::atoui_ex(p_string + minutes_base,minutes_length); + + return ret; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/cuesheet_index_list.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/cuesheet_index_list.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,35 @@ +#pragma once + +unsigned cuesheet_parse_index_time_ticks_e(const char * p_string,t_size p_length); +double cuesheet_parse_index_time_e(const char * p_string,t_size p_length); + +class cuesheet_format_index_time +{ +public: + cuesheet_format_index_time(double p_time); + inline operator const char*() const {return m_buffer;} +private: + pfc::string_formatter m_buffer; +}; + + +struct t_cuesheet_index_list +{ + enum {count = 100}; + t_cuesheet_index_list() {reset();} + void reset() {for(unsigned n=0;nptMaxTrackSize.x = r.right - r.left; + info->ptMaxTrackSize.y = r.bottom - r.top; + } + if (min_x && min_y) + { + r.left = 0; r.right = min_x; + r.top = 0; r.bottom = min_y; + MapDialogRect(hWnd,&r); + AdjustWindowRectEx(&r, dwStyle, FALSE, dwExStyle); + info->ptMinTrackSize.x = r.right - r.left; + info->ptMinTrackSize.y = r.bottom - r.top; + } + } + lResult = 0; + return TRUE; + case WM_INITDIALOG: + set_parent(hWnd); + { + t_size n; + for(n=0;n + +// Legacy class referenced by old code +// Do not use in new code, use libPPUI instead +class dialog_resize_helper : public CDialogResizeHelperCompat +{ + pfc::array_t rects; + RECT orig_client; + HWND parent; + HWND sizegrip; + unsigned min_x,min_y,max_x,max_y; + + pfc::array_t m_table; + + void set_parent(HWND wnd); + void reset(); + void on_wm_size(); +public: + inline void set_min_size(unsigned x,unsigned y) {min_x = x; min_y = y;} + inline void set_max_size(unsigned x,unsigned y) {max_x = x; max_y = y;} + void add_sizegrip(); + + //the old way + bool process_message(HWND wnd,UINT msg,WPARAM wp,LPARAM lp); + + //ATL-compatible + BOOL ProcessWindowMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT& lResult); + + dialog_resize_helper(const param * src,unsigned count,unsigned p_min_x,unsigned p_min_y,unsigned p_max_x,unsigned p_max_y); + + ~dialog_resize_helper(); + + PFC_CLASS_NOT_COPYABLE_EX(dialog_resize_helper); +}; + +#endif // FOOBAR2000_DESKTOP_WINDOWS \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/dropdown_helper.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/dropdown_helper.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,174 @@ +#include "StdAfx.h" + +#include "dropdown_helper.h" + +void _cfg_dropdown_history_base::build_list(pfc::ptr_list_t & out) +{ + pfc::string8 temp; get_state(temp); + const char * src = temp; + while(*src) + { + int ptr = 0; + while(src[ptr] && src[ptr]!=separator) ptr++; + if (ptr>0) + { + out.add_item(pfc::strdup_n(src,ptr)); + src += ptr; + } + while(*src==separator) src++; + } +} + +void _cfg_dropdown_history_base::parse_list(const pfc::ptr_list_t & src) +{ + t_size n; + pfc::string8_fastalloc temp; + for(n=0;n & list) +{ + t_size n, m = list.get_count(); + uSendMessage(wnd,CB_RESETCONTENT,0,0); + for(n=0;n list; + build_list(list); + g_setup_dropdown_fromlist(wnd, list); + if ( list.get_size() > 0 ) { + uSetWindowText(wnd, list[0] ); + } + list.free_all(); +} + +void _cfg_dropdown_history_base::setup_dropdown(HWND wnd) +{ + pfc::ptr_list_t list; + build_list(list); + g_setup_dropdown_fromlist(wnd,list); + list.free_all(); +} +#endif // _WIN32 + +bool _cfg_dropdown_history_base::add_item(const char * item) +{ + if (!item || !*item) return false; + pfc::string8 meh; + if (strchr(item,separator)) + { + uReplaceChar(meh,item,-1,separator,'|',false); + item = meh; + } + pfc::ptr_list_t list; + build_list(list); + unsigned n; + bool found = false; + for(n=0;n m_max) list.delete_by_idx(list.get_count()-1); + list.insert_item(strdup(item),0); + } + parse_list(list); + list.free_all(); + return found; +} + +bool _cfg_dropdown_history_base::is_empty() +{ + pfc::string8 temp; get_state(temp); + const char * src = temp; + while(*src) + { + if (*src!=separator) return false; + src++; + } + return true; +} + +#ifdef _WIN32 +bool _cfg_dropdown_history_base::add_item(const char *item, HWND combobox) { + const bool state = add_item(item); + if (state) uSendMessageText(combobox, CB_ADDSTRING, 0, item); + return state; +} + +bool _cfg_dropdown_history_base::on_context(HWND wnd,LPARAM coords) { + try { + int coords_x = (short)LOWORD(coords), coords_y = (short)HIWORD(coords); + if (coords_x == -1 && coords_y == -1) + { + RECT asdf; + GetWindowRect(wnd,&asdf); + coords_x = (asdf.left + asdf.right) / 2; + coords_y = (asdf.top + asdf.bottom) / 2; + } + enum {ID_ERASE_ALL = 1, ID_ERASE_ONE }; + HMENU menu = CreatePopupMenu(); + uAppendMenu(menu,MF_STRING,ID_ERASE_ALL,"Wipe history"); + { + pfc::string8 tempvalue; + uGetWindowText(wnd,tempvalue); + if (!tempvalue.is_empty()) + uAppendMenu(menu,MF_STRING,ID_ERASE_ONE,"Remove this history item"); + } + int cmd = TrackPopupMenu(menu,TPM_RIGHTBUTTON|TPM_NONOTIFY|TPM_RETURNCMD,coords_x,coords_y,0,wnd,0); + DestroyMenu(menu); + switch(cmd) + { + case ID_ERASE_ALL: + { + set_state(""); + pfc::string8 value;//preserve old value while wiping dropdown list + uGetWindowText(wnd,value); + uSendMessage(wnd,CB_RESETCONTENT,0,0); + uSetWindowText(wnd,value); + return true; + } + case ID_ERASE_ONE: + { + pfc::string8 value; + uGetWindowText(wnd,value); + + pfc::ptr_list_t list; + build_list(list); + bool found = false; + for(t_size n=0;n & out); + void parse_list(const pfc::ptr_list_t & src); +public: + enum {separator = '\n'}; + + _cfg_dropdown_history_base(const GUID & varid, unsigned p_max = 10, const char * initial = "") : m_max(p_max), m_state(varid, initial) {} +#ifdef FOOBAR2000_DESKTOP_WINDOWS + void on_init(HWND ctrl, const char * initVal) { + add_item(initVal); setup_dropdown(ctrl); uSetWindowText(ctrl, initVal); + } + void setup_dropdown(HWND wnd); + void setup_dropdown_set_value(HWND wnd); + void setup_dropdown(HWND wnd,UINT id) {setup_dropdown(GetDlgItem(wnd,id));} + bool on_context(HWND wnd,LPARAM coords); //returns true when the content has changed + bool add_item(const char * item, HWND combobox); //immediately adds the item to the combobox +#endif + bool add_item(const char * item); //returns true when the content has changed, false when not (the item was already on the list) + bool is_empty(); + + void set_state(const char* val) { m_state = val; } + void get_state(pfc::string_base& out) { out = m_state.get(); } +private: + cfg_string m_state; +}; + +typedef _cfg_dropdown_history_base cfg_dropdown_history; +typedef _cfg_dropdown_history_base cfg_dropdown_history_mt; + +#ifdef FOOBAR2000_DESKTOP_WINDOWS +// ATL-compatible message map entry macro for installing dropdown list context menus. +#define DROPDOWN_HISTORY_HANDLER(ctrlID,var) \ + if(uMsg == WM_CONTEXTMENU) { \ + const HWND source = (HWND) wParam; \ + if (source != NULL && source == CWindow(hWnd).GetDlgItem(ctrlID)) { \ + var.on_context(source,lParam); \ + lResult = 0; \ + return TRUE; \ + } \ + } + +#endif // FOOBAR2000_DESKTOP_WINDOWS diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/dsp_dialog.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/dsp_dialog.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,85 @@ +#pragma once +#ifdef _WIN32 +#include "atl-misc.h" + +// dsp_dialog.h +// DSP UI helper +// Simplifies implementation of DSP configuration popups, removes the need for separate blocking/nonblocking dialog routing all calls to one dialog class. +// Your dialog_t class must be WTL dialog taking dsp_preset_edit_callback_v2::ptr parameter in constructor. +// Do not call EndDialog(), DestroyWindow() etc, only use the provided callback's dsp_dialog_done() to make your dialog disappear. + +template +void dsp_dialog_v2(const dsp_preset& p_data, HWND p_parent, dsp_preset_edit_callback& p_callback) { + core_api::ensure_main_thread(); + + class mycallback : public dsp_preset_edit_callback_v2 { + public: + void get_preset(dsp_preset& outPreset) override { + outPreset = m_state; + } + void set_preset(const dsp_preset& inPreset) { m_state = inPreset; if (m_chain) m_chain->on_preset_changed(inPreset); } + void dsp_dialog_done(bool bOK) override { + if (m_dialog) m_dialog->EndDialog(bOK ? IDOK : IDCANCEL); + } + + dsp_preset_impl m_state; + dsp_preset_edit_callback* m_chain = nullptr; + dialog_t* m_dialog = nullptr; + }; + + + auto cb = fb2k::service_new(); + cb->m_state = p_data; + auto toggle = pfc::autoToggle(cb->m_chain, &p_callback); + ImplementModalTracking< dialog_t > dialog(cb); + auto toggle2 = pfc::autoToggle(cb->m_dialog, &dialog); + dialog.DoModal(p_parent); +} + +template +class _dialog_as_service : public dialog_t, public service_base { +public: + template _dialog_as_service(arg_t && ... arg) : dialog_t(std::forward(arg) ...) {} +}; + +template +service_ptr dsp_dialog_v3(HWND parent, dsp_preset_edit_callback_v2::ptr callback) { + class mycallback : public dsp_preset_edit_callback_v2 { + public: + void get_preset(dsp_preset& outPreset) override { m_chain->get_preset(outPreset); } + void set_preset(const dsp_preset& inPreset) { m_chain->set_preset(inPreset); } + void dsp_dialog_done(bool bOK) override { + m_chain->dsp_dialog_done(bOK); + m_dialog->DestroyWindow(); + } + dsp_preset_edit_callback_v2::ptr m_chain; + dialog_t* m_dialog = nullptr; + }; + auto cb = fb2k::service_new< mycallback >(); + cb->m_chain = callback; + auto obj = fb2k::service_new_window > >(cb); + cb->m_dialog = &*obj; + WIN32_OP_D(obj->Create(parent)); obj->ShowWindow(SW_SHOW); + return obj; +} +#endif + +template +class dsp_impl_with_ui : public dsp_entry_common_t { +public: + void get_display_name(const dsp_preset& arg, pfc::string_base& out) override { + dsp_t::g_get_display_name(arg, out); + } +#ifdef _WIN32 + void show_config_popup_v2(const dsp_preset& p_data, fb2k::hwnd_t p_parent, dsp_preset_edit_callback& p_callback) override { + dsp_dialog_v2(p_data, p_parent, p_callback); + } + service_ptr show_config_popup_v3(fb2k::hwnd_t parent, dsp_preset_edit_callback_v2::ptr callback) override { + return dsp_dialog_v3(parent, callback); + } +#else + service_ptr show_config_popup(fb2k::hwnd_t parent, dsp_preset_edit_callback_v2::ptr callback) override { + return dialog_t::show_config_popup(parent, callback); + } +#endif +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/duration_counter.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/duration_counter.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,96 @@ +#pragma once + +#include +#include + +//! Duration counter class - accumulates duration using sample values, without any kind of rounding error accumulation. +class duration_counter { +public: + duration_counter() {} + void set(double v) { + m_sampleCounts.remove_all(); + m_offset = v; + } + void reset() { + set(0); + } + + void add(double v) { m_offset += v; } + void subtract(double v) { m_offset -= v; } + + double query() const { + double acc = m_offset; + for (auto& walk : m_sampleCounts) { + acc += audio_math::samples_to_time(walk.m_value, walk.m_key); + } + return acc; + } + + uint64_t queryAsAnySampleCount() const { + if (m_sampleCounts.get_count() == 1) { + return m_sampleCounts.first()->m_value; + } + return 0; + } + + uint64_t queryAsSampleCount(uint32_t rate) const { + uint64_t samples = 0; + double acc = m_offset; + for (auto& walk : m_sampleCounts) { + if (walk.m_key == rate) samples += walk.m_value; + else acc += audio_math::samples_to_time(walk.m_value, walk.m_key); + } + return samples + audio_math::time_to_samples(acc, rate); + } + + void add(const audio_chunk & c) { + add(c.get_sample_count(), c.get_sample_rate()); + } +#ifdef FOOBAR2000_HAVE_DSP + void add(dsp_chunk_list const & c) { + const size_t num = c.get_count(); + for (size_t walk = 0; walk < num; ++walk) { + add(*c.get_item(walk)); + } + } +#endif + void add(t_uint64 sampleCount, t_uint32 sampleRate) { + PFC_ASSERT(sampleRate > 0); + if (sampleRate > 0 && sampleCount > 0) { + m_sampleCounts.find_or_add(sampleRate) += sampleCount; + } + } + void add(const duration_counter & other) { + add(other.m_offset); + for (auto& walk : other.m_sampleCounts) add(walk.m_value, walk.m_key); + } + void subtract(const duration_counter & other) { + subtract(other.m_offset); + for (auto& walk : other.m_sampleCounts) subtract(walk.m_value, walk.m_key); + } + void subtract(t_uint64 sampleCount, t_uint32 sampleRate) { + PFC_ASSERT(sampleRate > 0); + if (sampleRate > 0 && sampleCount > 0) { + t_uint64 * val = m_sampleCounts.query_ptr(sampleRate); + if (val == NULL) throw pfc::exception_invalid_params(); + if (*val < sampleCount) throw pfc::exception_invalid_params(); + else if (*val == sampleCount) { + m_sampleCounts.remove(sampleRate); + } else { + *val -= sampleCount; + } + + } + } + void subtract(const audio_chunk & c) { + subtract(c.get_sample_count(), c.get_sample_rate()); + } + template duration_counter & operator+=(const t_source & source) { add(source); return *this; } + template duration_counter & operator-=(const t_source & source) { subtract(source); return *this; } + template duration_counter & operator=(const t_source & source) { reset(); add(source); return *this; } +private: + double m_offset = 0; + typedef pfc::map_t t_map; + t_map m_sampleCounts; +}; + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/dynamic_bitrate_helper.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/dynamic_bitrate_helper.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,77 @@ +#include "StdAfx.h" + +#include "dynamic_bitrate_helper.h" +#include + +static unsigned g_query_settings() +{ + t_int32 temp; + try { + config_object::g_get_data_int32(standard_config_objects::int32_dynamic_bitrate_display_rate,temp); + } catch(std::exception const &) {return 9;} + if (temp < 0) return 0; + return (unsigned) temp; +} + +dynamic_bitrate_helper::dynamic_bitrate_helper() +{ + reset(); +} + +void dynamic_bitrate_helper::init() +{ + if (!m_inited) + { + m_inited = true; + unsigned temp = g_query_settings(); + if (temp > 0) {m_enabled = true; m_update_interval = 1.0 / (double) temp; } + else {m_enabled = false; m_update_interval = 0; } + m_last_duration = 0; + m_update_bits = 0; + m_update_time = 0; + + } +} + +void dynamic_bitrate_helper::on_frame(double p_duration,t_size p_bits) +{ + init(); + m_last_duration = p_duration; + m_update_time += p_duration; + m_update_bits += p_bits; +} + +bool dynamic_bitrate_helper::on_update(file_info & p_out, double & p_timestamp_delta) +{ + init(); + + bool ret = false; + if (m_enabled) + { + if (m_update_time > m_update_interval) + { + int val = (int) ( ((double)m_update_bits / m_update_time + 500.0) / 1000.0 ); + if (val != p_out.info_get_bitrate_vbr()) + { + p_timestamp_delta = - (m_update_time - m_last_duration); //relative to last frame beginning; + p_out.info_set_bitrate_vbr(val); + ret = true; + } + m_update_bits = 0; + m_update_time = 0; + } + } + else + { + m_update_bits = 0; + m_update_time = 0; + } + + return ret; + +} + +void dynamic_bitrate_helper::reset() +{ + m_inited = false; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/dynamic_bitrate_helper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/dynamic_bitrate_helper.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,17 @@ +#pragma once + +class dynamic_bitrate_helper +{ +public: + dynamic_bitrate_helper(); + void on_frame(double p_duration,t_size p_bits); + bool on_update(file_info & p_out, double & p_timestamp_delta); + void reset(); +private: + void init(); + double m_last_duration; + t_size m_update_bits; + double m_update_time; + double m_update_interval; + bool m_inited, m_enabled; +}; \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/fb2kWorkerTool.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/fb2kWorkerTool.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,69 @@ +#pragma once +#include +#include + +#include + +namespace fb2k { + class workerTool { + public: + struct work_t { + std::function work, done; + }; + + void operator+=(work_t && work) { + m_workQueue.push_back( std::make_shared< work_t> ( std::move(work) ) ); + kickWork(); + } + void flush() { + if ( m_working ) { + m_abort->set(); + m_abort = std::make_shared(); + m_working = false; + } + m_workQueue.clear(); + } + + void workDone() { + m_working = false; + kickWork(); + } + void kickWork() { + PFC_ASSERT( core_api::is_main_thread() ); + if (!m_working && !m_workQueue.empty()) { + m_working = true; + auto iter = m_workQueue.begin(); + auto work = std::move(*iter); m_workQueue.erase(iter); + auto pThis = this; + auto a = m_abort; + fb2k::inCpuWorkerThread( [ work, pThis, a] { + try { + // release lambdas early, synchronously from same context as they're executed + { auto f = std::move(work->work); if (f) f(); } + a->check(); + fb2k::inMainThread( [work, pThis, a] { + if ( ! a->is_set() ) { + // release lambdas early, synchronously from same context as they're executed + { auto f = std::move(work->done); if (f) f(); } + pThis->workDone(); + } + }); + } catch(exception_aborted const &) {} + } ); + } + } + + workerTool() {} + ~workerTool() { m_abort->set(); } + workerTool(const workerTool&) = delete; + void operator=(const workerTool&) = delete; + + std::shared_ptr aborter() const { return m_abort; } + private: + std::shared_ptr m_abort = std::make_shared(); + + bool m_working = false; + std::list< std::shared_ptr > m_workQueue; + }; + +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/fb2k_threads.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/fb2k_threads.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,92 @@ +#pragma once + +inline static t_size GetOptimalWorkerThreadCount() throw() { + return pfc::getOptimalWorkerThreadCount(); +} + +//! IMPORTANT: all classes derived from CVerySimpleThread must call WaitTillThreadDone() in their destructor, to avoid object destruction during a virtual function call! +class CVerySimpleThread : private pfc::thread { +public: +#ifdef _WIN32 + void StartThread(int winPriority) { + StartThread(pfc::thread::argWinPriority(winPriority)); + } +#endif + void StartThread( pfc::thread::arg_t const & arg = pfc::thread::argCurrentThread() ) { + pfc::thread::start( arg ); + } + + bool IsThreadActive() const { + return this->pfc::thread::isActive(); + } + void WaitTillThreadDone() { + this->pfc::thread::waitTillDone(); + } +protected: + CVerySimpleThread() {} + virtual void ThreadProc() = 0; +private: + + void threadProc() { + this->ThreadProc(); + } + + PFC_CLASS_NOT_COPYABLE_EX(CVerySimpleThread) +}; + +//! IMPORTANT: all classes derived from CSimpleThread must call AbortThread()/WaitTillThreadDone() in their destructors, to avoid object destruction during a virtual function call! +class CSimpleThread : private completion_notify_receiver, private pfc::thread { +public: +#ifdef _WIN32 + void StartThread(int winPriority) { + StartThread(pfc::thread::argWinPriority(winPriority)); + } +#endif + void StartThread(pfc::thread::arg_t const & arg = pfc::thread::argCurrentThread() ) { + AbortThread(); + m_abort.reset(); + m_ownNotify = create_task(0); + this->pfc::thread::start( arg ); + } + void AbortThread() { + m_abort.abort(); + CloseThread(); + } + bool IsThreadActive() const { + return this->pfc::thread::isActive(); + } + void WaitTillThreadDone() { + CloseThread(); + } +protected: + CSimpleThread() {} + ~CSimpleThread() {AbortThread();} + + virtual unsigned ThreadProc(abort_callback & p_abort) = 0; + //! Called when the thread has completed normally, with p_code equal to ThreadProc retval. Not called when AbortThread() or WaitTillThreadDone() was used to abort the thread / wait for the thread to finish. + virtual void ThreadDone(unsigned p_code) {}; +private: + void CloseThread() { + this->pfc::thread::waitTillDone(); + orphan_all_tasks(); + } + + void on_task_completion(unsigned p_id,unsigned p_status) { + if (IsThreadActive()) { + CloseThread(); + ThreadDone(p_status); + } + } + void threadProc() { + unsigned code = ~0; + try { + code = ThreadProc(m_abort); + } catch(...) {} + if (!m_abort.is_aborting()) m_ownNotify->on_completion_async(code); + } + abort_callback_impl m_abort; + completion_notify_ptr m_ownNotify; + + PFC_CLASS_NOT_COPYABLE_EX(CSimpleThread); +}; + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/fb2k_wfx.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/fb2k_wfx.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,38 @@ +#pragma once + +struct fb2k_wfx { + audio_chunk::spec_t spec; + bool bFloat; + unsigned bps; + void parse( const WAVEFORMATEX * wfx ) { + spec.sampleRate = wfx->nSamplesPerSec; + spec.chanCount = wfx->nChannels; + spec.chanMask = audio_chunk::g_guess_channel_config( spec.chanCount ); + bps = wfx->wBitsPerSample; + switch( wfx->wFormatTag ) { + case WAVE_FORMAT_PCM: + bFloat = false; break; + case WAVE_FORMAT_IEEE_FLOAT: + bFloat = true; break; + case WAVE_FORMAT_EXTENSIBLE: + { + auto wfxe = (const WAVEFORMATEXTENSIBLE*) wfx; + auto newMask = audio_chunk::g_channel_config_from_wfx( wfxe->dwChannelMask ); + if ( audio_chunk::g_count_channels(newMask) == spec.chanCount ) { + spec.chanMask = newMask; + } + if ( wfxe->SubFormat == KSDATAFORMAT_SUBTYPE_IEEE_FLOAT ) { + bFloat = true; + } else if ( wfxe->SubFormat == KSDATAFORMAT_SUBTYPE_PCM ) { + bFloat = false; + } else { + throw exception_io_data(); + } + } + break; + default: + throw exception_io_data(); + } + + } +}; \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/fileReadAhead.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/fileReadAhead.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,4 @@ +#pragma once + +//! Creates a file with a background thread reading ahead of the current position +file::ptr fileCreateReadAhead(file::ptr chain, size_t readAheadBytes, abort_callback & aborter ); diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/file_cached.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/file_cached.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,1 @@ +// obsolete, moved to SDK \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/file_info_const_impl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/file_info_const_impl.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,2 @@ +#pragma once +#include "../SDK/file_info_const_impl.h" \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/file_list_helper.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/file_list_helper.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,79 @@ +#include "StdAfx.h" + +#include "file_list_helper.h" + +#ifndef _MSC_VER +#define _strdup strdup +#endif + +static void file_list_remove_duplicates(pfc::ptr_list_t & out) +{ + t_size n, m = out.get_count(); + out.sort_t(metadb::path_compare); + pfc::bit_array_bittable mask(m); + t_size duplicates = 0; + for(n=1;n0) { + out.free_mask(mask); + } +} + + +namespace file_list_helper +{ + t_size file_list_from_metadb_handle_list::g_get_count(metadb_handle_list_cref data, t_size max) { + pfc::avltree_t content; + const t_size inCount = data.get_size(); + for(t_size walk = 0; walk < inCount && content.get_count() < max; ++walk) { + content += data[walk]->get_path(); + } + return content.get_count(); + } + void file_list_from_metadb_handle_list::_add(const char * p_what) { + char * temp = _strdup(p_what); + if (temp == NULL) throw std::bad_alloc(); + try {m_data.add_item(temp); } catch(...) {free(temp); throw;} + } + + void file_list_from_metadb_handle_list::init_from_list(const list_base_const_t & p_list) + { + m_data.free_all(); + + t_size n, m = p_list.get_count(); + for(n=0;nget_path() ); + } + file_list_remove_duplicates(m_data); + } + + void file_list_from_metadb_handle_list::init_from_list_display(const list_base_const_t & p_list) + { + m_data.free_all(); + + pfc::string8_fastalloc temp; + + t_size n, m = p_list.get_count(); + for(n=0;nget_path(),temp); + _add(temp); + } + file_list_remove_duplicates(m_data); + } + + file_list_from_metadb_handle_list::file_list_from_metadb_handle_list(metadb_handle_list_cref lst, bool bDisplayPaths) { + if ( bDisplayPaths ) init_from_list_display(lst); + else init_from_list( lst ); + } + + t_size file_list_from_metadb_handle_list::get_count() const {return m_data.get_count();} + void file_list_from_metadb_handle_list::get_item_ex(const char * & p_out,t_size n) const {p_out = m_data.get_item(n);} + + file_list_from_metadb_handle_list::~file_list_from_metadb_handle_list() + { + m_data.free_all(); + } + +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/file_list_helper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/file_list_helper.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,28 @@ +#pragma once + +namespace file_list_helper +{ + typedef pfc::list_base_const_t base_t; + + //list guaranteed to be sorted by metadb::path_compare + class file_list_from_metadb_handle_list : public base_t { + public: + file_list_from_metadb_handle_list() {} + file_list_from_metadb_handle_list( metadb_handle_list_cref lst, bool bDisplayPaths = false ); + + static t_size g_get_count(const list_base_const_t & p_list, t_size max = SIZE_MAX); + + void init_from_list(const list_base_const_t & p_list); + void init_from_list_display(const list_base_const_t & p_list); + + t_size get_count() const; + void get_item_ex(const char * & p_out,t_size n) const; + + ~file_list_from_metadb_handle_list(); + + private: + void _add(const char * p_what); + pfc::ptr_list_t m_data; + }; +}; + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/file_move_helper.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/file_move_helper.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,41 @@ +#include "StdAfx.h" + +#include "file_move_helper.h" +#include + +bool file_move_helper::g_on_deleted(const pfc::list_base_const_t & p_files) +{ + file_operation_callback::g_on_files_deleted(p_files); + return true; +} + +t_size file_move_helper::g_filter_dead_files_sorted_make_mask(pfc::list_base_t & p_data,const pfc::list_base_const_t & p_dead,bit_array_var & p_mask) +{ + t_size n, m = p_data.get_count(); + t_size found = 0; + for(n=0;nget_path(),dummy); + if (dead) found++; + p_mask.set(n,dead); + } + return found; +} + +t_size file_move_helper::g_filter_dead_files_sorted(pfc::list_base_t & p_data,const pfc::list_base_const_t & p_dead) +{ + pfc::bit_array_bittable mask(p_data.get_count()); + t_size found = g_filter_dead_files_sorted_make_mask(p_data,p_dead,mask); + if (found > 0) p_data.remove_mask(mask); + return found; +} + +t_size file_move_helper::g_filter_dead_files(pfc::list_base_t & p_data,const pfc::list_base_const_t & p_dead) +{ + pfc::ptr_list_t temp; + temp.add_items(p_dead); + temp.sort_t(metadb::path_compare); + return g_filter_dead_files_sorted(p_data,temp); +} + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/file_move_helper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/file_move_helper.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,10 @@ +#pragma once + +class file_move_helper { +public: + static bool g_on_deleted(const pfc::list_base_const_t & p_files); + + static t_size g_filter_dead_files_sorted_make_mask(pfc::list_base_t & p_data,const pfc::list_base_const_t & p_dead,bit_array_var & p_mask); + static t_size g_filter_dead_files_sorted(pfc::list_base_t & p_data,const pfc::list_base_const_t & p_dead); + static t_size g_filter_dead_files(pfc::list_base_t & p_data,const pfc::list_base_const_t & p_dead); +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/file_streamstub.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/file_streamstub.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,19 @@ +#pragma once + +//! Stub implementation of file object, no file content, only info. +class file_streamstub : public file_readonly { +public: + t_size read(void*, t_size, abort_callback&) override { return 0; } + t_filesize get_size(abort_callback&) override { return filesize_invalid; } + t_filesize get_position(abort_callback&) override { return 0; } + bool get_content_type(pfc::string_base& out) override { + if (m_contentType.length() > 0) { out = m_contentType; return true; } else return false; + } + bool is_remote() override { return m_remote; } + void reopen(abort_callback&) override {} + void seek(t_filesize, abort_callback&) override { throw exception_io_object_not_seekable(); } + bool can_seek() override { return false; } + + pfc::string8 m_contentType; + bool m_remote = true; +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/file_win32_wrapper.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/file_win32_wrapper.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,312 @@ +#include "StdAfx.h" + +#ifdef _WIN32 + +#include "file_win32_wrapper.h" + +namespace file_win32_helpers { + t_filesize get_size(HANDLE p_handle) { + LARGE_INTEGER v = {}; + WIN32_IO_OP(GetFileSizeEx(p_handle, &v)); + return make_uint64(v); + } + void seek(HANDLE p_handle,t_sfilesize p_position,file::t_seek_mode p_mode) { + union { + t_int64 temp64; + struct { + DWORD temp_lo; + LONG temp_hi; + }; + }; + + temp64 = p_position; + SetLastError(ERROR_SUCCESS); + temp_lo = SetFilePointer(p_handle,temp_lo,&temp_hi,(DWORD)p_mode); + if (GetLastError() != ERROR_SUCCESS) exception_io_from_win32(GetLastError()); + } + + void fillOverlapped(OVERLAPPED & ol, HANDLE myEvent, t_filesize s) { + ol.hEvent = myEvent; + ol.Offset = (DWORD)( s & 0xFFFFFFFF ); + ol.OffsetHigh = (DWORD)(s >> 32); + } + + void writeOverlappedPass(HANDLE handle, HANDLE myEvent, t_filesize position, const void * in,DWORD inBytes, abort_callback & abort) { + abort.check(); + if (inBytes == 0) return; + OVERLAPPED ol = {}; + fillOverlapped(ol, myEvent, position); + ResetEvent(myEvent); + DWORD bytesWritten; + SetLastError(NO_ERROR); + if (WriteFile( handle, in, inBytes, &bytesWritten, &ol)) { + // succeeded already? + if (bytesWritten != inBytes) throw exception_io(); + return; + } + + { + const DWORD code = GetLastError(); + if (code != ERROR_IO_PENDING) exception_io_from_win32(code); + } + const HANDLE handles[] = {myEvent, abort.get_abort_event()}; + SetLastError(NO_ERROR); + DWORD state = WaitForMultipleObjects(_countof(handles), handles, FALSE, INFINITE); + if (state == WAIT_OBJECT_0) { + try { + WIN32_IO_OP( GetOverlappedResult(handle,&ol,&bytesWritten,TRUE) ); + } catch(...) { + CancelIo(handle); + throw; + } + if (bytesWritten != inBytes) throw exception_io(); + return; + } + CancelIo(handle); + throw exception_aborted(); + } + + void writeOverlapped(HANDLE handle, HANDLE myEvent, t_filesize & position, const void * in, size_t inBytes, abort_callback & abort) { + enum {writeMAX = 16*1024*1024}; + size_t done = 0; + while(done < inBytes) { + size_t delta = inBytes - done; + if (delta > writeMAX) delta = writeMAX; + writeOverlappedPass(handle, myEvent, position, (const BYTE*)in + done, (DWORD) delta, abort); + done += delta; + position += delta; + } + } + void writeStreamOverlapped(HANDLE handle, HANDLE myEvent, const void * in, size_t inBytes, abort_callback & abort) { + enum {writeMAX = 16*1024*1024}; + size_t done = 0; + while(done < inBytes) { + size_t delta = inBytes - done; + if (delta > writeMAX) delta = writeMAX; + writeOverlappedPass(handle, myEvent, 0, (const BYTE*)in + done, (DWORD) delta, abort); + done += delta; + } + } + + DWORD readOverlappedPass(HANDLE handle, HANDLE myEvent, t_filesize position, void * out, DWORD outBytes, abort_callback & abort) { + abort.check(); + if (outBytes == 0) return 0; + OVERLAPPED ol = {}; + fillOverlapped(ol, myEvent, position); + ResetEvent(myEvent); + DWORD bytesDone; + SetLastError(NO_ERROR); + if (ReadFile( handle, out, outBytes, &bytesDone, &ol)) { + // succeeded already? + return bytesDone; + } + + { + const DWORD code = GetLastError(); + switch(code) { + case ERROR_HANDLE_EOF: + case ERROR_BROKEN_PIPE: + return 0; + case ERROR_IO_PENDING: + break; // continue + default: + exception_io_from_win32(code); + }; + } + + const HANDLE handles[] = {myEvent, abort.get_abort_event()}; + SetLastError(NO_ERROR); + DWORD state = WaitForMultipleObjects(_countof(handles), handles, FALSE, INFINITE); + if (state == WAIT_OBJECT_0) { + SetLastError(NO_ERROR); + if (!GetOverlappedResult(handle,&ol,&bytesDone,TRUE)) { + const DWORD code = GetLastError(); + if (code == ERROR_HANDLE_EOF || code == ERROR_BROKEN_PIPE) bytesDone = 0; + else { + CancelIo(handle); + exception_io_from_win32(code); + } + } + return bytesDone; + } + CancelIo(handle); + throw exception_aborted(); + } + size_t readOverlapped(HANDLE handle, HANDLE myEvent, t_filesize & position, void * out, size_t outBytes, abort_callback & abort) { + enum {readMAX = 16*1024*1024}; + size_t done = 0; + while(done < outBytes) { + size_t delta = outBytes - done; + if (delta > readMAX) delta = readMAX; + delta = readOverlappedPass(handle, myEvent, position, (BYTE*) out + done, (DWORD) delta, abort); + if (delta == 0) break; + done += delta; + position += delta; + } + return done; + } + + size_t readStreamOverlapped(HANDLE handle, HANDLE myEvent, void * out, size_t outBytes, abort_callback & abort) { + enum {readMAX = 16*1024*1024}; + size_t done = 0; + while(done < outBytes) { + size_t delta = outBytes - done; + if (delta > readMAX) delta = readMAX; + delta = readOverlappedPass(handle, myEvent, 0, (BYTE*) out + done, (DWORD) delta, abort); + if (delta == 0) break; + done += delta; + } + return done; + } + + typedef BOOL (WINAPI * pCancelSynchronousIo_t)(HANDLE hThread); + + + struct createFileData_t { + LPCTSTR lpFileName; + DWORD dwDesiredAccess; + DWORD dwShareMode; + LPSECURITY_ATTRIBUTES lpSecurityAttributes; + DWORD dwCreationDisposition; + DWORD dwFlagsAndAttributes; + HANDLE hTemplateFile; + HANDLE hResult; + DWORD dwErrorCode; + }; + + HANDLE createFile(LPCTSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile, abort_callback & abort) { + abort.check(); + + return CreateFile(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile); + } + + size_t lowLevelIO(HANDLE hFile, const GUID & guid, size_t arg1, void * arg2, size_t arg2size, bool canWrite, abort_callback & abort) { + if ( guid == file_lowLevelIO::guid_flushFileBuffers ) { + if (!canWrite) { + PFC_ASSERT(!"File opened for reading, not writing"); + throw exception_io_denied(); + } + WIN32_IO_OP( ::FlushFileBuffers(hFile) ); + return 1; + } else if ( guid == file_lowLevelIO::guid_getFileTimes ) { + if ( arg2size == sizeof(file_lowLevelIO::filetimes_t) ) { + if (canWrite) WIN32_IO_OP(::FlushFileBuffers(hFile)); + auto ft = reinterpret_cast(arg2); + static_assert(sizeof(t_filetimestamp) == sizeof(FILETIME), "struct sanity"); + WIN32_IO_OP( GetFileTime( hFile, (FILETIME*)&ft->creation, (FILETIME*)&ft->lastAccess, (FILETIME*)&ft->lastWrite) ); + return 1; + } + } else if ( guid == file_lowLevelIO::guid_setFileTimes ) { + if (arg2size == sizeof(file_lowLevelIO::filetimes_t)) { + if (!canWrite) { + PFC_ASSERT(!"File opened for reading, not writing"); + throw exception_io_denied(); + } + WIN32_IO_OP(::FlushFileBuffers(hFile)); + auto ft = reinterpret_cast(arg2); + static_assert(sizeof(t_filetimestamp) == sizeof(FILETIME), "struct sanity"); + const FILETIME * pCreation = nullptr; + const FILETIME * pLastAccess = nullptr; + const FILETIME * pLastWrite = nullptr; + if ( ft->creation != filetimestamp_invalid ) pCreation = (const FILETIME*)&ft->creation; + if ( ft->lastAccess != filetimestamp_invalid ) pLastAccess = (const FILETIME*)&ft->lastAccess; + if ( ft->lastWrite != filetimestamp_invalid ) pLastWrite = (const FILETIME*)&ft->lastWrite; + WIN32_IO_OP( SetFileTime(hFile, pCreation, pLastAccess, pLastWrite) ); + return 1; + } + } + return 0; + } + + t_filestats2 stats2_from_handle(HANDLE h, const wchar_t * fallbackPath, uint32_t flags, abort_callback& a) { + a.check(); + // Sadly GetFileInformationByHandle() is UNRELIABLE with certain net shares + BY_HANDLE_FILE_INFORMATION info = {}; + if (GetFileInformationByHandle(h, &info)) { + return file_win32_helpers::translate_stats2(info); + } + + a.check(); + t_filestats2 ret; + + // ALWAYS get size, fail if bad handle + ret.m_size = get_size(h); + + if (flags & (stats2_timestamp | stats2_timestampCreate)) { + static_assert(sizeof(t_filetimestamp) == sizeof(FILETIME), "struct sanity"); + FILETIME ftCreate = {}, ftWrite = {}; + if (GetFileTime(h, &ftCreate, nullptr, &ftWrite)) { + ret.m_timestamp = make_uint64(ftWrite); ret.m_timestampCreate = make_uint64(ftCreate); + } + } + if (flags & stats2_flags) { + // No other way to get this from handle? + if (fallbackPath != nullptr && *fallbackPath != 0) { + DWORD attr = GetFileAttributes(fallbackPath); + if (attr != INVALID_FILE_ATTRIBUTES) { + attribs_from_win32(ret, attr); + } + } + } + return ret; + } + void attribs_from_win32(t_filestats2& out, DWORD in) { + out.set_readonly((in & FILE_ATTRIBUTE_READONLY) != 0); + out.set_folder((in & FILE_ATTRIBUTE_DIRECTORY) != 0); + out.set_hidden((in & FILE_ATTRIBUTE_HIDDEN) != 0); + out.set_system((in & FILE_ATTRIBUTE_SYSTEM) != 0); + out.set_remote(false); + } + + + // Seek penalty query, effectively: is this an SSD? + // Credit: + // https://devblogs.microsoft.com/oldnewthing/20201023-00/?p=104395 + static bool queryVolumeSeekPenalty(HANDLE hVolume, bool& out) { + STORAGE_PROPERTY_QUERY query = {}; + query.PropertyId = StorageDeviceSeekPenaltyProperty; + query.QueryType = PropertyStandardQuery; + DWORD count = 1; + DEVICE_SEEK_PENALTY_DESCRIPTOR result = {}; + if (!DeviceIoControl(hVolume, IOCTL_STORAGE_QUERY_PROPERTY, &query, sizeof(query), &result, sizeof(result), &count, nullptr)) { + return false; + } + out = result.IncursSeekPenalty; + return true; + } + + static HANDLE GetVolumeHandleForFile(PCWSTR filePath) { + wchar_t volumePath[MAX_PATH] = {}; + WIN32_OP_D(GetVolumePathName(filePath, volumePath, ARRAYSIZE(volumePath))); + + wchar_t volumeName[MAX_PATH] = {}; + WIN32_OP_D(GetVolumeNameForVolumeMountPoint(volumePath, volumeName, ARRAYSIZE(volumeName))); + + auto length = wcslen(volumeName); + if ( length == 0 ) { + PFC_ASSERT(!"???"); + return NULL; + } + if (length && volumeName[length - 1] == L'\\') { + volumeName[length - 1] = L'\0'; + } + + HANDLE ret; + WIN32_OP_D( ret = CreateFile(volumeName, 0, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr) ); + return ret; + } + bool querySeekPenalty(const wchar_t* nativePath, bool& out) { + CHandle h; + h.Attach( GetVolumeHandleForFile( nativePath ) ); + if (!h) return false; + return queryVolumeSeekPenalty(h, out); + } + bool querySeekPenalty(const char* fb2k_path, bool& out) { + const char * path = fb2k_path; + if ( matchProtocol(path, "file")) path = afterProtocol(path); + return querySeekPenalty(pfc::wideFromUTF8(path), out); + } +} + +#endif // _WIN32 + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/file_win32_wrapper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/file_win32_wrapper.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,315 @@ +#pragma once + +#include +#include + +#ifdef _WIN32 +namespace file_win32_helpers { + t_filesize get_size(HANDLE p_handle); + void seek(HANDLE p_handle,t_sfilesize p_position,file::t_seek_mode p_mode); + void fillOverlapped(OVERLAPPED & ol, HANDLE myEvent, t_filesize s); + void writeOverlappedPass(HANDLE handle, HANDLE myEvent, t_filesize position, const void * in,DWORD inBytes, abort_callback & abort); + void writeOverlapped(HANDLE handle, HANDLE myEvent, t_filesize & position, const void * in, size_t inBytes, abort_callback & abort); + void writeStreamOverlapped(HANDLE handle, HANDLE myEvent, const void * in, size_t inBytes, abort_callback & abort); + DWORD readOverlappedPass(HANDLE handle, HANDLE myEvent, t_filesize position, void * out, DWORD outBytes, abort_callback & abort); + size_t readOverlapped(HANDLE handle, HANDLE myEvent, t_filesize & position, void * out, size_t outBytes, abort_callback & abort); + size_t readStreamOverlapped(HANDLE handle, HANDLE myEvent, void * out, size_t outBytes, abort_callback & abort); + HANDLE createFile(LPCTSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile, abort_callback & abort); + size_t lowLevelIO(HANDLE hFile, const GUID & guid, size_t arg1, void * arg2, size_t arg2size, bool canWrite, abort_callback & abort); + bool querySeekPenalty(const char * fb2k_path, bool & out); + bool querySeekPenalty(const wchar_t * nativePath, bool & out); + + static uint64_t make_uint64(t_uint32 p_low, t_uint32 p_high) { + return ((t_uint64)p_low) + ((t_uint64)p_high << 32); + } + static uint64_t make_uint64(LARGE_INTEGER const& i) { + return reinterpret_cast(i); + } + static uint64_t make_uint64(FILETIME const& ft) { + return reinterpret_cast(ft); +// return make_uint64(ft.dwLowDateTime, ft.dwHighDateTime); + } + + template + static t_filestats translate_stats(const t_info& p_info) { + t_filestats ret; + ret.m_size = make_uint64(p_info.nFileSizeLow, p_info.nFileSizeHigh); + ret.m_timestamp = make_uint64(p_info.ftLastWriteTime); + return ret; + } + + void attribs_from_win32(t_filestats2& out, DWORD in); + template + static t_filestats2 translate_stats2(const t_info& p_info) { + t_filestats2 ret; + ret.m_size = make_uint64(p_info.nFileSizeLow, p_info.nFileSizeHigh); + ret.m_timestamp = make_uint64(p_info.ftLastWriteTime); + ret.m_timestampCreate = make_uint64(p_info.ftCreationTime); + attribs_from_win32(ret, p_info.dwFileAttributes); + return ret; + } + + t_filestats2 stats2_from_handle(HANDLE, const wchar_t * fallbackPath, uint32_t flags, abort_callback &a); +}; + + +template +class file_win32_wrapper_t : public service_multi_inherit { + typedef file_win32_wrapper_t self_t; +public: + file_win32_wrapper_t(HANDLE handle, pfc::wstringLite && path) : m_handle(handle), m_path(std::move(path)) {} + + static file::ptr g_CreateFile(const char * p_path,DWORD p_access,DWORD p_sharemode,LPSECURITY_ATTRIBUTES p_security_attributes,DWORD p_createmode,DWORD p_flags,HANDLE p_template) { + auto pathW = pfc::wideFromUTF8(p_path); + SetLastError(NO_ERROR); + HANDLE handle = CreateFile(pathW,p_access,p_sharemode,p_security_attributes,p_createmode,p_flags,p_template); + if (handle == INVALID_HANDLE_VALUE) { + const DWORD code = GetLastError(); + if (p_access & GENERIC_WRITE) win32_file_write_failure(code, p_path); + else exception_io_from_win32(code); + } + try { + return g_create_from_handle(handle, std::move(pathW)); + } catch(...) {CloseHandle(handle); throw;} + } + + static service_ptr_t g_create_from_handle(HANDLE handle, pfc::wstringLite && path) { + return new service_impl_t(handle, std::move(path)); + } + static service_ptr_t g_create_from_handle(HANDLE handle) { + pfc::wstringLite blank; + g_create_from_handle(handle, std::move(blank)); + } + + + void reopen(abort_callback & p_abort) {seek(0,p_abort);} + + void write(const void * p_buffer,t_size p_bytes,abort_callback & p_abort) { + if (!p_writeable) throw exception_io_denied(); + + PFC_STATIC_ASSERT(sizeof(t_size) >= sizeof(DWORD)); + + t_size bytes_written_total = 0; + + if (sizeof(t_size) == sizeof(DWORD)) { + p_abort.check_e(); + DWORD bytes_written = 0; + SetLastError(ERROR_SUCCESS); + if (!WriteFile(m_handle,p_buffer,(DWORD)p_bytes,&bytes_written,0)) exception_io_from_win32(GetLastError()); + if (bytes_written != p_bytes) throw exception_io("Write failure"); + bytes_written_total = bytes_written; + m_position += bytes_written; + } else { + while(bytes_written_total < p_bytes) { + p_abort.check_e(); + DWORD bytes_written = 0; + DWORD delta = (DWORD) pfc::min_t(p_bytes - bytes_written_total, 0x80000000u); + SetLastError(ERROR_SUCCESS); + if (!WriteFile(m_handle,(const t_uint8*)p_buffer + bytes_written_total,delta,&bytes_written,0)) exception_io_from_win32(GetLastError()); + if (bytes_written != delta) throw exception_io("Write failure"); + bytes_written_total += bytes_written; + m_position += bytes_written; + } + } + } + + t_size read(void * p_buffer,t_size p_bytes,abort_callback & p_abort) { + PFC_STATIC_ASSERT(sizeof(t_size) >= sizeof(DWORD)); + + t_size bytes_read_total = 0; + if (sizeof(t_size) == sizeof(DWORD)) { + p_abort.check_e(); + DWORD bytes_read = 0; + SetLastError(ERROR_SUCCESS); + if (!ReadFile(m_handle,p_buffer,pfc::downcast_guarded(p_bytes),&bytes_read,0)) exception_io_from_win32(GetLastError()); + bytes_read_total = bytes_read; + m_position += bytes_read; + } else { + while(bytes_read_total < p_bytes) { + p_abort.check_e(); + DWORD bytes_read = 0; + DWORD delta = (DWORD) pfc::min_t(p_bytes - bytes_read_total, 0x80000000u); + SetLastError(ERROR_SUCCESS); + if (!ReadFile(m_handle,(t_uint8*)p_buffer + bytes_read_total,delta,&bytes_read,0)) exception_io_from_win32(GetLastError()); + bytes_read_total += bytes_read; + m_position += bytes_read; + if (bytes_read != delta) break; + } + } + return bytes_read_total; + } + + + t_filesize get_size(abort_callback & p_abort) { + p_abort.check_e(); + return file_win32_helpers::get_size(m_handle); + } + + t_filesize get_position(abort_callback & p_abort) { + p_abort.check_e(); + return m_position; + } + + void resize(t_filesize p_size,abort_callback & p_abort) { + if (!p_writeable) throw exception_io_denied(); + p_abort.check_e(); + if (m_position != p_size) { + file_win32_helpers::seek(m_handle,p_size,file::seek_from_beginning); + } + SetLastError(ERROR_SUCCESS); + if (!SetEndOfFile(m_handle)) { + DWORD code = GetLastError(); + if (m_position != p_size) try {file_win32_helpers::seek(m_handle,m_position,file::seek_from_beginning);} catch(...) {} + exception_io_from_win32(code); + } + if (m_position > p_size) m_position = p_size; + if (m_position != p_size) file_win32_helpers::seek(m_handle,m_position,file::seek_from_beginning); + } + + + void seek(t_filesize p_position,abort_callback & p_abort) { + if (!p_seekable) throw exception_io_object_not_seekable(); + p_abort.check_e(); + if (p_position > file_win32_helpers::get_size(m_handle)) throw exception_io_seek_out_of_range(); + file_win32_helpers::seek(m_handle,p_position,file::seek_from_beginning); + m_position = p_position; + } + + bool can_seek() {return p_seekable;} + bool get_content_type(pfc::string_base & out) {return false;} + bool is_in_memory() {return false;} + void on_idle(abort_callback & p_abort) {p_abort.check_e();} + + t_filestats2 get_stats2(uint32_t f, abort_callback& a) { + a.check(); + if (p_writeable) FlushFileBuffers(m_handle); + return file_win32_helpers::stats2_from_handle(m_handle, m_path, f, a); + } + t_filetimestamp get_timestamp(abort_callback & p_abort) { + p_abort.check_e(); + if (p_writeable) FlushFileBuffers(m_handle); + SetLastError(ERROR_SUCCESS); + FILETIME temp; + if (!GetFileTime(m_handle,0,0,&temp)) exception_io_from_win32(GetLastError()); + return file_win32_helpers::make_uint64(temp); + } + + bool is_remote() {return false;} + ~file_win32_wrapper_t() {CloseHandle(m_handle);} + + size_t lowLevelIO(const GUID & guid, size_t arg1, void * arg2, size_t arg2size, abort_callback & abort) override { + return file_win32_helpers::lowLevelIO(m_handle, guid, arg1, arg2, arg2size, p_writeable, abort); + } +protected: + HANDLE m_handle; + t_filesize m_position = 0; + pfc::wstringLite m_path; +}; + +template +class file_win32_wrapper_overlapped_t : public service_multi_inherit< file_v2, file_lowLevelIO > { + typedef file_win32_wrapper_overlapped_t self_t; +public: + file_win32_wrapper_overlapped_t(HANDLE file, pfc::wstringLite && path) : m_handle(file), m_path(std::move(path)) { + WIN32_OP( (m_event = CreateEvent(NULL, TRUE, FALSE, NULL)) != NULL ); + } + ~file_win32_wrapper_overlapped_t() {CloseHandle(m_event); CloseHandle(m_handle);} + void write(const void * p_buffer,t_size p_bytes,abort_callback & p_abort) { + if (!p_writeable) throw exception_io_denied(); + return file_win32_helpers::writeOverlapped(m_handle, m_event, m_position, p_buffer, p_bytes, p_abort); + } + t_size read(void * p_buffer,t_size p_bytes,abort_callback & p_abort) { + return file_win32_helpers::readOverlapped(m_handle, m_event, m_position, p_buffer, p_bytes, p_abort); + } + + void reopen(abort_callback & p_abort) {seek(0,p_abort);} + + + t_filesize get_size(abort_callback & p_abort) { + p_abort.check_e(); + return file_win32_helpers::get_size(m_handle); + } + + t_filesize get_position(abort_callback & p_abort) { + p_abort.check_e(); + return m_position; + } + + void resize(t_filesize p_size,abort_callback & p_abort) { + if (!p_writeable) throw exception_io_denied(); + p_abort.check_e(); + file_win32_helpers::seek(m_handle,p_size,file::seek_from_beginning); + SetLastError(ERROR_SUCCESS); + if (!SetEndOfFile(m_handle)) { + DWORD code = GetLastError(); + exception_io_from_win32(code); + } + if (m_position > p_size) m_position = p_size; + } + + + void seek(t_filesize p_position,abort_callback & p_abort) { + p_abort.check_e(); + if (p_position > file_win32_helpers::get_size(m_handle)) throw exception_io_seek_out_of_range(); + // file_win32_helpers::seek(m_handle,p_position,file::seek_from_beginning); + m_position = p_position; + } + + bool can_seek() {return true;} + bool get_content_type(pfc::string_base & out) {return false;} + bool is_in_memory() {return false;} + void on_idle(abort_callback & p_abort) {p_abort.check_e();} + + + t_filestats2 get_stats2(uint32_t f, abort_callback& a) { + a.check(); + if (p_writeable) FlushFileBuffers(m_handle); + return file_win32_helpers::stats2_from_handle(m_handle, m_path, f, a); + } + + t_filetimestamp get_timestamp(abort_callback & p_abort) { + p_abort.check_e(); + if (p_writeable) FlushFileBuffers(m_handle); + SetLastError(ERROR_SUCCESS); + FILETIME temp; + if (!GetFileTime(m_handle,0,0,&temp)) exception_io_from_win32(GetLastError()); + return file_win32_helpers::make_uint64(temp); + } + + bool is_remote() {return false;} + + + static file::ptr g_CreateFile(const char * p_path,DWORD p_access,DWORD p_sharemode,LPSECURITY_ATTRIBUTES p_security_attributes,DWORD p_createmode,DWORD p_flags,HANDLE p_template) { + auto pathW = pfc::wideFromUTF8(p_path); + p_flags |= FILE_FLAG_OVERLAPPED; + SetLastError(NO_ERROR); + HANDLE handle = CreateFile(pathW,p_access,p_sharemode,p_security_attributes,p_createmode,p_flags,p_template); + if (handle == INVALID_HANDLE_VALUE) { + const DWORD code = GetLastError(); + if (p_access & GENERIC_WRITE) win32_file_write_failure(code, p_path); + else exception_io_from_win32(code); + } + try { + return g_create_from_handle(handle, std::move(pathW)); + } catch(...) {CloseHandle(handle); throw;} + } + + static file::ptr g_create_from_handle(HANDLE p_handle, pfc::wstringLite && path) { + return new service_impl_t(p_handle, std::move(path)); + } + static file::ptr g_create_from_handle(HANDLE p_handle) { + pfc::wstringLite blank; + return g_create_from_handle(p_handle, std::move(blank)); + } + + size_t lowLevelIO(const GUID & guid, size_t arg1, void * arg2, size_t arg2size, abort_callback & abort) override { + return file_win32_helpers::lowLevelIO(m_handle, guid, arg1, arg2, arg2size, p_writeable, abort); + } + +protected: + HANDLE m_event, m_handle; + t_filesize m_position = 0; + pfc::wstringLite m_path; +}; + +#endif // _WIN32 diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/filetimetools.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/filetimetools.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,28 @@ +#include "StdAfx.h" + +#include "filetimetools.h" + +#include + +// Stub - functionality moved to PFC + +namespace foobar2000_io { + t_filetimestamp filetimestamp_from_string(const char* date) { + return pfc::filetimestamp_from_string( date ); + } + t_filetimestamp filetimestamp_from_string_utc(const char* date) { + return pfc::filetimestamp_from_string_utc( date ); + } + + pfc::string_formatter format_filetimestamp(t_filetimestamp p_timestamp) { + return pfc::format_filetimestamp( p_timestamp ); + } + + pfc::string_formatter format_filetimestamp_utc(t_filetimestamp p_timestamp) { + return pfc::format_filetimestamp_utc( p_timestamp ); + } + + pfc::string_formatter format_filetimestamp_ms(t_filetimestamp p_timestamp) { + return pfc::format_filetimestamp_ms( p_timestamp ); + } +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/filetimetools.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/filetimetools.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,13 @@ +#pragma once + +namespace foobar2000_io { + t_filetimestamp filetimestamp_from_string(const char * date); + t_filetimestamp filetimestamp_from_string_utc(const char* date); + + //! Warning: this formats according to system timezone settings, created strings should be used for display only, never for storage. + pfc::string_formatter format_filetimestamp(t_filetimestamp p_timestamp); + //! UTC timestamp + pfc::string_formatter format_filetimestamp_utc(t_filetimestamp p_timestamp); + //! Local timestamp with milliseconds + pfc::string_formatter format_filetimestamp_ms(t_filetimestamp p_timestamp); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/foobar2000+atl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/foobar2000+atl.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,3 @@ +#pragma once +#include "foobar2000-lite+atl.h" +#include \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/foobar2000-lite+atl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/foobar2000-lite+atl.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,22 @@ +#pragma once + +#include "../SDK/foobar2000-winver.h" + +#ifdef _WIN32 +#define _SECURE_ATL 1 +#endif + +#include "../SDK/foobar2000-lite.h" + +#ifdef _WIN32 +#include +#include +#include +#include +#include +#include +#include +#include +#endif + +#pragma once diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/foobar2000_SDK_helpers.xcodeproj/project.pbxproj --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/foobar2000_SDK_helpers.xcodeproj/project.pbxproj Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,819 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 54; + objects = { + +/* Begin PBXBuildFile section */ + 0F75F5EA2A6B1DB200A45078 /* dialog_resize_helper.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5622A6B1DAE00A45078 /* dialog_resize_helper.h */; }; + 0F75F5EB2A6B1DB200A45078 /* input_logging.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5632A6B1DAE00A45078 /* input_logging.h */; }; + 0F75F5EC2A6B1DB200A45078 /* cfg_var_import.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F5642A6B1DAE00A45078 /* cfg_var_import.cpp */; }; + 0F75F5ED2A6B1DB200A45078 /* readers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F5652A6B1DAE00A45078 /* readers.cpp */; }; + 0F75F5EE2A6B1DB200A45078 /* text_file_loader_v2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F5662A6B1DAE00A45078 /* text_file_loader_v2.cpp */; }; + 0F75F5EF2A6B1DB200A45078 /* VisUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5672A6B1DAE00A45078 /* VisUtils.h */; }; + 0F75F5F02A6B1DB200A45078 /* file_move_helper.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5682A6B1DAE00A45078 /* file_move_helper.h */; }; + 0F75F5F12A6B1DB200A45078 /* filetimetools.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5692A6B1DAE00A45078 /* filetimetools.h */; }; + 0F75F5F22A6B1DB200A45078 /* create_directory_helper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F56A2A6B1DAE00A45078 /* create_directory_helper.cpp */; }; + 0F75F5F32A6B1DB200A45078 /* writer_wav.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F56B2A6B1DAE00A45078 /* writer_wav.h */; }; + 0F75F5F42A6B1DB200A45078 /* VisUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F56C2A6B1DAE00A45078 /* VisUtils.cpp */; }; + 0F75F5F52A6B1DB200A45078 /* COM_utils.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F56D2A6B1DAE00A45078 /* COM_utils.h */; }; + 0F75F5F62A6B1DB200A45078 /* VolumeMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F56E2A6B1DAE00A45078 /* VolumeMap.h */; }; + 0F75F5F72A6B1DB200A45078 /* file_win32_wrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F56F2A6B1DAE00A45078 /* file_win32_wrapper.h */; }; + 0F75F5F82A6B1DB200A45078 /* foobar2000-lite+atl.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5702A6B1DAE00A45078 /* foobar2000-lite+atl.h */; }; + 0F75F5F92A6B1DB200A45078 /* metadb_handle_array.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5712A6B1DAE00A45078 /* metadb_handle_array.h */; }; + 0F75F5FA2A6B1DB200A45078 /* atl-misc.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5722A6B1DAE00A45078 /* atl-misc.h */; }; + 0F75F5FB2A6B1DB200A45078 /* CSingleThreadWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5732A6B1DAE00A45078 /* CSingleThreadWrapper.h */; }; + 0F75F5FC2A6B1DB200A45078 /* image_load_save.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5742A6B1DAE00A45078 /* image_load_save.h */; }; + 0F75F5FD2A6B1DB200A45078 /* reader_pretend_nonseekable.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5752A6B1DAF00A45078 /* reader_pretend_nonseekable.h */; }; + 0F75F5FF2A6B1DB200A45078 /* meta_table_builder.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5772A6B1DAF00A45078 /* meta_table_builder.h */; }; + 0F75F6002A6B1DB200A45078 /* fb2k_threads.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5782A6B1DAF00A45078 /* fb2k_threads.h */; }; + 0F75F6012A6B1DB200A45078 /* playlist_position_reference_tracker.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5792A6B1DAF00A45078 /* playlist_position_reference_tracker.h */; }; + 0F75F6022A6B1DB200A45078 /* file_list_helper.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F57A2A6B1DAF00A45078 /* file_list_helper.h */; }; + 0F75F6032A6B1DB200A45078 /* inplace_edit.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F57B2A6B1DAF00A45078 /* inplace_edit.h */; }; + 0F75F6042A6B1DB200A45078 /* album_art_helpers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F57C2A6B1DAF00A45078 /* album_art_helpers.cpp */; }; + 0F75F6052A6B1DB200A45078 /* AutoComplete.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F57D2A6B1DAF00A45078 /* AutoComplete.h */; }; + 0F75F6062A6B1DB200A45078 /* ProfileCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F57E2A6B1DAF00A45078 /* ProfileCache.h */; }; + 0F75F6072A6B1DB200A45078 /* fileReadAhead.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F57F2A6B1DAF00A45078 /* fileReadAhead.h */; }; + 0F75F6082A6B1DB200A45078 /* cfg_dsp_chain_config.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5802A6B1DAF00A45078 /* cfg_dsp_chain_config.h */; }; + 0F75F6092A6B1DB200A45078 /* metadb_io_callback_v2_data.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5812A6B1DAF00A45078 /* metadb_io_callback_v2_data.h */; }; + 0F75F60A2A6B1DB200A45078 /* cue_parser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F5822A6B1DAF00A45078 /* cue_parser.cpp */; }; + 0F75F60C2A6B1DB200A45078 /* ui_element_helpers.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5842A6B1DAF00A45078 /* ui_element_helpers.h */; }; + 0F75F60D2A6B1DB200A45078 /* CListControlFb2kColors.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5852A6B1DAF00A45078 /* CListControlFb2kColors.h */; }; + 0F75F60E2A6B1DB200A45078 /* stream_buffer_helper.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5862A6B1DAF00A45078 /* stream_buffer_helper.h */; }; + 0F75F60F2A6B1DB200A45078 /* advconfig_runtime.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5872A6B1DAF00A45078 /* advconfig_runtime.h */; }; + 0F75F6102A6B1DB200A45078 /* readWriteLock.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5882A6B1DAF00A45078 /* readWriteLock.h */; }; + 0F75F6112A6B1DB200A45078 /* writer_wav.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F5892A6B1DAF00A45078 /* writer_wav.cpp */; }; + 0F75F6122A6B1DB200A45078 /* fb2kWorkerTool.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F58A2A6B1DAF00A45078 /* fb2kWorkerTool.h */; }; + 0F75F6132A6B1DB200A45078 /* cfg_objList.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F58B2A6B1DAF00A45078 /* cfg_objList.h */; }; + 0F75F6142A6B1DB200A45078 /* CDialogResizeHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F58C2A6B1DAF00A45078 /* CDialogResizeHelper.h */; }; + 0F75F6152A6B1DB200A45078 /* file_info_const_impl.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F58D2A6B1DAF00A45078 /* file_info_const_impl.h */; }; + 0F75F6162A6B1DB200A45078 /* file_list_helper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F58E2A6B1DAF00A45078 /* file_list_helper.cpp */; }; + 0F75F6172A6B1DB200A45078 /* albumArtCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F58F2A6B1DAF00A45078 /* albumArtCache.h */; }; + 0F75F6182A6B1DB200A45078 /* rethrow.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5902A6B1DAF00A45078 /* rethrow.h */; }; + 0F75F6192A6B1DB200A45078 /* cfg_var_import.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5912A6B1DAF00A45078 /* cfg_var_import.h */; }; + 0F75F61A2A6B1DB200A45078 /* album_art_helpers.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5922A6B1DB000A45078 /* album_art_helpers.h */; }; + 0F75F61B2A6B1DB200A45078 /* create_directory_helper.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5932A6B1DB000A45078 /* create_directory_helper.h */; }; + 0F75F61C2A6B1DB200A45078 /* input_helpers.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5942A6B1DB000A45078 /* input_helpers.h */; }; + 0F75F61D2A6B1DB200A45078 /* notifyList.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5952A6B1DB000A45078 /* notifyList.h */; }; + 0F75F6202A6B1DB200A45078 /* win-MulDiv.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5982A6B1DB000A45078 /* win-MulDiv.h */; }; + 0F75F6212A6B1DB200A45078 /* metadb_info_container_impl.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5992A6B1DB000A45078 /* metadb_info_container_impl.h */; }; + 0F75F6222A6B1DB200A45078 /* metadb_io_hintlist.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F59A2A6B1DB000A45078 /* metadb_io_hintlist.h */; }; + 0F75F6232A6B1DB200A45078 /* track_property_callback_impl.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F59B2A6B1DB000A45078 /* track_property_callback_impl.h */; }; + 0F75F6242A6B1DB200A45078 /* filetimetools.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F59C2A6B1DB000A45078 /* filetimetools.cpp */; }; + 0F75F6252A6B1DB200A45078 /* ProcessUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F59D2A6B1DB000A45078 /* ProcessUtils.h */; }; + 0F75F6262A6B1DB200A45078 /* readers.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F59E2A6B1DB000A45078 /* readers.h */; }; + 0F75F6272A6B1DB200A45078 /* VolumeMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F59F2A6B1DB000A45078 /* VolumeMap.cpp */; }; + 0F75F6282A6B1DB200A45078 /* cfg_guidlist.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F5A02A6B1DB000A45078 /* cfg_guidlist.cpp */; }; + 0F75F6292A6B1DB200A45078 /* dropdown_helper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F5A12A6B1DB000A45078 /* dropdown_helper.cpp */; }; + 0F75F62A2A6B1DB200A45078 /* callback_merit.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5A22A6B1DB000A45078 /* callback_merit.h */; }; + 0F75F62B2A6B1DB200A45078 /* cue_creator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F5A32A6B1DB000A45078 /* cue_creator.cpp */; }; + 0F75F62C2A6B1DB200A45078 /* CPropVariant.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5A42A6B1DB000A45078 /* CPropVariant.h */; }; + 0F75F62D2A6B1DB200A45078 /* text_file_loader_v2.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5A52A6B1DB000A45078 /* text_file_loader_v2.h */; }; + 0F75F62E2A6B1DB200A45078 /* helpers.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5A62A6B1DB000A45078 /* helpers.h */; }; + 0F75F6302A6B1DB200A45078 /* dynamic_bitrate_helper.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5A82A6B1DB000A45078 /* dynamic_bitrate_helper.h */; }; + 0F75F6312A6B1DB200A45078 /* packet_decoder_mp3_common.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5A92A6B1DB000A45078 /* packet_decoder_mp3_common.h */; }; + 0F75F6322A6B1DB200A45078 /* foobar2000+atl.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5AA2A6B1DB000A45078 /* foobar2000+atl.h */; }; + 0F75F6332A6B1DB200A45078 /* CallForwarder.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5AB2A6B1DB000A45078 /* CallForwarder.h */; }; + 0F75F6342A6B1DB200A45078 /* StdAfx.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F5AC2A6B1DB000A45078 /* StdAfx.cpp */; }; + 0F75F6352A6B1DB200A45078 /* CTableEditHelper-Legacy.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5AD2A6B1DB100A45078 /* CTableEditHelper-Legacy.h */; }; + 0F75F6362A6B1DB200A45078 /* window_placement_helper.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5AE2A6B1DB100A45078 /* window_placement_helper.h */; }; + 0F75F6372A6B1DB200A45078 /* input_helper_cue.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5AF2A6B1DB100A45078 /* input_helper_cue.h */; }; + 0F75F6382A6B1DB200A45078 /* cuesheet_index_list.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F5B02A6B1DB100A45078 /* cuesheet_index_list.cpp */; }; + 0F75F6392A6B1DB200A45078 /* win-systemtime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F5B12A6B1DB100A45078 /* win-systemtime.cpp */; }; + 0F75F63A2A6B1DB200A45078 /* dynamic_bitrate_helper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F5B22A6B1DB100A45078 /* dynamic_bitrate_helper.cpp */; }; + 0F75F63B2A6B1DB200A45078 /* bitreader_helper.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5B32A6B1DB100A45078 /* bitreader_helper.h */; }; + 0F75F63C2A6B1DB200A45078 /* StdAfx.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5B42A6B1DB100A45078 /* StdAfx.h */; }; + 0F75F63D2A6B1DB200A45078 /* packet_decoder_aac_common.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5B52A6B1DB100A45078 /* packet_decoder_aac_common.h */; }; + 0F75F63E2A6B1DB200A45078 /* CmdThread.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5B62A6B1DB100A45078 /* CmdThread.h */; }; + 0F75F63F2A6B1DB200A45078 /* readers_lite.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5B72A6B1DB100A45078 /* readers_lite.h */; }; + 0F75F6402A6B1DB200A45078 /* text_file_loader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F5B82A6B1DB100A45078 /* text_file_loader.cpp */; }; + 0F75F6412A6B1DB200A45078 /* cue_creator.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5B92A6B1DB100A45078 /* cue_creator.h */; }; + 0F75F6422A6B1DB200A45078 /* ThreadUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F5BA2A6B1DB100A45078 /* ThreadUtils.cpp */; }; + 0F75F6432A6B1DB200A45078 /* file_streamstub.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5BB2A6B1DB100A45078 /* file_streamstub.h */; }; + 0F75F6442A6B1DB200A45078 /* tag_write_callback_impl.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5BC2A6B1DB100A45078 /* tag_write_callback_impl.h */; }; + 0F75F6452A6B1DB200A45078 /* win32_misc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F5BD2A6B1DB100A45078 /* win32_misc.cpp */; }; + 0F75F6462A6B1DB200A45078 /* WindowPositionUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5BE2A6B1DB100A45078 /* WindowPositionUtils.h */; }; + 0F75F6472A6B1DB200A45078 /* packet_decoder_mp3_common.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F5BF2A6B1DB100A45078 /* packet_decoder_mp3_common.cpp */; }; + 0F75F6492A6B1DB200A45078 /* duration_counter.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5C12A6B1DB100A45078 /* duration_counter.h */; }; + 0F75F64A2A6B1DB200A45078 /* cue_parser.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5C22A6B1DB100A45078 /* cue_parser.h */; }; + 0F75F64B2A6B1DB200A45078 /* dialog_resize_helper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F5C32A6B1DB100A45078 /* dialog_resize_helper.cpp */; }; + 0F75F64C2A6B1DB200A45078 /* seekabilizer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F5C42A6B1DB100A45078 /* seekabilizer.cpp */; }; + 0F75F64D2A6B1DB200A45078 /* fullFileBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5C52A6B1DB100A45078 /* fullFileBuffer.h */; }; + 0F75F64E2A6B1DB200A45078 /* win32_dialog.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5C62A6B1DB100A45078 /* win32_dialog.h */; }; + 0F75F64F2A6B1DB200A45078 /* cuesheet_index_list.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5C72A6B1DB100A45078 /* cuesheet_index_list.h */; }; + 0F75F6502A6B1DB200A45078 /* callInMainThreadHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5C82A6B1DB100A45078 /* callInMainThreadHelper.h */; }; + 0F75F6512A6B1DB200A45078 /* icon_remapping_wildcard.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5C92A6B1DB100A45078 /* icon_remapping_wildcard.h */; }; + 0F75F6522A6B1DB200A45078 /* audio_render_float.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5CA2A6B1DB100A45078 /* audio_render_float.h */; }; + 0F75F6542A6B1DB200A45078 /* advconfig_impl.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5CC2A6B1DB100A45078 /* advconfig_impl.h */; }; + 0F75F6552A6B1DB200A45078 /* input_fix_seeking.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5CD2A6B1DB100A45078 /* input_fix_seeking.h */; }; + 0F75F6562A6B1DB200A45078 /* win-systemtime.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5CE2A6B1DB100A45078 /* win-systemtime.h */; }; + 0F75F6572A6B1DB200A45078 /* stream_buffer_helper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F5CF2A6B1DB100A45078 /* stream_buffer_helper.cpp */; }; + 0F75F6582A6B1DB200A45078 /* dsp_dialog.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5D02A6B1DB100A45078 /* dsp_dialog.h */; }; + 0F75F6592A6B1DB200A45078 /* BumpableElem.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5D12A6B1DB100A45078 /* BumpableElem.h */; }; + 0F75F65A2A6B1DB200A45078 /* cfg_obj.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5D22A6B1DB100A45078 /* cfg_obj.h */; }; + 0F75F65B2A6B1DB200A45078 /* packet_decoder_aac_common.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F5D32A6B1DB200A45078 /* packet_decoder_aac_common.cpp */; }; + 0F75F65C2A6B1DB200A45078 /* mp3_utils.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5D42A6B1DB200A45078 /* mp3_utils.h */; }; + 0F75F65D2A6B1DB200A45078 /* cue_parser_embedding.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F5D52A6B1DB200A45078 /* cue_parser_embedding.cpp */; }; + 0F75F65E2A6B1DB200A45078 /* input_helpers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F5D62A6B1DB200A45078 /* input_helpers.cpp */; }; + 0F75F65F2A6B1DB200A45078 /* ThreadUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5D72A6B1DB200A45078 /* ThreadUtils.h */; }; + 0F75F6602A6B1DB200A45078 /* track_property_callback_impl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F5D82A6B1DB200A45078 /* track_property_callback_impl.cpp */; }; + 0F75F6622A6B1DB200A45078 /* fb2k_wfx.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5DA2A6B1DB200A45078 /* fb2k_wfx.h */; }; + 0F75F6632A6B1DB200A45078 /* DarkMode.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5DB2A6B1DB200A45078 /* DarkMode.h */; }; + 0F75F6642A6B1DB200A45078 /* win32_misc.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5DC2A6B1DB200A45078 /* win32_misc.h */; }; + 0F75F6652A6B1DB200A45078 /* winmm-types.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5DD2A6B1DB200A45078 /* winmm-types.h */; }; + 0F75F6662A6B1DB200A45078 /* metadb_handle_set.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5DE2A6B1DB200A45078 /* metadb_handle_set.h */; }; + 0F75F6672A6B1DB200A45078 /* mp3_utils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F5DF2A6B1DB200A45078 /* mp3_utils.cpp */; }; + 0F75F6682A6B1DB200A45078 /* file_win32_wrapper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F5E02A6B1DB200A45078 /* file_win32_wrapper.cpp */; }; + 0F75F6692A6B1DB200A45078 /* seekabilizer.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5E12A6B1DB200A45078 /* seekabilizer.h */; }; + 0F75F66A2A6B1DB200A45078 /* file_move_helper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F5E22A6B1DB200A45078 /* file_move_helper.cpp */; }; + 0F75F66B2A6B1DB200A45078 /* cfg_guidlist.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5E32A6B1DB200A45078 /* cfg_guidlist.h */; }; + 0F75F66C2A6B1DB200A45078 /* input_helper_cue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F5E42A6B1DB200A45078 /* input_helper_cue.cpp */; }; + 0F75F66D2A6B1DB200A45078 /* text_file_loader.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5E52A6B1DB200A45078 /* text_file_loader.h */; }; + 0F75F66E2A6B1DB200A45078 /* file_cached.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5E62A6B1DB200A45078 /* file_cached.h */; }; + 0F75F66F2A6B1DB200A45078 /* input_stream_info_reader.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5E72A6B1DB200A45078 /* input_stream_info_reader.h */; }; + 0F75F6712A6B1DB200A45078 /* dropdown_helper.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75F5E92A6B1DB200A45078 /* dropdown_helper.h */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 0F75F5622A6B1DAE00A45078 /* dialog_resize_helper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dialog_resize_helper.h; sourceTree = ""; }; + 0F75F5632A6B1DAE00A45078 /* input_logging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = input_logging.h; sourceTree = ""; }; + 0F75F5642A6B1DAE00A45078 /* cfg_var_import.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cfg_var_import.cpp; sourceTree = ""; }; + 0F75F5652A6B1DAE00A45078 /* readers.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = readers.cpp; sourceTree = ""; }; + 0F75F5662A6B1DAE00A45078 /* text_file_loader_v2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = text_file_loader_v2.cpp; sourceTree = ""; }; + 0F75F5672A6B1DAE00A45078 /* VisUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VisUtils.h; sourceTree = ""; }; + 0F75F5682A6B1DAE00A45078 /* file_move_helper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = file_move_helper.h; sourceTree = ""; }; + 0F75F5692A6B1DAE00A45078 /* filetimetools.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = filetimetools.h; sourceTree = ""; }; + 0F75F56A2A6B1DAE00A45078 /* create_directory_helper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = create_directory_helper.cpp; sourceTree = ""; }; + 0F75F56B2A6B1DAE00A45078 /* writer_wav.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = writer_wav.h; sourceTree = ""; }; + 0F75F56C2A6B1DAE00A45078 /* VisUtils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VisUtils.cpp; sourceTree = ""; }; + 0F75F56D2A6B1DAE00A45078 /* COM_utils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = COM_utils.h; sourceTree = ""; }; + 0F75F56E2A6B1DAE00A45078 /* VolumeMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VolumeMap.h; sourceTree = ""; }; + 0F75F56F2A6B1DAE00A45078 /* file_win32_wrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = file_win32_wrapper.h; sourceTree = ""; }; + 0F75F5702A6B1DAE00A45078 /* foobar2000-lite+atl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "foobar2000-lite+atl.h"; sourceTree = ""; }; + 0F75F5712A6B1DAE00A45078 /* metadb_handle_array.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = metadb_handle_array.h; sourceTree = ""; }; + 0F75F5722A6B1DAE00A45078 /* atl-misc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "atl-misc.h"; sourceTree = ""; }; + 0F75F5732A6B1DAE00A45078 /* CSingleThreadWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSingleThreadWrapper.h; sourceTree = ""; }; + 0F75F5742A6B1DAE00A45078 /* image_load_save.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = image_load_save.h; sourceTree = ""; }; + 0F75F5752A6B1DAF00A45078 /* reader_pretend_nonseekable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = reader_pretend_nonseekable.h; sourceTree = ""; }; + 0F75F5762A6B1DAF00A45078 /* window_placement_helper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = window_placement_helper.cpp; sourceTree = ""; }; + 0F75F5772A6B1DAF00A45078 /* meta_table_builder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = meta_table_builder.h; sourceTree = ""; }; + 0F75F5782A6B1DAF00A45078 /* fb2k_threads.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fb2k_threads.h; sourceTree = ""; }; + 0F75F5792A6B1DAF00A45078 /* playlist_position_reference_tracker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = playlist_position_reference_tracker.h; sourceTree = ""; }; + 0F75F57A2A6B1DAF00A45078 /* file_list_helper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = file_list_helper.h; sourceTree = ""; }; + 0F75F57B2A6B1DAF00A45078 /* inplace_edit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = inplace_edit.h; sourceTree = ""; }; + 0F75F57C2A6B1DAF00A45078 /* album_art_helpers.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = album_art_helpers.cpp; sourceTree = ""; }; + 0F75F57D2A6B1DAF00A45078 /* AutoComplete.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AutoComplete.h; sourceTree = ""; }; + 0F75F57E2A6B1DAF00A45078 /* ProfileCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProfileCache.h; sourceTree = ""; }; + 0F75F57F2A6B1DAF00A45078 /* fileReadAhead.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fileReadAhead.h; sourceTree = ""; }; + 0F75F5802A6B1DAF00A45078 /* cfg_dsp_chain_config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cfg_dsp_chain_config.h; sourceTree = ""; }; + 0F75F5812A6B1DAF00A45078 /* metadb_io_callback_v2_data.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = metadb_io_callback_v2_data.h; sourceTree = ""; }; + 0F75F5822A6B1DAF00A45078 /* cue_parser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cue_parser.cpp; sourceTree = ""; }; + 0F75F5832A6B1DAF00A45078 /* ui_element_helpers.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ui_element_helpers.cpp; sourceTree = ""; }; + 0F75F5842A6B1DAF00A45078 /* ui_element_helpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ui_element_helpers.h; sourceTree = ""; }; + 0F75F5852A6B1DAF00A45078 /* CListControlFb2kColors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CListControlFb2kColors.h; sourceTree = ""; }; + 0F75F5862A6B1DAF00A45078 /* stream_buffer_helper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = stream_buffer_helper.h; sourceTree = ""; }; + 0F75F5872A6B1DAF00A45078 /* advconfig_runtime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = advconfig_runtime.h; sourceTree = ""; }; + 0F75F5882A6B1DAF00A45078 /* readWriteLock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = readWriteLock.h; sourceTree = ""; }; + 0F75F5892A6B1DAF00A45078 /* writer_wav.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = writer_wav.cpp; sourceTree = ""; }; + 0F75F58A2A6B1DAF00A45078 /* fb2kWorkerTool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fb2kWorkerTool.h; sourceTree = ""; }; + 0F75F58B2A6B1DAF00A45078 /* cfg_objList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cfg_objList.h; sourceTree = ""; }; + 0F75F58C2A6B1DAF00A45078 /* CDialogResizeHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDialogResizeHelper.h; sourceTree = ""; }; + 0F75F58D2A6B1DAF00A45078 /* file_info_const_impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = file_info_const_impl.h; sourceTree = ""; }; + 0F75F58E2A6B1DAF00A45078 /* file_list_helper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = file_list_helper.cpp; sourceTree = ""; }; + 0F75F58F2A6B1DAF00A45078 /* albumArtCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = albumArtCache.h; sourceTree = ""; }; + 0F75F5902A6B1DAF00A45078 /* rethrow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = rethrow.h; sourceTree = ""; }; + 0F75F5912A6B1DAF00A45078 /* cfg_var_import.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cfg_var_import.h; sourceTree = ""; }; + 0F75F5922A6B1DB000A45078 /* album_art_helpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = album_art_helpers.h; sourceTree = ""; }; + 0F75F5932A6B1DB000A45078 /* create_directory_helper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = create_directory_helper.h; sourceTree = ""; }; + 0F75F5942A6B1DB000A45078 /* input_helpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = input_helpers.h; sourceTree = ""; }; + 0F75F5952A6B1DB000A45078 /* notifyList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = notifyList.h; sourceTree = ""; }; + 0F75F5962A6B1DB000A45078 /* inplace_edit.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = inplace_edit.cpp; sourceTree = ""; }; + 0F75F5972A6B1DB000A45078 /* image_load_save.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = image_load_save.cpp; sourceTree = ""; }; + 0F75F5982A6B1DB000A45078 /* win-MulDiv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "win-MulDiv.h"; sourceTree = ""; }; + 0F75F5992A6B1DB000A45078 /* metadb_info_container_impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = metadb_info_container_impl.h; sourceTree = ""; }; + 0F75F59A2A6B1DB000A45078 /* metadb_io_hintlist.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = metadb_io_hintlist.h; sourceTree = ""; }; + 0F75F59B2A6B1DB000A45078 /* track_property_callback_impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = track_property_callback_impl.h; sourceTree = ""; }; + 0F75F59C2A6B1DB000A45078 /* filetimetools.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = filetimetools.cpp; sourceTree = ""; }; + 0F75F59D2A6B1DB000A45078 /* ProcessUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProcessUtils.h; sourceTree = ""; }; + 0F75F59E2A6B1DB000A45078 /* readers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = readers.h; sourceTree = ""; }; + 0F75F59F2A6B1DB000A45078 /* VolumeMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VolumeMap.cpp; sourceTree = ""; }; + 0F75F5A02A6B1DB000A45078 /* cfg_guidlist.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cfg_guidlist.cpp; sourceTree = ""; }; + 0F75F5A12A6B1DB000A45078 /* dropdown_helper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = dropdown_helper.cpp; sourceTree = ""; }; + 0F75F5A22A6B1DB000A45078 /* callback_merit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = callback_merit.h; sourceTree = ""; }; + 0F75F5A32A6B1DB000A45078 /* cue_creator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cue_creator.cpp; sourceTree = ""; }; + 0F75F5A42A6B1DB000A45078 /* CPropVariant.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CPropVariant.h; sourceTree = ""; }; + 0F75F5A52A6B1DB000A45078 /* text_file_loader_v2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = text_file_loader_v2.h; sourceTree = ""; }; + 0F75F5A62A6B1DB000A45078 /* helpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = helpers.h; sourceTree = ""; }; + 0F75F5A72A6B1DB000A45078 /* WindowPositionUtils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WindowPositionUtils.cpp; sourceTree = ""; }; + 0F75F5A82A6B1DB000A45078 /* dynamic_bitrate_helper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dynamic_bitrate_helper.h; sourceTree = ""; }; + 0F75F5A92A6B1DB000A45078 /* packet_decoder_mp3_common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = packet_decoder_mp3_common.h; sourceTree = ""; }; + 0F75F5AA2A6B1DB000A45078 /* foobar2000+atl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "foobar2000+atl.h"; sourceTree = ""; }; + 0F75F5AB2A6B1DB000A45078 /* CallForwarder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CallForwarder.h; sourceTree = ""; }; + 0F75F5AC2A6B1DB000A45078 /* StdAfx.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StdAfx.cpp; sourceTree = ""; }; + 0F75F5AD2A6B1DB100A45078 /* CTableEditHelper-Legacy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "CTableEditHelper-Legacy.h"; sourceTree = ""; }; + 0F75F5AE2A6B1DB100A45078 /* window_placement_helper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = window_placement_helper.h; sourceTree = ""; }; + 0F75F5AF2A6B1DB100A45078 /* input_helper_cue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = input_helper_cue.h; sourceTree = ""; }; + 0F75F5B02A6B1DB100A45078 /* cuesheet_index_list.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cuesheet_index_list.cpp; sourceTree = ""; }; + 0F75F5B12A6B1DB100A45078 /* win-systemtime.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "win-systemtime.cpp"; sourceTree = ""; }; + 0F75F5B22A6B1DB100A45078 /* dynamic_bitrate_helper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = dynamic_bitrate_helper.cpp; sourceTree = ""; }; + 0F75F5B32A6B1DB100A45078 /* bitreader_helper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bitreader_helper.h; sourceTree = ""; }; + 0F75F5B42A6B1DB100A45078 /* StdAfx.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StdAfx.h; sourceTree = ""; }; + 0F75F5B52A6B1DB100A45078 /* packet_decoder_aac_common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = packet_decoder_aac_common.h; sourceTree = ""; }; + 0F75F5B62A6B1DB100A45078 /* CmdThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CmdThread.h; sourceTree = ""; }; + 0F75F5B72A6B1DB100A45078 /* readers_lite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = readers_lite.h; sourceTree = ""; }; + 0F75F5B82A6B1DB100A45078 /* text_file_loader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = text_file_loader.cpp; sourceTree = ""; }; + 0F75F5B92A6B1DB100A45078 /* cue_creator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cue_creator.h; sourceTree = ""; }; + 0F75F5BA2A6B1DB100A45078 /* ThreadUtils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadUtils.cpp; sourceTree = ""; }; + 0F75F5BB2A6B1DB100A45078 /* file_streamstub.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = file_streamstub.h; sourceTree = ""; }; + 0F75F5BC2A6B1DB100A45078 /* tag_write_callback_impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tag_write_callback_impl.h; sourceTree = ""; }; + 0F75F5BD2A6B1DB100A45078 /* win32_misc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = win32_misc.cpp; sourceTree = ""; }; + 0F75F5BE2A6B1DB100A45078 /* WindowPositionUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WindowPositionUtils.h; sourceTree = ""; }; + 0F75F5BF2A6B1DB100A45078 /* packet_decoder_mp3_common.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = packet_decoder_mp3_common.cpp; sourceTree = ""; }; + 0F75F5C02A6B1DB100A45078 /* CTableEditHelper-Legacy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "CTableEditHelper-Legacy.cpp"; sourceTree = ""; }; + 0F75F5C12A6B1DB100A45078 /* duration_counter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = duration_counter.h; sourceTree = ""; }; + 0F75F5C22A6B1DB100A45078 /* cue_parser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cue_parser.h; sourceTree = ""; }; + 0F75F5C32A6B1DB100A45078 /* dialog_resize_helper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = dialog_resize_helper.cpp; sourceTree = ""; }; + 0F75F5C42A6B1DB100A45078 /* seekabilizer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = seekabilizer.cpp; sourceTree = ""; }; + 0F75F5C52A6B1DB100A45078 /* fullFileBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fullFileBuffer.h; sourceTree = ""; }; + 0F75F5C62A6B1DB100A45078 /* win32_dialog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = win32_dialog.h; sourceTree = ""; }; + 0F75F5C72A6B1DB100A45078 /* cuesheet_index_list.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cuesheet_index_list.h; sourceTree = ""; }; + 0F75F5C82A6B1DB100A45078 /* callInMainThreadHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = callInMainThreadHelper.h; sourceTree = ""; }; + 0F75F5C92A6B1DB100A45078 /* icon_remapping_wildcard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = icon_remapping_wildcard.h; sourceTree = ""; }; + 0F75F5CA2A6B1DB100A45078 /* audio_render_float.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = audio_render_float.h; sourceTree = ""; }; + 0F75F5CB2A6B1DB100A45078 /* win32_dialog.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = win32_dialog.cpp; sourceTree = ""; }; + 0F75F5CC2A6B1DB100A45078 /* advconfig_impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = advconfig_impl.h; sourceTree = ""; }; + 0F75F5CD2A6B1DB100A45078 /* input_fix_seeking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = input_fix_seeking.h; sourceTree = ""; }; + 0F75F5CE2A6B1DB100A45078 /* win-systemtime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "win-systemtime.h"; sourceTree = ""; }; + 0F75F5CF2A6B1DB100A45078 /* stream_buffer_helper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = stream_buffer_helper.cpp; sourceTree = ""; }; + 0F75F5D02A6B1DB100A45078 /* dsp_dialog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dsp_dialog.h; sourceTree = ""; }; + 0F75F5D12A6B1DB100A45078 /* BumpableElem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BumpableElem.h; sourceTree = ""; }; + 0F75F5D22A6B1DB100A45078 /* cfg_obj.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cfg_obj.h; sourceTree = ""; }; + 0F75F5D32A6B1DB200A45078 /* packet_decoder_aac_common.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = packet_decoder_aac_common.cpp; sourceTree = ""; }; + 0F75F5D42A6B1DB200A45078 /* mp3_utils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mp3_utils.h; sourceTree = ""; }; + 0F75F5D52A6B1DB200A45078 /* cue_parser_embedding.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cue_parser_embedding.cpp; sourceTree = ""; }; + 0F75F5D62A6B1DB200A45078 /* input_helpers.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = input_helpers.cpp; sourceTree = ""; }; + 0F75F5D72A6B1DB200A45078 /* ThreadUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreadUtils.h; sourceTree = ""; }; + 0F75F5D82A6B1DB200A45078 /* track_property_callback_impl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = track_property_callback_impl.cpp; sourceTree = ""; }; + 0F75F5D92A6B1DB200A45078 /* AutoComplete.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AutoComplete.cpp; sourceTree = ""; }; + 0F75F5DA2A6B1DB200A45078 /* fb2k_wfx.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fb2k_wfx.h; sourceTree = ""; }; + 0F75F5DB2A6B1DB200A45078 /* DarkMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DarkMode.h; sourceTree = ""; }; + 0F75F5DC2A6B1DB200A45078 /* win32_misc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = win32_misc.h; sourceTree = ""; }; + 0F75F5DD2A6B1DB200A45078 /* winmm-types.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "winmm-types.h"; sourceTree = ""; }; + 0F75F5DE2A6B1DB200A45078 /* metadb_handle_set.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = metadb_handle_set.h; sourceTree = ""; }; + 0F75F5DF2A6B1DB200A45078 /* mp3_utils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = mp3_utils.cpp; sourceTree = ""; }; + 0F75F5E02A6B1DB200A45078 /* file_win32_wrapper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = file_win32_wrapper.cpp; sourceTree = ""; }; + 0F75F5E12A6B1DB200A45078 /* seekabilizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = seekabilizer.h; sourceTree = ""; }; + 0F75F5E22A6B1DB200A45078 /* file_move_helper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = file_move_helper.cpp; sourceTree = ""; }; + 0F75F5E32A6B1DB200A45078 /* cfg_guidlist.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cfg_guidlist.h; sourceTree = ""; }; + 0F75F5E42A6B1DB200A45078 /* input_helper_cue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = input_helper_cue.cpp; sourceTree = ""; }; + 0F75F5E52A6B1DB200A45078 /* text_file_loader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = text_file_loader.h; sourceTree = ""; }; + 0F75F5E62A6B1DB200A45078 /* file_cached.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = file_cached.h; sourceTree = ""; }; + 0F75F5E72A6B1DB200A45078 /* input_stream_info_reader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = input_stream_info_reader.h; sourceTree = ""; }; + 0F75F5E82A6B1DB200A45078 /* DarkMode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DarkMode.cpp; sourceTree = ""; }; + 0F75F5E92A6B1DB200A45078 /* dropdown_helper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dropdown_helper.h; sourceTree = ""; }; + B12D1DB11991061A0087CEF3 /* libfoobar2000_SDK_helpers.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libfoobar2000_SDK_helpers.a; sourceTree = BUILT_PRODUCTS_DIR; }; + B166964A19ACC1560001728F /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + B166965819ACC1560001728F /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; + B166965B19ACC1560001728F /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + B12D1DAE1991061A0087CEF3 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + B12D1DA81991061A0087CEF3 = { + isa = PBXGroup; + children = ( + B12D1DBE1991063D0087CEF3 /* Source */, + B166964919ACC1560001728F /* Frameworks */, + B12D1DB21991061A0087CEF3 /* Products */, + ); + sourceTree = ""; + }; + B12D1DB21991061A0087CEF3 /* Products */ = { + isa = PBXGroup; + children = ( + B12D1DB11991061A0087CEF3 /* libfoobar2000_SDK_helpers.a */, + ); + name = Products; + sourceTree = ""; + }; + B12D1DBE1991063D0087CEF3 /* Source */ = { + isa = PBXGroup; + children = ( + 0F75F5CC2A6B1DB100A45078 /* advconfig_impl.h */, + 0F75F5872A6B1DAF00A45078 /* advconfig_runtime.h */, + 0F75F57C2A6B1DAF00A45078 /* album_art_helpers.cpp */, + 0F75F5922A6B1DB000A45078 /* album_art_helpers.h */, + 0F75F58F2A6B1DAF00A45078 /* albumArtCache.h */, + 0F75F5722A6B1DAE00A45078 /* atl-misc.h */, + 0F75F5CA2A6B1DB100A45078 /* audio_render_float.h */, + 0F75F5D92A6B1DB200A45078 /* AutoComplete.cpp */, + 0F75F57D2A6B1DAF00A45078 /* AutoComplete.h */, + 0F75F5B32A6B1DB100A45078 /* bitreader_helper.h */, + 0F75F5D12A6B1DB100A45078 /* BumpableElem.h */, + 0F75F5A22A6B1DB000A45078 /* callback_merit.h */, + 0F75F5AB2A6B1DB000A45078 /* CallForwarder.h */, + 0F75F5C82A6B1DB100A45078 /* callInMainThreadHelper.h */, + 0F75F58C2A6B1DAF00A45078 /* CDialogResizeHelper.h */, + 0F75F5802A6B1DAF00A45078 /* cfg_dsp_chain_config.h */, + 0F75F5A02A6B1DB000A45078 /* cfg_guidlist.cpp */, + 0F75F5E32A6B1DB200A45078 /* cfg_guidlist.h */, + 0F75F5D22A6B1DB100A45078 /* cfg_obj.h */, + 0F75F58B2A6B1DAF00A45078 /* cfg_objList.h */, + 0F75F5642A6B1DAE00A45078 /* cfg_var_import.cpp */, + 0F75F5912A6B1DAF00A45078 /* cfg_var_import.h */, + 0F75F5852A6B1DAF00A45078 /* CListControlFb2kColors.h */, + 0F75F5B62A6B1DB100A45078 /* CmdThread.h */, + 0F75F56D2A6B1DAE00A45078 /* COM_utils.h */, + 0F75F5A42A6B1DB000A45078 /* CPropVariant.h */, + 0F75F56A2A6B1DAE00A45078 /* create_directory_helper.cpp */, + 0F75F5932A6B1DB000A45078 /* create_directory_helper.h */, + 0F75F5732A6B1DAE00A45078 /* CSingleThreadWrapper.h */, + 0F75F5C02A6B1DB100A45078 /* CTableEditHelper-Legacy.cpp */, + 0F75F5AD2A6B1DB100A45078 /* CTableEditHelper-Legacy.h */, + 0F75F5A32A6B1DB000A45078 /* cue_creator.cpp */, + 0F75F5B92A6B1DB100A45078 /* cue_creator.h */, + 0F75F5D52A6B1DB200A45078 /* cue_parser_embedding.cpp */, + 0F75F5822A6B1DAF00A45078 /* cue_parser.cpp */, + 0F75F5C22A6B1DB100A45078 /* cue_parser.h */, + 0F75F5B02A6B1DB100A45078 /* cuesheet_index_list.cpp */, + 0F75F5C72A6B1DB100A45078 /* cuesheet_index_list.h */, + 0F75F5E82A6B1DB200A45078 /* DarkMode.cpp */, + 0F75F5DB2A6B1DB200A45078 /* DarkMode.h */, + 0F75F5C32A6B1DB100A45078 /* dialog_resize_helper.cpp */, + 0F75F5622A6B1DAE00A45078 /* dialog_resize_helper.h */, + 0F75F5A12A6B1DB000A45078 /* dropdown_helper.cpp */, + 0F75F5E92A6B1DB200A45078 /* dropdown_helper.h */, + 0F75F5D02A6B1DB100A45078 /* dsp_dialog.h */, + 0F75F5C12A6B1DB100A45078 /* duration_counter.h */, + 0F75F5B22A6B1DB100A45078 /* dynamic_bitrate_helper.cpp */, + 0F75F5A82A6B1DB000A45078 /* dynamic_bitrate_helper.h */, + 0F75F5782A6B1DAF00A45078 /* fb2k_threads.h */, + 0F75F5DA2A6B1DB200A45078 /* fb2k_wfx.h */, + 0F75F58A2A6B1DAF00A45078 /* fb2kWorkerTool.h */, + 0F75F5E62A6B1DB200A45078 /* file_cached.h */, + 0F75F58D2A6B1DAF00A45078 /* file_info_const_impl.h */, + 0F75F58E2A6B1DAF00A45078 /* file_list_helper.cpp */, + 0F75F57A2A6B1DAF00A45078 /* file_list_helper.h */, + 0F75F5E22A6B1DB200A45078 /* file_move_helper.cpp */, + 0F75F5682A6B1DAE00A45078 /* file_move_helper.h */, + 0F75F5BB2A6B1DB100A45078 /* file_streamstub.h */, + 0F75F5E02A6B1DB200A45078 /* file_win32_wrapper.cpp */, + 0F75F56F2A6B1DAE00A45078 /* file_win32_wrapper.h */, + 0F75F57F2A6B1DAF00A45078 /* fileReadAhead.h */, + 0F75F59C2A6B1DB000A45078 /* filetimetools.cpp */, + 0F75F5692A6B1DAE00A45078 /* filetimetools.h */, + 0F75F5702A6B1DAE00A45078 /* foobar2000-lite+atl.h */, + 0F75F5AA2A6B1DB000A45078 /* foobar2000+atl.h */, + 0F75F5C52A6B1DB100A45078 /* fullFileBuffer.h */, + 0F75F5A62A6B1DB000A45078 /* helpers.h */, + 0F75F5C92A6B1DB100A45078 /* icon_remapping_wildcard.h */, + 0F75F5972A6B1DB000A45078 /* image_load_save.cpp */, + 0F75F5742A6B1DAE00A45078 /* image_load_save.h */, + 0F75F5962A6B1DB000A45078 /* inplace_edit.cpp */, + 0F75F57B2A6B1DAF00A45078 /* inplace_edit.h */, + 0F75F5CD2A6B1DB100A45078 /* input_fix_seeking.h */, + 0F75F5E42A6B1DB200A45078 /* input_helper_cue.cpp */, + 0F75F5AF2A6B1DB100A45078 /* input_helper_cue.h */, + 0F75F5D62A6B1DB200A45078 /* input_helpers.cpp */, + 0F75F5942A6B1DB000A45078 /* input_helpers.h */, + 0F75F5632A6B1DAE00A45078 /* input_logging.h */, + 0F75F5E72A6B1DB200A45078 /* input_stream_info_reader.h */, + 0F75F5772A6B1DAF00A45078 /* meta_table_builder.h */, + 0F75F5712A6B1DAE00A45078 /* metadb_handle_array.h */, + 0F75F5DE2A6B1DB200A45078 /* metadb_handle_set.h */, + 0F75F5992A6B1DB000A45078 /* metadb_info_container_impl.h */, + 0F75F5812A6B1DAF00A45078 /* metadb_io_callback_v2_data.h */, + 0F75F59A2A6B1DB000A45078 /* metadb_io_hintlist.h */, + 0F75F5DF2A6B1DB200A45078 /* mp3_utils.cpp */, + 0F75F5D42A6B1DB200A45078 /* mp3_utils.h */, + 0F75F5952A6B1DB000A45078 /* notifyList.h */, + 0F75F5D32A6B1DB200A45078 /* packet_decoder_aac_common.cpp */, + 0F75F5B52A6B1DB100A45078 /* packet_decoder_aac_common.h */, + 0F75F5BF2A6B1DB100A45078 /* packet_decoder_mp3_common.cpp */, + 0F75F5A92A6B1DB000A45078 /* packet_decoder_mp3_common.h */, + 0F75F5792A6B1DAF00A45078 /* playlist_position_reference_tracker.h */, + 0F75F59D2A6B1DB000A45078 /* ProcessUtils.h */, + 0F75F57E2A6B1DAF00A45078 /* ProfileCache.h */, + 0F75F5752A6B1DAF00A45078 /* reader_pretend_nonseekable.h */, + 0F75F5B72A6B1DB100A45078 /* readers_lite.h */, + 0F75F5652A6B1DAE00A45078 /* readers.cpp */, + 0F75F59E2A6B1DB000A45078 /* readers.h */, + 0F75F5882A6B1DAF00A45078 /* readWriteLock.h */, + 0F75F5902A6B1DAF00A45078 /* rethrow.h */, + 0F75F5C42A6B1DB100A45078 /* seekabilizer.cpp */, + 0F75F5E12A6B1DB200A45078 /* seekabilizer.h */, + 0F75F5AC2A6B1DB000A45078 /* StdAfx.cpp */, + 0F75F5B42A6B1DB100A45078 /* StdAfx.h */, + 0F75F5CF2A6B1DB100A45078 /* stream_buffer_helper.cpp */, + 0F75F5862A6B1DAF00A45078 /* stream_buffer_helper.h */, + 0F75F5BC2A6B1DB100A45078 /* tag_write_callback_impl.h */, + 0F75F5662A6B1DAE00A45078 /* text_file_loader_v2.cpp */, + 0F75F5A52A6B1DB000A45078 /* text_file_loader_v2.h */, + 0F75F5B82A6B1DB100A45078 /* text_file_loader.cpp */, + 0F75F5E52A6B1DB200A45078 /* text_file_loader.h */, + 0F75F5BA2A6B1DB100A45078 /* ThreadUtils.cpp */, + 0F75F5D72A6B1DB200A45078 /* ThreadUtils.h */, + 0F75F5D82A6B1DB200A45078 /* track_property_callback_impl.cpp */, + 0F75F59B2A6B1DB000A45078 /* track_property_callback_impl.h */, + 0F75F5832A6B1DAF00A45078 /* ui_element_helpers.cpp */, + 0F75F5842A6B1DAF00A45078 /* ui_element_helpers.h */, + 0F75F56C2A6B1DAE00A45078 /* VisUtils.cpp */, + 0F75F5672A6B1DAE00A45078 /* VisUtils.h */, + 0F75F59F2A6B1DB000A45078 /* VolumeMap.cpp */, + 0F75F56E2A6B1DAE00A45078 /* VolumeMap.h */, + 0F75F5982A6B1DB000A45078 /* win-MulDiv.h */, + 0F75F5B12A6B1DB100A45078 /* win-systemtime.cpp */, + 0F75F5CE2A6B1DB100A45078 /* win-systemtime.h */, + 0F75F5CB2A6B1DB100A45078 /* win32_dialog.cpp */, + 0F75F5C62A6B1DB100A45078 /* win32_dialog.h */, + 0F75F5BD2A6B1DB100A45078 /* win32_misc.cpp */, + 0F75F5DC2A6B1DB200A45078 /* win32_misc.h */, + 0F75F5762A6B1DAF00A45078 /* window_placement_helper.cpp */, + 0F75F5AE2A6B1DB100A45078 /* window_placement_helper.h */, + 0F75F5A72A6B1DB000A45078 /* WindowPositionUtils.cpp */, + 0F75F5BE2A6B1DB100A45078 /* WindowPositionUtils.h */, + 0F75F5DD2A6B1DB200A45078 /* winmm-types.h */, + 0F75F5892A6B1DAF00A45078 /* writer_wav.cpp */, + 0F75F56B2A6B1DAE00A45078 /* writer_wav.h */, + ); + name = Source; + sourceTree = ""; + }; + B166964919ACC1560001728F /* Frameworks */ = { + isa = PBXGroup; + children = ( + B166964A19ACC1560001728F /* Foundation.framework */, + B166965819ACC1560001728F /* XCTest.framework */, + B166965B19ACC1560001728F /* UIKit.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + B12D1DAF1991061A0087CEF3 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 0F75F6092A6B1DB200A45078 /* metadb_io_callback_v2_data.h in Headers */, + 0F75F62E2A6B1DB200A45078 /* helpers.h in Headers */, + 0F75F5F52A6B1DB200A45078 /* COM_utils.h in Headers */, + 0F75F6122A6B1DB200A45078 /* fb2kWorkerTool.h in Headers */, + 0F75F6082A6B1DB200A45078 /* cfg_dsp_chain_config.h in Headers */, + 0F75F6362A6B1DB200A45078 /* window_placement_helper.h in Headers */, + 0F75F61B2A6B1DB200A45078 /* create_directory_helper.h in Headers */, + 0F75F5FC2A6B1DB200A45078 /* image_load_save.h in Headers */, + 0F75F5F82A6B1DB200A45078 /* foobar2000-lite+atl.h in Headers */, + 0F75F61C2A6B1DB200A45078 /* input_helpers.h in Headers */, + 0F75F62D2A6B1DB200A45078 /* text_file_loader_v2.h in Headers */, + 0F75F6352A6B1DB200A45078 /* CTableEditHelper-Legacy.h in Headers */, + 0F75F6442A6B1DB200A45078 /* tag_write_callback_impl.h in Headers */, + 0F75F61A2A6B1DB200A45078 /* album_art_helpers.h in Headers */, + 0F75F6322A6B1DB200A45078 /* foobar2000+atl.h in Headers */, + 0F75F65F2A6B1DB200A45078 /* ThreadUtils.h in Headers */, + 0F75F6592A6B1DB200A45078 /* BumpableElem.h in Headers */, + 0F75F64D2A6B1DB200A45078 /* fullFileBuffer.h in Headers */, + 0F75F60C2A6B1DB200A45078 /* ui_element_helpers.h in Headers */, + 0F75F6252A6B1DB200A45078 /* ProcessUtils.h in Headers */, + 0F75F66D2A6B1DB200A45078 /* text_file_loader.h in Headers */, + 0F75F6072A6B1DB200A45078 /* fileReadAhead.h in Headers */, + 0F75F60D2A6B1DB200A45078 /* CListControlFb2kColors.h in Headers */, + 0F75F6132A6B1DB200A45078 /* cfg_objList.h in Headers */, + 0F75F6692A6B1DB200A45078 /* seekabilizer.h in Headers */, + 0F75F6562A6B1DB200A45078 /* win-systemtime.h in Headers */, + 0F75F6312A6B1DB200A45078 /* packet_decoder_mp3_common.h in Headers */, + 0F75F64A2A6B1DB200A45078 /* cue_parser.h in Headers */, + 0F75F6502A6B1DB200A45078 /* callInMainThreadHelper.h in Headers */, + 0F75F6652A6B1DB200A45078 /* winmm-types.h in Headers */, + 0F75F6662A6B1DB200A45078 /* metadb_handle_set.h in Headers */, + 0F75F6522A6B1DB200A45078 /* audio_render_float.h in Headers */, + 0F75F65A2A6B1DB200A45078 /* cfg_obj.h in Headers */, + 0F75F6182A6B1DB200A45078 /* rethrow.h in Headers */, + 0F75F5EA2A6B1DB200A45078 /* dialog_resize_helper.h in Headers */, + 0F75F6232A6B1DB200A45078 /* track_property_callback_impl.h in Headers */, + 0F75F6372A6B1DB200A45078 /* input_helper_cue.h in Headers */, + 0F75F6552A6B1DB200A45078 /* input_fix_seeking.h in Headers */, + 0F75F64F2A6B1DB200A45078 /* cuesheet_index_list.h in Headers */, + 0F75F5F02A6B1DB200A45078 /* file_move_helper.h in Headers */, + 0F75F6222A6B1DB200A45078 /* metadb_io_hintlist.h in Headers */, + 0F75F5F32A6B1DB200A45078 /* writer_wav.h in Headers */, + 0F75F6582A6B1DB200A45078 /* dsp_dialog.h in Headers */, + 0F75F6102A6B1DB200A45078 /* readWriteLock.h in Headers */, + 0F75F63C2A6B1DB200A45078 /* StdAfx.h in Headers */, + 0F75F6002A6B1DB200A45078 /* fb2k_threads.h in Headers */, + 0F75F65C2A6B1DB200A45078 /* mp3_utils.h in Headers */, + 0F75F66B2A6B1DB200A45078 /* cfg_guidlist.h in Headers */, + 0F75F6142A6B1DB200A45078 /* CDialogResizeHelper.h in Headers */, + 0F75F63E2A6B1DB200A45078 /* CmdThread.h in Headers */, + 0F75F5FB2A6B1DB200A45078 /* CSingleThreadWrapper.h in Headers */, + 0F75F6632A6B1DB200A45078 /* DarkMode.h in Headers */, + 0F75F5EF2A6B1DB200A45078 /* VisUtils.h in Headers */, + 0F75F6542A6B1DB200A45078 /* advconfig_impl.h in Headers */, + 0F75F6262A6B1DB200A45078 /* readers.h in Headers */, + 0F75F6032A6B1DB200A45078 /* inplace_edit.h in Headers */, + 0F75F5EB2A6B1DB200A45078 /* input_logging.h in Headers */, + 0F75F6202A6B1DB200A45078 /* win-MulDiv.h in Headers */, + 0F75F6062A6B1DB200A45078 /* ProfileCache.h in Headers */, + 0F75F6302A6B1DB200A45078 /* dynamic_bitrate_helper.h in Headers */, + 0F75F61D2A6B1DB200A45078 /* notifyList.h in Headers */, + 0F75F5FD2A6B1DB200A45078 /* reader_pretend_nonseekable.h in Headers */, + 0F75F6512A6B1DB200A45078 /* icon_remapping_wildcard.h in Headers */, + 0F75F5F12A6B1DB200A45078 /* filetimetools.h in Headers */, + 0F75F63B2A6B1DB200A45078 /* bitreader_helper.h in Headers */, + 0F75F6012A6B1DB200A45078 /* playlist_position_reference_tracker.h in Headers */, + 0F75F62C2A6B1DB200A45078 /* CPropVariant.h in Headers */, + 0F75F6622A6B1DB200A45078 /* fb2k_wfx.h in Headers */, + 0F75F60E2A6B1DB200A45078 /* stream_buffer_helper.h in Headers */, + 0F75F6462A6B1DB200A45078 /* WindowPositionUtils.h in Headers */, + 0F75F6412A6B1DB200A45078 /* cue_creator.h in Headers */, + 0F75F62A2A6B1DB200A45078 /* callback_merit.h in Headers */, + 0F75F6212A6B1DB200A45078 /* metadb_info_container_impl.h in Headers */, + 0F75F6172A6B1DB200A45078 /* albumArtCache.h in Headers */, + 0F75F66E2A6B1DB200A45078 /* file_cached.h in Headers */, + 0F75F6712A6B1DB200A45078 /* dropdown_helper.h in Headers */, + 0F75F5F92A6B1DB200A45078 /* metadb_handle_array.h in Headers */, + 0F75F63D2A6B1DB200A45078 /* packet_decoder_aac_common.h in Headers */, + 0F75F66F2A6B1DB200A45078 /* input_stream_info_reader.h in Headers */, + 0F75F6332A6B1DB200A45078 /* CallForwarder.h in Headers */, + 0F75F6642A6B1DB200A45078 /* win32_misc.h in Headers */, + 0F75F6192A6B1DB200A45078 /* cfg_var_import.h in Headers */, + 0F75F6052A6B1DB200A45078 /* AutoComplete.h in Headers */, + 0F75F64E2A6B1DB200A45078 /* win32_dialog.h in Headers */, + 0F75F5F62A6B1DB200A45078 /* VolumeMap.h in Headers */, + 0F75F5FA2A6B1DB200A45078 /* atl-misc.h in Headers */, + 0F75F60F2A6B1DB200A45078 /* advconfig_runtime.h in Headers */, + 0F75F6152A6B1DB200A45078 /* file_info_const_impl.h in Headers */, + 0F75F63F2A6B1DB200A45078 /* readers_lite.h in Headers */, + 0F75F6022A6B1DB200A45078 /* file_list_helper.h in Headers */, + 0F75F6432A6B1DB200A45078 /* file_streamstub.h in Headers */, + 0F75F6492A6B1DB200A45078 /* duration_counter.h in Headers */, + 0F75F5FF2A6B1DB200A45078 /* meta_table_builder.h in Headers */, + 0F75F5F72A6B1DB200A45078 /* file_win32_wrapper.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + B12D1DB01991061A0087CEF3 /* foobar2000_SDK_helpers */ = { + isa = PBXNativeTarget; + buildConfigurationList = B12D1DB51991061A0087CEF3 /* Build configuration list for PBXNativeTarget "foobar2000_SDK_helpers" */; + buildPhases = ( + B12D1DAD1991061A0087CEF3 /* Sources */, + B12D1DAE1991061A0087CEF3 /* Frameworks */, + B12D1DAF1991061A0087CEF3 /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = foobar2000_SDK_helpers; + productName = foobar2000_SDK_helpers; + productReference = B12D1DB11991061A0087CEF3 /* libfoobar2000_SDK_helpers.a */; + productType = "com.apple.product-type.library.static"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + B12D1DA91991061A0087CEF3 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 1250; + ORGANIZATIONNAME = "___FULLUSERNAME___"; + }; + buildConfigurationList = B12D1DAC1991061A0087CEF3 /* Build configuration list for PBXProject "foobar2000_SDK_helpers" */; + compatibilityVersion = "Xcode 12.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = B12D1DA81991061A0087CEF3; + productRefGroup = B12D1DB21991061A0087CEF3 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + B12D1DB01991061A0087CEF3 /* foobar2000_SDK_helpers */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + B12D1DAD1991061A0087CEF3 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 0F75F6672A6B1DB200A45078 /* mp3_utils.cpp in Sources */, + 0F75F63A2A6B1DB200A45078 /* dynamic_bitrate_helper.cpp in Sources */, + 0F75F62B2A6B1DB200A45078 /* cue_creator.cpp in Sources */, + 0F75F6292A6B1DB200A45078 /* dropdown_helper.cpp in Sources */, + 0F75F60A2A6B1DB200A45078 /* cue_parser.cpp in Sources */, + 0F75F6472A6B1DB200A45078 /* packet_decoder_mp3_common.cpp in Sources */, + 0F75F6422A6B1DB200A45078 /* ThreadUtils.cpp in Sources */, + 0F75F64B2A6B1DB200A45078 /* dialog_resize_helper.cpp in Sources */, + 0F75F6272A6B1DB200A45078 /* VolumeMap.cpp in Sources */, + 0F75F65E2A6B1DB200A45078 /* input_helpers.cpp in Sources */, + 0F75F6392A6B1DB200A45078 /* win-systemtime.cpp in Sources */, + 0F75F6112A6B1DB200A45078 /* writer_wav.cpp in Sources */, + 0F75F6682A6B1DB200A45078 /* file_win32_wrapper.cpp in Sources */, + 0F75F5ED2A6B1DB200A45078 /* readers.cpp in Sources */, + 0F75F5EC2A6B1DB200A45078 /* cfg_var_import.cpp in Sources */, + 0F75F6572A6B1DB200A45078 /* stream_buffer_helper.cpp in Sources */, + 0F75F6282A6B1DB200A45078 /* cfg_guidlist.cpp in Sources */, + 0F75F5F42A6B1DB200A45078 /* VisUtils.cpp in Sources */, + 0F75F5EE2A6B1DB200A45078 /* text_file_loader_v2.cpp in Sources */, + 0F75F6042A6B1DB200A45078 /* album_art_helpers.cpp in Sources */, + 0F75F6602A6B1DB200A45078 /* track_property_callback_impl.cpp in Sources */, + 0F75F64C2A6B1DB200A45078 /* seekabilizer.cpp in Sources */, + 0F75F65D2A6B1DB200A45078 /* cue_parser_embedding.cpp in Sources */, + 0F75F66C2A6B1DB200A45078 /* input_helper_cue.cpp in Sources */, + 0F75F6402A6B1DB200A45078 /* text_file_loader.cpp in Sources */, + 0F75F6242A6B1DB200A45078 /* filetimetools.cpp in Sources */, + 0F75F6382A6B1DB200A45078 /* cuesheet_index_list.cpp in Sources */, + 0F75F5F22A6B1DB200A45078 /* create_directory_helper.cpp in Sources */, + 0F75F66A2A6B1DB200A45078 /* file_move_helper.cpp in Sources */, + 0F75F6342A6B1DB200A45078 /* StdAfx.cpp in Sources */, + 0F75F6162A6B1DB200A45078 /* file_list_helper.cpp in Sources */, + 0F75F65B2A6B1DB200A45078 /* packet_decoder_aac_common.cpp in Sources */, + 0F75F6452A6B1DB200A45078 /* win32_misc.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + B12D1DB31991061A0087CEF3 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = StdAfx.h; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + ../.., + .., + ); + IPHONEOS_DEPLOYMENT_TARGET = 12.1; + MACOSX_DEPLOYMENT_TARGET = 11.0; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SKIP_INSTALL = YES; + }; + name = Debug; + }; + B12D1DB41991061A0087CEF3 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_NO_COMMON_BLOCKS = YES; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = StdAfx.h; + GCC_PREPROCESSOR_DEFINITIONS = "NDEBUG=1"; + GCC_SYMBOLS_PRIVATE_EXTERN = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + ../.., + .., + ); + IPHONEOS_DEPLOYMENT_TARGET = 12.1; + MACOSX_DEPLOYMENT_TARGET = 11.0; + SDKROOT = macosx; + SKIP_INSTALL = YES; + }; + name = Release; + }; + B12D1DB61991061A0087CEF3 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + COMBINE_HIDPI_IMAGES = YES; + EXECUTABLE_PREFIX = lib; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + B12D1DB71991061A0087CEF3 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + COMBINE_HIDPI_IMAGES = YES; + EXECUTABLE_PREFIX = lib; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + B12D1DAC1991061A0087CEF3 /* Build configuration list for PBXProject "foobar2000_SDK_helpers" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + B12D1DB31991061A0087CEF3 /* Debug */, + B12D1DB41991061A0087CEF3 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + B12D1DB51991061A0087CEF3 /* Build configuration list for PBXNativeTarget "foobar2000_SDK_helpers" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + B12D1DB61991061A0087CEF3 /* Debug */, + B12D1DB71991061A0087CEF3 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = B12D1DA91991061A0087CEF3 /* Project object */; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/foobar2000_sdk_helpers.vcxproj --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/foobar2000_sdk_helpers.vcxproj Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,600 @@ + + + + + Debug + ARM64 + + + Debug + ARM64EC + + + Debug + Win32 + + + Debug + x64 + + + Release + ARM64 + + + Release + ARM64EC + + + Release + Win32 + + + Release + x64 + + + + {EE47764E-A202-4F85-A767-ABDAB4AFF35F} + foobar2000_sdk_helpers + 10.0 + + + + StaticLibrary + false + Unicode + v142 + + + StaticLibrary + false + Unicode + v142 + + + StaticLibrary + false + Unicode + v143 + + + StaticLibrary + false + Unicode + v143 + + + StaticLibrary + false + Unicode + true + v142 + + + StaticLibrary + false + Unicode + true + v142 + + + StaticLibrary + false + Unicode + true + v143 + + + StaticLibrary + false + Unicode + true + v143 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + + + + MinSpace + true + false + Fast + false + Use + stdafx.h + Level3 + true + ProgramDatabase + MultiThreadedDLL + ../..;.. + /d2notypeopt %(AdditionalOptions) + 4715 + true + true + NDEBUG;_UNICODE;UNICODE;%(PreprocessorDefinitions) + true + stdcpp17 + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + + + + + MinSpace + true + false + Fast + false + Use + stdafx.h + Level3 + true + ProgramDatabase + MultiThreadedDLL + ../..;.. + /d2notypeopt %(AdditionalOptions) + 4715 + true + true + NDEBUG;_UNICODE;UNICODE;%(PreprocessorDefinitions) + true + stdcpp17 + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + + + + + MinSpace + true + false + Fast + false + Use + stdafx.h + Level3 + true + ProgramDatabase + MultiThreadedDLL + ../..;.. + /d2notypeopt %(AdditionalOptions) + 4715 + true + true + NDEBUG;_UNICODE;UNICODE;%(PreprocessorDefinitions) + true + stdcpp17 + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + + + + + MinSpace + true + false + Fast + false + Use + stdafx.h + Level3 + true + ProgramDatabase + MultiThreadedDLL + ../..;.. + /d2notypeopt %(AdditionalOptions) + 4715 + true + true + NDEBUG;_UNICODE;UNICODE;%(PreprocessorDefinitions) + true + stdcpp17 + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + + + + + Disabled + EnableFastChecks + Use + stdafx.h + Level3 + true + ProgramDatabase + MultiThreadedDebugDLL + ../..;.. + 4715 + true + true + stdcpp17 + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + + + + + Disabled + EnableFastChecks + Use + stdafx.h + Level3 + true + ProgramDatabase + MultiThreadedDebugDLL + ../..;.. + 4715 + true + true + stdcpp17 + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + + + + + Disabled + EnableFastChecks + Use + stdafx.h + Level3 + true + ProgramDatabase + MultiThreadedDebugDLL + ../..;.. + 4715 + true + true + stdcpp17 + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + + + + + Disabled + EnableFastChecks + Use + stdafx.h + Level3 + true + ProgramDatabase + MultiThreadedDebugDLL + ../..;.. + 4715 + true + true + stdcpp17 + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + + + + + + + + true + true + true + true + true + true + true + true + + + Disabled + Disabled + Disabled + Disabled + EnableFastChecks + EnableFastChecks + EnableFastChecks + EnableFastChecks + + + + + Disabled + Disabled + Disabled + Disabled + EnableFastChecks + EnableFastChecks + EnableFastChecks + EnableFastChecks + + + + + + Disabled + Disabled + Disabled + Disabled + EnableFastChecks + EnableFastChecks + EnableFastChecks + EnableFastChecks + + + Disabled + Disabled + Disabled + Disabled + EnableFastChecks + EnableFastChecks + EnableFastChecks + EnableFastChecks + + + Disabled + Disabled + Disabled + Disabled + EnableFastChecks + EnableFastChecks + EnableFastChecks + EnableFastChecks + + + Disabled + Disabled + Disabled + Disabled + EnableFastChecks + EnableFastChecks + EnableFastChecks + EnableFastChecks + + + + + + + + + + + + + + + Disabled + Disabled + Disabled + Disabled + EnableFastChecks + EnableFastChecks + EnableFastChecks + EnableFastChecks + Create + Create + Create + Create + Create + Create + Create + Create + + + Disabled + Disabled + Disabled + Disabled + EnableFastChecks + EnableFastChecks + EnableFastChecks + EnableFastChecks + + + Disabled + Disabled + Disabled + Disabled + EnableFastChecks + EnableFastChecks + EnableFastChecks + EnableFastChecks + + + + + + + + + + Disabled + Disabled + Disabled + Disabled + EnableFastChecks + EnableFastChecks + EnableFastChecks + EnableFastChecks + + + + + Disabled + Disabled + Disabled + Disabled + EnableFastChecks + EnableFastChecks + EnableFastChecks + EnableFastChecks + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/foobar2000_sdk_helpers.vcxproj.filters --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/foobar2000_sdk_helpers.vcxproj.filters Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,425 @@ + + + + + {f9bf58c4-374f-49a5-94db-1f5ae50beca1} + cpp;c;cxx;rc;def;r;odl;idl;hpj;bat + + + {07b1c50a-a3ad-4711-9ae0-d1411b80fd7a} + h;hpp;hxx;hm;inl + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/fullFileBuffer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/fullFileBuffer.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,18 @@ +#pragma once + +class fullFileBuffer { +public: + fullFileBuffer() { + //hMutex = CreateMutex(NULL, FALSE, pfc::stringcvt::string_os_from_utf8(pfc::string_formatter() << "{3ABC4D98-2510-431C-A720-26BEB45F0278}-" << (uint32_t) GetCurrentProcessId())); + } + ~fullFileBuffer() { + //CloseHandle(hMutex); + } + file::ptr open(const char * path, abort_callback & abort, file::ptr hint, t_filesize sizeMax = 1024 * 1024 * 256); + +private: + fullFileBuffer(const fullFileBuffer&); + void operator=(const fullFileBuffer&); + + //HANDLE hMutex; +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/helpers.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/helpers.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,41 @@ +#pragma once +// #pragma message("Avoid using this header. #include individual ones instead.") + +#include "duration_counter.h" +#include "input_helpers.h" +#include "create_directory_helper.h" +#include "dialog_resize_helper.h" +#include "dropdown_helper.h" +#include "window_placement_helper.h" +#include "win32_dialog.h" +#include "cuesheet_index_list.h" +#include "cue_creator.h" +#include "cue_parser.h" +#include "text_file_loader.h" +#include "file_list_helper.h" +#include "stream_buffer_helper.h" +#include "file_info_const_impl.h" +#include "dynamic_bitrate_helper.h" +#include "cfg_guidlist.h" +#include "file_move_helper.h" +#include "file_cached.h" +#include "seekabilizer.h" +#include "bitreader_helper.h" +#include "mp3_utils.h" +#include "win32_misc.h" +#include "fb2k_threads.h" +#include "COM_utils.h" +#include "metadb_io_hintlist.h" +#include "meta_table_builder.h" +#include "icon_remapping_wildcard.h" +#include "CallForwarder.h" +#include "playlist_position_reference_tracker.h" +#include "ThreadUtils.h" +#include "ProcessUtils.h" +#include "VisUtils.h" +#include "filetimetools.h" +#include "ProfileCache.h" +#include "file_win32_wrapper.h" +#include "fullFileBuffer.h" +#include "writer_wav.h" +#include "readers.h" \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/icon_remapping_wildcard.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/icon_remapping_wildcard.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,15 @@ +#pragma once + +class icon_remapping_wildcard_impl : public icon_remapping { +public: + icon_remapping_wildcard_impl(const char * p_pattern,const char * p_iconname) : m_pattern(p_pattern), m_iconname(p_iconname) {} + bool query(const char * p_extension,pfc::string_base & p_iconname) { + if (wildcard_helper::test(p_extension,m_pattern,true)) { + p_iconname = m_iconname; return true; + } else { + return false; + } + } +private: + pfc::string8 m_pattern,m_iconname; +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/image_load_save.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/image_load_save.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,91 @@ +#include "StdAfx.h" +#include "image_load_save.h" +#include +#include +#include +#include + +namespace fb2k { + bool imageSaveDialog(album_art_data_ptr content, HWND wndParent, const char* initDir, bool bAsync) { + pfc::string8 fileTypes = "All files|*.*"; + pfc::string8 ext; + + try { + auto info = fb2k::imageLoaderLite::get()->getInfo(content); + if (info.formatName) { + pfc::string8 nameCapitalized = pfc::stringToUpper( info.formatName ); + ext = pfc::stringToLower( info.formatName ); + if (nameCapitalized == "WEBP") nameCapitalized = "WebP"; + pfc::string8 extmask; + if (ext == "jpeg-xl") ext = "jxl"; + if (ext == "jpeg") { + ext = "jpg"; + extmask = "*.jpg;*.jpeg"; + } else { + extmask << "*." << ext; + } + fileTypes.reset(); + fileTypes << nameCapitalized << " files|" << extmask; + } + } catch (...) {} + pfc::string8 fn; + + if (!uGetOpenFileName(wndParent, fileTypes, 0, ext.length() > 0 ? ext.c_str() : nullptr, "Export picture file", initDir, fn, TRUE)) return false; + + auto bErrord = std::make_shared(false); + auto work = [content, fn, bErrord] { + try { + auto f = fileOpenWriteNew(fn, fb2k::noAbort, 0.5); + f->write(content->get_ptr(), content->get_size(), fb2k::noAbort); + } catch(std::exception const & e) { + * bErrord = true; + pfc::string8 msg; + msg << "Image file could not be written: " << e; + fb2k::inMainThread([msg] { + popup_message::g_show(msg, "Information"); + }); + } + }; + if (bAsync) { + fb2k::splitTask(work); + return true; + } else { + work(); + return ! *bErrord; + } + } + + bool imageLoadDialog(pfc::string_base& outFN, HWND wndParent, const char* initDir) { + return !!uGetOpenFileName(wndParent, FB2K_GETOPENFILENAME_PICTUREFILES_ALL, 0, nullptr, "Import picture file", initDir, outFN, FALSE); + } + album_art_data::ptr imageLoadDialog(HWND wndParent, const char* initDir) { + album_art_data::ptr ret; + pfc::string8 fn; + if (imageLoadDialog(fn, wndParent, initDir)) { + try { + ret = readPictureFile(fn, fb2k::noAbort); + } catch (std::exception const& e) { + popup_message::g_show(PFC_string_formatter() << "Image file could not be read: " << e, "Information"); + } + } + return ret; + } + + album_art_data_ptr readPictureFile(const char* p_path, abort_callback& p_abort) { + PFC_ASSERT(p_path != nullptr); + PFC_ASSERT(*p_path != 0); + p_abort.check(); + + // Pointless, not a media file, path often from openfiledialog and not canonical + // file_lock_ptr lock = file_lock_manager::get()->acquire_read(p_path, p_abort); + + file_ptr l_file; + filesystem::g_open_timeout(l_file, p_path, filesystem::open_mode_read, 0.5, p_abort); + service_ptr_t instance = new service_impl_t(); + t_filesize size = l_file->get_size_ex(p_abort); + if (size > 1024 * 1024 * 64) throw std::runtime_error("File too large"); + instance->from_stream(l_file.get_ptr(), (t_size)size, p_abort); + return instance; + } + +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/image_load_save.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/image_load_save.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,13 @@ +#pragma once + +namespace fb2k { + bool imageLoadDialog( pfc::string_base & outFN, HWND wndParent, const char * initDir ); + + album_art_data::ptr imageLoadDialog( HWND wndParent, const char * initDir ); + + //! bAllowAsync: run file writing offthread. In such case the caller will not be made aware if writing failed. \n + //! Error popup is shown if actual file writing fails. + bool imageSaveDialog(album_art_data_ptr content, HWND wndParent, const char * initDir , bool bAllowAsync = true ); + + album_art_data::ptr readPictureFile( const char * path, abort_callback & a); +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/inplace_edit.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/inplace_edit.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,25 @@ +#include "stdafx.h" +#include "inplace_edit.h" + +// Functionality moved to libPPUI + +namespace InPlaceEdit { + static reply_t wrapCN( completion_notify::ptr cn ) { + return [cn](unsigned code) { cn->on_completion(code); }; + } + HWND Start(HWND p_parentwnd, const RECT & p_rect, bool p_multiline, pfc::rcptr_t p_content, completion_notify_ptr p_notify) { + return Start(p_parentwnd, p_rect, p_multiline, p_content, wrapCN(p_notify) ); + } + + HWND StartEx(HWND p_parentwnd, const RECT & p_rect, unsigned p_flags, pfc::rcptr_t p_content, completion_notify_ptr p_notify, IUnknown * ACData, DWORD ACOpts ) { + return StartEx(p_parentwnd, p_rect, p_flags, p_content, wrapCN(p_notify), ACData, ACOpts ); + } + + void Start_FromListView(HWND p_listview, unsigned p_item, unsigned p_subitem, unsigned p_linecount, pfc::rcptr_t p_content, completion_notify_ptr p_notify) { + Start_FromListView(p_listview,p_item, p_subitem, p_linecount, p_content, wrapCN(p_notify) ); + } + void Start_FromListViewEx(HWND p_listview, unsigned p_item, unsigned p_subitem, unsigned p_linecount, unsigned p_flags, pfc::rcptr_t p_content, completion_notify_ptr p_notify) { + Start_FromListViewEx(p_listview, p_item, p_subitem, p_linecount, p_flags, p_content, wrapCN(p_notify) ); + } + +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/inplace_edit.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/inplace_edit.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,13 @@ +#pragma once + +#include + +namespace InPlaceEdit { + + HWND Start(HWND p_parentwnd,const RECT & p_rect,bool p_multiline,pfc::rcptr_t p_content,completion_notify_ptr p_notify); + + HWND StartEx(HWND p_parentwnd,const RECT & p_rect,unsigned p_flags,pfc::rcptr_t p_content,completion_notify_ptr p_notify, IUnknown * ACData = NULL, DWORD ACOpts = 0); + + void Start_FromListView(HWND p_listview,unsigned p_item,unsigned p_subitem,unsigned p_linecount,pfc::rcptr_t p_content,completion_notify_ptr p_notify); + void Start_FromListViewEx(HWND p_listview,unsigned p_item,unsigned p_subitem,unsigned p_linecount,unsigned p_flags,pfc::rcptr_t p_content,completion_notify_ptr p_notify); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/input_fix_seeking.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/input_fix_seeking.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,65 @@ +#pragma once + +#include "duration_counter.h" + +// Wrapper to implement input_flag_allow_inaccurate_seeking semantics with decoders that do not implement seeking properly. +// If input_flag_allow_inaccurate_seeking is not specified, brute force seeking is used. +template +class input_fix_seeking : public base_t { +public: + input_fix_seeking() : m_active() {} + + void decode_initialize(unsigned p_flags,abort_callback & p_abort) { + base_t::decode_initialize( p_flags, p_abort ); + m_active = ( p_flags & input_flag_allow_inaccurate_seeking ) == 0; + m_position = 0; + m_decodeFrom = 0; + } + + void decode_initialize(t_uint32 p_subsong,unsigned p_flags,abort_callback & p_abort) { + base_t::decode_initialize( p_subsong, p_flags, p_abort ); + m_active = ( p_flags & input_flag_allow_inaccurate_seeking ) == 0; + m_position = 0; + } + + bool decode_run(audio_chunk & p_chunk,abort_callback & p_abort) { + if ( ! m_active ) { + return base_t::decode_run ( p_chunk, p_abort ); + } + for ( ;; ) { + p_abort.check(); + if (! base_t::decode_run( p_chunk, p_abort ) ) return false; + + double p = m_position.query(); + m_position += p_chunk; + if ( m_decodeFrom > p ) { + auto skip = audio_math::time_to_samples( m_decodeFrom - p, p_chunk.get_sample_rate() ); + if ( skip >= p_chunk.get_sample_count() ) continue; + if ( skip > 0 ) { + p_chunk.skip_first_samples( (size_t) skip ); + } + } + return true; + } + } + + void decode_seek(double p_seconds,abort_callback & p_abort) { + if ( m_active ) { + if ( ! this->decode_can_seek() ) throw exception_io_object_not_seekable(); + m_decodeFrom = p_seconds; + if ( m_decodeFrom < m_position.query() ) { + base_t::decode_seek(0, p_abort); m_position.reset(); + } + } else { + base_t::decode_seek(p_seconds, p_abort); + } + } + + bool decode_run_raw(audio_chunk & p_chunk, mem_block_container & p_raw, abort_callback & p_abort) { + throw pfc::exception_not_implemented(); // shitformats that need this class are not likely to care + } +private: + bool m_active; + duration_counter m_position; + double m_decodeFrom; +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/input_helper_cue.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/input_helper_cue.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,223 @@ +#include "StdAfx.h" +#include "input_helper_cue.h" +#include +#include +#include + + +namespace { + class input_dec_binary : public input_decoder_v2 { + enum { + m_rate = 44100, + m_bps = 16, + m_channels = 2, + m_channelMask = audio_chunk::channel_config_stereo, + m_sampleBytes = (m_bps/8)*m_channels, + m_readAtOnce = 588, + m_readAtOnceBytes = m_readAtOnce * m_sampleBytes + }; + public: + input_dec_binary( file::ptr f ) : m_file(f) {} + t_uint32 get_subsong_count() override {return 0;} + t_uint32 get_subsong(t_uint32 p_index) override {return 0;} + + void get_info(t_uint32 p_subsong,file_info & p_info,abort_callback & p_abort) override { + p_info.reset(); + p_info.info_set_int("samplerate", m_rate); + p_info.info_set_int("channels", m_channels); + p_info.info_set_int("bitspersample", m_bps); + p_info.info_set("encoding","lossless"); + p_info.info_set_bitrate((m_bps * m_channels * m_rate + 500 /* rounding for bps to kbps*/ ) / 1000 /* bps to kbps */); + p_info.info_set("codec", "PCM"); + + try { + auto stats = get_file_stats(p_abort); + if ( stats.m_size != filesize_invalid ) { + p_info.set_length( audio_math::samples_to_time( stats.m_size / 4, 44100 ) ); + } + } catch(exception_io) {} + } + + + t_filestats get_file_stats(abort_callback & p_abort) override { + return m_file->get_stats(p_abort); + } + void initialize(t_uint32 p_subsong,unsigned p_flags,abort_callback & p_abort) override { + m_file->reopen( p_abort ); + } + bool run(audio_chunk & p_chunk,abort_callback & p_abort) override { + mem_block_container_impl stfu; + return run_raw(p_chunk, stfu, p_abort); + } + bool run_raw(audio_chunk & out, mem_block_container & outRaw, abort_callback & abort) override { + size_t bytes = m_readAtOnceBytes; + outRaw.set_size( bytes ); + size_t got = m_file->read(outRaw.get_ptr(), bytes, abort); + got -= got % m_sampleBytes; + if ( got == 0 ) return false; + if ( got < bytes ) outRaw.set_size( got ); + out.set_data_fixedpoint_signed( outRaw.get_ptr(), got, m_rate, m_channels, m_bps, m_channelMask); + return true; + } + void seek(double p_seconds,abort_callback & p_abort) override { + m_file->seek( audio_math::time_to_samples( p_seconds, m_rate ) * m_sampleBytes, p_abort ); + } + bool can_seek() override { + return m_file->can_seek(); + } + bool get_dynamic_info(file_info & p_out, double & p_timestamp_delta) override {return false;} + bool get_dynamic_info_track(file_info & p_out, double & p_timestamp_delta) override {return false;} + void on_idle(abort_callback & p_abort) override {} + void set_logger(event_logger::ptr ptr) override {} + private: + const file::ptr m_file; + }; +} + + +void input_helper_cue::get_info_binary( const char * path, file_info & out, abort_callback & abort ) { + auto f = fileOpenReadExisting( path, abort ); + auto obj = fb2k::service_new< input_dec_binary > ( f ); + obj->get_info( 0, out, abort ); +} + +void input_helper_cue::open(service_ptr_t p_filehint,const playable_location & p_location,unsigned p_flags,abort_callback & p_abort,double p_start,double p_length, bool binary) { + p_abort.check(); + + m_start = p_start; + m_position = 0; + m_dynamic_info_trigger = false; + m_dynamic_info_track_trigger = false; + + if ( binary ) { + { + const char * path = p_location.get_path(); + auto f = fileOpenReadExisting( path, p_abort ); + auto obj = fb2k::service_new< input_dec_binary > ( f ); + + m_input.attach( obj, path ); + m_input.open_decoding( 0, p_flags, p_abort ); + } + } else { + m_input.open(p_filehint,p_location,p_flags,p_abort,true,true); + } + + + if (!m_input.can_seek()) throw exception_io_object_not_seekable(); + + if (m_start > 0) { + m_input.seek(m_start,p_abort); + } + + if (p_length > 0) { + m_length = p_length; + } else { + file_info_impl temp; + m_input.get_info(0,temp,p_abort); + double ref_length = temp.get_length(); + if (ref_length <= 0) throw exception_io_data(); + m_length = ref_length - m_start + p_length /* negative or zero */; + if (m_length <= 0) throw exception_io_data(); + } +} + +void input_helper_cue::close() {m_input.close();} +bool input_helper_cue::is_open() {return m_input.is_open();} + +bool input_helper_cue::_m_input_run(audio_chunk & p_chunk, mem_block_container * p_raw, abort_callback & p_abort) { + if (p_raw == NULL) { + return m_input.run(p_chunk, p_abort); + } else { + return m_input.run_raw(p_chunk, *p_raw, p_abort); + } +} +bool input_helper_cue::_run(audio_chunk & p_chunk, mem_block_container * p_raw, abort_callback & p_abort) { + p_abort.check(); + + if (m_length > 0) { + if (m_position >= m_length) return false; + + if (!_m_input_run(p_chunk, p_raw, p_abort)) return false; + + m_dynamic_info_trigger = true; + m_dynamic_info_track_trigger = true; + + t_uint64 max = (t_uint64)audio_math::time_to_samples(m_length - m_position, p_chunk.get_sample_rate()); + if (max == 0) + {//handle rounding accidents, this normally shouldn't trigger + m_position = m_length; + return false; + } + + t_size samples = p_chunk.get_sample_count(); + if ((t_uint64)samples > max) + { + p_chunk.set_sample_count((unsigned)max); + if (p_raw != NULL) { + const t_size rawSize = p_raw->get_size(); + PFC_ASSERT(rawSize % samples == 0); + p_raw->set_size((t_size)((t_uint64)rawSize * max / samples)); + } + m_position = m_length; + } + else + { + m_position += p_chunk.get_duration(); + } + return true; + } + else + { + if (!_m_input_run(p_chunk, p_raw, p_abort)) return false; + m_position += p_chunk.get_duration(); + return true; + } +} +bool input_helper_cue::run_raw(audio_chunk & p_chunk, mem_block_container & p_raw, abort_callback & p_abort) { + return _run(p_chunk, &p_raw, p_abort); +} + +bool input_helper_cue::run(audio_chunk & p_chunk, abort_callback & p_abort) { + return _run(p_chunk, NULL, p_abort); +} + +void input_helper_cue::seek(double p_seconds, abort_callback & p_abort) +{ + m_dynamic_info_trigger = false; + m_dynamic_info_track_trigger = false; + if (m_length <= 0 || p_seconds < m_length) { + m_input.seek(p_seconds + m_start, p_abort); + m_position = p_seconds; + } + else { + m_position = m_length; + } +} + +bool input_helper_cue::can_seek() { return true; } + +void input_helper_cue::on_idle(abort_callback & p_abort) { m_input.on_idle(p_abort); } + +bool input_helper_cue::get_dynamic_info(file_info & p_out, double & p_timestamp_delta) { + if (m_dynamic_info_trigger) { + m_dynamic_info_trigger = false; + return m_input.get_dynamic_info(p_out, p_timestamp_delta); + } + else { + return false; + } +} + +bool input_helper_cue::get_dynamic_info_track(file_info & p_out, double & p_timestamp_delta) { + if (m_dynamic_info_track_trigger) { + m_dynamic_info_track_trigger = false; + return m_input.get_dynamic_info_track(p_out, p_timestamp_delta); + } + else { + return false; + } +} + +const char * input_helper_cue::get_path() const { return m_input.get_path(); } + +void input_helper_cue::get_info(t_uint32 p_subsong, file_info & p_info, abort_callback & p_abort) { m_input.get_info(p_subsong, p_info, p_abort); } diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/input_helper_cue.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/input_helper_cue.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,32 @@ +#pragma once + +#include "input_helpers.h" + + +class input_helper_cue { +public: + void open(service_ptr_t p_filehint,const playable_location & p_location,unsigned p_flags,abort_callback & p_abort,double p_start,double p_length, bool binary = false); + static void get_info_binary( const char * path, file_info & out, abort_callback & abort ); + + void close(); + bool is_open(); + bool run(audio_chunk & p_chunk,abort_callback & p_abort); + bool run_raw(audio_chunk & p_chunk, mem_block_container & p_raw, abort_callback & p_abort); + void seek(double seconds,abort_callback & p_abort); + bool can_seek(); + void on_idle(abort_callback & p_abort); + bool get_dynamic_info(file_info & p_out,double & p_timestamp_delta); + bool get_dynamic_info_track(file_info & p_out,double & p_timestamp_delta); + void set_logger(event_logger::ptr ptr) {m_input.set_logger(ptr);} + + const char * get_path() const; + + void get_info(t_uint32 p_subsong,file_info & p_info,abort_callback & p_abort); + +private: + bool _run(audio_chunk & p_chunk, mem_block_container * p_raw, abort_callback & p_abort); + bool _m_input_run(audio_chunk & p_chunk, mem_block_container * p_raw, abort_callback & p_abort); + input_helper m_input; + double m_start,m_length,m_position; + bool m_dynamic_info_trigger,m_dynamic_info_track_trigger; +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/input_helpers.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/input_helpers.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,660 @@ +#include "StdAfx.h" + +#include "input_helpers.h" +#include "fullFileBuffer.h" +#include "file_list_helper.h" +#include "fileReadAhead.h" +#include +#include "readers_lite.h" + +#define LOCAL_DEBUG_PRINT(...) // PFC_DEBUG_PRINT(__VA_ARGS__) + +#define FILE_DECODEDAUDIO_PRINT(...) LOCAL_DEBUG_PRINT("file_decodeaudio(", pfc::format_ptr(this), "): ", __VA_ARGS__) + +input_helper::ioFilter_t input_helper::ioFilter_full_buffer(t_filesize val) { + if (val == 0) return nullptr; + return [val] ( file_ptr & f, const char * path, abort_callback & aborter) { + if (!filesystem::g_is_remote_or_unrecognized(path)) { + if (f.is_empty()) filesystem::g_open_read(f, path, aborter); + if (!f->is_in_memory() && !f->is_remote() && f->can_seek() && f->get_size(aborter) <= val) { + try { + f = createFileMemMirrorAsync(f, nullptr, aborter); + return true; + } catch (std::bad_alloc const &) {} // keep orig file object + } + } + return false; + }; +} + +input_helper::ioFilter_t input_helper::ioFilter_block_buffer(size_t arg) { + if (arg == 0) return nullptr; + + return [arg](file_ptr & p_file, const char * p_path, abort_callback & p_abort) { + if (!filesystem::g_is_remote_or_unrecognized(p_path)) { + if (p_file.is_empty()) filesystem::g_open_read(p_file, p_path, p_abort); + if (!p_file->is_in_memory() && !p_file->is_remote() && p_file->can_seek()) { + file_cached::g_create(p_file, p_file, p_abort, (size_t)arg); + return true; + } + } + return false; + }; +} + +static bool looksLikePlaylist(filesystem::ptr const& fs, const char* path) { + auto ext = fs->get_extension(path); + // match against common internet playlist extensions + // yes, this could query fb2k services instead, but uses a fixed list by design + for (auto walk : { "m3u", "pls", "m3u8", "asx" }) { + if (pfc::stringEqualsI_ascii(walk, ext)) return true; + } + return false; +} +static input_helper::ioFilter_t makeReadAhead(size_t arg, bool bRemote) { + if (arg == 0) return nullptr; + + return [arg, bRemote](file_ptr & p_file, const char * p_path, abort_callback & p_abort) { + if (p_file.is_empty()) { + filesystem::ptr fs; + if (!filesystem::g_get_interface(fs, p_path)) return false; + if (bRemote != fs->is_remote(p_path)) return false; + if (looksLikePlaylist(fs, p_path)) return false; + fs->open(p_file, p_path, filesystem::open_mode_read, p_abort); + } else if (bRemote != p_file->is_remote()) return false; + if (p_file->is_in_memory()) return false; + p_file = fileCreateReadAhead(p_file, (size_t)arg, p_abort); + return true; + }; +} + +input_helper::ioFilter_t input_helper::ioFilter_remote_read_ahead(size_t arg) { + return makeReadAhead(arg, true); +} + +input_helper::ioFilter_t input_helper::ioFilter_local_read_ahead(size_t arg) { + return makeReadAhead(arg, false); +} + +void input_helper::open(trackRef location, abort_callback & abort, decodeOpen_t const & other) { + this->open( trackGetLocation(location), abort, other); +} + +void input_helper::open(service_ptr_t p_filehint,trackRef p_location,unsigned p_flags,abort_callback & p_abort,bool p_from_redirect,bool p_skip_hints) +{ + open(p_filehint,trackGetLocation( p_location ),p_flags,p_abort,p_from_redirect,p_skip_hints); +} + +bool input_helper::test_if_lockless(abort_callback& a) { + if (m_file_in_memory || extended_param(input_params::is_tag_write_safe) != 0) return true; + +#if 0 + // doesn't work with current components because they don't support seeking_expensive either + if (extended_param(input_params::seeking_expensive)) { + // could be that the decoder doesn't understand is_tag_write_safe + if (matchProtocol("file", m_path)) { + try { + fileOpenWriteExisting(m_path, a); + return true; + } catch (exception_io const &) {} + } + } +#endif + return false; +} +void input_helper::fileOpenTools(service_ptr_t & p_file,const char * p_path,input_helper::ioFilters_t const & filters, abort_callback & p_abort) { + for( auto & f : filters ) { + if (f) { + if (f(p_file, p_path, p_abort)) break; + } + } +} + +bool input_helper::need_file_reopen(const char * newPath) const { + return m_input.is_empty() || playable_location::path_compare(m_path, newPath) != 0; +} + +bool input_helper::open_path(const char * path, abort_callback & abort, decodeOpen_t const & other) { + abort.check(); + + m_logger = other.m_logger; + + if (!need_file_reopen(path)) { + if ( other.m_logger.is_valid() ) { + input_decoder_v2::ptr v2; + if (m_input->service_query_t(v2)) v2->set_logger(other.m_logger); + } + return false; + } + m_input.release(); + + service_ptr_t l_file = other.m_hint; + fileOpenTools(l_file, path, other.m_ioFilters, abort); + + m_file_in_memory = l_file.is_valid() && l_file->is_in_memory(); + + TRACK_CODE("input_entry::g_open_for_decoding", + m_input ^= input_entry::g_open(input_decoder::class_guid, l_file, path, m_logger, abort, other.m_from_redirect ); + ); + + if (!other.m_skip_hints) { + try { + if ( other.m_infoHook ) { + other.m_infoHook( m_input, path, abort ); + } +#ifdef FOOBAR2000_HAVE_METADB + metadb_io::get()->hint_reader(m_input.get_ptr(), path, abort); +#endif + } + catch (exception_io_data const &) { + //Don't fail to decode when this barfs, might be barfing when reading info from another subsong than the one we're trying to decode etc. + m_input.release(); + if (l_file.is_valid()) l_file->reopen(abort); + TRACK_CODE("input_entry::g_open_for_decoding", + m_input ^= input_entry::g_open(input_decoder::class_guid, l_file, path, m_logger, abort, other.m_from_redirect); + ); + } + } + + if (other.m_shim) m_input = other.m_shim(m_input, path, abort); + + m_path = path; + return true; +} + +void input_helper::open_decoding(t_uint32 subsong, t_uint32 flags, abort_callback & p_abort) { + TRACK_CODE("input_decoder::initialize", m_input->initialize(subsong, flags, p_abort)); +} + +void input_helper::open(const playable_location & location, abort_callback & abort, decodeOpen_t const & other) { + open_path(location.get_path(), abort, other); + + if (other.m_setSampleRate != 0) { + this->extended_param(input_params::set_preferred_sample_rate, other.m_setSampleRate, nullptr, 0); + } + + open_decoding(location.get_subsong(), other.m_flags, abort); +} + +void input_helper::attach(input_decoder::ptr dec, const char * path) { + m_input = dec; + m_path = path; +} + +void input_helper::open(service_ptr_t p_filehint, const playable_location & p_location, unsigned p_flags, abort_callback & p_abort, bool p_from_redirect, bool p_skip_hints) { + decodeOpen_t o; + o.m_hint = p_filehint; + o.m_flags = p_flags; + o.m_from_redirect = p_from_redirect; + o.m_skip_hints = p_skip_hints; + this->open(p_location, p_abort, o); +} + + +void input_helper::close() { + m_input.release(); +} + +bool input_helper::is_open() { + return m_input.is_valid(); +} + +void input_helper::set_pause(bool state) { + input_decoder_v3::ptr v3; + if (m_input->service_query_t(v3)) v3->set_pause(state); +} +bool input_helper::flush_on_pause() { + input_decoder_v3::ptr v3; + if (m_input->service_query_t(v3)) return v3->flush_on_pause(); + else return false; +} + + +void input_helper::set_logger(event_logger::ptr ptr) { + m_logger = ptr; + input_decoder_v2::ptr v2; + if (m_input->service_query_t(v2)) v2->set_logger(ptr); +} + +bool input_helper::run_raw_v2(audio_chunk& p_chunk, mem_block_container& p_raw, uint32_t knownBPS,abort_callback& p_abort) { + PFC_ASSERT(knownBPS >= 8 && knownBPS <= 32); + input_decoder_v2::ptr v2; + if (v2 &= m_input) { + try { + return v2->run_raw(p_chunk, p_raw, p_abort); + // UGLY: it may STILL FAIL with exception_not_implemented due to some underlying code not being able to handle the request!! + } catch (pfc::exception_not_implemented const &) {} + } + if (!m_input->run(p_chunk, p_abort)) return false; + + uint32_t pad = knownBPS + 7; pad -= pad % 8; + p_chunk.toFixedPoint(p_raw, pad, knownBPS); + return true; +} + +bool input_helper::run_raw(audio_chunk & p_chunk, mem_block_container & p_raw, abort_callback & p_abort) { + input_decoder_v2::ptr v2; + if (!m_input->service_query_t(v2)) throw pfc::exception_not_implemented(); + return v2->run_raw(p_chunk, p_raw, p_abort); +} + +bool input_helper::run(audio_chunk & p_chunk, abort_callback & p_abort) { + TRACK_CODE("input_decoder::run", return m_input->run(p_chunk, p_abort)); +} + +void input_helper::seek(double seconds, abort_callback & p_abort) { + TRACK_CODE("input_decoder::seek", m_input->seek(seconds, p_abort)); +} + +bool input_helper::can_seek() { + return m_input->can_seek(); +} + +bool input_helper::query_position( double & val ) { + return extended_param(input_params::query_position, 0, &val, sizeof(val) ) != 0; +} + +size_t input_helper::extended_param(const GUID & type, size_t arg1, void * arg2, size_t arg2size) { + input_decoder_v4::ptr v4; + if (v4 &= m_input) { + return v4->extended_param(type, arg1, arg2, arg2size); + } + return 0; +} +input_helper::decodeInfo_t input_helper::decode_info() { + decodeInfo_t ret = {}; + if (m_input.is_valid()) { + ret.m_can_seek = can_seek(); + ret.m_flush_on_pause = flush_on_pause(); + if (ret.m_can_seek) { + ret.m_seeking_expensive = extended_param(input_params::seeking_expensive, 0, nullptr, 0) != 0; + } + } + return ret; +} + +void input_helper::on_idle(abort_callback & p_abort) { + if (m_input.is_valid()) { + TRACK_CODE("input_decoder::on_idle",m_input->on_idle(p_abort)); + } +} + +bool input_helper::get_dynamic_info(file_info & p_out,double & p_timestamp_delta) { + TRACK_CODE("input_decoder::get_dynamic_info",return m_input->get_dynamic_info(p_out,p_timestamp_delta)); +} + +bool input_helper::get_dynamic_info_track(file_info & p_out,double & p_timestamp_delta) { + TRACK_CODE("input_decoder::get_dynamic_info_track",return m_input->get_dynamic_info_track(p_out,p_timestamp_delta)); +} + +void input_helper::get_info(t_uint32 p_subsong,file_info & p_info,abort_callback & p_abort) { + TRACK_CODE("input_decoder::get_info",m_input->get_info(p_subsong,p_info,p_abort)); +} + +const char * input_helper::get_path() const { + return m_path; +} + + +input_helper::input_helper() +{ +} + + +void input_helper::g_get_info(const playable_location & p_location,file_info & p_info,abort_callback & p_abort,bool p_from_redirect) { + service_ptr_t instance; + input_entry::g_open_for_info_read(instance,0,p_location.get_path(),p_abort,p_from_redirect); + instance->get_info(p_location.get_subsong_index(),p_info,p_abort); +} + +void input_helper::g_set_info(const playable_location & p_location,file_info & p_info,abort_callback & p_abort,bool p_from_redirect) { + service_ptr_t instance; + input_entry::g_open_for_info_write(instance,0,p_location.get_path(),p_abort,p_from_redirect); + instance->set_info(p_location.get_subsong_index(),p_info,p_abort); + instance->commit(p_abort); +} + +#ifdef FOOBAR2000_HAVE_METADB +bool dead_item_filter::run(const pfc::list_base_const_t & p_list,bit_array_var & p_mask) { + file_list_helper::file_list_from_metadb_handle_list path_list; + path_list.init_from_list(p_list); + metadb_handle_list valid_handles; + auto l_metadb = metadb::get(); + for(t_size pathidx=0;pathidxhandle_create(temp,make_playable_location(path,0)); + valid_handles.add_item(temp); + } else { + try { + service_ptr_t reader; + + input_entry::g_open_for_info_read(reader,0,path,*this); + t_uint32 count = reader->get_subsong_count(); + for(t_uint32 n=0;nget_subsong(n); + l_metadb->handle_create(ptr,make_playable_location(path,index)); + valid_handles.add_item(ptr); + } + } catch(...) {} + } + } + + if (is_aborting()) return false; + + valid_handles.sort_by_pointer(); + for(t_size listidx=0;listidx & p_list,bit_array_var & p_mask,abort_callback & p_abort) +{ + dead_item_filter_impl_simple filter(p_abort); + return filter.run(p_list,p_mask); +} + +#endif // #ifdef FOOBAR2000_HAVE_METADB + +void input_info_read_helper::open(const char * p_path,abort_callback & p_abort) { + if (m_input.is_empty() || playable_location::path_compare(m_path,p_path) != 0) + { + TRACK_CODE("input_entry::g_open_for_info_read",input_entry::g_open_for_info_read(m_input,0,p_path,p_abort)); + + m_path = p_path; + } +} + +void input_info_read_helper::get_info(const playable_location & p_location,file_info & p_info,t_filestats & p_stats,abort_callback & p_abort) { + open(p_location.get_path(),p_abort); + + TRACK_CODE("input_info_reader::get_file_stats",p_stats = m_input->get_file_stats(p_abort)); + + TRACK_CODE("input_info_reader::get_info",m_input->get_info(p_location.get_subsong_index(),p_info,p_abort)); +} + +#ifdef FOOBAR2000_HAVE_METADB +void input_info_read_helper::get_info_check(const playable_location & p_location,file_info & p_info,t_filestats & p_stats,bool & p_reloaded,abort_callback & p_abort) { + open(p_location.get_path(),p_abort); + t_filestats newstats; + TRACK_CODE("input_info_reader::get_file_stats",newstats = m_input->get_file_stats(p_abort)); + if (metadb_handle::g_should_reload(p_stats,newstats,true)) { + p_stats = newstats; + TRACK_CODE("input_info_reader::get_info",m_input->get_info(p_location.get_subsong_index(),p_info,p_abort)); + p_reloaded = true; + } else { + p_reloaded = false; + } +} +#endif // #ifdef FOOBAR2000_HAVE_METADB + +// openAudioData code + +static constexpr openAudioDataFormat formatNative = (sizeof(audio_sample) == sizeof(double)) ? openAudioDataFormat::float64 : openAudioDataFormat::float32; + +namespace { + + class file_decodedaudio : public file_readonly { + public: + void init(const playable_location & loc, input_helper::decodeOpen_t const & arg, openAudioDataFormat format, abort_callback & aborter) { + FILE_DECODEDAUDIO_PRINT("opening: ", loc ); + m_length = -1; m_lengthKnown = false; + m_format = format; + m_subsong = loc.get_subsong(); + m_decoder ^= input_entry::g_open( input_decoder::class_guid, arg.m_hint, loc.get_path(), arg.m_logger, aborter, arg.m_from_redirect); + m_seekable = ( arg.m_flags & input_flag_no_seeking ) == 0 && m_decoder->can_seek(); + m_flags = arg.m_flags; + reopenDecoder(aborter); + readChunk(aborter, true); + } + void init(const playable_location & loc, bool bSeekable, file::ptr fileHint, abort_callback & aborter) { + FILE_DECODEDAUDIO_PRINT("opening: ", loc); + m_length = -1; m_lengthKnown = false; + m_subsong = loc.get_subsong(); + input_entry::g_open_for_decoding(m_decoder, fileHint, loc.get_path(), aborter); + m_seekable = bSeekable && m_decoder->can_seek(); + reopenDecoder(aborter); + readChunk(aborter, true); + } + + void reopen(abort_callback & aborter) override { + + // Have valid chunk and it is the first chunk in the stream? Reset read pointers and bail, no need to reopen + if (m_chunk.get_sample_count() > 0 && m_chunkBytesPtr == m_currentPosition) { + m_currentPosition = 0; + m_chunkBytesPtr = 0; + m_eof = false; + return; + } + + reopenDecoder(aborter); + readChunk(aborter); + } + + bool is_remote() override { + return false; + } + t_filetimestamp get_timestamp(abort_callback & p_abort) override { + return m_decoder->get_file_stats(p_abort).m_timestamp; + } + void on_idle(abort_callback & p_abort) override { + m_decoder->on_idle(p_abort); + } + bool get_content_type(pfc::string_base & p_out) override { + return false; + } + bool can_seek() override { + return m_seekable; + } + void seek(t_filesize p_position, abort_callback & p_abort) override { + if (!m_seekable) throw exception_io_object_not_seekable(); + + + { + t_filesize chunkBegin = m_currentPosition - m_chunkBytesPtr; + t_filesize chunkEnd = chunkBegin + curChunkBytes(); + if (p_position >= chunkBegin && p_position < chunkEnd) { + m_chunkBytesPtr = (size_t)(p_position - chunkBegin); + m_currentPosition = p_position; + m_eof = false; + return; + } + } + + { + t_filesize s = get_size(p_abort); + if (s != filesize_invalid) { + if (p_position > s) throw exception_io_seek_out_of_range(); + if (p_position == s) { + m_chunk.reset(); m_curChunkBytes = 0; m_chunkBytesPtr = 0; + m_currentPosition = p_position; + m_eof = true; + return; + } + } + } + + + + const auto row = m_spec.chanCount * sampleBytes(); + t_filesize samples = p_position / row; + const double seekTime = audio_math::samples_to_time(samples, m_spec.sampleRate); + m_decoder->seek(seekTime, p_abort); + m_eof = false; // do this before readChunk + if (!this->readChunk(p_abort)) { + throw std::runtime_error( ( PFC_string_formatter() << "Premature EOF in referenced audio file at " << pfc::format_time_ex(seekTime, 6) << " out of " << pfc::format_time_ex(length(p_abort), 6) ).get_ptr() ); + } + m_chunkBytesPtr = p_position % row; + if (m_chunkBytesPtr > curChunkBytes()) { + // Should not ever happen + m_chunkBytesPtr = 0; + throw std::runtime_error("Decoder returned invalid data"); + } + + m_currentPosition = p_position; + m_eof = false; + } + + t_filesize get_size(abort_callback & aborter) override { + const double l = length(aborter); + if (l <= 0) return filesize_invalid; + return audio_math::time_to_samples(l, m_spec.sampleRate) * m_spec.chanCount * sampleBytes(); + } + t_filesize get_position(abort_callback & p_abort) override { + return m_currentPosition; + } + t_size read(void * p_buffer, t_size p_bytes, abort_callback & p_abort) override { + FILE_DECODEDAUDIO_PRINT("read(", p_bytes, ")"); + size_t done = 0; + for (;;) { + p_abort.check(); + { + const size_t inChunk = curChunkBytes(); + const size_t inChunkRemaining = inChunk - m_chunkBytesPtr; + const size_t delta = pfc::min_t(inChunkRemaining, (p_bytes - done)); + memcpy((uint8_t*)p_buffer + done, (const uint8_t*)m_curChunkPtr + m_chunkBytesPtr, delta); + m_chunkBytesPtr += delta; + done += delta; + m_currentPosition += delta; + + if (done == p_bytes) break; + } + if (!readChunk(p_abort)) break; + } + FILE_DECODEDAUDIO_PRINT("read(", p_bytes, ") returning ", done); + return done; + } + audio_chunk::spec_t const & get_spec() const { return m_spec; } + private: + void reopenDecoder(abort_callback & aborter) { + uint32_t flags = m_flags | input_flag_no_looping; + if (!m_seekable) flags |= input_flag_no_seeking; + + m_decoder->initialize(m_subsong, flags, aborter); + m_eof = false; + m_currentPosition = 0; + } + size_t curChunkBytes() const { + return m_curChunkBytes; + } + bool readChunk(abort_callback & aborter, bool initial = false) { + m_chunkBytesPtr = 0; + FILE_DECODEDAUDIO_PRINT("readChunk()"); + for (;;) { + if (m_eof || !m_decoder->run(m_chunk, aborter)) { + if (initial) throw std::runtime_error("Decoder produced no data"); + m_eof = true; + m_chunk.reset(); m_curChunkBytes = 0; + FILE_DECODEDAUDIO_PRINT("readChunk() EOF"); + return false; + } + if (m_chunk.is_valid()) break; + } + PFC_ASSERT(m_chunk.get_peak() < 100); + audio_chunk::spec_t spec = m_chunk.get_spec(); + if (initial) m_spec = spec; + else if (m_spec != spec) throw std::runtime_error("Sample format change in mid stream"); + + auto inPtr = m_chunk.get_data(); + const size_t inCount = m_chunk.get_used_size(); + m_curChunkBytes = inCount * sampleBytes(); + FILE_DECODEDAUDIO_PRINT("readChunk(): ", m_chunk.get_sample_count(), " samples, ", m_curChunkBytes, " bytes"); + if ( m_format == formatNative ) { + m_curChunkPtr = inPtr; + } else { + m_altFormatBuffer.grow_size(m_curChunkBytes); + m_curChunkPtr = m_altFormatBuffer.get_ptr(); + switch (m_format) { + case openAudioDataFormat::float32: + { auto out = reinterpret_cast(m_curChunkPtr); for (size_t walk = 0; walk < inCount; ++walk) out[walk] = (float)inPtr[walk]; } + break; + case openAudioDataFormat::float64: + { auto out = reinterpret_cast(m_curChunkPtr); for (size_t walk = 0; walk < inCount; ++walk) out[walk] = (double)inPtr[walk]; } + break; + default: + PFC_ASSERT(!"???"); + } + } + + return true; + } + double length(abort_callback & aborter) { + if (!m_lengthKnown) { + file_info_impl temp; + m_decoder->get_info(m_subsong, temp, aborter); + m_length = temp.get_length(); + m_lengthKnown = true; + } + return m_length; + } + unsigned sampleBytes() const { + return m_format == openAudioDataFormat::float32 ? 4 : 8; + } + audio_chunk_fast_impl m_chunk; + size_t m_chunkBytesPtr; + audio_chunk::spec_t m_spec; + double m_length; + bool m_lengthKnown; + bool m_seekable; + uint32_t m_subsong; + input_decoder::ptr m_decoder; + bool m_eof; + t_filesize m_currentPosition; + unsigned m_flags = 0; + openAudioDataFormat m_format = formatNative; + + pfc::array_t m_altFormatBuffer; + void* m_curChunkPtr = nullptr; + size_t m_curChunkBytes = 0; + }; + +} + +openAudioData_t openAudioData3(playable_location const& loc, input_helper::decodeOpen_t const& openArg, openAudioDataFormat format, abort_callback& aborter) { + service_ptr_t f; f = new service_impl_t < file_decodedaudio >; + f->init(loc, openArg, format, aborter); + + openAudioData_t oad = {}; + oad.audioData = f; + oad.audioSpec = f->get_spec(); + return oad; +} + +openAudioData_t openAudioData2(playable_location const & loc, input_helper::decodeOpen_t const & openArg, abort_callback & aborter) { + return openAudioData3(loc, openArg, formatNative, aborter); +} + +openAudioData_t openAudioData(playable_location const & loc, bool bSeekable, file::ptr fileHint, abort_callback & aborter) { + service_ptr_t f; f = new service_impl_t < file_decodedaudio > ; + f->init(loc, bSeekable, fileHint, aborter); + + openAudioData_t oad = {}; + oad.audioData = f; + oad.audioSpec = f->get_spec(); + return oad; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/input_helpers.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/input_helpers.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,162 @@ +#pragma once + +#include +#include +#include +#include + +class input_helper { +public: + input_helper(); + + typedef std::function shim_t; + typedef std::function infoHook_t; + + typedef std::function< bool ( file::ptr &, const char *, abort_callback & ) > ioFilter_t; + typedef std::list ioFilters_t; + + struct decodeInfo_t { + bool m_flush_on_pause; + bool m_can_seek; + bool m_seeking_expensive; + }; + + struct decodeOpen_t { + bool m_from_redirect = false; + bool m_skip_hints = false; + unsigned m_flags = 0; + file::ptr m_hint; + unsigned m_setSampleRate = 0; + + ioFilters_t m_ioFilters; + event_logger::ptr m_logger; + infoHook_t m_infoHook; + shim_t m_shim; + }; + + void open(service_ptr_t p_filehint,const playable_location & p_location,unsigned p_flags,abort_callback & p_abort,bool p_from_redirect = false,bool p_skip_hints = false); + void attach(input_decoder::ptr dec, const char * path); + + void open(const playable_location & location, abort_callback & abort, decodeOpen_t const & other); + + void open(service_ptr_t p_filehint,trackRef p_location,unsigned p_flags,abort_callback & p_abort,bool p_from_redirect = false,bool p_skip_hints = false); + void open(trackRef location, abort_callback & abort, decodeOpen_t const & other); + + + //! Multilevel open helpers. + //! @returns Diagnostic/helper value: true if the decoder had to be re-opened entirely, false if the instance was reused. + bool open_path(const char * path, abort_callback & abort, decodeOpen_t const & other); + //! Multilevel open helpers. + void open_decoding(t_uint32 subsong, t_uint32 flags, abort_callback & p_abort); + + bool need_file_reopen(const char * newPath) const; + + decodeInfo_t decode_info(); + + void close(); + bool is_open(); + //! Single decode pass. + //! @returns True if a chunk was returned, false if EOF (no more audio to return). + bool run(audio_chunk & p_chunk,abort_callback & p_abort); + //! Single decode pass with raw output for integrity verification. \n + //! Throws pfc::exception_not_implemented if this input doesn't support run_raw(). + //! @returns True if a chunk was returned, false if EOF (no more audio to return). + bool run_raw(audio_chunk & p_chunk, mem_block_container & p_raw, abort_callback & p_abort); + //! Single decode pass with raw output for integrity verification. \n + //! If the input doesn't support run_raw(), raw PCM is recreated from audio_chunk. + //! @returns True if a chunk was returned, false if EOF (no more audio to return). + bool run_raw_v2(audio_chunk& p_chunk, mem_block_container& p_raw, uint32_t knownBPS, abort_callback& p_abort); + void seek(double seconds,abort_callback & p_abort); + bool can_seek(); + size_t extended_param( const GUID & type, size_t arg1 = 0, void * arg2 = nullptr, size_t arg2size = 0); + static ioFilter_t ioFilter_full_buffer(t_filesize val ); + static ioFilter_t ioFilter_block_buffer(size_t val); + static ioFilter_t ioFilter_remote_read_ahead( size_t val ); + static ioFilter_t ioFilter_local_read_ahead(size_t val); + + void on_idle(abort_callback & p_abort); + bool get_dynamic_info(file_info & p_out,double & p_timestamp_delta); + bool get_dynamic_info_track(file_info & p_out,double & p_timestamp_delta); + void set_logger(event_logger::ptr ptr); + void set_pause(bool state); + bool flush_on_pause(); + + //! If this decoder has its own special position reporting, decoder-signaled logical decoding position will be returned. \n + //! Otherwise, position calculated from returned audio duration should be assumed. \n + //! Very few special-purpose decoders do this. + bool query_position( double & val ); + + //! Retrieves path of currently open file. + const char * get_path() const; + + //! Retrieves info about specific subsong of currently open file. + void get_info(t_uint32 p_subsong,file_info & p_info,abort_callback & p_abort); + + static void g_get_info(const playable_location & p_location,file_info & p_info,abort_callback & p_abort,bool p_from_redirect = false); + static void g_set_info(const playable_location & p_location,file_info & p_info,abort_callback & p_abort,bool p_from_redirect = false); + + +#ifdef FOOBAR2000_HAVE_METADB + static bool g_mark_dead(const pfc::list_base_const_t & p_list,bit_array_var & p_mask,abort_callback & p_abort); +#endif + + static void fileOpenTools(service_ptr_t& p_file, const char* p_path, ioFilters_t const& filters, abort_callback& p_abort); + + bool test_if_lockless(abort_callback&); + + uint32_t get_subsong_count() const { return m_input->get_subsong_count(); } + uint32_t get_subsong(uint32_t i) const { return m_input->get_subsong(i); } +private: + bool m_file_in_memory = false; + service_ptr_t m_input; + pfc::string8 m_path; + event_logger::ptr m_logger; +}; + +#ifdef FOOBAR2000_HAVE_METADB +class NOVTABLE dead_item_filter : public abort_callback { +public: + virtual void on_progress(t_size p_position,t_size p_total) = 0; + + bool run(const pfc::list_base_const_t & p_list,bit_array_var & p_mask); +}; +#endif + +class input_info_read_helper { +public: + input_info_read_helper() {} + void get_info(const playable_location & p_location,file_info & p_info,t_filestats & p_stats,abort_callback & p_abort); +#ifdef FOOBAR2000_HAVE_METADB + void get_info_check(const playable_location & p_location,file_info & p_info,t_filestats & p_stats,bool & p_reloaded,abort_callback & p_abort); +#endif +private: + void open(const char * p_path,abort_callback & p_abort); + + pfc::string8 m_path; + service_ptr_t m_input; +}; + + +//! openAudioData return value, see openAudioData() +struct openAudioData_t { + file::ptr audioData; // audio data stream + audio_chunk::spec_t audioSpec; // format description (sample rate, channel layout). +}; + +//! Opens the specified location as a stream of audio_samples. \n +//! Returns a file object that allows you to read the audio data stream as if it was a physical file, together with audio stream format description (sample rate, channel layout). \n +//! Please keep in mind that certain features of the returned file object are only as reliable as the underlying file format or decoder implementation allows them to be. \n +//! Reported exact file size may be either unavailable or unreliable if the file format does not let us known the exact value without decoding the whole file. \n +//! Seeking may be inaccurate with certain file formats. \n +//! In general, all file object methods will work as intended on core-supported file formats such as FLAC or WavPack. \n +//! However, if you want 100% functionality regardless of file format being worked with, mirror the content to a temp file and let go of the file object returned by openAudioData(). +openAudioData_t openAudioData(playable_location const & loc, bool bSeekable, file::ptr fileHint, abort_callback & aborter); +openAudioData_t openAudioData2(playable_location const & loc, input_helper::decodeOpen_t const & openArg, abort_callback & aborter); + + +//! openAudioData3 allows explicit format: float32 or float64, for use cases that need such. +enum class openAudioDataFormat { + float32, + float64 +}; +openAudioData_t openAudioData3(playable_location const& loc, input_helper::decodeOpen_t const& openArg, openAudioDataFormat format, abort_callback& aborter); diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/input_logging.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/input_logging.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,35 @@ +#pragma once + + +class input_logging : public input_stubs { +public: + input_logging() { + set_logger(nullptr); + } + + event_logger_recorder::ptr log_record( std::function f ) { + auto rec = event_logger_recorder::create(); + { + pfc::vartoggle_t< event_logger::ptr > toggle( m_logger, rec ); + f(); + } + return rec; + } + + void set_logger( event_logger::ptr logger ) { + if ( logger.is_valid() ) { + m_haveCustomLogger = true; + m_logger = logger; + } else { + m_haveCustomLogger = false; + m_logger = new service_impl_t(); + } + } +protected: + event_logger::ptr m_logger; + bool m_haveCustomLogger = false; +}; + +#define FB2K_INPUT_LOG_STATUS(X) FB2K_LOG_STATUS(m_logger, X) +#define FB2K_INPUT_LOG_WARNING(X) FB2K_LOG_WARNING(m_logger, X) +#define FB2K_INPUT_LOG_ERROR(X) FB2K_LOG_ERROR(m_logger, X) diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/input_stream_info_reader.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/input_stream_info_reader.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,35 @@ +#pragma once + +#ifdef FOOBAR2000_DESKTOP + +template +class input_stream_info_reader_impl : public input_stream_info_reader { +public: + input_t theInput; + + uint32_t get_stream_count() { + return theInput.get_stream_count(); + } + void get_stream_info(uint32_t index, file_info & out, abort_callback & a) { + theInput.get_stream_info(index, out, a); + } + uint32_t get_default_stream() { + return theInput.get_default_stream(); + } +}; + +template +class input_stream_info_reader_entry_impl : public input_stream_info_reader_entry { +public: + input_stream_info_reader::ptr open(const char * path, file::ptr fileHint, abort_callback & abort) { + typedef input_stream_info_reader_impl obj_t; + service_ptr_t p = new service_impl_t(); + p->theInput.open(fileHint, path, input_open_info_read, abort); + return p; + } + GUID get_guid() { + return input_t::g_get_guid(); + } +}; + +#endif // FOOBAR2000_DESKTOP diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/meta_table_builder.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/meta_table_builder.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,146 @@ +#pragma once + +class _meta_table_enum_wrapper { +public: + _meta_table_enum_wrapper(file_info & p_info) : m_info(p_info) {} + template + void operator() (const char * p_name,const t_values & p_values) { + t_size index = ~0; + for(typename t_values::const_iterator iter = p_values.first(); iter.is_valid(); ++iter) { + if (index == ~0) index = m_info.__meta_add_unsafe(p_name,*iter); + else m_info.meta_add_value(index,*iter); + } + } +private: + file_info & m_info; +}; + +class _meta_table_enum_wrapper_RG { +public: + _meta_table_enum_wrapper_RG(file_info & p_info) : m_info(p_info) {} + template + void operator() (const char * p_name,const t_values & p_values) { + if (p_values.get_count() > 0) { + if (!m_info.info_set_replaygain(p_name, *p_values.first())) { + t_size index = ~0; + for(typename t_values::const_iterator iter = p_values.first(); iter.is_valid(); ++iter) { + if (index == ~0) index = m_info.__meta_add_unsafe(p_name,*iter); + else m_info.meta_add_value(index,*iter); + } + } + } + } +private: + file_info & m_info; +}; + +//! Purpose: building a file_info metadata table from loose input without search-for-existing-entry bottleneck +class meta_table_builder { +public: + typedef pfc::chain_list_v2_t t_entry; + typedef pfc::map_t t_content; + + t_content & content() {return m_data;} + t_content const & content() const {return m_data;} + + void add(const char * p_name,const char * p_value,t_size p_value_len = ~0) { + if (file_info::g_is_valid_field_name(p_name)) { + _add(p_name).insert_last()->set_string(p_value,p_value_len); + } + } + + void remove(const char * p_name) { + m_data.remove(p_name); + } + void set(const char * p_name,const char * p_value,t_size p_value_len = ~0) { + if (file_info::g_is_valid_field_name(p_name)) { + t_entry & entry = _add(p_name); + entry.remove_all(); + entry.insert_last()->set_string(p_value,p_value_len); + } + } + t_entry & add(const char * p_name) { + if (!file_info::g_is_valid_field_name(p_name)) uBugCheck();//we return a reference, nothing smarter to do + return _add(p_name); + } + void deduplicate(const char * name) { + t_entry * e; + if (!m_data.query_ptr(name, e)) return; + pfc::avltree_t found; + for(t_entry::iterator iter = e->first(); iter.is_valid(); ) { + t_entry::iterator next = iter; ++next; + const char * v = *iter; + if (!found.add_item_check(v)) e->remove(iter); + iter = next; + } + } + void keep_one(const char * name) { + t_entry * e; + if (!m_data.query_ptr(name, e)) return; + while(e->get_count() > 1) e->remove(e->last()); + } + void tidy_VorbisComment() { + deduplicate("album artist"); + deduplicate("publisher"); + keep_one("totaltracks"); + keep_one("totaldiscs"); + } + void finalize(file_info & p_info) const { + p_info.meta_remove_all(); + _meta_table_enum_wrapper e(p_info); + m_data.enumerate(e); + } + void finalize_withRG(file_info & p_info) const { + p_info.meta_remove_all(); p_info.set_replaygain(replaygain_info_invalid); + _meta_table_enum_wrapper_RG e(p_info); + m_data.enumerate(e); + } + + void from_info(const file_info & p_info) { + m_data.remove_all(); + from_info_overwrite(p_info); + } + void from_info_withRG(const file_info & p_info) { + m_data.remove_all(); + from_info_overwrite(p_info); + from_RG_overwrite(p_info.get_replaygain()); + } + void from_RG_overwrite(replaygain_info const & info) { + info.for_each([&](const char* key, const char* value) { + set(key, value); + }); + } + void from_info_overwrite(const file_info & p_info) { + for(t_size metawalk = 0, metacount = p_info.meta_get_count(); metawalk < metacount; ++metawalk ) { + const t_size valuecount = p_info.meta_enum_value_count(metawalk); + if (valuecount > 0) { + t_entry & entry = add(p_info.meta_enum_name(metawalk)); + entry.remove_all(); + for(t_size valuewalk = 0; valuewalk < valuecount; ++valuewalk) { + entry.insert_last(p_info.meta_enum_value(metawalk,valuewalk)); + } + } + } + } + void reset() {m_data.remove_all();} + + void fix_itunes_compilation() { + auto entry = m_data.find("itunescompilation"); + if (entry.is_valid()) { + auto val = entry->m_value.first(); + if (val.is_valid()) { + if (atoi(val->c_str()) != 0) { + // m_data.remove(cmp); + if (!m_data.have_item("album artist")) add("album artist", "Various Artists"); + } + } + } + } +private: + + t_entry & _add(const char * p_name) { + return m_data.find_or_add(p_name); + } + + t_content m_data; +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/metadb_handle_array.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/metadb_handle_array.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,15 @@ +#pragma once + +class metadb_handle_array : public fb2k::array { +public: + metadb_handle_array() {} + metadb_handle_array(metadb_handle_list&& lst) : m_items(std::move(lst)) {} + size_t count() const override { return m_items.get_size(); } + fb2k::objRef itemAt(size_t index) const override { return m_items[index]; } + + t_size get_count() const override { return m_items.get_size(); } + void get_item_ex(service_ptr& p_out, t_size n) const override { p_out = m_items[n]; } + + metadb_handle_list m_items; +}; + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/metadb_handle_set.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/metadb_handle_set.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,81 @@ +#pragma once +#include +class metadb_handle; + +// Roughly same as pfc::avltree_t or std::set, but optimized for use with large amounts of items +class metadb_handle_set { +public: + metadb_handle_set() {} + template + bool add_item_check(ptr_t const & item) { return add_item_check_(&*item); } + template + bool remove_item(ptr_t const & item) { return remove_item_(&*item); } + + bool add_item_check_(metadb_handle * p) { + bool rv = m_content.insert(p).second; + if (rv) p->service_add_ref(); + return rv; + } + bool remove_item_(metadb_handle * p) { + bool rv = m_content.erase(p) != 0; + if (rv) p->service_release(); + return rv; + } + size_t size() const {return m_content.size();} + size_t get_count() const {return m_content.size(); } + template + bool contains(ptr_t const & item) const { + return m_content.count(&*item) != 0; + } + template + bool have_item(ptr_t const & item) const { + return m_content.count(&*item) != 0; + } + void operator+=(metadb_handle::ptr const & item) { + add_item_check_(item.get_ptr()); + } + void operator-=(metadb_handle::ptr const & item) { + remove_item_(item.get_ptr()); + } + void operator+=(metadb_handle::ptr && item) { + auto p = item.detach(); + bool added = m_content.insert(p).second; + if (!added) p->service_release(); + } + void clear() { + for (auto p : m_content) p->service_release(); + m_content.clear(); + } + void remove_all() { clear();} + template + void enumerate(callback_t & cb) const { + for (auto iter : m_content) cb(iter); + } + typedef std::set impl_t; + typedef impl_t::const_iterator const_iterator; + const_iterator begin() const { return m_content.begin(); } + const_iterator end() const { return m_content.end(); } + + metadb_handle_list to_list() const { + metadb_handle_list ret; ret.prealloc(m_content.size()); + for (auto h : m_content) { + ret.add_item(h); + } + return ret; + } + metadb_handle_set(const metadb_handle_set& src) { _copy(src); } + void operator=(const metadb_handle_set& src) { _copy(src); } + + metadb_handle_set(metadb_handle_set&& src) noexcept { _move(src); } + void operator=(metadb_handle_set&& src) noexcept { _move(src); } +private: + void _copy(const metadb_handle_set& src) { + m_content = src.m_content; + for (auto h : m_content) h->service_add_ref(); + } + void _move(metadb_handle_set& src) { + m_content = std::move(src.m_content); src.m_content.clear(); + } + + impl_t m_content; +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/metadb_info_container_impl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/metadb_info_container_impl.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,2 @@ +#pragma once +#include "../SDK/metadb_info_container_impl.h" \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/metadb_io_callback_v2_data.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/metadb_io_callback_v2_data.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,50 @@ +#pragma once + +#pragma once +#include +#include +#include + +class metadb_io_callback_v2_data_impl : public metadb_io_callback_v2_data { + metadb_handle_list_cref m_items; + pfc::array_t< metadb_v2_rec_t> m_data; + std::once_flag m_once; +public: + metadb_io_callback_v2_data_impl(metadb_handle_list_cref items) : m_items(items) {} + metadb_v2_rec_t get(size_t idxInList) override { + // Late init, don't hammer metadb if nobody cares + // Maybe this should be offthread somehow?? Kick off early, stall till done once asked? + std::call_once(m_once, [&] { m_data = metadb_v2::get()->queryMultiSimple(m_items); }); + PFC_ASSERT(m_data.size() == m_items.get_size()); + PFC_ASSERT(idxInList < m_data.size()); + return m_data[idxInList]; + } +}; + +class metadb_io_callback_v2_data_wrap : public metadb_io_callback_v2_data { +public: + metadb_io_callback_v2_data_wrap(metadb_io_callback_v2_data& chain) : m_chain(chain) {} + metadb_io_callback_v2_data& m_chain; + std::vector m_mapping; + + metadb_v2_rec_t get(size_t idxInList) override { + PFC_ASSERT(idxInList < m_mapping.size()); + return m_chain[m_mapping[idxInList]]; + } +}; + +class metadb_io_callback_v2_data_mirror : public metadb_io_callback_v2_data { +public: + metadb_v2_rec_t get(size_t idxInList) override {return m_data[idxInList];} + + metadb_io_callback_v2_data_mirror() {} + metadb_io_callback_v2_data_mirror(metadb_io_callback_v2_data& source, size_t size) { + init(source, size); + } + void init(metadb_io_callback_v2_data& source, size_t size) { + m_data.set_size_discard(size); + for (size_t w = 0; w < size; ++w) m_data[w] = source[w]; + } +private: + pfc::array_t< metadb_v2_rec_t> m_data; +}; \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/metadb_io_hintlist.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/metadb_io_hintlist.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,50 @@ +#pragma once + +#include "metadb_info_container_impl.h" +#include +#include +#include + + +// Obsolete, use metadb_hint_list instead when possible, wrapper provided for compatibility with old code + +class metadb_io_hintlist { +public: + void hint_reader(service_ptr_t p_reader, const char * p_path,abort_callback & p_abort) { + init(); + m_hints->add_hint_reader( p_path, p_reader, p_abort ); + m_pendingCount += p_reader->get_subsong_count(); + } + void add(metadb_handle_ptr const& h, const file_info& i, t_filestats2 const& s, bool f) { + init(); + metadb_hint_list_v3::ptr v3; + v3 ^= m_hints; + + auto infoObj = fb2k::service_new< metadb_info_container_const_impl >(); + infoObj->m_info = i; infoObj->m_stats = s; + v3->add_hint_v3(h, infoObj, f); + + ++m_pendingCount; + } + void add(metadb_handle_ptr const & p_handle,const file_info & p_info,t_filestats const & p_stats,bool p_fresh) { + init(); + m_hints->add_hint( p_handle, p_info, p_stats, p_fresh ); + ++m_pendingCount; + } + void run() { + if ( m_hints.is_valid() ) { + m_hints->on_done(); + m_hints.release(); + } + m_pendingCount = 0; + } + size_t get_pending_count() const { return m_pendingCount; } +private: + void init() { + if ( m_hints.is_empty() ) { + m_hints = metadb_io_v2::get()->create_hint_list(); + } + } + metadb_hint_list::ptr m_hints; + size_t m_pendingCount = 0; +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/mp3_utils.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/mp3_utils.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,281 @@ +#include "StdAfx.h" + +#include "mp3_utils.h" +#include "bitreader_helper.h" + +using namespace bitreader_helper; + +static unsigned extract_header_bits(const t_uint8 p_header[4],unsigned p_base,unsigned p_bits) +{ + PFC_ASSERT(p_base+p_bits<=32); + return (unsigned) extract_bits(p_header,p_base,p_bits); +} + +namespace { + + class header_parser + { + public: + header_parser(const t_uint8 p_header[4]) : m_bitptr(0) + { + memcpy(m_header,p_header,4); + } + unsigned read(unsigned p_bits) + { + unsigned ret = extract_header_bits(m_header,m_bitptr,p_bits); + m_bitptr += p_bits; + return ret; + } + private: + t_uint8 m_header[4]; + unsigned m_bitptr; + }; +} + +typedef t_uint16 uint16; + +static const uint16 bitrate_table_l1v1[16] = { 0, 32, 64, 96,128,160,192,224,256,288,320,352,384,416,448, 0}; +static const uint16 bitrate_table_l2v1[16] = { 0, 32, 48, 56, 64, 80, 96,112,128,160,192,224,256,320,384, 0}; +static const uint16 bitrate_table_l3v1[16] = { 0, 32, 40, 48, 56, 64, 80, 96,112,128,160,192,224,256,320, 0}; +static const uint16 bitrate_table_l1v2[16] = { 0, 32, 48, 56, 64, 80, 96,112,128,144,160,176,192,224,256, 0}; +static const uint16 bitrate_table_l23v2[16] = { 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96,112,128,144,160, 0}; +static const uint16 sample_rate_table[] = {11025,12000,8000}; + +unsigned mp3_utils::QueryMPEGFrameSize(const t_uint8 p_header[4]) +{ + TMPEGFrameInfo info; + if (!ParseMPEGFrameHeader(info,p_header)) return 0; + return info.m_bytes; +} + +bool mp3_utils::ParseMPEGFrameHeader(TMPEGFrameInfo & p_info,const t_uint8 p_header[4]) +{ + enum {MPEG_LAYER_1 = 3, MPEG_LAYER_2 = 2, MPEG_LAYER_3 = 1}; + enum {_MPEG_1 = 3, _MPEG_2 = 2, _MPEG_25 = 0}; + + header_parser parser(p_header); + if (parser.read(11) != 0x7FF) return false; + unsigned mpeg_version = parser.read(2); + unsigned layer = parser.read(2); + unsigned protection = parser.read(1); + unsigned bitrate_index = parser.read(4); + unsigned sample_rate_index = parser.read(2); + if (sample_rate_index == 3) return false;//reserved + unsigned paddingbit = parser.read(1); + int paddingdelta = 0; + parser.read(1);//private + unsigned channel_mode = parser.read(2); + unsigned channel_mode_ext = parser.read(2);//channel_mode_extension + parser.read(1);//copyright + parser.read(1);//original + parser.read(2);//emphasis + + unsigned bitrate = 0,sample_rate = 0; + + switch(layer) + { + default: + return false; + case MPEG_LAYER_3: + paddingdelta = paddingbit ? 1 : 0; + + p_info.m_layer = 3; + switch(mpeg_version) + { + case _MPEG_1: + p_info.m_duration = 1152; + bitrate = bitrate_table_l3v1[bitrate_index]; + break; + case _MPEG_2: + case _MPEG_25: + p_info.m_duration = 576; + bitrate = bitrate_table_l23v2[bitrate_index]; + break; + default: + return false; + } + + break; + case MPEG_LAYER_2: + paddingdelta = paddingbit ? 1 : 0; + p_info.m_duration = 1152; + p_info.m_layer = 2; + switch(mpeg_version) + { + case _MPEG_1: + bitrate = bitrate_table_l2v1[bitrate_index]; + break; + case _MPEG_2: + case _MPEG_25: + bitrate = bitrate_table_l23v2[bitrate_index]; + break; + default: + return false; + } + break; + case MPEG_LAYER_1: + paddingdelta = paddingbit ? 4 : 0; + p_info.m_duration = 384; + p_info.m_layer = 1; + switch(mpeg_version) + { + case _MPEG_1: + bitrate = bitrate_table_l1v1[bitrate_index]; + break; + case _MPEG_2: + case _MPEG_25: + bitrate = bitrate_table_l1v2[bitrate_index]; + break; + default: + return false; + } + break; + } + if (bitrate == 0) return false; + + sample_rate = sample_rate_table[sample_rate_index]; + if (sample_rate == 0) return false; + switch(mpeg_version) + { + case _MPEG_1: + sample_rate *= 4; + p_info.m_mpegversion = MPEG_1; + break; + case _MPEG_2: + sample_rate *= 2; + p_info.m_mpegversion = MPEG_2; + break; + case _MPEG_25: + p_info.m_mpegversion = MPEG_25; + break; + } + + switch(channel_mode) + { + case 0: + case 1: + case 2: + p_info.m_channels = 2; + break; + case 3: + p_info.m_channels = 1; + break; + } + + + p_info.m_channel_mode = channel_mode; + p_info.m_channel_mode_ext = channel_mode_ext; + + p_info.m_sample_rate = sample_rate; + p_info.m_sample_rate_idx = sample_rate_index; + + p_info.m_bitrate = bitrate; + p_info.m_bitrate_idx = bitrate_index; + + p_info.m_bytes = ( bitrate /*kbps*/ * (1000/8) /* kbps-to-bytes*/ * p_info.m_duration /*samples-per-frame*/ ) / sample_rate + paddingdelta; + + if (p_info.m_layer == 1) p_info.m_bytes &= ~3; + + p_info.m_crc = protection == 0; + + return true; +} + +unsigned mp3header::get_samples_per_frame() +{ + mp3_utils::TMPEGFrameInfo fr; + if (!decode(fr)) return 0; + return fr.m_duration; +} + +bool mp3_utils::IsSameStream(TMPEGFrameInfo const & p_frame1,TMPEGFrameInfo const & p_frame2) { + return + // FFmpeg writes VBR headers with null channel mode... + /* p_frame1.m_channel_mode == p_frame2.m_channel_mode && */ + p_frame1.m_sample_rate == p_frame2.m_sample_rate && + p_frame1.m_layer == p_frame2.m_layer && + p_frame1.m_mpegversion == p_frame2.m_mpegversion; +} + + + +bool mp3_utils::ValidateFrameCRC(const t_uint8 * frameData, t_size frameSize, TMPEGFrameInfo const & info) { + if (frameSize < info.m_bytes) return false; //FAIL, incomplete data + if (!info.m_crc) return true; //nothing to check, frame appears valid + return ExtractFrameCRC(frameData, frameSize, info) == CalculateFrameCRC(frameData, frameSize, info); +} + +static t_uint32 CRC_update(unsigned value, t_uint32 crc) +{ + enum { CRC16_POLYNOMIAL = 0x8005 }; + unsigned i; + value <<= 8; + for (i = 0; i < 8; i++) { + value <<= 1; + crc <<= 1; + if (((crc ^ value) & 0x10000)) crc ^= CRC16_POLYNOMIAL; + } + return crc; +} + + +void mp3_utils::RecalculateFrameCRC(t_uint8 * frameData, t_size frameSize, TMPEGFrameInfo const & info) { + PFC_ASSERT( frameSize >= info.m_bytes && info.m_crc ); + + const t_uint16 crc = CalculateFrameCRC(frameData, frameSize, info); + frameData[4] = (t_uint8)(crc >> 8); + frameData[5] = (t_uint8)(crc & 0xFF); +} + +static t_uint16 grabFrameCRC(const t_uint8 * frameData, t_size sideInfoLen) { + t_uint32 crc = 0xffff; + crc = CRC_update(frameData[2], crc); + crc = CRC_update(frameData[3], crc); + for (t_size i = 6; i < sideInfoLen; i++) { + crc = CRC_update(frameData[i], crc); + } + + return (t_uint32) (crc & 0xFFFF); +} + +t_uint16 mp3_utils::ExtractFrameCRC(const t_uint8 * frameData, t_size frameSize, TMPEGFrameInfo const & info) { + PFC_ASSERT(frameSize >= info.m_bytes && info.m_crc); (void)info; (void)frameSize; + + return ((t_uint16)frameData[4] << 8) | (t_uint16)frameData[5]; + +} +t_uint16 mp3_utils::CalculateFrameCRC(const t_uint8 * frameData, t_size frameSize, TMPEGFrameInfo const & info) { + PFC_ASSERT(frameSize >= info.m_bytes && info.m_crc); (void)frameSize; + + t_size sideInfoLen = 0; + if (info.m_mpegversion == MPEG_1) + sideInfoLen = (info.m_channels == 1) ? 4 + 17 : 4 + 32; + else + sideInfoLen = (info.m_channels == 1) ? 4 + 9 : 4 + 17; + + //CRC + sideInfoLen += 2; + + PFC_ASSERT( sideInfoLen <= frameSize ); + + return grabFrameCRC(frameData, sideInfoLen); +} + + +bool mp3_utils::ValidateFrameCRC(const t_uint8 * frameData, t_size frameSize) { + if (frameSize < 4) return false; //FAIL, not a valid frame + TMPEGFrameInfo info; + if (!ParseMPEGFrameHeader(info, frameData)) return false; //FAIL, not a valid frame + return ValidateFrameCRC(frameData, frameSize, info); +} + + +bool mp3_utils::ParseMPEGFrameHeader(TMPEGFrameInfo & p_info, const void * bytes, size_t bytesAvail) { + if (bytesAvail < 4) return false; //FAIL, not a valid frame + return ParseMPEGFrameHeader(p_info, reinterpret_cast(bytes)); +} + +bool mp3_utils::IsValidMPEGFrameHeader(const void* fourbytes) { + TMPEGFrameInfo info = {}; + return ParseMPEGFrameHeader(info, fourbytes, 4); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/mp3_utils.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/mp3_utils.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,71 @@ +#pragma once + +namespace mp3_utils +{ + + enum { + MPG_MD_STEREO=0, + MPG_MD_JOINT_STEREO=1, + MPG_MD_DUAL_CHANNEL=2, + MPG_MD_MONO=3, + }; + + typedef t_uint8 byte; + + enum {MPEG_1, MPEG_2, MPEG_25}; + + struct TMPEGFrameInfo + { + unsigned m_bytes; + unsigned m_bitrate_idx; // original bitrate index value + unsigned m_bitrate; // kbps + unsigned m_sample_rate_idx; // original samples per second index value + unsigned m_sample_rate; // samples per second + unsigned m_layer; // 1, 2 or 3 + unsigned m_mpegversion; // MPEG_1, MPEG_2, MPEG_25 + unsigned m_channels; // 1 or 2 + unsigned m_duration; // samples + unsigned m_channel_mode; // MPG_MD_* + unsigned m_channel_mode_ext; + bool m_crc; + }; + + + bool ParseMPEGFrameHeader(TMPEGFrameInfo & p_info,const t_uint8 p_header[4]); + bool ParseMPEGFrameHeader(TMPEGFrameInfo & p_info, const void * bytes, size_t bytesAvail); + bool IsValidMPEGFrameHeader(const void* fourbytes); + bool ValidateFrameCRC(const t_uint8 * frameData, t_size frameSize); + bool ValidateFrameCRC(const t_uint8 * frameData, t_size frameSize, TMPEGFrameInfo const & frameInfo); + + //! Assumes valid frame with CRC (frameInfo.m_crc set, frameInfo.m_bytes <= frameSize). + t_uint16 ExtractFrameCRC(const t_uint8 * frameData, t_size frameSize, TMPEGFrameInfo const & frameInfo); + //! Assumes valid frame with CRC (frameInfo.m_crc set, frameInfo.m_bytes <= frameSize). + t_uint16 CalculateFrameCRC(const t_uint8 * frameData, t_size frameSize, TMPEGFrameInfo const & frameInfo); + //! Assumes valid frame with CRC (frameInfo.m_crc set, frameInfo.m_bytes <= frameSize). + void RecalculateFrameCRC(t_uint8 * frameData, t_size frameSize, TMPEGFrameInfo const & frameInfo); + + unsigned QueryMPEGFrameSize(const t_uint8 p_header[4]); + bool IsSameStream(TMPEGFrameInfo const & p_frame1,TMPEGFrameInfo const & p_frame2); +}; + +class mp3header +{ + t_uint8 bytes[4]; +public: + + inline void copy(const mp3header & src) {memcpy(bytes,src.bytes,4);} + inline void copy_raw(const void * src) {memcpy(bytes,src,4);} + + inline void get_bytes(void * out) {memcpy(out,bytes,4);} + inline unsigned get_frame_size() const {return mp3_utils::QueryMPEGFrameSize(bytes);} + inline bool decode(mp3_utils::TMPEGFrameInfo & p_out) {return mp3_utils::ParseMPEGFrameHeader(p_out,bytes);} + + unsigned get_samples_per_frame(); +}; + +static inline mp3header mp3header_from_buffer(const void * p_buffer) +{ + mp3header temp; + temp.copy_raw(p_buffer); + return temp; +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/notifyList.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/notifyList.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,222 @@ +#pragma once + +#include +#include +#include +#include +#include + +template class notifyList : public std::vector { +public: + void operator+=( obj_t * obj ) { this->push_back(obj); } + void operator-=( obj_t * obj ) { + for(auto i = this->begin(); i != this->end(); ++i) { + if (*i == obj) {this->erase(i); return;} + } + PFC_ASSERT(!"Should not get here"); + } + bool contains(obj_t* obj) const { + for (auto i : *this) { + if (i == obj) return true; + } + return false; + } +}; + + + +// Efficient notifylist. Efficient addremove, ordered operation. +template class notifyList2 { +public: + typedef uint64_t key_t; + typedef obj_t * val_t; + + void add( obj_t * obj ) { + auto key = m_increment++; + m_ordered[key] = obj; + m_unordered[obj] = key; + } + void remove(obj_t * obj) { + auto i1 = m_unordered.find(obj); + if (i1 != m_unordered.end()) { + m_ordered.erase(i1->second); + m_unordered.erase(i1); + } + } + void operator+=(obj_t * obj) {add(obj);} + void operator-=(obj_t * obj) {remove(obj);} + + typedef std::vector state_t; + + state_t get() const { + state_t ret; + ret.resize(m_ordered.size()); + size_t walk = 0; + for( auto i = m_ordered.begin(); i != m_ordered.end(); ++i ) { + ret[walk++] = i->second; + } + return std::move(ret); + } + size_t size() const { return m_unordered.size(); } + bool contains( obj_t * obj ) const { return m_unordered.find( obj ) != m_unordered.end(); } + + key_t firstKey() const { + auto iter = m_ordered.begin(); + if (iter == m_ordered.end()) return keyInvalid(); + return iter->first; + } + key_t nextKey(key_t key) const { + auto iter = m_ordered.upper_bound( key ); + if (iter == m_ordered.end()) return keyInvalid(); + return iter->first; + } + obj_t * resolveKey( key_t key ) const { + auto iter = m_ordered.find( key ); + if (iter != m_ordered.end()) return iter->second; + return nullptr; + } + bool validKey(key_t key) const { + return m_ordered.find( key ) != m_ordered.end(); + } + static key_t keyInvalid() { return (key_t)(-1); } +private: + + key_t m_increment; + + std::map m_ordered; + std::map m_unordered; +}; + +template class notifyListUnordered : public std::set { +public: + void operator+=( obj_t * obj ) { + this->insert( obj ); + } + void operator-=( obj_t * obj ) { + this->erase( obj ); + } +}; + +//! Notify list v3 \n +//! Traits: \n +//! * Ordered \n +//! * Efficient add/remove \n +//! * Handles every possible scenario of add/remove in mid enumeration \n +//! * Use begin()/end() to walk with no further workarounds \n +//! * If you've done anything between ++ and *iter - or are using the notifylist in multiple threads, check *iter for giving you a null. Otherwise, after ++ you always have a valid value, or end. \n +//! Available in two flavours, non thread safe (notifyList3<>) and thread safe (notifyList3MT<>). \n +//! Multi threaded version ensures thread safety internally - though once it gives you a pointer, there's no safeguard against removal attempt while the pointer is being used, hence not adivsed. +template class notifyList3_ { +private: + typedef notifyList3_ self_t; + typedef notifyList2< obj_t > content_t; +public: + typedef typename content_t::key_t contentKey_t; + struct data_t { + content_t content; + sync_t sync; + }; + + typedef std::shared_ptr< data_t > dataRef_t; + + notifyList3_( ) : m_data(std::make_shared< data_t >()) {} + + void operator+=( obj_t * obj ) { add(obj); } + void operator-=( obj_t * obj ) { remove(obj); } + + void add( obj_t * obj ) { + inWriteSync( m_data->sync ); + m_data->content.add( obj ); + } + void remove( obj_t * obj ) { + inWriteSync( m_data->sync ); + m_data->content.remove( obj ); + } + size_t size() const { + inReadSync( m_data->sync ); + return m_data->content.size(); + } + + class const_iterator { + public: + + const_iterator( dataRef_t ref, contentKey_t key ) : m_data(ref), m_key(key) { + } + + const_iterator const & operator++(int) { + increment(); + return *this; + } + const_iterator operator++() { + const_iterator ret ( *this ); + increment(); + return std::move(ret); + } + + void increment() { + PFC_ASSERT( isValid() ); + inReadSync( m_data->sync ); + m_key = m_data->content.nextKey( m_key ); + } + + bool isValid() const { + inReadSync( m_data->sync ); + return m_data->content.validKey( m_key ); + } + + bool operator==( const_iterator const & other ) const { + return equals( *this, other ); + } + bool operator!=( const_iterator const & other ) const { + return !equals( *this, other ); + } + + static bool equals( const_iterator const & i1, const_iterator const & i2 ) { + return i1.m_key == i2.m_key; + } + + //! Returns the referenced value. Will be null in case of invalidation in mid-enumeration. + obj_t * operator*() const { + inReadSync( m_data->sync ); + return m_data->content.resolveKey( m_key ); + } + + private: + const_iterator() = delete; + + const dataRef_t m_data; + contentKey_t m_key; + }; + + const_iterator begin() const { + inReadSync( m_data->sync ); + return const_iterator( m_data, m_data->content.firstKey() ); + } + const_iterator end() const { + inReadSync( m_data->sync ); + return const_iterator( m_data, content_t::keyInvalid() ); + } + +private: + notifyList3_( const self_t & ) = delete; + void operator=( const self_t & ) = delete; + + + const dataRef_t m_data; +}; + +//! Thread safe notifyList3. \n +//! See: notifyList3_ +template +class notifyList3MT : public notifyList3_ { +public: + +}; + +//! Non-thread-safe notifyList3. \n +//! See: notifyList3_ +template +class notifyList3 : public notifyList3_ { +public: + +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/packet_decoder_aac_common.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/packet_decoder_aac_common.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,312 @@ +#include "StdAfx.h" + +#include "packet_decoder_aac_common.h" + +#include "../SDK/filesystem_helper.h" +#include "bitreader_helper.h" + +size_t packet_decoder_aac_common::skipADTSHeader( const uint8_t * data,size_t size ) { + if ( size < 7 ) throw exception_io_data(); + PFC_ASSERT( bitreader_helper::extract_int(data, 0, 12) == 0xFFF); + if (bitreader_helper::extract_bit(data, 12+1+2)) { + return 7; // ABSENT flag + } + if (size < 9) throw exception_io_data(); + return 9; +} + +pfc::array_t packet_decoder_aac_common::parseDecoderSetup( const GUID & p_owner,t_size p_param1,const void * p_param2,t_size p_param2size) { + + if ( p_owner == owner_ADTS ) { + pfc::array_t ret; + ret.resize( 2 ); + ret[0] = 0; ret[1] = 0; + // ret: + // 5 bits AOT + // 4 bits freqindex + // 4 bits channelconfig + + // source: + // 12 bits 0xFFF + // 4 bits disregard + // 2 bits AOT-1 @ 16 + // 4 bits freqindex @ 18 + // 1 bit disregard + // 3 bits channelconfig @ 23 + // 26 bits total, 4 bytes minimum + + + if ( p_param2size < 4 ) throw exception_io_data(); + const uint8_t * source = (const uint8_t*) p_param2; + if ( bitreader_helper::extract_int(source, 0, 12) != 0xFFF ) throw exception_io_data(); + size_t aot = bitreader_helper::extract_int(source, 16, 2) + 1; + if ( aot >= 31 ) throw exception_io_data(); + size_t freqindex = bitreader_helper::extract_int(source, 18, 4); + if ( freqindex > 12 ) throw exception_io_data(); + size_t channelconfig = bitreader_helper::extract_bits( source, 23, 3); + + bitreader_helper::write_int(ret.get_ptr(), 0, 5, aot); + bitreader_helper::write_int(ret.get_ptr(), 5, 4, freqindex); + bitreader_helper::write_int(ret.get_ptr(), 9, 4, channelconfig); + return ret; + } else if ( p_owner == owner_ADIF ) { + // bah + } else if ( p_owner == owner_MP4 ) + { + if ( p_param1 == 0x40 || p_param1 == 0x66 || p_param1 == 0x67 || p_param1 == 0x68 ) { + pfc::array_t ret; + ret.set_data_fromptr( (const uint8_t*) p_param2, p_param2size); + return ret; + } + } + else if ( p_owner == owner_matroska ) + { + const matroska_setup * setup = ( const matroska_setup * ) p_param2; + if ( p_param2size == sizeof(*setup) ) + { + if ( !strcmp(setup->codec_id, "A_AAC") || !strncmp(setup->codec_id, "A_AAC/", 6) ) { + pfc::array_t ret; + ret.set_data_fromptr( (const uint8_t*) setup->codec_private, setup->codec_private_size ); + return ret; + } + } + } + throw exception_io_data(); +} + +#if 0 +bool packet_decoder_aac_common::parseDecoderSetup(const GUID &p_owner, t_size p_param1, const void *p_param2, t_size p_param2size, const void *&outCodecPrivate, size_t &outCodecPrivateSize) { + outCodecPrivate = NULL; + outCodecPrivateSize = 0; + + if ( p_owner == owner_ADTS ) { return true; } + else if ( p_owner == owner_ADIF ) { return true; } + else if ( p_owner == owner_MP4 ) + { + if ( p_param1 == 0x40 || p_param1 == 0x66 || p_param1 == 0x67 || p_param1 == 0x68 ) { + outCodecPrivate = p_param2; outCodecPrivateSize = p_param2size; + return true; + } + } + else if ( p_owner == owner_matroska ) + { + const matroska_setup * setup = ( const matroska_setup * ) p_param2; + if ( p_param2size == sizeof(*setup) ) + { + if ( !strcmp(setup->codec_id, "A_AAC") || !strncmp(setup->codec_id, "A_AAC/", 6) ) { + outCodecPrivate = (const uint8_t *) setup->codec_private; + outCodecPrivateSize = setup->codec_private_size; + return true; + } + } + } + return false; + +} +#endif + +bool packet_decoder_aac_common::testDecoderSetup( const GUID & p_owner, t_size p_param1, const void * p_param2, t_size p_param2size ) { + if ( p_owner == owner_ADTS ) { return true; } + else if ( p_owner == owner_ADIF ) { return true; } + else if ( p_owner == owner_MP4 ) + { + if ( p_param1 == 0x40 || p_param1 == 0x66 || p_param1 == 0x67 || p_param1 == 0x68 ) { + return true; + } + } + else if ( p_owner == owner_matroska ) + { + const matroska_setup * setup = ( const matroska_setup * ) p_param2; + if ( p_param2size == sizeof(*setup) ) + { + if ( !strcmp(setup->codec_id, "A_AAC") || !strncmp(setup->codec_id, "A_AAC/", 6) ) { + return true; + } + } + } + return false; +} + + +namespace { + class esds_maker : public stream_writer_buffer_simple { + public: + void write_esds_obj( uint8_t code, const void * data, size_t size, abort_callback & aborter ) { + if ( size >= ( 1 << 28 ) ) throw pfc::exception_overflow(); + write_byte(code, aborter); + for ( int i = 3; i >= 0; -- i ) { + uint8_t c = (uint8_t)( 0x7F & ( size >> 7 * i ) ); + if ( i > 0 ) c |= 0x80; + write_byte(c, aborter); + } + write( data, size, aborter ); + } + void write_esds_obj( uint8_t code, esds_maker const & other, abort_callback & aborter ) { + write_esds_obj( code, other.m_buffer.get_ptr(), other.m_buffer.get_size(), aborter ); + } + void write_byte( uint8_t byte , abort_callback & aborter ) { + write( &byte, 1, aborter ); + } + }; +} + +void packet_decoder_aac_common::make_ESDS( pfc::array_t & outESDS, const void * inCodecPrivate, size_t inCodecPrivateSize ) { + if (inCodecPrivateSize > 1024*1024) throw exception_io_data(); // sanity + auto & p_abort = fb2k::noAbort; + + esds_maker esds4; + + const uint8_t crap[] = {0x40, 0x15, 0x00, 0x00, 0x00, 0x00, 0x05, 0x34, 0x08, 0x00, 0x02, 0x3D, 0x55}; + esds4.write( crap, sizeof(crap), p_abort ); + + { + esds_maker esds5; + esds5.write( inCodecPrivate, inCodecPrivateSize, p_abort ); + esds4.write_esds_obj(5, esds5, p_abort); + } + + + esds_maker esds3; + + esds3.write_byte( 0, p_abort ); + esds3.write_byte( 1, p_abort ); + esds3.write_byte( 0, p_abort ); + esds3.write_esds_obj(4, esds4, p_abort); + + // esds6 after esds4, but doesn't seem that important + + esds_maker final; + final.write_esds_obj(3, esds3, p_abort); + outESDS.set_data_fromptr( final.m_buffer.get_ptr(), final.m_buffer.get_size() ); + + /* + static const uint8_t esdsTemplate[] = { + 0x03, 0x80, 0x80, 0x80, 0x25, 0x00, 0x01, 0x00, 0x04, 0x80, 0x80, 0x80, 0x17, 0x40, 0x15, 0x00, + 0x00, 0x00, 0x00, 0x05, 0x34, 0x08, 0x00, 0x02, 0x3D, 0x55, 0x05, 0x80, 0x80, 0x80, 0x05, 0x12, + 0x30, 0x56, 0xE5, 0x00, 0x06, 0x80, 0x80, 0x80, 0x01, 0x02 + }; + */ + + // ESDS: 03 80 80 80 25 00 01 00 04 80 80 80 17 40 15 00 00 00 00 05 34 08 00 02 3D 55 05 80 80 80 05 12 30 56 E5 00 06 80 80 80 01 02 + // For: 12 30 56 E5 00 + +} + +const uint32_t aac_sample_rates[] = { + 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000, 7350 +}; + +static unsigned readSamplingFreq(bitreader_helper::bitreader_limited& r) { + unsigned samplingRateIndex = (unsigned)r.read(4); + if (samplingRateIndex == 15) { + return (unsigned)r.read(24); + } else { + if (samplingRateIndex >= PFC_TABSIZE(aac_sample_rates)) throw exception_io_data(); + return aac_sample_rates[samplingRateIndex]; + } +} + +packet_decoder_aac_common::audioSpecificConfig_t packet_decoder_aac_common::parseASC(const void * p_, size_t s) { + // Source: https://wiki.multimedia.cx/index.php?title=MPEG-4_Audio + bitreader_helper::bitreader_limited r((const uint8_t*)p_, 0, s * 8); + + audioSpecificConfig_t cfg = {}; + cfg.m_objectType = (unsigned) r.read(5); + if (cfg.m_objectType == 31) { + cfg.m_objectType = 32 + (unsigned) r.read(6); + } + + cfg.m_sampleRate = readSamplingFreq(r); + + cfg.m_channels = (unsigned) r.read( 4 ); + + if (cfg.m_objectType == 5 || cfg.m_objectType == 29) { + cfg.m_explicitSBR = true; + cfg.m_explicitPS = (cfg.m_objectType == 29); + cfg.m_sbrRate = readSamplingFreq(r); + cfg.m_objectType = (unsigned)r.read(5); + } + + switch (cfg.m_objectType) { + case 1: case 2: case 3: case 4: case 17: case 23: + cfg.m_shortWindow = (r.read(1) != 0); + break; + } + + return cfg; +} + +unsigned packet_decoder_aac_common::get_ASC_object_type(const void * p_, size_t s) { + // Source: https://wiki.multimedia.cx/index.php?title=MPEG-4_Audio + bitreader_helper::bitreader_limited r((const uint8_t*)p_, 0, s * 8); + unsigned objectType = (unsigned) r.read(5); + if (objectType == 31) { + objectType = 32 + (unsigned) r.read(6); + } + return objectType; +} + +const char * packet_decoder_aac_common::objectTypeStr( unsigned ot ) { + switch(ot) { + case 1: return "Main"; + case 2: return "LC"; + case 3: return "SSR"; + case 4: return "LTP"; + case 5: return "SBR"; + case 23: return "LD"; + case 39: return "ELD"; + case 42: + case 45: + return "USAC"; + default: + return nullptr; // unknown + } + +} + +const char * packet_decoder_aac_common::audioSpecificConfig_t::objectTypeStr() const { + return packet_decoder_aac_common::objectTypeStr( this->m_objectType ); +} + +pfc::array_t packet_decoder_aac_common::buildASC(audioSpecificConfig_t const& arg) { + pfc::array_t ret; ret.resize(5); memset(ret.get_ptr(), 0, ret.get_size()); + unsigned pos = 0; + auto write = [&](unsigned v, unsigned bits) { + bitreader_helper::write_int(ret.get_ptr(), pos, bits, v); + pos += bits; + }; + + if (arg.m_objectType < 32) { + write(arg.m_objectType, 5); + } else { + write(31, 5); + write(arg.m_objectType - 32, 6); + } + + { + bool stdRate = false; + for (unsigned i = 0; i < std::size(aac_sample_rates); ++i) { + if (arg.m_sampleRate == aac_sample_rates[i]) { + write(i, 4); + stdRate = true; break; + } + } + if (!stdRate) { + write(arg.m_sampleRate, 24); + } + + write(arg.m_channels, 4); + } + + ret.set_size((pos + 7) / 8); + return ret; +} + +pfc::array_t packet_decoder_aac_common::buildSafeASC(unsigned rate) { + if (rate == 0) rate = 44100; + audioSpecificConfig_t info = {}; + info.m_sampleRate = rate; + info.m_objectType = 1; // 1 = main, 2 = LC + info.m_channels = 2; // stereo + return buildASC(info); +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/packet_decoder_aac_common.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/packet_decoder_aac_common.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,46 @@ +#pragma once +#include "../SDK/packet_decoder.h" + +/* +Helper code with common AAC packet_decoder functionality. Primarily meant for foo_input_std-internal use. +*/ + +class packet_decoder_aac_common : public packet_decoder { +public: + static pfc::array_t parseDecoderSetup( const GUID & p_owner,t_size p_param1,const void * p_param2,t_size p_param2size); + static bool testDecoderSetup( const GUID & p_owner, t_size p_param1, const void * p_param2, t_size p_param2size ); + static size_t skipADTSHeader( const uint8_t * data,size_t size ); + + static unsigned get_max_frame_dependency_() + { + return 2; + } + static double get_max_frame_dependency_time_() + { + return 1024.0 / 8000.0; + } + + static void make_ESDS( pfc::array_t & outESDS, const void * inCodecPrivate, size_t inCodecPrivateSize ); + static const char * objectTypeStr( unsigned ot ); + struct audioSpecificConfig_t { + unsigned m_objectType; + unsigned m_sampleRate; + unsigned m_channels; + unsigned m_sbrRate; + bool m_shortWindow; + bool m_explicitSBR, m_explicitPS; + + bool isUSAC() const { return m_objectType == 42 || m_objectType == 45; } + const char * objectTypeStr() const; + }; + + static audioSpecificConfig_t parseASC(const void *, size_t); + + static unsigned get_ASC_object_type(const void *, size_t); + + static pfc::array_t buildASC(audioSpecificConfig_t const&); + + // If no sane ASC was provided by container, make something up to initialize decoder and attempt decoding. + static pfc::array_t buildSafeASC(unsigned rate = 0); + +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/packet_decoder_mp3_common.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/packet_decoder_mp3_common.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,44 @@ +#include "StdAfx.h" +#include "packet_decoder_mp3_common.h" +#include "mp3_utils.h" + +unsigned packet_decoder_mp3_common::parseDecoderSetup( const GUID & p_owner,t_size p_param1,const void * p_param2,t_size p_param2size ) +{ + if (p_owner == owner_MP3) return 3; + else if (p_owner == owner_MP2) return 2; + else if (p_owner == owner_MP1) return 1; + else if (p_owner == owner_MP4) + { + switch(p_param1) + { + case 0x6B: + return 3; + break; + case 0x69: + return 3; + break; + default: + return 0; + } + } + else if (p_owner == owner_matroska) + { + if (p_param2size==sizeof(matroska_setup)) + { + const matroska_setup * setup = (const matroska_setup*) p_param2; + if (!strcmp(setup->codec_id,"A_MPEG/L3")) return 3; + else if (!strcmp(setup->codec_id,"A_MPEG/L2")) return 2; + else if (!strcmp(setup->codec_id,"A_MPEG/L1")) return 1; + else return 0; + } + else return 0; + } + else return 0; +} + +unsigned packet_decoder_mp3_common::layer_from_frame(const void * frame, size_t size) { + using namespace mp3_utils; + TMPEGFrameInfo info; + if (!ParseMPEGFrameHeader(info, frame, size)) throw exception_io_data(); + return info.m_layer; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/packet_decoder_mp3_common.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/packet_decoder_mp3_common.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,84 @@ +#pragma once +#include +/* +Helper code with common MP3 packet_decoder functionality. Primarily meant for foo_input_std-internal use. +*/ + +class packet_decoder_mp3_common : public packet_decoder { +public: + static unsigned parseDecoderSetup( const GUID & p_owner,t_size p_param1,const void * p_param2,t_size p_param2size ); + + static unsigned layer_from_frame(const void *, size_t); + + static unsigned get_max_frame_dependency_() {return 10;} + static double get_max_frame_dependency_time_() {return 10.0 * 1152.0 / 32000.0;} +}; + + +template +class packet_decoder_mp3 : public packet_decoder +{ + impl_t m_decoder; + unsigned m_layer; + + void init(unsigned p_layer) { + m_layer = p_layer; + m_decoder.reset_after_seek(); + } + + bool m_MP4fixes; + +public: + packet_decoder_mp3() : m_layer(0), m_MP4fixes() + { + } + + ~packet_decoder_mp3() + { + } + + t_size set_stream_property(const GUID & p_type, t_size p_param1, const void * p_param2, t_size p_param2size) { + return m_decoder.set_stream_property(p_type, p_param1, p_param2, p_param2size); + } + + void get_info(file_info & p_info) + { + switch (m_layer) + { + case 1: p_info.info_set("codec", "MP1"); break; + case 2: p_info.info_set("codec", "MP2"); break; + case 3: p_info.info_set("codec", "MP3"); break; + default: + throw exception_io_data(); + } + p_info.info_set("encoding", "lossy"); + } + + unsigned get_max_frame_dependency() { return 10; } + double get_max_frame_dependency_time() { return 10.0 * 1152.0 / 32000.0; } + + static bool g_is_our_setup(const GUID & p_owner, t_size p_param1, const void * p_param2, t_size p_param2size) { + return packet_decoder_mp3_common::parseDecoderSetup(p_owner, p_param1, p_param2, p_param2size) != 0; + } + + void open(const GUID & p_owner, bool p_decode, t_size p_param1, const void * p_param2, t_size p_param2size, abort_callback & p_abort) + { + m_MP4fixes = (p_owner == owner_MP4); + unsigned layer = packet_decoder_mp3_common::parseDecoderSetup(p_owner, p_param1, p_param2, p_param2size); + if (layer == 0) throw exception_io_data(); + init(layer); + } + + void reset_after_seek() { + m_decoder.reset_after_seek(); + } + + void decode(const void * p_buffer, t_size p_bytes, audio_chunk & p_chunk, abort_callback & p_abort) { + m_decoder.decode(p_buffer, p_bytes, p_chunk, p_abort); + } + + bool analyze_first_frame_supported() { return m_MP4fixes; } + void analyze_first_frame(const void * p_buffer, t_size p_bytes, abort_callback & p_abort) { + m_layer = packet_decoder_mp3_common::layer_from_frame(p_buffer, p_bytes); + } +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/playlist_position_reference_tracker.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/playlist_position_reference_tracker.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,75 @@ +#pragma once + +class playlist_position_reference_tracker : public playlist_callback_impl_base { +public: + //! @param p_trackitem Specifies whether we want to track some specific item rather than just an offset in a playlist. When set to true, item index becomes invalidated when the item we're tracking is removed. + playlist_position_reference_tracker(bool p_trackitem = true) : playlist_callback_impl_base(~0), m_trackitem(p_trackitem), m_playlist(pfc_infinite), m_item(pfc_infinite) {} + + void on_items_added(t_size p_playlist,t_size p_start, const pfc::list_base_const_t & p_data,const bit_array & p_selection) { + if (p_playlist == m_playlist && m_item != pfc_infinite && p_start <= m_item) { + m_item += p_data.get_count(); + } + } + void on_items_reordered(t_size p_playlist,const t_size * p_order,t_size p_count) { + if (p_playlist == m_playlist) { + if (m_item < p_count) { + m_item = order_helper::g_find_reverse(p_order,m_item); + } else { + m_item = pfc_infinite; + } + } + } + + void on_items_removed(t_size p_playlist,const bit_array & p_mask,t_size p_old_count,t_size p_new_count) { + if (p_playlist == m_playlist) { + if (m_item < p_old_count) { + const t_size item_before = m_item; + for(t_size walk = p_mask.find_first(true,0,p_old_count); walk < p_old_count; walk = p_mask.find_next(true,walk,p_old_count)) { + if (walk < item_before) { + m_item--; + } else if (walk == item_before) { + if (m_trackitem) m_item = pfc_infinite; + break; + } else { + break; + } + } + if (m_item >= p_new_count) m_item = pfc_infinite; + } else { + m_item = pfc_infinite; + } + } + } + + //todo? could be useful in some cases + void on_items_replaced(t_size p_playlist,const bit_array & p_mask,const pfc::list_base_const_t & p_data) {} + + void on_playlist_created(t_size p_index,const char * p_name,t_size p_name_len) { + if (m_playlist != pfc_infinite && p_index <= m_playlist) m_playlist++; + } + void on_playlists_reorder(const t_size * p_order,t_size p_count) { + if (m_playlist < p_count) m_playlist = order_helper::g_find_reverse(p_order,m_playlist); + else m_playlist = pfc_infinite; + } + void on_playlists_removed(const bit_array & p_mask,t_size p_old_count,t_size p_new_count) { + if (m_playlist < p_old_count) { + const t_size playlist_before = m_playlist; + for(t_size walk = p_mask.find_first(true,0,p_old_count); walk < p_old_count; walk = p_mask.find_next(true,walk,p_old_count)) { + if (walk < playlist_before) { + m_playlist--; + } else if (walk == playlist_before) { + m_playlist = pfc_infinite; + break; + } else { + break; + } + } + } else { + m_playlist = pfc_infinite; + } + } + + t_size m_playlist, m_item; +private: + const bool m_trackitem; +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/readWriteLock.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/readWriteLock.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,77 @@ +#pragma once + + +namespace fb2k { + //! fb2k::readWriteLock: abortable readWriteLock, allowing multiple concurrent readers while not writing, or one writer while not reading. \n + //! Safe to release locks in different threads than obtained, contrary to system object such as SRW locks. + class readWriteLock { + pfc::mutex m_guard; + size_t m_readers = 0, m_writers = 0; + typedef std::shared_ptr < pfc::event> eventRef_t; + eventRef_t m_currentEvent; + public: + + void shutdown() { + for (;;) { + eventRef_t waitFor; + { + PFC_INSYNC(m_guard); + if (m_readers == 0 && m_writers == 0) return; + PFC_ASSERT(m_currentEvent); + waitFor = m_currentEvent; + } + waitFor->wait_for(-1); + } + } + + service_ptr beginRead(abort_callback& a) { + for (;;) { + a.check(); + eventRef_t waitFor; + { + PFC_INSYNC(m_guard); + if (m_writers == 0) { + if (!m_currentEvent) m_currentEvent = std::make_shared(); + ++m_readers; + return fb2k::callOnRelease([this] { + PFC_INSYNC(m_guard); + PFC_ASSERT(m_currentEvent); + PFC_ASSERT(m_readers > 0 && m_writers == 0); + if (--m_readers == 0) { + m_currentEvent->set_state(true); m_currentEvent = nullptr; + } + }); + } + PFC_ASSERT(m_currentEvent); + waitFor = m_currentEvent; + } + a.waitForEvent(*waitFor); + } + } + service_ptr beginWrite(abort_callback& a) { + for (;;) { + a.check(); + eventRef_t waitFor; + { + PFC_INSYNC(m_guard); + if (m_readers == 0 && m_writers == 0) { + m_currentEvent = std::make_shared(); + ++m_writers; + return fb2k::callOnRelease([this] { + PFC_INSYNC(m_guard); + PFC_ASSERT(m_currentEvent); + PFC_ASSERT(m_readers == 0 && m_writers > 0); + if (--m_writers == 0) { + m_currentEvent->set_state(true); m_currentEvent = nullptr; + } + }); + } + PFC_ASSERT(m_currentEvent); + waitFor = m_currentEvent; + } + a.waitForEvent(*waitFor); + } + } + + }; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/reader_pretend_nonseekable.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/reader_pretend_nonseekable.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,61 @@ +#pragma once + +class reader_pretend_nonseekable : public file { +public: + reader_pretend_nonseekable( file::ptr f, bool pretendRemote = true ) : m_file(f), m_pretendRemote(pretendRemote) {} + + t_filesize get_size(abort_callback & p_abort) { + return m_file->get_size(p_abort); + } + + + t_filesize get_position(abort_callback & p_abort) { + return m_file->get_position(p_abort); + } + + void resize(t_filesize p_size, abort_callback & p_abort) { + throw exception_io_denied(); + } + + void seek(t_filesize p_position, abort_callback & p_abort) { + throw exception_io_object_not_seekable(); + } + + void seek_ex(t_sfilesize p_position, t_seek_mode p_mode, abort_callback & p_abort) { + throw exception_io_object_not_seekable(); + } + + bool can_seek() {return false;} + + bool get_content_type(pfc::string_base & p_out) { + return m_file->get_content_type(p_out); + } + + bool is_in_memory() { return m_file->is_in_memory(); } + + void on_idle(abort_callback & p_abort) {m_file->on_idle(p_abort);} + + t_filetimestamp get_timestamp(abort_callback & p_abort) { return m_file->get_timestamp(p_abort); } + + void reopen(abort_callback & p_abort) { +#if PFC_DEBUG + auto pos = get_position(p_abort); + FB2K_console_formatter() << "pretend nonseekable reader reopen @ " << pos; + if ( pos > 0 ) { + pfc::nop(); + } +#endif + m_file->reopen(p_abort); + } + + bool is_remote() {return m_pretendRemote;} + + size_t read( void * ptr, size_t bytes, abort_callback & abort ) { return m_file->read(ptr, bytes, abort); } + void read_object(void * p_buffer, t_size p_bytes, abort_callback & p_abort) {m_file->read_object(p_buffer, p_bytes, p_abort); } + t_filesize skip(t_filesize p_bytes, abort_callback & p_abort) { return m_file->skip(p_bytes, p_abort); } + void skip_object(t_filesize p_bytes, abort_callback & p_abort) { m_file->skip_object(p_bytes, p_abort); } + void write( const void * ptr, size_t bytes, abort_callback & abort ) { throw exception_io_denied(); } +private: + const file::ptr m_file; + const bool m_pretendRemote; +}; \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/readers.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/readers.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,594 @@ +#include "StdAfx.h" +#include "readers.h" +#include "readers_lite.h" +#include "fullFileBuffer.h" +#include "fileReadAhead.h" +#include +#include +#include +#include + +t_size reader_membuffer_base::read(void * p_buffer, t_size p_bytes, abort_callback & p_abort) { + p_abort.check_e(); + t_size max = get_buffer_size(); + if (max < m_offset) uBugCheck(); + max -= m_offset; + t_size delta = p_bytes; + if (delta > max) delta = max; + memcpy(p_buffer, (char*)get_buffer() + m_offset, delta); + m_offset += delta; + return delta; +} + +void reader_membuffer_base::seek(t_filesize position, abort_callback & p_abort) { + p_abort.check_e(); + t_filesize max = get_buffer_size(); + if (position == filesize_invalid || position > max) throw exception_io_seek_out_of_range(); + m_offset = (t_size)position; +} + + + + +file::ptr fullFileBuffer::open(const char * path, abort_callback & abort, file::ptr hint, t_filesize sizeMax) { + //mutexScope scope(hMutex, abort); + + file::ptr f; + if (hint.is_valid()) f = hint; + else filesystem::g_open_read(f, path, abort); + + if (sizeMax != filesize_invalid) { + t_filesize fs = f->get_size(abort); + if (fs > sizeMax) return f; + } + try { + service_ptr_t r = new service_impl_t(); + r->init(f, abort); + f = r; + } + catch (std::bad_alloc const &) {} + return f; +} + + + + + + + + + + +#include +#include +#include +#include + +namespace { + struct dynInfoEntry_t { + file_info_impl m_info; + t_filesize m_offset; + }; + struct readAheadInstance_t { + file::ptr m_file; + size_t m_readAhead, m_wakeUpThreschold; + + pfc::array_t m_buffer; + size_t m_bufferBegin, m_bufferEnd; + pfc::event m_canRead; + pfc::event_std m_canWrite; + pfc::mutex m_guard; + std::exception_ptr m_error; + t_filesize m_seekto; + abort_callback_impl m_abort; + bool m_remote; + bool m_atEOF = false; + + bool m_haveDynamicInfo; + std::list m_dynamicInfo; + }; + typedef std::shared_ptr readAheadInstanceRef; + static constexpr t_filesize seek_reopen = (filesize_invalid-1); + class fileReadAhead : public file_readonly_t< service_multi_inherit< service_multi_inherit, stream_receive > > { + service_ptr m_metadata; + public: + readAheadInstanceRef m_instance; + ~fileReadAhead() { + if ( m_instance ) { + auto & i = *m_instance; + pfc::mutexScope guard( i.m_guard ); + i.m_abort.set(); + i.m_canWrite.set_state(true); + } + } + service_ptr get_metadata(abort_callback&) override { return m_metadata; } + void initialize( file::ptr chain, size_t readAhead, abort_callback & aborter ) { + m_metadata = chain->get_metadata_(aborter); + m_stats = chain->get_stats2_( stats2_all, aborter ); + if (!chain->get_content_type(m_contentType)) m_contentType = ""; + m_canSeek = chain->can_seek(); + m_position = chain->get_position( aborter ); + + + auto i = std::make_shared();; + i->m_file = chain; + i->m_remote = chain->is_remote(); + i->m_readAhead = readAhead; + i->m_wakeUpThreschold = readAhead * 3 / 4; + i->m_buffer.set_size_discard( readAhead * 2 ); + i->m_bufferBegin = 0; i->m_bufferEnd = 0; + i->m_canWrite.set_state(true); + i->m_seekto = filesize_invalid; + m_instance = i; + + { + file_dynamicinfo::ptr dyn; + if (dyn &= chain) { + m_haveStaticInfo = dyn->get_static_info(m_staticInfo); + i->m_haveDynamicInfo = dyn->is_dynamic_info_enabled(); + } + } + + fb2k::splitTask( [i] { +#ifdef PFC_SET_THREAD_DESCRIPTION + PFC_SET_THREAD_DESCRIPTION("Fb2k Read-Ahead Thread"); +#endif + worker(*i); + } ); + } + t_size receive(void* p_buffer, t_size p_bytes, abort_callback& p_abort) override { + return read_internal(p_buffer, p_bytes, p_abort, true); + } + t_size read(void* p_buffer, t_size p_bytes, abort_callback& p_abort) override { + return read_internal(p_buffer, p_bytes, p_abort, false); + } + t_size read_internal(void * p_buffer,t_size p_bytes,abort_callback & p_abort, bool bReceive) { + auto & i = * m_instance; + size_t done = 0; + bool initial = true; + while( bReceive ? done == 0 : done < p_bytes ) { + if ( !initial ) { + // Do not invoke waiting with common case read with lots of data in the buffer + pfc::event::g_twoEventWait( i.m_canRead.get_handle(), p_abort.get_abort_event(), -1); + } + p_abort.check(); + pfc::mutexScope guard ( i.m_guard ); + size_t got = i.m_bufferEnd - i.m_bufferBegin; + if (got == 0) { + if (i.m_error) std::rethrow_exception(i.m_error); + if ( initial && ! i.m_atEOF ) { + initial = false; continue; // proceed to wait for more data + } + break; // EOF + } + + size_t delta = pfc::min_t( p_bytes - done, got ); + + const bool wakeUpBefore = got < i.m_wakeUpThreschold; + + auto bufptr = i.m_buffer.get_ptr(); + if ( p_buffer != nullptr ) memcpy( (uint8_t*) p_buffer + done, bufptr + i.m_bufferBegin, delta ); + done += delta; + i.m_bufferBegin += delta; + got -= delta; + m_position += delta; + + if (!i.m_error && !i.m_atEOF) { + if ( got == 0 ) i.m_canRead.set_state( false ); + const bool wakeUpNow = got < i.m_wakeUpThreschold; + // Only set the event when *crossing* the boundary + // we will get a lot of wakeUpNow when nearing EOF + if ( wakeUpNow && ! wakeUpBefore ) i.m_canWrite.set_state( true ); + } + initial = false; + if ( i.m_atEOF ) break; // go no further + } + // FB2K_console_formatter() << "ReadAhead read: " << p_bytes << " => " << done; + return done; + } + t_filesize get_size(abort_callback & p_abort) override { + p_abort.check(); + return m_stats.m_size; + } + t_filesize get_position(abort_callback & p_abort) override { + p_abort.check(); + return m_position; + } + + void seek(t_filesize p_position,abort_callback & p_abort) override { + p_abort.check(); + if (!m_canSeek) throw exception_io_object_not_seekable(); + if ( m_stats.m_size != filesize_invalid && p_position > m_stats.m_size ) throw exception_io_seek_out_of_range(); + + auto posNow = get_position(p_abort); + + if ( p_position >= posNow && p_position < posNow + m_instance->m_readAhead ) { + // FB2K_console_formatter() << "ReadAhead skip: " << posNow << " => " << p_position; + auto toSkip = p_position - posNow; + if ( toSkip > 0 ) read(nullptr, (size_t) toSkip, p_abort); + return; + } + // FB2K_console_formatter() << "ReadAhead seek: " << posNow << " => " << p_position; + + seekInternal( p_position ); + } + bool can_seek() override { + return m_canSeek; + } + bool get_content_type(pfc::string_base & p_out) override { + if (m_contentType.length() == 0) return false; + p_out = m_contentType; return true; + } + t_filestats2 get_stats2( uint32_t, abort_callback & p_abort ) override { + p_abort.check(); + return m_stats; + + } + bool is_remote() override { + return m_instance->m_remote; + } + + void reopen( abort_callback & p_abort ) override { + if ( get_position( p_abort ) == 0 ) return; + seekInternal( seek_reopen ); + } + + bool get_static_info(class file_info & p_out) override { + if ( ! m_haveStaticInfo ) return false; + mergeInfo(p_out, m_staticInfo); + return true; + } + bool is_dynamic_info_enabled() override { + return m_instance->m_haveDynamicInfo; + + } + static void mergeInfo( file_info & out, const file_info & in ) { + out.copy_meta(in); + out.overwrite_info(in); + } + bool get_dynamic_info_v2(class file_info & out, t_filesize & outOffset) override { + auto & i = * m_instance; + if ( ! i.m_haveDynamicInfo ) return false; + + insync( i.m_guard ); + auto ptr = i.m_dynamicInfo.begin(); + for ( ;; ) { + if ( ptr == i.m_dynamicInfo.end() ) break; + if ( ptr->m_offset > m_position ) break; + ++ ptr; + } + + if ( ptr == i.m_dynamicInfo.begin() ) return false; + + auto iter = ptr; --iter; + mergeInfo(out, iter->m_info); + outOffset = iter->m_offset; + i.m_dynamicInfo.erase( i.m_dynamicInfo.begin(), ptr ); + + return true; + } + private: + void seekInternal( t_filesize p_position ) { + auto & i = * m_instance; + insync( i.m_guard ); + if (i.m_error) std::rethrow_exception(i.m_error); + i.m_bufferBegin = i.m_bufferEnd = 0; + i.m_canWrite.set_state(true); + i.m_seekto = p_position; + i.m_atEOF = false; + i.m_canRead.set_state(false); + + m_position = ( p_position == seek_reopen ) ? 0 : p_position; + } + static void worker( readAheadInstance_t & i ) { + try { + bool atEOF = false; + uint8_t* bufptr = i.m_buffer.get_ptr(); + const size_t readAtOnceLimit = i.m_remote ? 64*1024 : 256 * 1024; + for ( ;; ) { + i.m_canWrite.wait_for(-1); + size_t readHowMuch = 0, readOffset = 0; + { + pfc::mutexScope guard(i.m_guard); + i.m_abort.check(); + if ( i.m_seekto != filesize_invalid ) { + if ( i.m_seekto == seek_reopen ) { + i.m_file->reopen( i.m_abort ); + } else { + i.m_file->seek( i.m_seekto, i.m_abort ); + } + + i.m_seekto = filesize_invalid; + atEOF = false; + } + size_t got = i.m_bufferEnd - i.m_bufferBegin; + + if ( i.m_bufferBegin >= i.m_readAhead ) { + memmove( bufptr, bufptr + i.m_bufferBegin, got ); + i.m_bufferBegin = 0; + i.m_bufferEnd = got; + } + + if ( got < i.m_readAhead ) { + readHowMuch = i.m_readAhead - got; + readOffset = i.m_bufferEnd; + } + } + + if ( readHowMuch > readAtOnceLimit ) { + readHowMuch = readAtOnceLimit; + } + + bool dynInfoGot = false; + dynInfoEntry_t dynInfo; + + if ( readHowMuch > 0 ) { + readHowMuch = i.m_file->receive( bufptr + readOffset, readHowMuch, i.m_abort ); + + if ( readHowMuch == 0 ) atEOF = true; + + if ( i.m_haveDynamicInfo ) { + file_dynamicinfo::ptr dyn; + if ( dyn &= i.m_file ) { + file_dynamicinfo_v2::ptr dyn2; + if ( dyn2 &= dyn ) { + dynInfoGot = dyn2->get_dynamic_info_v2(dynInfo.m_info, dynInfo.m_offset); + } else { + dynInfoGot = dyn->get_dynamic_info( dynInfo.m_info ); + if (dynInfoGot) { + dynInfo.m_offset = dyn->get_position( i.m_abort ); + } + } + } + } + } + + { + pfc::mutexScope guard( i.m_guard ); + i.m_abort.check(); + if ( i.m_seekto != filesize_invalid ) { + // Seek request happened while we were reading - discard and continue + continue; + } + i.m_atEOF = atEOF; + i.m_canRead.set_state( true ); + i.m_bufferEnd += readHowMuch; + size_t got = i.m_bufferEnd - i.m_bufferBegin; + if ( atEOF || got >= i.m_readAhead ) i.m_canWrite.set_state(false); + + if ( dynInfoGot ) { + i.m_dynamicInfo.push_back( std::move(dynInfo) ); + } + + } + } + } catch (...) { + pfc::mutexScope guard(i.m_guard); + i.m_error = std::current_exception(); + i.m_canRead.set_state(true); + } + } + + bool m_canSeek; + t_filestats2 m_stats; + pfc::string8 m_contentType; + t_filesize m_position; + + + bool m_haveStaticInfo; + file_info_impl m_staticInfo; + }; + +} + + +file::ptr fileCreateReadAhead(file::ptr chain, size_t readAheadBytes, abort_callback & aborter ) { + auto obj = fb2k::service_new(); + obj->initialize( chain, readAheadBytes, aborter ); + + // Two paths to cast to file*, pick one explicitly to avoid compiler error + file_v2::ptr temp = std::move(obj); + return std::move(temp); +} + + + +namespace { + class CFileWithMemBlock : public reader_membuffer_base { + public: + CFileWithMemBlock(fb2k::memBlockRef mem, t_filestats const& stats, const char* contentType, bool remote) { + m_mem = mem; + m_stats = stats; + m_stats.m_size = mem->size(); + if (contentType != nullptr) m_contentType = contentType; + m_remote = remote; + } + const void* get_buffer() { + return m_mem->get_ptr(); + } + t_size get_buffer_size() { + return m_mem->get_size(); + } + t_filestats get_stats(abort_callback& p_abort) { + p_abort.check(); + return m_stats; + } + bool get_content_type(pfc::string_base& out) { + if (m_contentType.is_empty()) return false; + out = m_contentType; + return true; + } + bool is_remote() { + return m_remote; + } + private: + bool m_remote; + fb2k::memBlockRef m_mem; + pfc::string8 m_contentType; + t_filestats m_stats; + }; +} + +file::ptr createFileWithMemBlock(fb2k::memBlock::ptr mem, t_filestats stats, const char* contentType, bool remote) { + return new service_impl_t< CFileWithMemBlock >(mem, stats, contentType, remote); +} + +file::ptr createFileLimited(file::ptr base, t_filesize offset, t_filesize size, abort_callback& abort) { + return reader_limited::g_create(base, offset, size, abort); +} + +file::ptr createFileBigMemMirror(file::ptr source, abort_callback& abort) { + if (source->is_in_memory()) return source; + auto r = fb2k::service_new(); + r->init(source, abort); + return r; +} + +file::ptr createFileMemMirror(file::ptr source, abort_callback& abort) { + file::ptr ret; + if (!reader_membuffer_mirror::g_create(ret, source, abort)) ret = source; + return ret; +} + +namespace { + class file_memMirrorAsync : public file_readonly_t< file_v2 > { + struct shared_t { + abort_callback_impl m_abort; + size_t m_size; + pfc::mutex m_sync; + file::ptr m_file; + + pfc::bigmem m_data; + size_t m_dataAvailable = 0; + + size_t m_triggerOffset = SIZE_MAX; + pfc::event m_trigger; + }; + shared_t m_shared; + + static void worker(shared_t& s) { + + constexpr size_t tempSize = 256 * 1024; + auto temp = std::make_unique(tempSize); + + while (s.m_dataAvailable < s.m_size) { + size_t got = s.m_file->receive(temp.get(), tempSize, s.m_abort); + if (got == 0) break; + + PFC_INSYNC(s.m_sync); + s.m_data.write(temp.get(), got, s.m_dataAvailable); + + auto before = s.m_dataAvailable; + s.m_dataAvailable += got; + if (before < s.m_triggerOffset && s.m_dataAvailable >= s.m_triggerOffset) { + s.m_trigger.set_state(true); + } + } + } + t_filestats2 m_stats; + bool m_is_remote = false; + pfc::string8 m_contentType; + service_ptr m_metadata; + size_t m_position = 0; + fb2k::thread m_thread; + public: + ~file_memMirrorAsync() { + m_shared.m_abort.set(); + m_thread.waitTillDone(); + } + void open(file::ptr chain, completion_notify::ptr onDone, abort_callback& a) { + if ( chain->get_position(a) > 0 ) chain->reopen(a); + m_stats = chain->get_stats2_(stats2_all, a); + if (m_stats.m_size > SIZE_MAX) throw pfc::exception_overflow(); + m_is_remote = chain->is_remote(); + m_contentType = chain->get_content_type(); + m_metadata = chain->get_metadata_(a); + m_shared.m_size = (size_t)m_stats.m_size; + m_shared.m_file = chain; + m_shared.m_data.resize(m_shared.m_size); + auto work = [this, onDone] { + try { + worker(this->m_shared); + } catch (...) {} + this->m_shared.m_file.release(); + if (onDone.is_valid()) onDone->on_completion(this->m_shared.m_size == this->m_shared.m_dataAvailable ? 1 : 0); + }; + m_thread.startHere(work); + } + + + service_ptr get_metadata(abort_callback& a) override { + a.check(); + return m_metadata; + } + + t_filestats2 get_stats2(uint32_t, abort_callback& a) override { + a.check(); + return m_stats; + } + + t_filesize get_position(abort_callback& p_abort) override { + p_abort.check(); + return m_position; + } + + void seek(t_filesize p_position, abort_callback& p_abort) override { + if (p_position > get_size(p_abort)) throw exception_io_seek_out_of_range(); + m_position = (size_t)p_position; + } + + bool can_seek() override { return true; } + + bool get_content_type(pfc::string_base& p_out) override { + bool rv = m_contentType.length() > 0; + if (rv) p_out = m_contentType; + return rv; + } + + void reopen(abort_callback& p_abort) override { seek(0, p_abort); } + + bool is_remote() override { return m_is_remote; } + + t_size read(void* p_buffer, t_size p_bytes, abort_callback& p_abort) override { + auto limit = get_size(p_abort); + auto left = limit - m_position; + if (p_bytes > left) p_bytes = (size_t)left; + + const auto upper = m_position + p_bytes; + + auto& shared = m_shared; + + { + PFC_INSYNC(shared.m_sync); + if (shared.m_dataAvailable >= upper) { + shared.m_data.read(p_buffer, p_bytes, m_position); + m_position += p_bytes; + return p_bytes; + } + shared.m_trigger.set_state(false); + shared.m_triggerOffset = upper; + } + p_abort.waitForEvent(shared.m_trigger); + + PFC_INSYNC(shared.m_sync); + PFC_ASSERT(shared.m_dataAvailable >= upper); + shared.m_data.read(p_buffer, p_bytes, m_position); + m_position += p_bytes; + return p_bytes; + } + t_filesize skip(t_filesize p_bytes, abort_callback& p_abort) override { + auto total = get_size(p_abort); + PFC_ASSERT(total >= m_position ); + auto left = total - m_position; + if (p_bytes > left) p_bytes = left; + m_position += (size_t)p_bytes; + return p_bytes; + } + }; +} + +file::ptr createFileMemMirrorAsync(file::ptr source, completion_notify::ptr onDone, abort_callback & a) { + auto ret = fb2k::service_new(); + ret->open(source, onDone, a); + return ret; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/readers.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/readers.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,338 @@ +#pragma once + +class NOVTABLE reader_membuffer_base : public file_readonly { +public: + reader_membuffer_base() : m_offset(0) {} + + t_size read(void * p_buffer, t_size p_bytes, abort_callback & p_abort) override; + + void write(const void * p_buffer, t_size p_bytes, abort_callback & p_abort) override { throw exception_io_denied(); } + + t_filesize get_size(abort_callback & p_abort) override { return get_buffer_size(); } + t_filesize get_position(abort_callback & p_abort) override { return m_offset; } + void seek(t_filesize position, abort_callback & p_abort) override; + void reopen(abort_callback & p_abort) override { seek(0, p_abort); } + + bool can_seek() override { return true; } + bool is_in_memory() override { return true; } + +protected: + virtual const void * get_buffer() = 0; + virtual t_size get_buffer_size() = 0; + //virtual t_filetimestamp get_timestamp(abort_callback & p_abort) = 0; + bool get_content_type(pfc::string_base &) override { return false; } + inline void seek_internal(t_size p_offset) { if (p_offset > get_buffer_size()) throw exception_io_seek_out_of_range(); m_offset = p_offset; } +private: + t_size m_offset; +}; + +class reader_membuffer_simple : public reader_membuffer_base { +public: + reader_membuffer_simple(pfc::mem_block&& block, t_filetimestamp ts = filetimestamp_invalid, bool is_remote = false) : m_data(std::move(block)), m_ts(ts), m_isRemote(is_remote) {} + reader_membuffer_simple(const void * ptr, t_size size, t_filetimestamp ts = filetimestamp_invalid, bool is_remote = false) : m_ts(ts), m_isRemote(is_remote) { + m_data.resize(size); + if ( ptr != nullptr ) memcpy(m_data.get_ptr(), ptr, size); + } + const void * get_buffer() { return m_data.get_ptr(); } + void* _get_write_buffer() { return m_data.get_ptr(); } + t_size get_buffer_size() { return m_data.get_size(); } + t_filetimestamp get_timestamp(abort_callback & p_abort) { return m_ts; } + bool is_remote() { return m_isRemote; } + +private: + pfc::mem_block m_data; + t_filetimestamp m_ts; + bool m_isRemote; +}; + +class reader_membuffer_mirror : public reader_membuffer_base +{ +public: + t_filetimestamp get_timestamp(abort_callback & p_abort) { return m_timestamp; } + bool is_remote() { return m_remote; } + + //! Returns false when the object could not be mirrored (too big) or did not need mirroring. + static bool g_create(service_ptr_t & p_out, const service_ptr_t & p_src, abort_callback & p_abort) { + service_ptr_t ptr = new service_impl_t(); + if (!ptr->init(p_src, p_abort)) return false; + p_out = ptr.get_ptr(); + return true; + } + bool get_content_type(pfc::string_base & out) { + if (m_contentType.is_empty()) return false; + out = m_contentType; return true; + } +private: + const void * get_buffer() { return m_buffer.get_ptr(); } + t_size get_buffer_size() { return m_buffer.get_size(); } + + bool init(const service_ptr_t & p_src, abort_callback & p_abort) { + if (p_src->is_in_memory()) return false;//already buffered + if (!p_src->get_content_type(m_contentType)) m_contentType.reset(); + m_remote = p_src->is_remote(); + + t_size size = pfc::downcast_guarded(p_src->get_size(p_abort)); + + m_buffer.set_size(size); + + p_src->reopen(p_abort); + + p_src->read_object(m_buffer.get_ptr(), size, p_abort); + + m_timestamp = p_src->get_timestamp(p_abort); + + return true; + } + + + t_filetimestamp m_timestamp; + pfc::array_t m_buffer; + bool m_remote; + pfc::string8 m_contentType; + +}; + +class reader_limited : public file_readonly_t { + service_ptr_t r; + t_filesize begin; + t_filesize end; + +public: + static file::ptr g_create(file::ptr base, t_filesize offset, t_filesize size, abort_callback & abort) { + service_ptr_t r = new service_impl_t(); + if (offset + size < offset) throw pfc::exception_overflow(); + r->init(base, offset, offset + size, abort); + return r; + } + reader_limited() { begin = 0;end = 0; } + reader_limited(const service_ptr_t & p_r, t_filesize p_begin, t_filesize p_end, abort_callback & p_abort) { + r = p_r; + begin = p_begin; + end = p_end; + reopen(p_abort); + } + + void init(const service_ptr_t & p_r, t_filesize p_begin, t_filesize p_end, abort_callback & p_abort) { + r = p_r; + begin = p_begin; + end = p_end; + reopen(p_abort); + } + + service_ptr get_metadata(abort_callback& a) override {return r->get_metadata_(a);} + t_filestats2 get_stats2(uint32_t f, abort_callback& a) override { + auto ret = r->get_stats2_(f, a); + ret.m_size = this->get_size(a); + return ret; + } + t_filetimestamp get_timestamp(abort_callback & p_abort) override { return r->get_timestamp(p_abort); } + + t_size read(void *p_buffer, t_size p_bytes, abort_callback & p_abort) override { + t_filesize pos; + pos = r->get_position(p_abort); + if (p_bytes > end - pos) p_bytes = (t_size)(end - pos); + return r->read(p_buffer, p_bytes, p_abort); + } + + t_filesize get_size(abort_callback & p_abort) override { return end - begin; } + + t_filesize get_position(abort_callback & p_abort) override { + return r->get_position(p_abort) - begin; + } + + void seek(t_filesize position, abort_callback & p_abort) override { + if (position > end) throw exception_io_seek_out_of_range(); + r->seek(position + begin, p_abort); + } + bool can_seek() override { return r->can_seek(); } + bool is_remote() override { return r->is_remote(); } + + bool get_content_type(pfc::string_base & out) override { return r->get_content_type(out); } + + void reopen(abort_callback & p_abort) override { + seekInternal(begin, p_abort); + } +private: + void seekInternal(t_filesize position, abort_callback & abort) { + if (r->can_seek()) { + r->seek(position, abort); + } else { + t_filesize positionWas = r->get_position(abort); + if (positionWas == filesize_invalid || positionWas > position) { + r->reopen(abort); + try { r->skip_object(position, abort); } + catch (exception_io_data const &) { throw exception_io_seek_out_of_range(); } + } else { + t_filesize skipMe = position - positionWas; + if (skipMe > 0) { + try { r->skip_object(skipMe, abort); } + catch (exception_io_data const &) { throw exception_io_seek_out_of_range(); } + } + } + } + } +}; + + + +// A more clever version of reader_membuffer_*. +// Behaves more nicely with large files within 32bit address space. +class reader_bigmem : public file_readonly_t { +public: + reader_bigmem() : m_offset() {} + t_size read(void * p_buffer, t_size p_bytes, abort_callback & p_abort) override { + pfc::min_acc(p_bytes, remaining()); + m_mem.read(p_buffer, p_bytes, m_offset); + m_offset += p_bytes; + return p_bytes; + } + void read_object(void * p_buffer, t_size p_bytes, abort_callback & p_abort) override { + if (p_bytes > remaining()) throw exception_io_data_truncation(); + m_mem.read(p_buffer, p_bytes, m_offset); + m_offset += p_bytes; + } + t_filesize skip(t_filesize p_bytes, abort_callback & p_abort) override { + pfc::min_acc(p_bytes, (t_filesize)remaining()); + m_offset += (size_t)p_bytes; + return p_bytes; + } + void skip_object(t_filesize p_bytes, abort_callback & p_abort) override { + if (p_bytes > remaining()) throw exception_io_data_truncation(); + m_offset += (size_t)p_bytes; + } + + t_filesize get_size(abort_callback & p_abort) override { p_abort.check(); return m_mem.size(); } + t_filesize get_position(abort_callback & p_abort) override { p_abort.check(); return m_offset; } + void seek(t_filesize p_position, abort_callback & p_abort) override { + if (p_position > m_mem.size()) throw exception_io_seek_out_of_range(); + m_offset = (size_t)p_position; + } + bool can_seek() override { return true; } + bool is_in_memory() override { return true; } + void reopen(abort_callback & p_abort) override { seek(0, p_abort); } + + // To be overridden by individual derived classes + bool get_content_type(pfc::string_base & p_out) override { return false; } + bool is_remote() override { return false; } + service_ptr get_metadata(abort_callback&) override { return nullptr; } + + t_filestats2 get_stats2(uint32_t f, abort_callback& a) override { + t_filestats2 ret; + ret.set_file(); + ret.m_size = get_size(a); + if ( f & stats2_timestamp ) ret.m_timestamp = this->get_timestamp(a); + return ret; + } +protected: + void resize(size_t newSize) { + m_offset = 0; + m_mem.resize(newSize); + } + size_t remaining() const { return m_mem.size() - m_offset; } + pfc::bigmem m_mem; + size_t m_offset; +}; + +class reader_bigmem_mirror : public reader_bigmem { +public: + reader_bigmem_mirror() {} + + void init(file::ptr source, abort_callback & abort) { + source->reopen(abort); + m_metadata = source->get_metadata_(abort); + t_filesize fs = source->get_size(abort); + if (fs > 1024 * 1024 * 1024) { // reject > 1GB + throw std::bad_alloc(); + } + size_t s = (size_t)fs; + resize(s); + for (size_t walk = 0; walk < m_mem._sliceCount(); ++walk) { + source->read(m_mem._slicePtr(walk), m_mem._sliceSize(walk), abort); + } + + if (!source->get_content_type(m_contentType)) m_contentType.reset(); + m_isRemote = source->is_remote(); + m_stats2 = source->get_stats2_(stats2_all, abort); + } + + bool get_content_type(pfc::string_base & p_out) override { + if (m_contentType.is_empty()) return false; + p_out = m_contentType; return true; + } + t_filetimestamp get_timestamp(abort_callback & p_abort) override { return m_stats2.m_timestamp; } + bool is_remote() override { return m_isRemote; } + service_ptr get_metadata(abort_callback&) override { return m_metadata; } + t_filestats2 get_stats2(uint32_t f, abort_callback& a) override { + a.check(); (void)f; return m_stats2; + } +private: + service_ptr m_metadata; + t_filestats2 m_stats2; + pfc::string8 m_contentType; + bool m_isRemote = false; +}; + +class file_chain : public file_v2 { +public: + service_ptr get_metadata(abort_callback& a) override { + return m_file->get_metadata_(a); + } + t_filestats2 get_stats2(uint32_t f, abort_callback& a) override { + return m_file->get_stats2_(f, a); + } + t_size read(void * p_buffer, t_size p_bytes, abort_callback & p_abort) override { + return m_file->read(p_buffer, p_bytes, p_abort); + } + void read_object(void * p_buffer, t_size p_bytes, abort_callback & p_abort) override { + m_file->read_object(p_buffer, p_bytes, p_abort); + } + t_filesize skip(t_filesize p_bytes, abort_callback & p_abort) override { + return m_file->skip(p_bytes, p_abort); + } + void skip_object(t_filesize p_bytes, abort_callback & p_abort) override { + m_file->skip_object(p_bytes, p_abort); + } + void write(const void * p_buffer, t_size p_bytes, abort_callback & p_abort) override { + m_file->write(p_buffer, p_bytes, p_abort); + } + + t_filesize get_size(abort_callback & p_abort) override { + return m_file->get_size(p_abort); + } + + t_filesize get_position(abort_callback & p_abort) override { + return m_file->get_position(p_abort); + } + + void resize(t_filesize p_size, abort_callback & p_abort) override { + m_file->resize(p_size, p_abort); + } + + void seek(t_filesize p_position, abort_callback & p_abort) override { + m_file->seek(p_position, p_abort); + } + + void seek_ex(t_sfilesize p_position, t_seek_mode p_mode, abort_callback & p_abort) override { + m_file->seek_ex(p_position, p_mode, p_abort); + } + + bool can_seek() override { return m_file->can_seek(); } + bool get_content_type(pfc::string_base & p_out) override { return m_file->get_content_type(p_out); } + bool is_in_memory() override { return m_file->is_in_memory(); } + void on_idle(abort_callback & p_abort) override { m_file->on_idle(p_abort); } + t_filetimestamp get_timestamp(abort_callback & p_abort) override { return m_file->get_timestamp(p_abort); } + void reopen(abort_callback & p_abort) override { m_file->reopen(p_abort); } + bool is_remote() override { return m_file->is_remote(); } + + file_chain(file::ptr chain) : m_file(chain) {} +private: + file::ptr m_file; +}; + +class file_chain_readonly : public file_chain { +public: + void write(const void * p_buffer, t_size p_bytes, abort_callback & p_abort) override { throw exception_io_denied(); } + void resize(t_filesize p_size, abort_callback & p_abort) override { throw exception_io_denied(); } + file_chain_readonly(file::ptr chain) : file_chain(chain) {} + static file::ptr create(file::ptr chain) { return new service_impl_t< file_chain_readonly >(chain); } +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/readers_lite.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/readers_lite.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,7 @@ +#pragma once + +file::ptr createFileWithMemBlock(fb2k::memBlock::ptr mem, t_filestats stats = filestats_invalid, const char* contentType = nullptr, bool remote = false); +file::ptr createFileLimited(file::ptr base, t_filesize offset, t_filesize size, abort_callback& abort); +file::ptr createFileBigMemMirror(file::ptr source, abort_callback& abort); +file::ptr createFileMemMirror(file::ptr source, abort_callback& abort); +file::ptr createFileMemMirrorAsync(file::ptr source, completion_notify::ptr optionalDoneReading, abort_callback & a); diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/rethrow.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/rethrow.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,17 @@ +#pragma once + +#include + +#include + +namespace ThreadUtils { + class CRethrow { + private: + std::exception_ptr m_exception; + public: + bool exec( std::function f ) throw(); + void rethrow() const; + bool didFail() const { return !!m_exception; } + void clear() { m_exception = nullptr; } + }; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/seekabilizer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/seekabilizer.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,233 @@ +#include "StdAfx.h" + +#include "seekabilizer.h" + +enum {backread_on_seek = 1024}; + +void seekabilizer_backbuffer::initialize(t_size p_size) +{ + m_depth = m_cursor = 0; + + m_buffer.set_size(p_size); +} + +void seekabilizer_backbuffer::write(const void * p_buffer,t_size p_bytes) +{ + if (p_bytes >= m_buffer.get_size()) + { + memcpy(m_buffer.get_ptr(),(const t_uint8*)p_buffer + p_bytes - m_buffer.get_size(),m_buffer.get_size()); + m_cursor = 0; + m_depth = m_buffer.get_size(); + } + else + { + const t_uint8* sourceptr = (const t_uint8*) p_buffer; + t_size remaining = p_bytes; + while(remaining > 0) + { + t_size delta = m_buffer.get_size() - m_cursor; + if (delta > remaining) delta = remaining; + + memcpy(m_buffer.get_ptr() + m_cursor,sourceptr,delta); + + sourceptr += delta; + remaining -= delta; + m_cursor = (m_cursor + delta) % m_buffer.get_size(); + + m_depth = pfc::min_t(m_buffer.get_size(),m_depth + delta); + + } + } +} + +void seekabilizer_backbuffer::read(t_size p_backlogdepth,void * p_buffer,t_size p_bytes) const +{ + PFC_ASSERT(p_backlogdepth <= m_depth); + PFC_ASSERT(p_backlogdepth >= p_bytes); + + + t_uint8* targetptr = (t_uint8*) p_buffer; + t_size remaining = p_bytes; + t_size cursor = (m_cursor + m_buffer.get_size() - p_backlogdepth) % m_buffer.get_size(); + + while(remaining > 0) + { + t_size delta = m_buffer.get_size() - cursor; + if (delta > remaining) delta = remaining; + + memcpy(targetptr,m_buffer.get_ptr() + cursor,delta); + + targetptr += delta; + remaining -= delta; + cursor = (cursor + delta) % m_buffer.get_size(); + } +} + +t_size seekabilizer_backbuffer::get_depth() const +{ + return m_depth; +} + +t_size seekabilizer_backbuffer::get_max_depth() const +{ + return m_buffer.get_size(); +} + +void seekabilizer_backbuffer::reset() +{ + m_depth = m_cursor = 0; +} + + +void seekabilizer::initialize(service_ptr_t p_base,t_size p_buffer_size,abort_callback & p_abort) { + m_buffer.initialize(p_buffer_size); + m_file = p_base; + m_position = m_position_base = 0; + m_size = m_file->get_size(p_abort); +} + +void seekabilizer::g_seekabilize(service_ptr_t & p_reader,t_size p_buffer_size,abort_callback & p_abort) { + if (p_reader.is_valid() && (p_reader->is_remote() || !p_reader->can_seek()) && p_buffer_size > 0) { + auto instance = fb2k::service_new(); + instance->initialize(p_reader,p_buffer_size,p_abort); + p_reader = instance.get_ptr(); + } +} + +t_size seekabilizer::read(void * p_buffer,t_size p_bytes,abort_callback & p_abort) { + p_abort.check_e(); + + if (m_position > m_position_base + pfc::max_t(m_buffer.get_max_depth(),backread_on_seek) && m_file->can_seek()) { + m_buffer.reset(); + t_filesize target = m_position; + if (target < backread_on_seek) target = 0; + else target -= backread_on_seek; + m_file->seek(target,p_abort); + m_position_base = target; + } + + //seek ahead + while(m_position > m_position_base) { + enum {tempsize = 1024}; + t_uint8 temp[tempsize]; + t_size delta = (t_size) pfc::min_t(tempsize,m_position - m_position_base); + t_size bytes_read = 0; + bytes_read = m_file->read(temp,delta,p_abort); + m_buffer.write(temp,bytes_read); + m_position_base += bytes_read; + + if (bytes_read < delta) { + return 0; + } + } + + t_size done = 0; + t_uint8 * targetptr = (t_uint8*) p_buffer; + + //try to read backbuffer + if (m_position < m_position_base) { + if (m_position_base - m_position > (t_filesize)m_buffer.get_depth()) throw exception_io_seek_out_of_range(); + t_size backread_depth = (t_size) (m_position_base - m_position); + t_size delta = pfc::min_t(backread_depth,p_bytes-done); + m_buffer.read(backread_depth,targetptr,delta); + done += delta; + m_position += delta; + } + + //regular read + if (done < p_bytes) + { + t_size bytes_read; + bytes_read = m_file->read(targetptr+done,p_bytes-done,p_abort); + + m_buffer.write(targetptr+done,bytes_read); + + done += bytes_read; + m_position += bytes_read; + m_position_base += bytes_read; + } + + return done; +} + +t_filesize seekabilizer::get_size(abort_callback & p_abort) { + p_abort.check_e(); + return m_size; +} + +t_filesize seekabilizer::get_position(abort_callback & p_abort) { + p_abort.check_e(); + return m_position; +} + +void seekabilizer::seek(t_filesize p_position,abort_callback & p_abort) { + PFC_ASSERT(m_position_base >= m_buffer.get_depth()); + p_abort.check_e(); + + if (m_size != filesize_invalid && p_position > m_size) throw exception_io_seek_out_of_range(); + + t_filesize lowest = m_position_base - m_buffer.get_depth(); + + if (p_position < lowest) { + if (m_file->can_seek()) { + m_buffer.reset(); + t_filesize target = p_position; + t_size delta = m_buffer.get_max_depth(); + if (delta > backread_on_seek) delta = backread_on_seek; + if (target > delta) target -= delta; + else target = 0; + m_file->seek(target,p_abort); + m_position_base = target; + } + else { + m_buffer.reset(); + m_file->reopen(p_abort); + m_position_base = 0; + } + } + + m_position = p_position; +} + +bool seekabilizer::can_seek() +{ + return true; +} + +bool seekabilizer::get_content_type(pfc::string_base & p_out) {return m_file->get_content_type(p_out);} + +bool seekabilizer::is_in_memory() {return false;} + +void seekabilizer::on_idle(abort_callback & p_abort) {return m_file->on_idle(p_abort);} + +t_filetimestamp seekabilizer::get_timestamp(abort_callback & p_abort) { + p_abort.check_e(); + return m_file->get_timestamp(p_abort); +} + +void seekabilizer::reopen(abort_callback & p_abort) { + if (m_position_base - m_buffer.get_depth() == 0) { + seek(0,p_abort); + } else { + m_position = m_position_base = 0; + m_buffer.reset(); + m_file->reopen(p_abort); + } +} + +bool seekabilizer::is_remote() +{ + return m_file->is_remote(); +} + +service_ptr seekabilizer::get_metadata(abort_callback& a) { + return m_file->get_metadata_(a); +} + +t_filestats2 seekabilizer::get_stats2(uint32_t s2flags, abort_callback& a) { + return m_file->get_stats2_(s2flags, a); +} + +size_t seekabilizer::lowLevelIO(const GUID& guid, size_t arg1, void* arg2, size_t arg2size, abort_callback& abort) { + return m_file->lowLevelIO_(guid, arg1, arg2, arg2size, abort); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/seekabilizer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/seekabilizer.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,42 @@ +#pragma once + +class seekabilizer_backbuffer +{ +public: + void initialize(t_size p_size); + void write(const void * p_buffer,t_size p_bytes); + void read(t_size p_backlogdepth,void * p_buffer,t_size p_bytes) const; + t_size get_depth() const; + void reset(); + t_size get_max_depth() const; +private: + pfc::array_t m_buffer; + t_size m_depth,m_cursor; +}; + +class seekabilizer : public file_readonly_t { +public: + void initialize(service_ptr_t p_base,t_size p_buffer_size,abort_callback & p_abort); + + static void g_seekabilize(service_ptr_t & p_reader,t_size p_buffer_size,abort_callback & p_abort); + + t_size read(void * p_buffer,t_size p_bytes,abort_callback & p_abort); + t_filesize get_size(abort_callback & p_abort); + t_filesize get_position(abort_callback & p_abort); + void seek(t_filesize p_position,abort_callback & p_abort); + bool can_seek(); + bool get_content_type(pfc::string_base & p_out); + bool is_in_memory(); + void on_idle(abort_callback & p_abort); + t_filetimestamp get_timestamp(abort_callback & p_abort); + void reopen(abort_callback & p_abort); + bool is_remote(); + + service_ptr get_metadata(abort_callback&); + t_filestats2 get_stats2(uint32_t s2flags, abort_callback&); + size_t lowLevelIO(const GUID& guid, size_t arg1, void* arg2, size_t arg2size, abort_callback& abort); +private: + service_ptr_t m_file; + seekabilizer_backbuffer m_buffer; + t_filesize m_size,m_position,m_position_base; +}; \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/stream_buffer_helper.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/stream_buffer_helper.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,89 @@ +#include "StdAfx.h" + +#include "stream_buffer_helper.h" + +stream_reader_buffered::stream_reader_buffered(stream_reader * p_base,t_size p_buffer) : m_base(p_base) +{ + m_buffer.set_size_in_range(pfc::min_t(1024, p_buffer), p_buffer); + m_bufferRemaining = 0; +} + +t_size stream_reader_buffered::read(void * p_buffer,t_size p_bytes,abort_callback & p_abort) { + if (p_bytes <= m_bufferRemaining) { + memcpy( p_buffer, m_bufferPtr, p_bytes ); + m_bufferRemaining -= p_bytes; + m_bufferPtr += p_bytes; + return p_bytes; + } + + p_abort.check(); + char * output = (char*) p_buffer; + t_size output_ptr = 0; + + while(output_ptr < p_bytes) { + { + t_size delta = pfc::min_t(p_bytes - output_ptr, m_bufferRemaining); + if (delta > 0) + { + memcpy(output + output_ptr, m_bufferPtr, delta); + output_ptr += delta; + m_bufferPtr += delta; + m_bufferRemaining -= delta; + } + } + + if (m_bufferRemaining == 0) + { + t_size bytes_read; + bytes_read = m_base->read(m_buffer.get_ptr(), m_buffer.get_size(), p_abort); + m_bufferPtr = m_buffer.get_ptr(); + m_bufferRemaining = bytes_read; + + if (m_bufferRemaining == 0) break; + } + + } + + return output_ptr; +} + +stream_writer_buffered::stream_writer_buffered(stream_writer * p_base,t_size p_buffer) + : m_base(p_base) +{ + m_buffer.set_size_in_range(pfc::min_t(1024, p_buffer), p_buffer); + m_buffer_ptr = 0; +} + +void stream_writer_buffered::write(const void * p_buffer,t_size p_bytes,abort_callback & p_abort) { + p_abort.check_e(); + const char * source = (const char*)p_buffer; + t_size source_remaining = p_bytes; + const t_size buffer_size = m_buffer.get_size(); + if (source_remaining >= buffer_size) + { + flush(p_abort); + m_base->write_object(source,source_remaining,p_abort); + return; + } + + if (m_buffer_ptr + source_remaining >= buffer_size) + { + t_size delta = buffer_size - m_buffer_ptr; + memcpy(m_buffer.get_ptr() + m_buffer_ptr, source,delta); + source += delta; + source_remaining -= delta; + m_buffer_ptr += delta; + flush(p_abort); + } + + memcpy(m_buffer.get_ptr() + m_buffer_ptr, source,source_remaining); + m_buffer_ptr += source_remaining; +} + + +void stream_writer_buffered::flush(abort_callback & p_abort) { + if (m_buffer_ptr > 0) { + m_base->write_object(m_buffer.get_ptr(),m_buffer_ptr,p_abort); + m_buffer_ptr = 0; + } +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/stream_buffer_helper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/stream_buffer_helper.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,29 @@ +#pragma once + +class stream_reader_buffered : public stream_reader +{ +public: + stream_reader_buffered(stream_reader * p_base,t_size p_buffer); + t_size read(void * p_buffer,t_size p_bytes,abort_callback & p_abort); +private: + stream_reader * m_base; + pfc::array_t m_buffer; + const char * m_bufferPtr; + size_t m_bufferRemaining; +}; + +class stream_writer_buffered : public stream_writer +{ +public: + stream_writer_buffered(stream_writer * p_base,t_size p_buffer); + + void write(const void * p_buffer,t_size p_bytes,abort_callback & p_abort); + + void flush(abort_callback & p_abort); + +private: + stream_writer * m_base; + pfc::array_t m_buffer; + t_size m_buffer_ptr; +}; + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/tag_write_callback_impl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/tag_write_callback_impl.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,81 @@ +#pragma once + +#ifdef PFC_WINDOWS_STORE_APP +#include +#endif + +#if defined(_WIN32) && defined(FOOBAR2000_MOBILE) +#include +#include +#endif + +#include +#include + +class tag_write_callback_impl : public tag_write_callback { +public: + tag_write_callback_impl(const char * p_origpath) : m_origpath(p_origpath) { + m_fs = filesystem::get(p_origpath); + } + bool open_temp_file(service_ptr_t & p_out,abort_callback & p_abort) { + pfc::dynamic_assert(m_tempfile.is_empty()); + generate_temp_location_for_file(m_temppath,m_origpath,/*pfc::string_extension(m_origpath)*/ "tmp","retagging temporary file"); + service_ptr_t l_tempfile; + try { + openTempFile(l_tempfile, p_abort); + } catch(exception_io const &) {return false;} + p_out = m_tempfile = l_tempfile; + return true; + } + bool got_temp_file() const {return m_tempfile.is_valid();} + + // p_owner must be the only reference to open source file, it will be closed + reopened + //WARNING: if this errors out, it may leave caller with null file pointer; take appropriate measures not to crash in such cases + void finalize(service_ptr_t & p_owner,abort_callback & p_abort) { + if (m_tempfile.is_valid()) { + m_tempfile->flushFileBuffers_(p_abort); + + if (p_owner.is_valid()) { + try { + file::g_copy_creation_time(p_owner, m_tempfile, p_abort); + } catch (exception_io const &) {} + } + + m_tempfile.release(); + p_owner.release(); + handleFileMove(m_temppath, m_origpath, p_abort); + input_open_file_helper(p_owner,m_origpath,input_open_info_write,p_abort); + } + } + // Alternate finalizer without owner file object, caller takes responsibility for closing the source file before calling + void finalize_no_reopen( abort_callback & p_abort ) { + if (m_tempfile.is_valid()) { + m_tempfile->flushFileBuffers_(p_abort); + m_tempfile.release(); + handleFileMove(m_temppath, m_origpath, p_abort); + } + } + void handle_failure() throw() { + if (m_tempfile.is_valid()) { + m_tempfile.release(); + try { + retryOnSharingViolation( 1, fb2k::noAbort, [&] { + m_fs->remove(m_temppath, fb2k::noAbort); + } ); + } catch(...) {} + } + } +private: + void openTempFile(file::ptr & out, abort_callback & abort) { + out = m_fs->openWriteNew(m_temppath, abort, 1 ); + } + void handleFileMove(const char * from, const char * to, abort_callback & abort) { + PFC_ASSERT(m_fs->is_our_path(from)); + PFC_ASSERT(m_fs->is_our_path(to)); + FB2K_RETRY_FILE_MOVE(m_fs->replace_file(from, to, abort), abort, 10 ); + } + pfc::string8 m_origpath; + pfc::string8 m_temppath; + service_ptr_t m_tempfile; + filesystem::ptr m_fs; +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/text_file_loader.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/text_file_loader.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,120 @@ +#include "StdAfx.h" + +#include "text_file_loader.h" + +#include + +static const unsigned char utf8_header[3] = {0xEF,0xBB,0xBF}; + +namespace text_file_loader +{ + void write(const service_ptr_t & p_file,abort_callback & p_abort,const char * p_string,bool is_utf8) + { + p_file->seek(0,p_abort); + p_file->set_eof(p_abort); + if (is_utf8) + { + p_file->write_object(utf8_header,sizeof(utf8_header),p_abort); + p_file->write_object(p_string,strlen(p_string),p_abort); + } + else + { + pfc::stringcvt::string_ansi_from_utf8 bah(p_string); + p_file->write_object(bah,bah.length(),p_abort); + } + } + void read(const service_ptr_t & p_file, abort_callback & p_abort, pfc::string_base & p_out, bool & is_utf8) { + read_v2( p_file, p_abort, p_out, is_utf8, false ); + } + void read_v2(const service_ptr_t & p_file,abort_callback & p_abort,pfc::string_base & p_out,bool & is_utf8, bool forceUTF8) { + p_out.reset(); + p_file->reopen( p_abort ); + + pfc::array_t mem; + t_filesize size64; + size64 = p_file->get_size(p_abort); + if (size64 == filesize_invalid)//typically HTTP + { + pfc::string8 ansitemp; + t_size done; + enum { delta = 1024 * 64, max = 1024 * 512 }; + + is_utf8 = forceUTF8; + char temp[3]; + done = p_file->read(temp, 3, p_abort); + if (done != 3) + { + if (done > 0) { + if ( is_utf8 ) { + p_out.set_string( temp, done ); + } else { + p_out = pfc::stringcvt::string_utf8_from_ansi(temp, done); + } + + } + return; + } + if (!memcmp(utf8_header, temp, 3)) is_utf8 = true; + else if (is_utf8) p_out.add_string(temp,3); + else ansitemp.add_string(temp, 3); + + mem.set_size(delta); + + for(;;) + { + done = p_file->read(mem.get_ptr(),delta,p_abort); + if (done > 0) + { + if (is_utf8) p_out.add_string(mem.get_ptr(),done); + else ansitemp.add_string(mem.get_ptr(),done); + } + if (done < delta) break; + } + + if (!is_utf8) + { + p_out = pfc::stringcvt::string_utf8_from_ansi(ansitemp); + } + + return; + } + else + { + if (size64 > hardlimit_bytes) throw exception_io_data();//hard limit + t_size size = pfc::downcast_guarded(size64); + mem.set_size(size+1); + char * asdf = mem.get_ptr(); + p_file->read_object(asdf,size,p_abort); + asdf[size]=0; + if (size>=3 && !memcmp(utf8_header,asdf,3)) { + is_utf8 = true; + p_out.add_string(asdf+3); + } else if (forceUTF8) { + is_utf8 = true; + p_out = asdf; + } else { + is_utf8 = false; + p_out = pfc::stringcvt::string_utf8_from_ansi(asdf); + } + return; + } + } + + void write(const char * p_path,abort_callback & p_abort,const char * p_string,bool is_utf8) + { + service_ptr_t f; + filesystem::g_open_write_new(f,p_path,p_abort); + write(f,p_abort,p_string,is_utf8); + } + + void read(const char * p_path, abort_callback & p_abort, pfc::string_base & p_out, bool & is_utf8) { + read_v2( p_path, p_abort, p_out, is_utf8, false ); + } + void read_v2(const char * p_path,abort_callback & p_abort,pfc::string_base & p_out,bool & is_utf8, bool forceUTF8) + { + service_ptr_t f; + filesystem::g_open_read(f,p_path,p_abort); + read_v2(f,p_abort,p_out,is_utf8,forceUTF8); + } + +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/text_file_loader.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/text_file_loader.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,16 @@ +#pragma once + +namespace text_file_loader +{ + constexpr size_t hardlimit_bytes = 1024 * 1024 * 128; + + void write(const service_ptr_t & p_file,abort_callback & p_abort,const char * p_string,bool is_utf8); + void read(const service_ptr_t & p_file,abort_callback & p_abort,pfc::string_base & p_out,bool & is_utf8); + void read_v2(const service_ptr_t & p_file, abort_callback & p_abort, pfc::string_base & p_out, bool & is_utf8, bool forceUTF8); + + + void write(const char * p_path,abort_callback & p_abort,const char * p_string,bool is_utf8); + void read(const char * p_path,abort_callback & p_abort,pfc::string_base & p_out,bool & is_utf8); + void read_v2(const char * p_path, abort_callback & p_abort, pfc::string_base & p_out, bool & is_utf8, bool forceUTF8); + +}; \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/text_file_loader_v2.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/text_file_loader_v2.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,25 @@ +#include "StdAfx.h" +#include "text_file_loader_v2.h" +#include "text_file_loader.h" + +void text_file_loader_v2::load(file::ptr f, abort_callback & abort) { + m_lines.clear(); + bool dummy; + text_file_loader::read_v2(f, abort, m_data, dummy, m_forceUTF8); + + m_lines.reserve(128); + + char * p = const_cast(m_data.get_ptr()); + bool line = false; + const size_t len = m_data.length(); + for (size_t walk = 0; walk < len; ++walk) { + char & c = p[walk]; + if (c == '\n' || c == '\r') { + c = 0; + line = false; + } else if (!line) { + m_lines.push_back(&c); + line = true; + } + } +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/text_file_loader_v2.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/text_file_loader_v2.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,14 @@ +#pragma once +#include +#include + +class text_file_loader_v2 { +public: + bool m_forceUTF8 = false; + + void load(file::ptr f, abort_callback & abort); + + std::vector< char * > m_lines; + + pfc::string8 m_data; +}; \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/track_property_callback_impl.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/track_property_callback_impl.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,202 @@ +#include "StdAfx.h" + +#include +#include + +#include "track_property_callback_impl.h" +#include +#include + +void track_property_callback_impl::set_property(const char * p_group, double p_sortpriority, const char * p_name, const char * p_value) { + propertyname_container temp; + temp.m_name = p_name; + temp.m_priority = p_sortpriority; + + pfc::string8 fixEOL; + if (m_cutMultiLine && strchr(p_value, '\n') != nullptr) { + fixEOL = p_value; fixEOL.fix_eol(); p_value = fixEOL; + } + + m_entries.find_or_add(p_group).set(temp, p_value); +} + +bool track_property_callback_impl::is_group_wanted(const char * p_group) { + if (m_groupFilter) return m_groupFilter(p_group); + return true; +} + +void track_property_callback_impl::merge(track_property_callback_impl const & other) { + for (auto iterGroup = other.m_entries.first(); iterGroup.is_valid(); ++iterGroup) { + auto & in = iterGroup->m_value; + auto & out = m_entries[iterGroup->m_key]; + for (auto iterEntry = in.first(); iterEntry.is_valid(); ++iterEntry) { + out.set(iterEntry->m_key, iterEntry->m_value); + } + } +} + +static bool is_filtered_info_field(const char * p_name) { + for (auto ptr : track_property_provider::enumerate()) { + if (ptr->is_our_tech_info(p_name)) return true; + } + return false; +} + +static const char strGroupOther[] = "Other"; + +static pfc::string8 encloseInfoName(const char* name) { + pfc::string8 temp; + temp << "<"; + uAddStringUpper(temp, name); + temp << ">"; + return temp; +} + +static void enumOtherHere(track_property_callback_impl & callback, metadb_info_container::ptr info_) { + if (info_.is_empty()) return; + const file_info * infoptr = &info_->info(); + for (t_size n = 0, m = infoptr->info_get_count(); n < m; n++) { + const char * name = infoptr->info_enum_name(n); + if (!is_filtered_info_field(name)) { + callback.set_property(strGroupOther, 0, encloseInfoName(name), infoptr->info_enum_value(n)); + } + } +} + +static trackInfoContainer::ptr getInfoHelper(track_property_provider_v3_info_source* source, size_t idx) { + return source->get_info(idx); +} + +static trackInfoContainer::ptr getInfoHelper(track_property_provider_v5_info_source* source, size_t idx) { + return source->get_info(idx).info; +} + +template +static void enumOther( track_property_callback_impl & callback, metadb_handle_list_cref items, infoSource_t* infoSource ) { + + const size_t itemCount = items.get_count(); + if (itemCount == 1 ) { + enumOtherHere(callback, getInfoHelper(infoSource,0) ); + return; + } + + typedef file_info::field_name_comparator field_name_comparator_t; + typedef pfc::comparator_stricmp_ascii value_comparator_t; + + typedef pfc::avltree_t< pfc::string8, field_name_comparator_t > field_mask_t; + + struct stats_t { + size_t count = 0; + double totalDuration = 0; + }; + typedef pfc::map_t field_results_t; + typedef pfc::map_t results_t; + results_t results; + + field_mask_t fieldsIgnore, fieldsUse; + bool useDuration = true; + double totalDuration = 0; + + for (size_t itemWalk = 0; itemWalk < itemCount; ++itemWalk) { + auto info_ = getInfoHelper(infoSource, itemWalk); + if (info_.is_empty()) continue; + const file_info * infoptr = &info_->info(); + const size_t numInfo = infoptr->info_get_count(); + const double duration = infoptr->get_length(); + if (duration > 0) totalDuration += duration; + else useDuration = false; + for (size_t infoWalk = 0; infoWalk < numInfo; ++infoWalk) { + const char * name = infoptr->info_enum_name(infoWalk); + if ( fieldsIgnore.contains( name )) continue; + if (!fieldsUse.contains(name)) { + const bool bUse = !is_filtered_info_field( name ); + if ( bUse ) fieldsUse += name; + else { fieldsIgnore += name; continue; } + } + + const char * value = infoptr->info_enum_value(infoWalk); + auto & stats = results[name][value]; + ++ stats.count; + if ( duration > 0 ) { + stats.totalDuration += duration; + } + } + } + + for (auto iter = results.first(); iter.is_valid(); ++iter) { + const auto key = encloseInfoName(iter->m_key); + pfc::string8 out; + if (iter->m_value.get_count() == 1 && iter->m_value.first()->m_value.count == itemCount) { + out = iter->m_value.first()->m_key; + } else { + for (auto iterValue = iter->m_value.first(); iterValue.is_valid(); ++iterValue) { + double percentage; + if ( useDuration ) percentage = iterValue->m_value.totalDuration / totalDuration; + else percentage = (double) iterValue->m_value.count / (double) itemCount; + if (!out.is_empty()) out << "; "; + out << iterValue->m_key << " (" << pfc::format_fixedpoint( pfc::rint64( percentage * 1000.0), 1) << "%)"; + } + } + callback.set_property(strGroupOther, 0, key, out); + } +} + +template static void enumerateTrackProperties_(track_property_callback_impl& callback, std::function< metadb_handle_list_cref() > itemsSource, source_t infoSource, std::function abortSource) { + if (core_api::is_main_thread()) { + // should not get here like this + // but that does make our job easier + auto& items = itemsSource(); + auto info = infoSource(); + for (auto ptr : track_property_provider::enumerate()) { + ptr->enumerate_properties_helper(items, info, callback, abortSource()); + } + if (callback.is_group_wanted(strGroupOther)) { + enumOther(callback, items, info); + } + return; + } + + std::list > lstWaitFor; + std::list > lstMerge; + for (auto ptr : track_property_provider::enumerate()) { + auto evt = std::make_shared(); + auto cb = std::make_shared< track_property_callback_impl >(callback); // clone watched group info + auto work = [ptr, itemsSource, evt, cb, infoSource, abortSource] { + try { + ptr->enumerate_properties_helper(itemsSource(), infoSource(), *cb, abortSource()); + } catch (...) {} + evt->set_state(true); + }; + + track_property_provider_v4::ptr v4; + if (v4 &= ptr) { + // Supports v4 = split a worker thread, work in parallel + fb2k::inCpuWorkerThread(work); + } else { + // No v4 = delegate to main thread. Ugly but gets the job done. + fb2k::inMainThread(work); + } + + lstWaitFor.push_back(std::move(evt)); + lstMerge.push_back(std::move(cb)); + } + + if (callback.is_group_wanted(strGroupOther)) { + enumOther(callback, itemsSource(), infoSource()); + } + + for (auto& i : lstWaitFor) { + abortSource().waitForEvent(*i, -1); + } + for (auto& i : lstMerge) { + callback.merge(*i); + } +} + +void enumerateTrackProperties(track_property_callback_impl& callback, std::function< metadb_handle_list_cref() > itemsSource, std::function infoSource, std::function abortSource) { + enumerateTrackProperties_(callback, itemsSource, infoSource, abortSource); +} + +void enumerateTrackProperties_v5(track_property_callback_impl& callback, std::function< metadb_handle_list_cref() > itemsSource, std::function infoSource, std::function abortSource) { + enumerateTrackProperties_(callback, itemsSource, infoSource, abortSource); +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/track_property_callback_impl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/track_property_callback_impl.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,53 @@ +#pragma once + +#include +#include + +class groupname_comparator { +public: + static int compare(pfc::stringp p_name1,pfc::stringp p_name2) { + int temp = uStringCompare(p_name1,p_name2); + if (temp != 0) return temp; + return strcmp(p_name1,p_name2); + } +}; + +struct propertyname_container { + pfc::string m_name; + double m_priority; +}; + +class propertyname_comparator { +public: + static int compare(const propertyname_container & p_item1,const propertyname_container & p_item2) { + int state = pfc::compare_t(p_item1.m_priority,p_item2.m_priority); + if (state != 0) return state; + return uStringCompare(p_item1.m_name.ptr(),p_item2.m_name.ptr()); + } +}; + +typedef pfc::map_t property_group; + +typedef pfc::map_t t_property_group_list; + +class track_property_callback_impl : public track_property_callback_v2 { +public: + void set_property(const char * p_group,double p_sortpriority,const char * p_name,const char * p_value) override; + bool is_group_wanted(const char * p_group) override; + + void merge( track_property_callback_impl const & other ); + + t_property_group_list m_entries; + + bool m_cutMultiLine = false; + typedef std::function groupFilter_t; + groupFilter_t m_groupFilter; +}; + +// Helper function to walk all track property providers in an optimized multithread manner +// Various *source arguments have been std::function'd so you can reference your own data structures gracefully +// If the function is aborted, it returns immediately - while actual worker threads may not yet have completed, and may still reference *source arguments. +// You must ensure - by means of std::shared_ptr<> or such - that all of the *source arguments remain accessible even after enumerateTrackProperties() returns, until the std::functions are released. +// Legacy track property providers that do not support off main thread operation will be invoked via main_thread_callback in main thread, and the function will stall until they have returned (unless aborted). +void enumerateTrackProperties(track_property_callback_impl & callback, std::function< metadb_handle_list_cref() > itemsSource, std::function infoSource, std::function abortSource); +void enumerateTrackProperties_v5(track_property_callback_impl& callback, std::function< metadb_handle_list_cref() > itemsSource, std::function infoSource, std::function abortSource); diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/ui_element_helpers.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/ui_element_helpers.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,389 @@ +#include "stdafx.h" + +#if FOOBAR2000_TARGET_VERSION >= 79 + +#include "ui_element_helpers.h" +#include +#include "atl-misc.h" + +namespace ui_element_helpers { + + ui_element_instance_ptr instantiate_dummy(HWND p_parent,ui_element_config::ptr cfg, ui_element_instance_callback_ptr p_callback) { + service_ptr_t ptr; + if (!find(ptr,pfc::guid_null)) uBugCheck(); + return ptr->instantiate(p_parent,cfg,p_callback); + } + ui_element_instance_ptr instantiate(HWND p_parent,ui_element_config::ptr cfg,ui_element_instance_callback_ptr p_callback) { + try { + service_ptr_t ptr; + if (!find(ptr,cfg->get_guid())) throw exception_io_data("UI Element Not Found"); + auto ret = ptr->instantiate(p_parent,cfg,p_callback); + if (ret.is_empty()) throw std::runtime_error("Null UI Element returned"); + return ret; + } catch(std::exception const & e) { + console::complain("UI Element instantiation failure",e); + return instantiate_dummy(p_parent,cfg,p_callback); + } + } + + ui_element_instance_ptr update(ui_element_instance_ptr p_element,HWND p_parent,ui_element_config::ptr cfg,ui_element_instance_callback_ptr p_callback) { + if (p_element.is_valid() && cfg->get_guid() == p_element->get_guid()) { + p_element->set_configuration(cfg); + return p_element; + } else { + return instantiate(p_parent,cfg,p_callback); + } + } + + bool find(service_ptr_t & p_out,const GUID & p_guid) { + return service_by_guid(p_out,p_guid); + } + + ui_element_children_enumerator_ptr enumerate_children(ui_element_config::ptr cfg) { + service_ptr_t ptr; + if (!find(ptr,cfg->get_guid())) return NULL; + try { + return ptr->enumerate_children(cfg); + } catch(exception_io_data const &) { + return NULL; + } + } +}; + +void ui_element_helpers::replace_with_new_element(ui_element_instance_ptr & p_item,const GUID & p_guid,HWND p_parent,ui_element_instance_callback_ptr p_callback) { + ui_element_config::ptr cfg; + try { + if (p_item.is_empty()) { + service_ptr_t ptr; + if (!find(ptr,p_guid)) throw exception_io_data("UI Element Not Found"); + cfg = ptr->get_default_configuration(); + p_item = ptr->instantiate(p_parent,cfg,p_callback); + } else if (p_item->get_guid() != p_guid) { + service_ptr_t ptr; + if (!find(ptr,p_guid)) throw exception_io_data("UI Element Not Found"); + cfg = ptr->import(p_item->get_configuration()); + //p_item.release(); + if (cfg.is_empty()) cfg = ptr->get_default_configuration(); + p_item = ptr->instantiate(p_parent,cfg,p_callback); + } + } catch(std::exception const & e) { + console::complain("UI Element instantiation failure",e); + if (cfg.is_empty()) cfg = ui_element_config::g_create_empty(); + p_item = instantiate_dummy(p_parent,cfg,p_callback); + } +} + + + +namespace { + class CMyMenuSelectionReceiver : public CMenuSelectionReceiver { + public: + CMyMenuSelectionReceiver(HWND p_wnd,ui_element_helpers::ui_element_edit_tools * p_host,ui_element_instance_ptr p_client,unsigned p_client_id,unsigned p_host_base,unsigned p_client_base) : CMenuSelectionReceiver(p_wnd), m_host(p_host), m_client(p_client), m_client_id(p_client_id), m_host_base(p_host_base), m_client_base(p_client_base) {} + bool QueryHint(unsigned p_id,pfc::string_base & p_out) { + if (p_id >= m_client_base) { + return m_client->edit_mode_context_menu_get_description(p_id,m_client_base,p_out); + } else if (p_id >= m_host_base) { + return m_host->host_edit_mode_context_menu_get_description(m_client_id,p_id,m_host_base,p_out); + } else { + const char * msg = ui_element_helpers::ui_element_edit_tools::description_from_menu_command(p_id); + if (msg == NULL) return false; + p_out = msg; + return true; + } + } + private: + ui_element_helpers::ui_element_edit_tools * const m_host; + ui_element_instance_ptr const m_client; + unsigned const m_client_id,m_host_base,m_client_base; + }; +}; + +namespace HostHelperIDs { + enum {ID_LABEL, ID_REPLACE = 1, ID_ADD_NEW, ID_CUT, ID_COPY, ID_PASTE, ID_CUSTOM_BASE}; +} + +void ui_element_helpers::ui_element_edit_tools::standard_edit_context_menu(LPARAM p_point,ui_element_instance_ptr p_item,unsigned p_id,HWND p_parent) { + using namespace HostHelperIDs; + static_api_ptr_t api; + POINT pt; + bool fromkeyboard = false; + if (p_point == (LPARAM)(-1)) { + fromkeyboard = true; + if (!p_item->edit_mode_context_menu_get_focus_point(pt)) { + CRect rect; + WIN32_OP_D( CWindow(p_item->get_wnd()).GetWindowRect(&rect) ); + pt = rect.CenterPoint(); + } + } else { + pt.x = (short)LOWORD(p_point); + pt.y = (short)HIWORD(p_point); + } + + CMenu menu; + WIN32_OP_D( menu.CreatePopupMenu() ); + + const GUID sourceItemGuid = p_item->get_guid(); + const bool sourceItemEmpty = !!(sourceItemGuid == pfc::guid_null); + + if (sourceItemEmpty) { + WIN32_OP_D( menu.AppendMenu(MF_STRING,ID_ADD_NEW,TEXT(AddNewUIElementCommand)) ); + WIN32_OP_D( menu.SetMenuDefaultItem(ID_ADD_NEW) ); + } else { + service_ptr_t elem; + pfc::string8 name; + if (find(elem,sourceItemGuid)) { + elem->get_name(name); + } else { + name = ""; + } + WIN32_OP_D( menu.AppendMenu(MF_STRING | MF_DISABLED,ID_LABEL,pfc::stringcvt::string_os_from_utf8(name)) ); + WIN32_OP_D( menu.AppendMenu(MF_SEPARATOR,(UINT_PTR)0,TEXT("")) ); + WIN32_OP_D( menu.AppendMenu(MF_STRING,ID_REPLACE,TEXT(ReplaceUIElementCommand)) ); + } + WIN32_OP_D( menu.AppendMenu(MF_SEPARATOR,(UINT_PTR)0,TEXT("")) ); + + //menu.AppendMenu(MF_STRING,ID_REPLACE,TEXT(ReplaceUIElementCommand)); + WIN32_OP_D( menu.AppendMenu(MF_STRING | (sourceItemEmpty ? (MF_DISABLED|MF_GRAYED) : 0),ID_CUT,TEXT(CutUIElementCommand)) ); + WIN32_OP_D( menu.AppendMenu(MF_STRING | (sourceItemEmpty ? (MF_DISABLED|MF_GRAYED) : 0),ID_COPY,TEXT(CopyUIElementCommand)) ); + WIN32_OP_D( menu.AppendMenu(MF_STRING | (api->is_paste_available() ? 0 : (MF_DISABLED|MF_GRAYED)),ID_PASTE,TEXT(PasteUIElementCommand)) ); + + unsigned custom_walk = ID_CUSTOM_BASE; + unsigned custom_base_host = ~0, custom_base_client = ~0; + + if (host_edit_mode_context_menu_test(p_id,pt,fromkeyboard)) { + menu.AppendMenu(MF_SEPARATOR,(UINT_PTR)0,TEXT("")); + custom_base_host = custom_walk; + host_edit_mode_context_menu_build(p_id,pt,fromkeyboard,menu,custom_walk); + } + + { + if (p_item->edit_mode_context_menu_test(pt,fromkeyboard)) { + WIN32_OP_D( menu.AppendMenu(MF_SEPARATOR,(UINT_PTR)0,TEXT("")) ); + custom_base_client = custom_walk; + p_item->edit_mode_context_menu_build(pt,fromkeyboard,menu,custom_walk); + } + } + int cmd; + + { + ui_element_highlight_scope s(p_item->get_wnd()); + CMyMenuSelectionReceiver receiver(p_parent,this,p_item,p_id,custom_base_host,custom_base_client); + cmd = menu.TrackPopupMenu(TPM_RIGHTBUTTON|TPM_NONOTIFY|TPM_RETURNCMD,pt.x,pt.y,receiver); + } + + if (cmd > 0) { + switch(cmd) { + case ID_REPLACE: + case ID_ADD_NEW: + replace_dialog(p_item->get_wnd(),p_id,p_item->get_guid()); + break; + case ID_COPY: + api->copy(p_item); + break; + case ID_CUT: + api->copy(p_item); + p_item.release(); + host_replace_element(p_id,pfc::guid_null); + break; + case ID_PASTE: + host_paste_element(p_id); + break; + default: + if ((unsigned)cmd >= custom_base_client) { + p_item->edit_mode_context_menu_command(pt,fromkeyboard,(unsigned)cmd,custom_base_client); + } else if ((unsigned)cmd >= custom_base_host) { + host_edit_mode_context_menu_command(p_id,pt,fromkeyboard,(unsigned)cmd,custom_base_host); + } + break; + } + } +} + +void ui_element_helpers::ui_element_edit_tools::on_elem_replace(unsigned p_id, GUID const & newGuid) { + m_replace_dialog.Detach(); + + if ( newGuid != pfc::guid_null ) { + host_replace_element(p_id,newGuid); + } +} + +void ui_element_helpers::ui_element_edit_tools::replace_dialog(HWND p_parent,unsigned p_id,const GUID & p_current) { + _release_replace_dialog(); + + auto ks = m_killSwitch; + + auto reply = ui_element_replace_dialog_notify::create( [=] ( GUID newGUID ) { + if ( !*ks) { + on_elem_replace(p_id, newGUID ); + } + } ); + + HWND dlg = ui_element_common_methods_v3::get()->replace_element_dialog_start( p_parent, p_current, reply ); + + m_replace_dialog.Attach( dlg ); +} + +const char * ui_element_helpers::ui_element_edit_tools::description_from_menu_command(unsigned p_id) { + using namespace HostHelperIDs; + switch(p_id) { + case ID_REPLACE: + return ReplaceUIElementDescription; + case ID_CUT: + return CutUIElementDescription; + case ID_COPY: + return CopyUIElementDescription; + case ID_PASTE: + return PasteUIElementDescription; + case ID_ADD_NEW: + return AddNewUIElementDescription; + default: + return NULL; + } +} + +void ui_element_helpers::ui_element_edit_tools::_release_replace_dialog() { + if (m_replace_dialog.m_hWnd != NULL) { + m_replace_dialog.DestroyWindow(); + } +} + +bool ui_element_helpers::enforce_min_max_info(CWindow p_window,ui_element_min_max_info const & p_info) { + CRect rect; + WIN32_OP_D( p_window.GetWindowRect(&rect) ); + t_uint32 width = (t_uint32) rect.Width(); + t_uint32 height = (t_uint32) rect.Height(); + bool changed = false; + if (width < p_info.m_min_width) {changed = true; width = p_info.m_min_width;} + if (width > p_info.m_max_width) {changed = true; width = p_info.m_max_width;} + if (height < p_info.m_min_height) {changed = true; height = p_info.m_min_height;} + if (height > p_info.m_max_height) {changed = true; height = p_info.m_max_height;} + if (changed) { + WIN32_OP_D( p_window.SetWindowPos(NULL,0,0,width,height,SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER) ); + } + return changed; +} + + + +void ui_element_helpers::handle_WM_GETMINMAXINFO(LPARAM p_lp,const ui_element_min_max_info & p_myinfo) { + MINMAXINFO * info = reinterpret_cast(p_lp); + /*console::formatter() << "handle_WM_GETMINMAXINFO"; + console::formatter() << p_myinfo.m_min_width << ", " << p_myinfo.m_min_height; + console::formatter() << info->ptMinTrackSize << ", " << info->ptMaxTrackSize;*/ + pfc::max_acc(info->ptMinTrackSize.x,(LONG)p_myinfo.m_min_width); + pfc::max_acc(info->ptMinTrackSize.y,(LONG)p_myinfo.m_min_height); + if ((LONG) p_myinfo.m_max_width >= 0) pfc::min_acc(info->ptMaxTrackSize.x, (LONG) p_myinfo.m_max_width); + if ((LONG) p_myinfo.m_max_height >= 0) pfc::min_acc(info->ptMaxTrackSize.y, (LONG) p_myinfo.m_max_height); + //console::formatter() << info->ptMinTrackSize << ", " << info->ptMaxTrackSize; +} + +bool ui_element_helpers::ui_element_edit_tools::host_paste_element(unsigned p_id) { + pfc::com_ptr_t obj; + if (SUCCEEDED(OleGetClipboard(obj.receive_ptr()))) { + DWORD effect; + ui_element_config::ptr cfg; + if (static_api_ptr_t()->parse_dataobject(obj,cfg,effect)) { + host_replace_element(p_id, cfg); + IDataObjectUtils::SetDataObjectDWORD(obj, RegisterClipboardFormat(CFSTR_PERFORMEDDROPEFFECT), effect); + IDataObjectUtils::PasteSucceeded(obj,effect); + if (effect == DROPEFFECT_MOVE) OleSetClipboard(NULL); + return true; + } + } + return false; +} + + +bool ui_element_helpers::recurse_for_elem_config(ui_element_config::ptr root, ui_element_config::ptr & out, const GUID & toFind) { + const GUID rootID = root->get_guid(); + if (rootID == toFind) { + out = root; return true; + } + ui_element::ptr elem; + if (!find(elem, rootID)) return false; + ui_element_children_enumerator::ptr children; + try { + children = elem->enumerate_children(root); + } catch(exception_io_data const &) {return false;} + if (children.is_empty()) return false; + const t_size childrenTotal = children->get_count(); + for(t_size walk = 0; walk < childrenTotal; ++walk) { + if (recurse_for_elem_config(children->get_item(walk), out, toFind)) return true; + } + return false; +} + +bool ui_element_helpers::ui_element_instance_host_base::grabTopPriorityVisibleChild(ui_element_instance_ptr & out, t_size & outWhich, double & outPriority) { + double bestPriority = 0; + ui_element_instance_ptr best; + t_size bestWhich = ~0; + const t_size count = host_get_children_count(); + for (t_size walk = 0; walk < count; ++walk) if (this->host_is_child_visible(walk) ) { + ui_element_instance_ptr item = host_get_child(walk); + if (item.is_valid() ) { + const double priority = item->get_focus_priority(); + if (best.is_empty() || childPriorityCompare(walk, priority, bestPriority)) { + best = item; bestPriority = priority; bestWhich = walk; + } + } + } + if (best.is_empty()) return false; + out = best; outPriority = bestPriority; outWhich = bestWhich; return true; +} +bool ui_element_helpers::ui_element_instance_host_base::grabTopPriorityChild(ui_element_instance_ptr & out, t_size & outWhich, double & outPriority, const GUID & subclass) { + double bestPriority = 0; + ui_element_instance_ptr best; + t_size bestWhich = ~0; + const t_size count = host_get_children_count(); + for (t_size walk = 0; walk < count; ++walk) { + ui_element_instance_ptr item = host_get_child(walk); + if (item.is_valid()) { + double priority; + if (item->get_focus_priority_subclass(priority, subclass)) { + if (best.is_empty() || childPriorityCompare(walk, priority, bestPriority)) { + best = item; bestPriority = priority; bestWhich = walk; + } + } + } + } + if (best.is_empty()) return false; + out = best; outPriority = bestPriority; outWhich = bestWhich; return true; +} + +void ui_element_instance_standard_context_menu(service_ptr_t p_elem, LPARAM p_pt) { + CPoint pt; + bool fromKeyboard; + if (p_pt == -1) { + fromKeyboard = true; + if (!p_elem->edit_mode_context_menu_get_focus_point(pt)) { + CRect rc; + WIN32_OP_D(GetWindowRect(p_elem->get_wnd(), rc)); + pt = rc.CenterPoint(); + } + } else { + fromKeyboard = false; + pt = p_pt; + } + if (p_elem->edit_mode_context_menu_test(pt, fromKeyboard)) { + const unsigned idBase = 1; + CMenu menu; + WIN32_OP_D(menu.CreatePopupMenu()); + p_elem->edit_mode_context_menu_build(pt, fromKeyboard, menu, idBase); + + int cmd; + { + CMenuSelectionReceiver_UiElement receiver(p_elem, idBase); + cmd = menu.TrackPopupMenu(TPM_RIGHTBUTTON | TPM_NONOTIFY | TPM_RETURNCMD, pt.x, pt.y, receiver); + } + if (cmd > 0) p_elem->edit_mode_context_menu_command(pt, fromKeyboard, cmd, idBase); + } +} +void ui_element_instance_standard_context_menu_eh(service_ptr_t p_elem, LPARAM p_pt) { + try { + ui_element_instance_standard_context_menu(p_elem, p_pt); + } catch (std::exception const & e) { + console::complain("Context menu failure", e); + } +} + +#endif // FOOBAR2000_TARGET_VERSION >= 79 diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/ui_element_helpers.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/ui_element_helpers.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,382 @@ +#pragma once +#include + +#ifdef _WIN32 + +// ==================================================================================================== +// ui_element_helpers +// A framework for creating UI Elements that host other elements. +// All foo_ui_std elements that host other elements - such as splitters or tabs - are based on this. +// Note that API 79 (v1.4) or newer is required, earlier did not provide ui_element_common_methods_v3. +// ==================================================================================================== + +#if FOOBAR2000_TARGET_VERSION >= 79 + +#include +#include + +namespace ui_element_helpers { + template class ui_element_instance_callback_multi_impl : public ui_element_instance_callback_v3 { + public: + ui_element_instance_callback_multi_impl(t_size id, t_receiver * p_receiver) : m_receiver(p_receiver), m_id(id) {} + void on_min_max_info_change() { + if (m_receiver != NULL) m_receiver->on_min_max_info_change(); + } + bool query_color(const GUID & p_what,t_ui_color & p_out) { + if (m_receiver != NULL) return m_receiver->query_color(p_what,p_out); + else return false; + } + + bool request_activation(service_ptr_t p_item) { + if (m_receiver) return m_receiver->request_activation(m_id); + else return false; + } + + bool is_edit_mode_enabled() { + if (m_receiver) return m_receiver->is_edit_mode_enabled(); + else return false; + } + void request_replace(service_ptr_t p_item) { + if (m_receiver) m_receiver->request_replace(m_id); + } + + t_ui_font query_font_ex(const GUID & p_what) { + if (m_receiver) return m_receiver->query_font_ex(p_what); + else return NULL; + } + + t_size notify(ui_element_instance * source, const GUID & what, t_size param1, const void * param2, t_size param2size) { + if (m_receiver) return m_receiver->host_notify(source, what, param1, param2, param2size); + else return 0; + } + void orphan() {m_receiver = NULL;} + + bool is_elem_visible(service_ptr_t elem) { + if (m_receiver) return m_receiver->is_elem_visible(m_id); + else return false; + } + + void override_id(t_size id) {m_id = id;} + + void on_alt_pressed(bool) {} + private: + t_size m_id; + t_receiver * m_receiver; + }; + class ui_element_instance_callback_receiver_multi { + public: + virtual void on_min_max_info_change() {} + virtual bool query_color(const GUID & p_what,t_ui_color & p_out) {return false;} + virtual bool request_activation(t_size which) {return false;} + virtual bool is_edit_mode_enabled() {return false;} + virtual void request_replace(t_size which) {} + virtual t_ui_font query_font_ex(const GUID&) {return NULL;} + virtual bool is_elem_visible(t_size which) {return true;} + virtual t_size host_notify(ui_element_instance * source, const GUID & what, t_size param1, const void * param2, t_size param2size) {return 0;} + + void ui_element_instance_callback_handle_remove(bit_array const & mask, t_size const oldCount) { + t_callback_list newCallbacks; + t_size newWalk = 0; + for(t_size walk = 0; walk < oldCount; ++walk) { + if (mask[walk]) { + t_callback_ptr ptr; + if (m_callbacks.query(walk,ptr)) { + ptr->orphan(); m_callbacks.remove(walk); + } + } else { + if (newWalk != walk) { + t_callback_ptr ptr; + if (m_callbacks.query(walk,ptr)) { + m_callbacks.remove(walk); + ptr->override_id(newWalk); + m_callbacks.set(newWalk,ptr); + } + } + ++newWalk; + } + } + } + + void ui_element_instance_callback_handle_reorder(const t_size * order, t_size count) { + t_callback_list newCallbacks; + for(t_size walk = 0; walk < count; ++walk) { + t_callback_ptr ptr; + if (m_callbacks.query(order[walk],ptr)) { + ptr->override_id(walk); + newCallbacks.set(walk,ptr); + m_callbacks.remove(order[walk]); + } + } + + PFC_ASSERT( m_callbacks.get_count() == 0 ); + ui_element_instance_callback_release_all(); + + m_callbacks = newCallbacks; + } + + ui_element_instance_callback_ptr ui_element_instance_callback_get_ptr(t_size which) { + t_callback_ptr ptr; + if (!m_callbacks.query(which,ptr)) { + ptr = new service_impl_t(which,this); + m_callbacks.set(which,ptr); + } + return ptr; + } + ui_element_instance_callback_ptr ui_element_instance_callback_create(t_size which) { + ui_element_instance_callback_release(which); + t_callback_ptr ptr = new service_impl_t(which,this); + m_callbacks.set(which,ptr); + return ptr; + } + void ui_element_instance_callback_release_all() { + for(t_callback_list::const_iterator walk = m_callbacks.first(); walk.is_valid(); ++walk) { + walk->m_value->orphan(); + } + m_callbacks.remove_all(); + } + void ui_element_instance_callback_release(t_size which) { + t_callback_ptr ptr; + if (m_callbacks.query(which,ptr)) { + ptr->orphan(); + m_callbacks.remove(which); + } + } + protected: + ~ui_element_instance_callback_receiver_multi() { + ui_element_instance_callback_release_all(); + } + ui_element_instance_callback_receiver_multi() {} + + private: + typedef ui_element_instance_callback_receiver_multi t_self; + typedef ui_element_instance_callback_multi_impl t_callback; + typedef service_ptr_t t_callback_ptr; + typedef pfc::map_t t_callback_list; + t_callback_list m_callbacks; + }; + + + //! Parses container tree to find configuration of specified element inside a layout configuration. + bool recurse_for_elem_config(ui_element_config::ptr root, ui_element_config::ptr & out, const GUID & toFind); + + ui_element_instance_ptr create_root_container(HWND p_parent,ui_element_instance_callback_ptr p_callback); + ui_element_instance_ptr instantiate(HWND p_parent,ui_element_config::ptr cfg,ui_element_instance_callback_ptr p_callback); + ui_element_instance_ptr instantiate_dummy(HWND p_parent,ui_element_config::ptr cfg,ui_element_instance_callback_ptr p_callback); + ui_element_instance_ptr update(ui_element_instance_ptr p_element,HWND p_parent,ui_element_config::ptr cfg,ui_element_instance_callback_ptr p_callback); + bool find(service_ptr_t & p_out,const GUID & p_guid); + ui_element_children_enumerator_ptr enumerate_children(ui_element_config::ptr cfg); + + void replace_with_new_element(ui_element_instance_ptr & p_item,const GUID & p_guid,HWND p_parent,ui_element_instance_callback_ptr p_callback); + + class ui_element_highlight_scope { + public: + ui_element_highlight_scope(HWND wndElem) { + m_highlight = ui_element_common_methods_v3::get()->highlight_element( wndElem ); + } + ~ui_element_highlight_scope() { + DestroyWindow(m_highlight); + } + private: + ui_element_highlight_scope(const ui_element_highlight_scope&) = delete; + void operator=(const ui_element_highlight_scope&) = delete; + HWND m_highlight; + }; + + //! Helper class; provides edit-mode context menu functionality and interacts with "Replace UI Element" dialog. \n + //! Do not use directly - derive from ui_element_instance_host_base instead. + class ui_element_edit_tools { + public: + //! Override me + virtual void host_replace_element(unsigned p_id, ui_element_config::ptr cfg) {} + //! Override me + virtual void host_replace_element(unsigned p_id,const GUID & p_newguid) {} + + //! Override me optionally if you customize edit mode context menu + virtual bool host_edit_mode_context_menu_test(unsigned p_childid,const POINT & p_point,bool p_fromkeyboard) {return false;} + //! Override me optionally if you customize edit mode context menu + virtual void host_edit_mode_context_menu_build(unsigned p_childid,const POINT & p_point,bool p_fromkeyboard,HMENU p_menu,unsigned & p_id_base) {} + //! Override me optionally if you customize edit mode context menu + virtual void host_edit_mode_context_menu_command(unsigned p_childid,const POINT & p_point,bool p_fromkeyboard,unsigned p_id,unsigned p_id_base) {} + //! Override me optionally if you customize edit mode context menu + virtual bool host_edit_mode_context_menu_get_description(unsigned p_childid,unsigned p_id,unsigned p_id_base,pfc::string_base & p_out) {return false;} + + //! Initiates "Replace UI Element" dialog for one of your sub-elements. + void replace_dialog(HWND p_parent,unsigned p_id,const GUID & p_current); + + //! Shows edit mode context menu for your element. + void standard_edit_context_menu(LPARAM p_point,ui_element_instance_ptr p_item,unsigned p_id,HWND p_parent); + + static const char * description_from_menu_command(unsigned p_id); + + bool host_paste_element(unsigned p_id); + + BEGIN_MSG_MAP(ui_element_edit_tools) + MESSAGE_HANDLER(WM_DESTROY,OnDestroy) + END_MSG_MAP() + protected: + ui_element_edit_tools() {} + private: + void on_elem_replace(unsigned p_id,GUID const & newElem); + void _release_replace_dialog(); + LRESULT OnDestroy(UINT,WPARAM,LPARAM,BOOL& bHandled) {bHandled = FALSE; *m_killSwitch = true; _release_replace_dialog(); return 0;} + + CWindow m_replace_dialog; + std::shared_ptr m_killSwitch = std::make_shared(); + + ui_element_edit_tools( const ui_element_edit_tools & ) = delete; + void operator=( const ui_element_edit_tools & ) = delete; + }; + + //! Base class for ui_element_instances that host other elements. + class ui_element_instance_host_base : public ui_element_instance, protected ui_element_instance_callback_receiver_multi, protected ui_element_edit_tools { + protected: + // Any derived class must pass their messages to us, by CHAIN_MSG_MAP(ui_element_instance_host_base) + BEGIN_MSG_MAP(ui_element_instance_host_base) + CHAIN_MSG_MAP(ui_element_edit_tools) + MESSAGE_HANDLER(WM_SETTINGCHANGE,OnSettingChange); + END_MSG_MAP() + + //override me + virtual ui_element_instance_ptr host_get_child(t_size which) = 0; + //override me + virtual t_size host_get_children_count() = 0; + //override me (tabs) + virtual void host_bring_to_front(t_size which) {} + //override me + virtual void on_min_max_info_change() {m_callback->on_min_max_info_change();} + //override me + virtual void host_replace_child(t_size which) = 0; + + virtual bool host_is_child_visible(t_size which) {return true;} + + void host_child_visibility_changed(t_size which, bool state) { + if (m_callback->is_elem_visible_(this)) { + ui_element_instance::ptr item = host_get_child(which); + if (item.is_valid()) item->notify(ui_element_notify_visibility_changed,state ? 1 : 0,NULL,0); + } + } + + + bool is_elem_visible(t_size which) { + if (!m_callback->is_elem_visible_(this)) return false; + return this->host_is_child_visible(which); + } + + GUID get_subclass() {return ui_element_subclass_containers;} + + double get_focus_priority() { + ui_element_instance_ptr item; double priority; t_size which; + if (!grabTopPriorityVisibleChild(item,which,priority)) return 0; + return priority; + } + void set_default_focus() { + ui_element_instance_ptr item; double priority; t_size which; + if (!grabTopPriorityVisibleChild(item,which,priority)) { + this->set_default_focus_fallback(); + } else { + host_bring_to_front(which); + item->set_default_focus(); + } + } + + bool get_focus_priority_subclass(double & p_out,const GUID & p_subclass) { + ui_element_instance_ptr item; double priority; t_size which; + if (!grabTopPriorityChild(item,which,priority,p_subclass)) return false; + p_out = priority; + return true; + } + bool set_default_focus_subclass(const GUID & p_subclass) { + ui_element_instance_ptr item; double priority; t_size which; + if (!grabTopPriorityChild(item,which,priority,p_subclass)) return false; + host_bring_to_front(which); + return item->set_default_focus_subclass(p_subclass); + } + void notify(const GUID & p_what, t_size p_param1, const void * p_param2, t_size p_param2size) { + if (p_what == ui_element_notify_visibility_changed) { + const t_size total = host_get_children_count(); + for(t_size walk = 0; walk < total; ++walk) { + if (this->host_is_child_visible(walk)) { + ui_element_instance_ptr item = host_get_child(walk); + if (item.is_valid()) item->notify(p_what,p_param1,p_param2,p_param2size); + } + } + } else if (p_what == ui_element_notify_get_element_labels) { + handleGetLabels(p_param1, p_param2, p_param2size); + } else { + const t_size total = host_get_children_count(); + for(t_size walk = 0; walk < total; ++walk) { + ui_element_instance_ptr item = host_get_child(walk); + if (item.is_valid()) item->notify(p_what,p_param1,p_param2,p_param2size); + } + } + } + bool query_color(const GUID & p_what,t_ui_color & p_out) {return m_callback->query_color(p_what,p_out);} + bool request_activation(t_size which) { + if (!m_callback->request_activation(this)) return false; + host_bring_to_front(which); + return true; + } + bool is_edit_mode_enabled() {return m_callback->is_edit_mode_enabled();} + + t_ui_font query_font_ex(const GUID& id) {return m_callback->query_font_ex(id);} + + void request_replace(t_size which) { + host_replace_child(which); + } + private: + void handleGetLabelsChild(ui_element_instance::ptr child, t_size which, t_size param1, const void * param2, t_size param2size) { + if (child->get_subclass() == ui_element_subclass_containers) { + child->notify(ui_element_notify_get_element_labels, param1, param2, param2size); + } else if (child->get_guid() != pfc::guid_null && child->get_wnd() != NULL && this->host_is_child_visible(which)) { + FB2K_DYNAMIC_ASSERT(param2 != NULL); + reinterpret_cast(const_cast(param2))->set_visible_element(child); + } + } + void handleGetLabels(t_size param1, const void * param2, t_size param2size) { + const t_size childrenTotal = host_get_children_count(); + for(t_size childWalk = 0; childWalk < childrenTotal; ++childWalk) { + ui_element_instance_ptr item = host_get_child(childWalk); + if (item.is_valid()) handleGetLabelsChild(item, childWalk, param1, param2, param2size); + } + } + LRESULT OnSettingChange(UINT msg,WPARAM wp,LPARAM lp,BOOL& bHandled) { + bHandled = FALSE; + const t_size total = host_get_children_count(); + for(t_size walk = 0; walk < total; ++walk) { + ui_element_instance::ptr item = host_get_child(walk); + if (item.is_valid()) { + ::SendMessage(item->get_wnd(),msg,wp,lp); + } + } + return 0; + } + t_size whichChild(ui_element_instance_ptr child) { + const t_size count = host_get_children_count(); + for(t_size walk = 0; walk < count; ++walk) { + if (child == host_get_child(walk)) return walk; + } + return ~0; + } + bool childPriorityCompare(t_size which, double priority, double bestPriority) { + if (host_is_child_visible(which)) return priority >= bestPriority; + else return priority > bestPriority; + } + bool grabTopPriorityVisibleChild(ui_element_instance_ptr & out,t_size & outWhich,double & outPriority); + bool grabTopPriorityChild(ui_element_instance_ptr & out,t_size & outWhich,double & outPriority,const GUID & subclass); + protected: + ui_element_instance_host_base(ui_element_instance_callback::ptr callback) : m_callback(callback) {} + const ui_element_instance_callback::ptr m_callback; + }; + + + bool enforce_min_max_info(CWindow p_window,ui_element_min_max_info const & p_info); + + void handle_WM_GETMINMAXINFO(LPARAM p_lp,const ui_element_min_max_info & p_myinfo); +}; + +void ui_element_instance_standard_context_menu(service_ptr_t p_elem, LPARAM p_pt); +void ui_element_instance_standard_context_menu_eh(service_ptr_t p_elem, LPARAM p_pt); + +#endif // FOOBAR2000_TARGET_VERSION >= 79 + +#endif // _WIN32 diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/win-MulDiv.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/win-MulDiv.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,7 @@ +#pragma once + +#ifndef _WIN32 +inline int MulDiv(int v1, int v2, int v3) { + return pfc::rint32((double) v1 * (double) v2 / (double) v3); +} +#endif diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/win-systemtime.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/win-systemtime.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,85 @@ +#include "StdAfx.h" +#include "win-systemtime.h" +#include + +#ifdef _WIN32 +static void theSelfTest(); // has to be outside namespace +#endif + +namespace winTimeWrapper { + uint64_t FileTimeToInt(FILETIME ft) { + return ((uint64_t)ft.dwLowDateTime) | ((uint64_t)ft.dwHighDateTime << 32); + } + FILETIME FileTimeFromInt(uint64_t i) { + return { (uint32_t)(i & 0xFFFFFFFF), (uint32_t)(i >> 32) }; + } + bool SystemTimeToFileTime(const SYSTEMTIME* st, FILETIME* ft) { + struct tm tmTemp = {}; + if (st->wYear < 1900) return false; + tmTemp.tm_year = st->wYear - 1900; + if (st->wMonth < 1 || st->wMonth > 12) return false; + tmTemp.tm_mon = st->wMonth - 1; + tmTemp.tm_mday = st->wDay; + tmTemp.tm_hour = st->wHour; + tmTemp.tm_min = st->wMinute; + tmTemp.tm_sec = st->wSecond; + tmTemp.tm_isdst = -1; + + time_t timeTemp = mktime(&tmTemp); + uint64_t wintime = pfc::fileTimeUtoW(timeTemp); + wintime += (filetimestamp_1second_increment / 1000) * st->wMilliseconds; + auto ftTemp = FileTimeFromInt( wintime ); + return LocalFileTimeToFileTime(&ftTemp, ft); + } + bool LocalFileTimeToFileTime(const FILETIME* lpLocalFileTime, FILETIME* lpFileTime) { + uint64_t t64 = FileTimeToInt(*lpLocalFileTime); + + time_t rawtime = pfc::fileTimeWtoU(t64); + + auto gm = * gmtime(&rawtime); + auto loc = * localtime(&rawtime); + + int64_t diff = (int64_t)mktime(&loc) - (int64_t)mktime(&gm); + + *lpFileTime = FileTimeFromInt(t64 + diff * filetimestamp_1second_increment); + return true; + } + +#ifdef _WIN32 + void selfTest() { theSelfTest(); } +#endif +} + + +#ifdef _WIN32 +static void theSelfTest() { + uint64_t ft1, ft2; + auto ft_1s = filetimestamp_1second_increment; + { + SYSTEMTIME st = {}; + st.wDay = 21; st.wMonth = 2; st.wYear = 2022; + st.wHour = 15; st.wMinute = 15; + FILETIME ft = {}; + SystemTimeToFileTime(&st, &ft); + ft1 = *(uint64_t*)(&ft); + } + { + winTimeWrapper::SYSTEMTIME st = {}; + st.wDay = 21; st.wMonth = 2; st.wYear = 2022; + st.wHour = 15; st.wMinute = 15; + winTimeWrapper::FILETIME ft = {}; + winTimeWrapper::SystemTimeToFileTime(&st, &ft); + ft2 = winTimeWrapper::FileTimeToInt(ft); + } + + if (ft1 < ft2) { + pfc::outputDebugLine(pfc::format("ahead by ", (ft2 - ft1) / ft_1s)); + } else if (ft1 > ft2) { + pfc::outputDebugLine(pfc::format("behind by ", (ft1 - ft2) / ft_1s)); + } else { + pfc::outputDebugLine("ok"); + } + + pfc::nop(); +} +#endif diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/win-systemtime.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/win-systemtime.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,34 @@ +#pragma once + +namespace winTimeWrapper { + typedef struct _SYSTEMTIME { + uint16_t wYear; + uint16_t wMonth; + uint16_t wDayOfWeek; + uint16_t wDay; + uint16_t wHour; + uint16_t wMinute; + uint16_t wSecond; + uint16_t wMilliseconds; + } SYSTEMTIME, * PSYSTEMTIME, * LPSYSTEMTIME; + + typedef struct _FILETIME { + uint32_t dwLowDateTime; + uint32_t dwHighDateTime; + } FILETIME, * PFILETIME, * LPFILETIME; + + + bool SystemTimeToFileTime(const SYSTEMTIME* lpSystemTime, FILETIME* lpFileTime); + bool LocalFileTimeToFileTime(const FILETIME* lpLocalFileTime, FILETIME* lpFileTime); + + uint64_t FileTimeToInt(FILETIME); + FILETIME FileTimeFromInt(uint64_t); + +#ifdef _WIN32 + void selfTest(); +#endif +} + +#ifndef _WIN32 +using namespace winTimeWrapper; +#endif diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/win32_dialog.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/win32_dialog.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,117 @@ +#include "StdAfx.h" + +#ifdef FOOBAR2000_DESKTOP_WINDOWS + +#include "win32_misc.h" +#include "win32_dialog.h" + +namespace dialog_helper { + + + INT_PTR CALLBACK dialog::DlgProc(HWND wnd,UINT msg,WPARAM wp,LPARAM lp) + { + dialog * p_this; + BOOL rv; + if (msg==WM_INITDIALOG) + { + p_this = reinterpret_cast(lp); + p_this->wnd = wnd; + SetWindowLongPtr(wnd,DWLP_USER,lp); + + if (p_this->m_is_modal) p_this->m_modal_scope.initialize(wnd); + } + else p_this = reinterpret_cast(GetWindowLongPtr(wnd,DWLP_USER)); + + rv = p_this ? p_this->on_message(msg,wp,lp) : FALSE; + + if (msg==WM_DESTROY && p_this) + { + SetWindowLongPtr(wnd,DWLP_USER,0); +// p_this->wnd = 0; + } + + return rv; + } + + + int dialog::run_modal(unsigned id,HWND parent) + { + assert(wnd == 0); + if (wnd != 0) return -1; + m_is_modal = true; + return uDialogBox(id,parent,DlgProc,reinterpret_cast(this)); + } + HWND dialog::run_modeless(unsigned id,HWND parent) + { + assert(wnd == 0); + if (wnd != 0) return 0; + m_is_modal = false; + return uCreateDialog(id,parent,DlgProc,reinterpret_cast(this)); + } + + void dialog::end_dialog(int code) + { + assert(m_is_modal); + if (m_is_modal) uEndDialog(wnd,code); + } + + + + + + + + + + + int dialog_modal::run(unsigned p_id,HWND p_parent,HINSTANCE p_instance) + { + int status; + + // note: uDialogBox() has its own modal scope, we don't want that to trigger + // if this is ever changed, move deinit to WM_DESTROY handler in DlgProc + + status = (int)DialogBoxParam(p_instance,MAKEINTRESOURCE(p_id),p_parent,DlgProc,reinterpret_cast(this)); + + m_modal_scope.deinitialize(); + + return status; + } + + void dialog_modal::end_dialog(int p_code) + { + EndDialog(m_wnd,p_code); + } + + + INT_PTR CALLBACK dialog_modal::DlgProc(HWND wnd,UINT msg,WPARAM wp,LPARAM lp) + { + dialog_modal * _this; + if (msg==WM_INITDIALOG) + { + _this = reinterpret_cast(lp); + _this->m_wnd = wnd; + SetWindowLongPtr(wnd,DWLP_USER,lp); + + _this->m_modal_scope.initialize(wnd); + } + else _this = reinterpret_cast(GetWindowLongPtr(wnd,DWLP_USER)); + + assert(_this == 0 || _this->m_wnd == wnd); + + return _this ? _this->on_message(msg,wp,lp) : FALSE; + } + +} + +HWND uCreateDialog(UINT id,HWND parent,DLGPROC proc,LPARAM param) +{ + return CreateDialogParam(core_api::get_my_instance(),MAKEINTRESOURCE(id),parent,proc,param); +} + +int uDialogBox(UINT id,HWND parent,DLGPROC proc,LPARAM param) +{ + return (int)DialogBoxParam(core_api::get_my_instance(),MAKEINTRESOURCE(id),parent,proc,param); +} + +#endif // FOOBAR2000_DESKTOP_WINDOWS diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/win32_dialog.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/win32_dialog.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,62 @@ +#pragma once + +#ifdef FOOBAR2000_DESKTOP_WINDOWS + +//DEPRECATED dialog helpers - kept only for compatibility with old code - do not use in new code, use WTL instead. + +namespace dialog_helper +{ + + class dialog + { + protected: + + dialog() : wnd(0), m_is_modal(false) {} + ~dialog() { } + + virtual BOOL on_message(UINT msg,WPARAM wp,LPARAM lp)=0; + + void end_dialog(int code); + + public: + inline HWND get_wnd() {return wnd;} + + __declspec(deprecated) int run_modal(unsigned id,HWND parent); + + __declspec(deprecated) HWND run_modeless(unsigned id,HWND parent); + private: + HWND wnd; + static INT_PTR CALLBACK DlgProc(HWND wnd,UINT msg,WPARAM wp,LPARAM lp); + + bool m_is_modal; + + modal_dialog_scope m_modal_scope; + }; + + //! This class is meant to be instantiated on-stack, as a local variable. Using new/delete operators instead or even making this a member of another object works, but does not make much sense because of the way this works (single run() call). + class dialog_modal + { + public: + __declspec(deprecated) int run(unsigned p_id,HWND p_parent,HINSTANCE p_instance = core_api::get_my_instance()); + protected: + virtual BOOL on_message(UINT msg,WPARAM wp,LPARAM lp)=0; + + inline dialog_modal() : m_wnd(0) {} + void end_dialog(int p_code); + inline HWND get_wnd() const {return m_wnd;} + private: + static INT_PTR CALLBACK DlgProc(HWND wnd,UINT msg,WPARAM wp,LPARAM lp); + + HWND m_wnd; + modal_dialog_scope m_modal_scope; + }; + +}; + +//! Wrapper (provided mainly for old code), simplifies parameters compared to standard CreateDialog() by using core_api::get_my_instance(). +HWND uCreateDialog(UINT id,HWND parent,DLGPROC proc,LPARAM param = 0); +//! Wrapper (provided mainly for old code), simplifies parameters compared to standard DialogBox() by using core_api::get_my_instance(). +int uDialogBox(UINT id,HWND parent,DLGPROC proc,LPARAM param = 0); + + +#endif // FOOBAR2000_DESKTOP_WINDOWS \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/win32_misc.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/win32_misc.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,221 @@ +#include "StdAfx.h" +#include "win32_misc.h" + +#ifdef FOOBAR2000_MOBILE_WINDOWS +#include +#endif + +#ifdef _WIN32 + +#include + +mutexScope::mutexScope(HANDLE hMutex_, abort_callback & abort) : hMutex(hMutex_) { + HANDLE h[2] = { hMutex, abort.get_abort_event() }; + switch (WaitForMultipleObjectsEx(2, h, FALSE, INFINITE, FALSE)) { + case WAIT_OBJECT_0: + break; // and enter + case WAIT_OBJECT_0 + 1: + throw exception_aborted(); + default: + uBugCheck(); + } +} +mutexScope::~mutexScope() { + ReleaseMutex(hMutex); +} + +CMutex::CMutex(const TCHAR * name) { + WIN32_OP_CRITICAL("CreateMutex", m_hMutex = CreateMutex(NULL, FALSE, name)); +} +CMutex::~CMutex() { + CloseHandle(m_hMutex); +} + +void CMutex::AcquireByHandle(HANDLE hMutex, abort_callback & aborter) { + SetLastError(0); + HANDLE hWait[2] = { hMutex, aborter.get_abort_event() }; + switch (WaitForMultipleObjects(2, hWait, FALSE, INFINITE)) { + case WAIT_FAILED: + WIN32_OP_FAIL_CRITICAL("WaitForSingleObject"); + case WAIT_OBJECT_0: + return; + case WAIT_OBJECT_0 + 1: + PFC_ASSERT(aborter.is_aborting()); + throw exception_aborted(); + default: + uBugCheck(); + } +} + +void CMutex::Acquire(abort_callback& aborter) { + AcquireByHandle(Handle(), aborter); +} + +void CMutex::Release() { + ReleaseMutex(Handle()); +} + + +CMutexScope::CMutexScope(CMutex & mutex, DWORD timeOutMS, const char * timeOutBugMsg) : m_mutex(mutex) { + SetLastError(0); + const unsigned div = 4; + for (unsigned walk = 0; walk < div; ++walk) { + switch (WaitForSingleObject(m_mutex.Handle(), timeOutMS / div)) { + case WAIT_FAILED: + WIN32_OP_FAIL_CRITICAL("WaitForSingleObject"); + case WAIT_OBJECT_0: + return; + case WAIT_TIMEOUT: + break; + default: + uBugCheck(); + } + } + TRACK_CODE(timeOutBugMsg, uBugCheck()); +} + +CMutexScope::CMutexScope(CMutex & mutex) : m_mutex(mutex) { + SetLastError(0); + switch (WaitForSingleObject(m_mutex.Handle(), INFINITE)) { + case WAIT_FAILED: + WIN32_OP_FAIL_CRITICAL("WaitForSingleObject"); + case WAIT_OBJECT_0: + return; + default: + uBugCheck(); + } +} + +CMutexScope::CMutexScope(CMutex & mutex, abort_callback & aborter) : m_mutex(mutex) { + mutex.Acquire(aborter); +} + +CMutexScope::~CMutexScope() { + ReleaseMutex(m_mutex.Handle()); +} + +#endif + +#ifdef FOOBAR2000_DESKTOP_WINDOWS + +void registerclass_scope_delayed::toggle_on(UINT p_style,WNDPROC p_wndproc,int p_clsextra,int p_wndextra,HICON p_icon,HCURSOR p_cursor,HBRUSH p_background,const TCHAR * p_class_name,const TCHAR * p_menu_name) { + toggle_off(); + WNDCLASS wc = {}; + wc.style = p_style; + wc.lpfnWndProc = p_wndproc; + wc.cbClsExtra = p_clsextra; + wc.cbWndExtra = p_wndextra; + wc.hInstance = core_api::get_my_instance(); + wc.hIcon = p_icon; + wc.hCursor = p_cursor; + wc.hbrBackground = p_background; + wc.lpszMenuName = p_menu_name; + wc.lpszClassName = p_class_name; + WIN32_OP_CRITICAL("RegisterClass", (m_class = RegisterClass(&wc)) != 0); +} + +void registerclass_scope_delayed::toggle_off() { + if (m_class != 0) { + UnregisterClass((LPCTSTR)m_class,core_api::get_my_instance()); + m_class = 0; + } +} + +void CModelessDialogEntry::Set(HWND p_new) { + auto api = modeless_dialog_manager::get(); + if (m_wnd) api->remove(m_wnd); + m_wnd = p_new; + if (m_wnd) api->add(m_wnd); +} + +OleInitializeScope::OleInitializeScope() { + if (FAILED(OleInitialize(NULL))) throw pfc::exception("OleInitialize() failure"); +} +OleInitializeScope::~OleInitializeScope() { + OleUninitialize(); +} + +CoInitializeScope::CoInitializeScope() { + if (FAILED(CoInitialize(NULL))) throw pfc::exception("CoInitialize() failed"); +} +CoInitializeScope::CoInitializeScope(DWORD params) { + if (FAILED(CoInitializeEx(NULL, params))) throw pfc::exception("CoInitialize() failed"); +} +CoInitializeScope::~CoInitializeScope() { + CoUninitialize(); +} + +void winLocalFileScope::open(const char * inPath, file::ptr inReader, abort_callback & aborter) { + close(); + if (inPath != nullptr) { + if (_extract_native_path_ptr(inPath)) { + pfc::string8 prefixed; + pfc::winPrefixPath(prefixed, inPath); + m_path = pfc::stringcvt::string_wide_from_utf8(prefixed); + m_isTemp = false; + return; + } + } + + pfc::string8 tempPath; tempPath.prealloc(1024); + if (!uGetTempPath(tempPath)) uBugCheck(); + tempPath.add_filename(PFC_string_formatter() << pfc::print_guid(pfc::createGUID()) ); + if ( inPath != nullptr ) { + auto ext = pfc::string_extension(inPath); + if (ext.length() > 0) tempPath << "." << ext; + } + + m_path = pfc::stringcvt::string_wide_from_utf8(tempPath); + + if (inReader.is_empty()) { + if (inPath == NULL) uBugCheck(); + inReader = fileOpenReadExisting(inPath, aborter, 1.0); + } + + file::ptr writer = fileOpenWriteNew(PFC_string_formatter() << "file://" << tempPath, aborter, 1.0); + file::g_transfer_file(inReader, writer, aborter); + m_isTemp = true; +} +void winLocalFileScope::close() { + if (m_isTemp && m_path.length() > 0) { + pfc::lores_timer timer; + timer.start(); + for (;;) { + if (DeleteFile(m_path.c_str())) break; + if (timer.query() > 1.0) break; + Sleep(10); + } + } + m_path.clear(); +} + +bool IsWindowsS() { + bool ret = false; +#if FB2K_TARGET_MICROSOFT_STORE + static bool cached = false; + static bool inited = false; + if ( inited ) { + ret = cached; + } else { + HKEY key; + if (RegOpenKey(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Control\\CI\\Policy", &key) == 0) { + DWORD dwVal = 0, dwType; + DWORD valSize; + valSize = sizeof(dwVal); + if (RegQueryValueEx(key, L"SkuPolicyRequired", nullptr, &dwType, (LPBYTE)&dwVal, &valSize) == 0) { + if (dwType == REG_DWORD && dwVal != 0) ret = true; + } + RegCloseKey(key); + } + cached = ret; + inited = true; + } +#endif + return ret; +} + +WORD GetOSVersion() { + // wrap libPPUI function + return ::GetOSVersionCode(); +} +#endif // FOOBAR2000_DESKTOP_WINDOWS diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/win32_misc.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/win32_misc.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,173 @@ +#pragma once + +#ifdef _WIN32 + + +#include +#include + + +class mutexScope { +public: + mutexScope(HANDLE hMutex_, abort_callback & abort); + ~mutexScope(); +private: + PFC_CLASS_NOT_COPYABLE_EX(mutexScope); + HANDLE hMutex; +}; + +#ifdef FOOBAR2000_DESKTOP_WINDOWS + +class registerclass_scope_delayed { +public: + registerclass_scope_delayed() {} + bool is_registered() const {return m_class != 0;} + void toggle_on(UINT p_style,WNDPROC p_wndproc,int p_clsextra,int p_wndextra,HICON p_icon,HCURSOR p_cursor,HBRUSH p_background,const TCHAR * p_classname,const TCHAR * p_menuname); + void toggle_off(); + ATOM get_class() const {return m_class;} + + ~registerclass_scope_delayed() {toggle_off();} +private: + registerclass_scope_delayed(const registerclass_scope_delayed &) = delete; + const registerclass_scope_delayed & operator=(const registerclass_scope_delayed &) = delete; + + ATOM m_class = 0; +}; + + +typedef CGlobalLockScope CGlobalLock; // compatibility + +class OleInitializeScope { +public: + OleInitializeScope(); + ~OleInitializeScope(); + +private: + PFC_CLASS_NOT_COPYABLE_EX(OleInitializeScope); +}; + +class CoInitializeScope { +public: + CoInitializeScope(); + CoInitializeScope(DWORD params); + ~CoInitializeScope(); +private: + PFC_CLASS_NOT_COPYABLE_EX(CoInitializeScope) +}; + +WORD GetOSVersion(); + +#if _WIN32_WINNT >= 0x501 +#define WS_EX_COMPOSITED_Safe() WS_EX_COMPOSITED +#else +static DWORD WS_EX_COMPOSITED_Safe() { + return (GetOSVersion() < 0x501) ? 0 : 0x02000000L; +} +#endif + + +class CModelessDialogEntry { +public: + CModelessDialogEntry() : m_wnd() {} + CModelessDialogEntry(HWND p_wnd) : m_wnd() {Set(p_wnd);} + ~CModelessDialogEntry() {Set(NULL);} + + void Set(HWND p_new); +private: + PFC_CLASS_NOT_COPYABLE_EX(CModelessDialogEntry); + HWND m_wnd; +}; + +class CDLL { +public: +#ifdef _DEBUG + static LPTOP_LEVEL_EXCEPTION_FILTER _GetEH() { + LPTOP_LEVEL_EXCEPTION_FILTER rv = SetUnhandledExceptionFilter(NULL); + SetUnhandledExceptionFilter(rv); + return rv; + } +#endif + CDLL(const wchar_t * Name) : hMod() { + Load(Name); + } + CDLL() : hMod() {} + void Load(const wchar_t * Name) { + PFC_ASSERT( hMod == NULL ); +#ifdef _DEBUG + auto handlerBefore = _GetEH(); +#endif + WIN32_OP( hMod = LoadLibrary(Name) ); +#ifdef _DEBUG + PFC_ASSERT( handlerBefore == _GetEH() ); +#endif + } + + + ~CDLL() { + if (hMod) FreeLibrary(hMod); + } + template void Bind(funcptr_t & outFunc, const char * name) { + WIN32_OP( outFunc = (funcptr_t)GetProcAddress(hMod, name) ); + } + + HMODULE hMod; + + PFC_CLASS_NOT_COPYABLE_EX(CDLL); +}; + +class winLocalFileScope { +public: + void open(const char * inPath, file::ptr inReader, abort_callback & aborter); + void close(); + + winLocalFileScope() {} + winLocalFileScope(const char * inPath, file::ptr inReader, abort_callback & aborter) : m_isTemp() { + open(inPath, inReader, aborter); + } + + ~winLocalFileScope() { + close(); + } + + const wchar_t * Path() const { return m_path.c_str(); } + bool isTemp() const { return m_isTemp; } +private: + bool m_isTemp = false; + std::wstring m_path; +}; + +#endif // FOOBAR2000_DESKTOP_WINDOWS + + +class CMutex { +public: + CMutex(const TCHAR * name = NULL); + ~CMutex(); + HANDLE Handle() {return m_hMutex;} + static void AcquireByHandle( HANDLE hMutex, abort_callback & aborter ); + void Acquire( abort_callback& aborter ); + void Release(); +private: + CMutex(const CMutex&) = delete; void operator=(const CMutex&) = delete; + HANDLE m_hMutex; +}; + +class CMutexScope { +public: + CMutexScope(CMutex & mutex, DWORD timeOutMS, const char * timeOutBugMsg); + CMutexScope(CMutex & mutex); + CMutexScope(CMutex & mutex, abort_callback & aborter); + ~CMutexScope(); +private: + CMutexScope(const CMutexScope &) = delete; void operator=(const CMutexScope&) = delete; + CMutex & m_mutex; +}; + +bool IsWindowsS(); + +#else + +class OleInitializeScope {}; +class CoInitializeScope {}; + +#endif // _WIN32 diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/window_placement_helper.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/window_placement_helper.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,166 @@ +#include "StdAfx.h" + +#ifdef FOOBAR2000_DESKTOP_WINDOWS + +#include "window_placement_helper.h" +#include + +static bool g_is_enabled() +{ + return standard_config_objects::query_remember_window_positions(); +} + +static BOOL CALLBACK __MonitorEnumProc( + HMONITOR hMonitor, // handle to display monitor + HDC hdcMonitor, // handle to monitor DC + LPRECT lprcMonitor, // monitor intersection rectangle + LPARAM dwData // data + ) { + RECT * clip = (RECT*)dwData; + RECT newclip; + if (UnionRect(&newclip,clip,lprcMonitor)) { + *clip = newclip; + } + return TRUE; +} + +static bool test_rect(const RECT * rc) { + RECT clip = {}; + if (EnumDisplayMonitors(NULL,NULL,__MonitorEnumProc,(LPARAM)&clip)) { + const LONG sanitycheck = 4; + const LONG cwidth = clip.right - clip.left; + const LONG cheight = clip.bottom - clip.top; + + const LONG width = rc->right - rc->left; + const LONG height = rc->bottom - rc->top; + + if (width > cwidth * sanitycheck || height > cheight * sanitycheck) return false; + } + + return MonitorFromRect(rc,MONITOR_DEFAULTTONULL) != NULL; +} + + +bool cfg_window_placement::read_from_window(HWND window) +{ + WINDOWPLACEMENT wp = {}; + if (g_is_enabled()) { + wp.length = sizeof(wp); + if (!GetWindowPlacement(window,&wp)) { + PFC_ASSERT(!"GetWindowPlacement fail!"); + memset(&wp,0,sizeof(wp)); + } else { + // bad, breaks with taskbar on top + /*if (wp.showCmd == SW_SHOWNORMAL) { + GetWindowRect(window, &wp.rcNormalPosition); + }*/ + + if ( !IsWindowVisible( window ) ) wp.showCmd = SW_HIDE; + } + /*else + { + if (!IsWindowVisible(window)) wp.showCmd = SW_HIDE; + }*/ + } + + try { set(wp); } catch(...) {} // this tends to be called often / we really couldn't care less about this failing + + return wp.length == sizeof(wp); +} + +bool applyWindowPlacement(HWND window, WINDOWPLACEMENT const& data, bool allowHidden) { + bool ret = false; + if (data.length == sizeof(data) && test_rect(&data.rcNormalPosition)) + { + if (allowHidden || data.showCmd != SW_HIDE) { + if (data.showCmd == SW_HIDE && (data.flags & WPF_RESTORETOMAXIMIZED)) { + // Special case of hidden-from-maximized + auto fix = data; + fix.showCmd = SW_SHOWMINIMIZED; + if (SetWindowPlacement(window, &fix)) { + ShowWindow(window, SW_HIDE); + ret = true; + } + } else { + if (SetWindowPlacement(window, &data)) { + ret = true; + } + } + } + } + return ret; +} + +bool cfg_window_placement::apply_to_window(HWND window, bool allowHidden) { + bool ret = false; + if (g_is_enabled()) + { + auto data = get(); + ret = applyWindowPlacement(window, data, allowHidden); + } + + return ret; +} + +void cfg_window_placement::on_window_creation_silent(HWND window) { +} +bool cfg_window_placement::on_window_creation(HWND window, bool allowHidden) { + + return apply_to_window(window, allowHidden); +} + + +void cfg_window_placement::on_window_destruction(HWND window) +{ + read_from_window(window); +} + +static BOOL SetWindowSize(HWND p_wnd,unsigned p_x,unsigned p_y) +{ + if (p_x != ~0 && p_y != ~0) + return SetWindowPos(p_wnd,0,0,0,p_x,p_y,SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER); + else + return FALSE; +} + +bool cfg_window_size::apply_to_window(HWND p_wnd) { + bool ret = false; + + if (g_is_enabled()) + { + auto v = get(); + if (v.cx > 0 && v.cy > 0) { + if (SetWindowSize(p_wnd, v.cx, v.cy)) ret = true; + } + + } + return ret; +} +bool cfg_window_size::on_window_creation(HWND p_wnd) +{ + return apply_to_window(p_wnd); +} + +void cfg_window_size::on_window_destruction(HWND p_wnd) +{ + read_from_window(p_wnd); +} + +bool cfg_window_size::read_from_window(HWND p_wnd) +{ + SIZE val = {}; + if (g_is_enabled()) + { + RECT r; + if (GetWindowRect(p_wnd,&r)) + { + val.cx = r.right - r.left; + val.cy = r.bottom - r.top; + } + } + + set(val); + return val.cx > 0 && val.cy > 0; +} + +#endif // FOOBAR2000_DESKTOP_WINDOWS diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/window_placement_helper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/window_placement_helper.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,45 @@ +#pragma once + +// DEPRECATED, NOT DPI SAFE +// use cfgDialogPosition & cfgWindowSize2 instead +#ifdef FOOBAR2000_DESKTOP_WINDOWS + +#include "../SDK/cfg_var.h" + +//! Window position management helpers +//! Usage: create a static instance, like with any cfg_var; access it on creation/reposition/destruction of your window. +class cfg_window_placement : public cfg_struct_t { +public: + cfg_window_placement(const GUID& guid) : cfg_struct_t(guid) {} + //! Read and save position data from HWND. + bool read_from_window(HWND window); + //! Apply saved position data to HWND. + bool apply_to_window(HWND window, bool allowHidden); + + // OLD methods tracking only destroy/create. + // Use of read_from_window() / apply_to_window() instead is preferred, so changes can be saved immediately. + bool on_window_creation(HWND window, bool allowHidden = false);//returns true if window position has been changed, false if not + void on_window_creation_silent(HWND window); + void on_window_destruction(HWND window); +}; + +// At one point there was a separate cfg_window_placement_v2 without legacy methods +typedef cfg_window_placement cfg_window_placement_v2; + +//! Window size tracker \n +//! Usage: create a static instance, like with any cfg_var; access it on creation/reposition/destruction of your window. +class cfg_window_size : public cfg_struct_t { +public: + cfg_window_size(const GUID& id) : cfg_struct_t(id) {} + //! Read and save size data from HWND. + bool read_from_window(HWND window); + //! Apply saved size data to HWND. + bool apply_to_window(HWND); + + // OLD methods tracking only destroy/create. + // Use of read_from_window() / apply_to_window() instead is preferred, so changes can be saved immediately. + bool on_window_creation(HWND window);//returns true if window position has been changed, false if not + void on_window_destruction(HWND window); +}; + +#endif // FOOBAR2000_DESKTOP_WINDOWS diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/winmm-types.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/winmm-types.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,103 @@ +#ifndef _WINMM_TYPES_H_ +#define _WINMM_TYPES_H_ + +#ifdef _WIN32 +#pragma warning (disable: 4201) // nostandard ext used +#include +#pragma warning (default: 4201) // nostandard ext used +#else // non _WIN32 + + +typedef uint32_t DWORD; +typedef uint16_t WORD; + + +#define _WAVEFORMATEX_ + +typedef struct tWAVEFORMATEX +{ + WORD wFormatTag; /* format type */ + WORD nChannels; /* number of channels (i.e. mono, stereo...) */ + DWORD nSamplesPerSec; /* sample rate */ + DWORD nAvgBytesPerSec; /* for buffer estimation */ + WORD nBlockAlign; /* block size of data */ + WORD wBitsPerSample; /* number of bits per sample of mono data */ + WORD cbSize; /* the count in bytes of the size of */ + /* extra information (after cbSize) */ +} __attribute__((packed)) WAVEFORMATEX, *PWAVEFORMATEX, *NPWAVEFORMATEX, *LPWAVEFORMATEX; + + +#define _WAVEFORMATEXTENSIBLE_ + +typedef struct { + WAVEFORMATEX Format; + union { + WORD wValidBitsPerSample; /* bits of precision */ + WORD wSamplesPerBlock; /* valid if wBitsPerSample==0 */ + WORD wReserved; /* If neither applies, set to zero. */ + } Samples; + DWORD dwChannelMask; /* which channels are */ + /* present in stream */ + GUID SubFormat; +} __attribute__((packed)) WAVEFORMATEXTENSIBLE, *PWAVEFORMATEXTENSIBLE; + +typedef struct { + WORD wFormatTag; + WORD nChannels; + DWORD nSamplesPerSec; + DWORD nAvgBytesPerSec; + WORD nBlockAlign; +} __attribute__((packed)) WAVEFORMAT; + +typedef struct { + WAVEFORMAT wf; + WORD wBitsPerSample; +} __attribute__((packed)) PCMWAVEFORMAT; + +#define WAVE_FORMAT_PCM 0x0001 +#define WAVE_FORMAT_ADPCM 0x0002 +#define WAVE_FORMAT_IEEE_FLOAT 0x0003 +#define WAVE_FORMAT_ALAW 0x0006 +#define WAVE_FORMAT_MULAW 0x0007 +#define WAVE_FORMAT_MPEG 0x0050 +#define WAVE_FORMAT_EXTENSIBLE 0xFFFE +#define WAVE_FORMAT_MPEGLAYER3 0x0055 + +#define SPEAKER_FRONT_LEFT 0x1 +#define SPEAKER_FRONT_RIGHT 0x2 +#define SPEAKER_FRONT_CENTER 0x4 +#define SPEAKER_LOW_FREQUENCY 0x8 +#define SPEAKER_BACK_LEFT 0x10 +#define SPEAKER_BACK_RIGHT 0x20 +#define SPEAKER_FRONT_LEFT_OF_CENTER 0x40 +#define SPEAKER_FRONT_RIGHT_OF_CENTER 0x80 +#define SPEAKER_BACK_CENTER 0x100 +#define SPEAKER_SIDE_LEFT 0x200 +#define SPEAKER_SIDE_RIGHT 0x400 +#define SPEAKER_TOP_CENTER 0x800 +#define SPEAKER_TOP_FRONT_LEFT 0x1000 +#define SPEAKER_TOP_FRONT_CENTER 0x2000 +#define SPEAKER_TOP_FRONT_RIGHT 0x4000 +#define SPEAKER_TOP_BACK_LEFT 0x8000 +#define SPEAKER_TOP_BACK_CENTER 0x10000 +#define SPEAKER_TOP_BACK_RIGHT 0x20000 +#define SPEAKER_ALL 0x80000000 + +static const GUID KSDATAFORMAT_SUBTYPE_PCM = {0x00000001, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; // "00000001-0000-0010-8000-00aa00389b71" +static const GUID KSDATAFORMAT_SUBTYPE_IEEE_FLOAT = {0x00000003, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; // "00000003-0000-0010-8000-00aa00389b71" + +static const GUID KSDATAFORMAT_SUBTYPE_ALAW = {0x00000006, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; // "00000006-0000-0010-8000-00aa00389b71" +static const GUID KSDATAFORMAT_SUBTYPE_MULAW = {0x00000007, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; // "00000007-0000-0010-8000-00aa00389b71" +static const GUID KSDATAFORMAT_SUBTYPE_ADPCM = {0x00000002, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; // "00000002-0000-0010-8000-00aa00389b71" +static const GUID KSDATAFORMAT_SUBTYPE_MPEG = {0x00000050, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; // "00000050-0000-0010-8000-00aa00389b71" + +#define mmioFOURCC(ch0, ch1, ch2, ch3) \ +MAKEFOURCC(ch0, ch1, ch2, ch3) + +#define MAKEFOURCC(ch0, ch1, ch2, ch3) \ +((DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) << 8) | \ + ((DWORD)(BYTE)(ch2) << 16) | ((DWORD)(BYTE)(ch3) << 24 )) + +#endif + +#endif // _WINMM_TYPES_H_ diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/writer_wav.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/writer_wav.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,378 @@ +#include "StdAfx.h" + +#include + +#ifndef _WIN32 +#include "winmm-types.h" +#endif + +#include "writer_wav.h" + +#include "audio_render_float.h" + +static const GUID guid_RIFF = pfc::GUID_from_text("66666972-912E-11CF-A5D6-28DB04C10000"); +static const GUID guid_WAVE = pfc::GUID_from_text("65766177-ACF3-11D3-8CD1-00C04F8EDB8A"); +static const GUID guid_FMT = pfc::GUID_from_text("20746D66-ACF3-11D3-8CD1-00C04F8EDB8A"); +static const GUID guid_DATA = pfc::GUID_from_text("61746164-ACF3-11D3-8CD1-00C04F8EDB8A"); +static const GUID guid_JUNK = pfc::GUID_from_text("6b6E756A-ACF3-11D3-8CD1-00C04f8EDB8A"); + +struct RIFF_chunk_desc { + GUID m_guid; + const char * m_name; +}; + +static const RIFF_chunk_desc RIFF_chunks[] = { + {guid_RIFF, "RIFF"}, + {guid_WAVE, "WAVE"}, + {guid_FMT , "fmt "}, + {guid_DATA, "data"}, + {guid_JUNK, "JUNK"}, +}; + +bool wavWriterSetup_t::needWFXE() const { + if (this->m_bpsValid != this->m_bps) return true; + switch(m_channels) + { + case 1: + return m_channel_mask != audio_chunk::channel_config_mono; + case 2: + return m_channel_mask != audio_chunk::channel_config_stereo; +/* case 4: + m_wfxe = m_setup.m_channel_mask != (audio_chunk::channel_front_left | audio_chunk::channel_front_right | audio_chunk::channel_back_left | audio_chunk::channel_back_right); + break; + case 6: + m_wfxe = m_setup.m_channel_mask != audio_chunk::channel_config_5point1; + break;*/ + default: + return true; + } + +} + +void wavWriterSetup_t::initialize3(const audio_chunk::spec_t & spec, unsigned bps, unsigned bpsValid, bool bFloat, bool bDither, bool bWave64) { + m_bps = bps; + m_bpsValid = bpsValid; + m_samplerate = spec.sampleRate; + m_channels = spec.chanCount; + m_channel_mask = spec.chanMask; + m_float = bFloat; + m_dither = bDither; + m_wave64 = bWave64; + + m_rf64_explicit = false; + m_rf64_implicit = false; +} + +void wavWriterSetup_t::initialize2(const audio_chunk & p_chunk, unsigned p_bps, unsigned p_bpsValid, bool p_float, bool p_dither, bool p_wave64) { + initialize3(p_chunk.get_spec(), p_bps, p_bpsValid, p_float, p_dither, p_wave64); +} + +void wavWriterSetup_t::initialize(const audio_chunk & p_chunk, unsigned p_bps, bool p_float, bool p_dither, bool p_wave64) +{ + unsigned bpsValid = p_bps; + unsigned bps = (p_bps + 7) & ~7; + initialize2(p_chunk, bps, bpsValid, p_float, p_dither, p_wave64); +} + +void wavWriterSetup_t::setup_wfx(WAVEFORMATEX & p_wfx) +{ + p_wfx.wFormatTag = m_float ? WAVE_FORMAT_IEEE_FLOAT : WAVE_FORMAT_PCM; + p_wfx.nChannels = m_channels; + p_wfx.nSamplesPerSec = m_samplerate; + p_wfx.nAvgBytesPerSec = (m_bps >> 3) * m_channels * m_samplerate; + p_wfx.nBlockAlign = (m_bps>>3) * m_channels; + p_wfx.wBitsPerSample = m_bps; + p_wfx.cbSize = 0; +} + +void wavWriterSetup_t::setup_wfxe(WAVEFORMATEXTENSIBLE & p_wfxe) +{ + setup_wfx(p_wfxe.Format); + p_wfxe.Format.wFormatTag=WAVE_FORMAT_EXTENSIBLE; + p_wfxe.Format.cbSize=22; + p_wfxe.Samples.wValidBitsPerSample = this->m_bpsValid; + p_wfxe.dwChannelMask = audio_chunk::g_channel_config_to_wfx(m_channel_mask); + p_wfxe.SubFormat = m_float ? KSDATAFORMAT_SUBTYPE_IEEE_FLOAT : KSDATAFORMAT_SUBTYPE_PCM; + +} + +void CWavWriter::writeID(const GUID & id, abort_callback & abort) { + if (is64()) { + m_file->write_object_t(id, abort); + } else { + for( auto & walk : RIFF_chunks) { + if (id == walk.m_guid) { + m_file->write(walk.m_name, 4, abort); return; + } + } + uBugCheck(); + } +} + +void CWavWriter::writeSize(t_uint64 size, abort_callback & abort) { + if (is64()) { + if (size != UINT64_MAX) size += 24; + m_file->write_lendian_t(size, abort); + } else { + t_uint32 clipped; + if (size > UINT32_MAX) clipped = UINT32_MAX; + else clipped = (t_uint32) size; + m_file->write_lendian_t(clipped, abort); + } +} + +size_t CWavWriter::align(abort_callback & abort) { + t_uint8 dummy[8] = {}; + const t_uint32 val = is64() ? 8 : 2; + t_filesize pos = m_file->get_position(abort); + t_size delta = (val - (pos%val)) % val; + if (delta > 0) m_file->write(dummy, delta, abort); + return delta; +} + +void CWavWriter::open(const char * p_path, const wavWriterSetup_t & p_setup, abort_callback & p_abort) +{ + service_ptr_t l_file; + filesystem::g_open_write_new(l_file,p_path,p_abort); + open(l_file,p_setup,p_abort); +} + +namespace { +PFC_DECLARE_EXCEPTION(exceptionBadBitDepth, exception_io_data, "Invalid bit depth specified"); +} +void CWavWriter::open(service_ptr_t p_file, const wavWriterSetup_t & p_setup, abort_callback & p_abort) +{ + m_file = p_file; + m_setup = p_setup; + + if (m_setup.m_channels == 0 || m_setup.m_channels > 18 || m_setup.m_channels != audio_chunk::g_count_channels(m_setup.m_channel_mask)) throw exception_io_data(); + + if (!audio_chunk::g_is_valid_sample_rate(m_setup.m_samplerate)) throw exception_io_data(); + + if (m_setup.m_bpsValid > m_setup.m_bps) throw exceptionBadBitDepth(); + + if (m_setup.m_float) + { + if (m_setup.m_bps != 32 && m_setup.m_bps != 64) throw exceptionBadBitDepth(); + if (m_setup.m_bpsValid != m_setup.m_bps) throw exceptionBadBitDepth(); + } + else + { + if (m_setup.m_bps != 8 && m_setup.m_bps != 16 && m_setup.m_bps != 24 && m_setup.m_bps != 32) throw exceptionBadBitDepth(); + if (m_setup.m_bpsValid < 1) throw exceptionBadBitDepth(); + } + + m_wfxe = m_setup.needWFXE(); + + if (m_setup.m_wave64) { + m_file->write_object_t(guid_RIFF, p_abort); + } else if (m_setup.m_rf64_explicit) { + m_file->write("RF64", 4, p_abort); + } else { + m_file->write("RIFF", 4, p_abort); + } + + m_offset_fix1 = m_file->get_position(p_abort); + writeSize(UINT64_MAX, p_abort); + + writeID(guid_WAVE, p_abort); + + if (!is64() && m_file->can_seek() && (m_setup.m_rf64_explicit || m_setup.m_rf64_implicit)) { + // write JUNK placeholder for DS64 + m_ds64_at = m_file->get_position(p_abort); + static const uint8_t dummy[28] = {}; // riffsize64, datasize64, samplecount64, tablecount32 + writeID(guid_JUNK, p_abort); + writeSize(sizeof(dummy), p_abort); + m_file->write_object(dummy, sizeof(dummy), p_abort); + } + + + writeID(guid_FMT, p_abort); + if (m_wfxe) { + writeSize(sizeof(WAVEFORMATEXTENSIBLE),p_abort); + + WAVEFORMATEXTENSIBLE wfxe = {}; + m_setup.setup_wfxe(wfxe); + m_file->write_object(&wfxe,sizeof(wfxe),p_abort); + } else { + writeSize(sizeof(PCMWAVEFORMAT),p_abort); + + WAVEFORMATEX wfx = {}; + m_setup.setup_wfx(wfx); + m_file->write_object(&wfx,/* blah */ sizeof(PCMWAVEFORMAT),p_abort); + } + align(p_abort); + + writeID(guid_DATA, p_abort); + m_offset_fix2 = m_file->get_position(p_abort); + writeSize(UINT64_MAX, p_abort); + m_offset_fix1_delta = m_file->get_position(p_abort) - chunkOverhead(); + + m_bytes_written = 0; + + if (!m_setup.m_float) + { + m_postprocessor = standard_api_create_t(); + } +} + +void CWavWriter::write_raw( const void * raw, size_t rawSize, abort_callback & p_abort ) { + m_file->write_object(raw,rawSize,p_abort); + m_bytes_written += rawSize; +} + +void CWavWriter::write(const audio_chunk & p_chunk, abort_callback & p_abort) +{ + if (p_chunk.get_channels() != m_setup.m_channels + || p_chunk.get_channel_config() != m_setup.m_channel_mask + || p_chunk.get_srate() != m_setup.m_samplerate + ) throw exception_unexpected_audio_format_change(); + + + if (m_setup.m_float) + { + const size_t count = p_chunk.get_channels() * p_chunk.get_sample_count(); + const void* data = render_float_by_bps(m_setup.m_bps, m_postprocessor_output, p_chunk.get_data(), count); + write_raw(data, count * m_setup.m_bps / 8, p_abort); + } + else + { + m_postprocessor->run(p_chunk,m_postprocessor_output,m_setup.m_bpsValid,m_setup.m_bps,m_setup.m_dither,1.0f); + write_raw( m_postprocessor_output.get_ptr(),m_postprocessor_output.get_size(), p_abort ); + } +} + +void CWavWriter::finalize(abort_callback & p_abort) +{ + if (m_file.is_valid()) + { + const size_t alignG = align(p_abort); + + if (m_file->can_seek()) { + m_file->seek(m_offset_fix1,p_abort); + const uint64_t riffSize = m_bytes_written + alignG + m_offset_fix1_delta; + writeSize(riffSize, p_abort); + m_file->seek(m_offset_fix2,p_abort); + writeSize(m_bytes_written, p_abort); + + if (!is64() && (m_setup.m_rf64_explicit || (m_setup.m_rf64_implicit && m_bytes_written > UINT32_MAX))) { + if (!m_setup.m_rf64_explicit) { // turn RIFF into RF64? + m_file->seek(0, p_abort); + m_file->write("RF64", 4, p_abort); + } + m_file->seek(m_ds64_at, p_abort); + m_file->write("ds64", 4, p_abort); + writeSize(28, p_abort); + + // RIFF size, data size, sample count + m_file->write_lendian_t(riffSize, p_abort); + m_file->write_lendian_t(m_bytes_written, p_abort); + + unsigned sampleBytes = (m_setup.m_bps + 7) / 8 * m_setup.m_channels; + uint64_t samples = m_bytes_written / sampleBytes; + m_file->write_lendian_t(samples, p_abort); + uint32_t tableCount = 0; + m_file->write_lendian_t(tableCount, p_abort); + } + } + m_file.release(); + } + m_postprocessor.release(); +} + +void CWavWriter::close() +{ + m_file.release(); + m_postprocessor.release(); +} + +audio_chunk::spec_t CWavWriter::get_spec() const { + audio_chunk::spec_t spec = {}; + spec.sampleRate = m_setup.m_samplerate; + spec.chanCount = m_setup.m_channels; + spec.chanMask = m_setup.m_channel_mask; + return spec; +} + +namespace { +class fileWav : public foobar2000_io::file { +public: + size_t read( void * buffer, size_t bytes, abort_callback & aborter ) override { + aborter.check(); + uint8_t * out = (uint8_t*) buffer; + size_t ret = 0; + if (m_position < m_header.size()) { + size_t delta = (size_t) ( m_header.size() - m_position ); + if (delta > bytes) delta = bytes; + memcpy( out, &m_header[(size_t)m_position], delta ); + m_position += delta; + out += delta; ret += delta; bytes -= delta; + } + if (bytes > 0) { + m_data->seek( m_position, aborter ); + size_t didRead = m_data->read( out, bytes, aborter ); + m_position += didRead; + ret += didRead; + } + return ret; + } + void write( const void * buffer, size_t bytes, abort_callback & aborter ) override { + throw exception_io_denied(); + } + fileWav( std::vector const & header, file::ptr data) { + m_data = data; + m_position = 0; + m_header = header; + } + fileWav( std::vector && header, file::ptr data) { + m_data = data; + m_position = 0; + m_header = std::move(header); + } + t_filesize get_size(abort_callback & p_abort) override { + t_filesize s = m_data->get_size( p_abort ); + if (s != filesize_invalid) s += m_header.size(); + return s; + } + t_filesize get_position(abort_callback & p_abort) override { + return m_position; + } + void resize(t_filesize p_size,abort_callback & p_abort) override { + throw exception_io_denied(); + } + void seek(t_filesize p_position,abort_callback & p_abort) override { + if (p_position > get_size(p_abort)) throw exception_io_seek_out_of_range(); + m_position = p_position; + } + bool can_seek() override {return true; } + bool get_content_type(pfc::string_base & p_out) override { return false; } + void reopen(abort_callback & p_abort) override { seek(0, p_abort); } + bool is_remote() override { return m_data->is_remote(); } +private: + std::vector m_header; + t_filesize m_position; + file::ptr m_data; +}; +} + +static std::vector makeWavHeader( const wavWriterSetup_t & setup, t_filesize dataSize, abort_callback & aborter ) { + std::vector ret; + file::ptr temp; filesystem::g_open_tempmem( temp, aborter ); + { + CWavWriter w; + w.open( temp, setup, aborter ); + } + const size_t s = pfc::downcast_guarded( temp->get_size( aborter ) ); + if (s > 0) { + ret.resize( s ); + temp->seek( 0, aborter ); + temp->read_object( &ret[0], s, aborter ); + } + return ret; +} + +file::ptr makeLiveWAVFile( const wavWriterSetup_t & setup, file::ptr data ) { + t_filesize size = data->get_size( fb2k::noAbort ); + auto vec = makeWavHeader( setup, size, fb2k::noAbort ); + return new service_impl_t< fileWav >( std::move(vec), data ); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/helpers/writer_wav.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/helpers/writer_wav.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,55 @@ +#pragma once + +#ifdef _WIN32 +#include +#endif + +#include + +struct wavWriterSetup_t +{ + unsigned m_bps,m_bpsValid,m_samplerate,m_channels,m_channel_mask; + bool m_float,m_dither, m_wave64; + bool m_rf64_implicit, m_rf64_explicit; + + + void initialize(const audio_chunk & p_chunk,unsigned p_bps,bool p_float,bool p_dither, bool p_wave64 = false); + void initialize2(const audio_chunk & p_chunk,unsigned p_bps, unsigned p_bpsValid,bool p_float,bool p_dither, bool p_wave64 = false); + void initialize3(const audio_chunk::spec_t & spec, unsigned bps, unsigned bpsValid, bool bFloat, bool bDither, bool bWave64 = false); + +#ifdef _WAVEFORMATEX_ + void setup_wfx(WAVEFORMATEX & p_wfx); +#endif +#ifdef _WAVEFORMATEXTENSIBLE_ + void setup_wfxe(WAVEFORMATEXTENSIBLE & p_wfx); +#endif + bool needWFXE() const; +}; + +class CWavWriter +{ +public: + void open(const char * p_path, const wavWriterSetup_t & p_setup, abort_callback & p_abort); + void open(service_ptr_t p_file, const wavWriterSetup_t & p_setup, abort_callback & p_abort); + void write(const audio_chunk & p_chunk,abort_callback & p_abort); + void write_raw( const void * raw, size_t rawSize, abort_callback & p_abort ); + void finalize(abort_callback & p_abort); + void close(); + bool is_open() const { return m_file.is_valid(); } + audio_chunk::spec_t get_spec() const; +private: + size_t align(abort_callback & abort); + void writeSize(t_uint64 size, abort_callback & abort); + bool is64() const {return m_setup.m_wave64;} + t_uint32 chunkOverhead() const {return is64() ? 24 : 8;} + void writeID(const GUID & id, abort_callback & abort); + service_ptr_t m_file; + service_ptr_t m_postprocessor; + wavWriterSetup_t m_setup; + bool m_wfxe = false; + t_uint64 m_offset_fix1 = 0,m_offset_fix2 = 0,m_offset_fix1_delta = 0,m_bytes_written = 0; + uint64_t m_ds64_at = 0; + mem_block_container_aligned_incremental_impl<16> m_postprocessor_output; +}; + +file::ptr makeLiveWAVFile( const wavWriterSetup_t & setup, file::ptr data ); diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/shared/Utility.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/shared/Utility.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,131 @@ +#include "shared.h" + +#include + +static std::once_flag g_infinitWaitInit; +static HANDLE g_infinitWaitEvent = NULL; + +HANDLE SHARED_EXPORT GetInfiniteWaitEvent() { + std::call_once(g_infinitWaitInit, [] { + g_infinitWaitEvent = CreateEvent(NULL, TRUE, FALSE, NULL); + } ); + return g_infinitWaitEvent; +} + +struct createFileRequest { + TCHAR * lpFileName; + DWORD dwDesiredAccess; + DWORD dwShareMode; + LPSECURITY_ATTRIBUTES lpSecurityAttributes; + DWORD dwCreationDisposition; + DWORD dwFlagsAndAttributes; + + HANDLE hResultHandle; + + DWORD dwErrorCode; + + volatile LONG refCounter; + + void Delete() { + free(lpFileName); + if (hResultHandle != INVALID_HANDLE_VALUE) CloseHandle(hResultHandle); + delete this; + } + + void Release() { + if (InterlockedDecrement(&refCounter) == 0) { + Delete(); + } + } +}; + +static unsigned CALLBACK createFileThread(void* p) { + createFileRequest * req = reinterpret_cast(p); + + SetLastError(0); + req->hResultHandle = CreateFile(req->lpFileName, req->dwDesiredAccess, req->dwShareMode, req->lpSecurityAttributes, req->dwCreationDisposition, req->dwFlagsAndAttributes, NULL); + req->dwErrorCode = GetLastError(); + + req->Release(); + return 0; +} + + +HANDLE SHARED_EXPORT CreateFileAbortable( __in LPCWSTR lpFileName, + __in DWORD dwDesiredAccess, + __in DWORD dwShareMode, + __in_opt LPSECURITY_ATTRIBUTES lpSecurityAttributes, + __in DWORD dwCreationDisposition, + __in DWORD dwFlagsAndAttributes, + __in_opt HANDLE hAborter + ) { + if (hAborter == NULL || hAborter == GetInfiniteWaitEvent()) { + return CreateFile(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, NULL); + } + switch(WaitForSingleObject(hAborter, 0)) { + case WAIT_TIMEOUT: + break; + case WAIT_OBJECT_0: + SetLastError(ERROR_OPERATION_ABORTED); + return INVALID_HANDLE_VALUE; + default: + return INVALID_HANDLE_VALUE; + } + + createFileRequest * req = new createFileRequest(); + req->lpFileName = _tcsdup(lpFileName); + req->dwDesiredAccess = dwDesiredAccess; + req->dwShareMode = dwShareMode; + req->lpSecurityAttributes = lpSecurityAttributes; + req->dwCreationDisposition = dwCreationDisposition; + req->dwFlagsAndAttributes = dwFlagsAndAttributes; + req->hResultHandle = INVALID_HANDLE_VALUE; + req->dwErrorCode = 0; + req->refCounter = 2; + + HANDLE hThread = (HANDLE) _beginthreadex(NULL, 0, createFileThread, req, CREATE_SUSPENDED, NULL); + if (hThread == NULL) { + req->Delete(); + return INVALID_HANDLE_VALUE; + } + SetThreadPriority(hThread, GetThreadPriority(GetCurrentThread())); + ResumeThread(hThread); + + DWORD waitStatus; + { + HANDLE waits[2] = {hThread, hAborter}; + waitStatus = WaitForMultipleObjects(2, waits, FALSE, INFINITE); + } + HANDLE hRetVal = INVALID_HANDLE_VALUE; + DWORD dwErrorCode = 0; + switch(waitStatus) { + case WAIT_OBJECT_0: // thread completed + hRetVal = req->hResultHandle; + req->hResultHandle = INVALID_HANDLE_VALUE; + dwErrorCode = req->dwErrorCode; + break; + case WAIT_OBJECT_0 + 1: // aborted + dwErrorCode = ERROR_OPERATION_ABORTED; + CancelSynchronousIo(hThread); + break; + default: // unexpected, use last-error code from WFMO + dwErrorCode = GetLastError(); + CancelSynchronousIo(hThread); + break; + } + req->Release(); + CloseHandle(hThread); + SetLastError(dwErrorCode); + return hRetVal; +} + +namespace pfc { + BOOL winFormatSystemErrorMessageImpl(pfc::string_base & p_out, DWORD p_code); + BOOL winFormatSystemErrorMessageHook(pfc::string_base & p_out, DWORD p_code) { + return winFormatSystemErrorMessageImpl(p_out, p_code); + } + + void crashHook() { + uBugCheck(); + } +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/shared/audio_math.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/shared/audio_math.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,137 @@ +#include "shared.h" + +//#define AUDIO_MATH_NOASM + +// NOTE: SSE4.1 int16 ops code determined MUCH SLOWER than SSE2 on Sandy Bridge era Xeon and therefore disabled for now +// #define SUPPORT_SSE41 + +#ifdef SUPPORT_SSE41 +static const bool g_have_sse41 = pfc::query_cpu_feature_set(pfc::CPU_HAVE_SSE41); + +inline static void convert_from_int16_noopt(const t_int16 * p_source,t_size p_count,audio_sample * p_output,float p_scale) +{ + t_size num = p_count; + for(;num;num--) + *(p_output++) = (audio_sample)*(p_source++) * p_scale; +} + +__declspec(naked) static void __fastcall convert_from_int16_sse41_8word(const t_int16 * p_source,t_size p_count,audio_sample * p_output,float p_scale) { + __asm { + // ecx = source, edx = count, [esp + 4] = output, [esp + 8] = scale + movss xmm7, [esp + 8] + test edx, edx + mov eax, [esp + 4] + pshufd xmm7, xmm7, 0 + jz loopend +loopbegin: + PMOVSXWD xmm0, mmword ptr [ecx] + PMOVSXWD xmm1, mmword ptr [ecx+8] + CVTDQ2PS xmm0, xmm0 + CVTDQ2PS xmm1, xmm1 + add ecx, 16 + mulps xmm0, xmm7 + mulps xmm1, xmm7 + dec edx + movups [eax], xmm0 + movups [eax + 16], xmm1 + lea eax, [eax + 32] + jnz loopbegin +loopend: + ret 8 + } +} + + +__declspec(naked) static void __fastcall convert_from_int16_sse41_8word_aligned(const t_int16 * p_source,t_size p_count,audio_sample * p_output,float p_scale) { + __asm { + // ecx = source, edx = count, [esp + 4] = output, [esp + 8] = scale + movss xmm7, [esp + 8] + test edx, edx + mov eax, [esp + 4] + pshufd xmm7, xmm7, 0 + jz loopend +loopbegin: + PMOVSXWD xmm0, mmword ptr [ecx] + PMOVSXWD xmm1, mmword ptr [ecx+8] + CVTDQ2PS xmm0, xmm0 + CVTDQ2PS xmm1, xmm1 + add ecx, 16 + mulps xmm0, xmm7 + mulps xmm1, xmm7 + dec edx + movaps [eax], xmm0 + movaps [eax + 16], xmm1 + lea eax, [eax + 32] + jnz loopbegin +loopend: + ret 8 + } +} +#endif + + + +#ifdef audio_math +#undef audio_math +#endif +namespace audio_math { + + void SHARED_EXPORT scale(const audio_sample * p_source,t_size p_count,audio_sample * p_output,audio_sample p_scale) + { + ::pfc::audio_math::scale(p_source, p_count, p_output, p_scale); + } + + void SHARED_EXPORT convert_to_int16(const audio_sample * p_source,t_size p_count,t_int16 * p_output,audio_sample p_scale) + { + ::pfc::audio_math::convert_to_int16(p_source, p_count, p_output, p_scale); + } + + audio_sample SHARED_EXPORT convert_to_int16_calculate_peak(const audio_sample * p_source,t_size p_count,t_int16 * p_output,audio_sample p_scale) + { + convert_to_int16(p_source,p_count,p_output,p_scale); + return p_scale * calculate_peak(p_source,p_count); + } + + void SHARED_EXPORT convert_from_int16(const t_int16 * p_source,t_size p_count,audio_sample * p_output,audio_sample p_scale) + { +#ifdef SUPPORT_SSE41 + if (g_have_sse41) { + audio_sample scale = (audio_sample)(p_scale / (double)0x8000); + convert_from_int16_sse41_8word(p_source, p_count >> 3, p_output, scale); + convert_from_int16_noopt(p_source + (p_count & ~7), p_count & 7, p_output + (p_count & ~7), scale); + return; + } +#endif + ::pfc::audio_math::convert_from_int16(p_source, p_count, p_output, p_scale); + } + + void SHARED_EXPORT convert_to_int32(const audio_sample * p_source,t_size p_count,t_int32 * p_output,audio_sample p_scale) + { + return ::pfc::audio_math::convert_to_int32(p_source, p_count, p_output, p_scale); + } + + audio_sample SHARED_EXPORT convert_to_int32_calculate_peak(const audio_sample * p_source,t_size p_count,t_int32 * p_output,audio_sample p_scale) + { + convert_to_int32(p_source,p_count,p_output,p_scale); + return p_scale * calculate_peak(p_source,p_count); + } + + void SHARED_EXPORT convert_from_int32(const t_int32 * p_source,t_size p_count,audio_sample * p_output,audio_sample p_scale) + { + ::pfc::audio_math::convert_from_int32(p_source, p_count, p_output, p_scale); + } + + + audio_sample SHARED_EXPORT calculate_peak(const audio_sample * p_source,t_size p_count) { + return ::pfc::audio_math::calculate_peak(p_source, p_count); + } + + void SHARED_EXPORT kill_denormal(audio_sample * p_buffer,t_size p_count) { + ::pfc::audio_math::remove_denormals(p_buffer, p_count); + } + + void SHARED_EXPORT add_offset(audio_sample * p_buffer,audio_sample p_delta,t_size p_count) { + ::pfc::audio_math::add_offset(p_buffer, p_delta, p_count); + } + +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/shared/audio_math.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/shared/audio_math.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,82 @@ +#pragma once + +#include +#if SIZE_MAX < UINT64_MAX +#define audio_sample_size 32 +#else +#define audio_sample_size 64 +#endif + +#if audio_sample_size == 32 +typedef float audio_sample; +#define audio_sample_asm dword +#elif audio_sample_size == 64 +typedef double audio_sample; +#define audio_sample_asm qword +#else +#error wrong audio_sample_size +#endif + +#define audio_sample_bytes (audio_sample_size/8) + +/* +PROBLEM: +audio_math is implemented in pfc (pfc::audio_math) and in shared.dll (::audio_math) +We must overlay shared.dll methods on top of PFC ones +*/ + +namespace audio_math +{ + //! p_source/p_output can point to same buffer + void SHARED_EXPORT scale(const audio_sample * p_source,t_size p_count,audio_sample * p_output,audio_sample p_scale); + void SHARED_EXPORT convert_to_int16(const audio_sample * p_source,t_size p_count,t_int16 * p_output,audio_sample p_scale); + void SHARED_EXPORT convert_to_int32(const audio_sample * p_source,t_size p_count,t_int32 * p_output,audio_sample p_scale); + audio_sample SHARED_EXPORT convert_to_int16_calculate_peak(const audio_sample * p_source,t_size p_count,t_int16 * p_output,audio_sample p_scale); + void SHARED_EXPORT convert_from_int16(const t_int16 * p_source,t_size p_count,audio_sample * p_output,audio_sample p_scale); + void SHARED_EXPORT convert_from_int32(const t_int32 * p_source,t_size p_count,audio_sample * p_output,audio_sample p_scale); + audio_sample SHARED_EXPORT convert_to_int32_calculate_peak(const audio_sample * p_source,t_size p_count,t_int32 * p_output,audio_sample p_scale); + audio_sample SHARED_EXPORT calculate_peak(const audio_sample * p_source,t_size p_count); + void SHARED_EXPORT kill_denormal(audio_sample * p_buffer,t_size p_count); + void SHARED_EXPORT add_offset(audio_sample * p_buffer,audio_sample p_delta,t_size p_count); +} + +namespace audio_math_shareddll = audio_math; +typedef pfc::audio_math audio_math_pfc; + +// Overlay class, overrides specific pfc::audio_math methods +class fb2k_audio_math : public audio_math_pfc { +public: + static void scale(const audio_sample * p_source,t_size p_count,audio_sample * p_output,audio_sample p_scale) { + audio_math_shareddll::scale(p_source, p_count, p_output, p_scale); + } + static void convert_to_int16(const audio_sample * p_source,t_size p_count,t_int16 * p_output,audio_sample p_scale) { + audio_math_shareddll::convert_to_int16(p_source, p_count, p_output, p_scale); + } + static void convert_to_int32(const audio_sample * p_source,t_size p_count,t_int32 * p_output,audio_sample p_scale) { + audio_math_shareddll::convert_to_int32(p_source, p_count, p_output, p_scale); + } + static audio_sample convert_to_int16_calculate_peak(const audio_sample * p_source,t_size p_count,t_int16 * p_output,audio_sample p_scale) { + return audio_math_shareddll::convert_to_int16_calculate_peak(p_source,p_count,p_output,p_scale); + } + static void convert_from_int16(const t_int16 * p_source,t_size p_count,audio_sample * p_output,audio_sample p_scale) { + audio_math_shareddll::convert_from_int16(p_source,p_count,p_output,p_scale); + } + static void convert_from_int32(const t_int32 * p_source,t_size p_count,audio_sample * p_output,audio_sample p_scale) { + audio_math_shareddll::convert_from_int32(p_source,p_count,p_output,p_scale); + } + static audio_sample convert_to_int32_calculate_peak(const audio_sample * p_source,t_size p_count,t_int32 * p_output,audio_sample p_scale) { + return audio_math_shareddll::convert_to_int32_calculate_peak(p_source,p_count,p_output,p_scale); + } + static audio_sample calculate_peak(const audio_sample * p_source,t_size p_count) { + return audio_math_shareddll::calculate_peak(p_source,p_count); + } + static void kill_denormal(audio_sample * p_buffer,t_size p_count) { + audio_math_shareddll::kill_denormal(p_buffer, p_count); + } + static void add_offset(audio_sample * p_buffer,audio_sample p_delta,t_size p_count) { + audio_math_shareddll::add_offset(p_buffer,p_delta,p_count); + } +}; + +// Anyone trying to talk to audio_math namespace will reach fb2k_audio_math which calls the right thing +#define audio_math fb2k_audio_math diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/shared/crash_info.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/shared/crash_info.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,652 @@ +#include "shared.h" +#include +#include + +#if SIZE_MAX == UINT32_MAX +#define STACKSPEC "%08X" +#define PTRSPEC "%08Xh" +#define OFFSETSPEC "%Xh" +#elif SIZE_MAX == UINT64_MAX +#define STACKSPEC "%016llX" +#define PTRSPEC "%016llXh" +#define OFFSETSPEC "%llXh" +#else +#error WTF? +#endif + + +static volatile bool g_didSuppress = false; +static critical_section g_panicHandlersSync; +static std::forward_list g_panicHandlers; + +static void callPanicHandlers() { + insync(g_panicHandlersSync); + for( auto i = g_panicHandlers.begin(); i != g_panicHandlers.end(); ++ i ) { + try { + (*i)->onPanic(); + } catch(...) {} + } +} + +void SHARED_EXPORT uAddPanicHandler(fb2k::panicHandler* p) { + insync(g_panicHandlersSync); + g_panicHandlers.push_front(p); +} + +void SHARED_EXPORT uRemovePanicHandler(fb2k::panicHandler* p) { + insync(g_panicHandlersSync); + g_panicHandlers.remove(p); +} + + +enum { EXCEPTION_BUG_CHECK = 0xaa67913c }; + +#if FB2K_SUPPORT_CRASH_LOGS + +static const unsigned char utf8_header[3] = {0xEF,0xBB,0xBF}; + +static __declspec(thread) char g_thread_call_stack[1024]; +static __declspec(thread) t_size g_thread_call_stack_length; + +static critical_section g_lastEventsSync; +static pfc::chain_list_v2_t g_lastEvents; +static constexpr t_size KLastEventCount = 200; + +static pfc::string8 version_string; + +static pfc::array_t DumpPathBuffer; + +static long crash_no = 0; + +// Debug timer: GetTickCount() diff since app startup. +// Intentionally kept as dumb as possible (originally meant to format system time nicely). +// Do not want to do expensive preformat of every event that in >99% of scenarios isn't logged. +// Cannot do formatting & system calls in crash handler. +// So we just write amount of MS since app startup. +static const uint64_t debugTimerInit = GetTickCount64(); +static pfc::format_int_t queryDebugTimer() { return pfc::format_int( GetTickCount64() - debugTimerInit ); } + +static pfc::string8 g_components; + +static void WriteFileString_internal(HANDLE hFile,const char * ptr,t_size len) +{ + DWORD bah; + WriteFile(hFile,ptr,(DWORD)len,&bah,0); +} + +static HANDLE create_failure_log() +{ + bool rv = false; + if (DumpPathBuffer.get_size() == 0) return INVALID_HANDLE_VALUE; + + TCHAR * path = DumpPathBuffer.get_ptr(); + + t_size lenWalk = _tcslen(path); + + if (lenWalk == 0 || path[lenWalk-1] != '\\') {path[lenWalk++] = '\\';} + + _tcscpy(path + lenWalk, _T("crash reports")); + lenWalk += _tcslen(path + lenWalk); + + SetLastError(NO_ERROR); + if (!CreateDirectory(path, NULL)) { + if (GetLastError() != ERROR_ALREADY_EXISTS) return INVALID_HANDLE_VALUE; + } + path[lenWalk++] = '\\'; + + TCHAR * fn_out = path + lenWalk; + HANDLE hFile = INVALID_HANDLE_VALUE; + unsigned attempts = 0; + for(;;) { + wsprintf(fn_out,TEXT("failure_%08u.txt"),++attempts); + hFile = CreateFile(path,GENERIC_WRITE,0,0,CREATE_NEW,0,0); + if (hFile!=INVALID_HANDLE_VALUE) break; + if (attempts > 1000) break; + } + if (hFile!=INVALID_HANDLE_VALUE) WriteFileString_internal(hFile, (const char*)utf8_header, sizeof(utf8_header)); + return hFile; +} + + +static void WriteFileString(HANDLE hFile,const char * str) +{ + const char * ptr = str; + for(;;) + { + const char * start = ptr; + ptr = strchr(ptr,'\n'); + if (ptr) + { + if (ptr>start) { + t_size len = ptr-start; + if (ptr[-1] == '\r') --len; + WriteFileString_internal(hFile,start,len); + } + WriteFileString_internal(hFile,"\r\n",2); + ptr++; + } + else + { + WriteFileString_internal(hFile,start,strlen(start)); + break; + } + } +} + +static void WriteEvent(HANDLE hFile,const char * str) { + bool haveText = false; + const char * ptr = str; + bool isLineBreak = false; + while(*ptr) { + const char * base = ptr; + while(*ptr && *ptr != '\r' && *ptr != '\n') ++ptr; + if (ptr > base) { + if (isLineBreak) WriteFileString_internal(hFile,"\r\n",2); + WriteFileString_internal(hFile,base,ptr-base); + isLineBreak = false; haveText = true; + } + for(;;) { + if (*ptr == '\n') isLineBreak = haveText; + else if (*ptr != '\r') break; + ++ptr; + } + } + if (haveText) WriteFileString_internal(hFile,"\r\n",2); +} + +static bool read_int(t_size src, t_size* out) +{ + __try + { + *out = *(t_size*)src; + return true; + } __except (1) { return false; } +} + +static bool hexdump8(char * out,size_t address,const char * msg,int from,int to) +{ + unsigned max = (to-from)*16; + if (IsBadReadPtr((const void*)(address+(from*16)),max)) return false; + out += sprintf(out,"\n%s (" PTRSPEC "):",msg,address); + unsigned n; + const unsigned char * src = (const unsigned char*)(address)+(from*16); + + for(n=0;n(rptr); + t_size walk = 0; + for (; walk < 255; ++walk) { + char c = ptr[walk]; + if (c == 0) break; + if (c < 0x20) c = ' '; + temp[walk] = c; + } + temp[walk] = 0; + return true; + } __except (1) { return false; } +} + +static void DumpCPPExceptionData(HANDLE hFile, const ULONG_PTR* params, char* temp) { + t_size strPtr; + if (read_int(params[1] + sizeof(void*), &strPtr)) { + if (SalvageString(strPtr, temp)) { + WriteFileString(hFile, "Message: "); + WriteFileString(hFile, temp); + WriteFileString(hFile, "\n"); + } + } +} + +static void writeFailureTxt(LPEXCEPTION_POINTERS param, HANDLE hFile, DWORD lastError) { + char temp[2048]; + { + t_size address = (t_size)param->ExceptionRecord->ExceptionAddress; + sprintf(temp, "Illegal operation:\nCode: %08Xh, flags: %08Xh, address: " PTRSPEC "\n", param->ExceptionRecord->ExceptionCode, param->ExceptionRecord->ExceptionFlags, address); + WriteFileString(hFile, temp); + + if (param->ExceptionRecord->ExceptionCode == EXCEPTION_BUG_CHECK) { + WriteFileString(hFile, "Bug check\n"); + } else if (param->ExceptionRecord->ExceptionCode == EXCEPTION_ACCESS_VIOLATION && param->ExceptionRecord->NumberParameters >= 2) { + sprintf(temp, "Access violation, operation: %s, address: " PTRSPEC "\n", param->ExceptionRecord->ExceptionInformation[0] ? "write" : "read", param->ExceptionRecord->ExceptionInformation[1]); + WriteFileString(hFile, temp); + } else if (param->ExceptionRecord->NumberParameters > 0) { + WriteFileString(hFile, "Additional parameters:"); + for (DWORD walk = 0; walk < param->ExceptionRecord->NumberParameters; ++walk) { + sprintf(temp, " " PTRSPEC, param->ExceptionRecord->ExceptionInformation[walk]); + WriteFileString(hFile, temp); + } + WriteFileString(hFile, "\n"); + } + + if (param->ExceptionRecord->ExceptionCode == 0xE06D7363 && param->ExceptionRecord->NumberParameters >= 3) { //C++ exception + DumpCPPExceptionData(hFile, param->ExceptionRecord->ExceptionInformation, temp); + } + + if (lastError) { + sprintf(temp, "Last win32 error: %u\n", lastError); + WriteFileString(hFile, temp); + } + + if (g_thread_call_stack[0] != 0) { + WriteFileString(hFile, "\nCall path:\n"); + WriteFileString(hFile, g_thread_call_stack); + WriteFileString(hFile, "\n"); + } else { + WriteFileString(hFile, "\nCall path not available.\n"); + } + + + if (hexdump8(temp, address, "Code bytes", -4, +4)) WriteFileString(hFile, temp); +#ifdef _M_IX86 + if (hexdump_stack(temp, param->ContextRecord->Esp, "Stack", -2, +18)) WriteFileString(hFile, temp); + sprintf(temp, "\nRegisters:\nEAX: %08X, EBX: %08X, ECX: %08X, EDX: %08X\nESI: %08X, EDI: %08X, EBP: %08X, ESP: %08X\n", param->ContextRecord->Eax, param->ContextRecord->Ebx, param->ContextRecord->Ecx, param->ContextRecord->Edx, param->ContextRecord->Esi, param->ContextRecord->Edi, param->ContextRecord->Ebp, param->ContextRecord->Esp); + WriteFileString(hFile, temp); +#endif + +#ifdef _M_X64 + if (hexdump_stack(temp, param->ContextRecord->Rsp, "Stack", -2, +18)) WriteFileString(hFile, temp); + sprintf(temp, "\nRegisters:\nRAX: %016llX, RBX: %016llX, RCX: %016llX, RDX: %016llX\nRSI: %016llX, RDI: %016llX, RBP: %016llX, RSP: %016llX\n", param->ContextRecord->Rax, param->ContextRecord->Rbx, param->ContextRecord->Rcx, param->ContextRecord->Rdx, param->ContextRecord->Rsi, param->ContextRecord->Rdi, param->ContextRecord->Rbp, param->ContextRecord->Rsp); + WriteFileString(hFile, temp); +#endif + +#ifdef _M_ARM64 + if (hexdump_stack(temp, param->ContextRecord->Sp, "Stack", -2, +18)) WriteFileString(hFile, temp); +#endif + + WriteFileString(hFile, "\nTimestamp:\n"); + WriteFileString(hFile, queryDebugTimer() ); + WriteFileString(hFile, "ms\n"); + + { + const HANDLE hProcess = GetCurrentProcess(); + if (SymInitialize(hProcess, NULL, TRUE)) + { + { + IMAGEHLP_MODULE mod = {}; + mod.SizeOfStruct = sizeof(mod); + if (!IsBadCodePtr((FARPROC)address) && SymGetModuleInfo(hProcess, address, &mod)) + { + sprintf(temp, "\nCrash location:\nModule: %s\nOffset: " OFFSETSPEC "\n", mod.ModuleName, address - mod.BaseOfImage); + WriteFileString(hFile, temp); + } else + { + sprintf(temp, "\nUnable to identify crash location!\n"); + WriteFileString(hFile, temp); + } + } + + { + union + { + char buffer[128]; + IMAGEHLP_SYMBOL symbol; + }; + memset(buffer, 0, sizeof(buffer)); + symbol.SizeOfStruct = sizeof(symbol); + symbol.MaxNameLength = (DWORD)(buffer + sizeof(buffer) - symbol.Name); + DWORD_PTR offset = 0; + if (SymGetSymFromAddr(hProcess, address, &offset, &symbol)) + { + buffer[PFC_TABSIZE(buffer) - 1] = 0; + if (symbol.Name[0]) + { + sprintf(temp, "Symbol: \"%s\" (+" OFFSETSPEC ")\n", symbol.Name, offset); + WriteFileString(hFile, temp); + } + } + } + + WriteFileString(hFile, "\nLoaded modules:\n"); + SymEnumerateModules(hProcess, EnumModulesCallback, hFile); + +#ifdef _M_IX86 + call_stack_parse(param->ContextRecord->Esp, hFile, temp, hProcess); +#endif + +#ifdef _M_X64 + call_stack_parse(param->ContextRecord->Rsp, hFile, temp, hProcess); +#endif + + SymCleanup(hProcess); + } else { + WriteFileString(hFile, "\nFailed to get module/symbol info.\n"); + } + } + + WriteFileString(hFile, "\nEnvironment:\n"); + WriteFileString(hFile, version_string); + + WriteFileString(hFile, "\n"); + + if (!g_components.is_empty()) { + WriteFileString(hFile, "\nComponents:\n"); + WriteFileString(hFile, g_components); + } + + { + insync(g_lastEventsSync); + if (g_lastEvents.get_count() > 0) { + WriteFileString(hFile, "\nRecent events:\n"); + for( auto & walk : g_lastEvents) WriteEvent(hFile, walk); + } + } + } +} + +static bool GrabOSVersion(char * out) { + OSVERSIONINFO ver = {}; ver.dwOSVersionInfoSize = sizeof(ver); + if (!GetVersionEx(&ver)) return false; + *out = 0; + char temp[16]; + strcat(out,"Windows "); + _itoa(ver.dwMajorVersion,temp,10); strcat(out,temp); + strcat(out,"."); + _itoa(ver.dwMinorVersion,temp,10); strcat(out,temp); + return true; +} + +static void OnLogFileWritten() { + TCHAR exePath[MAX_PATH + 1] = {}; + TCHAR params[1024]; + GetModuleFileName(NULL, exePath, MAX_PATH); + exePath[MAX_PATH] = 0; + //unsafe... + wsprintf(params, _T("/crashed \"%s\""), DumpPathBuffer.get_ptr()); + ShellExecute(NULL, NULL, exePath, params, NULL, SW_SHOW); +} + +BOOL WriteMiniDumpHelper(HANDLE, LPEXCEPTION_POINTERS); //minidump.cpp + + +void SHARED_EXPORT uDumpCrashInfo(LPEXCEPTION_POINTERS param) +{ + if (g_didSuppress) return; + const DWORD lastError = GetLastError(); + if (InterlockedIncrement(&crash_no) > 1) {Sleep(10000);return;} + HANDLE hFile = create_failure_log(); + if (hFile == INVALID_HANDLE_VALUE) return; + + { + _tcscpy(_tcsrchr(DumpPathBuffer.get_ptr(), '.'), _T(".dmp")); + HANDLE hDump = CreateFile(DumpPathBuffer.get_ptr(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL); + if (hDump != INVALID_HANDLE_VALUE) { + const BOOL written = WriteMiniDumpHelper(hDump, param); + CloseHandle(hDump); + if (!written) { //don't bother proceeding if we don't have a valid minidump + DeleteFile(DumpPathBuffer.get_ptr()); + CloseHandle(hFile); + _tcscpy(_tcsrchr(DumpPathBuffer.get_ptr(), '.'), _T(".txt")); + DeleteFile(DumpPathBuffer.get_ptr()); + return; + } + } + _tcscpy(_tcsrchr(DumpPathBuffer.get_ptr(), '.'), _T(".txt")); + } + + writeFailureTxt(param, hFile, lastError); + + CloseHandle(hFile); + + OnLogFileWritten(); +} + +//No longer used. +size_t SHARED_EXPORT uPrintCrashInfo(LPEXCEPTION_POINTERS param,const char * extra_info,char * outbase) { + *outbase = 0; + return 0; +} + + +LONG SHARED_EXPORT uExceptFilterProc(LPEXCEPTION_POINTERS param) { + if (g_didSuppress) return UnhandledExceptionFilter(param); + callPanicHandlers(); + if (IsDebuggerPresent()) { + return UnhandledExceptionFilter(param); + } else { + if ( param->ExceptionRecord->ExceptionCode == STATUS_STACK_OVERFLOW ) { + pfc::thread2 trd; + trd.startHere( [param] { + uDumpCrashInfo(param); + } ); + trd.waitTillDone(); + } else { + uDumpCrashInfo(param); + } + TerminateProcess(GetCurrentProcess(), 0); + return 0;// never reached + } +} + +void SHARED_EXPORT uPrintCrashInfo_Init(const char * name)//called only by exe on startup +{ + version_string = pfc::format( "App: ", name, "\nArch: ", pfc::cpuArch()); + + SetUnhandledExceptionFilter(uExceptFilterProc); +} +void SHARED_EXPORT uPrintCrashInfo_Suppress() { + g_didSuppress = true; +} + +void SHARED_EXPORT uPrintCrashInfo_AddEnvironmentInfo(const char * p_info) { + version_string << "\n" << p_info; +} + +void SHARED_EXPORT uPrintCrashInfo_SetComponentList(const char * p_info) { + g_components = p_info; +} + +void SHARED_EXPORT uPrintCrashInfo_SetDumpPath(const char * p_path) { + pfc::stringcvt::string_os_from_utf8 temp(p_path); + DumpPathBuffer.set_size(temp.length() + 256); + _tcscpy(DumpPathBuffer.get_ptr(), temp.get_ptr()); +} + +static HANDLE hLogFile = INVALID_HANDLE_VALUE; + +static void logEvent(const char* message) { + if ( hLogFile != INVALID_HANDLE_VALUE ) { + DWORD wrote = 0; + WriteFile(hLogFile, message, (DWORD) strlen(message), &wrote, NULL ); + WriteFile(hLogFile, "\r\n", 2, &wrote, NULL); + } +} + +void SHARED_EXPORT uPrintCrashInfo_StartLogging(const char * path) { + insync(g_lastEventsSync); + PFC_ASSERT(hLogFile == INVALID_HANDLE_VALUE); + hLogFile = CreateFile( pfc::stringcvt::string_wide_from_utf8(path), GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, NULL); + PFC_ASSERT(hLogFile != INVALID_HANDLE_VALUE); + + for( auto & walk : g_lastEvents ) { + logEvent( walk.c_str() ); + } +} + +void SHARED_EXPORT uPrintCrashInfo_OnEvent(const char * message, t_size length) { + + pfc::string8 msg = pfc::format("[", queryDebugTimer(), "ms] "); + msg.add_string( message, length ); + uOutputDebugString(msg + "\n"); + + insync(g_lastEventsSync); + logEvent(msg); + while(g_lastEvents.get_count() >= KLastEventCount) g_lastEvents.remove(g_lastEvents.first()); + g_lastEvents.insert_last( std::move(msg) ); +} + +static void callstack_add(const char * param) +{ + enum { MAX = PFC_TABSIZE(g_thread_call_stack) - 1} ; + t_size len = strlen(param); + if (g_thread_call_stack_length + len > MAX) len = MAX - g_thread_call_stack_length; + if (len>0) + { + memcpy(g_thread_call_stack+g_thread_call_stack_length,param,len); + g_thread_call_stack_length += len; + g_thread_call_stack[g_thread_call_stack_length]=0; + } +} + +uCallStackTracker::uCallStackTracker(const char * name) +{ + param = g_thread_call_stack_length; + if (g_thread_call_stack_length>0) callstack_add("=>"); + callstack_add(name); +} + +uCallStackTracker::~uCallStackTracker() +{ + g_thread_call_stack_length = param; + g_thread_call_stack[param]=0; + +} + +extern "C" {LPCSTR SHARED_EXPORT uGetCallStackPath() {return g_thread_call_stack;} } + +#ifdef _DEBUG +extern "C" { + void SHARED_EXPORT fb2kDebugSelfTest() { + auto ptr = SetUnhandledExceptionFilter(NULL); + PFC_ASSERT( ptr == uExceptFilterProc ); + SetUnhandledExceptionFilter(ptr); + } +} +#endif + +#else + +void SHARED_EXPORT uDumpCrashInfo(LPEXCEPTION_POINTERS param) {} +void SHARED_EXPORT uPrintCrashInfo_OnEvent(const char * message, t_size length) {} +LONG SHARED_EXPORT uExceptFilterProc(LPEXCEPTION_POINTERS param) { + return UnhandledExceptionFilter(param); +} +uCallStackTracker::uCallStackTracker(const char * name) {} +uCallStackTracker::~uCallStackTracker() {} +extern "C" { + LPCSTR SHARED_EXPORT uGetCallStackPath() { return ""; } + void SHARED_EXPORT fb2kDebugSelfTest() {} +} +#endif + +PFC_NORETURN void SHARED_EXPORT uBugCheck() { + fb2k_instacrash_scope(RaiseException(EXCEPTION_BUG_CHECK, EXCEPTION_NONCONTINUABLE, 0, NULL); ); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/shared/fb2kdebug.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/shared/fb2kdebug.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,189 @@ +#pragma once + +#include + +class uDebugLog_ : public pfc::string_formatter { +public: + ~uDebugLog_() {*this << "\n"; uOutputDebugString(get_ptr());} +}; + +#define FB2K_DebugLog() uDebugLog_()._formatter() +#define uDebugLog() FB2K_DebugLog() + +// since fb2k 1.5 +namespace fb2k { + class panicHandler { + public: + virtual void onPanic() = 0; + }; +} + +// since fb2k 1.5 +extern "C" +{ + void SHARED_EXPORT uAddPanicHandler(fb2k::panicHandler*); + void SHARED_EXPORT uRemovePanicHandler(fb2k::panicHandler*); +} + +extern "C" +{ +#ifdef _WIN32 + LPCSTR SHARED_EXPORT uGetCallStackPath(); + LONG SHARED_EXPORT uExceptFilterProc(LPEXCEPTION_POINTERS param); +#endif + + PFC_NORETURN void SHARED_EXPORT uBugCheck(); + +#if PFC_DEBUG + void SHARED_EXPORT fb2kDebugSelfTest(); +#endif + +#ifdef _WIN32 + static inline void uAddDebugEvent(const char * msg) {uPrintCrashInfo_OnEvent(msg, SIZE_MAX);} +#else + static inline void uAddDebugEvent( const char * msg ) { uOutputDebugString(pfc::format(msg, "\n")); } +#endif +} + +#ifdef _WIN32 +class uCallStackTracker { + t_size param; +public: + explicit SHARED_EXPORT uCallStackTracker(const char* name); + SHARED_EXPORT ~uCallStackTracker(); +}; +#endif + +#if FB2K_SUPPORT_CRASH_LOGS + +#define TRACK_CALL(X) uCallStackTracker TRACKER__##X(#X) +#define TRACK_CALL_TEXT(X) uCallStackTracker TRACKER__BLAH(X) +#define TRACK_CODE(description,code) {uCallStackTracker __call_tracker(description); code;} + +#else // FB2K_SUPPORT_CRASH_LOGS + +#define TRACK_CALL(X) +#define TRACK_CALL_TEXT(X) +#define TRACK_CODE(description,code) {code;} + +#endif // FB2K_SUPPORT_CRASH_LOGS + +#if FB2K_SUPPORT_CRASH_LOGS +inline int uExceptFilterProc_inline(LPEXCEPTION_POINTERS param) { + uDumpCrashInfo(param); + TerminateProcess(GetCurrentProcess(), 0); + return 0;// never reached +} +#endif + + +#define FB2K_DYNAMIC_ASSERT( X ) { if (!(X)) uBugCheck(); } + +#if FB2K_SUPPORT_CRASH_LOGS +#define __except_instacrash __except(uExceptFilterProc(GetExceptionInformation())) +#define fb2k_instacrash_scope(X) __try { X; } __except_instacrash {} +#else +#define fb2k_instacrash_scope(X) {X;} +#endif + +#if 0 // no longer used +PFC_NORETURN inline void fb2kCriticalError(DWORD code, DWORD argCount = 0, const ULONG_PTR * args = NULL) { + fb2k_instacrash_scope( RaiseException(code,EXCEPTION_NONCONTINUABLE,argCount,args); ); +} +PFC_NORETURN inline void fb2kDeadlock() { + fb2kCriticalError(0x63d81b66); +} +#endif + +#ifdef _WIN32 +inline void fb2kWaitForCompletion(HANDLE hEvent) { + switch(WaitForSingleObject(hEvent, INFINITE)) { + case WAIT_OBJECT_0: + return; + default: + uBugCheck(); + } +} + +inline void fb2kWaitForThreadCompletion(HANDLE hWaitFor, DWORD threadID) { + (void) threadID; + switch(WaitForSingleObject(hWaitFor, INFINITE)) { + case WAIT_OBJECT_0: + return; + default: + uBugCheck(); + } +} + +inline void fb2kWaitForThreadCompletion2(HANDLE hWaitFor, HANDLE hThread, DWORD threadID) { + (void)threadID; (void)hThread; + switch(WaitForSingleObject(hWaitFor, INFINITE)) { + case WAIT_OBJECT_0: + return; + default: + uBugCheck(); + } +} + + +inline void __cdecl _OverrideCrtAbort_handler(int signal) { + const ULONG_PTR args[] = {(ULONG_PTR)signal}; + RaiseException(0x6F8E1DC8 /* random GUID */, EXCEPTION_NONCONTINUABLE, _countof(args), args); +} + +static void __cdecl _PureCallHandler() { + RaiseException(0xf6538887 /* random GUID */, EXCEPTION_NONCONTINUABLE, 0, 0); +} + +static void _InvalidParameter( + const wchar_t * expression, + const wchar_t * function, + const wchar_t * file, + unsigned int line, + uintptr_t pReserved +) { + (void)pReserved; (void) line; (void) file; (void) function; (void) expression; + RaiseException(0xd142b808 /* random GUID */, EXCEPTION_NONCONTINUABLE, 0, 0); +} + +inline void OverrideCrtAbort() { + const int signals[] = {SIGINT, SIGTERM, SIGBREAK, SIGABRT}; + for(size_t i=0; i<_countof(signals); i++) signal(signals[i], _OverrideCrtAbort_handler); + _set_abort_behavior(0, UINT_MAX); + + _set_purecall_handler(_PureCallHandler); + _set_invalid_parameter_handler(_InvalidParameter); +} +#endif + +namespace fb2k { +#ifdef _WIN32 + PFC_NORETURN inline void crashWithMessage(const char * msg) { + uAddDebugEvent(msg); + uBugCheck(); + } + inline void crashOnException(std::function const & f, const char* context = nullptr) { + (void)context; + fb2k_instacrash_scope(f()); + } +#else + void crashWithMessage [[noreturn]] (const char*); + void crashOnException(std::function, const char* context = nullptr); +#endif + +} + +#define FB2K_CrashOnException( ... ) ::fb2k::crashWithMessage(__VA_ARGS__) + + +// implement me +#define FB2K_TRACE_ENABLED 0 + +#define FB2K_TRACE_FORCED(X) +#define FB2K_TRACE(X) +#define FB2K_TRACE_THIS FB2K_TRACE(__FUNCTION__) +#define FB2K_TRACE_THIS_FORCED FB2K_TRACE_FORCED(__FUNCTION__) + +#define FB2K_BugCheck() fb2k::crashWithMessage( pfc::format("FB2K_BugCheck: ", __FUNCTION__ ) ) +#define FB2K_BugCheckEx(msg) fb2k::crashWithMessage(msg) +#define FB2K_BugCheckUnlikely() uBugCheck() diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/shared/filedialogs.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/shared/filedialogs.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,317 @@ +#include "shared.h" +#include "filedialogs.h" +#include + +#define dTEXT(X) pfc::stringcvt::string_os_from_utf8(X) + +static UINT_PTR CALLBACK uGetOpenFileName_Hook(HWND wnd,UINT msg,WPARAM wp,LPARAM lp) +{ + switch(msg) { + case WM_INITDIALOG: + { + OPENFILENAME * ofn = reinterpret_cast(lp); + reinterpret_cast(ofn->lCustData)->initialize(FindOwningPopup(wnd)); + } + return 0; + default: + return 0; + } +} + +static void ImportExtMask(pfc::array_t & out, const char * in) { + { + pfc::stringcvt::string_os_from_utf8 temp(in); + out.set_size(temp.length()+2); + out.fill_null(); + pfc::memcpy_t(out.get_ptr(),temp.get_ptr(),temp.length()); + } + + for(t_size walk = 0; walk < out.get_size(); ++walk) { + if (out[walk] == '|') out[walk] = 0; + } +} + +BOOL Vista_GetOpenFileName(HWND parent,const char * p_ext_mask,unsigned def_ext_mask,const char * p_def_ext,const char * p_title,const char * p_directory,pfc::string_base & p_filename,BOOL b_save); +BOOL Vista_GetOpenFileNameMulti(HWND parent,const char * p_ext_mask,unsigned def_ext_mask,const char * p_def_ext,const char * p_title,const char * p_directory,pfc::ptrholder_t & out); +BOOL Vista_BrowseForFolder(HWND parent, const char * p_title, pfc::string_base & path); +puGetOpenFileNameMultiResult Vista_BrowseForFolderEx(HWND parent,const char * title, const char * initPath); + +static bool UseVistaDialogs() { +#if FB2K_TARGET_MICROSOFT_STORE || _WIN32_WINNT >= 0x600 + return true; +#else + return GetWindowsVersionCode() >= 0x600; +#endif +} + +BOOL SHARED_EXPORT uGetOpenFileName(HWND parent,const char * p_ext_mask,unsigned def_ext_mask,const char * p_def_ext,const char * p_title,const char * p_directory,pfc::string_base & p_filename,BOOL b_save) { + TRACK_CALL_TEXT("uGetOpenFileName"); + try { + if (UseVistaDialogs()) return Vista_GetOpenFileName(parent, p_ext_mask, def_ext_mask, p_def_ext, p_title, p_directory, p_filename, b_save); + } catch(pfc::exception_not_implemented const &) {} + + modal_dialog_scope scope; + + pfc::array_t ext_mask; + ImportExtMask(ext_mask,p_ext_mask); + + TCHAR buffer[4096]; + + pfc::stringToBuffer(buffer,pfc::stringcvt::string_os_from_utf8(p_filename)); + + pfc::stringcvt::string_os_from_utf8 def_ext(p_def_ext ? p_def_ext : ""),title(p_title ? p_title : ""), + directory(p_directory ? p_directory : ""); + + OPENFILENAME ofn = {}; + + ofn.lStructSize=sizeof(ofn); + ofn.hwndOwner = parent; + ofn.lpstrFilter = ext_mask.get_ptr(); + ofn.nFilterIndex = def_ext_mask + 1; + ofn.lpstrFile = buffer; + ofn.lpstrInitialDir = directory; + ofn.nMaxFile = _countof(buffer); + ofn.Flags = b_save ? OFN_NOCHANGEDIR|OFN_EXPLORER|OFN_HIDEREADONLY|OFN_PATHMUSTEXIST|OFN_OVERWRITEPROMPT|OFN_ENABLEHOOK|OFN_ENABLESIZING : OFN_NOCHANGEDIR|OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY|OFN_PATHMUSTEXIST|OFN_ENABLEHOOK|OFN_ENABLESIZING; + ofn.lpstrDefExt = *(const TCHAR*)def_ext ? (const TCHAR*)def_ext : 0; + ofn.lpstrTitle = *(const TCHAR*)title ? (const TCHAR*)title : 0; + ofn.lCustData = reinterpret_cast(&scope); + ofn.lpfnHook = uGetOpenFileName_Hook; + if (b_save ? GetSaveFileName(&ofn) : GetOpenFileName(&ofn)) + { + buffer[_countof(buffer)-1]=0; + + { + t_size ptr = _tcslen(buffer); + while(ptr>0 && buffer[ptr-1]==' ') buffer[--ptr] = 0; + } + + p_filename = pfc::stringcvt::string_utf8_from_os(buffer,_countof(buffer)); + return TRUE; + } + else return FALSE; +} + + +puGetOpenFileNameMultiResult SHARED_EXPORT uGetOpenFileNameMulti(HWND parent,const char * p_ext_mask,unsigned def_ext_mask,const char * p_def_ext,const char * p_title,const char * p_directory) { + TRACK_CALL_TEXT("uGetOpenFileNameMulti"); + try { + if (UseVistaDialogs()) { + pfc::ptrholder_t result; + if (!Vista_GetOpenFileNameMulti(parent,p_ext_mask,def_ext_mask,p_def_ext,p_title,p_directory,result)) return NULL; + return result.detach(); + } + } catch(pfc::exception_not_implemented const &) {} + + modal_dialog_scope scope; + + pfc::array_t ext_mask; + ImportExtMask(ext_mask,p_ext_mask); + + TCHAR buffer[0x4000]; + buffer[0]=0; + + pfc::stringcvt::string_os_from_utf8 def_ext(p_def_ext ? p_def_ext : ""),title(p_title ? p_title : ""), + directory(p_directory ? p_directory : ""); + + OPENFILENAME ofn = {}; + + ofn.lStructSize=sizeof(ofn); + ofn.hwndOwner = parent; + ofn.lpstrFilter = ext_mask.get_ptr(); + ofn.nFilterIndex = def_ext_mask + 1; + ofn.lpstrFile = buffer; + ofn.lpstrInitialDir = directory; + ofn.nMaxFile = _countof(buffer); + ofn.Flags = OFN_NOCHANGEDIR|OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY|OFN_PATHMUSTEXIST|OFN_ALLOWMULTISELECT|OFN_ENABLEHOOK|OFN_ENABLESIZING; + ofn.lpstrDefExt = *(const TCHAR*)def_ext ? (const TCHAR*)def_ext : 0; + ofn.lpstrTitle = *(const TCHAR*)title ? (const TCHAR*)title : 0; + ofn.lCustData = reinterpret_cast(&scope); + ofn.lpfnHook = uGetOpenFileName_Hook; + if (GetOpenFileName(&ofn)) + { + buffer[_countof(buffer)-1]=0; + buffer[_countof(buffer)-2]=0; + + pfc::ptrholder_t result = new uGetOpenFileNameMultiResult_impl; + + TCHAR * p=buffer; + while(*p) p++; + p++; + if (!*p) + { + { + t_size ptr = _tcslen(buffer); + while(ptr>0 && buffer[ptr-1]==' ') buffer[--ptr] = 0; + } + + result->AddItem(pfc::stringcvt::string_utf8_from_os(buffer)); + } + else + { + pfc::string_formatter s = (const char*) pfc::stringcvt::string_utf8_from_os(buffer,_countof(buffer)); + t_size ofs = s.length(); + if (ofs>0 && s[ofs-1]!='\\') {s.add_char('\\');ofs++;} + while(*p) + { + s.truncate(ofs); + s += pfc::stringcvt::string_utf8_from_os(p); + s.skip_trailing_char(' '); + result->AddItem(s); + while(*p) p++; + p++; + } + } + return result.detach(); + } + else return 0; +} + + + + + +struct browse_for_dir_struct +{ + const TCHAR * m_initval; + const TCHAR * m_tofind; + + modal_dialog_scope m_scope; +}; + +static bool file_exists(const TCHAR * p_path) +{ + DWORD val = GetFileAttributes(p_path); + if (val == (-1) || (val & FILE_ATTRIBUTE_DIRECTORY)) return false; + return true; +} + +static void browse_proc_check_okbutton(HWND wnd,const browse_for_dir_struct * p_struct,const TCHAR * p_path) +{ + TCHAR temp[MAX_PATH+1]; + pfc::stringToBuffer(temp, p_path); + + t_size len = _tcslen(temp); + if (len < MAX_PATH && len > 0) + { + if (temp[len-1] != '\\') + temp[len++] = '\\'; + } + t_size idx = 0; + while(p_struct->m_tofind[idx] && idx+len < MAX_PATH) + { + temp[len+idx] = p_struct->m_tofind[idx]; + idx++; + } + temp[len+idx] = 0; + + SendMessage(wnd,BFFM_ENABLEOK,0,!!file_exists(temp)); + +} + +static int _stdcall browse_proc(HWND wnd,UINT msg,LPARAM lp,LPARAM dat) +{ + browse_for_dir_struct * p_struct = reinterpret_cast(dat); + switch(msg) + { + case BFFM_INITIALIZED: + p_struct->m_scope.initialize(wnd); + SendMessage(wnd,BFFM_SETSELECTION,1,(LPARAM)p_struct->m_initval); + if (p_struct->m_tofind) browse_proc_check_okbutton(wnd,p_struct,p_struct->m_initval); + break; + case BFFM_SELCHANGED: + if (p_struct->m_tofind) + { + if (lp != 0) + { + TCHAR temp[MAX_PATH+1]; + if (SHGetPathFromIDList(reinterpret_cast(lp),temp)) + { + temp[MAX_PATH] = 0; + browse_proc_check_okbutton(wnd,p_struct,temp); + } + else + SendMessage(wnd,BFFM_ENABLEOK,0,FALSE); + } + else SendMessage(wnd,BFFM_ENABLEOK,0,FALSE); + } + break; + } + return 0; +} + +static BOOL BrowseForFolderHelper(HWND p_parent,const TCHAR * p_title,TCHAR (&p_out)[MAX_PATH],const TCHAR * p_file_to_find) +{ + pfc::com_ptr_t mallocptr; + + if (FAILED(SHGetMalloc(mallocptr.receive_ptr()))) return FALSE; + if (mallocptr.is_empty()) return FALSE; + + browse_for_dir_struct data; + data.m_initval = p_out; + data.m_tofind = p_file_to_find; + + + BROWSEINFO bi= + { + p_parent, + 0, + 0, + p_title, + BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE | BIF_EDITBOX, + browse_proc, + reinterpret_cast(&data), + 0 + }; + + LPITEMIDLIST li = SHBrowseForFolder(&bi); + if (li == NULL) return FALSE; + BOOL state = SHGetPathFromIDList(li,p_out); + mallocptr->Free(li); + return state; +} + +BOOL SHARED_EXPORT uBrowseForFolder(HWND parent,const char * p_title,pfc::string_base & out) { + TRACK_CALL_TEXT("uBrowseForFolder"); + try { + if (UseVistaDialogs()) { + return Vista_BrowseForFolder(parent,p_title,out); + } + } catch(pfc::exception_not_implemented const &) {} + + TCHAR temp[MAX_PATH]; + pfc::stringToBuffer(temp,dTEXT(out)); + BOOL rv = BrowseForFolderHelper(parent,dTEXT(p_title),temp,0); + if (rv) { + out = pfc::stringcvt::string_utf8_from_os(temp,_countof(temp)); + } + return rv; +} + +BOOL SHARED_EXPORT uBrowseForFolderWithFile(HWND parent,const char * title,pfc::string_base & out,const char * p_file_to_find) +{ + TRACK_CALL_TEXT("uBrowseForFolderWithFile"); + TCHAR temp[MAX_PATH]; + pfc::stringToBuffer(temp,dTEXT(out)); + BOOL rv = BrowseForFolderHelper(parent,dTEXT(title),temp,dTEXT(p_file_to_find)); + if (rv) { + out = pfc::stringcvt::string_utf8_from_os(temp,_countof(temp)); + } + return rv; +} + + +puGetOpenFileNameMultiResult SHARED_EXPORT uBrowseForFolderEx(HWND parent,const char * title, const char * initPath) { + TRACK_CALL_TEXT("uBrowseForFolderEx"); + try { + if (UseVistaDialogs()) { + return Vista_BrowseForFolderEx(parent,title, initPath); + } + } catch(pfc::exception_not_implemented const &) {} + + pfc::string8 temp; + if (initPath) temp = initPath; + if (!uBrowseForFolder(parent, title, temp)) return NULL; + pfc::ptrholder_t result = new uGetOpenFileNameMultiResult_impl; + result->AddItem(temp); + return result.detach(); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/shared/filedialogs.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/shared/filedialogs.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,7 @@ +class uGetOpenFileNameMultiResult_impl : public uGetOpenFileNameMultiResult { + pfc::list_t m_data; +public: + void AddItem(pfc::stringp param) {m_data.add_item(param);} + t_size get_count() const {return m_data.get_count();} + void get_item_ex(const char * & out,t_size n) const {out = m_data[n].ptr();} +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/shared/filedialogs_vista.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/shared/filedialogs_vista.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,497 @@ +#include "shared.h" +#include "filedialogs.h" +#include +#include +#include +#include +#include + +#define dTEXT(X) pfc::stringcvt::string_os_from_utf8(X) + +class FilterSpec { +public: + void clear() { + m_types.set_size(0); m_strings.remove_all(); + } + void Sanity() { + if ( GetCount() > 200 ) SetAllFiles(); + } + void SetAllFiles() { + FromString( "All files|*.*" ); + } + void FromString(const char * in) { + clear(); + if (in == NULL) return; + pfc::chain_list_v2_t types; + + for(t_size inWalk = 0; ; ) { + + t_size base1 = inWalk; + t_size delta1 = ScanForSeparator(in+base1); + t_size base2 = base1 + delta1; + if (in[base2] == 0) break; + ++base2; + t_size delta2 = ScanForSeparator(in+base2); + if (delta1 > 0 && delta2 > 0) { + COMDLG_FILTERSPEC spec; + spec.pszName = MakeString(in+base1,delta1); + spec.pszSpec = MakeString(in+base2,delta2); + types.add_item(spec); + } + inWalk = base2 + delta2; + if (in[inWalk] == 0) break; + ++inWalk; + } + + pfc::list_to_array(m_types,types); + } + + t_size GetCount() const {return m_types.get_count();} + const COMDLG_FILTERSPEC * GetPtr() const {return m_types.get_ptr();} +private: + static t_size ScanForSeparator(const char * in) { + for(t_size walk = 0; ; ++walk) { + if (in[walk] == 0 || in[walk] == '|') return walk; + } + } + WCHAR * MakeString(const char * in, t_size inLen) { + t_size len = pfc::stringcvt::estimate_utf8_to_wide(in,inLen); + WCHAR* str = AllocString(len); + pfc::stringcvt::convert_utf8_to_wide(str,len,in,inLen); + return str; + } + WCHAR * AllocString(t_size size) { + auto iter = m_strings.insert_last(); + iter->set_size(size); + return iter->get_ptr(); + } + pfc::chain_list_v2_t > m_strings; + pfc::array_t m_types; +}; + +static HRESULT AddOptionsHelper(pfc::com_ptr_t dlg, DWORD opts) { + DWORD options; + HRESULT state; + if (FAILED(state = dlg->GetOptions(&options))) return state; + options |= opts; + if (FAILED(state = dlg->SetOptions( options ))) return state; + return S_OK; +} + +namespace { + + // SPECIAL + // Deal with slow or nonworking net shares, do not lockup the calling thread in such cases, just split away + // Particularly relevant to net shares referred by raw IP, these get us stuck for a long time + class PDNArg_t : public pfc::refcounted_object_root { + public: + CoTaskMemObject m_idList; + pfc::string8 m_path; + HRESULT m_result; + }; + + static unsigned CALLBACK PDNProc(void * arg) { + pfc::refcounted_object_ptr_t ptr; ptr.attach( reinterpret_cast( arg ) ); + CoInitialize(0); + + SFGAOF dummy = {}; + ptr->m_result = SHParseDisplayName(dTEXT(ptr->m_path),NULL,&ptr->m_idList.m_ptr,0,&dummy); + + CoUninitialize(); + + return 0; + } +} + +static HRESULT SetFolderHelper(pfc::com_ptr_t dlg, const char * folderPath) { + CoTaskMemObject idList; + + // Do SHParseDisplayName() off-thread as it is known to lock up on bad net share references + pfc::refcounted_object_ptr_t ptr = new PDNArg_t(); + ptr->m_path = folderPath; + ptr->m_result = E_FAIL; + HANDLE hThread = (HANDLE)_beginthreadex(NULL, 0, PDNProc, reinterpret_cast(ptr._duplicate_ptr()), 0, NULL); + DWORD status = WaitForSingleObject( hThread, 3000 ); + CloseHandle(hThread); + if (status != WAIT_OBJECT_0) return E_FAIL; + if (FAILED(ptr->m_result)) return ptr->m_result; + + pfc::com_ptr_t item; + HRESULT state; + if (FAILED(state = SHCreateShellItem(NULL,NULL,ptr->m_idList.m_ptr,item.receive_ptr()))) return state; + return dlg->SetFolder(item.get_ptr()); +} + +namespace { + class _EH { + public: + void operator<<(HRESULT hr) { + if (FAILED(hr)) throw exception_com(hr); + } + }; + static _EH EH; +}; + +BOOL Vista_GetOpenFileName(HWND parent,const char * p_ext_mask,unsigned def_ext_mask,const char * p_def_ext,const char * p_title,const char * p_directory,pfc::string_base & p_filename,BOOL b_save) { + modal_dialog_scope modalScope(parent); + + pfc::com_ptr_t dlg; + + if (b_save) { + if (FAILED(CoCreateInstance(__uuidof(FileSaveDialog), NULL, CLSCTX_ALL, IID_IFileSaveDialog, (void**) dlg.receive_ptr()))) throw pfc::exception_not_implemented(); + } else { + if (FAILED(CoCreateInstance(__uuidof(FileOpenDialog), NULL, CLSCTX_ALL, IID_IFileOpenDialog, (void**) dlg.receive_ptr()))) throw pfc::exception_not_implemented(); + } + + { + FilterSpec spec; spec.FromString(p_ext_mask); + spec.Sanity(); + if (FAILED(dlg->SetFileTypes((UINT)spec.GetCount(),spec.GetPtr()))) return FALSE; + if (def_ext_mask < spec.GetCount()) { + if (FAILED(dlg->SetFileTypeIndex(def_ext_mask + 1))) return FALSE; + } + } + if (p_def_ext != NULL) { + if (FAILED(dlg->SetDefaultExtension(dTEXT(p_def_ext)))) return FALSE; + } + if (p_title != NULL) { + if (FAILED(dlg->SetTitle(dTEXT(p_title)))) return FALSE; + } + + if (!p_filename.is_empty()) { + pfc::string path(p_filename); + pfc::string fn = pfc::io::path::getFileName(path); + pfc::string parent = pfc::io::path::getParent(path); + if (!parent.isEmpty()) SetFolderHelper(dlg,parent.ptr()); + dlg->SetFileName(dTEXT(fn.ptr())); + } else if (p_directory != NULL) { + SetFolderHelper(dlg,p_directory); + } + + if (FAILED(AddOptionsHelper(dlg, FOS_FORCEFILESYSTEM))) return FALSE; + + if (FAILED( dlg->Show(parent) ) ) return FALSE; + + { + pfc::com_ptr_t result; + if (FAILED(dlg->GetResult(result.receive_ptr()))) return FALSE; + + CoTaskMemObject nameBuf; + if (FAILED(result->GetDisplayName(SIGDN_FILESYSPATH,&nameBuf.m_ptr))) return FALSE; + + p_filename = pfc::stringcvt::string_utf8_from_os_ex( nameBuf.m_ptr ); + } + return TRUE; +} + +BOOL Vista_GetOpenFileNameMulti(HWND parent,const char * p_ext_mask,unsigned def_ext_mask,const char * p_def_ext,const char * p_title,const char * p_directory,pfc::ptrholder_t & out) { + modal_dialog_scope modalScope(parent); + + pfc::com_ptr_t dlg; + if (FAILED(CoCreateInstance(__uuidof(FileOpenDialog), NULL, CLSCTX_ALL, IID_IFileOpenDialog, (void**) dlg.receive_ptr()))) throw pfc::exception_not_implemented(); + + { + FilterSpec spec; spec.FromString(p_ext_mask); + spec.Sanity(); + if (FAILED(dlg->SetFileTypes((UINT)spec.GetCount(),spec.GetPtr()))) return FALSE; + if (def_ext_mask < spec.GetCount()) { + if (FAILED(dlg->SetFileTypeIndex(def_ext_mask + 1))) return FALSE; + } + } + if (p_def_ext != NULL) { + if (FAILED(dlg->SetDefaultExtension(dTEXT(p_def_ext)))) return FALSE; + } + if (p_title != NULL) { + if (FAILED(dlg->SetTitle(dTEXT(p_title)))) return FALSE; + } + + if (p_directory != NULL) { + SetFolderHelper(dlg,p_directory); + } + + if (FAILED(AddOptionsHelper(dlg, FOS_ALLOWMULTISELECT | FOS_FORCEFILESYSTEM))) return FALSE; + + if (FAILED( dlg->Show(parent) ) ) return FALSE; + + { + pfc::ptrholder_t result = new uGetOpenFileNameMultiResult_impl; + pfc::com_ptr_t results; + if (FAILED(dlg->GetResults(results.receive_ptr()))) return FALSE; + DWORD total; + if (FAILED(results->GetCount(&total))) return FALSE; + for(DWORD itemWalk = 0; itemWalk < total; ++itemWalk) { + pfc::com_ptr_t item; + if (SUCCEEDED(results->GetItemAt(itemWalk,item.receive_ptr()))) { + CoTaskMemObject nameBuf; + if (FAILED(item->GetDisplayName(SIGDN_FILESYSPATH,&nameBuf.m_ptr))) return FALSE; + + result->AddItem(pfc::stringcvt::string_utf8_from_os_ex( nameBuf.m_ptr ) ); + + } + } + + if (result->get_count() == 0) return FALSE; + + out = result.detach(); + } + + return TRUE; +} +#if 0 +namespace { + class CFileDialogEvents_LocateFile : public IFileDialogEvents { + public: + CFileDialogEvents_LocateFile(pfc::stringp tofind) : m_tofind(tofind) {} + HRESULT STDMETHODCALLTYPE OnFileOk(IFileDialog *pfd) {return S_OK;} + + HRESULT STDMETHODCALLTYPE OnFolderChanging( IFileDialog *pfd, IShellItem *psiFolder) {return S_OK;} + + HRESULT STDMETHODCALLTYPE OnFolderChange( IFileDialog *pfd ) { + //pfd->GetFolder(); + return S_OK; + } + + HRESULT STDMETHODCALLTYPE OnSelectionChange( IFileDialog *pfd ) {return S_OK;} + + HRESULT STDMETHODCALLTYPE OnShareViolation( IFileDialog *pfd, IShellItem *psi, FDE_SHAREVIOLATION_RESPONSE *pResponse) { return S_OK; } + + HRESULT STDMETHODCALLTYPE OnTypeChange( IFileDialog *pfd ) {return S_OK; } + + HRESULT STDMETHODCALLTYPE OnOverwrite( IFileDialog *pfd, IShellItem *psi, FDE_OVERWRITE_RESPONSE *pResponse) {return S_OK; } + + private: + const pfc::string m_tofind; + }; + +} +#endif +BOOL Vista_BrowseForFolder(HWND parent, const char * p_title, pfc::string_base & path) { + modal_dialog_scope modalScope(parent); + pfc::com_ptr_t dlg; + if (FAILED(CoCreateInstance(__uuidof(FileOpenDialog), NULL, CLSCTX_ALL, IID_IFileOpenDialog, (void**) dlg.receive_ptr()))) throw pfc::exception_not_implemented(); + + if (p_title != NULL) { + if (FAILED(dlg->SetTitle(dTEXT(p_title)))) return FALSE; + } + + if (FAILED(AddOptionsHelper(dlg, FOS_PICKFOLDERS | FOS_FORCEFILESYSTEM))) return FALSE; + + if (!path.is_empty()) { + SetFolderHelper(dlg,path); + } + + if (FAILED( dlg->Show(parent) ) ) return FALSE; + + { + pfc::com_ptr_t result; + if (FAILED(dlg->GetResult(result.receive_ptr()))) return FALSE; + + CoTaskMemObject nameBuf; + if (FAILED(result->GetDisplayName(SIGDN_FILESYSPATH,&nameBuf.m_ptr))) return FALSE; + + path = pfc::stringcvt::string_utf8_from_os_ex( nameBuf.m_ptr ); + } + return TRUE; +} + + +__inline HRESULT mySHLoadLibraryFromItem( + __in IShellItem *psiLibrary, + __in DWORD grfMode, + __in REFIID riid, + __deref_out void **ppv +) +{ + *ppv = NULL; + IShellLibrary *plib; + + HRESULT hr = CoCreateInstance( + CLSID_ShellLibrary, + NULL, + CLSCTX_INPROC_SERVER, + IID_PPV_ARGS(&plib)); + + if (SUCCEEDED(hr)) + { + hr = plib->LoadLibraryFromItem (psiLibrary, grfMode); + if (SUCCEEDED(hr)) + { + hr = plib->QueryInterface (riid, ppv); + } + plib->Release(); + } + return hr; +} + +// +// from shobjidl.h +// +__inline HRESULT mySHLoadLibraryFromKnownFolder( + __in REFKNOWNFOLDERID kfidLibrary, + __in DWORD grfMode, + __in REFIID riid, + __deref_out void **ppv) +{ + *ppv = NULL; + IShellLibrary *plib; + HRESULT hr = CoCreateInstance( + CLSID_ShellLibrary, + NULL, + CLSCTX_INPROC_SERVER, + IID_PPV_ARGS(&plib)); + if (SUCCEEDED(hr)) + { + hr = plib->LoadLibraryFromKnownFolder(kfidLibrary, grfMode); + if (SUCCEEDED(hr)) + { + hr = plib->QueryInterface(riid, ppv); + } + plib->Release(); + } + return hr; +} + +puGetOpenFileNameMultiResult Vista_BrowseForFolderEx(HWND parent,const char * p_title, const char * initPath) { + try { + modal_dialog_scope modalScope(parent); + pfc::com_ptr_t dlg; + if (FAILED(CoCreateInstance(__uuidof(FileOpenDialog), NULL, CLSCTX_ALL, IID_IFileOpenDialog, (void**) dlg.receive_ptr()))) throw pfc::exception_not_implemented(); + + if (p_title != NULL) { + EH << dlg->SetTitle(dTEXT(p_title)); + } + + EH << AddOptionsHelper(dlg, FOS_ALLOWMULTISELECT | FOS_PICKFOLDERS); + + if (initPath && *initPath) { + SetFolderHelper(dlg,initPath); + } + + EH << dlg->Show(parent); + + pfc::ptrholder_t result = new uGetOpenFileNameMultiResult_impl; + pfc::com_ptr_t results; + EH << dlg->GetResults(results.receive_ptr()); + DWORD total; + EH << results->GetCount(&total); + CoTaskMemObject nameBuf; + for(DWORD itemWalk = 0; itemWalk < total; ++itemWalk) { + pfc::com_ptr_t item; + EH << results->GetItemAt(itemWalk,item.receive_ptr()); + if (SUCCEEDED(item->GetDisplayName(SIGDN_FILESYSPATH,nameBuf.Receive()))) { + result->AddItem(pfc::stringcvt::string_utf8_from_os_ex( nameBuf.m_ptr ) ); + } else { + pfc::com_ptr_t library; + if (SUCCEEDED(mySHLoadLibraryFromItem(item.get_ptr(), STGM_READ, IID_IShellLibrary, (void**)library.receive_ptr()))) { + pfc::com_ptr_t subFolders; + EH << library->GetFolders(LFF_FORCEFILESYSTEM, IID_IShellItemArray, (void**)subFolders.receive_ptr()); + DWORD subTotal; + EH << subFolders->GetCount(&subTotal); + for(DWORD subWalk = 0; subWalk < subTotal; ++subWalk) { + pfc::com_ptr_t subItem; + EH << subFolders->GetItemAt(subWalk,subItem.receive_ptr()); + EH << subItem->GetDisplayName(SIGDN_FILESYSPATH,nameBuf.Receive()); + result->AddItem(pfc::stringcvt::string_utf8_from_os_ex( nameBuf.m_ptr ) ); + } + } + } + } + if (result->GetCount() == 0) return NULL; + return result.detach(); + } catch(exception_com const &) { + return NULL; + } +} + +static bool GetLegacyKnownFolder(int & out, REFKNOWNFOLDERID id) { + if (id == FOLDERID_Music) { + out = CSIDL_MYMUSIC; + return true; + } else if (id == FOLDERID_Pictures) { + out = CSIDL_MYPICTURES; + return true; + } else if (id == FOLDERID_Videos) { + out = CSIDL_MYVIDEO; + return true; + } else if (id == FOLDERID_Documents) { + out = CSIDL_MYDOCUMENTS; + return true; + } else if (id == FOLDERID_Desktop) { + out = CSIDL_DESKTOP; + return true; + } else { + return false; + } +} + +puGetOpenFileNameMultiResult SHARED_EXPORT uEvalKnownFolder(REFKNOWNFOLDERID id) { + try { + pfc::com_ptr_t library; + EH << mySHLoadLibraryFromKnownFolder(id, STGM_READ, IID_IShellLibrary, (void**)library.receive_ptr()); + + pfc::com_ptr_t subFolders; + EH << library->GetFolders(LFF_FORCEFILESYSTEM, IID_IShellItemArray, (void**)subFolders.receive_ptr()); + + pfc::ptrholder_t result = new uGetOpenFileNameMultiResult_impl; + + DWORD subTotal; + EH << subFolders->GetCount(&subTotal); + CoTaskMemObject nameBuf; + for(DWORD subWalk = 0; subWalk < subTotal; ++subWalk) { + pfc::com_ptr_t subItem; + EH << subFolders->GetItemAt(subWalk,subItem.receive_ptr()); + EH << subItem->GetDisplayName(SIGDN_FILESYSPATH,nameBuf.Receive()); + result->AddItem(pfc::stringcvt::string_utf8_from_os_ex( nameBuf.m_ptr ) ); + } + if (result->get_count() == 0) return NULL; + return result.detach(); + } catch(exception_com const &) { + //failed + } + + + try { + CComPtr mgr; CComPtr folder; CoTaskMemObject path; + EH << CoCreateInstance(__uuidof(KnownFolderManager), nullptr, CLSCTX_ALL, IID_IKnownFolderManager, (void**)&mgr.p); + EH << mgr->GetFolder(id, &folder.p); + EH << folder->GetPath(0, &path.m_ptr); + + pfc::ptrholder_t result = new uGetOpenFileNameMultiResult_impl; + result->AddItem(pfc::stringcvt::string_utf8_from_os(path.m_ptr)); + return result.detach(); + } catch (exception_com const &) { + + } + + //FALLBACK + + + + { + int legacyID; + if (GetLegacyKnownFolder(legacyID, id)) { + try { + TCHAR path[MAX_PATH+16] = {}; + EH << SHGetFolderPath(NULL, legacyID, NULL, SHGFP_TYPE_CURRENT, path); + path[_countof(path)-1] = 0; + pfc::ptrholder_t result = new uGetOpenFileNameMultiResult_impl; + result->AddItem(pfc::stringcvt::string_utf8_from_os_ex( path ) ); + return result.detach(); + } catch(exception_com const &) { + //failed; + } + } + } +#if 0 // Vista code path - uninteresting, XP shit still needs to be supported, SHGetKnownFolderPath() does not exist on XP + try { + pfc::ptrholder_t result = new uGetOpenFileNameMultiResult_impl; + CoTaskMemObject nameBuf; + EH << SHGetKnownFolderPath(id, 0, NULL, nameBuf.Receive()); + result->AddItem(pfc::stringcvt::string_utf8_from_os_ex( nameBuf.m_ptr ) ); + return result.detach(); + } catch(exception_com const &) { + //failed + } +#endif + return NULL; //failure +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/shared/font_description.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/shared/font_description.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,126 @@ +#include "shared.h" + + +static unsigned query_dpi() +{ + unsigned ret; + HDC dc = GetDC(0); + ret = GetDeviceCaps(dc,LOGPIXELSY); + ReleaseDC(0,dc); + return ret; +} + + +#if 0 +struct t_font_description +{ + enum {m_facename_length = LF_FACESIZE*2}; + + t_uint32 m_height; + t_uint32 m_weight; + t_uint8 m_italic; + t_uint8 m_charset; + char m_facename[m_facename_length]; +} +#endif + +static void make_logfont(LOGFONT & p_logfont,const t_font_description & p_desc) +{ + p_logfont.lfHeight = - MulDiv(p_desc.m_height, query_dpi(), t_font_description::m_height_dpi); + p_logfont.lfWidth = 0; + p_logfont.lfEscapement = 0; + p_logfont.lfOrientation = 0; + p_logfont.lfWeight = p_desc.m_weight; + p_logfont.lfItalic = p_desc.m_italic; + p_logfont.lfUnderline = 0; + p_logfont.lfStrikeOut = 0; + p_logfont.lfCharSet = p_desc.m_charset; + p_logfont.lfOutPrecision = 3; + p_logfont.lfClipPrecision = 2; + p_logfont.lfQuality = 1; + p_logfont.lfPitchAndFamily = 34; + pfc::stringToBuffer(p_logfont.lfFaceName,pfc::stringcvt::string_os_from_utf8(p_desc.m_facename,tabsize(p_desc.m_facename))); +} + +static void make_description(t_font_description & p_desc,const LOGFONT & p_logfont) +{ + p_desc.m_height = MulDiv(pfc::abs_t(p_logfont.lfHeight), t_font_description::m_height_dpi, query_dpi()); + p_desc.m_weight = p_logfont.lfWeight; + p_desc.m_italic = p_logfont.lfItalic; + p_desc.m_charset = p_logfont.lfCharSet; + pfc::stringToBuffer(p_desc.m_facename,pfc::stringcvt::string_utf8_from_os(p_logfont.lfFaceName,tabsize(p_logfont.lfFaceName))); +} + +HFONT SHARED_EXPORT t_font_description::create() const +{ + LOGFONT temp; + make_logfont(temp,*this); + return CreateFontIndirect(&temp); +} + +static UINT_PTR CALLBACK choose_font_hook(HWND wnd,UINT msg,WPARAM wp,LPARAM lp) +{ + switch(msg) + { + case WM_INITDIALOG: + { + CHOOSEFONT * cf = reinterpret_cast(lp); + reinterpret_cast(cf->lCustData)->initialize(FindOwningPopup(wnd)); + } + return 0; + default: + return 0; + } +} + +bool SHARED_EXPORT t_font_description::popup_dialog(HWND p_parent) +{ + modal_dialog_scope scope; + + LOGFONT logfont; + make_logfont(logfont,*this); + + CHOOSEFONT cf = {}; + cf.lStructSize = sizeof(cf); + cf.hwndOwner = p_parent; + cf.lpLogFont = &logfont; + cf.Flags = CF_SCREENFONTS|CF_FORCEFONTEXIST|CF_INITTOLOGFONTSTRUCT|CF_ENABLEHOOK; + cf.nFontType = SCREEN_FONTTYPE; + cf.lCustData = reinterpret_cast(&scope); + cf.lpfnHook = choose_font_hook; + if (ChooseFont(&cf)) + { + make_description(*this,logfont); + return true; + } + else return false; +} + + +void SHARED_EXPORT t_font_description::from_font(HFONT p_font) +{ + LOGFONT logfont; + PFC_ASSERT_SUCCESS( GetObject((HGDIOBJ) p_font, sizeof(logfont), &logfont) != 0 ); + make_description(*this,logfont); +} + +t_font_description SHARED_EXPORT t_font_description::g_from_font(HFONT p_font) +{ + t_font_description temp; + temp.from_font(p_font); + return temp; +} + + +t_font_description SHARED_EXPORT t_font_description::g_from_logfont(LOGFONT const & lf) { + t_font_description ret; make_description(ret, lf); return ret; +} + +t_font_description SHARED_EXPORT t_font_description::g_from_system(int id) { + LOGFONT lf; + if (FAILED( GetThemeSysFont(NULL, id, &lf) ) ) { + PFC_ASSERT(!"Should not get here!"); + return g_from_font( (HFONT) GetStockObject(DEFAULT_GUI_FONT) ); + } + return g_from_logfont(lf); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/shared/minidump.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/shared/minidump.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,251 @@ +#include "shared.h" +#include + +#ifdef _M_ARM64EC +typedef ARM64EC_NT_CONTEXT myCONTEXT; +#else +typedef CONTEXT myCONTEXT; +#endif +struct DumpState { + int state; + myCONTEXT*context; +}; + +__declspec(noinline) static bool safeRead(volatile const void* addr, size_t& dest) +{ + __try { + dest = *(const volatile size_t*)addr; + return true; + } + __except (1) { + return false; + } +} + +__declspec(noinline) static bool safeTestReadAccess(volatile const void* addr) +{ + size_t dummy; + return safeRead(addr, dummy); +} + +#if defined(_M_ARM64) || defined(_M_ARM64EC) + +BOOL WINAPI MiniDumpCallback(PVOID CallbackParam, + const PMINIDUMP_CALLBACK_INPUT CallbackInput, + PMINIDUMP_CALLBACK_OUTPUT CallbackOutput) +{ + static const unsigned STACK_SEARCH_SIZE = 0x400; + static const unsigned MEM_BLOCK_SIZE = 0x400; + + if (CallbackInput->CallbackType == MemoryCallback) { + // Called to get user defined blocks of memory to write until + // callback returns FALSE or CallbackOutput->MemorySize == 0. + + DumpState* ds = (DumpState*)CallbackParam; + switch (ds->state) { + // Save memory referenced by registers. + case 0: CallbackOutput->MemoryBase = ds->context->X0; ds->state++; break; + case 1: CallbackOutput->MemoryBase = ds->context->X1; ds->state++; break; + case 2: CallbackOutput->MemoryBase = ds->context->X2; ds->state++; break; + case 3: CallbackOutput->MemoryBase = ds->context->X3; ds->state++; break; + case 4: CallbackOutput->MemoryBase = ds->context->X4; ds->state++; break; + case 5: CallbackOutput->MemoryBase = ds->context->X5; ds->state++; break; + case 6: CallbackOutput->MemoryBase = ds->context->X6; ds->state++; break; + case 7: CallbackOutput->MemoryBase = ds->context->X7; ds->state++; break; + case 8: CallbackOutput->MemoryBase = ds->context->X8; ds->state++; break; + case 9: CallbackOutput->MemoryBase = ds->context->X9; ds->state++; break; + case 10: CallbackOutput->MemoryBase = ds->context->X10; ds->state++; break; + case 11: CallbackOutput->MemoryBase = ds->context->X11; ds->state++; break; + case 12: CallbackOutput->MemoryBase = ds->context->X12; ds->state++; break; +#ifndef _M_ARM64EC + case 13: CallbackOutput->MemoryBase = ds->context->X13; ds->state++; break; + case 14: CallbackOutput->MemoryBase = ds->context->X14; ds->state++; break; + case 15: CallbackOutput->MemoryBase = ds->context->X15; ds->state++; break; + case 16: CallbackOutput->MemoryBase = ds->context->X16; ds->state++; break; + case 17: CallbackOutput->MemoryBase = ds->context->X17; ds->state++; break; + case 18: CallbackOutput->MemoryBase = ds->context->X18; ds->state++; break; + case 19: CallbackOutput->MemoryBase = ds->context->X19; ds->state++; break; + case 20: CallbackOutput->MemoryBase = ds->context->X20; ds->state++; break; + case 21: CallbackOutput->MemoryBase = ds->context->X21; ds->state++; break; + case 22: CallbackOutput->MemoryBase = ds->context->X22; ds->state++; break; + case 23: CallbackOutput->MemoryBase = ds->context->X23; ds->state++; break; + case 24: CallbackOutput->MemoryBase = ds->context->X24; ds->state++; break; + case 25: CallbackOutput->MemoryBase = ds->context->X25; ds->state++; break; + case 26: CallbackOutput->MemoryBase = ds->context->X26; ds->state++; break; + case 27: CallbackOutput->MemoryBase = ds->context->X27; ds->state++; break; + case 28: CallbackOutput->MemoryBase = ds->context->X28; ds->state++; break; +#endif + + // Save memory referenced by values in stack. + default: + if (ds->state < 0x1000) + ds->state = 0x1000; + + size_t addr; + do { + if (ds->state > 0x1000 + STACK_SEARCH_SIZE) + return FALSE; + + if (!safeRead((void*)((ds->context->Sp & ~7) + ds->state - 0x1000), addr)) + return FALSE; + + ds->state += 4; + } while (addr < 0x1000 || !safeTestReadAccess((void*)addr)); + + CallbackOutput->MemoryBase = addr; + break; + } + + if (CallbackOutput->MemoryBase >= MEM_BLOCK_SIZE / 2) + CallbackOutput->MemoryBase -= MEM_BLOCK_SIZE / 2; + CallbackOutput->MemorySize = MEM_BLOCK_SIZE; + + // No need to perform additional checks here, the minidump engine + // safely clips the addresses to valid memory pages only. + // Also seems to apply for overlapped areas etc. + } + + return TRUE; +} + +#elif defined(_M_IX86) + +BOOL WINAPI MiniDumpCallback(PVOID CallbackParam, + const PMINIDUMP_CALLBACK_INPUT CallbackInput, + PMINIDUMP_CALLBACK_OUTPUT CallbackOutput) +{ + static const unsigned STACK_SEARCH_SIZE = 0x400; + static const unsigned MEM_BLOCK_SIZE = 0x400; + + if (CallbackInput->CallbackType == MemoryCallback) { + // Called to get user defined blocks of memory to write until + // callback returns FALSE or CallbackOutput->MemorySize == 0. + + DumpState* ds = (DumpState*)CallbackParam; + switch (ds->state) { + // Save memory referenced by registers. + case 0: CallbackOutput->MemoryBase = ds->context->Eax; ds->state++; break; + case 1: CallbackOutput->MemoryBase = ds->context->Ebx; ds->state++; break; + case 2: CallbackOutput->MemoryBase = ds->context->Ecx; ds->state++; break; + case 3: CallbackOutput->MemoryBase = ds->context->Edx; ds->state++; break; + case 4: CallbackOutput->MemoryBase = ds->context->Esi; ds->state++; break; + case 5: CallbackOutput->MemoryBase = ds->context->Edi; ds->state++; break; + case 6: CallbackOutput->MemoryBase = ds->context->Ebp; ds->state++; break; + case 7: CallbackOutput->MemoryBase = ds->context->Esp; ds->state++; break; + case 8: CallbackOutput->MemoryBase = ds->context->Eip; ds->state++; break; + + // Save memory referenced by values in stack. + default: + if (ds->state < 0x1000) + ds->state = 0x1000; + + size_t addr; + do { + if (ds->state > 0x1000 + STACK_SEARCH_SIZE) + return FALSE; + + if (!safeRead((void*)((ds->context->Esp & ~3) + ds->state - 0x1000), addr)) + return FALSE; + + ds->state += 4; + } while (addr < 0x1000 || !safeTestReadAccess((void*)addr)); + + CallbackOutput->MemoryBase = addr; + break; + } + + if (CallbackOutput->MemoryBase >= MEM_BLOCK_SIZE / 2) + CallbackOutput->MemoryBase -= MEM_BLOCK_SIZE / 2; + CallbackOutput->MemorySize = MEM_BLOCK_SIZE; + + // No need to perform additional checks here, the minidump engine + // safely clips the addresses to valid memory pages only. + // Also seems to apply for overlapped areas etc. + } + + return TRUE; +} + +#elif defined(_M_X64) + +BOOL WINAPI MiniDumpCallback(PVOID CallbackParam, + const PMINIDUMP_CALLBACK_INPUT CallbackInput, + PMINIDUMP_CALLBACK_OUTPUT CallbackOutput) +{ + static const unsigned STACK_SEARCH_SIZE = 0x400; + static const unsigned MEM_BLOCK_SIZE = 0x400; + + if (CallbackInput->CallbackType == MemoryCallback) { + // Called to get user defined blocks of memory to write until + // callback returns FALSE or CallbackOutput->MemorySize == 0. + + DumpState* ds = (DumpState*)CallbackParam; + switch (ds->state) { + // Save memory referenced by registers. + case 0: CallbackOutput->MemoryBase = ds->context->Rax; ds->state++; break; + case 1: CallbackOutput->MemoryBase = ds->context->Rbx; ds->state++; break; + case 2: CallbackOutput->MemoryBase = ds->context->Rcx; ds->state++; break; + case 3: CallbackOutput->MemoryBase = ds->context->Rdx; ds->state++; break; + case 4: CallbackOutput->MemoryBase = ds->context->Rsi; ds->state++; break; + case 5: CallbackOutput->MemoryBase = ds->context->Rdi; ds->state++; break; + case 6: CallbackOutput->MemoryBase = ds->context->Rsp; ds->state++; break; + case 7: CallbackOutput->MemoryBase = ds->context->Rbp; ds->state++; break; + case 8: CallbackOutput->MemoryBase = ds->context->R8; ds->state++; break; + case 9: CallbackOutput->MemoryBase = ds->context->R9; ds->state++; break; + case 10: CallbackOutput->MemoryBase = ds->context->R10; ds->state++; break; + case 11: CallbackOutput->MemoryBase = ds->context->R11; ds->state++; break; + case 12: CallbackOutput->MemoryBase = ds->context->R12; ds->state++; break; + case 13: CallbackOutput->MemoryBase = ds->context->R13; ds->state++; break; + case 14: CallbackOutput->MemoryBase = ds->context->R14; ds->state++; break; + case 15: CallbackOutput->MemoryBase = ds->context->R15; ds->state++; break; + + // Save memory referenced by values in stack. + default: + if (ds->state < 0x1000) + ds->state = 0x1000; + + size_t addr; + do { + if (ds->state > 0x1000 + STACK_SEARCH_SIZE) + return FALSE; + + if (!safeRead((void*)((ds->context->Rsp & ~7) + ds->state - 0x1000), addr)) + return FALSE; + + ds->state += 4; + } while (addr < 0x1000 || !safeTestReadAccess((void*)addr)); + + CallbackOutput->MemoryBase = addr; + break; + } + + if (CallbackOutput->MemoryBase >= MEM_BLOCK_SIZE / 2) + CallbackOutput->MemoryBase -= MEM_BLOCK_SIZE / 2; + CallbackOutput->MemorySize = MEM_BLOCK_SIZE; + + // No need to perform additional checks here, the minidump engine + // safely clips the addresses to valid memory pages only. + // Also seems to apply for overlapped areas etc. + } + + return TRUE; +} + +#endif // _M_X64 + + + + +BOOL WriteMiniDumpHelper(HANDLE hDump, LPEXCEPTION_POINTERS param) { + MINIDUMP_EXCEPTION_INFORMATION exception = {}; + exception.ThreadId = GetCurrentThreadId(); + exception.ExceptionPointers = param; + exception.ClientPointers = FALSE; + DumpState ds; + ds.state = 0; + ds.context = reinterpret_cast(param->ContextRecord); + MINIDUMP_CALLBACK_INFORMATION mci; + mci.CallbackRoutine = &MiniDumpCallback; + mci.CallbackParam = (void*)&ds; + return MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), hDump, (MINIDUMP_TYPE)(MiniDumpWithUnloadedModules), &exception, NULL, &mci); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/shared/modal_dialog.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/shared/modal_dialog.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,66 @@ +#include "shared.h" + +static DWORD g_main_thread = GetCurrentThreadId(); + +static t_modal_dialog_entry g_status = {0,false}; + +static bool TestMainThread() +{ + if (GetCurrentThreadId() == g_main_thread) return true; + OutputDebugString(TEXT("This function can be called only from main thread.\n")); + return false; +} + +HWND SHARED_EXPORT FindOwningPopup(HWND p_wnd) +{ + return pfc::findOwningPopup(p_wnd); +} + +void SHARED_EXPORT PokeWindow(HWND p_wnd) +{ + p_wnd = FindOwningPopup(p_wnd); + if (IsWindowEnabled(p_wnd)) + { +// SetForegroundWindow(p_wnd); + SetActiveWindow(p_wnd); + FlashWindow(p_wnd,FALSE); + } + else + { + HWND child = GetWindow(p_wnd,GW_ENABLEDPOPUP); + if (child != 0) + { +// SetForegroundWindow(child); + SetActiveWindow(child); + FlashWindow(child,FALSE); + } + } +} + +extern "C" { + void SHARED_EXPORT ModalDialog_Switch(t_modal_dialog_entry & p_entry) + { + if (TestMainThread()) + pfc::swap_t(p_entry,g_status); + } + + void SHARED_EXPORT ModalDialog_PokeExisting() + { + if (TestMainThread()) + { + if (g_status.m_in_use && g_status.m_wnd_to_poke != 0) + { + PokeWindow(g_status.m_wnd_to_poke); + MessageBeep(0); + } + } + } + + bool SHARED_EXPORT ModalDialog_CanCreateNew() + { + if (TestMainThread()) + return !g_status.m_in_use; + else + return false; + } +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/shared/shared-ARM64EC.lib Binary file foosdk/sdk/foobar2000/shared/shared-ARM64EC.lib has changed diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/shared/shared-Win32.lib Binary file foosdk/sdk/foobar2000/shared/shared-Win32.lib has changed diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/shared/shared-apple.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/shared/shared-apple.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,4 @@ +#pragma once + +bool uSetClipboardString(const char * ptr); +bool uGetClipboardString(pfc::string_base & out); diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/shared/shared-apple.mm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/shared/shared-apple.mm Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,66 @@ +#include "shared.h" +#include "shared-apple.h" + +#import + +bool uSetClipboardString(const char * str) { + @autoreleasepool { + @try { + NSPasteboard * pb = [NSPasteboard generalPasteboard]; + [pb clearContents]; + [pb setString: [NSString stringWithUTF8String: str] forType:NSPasteboardTypeString]; + return true; + } @catch (NSException *) { + + } + } + return false; +} + +bool uGetClipboardString(pfc::string_base & out) { + bool rv = false; + @autoreleasepool { + NSPasteboard * pb = [NSPasteboard generalPasteboard]; + NSString * str = [pb stringForType: NSPasteboardTypeString]; + if ( str != nil ) { + out = str.UTF8String; + rv = true; + } + } + return rv; +} + +static void wrapNoExcept(std::function f) noexcept {f();} + +void fb2k::crashOnException(std::function f, const char * context) { +#if 0 + auto fail = [context] ( const char * msg ) { + if (context) { + fb2k::crashWithMessage(pfc::format(context, ": ", msg)); + } else { + fb2k::crashWithMessage(msg); + } + }; + try { + @autoreleasepool { + @try { + f(); + } @catch(NSException * e) { + auto header = pfc::format("NSException: ", e.name.UTF8String, " reason: ", e.reason.UTF8String ); + uAddDebugEvent( header ); + uAddDebugEvent("Stack:"); + for(NSString * str in e.callStackSymbols ) { + uAddDebugEvent(str.UTF8String); + } + fail(header); + } + } + } catch(std::exception const & e) { + fail(pfc::format("C++ exception: ", e.what())); + } catch(...) { + fail("Invalid exception"); + } +#else + wrapNoExcept(f); +#endif +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/shared/shared-nix.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/shared/shared-nix.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,212 @@ +#include "shared.h" +#include +#include +#include + +// foobar2000 SDK project method... bah +namespace foobar2000_io { + PFC_NORETURN void nix_io_op_fail(); +} +using namespace foobar2000_io; + +namespace { + class uFindFileImpl : public uFindFile { + public: + uFindFileImpl ( DIR * dir ) : m_dir(dir) {} + bool FindNext() override { + m_entry = readdir(m_dir); + return m_entry != NULL; + } + const char * GetFileName() override { + return m_entry->d_name; + } + bool IsDirectory() override { + return m_entry->d_type == DT_DIR; + } + ~uFindFileImpl() { + closedir(m_dir); + } + private: + dirent * m_entry; + + DIR * m_dir; + }; + + class uFindFileFiltered : public uFindFile { + public: + uFindFileFiltered( DIR * dir, const char * wc ) : m_impl(dir), m_wc(wc) {} + bool FindNext() override { + for( ;; ) { + if (!m_impl.FindNext()) return false; + if ( testWC() ) return true; + } + } + const char * GetFileName() override { + return m_impl.GetFileName(); + } + bool IsDirectory() override { + return m_impl.IsDirectory(); + } + bool testWC() { + return wildcard_helper::test(GetFileName(), m_wc); + } + + uFindFileImpl m_impl; + const pfc::string8 m_wc; + }; +} + +puFindFile uFindFirstFile(const char * path) { + + if ( wildcard_helper::has_wildcards( path ) ) { + size_t idx = pfc::scan_filename(path); + + try { + DIR * dir = opendir( pfc::string8(path, idx) ); + if (dir == NULL) nix_io_op_fail(); + try { + uFindFile * ff; + try { + ff = new uFindFileFiltered(dir, path + idx); + } catch(...) { closedir( dir ); throw; } + if (ff->FindNext()) return ff; + delete ff; + return NULL; + } catch(...) { closedir( dir ); throw; } + } catch(...) {return NULL;} + + } + + try { + DIR * dir = opendir( path ); + if (dir == NULL) nix_io_op_fail(); + try { + uFindFile * ff; + try { + ff = new uFindFileImpl(dir); + } catch(...) { closedir( dir ); throw; } + if (ff->FindNext()) return ff; + delete ff; + return NULL; + } catch(...) { closedir( dir ); throw; } + } catch(...) {return NULL;} +} + +pfc::string8 uStringPrintf(const char * fmt, ...) { + pfc::string8 ret; + va_list list; + va_start(list,fmt); + uPrintfV(ret,fmt,list); + va_end(list); + return ret; +} + +void uPrintfV(pfc::string_base & out,const char * fmt,va_list arglist) { + pfc::string_printf_here_va(out, fmt, arglist); +} + +void uPrintf(pfc::string_base & out,const char * fmt,...) { + va_list list;va_start(list,fmt);uPrintfV(out,fmt,list);va_end(list); +} + + +static int makeInfiniteWaitEvent() { + int fdPipe[2]; + pfc::createPipe(fdPipe); + return fdPipe[0]; // leak the other end +} + +int GetInfiniteWaitEvent() { + static int obj = makeInfiniteWaitEvent(); + return obj; +} + + +// DUMMY +void SHARED_EXPORT uAddPanicHandler(fb2k::panicHandler*) { + +} +void SHARED_EXPORT uRemovePanicHandler(fb2k::panicHandler*) { + +} + +void SHARED_EXPORT uOutputDebugString(const char * msg) { + // UGLY: underlying APIs want whole lines, calling code feeds lines terminated with \n or \r\n because Windows + pfc::string8 temp ( msg ); + if ( temp.endsWith('\n') ) temp.truncate( temp.length() - 1) ; + if ( temp.endsWith('\r') ) temp.truncate( temp.length() - 1) ; + pfc::outputDebugLine(temp); +} +namespace pfc { PFC_NORETURN void crashImpl(); } +PFC_NORETURN void SHARED_EXPORT uBugCheck() { + pfc::crashImpl(); +} + +int SHARED_EXPORT uStringCompare(const char * elem1, const char * elem2) { + return pfc::naturalSortCompareI(elem1, elem2); +} + +void fb2kDebugSelfTest() { + +} + +bool uGetTempPath(pfc::string_base & out) { + auto var = getenv("TMPDIR"); + if ( var == nullptr ) uBugCheck(); + out = var; + return true; +} +bool uGetTempFileName(const char * path_name,const char * prefix,unsigned unique,pfc::string_base & out) { +#if 0 // sample use + pfc::string8 temp_path, temp_file; + uGetTempPath(temp_path); + uGetTempFileName(temp_path, "img", 0, temp_file); +#endif + pfc::string8 ret; + if ( path_name == nullptr ) uGetTempPath( ret ); + else ret = path_name; + + pfc::chain_list_v2_t segments; + if ( prefix ) segments += prefix; + if ( unique ) segments += pfc::format(unique); + segments += pfc::print_guid(pfc::createGUID()); + + pfc::string8 fn; + for( auto & seg : segments ) { + if (seg.length() == 0) continue; + if ( fn.length() > 0 ) fn += "-"; + fn += seg; + } + + ret.add_filename( fn ); + out = ret; + return true; +} + +pfc::string8 uGetTempFileName() { + pfc::string8 ret; + uGetTempFileName(nullptr, nullptr, 0, ret); + return ret; +} + + +void fb2k::crashWithMessage [[noreturn]] ( const char * msg_ ) { + uAddDebugEvent( msg_ ); + pfc::crashWithMessageOnStack(msg_); +} + +bool uSetCurrentDirectory(const char * path) { + return chdir(path) == 0; +} +bool uGetCurrentDirectory(pfc::string_base & out) { + pfc::array_t work; + work.resize( PATH_MAX ); + for(;;) { + errno = 0; + if ( getcwd(work.get_ptr(), work.size()) != nullptr ) { + out = work.get_ptr(); return true; + } + if ( errno != ENAMETOOLONG ) return false; + work.resize( work.size() * 2 ); + } +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/shared/shared-nix.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/shared/shared-nix.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,28 @@ +#pragma once + +class uFindFile +{ +protected: + uFindFile() {} +public: + virtual ~uFindFile() {}; + virtual bool FindNext() = 0; + virtual const char * GetFileName() = 0; + virtual bool IsDirectory() = 0; +}; + +typedef uFindFile * puFindFile; + +puFindFile uFindFirstFile(const char * path); + +pfc::string8 uStringPrintf(const char * format, ...); +void uPrintfV(pfc::string_base & out,const char * fmt,va_list arglist); +void uPrintf(pfc::string_base & out,const char * fmt,...); + +bool uGetTempPath(pfc::string_base & out); +bool uGetTempFileName(const char * path_name,const char * prefix,unsigned unique,pfc::string_base & out); +pfc::string8 uGetTempFileName(); + + +bool uSetCurrentDirectory(const char * path); +bool uGetCurrentDirectory(pfc::string_base & out); diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/shared/shared-x64.lib Binary file foosdk/sdk/foobar2000/shared/shared-x64.lib has changed diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/shared/shared.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/shared/shared.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,593 @@ +#ifndef _SHARED_DLL__SHARED_H_ +#define _SHARED_DLL__SHARED_H_ + +#include "../../pfc/pfc.h" + +#include + +// Global flag - whether it's OK to leak static objects as they'll be released anyway by process death +#define FB2K_LEAK_STATIC_OBJECTS PFC_LEAK_STATIC_OBJECTS + +#define FB2K_TARGET_MICROSOFT_STORE 0 + +#if defined(_WIN32) && ! FB2K_TARGET_MICROSOFT_STORE +#define FB2K_SUPPORT_CRASH_LOGS 1 +#endif +#ifndef FB2K_SUPPORT_CRASH_LOGS +#define FB2K_SUPPORT_CRASH_LOGS 0 +#endif + +#include + + +#ifdef _WIN32 +#include +#include +#include +#include +//#include +#include + +#define SHARED_API /*NOTHROW*/ __stdcall + +#ifndef SHARED_EXPORTS +#define SHARED_EXPORT __declspec(dllimport) SHARED_API +#else +#define SHARED_EXPORT __declspec(dllexport) SHARED_API +#endif + +#else // _WIN32 + +#define SHARED_API +#define SHARED_EXPORT + +#endif // _WIN32 + +extern "C" { + +#ifdef _WIN32 + typedef HANDLE uSortString_t; +#else + typedef void* uSortString_t; +#endif + +// Implemented for non-Windows as well +void SHARED_EXPORT uOutputDebugString(const char * msg); +unsigned SHARED_EXPORT uCharLower(unsigned c); +unsigned SHARED_EXPORT uCharUpper(unsigned c); +int SHARED_EXPORT uStringCompare(const char * elem1, const char * elem2); +int SHARED_EXPORT uCharCompare(t_uint32 p_char1,t_uint32 p_char2); +uSortString_t SHARED_EXPORT uSortStringCreate(const char * src); +int SHARED_EXPORT uSortStringCompare(uSortString_t string1,uSortString_t string2); +int SHARED_EXPORT uSortStringCompareEx(uSortString_t string1,uSortString_t string2,uint32_t flags);//flags - see win32 CompareString +int SHARED_EXPORT uSortPathCompare(uSortString_t string1,uSortString_t string2); +void SHARED_EXPORT uSortStringFree(uSortString_t string); +pfc::eventHandle_t SHARED_EXPORT GetInfiniteWaitEvent(); +} // extern "C" + +#ifdef _WIN32 +extern "C" { +LRESULT SHARED_EXPORT uSendMessageText(HWND wnd,UINT msg,WPARAM wp,const char * text); +LRESULT SHARED_EXPORT uSendDlgItemMessageText(HWND wnd,UINT id,UINT msg,WPARAM wp,const char * text); +BOOL SHARED_EXPORT uGetWindowText(HWND wnd,pfc::string_base & out); +BOOL SHARED_EXPORT uSetWindowText(HWND wnd,const char * p_text); +BOOL SHARED_EXPORT uSetWindowTextEx(HWND wnd,const char * p_text,size_t p_text_length); +BOOL SHARED_EXPORT uGetDlgItemText(HWND wnd,UINT id,pfc::string_base & out); +BOOL SHARED_EXPORT uSetDlgItemText(HWND wnd,UINT id,const char * p_text); +BOOL SHARED_EXPORT uSetDlgItemTextEx(HWND wnd,UINT id,const char * p_text,size_t p_text_length); +BOOL SHARED_EXPORT uBrowseForFolder(HWND parent,const char * title,pfc::string_base & out); +BOOL SHARED_EXPORT uBrowseForFolderWithFile(HWND parent,const char * title,pfc::string_base & out,const char * p_file_to_find); +int SHARED_EXPORT uMessageBox(HWND wnd,const char * text,const char * caption,UINT type); +BOOL SHARED_EXPORT uAppendMenu(HMENU menu,UINT flags,UINT_PTR id,const char * content); +BOOL SHARED_EXPORT uInsertMenu(HMENU menu,UINT position,UINT flags,UINT_PTR id,const char * content); +int SHARED_EXPORT uStringCompare_ConvertNumbers(const char * elem1,const char * elem2); +HINSTANCE SHARED_EXPORT uLoadLibrary(const char * name); +HANDLE SHARED_EXPORT uCreateEvent(LPSECURITY_ATTRIBUTES lpEventAttributes,BOOL bManualReset,BOOL bInitialState, const char * lpName); +DWORD SHARED_EXPORT uGetModuleFileName(HMODULE hMod,pfc::string_base & out); +BOOL SHARED_EXPORT uSetClipboardString(const char * ptr); +BOOL SHARED_EXPORT uGetClipboardString(pfc::string_base & out); +BOOL SHARED_EXPORT uSetClipboardRawData(UINT format,const void * ptr,t_size size);//does not empty the clipboard +BOOL SHARED_EXPORT uGetClassName(HWND wnd,pfc::string_base & out); +t_size SHARED_EXPORT uCharLength(const char * src); +#ifdef DragQueryFile // don't declare if relevant Windows #include has been omitted, breaks on HDROP +BOOL SHARED_EXPORT uDragQueryFile(HDROP hDrop,UINT idx,pfc::string_base & out); +UINT SHARED_EXPORT uDragQueryFileCount(HDROP hDrop); +#endif +BOOL SHARED_EXPORT uGetTextExtentPoint32(HDC dc,const char * text,UINT cb,LPSIZE size);//note, cb is number of bytes, not actual unicode characters in the string (read: plain strlen() will do) +BOOL SHARED_EXPORT uExtTextOut(HDC dc,int x,int y,UINT flags,const RECT * rect,const char * text,UINT cb,const int * lpdx); +BOOL SHARED_EXPORT uTextOutColors(HDC dc,const char * src,UINT len,int x,int y,const RECT * clip,BOOL is_selected,DWORD default_color); +BOOL SHARED_EXPORT uTextOutColorsTabbed(HDC dc,const char * src,UINT src_len,const RECT * item,int border,const RECT * clip,BOOL selected,DWORD default_color,BOOL use_columns); +UINT SHARED_EXPORT uGetTextHeight(HDC dc); +UINT SHARED_EXPORT uGetFontHeight(HFONT font); +BOOL SHARED_EXPORT uChooseColor(DWORD * p_color,HWND parent,DWORD * p_custom_colors); +HCURSOR SHARED_EXPORT uLoadCursor(HINSTANCE hIns,const char * name); +HICON SHARED_EXPORT uLoadIcon(HINSTANCE hIns,const char * name); +HMENU SHARED_EXPORT uLoadMenu(HINSTANCE hIns,const char * name); +BOOL SHARED_EXPORT uGetEnvironmentVariable(const char * name,pfc::string_base & out); +HMODULE SHARED_EXPORT uGetModuleHandle(const char * name); +UINT SHARED_EXPORT uRegisterWindowMessage(const char * name); +BOOL SHARED_EXPORT uMoveFile(const char * src,const char * dst); +BOOL SHARED_EXPORT uDeleteFile(const char * fn); +DWORD SHARED_EXPORT uGetFileAttributes(const char * fn); +BOOL SHARED_EXPORT uFileExists(const char * fn); +BOOL SHARED_EXPORT uRemoveDirectory(const char * fn); +HANDLE SHARED_EXPORT uCreateFile(const char * p_path,DWORD p_access,DWORD p_sharemode,LPSECURITY_ATTRIBUTES p_security_attributes,DWORD p_createmode,DWORD p_flags,HANDLE p_template); +HANDLE SHARED_EXPORT uCreateFileMapping(HANDLE hFile,LPSECURITY_ATTRIBUTES lpFileMappingAttributes,DWORD flProtect,DWORD dwMaximumSizeHigh,DWORD dwMaximumSizeLow,const char * lpName); +BOOL SHARED_EXPORT uCreateDirectory(const char * fn,LPSECURITY_ATTRIBUTES blah); +HANDLE SHARED_EXPORT uCreateMutex(LPSECURITY_ATTRIBUTES blah,BOOL bInitialOwner,const char * name); +BOOL SHARED_EXPORT uGetLongPathName(const char * name,pfc::string_base & out);//may just fail to work on old windows versions, present on win98/win2k+ +BOOL SHARED_EXPORT uGetFullPathName(const char * name,pfc::string_base & out); +BOOL SHARED_EXPORT uSearchPath(const char * path, const char * filename, const char * extension, pfc::string_base & p_out); +BOOL SHARED_EXPORT uFixPathCaps(const char * path,pfc::string_base & p_out); +//BOOL SHARED_EXPORT uFixPathCapsQuick(const char * path,pfc::string_base & p_out); +void SHARED_EXPORT uGetCommandLine(pfc::string_base & out); +BOOL SHARED_EXPORT uGetTempPath(pfc::string_base & out); +BOOL SHARED_EXPORT uGetTempFileName(const char * path_name,const char * prefix,UINT unique,pfc::string_base & out); + +//! Win32 GetOpenFileName/GetSaveFileName wrapper. \n +//! Extension mask uses | instead of \0 for delimiter; "Text files|*.txt|foo files|*.foo" +BOOL SHARED_EXPORT uGetOpenFileName(HWND parent,const char * p_ext_mask,unsigned def_ext_mask,const char * p_def_ext,const char * p_title,const char * p_directory,pfc::string_base & p_filename,BOOL b_save); + +HANDLE SHARED_EXPORT uLoadImage(HINSTANCE hIns,const char * name,UINT type,int x,int y,UINT flags); +UINT SHARED_EXPORT uRegisterClipboardFormat(const char * name); +BOOL SHARED_EXPORT uGetClipboardFormatName(UINT format,pfc::string_base & out); +BOOL SHARED_EXPORT uFormatSystemErrorMessage(pfc::string_base & p_out,DWORD p_code); + +// New in 1.1.12 +HANDLE SHARED_EXPORT CreateFileAbortable( __in LPCWSTR lpFileName, + __in DWORD dwDesiredAccess, + __in DWORD dwShareMode, + __in_opt LPSECURITY_ATTRIBUTES lpSecurityAttributes, + __in DWORD dwCreationDisposition, + __in DWORD dwFlagsAndAttributes, + // Template file handle NOT supported. + __in_opt HANDLE hAborter + ); + + +int SHARED_EXPORT uCompareString(DWORD flags,const char * str1,size_t len1,const char * str2,size_t len2); + +class NOVTABLE uGetOpenFileNameMultiResult : public pfc::list_base_const_t +{ +public: + inline t_size GetCount() {return get_count();} + inline const char * GetFileName(t_size index) {return get_item(index);} + virtual ~uGetOpenFileNameMultiResult() {} +}; + +typedef uGetOpenFileNameMultiResult * puGetOpenFileNameMultiResult; + +puGetOpenFileNameMultiResult SHARED_EXPORT uGetOpenFileNameMulti(HWND parent,const char * p_ext_mask,unsigned def_ext_mask,const char * p_def_ext,const char * p_title,const char * p_directory); + +// new in fb2k 1.1.1 +puGetOpenFileNameMultiResult SHARED_EXPORT uBrowseForFolderEx(HWND parent,const char * title, const char * initPath); +puGetOpenFileNameMultiResult SHARED_EXPORT uEvalKnownFolder(const GUID& id); + + +class NOVTABLE uFindFile +{ +protected: + uFindFile() {} +public: + virtual BOOL FindNext()=0; + virtual const char * GetFileName()=0; + virtual t_uint64 GetFileSize()=0; + virtual DWORD GetAttributes()=0; + virtual FILETIME GetCreationTime()=0; + virtual FILETIME GetLastAccessTime()=0; + virtual FILETIME GetLastWriteTime()=0; + virtual ~uFindFile() {}; + inline bool IsDirectory() {return (GetAttributes() & FILE_ATTRIBUTE_DIRECTORY) ? true : false;} +}; + +typedef uFindFile * puFindFile; + +puFindFile SHARED_EXPORT uFindFirstFile(const char * path); + +HINSTANCE SHARED_EXPORT uShellExecute(HWND wnd,const char * oper,const char * file,const char * params,const char * dir,int cmd); +HWND SHARED_EXPORT uCreateStatusWindow(LONG style,const char * text,HWND parent,UINT id); + +BOOL SHARED_EXPORT uShellNotifyIcon(DWORD dwMessage,HWND wnd,UINT id,UINT callbackmsg,HICON icon,const char * tip); +BOOL SHARED_EXPORT uShellNotifyIconEx(DWORD dwMessage,HWND wnd,UINT id,UINT callbackmsg,HICON icon,const char * tip,const char * balloon_title,const char * balloon_msg); + +HWND SHARED_EXPORT uCreateWindowEx(DWORD dwExStyle,const char * lpClassName,const char * lpWindowName,DWORD dwStyle,int x,int y,int nWidth,int nHeight,HWND hWndParent,HMENU hMenu,HINSTANCE hInstance,LPVOID lpParam); + +BOOL SHARED_EXPORT uGetSystemDirectory(pfc::string_base & out); +BOOL SHARED_EXPORT uGetWindowsDirectory(pfc::string_base & out); +BOOL SHARED_EXPORT uSetCurrentDirectory(const char * path); +BOOL SHARED_EXPORT uGetCurrentDirectory(pfc::string_base & out); +BOOL SHARED_EXPORT uExpandEnvironmentStrings(const char * src,pfc::string_base & out); +BOOL SHARED_EXPORT uGetUserName(pfc::string_base & out); +BOOL SHARED_EXPORT uGetShortPathName(const char * src,pfc::string_base & out); + +HSZ SHARED_EXPORT uDdeCreateStringHandle(DWORD ins,const char * src); +BOOL SHARED_EXPORT uDdeQueryString(DWORD ins,HSZ hsz,pfc::string_base & out); +UINT SHARED_EXPORT uDdeInitialize(LPDWORD pidInst,PFNCALLBACK pfnCallback,DWORD afCmd,DWORD ulRes); +BOOL SHARED_EXPORT uDdeAccessData_Text(HDDEDATA data,pfc::string_base & out); + +HIMAGELIST SHARED_EXPORT uImageList_LoadImage(HINSTANCE hi, const char * lpbmp, int cx, int cGrow, COLORREF crMask, UINT uType, UINT uFlags); + +#define uDdeFreeStringHandle DdeFreeStringHandle +#define uDdeCmpStringHandles DdeCmpStringHandles +#define uDdeKeepStringHandle DdeKeepStringHandle +#define uDdeUninitialize DdeUninitialize +#define uDdeNameService DdeNameService +#define uDdeFreeDataHandle DdeFreeDataHandle + + +typedef TVINSERTSTRUCTA uTVINSERTSTRUCT; + +HTREEITEM SHARED_EXPORT uTreeView_InsertItem(HWND wnd,const uTVINSERTSTRUCT * param); +LPARAM SHARED_EXPORT uTreeView_GetUserData(HWND wnd,HTREEITEM item); +bool SHARED_EXPORT uTreeView_GetText(HWND wnd,HTREEITEM item,pfc::string_base & out); + +#define uSetWindowsHookEx SetWindowsHookEx +#define uUnhookWindowsHookEx UnhookWindowsHookEx +#define uCallNextHookEx CallNextHookEx + +typedef TCITEMA uTCITEM; +int SHARED_EXPORT uTabCtrl_InsertItem(HWND wnd,t_size idx,const uTCITEM * item); +int SHARED_EXPORT uTabCtrl_SetItem(HWND wnd,t_size idx,const uTCITEM * item); + +int SHARED_EXPORT uGetKeyNameText(LONG lparam,pfc::string_base & out); + +void SHARED_EXPORT uFixAmpersandChars(const char * src,pfc::string_base & out);//for system tray icon +void SHARED_EXPORT uFixAmpersandChars_v2(const char * src,pfc::string_base & out);//for other controls + +#if FB2K_SUPPORT_CRASH_LOGS +t_size SHARED_EXPORT uPrintCrashInfo(LPEXCEPTION_POINTERS param,const char * extrainfo,char * out); +enum {uPrintCrashInfo_max_length = 1024}; + +void SHARED_EXPORT uPrintCrashInfo_Init(const char * name);//called only by the exe on startup +void SHARED_EXPORT uPrintCrashInfo_SetComponentList(const char * p_info);//called only by the exe on startup +void SHARED_EXPORT uPrintCrashInfo_AddEnvironmentInfo(const char * p_info);//called only by the exe on startup +void SHARED_EXPORT uPrintCrashInfo_SetDumpPath(const char * name);//called only by the exe on startup + + +#endif // FB2K_SUPPORT_CRASH_LOGS + +void SHARED_EXPORT uDumpCrashInfo(LPEXCEPTION_POINTERS param); + +BOOL SHARED_EXPORT uListBox_GetText(HWND listbox,UINT index,pfc::string_base & out); + +void SHARED_EXPORT uPrintfV(pfc::string_base & out,const char * fmt,va_list arglist); +static inline void uPrintf(pfc::string_base & out,const char * fmt,...) {va_list list;va_start(list,fmt);uPrintfV(out,fmt,list);va_end(list);} + + +class NOVTABLE uResource +{ +public: + virtual const void * GetPointer() = 0; + virtual unsigned GetSize() = 0; + virtual ~uResource() {} +}; + +typedef uResource* puResource; + +puResource SHARED_EXPORT uLoadResource(HMODULE hMod,const char * name,const char * type,WORD wLang = MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL) ); +puResource SHARED_EXPORT LoadResourceEx(HMODULE hMod,const TCHAR * name,const TCHAR * type,WORD wLang = MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL) ); +HRSRC SHARED_EXPORT uFindResource(HMODULE hMod,const char * name,const char * type,WORD wLang = MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL) ); + +BOOL SHARED_EXPORT uLoadString(HINSTANCE ins,UINT id,pfc::string_base & out); + +BOOL SHARED_EXPORT uGetMenuString(HMENU menu,UINT id,pfc::string_base & out,UINT flag); +BOOL SHARED_EXPORT uModifyMenu(HMENU menu,UINT id,UINT flags,UINT newitem,const char * data); +UINT SHARED_EXPORT uGetMenuItemType(HMENU menu,UINT position); + + +// New in 1.3.4 +// Load a system library safely - forcibly look in system directories, not elsewhere. +HMODULE SHARED_EXPORT LoadSystemLibrary(const TCHAR * name); + +void SHARED_EXPORT uPrintCrashInfo_OnEvent(const char * message, t_size length); +void SHARED_EXPORT uPrintCrashInfo_StartLogging(const char * path); + +}//extern "C" + + +inline char * uCharNext(char * src) {return src+uCharLength(src);} +inline const char * uCharNext(const char * src) {return src+uCharLength(src);} + + +inline pfc::string uGetWindowText(HWND wnd) { + pfc::string8 temp; + if (!uGetWindowText(wnd,temp)) temp = ""; + return temp; +} + +inline pfc::string uGetDlgItemText(HWND wnd,UINT id) { + pfc::string8 temp; + if (!uGetDlgItemText(wnd,id,temp)) temp = ""; + return temp; +} + +#define uMAKEINTRESOURCE(x) ((const char*)LOWORD(x)) + +//other + +#define uIsDialogMessage IsDialogMessage +#define uGetMessage GetMessage +#define uPeekMessage PeekMessage +#define uDispatchMessage DispatchMessage + +#define uCallWindowProc CallWindowProc +#define uDefWindowProc DefWindowProc +#define uGetWindowLong GetWindowLong +#define uSetWindowLong SetWindowLong + +#define uEndDialog EndDialog +#define uDestroyWindow DestroyWindow +#define uGetDlgItem GetDlgItem +#define uEnableWindow EnableWindow +#define uGetDlgItemInt GetDlgItemInt +#define uSetDlgItemInt SetDlgItemInt + +#define uSendMessage SendMessage +#define uSendDlgItemMessage SendDlgItemMessage +#define uSendMessageTimeout SendMessageTimeout +#define uSendNotifyMessage SendNotifyMessage +#define uSendMessageCallback SendMessageCallback +#define uPostMessage PostMessage +#define uPostThreadMessage PostThreadMessage + + +class uStringPrintf +{ +public: + inline explicit uStringPrintf(const char * fmt,...) + { + va_list list; + va_start(list,fmt); + uPrintfV(m_data,fmt,list); + va_end(list); + } + inline operator const char * () const {return m_data.get_ptr();} + inline t_size length() const {return m_data.length();} + inline bool is_empty() const {return length() == 0;} + inline const char * get_ptr() const {return m_data.get_ptr();} + const char * toString() const {return get_ptr();} +private: + pfc::string8_fastalloc m_data; +}; + +inline LRESULT uButton_SetCheck(HWND wnd,UINT id,bool state) {return uSendDlgItemMessage(wnd,id,BM_SETCHECK,state ? BST_CHECKED : BST_UNCHECKED,0); } +inline bool uButton_GetCheck(HWND wnd,UINT id) {return uSendDlgItemMessage(wnd,id,BM_GETCHECK,0,0) == BST_CHECKED;} + +inline BOOL uGetLongPathNameEx(const char * name,pfc::string_base & out) +{ + if (uGetLongPathName(name,out)) return TRUE; + return uGetFullPathName(name,out); +} + +#endif // _WIN32 + +extern "C" { +int SHARED_EXPORT stricmp_utf8(const char * p1,const char * p2) throw(); +int SHARED_EXPORT stricmp_utf8_ex(const char * p1,t_size len1,const char * p2,t_size len2) throw(); +int SHARED_EXPORT stricmp_utf8_stringtoblock(const char * p1,const char * p2,t_size p2_bytes) throw(); +int SHARED_EXPORT stricmp_utf8_partial(const char * p1,const char * p2,t_size num = ~0) throw(); +int SHARED_EXPORT stricmp_utf8_max(const char * p1,const char * p2,t_size p1_bytes) throw(); +t_size SHARED_EXPORT uReplaceStringAdd(pfc::string_base & out,const char * src,t_size src_len,const char * s1,t_size len1,const char * s2,t_size len2,bool casesens); +t_size SHARED_EXPORT uReplaceCharAdd(pfc::string_base & out,const char * src,t_size src_len,unsigned c1,unsigned c2,bool casesens); +//all lengths in uReplaceString functions are optional, set to -1 if parameters is a simple null-terminated string +void SHARED_EXPORT uAddStringLower(pfc::string_base & out,const char * src,t_size len = ~0); +void SHARED_EXPORT uAddStringUpper(pfc::string_base & out,const char * src,t_size len = ~0); +} + +class comparator_stricmp_utf8 { +public: + static int compare(const char * p_string1,const char * p_string2) throw() {return stricmp_utf8(p_string1,p_string2);} +}; + +inline void uStringLower(pfc::string_base & out,const char * src,t_size len = ~0) {out.reset();uAddStringLower(out,src,len);} +inline void uStringUpper(pfc::string_base & out,const char * src,t_size len = ~0) {out.reset();uAddStringUpper(out,src,len);} + +inline t_size uReplaceString(pfc::string_base & out,const char * src,t_size src_len,const char * s1,t_size len1,const char * s2,t_size len2,bool casesens) +{ + out.reset(); + return uReplaceStringAdd(out,src,src_len,s1,len1,s2,len2,casesens); +} + +inline t_size uReplaceChar(pfc::string_base & out,const char * src,t_size src_len,unsigned c1,unsigned c2,bool casesens) +{ + out.reset(); + return uReplaceCharAdd(out,src,src_len,c1,c2,casesens); +} + +class string_lower +{ +public: + explicit string_lower(const char * ptr,t_size p_count = ~0) {uAddStringLower(m_data,ptr,p_count);} + inline operator const char * () const {return m_data.get_ptr();} + inline t_size length() const {return m_data.length();} + inline bool is_empty() const {return length() == 0;} + inline const char * get_ptr() const {return m_data.get_ptr();} +private: + pfc::string8 m_data; +}; + +class string_upper +{ +public: + explicit string_upper(const char * ptr,t_size p_count = ~0) {uAddStringUpper(m_data,ptr,p_count);} + inline operator const char * () const {return m_data.get_ptr();} + inline t_size length() const {return m_data.length();} + inline bool is_empty() const {return length() == 0;} + inline const char * get_ptr() const {return m_data.get_ptr();} +private: + pfc::string8 m_data; +}; + +#ifdef _WIN32 +struct t_font_description +{ + enum + { + m_facename_length = LF_FACESIZE*2, + m_height_dpi = 480, + }; + + t_uint32 m_height; + t_uint32 m_weight; + t_uint8 m_italic; + t_uint8 m_charset; + char m_facename[m_facename_length]; + + bool operator==(const t_font_description & other) const {return g_equals(*this, other);} + bool operator!=(const t_font_description & other) const {return !g_equals(*this, other);} + + static bool g_equals(const t_font_description & v1, const t_font_description & v2) { + return v1.m_height == v2.m_height && v1.m_weight == v2.m_weight && v1.m_italic == v2.m_italic && v1.m_charset == v2.m_charset && pfc::strcmp_ex(v1.m_facename, m_facename_length, v2.m_facename, m_facename_length) == 0; + } + + HFONT SHARED_EXPORT create() const; + bool SHARED_EXPORT popup_dialog(HWND p_parent); + void SHARED_EXPORT from_font(HFONT p_font); + static t_font_description SHARED_EXPORT g_from_font(HFONT p_font); + static t_font_description SHARED_EXPORT g_from_logfont(LOGFONT const & lf); + static t_font_description SHARED_EXPORT g_from_system(int id = TMT_MENUFONT); + + template void to_stream(t_stream p_stream,t_abort & p_abort) const; + template void from_stream(t_stream p_stream,t_abort & p_abort); +}; + +/* relevant types not yet defined here */ template void t_font_description::to_stream(t_stream p_stream,t_abort & p_abort) const { + p_stream->write_lendian_t(m_height,p_abort); + p_stream->write_lendian_t(m_weight,p_abort); + p_stream->write_lendian_t(m_italic,p_abort); + p_stream->write_lendian_t(m_charset,p_abort); + p_stream->write_string(m_facename,PFC_TABSIZE(m_facename),p_abort); +} + +/* relevant types not yet defined here */ template void t_font_description::from_stream(t_stream p_stream,t_abort & p_abort) { + p_stream->read_lendian_t(m_height,p_abort); + p_stream->read_lendian_t(m_weight,p_abort); + p_stream->read_lendian_t(m_italic,p_abort); + p_stream->read_lendian_t(m_charset,p_abort); + pfc::string8 temp; + p_stream->read_string(temp,p_abort); + strncpy_s(m_facename,temp,PFC_TABSIZE(m_facename)); +} + + +struct t_modal_dialog_entry +{ + HWND m_wnd_to_poke; + bool m_in_use; +}; + +extern "C" { + void SHARED_EXPORT ModalDialog_Switch(t_modal_dialog_entry & p_entry); + void SHARED_EXPORT ModalDialog_PokeExisting(); + bool SHARED_EXPORT ModalDialog_CanCreateNew(); + + HWND SHARED_EXPORT FindOwningPopup(HWND p_wnd); + void SHARED_EXPORT PokeWindow(HWND p_wnd); +}; + +inline bool ModalDialogPrologue() { + bool rv = ModalDialog_CanCreateNew(); + if (!rv) ModalDialog_PokeExisting(); + return rv; +} + +//! The purpose of modal_dialog_scope is to help to avoid the modal dialog recursion problem. Current toplevel modal dialog handle is stored globally, so when creation of a new modal dialog is blocked, it can be activated to indicate the reason for the task being blocked. +class modal_dialog_scope { +public: + //! This constructor initializes the modal dialog scope with specified dialog handle. + inline modal_dialog_scope(HWND p_wnd) throw() : m_initialized(false) {initialize(p_wnd);} + //! This constructor leaves the scope uninitialized (you can call initialize() later with your window handle). + inline modal_dialog_scope() throw() : m_initialized(false) {} + inline ~modal_dialog_scope() throw() {deinitialize();} + + //! Returns whether creation of a new modal dialog is allowed (false when there's another one active).\n + //! NOTE: when calling context is already inside a modal dialog that you own, you should not be checking this before creating a new modal dialog. + inline static bool can_create() throw(){return ModalDialog_CanCreateNew();} + //! Activates the top-level modal dialog existing, if one exists. + inline static void poke_existing() throw() {ModalDialog_PokeExisting();} + + //! Initializes the scope with specified window handle. + void initialize(HWND p_wnd) throw() + { + if (!m_initialized) + { + m_initialized = true; + m_entry.m_in_use = true; + m_entry.m_wnd_to_poke = p_wnd; + ModalDialog_Switch(m_entry); + } + } + + void deinitialize() throw() + { + if (m_initialized) + { + ModalDialog_Switch(m_entry); + m_initialized = false; + } + } + + + +private: + modal_dialog_scope(const modal_dialog_scope & p_scope) = delete; + const modal_dialog_scope & operator=(const modal_dialog_scope &) = delete; + + t_modal_dialog_entry m_entry; + + bool m_initialized; +}; + +#endif // _WIN32 + +#include "audio_math.h" +#ifdef _WIN32 +#include "win32_misc.h" +#endif + +#include "fb2kdebug.h" + +#if FB2K_LEAK_STATIC_OBJECTS +#define FB2K_STATIC_OBJECT(TYPE, NAME) static TYPE & NAME = * new TYPE; +#else +#define FB2K_STATIC_OBJECT(TYPE, NAME) static TYPE NAME; +#endif + + +#ifdef _MSC_VER +#define FB2K_DEPRECATED __declspec(deprecated) +#else +#define FB2K_DEPRECATED +#endif + + +namespace fb2k { +#ifdef _WIN32 +typedef HWND hwnd_t; +typedef HICON hicon_t; +typedef HMENU hmenu_t; +typedef HFONT hfont_t; +#else +typedef void* hwnd_t; // Mac: bridged NSObject, context specific (NSWindow, NSView, NSViewController) +typedef void* hicon_t; +typedef void* hmenu_t; +typedef void* hfont_t; +#endif + +inline void messageBeep() { +#ifdef _WIN32 + MessageBeep(0); +#endif +} +} + +#ifdef __APPLE__ +#include "shared-apple.h" +#endif + +#ifndef _WIN32 +#include "shared-nix.h" +#endif + + +#endif //_SHARED_DLL__SHARED_H_ diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/shared/shared.vcxproj --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/shared/shared.vcxproj Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,404 @@ + + + + + Debug + ARM64 + + + Debug + ARM64EC + + + Debug + Win32 + + + Debug + x64 + + + Release + ARM64 + + + Release + ARM64EC + + + Release + Win32 + + + Release + x64 + + + + {054C606B-17BF-4540-AC4E-A9A7243628B8} + shared + Win32Proj + 10.0 + + + + DynamicLibrary + Unicode + true + v142 + + + DynamicLibrary + Unicode + true + v142 + + + DynamicLibrary + Unicode + true + v143 + + + DynamicLibrary + Unicode + true + v143 + + + DynamicLibrary + Unicode + v142 + + + DynamicLibrary + Unicode + v142 + + + DynamicLibrary + Unicode + v143 + + + DynamicLibrary + Unicode + v143 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + true + true + true + true + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + false + false + false + false + + + + Disabled + EnableFastChecks + Use + shared.h + Level3 + ProgramDatabase + MultiThreadedDebugDLL + 4715 + Fast + _CRT_SECURE_NO_WARNINGS;SHARED_EXPORTS;_WINDLL;%(PreprocessorDefinitions) + true + stdcpp20 + + + comctl32.lib;imagehlp.lib;uxtheme.lib;dbghelp.lib;%(AdditionalDependencies) + true + $(OutDir)shared.pdb + Windows + + + $(OutDir)shared.lib + MachineX86 + + + + + Disabled + EnableFastChecks + Use + shared.h + Level3 + ProgramDatabase + MultiThreadedDebugDLL + 4715 + Fast + _CRT_SECURE_NO_WARNINGS;SHARED_EXPORTS;_WINDLL;%(PreprocessorDefinitions) + true + stdcpp20 + + + comctl32.lib;imagehlp.lib;uxtheme.lib;dbghelp.lib;%(AdditionalDependencies) + true + $(OutDir)shared.pdb + Windows + + + $(OutDir)shared.lib + + + + + Disabled + EnableFastChecks + Use + shared.h + Level3 + ProgramDatabase + MultiThreadedDebugDLL + 4715 + Fast + _CRT_SECURE_NO_WARNINGS;SHARED_EXPORTS;_WINDLL;%(PreprocessorDefinitions) + true + stdcpp20 + + + comctl32.lib;imagehlp.lib;uxtheme.lib;dbghelp.lib;%(AdditionalDependencies) + true + $(OutDir)shared.pdb + Windows + + + $(OutDir)shared.lib + + + + + Disabled + EnableFastChecks + Use + shared.h + Level3 + ProgramDatabase + MultiThreadedDebugDLL + 4715 + Fast + _CRT_SECURE_NO_WARNINGS;SHARED_EXPORTS;_WINDLL;%(PreprocessorDefinitions) + true + stdcpp20 + + + comctl32.lib;imagehlp.lib;uxtheme.lib;dbghelp.lib;%(AdditionalDependencies) + true + $(OutDir)shared.pdb + Windows + + + $(OutDir)shared.lib + + + + + Full + true + false + Fast + false + Use + shared.h + Level3 + ProgramDatabase + MultiThreadedDLL + /d2notypeopt %(AdditionalOptions) + 4715 + true + _CRT_SECURE_NO_WARNINGS;SHARED_EXPORTS;_WINDLL;NDEBUG;%(PreprocessorDefinitions) + true + stdcpp20 + + + comctl32.lib;imagehlp.lib;uxtheme.lib;dbghelp.lib;%(AdditionalDependencies) + true + Windows + true + true + + + $(OutDir)shared.lib + MachineX86 + + + copy "$(OutDir)shared.lib" "$(ProjectDir)shared-$(Platform).lib" + + + + + Full + true + false + Fast + false + Use + shared.h + Level3 + ProgramDatabase + MultiThreadedDLL + /d2notypeopt %(AdditionalOptions) + 4715 + true + _CRT_SECURE_NO_WARNINGS;SHARED_EXPORTS;_WINDLL;NDEBUG;%(PreprocessorDefinitions) + true + stdcpp20 + + + comctl32.lib;imagehlp.lib;uxtheme.lib;dbghelp.lib;%(AdditionalDependencies) + true + Windows + true + true + + + $(OutDir)shared.lib + + + copy "$(OutDir)shared.lib" "$(ProjectDir)shared-$(Platform).lib" + + + + + Full + true + false + Fast + false + Use + shared.h + Level3 + ProgramDatabase + MultiThreadedDLL + /d2notypeopt %(AdditionalOptions) + 4715 + true + _CRT_SECURE_NO_WARNINGS;SHARED_EXPORTS;_WINDLL;NDEBUG;%(PreprocessorDefinitions) + true + stdcpp20 + + + comctl32.lib;imagehlp.lib;uxtheme.lib;dbghelp.lib;%(AdditionalDependencies) + true + Windows + true + true + + + $(OutDir)shared.lib + + + copy "$(OutDir)shared.lib" "$(ProjectDir)shared-$(Platform).lib" + + + + + Full + true + false + Fast + false + Use + shared.h + Level3 + ProgramDatabase + MultiThreadedDLL + /d2notypeopt %(AdditionalOptions) + 4715 + true + _CRT_SECURE_NO_WARNINGS;SHARED_EXPORTS;_WINDLL;NDEBUG;%(PreprocessorDefinitions) + true + stdcpp20 + + + comctl32.lib;imagehlp.lib;uxtheme.lib;dbghelp.lib;%(AdditionalDependencies) + true + Windows + true + true + + + $(OutDir)shared.lib + + + copy "$(OutDir)shared.lib" "$(ProjectDir)shared-$(Platform).lib" + + + + + + + + + + + + Create + Create + Create + Create + Create + Create + Create + Create + + + + + + + + + + + + + + + + + {ebfffb4e-261d-44d3-b89c-957b31a0bf9c} + + + + + + \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/shared/shared.vcxproj.filters --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/shared/shared.vcxproj.filters Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,75 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/shared/shared.xcodeproj/project.pbxproj --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/shared/shared.xcodeproj/project.pbxproj Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,352 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 54; + objects = { + +/* Begin PBXBuildFile section */ + 0F75F3A72A6B1A8C00A45078 /* stdafx.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F3932A6B1A8C00A45078 /* stdafx.cpp */; }; + 0F75F3AB2A6B1A8C00A45078 /* shared-apple.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F39A2A6B1A8C00A45078 /* shared-apple.mm */; }; + 0F75F3AC2A6B1A8C00A45078 /* utf8.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F39B2A6B1A8C00A45078 /* utf8.cpp */; }; + 0F75F3AE2A6B1A8C00A45078 /* shared-nix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F39E2A6B1A8C00A45078 /* shared-nix.cpp */; }; + 0F75F3B02A6B1A8C00A45078 /* audio_math.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F75F3A02A6B1A8C00A45078 /* audio_math.cpp */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 0F75F3772A6B1A3900A45078 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = "include/$(PRODUCT_NAME)"; + dstSubfolderSpec = 16; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 0F75F3792A6B1A3900A45078 /* libshared.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libshared.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 0F75F38C2A6B1A8C00A45078 /* modal_dialog.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = modal_dialog.cpp; sourceTree = ""; }; + 0F75F38D2A6B1A8C00A45078 /* minidump.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = minidump.cpp; sourceTree = ""; }; + 0F75F38E2A6B1A8C00A45078 /* font_description.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = font_description.cpp; sourceTree = ""; }; + 0F75F38F2A6B1A8C00A45078 /* filedialogs_vista.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = filedialogs_vista.cpp; sourceTree = ""; }; + 0F75F3902A6B1A8C00A45078 /* audio_math.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = audio_math.h; sourceTree = ""; }; + 0F75F3912A6B1A8C00A45078 /* text_drawing.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = text_drawing.cpp; sourceTree = ""; }; + 0F75F3922A6B1A8C00A45078 /* filedialogs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = filedialogs.h; sourceTree = ""; }; + 0F75F3932A6B1A8C00A45078 /* stdafx.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = stdafx.cpp; sourceTree = ""; }; + 0F75F3942A6B1A8C00A45078 /* crash_info.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = crash_info.cpp; sourceTree = ""; }; + 0F75F3952A6B1A8C00A45078 /* fb2kdebug.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fb2kdebug.h; sourceTree = ""; }; + 0F75F3962A6B1A8C00A45078 /* systray.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = systray.cpp; sourceTree = ""; }; + 0F75F3972A6B1A8C00A45078 /* win32_misc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = win32_misc.h; sourceTree = ""; }; + 0F75F3982A6B1A8C00A45078 /* shared-nix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "shared-nix.h"; sourceTree = ""; }; + 0F75F3992A6B1A8C00A45078 /* filedialogs.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = filedialogs.cpp; sourceTree = ""; }; + 0F75F39A2A6B1A8C00A45078 /* shared-apple.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "shared-apple.mm"; sourceTree = ""; }; + 0F75F39B2A6B1A8C00A45078 /* utf8.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = utf8.cpp; sourceTree = ""; }; + 0F75F39C2A6B1A8C00A45078 /* utf8api.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = utf8api.cpp; sourceTree = ""; }; + 0F75F39D2A6B1A8C00A45078 /* shared.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = shared.h; sourceTree = ""; }; + 0F75F39E2A6B1A8C00A45078 /* shared-nix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "shared-nix.cpp"; sourceTree = ""; }; + 0F75F39F2A6B1A8C00A45078 /* Utility.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Utility.cpp; sourceTree = ""; }; + 0F75F3A02A6B1A8C00A45078 /* audio_math.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = audio_math.cpp; sourceTree = ""; }; + 0F75F3A12A6B1A8C00A45078 /* shared-apple.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "shared-apple.h"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 0F75F3762A6B1A3900A45078 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 0F75F3702A6B1A3900A45078 = { + isa = PBXGroup; + children = ( + 0F75F38B2A6B1A7D00A45078 /* Source */, + 0F75F37A2A6B1A3900A45078 /* Products */, + ); + sourceTree = ""; + }; + 0F75F37A2A6B1A3900A45078 /* Products */ = { + isa = PBXGroup; + children = ( + 0F75F3792A6B1A3900A45078 /* libshared.a */, + ); + name = Products; + sourceTree = ""; + }; + 0F75F38B2A6B1A7D00A45078 /* Source */ = { + isa = PBXGroup; + children = ( + 0F75F3A02A6B1A8C00A45078 /* audio_math.cpp */, + 0F75F3902A6B1A8C00A45078 /* audio_math.h */, + 0F75F3942A6B1A8C00A45078 /* crash_info.cpp */, + 0F75F3952A6B1A8C00A45078 /* fb2kdebug.h */, + 0F75F38F2A6B1A8C00A45078 /* filedialogs_vista.cpp */, + 0F75F3992A6B1A8C00A45078 /* filedialogs.cpp */, + 0F75F3922A6B1A8C00A45078 /* filedialogs.h */, + 0F75F38E2A6B1A8C00A45078 /* font_description.cpp */, + 0F75F38D2A6B1A8C00A45078 /* minidump.cpp */, + 0F75F38C2A6B1A8C00A45078 /* modal_dialog.cpp */, + 0F75F3A12A6B1A8C00A45078 /* shared-apple.h */, + 0F75F39A2A6B1A8C00A45078 /* shared-apple.mm */, + 0F75F39E2A6B1A8C00A45078 /* shared-nix.cpp */, + 0F75F3982A6B1A8C00A45078 /* shared-nix.h */, + 0F75F39D2A6B1A8C00A45078 /* shared.h */, + 0F75F3932A6B1A8C00A45078 /* stdafx.cpp */, + 0F75F3962A6B1A8C00A45078 /* systray.cpp */, + 0F75F3912A6B1A8C00A45078 /* text_drawing.cpp */, + 0F75F39B2A6B1A8C00A45078 /* utf8.cpp */, + 0F75F39C2A6B1A8C00A45078 /* utf8api.cpp */, + 0F75F39F2A6B1A8C00A45078 /* Utility.cpp */, + 0F75F3972A6B1A8C00A45078 /* win32_misc.h */, + ); + name = Source; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 0F75F3782A6B1A3900A45078 /* shared */ = { + isa = PBXNativeTarget; + buildConfigurationList = 0F75F3822A6B1A3900A45078 /* Build configuration list for PBXNativeTarget "shared" */; + buildPhases = ( + 0F75F3752A6B1A3900A45078 /* Sources */, + 0F75F3762A6B1A3900A45078 /* Frameworks */, + 0F75F3772A6B1A3900A45078 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = shared; + productName = shared; + productReference = 0F75F3792A6B1A3900A45078 /* libshared.a */; + productType = "com.apple.product-type.library.static"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 0F75F3712A6B1A3900A45078 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 1250; + TargetAttributes = { + 0F75F3782A6B1A3900A45078 = { + CreatedOnToolsVersion = 12.5.1; + }; + }; + }; + buildConfigurationList = 0F75F3742A6B1A3900A45078 /* Build configuration list for PBXProject "shared" */; + compatibilityVersion = "Xcode 12.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 0F75F3702A6B1A3900A45078; + productRefGroup = 0F75F37A2A6B1A3900A45078 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 0F75F3782A6B1A3900A45078 /* shared */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 0F75F3752A6B1A3900A45078 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 0F75F3B02A6B1A8C00A45078 /* audio_math.cpp in Sources */, + 0F75F3AE2A6B1A8C00A45078 /* shared-nix.cpp in Sources */, + 0F75F3AB2A6B1A8C00A45078 /* shared-apple.mm in Sources */, + 0F75F3A72A6B1A8C00A45078 /* stdafx.cpp in Sources */, + 0F75F3AC2A6B1A8C00A45078 /* utf8.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 0F75F3802A6B1A3900A45078 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = shared.h; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + ../.., + .., + ); + IPHONEOS_DEPLOYMENT_TARGET = 14.5; + MACOSX_DEPLOYMENT_TARGET = 11.0; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + }; + name = Debug; + }; + 0F75F3812A6B1A3900A45078 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = shared.h; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + ../.., + .., + ); + IPHONEOS_DEPLOYMENT_TARGET = 14.5; + MACOSX_DEPLOYMENT_TARGET = 11.0; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = macosx; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 0F75F3832A6B1A3900A45078 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 4S876G9VCD; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 0F75F3842A6B1A3900A45078 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 4S876G9VCD; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 0F75F3742A6B1A3900A45078 /* Build configuration list for PBXProject "shared" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 0F75F3802A6B1A3900A45078 /* Debug */, + 0F75F3812A6B1A3900A45078 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 0F75F3822A6B1A3900A45078 /* Build configuration list for PBXNativeTarget "shared" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 0F75F3832A6B1A3900A45078 /* Debug */, + 0F75F3842A6B1A3900A45078 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 0F75F3712A6B1A3900A45078 /* Project object */; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/shared/stdafx.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/shared/stdafx.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,1 @@ +#include "shared.h" \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/shared/systray.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/shared/systray.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,108 @@ +#include "shared.h" +#include + +void SHARED_EXPORT uFixAmpersandChars(const char * src,pfc::string_base & out) +{ + out.reset(); + while(*src) + { + if (*src=='&') + { + out.add_string("&&&"); + src++; + while(*src=='&') + { + out.add_string("&&"); + src++; + } + } + else out.add_byte(*(src++)); + } +} + +void SHARED_EXPORT uFixAmpersandChars_v2(const char * src,pfc::string_base & out) +{ + out.reset(); + while(*src) + { + if (*src=='&') + { + out.add_string("&&"); + src++; + } + else out.add_byte(*(src++)); + } +} + +static BOOL run_action(DWORD action,NOTIFYICONDATA * data) +{ + if (Shell_NotifyIcon(action,data)) return TRUE; + if (action==NIM_MODIFY) + { + if (Shell_NotifyIcon(NIM_ADD,data)) return TRUE; + } + return FALSE; +} + +extern "C" +{ + + BOOL SHARED_EXPORT uShellNotifyIcon(DWORD action,HWND wnd,UINT id,UINT callbackmsg,HICON icon,const char * tip) + { + NOTIFYICONDATA nid = {}; + nid.cbSize = sizeof(nid); + nid.hWnd = wnd; + nid.uID = id; + nid.uFlags = 0; + if (callbackmsg) + { + nid.uFlags |= NIF_MESSAGE; + nid.uCallbackMessage = callbackmsg; + } + if (icon) + { + nid.uFlags |= NIF_ICON; + nid.hIcon = icon; + } + if (tip) + { + nid.uFlags |= NIF_TIP; + pfc::stringToBuffer(nid.szTip,pfc::stringcvt::string_os_from_utf8(tip)); + } + + return run_action(action,&nid); + } + + BOOL SHARED_EXPORT uShellNotifyIconEx(DWORD action,HWND wnd,UINT id,UINT callbackmsg,HICON icon,const char * tip,const char * balloon_title,const char * balloon_msg) + { + NOTIFYICONDATA nid = {}; + nid.cbSize = sizeof(nid); + nid.hWnd = wnd; + nid.uID = id; + if (callbackmsg) + { + nid.uFlags |= NIF_MESSAGE; + nid.uCallbackMessage = callbackmsg; + } + if (icon) + { + nid.uFlags |= NIF_ICON; + nid.hIcon = icon; + } + if (tip) + { + nid.uFlags |= NIF_TIP; + pfc::stringToBuffer(nid.szTip,pfc::stringcvt::string_os_from_utf8(tip)); + } + + nid.dwInfoFlags = NIIF_INFO | NIIF_NOSOUND; + //if (balloon_title || balloon_msg) + { + nid.uFlags |= NIF_INFO; + if (balloon_title) pfc::stringToBuffer(nid.szInfoTitle,pfc::stringcvt::string_os_from_utf8(balloon_title)); + if (balloon_msg) pfc::stringToBuffer(nid.szInfo,pfc::stringcvt::string_os_from_utf8(balloon_msg)); + } + return run_action(action,&nid); + } + +}//extern "C" diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/shared/text_drawing.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/shared/text_drawing.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,230 @@ +#include "shared.h" + + +static bool is_rect_null(const RECT * r) +{ + return r->right <= r->left || r->bottom <= r->top; +} + +UINT SHARED_EXPORT uGetTextHeight(HDC dc) +{ + TEXTMETRIC tm; + POINT pt[2]; + GetTextMetrics(dc,&tm); + pt[0].x = 0; + pt[0].y = tm.tmHeight; + pt[1].x = 0; + pt[1].y = 0; + LPtoDP(dc,pt,2); + + int ret = pt[0].y - pt[1].y; + return ret > 1 ? (unsigned)ret : 1; +} + +static int get_text_width(HDC dc,const TCHAR * src,int len) +{ + if (len<=0) return 0; + else + { + SIZE goatse; + GetTextExtentPoint32(dc,src,len,&goatse); + return goatse.cx; + } +} + +//GetTextExtentPoint32 wrapper, removes color marks +static int get_text_width_color(HDC dc,const TCHAR * src,int len) +{ + int ptr = 0; + int start = 0; + int rv = 0; + if (len<0) len = (int) _tcslen(src); + while(ptrright<=pos_x || clip->bottom<=pos_y) return TRUE; + } + SetTextAlign(dc,TA_LEFT); + SetBkMode(dc,TRANSPARENT); + SetTextColor(dc,selected ? 0xFFFFFF - default_color : default_color); + + int title_ptr = 0; + int textout_start = 0; + int position = pos_x;//item.left+BORDER; + + for(;;) + { + if (title_ptr>=len || src[title_ptr]==3) + { + if (title_ptr>textout_start) + { + int width = get_text_width(dc,src+textout_start,title_ptr-textout_start); + ExtTextOut(dc,position,pos_y,clip ? ETO_CLIPPED : 0,clip,src+textout_start,title_ptr-textout_start,0); + position += width; + textout_start = title_ptr; + } + if (title_ptr>=len) break; + } + if (src[title_ptr]==3) + { + DWORD new_color; + DWORD new_inverted; + bool have_inverted = false; + + if (src[title_ptr+1]==3) {new_color=default_color;title_ptr+=2;} + else + { + title_ptr++; + new_color = _tcstoul(src+title_ptr,0,16); + while(title_ptrtop + (item->bottom-item->top - (int)uGetTextHeight(dc)) / 2; + + int n_tabs = 0; + int total_width = 0; + { + int start = 0; + int n; + for(n=0;nright - item->left; + if (!columns) tab_total -= total_width; + int ptr = display_len; + int tab_ptr = 0; + int written = 0; + int clip_x = item->right; + do + { + int ptr_end = ptr; + while(ptr>0 && display[ptr-1]!='\t') ptr--; + const TCHAR * t_string = display + ptr; + int t_length = ptr_end - ptr; + if (t_length>0) + { + int t_width = get_text_width_color(dc,t_string,t_length) + border*2; + + int pos_x; + int pos_x_right; + + if (!columns) + { + pos_x_right = item->right - MulDiv(tab_ptr,tab_total,n_tabs) - written; + } + else + { + if (tab_ptr==0) pos_x_right = item->right; + else pos_x_right = item->right - MulDiv(tab_ptr,tab_total,n_tabs) + t_width; + } + + if (ptr==0) + { + pos_x = item->left; + } + else + { + pos_x = pos_x_right - t_width ; + if (pos_xleft) pos_x = item->left; + } + + RECT t_clip = clip; + + if (t_clip.right > clip_x) t_clip.right = clip_x; + + text_out_colors(dc,t_string,t_length,pos_x+border,pos_y,&t_clip,selected,default_color); + + if (clip_x>pos_x) clip_x = pos_x; + + written += t_width; + } + + if (ptr>0) + { + ptr--;//tab char + tab_ptr++; + } + } + while(ptr>0); + + return TRUE; +} + +extern "C" { + +BOOL SHARED_EXPORT uTextOutColors(HDC dc,const char * p_text,UINT len,int x,int y,const RECT * clip,BOOL is_selected,DWORD default_color) +{ + try { + pfc::stringcvt::string_os_from_utf8 temp(p_text); + return text_out_colors(dc,temp,pfc::downcast_guarded(temp.length()),x,y,clip,!!is_selected,default_color); + } catch(...) {return FALSE;} +} + +BOOL SHARED_EXPORT uTextOutColorsTabbed(HDC dc,const char * p_text,UINT len,const RECT * item,int border,const RECT * clip,BOOL selected,DWORD default_color,BOOL use_columns) +{ + try { + pfc::stringcvt::string_os_from_utf8 temp(p_text); + return text_out_colors_tab(dc,temp,pfc::downcast_guarded(temp.length()),item,border,clip,!!selected,default_color,!!use_columns); + } catch(...) {return FALSE;} +} + +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/shared/utf8.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/shared/utf8.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,226 @@ +#include "shared.h" + +#include + +using namespace pfc; + +extern "C" { + +#if 0 +inline static unsigned q_tolower(unsigned c) +{ + if (c>='A' && c<='Z') c += 'a' - 'A'; + return c; +} +#else +static const t_uint8 ascii_tolower_table[128] = {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F,0x40,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x5B,0x5C,0x5D,0x5E,0x5F,0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x7B,0x7C,0x7D,0x7E,0x7F}; +#define q_tolower(c) ascii_tolower_table[(unsigned)c] +#endif + + +unsigned SHARED_EXPORT uCharLower(unsigned param) +{ + return pfc::charLower(param); +} + +unsigned SHARED_EXPORT uCharUpper(unsigned param) +{ + return pfc::charUpper(param); +} + +static inline int compare_wchar(unsigned c1,unsigned c2) throw() +{ + if (c1==c2) return 0; + c1 = pfc::charLower(c1); + c2 = pfc::charLower(c2); + if (c1c2) return 1; + else return 0; +} + + +int SHARED_EXPORT stricmp_utf8(const char * p1,const char * p2) throw() +{ + for(;;) + { + if (*p1>=0 && *p2>=0)//signed char + { + unsigned c1 = q_tolower(*p1), c2 = q_tolower(*p2); + if (c1c2) return 1; + else if (c1 == 0) return 0; + else + { + p1++; + p2++; + } + } + else + { + unsigned w1,w2; t_size d1,d2; + d1 = utf8_decode_char(p1,w1); + d2 = utf8_decode_char(p2,w2); + if (d1 == 0 && d2 == 0) return 0; + else if (d1==0) return -1; + else if (d2==0) return 1; + int rv = compare_wchar(w1,w2); + if (rv) return rv; + p1 += d1; + p2 += d2; + } + } +} + +int SHARED_EXPORT stricmp_utf8_stringtoblock(const char * p1,const char * p2,t_size p2_bytes) throw() +{ + return stricmp_utf8_ex(p1,-1,p2,p2_bytes); +} + +int SHARED_EXPORT stricmp_utf8_partial(const char * p1,const char * p2,t_size num) throw() +{ + for(;num;) + { + unsigned w1,w2; t_size d1,d2; + d1 = utf8_decode_char(p1,w1); + d2 = utf8_decode_char(p2,w2); + if (w2==0 || d2==0) return 0; + int rv = compare_wchar(w1,w2); + if (rv) return rv; + p1 += d1; + p2 += d2; + num--; + } + return 0; +} + +int SHARED_EXPORT stricmp_utf8_max(const char * p1,const char * p2,t_size p1_bytes) throw() +{ + return stricmp_utf8_ex(p1,p1_bytes,p2,-1); +} + +namespace { + typedef bool (*t_replace_test)(const char * src,const char * test,t_size len); + + static bool replace_test_i(const char * src,const char * test,t_size len) + { + return stricmp_utf8_max(src,test,len)==0; + } + + static bool replace_test(const char * src,const char * test,t_size len) + { + t_size ptr; + bool rv = true; + for(ptr=0;ptr0) + { + t_size ptr = 0; + while(ptr+len1<=len) + { + if (testfunc(src+ptr,s1,len1)) + { + count++; + out.add_string(s2,len2); + ptr += len1; + } + else out.add_byte(src[ptr++]); + } + if (ptr0); + assert(c2>0); + char s1[8],s2[8]; + t_size len1,len2; + len1 = utf8_encode_char(c1,s1); + len2 = utf8_encode_char(c2,s2); + return uReplaceString(out,src,src_len,s1,len1,s2,len2,casesens); +} + + +void SHARED_EXPORT uAddStringLower(string_base & out,const char * src,t_size len) +{ + while(len && *src) + { + unsigned c; t_size d; + d = utf8_decode_char(src,c,len); + if (d==0 || d>len) break; + out.add_char(uCharLower(c)); + src+=d; + len-=d; + } +} + +void SHARED_EXPORT uAddStringUpper(string_base & out,const char * src,t_size len) +{ + while(len && *src) + { + unsigned c; t_size d; + d = utf8_decode_char(src,c,len); + if (d==0 || d>len) break; + out.add_char(uCharUpper(c)); + src+=d; + len-=d; + } +} + +int SHARED_EXPORT stricmp_utf8_ex(const char * p1,t_size p1_bytes,const char * p2,t_size p2_bytes) throw() +{ + p1_bytes = strlen_max(p1,p1_bytes); + p2_bytes = strlen_max(p2,p2_bytes); + for(;;) + { + if (p1_bytes == 0 && p2_bytes == 0) return 0; + else if (p1_bytes == 0) return -1; + else if (p2_bytes == 0) return 1; + else if (*p1>0 && *p2>0)//signed char + { + unsigned c1 = q_tolower(*p1), c2 = q_tolower(*p2); + if (c1c2) return 1; + else + { + p1++; + p2++; + p1_bytes--; + p2_bytes--; + } + } + else + { + unsigned w1,w2; + auto d1 = utf8_decode_char(p1,w1,p1_bytes); + auto d2 = utf8_decode_char(p2,w2,p2_bytes); + if (d1==0) return -1; + if (d2==0) return 1; + int rv = compare_wchar(w1,w2); + if (rv) return rv; + p1 += d1; + p2 += d2; + p1_bytes -= d1; + p2_bytes -= d2; + } + } +} + +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/shared/utf8api.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/shared/utf8api.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,1186 @@ +#include "shared.h" + + +#include + +#ifndef BIF_NEWDIALOGSTYLE +#define BIF_NEWDIALOGSTYLE 0x0040 +#endif + +using namespace pfc; + +class param_os_from_utf8 +{ + bool m_is_null; + WORD m_low_word; + stringcvt::string_os_from_utf8 m_cvt; +public: + param_os_from_utf8(const char * p) : + m_is_null(p==NULL), + m_low_word( ((t_size)p & ~0xFFFF) == 0 ? (WORD)((t_size)p & 0xFFFF) : 0), + m_cvt( p != NULL && ((t_size)p & ~0xFFFF) != 0 ? p : "") + {} + operator const TCHAR *() + { + return get_ptr(); + } + const TCHAR * get_ptr() + { + return m_low_word ? (const TCHAR*)(t_size)m_low_word : m_is_null ? 0 : m_cvt.get_ptr(); + } + +}; + + + +extern "C" { + +LRESULT SHARED_EXPORT uSendMessageText(HWND wnd,UINT msg,WPARAM wp,const char * p_text) +{ + if (p_text == NULL) + return SendMessage(wnd,msg,wp,0); + else { + stringcvt::string_os_from_utf8 temp; + temp.convert(p_text); + return SendMessage(wnd,msg,wp,(LPARAM)temp.get_ptr()); + } +} + +LRESULT SHARED_EXPORT uSendDlgItemMessageText(HWND wnd,UINT id,UINT msg,WPARAM wp,const char * text) +{ + return uSendMessageText(uGetDlgItem(wnd,id),msg,wp,text);//SendDlgItemMessage(wnd,id,msg,wp,(long)(const TCHAR*)string_os_from_utf8(text)); +} + +BOOL SHARED_EXPORT uGetWindowText(HWND wnd,string_base & out) +{ + PFC_ASSERT( wnd != NULL ); + int len = GetWindowTextLength(wnd); + if (len>0) + { + len++; + pfc::array_t temp; + temp.set_size(len); + temp[0]=0; + if (GetWindowText(wnd,temp.get_ptr(),len)>0) + { + out = stringcvt::string_utf8_from_os(temp.get_ptr(),len); + return TRUE; + } + else return FALSE; + } + else + { + out.reset(); + return TRUE; + } +} + +BOOL SHARED_EXPORT uSetWindowTextEx(HWND wnd,const char * p_text,size_t p_text_length) +{ + return SetWindowText(wnd,stringcvt::string_os_from_utf8(p_text, p_text_length)); +} + + +BOOL SHARED_EXPORT uGetDlgItemText(HWND wnd,UINT id,string_base & out) +{ + return uGetWindowText(GetDlgItem(wnd,id),out); +} + +BOOL SHARED_EXPORT uSetDlgItemTextEx(HWND wnd,UINT id,const char * p_text,size_t p_text_length) +{ + return SetDlgItemText(wnd,id,stringcvt::string_os_from_utf8(p_text,p_text_length)); +} + +int SHARED_EXPORT uMessageBox(HWND wnd,const char * text,const char * caption,UINT type) +{ + modal_dialog_scope scope(wnd); + return MessageBox(wnd,param_os_from_utf8(text),param_os_from_utf8(caption),type); +} + +void SHARED_EXPORT uOutputDebugString(const char * msg) {OutputDebugString(stringcvt::string_os_from_utf8(msg));} + +BOOL SHARED_EXPORT uAppendMenu(HMENU menu,UINT flags,UINT_PTR id,const char * content) +{ + return AppendMenu(menu,flags,id,param_os_from_utf8(content)); +} + +BOOL SHARED_EXPORT uInsertMenu(HMENU menu,UINT position,UINT flags,UINT_PTR id,const char * content) +{ + return InsertMenu(menu,position,flags,id,param_os_from_utf8(content)); +} + +int SHARED_EXPORT uCharCompare(t_uint32 p_char1,t_uint32 p_char2) { +#ifdef UNICODE + wchar_t temp1[4],temp2[4]; + temp1[utf16_encode_char(p_char1,temp1)]=0; + temp2[utf16_encode_char(p_char2,temp2)]=0; + return lstrcmpiW(temp1,temp2); +#else + wchar_t temp1[4],temp2[4]; + char ctemp1[20],ctemp2[20]; + temp1[utf16_encode_char(p_char1,temp1)]=0; + temp2[utf16_encode_char(p_char2,temp2)]=0; + WideCharToMultiByte(CP_ACP,0,temp1,-1,ctemp1,_countof(ctemp1),0,0); + WideCharToMultiByte(CP_ACP,0,temp2,-1,ctemp2,_countof(ctemp2),0,0); + return lstrcmpiA(ctemp1,ctemp2); +#endif +} + +int SHARED_EXPORT uStringCompare(const char * elem1, const char * elem2) { + for(;;) { + unsigned c1,c2; t_size l1,l2; + l1 = utf8_decode_char(elem1,c1); + l2 = utf8_decode_char(elem2,c2); + if (l1==0 && l2==0) return 0; + if (c1!=c2) { + int test = uCharCompare(c1,c2); + if (test) return test; + } + elem1 += l1; + elem2 += l2; + } +} + +int SHARED_EXPORT uStringCompare_ConvertNumbers(const char * elem1,const char * elem2) { + for(;;) { + if (pfc::char_is_numeric(*elem1) && pfc::char_is_numeric(*elem2)) { + t_size delta1 = 1, delta2 = 1; + while(pfc::char_is_numeric(elem1[delta1])) delta1++; + while(pfc::char_is_numeric(elem2[delta2])) delta2++; + int test = pfc::compare_t(pfc::atoui64_ex(elem1,delta1),pfc::atoui64_ex(elem2,delta2)); + if (test != 0) return test; + elem1 += delta1; + elem2 += delta2; + } else { + unsigned c1,c2; t_size l1,l2; + l1 = utf8_decode_char(elem1,c1); + l2 = utf8_decode_char(elem2,c2); + if (l1==0 && l2==0) return 0; + if (c1!=c2) { + int test = uCharCompare(c1,c2); + if (test) return test; + } + elem1 += l1; + elem2 += l2; + } + } +} + +HINSTANCE SHARED_EXPORT uLoadLibrary(const char * name) +{ + return LoadLibrary(param_os_from_utf8(name)); +} + +HANDLE SHARED_EXPORT uCreateEvent(LPSECURITY_ATTRIBUTES lpEventAttributes,BOOL bManualReset,BOOL bInitialState, const char * lpName) +{ + return CreateEvent(lpEventAttributes,bManualReset,bInitialState, param_os_from_utf8(lpName)); +} + +DWORD SHARED_EXPORT uGetModuleFileName(HMODULE hMod,string_base & out) +{ + try { + pfc::array_t buffer; buffer.set_size(256); + for(;;) { + DWORD ret = GetModuleFileName(hMod,buffer.get_ptr(), (DWORD)buffer.get_size()); + if (ret == 0) return 0; + if (ret < buffer.get_size()) break; + buffer.set_size(buffer.get_size() * 2); + } + out = stringcvt::string_utf8_from_os(buffer.get_ptr(),buffer.get_size()); + return (DWORD) out.length(); + } catch(...) { + return 0; + } +} + +BOOL SHARED_EXPORT uSetClipboardRawData(UINT format,const void * ptr,t_size size) { + try { + HANDLE buffer = GlobalAlloc(GMEM_DDESHARE,size); + if (buffer == NULL) throw std::bad_alloc(); + try { + CGlobalLockScope lock(buffer); + PFC_ASSERT(lock.GetSize() == size); + memcpy(lock.GetPtr(),ptr,size); + } catch(...) { + GlobalFree(buffer); throw; + } + + if (SetClipboardData(format,buffer) == NULL) throw pfc::exception_bug_check(); + return TRUE; + } catch(...) { + return FALSE; + } +} +BOOL SHARED_EXPORT uSetClipboardString(const char * ptr) +{ + try { + CClipboardOpenScope scope; + if (!scope.Open(NULL)) return FALSE; + EmptyClipboard(); + stringcvt::string_os_from_utf8 temp(ptr); + return uSetClipboardRawData( + #ifdef UNICODE + CF_UNICODETEXT + #else + CF_TEXT + #endif + ,temp.get_ptr(), (temp.length() + 1) * sizeof(TCHAR)); + } catch(...) { + return FALSE; + } +} + +BOOL SHARED_EXPORT uGetClipboardString(pfc::string_base & p_out) { + try { + CClipboardOpenScope scope; + if (!scope.Open(NULL)) return FALSE; + HANDLE data = GetClipboardData( + #ifdef UNICODE + CF_UNICODETEXT + #else + CF_TEXT + #endif + ); + if (data == NULL) return FALSE; + + CGlobalLockScope lock(data); + p_out = pfc::stringcvt::string_utf8_from_os( (const TCHAR*) lock.GetPtr(), lock.GetSize() / sizeof(TCHAR) ); + return TRUE; + } catch(...) { + return FALSE; + } +} + + +BOOL SHARED_EXPORT uGetClassName(HWND wnd,string_base & out) +{ + TCHAR temp[512]; + temp[0]=0; + if (GetClassName(wnd,temp,_countof(temp))>0) + { + out = stringcvt::string_utf8_from_os(temp,_countof(temp)); + return TRUE; + } + else return FALSE; +} + +t_size SHARED_EXPORT uCharLength(const char * src) {return utf8_char_len(src);} + +BOOL SHARED_EXPORT uDragQueryFile(HDROP hDrop,UINT idx,string_base & out) +{ + UINT len = DragQueryFile(hDrop,idx,0,0); + if (len>0 && len!=(UINT)(~0)) + { + len++; + array_t temp; + temp.set_size(len); + temp[0] =0 ; + if (DragQueryFile(hDrop,idx,temp.get_ptr(),len)>0) + { + out = stringcvt::string_utf8_from_os(temp.get_ptr(),len); + return TRUE; + } + } + return FALSE; +} + +UINT SHARED_EXPORT uDragQueryFileCount(HDROP hDrop) +{ + return DragQueryFile(hDrop,-1,0,0); +} + + + +BOOL SHARED_EXPORT uGetTextExtentPoint32(HDC dc,const char * text,UINT cb,LPSIZE size) +{ + stringcvt::string_os_from_utf8 temp(text,cb); + return GetTextExtentPoint32(dc,temp,pfc::downcast_guarded(temp.length()),size); +} + +BOOL SHARED_EXPORT uExtTextOut(HDC dc,int x,int y,UINT flags,const RECT * rect,const char * text,UINT cb,const int * lpdx) +{ + stringcvt::string_os_from_utf8 temp(text,cb); + return ExtTextOut(dc,x,y,flags,rect,temp,pfc::downcast_guarded(_tcslen(temp)),lpdx); +} + +static UINT_PTR CALLBACK choose_color_hook(HWND wnd,UINT msg,WPARAM wp,LPARAM lp) +{ + switch(msg) + { + case WM_INITDIALOG: + { + CHOOSECOLOR * cc = reinterpret_cast(lp); + reinterpret_cast(cc->lCustData)->initialize(FindOwningPopup(wnd)); + } + return 0; + default: + return 0; + } +} + +BOOL SHARED_EXPORT uChooseColor(DWORD * p_color,HWND parent,DWORD * p_custom_colors) +{ + modal_dialog_scope scope; + + CHOOSECOLOR cc = {}; + cc.lStructSize = sizeof(cc); + cc.hwndOwner = parent; + cc.rgbResult = *p_color; + cc.lpCustColors = p_custom_colors; + cc.Flags = CC_ANYCOLOR|CC_FULLOPEN|CC_RGBINIT|CC_ENABLEHOOK; + cc.lpfnHook = choose_color_hook; + cc.lCustData = reinterpret_cast(&scope); + BOOL rv = ChooseColor(&cc); + if (rv) + { + *p_color = cc.rgbResult; + return TRUE; + } + else return FALSE; +} + +HCURSOR SHARED_EXPORT uLoadCursor(HINSTANCE hIns,const char * name) +{ + return LoadCursor(hIns,param_os_from_utf8(name)); +} + +HICON SHARED_EXPORT uLoadIcon(HINSTANCE hIns,const char * name) +{ + return LoadIcon(hIns,param_os_from_utf8(name)); +} + +HMENU SHARED_EXPORT uLoadMenu(HINSTANCE hIns,const char * name) +{ + return LoadMenu(hIns,param_os_from_utf8(name)); +} + + + +BOOL SHARED_EXPORT uGetEnvironmentVariable(const char * name,string_base & out) +{ + stringcvt::string_os_from_utf8 name_t(name); + DWORD size = GetEnvironmentVariable(name_t,0,0); + if (size>0) + { + size++; + array_t temp; + temp.set_size(size); + temp[0]=0; + if (GetEnvironmentVariable(name_t,temp.get_ptr(),size)>0) + { + out = stringcvt::string_utf8_from_os(temp.get_ptr(),size); + return TRUE; + } + } + return FALSE; +} + +HMODULE SHARED_EXPORT uGetModuleHandle(const char * name) +{ + return GetModuleHandle(param_os_from_utf8(name)); +} + +UINT SHARED_EXPORT uRegisterWindowMessage(const char * name) +{ + return RegisterWindowMessage(stringcvt::string_os_from_utf8(name)); +} + +BOOL SHARED_EXPORT uMoveFile(const char * src,const char * dst) +{ + return MoveFile(stringcvt::string_os_from_utf8(src),stringcvt::string_os_from_utf8(dst)); +} + +BOOL SHARED_EXPORT uDeleteFile(const char * fn) +{ + return DeleteFile(stringcvt::string_os_from_utf8(fn)); +} + +DWORD SHARED_EXPORT uGetFileAttributes(const char * fn) +{ + PFC_ASSERT( ! pfc::string_has_prefix_i( fn, "file://" ) ); + return GetFileAttributes(stringcvt::string_os_from_utf8(fn)); +} + +BOOL SHARED_EXPORT uRemoveDirectory(const char * fn) +{ + return RemoveDirectory(stringcvt::string_os_from_utf8(fn)); +} + +HANDLE SHARED_EXPORT uCreateFile(const char * fn,DWORD access,DWORD share,LPSECURITY_ATTRIBUTES blah,DWORD creat,DWORD flags,HANDLE tmpl) +{ + return CreateFile(stringcvt::string_os_from_utf8(fn),access,share,blah,creat,flags,tmpl); +} + +BOOL SHARED_EXPORT uCreateDirectory(const char * fn,LPSECURITY_ATTRIBUTES blah) +{ + return CreateDirectory(stringcvt::string_os_from_utf8(fn),blah); +} + +HANDLE SHARED_EXPORT uCreateMutex(LPSECURITY_ATTRIBUTES blah,BOOL bInitialOwner,const char * name) +{ + return name ? CreateMutex(blah,bInitialOwner,stringcvt::string_os_from_utf8(name)) : CreateMutex(blah,bInitialOwner,0); +} + +BOOL SHARED_EXPORT uGetFullPathName(const char * name,string_base & out) +{ + stringcvt::string_os_from_utf8 name_os(name); + unsigned len = GetFullPathName(name_os,0,0,0); + if (len==0) return FALSE; + array_t temp; + temp.set_size(len+1); + TCHAR * blah; + if (GetFullPathName(name_os,len+1,temp.get_ptr(),&blah)==0) return FALSE; + out = stringcvt::string_utf8_from_os(temp.get_ptr(),len); + return TRUE; +} + +BOOL SHARED_EXPORT uGetLongPathName(const char * name,string_base & out) +{ + TCHAR temp[4096]; + temp[0]=0; + BOOL state = GetLongPathName(stringcvt::string_os_from_utf8(name),temp,_countof(temp)); + if (state) out = stringcvt::string_utf8_from_os(temp,_countof(temp)); + return state; +} + +void SHARED_EXPORT uGetCommandLine(string_base & out) +{ + out = stringcvt::string_utf8_from_os(GetCommandLine()); +} + +BOOL SHARED_EXPORT uGetTempPath(string_base & out) +{ + TCHAR temp[MAX_PATH+1]; + temp[0]=0; + if (GetTempPath(_countof(temp),temp)) + { + out = stringcvt::string_utf8_from_os(temp,_countof(temp)); + return TRUE; + } + return FALSE; + +} +BOOL SHARED_EXPORT uGetTempFileName(const char * path_name,const char * prefix,UINT unique,string_base & out) +{ + if (path_name==0 || prefix==0) return FALSE; + TCHAR temp[MAX_PATH+1]; + temp[0]=0; + if (GetTempFileName(stringcvt::string_os_from_utf8(path_name),stringcvt::string_os_from_utf8(prefix),unique,temp)) + { + out = stringcvt::string_utf8_from_os(temp,_countof(temp)); + return TRUE; + } + return FALSE; +} + +class uFindFile_i : public uFindFile +{ + string8 fn; + WIN32_FIND_DATA fd; + HANDLE hFF; +public: + uFindFile_i() {hFF = INVALID_HANDLE_VALUE;} + bool FindFirst(const char * path) + { + hFF = FindFirstFile(stringcvt::string_os_from_utf8(path),&fd); + if (hFF==INVALID_HANDLE_VALUE) return false; + fn = stringcvt::string_utf8_from_os(fd.cFileName,_countof(fd.cFileName)); + return true; + } + virtual BOOL FindNext() + { + if (hFF==INVALID_HANDLE_VALUE) return FALSE; + BOOL rv = FindNextFile(hFF,&fd); + if (rv) fn = stringcvt::string_utf8_from_os(fd.cFileName,_countof(fd.cFileName)); + return rv; + } + + virtual const char * GetFileName() + { + return fn; + } + + virtual t_uint64 GetFileSize() + { + union + { + t_uint64 val64; + struct + { + DWORD lo,hi; + }; + } ret; + + ret.hi = fd.nFileSizeHigh; + ret.lo = fd.nFileSizeLow; + return ret.val64; + + } + virtual DWORD GetAttributes() + { + return fd.dwFileAttributes; + } + + virtual FILETIME GetCreationTime() + { + return fd.ftCreationTime; + } + virtual FILETIME GetLastAccessTime() + { + return fd.ftLastAccessTime; + } + virtual FILETIME GetLastWriteTime() + { + return fd.ftLastWriteTime; + } + virtual ~uFindFile_i() + { + if (hFF!=INVALID_HANDLE_VALUE) FindClose(hFF); + } +}; + +puFindFile SHARED_EXPORT uFindFirstFile(const char * path) +{ + pfc::ptrholder_t ptr = new uFindFile_i; + if (!ptr->FindFirst(path)) { + ptr.release(); + return NULL; + } else { + return ptr.detach(); + } +} + +HINSTANCE SHARED_EXPORT uShellExecute(HWND wnd,const char * oper,const char * file,const char * params,const char * dir,int cmd) +{ + modal_dialog_scope modal; // IDIOCY - ShellExecute may spawn a modal dialog + if (wnd) modal.initialize(wnd); + return ShellExecute(wnd,param_os_from_utf8(oper),param_os_from_utf8(file),param_os_from_utf8(params),param_os_from_utf8(dir),cmd); +} + +HWND SHARED_EXPORT uCreateStatusWindow(LONG style,const char * text,HWND parent,UINT id) +{ + return CreateStatusWindow(style,param_os_from_utf8(text),parent,id); +} + +HWND SHARED_EXPORT uCreateWindowEx(DWORD dwExStyle,const char * lpClassName,const char * lpWindowName,DWORD dwStyle,int x,int y,int nWidth,int nHeight,HWND hWndParent,HMENU hMenu,HINSTANCE hInstance,LPVOID lpParam) +{ + return CreateWindowEx(dwExStyle,param_os_from_utf8(lpClassName),param_os_from_utf8(lpWindowName),dwStyle,x,y,nWidth,nHeight,hWndParent,hMenu,hInstance,lpParam); +} + +HANDLE SHARED_EXPORT uLoadImage(HINSTANCE hIns,const char * name,UINT type,int x,int y,UINT flags) +{ + return LoadImage(hIns,param_os_from_utf8(name),type,x,y,flags); +} + +BOOL SHARED_EXPORT uGetSystemDirectory(string_base & out) +{ + UINT len = GetSystemDirectory(0,0); + if (len==0) len = MAX_PATH; + len++; + array_t temp; + temp.set_size(len); + if (GetSystemDirectory(temp.get_ptr(),len)==0) return FALSE; + out = stringcvt::string_utf8_from_os(temp.get_ptr(),len); + return TRUE; +} + +BOOL SHARED_EXPORT uGetWindowsDirectory(string_base & out) +{ + UINT len = GetWindowsDirectory(0,0); + if (len==0) len = MAX_PATH; + len++; + array_t temp; + temp.set_size(len); + if (GetWindowsDirectory(temp.get_ptr(),len)==0) return FALSE; + out = stringcvt::string_utf8_from_os(temp.get_ptr(),len); + return TRUE; +} + +BOOL SHARED_EXPORT uSetCurrentDirectory(const char * path) +{ + return SetCurrentDirectory(stringcvt::string_os_from_utf8(path)); +} + +BOOL SHARED_EXPORT uGetCurrentDirectory(string_base & out) +{ + UINT len = GetCurrentDirectory(0,0); + if (len==0) len = MAX_PATH; + len++; + array_t temp; + temp.set_size(len); + if (GetCurrentDirectory(len,temp.get_ptr())==0) return FALSE; + out = stringcvt::string_utf8_from_os(temp.get_ptr(),len); + return TRUE; +} + +BOOL SHARED_EXPORT uExpandEnvironmentStrings(const char * src,string_base & out) +{ + stringcvt::string_os_from_utf8 src_os(src); + UINT len = ExpandEnvironmentStrings(src_os,0,0); + if (len==0) len = 256; + len++; + array_t temp; + temp.set_size(len); + if (ExpandEnvironmentStrings(src_os,temp.get_ptr(),len)==0) return FALSE; + out = stringcvt::string_utf8_from_os(temp.get_ptr(),len); + return TRUE; +} + +BOOL SHARED_EXPORT uGetUserName(string_base & out) +{ + TCHAR temp[UNLEN+1]; + DWORD len = _countof(temp); + if (GetUserName(temp,&len)) + { + out = stringcvt::string_utf8_from_os(temp,_countof(temp)); + return TRUE; + } + else return FALSE; +} + +BOOL SHARED_EXPORT uGetShortPathName(const char * src,string_base & out) +{ + stringcvt::string_os_from_utf8 src_os(src); + UINT len = GetShortPathName(src_os,0,0); + if (len==0) len = MAX_PATH; + len++; + array_t temp; temp.set_size(len); + if (GetShortPathName(src_os,temp.get_ptr(),len)) + { + out = stringcvt::string_utf8_from_os(temp.get_ptr(),len); + return TRUE; + } + else return FALSE; +} + + +#ifdef UNICODE +#define DDE_CODEPAGE CP_WINUNICODE +#else +#define DDE_CODEPAGE CP_WINANSI +#endif + + +HSZ SHARED_EXPORT uDdeCreateStringHandle(DWORD ins,const char * src) +{ + return DdeCreateStringHandle(ins,stringcvt::string_os_from_utf8(src),DDE_CODEPAGE); +} + +BOOL SHARED_EXPORT uDdeQueryString(DWORD ins,HSZ hsz,string_base & out) +{ + array_t temp; + UINT len = DdeQueryString(ins,hsz,0,0,DDE_CODEPAGE); + if (len==0) len = MAX_PATH; + len++; + temp.set_size(len); + if (DdeQueryString(ins,hsz,temp.get_ptr(),len,DDE_CODEPAGE)) + { + out = stringcvt::string_utf8_from_os(temp.get_ptr(),len); + return TRUE; + } + else return FALSE; +} + +UINT SHARED_EXPORT uDdeInitialize(LPDWORD pidInst,PFNCALLBACK pfnCallback,DWORD afCmd,DWORD ulRes) +{ + return DdeInitialize(pidInst,pfnCallback,afCmd,ulRes); +} + +BOOL SHARED_EXPORT uDdeAccessData_Text(HDDEDATA data,string_base & out) +{ + const TCHAR * ptr = (const TCHAR*) DdeAccessData(data,0); + if (ptr) + { + out = stringcvt::string_utf8_from_os(ptr); + return TRUE; + } + else return FALSE; +} + +uSortString_t SHARED_EXPORT uSortStringCreate(const char * src) { + t_size lenEst = pfc::stringcvt::estimate_utf8_to_wide(src,SIZE_MAX); + TCHAR * ret = pfc::__raw_malloc_t(lenEst); + pfc::stringcvt::convert_utf8_to_wide(ret,lenEst,src,SIZE_MAX); + return reinterpret_cast( ret ); +} + +int SHARED_EXPORT uSortStringCompareEx(uSortString_t string1, uSortString_t string2,uint32_t flags) { + return CompareString(LOCALE_USER_DEFAULT,flags,reinterpret_cast(string1),-1,reinterpret_cast(string2),-1); +} + +int SHARED_EXPORT uSortStringCompare(uSortString_t string1, uSortString_t string2) { + return lstrcmpi(reinterpret_cast(string1),reinterpret_cast(string2)); +} + +void SHARED_EXPORT uSortStringFree(uSortString_t string) { + pfc::__raw_free_t(reinterpret_cast(string)); +} + +HTREEITEM SHARED_EXPORT uTreeView_InsertItem(HWND wnd,const uTVINSERTSTRUCT * param) +{ + stringcvt::string_os_from_utf8 temp; + temp.convert(param->item.pszText); + + + TVINSERTSTRUCT l_param = {}; + l_param.hParent = param->hParent; + l_param.hInsertAfter = param->hInsertAfter; + l_param.item.mask = param->item.mask; + l_param.item.hItem = param->item.hItem; + l_param.item.state = param->item.state; + l_param.item.stateMask = param->item.stateMask; + l_param.item.pszText = const_cast(temp.get_ptr()); + l_param.item.cchTextMax = 0; + l_param.item.iImage = param->item.iImage; + l_param.item.iSelectedImage = param->item.iImage; + l_param.item.cChildren = param->item.cChildren; + l_param.item.lParam = param->item.lParam; + if (param->item.mask & TVIF_INTEGRAL) + { + l_param.itemex.iIntegral = param->itemex.iIntegral; + } + + return (HTREEITEM) uSendMessage(wnd,TVM_INSERTITEM,0,(LPARAM)&l_param); +} + +UINT SHARED_EXPORT uGetFontHeight(HFONT font) +{ + UINT ret; + HDC dc = CreateCompatibleDC(0); + SelectObject(dc,font); + ret = uGetTextHeight(dc); + DeleteDC(dc); + return ret; +} + + +HIMAGELIST SHARED_EXPORT uImageList_LoadImage(HINSTANCE hi, const char * lpbmp, int cx, int cGrow, COLORREF crMask, UINT uType, UINT uFlags) +{ + return ImageList_LoadImage(hi,param_os_from_utf8(lpbmp),cx,cGrow,crMask,uType,uFlags); +} + +int SHARED_EXPORT uTabCtrl_InsertItem(HWND wnd,t_size idx,const uTCITEM * item) +{ + param_os_from_utf8 text((item->mask & TCIF_TEXT) ? item->pszText : 0); + TCITEM l_item; + assert(sizeof(l_item)==sizeof(*item));//meh lazy + memcpy(&l_item,item,sizeof(l_item)); + l_item.pszText = const_cast(text.get_ptr()); + l_item.cchTextMax = 0; + return TabCtrl_InsertItem(wnd,idx,&l_item); +} + +int SHARED_EXPORT uTabCtrl_SetItem(HWND wnd,t_size idx,const uTCITEM * item) +{ + param_os_from_utf8 text((item->mask & TCIF_TEXT) ? item->pszText : 0); + TCITEM l_item; + PFC_STATIC_ASSERT(sizeof(l_item)==sizeof(*item));//meh lazy + memcpy(&l_item,item,sizeof(l_item)); + l_item.pszText = const_cast(text.get_ptr()); + l_item.cchTextMax = 0; + return TabCtrl_SetItem(wnd,idx,&l_item); +} + +int SHARED_EXPORT uGetKeyNameText(LONG lparam,string_base & out) +{ + TCHAR temp[256]; + temp[0]=0; + if (!GetKeyNameText(lparam,temp,_countof(temp))) return 0; + out = stringcvt::string_utf8_from_os(temp,_countof(temp)); + return 1; +} + +HANDLE SHARED_EXPORT uCreateFileMapping(HANDLE hFile,LPSECURITY_ATTRIBUTES lpFileMappingAttributes,DWORD flProtect,DWORD dwMaximumSizeHigh,DWORD dwMaximumSizeLow,const char * lpName) +{ + return CreateFileMapping(hFile,lpFileMappingAttributes,flProtect,dwMaximumSizeHigh,dwMaximumSizeLow,param_os_from_utf8(lpName)); +} + +BOOL SHARED_EXPORT uListBox_GetText(HWND listbox,UINT index,string_base & out) +{ + t_size len = uSendMessage(listbox,LB_GETTEXTLEN,index,0); + if (len==LB_ERR || len>16*1024*1024) return FALSE; + if (len==0) {out.reset();return TRUE;} + + array_t temp; temp.set_size(len+1); + pfc::memset_t(temp,(TCHAR)0); + len = uSendMessage(listbox,LB_GETTEXT,index,(LPARAM)temp.get_ptr()); + if (len==LB_ERR) return false; + out = stringcvt::string_utf8_from_os(temp.get_ptr()); + return TRUE; +} +/* +void SHARED_EXPORT uPrintf(string_base & out,const char * fmt,...) +{ + va_list list; + va_start(list,fmt); + uPrintfV(out,fmt,list); + va_end(list); +} +*/ +void SHARED_EXPORT uPrintfV(string_base & out,const char * fmt,va_list arglist) +{ + pfc::string_printf_here_va(out, fmt, arglist); +} + +int SHARED_EXPORT uCompareString(DWORD flags,const char * str1,size_t len1,const char * str2,size_t len2) +{ + return CompareString(LOCALE_USER_DEFAULT,flags,stringcvt::string_os_from_utf8(str1,len1),-1,stringcvt::string_os_from_utf8(str2,len2),-1); +} + +class uResource_i : public uResource +{ + unsigned size; + const void * ptr; +public: + inline uResource_i(const void * p_ptr,unsigned p_size) : ptr(p_ptr), size(p_size) + { + } + virtual const void * GetPointer() + { + return ptr; + } + virtual unsigned GetSize() + { + return size; + } + virtual ~uResource_i() + { + } +}; + +puResource SHARED_EXPORT uLoadResource(HMODULE hMod,const char * name,const char * type,WORD wLang) +{ + HRSRC res = uFindResource(hMod,name,type,wLang); + if (res==0) return 0; + HGLOBAL hglob = LoadResource(hMod,res); + if (hglob) + { + void * ptr = LockResource(hglob); + if (ptr) + { + return new uResource_i(ptr,SizeofResource(hMod,res)); + } + else return 0; + } + else return 0; +} + +puResource SHARED_EXPORT LoadResourceEx(HMODULE hMod,const TCHAR * name,const TCHAR * type,WORD wLang) +{ + HRSRC res = wLang ? FindResourceEx(hMod,type,name,wLang) : FindResource(hMod,name,type); + if (res==0) return 0; + HGLOBAL hglob = LoadResource(hMod,res); + if (hglob) + { + void * ptr = LockResource(hglob); + if (ptr) + { + return new uResource_i(ptr,SizeofResource(hMod,res)); + } + else return 0; + } + else return 0; +} + +HRSRC SHARED_EXPORT uFindResource(HMODULE hMod,const char * name,const char * type,WORD wLang) +{ + return wLang ? FindResourceEx(hMod,param_os_from_utf8(type),param_os_from_utf8(name),wLang) : FindResource(hMod,param_os_from_utf8(name),param_os_from_utf8(type)); +} + +BOOL SHARED_EXPORT uLoadString(HINSTANCE ins,UINT id,string_base & out) +{ + BOOL rv = FALSE; + uResource * res = uLoadResource(ins,uMAKEINTRESOURCE(id),(const char*)(RT_STRING)); + if (res) + { + unsigned size = res->GetSize(); + const WCHAR * ptr = (const WCHAR*)res->GetPointer(); + if (size>=4) + { + unsigned len = *(const WORD*)(ptr+1); + if (len * 2 + 4 <= size) + { + out = stringcvt::string_utf8_from_wide(ptr+2,len); + } + } + + delete res; + rv = TRUE; + } + return rv; +} + +BOOL SHARED_EXPORT uGetMenuString(HMENU menu,UINT id,string_base & out,UINT flag) +{ + unsigned len = GetMenuString(menu,id,0,0,flag); + if (len==0) + { + out.reset(); + return FALSE; + } + array_t temp; + temp.set_size(len+1); + if (GetMenuString(menu,id,temp.get_ptr(),len+1,flag)==0) { + out.reset(); + return FALSE; + } + out = stringcvt::string_utf8_from_os(temp.get_ptr()); + return TRUE; +} + +BOOL SHARED_EXPORT uModifyMenu(HMENU menu,UINT id,UINT flags,UINT newitem,const char * data) +{ + return ModifyMenu(menu,id,flags,newitem,param_os_from_utf8(data)); +} + +UINT SHARED_EXPORT uGetMenuItemType(HMENU menu,UINT position) +{ + MENUITEMINFO info = {}; + info.cbSize = sizeof(info); + info.fMask = MIIM_TYPE; + if (!GetMenuItemInfo(menu,position,TRUE,&info)) + return 0; + return info.fType; +} + +static inline bool i_is_path_separator(unsigned c) +{ + return c=='\\' || c=='/' || c=='|' || c==':'; +} + +int SHARED_EXPORT uSortPathCompare(HANDLE string1,HANDLE string2) +{ + const TCHAR * s1 = reinterpret_cast(string1); + const TCHAR * s2 = reinterpret_cast(string2); + const TCHAR * p1, * p2; + + while (*s1 || *s2) + { + if (*s1 == *s2) + { + s1++; + s2++; + continue; + } + + p1 = s1; while (*p1 && !i_is_path_separator(*p1)) p1++; + p2 = s2; while (*p2 && !i_is_path_separator(*p2)) p2++; + + if ((!*p1 && !*p2) || (*p1 && *p2)) + { + int test = CompareString(LOCALE_USER_DEFAULT, NORM_IGNORECASE | NORM_IGNOREKANATYPE | NORM_IGNOREWIDTH, s1, pfc::downcast_guarded(p1 - s1), s2, pfc::downcast_guarded(p2 - s2)); + if (test && test != 2) return test - 2; + if (!*p1) return 0; + } + else + { + if (*p1) return -1; + else return 1; + } + + s1 = p1 + 1; + s2 = p2 + 1; + } + + return 0; +} + +UINT SHARED_EXPORT uRegisterClipboardFormat(const char * name) +{ + return RegisterClipboardFormat(stringcvt::string_os_from_utf8(name)); +} + +BOOL SHARED_EXPORT uGetClipboardFormatName(UINT format,string_base & out) +{ + TCHAR temp[1024]; + if (!GetClipboardFormatName(format,temp,_countof(temp))) return FALSE; + out = stringcvt::string_utf8_from_os(temp,_countof(temp)); + return TRUE; +} + +}//extern "C" + +BOOL SHARED_EXPORT uSearchPath(const char * path, const char * filename, const char * extension, string_base & p_out) +{ + enum {temp_size = 1024}; + param_os_from_utf8 path_os(path), filename_os(filename), extension_os(extension); + array_t temp; temp.set_size(temp_size); + LPTSTR dummy; + unsigned len; + + len = SearchPath(path_os,filename_os,extension_os,temp_size,temp.get_ptr(),&dummy); + if (len == 0) return FALSE; + if (len >= temp_size) + { + unsigned len2; + temp.set_size(len + 1); + len2 = SearchPath(path_os,filename_os,extension_os,len+1,temp.get_ptr(),&dummy); + if (len2 == 0 || len2 > len) return FALSE; + len = len2; + } + + p_out = stringcvt::string_utf8_from_os(temp.get_ptr(),len); + + return TRUE; + +} + +static bool is_ascii_alpha(char c) +{ + return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); +} + +static char ascii_upper(char c) +{ + if (c >= 'a' && c <= 'z') c += 'A' - 'a'; + return c; +} + +static BOOL uFixPathCaps_Internal(const char * path,string_base & p_out, bool bQuick) { + pfc::string8_fastalloc temp, prependbuffer; + if (path[0] == '\\' && path[1] == '\\') + { + unsigned index = 2; + while(path[index] != '\\') + { + if (path[index] == 0) return FALSE; + index++; + } + index++; + if (path[index] == '\\' || path[index] == 0) return FALSE; + while(path[index] != '\\') + { + if (path[index] == 0) { + // \\host\share + uStringLower(p_out,path); + return TRUE; + } + index++; + } + index++; + if (path[index] == '\\') return FALSE; + uAddStringLower(temp,path,index); + path += index; + } + else if (is_ascii_alpha(path[0]) && path[1] == ':' && path[2] == '\\') + { + temp.add_char(ascii_upper(path[0])); + temp.add_string(":\\"); + path += 3; + } + else return FALSE; + + for(;;) + { + t_size truncat = temp.length(); + t_size delta = 0; + while(path[delta]!=0 && path[delta]!='\\') delta++; + if (delta == 0) break; + temp.add_string_nc(path,delta); + + bool found = false; + if (!bQuick) { +#ifdef UNICODE + pfc::winPrefixPath( prependbuffer, temp ); + pfc::ptrholder_t ff = uFindFirstFile(prependbuffer); +#else + pfc::ptrholder_t ff = uFindFirstFile(temp); +#endif + if (ff.is_valid()) { + do { + const char * fn = ff->GetFileName(); + if (!stricmp_utf8_ex(path,delta,fn,strlen(fn))) + { + found = true; + temp.truncate(truncat); + temp.add_string(fn); + break; + } + } while(ff->FindNext()); + } + } + if (!found) + { + temp.add_string(path + delta); + break; + } + path += delta; + if (*path == 0) break; + path ++; + temp.add_char('\\'); + } + + + p_out = temp; + + return TRUE; +} +/*BOOL SHARED_EXPORT uFixPathCapsQuick(const char * path,string_base & p_out) { + return uFixPathCaps_Internal(path, p_out, true); +}*/ +BOOL SHARED_EXPORT uFixPathCaps(const char * path,string_base & p_out) { + return uFixPathCaps_Internal(path, p_out, false); +} + +LPARAM SHARED_EXPORT uTreeView_GetUserData(HWND p_tree,HTREEITEM p_item) +{ + TVITEM item = {}; + item.mask = TVIF_PARAM; + item.hItem = p_item; + if (uSendMessage(p_tree,TVM_GETITEM,0,(LPARAM)&item)) + return item.lParam; + return 0; +} + +bool SHARED_EXPORT uTreeView_GetText(HWND p_tree,HTREEITEM p_item,string_base & p_out) +{ + TCHAR temp[1024];//changeme ? + TVITEM item = {}; + item.mask = TVIF_TEXT; + item.hItem = p_item; + item.pszText = temp; + item.cchTextMax = _countof(temp); + if (uSendMessage(p_tree,TVM_GETITEM,0,(LPARAM)&item)) + { + p_out = stringcvt::string_utf8_from_os(temp,_countof(temp)); + return true; + } + else return false; +} + +BOOL SHARED_EXPORT uSetWindowText(HWND wnd,const char * p_text) +{ + PFC_ASSERT( wnd != NULL ); + return SetWindowText(wnd,stringcvt::string_os_from_utf8(p_text)); +} + +BOOL SHARED_EXPORT uSetDlgItemText(HWND wnd,UINT id,const char * p_text) +{ + PFC_ASSERT( wnd != NULL ); + return SetDlgItemText(wnd, id, stringcvt::string_os_from_utf8(p_text)); +} + +BOOL SHARED_EXPORT uFileExists(const char * fn) +{ + DWORD attrib = uGetFileAttributes(fn); + if (attrib == 0xFFFFFFFF || (attrib & FILE_ATTRIBUTE_DIRECTORY)) return FALSE; + return TRUE; +} + +BOOL SHARED_EXPORT uFormatSystemErrorMessage(string_base & p_out,DWORD p_code) { + return pfc::winFormatSystemErrorMessage(p_out, p_code); +} + +HMODULE SHARED_EXPORT LoadSystemLibrary(const TCHAR * name) { + pfc::array_t buffer; buffer.set_size( MAX_PATH + _tcslen(name) + 2 ); + TCHAR * bufptr = buffer.get_ptr(); + if (GetSystemDirectory(bufptr, MAX_PATH) == 0) return NULL; + bufptr[MAX_PATH] = 0; + + size_t idx = _tcslen(bufptr); + if (idx > 0 && bufptr[idx-1] != '\\') bufptr[idx++] = '\\'; + + pfc::strcpy_t(bufptr+idx, name); + + return LoadLibrary(bufptr); +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/foobar2000/shared/win32_misc.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/shared/win32_misc.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,33 @@ +#pragma once + + +class win32_font { +public: + win32_font(HFONT p_initval) : m_font(p_initval) {} + win32_font() : m_font(NULL) {} + ~win32_font() {release();} + + void release() { + HFONT temp = detach(); + if (temp != NULL) DeleteObject(temp); + } + + void set(HFONT p_font) {release(); m_font = p_font;} + HFONT get() const {return m_font;} + HFONT detach() {return pfc::replace_t(m_font,(HFONT)NULL);} + + void create(const t_font_description & p_desc) { + SetLastError(NO_ERROR); + HFONT temp = p_desc.create(); + if (temp == NULL) throw exception_win32(GetLastError()); + set(temp); + } + + bool is_valid() const {return m_font != NULL;} + +private: + win32_font(const win32_font&) = delete; + void operator=(const win32_font &) = delete; + + HFONT m_font; +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/AutoComplete.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/AutoComplete.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,70 @@ +#include "stdafx.h" +#include "AutoComplete.h" +#include "pp-COM-macros.h" + +#include // CLSID_AutoComplete + +#include "CEnumString.h" +using PP::CEnumString; + +HRESULT InitializeSimpleAC(HWND edit, IUnknown * vals, DWORD opts) { + pfc::com_ptr_t ac; + HRESULT hr; + hr = CoCreateInstance(CLSID_AutoComplete, NULL, CLSCTX_ALL, IID_IAutoComplete, (void**)ac.receive_ptr()); + if (FAILED(hr)) { + PFC_ASSERT(!"Should not get here - CoCreateInstance/IAutoComplete fail!"); return hr; + } + hr = ac->Init(edit, vals, NULL, NULL); + if (FAILED(hr)) { + PFC_ASSERT(!"Should not get here - ac->Init fail!"); return hr; + } + + pfc::com_ptr_t ac2; + hr = ac->QueryInterface(ac2.receive_ptr()); + if (FAILED(hr)) { + PFC_ASSERT(!"Should not get here - ac->QueryInterface fail!"); return hr; + } + hr = ac2->SetOptions(opts); + if (FAILED(hr)) { + PFC_ASSERT(!"Should not get here - ac2->SetOptions fail!"); return hr; + } + return S_OK; +} + +pfc::com_ptr_t CreateACList(pfc::const_iterator valueEnum) { + pfc::com_ptr_t acl = new CEnumString::TImpl(); + while (valueEnum.is_valid()) { + acl->AddStringU(*valueEnum); ++valueEnum; + } + return acl; +} +pfc::com_ptr_t CreateACList(pfc::const_iterator valueEnum) { + pfc::com_ptr_t acl = new CEnumString::TImpl(); + while (valueEnum.is_valid()) { + acl->AddStringU(*valueEnum); ++valueEnum; + } + return acl; +} + +pfc::com_ptr_t CreateACList() { + return new CEnumString::TImpl(); +} + +void CreateACList_AddItem(IUnknown * theList, const char * item) { + static_cast(theList)->AddStringU(item); +} + +HRESULT InitializeEditAC(HWND edit, pfc::const_iterator valueEnum, DWORD opts) { + pfc::com_ptr_t acl = CreateACList(valueEnum); + return InitializeSimpleAC(edit, acl.get_ptr(), opts); +} +HRESULT InitializeEditAC(HWND edit, const char * values, DWORD opts) { + pfc::com_ptr_t acl = new CEnumString::TImpl(); + for (const char * walk = values;;) { + const char * next = strchr(walk, '\n'); + if (next == NULL) { acl->AddStringU(walk, SIZE_MAX); break; } + acl->AddStringU(walk, next - walk); + walk = next + 1; + } + return InitializeSimpleAC(edit, acl.get_ptr(), opts); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/AutoComplete.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/AutoComplete.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,11 @@ +#pragma once + +#include + +HRESULT InitializeEditAC(HWND edit, pfc::const_iterator valueEnum, DWORD opts = ACO_AUTOAPPEND | ACO_AUTOSUGGEST); +HRESULT InitializeEditAC(HWND edit, const char * values, DWORD opts = ACO_AUTOAPPEND | ACO_AUTOSUGGEST); +HRESULT InitializeSimpleAC(HWND edit, IUnknown * vals, DWORD opts); +pfc::com_ptr_t CreateACList(pfc::const_iterator valueEnum); +pfc::com_ptr_t CreateACList(pfc::const_iterator valueEnum); +pfc::com_ptr_t CreateACList(); +void CreateACList_AddItem(IUnknown * theList, const char * item); diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/CButtonLite.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/CButtonLite.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,259 @@ +#pragma once + +#include +#include +#include "wtl-pp.h" +#include "win32_op.h" +#include "DarkMode.h" + +typedef CWinTraits CButtonLiteTraits; + +class CButtonLite : public CWindowImpl { +public: + BEGIN_MSG_MAP_EX(CButtonLite) + MESSAGE_RANGE_HANDLER_EX(WM_MOUSEFIRST, WM_MOUSELAST, MousePassThru) + MSG_WM_MOUSELEAVE(OnMouseLeave) + MSG_WM_SETTEXT(OnSetText) + MSG_WM_PAINT( OnPaint ) + MSG_WM_MOUSEMOVE(OnMouseMove) + MSG_WM_LBUTTONDOWN(OnLButtonDown) + MSG_WM_SETFOCUS(OnSetFocus) + MSG_WM_KILLFOCUS(OnKillFocus) + MSG_WM_KEYDOWN(OnKeyDown) + MSG_WM_KEYUP(OnKeyUp) + MSG_WM_CHAR(OnChar) + MSG_WM_ENABLE(OnEnable) + MESSAGE_HANDLER_EX(WM_GETDLGCODE, OnGetDlgCode) + MSG_WM_SETFONT(OnSetFont) + MSG_WM_GETFONT(OnGetFont) + MSG_WM_CREATE(OnCreate) + END_MSG_MAP() + std::function ClickHandler; + + unsigned Measure() const { + auto font = myGetFont(); + LOGFONT lf; + WIN32_OP_D(font.GetLogFont(lf)); + MakeBoldFont( lf ); + CFont bold; + WIN32_OP_D(bold.CreateFontIndirect(&lf)); + CWindowDC dc(*this); + auto oldFont = dc.SelectFont( bold ); + CSize size (0,0); + + { + CString measure; + measure = L"#"; + measure += m_textDrawMe; + WIN32_OP_D(dc.GetTextExtent(measure, measure.GetLength(), &size)); + } + + dc.SelectFont( oldFont ); + + return size.cx; + } + std::function< void (HWND) > TabCycleHandler; + std::function< HBRUSH (CDCHandle) > CtlColorHandler; + std::function< bool (HWND) > WantTabCheck; + CWindow WndCtlColorTarget; + + // Rationale: sometimes you want a different text to be presented to accessibility APIs than actually drawn + // For an example, a clear button looks best with a multiplication sign, but the narrator should say "clear" or so when focused + void DrawAlternateText( const wchar_t * textDrawMe ) { + m_textDrawMe = textDrawMe; + } + +protected: + LRESULT MousePassThru(UINT cMsg, WPARAM cFlags, LPARAM lParam) { + SetMsgHandled(FALSE); + CPoint cPoint(lParam); + const DWORD maskButtons = MK_LBUTTON | MK_RBUTTON | MK_MBUTTON | MK_XBUTTON1 | MK_XBUTTON2; + if (cMsg == WM_MOUSEWHEEL || cMsg == WM_MOUSEHWHEEL || (cFlags & maskButtons) != 0) { + ToggleHot(false); + } + if (cMsg == WM_MOUSEWHEEL || cMsg == WM_MOUSEHWHEEL) { + TogglePressed(false); + } + if (cMsg == WM_LBUTTONUP) { + bool wasPressed = m_pressed; + TogglePressed(false); + if (wasPressed) OnClicked(); + SetMsgHandled(TRUE); + } + return 0; + } + CFontHandle m_font; + void OnSetFont(HFONT font, BOOL bRedraw) { + m_font = font; if (bRedraw) Invalidate(); + } + HFONT OnGetFont() { + return m_font; + } + LRESULT OnGetDlgCode(UINT, WPARAM wp, LPARAM) { + if ( wp == VK_TAB && TabCycleHandler != NULL) { + if ( WantTabCheck == NULL || WantTabCheck(m_hWnd) ) { + TabCycleHandler( m_hWnd ); + return DLGC_WANTTAB; + } + } + SetMsgHandled(FALSE); return 0; + } + void OnChar(UINT, UINT, UINT) { + } + void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { + (void)nRepCnt; (void)nFlags; + switch(nChar) { + case VK_SPACE: + case VK_RETURN: + TogglePressed(true); break; + } + } + void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) { + (void)nRepCnt; (void)nFlags; + switch(nChar) { + case VK_SPACE: + case VK_RETURN: + TogglePressed(false); + OnClicked(); + break; + } + } + void OnSetFocus(CWindow) { + m_focused = true; Invalidate(); + } + void OnKillFocus(CWindow) { + m_focused = false; Invalidate(); + } + CFontHandle myGetFont() const { + auto f = GetFont(); + if ( f == NULL ) f = (HFONT) GetStockObject(DEFAULT_GUI_FONT); + return f; + } + static void MakeBoldFont(LOGFONT & lf ) { + lf.lfWeight += 300; + if (lf.lfWeight > 1000 ) lf.lfWeight = 1000; + } + + CWindow GetCtlColorTarget() { + CWindow target = WndCtlColorTarget; + if (target == NULL) target = GetParent(); + return target; + } + virtual void DrawBackground( CDCHandle dc, CRect rcClient ) { + { + HBRUSH brush = NULL; + if (CtlColorHandler) { + brush = CtlColorHandler(dc); + } else { + brush = (HBRUSH)GetCtlColorTarget().SendMessage(WM_CTLCOLORBTN, (WPARAM)dc.m_hDC, (LPARAM)this->m_hWnd); + } + if (brush != NULL) { + dc.FillRect(rcClient, brush); + dc.SetBkMode(TRANSPARENT); + } + } + if ( IsPressed() ) { + CTheme theme; + if (theme.OpenThemeData(*this, L"BUTTON" )) { + DrawThemeBackground(theme, dc, BP_PUSHBUTTON, PBS_PRESSED, rcClient, rcClient ); + } else { + DrawFrameControl( dc, rcClient, DFC_BUTTON, DFCS_PUSHED ); + } + } else if (m_hot) { + CTheme theme; + if (theme.OpenThemeData(*this, L"BUTTON")) { + DrawThemeBackground(theme, dc, BP_PUSHBUTTON, PBS_HOT, rcClient, rcClient); + } else { + DrawFrameControl(dc, rcClient, DFC_BUTTON, DFCS_HOT); + } + } + } + + virtual void OnPaint(CDCHandle) { + CPaintDC pdc(*this); + + CRect rcClient; + if (! GetClientRect( &rcClient ) ) return; + + auto font = myGetFont(); + /* + CFont fontOverride; + if ( IsPressed() ) { + LOGFONT lf; + font.GetLogFont( lf ); + MakeBoldFont( lf ); + fontOverride.CreateFontIndirect( & lf ); + font = fontOverride; + } + */ + HFONT oldFont = pdc.SelectFont( font ); + + DrawBackground( pdc.m_hDC, rcClient ); + + pdc.SetBkMode( TRANSPARENT ); + if ( !IsWindowEnabled() ) { + pdc.SetTextColor( DarkMode::GetSysColor(COLOR_GRAYTEXT) ); + } else if ( m_focused ) { + pdc.SetTextColor( DarkMode::GetSysColor(COLOR_HIGHLIGHT) ); + } + pdc.DrawText( m_textDrawMe, m_textDrawMe.GetLength(), &rcClient, DT_VCENTER | DT_CENTER | DT_SINGLELINE | DT_NOPREFIX ); + + pdc.SelectFont( oldFont ); + } + virtual void OnClicked() { + if ( ClickHandler ) { + ClickHandler(); + } else { + GetParent().PostMessage( WM_COMMAND, MAKEWPARAM( this->GetDlgCtrlID(), BN_CLICKED ), (LPARAM) m_hWnd ); + } + } + bool IsPressed() {return m_pressed; } +private: + int OnCreate(LPCREATESTRUCT lpCreateStruct) { + DarkMode::ApplyDarkThemeCtrl(*this, DarkMode::IsDialogDark(GetCtlColorTarget(), WM_CTLCOLORBTN)); + if ( lpCreateStruct->lpszName != nullptr ) this->m_textDrawMe = lpCreateStruct->lpszName; + SetMsgHandled(FALSE); return 0; + } + void OnEnable(BOOL) { + Invalidate(); SetMsgHandled(FALSE); + } + void ToggleHot( bool bHot ) { + if ( bHot != m_hot ) { + m_hot = bHot; Invalidate(); + } + } + void OnMouseMove(UINT nFlags, CPoint) { + const DWORD maskButtons = MK_LBUTTON | MK_RBUTTON | MK_MBUTTON | MK_XBUTTON1 | MK_XBUTTON2; + if ((nFlags & maskButtons) != 0) return; + ToggleHot(true); + TrackMouseLeave(); + } + void OnLButtonDown(UINT nFlags, CPoint) { + const DWORD maskButtons = MK_LBUTTON | MK_RBUTTON | MK_MBUTTON | MK_XBUTTON1 | MK_XBUTTON2; + if ( ( nFlags & maskButtons ) != MK_LBUTTON ) return; + TogglePressed( true ); + TrackMouseLeave(); + } + void TogglePressed( bool bPressed ) { + if ( bPressed != m_pressed ) { + m_pressed = bPressed; Invalidate(); + } + } + int OnSetText(LPCTSTR lpstrText) { + m_textDrawMe = lpstrText; + Invalidate(); SetMsgHandled(FALSE); + return 0; + } + void TrackMouseLeave() { + TRACKMOUSEEVENT tme = { sizeof(tme) }; + tme.dwFlags = TME_LEAVE; + tme.hwndTrack = m_hWnd; + TrackMouseEvent(&tme); + } + void OnMouseLeave() { + ToggleHot(false); TogglePressed(false); + } + + bool m_pressed = false, m_focused = false, m_hot = false; + CString m_textDrawMe; +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/CDialogResizeHelper.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/CDialogResizeHelper.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,194 @@ +#include "stdafx.h" +#include "CDialogResizeHelper.h" + +#include "win32_op.h" + +static BOOL GetChildWindowRect2(HWND wnd, HWND wndChild, RECT* child) { + RECT temp; + if (wndChild == NULL) return FALSE; + if (!GetWindowRect(wndChild, &temp)) return FALSE; + if (!MapWindowPoints(NULL, wnd, (POINT*)&temp, 2)) return FALSE; + *child = temp; + return TRUE; +} + +static BOOL GetChildWindowRect(HWND wnd, UINT id, RECT* child) { + return GetChildWindowRect2(wnd, GetDlgItem(wnd, id), child); +} + + +bool CDialogResizeHelper::EvalRect(UINT id, CRect & out) const { + for( auto iter = m_runtime.begin(); iter != m_runtime.end(); ++ iter ) { + if ( iter->initData.id == id ) { + out = _EvalRect(*iter, this->CurrentSize() ); + return true; + } + } + return false; +} + +CRect CDialogResizeHelper::_EvalRect(runtime_t const & rt, CSize wndSize) const { + CRect rc = rt.origRect; + int delta_x = wndSize.cx - rt.origWindowSize.cx, + delta_y = wndSize.cy - rt.origWindowSize.cy; + + const Param & e = rt.initData; + rc.left += pfc::rint32(e.snapLeft * delta_x); + rc.right += pfc::rint32(e.snapRight * delta_x); + rc.top += pfc::rint32(e.snapTop * delta_y); + rc.bottom += pfc::rint32(e.snapBottom * delta_y); + + return rc; +} + +CWindow CDialogResizeHelper::ResolveWnd(runtime_t const & rt) const { + if ( rt.userHWND != NULL ) return rt.userHWND; + return m_thisWnd.GetDlgItem( rt.initData.id ); +} + +CSize CDialogResizeHelper::CurrentSize() const { + CRect rc; + WIN32_OP_D( m_thisWnd.GetClientRect(rc) ); + return rc.Size(); +} + +void CDialogResizeHelper::OnSize(UINT, CSize newSize) +{ + if (m_thisWnd != NULL) { + HDWP hWinPosInfo = BeginDeferWindowPos((int)(m_runtime.size() + (m_sizeGrip != NULL ? 1 : 0))); + for (auto iter = m_runtime.begin(); iter != m_runtime.end(); ++ iter) { + CRect rc = _EvalRect(*iter, newSize); + hWinPosInfo = DeferWindowPos(hWinPosInfo, ResolveWnd(*iter), 0, rc.left, rc.top, rc.Width(), rc.Height(), SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE | SWP_NOCOPYBITS); + } + if (m_sizeGrip != NULL) + { + RECT rc, rc_grip; + if (m_thisWnd.GetClientRect(&rc) && m_sizeGrip.GetWindowRect(&rc_grip)) { + DWORD flags = SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOCOPYBITS; + if (IsZoomed(m_thisWnd)) flags |= SWP_HIDEWINDOW; + else flags |= SWP_SHOWWINDOW; + hWinPosInfo = DeferWindowPos(hWinPosInfo, m_sizeGrip, NULL, rc.right - (rc_grip.right - rc_grip.left), rc.bottom - (rc_grip.bottom - rc_grip.top), 0, 0, flags); + } + } + EndDeferWindowPos(hWinPosInfo); + //RedrawWindow(m_thisWnd, NULL, NULL, RDW_UPDATENOW | RDW_ALLCHILDREN); + } + SetMsgHandled(FALSE); +} + +void CDialogResizeHelper::OnGetMinMaxInfo(LPMINMAXINFO info) const { + CRect r; + const DWORD dwStyle = m_thisWnd.GetWindowLong(GWL_STYLE); + const DWORD dwExStyle = m_thisWnd.GetWindowLong(GWL_EXSTYLE); + if (max_x && max_y) + { + r.left = 0; r.right = max_x; + r.top = 0; r.bottom = max_y; + MapDialogRect(m_thisWnd, &r); + AdjustWindowRectEx(&r, dwStyle, FALSE, dwExStyle); + info->ptMaxTrackSize.x = r.right - r.left; + info->ptMaxTrackSize.y = r.bottom - r.top; + } + if (min_x && min_y) + { + r.left = 0; r.right = min_x; + r.top = 0; r.bottom = min_y; + MapDialogRect(m_thisWnd, &r); + AdjustWindowRectEx(&r, dwStyle, FALSE, dwExStyle); + info->ptMinTrackSize.x = r.right - r.left; + info->ptMinTrackSize.y = r.bottom - r.top; + } +} + +void CDialogResizeHelper::OnInitDialog(CWindow thisWnd) { + + m_thisWnd = thisWnd; + const auto origSize = CurrentSize(); + for( auto initIter = m_initData.begin(); initIter != m_initData.end(); ++ initIter ) { + CRect rc; + if (GetChildWindowRect(m_thisWnd, initIter->id, &rc)) { + runtime_t rt; + rt.origRect = rc; + rt.initData = * initIter; + rt.origWindowSize = origSize; + m_runtime.push_back( std::move(rt) ); + } + } + AddSizeGrip(); + SetMsgHandled(FALSE); +} +void CDialogResizeHelper::OnDestroy() { + m_runtime.clear(); + m_sizeGrip = NULL; m_thisWnd = NULL; + SetMsgHandled(FALSE); +} + +void CDialogResizeHelper::AddSizeGrip() +{ + if ( m_autoSizeGrip && m_thisWnd != NULL && m_sizeGrip == NULL) + { + if (m_thisWnd.GetWindowLong(GWL_STYLE) & WS_POPUP) { + m_sizeGrip = CreateWindowEx(0, WC_SCROLLBAR, _T(""), WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | SBS_SIZEGRIP | SBS_SIZEBOXBOTTOMRIGHTALIGN, + 0, 0, CW_USEDEFAULT, CW_USEDEFAULT, + m_thisWnd, (HMENU)0, NULL, NULL); + if (m_sizeGrip != NULL) + { + RECT rc, rc_grip; + if (m_thisWnd.GetClientRect(&rc) && m_sizeGrip.GetWindowRect(&rc_grip)) { + m_sizeGrip.SetWindowPos(NULL, rc.right - (rc_grip.right - rc_grip.left), rc.bottom - (rc_grip.bottom - rc_grip.top), 0, 0, SWP_NOZORDER | SWP_NOSIZE); + } + } + } + } +} + + +void CDialogResizeHelper::InitTable(const Param* table, size_t tableSize) { + m_initData.assign( table, table+tableSize ); +} +void CDialogResizeHelper::InitTable(const ParamOld * table, size_t tableSize) { + m_initData.resize(tableSize); + for (size_t walk = 0; walk < tableSize; ++walk) { + const ParamOld in = table[walk]; + Param entry = {}; + entry.id = table[walk].id; + if (in.flags & CDialogResizeHelperCompat::X_MOVE) entry.snapLeft = entry.snapRight = 1; + else if (in.flags & CDialogResizeHelperCompat::X_SIZE) entry.snapRight = 1; + if (in.flags & CDialogResizeHelperCompat::Y_MOVE) entry.snapTop = entry.snapBottom = 1; + else if (in.flags & CDialogResizeHelperCompat::Y_SIZE) entry.snapBottom = 1; + m_initData[walk] = entry; + } +} +void CDialogResizeHelper::InitMinMax(const CRect & range) { + min_x = range.left; min_y = range.top; max_x = range.right; max_y = range.bottom; +} + +void CDialogResizeHelper::AddControl(Param const & initData, CWindow wnd) { + CRect rc; + if ( wnd == NULL ) { + PFC_ASSERT( initData.id != 0 ); + WIN32_OP_D(GetChildWindowRect(m_thisWnd, initData.id, rc)); + } else { + WIN32_OP_D(GetChildWindowRect2(m_thisWnd, wnd, rc)); + } + + runtime_t rt; + rt.initData = initData; + rt.userHWND = wnd; + rt.origRect = rc; + rt.origWindowSize = this->CurrentSize(); + m_runtime.push_back( std::move(rt) ); +} + +bool CDialogResizeHelper::RemoveControl(CWindow wnd) { + return pfc::remove_if_t( m_runtime, [wnd] (runtime_t const & rt) { + return rt.userHWND == wnd; + } ) > 0; +} + +bool CDialogResizeHelper::HaveControl(CWindow wnd) const { + for( auto i = m_runtime.begin(); i != m_runtime.end(); ++ i ) { + if ( i->userHWND == wnd ) return true; + } + return false; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/CDialogResizeHelper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/CDialogResizeHelper.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,79 @@ +#pragma once + +#include "CDialogResizeHelperCompat.h" +#include + +// ========================================================== +// CDialogResizeHelper +// ========================================================== +// Usage: +// Put CDialogResizeHelper member in your dialog class +// Initialize with controls sizing info table, array of CDialogResizeHelper::Param +// Put CHAIN_MSG_MAP_MEMBER(m_resizer) before your dialog message handlers +// CDialogResizeHelper will do its own message handling without marking messages as handled, that is, your handlers of the same messages will be allowed to run. +// CRect minMaxRange specifies allowed size min (left&top) and max (right&bottom) values, in DLU not pixels. +// ========================================================== + +class CDialogResizeHelper : public CMessageMap { +public: + + typedef CDialogResizeHelperCompat::param ParamOld; + + struct Param { + uint32_t id; + float snapLeft, snapTop, snapRight, snapBottom; + }; +private: + void AddSizeGrip(); +public: + inline void set_min_size(unsigned x, unsigned y) { min_x = x; min_y = y; } + inline void set_max_size(unsigned x, unsigned y) { max_x = x; max_y = y; } + + bool m_autoSizeGrip = true; + + BEGIN_MSG_MAP_EX(CDialogResizeHelper) + if (uMsg == WM_INITDIALOG) OnInitDialog(hWnd); + MSG_WM_SIZE(OnSize) + MSG_WM_DESTROY(OnDestroy) + MSG_WM_GETMINMAXINFO(OnGetMinMaxInfo) + END_MSG_MAP() + + template CDialogResizeHelper(const TParam(&src)[paramCount], CRect const& minMaxRange = CRect(0, 0, 0, 0)) { + InitTable(src, paramCount); + InitMinMax(minMaxRange); + } + + void InitTable(const Param* table, size_t tableSize); + void InitTable(const ParamOld * table, size_t tableSize); + void InitMinMax(const CRect & range); + + bool EvalRect(UINT id, CRect & out) const; + + //! initData.id may be null, if so specify a non null window handle. + void AddControl( Param const & initData, CWindow wnd = NULL ); + bool RemoveControl( CWindow wnd ); + bool HaveControl(CWindow wnd) const; +private: + struct runtime_t { + HWND userHWND = 0; + CRect origRect; + CSize origWindowSize; + Param initData = {}; + }; + + CSize CurrentSize() const; + CWindow ResolveWnd( runtime_t const & rt ) const; + + CRect _EvalRect(runtime_t const & rt, CSize wndSize) const; + void OnGetMinMaxInfo(LPMINMAXINFO lpMMI) const; + void OnSize(UINT nType, CSize size); + void OnInitDialog(CWindow thisWnd); + void OnDestroy(); + + + std::vector m_runtime; + std::vector m_initData; + + CWindow m_thisWnd, m_sizeGrip; + unsigned min_x, min_y, max_x, max_y; +}; \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/CDialogResizeHelperCompat.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/CDialogResizeHelperCompat.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,16 @@ +#pragma once + +class CDialogResizeHelperCompat { +public: + struct param { + unsigned short id; + unsigned short flags; + }; + + enum { + X_MOVE = 1, X_SIZE = 2, Y_MOVE = 4, Y_SIZE = 8, + XY_MOVE = X_MOVE | Y_MOVE, XY_SIZE = X_SIZE | Y_SIZE, + X_MOVE_Y_SIZE = X_MOVE | Y_SIZE, X_SIZE_Y_MOVE = X_SIZE | Y_MOVE, + }; + +}; \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/CEditWithButtons.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/CEditWithButtons.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,196 @@ +#include "stdafx.h" +#include "CEditWithButtons.h" + + +void CEditWithButtons::AddMoreButton(std::function f) { + AddButton(L"more", f, nullptr, L"\x2026"); +} +void CEditWithButtons::AddClearButton(const wchar_t * clearVal, bool bHandleEsc) { + std::wstring clearValCopy(clearVal); + auto handler = [this, clearValCopy] { + this->SetWindowText(clearValCopy.c_str()); + }; + auto condition = [clearValCopy](const wchar_t * txt) -> bool { + return clearValCopy != txt; + }; + // Present "clear" to accessibility APIs but actually draw a multiplication x sign + AddButton(L"clear", handler, condition, L"\x00D7"); + + if (bHandleEsc) { + this->onEscKey = handler; + } + +} + +void CEditWithButtons::AddButton(const wchar_t * str, handler_t handler, condition_t condition, const wchar_t * drawAlternateText) { + PFC_ASSERT(GetStyle() & WS_CLIPCHILDREN); + Button_t btn; + btn.handler = handler; + btn.title = str; + btn.condition = condition; + btn.visible = EvalCondition(btn, nullptr); + + if (drawAlternateText != nullptr) { + btn.titleDraw = drawAlternateText; + } + + m_buttons.push_back(std::move(btn)); + RefreshButtons(); +} + +CRect CEditWithButtons::RectOfButton(const wchar_t * text) { + for (auto i = m_buttons.begin(); i != m_buttons.end(); ++i) { + if (i->title == text && i->wnd != NULL) { + CRect rc; + if (i->wnd.GetWindowRect(rc)) return rc; + } + } + return CRect(); +} + +void CEditWithButtons::TabCycleButtons(HWND wnd) { + for (auto i = m_buttons.begin(); i != m_buttons.end(); ++i) { + if (i->wnd == wnd) { + if (IsShiftPressed()) { + // back + for (;; ) { + if (i == m_buttons.begin()) { + TabFocusThis(m_hWnd); break; + } else { + --i; + if (i->visible) { + TabFocusThis(i->wnd); + break; + } + } + } + } else { + // forward + for (;; ) { + ++i; + if (i == m_buttons.end()) { + TabFocusThis(m_hWnd); + TabFocusPrevNext(false); + break; + } else { + if (i->visible) { + TabFocusThis(i->wnd); + break; + } + } + } + } + + return; + } + } +} + + +bool CEditWithButtons::ButtonWantTab(HWND wnd) { + if (IsShiftPressed()) return true; + if (m_buttons.size() == 0) return false; // should not be possible + auto last = m_buttons.rbegin(); + if (wnd == last->wnd) return false; // not for last button + return true; +} +bool CEditWithButtons::EvalCondition(Button_t & btn, const wchar_t * newText) { + if (!btn.condition) return true; + if (newText != nullptr) return btn.condition(newText); + TCHAR text[256] = {}; + GetWindowText(text, 256); + text[255] = 0; + return btn.condition(text); +} +void CEditWithButtons::RefreshConditions(const wchar_t * newText) { + bool changed = false; + for (auto i = m_buttons.begin(); i != m_buttons.end(); ++i) { + bool status = EvalCondition(*i, newText); + if (status != i->visible) { + i->visible = status; changed = true; + } + } + if (changed) { + Layout(); + } +} + +void CEditWithButtons::Layout(CSize size, CFontHandle fontSetMe) { + if (m_buttons.size() == 0) return; + + int walk = size.cx; + + HDWP dwp = BeginDeferWindowPos((int)m_buttons.size()); + for (auto iter = m_buttons.rbegin(); iter != m_buttons.rend(); ++iter) { + if (!iter->visible) { + if (::GetFocus() == iter->wnd) { + this->SetFocus(); + } + ::DeferWindowPos(dwp, iter->wnd, NULL, 0, 0, 0, 0, SWP_NOZORDER | SWP_HIDEWINDOW | SWP_NOMOVE | SWP_NOSIZE | SWP_NOCOPYBITS); + continue; + } + + if (iter->wnd == NULL) { + auto* b = &iter->wnd; + b->Create(*this, NULL, iter->title.c_str()); + if (iter->titleDraw.length() > 0) b->DrawAlternateText(iter->titleDraw.c_str()); + CFontHandle font = fontSetMe; + if (font == NULL) font = GetFont(); + b->SetFont(font); + b->ClickHandler = iter->handler; + b->CtlColorHandler = [=](CDCHandle dc) -> HBRUSH { + return this->OnColorBtn(dc, NULL); + }; + b->TabCycleHandler = [=](HWND wnd) { + TabCycleButtons(wnd); + }; + b->WantTabCheck = [=](HWND wnd) -> bool { + return ButtonWantTab(wnd); + }; + if (!IsWindowEnabled()) b->EnableWindow(FALSE); + } else if (fontSetMe) { + iter->wnd.SetFont(fontSetMe); + } + + unsigned delta = MeasureButton(*iter); + int left = walk - delta; + + if (iter->wnd != NULL) { + CRect rc; + rc.top = 0; + rc.bottom = size.cy; + rc.left = left; + rc.right = walk; + ::DeferWindowPos(dwp, iter->wnd, NULL, rc.left, rc.top, rc.Width(), rc.Height(), SWP_NOZORDER | SWP_SHOWWINDOW | SWP_NOCOPYBITS); + } + + walk = left; + } + EndDeferWindowPos(dwp); + this->SetMargins(0, size.cx - walk, EC_RIGHTMARGIN); +} + +unsigned CEditWithButtons::MeasureButton(Button_t const & button) { + if (m_fixedWidthAuto && m_fixedWidth == 0) { + CWindowDC dc(*this); + SelectObjectScope fontScope(dc, GetFont()); + SIZE sz = {}; + WIN32_OP_D( dc.GetTextExtent(L"#", 1, &sz) ); + m_fixedWidth = MulDiv(sz.cx, 3, 2); + } + if (m_fixedWidth != 0) return m_fixedWidth; + + return button.wnd.Measure(); +} + +void CEditWithButtons::OnSetFont(CFontHandle font, BOOL bRedraw) { + (void)bRedraw; + + if ( m_fixedWidthAuto ) m_fixedWidth = 0; // require re-calculation + + DefWindowProc(); + CRect rc; + if (GetClientRect(&rc)) { + Layout(rc.Size(), font); + } +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/CEditWithButtons.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/CEditWithButtons.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,223 @@ +#pragma once + +#include +#include +#include +#include +#include "wtl-pp.h" + +#include "CButtonLite.h" + +class CEditWithButtons : public CEditPPHooks { +public: + CEditWithButtons(::ATL::CMessageMap * hookMM = nullptr, int hookMMID = 0) : CEditPPHooks(hookMM, hookMMID) {} + + static constexpr UINT MSG_CHECKCONDITIONS = WM_USER + 13; + static constexpr WPARAM MSG_CHECKCONDITIONS_MAGIC1 = 0xaec66f0c; + static constexpr LPARAM MSG_CHECKCONDITIONS_MAGIC2 = 0x180c2f35; + + BEGIN_MSG_MAP_EX(CEditWithButtons) + MSG_WM_CREATE(OnCreate) + MSG_WM_SETFONT(OnSetFont) + MSG_WM_WINDOWPOSCHANGED(OnPosChanged) + MSG_WM_CTLCOLORBTN(OnColorBtn) + MESSAGE_HANDLER_EX(WM_GETDLGCODE, OnGetDlgCode) + MSG_WM_KEYDOWN(OnKeyDown) + MSG_WM_CHAR(OnChar) + // MSG_WM_SETFOCUS( OnSetFocus ) + // MSG_WM_KILLFOCUS( OnKillFocus ) + MSG_WM_ENABLE(OnEnable) + MSG_WM_SETTEXT( OnSetText ) + MESSAGE_HANDLER_EX(WM_PAINT, CheckConditionsTrigger) + MESSAGE_HANDLER_EX(WM_CUT, CheckConditionsTrigger) + MESSAGE_HANDLER_EX(WM_PASTE, CheckConditionsTrigger) + MESSAGE_HANDLER_EX(MSG_CHECKCONDITIONS, OnCheckConditions) + CHAIN_MSG_MAP(CEditPPHooks) + END_MSG_MAP() + + BOOL SubclassWindow( HWND wnd ) { + if (!CEditPPHooks::SubclassWindow(wnd)) return FALSE; + m_initialParent = GetParent(); + this->ModifyStyle(0, WS_CLIPCHILDREN); + RefreshButtons(); + return TRUE; + } + typedef std::function handler_t; + typedef std::function condition_t; + + void AddMoreButton( std::function f ); + void AddClearButton( const wchar_t * clearVal = L"", bool bHandleEsc = false); + void AddButton( const wchar_t * str, handler_t handler, condition_t condition = nullptr, const wchar_t * drawAlternateText = nullptr ); + + void SetFixedWidth(unsigned fw) { + m_fixedWidth = fw; m_fixedWidthAuto = false; + RefreshButtons(); + } + void SetFixedWidth() { + m_fixedWidth = 0; m_fixedWidthAuto = true; + RefreshButtons(); + } + CRect RectOfButton( const wchar_t * text ); + + void Invalidate() { + __super::Invalidate(); + for( auto & i : m_buttons ) { + if (i.wnd != NULL) i.wnd.Invalidate(); + } + } + void SetShellFolderAutoComplete() { + SetShellAutoComplete(SHACF_FILESYS_DIRS); + } + void SetShellFileAutoComplete() { + SetShellAutoComplete(SHACF_FILESYS_ONLY); + } + void SetShellAutoComplete(DWORD flags) { + SHAutoComplete(*this, flags); + SetHasAutoComplete(); + } + void SetHasAutoComplete(bool bValue = true) { + m_hasAutoComplete = bValue; + } + void RefreshConditions(const wchar_t * newText = nullptr); +private: + int OnCreate(LPCREATESTRUCT lpCreateStruct) { + m_initialParent = GetParent(); + SetMsgHandled(FALSE); + return 0; + } + LRESULT OnCheckConditions( UINT msg, WPARAM wp, LPARAM lp ) { + if ( msg == MSG_CHECKCONDITIONS && wp == MSG_CHECKCONDITIONS_MAGIC1 && lp == MSG_CHECKCONDITIONS_MAGIC2 ) { + this->RefreshConditions(); + } else { + SetMsgHandled(FALSE); + } + return 0; + } + bool HaveConditions() { + for( auto i = m_buttons.begin(); i != m_buttons.end(); ++i ) { + if ( i->condition ) return true; + } + return false; + } + void PostCheckConditions() { + if ( HaveConditions() ) { + PostMessage( MSG_CHECKCONDITIONS, MSG_CHECKCONDITIONS_MAGIC1, MSG_CHECKCONDITIONS_MAGIC2 ); + } + } + LRESULT CheckConditionsTrigger( UINT, WPARAM, LPARAM ) { + PostCheckConditions(); + SetMsgHandled(FALSE); + return 0; + } + int OnSetText(LPCTSTR) { + PostCheckConditions(); + SetMsgHandled(FALSE); + return 0; + } + void OnEnable(BOOL bEnable) { + for( auto & i : m_buttons ) { + if ( i.wnd != NULL ) { + i.wnd.EnableWindow( bEnable ); + } + } + SetMsgHandled(FALSE); + } + void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) { + (void)nRepCnt; (void)nFlags; + if (nChar == VK_TAB ) { + return; + } + PostCheckConditions(); + SetMsgHandled(FALSE); + } + void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { + (void)nRepCnt; (void)nFlags; + if ( nChar == VK_TAB ) { + return; + } + SetMsgHandled(FALSE); + } + bool canStealTab() { + if (m_hasAutoComplete) return false; + if (IsShiftPressed()) return false; + if (m_buttons.size() == 0) return false; + return true; + } + UINT OnGetDlgCode(UINT, WPARAM wp, LPARAM) { + if ( wp == VK_TAB && canStealTab() ) { + for (auto i = m_buttons.begin(); i != m_buttons.end(); ++ i ) { + if ( i->visible ) { + TabFocusThis(i->wnd); + return DLGC_WANTTAB; + } + } + } + SetMsgHandled(FALSE); return 0; + } + void OnSetFocus(HWND) { + this->ModifyStyleEx(0, WS_EX_CONTROLPARENT ); SetMsgHandled(FALSE); + } + void OnKillFocus(HWND) { + this->ModifyStyleEx(WS_EX_CONTROLPARENT, 0 ); SetMsgHandled(FALSE); + } + HBRUSH OnColorBtn(CDCHandle dc, CButton) { + if ( (this->GetStyle() & ES_READONLY) != 0 || !this->IsWindowEnabled() ) { + return (HBRUSH) GetParent().SendMessage( WM_CTLCOLORSTATIC, (WPARAM) dc.m_hDC, (LPARAM) m_hWnd ); + } else { + return (HBRUSH) GetParent().SendMessage( WM_CTLCOLOREDIT, (WPARAM) dc.m_hDC, (LPARAM) m_hWnd ); + } + } + void OnPosChanged(LPWINDOWPOS) { + Layout(); SetMsgHandled(FALSE); + } + + struct Button_t { + std::wstring title, titleDraw; + handler_t handler; + CButtonLite wnd; + bool visible; + condition_t condition; + }; + + void OnSetFont(CFontHandle font, BOOL bRedraw); + + void RefreshButtons() { + if ( m_hWnd != NULL && m_buttons.size() > 0 ) { + Layout(); + } + } + void Layout( ) { + CRect rc; + if (GetClientRect(&rc)) { + Layout(rc.Size(), NULL); + } + } + static bool IsShiftPressed() { + return (GetKeyState(VK_SHIFT) & 0x8000) ? true : false; + } + CWindow FindDialog() { + // Return a window that we can send WM_NEXTDLGCTL to + // PROBLEM: There is no clear way of obtaining one - something in our GetParent() hierarchy is usually a dialog, but we don't know which one + // Assume our initial parent window to be the right thing to talk to + PFC_ASSERT(m_initialParent != NULL); + return m_initialParent; + } + void TabFocusThis(HWND wnd) { + FindDialog().PostMessage(WM_NEXTDLGCTL, (WPARAM) wnd, TRUE ); + } + void TabFocusPrevNext(bool bPrev) { + FindDialog().PostMessage(WM_NEXTDLGCTL, bPrev ? TRUE : FALSE, FALSE); + } + void TabCycleButtons(HWND wnd); + + bool ButtonWantTab( HWND wnd ); + bool EvalCondition( Button_t & btn, const wchar_t * newText ); + void Layout(CSize size, CFontHandle fontSetMe); + unsigned MeasureButton(Button_t const & button ); + + unsigned m_fixedWidth = 0; + bool m_fixedWidthAuto = false; + std::list< Button_t > m_buttons; + bool m_hasAutoComplete = false; + CWindow m_initialParent; +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/CEnumString.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/CEnumString.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,118 @@ +#pragma once +#include +#include "pp-COM-macros.h" + +namespace PP { + + class CEnumString : public IEnumString { + public: + typedef pfc::chain_list_v2_t > t_data; + + + struct shared_t { + t_data m_data; + pfc::mutex m_sync; + }; + typedef std::shared_ptr shared_ptr_t; + + CEnumString(t_data && in) { + m_shared = std::make_shared(); + m_shared->m_data = std::move(in); + myReset(); + } + CEnumString(const t_data & in) { + m_shared = std::make_shared(); + m_shared->m_data = in; + myReset(); + } + CEnumString() { + m_shared = std::make_shared< shared_t >(); + } + + void SetStrings(t_data && data) { + PFC_INSYNC(m_shared->m_sync); + m_shared->m_data = std::move(data); + myReset(); + } + + static pfc::array_t stringToBuffer(const char * in) { + pfc::array_t arr; + arr.set_size(pfc::stringcvt::estimate_utf8_to_wide(in)); + pfc::stringcvt::convert_utf8_to_wide_unchecked(arr.get_ptr(), in); + return arr; + } + + void AddString(const TCHAR * in) { + PFC_INSYNC(m_shared->m_sync); + m_shared->m_data.insert_last()->set_data_fromptr(in, _tcslen(in) + 1); + myReset(); + } + void AddStringU(const char * in, t_size len) { + PFC_INSYNC(m_shared->m_sync); + pfc::array_t & arr = *m_shared->m_data.insert_last(); + arr.set_size(pfc::stringcvt::estimate_utf8_to_wide(in, len)); + pfc::stringcvt::convert_utf8_to_wide(arr.get_ptr(), arr.get_size(), in, len); + myReset(); + } + void AddStringU(const char * in) { + PFC_INSYNC(m_shared->m_sync); + *m_shared->m_data.insert_last() = stringToBuffer(in); + myReset(); + } + void ResetStrings() { + PFC_INSYNC(m_shared->m_sync); + m_shared->m_data.remove_all(); + myReset(); + } + + typedef ImplementCOMRefCounter TImpl; + COM_QI_BEGIN() + COM_QI_ENTRY(IUnknown) + COM_QI_ENTRY(IEnumString) + COM_QI_END() + + HRESULT STDMETHODCALLTYPE Next(ULONG celt, LPOLESTR *rgelt, ULONG *pceltFetched) override { + PFC_INSYNC(m_shared->m_sync); + if (rgelt == NULL) return E_INVALIDARG; + ULONG done = 0; + while (done < celt && m_walk.is_valid()) { + rgelt[done] = CoStrDup(m_walk->get_ptr()); + ++m_walk; ++done; + } + if (pceltFetched != NULL) *pceltFetched = done; + return done == celt ? S_OK : S_FALSE; + } + + HRESULT STDMETHODCALLTYPE Skip(ULONG celt) override { + PFC_INSYNC(m_shared->m_sync); + while (celt > 0) { + if (m_walk.is_empty()) return S_FALSE; + --celt; ++m_walk; + } + return S_OK; + } + + HRESULT STDMETHODCALLTYPE Reset() override { + PFC_INSYNC(m_shared->m_sync); + myReset(); + return S_OK; + } + + HRESULT STDMETHODCALLTYPE Clone(IEnumString **ppenum) override { + PFC_INSYNC(m_shared->m_sync); + *ppenum = new TImpl(*this); return S_OK; + } + private: + void myReset() { m_walk = m_shared->m_data.first(); } + + static TCHAR * CoStrDup(const TCHAR * in) { + const size_t lenBytes = (_tcslen(in) + 1) * sizeof(TCHAR); + TCHAR * out = reinterpret_cast(CoTaskMemAlloc(lenBytes)); + if (out) memcpy(out, in, lenBytes); + return out; + } + + shared_ptr_t m_shared; + t_data::const_iterator m_walk; + }; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/CFlashWindow.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/CFlashWindow.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,69 @@ +#pragma once + +#include "win32_op.h" + +typedef CWinTraits CFlashWindowTraits; + +class CFlashWindow : public CWindowImpl { +public: + void Activate(CWindow parent) { + ShowAbove(parent); + m_tickCount = 0; + SetTimer(KTimerID, 500); + } + void Deactivate() throw() { + ShowWindow(SW_HIDE); KillTimer(KTimerID); + } + + void ShowAbove(CWindow parent) { + if (m_hWnd == NULL) { + WIN32_OP( Create(NULL) != NULL ); + } + CRect rect; + WIN32_OP_D( parent.GetWindowRect(rect) ); + WIN32_OP_D( SetWindowPos(NULL,rect,SWP_NOZORDER | SWP_NOACTIVATE | SWP_SHOWWINDOW) ); + m_parent = parent; + } + + void CleanUp() throw() { + if (m_hWnd != NULL) DestroyWindow(); + } + + BEGIN_MSG_MAP_EX(CFlashWindow) + MSG_WM_CREATE(OnCreate) + MSG_WM_TIMER(OnTimer) + MSG_WM_DESTROY(OnDestroy) + END_MSG_MAP() + + DECLARE_WND_CLASS_EX(TEXT("{2E124D52-131F-4004-A569-2316615BE63F}"),0,COLOR_HIGHLIGHT); +private: + void OnDestroy() throw() { + KillTimer(KTimerID); + } + enum { + KTimerID = 0x47f42dd0 + }; + void OnTimer(WPARAM id) { + if (id == KTimerID) { + switch(++m_tickCount) { + case 1: + ShowWindow(SW_HIDE); + break; + case 2: + ShowAbove(m_parent); + break; + case 3: + ShowWindow(SW_HIDE); + KillTimer(KTimerID); + break; + } + } + } + LRESULT OnCreate(LPCREATESTRUCT) throw() { + SetLayeredWindowAttributes(*this,0,128,LWA_ALPHA); + return 0; + } + CWindow m_parent; + uint32_t m_tickCount; +}; + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/CHeaderCtrlEx.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/CHeaderCtrlEx.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,15 @@ +#pragma once + +class CHeaderCtrlEx : public CHeaderCtrl { +public: + CHeaderCtrlEx(HWND wnd = NULL) : CHeaderCtrl(wnd) {} + CHeaderCtrlEx const & operator=(HWND wnd) { m_hWnd = wnd; return *this; } + + // Column sort marker operations + // If they appear to have no effect, you're probably missing Common Controls 6 manifest, see link-CommonControls6.h + DWORD GetItemFormat(int iItem); + void SetItemFormat(int iItem, DWORD flags); + void SetItemSort(int iItem, int direction); + void SetSingleItemSort(int iItem, int direction); + void ClearSort(); +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/CIconOverlayWindow.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/CIconOverlayWindow.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,47 @@ +#pragma once + +#include "win32_op.h" + +typedef CWinTraits _COverlayWindowTraits; + +class CIconOverlayWindow : public CWindowImpl { +public: + DECLARE_WND_CLASS_EX(TEXT("{384298D0-4370-4f9b-9C36-49FC1A396DC7}"),0,(-1)); + + void AttachIcon(HICON p_icon) {m_icon = p_icon;} + bool HaveIcon() const {return m_icon != NULL;} + + enum { + ColorKey = 0xc0ffee + }; + + BEGIN_MSG_MAP_EX(CIconOverlayWindow) + MESSAGE_HANDLER(WM_CREATE,OnCreate); + MESSAGE_HANDLER(WM_PAINT,OnPaint); + MESSAGE_HANDLER(WM_ERASEBKGND,OnEraseBkgnd); + END_MSG_MAP() +private: + LRESULT OnCreate(UINT,WPARAM,LPARAM,BOOL&) { + ::SetLayeredWindowAttributes(*this,ColorKey,0,LWA_COLORKEY); + return 0; + } + LRESULT OnEraseBkgnd(UINT,WPARAM p_wp,LPARAM,BOOL&) { + CRect rcClient; + WIN32_OP_D( GetClientRect(rcClient) ); + CDCHandle((HDC)p_wp).FillSolidRect(rcClient,ColorKey); + return 1; + } + LRESULT OnPaint(UINT,WPARAM,LPARAM,BOOL& bHandled) { + if (m_icon != NULL) { + CPaintDC dc(*this); + CRect client; + WIN32_OP_D( GetClientRect(&client) ); + dc.DrawIconEx(0,0,m_icon,client.right,client.bottom); + //CDCHandle(ps.hdc).DrawIcon(0,0,m_icon); + } else { + bHandled = FALSE; + } + return 0; + } + CIcon m_icon; +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/CListAccessible.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/CListAccessible.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,751 @@ +#include "stdafx.h" +#include "CListAccessible.h" + +#include "pp-COM-macros.h" + +static size_t IndexFromChildId(LONG id) {return (size_t)(id-1);} +static LONG ChildIdFromIndex(size_t index) {return (LONG)(index+1);} + +class IEnumVARIANT_selection : public ImplementCOMRefCounter { +public: + IEnumVARIANT_selection(const LONG * data,size_t dataCount, ULONG pos = 0) : m_pos(pos) { + m_data.set_data_fromptr(data,dataCount); + } + + COM_QI_BEGIN() + COM_QI_ENTRY(IEnumVARIANT) + COM_QI_ENTRY(IUnknown) + COM_QI_END() + + // IEnumVARIANT methods + STDMETHOD(Next)(ULONG celt, VARIANT *rgVar, ULONG *pCeltFetched); + STDMETHOD(Skip)(ULONG celt); + STDMETHOD(Reset)(); + STDMETHOD(Clone)(IEnumVARIANT **ppEnum); +private: + pfc::array_t m_data; + ULONG m_pos; +}; + + +HRESULT IEnumVARIANT_selection::Next(ULONG celt, VARIANT *rgVar, ULONG *pceltFetched) { + if (rgVar == NULL) return E_INVALIDARG; + + if (pceltFetched) *pceltFetched = 0; + + ULONG n; + for (n = 0; n < celt; n++) VariantInit(&rgVar[n]); + + for (n = 0; n < celt && m_pos+n < m_data.get_size(); n++) { + rgVar[n].vt = VT_I4; + rgVar[n].lVal = m_data[m_pos+n]; + } + + if (pceltFetched) *pceltFetched = n; + + m_pos += n; + + return n == celt ? S_OK : S_FALSE; +} + +HRESULT IEnumVARIANT_selection::Skip(ULONG celt) { + m_pos += celt; + if (m_pos > m_data.get_size()) { + m_pos = (ULONG)m_data.get_size(); + return S_FALSE; + } + return S_OK; +} + +HRESULT IEnumVARIANT_selection::Reset() { + m_pos = 0; + return S_OK; +} + +HRESULT IEnumVARIANT_selection::Clone(IEnumVARIANT **ppEnum) +{ + if (ppEnum == NULL) + return E_INVALIDARG; + + IEnumVARIANT * var; + try { + var = new IEnumVARIANT_selection(m_data.get_ptr(), m_data.get_size(), m_pos); + } catch(std::bad_alloc const &) {return E_OUTOFMEMORY;} + + var->AddRef(); + *ppEnum = var; + + return S_OK; +} + +namespace { + class WeakRef { + public: + WeakRef( CListAccessible * ptr_, std::shared_ptr ks_ ) : ptr(ptr_), ks(ks_) {} + + CListAccessible * operator->() const { return ptr; } + + bool IsEmpty() const { + return * ks; + } + private: + CListAccessible * ptr; + std::shared_ptr ks; + }; +} + +class IAccessible_CListControl : public ImplementCOMRefCounter { +public: + IAccessible_CListControl(WeakRef owner) : m_owner(owner) {} + COM_QI_BEGIN() + COM_QI_ENTRY(IUnknown) + COM_QI_ENTRY(IDispatch) + COM_QI_ENTRY(IAccessible) + COM_QI_END() + + //IDispatch + STDMETHOD(GetTypeInfoCount)(UINT * pcTInfo); + STDMETHOD(GetTypeInfo)(UINT iTInfo, LCID lcid, ITypeInfo ** ppTInfo); + STDMETHOD(GetIDsOfNames)(REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId); + STDMETHOD(Invoke)(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS * pDispParams, VARIANT * pVarResult, EXCEPINFO * pExcepInfo, UINT * puArgErr); + //IAccessible + STDMETHOD(get_accParent)(IDispatch **ppdispParent); // required + STDMETHOD(get_accChildCount)(long *pcountChildren); + STDMETHOD(get_accChild)(VARIANT varChild, IDispatch **ppdispChild); + STDMETHOD(get_accName)(VARIANT varChild, BSTR *pszName); // required + STDMETHOD(get_accValue)(VARIANT varChild, BSTR *pszValue); + STDMETHOD(get_accDescription)(VARIANT varChild, BSTR *pszDescription); + STDMETHOD(get_accRole)(VARIANT varChild, VARIANT *pvarRole); // required + STDMETHOD(get_accState)(VARIANT varChild, VARIANT *pvarState); // required + STDMETHOD(get_accHelp)(VARIANT varChild, BSTR *pszHelp); + STDMETHOD(get_accHelpTopic)(BSTR *pszHelpFile, VARIANT varChild, long *pidTopic); + STDMETHOD(get_accKeyboardShortcut)(VARIANT varChild, BSTR *pszKeyboardShortcut); + STDMETHOD(get_accFocus)(VARIANT *pvarChild); + STDMETHOD(get_accSelection)(VARIANT *pvarChildren); + STDMETHOD(get_accDefaultAction)(VARIANT varChild, BSTR *pszDefaultAction); + STDMETHOD(accSelect)(long flagsSelect, VARIANT varChild); + STDMETHOD(accLocation)(long *pxLeft, long *pyTop, long *pcxWidth, long *pcyHeight, VARIANT varChild); // required + STDMETHOD(accNavigate)(long navDir, VARIANT varStart, VARIANT *pvarEndUpAt); + STDMETHOD(accHitTest)(long xLeft, long yTop, VARIANT *pvarChild); + STDMETHOD(accDoDefaultAction)(VARIANT varChild); + STDMETHOD(put_accName)(VARIANT varChild, BSTR szName); + STDMETHOD(put_accValue)(VARIANT varChild, BSTR szValue); +private: + const WeakRef m_owner; +}; + +void CListAccessible::AccInitialize(CWindow wnd) { + m_wnd = wnd; +} +void CListAccessible::AccCleanup() { + if (m_interface.is_valid()) { + NotifyWinEvent(EVENT_OBJECT_DESTROY, m_wnd, OBJID_CLIENT, CHILDID_SELF); + m_interface.release(); + } + m_wnd = NULL; +} + +LRESULT CListAccessible::AccGetObject(WPARAM wp,LPARAM lp) { + const auto dwFlags = (DWORD) wp; + const auto dwObjId = (DWORD) lp; + + if (dwObjId == OBJID_CLIENT) + { + if (m_interface.is_empty()) + { + try { + m_interface = new IAccessible_CListControl( WeakRef(this, m_killSwitch) ); + } catch(...) { + //bah + return DefWindowProc(m_wnd,WM_GETOBJECT,wp,lp); + } + NotifyWinEvent(EVENT_OBJECT_CREATE, m_wnd, OBJID_CLIENT, CHILDID_SELF); + } + return LresultFromObject(IID_IAccessible, dwFlags, m_interface.get_ptr()); + } + else return DefWindowProc(m_wnd,WM_GETOBJECT,wp,lp); +} + +void CListAccessible::AccItemNamesChanged(pfc::bit_array const & mask) { + this->AccRefreshItems(mask, EVENT_OBJECT_NAMECHANGE); +} +void CListAccessible::AccReloadItems(pfc::bit_array const & mask) { + this->AccRefreshItems(mask, EVENT_OBJECT_NAMECHANGE); +} +void CListAccessible::AccStateChange(pfc::bit_array const & mask) { + this->AccRefreshItems(mask, EVENT_OBJECT_STATECHANGE); +} +void CListAccessible::AccStateChange(size_t index) { + this->AccStateChange(pfc::bit_array_one(index)); +} +void CListAccessible::AccRefreshItems(pfc::bit_array const & affected, UINT what) { + if (m_wnd == NULL || m_interface.is_empty()) return; + //if (GetFocus() != m_hWnd) return; + const size_t total = AccGetItemCount(); + for (size_t walk = affected.find_first(true, 0, total); walk < total; walk = affected.find_next(true, walk, total)) { + NotifyWinEvent(what, m_wnd, OBJID_CLIENT, ChildIdFromIndex(walk)); + } +} +void CListAccessible::AccItemLayoutChanged() { + if (m_wnd == NULL || m_interface.is_empty()) return; + NotifyWinEvent(EVENT_OBJECT_REORDER, m_wnd, OBJID_CLIENT, CHILDID_SELF); +} +void CListAccessible::AccFocusItemChanged(size_t index) { + if (m_wnd == NULL || m_interface.is_empty()) return; + if (GetFocus() != m_wnd) return; + NotifyWinEvent(EVENT_OBJECT_FOCUS, m_wnd, OBJID_CLIENT, index != SIZE_MAX ? ChildIdFromIndex(index) : CHILDID_SELF); +} +void CListAccessible::AccFocusOtherChanged(size_t index) { + if (m_wnd == NULL || m_interface.is_empty()) return; + if (GetFocus() != m_wnd) return; + const size_t itemCount = this->AccGetItemCount(); + index += itemCount; + NotifyWinEvent(EVENT_OBJECT_FOCUS, m_wnd, OBJID_CLIENT, index != SIZE_MAX ? ChildIdFromIndex(index) : CHILDID_SELF); +} +void CListAccessible::AccSelectionChanged(const pfc::bit_array & affected, const pfc::bit_array & state) { + if (m_wnd == NULL || m_interface.is_empty()) return; + //if (GetFocus() != m_wnd) return; + const size_t itemCount = this->AccGetItemCount(); + + const size_t limit = 20; + if (affected.calc_count(true, 0, itemCount, limit) == limit) { + NotifyWinEvent(EVENT_OBJECT_SELECTIONWITHIN, m_wnd, OBJID_CLIENT, CHILDID_SELF); + } else for(size_t walk = affected.find_first(true,0,itemCount); walk < itemCount; walk = affected.find_next(true,walk,itemCount)) { + NotifyWinEvent(state[walk] ? EVENT_OBJECT_SELECTIONADD : EVENT_OBJECT_SELECTIONREMOVE, m_wnd, OBJID_CLIENT, ChildIdFromIndex(walk)); + } +} +void CListAccessible::AccLocationChange() { + if (m_wnd == NULL || m_interface.is_empty()) return; + NotifyWinEvent(EVENT_OBJECT_LOCATIONCHANGE,m_wnd,OBJID_CLIENT, CHILDID_SELF); +} + +HRESULT IAccessible_CListControl::GetTypeInfoCount(UINT * pcTInfo) { + (void)pcTInfo; + return E_NOTIMPL; +} + +HRESULT IAccessible_CListControl::GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo ** ppTInfo) { + (void)iTInfo; (void)lcid; (void)ppTInfo; + return E_NOTIMPL; +} + +HRESULT IAccessible_CListControl::GetIDsOfNames(REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId) { + (void)riid; (void)rgszNames; (void)cNames; (void)lcid; (void)rgDispId; + return E_NOTIMPL; +} + +HRESULT IAccessible_CListControl::Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS * pDispParams, VARIANT * pVarResult, EXCEPINFO * pExcepInfo, UINT * puArgErr) { + (void)dispIdMember; (void)riid; (void)lcid; (void)wFlags; (void)pDispParams; (void)pVarResult; (void)pExcepInfo; (void)puArgErr; + return E_NOTIMPL; +} + +HRESULT IAccessible_CListControl::get_accParent(IDispatch **ppdispParent) // required +{ + if (ppdispParent == NULL) return E_INVALIDARG; + if (m_owner.IsEmpty()) return E_FAIL; + + *ppdispParent = NULL; + HRESULT hResult = AccessibleObjectFromWindow(m_owner->AccGetWnd(), OBJID_WINDOW, IID_IDispatch, (void**)ppdispParent); + return (hResult == S_OK) ? S_OK : S_FALSE; +} + +HRESULT IAccessible_CListControl::get_accChildCount(long *pcountChildren) { + if (pcountChildren == NULL) return E_INVALIDARG; + if (m_owner.IsEmpty()) return E_FAIL; + *pcountChildren = (long)( m_owner->AccGetItemCount() + m_owner->AccGetOtherCount() ); + return S_OK; +} +HRESULT IAccessible_CListControl::get_accChild(VARIANT varChild, IDispatch **ppdispChild) { + if (varChild.vt != VT_I4) return E_INVALIDARG; + if (ppdispChild == NULL) return E_INVALIDARG; + if (varChild.lVal == CHILDID_SELF) { + *ppdispChild = this; AddRef(); + return S_OK; + } else { + if (m_owner.IsEmpty()) return E_FAIL; + const size_t index = IndexFromChildId(varChild.lVal); + const size_t itemCount = m_owner->AccGetItemCount(); + if (index < itemCount) { + return S_FALSE; + } else if (index < itemCount + m_owner->AccGetOtherCount()) { + CWindow wnd = m_owner->AccGetOtherChildWnd(index - itemCount); + if (wnd == NULL) return S_FALSE; + if (AccessibleObjectFromWindow(wnd, OBJID_WINDOW, IID_IDispatch, (void**)ppdispChild) != S_OK) return S_FALSE; + return S_OK; + } else { + return E_INVALIDARG; + } + } +} + + +HRESULT IAccessible_CListControl::get_accName(VARIANT varChild, BSTR *pszName) // required +{ + if (varChild.vt != VT_I4) return E_INVALIDARG; + if (pszName == NULL) return E_INVALIDARG; + if (m_owner.IsEmpty()) return E_FAIL; + pfc::string8_fastalloc name; + if (varChild.lVal == CHILDID_SELF) { + m_owner->AccGetName(name); + } else { + const size_t index = IndexFromChildId(varChild.lVal); + const size_t itemCount = m_owner->AccGetItemCount(); + if (index < itemCount) { + m_owner->AccGetItemName(index,name); + } else if (index < itemCount + m_owner->AccGetOtherCount()) { + m_owner->AccGetOtherName(index - itemCount, name); + } else { + return E_INVALIDARG; + } + } + *pszName = SysAllocString(pfc::stringcvt::string_wide_from_utf8(name)); + return S_OK; +} +HRESULT IAccessible_CListControl::get_accValue(VARIANT varChild, BSTR *pszValue) { + if (varChild.vt != VT_I4) + return E_INVALIDARG; + if (pszValue == NULL) + return E_INVALIDARG; + + return S_FALSE; +} +HRESULT IAccessible_CListControl::get_accDescription(VARIANT varChild, BSTR *pszDescription) { + if (varChild.vt != VT_I4) return E_INVALIDARG; + if (pszDescription == NULL) return E_INVALIDARG; + if (varChild.lVal == CHILDID_SELF) return S_FALSE; + if (m_owner.IsEmpty()) return E_FAIL; + + *pszDescription = NULL; + + const size_t itemCount = m_owner->AccGetItemCount(); + const size_t index = IndexFromChildId(varChild.lVal); + + pfc::string_formatter temp; + if (index < itemCount) { + if (!m_owner->AccGetItemDescription(index, temp)) return S_FALSE; + } else if (index < itemCount + m_owner->AccGetOtherCount()) { + if (!m_owner->AccGetOtherDescription(index - itemCount, temp)) return S_FALSE; + } else { + return E_INVALIDARG; + } + *pszDescription = SysAllocString(pfc::stringcvt::string_os_from_utf8(temp)); + return S_OK; +} + +HRESULT IAccessible_CListControl::get_accRole(VARIANT varChild, VARIANT *pvarRole) // required +{ + if (varChild.vt != VT_I4) return E_INVALIDARG; + if (pvarRole == NULL) return E_INVALIDARG; + if (m_owner.IsEmpty()) return E_FAIL; + VariantClear(pvarRole); + pvarRole->vt = VT_I4; + if (varChild.lVal == CHILDID_SELF) { + pvarRole->lVal = ROLE_SYSTEM_LIST; + } else { + const size_t itemCount = m_owner->AccGetItemCount(); + const size_t index = IndexFromChildId(varChild.lVal); + if (index < itemCount) { + pvarRole->lVal = m_owner->AccGetItemRole( index ); + } else if (index < itemCount + m_owner->AccGetOtherCount()) { + pvarRole->lVal = m_owner->AccGetOtherRole(index - itemCount); + } else { + return E_INVALIDARG; + } + } + return S_OK; +} + +HRESULT IAccessible_CListControl::get_accState(VARIANT varChild, VARIANT *pvarState) // required +{ + if (varChild.vt != VT_I4) return E_INVALIDARG; + if (pvarState == NULL) return E_INVALIDARG; + if (m_owner.IsEmpty()) return E_FAIL; + + VariantClear(pvarState); + pvarState->vt = VT_I4; + + if (varChild.lVal == CHILDID_SELF) { + pvarState->lVal = /*STATE_SYSTEM_NORMAL*/ 0; + if (GetFocus() == m_owner->AccGetWnd()) + pvarState->lVal |= STATE_SYSTEM_FOCUSED; + } + else + { + const size_t index = IndexFromChildId(varChild.lVal); + const size_t itemCount = m_owner->AccGetItemCount(); + if (index < itemCount) { + pvarState->lVal = STATE_SYSTEM_MULTISELECTABLE | STATE_SYSTEM_SELECTABLE; + if (GetFocus() == m_owner->AccGetWnd()) { + pvarState->lVal |= STATE_SYSTEM_FOCUSABLE; + if (m_owner->AccGetFocusItem() == index) pvarState->lVal |= STATE_SYSTEM_FOCUSED; + } + if (m_owner->AccIsItemSelected(index)) pvarState->lVal |= STATE_SYSTEM_SELECTED; + if (!m_owner->AccIsItemVisible(index)) pvarState->lVal |= STATE_SYSTEM_OFFSCREEN | STATE_SYSTEM_INVISIBLE; + if (m_owner->AccIsItemChecked(index)) pvarState->lVal |= STATE_SYSTEM_CHECKED; + } else if (index < itemCount + m_owner->AccGetOtherCount()) { + const size_t indexO = index - itemCount; + pvarState->lVal = 0; + if (m_owner->AccIsOtherFocusable(indexO) && GetFocus() == m_owner->AccGetWnd()) { + pvarState->lVal |= STATE_SYSTEM_FOCUSABLE; + if (m_owner->AccGetFocusOther() == indexO) pvarState->lVal |= STATE_SYSTEM_FOCUSED; + } + if (!m_owner->AccIsOtherVisible(indexO)) pvarState->lVal |= STATE_SYSTEM_OFFSCREEN | STATE_SYSTEM_INVISIBLE; + } else { + return E_INVALIDARG; + } + } + return S_OK; +} +HRESULT IAccessible_CListControl::get_accHelp(VARIANT varChild, BSTR *pszHelp) +{ + if (varChild.vt != VT_I4) + return E_INVALIDARG; + if (pszHelp == NULL) + return E_INVALIDARG; + return S_FALSE; +} +HRESULT IAccessible_CListControl::get_accHelpTopic(BSTR *pszHelpFile, VARIANT varChild, long *pidTopic) +{ + if (varChild.vt != VT_I4) + return E_INVALIDARG; + if (pszHelpFile == NULL) + return E_INVALIDARG; + if (pidTopic == NULL) + return E_INVALIDARG; + return S_FALSE; +} +HRESULT IAccessible_CListControl::get_accKeyboardShortcut(VARIANT varChild, BSTR *pszKeyboardShortcut) +{ + (void)varChild; + if (pszKeyboardShortcut == NULL) + return E_INVALIDARG; + return S_FALSE; +} +HRESULT IAccessible_CListControl::get_accFocus(VARIANT *pvarChild) +{ + if (pvarChild == NULL) return E_INVALIDARG; + if (m_owner.IsEmpty()) return E_FAIL; + VariantClear(pvarChild); + if (GetFocus() != m_owner->AccGetWnd()) + pvarChild->vt = VT_EMPTY; + else { + pvarChild->vt = VT_I4; + size_t index = m_owner->AccGetFocusItem(); + if (index != ~0) { + pvarChild->lVal = ChildIdFromIndex(index); + } else { + index = m_owner->AccGetFocusOther(); + if (index != ~0) { + pvarChild->lVal = ChildIdFromIndex(index + m_owner->AccGetItemCount()); + } else { + pvarChild->lVal = CHILDID_SELF; + } + } + } + return S_OK; +} +HRESULT IAccessible_CListControl::get_accSelection(VARIANT *pvarChildren) +{ + if (pvarChildren == NULL) return E_INVALIDARG; + if (m_owner.IsEmpty()) return E_FAIL; + VariantClear(pvarChildren); + try { + + const size_t itemCount = m_owner->AccGetItemCount(); + size_t selCount = 0; + pfc::bit_array_bittable mask(itemCount); + for(size_t walk = 0; walk < itemCount; ++walk) { + bool state = m_owner->AccIsItemSelected(walk); + mask.set(walk,state); + if (state) selCount++; + } + + if (selCount == 0) { + pvarChildren->vt = VT_EMPTY; + } else if (selCount == 1) { + pvarChildren->vt = VT_I4; + pvarChildren->lVal = ChildIdFromIndex(mask.find_first(true, 0, itemCount)); + } else { + pfc::array_t data; data.set_size(selCount); size_t dataWalk = 0; + for(size_t walk = mask.find_first(true,0,itemCount); walk < itemCount; walk = mask.find_next(true,walk,itemCount)) { + data[dataWalk++] = ChildIdFromIndex(walk); + } + IEnumVARIANT * ptr = new IEnumVARIANT_selection(data.get_ptr(),data.get_size()); + ptr->AddRef(); + pvarChildren->vt = VT_UNKNOWN; + pvarChildren->punkVal = ptr; + } + } catch(std::bad_alloc const &) { + return E_OUTOFMEMORY; + } + return S_OK; +} +HRESULT IAccessible_CListControl::get_accDefaultAction(VARIANT varChild, BSTR *pszDefaultAction) +{ + if (varChild.vt != VT_I4) return E_INVALIDARG; + if (pszDefaultAction == NULL) return E_INVALIDARG; + if (m_owner.IsEmpty()) return E_FAIL; + *pszDefaultAction = NULL; + if (varChild.lVal == CHILDID_SELF) { + return S_FALSE; + } else { + pfc::string_formatter temp; + const size_t index = IndexFromChildId(varChild.lVal); + const size_t itemCount = m_owner->AccGetItemCount(); + if (index < itemCount) { + if (!m_owner->AccGetItemDefaultAction(temp)) return S_FALSE; + } else if (index < itemCount + m_owner->AccGetOtherCount()) { + if (!m_owner->AccGetOtherDefaultAction(index - itemCount, temp)) return false; + } else { + return E_INVALIDARG; + } + + *pszDefaultAction = SysAllocString(pfc::stringcvt::string_os_from_utf8(temp)); + return S_OK; + } +} +HRESULT IAccessible_CListControl::accSelect(long flagsSelect, VARIANT varChild) +{ + if (varChild.vt != VT_EMPTY && varChild.vt != VT_I4) return E_INVALIDARG; + if (m_owner.IsEmpty()) return E_FAIL; + if (varChild.vt == VT_EMPTY || varChild.lVal == CHILDID_SELF) + { + switch (flagsSelect) + { + case SELFLAG_TAKEFOCUS: + m_owner->AccGetWnd().SetFocus(); + return S_OK; + default: + return DISP_E_MEMBERNOTFOUND; + } + } + else + { + const size_t count = m_owner->AccGetItemCount(); + const size_t index = IndexFromChildId(varChild.lVal); + if (index < count) { + if (flagsSelect & SELFLAG_TAKESELECTION) + { + if (flagsSelect & (SELFLAG_ADDSELECTION | SELFLAG_REMOVESELECTION | SELFLAG_EXTENDSELECTION)) + return E_INVALIDARG; + m_owner->AccSetSelection(pfc::bit_array_true(), pfc::bit_array_one(index)); + } + else if (flagsSelect & SELFLAG_EXTENDSELECTION) + { + if (flagsSelect & SELFLAG_TAKESELECTION) + return E_INVALIDARG; + size_t focus = m_owner->AccGetFocusItem(); + if (focus == ~0) return S_FALSE; + bool state; + if (flagsSelect & SELFLAG_ADDSELECTION) + { + if (flagsSelect & SELFLAG_REMOVESELECTION) + return E_INVALIDARG; + state = true; + } + else if (flagsSelect & SELFLAG_REMOVESELECTION) + { + if (flagsSelect & SELFLAG_ADDSELECTION) + return E_INVALIDARG; + state = false; + } + else + { + state = m_owner->AccIsItemSelected(focus); + } + m_owner->AccSetSelection(pfc::bit_array_range(min(index, focus), max(index, focus)-min(index, focus)+1), pfc::bit_array_val(state)); + } + else if (flagsSelect & SELFLAG_ADDSELECTION) + { + if (flagsSelect & (SELFLAG_REMOVESELECTION | SELFLAG_EXTENDSELECTION)) + return E_INVALIDARG; + m_owner->AccSetSelection(pfc::bit_array_one(index), pfc::bit_array_true()); + } + else if (flagsSelect & SELFLAG_REMOVESELECTION) + { + if (flagsSelect & (SELFLAG_ADDSELECTION | SELFLAG_EXTENDSELECTION)) + return E_INVALIDARG; + m_owner->AccSetSelection(pfc::bit_array_one(index), pfc::bit_array_false()); + } + + if (flagsSelect & SELFLAG_TAKEFOCUS) { + m_owner->AccSetFocusItem(index); + } + } else if (index < count + m_owner->AccGetOtherCount()) { + const size_t indexO = index - count; + if (flagsSelect & SELFLAG_TAKEFOCUS) { + m_owner->AccSetFocusOther(indexO); + } + } else { + return E_INVALIDARG; + } + return S_OK; + } +} +HRESULT IAccessible_CListControl::accLocation(long *pxLeft, long *pyTop, long *pcxWidth, long *pcyHeight, VARIANT varChild) // required +{ + if (varChild.vt != VT_I4) return E_INVALIDARG; + if (pxLeft == NULL || pyTop == NULL || pcxWidth == NULL || pcyHeight == NULL) return E_INVALIDARG; + if (m_owner.IsEmpty()) return E_FAIL; + CRect rc; + const CWindow ownerWnd = m_owner->AccGetWnd(); + if (varChild.lVal == CHILDID_SELF) { + if (!ownerWnd.GetClientRect(&rc)) return E_FAIL; + } else { + const size_t index = IndexFromChildId(varChild.lVal); + const size_t itemCount = m_owner->AccGetItemCount(); + if (index < itemCount) { + if (!m_owner->AccGetItemRect(index,rc)) return S_FALSE; + } else if (index < itemCount + m_owner->AccGetOtherCount()) { + if (!m_owner->AccGetOtherRect(index - itemCount, rc)) return S_FALSE; + } else { + return E_INVALIDARG; + } + } + + if (!ownerWnd.ClientToScreen(rc)) return E_FAIL; + *pxLeft = rc.left; + *pyTop = rc.top; + *pcxWidth = rc.right-rc.left; + *pcyHeight = rc.bottom-rc.top; + return S_OK; +} +HRESULT IAccessible_CListControl::accNavigate(long navDir, VARIANT varStart, VARIANT *pvarEndUpAt) +{ + if (varStart.vt != VT_I4 && varStart.vt != VT_EMPTY) return E_INVALIDARG; + if (pvarEndUpAt == NULL) return E_INVALIDARG; + if (m_owner.IsEmpty()) return E_FAIL; + VariantClear(pvarEndUpAt); + pvarEndUpAt->vt = VT_EMPTY; + if (varStart.vt == VT_EMPTY || varStart.lVal == CHILDID_SELF) + { + switch (navDir) + { + case NAVDIR_LEFT: + case NAVDIR_RIGHT: + case NAVDIR_UP: + case NAVDIR_DOWN: + case NAVDIR_PREVIOUS: + case NAVDIR_NEXT: + // leave empty + break; + case NAVDIR_FIRSTCHILD: + if (m_owner->AccGetItemCount() > 0) + { + pvarEndUpAt->vt = VT_I4; + pvarEndUpAt->lVal = ChildIdFromIndex(0); + } + break; + case NAVDIR_LASTCHILD: + if (m_owner->AccGetItemCount() > 0) + { + pvarEndUpAt->vt = VT_I4; + pvarEndUpAt->lVal = ChildIdFromIndex(m_owner->AccGetItemCount()-1); + } + break; + } + } + else + { + const size_t index = IndexFromChildId(varStart.lVal); + const size_t itemCount = m_owner->AccGetItemCount(); + if (index >= itemCount) { + if (index < itemCount + m_owner->AccGetOtherCount()) return S_FALSE; + else return E_INVALIDARG; + } + switch (navDir) + { + case NAVDIR_LEFT: + case NAVDIR_RIGHT: + case NAVDIR_FIRSTCHILD: + case NAVDIR_LASTCHILD: + // leave empty + break; + case NAVDIR_UP: + case NAVDIR_PREVIOUS: + if (index > 0) + { + pvarEndUpAt->vt = VT_I4; + pvarEndUpAt->lVal = ChildIdFromIndex(index-1); + } + break; + case NAVDIR_DOWN: + case NAVDIR_NEXT: + if (index+1 < itemCount) + { + pvarEndUpAt->vt = VT_I4; + pvarEndUpAt->lVal = ChildIdFromIndex(index+1); + } + break; + } + } + return (pvarEndUpAt->vt != VT_EMPTY) ? S_OK : S_FALSE; +} +HRESULT IAccessible_CListControl::accHitTest(long xLeft, long yTop, VARIANT *pvarChild) +{ + if (pvarChild == NULL) return E_INVALIDARG; + if (m_owner.IsEmpty()) return E_FAIL; + VariantClear(pvarChild); + CPoint pt (xLeft, yTop); + const CWindow ownerWnd = m_owner->AccGetWnd(); + if (!ownerWnd.ScreenToClient(&pt)) return E_FAIL; + CRect rcClient; + if (!ownerWnd.GetClientRect(&rcClient)) return E_FAIL; + if (PtInRect(&rcClient, pt)) { + size_t index = m_owner->AccItemHitTest(pt); + if (index != ~0) { + pvarChild->vt = VT_I4; + pvarChild->lVal = ChildIdFromIndex(index); + } else { + index = m_owner->AccOtherHitTest(pt); + if (index != ~0) { + pvarChild->vt = VT_I4; + pvarChild->lVal = ChildIdFromIndex(m_owner->AccGetItemCount() + index); + CWindow wnd = m_owner->AccGetOtherChildWnd(index); + if (wnd != NULL) { + IDispatch * obj; + if (AccessibleObjectFromWindow(wnd,OBJID_WINDOW, IID_IDispatch, (void**)&obj) == S_OK) { + pvarChild->vt = VT_DISPATCH; + pvarChild->pdispVal = obj; + } + } + } else { + pvarChild->vt = VT_I4; + pvarChild->lVal = CHILDID_SELF; + } + } + } else { + pvarChild->vt = VT_EMPTY; + } + return S_OK; +} +HRESULT IAccessible_CListControl::accDoDefaultAction(VARIANT varChild) +{ + if (varChild.vt != VT_I4) return E_INVALIDARG; + if (m_owner.IsEmpty()) return E_FAIL; + if (varChild.lVal == CHILDID_SELF) return S_FALSE; + const size_t index = IndexFromChildId(varChild.lVal); + const size_t itemCount = m_owner->AccGetItemCount(); + if (index < itemCount) { + if (!m_owner->AccExecuteItemDefaultAction(index)) return S_FALSE; + } else if (index < itemCount + m_owner->AccGetOtherCount()) { + if (!m_owner->AccExecuteOtherDefaultAction(index - itemCount)) return S_FALSE; + } else { + return E_INVALIDARG; + } + return S_OK; +} +HRESULT IAccessible_CListControl::put_accName(VARIANT varChild, BSTR szName) { + (void)varChild; (void)szName; + return DISP_E_MEMBERNOTFOUND; +} +HRESULT IAccessible_CListControl::put_accValue(VARIANT varChild, BSTR szValue) { + (void)varChild; (void)szValue; + return DISP_E_MEMBERNOTFOUND; +} + +void CListAccessible::AccGetName(pfc::string_base & out) const { + auto str = pfc::getWindowText(m_wnd); + if ( str.length() > 0 ) out = str; + else out = "List Control"; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/CListAccessible.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/CListAccessible.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,294 @@ +#pragma once + +#include + +#pragma comment(lib, "oleacc.lib") + +#include "CListControl-Cell.h" +#include "CListControlWithSelection.h" + +//! Internal class interfacing with Windows accessibility APIs. \n +//! This class is not tied to any specific control and requires most of its methods to be overridden. \n +//! With CListControl you want to use CListControlAccImpl<> template instead of using CListAccessible directly. +class CListAccessible { +public: + void AccInitialize(CWindow wnd); + void AccCleanup(); + LRESULT AccGetObject(WPARAM wp,LPARAM lp); + CWindow AccGetWnd() const {return m_wnd;} + virtual size_t AccGetItemCount() const {return 0;} + virtual LONG AccGetItemRole(size_t index) const { (void)index; return ROLE_SYSTEM_LISTITEM; } + virtual void AccGetItemName(size_t index, pfc::string_base& out) const { (void)index; out = ""; } + virtual void AccGetName(pfc::string_base & out) const; + virtual size_t AccGetFocusItem() const {return SIZE_MAX;} + virtual bool AccIsItemSelected(size_t index) const { (void)index; return false; } + virtual bool AccIsItemChecked(size_t index) const { (void)index; return false; } + virtual bool AccIsItemVisible(size_t index) const { (void)index; return false; } + virtual bool AccGetItemDefaultAction(pfc::string_base& out) const { (void)out; return false; } + virtual bool AccExecuteItemDefaultAction(size_t index) { (void)index; return false; } + virtual void AccSetSelection(pfc::bit_array const& affected, pfc::bit_array const& state) { (void)affected; (void)state; } + virtual void AccSetFocusItem(size_t index) { (void)index; } + virtual bool AccGetItemRect(size_t index, CRect& out) const { (void)index; (void)out; return false; } + virtual bool AccGetItemDescription(size_t index, pfc::string_base& out) const { (void)index; (void)out; return false; } + virtual size_t AccItemHitTest(CPoint const& pt) const { (void)pt; return SIZE_MAX; } + + virtual DWORD AccGetOtherRole(size_t index) { (void)index; return 0; } + virtual size_t AccGetOtherCount() const {return 0;} + virtual void AccGetOtherName(size_t index, pfc::string_base& out) const { (void)index; out = ""; } + virtual size_t AccGetFocusOther() const {return SIZE_MAX;} + virtual void AccSetFocusOther(size_t index) { (void)index; } + virtual bool AccIsOtherVisible(size_t index) const { (void)index; return false; } + virtual bool AccGetOtherDescription(size_t index, pfc::string_base& out) const { (void)index; (void)out; return false; } + virtual size_t AccOtherHitTest(CPoint const& pt) const { (void)pt; return SIZE_MAX; } + virtual bool AccIsOtherFocusable(size_t index) const { (void)index; return false; } + virtual bool AccGetOtherDefaultAction(size_t index, pfc::string_base& out) const { (void)index; (void)out; return false; } + virtual bool AccExecuteOtherDefaultAction(size_t index) { (void)index; return false; } + virtual bool AccGetOtherRect(size_t index, CRect& out) const { (void)index; (void)out; return false; } + virtual CWindow AccGetOtherChildWnd(size_t index) const { (void)index; return NULL; } + + void AccItemNamesChanged( pfc::bit_array const & mask); + void AccReloadItems(pfc::bit_array const & mask ); + void AccRefreshItems(pfc::bit_array const & mask, UINT what); + void AccStateChange(pfc::bit_array const & mask); + void AccStateChange(size_t index); + void AccItemLayoutChanged(); + void AccFocusItemChanged(size_t index); + void AccFocusOtherChanged(size_t index); + void AccSelectionChanged(const pfc::bit_array & affected, const pfc::bit_array & status); + void AccLocationChange(); +protected: + ~CListAccessible() { * m_killSwitch = true; } +private: + CWindow m_wnd; + std::shared_ptr m_killSwitch = std::make_shared(); + pfc::com_ptr_t m_interface; +}; + +//! Basic wrapper implementing CListAccessible methods on top of CListControl. Leaves many methods to be overridden by calle +template class CListControlAccImpl : public TBaseClass, protected CListAccessible { +public: + template CListControlAccImpl( arg_t && ... arg ) : TBaseClass(std::forward(arg) ... ) {} + + BEGIN_MSG_MAP_EX(CListControlAccImpl) + MESSAGE_HANDLER(WM_GETOBJECT,OnGetObject) + MESSAGE_HANDLER(WM_DESTROY,OnDestroyPassThru) + MESSAGE_HANDLER(WM_CREATE,OnCreatePassThru) + CHAIN_MSG_MAP(TBaseClass) + END_MSG_MAP() +public: + void ReloadData() { + TBaseClass::ReloadData(); + AccItemLayoutChanged(); + } + void ReloadItems(pfc::bit_array const & mask) { + TBaseClass::ReloadItems(mask); + AccReloadItems(mask); + } +protected: + size_t AccGetItemCount() const {return this->GetItemCount();} + size_t AccGetFocusItem() const {return this->GetFocusItem();} + bool AccIsItemSelected(size_t index) const {return this->IsItemSelected(index);} + bool AccIsItemVisible(size_t index) const { + if (index >= AccGetItemCount()) return false; + return this->IsRectVisible(this->GetItemRect(index)); + } + bool AccExecuteItemDefaultAction(size_t index) {if (index < AccGetItemCount()) {this->ExecuteDefaultAction(index);return true;} else return false;} + bool AccGetItemRect(size_t index, CRect & out) const { + if (index >= AccGetItemCount()) return false; + out = this->GetItemRect(index); + return true; + } + size_t AccItemHitTest(CPoint const & pt) const { + size_t item; + if (!this->ItemFromPoint(pt,item)) return SIZE_MAX; + return item; + } + + void OnViewOriginChange(CPoint p_delta) override { + TBaseClass::OnViewOriginChange(p_delta); + AccLocationChange(); + } + + /* overrideme, optional + void AccGetName(pfc::string_base & out) const; + bool AccGetItemDefaultAction(pfc::string_base & out) const; + */ + + LONG AccRoleAt(size_t idx, size_t sub) const { + auto cell = this->GetCellType(idx, sub); + if (cell == nullptr) return 0; + return cell->AccRole(); + } + bool isCellText(size_t idx, size_t sub) const { + switch (AccRoleAt(idx, sub)) { + case ROLE_SYSTEM_TEXT: + case ROLE_SYSTEM_STATICTEXT: + case ROLE_SYSTEM_LISTITEM: + return true; + default: + return false; + } + } + bool useCellForDescription(size_t idx, size_t sub) const { + return sub > 0 && isCellText(idx, sub); + } + bool AccGetItemDescription(size_t index, pfc::string_base& out) const { + pfc::string_formatter ret, temp, temp2; + const size_t total = this->GetColumnCount(); + for (size_t walk = 0; walk < total; ) { + if (useCellForDescription(index, walk) && this->GetSubItemText(index, walk, temp) && temp.length() > 0) { + if (ret.length() > 0) ret << "; "; + this->GetColumnText(walk, temp2); + if (temp2.length() > 0) ret << temp2 << ": "; + ret << temp; + } + size_t d = this->GetSubItemSpan(index, walk); + if (d < 1) d = 1; + walk += d; + } + bool rv = (ret.length() > 0); + if (rv) out = ret; + return ret; + } + + void AccGetItemNameAlt(size_t index, pfc::string_base & out) const { + pfc::string_formatter ret, temp; + const size_t total = this->GetColumnCount(); + for (size_t walk = 0; walk < total; ) { + if (this->isCellText(index, walk) && this->GetSubItemText(index, walk, temp) && temp.length() > 0) { + if (ret.length() > 0) ret << "; "; + ret << temp; + } + size_t d = this->GetSubItemSpan(index, walk); + if (d < 1) d = 1; + walk += d; + } + out = ret; + } + + // Item name by default taken from column 0, override this if you supply another + void AccGetItemName(size_t index, pfc::string_base & out) const { + this->GetSubItemText(index, 0, out); + } + + void AccSetSelection(pfc::bit_array const & affected, pfc::bit_array const & state) override { + this->SetSelection(affected, state); +} + void AccSetFocusItem(size_t index) override { + this->SetFocusItem(index); + } + + void OnFocusChangedGroup2(size_t baseItem) override { + TBaseClass::OnFocusChangedGroup2(baseItem); + AccFocusOtherChanged((size_t)baseItem + 1); + } + void OnFocusChanged(size_t o, size_t f) override { + TBaseClass::OnFocusChanged(o, f); + AccFocusItemChanged(f); + } + + void OnSelectionChanged(pfc::bit_array const & affected, pfc::bit_array const & status) override { + TBaseClass::OnSelectionChanged(affected, status); + AccSelectionChanged(affected, status); + } + + CWindow AccGetOtherChildWnd(size_t index) const {return index == 0 ? CWindow(this->GetHeaderCtrl()) : CWindow(NULL) ;} + virtual DWORD AccGetOtherRole(size_t index) {return index > 0 ? ROLE_SYSTEM_GROUPING : ROLE_SYSTEM_WINDOW;}//FIXME? + virtual bool AccGetOtherDescription(size_t index, pfc::string_base& out) const { (void)index; (void)out; return false; }//FIXME?? + + size_t AccGetOtherCount() const {return 1 + this->GetItemCount();} + void AccGetOtherName(size_t index, pfc::string_base & out) const override { + if (index == 0) out = "Columns Header"; + else if (!this->GetGroupHeaderText2(index-1, out)) out = ""; + } + size_t AccGetFocusOther() const override { + size_t focus = this->GetGroupFocus2(); + if (focus != SIZE_MAX) return focus + 1; + else return SIZE_MAX; + } + void AccSetFocusOther(size_t index) override { + if (index > 0) { + this->SetGroupFocusByItem(index-1); + } + } + bool AccIsOtherVisible(size_t index) const override { + if (index == 0) return true; + CRect rc; + if (!this->GetGroupHeaderRect2(index-1,rc)) return false; + return IsRectVisible(rc); + } + + size_t AccOtherHitTest(CPoint const & pt) const { + { + CPoint s(pt); + if (this->ClientToScreen(&s)) { + CRect rc; + auto hdr = this->GetHeaderCtrl(); + if (hdr != NULL && hdr.GetWindowRect(rc)) { + if (rc.PtInRect(s)) { + return 0; + } + } + } + } + size_t groupBase; + if (this->GroupHeaderFromPoint2(pt, groupBase)) return groupBase+1; + return SIZE_MAX; + } + bool AccIsOtherFocusable(size_t index) const {return index > 0;} + bool AccGetOtherDefaultAction(size_t index, pfc::string_base& out) const { (void)index; (void)out; return false; } + bool AccExecuteOtherDefaultAction(size_t index) { (void)index; return false; } + bool AccGetOtherRect(size_t index, CRect & out) const { + if (index == 0) { + CRect rc, client; + + auto hdr = this->GetHeaderCtrl(); + if ( hdr == NULL ) return false; + if (!hdr.GetWindowRect(rc)) return false; + if (!this->ScreenToClient(rc)) return false; + if (!this->GetClientRect(client)) return false; + return !! out.IntersectRect(rc, client); + } else { + return this->GetGroupHeaderRect2(index-1, out); + } + } + LONG AccGetItemRole( size_t index ) const override { + auto type = this->GetCellType( index, 0 ); + if ( type != nullptr ) { + return type->AccRole(); + } + return ROLE_SYSTEM_LISTITEM; + } + void SetCellCheckState(size_t item, size_t subItem, bool value) override { + __super::SetCellCheckState(item, subItem, value); + this->AccStateChange(item); + } + bool AccIsItemChecked( size_t index ) const override { + auto type = this->GetCellType( index, 0 ); + if ( type != nullptr && type->IsToggle() ) { + return this->GetCellCheckState( index, 0 ); + } + return false; + } +private: + bool IsRectVisible(CRect const & rc) const { + return !!CRect().IntersectRect(this->GetClientRectHook(),rc); + } + LRESULT OnCreatePassThru(UINT,WPARAM,LPARAM,BOOL& bHandled) { + bHandled = FALSE; + try { AccInitialize(*this); } catch(...) {AccCleanup();} + return 0; + } + LRESULT OnDestroyPassThru(UINT,WPARAM,LPARAM,BOOL& bHandled) { + bHandled = FALSE; + AccCleanup(); + return 0; + } + LRESULT OnGetObject(UINT,WPARAM wp, LPARAM lp, BOOL & ) { + return this->AccGetObject(wp,lp); + } + +}; + +class CListControlWithSelectionImpl; +typedef CListControlAccImpl< CListControlWithSelectionImpl > CListControlWithSelectionAccImpl; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/CListControl-Cell.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/CListControl-Cell.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,45 @@ +#pragma once +#include // HTHEME +#include + +class CListCell { +public: + typedef uint32_t cellState_t; + enum { + cellState_none = 0, + cellState_hot = 1 << 0, + cellState_pressed = 1 << 1, + cellState_disabled = 1 << 2, + }; + + struct DrawContentArg_t { + DWORD hdrFormat = 0; + cellState_t cellState = 0; + CRect subItemRect; + CDCHandle dc; + const wchar_t * text = nullptr; + bool allowColors = true; + CRect rcHot; + CRect rcText; + HTHEME theme = NULL; + uint32_t colorHighlight = 0; + CWindow thisWnd; + std::function imageRenderer; + bool darkMode = false; + }; + virtual void DrawContent( DrawContentArg_t const & arg ) = 0; + virtual const char * Theme() { return nullptr; } + virtual bool ApplyTextStyle( LOGFONT & font, double scale, uint32_t state ); + virtual bool IsInteractive() { return false; } + virtual bool TracksMouseMove() { return false; } + virtual bool SuppressRowSelect() { return false; } + virtual bool IsToggle() { return false; } + virtual bool IsRadioToggle() { return false; } + virtual bool AllowTypeFind() { return true; } + virtual CRect HotRect( CRect rc ) { return rc; } + virtual HCURSOR HotCursor() { return NULL; } + virtual bool AllowDrawThemeText() { return false; } + virtual LONG AccRole(); + virtual uint32_t EditFlags() { return 0; } + virtual bool ClickToEdit() { return false; } +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/CListControl-Cells-Compat.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/CListControl-Cells-Compat.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,13 @@ +#pragma once +#include "CListControl-Cells.h" + +// Wrapper for old code using cell type enum constants + +#define cell_text &PFC_SINGLETON(CListCell_Text) +#define cell_multitext &PFC_SINGLETON(CListCell_MultiText) +#define cell_hyperlink &PFC_SINGLETON(CListCell_Hyperlink) +#define cell_button &PFC_SINGLETON(CListCell_Button) +#define cell_button_lite &PFC_SINGLETON(CListCell_ButtonLite) +#define cell_button_glyph &PFC_SINGLETON(CListCell_ButtonGlyph) +#define cell_checkbox &PFC_SINGLETON(CListCell_Checkbox) +#define cell_radiocheckbox &PFC_SINGLETON(CListCell_RadioCheckbox) diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/CListControl-Cells.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/CListControl-Cells.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,345 @@ +#include "stdafx.h" +#include "CListControl.h" +#include "CListControlHeaderImpl.h" +#include "CListControl-Cells.h" +#include "PaintUtils.h" +#include "GDIUtils.h" +#include +#include "InPlaceEdit.h" +#include "DarkMode.h" + +#define PRETEND_CLASSIC_THEME 0 + + +#if PRETEND_CLASSIC_THEME +#define IsThemePartDefined(A,B,C) false +#endif + +LONG CListCell::AccRole() { + return ROLE_SYSTEM_LISTITEM; +} + +void RenderCheckbox( HTHEME theme, CDCHandle dc, CRect rcCheckBox, unsigned stateFlags, bool bRadio ) { + + const int part = bRadio ? BP_RADIOBUTTON : BP_CHECKBOX; + + const bool bDisabled = (stateFlags & CListCell::cellState_disabled) != 0; + const bool bPressed = (stateFlags & CListCell::cellState_pressed ) != 0; + const bool bHot = ( stateFlags & CListCell::cellState_hot ) != 0; + + if (theme != NULL && IsThemePartDefined(theme, part, 0)) { + int state = 0; + if (bDisabled) { + state = bPressed ? CBS_CHECKEDDISABLED : CBS_UNCHECKEDDISABLED; + } else if ( bHot ) { + state = bPressed ? CBS_CHECKEDHOT : CBS_UNCHECKEDHOT; + } else { + state = bPressed ? CBS_CHECKEDNORMAL : CBS_UNCHECKEDNORMAL; + } + + CSize size; + if (SUCCEEDED(GetThemePartSize(theme, dc, part, state, rcCheckBox, TS_TRUE, &size))) { + if (size.cx <= rcCheckBox.Width() && size.cy <= rcCheckBox.Height()) { + CRect rc = rcCheckBox; + rc.left += ( rc.Width() - size.cx ) / 2; + rc.top += ( rc.Height() - size.cy ) / 2; + rc.right = rc.left + size.cx; + rc.bottom = rc.top + size.cy; + DrawThemeBackground(theme, dc, part, state, rc, &rc); + return; + } + } + } + + auto DPI = QueryContextDPI(dc); + CSize size(MulDiv(13, DPI.cx, 96), MulDiv(13, DPI.cy, 96)); + CSize sizeBig = rcCheckBox.Size(); + if (sizeBig.cx >= size.cx && sizeBig.cy >= size.cy) { + CPoint center = rcCheckBox.CenterPoint(); + rcCheckBox.left = center.x - size.cx / 2; rcCheckBox.right = rcCheckBox.left + size.cx; + rcCheckBox.top = center.y - size.cy / 2; rcCheckBox.bottom = rcCheckBox.top + size.cy; + } + + int stateEx = bRadio ? DFCS_BUTTONRADIO : DFCS_BUTTONCHECK; + if ( bPressed ) stateEx |= DFCS_CHECKED; + if ( bDisabled ) stateEx |= DFCS_INACTIVE; + else if ( bHot ) stateEx |= DFCS_HOT; + DrawFrameControl(dc, rcCheckBox, DFC_BUTTON, stateEx); +} + +void RenderButton( HTHEME theme, CDCHandle dc, CRect rcButton, CRect rcUpdate, uint32_t cellState ) { + + const int part = BP_PUSHBUTTON; + + enum { + stNormal = PBS_NORMAL, + stHot = PBS_HOT, + stDisabled = PBS_DISABLED, + stPressed = PBS_PRESSED, + }; + + int state = 0; + if (cellState & CListCell::cellState_disabled) state = stDisabled; + if ( cellState & CListCell::cellState_pressed ) state = stPressed; + else if ( cellState & CListCell::cellState_hot ) state = stHot; + else state = stNormal; + + CRect rcClient = rcButton; + + if (theme != NULL && IsThemePartDefined(theme, part, 0)) { + DrawThemeBackground(theme, dc, part, state, rcClient, &rcUpdate); + } else { + int stateEx = DFCS_BUTTONPUSH; + switch (state) { + case stPressed: stateEx |= DFCS_PUSHED; break; + case stDisabled: stateEx |= DFCS_INACTIVE; break; + } + DrawFrameControl(dc, rcClient, DFC_BUTTON, stateEx); + } +} + +bool CListCell::ApplyTextStyle( LOGFONT & font, double scale, uint32_t ) { + if ( scale != 1.0 ) { + font.lfHeight = pfc::rint32( font.lfHeight * scale ); + return true; + } else { + return false; + } +} + +void CListCell_Text::DrawContent( DrawContentArg_t const & arg ) { + const auto fgWas = arg.dc.GetTextColor(); + CDCHandle dc = arg.dc; + if ((arg.cellState & cellState_disabled) != 0 && arg.allowColors) { + dc.SetTextColor(DarkMode::GetSysColor(COLOR_GRAYTEXT, arg.darkMode)); + } + + CRect clip = arg.rcText; + + if (arg.imageRenderer && clip.Width() > clip.Height() ) { + CRect rcImage = clip; rcImage.right = rcImage.left + clip.Height(); + arg.imageRenderer(dc, rcImage); + clip.left = rcImage.right; + } + + const t_uint32 format = PaintUtils::DrawText_TranslateHeaderAlignment(arg.hdrFormat); + dc.DrawText( arg.text, (int)wcslen(arg.text), clip, format | DT_NOPREFIX | DT_END_ELLIPSIS | DT_SINGLELINE | DT_VCENTER ); + + dc.SetTextColor(fgWas); +} + +void CListCell_TextColors::DrawContent( DrawContentArg_t const & arg ) { + CDCHandle dc = arg.dc; + + CRect clip = arg.rcText; + + const uint32_t fgWas = dc.GetTextColor(); + + const t_uint32 format = PaintUtils::DrawText_TranslateHeaderAlignment(arg.hdrFormat); + const t_uint32 bk = dc.GetBkColor(); + const t_uint32 fg = fgWas; + const t_uint32 hl = (arg.allowColors ? arg.colorHighlight : fg); + const t_uint32 colors[3] = { PaintUtils::BlendColor(bk, fg, 33), fg, hl }; + + PaintUtils::TextOutColorsEx(dc, arg.text, clip, format, colors); + + dc.SetTextColor(fgWas); +} + +void CListCell_MultiText::DrawContent( DrawContentArg_t const & arg ) { + CDCHandle dc = arg.dc; + + const int textLen = (int) wcslen( arg.text ); + + CRect clip = arg.rcText; + + const t_uint32 format = PaintUtils::DrawText_TranslateHeaderAlignment(arg.hdrFormat) | DT_NOPREFIX | DT_VCENTER ; + + CRect rcDraw = clip; + dc.DrawText(arg.text, textLen, rcDraw, format | DT_CALCRECT); + auto txSize = rcDraw.Size(); + rcDraw = clip; + if ( txSize.cy < rcDraw.Height() ) { + int sub = rcDraw.Height() - txSize.cy; + rcDraw.top += sub/2; + rcDraw.bottom = rcDraw.top + txSize.cy; + } + dc.DrawText(arg.text, textLen, rcDraw, format); +} + +bool CListCell_Hyperlink::ApplyTextStyle( LOGFONT & font, double scale, uint32_t state ) { + bool rv = __super::ApplyTextStyle(font, scale, state); + + if ( state & cellState_hot ) { + font.lfUnderline = TRUE; + rv = true; + } + + return rv; +} + +HCURSOR CListCell_Hyperlink::HotCursor() { + return LoadCursor(NULL, IDC_HAND); +} + +LONG CListCell_Hyperlink::AccRole() { + return ROLE_SYSTEM_LINK; +} + +void CListCell_Hyperlink::DrawContent( DrawContentArg_t const & arg ) { + + CDCHandle dc = arg.dc; + + const uint32_t fgWas = dc.GetTextColor(); + + const t_uint32 format = PaintUtils::DrawText_TranslateHeaderAlignment(arg.hdrFormat); + if (arg.allowColors) dc.SetTextColor( arg.colorHighlight ); + // const t_uint32 bk = dc.GetBkColor(); + + CRect rc = arg.rcText; + dc.DrawText(arg.text, (int) wcslen(arg.text), rc, format | DT_NOPREFIX | DT_END_ELLIPSIS | DT_SINGLELINE | DT_VCENTER ); + + dc.SetTextColor(fgWas); +} + +LONG CListCell_Button::AccRole() { + return ROLE_SYSTEM_PUSHBUTTON; +} + +void CListCell_Button::DrawContent( DrawContentArg_t const & arg ) { + + CDCHandle dc = arg.dc; + + const bool bPressed = (arg.cellState & cellState_pressed) != 0; + const bool bHot = (arg.cellState & cellState_hot) != 0; + + + if ( !m_lite || bHot || bPressed ) { + RenderButton( arg.theme, dc, arg.rcHot, arg.rcHot, arg.cellState ); + } + + CRect clip = arg.rcText; + + dc.DrawText(arg.text, (int) wcslen(arg.text), clip, DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER | DT_CENTER); +} + +bool CListCell_ButtonGlyph::ApplyTextStyle( LOGFONT & font, double scale, uint32_t state ) { + return __super::ApplyTextStyle(font, scale * 1.3, state); +} + +static CRect CheckBoxRect(CRect rc) { + if (rc.Width() > rc.Height()) { + rc.right = rc.left + rc.Height(); + } + return rc; +} + +LONG CListCell_Checkbox::AccRole() { + return m_radio ? ROLE_SYSTEM_RADIOBUTTON : ROLE_SYSTEM_CHECKBUTTON; +} + +CRect CListCell_Checkbox::HotRect( CRect rc ) { + return CheckBoxRect( rc ); +} + +void CListCell_Checkbox::DrawContent( DrawContentArg_t const & arg ) { + + CDCHandle dc = arg.dc; + + // const bool bPressed = (arg.cellState & cellState_pressed) != 0; + // const bool bHot = (arg.cellState & cellState_hot) != 0; + + + // CRect clip = arg.rcText; + + const uint32_t fgWas = dc.GetTextColor(); + + if (arg.subItemRect.Width() > arg.subItemRect.Height() ) { + CRect rcCheckbox = arg.subItemRect; + rcCheckbox.right = rcCheckbox.left + rcCheckbox.Height(); + RenderCheckbox(arg.theme, dc, rcCheckbox, arg.cellState, m_radio ); + CRect rcText = arg.subItemRect; + rcText.left = rcCheckbox.right; + if (arg.cellState & cellState_disabled) { + dc.SetTextColor(GetSysColor(COLOR_GRAYTEXT)); + } + + if (arg.imageRenderer && rcText.Width() > rcText.Height()) { + CRect rcImage = rcText; rcImage.right = rcImage.left + rcImage.Height(); + arg.imageRenderer(dc, rcImage); + rcText.left = rcImage.right; + } + + dc.DrawText(arg.text, (int) wcslen(arg.text), rcText, DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER | DT_LEFT); + } else { + RenderCheckbox(arg.theme, dc, arg.subItemRect, arg.cellState, m_radio ); + } + + dc.SetTextColor(fgWas); +} + +void CListCell_Text_FixedColor::DrawContent(DrawContentArg_t const & arg) { + if (arg.allowColors) { + SetTextColorScope scope(arg.dc, m_col); + __super::DrawContent(arg); + } else { + __super::DrawContent(arg); + } +} + +uint32_t CListCell_Combo::EditFlags() { + return InPlaceEdit::KFlagCombo; +} + +void CListCell_Combo::DrawContent(DrawContentArg_t const & arg) { + CDCHandle dc = arg.dc; + + const bool bDisabled = (arg.cellState & CListCell::cellState_disabled) != 0; + const bool bPressed = (arg.cellState & cellState_pressed) != 0; + const bool bHot = (arg.cellState & cellState_hot) != 0; + + const int part = CP_DROPDOWNBUTTONRIGHT; + + const HTHEME theme = arg.theme; + + const int w = MulDiv(16, GetDeviceCaps(dc, LOGPIXELSX), 96); + CRect rcText = arg.rcText; + if (theme != NULL && IsThemePartDefined(theme, part, 0)) { + int state = CBXSR_NORMAL; + if (bDisabled) { + state = CBXSR_DISABLED; + } else if (bPressed) { + state = CBXSR_PRESSED; + } else if (bHot) { + state = CBXSR_HOT; + } + + CSize size; + CRect rcCombo = arg.subItemRect; + if (w < rcCombo.Width()) { + rcCombo.left = rcCombo.right - w; + DrawThemeBackground(theme, dc, part, state, rcCombo, &rcCombo); + if (rcCombo.left < rcText.right ) rcText.right = rcCombo.left; + } + } else { + CRect rcCombo = arg.subItemRect; + if (w < rcCombo.Width()) { + rcCombo.left = rcCombo.right - w; + if (rcCombo.left < rcText.right) rcText.right = rcCombo.left; + + if (bHot) { + DrawFrameControl(dc, rcCombo, DFC_BUTTON, DFCS_BUTTONPUSH | DFCS_HOT); + } + dc.DrawText(L"˅", 1, rcCombo, DT_VCENTER | DT_CENTER | DT_SINGLELINE); + } + + } + + DrawContentArg_t arg2 = arg; + arg2.rcText = rcText; + PFC_SINGLETON(CListCell_Text).DrawContent(arg2); +} + +LONG CListCell_Combo::AccRole() { + return ROLE_SYSTEM_DROPLIST; +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/CListControl-Cells.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/CListControl-Cells.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,101 @@ +#pragma once + +#include "CListControl-Cell.h" + + +class CListCell_Interactive : public CListCell { +public: + bool IsInteractive() override { return true; } +}; + +class CListCell_Text : public CListCell { +public: + void DrawContent( DrawContentArg_t const & ) override; + bool AllowDrawThemeText() override { return true; } +}; + +class CListCell_Edit: public CListCell_Text { +public: + bool ClickToEdit() { return true; } +}; + +class CListCell_TextColors : public CListCell_Text { +public: + void DrawContent( DrawContentArg_t const & ) override; +}; + +class CListCell_MultiText : public CListCell { +public: + void DrawContent( DrawContentArg_t const & ) override; +}; + +class CListCell_Hyperlink : public CListCell_Interactive { +public: + void DrawContent( DrawContentArg_t const & ) override; + bool ApplyTextStyle( LOGFONT & font, double scale, uint32_t state ) override; + HCURSOR HotCursor() override; + LONG AccRole() override; + bool SuppressRowSelect() override { return true; } +}; + +class CListCell_Button : public CListCell_Interactive { +public: + void DrawContent( DrawContentArg_t const & ) override; + const char * Theme() override { return "BUTTON"; } + bool AllowTypeFind() override { return false; } + LONG AccRole() override; + bool SuppressRowSelect() override { return true; } + +protected: + bool m_lite = false; +}; + +class CListCell_ButtonLite : public CListCell_Button { +public: + CListCell_ButtonLite() { m_lite = true; } +}; + +class CListCell_ButtonGlyph : public CListCell_ButtonLite { +public: + bool ApplyTextStyle( LOGFONT & font, double scale, uint32_t state ) override; +}; + +class CListCell_Checkbox : public CListCell_Interactive { +public: + void DrawContent( DrawContentArg_t const & ) override; + const char * Theme() override { return "BUTTON"; } + bool IsToggle() override { return true; } + CRect HotRect( CRect rc ) override; + bool IsRadioToggle() override { return m_radio; } + LONG AccRole() override; + +protected: + bool m_radio = false; +}; + +class CListCell_RadioCheckbox : public CListCell_Checkbox { +public: + CListCell_RadioCheckbox() { m_radio = true; } + + static CListCell_RadioCheckbox instance; +}; + +class CListCell_Combo : public CListCell_Interactive { +public: + void DrawContent(DrawContentArg_t const &) override; + const char * Theme() override { return "COMBOBOX"; } + LONG AccRole() override; + uint32_t EditFlags() override; + bool ClickToEdit() { return true; } +}; + +void RenderButton( HTHEME theme, CDCHandle dc, CRect rcButton, CRect rcUpdate, uint32_t cellState ); +void RenderCheckbox( HTHEME theme, CDCHandle dc, CRect rcCheckBox, unsigned stateFlags, bool bRadio ); + + +class CListCell_Text_FixedColor : public CListCell_Text { + const COLORREF m_col; +public: + CListCell_Text_FixedColor(COLORREF col) : m_col(col) {} + void DrawContent(DrawContentArg_t const & arg) override; +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/CListControl-Subst.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/CListControl-Subst.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,1503 @@ +#include "stdafx.h" +#include "CListControlComplete.h" +#include "CListControl-Subst.h" +#include "CWindowCreateAndDelete.h" +#include +#include "ImplementOnFinalMessage.h" +#include "CListControl-Cells.h" +#include "windowLifetime.h" + +#define I_IMAGEREALLYNONE (-3) + +namespace { + + static int safeFillText(wchar_t* psz, int cch, pfc::wstringLite const& text) { + int len = (int)text.length(); + int lim = cch - 1; + if (len > lim) len = lim; + for (int i = 0; i < len; ++i) psz[i] = text[i]; + psz[len] = 0; + return len; + } + + class CListControl_ListViewBase : public CListControlComplete { + protected: + const DWORD m_style; + DWORD m_listViewExStyle = 0; + CImageList m_imageLists[4]; + bool m_groupViewEnabled = false; + public: + CListControl_ListViewBase(DWORD style) : m_style(style) { + if (style & LVS_SINGLESEL) this->SetSelectionModeSingle(); + else this->SetSelectionModeMulti(); + } + + BEGIN_MSG_MAP_EX(CListControl_ListViewBase) + MSG_WM_CREATE(OnCreate) + MESSAGE_HANDLER_EX(LVM_INSERTCOLUMN, OnInsertColumn) + MESSAGE_HANDLER_EX(LVM_DELETECOLUMN, OnDeleteColumn) + MESSAGE_HANDLER_EX(LVM_SETCOLUMN, OnSetColumn) + MESSAGE_HANDLER_EX(LVM_SETCOLUMNWIDTH, OnSetColumnWidth) + MESSAGE_HANDLER_EX(LVM_GETCOLUMNWIDTH, OnGetColumnWidth) + MESSAGE_HANDLER_EX(LVM_GETCOLUMNORDERARRAY, OnGetColumnOrderArray) + MESSAGE_HANDLER_EX(LVM_SETCOLUMNORDERARRAY, OnSetColumnOrderArray) + MESSAGE_HANDLER_EX(LVM_GETITEMCOUNT, OnGetItemCount) + MESSAGE_HANDLER_EX(LVM_GETITEMRECT, OnGetItemRect) + MESSAGE_HANDLER_EX(LVM_GETSUBITEMRECT, OnGetSubItemRect) + MESSAGE_HANDLER_EX(LVM_HITTEST, OnHitTest) + MESSAGE_HANDLER_EX(LVM_GETITEMSTATE, OnGetItemState) + MESSAGE_HANDLER_EX(LVM_SETITEMSTATE, OnSetItemState) + MESSAGE_HANDLER_EX(LVM_GETNEXTITEM, OnGetNextItem) + MESSAGE_HANDLER_EX(LVM_GETNEXTITEMINDEX, OnGetNextItemIndex) + MESSAGE_HANDLER_EX(LVM_SUBITEMHITTEST, OnSubItemHitTest) + MESSAGE_HANDLER_EX(LVM_GETSELECTEDCOUNT, OnGetSelCount) + MESSAGE_HANDLER_EX(LVM_GETHEADER, OnGetHeader) + MESSAGE_HANDLER_EX(LVM_SETEXTENDEDLISTVIEWSTYLE, OnSetExtendedListViewStyle) + MESSAGE_HANDLER_EX(LVM_GETEXTENDEDLISTVIEWSTYLE, OnGetExtendedListViewStyle) + MESSAGE_HANDLER_EX(LVM_ENSUREVISIBLE, OnEnsureVisible) + MESSAGE_HANDLER_EX(LVM_SETIMAGELIST, OnSetImageList) + MESSAGE_HANDLER_EX(LVM_GETIMAGELIST, OnGetImageList) + MESSAGE_HANDLER_EX(LVM_EDITLABEL, OnEditLabel) + MESSAGE_HANDLER_EX(LVM_GETSTRINGWIDTH, OnGetStringWidth) + MESSAGE_HANDLER_EX(LVM_ENABLEGROUPVIEW, OnEnableGroupView) + MESSAGE_HANDLER_EX(LVM_SCROLL, OnScroll) + MESSAGE_HANDLER_EX(LVM_REDRAWITEMS, OnRedrawItems) + MSG_WM_KEYDOWN(OnKeyDown) + MSG_WM_SYSKEYDOWN(OnKeyDown) + CHAIN_MSG_MAP(CListControlComplete) + END_MSG_MAP() + + void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { + NMLVKEYDOWN arg = {}; + arg.hdr = this->setupHdr(LVN_KEYDOWN); + arg.wVKey = nChar; + sendNotify(&arg); + SetMsgHandled(FALSE); + } + LRESULT OnCreate(LPCREATESTRUCT) { + SetMsgHandled(FALSE); + // Adopt style flags of the original control to keep various ATL checks happy + DWORD style = GetStyle(); + style = (style & 0xFFFF0000) | (m_style & 0xFFFF); + SetWindowLong(GWL_STYLE, style); + return 0; + } + + LRESULT OnGetColumnWidth(UINT, WPARAM wp, LPARAM) { + size_t idx = (size_t)wp; + return GetSubItemWidth(idx); + } + LRESULT OnSetColumnWidth(UINT, WPARAM wp, LPARAM lp) { + size_t idx = (size_t)wp; + if (idx >= GetColumnCount()) return FALSE; + // undocumented: low 16 bits must be used, or else testing against LVSCW_AUTOSIZE fails hard + // all macros sending LVM_SETCOLUMNWIDTH use low 16 bits of LPARAM + int w = (short)lp; + if (this->IsHeaderless()) { + if (w < 0) { + m_headerlessColumns[idx] = UINT32_MAX; + } else { + m_headerlessColumns[idx] = (uint32_t)w; + this->OnColumnsChanged(); + } + } else { + uint32_t pass = (uint32_t)w; + if (w < 0) { + if (w == LVSCW_AUTOSIZE_USEHEADER) pass = columnWidthAuto; + else pass = columnWidthAutoUseContent; + } + this->ResizeColumn(idx, pass); + } + return TRUE; + } + LRESULT OnGetColumnOrderArray(UINT, WPARAM wp, LPARAM lp) { + int* out = (int*)lp; + auto arr = this->GetColumnOrderArray(); + if ((size_t)wp != arr.size()) return 0; + for (size_t w = 0; w < arr.size(); ++w) out[w] = arr[w]; + return 1; + } + LRESULT OnSetColumnOrderArray(UINT, WPARAM wp, LPARAM lp) { + if (this->IsHeaderless()) { + PFC_ASSERT(!"Implement and test me"); + return 0; + } else { + auto hdr = GetHeaderCtrl(); + WIN32_OP_D(hdr.SetOrderArray((int)wp, (int*)lp)); + } + ReloadData(); + return 1; + } + LRESULT OnInsertColumn(UINT, WPARAM wp, LPARAM lp) { + size_t idx = (size_t)wp; + auto col = reinterpret_cast(lp); + + if (IsHeaderless()) { + if (idx > m_headerlessColumns.size()) idx = m_headerlessColumns.size(); + uint32_t width = 0; + if (col->mask & LVCF_WIDTH) width = col->cx; + m_headerlessColumns.insert(m_headerlessColumns.begin() + idx, width); + this->OnColumnsChanged(); + return 0; + } + if (this->GetHeaderCtrl() == NULL) { + if (m_style & LVS_NOSORTHEADER) { + this->InitializeHeaderCtrl(); + } else { + this->InitializeHeaderCtrlSortable(); + } + } + + PFC_ASSERT(this->GetHeaderCtrl().GetItemCount() == (int)this->GetColumnCount()); + + if (idx != this->GetColumnCount()) { + PFC_ASSERT(!"Arbitrary column insert not implemented, please add columns in order"); + return -1; + } + + pfc::string8 label; int width = 0; DWORD format = HDF_LEFT; + if (col->mask & LVCF_TEXT) label = pfc::utf8FromWide(col->pszText); + if (col->mask & LVCF_WIDTH) width = col->cx; + if (col->mask & LVCF_FMT) { + format = col->fmt & LVCFMT_JUSTIFYMASK; + } + this->AddColumn(label, width, format); + + PFC_ASSERT(this->GetHeaderCtrl().GetItemCount() == (int)this->GetColumnCount()); + + return idx; + } + LRESULT OnDeleteColumn(UINT, WPARAM wp, LPARAM) { + size_t idx = (size_t)wp; + if (idx >= this->GetColumnCount()) { + PFC_ASSERT(!"???"); return FALSE; + } + this->DeleteColumn(idx); + return TRUE; + } + LRESULT OnSetColumn(UINT, WPARAM wp, LPARAM lp) { + size_t idx = (size_t)wp; + if (idx >= this->GetColumnCount()) { + PFC_ASSERT(!"???"); return FALSE; + } + auto col = reinterpret_cast(lp); + + if (col->mask & (LVCF_TEXT | LVCF_FMT)) { + const char* pText = nullptr; DWORD format = UINT32_MAX; + pfc::string8 strText; + if (col->mask & LVCF_TEXT) { + strText = pfc::utf8FromWide(col->pszText); + pText = strText.c_str(); + } + if (col->mask & LVCF_FMT) { + format = col->fmt & LVCFMT_JUSTIFYMASK; + } + this->SetColumn(idx, pText, format); + } + + if (col->mask & LVCF_WIDTH) { + this->ResizeColumn(idx, col->cx); + } + + return TRUE; + } + LRESULT OnGetItemCount(UINT, WPARAM, LPARAM) { + return (LRESULT)this->GetItemCount(); + } + + LRESULT OnGetItemRect(UINT, WPARAM wp, LPARAM lp) { + size_t idx = (size_t)wp; + RECT* rc = (RECT*)lp; + if (idx < GetItemCount()) { + // LVIR_* not supported + * rc = GetItemRect(idx); + return TRUE; + } + return FALSE; + } + + LRESULT OnGetSubItemRect(UINT, WPARAM wp, LPARAM lp) { + size_t idx = (size_t)wp; + RECT* rc = (RECT*)lp; + if (idx < GetItemCount()) { + size_t subItem = (size_t)rc->top; + // LVIR_* not supported + *rc = GetSubItemRect(idx, subItem); + return TRUE; + } + return FALSE; + } + + LRESULT OnHitTest(UINT, WPARAM, LPARAM lp) { + auto info = (LVHITTESTINFO*)lp; + CPoint pt = this->PointClientToAbs(info->pt); + size_t item = this->ItemFromPointAbs(pt); + size_t subItem = SIZE_MAX; + if (item != SIZE_MAX) { + info->iItem = (int)item; + size_t subItem = this->SubItemFromPointAbs(pt); + info->iSubItem = (subItem != SIZE_MAX) ? (int)subItem : -1; + } + return item != SIZE_MAX ? (LRESULT)item : (LRESULT)-1; + } + LRESULT OnSubItemHitTest(UINT, WPARAM, LPARAM lp) { + auto info = (LVHITTESTINFO*)lp; + CPoint pt = this->PointClientToAbs(info->pt); + size_t item = this->ItemFromPointAbs(pt); + size_t subItem = SIZE_MAX; + if (item != SIZE_MAX) { + info->iItem = (int)item; + subItem = this->SubItemFromPointAbs(pt); + info->iSubItem = (subItem != SIZE_MAX) ? (int)subItem : -1; + } + return subItem != SIZE_MAX ? (LRESULT)subItem : (LRESULT)-1; + } + + virtual void SetItemState(size_t idx, DWORD mask, DWORD state) { + if (idx >= GetItemCount()) return; + if (mask & LVIS_FOCUSED) { + if (state & LVIS_FOCUSED) { + this->SetFocusItem(idx); + } else { + if (this->GetFocusItem() == idx) { + this->SetFocusItem(SIZE_MAX); + } + } + } + if (mask & LVIS_SELECTED) { + if (this->IsSingleSelect()) { + if (state & LVIS_SELECTED) this->SelectSingle(idx); + } else { + this->SetSelectionAt(idx, (state & LVIS_SELECTED) != 0); + } + } + } + LRESULT OnSetItemState(UINT, WPARAM wp, LPARAM lp) { + LVITEM* pItem = (LVITEM*)lp; + if ((LONG_PTR)wp < 0) { + if (pItem->stateMask & LVIS_FOCUSED) { + if (pItem->state & LVIS_FOCUSED) { + // makes no sense + } else { + this->SetFocusItem(SIZE_MAX); + } + } + if (pItem->stateMask & LVIS_SELECTED) { + if (pItem->state & LVIS_SELECTED) { + this->SelectAll(); + } else { + this->SelectNone(); + } + } + } else { + size_t idx = (size_t)wp; + SetItemState(idx, pItem->stateMask, pItem->state); + } + return TRUE; + } + + virtual UINT GetItemState(size_t idx) const { + UINT ret = 0; + if (idx == this->GetFocusItem()) ret |= LVIS_FOCUSED; + if (this->IsItemSelected(idx)) ret |= LVIS_SELECTED; + return ret; + } + LRESULT OnGetItemState(UINT, WPARAM wp, LPARAM lp) { + LRESULT ret = 0; + size_t idx = (size_t)wp; + if (idx < GetItemCount()) { + ret |= (this->GetItemState(idx) & lp); + } + return ret; + } + + LRESULT OnGetNextItemIndex(UINT, WPARAM wp, LPARAM lp) { + LVITEMINDEX* info = (LVITEMINDEX*)wp; + int item = (int)OnGetNextItem(LVM_GETNEXTITEM, info->iItem, lp); + info->iItem = item; + return item >= 0; + } + LRESULT OnGetNextItem(UINT, WPARAM wp, LPARAM lp) { + // GetSelectedIndex() : + // return (int)::SendMessage(this->m_hWnd, LVM_GETNEXTITEM, (WPARAM)-1, MAKELPARAM(LVNI_ALL | LVNI_SELECTED, 0)); + + const bool bVisible = (lp & LVNI_VISIBLEONLY) != 0; + std::pair range; + if ( bVisible ) range = this->GetVisibleRange(); + + if ((lp & LVNI_STATEMASK) == LVNI_FOCUSED) { + size_t ret = this->GetFocusItem(); + if (bVisible) { + if (ret < range.first || ret >= range.second) ret = SIZE_MAX; + } + return (LRESULT)ret; + } + + const auto count = this->GetItemCount(); + + if (wp == (WPARAM)-1 && bVisible) { + // Simplified visible range search + for (size_t idx = range.first; idx < range.second; ++idx) { + if (this->GetItemState(idx) & lp) { + return (LRESULT)idx; + } + } + return -1; + } + + size_t base; + if ((LONG_PTR)wp < 0) base = 0; + else base = wp + 1; + for (size_t idx = base; idx < count; ++idx) { + if (bVisible) { + if (idx < range.first || idx >= range.second) continue; + } + if (this->GetItemState(idx) & lp) { + return (LRESULT)idx; + } + } + return -1; + } + LRESULT OnGetSelCount(UINT, WPARAM, LPARAM) { + return (LRESULT) this->GetSelectedCount(); + } + LRESULT OnGetHeader(UINT, WPARAM, LPARAM) { + return (LRESULT)GetHeaderCtrl().m_hWnd; + } + LRESULT OnSetExtendedListViewStyle(UINT, WPARAM wp, LPARAM lp) { + DWORD ret = m_listViewExStyle; + DWORD set = (DWORD)lp, mask = (DWORD)wp; + if (mask == 0) mask = 0xFFFFFFFF; + m_listViewExStyle = (m_listViewExStyle & ~mask) | (set & mask); + + this->SetRowStyle((m_listViewExStyle & LVS_EX_GRIDLINES) ? rowStyleGrid : rowStyleDefault); + + if (m_listViewExStyle != ret) ReloadData(); + return ret; + } + LRESULT OnGetExtendedListViewStyle(UINT, WPARAM, LPARAM) { + return m_listViewExStyle; + } + LRESULT OnEnsureVisible(UINT, WPARAM wp, LPARAM lp) { + size_t idx = (size_t)wp; + if (idx < this->GetItemCount()) { + (void)lp; // FIX ME partialOK? + this->EnsureItemVisible(idx); + return TRUE; + } + return FALSE; + } + LRESULT OnSetImageList(UINT, WPARAM wp, LPARAM lp) { + size_t idx = (size_t)wp; + LRESULT ret = 0; + if (idx < std::size(m_imageLists)) { + auto& ref = m_imageLists[idx]; + ret = (LRESULT)ref.m_hImageList; + ref = (HIMAGELIST)lp; + } + return ret; + } + LRESULT OnGetImageList(UINT, WPARAM wp, LPARAM lp) { + size_t idx = (size_t)wp; + LRESULT ret = 0; + if (idx < std::size(m_imageLists)) { + ret = (LRESULT)m_imageLists[idx].m_hImageList; + } + return ret; + } + LRESULT OnEditLabel(UINT, WPARAM wp, LPARAM) { + int index = (int)wp; + HWND ret = NULL; + if (index < 0) { + this->TableEdit_Abort(false); + } else { + ret = this->TableEdit_Start((size_t)index, 0); + } + return (LRESULT)ret; + } + LRESULT OnGetStringWidth(UINT, WPARAM, LPARAM lp) { + auto str = (const wchar_t*)lp; + return this->GetOptimalColumnWidthFixed(pfc::utf8FromWide(str), false /* no pad */); + } + LRESULT OnEnableGroupView(UINT, WPARAM wp, LPARAM) { + bool bEnable = (wp != 0); + if (bEnable == m_groupViewEnabled) return 0; + m_groupViewEnabled = bEnable; + ReloadData(); + return 1; + } + LRESULT OnScroll(UINT, WPARAM, LPARAM) { + PFC_ASSERT(!"Implement me"); + return 0; + } + LRESULT OnRedrawItems(UINT, WPARAM wp, LPARAM lp) { + size_t base = wp; + size_t last = lp; + if (last < base) return FALSE; + size_t count = last + 1 - base; + this->UpdateItems(pfc::bit_array_range(base, count)); + return TRUE; + } + bool TableEdit_CanAdvanceHere(size_t item, size_t subItem, uint32_t whatHappened) const override { + // Block line cycling with enter key + auto code = (whatHappened & InPlaceEdit::KEditMaskReason); + if (code == InPlaceEdit::KEditEnter) return false; + return __super::TableEdit_CanAdvanceHere(item, subItem, whatHappened); + } + bool TableEdit_IsColumnEditable(t_size subItem) const override { + return subItem == 0; + } + NMHDR setupHdr(UINT code) const { + return { m_hWnd, (UINT_PTR)this->GetDlgCtrlID(), code }; + } + LRESULT sendNotify(void* data) const { + auto hdr = reinterpret_cast(data); + PFC_ASSERT(hdr->idFrom == (UINT_PTR) GetDlgCtrlID()); + return GetParent().SendMessage(WM_NOTIFY, hdr->idFrom, reinterpret_cast(data)); + } + int getDispInfoImage(size_t item, size_t subItem) const { + NMLVDISPINFO info = { setupHdr(LVN_GETDISPINFO) }; + info.item.mask = LVIF_IMAGE; + info.item.iItem = (int)item; + info.item.iSubItem = (int)subItem; + sendNotify(&info); + PFC_ASSERT(info.item.iImage != I_IMAGECALLBACK); + return info.item.iImage; + } + pfc::string8 getDispInfoText(size_t item, size_t subItem) const { + NMLVDISPINFO info = { setupHdr(LVN_GETDISPINFO) }; + info.item.mask = LVIF_TEXT; + info.item.iItem = (int)item; + info.item.iSubItem = (int)subItem; + + wchar_t buffer[1024] = {}; + info.item.pszText = buffer; + info.item.cchTextMax = (int) std::size(buffer); + sendNotify(&info); + if (info.item.pszText == LPSTR_TEXTCALLBACK || info.item.pszText == nullptr) { + PFC_ASSERT(!"WTF??"); return ""; + } + return pfc::utf8FromWide(info.item.pszText); + } + virtual LPARAM GetItemParam(size_t) { return 0; } + void ExecuteDefaultAction(size_t idx) override { + NMITEMACTIVATE info = { setupHdr(NM_DBLCLK) }; + info.iItem = (int) idx; + info.lParam = GetItemParam(idx); + sendNotify(&info); + } + void OnSubItemClicked(t_size item, t_size subItem, CPoint pt) override { + __super::OnSubItemClicked(item, subItem, pt); + NMITEMACTIVATE info = { setupHdr(NM_CLICK) }; + info.iItem = (int)item; + info.iSubItem = (int)subItem; + info.ptAction = pt; + sendNotify(&info); + } + void OnFocusChanged(size_t oldFocus, size_t newFocus) override { + __super::OnFocusChanged(oldFocus, newFocus); + const auto count = this->GetItemCount(); + + if (oldFocus < count) { + auto idx = oldFocus; + NMLISTVIEW info = { setupHdr(LVN_ITEMCHANGED) }; + info.iItem = (int)idx; + info.lParam = this->GetItemParam(idx); + auto base = this->GetItemState(idx); + info.uOldState = base | LVIS_FOCUSED; + info.uNewState = base; + info.uChanged = LVIF_STATE; + this->sendNotify(&info); + } + if (newFocus < count) { + auto idx = newFocus; + NMLISTVIEW info = { setupHdr(LVN_ITEMCHANGED) }; + info.iItem = (int)idx; + info.lParam = this->GetItemParam(idx); + auto base = this->GetItemState(idx); + info.uOldState = base & ~LVIS_FOCUSED; + info.uNewState = base; + info.uChanged = LVIF_STATE; + this->sendNotify(&info); + } + } + + void OnSelectionChanged(pfc::bit_array const& affected, pfc::bit_array const& status) override { + + __super::OnSelectionChanged(affected, status); + const auto count = this->GetItemCount(); + + const size_t focus = this->GetFocusItem(); + + // LVN_ITEMCHANGING not supported, CListControl currently doesn't hand this info + + affected.for_each(true, 0, count, [&](size_t idx) { + bool sel_new = status[idx]; + bool sel_old = !sel_new; + NMLISTVIEW info = { setupHdr(LVN_ITEMCHANGED) }; + info.iItem = (int)idx; + info.lParam = this->GetItemParam(idx); + info.uOldState = (sel_old ? LVIS_SELECTED : 0) | (idx == focus ? LVIS_FOCUSED : 0); + info.uNewState = (sel_new ? LVIS_SELECTED : 0) | (idx == focus ? LVIS_FOCUSED : 0); + info.uChanged = LVIF_STATE; + this->sendNotify(&info); + }); + } + void RequestReorder(size_t const* order, size_t count) override {} + void RequestRemoveSelection() override {} + + void OnColumnHeaderClick(t_size index) override { + NMLISTVIEW info = { setupHdr(LVN_COLUMNCLICK) }; + info.iItem = -1; + info.iSubItem = (int)index; + this->sendNotify(&info); + } + + bool IsHeaderless() const { + return (m_style & LVS_NOCOLUMNHEADER) != 0; + } + + std::vector< uint32_t > m_headerlessColumns; + + size_t GetColumnCount() const override { + if (IsHeaderless()) { + return m_headerlessColumns.size(); + } + return __super::GetColumnCount(); + } + uint32_t GetSubItemWidth(size_t subItem) const override { + if (IsHeaderless()) { + if (subItem < m_headerlessColumns.size()) { + auto v = m_headerlessColumns[subItem]; + if (v == UINT32_MAX) { + uint32_t nAuto = 0, wNormal = 0; + for (auto walk : m_headerlessColumns) { + if (walk == UINT32_MAX) ++nAuto; + else wNormal += walk; + } + PFC_ASSERT(nAuto > 0); + uint32_t wTotal = this->GetClientRectHook().Width(); + if (wTotal > wNormal) { + uint32_t autoTotal = wTotal - wNormal; + v = autoTotal / nAuto; + } else { + v = 0; + } + } + return v; + } + else return 0; + } + return __super::GetSubItemWidth(subItem); + } + + bool GetCellTypeSupported() const override { + return useCheckBoxes(); + } + + cellType_t GetCellType(size_t item, size_t subItem) const override { + if (useCheckBoxes() && subItem == 0) { + return &PFC_SINGLETON(CListCell_Checkbox); + } + return __super::GetCellType(item, subItem); + } + + bool useCheckBoxes() const { + return (m_listViewExStyle & LVS_EX_CHECKBOXES) != 0; + } + + void TableEdit_SetField(t_size item, t_size subItem, const char* value) override { + if (subItem != 0) { + PFC_ASSERT(!"subItem should be zero"); + return; + } + auto textW = pfc::wideFromUTF8(value); + NMLVDISPINFO info = { setupHdr(LVN_ENDLABELEDIT) }; + info.item.iItem = (int)item; + info.item.mask = LVIF_TEXT; + info.item.pszText = const_cast( textW.c_str() ); + + if (sendNotify(&info) != 0) { + SetSubItemText(item, subItem, value); + } + } + + virtual void SetSubItemText(size_t item, size_t subItem, const char* text) {} + + virtual int GetItemImage(size_t item, size_t subItem) const { + return I_IMAGEREALLYNONE; + } + CImageList GetImageList() const { + return m_imageLists[LVSIL_SMALL]; + } + bool RenderCellImageTest(size_t item, size_t subItem) const override { + return GetImageList() != NULL && GetItemImage(item, subItem) != I_IMAGEREALLYNONE; + } + void RenderCellImage(size_t item, size_t subItem, CDCHandle dc, const CRect& rc) const override { + auto img = GetItemImage(item, subItem); + auto imgList = GetImageList(); + if (img >= 0 && imgList) { + CSize size; + WIN32_OP_D(imgList.GetIconSize(size)); + CRect rc2 = rc; + if (size.cx <= rc.Width() && size.cy <= rc.Height()) { + auto cp = rc.CenterPoint(); + rc2.left = cp.x - size.cx / 2; + rc2.top = cp.y - size.cy / 2; + rc2.right = rc2.left + size.cx; + rc2.bottom = rc2.top + size.cy; + } + imgList.DrawEx(img, dc, rc2, CLR_NONE, CLR_NONE, ILD_SCALE); + } + } + + bool m_notifyItemDraw = false; + + UINT GetItemCDState(size_t which) const { + UINT ret = 0; + DWORD state = GetItemState(which); + if (state & LVIS_FOCUSED) ret |= CDIS_FOCUS; + if (state & LVIS_SELECTED) ret |= CDIS_SELECTED; + return ret; + } + + void RenderRect(const CRect& p_rect, CDCHandle p_dc) override { + NMCUSTOMDRAW cd = { setupHdr(NM_CUSTOMDRAW) }; + cd.dwDrawStage = CDDS_PREPAINT; + cd.hdc = p_dc; + cd.rc = p_rect; + cd.dwItemSpec = UINT32_MAX; + cd.uItemState = 0; + cd.lItemlParam = 0; + LRESULT status = sendNotify(&cd); + m_notifyItemDraw = (status & CDRF_NOTIFYITEMDRAW) != 0; + + if ((status & CDRF_SKIPDEFAULT) != 0) { + return; + } + __super::RenderRect(p_rect, p_dc); + + cd.dwDrawStage = CDDS_POSTPAINT; + sendNotify(&cd); + } + void RenderItem(t_size item, const CRect& itemRect, const CRect& updateRect, CDCHandle dc) override { + NMCUSTOMDRAW cd = {}; + if (m_notifyItemDraw) { + cd = { setupHdr(NM_CUSTOMDRAW) }; + cd.dwDrawStage = CDDS_ITEMPREPAINT; + cd.hdc = dc; + cd.rc = itemRect; + cd.dwItemSpec = (DWORD)item; + cd.uItemState = GetItemCDState(item); + cd.lItemlParam = GetItemParam(item); + LRESULT status = sendNotify(&cd); + if (status & CDRF_SKIPDEFAULT) return; + } + + __super::RenderItem(item, itemRect, updateRect, dc); + + + if (m_notifyItemDraw) { + cd.dwDrawStage = CDDS_ITEMPOSTPAINT; + sendNotify(&cd); + } + } +#if 0 + void RenderSubItemText(t_size item, t_size subItem, const CRect& subItemRect, const CRect& updateRect, CDCHandle dc, bool allowColors) override { + + __super::RenderSubItemText(item, subItem, subItemRect, updateRect, dc, allowColors); + } +#endif + + }; + + class CListControl_ListViewOwnerData : public CListControl_ListViewBase { + public: + CListControl_ListViewOwnerData(DWORD style) : CListControl_ListViewBase(style) {} + + BEGIN_MSG_MAP_EX(CListControl_ListViewOwnerData) + MESSAGE_HANDLER_EX(LVM_SETITEMCOUNT, OnSetItemCount) + CHAIN_MSG_MAP(CListControl_ListViewBase) + END_MSG_MAP() + private: + size_t m_itemCount = 0; + LRESULT OnSetItemCount(UINT, WPARAM wp, LPARAM) { + auto count = (size_t)wp; + if (m_itemCount != count) { + m_itemCount = count; ReloadData(); + } + return 0; + } + + t_size GetItemCount() const override { + return m_itemCount; + } + bool GetSubItemText(t_size item, t_size subItem, pfc::string_base& out) const override { + if (item < m_itemCount) { + out = this->getDispInfoText(item, subItem); + return true; + } + return false; + } + int GetItemImage(size_t item, size_t subItem) const override { + int ret = I_IMAGEREALLYNONE; + if (subItem == 0) { + ret = this->getDispInfoImage(item, subItem); + } + return ret; + } + void SetSubItemText(size_t item, size_t subItem, const char* text) override { + auto textW = pfc::wideFromUTF8(text); + NMLVDISPINFO info = { setupHdr(LVN_SETDISPINFO) }; + info.item.iItem = (int)item; + info.item.iSubItem = (int)subItem; + info.item.mask = LVIF_TEXT; + info.item.pszText = const_cast(textW.c_str()); + sendNotify(&info); + ReloadItem(item); + } + }; + + class CListControl_ListView : public CListControl_ListViewBase { + public: + CListControl_ListView(DWORD style) : CListControl_ListViewBase(style) {} + + BEGIN_MSG_MAP_EX(CListControl_ListView) + MESSAGE_HANDLER_EX(LVM_INSERTITEM, OnInsertItem) + MESSAGE_HANDLER_EX(LVM_SETITEM, OnSetItem) + MESSAGE_HANDLER_EX(LVM_SETITEMCOUNT, OnSetItemCount) + MESSAGE_HANDLER_EX(LVM_GETITEM, OnGetItem) + MESSAGE_HANDLER_EX(LVM_GETITEMTEXT, OnGetItemText) + MESSAGE_HANDLER_EX(LVM_INSERTGROUP, OnInsertGroup) + MESSAGE_HANDLER_EX(LVM_REMOVEGROUP, OnRemoveGroup) + MESSAGE_HANDLER_EX(LVM_GETGROUPCOUNT, OnGetGroupCount) + MESSAGE_HANDLER_EX(LVM_GETGROUPINFO, OnGetGroupInfo) + MESSAGE_HANDLER_EX(LVM_SETGROUPINFO, OnSetGroupInfo) + MESSAGE_HANDLER_EX(LVM_GETGROUPINFOBYINDEX, OnGetGroupInfoByIndex) + MESSAGE_HANDLER_EX(LVM_REMOVEALLGROUPS, OnRemoveAllGroups) + MESSAGE_HANDLER_EX(LVM_DELETEITEM, OnDeleteItem) + MESSAGE_HANDLER_EX(LVM_DELETEALLITEMS, OnDeleteAllItems) + CHAIN_MSG_MAP(CListControl_ListViewBase) + END_MSG_MAP() + private: + struct text_t { + pfc::string8 text; + bool callback = false; + }; + struct rec_t { + std::vector< text_t > text; + LPARAM param = 0; + int image = I_IMAGEREALLYNONE; + bool checked = false; + groupID_t groupID = 0; + int LVGroupID = 0; + }; + + std::vector m_content; + + groupID_t m_groupIDGen = 0; + groupID_t groupIDGen() { return ++m_groupIDGen; } + struct group_t { + int LVGroupID = 0; + groupID_t GroupID = 0; + pfc::string8 header; + }; + std::vector m_groups; + + groupID_t groupFromLV(int LV) const { + for (auto& g : m_groups) { + if (g.LVGroupID == LV) return g.GroupID; + } + return 0; + } + + t_size GetItemCount() const override { + return m_content.size(); + } + bool GetSubItemText(t_size item, t_size subItem, pfc::string_base& out) const override { + if (item < m_content.size()) { + auto& r = m_content[item]; + if (subItem < r.text.size()) { + auto& t = r.text[subItem]; + if (t.callback) { + out = getDispInfoText(item, subItem); + } else { + out = t.text; + } + return true; + } + } + return false; + } + void SetSubItemText(size_t item, size_t subItem, const char* text) override { + if (item < m_content.size()) { + auto& r = m_content[item]; + if (subItem < r.text.size()) { + auto& t = r.text[subItem]; + t.callback = false; t.text = text; + ReloadItem(item); + } + } + } + + int GetItemImage(size_t item, size_t subItem) const override { + int ret = I_IMAGEREALLYNONE; + if (subItem == 0 && item < m_content.size()) { + auto& r = m_content[item]; + ret = r.image; + if (ret == I_IMAGECALLBACK) ret = this->getDispInfoImage(item, subItem); + } + return ret; + } + LPARAM GetItemParam(size_t item) override { + LPARAM ret = 0; + if (item < m_content.size()) { + ret = m_content[item].param; + } + return ret; + } + + static text_t makeText(const wchar_t* p) { + text_t text; + if (p == LPSTR_TEXTCALLBACK) { + text.callback = true; + } else { + text.text = pfc::utf8FromWide(p); + } + return text; + } + LRESULT OnSetItem(UINT, WPARAM, LPARAM lp) { + auto pItem = reinterpret_cast(lp); + size_t item = (size_t)pItem->iItem; + const size_t total = GetItemCount(); + if (item >= total) return FALSE; + size_t subItem = (size_t)pItem->iSubItem; + if (subItem > 1024) return FALSE; // quick sanity + auto& rec = m_content[item]; + size_t width = subItem + 1; + if (rec.text.size() < width) rec.text.resize(width); + bool bReload = false, bReloadAll = false; + if (pItem->mask & LVIF_TEXT) { + rec.text[subItem] = makeText(pItem->pszText); + bReload = true; + } + if (pItem->mask & LVIF_IMAGE) { + rec.image = pItem->iImage; + bReload = true; + } + if (pItem->mask & LVIF_PARAM) { + rec.param = pItem->lParam; + } + if (pItem->mask & LVIF_GROUPID) { + rec.LVGroupID = pItem->iGroupId; + rec.groupID = groupFromLV(rec.LVGroupID); + if (m_groupViewEnabled) bReloadAll = true; + } + if (bReloadAll) { + this->ReloadData(); + } else if (bReload) { + this->ReloadItem(item); + } + if (pItem->mask & LVIF_STATE) { + this->SetItemState(item, pItem->stateMask, pItem->state); + } + return TRUE; + } + LRESULT OnInsertItem(UINT, WPARAM, LPARAM lp) { + auto pItem = reinterpret_cast(lp); + + size_t item = (size_t)pItem->iItem; + const size_t total = GetItemCount(); + if (item > total) item = total; + + rec_t r; + if (pItem->mask & LVIF_TEXT) { + r.text = { makeText(pItem->pszText) }; + } + if (pItem->mask & LVIF_GROUPID) { + r.LVGroupID = pItem->iGroupId; + r.groupID = groupFromLV(r.LVGroupID); + } + if (pItem->mask & LVIF_IMAGE) { + r.image = pItem->iImage; + } + if (pItem->mask & LVIF_PARAM) { + r.param = pItem->lParam; + } + + m_content.insert(m_content.begin() + item, std::move(r)); + if (m_groupViewEnabled) ReloadData(); + else this->OnItemsInserted(item, 1, false); + + return (LRESULT)item; + } + LRESULT OnSetItemCount(UINT, WPARAM wp, LPARAM) { + // It's not actually supposed to be called like this, LVM_SETITEMCOUNT is meant for ownerdata listviews + auto count = (size_t)wp; + if (count != m_content.size()) { + m_content.resize(wp); + ReloadData(); + } + return 0; + } + + LRESULT OnInsertGroup(UINT, WPARAM wp, LPARAM lp) { + LVGROUP* arg = (LVGROUP*)lp; + if ((arg->mask & (LVGF_GROUPID | LVGF_HEADER)) != (LVGF_GROUPID | LVGF_HEADER)) return -1; + + auto LVGroupID = arg->iGroupId; + for (auto& existing : m_groups) { + if (existing.LVGroupID == LVGroupID) return -1; + } + + size_t idx = (size_t)wp; + if (idx > m_groups.size()) idx = m_groups.size(); + + group_t grp; + grp.LVGroupID = LVGroupID; + grp.GroupID = this->groupIDGen(); + grp.header = pfc::utf8FromWide(arg->pszHeader); + m_groups.insert(m_groups.begin() + idx, std::move(grp)); + // No reload data - adding of items does it + return (LRESULT)idx; + } + LRESULT OnRemoveGroup(UINT, WPARAM wp, LPARAM) { + int LVGroupID = (int)wp; + for (size_t walk = 0; walk < m_groups.size(); ++walk) { + if (m_groups[walk].LVGroupID == LVGroupID) { + m_groups.erase(m_groups.begin() + walk); + return walk; + } + } + return -1; + } + void getGroupInfo(group_t const& in, LVGROUP* out) { + if (out->mask & LVGF_HEADER) { + auto text = pfc::wideFromUTF8(in.header.c_str()); + safeFillText(out->pszHeader, out->cchHeader, text); + } + if (out->mask & LVGF_GROUPID) { + out->iGroupId = in.LVGroupID; + } + } + void setGroupInfo(group_t& grp, LVGROUP* in) { + bool bReload = false; + if (in->mask & LVGF_HEADER) { + grp.header = pfc::utf8FromWide(in->pszHeader); + bReload = true; + } + if (in->mask & LVGF_GROUPID) { + grp.LVGroupID = in->iGroupId; + bReload = true; + } + + if (bReload) this->ReloadData(); + } + LRESULT OnGetGroupCount(UINT, WPARAM, LPARAM) { + return (LRESULT)m_groups.size(); + } + LRESULT OnGetGroupInfo(UINT, WPARAM wp, LPARAM lp) { + int LVGroupID = (int)wp; + auto out = (LVGROUP*)lp; + for (auto& grp : m_groups) { + if (grp.LVGroupID == LVGroupID) { + getGroupInfo(grp, out); + return LVGroupID; + } + } + return -1; + } + LRESULT OnSetGroupInfo(UINT, WPARAM wp, LPARAM lp) { + int LVGroupID = (int)wp; + auto in = (LVGROUP*)lp; + int ret = -1; + for (auto& grp : m_groups) { + if (grp.LVGroupID == LVGroupID) { + setGroupInfo(grp, in); + ret = grp.LVGroupID; + } + } + return ret; + } + LRESULT OnGetGroupInfoByIndex(UINT, WPARAM wp, LPARAM lp) { + size_t idx = (size_t)wp; + LVGROUP* out = (LVGROUP*)lp; + if (idx < m_groups.size()) { + getGroupInfo(m_groups[idx], out); + } + return FALSE; + } + LRESULT OnRemoveAllGroups(UINT, WPARAM, LPARAM) { + m_groups.clear(); return 0; + } + LRESULT OnDeleteItem(UINT, WPARAM wp, LPARAM) { + size_t idx = (size_t)wp; + LRESULT rv = FALSE; + const size_t oldCount = m_content.size(); + if (idx < oldCount) { + m_content.erase(m_content.begin() + idx); + this->OnItemsRemoved(pfc::bit_array_one(idx), oldCount); + rv = TRUE; + } + return rv; + } + LRESULT OnDeleteAllItems(UINT, WPARAM, LPARAM) { + m_content.clear(); ReloadData(); + return TRUE; + } + int fillText(size_t item, size_t subItem, LVITEM* pItem) const { + pfc::wstringLite text; + if (item < m_content.size()) { + auto& r = m_content[item]; + if (subItem < r.text.size()) { + auto& t = r.text[subItem]; + if (!t.callback) { + text = pfc::wideFromUTF8(t.text); + } + } + } + return safeFillText(pItem->pszText, pItem->cchTextMax, text); + } + LRESULT OnGetItem(UINT, WPARAM, LPARAM lp) { + auto pItem = reinterpret_cast(lp); + if (pItem->mask & LVIF_TEXT) { + fillText(pItem->iItem, pItem->iSubItem, pItem); + } + if (pItem->mask & LVIF_IMAGE) { + size_t idx = pItem->iItem; + if (idx < m_content.size()) { + auto& line = m_content[idx]; + pItem->iImage = line.image; + } + } + if (pItem->mask & LVIF_PARAM) { + pItem->lParam = GetItemParam(pItem->iItem); + } + + return TRUE; + } + LRESULT OnGetItemText(UINT, WPARAM wp, LPARAM lp) { + auto item = (size_t)wp; + auto pItem = reinterpret_cast(lp); + size_t subItem = (size_t)pItem->iSubItem; + return fillText(item, subItem, pItem); + } + + bool GetCellCheckState(size_t item, size_t sub) const override { + bool rv = false; + if (sub == 0 && item < m_content.size()) { + rv = m_content[item].checked; + } + return rv; + } + void SetCellCheckState(size_t item, size_t sub, bool value) override { + if (sub == 0 && item < m_content.size()) { + auto& rec = m_content[item]; + if (rec.checked != value) { + auto oldState = this->GetItemState(item); + rec.checked = value; + __super::SetCellCheckState(item, sub, value); + + NMLISTVIEW info = { this->setupHdr(LVN_ITEMCHANGED) }; + info.iItem = (int)item; + info.lParam = this->GetItemParam(item); + info.uChanged = LVIF_STATE; + info.uOldState = oldState; + info.uNewState = this->GetItemState(item); + this->sendNotify(&info); + } + } + } + UINT GetItemState(size_t idx) const override { + UINT ret = __super::GetItemState(idx); + if (useCheckBoxes() && idx < m_content.size()) { + int nCheck = m_content[idx].checked ? 2 : 1; + ret |= INDEXTOSTATEIMAGEMASK(nCheck); + } + return ret; + } + void SetItemState(size_t idx, DWORD mask, DWORD state) override { + __super::SetItemState(idx, mask, state); + if (useCheckBoxes() && (mask & LVIS_STATEIMAGEMASK) != 0) { + int nCheck = ((state & LVIS_STATEIMAGEMASK) >> 12); + this->SetCellCheckState(idx, 0, nCheck == 2); + } + } + groupID_t GetItemGroup(t_size p_item) const override { + if (m_groupViewEnabled && p_item < m_content.size()) { + return m_content[p_item].groupID; + } + return 0; + } + bool GetGroupHeaderText2(size_t baseItem, pfc::string_base& out) const override { + auto id = GetItemGroup(baseItem); + if (id != 0) { + for (auto& g : m_groups) { + if (id == g.GroupID) { + out = g.header; + return true; + } + } + } + return false; + } + }; +} + +HWND CListControl_ReplaceListView(HWND wndReplace) { + CListViewCtrl src(wndReplace); + const auto style = src.GetStyle(); + HWND ret = NULL; + if (style & LVS_REPORT) { + const auto ctrlID = src.GetDlgCtrlID(); + CWindow parent = src.GetParent(); + DWORD headerStyle = 0; + if ((style & LVS_NOCOLUMNHEADER) == 0) { + auto header = src.GetHeader(); + if (header) { + headerStyle = header.GetStyle(); + } + } + if (style & LVS_OWNERDATA) { + auto obj = PP::newWindowObj(style); + ret = obj->CreateInDialog(parent, ctrlID, src); + PFC_ASSERT(ret != NULL); + if (headerStyle != 0 && obj->GetHeaderCtrl() == NULL) { + obj->InitializeHeaderCtrl((headerStyle&(HDS_FULLDRAG | HDS_BUTTONS))); + } + } else { + PFC_ASSERT(src.GetItemCount() == 0); // transferring of items not yet implemented + auto obj = PP::newWindowObj(style); + ret = obj->CreateInDialog(parent, ctrlID, src); + PFC_ASSERT(ret != NULL); + if (headerStyle != 0 && obj->GetHeaderCtrl() == NULL) { + obj->InitializeHeaderCtrl((headerStyle & (HDS_FULLDRAG | HDS_BUTTONS))); + } + } + } + return ret; +} + +namespace { + // FIX ME WM_DELETEITEM + + class CListControl_ListBoxBase : public CListControlReadOnly { + protected: + const DWORD m_style; + public: + CListControl_ListBoxBase(DWORD style) : m_style(style) { + + // owner data not implemented + PFC_ASSERT((m_style & LBS_NODATA) == 0); + + if (m_style & LBS_NOSEL) { + this->SetSelectionModeNone(); + } else if (m_style & LBS_MULTIPLESEL) { + this->SetSelectionModeMulti(); + } else { + this->SetSelectionModeSingle(); + } + } + + BEGIN_MSG_MAP_EX(CListControl_ListBoxBase) + MSG_WM_SETFOCUS(OnSetFocus) + MSG_WM_KILLFOCUS(OnKillFocus) + MESSAGE_HANDLER_EX(LB_SETCURSEL, OnSetCurSel) + MESSAGE_HANDLER_EX(LB_GETCURSEL, OnGetCurSel) + MESSAGE_HANDLER_EX(LB_GETITEMRECT, OnGetItemRect) + MESSAGE_HANDLER_EX(LB_SELECTSTRING, OnSelectString) + MESSAGE_HANDLER_EX(LB_ITEMFROMPOINT, OnItemFromPoint) + MESSAGE_HANDLER_EX(LB_GETSEL, OnGetSel) + MESSAGE_HANDLER_EX(LB_SETSEL, OnSetSel) + MESSAGE_HANDLER_EX(LB_GETSELCOUNT, OnGetSelCount) + MESSAGE_HANDLER_EX(LB_GETSELITEMS, OnGetSelItems) + MESSAGE_HANDLER_EX(LB_SETCARETINDEX, OnSetCaretIndex) + MESSAGE_HANDLER_EX(LB_GETCARETINDEX, OnGetCaretIndex) + MSG_WM_CREATE(OnCreate) + CHAIN_MSG_MAP(CListControlReadOnly) + END_MSG_MAP() + + LRESULT OnCreate(LPCREATESTRUCT) { + SetMsgHandled(FALSE); + // Adopt style flags of the original control to keep various ATL checks happy + DWORD style = GetStyle(); + style = (style & 0xFFFF0000) | (m_style & 0xFFFF); + SetWindowLong(GWL_STYLE, style); + return 0; + } + void notifyParent(WORD code) { + if (m_style & LBS_NOTIFY) { + GetParent().PostMessage(WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(), code), (LPARAM)m_hWnd); + } + } + LRESULT OnGetCurSel(UINT, WPARAM, LPARAM) { + return (LRESULT)this->GetSingleSel(); + } + LRESULT OnSetCurSel(UINT, WPARAM wp, LPARAM) { + this->SelectSingle((size_t)wp); + return LB_OKAY; + } + LRESULT OnGetItemRect(UINT, WPARAM wp, LPARAM lp) { + size_t idx = (size_t)wp; + if (idx < this->GetItemCount()) { + *reinterpret_cast(lp) = this->GetItemRect(idx); + return LB_OKAY; + } else { + return LB_ERR; + } + } + LRESULT OnSelectString(UINT, WPARAM wp, LPARAM lp) { + auto idx = this->SendMessage(LB_FINDSTRING, wp, lp); + if (idx != LB_ERR) this->SelectSingle((size_t)idx); + return idx; + } + LRESULT OnItemFromPoint(UINT, WPARAM, LPARAM lp) { + CPoint pt(lp); + size_t ret; + if (!this->ItemFromPoint(pt, ret)) return LB_ERR; + return (LRESULT)ret; + } + LRESULT OnGetSel(UINT, WPARAM wp, LPARAM) { + size_t idx = (size_t)wp; + if (idx < this->GetItemCount()) { + return this->IsItemSelected(idx) ? 1 : 0; + } else { + return LB_ERR; + } + + } + LRESULT OnSetSel(UINT, WPARAM wp, LPARAM lp) { + // Contrary to the other methods, index comes in LPARAM + if (lp < 0) { + if (wp) this->SelectAll(); + else this->SelectNone(); + } else { + this->SetSelection(pfc::bit_array_one((size_t)lp), pfc::bit_array_val(wp != 0)); + } + return LB_OKAY; + } + LRESULT OnGetSelItems(UINT, WPARAM wp, LPARAM lp) { + int* out = reinterpret_cast(lp); + size_t outSize = (size_t)wp; + size_t outWalk = 0; + const size_t total = this->GetItemCount(); + for (size_t walk = 0; walk < total && outWalk < outSize; ++walk) { + if (this->IsItemSelected(walk)) { + out[outWalk++] = (int)walk; + } + } + return outWalk; + } + LRESULT OnGetSelCount(UINT, WPARAM, LPARAM) { + return (LRESULT)this->GetSelectedCount(); + } + LRESULT OnGetCaretIndex(UINT, WPARAM, LPARAM) { + size_t focus = this->GetFocusItem(); + if (focus == SIZE_MAX) return LB_ERR; + return (LRESULT)focus; + } + LRESULT OnSetCaretIndex(UINT, WPARAM wp, LPARAM) { + size_t idx = (size_t)wp; + if (idx < this->GetItemCount()) { + this->SetFocusItem(idx); return LB_OKAY; + } else { + return LB_ERR; + } + } + + void OnSetFocus(HWND) { + notifyParent(LBN_SETFOCUS); + SetMsgHandled(FALSE); + } + void OnKillFocus(HWND) { + notifyParent(LBN_KILLFOCUS); + SetMsgHandled(FALSE); + } + + void OnSelectionChanged(pfc::bit_array const& affected, pfc::bit_array const& status) override { + __super::OnSelectionChanged(affected, status); + notifyParent(LBN_SELCHANGE); + } + void ExecuteDefaultAction(size_t idx) override { + notifyParent(LBN_DBLCLK); + } + + void RequestReorder(size_t const* order, size_t count) override {} + void RequestRemoveSelection() override {} + }; + class CListControl_ListBox : public CListControl_ListBoxBase { + public: + CListControl_ListBox(DWORD style) : CListControl_ListBoxBase(style) {} + + BEGIN_MSG_MAP_EX(CListControl_ListBox) + MESSAGE_HANDLER_EX(LB_INSERTSTRING, OnInsertString) + MESSAGE_HANDLER_EX(LB_ADDSTRING, OnAddString) + MESSAGE_HANDLER_EX(LB_RESETCONTENT, OnResetContent) + MESSAGE_HANDLER_EX(LB_DELETESTRING, OnDeleteString) + MESSAGE_HANDLER_EX(LB_SETITEMDATA, OnSetItemData) + MESSAGE_HANDLER_EX(LB_GETITEMDATA, OnGetItemData) + MESSAGE_HANDLER_EX(LB_GETCOUNT, OnGetCount) + MESSAGE_HANDLER_EX(LB_FINDSTRING, OnFindString) + MESSAGE_HANDLER_EX(LB_FINDSTRINGEXACT, OnFindStringExact) + MESSAGE_HANDLER_EX(LB_SETCOUNT, OnSetCount) + MESSAGE_HANDLER_EX(LB_INITSTORAGE, OnInitStorage) + MESSAGE_HANDLER_EX(LB_GETTEXT, OnGetText) + MESSAGE_HANDLER_EX(LB_GETTEXTLEN, OnGetTextLen) + CHAIN_MSG_MAP(CListControl_ListBoxBase) + END_MSG_MAP() + + struct rec_t { + pfc::string8 text; + LPARAM data = 0; + }; + + std::vector m_content; + t_size GetItemCount() const override { + return m_content.size(); + } + + bool isForceSorted() const { + return (m_style & LBS_SORT) != 0; + } + size_t AddStringSorted(pfc::string8 && str) { + size_t ret = 0; + // FIX ME bsearch?? + // even with bsearch it's still O(n) so it's pointless + while (ret < m_content.size() && pfc::stricmp_ascii(str, m_content[ret].text) > 0) ++ret; + + m_content.insert(m_content.begin() + ret, { std::move(str) }); + + this->OnItemsInserted(ret, 1, false); + return ret; + } + static pfc::string8 importString(LPARAM lp) { + return pfc::utf8FromWide(reinterpret_cast(lp)); + } + LRESULT OnInsertString(UINT, WPARAM wp, LPARAM lp) { + auto str = importString(lp); + if (isForceSorted()) return AddStringSorted(std::move(str)); + size_t at = wp; + if (at > m_content.size()) at = m_content.size(); + m_content.insert(m_content.begin() + at, { std::move(str) }); + this->OnItemsInserted(at, 1, false); + return at; + } + LRESULT OnAddString(UINT, WPARAM wp, LPARAM lp) { + auto str = importString(lp); + if (isForceSorted()) return AddStringSorted(std::move(str)); + size_t ret = m_content.size(); + m_content.push_back({ std::move(str) }); + this->OnItemsInserted(ret, 1, false); + return ret; + } + LRESULT OnResetContent(UINT, WPARAM, LPARAM) { + size_t oldCount = m_content.size(); + if (oldCount > 0) { + m_content.clear(); + this->OnItemsRemoved(pfc::bit_array_true(), oldCount); + } + return LB_OKAY; + } + LRESULT OnDeleteString(UINT, WPARAM wp, LPARAM) { + size_t idx = (size_t) wp; + if (idx < m_content.size()) { + m_content.erase(m_content.begin() + idx); + this->OnItemRemoved(idx); + return m_content.size(); + } else { + return LB_ERR; + } + } + + LRESULT OnSetItemData(UINT, WPARAM wp, LPARAM lp) { + size_t idx = (size_t)wp; + if (idx < m_content.size()) { + m_content[idx].data = (size_t)lp; + return LB_OKAY; + } else { + return LB_ERR; + } + } + LRESULT OnGetItemData(UINT, WPARAM wp, LPARAM lp) { + size_t idx = (size_t)wp; + if (idx < m_content.size()) { + return (LRESULT)m_content[idx].data; + } else { + return LB_ERR; + } + } + LRESULT OnGetCount(UINT, WPARAM, LPARAM) { + return (LRESULT)m_content.size(); + } + LRESULT OnFindString(UINT, WPARAM wp, LPARAM lp) { + auto str = importString(lp); + const auto total = m_content.size(); + size_t first = (size_t)(wp + 1) % total; + for (size_t walk = 0; walk < total; ++walk) { + size_t at = (first + walk) % total; + if (pfc::string_has_prefix_i(m_content[at].text, str)) return (LRESULT)at; + } + return LB_ERR; + } + LRESULT OnFindStringExact(UINT, WPARAM wp, LPARAM lp) { + auto str = importString(lp); + const auto total = m_content.size(); + size_t first = (size_t)(wp + 1) % total; + for (size_t walk = 0; walk < total; ++walk) { + size_t at = (first + walk) % total; + if (pfc::stringEqualsI_utf8(m_content[at].text, str)) return (LRESULT)at; + } + return LB_ERR; + } + + LRESULT OnSetCount(UINT, WPARAM wp, LPARAM) { + m_content.resize((size_t)wp); + ReloadData(); + return LB_OKAY; + } + LRESULT OnInitStorage(UINT, WPARAM wp, LPARAM) { + m_content.reserve(m_content.size() + (size_t)wp); + return LB_OKAY; + } + + LRESULT OnGetText(UINT, WPARAM wp, LPARAM lp) { + size_t idx = (size_t)wp; + if (idx < m_content.size()) { + auto out = reinterpret_cast(lp); + wcscpy(out, pfc::wideFromUTF8(m_content[idx].text.c_str()).c_str()); + return LB_OKAY; + } else { + return LB_ERR; + } + } + LRESULT OnGetTextLen(UINT, WPARAM wp, LPARAM) { + size_t idx = (size_t)wp; + if (idx < m_content.size()) { + return pfc::wideFromUTF8(m_content[idx].text.c_str()).length(); + } else { + return LB_ERR; + } + } + + bool GetSubItemText(size_t item, size_t subItem, pfc::string_base& out) const override { + PFC_ASSERT(subItem == 0); (void)subItem; + PFC_ASSERT(item < m_content.size()); + out = m_content[item].text; + return true; + } + }; +} + +HWND CListControl_ReplaceListBox(HWND wndReplace) { + CListBox src(wndReplace); + const auto style = src.GetStyle(); + HWND ret = NULL; + if ((style & LBS_NODATA) == 0) { + PFC_ASSERT(src.GetCount() == 0); // transferring of items not yet implemented + const auto ctrlID = src.GetDlgCtrlID(); + CWindow parent = src.GetParent(); + auto obj = PP::newWindowObj(style); + ret = obj->CreateInDialog(parent, ctrlID, src); + } + return ret; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/CListControl-Subst.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/CListControl-Subst.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,4 @@ +#pragma once + +HWND CListControl_ReplaceListView(HWND); +HWND CListControl_ReplaceListBox(HWND); \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/CListControl.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/CListControl.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,1513 @@ +#include "stdafx.h" +#include "CListControl.h" +#include "PaintUtils.h" +#include "CListControlUserOptions.h" +#include "GDIUtils.h" +#include "DarkMode.h" + +#define PrepLayoutCache_Debug 0 +#define Scroll_Debug 0 + +#if Scroll_Debug +#define Scroll_Debug_Print(...) PFC_DEBUG_PRINT_FORCED(__VA_ARGS__) +#else +#define Scroll_Debug_Print(...) +#endif + +CListControlUserOptions * CListControlUserOptions::instance = nullptr; + +CRect CListControlImpl::GetClientRectHook() const { + CRect temp; + if ( m_hWnd == NULL || !GetClientRect(temp)) temp.SetRectEmpty(); + return temp; +} + +bool CListControlImpl::UserEnabledSmoothScroll() const { + auto i = CListControlUserOptions::instance; + if ( i != nullptr ) return i->useSmoothScroll(); + return false; +} + +LRESULT CListControlImpl::SetFocusPassThru(UINT,WPARAM,LPARAM,BOOL& bHandled) { + SetFocus(); + bHandled = FALSE; + return 0; +} + +void CListControlImpl::EnsureVisibleRectAbs(const CRect & p_rect) { + const CRect rcView = GetVisibleRectAbs(); + const CRect rcItem = p_rect; + int deltaX = 0, deltaY = 0; + + const bool centerOnItem = m_ensureVisibleUser; + + if (rcItem.top < rcView.top || rcItem.bottom > rcView.bottom) { + if (rcItem.Height() > rcView.Height()) { + deltaY = rcItem.top - rcView.top; + } else { + if (centerOnItem) { + deltaY = rcItem.CenterPoint().y - rcView.CenterPoint().y; + } else { + if (rcItem.bottom > rcView.bottom) deltaY = rcItem.bottom - rcView.bottom; + else deltaY = rcItem.top - rcView.top; + + } + } + } + if (rcItem.left < rcView.left || rcItem.right > rcView.right) { + if (rcItem.Width() > rcView.Width()) { + if (rcItem.left > rcView.left || rcItem.right < rcView.right) deltaX = rcItem.left - rcView.left; + } else { + if (centerOnItem) { + deltaX = rcItem.CenterPoint().x - rcView.CenterPoint().x; + } else { + if (rcItem.right > rcView.right) deltaX = rcItem.right - rcView.right; + else deltaX = rcItem.left - rcView.left; + } + } + } + + if (deltaX != 0 || deltaY != 0) { + MoveViewOriginDelta(CPoint(deltaX,deltaY)); + } +} +void CListControlImpl::EnsureItemVisible(t_size p_item, bool bUser) { + m_ensureVisibleUser = bUser; + PFC_ASSERT(p_item < GetItemCount()); + if (this->PrepLayoutCache(m_viewOrigin, p_item, p_item+1 )) { + RefreshSliders(); Invalidate(); + } + EnsureVisibleRectAbs(GetItemRectAbs(p_item)); + m_ensureVisibleUser = false; +} +void CListControlImpl::EnsureHeaderVisible2(size_t atItem) { + CRect rect; + if (GetGroupHeaderRectAbs2(atItem,rect)) EnsureVisibleRectAbs(rect); +} + +void CListControlImpl::RefreshSlider(bool p_vertical) { + const CRect viewArea = GetViewAreaRectAbs(); + const CRect rcVisible = GetVisibleRectAbs(); + SCROLLINFO si = {}; + si.cbSize = sizeof(si); + si.fMask = SIF_PAGE|SIF_RANGE|SIF_POS; + + + if (AllowScrollbar(p_vertical)) { + if (p_vertical) { + si.nPage = rcVisible.Height(); + si.nMin = viewArea.top; + si.nMax = viewArea.bottom - 1; + si.nPos = rcVisible.top; + } else { + si.nPage = rcVisible.Width(); + si.nMin = viewArea.left; + si.nMax = viewArea.right - 1; + si.nPos = rcVisible.left; + } + } + + Scroll_Debug_Print("RefreshSlider vertical=", p_vertical, ", nPage=", si.nPage, ", nMin=", si.nMin, ", nMax=", si.nMax, ", nPos=", si.nPos); + + SetScrollInfo(p_vertical ? SB_VERT : SB_HORZ, &si); +} + +void CListControlImpl::RefreshSliders() { + //PROBLEM: while lots of data can be reused across those, it has to be recalculated inbetween because view area etc may change when scroll info changes + RefreshSlider(false); RefreshSlider(true); +} + +int CListControlImpl::GetScrollThumbPos(int which) { + SCROLLINFO si = {}; + si.cbSize = sizeof(si); + si.fMask = SIF_TRACKPOS; + WIN32_OP_D( GetScrollInfo(which,&si) ); + return si.nTrackPos; +} + +bool CListControlImpl::ResolveGroupRangeCached(size_t itemInGroup, size_t& outBegin, size_t& outEnd) const { + auto end = this->m_groupHeaders.upper_bound(itemInGroup); + if (end == this->m_groupHeaders.begin()) return false; + auto begin = end; --begin; + outBegin = *begin; + if (end == this->m_groupHeaders.end()) outEnd = this->GetItemCount(); + else outEnd = *end; + return true; +} + +size_t CListControlImpl::ResolveGroupRange2(t_size p_base) const { + const auto id = this->GetItemGroup(p_base); + const size_t count = this->GetItemCount(); + size_t walk = p_base + 1; + while (walk < count && GetItemGroup(walk) == id) ++walk; + return walk - p_base; +} + + +static int HandleScroll(WORD p_code,int p_offset,int p_page, int p_line, int p_bottom, int p_thumbpos) { + switch(p_code) { + case SB_LINEUP: + return p_offset - p_line; + case SB_LINEDOWN: + return p_offset + p_line; + case SB_BOTTOM: + return p_bottom - p_page; + case SB_TOP: + return 0; + case SB_PAGEUP: + return p_offset - p_page; + case SB_PAGEDOWN: + return p_offset + p_page; + case SB_THUMBPOSITION: + return p_thumbpos; + case SB_THUMBTRACK: + return p_thumbpos; + default: + return p_offset; + } +} + +static CPoint ClipPointToRect(CPoint const & p_pt,CRect const & p_rect) { + return CPoint(pfc::clip_t(p_pt.x,p_rect.left,p_rect.right),pfc::clip_t(p_pt.y,p_rect.top,p_rect.bottom)); +} + +void CListControlImpl::MoveViewOriginNoClip(CPoint p_target) { + UpdateWindow(); + PrepLayoutCache(p_target); + const CPoint old = m_viewOrigin; + m_viewOrigin = p_target; + + if (m_viewOrigin != old) { +#if PrepLayoutCache_Debug + PFC_DEBUGLOG << "MoveViewOriginNoClip: m_viewOrigin=" << m_viewOrigin.x << "," << m_viewOrigin.y; +#endif + + if (m_viewOrigin.x != old.x) SetScrollPos(SB_HORZ,m_viewOrigin.x); + if (m_viewOrigin.y != old.y) SetScrollPos(SB_VERT,m_viewOrigin.y); + + const CPoint delta = old - m_viewOrigin; + if (FixedOverlayPresent()) Invalidate(); + else { + DWORD flags = SW_INVALIDATE | SW_ERASE; + const DWORD smoothScrollMS = 50; + if (this->UserEnabledSmoothScroll() && this->CanSmoothScroll()) { + flags |= SW_SMOOTHSCROLL | (smoothScrollMS << 16); + } + + ScrollWindowEx(delta.x,delta.y,GetClientRectHook(),NULL,0,0,flags ); + } + + OnViewOriginChange(m_viewOrigin - old); + } +} + +CPoint CListControlImpl::ClipViewOrigin(CPoint p_origin) const { + return ClipPointToRect(p_origin,GetValidViewOriginArea()); +} +void CListControlImpl::MoveViewOrigin(CPoint p_target) { + PrepLayoutCache(p_target); + MoveViewOriginNoClip(ClipViewOrigin(p_target)); +} + +#ifndef SPI_GETWHEELSCROLLCHARS +#define SPI_GETWHEELSCROLLCHARS 0x006C +#endif +int CListControlImpl::HandleWheel(int & p_accum,int p_delta, bool bHoriz) { + if ( m_suppressMouseWheel ) return 0; + UINT scrollLines = 1; + SystemParametersInfo(bHoriz ? SPI_GETWHEELSCROLLCHARS : SPI_GETWHEELSCROLLLINES,0,&scrollLines,0); + if (scrollLines == ~0) { + p_accum = 0; + int rv = -pfc::sgn_t(p_delta); + CRect client = GetClientRectHook(); + if (bHoriz) rv *= client.Width(); + else rv *= client.Height(); + return rv; + } + + const int itemHeight = GetItemHeight(); + const int extraScale = 10000; + + p_accum += p_delta * extraScale; + if ((int)scrollLines < 1) scrollLines = 1; + int multiplier = (WHEEL_DELTA * extraScale) / (scrollLines * itemHeight); + if (multiplier<1) multiplier = 1; + + int delta = pfc::rint32( (double) p_accum / (double) multiplier ); + p_accum -= delta * multiplier; + return -delta; + + /* + if (p_accum<=-multiplier || p_accum>=multiplier) { + int direction; + int ov = p_accum; + if (ov<0) { + direction = -1; + ov = -ov; + p_accum = - ((-p_accum)%multiplier); + } else { + p_accum %= multiplier; + direction = 1; + } + + return - (direction * (ov + multiplier - 1) ) / multiplier; + } else { + return 0; + } + */ +} + +LRESULT CListControlImpl::OnVWheel(UINT,WPARAM p_wp,LPARAM,BOOL&) { + const CRect client = GetClientRectHook(), view = this->GetViewAreaRectAbs(); + int deltaPixels = HandleWheel(m_wheelAccumY,(short)HIWORD(p_wp), false); + + const bool canVScroll = client.Height() < view.Height(); + const bool canHScroll = client.Width() < view.Width(); + + CPoint ptDelta; + if ( canVScroll && canHScroll && GetHotkeyModifierFlags() == MOD_SHIFT) { + ptDelta = CPoint(deltaPixels, 0); // default to horizontal scroll if shift is pressed + } else if (canVScroll) { + ptDelta = CPoint(0,deltaPixels); + } else if (canHScroll) { + ptDelta = CPoint(deltaPixels,0); + } + + if ( ptDelta != CPoint(0,0) ) { + MoveViewOriginDelta(ptDelta); + } + return 0; +} +LRESULT CListControlImpl::OnHWheel(UINT,WPARAM p_wp,LPARAM,BOOL&) { + // const CRect client = GetClientRectHook(); + int deltaPixels = HandleWheel(m_wheelAccumX,(short)HIWORD(p_wp), true); + MoveViewOriginDelta(CPoint(-deltaPixels,0)); + return 0; +} + +// WM_VSCROLL special fix +// We must expect SCROLLINFO to go out of sync with layout, due to group partitioning happening as the user scrolls +// SetScrollInfo() is apparently disregarded while the user is scrolling, causing nonsensical behavior if we live update it as we discover new groups +// When handling input, we must take the position as % of the set scrollbar range and map it to our coordinates - even though it is mappable directly if no groups etc are in use +LRESULT CListControlImpl::OnVScroll(UINT,WPARAM p_wp,LPARAM,BOOL&) { + SCROLLINFO si = {}; + si.cbSize = sizeof(si); + si.fMask = SIF_ALL; + WIN32_OP_D(GetScrollInfo(SB_VERT, &si)); + int thumb = si.nTrackPos; // HIWORD(p_wp); + auto bottom = GetViewAreaRectAbs().bottom; + auto visible = GetVisibleHeight(); + + if (si.nMax < si.nMin) return 0; + double p = (double)(thumb - si.nMin) / (double)(si.nMax + 1 - si.nMin); + thumb = pfc::rint32(p * bottom); + int target = HandleScroll(LOWORD(p_wp), m_viewOrigin.y, visible, GetItemHeight(), bottom, thumb); + + Scroll_Debug_Print("OnVScroll thumb=", thumb, ", target=", target, ", bottom=", bottom, ", visible=", visible, ", p=", p); + + MoveViewOrigin(CPoint(m_viewOrigin.x, target)); + + return 0; +} + +// ====== Logitech scroll bug explanation ====== +// With Logitech wheel hscroll, we must use WPARAM position, not GetScrollInfo() value. +// However this is wrong, we'll get nonsense if scroll range doesn't fit in 16-bit! +// As a workaround, we use GetScrollInfo() value for vscroll (good) +// and workaround Logitech bug by using WPARAM position with hscroll (practically impossible to overflow) +LRESULT CListControlImpl::OnHScroll(UINT,WPARAM p_wp,LPARAM,BOOL&) { + int thumb = HIWORD(p_wp); + const auto fullWidth = GetViewAreaWidth(); + if (fullWidth > INT16_MAX) { // Possible overflow or near-overflow? Drop Logitech stupidity mitigation + thumb = GetScrollThumbPos(SB_HORZ); + } + int target = HandleScroll(LOWORD(p_wp), m_viewOrigin.x, GetVisibleRectAbs().Width(), GetItemHeight() /*fixme*/, fullWidth, thumb); + Scroll_Debug_Print("OnHScroll thumb=", thumb, ", target=", target); + MoveViewOrigin(CPoint(target,m_viewOrigin.y)); + return 0; +} + +LRESULT CListControlImpl::OnGesture(UINT,WPARAM,LPARAM lParam,BOOL& bHandled) { + if (!this->m_gestureAPI.IsAvailable()) { + bHandled = FALSE; + return 0; + } + HGESTUREINFO hGesture = (HGESTUREINFO) lParam; + GESTUREINFO gestureInfo = {sizeof(gestureInfo)}; + if (m_gestureAPI.GetGestureInfo(hGesture, &gestureInfo)) { + //console::formatter() << "WM_GESTURE " << pfc::format_hex( gestureInfo.dwFlags ) << " " << (int)gestureInfo.dwID << " X:" << gestureInfo.ptsLocation.x << " Y:" << gestureInfo.ptsLocation.y << " arg:" << (__int64) gestureInfo.ullArguments; + CPoint pt( gestureInfo.ptsLocation.x, gestureInfo.ptsLocation.y ); + switch(gestureInfo.dwID) { + case GID_BEGIN: + m_gesturePoint = pt; + break; + case GID_END: + break; + case GID_PAN: + MoveViewOriginDelta( this->m_gesturePoint - pt); + m_gesturePoint = pt; + break; + } + } + + m_gestureAPI.CloseGestureInfoHandle(hGesture); + bHandled = TRUE; + return 0; +} + +LRESULT CListControlImpl::OnSize(UINT,WPARAM,LPARAM,BOOL&) { + this->PrepLayoutCache(m_viewOrigin); + OnSizeAsync_Trigger(); + RefreshSliders(); + return 0; +} + + +void CListControlImpl::RenderBackground( CDCHandle dc, CRect const & rc ) { + PaintUtils::FillRectSimple(dc,rc,GetSysColorHook(colorBackground)); +} + +void CListControlImpl::PaintContent(CRect rcPaint, HDC dc) { + CDCHandle renderDC(dc); + + CMemoryDC bufferDC(renderDC,rcPaint); + renderDC = bufferDC; + this->RenderBackground(renderDC, rcPaint); + + RenderRect(rcPaint, renderDC); +} + +void CListControlImpl::OnPrintClient(HDC dc, UINT) { + CRect rcClient; this->GetClientRect( rcClient ); + PaintContent( rcClient, dc ); +} + +void CListControlImpl::OnPaint(CDCHandle target) { + auto toggle = pfc::autoToggle(m_paintInProgress, true); + if (target) { + CRect rcClient; this->GetClientRect(rcClient); + PaintContent(rcClient, target); + } else { + CPaintDC paintDC(*this); + PaintContent(paintDC.m_ps.rcPaint, paintDC.m_hDC); + } +} + +bool CListControlImpl::GetItemRange(const CRect & p_rect,t_size & p_base,t_size & p_count) const { + return GetItemRangeAbs(this->RectClientToAbs(p_rect), p_base, p_count); +} + + + +bool CListControlImpl::GetItemRangeAbsInclHeaders(const CRect & p_rect,t_size & p_base,t_size & p_count) const { + CRect temp(p_rect); + temp.bottom += this->GetGroupHeaderHeight(); + return GetItemRangeAbs(temp, p_base, p_count); +} + +bool CListControlImpl::GetItemRangeAbs(const CRect & p_rect,t_size & p_base,t_size & p_count) const { + const size_t count = GetItemCount(); + if (p_rect.right < 0 || p_rect.left >= GetItemWidth() || count == 0) return false; + + size_t top = IndexFromPointAbs(CPoint(0, p_rect.top)); + size_t bottom = IndexFromPointAbs(CPoint(0, p_rect.bottom)); + if (top == SIZE_MAX) return false; + if (bottom > count-1) bottom = count - 1; + p_base = top; + p_count = bottom - top + 1; + PFC_ASSERT(p_base + p_count <= count); + return true; +} + +void CListControlImpl::RenderRect(const CRect & p_rect,CDCHandle p_dc) { + t_size base, count; + if (GetItemRange(p_rect,base,count)) { + for(t_size walk = 0; walk < count; ++walk) { + size_t atItem = base + walk; + if (m_groupHeaders.count(atItem) > 0) { + CRect rcHeader, rcUpdate; + if (GetGroupHeaderRectAbs2(atItem, rcHeader) ) { + rcHeader = RectAbsToClient(rcHeader); + if (rcUpdate.IntersectRect(rcHeader, p_rect)) { + DCStateScope dcState(p_dc); + if (p_dc.IntersectClipRect(rcUpdate) != NULLREGION) { + try { + RenderGroupHeader2(atItem, rcHeader, rcUpdate, p_dc); + } catch (...) { + PFC_ASSERT(!"Should not get here"); + } + } + } + } + } + + CRect rcUpdate, rcItem = GetItemRect(atItem); + if (rcUpdate.IntersectRect(rcItem,p_rect)) { + DCStateScope dcState(p_dc); + if (p_dc.IntersectClipRect(rcUpdate) != NULLREGION) { + try { + RenderItem(atItem,rcItem,rcUpdate,p_dc); + } catch(...) { + PFC_ASSERT(!"Should not get here"); + } + } + } + } + + if ( this->m_groupHeaders.size() > 0 ) { + auto iter = m_groupHeaders.upper_bound(base); + if (iter != m_groupHeaders.begin()) { + --iter; + while ( iter != m_groupHeaders.end() && *iter < base + count) { + auto iter2 = iter; ++iter2; + + size_t begin = *iter; + size_t end; + if (iter2 == m_groupHeaders.end()) end = this->GetItemCount(); + else end = *iter2; + + CRect rc; + rc.top = this->GetItemOffsetAbs(begin); + rc.bottom = this->GetItemBottomOffsetAbs(end-1); + rc.left = 0; + rc.right = this->GetItemWidth(); + rc = this->RectAbsToClient(rc); + CRect rcUpdate; + if (rcUpdate.IntersectRect(rc, p_rect)) { + DCStateScope dcState(p_dc); + if (p_dc.IntersectClipRect(rcUpdate) != NULLREGION) { + try { + this->RenderGroupOverlay(begin, rc, rcUpdate, p_dc); + } catch (...) { + PFC_ASSERT(!"Should not get here"); + } + } + } + + + iter = iter2; + } + } + } + } + + RenderOverlay2(p_rect,p_dc); +} + +bool CListControlImpl::GetGroupOverlayRectAbs(size_t atItem, CRect& outRect) { + auto iter = m_groupHeaders.upper_bound(atItem); + if (iter == m_groupHeaders.begin()) return false; + auto iter2 = iter; --iter; + + size_t begin = *iter; + size_t end; + if (iter2 == m_groupHeaders.end()) end = this->GetItemCount(); + else end = *iter2; + + CRect rc; + + rc.top = this->GetItemOffsetAbs(begin); + rc.bottom = this->GetItemBottomOffsetAbs(end - 1); + rc.left = 0; + rc.right = this->GetItemWidth(); + + outRect = rc; + return true; +} + +void CListControlImpl::MinGroupHeight2ChangedForGroup(groupID_t groupID, bool reloadWhole) { + for (auto iter = m_groupHeaders.begin(); iter != m_groupHeaders.end(); ++iter) { + if (groupID == GetItemGroup(*iter)) { + this->MinGroupHeight2Changed(*iter, reloadWhole); + } + } +} + +void CListControlImpl::UpdateGroupOverlayByID(groupID_t groupID, int xFrom, int xTo) { + t_size base, count; + if (GetItemRangeAbs(GetVisibleRectAbs(), base, count)) { + bool on = false; // Have to walk whole range - there may be multiple groups with the same ID + for (size_t walk = 0; walk < count; ++walk) { + bool test = (groupID == GetItemGroup(base + walk)); + if (test && !on) { + CRect rc; + if (GetGroupOverlayRectAbs(base + walk, rc)) { + if (xFrom < xTo) { + rc.left = xFrom; rc.right = xTo; + } + this->InvalidateRect(this->RectAbsToClient(rc)); + } + } + + on = test; + } + } +} + +CRect CListControlImpl::GetItemRect(t_size p_item) const { + return this->RectAbsToClient(GetItemRectAbs(p_item)); +} + +bool CListControlImpl::GetGroupHeaderRect2(size_t atItem,CRect & p_rect) const { + CRect temp; + if (!GetGroupHeaderRectAbs2(atItem,temp)) return false; + p_rect = RectAbsToClient(temp); + return true; +} + +size_t CListControlImpl::FindGroupBaseCached(size_t itemFor) const { + auto iter = m_groupHeaders.upper_bound(itemFor); + if (iter == m_groupHeaders.begin()) return 0; + --iter; + return *iter; +} + +size_t CListControlImpl::FindGroupBase(size_t itemFor) const { + return this->FindGroupBase(itemFor, this->GetItemGroup(itemFor)); +} + +size_t CListControlImpl::FindGroupBase(size_t itemFor, groupID_t id) const { + size_t walk = itemFor; + while (walk > 0) { + size_t prev = walk - 1; + if (this->GetItemGroup(prev) != id) break; + walk = prev; + } + return walk; +} + +bool CListControlImpl::PrepLayoutCache(CPoint& ptOrigin, size_t indexLo, size_t indexHi) { + const size_t count = GetItemCount(); + if (count == 0) return false; +#if PrepLayoutCache_Debug + PFC_DEBUGLOG << "PrepLayoutCache entry"; + PFC_DEBUGLOG << "PrepLayoutCache: count=" << count << " knownGroups=" << this->m_groupHeaders.size(); + PFC_DEBUGLOG << "PrepLayoutCache: indexLo=" << pfc::format_index(indexLo) << " indexHi=" << pfc::format_index(indexHi); +#endif + const int clientHeight = pfc::max_t(this->GetClientRectHook().Height(), 100); + + // Always walk 2*clientHeight, with area above and below + int yMax = -1, yBase = 0; + size_t baseItem = 0, endItem = SIZE_MAX; + + if (!m_greedyGroupLayout) { + if (indexLo == SIZE_MAX) { + yBase = pfc::max_t(ptOrigin.y - clientHeight / 2, 0); + yMax = yBase + clientHeight * 2; + baseItem = pfc::min_t(this->IndexFromPointAbs(yBase), count - 1); + } else { + auto itemHeight = GetItemHeight(); + size_t extraItems = (size_t)(clientHeight / itemHeight); +#if PrepLayoutCache_Debug + PFC_DEBUGLOG << "PrepLayoutCache: clientHeight=" << clientHeight << " itemHeight=" << itemHeight << " extraItems=" << extraItems; +#endif + if (indexLo < extraItems) baseItem = 0; + else baseItem = indexLo - extraItems; + + if (indexHi == SIZE_MAX) { + endItem = baseItem + extraItems; + } else { + endItem = indexHi + extraItems; + } + if (endItem > count) endItem = count; + +#if PrepLayoutCache_Debug + PFC_DEBUGLOG << "PrepLayoutCache: baseItem=" << baseItem << " endItem=" << endItem; +#endif + } + } + + + + + size_t item = baseItem; + { + const auto group = this->GetItemGroup(baseItem); + if (group != 0) { + size_t hdr = this->FindGroupBase(baseItem, group); + if (hdr < baseItem) { + item = hdr; + } + } + } + +#if PrepLayoutCache_Debug + if (yMax != -1) { + PFC_DEBUGLOG << "PrepLayoutCache: yBase=" << yBase << " yMax=" << yMax; + } + if (indexLo != SIZE_MAX) { + pfc::string_formatter msg; + msg << "PrepLayoutCache: indexLo=" << indexLo; + if (indexHi != SIZE_MAX) { + msg << " indexHi=" << indexHi; + } + pfc::outputDebugLine(msg); + } + PFC_DEBUGLOG << "PrepLayoutCache: baseItem=" << baseItem; +#endif + + size_t anchorIdx = m_greedyGroupLayout ? SIZE_MAX : this->IndexFromPointAbs(ptOrigin.y); + int anchorDelta = 0; + bool anchorIsFirstInGroup = IsItemFirstInGroupCached(anchorIdx); + if (anchorIdx != SIZE_MAX) { + anchorDelta = ptOrigin.y - GetItemOffsetAbs(anchorIdx); + } + +#if PrepLayoutCache_Debug + PFC_DEBUGLOG << "PrepLayoutCache: anchorIdx=" << pfc::format_index(anchorIdx) << " anchorDelta=" << anchorDelta << " anchorIsFirstInGroup=" << anchorIsFirstInGroup; +#endif + + bool bChanged = false; + int gh = -1; + int ih = -1; + int yWalk = yBase; + groupID_t prevGroup = 0; + if (item > 1) prevGroup = this->GetItemGroup(item - 1); + for (; item < count; ++item) { + int yDelta = 0; + auto group = this->GetItemGroup(item); + if (group != prevGroup) { + if (m_groupHeaders.insert(item).second) bChanged = true; + if (gh < 0) gh = GetGroupHeaderHeight(); + yDelta += gh; + } else { + if (m_groupHeaders.erase(item) > 0) bChanged = true; + } + prevGroup = group; + + auto iter = m_varItemHeights.find(item); + int varHeight = this->GetItemHeight2(item); + if (varHeight < 0) { + if (iter != m_varItemHeights.end()) { + m_varItemHeights.erase(iter); + bChanged = true; + } + if (ih < 0) ih = this->GetItemHeight(); + yDelta += ih; + } else { + if (iter == m_varItemHeights.end()) { + m_varItemHeights[item] = varHeight; + bChanged = true; + } else if ( iter->second != varHeight ) { + iter->second = varHeight; + bChanged = true; + } + + yDelta += varHeight; + } + + if (item >= endItem) { + break; + } + if (item >= baseItem && yMax != -1) { + yWalk += yDelta; + if (yWalk > yMax) break; + } + } + +#if PrepLayoutCache_Debug + PFC_DEBUGLOG << "PrepLayoutCache: bChanged=" << bChanged << " knownGroups=" << m_groupHeaders.size() << " knownVarHeights=" << m_varItemHeights.size(); +#endif + + if (bChanged) { + if (anchorIdx != SIZE_MAX) { + int fix = GetItemOffsetAbs(anchorIdx) + anchorDelta; + + // View would begin exactly with an item that became a first item in a group? + if (anchorDelta == 0 && !anchorIsFirstInGroup && IsItemFirstInGroupCached(anchorIdx)) { + if (gh < 0) gh = GetGroupHeaderHeight(); + fix -= gh; + } + +#if PrepLayoutCache_Debug + PFC_DEBUGLOG << "PrepLayoutCache: fixing origin: " << ptOrigin.y << " to " << fix; +#endif + + ptOrigin.y = fix; + if (&ptOrigin != &m_viewOrigin && m_hWnd != NULL) { +#if PrepLayoutCache_Debug + PFC_DEBUGLOG << "PrepLayoutCache: invalidating view"; +#endif + Invalidate(); + } + } + } + + if ( bChanged ) { + // DO NOT update sliders from here, causes mayhem, SetScrollInfo() in mid-scroll is not really handled + // this->RefreshSliders(); + } + return bChanged; +} + +int CListControlImpl::GetViewAreaHeight() const { + auto ret = GetItemOffsetAbs(GetItemCount()); + Scroll_Debug_Print("GetViewAreaHeight: " , ret); + return ret; +} + +int CListControlImpl::GetItemBottomOffsetAbs(size_t item) const { + return GetItemOffsetAbs(item) + GetItemHeightCached(item); +} + +int CListControlImpl::GetItemOffsetAbs2(size_t base, size_t item) const { + // Also valid with item == GetItemCount() + size_t varcount = 0; + int acc = 0; + const bool baseValid = (base != SIZE_MAX); + const size_t itemDelta = baseValid ? item - base : item; + for (auto iter = (baseValid ? m_varItemHeights.lower_bound(base) : m_varItemHeights.begin()); iter != m_varItemHeights.end(); ++iter){ + if (iter->first >= item) break; + if (iter->second > 0) acc += iter->second; + ++varcount; + } + if (varcount < itemDelta) { + acc += GetItemHeight() * (int)(itemDelta - varcount); + } + + int gh = -1; + for (auto iter = (baseValid ? m_groupHeaders.upper_bound(base) : m_groupHeaders.begin()); iter != m_groupHeaders.end(); ++iter){ + if (*iter > item) break; + if (gh < 0) gh = GetGroupHeaderHeight(); + acc += gh; + } + + return acc; +} + +int CListControlImpl::GetItemOffsetAbs(size_t item) const { + // Also valid with item == GetItemCount() + return GetItemOffsetAbs2(SIZE_MAX, item); +} + +int CListControlImpl::GetItemContentHeightCached(size_t item) const { + auto iter = m_varItemHeights.find(item); + if (iter == m_varItemHeights.end()) return GetItemHeight(); + else return this->GetItemHeight2Content( item, iter->second ); +} + +int CListControlImpl::GetItemHeightCached(size_t item) const { + auto iter = m_varItemHeights.find(item); + if (iter == m_varItemHeights.end()) return GetItemHeight(); + else return iter->second; +} + +CRect CListControlImpl::GetItemRectAbs(t_size p_item) const { + PFC_ASSERT(p_item < GetItemCount()); + // const int normalHeight = GetItemHeight(); + CRect rcItem; + rcItem.top = GetItemOffsetAbs(p_item); + rcItem.bottom = rcItem.top + GetItemContentHeightCached(p_item); + rcItem.left = 0; + rcItem.right = rcItem.left + GetItemWidth(); + return rcItem; +} + +bool CListControlImpl::GetGroupHeaderRectAbs2(size_t atItem,CRect & p_rect) const { + + if (m_groupHeaders.count(atItem) == 0) return false; + + p_rect.bottom = GetItemOffsetAbs(atItem); + p_rect.top = p_rect.bottom - GetGroupHeaderHeight(); + p_rect.left = 0; + p_rect.right = GetItemWidth(); + return true; +} + +CRect CListControlImpl::GetViewAreaRectAbs() const { + return CRect(0,0,GetViewAreaWidth(),GetViewAreaHeight()); +} + +CRect CListControlImpl::GetViewAreaRect() const { + CRect rc = GetViewAreaRectAbs(); + rc.OffsetRect( - GetViewOffset() ); + CRect ret; ret.IntersectRect(rc,GetClientRectHook()); + return ret; +} + +void CListControlImpl::UpdateGroupHeader2(size_t atItem) { + CRect rect; + if (GetGroupHeaderRect2(atItem,rect)) { + InvalidateRect(rect); + } +} +static void AddUpdateRect(HRGN p_rgn,CRect const & p_rect) { + CRgn temp; temp.CreateRectRgnIndirect(p_rect); + CRgnHandle(p_rgn).CombineRgn(temp,RGN_OR); +} + +void CListControlImpl::OnItemsReordered( const size_t * order, size_t count ) { + PFC_ASSERT(count == GetItemCount()); (void)count; + ReloadItems( pfc::bit_array_order_changed(order) ); +} +void CListControlImpl::UpdateItems(const pfc::bit_array & p_mask) { + t_size base,count; + if (GetItemRangeAbs(GetVisibleRectAbs(),base,count)) { + const t_size max = base+count; + CRgn updateRgn; updateRgn.CreateRectRgn(0,0,0,0); + bool found = false; + for(t_size walk = p_mask.find_first(true,base,max); walk < max; walk = p_mask.find_next(true,walk,max)) { + found = true; + AddUpdateRect(updateRgn,GetItemRect(walk)); + } + if (found) { + InvalidateRgn(updateRgn); + } + } +} + +std::pair CListControlImpl::GetVisibleRange() const { + const size_t total = GetItemCount(); + CRect rcVisible = this->GetVisibleRectAbs(); + size_t lo = this->IndexFromPointAbs(rcVisible.top); + PFC_ASSERT(lo != SIZE_MAX); + if (lo == SIZE_MAX) lo = 0; // should not happen + size_t hi = this->IndexFromPointAbs(rcVisible.bottom); + if (hi < total) ++hi; + else hi = total; + return { lo, hi }; +} + +bool CListControlImpl::IsItemVisible(size_t which) const { + CRect rcVisible = this->GetVisibleRectAbs(); + CRect rcItem = this->GetItemRectAbs(which); + return rcItem.top >= rcVisible.top && rcItem.bottom <= rcVisible.bottom; +} + +void CListControlImpl::UpdateItemsAndHeaders(const pfc::bit_array & p_mask) { + t_size base,count; + groupID_t groupWalk = 0; + if (GetItemRangeAbsInclHeaders(GetVisibleRectAbs(),base,count)) { + const t_size max = base+count; + CRgn updateRgn; updateRgn.CreateRectRgn(0,0,0,0); + bool found = false; + for(t_size walk = p_mask.find_first(true,base,max); walk < max; walk = p_mask.find_next(true,walk,max)) { + found = true; + const groupID_t groupId = GetItemGroup(walk); + if (groupId != groupWalk) { + CRect rect; + if (GetGroupHeaderRect2(walk,rect)) { + AddUpdateRect(updateRgn,rect); + } + groupWalk = groupId; + } + AddUpdateRect(updateRgn,GetItemRect(walk)); + } + if (found) { + InvalidateRgn(updateRgn); + } + } +} + + +CRect CListControlImpl::GetValidViewOriginArea() const { + const CRect rcView = GetViewAreaRectAbs(); + const CRect rcClient = GetClientRectHook(); + CRect rcArea = rcView; + rcArea.right -= pfc::min_t(rcView.Width(),rcClient.Width()); + rcArea.bottom -= pfc::min_t(rcView.Height(),rcClient.Height()); + return rcArea; +} + +void CListControlImpl::OnViewAreaChanged(CPoint p_originOverride) { + const CPoint oldViewOrigin = m_viewOrigin; + + PrepLayoutCache(p_originOverride); + + m_viewOrigin = ClipPointToRect(p_originOverride,GetValidViewOriginArea()); + + if (m_viewOrigin != p_originOverride) { + // Did clip from the requested? + PrepLayoutCache(m_viewOrigin); + } +#if PrepLayoutCache_Debug + PFC_DEBUGLOG << "OnViewAreaChanged: m_viewOrigin=" << m_viewOrigin.x << "," << m_viewOrigin.y; +#endif + + RefreshSliders(); + + Invalidate(); + + if (oldViewOrigin != m_viewOrigin) { + OnViewOriginChange(m_viewOrigin - oldViewOrigin); + } +} + +size_t CListControlImpl::IndexFromPointAbs(CPoint pt) const { + if (pt.x < 0 || pt.x >= GetItemWidth()) return SIZE_MAX; + return IndexFromPointAbs(pt.y); +} + +size_t CListControlImpl::IndexFromPointAbs(int ptY) const { + const size_t count = GetItemCount(); + if (count == 0) return SIZE_MAX; + + class wrapper { + public: + wrapper(const CListControlImpl & o) : owner(o) {} + int operator[] (size_t idx) const { + // Return LAST line of this item + return owner.GetItemBottomOffsetAbs(idx)-1; + } + const CListControlImpl & owner; + }; + + wrapper w(*this); + size_t result = SIZE_MAX; + pfc::binarySearch<>::run(w, 0, count, ptY, result); + PFC_ASSERT(result != SIZE_MAX); + return result; +} + +bool CListControlImpl::ItemFromPointAbs(CPoint const & p_pt,t_size & p_item) const { + size_t idx = IndexFromPointAbs(p_pt); + if (idx >= GetItemCount()) return false; + CRect rc = this->GetItemRectAbs(idx); + if (!rc.PtInRect(p_pt)) return false; + p_item = idx; + return true; +} + +size_t CListControlImpl::ItemFromPointAbs(CPoint const& p_pt) const { + size_t ret = SIZE_MAX; + ItemFromPointAbs(p_pt, ret); + return ret; +} + +bool CListControlImpl::GroupHeaderFromPointAbs2(CPoint const & p_pt,size_t & atItem) const { + size_t idx = IndexFromPointAbs(p_pt); + if (idx == SIZE_MAX) return false; + CRect rc; + if (!this->GetGroupHeaderRectAbs2(idx, rc)) return false; + if (!rc.PtInRect(p_pt)) return false; + atItem = idx; + return true; +} + +void CListControlImpl::OnThemeChanged() { + m_themeCache.remove_all(); +} + +CTheme & CListControlImpl::themeFor(const char * what) { + bool bNew; + auto & ret = this->m_themeCache.find_or_add_ex( what, bNew ); + if (bNew) ret.OpenThemeData(*this, pfc::stringcvt::string_wide_from_utf8(what)); + return ret; +} + +void CListControlImpl::SetDarkMode(bool v) { + if (m_darkMode != v) { + m_darkMode = v; + RefreshDarkMode(); + } +} + +void CListControlImpl::RefreshDarkMode() { + if (m_hWnd != NULL) { + Invalidate(); + + // GOD DAMNIT: Should use ItemsView, but only Explorer fixes scrollbars + DarkMode::ApplyDarkThemeCtrl(m_hWnd, m_darkMode, L"Explorer"); + } +} + +LRESULT CListControlImpl::OnCreatePassThru(UINT,WPARAM,LPARAM,BOOL& bHandled) { + + RefreshDarkMode(); + + + OnViewAreaChanged(); + + if (m_gestureAPI.IsAvailable()) { + GESTURECONFIG config = {GID_PAN, GC_PAN_WITH_SINGLE_FINGER_VERTICALLY|GC_PAN_WITH_INERTIA, GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY | GC_PAN_WITH_GUTTER}; + m_gestureAPI.SetGestureConfig( *this, 0, 1, &config, sizeof(GESTURECONFIG)); + } + + bHandled = FALSE; + return 0; +} +bool CListControlImpl::IsSameItemOrHeaderAbs(const CPoint & p_point1, const CPoint & p_point2) const { + t_size item1, item2; + if (ItemFromPointAbs(p_point1, item1)) { + if (ItemFromPointAbs(p_point2,item2)) { + return item1 == item2; + } else { + return false; + } + } + if (GroupHeaderFromPointAbs2(p_point1, item1)) { + if (GroupHeaderFromPointAbs2(p_point2, item2)) { + return item1 == item2; + } else { + return false; + } + } + return false; +} + +void CListControlImpl::OnSizeAsync_Trigger() { + if (!m_sizeAsyncPending) { + if (PostMessage(MSG_SIZE_ASYNC,0,0)) { + m_sizeAsyncPending = true; + } else { + PFC_ASSERT(!"Shouldn't get here!"); + //should not happen + ListHandleResize(); + } + } +} + +void CListControlImpl::ListHandleResize() { + MoveViewOriginDelta(CPoint(0,0)); + m_sizeAsyncPending = false; +} + +void CListControlImpl::AddGroupHeaderToUpdateRgn2(HRGN p_rgn, size_t atItem) const { + CRect rcHeader; + if (GetGroupHeaderRect2(atItem,rcHeader)) AddUpdateRect(p_rgn,rcHeader); +} +void CListControlImpl::AddItemToUpdateRgn(HRGN p_rgn, t_size p_index) const { + if (p_index < this->GetItemCount()) { + AddUpdateRect(p_rgn,GetItemRect(p_index)); + } +} + +COLORREF CListControlImpl::GetSysColorHook(int colorIndex) const { + if (m_darkMode) { + return DarkMode::GetSysColor(colorIndex); + } else { + return GetSysColor(colorIndex); + } +} + +BOOL CListControlImpl::OnEraseBkgnd(CDCHandle dc) { + + if (paintInProgress()) return FALSE; + + CRect rcClient; WIN32_OP_D(GetClientRect(rcClient)); // SPECIAL CASE: No GetClientRectHook() here, fill physical client area, not logical + PaintUtils::FillRectSimple(dc,rcClient,this->GetSysColorHook(COLOR_WINDOW)); + + return TRUE; +} + +t_size CListControlImpl::InsertIndexFromPointEx(const CPoint & pt, bool & bInside) const { + bInside = false; + int y_abs = pt.y + GetViewOffset().y; + + if (y_abs >= GetViewAreaHeight()) { + return GetItemCount(); + } + size_t itemIdx = IndexFromPointAbs(y_abs); + if (itemIdx == SIZE_MAX) return SIZE_MAX; + + { + CRect rc; + if (!this->GetGroupHeaderRectAbs2(itemIdx, rc)) { + if (y_abs >= rc.top && y_abs <= rc.bottom) { + bInside = false; + return itemIdx; + } + } + } + if (itemIdx != SIZE_MAX) { + const CRect rc = GetItemRectAbs(itemIdx); + if (y_abs > rc.top + MulDiv(rc.Height(), 2, 3)) itemIdx++; + else if (y_abs >= rc.top + MulDiv(rc.Height(), 1, 3)) bInside = true; + return itemIdx; + } + return SIZE_MAX; +} + +t_size CListControlImpl::InsertIndexFromPoint(const CPoint & pt) const { + bool dummy; return InsertIndexFromPointEx(pt,dummy); +} + +COLORREF CListControlImpl::BlendGridColor( COLORREF bk ) { + return BlendGridColor( bk, PaintUtils::DetermineTextColor( bk ) ); +} + +COLORREF CListControlImpl::BlendGridColor( COLORREF bk, COLORREF tx ) { + return PaintUtils::BlendColor(bk, tx, 10); +} + +COLORREF CListControlImpl::GridColor() { + return BlendGridColor( GetSysColorHook(colorBackground), GetSysColorHook(colorText) ); +} + +void CListControlImpl::RenderItemBackground(CDCHandle p_dc,const CRect & p_itemRect,size_t p_item, uint32_t bkColor) { + switch( this->m_rowStyle ) { + case rowStylePlaylistDelimited: + PaintUtils::RenderItemBackground(p_dc,p_itemRect,p_item,bkColor); + { + auto blend = BlendGridColor(bkColor); + CDCPen pen(p_dc, blend); + SelectObjectScope scope(p_dc, pen); + + p_dc.MoveTo( p_itemRect.right-1, p_itemRect.top ); + p_dc.LineTo( p_itemRect.right-1, p_itemRect.bottom ); + } + break; + case rowStylePlaylist: + PaintUtils::RenderItemBackground(p_dc,p_itemRect,p_item,bkColor); + break; + case rowStyleGrid: + PaintUtils::FillRectSimple(p_dc, p_itemRect, bkColor ); + { + auto blend = BlendGridColor(bkColor); + CDCBrush brush(p_dc, blend); + p_dc.FrameRect(&p_itemRect, brush); + + } + break; + case rowStyleFlat: + PaintUtils::FillRectSimple(p_dc, p_itemRect, bkColor ); + break; + } +} + +void CListControlImpl::RenderGroupHeaderBackground(CDCHandle p_dc,const CRect & p_headerRect,int p_group) { + (void)p_group; + const t_uint32 bkColor = GetSysColorHook(colorBackground); + size_t pretendIndex = 0; + switch( this->m_rowStyle ) { + default: + PaintUtils::FillRectSimple( p_dc, p_headerRect, bkColor ); + break; + case rowStylePlaylistDelimited: + case rowStylePlaylist: + PaintUtils::RenderItemBackground(p_dc,p_headerRect,pretendIndex,bkColor); + break; + } +} + +void CListControlImpl::RenderItem(t_size p_item,const CRect & p_itemRect,const CRect & p_updateRect,CDCHandle p_dc) { + this->RenderItemBackground(p_dc, p_itemRect, p_item, GetSysColorHook(colorBackground) ); + + DCStateScope backup(p_dc); + p_dc.SetBkMode(TRANSPARENT); + p_dc.SetBkColor(GetSysColorHook(colorBackground)); + p_dc.SetTextColor(GetSysColorHook(colorText)); + + RenderItemText(p_item,p_itemRect,p_updateRect,p_dc, true); +} + +void CListControlImpl::RenderGroupHeader2(size_t baseItem,const CRect & p_headerRect,const CRect & p_updateRect,CDCHandle p_dc) { + this->RenderGroupHeaderBackground(p_dc, p_headerRect, 0 ); + + DCStateScope backup(p_dc); + p_dc.SetBkMode(TRANSPARENT); + p_dc.SetBkColor(GetSysColorHook(colorBackground)); + p_dc.SetTextColor(GetSysColorHook(colorHighlight)); + + RenderGroupHeaderText2(baseItem,p_headerRect,p_updateRect,p_dc); +} + + +CListControlFontOps::CListControlFontOps() : m_font((HFONT)::GetStockObject(DEFAULT_GUI_FONT)), m_itemHeight(), m_groupHeaderHeight() { + UpdateGroupHeaderFont(); + CalculateHeights(); +} + +void CListControlFontOps::UpdateGroupHeaderFont() { + try { + m_groupHeaderFont = NULL; + LOGFONT lf = {}; + WIN32_OP_D( m_font.GetLogFont(lf) ); + lf.lfHeight = pfc::rint32( (double) lf.lfHeight * GroupHeaderFontScale() ); + lf.lfWeight = GroupHeaderFontWeight(lf.lfWeight); + WIN32_OP_D( m_groupHeaderFont.CreateFontIndirect(&lf) != NULL ); + } catch(std::exception const & e) { + (void) e; + // console::print(e.what()); + m_groupHeaderFont = (HFONT)::GetStockObject(DEFAULT_GUI_FONT); + } +} + +void CListControlFontOps::CalculateHeights() { + const t_uint32 spacing = MulDiv(4, m_dpi.cy, 96); + m_itemHeight = GetFontHeight( m_font ) + spacing; + m_groupHeaderHeight = GetFontHeight( m_groupHeaderFont ) + spacing; +} + +void CListControlFontOps::SetFont(HFONT font,bool bUpdateView) { + m_font = font; + UpdateGroupHeaderFont(); CalculateHeights(); + OnSetFont(bUpdateView); + if (bUpdateView && m_hWnd != NULL) OnViewAreaChanged(); + +} + +LRESULT CListControlFontOps::OnSetFont(UINT,WPARAM wp,LPARAM,BOOL&) { + SetFont((HFONT)wp); + return 0; +} + +LRESULT CListControlFontOps::OnGetFont(UINT,WPARAM,LPARAM,BOOL&) { + return (LRESULT)(HFONT)m_font; +} + +LRESULT CListControlImpl::OnGetDlgCode(UINT, WPARAM wp, LPARAM) { + switch(wp) { + case VK_RETURN: + return m_dlgWantEnter ? DLGC_WANTMESSAGE : 0; + default: + SetMsgHandled(FALSE); + return 0; + } +} + +HWND CListControlImpl::CreateInDialog(CWindow wndDialog, UINT replaceControlID, CWindow lstReplace) { + PFC_ASSERT(lstReplace != NULL); + auto status = lstReplace.SendMessage(WM_GETDLGCODE, VK_RETURN); + m_dlgWantEnter = (status & DLGC_WANTMESSAGE); + CRect rc; + CWindow wndPrev = wndDialog.GetNextDlgTabItem(lstReplace, TRUE); + WIN32_OP_D(lstReplace.GetWindowRect(&rc)); + WIN32_OP_D(wndDialog.ScreenToClient(rc)); + WIN32_OP_D(lstReplace.DestroyWindow()); + WIN32_OP_D(this->Create(wndDialog, &rc, 0, 0, WS_EX_STATICEDGE, replaceControlID)); + if (wndPrev != NULL) this->SetWindowPos(wndPrev, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE); + // this->BringWindowToTop(); + this->SetFont(wndDialog.GetFont()); + return m_hWnd; +} + +HWND CListControlImpl::CreateInDialog(CWindow wndDialog, UINT replaceControlID ) { + return this->CreateInDialog(wndDialog, replaceControlID, wndDialog.GetDlgItem(replaceControlID)); +} + + +void CListControlImpl::defer(std::function f) { + m_deferred.push_back( f ); + if (!m_defferredMsgPending) { + if ( PostMessage(MSG_EXEC_DEFERRED) ) m_defferredMsgPending = true; + } +} + +LRESULT CListControlImpl::OnExecDeferred(UINT, WPARAM, LPARAM) { + + for ( ;; ) { + auto i = m_deferred.begin(); + if ( i == m_deferred.end() ) break; + auto op = std::move(*i); + m_deferred.erase(i); // erase first, execute later - avoid erratic behavior if op alters the list + op(); + } + + m_defferredMsgPending = false; + return 0; +} + +// ======================================================================================== +// Mouse wheel vs drag&drop hacks +// Install MouseHookProc for the duration of DoDragDrop and handle the input from there +// ======================================================================================== +static HHOOK g_hook = NULL; +static CListControlImpl * g_dragDropInstance = nullptr; +LRESULT CALLBACK CListControlImpl::MouseHookProc(int nCode, WPARAM wParam, LPARAM lParam) { + if (nCode == HC_ACTION && g_dragDropInstance != nullptr) { + switch (wParam) { + case WM_MOUSEWHEEL: + case WM_MOUSEHWHEEL: + g_dragDropInstance->MouseWheelFromHook((UINT)wParam, lParam); + break; + } + } + return CallNextHookEx(g_hook, nCode, wParam, lParam); +} + +bool CListControlImpl::MouseWheelFromHook(UINT msg, LPARAM data) { + MOUSEHOOKSTRUCTEX const * mhs = reinterpret_cast ( data ); + if ( ::WindowFromPoint(mhs->pt) != m_hWnd ) return false; + LRESULT dummyResult = 0; + WPARAM wp = mhs->mouseData; + LPARAM lp = MAKELPARAM( mhs->pt.x, mhs->pt.y ); + // If we get here, m_suppressMouseWheel should be true per our DoDragDrop() + pfc::vartoggle_t scope(m_suppressMouseWheel, false); + this->ProcessWindowMessage( m_hWnd, msg, wp, lp, dummyResult ); + return true; +} + +HRESULT CListControlImpl::DoDragDrop(LPDATAOBJECT pDataObj, LPDROPSOURCE pDropSource, DWORD dwOKEffects, LPDWORD pdwEffect) { + HRESULT ret = E_FAIL; + // Should not get here with non null g_dragDropInstance - means we have a recursive call + PFC_ASSERT(g_dragDropInstance == nullptr); + if ( g_dragDropInstance == nullptr ) { + // futureproofing: kill mouse wheel message processing if we get them delivered the regular way while this is in progress + pfc::vartoggle_t scope(m_suppressMouseWheel, true); + g_dragDropInstance = this; + g_hook = SetWindowsHookEx(WH_MOUSE, MouseHookProc, NULL, GetCurrentThreadId()); + try { + ret = ::DoDragDrop(pDataObj, pDropSource, dwOKEffects, pdwEffect); + } catch (...) { + } + g_dragDropInstance = nullptr; + UnhookWindowsHookEx(pfc::replace_null_t(g_hook)); + } + return ret; +} + + +CPoint CListControlImpl::PointAbsToClient(CPoint pt) const { + return pt - GetViewOffset(); +} + +CPoint CListControlImpl::PointClientToAbs(CPoint pt) const { + return pt + GetViewOffset(); +} + +CRect CListControlImpl::RectAbsToClient(CRect rc) const { + CRect ret; +#if 1 + ret = rc; + ret.OffsetRect(-GetViewOffset()); +#else + ret.TopLeft() = PointAbsToClient(rc.TopLeft()); + ret.BottomRight() = PointAbsToClient(rc.BottomRight()); +#endif + return ret; +} + +CRect CListControlImpl::RectClientToAbs(CRect rc) const { + CRect ret; +#if 1 + ret = rc; + ret.OffsetRect(GetViewOffset()); +#else + ret.TopLeft() = PointClientToAbs(rc.TopLeft()); + ret.BottomRight() = PointAbsToClient(rc.BottomRight()); +#endif + return ret; +} + +size_t CListControlImpl::ItemFromPoint(CPoint const& pt) const { + size_t ret = SIZE_MAX; + if (!ItemFromPoint(pt, ret)) ret = SIZE_MAX; + return ret; +} + +bool CListControlImpl::ItemFromPoint(CPoint const & p_pt, t_size & p_item) const { + return ItemFromPointAbs( PointClientToAbs( p_pt ), p_item); +} + +void CListControlImpl::ReloadData() { + this->m_varItemHeights.clear(); + this->m_groupHeaders.clear(); + OnViewAreaChanged(); +} + +void CListControlImpl::ReloadItems(pfc::bit_array const & mask) { + bool bReLayout = false; + mask.for_each(true, 0, GetItemCount(), [this, &bReLayout] (size_t idx) { + int hNew = this->GetItemHeight2(idx); + int hOld = -1; + { + auto iter = m_varItemHeights.find(idx); + if (iter != m_varItemHeights.end()) hOld = iter->second; + } + if (hNew != hOld) { + m_varItemHeights[idx] = hNew; + bReLayout = true; + } + }); + if (bReLayout) { + OnViewAreaChanged(); + } else { + UpdateItems(mask); + } + +} + +void CListControlImpl::MinGroupHeight2Changed(size_t itemInGroup, bool reloadWhole) { + size_t lo, hi; + if (ResolveGroupRangeCached(itemInGroup, lo, hi)) { + if (reloadWhole) { + CRect rc; + if (this->GetGroupOverlayRectAbs(itemInGroup, rc)) { + this->InvalidateRect(this->RectAbsToClient(rc)); + } + { + pfc::bit_array_range range(lo, hi-lo); + this->ReloadItems(range); + } + } else { + this->ReloadItem(hi - 1); + } + } +} + +bool CListControlImpl::IsItemFirstInGroupCached(size_t item) const { + return m_groupHeaders.count(item) > 0; +} + +bool CListControlImpl::IsItemFirstInGroup(size_t item) const { + if (item == 0) return true; + return GetItemGroup(item) != GetItemGroup(item - 1); +} +bool CListControlImpl::IsItemLastInGroup(size_t item) const { + size_t next = item + 1; + if (next >= GetItemCount()) return true; + return GetItemGroup(item) != GetItemGroup(next); +} + +int CListControlImpl::GetItemHeight2(size_t which) const { + if (!IsItemLastInGroup(which)) return -1; + + const int minGroupHeight = this->GetMinGroupHeight2(which); + if (minGroupHeight <= 0) return -1; + + const int heightNormal = this->GetItemHeight(); + + const size_t base = FindGroupBase(which); + + const int groupHeightWithout = (which > base ? this->GetItemOffsetAbs2(base,which) : 0); + + const int minItemHeight = minGroupHeight - groupHeightWithout; // possibly negative + + if (minItemHeight > heightNormal) return minItemHeight; + else return -1; // use normal +} + +void CListControlImpl::wndSetDarkMode(CWindow wndListControl, bool bDark) { + wndListControl.SendMessage(DarkMode::msgSetDarkMode(), bDark ? 1 : 0); +} + +LRESULT CListControlImpl::OnSetDark(UINT, WPARAM wp, LPARAM) { + switch (wp) { + case 0: + this->SetDarkMode(false); + break; + case 1: + this->SetDarkMode(true); + break; + } + return 1; +} + +void CListControlImpl::OnItemRemoved(size_t which) { + this->OnItemsRemoved(pfc::bit_array_one(which), GetItemCount() + 1); +} + + +UINT CListControlImpl::msgSetDarkMode() { + return DarkMode::msgSetDarkMode(); +} + +void CListControlImpl::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { + (void)nRepCnt; (void)nFlags; + switch (nChar) { + case VK_LEFT: + MoveViewOriginDelta(CPoint(-MulDiv(16, m_dpi.cx, 96), 0)); + break; + case VK_RIGHT: + MoveViewOriginDelta(CPoint(MulDiv(16, m_dpi.cx, 96), 0)); + break; + default: + SetMsgHandled(FALSE); break; + } +} + +void CListControlImpl::OnItemsInserted(size_t at, size_t count, bool bSelect) { + size_t newCount = this->GetItemCount(); + this->OnItemsInsertedEx(pfc::bit_array_range(at, count, true), newCount - count, newCount, bSelect); +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/CListControl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/CListControl.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,405 @@ +#pragma once + +// ================================================================================ +// Main CListControl implementation +// +// For ready-to-use CListControl specializations, +// see CListControlSimple.h and CListControlOwnerData.h +// ================================================================================ + + +#pragma comment(lib, "uxtheme.lib") + +#include +#include +#include +#include +#include +#include +#include "CMiddleDragImpl.h" +#include "wtl-pp.h" +#include "gesture.h" +#include "gdiplus_helpers.h" + +#define CListControl_ScrollWindowFix + +#ifdef CListControl_ScrollWindowFix +#define WS_EX_COMPOSITED_CListControl 0 +#else +#define WS_EX_COMPOSITED_CListControl WS_EX_COMPOSITED +#endif + + +typedef std::function< bool ( UINT, DWORD, CPoint ) > CaptureProc_t; + +typedef CWinTraits CListControlTraits; + +class CListControlImpl : public CWindowImpl { +public: + typedef uint64_t groupID_t; + + CListControlImpl() {} + + static const wchar_t* GetWndClassName() { return L"libPPUI:CListControl"; } + DECLARE_WND_CLASS_EX(GetWndClassName(), CS_DBLCLKS, (-1)); + + // Wrapper around CWindowImpl::Create(). + // Creates CListControl replacing another dialog control with the specified ID. + // Note that m_dlgWantEnter is set to false by this method, as it's typically unwanted in dialogs. + HWND CreateInDialog( CWindow wndDialog, UINT replaceControlID ); + HWND CreateInDialog(CWindow wndDialog, UINT replaceControlID, CWindow wndReplace); + + enum { + MSG_SIZE_ASYNC = WM_USER + 13, + MSG_EXEC_DEFERRED, + UserMsgBase + }; + static UINT msgSetDarkMode(); + const UINT MSG_SET_DARK = msgSetDarkMode(); + + static void wndSetDarkMode(CWindow wndListControl, bool bDark); + + BEGIN_MSG_MAP_EX(CListControlImpl) + MESSAGE_HANDLER_EX(MSG_EXEC_DEFERRED, OnExecDeferred); + MSG_WM_PAINT(OnPaint) + MSG_WM_PRINTCLIENT(OnPrintClient); + MESSAGE_HANDLER(WM_VSCROLL,OnVScroll); + MESSAGE_HANDLER(WM_HSCROLL,OnHScroll); + MESSAGE_HANDLER(WM_SIZE,OnSize); + MESSAGE_HANDLER(WM_MOUSEHWHEEL,OnHWheel); + MESSAGE_HANDLER(WM_MOUSEWHEEL,OnVWheel); + MESSAGE_HANDLER(WM_LBUTTONDOWN,SetFocusPassThru); + MESSAGE_HANDLER(WM_RBUTTONDOWN,SetFocusPassThru); + MESSAGE_HANDLER(WM_MBUTTONDOWN,SetFocusPassThru); + MESSAGE_HANDLER(WM_LBUTTONDBLCLK,SetFocusPassThru); + MESSAGE_HANDLER(WM_RBUTTONDBLCLK,SetFocusPassThru); + MESSAGE_HANDLER(WM_MBUTTONDBLCLK,SetFocusPassThru); + MESSAGE_HANDLER(WM_CREATE,OnCreatePassThru); + MSG_WM_ERASEBKGND(OnEraseBkgnd) + MESSAGE_HANDLER(MSG_SIZE_ASYNC,OnSizeAsync); + MESSAGE_HANDLER(WM_GESTURE, OnGesture) + MSG_WM_THEMECHANGED(OnThemeChanged) + MESSAGE_HANDLER_EX( WM_GETDLGCODE, OnGetDlgCode ) + MESSAGE_HANDLER_EX( MSG_SET_DARK, OnSetDark ) + MSG_WM_KEYDOWN(OnKeyDown) + END_MSG_MAP() + + virtual void ReloadData(); + virtual void ReloadItems(pfc::bit_array const & mask); + + //! Hookable function called in response to reordering of items. Redraws the view and updates internal data to reflect the change. + virtual void OnItemsReordered( const size_t * order, size_t count ); + //! Hookable function called in response to removal of items. Redraws the view and updates internal data to reflect the change. + virtual void OnItemsRemoved(pfc::bit_array const& mask, size_t oldCount) { (void)mask; (void)oldCount; ReloadData(); } + //! Hookable function called in response to insertion of items. Redraws the view and updates internal data to reflect the change. + virtual void OnItemsInsertedEx(pfc::bit_array const& mask, size_t oldCount, size_t newCount, bool bSelect) { (void)mask; (void)oldCount; (void) newCount; (void)bSelect; ReloadData(); } + void OnItemsInserted(size_t at, size_t count, bool bSelect); + + //! Helper around OnItemsRemoved() + void OnItemRemoved(size_t which); + + void ReloadItem(size_t i) { ReloadItems( pfc::bit_array_one(i) ); } + void OnViewAreaChanged() {OnViewAreaChanged(GetViewOrigin());} + void OnViewAreaChanged(CPoint p_originOverride); + void UpdateGroupHeader2(size_t atItem); + void UpdateItems(const pfc::bit_array & p_mask); + void UpdateItemsAndHeaders(const pfc::bit_array & p_mask); + void UpdateItem(t_size p_item) {UpdateItems(pfc::bit_array_one(p_item));} + void UpdateItemsAll() {Invalidate();} + void EnsureItemVisible(t_size p_item, bool bUser = false); + void EnsureHeaderVisible2(size_t atItem); + virtual void EnsureVisibleRectAbs(const CRect & p_rect); + CRect GetItemRect(t_size p_item) const; + bool GetGroupHeaderRect2(size_t atItem,CRect & p_rect) const; + CRect GetItemRectAbs(t_size p_item) const; + int GetItemOffsetAbs(size_t item) const; + int GetItemOffsetAbs2(size_t from, size_t to) const; + int GetItemBottomOffsetAbs(size_t item) const; + int GetItemHeightCached(size_t item) const; + int GetItemContentHeightCached(size_t item) const; + bool GetGroupHeaderRectAbs2(size_t atItem,CRect & p_rect) const; + CPoint GetViewOrigin() const {return m_viewOrigin;} + CPoint GetViewOffset() const {return GetViewOrigin() - GetClientOrigin();} + CPoint PointAbsToClient(CPoint pt) const; + CPoint PointClientToAbs(CPoint pt) const; + CRect RectAbsToClient(CRect rc) const; + CRect RectClientToAbs(CRect rc) const; + int GetViewAreaWidth() const {return GetItemWidth();} + int GetViewAreaHeight() const; + CRect GetViewAreaRectAbs() const; + CRect GetViewAreaRect() const; + CRect GetValidViewOriginArea() const; + bool GetItemRangeAbs(const CRect & p_rect,t_size & p_base,t_size & p_count) const; + bool GetItemRangeAbsInclHeaders(const CRect & p_rect,t_size & p_base,t_size & p_count) const; + bool GetItemRange(const CRect & p_rect,t_size & p_base,t_size & p_count) const; + void MoveViewOriginNoClip(CPoint p_target); + void MoveViewOrigin(CPoint p_target); + CPoint ClipViewOrigin(CPoint p_origin) const; + void MoveViewOriginDelta(CPoint p_delta) {MoveViewOrigin( GetViewOrigin() + p_delta );} + void MoveViewOriginDeltaNoClip(CPoint p_delta) {MoveViewOriginNoClip( GetViewOrigin() + p_delta );} + bool ItemFromPoint(CPoint const & p_pt, t_size & p_item) const; + size_t ItemFromPoint(CPoint const& pt) const; + bool GroupHeaderFromPoint2(CPoint const & p_pt,size_t & p_atItem) const {return GroupHeaderFromPointAbs2( PointClientToAbs(p_pt),p_atItem);} + bool ItemFromPointAbs(CPoint const & p_pt,t_size & p_item) const; + size_t ItemFromPointAbs(CPoint const& p_pt) const; + bool GroupHeaderFromPointAbs2(CPoint const & p_pt,size_t & p_atItem) const; + size_t IndexFromPointAbs(CPoint pt) const; + size_t IndexFromPointAbs(int ptY) const; + + size_t ResolveGroupRange2(t_size p_base) const; + bool ResolveGroupRangeCached(size_t itemInGroup, size_t & outBegin, size_t & outEnd) const; + + virtual int GetGroupHeaderHeight() const {return 0;} + virtual int GetItemHeight() const {return 0;} + + // Variable height items - return -1 to use generic. + // This is intended to be used scarcely. Layout engine assumes that majority of items use the generic height. + // Heavy use of variable height items on large data sets will lead to performance issues. + virtual int GetItemHeight2(size_t which) const; + + // Companion to GetItemHeight2(), returns portion of GetItemHeight2()-defined item which the item content actually occupies + virtual int GetItemHeight2Content(size_t which, int iHeight) const { (void)which; return iHeight; } + + virtual int GetMinGroupHeight() const { return 0; } + virtual int GetMinGroupHeight2(size_t itemInGroup) const { (void)itemInGroup; return GetMinGroupHeight(); } + void MinGroupHeight2Changed(size_t itemInGroup, bool reloadWhole = false); + void MinGroupHeight2ChangedForGroup(groupID_t group, bool reloadWhole = false); + virtual int GetItemWidth() const {return 0;} + virtual t_size GetItemCount() const {return 0;} + + bool IsItemFirstInGroupCached(size_t item) const; + bool IsItemFirstInGroup(size_t item) const; + bool IsItemLastInGroup(size_t item) const; + + virtual groupID_t GetItemGroup(t_size p_item) const { (void)p_item; return 0; } + + virtual void RenderRect(const CRect& p_rect, CDCHandle p_dc); + //override optionally + virtual void RenderItem(t_size p_item,const CRect & p_itemRect,const CRect & p_updateRect,CDCHandle p_dc); + //override optionally + virtual void RenderGroupHeader2(size_t p_item,const CRect & p_headerRect,const CRect & p_updateRect,CDCHandle p_dc); + + virtual void RenderGroupOverlay(size_t baseItem, const CRect& p_groupWhole, const CRect& p_updateRect, CDCHandle p_dc) { (void)baseItem; (void)p_groupWhole; (void)p_updateRect; (void)p_dc; } + void UpdateGroupOverlayByID(groupID_t groupID, int xFrom = 0, int xTo = -1); + bool GetGroupOverlayRectAbs(size_t atItem, CRect & outRect); + + //called by default RenderItem implementation + virtual void RenderItemText(t_size p_item, const CRect& p_itemRect, const CRect& p_updateRect, CDCHandle p_dc, bool allowColors) { (void)p_item; (void)p_itemRect; (void)p_updateRect; (void)p_dc; (void)allowColors; } + //called by default RenderItem implementation + virtual void RenderGroupHeaderText2(size_t p_item, const CRect& p_headerRect, const CRect& p_updateRect, CDCHandle p_dc) { (void)p_item; (void)p_headerRect; (void)p_updateRect; (void)p_dc; } + + virtual void RenderItemBackground(CDCHandle p_dc,const CRect & p_itemRect,size_t item, uint32_t bkColor); + virtual void RenderGroupHeaderBackground(CDCHandle p_dc,const CRect & p_headerRect,int iGroup); + + virtual void RenderBackground( CDCHandle dc, CRect const & rc ); + + virtual void OnViewOriginChange(CPoint p_delta) { (void)p_delta; } + + // RenderOverlay2 takes rect in client coords, not absolute + // p_dc operates on client coords also + virtual void RenderOverlay2(const CRect& p_updaterect, CDCHandle p_dc) { (void)p_updaterect; (void)p_dc; } + + virtual bool FixedOverlayPresent() {return false;} + + virtual CRect GetClientRectHook() const; + + enum { + colorText = COLOR_WINDOWTEXT, + colorBackground = COLOR_WINDOW, + colorHighlight = COLOR_HOTLIGHT, + colorSelection = COLOR_HIGHLIGHT, + }; + + virtual COLORREF GetSysColorHook( int colorIndex ) const; + + //! Called by CListControlWithSelectionBase. + virtual void OnItemClicked(t_size item, CPoint pt) { (void)item; (void)pt; } + //! Called by CListControlWithSelectionBase. + virtual void OnGroupHeaderClicked(groupID_t groupId, CPoint pt) { (void)groupId; (void)pt; } + + //! Return true to indicate that some area of the control has a special purpose and clicks there should not trigger changes in focus/selection. + virtual bool OnClickedSpecialHitTest(CPoint pt) { (void)pt; return false; } + virtual bool OnClickedSpecial(DWORD status, CPoint pt) { (void)status; (void)pt; return false; } + + virtual bool AllowScrollbar(bool vertical) const { (void)vertical; return true; } + + CPoint GetClientOrigin() const {return GetClientRectHook().TopLeft();} + int GetVisibleHeight() const { return GetClientRectHook().Height(); } + + bool IsItemVisible(size_t which) const; + //! Returns first visible item, first invisible item, begin-end style + std::pair GetVisibleRange() const; + CRect GetVisibleRectAbs() const { + return this->RectClientToAbs(GetClientRectHook()); + } + + bool IsSameItemOrHeaderAbs(const CPoint & p_point1, const CPoint & p_point2) const; + + void AddItemToUpdateRgn(HRGN p_rgn, t_size p_index) const; + void AddGroupHeaderToUpdateRgn2(HRGN p_rgn, size_t atItem) const; + + t_size InsertIndexFromPoint(const CPoint & p_pt) const; + //! Translate point to insert location for drag and drop. \n + //! Made virtual so it can be specialized to allow only specific drop locations. + virtual t_size InsertIndexFromPointEx(const CPoint & pt, bool & bInside) const; + + virtual void ListHandleResize(); + + //! Can smooth-scroll *now* ? Used to suppress smooth scroll on temporary basis due to specific user operations in progress + virtual bool CanSmoothScroll() const { return true; } + //! Is smooth scroll enabled by user? + virtual bool UserEnabledSmoothScroll() const; + virtual bool ToggleSelectedItemsHook(pfc::bit_array const& mask) { (void)mask; return false; } + + + SIZE GetDPI() const { return this->m_dpi;} + + // Should this control take enter key in dialogs or not? + // Default to true for compatibility with existing code - but when used in dialogs, you'll want it set to false to hit [OK] with enter. + // Note that CreateInDialog() sets this to false. Change it later if you want enter key presses to reach this control in a dialog. + bool m_dlgWantEnter = true; + + bool WantReturn() const { return m_dlgWantEnter; } + void SetWantReturn(bool v) { m_dlgWantEnter = v; } + + enum { + rowStyleGrid = 0, + rowStyleFlat, + rowStylePlaylist, + rowStylePlaylistDelimited, + + + rowStyleDefault = rowStylePlaylistDelimited + }; + void SetPlaylistStyle() {SetRowStyle(rowStylePlaylist);} + void SetRowStyle(unsigned v) { if (m_rowStyle == v) return; this->m_rowStyle = v; if (m_hWnd) Invalidate(); } + void SetFlatStyle() {SetRowStyle(rowStyleFlat);} + unsigned m_rowStyle = rowStyleDefault; + bool DelimitColumns() const { return m_rowStyle == rowStyleGrid || m_rowStyle == rowStylePlaylistDelimited; } + + static COLORREF BlendGridColor( COLORREF bk, COLORREF tx ); + static COLORREF BlendGridColor( COLORREF bk ); + COLORREF GridColor(); + + void SetDarkMode(bool bDark); + virtual void RefreshDarkMode(); + bool GetDarkMode() const { return m_darkMode; } +private: + void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); + LRESULT OnSetDark(UINT, WPARAM, LPARAM); + int HandleWheel(int & p_accum,int p_delta, bool bHoriz); + + void PaintContent(CRect rcPaint, HDC dc); + void OnPrintClient(HDC dc, UINT uFlags); + void OnPaint(CDCHandle); + LRESULT OnVScroll(UINT,WPARAM,LPARAM,BOOL&); + LRESULT OnHScroll(UINT,WPARAM,LPARAM,BOOL&); + LRESULT OnSize(UINT,WPARAM,LPARAM,BOOL&); + LRESULT OnSizeAsync(UINT,WPARAM,LPARAM,BOOL&) {ListHandleResize();return 0;} + LRESULT OnVWheel(UINT,WPARAM,LPARAM,BOOL&); + LRESULT OnHWheel(UINT,WPARAM,LPARAM,BOOL&); + LRESULT OnGesture(UINT,WPARAM,LPARAM,BOOL&); + LRESULT SetFocusPassThru(UINT,WPARAM,LPARAM,BOOL&); + LRESULT OnCreatePassThru(UINT,WPARAM,LPARAM,BOOL&); + BOOL OnEraseBkgnd(CDCHandle); + LRESULT OnGetDlgCode(UINT, WPARAM, LPARAM); + + void OnThemeChanged(); + int GetScrollThumbPos(int which); + void RefreshSliders(); + void RefreshSlider(bool p_vertical); + + void OnSizeAsync_Trigger(); + static LRESULT CALLBACK MouseHookProc(int nCode, WPARAM wParam, LPARAM lParam); + bool MouseWheelFromHook(UINT msg, LPARAM data); + + bool m_suppressMouseWheel = false; + int m_wheelAccumX = 0, m_wheelAccumY = 0; + CPoint m_viewOrigin = CPoint(0,0); + bool m_sizeAsyncPending = false; + CPoint m_gesturePoint; + + // Prepares group header & variable height item data for view with the specified origin and current client size + // Returns true if layout cache has changed, false otherwise. + // Updates ptOrigin if necessary + bool PrepLayoutCache(CPoint & ptOrigin, size_t indexLo = SIZE_MAX, size_t indexHi = SIZE_MAX); + std::map m_varItemHeights; + std::set m_groupHeaders; + + size_t FindGroupBaseCached(size_t itemFor) const; + size_t FindGroupBase(size_t itemFor) const; + size_t FindGroupBase(size_t itemFor, groupID_t group) const; + +protected: + // Grouped layout mode toggle + // Default mode is greedy, probes whole list layout in advance (no glitches when scrolling) + // In special conditions when probing is expensive, greedy mode should be turned off + bool m_greedyGroupLayout = true; + + pfc::map_t m_themeCache; + CTheme & themeFor( const char * what ); + CTheme & theme() { return themeFor("LISTVIEW");} + + const SIZE m_dpi = QueryScreenDPIEx(); + CGestureAPI m_gestureAPI; + bool m_ensureVisibleUser = false; + + void defer( std::function f ); + LRESULT OnExecDeferred(UINT, WPARAM, LPARAM); + + // Overlays our stuff on top of generic DoDragDrop call. + // Currently catches mouse wheel messages in mid-drag&drop and handles them in our view. + HRESULT DoDragDrop(LPDATAOBJECT pDataObj, LPDROPSOURCE pDropSource, DWORD dwOKEffects, LPDWORD pdwEffect); + + bool paintInProgress() const { return m_paintInProgress; } +private: + bool m_defferredMsgPending = false; + std::list > m_deferred; + bool m_darkMode = false; + + bool m_paintInProgress = false; +}; + +class CListControlFontOps : public CListControlImpl { +private: + typedef CListControlImpl TParent; +public: + CListControlFontOps(); + BEGIN_MSG_MAP_EX(CListControlFontOps) + MESSAGE_HANDLER(WM_GETFONT,OnGetFont); + MESSAGE_HANDLER(WM_SETFONT,OnSetFont); + CHAIN_MSG_MAP(TParent); + END_MSG_MAP() + CFontHandle GetFont() const { return m_font; } + void SetFont(HFONT font, bool bUpdateView = true); +protected: + CFontHandle GetGroupHeaderFont() const {return (HFONT)m_groupHeaderFont;} + virtual double GroupHeaderFontScale() const { return 1.25; } + virtual int GroupHeaderFontWeight(int origVal) const { + //return pfc::min_t(FW_BLACK, origVal + 200); + return origVal; + } + + //! Overridden implementations should always forward the call to the base class. + virtual void OnSetFont(bool bUpdatingView) { (void)bUpdatingView; } + + int GetGroupHeaderHeight() const override {return m_groupHeaderHeight;} + int GetItemHeight() const override {return m_itemHeight;} + +private: + LRESULT OnSetFont(UINT,WPARAM,LPARAM,BOOL&); + LRESULT OnGetFont(UINT,WPARAM,LPARAM,BOOL&); + void UpdateGroupHeaderFont(); + void CalculateHeights(); + int m_itemHeight, m_groupHeaderHeight; + CFontHandle m_font; + CFont m_groupHeaderFont; +}; + +#include "CListControlHeaderImpl.h" +#include "CListControlTruncationTooltipImpl.h" + + + +typedef CMiddleDragImpl CListControl; + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/CListControlComplete.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/CListControlComplete.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,22 @@ +#pragma once + +// ================================================================================ +// CListControlComplete +// ================================================================================ +// Simplified declaration of the base class that most CListControl users will need. +// The other base classes are used directly mainly by old code predating libPPUI. +// ================================================================================ + +#include "CListControlWithSelection.h" +#include "CListControl_EditImpl.h" +#include "CListAccessible.h" + +// ================================================================================ +// CListControlWithSelectionImpl = list control with selection/focus +// CListControl_EditImpl = inplace editbox implementation +// CListControlAccImpl = accessibility API implementation (screen reader interop) +// ================================================================================ +typedef CListControlAccImpl > CListControlComplete; + +// CListControlReadOnly : no inplace edit functionality (CListControl_EditImpl) +typedef CListControlAccImpl CListControlReadOnly; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/CListControlHeaderImpl.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/CListControlHeaderImpl.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,1309 @@ +#include "stdafx.h" +#include "CListControl.h" +#include "CListControlHeaderImpl.h" // redundant but makes intelisense quit showing false errors +#include "CListControl-Cells.h" +#include "PaintUtils.h" +#include "GDIUtils.h" +#include "win32_utility.h" +#include "DarkMode.h" +#include + +static constexpr int lineBelowHeaderCY = 1; + +// Prevent erratic behavior of header control +static constexpr uint32_t columnWidthSanityLimit = 10000; + +static uint32_t columWidthToPixels(uint32_t user) { + PFC_ASSERT(user <= CListControlHeaderImpl::columnWidthMax); + return user < columnWidthSanityLimit ? user : columnWidthSanityLimit; +} + +static bool testDrawLineBelowHeader() { + // Win10 + return IsWindows10OrGreater(); +} + +void CListControlHeaderImpl::OnThemeChangedPT() { + if (m_header) { + auto dark = GetDarkMode(); + if (dark != m_headerDark) { + m_headerDark = dark; + DarkMode::ApplyDarkThemeCtrl(m_header, dark, L"ItemsView"); + } + } + this->SetMsgHandled(FALSE); +} + +void CListControlHeaderImpl::InitializeHeaderCtrl(DWORD flags) { + PFC_ASSERT(IsWindow()); + PFC_ASSERT(!IsHeaderEnabled()); + m_headerDark = false; + WIN32_OP_D( m_header.Create(*this,NULL,NULL,WS_CHILD | flags) != NULL ); + m_header.SetFont( GetFont() ); + + InjectParentEraseHandler(m_header); + + this->OnThemeChangedPT(); + + if (testDrawLineBelowHeader()) { + WIN32_OP_D( m_headerLine.Create( *this, NULL, NULL, WS_CHILD ) != NULL ); + InjectParentEraseHandler(m_headerLine); + } + + UpdateHeaderLayout(); +} + +void CListControlHeaderImpl::UpdateHeaderLayout() { + CRect client; WIN32_OP_D( GetClientRect(client) ); + int cw_old = m_clientWidth; + m_clientWidth = client.Width(); + if (IsHeaderEnabled()) { + auto rc = client; + rc.left -= GetViewOffset().x; + WINDOWPOS wPos = {}; + HDLAYOUT layout = {&rc, &wPos}; + if (m_header.Layout(&layout)) { + m_header.SetWindowPos(wPos.hwndInsertAfter,wPos.x,wPos.y,wPos.cx,wPos.cy,wPos.flags | SWP_SHOWWINDOW); + if (m_headerLine != NULL) m_headerLine.SetWindowPos(m_header, wPos.x, wPos.y + wPos.cy, wPos.cx, lineBelowHeaderCY, wPos.flags | SWP_SHOWWINDOW); + } else { + m_header.ShowWindow(SW_HIDE); + if (m_headerLine != NULL) m_headerLine.ShowWindow(SW_HIDE); + } + } else { + if ( cw_old != m_clientWidth) Invalidate(); + } +} + +int CListControlHeaderImpl::GetItemWidth() const { + if (IsHeaderEnabled()) return m_itemWidth; + else return m_clientWidth; +} + +LRESULT CListControlHeaderImpl::OnSizePassThru(UINT,WPARAM,LPARAM) { + UpdateHeaderLayout(); + + ProcessAutoWidth(); + + SetMsgHandled(FALSE); + return 0; +} + +void CListControlHeaderImpl::OnViewOriginChange(CPoint p_delta) { + TParent::OnViewOriginChange(p_delta); + if (p_delta.x != 0) UpdateHeaderLayout(); +} + +void CListControlHeaderImpl::SetHeaderFont(HFONT font) { + if (IsHeaderEnabled()) { + m_header.SetFont(font); UpdateHeaderLayout(); + } +} + +LRESULT CListControlHeaderImpl::OnHeaderCustomDraw(LPNMHDR hdr) { + LPNMCUSTOMDRAW nmcd = reinterpret_cast(hdr); + if ( m_header != NULL && this->GetDarkMode() && nmcd->hdr.hwndFrom == m_header) { + switch (nmcd->dwDrawStage) + { + case CDDS_PREPAINT: + return CDRF_NOTIFYITEMDRAW; + case CDDS_ITEMPREPAINT: + { + CDCHandle dc(nmcd->hdc); + dc.SetTextColor(0xdedede); + dc.SetBkColor(0x191919); // disregarded anyway + } + return CDRF_DODEFAULT; + } + } + SetMsgHandled(FALSE); return 0; +} + +LRESULT CListControlHeaderImpl::OnDividerDoubleClick(int,LPNMHDR hdr,BOOL&) { + const NMHEADER * info = (const NMHEADER *) hdr; + if (info->iButton == 0) { + AutoColumnWidth((t_size)info->iItem); + } + return 0; +} + +LRESULT CListControlHeaderImpl::OnHeaderItemClick(int,LPNMHDR p_hdr,BOOL&) { + const NMHEADER * info = (const NMHEADER *) p_hdr; + if (info->iButton == 0) { + OnColumnHeaderClick((t_uint32)info->iItem); + } + return 0; +} + +LRESULT CListControlHeaderImpl::OnHeaderItemChanged(int,LPNMHDR p_hdr,BOOL&) { + const NMHEADER * info = (const NMHEADER*) p_hdr; + if (info->pitem->mask & (HDI_WIDTH | HDI_ORDER)) { + if(!m_ownColumnsChange) ProcessColumnsChange(); + } + return 0; +} + +LRESULT CListControlHeaderImpl::OnHeaderEndDrag(int,LPNMHDR hdr,BOOL&) { + NMHEADER * info = (NMHEADER*) hdr; + return OnColumnHeaderDrag(info->iItem,info->pitem->iOrder) ? TRUE : FALSE; +} + +bool CListControlHeaderImpl::OnColumnHeaderDrag(t_size index, t_size newPos) { + index = GetSubItemOrder(index); + const t_size count = this->GetColumnCount(); + if ( count == 0 ) return false; + std::vector perm; perm.resize(count); pfc::create_move_items_permutation(&perm[0],count, pfc::bit_array_one(index), (int) newPos - (int) index ); + std::vector order, newOrder; order.resize(count); newOrder.resize(count); + WIN32_OP_D(m_header.GetOrderArray((int)count, &order[0])); + for(t_size walk = 0; walk < count; ++walk) newOrder[walk] = order[perm[walk]]; + WIN32_OP_D(m_header.SetOrderArray((int)count, &newOrder[0])); + OnColumnsChanged(); + return true; +} +t_size CListControlHeaderImpl::SubItemFromPointAbs(CPoint pt) const { + + auto order = GetColumnOrderArray(); + const t_size colCount = order.size(); + + size_t item; + if (! ItemFromPointAbs(pt, item ) ) item = SIZE_MAX; + + long xWalk = 0; + for(t_size _walk = 0; _walk < colCount; ) { + const t_size walk = (t_size) order[_walk]; + + size_t span = 1; + if (item != SIZE_MAX) span = this->GetSubItemSpan(item, walk); + + PFC_ASSERT( span == 1 || _walk == walk ); + + if ( walk + span > colCount ) span = colCount - walk; + + long width = 0; + for( size_t sub = 0; sub < span; ++ sub ) { + width += (long)this->GetSubItemWidth(walk + sub); + } + + if (xWalk + width > pt.x) return walk; + xWalk += width; + _walk += span; + } + return SIZE_MAX; +} + +bool CListControlHeaderImpl::OnClickedSpecial(DWORD status, CPoint pt) { + + const DWORD maskButtons = MK_LBUTTON | MK_RBUTTON | MK_MBUTTON | MK_XBUTTON1 | MK_XBUTTON2; + + if ( (status & maskButtons) != MK_LBUTTON ) return false; + + if (!GetCellTypeSupported()) return false; + + size_t item; size_t subItem; + if (! this->GetItemAtPointAbsEx( this->PointClientToAbs(pt), item, subItem ) ) { + return false; + } + + auto cellType = GetCellType(item, subItem); + if ( !CellTypeReactsToMouseOver( cellType ) ) return false; + auto rcHot = CellHotRect( item, subItem, cellType ); + if (!rcHot.PtInRect( pt )) return false; + + SetPressedItem(item, subItem); + mySetCapture([=](UINT msg, DWORD newStatus, CPoint pt) { + + if (msg == WM_MOUSELEAVE) { + ClearPressedItem(); return false; + } + + { + CRect rc = this->GetClientRectHook(); + if (!rc.PtInRect(pt)) { + ClearPressedItem(); return false; + } + } + + size_t newItem, newSubItem; + if (!this->GetItemAtPointAbsEx(this->PointClientToAbs(pt), newItem, newSubItem) || newItem != item || newSubItem != subItem) { + ClearPressedItem(); return false; + } + + DWORD buttons = newStatus & maskButtons; + if (buttons == 0) { + // button released? + this->defer( [=] { + OnSubItemClicked(item, subItem, pt); + } ); + ClearPressedItem(); return false; + } + if (buttons != MK_LBUTTON) { + // another button pressed? + ClearPressedItem(); return false; + } + + return true; + }); + return true; +} + +bool CListControlHeaderImpl::CellTypeUsesSpecialHitTests( cellType_t ct ) { + if ( ct == nullptr ) return false; + return ct->SuppressRowSelect(); +} + +bool CListControlHeaderImpl::OnClickedSpecialHitTest(CPoint pt) { + if ( ! GetCellTypeSupported() ) return false; + auto ct = GetCellTypeAtPointAbs( PointClientToAbs( pt ) ); + return CellTypeUsesSpecialHitTests(ct); +} + +void CListControlHeaderImpl::OnItemClicked(t_size item, CPoint pt) { + t_size subItem = SubItemFromPointAbs( PointClientToAbs( pt ) ); + if (subItem != SIZE_MAX) { + if ( this->GetCellTypeSupported() ) { + auto ct = this->GetCellType(item, subItem ); + // we don't handle hyperlink & button clicks thru here + if (CellTypeUsesSpecialHitTests(ct)) return; + } + OnSubItemClicked(item, subItem, pt); + } +} + +std::vector CListControlHeaderImpl::GetColumnOrderArray() const { + const size_t cCount = this->GetColumnCount(); + std::vector order; + if ( cCount > 0 ) { + order.resize(cCount); + if (IsHeaderEnabled()) { + PFC_ASSERT(m_header.IsWindow()); + PFC_ASSERT(m_header.GetItemCount() == (int)cCount); + WIN32_OP_D(m_header.GetOrderArray((int)cCount, &order[0])); + } else { + for (size_t c = 0; c < cCount; ++c) order[c] = (int)c; + } + } + return order; +} + +void CListControlHeaderImpl::RenderItemText(t_size item,const CRect & itemRect,const CRect & updateRect,CDCHandle dc, bool allowColors) { + + int xWalk = itemRect.left; + CRect subItemRect(itemRect); + auto order = GetColumnOrderArray(); + const size_t cCount = order.size(); + SelectObjectScope fontScope(dc,GetFont()); + for(t_size _walk = 0; _walk < cCount; ) { + const t_size walk = order[_walk]; + + size_t span = GetSubItemSpan(item, walk); + + PFC_ASSERT( walk == _walk || span == 1 ); + + int width = GetSubItemWidth(walk); + + if ( span > 1 ) { + if ( walk + span > cCount ) span = cCount - walk; + for( size_t extraWalk = 1; extraWalk < span; ++ extraWalk ) { + width += GetSubItemWidth(walk + extraWalk); + } + } + + subItemRect.left = xWalk; subItemRect.right = xWalk + width; + CRect test; + if (test.IntersectRect(itemRect, subItemRect)) { + CRect subUpdate; + if (subUpdate.IntersectRect(subItemRect, updateRect)) { + DCStateScope scope(dc); + if (dc.IntersectClipRect(subItemRect) != NULLREGION) { + RenderSubItemText(item, walk, subItemRect, subUpdate, dc, allowColors); + } + } + } + xWalk += width; + + _walk += span; + } +} + +t_size CListControlHeaderImpl::GetSubItemOrder(t_size subItem) const { + if ( ! IsHeaderEnabled( ) ) return subItem; + HDITEM hditem = {}; + hditem.mask = HDI_ORDER; + WIN32_OP_D( m_header.GetItem( (int) subItem, &hditem ) ); + return (t_size) hditem.iOrder; +} + +size_t CListControlHeaderImpl::GetSubItemSpan(size_t row, size_t column) const { + (void)row; (void)column; + return 1; +} + +uint32_t CListControlHeaderImpl::GetSubItemWidth(t_size subItem) const { + if ( ! IsHeaderEnabled( ) ) { + // Should be overridden for custom columns layout + PFC_ASSERT( GetColumnCount() == 1 ); + PFC_ASSERT( subItem == 0 ); + return GetItemWidth(); + } + + if ( subItem < m_colRuntime.size() ) return m_colRuntime[subItem].m_widthPixels; + PFC_ASSERT( !"bad column idx"); + return 0; +} + +int CListControlHeaderImpl::GetHeaderItemWidth( int which ) { + HDITEM hditem = {}; + hditem.mask = HDI_WIDTH; + WIN32_OP_D( m_header.GetItem( which, &hditem) ); + return hditem.cxy; +} + +void CListControlHeaderImpl::OnColumnsChanged() { + if ( IsHeaderEnabled() ) { + for( size_t walk = 0; walk < m_colRuntime.size(); ++ walk ) { + m_colRuntime[walk].m_widthPixels = GetHeaderItemWidth( (int) walk ); + } + RecalcItemWidth(); + } + this->OnViewAreaChanged(); +} + +void CListControlHeaderImpl::ResetColumns(bool update) { + m_colRuntime.clear(); + m_itemWidth = 0; + PFC_ASSERT(IsHeaderEnabled()); + for(;;) { + int count = m_header.GetItemCount(); + if (count <= 0) break; + m_header.DeleteItem(count - 1); + } + if (update) OnColumnsChanged(); +} + +void CListControlHeaderImpl::SetColumn( size_t which, const char * label, DWORD fmtFlags, bool updateView) { + PFC_ASSERT( IsHeaderEnabled() ); + pfc::stringcvt::string_os_from_utf8 labelOS; + + HDITEM item = {}; + + if (label != nullptr) { + if (which < m_colRuntime.size()) m_colRuntime[which].m_text = label; + + labelOS.convert(label); + item.mask |= HDI_TEXT; + item.pszText = const_cast(labelOS.get_ptr()); + } + if (fmtFlags != UINT32_MAX) { + item.mask |= HDI_FORMAT; + item.fmt = fmtFlags | HDF_STRING; + } + + m_header.SetItem( (int) which, &item ); + + if (updateView) OnColumnsChanged(); +} + +void CListControlHeaderImpl::GetColumnText(size_t which, pfc::string_base & out) const { + if (which < m_colRuntime.size()) { + out = m_colRuntime[which].m_text.c_str(); + } else { + out = ""; + } +} + +void CListControlHeaderImpl::ResizeColumn(t_size index, t_uint32 userWidth, bool updateView) { + PFC_ASSERT( IsHeaderEnabled() ); + PFC_ASSERT( index < m_colRuntime.size() ); + auto& rt = m_colRuntime[index]; + rt.m_userWidth = userWidth; + if (rt.autoWidth()) { + this->ProcessAutoWidth(); + } else { + auto widthPixels = columWidthToPixels(userWidth); + rt.m_widthPixels = widthPixels; + HDITEM item = {}; + item.mask = HDI_WIDTH; + item.cxy = widthPixels; + { pfc::vartoggle_t scope(m_ownColumnsChange, true); m_header.SetItem((int)index, &item); } + RecalcItemWidth(); + if (updateView) OnColumnsChanged(); + } +} + +void CListControlHeaderImpl::DeleteColumns( pfc::bit_array const & mask, bool updateView ) { + int nDeleted = 0; + const size_t oldCount = GetColumnCount(); + mask.for_each(true, 0, oldCount, [&] (size_t idx) { + int iDelete = (int) idx - nDeleted; + bool bDeleted = m_header.DeleteItem( iDelete ); + PFC_ASSERT( bDeleted ); + if ( bDeleted ) ++ nDeleted; + } ); + + pfc::remove_mask_t( m_colRuntime, mask ); + + ColumnWidthFix(); + + if (updateView) { + OnColumnsChanged(); + } + +} + +bool CListControlHeaderImpl::DeleteColumn(size_t index, bool update) { + PFC_ASSERT( IsHeaderEnabled() ); + + if (!m_header.DeleteItem( (int) index )) return false; + + pfc::remove_mask_t( m_colRuntime, pfc::bit_array_one( index ) ); + + ColumnWidthFix(); + + if (update) { + OnColumnsChanged(); + } + + return true; +} + +void CListControlHeaderImpl::SetSortIndicator( size_t whichColumn, bool isUp ) { + HeaderControl_SetSortIndicator( GetHeaderCtrl(), (int) whichColumn, isUp ); +} + +void CListControlHeaderImpl::ClearSortIndicator() { + HeaderControl_SetSortIndicator(GetHeaderCtrl(), -1, false); +} + +bool CListControlHeaderImpl::HaveAutoWidthContentColumns() const { + for( auto i = m_colRuntime.begin(); i != m_colRuntime.end(); ++ i ) { + if ( i->autoWidthContent() ) return true; + } + return false; +} +bool CListControlHeaderImpl::HaveAutoWidthColumns() const { + for( auto i = m_colRuntime.begin(); i != m_colRuntime.end(); ++ i ) { + if ( i->autoWidth() ) return true; + } + return false; +} +void CListControlHeaderImpl::AddColumnEx( const char * label, uint32_t widthPixelsAt96DPI, DWORD fmtFlags, bool update ) { + uint32_t w = widthPixelsAt96DPI; + if ( w <= columnWidthMax ) { + w = MulDiv( w, m_dpi.cx, 96 ); + } + AddColumn( label, w, fmtFlags, update ); +} + +void CListControlHeaderImpl::AddColumnDLU( const char * label, uint32_t widthDLU, DWORD fmtFlags, bool update ) { + uint32_t w = widthDLU; + if ( w <= columnWidthMax ) { + w = ::MapDialogWidth( GetParent(), w ); + } + AddColumn( label, w, fmtFlags, update ); +} +void CListControlHeaderImpl::AddColumnF( const char * label, float widthF, DWORD fmtFlags, bool update) { + uint32_t w = columnWidthMax; + if ( widthF >= 0 ) { + w = pfc::rint32( widthF * m_dpi.cx / 96.0f ); + } + AddColumn( label, w, fmtFlags, update ); +} +void CListControlHeaderImpl::AddColumn(const char * label, uint32_t userWidth, DWORD fmtFlags,bool update) { + // userWidth is either UINT32_MAX or desired width in pixels + PFC_ASSERT(IsWindow()); + if (! IsHeaderEnabled( ) ) InitializeHeaderCtrl(); + + uint32_t widthPixels = 0; + + pfc::stringcvt::string_os_from_utf8 labelOS(label); + HDITEM item = {}; + item.mask = HDI_TEXT | HDI_FORMAT; + if ( userWidth <= columnWidthMax ) { + widthPixels = columWidthToPixels(userWidth); + item.cxy = widthPixels; + item.mask |= HDI_WIDTH; + } + + item.pszText = const_cast(labelOS.get_ptr()); + item.fmt = HDF_STRING | fmtFlags; + int iColumn; + WIN32_OP_D( (iColumn = m_header.InsertItem(m_header.GetItemCount(),&item) ) >= 0 ); + colRuntime_t rt; + rt.m_text = label; + rt.m_userWidth = userWidth; + m_itemWidth += widthPixels; + rt.m_widthPixels = widthPixels; + m_colRuntime.push_back( std::move(rt) ); + + if (update) OnColumnsChanged(); + + ProcessAutoWidth(); +} + +float CListControlHeaderImpl::GetColumnWidthF(size_t subItem) const { + auto w = GetSubItemWidth(subItem); + return (float) w * 96.0f / (float)m_dpi.cx; +} + +void CListControlHeaderImpl::RenderBackground(CDCHandle dc, CRect const& rc) { + __super::RenderBackground(dc,rc); +#if 0 + if ( m_drawLineBelowHeader && IsHeaderEnabled()) { + CRect rcHeader; + if (m_header.GetWindowRect(rcHeader)) { + // Draw a grid line below header + int y = rcHeader.Height(); + if ( y >= rc.top && y < rc.bottom ) { + CDCPen pen(dc, GridColor()); + SelectObjectScope scope(dc, pen); + dc.MoveTo(rc.left, y); + dc.LineTo(rc.right, y); + } + } + } +#endif +} + +CRect CListControlHeaderImpl::GetClientRectHook() const { + CRect rcClient = __super::GetClientRectHook(); + if (m_header != NULL) { + PFC_ASSERT( m_header.IsWindow() ); + CRect rcHeader; + if (m_header.GetWindowRect(rcHeader)) { + int h = rcHeader.Height(); + if ( m_headerLine != NULL ) h += lineBelowHeaderCY; + rcClient.top = pfc::min_t(rcClient.bottom,rcClient.top + h); + } + } + return rcClient; +} + +CRect CListControlHeaderImpl::GetItemTextRectHook(size_t, size_t, CRect const & rc) const { + return GetItemTextRect( rc ); +} + +CRect CListControlHeaderImpl::GetItemTextRect(const CRect & itemRect) const { + CRect rc ( itemRect ); + rc.DeflateRect(GetColumnSpacing(),0); + return rc; +} + +void CListControlHeaderImpl::SetColumnSort(t_size which, bool isUp) { + HeaderControl_SetSortIndicator(m_header,(int)which,isUp); +} + +void CListControlHeaderImpl::SetColumnFormat(t_size which, DWORD format) { + HDITEM item = {}; + item.mask = HDI_FORMAT; + item.fmt = HDF_STRING | format; + WIN32_OP_D( m_header.SetItem((int)which,&item) ); +} + +DWORD CListControlHeaderImpl::GetColumnFormat(t_size which) const { + if (!IsHeaderEnabled()) return HDF_LEFT; + HDITEM hditem = {}; + hditem.mask = HDI_FORMAT; + WIN32_OP_D( m_header.GetItem( (int) which, &hditem) ); + return hditem.fmt; +} + +BOOL CListControlHeaderImpl::OnSetCursor(CWindow, UINT nHitTest, UINT message) { + (void)nHitTest; + if ( message != 0 && GetCellTypeSupported() ) { + CPoint pt( (LPARAM) GetMessagePos() ); + WIN32_OP_D( ScreenToClient( &pt ) ); + size_t item, subItem; + if (GetItemAtPointAbsEx(this->PointClientToAbs(pt), item, subItem)) { + auto ct = GetCellType(item, subItem); + if (CellTypeReactsToMouseOver(ct)) { + auto rc = CellHotRect(item, subItem, ct); + if (PtInRect(rc, pt)) { + auto cursor = ct->HotCursor(); + if (cursor) { + SetCursor(cursor); return TRUE; + } + } + } + } + } + SetMsgHandled(FALSE); return FALSE; +} + +bool CListControlHeaderImpl::GetItemAtPointAbsEx(CPoint pt, size_t & outItem, size_t & outSubItem) const { + size_t item, subItem; + if (ItemFromPointAbs(pt, item)) { + subItem = SubItemFromPointAbs(pt); + if (subItem != SIZE_MAX) { + outItem = item; outSubItem = subItem; return true; + } + } + return false; +} + +CListControlHeaderImpl::cellType_t CListControlHeaderImpl::GetCellTypeAtPointAbs(CPoint pt) const { + size_t item, subItem; + if ( GetItemAtPointAbsEx( pt, item, subItem) ) { + return GetCellType( item, subItem ); + } + return nullptr; +} + +CListCell * CListControlHeaderImpl::GetCellType( size_t item, size_t subItem ) const { + (void)item; (void)subItem; + return &PFC_SINGLETON(CListCell_Text); +} + +void CListControlHeaderImpl::RenderSubItemText(t_size item, t_size subItem,const CRect & subItemRect,const CRect & updateRect,CDCHandle dc, bool allowColors) { + (void)updateRect; + const auto cellType = GetCellType( item, subItem ); + if ( cellType == nullptr ) { + return; + } + pfc::string_formatter label; + const bool bHaveText = GetSubItemText(item,subItem,label); + if (! bHaveText ) { + label = ""; //sanity + } + + pfc::stringcvt::string_os_from_utf8_fast labelOS ( label ); + CListCell::DrawContentArg_t arg; + arg.darkMode = this->GetDarkMode(); + arg.hdrFormat = GetColumnFormat( subItem ); + arg.subItemRect = subItemRect; + arg.dc = dc; + arg.text = labelOS.get_ptr(); + arg.allowColors = allowColors; + bool bPressed; + if ( cellType->IsToggle() ) bPressed = this->GetCellCheckState(item, subItem); + else bPressed = (item == m_pressedItem) && (subItem == m_pressedSubItem); + bool bHot = (item == m_hotItem) && ( subItem == m_hotSubItem ); + if ( bPressed ) arg.cellState |= CListCell::cellState_pressed; + if ( bHot ) arg.cellState|= CListCell::cellState_hot; + arg.rcText = GetItemTextRectHook(item, subItem, subItemRect); + arg.rcHot = CellHotRect(item, subItem, cellType, subItemRect); + + auto strTheme = cellType->Theme(); + if ( strTheme != nullptr ) { + arg.theme = themeFor( strTheme ).m_theme; + } + arg.colorHighlight = GetSysColorHook(colorHighlight); + + arg.thisWnd = m_hWnd; + + if (this->IsSubItemGrayed( item, subItem ) ) { + arg.cellState |= CListCell::cellState_disabled; + } + + if (this->RenderCellImageTest(item, subItem)) { + arg.imageRenderer = [this, item, subItem](CDCHandle dc, const CRect& rc) { this->RenderCellImage(item, subItem, dc, rc); }; + } + + CFontHandle fontRestore; + CFont fontOverride; + + LOGFONT data; + if (dc.GetCurrentFont().GetLogFont(&data)) { + if ( cellType->ApplyTextStyle( data, CellTextScale(item, subItem ), arg.cellState ) ) { + if (fontOverride.CreateFontIndirect( & data )) { + fontRestore = dc.SelectFont( fontOverride ); + } + } + } + cellType->DrawContent( arg ); + + if ( fontRestore != NULL ) dc.SelectFont( fontRestore ); +} + +void CListControlHeaderImpl::RenderGroupHeaderText2(size_t baseItem,const CRect & headerRect,const CRect & updateRect,CDCHandle dc) { + (void)updateRect; + pfc::string_formatter label; + if (GetGroupHeaderText2(baseItem,label)) { + SelectObjectScope fontScope(dc,GetGroupHeaderFont()); + pfc::stringcvt::string_os_from_utf8 cvt(label); + CRect contentRect(GetItemTextRect(headerRect)); + dc.DrawText(cvt,(int)cvt.length(),contentRect,DT_NOPREFIX | DT_END_ELLIPSIS | DT_SINGLELINE | DT_VCENTER | DT_LEFT ); + SIZE txSize; + const int lineSpacing = contentRect.Height() / 2; + if (dc.GetTextExtent(cvt,(int)cvt.length(),&txSize)) { + if (txSize.cx + lineSpacing < contentRect.Width()) { + const CPoint center = contentRect.CenterPoint(); + const CPoint pt1(contentRect.left + txSize.cx + lineSpacing, center.y), pt2(contentRect.right, center.y); + const COLORREF lineColor = PaintUtils::BlendColor(dc.GetTextColor(),dc.GetBkColor(),25); + +#ifndef CListControl_ScrollWindowFix +#error FIXME CMemoryDC needed +#endif + PaintUtils::DrawSmoothedLine(dc, pt1, pt2, lineColor, 1.0 * (double)m_dpi.cy / 96.0); + } + } + } +} + +uint32_t CListControlHeaderImpl::GetOptimalColumnWidthFixed(const char * fixedText, bool pad) const { + CWindowDC dc(*this); + SelectObjectScope fontScope(dc, GetFont()); + GetOptimalWidth_Cache cache; + cache.m_dc = dc; + cache.m_stringTemp = fixedText; + uint32_t ret = cache.GetStringTempWidth(); + if ( pad ) ret += this->GetColumnSpacing() * 2; + return ret; +} + +t_uint32 CListControlHeaderImpl::GetOptimalSubItemWidth(t_size item, t_size subItem, GetOptimalWidth_Cache & cache) const { + const t_uint32 base = this->GetColumnSpacing() * 2; + if (GetSubItemText(item,subItem,cache.m_stringTemp)) { + return base + cache.GetStringTempWidth(); + } else { + return base; + } +} + +t_uint32 CListControlHeaderImpl::GetOptimalWidth_Cache::GetStringTempWidth() { + if (m_stringTemp.replace_string_ex(m_stringTempFixAmpersands, "&", "&&") > 0) { + m_convertTemp.convert(m_stringTempFixAmpersands); + } else { + m_convertTemp.convert(m_stringTemp); + } + return PaintUtils::TextOutColors_CalcWidth(m_dc, m_convertTemp); +} + +t_uint32 CListControlHeaderImpl::GetOptimalColumnWidth(t_size which, GetOptimalWidth_Cache & cache) const { + const t_size totalItems = GetItemCount(); + t_uint32 val = 0; + for(t_size item = 0; item < totalItems; ++item) { + pfc::max_acc( val, GetOptimalSubItemWidth( item, which, cache ) ); + } + return val; +} + +t_uint32 CListControlHeaderImpl::GetOptimalSubItemWidthSimple(t_size item, t_size subItem) const { + CWindowDC dc(*this); + SelectObjectScope fontScope(dc, GetFont() ); + GetOptimalWidth_Cache cache; + cache.m_dc = dc; + return GetOptimalSubItemWidth(item, subItem, cache); +} + +LRESULT CListControlHeaderImpl::OnKeyDown(UINT,WPARAM wp,LPARAM,BOOL& bHandled) { + switch(wp) { + case VK_ADD: + if (IsKeyPressed(VK_CONTROL)) { + AutoColumnWidths(); + return 0; + } + break; + } + bHandled = FALSE; + return 0; +} + +uint32_t CListControlHeaderImpl::GetOptimalColumnWidth(size_t colIndex) const { + CWindowDC dc(*this); + SelectObjectScope fontScope(dc, GetFont()); + GetOptimalWidth_Cache cache; + cache.m_dc = dc; + uint32_t ret = 0; + const auto itemCount = GetItemCount(); + for (t_size walk = 0; walk < itemCount; ++walk) { + pfc::max_acc(ret, GetOptimalSubItemWidth(walk, colIndex, cache)); + } + return ret; +} + +void CListControlHeaderImpl::AutoColumnWidths(const pfc::bit_array & mask, bool expandLast) { + PFC_ASSERT( IsHeaderEnabled() ); + if (!IsHeaderEnabled()) return; + const t_size itemCount = GetItemCount(); + if (itemCount == 0) return; + const t_size columnCount = (t_size) m_header.GetItemCount(); + if (columnCount == 0) return; + pfc::array_t widths; widths.set_size(columnCount); widths.fill_null(); + { + CWindowDC dc(*this); + SelectObjectScope fontScope(dc,GetFont()); + GetOptimalWidth_Cache cache; + cache.m_dc = dc; + for(t_size walk = 0; walk < itemCount; ++walk) { + for(t_size colWalk = mask.find_first(true,0,columnCount); colWalk < columnCount; colWalk = mask.find_next(true,colWalk,columnCount)) { + pfc::max_acc(widths[colWalk], GetOptimalSubItemWidth(walk,colWalk,cache)); + } + } + } + + // Enforce limit + for (auto& walk : widths) walk = columWidthToPixels(walk); + + if (expandLast) { + uint32_t usedWidth = 0; size_t lastCol = SIZE_MAX; + pfc::array_t order; order.set_size(columnCount); + WIN32_OP_D( m_header.GetOrderArray((int)columnCount,order.get_ptr()) ); + for(size_t _walk = 0; _walk < columnCount; ++_walk) { + const size_t colWalk = (size_t) order[_walk]; + PFC_ASSERT( colWalk < columnCount ); + if (mask[colWalk]) { + lastCol = colWalk; + usedWidth += widths[colWalk]; + } else { + usedWidth += GetSubItemWidth(colWalk); + } + } + if (lastCol != SIZE_MAX) { + t_uint32 clientWidth = this->GetClientRectHook().Width(); + if (clientWidth > 0) --clientWidth; // $!@# scrollbar hack + if (usedWidth < clientWidth) { + widths[lastCol] += clientWidth - usedWidth; + } + } + } + for(t_size colWalk = mask.find_first(true,0,columnCount); colWalk < columnCount; colWalk = mask.find_next(true,colWalk,columnCount)) { + ResizeColumn(colWalk,widths[colWalk],false); + } + ProcessColumnsChange(); +} + +t_uint32 CListControlHeaderImpl::GetOptimalGroupHeaderWidth2(size_t baseItem) const { + CWindowDC dc(*this); + SelectObjectScope fontScope(dc,GetGroupHeaderFont()); + GetOptimalWidth_Cache cache; cache.m_dc = dc; + const t_uint32 base = this->GetColumnSpacing() * 2; + if (GetGroupHeaderText2(baseItem,cache.m_stringTemp)) { + return base + cache.GetStringTempWidth(); + } else { + return base; + } +} + +size_t CListControlHeaderImpl::GetColumnCount() const { + if ( ! IsHeaderEnabled() ) return 1; +#if PFC_DEBUG + int iHeaderCount = m_header.GetItemCount(); + PFC_ASSERT( m_colRuntime.size() == (size_t) iHeaderCount ); +#endif + return m_colRuntime.size(); +} + +void CListControlHeaderImpl::ColumnWidthFix() { + if ( this->HaveAutoWidthColumns() ) { + ProcessAutoWidth(); + } else { + RecalcItemWidth(); + } +} + +void CListControlHeaderImpl::ProcessAutoWidth() { + if ( HaveAutoWidthColumns() ) { + const int clientWidth = this->GetClientRectHook().Width(); + + if ( ! this->HaveAutoWidthContentColumns( ) && clientWidth == m_itemWidth) return; + + const size_t count = GetColumnCount(); + uint32_t totalNonAuto = 0; + size_t numAutoWidth = 0; + for(size_t walk = 0; walk < count; ++ walk ) { + if ( m_colRuntime[walk].autoWidth() ) { + ++ numAutoWidth; + } else { + totalNonAuto += GetSubItemWidth(walk); + } + } + int toDivide = clientWidth - totalNonAuto; + if ( toDivide < 0 ) toDivide = 0; + + size_t numLeft = numAutoWidth; + auto worker = [&] ( size_t iCol ) { + auto & rt = m_colRuntime[iCol]; + int lo = this->GetOptimalColumnWidthFixed( rt.m_text.c_str() ); + if ( rt.autoWidthContent() ) { + int lo2 = this->GetOptimalColumnWidth( iCol ); + if ( lo < lo2 ) lo = lo2; + } + int width = (int)(toDivide / numLeft); + if ( width < lo ) width = lo; + + HDITEM item = {}; + item.mask = HDI_WIDTH; + item.cxy = width; + WIN32_OP_D( m_header.SetItem( (int) iCol, &item ) ); + rt.m_widthPixels = width; + + if ( toDivide > width ) { + toDivide -= width; + } else { + toDivide = 0; + } + -- numLeft; + + }; + for( size_t iCol = 0; iCol < count; ++ iCol ) { + if (m_colRuntime[iCol].autoWidthContent() ) worker(iCol); + } + for( size_t iCol = 0; iCol < count; ++ iCol ) { + if ( m_colRuntime[iCol].autoWidthPlain() ) worker(iCol); + } + + RecalcItemWidth(); + OnColumnsChanged(); + m_header.Invalidate(); + } +} + +void CListControlHeaderImpl::RecalcItemWidth() { + int total = 0; + const t_size count = GetColumnCount(); + for(t_size walk = 0; walk < count; ++walk) total += GetSubItemWidth(walk); + m_itemWidth = total; +} + +CRect CListControlHeaderImpl::GetSubItemRectAbs(t_size item,t_size subItem) const { + CRect rc = GetItemRectAbs(item); + auto order = GetColumnOrderArray(); + const t_size colCount = order.size(); + for(t_size _walk = 0; _walk < colCount; ++_walk) { + const t_size walk = (t_size) order[_walk]; + + t_size width = this->GetSubItemWidth(walk); + if (subItem == walk) { + + size_t span = GetSubItemSpan(item, walk); + if ( walk + span > colCount ) span = colCount - walk; + for( size_t extra = 1; extra < span; ++ extra ) { + width += GetSubItemWidth( walk + extra); + } + + rc.right = rc.left + (long)width; + + return rc; + } else { + rc.left += (long)width; + } + } + throw pfc::exception_invalid_params(); +} + +CRect CListControlHeaderImpl::GetSubItemRect(t_size item,t_size subItem) const { + return RectAbsToClient(GetSubItemRectAbs(item, subItem)); +} + +void CListControlHeaderImpl::SetHotItem(size_t row, size_t column) { + if ( m_hotItem != row || m_hotSubItem != column ) { + const size_t total = GetItemCount(); + if (m_hotItem < total) InvalidateRect(GetSubItemRect(m_hotItem, m_hotSubItem)); + m_hotItem = row; m_hotSubItem = column; + if (m_hotItem < total) InvalidateRect(GetSubItemRect(m_hotItem, m_hotSubItem)); + HotItemChanged(row, column); + } +} + +void CListControlHeaderImpl::SetPressedItem(size_t row, size_t column) { + if (m_pressedItem != row || m_pressedSubItem != column) { + if (m_pressedItem != SIZE_MAX) InvalidateRect(GetSubItemRect(m_pressedItem, m_pressedSubItem)); + m_pressedItem = row; m_pressedSubItem = column; + if (m_pressedItem != SIZE_MAX) InvalidateRect(GetSubItemRect(m_pressedItem, m_pressedSubItem)); + PressedItemChanged(row, column); + } +} + +void CListControlHeaderImpl::SetCellCheckState(size_t item, size_t subItem, bool value) { + ReloadItem(item); (void)subItem; (void)value; + // Subclass deals with keeping track of state +} + +bool CListControlHeaderImpl::ToggleSelectedItemsHook(const pfc::bit_array & mask) { + if (this->GetCellTypeSupported() ) { + bool handled = false; + bool setTo = true; + + mask.walk(GetItemCount(), [&](size_t idx) { + auto ct = this->GetCellType(idx, 0); + if ( ct != nullptr && ct->IsToggle() ) { + if ( ct->IsRadioToggle() ) { + if (!handled) { + handled = true; + setTo = !this->GetCellCheckState(idx, 0); + this->SetCellCheckState(idx, 0, setTo); + } + } else { + if (!handled) { + handled = true; + setTo = ! this->GetCellCheckState(idx,0); + } + this->SetCellCheckState(idx,0,setTo); + } + } + }); + + if (handled) return true; + } + return __super::ToggleSelectedItemsHook(mask); +} + +void CListControlHeaderImpl::OnSubItemClicked(t_size item, t_size subItem, CPoint pt) { + auto ct = GetCellType(item, subItem); + if (ct != nullptr) { + if (ct->IsToggle()) { + if (ct->HotRect(GetSubItemRect(item, subItem)).PtInRect(pt)) { + this->SetCellCheckState(item, subItem, !GetCellCheckState(item, subItem)); + } + } else if (ct->ClickToEdit()) { + this->RequestEditItem(item, subItem); + } + } +} + + +bool CListControlHeaderImpl::AllowTypeFindInCell(size_t item, size_t subItem) const { + auto cell = GetCellType( item, subItem ); + if ( cell == nullptr ) return false; + return cell->AllowTypeFind(); +} + +bool CListControlHeaderImpl::CellTypeReactsToMouseOver(cellType_t ct) { + return ct != nullptr && ct->IsInteractive(); +} + +CRect CListControlHeaderImpl::CellHotRect( size_t, size_t, cellType_t ct, CRect rcCell) { + if ( ct != nullptr ) { + return ct->HotRect(rcCell); + } + return rcCell; +} +CRect CListControlHeaderImpl::CellHotRect(size_t item, size_t subItem, cellType_t ct) { + return CellHotRect( item, subItem, ct, GetSubItemRect( item, subItem ) ); +} +void CListControlHeaderImpl::OnMouseMove(UINT nFlags, CPoint pt) { + const DWORD maskButtons = MK_LBUTTON | MK_RBUTTON | MK_MBUTTON | MK_XBUTTON1 | MK_XBUTTON2; + if (GetCellTypeSupported() && (nFlags & maskButtons) == 0 ) { + size_t item; size_t subItem; + if (this->GetItemAtPointAbsEx( PointClientToAbs(pt), item, subItem)) { + auto ct = this->GetCellType( item, subItem ); + if (CellTypeReactsToMouseOver(ct) ) { + auto rc = CellHotRect( item, subItem, ct ); + if ( PtInRect( rc, pt ) ) { + const bool bTrack = ct != nullptr && ct->TracksMouseMove(); + SetHotItem(item, subItem); + + if (bTrack) this->CellTrackMouseMove(item, subItem, WM_MOUSEMOVE, nFlags, pt); + + mySetCapture([=](UINT msg, DWORD newStatus, CPoint pt) { + if (msg == WM_MOUSELEAVE) { + this->ClearHotItem(); + return false; + } + + if ((newStatus & maskButtons) != 0 || msg == WM_MOUSEWHEEL || msg == WM_MOUSEHWHEEL ) { + // A button has been pressed or wheel has been moved + this->ClearHotItem(); + mySetCaptureMsgHandled(FALSE); + return false; + } + + if ( ! PtInRect( rc, pt ) || item >= GetItemCount() ) { + // Left the rect + this->ClearHotItem(); + this->mySetCaptureMsgHandled(FALSE); + return false; + } + if (bTrack) { + this->CellTrackMouseMove(item, subItem, msg, newStatus, pt); + } + + return true; + }); + } + } + } + } + SetMsgHandled(FALSE); +} + +bool CListControlHeaderImpl::AllowScrollbar(bool vertical) const { + if ( vertical ) { + // vertical + return true; + } else { + // horizontal + if (! IsHeaderEnabled( ) ) return false; // no header? + return true; + } +} + +void CListControlHeaderImpl::OnDestroy() { + m_colRuntime.clear(); + m_header = NULL; + m_headerLine = NULL; + m_headerDark = false; + SetMsgHandled(FALSE); +} + + +uint32_t CListControlHeaderImpl::GetColumnsBlankWidth( size_t colExclude ) const { + auto client = this->GetClientRectHook().Width(); + int item = GetItemWidth(); + if (colExclude) item -= GetSubItemWidth(colExclude); + if ( item < 0 ) item = 0; + if ( item < client ) return (uint32_t)( client - item ); + else return 0; +} + +void CListControlHeaderImpl::SizeColumnToContent( size_t which, uint32_t minWidth ) { + auto width = this->GetOptimalColumnWidth( which ); + if ( width < minWidth ) width = minWidth; + this->ResizeColumn( which, width ); +} + +void CListControlHeaderImpl::SizeColumnToContentFillBlank( size_t which ) { + this->SizeColumnToContent( which, this->GetColumnsBlankWidth(which) ); +} + +HBRUSH CListControlHeaderImpl::OnCtlColorStatic(CDCHandle dc, CStatic wndStatic) { + if ( wndStatic == m_headerLine ) { + COLORREF col = GridColor(); + dc.SetDCBrushColor( col ); + return (HBRUSH) GetStockObject(DC_BRUSH); + } + SetMsgHandled(FALSE); + return NULL; +} + +void CListControlHeaderImpl::ReloadData() { + __super::ReloadData(); + if ( this->HaveAutoWidthContentColumns( ) ) { + this->ColumnWidthFix(); + } +} + +void CListControlHeaderImpl::RenderGroupOverlay(size_t baseItem, const CRect& p_groupWhole, const CRect& p_updateRect, CDCHandle dc) { + CRect subItemRect = p_groupWhole; + t_uint32 xWalk = p_groupWhole.left; + auto order = GetColumnOrderArray(); + const size_t cCount = order.size(); + for (t_size _walk = 0; _walk < cCount; ) { + const t_size walk = order[_walk]; + + t_uint32 width = GetSubItemWidth(walk); + + subItemRect.left = xWalk; subItemRect.right = xWalk + width; + CRect subUpdate; + if (subUpdate.IntersectRect(subItemRect, p_updateRect)) { + DCStateScope scope(dc); + if (dc.IntersectClipRect(subItemRect) != NULLREGION) { + this->RenderGroupOverlayColumn(baseItem, walk, subItemRect, subUpdate, dc); + } + } + xWalk += width; + + _walk += 1; + } +} + +void CListControlHeaderImpl::UpdateGroupOverlayColumnByID(groupID_t groupID, size_t subItem) { + if (this->GetItemCount() == 0) return; + CRect rc = this->GetSubItemRectAbs(0, subItem); + this->UpdateGroupOverlayByID(groupID, rc.left, rc.right); +} + +void CListControlHeaderImpl::mySetCapture(CaptureProc_t proc) { + this->m_captureProc = proc; + this->TrackMouseLeave(); +} + +void CListControlHeaderImpl::myReleaseCapture() { + m_captureProc = nullptr; +} + +void CListControlHeaderImpl::TrackMouseLeave() { + TRACKMOUSEEVENT tme = { sizeof(tme) }; + tme.dwFlags = TME_LEAVE; + tme.hwndTrack = m_hWnd; + TrackMouseEvent(&tme); +} + +LRESULT CListControlHeaderImpl::MousePassThru(UINT msg, WPARAM wp, LPARAM lp) { + auto p = m_captureProc; // create local ref in case something in mid-captureproc clears it + if (p) { + CPoint pt(lp); + if (!p(msg, (DWORD)wp, pt)) { + myReleaseCapture(); + } + return 0; + } + + SetMsgHandled(FALSE); + return 0; +} + +void CListControlHeaderImpl::OnMouseLeave() { + if (m_captureProc) { + m_captureProc(WM_MOUSELEAVE, 0, -1); + myReleaseCapture(); + } +} + +void CListControlHeaderImpl::OnKillFocus(CWindow) { + myReleaseCapture(); + SetMsgHandled(FALSE); +} + +void CListControlHeaderImpl::OnWindowPosChanged(LPWINDOWPOS arg) { + if (arg->flags & SWP_HIDEWINDOW) { + myReleaseCapture(); + } + SetMsgHandled(FALSE); +} + +void CListControlHeaderImpl::RequestEditItem(size_t, size_t) { + PFC_ASSERT(!"Please enable CListControl_EditImpl"); +} + +void CListControlHeaderImpl::OnLButtonDblClk(UINT nFlags, CPoint point) { + (void)nFlags; + if (this->GetCellTypeSupported()) { + auto ptAbs = PointClientToAbs(point); + size_t item = this->ItemFromPointAbs(ptAbs); + size_t subItem = SubItemFromPointAbs(ptAbs); + if (item != SIZE_MAX && subItem != SIZE_MAX) { + auto ct = GetCellType(item, subItem); + if (ct != nullptr) { + if (ct->IsToggle()) { + if (ct->HotRect(GetSubItemRect(item, subItem)).PtInRect(point)) { + return; // disregard doubleclick on checkbox + } + } + } + } + } + SetMsgHandled(FALSE); // handle doubleclick +} + + +void CListControlHeaderImpl::RenderItemBackground(CDCHandle p_dc, const CRect& p_itemRect, size_t item, uint32_t bkColor) { + if (!this->DelimitColumns()) { + __super::RenderItemBackground(p_dc, p_itemRect, item, bkColor); + } else { + auto cnt = this->GetColumnCount(); + const auto order = this->GetColumnOrderArray(); + uint32_t x = p_itemRect.left; + for (size_t walk = 0; walk < cnt; ) { + const size_t sub = order[walk]; + auto span = this->GetSubItemSpan(item, sub); + PFC_ASSERT(span > 0); + uint32_t width = 0; + for (size_t walk2 = 0; walk2 < span; ++walk2) { + width += this->GetSubItemWidth(sub + walk2); + } + CRect rc = p_itemRect; + rc.left = x; + x += width; + rc.right = x; + + CRect test; + if (test.IntersectRect(rc, p_itemRect)) { + DCStateScope s(p_dc); + if (p_dc.IntersectClipRect(rc) != NULLREGION) { + __super::RenderItemBackground(p_dc, rc, item, bkColor); + } + } + walk += span; + } + } +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/CListControlHeaderImpl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/CListControlHeaderImpl.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,266 @@ +#pragma once + +class CListCell; + +class CListControlHeaderImpl : public CListControlFontOps { +private: + typedef CListControlFontOps TParent; +public: + CListControlHeaderImpl() {} + + BEGIN_MSG_MAP_EX(CListControlHeaderImpl) + MSG_WM_THEMECHANGED(OnThemeChangedPT) + MSG_WM_LBUTTONDBLCLK(OnLButtonDblClk) + MESSAGE_RANGE_HANDLER_EX(WM_MOUSEFIRST, WM_MOUSELAST, MousePassThru); + MSG_WM_MOUSELEAVE(OnMouseLeave) + MSG_WM_CTLCOLORSTATIC(OnCtlColorStatic); + MESSAGE_HANDLER(WM_KEYDOWN,OnKeyDown); + MESSAGE_HANDLER(WM_SYSKEYDOWN,OnKeyDown); + MESSAGE_HANDLER_EX(WM_SIZE,OnSizePassThru); + NOTIFY_CODE_HANDLER(HDN_ITEMCHANGED,OnHeaderItemChanged); + NOTIFY_CODE_HANDLER(HDN_ENDDRAG,OnHeaderEndDrag); + NOTIFY_CODE_HANDLER(HDN_ITEMCLICK,OnHeaderItemClick); + NOTIFY_CODE_HANDLER(HDN_DIVIDERDBLCLICK,OnDividerDoubleClick); + NOTIFY_CODE_HANDLER_EX(NM_CUSTOMDRAW, OnHeaderCustomDraw); + MSG_WM_SETCURSOR(OnSetCursor); + MSG_WM_MOUSEMOVE(OnMouseMove) + MSG_WM_DESTROY(OnDestroy) + MSG_WM_ENABLE(OnEnable) + MSG_WM_KILLFOCUS(OnKillFocus) + MSG_WM_WINDOWPOSCHANGED(OnWindowPosChanged) + CHAIN_MSG_MAP(TParent) + END_MSG_MAP() + + typedef uint32_t cellState_t; + typedef CListCell * cellType_t; + + int GetHeaderItemWidth( int which ); + void InitializeHeaderCtrl(DWORD flags = HDS_FULLDRAG); + void InitializeHeaderCtrlSortable() {InitializeHeaderCtrl(HDS_FULLDRAG | HDS_BUTTONS);} + CHeaderCtrl GetHeaderCtrl() const {return m_header;} + void SetSortIndicator( size_t whichColumn, bool isUp ); + void ClearSortIndicator(); + + bool IsHeaderEnabled() const {return m_header.m_hWnd != NULL;} + void ResetColumns(bool update = true); + + static constexpr uint32_t columnWidthMax = (uint32_t)INT32_MAX, + columnWidthAuto = UINT32_MAX, + columnWidthAutoUseContent = UINT32_MAX - 1; + + void AddColumn(const char * label, uint32_t widthPixels, DWORD fmtFlags = HDF_LEFT,bool update = true); + //! Extended AddColumn, specifies width in pixels @ 96DPI instead of screen-specific pixels + void AddColumnEx( const char * label, uint32_t widthPixelsAt96DPI, DWORD fmtFlags = HDF_LEFT, bool update = true ); + //! Extended AddColumn, specifies width in Dialog Length Units (DLU), assumes parent of this list to be a dialog window. + void AddColumnDLU( const char * label, uint32_t widthDLU, DWORD fmtFlags = HDF_LEFT, bool update = true ); + //! Extended AddColumn, specifies width as floating-point value of pixels at 96DPI. \n + //! For DPI-safe storage of user's column widths. + void AddColumnF( const char * label, float widthF, DWORD fmtFlags = HDF_LEFT, bool update = true ); + void AddColumnAutoWidth( const char * label, DWORD fmtFlags = HDF_LEFT, bool bUpdate = true) { AddColumn(label, columnWidthAuto, fmtFlags, bUpdate); } + bool DeleteColumn(size_t index, bool updateView = true); + void DeleteColumns( pfc::bit_array const & mask, bool updateView = true); + void ResizeColumn(t_size index, t_uint32 widthPixels, bool updateView = true); + void SetColumn( size_t which, const char * title, DWORD fmtFlags = HDF_LEFT, bool updateView = true); + void GetColumnText(size_t which, pfc::string_base & out) const; + + uint32_t GetOptimalColumnWidth( size_t index ) const; + uint32_t GetOptimalColumnWidthFixed( const char * fixedText, bool pad = true) const; + uint32_t GetColumnsBlankWidth( size_t colExclude = SIZE_MAX ) const; + void SizeColumnToContent( size_t which, uint32_t minWidth ); + void SizeColumnToContentFillBlank( size_t which ); + + //! If creating a custom headerless multi column scheme, override these to manipulate your columns + virtual size_t GetColumnCount() const; + virtual uint32_t GetSubItemWidth(size_t subItem) const; + //! Returns column width as a floating-point value of pixels at 96DPI. \n + //! For DPI-safe storage of user's column widths. + float GetColumnWidthF( size_t subItem ) const; + //! Indicate how many columns a specific row/column cell spans\n + //! This makes sense only if the columns can't be user-reordered + virtual size_t GetSubItemSpan(size_t row, size_t column) const; + + t_size GetSubItemOrder(t_size subItem) const; + int GetItemWidth() const override; + + void SetHeaderFont(HFONT font); +protected: + CRect GetClientRectHook() const override; + void RenderBackground(CDCHandle dc, CRect const& rc) override; + + struct GetOptimalWidth_Cache { + //! For temporary use. + pfc::string8_fastalloc m_stringTemp, m_stringTempFixAmpersands; + //! For temporary use. + pfc::stringcvt::string_wide_from_utf8_t m_convertTemp; + //! Our DC for measuring text. Correct font pre-selected. + CDCHandle m_dc; + + t_uint32 GetStringTempWidth(); + }; + + void UpdateHeaderLayout(); + void OnViewOriginChange(CPoint p_delta) override; + void RenderItemText(t_size item,const CRect & itemRect,const CRect & updateRect,CDCHandle dc, bool allowColors) override; + void RenderGroupHeaderText2(size_t baseItem,const CRect & headerRect,const CRect & updateRect,CDCHandle dc) override; + void RenderGroupOverlay(size_t baseItem, const CRect& p_groupWhole, const CRect& p_updateRect, CDCHandle p_dc) override; + void UpdateGroupOverlayColumnByID(groupID_t groupID, size_t subItem); + + //! Converts an item/subitem rect to a rect in which the text should be rendered, removing spacing to the left/right of the text. + virtual CRect GetItemTextRectHook(size_t item, size_t subItem, CRect const & itemRect) const; + CRect GetItemTextRect(CRect const & itemRect) const; + //! Override for custom spacing to the left/right of the text in each column. + virtual t_uint32 GetColumnSpacing() const {return MulDiv(4,m_dpi.cx,96);} + //! Override for column-header-click sorting. + virtual void OnColumnHeaderClick(t_size index) { (void)index; } + //! Override to supply item labels. + virtual bool GetSubItemText(t_size item, t_size subItem, pfc::string_base& out) const { (void)item; (void)subItem; (void)out; return false; } + //! Override if you support groups. + virtual bool GetGroupHeaderText2(size_t baseItem, pfc::string_base& out) const { (void)baseItem; (void)out; return false; } + //! Override optionally. + virtual void RenderSubItemText(t_size item, t_size subItem,const CRect & subItemRect,const CRect & updateRect,CDCHandle dc, bool allowColors); + virtual void RenderGroupOverlayColumn(size_t baseItem, size_t subItem, const CRect& p_groupWhole, const CRect& p_updateRect, CDCHandle p_dc) { (void)baseItem; (void)subItem; (void)p_groupWhole; (void)p_updateRect; (void)p_dc; } + + virtual void OnColumnsChanged(); + + virtual t_uint32 GetOptimalSubItemWidth(t_size item, t_size subItem, GetOptimalWidth_Cache & cache) const; + + virtual t_uint32 GetOptimalGroupHeaderWidth2(size_t baseItem) const; + + + bool GetItemAtPointAbsEx( CPoint pt, size_t & outItem, size_t & outSubItem ) const; + cellType_t GetCellTypeAtPointAbs( CPoint pt ) const; + virtual cellType_t GetCellType( size_t item, size_t subItem ) const; + virtual bool AllowTypeFindInCell( size_t item, size_t subItem ) const; + virtual bool GetCellTypeSupported() const { return false; } // optimization hint, some expensive checks can be suppressed if cell types are not used for this view + virtual bool GetCellCheckState(size_t item, size_t subItem) const { (void)item; (void)subItem; return false; } + virtual void SetCellCheckState(size_t item, size_t subItem, bool value); + virtual bool ToggleSelectedItemsHook(const pfc::bit_array & mask) override; + + virtual bool RenderCellImageTest(size_t item, size_t subItem) const { (void)item; (void)subItem; return false; } + virtual void RenderCellImage(size_t item, size_t subItem, CDCHandle, const CRect&) const { (void)item; (void)subItem; } + + t_uint32 GetOptimalColumnWidth(t_size which, GetOptimalWidth_Cache & cache) const; + t_uint32 GetOptimalSubItemWidthSimple(t_size item, t_size subItem) const; + + void AutoColumnWidths(const pfc::bit_array & mask,bool expandLast = false); + void AutoColumnWidths() {AutoColumnWidths(pfc::bit_array_true());} + void AutoColumnWidth(t_size which) {AutoColumnWidths(pfc::bit_array_one(which));} + + virtual bool OnColumnHeaderDrag(t_size index, t_size newOrder); + + void OnItemClicked(t_size item, CPoint pt) override; + virtual void OnSubItemClicked(t_size item, t_size subItem,CPoint pt); + bool OnClickedSpecialHitTest(CPoint pt) override; + bool OnClickedSpecial(DWORD status, CPoint pt) override; + static bool CellTypeUsesSpecialHitTests( cellType_t ct ); + + + CRect GetSubItemRectAbs(t_size item,t_size subItem) const; + CRect GetSubItemRect(t_size item,t_size subItem) const; + + t_size SubItemFromPointAbs(CPoint pt) const; + + static bool CellTypeReactsToMouseOver( cellType_t ct ); + virtual CRect CellHotRect( size_t item, size_t subItem, cellType_t ct, CRect rcCell ); + CRect CellHotRect( size_t item, size_t subItem, cellType_t ct ); + virtual double CellTextScale(size_t item, size_t subItem) { (void)item; (void)subItem; return 1; } + virtual bool IsSubItemGrayed(size_t item, size_t subItem) { (void)item; (void)subItem; return !this->IsWindowEnabled(); } + + virtual void CellTrackMouseMove(size_t item, size_t subItem, UINT msg, DWORD status, CPoint pt) { (void)item; (void)subItem; (void)msg; (void)status; (void)pt; } + + // HDF_* constants for this column, override when not using list header control. Used to control text alignment. + virtual DWORD GetColumnFormat(t_size which) const; + void SetColumnFormat(t_size which,DWORD format); + void SetColumnSort(t_size which, bool isUp); + + std::vector GetColumnOrderArray() const; + + bool AllowScrollbar(bool vertical) const override; + + void RenderItemBackground(CDCHandle p_dc,const CRect & p_itemRect,size_t item, uint32_t bkColor) override; + + void ColumnWidthFix(); // Call RecalcItemWidth() / ProcessAutoWidth() + + void ReloadData() override; + + size_t HotItem() const { return m_hotItem; } + size_t HotSubItem() const { return m_hotSubItem; } + + virtual void RequestEditItem(size_t item, size_t subItem); +private: + void OnLButtonDblClk(UINT nFlags, CPoint point); + void OnThemeChangedPT(); + void OnEnable(BOOL) { Invalidate(); } + HBRUSH OnCtlColorStatic(CDCHandle dc, CStatic wndStatic); + void ProcessColumnsChange() { OnColumnsChanged();} + LRESULT OnSizePassThru(UINT,WPARAM,LPARAM); + LRESULT OnHeaderItemClick(int,LPNMHDR,BOOL&); + LRESULT OnHeaderCustomDraw(LPNMHDR); + LRESULT OnDividerDoubleClick(int,LPNMHDR,BOOL&); + LRESULT OnHeaderItemChanged(int,LPNMHDR,BOOL&); + LRESULT OnHeaderEndDrag(int,LPNMHDR,BOOL&); + LRESULT OnKeyDown(UINT,WPARAM,LPARAM,BOOL&); + void OnDestroy(); + BOOL OnSetCursor(CWindow wnd, UINT nHitTest, UINT message); + void OnMouseMove(UINT nFlags, CPoint point); + + void RecalcItemWidth(); // FIXED width math + void ProcessAutoWidth(); // DYNAMIC width math + + bool m_ownColumnsChange = false; + + int m_itemWidth = 0; + int m_clientWidth = 0; + CHeaderCtrl m_header; + bool m_headerDark = false; + CStatic m_headerLine; + + bool HaveAutoWidthColumns() const; + bool HaveAutoWidthContentColumns() const; + + struct colRuntime_t { + bool m_autoWidth = false; + bool m_autoWidthContent = false; + int m_widthPixels = 0; + uint32_t m_userWidth = 0; + std::string m_text; + + bool autoWidth() const { return m_userWidth > columnWidthMax; } + bool autoWidthContent() const { return m_userWidth == columnWidthAutoUseContent; } + bool autoWidthPlain() const { return m_userWidth == columnWidthAuto; } + }; + + std::vector m_colRuntime; + + + //for group headers + GdiplusScope m_gdiPlusScope; + + void SetPressedItem(size_t row, size_t column); + void ClearPressedItem() {SetPressedItem(SIZE_MAX, SIZE_MAX);} + void SetHotItem( size_t row, size_t column ); + void ClearHotItem() { SetHotItem(SIZE_MAX, SIZE_MAX); } + + virtual void HotItemChanged(size_t row, size_t column) { (void)row; (void)column; } + virtual void PressedItemChanged(size_t row, size_t column) { (void)row; (void)column; } + + size_t m_pressedItem = SIZE_MAX, m_pressedSubItem = SIZE_MAX; + size_t m_hotItem = SIZE_MAX, m_hotSubItem = SIZE_MAX; + +private: + // ==== mySetCapture stuff ==== + // SetCapture()-like functionality used for tracking of hot fields. + // Not a part of the API, do not reuse in subclasses. + void mySetCapture(CaptureProc_t proc); + void myReleaseCapture(); + + void TrackMouseLeave(); + + void mySetCaptureMsgHandled(BOOL v) { this->SetMsgHandled(v); } + CaptureProc_t m_captureProc; + + void OnMouseLeave(); + void OnKillFocus(CWindow); + void OnWindowPosChanged(LPWINDOWPOS); + LRESULT MousePassThru(UINT, WPARAM, LPARAM); +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/CListControlOwnerData.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/CListControlOwnerData.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,239 @@ +#pragma once + +// ================================================================================ +// CListControlOwnerData +// ================================================================================ +// Forwards all list data retrieval and manipulation calls to a host object. +// Not intended for subclassing, just implement IListControlOwnerDataSource methods +// in your class. +// ================================================================================ + +#include "CListControlComplete.h" + +class CListControlOwnerData; + +class IListControlOwnerDataSource { +public: + typedef const CListControlOwnerData * ctx_t; + + + virtual size_t listGetItemCount( ctx_t ) = 0; + virtual pfc::string8 listGetSubItemText( ctx_t, size_t item, size_t subItem ) = 0; + virtual bool listCanReorderItems( ctx_t ) { return false; } + virtual bool listReorderItems( ctx_t, const size_t*, size_t) {return false;} + virtual bool listRemoveItems( ctx_t, pfc::bit_array const & ) {return false;} + virtual void listItemAction(ctx_t, size_t) {} + virtual void listSubItemClicked( ctx_t, size_t, size_t ) {} + virtual bool listCanSelectItem( ctx_t, size_t ) { return true; } + virtual pfc::string8 listGetEditField(ctx_t ctx, size_t item, size_t subItem, size_t & lineCount) { + lineCount = 1; return listGetSubItemText( ctx, item, subItem); + } + virtual void listSetEditField(ctx_t ctx, size_t item, size_t subItem, const char * val) {} + // Returns InPlaceEdit::KFlag* + virtual uint32_t listGetEditFlags(ctx_t ctx, size_t item, size_t subItem) {return 0;} + typedef InPlaceEdit::CTableEditHelperV2::autoComplete_t autoComplete_t; + typedef InPlaceEdit::CTableEditHelperV2::combo_t combo_t; + virtual autoComplete_t listGetAutoComplete(ctx_t, size_t item, size_t subItem) {return autoComplete_t();} + virtual combo_t listGetCombo(ctx_t, size_t item, size_t subItem) { return combo_t(); } + + virtual bool listIsColumnEditable( ctx_t, size_t ) { return false; } + virtual bool listKeyDown(ctx_t, UINT nChar, UINT nRepCnt, UINT nFlags) { return false; } + virtual bool listKeyUp(ctx_t, UINT nChar, UINT nRepCnt, UINT nFlags) { return false; } + + // Allow type-find in this view? + // Called prior to a typefind pass attempt, you can either deny entirely, or prepare any necessary data and allow it. + virtual bool listAllowTypeFind( ctx_t ) { return true; } + // Allow type-find in a specific item/column? + virtual bool listAllowTypeFindHere( ctx_t, size_t item, size_t subItem ) { return true ;} + + virtual void listColumnHeaderClick(ctx_t, size_t subItem) {} + + virtual void listBeforeDrawItemText( ctx_t, size_t item, CDCHandle dc ) {} + virtual bool listIsSubItemGrayed(ctx_t, size_t item, size_t subItem) { return false; } + + virtual void listSelChanged(ctx_t) {} + virtual void listFocusChanged(ctx_t) {} + + virtual void listColumnsChanged(ctx_t) {} + + virtual bool listEditCanAdvanceHere(ctx_t, size_t item, size_t subItem, uint32_t whatHappened) {(void) item; (void) subItem, (void) whatHappened; return true;} + + virtual uint32_t listQueryDragDropTypes(ctx_t) const { return 0; } + virtual DWORD listDragDropAccept(ctx_t, IDataObject* obj, bool& showDropMark) { return DROPEFFECT_NONE; } + virtual pfc::com_ptr_t listMakeDataObject(ctx_t) {return nullptr;} + virtual void listOnDrop(ctx_t,IDataObject* obj, CPoint pt) {} + virtual DWORD listDragDropSourceEffects(ctx_t) { return DROPEFFECT_MOVE | DROPEFFECT_COPY; } + virtual void listDragDropSourceSucceeded(ctx_t,DWORD effect) {} + + virtual CListControl::groupID_t listItemGroup(ctx_t, size_t) { return 0; } + virtual pfc::string8 listGroupText(ctx_t, size_t /*baseItem*/) { return ""; } +}; + +class IListControlOwnerDataCells { +public: + typedef const CListControlOwnerData * cellsCtx_t; + virtual CListControl::cellType_t listCellType( cellsCtx_t, size_t item, size_t subItem ) = 0; + virtual size_t listCellSpan( cellsCtx_t, size_t item, size_t subItem ) {return 1;} + virtual bool listCellCheckState( cellsCtx_t, size_t item, size_t subItem ) {return false; } + virtual void listCellSetCheckState( cellsCtx_t, size_t item, size_t subItem, bool state ) {} +}; + +class CListControlOwnerData : public CListControlComplete { +public: + IListControlOwnerDataSource* const m_host; + size_t m_listControlOwnerDataTag = 0; + CListControlOwnerData( IListControlOwnerDataSource * h) : m_host(h) {} + + BEGIN_MSG_MAP_EX(CListControlOwnerData) + MSG_WM_KEYDOWN(OnKeyDown) + MSG_WM_KEYUP(OnKeyUp) + MSG_WM_SYSKEYDOWN(OnKeyDown) + MSG_WM_SYSKEYUP(OnKeyUp) + CHAIN_MSG_MAP(CListControlComplete) + END_MSG_MAP() + + using CListControl_EditImpl::TableEdit_Abort; + using CListControl_EditImpl::TableEdit_Start; + using CListControl_EditImpl::TableEdit_IsActive; + + bool CanSelectItem( size_t idx ) const override { + return m_host->listCanSelectItem( this, idx ); + } + size_t GetItemCount() const override { + return m_host->listGetItemCount( this ); + } + bool GetSubItemText(size_t item, size_t subItem, pfc::string_base & out) const override { + out = m_host->listGetSubItemText( this, item, subItem ); + return true; + } + void OnSubItemClicked( size_t item, size_t subItem, CPoint pt ) override { + __super::OnSubItemClicked(item, subItem, pt); // needed to toggle checkboxes etc + m_host->listSubItemClicked( this, item, subItem ); + } + + uint32_t QueryDragDropTypes() const override { + uint32_t ret = (m_host->listCanReorderItems(this)) ? dragDrop_reorder : 0; + ret |= m_host->listQueryDragDropTypes(this); + return ret; + } + + void RequestReorder( const size_t * order, size_t count) override { + if ( ! m_host->listReorderItems( this, order, count )) return; + this->OnItemsReordered( order, count ); + } + void RequestRemoveSelection() override { + auto mask = this->GetSelectionMask(); + size_t oldCount = GetItemCount(); + if ( ! m_host->listRemoveItems( this, mask ) ) return; + this->OnItemsRemoved( mask, oldCount ); + } + void ExecuteDefaultAction( size_t idx ) override { + m_host->listItemAction( this, idx ); + } + size_t EvalTypeFind() override { + if (! m_host->listAllowTypeFind(this) ) return SIZE_MAX; + return __super::EvalTypeFind(); + } + bool AllowTypeFindInCell( size_t item, size_t subItem ) const { + return __super::AllowTypeFindInCell( item, subItem ) && m_host->listAllowTypeFindHere( this, item, subItem ); + } + + groupID_t GetItemGroup(t_size p_item) const override { + return m_host->listItemGroup(this, p_item); + } + bool GetGroupHeaderText2(size_t baseItem, pfc::string_base& out) const override { + out = m_host->listGroupText(this, baseItem); + return true; + } +protected: + void OnFocusChanged(size_t oldFocus, size_t newFocus) override { + __super::OnFocusChanged(oldFocus, newFocus); + m_host->listFocusChanged(this); + } + void OnSelectionChanged(pfc::bit_array const & affected, pfc::bit_array const & status) { + __super::OnSelectionChanged(affected, status); + m_host->listSelChanged(this); + } + + void RenderItemText(t_size p_item,const CRect & p_itemRect,const CRect & p_updateRect,CDCHandle p_dc, bool allowColors) { + m_host->listBeforeDrawItemText(this, p_item, p_dc ); + __super::RenderItemText(p_item, p_itemRect, p_updateRect, p_dc, allowColors); + } + void TableEdit_SetField(t_size item, t_size subItem, const char * value) override { + m_host->listSetEditField(this, item, subItem, value); + } + void TableEdit_GetField(t_size item, t_size subItem, pfc::string_base & out, t_size & lineCount) override { + lineCount = 1; + out = m_host->listGetEditField(this, item, subItem, lineCount); + } + + t_uint32 TableEdit_GetEditFlags(t_size item, t_size subItem) const override { + auto ret = __super::TableEdit_GetEditFlags(item, subItem); + ret |= m_host->listGetEditFlags( this, item, subItem ); + return ret; + } + + combo_t TableEdit_GetCombo(size_t item, size_t subItem) override { + return m_host->listGetCombo(this, item, subItem); + } + autoComplete_t TableEdit_GetAutoCompleteEx(t_size item, t_size subItem) override { + return m_host->listGetAutoComplete( this, item, subItem ); + } + bool TableEdit_IsColumnEditable(t_size subItem) const override { + return m_host->listIsColumnEditable( this, subItem ); + } + void OnColumnHeaderClick(t_size index) override { + m_host->listColumnHeaderClick(this, index); + } + void OnColumnsChanged() override { + __super::OnColumnsChanged(); + m_host->listColumnsChanged(this); + } + bool IsSubItemGrayed(size_t item, size_t subItem) override { + return __super::IsSubItemGrayed(item, subItem) || m_host->listIsSubItemGrayed(this, item, subItem); + } + + DWORD DragDropAccept(IDataObject* obj, bool& showDropMark) override { return m_host->listDragDropAccept(this, obj, showDropMark); } + pfc::com_ptr_t MakeDataObject() override { + auto ret = m_host->listMakeDataObject(this); + if (ret.is_empty()) ret = __super::MakeDataObject(); + return ret; + } + void OnDrop(IDataObject* obj, CPoint pt) override { return m_host->listOnDrop(this, obj, pt); } + DWORD DragDropSourceEffects() override { return m_host->listDragDropSourceEffects(this); } + void DragDropSourceSucceeded(DWORD effect) override { m_host->listDragDropSourceSucceeded(this, effect); } + +private: + bool TableEdit_CanAdvanceHere( size_t item, size_t subItem, uint32_t whatHappened ) const override { + return m_host->listEditCanAdvanceHere(this, item, subItem, whatHappened); + } + void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { + bool handled = m_host->listKeyDown(this, nChar, nRepCnt, nFlags); + SetMsgHandled( !! handled ); + } + void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) { + bool handled = m_host->listKeyUp(this, nChar, nRepCnt, nFlags); + SetMsgHandled( !! handled ); + } +}; + +class CListControlOwnerDataCells : public CListControlOwnerData { + IListControlOwnerDataCells * const m_cells; +public: + CListControlOwnerDataCells( IListControlOwnerDataSource * source, IListControlOwnerDataCells * cells ) : CListControlOwnerData(source), m_cells(cells) {} + + bool GetCellTypeSupported() const override {return true; } + bool GetCellCheckState( size_t item, size_t subItem ) const override { + return m_cells->listCellCheckState( this, item, subItem ); + } + void SetCellCheckState( size_t item, size_t subItem, bool value ) override { + m_cells->listCellSetCheckState( this, item, subItem, value ); + __super::SetCellCheckState(item, subItem, value); + } + cellType_t GetCellType( size_t item, size_t subItem ) const override { + return m_cells->listCellType( this, item, subItem ); + } + size_t GetSubItemSpan(size_t row, size_t column) const override { + return m_cells->listCellSpan( this, row, column ); + } +}; \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/CListControlSimple.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/CListControlSimple.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,176 @@ +#pragma once + +// ================================================================================ +// CListControlSimple +// Simplified CListControl interface; a ready-to-use class that can be instantiated +// without subclassing or setting callback objects. +// Use when you don't need advanced features such as buttons or editing. +// Maintains its own data. +// ================================================================================ + +#include "CListControlComplete.h" + +#include +#include +#include +#include +#include + + +class CListControlSimple : public CListControlReadOnly { +public: + // Events + std::function onReordered; // if not set, list reordering is disabled + std::function onRemoved; // if not set, list item removal is disabled + std::function onItemAction; // optional, handle item double click or enter key + std::function onSelChange; // optional, handle selectionchange + std::function onColumnHeaderClick; // optional, handle column header click, if not set sorting will happen + + size_t GetItemCount() const override { + return m_lines.size(); + } + void SetItemCount( size_t count ) { + m_lines.resize( count ); + ReloadData(); + } + void SetItemText(size_t item, size_t subItem, const char * text, bool bRedraw = true) { + if ( item < m_lines.size() ) { + m_lines[item].text[subItem] = text; + if ( bRedraw ) ReloadItem( item ); + } else { + PFC_ASSERT(!"CListControlSimple: item index out of range, call SetItemCount() first"); + } + } + bool GetSubItemText(size_t item, size_t subItem, pfc::string_base & out) const override { + if ( item < m_lines.size() ) { + auto & l = m_lines[item].text; + auto iter = l.find( subItem ); + if ( iter != l.end() ) { + out = iter->second.c_str(); + return true; + } + } + return false; + } + + uint32_t QueryDragDropTypes() const override { + return (onReordered != nullptr) ? dragDrop_reorder : 0; + } + + void RequestReorder( const size_t * order, size_t count) override { + if ( onReordered == nullptr ) return; + _Reorder(order, count); + } + void RequestRemoveSelection() override { + if (onRemoved == nullptr) return; + auto mask = this->GetSelectionMask(); + size_t oldCount = m_lines.size(); + pfc::remove_mask_t( m_lines, mask ); + this->OnItemsRemoved( mask, oldCount ); + onRemoved(); + } + void ExecuteDefaultAction( size_t idx ) override { + if (onItemAction != nullptr) onItemAction(idx); + } + + void SetItemUserData( size_t item, size_t user ) { + if ( item < m_lines.size() ) { + m_lines[item].user = user; + } + } + size_t GetItemUserData( size_t item ) const { + size_t ret = 0; + if ( item < m_lines.size() ) { + ret = m_lines[item].user; + } + return ret; + } + void RemoveAllItems() { + RemoveItems(pfc::bit_array_true()); + } + void RemoveItems( pfc::bit_array const & mask ) { + const auto oldCount = m_lines.size(); + pfc::remove_mask_t( m_lines, mask ); + this->OnItemsRemoved( mask, oldCount ); + } + void RemoveItem( size_t which ) { + RemoveItems( pfc::bit_array_one( which ) ); + } + + size_t InsertItem( size_t insertAt, const char * textCol0 = nullptr ) { + if ( insertAt > m_lines.size() ) { + insertAt = m_lines.size(); + } + { + line_t data; + if ( textCol0 != nullptr ) data.text[0] = textCol0; + m_lines.insert( m_lines.begin() + insertAt, std::move(data) ); + } + this->OnItemsInserted( insertAt, 1, false ); + return insertAt; + } + size_t AddItem( const char * textCol0 = nullptr ) { + return InsertItem( SIZE_MAX, textCol0 ); + } + size_t InsertItems( size_t insertAt, size_t count ) { + if ( insertAt > m_lines.size() ) { + insertAt = m_lines.size(); + } + + { + line_t val; + m_lines.insert( m_lines.begin() + insertAt, count, val ); + } + + this->OnItemsInserted( insertAt, count, false ); + return insertAt; + } + void SortBy(size_t column, bool descending) { + std::vector order; order.resize(m_lines.size()); + for (size_t walk = 0; walk < order.size(); ++walk) order[walk] = walk; + auto pred = [column, descending](const line_t& l1, const line_t& l2) { + int ret = pfc::winNaturalSortCompare(l1.at(column), l2.at(column)); + if (!descending) ret = -ret; + return ret > 0; + }; + auto pred_order = [&](size_t i1, size_t i2) { + return pred(m_lines[i1], m_lines[i2]); + }; + std::sort(order.begin(), order.end(), pred_order); + this->_Reorder(order.data(), order.size()); + this->SetSortIndicator(column, descending); + } + void SortBy(size_t column) { + HDITEM item = { HDI_FORMAT }; + if (this->GetHeaderCtrl().GetItem((int)column, &item)) { + bool bDescending = (item.fmt & HDF_SORTDOWN) != 0; + this->SortBy(column, bDescending); + } + } +protected: + void OnSelectionChanged(pfc::bit_array const & affected, pfc::bit_array const & status) override { + __super::OnSelectionChanged(affected, status); + if ( onSelChange ) onSelChange(); + } + void OnColumnHeaderClick(t_size index) { + __super::OnColumnHeaderClick(index); + if (onColumnHeaderClick) onColumnHeaderClick(index); + else this->SortBy(index); + } + void _Reorder(const size_t* order, size_t count) { + pfc::reorder_t(m_lines, order, count); + this->OnItemsReordered(order, count); + if (onReordered) onReordered(); + } +private: + struct line_t { + std::map text; + size_t user = 0; + const char* at(size_t i) const { + auto iter = text.find(i); + if (iter == text.end()) return ""; + return iter->second.c_str(); + } + }; + std::vector m_lines; +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/CListControlTruncationTooltipImpl.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/CListControlTruncationTooltipImpl.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,219 @@ +#include "stdafx.h" +#include "CListControl.h" +#include "PaintUtils.h" +#include "DarkMode.h" + +LRESULT CListControlTruncationTooltipImpl::OnTTShow(int,LPNMHDR,BOOL&) { + SetTimer(KTooltipTimer,KTooltipTimerDelay); + return 0; +} +LRESULT CListControlTruncationTooltipImpl::OnTTPop(int,LPNMHDR,BOOL&) { + KillTimer(KTooltipTimer); + return 0; +} +LRESULT CListControlTruncationTooltipImpl::OnTTGetDispInfo(int,LPNMHDR p_hdr,BOOL&) { + LPNMTTDISPINFO info = (LPNMTTDISPINFO)p_hdr; + + info->lpszText = const_cast(this->m_tooltipText.get_ptr()); + info->hinst = 0; + info->uFlags = 0; + + return 0; +} + +LRESULT CListControlTruncationTooltipImpl::OnDestroyPassThru(UINT,WPARAM,LPARAM,BOOL& bHandled) { + if (m_tooltip.m_hWnd != NULL) m_tooltip.DestroyWindow(); + KillTimer(KTooltipTimer); + bHandled = FALSE; return 0; +} + +CListControlTruncationTooltipImpl::CListControlTruncationTooltipImpl() + : m_toolinfo() + , m_tooltipRect(0,0,0,0) +{ +} + + + +void CListControlTruncationTooltipImpl::TooltipRemove() { + m_tooltipRect = CRect(0,0,0,0); + if (m_tooltip.m_hWnd != NULL) { + m_tooltip.TrackActivate(&m_toolinfo,FALSE); + } +} + +void CListControlTruncationTooltipImpl::TooltipRemoveCheck() { + CPoint pt; ; + if (GetCursorPos(&pt) && ScreenToClient(&pt)) { + TooltipRemoveCheck( MAKELPARAM( pt.x, pt.y ) ); + } +} +void CListControlTruncationTooltipImpl::TooltipRemoveCheck(LPARAM pos) { + if (!m_tooltipRect.IsRectEmpty()) { + CPoint pt(pos); + if (!GetClientRectHook().PtInRect(pt)) { + TooltipRemove(); + } else { + ClientToScreen(&pt); + if (!m_tooltipRect.PtInRect(pt)) { + TooltipRemove(); + } + } + } +} + +LRESULT CListControlTruncationTooltipImpl::OnTimer(UINT,WPARAM wp,LPARAM,BOOL& bHandled) { + switch(wp) { + case KTooltipTimer: + TooltipRemoveCheck(); + return 0; + default: + bHandled = FALSE; + return 0; + } +} + +LRESULT CListControlTruncationTooltipImpl::OnMouseMovePassThru(UINT,WPARAM,LPARAM lp,BOOL& bHandled) { + TooltipRemoveCheck(lp); + { + TRACKMOUSEEVENT ev = {sizeof(ev)}; + ev.dwFlags = TME_HOVER; + ev.hwndTrack = *this; + ev.dwHoverTime = HOVER_DEFAULT; + TrackMouseEvent(&ev); + } + bHandled = FALSE; + return 0; +} + + +bool CListControlTruncationTooltipImpl::IsRectPartiallyObscuredAbs(CRect const & r) const { + const CRect cl = GetVisibleRectAbs(); + return r.right > cl.right || r.top < cl.top || r.bottom > cl.bottom; +} + +bool CListControlTruncationTooltipImpl::IsRectFullyVisibleAbs(CRect const & r) { + const CRect cl = GetVisibleRectAbs(); + return r.left >= cl.left && r.right <= cl.right && r.top >= cl.top && r.bottom <= cl.bottom; +} + +bool CListControlTruncationTooltipImpl::GetTooltipData(CPoint pt, pfc::string_base & outText, CRect & outRC, CFontHandle & outFont) const { + t_size item; + if (ItemFromPointAbs(pt, item)) { + PFC_ASSERT(item < GetItemCount()); + const CRect itemRectAbs = this->GetItemRectAbs(item); + /*if (this->IsHeaderEnabled()) */{ + t_uint32 cbase = 0; + auto orderArray = this->GetColumnOrderArray(); + for (t_size _cwalk = 0; _cwalk < orderArray.size(); ++_cwalk) { + const t_size cwalk = orderArray[_cwalk]; + //const TColumnRuntime & col = m_columns[cwalk]; + + const t_uint32 width = GetSubItemWidth(cwalk); + if ((t_uint32)pt.x < cbase + width) { + t_uint32 estWidth = GetOptimalSubItemWidthSimple(item, cwalk); + CRect rc = itemRectAbs; rc.left = cbase; rc.right = cbase + estWidth; + if (estWidth > width || (IsRectPartiallyObscuredAbs(rc) && rc.PtInRect(pt))) { + pfc::string_formatter label, ccTemp; + if (GetSubItemText(item, cwalk, label)) { + PaintUtils::TextOutColors_StripCodes(ccTemp, label); + outFont = GetFont(); outRC = rc; outText = ccTemp; + return true; + } + } + break; + } + cbase += width; + } + } + } else if (GroupHeaderFromPointAbs2(pt, item)) { + CRect rc; + if (GetGroupHeaderRectAbs2(item, rc) && rc.PtInRect(pt)) { + const t_uint32 estWidth = GetOptimalGroupHeaderWidth2( item ); + CRect rcText = rc; rcText.right = rcText.left + estWidth; + if (estWidth > (t_uint32)rc.Width() || (IsRectPartiallyObscuredAbs(rcText) && rcText.PtInRect(pt))) { + pfc::string_formatter label; + if (GetGroupHeaderText2(item, label)) { + outFont = GetGroupHeaderFont(); outRC = rc; outText = label; + return true; + } + } + } + } + return false; +} +LRESULT CListControlTruncationTooltipImpl::OnHover(UINT,WPARAM wp,LPARAM lp,BOOL&) { + if (!m_tooltipRect.IsRectEmpty()) { + return 0; + } + if (wp & (MK_LBUTTON | MK_RBUTTON | MK_MBUTTON)) return 0; + + const CPoint pt = PointClientToAbs(CPoint(lp)); + + CFontHandle font; + CRect rc; + pfc::string8 text; + if ( this->GetTooltipData(pt, text, rc, font) ) { + this->m_tooltipFont = font; + // Gets stuck if the text is very long! + if (text.length() < 4096) { + TooltipActivateAbs(text, rc); + } + } + return 0; +} + +void CListControlTruncationTooltipImpl::TooltipActivateAbs(const char * label, const CRect & rect) { + CRect temp = RectAbsToClient(rect); + ClientToScreen(temp); + TooltipActivate(label,temp); +} +void CListControlTruncationTooltipImpl::TooltipActivate(const char * label, const CRect & rect) { + if (rect.IsRectEmpty()) return; + if (m_tooltip.m_hWnd == NULL) { + try { + InitTooltip(); + } catch(std::exception const & e) { + (void) e; + // console::complain("Tooltip initialization failure", e); + return; + } + } + + m_tooltipText.convert( EscapeTooltipText( label ) ); + + m_tooltipRect = rect; + + TooltipUpdateFont(); + m_tooltip.TrackPosition(rect.left,rect.top); + m_tooltip.TrackActivate(&m_toolinfo,TRUE); +} + +void CListControlTruncationTooltipImpl::TooltipUpdateFont() { + if (m_tooltip.m_hWnd != NULL) { + if (m_tooltipFont) { + m_tooltip.SetFont(m_tooltipFont); + } + } +} + +void CListControlTruncationTooltipImpl::InitTooltip() { + m_tooltipRect = CRect(0,0,0,0); + WIN32_OP( m_tooltip.Create(NULL,NULL,NULL,WS_POPUP,WS_EX_TRANSPARENT) ); + m_toolinfo.cbSize = sizeof(m_toolinfo); + m_toolinfo.uFlags = TTF_TRACK | TTF_IDISHWND | TTF_ABSOLUTE | TTF_TRANSPARENT; + m_toolinfo.hwnd = *this; + m_toolinfo.uId = 0; + m_toolinfo.lpszText = LPSTR_TEXTCALLBACK; + m_toolinfo.hinst = GetThisModuleHandle(); + WIN32_OP_D( m_tooltip.AddTool(&m_toolinfo) ); + + if ( GetDarkMode() ) DarkMode::ApplyDarkThemeCtrl(m_tooltip, true ); +} + +void CListControlTruncationTooltipImpl::RefreshDarkMode() { + __super::RefreshDarkMode(); + if (m_tooltip) { + DarkMode::ApplyDarkThemeCtrl(m_tooltip, GetDarkMode() ); + } +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/CListControlTruncationTooltipImpl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/CListControlTruncationTooltipImpl.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,52 @@ +#pragma once + +class CListControlTruncationTooltipImpl : public CListControlHeaderImpl { +private: + typedef CListControlHeaderImpl TParent; +public: + CListControlTruncationTooltipImpl(); + + BEGIN_MSG_MAP_EX(CListControlTruncationTooltipImpl) + MESSAGE_HANDLER(WM_MOUSEHOVER,OnHover); + MESSAGE_HANDLER(WM_MOUSEMOVE,OnMouseMovePassThru); + MESSAGE_HANDLER(WM_TIMER,OnTimer); + MESSAGE_HANDLER(WM_DESTROY,OnDestroyPassThru); + CHAIN_MSG_MAP(TParent) + NOTIFY_CODE_HANDLER(TTN_GETDISPINFO,OnTTGetDispInfo); + NOTIFY_CODE_HANDLER(TTN_POP,OnTTPop); + NOTIFY_CODE_HANDLER(TTN_SHOW,OnTTShow); + END_MSG_MAP() + + void OnViewOriginChange(CPoint p_delta) override {TParent::OnViewOriginChange(p_delta);TooltipRemove();} + void TooltipRemove(); + virtual void RefreshDarkMode(); +protected: + virtual bool GetTooltipData( CPoint ptAbs, pfc::string_base & text, CRect & rc, CFontHandle & font) const; +private: + enum { + KTooltipTimer = 0x51dbee9e, + KTooltipTimerDelay = 50, + }; + LRESULT OnHover(UINT,WPARAM,LPARAM,BOOL&); + LRESULT OnMouseMovePassThru(UINT,WPARAM,LPARAM,BOOL&); + LRESULT OnTimer(UINT,WPARAM,LPARAM,BOOL&); + LRESULT OnTTGetDispInfo(int,LPNMHDR,BOOL&); + LRESULT OnTTShow(int,LPNMHDR,BOOL&); + LRESULT OnTTPop(int,LPNMHDR,BOOL&); + LRESULT OnDestroyPassThru(UINT,WPARAM,LPARAM,BOOL&); + + void InitTooltip(); + void TooltipActivateAbs(const char * label, const CRect & rect); + void TooltipActivate(const char * label, const CRect & rect); + void TooltipRemoveCheck(LPARAM pos); + void TooltipRemoveCheck(); + void TooltipUpdateFont(); + void OnSetFont(bool) override {TooltipUpdateFont();} + bool IsRectFullyVisibleAbs(CRect const & r); + bool IsRectPartiallyObscuredAbs(CRect const & r) const; + CRect m_tooltipRect; + CToolTipCtrl m_tooltip; + TOOLINFO m_toolinfo; + pfc::stringcvt::string_os_from_utf8 m_tooltipText; + CFontHandle m_tooltipFont; +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/CListControlUserOptions.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/CListControlUserOptions.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,9 @@ +#pragma once + +class CListControlUserOptions { +public: + CListControlUserOptions() { instance = this; } + virtual bool useSmoothScroll() = 0; + + static CListControlUserOptions * instance; +}; \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/CListControlWithSelection.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/CListControlWithSelection.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,1662 @@ +#include "stdafx.h" +#include +#include +#include "CListControlWithSelection.h" +#include "PaintUtils.h" +#include "IDataObjectUtils.h" +#include "SmartStrStr.h" +#include "CListControl-Cells.h" + +namespace { + class bit_array_selection_CListControl : public pfc::bit_array { + public: + bit_array_selection_CListControl(CListControlWithSelectionBase const & list) : m_list(list) {} + bool get(t_size n) const {return m_list.IsItemSelected(n);} + private: + CListControlWithSelectionBase const & m_list; + }; +} + +bool CListControlWithSelectionBase::SelectAll() { + SetSelection(pfc::bit_array_true(), pfc::bit_array_true() ); + return true; +} +void CListControlWithSelectionBase::SelectNone() { + SetSelection(pfc::bit_array_true(), pfc::bit_array_false() ); +} +void CListControlWithSelectionBase::SetSelectionAt(size_t idx, bool bSel) { + if (bSel == this->IsItemSelected(idx)) return; + this->SetSelection(pfc::bit_array_one(idx), pfc::bit_array_val(bSel)); +} +void CListControlWithSelectionBase::SelectSingle(size_t which) { + this->SetFocusItem( which ); + SetSelection(pfc::bit_array_true(), pfc::bit_array_one( which ) ); +} + +LRESULT CListControlWithSelectionBase::OnFocus(UINT,WPARAM,LPARAM,BOOL& bHandled) { + UpdateItems(pfc::bit_array_or(bit_array_selection_CListControl(*this), pfc::bit_array_one(GetFocusItem()))); + bHandled = FALSE; + return 0; +} + +void CListControlWithSelectionBase::OnKeyDown_SetIndexDeltaPageHelper(int p_delta, int p_keys) { + const CRect rcClient = GetClientRectHook(); + int itemHeight = GetItemHeight(); + if (itemHeight > 0) { + int delta = rcClient.Height() / itemHeight; + if (delta < 1) delta = 1; + OnKeyDown_SetIndexDeltaHelper(delta * p_delta,p_keys); + } +} + +void CListControlWithSelectionBase::OnKeyDown_HomeEndHelper(bool isEnd, int p_keys) { + if (!isEnd) { + //SPECIAL FIX - ensure first group header visibility. + MoveViewOrigin(CPoint(GetViewOrigin().x,0)); + } + + const t_size itemCount = GetItemCount(); + if (itemCount == 0) return;//don't bother + + if ((p_keys & (MK_SHIFT|MK_CONTROL)) == (MK_SHIFT|MK_CONTROL)) { + RequestMoveSelection( isEnd ? (int)itemCount : -(int)itemCount ); + } else { + OnKeyDown_SetIndexHelper(isEnd ? (int)(itemCount-1) : 0,p_keys); + } +} +void CListControlWithSelectionBase::OnKeyDown_SetIndexHelper(int p_index, int p_keys) { + const t_size count = GetItemCount(); + if (count > 0) { + t_size idx = (t_size)pfc::clip_t(p_index,0,(int)(count - 1)); + const t_size oldFocus = GetFocusItem(); + if (p_keys & MK_CONTROL) { + SetFocusItem(idx); + } else if ((p_keys & MK_SHIFT) != 0 && this->AllowRangeSelect() ) { + t_size selStart = GetSelectionStart(); + if (selStart == pfc_infinite) selStart = oldFocus; + if (selStart == pfc_infinite) selStart = idx; + t_size selFirst, selCount; + selFirst = pfc::min_t(selStart,idx); + selCount = pfc::max_t(selStart,idx) + 1 - selFirst; + SetSelection(pfc::bit_array_true(), pfc::bit_array_range(selFirst,selCount)); + SetFocusItem(idx); + SetSelectionStart(selStart); + } else { + SetFocusItem(idx); + SetSelection(pfc::bit_array_true(), pfc::bit_array_one(idx)); + } + } +} + +void CListControlWithSelectionBase::SelectGroupHelper2(size_t base,int p_keys) { + size_t count = this->ResolveGroupRange2(base); + if ( count > 0 ) { + if (p_keys & MK_CONTROL) { + SetGroupFocusByItem(base); + } /*else if (p_keys & MK_SHIFT) { + } */else { + SetGroupFocusByItem(base); + SetSelection(pfc::bit_array_true(), pfc::bit_array_range(base,count)); + } + } +} + +void CListControlWithSelectionBase::OnKeyDown_SetIndexDeltaLineHelper(int p_delta, int p_keys) { + if ((p_keys & (MK_SHIFT | MK_CONTROL)) == (MK_SHIFT|MK_CONTROL)) { + this->RequestMoveSelection(p_delta); + return; + } + const t_size total = GetItemCount(); + t_size current = GetFocusItem(); + const size_t focusGroupItem = this->GetGroupFocus2(); + if (focusGroupItem != SIZE_MAX) current = focusGroupItem; + + if (current == pfc_infinite) { + OnKeyDown_SetIndexDeltaHelper(p_delta,p_keys); + return; + } + + const groupID_t currentGroup = GetItemGroup(current); + if (GroupFocusActive()) { + if (p_delta < 0 && focusGroupItem > 0) { + OnKeyDown_SetIndexHelper((int)(focusGroupItem-1), p_keys); + } else if (p_delta > 0) { + OnKeyDown_SetIndexHelper((int) current, p_keys); + } + } else { + if ((p_keys & MK_SHIFT) != 0) { + OnKeyDown_SetIndexDeltaHelper(p_delta,p_keys); + } else if (p_delta < 0) { + if (currentGroup == 0 || (current > 0 && currentGroup == GetItemGroup(current - 1))) { + OnKeyDown_SetIndexDeltaHelper(p_delta,p_keys); + } else { + SelectGroupHelper2(current, p_keys); + } + } else if (p_delta > 0) { + if (current + 1 >= total || currentGroup == GetItemGroup(current + 1)) { + OnKeyDown_SetIndexDeltaHelper(p_delta,p_keys); + } else { + SelectGroupHelper2(current + 1, p_keys); + } + } + } +} + +LRESULT CListControlWithSelectionBase::OnLButtonDblClk(UINT,WPARAM p_wp,LPARAM p_lp,BOOL& bHandled) { + CPoint pt(p_lp); + if (OnClickedSpecialHitTest(pt)) { + return OnButtonDown(WM_LBUTTONDOWN, p_wp, p_lp, bHandled); + } + t_size item; + if (ItemFromPoint(pt,item)) { + ExecuteDefaultAction(item); + return 0; + } else if (GroupHeaderFromPoint2(pt,item)) { + t_size count = this->ResolveGroupRange2(item); + if (count > 0) ExecuteDefaultActionGroup(item, count); + return 0; + } else if (ExecuteCanvasDefaultAction(pt)) { + return 0; + } else { + return OnButtonDown(WM_LBUTTONDOWN,p_wp,p_lp,bHandled); + } +} +void CListControlWithSelectionBase::ExecuteDefaultActionByFocus() { + size_t groupFocus = this->GetGroupFocus2(); + if ( groupFocus != SIZE_MAX ) { + size_t count = this->ResolveGroupRange2(groupFocus); + if (count > 0) { + ExecuteDefaultActionGroup(groupFocus, count); + } + } else { + size_t index = this->GetFocusItem(); + if (index != SIZE_MAX) this->ExecuteDefaultAction(index); + } +} + +t_size CListControlWithSelectionBase::GetSingleSel() const { + t_size total = GetItemCount(); + t_size first = SIZE_MAX; + for(t_size walk = 0; walk < total; ++walk) { + if (IsItemSelected(walk)) { + if (first == SIZE_MAX) first = walk; + else return SIZE_MAX; + } + } + return first; +} + +t_size CListControlWithSelectionBase::GetSelectedCount(pfc::bit_array const & mask,t_size max) const { + const t_size itemCount = this->GetItemCount(); + t_size found = 0; + for(t_size walk = mask.find_first(true,0,itemCount); walk < itemCount && found < max; walk = mask.find_next(true,walk,itemCount)) { + if (IsItemSelected(walk)) ++found; + } + return found; +} +LRESULT CListControlWithSelectionBase::OnButtonDown(UINT p_msg,WPARAM p_wp,LPARAM p_lp,BOOL&) { + pfc::vartoggle_t l_noEnsureVisible(m_noEnsureVisible,true); + if (m_selectDragMode) { + AbortSelectDragMode(); + return 0; + } + + CPoint pt(p_lp); + + if (OnClickedSpecial( (DWORD) p_wp, pt)) { + return 0; + } + + + size_t item; + const bool isRightClick = (p_msg == WM_RBUTTONDOWN || p_msg == WM_RBUTTONDBLCLK); + const bool gotCtrl = (p_wp & MK_CONTROL) != 0 && !isRightClick; + const bool gotShift = (p_wp & MK_SHIFT) != 0 && !isRightClick; + + + + const bool bCanSelect = !OnClickedSpecialHitTest( pt ); + + const bool instaDrag = false; + const bool ddSupported = IsDragDropSupported(); + + if (GroupHeaderFromPoint2(pt, item)) { + t_size base = item,count = ResolveGroupRange2(base); + if (AllowRangeSelect() && count > 0) { + SetGroupFocusByItem(base); + pfc::bit_array_range groupRange(base,count); + bool instaDragOverride = false; + if (gotCtrl) { + ToggleRangeSelection(groupRange); + } else if (gotShift) { + SetSelection(groupRange, pfc::bit_array_true()); + } else { + if (GetSelectedCount(groupRange) == count) instaDragOverride = true; + else SetSelection(pfc::bit_array_true(),groupRange); + } + if (ddSupported && (instaDrag || instaDragOverride)) { + PrepareDragDrop(pt,isRightClick); + } else { + InitSelectDragMode(pt, isRightClick); + } + } + } else if (ItemFromPoint(pt,item)) { + const t_size oldFocus = GetFocusItem(); + const t_size selStartBefore = GetSelectionStart(); + if ( bCanSelect ) SetFocusItem(item); + if (gotShift && AllowRangeSelect() ) { + if (bCanSelect) { + t_size selStart = selStartBefore; + if (selStart == pfc_infinite) selStart = oldFocus; + if (selStart == pfc_infinite) selStart = item; + SetSelectionStart(selStart); + t_size selFirst, selCount; + selFirst = pfc::min_t(selStart, item); + selCount = pfc::max_t(selStart, item) + 1 - selFirst; + pfc::bit_array_range rangeMask(selFirst, selCount); + pfc::bit_array_true trueMask; + SetSelection(gotCtrl ? pfc::implicit_cast(rangeMask) : pfc::implicit_cast(trueMask), rangeMask); + //if (!instaDrag) InitSelectDragMode(pt, isRightClick); + } + } else { + if (gotCtrl) { + if (bCanSelect) SetSelection(pfc::bit_array_one(item), pfc::bit_array_val(!IsItemSelected(item))); + if (!instaDrag) InitSelectDragMode(pt, isRightClick); + } else { + if (!IsItemSelected(item)) { + if (bCanSelect) SetSelection(pfc::bit_array_true(), pfc::bit_array_one(item)); + if (ddSupported && instaDrag) { + PrepareDragDrop(pt,isRightClick); + } else { + InitSelectDragMode(pt, isRightClick); + } + } else { + if (ddSupported) { + PrepareDragDrop(pt,isRightClick); + } else { + InitSelectDragMode(pt, isRightClick); + } + } + } + } + } else { + if (!gotShift && !gotCtrl && bCanSelect) SelectNone(); + InitSelectDragMode(pt, isRightClick); + } + return 0; +} + + +void CListControlWithSelectionBase::ToggleRangeSelection(pfc::bit_array const & mask) { + SetSelection(mask, pfc::bit_array_val(GetSelectedCount(mask,1) == 0)); +} +void CListControlWithSelectionBase::ToggleGroupSelection2(size_t base) { + size_t count = this->ResolveGroupRange2(base); + if (count > 0) { + ToggleRangeSelection(pfc::bit_array_range(base, count)); + } +} + +LRESULT CListControlWithSelectionBase::OnRButtonUp(UINT,WPARAM,LPARAM,BOOL& bHandled) { + bHandled = FALSE; + AbortPrepareDragDropMode(); + AbortSelectDragMode(); + return 0; +} + +bool CListControlWithSelectionBase::ShouldBeginDrag(CPoint ptRef, CPoint ptNow) const { + auto threshold = PP::queryDragThresholdForDPI(this->GetDPI()); + return abs(ptNow.x - ptRef.x) > threshold.cx || abs(ptNow.y - ptRef.y) > threshold.cy; +} + +LRESULT CListControlWithSelectionBase::OnMouseMove(UINT,WPARAM,LPARAM p_lp,BOOL&) { + if (m_prepareDragDropMode) { + if (ShouldBeginDrag(m_prepareDragDropOrigin, CPoint(p_lp))) { + AbortPrepareDragDropMode(); + if (!m_ownDDActive) { + pfc::vartoggle_t ownDD(m_ownDDActive,true); + RunDragDrop( PointClientToAbs( m_prepareDragDropOrigin ),m_prepareDragDropModeRightClick); + } + } + } else if (m_selectDragMode) { + HandleDragSel(CPoint(p_lp)); + } + return 0; +} +LRESULT CListControlWithSelectionBase::OnLButtonUp(UINT,WPARAM p_wp,LPARAM p_lp,BOOL&) { + const bool wasPreparingDD = m_prepareDragDropMode; + AbortPrepareDragDropMode(); + CPoint pt(p_lp); + const bool gotCtrl = (p_wp & MK_CONTROL) != 0; + const bool gotShift = (p_wp & MK_SHIFT) != 0; + bool click = false; + bool processSel = wasPreparingDD; + if (m_selectDragMode) { + processSel = !m_selectDragMoved; + AbortSelectDragMode(); + } + if (processSel) { + click = true; + if (!OnClickedSpecialHitTest(pt) ) { + size_t item; + if (GroupHeaderFromPoint2(pt, item)) { + t_size base = item, count = ResolveGroupRange2(base); + if ( count > 0 ) { + if (gotCtrl) { + } else { + SetSelection(pfc::bit_array_true(), pfc::bit_array_range(base, count)); + } + } + } else if (ItemFromPoint(pt, item)) { + const t_size selStartBefore = GetSelectionStart(); + if (gotCtrl) { + } else if (gotShift) { + SetSelectionStart(selStartBefore); + } else { + SetSelection(pfc::bit_array_true(), pfc::bit_array_one(item)); + } + } + } + } + if (click && !gotCtrl && !gotShift) { + size_t item; + if (GroupHeaderFromPoint2(pt,item)) { + OnGroupHeaderClicked(GetItemGroup(item),pt); + } else if (ItemFromPoint(pt,item)) { + OnItemClicked(item,pt); + } + } + return 0; +} + +void CListControlWithSelectionBase::OnKeyDown_SetIndexDeltaHelper(int p_delta, int p_keys) { + size_t focus = SIZE_MAX; + if (this->GroupFocusActive()) { + focus = this->GetGroupFocus2(); + } else { + focus = GetFocusItem(); + } + int target = 0; + if (focus != SIZE_MAX) target = (int) focus + p_delta; + OnKeyDown_SetIndexHelper(target,p_keys); +} + + +static int _get_keyflags() { + int ret = 0; + if (IsKeyPressed(VK_CONTROL)) ret |= MK_CONTROL; + if (IsKeyPressed(VK_SHIFT)) ret |= MK_SHIFT; + return ret; +} + +LRESULT CListControlWithSelectionBase::OnKeyDown(UINT,WPARAM p_wp,LPARAM,BOOL& bHandled) { + switch(p_wp) { + case VK_NEXT: + OnKeyDown_SetIndexDeltaPageHelper(1,_get_keyflags()); + return 0; + case VK_PRIOR: + OnKeyDown_SetIndexDeltaPageHelper(-1,_get_keyflags()); + return 0; + case VK_DOWN: + OnKeyDown_SetIndexDeltaLineHelper(1,_get_keyflags()); + return 0; + case VK_UP: + OnKeyDown_SetIndexDeltaLineHelper(-1,_get_keyflags()); + return 0; + case VK_HOME: + OnKeyDown_HomeEndHelper(false,_get_keyflags()); + return 0; + case VK_END: + OnKeyDown_HomeEndHelper(true,_get_keyflags()); + return 0; + case VK_SPACE: + if (!TypeFindCheck()) { + ToggleSelectedItems(); + } + return 0; + case VK_RETURN: + ExecuteDefaultActionByFocus(); + return 0; + case VK_DELETE: + if (GetHotkeyModifierFlags() == 0) { + RequestRemoveSelection(); + return 0; + } + break; + case 'A': + if (GetHotkeyModifierFlags() == MOD_CONTROL) { + if (SelectAll()) { + return 0; + } + // otherwise unhandled + } + break; + } + + bHandled = FALSE; + return 0; +} + +void CListControlWithSelectionBase::ToggleSelectedItems() { + if (ToggleSelectedItemsHook(bit_array_selection_CListControl(*this))) return; + if (GroupFocusActive()) { + ToggleGroupSelection2(this->GetGroupFocus2()); + } else { + const t_size focus = GetFocusItem(); + if (focus != pfc_infinite) { + ToggleRangeSelection(pfc::bit_array_range(focus, 1)); + } + } +} + +LRESULT CListControlWithSelectionBase::OnTimer(UINT,WPARAM p_wp,LPARAM,BOOL& bHandled) { + switch((DWORD)p_wp) { + case (DWORD)KSelectionTimerID: + if (m_selectDragMode) { + CPoint pt; + if (GetCursorPos(&pt) && ScreenToClient(&pt)) { + const CRect client = GetClientRectHook(); + CPoint delta(0, 0); + if (pt.x < client.left) { + delta.x = pt.x - client.left; + } else if (pt.x > client.right) { + delta.x = pt.x - client.right; + } + if (pt.y < client.top) { + delta.y = pt.y - client.top; + } else if (pt.y > client.bottom) { + delta.y = pt.y - client.bottom; + } + + MoveViewOriginDelta(delta); + HandleDragSel(pt); + } + } + return 0; + case TDDScrollControl::KTimerID: + HandleDDScroll(); + return 0; + default: + bHandled = FALSE; + return 0; + } +} + +bool CListControlWithSelectionBase::MoveSelectionProbe(int delta) { + pfc::array_t order; order.set_size(GetItemCount()); + { + bit_array_selection_CListControl sel(*this); + pfc::create_move_items_permutation(order.get_ptr(), order.get_size(), sel, delta); + } + for( size_t w = 0; w < order.get_size(); ++w ) if ( order[w] != w ) return true; + return false; +} +void CListControlWithSelectionBase::RequestMoveSelection(int delta) { + pfc::array_t order; order.set_size(GetItemCount()); + { + bit_array_selection_CListControl sel(*this); + pfc::create_move_items_permutation(order.get_ptr(), order.get_size(), sel, delta); + } + + this->RequestReorder(order.get_ptr(), order.get_size()); + + if (delta < 0) { + size_t idx = GetFirstSelected(); + if (idx != pfc_infinite) EnsureItemVisible(idx); + } else { + size_t idx = GetLastSelected(); + if (idx != pfc_infinite) EnsureItemVisible(idx); + } +} + +void CListControlWithSelectionBase::ToggleSelection(pfc::bit_array const & mask) { + const t_size count = GetItemCount(); + pfc::bit_array_bittable table(count); + for(t_size walk = mask.find_first(true,0,count); walk < count; walk = mask.find_next(true,walk,count)) { + table.set(walk,!IsItemSelected(walk)); + } + this->SetSelection(mask,table); +} + +static HRGN FrameRectRgn(const CRect & rect) { + CRect exterior(rect); exterior.InflateRect(1,1); + CRgn rgn; rgn.CreateRectRgnIndirect(exterior); + CRect interior(rect); interior.DeflateRect(1,1); + if (!interior.IsRectEmpty()) { + CRgn rgn2; rgn2.CreateRectRgnIndirect(interior); + rgn.CombineRgn(rgn2,RGN_DIFF); + } + return rgn.Detach(); +} + +void CListControlWithSelectionBase::HandleDragSel(const CPoint & p_pt) { + const CPoint pt = PointClientToAbs(p_pt); + if (m_selectDragMoved || ShouldBeginDrag(m_selectDragCurrentAbs, pt)) { + + if (!this->AllowRangeSelect()) { + // simplified + m_selectDragCurrentAbs = pt; + if (pt != m_selectDragOriginAbs) m_selectDragMoved = true; + return; + } + + CRect rcOld(m_selectDragOriginAbs,m_selectDragCurrentAbs); rcOld.NormalizeRect(); + m_selectDragCurrentAbs = pt; + CRect rcNew(m_selectDragOriginAbs,m_selectDragCurrentAbs); rcNew.NormalizeRect(); + + + { + CRgn rgn = FrameRectRgn(rcNew); + CRgn rgn2 = FrameRectRgn(rcOld); + rgn.CombineRgn(rgn2,RGN_OR); + rgn.OffsetRgn( - GetViewOffset() ); + InvalidateRgn(rgn); + } + + if (pt != m_selectDragOriginAbs) m_selectDragMoved = true; + + if (m_selectDragChanged || !IsSameItemOrHeaderAbs(pt,m_selectDragOriginAbs)) { + m_selectDragChanged = true; + const int keys = _get_keyflags(); + t_size base,count, baseOld, countOld; + if (!GetItemRangeAbs(rcNew,base,count)) base = count = 0; + if (!GetItemRangeAbs(rcOld,baseOld,countOld)) baseOld = countOld = 0; + { + pfc::bit_array_range rangeNew(base,count), rangeOld(baseOld,countOld); + if (keys & MK_CONTROL) { + ToggleSelection(pfc::bit_array_xor(rangeNew,rangeOld)); + } else if (keys & MK_SHIFT) { + SetSelection(pfc::bit_array_or(rangeNew,rangeOld),rangeNew); + } else { + SetSelection(pfc::bit_array_true(),rangeNew); + } + } + if (ItemFromPointAbs(pt,base)) { + const CRect rcVisible = GetVisibleRectAbs(), rcItem = GetItemRectAbs(base); + if (rcItem.top >= rcVisible.top && rcItem.bottom <= rcVisible.bottom) { + SetFocusItem(base); + } + } else if (GroupHeaderFromPointAbs2(pt,base)) { + const CRect rcVisible = GetVisibleRectAbs(); + CRect rcGroup; + if (GetGroupHeaderRectAbs2(base,rcGroup)) { + if (rcGroup.top >= rcVisible.top && rcGroup.bottom <= rcVisible.bottom) { + this->SetGroupFocusByItem(base); + } + } + } + } + } +} + +void CListControlWithSelectionBase::InitSelectDragMode(const CPoint & p_pt,bool p_rightClick) { + // Perform the bookkeeping even if multiple selection is disabled, detection of clicks relies on it + (void)p_rightClick; + SetTimer(KSelectionTimerID,KSelectionTimerPeriod); + m_selectDragMode = true; + m_selectDragOriginAbs = m_selectDragCurrentAbs = PointClientToAbs(p_pt); + m_selectDragChanged = false; m_selectDragMoved = false; + SetCapture(); +} + +void CListControlWithSelectionBase::AbortSelectDragMode(bool p_lostCapture) { + if (m_selectDragMode) { + m_selectDragMode = false; + CRect rcSelect(m_selectDragOriginAbs,m_selectDragCurrentAbs); rcSelect.NormalizeRect(); + rcSelect.OffsetRect( - GetViewOffset() ); + if (!p_lostCapture) ::SetCapture(NULL); + rcSelect.InflateRect(1,1); + InvalidateRect(rcSelect); + KillTimer(KSelectionTimerID); + } +} + + +LRESULT CListControlWithSelectionBase::OnCaptureChanged(UINT,WPARAM,LPARAM,BOOL&) { + AbortPrepareDragDropMode(true); + AbortSelectDragMode(true); + return 0; +} + +void CListControlWithSelectionBase::RenderOverlay2(const CRect & p_updaterect,CDCHandle p_dc) { + if (m_selectDragMode && this->AllowRangeSelect() ) { + CRect rcSelect(m_selectDragOriginAbs,m_selectDragCurrentAbs); + rcSelect.NormalizeRect(); + rcSelect.OffsetRect(-GetViewOffset()); + PaintUtils::FocusRect(p_dc,rcSelect); + } + if (m_dropMark != SIZE_MAX) { + RenderDropMarkerClipped2(p_dc, p_updaterect, m_dropMark, m_dropMarkInside); + } + TParent::RenderOverlay2(p_updaterect,p_dc); +} + +void CListControlWithSelectionBase::SetDropMark(size_t mark, bool inside) { + if (mark != m_dropMark || inside != m_dropMarkInside) { + CRgn updateRgn; updateRgn.CreateRectRgn(0, 0, 0, 0); + AddDropMarkToUpdateRgn(updateRgn, m_dropMark, m_dropMarkInside); + m_dropMark = mark; + m_dropMarkInside = inside; + AddDropMarkToUpdateRgn(updateRgn, m_dropMark, m_dropMarkInside); + RedrawWindow(NULL, updateRgn); + } +} + +static int transformDDScroll(int p_value,int p_width, int p_dpi) { + if (p_dpi <= 0) p_dpi = 96; + const double dpiMul = 96.0 / (double) p_dpi; + double val = (double)(p_width - p_value); + val *= dpiMul; + val = pow(val,1.1) * 0.33; + val /= dpiMul; + return pfc::rint32(val); +} + +void CListControlWithSelectionBase::HandleDDScroll() { + CPoint position; + if (m_ddScroll.m_timerActive && GetCursorPos(&position)) { + CRect client = GetClientRectHook(); + CPoint delta (0,0); + if (ClientToScreen(client)) { + const CSize DPI = QueryScreenDPIEx(); + const int scrollZoneWidthBase = GetItemHeight() * 2; + const int scrollZoneHeight = pfc::min_t( scrollZoneWidthBase, client.Height() / 4 ); + const int scrollZoneWidth = pfc::min_t( scrollZoneWidthBase, client.Width() / 4 ); + + if (position.y >= client.top && position.y < client.top + scrollZoneHeight) { + delta.y -= transformDDScroll(position.y - client.top, scrollZoneHeight, DPI.cy); + } else if (position.y >= client.bottom - scrollZoneHeight && position.y < client.bottom) { + delta.y += transformDDScroll(client.bottom - position.y, scrollZoneHeight, DPI.cy); + } + + if (position.x >= client.left && position.x < client.left + scrollZoneWidth) { + delta.x -= transformDDScroll(position.x - client.left, scrollZoneWidth, DPI.cx); + } else if (position.x >= client.right - scrollZoneWidth && position.x < client.right) { + delta.x += transformDDScroll(client.right - position.x, scrollZoneWidth, DPI.cx); + } + } + + if (delta != CPoint(0,0)) MoveViewOriginDelta(delta); + } +} + +void CListControlWithSelectionBase::ToggleDDScroll(bool p_state) { + if (p_state != m_ddScroll.m_timerActive) { + if (p_state) { + SetTimer(m_ddScroll.KTimerID,m_ddScroll.KTimerPeriod); + } else { + KillTimer(m_ddScroll.KTimerID); + } + m_ddScroll.m_timerActive = p_state; + } +} + +void CListControlWithSelectionBase::PrepareDragDrop(const CPoint & p_point,bool p_isRightClick) { + m_prepareDragDropMode = true; + m_prepareDragDropOrigin = p_point; + m_prepareDragDropModeRightClick = p_isRightClick; + SetCapture(); +} +void CListControlWithSelectionBase::AbortPrepareDragDropMode(bool p_lostCapture) { + if (m_prepareDragDropMode) { + m_prepareDragDropMode = false; + if (!p_lostCapture) ::SetCapture(NULL); + } +} + + +void CListControlWithSelectionBase::RenderItem(t_size p_item,const CRect & p_itemRect,const CRect & p_updateRect,CDCHandle p_dc) { + //console::formatter() << "RenderItem: " << p_item; + const bool weHaveFocus = ::GetFocus() == m_hWnd; + const bool isSelected = this->IsItemSelected(p_item); + + const t_uint32 bkColor = GetSysColorHook(colorBackground); + const t_uint32 hlColor = GetSysColorHook(colorSelection); + const t_uint32 bkColorUsed = isSelected ? (weHaveFocus ? hlColor : PaintUtils::BlendColor(hlColor,bkColor)) : bkColor; + + bool alternateTextColor = false, dtt = false; + auto & m_theme = theme(); + CRect rcSelection = p_itemRect; + this->AdjustSelectionRect(p_item, rcSelection); + if (m_theme != NULL && isSelected && hlColor == GetSysColor(COLOR_HIGHLIGHT) && /*bkColor == GetSysColor(COLOR_WINDOW) && */ IsThemePartDefined(m_theme, LVP_LISTITEM, 0)) { + //PaintUtils::RenderItemBackground(p_dc,p_itemRect,p_item+GetItemGroup(p_item),bkColor); + DrawThemeBackground(m_theme, p_dc, LVP_LISTITEM, weHaveFocus ? LISS_SELECTED : LISS_SELECTEDNOTFOCUS, rcSelection, p_updateRect); + // drawthemetext is acting whacky with dark mode + if (!this->GetDarkMode()) dtt = true; + } else { + this->RenderItemBackground(p_dc, rcSelection, p_item, bkColorUsed ); + // PaintUtils::RenderItemBackground(p_dc,p_itemRect,p_item+GetItemGroup(p_item),bkColorUsed); + if (isSelected) alternateTextColor = true; + } + + { + DCStateScope backup(p_dc); + p_dc.SetBkMode(TRANSPARENT); + p_dc.SetBkColor(bkColorUsed); + p_dc.SetTextColor(alternateTextColor ? PaintUtils::DetermineTextColor(bkColorUsed) : this->GetSysColorHook(colorText)); + pfc::vartoggle_t toggle(m_drawThemeText, dtt); + RenderItemText(p_item,p_itemRect,p_updateRect,p_dc, !alternateTextColor); + } + + if (IsItemFocused(p_item) && weHaveFocus) { + PaintUtils::FocusRect2(p_dc,rcSelection, bkColorUsed); + } +} + +void CListControlWithSelectionBase::RenderSubItemText(t_size item, t_size subItem,const CRect & subItemRect,const CRect & updateRect,CDCHandle dc, bool allowColors) { +#if 0 + auto ct = GetCellType(item, subItem); + if ( ct == nullptr ) return; + + if (m_drawThemeText && ct->AllowDrawThemeText() && !this->IsSubItemGrayed(item, subItem)) for(;;) { + pfc::string_formatter label; + if (!GetSubItemText(item,subItem,label)) return; + const bool weHaveFocus = ::GetFocus() == m_hWnd; + // const bool isSelected = this->IsItemSelected(item); + pfc::stringcvt::string_os_from_utf8 cvt(label); + if (PaintUtils::TextContainsCodes(cvt)) break; + CRect clip = GetItemTextRect(subItemRect); + const t_uint32 format = PaintUtils::DrawText_TranslateHeaderAlignment(GetColumnFormat(subItem)); + DrawThemeText(theme(), dc, LVP_LISTITEM, weHaveFocus ? LISS_SELECTED : LISS_SELECTEDNOTFOCUS, cvt, (int)cvt.length(), DT_NOPREFIX | DT_END_ELLIPSIS | DT_SINGLELINE | DT_VCENTER | format, 0, clip); + return; + } +#endif + __super::RenderSubItemText(item, subItem, subItemRect, updateRect, dc, allowColors); +} + +void CListControlWithSelectionBase::RenderGroupHeader2(size_t baseItem,const CRect & p_headerRect,const CRect & p_updateRect,CDCHandle p_dc) { + TParent::RenderGroupHeader2(baseItem,p_headerRect,p_updateRect,p_dc); + if (IsGroupHeaderFocused2(baseItem)) { + PaintUtils::FocusRect(p_dc,p_headerRect); + } +} + +CRect CListControlWithSelectionBase::DropMarkerUpdateRect(t_size index,bool bInside) const { + if (index != SIZE_MAX) { + CRect rect; + if (bInside) { + rect = GetItemRect(index); + rect.InflateRect(DropMarkerMargin()); + } else { + rect = DropMarkerRect(DropMarkerOffset(index)); + } + return rect; + } else { + return CRect(0,0,0,0); + } +} +void CListControlWithSelectionBase::AddDropMarkToUpdateRgn(HRGN p_rgn, t_size p_index, bool bInside) const { + CRect rect = DropMarkerUpdateRect(p_index,bInside); + if (!rect.IsRectEmpty()) PaintUtils::AddRectToRgn(p_rgn,rect); +} + +CRect CListControlWithSelectionBase::DropMarkerRect(int offset) const { + const int delta = MulDiv(5,m_dpi.cy,96); + CRect rc(0,offset - delta,GetViewAreaWidth(), offset + delta); + rc.InflateRect(DropMarkerMargin()); + return rc; +} + +int CListControlWithSelectionBase::DropMarkerOffset(t_size marker) const { + + return (marker > 0 ? this->GetItemBottomOffsetAbs(marker-1): 0) - GetViewOffset().y; +} + +bool CListControlWithSelectionBase::RenderDropMarkerClipped2(CDCHandle dc, const CRect & update, t_size item, bool bInside) { + CRect markerRect = DropMarkerUpdateRect(item,bInside); + CRect affected; + if (affected.IntersectRect(markerRect,update)) { + DCStateScope state(dc); + if (dc.IntersectClipRect(affected)) { + RenderDropMarker2(dc,item,bInside); + return true; + } + } + return false; +} +void CListControlWithSelectionBase::RenderDropMarker2(CDCHandle dc, t_size item, bool bInside) { + if (item != SIZE_MAX) { + if (bInside) { + CPen pen; MakeDropMarkerPen(pen); + SelectObjectScope penScope(dc,pen); + const CRect rc = GetItemRect(item); + dc.MoveTo(rc.left,rc.top); + dc.LineTo(rc.right,rc.top); + dc.LineTo(rc.right,rc.bottom); + dc.LineTo(rc.left,rc.bottom); + dc.LineTo(rc.left,rc.top); + } else { + RenderDropMarkerByOffset2(DropMarkerOffset(item),dc); + } + } +} + +SIZE CListControlWithSelectionBase::DropMarkerMargin() const { + const int penDeltaX = MulDiv(5 /* we don't know how to translate CreatePen units... */,m_dpi.cx,96); + const int penDeltaY = MulDiv(5 /* we don't know how to translate CreatePen units... */,m_dpi.cy,96); + SIZE s = {penDeltaX,penDeltaY}; + return s; +} +void CListControlWithSelectionBase::MakeDropMarkerPen(CPen & out) const { + WIN32_OP_D( out.CreatePen(PS_SOLID,3,GetSysColorHook(colorText)) != NULL ); +} + +void CListControlWithSelectionBase::RenderDropMarkerByOffset2(int offset,CDCHandle p_dc) { + CPen pen; MakeDropMarkerPen(pen); + const int delta = MulDiv(5,m_dpi.cy,96); + SelectObjectScope penScope(p_dc,pen); + const int width = GetViewAreaWidth(); + if (width > 0) { + const int vx = this->GetViewOffset().x; + const int left = -vx; + const int right = width - 1 - vx; + p_dc.MoveTo(left,offset); + p_dc.LineTo(right,offset); + p_dc.MoveTo(left,offset-delta); + p_dc.LineTo(left,offset+delta); + p_dc.MoveTo(right,offset-delta); + p_dc.LineTo(right,offset+delta); + } +} + +void CListControlWithSelectionBase::FocusToUpdateRgn(HRGN rgn) { + size_t focusItem = GetFocusItem(); + if (focusItem != SIZE_MAX) AddItemToUpdateRgn(rgn,focusItem); + size_t focusGroup = GetGroupFocus2(); + if (focusGroup != SIZE_MAX) AddGroupHeaderToUpdateRgn2(rgn,focusGroup); +} + +void CListControlWithSelectionImpl::ReloadData() { + if ( GetItemCount() != m_selection.get_size() ) { + this->SelHandleReset(); + } + __super::ReloadData(); +} + +size_t CListControlWithSelectionImpl::GetGroupFocus2() const { + return (m_groupFocus && m_focus < GetItemCount()) ? m_focus : SIZE_MAX; +} + +void CListControlWithSelectionImpl::SetSelectionImpl(pfc::bit_array const & affected, pfc::bit_array const & status) { + const t_size total = m_selection.get_size(); + pfc::bit_array_flatIndexList toUpdate; + + // Only fire UpdateItems for stuff that's both on-screen and actually changed + // Firing for whole affected mask will repaint everything when selecting one item + t_size base, count; + if (!GetItemRangeAbs(GetVisibleRectAbs(), base, count)) { base = count = 0; } + + affected.walk( total, [&] (size_t idx) { + if ( m_selection[idx] != status[idx] && this->CanSelectItem(idx) ) { + m_selection[idx] = status[idx]; + if ( idx >= base && idx < base+count ) toUpdate.add(idx); + } + } ); + + if ( toUpdate.get_count() > 0 ) { + UpdateItems(toUpdate); + } + + + // Fire subclassable method ONLY WITH ITEMS THAT CHANGED + // We provide no other means for them to know old state + this->OnSelectionChanged(toUpdate, status ); +} + +void CListControlWithSelectionImpl::SetSelection(pfc::bit_array const & affected, pfc::bit_array const & status) { + RefreshSelectionSize(); + + + if ( m_selectionSupport == selectionSupportNone ) return; + + if ( m_selectionSupport == selectionSupportSingle ) { + size_t single = SIZE_MAX; + bool selNone = true; + const size_t total = m_selection.get_size(); + for( size_t walk = 0; walk < total; ++ walk ) { + if ( affected.get(walk) ) { + if ( status.get(walk) && single == SIZE_MAX ) { + single = walk; + } + } else if ( IsItemSelected( walk ) ) { + selNone = false; + } + } + if ( single < total ) { + SetSelectionImpl( pfc::bit_array_true(), pfc::bit_array_one( single ) ); + } else if ( selNone ) { + this->SetSelectionImpl( pfc::bit_array_true(), pfc::bit_array_false() ); + } + } else { + SetSelectionImpl( affected, status ); + } + +} + +void CListControlWithSelectionImpl::RefreshSelectionSize() { + RefreshSelectionSize(GetItemCount()); +} +void CListControlWithSelectionImpl::RefreshSelectionSize(t_size total) { + const t_size oldSize = m_selection.get_size(); + if (total != oldSize) { + m_selection.set_size(total); + for(t_size walk = oldSize; walk < total; ++walk) m_selection[walk] = false; + } +} + +void CListControlWithSelectionImpl::SetGroupFocusByItem(t_size item) { + CRgn update; update.CreateRectRgn(0,0,0,0); + FocusToUpdateRgn(update); + m_groupFocus = true; m_focus = item; + FocusToUpdateRgn(update); + InvalidateRgn(update); + + + CRect header; + if (GetGroupHeaderRectAbs2(item,header)) EnsureVisibleRectAbs(header); + + this->OnFocusChangedGroup2( item ); +} + +void CListControlWithSelectionImpl::SetFocusItem(t_size index) { + CRgn update; update.CreateRectRgn(0,0,0,0); + FocusToUpdateRgn(update); + size_t oldFocus = m_focus; + m_groupFocus = false; m_focus = index; + FocusToUpdateRgn(update); + InvalidateRgn(update); + + if ( index != SIZE_MAX ) { + EnsureVisibleRectAbs(GetItemRectAbs(index)); + } + + SetSelectionStart(index); + + this->OnFocusChanged(oldFocus, index); +} + +static void UpdateIndexOnReorder(t_size & index, const t_size * order, t_size count) { + index = pfc::permutation_find_reverse(order,count,index); +} +static void UpdateIndexOnRemoval(t_size & index, const pfc::bit_array & mask, t_size oldCount, t_size newCount) { + if (index >= oldCount || newCount == 0) {index = SIZE_MAX; return;} + for(t_size walk = mask.find_first(true,0,oldCount); walk < newCount; ++walk) { + if (walk < index) --index; + else break; + } + if (index >= newCount) index = newCount - 1; +} + +static void UpdateIndexOnInsert(size_t& index, pfc::bit_array const& mask, size_t newCount) { + if (index == SIZE_MAX) return; + for (size_t walk = 0; walk < index; ) { + size_t delta = mask.calc_count(true, walk, index - walk); + if (delta == 0) break; + walk = index; index += delta; + } +} + +static void UpdateIndexOnInsert(t_size & index, t_size base, t_size count) { + if (index != SIZE_MAX && index >= base) index += count; +} + +void CListControlWithSelectionImpl::SelHandleReorder(const t_size * order, t_size count) { + RefreshSelectionSize(); + UpdateIndexOnReorder(m_focus,order,count); + UpdateIndexOnReorder(m_selectionStart,order,count); + pfc::array_t newSel; newSel.set_size(m_selection.get_size()); + for(t_size walk = 0; walk < m_selection.get_size(); ++walk) newSel[walk] = m_selection[order[walk]]; + m_selection = newSel; +} + +void CListControlWithSelectionImpl::SelHandleReset() { + RefreshSelectionSize(GetItemCount()); + for(t_size walk = 0; walk < m_selection.get_size(); walk++) m_selection[walk] = false; + m_focus = SIZE_MAX; + m_groupFocus = false; + +} +void CListControlWithSelectionImpl::SelHandleRemoval(const pfc::bit_array & mask, t_size oldCount) { + RefreshSelectionSize(oldCount); + const t_size newCount = GetItemCount(); + UpdateIndexOnRemoval(m_focus,mask,oldCount,newCount); + UpdateIndexOnRemoval(m_selectionStart,mask,oldCount,newCount); + pfc::remove_mask_t(m_selection,mask); +} + +void CListControlWithSelectionImpl::SelHandleInsertion(pfc::bit_array const& mask, size_t oldCount, size_t newCount, bool select) { + PFC_ASSERT(newCount == GetItemCount()); + PFC_ASSERT(oldCount <= newCount); (void)oldCount; + + // To behave sanely in single-select mode, we'd have to alter selection of other items from here + // Let caller worry and outright deny select requests in modes other than multisel + if (m_selectionSupport != selectionSupportMulti) select = false; + + UpdateIndexOnInsert(m_focus, mask, newCount); + UpdateIndexOnInsert(m_selectionStart, mask, newCount); + pfc::array_t newSel; + newSel.resize(newCount); + + size_t inWalk = 0; + for (size_t walk = 0; walk < newCount; ++walk) { + bool v = false; + if (mask[walk]) { + v = select; + } else if (inWalk < m_selection.get_size()) { + v = m_selection[inWalk++]; + } + newSel[walk] = v; + } + + m_selection = std::move(newSel); +} + +void CListControlWithSelectionImpl::SelHandleInsertion(t_size base, t_size count, bool select) { + PFC_ASSERT(base + count <= GetItemCount()); + + // To behave sanely in single-select mode, we'd have to alter selection of other items from here + // Let caller worry and outright deny select requests in modes other than multisel + if (m_selectionSupport != selectionSupportMulti) select = false; + + UpdateIndexOnInsert(m_focus,base,count); + UpdateIndexOnInsert(m_selectionStart,base,count); + RefreshSelectionSize(GetItemCount() - count); + + + m_selection.insert_multi(select,base,count); +} + + +LRESULT CListControlWithSelectionBase::OnGetDlgCode(UINT,WPARAM,LPARAM p_lp,BOOL& bHandled) { + if (p_lp == 0) { + return DLGC_WANTALLKEYS | DLGC_WANTCHARS | DLGC_WANTARROWS; + } else { + const MSG * pmsg = reinterpret_cast(p_lp); + switch(pmsg->message) { + case WM_KEYDOWN: + case WM_KEYUP: + switch(pmsg->wParam) { + case VK_ESCAPE: + case VK_TAB: + bHandled = FALSE; + return 0; + default: + return DLGC_WANTMESSAGE; + } + case WM_CHAR: + return DLGC_WANTMESSAGE; + default: + bHandled = FALSE; + return 0; + } + } +} + +bool CListControlWithSelectionBase::GetFocusRect(CRect & p_rect) { + CRect temp; + if (!GetFocusRectAbs(temp)) return false; + p_rect = RectClientToAbs(temp); + return true; +} + +bool CListControlWithSelectionBase::GetFocusRectAbs(CRect & p_rect) { + size_t item = this->GetFocusItem(); + if (item != SIZE_MAX) { + p_rect = this->GetItemRectAbs(item); + return true; + } + + item = this->GetGroupFocus2(); + if (item != SIZE_MAX) { + return this->GetGroupHeaderRectAbs2(item, p_rect); + } + + return false; +} + +bool CListControlWithSelectionBase::GetContextMenuPoint2(CPoint& ptInOut) { + CPoint ptInvalid(-1,-1); + if (ptInOut == ptInvalid) { + ptInOut = GetContextMenuPointDefault(); + return ptInOut != ptInvalid; + } else { + CRect rc = this->GetClientRectHook(); + WIN32_OP_D( ClientToScreen(rc) ); + return !!rc.PtInRect(ptInOut); + } +} + +CPoint CListControlWithSelectionBase::GetContextMenuPointDefault() { + CRect rect; + if (!GetFocusRectAbs(rect)) return CPoint(-1,-1); + EnsureVisibleRectAbs(rect); + CPoint pt = rect.CenterPoint() - GetViewOffset(); + ClientToScreen(&pt); + return pt; +} + +CPoint CListControlWithSelectionBase::GetContextMenuPoint(CPoint ptGot) { + CPoint pt; + if (ptGot.x == -1 && ptGot.y == -1) { + pt = GetContextMenuPointDefault(); + } else { + pt = ptGot; + } + return pt; +} + +CPoint CListControlWithSelectionBase::GetContextMenuPoint(LPARAM lp) { + CPoint pt; + if (lp == -1) { + pt = GetContextMenuPointDefault(); + } else { + pt = lp; + } + return pt; +} + +bool CListControlWithSelectionBase::MakeDropReorderPermutation(pfc::array_t & out, CPoint ptDrop) const { + t_size insertMark = InsertIndexFromPoint(ptDrop); + /*if (insertMark != this->GetFocusItem())*/ { + const t_size count = GetItemCount(); + if (insertMark > count) insertMark = count; + { + t_size selBefore = 0; + for(t_size walk = 0; walk < insertMark; ++walk) { + if (IsItemSelected(walk)) selBefore++; + } + insertMark -= selBefore; + } + { + pfc::array_t permutation, selected, nonselected; + const t_size selcount = this->GetSelectedCount(); + selected.set_size(selcount); nonselected.set_size(count - selcount); + permutation.set_size(count); + if (insertMark > nonselected.get_size()) insertMark = nonselected.get_size(); + for(t_size walk = 0, swalk = 0, nwalk = 0; walk < count; ++walk) { + if (IsItemSelected(walk)) { + selected[swalk++] = walk; + } else { + nonselected[nwalk++] = walk; + } + } + for(t_size walk = 0; walk < insertMark; ++walk) { + permutation[walk] = nonselected[walk]; + } + for(t_size walk = 0; walk < selected.get_size(); ++walk) { + permutation[insertMark + walk] = selected[walk]; + } + for(t_size walk = insertMark; walk < nonselected.get_size(); ++walk) { + permutation[selected.get_size() + walk] = nonselected[walk]; + } + for(t_size walk = 0; walk < permutation.get_size(); ++walk) { + if (permutation[walk] != walk) { + out = permutation; + return true; + } + } + } + } + return false; +} + +void CListControlWithSelectionBase::EnsureVisibleRectAbs(const CRect & p_rect) { + if (!m_noEnsureVisible) TParent::EnsureVisibleRectAbs(p_rect); +} + +bool CListControlWithSelectionBase::TypeFindCheck(DWORD ts) const { + if (m_typeFindTS == 0) return false; + return ts - m_typeFindTS < 1000; +} + +void CListControlWithSelectionBase::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) { + (void)nRepCnt; (void)nFlags; + if (nChar < 32) { + m_typeFindTS = 0; + return; + } + + const DWORD ts = GetTickCount(); + if (!TypeFindCheck(ts)) m_typeFind.reset(); + + if (nChar == ' ' && m_typeFind.is_empty()) { + m_typeFindTS = 0; + return; + } + + m_typeFindTS = ts; + if (m_typeFindTS == 0) m_typeFindTS = UINT32_MAX; + char temp[10] = {}; + pfc::utf8_encode_char(nChar, temp); + m_typeFind += temp; + RunTypeFind(); +} + +static unsigned detectRepetition( pfc::string8 const & str ) { + size_t count = 0; + size_t walk = 0; + uint32_t first = 0; + + while( walk < str.length() ) { + uint32_t current; + auto delta = pfc::utf8_decode_char( str.c_str() + walk, current, str.length() - walk ); + if ( delta == 0 ) break; + walk += delta; + + if ( count == 0 ) first = current; + else if ( first != current ) return 0; + + ++ count; + } + + if ( count > 1 ) return first; + return 0; +} + +size_t CListControlWithSelectionBase::EvalTypeFind() { + if ( GetItemCount() == 0 ) return SIZE_MAX; + + static SmartStrStr tool; + + const size_t itemCount = GetItemCount(); + const size_t colCount = GetColumnCount(); + pfc::string_formatter temp; temp.prealloc(1024); + t_size searchBase = this->GetFocusItem(); + if (searchBase >= itemCount) searchBase = 0; + + size_t partial = SIZE_MAX; + size_t repetition = SIZE_MAX; + bool useRepetition = false; + pfc::string8 strRepetitionChar; + unsigned repChar = detectRepetition( m_typeFind ); + if ( repChar != 0 ) { + useRepetition = true; + strRepetitionChar.add_char( repChar ); + } + + for(t_size walk = 0; walk < itemCount; ++walk) { + t_size index = (walk + searchBase) % itemCount; + for(size_t cWalk = 0; cWalk < colCount; ++cWalk) { + + temp.reset(); + + if (AllowTypeFindInCell( index, cWalk )) { + this->GetSubItemText(index, cWalk, temp); + } + + if ( temp.length() == 0 ) { + continue; + } + if (partial == SIZE_MAX) { + size_t matchAt; + if (tool.strStrEnd( temp, m_typeFind, & matchAt ) != nullptr) { + if ( matchAt == 0 ) return index; + partial = index; + } + } else { + if ( tool.matchHere( temp, m_typeFind ) ) return index; + } + if (useRepetition && index != searchBase) { + if ( tool.matchHere( temp, strRepetitionChar ) ) { + useRepetition = false; + repetition = index; + } + } + } + } + if (partial < itemCount) return partial; + if (repetition < itemCount) return repetition; + return SIZE_MAX; +} + +void CListControlWithSelectionBase::RunTypeFind() { + size_t index = EvalTypeFind(); + if (index < GetItemCount() ) { + this->SetFocusItem( index ); + this->SetSelection(pfc::bit_array_true(), pfc::bit_array_one(index) ); + } else { + MessageBeep(0); + } +} + +size_t CListControlWithSelectionBase::GetFirstSelected() const { + const size_t count = GetItemCount(); + for( size_t w = 0; w < count; ++w ) { + if ( IsItemSelected(w) ) return w; + } + return SIZE_MAX; +} + +size_t CListControlWithSelectionBase::GetLastSelected() const { + const size_t count = GetItemCount(); + for( size_t w = count - 1; (t_ssize) w >= 0; --w ) { + if ( IsItemSelected(w) ) return w; + } + return SIZE_MAX; +} + +namespace { + class CDropTargetImpl : public ImplementCOMRefCounter { + public: + COM_QI_BEGIN() + COM_QI_ENTRY(IUnknown) + COM_QI_ENTRY(IDropTarget) + COM_QI_END() + + bool valid = true; + std::function Track; + std::function HookAccept; + std::function HookDrop; + std::function HookLeave; + + DWORD m_effect = DROPEFFECT_NONE; + + HRESULT STDMETHODCALLTYPE DragEnter(IDataObject *pDataObj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect) { + (void)grfKeyState; (void)pt; + if (pDataObj == NULL || pdwEffect == NULL) return E_INVALIDARG; + if (!valid) return E_FAIL; + if ( HookAccept ) { + m_effect = HookAccept(pDataObj); + } else { + m_effect = DROPEFFECT_MOVE; + } + *pdwEffect = m_effect; + return S_OK; + } + HRESULT STDMETHODCALLTYPE DragOver(DWORD grfKeyState, POINTL pt, DWORD *pdwEffect) { + (void)grfKeyState; + if (pdwEffect == NULL) return E_INVALIDARG; + if (!valid) return E_FAIL; + if ( m_effect != DROPEFFECT_NONE ) Track(CPoint(pt.x, pt.y)); + *pdwEffect = m_effect; + return S_OK; + } + HRESULT STDMETHODCALLTYPE DragLeave() { + if (HookLeave) HookLeave(); + return S_OK; + } + HRESULT STDMETHODCALLTYPE Drop(IDataObject *pDataObj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect) { + (void)grfKeyState; (void)pdwEffect; + if ( HookDrop && m_effect != DROPEFFECT_NONE ) { + HookDrop( pDataObj, CPoint(pt.x, pt.y) ); + } + return S_OK; + } + }; + + class CDropSourceImpl : public ImplementCOMRefCounter { + public: + CPoint droppedAt; + bool droppedAtValid = false; + bool allowReorder = false; + + bool allowDragOutside = false; + CWindow wndOrigin; + + COM_QI_BEGIN() + COM_QI_ENTRY(IUnknown) + COM_QI_ENTRY(IDropSource) + COM_QI_END() + + HRESULT STDMETHODCALLTYPE GiveFeedback(DWORD dwEffect) { + m_effect = dwEffect; + return DRAGDROP_S_USEDEFAULTCURSORS; + } + + HRESULT STDMETHODCALLTYPE QueryContinueDrag(BOOL fEscapePressed, DWORD grfKeyState) { + + if (fEscapePressed || (grfKeyState & MK_RBUTTON) != 0) { + return DRAGDROP_S_CANCEL; + } else if (!(grfKeyState & MK_LBUTTON)) { + if (m_effect == DROPEFFECT_NONE) return DRAGDROP_S_CANCEL; + + CPoint pt; + if (!GetCursorPos(&pt)) return DRAGDROP_S_CANCEL; + bool bInside = false; + if (wndOrigin) { + CRect rc; + WIN32_OP_D(wndOrigin.GetWindowRect(rc)); + bInside = rc.PtInRect(pt); + } + if (!allowDragOutside && !bInside) return DRAGDROP_S_CANCEL; + + if ( allowReorder && bInside) { + droppedAt = pt; + droppedAtValid = true; + return DRAGDROP_S_CANCEL; + } + return DRAGDROP_S_DROP; + + } else { + return S_OK; + } + } + private: + DWORD m_effect = 0; + }; +} + +void CListControlWithSelectionBase::RunDragDrop(const CPoint & p_origin, bool p_isRightClick) { + + uint32_t flags = this->QueryDragDropTypes(); + if ( flags == 0 ) { + PFC_ASSERT(!"How did we get here?"); + return; + } + if ( flags == dragDrop_reorder ) { + if ( p_isRightClick ) return; + CPoint ptDrop; + if ( RunReorderDragDrop( p_origin, ptDrop ) ) { + pfc::array_t order; + if (MakeDropReorderPermutation(order, ptDrop)) { + this->RequestReorder(order.get_ptr(), order.get_size()); + } + } + return; + } + + auto obj = this->MakeDataObject(); + if (obj.is_empty()) { + PFC_ASSERT(!"How did we get here? No IDataObject"); + return; + } + + pfc::com_ptr_t source = new CDropSourceImpl(); + source->wndOrigin = m_hWnd; + source->allowDragOutside = true; + source->allowReorder = (flags & dragDrop_reorder) != 0; + + DWORD outEffect = DROPEFFECT_NONE; + HRESULT status = DoDragDrop(obj.get_ptr(), source.get_ptr(), DragDropSourceEffects() , &outEffect); + + if ( source->droppedAtValid ) { + CPoint ptDrop = source->droppedAt; + WIN32_OP_D(this->ScreenToClient(&ptDrop)); + pfc::array_t order; + if (MakeDropReorderPermutation(order, ptDrop)) { + this->RequestReorder(order.get_ptr(), order.get_size()); + } + } else if (status == DRAGDROP_S_DROP) { + DragDropSourceSucceeded(outEffect); + } +} + +pfc::com_ptr_t CListControlWithSelectionBase::MakeDataObject() { + // return dummy IDataObject, presume derived transmits drag and drop payload by other means + using namespace IDataObjectUtils; + return new ImplementCOMRefCounter< CDataObjectBase >(); +} + +bool CListControlWithSelectionBase::RunReorderDragDrop(CPoint ptOrigin, CPoint & ptDrop) { + (void)ptOrigin; + pfc::com_ptr_t source = new CDropSourceImpl(); + pfc::com_ptr_t target = new CDropTargetImpl(); + + source->wndOrigin = m_hWnd; + source->allowDragOutside = false; + source->allowReorder = true; + + target->Track = [this](CPoint pt) { + WIN32_OP_D(this->ScreenToClient(&pt)); + size_t idx = this->InsertIndexFromPoint(pt); + this->SetDropMark(idx, false); + }; + + if ( FAILED(RegisterDragDrop(*this, target.get_ptr())) ) { + // OleInitialize not called? + PFC_ASSERT( !"Should not get here" ); + return false; + } + + pfc::onLeaving scope([=] { target->valid = false; RevokeDragDrop(*this); }); + + using namespace IDataObjectUtils; + pfc::com_ptr_t dataobject = new ImplementCOMRefCounter< CDataObjectBase >(); + DWORD outeffect = 0; + + ToggleDDScroll(true); + DoDragDrop(dataobject.get_ptr(), source.get_ptr(), DROPEFFECT_MOVE, &outeffect); + ClearDropMark(); + ToggleDDScroll(false); + if (source->droppedAtValid ) { + CPoint pt = source->droppedAt; + WIN32_OP_D( this->ScreenToClient( &pt ) ); + ptDrop = pt; + return true; + } + return false; +} + +int CListControlWithSelectionBase::OnCreatePassThru(LPCREATESTRUCT) { + const uint32_t flags = this->QueryDragDropTypes(); + if ( flags & dragDrop_external ) { + + pfc::com_ptr_t target = new CDropTargetImpl(); + + auto dda = std::make_shared(); + + target->HookAccept = [this, flags, dda] ( IDataObject * obj ) { + if (this->m_ownDDActive && (flags & dragDrop_reorder) != 0) { + // Do not generate OnDrop for reorderings + dda->showDropMark = true; + dda->dwEFfect = DROPEFFECT_MOVE; + } else { + *dda = this->DragDropAccept2(obj); + } + return dda->dwEFfect; + }; + target->HookDrop = [this, flags] ( IDataObject * obj, CPoint pt ) { + this->ToggleDDScroll(false); + this->ClearDropMark(); + if ( this->m_ownDDActive ) { + // Do not generate OnDrop for reorderings + if ( flags & dragDrop_reorder ) return; + } + this->OnDrop( obj, pt ); + }; + target->HookLeave = [this] { + this->ClearDropMark(); + this->ToggleDDScroll(false); + }; + + target->Track = [this, dda](CPoint pt) { + this->ToggleDDScroll(true); + if ( dda->showDropMark ) { + WIN32_OP_D(this->ScreenToClient(&pt)); + size_t idx = this->InsertIndexFromPoint(pt); + if (dda->dropOnItem) { + if (idx < this->GetItemCount()) { + this->SetDropMark(idx, true); + } else { + this->ClearDropMark(); + } + } else { + this->SetDropMark(idx, false); + } + + } else { + this->ClearDropMark(); + } + }; + + RegisterDragDrop(*this, target.get_ptr() ); + } + SetMsgHandled(FALSE); return 0; +} + +void CListControlWithSelectionBase::OnDestroyPassThru() { + AbortSelectDragMode(); + ToggleDDScroll(false); + RevokeDragDrop(*this); + SetMsgHandled(FALSE); +} + +size_t CListControlWithSelectionBase::GetPasteTarget(const CPoint * ptPaste) const { + size_t target = SIZE_MAX; + if (ptPaste != nullptr) { + CPoint pt(*ptPaste); WIN32_OP_D(ScreenToClient(&pt)); + size_t groupBase; + if (GroupHeaderFromPoint2(pt, groupBase)) { + target = groupBase; + } else if (ItemFromPoint(pt, target)) { + auto rc = GetItemRect(target); + auto height = rc.Height(); + if (height > 0) { + double posInItem = (double)(pt.y - rc.top) / (double)height; + if (posInItem >= 0.5) ++target; + } + } + } else if (GroupFocusActive()) { + target = GetGroupFocus2(); + } else { + target = GetFocusItem(); + } + return target; +} + + +pfc::bit_array_table CListControlWithSelectionImpl::GetSelectionMaskRef() const { + return pfc::bit_array_table(m_selection.get_ptr(), m_selection.get_size()); +} +pfc::bit_array_bittable CListControlWithSelectionImpl::GetSelectionMask() const { + pfc::bit_array_bittable ret; + const auto count = GetItemCount(); + ret.resize( GetItemCount() ); + for( size_t walk = 0; walk < count; ++ walk ) { + ret.set(walk, IsItemSelected(walk)); + } + return ret; +} + +void CListControlWithSelectionImpl::OnItemsReordered( const size_t * order, size_t count) { + PFC_ASSERT( count == GetItemCount() ); + + SelHandleReorder( order, count ); + __super::OnItemsReordered(order, count); +} + +void CListControlWithSelectionImpl::OnItemsRemoved( pfc::bit_array const & mask, size_t oldCount) { + SelHandleRemoval(mask, oldCount); + __super::OnItemsRemoved( mask, oldCount ); +} + +void CListControlWithSelectionImpl::OnItemsInsertedEx(pfc::bit_array const& mask, size_t oldCount, size_t newCount, bool bSelect) { + SelHandleInsertion( mask, oldCount, newCount, bSelect); + __super::OnItemsInsertedEx( mask, oldCount, newCount, bSelect ); +} + +bool CListControlWithSelectionImpl::SelectAll() { + if ( m_selectionSupport != selectionSupportMulti ) return false; + return __super::SelectAll(); +} + +DWORD CListControlWithSelectionBase::DragDropAccept(IDataObject* obj, bool& showDropMark) { + (void)obj; + showDropMark = false; return DROPEFFECT_NONE; +} + +CListControlWithSelectionBase::dragDropAccept_t CListControlWithSelectionBase::DragDropAccept2(IDataObject* obj) { + dragDropAccept_t ret; + ret.dwEFfect = this->DragDropAccept(obj, ret.showDropMark); + return ret; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/CListControlWithSelection.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/CListControlWithSelection.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,286 @@ +#pragma once + +#include "CListControl.h" + +//! Implementation of focus/selection handling. Leaves maintaining focus/selection info to the derived class. \n +//! Most classes should derive from CListControlWithSelectionImpl instead. +class CListControlWithSelectionBase : public CListControl { +public: + typedef CListControl TParent; + CListControlWithSelectionBase() {} + BEGIN_MSG_MAP_EX(CListControlWithSelectionBase) + MSG_WM_CREATE(OnCreatePassThru); + MSG_WM_DESTROY(OnDestroyPassThru); + CHAIN_MSG_MAP(TParent) + MESSAGE_HANDLER(WM_LBUTTONDBLCLK,OnLButtonDblClk) + MESSAGE_HANDLER(WM_LBUTTONDOWN,OnButtonDown) + MESSAGE_HANDLER(WM_RBUTTONDOWN,OnButtonDown) + MESSAGE_HANDLER(WM_RBUTTONDBLCLK,OnButtonDown) + MESSAGE_HANDLER(WM_RBUTTONUP,OnRButtonUp) + MESSAGE_HANDLER(WM_MOUSEMOVE,OnMouseMove) + MESSAGE_HANDLER(WM_LBUTTONUP,OnLButtonUp) + MESSAGE_HANDLER(WM_KEYDOWN,OnKeyDown); + MESSAGE_HANDLER(WM_SYSKEYDOWN,OnKeyDown); + MESSAGE_HANDLER(WM_SETFOCUS,OnFocus); + MESSAGE_HANDLER(WM_KILLFOCUS,OnFocus); + MESSAGE_HANDLER(WM_TIMER,OnTimer); + MESSAGE_HANDLER(WM_CAPTURECHANGED,OnCaptureChanged); + MESSAGE_HANDLER(WM_GETDLGCODE,OnGetDlgCode); + MSG_WM_CHAR(OnChar) + END_MSG_MAP() + + virtual void SetFocusItem(t_size index) = 0; + virtual t_size GetFocusItem() const = 0; + virtual void SetGroupFocusByItem(t_size item) = 0; + virtual size_t GetGroupFocus2() const = 0; + virtual bool IsItemSelected(t_size index) const = 0; + virtual void SetSelection(pfc::bit_array const & affected,pfc::bit_array const & status) = 0; + void SelectSingle(size_t which); + void SetSelectionAt(size_t idx, bool bSel); + virtual bool SelectAll(); + void SelectNone(); + virtual void RequestMoveSelection(int delta); + bool MoveSelectionProbe(int delta); + virtual void RequestReorder( size_t const * order, size_t count ) = 0; + virtual void RequestRemoveSelection() = 0; + virtual void ExecuteDefaultAction(t_size index) = 0; + virtual void ExecuteDefaultActionGroup(t_size base, t_size count) { (void)base; (void)count; } + virtual bool ExecuteCanvasDefaultAction(CPoint pt) { (void)pt; return false; } + + virtual t_size GetSelectionStart() const = 0; + virtual void SetSelectionStart(t_size val) = 0; + //! Full hook for drag-drop loop + virtual void RunDragDrop(const CPoint & p_origin,bool p_isRightClick); + + //! Should RunDragDrop() be called at all? + virtual bool IsDragDropSupported() {return QueryDragDropTypes() != 0;} + + //! Notification, mandatory to call by SetFocusItem() implementation. \n + //! If overridden by subclass, must call parent. + virtual void OnFocusChanged(size_t oldFocus, size_t newFocus) { (void)oldFocus; (void)newFocus; } + virtual void OnFocusChangedGroup2(size_t baseItem) { (void)baseItem; } + //! Notification, mandatory to call by SetSelection() implementation. \n + //! If overridden by subclass, must call parent. \n + //! Affected: Mask indicating what items ACTUALLY CHANGED, old state to be assumed opposite of new. \n + //! During this call, IsSelected() already returns new state. + virtual void OnSelectionChanged(pfc::bit_array const& affected, pfc::bit_array const& status) { (void)affected; (void)status; } + + enum { + dragDrop_reorder = 1 << 0, + dragDrop_external = 1 << 1, + }; + + virtual uint32_t QueryDragDropTypes() const { return 0; } + struct dragDropAccept_t { + DWORD dwEFfect = DROPEFFECT_NONE; + //! Show drop mark or not? + bool showDropMark = false; + //! Drop on item or insert into list? + bool dropOnItem = false; + }; + //! Deprecated, use DragDropAccept2() + virtual DWORD DragDropAccept(IDataObject* obj, bool& showDropMark); + //! Return info on what you can do with this IDataObject. + virtual dragDropAccept_t DragDropAccept2(IDataObject*); + virtual pfc::com_ptr_t MakeDataObject(); + //! Called upon drop + //! @param pt Drop point in screen coordinates. + virtual void OnDrop(IDataObject* obj, CPoint pt) { (void)obj; (void)pt; } + virtual DWORD DragDropSourceEffects() { return DROPEFFECT_MOVE | DROPEFFECT_COPY;} + virtual void DragDropSourceSucceeded(DWORD effect) { (void)effect; } + + virtual void AdjustSelectionRect(size_t item, CRect& rc) { (void)item; (void)rc; } + + bool GroupFocusActive() const {return GetGroupFocus2() != SIZE_MAX;} + + void RenderOverlay2(const CRect & p_updaterect,CDCHandle p_dc) override; + + bool IsItemFocused(t_size index) const {return GetFocusItem() == index;} + bool IsGroupHeaderFocused2(size_t atItem) const {return GetGroupFocus2() == atItem;} + void ToggleSelection(pfc::bit_array const & mask); + + size_t GetSelectedCount(pfc::bit_array const & mask,size_t max = SIZE_MAX) const; + size_t GetSelectedCount() const {return GetSelectedCount(pfc::bit_array_true());} + size_t GetSingleSel() const; + size_t GetFirstSelected() const; + size_t GetLastSelected() const; + + //! Execute default action per focus or selection depending on what's focused/selected + virtual void ExecuteDefaultActionByFocus(); + + void FocusToUpdateRgn(HRGN rgn); + + + //! Self-contained minimal drag and drop implementation for reordering list items only; dummy IDataObject presented. \n + //! Call from your override of RunDragDrop(), if p_isRightClick is false / left button clicked, never with right button clicked. \n + //! On success, use MakeDropReorderPermutation() to fetch the permutation to apply to your content. + bool RunReorderDragDrop(CPoint ptOrigin, CPoint & ptDrop); + + bool MakeDropReorderPermutation(pfc::array_t & out, CPoint ptDrop) const; + + size_t GetPasteTarget( const CPoint * ptPaste = nullptr ) const; + + //! Fix coordinates of context menu point handed by WM_CONTEXTMENU, turn (-1,-1) into something that makes sense. \n + //! Input & output in screen coordinates, per WM_CONTEXTMENU conventions. + CPoint GetContextMenuPoint(LPARAM lp); + CPoint GetContextMenuPoint(CPoint ptGot); + //! Import context menu point coordinates: turn (-1,-1) to something that makes sense; \n + //! Returns false if clicked point was outside client area so WM_CONTEXTMENU should be left unhandled. + bool GetContextMenuPoint2(CPoint & ptInOut); + //! Returns center-of-focused-item point for context menu, in screen coordinates. + CPoint GetContextMenuPointDefault(); + +protected: + void ToggleDDScroll(bool p_state); + void AbortSelectDragMode() {AbortSelectDragMode(false);} + void RenderDropMarkerByOffset2(int offset,CDCHandle p_dc); + void RenderDropMarker2(CDCHandle dc, t_size item, bool bInside); + bool RenderDropMarkerClipped2(CDCHandle dc, const CRect & update, t_size item, bool bInside); + CRect DropMarkerRect(int offset) const; + int DropMarkerOffset(t_size marker) const; + void AddDropMarkToUpdateRgn(HRGN p_rgn, t_size p_index, bool bInside = false) const; + CRect DropMarkerUpdateRect(t_size index,bool bInside) const; + bool GetFocusRect(CRect & p_rect); + bool GetFocusRectAbs(CRect & p_rect); + bool IsOwnDDActive() const {return m_ownDDActive;} + + SIZE DropMarkerMargin() const; + void MakeDropMarkerPen(CPen & out) const; + + void EnsureVisibleRectAbs(const CRect & p_rect) override; + virtual size_t EvalTypeFind(); + + virtual bool AllowRangeSelect() const { return true; } + + size_t GetDropMark( ) const { return m_dropMark; } + bool IsDropMarkInside( ) const { return m_dropMarkInside; } + void SetDropMark( size_t idx, bool bInside ); + void ClearDropMark() { SetDropMark(SIZE_MAX, false); } +private: + int OnCreatePassThru(LPCREATESTRUCT lpCreateStruct); + void OnDestroyPassThru(); + + struct TDDScrollControl { + bool m_timerActive = false; + + enum {KTimerID = 0x35bb25af,KTimerPeriod = 25}; + }; + + static constexpr unsigned + KSelectionTimerID = 0xad8abd04, + KSelectionTimerPeriod = 50; + + LRESULT OnFocus(UINT,WPARAM,LPARAM,BOOL&); + LRESULT OnKeyDown(UINT,WPARAM,LPARAM,BOOL&); + LRESULT OnLButtonDblClk(UINT,WPARAM,LPARAM,BOOL&); + LRESULT OnButtonDown(UINT,WPARAM,LPARAM,BOOL&); + LRESULT OnRButtonUp(UINT,WPARAM,LPARAM,BOOL&); + LRESULT OnMouseMove(UINT,WPARAM,LPARAM,BOOL&); + LRESULT OnLButtonUp(UINT,WPARAM,LPARAM,BOOL&); + LRESULT OnTimer(UINT,WPARAM,LPARAM,BOOL&); + LRESULT OnCaptureChanged(UINT,WPARAM,LPARAM,BOOL&); + LRESULT OnGetDlgCode(UINT,WPARAM,LPARAM,BOOL&); + void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags); + void RunTypeFind(); + + void OnKeyDown_HomeEndHelper(bool isEnd, int p_keys); + void OnKeyDown_SetIndexHelper(int p_index, int p_keys); + void OnKeyDown_SetIndexDeltaHelper(int p_delta, int p_keys); + void OnKeyDown_SetIndexDeltaLineHelper(int p_delta, int p_keys); + void OnKeyDown_SetIndexDeltaPageHelper(int p_delta, int p_keys); + void SelectGroupHelper2(size_t p_groupBase,int p_keys); + void HandleDragSel(const CPoint & p_pt); + void AbortSelectDragMode(bool p_lostCapture); + void InitSelectDragMode(const CPoint & p_pt,bool p_rightClick = false); + + void ToggleRangeSelection(pfc::bit_array const & mask); + void ToggleGroupSelection2(size_t p_item); + + void HandleDDScroll(); + + void PrepareDragDrop(const CPoint & p_point,bool p_isRightClick); + void AbortPrepareDragDropMode(bool p_lostCapture = false); + + bool TypeFindCheck(DWORD ts = GetTickCount()) const; + + +protected: + // Spacebar handler + void ToggleSelectedItems(); + + void RenderItem(t_size p_item,const CRect & p_itemRect,const CRect & p_updateRect,CDCHandle p_dc) override; + void RenderGroupHeader2(size_t baseItem,const CRect & p_headerRect,const CRect & p_updateRect,CDCHandle p_dc) override; + void RenderSubItemText(t_size item, t_size subItem,const CRect & subItemRect,const CRect & updateRect,CDCHandle dc, bool allowColors) override; +private: + bool m_selectDragMode = false; + CPoint m_selectDragOriginAbs, m_selectDragCurrentAbs; + bool m_selectDragChanged, m_selectDragMoved; + TDDScrollControl m_ddScroll; + + bool m_prepareDragDropMode = false, m_prepareDragDropModeRightClick = false; + bool m_noEnsureVisible = false; + CPoint m_prepareDragDropOrigin; + bool ShouldBeginDrag(CPoint ptRef, CPoint ptNow) const; + + bool m_ownDDActive = false; + bool m_drawThemeText = false; + pfc::string8 m_typeFind; DWORD m_typeFindTS = 0; + + size_t m_dropMark = SIZE_MAX; bool m_dropMarkInside = false; +}; + +//! CListControlWithSelectionImpl implements virtual methods of CListControlWithSelectionBase, +//! maintaining focus/selection info for you. +class CListControlWithSelectionImpl : public CListControlWithSelectionBase { +public: + + enum { selectionSupportNone = 0, selectionSupportSingle, selectionSupportMulti }; + unsigned m_selectionSupport = selectionSupportMulti; + + void SetSelectionModeNone() { m_selectionSupport = selectionSupportNone; } + void SetSelectionModeSingle() { m_selectionSupport = selectionSupportSingle; } + void SetSelectionModeMulti() { m_selectionSupport = selectionSupportMulti; } + bool IsSingleSelect() const { return m_selectionSupport == selectionSupportSingle; } + + CListControlWithSelectionImpl() {} + void SetFocusItem(t_size index); + t_size GetFocusItem() const {return m_groupFocus ? SIZE_MAX : m_focus;} + void SetGroupFocusByItem(t_size item) override; + size_t GetGroupFocus2() const override; + bool IsItemSelected(t_size index) const {return index < m_selection.get_size() ? m_selection[index] : false;} + void SetSelection(pfc::bit_array const & affected,pfc::bit_array const & status); + virtual bool CanSelectItem(size_t index) const { (void)index; return true; } + t_size GetSelectionStart() const {return m_selectionStart;} + void SetSelectionStart(t_size val) {m_selectionStart = val;} + + void SelHandleReorder(const t_size * order, t_size count); + void SelHandleRemoval(const pfc::bit_array & mask, t_size oldCount); + void SelHandleInsertion(t_size base, t_size count, bool select); + void SelHandleInsertion(pfc::bit_array const & mask, size_t oldCount, size_t newCount, bool select); + void SelHandleReset(); + + void ReloadData() override; + size_t _DebugGetItemCountSel() const { return m_selection.get_size(); } + + virtual void OnItemsReordered( const size_t* order, size_t count ) override; + virtual void OnItemsRemoved( pfc::bit_array const & mask, size_t oldCount ) override; + virtual void OnItemsInsertedEx(pfc::bit_array const& mask, size_t oldCount, size_t newCount, bool bSelect) override; + + pfc::bit_array_bittable GetSelectionMask() const; // returns a standalone object holding a copy of the state + pfc::bit_array_table GetSelectionMaskRef() const; // returns a TEMPORARY object referencing this list's internal data + + bool SelectAll() override; + + const bool* GetSelectionArray() { RefreshSelectionSize(); return m_selection.get_ptr(); } + +protected: + + bool AllowRangeSelect() const override { return m_selectionSupport == selectionSupportMulti; } +private: + void SetSelectionImpl(pfc::bit_array const & affected,pfc::bit_array const & status); + void RefreshSelectionSize(); + void RefreshSelectionSize(t_size size); + pfc::array_t m_selection; + size_t m_focus = SIZE_MAX, m_selectionStart = SIZE_MAX; + bool m_groupFocus = false; +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/CListControl_EditImpl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/CListControl_EditImpl.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,77 @@ +#pragma once + +#include "InPlaceEditTable.h" +#include "GDIUtils.h" // MakeTempBrush() + +//! Implements inplace-edit functionality on top of TParent class. Must derive from CListControlHeaderImpl. +template class CListControl_EditImpl : public T_CListControl_EditImpl_Parent, protected InPlaceEdit::CTableEditHelperV2 { +public: + BEGIN_MSG_MAP_EX(CListControl_EditImpl) + CHAIN_MSG_MAP(T_CListControl_EditImpl_Parent) + MESSAGE_HANDLER(WM_CTLCOLOREDIT,OnCtlColor); + MESSAGE_HANDLER(WM_CTLCOLORSTATIC,OnCtlColor); + END_MSG_MAP() + + // IMPLEMENT ME + // virtual void TableEdit_SetField(t_size item, t_size subItem, const char * value) = 0; +protected: + RECT TableEdit_GetItemRect(t_size item, t_size subItem) const override { + return this->GetSubItemRect(item,subItem); + } + void TableEdit_GetField(t_size item, t_size subItem, pfc::string_base & out, t_size & lineCount) override { + lineCount = 1; + if (!this->GetSubItemText(item,subItem,out)) { + PFC_ASSERT(!"Should not get here."); out = ""; + } + } + HWND TableEdit_GetParentWnd() const override {return this->m_hWnd;} + t_size TableEdit_GetItemCount() const override {return this->GetItemCount();} + t_size TableEdit_GetColumnCount() const override {return this->GetColumnCount();} + void TableEdit_SetItemFocus(t_size item, t_size subItem) override { + this->TooltipRemove(); + this->SetFocusItem(item); this->SetSelection(pfc::bit_array_true(), pfc::bit_array_one(item)); + auto rcView = this->GetVisibleRectAbs(); + auto rcEdit = this->GetSubItemRectAbs(item,subItem); + CRect rcTest; + if (!rcTest.IntersectRect(rcView, rcEdit)) { + // Only scroll to subitem if entirely invisible + this->EnsureVisibleRectAbs( rcEdit ); + } + } + void TableEdit_GetColumnOrder(t_size * out, t_size count) const override { + PFC_ASSERT( count == this->GetColumnCount() ); + if ( this->IsHeaderEnabled() ) { + pfc::array_t temp; temp.set_size(count); + WIN32_OP_D( this->GetHeaderCtrl().GetOrderArray((int) temp.get_size(), temp.get_ptr()) ); + for(t_size walk = 0; walk < count; ++walk) out[walk] = (t_size) temp[walk]; + } else { + for(t_size walk = 0; walk < count; ++walk) out[walk] = walk; + } + } + + void TableEdit_OnColorsChanged() {} + bool TableEdit_GetDarkMode() const override { + return this->GetDarkMode(); + } + t_uint32 TableEdit_GetEditFlags(t_size item, t_size subItem) const override { + auto ret = __super::TableEdit_GetEditFlags(item, subItem); + if (this->GetCellTypeSupported()) { + auto cell = this->GetCellType(item, subItem); + if (cell != nullptr) ret |= cell->EditFlags(); + } + return ret; + } + void RequestEditItem(size_t item, size_t subItem) override { + this->TableEdit_Start(item, subItem); + } +private: + LRESULT OnCtlColor(UINT,WPARAM wp,LPARAM lp,BOOL&) { + (void)lp; + CDCHandle dc((HDC)wp); + const COLORREF bkgnd = this->GetSysColorHook(CListControlImpl::colorBackground); + dc.SetTextColor(this->GetSysColorHook(CListControlImpl::colorText)); + dc.SetBkColor(bkgnd); + + return (LRESULT) MakeTempBrush(dc, bkgnd); + } +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/CListViewCtrlEx.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/CListViewCtrlEx.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,34 @@ +#pragma once + +class CListViewCtrlEx : public CListViewCtrl { +public: + CListViewCtrlEx( HWND wnd = NULL ) : CListViewCtrl(wnd) {} + CListViewCtrlEx const & operator=( HWND wnd ) { m_hWnd = wnd; return *this; } + unsigned InsertColumnEx(unsigned index, const wchar_t * name, unsigned widthDLU); + unsigned AddColumnEx( const wchar_t * name, unsigned widthDLU ); + void FixContextMenuPoint( CPoint & pt ); + unsigned GetColunnCount(); + + unsigned InsertString( unsigned index, const wchar_t * str ); + unsigned InsertString8( unsigned index, const char * str ); + unsigned AddString( const wchar_t * str ); + unsigned AddString8(const char * str); + void SetItemText(unsigned item, unsigned subItem, const wchar_t * str ); + void SetItemText8(unsigned item, unsigned subItem, const char * str ); + + void AutoSizeColumn( int iCol ) { SetColumnWidth(iCol, LVSCW_AUTOSIZE) ;} + int AddGroup(int iGroupID, const wchar_t * header); +}; + +// BOOL HandleLVKeyDownMod() +#define LVN_KEYDOWN_MOD_HANDLER(id, key, mod, func) \ + if (uMsg == WM_NOTIFY && LVN_KEYDOWN == ((LPNMHDR)lParam)->code && id == ((LPNMHDR)lParam)->idFrom && ((LPNMLVKEYDOWN)lParam)->wVKey == (key) && GetHotkeyModifierFlags() == (mod)) \ + { \ + SetMsgHandled(TRUE); \ + lResult = func()?1:0; \ + if(IsMsgHandled()) \ + return TRUE; \ + } + +// BOOL HandleLVCopy() +#define LVN_COPY_HANDLER(id, func) LVN_KEYDOWN_MOD_HANDLER(id, 'C', MOD_CONTROL, func) diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/CMiddleDragImpl.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/CMiddleDragImpl.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,101 @@ +#include "stdafx.h" +#include "CMiddleDragImpl.h" +#include "CMiddleDragLite.h" +#include "ImplementOnFinalMessage.h" + +double CMiddleDragCommon::myPow(double p_val, double p_exp) { + if (p_val < 0) { + return -pow(-p_val, p_exp); + } else { + return pow(p_val, p_exp); + } +} + +double CMiddleDragCommon::ProcessMiddleDragDeltaInternal(double p_delta) { + p_delta *= (double)KTimerPeriod / 25; /*originally calculated for 25ms timer interval*/ + return myPow(p_delta * 0.05, 2.0); +} + +double CMiddleDragCommon::radiusHelper(double p_x, double p_y) { + return sqrt(p_x * p_x + p_y * p_y); +} +int CMiddleDragCommon::mySGN(LONG v) { + if (v > 0) return 1; + else if (v < 0) return -1; + else return 0; +} + +int32_t CMiddleDragCommon::Round(double val, double & acc) { + val += acc; + int32_t ret = (int32_t)floor(val + 0.5); + acc = val - ret; + return ret; +} + +LONG CMiddleDragCommon::LineToPixelsHelper(LONG & p_overflow, LONG p_pixels, LONG p_dpi, LONG p_lineWidth) { + const int lineWidth = MulDiv(p_lineWidth, p_dpi, 96); + if (lineWidth == 0) return 0; + p_overflow += p_pixels; + LONG ret = p_overflow / lineWidth; + p_overflow -= ret * lineWidth; + return ret; +} + +void CMiddleDragOverlay::ShowHere(CPoint pt) { + + auto dpi = QueryScreenDPIEx(*this); + CSize size(MulDiv(32, dpi.cx, 96), MulDiv(32, dpi.cy, 96)); + // Original path values are for 32x32, don't rescale for sizes close-enough + if (size.cx < 48) size.cx = 32; + if (size.cy < 48) size.cy = 32; + CPoint center(pt); + CPoint origin = center - CSize(size.cx / 2, size.cy / 2); + CRect rect(origin, origin + size); + this->SetWindowPos(HWND_TOPMOST, rect, SWP_SHOWWINDOW | SWP_NOACTIVATE); +} + +namespace { + struct pt_t { uint8_t x, y; }; + static CPoint transform(pt_t pt, CRect const& rc) { + return CPoint(rc.left + MulDiv(pt.x, rc.Width(), 32), rc.top + MulDiv(pt.y, rc.Height(), 32)); + } +} + +void CMiddleDragOverlay::Paint(CDCHandle dc) { + CRect client; + WIN32_OP_D(GetClientRect(&client)); + static constexpr pt_t path[] = { + {15,0}, {9,6}, {9,7}, {14,7}, {14, 14}, + {7, 14}, {7, 9}, {6, 9}, {0, 15}, + {0, 16}, {6, 22}, {7, 22}, {7, 17}, {14, 17}, + {14, 24}, {9, 24}, {9, 25}, {15, 31}, + {16, 31}, {22, 25}, {22, 24}, {17, 24}, {17, 17}, + {24, 17}, {24, 22}, {25, 22}, {31, 16}, + {31, 15}, {25, 9}, {24, 9}, {24, 14}, {17, 14}, + {17, 7}, {22, 7}, {22, 6}, {16, 0}, + }; + + POINT points[std::size(path)]; + for (size_t walk = 0; walk < std::size(path); ++walk) { + points[walk] = transform(path[walk], client); + } + CRgn rgn = CreatePolygonRgn(points, (int)std::size(path), WINDING); + PFC_ASSERT(rgn != NULL); + const HBRUSH brush = (HBRUSH)GetStockObject(DC_BRUSH); + dc.SetDCBrushColor(0); + dc.FillRgn(rgn, brush); + dc.SetDCBrushColor(0xFFFFFF); + dc.FrameRgn(rgn, brush, 1, 1); +} + + +namespace { + class CMiddleDragLiteBase : public CWindowImpl { + public: + BOOL ProcessWindowMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT& lResult, DWORD dwMsgMapID = 0) { return FALSE; } + }; +} +void PP::addMiddleDragToCtrl(HWND wndCtrl) { + auto obj = new ImplementOnFinalMessage > > (); + WIN32_OP_D( obj->SubclassWindow(wndCtrl) ); +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/CMiddleDragImpl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/CMiddleDragImpl.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,275 @@ +#pragma once + +#include "CMiddleDragOverlay.h" +#include + +class CMiddleDragCommon { +public: + enum { + KTimerID = 0x389675f8, + KTimerPeriod = 15, + }; + static double myPow(double p_val, double p_exp); + static double ProcessMiddleDragDeltaInternal(double p_delta); + static double radiusHelper(double p_x, double p_y); + static int mySGN(LONG v); + static int32_t Round(double val, double & acc); + static LONG LineToPixelsHelper(LONG & p_overflow, LONG p_pixels, LONG p_dpi, LONG p_lineWidth); +}; + +template +class CMiddleDragImpl : public TBase, protected CMiddleDragCommon { +private: + typedef CMiddleDragImpl TSelf; +public: + template CMiddleDragImpl( arg_t && ... arg ) : TBase(std::forward(arg) ... ) {} + + BEGIN_MSG_MAP_EX(TSelf) + MESSAGE_HANDLER(WM_TIMER,OnTimer); + MESSAGE_HANDLER(WM_CAPTURECHANGED,OnCaptureChanged); + MESSAGE_HANDLER(WM_MBUTTONDOWN,OnMButtonDown); + MESSAGE_HANDLER(WM_MBUTTONDBLCLK,OnMButtonDown); + MESSAGE_HANDLER(WM_MBUTTONUP,OnMButtonUp); + MESSAGE_HANDLER(WM_LBUTTONDOWN,OnMouseAction); + MESSAGE_HANDLER(WM_RBUTTONDOWN,OnMouseAction); + MESSAGE_HANDLER(WM_LBUTTONDBLCLK,OnMouseAction); + MESSAGE_HANDLER(WM_RBUTTONDBLCLK,OnMouseAction); + MESSAGE_HANDLER(WM_LBUTTONUP,OnMouseAction); + MESSAGE_HANDLER(WM_RBUTTONUP,OnMouseAction); + MESSAGE_HANDLER(WM_XBUTTONDOWN,OnMouseAction); + MESSAGE_HANDLER(WM_XBUTTONDBLCLK,OnMouseAction); + MESSAGE_HANDLER(WM_XBUTTONUP,OnMouseAction); + MESSAGE_HANDLER(WM_MOUSEMOVE,OnMouseMove); + MESSAGE_HANDLER(WM_DESTROY,OnDestroyPassThru); + CHAIN_MSG_MAP(TBase); + END_MSG_MAP() +protected: + bool CanSmoothScroll() const { + return !m_active; + } +private: + bool m_active = false, m_dragged = false; + CPoint m_base; + CMiddleDragOverlay m_overlay; + double m_accX = 0, m_accY = 0; + + LRESULT OnDestroyPassThru(UINT,WPARAM,LPARAM,BOOL& bHandled) { + if (m_overlay != NULL) m_overlay.DestroyWindow(); + bHandled = FALSE; + return 0; + } + + LRESULT OnMButtonUp(UINT,WPARAM,LPARAM,BOOL&) { + if (m_active /*&& m_dragged*/) { + EndDrag(); + } + return 0; + } + + LRESULT OnMButtonDown(UINT,WPARAM,LPARAM p_lp,BOOL&) { + if (m_active) { + EndDrag(); + return 0; + } + EndDrag(); + this->SetFocus(); + CPoint pt(p_lp); + WIN32_OP_D( this->ClientToScreen(&pt) ); + StartDrag(pt); + return 0; + } + + LRESULT OnMouseMove(UINT,WPARAM,LPARAM p_lp,BOOL& bHandled) { + if (m_active) { + if (!m_dragged) { + CPoint pt(p_lp); + WIN32_OP_D( this->ClientToScreen(&pt) ); + if (pt != m_base) { + m_dragged = true; + } + } + bHandled = TRUE; + } else { + bHandled = FALSE; + } + return 0; + } + + LRESULT OnMouseAction(UINT,WPARAM,LPARAM,BOOL& bHandled) { + EndDrag(); + bHandled = FALSE; + return 0; + } + + void StartDrag(CPoint const & p_point) { + ::SetCapture(NULL); + + if (m_overlay == NULL) { + PFC_ASSERT( this->m_hWnd != NULL ); + WIN32_OP_D(m_overlay.Create(*this)); + } + + //todo sanity checks - don't drag when the entire content is visible, perhaps use a different icon when only vertical or horizontal drag is possible + SetCursor(::LoadCursor(NULL,IDC_SIZEALL)); + m_active = true; + m_dragged = false; + m_base = p_point; + m_accX = m_accY = 0; + this->SetCapture(); + this->SetTimer(KTimerID,KTimerPeriod); + + m_overlay.ShowHere(p_point); + } + + void EndDrag() { + if (m_active) ::SetCapture(NULL); + } + + void HandleEndDrag() { + if (m_active) { + m_active = false; + this->KillTimer(KTimerID); + if (m_overlay != NULL) m_overlay.ShowWindow(SW_HIDE); + } + } + + LRESULT OnCaptureChanged(UINT,WPARAM,LPARAM,BOOL& bHandled) { + HandleEndDrag(); + bHandled = FALSE; + return 0; + } + + LRESULT OnTimer(UINT,WPARAM p_wp,LPARAM,BOOL& bHandled) { + switch(p_wp) { + case KTimerID: + { + CPoint ptCursor; + if (GetCursorPos(&ptCursor)) { + this->MoveViewOriginDelta(ProcessMiddleDragDelta(ptCursor - m_base)); + } + } + return 0; + default: + bHandled = FALSE; + return 0; + } + } + + CPoint ProcessMiddleDragDelta(CPoint p_delta) { + const CSize dpi = QueryScreenDPIEx(); + if (dpi.cx <= 0 || dpi.cy <= 0 || p_delta == CPoint(0, 0)) return CPoint(0, 0); + const double dpiMulX = 96.0 / (double)dpi.cx; + const double dpiMulY = 96.0 / (double)dpi.cy; + + const double deltaTotal = ProcessMiddleDragDeltaInternal(radiusHelper((double)p_delta.x * dpiMulX, (double)p_delta.y * dpiMulY)); + + double xVal = 0, yVal = 0; + + if (p_delta.x == 0) { + yVal = deltaTotal; + } else if (p_delta.y == 0) { + xVal = deltaTotal; + } else { + const double ratio = (double)p_delta.x / (double)p_delta.y; + yVal = sqrt((deltaTotal*deltaTotal) / (1.0 + (ratio*ratio))); + xVal = yVal * ratio; + } + + xVal = mySGN(p_delta.x) * fabs(xVal); + yVal = mySGN(p_delta.y) * fabs(yVal); + + + return CPoint(Round(xVal / dpiMulX, m_accX), Round(yVal / dpiMulY, m_accY)); + } + +}; + +template +class CMiddleDragWrapper : public TBase { +private: + typedef CMiddleDragWrapper TSelf; +public: + template CMiddleDragWrapper(arg_t && ... arg ) : TBase(std::forward(arg) ... ) { m_overflow = CPoint(0, 0); m_lineWidth = CSize(4, 16); } + + BEGIN_MSG_MAP_EX(TSelf) + MESSAGE_HANDLER(WM_CAPTURECHANGED,OnCaptureChanged); + CHAIN_MSG_MAP(TBase) + END_MSG_MAP() + + void MoveViewOriginDelta(CPoint p_delta) { + MoveViewOriginDeltaLines( MiddleDrag_PixelsToLines( m_overflow, p_delta ) ); + } + void MoveViewOriginDeltaLines(CPoint p_delta) { + FireScrollMessage(WM_HSCROLL,p_delta.x); + FireScrollMessage(WM_VSCROLL,p_delta.y); + } + void SetLineWidth(CSize p_width) {m_lineWidth = p_width;} + +private: + void FireScrollMessage(UINT p_msg,int p_delta) { + UINT count = (UINT)(p_delta<0?-p_delta:p_delta); + const UINT which = (p_msg == WM_HSCROLL ? SB_HORZ : SB_VERT); + SCROLLINFO si = {}; si.cbSize = sizeof(si); si.fMask = SIF_PAGE | SIF_RANGE; + if (!this->GetScrollInfo(which, &si) || si.nPage <= 0) return; + while(count >= si.nPage) { + const WPARAM code = p_delta < 0 ? SB_PAGEUP : SB_PAGEDOWN; + this->SendMessage(p_msg, code, 0); + count -= si.nPage; + } + const WPARAM code = p_delta < 0 ? SB_LINEUP : SB_LINEDOWN; + for(UINT walk = 0; walk < count; ++walk) this->SendMessage(p_msg, code, 0); + } + LRESULT OnCaptureChanged(UINT,WPARAM,LPARAM,BOOL& bHandled) { + m_overflow = CPoint(0,0); + bHandled = FALSE; + return 0; + } + + + CPoint MiddleDrag_PixelsToLines(CPoint & p_overflow,CPoint p_pixels) { + const CSize dpi = QueryScreenDPIEx(); + if (dpi.cx <= 0 || dpi.cy <= 0) return CPoint(0,0); + CPoint pt; + pt.x = CMiddleDragCommon::LineToPixelsHelper(p_overflow.x,p_pixels.x,dpi.cx,m_lineWidth.cx); + pt.y = CMiddleDragCommon::LineToPixelsHelper(p_overflow.y,p_pixels.y,dpi.cy,m_lineWidth.cy); + return pt; + } + + CSize m_lineWidth; + + CPoint m_overflow; +}; + +template +class CWindow_DummyMsgMap : public TBase , public CMessageMap { +public: + BOOL ProcessWindowMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, + LRESULT& lResult, DWORD dwMsgMapID = 0) {return FALSE;} +}; + +typedef CMiddleDragImpl > > CMiddleDragImplSimple; + +template +class CContainedWindow_MsgMap : public CContainedWindowT > { +protected: + CContainedWindow_MsgMap() : CContainedWindowT >(msgMapCast(this)) {} +private: + template static CMessageMap * msgMapCast(t* arg) { return arg; } +}; + +template +class CMiddleDragImplCtrlHook : public CMiddleDragImpl > > { +}; + +template class CMiddleDragImplCtrlHookEx : public CMiddleDragImplCtrlHook { +public: + CMiddleDragImplCtrlHookEx(CMessageMap * hook, DWORD hookMapID = 0) : m_hook(*hook), m_hookMapID(hookMapID) {} + + BEGIN_MSG_MAP_EX(CMiddleDragImplCtrlHookEx) + CHAIN_MSG_MAP(CMiddleDragImplCtrlHook) + CHAIN_MSG_MAP_ALT_MEMBER(m_hook,m_hookMapID); + END_MSG_MAP() +private: + DWORD const m_hookMapID; + CMessageMap & m_hook; +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/CMiddleDragLite.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/CMiddleDragLite.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,9 @@ +#pragma once + +namespace PP { + //! Single-function-call API to add middle click drag capability to any standard Windows control. \n + //! Works with listviews, listboxes, treeviews, etc. \n + //! Window will be subclassed, lifetime of subclass managed automatically. No further interaction needed from your code. \n + //! If you also subclass it to handle middle click events, pay attention to order in which you install the subclasses to receive your events. + void addMiddleDragToCtrl(HWND wndCtrl); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/CMiddleDragOverlay.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/CMiddleDragOverlay.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,41 @@ +#pragma once + +#include "win32_op.h" +#include "win32_utility.h" + +class CMiddleDragOverlay : public CWindowImpl > { +public: + DECLARE_WND_CLASS_EX(TEXT("{61BFC7AD-C00F-4CEA-8E6A-EA22E01F43F9}"),0,(-1)); + + enum { + ColorKey = 0xc0ffee + }; + + BEGIN_MSG_MAP_EX(CMiddleDragOverlay) + MESSAGE_HANDLER(WM_CREATE,OnCreate); + MSG_WM_ERASEBKGND(OnEraseBkgnd) + MSG_WM_PAINT(OnPaint) + END_MSG_MAP() + + void ShowHere(CPoint pt); +private: + LRESULT OnCreate(UINT,WPARAM,LPARAM,BOOL&) { + ::SetLayeredWindowAttributes(*this,ColorKey,0,LWA_COLORKEY); + return 0; + } + BOOL OnEraseBkgnd(CDCHandle dc) { + CRect rcClient; + WIN32_OP_D(GetClientRect(rcClient)); + dc.FillSolidRect(rcClient, ColorKey); + return TRUE; + } + void OnPaint(CDCHandle dc) { + if (dc) { + Paint(dc); + } else { + CPaintDC pdc(*this); + Paint(pdc.m_hDC); + } + } + void Paint(CDCHandle dc); +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/CPopupTooltipMessage.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/CPopupTooltipMessage.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,101 @@ +#pragma once + +#include "win32_op.h" +#include "wtl-pp.h" + +class CPopupTooltipMessage { +public: + CPopupTooltipMessage(DWORD style = TTS_BALLOON | TTS_NOPREFIX) : m_style(style | WS_POPUP), m_toolinfo(), m_shutDown() {} + void ShowFocus(const TCHAR * message, CWindow wndParent) { + Show(message, wndParent); wndParent.SetFocus(); + } + void Show(const TCHAR * message, CWindow wndParent) { + if (m_shutDown || (message == NULL && m_tooltip.m_hWnd == NULL)) return; + Initialize(); + Hide(); + + if (message != NULL) { + CRect rect; + WIN32_OP_D(wndParent.GetWindowRect(rect)); + ShowInternal(message, wndParent, rect); + } + } + void ShowEx(const TCHAR * message, CWindow wndParent, CRect rect) { + if (m_shutDown) return; + Initialize(); + Hide(); + ShowInternal(message, wndParent, rect); + } + void Hide() { + if (m_tooltip.m_hWnd != NULL && m_tooltip.GetToolCount() > 0) { + m_tooltip.TrackActivate(&m_toolinfo, FALSE); + m_tooltip.DelTool(&m_toolinfo); + } + } + + void CleanUp() { + if (m_tooltip.m_hWnd != NULL) { + m_tooltip.DestroyWindow(); + } + } + void ShutDown() { + m_shutDown = true; CleanUp(); + } +private: + void ShowInternal(const TCHAR * message, CWindow wndParent, CRect rect) { + + PFC_ASSERT(!m_shutDown); + PFC_ASSERT(message != NULL); + PFC_ASSERT(wndParent != NULL); + + if (_tcschr(message, '\n') != nullptr) { + m_tooltip.SetMaxTipWidth(rect.Width()); + } + m_toolinfo.cbSize = sizeof(m_toolinfo); + m_toolinfo.uFlags = TTF_TRACK | TTF_IDISHWND | TTF_ABSOLUTE | TTF_TRANSPARENT | TTF_CENTERTIP; + m_toolinfo.hwnd = wndParent; + m_toolinfo.uId = 0; + m_toolinfo.lpszText = const_cast(message); + m_toolinfo.hinst = NULL; //core_api::get_my_instance(); + if (m_tooltip.AddTool(&m_toolinfo)) { + m_tooltip.TrackPosition(rect.CenterPoint().x, rect.bottom); + m_tooltip.TrackActivate(&m_toolinfo, TRUE); + } + } + void Initialize() { + if (m_tooltip.m_hWnd == NULL) { + WIN32_OP(m_tooltip.Create(NULL, NULL, NULL, m_style)); + } + } + CToolTipCtrl m_tooltip; + TOOLINFO m_toolinfo; + const DWORD m_style; + bool m_shutDown; +}; + + +template class CDialogWithTooltip : public CDialogImpl { +public: + BEGIN_MSG_MAP_EX(CDialogWithTooltip) + MSG_WM_DESTROY(OnDestroy) + END_MSG_MAP() + + void ShowTip(UINT id, const TCHAR * label) { + m_tip.Show(label, this->GetDlgItem(id)); + } + void ShowTip(HWND child, const TCHAR * label) { + m_tip.Show(label, child); + } + + void ShowTipF(UINT id, const TCHAR * label) { + m_tip.ShowFocus(label, this->GetDlgItem(id)); + } + void ShowTipF(HWND child, const TCHAR * label) { + m_tip.ShowFocus(label, child); + } + void HideTip() { m_tip.Hide(); } +private: + void OnDestroy() { m_tip.ShutDown(); this->SetMsgHandled(FALSE); } + CPopupTooltipMessage m_tip; +}; + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/CPowerRequest.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/CPowerRequest.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,68 @@ +#include "stdafx.h" + +#include "CPowerRequest.h" + +#ifdef CPowerRequestAPI_Avail + +class CPowerRequestAPI { +public: + static void ToggleSystem(HANDLE hRequest, bool bSystem) { + Toggle(hRequest, bSystem, PowerRequestSystemRequired); + } + + static void ToggleExecution(HANDLE hRequest, bool bSystem) { + const POWER_REQUEST_TYPE RequestType = IsWindows8OrGreater() ? PowerRequestExecutionRequired : PowerRequestSystemRequired; + Toggle(hRequest, bSystem, RequestType); + } + + static void ToggleDisplay(HANDLE hRequest, bool bDisplay) { + Toggle(hRequest, bDisplay, PowerRequestDisplayRequired); + } + + static void Toggle(HANDLE hRequest, bool bToggle, POWER_REQUEST_TYPE what) { + if (bToggle) { + PowerSetRequest(hRequest, what); + } else { + PowerClearRequest(hRequest, what); + } + } +}; + +CPowerRequest::CPowerRequest(const wchar_t * Reason) : m_Request(INVALID_HANDLE_VALUE), m_bSystem(), m_bDisplay() { + REASON_CONTEXT ctx = {POWER_REQUEST_CONTEXT_VERSION, POWER_REQUEST_CONTEXT_SIMPLE_STRING}; + ctx.Reason.SimpleReasonString = const_cast(Reason); + m_Request = PowerCreateRequest(&ctx); +} + +void CPowerRequest::SetSystem(bool bSystem) { + if (bSystem == m_bSystem) return; + m_bSystem = bSystem; + if (m_Request != INVALID_HANDLE_VALUE) { + CPowerRequestAPI::ToggleSystem( m_Request, bSystem ); + } +} + +void CPowerRequest::SetExecution(bool bExecution) { + if (bExecution == m_bSystem) return; + m_bSystem = bExecution; + if (m_Request != INVALID_HANDLE_VALUE) { + CPowerRequestAPI::ToggleExecution( m_Request, bExecution ); + } +} + +void CPowerRequest::SetDisplay(bool bDisplay) { + if (bDisplay == m_bDisplay) return; + m_bDisplay = bDisplay; + if (m_Request != INVALID_HANDLE_VALUE) { + CPowerRequestAPI::ToggleDisplay(m_Request, bDisplay); + } +} + +CPowerRequest::~CPowerRequest() { + if (m_Request != INVALID_HANDLE_VALUE) { + CloseHandle(m_Request); + } +} + +#endif // _WIN32 + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/CPowerRequest.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/CPowerRequest.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,43 @@ +#pragma once + +#ifdef _WIN32 + +#ifdef WINAPI_FAMILY_PARTITION +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) +#define CPowerRequestAPI_Avail +#endif +#else // no WINAPI_FAMILY_PARTITION, desktop SDK +#define CPowerRequestAPI_Avail +#endif + +#endif // _WIN32 + +#ifdef CPowerRequestAPI_Avail + +class CPowerRequest { +public: + CPowerRequest(const wchar_t * Reason); + void SetSystem(bool bSystem); + void SetExecution(bool bExecution); + void SetDisplay(bool bDisplay); + ~CPowerRequest(); + + CPowerRequest(const CPowerRequest&) = delete; + void operator=(const CPowerRequest&) = delete; +private: + HANDLE m_Request = INVALID_HANDLE_VALUE; + bool m_bSystem = false, m_bDisplay = false; +}; +#else + +class CPowerRequest { +public: + CPowerRequest(const wchar_t * Reason) {} + void SetSystem(bool bSystem) {} + void SetExecution(bool bExecution) {} + void SetDisplay(bool bDisplay) {} + CPowerRequest(const CPowerRequest&) = delete; + void operator=(const CPowerRequest&) = delete; +}; + +#endif // CPowerRequestAPI_Avail diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/CPropVariant.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/CPropVariant.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,54 @@ +#pragma once + +class CPropVariant : public PROPVARIANT { +public: + CPropVariant() {init();} + ~CPropVariant() {clear();} + CPropVariant( const CPropVariant & other ) { + init(); + PropVariantCopy( this, &other ); + } + const CPropVariant& operator=( const CPropVariant & other ) { + clear(); + PropVariantCopy(this, &other); + return *this; + } + + bool toInt64(int64_t & out) const { + switch( vt ) { + case VT_I1: out = (int64_t) cVal; return true; + case VT_I2: out = (int64_t) iVal; return true; + case VT_I4: out = (int64_t) lVal; return true; + case VT_I8: out = (int64_t) hVal.QuadPart; return true; + case VT_INT: out = (int64_t) intVal; return true; + default: return false; + } + } + bool toUint64(uint64_t & out) const { + switch( vt ) { + case VT_UI1: out = (uint64_t) bVal; return true; + case VT_UI2: out = (uint64_t) uiVal; return true; + case VT_UI4: out = (uint64_t) ulVal; return true; + case VT_UI8: out = (uint64_t) uhVal.QuadPart; return true; + case VT_UINT: out = (uint64_t) uintVal; return true; + default: return false; + } + } + bool toString( pfc::string_base & out ) const { + switch( vt ) { + case VT_LPSTR: + out = pfc::stringcvt::string_utf8_from_ansi( pszVal ); return true; + case VT_LPWSTR: + out = pfc::stringcvt::string_utf8_from_wide( pwszVal ); return true; + default: return false; + } + } +private: + void clear() { + PropVariantClear( this ); + } + void init() { + PROPVARIANT * pv = this; + PropVariantInit( pv ); + } +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/CWindowCreateAndDelete.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/CWindowCreateAndDelete.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,11 @@ +#pragma once + +#include "win32_op.h" + +template +class CWindowCreateAndDelete : public TClass { +public: + template CWindowCreateAndDelete(HWND parent, arg_t && ... arg) : TClass(std::forward(arg) ...) { WIN32_OP(this->Create(parent) != NULL); } +private: + void OnFinalMessage(HWND wnd) override { PFC_ASSERT_NO_EXCEPTION(TClass::OnFinalMessage(wnd)); PFC_ASSERT_NO_EXCEPTION(delete this); } +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/Controls.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/Controls.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,82 @@ +#include "stdafx.h" +#include +#include "Controls.h" +#include "PaintUtils.h" +#include "HyperLinkCtrl.h" + +void CStaticSeparator::OnPaint(CDCHandle) { + PaintUtils::PaintSeparatorControl(*this); +} + +void CSeparator::OnPaint(CDCHandle dc) { + PaintUtils::PaintSeparatorControl(*this); +} + +#if 0 // BROKEN WITH DARK MODE, DO NOT USE +CStaticMainInstruction::CStaticMainInstruction() { + SetThemePart(TEXT_MAININSTRUCTION); +} + +void CStaticThemed::OnPaint(CDCHandle) { + if (m_fallback) { + SetMsgHandled(FALSE); return; + } + if (m_theme == NULL) { + m_theme.OpenThemeData(*this, L"TextStyle"); + if (m_theme == NULL) { + m_fallback = true; SetMsgHandled(FALSE); return; + } + } + CPaintDC dc(*this); + TCHAR buffer[512] = {}; + GetWindowText(buffer, _countof(buffer)); + const int txLen = (int) pfc::strlen_max_t(buffer, _countof(buffer)); + CRect contentRect; + WIN32_OP_D(GetClientRect(contentRect)); + SelectObjectScope scopeFont(dc, GetFont()); + dc.SetTextColor(GetSysColor(COLOR_WINDOWTEXT)); + dc.SetBkMode(TRANSPARENT); + + if (txLen > 0) { + CRect rcText(contentRect); + DWORD flags = 0; + DWORD style = GetStyle(); + if (style & SS_LEFT) flags |= DT_LEFT; + else if (style & SS_RIGHT) flags |= DT_RIGHT; + else if (style & SS_CENTER) flags |= DT_CENTER; + if (style & SS_ENDELLIPSIS) flags |= DT_END_ELLIPSIS; + + HRESULT retval = DrawThemeText(m_theme, dc, m_id, 0, buffer, txLen, flags, 0, rcText); + PFC_ASSERT(SUCCEEDED(retval)); + } +} +#endif + + +#include "DarkMode-CHyperLink.h" +#include "windowLifetime.h" + +void PP::createHyperLink(HWND wndReplaceMe) { + auto obj = PP::subclassThisWindow(wndReplaceMe); + obj->SetHyperLinkExtendedStyle(HLINK_NOTIFYBUTTON); +} + +namespace { + class CHyperLinkLambda : public DarkMode::CHyperLinkImpl { + public: + std::function f; + bool Navigate() { + f(); + return true; + } + }; +} +void PP::createHyperLink(HWND wndReplaceMe, std::function handler) { + auto obj = PP::subclassThisWindow(wndReplaceMe); + obj->f = handler; +} + +void PP::createHyperLink(HWND wndReplaceMe, const wchar_t* openURL) { + auto obj = PP::subclassThisWindow(wndReplaceMe); + obj->SetHyperLink(openURL); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/Controls.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/Controls.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,103 @@ +#pragma once + +#pragma comment(lib, "uxtheme.lib") + +#include "wtl-pp.h" +#include "win32_op.h" + +// Separator-in-dialog tool: subclass a static control on init +class CStaticSeparator : public CWindowImpl { +public: + CStaticSeparator() {} + BEGIN_MSG_MAP_EX(CSeparator) + MSG_WM_PAINT(OnPaint) + MSG_WM_SETTEXT(OnSetText) + END_MSG_MAP() +private: + int OnSetText(LPCTSTR) { + Invalidate(); + SetMsgHandled(FALSE); + return 0; + } + void OnPaint(CDCHandle); +}; + +// CWindowRegistered with font & text functionality, for creating custom text label classes +template +class CTextControl : public CWindowRegisteredT { +public: + BEGIN_MSG_MAP_EX(CTextControl) + MSG_WM_SETFONT(OnSetFont) + MSG_WM_GETFONT(OnGetFont) + MSG_WM_SETTEXT(OnSetText) + CHAIN_MSG_MAP(__super) + END_MSG_MAP() +private: + HFONT OnGetFont() { + return m_font; + } + void OnSetFont(HFONT font, BOOL bRedraw) { + m_font = font; + if (bRedraw) this->Invalidate(); + } + int OnSetText(LPCTSTR) { + this->Invalidate();this->SetMsgHandled(FALSE); return 0; + } + CFontHandle m_font; +}; + +// CStaticThemed BROKEN WITH DARK MODE, DO NOT USE +// CStaticMainInstruction = use 1.5x scaled font for non subclassed static instead +#if 0 +// Static control subclass with override for theme part used for rendering +class CStaticThemed : public CWindowImpl { +public: + CStaticThemed() : m_id(), m_fallback() {} + BEGIN_MSG_MAP_EX(CStaticThemed) + MSG_WM_PAINT(OnPaint) + MSG_WM_THEMECHANGED(OnThemeChanged) + MSG_WM_SETTEXT(OnSetText) + END_MSG_MAP() + + void SetThemePart(int id) {m_id = id; if (m_hWnd != NULL) Invalidate();} +private: + int OnSetText(LPCTSTR) { + Invalidate(); + SetMsgHandled(FALSE); + return 0; + } + void OnThemeChanged() { + m_theme.Release(); + m_fallback = false; + } + void OnPaint(CDCHandle); + int m_id; + CTheme m_theme; + bool m_fallback; +}; + +class CStaticMainInstruction : public CStaticThemed { +public: + CStaticMainInstruction(); +}; +#endif + + +class CSeparator : public CTextControl { +public: + BEGIN_MSG_MAP_EX(CSeparator) + MSG_WM_PAINT(OnPaint) + MSG_WM_ENABLE(OnEnable) + CHAIN_MSG_MAP(__super) + END_MSG_MAP() + + static const TCHAR * GetClassName() { + return _T("foobar2000:separator"); + } +private: + void OnEnable(BOOL) { + Invalidate(); + } + void OnPaint(CDCHandle dc); +}; + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/DarkMode-CHyperLink.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/DarkMode-CHyperLink.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,37 @@ +#pragma once +#include +#include "DarkMode.h" + +namespace DarkMode { + static constexpr COLORREF colorHyperLink = 0xCC6600; // taken from screenshot of syslink + + template class CHyperLinkImpl : public ::CHyperLinkImpl { + public: + BEGIN_MSG_MAP_EX(CDarkHyperLinkImpl) + MESSAGE_HANDLER_EX(DarkMode::msgSetDarkMode(), OnSetDarkMode) + CHAIN_MSG_MAP(::CHyperLinkImpl) + END_MSG_MAP() + private: + LRESULT OnSetDarkMode(UINT, WPARAM wp, LPARAM) { + const bool bDark = (wp != 0); + if ( m_clrLinkBackup == CLR_INVALID ) m_clrLinkBackup = this->m_clrLink; + + if (bDark != m_isDark) { + m_isDark = bDark; + this->m_clrLink = bDark ? colorHyperLink : m_clrLinkBackup; + this->Invalidate(); + } + + return 1; + } + COLORREF m_clrLinkBackup = CLR_INVALID; + bool m_isDark = false; + }; + + + class CHyperLink : public CHyperLinkImpl { + public: + DECLARE_WND_CLASS(_T("WTL_DarkHyperLink")) + }; + +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/DarkMode.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/DarkMode.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,1931 @@ +#include "stdafx.h" +#include "DarkMode.h" +#include "DarkModeEx.h" +#include "win32_utility.h" +#include "win32_op.h" +#include "PaintUtils.h" +#include "ImplementOnFinalMessage.h" +#include +#include "GDIUtils.h" +#include "CListControl.h" +#include "CListControl-Subst.h" +#include "ReStyleWnd.h" +#include + +// Allow scary undocumented ordinal-dll-export functions? +#define DARKMODE_ALLOW_HAX 1 + +#define DARKMODE_DEBUG 0 + +#if DARKMODE_DEBUG +#define DARKMODE_DEBUG_PRINT(...) PFC_DEBUG_PRINT("DarkMode: ", __VA_ARGS__) +#else +#define DARKMODE_DEBUG_PRINT(...) +#endif + + +#include +#pragma comment(lib, "dwmapi.lib") + +/* + +==== DARK MODE KNOWLEDGE BASE ==== + +== Generic window == +UpdateTitleBar() to set title bar to black + +== Dialog box == +Use WM_CTLCOLORDLG, background of 0x383838 +UpdateTitleBar() to set title bar to black + +== Edit box == +Use WM_CTLCOLOREDIT, background of 0x383838 +ApplyDarkThemeCtrl() with "Explorer" + +== Drop list combo == +Method #1: ::SetWindowTheme(wnd, L"DarkMode_CFD", nullptr); +Method #2: ::SetWindowTheme(wnd, L"", L""); to obey WM_CTLCOLOR* but leaves oldstyle classic-colors button and breaks comboboxex + +== Button == +Use WM_CTLCOLORBTN, background of 0x383838 +ApplyDarkThemeCtrl() with "Explorer" + +== Scroll bar == +ApplyDarkThemeCtrl() with "Explorer" +^^ on either scrollbar or the window that implicitly creates scrollbars + +== Header == +ApplyDarkThemeCtrl() with "ItemsView" +Handle custom draw, override text color + +== Tree view == +ApplyDarkThemeCtrl() with "Explorer" +Set text/bk colors explicitly + +Text color: 0xdedede +Background: 0x191919 + +Label-editing: +Pass WM_CTLCOLOR* to parent, shim TVM_EDITLABEL to pass theme to the editbox (not really necessary tho) + + +== Rebar == +Can be beaten into working to some extent with a combination of: +* ::SetWindowTheme(toolbar, L"", L""); or else RB_SETTEXTCOLOR & REBARBANDINFO colors are disregarded +* Use RB_SETTEXTCOLOR / SetTextColor() + RB_SETBKCOLOR / SetBkColor() to override text/background colors +* Override WM_ERASEBKGND to draw band frames, RB_SETBKCOLOR doesn't seem to be thorough +* NM_CUSTOMDRAW on parent window to paint band labels & grippers without annoying glitches +NM_CUSTOMDRAW is buggy, doesn't hand you band indexes to query text, have to use hit tests to know what text to render + +Solution: full custom draw + + +== Toolbar == +Source: https://stackoverflow.com/questions/61271578/winapi-toolbar-text-color +Respects background color of its parent +Override text: +::SetWindowTheme(toolbar, L"", L""); or else NM_CUSTOMDRAW color is disregarded +NM_CUSTOMDRAW handler: +switch (cd->nmcd.dwDrawStage) { + case CDDS_PREPAINT: return CDRF_NOTIFYITEMDRAW; + case CDDS_ITEMPREPAINT: cd->clrText = DarkMode::GetSysColor(COLOR_WINDOWTEXT); return CDRF_DODEFAULT; +} + +== Tab control == +Full custom draw, see CTabsHook + +== List View == +Dark scrollbars are shown only if using "Explorer" theme, but other stuff needs "ItemsView" theme??? +Other projects shim Windows functions to bypass the above. +Avoid using List View, use libPPUI CListControl instead. + +== List Box == +Use WM_CTLCOLOR* + +== Status Bar == +Full custom draw + +== Check box, radio button == +SetWindowTheme(wnd, L"", L""); works but not 100% pretty, disabled text ugly in particular +Full custom draw preferred + +== Group box === +SetWindowTheme(wnd, L"", L""); works but not 100% pretty, disabled text ugly in particular +Full custom draw preferred (we don't do this). +Avoid disabling groupboxes / use something else. + +==== NOTES ==== +AllowDarkModeForWindow() needs SetPreferredAppMode() to take effect, hence we implicitly call it +AllowDarkModeForWindow() must be called BEFORE SetWindowTheme() to take effect + +It seems it is interchangeable to do: +AllowDarkModeForWindow(wnd, true); SetWindowTheme(wnd, L"foo", nullptr); +vs +SetWindowTheme(wnd, L"DarkMode_foo", nullptr) +But the latter doesn't require undocumented function calls and doesn't infect all menus with dark mode +*/ + +namespace { + enum class PreferredAppMode + { + Default, + AllowDark, + ForceDark, + ForceLight, + Max + }; + + enum WINDOWCOMPOSITIONATTRIB + { + WCA_UNDEFINED = 0, + WCA_NCRENDERING_ENABLED = 1, + WCA_NCRENDERING_POLICY = 2, + WCA_TRANSITIONS_FORCEDISABLED = 3, + WCA_ALLOW_NCPAINT = 4, + WCA_CAPTION_BUTTON_BOUNDS = 5, + WCA_NONCLIENT_RTL_LAYOUT = 6, + WCA_FORCE_ICONIC_REPRESENTATION = 7, + WCA_EXTENDED_FRAME_BOUNDS = 8, + WCA_HAS_ICONIC_BITMAP = 9, + WCA_THEME_ATTRIBUTES = 10, + WCA_NCRENDERING_EXILED = 11, + WCA_NCADORNMENTINFO = 12, + WCA_EXCLUDED_FROM_LIVEPREVIEW = 13, + WCA_VIDEO_OVERLAY_ACTIVE = 14, + WCA_FORCE_ACTIVEWINDOW_APPEARANCE = 15, + WCA_DISALLOW_PEEK = 16, + WCA_CLOAK = 17, + WCA_CLOAKED = 18, + WCA_ACCENT_POLICY = 19, + WCA_FREEZE_REPRESENTATION = 20, + WCA_EVER_UNCLOAKED = 21, + WCA_VISUAL_OWNER = 22, + WCA_HOLOGRAPHIC = 23, + WCA_EXCLUDED_FROM_DDA = 24, + WCA_PASSIVEUPDATEMODE = 25, + WCA_USEDARKMODECOLORS = 26, + WCA_LAST = 27 + }; + + struct WINDOWCOMPOSITIONATTRIBDATA + { + WINDOWCOMPOSITIONATTRIB Attrib; + PVOID pvData; + SIZE_T cbData; + }; +#if DARKMODE_ALLOW_HAX + using fnAllowDarkModeForWindow = bool (WINAPI*)(HWND hWnd, bool allow); // ordinal 133 + using fnSetPreferredAppMode = PreferredAppMode(WINAPI*)(PreferredAppMode appMode); // ordinal 135, since 1809 + using fnFlushMenuThemes = void (WINAPI*)(); // ordinal 136 + fnAllowDarkModeForWindow _AllowDarkModeForWindow = nullptr; + fnSetPreferredAppMode _SetPreferredAppMode = nullptr; + fnFlushMenuThemes _FlushMenuThemes = nullptr; + + bool ImportsInited = false; + + void InitImports() { + if (ImportsInited) return; + if (DarkMode::IsSupportedSystem()) { + HMODULE hUxtheme = LoadLibraryEx(L"uxtheme.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32); + if (hUxtheme) { + _AllowDarkModeForWindow = reinterpret_cast(GetProcAddress(hUxtheme, MAKEINTRESOURCEA(133))); + _SetPreferredAppMode = reinterpret_cast(GetProcAddress(hUxtheme, MAKEINTRESOURCEA(135))); + _FlushMenuThemes = reinterpret_cast(GetProcAddress(hUxtheme, MAKEINTRESOURCEA(136))); + } + } + ImportsInited = true; + } +#endif +} + + + +namespace DarkMode { + UINT msgSetDarkMode() { + // No need to threadguard this, should be main thread only, not much harm even if it's not + static UINT val = 0; + if (val == 0) val = RegisterWindowMessage(L"libPPUI:msgSetDarkMode"); + return val; + } + bool IsSupportedSystem() { + return Win10BuildNumber() >= 17763 && !IsWine(); // require at least Win10 1809 / Server 2019 + } + bool IsWindows11() { + return Win10BuildNumber() >= 22000; + } + bool QueryUserOption() { + DWORD v = 0; + DWORD cb = sizeof(v); + DWORD type = 0; + if (RegGetValue(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", L"AppsUseLightTheme", RRF_RT_REG_DWORD, &type, &v, &cb) == 0) { + if (type == REG_DWORD) { + return v == 0; + } + } + return false; + } + void UpdateTitleBar(HWND hWnd, bool bDark) { + if (!IsSupportedSystem()) return; + + CWindow wnd(hWnd); + DWORD style = wnd.GetStyle(); + if ((style & WS_CAPTION) != WS_CAPTION) return; + +#if 0 + // Some apps do this - no idea why, doesn't work + // Kept for future reference + AllowDarkModeForWindow(hWnd, bDark); + SetProp(hWnd, L"UseImmersiveDarkModeColors", (HANDLE)(INT_PTR)(bDark ? TRUE : FALSE)); +#endif + + if (IsWindows11()) { + // DwmSetWindowAttribute() + // Windows 11 : works + // Windows 10 @ late 2021 : doesn't work + // Server 2019 : as good as SetWindowCompositionAttribute(), needs ModifyStyle() hack for full effect + BOOL arg = !!bDark; + DwmSetWindowAttribute(hWnd, 19 /*DWMWA_USE_IMMERSIVE_DARK_MODE*/, &arg, sizeof(arg)); + } else { + // Windows 10 mode + using fnSetWindowCompositionAttribute = BOOL(WINAPI*)(HWND hWnd, WINDOWCOMPOSITIONATTRIBDATA*); + static fnSetWindowCompositionAttribute _SetWindowCompositionAttribute = reinterpret_cast(GetProcAddress(GetModuleHandleW(L"user32.dll"), "SetWindowCompositionAttribute")); + if (_SetWindowCompositionAttribute != nullptr) { + BOOL dark = !!bDark; + WINDOWCOMPOSITIONATTRIBDATA data = { WCA_USEDARKMODECOLORS, &dark, sizeof(dark) }; + _SetWindowCompositionAttribute(hWnd, &data); + + // Neither of these fixes stuck titlebar (kept in here for future reference) + // ::RedrawWindow(hWnd, NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_UPDATENOW); + // ::SetWindowPos(hWnd, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_DRAWFRAME); + + // Apparently the least painful way to reliably fix stuck titlebar + // 2x SWP_FRAMECHANGED needed with actual style changes + + if (style & WS_VISIBLE) { // Only do this if visible + wnd.ModifyStyle(WS_BORDER, 0, SWP_FRAMECHANGED); + wnd.ModifyStyle(0, WS_BORDER, SWP_FRAMECHANGED); + } + + } + } + } + + void ApplyDarkThemeCtrl2(HWND ctrl, bool bDark, const wchar_t* ThemeID_light, const wchar_t * ThemeID_dark) { + if (ctrl == NULL) return; + AllowDarkModeForWindow(ctrl, bDark); + if (bDark && IsSupportedSystem()) { + ::SetWindowTheme(ctrl, ThemeID_dark, NULL); + } else { + ::SetWindowTheme(ctrl, ThemeID_light, NULL); + } + } + + void ApplyDarkThemeCtrl(HWND ctrl, bool bDark, const wchar_t* ThemeID) { + if ( ctrl == NULL ) return; + AllowDarkModeForWindow(ctrl, bDark); + if (bDark && IsSupportedSystem()) { + std::wstring temp = L"DarkMode_"; temp += ThemeID; + ::SetWindowTheme(ctrl, temp.c_str(), NULL); + } else { + ::SetWindowTheme(ctrl, ThemeID, NULL); + } + } + + void DarkenEditLite(HWND ctrl) { + if (IsSupportedSystem()) { + ::SetWindowTheme(ctrl, L"DarkMode_Explorer", NULL); + } + } + + void DarkenComboLite(HWND ctrl) { + if (IsSupportedSystem()) { + ::SetWindowTheme(ctrl, L"DarkMode_CFD", NULL); + } + } + + bool IsDCDark(HDC dc_) { + CDCHandle dc(dc_); + return IsThemeDark(dc.GetTextColor(), dc.GetBkColor()); + } + bool IsDialogDark(HWND dlg, UINT msgSend) { + CWindowDC dc(dlg); + dc.SetTextColor(0x000000); + dc.SetBkColor(0xFFFFFF); + ::SendMessage(dlg, msgSend, (WPARAM)dc.m_hDC, (LPARAM)dlg); + return IsDCDark(dc); + } + + COLORREF GetSysColor(int idx, bool bDark) { + if (!bDark) return ::GetSysColor(idx); + switch (idx) { + case COLOR_MENU: + case COLOR_BTNFACE: + case COLOR_WINDOW: + case COLOR_MENUBAR: + // Explorer: + // return 0x383838; + return 0x202020; + case COLOR_BTNSHADOW: + return 0; + case COLOR_WINDOWTEXT: + case COLOR_MENUTEXT: + case COLOR_BTNTEXT: + case COLOR_CAPTIONTEXT: + // Explorer: + // return 0xdedede; + return 0xC0C0C0; + case COLOR_BTNHIGHLIGHT: + case COLOR_MENUHILIGHT: + return 0x383838; + case COLOR_HIGHLIGHT: + return 0x777777; + case COLOR_HIGHLIGHTTEXT: + return 0x101010; + case COLOR_GRAYTEXT: + return 0x777777; + case COLOR_HOTLIGHT: + return 0xd69c56; + default: + return ::GetSysColor(idx); + } + } +#if DARKMODE_ALLOW_HAX + void SetAppDarkMode(bool bDark) { + InitImports(); + + if (_SetPreferredAppMode != nullptr) { + static PreferredAppMode lastMode = PreferredAppMode::Default; + PreferredAppMode wantMode = bDark ? PreferredAppMode::ForceDark : PreferredAppMode::ForceLight; + if (lastMode != wantMode) { + _SetPreferredAppMode(wantMode); + lastMode = wantMode; + if (_FlushMenuThemes) _FlushMenuThemes(); + } + } + } +#else + void SetAppDarkMode(bool) {} +#endif +#if DARKMODE_ALLOW_HAX + void AllowDarkModeForWindow(HWND wnd, bool bDark) { + InitImports(); + + if (_AllowDarkModeForWindow) _AllowDarkModeForWindow(wnd, bDark); + } +#else + void AllowDarkModeForWindow(HWND, bool) {} +#endif + + bool IsThemeDark(COLORREF text, COLORREF background) { + if (!IsSupportedSystem() || IsHighContrast()) return false; + auto l_text = PaintUtils::Luminance(text); + auto l_bk = PaintUtils::Luminance(background); + if (l_text > l_bk) { + if (l_bk <= PaintUtils::Luminance(GetSysColor(COLOR_BTNFACE))) { + return true; + } + } + return false; + } + + bool IsHighContrast() { + HIGHCONTRASTW highContrast = { sizeof(highContrast) }; + if (SystemParametersInfoW(SPI_GETHIGHCONTRAST, sizeof(highContrast), &highContrast, FALSE)) + return (highContrast.dwFlags & HCF_HIGHCONTRASTON) != 0; + return false; + } + + static void DrawTab(CTabCtrl& tabs, CDCHandle dc, int iTab, bool selected, bool focused, const RECT * rcPaint) { + (void)focused; + PFC_ASSERT((tabs.GetStyle() & TCS_VERTICAL) == 0); + + CRect rc; + if (!tabs.GetItemRect(iTab, rc)) return; + + if ( rcPaint != nullptr ) { + CRect foo; + if (!foo.IntersectRect(rc, rcPaint)) return; + } + const int edgeCX = MulDiv(1, QueryScreenDPI_X(tabs), 120); // note: MulDiv() rounds up from +0.5, this will + const auto colorBackground = GetSysColor(selected ? COLOR_HIGHLIGHT : COLOR_BTNFACE); + const auto colorFrame = GetSysColor(COLOR_WINDOWFRAME); + dc.SetDCBrushColor(colorBackground); + dc.FillSolidRect(rc, colorBackground); + + { + CPen pen; + WIN32_OP_D(pen.CreatePen(PS_SOLID, edgeCX, colorFrame)); + SelectObjectScope scope(dc, pen); + dc.MoveTo(rc.left, rc.bottom); + dc.LineTo(rc.left, rc.top); + dc.LineTo(rc.right, rc.top); + dc.LineTo(rc.right, rc.bottom); + } + + wchar_t text[512] = {}; + TCITEM item = {}; + item.mask = TCIF_TEXT; + item.pszText = text; + item.cchTextMax = (int)(std::size(text) - 1); + if (tabs.GetItem(iTab, &item)) { + SelectObjectScope fontScope(dc, tabs.GetFont()); + dc.SetBkMode(TRANSPARENT); + dc.SetTextColor(GetSysColor(selected ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT)); + dc.DrawText(text, (int)wcslen(text), rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER); + } + } + + void PaintTabs(CTabCtrl tabs, CDCHandle dc, const RECT * rcPaint) { + CRect rcClient; tabs.GetClientRect(rcClient); + CRect rcArea = rcClient; tabs.AdjustRect(FALSE, rcArea); + int dx = rcClient.bottom - rcArea.bottom; + int dy = rcClient.right - rcArea.right; + CRect rcFrame = rcArea; rcFrame.InflateRect(dx/2, dy/2); + dc.SetDCBrushColor(GetSysColor(COLOR_WINDOWFRAME)); + dc.FrameRect(rcFrame, (HBRUSH)GetStockObject(DC_BRUSH)); + const int tabCount = tabs.GetItemCount(); + const int tabSelected = tabs.GetCurSel(); + const int tabFocused = tabs.GetCurFocus(); + for (int iTab = 0; iTab < tabCount; ++iTab) { + if (iTab != tabSelected) DrawTab(tabs, dc, iTab, false, iTab == tabFocused, rcPaint); + } + if (tabSelected >= 0) DrawTab(tabs, dc, tabSelected, true, tabSelected == tabFocused, rcPaint); + } + + void PaintTabsErase(CTabCtrl tabs, CDCHandle dc) { + CRect rcClient; WIN32_OP_D(tabs.GetClientRect(rcClient)); + dc.FillSolidRect(&rcClient, GetSysColor(COLOR_BTNFACE)); + } + + + // ================================================= + // NM_CUSTOMDRAW handlers + // ================================================= + + // We keep a global list of HWNDs that require dark rendering, so dialogs can call DarkMode::OnCustomDraw() which deals with this nonsense behind the scenes + // This way there's no need to subclass parent windows at random + + enum class whichDark_t { + none, toolbar + }; + + // readWriteLock used in case someone uses off-main-thread UI, though it should not really happen in real life + static pfc::readWriteLock lstDarkGuard; + static std::map lstDark; + static whichDark_t lstDark_query(HWND w) { + PFC_INSYNC_READ(lstDarkGuard); + auto iter = lstDark.find(w); + if (iter == lstDark.end()) return whichDark_t::none; + return iter->second; + } + static void lstDark_set(HWND w, whichDark_t which) { + PFC_INSYNC_WRITE(lstDarkGuard); + lstDark[w] = which; + } + static void lstDark_clear(HWND w) { + PFC_INSYNC_WRITE(lstDarkGuard); + lstDark.erase(w); + } + + LRESULT CustomDrawToolbar(NMHDR* hdr) { + LPNMTBCUSTOMDRAW cd = reinterpret_cast(hdr); + switch (cd->nmcd.dwDrawStage) { + case CDDS_PREPAINT: return CDRF_NOTIFYITEMDRAW; + case CDDS_ITEMPREPAINT: + cd->clrText = DarkMode::GetSysColor(COLOR_WINDOWTEXT); + cd->clrBtnFace = DarkMode::GetSysColor(COLOR_BTNFACE); + cd->clrBtnHighlight = DarkMode::GetSysColor(COLOR_BTNHIGHLIGHT); + return CDRF_DODEFAULT; + default: + return CDRF_DODEFAULT; + } + } + + LRESULT OnCustomDraw(int,NMHDR* hdr, BOOL& bHandled) { + switch (lstDark_query(hdr->hwndFrom)) { + case whichDark_t::toolbar: + bHandled = TRUE; + return CustomDrawToolbar(hdr); + default: + bHandled = FALSE; return 0; + } + } + + namespace { + + class CToolbarHook { + bool m_dark = false; + const bool m_explorerTheme; + CToolBarCtrl m_wnd; + public: + CToolbarHook(HWND wnd, bool initial, bool bExplorerTheme) : m_wnd(wnd), m_explorerTheme(bExplorerTheme) { + SetDark(initial); + } + + void SetDark(bool v) { + if (m_dark == v) return; + m_dark = v; + if (v) { + lstDark_set(m_wnd, whichDark_t::toolbar); + if (m_explorerTheme) ::SetWindowTheme(m_wnd, L"", L""); // if we don't do this, NM_CUSTOMDRAW color overrides get disregarded + } else { + lstDark_clear(m_wnd); + if (m_explorerTheme) ::SetWindowTheme(m_wnd, L"Explorer", NULL); + } + m_wnd.Invalidate(); + + ApplyDarkThemeCtrl(m_wnd.GetToolTips(), v); + } + ~CToolbarHook() { + if (m_dark) lstDark_clear(m_wnd); + } + + }; + + class CTabsHook : public CWindowImpl { + public: + CTabsHook(bool bDark = false) : m_dark(bDark) {} + BEGIN_MSG_MAP_EX(CTabsHook) + MSG_WM_PAINT(OnPaint) + MSG_WM_ERASEBKGND(OnEraseBkgnd) + MESSAGE_HANDLER_EX(msgSetDarkMode(), OnSetDarkMode) + END_MSG_MAP() + + void SetDark(bool v = false); + private: + void OnPaint(CDCHandle); + BOOL OnEraseBkgnd(CDCHandle); + + LRESULT OnSetDarkMode(UINT, WPARAM wp, LPARAM) { + switch (wp) { + case 0: SetDark(false); break; + case 1: SetDark(true); break; + } + return 1; + } + + bool m_dark = false; + }; + + void CTabsHook::OnPaint(CDCHandle target) { + if (!m_dark) { SetMsgHandled(FALSE); return; } + if (target) { + PaintTabs(m_hWnd, target); + } else { + CPaintDC dc(*this); + PaintTabs(m_hWnd, dc.m_hDC, &dc.m_ps.rcPaint); + } + } + BOOL CTabsHook::OnEraseBkgnd(CDCHandle dc) { + if (m_dark) { + PaintTabsErase(*this, dc); + return TRUE; + } + SetMsgHandled(FALSE); + return FALSE; + } + + void CTabsHook::SetDark(bool v) { + m_dark = v; + if (m_hWnd != NULL) Invalidate(); + + ApplyDarkThemeCtrl(GetToolTips(), v); + } + + class CTreeViewHook : public CWindowImpl { + bool m_dark; + public: + CTreeViewHook(bool v) : m_dark(v) {} + + BEGIN_MSG_MAP_EX(CTreeViewHook) + MESSAGE_RANGE_HANDLER_EX(WM_CTLCOLORMSGBOX, WM_CTLCOLORSTATIC, OnCtlColor) + MESSAGE_HANDLER_EX(msgSetDarkMode(), OnSetDarkMode) + MESSAGE_HANDLER_EX(TVM_EDITLABEL, OnEditLabel) + END_MSG_MAP() + + LRESULT OnCtlColor(UINT uMsg, WPARAM wParam, LPARAM lParam) { + return GetParent().SendMessage(uMsg, wParam, lParam); + } + LRESULT OnEditLabel(UINT, WPARAM, LPARAM) { + LRESULT ret = DefWindowProc(); + if (ret != 0) { + HWND edit = (HWND) ret; + PFC_ASSERT( ::IsWindow(edit) ); + ApplyDarkThemeCtrl( edit, m_dark ); + } + return ret; + } + void SetDark(bool v) { + if (m_dark == v) return; + m_dark = v; + ApplyDark(); + } + void ApplyDark() { + ApplyDarkThemeCtrl(m_hWnd, m_dark); + COLORREF bk = m_dark ? GetSysColor(COLOR_WINDOW) : (COLORREF)(-1); + COLORREF tx = m_dark ? GetSysColor(COLOR_WINDOWTEXT) : (COLORREF)(-1); + this->SetTextColor(tx); this->SetLineColor(tx); + this->SetBkColor(bk); + + ApplyDarkThemeCtrl(GetToolTips(), m_dark); + } + + void SubclassWindow(HWND wnd) { + WIN32_OP_D( __super::SubclassWindow(wnd) ); + this->ApplyDark(); + } + + LRESULT OnSetDarkMode(UINT, WPARAM wp, LPARAM) { + switch (wp) { + case 0: SetDark(false); break; + case 1: SetDark(true); break; + } + return 1; + } + }; + + class CDialogHook : public CWindowImpl { + bool m_enabled; + public: + CDialogHook(bool v) : m_enabled(v) {} + + void SetDark(bool v) { + if (m_enabled == v) return; + + // Important: PostMessage()'ing this caused bugs + SendMessage(WM_THEMECHANGED); + + m_enabled = v; + + // Ensure menu bar redraw with RDW_FRAME + RedrawWindow(NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME); + } + + // Undocumented Windows menu drawing API + // Source: https://github.com/adzm/win32-custom-menubar-aero-theme + + static constexpr unsigned WM_UAHDRAWMENU = 0x0091; + static constexpr unsigned WM_UAHDRAWMENUITEM = 0x0092; + + typedef union tagUAHMENUITEMMETRICS + { + struct { + DWORD cx; + DWORD cy; + } rgsizeBar[2]; + struct { + DWORD cx; + DWORD cy; + } rgsizePopup[4]; + } UAHMENUITEMMETRICS; + + typedef struct tagUAHMENUPOPUPMETRICS + { + DWORD rgcx[4]; + DWORD fUpdateMaxWidths : 2; + } UAHMENUPOPUPMETRICS; + + typedef struct tagUAHMENU + { + HMENU hmenu; + HDC hdc; + DWORD dwFlags; + } UAHMENU; + + typedef struct tagUAHMENUITEM + { + int iPosition; + UAHMENUITEMMETRICS umim; + UAHMENUPOPUPMETRICS umpm; + } UAHMENUITEM; + + typedef struct UAHDRAWMENUITEM + { + DRAWITEMSTRUCT dis; + UAHMENU um; + UAHMENUITEM umi; + } UAHDRAWMENUITEM; + + + BEGIN_MSG_MAP_EX(CDialogHook) + MSG_WM_CTLCOLORDLG(ctlColorCommon) + MSG_WM_CTLCOLORSTATIC(ctlColorCommon) + MSG_WM_CTLCOLOREDIT(ctlColorCommon) + MSG_WM_CTLCOLORBTN(ctlColorCommon) + MSG_WM_CTLCOLORLISTBOX(ctlColorCommon) + MSG_WM_CTLCOLORSCROLLBAR(ctlColorCommon) + NOTIFY_CODE_HANDLER(NM_CUSTOMDRAW, DarkMode::OnCustomDraw) + MESSAGE_HANDLER_EX(WM_UAHDRAWMENU, Handle_WM_UAHDRAWMENU) + MESSAGE_HANDLER_EX(WM_UAHDRAWMENUITEM, Handle_WM_UAHDRAWMENUITEM) + MESSAGE_HANDLER_EX(msgSetDarkMode(), OnSetDarkMode) + END_MSG_MAP() + + LRESULT OnSetDarkMode(UINT, WPARAM wp, LPARAM) { + switch (wp) { + case 0: SetDark(false); break; + case 1: SetDark(true); break; + } + return 1; + } + + static COLORREF GetBkColor() { return DarkMode::GetSysColor(COLOR_WINDOW); } + static COLORREF GetTextColor() { return DarkMode::GetSysColor(COLOR_WINDOWTEXT); } + + HBRUSH ctlColorDlg(CDCHandle dc, CWindow wnd) { + if (m_enabled && ::IsThemeDialogTextureEnabled(*this)) { + auto bkColor = DarkMode::GetSysColor(COLOR_HIGHLIGHT); + auto txColor = GetTextColor(); + + dc.SetTextColor(txColor); + dc.SetBkColor(bkColor); + dc.SetDCBrushColor(bkColor); + return (HBRUSH)GetStockObject(DC_BRUSH); + } + return ctlColorCommon(dc, wnd); + } + + HBRUSH ctlColorCommon(CDCHandle dc, CWindow wnd) { + (void)wnd; + if (m_enabled) { + auto bkColor = GetBkColor(); + auto txColor = GetTextColor(); + + dc.SetTextColor(txColor); + dc.SetBkColor(bkColor); + dc.SetDCBrushColor(bkColor); + return (HBRUSH)GetStockObject(DC_BRUSH); + } + SetMsgHandled(FALSE); + return NULL; + } + LRESULT Handle_WM_UAHDRAWMENU(UINT, WPARAM wParam, LPARAM lParam) { + if (!m_enabled) { + SetMsgHandled(FALSE); + return 0; + } + UAHMENU* pUDM = (UAHMENU*)lParam; + CRect rc; + + MENUBARINFO mbi = { sizeof(mbi) }; + WIN32_OP_D(GetMenuBarInfo(m_hWnd, OBJID_MENU, 0, &mbi)); + + CRect rcWindow; + WIN32_OP_D(GetWindowRect(rcWindow)); + + rc = mbi.rcBar; + OffsetRect(&rc, -rcWindow.left, -rcWindow.top); + + rc.top -= 1; + + CDCHandle dc(pUDM->hdc); + dc.FillSolidRect(rc, DarkMode::GetSysColor(COLOR_MENUBAR)); + return 0; + } + LRESULT Handle_WM_UAHDRAWMENUITEM(UINT, WPARAM wParam, LPARAM lParam) { + if (!m_enabled) { + SetMsgHandled(FALSE); + return 0; + } + + UAHDRAWMENUITEM* pUDMI = (UAHDRAWMENUITEM*)lParam; + CMenuHandle hMenu = pUDMI->um.hmenu; + + CString menuString; + WIN32_OP_D(hMenu.GetMenuString(pUDMI->umi.iPosition, menuString, MF_BYPOSITION) > 0); + + DWORD drawTextFlags = DT_CENTER | DT_SINGLELINE | DT_VCENTER; + + int iTextStateID = MPI_NORMAL; + int iBackgroundStateID = MPI_NORMAL; + if ((pUDMI->dis.itemState & ODS_INACTIVE) | (pUDMI->dis.itemState & ODS_DEFAULT)) { + iTextStateID = MPI_NORMAL; + iBackgroundStateID = MPI_NORMAL; + } + if (pUDMI->dis.itemState & (ODS_HOTLIGHT|ODS_SELECTED)) { + iTextStateID = MPI_HOT; + iBackgroundStateID = MPI_HOT; + } + if (pUDMI->dis.itemState & (ODS_GRAYED|ODS_DISABLED)) { + iTextStateID = MPI_DISABLED; + iBackgroundStateID = MPI_DISABLED; + } + if (pUDMI->dis.itemState & ODS_NOACCEL) { + drawTextFlags |= DT_HIDEPREFIX; + } + + if (m_menuTheme == NULL) { + m_menuTheme.OpenThemeData(m_hWnd, L"Menu"); + } + + CDCHandle dc(pUDMI->um.hdc); + switch (iBackgroundStateID) { + case MPI_NORMAL: + case MPI_DISABLED: + dc.FillSolidRect(&pUDMI->dis.rcItem, DarkMode::GetSysColor(COLOR_MENUBAR)); + break; + case MPI_HOT: + case MPI_DISABLEDHOT: + dc.FillSolidRect(&pUDMI->dis.rcItem, DarkMode::GetSysColor(COLOR_MENUHILIGHT)); + break; + default: + DrawThemeBackground(m_menuTheme, pUDMI->um.hdc, MENU_POPUPITEM, iBackgroundStateID, &pUDMI->dis.rcItem, nullptr); + break; + } + DTTOPTS dttopts = { sizeof(dttopts) }; + if (iTextStateID == MPI_NORMAL || iTextStateID == MPI_HOT) + { + dttopts.dwFlags |= DTT_TEXTCOLOR; + dttopts.crText = DarkMode::GetSysColor(COLOR_WINDOWTEXT); + } + DrawThemeTextEx(m_menuTheme, dc, MENU_POPUPITEM, iTextStateID, menuString, menuString.GetLength(), drawTextFlags, &pUDMI->dis.rcItem, &dttopts); + + return 0; + } + CTheme m_menuTheme; + }; + + + class CStatusBarHook : public CWindowImpl { + public: + CStatusBarHook(bool v = false) : m_dark(v) {} + + BEGIN_MSG_MAP_EX(CStatusBarHook) + MSG_WM_ERASEBKGND(OnEraseBkgnd) + MSG_WM_PAINT(OnPaint) + MESSAGE_HANDLER_EX(SB_SETTEXT, OnSetText) + MESSAGE_HANDLER_EX(SB_SETICON, OnSetIcon) + MESSAGE_HANDLER_EX(msgSetDarkMode(), OnSetDarkMode) + END_MSG_MAP() + + LRESULT OnSetDarkMode(UINT, WPARAM wp, LPARAM) { + switch (wp) { + case 0: SetDark(false); break; + case 1: SetDark(true); break; + } + return 1; + } + + void SetDark(bool v = true) { + if (m_dark != v) { + m_dark = v; + Invalidate(); + ApplyDarkThemeCtrl(m_hWnd, v); + } + } + + void SubclassWindow(HWND wnd) { + WIN32_OP_D(__super::SubclassWindow(wnd)); + Invalidate(); + ApplyDarkThemeCtrl(m_hWnd, m_dark); + } + LRESULT OnSetIcon(UINT, WPARAM wp, LPARAM lp) { + unsigned idx = (unsigned)wp; + if (idx < 32) { + CSize sz; + if (lp != 0) sz = GetIconSize((HICON)lp); + m_iconSizeCache[idx] = sz; + } + SetMsgHandled(FALSE); + return 0; + } + LRESULT OnSetText(UINT, WPARAM wp, LPARAM) { + // Status bar won't tell us about ownerdraw from GetText() + // Have to listen to relevant messages to know + unsigned idx = (unsigned)(wp & 0xFF); + if (idx < 32) { + uint32_t flag = 1 << idx; + if (wp & SBT_OWNERDRAW) { + m_ownerDrawMask |= flag; + } else { + m_ownerDrawMask &= ~flag; + } + } + + SetMsgHandled(FALSE); + return 0; + } + + void Paint(CDCHandle dc) { + CRect rcClient; WIN32_OP_D(GetClientRect(rcClient)); + dc.FillSolidRect(rcClient, GetSysColor(COLOR_BTNFACE)); // Wine seems to not call our WM_ERASEBKGND handler, fill the background here too + + dc.SelectFont(GetFont()); + dc.SetBkMode(TRANSPARENT); + dc.SetTextColor(GetSysColor(COLOR_WINDOWTEXT)); + CPen pen; pen.CreatePen(PS_SOLID, 1, GetSysColor(COLOR_BTNHIGHLIGHT)); + dc.SelectPen(pen); + int count = this->GetParts(0, nullptr); + for (int iPart = 0; iPart < count; ++iPart) { + CRect rcPart; + this->GetRect(iPart, rcPart); + if (rcPart.left > 0) { + dc.MoveTo(rcPart.left, rcPart.top); + dc.LineTo(rcPart.left, rcPart.bottom); + } + int type = 0; + CString text; + this->GetText(iPart, text, &type); + + HICON icon = this->GetIcon(iPart); + int iconMargin = 0; + if (icon != NULL && (unsigned)iPart < std::size(m_iconSizeCache)) { + + auto size = m_iconSizeCache[iPart]; + + dc.DrawIconEx(rcPart.left + size.cx / 4, (rcPart.top + rcPart.bottom) / 2 - size.cy / 2, icon, size.cx, size.cy); + iconMargin = MulDiv(size.cx, 3, 2); + } + + if (m_ownerDrawMask & (1 << iPart)) { // statusbar won't tell us about ownerdraw from GetText() + DRAWITEMSTRUCT ds = {}; + ds.CtlType = ODT_STATIC; + ds.CtlID = this->GetDlgCtrlID(); + ds.itemID = iPart; + ds.hwndItem = m_hWnd; + ds.hDC = dc; + ds.rcItem = rcPart; + + DCStateScope scope(dc); + GetParent().SendMessage(WM_DRAWITEM, GetDlgCtrlID(), (LPARAM)&ds); + } else { + CRect rcText = rcPart; + int defMargin = rcText.Height() / 4; + int l = iconMargin > 0 ? iconMargin : defMargin; + int r = defMargin; + rcText.DeflateRect(l, 0, r, 0); + dc.DrawText(text, text.GetLength(), rcText, DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS | DT_NOPREFIX); + } + + if (GetStyle() & SBARS_SIZEGRIP) { + CSize size; + auto theme = OpenThemeData(*this, L"status"); + PFC_ASSERT(theme != NULL); + GetThemePartSize(theme, dc, SP_GRIPPER, 0, &rcClient, TS_DRAW, &size); + auto rc = rcClient; + rc.left = rc.right - size.cx; + rc.top = rc.bottom - size.cy; + DrawThemeBackground(theme, dc, SP_GRIPPER, 0, &rc, nullptr); + CloseThemeData(theme); + } + } + } + + void OnPaint(CDCHandle target) { + if (!m_dark) { SetMsgHandled(FALSE); return; } + if (target) { + Paint(target); + } else { + CPaintDC dc(*this); + Paint(dc.m_hDC); + } + } + + BOOL OnEraseBkgnd(CDCHandle dc) { + if (m_dark) { + CRect rc; WIN32_OP_D(GetClientRect(rc)); dc.FillSolidRect(rc, DarkMode::GetSysColor(COLOR_BTNFACE)); return TRUE; + } + SetMsgHandled(FALSE); return FALSE; + } + + bool m_dark = false; + + uint32_t m_ownerDrawMask = 0; + CSize m_iconSizeCache[32]; + }; + + class CCheckBoxHook : public CWindowImpl { + public: + CCheckBoxHook(bool v = false) : m_dark(v) {} + + BEGIN_MSG_MAP_EX(CCheckBoxHook) + MSG_WM_PAINT(OnPaint) + MSG_WM_PRINTCLIENT(OnPaint) + MSG_WM_ERASEBKGND(OnEraseBkgnd) + MSG_WM_UPDATEUISTATE(OnUpdateUIState) + + // Note that checkbox implementation likes to paint on its own in response to events + // instead of invalidating and handling WM_PAINT + // We have to specifically trigger WM_PAINT to override their rendering with ours + MESSAGE_HANDLER_EX(WM_SETFOCUS, OnMsgRedraw) + MESSAGE_HANDLER_EX(WM_KILLFOCUS, OnMsgRedraw) + MESSAGE_HANDLER_EX(WM_ENABLE, OnMsgRedraw) + MESSAGE_HANDLER_EX(WM_SETTEXT, OnMsgRedraw) + + MESSAGE_HANDLER_EX(msgSetDarkMode(), OnSetDarkMode) + END_MSG_MAP() + + LRESULT OnSetDarkMode(UINT, WPARAM wp, LPARAM) { + switch (wp) { + case 0: SetDark(false); break; + case 1: SetDark(true); break; + } + return 1; + } + + LRESULT OnMsgRedraw(UINT, WPARAM, LPARAM) { + if ( m_dark ) { + // PROBLEM: + // Can't invalidate prior to their handling of the message + // Causes bugs with specific chains of events - EnableWindow() followed immediately SetWindowText() + LRESULT ret = DefWindowProc(); + Invalidate(); + return ret; + } + SetMsgHandled(FALSE); return 0; + } + + void OnUpdateUIState(WORD nAction, WORD nState) { + (void)nAction; + if ( m_dark && (nState & (UISF_HIDEACCEL | UISF_HIDEFOCUS)) != 0) { + // PROBLEM: + // Can't invalidate prior to their handling of the message + // Causes bugs with specific chains of events - EnableWindow() followed immediately SetWindowText() + DefWindowProc(); + Invalidate(); + return; + } + SetMsgHandled(FALSE); + } + void PaintHandler(CDCHandle dc) { + CRect rcClient; WIN32_OP_D(GetClientRect(rcClient)); + + const bool bDisabled = !this->IsWindowEnabled(); + + dc.SetTextColor(DarkMode::GetSysColor(COLOR_BTNTEXT)); + dc.SetBkColor(DarkMode::GetSysColor(COLOR_BTNFACE)); + dc.SetBkMode(OPAQUE); + dc.SelectFont(GetFont()); + GetParent().SendMessage(WM_CTLCOLORBTN, (WPARAM)dc.m_hDC, (LPARAM)m_hWnd); + if (bDisabled) dc.SetTextColor(DarkMode::GetSysColor(COLOR_GRAYTEXT)); // override WM_CTLCOLORBTN + + const DWORD btnStyle = GetStyle(); + const DWORD btnType = btnStyle & BS_TYPEMASK; + const bool bRadio = (btnType == BS_RADIOBUTTON || btnType == BS_AUTORADIOBUTTON); + const int part = bRadio ? BP_RADIOBUTTON : BP_CHECKBOX; + + const auto ctrlState = GetState(); + const DWORD uiState = (DWORD)SendMessage(WM_QUERYUISTATE); + + + const bool bChecked = (ctrlState & BST_CHECKED) != 0; + const bool bMixed = (ctrlState & BST_INDETERMINATE) != 0; + const bool bHot = (ctrlState & BST_HOT) != 0; + const bool bFocus = (ctrlState & BST_FOCUS) != 0 && (uiState & UISF_HIDEFOCUS) == 0; + + HTHEME theme = OpenThemeData(m_hWnd, L"button"); + + CRect rcCheckBox = rcClient; + bool bDrawn = false; + int margin = 0; + if (theme != NULL && IsThemePartDefined(theme, part, 0)) { + int state = 0; + if (bDisabled) { + if ( bChecked ) state = CBS_CHECKEDDISABLED; + else if ( bMixed ) state = CBS_MIXEDDISABLED; + else state = CBS_UNCHECKEDDISABLED; + } else if (bHot) { + if ( bChecked ) state = CBS_CHECKEDHOT; + else if ( bMixed ) state = CBS_MIXEDHOT; + else state = CBS_UNCHECKEDNORMAL; + } else { + if ( bChecked ) state = CBS_CHECKEDNORMAL; + else if ( bMixed ) state = CBS_MIXEDNORMAL; + else state = CBS_UNCHECKEDNORMAL; + } + + CSize size; + if (SUCCEEDED(GetThemePartSize(theme, dc, part, state, rcCheckBox, TS_TRUE, &size))) { + if (size.cx <= rcCheckBox.Width() && size.cy <= rcCheckBox.Height()) { + CRect rc = rcCheckBox; + margin = MulDiv(size.cx, 5, 4); + // rc.left += (rc.Width() - size.cx) / 2; + rc.top += (rc.Height() - size.cy) / 2; + rc.right = rc.left + size.cx; + rc.bottom = rc.top + size.cy; + DrawThemeBackground(theme, dc, part, state, rc, &rc); + bDrawn = true; + } + } + } + if (theme != NULL) CloseThemeData(theme); + if (!bDrawn) { + int stateEx = bRadio ? DFCS_BUTTONRADIO : DFCS_BUTTONCHECK; + if (bChecked) stateEx |= DFCS_CHECKED; + // FIX ME bMixed ? + if (bDisabled) stateEx |= DFCS_INACTIVE; + else if (bHot) stateEx |= DFCS_HOT; + + const int dpi = GetDeviceCaps(dc, LOGPIXELSX); + int w = MulDiv(16, dpi, 96); + + CRect rc = rcCheckBox; + if (rc.Width() > w) rc.right = rc.left + w;; + + DrawFrameControl(dc, rc, DFC_BUTTON, stateEx); + margin = MulDiv(20, dpi, 96); + } + + CString text; + if (margin < rcClient.Width()) GetWindowText(text); + if (!text.IsEmpty()) { + CRect rcText = rcClient; + rcText.left += margin; + UINT dtFlags = DT_VCENTER; + if (btnStyle & BS_MULTILINE) { + dtFlags |= DT_WORDBREAK; + } else { + dtFlags |= DT_END_ELLIPSIS | DT_SINGLELINE; + } + dc.DrawText(text, text.GetLength(), rcText, dtFlags); + if (bFocus) { + dc.DrawText(text, text.GetLength(), rcText, DT_CALCRECT | dtFlags); + dc.DrawFocusRect(rcText); + } + } else if (bFocus) { + dc.DrawFocusRect(rcClient); + } + } + void OnPaint(CDCHandle userDC, UINT flags = 0) { + (void)flags; + if (!m_dark) { SetMsgHandled(FALSE); return; } + if (userDC) { + PaintHandler(userDC); + } else { + CPaintDC dc(*this); + PaintHandler(dc.m_hDC); + } + } + BOOL OnEraseBkgnd(CDCHandle dc) { + if (m_dark) { + CRect rc; WIN32_OP_D(GetClientRect(rc)); + + dc.SetTextColor(DarkMode::GetSysColor(COLOR_BTNTEXT)); + dc.SetBkColor(DarkMode::GetSysColor(COLOR_BTNFACE)); + auto br = (HBRUSH)GetParent().SendMessage(WM_CTLCOLORSTATIC, (WPARAM)dc.m_hDC, (LPARAM)m_hWnd); + if (br != NULL) { + dc.FillRect(rc, br); + } else { + dc.FillSolidRect(rc, DarkMode::GetSysColor(COLOR_BTNFACE)); + } + return TRUE; + } + SetMsgHandled(FALSE); return FALSE; + } + + void SetDark(bool v = true) { + if (v != m_dark) { + m_dark = v; + Invalidate(); + ApplyDarkThemeCtrl(m_hWnd, m_dark); + } + } + + void SubclassWindow(HWND wnd) { + WIN32_OP_D(__super::SubclassWindow(wnd)); + ApplyDarkThemeCtrl(m_hWnd, m_dark); + } + + bool m_dark = false; + }; + + class CGripperHook : public CWindowImpl { + public: + CGripperHook(bool v) : m_dark(v) {} + + BEGIN_MSG_MAP_EX(CGRipperHook) + MSG_WM_ERASEBKGND(OnEraseBkgnd) + MSG_WM_PAINT(OnPaint) + MESSAGE_HANDLER_EX(msgSetDarkMode(), OnSetDarkMode) + END_MSG_MAP() + + LRESULT OnSetDarkMode(UINT, WPARAM wp, LPARAM) { + switch (wp) { + case 0: SetDark(false); break; + case 1: SetDark(true); break; + } + return 1; + } + + void SetDark(bool v) { + if (v != m_dark) { + m_dark = v; + ApplyDarkThemeCtrl(*this, m_dark); + } + } + + void SubclassWindow(HWND wnd) { + WIN32_OP_D(__super::SubclassWindow(wnd)); + ApplyDarkThemeCtrl(m_hWnd, m_dark); + } + + void PaintGripper(CDCHandle dc) { + CRect rcClient; WIN32_OP_D(GetClientRect(rcClient)); + CSize size; + auto theme = OpenThemeData(*this, L"status"); + PFC_ASSERT(theme != NULL); + GetThemePartSize(theme, dc, SP_GRIPPER, 0, &rcClient, TS_DRAW, &size); + auto rc = rcClient; + rc.left = rc.right - size.cx; + rc.top = rc.bottom - size.cy; + DrawThemeBackground(theme, dc, SP_GRIPPER, 0, &rc, nullptr); + CloseThemeData(theme); + } + + void OnPaint(CDCHandle dc) { + if (!m_dark) { SetMsgHandled(FALSE); return; } + if (dc) PaintGripper(dc); + else {CPaintDC pdc(*this); PaintGripper(pdc.m_hDC);} + } + + BOOL OnEraseBkgnd(CDCHandle dc) { + if (m_dark) { + CRect rc; GetClientRect(rc); + dc.FillSolidRect(rc, GetSysColor(COLOR_WINDOW)); + return TRUE; + } + SetMsgHandled(FALSE); return FALSE; + } + bool m_dark = false; + }; + + class CReBarHook : public CWindowImpl { + bool m_dark; + public: + CReBarHook(bool v) : m_dark(v) {} + BEGIN_MSG_MAP_EX(CReBarHook) + MSG_WM_ERASEBKGND(OnEraseBkgnd) + MSG_WM_DESTROY(OnDestroy) + MSG_WM_PAINT(OnPaint) + MSG_WM_PRINTCLIENT(OnPaint) + NOTIFY_CODE_HANDLER(NM_CUSTOMDRAW, DarkMode::OnCustomDraw) + MESSAGE_HANDLER_EX(msgSetDarkMode(), OnSetDarkMode) + END_MSG_MAP() + + LRESULT OnSetDarkMode(UINT, WPARAM wp, LPARAM) { + switch (wp) { + case 0: SetDark(false); break; + case 1: SetDark(true); break; + } + return 1; + } + + void OnPaint(CDCHandle target, unsigned flags = 0) { + if (!m_dark) { SetMsgHandled(FALSE); return; } + (void)flags; + if (target) { + HandlePaint(target); + } else { + CPaintDC pdc(*this); + HandlePaint(pdc.m_hDC); + } + } + + void HandlePaint(CDCHandle dc) { + const int total = this->GetBandCount(); + for (int iBand = 0; iBand < total; ++iBand) { + CRect rc; + WIN32_OP_D(this->GetRect(iBand, rc)); + + wchar_t buffer[256] = {}; + REBARBANDINFO info = { sizeof(info) }; + info.fMask = RBBIM_TEXT | RBBIM_CHILD | RBBIM_STYLE; + info.lpText = buffer; info.cch = (UINT)std::size(buffer); + WIN32_OP_D(this->GetBandInfo(iBand, &info)); + + HFONT useFont; + // Sadly overriding the font breaks the layout + // MS implementation disregards fonts too + // useFont = this->GetFont(); + useFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT); + SelectObjectScope fontScope(dc, useFont); + dc.SetTextColor(DarkMode::GetSysColor(COLOR_BTNTEXT)); + dc.SetBkMode(TRANSPARENT); + + CRect rcText = rc; + if ((info.fStyle & RBBS_NOGRIPPER) == 0) { + auto color = PaintUtils::BlendColor(DarkMode::GetSysColor(COLOR_WINDOWFRAME), DarkMode::GetSysColor(COLOR_BTNFACE)); + dc.SetDCPenColor(color); + SelectObjectScope penScope(dc, GetStockObject(DC_PEN)); + dc.MoveTo(rcText.TopLeft()); + dc.LineTo(CPoint(rcText.left, rcText.bottom)); + rcText.left += 6; // this should be DPI-scaled, only it's not because rebar layout isn't either + } else { + rcText.left += 2; + } + dc.DrawText(buffer, (int)wcslen(buffer), &rcText, DT_VCENTER | DT_LEFT | DT_SINGLELINE | DT_NOPREFIX); + } + } + + + void OnDestroy() { + SetMsgHandled(FALSE); + } + BOOL OnEraseBkgnd(CDCHandle dc) { + if (m_dark) { + CRect rc; + WIN32_OP_D(GetClientRect(rc)); + dc.FillSolidRect(rc, DarkMode::GetSysColor(COLOR_BTNFACE)); + return TRUE; + } + SetMsgHandled(FALSE); return FALSE; + } + void SetDark(bool v) { + if (v != m_dark) { + m_dark = v; Apply(); + } + } + void Apply() { + if (m_dark) { + this->SetTextColor(DarkMode::GetSysColor(COLOR_WINDOWTEXT)); + this->SetBkColor(DarkMode::GetSysColor(COLOR_BTNFACE)); + } else { + this->SetTextColor((COLORREF)-1); + this->SetBkColor((COLORREF)-1); + } + Invalidate(); + } + void SubclassWindow(HWND wnd) { + WIN32_OP_D(__super::SubclassWindow(wnd)); + Apply(); + } + }; + + class CStaticHook : public CWindowImpl { + bool m_dark; + public: + CStaticHook(bool v) : m_dark(v) {} + + BEGIN_MSG_MAP_EX(CStaticHook) + MSG_WM_PAINT(OnPaint) + MESSAGE_HANDLER_EX(WM_ENABLE, OnMsgRedraw) + MESSAGE_HANDLER_EX(msgSetDarkMode(), OnSetDarkMode) + END_MSG_MAP() + + LRESULT OnSetDarkMode(UINT, WPARAM wp, LPARAM) { + switch (wp) { + case 0: SetDark(false); break; + case 1: SetDark(true); break; + } + return 1; + } + + LRESULT OnMsgRedraw(UINT, WPARAM, LPARAM) { + Invalidate(); + SetMsgHandled(FALSE); + return 0; + } + + void SetDark(bool v) { + if (m_dark != v) { + m_dark = v; + Invalidate(); + } + } + + void OnPaint(CDCHandle dc) { + // ONLY override the dark+disabled or dark+icon behavior + if (!m_dark || (this->IsWindowEnabled() && this->GetIcon() == NULL) ) { + SetMsgHandled(FALSE); return; + } + + if (dc) HandlePaint(dc); + else { + CPaintDC pdc(*this); HandlePaint(pdc.m_hDC); + } + } + void HandlePaint(CDCHandle dc) { + CString str; + CIconHandle icon = this->GetIcon(); + this->GetWindowTextW(str); + + CRect rcClient; + WIN32_OP_D(GetClientRect(rcClient)); + + const DWORD style = this->GetStyle(); + + dc.SelectFont(GetFont()); + + HBRUSH br = (HBRUSH) GetParent().SendMessage(WM_CTLCOLORSTATIC, (WPARAM)dc.m_hDC, (LPARAM)m_hWnd);; + if (br == NULL) { + dc.FillSolidRect(rcClient, DarkMode::GetSysColor(COLOR_WINDOW)); + } else { + WIN32_OP_D(dc.FillRect(rcClient, br)); + } + + if (icon != NULL) { + dc.DrawIcon(0, 0, icon); + } else { + DWORD flags = 0; + if (style & SS_SIMPLE) flags |= DT_SINGLELINE | DT_WORD_ELLIPSIS; + else flags |= DT_WORDBREAK; + if (style & SS_RIGHT) flags |= DT_RIGHT; + else if (style & SS_CENTER) flags |= DT_CENTER; + + dc.SetTextColor(DarkMode::GetSysColor(COLOR_GRAYTEXT)); + dc.SetBkMode(TRANSPARENT); + dc.DrawText(str, str.GetLength(), rcClient, flags); + } + } + }; + + class CUpDownHook : public CWindowImpl { + bool m_dark; + public: + CUpDownHook(bool v) : m_dark(v) {} + + void SetDark(bool v) { + if (v != m_dark) { + m_dark = v; Invalidate(); + } + } + + BEGIN_MSG_MAP_EX(CUpDownHook) + MSG_WM_PAINT(OnPaint) + MSG_WM_PRINTCLIENT(OnPaint) + MSG_WM_MOUSEMOVE(OnMouseMove) + MSG_WM_LBUTTONDOWN(OnMouseBtn) + MSG_WM_LBUTTONUP(OnMouseBtn) + MSG_WM_MOUSELEAVE(OnMouseLeave) + MESSAGE_HANDLER_EX(msgSetDarkMode(), OnSetDarkMode) + END_MSG_MAP() + + private: + LRESULT OnSetDarkMode(UINT, WPARAM wp, LPARAM) { + switch (wp) { + case 0: SetDark(false); break; + case 1: SetDark(true); break; + } + return 1; + } + + struct layout_t { + CRect whole, upper, lower; + int yCenter; + }; + layout_t Layout(CRect const & rcClient) { + CRect rc = rcClient; + rc.DeflateRect(1, 1); + int yCenter = (rc.top + rc.bottom) / 2; + layout_t ret; + ret.yCenter = yCenter; + ret.whole = rc; + ret.upper = rc; + ret.upper.bottom = yCenter; + ret.lower = rc; + ret.lower.top = yCenter; + return ret; + } + layout_t Layout() { + CRect rcClient; WIN32_OP_D(GetClientRect(rcClient)); return Layout(rcClient); + } + int m_hot = 0; + bool m_btnDown = false; + void SetHot(int iHot) { + if (iHot != m_hot) { + m_hot = iHot; Invalidate(); + } + } + void OnMouseLeave() { + SetHot(0); + SetMsgHandled(FALSE); + } + int HitTest(CPoint pt) { + auto layout = Layout(); + if (layout.upper.PtInRect(pt)) return 1; + else if (layout.lower.PtInRect(pt)) return 2; + else return 0; + } + void OnMouseBtn(UINT flags, CPoint) { + bool bDown = (flags & MK_LBUTTON) != 0; + if (bDown != m_btnDown) { + m_btnDown = bDown; + Invalidate(); + } + SetMsgHandled(FALSE); + } + void OnMouseMove(UINT, CPoint pt) { + SetHot(HitTest(pt)); + SetMsgHandled(FALSE); + } + void OnPaint(CDCHandle target, unsigned flags = 0) { + if (!m_dark) { SetMsgHandled(FALSE); return; } + (void)flags; + if (target) { + HandlePaint(target); + } else { + CPaintDC pdc(*this); + HandlePaint(pdc.m_hDC); + } + } + void HandlePaint(CDCHandle dc) { + // no corresponding getsyscolor values for this, hardcoded values taken from actual button control + // + frame trying to fit edit control frame + const COLORREF colorText = 0xFFFFFF; + const COLORREF colorFrame = 0xFFFFFF; + const COLORREF colorBk = 0x333333; + const COLORREF colorHot = 0x454545; + const COLORREF colorPressed = 0x666666; + + CRect rcClient; WIN32_OP_D(GetClientRect(rcClient)); + auto layout = Layout(rcClient); + dc.FillRect(rcClient, MakeTempBrush(dc, colorBk)); + + if (m_hot != 0) { + auto color = m_btnDown ? colorPressed : colorHot; + switch (m_hot) { + case 1: + dc.FillSolidRect(layout.upper, color); + break; + case 2: + dc.FillSolidRect(layout.lower, color); + break; + } + } + + dc.FrameRect(layout.whole, MakeTempBrush(dc, colorFrame)); + dc.SetDCPenColor(colorFrame); + dc.SelectPen((HPEN)GetStockObject(DC_PEN)); + dc.MoveTo(layout.whole.left, layout.yCenter); + dc.LineTo(layout.whole.right, layout.yCenter); + + CFontHandle f = GetFont(); + if (f == NULL) { + auto buddy = this->GetBuddy(); + if ( buddy ) f = buddy.GetFont(); + } + if (f == NULL) f = (HFONT) GetStockObject(DEFAULT_GUI_FONT); + PFC_ASSERT(f != NULL); + CFont font2; + CreateScaledFont(font2, f, 0.5); + SelectObjectScope selectFont(dc, font2); + dc.SetBkMode(TRANSPARENT); + dc.SetTextColor(colorText); + dc.DrawText(L"˄", 1, layout.upper, DT_SINGLELINE | DT_VCENTER | DT_CENTER | DT_NOPREFIX); + dc.DrawText(L"˅", 1, layout.lower, DT_SINGLELINE | DT_VCENTER | DT_CENTER | DT_NOPREFIX); + } + }; + + class CNCFrameHook : public CWindowImpl { + public: + CNCFrameHook(bool dark) : m_dark(dark) {} + + BEGIN_MSG_MAP_EX(CNCFrameHook) + MESSAGE_HANDLER_EX(msgSetDarkMode(), OnSetDarkMode) + MSG_WM_NCPAINT(OnNCPaint) + END_MSG_MAP() + + void SetDark(bool v) { + if (v != m_dark) { + m_dark = v; ApplyDark(); + } + } + BOOL SubclassWindow(HWND wnd) { + auto rv = __super::SubclassWindow(wnd); + if (rv) { + ApplyDark(); + } + return rv; + } + private: + void OnNCPaint(HRGN rgn) { + if (m_dark) { + NCPaintDarkFrame(m_hWnd, rgn); + return; + } + SetMsgHandled(FALSE); + } + void ApplyDark() { + ApplyDarkThemeCtrl(m_hWnd, m_dark); + Invalidate(); + } + LRESULT OnSetDarkMode(UINT, WPARAM wp, LPARAM) { + switch (wp) { + case 0: SetDark(false); break; + case 1: SetDark(true); break; + } + return 1; + } + + bool m_dark; + }; + } + + void CHooks::AddPopup(HWND wnd) { + addOp( [wnd, this] { + UpdateTitleBar(wnd, m_dark); + } ); + } + + void CHooks::AddDialogWithControls(HWND wnd) { + AddDialog(wnd); AddControls(wnd); + } + + void CHooks::AddDialog(HWND wnd) { + + { + CWindow w(wnd); + if ((w.GetStyle() & WS_CHILD) == 0) { + AddPopup(wnd); + } + } + + auto hook = new ImplementOnFinalMessage< CDialogHook > (m_dark); + hook->SubclassWindow(wnd); + AddCtrlMsg(wnd); + } + void CHooks::AddTabCtrl(HWND wnd) { + auto hook = new ImplementOnFinalMessage(m_dark); + hook->SubclassWindow(wnd); + AddCtrlMsg(wnd); + } + void CHooks::AddComboBox(HWND wnd) { + { + CComboBox combo = wnd; + COMBOBOXINFO info = {sizeof(info)}; + WIN32_OP_D( combo.GetComboBoxInfo(&info) ); + if (info.hwndList != NULL) { + AddListBox( info.hwndList ); + } + } + + addOp([wnd, this] { + SetWindowTheme(wnd, m_dark ? L"DarkMode_CFD" : L"Explorer", NULL); + }); + } + void CHooks::AddComboBoxEx(HWND wnd) { + this->AddControls(wnd); // recurse to add the combo box + } + void CHooks::AddEditBox(HWND wnd) { +#if 0 // Experimental + auto hook = new ImplementOnFinalMessage(m_dark); + hook->SubclassWindow( wnd ); + AddCtrlMsg( wnd ); +#else + AddGeneric(wnd); +#endif + } + void CHooks::AddButton(HWND wnd) { + CButton btn(wnd); + auto style = btn.GetButtonStyle(); + auto type = style & BS_TYPEMASK; + if ((type == BS_CHECKBOX || type == BS_AUTOCHECKBOX || type == BS_RADIOBUTTON || type == BS_AUTORADIOBUTTON || type == BS_3STATE || type == BS_AUTO3STATE) && (style & BS_PUSHLIKE) == 0) { + // MS checkbox implementation is terminally retarded and won't draw text in correct color + // Subclass it and draw our own content + // Other button types seem OK + auto hook = new ImplementOnFinalMessage(m_dark); + hook->SubclassWindow(wnd); + AddCtrlMsg(wnd); + } else if (type == BS_GROUPBOX) { + SetWindowTheme(wnd, L"", L""); + // SNAFU: re-creation of other controls such as list boxes causes repaint bugs due to overlapping + // Even though this is not a fault of the groupbox, fix it here - by defer-pushing all group boxes to the back + // Can't move to back right away, breaks window enumeration + m_lstMoveToBack.push_back(wnd); + } else { + AddGeneric(wnd); + } + + } + void CHooks::AddGeneric(HWND wnd, const wchar_t * name) { + this->addOp([wnd, this, name] {ApplyDarkThemeCtrl(wnd, m_dark, name); }); + } + void CHooks::AddClassic(HWND wnd, const wchar_t* normalTheme) { + this->addOp([wnd, this, normalTheme] { + if (m_dark) ::SetWindowTheme(wnd, L"", L""); + else ::SetWindowTheme(wnd, normalTheme, nullptr); + }); + } + void CHooks::AddStatusBar(HWND wnd) { + auto hook = new ImplementOnFinalMessage(m_dark); + hook->SubclassWindow(wnd); + this->AddCtrlMsg(wnd); + } + void CHooks::AddScrollBar(HWND wnd) { + CWindow w(wnd); + if (w.GetStyle() & SBS_SIZEGRIP) { + auto hook = new ImplementOnFinalMessage(m_dark); + hook->SubclassWindow(wnd); + this->AddCtrlMsg(wnd); + } else { + AddGeneric(wnd); + } + } + + void CHooks::AddReBar(HWND wnd) { + auto hook = new ImplementOnFinalMessage(m_dark); + hook->SubclassWindow(wnd); + this->AddCtrlMsg(wnd); + } + + void CHooks::AddToolBar(HWND wnd, bool bExplorerTheme) { + // Not a subclass + addObj(new CToolbarHook(wnd, m_dark, bExplorerTheme)); + } + + void CHooks::AddStatic(HWND wnd) { + auto hook = new ImplementOnFinalMessage(m_dark); + hook->SubclassWindow(wnd); + this->AddCtrlMsg(wnd); + } + + void CHooks::AddUpDown(HWND wnd) { + auto hook = new ImplementOnFinalMessage(m_dark); + hook->SubclassWindow(wnd); + this->AddCtrlMsg(wnd); + } + + void CHooks::AddTreeView(HWND wnd) { + auto hook = new ImplementOnFinalMessage(m_dark); + hook->SubclassWindow(wnd); + this->AddCtrlMsg(wnd); + } + void CHooks::AddListBox(HWND wnd) { + this->AddGeneric( wnd ); +#if 0 + auto subst = CListControl_ReplaceListBox(wnd); + if (subst) AddPPListControl(subst); +#endif + } + + void CHooks::AddListView(HWND wnd) { + auto subst = CListControl_ReplaceListView(wnd); + if (subst) AddPPListControl(subst); + } + + void CHooks::AddPPListControl(HWND wnd) { + this->AddCtrlMsg(wnd); + // this->addOp([this, wnd] { CListControl::wndSetDarkMode(wnd, m_dark); }); + } + + void CHooks::SetDark(bool v) { + // Important: some handlers to ugly things if told to apply when no state change occurred - UpdateTitleBar() stuff in particular + if (m_dark != v) { + m_dark = v; + for (auto& f : m_apply) f(); + } + } + void CHooks::flushMoveToBack() { + for (auto w : m_lstMoveToBack) { + ::SetWindowPos(w, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); + } + m_lstMoveToBack.clear(); + } + void CHooks::AddControls(HWND wndParent) { + for (HWND walk = GetWindow(wndParent, GW_CHILD); walk != NULL; ) { + HWND next = GetWindow(walk, GW_HWNDNEXT); + AddCtrlAuto(walk); + walk = next; + } + this->flushMoveToBack(); + // EnumChildWindows(wndParent, [this](HWND ctrl) {this->AddCtrlAuto(ctrl);}); + } + + void CHooks::AddCtrlMsg(HWND w) { + this->addOp([this, w] { + ::SendMessage(w, msgSetDarkMode(), this->m_dark ? 1 : 0, 0); + }); + } + + void CHooks::AddCtrlAuto(HWND wnd) { + + if (::SendMessage(wnd, msgSetDarkMode(), -1, -1)) { + AddCtrlMsg(wnd); return; + } + + wchar_t buffer[128] = {}; + + ::GetClassName(wnd, buffer, (int)(std::size(buffer) - 1)); + + const wchar_t* cls = buffer; + if (_wcsnicmp(cls, L"ATL:", 4) == 0) cls += 4; + + + if (_wcsicmp(cls, CButton::GetWndClassName()) == 0) { + AddButton(wnd); + } else if (_wcsicmp(cls, CComboBox::GetWndClassName()) == 0) { + AddComboBox(wnd); + } else if (_wcsicmp(cls, CComboBoxEx::GetWndClassName()) == 0 ) { + AddComboBoxEx(wnd); + } else if (_wcsicmp(cls, CTabCtrl::GetWndClassName()) == 0) { + AddTabCtrl(wnd); + } else if (_wcsicmp(cls, CStatusBarCtrl::GetWndClassName()) == 0) { + AddStatusBar(wnd); + } else if (_wcsicmp(cls, CEdit::GetWndClassName()) == 0) { + AddEditBox(wnd); + } else if (_wcsicmp(cls, WC_SCROLLBAR) == 0) { + AddScrollBar(wnd); + } else if (_wcsicmp(cls, CToolBarCtrl::GetWndClassName()) == 0) { + AddToolBar(wnd); + } else if (_wcsicmp(cls, CTrackBarCtrl::GetWndClassName()) == 0) { + AddGeneric(wnd); + } else if (_wcsicmp(cls, CTreeViewCtrl::GetWndClassName()) == 0) { + AddTreeView(wnd); + } else if (_wcsicmp(cls, CStatic::GetWndClassName()) == 0) { + AddStatic(wnd); + } else if (_wcsicmp(cls, CUpDownCtrl::GetWndClassName()) == 0) { + AddUpDown(wnd); + } else if (_wcsicmp(cls, CListViewCtrl::GetWndClassName()) == 0) { + AddListView(wnd); + } else if (_wcsicmp(cls, CListBox::GetWndClassName()) == 0) { + AddListBox(wnd); + } else if (_wcsicmp(cls, CReBarCtrl::GetWndClassName()) == 0) { + AddReBar(wnd); + } else { +#if PFC_DEBUG + pfc::outputDebugLine(pfc::format("DarkMode: unknown class - ", buffer)); +#endif + } + } + + void CHooks::clear() { + m_apply.clear(); + for (auto v : m_cleanup) v(); + m_cleanup.clear(); + } + + void CHooks::AddApp() { + addOp([this] { + SetAppDarkMode(this->m_dark); + }); + } + + void NCPaintDarkFrame(HWND wnd_, HRGN rgn_) { + // rgn is in SCREEN COORDINATES, possibly (HRGN)1 to indicate no clipping / whole nonclient area redraw + // we're working with SCREEN COORDINATES until actual DC painting + CWindow wnd = wnd_; + + CRect rcWindow, rcClient; + WIN32_OP_D( wnd.GetWindowRect(rcWindow) ); + WIN32_OP_D( wnd.GetClientRect(rcClient) ); + WIN32_OP_D( wnd.ClientToScreen( rcClient ) ); // transform all to same coordinate system + + CRgn rgnClip; + WIN32_OP_D( rgnClip.CreateRectRgnIndirect(rcWindow) != NULL ); + if (rgn_ != NULL && rgn_ != (HRGN)1) { + // we have a valid HRGN from caller? + if (rgnClip.CombineRgn(rgn_, RGN_AND) == NULLREGION) return; // nothing to draw, exit early + } + + { + // Have scroll bars? Have DefWindowProc() them then exclude from our rgnClip. + SCROLLBARINFO si = { sizeof(si) }; + if (::GetScrollBarInfo(wnd, OBJID_VSCROLL, &si) && (si.rgstate[0] & STATE_SYSTEM_INVISIBLE) == 0 && si.rcScrollBar.left < si.rcScrollBar.right) { + CRect rc = si.rcScrollBar; + // rcClient.right = rc.right; + CRgn rgn; WIN32_OP_D( rgn.CreateRectRgnIndirect(rc) ); + int status = SIMPLEREGION; + if (rgnClip) { + status = rgn.CombineRgn(rgn, rgnClip, RGN_AND); + } + if (status != NULLREGION) { + DefWindowProc(wnd, WM_NCPAINT, (WPARAM)rgn.m_hRgn, 0); + rgnClip.CombineRgn(rgn, RGN_DIFF); // exclude from further drawing + } + } + if (::GetScrollBarInfo(wnd, OBJID_HSCROLL, &si) && (si.rgstate[0] & STATE_SYSTEM_INVISIBLE) == 0 && si.rcScrollBar.top < si.rcScrollBar.bottom) { + CRect rc = si.rcScrollBar; + // rcClient.bottom = rc.bottom; + CRgn rgn; WIN32_OP_D(rgn.CreateRectRgnIndirect(rc)); + int status = SIMPLEREGION; + if (rgnClip) { + status = rgn.CombineRgn(rgn, rgnClip, RGN_AND); + } + if (status != NULLREGION) { + DefWindowProc(wnd, WM_NCPAINT, (WPARAM)rgn.m_hRgn, 0); + rgnClip.CombineRgn(rgn, RGN_DIFF); // exclude from further drawing + } + } + } + + const auto colorLight = DarkMode::GetSysColor(COLOR_BTNHIGHLIGHT); + const auto colorDark = DarkMode::GetSysColor(COLOR_BTNSHADOW); + + CWindowDC dc( wnd ); + if (dc.IsNull()) { + PFC_ASSERT(!"???"); + return; + } + + + // Window DC has (0,0) in upper-left corner of our window (not screen, not client) + // Turn rcWindow to (0,0), (winWidth, winHeight) + CPoint origin = rcWindow.TopLeft(); + rcWindow.OffsetRect(-origin); + rcClient.OffsetRect(-origin); + + if (!rgnClip.IsNull()) { + // rgnClip is still in screen coordinates, fix this here + rgnClip.OffsetRgn(-origin); + dc.SelectClipRgn(rgnClip); + } + + // bottom + dc.FillSolidRect(CRect(rcClient.left, rcClient.bottom, rcWindow.right, rcWindow.bottom), colorLight); + // right + dc.FillSolidRect(CRect(rcClient.right, rcWindow.top, rcWindow.right, rcClient.bottom), colorLight); + // top + dc.FillSolidRect(CRect(rcWindow.left, rcWindow.top, rcWindow.right, rcClient.top), colorDark); + // left + dc.FillSolidRect(CRect(rcWindow.left, rcClient.top, rcClient.left, rcWindow.bottom), colorDark); + } +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/DarkMode.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/DarkMode.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,112 @@ +#pragma once +#include +#include + +namespace DarkMode { + // Is dark mode supported on this system or not? + bool IsSupportedSystem(); + // Is system in dark mode or not? + bool QueryUserOption(); + + // Darken menus etc app-wide + void SetAppDarkMode(bool bDark); + // Darken window title bar + void UpdateTitleBar(HWND wnd, bool bDark ); + void ApplyDarkThemeCtrl(HWND ctrl, bool bDark, const wchar_t * ThemeID = L"Explorer"); + void ApplyDarkThemeCtrl2(HWND ctrl, bool bDark, const wchar_t* ThemeID_light = L"Explorer", const wchar_t* ThemeID_dark = L"DarkMode_Explorer"); + void AllowDarkModeForWindow(HWND wnd, bool bDark); + + // One-shot version of darkening function for editboxes + void DarkenEditLite(HWND ctrl); + // One-shot version of darkening function for comboboxes + void DarkenComboLite(HWND ctrl); + + // Returns if the dialog appears to be using dark mode (text brighter than background) + bool IsDialogDark(HWND dlg, UINT msgSend = WM_CTLCOLORDLG); + // Returns if the DC appears to be using dark mode (text brighter than background) + bool IsDCDark(HDC dc); + + // Returns if these colors (text, background) look like dark theme + bool IsThemeDark(COLORREF text, COLORREF background); + + COLORREF GetSysColor(int, bool bDark = true); + + LRESULT CustomDrawToolbar(NMHDR*); + // Custom draw handler that paints registered darkened controls. + // Can be used with NOTIFY_CODE_HANDLER() directly + LRESULT OnCustomDraw(int, NMHDR*, BOOL & bHandled); + + // Handle WM_NCPAINT drawing dark frame + void NCPaintDarkFrame(HWND ctrl, HRGN rgn); + + bool IsHighContrast(); + + // msgSetDarkMode + // return 1 if understood, 0 otherwise + // WPARAM = 0, DISABLE dark mode + // WPARAM = 1, ENABLE dark mode + // WPARAM = -1, query if supported + UINT msgSetDarkMode(); + + //! CHooks class: entrypoint class for all Dark Mode hacks. \n + //! Usage: Keep CHooks m_dark = detectDarkMode(); as a member of your window class, replacing detectDarkMode() with your own function returning dark mode on/off state. \n + //! When initializing your window (WM_CREATE, WM_INITDIALOG), call m_dark.AddDialogWithControls(m_hWnd); \n + //! AddDialogWithControls() walks all child windows of your window; call other individual methods to finetune handling of Dark Mode if that's not acceptable in your case. + class CHooks { + public: + CHooks(bool enabled = false) : m_dark(enabled) {} + CHooks(const CHooks&) = delete; + void operator=(const CHooks&) = delete; + + void AddDialog(HWND); + void AddTabCtrl(HWND); + void AddComboBox(HWND); + void AddComboBoxEx(HWND); + void AddButton(HWND); + void AddEditBox(HWND); + void AddPopup(HWND); + void AddStatusBar(HWND); + void AddScrollBar(HWND); + void AddToolBar(HWND, bool bExplorerTheme = true); + void AddReBar(HWND); + void AddStatic(HWND); + void AddUpDown(HWND); + void AddListBox(HWND); + void AddListView(HWND); + void AddTreeView(HWND); + void AddPPListControl(HWND); + + + // SetWindowTheme with DarkMode_Explorer <=> Explorer + void AddGeneric(HWND, const wchar_t * name = L"explorer"); + // SetWindowTheme(wnd, L"", L"") for dark, Explorer theme for normal + void AddClassic(HWND, const wchar_t* normalTheme = L"explorer"); + + void AddCtrlAuto(HWND); + void AddCtrlMsg(HWND); + + void AddDialogWithControls(HWND); + void AddControls(HWND wndParent); + + void SetDark(bool v = true); + bool IsDark() const { return m_dark; } + operator bool() const { return m_dark; } + + ~CHooks() { clear(); } + void clear(); + + void AddApp(); + private: + template void addObj(obj_t* arg) { + m_apply.push_back([arg, this] { arg->SetDark(m_dark); }); + m_cleanup.push_back([arg] { delete arg; }); + } + void addOp(std::function f) { f(); m_apply.push_back(f); } + bool m_dark = false; + std::list > m_apply; + std::list > m_cleanup; + + void flushMoveToBack(); + std::list m_lstMoveToBack; + }; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/DarkModeEx.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/DarkModeEx.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,8 @@ +#pragma once + +#include "DarkMode.h" + +namespace DarkMode { + void PaintTabsErase(CTabCtrl, CDCHandle); + void PaintTabs(CTabCtrl, CDCHandle, const RECT* rcPaint = nullptr); +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/EditBoxFix.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/EditBoxFix.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,19 @@ +#include "stdafx.h" +#include "EditBoxFixes.h" +#include "wtl-pp.h" +#include "windowLifetime.h" + +namespace PP { + void editBoxFix(HWND wndEdit) { + PFC_ASSERT( IsWindow(wndEdit) ); + PP::subclassThisWindow(wndEdit); + } + void comboBoxFix(HWND wndCombo) { + PFC_ASSERT( IsWindow(wndCombo) ); + CComboBox combo = wndCombo; + COMBOBOXINFO info = { sizeof(info) }; + if (combo.GetComboBoxInfo(&info)) { + if ( info.hwndItem != NULL ) editBoxFix( info.hwndItem ); + } + } +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/EditBoxFixes.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/EditBoxFixes.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,7 @@ +#pragma once + +namespace PP { + // One-line methods to inject our edit box shims: Ctrl+A, Ctrl+Backspace, etc + void editBoxFix(HWND wndEdit); + void comboBoxFix(HWND wndCombo); +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/GDIUtils.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/GDIUtils.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,101 @@ +#include "stdafx.h" + +#include "GDIUtils.h" + +HBITMAP CreateDIB24(CSize size) { + struct { + BITMAPINFOHEADER bmi; + } bi = {}; + bi.bmi.biSize = sizeof(bi.bmi); + bi.bmi.biWidth = size.cx; + bi.bmi.biHeight = size.cy; + bi.bmi.biPlanes = 1; + bi.bmi.biBitCount = 24; + bi.bmi.biCompression = BI_RGB; + void* bitsPtr; + return CreateDIBSection(NULL, reinterpret_cast(&bi), DIB_RGB_COLORS, &bitsPtr, 0, 0); +} + +HBITMAP CreateDIB16(CSize size) { + struct { + BITMAPINFOHEADER bmi; + } bi = {}; + bi.bmi.biSize = sizeof(bi.bmi); + bi.bmi.biWidth = size.cx; + bi.bmi.biHeight = size.cy; + bi.bmi.biPlanes = 1; + bi.bmi.biBitCount = 16; + bi.bmi.biCompression = BI_RGB; + void* bitsPtr; + return CreateDIBSection(NULL, reinterpret_cast(&bi), DIB_RGB_COLORS, &bitsPtr, 0, 0); +} + +HBITMAP CreateDIB8(CSize size, const COLORREF palette[256]) { + struct { + BITMAPINFOHEADER bmi; + COLORREF colors[256]; + } bi = { }; + for (int c = 0; c < 256; ++c) bi.colors[c] = palette[c]; + bi.bmi.biSize = sizeof(bi.bmi); + bi.bmi.biWidth = size.cx; + bi.bmi.biHeight = size.cy; + bi.bmi.biPlanes = 1; + bi.bmi.biBitCount = 8; + bi.bmi.biCompression = BI_RGB; + bi.bmi.biClrUsed = 256; + void* bitsPtr; + return CreateDIBSection(NULL, reinterpret_cast(&bi), DIB_RGB_COLORS, &bitsPtr, 0, 0); +} + +void CreateScaledFont(CFont& out, CFontHandle in, double scale) { + LOGFONT lf; + WIN32_OP_D(in.GetLogFont(lf)); + int temp = pfc::rint32(scale * lf.lfHeight); + if (temp == 0) temp = pfc::sgn_t(lf.lfHeight); + lf.lfHeight = temp; + WIN32_OP_D(out.CreateFontIndirect(&lf) != NULL); +} + +void CreateScaledFontEx(CFont& out, CFontHandle in, double scale, int weight) { + LOGFONT lf; + WIN32_OP_D(in.GetLogFont(lf)); + int temp = pfc::rint32(scale * lf.lfHeight); + if (temp == 0) temp = pfc::sgn_t(lf.lfHeight); + lf.lfHeight = temp; + lf.lfWeight = weight; + WIN32_OP_D(out.CreateFontIndirect(&lf) != NULL); +} + +void CreatePreferencesHeaderFont(CFont& out, CWindow source) { + CreateScaledFontEx(out, source.GetFont(), 1.3, FW_BOLD); +} + +void CreatePreferencesHeaderFont2(CFont& out, CWindow source) { + CreateScaledFontEx(out, source.GetFont(), 1.1, FW_BOLD); +} + +CSize GetBitmapSize(HBITMAP bmp) { + PFC_ASSERT(bmp != NULL); + CBitmapHandle h(bmp); + BITMAP bm = {}; + WIN32_OP_D(h.GetBitmap(bm)); + return CSize(bm.bmWidth, bm.bmHeight); +} + +CSize GetIconSize(HICON icon) { + PFC_ASSERT(icon != NULL); + CIconHandle h(icon); + ICONINFO info = {}; + WIN32_OP_D( h.GetIconInfo(&info) ); + CSize ret; + if (info.hbmColor != NULL) ret = GetBitmapSize(info.hbmColor); + else if (info.hbmMask != NULL) ret = GetBitmapSize(info.hbmMask); + else { PFC_ASSERT(!"???"); } + if (info.hbmColor != NULL) DeleteObject(info.hbmColor); + if (info.hbmMask != NULL) DeleteObject(info.hbmMask); + return ret; +} + +HBRUSH MakeTempBrush(HDC dc, COLORREF color) noexcept { + SetDCBrushColor(dc, color); return (HBRUSH)GetStockObject(DC_BRUSH); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/GDIUtils.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/GDIUtils.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,191 @@ +#pragma once +#include "win32_op.h" + +HBITMAP CreateDIB24(CSize size); +HBITMAP CreateDIB16(CSize size); +HBITMAP CreateDIB8(CSize size, const COLORREF palette[256]); +void CreateScaledFont(CFont& out, CFontHandle in, double scale); +void CreateScaledFontEx(CFont& out, CFontHandle in, double scale, int weight); +void CreatePreferencesHeaderFont(CFont& out, CWindow source); +void CreatePreferencesHeaderFont2(CFont& out, CWindow source); + +template +class CAltFontCtrl : public TCtrl { +public: + void Initialize(CWindow wnd, double scale, int weight) { + CreateScaledFontEx(m_font, wnd.GetFont(), scale, weight); + _initWnd(wnd); + } + void MakeHeader(CWindow wnd) { + CreatePreferencesHeaderFont(m_font, wnd); + _initWnd(wnd); + } + void MakeHeader2(CWindow wnd) { + CreatePreferencesHeaderFont2(m_font, wnd); + _initWnd(wnd); + } +private: + void _initWnd(CWindow wnd) { + this->SubclassWindow(wnd); this->SetFont(m_font); + } + CFont m_font; +}; + +class CFontScaled : public CFont { +public: + CFontScaled(HFONT _in, double scale) { + CreateScaledFont(*this, _in, scale); + } +}; + +class DCClipRgnScope { +public: + DCClipRgnScope(HDC dc) : m_dc(dc) { + m_dc.GetClipRgn(m_rgn); + } + ~DCClipRgnScope() { + m_dc.SelectClipRgn(m_rgn); + } + + HRGN OldVal() const noexcept {return m_rgn;} + + PFC_CLASS_NOT_COPYABLE_EX(DCClipRgnScope) +private: + CDCHandle m_dc; + CRgn m_rgn; +}; + + +HBRUSH MakeTempBrush(HDC dc, COLORREF color) noexcept; + +class CDCBrush : public CBrushHandle { +public: + CDCBrush(HDC dc, COLORREF color) noexcept { + m_dc = dc; + m_oldCol = m_dc.SetDCBrushColor(color); + m_hBrush = (HBRUSH) GetStockObject(DC_BRUSH); + } + ~CDCBrush() noexcept { + m_dc.SetDCBrushColor(m_oldCol); + } + PFC_CLASS_NOT_COPYABLE_EX(CDCBrush) +private: + CDCHandle m_dc; + COLORREF m_oldCol; +}; + +class CDCPen : public CPenHandle { +public: + CDCPen(HDC dc, COLORREF color) noexcept { + m_dc = dc; + m_oldCol = m_dc.SetDCPenColor(color); + m_hPen = (HPEN) GetStockObject(DC_PEN); + } + ~CDCPen() noexcept { + m_dc.SetDCPenColor(m_oldCol); + } +private: + CDCHandle m_dc; + COLORREF m_oldCol; +}; + + +class CBackBuffer : public CDC { +public: + CBackBuffer() { + CreateCompatibleDC(NULL); + ATLASSERT(m_hDC != NULL); + } + ~CBackBuffer() { + Dispose(); + } + void Attach(HBITMAP bmp, CSize size) { + Dispose(); + m_bitmap.Attach(bmp); m_curSize = size; + m_bitmapOld = SelectBitmap(m_bitmap); + } + void Attach(HBITMAP bmp) { + CSize size; + bool state = CBitmapHandle(bmp).GetSize(size); + ATLASSERT(state); (void)state; + Attach(bmp, size); + } + BOOL Allocate(CSize size, HDC dcCompatible = NULL) { + if (m_hDC == NULL) return FALSE; + if (m_curSize == size) return TRUE; + Dispose(); + HBITMAP temp; + if (dcCompatible == NULL) { + temp = CreateDIB24(size); + } else { + temp = CreateCompatibleBitmap(dcCompatible, size.cx, size.cy); + } + if (temp == NULL) return FALSE; + Attach(temp); + return TRUE; + } + + void Dispose() { + if (m_bitmap != NULL) { + SelectBitmap(m_bitmapOld); m_bitmapOld = NULL; + m_bitmap.DeleteObject(); + } + m_curSize = CSize(0,0); + } + BOOL GetBitmapPtr(t_uint8 * & ptr, t_ssize & lineWidth) { + if (m_bitmap == NULL) return FALSE; + BITMAP bmp = {}; + if (!m_bitmap.GetBitmap(bmp)) return FALSE; + lineWidth = bmp.bmWidthBytes; + ptr = reinterpret_cast(bmp.bmBits); + return TRUE; + } + CSize GetSize() const { return m_curSize; } + + PFC_CLASS_NOT_COPYABLE_EX(CBackBuffer) +private: + CSize m_curSize = CSize(0,0); + CBitmap m_bitmap; + HBITMAP m_bitmapOld = NULL; +}; + +class CBackBufferScope : public CDCHandle { +public: + CBackBufferScope(HDC hDC, HDC hDCBB, const CRect & rcPaint) : CDCHandle(hDCBB), m_rcPaint(rcPaint), m_dcOrig(hDC) + { + GetClipRgn(m_clipRgnOld); + CRgn temp; + if (m_dcOrig.GetClipRgn(temp) == 1) { + if (m_clipRgnOld != NULL) temp.CombineRgn(m_clipRgnOld,RGN_AND); + SelectClipRgn(temp); + } + IntersectClipRect(rcPaint); + } + + ~CBackBufferScope() + { + m_dcOrig.BitBlt(m_rcPaint.left,m_rcPaint.top,m_rcPaint.Width(),m_rcPaint.Height(),m_hDC,m_rcPaint.left,m_rcPaint.top,SRCCOPY); + SelectClipRgn(m_clipRgnOld); + } +private: + const CRect m_rcPaint; + CDCHandle m_dcOrig; + CRgn m_clipRgnOld; +}; + +class SetTextColorScope { +public: + SetTextColorScope(HDC dc, COLORREF col) noexcept : m_dc(dc) { + m_oldCol = SetTextColor(dc, col); + } + ~SetTextColorScope() noexcept { + SetTextColor(m_dc, m_oldCol); + } + PFC_CLASS_NOT_COPYABLE_EX(SetTextColorScope) +private: + HDC m_dc; + COLORREF m_oldCol; +}; + +CSize GetBitmapSize(HBITMAP bmp); +CSize GetIconSize(HICON icon); \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/HyperLinkCtrl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/HyperLinkCtrl.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,8 @@ +#pragma once +#include +namespace PP { + // One-line method to turn static control to hyperlink firing WM_NOTIFY + void createHyperLink(HWND wndReplaceMe); + void createHyperLink(HWND wndReplaceMe, std::function handler); + void createHyperLink(HWND wndReplaceMe, const wchar_t * openURL); +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/IDataObjectUtils.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/IDataObjectUtils.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,187 @@ +#include "stdafx.h" + +#include "IDataObjectUtils.h" + +HRESULT IDataObjectUtils::DataBlockToSTGMEDIUM(const void * blockPtr, t_size blockSize, STGMEDIUM * medium, DWORD tymed, bool bHere) throw() { + try { + if (bHere) { + switch(tymed) { + case TYMED_ISTREAM: + { + if (medium->pstm == NULL) return E_INVALIDARG; + ULONG written = 0; + HRESULT state; + state = medium->pstm->Write(blockPtr, pfc::downcast_guarded(blockSize),&written); + if (FAILED(state)) return state; + if (written != blockSize) return STG_E_MEDIUMFULL; + return S_OK; + } + default: + return DV_E_TYMED; + } + } else { + if (tymed & TYMED_HGLOBAL) { + HGLOBAL hMem = HGlobalFromMemblock(blockPtr, blockSize); + if (hMem == NULL) return E_OUTOFMEMORY; + medium->tymed = TYMED_HGLOBAL; + medium->hGlobal = hMem; + medium->pUnkForRelease = NULL; + return S_OK; + } + if (tymed & TYMED_ISTREAM) { + HRESULT state; + HGLOBAL hMem = HGlobalFromMemblock(blockPtr, blockSize); + if (hMem == NULL) return E_OUTOFMEMORY; + medium->tymed = TYMED_ISTREAM; + pfc::com_ptr_t stream; + if (FAILED( state = CreateStreamOnHGlobal(hMem,TRUE,stream.receive_ptr()) ) ) { + GlobalFree(hMem); + return state; + } + { + LARGE_INTEGER wtf = {}; + if (FAILED( state = stream->Seek(wtf,STREAM_SEEK_END,NULL) ) ) { + return state; + } + } + medium->pstm = stream.detach(); + medium->pUnkForRelease = NULL; + return S_OK; + } + return DV_E_TYMED; + } + } catch(pfc::exception_not_implemented const &) { + return E_NOTIMPL; + } catch(std::bad_alloc const &) { + return E_OUTOFMEMORY; + } catch(...) { + return E_UNEXPECTED; + } +} + + +HGLOBAL IDataObjectUtils::HGlobalFromMemblock(const void * ptr,t_size size) { + HGLOBAL handle = GlobalAlloc(GMEM_MOVEABLE,size); + if (handle != NULL) { + void * destptr = GlobalLock(handle); + if (destptr == NULL) { + GlobalFree(handle); + handle = NULL; + } else { + memcpy(destptr,ptr,size); + GlobalUnlock(handle); + } + } + return handle; +} + +HRESULT IDataObjectUtils::ExtractDataObjectContent(pfc::com_ptr_t obj, UINT format, DWORD aspect, LONG index, pfc::array_t & out) { + FORMATETC fmt = {}; + fmt.cfFormat = (CLIPFORMAT)format; fmt.dwAspect = aspect; fmt.lindex = index; + fmt.tymed = TYMED_HGLOBAL /* | TYMED_ISTREAM*/; + + STGMEDIUM med = {}; + HRESULT state; + if (FAILED( state = obj->GetData(&fmt,&med) ) ) return state; + ReleaseStgMediumScope relScope(&med); + return STGMEDIUMToDataBlock(med, out); +} + +HRESULT IDataObjectUtils::STGMEDIUMToDataBlock(const STGMEDIUM & med, pfc::array_t & out) { + switch(med.tymed) { + case TYMED_HGLOBAL: + { + CGlobalLockScope lock(med.hGlobal); + out.set_data_fromptr( (const t_uint8*) lock.GetPtr(), lock.GetSize() ); + } + return S_OK; + case TYMED_ISTREAM: + { + HRESULT state; + IStream * stream = med.pstm; + LARGE_INTEGER offset = {}; + STATSTG stats = {}; + if (FAILED( state = stream->Stat(&stats,STATFLAG_NONAME ) ) ) return state; + t_size toRead = pfc::downcast_guarded(stats.cbSize.QuadPart); + out.set_size(toRead); + if (FAILED( state = stream->Seek(offset,STREAM_SEEK_SET,NULL) ) ) return state; + ULONG cbRead = 0; + if (FAILED( state = stream->Read(out.get_ptr(), pfc::downcast_guarded(toRead), &cbRead) ) ) return state; + if (cbRead != toRead) return E_UNEXPECTED; + } + return S_OK; + default: + return DV_E_TYMED; + } +} + +HRESULT IDataObjectUtils::ExtractDataObjectContent(pfc::com_ptr_t obj, UINT format, pfc::array_t & out) { + return ExtractDataObjectContent(obj, format, DVASPECT_CONTENT, -1, out); +} + +HRESULT IDataObjectUtils::ExtractDataObjectContentTest(pfc::com_ptr_t obj, UINT format, DWORD aspect, LONG index) { + FORMATETC fmt = {}; + fmt.cfFormat = (CLIPFORMAT)format; fmt.dwAspect = aspect; fmt.lindex = index; + for(t_uint32 walk = 0; walk < 32; ++walk) { + const DWORD tymed = 1 << walk; + if ((ExtractDataObjectContent_SupportedTymeds & tymed) != 0) { + fmt.tymed = tymed; + HRESULT state = obj->QueryGetData(&fmt); + if (SUCCEEDED(state)) { + if (state == S_OK) return S_OK; + } else { + if (state != DV_E_TYMED) return state; + } + } + } + return E_FAIL; +} + +HRESULT IDataObjectUtils::ExtractDataObjectContentTest(pfc::com_ptr_t obj, UINT format) { + return ExtractDataObjectContentTest(obj,format,DVASPECT_CONTENT,-1); +} + +HRESULT IDataObjectUtils::ExtractDataObjectString(pfc::com_ptr_t obj, pfc::string_base & out) { + pfc::array_t data; + HRESULT state; + state = ExtractDataObjectContent(obj,CF_UNICODETEXT,data); + if (SUCCEEDED(state)) { + out = pfc::stringcvt::string_utf8_from_os_ex( (const wchar_t*) data.get_ptr(), data.get_size() / sizeof(wchar_t) ); + return S_OK; + } + state = ExtractDataObjectContent(obj,CF_TEXT,data); + if (SUCCEEDED(state)) { + out = pfc::stringcvt::string_utf8_from_os_ex( (const char*) data.get_ptr(), data.get_size() / sizeof(char) ); + return S_OK; + } + return E_FAIL; +} + +HRESULT IDataObjectUtils::SetDataObjectContent(pfc::com_ptr_t obj, UINT format, DWORD aspect, LONG index, const void * data, t_size dataSize) { + STGMEDIUM med = {}; + FORMATETC fmt = {}; + fmt.cfFormat = (CLIPFORMAT)format; fmt.dwAspect = aspect; fmt.lindex = index; fmt.tymed = TYMED_HGLOBAL; + HRESULT state; + if (FAILED(state = DataBlockToSTGMEDIUM(data,dataSize,&med,TYMED_HGLOBAL,false))) return state; + return obj->SetData(&fmt,&med,TRUE); +} + +HRESULT IDataObjectUtils::SetDataObjectString(pfc::com_ptr_t obj, const char * str) { + pfc::stringcvt::string_wide_from_utf8 s(str); + return SetDataObjectContent(obj,CF_UNICODETEXT,DVASPECT_CONTENT,-1,s.get_ptr(), (s.length()+1) * sizeof(s[0])); +} + +HRESULT IDataObjectUtils::ExtractDataObjectDWORD(pfc::com_ptr_t obj, UINT format, DWORD & val) { + HRESULT state; + pfc::array_t buffer; + if (FAILED( state = ExtractDataObjectContent(obj, format, DVASPECT_CONTENT, -1, buffer) ) ) return state; + if (buffer.get_size() < sizeof(val)) return E_UNEXPECTED; + val = *(DWORD*) buffer.get_ptr(); + return S_OK; +} +HRESULT IDataObjectUtils::SetDataObjectDWORD(pfc::com_ptr_t obj, UINT format, DWORD val) { + return SetDataObjectContent(obj,format,DVASPECT_CONTENT,-1,&val,sizeof(val)); +} +HRESULT IDataObjectUtils::PasteSucceeded(pfc::com_ptr_t obj, DWORD effect) { + return SetDataObjectDWORD(obj, RegisterClipboardFormat(CFSTR_PASTESUCCEEDED), effect); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/IDataObjectUtils.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/IDataObjectUtils.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,230 @@ +#pragma once + +#include +#include // IAsyncOperation +#include "pp-COM-macros.h" + +namespace IDataObjectUtils { + + class ReleaseStgMediumScope { + public: + ReleaseStgMediumScope(STGMEDIUM * medium) : m_medium(medium) {} + ~ReleaseStgMediumScope() {if (m_medium != NULL) ReleaseStgMedium(m_medium);} + private: + STGMEDIUM * m_medium; + + PFC_CLASS_NOT_COPYABLE_EX(ReleaseStgMediumScope) + }; + + static constexpr DWORD DataBlockToSTGMEDIUM_SupportedTymeds = TYMED_ISTREAM | TYMED_HGLOBAL; + static constexpr DWORD ExtractDataObjectContent_SupportedTymeds = TYMED_ISTREAM | TYMED_HGLOBAL; + + HRESULT DataBlockToSTGMEDIUM(const void * blockPtr, t_size blockSize, STGMEDIUM * medium, DWORD tymed, bool bHere) throw(); + + HGLOBAL HGlobalFromMemblock(const void * ptr,t_size size); + + HRESULT ExtractDataObjectContent(pfc::com_ptr_t obj, UINT format, DWORD aspect, LONG index, pfc::array_t & out); + HRESULT ExtractDataObjectContent(pfc::com_ptr_t obj, UINT format, pfc::array_t & out); + + HRESULT ExtractDataObjectContentTest(pfc::com_ptr_t obj, UINT format, DWORD aspect, LONG index); + HRESULT ExtractDataObjectContentTest(pfc::com_ptr_t obj, UINT format); + + HRESULT ExtractDataObjectString(pfc::com_ptr_t obj, pfc::string_base & out); + HRESULT SetDataObjectString(pfc::com_ptr_t obj, const char * str); + + HRESULT SetDataObjectContent(pfc::com_ptr_t obj, UINT format, DWORD aspect, LONG index, const void * data, t_size dataSize); + + HRESULT STGMEDIUMToDataBlock(const STGMEDIUM & med, pfc::array_t & out); + + HRESULT ExtractDataObjectDWORD(pfc::com_ptr_t obj, UINT format, DWORD & val); + HRESULT SetDataObjectDWORD(pfc::com_ptr_t obj, UINT format, DWORD val); + + HRESULT PasteSucceeded(pfc::com_ptr_t obj, DWORD effect); + + class comparator_FORMATETC { + public: + static int compare(const FORMATETC & v1, const FORMATETC & v2) { + int val; + val = pfc::compare_t(v1.cfFormat,v2.cfFormat); if (val != 0) return val; + val = pfc::compare_t(v1.dwAspect,v2.dwAspect); if (val != 0) return val; + val = pfc::compare_t(v1.lindex, v2.lindex ); if (val != 0) return val; + return 0; + } + }; + + class CDataObjectBase : public IDataObject { + public: + COM_QI_SIMPLE(IDataObject) + + HRESULT STDMETHODCALLTYPE GetData(FORMATETC * formatetc, STGMEDIUM * medium) override { + return GetData_internal(formatetc,medium,false); + } + + HRESULT STDMETHODCALLTYPE GetDataHere(FORMATETC * formatetc, STGMEDIUM * medium) override { + return GetData_internal(formatetc,medium,true); + } + + HRESULT STDMETHODCALLTYPE QueryGetData(FORMATETC * formatetc) override { + if (formatetc == NULL) return E_INVALIDARG; + + if ((DataBlockToSTGMEDIUM_SupportedTymeds & formatetc->tymed) == 0) return DV_E_TYMED; + + try { + return RenderDataTest(formatetc->cfFormat,formatetc->dwAspect,formatetc->lindex); + } PP_COM_CATCH; + } + + + HRESULT STDMETHODCALLTYPE GetCanonicalFormatEtc(FORMATETC * in, FORMATETC * out) override { + //check this again + if (in == NULL || out == NULL) + return E_INVALIDARG; + *out = *in; + return DATA_S_SAMEFORMATETC; + } + + HRESULT STDMETHODCALLTYPE EnumFormatEtc(DWORD dwDirection,IEnumFORMATETC ** ppenumFormatetc) override { + if (dwDirection == DATADIR_GET) { + if (ppenumFormatetc == NULL) return E_INVALIDARG; + return CreateIEnumFORMATETC(ppenumFormatetc); + } else if (dwDirection == DATADIR_SET) { + return E_NOTIMPL; + } else { + return E_INVALIDARG; + } + } + + HRESULT STDMETHODCALLTYPE SetData(FORMATETC * pFormatetc, STGMEDIUM * pmedium, BOOL fRelease) override { + try { + ReleaseStgMediumScope relScope(fRelease ? pmedium : NULL); + if (pFormatetc == NULL || pmedium == NULL) return E_INVALIDARG; + + /*TCHAR buf[256]; + if (GetClipboardFormatName(pFormatetc->cfFormat,buf,PFC_TABSIZE(buf)) > 0) { + buf[PFC_TABSIZE(buf)-1] = 0; + OutputDebugString(TEXT("SetData: ")); OutputDebugString(buf); OutputDebugString(TEXT("\n")); + } else { + OutputDebugString(TEXT("SetData: unknown clipboard format.\n")); + }*/ + + pfc::array_t temp; + HRESULT state = STGMEDIUMToDataBlock(*pmedium,temp); + if (FAILED(state)) return state; + m_entries.set(*pFormatetc,temp); + return S_OK; + } PP_COM_CATCH; + } + HRESULT STDMETHODCALLTYPE DAdvise(FORMATETC* pFormatetc, DWORD advf, IAdviseSink* pAdvSink, DWORD* pdwConnection) override { (void)pFormatetc; (void)advf; (void)pAdvSink; (void)pdwConnection; return OLE_E_ADVISENOTSUPPORTED; } + HRESULT STDMETHODCALLTYPE DUnadvise(DWORD dwConnection) override { (void)dwConnection; return OLE_E_ADVISENOTSUPPORTED; } + HRESULT STDMETHODCALLTYPE EnumDAdvise(IEnumSTATDATA** ppenumAdvise) override { (void)ppenumAdvise; return OLE_E_ADVISENOTSUPPORTED; } + protected: + typedef pfc::array_t data_t; + virtual HRESULT RenderData(UINT format,DWORD aspect,LONG dataIndex, data_t & out) const { + FORMATETC fmt = {}; + fmt.cfFormat = (CLIPFORMAT)format; fmt.dwAspect = aspect; fmt.lindex = dataIndex; + const pfc::array_t * entry = m_entries.query_ptr(fmt); + if (entry != NULL) { + out = * entry; + return S_OK; + } + return DV_E_FORMATETC; + } + virtual HRESULT RenderDataTest(UINT format,DWORD aspect,LONG dataIndex) const { + FORMATETC fmt = {}; + fmt.cfFormat = (CLIPFORMAT)format; fmt.dwAspect = aspect; fmt.lindex = dataIndex; + if (m_entries.have_item(fmt)) return S_OK; + return DV_E_FORMATETC; + } + typedef pfc::list_base_t TFormatList; + + static void AddFormat(TFormatList & out,UINT code) { + FORMATETC fmt = {}; + fmt.dwAspect = DVASPECT_CONTENT; + fmt.lindex = -1; + fmt.cfFormat = (CLIPFORMAT)code; + for(t_size medWalk = 0; medWalk < 32; ++medWalk) { + const DWORD med = 1 << medWalk; + if ((DataBlockToSTGMEDIUM_SupportedTymeds & med) != 0) { + fmt.tymed = med; + out.add_item(fmt); + } + } + } + + virtual void EnumFormats(TFormatList & out) const { + pfc::avltree_t formats; + for(auto walk = m_entries.cfirst(); walk.is_valid(); ++walk) { + formats.add_item( walk->m_key.cfFormat ); + } + for(auto walk = formats.cfirst(); walk.is_valid(); ++walk) { + AddFormat(out, *walk); + } + } + HRESULT CreateIEnumFORMATETC(IEnumFORMATETC ** outptr) const throw() { + try { + pfc::list_t out; + EnumFormats(out); + return SHCreateStdEnumFmtEtc((UINT)out.get_count(), out.get_ptr(), outptr); + } PP_COM_CATCH; + } + private: + HRESULT GetData_internal(FORMATETC * formatetc, STGMEDIUM * medium,bool bHere) { + if (formatetc == NULL || medium == NULL) return E_INVALIDARG; + + try { + data_t out; + HRESULT hr = RenderData(formatetc->cfFormat,formatetc->dwAspect,formatetc->lindex,out); + if (FAILED(hr)) return hr; + return DataBlockToSTGMEDIUM(out.get_ptr(),out.get_size(),medium,formatetc->tymed,bHere); + } PP_COM_CATCH; + } + + typedef pfc::map_t, comparator_FORMATETC> t_entries; + t_entries m_entries; + }; + +#ifdef __IDataObjectAsyncCapability_INTERFACE_DEFINED__ + typedef IDataObjectAsyncCapability IDataObjectAsyncCapability_t; +#else + typedef IAsyncOperation IDataObjectAsyncCapability_t; +#endif + + class CAsyncDataObjectBase : public CDataObjectBase, public IDataObjectAsyncCapability_t { + BOOL m_inOperation = FALSE; + BOOL m_asyncMode = TRUE; + protected: + COM_QI_BEGIN() + COM_QI_CHAIN(CDataObjectBase) + COM_QI_ENTRY(IDataObjectAsyncCapability_t) + COM_QI_END() + public: + HRESULT STDMETHODCALLTYPE SetAsyncMode(BOOL fDoOpAsync) override { + m_asyncMode = fDoOpAsync; + return S_OK; + } + + HRESULT STDMETHODCALLTYPE GetAsyncMode(BOOL *pfIsOpAsync) override { + if ( pfIsOpAsync == nullptr ) return E_INVALIDARG; + *pfIsOpAsync = m_asyncMode; + return S_OK; + } + + HRESULT STDMETHODCALLTYPE StartOperation(IBindCtx *pbcReserved) override { + (void)pbcReserved; + m_inOperation = TRUE; + return S_OK; + } + + HRESULT STDMETHODCALLTYPE InOperation(BOOL *pfInAsyncOp) override { + if ( pfInAsyncOp == nullptr ) return E_INVALIDARG; + *pfInAsyncOp = m_inOperation; + return S_OK; + } + + HRESULT STDMETHODCALLTYPE EndOperation(HRESULT hResult,IBindCtx *pbcReserved,DWORD dwEffects) override { + (void)hResult; (void)pbcReserved; (void)dwEffects; + m_inOperation = FALSE; + return S_OK; + } + }; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/ImageEncoder.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/ImageEncoder.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,157 @@ +#include "stdafx.h" +#include "ImageEncoder.h" +#include "gdiplus_helpers.h" +#include +#include + +using namespace Gdiplus; +static GdiplusErrorHandler EH; + +int GetEncoderClsid(const WCHAR* format, CLSID* pClsid) +{ + UINT num = 0; // number of image encoders + UINT size = 0; // size of the image encoder array in bytes + + ImageCodecInfo* pImageCodecInfo = NULL; + + GetImageEncodersSize(&num, &size); + if(size == 0) + return -1; // Failure + + pImageCodecInfo = (ImageCodecInfo*)(malloc(size)); + if(pImageCodecInfo == NULL) + return -1; // Failure + + GetImageEncoders(num, size, pImageCodecInfo); + + for(UINT j = 0; j < num; ++j) + { + if( wcscmp(pImageCodecInfo[j].MimeType, format) == 0 ) + { + *pClsid = pImageCodecInfo[j].Clsid; + free(pImageCodecInfo); + return j; // Success + } + } + + free(pImageCodecInfo); + return -1; // Failure +} + +void ConvertImage(const TCHAR * in, const TCHAR * out, const TCHAR * format, ULONG quality) { + GdiplusScope scope; + Bitmap image (in); + EH << image.GetLastStatus(); + SaveImage(&image, out, format, quality); +} + +static void add16clip(uint16_t& v, int d) { + int v2 = (int) v + d; + if ( v2 < 0 ) v2 = 0; + if ( v2 > (int) UINT16_MAX ) v2 = UINT16_MAX; + v = (uint16_t) v2; +} + +std::unique_ptr image16bpcto8(Gdiplus::Bitmap* img) { + + const unsigned channels = [img] { + switch (img->GetPixelFormat()) { + case PixelFormat48bppRGB: + return 3; + case PixelFormat16bppGrayScale: + return 1; + default: + throw std::runtime_error("Invalid pixel format"); + } + } (); + + + const unsigned Width = img->GetWidth(); + const unsigned Height = img->GetHeight(); + + if ( Width == 0 || Height == 0 ) throw std::runtime_error("Invalid dimensions"); + + std::unique_ptr< Gdiplus::Bitmap > ret ( new Gdiplus::Bitmap( Width, Height, channels == 3 ? PixelFormat24bppRGB : PixelFormat8bppIndexed ) ); + + + Gdiplus::Rect rcWhole = {}; + rcWhole.Width = Width; rcWhole.Height = Height; + Gdiplus::BitmapData dataIn, dataOut; + EH << ret->LockBits( &rcWhole, ImageLockModeWrite, PixelFormat24bppRGB, &dataOut); + EH << img->LockBits(&rcWhole, ImageLockModeRead, PixelFormat48bppRGB, &dataIn); + + + + + const uint8_t * inLine = (const uint8_t*)dataIn.Scan0; + uint8_t * outLine = (uint8_t*)dataOut.Scan0; + + std::vector curLineBuf, nextLineBuf; + curLineBuf.resize( (Width + 2) * channels ); + nextLineBuf.resize( (Width + 2) * channels ); + + memcpy(&nextLineBuf[channels], inLine, Width * channels * 2 ); + + for (unsigned y = 0; y < Height; ++y) { + std::swap( curLineBuf, nextLineBuf ); + if (y + 1 < Height) { + inLine += dataIn.Stride; + memcpy(&nextLineBuf[channels], inLine, Width * channels * 2 ); + } + + auto & inPix = curLineBuf; + auto & inPixNext = nextLineBuf; + size_t inOffset = channels; + uint8_t * outPix = outLine; + for (unsigned x = 0; x < Width; ++x) { + for (int c = 0; c < (int)channels; ++c) { + uint16_t orig = inPix[inOffset]; + uint16_t v8 = orig >> 8; + uint16_t v16 = v8 | (v8 << 8); + + outPix[c] = (uint8_t) v8; + + int d = (int) orig - (int) v16; + + add16clip(inPix [inOffset + channels], d * 7 / 16 ); // x+1 + add16clip(inPixNext[inOffset - channels], d * 3 / 16 ); // x-1, y+1 + add16clip(inPixNext[inOffset ], d * 5 / 16 ); // y+1 + add16clip(inPixNext[inOffset + channels], d * 1 / 16 ); // x+1, y+1 + + ++ inOffset; + } + + outPix += channels; + } + + outLine += dataOut.Stride; + } + + EH << img->UnlockBits(&dataIn); + EH << ret->UnlockBits(&dataOut); + + return ret; +} + +void SaveImage(Gdiplus::Image* bmp, const TCHAR* out, const TCHAR* format, ULONG quality) { + if (bmp->GetType() != Gdiplus::ImageTypeBitmap) throw std::runtime_error("Bitmap expected"); + SaveImage(static_cast(bmp), out, format, quality); +} +void SaveImage(Gdiplus::Bitmap* image, const TCHAR* out, const TCHAR* format, ULONG quality) { + CLSID encoderClsid; + EncoderParameters encoderParameters; + + if (GetEncoderClsid(format, &encoderClsid) < 0) throw std::runtime_error("Encoder not found"); + + if (_tcscmp(format, _T("image/jpeg")) == 0) { + encoderParameters.Count = 1; + encoderParameters.Parameter[0].Guid = EncoderQuality; + encoderParameters.Parameter[0].Type = EncoderParameterValueTypeLong; + encoderParameters.Parameter[0].NumberOfValues = 1; + encoderParameters.Parameter[0].Value = &quality; + + EH << image->Save(out, &encoderClsid, &encoderParameters); + } else { + EH << image->Save(out, &encoderClsid, NULL); + } +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/ImageEncoder.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/ImageEncoder.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,8 @@ +#pragma once +#include +namespace Gdiplus { class Image; class Bitmap; }; + +void SaveImage(Gdiplus::Image* bmp, const TCHAR* out, const TCHAR* format, ULONG quality = 100); +void SaveImage( Gdiplus::Bitmap * bmp, const TCHAR * out, const TCHAR * format, ULONG quality = 100); +void ConvertImage(const TCHAR * in, const TCHAR * out, const TCHAR * format, ULONG quality = 100); +std::unique_ptr image16bpcto8(Gdiplus::Bitmap* img); \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/ImplementOnFinalMessage.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/ImplementOnFinalMessage.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,8 @@ +#pragma once + +template +class ImplementOnFinalMessage : public class_t { +public: + template ImplementOnFinalMessage(arg_t && ... arg) : class_t(std::forward(arg) ...) {} + void OnFinalMessage(HWND wnd) override { PFC_ASSERT_NO_EXCEPTION(class_t::OnFinalMessage(wnd)); PFC_ASSERT_NO_EXCEPTION(delete this); } +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/InPlaceCombo.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/InPlaceCombo.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,351 @@ +#include "stdafx.h" + +#include "InPlaceEdit.h" +#include "wtl-pp.h" +#include "win32_op.h" + +#include "AutoComplete.h" +#include "CWindowCreateAndDelete.h" +#include "win32_utility.h" +#include "listview_helper.h" // ListView_GetColumnCount +#include "clipboard.h" +#include "DarkMode.h" + +#include + +using namespace InPlaceEdit; + + +namespace { + + enum { + MSG_COMPLETION = WM_USER, + MSG_DISABLE_EDITING + }; + + + // Rationale: more than one HWND on the list is extremely uncommon, hence forward_list + static std::forward_list g_editboxes; + static HHOOK g_hook = NULL /*, g_keyHook = NULL*/; + + static void GAbortEditing(HWND edit, t_uint32 code) { + CWindow parent = ::GetParent(edit); + parent.SendMessage(MSG_DISABLE_EDITING); + parent.PostMessage(MSG_COMPLETION, code, 0); + } + +#if 0 + static void GAbortEditing(t_uint32 code) { + for (auto walk = g_editboxes.begin(); walk != g_editboxes.end(); ++walk) { + GAbortEditing(*walk, code); + } + } +#endif + + static bool IsSamePopup(CWindow wnd1, CWindow wnd2) { + return pfc::findOwningPopup(wnd1) == pfc::findOwningPopup(wnd2); + } + + static void MouseEventTest(HWND target, CPoint pt, bool isWheel) { + for (auto walk = g_editboxes.begin(); walk != g_editboxes.end(); ++walk) { + CWindow edit(*walk); + bool cancel = false; + if (target != edit && IsSamePopup(target, edit)) { + cancel = true; + } else if (isWheel) { + CWindow target2 = WindowFromPoint(pt); + if (target2 != edit && IsSamePopup(target2, edit)) { + cancel = true; + } + } + + if (cancel) GAbortEditing(edit, KEditLostFocus); + } + } + + static LRESULT CALLBACK GMouseProc(int nCode, WPARAM wParam, LPARAM lParam) { + if (nCode == HC_ACTION) { + const MOUSEHOOKSTRUCT * mhs = reinterpret_cast(lParam); + switch (wParam) { + case WM_NCLBUTTONDOWN: + case WM_NCRBUTTONDOWN: + case WM_NCMBUTTONDOWN: + case WM_NCXBUTTONDOWN: + case WM_LBUTTONDOWN: + case WM_RBUTTONDOWN: + case WM_MBUTTONDOWN: + case WM_XBUTTONDOWN: + MouseEventTest(mhs->hwnd, mhs->pt, false); + break; + case WM_MOUSEWHEEL: + case WM_MOUSEHWHEEL: + MouseEventTest(mhs->hwnd, mhs->pt, true); + break; + } + } + return CallNextHookEx(g_hook, nCode, wParam, lParam); + } + + static void on_editbox_creation(HWND p_editbox) { + // PFC_ASSERT(core_api::is_main_thread()); + g_editboxes.push_front(p_editbox); + if (g_hook == NULL) { + g_hook = SetWindowsHookEx(WH_MOUSE, GMouseProc, NULL, GetCurrentThreadId()); + } + /*if (g_keyHook == NULL) { + g_keyHook = SetWindowsHookEx(WH_KEYBOARD, GKeyboardProc, NULL, GetCurrentThreadId()); + }*/ + } + static void UnhookHelper(HHOOK & hook) { + HHOOK v = pfc::replace_null_t(hook); + if (v != NULL) UnhookWindowsHookEx(v); + } + static void on_editbox_destruction(HWND p_editbox) { + // PFC_ASSERT(core_api::is_main_thread()); + g_editboxes.remove(p_editbox); + if (g_editboxes.empty()) { + UnhookHelper(g_hook); /*UnhookHelper(g_keyHook);*/ + } + } + + class CInPlaceComboBox : public CWindowImpl { + public: + BEGIN_MSG_MAP_EX(CInPlaceComboBox) + //MSG_WM_CREATE(OnCreate) + MSG_WM_DESTROY(OnDestroy) + MSG_WM_GETDLGCODE(OnGetDlgCode) + // MSG_WM_KILLFOCUS(OnKillFocus) + MSG_WM_KEYDOWN(OnKeyDown) + END_MSG_MAP() + + void OnCreation() { + on_editbox_creation(m_hWnd); + } + private: + void OnDestroy() { + m_selfDestruct = true; + on_editbox_destruction(m_hWnd); + SetMsgHandled(FALSE); + } + int OnCreate(LPCREATESTRUCT) { + OnCreation(); + SetMsgHandled(FALSE); + return 0; + } + UINT OnGetDlgCode(LPMSG lpMsg) { + if (lpMsg == NULL) { + SetMsgHandled(FALSE); return 0; + } else { + switch (lpMsg->message) { + case WM_KEYDOWN: + case WM_SYSKEYDOWN: + switch (lpMsg->wParam) { + case VK_TAB: + case VK_ESCAPE: + case VK_RETURN: + return DLGC_WANTMESSAGE; + default: + SetMsgHandled(FALSE); return 0; + } + default: + SetMsgHandled(FALSE); return 0; + + } + } + } + void OnKillFocus(CWindow wndFocus) { + if ( wndFocus != NULL ) ForwardCompletion(KEditLostFocus); + SetMsgHandled(FALSE); + } + + void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { + (void)nRepCnt; + m_suppressChar = nFlags & 0xFF; + switch (nChar) { + case VK_TAB: + ForwardCompletion(IsKeyPressed(VK_SHIFT) ? KEditShiftTab : KEditTab); + return; + case VK_ESCAPE: + ForwardCompletion(KEditAborted); + return; + } + m_suppressChar = 0; + SetMsgHandled(FALSE); + } + + void ForwardCompletion(t_uint32 code) { + if (IsWindowEnabled()) { + CWindow owner = GetParent(); + owner.SendMessage(MSG_DISABLE_EDITING); + owner.PostMessage(MSG_COMPLETION, code, 0); + EnableWindow(FALSE); + } + } + + bool m_selfDestruct = false; + UINT m_suppressChar = 0; + }; + + class InPlaceComboContainer : public CWindowImpl { + public: + DECLARE_WND_CLASS_EX(_T("{18D85006-0CDB-49AB-A563-6A42014309A3}"), 0, -1); + + const pfc::string_list_const * m_initData; + const unsigned m_iDefault; + + HWND Create(CWindow parent) { + + RECT rect_cropped; + { + RECT client; + WIN32_OP_D(parent.GetClientRect(&client)); + IntersectRect(&rect_cropped, &client, &m_initRect); + } + const DWORD containerStyle = WS_BORDER | WS_CHILD; + AdjustWindowRect(&rect_cropped, containerStyle, FALSE); + + + + WIN32_OP(__super::Create(parent, rect_cropped, NULL, containerStyle) != NULL); + + try { + CRect rcClient; + WIN32_OP_D(GetClientRect(rcClient)); + + + DWORD style = WS_CHILD | WS_VISIBLE;//parent is invisible now + + style |= CBS_DROPDOWNLIST; + + + CComboBox edit; + + WIN32_OP(edit.Create(*this, rcClient, NULL, style, 0, ID_MYEDIT) != NULL); + edit.SetFont(parent.GetFont()); + + if ((m_flags & KFlagDark) != 0) DarkMode::DarkenComboLite(edit); + + m_edit.SubclassWindow(edit); + m_edit.OnCreation(); + + +#if 0 // doesn't quite work + if (m_flags & (KFlagAlignCenter | KFlagAlignRight)) { + COMBOBOXINFO info = {sizeof(info)}; + if (m_edit.GetComboBoxInfo(&info)) { + CEdit edit2 = info.hwndList; + if (edit2) { + if (m_flags & KFlagAlignCenter) edit2.ModifyStyle(0, ES_CENTER); + else if (m_flags & KFlagAlignRight) edit2.ModifyStyle(0, ES_RIGHT); + } + } + } +#endif + + + if (m_initData != nullptr) { + const size_t count = m_initData->get_count(); + for (size_t walk = 0; walk < count; ++walk) { + m_edit.AddString(pfc::stringcvt::string_os_from_utf8(m_initData->get_item(walk))); + } + if (m_iDefault < count) m_edit.SetCurSel(m_iDefault); + } + } catch (...) { + PostMessage(MSG_COMPLETION, InPlaceEdit::KEditAborted, 0); + return m_hWnd; + } + + ShowWindow(SW_SHOW); + m_edit.SetFocus(); + + m_initialized = true; + + m_edit.ShowDropDown(); + + PFC_ASSERT(m_hWnd != NULL); + + return m_hWnd; + } + + InPlaceComboContainer(const RECT & p_rect, unsigned p_flags, pfc::string_list_const * initData, unsigned iDefault, comboReply_t p_notify) : m_notify(p_notify), m_initData(initData), m_iDefault(iDefault), m_initRect(p_rect), m_flags(p_flags) { } + + enum { ID_MYEDIT = 666 }; + + BEGIN_MSG_MAP_EX(InPlaceEditContainer) + MESSAGE_HANDLER_EX(WM_CTLCOLOREDIT, MsgForwardToParent) + MESSAGE_HANDLER_EX(WM_CTLCOLORSTATIC, MsgForwardToParent) + MESSAGE_HANDLER_EX(WM_MOUSEWHEEL, MsgLostFocus) + MESSAGE_HANDLER_EX(WM_MOUSEHWHEEL, MsgLostFocus) + MESSAGE_HANDLER_SIMPLE(MSG_DISABLE_EDITING, OnMsgDisableEditing) + MESSAGE_HANDLER_EX(MSG_COMPLETION, OnMsgCompletion) + COMMAND_ID_HANDLER_EX(ID_MYEDIT, OnComboMsg) + MSG_WM_DESTROY(OnDestroy) + END_MSG_MAP() + + HWND GetEditBox() const { return m_edit; } + + private: + void OnDestroy() { m_selfDestruct = true; } + + LRESULT MsgForwardToParent(UINT msg, WPARAM wParam, LPARAM lParam) { + return GetParent().SendMessage(msg, wParam, lParam); + } + LRESULT MsgLostFocus(UINT, WPARAM, LPARAM) { + PostMessage(MSG_COMPLETION, InPlaceEdit::KEditLostFocus, 0); + return 0; + } + void OnMsgDisableEditing() { + ShowWindow(SW_HIDE); + GetParent().UpdateWindow(); + } + LRESULT OnMsgCompletion(UINT, WPARAM wParam, LPARAM) { + PFC_ASSERT(m_initialized); + if ((wParam & KEditMaskReason) != KEditLostFocus) { + GetParent().SetFocus(); + } + OnCompletion((unsigned) wParam ); + if (!m_selfDestruct) { + m_selfDestruct = true; + DestroyWindow(); + } + return 0; + } + void OnComboMsg(UINT code, int, CWindow) { + if (m_initialized && (code == CBN_SELENDOK || code == CBN_SELENDCANCEL) ) { + PostMessage(MSG_COMPLETION, InPlaceEdit::KEditLostFocus, 0); + } + } + + private: + + void OnCompletion(unsigned p_status) { + if (!m_completed) { + m_completed = true; + if (m_notify) m_notify( p_status, m_edit.GetCurSel() ); + } + } + + const comboReply_t m_notify; + bool m_completed = false; + bool m_initialized = false; + bool m_selfDestruct = false; + const CRect m_initRect; + CInPlaceComboBox m_edit; + const unsigned m_flags; + }; + +} + +static void fail(comboReply_t p_notify) { + p_notify(KEditAborted, UINT_MAX); +} + +HWND InPlaceEdit::StartCombo(HWND p_parentwnd, const RECT & p_rect, unsigned p_flags, pfc::string_list_const & data, unsigned iDefault, comboReply_t p_notify) { + try { + PFC_ASSERT((CWindow(p_parentwnd).GetWindowLong(GWL_STYLE) & WS_CLIPCHILDREN) != 0); + return (new CWindowCreateAndDelete(p_parentwnd, p_rect, p_flags, &data, iDefault, p_notify))->GetEditBox(); + } catch (...) { + fail(p_notify); + return NULL; + } +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/InPlaceEdit.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/InPlaceEdit.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,521 @@ +#include "stdafx.h" + +#include "InPlaceEdit.h" +#include "wtl-pp.h" +#include "win32_op.h" + +#include "AutoComplete.h" +#include "CWindowCreateAndDelete.h" +#include "win32_utility.h" +#include "listview_helper.h" // ListView_GetColumnCount +#include "clipboard.h" + +#include "DarkMode.h" + +#include + +using namespace InPlaceEdit; + +namespace { + + enum { + MSG_COMPLETION = WM_USER, + MSG_DISABLE_EDITING + }; + + + // Rationale: more than one HWND on the list is extremely uncommon, hence forward_list + static std::forward_list g_editboxes; + static HHOOK g_hook = NULL /*, g_keyHook = NULL*/; + + static void GAbortEditing(HWND edit, t_uint32 code) { + CWindow parent = ::GetParent(edit); + parent.SendMessage(MSG_DISABLE_EDITING); + parent.PostMessage(MSG_COMPLETION, code, 0); + } + +#if 0 + static void GAbortEditing(t_uint32 code) { + for (auto walk = g_editboxes.begin(); walk != g_editboxes.end(); ++walk) { + GAbortEditing(*walk, code); + } + } +#endif + static bool IsSamePopup(CWindow wnd1, CWindow wnd2) { + return pfc::findOwningPopup(wnd1) == pfc::findOwningPopup(wnd2); + } + + static void MouseEventTest(HWND target, CPoint pt, bool isWheel) { + for (CWindow edit : g_editboxes) { + bool cancel = false; + if (target != edit && IsSamePopup(target, edit)) { + cancel = true; + } else if (isWheel) { + CWindow target2 = WindowFromPoint(pt); + if (target2 != edit && IsSamePopup(target2, edit)) { + cancel = true; + } + } + + if (cancel) GAbortEditing(edit, KEditLostFocus); + } + } + + static LRESULT CALLBACK GMouseProc(int nCode, WPARAM wParam, LPARAM lParam) { + if (nCode == HC_ACTION) { + const MOUSEHOOKSTRUCT * mhs = reinterpret_cast(lParam); + switch (wParam) { + case WM_NCLBUTTONDOWN: + case WM_NCRBUTTONDOWN: + case WM_NCMBUTTONDOWN: + case WM_NCXBUTTONDOWN: + case WM_LBUTTONDOWN: + case WM_RBUTTONDOWN: + case WM_MBUTTONDOWN: + case WM_XBUTTONDOWN: + MouseEventTest(mhs->hwnd, mhs->pt, false); + break; + case WM_MOUSEWHEEL: + case WM_MOUSEHWHEEL: + MouseEventTest(mhs->hwnd, mhs->pt, true); + break; + } + } + return CallNextHookEx(g_hook, nCode, wParam, lParam); + } + + static void on_editbox_creation(HWND p_editbox) { + // PFC_ASSERT(core_api::is_main_thread()); + g_editboxes.push_front(p_editbox); + if (g_hook == NULL) { + g_hook = SetWindowsHookEx(WH_MOUSE, GMouseProc, NULL, GetCurrentThreadId()); + } + /*if (g_keyHook == NULL) { + g_keyHook = SetWindowsHookEx(WH_KEYBOARD, GKeyboardProc, NULL, GetCurrentThreadId()); + }*/ + } + static void UnhookHelper(HHOOK & hook) { + HHOOK v = pfc::replace_null_t(hook); + if (v != NULL) UnhookWindowsHookEx(v); + } + static void on_editbox_destruction(HWND p_editbox) { + // PFC_ASSERT(core_api::is_main_thread()); + g_editboxes.remove(p_editbox); + if (g_editboxes.empty()) { + UnhookHelper(g_hook); /*UnhookHelper(g_keyHook);*/ + } + } + + class CInPlaceEditBox : public CWindowImpl { + public: + CInPlaceEditBox(uint32_t flags) : m_flags(flags) {} + BEGIN_MSG_MAP_EX(CInPlaceEditBox) + //MSG_WM_CREATE(OnCreate) + MSG_WM_DESTROY(OnDestroy) + MSG_WM_GETDLGCODE(OnGetDlgCode) + MSG_WM_KILLFOCUS(OnKillFocus) + MSG_WM_CHAR(OnChar) + MSG_WM_KEYDOWN(OnKeyDown) + MSG_WM_PASTE(OnPaste) + END_MSG_MAP() + + void OnCreation() { + on_editbox_creation(m_hWnd); + } + private: + void OnDestroy() { + m_selfDestruct = true; + on_editbox_destruction(m_hWnd); + SetMsgHandled(FALSE); + } + int OnCreate(LPCREATESTRUCT) { + OnCreation(); + SetMsgHandled(FALSE); + return 0; + } + UINT OnGetDlgCode(LPMSG lpMsg) { + if (lpMsg == NULL) { + SetMsgHandled(FALSE); return 0; + } else { + switch (lpMsg->message) { + case WM_KEYDOWN: + case WM_SYSKEYDOWN: + switch (lpMsg->wParam) { + case VK_TAB: + case VK_ESCAPE: + case VK_RETURN: + return DLGC_WANTMESSAGE; + default: + SetMsgHandled(FALSE); return 0; + } + default: + SetMsgHandled(FALSE); return 0; + + } + } + } + void OnKillFocus(CWindow wndFocus) { + if ( wndFocus != NULL ) ForwardCompletion(KEditLostFocus); + SetMsgHandled(FALSE); + } + + bool testPaste(const char* str) { + if (m_flags & InPlaceEdit::KFlagNumberSigned) { + if (pfc::string_is_numeric(str)) return true; + if (str[0] == '-' && pfc::string_is_numeric(str + 1) && GetWindowTextLength() == 0) return true; + return false; + } + if (m_flags & InPlaceEdit::KFlagNumber) { + return pfc::string_is_numeric(str); + } + return true; + } + + void OnPaste() { + if (m_flags & (InPlaceEdit::KFlagNumber | InPlaceEdit::KFlagNumberSigned)) { + pfc::string8 temp; + ClipboardHelper::OpenScope scope; scope.Open(m_hWnd); + if (ClipboardHelper::GetString(temp)) { + if (!testPaste(temp)) return; + } + } + // Let edit box handle it + SetMsgHandled(FALSE); + } + bool testChar(UINT nChar) { + // Allow various non text characters + if (nChar < ' ') return true; + + if (m_flags & InPlaceEdit::KFlagNumberSigned) { + if (pfc::char_is_numeric(nChar)) return true; + if (nChar == '-') { + return GetWindowTextLength() == 0; + } + return false; + } + if (m_flags & InPlaceEdit::KFlagNumber) { + return pfc::char_is_numeric(nChar); + } + return true; + } + void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) { + (void)nRepCnt; (void)nRepCnt; + if (m_suppressChar != 0) { + UINT code = nFlags & 0xFF; + if (code == m_suppressChar) return; + } + + if (!testChar(nChar)) { + MessageBeep(0); + return; + } + + SetMsgHandled(FALSE); + } + void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { + (void)nRepCnt; + m_suppressChar = nFlags & 0xFF; + switch (nChar) { + case VK_BACK: + if (GetHotkeyModifierFlags() == MOD_CONTROL) { + CEditPPHooks::DeleteLastWord(*this); + return; + } + break; + case 'A': + if (GetHotkeyModifierFlags() == MOD_CONTROL) { + this->SetSelAll(); return; + } + break; + case VK_RETURN: + if (!IsKeyPressed(VK_LCONTROL) && !IsKeyPressed(VK_RCONTROL)) { + ForwardCompletion(KEditEnter); + return; + } + break; + case VK_TAB: + ForwardCompletion(IsKeyPressed(VK_SHIFT) ? KEditShiftTab : KEditTab); + return; + case VK_ESCAPE: + ForwardCompletion(KEditAborted); + return; + } + m_suppressChar = 0; + SetMsgHandled(FALSE); + } + + void ForwardCompletion(t_uint32 code) { + if (IsWindowEnabled()) { + CWindow owner = GetParent(); + owner.SendMessage(MSG_DISABLE_EDITING); + owner.PostMessage(MSG_COMPLETION, code, 0); + EnableWindow(FALSE); + } + } + + const uint32_t m_flags; + bool m_selfDestruct = false; + UINT m_suppressChar = 0; + }; + + class InPlaceEditContainer : public CWindowImpl { + public: + DECLARE_WND_CLASS_EX(_T("{54340C80-248C-4b8e-8CD4-D624A8E9377B}"), 0, -1); + + + HWND Create(CWindow parent) { + + RECT rect_cropped; + { + RECT client; + WIN32_OP_D(parent.GetClientRect(&client)); + IntersectRect(&rect_cropped, &client, &m_initRect); + } + const DWORD containerStyle = WS_BORDER | WS_CHILD; + AdjustWindowRect(&rect_cropped, containerStyle, FALSE); + + + + WIN32_OP(__super::Create(parent, rect_cropped, NULL, containerStyle) != NULL); + + try { + CRect rcClient; + WIN32_OP_D(GetClientRect(rcClient)); + + + DWORD style = WS_CHILD | WS_VISIBLE;//parent is invisible now + if (m_flags & KFlagMultiLine) style |= WS_VSCROLL | ES_MULTILINE; + else style |= ES_AUTOHSCROLL; + if (m_flags & KFlagReadOnly) style |= ES_READONLY; + if (m_flags & KFlagAlignCenter) style |= ES_CENTER; + else if (m_flags & KFlagAlignRight) style |= ES_RIGHT; + else style |= ES_LEFT; + + // ES_NUMBER is buggy in many ways (repaint glitches after balloon popup) and does not allow signed numbers. + // We implement number handling by filtering WM_CHAR instead. + // if (m_flags & KFlagNumber) style |= ES_NUMBER; + + + CEdit edit; + + WIN32_OP(edit.Create(*this, rcClient, NULL, style, 0, ID_MYEDIT) != NULL); + edit.SetFont(parent.GetFont()); + + if ((m_flags & KFlagDark) != 0) DarkMode::DarkenEditLite(edit); + + if (m_ACData.is_valid()) InitializeSimpleAC(edit, m_ACData.get_ptr(), m_ACOpts); + m_edit.SubclassWindow(edit); + m_edit.OnCreation(); + + pfc::setWindowText(m_edit, *m_content); + m_edit.SetSelAll(); + } catch (...) { + PostMessage(MSG_COMPLETION, InPlaceEdit::KEditAborted, 0); + return m_hWnd; + } + + ShowWindow(SW_SHOW); + m_edit.SetFocus(); + + m_initialized = true; + + PFC_ASSERT(m_hWnd != NULL); + + return m_hWnd; + } + + InPlaceEditContainer(const RECT & p_rect, t_uint32 p_flags, pfc::rcptr_t p_content, reply_t p_notify, IUnknown * ACData, DWORD ACOpts) + : m_content(p_content), m_notify(p_notify), m_initRect(p_rect), + m_flags(p_flags), m_ACData(ACData), m_ACOpts(ACOpts), + m_edit(p_flags) + { + } + + enum { ID_MYEDIT = 666 }; + + BEGIN_MSG_MAP_EX(InPlaceEditContainer) + MESSAGE_HANDLER_EX(WM_CTLCOLOREDIT, MsgForwardToParent) + MESSAGE_HANDLER_EX(WM_CTLCOLORSTATIC, MsgForwardToParent) + MESSAGE_HANDLER_EX(WM_MOUSEWHEEL, MsgLostFocus) + MESSAGE_HANDLER_EX(WM_MOUSEHWHEEL, MsgLostFocus) + MESSAGE_HANDLER_SIMPLE(MSG_DISABLE_EDITING, OnMsgDisableEditing) + MESSAGE_HANDLER_EX(MSG_COMPLETION, OnMsgCompletion) + COMMAND_HANDLER_EX(ID_MYEDIT, EN_CHANGE, OnEditChange) + MSG_WM_DESTROY(OnDestroy) + END_MSG_MAP() + + HWND GetEditBox() const { return m_edit; } + + private: + void OnDestroy() { m_selfDestruct = true; } + + LRESULT MsgForwardToParent(UINT msg, WPARAM wParam, LPARAM lParam) { + return GetParent().SendMessage(msg, wParam, lParam); + } + LRESULT MsgLostFocus(UINT, WPARAM, LPARAM) { + PostMessage(MSG_COMPLETION, InPlaceEdit::KEditLostFocus, 0); + return 0; + } + void OnMsgDisableEditing() { + ShowWindow(SW_HIDE); + GetParent().UpdateWindow(); + m_disable_editing = true; + } + LRESULT OnMsgCompletion(UINT, WPARAM wParam, LPARAM) { + PFC_ASSERT(m_initialized); + if ((wParam & KEditMaskReason) != KEditLostFocus) { + GetParent().SetFocus(); + } + if ( m_changed && m_edit != NULL ) { + *m_content = pfc::getWindowText(m_edit); + } + OnCompletion((unsigned)wParam); + if (!m_selfDestruct) { + m_selfDestruct = true; + DestroyWindow(); + } + return 0; + } + void OnEditChange(UINT, int, CWindow source) { + if (m_initialized && !m_disable_editing) { + *m_content = pfc::getWindowText(source); + m_changed = true; + } + } + + private: + + void OnCompletion(unsigned p_status) { + if (!m_completed) { + m_completed = true; + p_status &= KEditMaskReason; + unsigned code = p_status; + if (m_changed && p_status != KEditAborted) code |= KEditFlagContentChanged; + if (m_notify) m_notify(code); + } + } + + const pfc::rcptr_t m_content; + const reply_t m_notify; + bool m_completed = false; + bool m_initialized = false, m_changed = false; + bool m_disable_editing = false; + bool m_selfDestruct = false; + const CRect m_initRect; + const t_uint32 m_flags; + CInPlaceEditBox m_edit; + + const pfc::com_ptr_t m_ACData; + const DWORD m_ACOpts; + }; + +} + +static void fail(reply_t p_notify) { + p_notify(KEditAborted); + // completion_notify::g_signal_completion_async(p_notify, KEditAborted); +} + +HWND InPlaceEdit::Start(HWND p_parentwnd, const RECT & p_rect, bool p_multiline, pfc::rcptr_t p_content, reply_t p_notify) { + return StartEx(p_parentwnd, p_rect, p_multiline ? KFlagMultiLine : 0, p_content, p_notify); +} + +void InPlaceEdit::Start_FromListView(HWND p_listview, unsigned p_item, unsigned p_subitem, unsigned p_linecount, pfc::rcptr_t p_content, reply_t p_notify) { + Start_FromListViewEx(p_listview, p_item, p_subitem, p_linecount, 0, p_content, p_notify); +} + +bool InPlaceEdit::TableEditAdvance_ListView(HWND p_listview, unsigned p_column_base, unsigned & p_item, unsigned & p_column, unsigned p_item_count, unsigned p_column_count, unsigned p_whathappened) { + if (p_column >= p_column_count) return false; + + + pfc::array_t orderRev; + { + pfc::array_t order; + const unsigned orderExCount = /*p_column_base + p_column_count*/ ListView_GetColumnCount(p_listview); + PFC_ASSERT(orderExCount >= p_column_base + p_column_count); + pfc::array_t orderEx; orderEx.set_size(orderExCount); + if (!ListView_GetColumnOrderArray(p_listview, orderExCount, orderEx.get_ptr())) { + PFC_ASSERT(!"Should not get here - probably mis-calculated column count"); + return false; + } + order.set_size(p_column_count); + for (unsigned walk = 0; walk < p_column_count; ++walk) order[walk] = orderEx[p_column_base + walk]; + + orderRev.set_size(p_column_count); order_helper::g_fill(orderRev); + pfc::sort_get_permutation_t(order, pfc::compare_t, p_column_count, orderRev.get_ptr()); + } + + unsigned columnVisible = (unsigned)orderRev[p_column]; + + + if (!TableEditAdvance(p_item, columnVisible, p_item_count, p_column_count, p_whathappened)) return false; + + p_column = (unsigned)order_helper::g_find_reverse(orderRev.get_ptr(), columnVisible); + + return true; +} + +bool InPlaceEdit::TableEditAdvance(unsigned & p_item, unsigned & p_column, unsigned p_item_count, unsigned p_column_count, unsigned p_whathappened) { + if (p_item >= p_item_count || p_column >= p_column_count) return false; + int delta = 0; + + switch (p_whathappened & KEditMaskReason) { + case KEditEnter: + delta = (int)p_column_count; + break; + case KEditTab: + delta = 1; + break; + case KEditShiftTab: + delta = -1; + break; + default: + return false; + } + while (delta > 0) { + p_column++; + if (p_column >= p_column_count) { + p_column = 0; + p_item++; + if (p_item >= p_item_count) return false; + } + delta--; + } + while (delta < 0) { + if (p_column == 0) { + if (p_item == 0) return false; + p_item--; + p_column = p_column_count; + } + p_column--; + delta++; + } + return true; +} + +HWND InPlaceEdit::StartEx(HWND p_parentwnd, const RECT & p_rect, unsigned p_flags, pfc::rcptr_t p_content, reply_t p_notify, IUnknown * ACData, DWORD ACOpts) { + try { + PFC_ASSERT((CWindow(p_parentwnd).GetWindowLong(GWL_STYLE) & WS_CLIPCHILDREN) != 0); + return (new CWindowCreateAndDelete(p_parentwnd, p_rect, p_flags, p_content, p_notify, ACData, ACOpts))->GetEditBox(); + } catch (...) { + fail(p_notify); + return NULL; + } +} + +void InPlaceEdit::Start_FromListViewEx(HWND p_listview, unsigned p_item, unsigned p_subitem, unsigned p_linecount, unsigned p_flags, pfc::rcptr_t p_content, reply_t p_notify) { + try { + ListView_EnsureVisible(p_listview, p_item, FALSE); + RECT itemrect; + WIN32_OP_D(ListView_GetSubItemRect(p_listview, p_item, p_subitem, LVIR_LABEL, &itemrect)); + + const bool multiline = p_linecount > 1; + if (multiline) { + itemrect.bottom = itemrect.top + (itemrect.bottom - itemrect.top) * p_linecount; + } + + StartEx(p_listview, itemrect, p_flags | (multiline ? KFlagMultiLine : 0), p_content, p_notify); + } catch (...) { + fail(p_notify); + } +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/InPlaceEdit.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/InPlaceEdit.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,45 @@ +#pragma once + +#include + +namespace InPlaceEdit { + + enum { + KEditAborted = 0, + KEditTab, + KEditShiftTab, + KEditEnter, + KEditLostFocus, + + KEditMaskReason = 0xFF, + KEditFlagContentChanged = 0x100, + + KFlagReadOnly = 1 << 0, + KFlagMultiLine = 1 << 1, + KFlagAlignCenter = 1 << 2, + KFlagAlignRight = 1 << 3, + KFlagNumber = 1 << 4, + KFlagNumberSigned = 1 << 5, + + KFlagCombo = 1 << 8, // FOR INTERNAL USE + KFlagDark = 1 << 9 + }; + + typedef std::function< void (unsigned) > reply_t; + + typedef std::function< void(unsigned, unsigned) > comboReply_t; // status, index (UINT_MAX if n/a) + + HWND Start(HWND p_parentwnd, const RECT & p_rect, bool p_multiline, pfc::rcptr_t p_content, reply_t p_notify); + + HWND StartEx(HWND p_parentwnd, const RECT & p_rect, unsigned p_flags, pfc::rcptr_t p_content, reply_t p_notify, IUnknown * ACData = NULL, DWORD ACOpts = 0); + + + HWND StartCombo(HWND p_parentwnd, const RECT & p_rect, unsigned p_flags, pfc::string_list_const & data, unsigned iDefault, comboReply_t p_notify); + + void Start_FromListView(HWND p_listview, unsigned p_item, unsigned p_subitem, unsigned p_linecount, pfc::rcptr_t p_content, reply_t p_notify); + void Start_FromListViewEx(HWND p_listview, unsigned p_item, unsigned p_subitem, unsigned p_linecount, unsigned p_flags, pfc::rcptr_t p_content, reply_t p_notify); + + bool TableEditAdvance(unsigned & p_item, unsigned & p_column, unsigned p_item_count, unsigned p_column_count, unsigned p_whathappened); + bool TableEditAdvance_ListView(HWND p_listview, unsigned p_column_base, unsigned & p_item, unsigned & p_column, unsigned p_item_count, unsigned p_column_count, unsigned p_whathappened); + +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/InPlaceEditTable.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/InPlaceEditTable.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,228 @@ +#include "stdafx.h" +#include "InPlaceEditTable.h" + +#include "win32_op.h" +#include "win32_utility.h" +#include "AutoComplete.h" + +#include "listview_helper.h" + +namespace InPlaceEdit { + + bool CTableEditHelperV2::tableEdit_cancel_task() { + bool rv = false; + if (m_taskKill) { + *m_taskKill = true; m_taskKill = nullptr; + rv = true; + } + return rv; + } + reply_t CTableEditHelperV2::tableEdit_create_task() { + tableEdit_cancel_task(); + auto ks = std::make_shared(false); + m_taskKill = ks; + return [ks,this](unsigned code) { + if ( ! * ks ) { + this->tableEdit_on_task_completion( code ); + } + }; + } + t_size CTableEditHelperV2::ColumnToPosition(t_size col) const { + PFC_ASSERT(TableEdit_IsColumnEditable(col)); + pfc::array_t colOrder; GrabColumnOrder(colOrder); + t_size skipped = 0; + for (t_size walk = 0; walk < colOrder.get_size(); ++walk) { + const t_size curCol = colOrder[walk]; + if (TableEdit_IsColumnEditable(curCol)) { + if (curCol == col) return skipped; + ++skipped; + } + } + PFC_ASSERT(!"Should not get here."); + return SIZE_MAX; + } + t_size CTableEditHelperV2::PositionToColumn(t_size pos) const { + pfc::array_t colOrder; GrabColumnOrder(colOrder); + t_size skipped = 0; + for (t_size walk = 0; walk < colOrder.get_size(); ++walk) { + const t_size curCol = colOrder[walk]; + if (TableEdit_IsColumnEditable(curCol)) { + if (skipped == pos) return curCol; + ++skipped; + } + } + PFC_ASSERT(!"Should not get here."); + return SIZE_MAX; + } + t_size CTableEditHelperV2::EditableColumnCount() const { + const t_size total = TableEdit_GetColumnCount(); + t_size found = 0; + for (t_size walk = 0; walk < total; ++walk) { + if (TableEdit_IsColumnEditable(walk)) found++; + } + return found; + } + + bool CTableEditHelperV2::TableEdit_Advance(t_size & p_item, t_size & p_subItem, t_uint32 whathappened) { + size_t guardItem = SIZE_MAX, guardSubItem = SIZE_MAX; // infinite loop guard + size_t item = p_item, subItem = p_subItem; + for ( ;; ) { + unsigned _item((unsigned)item), _subItem((unsigned)ColumnToPosition(subItem)); + if (!InPlaceEdit::TableEditAdvance(_item, _subItem, (unsigned)TableEdit_GetItemCount(), (unsigned)EditableColumnCount(), whathappened)) return false; + item = _item; subItem = PositionToColumn(_subItem); + + if ( guardItem == SIZE_MAX ) { + guardItem = item; guardSubItem = subItem; + } else { + // infinite loop guard + if ( item == guardItem && subItem == guardSubItem ) return false; + } + + if (TableEdit_CanAdvanceHere(item, subItem, whathappened)) break; + } + p_item = item; + p_subItem = subItem; + return true; + } + + void CTableEditHelperV2::TableEdit_Abort(bool forwardContent) { + if (tableEdit_cancel_task()) { + if (forwardContent && (m_editFlags & KFlagReadOnly) == 0) { + if (m_editData.is_valid()) { + pfc::string8 temp(*m_editData); + TableEdit_SetField(m_editItem, m_editSubItem, temp); + } + } + m_editData.release(); + m_editDataCombo.reset(); + ::SetFocus(TableEdit_GetParentWnd()); + TableEdit_Finished(); + } + + } + + HWND CTableEditHelperV2::TableEdit_Start(t_size item, t_size subItem) { + PFC_ASSERT(TableEdit_IsColumnEditable(subItem)); + m_editItem = item; m_editSubItem = subItem; + return _ReStart(); + } + + HWND CTableEditHelperV2::_ReStart() { + PFC_ASSERT(m_editItem < TableEdit_GetItemCount()); + PFC_ASSERT(m_editSubItem < TableEdit_GetColumnCount()); + + TableEdit_SetItemFocus(m_editItem, m_editSubItem); + + m_editFlags = TableEdit_GetEditFlags(m_editItem, m_editSubItem); + + if (this->TableEdit_GetDarkMode()) m_editFlags |= KFlagDark; + + m_editData.release(); + m_editDataCombo.reset(); + + if (m_editFlags & InPlaceEdit::KFlagCombo) { + auto combo = TableEdit_GetCombo(m_editItem, m_editSubItem); + RECT rc = TableEdit_GetItemRect(m_editItem, m_editSubItem); + + auto data = std::make_shared< combo_t >(combo); + m_editDataCombo = data; + + auto task = tableEdit_create_task(); + auto comboTask = [data, task](unsigned status, unsigned sel) { + data->iDefault = sel; + task(status); + }; + + return InPlaceEdit::StartCombo(TableEdit_GetParentWnd(), rc, m_editFlags, combo.strings, combo.iDefault, comboTask ); + } + + m_editData.new_t(); + t_size lineCount = 1; + TableEdit_GetField(m_editItem, m_editSubItem, *m_editData, lineCount); + + RECT rc = TableEdit_GetItemRect(m_editItem, m_editSubItem); + if (lineCount > 1) { + rc.bottom = (LONG)( rc.top + (rc.bottom - rc.top) * lineCount ); + m_editFlags |= KFlagMultiLine; + } + auto ac = this->TableEdit_GetAutoCompleteEx(m_editItem, m_editSubItem ); + return InPlaceEdit::StartEx(TableEdit_GetParentWnd(), rc, m_editFlags, m_editData, tableEdit_create_task(), ac.data.get_ptr(), ac.options); + } + + CTableEditHelperV2::combo_t CTableEditHelperV2::TableEdit_GetCombo(size_t, size_t) { + return combo_t(); + } + CTableEditHelperV2::autoComplete_t CTableEditHelperV2::TableEdit_GetAutoCompleteEx( size_t item, size_t sub ) { + autoComplete_t ret; + if ( this->TableEdit_GetAutoComplete( item, sub, ret.data ) ) ret.options = ret.optsDefault; + return ret; + } + + void CTableEditHelperV2::tableEdit_on_task_completion(unsigned status) { + tableEdit_cancel_task(); + if (m_editData.is_valid()) { + if (status & InPlaceEdit::KEditFlagContentChanged) { + TableEdit_SetField(m_editItem, m_editSubItem, *m_editData); + } + m_editData.release(); + } + if (m_editDataCombo != nullptr) { + unsigned idx = m_editDataCombo->iDefault; + if ( idx < m_editDataCombo->strings.get_count()) { + const char * text = m_editDataCombo->strings.get_item(idx); + TableEdit_SetField(m_editItem, m_editSubItem, text); + } + + m_editDataCombo.reset(); + } + + if (TableEdit_Advance(m_editItem, m_editSubItem, status)) { + _ReStart(); + } else { + TableEdit_Finished(); + } + } + + + + + + void CTableEditHelperV2_ListView::TableEdit_GetColumnOrder(t_size * out, t_size count) const { + pfc::array_t temp; temp.set_size(count); + WIN32_OP_D(ListView_GetColumnOrderArray(TableEdit_GetParentWnd(), count, temp.get_ptr())); + for (t_size walk = 0; walk < count; ++walk) out[walk] = temp[walk]; + } + + RECT CTableEditHelperV2_ListView::TableEdit_GetItemRect(t_size item, t_size subItem) const { + RECT rc; + WIN32_OP_D(ListView_GetSubItemRect(TableEdit_GetParentWnd(), (int)item, (int)subItem, LVIR_LABEL, &rc)); + return rc; + } + + void CTableEditHelperV2_ListView::TableEdit_GetField(t_size item, t_size subItem, pfc::string_base & out, t_size & lineCount) { + listview_helper::get_item_text(TableEdit_GetParentWnd(), (int)item, (int)subItem, out); + lineCount = pfc::is_multiline(out) ? 5 : 1; + } + void CTableEditHelperV2_ListView::TableEdit_SetField(t_size item, t_size subItem, const char * value) { + WIN32_OP_D(listview_helper::set_item_text(TableEdit_GetParentWnd(), (int)item, (int)subItem, value)); + +#if PFC_DEBUG + pfc::string8 meh; + listview_helper::get_item_text(TableEdit_GetParentWnd(), (int)item, (int)subItem, meh); + PFC_ASSERT(meh == value); +#endif + } + t_size CTableEditHelperV2_ListView::TableEdit_GetItemCount() const { + LRESULT temp; + WIN32_OP_D((temp = ListView_GetItemCount(TableEdit_GetParentWnd())) >= 0); + return (t_size)temp; + } + void CTableEditHelperV2_ListView::TableEdit_SetItemFocus(t_size item, t_size) { + WIN32_OP_D(listview_helper::select_single_item(TableEdit_GetParentWnd(), (int) item)); + } + + t_size CTableEditHelperV2_ListView::TableEdit_GetColumnCount() const { + return (t_size)ListView_GetColumnCount(TableEdit_GetParentWnd()); + } + +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/InPlaceEditTable.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/InPlaceEditTable.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,88 @@ +#pragma once + +#include +#include "InPlaceEdit.h" + +namespace InPlaceEdit { + class NOVTABLE CTableEditHelperV2 { + public: + virtual RECT TableEdit_GetItemRect(t_size item, t_size subItem) const = 0; + virtual void TableEdit_GetField(t_size item, t_size subItem, pfc::string_base & out, t_size & lineCount) = 0; + virtual void TableEdit_SetField(t_size item, t_size subItem, const char * value) = 0; + virtual HWND TableEdit_GetParentWnd() const = 0; + virtual bool TableEdit_Advance(t_size & item, t_size & subItem, t_uint32 whathappened); + virtual bool TableEdit_CanAdvanceHere(size_t item, size_t subItem, uint32_t whatHappened) const { (void)item; (void)subItem; (void)whatHappened; return true; } + virtual void TableEdit_Finished() {} + virtual t_size TableEdit_GetItemCount() const = 0; + virtual t_size TableEdit_GetColumnCount() const = 0; + virtual void TableEdit_SetItemFocus(t_size item, t_size subItem) = 0; + virtual bool TableEdit_IsColumnEditable(t_size subItem) const { (void)subItem; return true; } + virtual void TableEdit_GetColumnOrder(t_size * out, t_size count) const { order_helper::g_fill(out, count); } + virtual t_uint32 TableEdit_GetEditFlags(t_size item, t_size subItem) const { (void)item; (void)subItem; return 0; } + virtual bool TableEdit_GetDarkMode() const { return false; } + virtual bool TableEdit_GetAutoComplete(t_size item, t_size subItem, pfc::com_ptr_t& out) { (void)item; (void)subItem; (void)out; return false; } + + struct autoComplete_t { + pfc::com_ptr_t data; + enum { // ACO_* equivalents + optsNone = 0, + optsDefault = 1, + optsAutoSuggest = 1, + optsAutoAppend = 3, + }; + DWORD options = optsNone; + }; + virtual autoComplete_t TableEdit_GetAutoCompleteEx( size_t item, size_t sub ); + + struct combo_t { + unsigned iDefault = 0; + pfc::string_list_impl strings; + }; + + virtual combo_t TableEdit_GetCombo(size_t item, size_t sub); + + HWND TableEdit_Start(t_size item, t_size subItem); + void TableEdit_Abort(bool forwardContent); + bool TableEdit_IsActive() const { return !!m_taskKill; } + protected: + ~CTableEditHelperV2() { tableEdit_cancel_task(); } + CTableEditHelperV2() {} + private: + void tableEdit_on_task_completion(unsigned p_status); + reply_t tableEdit_create_task(); + bool tableEdit_cancel_task(); + + t_size ColumnToPosition(t_size col) const; + t_size PositionToColumn(t_size pos) const; + t_size EditableColumnCount() const; + void GrabColumnOrder(pfc::array_t & buffer) const { buffer.set_size(TableEdit_GetColumnCount()); TableEdit_GetColumnOrder(buffer.get_ptr(), buffer.get_size()); } + HWND _ReStart(); + + t_size m_editItem = SIZE_MAX, m_editSubItem = SIZE_MAX; + t_uint32 m_editFlags = 0; + pfc::rcptr_t m_editData; + std::shared_ptr< combo_t > m_editDataCombo; + + std::shared_ptr m_taskKill; + + CTableEditHelperV2( const CTableEditHelperV2 & ) = delete; + void operator=( const CTableEditHelperV2 & ) = delete; + }; + + + + + class NOVTABLE CTableEditHelperV2_ListView : public CTableEditHelperV2 { + public: + RECT TableEdit_GetItemRect(t_size item, t_size subItem) const override; + void TableEdit_GetField(t_size item, t_size subItem, pfc::string_base & out, t_size & lineCount) override; + void TableEdit_SetField(t_size item, t_size subItem, const char * value) override; + + t_size TableEdit_GetColumnCount() const override; + + t_size TableEdit_GetItemCount() const override; + void TableEdit_SetItemFocus(t_size item, t_size subItem) override; + + void TableEdit_GetColumnOrder(t_size * out, t_size count) const override; + }; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/PaintUtils.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/PaintUtils.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,523 @@ +#include "stdafx.h" +#include + +#include "PaintUtils.h" +#include "gdiplus_helpers.h" + +#include "GDIUtils.h" +#include "win32_op.h" +#include "wtl-pp.h" + +namespace PaintUtils { + static t_uint16 extractChannel16(t_uint32 p_color,int p_which) throw() { + return (t_uint16)( ((p_color >> (p_which * 8)) & 0xFF) << 8 ); + } + + static t_uint8 extractbyte(t_uint32 p_val,t_size p_which) throw() { + return (t_uint8) ( (p_val >> (p_which * 8)) & 0xFF ); + } + + t_uint32 BlendColorEx(t_uint32 p_color1, t_uint32 p_color2, double mix) throw() { + PFC_ASSERT(mix >= 0 && mix <= 1); + t_uint32 ret = 0; + for(t_size walk = 0; walk < 3; ++walk) { + int val1 = extractbyte(p_color1,walk), val2 = extractbyte(p_color2,walk); + int val = val1 + pfc::rint32((val2 - val1) * mix); + ret |= (t_uint32)val << (walk * 8); + } + return ret; + } + t_uint32 BlendColor(t_uint32 p_color1, t_uint32 p_color2, int p_percentage) throw() { + PFC_ASSERT(p_percentage <= 100); + t_uint32 ret = 0; + for(t_size walk = 0; walk < 3; ++walk) { + int val1 = extractbyte(p_color1,walk), val2 = extractbyte(p_color2,walk); + int val = val1 + MulDiv(val2 - val1,p_percentage,100); + ret |= (t_uint32)val << (walk * 8); + } + return ret; + } + t_uint32 DriftColor(t_uint32 p_color,unsigned p_delta,bool p_direction) throw() { + t_uint32 ret = 0; + for(t_size walk = 0; walk < 3; ++walk) { + unsigned val = extractbyte(p_color,walk); + if (p_direction) val = 0xFF - val; + if (val < p_delta) val = p_delta; + val += p_delta; + if (val > 0xFF) val = 0xFF; + if (p_direction) val = 0xFF - val; + ret |= (t_uint32)val << (walk * 8); + } + return ret; + } + + void FillVertexColor(TRIVERTEX & p_vertex,t_uint32 p_color,t_uint16 p_alpha) throw() { + p_vertex.Red = extractChannel16(p_color,0); + p_vertex.Green = extractChannel16(p_color,1); + p_vertex.Blue = extractChannel16(p_color,2); + p_vertex.Alpha = p_alpha; + } + + void FillRectSimple(CDCHandle p_dc,const CRect & p_rect,t_uint32 p_color) throw() { + p_dc.FillSolidRect(p_rect, p_color); + } + + void GradientFillRect(CDCHandle p_dc,const CRect & p_rect,t_uint32 p_color1, t_uint32 p_color2, bool p_horizontal) throw() { + TRIVERTEX verticies[2]; + GRADIENT_RECT element = {0,1}; + FillVertexColor(verticies[0],p_color1); + FillVertexColor(verticies[1],p_color2); + verticies[0].x = p_rect.left; verticies[0].y = p_rect.top; + verticies[1].x = p_rect.right; verticies[1].y = p_rect.bottom; + p_dc.GradientFill(verticies,tabsize(verticies),&element,1,p_horizontal ? GRADIENT_FILL_RECT_H : GRADIENT_FILL_RECT_V); + } + + void GradientSplitRect(CDCHandle p_dc,const CRect & p_rect,t_uint32 p_bkColor, t_uint32 p_gradientColor,int p_splitPercent) throw() { + const long split = p_rect.top + MulDiv(p_rect.Height(),p_splitPercent,100); + CRect rcTemp; + rcTemp = p_rect; + rcTemp.bottom = split; + GradientFillRect(p_dc,rcTemp,p_bkColor,p_gradientColor,false); + rcTemp = p_rect; + rcTemp.top = split; + GradientFillRect(p_dc,rcTemp,p_gradientColor,p_bkColor,false); + } + + void GradientBar(CDCHandle p_dc,const CRect & p_rect,t_uint32 p_exterior, t_uint32 p_interior, int p_percentage) throw() { + const int gradientPix = MulDiv(p_rect.Height(),p_percentage,100); + CRect rcTemp; + + rcTemp = p_rect; + rcTemp.bottom = rcTemp.top + gradientPix; + GradientFillRect(p_dc,rcTemp,p_exterior,p_interior,false); + + rcTemp = p_rect; + rcTemp.top += gradientPix; rcTemp.bottom -= gradientPix; + FillRectSimple(p_dc,rcTemp,p_interior); + + rcTemp = p_rect; + rcTemp.top = rcTemp.bottom - gradientPix; + GradientFillRect(p_dc,rcTemp,p_interior,p_exterior,false); + } + + void RenderItemBackground(CDCHandle p_dc,const CRect & p_itemRect,t_size p_item,t_uint32 p_color) throw() { + const DWORD bkColor_base = p_color; + const DWORD bkColor = DriftColor(bkColor_base,3, (p_item&1) != 0); + + //GradientSplitRect(p_dc,p_itemRect,bkColor,BlendColor(bkColor,textColor,7),80); + GradientBar(p_dc,p_itemRect,bkColor_base,bkColor,10); + } + + double Luminance(t_uint32 color) throw() { + double r = extractbyte(color,0), g = extractbyte(color,1), b = extractbyte(color,2); + return (0.2126 * r + 0.7152 * g + 0.0722 * b) / 255.0; + //return (r * 0.3 + g * 0.59 + b * 0.11) / 255.0; + } + t_uint32 DetermineTextColor(t_uint32 bk) throw() { + double l = Luminance(bk); + if ( l > 0.6 ) { + return 0; // black + } else { + return 0xFFFFFF; // white + } + } + + void AddRectToRgn(HRGN p_rgn,CRect const & p_rect) throw() { + CRgn temp; + WIN32_OP_D( temp.CreateRectRgnIndirect(p_rect) != NULL ); + CRgnHandle(p_rgn).CombineRgn(temp,RGN_OR); + } + + void FocusRect2(CDCHandle dc, CRect const & rect, COLORREF bkColor) throw() { + COLORREF txColor = DetermineTextColor( bkColor ); + COLORREF useColor = BlendColor(bkColor, txColor, 50); + CDCBrush brush(dc, useColor); + WIN32_OP_D( dc.FrameRect(rect,brush) ); + } + void FocusRect(CDCHandle dc, CRect const & rect) throw() { + CDCBrush brush(dc, 0x7F7F7F); + WIN32_OP_D( dc.FrameRect(rect,brush) ); + //dc.DrawFocusRect(rect); + } + + namespace TrackBar { + void DrawThumb(HTHEME theme,HDC dc,int state,const RECT * rcThumb, const RECT * rcUpdate) { + if (theme == NULL) { + RECT blah = *rcThumb; + int flags = DFCS_BUTTONPUSH; + switch(state) { + case TUS_NORMAL: + break; + case TUS_DISABLED: + flags |= DFCS_INACTIVE; + break; + case TUS_PRESSED: + flags |= DFCS_PUSHED; + break; + } + DrawFrameControl(dc,&blah,DFC_BUTTON,flags); + } else { + DrawThemeBackground(theme,dc,TKP_THUMB,state,rcThumb,rcUpdate); + } + } + void DrawTrack(HTHEME theme,HDC dc,const RECT * rcTrack, const RECT * rcUpdate) { + if (theme == NULL) { + RECT blah = *rcTrack; + DrawFrameControl(dc,&blah,DFC_BUTTON,DFCS_BUTTONPUSH|DFCS_PUSHED); + } else { + DrawThemeBackground(theme,dc,TKP_TRACK,TKS_NORMAL,rcTrack,rcUpdate); + } + } + void DrawTrack2(HDC p_dc, const CRect& rcTrack, const CRect& rcUpdate, COLORREF clrHighlight, COLORREF clrShadow) { + CRect rc(*rcTrack); +#if 1 + CDCHandle dc(p_dc); + SelectObjectScope scope(dc, GetStockObject(DC_PEN)); + dc.SetDCPenColor(clrHighlight); + dc.MoveTo(rc.left, rc.bottom); + dc.LineTo(rc.right, rc.bottom); + dc.LineTo(rc.right, rc.top); + dc.SetDCPenColor(clrShadow); + dc.LineTo(rc.left, rc.top); + dc.LineTo(rc.left, rc.bottom); +#else + try { + Gdiplus::Point points[] = { Gdiplus::Point(rc.left, rc.bottom), Gdiplus::Point(rc.right, rc.bottom), Gdiplus::Point(rc.right, rc.top), Gdiplus::Point(rc.left, rc.top)}; + GdiplusErrorHandler eh; + Gdiplus::Graphics graphics(p_dc); + eh << graphics.GetLastStatus(); + Gdiplus::Color c; + c.SetFromCOLORREF(clrHighlight); + Gdiplus::Pen penHL(c); + c.SetFromCOLORREF(clrShadow); + Gdiplus::Pen penSH(c); + eh << graphics.SetSmoothingMode(Gdiplus::SmoothingModeHighQuality); + eh << graphics.DrawLine(&penHL, points[0], points[1]); + eh << graphics.DrawLine(&penHL, points[1], points[2]); + eh << graphics.DrawLine(&penSH, points[2], points[3]); + eh << graphics.DrawLine(&penSH, points[3], points[0]); + } catch (std::exception const& e) { + (void)e; + PFC_ASSERT(!"???"); + // console::print(e.what()); + } +#endif + } + void DrawTrackVolume2(HDC p_dc, const CRect& rcTrack, const CRect& rcUpdate, COLORREF clrHighlight, COLORREF clrShadow) { + CRect rc(rcTrack); + + try { + Gdiplus::Point points[] = { Gdiplus::Point(rc.left, rc.bottom), Gdiplus::Point(rc.right, rc.bottom), Gdiplus::Point(rc.right, rc.top) }; + GdiplusErrorHandler eh; + Gdiplus::Graphics graphics(p_dc); + eh << graphics.GetLastStatus(); + Gdiplus::Color c; + c.SetFromCOLORREF(clrHighlight); + Gdiplus::Pen penHL(c); + c.SetFromCOLORREF(clrShadow); + Gdiplus::Pen penSH(c); + eh << graphics.SetSmoothingMode(Gdiplus::SmoothingModeHighQuality); + //graphics.DrawPolygon(&pen,points,tabsize(points)); + eh << graphics.DrawLine(&penSH, points[0], points[0] + Gdiplus::Point(0, -1)); + eh << graphics.DrawLine(&penHL, points[0], points[1]); + eh << graphics.DrawLine(&penHL, points[1], points[2]); + eh << graphics.DrawLine(&penSH, points[2], points[0] + Gdiplus::Point(0, -1)); + } catch (std::exception const& e) { + (void)e; + PFC_ASSERT(!"???"); + // console::print(e.what()); + } + } + void DrawTrackVolume(HTHEME theme,HDC p_dc,const CRect & rcTrack, const CRect & rcUpdate) { + (void)theme; // disregarded + DrawTrackVolume2(p_dc, rcTrack, rcUpdate, GetSysColor(COLOR_BTNHIGHLIGHT), GetSysColor(COLOR_BTNSHADOW)); + } + } + + void DrawSmoothedLine(HDC dc, CPoint pt1, CPoint pt2, COLORREF col, double width) { + try { + Gdiplus::Point points[] = { Gdiplus::Point(pt1.x,pt1.y), Gdiplus::Point(pt2.x,pt2.y) }; + GdiplusErrorHandler eh; + Gdiplus::Graphics graphics(dc); + eh << graphics.GetLastStatus(); + Gdiplus::Color c; + c.SetFromCOLORREF( col ); + Gdiplus::Pen pen(c, (Gdiplus::REAL)( width )); + eh << graphics.SetSmoothingMode(Gdiplus::SmoothingModeHighQuality); + //graphics.DrawPolygon(&pen,points,tabsize(points)); + eh << graphics.DrawLine(&pen, points[0], points[1]); + } catch(std::exception const & e) { + (void) e; + PFC_ASSERT(!"???"); + // console::print(e.what()); + } + } + + + + static int get_text_width(HDC dc,const TCHAR * src,int len) { + if (len<=0) return 0; + else { + SIZE goatse; + GetTextExtentPoint32(dc,src,len,&goatse); + return goatse.cx; + } + } + + static t_uint32 TextOutColors_TranslateColor(const t_uint32 colors[3], int offset) { + const double v = (double)offset / 3.0; + if (v <= -1) return colors[0]; + else if (v < 0) return BlendColorEx(colors[0], colors[1], v + 1); + else if (v == 0) return colors[1]; + else if (v < 1) return BlendColorEx(colors[1], colors[2], v); + else return colors[2]; + } + + void TextOutColors_StripCodesAppend(pfc::string_formatter & out, const char * in) { + t_size done = 0, walk = 0; + for(;;) { + if (in[walk] == 0) { + if (walk > done) out.add_string_nc(in + done, walk - done); + return; + } + if ((unsigned)in[walk] < 32) { + if (walk > done) {out.add_string_nc(in + done, walk - done);} + done = walk + 1; + } + ++walk; + } + } + void TextOutColors_StripCodes(pfc::string_formatter & out, const char * in) { + out.reset(); TextOutColors_StripCodesAppend(out, in); + } + + static bool IsControlChar(TCHAR c) { + return (unsigned)c < 32; + } + static int MatchTruncat(HDC dc, int & pixels, const TCHAR * text, int textLen) { + int min = 0, max = textLen; + int minWidth = 0; + while(min + 1 < max) { + const int probe = (min + max) / 2; + CSize size; + WIN32_OP( GetTextExtentPoint32(dc, text, probe, &size) ); + if (size.cx <= pixels) {min = probe; minWidth = size.cx;} + else max = probe; + } + pixels = minWidth; + return min; + } + static int TruncatHeadroom(HDC dc) { + CSize size; + WIN32_OP( GetTextExtentPoint32(dc, _T("\x2026"), 1, &size) ); + return size.cx; + } + static void ExtTextOut_Truncat(HDC dc, int x, int y, CRect const & clip, const TCHAR * text, int textLen) { + int width = pfc::max_t(0, clip.right - x - TruncatHeadroom(dc)); + int truncat = MatchTruncat(dc, width, text, textLen); + WIN32_OP( ExtTextOut(dc, x, y, ETO_CLIPPED, &clip, text, truncat, NULL) ); + WIN32_OP( ExtTextOut(dc, x + width, y, ETO_CLIPPED, &clip, _T("\x2026"), 1, NULL) ); + + + } + bool TextContainsCodes(const TCHAR * src) { + for(;;) { + if (*src == 0) return false; + if ((unsigned)*src < 32) return true; + ++src; + } + } + void TextOutColorsEx(HDC dc,const TCHAR * src,const CRect & target,DWORD flags,const t_uint32 colors[3]) { + if (!TextContainsCodes(src)) { + SetTextColorScope cs(dc, colors[1]); + CRect rc(target); + CDCHandle(dc).DrawText(src,(int)_tcslen(src),rc,DT_NOPREFIX | DT_END_ELLIPSIS | DT_SINGLELINE | DT_VCENTER | flags); + } else { + const CSize textSize = PaintUtils::TextOutColors_CalcSize(dc, src); + CPoint origin = target.TopLeft(); + origin.y = (target.top + target.bottom - textSize.cy) / 2; + switch(flags & (DT_LEFT | DT_RIGHT | DT_CENTER)) { + case DT_LEFT: + break; + case DT_RIGHT: + if (textSize.cx < target.Width()) origin.x = target.right - textSize.cx; + break; + case DT_CENTER: + if (textSize.cx < target.Width()) origin.x = (target.right + target.left - textSize.cx) / 2; + break; + } + TextOutColors(dc, src, (int)_tcslen(src), origin, target, colors); + } + } + void TextOutColors(HDC dc,const TCHAR * src,int len,CPoint offset,const CRect & clip,const t_uint32 colors[3], int tabWidthTotal, int tabWidthDiv) { + SetTextAlign(dc,TA_LEFT); + SetBkMode(dc,TRANSPARENT); + + + int walk = 0; + int position = offset.x; + int colorOffset = 0; + int tabs = 0; + int positionTabDelta = 0; + + for(;;) { + int base = walk; + while(walk < len && !IsControlChar(src[walk])) ++walk; + if (walk>base) { + SetTextColor(dc,TextOutColors_TranslateColor(colors, colorOffset)); + int width = get_text_width(dc,src+base,walk-base); + if (position + width > clip.right) { + ExtTextOut_Truncat(dc, position, offset.y, clip, src + base, walk - base); + return; + } + WIN32_OP( ExtTextOut(dc,position,offset.y,ETO_CLIPPED,&clip,src+base,walk-base,0) ); + position += width; + } + if (walk>=len) break; + + while(walk < len && IsControlChar(src[walk])) { + if (src[walk] == TextOutColors_Dim) --colorOffset; + else if (src[walk] == TextOutColors_Highlight) ++colorOffset; + else if (src[walk] == '\t') { + int newDelta = MulDiv(++tabs, tabWidthTotal, tabWidthDiv); + position += newDelta - positionTabDelta; + positionTabDelta = newDelta; + } + walk++; + } + } + } + + CSize TextOutColors_CalcSize(HDC dc, const TCHAR * src) { + CSize acc(0,0); + for(int walk = 0;;) { + const int done = walk; + while(!IsControlChar(src[walk])) ++walk; + if (walk > done) { + CSize temp; + WIN32_OP( GetTextExtentPoint32(dc,src + done, walk - done, &temp) ); + acc.cx += temp.cx; pfc::max_acc(acc.cy, temp.cy); + } + if (src[walk] == 0) return acc; + while(src[walk] != 0 && IsControlChar(src[walk])) ++walk; + } + } + t_uint32 TextOutColors_CalcWidth(HDC dc, const TCHAR * src) { + t_uint32 acc = 0; + for(int walk = 0;;) { + const int done = walk; + while(!IsControlChar(src[walk])) ++walk; + acc += get_text_width(dc, src + done, walk - done); + if (src[walk] == 0) return acc; + while(src[walk] != 0 && IsControlChar(src[walk])) ++walk; + } + } + + pfc::string TextOutColors_ImportScript(pfc::string script) { + pfc::string_formatter temp; TextOutColors_ImportScript(temp, script.ptr()); return temp.get_ptr(); + } + void TextOutColors_ImportScript(pfc::string_base & out, const char * in) { + out.reset(); + for(;;) { + t_size delta; t_uint32 c; + delta = pfc::utf8_decode_char(in, c); + if (delta == 0) break; + switch(c) { + case '>': + c = PaintUtils::TextOutColors_Highlight; + break; + case '<': + c = PaintUtils::TextOutColors_Dim; + break; + } + out.add_char(c); + in += delta; + } + } + t_uint32 DrawText_TranslateHeaderAlignment(t_uint32 val) { + switch(val & HDF_JUSTIFYMASK) { + case HDF_LEFT: + default: + return DT_LEFT; + case HDF_RIGHT: + return DT_RIGHT; + case HDF_CENTER: + return DT_CENTER; + } + } + + void RenderButton(HWND wnd_, HDC dc_, CRect rcUpdate, bool bPressed) { + CDCHandle dc(dc_); CWindow wnd(wnd_); + CTheme theme; theme.OpenThemeData(wnd, L"BUTTON"); + + RelayEraseBkgnd(wnd, wnd.GetParent(), dc); + + const int part = BP_PUSHBUTTON; + + enum { + stNormal = PBS_NORMAL, + stHot = PBS_HOT, + stDisabled = PBS_DISABLED, + stPressed = PBS_PRESSED, + }; + + int state = 0; + if (!wnd.IsWindowEnabled()) state = stDisabled; + else if (bPressed) state = stPressed; + else state = stNormal; + + CRect rcClient; WIN32_OP_D( wnd.GetClientRect(rcClient) ); + + if (theme != NULL && IsThemePartDefined(theme, part, 0)) { + DrawThemeBackground(theme, dc, part, state, rcClient, &rcUpdate); + } else { + int stateEx = DFCS_BUTTONPUSH; + switch(state) { + case stPressed: stateEx |= DFCS_PUSHED; break; + case stDisabled: stateEx |= DFCS_INACTIVE; break; + } + DrawFrameControl(dc, rcClient, DFC_BUTTON, stateEx); + } + } + + + void PaintSeparatorControl(HWND wnd_) { + CWindow wnd(wnd_); + CPaintDC dc(wnd); + TCHAR buffer[512] = {}; + wnd.GetWindowText(buffer, _countof(buffer)); + const int txLen = (int) pfc::strlen_max_t(buffer, _countof(buffer)); + CRect contentRect; + WIN32_OP_D(wnd.GetClientRect(contentRect)); + + dc.SetTextColor(GetSysColor(COLOR_WINDOWTEXT)); + dc.SetBkMode(TRANSPARENT); + + { + CBrushHandle brush = (HBRUSH)wnd.GetParent().SendMessage(WM_CTLCOLORSTATIC, (WPARAM)(HDC)dc, (LPARAM)wnd.m_hWnd); + if (brush != NULL) dc.FillRect(contentRect, brush); + } + SelectObjectScope scopeFont(dc, wnd.GetFont()); + + if (txLen > 0) { + CRect rcText(contentRect); + if (!wnd.IsWindowEnabled()) { + dc.SetTextColor(GetSysColor(COLOR_GRAYTEXT)); + } + WIN32_OP_D(dc.DrawText(buffer, txLen, rcText, DT_NOPREFIX | DT_END_ELLIPSIS | DT_SINGLELINE | DT_VCENTER | DT_LEFT) > 0); + // WIN32_OP_D( dc.GrayString(NULL, NULL, (LPARAM) buffer, txLen, rcText.left, rcText.top, rcText.Width(), rcText.Height() ) ); + } + + SIZE txSize, probeSize; + const TCHAR probe[] = _T("#"); + if (dc.GetTextExtent(buffer, txLen, &txSize) && dc.GetTextExtent(probe, _countof(probe), &probeSize)) { + int spacing = txSize.cx > 0 ? (probeSize.cx / 4) : 0; + if (txSize.cx + spacing < contentRect.Width()) { + const CPoint center = contentRect.CenterPoint(); + CRect rcEdge(contentRect.left + txSize.cx + spacing, center.y, contentRect.right, contentRect.bottom); + WIN32_OP_D(dc.DrawEdge(rcEdge, EDGE_ETCHED, BF_TOP)); + } + } + } +} + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/PaintUtils.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/PaintUtils.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,55 @@ +#pragma once + +#include + +namespace PaintUtils { + t_uint32 BlendColor(t_uint32 p_color1, t_uint32 p_color2, int p_percentage = 50) throw(); + t_uint32 BlendColorEx(t_uint32 p_color1, t_uint32 p_color2, double mix = 0.5) throw(); + t_uint32 DriftColor(t_uint32 p_color,unsigned p_delta,bool p_direction) throw(); + void FillVertexColor(TRIVERTEX & p_vertex,t_uint32 p_color,t_uint16 p_alpha = 0) throw(); + void FillRectSimple(CDCHandle p_dc,const CRect & p_rect,t_uint32 p_color) throw(); + void GradientFillRect(CDCHandle p_dc,const CRect & p_rect,t_uint32 p_color1, t_uint32 p_color2, bool p_horizontal) throw(); + void GradientSplitRect(CDCHandle p_dc,const CRect & p_rect,t_uint32 p_bkColor, t_uint32 p_gradientColor,int p_splitPercent) throw(); + void GradientBar(CDCHandle p_dc,const CRect & p_rect,t_uint32 p_exterior, t_uint32 p_interior, int p_percentage) throw(); + void RenderItemBackground(CDCHandle p_dc,const CRect & p_itemRect,t_size p_item,t_uint32 p_color) throw(); + + t_uint32 DetermineTextColor(t_uint32 background) throw(); + double Luminance(t_uint32 color) throw(); + + void AddRectToRgn(HRGN rgn, CRect const & rect) throw(); + + void FocusRect(CDCHandle dc, CRect const & rect) throw(); + void FocusRect2(CDCHandle dc, CRect const & rect, COLORREF bkColor) throw(); + + namespace TrackBar { + void DrawThumb(HTHEME theme,HDC dc,int state,const RECT * rcThumb, const RECT * rcUpdate); + void DrawTrack(HTHEME theme,HDC dc,const RECT * rcTrack, const RECT * rcUpdate); + void DrawTrack2(HDC dc, const CRect& rcTrack, const CRect& rcUpdate, COLORREF highlight, COLORREF shadow); + void DrawTrackVolume(HTHEME theme,HDC dc,const CRect & rcTrack, const CRect & rcUpdate); + void DrawTrackVolume2(HDC dc, const CRect& rcTrack, const CRect& rcUpdate, COLORREF highlight, COLORREF shadow); + }; + + void DrawSmoothedLine(HDC dc, CPoint p1, CPoint p2, COLORREF col, double width); + + enum { + TextOutColors_Dim = 21, + TextOutColors_Highlight = 22, + }; + void TextOutColors(HDC dc,const TCHAR * src,int len,CPoint offset,const CRect & clip,const t_uint32 colors[3], int tabWidthTotal = 0, int tabWidthDiv = 1); + void TextOutColorsEx(HDC dc,const TCHAR * src,const CRect & target,DWORD flags,const t_uint32 colors[3]); + void TextOutColors_StripCodesAppend(pfc::string_formatter & out, const char * in); + void TextOutColors_StripCodes(pfc::string_formatter & out, const char * in); + + t_uint32 TextOutColors_CalcWidth(HDC dc, const TCHAR * src); + CSize TextOutColors_CalcSize(HDC dc, const TCHAR * src); + + pfc::string TextOutColors_ImportScript(pfc::string script); + void TextOutColors_ImportScript(pfc::string_base & out, const char * in); + + bool TextContainsCodes(const TCHAR * src); + + t_uint32 DrawText_TranslateHeaderAlignment(t_uint32 val); + + void RenderButton(HWND wnd_, HDC dc_, CRect rcUpdate, bool bPressed); + void PaintSeparatorControl(HWND wnd_); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/ReStyleWnd.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/ReStyleWnd.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,22 @@ +#pragma once +#include "win32_op.h" + +namespace PP { + // Recreate std control with a different style, keep position, title, font + template + void reStyleCtrl(CWindowT& btn, DWORD winStyle, DWORD winStyleEx) { + CWindowT btnNew; + CString title; + CWindow parent = btn.GetParent(); + btn.GetWindowText(title); + CRect rc; WIN32_OP_D(btn.GetWindowRect(rc)); WIN32_OP_D(parent.ScreenToClient(rc)); + CWindow wndPrev = parent.GetNextDlgTabItem(btn, TRUE); + auto ctrlID = btn.GetDlgCtrlID(); + auto font = btn.GetFont(); + btn.DestroyWindow(); + WIN32_OP_D(btnNew.Create(parent, rc, title, winStyle | WS_CLIPSIBLINGS, winStyleEx, ctrlID)); + if (wndPrev != NULL) btnNew.SetWindowPos(wndPrev, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE); + btnNew.SetFont(font); + btn = btnNew; + } +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/SmartStrStr.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/SmartStrStr.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,4 @@ +#pragma once + +// Moved +#include \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/TreeMultiSel.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/TreeMultiSel.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,440 @@ +#pragma once + +// ================================================================================ +// CTreeMultiSel +// Implementation of multi-selection in a tree view ctrl +// Instantiate with dialog ID of your treeview, +// plug into your dialog's message map. +// Doesn't work correctly with explorer-themed tree controls (glitches happen). +// ================================================================================ + +#include +#include + +class CTreeMultiSel : public CMessageMap { +public: + typedef std::set selection_t; + typedef std::vector selectionOrdered_t; + + CTreeMultiSel(unsigned ID) : m_ID(ID) {} + + BEGIN_MSG_MAP_EX(CTreeMultiSel) + NOTIFY_HANDLER_EX(m_ID, TVN_ITEMEXPANDED, OnItemExpanded) + NOTIFY_HANDLER_EX(m_ID, NM_CLICK, OnClick) + NOTIFY_HANDLER_EX(m_ID, TVN_DELETEITEM, OnItemDeleted) + NOTIFY_HANDLER_EX(m_ID, TVN_SELCHANGING, OnSelChanging) + NOTIFY_HANDLER_EX(m_ID, TVN_SELCHANGED, OnSelChangedFilter) + NOTIFY_HANDLER_EX(m_ID, NM_SETFOCUS, OnFocus) + NOTIFY_HANDLER_EX(m_ID, NM_KILLFOCUS, OnFocus) + NOTIFY_HANDLER_EX(m_ID, NM_CUSTOMDRAW, OnCustomDraw) + END_MSG_MAP() + + const unsigned m_ID; + + // Retrieves selected items - on order of appearance in the view + selectionOrdered_t GetSelectionOrdered(CTreeViewCtrl tree) const { + HTREEITEM first = tree.GetRootItem(); + selectionOrdered_t ret; ret.reserve( m_selection.size() ); + for(HTREEITEM walk = first; walk != NULL; walk = tree.GetNextVisibleItem(walk)) { + if (m_selection.count(walk) > 0) ret.push_back( walk ); + } + return ret; + } + + //! Undefined order! Use only when order of selected items is not relevant. + selection_t GetSelection() const { return m_selection; } + selection_t const & GetSelectionRef() const { return m_selection; } + bool IsItemSelected(HTREEITEM item) const {return m_selection.count(item) > 0;} + size_t GetSelCount() const {return m_selection.size();} + //! Retrieves a single-selection item. Null if nothing or more than one item is selected. + HTREEITEM GetSingleSel() const { + if (m_selection.size() != 1) return NULL; + return *m_selection.begin(); + } + + void OnContextMenu_FixSelection(CTreeViewCtrl tree, CPoint pt) { + if (pt != CPoint(-1, -1)) { + WIN32_OP_D(tree.ScreenToClient(&pt)); + UINT flags = 0; + const HTREEITEM item = tree.HitTest(pt, &flags); + if (item != NULL && (flags & TVHT_ONITEM) != 0) { + if (!IsItemSelected(item)) { + SelectSingleItem(tree, item); + } + CallSelectItem(tree, item); + } + } + } + + void OnLButtonDown(CTreeViewCtrl tree, WPARAM wp, LPARAM lp) { + if (!IsKeyPressed(VK_CONTROL)) { + UINT flags = 0; + HTREEITEM item = tree.HitTest(CPoint(lp), &flags); + if (item != NULL && (flags & TVHT_ONITEM) != 0) { + if (!IsItemSelected(item)) tree.SelectItem(item); + } + } + } + static bool IsNavKey(UINT vk) { + switch(vk) { + case VK_UP: + case VK_DOWN: + case VK_RIGHT: + case VK_LEFT: + case VK_PRIOR: + case VK_NEXT: + case VK_HOME: + case VK_END: + return true; + default: + return false; + } + } + BOOL OnChar(CTreeViewCtrl tree, WPARAM code) { + switch(code) { + case ' ': + if (IsKeyPressed(VK_CONTROL) || !IsTypingInProgress()) { + HTREEITEM item = tree.GetSelectedItem(); + if (item != NULL) SelectToggleItem(tree, item); + return TRUE; + } + break; + } + m_lastTypingTime = GetTickCount(); m_lastTypingTimeValid = true; + return FALSE; + } + BOOL OnKeyDown(CTreeViewCtrl tree, UINT vKey) { + if (IsNavKey(vKey)) m_lastTypingTimeValid = false; + switch(vKey) { + case VK_UP: + if (IsKeyPressed(VK_CONTROL)) { + HTREEITEM item = tree.GetSelectedItem(); + if (item != NULL) { + HTREEITEM prev = tree.GetPrevVisibleItem(item); + if (prev != NULL) { + CallSelectItem(tree, prev); + if (IsKeyPressed(VK_SHIFT)) { + if (m_selStart == NULL) m_selStart = item; + SelectItemRange(tree, prev); + } + } + } + return TRUE; + } + break; + case VK_DOWN: + if (IsKeyPressed(VK_CONTROL)) { + HTREEITEM item = tree.GetSelectedItem(); + if (item != NULL) { + HTREEITEM next = tree.GetNextVisibleItem(item); + if (next != NULL) { + CallSelectItem(tree, next); + if (IsKeyPressed(VK_SHIFT)) { + if (m_selStart == NULL) m_selStart = item; + SelectItemRange(tree, next); + } + } + } + return TRUE; + } + break; + /*case VK_LEFT: + if (IsKeyPressed(VK_CONTROL)) { + tree.SendMessage(WM_HSCROLL, SB_LINEUP, 0); + } + break; + case VK_RIGHT: + if (IsKeyPressed(VK_CONTROL)) { + tree.SendMessage(WM_HSCROLL, SB_LINEDOWN, 0); + } + break;*/ + } + return FALSE; + } +private: + LRESULT OnFocus(LPNMHDR hdr) { + if ( m_selection.size() > 100 ) { + CTreeViewCtrl tree(hdr->hwndFrom); + tree.RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_ERASE); + } else if (m_selection.size() > 0) { + CTreeViewCtrl tree(hdr->hwndFrom); + CRgn rgn; rgn.CreateRectRgn(0,0,0,0); + for(auto walk : m_selection) { + CRect rc; + if (tree.GetItemRect(walk, rc, TRUE)) { + CRgn temp; temp.CreateRectRgnIndirect(rc); + rgn.CombineRgn(temp, RGN_OR); + } + } + tree.RedrawWindow(NULL, rgn, RDW_INVALIDATE | RDW_ERASE); + } + SetMsgHandled(FALSE); + return 0; + } + void CallSelectItem(CTreeViewCtrl tree, HTREEITEM item) { + const bool was = m_ownSelChange; m_ownSelChange = true; + tree.SelectItem(item); + m_ownSelChange = was; + } + LRESULT OnSelChangedFilter(LPNMHDR) { + if (m_ownSelChangeNotify) SetMsgHandled(FALSE); + return 0; + } + LRESULT OnItemDeleted(LPNMHDR pnmh) { + const HTREEITEM item = reinterpret_cast(pnmh)->itemOld.hItem; + m_selection.erase( item ); + if (m_selStart == item) m_selStart = NULL; + SetMsgHandled(FALSE); + return 0; + } + LRESULT OnItemExpanded(LPNMHDR pnmh) { + NMTREEVIEW * info = reinterpret_cast(pnmh); + CTreeViewCtrl tree ( pnmh->hwndFrom ); + if ((info->itemNew.state & TVIS_EXPANDED) == 0) { + if (DeselectChildren( tree, info->itemNew.hItem )) { + SendOnSelChanged(tree); + } + } + SetMsgHandled(FALSE); + return 0; + } + + void FixFocusItem(CTreeViewCtrl tree, HTREEITEM item) { + if (this->IsItemSelected(item) || tree.GetSelectedItem() != item) return; + + auto scope = pfc::autoToggle(m_ownSelChange, true); + + for(;;) { + if (item == TVI_ROOT || item == NULL || this->IsItemSelected(item)) { + tree.SelectItem(item); return; + } + for (auto walk = tree.GetPrevSiblingItem(item); walk != NULL; walk = tree.GetPrevSiblingItem(walk)) { + if (this->IsItemSelected(walk)) { + tree.SelectItem(walk); return; + } + } + for (auto walk = tree.GetNextSiblingItem(item); walk != NULL; walk = tree.GetNextSiblingItem(walk)) { + if (this->IsItemSelected(walk)) { + tree.SelectItem(walk); return; + } + } + item = tree.GetParentItem(item); + } + } + + BOOL HandleClick(CTreeViewCtrl tree, CPoint pt) { + UINT htFlags = 0; + HTREEITEM item = tree.HitTest(pt, &htFlags); + if (item != NULL && (htFlags & TVHT_ONITEM) != 0) { + if (IsKeyPressed(VK_CONTROL)) { + SelectToggleItem(tree, item); + FixFocusItem(tree, item); + return TRUE; + } else if (item == tree.GetSelectedItem() && !IsItemSelected(item)) { + SelectToggleItem(tree, item); + return TRUE; + } else { + //tree.SelectItem(item); + return FALSE; + } + } else { + return FALSE; + } + } + + LRESULT OnClick(LPNMHDR pnmh) { + CPoint pt(GetMessagePos()); + CTreeViewCtrl tree ( pnmh->hwndFrom ); + WIN32_OP_D ( tree.ScreenToClient( &pt ) ); + return HandleClick(tree, pt) ? 1 : 0; + } + + LRESULT OnSelChanging(LPNMHDR pnmh) { + if (!m_ownSelChange) { + //console::formatter() << "OnSelChanging"; + NMTREEVIEW * info = reinterpret_cast(pnmh); + CTreeViewCtrl tree ( pnmh->hwndFrom ); + const HTREEITEM item = info->itemNew.hItem; + + if (IsTypingInProgress()) { + SelectSingleItem(tree, item); + } else if (IsKeyPressed(VK_SHIFT)) { + SelectItemRange(tree, item); + } else if (IsKeyPressed(VK_CONTROL)) { + SelectToggleItem(tree, item); + } else { + SelectSingleItem(tree, item); + } + } + return 0; + } + + void SelectItemRange(CTreeViewCtrl tree, HTREEITEM item) { + if (m_selStart == NULL || m_selStart == item) { + SelectSingleItem(tree, item); + return; + } + + selection_t newSel = GrabRange(tree, m_selStart, item ); + ApplySelection(tree, std::move(newSel)); + } + static selection_t GrabRange(CTreeViewCtrl tree, HTREEITEM item1, HTREEITEM item2) { + selection_t range1, range2; + HTREEITEM walk1 = item1, walk2 = item2; + for(;;) { + if (walk1 != NULL) { + range1.insert( walk1 ); + if (walk1 == item2) { + return range1; + } + walk1 = tree.GetNextVisibleItem(walk1); + } + if (walk2 != NULL) { + range2.insert( walk2 ); + if (walk2 == item1) { + return range2; + } + walk2 = tree.GetNextVisibleItem(walk2); + } + if (walk1 == NULL && walk2 == NULL) { + // should not get here + return selection_t(); + } + } + } + void SelectToggleItem(CTreeViewCtrl tree, HTREEITEM item) { + m_selStart = item; + if ( IsItemSelected( item ) ) { + m_selection.erase( item ); + } else { + m_selection.insert( item ); + } + UpdateItem(tree, item); + } + + LRESULT OnCustomDraw(LPNMHDR hdr) { + NMTVCUSTOMDRAW* info = (NMTVCUSTOMDRAW*)hdr; + switch (info->nmcd.dwDrawStage) { + case CDDS_ITEMPREPAINT: + // NOTE: This doesn't work all the way. Unflagging CDIS_FOCUS isn't respected, causing weird behaviors when using ctrl+cursors or unselecting items. + if (this->IsItemSelected((HTREEITEM)info->nmcd.dwItemSpec)) { + info->nmcd.uItemState |= CDIS_SELECTED; + } else { + info->nmcd.uItemState &= ~(CDIS_FOCUS | CDIS_SELECTED); + } + return CDRF_DODEFAULT; + case CDDS_PREPAINT: + return CDRF_NOTIFYITEMDRAW; + default: + return CDRF_DODEFAULT; + } + } +public: + void SelectSingleItem(CTreeViewCtrl tree, HTREEITEM item) { + m_selStart = item; + if (m_selection.size() == 1 && *m_selection.begin() == item) return; + DeselectAll(tree); SelectItem(tree, item); + } + + void ApplySelection(CTreeViewCtrl tree, selection_t && newSel) { + CRgn updateRgn; + bool changed = false; + if (newSel.size() != m_selection.size() && newSel.size() + m_selection.size() > 100) { + // don't bother with regions + changed = true; + } else { + WIN32_OP_D(updateRgn.CreateRectRgn(0, 0, 0, 0) != NULL); + for (auto walk : m_selection) { + if (newSel.count(walk) == 0) { + changed = true; + CRect rc; + if (tree.GetItemRect(walk, rc, TRUE)) { + CRgn temp; WIN32_OP_D(temp.CreateRectRgnIndirect(rc)); + WIN32_OP_D(updateRgn.CombineRgn(temp, RGN_OR) != ERROR); + } + } + } + for (auto walk : newSel) { + if (m_selection.count(walk) == 0) { + changed = true; + CRect rc; + if (tree.GetItemRect(walk, rc, TRUE)) { + CRgn temp; WIN32_OP_D(temp.CreateRectRgnIndirect(rc)); + WIN32_OP_D(updateRgn.CombineRgn(temp, RGN_OR) != ERROR); + } + } + } + } + if (changed) { + m_selection = std::move(newSel); + tree.RedrawWindow(NULL, updateRgn); + SendOnSelChanged(tree); + } + } + + void DeselectItem(CTreeViewCtrl tree, HTREEITEM item) { + if (IsItemSelected(item)) { + m_selection.erase(item); UpdateItem(tree, item); + } + } + void SelectItem(CTreeViewCtrl tree, HTREEITEM item) { + if (!IsItemSelected(item)) { + m_selection.insert(item); UpdateItem(tree, item); + } + } + + void DeselectAll(CTreeViewCtrl tree) { + if (m_selection.size() == 0) return; + CRgn updateRgn; + if (m_selection.size() <= 100) { + WIN32_OP_D(updateRgn.CreateRectRgn(0, 0, 0, 0) != NULL); + for (auto walk : m_selection) { + CRect rc; + if (tree.GetItemRect(walk, rc, TRUE)) { + CRgn temp; WIN32_OP_D(temp.CreateRectRgnIndirect(rc)); + WIN32_OP_D(updateRgn.CombineRgn(temp, RGN_OR) != ERROR); + } + } + } + m_selection.clear(); + tree.RedrawWindow(NULL, updateRgn); + } +private: + void UpdateItem(CTreeViewCtrl tree, HTREEITEM item) { + CRect rc; + if (tree.GetItemRect(item, rc, TRUE) ) { + tree.RedrawWindow(rc); + } + SendOnSelChanged(tree); + } + void SendOnSelChanged(CTreeViewCtrl tree) { + NMHDR hdr = {}; + hdr.code = TVN_SELCHANGED; + hdr.hwndFrom = tree; + hdr.idFrom = m_ID; + const bool was = m_ownSelChangeNotify; m_ownSelChangeNotify = true; + tree.GetParent().SendMessage(WM_NOTIFY, m_ID, (LPARAM) &hdr ); + m_ownSelChangeNotify = was; + } + + bool DeselectChildren( CTreeViewCtrl tree, HTREEITEM item ) { + bool state = false; + for(HTREEITEM walk = tree.GetChildItem( item ); walk != NULL; walk = tree.GetNextSiblingItem( walk ) ) { + if (m_selection.erase(walk) > 0) state = true; + if (m_selStart == walk) m_selStart = NULL; + if (tree.GetItemState( walk, TVIS_EXPANDED ) ) { + if (DeselectChildren( tree, walk )) state = true; + } + } + return state; + } + + bool IsTypingInProgress() const { + return m_lastTypingTimeValid && (GetTickCount() - m_lastTypingTime < 500); + } + + selection_t m_selection; + HTREEITEM m_selStart = NULL; + bool m_ownSelChangeNotify = false, m_ownSelChange = false; + DWORD m_lastTypingTime = 0; bool m_lastTypingTimeValid = false; +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/TypeFind.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/TypeFind.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,53 @@ +#include "stdafx.h" +#include "TypeFind.h" +#include "SmartStrStr.h" + +static size_t _ItemCount(HWND wnd) { + return ListView_GetItemCount(wnd); +} + +static const wchar_t * _ItemText(wchar_t * buffer, int bufSize, HWND wnd, size_t index, int subItem) { + NMLVDISPINFO info = {}; + info.hdr.code = LVN_GETDISPINFO; + info.hdr.idFrom = GetDlgCtrlID(wnd); + info.hdr.hwndFrom = wnd; + info.item.iItem = (int) index; + info.item.iSubItem = subItem; + info.item.mask = LVIF_TEXT; + info.item.pszText = buffer; + info.item.cchTextMax = bufSize; + ::SendMessage(::GetParent(wnd), WM_NOTIFY, info.hdr.idFrom, reinterpret_cast(&info)); + if (info.item.pszText == NULL) return L""; + if ( bufSize > 0 && info.item.pszText == buffer ) buffer[ bufSize - 1 ] = 0; + return info.item.pszText; +} + +LRESULT TypeFind::Handler(NMHDR* hdr, int subItemFrom, int subItemCnt) { + NMLVFINDITEM * info = reinterpret_cast(hdr); + const HWND wnd = hdr->hwndFrom; + if (info->lvfi.flags & LVFI_NEARESTXY) return -1; + const size_t count = _ItemCount(wnd); + if (count == 0) return -1; + const size_t base = (size_t)info->iStart % count; + + static SmartStrStr tool; + + enum { + bufSize = 1024, + }; + wchar_t textBuf[bufSize]; + + for (size_t walk = 0; walk < count; ++walk) { + const size_t index = (walk + base) % count; + for (int subItem = subItemFrom; subItem < subItemFrom + subItemCnt; ++subItem) { + if (tool.matchHereW(_ItemText(textBuf, bufSize, wnd, index, subItem), info->lvfi.psz)) return (LRESULT)index; + } + } + for (size_t walk = 0; walk < count; ++walk) { + const size_t index = (walk + base) % count; + for (int subItem = subItemFrom; subItem < subItemFrom + subItemCnt; ++subItem) { + if (tool.strStrEndW(_ItemText(textBuf, bufSize, wnd, index, subItem), info->lvfi.psz)) return (LRESULT)index; + } + } + return -1; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/TypeFind.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/TypeFind.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,6 @@ +#pragma once + +class TypeFind { +public: + static LRESULT Handler(NMHDR* hdr, int subItemFrom = 0, int subItemCnt = 1); +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/clipboard.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/clipboard.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,51 @@ +#include "stdafx.h" + +#include "clipboard.h" +#include "win32_op.h" + +#ifdef UNICODE +#define CF_TCHAR CF_UNICODETEXT +#else +#define CF_TCHAR CF_TEXT +#endif + +namespace ClipboardHelper { + void OpenScope::Open(HWND p_owner) { + Close(); + WIN32_OP(OpenClipboard(p_owner)); + m_open = true; + } + void OpenScope::Close() { + if (m_open) { + m_open = false; + CloseClipboard(); + } + } + void SetRaw(UINT format,const void * data, t_size size) { + HANDLE buffer = GlobalAlloc(GMEM_DDESHARE,size); + if (buffer == NULL) throw std::bad_alloc(); + try { + CGlobalLockScope lock(buffer); + PFC_ASSERT(lock.GetSize() == size); + memcpy(lock.GetPtr(),data,size); + } catch(...) { + GlobalFree(buffer); throw; + } + + WIN32_OP(SetClipboardData(format,buffer) != NULL); + } + void SetString(const char * in) { + pfc::stringcvt::string_os_from_utf8 temp(in); + SetRaw(CF_TCHAR,temp.get_ptr(),(temp.length() + 1) * sizeof(TCHAR)); + } + + bool GetString(pfc::string_base & out) { + pfc::array_t temp; + if (!GetRaw(CF_TCHAR,temp)) return false; + out = pfc::stringcvt::string_utf8_from_os(reinterpret_cast(temp.get_ptr()),temp.get_size() / sizeof(TCHAR)); + return true; + } + bool IsTextAvailable() { + return IsClipboardFormatAvailable(CF_TCHAR) == TRUE; + } +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/clipboard.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/clipboard.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,33 @@ +#pragma once + +namespace ClipboardHelper { + + class OpenScope { + public: + OpenScope() : m_open(false) {} + ~OpenScope() {Close();} + void Open(HWND p_owner); + void Close(); + private: + bool m_open; + + PFC_CLASS_NOT_COPYABLE_EX(OpenScope) + }; + + void SetRaw(UINT format,const void * buffer, t_size size); + void SetString(const char * in); + + bool GetString(pfc::string_base & out); + + template + bool GetRaw(UINT format,TArray & out) { + pfc::assert_byte_type(); + HANDLE data = GetClipboardData(format); + if (data == NULL) return false; + CGlobalLockScope lock(data); + out.set_size( lock.GetSize() ); + memcpy(out.get_ptr(), lock.GetPtr(), lock.GetSize() ); + return true; + } + bool IsTextAvailable(); +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/commandline_parser.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/commandline_parser.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,65 @@ +#include "stdafx.h" +#include "commandline_parser.h" + +commandline_parser::commandline_parser() { + init(pfc::stringcvt::string_utf8_from_os(GetCommandLine())); +} + +void commandline_parser::init(const char * cmd) +{ + pfc::string8_fastalloc temp; + pfc::chain_list_v2_t out; + while(*cmd) + { + temp.reset(); + while(*cmd && *cmd!=' ') + { + if (*cmd=='\"') + { + cmd++; + while(*cmd && *cmd!='\"') temp.add_byte(*(cmd++)); + if (*cmd == '\"') cmd++; + } + else temp.add_byte(*(cmd++)); + } + out.insert_last(temp); + while(*cmd==' ') cmd++; + } + pfc::list_to_array(m_data,out); +} + +size_t commandline_parser::find_param(const char * ptr) const { + for(size_t n=1;n m_data; +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/gdi-types-portable.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/gdi-types-portable.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,86 @@ +#pragma once +#include // std::swap + + +namespace gdi_types_portable { + + template + struct CSize { + typedef CSize self_t; + + CSize() {} + CSize(val_t _cx, val_t _cy) : cx(_cx), cy(_cy) {} + + val_t cx = 0, cy = 0; + }; + + template + struct CPoint { + typedef CPoint self_t; + typedef CSize size_t; + + CPoint() {} + CPoint(val_t _x, val_t _y) : x(_x), y(_y) {} + + self_t operator+(self_t const & other) const { + return self_t(x + other.x, y + other.y); + } + self_t operator-(self_t const & other) const { + return self_t(x - other.x, y - other.y); + } + static bool Equals(const self_t & v1, const self_t & v2) {return v1.x == v2.x && v1.y == v2.y;} + bool operator==(const self_t & other) const { return Equals(*this, other); } + bool operator!=(const self_t & other) const { return !Equals(*this, other); } + + + val_t x = 0, y = 0; + }; + + template + struct CRect { + + typedef CRect self_t; + typedef CPoint point_t; + typedef CSize size_t; + + CRect() { + left = 0, top = 0, right = 0, bottom = 0; + static_assert(sizeof(self_t) == 2 * sizeof(point_t), "sanity"); + } + CRect(val_t l, val_t t, val_t r, val_t b) : left(l), top(t), right(r), bottom(b) {} + CRect(point_t p1, point_t p2) { + _topLeft = p1; _bottomRight = p2; + this->NormalizeRect(); + } + + union { + struct { + val_t left, top, right, bottom; + }; + struct { + point_t _topLeft, _bottomRight; + }; + }; + + + point_t & TopLeft() { return _topLeft; } + point_t & BottomRight() { return _bottomRight; } + const point_t & TopLeft() const { return _topLeft; } + const point_t & BottomRight() const { return _bottomRight; } + + size_t Size() const { + return size_t(Width(), Height()); + } + + val_t Width() const { return right - left; } + val_t Height() const { return bottom - top; } + + void NormalizeRect() { + if (right < left) std::swap(left, right); + if (bottom < top) std::swap(top, bottom); + } + point_t CenterPoint() const { + return point_t((left + right) / 2, (top + bottom) / 2); + } + }; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/gdiplus-helpers-webp.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/gdiplus-helpers-webp.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,46 @@ +#pragma once + +#include "gdiplus_helpers.h" + +// Presumes prior #include of webp/decode.h + +inline bool IsImageWebP(const void * ptr, size_t bytes) { + if (bytes < 12) return false; + return memcmp(ptr, "RIFF", 4) == 0 && memcmp((const char*)ptr + 8, "WEBP", 4) == 0; +} + + +// WebP-aware GdiplusImageFromMem +static std::unique_ptr GdiplusImageFromMem2(const void * ptr, size_t bytes) { + GdiplusErrorHandler EH; + using namespace Gdiplus; + if (IsImageWebP(ptr, bytes)) { + WebPBitstreamFeatures bs; + if (WebPGetFeatures((const uint8_t*)ptr, bytes, &bs) != VP8_STATUS_OK) { + throw std::runtime_error("WebP decoding failure"); + } + const Gdiplus::PixelFormat pf = bs.has_alpha ? PixelFormat32bppARGB : PixelFormat32bppRGB; + const int pfBytes = 4; // Gdiplus RGB is 4 bytes + int w = 0, h = 0; + // ALWAYS decode BGRA, Gdiplus will disregard alpha if was not originally present + uint8_t * decodedData = WebPDecodeBGRA((const uint8_t*)ptr, bytes, &w, &h); + pfc::onLeaving scope([decodedData] {WebPFree(decodedData); }); + if (decodedData == nullptr || w <= 0 || h <= 0) throw std::runtime_error("WebP decoding failure"); + + std::unique_ptr ret ( new Gdiplus::Bitmap(w, h, pf) ); + EH << ret->GetLastStatus(); + Rect rc(0, 0, w, h); + Gdiplus::BitmapData bitmapData; + EH << ret->LockBits(&rc, 0, pf, &bitmapData); + uint8_t * target = (uint8_t*)bitmapData.Scan0; + const uint8_t * source = decodedData; + for (int y = 0; y < h; ++y) { + memcpy(target, source, w * pfBytes); + target += bitmapData.Stride; + source += pfBytes * w; + } + EH << ret->UnlockBits(&bitmapData); + return ret; + } + return GdiplusImageFromMem(ptr, bytes); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/gdiplus_helpers.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/gdiplus_helpers.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,224 @@ +#include "stdafx.h" +#include "gdiplus_helpers.h" + +static bool _Once() { + ULONG_PTR token = 0; + Gdiplus::GdiplusStartupInput input; + Gdiplus::GdiplusStartupOutput output; + GdiplusErrorHandler() << Gdiplus::GdiplusStartup(&token, &input, &output); + return true; +} + +void GdiplusScope::Once() { + static bool done = _Once(); + (void)done; // suppress warning +} + +void GdiplusErrorHandler::Handle(Gdiplus::Status p_code) { + if (p_code != Gdiplus::Ok) { + switch (p_code) { + case Gdiplus::InvalidParameter: + throw pfc::exception_invalid_params(); + default: + throw std::runtime_error(pfc::format("Gdiplus error (", (unsigned)p_code, ")")); + } + + } +} + +HBITMAP GdiplusLoadBitmap(UINT id, const TCHAR* resType, CSize size) { + using namespace Gdiplus; + try { + auto stream = WinLoadResourceAsStream(GetThisModuleHandle(), MAKEINTRESOURCE(id), resType); + + GdiplusErrorHandler EH; + Image source ( stream ); + EH << source.GetLastStatus(); + + Bitmap resized (size.cx, size.cy, PixelFormat32bppARGB); + EH << resized.GetLastStatus(); + + { + Graphics target(&resized); + EH << target.GetLastStatus(); + EH << target.SetInterpolationMode(InterpolationModeHighQuality); + EH << target.Clear(Color(0, 0, 0, 0)); + EH << target.DrawImage(&source, Rect(0, 0, size.cx, size.cy)); + } + + HBITMAP bmp = NULL; + EH << resized.GetHBITMAP(Gdiplus::Color::White, &bmp); + return bmp; + } catch (...) { + PFC_ASSERT(!"Should not get here"); + return NULL; + } +} + +std::unique_ptr GdiplusImageFromMem(const void* ptr, size_t bytes) { + using namespace Gdiplus; + GdiplusErrorHandler EH; + + CComPtr stream; + stream.p = SHCreateMemStream((const BYTE*)ptr, pfc::downcast_guarded(bytes)); + if (!stream) throw std::bad_alloc(); + std::unique_ptr source ( new Image(stream.p) ); + EH << source->GetLastStatus(); + return source; +} + +std::unique_ptr< Gdiplus::Bitmap > GdiplusResizeImage(Gdiplus::Image* source, CSize size, Gdiplus::PixelFormat pf) { + PFC_ASSERT(size.cx > 0 && size.cy > 0); + using namespace Gdiplus; + GdiplusErrorHandler EH; + std::unique_ptr resized ( new Bitmap(size.cx, size.cy, pf) ); + EH << resized->GetLastStatus(); + Graphics target (resized.get() ); + EH << target.GetLastStatus(); + EH << target.SetInterpolationMode(InterpolationModeHighQuality); + EH << target.Clear(Color(0, 0, 0, 0)); + EH << target.DrawImage(source, Rect(0, 0, size.cx, size.cy)); + return resized; +} + +HICON GdiplusLoadIconFromMem(const void* ptr, size_t bytes, CSize size) { + using namespace Gdiplus; + try { + + GdiplusErrorHandler EH; + auto source = GdiplusImageFromMem(ptr, bytes); + auto resized = GdiplusResizeImage(source.get(), size); + HICON icon = NULL; + EH << resized->GetHICON(&icon); + return icon; + } catch (...) { + PFC_ASSERT(!"Should not get here"); + return NULL; + } +} + +HICON GdiplusLoadIcon(UINT id, const TCHAR* resType, CSize size) { + GdiplusIconArg_t arg = { size }; + return GdiplusLoadIconEx(id, resType, arg); +} + +HICON GdiplusLoadIconEx(UINT id, const TCHAR* resType, GdiplusIconArg_t const& arg) { + using namespace Gdiplus; + try { + auto stream = WinLoadResourceAsStream(GetThisModuleHandle(), MAKEINTRESOURCE(id), resType); + + GdiplusErrorHandler EH; + + Bitmap resized(arg.size.cx, arg.size.cy, PixelFormat32bppARGB); + EH << resized.GetLastStatus(); + + { + Image source(stream); + EH << source.GetLastStatus(); + + Graphics target(&resized); + EH << target.GetLastStatus(); + EH << target.SetInterpolationMode(InterpolationModeHighQuality); + EH << target.Clear(Color(0, 0, 0, 0)); + EH << target.DrawImage(&source, Rect(0, 0, arg.size.cx, arg.size.cy)); + } + + + if (arg.transform) arg.transform(&resized); + + HICON icon = NULL; + EH << resized.GetHICON(&icon); + return icon; + } catch (...) { + PFC_ASSERT(!"Should not get here"); + return NULL; + } +} + +HICON GdiplusLoadPNGIcon(UINT id, CSize size) { + return GdiplusLoadIcon(id, _T("PNG"), size); +} + +HICON LoadPNGIcon(UINT id, CSize size) { + GdiplusScope scope; + return GdiplusLoadPNGIcon(id, size); +} + +void GdiplusLoadButtonPNG(CIcon& icon, HWND btn_, UINT image, GdiplusBitmapTransform_t transform) { + CButton btn(btn_); + if (icon == NULL) { + CRect client; WIN32_OP_D(btn.GetClientRect(client)); + CSize size = client.Size(); + int v = MulDiv(pfc::min_t(size.cx, size.cy), 3, 4); + if (v < 8) v = 8; + + GdiplusIconArg_t arg; + arg.size = CSize(v, v); + arg.transform = transform; + icon = GdiplusLoadIconEx(image, L"PNG", arg); + } + btn.SetIcon(icon); +} + +std::unique_ptr GdiplusLoadResource(UINT id, const TCHAR* resType) { + using namespace Gdiplus; + GdiplusErrorHandler EH; + + auto stream = WinLoadResourceAsStream(GetThisModuleHandle(), MAKEINTRESOURCE(id), resType); + + std::unique_ptr img ( new Bitmap(stream) ); + EH << img->GetLastStatus(); + return img; +} + +std::unique_ptr GdiplusLoadResourceAsSize(UINT id, const TCHAR* resType, CSize size) { + auto source = GdiplusLoadResource(id, resType); + return GdiplusResizeImage(source.get(), size); +} + +void GdiplusDimImage(Gdiplus::Bitmap* bmp) { + using namespace Gdiplus; + GdiplusErrorHandler EH; + Gdiplus::Rect r(0, 0, bmp->GetWidth(), bmp->GetHeight()); + BitmapData data = {}; + EH << bmp->LockBits(&r, ImageLockModeRead | ImageLockModeWrite, PixelFormat32bppARGB, &data); + + BYTE* scan = (BYTE*)data.Scan0; + for (UINT y = 0; y < data.Height; ++y) { + BYTE* px = scan; + for (UINT x = 0; x < data.Width; ++x) { + //px[0] = _dimPixel(px[0]); + //px[1] = _dimPixel(px[1]); + //px[2] = _dimPixel(px[2]); + px[3] /= 3; + px += 4; + } + scan += data.Stride; + } + + EH << bmp->UnlockBits(&data); +} + +void GdiplusInvertImage(Gdiplus::Bitmap* bmp) { + using namespace Gdiplus; + GdiplusErrorHandler EH; + Gdiplus::Rect r(0, 0, bmp->GetWidth(), bmp->GetHeight()); + BitmapData data = {}; + EH << bmp->LockBits(&r, ImageLockModeRead | ImageLockModeWrite, PixelFormat32bppARGB, &data); + + BYTE* scan = (BYTE*)data.Scan0; + for (UINT y = 0; y < data.Height; ++y) { + BYTE* px = scan; + for (UINT x = 0; x < data.Width; ++x) { + unsigned v = (unsigned)px[0] + (unsigned)px[1] + (unsigned)px[2]; + v /= 3; + px[0] = px[1] = px[2] = (BYTE)(255 - v); + px += 4; + } + scan += data.Stride; + } + + EH << bmp->UnlockBits(&data); +} + +#pragma comment(lib, "gdiplus.lib") diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/gdiplus_helpers.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/gdiplus_helpers.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,53 @@ +#pragma once +#include +#include +#include + +#include "win32_op.h" +#include "win32_utility.h" + +class GdiplusErrorHandler { +public: + static void Handle(Gdiplus::Status code); + void operator<<(Gdiplus::Status p_code) {Handle(p_code);} +}; + +class GdiplusScope { +public: + GdiplusScope() { + Gdiplus::GdiplusStartupInput input; + Gdiplus::GdiplusStartupOutput output; + GdiplusErrorHandler() << Gdiplus::GdiplusStartup(&m_token,&input,&output); + } + ~GdiplusScope() { + Gdiplus::GdiplusShutdown(m_token); + } + static void Once(); +private: + GdiplusScope( const GdiplusScope & ) = delete; + void operator=( const GdiplusScope & ) = delete; + + ULONG_PTR m_token = 0; +}; + +typedef std::function GdiplusBitmapTransform_t; + +struct GdiplusIconArg_t { + CSize size = CSize(0,0); + GdiplusBitmapTransform_t transform = nullptr; +}; + +HBITMAP GdiplusLoadBitmap(UINT id, const TCHAR* resType, CSize size); +std::unique_ptr GdiplusImageFromMem(const void* ptr, size_t bytes); +std::unique_ptr GdiplusResizeImage(Gdiplus::Image* source, CSize size, Gdiplus::PixelFormat pf = PixelFormat32bppARGB); +HICON GdiplusLoadIconFromMem(const void* ptr, size_t bytes, CSize size); +HICON GdiplusLoadIcon(UINT id, const TCHAR* resType, CSize size); +HICON GdiplusLoadIconEx(UINT id, const TCHAR* resType, GdiplusIconArg_t const & arg); +HICON GdiplusLoadPNGIcon(UINT id, CSize size); +HICON LoadPNGIcon(UINT id, CSize size); + +void GdiplusLoadButtonPNG(CIcon& icon, HWND btn_, UINT image, GdiplusBitmapTransform_t transform = nullptr); +std::unique_ptr GdiplusLoadResource(UINT id, const TCHAR* resType); +std::unique_ptr GdiplusLoadResourceAsSize(UINT id, const TCHAR* resType, CSize size); +void GdiplusDimImage(Gdiplus::Bitmap* bmp); +void GdiplusInvertImage(Gdiplus::Bitmap* bmp); diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/gesture.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/gesture.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,264 @@ +#pragma once + +#ifndef WM_GESTURE + +#define WM_GESTURE 0x0119 +#define WM_GESTURENOTIFY 0x011A + + +DECLARE_HANDLE(HGESTUREINFO); + + +/* + * Gesture flags - GESTUREINFO.dwFlags + */ +#define GF_BEGIN 0x00000001 +#define GF_INERTIA 0x00000002 +#define GF_END 0x00000004 + +/* + * Gesture IDs + */ +#define GID_BEGIN 1 +#define GID_END 2 +#define GID_ZOOM 3 +#define GID_PAN 4 +#define GID_ROTATE 5 +#define GID_TWOFINGERTAP 6 +#define GID_PRESSANDTAP 7 +#define GID_ROLLOVER GID_PRESSANDTAP + +/* + * Gesture information structure + * - Pass the HGESTUREINFO received in the WM_GESTURE message lParam into the + * GetGestureInfo function to retrieve this information. + * - If cbExtraArgs is non-zero, pass the HGESTUREINFO received in the WM_GESTURE + * message lParam into the GetGestureExtraArgs function to retrieve extended + * argument information. + */ +typedef struct tagGESTUREINFO { + UINT cbSize; // size, in bytes, of this structure (including variable length Args field) + DWORD dwFlags; // see GF_* flags + DWORD dwID; // gesture ID, see GID_* defines + HWND hwndTarget; // handle to window targeted by this gesture + POINTS ptsLocation; // current location of this gesture + DWORD dwInstanceID; // internally used + DWORD dwSequenceID; // internally used + ULONGLONG ullArguments; // arguments for gestures whose arguments fit in 8 BYTES + UINT cbExtraArgs; // size, in bytes, of extra arguments, if any, that accompany this gesture +} GESTUREINFO, *PGESTUREINFO; +typedef GESTUREINFO const * PCGESTUREINFO; + + +/* + * Gesture notification structure + * - The WM_GESTURENOTIFY message lParam contains a pointer to this structure. + * - The WM_GESTURENOTIFY message notifies a window that gesture recognition is + * in progress and a gesture will be generated if one is recognized under the + * current gesture settings. + */ +typedef struct tagGESTURENOTIFYSTRUCT { + UINT cbSize; // size, in bytes, of this structure + DWORD dwFlags; // unused + HWND hwndTarget; // handle to window targeted by the gesture + POINTS ptsLocation; // starting location + DWORD dwInstanceID; // internally used +} GESTURENOTIFYSTRUCT, *PGESTURENOTIFYSTRUCT; + +/* + * Gesture argument helpers + * - Angle should be a double in the range of -2pi to +2pi + * - Argument should be an unsigned 16-bit value + */ +#define GID_ROTATE_ANGLE_TO_ARGUMENT(_arg_) ((USHORT)((((_arg_) + 2.0 * 3.14159265) / (4.0 * 3.14159265)) * 65535.0)) +#define GID_ROTATE_ANGLE_FROM_ARGUMENT(_arg_) ((((double)(_arg_) / 65535.0) * 4.0 * 3.14159265) - 2.0 * 3.14159265) + +/* + * Gesture information retrieval + * - HGESTUREINFO is received by a window in the lParam of a WM_GESTURE message. + */ +WINUSERAPI +BOOL +WINAPI +GetGestureInfo( + __in HGESTUREINFO hGestureInfo, + __out PGESTUREINFO pGestureInfo); + + + +/* + * Gesture extra arguments retrieval + * - HGESTUREINFO is received by a window in the lParam of a WM_GESTURE message. + * - Size, in bytes, of the extra argument data is available in the cbExtraArgs + * field of the GESTUREINFO structure retrieved using the GetGestureInfo function. + */ +WINUSERAPI +BOOL +WINAPI +GetGestureExtraArgs( + __in HGESTUREINFO hGestureInfo, + __in UINT cbExtraArgs, + __out_bcount(cbExtraArgs) PBYTE pExtraArgs); + +/* + * Gesture information handle management + * - If an application processes the WM_GESTURE message, then once it is done + * with the associated HGESTUREINFO, the application is responsible for + * closing the handle using this function. Failure to do so may result in + * process memory leaks. + * - If the message is instead passed to DefWindowProc, or is forwarded using + * one of the PostMessage or SendMessage class of API functions, the handle + * is transfered with the message and need not be closed by the application. + */ +WINUSERAPI +BOOL +WINAPI +CloseGestureInfoHandle( + __in HGESTUREINFO hGestureInfo); + + +/* + * Gesture configuration structure + * - Used in SetGestureConfig and GetGestureConfig + * - Note that any setting not included in either GESTURECONFIG.dwWant or + * GESTURECONFIG.dwBlock will use the parent window's preferences or + * system defaults. + */ +typedef struct tagGESTURECONFIG { + DWORD dwID; // gesture ID + DWORD dwWant; // settings related to gesture ID that are to be turned on + DWORD dwBlock; // settings related to gesture ID that are to be turned off +} GESTURECONFIG, *PGESTURECONFIG; + +/* + * Gesture configuration flags - GESTURECONFIG.dwWant or GESTURECONFIG.dwBlock + */ + +/* + * Common gesture configuration flags - set GESTURECONFIG.dwID to zero + */ +#define GC_ALLGESTURES 0x00000001 + +/* + * Zoom gesture configuration flags - set GESTURECONFIG.dwID to GID_ZOOM + */ +#define GC_ZOOM 0x00000001 + +/* + * Pan gesture configuration flags - set GESTURECONFIG.dwID to GID_PAN + */ +#define GC_PAN 0x00000001 +#define GC_PAN_WITH_SINGLE_FINGER_VERTICALLY 0x00000002 +#define GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY 0x00000004 +#define GC_PAN_WITH_GUTTER 0x00000008 +#define GC_PAN_WITH_INERTIA 0x00000010 + +/* + * Rotate gesture configuration flags - set GESTURECONFIG.dwID to GID_ROTATE + */ +#define GC_ROTATE 0x00000001 + +/* + * Two finger tap gesture configuration flags - set GESTURECONFIG.dwID to GID_TWOFINGERTAP + */ +#define GC_TWOFINGERTAP 0x00000001 + +/* + * PressAndTap gesture configuration flags - set GESTURECONFIG.dwID to GID_PRESSANDTAP + */ +#define GC_PRESSANDTAP 0x00000001 +#define GC_ROLLOVER GC_PRESSANDTAP + +#define GESTURECONFIGMAXCOUNT 256 // Maximum number of gestures that can be included + // in a single call to SetGestureConfig / GetGestureConfig + +WINUSERAPI +BOOL +WINAPI +SetGestureConfig( + __in HWND hwnd, // window for which configuration is specified + __in DWORD dwReserved, // reserved, must be 0 + __in UINT cIDs, // count of GESTURECONFIG structures + __in_ecount(cIDs) PGESTURECONFIG pGestureConfig, // array of GESTURECONFIG structures, dwIDs will be processed in the + // order specified and repeated occurances will overwrite previous ones + __in UINT cbSize); // sizeof(GESTURECONFIG) + + + + +#define GCF_INCLUDE_ANCESTORS 0x00000001 // If specified, GetGestureConfig returns consolidated configuration + // for the specified window and it's parent window chain + +WINUSERAPI +BOOL +WINAPI +GetGestureConfig( + __in HWND hwnd, // window for which configuration is required + __in DWORD dwReserved, // reserved, must be 0 + __in DWORD dwFlags, // see GCF_* flags + __in PUINT pcIDs, // *pcIDs contains the size, in number of GESTURECONFIG structures, + // of the buffer pointed to by pGestureConfig + __inout_ecount(*pcIDs) PGESTURECONFIG pGestureConfig, + // pointer to buffer to receive the returned array of GESTURECONFIG structures + __in UINT cbSize); // sizeof(GESTURECONFIG) + + + +typedef BOOL +(WINAPI *pGetGestureInfo_t)( + __in HGESTUREINFO hGestureInfo, + __out PGESTUREINFO pGestureInfo); + +typedef BOOL +(WINAPI * pCloseGestureInfoHandle_t)( + __in HGESTUREINFO hGestureInfo); + +typedef BOOL +(WINAPI * pSetGestureConfig_t) ( + __in HWND hwnd, // window for which configuration is specified + __in DWORD dwReserved, // reserved, must be 0 + __in UINT cIDs, // count of GESTURECONFIG structures + __in_ecount(cIDs) PGESTURECONFIG pGestureConfig, // array of GESTURECONFIG structures, dwIDs will be processed in the + // order specified and repeated occurances will overwrite previous ones + __in UINT cbSize); // sizeof(GESTURECONFIG) + +class CGestureAPI { +public: + CGestureAPI() { + HMODULE dll = GetModuleHandle(_T("user32.dll")); + + Bind(GetGestureInfo, dll, "GetGestureInfo"); + Bind(CloseGestureInfoHandle, dll, "CloseGestureInfoHandle"); + Bind(SetGestureConfig, dll, "SetGestureConfig"); + } + + bool IsAvailable() { + return this->GetGestureInfo != NULL; + } + + pGetGestureInfo_t GetGestureInfo; + pCloseGestureInfoHandle_t CloseGestureInfoHandle; + pSetGestureConfig_t SetGestureConfig; +private: + template static void Bind(func_t & f, HMODULE dll, const char * name) { + f = reinterpret_cast(GetProcAddress(dll, name)); + } +}; +#else + +class CGestureAPI { +public: + inline static bool IsAvailable() { return true; } + inline static BOOL GetGestureInfo(HGESTUREINFO hGestureInfo, PGESTUREINFO pGestureInfo) { + return ::GetGestureInfo(hGestureInfo, pGestureInfo); + } + inline static BOOL CloseGestureInfoHandle(HGESTUREINFO hGestureInfo) { + return ::CloseGestureInfoHandle(hGestureInfo); + } + + inline static BOOL SetGestureConfig(HWND hwnd, DWORD dwReserved, UINT cIDs, PGESTURECONFIG pGestureConfig, UINT cbSize) { + return ::SetGestureConfig(hwnd, dwReserved, cIDs, pGestureConfig, cbSize); + } +}; +#endif + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/hookWindowMessages.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/hookWindowMessages.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,16 @@ +#pragma once + +#include "windowLifetime.h" + +namespace PP { + // CContainedWindow replacement + // Rationale: + // With CContainedWindow, all messages that the window gets are routed through the message map of your class. + // The window might bounce some of the messages to other windows (say, mouse4/5 handlers, WM_CONTEXTMENU), or do modal loops. + // If some events triggered by those destroy your CContainedWindow host, crash happens, because your object is still on stack. + // hookWindowMessages() sends only the messages you ask for to your class, also managing hook lifetime behind the scenes. + void hookWindowMessages(HWND wnd, CMessageMap* target, DWORD targetID, std::initializer_list&& msgs); + + typedef std::function messageHook_t; + void hookWindowMessages(HWND wnd, messageHook_t h); +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/libPPUI-license.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/libPPUI-license.txt Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,17 @@ +Copyright (C) 2002-2024 Peter Pawlowski + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/libPPUI-readme.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/libPPUI-readme.txt Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,3 @@ +libPPUI + +A library of user interface classes used by foobar2000 codebase; freely available for anyone to use in their programming projects. diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/libPPUI.vcxproj --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/libPPUI.vcxproj Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,438 @@ + + + + + Debug + ARM64 + + + Debug + ARM64EC + + + Debug + Win32 + + + Release + ARM64 + + + Release + ARM64EC + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {7729EB82-4069-4414-964B-AD399091A03F} + Win32Proj + libPPUI + 10.0 + + + + StaticLibrary + true + v142 + Unicode + + + StaticLibrary + false + v142 + true + Unicode + + + StaticLibrary + true + v142 + Unicode + + + StaticLibrary + true + v143 + Unicode + + + StaticLibrary + true + v143 + Unicode + + + StaticLibrary + false + v142 + true + Unicode + + + StaticLibrary + false + v143 + true + Unicode + + + StaticLibrary + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + true + + + true + + + true + + + false + + + false + + + false + + + false + + + + Use + Level3 + Disabled + false + .. + ProgramDatabase + true + 4715 + false + Fast + stdcpp17 + true + MultiThreadedDebugDLL + + + Windows + true + + + + + Use + Level3 + Disabled + false + true + false + .. + stdcpp17 + true + ProgramDatabase + MultiThreadedDebugDLL + + + Windows + true + + + + + Use + Level3 + Disabled + false + true + false + .. + stdcpp17 + true + MultiThreadedDebugDLL + + + Windows + true + + + + + Use + Level3 + Disabled + false + true + false + .. + stdcpp17 + true + + + Windows + true + + + + + Use + Level3 + MinSpace + true + true + false + .. + true + 4715 + false + Fast + true + /d2notypeopt %(AdditionalOptions) + NDEBUG;%(PreprocessorDefinitions) + stdcpp17 + true + + + Windows + true + true + true + + + + + Use + Level3 + MaxSpeed + true + true + false + Fast + true + false + .. + /d2notypeopt %(AdditionalOptions) + NDEBUG;%(PreprocessorDefinitions) + stdcpp17 + true + + + Windows + true + true + true + + + + + Use + Level3 + MaxSpeed + true + true + false + Fast + true + false + .. + /d2notypeopt %(AdditionalOptions) + NDEBUG;%(PreprocessorDefinitions) + stdcpp17 + true + + + Windows + true + true + true + + + + + Use + Level3 + MaxSpeed + true + true + false + Fast + true + false + .. + /d2notypeopt %(AdditionalOptions) + NDEBUG;%(PreprocessorDefinitions) + stdcpp17 + true + + + Windows + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Create + Create + Create + Create + Create + Create + Create + Create + + + + + + + + + + + + + \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/libPPUI.vcxproj.filters --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/libPPUI.vcxproj.filters Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,306 @@ + + + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;ipp;xsd + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + + + \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/link-CommonControls6.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/link-CommonControls6.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,3 @@ +#pragma once + +#pragma comment(linker, "\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' processorArchitecture='*'\"") diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/listview_helper.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/listview_helper.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,303 @@ +#include "stdafx.h" + +#include "win32_utility.h" +#include "win32_op.h" +#include "listview_helper.h" +#include "CListViewCtrlEx.h" +#include "CHeaderCtrlEx.h" + +namespace listview_helper { + + unsigned insert_item(HWND p_listview,unsigned p_index,const char * p_name,LPARAM p_param) + { + if (p_index == ~0) p_index = ListView_GetItemCount(p_listview); + LVITEM item = {}; + + pfc::stringcvt::string_os_from_utf8 os_string_temp(p_name); + + item.mask = LVIF_TEXT | LVIF_PARAM; + item.iItem = p_index; + item.lParam = p_param; + item.pszText = const_cast(os_string_temp.get_ptr()); + + LRESULT ret = SendMessage(p_listview,LVM_INSERTITEM,0,(LPARAM)&item); + PFC_ASSERT(ret >= 0); + if (ret < 0) return UINT_MAX; + else return (unsigned) ret; + } + + unsigned insert_item2(HWND p_listview, unsigned p_index, const char * col0, const char * col1, LPARAM p_param) { + unsigned i = insert_item( p_listview, p_index, col0, p_param ); + if (i != UINT_MAX) { + set_item_text( p_listview, i, 1, col1 ); + } + return i; + } + + unsigned insert_item3(HWND p_listview, unsigned p_index, const char * col0, const char * col1, const char * col2, LPARAM p_param) { + unsigned i = insert_item( p_listview, p_index, col0, p_param ); + if (i != UINT_MAX) { + set_item_text( p_listview, i, 1, col1 ); + set_item_text( p_listview, i, 2, col2 ); + } + return i; + } + + unsigned insert_column(HWND p_listview,unsigned p_index,const char * p_name,unsigned p_width_dlu) + { + pfc::stringcvt::string_os_from_utf8 os_string_temp(p_name); + + RECT rect = {0,0,(LONG)p_width_dlu,0}; + MapDialogRect(GetParent(p_listview),&rect); + + LVCOLUMN data = {}; + data.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_FMT; + data.fmt = LVCFMT_LEFT; + data.cx = rect.right; + data.pszText = const_cast(os_string_temp.get_ptr()); + + LRESULT ret = SendMessage(p_listview,LVM_INSERTCOLUMN,p_index,(LPARAM)&data); + PFC_ASSERT(ret >= 0); + if (ret < 0) return UINT_MAX; + else return (unsigned) ret; + } + + void get_item_text(HWND p_listview,unsigned p_index,unsigned p_column,pfc::string_base & p_out) { + enum {buffer_length = 1024*64}; + pfc::array_t buffer; buffer.set_size(buffer_length); + ListView_GetItemText(p_listview,p_index,p_column,buffer.get_ptr(),buffer_length); + p_out = pfc::stringcvt::string_utf8_from_os(buffer.get_ptr(),buffer_length); + } + + bool set_item_text(HWND p_listview,unsigned p_index,unsigned p_column,const char * p_name) + { + LVITEM item = {}; + + pfc::stringcvt::string_os_from_utf8 os_string_temp(p_name); + + item.mask = LVIF_TEXT; + item.iItem = p_index; + item.iSubItem = p_column; + item.pszText = const_cast(os_string_temp.get_ptr()); + return SendMessage(p_listview,LVM_SETITEM,0,(LPARAM)&item) ? true : false; + } + + bool is_item_selected(HWND p_listview,unsigned p_index) + { + LVITEM item = {}; + item.mask = LVIF_STATE; + item.iItem = p_index; + item.stateMask = LVIS_SELECTED; + if (!SendMessage(p_listview,LVM_GETITEM,0,(LPARAM)&item)) return false; + return (item.state & LVIS_SELECTED) ? true : false; + } + + void set_item_selection(HWND p_listview,unsigned p_index,bool p_state) + { + PFC_ASSERT( ::IsWindow(p_listview) ); + LVITEM item = {}; + item.stateMask = LVIS_SELECTED; + item.state = p_state ? LVIS_SELECTED : 0; + WIN32_OP_D( SendMessage(p_listview,LVM_SETITEMSTATE,(WPARAM)p_index,(LPARAM)&item) ); + } + + bool select_single_item(HWND p_listview,unsigned p_index) + { + LRESULT temp = SendMessage(p_listview,LVM_GETITEMCOUNT,0,0); + if (temp < 0) return false; + ListView_SetSelectionMark(p_listview,p_index); + unsigned n; const unsigned m = pfc::downcast_guarded(temp); + for(n=0;n= 0) { + ListView_EnsureVisible(p_list, firstsel, FALSE); + RECT rect; + WIN32_OP_D( ListView_GetItemRect(p_list,firstsel,&rect,LVIR_BOUNDS) ); + p_point.x = (rect.left + rect.right) / 2; + p_point.y = (rect.top + rect.bottom) / 2; + WIN32_OP_D( ClientToScreen(p_list,&p_point) ); + } else { + RECT rect; + WIN32_OP_D(GetClientRect(p_list,&rect)); + p_point.x = (rect.left + rect.right) / 2; + p_point.y = (rect.top + rect.bottom) / 2; + WIN32_OP_D(ClientToScreen(p_list,&p_point)); + } + p_selection = firstsel; + } else { + POINT pt = p_coords; // {(short)LOWORD(p_coords),(short)HIWORD(p_coords)}; + p_point = pt; + POINT client = pt; + WIN32_OP_D( ScreenToClient(p_list,&client) ); + LVHITTESTINFO info = {}; + info.pt = client; + p_selection = ListView_HitTest(p_list,&info); + } +} + +int ListView_GetFirstSelection(HWND p_listview) { + return ListView_GetNextItem(p_listview, -1, LVNI_SELECTED); +} + +int ListView_GetSingleSelection(HWND p_listview) { + if (ListView_GetSelectedCount(p_listview) != 1) return -1; + return ListView_GetFirstSelection(p_listview); +} + +int ListView_GetFocusItem(HWND p_listview) { + return ListView_GetNextItem(p_listview, -1, LVNI_FOCUSED); +} + +bool ListView_IsItemSelected(HWND p_listview, int p_index) { + return ListView_GetItemState(p_listview, p_index, LVIS_SELECTED) != 0; +} + +int ListView_GetColumnCount(HWND listView) { + HWND header = ListView_GetHeader(listView); + PFC_ASSERT(header != NULL); + return Header_GetItemCount(header); +} + +void ListView_FixContextMenuPoint(CListViewCtrl list, CPoint & coords) { + if (coords == CPoint(-1, -1)) { + int selWalk = -1; + CRect rcClient; WIN32_OP_D(list.GetClientRect(rcClient)); + for (;;) { + selWalk = list.GetNextItem(selWalk, LVNI_SELECTED); + if (selWalk < 0) { + CRect rc; + WIN32_OP_D(list.GetWindowRect(&rc)); + coords = rc.CenterPoint(); + return; + } + CRect rcItem, rcVisible; + WIN32_OP_D(list.GetItemRect(selWalk, &rcItem, LVIR_BOUNDS)); + if (rcVisible.IntersectRect(rcItem, rcClient)) { + coords = rcVisible.CenterPoint(); + WIN32_OP_D(list.ClientToScreen(&coords)); + return; + } + } + } +} + +unsigned CListViewCtrlEx::GetColunnCount() { + return (unsigned) ListView_GetColumnCount( *this ); +} +unsigned CListViewCtrlEx::AddColumnEx(const wchar_t * name, unsigned widthDLU) { + return InsertColumnEx( GetColunnCount(), name, widthDLU ); +} +unsigned CListViewCtrlEx::InsertColumnEx(unsigned index, const wchar_t * name, unsigned widthDLU) { + + RECT rect = { 0,0,(LONG)widthDLU,0 }; + MapDialogRect(GetParent(), &rect); + + LVCOLUMN data = {}; + data.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_FMT; + data.fmt = LVCFMT_LEFT; + data.cx = rect.right; + data.pszText = const_cast(name); + + auto ret = this->InsertColumn(index, & data ); + if (ret < 0) return UINT_MAX; + else return (unsigned)ret; +} + +void CListViewCtrlEx::FixContextMenuPoint(CPoint & pt) { + ListView_FixContextMenuPoint(*this, pt); +} + + + +unsigned CListViewCtrlEx::InsertString(unsigned index, const wchar_t * str) { + LVITEM item = {}; + + item.mask = LVIF_TEXT; + item.iItem = index; + item.pszText = const_cast(str); + + auto ret = InsertItem(&item); + if ( ret < 0 ) return UINT_MAX; + else return (unsigned) ret; +} +unsigned CListViewCtrlEx::InsertString8(unsigned index, const char * str) { + return InsertString(index, pfc::stringcvt::string_os_from_utf8( str ) ); +} +unsigned CListViewCtrlEx::AddString(const wchar_t * str) { + return InsertString(GetItemCount(), str); +} +unsigned CListViewCtrlEx::AddString8(const char * str) { + return AddString(pfc::stringcvt::string_os_from_utf8( str ) ); +} +void CListViewCtrlEx::SetItemText(unsigned iItem, unsigned iSubItem, const wchar_t * str) { + LVITEM item = {}; + item.mask = LVIF_TEXT; + item.iItem = iItem; + item.iSubItem = iSubItem; + item.pszText = const_cast(str); + SetItem(&item); +} +void CListViewCtrlEx::SetItemText8(unsigned item, unsigned subItem, const char * str) { + SetItemText( item, subItem, pfc::stringcvt::string_os_from_utf8( str ) ); +} + + +DWORD CHeaderCtrlEx::GetItemFormat(int iItem) { + HDITEM item = {}; + item.mask = HDI_FORMAT; + if (!this->GetItem(iItem, &item)) return 0; + return item.fmt; +} +void CHeaderCtrlEx::SetItemFormat(int iItem, DWORD flags) { + HDITEM item = {}; + item.mask = HDI_FORMAT; + item.fmt = flags; + SetItem(iItem, &item); +} + +void CHeaderCtrlEx::SetItemSort(int iItem, int direction) { + DWORD fmtWas = GetItemFormat(iItem); + DWORD fmt = fmtWas & ~(HDF_SORTDOWN | HDF_SORTUP); + if (direction > 0) fmt |= HDF_SORTDOWN; + else if (direction < 0) fmt |= HDF_SORTUP; + if (fmt != fmtWas) SetItemFormat(iItem, fmt); +} + +void CHeaderCtrlEx::SetSingleItemSort(int iItem, int direction) { + const int total = GetItemCount(); + for (int walk = 0; walk < total; ++walk) { + SetItemSort(walk, walk == iItem ? direction : 0); + } +} + +void CHeaderCtrlEx::ClearSort() { + SetSingleItemSort(-1,0); +} + +int CListViewCtrlEx::AddGroup(int iGroupID, const wchar_t * header) { + LVGROUP g = { sizeof(g) }; + g.mask = LVGF_HEADER | LVGF_GROUPID; + g.pszHeader = const_cast( header ); + g.iGroupId = iGroupID; + return __super::AddGroup(&g); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/listview_helper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/listview_helper.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,37 @@ +#pragma once + +namespace listview_helper +{ + unsigned insert_item(HWND p_listview,unsigned p_index,const char * p_name,LPARAM p_param);//returns index of new item on success, infinite on failure + + unsigned insert_column(HWND p_listview,unsigned p_index,const char * p_name,unsigned p_width_dlu);//returns index of new item on success, infinite on failure + + bool set_item_text(HWND p_listview,unsigned p_index,unsigned p_column,const char * p_name); + + bool is_item_selected(HWND p_listview,unsigned p_index); + + void set_item_selection(HWND p_listview,unsigned p_index,bool p_state); + + bool select_single_item(HWND p_listview,unsigned p_index); + + bool ensure_visible(HWND p_listview,unsigned p_index); + + void get_item_text(HWND p_listview,unsigned p_index,unsigned p_column,pfc::string_base & p_out); + + unsigned insert_item2(HWND p_listview, unsigned p_index, const char * col0, const char * col1, LPARAM p_param = 0); + unsigned insert_item3(HWND p_listview, unsigned p_index, const char * col0, const char * col1, const char * col2, LPARAM p_param = 0); + + +}; + +int ListView_GetFirstSelection(HWND p_listview); +int ListView_GetSingleSelection(HWND p_listview); +int ListView_GetFocusItem(HWND p_listview); +bool ListView_IsItemSelected(HWND p_listview, int p_index); + +void ListView_GetContextMenuPoint(HWND p_list,LPARAM p_coords,POINT & p_point,int & p_selection); +void ListView_GetContextMenuPoint(HWND p_list,POINT p_coords,POINT & p_point,int & p_selection); + +int ListView_GetColumnCount(HWND listView); + +void ListView_FixContextMenuPoint(CListViewCtrl list, CPoint & coords); \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/pp-COM-macros.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/pp-COM-macros.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,13 @@ +#pragma once + +#define COM_QI_BEGIN() HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid,void ** ppvObject) override { if (ppvObject == NULL) return E_INVALIDARG; +#define COM_QI_ENTRY(IWhat) { if (iid == __uuidof(IWhat)) {IWhat * temp = this; temp->AddRef(); * ppvObject = temp; return S_OK;} } +#define COM_QI_ENTRY_(IWhat, IID) { if (iid == IID) {IWhat * temp = this; temp->AddRef(); * ppvObject = temp; return S_OK;} } +#define COM_QI_END() * ppvObject = NULL; return E_NOINTERFACE; } + +#define COM_QI_CHAIN(Parent) { HRESULT status = Parent::QueryInterface(iid, ppvObject); if (SUCCEEDED(status)) return status; } + +#define COM_QI_SIMPLE(IWhat) COM_QI_BEGIN() COM_QI_ENTRY(IUnknown) COM_QI_ENTRY(IWhat) COM_QI_END() + + +#define PP_COM_CATCH catch(exception_com const & e) {return e.get_code();} catch(std::bad_alloc) {return E_OUTOFMEMORY;} catch(pfc::exception_invalid_params) {return E_INVALIDARG;} catch(...) {return E_UNEXPECTED;} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/stdafx.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/stdafx.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,1 @@ +#include "stdafx.h" diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/stdafx.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/stdafx.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,26 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#pragma once + +#include "targetver.h" + +#define _SECURE_ATL 1 + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + +#ifndef _UNICODE +#error seriously? +#endif \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/targetver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/targetver.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,6 @@ +#pragma once + +#ifndef _WIN32_WINNT +#define _WIN32_WINNT 0x0601 +#include +#endif \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/win32_op.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/win32_op.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,37 @@ +#include "stdafx.h" +#include "win32_op.h" +#include + +PFC_NORETURN PFC_NOINLINE void WIN32_OP_FAIL() { + const DWORD code = GetLastError(); + PFC_ASSERT(code != NO_ERROR); + throw exception_win32(code); +} + +PFC_NORETURN PFC_NOINLINE void WIN32_OP_FAIL_CRITICAL(const char * what) { + (void)what; +#if PFC_DEBUG + const DWORD code = GetLastError(); + PFC_ASSERT(code != NO_ERROR); +#endif + pfc::crash(); +#if 0 + pfc::string_formatter msg; msg << what << " failure #" << (uint32_t)code; + TRACK_CODE(msg.get_ptr(), uBugCheck()); +#endif +} + +#if PFC_DEBUG +void WIN32_OP_D_FAIL(const wchar_t * _Message, const wchar_t *_File, unsigned _Line) { + const DWORD code = GetLastError(); + pfc::array_t msgFormatted; msgFormatted.set_size(pfc::strlen_t(_Message) + 64); + wsprintfW(msgFormatted.get_ptr(), L"%s (code: %u)", _Message, code); + if (IsDebuggerPresent()) { + OutputDebugString(TEXT("WIN32_OP_D() failure:\n")); + OutputDebugString(msgFormatted.get_ptr()); + OutputDebugString(TEXT("\n")); + pfc::crash(); + } + _wassert(msgFormatted.get_ptr(), _File, _Line); +} +#endif diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/win32_op.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/win32_op.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,36 @@ +#pragma once + +PFC_NORETURN PFC_NOINLINE void WIN32_OP_FAIL(); +PFC_NORETURN PFC_NOINLINE void WIN32_OP_FAIL_CRITICAL(const char * what); + +#ifdef _DEBUG +void WIN32_OP_D_FAIL(const wchar_t * _Message, const wchar_t *_File, unsigned _Line); +#endif + +//Throws an exception when (OP) evaluates to false/zero. +#define WIN32_OP(OP) \ + { \ + SetLastError(NO_ERROR); \ + if (!(OP)) WIN32_OP_FAIL(); \ + } + +// Kills the application with appropriate debug info when (OP) evaluates to false/zero. +#define WIN32_OP_CRITICAL(WHAT, OP) \ + { \ + SetLastError(NO_ERROR); \ + if (!(OP)) WIN32_OP_FAIL_CRITICAL(WHAT); \ + } + +//WIN32_OP_D() acts like an assert specialized for win32 operations in debug build, ignores the return value / error codes in release build. +//Use WIN32_OP_D() instead of WIN32_OP() on operations that are extremely unlikely to fail, so failure condition checks are performed in the debug build only, to avoid bloating release code with pointless error checks. +#ifdef _DEBUG +#define WIN32_OP_D(OP) \ + { \ + SetLastError(NO_ERROR); \ + if (!(OP)) WIN32_OP_D_FAIL(PFC_WIDESTRING(#OP), PFC_WIDESTRING(__FILE__), __LINE__); \ + } + +#else +#define WIN32_OP_D(OP) (void)( (OP), 0); +#endif + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/win32_utility.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/win32_utility.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,390 @@ +#include "stdafx.h" +#include "win32_utility.h" +#include "win32_op.h" +#include + +SIZE QueryContextDPI(HDC dc) { + return {GetDeviceCaps(dc,LOGPIXELSX), GetDeviceCaps(dc,LOGPIXELSY)}; +} +unsigned QueryScreenDPI(HWND wnd) { + HDC dc = GetDC(wnd); + unsigned ret = GetDeviceCaps(dc, LOGPIXELSY); + ReleaseDC(wnd, dc); + return ret; +} +unsigned QueryScreenDPI_X(HWND wnd) { + HDC dc = GetDC(wnd); + unsigned ret = GetDeviceCaps(dc, LOGPIXELSX); + ReleaseDC(wnd, dc); + return ret; +} +unsigned QueryScreenDPI_Y(HWND wnd) { + HDC dc = GetDC(wnd); + unsigned ret = GetDeviceCaps(dc, LOGPIXELSY); + ReleaseDC(wnd, dc); + return ret; +} + +SIZE QueryScreenDPIEx(HWND wnd) { + HDC dc = GetDC(wnd); + SIZE ret = { GetDeviceCaps(dc,LOGPIXELSX), GetDeviceCaps(dc,LOGPIXELSY) }; + ReleaseDC(wnd, dc); + return ret; +} + +void HeaderControl_SetSortIndicator(HWND header_, int column, bool isUp) { + CHeaderCtrl header(header_); + const int total = header.GetItemCount(); + for (int walk = 0; walk < total; ++walk) { + HDITEM item = {}; item.mask = HDI_FORMAT; + if (header.GetItem(walk, &item)) { + auto newFormat = item.fmt; + newFormat &= ~(HDF_SORTUP | HDF_SORTDOWN); + if (walk == column) { + newFormat |= isUp ? HDF_SORTUP : HDF_SORTDOWN; + } + if (newFormat != item.fmt) { + item.fmt = newFormat; + header.SetItem(walk, &item); + } + } + } +} + +HINSTANCE GetThisModuleHandle() { + return (HINSTANCE)_AtlBaseModule.m_hInst; +} + +WinResourceRef_t WinLoadResource(HMODULE hMod, const TCHAR * name, const TCHAR * type, WORD wLang) { + SetLastError(0); + HRSRC res = wLang ? FindResourceEx(hMod, type, name, wLang) : FindResource(hMod, name, type); + if ( res == NULL ) WIN32_OP_FAIL(); + SetLastError(0); + HGLOBAL hglob = LoadResource(hMod, res); + if ( hglob == NULL ) WIN32_OP_FAIL(); + SetLastError(0); + void * ptr = LockResource(hglob); + if ( ptr == nullptr ) WIN32_OP_FAIL(); + WinResourceRef_t ref; + ref.ptr = ptr; + ref.bytes = SizeofResource(hMod, res); + return ref; +} + +CComPtr WinLoadResourceAsStream(HMODULE hMod, const TCHAR * name, const TCHAR * type, WORD wLang) { + auto res = WinLoadResource(hMod, name, type, wLang ); + auto str = SHCreateMemStream( (const BYTE*) res.ptr, (UINT) res.bytes ); + if ( str == nullptr ) throw std::bad_alloc(); + CComPtr ret; + ret.Attach( str ); + return ret; +} + +UINT GetFontHeight(HFONT font) +{ + UINT ret; + HDC dc = CreateCompatibleDC(0); + SelectObject(dc, font); + ret = GetTextHeight(dc); + DeleteDC(dc); + return ret; +} + +UINT GetTextHeight(HDC dc) +{ + TEXTMETRIC tm; + POINT pt[2]; + GetTextMetrics(dc, &tm); + pt[0].x = 0; + pt[0].y = tm.tmHeight; + pt[1].x = 0; + pt[1].y = 0; + LPtoDP(dc, pt, 2); + + int ret = pt[0].y - pt[1].y; + return ret > 1 ? (unsigned)ret : 1; +} + + +LRESULT RelayEraseBkgnd(HWND p_from, HWND p_to, HDC p_dc) { + + CDCHandle dc(p_dc); + DCStateScope scope(dc); + CRect client; + if (GetClientRect(p_from, client)) { + dc.IntersectClipRect(client); + } + + LRESULT status; + POINT pt = { 0, 0 }, pt_old = { 0,0 }; + MapWindowPoints(p_from, p_to, &pt, 1); + OffsetWindowOrgEx(p_dc, pt.x, pt.y, &pt_old); + status = SendMessage(p_to, WM_ERASEBKGND, (WPARAM)p_dc, 0); + SetWindowOrgEx(p_dc, pt_old.x, pt_old.y, 0); + return status; +} + +static LRESULT CALLBACK EraseHandlerProc( + HWND hWnd, + UINT uMsg, + WPARAM wParam, + LPARAM lParam, + UINT_PTR uIdSubclass, + DWORD_PTR dwRefData +) { + if (uMsg == WM_ERASEBKGND) { + HWND wndTarget = reinterpret_cast(dwRefData); + PFC_ASSERT(wndTarget != NULL); + return RelayEraseBkgnd(hWnd, wndTarget, (HDC)wParam); + } + return DefSubclassProc(hWnd, uMsg, wParam, lParam); +} + +static LRESULT CALLBACK CtlColorProc( + HWND hWnd, + UINT uMsg, + WPARAM wParam, + LPARAM lParam, + UINT_PTR uIdSubclass, + DWORD_PTR dwRefData +) { + switch (uMsg) { + case WM_CTLCOLORMSGBOX: + case WM_CTLCOLOREDIT: + case WM_CTLCOLORLISTBOX: + case WM_CTLCOLORBTN: + case WM_CTLCOLORDLG: + case WM_CTLCOLORSCROLLBAR: + case WM_CTLCOLORSTATIC: + return SendMessage(GetParent(hWnd), uMsg, wParam, lParam); + default: + return DefSubclassProc(hWnd, uMsg, wParam, lParam); + } +} + + +void InjectEraseHandler(HWND wnd, HWND sendTo) { + PFC_ASSERT(sendTo != NULL); + WIN32_OP_D(SetWindowSubclass(wnd, EraseHandlerProc, 0, reinterpret_cast(sendTo))); +} +void InjectParentEraseHandler(HWND wnd) { + InjectEraseHandler(wnd, GetParent(wnd)); +} +void InjectParentCtlColorHandler(HWND wnd) { + WIN32_OP_D(SetWindowSubclass(wnd, CtlColorProc, 0, 0)); +} +static LRESULT CALLBACK BounceNextDlgCtlProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData) { + if (uMsg == WM_NEXTDLGCTL) { + return ::SendMessage((HWND)dwRefData, uMsg, wParam, lParam); + } + return DefSubclassProc(hWnd, uMsg, wParam, lParam); +} + +void BounceNextDlgCtl(HWND wnd, HWND wndTo) { + ::SetWindowSubclass(wnd, BounceNextDlgCtlProc, 0, (DWORD_PTR)wndTo); +} + + +pfc::string8 EscapeTooltipText(const char * src) +{ + pfc::string8 out; + while (*src) + { + if (*src == '&') + { + out.add_string("&&&"); + src++; + while (*src == '&') + { + out.add_string("&&"); + src++; + } + } else out.add_byte(*(src++)); + } + return out; +} + +bool IsMenuNonEmpty(HMENU menu) { + unsigned n, m = GetMenuItemCount(menu); + for (n = 0; n < m; n++) { + if (GetSubMenu(menu, n)) return true; + if (!(GetMenuState(menu, n, MF_BYPOSITION)&MF_SEPARATOR)) return true; + } + return false; +} + +void SetDefaultMenuItem(HMENU p_menu, unsigned p_id) { + MENUITEMINFO info = { sizeof(info) }; + info.fMask = MIIM_STATE; + GetMenuItemInfo(p_menu, p_id, FALSE, &info); + info.fState |= MFS_DEFAULT; + SetMenuItemInfo(p_menu, p_id, FALSE, &info); +} + +static bool FetchWineInfoAppend(pfc::string_base & out) { + typedef const char *(__cdecl *t_wine_get_build_id)(void); + typedef void(__cdecl *t_wine_get_host_version)(const char **sysname, const char **release); + const HMODULE ntdll = GetModuleHandle(_T("ntdll.dll")); + if (ntdll == NULL) return false; + t_wine_get_build_id wine_get_build_id; + t_wine_get_host_version wine_get_host_version; + wine_get_build_id = (t_wine_get_build_id)GetProcAddress(ntdll, "wine_get_build_id"); + wine_get_host_version = (t_wine_get_host_version)GetProcAddress(ntdll, "wine_get_host_version"); + if (wine_get_build_id == NULL || wine_get_host_version == NULL) { + if (GetProcAddress(ntdll, "wine_server_call") != NULL) { + out << "wine (unknown version)"; + return true; + } + return false; + } + const char * sysname = NULL; const char * release = NULL; + wine_get_host_version(&sysname, &release); + out << wine_get_build_id() << ", on: " << sysname << " / " << release; + return true; +} + +static void GetOSVersionStringAppend(pfc::string_base & out) { + + if (FetchWineInfoAppend(out)) return; + + OSVERSIONINFO ver = {}; ver.dwOSVersionInfoSize = sizeof(ver); + WIN32_OP_D(GetVersionEx(&ver)); + SYSTEM_INFO info = {}; + GetNativeSystemInfo(&info); + + out << "Windows " << (int)ver.dwMajorVersion << "." << (int)ver.dwMinorVersion << "." << (int)ver.dwBuildNumber; + if (ver.szCSDVersion[0] != 0) out << " " << pfc::stringcvt::string_utf8_from_os(ver.szCSDVersion, PFC_TABSIZE(ver.szCSDVersion)); + + switch (info.wProcessorArchitecture) { + case PROCESSOR_ARCHITECTURE_AMD64: + out << " x64"; break; + case PROCESSOR_ARCHITECTURE_IA64: + out << " IA64"; break; + case PROCESSOR_ARCHITECTURE_INTEL: + out << " x86"; break; + case PROCESSOR_ARCHITECTURE_ARM64: + out << " ARM64"; break; + } +} + +void GetOSVersionString(pfc::string_base & out) { + out.reset(); GetOSVersionStringAppend(out); +} +WORD GetOSVersionCode() { + OSVERSIONINFO ver = {sizeof(ver)}; + WIN32_OP_D(GetVersionEx(&ver)); + + DWORD ret = ver.dwMinorVersion; + ret += ver.dwMajorVersion << 8; + + return (WORD)ret; +} + +bool IsWine() { + static bool ret = [] { + HMODULE module = GetModuleHandle(_T("ntdll.dll")); + if (!module) return false; + return GetProcAddress(module, "wine_server_call") != NULL; + } (); + return ret; +} + +static BOOL CALLBACK EnumChildWindowsProc(HWND w, LPARAM p) { + auto f = reinterpret_cast*>(p); + (*f)(w); + return TRUE; +} +void EnumChildWindows(HWND w, std::function f) { + ::EnumChildWindows(w, EnumChildWindowsProc, reinterpret_cast(&f)); +} +void EnumChildWindowsHere(HWND parent, std::function f) { + for (HWND walk = GetWindow(parent, GW_CHILD); walk != NULL; walk = GetWindow(walk, GW_HWNDNEXT)) { + f(walk); + } +} +static DWORD Win10BuildNumber_() { + OSVERSIONINFO ver = { sizeof(ver) }; + WIN32_OP_D(GetVersionEx(&ver)); + return ver.dwMajorVersion == 10 ? ver.dwBuildNumber : 0; +} +DWORD Win10BuildNumber() { + static DWORD b = Win10BuildNumber_(); + return b; +} + +#include "hookWindowMessages.h" +#include + +namespace { + + class CWindowHook_Map : public CWindowImpl { + public: + CMessageMap* m_target = nullptr; + DWORD m_targetID = 0; + + std::vector< DWORD > m_messages; + + void setup(std::initializer_list&& arg) { + m_messages = std::move(arg); + std::sort(m_messages.begin(), m_messages.end()); + } + + bool isMsgWanted(DWORD msg) const { + return std::binary_search(m_messages.begin(), m_messages.end(), msg); + } + BEGIN_MSG_MAP(CWindowHook) + if (isMsgWanted(uMsg)) { + CHAIN_MSG_MAP_ALT_MEMBER((*m_target), m_targetID); + } + END_MSG_MAP() + }; + + class CWindowHook_Proc : public CWindowImpl { + public: + CWindowHook_Proc(PP::messageHook_t proc) : m_proc(proc) {} + const PP::messageHook_t m_proc; + + BEGIN_MSG_MAP(CWindowHook) + if (m_proc(hWnd, uMsg, wParam, lParam, lResult)) return TRUE; + END_MSG_MAP() + }; + +} + +void PP::hookWindowMessages(HWND wnd, CMessageMap* target, DWORD targetID, std::initializer_list&& msgs) { + auto obj = PP::subclassThisWindow< CWindowHook_Map >(wnd); + obj->m_target = target; obj->m_targetID = targetID; + obj->setup(std::move(msgs)); +} +void PP::hookWindowMessages(HWND wnd, messageHook_t h) { + PP::subclassThisWindow< CWindowHook_Proc >(wnd, h); +} + +namespace PP { + static LONG regReadHelper(HKEY root, const wchar_t* path, const wchar_t* value, LONG def) { + wchar_t buf[64] = {}; + DWORD cb = (DWORD)((std::size(buf) - 1) * sizeof(buf[0])); + if (RegGetValue(root, path, value, RRF_RT_REG_SZ, NULL, buf, &cb) == 0) { + return _wtol(buf); + } + return def; + } + + static SIZE querySystemDragThreshold() { + constexpr DWORD def = 1; + static constexpr wchar_t path[] = L"Control Panel\\Desktop"; + return { + (LONG)regReadHelper(HKEY_CURRENT_USER, path, L"DragWidth", def), + (LONG)regReadHelper(HKEY_CURRENT_USER, path, L"DragHeight", def) + }; + } + SIZE queryDragThresholdForDPI(SIZE dpi) { + PFC_ASSERT(dpi.cx > 0 && dpi.cy > 0); + static SIZE sys = {}; + if ( sys.cx == 0 || sys.cy == 0 ) sys = querySystemDragThreshold(); + return { MulDiv(sys.cx, dpi.cx, 96), MulDiv(sys.cy, dpi.cy, 96) }; + } + SIZE queryDragThreshold(HWND wndFor) { + return queryDragThresholdForDPI(QueryScreenDPIEx(wndFor)); + } +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/win32_utility.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/win32_utility.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,58 @@ +#pragma once +#include +#include // CComPtr + +unsigned QueryScreenDPI(HWND wnd = NULL); +unsigned QueryScreenDPI_X(HWND wnd = NULL); +unsigned QueryScreenDPI_Y(HWND wnd = NULL); + +SIZE QueryScreenDPIEx(HWND wnd = NULL); +SIZE QueryContextDPI(HDC dc); + +namespace PP { + // Returns drag threshold, in actual pixels (DPI-corrected), for the specified window + SIZE queryDragThreshold(HWND wndFor); + SIZE queryDragThresholdForDPI(SIZE knownDPI); +} + +void HeaderControl_SetSortIndicator(HWND header, int column, bool isUp); + +HINSTANCE GetThisModuleHandle(); + +struct WinResourceRef_t { + const void * ptr; + size_t bytes; +} ; + +WinResourceRef_t WinLoadResource(HMODULE hMod, const TCHAR * name, const TCHAR * type, WORD wLang = 0); +CComPtr WinLoadResourceAsStream(HMODULE hMod, const TCHAR * name, const TCHAR * type, WORD wLang = 0); + +UINT GetFontHeight(HFONT font); +UINT GetTextHeight(HDC dc); + +LRESULT RelayEraseBkgnd(HWND p_from, HWND p_to, HDC p_dc); + +pfc::string8 EscapeTooltipText(const char * text); + +class CloseHandleScope { +public: + CloseHandleScope(HANDLE handle) throw() : m_handle(handle) {} + ~CloseHandleScope() throw() { CloseHandle(m_handle); } + HANDLE Detach() throw() { return pfc::replace_t(m_handle, INVALID_HANDLE_VALUE); } + HANDLE Get() const throw() { return m_handle; } + void Close() throw() { CloseHandle(Detach()); } + PFC_CLASS_NOT_COPYABLE_EX(CloseHandleScope) +private: + HANDLE m_handle; +}; + +bool IsMenuNonEmpty(HMENU menu); +void SetDefaultMenuItem(HMENU p_menu, unsigned p_id); + +void GetOSVersionString(pfc::string_base & out); +WORD GetOSVersionCode(); +bool IsWine(); +DWORD Win10BuildNumber(); // See https://en.wikipedia.org/wiki/Windows_10_version_history for build number reference + +void EnumChildWindows(HWND, std::function); // Recursive +void EnumChildWindowsHere(HWND, std::function); // Non-recursive \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/windowLifetime.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/windowLifetime.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,44 @@ +#pragma once +#include "ImplementOnFinalMessage.h" +#include "win32_op.h" +#include + +namespace PP { + //! Create a new window object - obj_t derived from CWindowImpl<> etc, with automatic lifetime management, \n + //! OnFinalMessage() is automatically overridden to delete the window object. \n + //! Does NOT create the window itself, it's up to you to call Create() or SubclassWindow() with the returned object. + template + obj_t* newWindowObj(arg_t && ... arg) { + return new ImplementOnFinalMessage(std::forward(arg) ...); + } + + //! Subclass HWND with window class object obj_t deriving from CWindowImpl<> etc, with automatic lifetime management of the object, \n + //! OnFinalMessage() is automatically overridden to delete the window subclass object. + template + obj_t* subclassThisWindow(HWND wnd, arg_t && ... arg) { + PFC_ASSERT( wnd != NULL ); + auto ret = newWindowObj(std::forward(arg) ...); + WIN32_OP_D(ret->SubclassWindow(wnd)); + return ret; + } + + //! Creates a new window object, of ctrl_t typem with automatic lifetime management, + //! and replaces an existing control in a dialog. + template + ctrl_t * replaceDialogCtrl(CWindow wndDialog, UINT replaceControlID) { + CWindow wndReplace = wndDialog.GetDlgItem(replaceControlID); + ATLASSERT(wndReplace != NULL); + CRect rc; + CWindow wndPrev = wndDialog.GetNextDlgTabItem(wndReplace, TRUE); + WIN32_OP_D(wndReplace.GetWindowRect(&rc)); + WIN32_OP_D(wndDialog.ScreenToClient(rc)); + CString text; + wndReplace.GetWindowText(text); + WIN32_OP_D(wndReplace.DestroyWindow()); + auto ctrl = newWindowObj(); + WIN32_OP_D(ctrl->Create(wndDialog, &rc, text, 0, 0, replaceControlID)); + if (wndPrev != NULL) ctrl->SetWindowPos(wndPrev, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE); + ctrl->SetFont(wndDialog.GetFont()); + return ctrl; + } +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/wtl-pp.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/wtl-pp.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,47 @@ +#include "stdafx.h" +#include "wtl-pp.h" + +void CEditPPHooks::DeleteLastWord( CEdit wnd, bool bForward ) { + if ( wnd.GetWindowLong(GWL_STYLE) & ES_READONLY ) return; + CString buffer; + if ( wnd.GetWindowText(buffer) <= 0 ) return; + const int len = buffer.GetLength(); + int selStart = len, selEnd = len; + wnd.GetSel(selStart, selEnd); + if ( selStart < 0 || selStart > len ) selStart = len; // sanity + if ( selEnd < selStart ) selEnd = selStart; // sanity + int work = selStart; + if ( work == selEnd ) { + // Only do our stuff if there is nothing yet selected. Otherwise first delete selection. + if (bForward) { + // go forward (ctrl+del) + if (work < len && isSpecial(buffer[work])) { // linebreaks etc? + do ++ work; while( work < len && isSpecial(buffer[work])); + } else { + // delete apparent spacing + while ( work < len && isWordDelimiter(buffer[work])) ++ work; + // delete apparent word + while ( work < len && (!isWordDelimiter(buffer[work]) && !isSpecial(buffer[work]))) ++ work; + } + + if ( selEnd < work ) { + wnd.SetSel(selEnd, work, TRUE ); + wnd.ReplaceSel( TEXT(""), TRUE ); + } + } else { + // go backward (ctrl+backspace) + if ( work > 0 && isSpecial(buffer[work-1])) { // linebreaks etc? + do --work; while( work > 0 && isSpecial(buffer[work-1])); + } else { + // delete apparent spacing + while( work > 0 && isWordDelimiter(buffer[work-1]) ) --work; + // delete apparent word + while( work > 0 && (!isWordDelimiter(buffer[work-1]) && !isSpecial(buffer[work-1]))) --work; + } + if ( selEnd > work ) { + wnd.SetSel(work, selEnd, TRUE ); + wnd.ReplaceSel( TEXT(""), TRUE ); + } + } + } +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/libPPUI/wtl-pp.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/libPPUI/wtl-pp.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,443 @@ +#pragma once +// Various WTL extensions that are not fb2k specific and can be reused in other WTL based software + +#include +#include + +#define ATLASSERT_SUCCESS(X) {auto RetVal = (X); ATLASSERT( RetVal ); (void) RetVal; } + +#ifdef SubclassWindow // mitigate windowsx.h clash +#undef SubclassWindow +#endif + +class NoRedrawScope { +public: + NoRedrawScope(HWND p_wnd) throw() : m_wnd(p_wnd) { + m_wnd.SetRedraw(FALSE); + } + ~NoRedrawScope() throw() { + m_wnd.SetRedraw(TRUE); + } +private: + CWindow m_wnd; +}; + +class NoRedrawScopeEx { +public: + NoRedrawScopeEx(HWND p_wnd) throw() : m_wnd(p_wnd) { + if (m_wnd.IsWindowVisible()) { + m_active = true; + m_wnd.SetRedraw(FALSE); + } + } + ~NoRedrawScopeEx() throw() { + if (m_active) { + m_wnd.SetRedraw(TRUE); + m_wnd.RedrawWindow(NULL,NULL,RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN); + } + } + NoRedrawScopeEx(const NoRedrawScopeEx&) = delete; + void operator=(const NoRedrawScopeEx&) = delete; +private: + bool m_active = false; + CWindow m_wnd; +}; + +class NoRedrawControl { +public: + CWindow m_wnd; + + void operator++() { + m_count++; + if (m_wnd.IsWindowVisible()) { + m_active = true; + m_wnd.SetRedraw(FALSE); + } + } + void operator--() { + if (--m_count == 0 && m_active) { + m_wnd.SetRedraw(TRUE); + m_wnd.RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_ALLCHILDREN); + m_active = false; + } + } + int m_count = 0; + bool m_active = false; + + NoRedrawControl(HWND wnd = NULL) : m_wnd(wnd) {} + void operator=(const NoRedrawControl&) = delete; + NoRedrawControl(const NoRedrawControl&) = delete; +}; + +LRESULT RelayEraseBkgnd(HWND p_from, HWND p_to, HDC p_dc); +void InjectParentEraseHandler(HWND); +void InjectEraseHandler(HWND, HWND sendTo); +void InjectParentCtlColorHandler(HWND); +void BounceNextDlgCtl(HWND wnd, HWND wndTo); + + + +#define MSG_WM_ERASEBKGND_PARENT() \ + if (uMsg == WM_ERASEBKGND) { \ + lResult = ::RelayEraseBkgnd(hWnd, ::GetParent(hWnd), (HDC)wParam); \ + return TRUE; \ + } + +#define MSG_WM_ERASEBKGND_TO(wndTarget) \ + if (uMsg == WM_ERASEBKGND) { \ + lResult = ::RelayEraseBkgnd(hWnd, wndTarget, (HDC)wParam); \ + return TRUE; \ + } + +#define MSG_WM_TIMER_EX(timerId, func) \ + if (uMsg == WM_TIMER && (UINT_PTR)wParam == timerId) \ + { \ + SetMsgHandled(TRUE); \ + func(); \ + lResult = 0; \ + if(IsMsgHandled()) \ + return TRUE; \ + } + +#define MESSAGE_HANDLER_SIMPLE(msg, func) \ + if(uMsg == msg) \ + { \ + SetMsgHandled(TRUE); \ + func(); \ + lResult = 0; \ + if(IsMsgHandled()) \ + return TRUE; \ + } + +// void OnSysCommandHelp() +#define MSG_WM_SYSCOMMAND_HELP(func) \ + if (uMsg == WM_SYSCOMMAND && wParam == SC_CONTEXTHELP) \ + { \ + SetMsgHandled(TRUE); \ + func(); \ + lResult = 0; \ + if(IsMsgHandled()) \ + return TRUE; \ + } + +//BOOL ProcessWindowMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT& lResult, DWORD dwMsgMapID) +#define END_MSG_MAP_HOOK() \ + break; \ + default: \ + return __super::ProcessWindowMessage(hWnd, uMsg, wParam, lParam, lResult, dwMsgMapID); \ + } \ + return FALSE; \ + } + + +// Obsolete, use CImageListManaged instead +class CImageListContainer : public CImageList { +public: + CImageListContainer() {} + ~CImageListContainer() {Destroy();} + + void operator=(const CImageListContainer&) = delete; + CImageListContainer(const CImageListContainer&) = delete; +}; + + +template class CThemeT { +public: + CThemeT(HTHEME source = NULL) : m_theme(source) {} + + ~CThemeT() { + Release(); + } + + HTHEME OpenThemeData(HWND wnd,LPCWSTR classList) { + Release(); + return m_theme = ::OpenThemeData(wnd, classList); + } + + void Release() { + HTHEME releaseme = pfc::replace_null_t(m_theme); + if (managed && releaseme != NULL) CloseThemeData(releaseme); + } + + operator HTHEME() const {return m_theme;} + HTHEME m_theme; +}; +typedef CThemeT CThemeHandle; +typedef CThemeT CTheme; + + +class CCheckBox : public CButton { +public: + void ToggleCheck(bool state) {SetCheck(state ? BST_CHECKED : BST_UNCHECKED);} + bool IsChecked() const {return GetCheck() == BST_CHECKED;} + + CCheckBox(HWND hWnd = NULL) : CButton(hWnd) { } + CCheckBox & operator=(HWND wnd) {m_hWnd = wnd; return *this; } +}; + +class CEditPPHooks : public CWindowImpl { +public: + bool HandleCtrlA = true, NoEscSteal = false, NoEnterSteal = false, WantAllKeys = false; + + std::function onEnterKey; + std::function onEscKey; + + CEditPPHooks(CMessageMap * hookMM = nullptr, int hookMMID = 0) : m_hookMM(hookMM), m_hookMMID(hookMMID) {} + + BEGIN_MSG_MAP_EX(CEditPPHooks) + MSG_WM_KEYDOWN(OnKeyDown) + MSG_WM_CHAR(OnChar) + MSG_WM_GETDLGCODE(OnEditGetDlgCode) + + if ( m_hookMM != nullptr ) { + + CHAIN_MSG_MAP_ALT_MEMBER( ( * m_hookMM ), m_hookMMID ); + + } + + END_MSG_MAP() + + static void DeleteLastWord( CEdit wnd, bool bForward = false ); +private: + static bool isSpecial( wchar_t c ) { + return (unsigned) c < ' '; + } + static bool isWordDelimiter( wchar_t c ) { + return c == ' ' || c == ',' || c == '.' || c == ';' || c == ':'; + } + void OnChar(UINT nChar, UINT, UINT nFlags) { + if (m_suppressChar != 0) { + if (nChar == m_suppressChar) return; + } + if (m_suppressScanCode != 0) { + UINT code = nFlags & 0xFF; + if (code == m_suppressScanCode) return; + } + SetMsgHandled(FALSE); + } + void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { + (void)nRepCnt; + m_suppressChar = 0; + m_suppressScanCode = 0; + if (HandleCtrlA) { + if (nChar == 'A') { + if (GetHotkeyModifierFlags() == MOD_CONTROL) { + m_suppressScanCode = nFlags & 0xFF; + this->SetSelAll(); return; + } + } + if ( nChar == VK_BACK ) { + if (GetHotkeyModifierFlags() == MOD_CONTROL) { + m_suppressScanCode = nFlags & 0xFF; + DeleteLastWord( *this ) ; return; + } + } + if ( nChar == VK_DELETE ) { + if (GetHotkeyModifierFlags() == MOD_CONTROL) { + m_suppressScanCode = nFlags & 0xFF; + DeleteLastWord( *this, true ) ; return; + } + } + if ( nChar == VK_RETURN && onEnterKey ) { + m_suppressChar = nChar; + onEnterKey(); return; + } + if ( nChar == VK_ESCAPE && onEscKey ) { + m_suppressChar = nChar; + onEscKey(); return; + } + } + SetMsgHandled(FALSE); + } + UINT OnEditGetDlgCode(LPMSG lpMsg) { + if (WantAllKeys) return DLGC_WANTALLKEYS; + if (lpMsg == NULL) { + SetMsgHandled(FALSE); return 0; + } else { + switch(lpMsg->message) { + case WM_KEYDOWN: + case WM_SYSKEYDOWN: + switch(lpMsg->wParam) { + case VK_ESCAPE: + if (onEscKey) { + return DLGC_WANTMESSAGE; + } + SetMsgHandled(!!NoEscSteal); + return 0; + case VK_RETURN: + if (onEnterKey) { + return DLGC_WANTMESSAGE; + } + SetMsgHandled(!!NoEnterSteal); + return 0; + default: + SetMsgHandled(FALSE); return 0; + } + default: + SetMsgHandled(FALSE); return 0; + + } + } + } + UINT m_suppressChar = 0, m_suppressScanCode = 0; + CMessageMap * const m_hookMM; + const int m_hookMMID; +}; + + +class CEditNoEscSteal : public CEdit { +public: + void SubclassWindow(HWND wnd) { + this->Attach(wnd); + SubclassThisWindow(wnd); + } + static void SubclassThisWindow(HWND wnd) { + SetWindowSubclass(wnd, proc, 0, 0); + } +private: + static LRESULT CALLBACK proc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR, DWORD_PTR) { + if ( uMsg == WM_GETDLGCODE ) { + auto lpMsg = reinterpret_cast(lParam); + if (lpMsg != NULL) { + switch(lpMsg->message) { + case WM_KEYDOWN: + case WM_SYSKEYDOWN: + switch(lpMsg->wParam) { + case VK_ESCAPE: + return 0; + } + } + } + } + return DefSubclassProc(hWnd, uMsg, wParam, lParam); + } +}; + +class CEditNoEnterEscSteal : public CEdit { +public: + void SubclassWindow(HWND wnd) { + this->Attach(wnd); + SubclassThisWindow(wnd); + } + static void SubclassThisWindow(HWND wnd) { + SetWindowSubclass(wnd, proc, 0, 0); + } +private: + static LRESULT CALLBACK proc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR, DWORD_PTR) { + if ( uMsg == WM_GETDLGCODE ) { + auto lpMsg = reinterpret_cast(lParam); + if (lpMsg != NULL) { + switch(lpMsg->message) { + case WM_KEYDOWN: + case WM_SYSKEYDOWN: + switch(lpMsg->wParam) { + case VK_RETURN: + case VK_ESCAPE: + return 0; + } + } + } + } + return DefSubclassProc(hWnd, uMsg, wParam, lParam); + } +}; + + + +class CWindowClassUnregisterScope { +public: + CWindowClassUnregisterScope() : name() {} + const TCHAR * name; + void Set(const TCHAR * n) {ATLASSERT( name == NULL ); name = n; } + bool IsActive() const {return name != NULL;} + void CleanUp() { + const TCHAR * n = name; name = NULL; + if (n != NULL) ATLASSERT_SUCCESS( UnregisterClass(n, (HINSTANCE)&__ImageBase) ); + } + ~CWindowClassUnregisterScope() {CleanUp();} +}; + + +// CWindowRegisteredT +// Minimalistic wrapper for registering own window classes that can be created by class name, included in dialogs and such. +// Usage: +// class myClass : public CWindowRegisteredT {...}; +// Call myClass::Register() before first use +template +class CWindowRegisteredT : public TBaseClass, public CMessageMap { +public: + static UINT GetClassStyle() { + return CS_VREDRAW | CS_HREDRAW; + } + static HCURSOR GetCursor() { + return ::LoadCursor(NULL, IDC_ARROW); + } + + BEGIN_MSG_MAP_EX(CWindowRegisteredT) + END_MSG_MAP() + + + static void Register() { + static CWindowClassUnregisterScope scope; + if (!scope.IsActive()) { + WNDCLASS wc = {}; + wc.style = TClass::GetClassStyle(); + wc.cbWndExtra = sizeof(void*); + wc.lpszClassName = TClass::GetClassName(); + wc.lpfnWndProc = myWindowProc; + wc.hInstance = (HINSTANCE)&__ImageBase; + wc.hCursor = TClass::GetCursor(); + ATLASSERT_SUCCESS( RegisterClass(&wc) != 0 ); + scope.Set(wc.lpszClassName); + } + } +protected: + virtual ~CWindowRegisteredT() {} +private: + static LRESULT CALLBACK myWindowProc(HWND wnd, UINT msg, WPARAM wp, LPARAM lp) { + TClass * i = NULL; + if (msg == WM_NCCREATE) { + i = new TClass; + i->Attach(wnd); + ::SetWindowLongPtr(wnd, 0, reinterpret_cast(i)); + } else { + i = reinterpret_cast( ::GetWindowLongPtr(wnd, 0) ); + } + LRESULT r; + if (i == NULL || !i->ProcessWindowMessage(wnd, msg, wp, lp, r)) r = ::DefWindowProc(wnd, msg, wp, lp); + if (msg == WM_NCDESTROY) { + ::SetWindowLongPtr(wnd, 0, 0); + delete i; + } + return r; + } +}; + + + + +class CSRWlock { +public: + CSRWlock() { } + + static bool HaveAPI() { return true; } + + void EnterShared() { + AcquireSRWLockShared( & theLock ); + } + void EnterExclusive() { + AcquireSRWLockExclusive( & theLock ); + } + void LeaveShared() { + ReleaseSRWLockShared( & theLock ); + } + void LeaveExclusive() { + ReleaseSRWLockExclusive( &theLock ); + } + +private: + CSRWlock(const CSRWlock&) = delete; + void operator=(const CSRWlock&) = delete; + + SRWLOCK theLock = {}; +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/CFObject.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/CFObject.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,59 @@ +#pragma once + +#include + +namespace pfc { + template + class CFObject { + public: + typedef CFObject self_t; + type_t p = NULL; + + ~CFObject() { + if ( p ) CFRelease(p); + } + + void Retain(type_t arg) { + if ( p ) CFRelease(p); + p = arg; + if ( p ) CFRetain(p); + } + + void Attach(type_t arg) { + if ( p ) CFRelease(p); + p = arg; + } + + void operator=( self_t const & arg ) { + if ( p ) CFRelease(p); + p = arg.p; + if ( p ) CFRetain(p); + } + CFObject() {} + CFObject( self_t const & arg ) { + p = arg.p; + if ( p ) CFRetain(p); + } + + CFObject(self_t && arg ) { + p = arg.p; arg.p = NULL; + } + void operator=(self_t && arg) { + if ( p ) CFRelease(p); + p = arg.p; arg.p = NULL; + } + + operator bool() const { return p != NULL; } + operator type_t() const { return p;} + + + void reset() { + if ( p ) CFRelease(p); + p = NULL; + } + + void operator=(nullptr_t) { + reset(); + } + }; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/SmartStrStr-table.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/SmartStrStr-table.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,382 @@ +#pragma once + +namespace { + struct mapping_t { + uint16_t from, to; + }; +} + +static constexpr mapping_t SmartStrStrTable[] = { + {160,32}, + {161,33}, + {162,99}, + {164,36}, + {165,89}, + {166,124}, + {169,67}, + {170,97}, + {171,60}, + {173,45}, + {174,82}, + {178,50}, + {179,51}, + {183,46}, + {184,44}, + {185,49}, + {186,111}, + {187,62}, + {192,65}, + {193,65}, + {194,65}, + {195,65}, + {196,65}, + {197,65}, + {198,65}, + {199,67}, + {200,69}, + {201,69}, + {202,69}, + {203,69}, + {204,73}, + {205,73}, + {206,73}, + {207,73}, + {208,68}, + {209,78}, + {210,79}, + {211,79}, + {212,79}, + {213,79}, + {214,79}, + {216,79}, + {217,85}, + {218,85}, + {219,85}, + {220,85}, + {221,89}, + {224,97}, + {225,97}, + {226,97}, + {227,97}, + {228,97}, + {229,97}, + {230,97}, + {231,99}, + {232,101}, + {233,101}, + {234,101}, + {235,101}, + {236,105}, + {237,105}, + {238,105}, + {239,105}, + {241,110}, + {242,111}, + {243,111}, + {244,111}, + {245,111}, + {246,111}, + {248,111}, + {249,117}, + {250,117}, + {251,117}, + {252,117}, + {253,121}, + {255,121}, + {256,65}, + {257,97}, + {258,65}, + {259,97}, + {260,65}, + {261,97}, + {262,67}, + {263,99}, + {264,67}, + {265,99}, + {266,67}, + {267,99}, + {268,67}, + {269,99}, + {270,68}, + {271,100}, + {272,68}, + {273,100}, + {274,69}, + {275,101}, + {276,69}, + {277,101}, + {278,69}, + {279,101}, + {280,69}, + {281,101}, + {282,69}, + {283,101}, + {284,71}, + {285,103}, + {286,71}, + {287,103}, + {288,71}, + {289,103}, + {290,71}, + {291,103}, + {292,72}, + {293,104}, + {294,72}, + {295,104}, + {296,73}, + {297,105}, + {298,73}, + {299,105}, + {300,73}, + {301,105}, + {302,73}, + {303,105}, + {304,73}, + {305,105}, + {308,74}, + {309,106}, + {310,75}, + {311,107}, + {313,76}, + {314,108}, + {315,76}, + {316,108}, + {317,76}, + {318,108}, + {321,76}, + {322,108}, + {323,78}, + {324,110}, + {325,78}, + {326,110}, + {327,78}, + {328,110}, + {332,79}, + {333,111}, + {334,79}, + {335,111}, + {336,79}, + {337,111}, + {338,79}, + {339,111}, + {340,82}, + {341,114}, + {342,82}, + {343,114}, + {344,82}, + {345,114}, + {346,83}, + {347,115}, + {348,83}, + {349,115}, + {350,83}, + {351,115}, + {352,83}, + {353,115}, + {354,84}, + {355,116}, + {356,84}, + {357,116}, + {358,84}, + {359,116}, + {360,85}, + {361,117}, + {362,85}, + {363,117}, + {364,85}, + {365,117}, + {366,85}, + {367,117}, + {368,85}, + {369,117}, + {370,85}, + {371,117}, + {372,87}, + {373,119}, + {374,89}, + {375,121}, + {376,89}, + {377,90}, + {378,122}, + {379,90}, + {380,122}, + {381,90}, + {382,122}, + {384,98}, + {393,68}, + {401,70}, + {402,102}, + {407,73}, + {410,108}, + {415,79}, + {416,79}, + {417,111}, + {427,116}, + {430,84}, + {431,85}, + {432,117}, + {438,122}, + {461,65}, + {462,97}, + {463,73}, + {464,105}, + {465,79}, + {466,111}, + {467,85}, + {468,117}, + {469,85}, + {470,117}, + {471,85}, + {472,117}, + {473,85}, + {474,117}, + {475,85}, + {476,117}, + {478,65}, + {479,97}, + {484,71}, + {485,103}, + {486,71}, + {487,103}, + {488,75}, + {489,107}, + {490,79}, + {491,111}, + {492,79}, + {493,111}, + {496,106}, + {609,103}, + {697,39}, + {698,34}, + {700,39}, + {708,94}, + {710,94}, + {712,39}, + {715,96}, + {717,95}, + {732,126}, + {768,96}, + {770,94}, + {771,126}, + {782,34}, + {817,95}, + {818,95}, + {8192,32}, + {8193,32}, + {8194,32}, + {8195,32}, + {8196,32}, + {8197,32}, + {8198,32}, + {8208,45}, + {8209,45}, + {8211,45}, + {8212,45}, + {8216,39}, + {8217,39}, + {8218,44}, + {8219,39}, + {8220,34}, + {8221,34}, + {8222,34}, + {8226,46}, + {8230,46}, + {8242,39}, + {8245,96}, + {8249,60}, + {8250,62}, + {8482,84}, + {65281,33}, + {65282,34}, + {65283,35}, + {65284,36}, + {65285,37}, + {65286,38}, + {65287,39}, + {65288,40}, + {65289,41}, + {65290,42}, + {65291,43}, + {65292,44}, + {65293,45}, + {65294,46}, + {65295,47}, + {65296,48}, + {65297,49}, + {65298,50}, + {65299,51}, + {65300,52}, + {65301,53}, + {65302,54}, + {65303,55}, + {65304,56}, + {65305,57}, + {65306,58}, + {65307,59}, + {65308,60}, + {65309,61}, + {65310,62}, + {65312,64}, + {65313,65}, + {65314,66}, + {65315,67}, + {65316,68}, + {65317,69}, + {65318,70}, + {65319,71}, + {65320,72}, + {65321,73}, + {65322,74}, + {65323,75}, + {65324,76}, + {65325,77}, + {65326,78}, + {65327,79}, + {65328,80}, + {65329,81}, + {65330,82}, + {65331,83}, + {65332,84}, + {65333,85}, + {65334,86}, + {65335,87}, + {65336,88}, + {65337,89}, + {65338,90}, + {65339,91}, + {65340,92}, + {65341,93}, + {65342,94}, + {65343,95}, + {65344,96}, + {65345,97}, + {65346,98}, + {65347,99}, + {65348,100}, + {65349,101}, + {65350,102}, + {65351,103}, + {65352,104}, + {65353,105}, + {65354,106}, + {65355,107}, + {65356,108}, + {65357,109}, + {65358,110}, + {65359,111}, + {65360,112}, + {65361,113}, + {65362,114}, + {65363,115}, + {65364,116}, + {65365,117}, + {65366,118}, + {65367,119}, + {65368,120}, + {65369,121}, + {65370,122}, + {65371,123}, + {65372,124}, + {65373,125}, + {65374,126}, +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/SmartStrStr-twoCharMappings.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/SmartStrStr-twoCharMappings.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,49 @@ +#pragma once + +static constexpr struct { + unsigned from; + const char* to; +} twoCharMappings[] = { + {0x00C6, "AE"}, + {0x00E6, "ae"}, + {0x00DF, "ss"}, + +#if 0 + // umlauts + // the problem with these is that changing them to two-letter represenatations prevents search by non-umlaut vowel from working. + {0x00C4, "AE"}, + {0x00E4, "ae"}, + {0x00D6, "OE"}, + {0x00F6, "oe"}, + {0x00DC, "UE"}, + {0x00FC, "ue"}, +#endif + +#if 0 + // Incomplete list, hence disabled. Nobody uses these. + {0x01E2, "AE"}, + {0x01FC, "AE"}, + {0x01E3, "ae"}, + {0x01FD, "ae"}, + {0x0152, "OE"}, + {0x0153, "oe"}, + {0x0276, "oe"}, + {0x01C3, "dz"}, + {0x01C4, "DZ"}, + {0x01C5, "Dz"}, + {0x01C6, "dz"}, + {0x01F1, "DZ"}, + {0x01F2, "Dz"}, + {0x01F3, "dz"}, + {0x02A3, "dz"}, + {0x02A5, "dz"}, + {0x01C7, "LJ"}, + {0x01C8, "Lj"}, + {0x01C9, "lj"}, + {0x01CA, "NJ"}, + {0x01CB, "Nj"}, + {0x01CC, "nj"}, + {0x0132, "IJ"}, + {0x0133, "ij"}, +#endif +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/SmartStrStr.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/SmartStrStr.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,444 @@ +#include "pfc-lite.h" + +#include "string-conv-lite.h" +#include "string_conv.h" +#include "SmartStrStr.h" +#include +#include "SmartStrStr-table.h" +#include "SmartStrStr-twoCharMappings.h" + +bool SmartStrStr::isWordChar(unsigned c) { + // FIX ME map Unicode ranges somehow + return c >= 128 || pfc::char_is_ascii_alphanumeric((char)c); +} + +bool SmartStrStr::isWordChar(const char* ptr) { + unsigned c; + size_t d = pfc::utf8_decode_char(ptr, c); + if (d == 0) return false; // bad UTF-8 + return isWordChar(c); +} + +bool SmartStrStr::isValidWord(const char* ptr) { + if (*ptr == 0) return false; + do { + unsigned c; + size_t d = pfc::utf8_decode_char(ptr, c); + if (d == 0) return false; // bad UTF-8 + if (!isWordChar(c)) return false; + ptr += d; + } while (*ptr != 0); + return true; +} + +void SmartStrStr::findWords(const char* str, std::function cb) { + size_t base = 0, walk = 0; + for (;; ) { + unsigned c = 0; + size_t d = pfc::utf8_decode_char(str + walk, c); + if (d == 0) break; + + if (!SmartStrStr::isWordChar(c)) { + if (walk > base) { + cb(pfc::string_part(str + base, walk - base)); + } + base = walk + d; + } + walk += d; + } + if (walk > base) { + cb(pfc::string_part(str + base, walk - base)); + } +} + +SmartStrStr::SmartStrStr() { + std::map > substitutions, substitutionsReverse; + std::map downconvert; + +#if 1 + for (auto& walk : SmartStrStrTable) { + downconvert[walk.from] = walk.to; + substitutions[walk.from].insert(walk.to); + } +#else + for (uint32_t walk = 128; walk < 0x10000; ++walk) { + uint32_t c = Transform(walk); + if (c != walk) { + downconvert[walk] = c; + substitutions[walk].insert(c); + } + } +#endif + + for (uint32_t walk = 32; walk < 0x10000; ++walk) { + auto lo = ToLower(walk); + if (lo != walk) { + auto & s = substitutions[walk]; s.insert(lo); + + auto iter = substitutions.find(lo); + if (iter != substitutions.end()) { + s.insert(iter->second.begin(), iter->second.end()); + } + } + } + + for( auto & walk : substitutions ) { + for( auto & walk2 : walk.second ) { + substitutionsReverse[walk2].insert(walk.first); + } + } + + this->m_substitutions.initialize(std::move(substitutions)); + this->m_substitutionsReverse.initialize(std::move(substitutionsReverse)); + this->m_downconvert.initialize(std::move(downconvert)); + InitTwoCharMappings(); +} + +// == TEMPLATES == +template const char_t * SmartStrStr::matchHere_(const char_t * pString, const char_t * pUserString) const { + auto walkData = pString; + auto walkUser = pUserString; + for (;; ) { + if (*walkUser == 0) return walkData; + + uint32_t cData, cUser; + size_t dData = pfc::uni_decode_char(walkData, cData); + size_t dUser = pfc::uni_decode_char(walkUser, cUser); + if (dData == 0 || dUser == 0) return nullptr; + + if (cData != cUser) { + bool gotMulti = false; + { + const char * cDataSubst = m_twoCharMappings.query(cData); + if (cDataSubst != nullptr) { + PFC_ASSERT(strlen(cDataSubst) == 2); + if (matchOneChar(cUser, (uint32_t)cDataSubst[0])) { + auto walkUser2 = walkUser + dUser; + uint32_t cUser2; + auto dUser2 = pfc::uni_decode_char(walkUser2, cUser2); + if (matchOneChar(cUser2, (uint32_t)cDataSubst[1])) { + gotMulti = true; + dUser += dUser2; + } + } + } + } + if (!gotMulti) { + if (!matchOneChar(cUser, cData)) return nullptr; + } + } + + walkData += dData; + walkUser += dUser; + } +} +template bool SmartStrStr::equals_( const char_t * pString, const char_t * pUserString) const { + auto p = this->matchHere_(pString, pUserString); + if ( p == nullptr ) return false; + return *p == 0; +} + +template const char_t * SmartStrStr::strStrEnd_(const char_t * pString, const char_t * pSubString, size_t * outFoundAt) const { + size_t walk = 0; + for (;; ) { + if (pString[walk] == 0) return nullptr; + auto end = matchHere_(pString + walk, pSubString); + if (end != nullptr) { + if (outFoundAt != nullptr) * outFoundAt = walk; + return end; + } + + size_t delta = pfc::uni_char_length(pString + walk); + if (delta == 0) return nullptr; + walk += delta; + } +} +// == END TEMPLATES == + +const char16_t * SmartStrStr::matchHere16(const char16_t * pString, const char16_t * pUserString) const { + return this->matchHere_(pString, pUserString); +} +const char * SmartStrStr::matchHere(const char * pString, const char * pUserString) const { + return this->matchHere_(pString, pUserString); +} +const wchar_t * SmartStrStr::matchHereW(const wchar_t * pString, const wchar_t * pUserString) const { + return this->matchHere_(pString, pUserString); +} + +bool SmartStrStr::equals(const char * pString, const char * pUserString) const { + return equals_(pString, pUserString); +} +bool SmartStrStr::equals16(const char16_t* pString, const char16_t* pUserString) const { + return equals_(pString, pUserString); +} +bool SmartStrStr::equalsW( const wchar_t * pString, const wchar_t * pUserString) const { + return equals_(pString, pUserString); +} +const char * SmartStrStr::strStrEnd(const char * pString, const char * pSubString, size_t * outFoundAt) const { + return strStrEnd_(pString, pSubString, outFoundAt); +} + +const char16_t * SmartStrStr::strStrEnd16(const char16_t * pString, const char16_t * pSubString, size_t * outFoundAt) const { + return strStrEnd_(pString, pSubString, outFoundAt); +} + +const wchar_t * SmartStrStr::strStrEndW(const wchar_t * pString, const wchar_t * pSubString, size_t * outFoundAt) const { + return strStrEnd_(pString, pSubString, outFoundAt); +} + +static bool wordBeginsHere(const char* base, size_t offset) { + if (offset == 0) return true; + for (size_t len = 1; len <= offset && len <= 6; --len) { + unsigned c; + if (pfc::utf8_decode_char(base + offset - len, c) == len) { + return !SmartStrStr::isWordChar(c); + } + } + return false; +} + +const char* SmartStrStr::strStrEndWord(const char* pString, const char* pSubString, size_t* outFoundAt) const { + size_t walk = 0; + for (;;) { + size_t foundAt = 0; + auto end = strStrEnd(pString + walk, pSubString, &foundAt); + if (end == nullptr) return nullptr; + foundAt += walk; + if (!isWordChar(end) && wordBeginsHere(pString, foundAt)) { + if (outFoundAt) *outFoundAt = foundAt; + return end; + } + walk = end - pString; + } +} + +bool SmartStrStr::matchOneChar(uint32_t cInput, uint32_t cData) const { + if (cInput == cData) return true; + auto v = m_substitutions.query_ptr(cData); + if (v == nullptr) return false; + return v->count(cInput) > 0; +} + +pfc::string8 SmartStrStr::transformStr(const char* str) const { + pfc::string8 ret; transformStrHere(ret, str); return ret; +} + +void SmartStrStr::transformStrHere(pfc::string8& out, const char* in) const { + transformStrHere(out, in, strlen(in)); +} + +void SmartStrStr::transformStrHere(pfc::string8& out, const char* in, size_t inLen) const { + out.prealloc(inLen); + out.clear(); + for (size_t walk = 0; walk < inLen; ) { + unsigned c; + size_t d = pfc::utf8_decode_char(in + walk, c); + if (d == 0 || walk+d>inLen) break; + walk += d; + const char* alt = m_twoCharMappings.query(c); + if (alt != nullptr) { + out << alt; continue; + } + unsigned alt2 = m_downconvert.query(c); + if (alt2 != 0) { + out.add_char(alt2); continue; + } + out.add_char(c); + } +} + +#if 0 // Windows specific code +uint32_t SmartStrStr::Transform(uint32_t c) { + wchar_t wide[2] = {}; char out[4] = {}; + pfc::utf16_encode_char(c, wide); + BOOL fail = FALSE; + if (WideCharToMultiByte(pfc::stringcvt::codepage_ascii, 0, wide, 2, out, 4, "?", &fail) > 0) { + if (!fail) { + if (out[0] > 0 && out[1] == 0) { + c = out[0]; + } + } + } + return c; +} +#endif + +uint32_t SmartStrStr::ToLower(uint32_t c) { + return pfc::charLower(c); +} + +void SmartStrStr::InitTwoCharMappings() { + std::map mappings; + std::map reverse; + for (auto& walk : twoCharMappings) { + mappings[walk.from] = walk.to; + uint32_t c1, c2; + const char * p = walk.to; + size_t d; + d = pfc::utf8_decode_char(p, c1); + if ( d > 0 ) { + p += d; + d = pfc::utf8_decode_char(p, c2); + if (d > 0) { + if (c1 < 0x10000 && c2 < 0x10000) { + reverse[c1 | (c2 << 16)] = walk.from; + } + } + } + } + m_twoCharMappings.initialize(std::move(mappings)); + m_twoCharMappingsReverse.initialize(std::move(reverse)); +} +bool SmartStrStr::testSubString_prefix(const char* str, const char* sub, const char * prefix, size_t prefixLen) const { + + switch(prefixLen) { + case 0: + return false; + case 1: + for(const char * walk = str;; ) { + walk = strchr(walk, *prefix); + if ( walk == nullptr ) return false; + ++walk; + if (matchHere(walk, sub)) return true; + } + default: + for(const char * walk = str;; ) { + walk = strstr(walk, prefix); + if ( walk == nullptr ) return false; + walk += prefixLen; + if (matchHere(walk, sub)) return true; + } + } +} +bool SmartStrStr::testSubString_prefix(const char* str, const char* sub, uint32_t c) const { + size_t tempLen; + char temp[8]; + tempLen = pfc::utf8_encode_char(c, temp); temp[tempLen] = 0; + return testSubString_prefix(str, sub, temp, tempLen); +} +bool SmartStrStr::testSubString_prefix_subst(const char* str, const char* sub, uint32_t prefix) const { + if ( testSubString_prefix(str, sub, prefix)) return true; + + auto alt = m_substitutionsReverse.query_ptr( prefix ); + if (alt != nullptr) { + for (auto c : *alt) { + if (testSubString_prefix(str, sub, c)) return true; + } + } + + return false; +} +bool SmartStrStr::testSubstring(const char* str, const char* sub) const { +#if 1 + // optimized version for UTF-8 + unsigned prefix; + const size_t skip = pfc::uni_decode_char(sub, prefix); + if ( skip == 0 ) return false; + sub += skip; + + if (testSubString_prefix_subst(str, sub, prefix)) return true; + + unsigned prefix2; + const size_t skip2 = pfc::uni_decode_char(sub, prefix2); + if (skip2 > 0 && prefix < 0x10000 && prefix2 < 0x10000) { + sub += skip2; + auto alt = m_twoCharMappingsReverse.query(prefix | (prefix2 << 16)); + if (alt != 0) { + if (testSubString_prefix_subst(str, sub, alt)) return true; + } + } + + return false; +#else + return this->strStrEnd(str, sub) != nullptr; +#endif +} +bool SmartStrStr::testSubstring16(const char16_t* str, const char16_t* sub) const { + return this->strStrEnd16(str, sub) != nullptr; +} +bool SmartStrStr::testSubstringW( const wchar_t * str, const wchar_t * sub ) const { + return this->strStrEndW(str, sub) != nullptr; +} + +SmartStrStr& SmartStrStr::global() { + static SmartStrStr g; + return g; +} + + +void SmartStrFilter::init(const char* ptr, size_t len) { + pfc::string_formatter current, temp; + bool inQuotation = false; + + auto addCurrent = [&] { + if (!current.is_empty()) { + ++m_items[current.get_ptr()]; current.reset(); + } + }; + + for (t_size walk = 0; walk < len; ++walk) { + const char c = ptr[walk]; + if (c == '\"') inQuotation = !inQuotation; + else if (!inQuotation && is_spacing(c)) { + addCurrent(); + } else { + current.add_byte(c); + } + } + if (inQuotation) { + // Allow unbalanced quotes, take the whole string *with* quotation marks + m_items.clear(); + current.set_string_nc(ptr, len); + } + + addCurrent(); +} + + +bool SmartStrFilter::test_disregardCounts(const char* src) const { + if (m_items.empty()) return false; + + for (auto& walk : m_items) { + if (!dc->strStrEnd(src, walk.first.c_str())) return false; + } + return true; +} + +bool SmartStrFilter::testWords(const char* src) const { + if (m_items.empty()) return false; + + for (auto& walk : m_items) { + const auto count = walk.second; + const auto& str = walk.first; + const auto* strWalk = src; + for (size_t i = 0; i < count; ++i) { + auto next = dc->strStrEndWord(strWalk, str.c_str()); + if (next == nullptr) return false; + strWalk = next; + } + } + return true; +} + +bool SmartStrFilter::test(const char* src) const { + + if (m_items.empty()) return false; + + // Use the faster routine first, it can't be used to count occurances but nobody really knows about this feature + for (auto& walk : m_items) { + if (!dc->testSubstring(src, walk.first.c_str())) return false; + } + // Have any items where specific number of occurances is wanted? + for (auto & walk : m_items) { + const auto count = walk.second; + if (count == 1) continue; + const auto& str = walk.first; + const auto* strWalk = src; + for (size_t i = 0; i < count; ++i) { + auto next = dc->strStrEnd(strWalk, str.c_str()); + if (next == nullptr) return false; + strWalk = next; + } + } + return true; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/SmartStrStr.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/SmartStrStr.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,103 @@ +#pragma once + + +#include +#include +#include +#include +#include "fixed_map.h" + +//! Implementation of string matching for search purposes, such as media library search or typefind in list views. \n +//! Inspired by Unicode asymetic search, but not strictly implementing the Unicode asymetric search specifications. \n +//! \n +//! Keeping a global instance of it is recommended, due to one time init overhead. \n +//! Thread safety: safe to call concurrently once constructed. + +class SmartStrStr { +public: + SmartStrStr(); + + static bool isWordChar(unsigned c); + static bool isWordChar(const char* ptr); + static bool isValidWord(const char*); + static void findWords(const char*, std::function); + + //! Returns ptr to the end of the string if positive (for continuing search), nullptr if negative. + const char * strStrEnd(const char * pString, const char * pSubString, size_t * outFoundAt = nullptr) const; + const char16_t * strStrEnd16(const char16_t * pString, const char16_t * pSubString, size_t * outFoundAt = nullptr) const; + const wchar_t * strStrEndW(const wchar_t * pString, const wchar_t * pSubString, size_t * outFoundAt = nullptr) const; + + const char* strStrEndWord(const char* pString, const char* pSubString, size_t* outFoundAt = nullptr) const; + + bool testSubstring( const char * str, const char * sub ) const; + bool testSubstring16( const char16_t * str, const char16_t * sub ) const; + bool testSubstringW( const wchar_t * str, const wchar_t * sub ) const; + + //! Returns ptr to the end of the string if positive (for continuing search), nullptr if negative. + const char * matchHere(const char * pString, const char * pUserString) const; + const char16_t * matchHere16(const char16_t * pString, const char16_t * pUserString) const; + const wchar_t * matchHereW( const wchar_t * pString, const wchar_t * pUserString) const; + + //! String-equals tool, compares strings rather than searching for occurance + bool equals( const char * pString, const char * pUserString) const; + bool equals16( const char16_t * pString, const char16_t * pUserString) const; + bool equalsW( const wchar_t * pString, const wchar_t * pUserString) const; + + //! One-char match. Doesn't use twoCharMappings, use only if you have to operate on char by char basis rather than call the other methods. + bool matchOneChar(uint32_t cInput, uint32_t cData) const; + + static SmartStrStr& global(); + + pfc::string8 transformStr(const char * str) const; + void transformStrHere(pfc::string8& out, const char* in) const; + void transformStrHere(pfc::string8& out, const char* in, size_t inLen) const; +private: + template const char_t * strStrEnd_(const char_t * pString, const char_t * pSubString, size_t * outFoundAt = nullptr) const; + template const char_t * matchHere_(const char_t * pString, const char_t * pUserString) const; + template bool equals_( const char_t * pString, const char_t * pUserString) const; + + bool testSubString_prefix(const char* str, const char* sub, const char * prefix, size_t prefixLen) const; + bool testSubString_prefix(const char* str, const char* sub, uint32_t c) const; + bool testSubString_prefix_subst(const char* str, const char* sub, uint32_t c) const; + + static uint32_t Transform(uint32_t c); + static uint32_t ToLower(uint32_t c); + + void InitTwoCharMappings(); + + fixed_map< uint32_t, uint32_t > m_downconvert; + fixed_map< uint32_t, std::set > m_substitutions; + fixed_map< uint32_t, std::set > m_substitutionsReverse; + + + fixed_map m_twoCharMappings; + fixed_map m_twoCharMappingsReverse; +}; + + +class SmartStrFilter { +public: + typedef std::map t_stringlist; + SmartStrFilter() { } + SmartStrFilter(t_stringlist const& arg) : m_items(arg) {} + SmartStrFilter(t_stringlist&& arg) : m_items(std::move(arg)) {} + SmartStrFilter(const char* p) { init(p, strlen(p)); } + SmartStrFilter(const char* p, size_t l) { init(p, l); } + + static bool is_spacing(char c) { return c == ' ' || c == 10 || c == 13 || c == '\t'; } + + void init(const char* ptr, size_t len); + void init( const char * ptr ) { init(ptr, strlen(ptr)); } + bool test(const char* src) const; + bool testWords(const char* src) const; + bool test_disregardCounts(const char* src) const; + + const t_stringlist& items() const { return m_items; } + operator bool() const { return !m_items.empty(); } + bool empty() const { return m_items.empty(); } + + SmartStrStr & _SmartStrStr() const { return *dc; } +private: + t_stringlist m_items; + SmartStrStr * dc = &SmartStrStr::global(); +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/alloc.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/alloc.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,541 @@ +#pragma once + +#include "primitives.h" + +namespace pfc { + + static void * raw_malloc(t_size p_size) { + return p_size > 0 ? new_ptr_check_t(malloc(p_size)) : NULL; + } + + static void raw_free(void * p_block) throw() {free(p_block);} + + inline void* raw_realloc(void * p_ptr,t_size p_size) { + if (p_size == 0) {raw_free(p_ptr); return NULL;} + else if (p_ptr == NULL) return raw_malloc(p_size); + else return pfc::new_ptr_check_t(::realloc(p_ptr,p_size)); + } + + inline bool raw_realloc_inplace(void * p_block,t_size p_size) throw() { + if (p_block == NULL) return p_size == 0; +#ifdef _MSC_VER + if (p_size == 0) return false; + return _expand(p_block,p_size) != NULL; +#else + return false; +#endif + } + + template + t_size calc_array_width(t_size p_width) { + return pfc::mul_safe_t(p_width,sizeof(T)); + } + + template + T * __raw_malloc_t(t_size p_size) { + return reinterpret_cast(raw_malloc(calc_array_width(p_size))); + } + + template + void __raw_free_t(T * p_block) throw() { + raw_free(reinterpret_cast(p_block)); + } + + template + T * __raw_realloc_t(T * p_block,t_size p_size) { + return reinterpret_cast(raw_realloc(p_block,calc_array_width(p_size))); + } + + template + bool __raw_realloc_inplace_t(T * p_block,t_size p_size) { + return raw_realloc_inplace(p_block,calc_array_width(p_size)); + } + + + template + inline t_int safe_shift_left_t(t_int p_val,t_size p_shift = 1) { + t_int newval = p_val << p_shift; + if (newval >> p_shift != p_val) throw t_exception(); + return newval; + } + + template class alloc_dummy { + private: typedef alloc_dummy t_self; + public: + alloc_dummy() {} + void set_size(t_size p_size) {throw pfc::exception_not_implemented();} + t_size get_size() const {throw pfc::exception_not_implemented();} + const t_item & operator[](t_size p_index) const {throw pfc::exception_not_implemented();} + t_item & operator[](t_size p_index) {throw pfc::exception_not_implemented();} + + bool is_ptr_owned(const void * p_item) const {return false;} + + //set to true when we prioritize speed over memory usage + enum { alloc_prioritizes_speed = false }; + + //not mandatory + const t_item * get_ptr() const {throw pfc::exception_not_implemented();} + t_item * get_ptr() {throw pfc::exception_not_implemented();} + void prealloc(t_size) {throw pfc::exception_not_implemented();} + void force_reset() {throw pfc::exception_not_implemented();} + void move_from(t_self &) {throw pfc::exception_not_implemented();} + private: + const t_self & operator=(const t_self &) {throw pfc::exception_not_implemented();} + alloc_dummy(const t_self&) {throw pfc::exception_not_implemented();} + }; + + template + bool is_pointer_in_range(const t_item * p_buffer,t_size p_buffer_size,const void * p_pointer) { + return p_pointer >= reinterpret_cast(p_buffer) && p_pointer < reinterpret_cast(p_buffer + p_buffer_size); + } + + + //! Simple inefficient fully portable allocator. + template class alloc_simple { + private: typedef alloc_simple t_self; + public: + alloc_simple() : m_data(NULL), m_size(0) {} + void set_size(t_size p_size) { + if (p_size != m_size) { + t_item * l_data = NULL; + if (p_size > 0) l_data = new t_item[p_size]; + try { + pfc::memcpy_t(l_data,m_data,pfc::min_t(m_size,p_size)); + } catch(...) { + delete[] l_data; + throw; + } + delete[] m_data; + m_data = l_data; + m_size = p_size; + } + } + t_size get_size() const {return m_size;} + const t_item & operator[](t_size p_index) const {PFC_ASSERT(p_index < m_size); return m_data[p_index];} + t_item & operator[](t_size p_index) {PFC_ASSERT(p_index < m_size); return m_data[p_index];} + bool is_ptr_owned(const void * p_item) const {return is_pointer_in_range(get_ptr(),get_size(),p_item);} + + enum { alloc_prioritizes_speed = false }; + + t_item * get_ptr() {return m_data;} + const t_item * get_ptr() const {return m_data;} + + void prealloc(t_size) {} + void force_reset() {set_size(0);} + + ~alloc_simple() {delete[] m_data;} + + void move_from(t_self & other) noexcept { + delete[] m_data; + m_data = replace_null_t(other.m_data); + m_size = replace_null_t(other.m_size); + } + private: + const t_self & operator=(const t_self &) = delete; + alloc_simple(const t_self&) = delete; + + t_item * m_data; + t_size m_size; + }; + + template class __array_fast_helper_t { + private: + typedef __array_fast_helper_t t_self; + public: + __array_fast_helper_t() : m_buffer(NULL), m_size(0), m_size_total(0) {} + + + void set_size(t_size p_size,t_size p_size_total) { + PFC_ASSERT(p_size <= p_size_total); + PFC_ASSERT(m_size <= m_size_total); + if (p_size_total > m_size_total) { + resize_storage(p_size_total); + resize_content(p_size); + } else { + resize_content(p_size); + resize_storage(p_size_total); + } + } + + + + t_size get_size() const {return m_size;} + t_size get_size_total() const {return m_size_total;} + const t_item & operator[](t_size p_index) const {PFC_ASSERT(p_index < m_size); return m_buffer[p_index];} + t_item & operator[](t_size p_index) {PFC_ASSERT(p_index < m_size); return m_buffer[p_index];} + ~__array_fast_helper_t() { + set_size(0,0); + } + t_item * get_ptr() {return m_buffer;} + const t_item * get_ptr() const {return m_buffer;} + bool is_ptr_owned(const void * p_item) const {return is_pointer_in_range(m_buffer,m_size_total,p_item);} + + void move_from(t_self & other) { + set_size(0,0); + m_buffer = replace_null_t(other.m_buffer); + m_size = replace_null_t(other.m_size); + m_size_total = replace_null_t(other.m_size_total); + } + private: + const t_self & operator=(const t_self &) = delete; + __array_fast_helper_t(const t_self &) = delete; + + + void resize_content(t_size p_size) { + if constexpr (traits_t::needs_constructor || traits_t::needs_destructor) { + if (p_size > m_size) {//expand + do { + __unsafe__in_place_constructor_t(m_buffer[m_size]); + m_size++; + } while(m_size < p_size); + } else if (p_size < m_size) { + __unsafe__in_place_destructor_array_t(m_buffer + p_size, m_size - p_size); + m_size = p_size; + } + } else { + m_size = p_size; + } + } + + void resize_storage(t_size p_size) { + PFC_ASSERT( m_size <= m_size_total ); + PFC_ASSERT( m_size <= p_size ); + if (m_size_total != p_size) { + if constexpr (pfc::traits_t::realloc_safe) { + m_buffer = pfc::__raw_realloc_t(m_buffer,p_size); + m_size_total = p_size; + } else if (__raw_realloc_inplace_t(m_buffer,p_size)) { + //success + m_size_total = p_size; + } else { + t_item * newbuffer = pfc::__raw_malloc_t(p_size); + try { + pfc::__unsafe__in_place_constructor_array_copy_t(newbuffer,m_size,m_buffer); + } catch(...) { + pfc::__raw_free_t(newbuffer); + throw; + } + pfc::__unsafe__in_place_destructor_array_t(m_buffer,m_size); + pfc::__raw_free_t(m_buffer); + m_buffer = newbuffer; + m_size_total = p_size; + } + } + } + + t_item * m_buffer; + t_size m_size,m_size_total; + }; + + template class __array_lite_helper_t { + private: + typedef __array_lite_helper_t t_self; + public: + __array_lite_helper_t() : m_buffer(NULL), m_size(0) {} + + + void set_size(t_size p_size) { + if (p_size > m_size) { // expand + resize_storage(p_size); + resize_content(p_size); + } else if (p_size < m_size) { // shrink + resize_content(p_size); + resize_storage(p_size); + } + } + + + + t_size get_size() const {return m_size;} + const t_item & operator[](t_size p_index) const {PFC_ASSERT(p_index < m_size); return m_buffer[p_index];} + t_item & operator[](t_size p_index) {PFC_ASSERT(p_index < m_size); return m_buffer[p_index];} + ~__array_lite_helper_t() { + set_size(0); + } + t_item * get_ptr() {return m_buffer;} + const t_item * get_ptr() const {return m_buffer;} + bool is_ptr_owned(const void * p_item) const {return is_pointer_in_range(m_buffer,m_size,p_item);} + + void move_from(t_self & other) { + set_size(0); + m_buffer = replace_null_t(other.m_buffer); + m_size = replace_null_t(other.m_size); + } + private: + const t_self & operator=(const t_self &) = delete; + __array_lite_helper_t(const t_self &) = delete; + + + void resize_content(t_size p_size) { + if constexpr (traits_t::needs_constructor || traits_t::needs_destructor) { + if (p_size > m_size) {//expand + do { + __unsafe__in_place_constructor_t(m_buffer[m_size]); + m_size++; + } while(m_size < p_size); + } else if (p_size < m_size) { + __unsafe__in_place_destructor_array_t(m_buffer + p_size, m_size - p_size); + m_size = p_size; + } + } else { + m_size = p_size; + } + } + + void resize_storage(t_size p_size) { + PFC_ASSERT( m_size <= p_size ); + if constexpr (pfc::traits_t::realloc_safe) { + m_buffer = pfc::__raw_realloc_t(m_buffer,p_size); + //m_size_total = p_size; + } else if (__raw_realloc_inplace_t(m_buffer,p_size)) { + //success + //m_size_total = p_size; + } else { + t_item * newbuffer = pfc::__raw_malloc_t(p_size); + try { + pfc::__unsafe__in_place_constructor_array_copy_t(newbuffer,m_size,m_buffer); + } catch(...) { + pfc::__raw_free_t(newbuffer); + throw; + } + pfc::__unsafe__in_place_destructor_array_t(m_buffer,m_size); + pfc::__raw_free_t(m_buffer); + m_buffer = newbuffer; + //m_size_total = p_size; + } + } + + t_item * m_buffer; + t_size m_size; + }; + + template class alloc_standard { + private: typedef alloc_standard t_self; + public: + alloc_standard() {} + void set_size(t_size p_size) {m_content.set_size(p_size);} + + t_size get_size() const {return m_content.get_size();} + + const t_item & operator[](t_size p_index) const {return m_content[p_index];} + t_item & operator[](t_size p_index) {return m_content[p_index];} + + const t_item * get_ptr() const {return m_content.get_ptr();} + t_item * get_ptr() {return m_content.get_ptr();} + + bool is_ptr_owned(const void * p_item) const {return m_content.is_ptr_owned(p_item);} + void prealloc(t_size p_size) {} + void force_reset() {set_size(0);} + + enum { alloc_prioritizes_speed = false }; + + void move_from(t_self & other) { m_content.move_from(other.m_content); } + private: + alloc_standard(const t_self &) = delete; + const t_self & operator=(const t_self&) = delete; + + __array_lite_helper_t m_content; + }; + + template class alloc_fast { + private: typedef alloc_fast t_self; + public: + alloc_fast() {} + + void set_size(t_size p_size) { + t_size size_base = m_data.get_size_total(); + if (size_base == 0) size_base = 1; + while(size_base < p_size) { + size_base = safe_shift_left_t(size_base,1); + } + while(size_base >> 2 > p_size) { + size_base >>= 1; + } + m_data.set_size(p_size,size_base); + } + + t_size get_size() const {return m_data.get_size();} + const t_item & operator[](t_size p_index) const {return m_data[p_index];} + t_item & operator[](t_size p_index) {return m_data[p_index];} + + const t_item * get_ptr() const {return m_data.get_ptr();} + t_item * get_ptr() {return m_data.get_ptr();} + bool is_ptr_owned(const void * p_item) const {return m_data.is_ptr_owned(p_item);} + void prealloc(t_size) {} + void force_reset() {m_data.set_size(0,0);} + + enum { alloc_prioritizes_speed = true }; + + void move_from(t_self & other) { m_data.move_from(other.m_data); } + private: + alloc_fast(const t_self &) = delete; + const t_self & operator=(const t_self&) = delete; + __array_fast_helper_t m_data; + }; + + template class alloc_fast_aggressive { + private: typedef alloc_fast_aggressive t_self; + public: + alloc_fast_aggressive() {} + + void set_size(t_size p_size) { + t_size size_base = m_data.get_size_total(); + if (size_base == 0) size_base = 1; + while(size_base < p_size) { + size_base = safe_shift_left_t(size_base,1); + } + m_data.set_size(p_size,size_base); + } + + void prealloc(t_size p_size) { + if (p_size > 0) { + t_size size_base = m_data.get_size_total(); + if (size_base == 0) size_base = 1; + while(size_base < p_size) { + size_base = safe_shift_left_t(size_base,1); + } + m_data.set_size(m_data.get_size(),size_base); + } + } + + t_size get_size() const {return m_data.get_size();} + const t_item & operator[](t_size p_index) const {;return m_data[p_index];} + t_item & operator[](t_size p_index) {return m_data[p_index];} + + const t_item * get_ptr() const {return m_data.get_ptr();} + t_item * get_ptr() {return m_data.get_ptr();} + bool is_ptr_owned(const void * p_item) const {return m_data.is_ptr_owned(p_item);} + void force_reset() {m_data.set_size(0,0);} + + enum { alloc_prioritizes_speed = true }; + + void move_from(t_self & other) { m_data.move_from(other.m_data); } + private: + alloc_fast_aggressive(const t_self &) = delete; + const t_self & operator=(const t_self&) = delete; + __array_fast_helper_t m_data; + }; + + template class alloc_fixed { + public: + template class alloc { + private: typedef alloc t_self; + public: + alloc() : m_size(0) {} + + void set_size(t_size p_size) { + static_assert_t(); + + if (p_size > p_width) throw pfc::exception_overflow(); + else if (p_size > m_size) { + __unsafe__in_place_constructor_array_t(get_ptr()+m_size,p_size-m_size); + m_size = p_size; + } else if (p_size < m_size) { + __unsafe__in_place_destructor_array_t(get_ptr()+p_size,m_size-p_size); + m_size = p_size; + } + } + + ~alloc() { + if constexpr (pfc::traits_t::needs_destructor) set_size(0); + } + + t_size get_size() const {return m_size;} + + t_item * get_ptr() {return reinterpret_cast(&m_array);} + const t_item * get_ptr() const {return reinterpret_cast(&m_array);} + + const t_item & operator[](t_size n) const {return get_ptr()[n];} + t_item & operator[](t_size n) {return get_ptr()[n];} + bool is_ptr_owned(const void * p_item) const {return is_pointer_in_range(get_ptr(),p_width,p_item);} + void prealloc(t_size) {} + void force_reset() {set_size(0);} + + enum { alloc_prioritizes_speed = false }; + + void move_from(t_self & other) { + const size_t count = other.get_size(); + set_size( count ); + for(size_t w = 0; w < count; ++w) this->get_ptr()[w] = other.get_ptr()[w]; + } + private: + alloc(const t_self&) {throw pfc::exception_not_implemented();} + const t_self& operator=(const t_self&) {throw pfc::exception_not_implemented();} + + t_uint8 m_array[sizeof(t_item[p_width])]; + t_size m_size; + }; + }; + + template class t_alloc = alloc_standard > class alloc_hybrid { + public: + template class alloc { + private: typedef alloc t_self; + public: + alloc() {} + + void set_size(t_size p_size) { + if (p_size > p_width) { + m_fixed.set_size(p_width); + m_variable.set_size(p_size - p_width); + } else { + m_fixed.set_size(p_size); + m_variable.set_size(0); + } + } + + t_item & operator[](t_size p_index) { + PFC_ASSERT(p_index < get_size()); + if (p_index < p_width) return m_fixed[p_index]; + else return m_variable[p_index - p_width]; + } + + const t_item & operator[](t_size p_index) const { + PFC_ASSERT(p_index < get_size()); + if (p_index < p_width) return m_fixed[p_index]; + else return m_variable[p_index - p_width]; + } + + t_size get_size() const {return m_fixed.get_size() + m_variable.get_size();} + bool is_ptr_owned(const void * p_item) const {return m_fixed.is_ptr_owned(p_item) || m_variable.is_ptr_owned(p_item);} + void prealloc(t_size p_size) { + if (p_size > p_width) m_variable.prealloc(p_size - p_width); + } + void force_reset() { + m_fixed.force_reset(); m_variable.force_reset(); + } + enum { alloc_prioritizes_speed = t_alloc::alloc_prioritizes_speed }; + + void move_from(t_self & other) { + m_fixed.move_from(other.m_fixed); + m_variable.move_from(other.m_variable); + } + private: + alloc(const t_self&) {throw pfc::exception_not_implemented();} + const t_self& operator=(const t_self&) {throw pfc::exception_not_implemented();} + + typename alloc_fixed::template alloc m_fixed; + t_alloc m_variable; + }; + }; + + template class traits_t > : public traits_default_movable {}; + template class traits_t<__array_fast_helper_t > : public traits_default_movable {}; + template class traits_t > : public pfc::traits_t<__array_fast_helper_t > {}; + template class traits_t > : public pfc::traits_t<__array_fast_helper_t > {}; + template class traits_t > : public pfc::traits_t<__array_fast_helper_t > {}; + +#if 0//not working (compiler bug?) + template class traits_t::template alloc > : public pfc::traits_t { + public: + enum { + needs_constructor = true, + }; + }; + + template class t_alloc,typename t_item> + class traits_t::template alloc > : public traits_combined::template alloc > {}; +#endif + + +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/array.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/array.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,378 @@ +#pragma once + +#include // std::forward + +#include "alloc.h" + +namespace pfc { + + template class t_alloc = alloc_standard> class array_t; + + + //! Special simplififed version of array class that avoids stepping on landmines with classes without public copy operators/constructors. + template + class array_staticsize_t { + public: typedef _t_item t_item; + private: typedef array_staticsize_t t_self; + public: + array_staticsize_t() : m_array(NULL), m_size(0) {} + array_staticsize_t(t_size p_size) : m_array(new t_item[p_size]), m_size(p_size) {} + ~array_staticsize_t() {release_();} + + //! Copy constructor nonfunctional when data type is not copyable. + array_staticsize_t(const t_self & p_source) : m_size(0), m_array(NULL) { + *this = p_source; + } + array_staticsize_t(t_self && p_source) { + move_(p_source); + } + + //! Copy operator nonfunctional when data type is not copyable. + const t_self & operator=(const t_self & p_source) { + release_(); + + const t_size newsize = p_source.get_size(); + if (newsize > 0) { + m_array = new t_item[newsize]; + m_size = newsize; + for(t_size n = 0; n < newsize; n++) m_array[n] = p_source[n]; + } + return *this; + } + + //! Move operator. + const t_self & operator=(t_self && p_source) { + release_(); + move_(p_source); + return *this; + } + + void set_size_discard(t_size p_size) { + release_(); + if (p_size > 0) { + m_array = new t_item[p_size]; + m_size = p_size; + } + } + template + void set_data_fromptr(const t_source * p_buffer,t_size p_count) { + if (p_count == m_size) { + pfc::copy_array_loop_t(*this,p_buffer,p_count); + } else { + t_item * arr = new t_item[p_count]; + try { + pfc::copy_array_loop_t(arr, p_buffer, p_count); + } catch(...) { delete[] arr; throw; } + delete[] m_array; + m_array = arr; + m_size = p_count; + } + } + + template + void assign(t_source const * items, size_t count) { + set_data_fromptr( items, count ); + } + + + t_size get_size() const {return m_size;} + t_size size() const {return m_size;} // std compat + const t_item * get_ptr() const {return m_array;} + t_item * get_ptr() {return m_array;} + + const t_item & operator[](t_size p_index) const {PFC_ASSERT(p_index < get_size());return m_array[p_index];} + t_item & operator[](t_size p_index) {PFC_ASSERT(p_index < get_size());return m_array[p_index];} + + template bool is_owned(const t_source & p_item) {return pfc::is_pointer_in_range(get_ptr(),get_size(),&p_item);} + + template void enumerate(t_out & out) const { for(t_size walk = 0; walk < m_size; ++walk) out(m_array[walk]); } + + // Modern for loop support + t_item* begin() { return get_ptr(); } + t_item* end() { return get_ptr() + get_size(); } + const t_item* begin() const { return get_ptr(); } + const t_item* end() const { return get_ptr() + get_size(); } + + private: + void release_() { + m_size = 0; + delete[] pfc::replace_null_t(m_array); + } + void move_(t_self & from) { + m_size = from.m_size; + m_array = from.m_array; + from.m_size = 0; + from.m_array = NULL; + } + t_item * m_array; + t_size m_size; + }; + + template + void copy_array_t(t_to & p_to,const t_from & p_from) { + const t_size size = array_size_t(p_from); + if (p_to.has_owned_items(p_from)) {//avoid landmines with actual array data overlapping, or p_from being same as p_to + array_staticsize_t temp; + temp.set_size_discard(size); + pfc::copy_array_loop_t(temp,p_from,size); + p_to.set_size(size); + pfc::copy_array_loop_t(p_to,temp,size); + } else { + p_to.set_size(size); + pfc::copy_array_loop_t(p_to,p_from,size); + } + } + + template + void fill_array_t(t_array & p_array,const t_value & p_value) { + const t_size size = array_size_t(p_array); + for(t_size n=0;n class t_alloc> class array_t { + public: typedef _t_item t_item; + private: typedef array_t t_self; + public: + array_t() {} + array_t(const t_self & p_source) {copy_array_t(*this,p_source);} + template array_t(const t_source & p_source) {copy_array_t(*this,p_source);} + const t_self & operator=(const t_self & p_source) {copy_array_t(*this,p_source); return *this;} + template const t_self & operator=(const t_source & p_source) {copy_array_t(*this,p_source); return *this;} + + array_t(t_self && p_source) {move_from(p_source);} + const t_self & operator=(t_self && p_source) {move_from(p_source); return *this;} + + void set_size(t_size p_size) {m_alloc.set_size(p_size);} + void resize( size_t s ) { set_size(s); } // std compat + + template + void set_size_fill(size_t p_size, fill_t const & filler) { + size_t before = get_size(); + set_size( p_size ); + for(size_t w = before; w < p_size; ++w) this->get_ptr()[w] = filler; + } + + void set_size_in_range(size_t minSize, size_t maxSize) { + if (minSize >= maxSize) { set_size( minSize); return; } + size_t walk = maxSize; + for(;;) { + try { + set_size(walk); + return; + } catch(std::bad_alloc const &) { + if (walk <= minSize) throw; + // go on + } + walk >>= 1; + if (walk < minSize) walk = minSize; + } + } + void set_size_discard(t_size p_size) {m_alloc.set_size(p_size);} + void set_count(t_size p_count) {m_alloc.set_size(p_count);} + t_size get_size() const {return m_alloc.get_size();} + size_t size() const {return m_alloc.get_size();} // std compat + t_size get_count() const {return m_alloc.get_size();} + void force_reset() {m_alloc.force_reset();} + + const t_item & operator[](t_size p_index) const {PFC_ASSERT(p_index < get_size());return m_alloc[p_index];} + t_item & operator[](t_size p_index) {PFC_ASSERT(p_index < get_size());return m_alloc[p_index];} + + //! Warning: buffer pointer must not point to buffer allocated by this array (fixme). + template + void set_data_fromptr(const t_source * p_buffer,t_size p_count) { + set_size(p_count); + pfc::copy_array_loop_t(*this,p_buffer,p_count); + } + + template + void append(const t_array & p_source) { + if (has_owned_items(p_source)) append(array_t(p_source)); + else { + const t_size source_size = array_size_t(p_source); + const t_size base = get_size(); + increase_size(source_size); + for(t_size n=0;n + void insert_multi(const t_insert & value, t_size base, t_size count) { + const t_size oldSize = get_size(); + if (base > oldSize) base = oldSize; + increase_size(count); + pfc::memmove_t(get_ptr() + base + count, get_ptr() + base, oldSize - base); + pfc::fill_ptr_t(get_ptr() + base, count, value); + } + template void append_multi(const t_append & value, t_size count) {insert_multi(value,~0,count);} + + //! Warning: buffer pointer must not point to buffer allocated by this array (fixme). + template + void append_fromptr(const t_append * p_buffer,t_size p_count) { + PFC_ASSERT( !is_owned(&p_buffer[0]) ); + t_size base = get_size(); + increase_size(p_count); + for(t_size n=0;n + void add_item( item_t && item ) { + const t_size base = get_size(); + increase_size(1); + m_alloc[base] = std::forward( item ); + } + template + void append_single_val( item_t && item ) { + const t_size base = get_size(); + increase_size(1); + m_alloc[base] = std::forward( item ); + } + + template + void append_single(const t_append & p_item) { + if (is_owned(p_item)) append_single(t_append(p_item)); + else { + const t_size base = get_size(); + increase_size(1); + m_alloc[base] = p_item; + } + } + + template + void fill(const t_filler & p_filler) { + const t_size max = get_size(); + for(t_size n=0;n get_size()) set_size(p_size); + } + + //not supported by some allocs + const t_item * get_ptr() const {return m_alloc.get_ptr();} + t_item * get_ptr() {return m_alloc.get_ptr();} + + void prealloc(t_size p_size) {m_alloc.prealloc(p_size);} + + template + bool has_owned_items(const t_array & p_source) { + if (array_size_t(p_source) == 0) return false; + + //how the hell would we properly check if any of source items is owned by us, in case source array implements some weird mixing of references of items from different sources? + //the most obvious way means evil bottleneck here (whether it matters or not from caller's point of view which does something O(n) already is another question) + //at least this will work fine with all standard classes which don't crossreference anyhow and always use own storage + //perhaps we'll traitify this someday later + return is_owned(p_source[0]); + } + + template + bool is_owned(const t_source & p_item) { + return m_alloc.is_ptr_owned(&p_item); + } + + template + void set_single(const t_item & p_item) { + set_size(1); + (*this)[0] = p_item; + } + + template void enumerate(t_callback & p_callback) const { for(t_size n = 0; n < get_size(); n++ ) { p_callback((*this)[n]); } } + + void move_from(t_self & other) { + m_alloc.move_from(other.m_alloc); + } + + // Modern for loop support + t_item* begin() { return get_ptr(); } + t_item* end() { return get_ptr() + get_size(); } + const t_item* begin() const { return get_ptr(); } + const t_item* end() const { return get_ptr() + get_size(); } + private: + t_alloc m_alloc; + }; + + template class t_alloc = alloc_standard > + class array_hybrid_t : public array_t::template alloc > + {}; + + + template class traits_t > : public traits_default_movable {}; + template class t_alloc> class traits_t > : public pfc::traits_t > {}; + + + template + class comparator_array { + public: + template + static int compare(const t_array1 & p_array1, const t_array2 & p_array2) { + t_size walk = 0; + for(;;) { + if (walk >= p_array1.get_size() && walk >= p_array2.get_size()) return 0; + else if (walk >= p_array1.get_size()) return -1; + else if (walk >= p_array2.get_size()) return 1; + else { + int state = t_comparator::compare(p_array1[walk],p_array2[walk]); + if (state != 0) return state; + } + ++walk; + } + } + }; + + template + static bool array_equals(const t_a1 & arr1, const t_a2 & arr2) { + const t_size s = array_size_t(arr1); + if (s != array_size_t(arr2)) return false; + for(t_size walk = 0; walk < s; ++walk) { + if (arr1[walk] != arr2[walk]) return false; + } + return true; + } + + + + template class t_alloc = alloc_standard> class array_2d_t { + public: + array_2d_t() : m_d1(), m_d2() {} + void set_size(t_size d1, t_size d2) { + m_content.set_size(pfc::mul_safe_t(d1, d2)); + m_d1 = d1; m_d2 = d2; + } + t_size get_dim1() const {return m_d1;} + t_size get_dim2() const {return m_d2;} + + t_item & at(t_size i1, t_size i2) { + return * _transformPtr(m_content.get_ptr(), i1, i2); + } + const t_item & at(t_size i1, t_size i2) const { + return * _transformPtr(m_content.get_ptr(), i1, i2); + } + template void fill(const t_filler & p_filler) {m_content.fill(p_filler);} + void fill_null() {m_content.fill_null();} + + t_item * rowPtr(t_size i1) {return _transformPtr(m_content.get_ptr(), i1, 0);} + const t_item * rowPtr(t_size i1) const {return _transformPtr(m_content.get_ptr(), i1, 0);} + + const t_item * operator[](t_size i1) const {return rowPtr(i1);} + t_item * operator[](t_size i1) {return rowPtr(i1);} + private: + template t_ptr _transformPtr(t_ptr ptr, t_size i1, t_size i2) const { + PFC_ASSERT( i1 < m_d1 ); PFC_ASSERT( i2 < m_d2 ); + return ptr + i1 * m_d2 + i2; + } + pfc::array_t m_content; + t_size m_d1, m_d2; + }; + +} + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/audio_math.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/audio_math.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,1186 @@ +#include "pfc-lite.h" +#include "audio_sample.h" +#include "primitives.h" +#include "cpuid.h" + + +#if (defined(_M_IX86_FP) && _M_IX86_FP >= 2) || (defined(_M_X64) && !defined(_M_ARM64EC)) || defined(__x86_64__) || defined(__SSE2__) +#define AUDIO_MATH_SSE +#include +#include // _mm_shuffle_epi8 +#include // _mm_blend_epi16 + +#ifndef _mm_loadu_si32 +#define _mm_loadu_si32(p) _mm_cvtsi32_si128(*(unsigned int const*)(p)) +#endif +#ifndef _mm_storeu_si32 +#define _mm_storeu_si32(p, a) (void)(*(int*)(p) = _mm_cvtsi128_si32((a))) +#endif + +#ifdef __AVX__ +#define allowAVX 1 +#define haveAVX 1 +#elif PFC_HAVE_CPUID +#define allowAVX 1 +static const bool haveAVX = pfc::query_cpu_feature_set(pfc::CPU_HAVE_AVX); +#else +#define allowAVX 0 +#define haveAVX 0 +#endif + +#ifdef __SSE4_1__ +#define haveSSE41 true +#elif PFC_HAVE_CPUID +static const bool haveSSE41 = pfc::query_cpu_feature_set(pfc::CPU_HAVE_SSE41); +#else +#define haveSSE41 false +#endif + +#if allowAVX +#include // _mm256_set1_pd +#endif + +#endif // end SSE + +#if defined( __aarch64__ ) || defined( _M_ARM64) || defined( _M_ARM64EC ) +#define AUDIO_MATH_ARM64 +#endif + +#if defined( AUDIO_MATH_ARM64 ) || defined( __ARM_NEON__ ) +#define AUDIO_MATH_NEON +#include + +// No vcvtnq_s32_f32 on ARM32, use vcvtq_s32_f32, close enough +#ifdef AUDIO_MATH_ARM64 +#define vcvtnq_s32_f32_wrap vcvtnq_s32_f32 +#else +#define vcvtnq_s32_f32_wrap vcvtq_s32_f32 +#endif + +#endif + + +#if defined( AUDIO_MATH_ARM64 ) && !defined( __ANDROID__ ) +// Don't do Neon float64 on Android, crashes clang from NDK 25 +#define AUDIO_MATH_NEON_FLOAT64 +#endif + +template inline static float_t noopt_calculate_peak(const float_t *p_src, t_size p_num) +{ + float_t peak = 0; + t_size num = p_num; + for(;num;num--) + { + float_t temp = (float_t)fabs(*(p_src++)); + peak = fmax(peak, temp); + } + return peak; +} + + +template +inline static void noopt_convert_to_32bit(const float_t* p_source,t_size p_count,t_int32 * p_output, float_t p_scale) +{ + t_size num = p_count; + for(;num;--num) + { + t_int64 val = pfc::audio_math::rint64( *(p_source++) * p_scale ); + if (val < INT32_MIN) val = INT32_MIN; + else if (val > INT32_MAX) val = INT32_MAX; + *(p_output++) = (t_int32) val; + } +} + +template +inline static void noopt_convert_to_16bit(const float_t* p_source,t_size p_count,t_int16 * p_output, float_t p_scale) { + for(t_size n=0;n(pfc::audio_math::rint32(*(p_source++)*p_scale),INT16_MIN,INT16_MAX); + } +} + +template +inline static void noopt_convert_from_int16(const t_int16 * __restrict p_source,t_size p_count, float_t* __restrict p_output, float_t p_scale) +{ + t_size num = p_count; + for(;num;num--) + *(p_output++) = (float_t)*(p_source++) * p_scale; +} + + + +template +inline static void noopt_convert_from_int32(const t_int32 * __restrict p_source,t_size p_count, float_t* __restrict p_output, float_t p_scale) +{ + t_size num = p_count; + for(;num;num--) + *(p_output++) = (float_t)( * (p_source++) * p_scale ); +} + +template +inline static void noopt_scale(const in_t * p_source,size_t p_count,out_t * p_output,scale_t p_scale) +{ + for(t_size n=0;n +inline static void noopt_convert(const in_t* in, out_t* out, size_t count) { + for (size_t walk = 0; walk < count; ++walk) out[walk] = (out_t)in[walk]; +} + +#ifdef AUDIO_MATH_NEON + +#ifdef AUDIO_MATH_ARM64 +#define _vmaxvq_f32_wrap vmaxvq_f32 +#else +inline float _vmaxvq_f32_wrap( float32x4_t arg ) { + return pfc::max_t( pfc::max_t(arg[0], arg[1]), pfc::max_t(arg[2], arg[3]) ); +} +#endif + +inline static float neon_calculate_peak( const float * p_source, size_t p_count ) { + size_t num = p_count / 8; + float32x4_t ret1 = {}, ret2 = {}; + for(;num;--num) { + float32x4_t f32lo = vld1q_f32( p_source ); + float32x4_t f32hi = vld1q_f32( p_source + 4 ); + p_source += 8; + ret1 = vmaxq_f32(ret1, vabsq_f32(f32lo)); + ret2 = vmaxq_f32(ret2, vabsq_f32(f32hi)); + } + + float ret = _vmaxvq_f32_wrap(vmaxq_f32( ret1, ret2 )); + + size_t rem = p_count % 8; + if ( rem != 0 ) { + float v = noopt_calculate_peak( p_source, p_count % 8); + if (v > ret) ret = v; + } + + return ret; +} + +inline static void neon_scale(const float * p_source,size_t p_count, float * p_output,float p_scale) { + size_t num = p_count / 8; + for(;num;--num) { + float32x4_t lo = vld1q_f32( p_source ); + float32x4_t hi = vld1q_f32( p_source + 4 ); + + lo = vmulq_n_f32( lo, p_scale); + hi = vmulq_n_f32( hi, p_scale); + + vst1q_f32( p_output, lo ); + vst1q_f32( p_output+4, hi ); + + p_source += 8; + p_output += 8; + } + + noopt_scale( p_source, p_count % 8, p_output, p_scale); +} +inline static void neon_convert_to_int32(const float * __restrict p_source,t_size p_count, int32_t * __restrict p_output,float p_scale) +{ + size_t num = p_count / 8; + for(;num;--num) { + float32x4_t f32lo = vld1q_f32( p_source ); + float32x4_t f32hi = vld1q_f32( p_source + 4 ); + + int32x4_t lo = vcvtnq_s32_f32_wrap( vmulq_n_f32(f32lo, p_scale) ); + int32x4_t hi = vcvtnq_s32_f32_wrap( vmulq_n_f32(f32hi, p_scale) ); + + vst1q_s32(p_output, lo); + vst1q_s32(p_output+4, hi); + + p_source += 8; + p_output += 8; + + } + + noopt_convert_to_32bit(p_source, p_count % 8, p_output, p_scale); +} + +inline static void neon_convert_from_int32(const int32_t * __restrict p_source,t_size p_count, float * __restrict p_output,float p_scale) +{ + size_t num = p_count / 8; + size_t rem = p_count % 8; + for(;num;num--) { + int32x4_t i32lo = vld1q_s32( p_source ); + int32x4_t i32hi = vld1q_s32( p_source + 4 ); + float32x4_t f32vl = vcvtq_f32_s32(i32lo); + float32x4_t f32vh = vcvtq_f32_s32(i32hi); + + vst1q_f32(&p_output[0], vmulq_n_f32(f32vl, p_scale)); + vst1q_f32(&p_output[4], vmulq_n_f32(f32vh, p_scale)); + + p_source += 8; + p_output += 8; + + } + + noopt_convert_from_int32( p_source, rem, p_output, p_scale ); +} + +inline static void neon_convert_to_int16(const float* __restrict p_source,t_size p_count, int16_t * __restrict p_output,float p_scale) +{ + size_t num = p_count / 8; + size_t rem = p_count % 8; + for(;num;--num) { + float32x4_t f32lo = vld1q_f32( p_source ); + float32x4_t f32hi = vld1q_f32( p_source + 4); + + int32x4_t lo = vcvtnq_s32_f32_wrap( vmulq_n_f32(f32lo, p_scale) ); + int32x4_t hi = vcvtnq_s32_f32_wrap( vmulq_n_f32(f32hi, p_scale) ); + + vst1q_s16(&p_output[0], vcombine_s16( vqmovn_s32( lo ), vqmovn_s32( hi ) ) ); + + p_source += 8; + p_output += 8; + + } + + noopt_convert_to_16bit(p_source, rem, p_output, p_scale); + +} +inline static void neon_convert_from_int16(const t_int16 * __restrict p_source,t_size p_count, float * __restrict p_output,float p_scale) +{ + size_t num = p_count / 8; + size_t rem = p_count % 8; + for(;num;num--) { + auto i16lo = vld1_s16(p_source); + auto i16hi = vld1_s16(p_source + 4); + + float32x4_t f32vl = vcvtq_f32_s32(vmovl_s16 (i16lo)); + float32x4_t f32vh = vcvtq_f32_s32(vmovl_s16 (i16hi)); + + vst1q_f32(&p_output[0], vmulq_n_f32(f32vl, p_scale)); + vst1q_f32(&p_output[4], vmulq_n_f32(f32vh, p_scale)); + + p_source += 8; + p_output += 8; + + } + + noopt_convert_from_int16( p_source, rem, p_output, p_scale ); +} +#ifdef AUDIO_MATH_NEON_FLOAT64 +inline static void neon_convert_to_int16(const double* __restrict p_source, t_size p_count, int16_t* __restrict p_output, double p_scale) +{ + size_t num = p_count / 4; + size_t rem = p_count % 4; + for (; num; --num) { + float64x2_t f64lo = vld1q_f64(p_source); + float64x2_t f64hi = vld1q_f64(p_source + 2); + + f64lo = vmulq_n_f64(f64lo, p_scale); + f64hi = vmulq_n_f64(f64hi, p_scale); + + int64x2_t lo64 = vcvtnq_s64_f64(f64lo); + int64x2_t hi64 = vcvtnq_s64_f64(f64hi); + + int32x4_t v32 = vcombine_s32(vqmovn_s64(lo64), vqmovn_s64(hi64)); + + + vst1_s16(&p_output[0], vqmovn_s32(v32)); + + p_source += 4; + p_output += 4; + + } + + noopt_convert_to_16bit(p_source, rem, p_output, p_scale); +} + +inline static void neon_convert_from_int16(const t_int16* __restrict p_source, t_size p_count, double* __restrict p_output, double p_scale) +{ + size_t num = p_count / 4; + size_t rem = p_count % 4; + for (; num; num--) { + int32x4_t i32 = vmovl_s16(vld1_s16(p_source)); + + int64x2_t lo64 = vmovl_s32( vget_low_s32(i32) ); + int64x2_t hi64 = vmovl_s32(vget_high_s32(i32)); + + float64x2_t f64vl = vcvtq_f64_s64(lo64); + float64x2_t f64vh = vcvtq_f64_s64(hi64); + + vst1q_f64(&p_output[0], vmulq_n_f64(f64vl, p_scale)); + vst1q_f64(&p_output[2], vmulq_n_f64(f64vh, p_scale)); + + p_source += 4; + p_output += 4; + + } + + noopt_convert_from_int16(p_source, rem, p_output, p_scale); +} +#endif // AUDIO_MATH_NEON_FLOAT64 + +#endif // AUDIO_MATH_NEON + +#if defined(AUDIO_MATH_SSE) + +inline void convert_to_32bit_sse2(const float* p_src, size_t numTotal, t_int32* p_dst, float p_mul) +{ + + // Implementation notes + // There doesn't seem to be a nice and tidy way to convert float to int32 with graceful clipping to INT32_MIN .. INT32_MAX range. + // While low clipping at INT32_MIN can be accomplished with _mm_max_ps(), high clipping needs float compare THEN substitute bad int with INT32_MAX. + // The best we could do with _mm_min_ps() would result with high clipping at 0x7FFFFF80 instead of 0x7FFFFFFF (INT32_MAX). + // We store masks from float compare and fix ints according to the mask later. + + __m128 mul = _mm_set1_ps(p_mul); + __m128 loF = _mm_set1_ps((float)INT32_MIN); + __m128 hiF = _mm_set1_ps((float)INT32_MAX); + // __m128i loI = _mm_set1_epi32(INT32_MIN); + __m128i hiI = _mm_set1_epi32(INT32_MAX); + + size_t num = numTotal / 4; + size_t rem = numTotal % 4; + for (; num; --num) { + __m128 s = _mm_mul_ps(mul, _mm_loadu_ps(p_src)); p_src += 4; + + s = _mm_max_ps(s, loF); + + // __m128i maskLo = _mm_castps_si128(_mm_cmple_ps(s, loF)); + __m128i maskHi = _mm_castps_si128(_mm_cmpge_ps(s, hiF)); + + __m128i i = _mm_cvtps_epi32(s); + + // i = _mm_or_si128(_mm_andnot_si128(maskLo, i), _mm_and_si128(loI, maskLo)); + i = _mm_or_si128(_mm_andnot_si128(maskHi, i), _mm_and_si128(hiI, maskHi)); + + _mm_storeu_si128((__m128i*) p_dst, i); p_dst += 4; + } + + for (; rem; --rem) { + __m128 s = _mm_mul_ss(_mm_load_ss(p_src++), mul); + s = _mm_max_ss(s, loF); + + // __m128i maskLo = _mm_castps_si128( _mm_cmple_ss(s, loF) ); + __m128i maskHi = _mm_castps_si128(_mm_cmpge_ss(s, hiF)); + + __m128i i = _mm_cvtps_epi32(s); // not ss + + // i = _mm_or_si128(_mm_andnot_si128(maskLo, i), _mm_and_si128(loI, maskLo)); + i = _mm_or_si128(_mm_andnot_si128(maskHi, i), _mm_and_si128(hiI, maskHi)); + + _mm_storeu_si32(p_dst++, i); + } +} + +inline void convert_to_32bit_sse2(const double* p_src, size_t numTotal, t_int32* p_dst, double p_mul) +{ + auto mul = _mm_set1_pd(p_mul); + auto loF = _mm_set1_pd(INT32_MIN); + auto hiF = _mm_set1_pd(INT32_MAX); + + size_t num = numTotal / 4; + size_t rem = numTotal % 4; + for (; num; --num) { + auto v1 = _mm_loadu_pd(p_src); + auto v2 = _mm_loadu_pd(p_src + 2); + p_src += 4; + + v1 = _mm_mul_pd(v1, mul); v2 = _mm_mul_pd(v2, mul); + + v1 = _mm_max_pd(v1, loF); v2 = _mm_max_pd(v2, loF); + v1 = _mm_min_pd(v1, hiF); v2 = _mm_min_pd(v2, hiF); + + auto i1 = _mm_cvtpd_epi32(v1), i2 = _mm_cvtpd_epi32(v2); + + + _mm_storeu_si128((__m128i*) p_dst, _mm_unpacklo_epi64(i1, i2)); p_dst += 4; + } + + for (; rem; --rem) { + auto s = _mm_mul_sd(_mm_load_sd(p_src++), mul); + s = _mm_max_sd(s, loF); s = _mm_min_sd(s, hiF); + * p_dst++ = _mm_cvtsd_si32(s); + } +} + +inline void convert_from_int16_sse2(const t_int16 * p_source,t_size p_count,float * p_output,float p_scale) +{ + while(!pfc::is_ptr_aligned_t<16>(p_output) && p_count) { + *(p_output++) = (float)*(p_source++) * p_scale; + p_count--; + } + + { + __m128 mul = _mm_set1_ps(p_scale); + __m128i nulls = _mm_setzero_si128(); + __m128i delta1 = _mm_set1_epi16((int16_t)0x8000); + __m128i delta2 = _mm_set1_epi32((int32_t)0x8000); + + for(t_size loop = p_count >> 3;loop;--loop) { + __m128i source, temp1, temp2; __m128 float1, float2; + source = _mm_loadu_si128((__m128i*)p_source); + source = _mm_xor_si128(source,delta1); + temp1 = _mm_unpacklo_epi16(source,nulls); + temp2 = _mm_unpackhi_epi16(source,nulls); + temp1 = _mm_sub_epi32(temp1,delta2); + temp2 = _mm_sub_epi32(temp2,delta2); + p_source += 8; + float1 = _mm_cvtepi32_ps(temp1); + float2 = _mm_cvtepi32_ps(temp2); + float1 = _mm_mul_ps(float1,mul); + float2 = _mm_mul_ps(float2,mul); + _mm_store_ps(p_output,float1); + _mm_store_ps(p_output+4,float2); + p_output += 8; + } + + p_count &= 7; + } + + while(p_count) { + *(p_output++) = (float)*(p_source++) * p_scale; + p_count--; + } +} + +inline static void convert_to_16bit_sse2(const float * p_source,t_size p_count,t_int16 * p_output,float p_scale) +{ + size_t num = p_count/8; + size_t rem = p_count%8; + __m128 mul = _mm_set1_ps(p_scale); + for(;num;--num) + { + __m128 temp1,temp2; __m128i itemp1, itemp2; + temp1 = _mm_loadu_ps(p_source); + temp2 = _mm_loadu_ps(p_source+4); + temp1 = _mm_mul_ps(temp1,mul); + temp2 = _mm_mul_ps(temp2,mul); + p_source += 8; + itemp1 = _mm_cvtps_epi32(temp1); + itemp2 = _mm_cvtps_epi32(temp2); + _mm_storeu_si128( (__m128i*)p_output, _mm_packs_epi32(itemp1, itemp2) ); + p_output += 8; + } + + noopt_convert_to_16bit(p_source, rem, p_output, p_scale); +} + +inline static void convert_to_16bit_sse2(const double* p_source, t_size p_count, t_int16* p_output, double p_scale) +{ + size_t num = p_count / 8; + size_t rem = p_count % 8; + __m128d mul = _mm_set1_pd(p_scale); + for (; num; --num) + { + __m128d temp1, temp2, temp3, temp4; __m128i itemp1, itemp2; + temp1 = _mm_loadu_pd(p_source); + temp2 = _mm_loadu_pd(p_source + 2); + temp3 = _mm_loadu_pd(p_source + 4); + temp4 = _mm_loadu_pd(p_source + 6); + + p_source += 8; + + temp1 = _mm_mul_pd(temp1, mul); + temp2 = _mm_mul_pd(temp2, mul); + temp3 = _mm_mul_pd(temp3, mul); + temp4 = _mm_mul_pd(temp4, mul); + + + itemp1 = _mm_unpacklo_epi64(_mm_cvtpd_epi32(temp1), _mm_cvtpd_epi32(temp2)); + itemp2 = _mm_unpacklo_epi64(_mm_cvtpd_epi32(temp3), _mm_cvtpd_epi32(temp4)); + + _mm_storeu_si128((__m128i*)p_output, _mm_packs_epi32(itemp1, itemp2)); + p_output += 8; + } + + noopt_convert_to_16bit(p_source, rem, p_output, p_scale); +} +#if allowAVX +inline static void avx_convert_to_16bit(const double* p_source, size_t p_count, int16_t* p_output, double p_scale) { + size_t num = p_count / 8; + size_t rem = p_count % 8; + auto mul = _mm256_set1_pd(p_scale); + for (; num; --num) + { + auto temp1 = _mm256_loadu_pd(p_source); + auto temp2 = _mm256_loadu_pd(p_source + 4); + + p_source += 8; + + temp1 = _mm256_mul_pd(temp1, mul); + temp2 = _mm256_mul_pd(temp2, mul); + + auto itemp1 = _mm256_cvtpd_epi32(temp1); + auto itemp2 = _mm256_cvtpd_epi32(temp2); + + _mm_storeu_si128((__m128i*)p_output, _mm_packs_epi32(itemp1, itemp2)); + p_output += 8; + } + + noopt_convert_to_16bit(p_source, rem, p_output, p_scale); +} +#endif + +inline float sse_calculate_peak( const float * src, size_t count ) { + size_t num = count/8; + size_t rem = count%8; + + __m128 mask = _mm_castsi128_ps(_mm_set1_epi32(0x7FFFFFFF)); + __m128 acc1 = _mm_setzero_ps(), acc2 = _mm_setzero_ps(); + + for(;num;--num) { + __m128 v1 = _mm_loadu_ps( src ); + __m128 v2 = _mm_loadu_ps( src + 4 ); + v1 = _mm_and_ps( v1, mask ); + v2 = _mm_and_ps( v2, mask ); + // Two acc channels so one _mm_max_ps doesn't block the other + acc1 = _mm_max_ps( acc1, v1 ); + acc2 = _mm_max_ps( acc2, v2 ); + src += 8; + } + + float ret; + { + float blah[4]; + _mm_storeu_ps(blah, _mm_max_ps( acc1, acc2 )); + __m128 acc = _mm_load_ss( &blah[0] ); + acc = _mm_max_ss( acc, _mm_load_ss( &blah[1] ) ); + acc = _mm_max_ss( acc, _mm_load_ss( &blah[2] ) ); + acc = _mm_max_ss( acc, _mm_load_ss( &blah[3] ) ); + ret = _mm_cvtss_f32(acc); + } + if ( rem > 0 ) { + __m128 acc = _mm_set_ss( ret ); + for( ;rem; --rem) { + __m128 v = _mm_load_ss( src++ ); + v = _mm_and_ps( v, mask ); + acc = _mm_max_ss( acc, v ); + } + ret = _mm_cvtss_f32(acc); + } + return ret; +} + +#if allowAVX +inline double avx_calculate_peak(const double* src, size_t count) { + size_t num = count / 8; + size_t rem = count % 8; + + auto mask = _mm256_castsi256_pd(_mm256_set1_epi64x(0x7FFFFFFFFFFFFFFF)); + auto acc1 = _mm256_setzero_pd(), acc2 = _mm256_setzero_pd(); + + for (; num; --num) { + auto v1 = _mm256_loadu_pd(src); + auto v2 = _mm256_loadu_pd(src + 4); + + v1 = _mm256_and_pd(v1, mask); + v2 = _mm256_and_pd(v2, mask); + + acc1 = _mm256_max_pd(acc1, v1); + acc2 = _mm256_max_pd(acc2, v2); + + src += 8; + } + + __m128d acc; + { + acc1 = _mm256_max_pd(acc1, acc2); + + acc = _mm_max_pd(_mm256_extractf128_pd(acc1, 0), _mm256_extractf128_pd(acc1, 1)); + + acc = _mm_max_sd(acc, _mm_shuffle_pd(acc, acc, _MM_SHUFFLE2(0, 1))); + } + + if (rem > 0) { + __m128d mask128 = _mm_castsi128_pd(_mm_set1_epi64x(0x7FFFFFFFFFFFFFFF)); + for (; rem; --rem) { + __m128d v = _mm_load_sd(src++); + v = _mm_and_pd(v, mask128); + acc = _mm_max_sd(acc, v); + } + } + return _mm_cvtsd_f64(acc); +} +#endif // allowAVX + +inline double sse_calculate_peak(const double* src, size_t count) { + size_t num = count / 4; + size_t rem = count % 4; + + __m128d mask = _mm_castsi128_pd(_mm_set1_epi64x(0x7FFFFFFFFFFFFFFF)); + __m128d acc1 = _mm_setzero_pd(), acc2 = _mm_setzero_pd(); + + for (; num; --num) { + __m128d v1 = _mm_loadu_pd(src); + __m128d v2 = _mm_loadu_pd(src + 2); + v1 = _mm_and_pd(v1, mask); + v2 = _mm_and_pd(v2, mask); + // Two acc channels so one _mm_max_pd doesn't block the other + acc1 = _mm_max_pd(acc1, v1); + acc2 = _mm_max_pd(acc2, v2); + src += 4; + } + + { + acc1 = _mm_max_pd(acc1, acc2); + acc1 = _mm_max_sd(acc1, _mm_shuffle_pd(acc1, acc1, _MM_SHUFFLE2(0, 1))); + } + if (rem > 0) { + for (; rem; --rem) { + __m128d v = _mm_load_sd(src++); + v = _mm_and_pd(v, mask); + acc1 = _mm_max_sd(acc1, v); + } + } + return _mm_cvtsd_f64(acc1); +} + +inline void sse_convert_from_int32(const int32_t* source, size_t count, float* output, float scale) { + __m128 mul = _mm_set1_ps(scale); + for (size_t num = count/8; num; --num) + { + __m128i itemp1, itemp2; __m128 temp1, temp2; + itemp1 = _mm_loadu_si128((__m128i*)source); + itemp2 = _mm_loadu_si128((__m128i*)source + 1); + temp1 = _mm_cvtepi32_ps(itemp1); + temp2 = _mm_cvtepi32_ps(itemp2); + source += 8; + temp1 = _mm_mul_ps(temp1, mul); + temp2 = _mm_mul_ps(temp2, mul); + _mm_storeu_ps(output, temp1); + _mm_storeu_ps(output + 4, temp2); + output += 8; + } + for (size_t rem = count % 8; rem; --rem) { + __m128i i = _mm_loadu_si32(source++); + __m128 f = _mm_cvtepi32_ps(i); + f = _mm_mul_ss(f, mul); + _mm_store_ss(output++, f); + } +} + +inline void sse_convert_from_int32(const int32_t* source, size_t count, double* output, double scale) { + auto mul = _mm_set1_pd(scale); + for (size_t num = count / 8; num; --num) + { + auto itemp1 = _mm_loadu_si128((__m128i*)source); + auto itemp2 = _mm_loadu_si128((__m128i*)source + 1); + auto temp1 = _mm_cvtepi32_pd(itemp1); + auto temp2 = _mm_cvtepi32_pd(_mm_shuffle_epi32(itemp1, _MM_SHUFFLE(1, 0, 3, 2))); + auto temp3 = _mm_cvtepi32_pd(itemp2); + auto temp4 = _mm_cvtepi32_pd(_mm_shuffle_epi32(itemp2, _MM_SHUFFLE(1, 0, 3, 2))); + source += 8; + temp1 = _mm_mul_pd(temp1, mul); + temp2 = _mm_mul_pd(temp2, mul); + temp3 = _mm_mul_pd(temp3, mul); + temp4 = _mm_mul_pd(temp4, mul); + _mm_storeu_pd(output, temp1); + _mm_storeu_pd(output + 2, temp2); + _mm_storeu_pd(output + 4, temp3); + _mm_storeu_pd(output + 6, temp4); + output += 8; + } + for (size_t rem = count % 8; rem; --rem) { + __m128i i = _mm_loadu_si32(source++); + auto f = _mm_cvtepi32_pd(i); + f = _mm_mul_sd(f, mul); + _mm_store_sd(output++, f); + } +} +#if allowAVX +inline void convert_from_int16_avx(const t_int16* p_source, t_size p_count, double* p_output, double p_scale) { + while (!pfc::is_ptr_aligned_t<32>(p_output) && p_count) { + *(p_output++) = (double)*(p_source++) * p_scale; + p_count--; + } + + { + __m256d muld = _mm256_set1_pd(p_scale); + + for (t_size loop = p_count >> 3; loop; --loop) { + auto source = _mm_loadu_si128((__m128i*)p_source); + auto temp1 = _mm_cvtepi16_epi32(source); + auto temp2 = _mm_cvtepi16_epi32(_mm_shuffle_epi32(source, _MM_SHUFFLE(0, 0, 3, 2))); + p_source += 8; + + auto double1 = _mm256_cvtepi32_pd(temp1); + auto double2 = _mm256_cvtepi32_pd(temp2); + + double1 = _mm256_mul_pd(double1, muld); + double2 = _mm256_mul_pd(double2, muld); + + _mm256_store_pd(p_output, double1); + _mm256_store_pd(p_output+4, double2); + + p_output += 8; + } + + p_count &= 7; + } + + while (p_count) { + *(p_output++) = (double)*(p_source++) * p_scale; + p_count--; + } + +} +#endif // allowAVX + +inline void convert_from_int16_sse2(const t_int16* p_source, t_size p_count, double * p_output, double p_scale) +{ + while (!pfc::is_ptr_aligned_t<16>(p_output) && p_count) { + *(p_output++) = (double) * (p_source++) * p_scale; + p_count--; + } + + { + __m128d muld = _mm_set1_pd(p_scale); + __m128i nulls = _mm_setzero_si128(); + __m128i delta1 = _mm_set1_epi16((int16_t)0x8000); + __m128i delta2 = _mm_set1_epi32((int32_t)0x8000); + + for (t_size loop = p_count >> 3; loop; --loop) { + __m128i source, temp1, temp2; __m128d double1, double2, double3, double4; + source = _mm_loadu_si128((__m128i*)p_source); + source = _mm_xor_si128(source, delta1); + temp1 = _mm_unpacklo_epi16(source, nulls); + temp2 = _mm_unpackhi_epi16(source, nulls); + temp1 = _mm_sub_epi32(temp1, delta2); + temp2 = _mm_sub_epi32(temp2, delta2); + p_source += 8; + + double1 = _mm_cvtepi32_pd(temp1); + double2 = _mm_cvtepi32_pd(_mm_shuffle_epi32(temp1, _MM_SHUFFLE(3, 2, 3, 2))); + double3 = _mm_cvtepi32_pd(temp2); + double4 = _mm_cvtepi32_pd(_mm_shuffle_epi32(temp2, _MM_SHUFFLE(3, 2, 3, 2))); + + double1 = _mm_mul_pd(double1, muld); + double2 = _mm_mul_pd(double2, muld); + double3 = _mm_mul_pd(double3, muld); + double4 = _mm_mul_pd(double4, muld); + _mm_store_pd(p_output, double1); + _mm_store_pd(p_output + 2, double2); + _mm_store_pd(p_output + 4, double3); + _mm_store_pd(p_output + 6, double4); + + p_output += 8; + } + + p_count &= 7; + } + + while (p_count) { + *(p_output++) = (double) * (p_source++) * p_scale; + p_count--; + } +} + +#endif + +namespace pfc { + void audio_math::scale(const float* p_source, size_t p_count, float* p_output, float p_scale) { +#if defined( AUDIO_MATH_NEON ) + neon_scale(p_source, p_count, p_output, p_scale); +#else + noopt_scale(p_source, p_count, p_output, p_scale); +#endif + } + void audio_math::scale(const double* p_source, size_t p_count, double* p_output, double p_scale) { + noopt_scale(p_source, p_count, p_output, p_scale); + } + + void audio_math::convert_to_int16(const float* p_source, t_size p_count, t_int16* p_output, float p_scale) + { + float scale = (float)(p_scale * 0x8000); +#if defined(AUDIO_MATH_SSE) + convert_to_16bit_sse2(p_source, p_count, p_output, scale); +#elif defined( AUDIO_MATH_NEON ) + neon_convert_to_int16(p_source, p_count, p_output, scale); +#else + noopt_convert_to_16bit(p_source, p_count, p_output, scale); +#endif + } + void audio_math::convert_to_int16(const double* p_source, t_size p_count, t_int16* p_output, double p_scale) + { + double scale = (double)(p_scale * 0x8000); +#if defined(AUDIO_MATH_SSE) +#if allowAVX + if (haveAVX) { + avx_convert_to_16bit(p_source, p_count, p_output, scale); + } else +#endif // allowAVX + { + convert_to_16bit_sse2(p_source, p_count, p_output, scale); + } +#elif defined( AUDIO_MATH_NEON_FLOAT64 ) + neon_convert_to_int16(p_source, p_count, p_output, scale); +#else + noopt_convert_to_16bit(p_source, p_count, p_output, scale); +#endif + } + + void audio_math::convert_from_int16(const t_int16* p_source, t_size p_count, float* p_output, float p_scale) + { + float scale = (float)(p_scale / (double)0x8000); +#if defined(AUDIO_MATH_SSE) + convert_from_int16_sse2(p_source, p_count, p_output, scale); +#elif defined( AUDIO_MATH_NEON ) + neon_convert_from_int16(p_source, p_count, p_output, scale); +#else + noopt_convert_from_int16(p_source, p_count, p_output, scale); +#endif + } + + void audio_math::convert_from_int16(const t_int16* p_source, t_size p_count, double* p_output, double p_scale) + { + double scale = (double)(p_scale / (double)0x8000); +#if defined(AUDIO_MATH_SSE) +#if allowAVX + if (haveAVX) { + convert_from_int16_avx(p_source, p_count, p_output, scale); + } else +#endif + { + convert_from_int16_sse2(p_source, p_count, p_output, scale); + } +#elif defined( AUDIO_MATH_NEON_FLOAT64 ) + neon_convert_from_int16(p_source, p_count, p_output, scale); +#else + noopt_convert_from_int16(p_source, p_count, p_output, scale); +#endif + } + + void audio_math::convert_to_int32(const float* p_source, t_size p_count, t_int32* p_output, float p_scale) + { + float scale = (float)(p_scale * 0x80000000ul); +#if defined(AUDIO_MATH_NEON) + neon_convert_to_int32(p_source, p_count, p_output, scale); +#elif defined(AUDIO_MATH_SSE) + convert_to_32bit_sse2(p_source, p_count, p_output, scale); +#else + noopt_convert_to_32bit(p_source, p_count, p_output, scale); +#endif + } + + void audio_math::convert_to_int32(const double* p_source, t_size p_count, t_int32* p_output, double p_scale) + { + double scale = (double)(p_scale * 0x80000000ul); +#if defined(AUDIO_MATH_SSE) + convert_to_32bit_sse2(p_source, p_count, p_output, scale); +#else + noopt_convert_to_32bit(p_source, p_count, p_output, scale); +#endif + } + + void audio_math::convert_from_int32(const t_int32* p_source, t_size p_count, float* p_output, float p_scale) + { + float scale = (float)(p_scale / (double)0x80000000ul); + // Note: speed difference here is marginal over compiler output as of Xcode 12 +#if defined(AUDIO_MATH_NEON) + neon_convert_from_int32(p_source, p_count, p_output, scale); +#elif defined(AUDIO_MATH_SSE) + sse_convert_from_int32(p_source, p_count, p_output, scale); +#else + noopt_convert_from_int32(p_source, p_count, p_output, scale); +#endif + } + + void audio_math::convert_from_int32(const t_int32* p_source, t_size p_count, double* p_output, double p_scale) + { + double scale = (double)(p_scale / (double)0x80000000ul); +#if defined(AUDIO_MATH_SSE) + sse_convert_from_int32(p_source, p_count, p_output, scale); +#else + noopt_convert_from_int32(p_source, p_count, p_output, scale); +#endif + } + + float audio_math::calculate_peak(const float * p_source, t_size p_count) { +#if defined(AUDIO_MATH_SSE) + return sse_calculate_peak(p_source, p_count); +#elif defined(AUDIO_MATH_NEON) + return neon_calculate_peak(p_source, p_count); +#else + return noopt_calculate_peak(p_source, p_count); +#endif + } + double audio_math::calculate_peak(const double * p_source, t_size p_count) { +#if defined(AUDIO_MATH_SSE) + // Note that avx_calculate_peak failed to score better than sse_calculate_peak + return sse_calculate_peak(p_source, p_count); +#else + return noopt_calculate_peak(p_source, p_count); +#endif + } + + void audio_math::remove_denormals(float* p_buffer, t_size p_count) { + t_uint32* ptr = reinterpret_cast(p_buffer); + for (; p_count; p_count--) + { + t_uint32 t = *ptr; + if ((t & 0x007FFFFF) && !(t & 0x7F800000)) *ptr = 0; + ptr++; + } + } + void audio_math::remove_denormals(double* p_buffer, t_size p_count) { + t_uint64* ptr = reinterpret_cast(p_buffer); + for (; p_count; p_count--) + { + t_uint64 t = *ptr; + if ((t & 0x000FFFFFFFFFFFFF) && !(t & 0x7FF0000000000000)) *ptr = 0; + ptr++; + } + } + + void audio_math::add_offset(float* p_buffer, float p_delta, size_t p_count) { + for (size_t n = 0; n < p_count; ++n) p_buffer[n] += p_delta; + } + void audio_math::add_offset(double* p_buffer, double p_delta, size_t p_count) { + for (size_t n = 0; n < p_count; ++n) p_buffer[n] += p_delta; + } + + void audio_math::convert(const float* in, float* out, size_t count) { + memcpy(out, in, count * sizeof(float)); + } + void audio_math::convert(const float* in, float* out, size_t count, float scale) { + audio_math::scale(in, count, out, scale); + } + void audio_math::convert(const double* in, double* out, size_t count) { + memcpy(out, in, count * sizeof(double)); + } + void audio_math::convert(const double* in, double* out, size_t count, double scale) { + audio_math::scale(in, count, out, scale); + } + + void audio_math::convert(const float* in, double* out, size_t count) { + // optimize me + noopt_convert(in, out, count); + } + void audio_math::convert(const float* in, double* out, size_t count, double scale) { + // optimize me + noopt_scale(in, count, out, scale); + } + void audio_math::convert(const double* in, float* out, size_t count) { + // optimize me + noopt_convert(in, out, count); + } + void audio_math::convert(const double* in, float* out, size_t count, double scale) { + // optimize me + noopt_scale(in, count, out, scale); + } + + + typedef char store24_t; + static store24_t* store24(store24_t* out, int32_t in) { + *(out++) = ((store24_t*)&in)[0]; + *(out++) = ((store24_t*)&in)[1]; + *(out++) = ((store24_t*)&in)[2]; + return out; + } + static store24_t* store24p(store24_t* out, int32_t in) { + *(int32_t*)out = in; + return out + 3; + } + + static constexpr int32_t INT24_MAX = 0x7FFFFF, INT24_MIN = -0x800000; + + template void convert_to_int24_noopt(float_t const* in, size_t count, void* out, float_t scale) { + if (count == 0) return; + --count; + auto ptr = reinterpret_cast(out); + constexpr float_t lo = INT24_MIN, hi = INT24_MAX; + while (count) { + auto vf = *in++ * scale; + if (vf < lo) vf = lo; + else if (vf > hi) vf = hi; + ptr = store24p(ptr, audio_math::rint32(vf)); + --count; + } + + auto vf = *in * scale; + if (vf < lo) vf = lo; + else if (vf > hi) vf = hi; + store24(ptr, audio_math::rint32(vf)); + } +#ifdef AUDIO_MATH_SSE +#if allowAVX + static void f64_to_i24_avx(double const* in, size_t n, uint8_t* out, double scale) { + const __m128i pi0 = _mm_set_epi8(-128, -128, -128, -128, 14, 13, 12, 10, 9, 8, 6, 5, 4, 2, 1, 0); + const __m128i pi1 = _mm_set_epi8(4, 2, 1, 0, -128, -128, -128, -128, 14, 13, 12, 10, 9, 8, 6, 5); + const __m128i pi2 = _mm_set_epi8(9, 8, 6, 5, 4, 2, 1, 0, -128, -128, -128, -128, 14, 13, 12, 10); + const __m128i pi3 = _mm_set_epi8(14, 13, 12, 10, 9, 8, 6, 5, 4, 2, 1, 0, -128, -128, -128, -128); + const auto mul = _mm256_set1_pd(scale); + + // PROBLEM: if we want to handle wildly out-of-bounds values, we can't do int clipping! + // float clipping is sadly considerably slower than int clipping + const auto lo = _mm256_set1_pd(INT24_MIN); + const auto hi = _mm256_set1_pd(INT24_MAX); + + while (n >= 4 * 4) { + auto f0 = _mm256_mul_pd(_mm256_loadu_pd(in + 0), mul); + auto f1 = _mm256_mul_pd(_mm256_loadu_pd(in + 4), mul); + auto f2 = _mm256_mul_pd(_mm256_loadu_pd(in + 8), mul); + auto f3 = _mm256_mul_pd(_mm256_loadu_pd(in + 12), mul); + f0 = _mm256_max_pd(_mm256_min_pd(f0, hi), lo); + f1 = _mm256_max_pd(_mm256_min_pd(f1, hi), lo); + f2 = _mm256_max_pd(_mm256_min_pd(f2, hi), lo); + f3 = _mm256_max_pd(_mm256_min_pd(f3, hi), lo); + __m128i w0 = _mm256_cvtpd_epi32(f0); + __m128i w1 = _mm256_cvtpd_epi32(f1); + __m128i w2 = _mm256_cvtpd_epi32(f2); + __m128i w3 = _mm256_cvtpd_epi32(f3); + + // _mm_shuffle_epi8 : SSSE3 + w0 = _mm_shuffle_epi8(w0, pi0); + w1 = _mm_shuffle_epi8(w1, pi1); + w2 = _mm_shuffle_epi8(w2, pi2); + w3 = _mm_shuffle_epi8(w3, pi3); + + // _mm_blend_epi16 : SSE4.1 + __m128i u0 = _mm_blend_epi16(w0, w1, 0xC0); + __m128i u1 = _mm_blend_epi16(w1, w2, 0xF0); + __m128i u2 = _mm_blend_epi16(w2, w3, 0xFC); + + _mm_storeu_si128((__m128i*)(out + 0), u0); + _mm_storeu_si128((__m128i*)(out + 16), u1); + _mm_storeu_si128((__m128i*)(out + 32), u2); + + in += 4 * 4; + out += 16 * 3; + n -= 4 * 4; + } + + convert_to_int24_noopt(in, n, out, scale); + } +#endif // allowAVX + static void f64_to_i24_sse41(double const* in, size_t n, uint8_t* out, double scale) { + const __m128i pi0 = _mm_set_epi8(-128, -128, -128, -128, 14, 13, 12, 10, 9, 8, 6, 5, 4, 2, 1, 0); + const __m128i pi1 = _mm_set_epi8(4, 2, 1, 0, -128, -128, -128, -128, 14, 13, 12, 10, 9, 8, 6, 5); + const __m128i pi2 = _mm_set_epi8(9, 8, 6, 5, 4, 2, 1, 0, -128, -128, -128, -128, 14, 13, 12, 10); + const __m128i pi3 = _mm_set_epi8(14, 13, 12, 10, 9, 8, 6, 5, 4, 2, 1, 0, -128, -128, -128, -128); + const auto mul = _mm_set1_pd(scale); + + // PROBLEM: if we want to handle wildly out-of-bounds values, we can't do int clipping! + // float clipping is sadly considerably slower than int clipping + const auto lo = _mm_set1_pd(INT24_MIN); + const auto hi = _mm_set1_pd(INT24_MAX); + + while (n >= 4 * 4) { + auto f0 = _mm_mul_pd(_mm_loadu_pd(in + 0), mul); + auto f1 = _mm_mul_pd(_mm_loadu_pd(in + 2), mul); + auto f2 = _mm_mul_pd(_mm_loadu_pd(in + 4), mul); + auto f3 = _mm_mul_pd(_mm_loadu_pd(in + 6), mul); + auto f4 = _mm_mul_pd(_mm_loadu_pd(in + 8), mul); + auto f5 = _mm_mul_pd(_mm_loadu_pd(in + 10), mul); + auto f6 = _mm_mul_pd(_mm_loadu_pd(in + 12), mul); + auto f7 = _mm_mul_pd(_mm_loadu_pd(in + 14), mul); + f0 = _mm_max_pd(_mm_min_pd(f0, hi), lo); + f1 = _mm_max_pd(_mm_min_pd(f1, hi), lo); + f2 = _mm_max_pd(_mm_min_pd(f2, hi), lo); + f3 = _mm_max_pd(_mm_min_pd(f3, hi), lo); + f4 = _mm_max_pd(_mm_min_pd(f4, hi), lo); + f5 = _mm_max_pd(_mm_min_pd(f5, hi), lo); + f6 = _mm_max_pd(_mm_min_pd(f6, hi), lo); + f7 = _mm_max_pd(_mm_min_pd(f7, hi), lo); + + + + __m128i w0 = _mm_unpacklo_epi64(_mm_cvtpd_epi32(f0), _mm_cvtpd_epi32(f1)); + __m128i w1 = _mm_unpacklo_epi64(_mm_cvtpd_epi32(f2), _mm_cvtpd_epi32(f3)); + __m128i w2 = _mm_unpacklo_epi64(_mm_cvtpd_epi32(f4), _mm_cvtpd_epi32(f5)); + __m128i w3 = _mm_unpacklo_epi64(_mm_cvtpd_epi32(f6), _mm_cvtpd_epi32(f7)); + + // _mm_shuffle_epi8 : SSSE3 + w0 = _mm_shuffle_epi8(w0, pi0); + w1 = _mm_shuffle_epi8(w1, pi1); + w2 = _mm_shuffle_epi8(w2, pi2); + w3 = _mm_shuffle_epi8(w3, pi3); + + // _mm_blend_epi16 : SSE4.1 + __m128i u0 = _mm_blend_epi16(w0, w1, 0xC0); + __m128i u1 = _mm_blend_epi16(w1, w2, 0xF0); + __m128i u2 = _mm_blend_epi16(w2, w3, 0xFC); + + _mm_storeu_si128((__m128i*)(out + 0), u0); + _mm_storeu_si128((__m128i*)(out + 16), u1); + _mm_storeu_si128((__m128i*)(out + 32), u2); + + in += 4 * 4; + out += 16 * 3; + n -= 4 * 4; + } + + convert_to_int24_noopt(in, n, out, scale); + } + static void f32_to_i24_sse41(float const* in, size_t n, uint8_t* out, float scale) { + const __m128i pi0 = _mm_set_epi8(-128, -128, -128, -128, 14, 13, 12, 10, 9, 8, 6, 5, 4, 2, 1, 0); + const __m128i pi1 = _mm_set_epi8(4, 2, 1, 0, -128, -128, -128, -128, 14, 13, 12, 10, 9, 8, 6, 5); + const __m128i pi2 = _mm_set_epi8(9, 8, 6, 5, 4, 2, 1, 0, -128, -128, -128, -128, 14, 13, 12, 10); + const __m128i pi3 = _mm_set_epi8(14, 13, 12, 10, 9, 8, 6, 5, 4, 2, 1, 0, -128, -128, -128, -128); + const __m128 mul = _mm_set1_ps(scale); + + // PROBLEM: if we want to handle wildly out-of-bounds values, we can't do int clipping! + // float clipping is sadly considerably slower than int clipping + const auto lo = _mm_set1_ps(INT24_MIN); + const auto hi = _mm_set1_ps(INT24_MAX); + + while (n >= 4 * 4) { + auto f0 = _mm_mul_ps(_mm_loadu_ps(in + 0), mul); + auto f1 = _mm_mul_ps(_mm_loadu_ps(in + 4), mul); + auto f2 = _mm_mul_ps(_mm_loadu_ps(in + 8), mul); + auto f3 = _mm_mul_ps(_mm_loadu_ps(in + 12), mul); + f0 = _mm_min_ps(_mm_max_ps(f0, lo), hi); + f1 = _mm_min_ps(_mm_max_ps(f1, lo), hi); + f2 = _mm_min_ps(_mm_max_ps(f2, lo), hi); + f3 = _mm_min_ps(_mm_max_ps(f3, lo), hi); + __m128i w0 = _mm_cvtps_epi32(f0); + __m128i w1 = _mm_cvtps_epi32(f1); + __m128i w2 = _mm_cvtps_epi32(f2); + __m128i w3 = _mm_cvtps_epi32(f3); + + // _mm_shuffle_epi8 : SSSE3 + w0 = _mm_shuffle_epi8(w0, pi0); + w1 = _mm_shuffle_epi8(w1, pi1); + w2 = _mm_shuffle_epi8(w2, pi2); + w3 = _mm_shuffle_epi8(w3, pi3); + + // _mm_blend_epi16 : SSE4.1 + __m128i u0 = _mm_blend_epi16(w0, w1, 0xC0); + __m128i u1 = _mm_blend_epi16(w1, w2, 0xF0); + __m128i u2 = _mm_blend_epi16(w2, w3, 0xFC); + + _mm_storeu_si128((__m128i*)(out + 0), u0); + _mm_storeu_si128((__m128i*)(out + 16), u1); + _mm_storeu_si128((__m128i*)(out + 32), u2); + + in += 4 * 4; + out += 16 * 3; + n -= 4 * 4; + } + + convert_to_int24_noopt(in, n, out, scale); + } + +#endif // AUDIO_MATH_SSE + + void audio_math::convert_to_int24(const float* in, size_t count, void* out, float scale) { + scale *= 0x800000; + +#ifdef AUDIO_MATH_SSE + if (haveSSE41) { + f32_to_i24_sse41(in, count, (uint8_t*)out, scale); return; + } +#endif + convert_to_int24_noopt(in, count, out, scale); + } + void audio_math::convert_to_int24(const double* in, size_t count, void* out, double scale) { + scale *= 0x800000; +#ifdef AUDIO_MATH_SSE +#if allowAVX + if (haveAVX) { + f64_to_i24_avx(in, count, (uint8_t*)out, scale); return; + } +#endif // allowAVX + if (haveSSE41) { + f64_to_i24_sse41(in, count, (uint8_t*)out, scale); return; + } +#endif // AUDIO_MATH_SSE + convert_to_int24_noopt(in, count, out, scale); + } + +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/audio_sample.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/audio_sample.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,76 @@ +#include "pfc-lite.h" +#include "audio_sample.h" +#include "primitives.h" +#include "byte_order.h" + +namespace pfc { + float audio_math::decodeFloat24ptr(const void* sourcePtr) { + PFC_STATIC_ASSERT(pfc::byte_order_is_little_endian); + union { + uint8_t bytes[4]; + float v; + } u; + const uint8_t* s = reinterpret_cast(sourcePtr); + u.bytes[0] = 0; + u.bytes[1] = s[0]; + u.bytes[2] = s[1]; + u.bytes[3] = s[2]; + return u.v; + } + float audio_math::decodeFloat24ptrbs(const void* sourcePtr) { + PFC_STATIC_ASSERT(pfc::byte_order_is_little_endian); + union { + uint8_t bytes[4]; + float v; + } u; + const uint8_t* s = reinterpret_cast(sourcePtr); + u.bytes[0] = 0; + u.bytes[1] = s[2]; + u.bytes[2] = s[1]; + u.bytes[3] = s[0]; + return u.v; + } + + float audio_math::decodeFloat16(uint16_t source) { + const unsigned fractionBits = 10; + const unsigned widthBits = 16; + typedef uint16_t source_t; + + /* typedef uint64_t out_t; typedef double retval_t; + enum { + outExponent = 11, + outFraction = 52, + outExponentShift = (1 << (outExponent-1))-1 + };*/ + + typedef uint32_t out_t; typedef float retval_t; + enum { + outExponent = 8, + outFraction = 23, + outExponentShift = (1 << (outExponent - 1)) - 1 + }; + + const unsigned exponentBits = widthBits - fractionBits - 1; + // 1 bit sign | exponent | fraction + source_t fraction = source & (((source_t)1 << fractionBits) - 1); + source >>= fractionBits; + int exponent = (int)(source & (((source_t)1 << exponentBits) - 1)) - (int)((1 << (exponentBits - 1)) - 1); + source >>= exponentBits; + + if constexpr (outExponent + outExponentShift <= 0) return 0; + + out_t output = (out_t)(source & 1); + output <<= outExponent; + output |= (unsigned)(exponent + outExponentShift) & ((1 << outExponent) - 1); + output <<= outFraction; + int shift = (int)outFraction - (int)fractionBits; + if (shift < 0) output |= (out_t)(fraction >> -shift); + else output |= (out_t)(fraction << shift); + return *(retval_t*)&output / pfc::audio_math::float16scale; + } + + unsigned audio_math::bitrate_kbps(uint64_t fileSize, double duration) { + if (fileSize > 0 && duration > 0) return (unsigned)floor((double)fileSize * 8 / (duration * 1000) + 0.5); + return 0; + } +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/audio_sample.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/audio_sample.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,75 @@ +#pragma once +#include + +#ifdef _MSC_VER +#include +#endif + + +namespace pfc { + // made a class so it can be redirected to an alternate class more easily than with namespacing + // in win desktop fb2k these are implemented in a DLL + class audio_math { + public: + + //! p_source/p_output can point to same buffer + static void convert_to_int16(const float* p_source, size_t p_count, int16_t * p_output, float p_scale); + static void convert_to_int16(const double* p_source, size_t p_count, int16_t* p_output, double p_scale); + static void convert_to_int32(const float* p_source, size_t p_count, int32_t * p_output, float p_scale); + static void convert_to_int32(const double* p_source, size_t p_count, int32_t* p_output, double p_scale); + static void convert_from_int16(const int16_t * p_source, size_t p_count, float * p_output, float p_scale); + static void convert_from_int16(const int16_t* p_source, size_t p_count, double * p_output, double p_scale); + static void convert_from_int32(const int32_t* p_source, size_t p_count, float* p_output, float p_scale); + static void convert_from_int32(const int32_t* p_source, size_t p_count, double* p_output, double p_scale); + static void convert_to_int24(const float* in, size_t count, void* out, float scale); + static void convert_to_int24(const double* in, size_t count, void* out, double scale); + + static float calculate_peak(const float * p_source, size_t p_count); + static double calculate_peak(const double * p_source, size_t p_count); + + static void remove_denormals(float * p_buffer, size_t p_count); + static void remove_denormals(double * p_buffer, size_t p_count); + + + static void add_offset(float * p_buffer, float p_delta, size_t p_count); + static void add_offset(double * p_buffer, double p_delta, size_t p_count); + + static void scale(const float* p_source, size_t p_count, float * p_output, float p_scale); + static void scale(const double* p_source, size_t p_count, double * p_output, double p_scale); + + static void convert(const float* in, float* out, size_t count); + static void convert(const float* in, float* out, size_t count, float scale); + static void convert(const float* in, double* out, size_t count); + static void convert(const float* in, double* out, size_t count, double scale); + static void convert(const double* in, float* out, size_t count); + static void convert(const double* in, float* out, size_t count, double scale); + static void convert(const double* in, double* out, size_t count); + static void convert(const double* in, double* out, size_t count, double scale); + + inline static int64_t rint64(float val) { return (int64_t)llrint(val); } + inline static int32_t rint32(float val) { return (int32_t)lrint(val); } + inline static int64_t rint64(double val) { return (int64_t)llrint(val); } + inline static int32_t rint32(double val) { return (int32_t)lrint(val); } + + static inline uint64_t time_to_samples(double p_time, uint32_t p_sample_rate) { + return (uint64_t)pfc::rint64((double)p_sample_rate * p_time); + } + + static inline double samples_to_time(uint64_t p_samples, uint32_t p_sample_rate) { + PFC_ASSERT(p_sample_rate > 0); + return (double)p_samples / (double)p_sample_rate; + } + + static inline double gain_to_scale(double p_gain) { return pow(10.0, p_gain / 20.0); } + static inline double scale_to_gain(double scale) { return 20.0*log10(scale); } + + static unsigned bitrate_kbps( uint64_t fileSize, double duration ); + + static constexpr float float16scale = 65536.f; + + static float decodeFloat24ptr(const void* sourcePtr); + static float decodeFloat24ptrbs(const void* sourcePtr); + static float decodeFloat16(uint16_t source); + }; // class audio_math + +} // namespace pfc diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/autoref.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/autoref.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,39 @@ +#pragma once +#include +#include "ptrholder.h" + +namespace pfc { + + // autoref<> : turn arbitrary ptr that needs to be delete'd into a shared_ptr<> alike + template class autoref { + public: + autoref() {} + autoref(std::nullptr_t) {} + autoref(obj_t * source) { + attach(source); + } + void attach(obj_t * source) { + PFC_ASSERT( source != nullptr ); + m_obj = std::make_shared(source); + } + void reset() { + m_obj.reset(); + } + + obj_t * operator->() const { + return m_obj->get_ptr(); + } + + obj_t * get() const { + if (! m_obj ) return nullptr; + return m_obj->get_ptr(); + } + + operator bool() const { + return !!m_obj; + } + private: + typedef pfc::ptrholder_t< obj_t > holder_t; + std::shared_ptr< holder_t > m_obj; + }; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/avltree.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/avltree.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,578 @@ +#pragma once + +#include "iterators.h" + +namespace pfc { + + template + class _avltree_node : public _list_node { + public: + typedef _list_node t_node; + typedef _avltree_node t_self; + template _avltree_node(t_param const& param) : t_node(param) {} + + typedef refcounted_object_ptr_t t_ptr; + typedef t_self* t_rawptr; + + t_ptr m_left, m_right; // smart ptr, no init + t_rawptr m_parent = nullptr; + + t_size m_depth = 0; + + void link_left(t_self* ptr) throw() { + m_left = ptr; + if (ptr != NULL) ptr->m_parent = this; + } + void link_right(t_self* ptr) throw() { + m_right = ptr; + if (ptr != NULL) ptr->m_parent = this; + } + + void link_child(bool which,t_self* ptr) throw() { + (which ? m_right : m_left) = ptr; + if (ptr != NULL) ptr->m_parent = this; + } + + void unlink() throw() { + m_left.release(); m_right.release(); m_parent = NULL; m_depth = 0; + } + + inline void add_ref() throw() {this->refcount_add_ref();} + inline void release() throw() {this->refcount_release();} + + inline t_rawptr child(bool which) const throw() {return which ? m_right.get_ptr() : m_left.get_ptr();} + inline bool which_child(const t_self* ptr) const throw() {return ptr == m_right.get_ptr();} + + + + t_rawptr step(bool direction) throw() { + t_self* walk = this; + for(;;) { + t_self* t = walk->child(direction); + if (t != NULL) return t->peakchild(!direction); + for(;;) { + t = walk->m_parent; + if (t == NULL) return NULL; + if (t->which_child(walk) != direction) return t; + walk = t; + } + } + } + t_rawptr peakchild(bool direction) throw() { + t_self* walk = this; + for(;;) { + t_rawptr next = walk->child(direction); + if (next == NULL) return walk; + walk = next; + } + } + t_node * prev() throw() {return step(false);} + t_node * next() throw() {return step(true);} + private: + ~_avltree_node() throw() {} + }; + + + template + class avltree_t { + public: + typedef avltree_t t_self; + typedef pfc::const_iterator const_iterator; + typedef pfc::iterator iterator; + typedef pfc::forward_iterator forward_iterator; + typedef pfc::forward_const_iterator forward_const_iterator; + typedef t_storage t_item; + private: + typedef _avltree_node t_node; +#if 1//MSVC8 bug fix + typedef refcounted_object_ptr_t t_nodeptr; + typedef t_node * t_noderawptr; +#else + typedef typename t_node::t_ptr t_nodeptr; + typedef typename t_node::t_rawptr t_noderawptr; +#endif + + static bool is_ptr_valid(t_nodeptr const & p) { return p.is_valid(); } + static bool is_ptr_valid(t_node const * p) { return p != NULL; } + + template + inline static int compare(const t_item1 & p_item1, const t_item2 & p_item2) { + return t_comparator::compare(p_item1,p_item2); + } + + t_nodeptr m_root; + + static t_size calc_depth(const t_nodeptr & ptr) + { + return ptr.is_valid() ? 1+ptr->m_depth : 0; + } + + static void recalc_depth(t_nodeptr const& ptr) { + ptr->m_depth = pfc::max_t(calc_depth(ptr->m_left), calc_depth(ptr->m_right)); + } + + static void assert_children(t_nodeptr ptr) { + PFC_ASSERT(ptr->m_depth == pfc::max_t(calc_depth(ptr->m_left),calc_depth(ptr->m_right)) ); + } + + static t_ssize test_depth(t_nodeptr const& ptr) + { + if (ptr==0) return 0; + else return calc_depth(ptr->m_right) - calc_depth(ptr->m_left); + } + + static t_nodeptr extract_left_leaf(t_nodeptr & p_base) { + if (is_ptr_valid(p_base->m_left)) { + t_nodeptr ret = extract_left_leaf(p_base->m_left); + recalc_depth(p_base); + g_rebalance(p_base); + return ret; + } else { + t_nodeptr node = p_base; + p_base = node->m_right; + if (p_base.is_valid()) p_base->m_parent = node->m_parent; + node->m_right.release(); + node->m_depth = 0; + node->m_parent = NULL; + return node; + } + } + + static t_nodeptr extract_right_leaf(t_nodeptr & p_base) { + if (is_ptr_valid(p_base->m_right)) { + t_nodeptr ret = extract_right_leaf(p_base->m_right); + recalc_depth(p_base); + g_rebalance(p_base); + return ret; + } else { + t_nodeptr node = p_base; + p_base = node->m_left; + if (p_base.is_valid()) p_base->m_parent = node->m_parent; + node->m_left.release(); + node->m_depth = 0; + node->m_parent = NULL; + return node; + } + } + + static void remove_internal(t_nodeptr & p_node) { + t_nodeptr oldval = p_node; + if (p_node->m_left.is_empty()) { + p_node = p_node->m_right; + if (p_node.is_valid()) p_node->m_parent = oldval->m_parent; + } else if (p_node->m_right.is_empty()) { + p_node = p_node->m_left; + if (p_node.is_valid()) p_node->m_parent = oldval->m_parent; + } else { + t_nodeptr swap = extract_left_leaf(p_node->m_right); + + swap->link_left(oldval->m_left.get_ptr()); + swap->link_right(oldval->m_right.get_ptr()); + swap->m_parent = oldval->m_parent; + recalc_depth(swap); + p_node = swap; + } + oldval->unlink(); + } + + template + static void __enum_items_recur(t_nodewalk * p_node,t_callback && p_callback) { + if (is_ptr_valid(p_node)) { + __enum_items_recur(p_node->m_left.get_ptr(),p_callback); + p_callback (p_node->m_content); + __enum_items_recur(p_node->m_right.get_ptr(),p_callback); + } + } + template + static t_node * g_find_or_add_node(t_nodeptr & p_base,t_node * parent,t_search const & p_search,bool & p_new) + { + if (p_base.is_empty()) { + p_base = new t_node(p_search); + p_base->m_parent = parent; + p_new = true; + return p_base.get_ptr(); + } + + PFC_ASSERT( p_base->m_parent == parent ); + + int result = compare(p_base->m_content,p_search); + if (result > 0) { + t_node * ret = g_find_or_add_node(p_base->m_left,p_base.get_ptr(),p_search,p_new); + PFC_ASSERT(compare(ret->m_content, p_search) == 0); + if (p_new) { + recalc_depth(p_base); + g_rebalance(p_base); + } + return ret; + } else if (result < 0) { + t_node * ret = g_find_or_add_node(p_base->m_right,p_base.get_ptr(),p_search,p_new); + PFC_ASSERT(compare(ret->m_content, p_search) == 0); + if (p_new) { + recalc_depth(p_base); + g_rebalance(p_base); + } + return ret; + } else { + p_new = false; + return p_base.get_ptr(); + } + } + + + + template + static t_storage * g_find_or_add(t_nodeptr & p_base,t_node * parent,t_search const & p_search,bool & p_new) { + return &g_find_or_add_node(p_base,parent,p_search,p_new)->m_content; + } + + + static void g_rotate_right(t_nodeptr & oldroot) { + t_nodeptr newroot ( oldroot->m_right ); + oldroot->link_child(true, newroot->m_left.get_ptr()); + newroot->m_left = oldroot; + newroot->m_parent = oldroot->m_parent; + oldroot->m_parent = newroot.get_ptr(); + recalc_depth(oldroot); + recalc_depth(newroot); + oldroot = newroot; + } + + static void g_rotate_left(t_nodeptr & oldroot) { + t_nodeptr newroot ( oldroot->m_left ); + oldroot->link_child(false, newroot->m_right.get_ptr()); + newroot->m_right = oldroot; + newroot->m_parent = oldroot->m_parent; + oldroot->m_parent = newroot.get_ptr(); + recalc_depth(oldroot); + recalc_depth(newroot); + oldroot = newroot; + } + + static void g_rebalance(t_nodeptr & p_node) { + t_ssize balance = test_depth(p_node); + if (balance > 1) { + //right becomes root + if (test_depth(p_node->m_right) < 0) { + g_rotate_left(p_node->m_right); + } + g_rotate_right(p_node); + } else if (balance < -1) { + //left becomes root + if (test_depth(p_node->m_left) > 0) { + g_rotate_right(p_node->m_left); + } + g_rotate_left(p_node); + } + selftest(p_node); + } + + template + static bool g_remove(t_nodeptr & p_node,t_search const & p_search) { + if (p_node.is_empty()) return false; + + int result = compare(p_node->m_content,p_search); + if (result == 0) { + remove_internal(p_node); + if (is_ptr_valid(p_node)) { + recalc_depth(p_node); + g_rebalance(p_node); + } + return true; + } else { + if (g_remove(result > 0 ? p_node->m_left : p_node->m_right,p_search)) { + recalc_depth(p_node); + g_rebalance(p_node); + return true; + } else { + return false; + } + } + } + + static void selftest(t_nodeptr const& p_node) { + (void)p_node; + #if 0 //def _DEBUG//SLOW! + if (is_ptr_valid(p_node)) { + selftest(p_node->m_left); + selftest(p_node->m_right); + assert_children(p_node); + t_ssize delta = test_depth(p_node); + PFC_ASSERT(delta >= -1 && delta <= 1); + + if (p_node->m_left.is_valid()) { + PFC_ASSERT( p_node.get_ptr() == p_node->m_left->m_parent ); + } + if (p_node->m_right.is_valid()) { + PFC_ASSERT( p_node.get_ptr() == p_node->m_right->m_parent ); + } + + if (is_ptr_valid(p_node->m_parent)) { + PFC_ASSERT(p_node == p_node->m_parent->m_left || p_node == p_node->m_parent->m_right); + } + } + #endif + } + + + static t_size calc_count(const t_node * p_node) throw() { + if (is_ptr_valid(p_node)) { + return 1 + calc_count(p_node->m_left.get_ptr()) + calc_count(p_node->m_right.get_ptr()); + } else { + return 0; + } + } + + template + t_storage * _find_item_ptr(t_param const & p_item) const { + t_node* ptr = m_root.get_ptr(); + while(is_ptr_valid(ptr)) { + int result = compare(ptr->m_content,p_item); + if (result > 0) ptr=ptr->m_left.get_ptr(); + else if (result < 0) ptr=ptr->m_right.get_ptr(); + else return &ptr->m_content; + } + return NULL; + } + + template + t_node * _find_node_ptr(t_param const & p_item) const { + t_node* ptr = m_root.get_ptr(); + while(is_ptr_valid(ptr)) { + int result = compare(ptr->m_content,p_item); + if (result > 0) ptr=ptr->m_left.get_ptr(); + else if (result < 0) ptr=ptr->m_right.get_ptr(); + else return ptr; + } + return NULL; + } + + template t_storage * __find_nearest(const t_search & p_search) const { + t_node * ptr = m_root.get_ptr(); + t_storage * found = NULL; + while(is_ptr_valid(ptr)) { + int result = compare(ptr->m_content,p_search); + if (above) result = -result; + if (inclusive && result == 0) { + //direct hit + found = &ptr->m_content; + break; + } else if (result < 0) { + //match + found = &ptr->m_content; + ptr = ptr->child(!above); + } else { + //mismatch + ptr = ptr->child(above); + } + } + return found; + } + public: + avltree_t() : m_root(NULL) {} + ~avltree_t() {reset();} + const t_self & operator=(const t_self & p_other) {__copy(p_other);return *this;} + avltree_t(const t_self & p_other) : m_root(NULL) {try{__copy(p_other);} catch(...) {remove_all(); throw;}} + + template const t_self & operator=(const t_other & p_other) {copy_list_enumerated(*this,p_other);return *this;} + template avltree_t(const t_other & p_other) : m_root(NULL) {try{copy_list_enumerated(*this,p_other);}catch(...){remove_all(); throw;}} + + + template const t_storage * find_nearest_item(const t_search & p_search) const { + return __find_nearest(p_search); + } + + template t_storage * find_nearest_item(const t_search & p_search) { + return __find_nearest(p_search); + } + + avltree_t( t_self && other ) { + m_root = std::move( other.m_root ); other.m_root.release(); + } + + const t_self & operator=( t_self && other ) { + move_from ( other ); return *this; + } + + void move_from( t_self & other ) { + reset(); m_root = std::move( other.m_root ); other.m_root.release(); + } + + template + t_storage & add_item(t_param const & p_item) { + bool dummy; + return add_item_ex(p_item,dummy); + } + + template + t_self & operator+=(const t_param & p_item) {add_item(p_item);return *this;} + + template + t_self & operator-=(const t_param & p_item) {remove_item(p_item);return *this;} + + //! Returns true when the list has been altered, false when the item was already present before. + template + bool add_item_check(t_param const & item) { + bool isNew = false; + g_find_or_add(m_root,NULL,item,isNew); + selftest(m_root); + return isNew; + } + template + t_storage & add_item_ex(t_param const & p_item,bool & p_isnew) { + t_storage * ret = g_find_or_add(m_root,NULL,p_item,p_isnew); + selftest(m_root); + return *ret; + } + + template + void set_item(const t_param & p_item) { + bool isnew; + t_storage & found = add_item_ex(p_item,isnew); + if (isnew) found = p_item; + } + + template + const t_storage * find_item_ptr(t_param const & p_item) const {return _find_item_ptr(p_item);} + + //! Unsafe! Caller must not modify items in a way that changes sort order! + template + t_storage * find_item_ptr(t_param const & p_item) { return _find_item_ptr(p_item); } + + template const_iterator find(t_param const & item) const { return _find_node_ptr(item);} + + //! Unsafe! Caller must not modify items in a way that changes sort order! + template iterator find(t_param const & item) { return _find_node_ptr(item);} + + + template + bool contains(const t_param & p_item) const { + return find_item_ptr(p_item) != NULL; + } + + //! Same as contains(). + template + bool have_item(const t_param & p_item) const {return contains(p_item);} + + void remove_all() throw() { + _unlink_recur(m_root); + m_root.release(); + } + void clear() throw() { remove_all(); } + + bool remove(const_iterator const& iter) { + PFC_ASSERT(iter.is_valid()); + return remove_item(*iter);//OPTIMIZEME + //should never return false unless there's a bug in calling code + } + + template + bool remove_item(t_param const & p_item) { + bool ret = g_remove(m_root,p_item); + selftest(m_root); + return ret; + } + + t_size get_count() const throw() { return calc_count(m_root.get_ptr()); } + size_t size() const throw() { return get_count(); } + + template + void enumerate(t_callback && p_callback) const { + __enum_items_recur(m_root.get_ptr(),p_callback); + } + + //! Allows callback to modify the tree content. + //! Unsafe! Caller must not modify items in a way that changes sort order! + template + void _enumerate_var(t_callback & p_callback) { __enum_items_recur(m_root.get_ptr(),p_callback); } + + template iterator insert(const t_param & p_item) { + bool isNew; + t_node * ret = g_find_or_add_node(m_root,NULL,p_item,isNew); + selftest(m_root); + return ret; + } + + //deprecated backwards compatibility method wrappers + template t_storage & add(const t_param & p_item) {return add_item(p_item);} + template t_storage & add_ex(const t_param & p_item,bool & p_isnew) {return add_item_ex(p_item,p_isnew);} + template const t_storage * find_ptr(t_param const & p_item) const {return find_item_ptr(p_item);} + template t_storage * find_ptr(t_param const & p_item) {return find_item_ptr(p_item);} + template bool exists(t_param const & p_item) const {return have_item(p_item);} + void reset() {remove_all();} + + + + + const_iterator first() const noexcept {return _firstlast(false);} + const_iterator last() const noexcept {return _firstlast(true);} + //! Unsafe! Caller must not modify items in a way that changes sort order! + iterator _first_var() { return _firstlast(false); } + //! Unsafe! Caller must not modify items in a way that changes sort order! + iterator _last_var() { return _firstlast(true); } + + const_iterator cfirst() const noexcept {return _firstlast(false);} + const_iterator clast() const noexcept {return _firstlast(true);} + + forward_const_iterator begin() const noexcept { return first(); } + forward_const_iterator end() const noexcept { return forward_const_iterator(); } + + template bool get_first(t_param & p_item) const throw() { + const_iterator iter = first(); + if (!iter.is_valid()) return false; + p_item = *iter; + return true; + } + template bool get_last(t_param & p_item) const throw() { + const_iterator iter = last(); + if (!iter.is_valid()) return false; + p_item = *iter; + return true; + } + + static bool equals(const t_self & v1, const t_self & v2) { + return listEquals(v1,v2); + } + bool operator==(const t_self & other) const {return equals(*this,other);} + bool operator!=(const t_self & other) const {return !equals(*this,other);} + + private: + static void _unlink_recur(t_nodeptr & node) { + if (node.is_valid()) { + _unlink_recur(node->m_left); + _unlink_recur(node->m_right); + node->unlink(); + } + } + t_node* _firstlast(bool which) const noexcept { + if (m_root.is_empty()) return nullptr; + for(t_node * walk = m_root.get_ptr(); ; ) { + t_node * next = walk->child(which); + if (next == nullptr) return walk; + PFC_ASSERT( next->m_parent == walk ); + walk = next; + } + } + static t_nodeptr __copy_recur(t_node * p_source,t_node * parent) { + if (p_source == NULL) { + return NULL; + } else { + t_nodeptr newnode = new t_node(p_source->m_content); + newnode->m_depth = p_source->m_depth; + newnode->m_left = __copy_recur(p_source->m_left.get_ptr(),newnode.get_ptr()); + newnode->m_right = __copy_recur(p_source->m_right.get_ptr(),newnode.get_ptr()); + newnode->m_parent = parent; + return newnode; + } + } + + void __copy(const t_self & p_other) { + reset(); + m_root = __copy_recur(p_other.m_root.get_ptr(),NULL); + selftest(m_root); + } + }; + + + template + class traits_t > : public traits_default_movable {}; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/base64.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/base64.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,124 @@ +#include "pfc-lite.h" +#include "base64.h" +#include "string_base.h" + +namespace bitWriter { + static void set_bit(t_uint8 * p_stream,size_t p_offset, bool state) { + t_uint8 mask = 1 << (7-(p_offset&7)); + t_uint8 & byte = p_stream[p_offset>>3]; + byte = (byte & ~mask) | (state ? mask : 0); + } + static void set_bits(t_uint8 * stream, t_size offset, t_size word, t_size bits) { + for(t_size walk = 0; walk < bits; ++walk) { + t_uint8 bit = (t_uint8)((word >> (bits - walk - 1))&1); + set_bit(stream, offset+walk, bit != 0); + } + } +}; + +namespace pfc { + static constexpr char alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + + static constexpr uint8_t alphabetRev[256] = + {0x40,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF + ,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF + ,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x3E,0xFF,0xFF,0xFF,0x3F + ,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF + ,0xFF,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E + ,0x0F,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0xFF,0xFF,0xFF,0xFF,0xFF + ,0xFF,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28 + ,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,0x30,0x31,0x32,0x33,0xFF,0xFF,0xFF,0xFF,0xFF + ,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF + ,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF + ,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF + ,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF + ,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF + ,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF + ,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF + ,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF + }; + + size_t base64_strlen( const char * text ) { + size_t ret = 0; + for ( size_t w = 0; ;++w ) { + uint8_t c = (uint8_t) text[w]; + if (c == 0) break; + if ( alphabetRev[c] != 0xFF ) ++ret; + } + return ret; + } + t_size base64_decode_estimate(const char * text) { + t_size textLen = base64_strlen(text); + return textLen * 3 / 4; + } + + mem_block base64_decode(const char* text) { + mem_block ret; ret.resize(base64_decode_estimate(text)); + base64_decode(text, ret.ptr()); + return ret; + } + + void base64_decode(const char * text, void * out) { + + size_t outWritePtr = 0; + size_t inTemp = 0; + uint8_t temp[3]; + for ( size_t textWalk = 0 ; ; ++ textWalk ) { + const uint8_t c = (uint8_t) text[textWalk]; + if (c == 0) break; + const uint8_t v = alphabetRev[ c ]; + if ( v != 0xFF ) { + PFC_ASSERT( inTemp + 6 <= 24 ); + bitWriter::set_bits(temp,inTemp,v,6); + inTemp += 6; + if ( inTemp == 24 ) { + memcpy( (uint8_t*) out + outWritePtr, temp, 3 ); + outWritePtr += 3; + inTemp = 0; + } + } + } + if ( inTemp > 0 ) { + size_t delta = inTemp / 8; + memcpy( (uint8_t*) out + outWritePtr, temp, delta ); + outWritePtr += delta; + inTemp = 0; + } +#if PFC_DEBUG + size_t estimated = base64_decode_estimate( text ) ; + PFC_ASSERT( outWritePtr == estimated ); +#endif + } + void base64_encode(pfc::string_base & out, const void * in, t_size inSize) { + out.reset(); base64_encode_append(out, in, inSize); + } + void base64_encode_append(pfc::string_base & out, const void * in, t_size inSize) { + int shift = 0; + int accum = 0; + const t_uint8 * inPtr = reinterpret_cast(in); + + for(t_size walk = 0; walk < inSize; ++walk) { + accum <<= 8; + shift += 8; + accum |= inPtr[walk]; + while ( shift >= 6 ) { + shift -= 6; + out << format_char( alphabet[(accum >> shift) & 0x3F] ); + } + } + if (shift == 4) { + out << format_char( alphabet[(accum & 0xF)<<2] ) << "="; + } else if (shift == 2) { + out << format_char( alphabet[(accum & 0x3)<<4] ) << "=="; + } + } + + void base64_decode_to_string( pfc::string_base & out, const char * text ) { + char * ptr = out.lock_buffer( base64_decode_estimate( text ) ); + base64_decode(text, ptr); + out.unlock_buffer(); + } + void base64_encode_from_string( pfc::string_base & out, const char * in ) { + base64_encode( out, in, strlen(in) ); + } +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/base64.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/base64.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,19 @@ +#pragma once + +namespace pfc { + class string_base; + void base64_encode(pfc::string_base & out, const void * in, t_size inSize); + void base64_encode_append(pfc::string_base & out, const void * in, t_size inSize); + void base64_encode_from_string( pfc::string_base & out, const char * in ); + t_size base64_decode_estimate(const char * text); + void base64_decode(const char * text, void * out); + mem_block base64_decode(const char* text); + + template void base64_decode_array(t_buffer & out, const char * text) { + PFC_STATIC_ASSERT( sizeof(out[0]) == 1 ); + out.set_size_discard( base64_decode_estimate(text) ); + base64_decode(text, out.get_ptr()); + } + + void base64_decode_to_string( pfc::string_base & out, const char * text ); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/bigmem.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/bigmem.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,59 @@ +#include "pfc-lite.h" +#include "bigmem.h" + +namespace pfc { + void bigmem::resize(size_t newSize) { + clear(); + m_data.set_size((newSize + slice - 1) / slice); + m_data.fill_null(); + for (size_t walk = 0; walk < m_data.get_size(); ++walk) { + size_t thisSlice = slice; + if (walk + 1 == m_data.get_size()) { + size_t cut = newSize % slice; + if (cut) thisSlice = cut; + } + void* ptr = malloc(thisSlice); + if (ptr == NULL) { clear(); throw std::bad_alloc(); } + m_data[walk] = (uint8_t*)ptr; + } + m_size = newSize; + } + void bigmem::clear() { + for (size_t walk = 0; walk < m_data.get_size(); ++walk) free(m_data[walk]); + m_data.set_size(0); + m_size = 0; + } + void bigmem::read(void* ptrOut, size_t bytes, size_t offset) const { + PFC_ASSERT(offset + bytes <= size()); + uint8_t* outWalk = (uint8_t*)ptrOut; + while (bytes > 0) { + size_t o1 = offset / slice, o2 = offset % slice; + size_t delta = slice - o2; if (delta > bytes) delta = bytes; + memcpy(outWalk, m_data[o1] + o2, delta); + offset += delta; + bytes -= delta; + outWalk += delta; + } + } + void bigmem::write(const void* ptrIn, size_t bytes, size_t offset) { + PFC_ASSERT(offset + bytes <= size()); + const uint8_t* inWalk = (const uint8_t*)ptrIn; + while (bytes > 0) { + size_t o1 = offset / slice, o2 = offset % slice; + size_t delta = slice - o2; if (delta > bytes) delta = bytes; + memcpy(m_data[o1] + o2, inWalk, delta); + offset += delta; + bytes -= delta; + inWalk += delta; + } + } + uint8_t* bigmem::_slicePtr(size_t which) { return m_data[which]; } + size_t bigmem::_sliceCount() { return m_data.get_size(); } + size_t bigmem::_sliceSize(size_t which) { + if (which + 1 == _sliceCount()) { + size_t s = m_size % slice; + if (s) return s; + } + return slice; + } +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/bigmem.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/bigmem.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,27 @@ +#pragma once + +#include "array.h" + +namespace pfc { + class bigmem { + public: + enum {slice = 1024*1024}; + bigmem() : m_size() {} + ~bigmem() {clear();} + + void resize(size_t newSize); + size_t size() const {return m_size;} + void clear(); + void read(void * ptrOut, size_t bytes, size_t offset) const; + void write(const void * ptrIn, size_t bytes, size_t offset); + uint8_t * _slicePtr(size_t which); + size_t _sliceCount(); + size_t _sliceSize(size_t which); + private: + array_t m_data; + size_t m_size; + + PFC_CLASS_NOT_COPYABLE_EX(bigmem) + }; + +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/binary_search.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/binary_search.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,83 @@ +#pragma once + +namespace pfc { + class comparator_default; + + template + class binarySearch { + public: + + template + static bool run(const t_container & p_container,t_size p_base,t_size p_count,const t_param & p_param,t_size & p_result) { + t_size max = p_base + p_count; + t_size min = p_base; + while(min> 1); + int state = t_comparator::compare(p_param,p_container[ptr]); + if (state > 0) min = ptr + 1; + else if (state < 0) max = ptr; + else { + p_result = ptr; + return true; + } + } + p_result = min; + return false; + } + + + template + static bool runGroupBegin(const t_container & p_container,t_size p_base,t_size p_count,const t_param & p_param,t_size & p_result) { + t_size max = p_base + p_count; + t_size min = p_base; + bool found = false; + while(min> 1); + int state = t_comparator::compare(p_param,p_container[ptr]); + if (state > 0) min = ptr + 1; + else if (state < 0) max = ptr; + else { + found = true; max = ptr; + } + } + p_result = min; + return found; + } + + template + static bool runGroupEnd(const t_container & p_container,t_size p_base,t_size p_count,const t_param & p_param,t_size & p_result) { + t_size max = p_base + p_count; + t_size min = p_base; + bool found = false; + while(min> 1); + int state = t_comparator::compare(p_param,p_container[ptr]); + if (state > 0) min = ptr + 1; + else if (state < 0) max = ptr; + else { + found = true; min = ptr + 1; + } + } + p_result = min; + return found; + } + + template + static bool runGroup(const t_container & p_container,t_size p_base,t_size p_count,const t_param & p_param,t_size & p_result,t_size & p_resultCount) { + if (!runGroupBegin(p_container,p_base,p_count,p_param,p_result)) { + p_resultCount = 0; + return false; + } + t_size groupEnd; + if (!runGroupEnd(p_container,p_result,p_count - p_result,p_param,groupEnd)) { + //should not happen.. + PFC_ASSERT(0); + p_resultCount = 0; + return false; + } + PFC_ASSERT(groupEnd > p_result); + p_resultCount = groupEnd - p_result; + return true; + } + }; +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/bit_array.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/bit_array.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,186 @@ +#include "pfc-lite.h" +#include "bit_array.h" +#include "bit_array_impl.h" +#include "bit_array_impl_part2.h" +#include "sort.h" + +namespace pfc { + void bit_array::for_each(bool value, size_t base, size_t max, std::function f) const { + for( size_t idx = find_first(value, base, max); idx < max; idx = find_next(value, idx, max) ) { + f(idx); + } + } + t_size bit_array::find(bool val, t_size start, t_ssize count) const + { + t_ssize d, todo, ptr = start; + if (count == 0) return start; + else if (count<0) { d = -1; todo = -count; } + else { d = 1; todo = count; } + while (todo>0 && get(ptr) != val) { ptr += d;todo--; } + return ptr; + } + + t_size bit_array::calc_count(bool val, t_size start, t_size count, t_size count_max) const + { + t_size found = 0; + t_size max = start + count; + t_size ptr; + for (ptr = find(val, start, count);found f, bool val ) const { + for ( size_t w = find_first(val, 0, to ); w < to; w = find_next(val, w, to) ) { + f(w); + } + } + void bit_array::walkBack(size_t from, std::function f, bool val) const { + t_ssize walk = from; + if ( walk == 0 ) return; + for( ;; ) { + walk = find(val, walk-1, - walk ); + if ( walk < 0 ) return; + f ( walk ); + } + } + + bit_array_var_impl::bit_array_var_impl( const bit_array & source, size_t sourceCount) { + for(size_t w = source.find_first( true, 0, sourceCount); w < sourceCount; w = source.find_next( true, w, sourceCount ) ) { + set(w, true); + } + } + + bool bit_array_var_impl::get(t_size n) const { + return m_data.have_item(n); + } + t_size bit_array_var_impl::find(bool val,t_size start,t_ssize count) const { + if (!val) { + return bit_array::find(false, start, count); //optimizeme. + } else if (count > 0) { + const t_size * v = m_data.find_nearest_item(start); + if (v == NULL || *v > start+count) return start + count; + return *v; + } else if (count < 0) { + const t_size * v = m_data.find_nearest_item(start); + if (v == NULL || *v < start+count) return start + count; + return *v; + } else return start; + } + + void bit_array_var_impl::set(t_size n,bool val) { + if (val) m_data += n; + else m_data -= n; + } + + + bit_array_flatIndexList::bit_array_flatIndexList() { + m_content.prealloc( 1024 ); + } + + void bit_array_flatIndexList::add( size_t n ) { + m_content.append_single_val( n ); + } + + bool bit_array_flatIndexList::get(t_size n) const { + size_t dummy; + return _find( n, dummy ); + } + t_size bit_array_flatIndexList::find(bool val,t_size start,t_ssize count) const { + if (val == false) { + // unoptimized but not really used + return bit_array::find(val, start, count); + } + + if (count==0) return start; + else if (count<0) { + size_t idx; + if (!_findNearestDown( start, idx ) || (t_ssize)m_content[idx] < (t_ssize)start+count) return start + count; + return m_content[idx]; + } else { // count > 0 + size_t idx; + if (!_findNearestUp( start, idx ) || m_content[idx] > start+count) return start + count; + return m_content[idx]; + } + } + + bool bit_array_flatIndexList::_findNearestUp( size_t val, size_t & outIdx ) const { + size_t idx; + if (_find( val, idx )) { outIdx = idx; return true; } + // we have a valid outIdx at where the bsearch gave up + PFC_ASSERT ( idx == 0 || m_content [ idx - 1 ] < val ); + PFC_ASSERT ( idx == m_content.get_size() || m_content[ idx ] > val ); + if (idx == m_content.get_size()) return false; + outIdx = idx; + return true; + } + bool bit_array_flatIndexList::_findNearestDown( size_t val, size_t & outIdx ) const { + size_t idx; + if (_find( val, idx )) { outIdx = idx; return true; } + // we have a valid outIdx at where the bsearch gave up + PFC_ASSERT ( idx == 0 || m_content [ idx - 1 ] < val ); + PFC_ASSERT ( idx == m_content.get_size() || m_content[ idx ] > val ); + if (idx == 0) return false; + outIdx = idx - 1; + return true; + } + + void bit_array_flatIndexList::presort() { + pfc::sort_t( m_content, pfc::compare_t< size_t, size_t >, m_content.get_size( ) ); + } + + + bit_array_bittable::bit_array_bittable(const pfc::bit_array & in, size_t inSize) : m_count() { + resize(inSize); + for (size_t w = in.find_first(true, 0, inSize); w < inSize; w = in.find_next(true, w, inSize)) { + set(w, true); + } + } + + void bit_array_bittable::resize(t_size p_count) + { + t_size old_bytes = g_estimate_size(m_count); + m_count = p_count; + t_size bytes = g_estimate_size(m_count); + m_data.set_size(bytes); + if (bytes > old_bytes) pfc::memset_null_t(m_data.get_ptr() + old_bytes, bytes - old_bytes); + } + + void bit_array_bittable::set(t_size n, bool val) + { + if (n0) + return (val >= start && (t_ssize)val < (t_ssize)start + count) ? val : start + count; + else + return (val <= start && (t_ssize)val > (t_ssize)start + count) ? val : start + count; + } + else + { + if (start == val) return count>0 ? start + 1 : start - 1; + else return start; + } + } +} // namespace pfc diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/bit_array.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/bit_array.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,69 @@ +#pragma once + +#include + +namespace pfc { + //! Bit array interface class, constant version (you can only retrieve values). \n + //! Range of valid indexes depends on the context. When passing a bit_array as a parameter to some code, valid index range must be signaled independently. + class NOVTABLE bit_array { + public: + virtual bool get(t_size n) const = 0; + //! Returns the first occurance of val between start and start+count (excluding start+count), or start+count if not found; count may be negative to search back rather than forward. \n + //! Can be overridden by bit_array implementations for improved speed in specific cases. + virtual t_size find(bool val, t_size start, t_ssize count) const; + bool operator[](t_size n) const { return get(n); } + + t_size calc_count(bool val, t_size start, t_size count, t_size count_max = ~0) const;//counts number of vals for start<=n f) const; + + void walk(size_t to, std::function< void ( size_t ) > f, bool val = true ) const; + void walkBack(size_t from, std::function< void ( size_t ) > f, bool val = true ) const; + protected: + bit_array() {} + ~bit_array() {} + }; + + //! Minimal lambda-based bit_array implementation, no find(), only get(). + class bit_array_lambda : public bit_array { + public: + typedef std::function f_t; + f_t f; + + bit_array_lambda( f_t f_ ) : f(f_) { } + + bool get(t_size n) const {return f(n);} + }; + + //! Bit array interface class, variable version (you can both set and retrieve values). \n + //! As with the constant version, valid index range depends on the context. + class NOVTABLE bit_array_var : public bit_array { + public: + virtual void set(t_size n,bool val)=0; + protected: + bit_array_var() {} + ~bit_array_var() {} + }; + + class bit_array_wrapper_permutation : public bit_array { + public: + bit_array_wrapper_permutation(const t_size * p_permutation, t_size p_size) : m_permutation(p_permutation), m_size(p_size) {} + bool get(t_size n) const { + if (n < m_size) { + return m_permutation[n] != n; + } else { + return false; + } + } + private: + const t_size * const m_permutation; + const t_size m_size; + }; + + +} +#define PFC_FOR_EACH_INDEX( bitArray, var, count ) \ +for( size_t var = (bitArray).find_first( true, 0, (count) ); var < (count); var = (bitArray).find_next( true, var, (count) ) ) diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/bit_array_impl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/bit_array_impl.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,201 @@ +#pragma once +#include "array.h" + +namespace pfc { + template + class bit_array_table_t : public bit_array + { + const T * data; + t_size count; + bool after; + public: + inline bit_array_table_t(const T * p_data,t_size p_count,bool p_after = false) + : data(p_data), count(p_count), after(p_after) + { + } + + bool get(t_size n) const + { + if (n + class bit_array_var_table_t : public bit_array_var + { + T * data; + t_size count; + bool after; + public: + inline bit_array_var_table_t(T * p_data,t_size p_count,bool p_after = false) + : data(p_data), count(p_count), after(p_after) + { + } + + bool get(t_size n) const { + if (n bit_array_table; + typedef bit_array_var_table_t bit_array_var_table; + + class bit_array_range : public bit_array + { + t_size begin,end; + bool state; + public: + bit_array_range(t_size first,t_size count,bool p_state = true) : begin(first), end(first+count), state(p_state) {} + + bool get(t_size n) const + { + bool rv = n>=begin && n m_data; + t_size m_count; + public: + //helpers + template + inline static bool g_get(const t_array & p_array,t_size idx) + { + return !! (p_array[idx>>3] & (1<<(idx&7))); + } + + template + inline static void g_set(t_array & p_array,t_size idx,bool val) + { + unsigned char & dst = p_array[idx>>3]; + unsigned char mask = 1<<(idx&7); + dst = val ? dst|mask : dst&~mask; + } + + inline static t_size g_estimate_size(t_size p_count) {return (p_count+7)>>3;} + + void resize(t_size p_count); + + bit_array_bittable(t_size p_count) : m_count(0) {resize(p_count);} + bit_array_bittable(const pfc::bit_array & in, size_t inSize); + bit_array_bittable() : m_count() {} + + + void set(t_size n, bool val); + + bool get(t_size n) const; + + size_t size() const {return m_count;} + }; + + + //! Bit array that takes a permutation and signals indexes reordered by the permutation. \n + //! Valid index range same as length of the permutation. + class bit_array_order_changed : public bit_array { + public: + bit_array_order_changed(const t_size * p_order) : m_order(p_order) {} + bool get(t_size n) const + { + return m_order[n] != n; + } + + private: + const t_size * m_order; + }; +} +// #define for_each_bit_array(var,mask,val,start,count) for(var = mask.find(val,start,count);var m_data; + }; + + + //! Specialized implementation of bit_array. \n + //! Indended for scenarios where fast searching for true values in a large list is needed, combined with low footprint regardless of the amount of items. + //! Call add() repeatedly with the true val indexes. If the indexes were not added in increasing order, call presort() when done with adding. + class bit_array_flatIndexList : public bit_array { + public: + bit_array_flatIndexList(); + + void add( size_t n ); + + bool get(t_size n) const; + t_size find(bool val,t_size start,t_ssize count) const; + + void presort(); + + size_t get_count() const { return m_content.get_size(); } + + private: + bool _findNearestUp( size_t val, size_t & outIdx ) const; + bool _findNearestDown( size_t val, size_t & outIdx ) const; + bool _find( size_t val, size_t & outIdx ) const { + return pfc::bsearch_simple_inline_t( m_content, m_content.get_size(), val, outIdx); + } + + pfc::array_t< size_t, pfc::alloc_fast > m_content; + }; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/bsearch.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/bsearch.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,21 @@ +#include "pfc-lite.h" +#include "bsearch.h" +#include "bsearch_inline.h" + +//deprecated + +/* +class NOVTABLE bsearch_callback +{ +public: + virtual int test(t_size p_index) const = 0; +}; +*/ + +namespace pfc { + + bool bsearch(t_size p_count, bsearch_callback const & p_callback,t_size & p_result) { + return bsearch_inline_t(p_count,p_callback,p_result); + } + +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/bsearch.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/bsearch.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,89 @@ +#pragma once + +namespace pfc { + + //deprecated + + class NOVTABLE bsearch_callback + { + public: + virtual int test(t_size n) const = 0; + }; + + bool bsearch(t_size p_count, bsearch_callback const & p_callback,t_size & p_result); + + template + class bsearch_callback_impl_simple_t : public bsearch_callback { + public: + int test(t_size p_index) const { + return m_compare(m_container[p_index],m_param); + } + bsearch_callback_impl_simple_t(const t_container & p_container,t_compare p_compare,const t_param & p_param) + : m_container(p_container), m_compare(p_compare), m_param(p_param) + { + } + private: + const t_container & m_container; + t_compare m_compare; + const t_param & m_param; + }; + + template + class bsearch_callback_impl_permutation_t : public bsearch_callback { + public: + int test(t_size p_index) const { + return m_compare(m_container[m_permutation[p_index]],m_param); + } + bsearch_callback_impl_permutation_t(const t_container & p_container,t_compare p_compare,const t_param & p_param,const t_permutation & p_permutation) + : m_container(p_container), m_compare(p_compare), m_param(p_param), m_permutation(p_permutation) + { + } + private: + const t_container & m_container; + t_compare m_compare; + const t_param & m_param; + const t_permutation & m_permutation; + }; + + + template + bool bsearch_t(t_size p_count,const t_container & p_container,t_compare p_compare,const t_param & p_param,t_size & p_index) { + return bsearch( + p_count, + bsearch_callback_impl_simple_t(p_container,p_compare,p_param), + p_index); + } + + template + bool bsearch_permutation_t(t_size p_count,const t_container & p_container,t_compare p_compare,const t_param & p_param,const t_permutation & p_permutation,t_size & p_index) { + t_size index; + if (bsearch( + p_count, + bsearch_callback_impl_permutation_t(p_container,p_compare,p_param,p_permutation), + index)) + { + p_index = p_permutation[index]; + return true; + } else { + return false; + } + } + + template + bool bsearch_range_t(const t_size p_count,const t_container & p_container,t_compare p_compare,const t_param & p_param,t_size & p_range_base,t_size & p_range_count) + { + t_size probe; + if (!bsearch( + p_count, + bsearch_callback_impl_simple_t(p_container,p_compare,p_param), + probe)) return false; + + t_size base = probe, count = 1; + while(base > 0 && p_compare(p_container[base-1],p_param) == 0) {base--; count++;} + while(base + count < p_count && p_compare(p_container[base+count],p_param) == 0) {count++;} + p_range_base = base; + p_range_count = count; + return true; + } + +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/bsearch_inline.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/bsearch_inline.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,72 @@ +#pragma once + +namespace pfc { + + //deprecated + +template +inline bool bsearch_inline_t(t_size p_count, t_callback && p_callback,t_size & p_result) +{ + t_size max = p_count; + t_size min = 0; + t_size ptr; + while(min> 1); + int result = p_callback.test(ptr); + if (result<0) min = ptr + 1; + else if (result>0) max = ptr; + else + { + p_result = ptr; + return true; + } + } + p_result = min; + return false; +} + +template +inline bool bsearch_simple_inline_t(t_buffer&& p_buffer, t_size p_count, t_value const& p_value, pred_t && pred, t_size& p_result) +{ + t_size max = p_count; + t_size min = 0; + t_size ptr; + while (min < max) + { + ptr = min + ((max - min) >> 1); + int test = pred(p_value, p_buffer[ptr]); + if ( test > 0 ) min = ptr + 1; + else if ( test < 0 ) max = ptr; + else + { + p_result = ptr; + return true; + } + } + p_result = min; + return false; +} + +template +inline bool bsearch_simple_inline_t(t_buffer && p_buffer,t_size p_count,t_value && p_value,t_size & p_result) +{ + t_size max = p_count; + t_size min = 0; + t_size ptr; + while(min> 1); + if (p_value > p_buffer[ptr]) min = ptr + 1; + else if (p_value < p_buffer[ptr]) max = ptr; + else + { + p_result = ptr; + return true; + } + } + p_result = min; + return false; +} + +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/byte_order.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/byte_order.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,255 @@ +#pragma once + +namespace pfc { + void byteswap_raw(void * p_buffer,t_size p_bytes); + + template T byteswap_t(T p_source); + + template<> inline char byteswap_t(char p_source) {return p_source;} + template<> inline unsigned char byteswap_t(unsigned char p_source) {return p_source;} + template<> inline signed char byteswap_t(signed char p_source) {return p_source;} + + template T byteswap_int_t(T p_source) { + enum { width = sizeof(T) }; + typedef typename sized_int_t::t_unsigned tU; + tU in = p_source, out = 0; + for(unsigned walk = 0; walk < width; ++walk) { + out |= ((in >> (walk * 8)) & 0xFF) << ((width - 1 - walk) * 8); + } + return out; + } + +#ifdef _MSC_VER//does this even help with performance/size? + template<> inline wchar_t byteswap_t(wchar_t p_source) {return _byteswap_ushort(p_source);} + + template<> inline short byteswap_t(short p_source) {return _byteswap_ushort(p_source);} + template<> inline unsigned short byteswap_t(unsigned short p_source) {return _byteswap_ushort(p_source);} + + template<> inline int byteswap_t(int p_source) {return _byteswap_ulong(p_source);} + template<> inline unsigned int byteswap_t(unsigned int p_source) {return _byteswap_ulong(p_source);} + + template<> inline long byteswap_t(long p_source) {return _byteswap_ulong(p_source);} + template<> inline unsigned long byteswap_t(unsigned long p_source) {return _byteswap_ulong(p_source);} + + template<> inline long long byteswap_t(long long p_source) {return _byteswap_uint64(p_source);} + template<> inline unsigned long long byteswap_t(unsigned long long p_source) {return _byteswap_uint64(p_source);} +#else + template<> inline wchar_t byteswap_t(wchar_t p_source) {return byteswap_int_t(p_source);} + + template<> inline short byteswap_t(short p_source) {return byteswap_int_t(p_source);} + template<> inline unsigned short byteswap_t(unsigned short p_source) {return byteswap_int_t(p_source);} + + template<> inline int byteswap_t(int p_source) {return byteswap_int_t(p_source);} + template<> inline unsigned int byteswap_t(unsigned int p_source) {return byteswap_int_t(p_source);} + + template<> inline long byteswap_t(long p_source) {return byteswap_int_t(p_source);} + template<> inline unsigned long byteswap_t(unsigned long p_source) {return byteswap_int_t(p_source);} + + template<> inline long long byteswap_t(long long p_source) {return byteswap_int_t(p_source);} + template<> inline unsigned long long byteswap_t(unsigned long long p_source) {return byteswap_int_t(p_source);} +#endif + + template<> inline float byteswap_t(float p_source) { + float ret; + *(t_uint32*) &ret = byteswap_t(*(const t_uint32*)&p_source ); + return ret; + } + + template<> inline double byteswap_t(double p_source) { + double ret; + *(t_uint64*) &ret = byteswap_t(*(const t_uint64*)&p_source ); + return ret; + } + + //blargh at GUID byteswap issue + template<> inline GUID byteswap_t(GUID p_guid) { + GUID ret; + ret.Data1 = pfc::byteswap_t(p_guid.Data1); + ret.Data2 = pfc::byteswap_t(p_guid.Data2); + ret.Data3 = pfc::byteswap_t(p_guid.Data3); + ret.Data4[0] = p_guid.Data4[0]; + ret.Data4[1] = p_guid.Data4[1]; + ret.Data4[2] = p_guid.Data4[2]; + ret.Data4[3] = p_guid.Data4[3]; + ret.Data4[4] = p_guid.Data4[4]; + ret.Data4[5] = p_guid.Data4[5]; + ret.Data4[6] = p_guid.Data4[6]; + ret.Data4[7] = p_guid.Data4[7]; + return ret; + } + +#if ! defined(_MSC_VER) || _MSC_VER >= 1900 + template<> inline char16_t byteswap_t(char16_t v) { return (char16_t)byteswap_t((uint16_t)v); } + template<> inline char32_t byteswap_t(char32_t v) { return (char32_t)byteswap_t((uint32_t)v); } +#endif +}; + +#ifdef _MSC_VER + +// No MSVC platform is ever big endian +#define PFC_BYTE_ORDER_IS_BIG_ENDIAN 0 + +#else//_MSC_VER + +#if defined(__APPLE__) +#include +#else +#include +#endif + +#if __BYTE_ORDER == __LITTLE_ENDIAN +#define PFC_BYTE_ORDER_IS_BIG_ENDIAN 0 +#else +#define PFC_BYTE_ORDER_IS_BIG_ENDIAN 1 +#endif + +#endif//_MSC_VER + +#ifdef PFC_BYTE_ORDER_IS_BIG_ENDIAN +#define PFC_BYTE_ORDER_IS_LITTLE_ENDIAN (!(PFC_BYTE_ORDER_IS_BIG_ENDIAN)) +#else +#error please update byte order #defines +#endif + + +namespace pfc { + static constexpr bool byte_order_is_big_endian = !!PFC_BYTE_ORDER_IS_BIG_ENDIAN; + static constexpr bool byte_order_is_little_endian = !!PFC_BYTE_ORDER_IS_LITTLE_ENDIAN; + + template T byteswap_if_be_t(T p_param) {return byte_order_is_big_endian ? byteswap_t(p_param) : p_param;} + template T byteswap_if_le_t(T p_param) {return byte_order_is_little_endian ? byteswap_t(p_param) : p_param;} +} + +namespace byte_order { + +#if PFC_BYTE_ORDER_IS_BIG_ENDIAN//big endian + template inline void order_native_to_le_t(T& param) {param = pfc::byteswap_t(param);} + template inline void order_native_to_be_t(T& param) { (void)param; } + template inline void order_le_to_native_t(T& param) {param = pfc::byteswap_t(param);} + template inline void order_be_to_native_t(T& param) { (void)param; } +#else//little endian + template inline void order_native_to_le_t(T& param) { (void)param; } + template inline void order_native_to_be_t(T& param) {param = pfc::byteswap_t(param);} + template inline void order_le_to_native_t(T& param) { (void)param; } + template inline void order_be_to_native_t(T& param) {param = pfc::byteswap_t(param);} +#endif +}; + + + +namespace pfc { + template + class __EncodeIntHelper { + public: + inline static void Run(TInt p_value,t_uint8 * p_out) { + *p_out = (t_uint8)(p_value); + __EncodeIntHelper::Run(p_value >> 8,p_out + (IsBigEndian ? -1 : 1)); + } + }; + + template + class __EncodeIntHelper { + public: + inline static void Run(TInt p_value,t_uint8* p_out) { + *p_out = (t_uint8)(p_value); + } + }; + template + class __EncodeIntHelper { + public: + inline static void Run(TInt,t_uint8*) {} + }; + + template + inline void encode_little_endian(t_uint8 * p_buffer,TInt p_value) { + __EncodeIntHelper::Run(p_value,p_buffer); + } + template + inline void encode_big_endian(t_uint8 * p_buffer,TInt p_value) { + __EncodeIntHelper::Run(p_value,p_buffer + (sizeof(TInt) - 1)); + } + + + template + class __DecodeIntHelper { + public: + inline static TInt Run(const t_uint8 * p_in) { + return (__DecodeIntHelper::Run(p_in + (IsBigEndian ? -1 : 1)) << 8) + *p_in; + } + }; + + template + class __DecodeIntHelper { + public: + inline static TInt Run(const t_uint8* p_in) {return *p_in;} + }; + + template + class __DecodeIntHelper { + public: + inline static TInt Run(const t_uint8*) {return 0;} + }; + + template + inline void decode_little_endian(TInt & p_out,const t_uint8 * p_buffer) { + p_out = __DecodeIntHelper::Run(p_buffer); + } + + template + inline void decode_big_endian(TInt & p_out,const t_uint8 * p_buffer) { + p_out = __DecodeIntHelper::Run(p_buffer + (sizeof(TInt) - 1)); + } + + template + inline TInt decode_little_endian(const t_uint8 * p_buffer) { + TInt temp; + decode_little_endian(temp,p_buffer); + return temp; + } + + template + inline TInt decode_big_endian(const t_uint8 * p_buffer) { + TInt temp; + decode_big_endian(temp,p_buffer); + return temp; + } + + template + inline void decode_endian(TInt & p_out,const t_uint8 * p_buffer) { + if (IsBigEndian) decode_big_endian(p_out,p_buffer); + else decode_little_endian(p_out,p_buffer); + } + template + inline void encode_endian(t_uint8 * p_buffer,TInt p_in) { + if (IsBigEndian) encode_big_endian(p_in,p_buffer); + else encode_little_endian(p_in,p_buffer); + } + + + + template + inline void reverse_bytes(t_uint8 * p_buffer) { + pfc::swap_t(p_buffer[0],p_buffer[width-1]); + reverse_bytes(p_buffer+1); + } + + template<> inline void reverse_bytes<1>(t_uint8 * ) { } + template<> inline void reverse_bytes<0>(t_uint8 * ) { } + + inline int32_t readInt24(const void * mem) { + const uint8_t * p = (const uint8_t*) mem; + int32_t ret; + if (byte_order_is_little_endian) { + ret = p[0]; + ret |= (uint32_t)p[1] << 8; + ret |= (int32_t)(int8_t)p[2] << 16; + return ret; + } else { + ret = p[2]; + ret |= (uint32_t)p[1] << 8; + ret |= (int32_t)(int8_t)p[0] << 16; + return ret; + } + } +} + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/chain_list_v2.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/chain_list_v2.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,304 @@ +#pragma once +#include "iterators.h" + +namespace pfc { + + template + class __chain_list_elem : public _list_node { + public: + typedef _list_node t_node; + template __chain_list_elem( arg_t && ... args ) : t_node( std::forward(args) ... ) {m_prev = m_next = NULL;} + + typedef __chain_list_elem t_self; + + t_self * m_prev, * m_next; + + t_node * prev() throw() {return m_prev;} + t_node * next() throw() {return m_next;} + + //helper wrappers + void add_ref() throw() {this->refcount_add_ref();} + void release() throw() {this->refcount_release();} + //workaround for cross-list-relinking case - never actually deletes p_elem + void __release_temporary() throw() {this->_refcount_release_temporary();} + }; + + //! Differences between chain_list_v2_t<> and old chain_list_t<>: \n + //! Iterators pointing to removed items as well as to items belonging to no longer existing list objects remain valid but they're no longer walkable - as if the referenced item was the only item in the list. The old class invalidated iterators on deletion instead. + template + class chain_list_v2_t { + public: + typedef _t_item t_item; + typedef chain_list_v2_t t_self; + typedef ::pfc::iterator iterator; + typedef ::pfc::const_iterator const_iterator; + typedef ::pfc::forward_iterator forward_iterator; + typedef ::pfc::forward_const_iterator forward_const_iterator; + typedef __chain_list_elem t_elem; + + chain_list_v2_t() {} + chain_list_v2_t(const t_self & p_source) { + try { + *this = p_source; + } catch(...) { + remove_all(); + throw; + } + } + + chain_list_v2_t(t_self && p_source) { + append_move_from( p_source ); + } + + template void _set(const t_in & in) { + remove_all(); _add(in); + } + template void _add(const t_in & in) { + for(typename t_in::const_iterator iter = in.first(); iter.is_valid(); ++in) add_item(*iter); + } + template t_self & operator=(const t_in & in) {_set(in); return *this;} + + t_self & operator=(const t_self & p_other) { + remove_all(); + for(t_elem * walk = p_other.m_first; walk != NULL; walk = walk->m_next) { + add_item(walk->m_content); + } + return *this; + } + t_self & operator=(t_self && p_other) { + move_from(p_other); return *this; + } + + // templated constructors = spawn of satan + // template chain_list_v2_t(const t_other & in) { try {_add(in);} catch(...) {remove_all(); throw;} } + + t_size get_count() const {return m_count;} + + iterator first() {return iterator(m_first);} + iterator last() {return iterator(m_last);} + const_iterator first() const {return const_iterator(m_first);} + const_iterator last() const {return const_iterator(m_last);} + const_iterator cfirst() const {return const_iterator(m_first);} + const_iterator clast() const {return const_iterator(m_last);} + + forward_iterator begin() { return first(); } + forward_const_iterator begin() const { return first(); } + forward_iterator end() {return forward_iterator(); } + forward_const_iterator end() const { return forward_const_iterator(); } + + void remove_single(const_iterator const & p_iter) { + PFC_ASSERT(p_iter.is_valid()); + __unlink(_elem(p_iter)); + } + + void remove(const_iterator const & p_iter) { + PFC_ASSERT(p_iter.is_valid()); + __unlink(_elem(p_iter)); + } + + void remove_all() throw() { + while(m_first != NULL) __unlink(m_first); + PFC_ASSERT(m_count == 0); + } + void remove_range(const_iterator const & p_from,const_iterator const & p_to) { + for(t_elem * walk = _elem(p_from);;) { + if (walk == NULL) {PFC_ASSERT(!"Should not get here"); break;}//should not happen unless there is a bug in calling code + t_elem * next = walk->m_next; + __unlink(walk); + if (walk == _elem(p_to)) break; + walk = next; + } + } + + template void enumerate(t_callback & p_callback) const {__enumerate_chain(m_first,p_callback);} + template void enumerate(t_callback & p_callback) {__enumerate_chain(m_first,p_callback);} + + template bool remove_item(const t_source & p_item) { + t_elem * elem; + if (__find(elem,p_item)) { + __unlink(elem); + return true; + } else { + return false; + } + } + + ~chain_list_v2_t() {remove_all();} + + template + inline void add_item(arg_t && ... arg) { + __link_last(new t_elem(std::forward(arg) ... )); + } + template + inline t_self & operator+=(t_source && p_source) { + add_item(std::forward(p_source)); return *this; + } + iterator insert_last() {return __link_last(new t_elem);} + iterator insert_first() {return __link_first(new t_elem);} + iterator insert_after(const_iterator const & p_iter) {return __link_next(_elem(p_iter),new t_elem);} + iterator insert_before(const_iterator const & p_iter) {return __link_prev(_elem(p_iter),new t_elem);} + template iterator insert_last(arg_t && ... arg) {return __link_last(new t_elem(std::forward(arg) ...));} + template iterator insert_first(arg_t && ... arg) {return __link_first(new t_elem(std::forward(arg) ...));} + template iterator insert_after(const_iterator const & p_iter,arg_t && ... arg) {return __link_next(_elem(p_iter),new t_elem(std::forward(arg) ... ));} + template iterator insert_before(const_iterator const & p_iter,arg_t && ... arg) {return __link_prev(_elem(p_iter),new t_elem(std::forward(arg) ... ));} + + template const_iterator find_item(const t_source & p_item) const { + t_elem * elem; + if (!__find(elem,p_item)) return const_iterator(); + return const_iterator(elem); + } + + template iterator find_item(const t_source & p_item) { + t_elem * elem; + if (!__find(elem,p_item)) return iterator(); + return iterator(elem); + } + + template bool have_item(const t_source & p_item) const { + t_elem * dummy; + return __find(dummy,p_item); + } + template void set_single(const t_source & p_item) { + remove_all(); add_item(p_item); + } + + //! Slow! + const_iterator by_index(t_size p_index) const {return __by_index(p_index);} + //! Slow! + iterator by_index(t_size p_index) {return __by_index(p_index);} + + t_self & operator<<(t_self & p_other) { + while(p_other.m_first != NULL) { + __link_last( p_other.__unlink_temporary(p_other.m_first) ); + } + return *this; + } + t_self & operator>>(t_self & p_other) { + while(m_last != NULL) { + p_other.__link_first(__unlink_temporary(m_last)); + } + return p_other; + } + //! Links an object that has been unlinked from another list. Unsafe. + void _link_last(const_iterator const& iter) { + PFC_ASSERT(iter.is_valid()); + PFC_ASSERT( _elem(iter)->m_prev == NULL && _elem(iter)->m_next == NULL ); + __link_last(_elem(iter)); + } + //! Links an object that has been unlinked from another list. Unsafe. + void _link_first(const_iterator const& iter) { + PFC_ASSERT(iter.is_valid()); + PFC_ASSERT( _elem(iter)->m_prev == NULL && _elem(iter)->m_next == NULL ); + __link_first(_elem(iter)); + } + void append_move_from( t_self & p_other ) { + while (p_other.m_first != NULL) { + __link_last(p_other.__unlink_temporary(p_other.m_first)); + } + } + void move_from( t_self & p_other ) { + remove_all(); + append_move_from( p_other ); + } + private: + static t_elem * _elem(const_iterator const & iter) { + return static_cast(iter._node()); + } + t_elem * __by_index(t_size p_index) const { + t_elem * walk = m_first; + while(p_index > 0 && walk != NULL) { + p_index--; + walk = walk->m_next; + } + return walk; + } + template + static void __enumerate_chain(t_elemwalk * p_elem,t_callback & p_callback) { + t_elemwalk * walk = p_elem; + while(walk != NULL) { + p_callback(walk->m_content); + walk = walk->m_next; + } + } + + template bool __find(t_elem * & p_elem,const t_source & p_item) const { + for(t_elem * walk = m_first; walk != NULL; walk = walk->m_next) { + if (walk->m_content == p_item) { + p_elem = walk; return true; + } + } + return false; + } + + void __unlink_helper(t_elem * p_elem) throw() { + (p_elem->m_prev == NULL ? m_first : p_elem->m_prev->m_next) = p_elem->m_next; + (p_elem->m_next == NULL ? m_last : p_elem->m_next->m_prev) = p_elem->m_prev; + p_elem->m_next = p_elem->m_prev = NULL; + } + + //workaround for cross-list-relinking case - never actually deletes p_elem + t_elem * __unlink_temporary(t_elem * p_elem) throw() { + __unlink_helper(p_elem); + --m_count; p_elem->__release_temporary(); + return p_elem; + } + + t_elem * __unlink(t_elem * p_elem) throw() { + __unlink_helper(p_elem); + --m_count; p_elem->release(); + return p_elem; + } + void __on_link(t_elem * p_elem) throw() { + p_elem->add_ref(); ++m_count; + } + t_elem * __link_first(t_elem * p_elem) throw() { + __on_link(p_elem); + p_elem->m_next = m_first; + p_elem->m_prev = NULL; + (m_first == NULL ? m_last : m_first->m_prev) = p_elem; + m_first = p_elem; + return p_elem; + } + t_elem * __link_last(t_elem * p_elem) throw() { + __on_link(p_elem); + p_elem->m_prev = m_last; + p_elem->m_next = NULL; + (m_last == NULL ? m_first : m_last->m_next) = p_elem; + m_last = p_elem; + return p_elem; + } + t_elem * __link_next(t_elem * p_prev,t_elem * p_elem) throw() { + __on_link(p_elem); + p_elem->m_prev = p_prev; + p_elem->m_next = p_prev->m_next; + (p_prev->m_next != NULL ? p_prev->m_next->m_prev : m_last) = p_elem; + p_prev->m_next = p_elem; + return p_elem; + } + t_elem * __link_prev(t_elem * p_next,t_elem * p_elem) throw() { + __on_link(p_elem); + p_elem->m_next = p_next; + p_elem->m_prev = p_next->m_prev; + (p_next->m_prev != NULL ? p_next->m_prev->m_next : m_first) = p_elem; + p_next->m_prev = p_elem; + return p_elem; + } + t_elem * m_first = nullptr, * m_last = nullptr; + t_size m_count = 0; + }; + + + template class traits_t > : public traits_default_movable {}; + + class __chain_list_iterator_traits : public traits_default_movable { + public: + enum { + constructor_may_fail = false + }; + }; + + template class traits_t > : public traits_t > > {}; + + template class traits_t > : public traits_t > {}; + +}//namespace pfc diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/charDownConvert.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/charDownConvert.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,130 @@ +#include "pfc-lite.h" +#include "charDownConvert.h" +#include "SmartStrStr-twoCharMappings.h" + +namespace { + static constexpr pfc::CharDownConvert::charMapping_t g_mappings[] = { + {65,97},{66,98},{67,99},{68,100},{69,101},{70,102},{71,103},{72,104},{73,105},{74,106},{75,107},{76,108},{77,109},{78,110},{79,111},{80,112},{81,113},{82,114},{83,115},{84,116},{85,117},{86,118},{87,119}, + {88,120},{89,121},{90,122},{160,32},{161,33},{162,99},{164,36},{165,89},{166,124},{169,67},{170,97},{171,60},{173,45},{174,82},{178,50},{179,51},{183,46},{184,44},{185,49},{186,111},{187,62},{192,97},{193,97}, + {194,97},{195,97},{196,97},{197,97},{198,97},{199,99},{200,101},{201,101},{202,101},{203,101},{204,105},{205,105},{206,105},{207,105},{208,240},{209,110},{210,111},{211,111},{212,111},{213,111},{214,111}, + {216,111},{217,117},{218,117},{219,117},{220,117},{221,121},{222,254},{224,97},{225,97},{226,97},{227,97},{228,97},{229,97},{230,97},{231,99},{232,101},{233,101},{234,101},{235,101},{236,105},{237,105}, + {238,105},{239,105},{241,110},{242,111},{243,111},{244,111},{245,111},{246,111},{248,111},{249,117},{250,117},{251,117},{252,117},{253,121},{255,121},{256,97},{257,97},{258,97},{259,97},{260,97},{261,97}, + {262,99},{263,99},{264,99},{265,99},{266,99},{267,99},{268,99},{269,99},{270,100},{271,100},{272,100},{273,100},{274,101},{275,101},{276,101},{277,101},{278,101},{279,101},{280,101},{281,101},{282,101}, + {283,101},{284,103},{285,103},{286,103},{287,103},{288,103},{289,103},{290,103},{291,103},{292,104},{293,104},{294,104},{295,104},{296,105},{297,105},{298,105},{299,105},{300,105},{301,105},{302,105},{303,105}, + {304,73},{305,105},{306,307},{308,106},{309,106},{310,107},{311,107},{313,108},{314,108},{315,108},{316,108},{317,108},{318,108},{319,320},{321,108},{322,108},{323,110},{324,110},{325,110},{326,110},{327,110}, + {328,110},{330,331},{332,111},{333,111},{334,111},{335,111},{336,111},{337,111},{338,111},{339,111},{340,114},{341,114},{342,114},{343,114},{344,114},{345,114},{346,115},{347,115},{348,115},{349,115},{350,115}, + {351,115},{352,115},{353,115},{354,116},{355,116},{356,116},{357,116},{358,116},{359,116},{360,117},{361,117},{362,117},{363,117},{364,117},{365,117},{366,117},{367,117},{368,117},{369,117},{370,117},{371,117}, + {372,119},{373,119},{374,121},{375,121},{376,121},{377,122},{378,122},{379,122},{380,122},{381,122},{382,122},{384,98},{385,595},{386,387},{388,389},{390,596},{391,392},{393,598},{394,599},{395,396},{398,477}, + {399,601},{400,603},{401,102},{402,102},{403,608},{404,611},{406,617},{407,616},{408,409},{410,108},{412,623},{413,626},{415,629},{416,111},{417,111},{418,419},{420,421},{422,640},{423,424},{425,643},{427,116}, + {428,429},{430,648},{431,117},{432,117},{433,650},{434,651},{435,436},{437,122},{438,122},{439,658},{440,441},{444,445},{452,454},{455,457},{458,460},{461,97},{462,97},{463,105},{464,105},{465,111},{466,111}, + {467,117},{468,117},{469,117},{470,117},{471,117},{472,117},{473,117},{474,117},{475,117},{476,117},{478,97},{479,97},{480,481},{482,483},{484,103},{485,103},{486,103},{487,103},{488,107},{489,107},{490,111}, + {491,111},{492,111},{493,111},{494,495},{496,106},{497,499},{500,501},{502,405},{503,447},{504,505},{506,507},{508,509},{510,511},{512,513},{514,515},{516,517},{518,519},{520,521},{522,523},{524,525},{526,527}, + {528,529},{530,531},{532,533},{534,535},{536,537},{538,539},{540,541},{542,543},{544,414},{546,547},{548,549},{550,551},{552,553},{554,555},{556,557},{558,559},{560,561},{562,563},{570,11365},{571,572}, + {573,108},{574,11366},{577,578},{579,98},{580,649},{581,652},{582,583},{584,585},{586,587},{588,589},{590,591},{609,103},{697,39},{698,34},{700,39},{708,94},{710,94},{712,39},{715,96},{717,95},{732,126}, + {768,96},{770,94},{771,126},{782,34},{817,95},{818,95},{880,881},{882,883},{886,887},{902,940},{904,941},{905,942},{906,943},{908,972},{910,973},{911,974},{913,945},{914,946},{915,947},{916,948},{917,949}, + {918,950},{919,951},{920,952},{921,953},{922,954},{923,955},{924,956},{925,957},{926,958},{927,959},{928,960},{929,961},{931,963},{932,964},{933,965},{934,966},{935,967},{936,968},{937,969},{938,970},{939,971}, + {975,983},{984,985},{986,987},{988,989},{990,991},{992,993},{994,995},{996,997},{998,999},{1000,1001},{1002,1003},{1004,1005},{1006,1007},{1015,1016},{1017,1010},{1018,1019},{1021,891},{1022,892},{1023,893}, + {1024,1104},{1025,1105},{1026,1106},{1027,1107},{1028,1108},{1029,1109},{1030,1110},{1031,1111},{1032,1112},{1033,1113},{1034,1114},{1035,1115},{1036,1116},{1037,1117},{1038,1118},{1039,1119},{1040,1072}, + {1041,1073},{1042,1074},{1043,1075},{1044,1076},{1045,1077},{1046,1078},{1047,1079},{1048,1080},{1049,1081},{1050,1082},{1051,1083},{1052,1084},{1053,1085},{1054,1086},{1055,1087},{1056,1088},{1057,1089}, + {1058,1090},{1059,1091},{1060,1092},{1061,1093},{1062,1094},{1063,1095},{1064,1096},{1065,1097},{1066,1098},{1067,1099},{1068,1100},{1069,1101},{1070,1102},{1071,1103},{1120,1121},{1122,1123},{1124,1125}, + {1126,1127},{1128,1129},{1130,1131},{1132,1133},{1134,1135},{1136,1137},{1138,1139},{1140,1141},{1142,1143},{1144,1145},{1146,1147},{1148,1149},{1150,1151},{1152,1153},{1162,1163},{1164,1165},{1166,1167}, + {1168,1169},{1170,1171},{1172,1173},{1174,1175},{1176,1177},{1178,1179},{1180,1181},{1182,1183},{1184,1185},{1186,1187},{1188,1189},{1190,1191},{1192,1193},{1194,1195},{1196,1197},{1198,1199},{1200,1201}, + {1202,1203},{1204,1205},{1206,1207},{1208,1209},{1210,1211},{1212,1213},{1214,1215},{1216,1231},{1217,1218},{1219,1220},{1221,1222},{1223,1224},{1225,1226},{1227,1228},{1229,1230},{1232,1233},{1234,1235}, + {1236,1237},{1238,1239},{1240,1241},{1242,1243},{1244,1245},{1246,1247},{1248,1249},{1250,1251},{1252,1253},{1254,1255},{1256,1257},{1258,1259},{1260,1261},{1262,1263},{1264,1265},{1266,1267},{1268,1269}, + {1270,1271},{1272,1273},{1274,1275},{1276,1277},{1278,1279},{1280,1281},{1282,1283},{1284,1285},{1286,1287},{1288,1289},{1290,1291},{1292,1293},{1294,1295},{1296,1297},{1298,1299},{1300,1301},{1302,1303}, + {1304,1305},{1306,1307},{1308,1309},{1310,1311},{1312,1313},{1314,1315},{1329,1377},{1330,1378},{1331,1379},{1332,1380},{1333,1381},{1334,1382},{1335,1383},{1336,1384},{1337,1385},{1338,1386},{1339,1387}, + {1340,1388},{1341,1389},{1342,1390},{1343,1391},{1344,1392},{1345,1393},{1346,1394},{1347,1395},{1348,1396},{1349,1397},{1350,1398},{1351,1399},{1352,1400},{1353,1401},{1354,1402},{1355,1403},{1356,1404}, + {1357,1405},{1358,1406},{1359,1407},{1360,1408},{1361,1409},{1362,1410},{1363,1411},{1364,1412},{1365,1413},{1366,1414},{4256,11520},{4257,11521},{4258,11522},{4259,11523},{4260,11524},{4261,11525},{4262,11526}, + {4263,11527},{4264,11528},{4265,11529},{4266,11530},{4267,11531},{4268,11532},{4269,11533},{4270,11534},{4271,11535},{4272,11536},{4273,11537},{4274,11538},{4275,11539},{4276,11540},{4277,11541},{4278,11542}, + {4279,11543},{4280,11544},{4281,11545},{4282,11546},{4283,11547},{4284,11548},{4285,11549},{4286,11550},{4287,11551},{4288,11552},{4289,11553},{4290,11554},{4291,11555},{4292,11556},{4293,11557},{7680,7681}, + {7682,7683},{7684,7685},{7686,7687},{7688,7689},{7690,7691},{7692,7693},{7694,7695},{7696,7697},{7698,7699},{7700,7701},{7702,7703},{7704,7705},{7706,7707},{7708,7709},{7710,7711},{7712,7713},{7714,7715}, + {7716,7717},{7718,7719},{7720,7721},{7722,7723},{7724,7725},{7726,7727},{7728,7729},{7730,7731},{7732,7733},{7734,7735},{7736,7737},{7738,7739},{7740,7741},{7742,7743},{7744,7745},{7746,7747},{7748,7749}, + {7750,7751},{7752,7753},{7754,7755},{7756,7757},{7758,7759},{7760,7761},{7762,7763},{7764,7765},{7766,7767},{7768,7769},{7770,7771},{7772,7773},{7774,7775},{7776,7777},{7778,7779},{7780,7781},{7782,7783}, + {7784,7785},{7786,7787},{7788,7789},{7790,7791},{7792,7793},{7794,7795},{7796,7797},{7798,7799},{7800,7801},{7802,7803},{7804,7805},{7806,7807},{7808,7809},{7810,7811},{7812,7813},{7814,7815},{7816,7817}, + {7818,7819},{7820,7821},{7822,7823},{7824,7825},{7826,7827},{7828,7829},{7840,7841},{7842,7843},{7844,7845},{7846,7847},{7848,7849},{7850,7851},{7852,7853},{7854,7855},{7856,7857},{7858,7859},{7860,7861}, + {7862,7863},{7864,7865},{7866,7867},{7868,7869},{7870,7871},{7872,7873},{7874,7875},{7876,7877},{7878,7879},{7880,7881},{7882,7883},{7884,7885},{7886,7887},{7888,7889},{7890,7891},{7892,7893},{7894,7895}, + {7896,7897},{7898,7899},{7900,7901},{7902,7903},{7904,7905},{7906,7907},{7908,7909},{7910,7911},{7912,7913},{7914,7915},{7916,7917},{7918,7919},{7920,7921},{7922,7923},{7924,7925},{7926,7927},{7928,7929}, + {7930,7931},{7932,7933},{7934,7935},{7944,7936},{7945,7937},{7946,7938},{7947,7939},{7948,7940},{7949,7941},{7950,7942},{7951,7943},{7960,7952},{7961,7953},{7962,7954},{7963,7955},{7964,7956},{7965,7957}, + {7976,7968},{7977,7969},{7978,7970},{7979,7971},{7980,7972},{7981,7973},{7982,7974},{7983,7975},{7992,7984},{7993,7985},{7994,7986},{7995,7987},{7996,7988},{7997,7989},{7998,7990},{7999,7991},{8008,8000}, + {8009,8001},{8010,8002},{8011,8003},{8012,8004},{8013,8005},{8025,8017},{8027,8019},{8029,8021},{8031,8023},{8040,8032},{8041,8033},{8042,8034},{8043,8035},{8044,8036},{8045,8037},{8046,8038},{8047,8039}, + {8072,8064},{8073,8065},{8074,8066},{8075,8067},{8076,8068},{8077,8069},{8078,8070},{8079,8071},{8088,8080},{8089,8081},{8090,8082},{8091,8083},{8092,8084},{8093,8085},{8094,8086},{8095,8087},{8104,8096}, + {8105,8097},{8106,8098},{8107,8099},{8108,8100},{8109,8101},{8110,8102},{8111,8103},{8120,8112},{8121,8113},{8122,8048},{8123,8049},{8124,8115},{8136,8050},{8137,8051},{8138,8052},{8139,8053},{8140,8131}, + {8152,8144},{8153,8145},{8154,8054},{8155,8055},{8168,8160},{8169,8161},{8170,8058},{8171,8059},{8172,8165},{8184,8056},{8185,8057},{8186,8060},{8187,8061},{8188,8179},{8192,32},{8193,32},{8194,32},{8195,32}, + {8196,32},{8197,32},{8198,32},{8208,45},{8209,45},{8211,45},{8212,45},{8216,39},{8217,39},{8218,44},{8220,34},{8221,34},{8222,34},{8226,46},{8230,46},{8242,39},{8245,96},{8249,60},{8250,62},{8482,84},{8498,8526}, + {8544,8560},{8545,8561},{8546,8562},{8547,8563},{8548,8564},{8549,8565},{8550,8566},{8551,8567},{8552,8568},{8553,8569},{8554,8570},{8555,8571},{8556,8572},{8557,8573},{8558,8574},{8559,8575},{8579,8580}, + {9398,9424},{9399,9425},{9400,9426},{9401,9427},{9402,9428},{9403,9429},{9404,9430},{9405,9431},{9406,9432},{9407,9433},{9408,9434},{9409,9435},{9410,9436},{9411,9437},{9412,9438},{9413,9439},{9414,9440}, + {9415,9441},{9416,9442},{9417,9443},{9418,9444},{9419,9445},{9420,9446},{9421,9447},{9422,9448},{9423,9449},{11264,11312},{11265,11313},{11266,11314},{11267,11315},{11268,11316},{11269,11317},{11270,11318}, + {11271,11319},{11272,11320},{11273,11321},{11274,11322},{11275,11323},{11276,11324},{11277,11325},{11278,11326},{11279,11327},{11280,11328},{11281,11329},{11282,11330},{11283,11331},{11284,11332},{11285,11333}, + {11286,11334},{11287,11335},{11288,11336},{11289,11337},{11290,11338},{11291,11339},{11292,11340},{11293,11341},{11294,11342},{11295,11343},{11296,11344},{11297,11345},{11298,11346},{11299,11347},{11300,11348}, + {11301,11349},{11302,11350},{11303,11351},{11304,11352},{11305,11353},{11306,11354},{11307,11355},{11308,11356},{11309,11357},{11310,11358},{11360,11361},{11362,619},{11363,7549},{11364,637},{11367,11368}, + {11369,11370},{11371,11372},{11373,593},{11374,625},{11375,592},{11378,11379},{11381,11382},{11392,11393},{11394,11395},{11396,11397},{11398,11399},{11400,11401},{11402,11403},{11404,11405},{11406,11407}, + {11408,11409},{11410,11411},{11412,11413},{11414,11415},{11416,11417},{11418,11419},{11420,11421},{11422,11423},{11424,11425},{11426,11427},{11428,11429},{11430,11431},{11432,11433},{11434,11435},{11436,11437}, + {11438,11439},{11440,11441},{11442,11443},{11444,11445},{11446,11447},{11448,11449},{11450,11451},{11452,11453},{11454,11455},{11456,11457},{11458,11459},{11460,11461},{11462,11463},{11464,11465},{11466,11467}, + {11468,11469},{11470,11471},{11472,11473},{11474,11475},{11476,11477},{11478,11479},{11480,11481},{11482,11483},{11484,11485},{11486,11487},{11488,11489},{11490,11491},{42560,42561},{42562,42563},{42564,42565}, + {42566,42567},{42568,42569},{42570,42571},{42572,42573},{42574,42575},{42576,42577},{42578,42579},{42580,42581},{42582,42583},{42584,42585},{42586,42587},{42588,42589},{42590,42591},{42594,42595},{42596,42597}, + {42598,42599},{42600,42601},{42602,42603},{42604,42605},{42624,42625},{42626,42627},{42628,42629},{42630,42631},{42632,42633},{42634,42635},{42636,42637},{42638,42639},{42640,42641},{42642,42643},{42644,42645}, + {42646,42647},{42786,42787},{42788,42789},{42790,42791},{42792,42793},{42794,42795},{42796,42797},{42798,42799},{42802,42803},{42804,42805},{42806,42807},{42808,42809},{42810,42811},{42812,42813},{42814,42815}, + {42816,42817},{42818,42819},{42820,42821},{42822,42823},{42824,42825},{42826,42827},{42828,42829},{42830,42831},{42832,42833},{42834,42835},{42836,42837},{42838,42839},{42840,42841},{42842,42843},{42844,42845}, + {42846,42847},{42848,42849},{42850,42851},{42852,42853},{42854,42855},{42856,42857},{42858,42859},{42860,42861},{42862,42863},{42873,42874},{42875,42876},{42877,7545},{42878,42879},{42880,42881},{42882,42883}, + {42884,42885},{42886,42887},{42891,42892},{65281,33},{65282,34},{65283,35},{65284,36},{65285,37},{65286,38},{65287,39},{65288,40},{65289,41},{65290,42},{65291,43},{65292,44},{65293,45},{65294,46},{65295,47}, + {65296,48},{65297,49},{65298,50},{65299,51},{65300,52},{65301,53},{65302,54},{65303,55},{65304,56},{65305,57},{65306,58},{65307,59},{65308,60},{65309,61},{65310,62},{65312,64},{65313,97},{65314,98},{65315,99}, + {65316,100},{65317,101},{65318,102},{65319,103},{65320,104},{65321,105},{65322,106},{65323,107},{65324,108},{65325,109},{65326,110},{65327,111},{65328,112},{65329,113},{65330,114},{65331,115},{65332,116}, + {65333,117},{65334,118},{65335,119},{65336,120},{65337,121},{65338,122},{65339,91},{65340,92},{65341,93},{65342,94},{65343,95},{65344,96},{65345,97},{65346,98},{65347,99},{65348,100},{65349,101},{65350,102}, + {65351,103},{65352,104},{65353,105},{65354,106},{65355,107},{65356,108},{65357,109},{65358,110},{65359,111},{65360,112},{65361,113},{65362,114},{65363,115},{65364,116},{65365,117},{65366,118},{65367,119}, + {65368,120},{65369,121},{65370,122},{65371,123},{65372,124},{65373,125},{65374,126}, + }; +} + +namespace pfc { + + const CharDownConvert::charMapping_t* CharDownConvert::mappings() { return g_mappings; } + size_t CharDownConvert::numMappings() { return std::size(g_mappings); } + + CharDownConvert::CharDownConvert() { + std::map charConvertMap; + + for (auto& l : g_mappings) { + charConvertMap[(uint32_t)l.from] = (uint32_t)l.to; + } + for (auto& line : twoCharMappings) { + charConvertMap[line.from] = line.to; + } + + m_charConvertMap.initialize(std::move(charConvertMap)); + } + + void CharDownConvert::TransformCharCachedAppend(t_uint32 c, pfc::string_base& out) { + auto subst = m_charConvertMap.query_ptr(c); + if (subst != nullptr) { + out << subst->ptr(); + } else { + out.add_char(c); + } + } + void CharDownConvert::TransformStringHere(pfc::string_base& out, const char* src, size_t len) { + out.reset(); this->TransformStringAppend(out, src, len); + } + + void CharDownConvert::TransformStringAppend(pfc::string_base& out, const char* src, size_t len) { + size_t walk = 0; + while(walk < len) { + char c = src[walk]; + if (c > 0) { + out.add_byte(pfc::ascii_tolower_lookup(c)); + ++walk; + } else if (c == 0) { + break; + } else { + unsigned wc; t_size d; + d = pfc::utf8_decode_char(src + walk, wc, len - walk); + if (d == 0) break; + TransformCharCachedAppend(wc, out); + walk += d; + } + } + } + + CharDownConvert& CharDownConvert::instance() { + static CharDownConvert obj; return obj; + } +} // namespace pfc \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/charDownConvert.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/charDownConvert.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,54 @@ +#pragma once +#include "string_base.h" +#include "fixed_map.h" + +// This converts to ASCII *and* lowercases for simplified search matching +namespace pfc { + class CharStorage { + public: + CharStorage() { } + template CharStorage(const TSource& in) { Import(in); } + template const CharStorage& operator=(const TSource& in) { Import(in); return *this; } + + const char* ptr() const { return m_data; } + + void Import(t_uint32 c) { + t_size l = pfc::utf8_encode_char(c, m_data); + m_data[l] = 0; + } + void Import(const char* c) { + PFC_ASSERT(strlen(c) < PFC_TABSIZE(m_data)); +#ifdef _MSC_VER + strcpy_s(m_data, c); +#else + strcpy(m_data, c); +#endif + } + + char m_data[16] = {}; + }; + + class CharDownConvert { + public: + CharDownConvert(); + + void TransformCharCachedAppend(t_uint32 c, pfc::string_base& out); + void TransformStringAppend(pfc::string_base& out, const char* src, size_t len = SIZE_MAX); + void TransformStringHere(pfc::string_base& out, const char* src, size_t len = SIZE_MAX); + string8 TransformString(const char* src) { pfc::string8 ret; TransformStringAppend(ret, src); return ret; } + void TransformString(pfc::string_base& out, const char* src) { + out.reset(); TransformStringAppend(out, src); + } + + static CharDownConvert& instance(); + + struct charMapping_t { + uint16_t from, to; + }; + static const charMapping_t* mappings(); + static size_t numMappings(); + + private: + fixed_map m_charConvertMap; + }; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/cmd_thread.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/cmd_thread.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,46 @@ +#pragma once + +#include "wait_queue.h" +#include +#include +#include + +namespace pfc { + + class cmdThread { + public: + typedef std::function cmd_t; + typedef pfc::waitQueue queue_t; + + void add(cmd_t c) { + std::call_once(m_once, [this] { + auto q = std::make_shared(); + pfc::splitThread([q] { + cmd_t cmd; + while (q->get(cmd)) { + cmd(); + } + }); + m_queue = q; + }); + m_queue->put(c); + } + + void shutdown() { + if (m_queue) { + m_queue->set_eof(); + m_queue.reset(); + } + } + ~cmdThread() { + shutdown(); + } + private: + + std::shared_ptr< queue_t > m_queue; + + + std::once_flag m_once; + }; + +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/com_ptr_t.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/com_ptr_t.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,87 @@ +#pragma once + +#ifdef _WIN32 +namespace pfc { + + template static void _COM_AddRef(what * ptr) { + if (ptr != NULL) ptr->AddRef(); + } + template static void _COM_Release(what * ptr) { + if (ptr != NULL) ptr->Release(); + } + + template + class com_ptr_t { + public: + typedef com_ptr_t t_self; + + com_ptr_t( nullptr_t ) throw() : m_ptr() {} + + com_ptr_t() throw() : m_ptr() {} + template inline com_ptr_t(source * p_ptr) throw() : m_ptr(p_ptr) {_COM_AddRef(m_ptr);} + com_ptr_t(const t_self & p_source) throw() : m_ptr(p_source.m_ptr) {_COM_AddRef(m_ptr);} + template inline com_ptr_t(const com_ptr_t & p_source) throw() : m_ptr(p_source.get_ptr()) {_COM_AddRef(m_ptr);} + + inline ~com_ptr_t() throw() {_COM_Release(m_ptr);} + + inline void copy(T * p_ptr) throw() { + _COM_Release(m_ptr); + m_ptr = p_ptr; + _COM_AddRef(m_ptr); + } + + template inline void copy(const com_ptr_t & p_source) throw() {copy(p_source.get_ptr());} + + inline void attach(T * p_ptr) throw() { + _COM_Release(m_ptr); + m_ptr = p_ptr; + } + + inline const t_self & operator=(const t_self & p_source) throw() {copy(p_source); return *this;} + inline const t_self & operator=(T* p_source) throw() {copy(p_source); return *this;} + template inline const t_self & operator=(const com_ptr_t & p_source) throw() {copy(p_source); return *this;} + template inline const t_self & operator=(source * p_ptr) throw() {copy(p_ptr); return *this;} + + inline void release() throw() { + _COM_Release(m_ptr); + m_ptr = NULL; + } + + + inline T* operator->() const throw() {PFC_ASSERT(m_ptr);return m_ptr;} + + inline T* get_ptr() const throw() {return m_ptr;} + + inline T* duplicate_ptr() const throw() //should not be used ! temporary ! + { + _COM_AddRef(m_ptr); + return m_ptr; + } + + inline T* detach() throw() { + return replace_null_t(m_ptr); + } + + inline bool is_valid() const throw() {return m_ptr != 0;} + inline bool is_empty() const throw() {return m_ptr == 0;} + + inline bool operator==(const com_ptr_t & p_item) const throw() {return m_ptr == p_item.m_ptr;} + inline bool operator!=(const com_ptr_t & p_item) const throw() {return m_ptr != p_item.m_ptr;} + inline bool operator>(const com_ptr_t & p_item) const throw() {return m_ptr > p_item.m_ptr;} + inline bool operator<(const com_ptr_t & p_item) const throw() {return m_ptr < p_item.m_ptr;} + + inline static void g_swap(com_ptr_t & item1, com_ptr_t & item2) throw() { + pfc::swap_t(item1.m_ptr,item2.m_ptr); + } + + inline T** receive_ptr() throw() {release();return &m_ptr;} + inline void** receive_void_ptr() throw() {return (void**) receive_ptr();} + + inline t_self & operator<<(t_self & p_source) throw() {attach(p_source.detach());return *this;} + inline t_self & operator>>(t_self & p_dest) throw() {p_dest.attach(detach());return *this;} + private: + T* m_ptr; + }; + +} +#endif diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/cpuid.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/cpuid.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,73 @@ +#include "pfc-lite.h" +#include "cpuid.h" + + +#ifdef _MSC_VER +#include +#endif + +#if PFC_HAVE_CPUID +namespace pfc { + + bool query_cpu_feature_set(unsigned p_value) { + +#ifdef __AVX__ + // AVX implies all supported values are set + return true; +#else + +#if _M_IX86_FP >= 2 || defined(_M_X64) + // don't bother checking for SSE/SSE2 if compiled to use them + p_value &= ~(CPU_HAVE_SSE | CPU_HAVE_SSE2); + if (p_value == 0) return true; +#endif + +#ifdef _MSC_VER + __try { +#endif + if (p_value & (CPU_HAVE_SSE | CPU_HAVE_SSE2 | CPU_HAVE_SSE3 | CPU_HAVE_SSSE3 | CPU_HAVE_SSE41 | CPU_HAVE_SSE42 | CPU_HAVE_AVX)) { + int buffer[4]; + __cpuid(buffer,1); + if (p_value & CPU_HAVE_SSE) { + if ((buffer[3]&(1<<25)) == 0) return false; + } + if (p_value & CPU_HAVE_SSE2) { + if ((buffer[3]&(1<<26)) == 0) return false; + } + if (p_value & CPU_HAVE_SSE3) { + if ((buffer[2]&(1<<0)) == 0) return false; + } + if (p_value & CPU_HAVE_SSSE3) { + if ((buffer[2]&(1<<9)) == 0) return false; + } + if (p_value & CPU_HAVE_SSE41) { + if ((buffer[2]&(1<<19)) == 0) return false; + } + if (p_value & CPU_HAVE_SSE42) { + if ((buffer[2]&(1<<20)) == 0) return false; + } + if (p_value & CPU_HAVE_AVX) { + if ((buffer[2] & (1 << 28)) == 0) return false; + } + } + return true; +#ifdef _MSC_VER + } __except(1) { + return false; + } +#endif +#endif + } +} + +#endif + +namespace pfc { + const char* cpuArch() { +#ifdef PFC_CPU_ARCH + return PFC_CPU_ARCH; +#else + return "Unknown"; +#endif + } +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/cpuid.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/cpuid.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,39 @@ +#pragma once + +// CPUID stuff supported only on MSVC for now, irrelevant for non x86 +#if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64)) +#define PFC_HAVE_CPUID 1 +namespace pfc { + enum { + CPU_HAVE_SSE = 1 << 2, + CPU_HAVE_SSE2 = 1 << 3, + CPU_HAVE_SSE3 = 1 << 4, + CPU_HAVE_SSSE3 = 1 << 5, + CPU_HAVE_SSE41 = 1 << 6, + CPU_HAVE_SSE42 = 1 << 7, + CPU_HAVE_AVX = 1 << 8, + }; + + bool query_cpu_feature_set(unsigned p_value); +}; +#endif + +#ifndef PFC_HAVE_CPUID +#define PFC_HAVE_CPUID 0 +#endif + +namespace pfc { + const char* cpuArch(); +} + +#ifdef _M_ARM64EC +#define PFC_CPU_ARCH "ARM64EC" +#elif defined(_M_X64) || defined(__x86_64__) +#define PFC_CPU_ARCH "x64" +#elif defined(_M_IX86) || defined(__i386__) +#define PFC_CPU_ARCH "x86" +#elif defined(_M_ARM64) || defined(__aarch64__) +#define PFC_CPU_ARCH "ARM64" +#elif defined(_M_ARM) || defined(__arm__) +#define PFC_CPU_ARCH "ARM" +#endif diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/crashWithMessage.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/crashWithMessage.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,114 @@ +#include "pfc-lite.h" +#include "debug.h" + +#ifdef _WIN32 +namespace pfc { + static volatile const char* g_msg; + [[noreturn]] void crashWithMessageOnStack(const char* msg) { + // fb2k crash reporter will get it reliably + g_msg = msg; + crash(); + } +} +#else + +#include "string_base.h" + +#ifdef __clang__ +#pragma clang optimize off +#endif + +[[noreturn]] static void recur( const char * msg ); + +// Rationale: don't make the letter-functions bit-identical or else the optimizer might merge them! +// Set a static volatile var to a unique value in each function. +static volatile char g; + +[[noreturn]] static void __(const char * msg) { g = '_'; recur(msg); } +[[noreturn]] static void _A_( const char * msg ) { g = 'A'; recur(msg); } +[[noreturn]] static void _B_( const char * msg ) { g = 'B'; recur(msg); } +[[noreturn]] static void _C_( const char * msg ) { g = 'C'; recur(msg); } +[[noreturn]] static void _D_( const char * msg ) { g = 'D'; recur(msg); } +[[noreturn]] static void _E_( const char * msg ) { g = 'E'; recur(msg); } +[[noreturn]] static void _F_( const char * msg ) { g = 'F'; recur(msg); } +[[noreturn]] static void _G_( const char * msg ) { g = 'G'; recur(msg); } +[[noreturn]] static void _H_( const char * msg ) { g = 'H'; recur(msg); } +[[noreturn]] static void _I_( const char * msg ) { g = 'I'; recur(msg); } +[[noreturn]] static void _J_( const char * msg ) { g = 'J'; recur(msg); } +[[noreturn]] static void _K_( const char * msg ) { g = 'K'; recur(msg); } +[[noreturn]] static void _L_( const char * msg ) { g = 'L'; recur(msg); } +[[noreturn]] static void _M_( const char * msg ) { g = 'M'; recur(msg); } +[[noreturn]] static void _N_( const char * msg ) { g = 'N'; recur(msg); } +[[noreturn]] static void _O_( const char * msg ) { g = 'O'; recur(msg); } +[[noreturn]] static void _P_( const char * msg ) { g = 'P'; recur(msg); } +[[noreturn]] static void _Q_( const char * msg ) { g = 'Q'; recur(msg); } +[[noreturn]] static void _R_( const char * msg ) { g = 'R'; recur(msg); } +[[noreturn]] static void _S_( const char * msg ) { g = 'S'; recur(msg); } +[[noreturn]] static void _T_( const char * msg ) { g = 'T'; recur(msg); } +[[noreturn]] static void _U_( const char * msg ) { g = 'U'; recur(msg); } +[[noreturn]] static void _V_( const char * msg ) { g = 'V'; recur(msg); } +[[noreturn]] static void _W_( const char * msg ) { g = 'W'; recur(msg); } +[[noreturn]] static void _X_( const char * msg ) { g = 'X'; recur(msg); } +[[noreturn]] static void _Y_( const char * msg ) { g = 'Y'; recur(msg); } +[[noreturn]] static void _Z_( const char * msg ) { g = 'Z'; recur(msg); } +[[noreturn]] static void _0_( const char * msg ) { g = '0'; recur(msg); } +[[noreturn]] static void _1_( const char * msg ) { g = '1'; recur(msg); } +[[noreturn]] static void _2_( const char * msg ) { g = '2'; recur(msg); } +[[noreturn]] static void _3_( const char * msg ) { g = '3'; recur(msg); } +[[noreturn]] static void _4_( const char * msg ) { g = '4'; recur(msg); } +[[noreturn]] static void _5_( const char * msg ) { g = '5'; recur(msg); } +[[noreturn]] static void _6_( const char * msg ) { g = '6'; recur(msg); } +[[noreturn]] static void _7_( const char * msg ) { g = '7'; recur(msg); } +[[noreturn]] static void _8_( const char * msg ) { g = '8'; recur(msg); } +[[noreturn]] static void _9_( const char * msg ) { g = '9'; recur(msg); } + + +[[noreturn]] static void recur( const char * msg ) { + char c = *msg++; + switch(pfc::ascii_toupper(c)) { + case 0: pfc::crash(); + case 'A': _A_(msg); break; + case 'B': _B_(msg); break; + case 'C': _C_(msg); break; + case 'D': _D_(msg); break; + case 'E': _E_(msg); break; + case 'F': _F_(msg); break; + case 'G': _G_(msg); break; + case 'H': _H_(msg); break; + case 'I': _I_(msg); break; + case 'J': _J_(msg); break; + case 'K': _K_(msg); break; + case 'L': _L_(msg); break; + case 'M': _M_(msg); break; + case 'N': _N_(msg); break; + case 'O': _O_(msg); break; + case 'P': _P_(msg); break; + case 'Q': _Q_(msg); break; + case 'R': _R_(msg); break; + case 'S': _S_(msg); break; + case 'T': _T_(msg); break; + case 'U': _U_(msg); break; + case 'V': _V_(msg); break; + case 'W': _W_(msg); break; + case 'X': _X_(msg); break; + case 'Y': _Y_(msg); break; + case 'Z': _Z_(msg); break; + case '0': _0_(msg); break; + case '1': _1_(msg); break; + case '2': _2_(msg); break; + case '3': _3_(msg); break; + case '4': _4_(msg); break; + case '5': _5_(msg); break; + case '6': _6_(msg); break; + case '7': _7_(msg); break; + case '8': _8_(msg); break; + case '9': _9_(msg); break; + default: __(msg) ;break; + } +} + +namespace pfc { + [[noreturn]] void crashWithMessageOnStack( const char * msg ) { recur(msg); } +} + +#endif \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/debug.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/debug.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,57 @@ +#pragma once +#include "string-lite.h" +#include + +#ifdef __ANDROID__ +#define PFC_SET_THREAD_DESCRIPTION_EXTERNAL +#endif + +namespace pfc { + void debugBreak(); + [[noreturn]] void crash(); + [[noreturn]] void crashWithMessageOnStack( const char * msg ); + void outputDebugLine(const char * msg); + +#ifdef __APPLE__ + [[noreturn]] void appleThrowException( const char * name, const char * reason ); +#endif + + // Debug logger service. + // It is up to the caller to ensure thread safety. You want to create debugLineReceiver instances on app startup and never destroy them. + class debugLineReceiver { + public: + debugLineReceiver(); + virtual void onLine( const char *) {} + + + static void dispatch( const char * msg ); + private: + debugLineReceiver * m_chain; + + void operator=( const debugLineReceiver & ) = delete; + debugLineReceiver( const debugLineReceiver & ) = delete; + }; + + class debugLog : public string_formatter { + public: + ~debugLog() { outputDebugLine(this->get_ptr()); } + }; +#define PFC_DEBUGLOG ::pfc::debugLog()._formatter() + + void setCurrentThreadDescription( const char * ); + +#ifdef PFC_SET_THREAD_DESCRIPTION_EXTERNAL + void initSetCurrentThreadDescription( std::function ); +#endif +} + +#define PFC_SET_THREAD_DESCRIPTION(X) { ::pfc::setCurrentThreadDescription(X); } +#define PFC_SET_THREAD_DESCRIPTION_SUPPORTED + +#define PFC_DEBUG_PRINT_FORCED(...) ::pfc::outputDebugLine(pfc::format(__VA_ARGS__)) + +#if PFC_DEBUG +#define PFC_DEBUG_PRINT(...) PFC_DEBUG_PRINT_FORCED(pfc::format(__VA_ARGS__)) +#else +#define PFC_DEBUG_PRINT(...) +#endif diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/event.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/event.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,4 @@ +#pragma once + +// All in win-objects.h & nix-objects.h +#include "platform-objects.h" \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/event_std.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/event_std.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,49 @@ +#pragma once + +// Alternate lightweight implementation of pfc::event, with similar method sigantures but no support for multi-event-wait-for-any. +// It's a safe drop-in replacement for the regular event - code trying to use unsupported methods will fail to compile rather than behave incorrectly. + +// Rationale: +// Mac/Linux multi-wait-capable pipe-backed event is relatively expensive, in terms of CPU, memory and file descriptors opened. +// On Windows, event_std still outperforms regular win32 event but the difference is mostly insignificant in real life use cases. + +#include +#include +namespace pfc { + class event_std { + public: + void set_state(bool v = true) { + std::scoped_lock lock(m_mutex); + if (m_state != v) { + m_state = v; + if (v) m_condition.notify_all(); + } + } + bool is_set() const { return m_state; } + void wait() { + std::unique_lock lock(m_mutex); + m_condition.wait(lock, [this] { return this->m_state; }); + } + bool wait_for(double timeout) { + if (timeout < 0) { wait(); return true; } + std::unique_lock lock(m_mutex); + return m_condition.wait_for(lock, std::chrono::duration(timeout), [this] { return this->m_state; }); + } + void wait_and_clear() { + std::unique_lock lock(m_mutex); + m_condition.wait(lock, [this] { return this->m_state; }); + m_state = false; + } + bool wait_for_and_clear(double timeout) { + if ( timeout < 0 ) {wait_and_clear(); return true;} + std::unique_lock lock(m_mutex); + bool rv = m_condition.wait_for(lock, std::chrono::duration(timeout), [this] { return this->m_state; }); + if ( rv ) m_state = false; + return rv; + } + private: + volatile bool m_state = false; + std::condition_variable m_condition; + std::mutex m_mutex; + }; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/filehandle.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/filehandle.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,34 @@ +#include "pfc-lite.h" +#include "filehandle.h" + +#ifndef _WIN32 +#include +#endif + +namespace pfc { +void fileHandleClose( fileHandle_t h ) noexcept { + if (h == fileHandleInvalid) return; +#ifdef _WIN32 + CloseHandle( h ); +#else + close( h ); +#endif +} + +fileHandle_t fileHandleDup( fileHandle_t h ) { +#ifdef _WIN32 + auto proc = GetCurrentProcess(); + HANDLE out; + if (!DuplicateHandle ( proc, h, proc, &out, 0, FALSE, DUPLICATE_SAME_ACCESS )) return fileHandleInvalid; + return out; +#else + return dup( h ); +#endif +} + +void fileHandle::close() noexcept { + fileHandleClose( h ); + clear(); +} + +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/filehandle.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/filehandle.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,31 @@ +#pragma once + +namespace pfc { +#ifdef _WIN32 + typedef HANDLE fileHandle_t; + const fileHandle_t fileHandleInvalid = INVALID_HANDLE_VALUE; +#else + typedef int fileHandle_t; + constexpr fileHandle_t fileHandleInvalid = -1; +#endif + + void fileHandleClose( fileHandle_t h ) noexcept; + fileHandle_t fileHandleDup( fileHandle_t h ); + + class fileHandle { + public: + fileHandle( fileHandle_t val ) : h(val) {} + fileHandle() : h ( fileHandleInvalid ) {} + ~fileHandle() noexcept { close(); } + fileHandle( fileHandle && other ) noexcept { h = other.h; other.clear(); } + void operator=( fileHandle && other ) noexcept { close(); h = other.h; other.clear(); } + void operator=( fileHandle_t other ) { close(); h = other; } + void close() noexcept; + void clear() noexcept { h = fileHandleInvalid; } + bool isValid() noexcept { return h != fileHandleInvalid; } + fileHandle_t h; + private: + fileHandle( const fileHandle & ) = delete; + void operator=( const fileHandle & ) = delete; + }; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/filetimetools.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/filetimetools.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,331 @@ +#include "pfc-lite.h" + +#include "filetimetools.h" + +#include "timers.h" + +#include + +namespace { + class exception_time_error {}; +} + +using namespace pfc; + +#ifndef _WIN32 +namespace { + typedef uint16_t WORD; + + typedef struct _SYSTEMTIME { + WORD wYear; + WORD wMonth; + WORD wDayOfWeek; + WORD wDay; + WORD wHour; + WORD wMinute; + WORD wSecond; + WORD wMilliseconds; + } SYSTEMTIME, * PSYSTEMTIME, * LPSYSTEMTIME; + +} +static void SystemTimeToNix(const SYSTEMTIME& st, struct tm& Time) { + memset(&Time, 0, sizeof(Time)); + Time.tm_sec = st.wSecond; + Time.tm_min = st.wMinute; + Time.tm_hour = st.wHour; + Time.tm_mday = st.wDay; + Time.tm_mon = st.wMonth - 1; + Time.tm_year = st.wYear - 1900; +} + +static t_filetimestamp ExportSystemTime(const SYSTEMTIME& st) { + struct tm Time; + SystemTimeToNix(st, Time); + return pfc::fileTimeUtoW(mktime(&Time)); +} + +static t_filetimestamp ExportSystemTimeLocal(const SYSTEMTIME& st) { + struct tm Time, Local; + SystemTimeToNix(st, Time); + time_t t = mktime(&Time); + localtime_r(&t, &Local); + return pfc::fileTimeUtoW(mktime(&Local)); +} +static void SystemTimeFromNix(SYSTEMTIME& st, struct tm const& Time, t_filetimestamp origTS) { + memset(&st, 0, sizeof(st)); + st.wSecond = Time.tm_sec; + st.wMinute = Time.tm_min; + st.wHour = Time.tm_hour; + st.wDay = Time.tm_mday; + st.wDayOfWeek = Time.tm_wday; + st.wMonth = Time.tm_mon + 1; + st.wYear = Time.tm_year + 1900; + st.wMilliseconds = (origTS % filetimestamp_1second_increment) / (filetimestamp_1second_increment/1000); +} + +static bool MakeSystemTime(SYSTEMTIME& st, t_filetimestamp ts) { + time_t t = (time_t)pfc::fileTimeWtoU(ts); + struct tm Time; + if (gmtime_r(&t, &Time) == NULL) return false; + SystemTimeFromNix(st, Time, ts); + return true; +} + +static bool MakeSystemTimeLocal(SYSTEMTIME& st, t_filetimestamp ts) { + time_t t = (time_t)pfc::fileTimeWtoU(ts); + struct tm Time; + if (localtime_r(&t, &Time) == NULL) return false; + SystemTimeFromNix(st, Time, ts); + return true; +} + +#else +static t_filetimestamp ExportSystemTime(const SYSTEMTIME& st) { + t_filetimestamp base; + if (!SystemTimeToFileTime(&st, (FILETIME*)&base)) throw exception_time_error(); + return base; +} +static t_filetimestamp ExportSystemTimeLocal(const SYSTEMTIME& st) { +#ifdef FOOBAR2000_DESKTOP_WINDOWS + t_filetimestamp base, out; + if (!SystemTimeToFileTime(&st, (FILETIME*)&base)) throw exception_time_error(); + if (!LocalFileTimeToFileTime((const FILETIME*)&base, (FILETIME*)&out)) throw exception_time_error(); + return out; +#else + SYSTEMTIME UTC; + if (!TzSpecificLocalTimeToSystemTime(NULL, &st, &UTC)) throw exception_time_error(); + return ExportSystemTime(UTC); +#endif +} +static bool MakeSystemTime(SYSTEMTIME& st, t_filetimestamp ts) { + if (ts == filetimestamp_invalid) return false; + return !!FileTimeToSystemTime((const FILETIME*)&ts, &st); + +} +static bool MakeSystemTimeLocal(SYSTEMTIME& st, t_filetimestamp ts) { + if (ts == filetimestamp_invalid) return false; +#ifdef FOOBAR2000_DESKTOP_WINDOWS + FILETIME ft; + if (FileTimeToLocalFileTime((FILETIME*)&ts, &ft)) { + if (FileTimeToSystemTime(&ft, &st)) { + return true; + } + } + return false; +#else + SYSTEMTIME UTC; + if (FileTimeToSystemTime((FILETIME*)&ts, &UTC)) { + if (SystemTimeToTzSpecificLocalTime(NULL, &UTC, &st)) return true; + } + return false; +#endif +} +#endif // _WIN32 + +static bool is_spacing(char c) { return c == ' ' || c == 10 || c == 13 || c == '\t'; } + +static unsigned ParseDateElem(const char* ptr, t_size len) { + unsigned ret = 0; + for (t_size walk = 0; walk < len; ++walk) { + const char c = ptr[walk]; + if (c < '0' || c > '9') throw exception_time_error(); + ret = ret * 10 + (unsigned)(c - '0'); + } + return ret; +} + +static bool st_sanity(SYSTEMTIME const& st) { + return st.wYear >= 1601 && st.wMonth >= 1 && st.wMonth <= 12 && st.wDay >= 1 && st.wDay <= 31 && st.wHour < 24 && st.wMinute < 60 && st.wSecond < 60 && st.wMilliseconds < 1000; +} +static t_filetimestamp filetimestamp_from_string_internal(const char* date, bool local) { + // Accepted format + // YYYY-MM-DD HH:MM:SS + try { + SYSTEMTIME st = {}; + st.wDay = 1; st.wMonth = 1; + + unsigned walk = 0; + auto worker = [&](unsigned n) { + auto ret = ParseDateElem(date + walk, n); + walk += n; + if (ret > UINT16_MAX) throw exception_time_error(); + return (WORD)ret;; + }; + + auto skip = [&](char c) { + if (date[walk] == c) ++walk; + }; + + auto skipSpacing = [&] { + while (is_spacing(date[walk])) ++walk; + }; + skipSpacing(); + st.wYear = worker(4); + skip('-'); + st.wMonth = worker(2); + skip('-'); + st.wDay = worker(2); + skipSpacing(); + st.wHour = worker(2); + skip(':'); + st.wMinute = worker(2); + skip(':'); + st.wSecond = worker(2); + if (date[walk] == '.') { + double v = pfc::string_to_float(date + walk); + st.wMilliseconds = (WORD)floor(v * 1000.f); // don't ever round up, don't want to handle ms of 1000 + } + + if (!st_sanity(st)) throw exception_time_error(); + + if (local) { + return ExportSystemTimeLocal(st); + } else { + return ExportSystemTime(st); + } + } catch (exception_time_error const &) { + return filetimestamp_invalid; + } +} + +namespace pfc { + t_filetimestamp filetimestamp_from_string(const char* date) { + return filetimestamp_from_string_internal(date, true); + } + + t_filetimestamp filetimestamp_from_string_utc(const char* date) { + return filetimestamp_from_string_internal(date, false); + } + + static constexpr char g_invalidMsg[] = ""; + + pfc::string_formatter format_filetimestamp(t_filetimestamp p_timestamp) { + try { + SYSTEMTIME st; + if (MakeSystemTimeLocal(st, p_timestamp)) { + pfc::string_formatter buffer; + buffer + << pfc::format_uint(st.wYear, 4) << "-" << pfc::format_uint(st.wMonth, 2) << "-" << pfc::format_uint(st.wDay, 2) << " " + << pfc::format_uint(st.wHour, 2) << ":" << pfc::format_uint(st.wMinute, 2) << ":" << pfc::format_uint(st.wSecond, 2); + return buffer; + } + } catch (...) {} + return g_invalidMsg; + } + + pfc::string_formatter format_filetimestamp_ms(t_filetimestamp p_timestamp) { + try { + SYSTEMTIME st; + if (MakeSystemTimeLocal(st, p_timestamp)) { + pfc::string_formatter buffer; + buffer + << pfc::format_uint(st.wYear, 4) << "-" << pfc::format_uint(st.wMonth, 2) << "-" << pfc::format_uint(st.wDay, 2) << " " + << pfc::format_uint(st.wHour, 2) << ":" << pfc::format_uint(st.wMinute, 2) << ":" << pfc::format_uint(st.wSecond, 2) << "." << pfc::format_uint(st.wMilliseconds, 3); + return buffer; + } + } catch (...) {} + return g_invalidMsg; + } + + pfc::string_formatter format_filetimestamp_utc(t_filetimestamp p_timestamp) { + try { + SYSTEMTIME st; + if (MakeSystemTime(st, p_timestamp)) { + pfc::string_formatter buffer; + buffer + << pfc::format_uint(st.wYear, 4) << "-" << pfc::format_uint(st.wMonth, 2) << "-" << pfc::format_uint(st.wDay, 2) << " " + << pfc::format_uint(st.wHour, 2) << ":" << pfc::format_uint(st.wMinute, 2) << ":" << pfc::format_uint(st.wSecond, 2); + return buffer; + } + } catch (...) {} + return g_invalidMsg; + } + +} // namespace foobar2000_io + +namespace { + struct dateISO_t { + unsigned Y, M, D; + unsigned h, m, s; + double sfrac; + int tzdelta; + }; + + dateISO_t read_ISO_8601(const char* dateISO) { + dateISO_t ret = {}; + // 2022-01-26T13:44:51.200000Z + // 2010-02-19T14:54:23.031+08:00 + // 2022-01-27T11:01:49+00:00 + // 2022-01-27T11:01:49Z + // 20220127T110149Z + + unsigned walk = 0; + auto worker = [&](unsigned n) { + auto ret = ParseDateElem(dateISO + walk, n); + walk += n; + return ret; + }; + auto skip = [&](char c) { + if (dateISO[walk] == c) ++walk; + }; + auto expect = [&](char c) { + if (dateISO[walk] != c) throw exception_time_error(); + ++walk; + }; + ret.Y = worker(4); + skip('-'); + ret.M = worker(2); + skip('-'); + ret.D = worker(2); + expect('T'); + ret.h = worker(2); + skip(':'); + ret.m = worker(2); + skip(':'); + ret.s = worker(2); + if (dateISO[walk] == '.') { + unsigned base = walk; + ++walk; + while (pfc::char_is_numeric(dateISO[walk])) ++walk; + ret.sfrac = pfc::string_to_float(dateISO + base, walk - base); + } + if (dateISO[walk] == '+' || dateISO[walk] == '-') { + bool neg = dateISO[walk] == '-'; + ++walk; + unsigned tz_h = worker(2); + if (tz_h >= 24) throw exception_time_error(); + skip(':'); + unsigned tz_m = worker(2); + if (tz_m >= 60) throw exception_time_error(); + tz_m += tz_h * 60; + ret.tzdelta = neg ? (int)tz_m : -(int)tz_m; // reversed! it's a timezone offset, have to *add* it if timezone has a minus + } + return ret; + } +} + +t_filetimestamp pfc::filetimestamp_from_string_ISO_8601(const char* dateISO) { + try { + auto elems = read_ISO_8601(dateISO); + + SYSTEMTIME st = {}; + st.wDay = 1; st.wMonth = 1; + st.wYear = (WORD)elems.Y; + st.wMonth = (WORD)elems.M; + st.wDay = (WORD)elems.D; + st.wHour = (WORD)elems.h; + st.wMinute = (WORD)elems.m; + st.wSecond = (WORD)elems.s; + st.wMilliseconds = (WORD)floor(elems.sfrac * 1000.f); + + if (!st_sanity(st)) throw exception_time_error(); + + auto ret = ExportSystemTime(st); + + ret += filetimestamp_1second_increment * elems.tzdelta * 60; + + return ret; + } catch (...) { + return filetimestamp_invalid; + } +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/filetimetools.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/filetimetools.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,20 @@ +#pragma once + +namespace pfc { + typedef uint64_t t_filetimestamp; + static constexpr t_filetimestamp filetimestamp_invalid = 0; + static constexpr t_filetimestamp filetimestamp_1second_increment = 10000000; + + t_filetimestamp filetimestamp_from_string(const char * date); + t_filetimestamp filetimestamp_from_string_utc(const char* date); + // From ISO 8601 time + t_filetimestamp filetimestamp_from_string_ISO_8601(const char* date); + + //! Warning: this formats according to system timezone settings, created strings should be used for display only, never for storage. + pfc::string_formatter format_filetimestamp(t_filetimestamp p_timestamp); + //! UTC timestamp + pfc::string_formatter format_filetimestamp_utc(t_filetimestamp p_timestamp); + //! Local timestamp with milliseconds + pfc::string_formatter format_filetimestamp_ms(t_filetimestamp p_timestamp); + +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/fixed_map.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/fixed_map.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,37 @@ +#pragma once + +#include +#include +#include + +template class fixed_map { +public: + typedef std::map source_t; + + void initialize(source_t&& src) { + const size_t size = src.size(); + m_keys.resize(size); m_values.resize(size); + size_t walk = 0; + for (auto iter = src.begin(); iter != src.end(); ++iter) { + m_keys[walk] = iter->first; + m_values[walk] = std::move(iter->second); + ++walk; + } + src.clear(); + } + + value_t query(key_t key) const { + auto iter = std::lower_bound(m_keys.begin(), m_keys.end(), key); + if (iter == m_keys.end() || *iter != key) return 0; + return m_values[iter - m_keys.begin()]; + } + + const value_t* query_ptr(key_t key) const { + auto iter = std::lower_bound(m_keys.begin(), m_keys.end(), key); + if (iter == m_keys.end() || *iter != key) return nullptr; + return &m_values[iter - m_keys.begin()]; + } +private: + std::vector m_keys; + std::vector m_values; +}; \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/fpu.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/fpu.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,58 @@ +#pragma once + +#ifdef _MSC_VER + +class fpu_control +{ + unsigned old_val; + unsigned mask; +public: + inline fpu_control(unsigned p_mask,unsigned p_val) + { + mask = p_mask; + _controlfp_s(&old_val,p_val,mask); + } + inline ~fpu_control() + { + unsigned dummy; + _controlfp_s(&dummy,old_val,mask); + } +}; + +class fpu_control_roundnearest : private fpu_control +{ +public: + fpu_control_roundnearest() : fpu_control(_MCW_RC,_RC_NEAR) {} +}; + +class fpu_control_flushdenormal : private fpu_control +{ +public: + fpu_control_flushdenormal() : fpu_control(_MCW_DN,_DN_FLUSH) {} +}; + +class fpu_control_default : private fpu_control +{ +public: + fpu_control_default() : fpu_control(_MCW_DN|_MCW_RC,_DN_FLUSH|_RC_NEAR) {} +}; + +#ifdef _M_IX86 +class sse_control { +public: + sse_control(unsigned p_mask,unsigned p_val) : m_mask(p_mask) { + __control87_2(p_val,p_mask,NULL,&m_oldval); + } + ~sse_control() { + __control87_2(m_oldval,m_mask,NULL,&m_oldval); + } +private: + unsigned m_mask,m_oldval; +}; +class sse_control_flushdenormal : private sse_control { +public: + sse_control_flushdenormal() : sse_control(_MCW_DN,_DN_FLUSH) {} +}; +#endif + +#endif diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/guid.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/guid.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,208 @@ +#include "pfc-lite.h" +#include "guid.h" +#include "debug.h" // pfc::crash() +#include "string_base.h" + +#ifdef _WIN32 +#include +#else +#include "nix-objects.h" +#endif + +/* +6B29FC40-CA47-1067-B31D-00DD010662DA +. +typedef struct _GUID { // size is 16 + DWORD Data1; + WORD Data2; + WORD Data3; + BYTE Data4[8]; +} GUID; + +// {B296CF59-4D51-466f-8E0B-E57D3F91D908} +static const GUID <> = +{ 0xb296cf59, 0x4d51, 0x466f, { 0x8e, 0xb, 0xe5, 0x7d, 0x3f, 0x91, 0xd9, 0x8 } }; + +*/ +namespace { + class _GUID_from_text + { + unsigned read_hex(char c); + unsigned read_byte(const char * ptr); + unsigned read_word(const char * ptr); + unsigned read_dword(const char * ptr); + void read_bytes(unsigned char * out,unsigned num,const char * ptr); + + public: + GUID m_val = pfc::guid_null; + _GUID_from_text(const char * text); + }; + + unsigned _GUID_from_text::read_hex(char c) + { + if (c>='0' && c<='9') return (unsigned)c - '0'; + else if (c>='a' && c<='f') return 0xa + (unsigned)c - 'a'; + else if (c>='A' && c<='F') return 0xa + (unsigned)c - 'A'; + else return 0; + } + + unsigned _GUID_from_text::read_byte(const char * ptr) + { + return (read_hex(ptr[0])<<4) | read_hex(ptr[1]); + } + unsigned _GUID_from_text::read_word(const char * ptr) + { + return (read_byte(ptr)<<8) | read_byte(ptr+2); + } + + unsigned _GUID_from_text::read_dword(const char * ptr) + { + return (read_word(ptr)<<16) | read_word(ptr+4); + } + + void _GUID_from_text::read_bytes(uint8_t * out,unsigned num,const char * ptr) + { + for(;num;num--) + { + *out = read_byte(ptr); + out++;ptr+=2; + } + } + + + _GUID_from_text::_GUID_from_text(const char * text) + { + if (*text=='{') text++; + const char * max; + + { + const char * t = strchr(text,'}'); + if (t) max = t; + else max = text + strlen(text); + } + + + bool OK = false; + + do { + if (text+8>max) break; + m_val.Data1 = read_dword(text); + text += 8; + while(*text=='-') text++; + if (text+4>max) break; + m_val.Data2 = read_word(text); + text += 4; + while(*text=='-') text++; + if (text+4>max) break; + m_val.Data3 = read_word(text); + text += 4; + while(*text=='-') text++; + if (text+4>max) break; + read_bytes(m_val.Data4,2,text); + text += 4; + while(*text=='-') text++; + if (text+12>max) break; + read_bytes(m_val.Data4+2,6,text); + OK = true; + } while(false); + + if (!OK) { + m_val= pfc::guid_null; + } + } +} + +namespace pfc { + +GUID GUID_from_text(const char * text) { + return _GUID_from_text( text ).m_val; +} + +static inline char print_hex_digit(unsigned val) +{ + static constexpr char table[16] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; + PFC_ASSERT((val & ~0xF) == 0); + return table[val]; +} + +static void print_hex(unsigned val,char * &out,unsigned bytes) +{ + unsigned n; + for(n=0;n> ((bytes - 1 - n) << 3)) & 0xFF); + *(out++) = print_hex_digit( c >> 4 ); + *(out++) = print_hex_digit( c & 0xF ); + } + *out = 0; +} + + +pfc::string8 print_guid(const GUID & p_guid) +{ + char data[64]; + char * out = data; + print_hex(p_guid.Data1,out,4); + *(out++) = '-'; + print_hex(p_guid.Data2,out,2); + *(out++) = '-'; + print_hex(p_guid.Data3,out,2); + *(out++) = '-'; + print_hex(p_guid.Data4[0],out,1); + print_hex(p_guid.Data4[1],out,1); + *(out++) = '-'; + print_hex(p_guid.Data4[2],out,1); + print_hex(p_guid.Data4[3],out,1); + print_hex(p_guid.Data4[4],out,1); + print_hex(p_guid.Data4[5],out,1); + print_hex(p_guid.Data4[6],out,1); + print_hex(p_guid.Data4[7],out,1); + *out = 0; + return data; +} + + +void print_hex_raw(const void * buffer,unsigned bytes,char * p_out) +{ + char * out = p_out; + const unsigned char * in = (const unsigned char *) buffer; + unsigned n; + for(n=0;n inline int compare_t(const GUID & p_item1,const GUID & p_item2) {return guid_compare(p_item1,p_item2);} + + static constexpr GUID guid_null = {}; + + void print_hex_raw(const void * buffer,unsigned bytes,char * p_out); + + inline GUID makeGUID(t_uint32 Data1, t_uint16 Data2, t_uint16 Data3, t_uint8 Data4_1, t_uint8 Data4_2, t_uint8 Data4_3, t_uint8 Data4_4, t_uint8 Data4_5, t_uint8 Data4_6, t_uint8 Data4_7, t_uint8 Data4_8) { + GUID guid = { Data1, Data2, Data3, {Data4_1, Data4_2, Data4_3, Data4_4, Data4_5, Data4_6, Data4_7, Data4_8 } }; + return guid; + } + inline GUID xorGUID(const GUID & v1, const GUID & v2) { + GUID temp; memxor(&temp, &v1, &v2, sizeof(GUID)); return temp; + } + + string8 format_guid_cpp( const GUID & ); + string8 print_guid( const GUID & ); + + GUID createGUID(); + uint64_t halveGUID( const GUID & ); + + struct predicateGUID { + inline bool operator() ( const GUID & v1, const GUID & v2 ) const {return guid_compare(v1, v2) > 0;} + }; + +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/instance_tracker_legacy.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/instance_tracker_legacy.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,51 @@ +#pragma once +// OBSOLETE, DO NOT USE +namespace pfc { + template + class instance_tracker_server_t { + public: + void add(t_object * p_object) { + m_list.add_item(p_object); + } + void remove(t_object * p_object) { + m_list.remove_item(p_object); + } + + t_size get_count() const {return m_list.get_count();} + t_object * get_item(t_size p_index) {return m_list[p_index];} + t_object * operator[](t_size p_index) {return m_list[p_index];} + + private: + ptr_list_hybrid_t m_list; + }; + + + template & p_server> + class instance_tracker_client_t { + public: + instance_tracker_client_t(t_object* p_ptr) : m_ptr(NULL), m_added(false) {initialize(p_ptr);} + instance_tracker_client_t() : m_ptr(NULL), m_added(false) {} + + void initialize(t_object * p_ptr) { + uninitialize(); + p_server.add(p_ptr); + m_ptr = p_ptr; + m_added = true; + } + + void uninitialize() { + if (m_added) { + p_server.remove(m_ptr); + m_ptr = NULL; + m_added = false; + } + } + + ~instance_tracker_client_t() { + uninitialize(); + } + private: + bool m_added; + t_object * m_ptr; + }; +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/int_types.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/int_types.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,96 @@ +#pragma once + +#include +typedef int64_t t_int64; +typedef uint64_t t_uint64; +typedef int32_t t_int32; +typedef uint32_t t_uint32; +typedef int16_t t_int16; +typedef uint16_t t_uint16; +typedef int8_t t_int8; +typedef uint8_t t_uint8; + +typedef int t_int; +typedef unsigned int t_uint; + +typedef float t_float32; +typedef double t_float64; + + + +namespace pfc { + template + class sized_int_t; + + template<> class sized_int_t<1> { + public: + typedef t_uint8 t_unsigned; + typedef t_int8 t_signed; + }; + + template<> class sized_int_t<2> { + public: + typedef t_uint16 t_unsigned; + typedef t_int16 t_signed; + }; + + template<> class sized_int_t<4> { + public: + typedef t_uint32 t_unsigned; + typedef t_int32 t_signed; + }; + + template<> class sized_int_t<8> { + public: + typedef t_uint64 t_unsigned; + typedef t_int64 t_signed; + }; +} + +typedef size_t t_size; +typedef pfc::sized_int_t< sizeof(size_t) >::t_signed t_ssize; + + +inline t_size MulDiv_Size(t_size x,t_size y,t_size z) {return (t_size) ( ((t_uint64)x * (t_uint64)y) / (t_uint64)z );} + +// Use of this is *discouraged*, define provided for backwards compat +#define pfc_infinite (~0) + +namespace pfc { + const t_uint16 infinite16 = (t_uint16)(~0); + const t_uint32 infinite32 = (t_uint32)(~0); + const t_uint64 infinite64 = (t_uint64)(~0); + const t_size infinite_size = (t_size)(~0); + + template class int_specs_t; + + template + class int_specs_signed_t { + public: + inline static T get_min() {return ((T)1<<(sizeof(T)*8-1));} + inline static T get_max() {return ~((T)1<<(sizeof(T)*8-1));} + enum {is_signed = true}; + }; + + template + class int_specs_unsigned_t { + public: + inline static T get_min() {return (T)0;} + inline static T get_max() {return (T)~0;} + enum {is_signed = false}; + }; + + template<> class int_specs_t : public int_specs_signed_t {}; + template<> class int_specs_t : public int_specs_unsigned_t {}; + template<> class int_specs_t : public int_specs_signed_t {}; + template<> class int_specs_t : public int_specs_unsigned_t {}; + template<> class int_specs_t : public int_specs_signed_t {}; + template<> class int_specs_t : public int_specs_unsigned_t {}; + template<> class int_specs_t : public int_specs_signed_t {}; + template<> class int_specs_t : public int_specs_unsigned_t {}; + template<> class int_specs_t : public int_specs_signed_t {}; + template<> class int_specs_t : public int_specs_unsigned_t {}; + + template<> class int_specs_t : public int_specs_unsigned_t {}; + +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/iterators.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/iterators.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,199 @@ +#pragma once +#include "ref_counter.h" + +namespace pfc { + //! Base class for list nodes. Implemented by list implementers. + template class _list_node : public refcounted_object_root { + public: + typedef _list_node t_self; + + template _list_node(arg_t && ... arg) : m_content( std::forward(arg) ...) {} + + t_item m_content; + + virtual t_self * prev() throw() {return NULL;} + virtual t_self * next() throw() {return NULL;} + + t_self * walk(bool forward) throw() {return forward ? next() : prev();} + }; + + template class const_iterator { + public: + typedef _list_node t_node; + typedef refcounted_object_ptr_t t_nodeptr; + typedef const_iterator t_self; + + bool is_empty() const throw() {return m_content.is_empty();} + bool is_valid() const throw() {return m_content.is_valid();} + void invalidate() throw() {m_content = NULL;} + + void walk(bool forward) throw() {m_content = m_content->walk(forward);} + void prev() throw() {m_content = m_content->prev();} + void next() throw() {m_content = m_content->next();} + + //! For internal use / list implementations only! Do not call! + t_node* _node() const throw() {return m_content.get_ptr();} + + const_iterator() {} + const_iterator(t_node* source) : m_content(source) {} + const_iterator(t_nodeptr const & source) : m_content(source) {} + const_iterator(t_self const & other) : m_content(other.m_content) {} + const_iterator(t_self && other) : m_content(std::move(other.m_content)) {} + + t_self const & operator=(t_self const & other) {m_content = other.m_content; return *this;} + t_self const & operator=(t_self && other) {m_content = std::move(other.m_content); return *this;} + + const t_item& operator*() const throw() {return m_content->m_content;} + const t_item* operator->() const throw() {return &m_content->m_content;} + + const t_self & operator++() throw() {this->next(); return *this;} + const t_self & operator--() throw() {this->prev(); return *this;} + t_self operator++(int) throw() {t_self old = *this; this->next(); return old;} + t_self operator--(int) throw() {t_self old = *this; this->prev(); return old;} + + bool operator==(const t_self & other) const throw() {return this->m_content == other.m_content;} + bool operator!=(const t_self & other) const throw() {return this->m_content != other.m_content;} + + // Returns pointer to referenced item - null if iterator isn't valid + const t_item* get() const noexcept { return this->m_content.is_valid() ? &this->m_content->m_content : nullptr; } + protected: + t_nodeptr m_content; + }; + template class iterator : public const_iterator { + public: + typedef const_iterator t_selfConst; + typedef iterator t_self; + typedef _list_node t_node; + typedef refcounted_object_ptr_t t_nodeptr; + + iterator() {} + iterator(t_node* source) : t_selfConst(source) {} + iterator(t_nodeptr const & source) : t_selfConst(source) {} + iterator(t_self const & other) : t_selfConst(other) {} + iterator(t_self && other) : t_selfConst(std::move(other)) {} + + t_self const & operator=(t_self const & other) {this->m_content = other.m_content; return *this;} + t_self const & operator=(t_self && other) {this->m_content = std::move(other.m_content); return *this;} + + t_item& operator*() const throw() {return this->m_content->m_content;} + t_item* operator->() const throw() {return &this->m_content->m_content;} + + const t_self & operator++() throw() {this->next(); return *this;} + const t_self & operator--() throw() {this->prev(); return *this;} + t_self operator++(int) throw() {t_self old = *this; this->next(); return old;} + t_self operator--(int) throw() {t_self old = *this; this->prev(); return old;} + + bool operator==(const t_self & other) const throw() {return this->m_content == other.m_content;} + bool operator!=(const t_self & other) const throw() {return this->m_content != other.m_content;} + + // Returns pointer to referenced item - null if iterator isn't valid + t_item* get() const noexcept { return this->m_content.is_valid() ? &this->m_content->m_content : nullptr; } + }; + + template class forward_iterator { + iterator m_iter; + public: + typedef forward_iterator self_t; + void operator++() { ++m_iter; } + + item_t& operator*() const throw() { return *m_iter; } + item_t* operator->() const throw() { return &*m_iter; } + + bool operator==(const self_t& other) const { return m_iter == other.m_iter; } + bool operator!=(const self_t& other) const { return m_iter != other.m_iter; } + + forward_iterator() {} + forward_iterator(iterator&& i) : m_iter(std::move(i)) {} + }; + + + template class forward_const_iterator { + const_iterator m_iter; + public: + typedef forward_const_iterator self_t; + void operator++() { ++m_iter; } + + const item_t& operator*() const throw() { return *m_iter; } + const item_t* operator->() const throw() { return &*m_iter; } + + bool operator==(const self_t& other) const { return m_iter == other.m_iter; } + bool operator!=(const self_t& other) const { return m_iter != other.m_iter; } + + forward_const_iterator() {} + forward_const_iterator(const_iterator&& i) : m_iter(std::move(i)) {} + }; + + template + class comparator_list { + public: + template + static int compare(const t_list1 & p_list1, const t_list2 & p_list2) { + typename t_list1::const_iterator iter1 = p_list1.first(); + typename t_list2::const_iterator iter2 = p_list2.first(); + for(;;) { + if (iter1.is_empty() && iter2.is_empty()) return 0; + else if (iter1.is_empty()) return -1; + else if (iter2.is_empty()) return 1; + else { + int state = t_comparator::compare(*iter1,*iter2); + if (state != 0) return state; + } + ++iter1; ++iter2; + } + } + }; + + template + static bool listEquals(const t_list1 & p_list1, const t_list2 & p_list2) { + typename t_list1::const_iterator iter1 = p_list1.first(); + typename t_list2::const_iterator iter2 = p_list2.first(); + for(;;) { + if (iter1.is_empty() && iter2.is_empty()) return true; + else if (iter1.is_empty() || iter2.is_empty()) return false; + else if (*iter1 != *iter2) return false; + ++iter1; ++iter2; + } + } + + template + class comparator_stdlist { + public: + template + static int compare(const t_list1 & p_list1, const t_list2 & p_list2) { + auto iter1 = p_list1.begin(); + auto iter2 = p_list2.begin(); + for(;;) { + const bool end1 = iter1 == p_list1.end(); + const bool end2 = iter2 == p_list2.end(); + if ( end1 && end2 ) return 0; + else if ( end1 ) return -1; + else if ( end2 ) return 1; + else { + int state = comparator_t::compare(*iter1,*iter2); + if (state != 0) return state; + } + ++iter1; ++iter2; + } + } + }; +} + +namespace std { + + template + struct iterator_traits< pfc::forward_iterator< item_t > > { + typedef ptrdiff_t difference_type; + typedef item_t value_type; + typedef value_type* pointer; + typedef value_type& reference; + typedef std::forward_iterator_tag iterator_category; + }; + template + struct iterator_traits< pfc::forward_const_iterator< item_t > > { + typedef ptrdiff_t difference_type; + typedef item_t value_type; + typedef const value_type* pointer; + typedef const value_type& reference; + typedef std::forward_iterator_tag iterator_category; + }; +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/killswitch.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/killswitch.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,32 @@ +#pragma once + +#include + +namespace pfc { + struct killSwitchData_t { + killSwitchData_t() : m_val() {} + volatile bool m_val; + }; + + + typedef std::shared_ptr killSwitchRef_t; + + class killSwitchRef { + public: + killSwitchRef( killSwitchRef_t ks ) : m_ks(ks) {} + + operator bool () const { + return m_ks->m_val; + } + + void set(bool val = true) { + m_ks->m_val = val; + } + private: + killSwitchRef_t m_ks; + }; + + killSwitchRef killSwitchMake() { + return std::make_shared(); + } +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/list.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/list.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,722 @@ +#pragma once +#include "bsearch.h" +#include "sort.h" +#include "primitives.h" +#include "traits.h" +#include "bit_array.h" +#include "bit_array_impl.h" +#include "order_helper.h" +#include "array.h" + +#include + +namespace pfc { + template + class list_const_iterator { + typedef list_const_iterator self_t; + public: + typedef ptrdiff_t difference_type; + typedef typename arr_t::t_item value_type; + typedef const value_type* pointer; + typedef const value_type& reference; + typedef std::random_access_iterator_tag iterator_category; + + list_const_iterator(arr_t* arr, size_t index) : m_arr(arr), m_index(index) {} + void operator++() { ++m_index; } + void operator--() { --m_index; } + value_type operator*() const { return m_arr->get_item(m_index); } + + bool operator==(const self_t& other) const { PFC_ASSERT(m_arr == other.m_arr); return m_index == other.m_index; } + bool operator!=(const self_t& other) const { PFC_ASSERT(m_arr == other.m_arr); return m_index != other.m_index; } + bool operator>(const self_t& other) const { PFC_ASSERT(m_arr == other.m_arr); return m_index > other.m_index; } + bool operator<(const self_t& other) const { PFC_ASSERT(m_arr == other.m_arr); return m_index < other.m_index; } + bool operator>=(const self_t& other) const { PFC_ASSERT(m_arr == other.m_arr); return m_index >= other.m_index; } + bool operator<=(const self_t& other) const { PFC_ASSERT(m_arr == other.m_arr); return m_index <= other.m_index; } + + void operator+=(size_t v) { m_index += v; } + self_t operator+(size_t v) { self_t ret = *this; ret += v; return ret; } + difference_type operator-(self_t const& other) const { PFC_ASSERT(m_arr == other.m_arr); return m_index - other.m_index; } + void operator-=(size_t v) { m_index -= v; } + private: + arr_t* m_arr; + size_t m_index; + }; +} + +namespace std { + template struct iterator_traits< pfc::list_const_iterator > { + typedef ptrdiff_t difference_type; + typedef typename arr_t::t_item value_type; + typedef value_type* pointer; + typedef value_type& reference; + typedef std::random_access_iterator_tag iterator_category; + }; +} + +namespace pfc { + +template +class NOVTABLE list_base_const_t { +private: typedef list_base_const_t t_self; +public: + typedef T t_item; + virtual t_size get_count() const = 0; + virtual void get_item_ex(T& p_out, t_size n) const = 0; + + inline t_size get_size() const {return get_count();} + inline size_t size() const { return get_count(); } + + inline T get_item(t_size n) const {T temp; get_item_ex(temp,n); return temp;} + inline T operator[](t_size n) const {T temp; get_item_ex(temp,n); return temp;} + + template + t_size find_duplicates_sorted_t(t_compare p_compare,bit_array_var & p_out) const + { + return ::pfc::find_duplicates_sorted_t const &,t_compare>(*this,get_count(),p_compare,p_out); + } + + template + t_size find_duplicates_sorted_permutation_t(t_compare p_compare,t_permutation const & p_permutation,bit_array_var & p_out) + { + return ::pfc::find_duplicates_sorted_permutation_t const &,t_compare,t_permutation>(*this,get_count(),p_compare,p_permutation,p_out); + } + + template + t_size find_item(const t_search & p_item) const//returns index of first occurance, infinite if not found + { + t_size n,max = get_count(); + for(n=0;n + inline bool have_item(const t_search & p_item) const {return find_item(p_item)!=SIZE_MAX;} + + + template + bool bsearch_t(t_compare p_compare,t_param const & p_param,t_size &p_index) const { + return ::pfc::bsearch_t(get_count(),*this,p_compare,p_param,p_index); + } + + template + bool bsearch_permutation_t(t_compare p_compare,t_param const & p_param,const t_permutation & p_permutation,t_size & p_index) const { + return ::pfc::bsearch_permutation_t(get_count(),*this,p_compare,p_param,p_permutation,p_index); + } + + template + void sort_get_permutation_t(t_compare p_compare,t_permutation const & p_permutation) const { + ::pfc::sort_get_permutation_t,t_compare,t_permutation>(*this,p_compare,get_count(),p_permutation); + } + + template + void sort_stable_get_permutation_t(t_compare p_compare,t_permutation const & p_permutation) const { + ::pfc::sort_stable_get_permutation_t,t_compare,t_permutation>(*this,p_compare,get_count(),p_permutation); + } + + template + void enumerate(t_callback & p_callback) const { + for(t_size n = 0, m = get_count(); n < m; ++n ) { + p_callback( (*this)[n] ); + } + } + + static bool g_equals(const t_self & item1, const t_self & item2) { + const t_size count = item1.get_count(); + if (count != item2.get_count()) return false; + for(t_size walk = 0; walk < count; ++walk) if (item1[walk] != item2[walk]) return false; + return true; + } + bool operator==(const t_self & item2) const {return g_equals(*this,item2);} + bool operator!=(const t_self & item2) const {return !g_equals(*this,item2);} + + typedef list_const_iterator< const t_self > iterator; + typedef iterator const_iterator; + + iterator begin() const { return iterator(this, 0); } + iterator end() const { return iterator(this, get_count()); } +protected: + list_base_const_t() {} + ~list_base_const_t() {} + + list_base_const_t(const t_self &) {} + void operator=(const t_self &) {} + +}; + + +template +class list_single_ref_t : public list_base_const_t +{ +public: + list_single_ref_t(const T & p_item,t_size p_count = 1) : m_item(p_item), m_count(p_count) {} + t_size get_count() const {return m_count;} + void get_item_ex(T& p_out, t_size n) const { PFC_ASSERT(n < m_count); (void)n; p_out = m_item; } +private: + const T & m_item; + t_size m_count; +}; + +template +inline list_single_ref_t list_single(item_t const& i, size_t n = 1) { return list_single_ref_t(i, n); } + +template +class list_partial_ref_t : public list_base_const_t +{ +public: + list_partial_ref_t(const list_base_const_t & p_list,t_size p_base,t_size p_count) + : m_list(p_list), m_base(p_base), m_count(p_count) + { + PFC_ASSERT(m_base + m_count <= m_list.get_count()); + } + +private: + const list_base_const_t & m_list; + t_size m_base,m_count; + + t_size get_count() const {return m_count;} + void get_item_ex(T & p_out,t_size n) const {m_list.get_item_ex(p_out,n+m_base);} +}; + +template +class list_const_array_t : public list_base_const_t +{ +public: + inline list_const_array_t(A p_data,t_size p_count) : m_data(p_data), m_count(p_count) {} + t_size get_count() const {return m_count;} + void get_item_ex(T & p_out,t_size n) const {p_out = m_data[n];} +private: + A m_data; + t_size m_count; +}; +template +class list_const_array_ref_t : public list_base_const_t { +public: + list_const_array_ref_t(const t_array & data) : m_data(data) {} + t_size get_count() const {return m_data.get_size();} + void get_item_ex(typename t_array::t_item & out, t_size n) const {out = m_data[n];} +private: + const t_array & m_data; +}; + +template +class list_const_cast_t : public list_base_const_t +{ +public: + list_const_cast_t(const list_base_const_t & p_from) : m_from(p_from) {} + t_size get_count() const {return m_from.get_count();} + void get_item_ex(to & p_out,t_size n) const + { + from temp; + m_from.get_item_ex(temp,n); + p_out = temp; + } +private: + const list_base_const_t & m_from; +}; + +template +class ptr_list_const_array_t : public list_base_const_t +{ +public: + inline ptr_list_const_array_t(A p_data,t_size p_count) : m_data(p_data), m_count(p_count) {} + t_size get_count() const {return m_count;} + void get_item_ex(T* & p_out,t_size n) const {p_out = &m_data[n];} +private: + A m_data; + t_size m_count; +}; +template +class list_const_ptr_t : public list_base_const_t +{ +public: + inline list_const_ptr_t(const T * p_data,t_size p_count) : m_data(p_data), m_count(p_count) {} + t_size get_count() const {return m_count;} + void get_item_ex(T & p_out,t_size n) const {p_out = m_data[n];} +private: + const T * m_data; + t_size m_count; +}; + +template +class NOVTABLE list_base_t : public list_base_const_t { +private: + typedef list_base_t t_self; + typedef const list_base_const_t t_self_const; +public: + class NOVTABLE sort_callback + { + public: + virtual int compare(const T& p_item1,const T& p_item2) = 0; + }; + + virtual void filter_mask(const bit_array & mask) = 0; + virtual t_size insert_items(const list_base_const_t & items,t_size base) = 0; + virtual void reorder_partial(t_size p_base,const t_size * p_data,t_size p_count) = 0; + virtual void sort(sort_callback & p_callback) = 0; + virtual void sort_stable(sort_callback & p_callback) = 0; + virtual void replace_item(t_size p_index,const T& p_item) = 0; + virtual void swap_item_with(t_size p_index,T & p_item) = 0; + virtual void swap_items(t_size p_index1,t_size p_index2) = 0; + + inline void reorder(const t_size * p_data) {reorder_partial(0,p_data,this->get_count());} + + inline t_size insert_item(const T & item,t_size base) {return insert_items(list_single_ref_t(item),base);} + t_size insert_items_repeat(const T & item,t_size num,t_size base) {return insert_items(list_single_ref_t(item,num),base);} + inline t_size add_items_repeat(T item,t_size num) {return insert_items_repeat(item,num,SIZE_MAX);} + t_size insert_items_fromptr(const T* source,t_size num,t_size base) {return insert_items(list_const_ptr_t(source,num),base);} + inline t_size add_items_fromptr(const T* source,t_size num) {return insert_items_fromptr(source,num,SIZE_MAX);} + + inline t_size add_items(const list_base_const_t & items) {return insert_items(items,SIZE_MAX);} + inline t_size add_item(const T& item) {return insert_item(item,SIZE_MAX);} + + inline void remove_mask(const bit_array & mask) {filter_mask(bit_array_not(mask));} + inline void remove_all() {filter_mask(bit_array_false());} + inline void truncate(t_size val) {if (val < this->get_count()) remove_mask(bit_array_range(val,this->get_count()-val,true));} + + inline T replace_item_ex(t_size p_index,const T & p_item) {T ret = p_item;swap_item_with(p_index,ret);return ret;} + + inline T operator[](t_size n) const {return this->get_item(n);} + + template + class sort_callback_impl_t : public sort_callback + { + public: + sort_callback_impl_t(t_compare p_compare) : m_compare(p_compare) {} + int compare(const T& p_item1,const T& p_item2) {return m_compare(p_item1,p_item2);} + private: + t_compare m_compare; + }; + + class sort_callback_auto : public sort_callback + { + public: + int compare(const T& p_item1,const T& p_item2) {return ::pfc::compare_t(p_item1,p_item2);} + }; + + void sort() {sort_callback_auto cb;sort(cb);} + template void sort_t(t_compare p_compare) {sort_callback_impl_t cb(p_compare);sort(cb);} + template void sort_stable_t(t_compare p_compare) {sort_callback_impl_t cb(p_compare); sort_stable(cb);} + + template void sort_remove_duplicates_t(t_compare p_compare) + { + sort_t(p_compare); + bit_array_bittable array(this->get_count()); + if (this->template find_duplicates_sorted_t(p_compare,array) > 0) + remove_mask(array); + } + + template void sort_stable_remove_duplicates_t(t_compare p_compare) + { + sort_stable_t(p_compare); + bit_array_bittable array(this->get_count()); + if (this->template find_duplicates_sorted_t(p_compare,array) > 0) + remove_mask(array); + } + + + template void remove_duplicates_t(t_compare p_compare) + { + order_helper order(this->get_count()); + sort_get_permutation_t(p_compare,order); + bit_array_bittable array(this->get_count()); + if (this->template find_duplicates_sorted_permutation_t(p_compare,order,array) > 0) + remove_mask(array); + } + + template + void for_each(t_func p_func) { + t_size n,max=this->get_count(); + for(n=0;nget_item(n)); + } + + template + void for_each(t_func p_func,const bit_array & p_mask) { + t_size n,max=this->get_count(); + for(n=p_mask.find(true,0,max);nget_item(n)); + } + } + + template + void remove_mask_ex(const bit_array & p_mask,t_releasefunc p_func) { + this->template for_each(p_func,p_mask); + remove_mask(p_mask); + } + + template + void remove_all_ex(t_releasefunc p_func) { + this->template for_each(p_func); + remove_all(); + } + + template t_self & operator=(t_in const & source) {remove_all(); add_items(source); return *this;} + template t_self & operator+=(t_in const & p_source) {add_item(p_source); return *this;} + template t_self & operator|=(t_in const & p_source) {add_items(p_source); return *this;} + +protected: + list_base_t() {} + ~list_base_t() {} + list_base_t(const t_self&) {} + void operator=(const t_self&) {} +}; + + +template +class list_impl_t : public list_base_t +{ +public: + typedef list_base_t t_base; + typedef list_impl_t t_self; + list_impl_t() {} + list_impl_t(const t_self & p_source) { add_items(p_source); } + + void copy(const t_self& p_source) { m_buffer = p_source.m_buffer; } + void move(t_self& p_source) { m_buffer = std::move(p_source.m_buffer); } + + void prealloc(t_size count) {m_buffer.prealloc(count);} + + void set_count(t_size p_count) {m_buffer.set_size(p_count);} + void set_size(t_size p_count) {m_buffer.set_size(p_count);} + + template + t_size _insert_item_t(const t_in & item, t_size idx) { + return ::pfc::insert_t(m_buffer, item, idx); + } + template + t_size insert_item(const t_in & item, t_size idx) { + return _insert_item_t(item, idx); + } + + t_size insert_item(const T& item,t_size idx) { + return _insert_item_t(item, idx); + } + + T remove_by_idx(t_size idx) + { + T ret = std::move(m_buffer[idx]); + t_size n; + t_size max = m_buffer.get_size(); + for(n=idx+1;n=0); + PFC_ASSERT(n=0); + PFC_ASSERT(n= 0); + PFC_ASSERT(n < get_size() ); + return m_buffer[n]; + }; + + inline t_size get_count() const {return m_buffer.get_size();} + inline t_size get_size() const {return m_buffer.get_size();} + inline size_t size() const { return m_buffer.get_size(); } + + inline const T & operator[](t_size n) const + { + PFC_ASSERT(n>=0); + PFC_ASSERT(n & source,t_size base) { //workaround for inefficient operator[] on virtual-interface-accessed lists + t_size count = get_size(); + if (base>count) base = count; + t_size num = source.get_count(); + m_buffer.set_size(count+num); + if (count > base) { + for(t_size n=count-1;(int)n>=(int)base;n--) { + ::pfc::move_t(m_buffer[n+num],m_buffer[n]); + } + } + + for(t_size n=0;n & source,t_size base) {return _insert_items_v(source, base);} + t_size insert_items(const list_base_t & source,t_size base) {return _insert_items_v(source, base);} + + template + t_size insert_items(const t_in & source,t_size base) { + t_size count = get_size(); + if (base>count) base = count; + t_size num = array_size_t(source); + m_buffer.set_size(count+num); + if (count > base) { + for(t_size n=count-1;(int)n>=(int)base;n--) { + ::pfc::move_t(m_buffer[n+num],m_buffer[n]); + } + } + + for(t_size n=0;n + void add_items(const t_in & in) {insert_items(in, SIZE_MAX);} + + void get_items_mask(list_impl_t & out,const bit_array & mask) + { + mask.walk( get_size(), [&] (size_t n) { + out.add_item(m_buffer[n]); + } ); + } + + void filter_mask(const bit_array & mask) + { + t_size n,count = get_size(), total = 0; + + n = total = mask.find(false,0,count); + + if (n=0); + PFC_ASSERT(idx wrapper(m_buffer); + ::pfc::sort(wrapper,get_size()); + } + + template + void sort_t(t_compare p_compare) + { + ::pfc::sort_callback_impl_simple_wrap_t wrapper(m_buffer,p_compare); + ::pfc::sort(wrapper,get_size()); + } + + template + void sort_stable_t(t_compare p_compare) + { + ::pfc::sort_callback_impl_simple_wrap_t wrapper(m_buffer,p_compare); + ::pfc::sort_stable(wrapper,get_size()); + } + inline void reorder_partial(t_size p_base,const t_size * p_order,t_size p_count) + { + PFC_ASSERT(p_base+p_count<=get_size()); + ::pfc::reorder_partial_t(m_buffer,p_base,p_order,p_count); + } + + template + t_size find_duplicates_sorted_t(t_compare p_compare,bit_array_var & p_out) const + { + return ::pfc::find_duplicates_sorted_t const &,t_compare>(*this,get_size(),p_compare,p_out); + } + + template + t_size find_duplicates_sorted_permutation_t(t_compare p_compare,t_permutation p_permutation,bit_array_var & p_out) + { + return ::pfc::find_duplicates_sorted_permutation_t const &,t_compare,t_permutation>(*this,get_size(),p_compare,p_permutation,p_out); + } + + + void move_from(t_self & other) { + remove_all(); + m_buffer = std::move(other.m_buffer); + } + + T* begin() { return m_buffer.get_ptr(); } + T* end() { return m_buffer.get_ptr() + get_size(); } + const T* begin() const { return m_buffer.get_ptr(); } + const T* end() const { return m_buffer.get_ptr() + get_size(); } + +private: + class sort_callback_wrapper + { + public: + explicit inline sort_callback_wrapper(typename t_base::sort_callback & p_callback) : m_callback(p_callback) {} + inline int operator()(const T& item1,const T& item2) const {return m_callback.compare(item1,item2);} + private: + typename t_base::sort_callback & m_callback; + }; +public: + void sort(typename t_base::sort_callback & p_callback) + { + sort_t(sort_callback_wrapper(p_callback)); + } + + void sort_stable(typename t_base::sort_callback & p_callback) + { + sort_stable_t(sort_callback_wrapper(p_callback)); + } + + void remove_mask(const bit_array & mask) {filter_mask(bit_array_not(mask));} + + void remove_mask(const bool * mask) {remove_mask(bit_array_table(mask,get_size()));} + void filter_mask(const bool * mask) {filter_mask(bit_array_table(mask,get_size()));} + + size_t add_item(const T& item) { + return pfc::append_t(m_buffer, item); + } + + size_t add_item(T&& item) { + return pfc::append_t(m_buffer, std::move(item)); + } + + template t_size add_item(const t_in & item) { + return pfc::append_t(m_buffer, item); + } + + void remove_all() {remove_mask(bit_array_true());} + + void remove_item(const T& item) + { + t_size n,max = get_size(); + bit_array_bittable mask(max); + for(n=0;n & p_item1,list_impl_t & p_item2) + { + swap_t(p_item1.m_buffer,p_item2.m_buffer); + } + + template + t_size find_item(const t_search & p_item) const//returns index of first occurance, infinite if not found + { + t_size n,max = get_size(); + for(n=0;n + inline bool have_item(const t_search & p_item) const {return this->template find_item(p_item)!=SIZE_MAX;} + + template t_self & operator=(t_in const & source) {remove_all(); add_items(source); return *this;} + template t_self & operator+=(t_in const & p_source) {add_item(p_source); return *this;} + template t_self & operator|=(t_in const & p_source) {add_items(p_source); return *this;} +protected: + t_storage m_buffer; +}; + +template class t_alloc = alloc_fast > +class list_t : public list_impl_t > { +public: + typedef list_t t_self; + template const t_self & operator=(t_in const & source) {this->remove_all(); this->add_items(source); return *this;} + template const t_self & operator+=(t_in const & p_source) {this->add_item(p_source); return *this;} + template const t_self & operator|=(t_in const & p_source) {this->add_items(p_source); return *this;} + + const t_self& operator=(t_self const& other) { this->copy(other); return *this; } + const t_self& operator=(t_self&& other) { this->move(other); return *this; } + + list_t() {} + list_t(t_self const& other) { this->copy(other); } + list_t(t_self&& other) { this->move(other); } +}; + +template class t_alloc = alloc_fast > +class list_hybrid_t : public list_impl_t > { +public: + typedef list_hybrid_t t_self; + template t_self & operator=(t_in const & source) {this->remove_all(); this->add_items(source); return *this;} + template t_self & operator+=(t_in const & p_source) {this->add_item(p_source); return *this;} + template t_self & operator|=(t_in const & p_source) {this->add_items(p_source); return *this;} +}; + +template +class ptr_list_const_cast_t : public list_base_const_t +{ +public: + inline ptr_list_const_cast_t(const list_base_const_t & p_param) : m_param(p_param) {} + t_size get_count() const {return m_param.get_count();} + void get_item_ex(const T * & p_out,t_size n) const {T* temp; m_param.get_item_ex(temp,n); p_out = temp;} +private: + const list_base_const_t & m_param; + +}; + + +template +class list_const_permutation_t : public list_base_const_t +{ +public: + inline list_const_permutation_t(const list_base_const_t & p_list,P p_permutation) : m_list(p_list), m_permutation(p_permutation) {} + t_size get_count() const {return m_list.get_count();} + void get_item_ex(T & p_out,t_size n) const {m_list.get_item_ex(p_out,m_permutation[n]);} +private: + P m_permutation; + const list_base_const_t & m_list; +}; + + +template +class list_permutation_t : public list_base_const_t +{ +public: + t_size get_count() const {return m_count;} + void get_item_ex(T & p_out,t_size n) const {m_base.get_item_ex(p_out,m_order[n]);} + list_permutation_t(const list_base_const_t & p_base,const t_size * p_order,t_size p_count) + : m_base(p_base), m_order(p_order), m_count(p_count) + { + PFC_ASSERT(m_base.get_count() >= m_count); + } +private: + const list_base_const_t & m_base; + const t_size * m_order; + t_size m_count; +}; + +template class alloc> class traits_t > : public combine_traits >, traits_vtable> {}; + +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/lockless.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/lockless.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,55 @@ +#pragma once + +#ifdef _MSC_VER +#include +#endif +namespace pfc { + + class threadSafeInt { + public: + typedef long val_t; + typedef val_t t_val; + + threadSafeInt(t_val p_val = 0) : m_val(p_val) {} + long operator++() throw() { return inc(); } + long operator--() throw() { return dec(); } + long operator++(int) throw() { return inc() - 1; } + long operator--(int) throw() { return dec() + 1; } + operator t_val() const throw() { return m_val; } + + static val_t exchangeHere( volatile val_t & here, val_t newVal ) { +#ifdef _MSC_VER + return InterlockedExchange(&here, newVal); +#else + return __sync_lock_test_and_set(&here, newVal); +#endif + } + + t_val exchange(t_val newVal) { + return exchangeHere( m_val, newVal ); + } + private: + t_val inc() { +#ifdef _MSC_VER + return _InterlockedIncrement(&m_val); +#else + return __sync_add_and_fetch(&m_val, 1); +#endif + } + t_val dec() { +#ifdef _MSC_VER + return _InterlockedDecrement(&m_val); +#else + return __sync_sub_and_fetch(&m_val, 1); +#endif + } + + volatile t_val m_val; + }; + + typedef threadSafeInt counter; + typedef threadSafeInt refcounter; + + void yield(); // forward declaration + +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/map.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/map.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,282 @@ +#pragma once +#include "avltree.h" + +namespace pfc { + PFC_DECLARE_EXCEPTION(exception_map_entry_not_found,exception,"Map entry not found"); + + template class __map_overwrite_wrapper { + public: + __map_overwrite_wrapper(t_destination & p_destination) : m_destination(p_destination) {} + template void operator() (const t_key & p_key,const t_value & p_value) {m_destination.set(p_key,p_value);} + private: + t_destination & m_destination; + }; + + template + class map_t { + private: + typedef map_t t_self; + public: + typedef t_storage_key t_key; typedef t_storage_value t_value; + template + void set(const _t_key & p_key, const _t_value & p_value) { + bool isnew; + t_storage & storage = m_data.add_ex(t_search_set<_t_key,_t_value>(p_key,p_value), isnew); + if (!isnew) storage.m_value = p_value; + } + + template + t_storage_value & find_or_add(_t_key const & p_key) { + return m_data.add(t_search_query<_t_key>(p_key)).m_value; + } + + template + t_storage_value & find_or_add_ex(_t_key const & p_key,bool & p_isnew) { + return m_data.add_ex(t_search_query<_t_key>(p_key),p_isnew).m_value; + } + + template + bool have_item(const _t_key & p_key) const { + return m_data.have_item(t_search_query<_t_key>(p_key)); + } + + template + bool contains(key_t const& arg) const { return have_item(arg); } + + template + bool query(const _t_key & p_key,_t_value & p_value) const { + const t_storage * storage = m_data.find_ptr(t_search_query<_t_key>(p_key)); + if (storage == NULL) return false; + p_value = storage->m_value; + return true; + } + + template + const t_storage_value & operator[] (const _t_key & p_key) const { + const t_storage_value * ptr = query_ptr(p_key); + if (ptr == NULL) throw exception_map_entry_not_found(); + return *ptr; + } + + template + t_storage_value & operator[] (const _t_key & p_key) { + return find_or_add(p_key); + } + + template + const t_storage_value * query_ptr(const _t_key & p_key) const { + const t_storage * storage = m_data.find_ptr(t_search_query<_t_key>(p_key)); + if (storage == NULL) return NULL; + return &storage->m_value; + } + + template + t_storage_value * query_ptr(const _t_key & p_key) { + t_storage * storage = m_data.find_ptr(t_search_query<_t_key>(p_key)); + if (storage == NULL) return NULL; + return &storage->m_value; + } + + template + bool query_ptr(const _t_key & p_key, const t_storage_value * & out) const { + const t_storage * storage = m_data.find_ptr(t_search_query<_t_key>(p_key)); + if (storage == NULL) return false; + out = &storage->m_value; + return true; + } + + template + bool query_ptr(const _t_key & p_key, t_storage_value * & out) { + t_storage * storage = m_data.find_ptr(t_search_query<_t_key>(p_key)); + if (storage == NULL) return false; + out = &storage->m_value; + return true; + } + + template + const t_storage_value * query_nearest_ptr(_t_key & p_key) const { + const t_storage * storage = m_data.template find_nearest_item(t_search_query<_t_key>(p_key)); + if (storage == NULL) return NULL; + p_key = storage->m_key; + return &storage->m_value; + } + + template + t_storage_value * query_nearest_ptr(_t_key & p_key) { + t_storage * storage = m_data.template find_nearest_item(t_search_query<_t_key>(p_key)); + if (storage == NULL) return NULL; + p_key = storage->m_key; + return &storage->m_value; + } + + template + bool query_nearest(_t_key & p_key,_t_value & p_value) const { + const t_storage * storage = m_data.template find_nearest_item(t_search_query<_t_key>(p_key)); + if (storage == NULL) return false; + p_key = storage->m_key; + p_value = storage->m_value; + return true; + } + + + template + bool remove(const _t_key & p_key) { + return m_data.remove_item(t_search_query<_t_key>(p_key)); + } + + template + void enumerate(t_callback && p_callback) const { + enumeration_wrapper cb(p_callback); + m_data.enumerate(cb); + } + + template + void enumerate(t_callback && p_callback) { + enumeration_wrapper_var cb(p_callback); + m_data._enumerate_var(cb); + } + + + t_size get_count() const throw() {return m_data.get_count();} + size_t size() const throw() { return get_count(); } + + void remove_all() throw() {m_data.remove_all();} + void clear() throw() { remove_all(); } + + template + void overwrite(const t_source & p_source) { + __map_overwrite_wrapper wrapper(*this); + p_source.enumerate(wrapper); + } + + //backwards compatibility method wrappers + template bool exists(const _t_key & p_key) const {return have_item(p_key);} + + + template bool get_first(_t_key & p_out) const { + t_retrieve_key<_t_key> wrap(p_out); + return m_data.get_first(wrap); + } + + template bool get_last(_t_key & p_out) const { + t_retrieve_key<_t_key> wrap(p_out); + return m_data.get_last(wrap); + } + + + map_t() {} + map_t( const t_self & other ) : m_data( other.m_data ) {} + map_t( t_self && other ) : m_data( std::move(other.m_data) ) {} + const t_self & operator=( const t_self & other ) {m_data = other.m_data; return *this;} + const t_self & operator=( t_self && other ) { m_data = std::move(other.m_data); return *this; } + + void move_from(t_self & other) { + m_data.move_from( other.m_data ); + } + + private: + template + struct t_retrieve_key { + typedef t_retrieve_key<_t_key> t_self; + t_retrieve_key(_t_key & p_key) : m_key(p_key) {} + template const t_self & operator=(const t_what & p_what) {m_key = p_what.m_key; return *this;} + _t_key & m_key; + }; + template + struct t_search_query { + t_search_query(const _t_key & p_key) : m_key(p_key) {} + _t_key const & m_key; + }; + template + struct t_search_set { + t_search_set(const _t_key & p_key, const _t_value & p_value) : m_key(p_key), m_value(p_value) {} + + _t_key const & m_key; + _t_value const & m_value; + }; + + struct t_storage { + const t_storage_key m_key; + t_storage_value m_value; + + template + t_storage(t_search_query<_t_key> const & p_source) : m_key(p_source.m_key), m_value() {} + + template + t_storage(t_search_set<_t_key,_t_value> const & p_source) : m_key(p_source.m_key), m_value(p_source.m_value) {} + + static bool equals(const t_storage & v1, const t_storage & v2) {return v1.m_key == v2.m_key && v1.m_value == v2.m_value;} + bool operator==(const t_storage & other) const {return equals(*this,other);} + bool operator!=(const t_storage & other) const {return !equals(*this,other);} + }; + + class comparator_wrapper { + public: + template + inline static int compare(const t1 & p_item1,const t2 & p_item2) { + return t_comparator::compare(p_item1.m_key,p_item2.m_key); + } + }; + + template + class enumeration_wrapper { + public: + enumeration_wrapper(t_callback & p_callback) : m_callback(p_callback) {} + void operator()(const t_storage & p_item) {m_callback(p_item.m_key,p_item.m_value);} + private: + t_callback & m_callback; + }; + + template + class enumeration_wrapper_var { + public: + enumeration_wrapper_var(t_callback & p_callback) : m_callback(p_callback) {} + void operator()(t_storage & p_item) {m_callback(implicit_cast(p_item.m_key),p_item.m_value);} + private: + t_callback & m_callback; + }; + + typedef avltree_t t_content; + + t_content m_data; + public: + typedef traits_t traits; + typedef typename t_content::const_iterator const_iterator; + typedef typename t_content::iterator iterator; + + typedef typename t_content::forward_iterator forward_iterator; + typedef typename t_content::forward_const_iterator forward_const_iterator; + + iterator first() throw() {return m_data._first_var();} + iterator last() throw() {return m_data._last_var();} + const_iterator first() const throw() {return m_data.first();} + const_iterator last() const throw() {return m_data.last();} + const_iterator cfirst() const throw() {return m_data.first();} + const_iterator clast() const throw() {return m_data.last();} + + forward_iterator begin() { return first(); } + forward_const_iterator begin() const { return first(); } + forward_iterator end() { return forward_iterator(); } + forward_const_iterator end() const { return forward_const_iterator(); } + + template iterator find(const _t_key & key) {return m_data.find(t_search_query<_t_key>(key));} + template const_iterator find(const _t_key & key) const {return m_data.find(t_search_query<_t_key>(key));} + + static bool equals(const t_self & v1, const t_self & v2) { + return t_content::equals(v1.m_data,v2.m_data); + } + bool operator==(const t_self & other) const {return equals(*this,other);} + bool operator!=(const t_self & other) const {return !equals(*this,other);} + + bool remove(iterator const& iter) { + PFC_ASSERT(iter.is_valid()); + return m_data.remove(iter); + //should never return false unless there's a bug in calling code + } + bool remove(const_iterator const& iter) { + PFC_ASSERT(iter.is_valid()); + return m_data.remove(iter); + //should never return false unless there's a bug in calling code + } + }; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/mem_block.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/mem_block.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,56 @@ +#pragma once + +namespace pfc { + //! Manages a malloc()'d memory block. Most methods are self explanatory. + class mem_block { + public: + mem_block( ) noexcept { _clear(); } + ~mem_block() noexcept { clear(); } + void resize(size_t); + void clear() noexcept; + size_t size() const noexcept { return m_size;} + void * ptr() noexcept { return m_ptr; } + const void * ptr() const noexcept { return m_ptr; } + void move( mem_block & other ) noexcept; + void copy( mem_block const & other ); + mem_block(const mem_block & other) { _clear(); copy(other); } + mem_block(mem_block && other) noexcept { _clear(); move(other); } + mem_block const & operator=( const mem_block & other ) { copy(other); return *this; } + mem_block const & operator=( mem_block && other ) noexcept { move(other); return *this; } + + void set(const void* ptr, size_t size) {set_data_fromptr(ptr, size); } + void set_data_fromptr(const void* p, size_t size) { resize(size); memcpy(ptr(), p, size); + } + void append_fromptr(const void* p, size_t size) { + const size_t base = this->size(); + resize(base + size); + memcpy((uint8_t*)ptr() + base, p, size); + } + + void* detach() noexcept { + void* ret = m_ptr; _clear(); return ret; + } + + void* get_ptr() noexcept { return m_ptr; } + const void* get_ptr() const noexcept { return m_ptr; } + size_t get_size() const noexcept { return m_size; } + + //! Attaches an existing memory block, allocated with malloc(), to this object. After this call, the memory becomes managed by this mem_block instance. + void attach(void* ptr, size_t size) noexcept { + clear(); + m_ptr = ptr; m_size = size; + } + //! Turns existing memory block, allocated with malloc(), to a mem_block object. After this call, the memory becomes managed by this mem_block instance. + static mem_block takeOwnership(void* ptr, size_t size) { + mem_block ret(noinit{}); + ret.m_ptr = ptr; ret.m_size = size; + return ret; + } + private: + struct noinit {}; mem_block(noinit) {} + void _clear() noexcept { m_ptr = nullptr; m_size = 0; } + void * m_ptr; + size_t m_size; + }; +} + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/memalign.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/memalign.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,106 @@ +#pragma once + +namespace pfc { + + void alignedAlloc( void* & ptr, size_t & ptrSize, size_t newSize, size_t alignBytes); + void * alignedAlloc( size_t size, size_t align ); + void alignedFree( void * ptr ); + + template + class mem_block_aligned { + public: + typedef mem_block_aligned self_t; + mem_block_aligned() : m_ptr(), m_size() {} + + void * ptr() {return m_ptr;} + const void * ptr() const {return m_ptr;} + void * get_ptr() {return m_ptr;} + const void * get_ptr() const {return m_ptr;} + size_t size() const {return m_size;} + size_t get_size() const {return m_size;} + + void resize(size_t s) { + alignedAlloc( m_ptr, m_size, s, alignBytes ); + } + void set_size(size_t s) {resize(s);} + + ~mem_block_aligned() { + alignedFree(m_ptr); + } + + self_t const & operator=(self_t const & other) { + assign(other); + return *this; + } + mem_block_aligned(self_t const & other) : m_ptr(), m_size() { + assign(other); + } + void assign(self_t const & other) { + resize(other.size()); + memcpy(ptr(), other.ptr(), size()); + } + mem_block_aligned(self_t && other) { + m_ptr = other.m_ptr; + m_size = other.m_size; + other.m_ptr = NULL; other.m_size = 0; + } + self_t const & operator=(self_t && other) { + alignedFree(m_ptr); + m_ptr = other.m_ptr; + m_size = other.m_size; + other.m_ptr = NULL; other.m_size = 0; + return *this; + } + + private: + void * m_ptr; + size_t m_size; + }; + + template + class mem_block_aligned_t { + public: + typedef mem_block_aligned_t self_t; + void resize(size_t s) { m.resize( multiply_guarded(s, sizeof(obj_t) ) ); } + void set_size(size_t s) {resize(s);} + size_t size() const { return m.size() / sizeof(obj_t); } + size_t get_size() const {return size();} + obj_t * ptr() { return reinterpret_cast(m.ptr()); } + const obj_t * ptr() const { return reinterpret_cast(m.ptr()); } + obj_t * get_ptr() { return reinterpret_cast(m.ptr()); } + const obj_t * get_ptr() const { return reinterpret_cast(m.ptr()); } + mem_block_aligned_t() {} + private: + mem_block_aligned m; + }; + + template + class mem_block_aligned_incremental_t { + public: + typedef mem_block_aligned_t self_t; + + void resize(size_t s) { + if (s > m.size()) { + m.resize( multiply_guarded(s, 3) / 2 ); + } + m_size = s; + } + void set_size(size_t s) {resize(s);} + + size_t size() const { return m_size; } + size_t get_size() const {return m_size; } + + obj_t * ptr() { return m.ptr(); } + const obj_t * ptr() const { return m.ptr(); } + obj_t * get_ptr() { return m.ptr(); } + const obj_t * get_ptr() const { return m.ptr(); } + mem_block_aligned_incremental_t() : m_size() {} + mem_block_aligned_incremental_t(self_t const & other) : m(other.m), m_size(other.m_size) {} + mem_block_aligned_incremental_t(self_t && other) : m(std::move(other.m)), m_size(other.m_size) { other.m_size = 0; } + self_t const & operator=(self_t const & other) {m = other.m; m_size = other.m_size; return *this;} + self_t const & operator=(self_t && other) {m = std::move(other.m); m_size = other.m_size; other.m_size = 0; return *this;} + private: + mem_block_aligned_t m; + size_t m_size; + }; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/nix-objects.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/nix-objects.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,358 @@ +#include "pfc-lite.h" + + +#ifndef _WIN32 +#include +#include +#include +#include +#include +#include + +#ifdef __APPLE__ +#include +#endif + +#include "nix-objects.h" +#include "string_base.h" +#include "array.h" +#include "debug.h" +#include "timers.h" +#include "filehandle.h" + +namespace pfc { + void nixFormatError( string_base & str, int code ) { + char buffer[512] = {}; + strerror_r(code, buffer, sizeof(buffer)); + str = buffer; + } + + void setNonBlocking( int fd, bool bNonBlocking ) { + int flags = fcntl(fd, F_GETFL, 0); + int flags2 = flags; + if (bNonBlocking) flags2 |= O_NONBLOCK; + else flags2 &= ~O_NONBLOCK; + if (flags2 != flags) fcntl(fd, F_SETFL, flags2); + } + + void setCloseOnExec( int fd, bool bCloseOnExec ) { + int flags = fcntl(fd, F_GETFD); + int flags2 = flags; + if (bCloseOnExec) flags2 |= FD_CLOEXEC; + else flags2 &= ~FD_CLOEXEC; + if (flags != flags2) fcntl(fd, F_SETFD, flags2); + } + + void setInheritable( int fd, bool bInheritable ) { + setCloseOnExec( fd, !bInheritable ); + } + + void createPipe( int fd[2], bool bInheritable ) { +#if defined(__linux__) && defined(O_CLOEXEC) + if (pipe2(fd, bInheritable ? 0 : O_CLOEXEC) < 0) throw exception_nix(); +#else + if (pipe(fd) < 0) throw exception_nix(); + if (!bInheritable) { + setInheritable( fd[0], false ); + setInheritable( fd[1], false ); + } +#endif + } + + exception_nix::exception_nix() { + _init(errno); + } + exception_nix::exception_nix(int code) { + _init(code); + } + void exception_nix::_init(int code) { + PFC_ASSERT( code != EINTR ); + m_code = code; + nixFormatError(m_msg, code); + } + + timeval makeTimeVal( double timeSeconds ) { + timeval tv = {}; + uint64_t temp = (uint64_t) floor( timeSeconds * 1000000.0 + 0.5); + tv.tv_usec = (uint32_t) (temp % 1000000); + tv.tv_sec = (uint32_t) (temp / 1000000); + return tv; + } + double importTimeval(const timeval & in) { + return (double)in.tv_sec + (double)in.tv_usec / 1000000.0; + } + + void fdSet::operator+=( int fd ) { + m_fds.insert( fd ); + } + void fdSet::operator-=( int fd ) { + m_fds.erase(fd); + } + bool fdSet::operator[] (int fd ) { + return m_fds.find( fd ) != m_fds.end(); + } + void fdSet::clear() { + m_fds.clear(); + } + + void fdSet::operator+=( fdSet const & other ) { + for(auto i = other.m_fds.begin(); i != other.m_fds.end(); ++ i ) { + (*this) += *i; + } + } + + int fdSelect::Select() { + return Select_( -1 ); + } + int fdSelect::Select( double timeOutSeconds ) { + int ms; + if (timeOutSeconds < 0) { + ms = -1; + } else if (timeOutSeconds == 0) { + ms = 0; + } else { + ms = pfc::rint32( timeOutSeconds * 1000 ); + if (ms < 1) ms = 1; + } + return Select_( ms ); + } + + int fdSelect::Select_( int timeOutMS ) { + fdSet total = Reads; + total += Writes; + total += Errors; + const size_t count = total.m_fds.size(); + pfc::array_t< pollfd > v; + v.set_size_discard( count ); + size_t walk = 0; + for( auto fd : total.m_fds) { + auto & f = v[walk++]; + f.fd = fd; + f.events = (Reads[fd] ? POLLIN : 0) | (Writes[fd] ? POLLOUT : 0); + // POLLERR ignored in events, only used in revents + f.revents = 0; + } + hires_timer timer; + int countdown = timeOutMS; + if (countdown > 0) timer.start(); + int status; + for ( ;; ) { + status = poll(v.get_ptr(), (int)count, countdown); + if (status >= 0) break; + + int e = errno; + if (e == EINTR) { + if (countdown < 0) continue; // infinite + if (countdown > 0) { + countdown = timeOutMS - rint32( timer.query() ); + if (countdown > 0) continue; + } + // should not really get here + status = 0; + break; + } else { + throw exception_nix(e); + } + + } + + Reads.clear(); Writes.clear(); Errors.clear(); + + if (status > 0) { + for(walk = 0; walk < count; ++walk) { + auto & f = v[walk]; + if (f.revents & POLLIN) Reads += f.fd; + if (f.revents & POLLOUT) Writes += f.fd; + if (f.revents & POLLERR) Errors += f.fd; + } + PFC_ASSERT( !Reads.m_fds.empty() || !Writes.m_fds.empty() || !Errors.m_fds.empty() ); + } + + return status; + } + + inline bool fdCanRead_select( int fdRead ) { + PFC_ASSERT( fdRead < FD_SETSIZE ); + timeval tv = {}; + fd_set set; + FD_ZERO(&set); + FD_SET(fdRead, &set); + + return select(fdRead + 1, &set, nullptr, nullptr, &tv) > 0; + } + inline bool fdCanRead_poll(int fdRead) { + pollfd arg = {fdRead, POLLIN }; + poll(&arg, 1, 0); + return (arg.revents & POLLIN) != 0; + } + + bool fdCanRead( int fdRead ) { + if ( fdRead < 0 ) { + PFC_ASSERT( !"???" ); + return false; + } + #ifdef __APPLE__ + // BROKEN extremely inefficient implementation of poll() on Apple systems, avoid if possible + if ( fdRead < FD_SETSIZE ) { + return fdCanRead_select( fdRead ); + } + #endif + return fdCanRead_poll(fdRead); + } + + bool fdCanWrite( int fd ) { + return fdWaitWrite( fd, 0 ); + } + + bool fdWaitRead( int fd, double timeOutSeconds ) { + if ( timeOutSeconds == 0 ) return fdCanRead( fd ); + fdSelect sel; sel.Reads += fd; + return sel.Select( timeOutSeconds ) > 0; + } + bool fdWaitWrite( int fd, double timeOutSeconds ) { + fdSelect sel; sel.Writes += fd; + return sel.Select( timeOutSeconds ) > 0; + } + + nix_event::nix_event(bool state) { + createPipe( m_fd ); + setNonBlocking( m_fd[0] ); + setNonBlocking( m_fd[1] ); + if ( state ) set_state(true); + } + nix_event::~nix_event() { + close( m_fd[0] ); + close( m_fd[1] ); + } + + void nix_event::set_state( bool state ) { + if (state) { + // Ensure that there is a byte in the pipe + if (!fdCanRead(m_fd[0] ) ) { + uint8_t dummy = 0; + write( m_fd[1], &dummy, 1); + } + } else { + // Keep reading until clear + for(;;) { + uint8_t dummy; + if (read(m_fd[0], &dummy, 1 ) != 1) break; + } + } + } + + bool nix_event::wait_for( double p_timeout_seconds ) { + return fdWaitRead( m_fd[0], p_timeout_seconds ); + } + bool nix_event::is_set() { + return fdCanRead(m_fd[0]); + } + bool nix_event::g_wait_for( int p_event, double p_timeout_seconds ) { + return fdWaitRead( p_event, p_timeout_seconds ); + } + size_t nix_event::g_multiWait( const pfc::eventHandle_t * events, size_t count, double timeout ) { + fdSelect sel; + for( size_t i = 0; i < count; ++ i ) { + sel.Reads += events[i]; + } + int state = sel.Select( timeout ); + if (state < 0) throw exception_nix(); + if (state == 0) return SIZE_MAX; + for( size_t i = 0; i < count; ++ i ) { + if ( sel.Reads[ events[i] ] ) return i; + } + crash(); // should not get here + return SIZE_MAX; + } + size_t nix_event::g_multiWait(std::initializer_list const & arg, double timeout) { + return g_multiWait(arg.begin(), arg.size(), timeout); + } + int nix_event::g_twoEventWait( int h1, int h2, double timeout ) { + fdSelect sel; + sel.Reads += h1; + sel.Reads += h2; + int state = sel.Select( timeout ); + if (state < 0) throw exception_nix(); + if (state == 0) return 0; + if (sel.Reads[ h1 ] ) return 1; + if (sel.Reads[ h2 ] ) return 2; + crash(); // should not get here + return 0; + } + int nix_event::g_twoEventWait( nix_event & ev1, nix_event & ev2, double timeout ) { + return g_twoEventWait( ev1.get_handle(), ev2.get_handle(), timeout ); + } + + void nixSleep(double seconds) { + fdSelect sel; sel.Select( seconds ); + } + void sleepSeconds(double seconds) { + return nixSleep(seconds); + } + + void yield() { + return nixSleep(0.001); + } + + double nixGetTime() { + timeval tv = {}; + gettimeofday(&tv, NULL); + return importTimeval(tv); + } + tickcount_t getTickCount() { + return rint64(nixGetTime() * 1000.f); + } + + bool nixReadSymLink( string_base & strOut, const char * path ) { + size_t l = 1024; + for(;;) { + array_t buffer; buffer.set_size( l + 1 ); + ssize_t rv = (size_t) readlink(path, buffer.get_ptr(), l); + if (rv < 0) return false; + if ((size_t)rv <= l) { + buffer.get_ptr()[rv] = 0; + strOut = buffer.get_ptr(); + return true; + } + l *= 2; + } + } + bool nixSelfProcessPath( string_base & strOut ) { +#ifdef __APPLE__ + uint32_t len = 0; + _NSGetExecutablePath(NULL, &len); + array_t temp; temp.set_size( len + 1 ); temp.fill_null(); + _NSGetExecutablePath(temp.get_ptr(), &len); + strOut = temp.get_ptr(); + return true; +#else + return nixReadSymLink( strOut, PFC_string_formatter() << "/proc/" << (unsigned) getpid() << "/exe"); +#endif + } + + static int openDevRand() { + int ret = open("/dev/urandom", O_RDONLY); + if ( ret < 0 ) throw exception_nix(); + return ret; + } + void nixGetRandomData( void * outPtr, size_t outBytes ) { + try { + static fileHandle randomData = openDevRand(); + if (read(randomData.h, outPtr, outBytes) != outBytes) throw exception_nix(); + } catch (std::exception const & e) { + throw std::runtime_error("getRandomData failure"); + } + } + +#ifndef __APPLE__ // for Apple they are implemented in Obj-C + bool isShiftKeyPressed() {return false;} + bool isCtrlKeyPressed() {return false;} + bool isAltKeyPressed() {return false;} +#endif +} + +void uSleepSeconds( double seconds, bool ) { + pfc::nixSleep( seconds ); +} +#endif // _WIN32 + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/nix-objects.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/nix-objects.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,130 @@ +#pragma once + +#include +#include +#include + +namespace pfc { + + void nixFormatError( string_base & str, int code ); + + class exception_nix : public std::exception { + public: + exception_nix(); + exception_nix(int code); + + ~exception_nix() throw() { } + + int code() const throw() {return m_code;} + const char * what() const throw() {return m_msg.get_ptr();} + private: + void _init(int code); + int m_code; + string8 m_msg; + }; + + // Toggles non-blocking mode on a file descriptor. + void setNonBlocking( int fd, bool bNonBlocking = true ); + + // Toggles close-on-exec mode on a file descriptor. + void setCloseOnExec( int fd, bool bCloseOnExec = true ); + + // Toggles inheritable mode on a file descriptor. Reverse of close-on-exec. + void setInheritable( int fd, bool bInheritable = true ); + + // Creates a pipe. The pipe is NOT inheritable by default (close-on-exec set). + void createPipe( int fd[2], bool bInheritable = false ); + + timeval makeTimeVal( double seconds ); + double importTimeval(const timeval & tv); + + class fdSet { + public: + + void operator+=( int fd ); + void operator-=( int fd ); + bool operator[] (int fd ); + void clear(); + + void operator+=( fdSet const & other ); + + std::set m_fds; + }; + + + bool fdCanRead( int fd ); + bool fdCanWrite( int fd ); + + bool fdWaitRead( int fd, double timeOutSeconds ); + bool fdWaitWrite( int fd, double timeOutSeconds ); + + class fdSelect { + public: + + int Select(); + int Select( double timeOutSeconds ); + int Select_( int timeOutMS ); + + fdSet Reads, Writes, Errors; + }; + + void nixSleep(double seconds); + void sleepSeconds(double seconds); + void yield(); + + typedef int eventHandle_t; + static constexpr eventHandle_t eventInvalid = -1; + + class nix_event { + public: + nix_event(bool state = false); + ~nix_event(); + + void set_state( bool state ); + + bool is_set( ); + + void wait_and_clear() { wait(); set_state(false); } + void wait() { wait_for(-1); } + bool wait_for( double p_timeout_seconds ); + + static bool g_wait_for( int p_event, double p_timeout_seconds ); + + eventHandle_t get_handle() const {return m_fd[0]; } + + // Two-wait event functions, return 0 on timeout, 1 on evt1 set, 2 on evt2 set + static int g_twoEventWait( nix_event & ev1, nix_event & ev2, double timeout ); + static int g_twoEventWait( int h1, int h2, double timeOut ); + + // Multi-wait. Returns SIZE_MAX on timeout, 0 based event index if either event becomes set. + static size_t g_multiWait( const eventHandle_t * events, size_t count, double timeout ); + static size_t g_multiWait(std::initializer_list const & arg, double timeout); + + private: + nix_event(nix_event const&) = delete; + void operator=(nix_event const&) = delete; + int m_fd[2]; + }; + + typedef nix_event event; + + double nixGetTime(); + typedef uint64_t tickcount_t; + tickcount_t getTickCount(); + + bool nixReadSymLink( string_base & strOut, const char * path ); + bool nixSelfProcessPath( string_base & strOut ); + + void nixGetRandomData( void * outPtr, size_t outBytes ); + + bool isShiftKeyPressed(); + bool isCtrlKeyPressed(); + bool isAltKeyPressed(); + +#ifdef __APPLE__ + bool appleRecycleFile( const char * path ); + void appleSetThreadDescription( const char * str ); +#endif +} + +void uSleepSeconds( double seconds, bool ); diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/notifyList.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/notifyList.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,85 @@ +#pragma once + +#include +#include +#include + +namespace pfc { + class notifyList { + public: + + typedef size_t token_t; + + typedef std::function notify_t; + token_t add( notify_t f ) { + auto token = ++ m_increment; + m_notify[token] = f; + return token; + } + + void remove( token_t t ) { + m_notify.erase(t); + } + + void dispatch() { + // Safeguard against someone altering our state in mid-dispatch + auto temp = m_notify; + for( auto walk = temp.begin(); walk != temp.end(); ++ walk ) { + if ( m_notify.count( walk->first ) > 0 ) { // still there? + walk->second(); + } + } + } + + + static std::shared_ptr make() { + return std::make_shared(); + } + private: + token_t m_increment = 0; + + std::map m_notify; + }; + + typedef std::shared_ptr< notifyList > notifyListRef_t; + + class notifyEntry { + public: + notifyEntry() {} + + notifyEntry & operator<<( notifyList & l ) { + PFC_ASSERT( m_list == nullptr ); + m_list = &l; + return *this; + } + notifyEntry & operator<<( notifyListRef_t l ) { + PFC_ASSERT( m_list == nullptr ); + m_listShared = l; + m_list = &*l; + return *this; + } + notifyEntry & operator<<( notifyList::notify_t f ) { + PFC_ASSERT( m_list != nullptr ); + PFC_ASSERT( m_token == 0 ); + m_token = m_list->add( f ); + return *this; + } + void clear() { + if ( m_list != nullptr && m_token != 0 ) { + m_list->remove(m_token); + m_token = 0; + } + } + ~notifyEntry() { + clear(); + } + + private: + notifyListRef_t m_listShared; + notifyList * m_list = nullptr; + notifyList::token_t m_token = 0; + + notifyEntry( const notifyEntry & ) = delete; + void operator=( const notifyEntry & ) = delete; + }; +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/obj-c.mm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/obj-c.mm Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,143 @@ +// +// PFC-ObjC.m +// pfc-test +// +// Created by PEPE on 28/07/14. +// Copyright (c) 2014 PEPE. All rights reserved. +// +#ifdef __APPLE__ +#import + + +#include + +#if TARGET_OS_MAC && !TARGET_OS_IPHONE +#import +#endif + +#include "pfc.h" +#include "sortstring.h" + + +namespace pfc { + void * thread::g_entry(void * arg) { + @autoreleasepool { + reinterpret_cast(arg)->entry(); + } + return NULL; + } + void thread::appleStartThreadPrologue() { + if (![NSThread isMultiThreaded]) [[[NSThread alloc] init] start]; + } + + bool isShiftKeyPressed() { +#if TARGET_OS_MAC && !TARGET_OS_IPHONE + return ( [NSEvent modifierFlags] & NSEventModifierFlagShift ) != 0; +#else + return false; +#endif + } + bool isCtrlKeyPressed() { +#if TARGET_OS_MAC && !TARGET_OS_IPHONE + return ( [NSEvent modifierFlags] & NSEventModifierFlagControl ) != 0; +#else + return false; +#endif + } + bool isAltKeyPressed() { +#if TARGET_OS_MAC && !TARGET_OS_IPHONE + return ( [NSEvent modifierFlags] & NSEventModifierFlagOption ) != 0; +#else + return false; +#endif + } + + void inAutoReleasePool(std::function f) { + @autoreleasepool { + f(); + } + } + + void appleDebugLog( const char * str ) { + NSLog(@"%s\n", str ); + } + + bool appleRecycleFile( const char * path ) { + @autoreleasepool { + NSFileManager * manager = [NSFileManager defaultManager]; + NSURL * url = [NSURL fileURLWithPath: [NSString stringWithUTF8String: path] ]; + if (@available(iOS 11.0, *)) { + NSError * error = nil; + if ([manager trashItemAtURL: url resultingItemURL: nil error: &error]) { + return true; + } + if ([error.domain isEqualToString: NSCocoaErrorDomain] && error.code == NSFeatureUnsupportedError) { + // trashcan not supported, fall thru + } else { + // failed to remove + return false; + } + } + return [manager removeItemAtURL: url error: nil]; + } + } + void appleSetThreadDescription( const char * str ) { + @autoreleasepool { + [NSThread currentThread].name = [NSString stringWithUTF8String: str]; + } + } + + pfc::string8 unicodeNormalizeD(const char * str) { + @autoreleasepool { + pfc::string8 ret; + NSString * v = [[NSString stringWithUTF8String: str] decomposedStringWithCanonicalMapping]; + if ( v ) ret = v.UTF8String; + else ret = str; + return ret; + } + } + pfc::string8 unicodeNormalizeC(const char * str) { + @autoreleasepool { + pfc::string8 ret; + NSString * v = [[NSString stringWithUTF8String: str] precomposedStringWithCanonicalMapping]; + if ( v ) ret = v.UTF8String; + else ret = str; + return ret; + } + } + + int appleNaturalSortCompare(const char* s1, const char* s2) { + @autoreleasepool { + NSString * str1 = [NSString stringWithUTF8String: s1]; + NSString * str2 = [NSString stringWithUTF8String: s2]; + return (int) [str1 localizedCompare: str2]; + } + } + int appleNaturalSortCompareI(const char* s1, const char* s2) { + @autoreleasepool { + NSString * str1 = [NSString stringWithUTF8String: s1]; + NSString * str2 = [NSString stringWithUTF8String: s2]; + return (int) [str1 localizedCaseInsensitiveCompare: str2]; + } + } + [[noreturn]] void appleThrowException( const char * name, const char * reason ) { + @autoreleasepool { + @throw [NSException exceptionWithName: [NSString stringWithUTF8String: name] reason:[NSString stringWithUTF8String: reason] userInfo:nil]; + } + } + +#ifndef PFC_SORTSTRING_GENERIC + sortString_t makeSortString(const char* str) { + sortString_t ret; + ret.Attach( CFStringCreateWithCString(NULL, str, kCFStringEncodingUTF8) ); + return ret; + } + int sortStringCompare(sortString_t const& s1, sortString_t const& s2) { + return (int) CFStringCompare(s1.p, s2.p, kCFCompareLocalized | kCFCompareNumerically ); + } + int sortStringCompareI(sortString_t const& s1, sortString_t const& s2) { + return (int) CFStringCompare(s1.p, s2.p, kCFCompareLocalized | kCFCompareNumerically | kCFCompareCaseInsensitive ); + } +#endif +} +#endif diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/once.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/once.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,51 @@ +#pragma once + +#include +#include "event.h" +#include +#include "lockless.h" + +#ifdef __ANDROID__ +#define PFC_CUSTOM_ONCE_FLAG 1 +#endif + +#ifndef PFC_CUSTOM_ONCE_FLAG +#define PFC_CUSTOM_ONCE_FLAG 0 +#endif + +#if ! PFC_CUSTOM_ONCE_FLAG +#include +#endif + +namespace pfc { +#if PFC_CUSTOM_ONCE_FLAG + struct once_flag { + bool inProgress = false, done = false; + std::shared_ptr<::pfc::event> waitFor; + }; + + void call_once( once_flag &, std::function ); +#else + using std::once_flag; + using std::call_once; +#endif + + //! Minimalist class to call some function only once. \n + //! Presumes low probability of concurrent run() calls actually happening, \n + //! but frequent calls once already initialized, hence only using basic volatile bool check. \n + //! If using a modern compiler you might want to use std::call_once instead. \n + //! The called function is not expected to throw exceptions. + struct once_flag_lite { + threadSafeInt::val_t guard = 0; + volatile bool done = false; + }; + + void call_once( once_flag_lite &, std::function ); + + class runOnceLock { + public: + void run(std::function f) {call_once(m_flag, f);} + private: + once_flag_lite m_flag; + }; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/order_helper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/order_helper.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,76 @@ +#pragma once + +namespace pfc { + PFC_DECLARE_EXCEPTION( exception_invalid_permutation, exception_invalid_params, "Invalid permutation" ); + t_size permutation_find_reverse(t_size const * order, t_size count, t_size value); + + //! For critical sanity checks. Speed: O(n), allocates memory. + bool permutation_is_valid(t_size const * order, t_size count); + //! For critical sanity checks. Speed: O(n), allocates memory. + void permutation_validate(t_size const * order, t_size count); + + //! Creates a permutation that moves selected items in a list box by the specified delta-offset. + void create_move_items_permutation(t_size * p_output,t_size p_count,const class bit_array & p_selection,int p_delta); + + void create_move_item_permutation( size_t * p_output, size_t p_count, size_t from, size_t to ); + bool create_drop_permutation(size_t * out, size_t itemCount, pfc::bit_array const & maskSelected, size_t insertMark ); + + bool is_identity(size_t const* order, size_t count); +} + +class order_helper +{ + pfc::array_t m_data; +public: + order_helper(t_size p_size) { + m_data.set_size(p_size); + for(t_size n=0;n static bool g_is_identity(const t_array & p_array) { + const t_size count = pfc::array_size_t(p_array); + for(t_size walk = 0; walk < count; ++walk) if (p_array[walk] != walk) return false; + return true; + } + + template + static void g_fill(t_int * p_order,const t_size p_count) { + t_size n; for(n=0;n + static void g_fill(t_array & p_array) { + t_size n; const t_size max = pfc::array_size_t(p_array); + for(n=0;n +#include +#endif +#ifndef _MSC_VER +#include +#include +#endif + +#if defined(__ANDROID__) +#include +#endif + +#include + +#include "string_base.h" +#include "other.h" +#include "bit_array_impl.h" +#include "order_helper.h" +#include "debug.h" +#include "byte_order.h" +#include "string_conv.h" +#include "memalign.h" +#include "platform-objects.h" +#include "synchro.h" + +#include "pfc-fb2k-hooks.h" + + +namespace pfc { + bool permutation_is_valid(t_size const * order, t_size count) { + bit_array_bittable found(count); + for(t_size walk = 0; walk < count; ++walk) { + const size_t v = order[walk]; + if (v >= count) return false; + if (found[v]) return false; + found.set(v,true); + } + return true; + } + void permutation_validate(t_size const * order, t_size count) { + if (!permutation_is_valid(order,count)) throw exception_invalid_permutation(); + } + + t_size permutation_find_reverse(t_size const * order, t_size count, t_size value) { + if (value >= count) return SIZE_MAX; + for(t_size walk = 0; walk < count; ++walk) { + if (order[walk] == value) return walk; + } + return SIZE_MAX; + } + + void create_move_item_permutation( size_t * order, size_t count, size_t from, size_t to ) { + PFC_ASSERT( from < count ); + PFC_ASSERT( to < count ); + for ( size_t w = 0; w < count; ++w ) { + size_t i = w; + if ( w == to ) i = from; + else if ( w < to && w >= from ) { + ++i; + } else if ( w > to && w <= from ) { + --i; + } + order[w] = i; + } + } + + void create_move_items_permutation(t_size * p_output,t_size p_count,const bit_array & p_selection,int p_delta) { + t_size * const order = p_output; + const t_size count = p_count; + + pfc::array_t selection; selection.set_size(p_count); + + for(t_size walk = 0; walk < count; ++walk) { + order[walk] = walk; + selection[walk] = p_selection[walk]; + } + + if (p_delta<0) + { + for(;p_delta<0;p_delta++) + { + t_size idx; + for(idx=1;idx0;p_delta--) + { + t_size idx; + for(idx=count-2;(int)idx>=0;idx--) + { + if (selection[idx] && !selection[idx+1]) + { + pfc::swap_t(order[idx],order[idx+1]); + pfc::swap_t(selection[idx],selection[idx+1]); + } + } + } + } + } + bool create_drop_permutation(size_t * out, size_t itemCount, pfc::bit_array const & maskSelected, size_t insertMark ) { + const t_size count = itemCount; + if (insertMark > count) insertMark = count; + { + t_size selBefore = 0; + for(t_size walk = 0; walk < insertMark; ++walk) { + if (maskSelected[walk]) selBefore++; + } + insertMark -= selBefore; + } + { + pfc::array_t permutation, selected, nonselected; + + const t_size selcount = maskSelected.calc_count( true, 0, count ); + selected.set_size(selcount); nonselected.set_size(count - selcount); + permutation.set_size(count); + if (insertMark > nonselected.get_size()) insertMark = nonselected.get_size(); + for(t_size walk = 0, swalk = 0, nwalk = 0; walk < count; ++walk) { + if (maskSelected[walk]) { + selected[swalk++] = walk; + } else { + nonselected[nwalk++] = walk; + } + } + for(t_size walk = 0; walk < insertMark; ++walk) { + permutation[walk] = nonselected[walk]; + } + for(t_size walk = 0; walk < selected.get_size(); ++walk) { + permutation[insertMark + walk] = selected[walk]; + } + for(t_size walk = insertMark; walk < nonselected.get_size(); ++walk) { + permutation[selected.get_size() + walk] = nonselected[walk]; + } + for(t_size walk = 0; walk < permutation.get_size(); ++walk) { + if (permutation[walk] != walk) { + memcpy(out, permutation.get_ptr(), count * sizeof(size_t)); + return true; + } + } + } + return false; + } + + bool is_identity(size_t const* order, size_t count) { + for (size_t walk = 0; walk < count; ++walk) { + if (order[walk] != walk) return false; + } + return true; + } +} + +void order_helper::g_swap(t_size * data,t_size ptr1,t_size ptr2) +{ + t_size temp = data[ptr1]; + data[ptr1] = data[ptr2]; + data[ptr2] = temp; +} + + +t_size order_helper::g_find_reverse(const t_size * order,t_size val) +{ + t_size prev = val, next = order[val]; + while(next != val) + { + prev = next; + next = order[next]; + } + return prev; +} + + +void order_helper::g_reverse(t_size * order,t_size base,t_size count) +{ + t_size max = count>>1; + t_size n; + t_size base2 = base+count-1; + for(n=0;n>1;n++) swap_t(ptr[n],ptr[p_bytes-n-1]); +} + +static pfc::debugLineReceiver * g_debugLineReceivers = nullptr; + +pfc::debugLineReceiver::debugLineReceiver() { + m_chain = g_debugLineReceivers; + g_debugLineReceivers = this; +} + +void pfc::debugLineReceiver::dispatch( const char * msg ) { + for( auto w = g_debugLineReceivers; w != nullptr; w = w->m_chain ) { + w->onLine( msg ); + } +} +namespace pfc { + void appleDebugLog( const char * str ); +} + +void pfc::outputDebugLine(const char * msg) { + debugLineReceiver::dispatch( msg ); +#ifdef _WIN32 + OutputDebugString(pfc::stringcvt::string_os_from_utf8(PFC_string_formatter() << msg << "\n") ); +#elif defined(__ANDROID__) + __android_log_write(ANDROID_LOG_INFO, "Debug", msg); +#elif defined(__APPLE__) + appleDebugLog( msg ); +#else + printf("%s\n", msg); +#endif +} + +void pfc::debugBreak() { +#ifdef _WIN32 + __debugbreak(); +#else + raise(SIGTRAP); +#endif +} + +#if PFC_DEBUG + +#ifdef _WIN32 +void pfc::myassert_win32(const wchar_t * _Message, const wchar_t *_File, unsigned _Line) { + if (IsDebuggerPresent()) debugBreak(); + PFC_DEBUGLOG << "PFC_ASSERT failure: " << _Message; + PFC_DEBUGLOG << "PFC_ASSERT location: " << _File << " : " << _Line; + _wassert(_Message,_File,_Line); +} +#else + +void pfc::myassert(const char * _Message, const char *_File, unsigned _Line) +{ + PFC_DEBUGLOG << "Assert failure: \"" << _Message << "\" in: " << _File << " line " << _Line; + debugBreak(); +} +#endif + +#endif + + +t_uint64 pfc::pow_int(t_uint64 base, t_uint64 exp) noexcept { + t_uint64 mul = base; + t_uint64 val = 1; + t_uint64 mask = 1; + while(exp != 0) { + if (exp & mask) { + val *= mul; + exp ^= mask; + } + mul = mul * mul; + mask <<= 1; + } + return val; +} + +double pfc::exp_int( const double base, const int expS ) noexcept { + // return pow(base, (double)v); + + bool neg; + unsigned exp; + if (expS < 0) { + neg = true; + exp = (unsigned) -expS; + } else { + neg = false; + exp = (unsigned) expS; + } + double v = 1.0; + if (exp) { + double mul = base; + for(;;) { + if (exp & 1) v *= mul; + exp >>= 1; + if (exp == 0) break; + mul *= mul; + } + } + if (neg) v = 1.0 / v; + return v; +} + + +t_int32 pfc::rint32(double p_val) { return (t_int32)lround(p_val); } +t_int64 pfc::rint64(double p_val) { return (t_int64)llround(p_val); } + + +// mem_block class +namespace pfc { + void mem_block::resize(size_t newSize) { + if (m_size != newSize) { + if (newSize == 0) { + free(m_ptr); m_ptr = nullptr; + } else if (m_size == 0) { + m_ptr = malloc( newSize ); + if (m_ptr == nullptr) throw std::bad_alloc(); + } else { + auto newptr = realloc( m_ptr, newSize ); + if (newptr == nullptr) throw std::bad_alloc(); + m_ptr = newptr; + } + + m_size = newSize; + } + } + void mem_block::clear() noexcept { + free(m_ptr); m_ptr = nullptr; m_size = 0; + } + void mem_block::move( mem_block & other ) noexcept { + clear(); + m_ptr = other.m_ptr; + m_size = other.m_size; + other._clear(); + } + void mem_block::copy( mem_block const & other ) { + const size_t size = other.size(); + resize( size ); + if (size > 0) memcpy(ptr(), other.ptr(), size); + } + + // aligned alloc + void alignedAlloc( void* & m_ptr, size_t & m_size, size_t s, size_t alignBytes) { + if (s == m_size) { + // nothing to do + } else if (s == 0) { + alignedFree(m_ptr); + m_ptr = NULL; + } else { + void * ptr; +#ifdef _MSC_VER + if (m_ptr == NULL) ptr = _aligned_malloc(s, alignBytes); + else ptr = _aligned_realloc(m_ptr, s, alignBytes); + if ( ptr == NULL ) throw std::bad_alloc(); +#else +#ifdef __ANDROID__ + if ((ptr = memalign( alignBytes, s )) == NULL) throw std::bad_alloc(); +#else + if (posix_memalign( &ptr, alignBytes, s ) < 0) throw std::bad_alloc(); +#endif + if (m_ptr != NULL) { + memcpy( ptr, m_ptr, min_t( m_size, s ) ); + alignedFree( m_ptr ); + } +#endif + m_ptr = ptr; + } + m_size = s; + } + + void* alignedAlloc( size_t s, size_t alignBytes ) { + void * ptr; +#ifdef _MSC_VER + ptr = _aligned_malloc(s, alignBytes); + if (ptr == nullptr) throw std::bad_alloc(); +#else +#ifdef __ANDROID__ + if ((ptr = memalign( alignBytes, s )) == NULL) throw std::bad_alloc(); +#else + if (posix_memalign( &ptr, alignBytes, s ) < 0) throw std::bad_alloc(); +#endif +#endif + return ptr; + } + + void alignedFree( void * ptr ) { +#ifdef _MSC_VER + _aligned_free(ptr); +#else + free(ptr); +#endif + } +} + + +#include "once.h" + +namespace pfc { +#if PFC_CUSTOM_ONCE_FLAG + static pfc::once_flag_lite g_onceGuardGuard; + static mutex * g_onceGuard; + + static mutex & onceGuard() { + call_once(g_onceGuardGuard, [] { + g_onceGuard = new mutex(); + } ); + return * g_onceGuard; + } + + void call_once( once_flag & flag, std::function work ) { + + if ( flag.done ) return; + + mutex & guard = onceGuard(); + for ( ;; ) { + std::shared_ptr waitFor; + { + insync(guard); + if ( flag.done ) { + PFC_ASSERT( ! flag.inProgress ); + return; + } + if ( flag.inProgress ) { + if ( ! flag.waitFor ) flag.waitFor = std::make_shared< event > (); + waitFor = flag.waitFor; + } else { + flag.inProgress = true; + } + } + + if ( waitFor ) { + waitFor->wait_for( -1 ); + continue; + } + + try { + work(); + } catch(...) { + insync( guard ); + PFC_ASSERT( ! flag.done ); + PFC_ASSERT( flag.inProgress ); + flag.inProgress = false; + if ( flag.waitFor ) { + flag.waitFor->set_state( true ); + flag.waitFor.reset(); + } + throw; + } + + // succeeded + insync( guard ); + PFC_ASSERT( ! flag.done ); + PFC_ASSERT( flag.inProgress ); + flag.inProgress = false; + flag.done = true; + if ( flag.waitFor ) { + flag.waitFor->set_state( true ); + flag.waitFor.reset(); + } + return; + } + } +#endif + void call_once( once_flag_lite & flag, std::function work ) { + for ( ;; ) { + if ( flag.done ) return; + if (! threadSafeInt::exchangeHere(flag.guard, 1)) { + try { + work(); + } catch(...) { + flag.guard = 0; + throw; + } + flag.done = true; + return; + } + yield(); + } + } + + +#ifdef PFC_SET_THREAD_DESCRIPTION_EXTERNAL + static std::function g_setCurrentThreadDescription; + void initSetCurrentThreadDescription( std::function f ) { g_setCurrentThreadDescription = f; } +#endif + + void setCurrentThreadDescription( const char * msg ) { +#ifdef __APPLE__ + appleSetThreadDescription( msg ); +#endif + +#ifdef PFC_WINDOWS_DESKTOP_APP + winSetThreadDescription(GetCurrentThread(), pfc::stringcvt::string_wide_from_utf8( msg ) );; +#endif +#ifdef PFC_SET_THREAD_DESCRIPTION_EXTERNAL + if (g_setCurrentThreadDescription) g_setCurrentThreadDescription(msg); +#endif + } +} + + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/other.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/other.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,86 @@ +#pragma once + +#include "avltree.h" + +namespace pfc { + + //warning: not multi-thread-safe + template + class instanceTracker : public t_base { + private: + typedef instanceTracker t_self; + public: + template instanceTracker( args_t && ... args) : t_base(std::forward(args) ...) {g_list += this; } + + instanceTracker(const t_self & p_other) : t_base( (const t_base &)p_other) {g_list += this;} + ~instanceTracker() {g_list -= this;} + + typedef pfc::avltree_t t_list; + static const t_list & instanceList() {return g_list;} + template static void forEach(t_callback && p_callback) {instanceList().enumerate(p_callback);} + private: + static t_list g_list; + }; + + template + typename instanceTracker::t_list instanceTracker::g_list; + + + //warning: not multi-thread-safe + template + class instanceTrackerV2 { + private: + typedef instanceTrackerV2 t_self; + public: + instanceTrackerV2(const t_self & p_other) {g_list += static_cast(this);} + instanceTrackerV2() {g_list += static_cast(this);} + ~instanceTrackerV2() {g_list -= static_cast(this);} + + typedef pfc::avltree_t t_instanceList; + static const t_instanceList & instanceList() {return g_list;} + template static void forEach(t_callback && p_callback) {instanceList().enumerate(p_callback);} + private: + static t_instanceList g_list; + }; + + template + typename instanceTrackerV2::t_instanceList instanceTrackerV2::g_list; + + + struct objDestructNotifyData { + bool m_flag; + objDestructNotifyData * m_next; + + }; + class objDestructNotify { + public: + objDestructNotify() : m_data() {} + ~objDestructNotify() { + set(); + } + + void set() { + objDestructNotifyData * w = m_data; + while(w) { + w->m_flag = true; w = w->m_next; + } + } + objDestructNotifyData * m_data; + }; + + class objDestructNotifyScope : private objDestructNotifyData { + public: + objDestructNotifyScope(objDestructNotify &obj) : m_obj(&obj) { + m_next = m_obj->m_data; + m_obj->m_data = this; + } + ~objDestructNotifyScope() { + if (!m_flag) m_obj->m_data = m_next; + } + bool get() const {return m_flag;} + PFC_CLASS_NOT_COPYABLE_EX(objDestructNotifyScope) + private: + objDestructNotify * m_obj; + + }; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/pathUtils.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/pathUtils.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,301 @@ +#include "pfc-lite.h" +#include "pathUtils.h" + +static_assert(L'Ö' == 0xD6, "Compile as Unicode!!!"); + +namespace pfc { namespace io { namespace path { + +#ifdef _WINDOWS +#define KPathSeparators "\\/|" +#else +#define KPathSeparators "/" +#endif + +string getFileName(string path) { + t_size split = path.lastIndexOfAnyChar(KPathSeparators); + if (split == SIZE_MAX) return path; + else return path.subString(split+1); +} +string getFileNameWithoutExtension(string path) { + string fn = getFileName(path); + t_size split = fn.lastIndexOf('.'); + if (split == SIZE_MAX) return fn; + else return fn.subString(0,split); +} +string getFileExtension(string path) { + string fn = getFileName(path); + t_size split = fn.lastIndexOf('.'); + if (split == SIZE_MAX) return ""; + else return fn.subString(split); +} +string getDirectory(string filePath) {return getParent(filePath);} + +string getParent(string filePath) { + t_size split = filePath.lastIndexOfAnyChar(KPathSeparators); + if (split == SIZE_MAX) return ""; +#ifdef _WINDOWS + if (split > 0 && getIllegalNameChars().contains(filePath[split-1])) { + if (split + 1 < filePath.length()) return filePath.subString(0,split+1); + else return ""; + } +#endif + return filePath.subString(0,split); +} +string combine(string basePath,string fileName) { + if (basePath.length() > 0) { + if (!isSeparator(basePath.lastChar())) { + basePath.add_byte( getDefaultSeparator() ); + } + return basePath + fileName; + } else { + //todo? + return fileName; + } +} + +bool isSeparator(char c) { + return strchr(KPathSeparators, c) != nullptr; +} +string getSeparators() { + return KPathSeparators; +} + +const char * charReplaceDefault(char c) { + switch (c) { + case '*': + return "x"; + case '\"': + return "\'\'"; + case ':': + case '/': + case '\\': + return "-"; + case '?': + return ""; + default: + return "_"; + } +} + +const char * charReplaceModern(char c) { + switch (c) { + case '*': + return reinterpret_cast( u8"∗" ); + case '\"': + return reinterpret_cast( u8"''" ); + case ':': + return reinterpret_cast( u8"∶" ); + case '/': + return reinterpret_cast( u8"\u2215" ); + case '\\': + return reinterpret_cast( u8"â§µ" ); + case '?': + return reinterpret_cast( u8"?" ); + case '<': + return reinterpret_cast( u8"Ë‚" ); + case '>': + return reinterpret_cast( u8"˃" ); + case '|': + return reinterpret_cast( u8"∣" ); + default: + return "_"; + } +} + +string replaceIllegalPathChars(string fn, charReplace_t replaceIllegalChar) { + string illegal = getIllegalNameChars(); + string separators = getSeparators(); + string_formatter output; + for(t_size walk = 0; walk < fn.length(); ++walk) { + const char c = fn[walk]; + if (separators.contains(c)) { + output.add_byte(getDefaultSeparator()); + } else if (string::isNonTextChar(c) || illegal.contains(c)) { + string replacement = replaceIllegalChar(c); + if (replacement.containsAnyChar(illegal)) /*per-OS weirdness security*/ replacement = "_"; + output << replacement.ptr(); + } else { + output.add_byte(c); + } + } + return output.toString(); +} + +string replaceIllegalNameChars(string fn, bool allowWC, charReplace_t replaceIllegalChar) { + const string illegal = getIllegalNameChars(allowWC); + string_formatter output; + for(t_size walk = 0; walk < fn.length(); ++walk) { + const char c = fn[walk]; + if (string::isNonTextChar(c) || illegal.contains(c)) { + string replacement = replaceIllegalChar(c); + if (replacement.containsAnyChar(illegal)) /*per-OS weirdness security*/ replacement = "_"; + output << replacement.ptr(); + } else { + output.add_byte(c); + } + } + return output.toString(); +} + +bool isInsideDirectory(pfc::string directory, pfc::string inside) { + //not very efficient + string walk = inside; + for(;;) { + walk = getParent(walk); + if (walk == "") return false; + if (equals(directory,walk)) return true; + } +} +bool isDirectoryRoot(string path) { + return getParent(path).isEmpty(); +} +//OS-dependant part starts here + + +char getDefaultSeparator() { +#ifdef _WINDOWS + return '\\'; +#else + return '/'; +#endif +} + +#ifdef _WINDOWS +#define KIllegalNameCharsEx ":<>\"" +#else +// Mac OS allows : in filenames but does funny things presenting them in Finder, so don't use it +#define KIllegalNameCharsEx ":" +#endif + +#define KWildcardChars "*?" + +#define KIllegalNameChars KPathSeparators KIllegalNameCharsEx KWildcardChars +#define KIllegalNameChars_noWC KPathSeparators KIllegalNameCharsEx + +static string g_illegalNameChars ( KIllegalNameChars ); +static string g_illegalNameChars_noWC ( KIllegalNameChars_noWC ); + +string getIllegalNameChars(bool allowWC) { + return allowWC ? g_illegalNameChars_noWC : g_illegalNameChars; +} + +#ifdef _WINDOWS +static const char * const specialIllegalNames[] = { + "con", "aux", "lst", "prn", "nul", "eof", "inp", "out" +}; +#endif // _WINDOWS + +#ifdef _WIN32 +static constexpr unsigned maxPathComponent = 255; +#else +static constexpr unsigned maxPathComponent = NAME_MAX; +#endif + +static size_t safeTruncat( const char * str, size_t maxLen ) { + size_t i = 0; + size_t ret = 0; + for( ; i < maxLen; ++ i ) { + auto d = pfc::utf8_char_len( str + ret ); + if ( d == 0 ) break; + ret += d; + } + return ret; +} + +static size_t utf8_length( const char * str ) { + size_t ret = 0; + for (; ++ret;) { + size_t d = pfc::utf8_char_len( str ); + if ( d == 0 ) break; + str += d; + } + return ret; +} +static string truncatePathComponent( string name, bool preserveExt ) { + + if (name.length() <= maxPathComponent) return name; + if (preserveExt) { + auto dot = name.lastIndexOf('.'); + if (dot != pfc_infinite) { + const auto ext = name.subString(dot); + const auto extLen = utf8_length( ext.c_str() ); + if (extLen < maxPathComponent) { + auto lim = maxPathComponent - extLen; + lim = safeTruncat( name.c_str(), lim ); + if (lim < dot) { + return name.subString(0, lim) + ext; + } + } + } + } + + size_t truncat = safeTruncat( name.c_str(), maxPathComponent ); + return name.subString(0, truncat); +} + +static string trailingSanity(string name, bool preserveExt, const char * lstIllegal) { + + const auto isIllegalTrailingChar = [lstIllegal](char c) { + return strchr(lstIllegal, c) != nullptr; + }; + + t_size end = name.length(); + if (preserveExt) { + size_t offset = pfc::string_find_last(name.c_str(), '.'); + if (offset < end) end = offset; + } + const size_t endEx = end; + while (end > 0) { + if (!isIllegalTrailingChar(name[end - 1])) break; + --end; + } + t_size begin = 0; + while (begin < end) { + if (!isIllegalTrailingChar(name[begin])) break; + ++begin; + } + if (end < endEx || begin > 0) { + name = name.subString(begin, end - begin) + name.subString(endEx); + } + return name; +} +string validateFileName(string name, bool allowWC, bool preserveExt, charReplace_t replaceIllegalChar) { + if (!allowWC) { // special fix for filenames that consist only of question marks + size_t end = name.length(); + if (preserveExt) { + size_t offset = pfc::string_find_last(name.c_str(), '.'); + if (offset < end) end = offset; + } + bool unnamed = true; + for (size_t walk = 0; walk < end; ++walk) { + if (name[walk] != '?') unnamed = false; + } + if (unnamed) { + name = string("[unnamed]") + name.subString(end); + } + } + + // Trailing sanity AFTER replaceIllegalNameChars + // replaceIllegalNameChars may remove chars exposing illegal prefix/suffix chars + name = replaceIllegalNameChars(name, allowWC, replaceIllegalChar); + if (name.length() > 0 && !allowWC) { + const char* lstIllegal = preserveExt ? "" : " ."; + name = trailingSanity(name, preserveExt, lstIllegal); + } + + name = truncatePathComponent(name, preserveExt); + +#ifdef _WINDOWS + for( auto p : specialIllegalNames ) { + if (pfc::stringEqualsI_ascii( name.c_str(), p ) ) { + name += "-"; + break; + } + } +#endif + + if (name.isEmpty()) name = "_"; + return name; +} + +}}} // namespaces diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/pathUtils.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/pathUtils.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,42 @@ +#pragma once + +#include +#include "string_base.h" + +namespace pfc { + namespace io { + namespace path { +#ifdef _WINDOWS + typedef string::comparatorCaseInsensitive comparator; +#else + typedef string::comparatorCaseSensitive comparator; // wild assumption +#endif + + + typedef std::function charReplace_t; + + const char * charReplaceDefault(char); + const char * charReplaceModern(char); + + string getFileName(string path); + string getFileNameWithoutExtension(string path); + string getFileExtension(string path); + string getParent(string filePath); + string getDirectory(string filePath);//same as getParent() + string combine(string basePath,string fileName); + char getDefaultSeparator(); + string getSeparators(); + bool isSeparator(char c); + string getIllegalNameChars(bool allowWC = false); + string replaceIllegalNameChars(string fn, bool allowWC = false, charReplace_t replace = charReplaceDefault); + string replaceIllegalPathChars(string fn, charReplace_t replace = charReplaceDefault); + bool isInsideDirectory(pfc::string directory, pfc::string inside); + bool isDirectoryRoot(string path); + string validateFileName(string name, bool allowWC = false, bool preserveExt = false, charReplace_t replace = charReplaceDefault);//removes various illegal things from the name, exact effect depends on the OS, includes removal of the invalid characters + + template inline bool equals(const t1 & v1, const t2 & v2) {return comparator::compare(v1,v2) == 0;} + + template inline int compare( t1 const & p1, t2 const & p2 ) {return comparator::compare(p1, p2); } + } + } +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/pfc-fb2k-hooks.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/pfc-fb2k-hooks.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,4 @@ +#include "pfc-lite.h" +#include "pfc-fb2k-hooks.h" + +#include "suppress_fb2k_hooks.h" diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/pfc-fb2k-hooks.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/pfc-fb2k-hooks.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,10 @@ +#pragma once + +namespace pfc { + [[noreturn]] void crashImpl(); + [[noreturn]] void crashHook(); +#ifdef _WIN32 + BOOL winFormatSystemErrorMessageImpl(pfc::string_base & p_out, DWORD p_code); + BOOL winFormatSystemErrorMessageHook(pfc::string_base & p_out, DWORD p_code); +#endif +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/pfc-license.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/pfc-license.txt Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,17 @@ +Copyright (C) 2002-2024 Peter Pawlowski + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/pfc-lite.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/pfc-lite.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,186 @@ +#pragma once + + +#ifdef _MSC_VER // MSVC sucks, doesn't set __cplusplus properly by default +#if _MSVC_LANG < 201703L +#error C++17 please +#endif +#else // not MSVC +#if __cplusplus < 201703L +#error C++17 please +#endif +#endif + +// Global flag - whether it's OK to leak static objects as they'll be released anyway by process death +#ifndef PFC_LEAK_STATIC_OBJECTS +#define PFC_LEAK_STATIC_OBJECTS 1 +#endif + + +#ifdef __clang__ +// Suppress a warning for a common practice in pfc/fb2k code +#pragma clang diagnostic ignored "-Wdelete-non-virtual-dtor" +#endif + +#if !defined(_WINDOWS) && (defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64) || defined(_WIN32_WCE)) +#define _WINDOWS +#endif + + +#ifdef _WINDOWS +#include "targetver.h" + +#ifndef STRICT +#define STRICT +#endif + +#ifndef _SYS_GUID_OPERATOR_EQ_ +#define _NO_SYS_GUID_OPERATOR_EQ_ //fix retarded warning with operator== on GUID returning int +#endif + +// WinSock2.h *before* Windows.h or else VS2017 15.3 breaks +#include +#include + +#if !defined(PFC_WINDOWS_STORE_APP) && !defined(PFC_WINDOWS_DESKTOP_APP) + +#ifdef WINAPI_FAMILY_PARTITION +#if ! WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) +#define PFC_WINDOWS_STORE_APP // Windows store or Windows phone app, not a desktop app +#endif // #if ! WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) +#endif // #ifdef WINAPI_FAMILY_PARTITION + +#ifndef PFC_WINDOWS_STORE_APP +#define PFC_WINDOWS_DESKTOP_APP +#endif + +#endif // #if !defined(PFC_WINDOWS_STORE_APP) && !defined(PFC_WINDOWS_DESKTOP_APP) + +#ifndef _SYS_GUID_OPERATOR_EQ_ +__inline bool __InlineIsEqualGUID(REFGUID rguid1, REFGUID rguid2) +{ + return ( + ((unsigned long*)&rguid1)[0] == ((unsigned long*)&rguid2)[0] && + ((unsigned long*)&rguid1)[1] == ((unsigned long*)&rguid2)[1] && + ((unsigned long*)&rguid1)[2] == ((unsigned long*)&rguid2)[2] && + ((unsigned long*)&rguid1)[3] == ((unsigned long*)&rguid2)[3]); +} + +inline bool operator==(REFGUID guidOne, REFGUID guidOther) { return __InlineIsEqualGUID(guidOne, guidOther); } +inline bool operator!=(REFGUID guidOne, REFGUID guidOther) { return !__InlineIsEqualGUID(guidOne, guidOther); } +#endif + +#include + +#else // not Windows + +#include +#include +#include +#include // memcmp + +#ifndef GUID_DEFINED +#define GUID_DEFINED + + +struct GUID { + uint32_t Data1; + uint16_t Data2; + uint16_t Data3; + uint8_t Data4[ 8 ]; +} __attribute__((packed)); + +inline bool operator==(const GUID & p_item1,const GUID & p_item2) { + return memcmp(&p_item1,&p_item2,sizeof(GUID)) == 0; +} + +inline bool operator!=(const GUID & p_item1,const GUID & p_item2) { + return memcmp(&p_item1,&p_item2,sizeof(GUID)) != 0; +} + +#endif // GUID_DEFINED + +#endif + + + +#define PFC_MEMORY_SPACE_LIMIT ((t_uint64)1<<(sizeof(void*)*8-1)) + +#define PFC_ALLOCA_LIMIT (4096) + +#include +#include +#include + +#define _PFC_WIDESTRING(_String) L ## _String +#define PFC_WIDESTRING(_String) _PFC_WIDESTRING(_String) + +#if defined(_DEBUG) || defined(DEBUG) +#define PFC_DEBUG 1 +#else +#define PFC_DEBUG 0 +#endif + +#if ! PFC_DEBUG + +#ifndef NDEBUG +#pragma message("WARNING: release build without NDEBUG") +#endif + +#define PFC_ASSERT(_Expression) ((void)0) +#define PFC_ASSERT_SUCCESS(_Expression) (void)( (_Expression), 0) +#define PFC_ASSERT_NO_EXCEPTION(_Expression) { _Expression; } +#else + +#ifdef _WIN32 +namespace pfc { void myassert_win32(const wchar_t* _Message, const wchar_t* _File, unsigned _Line); } +#define PFC_ASSERT(_Expression) (void)( (!!(_Expression)) || (pfc::myassert_win32(PFC_WIDESTRING(#_Expression), PFC_WIDESTRING(__FILE__), __LINE__), 0) ) +#define PFC_ASSERT_SUCCESS(_Expression) PFC_ASSERT(_Expression) +#else +namespace pfc { void myassert(const char* _Message, const char* _File, unsigned _Line); } +#define PFC_ASSERT(_Expression) (void)( (!!(_Expression)) || (pfc::myassert(#_Expression, __FILE__, __LINE__), 0) ) +#define PFC_ASSERT_SUCCESS(_Expression) PFC_ASSERT( _Expression ) +#endif + +#define PFC_ASSERT_NO_EXCEPTION(_Expression) { try { _Expression; } catch(...) { PFC_ASSERT(!"Should not get here - unexpected exception"); } } +#endif + +#ifdef _MSC_VER + +#if PFC_DEBUG +#define NOVTABLE +#else +#define NOVTABLE _declspec(novtable) +#endif + +#if PFC_DEBUG +#define ASSUME(X) PFC_ASSERT(X) +#else +#define ASSUME(X) __assume(X) +#endif + +#define PFC_DEPRECATE(X) // __declspec(deprecated(X)) don't do this since VS2015 defaults to erroring these +#define PFC_NORETURN __declspec(noreturn) +#define PFC_NOINLINE __declspec(noinline) +#else // else not MSVC + +#define NOVTABLE +#define ASSUME(X) PFC_ASSERT(X) +#define PFC_DEPRECATE(X) +#define PFC_NORETURN __attribute__ ((noreturn)) +#define PFC_NOINLINE + +#endif // end not MSVC + +#include "int_types.h" +#include "string-interface.h" +#include "string-lite.h" + +namespace pfc { + // forward types + class bit_array; + class bit_array_var; + + template class list_base_const_t; + template class list_base_t; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/pfc-readme.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/pfc-readme.txt Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,9 @@ +PFC : Peter's Foundation Classes + +A library of loosely connected classes used by foobar2000 codebase; freely available and reusable for other projects. + +PFC is not state-of-art code. Many parts of it exist only to keep old bits of foobar2000 codebase ( also third party foobar2000 components ) compiling without modification. For an example, certain classes predating 'pfc' namespace use exist outside the namespace. + +Regarding build configurations- +"Release FB2K" and "Debug FB2K" suppress the compilation of pfc-fb2k-hooks.cpp - which allows relevant calls to be redirected to shared.dll +These configurations should be used when compiling fb2k components. Regular configurations should be used for non fb2k apps instead. \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/pfc.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/pfc.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,74 @@ +#ifndef ___PFC_H___ +#define ___PFC_H___ + +#include "pfc-lite.h" + +#include "int_types.h" +#include "mem_block.h" +#include "traits.h" +#include "bit_array.h" +#include "primitives.h" +#include "alloc.h" +#include "array.h" +#include "bit_array_impl.h" +#include "binary_search.h" +#include "bsearch_inline.h" +#include "bsearch.h" +#include "sort.h" +#include "order_helper.h" +#include "list.h" +#include "ptr_list.h" +#include "string-lite.h" +#include "string_base.h" +#include "splitString.h" +#include "string_list.h" +#include "lockless.h" +#include "ref_counter.h" +#include "iterators.h" +#include "avltree.h" +#include "map.h" +#include "bit_array_impl_part2.h" +#include "timers.h" +#include "guid.h" +#include "byte_order.h" +#include "debug.h" +#include "ptrholder.h" +#include "fpu.h" +#include "other.h" +#include "chain_list_v2.h" +#include "rcptr.h" +#include "com_ptr_t.h" +#include "string_conv.h" +#include "pathUtils.h" +#include "threads.h" +#include "base64.h" +#include "primitives_part2.h" +#include "cpuid.h" +#include "memalign.h" + +#include "synchro.h" + +#include "syncd_storage.h" + +#include "platform-objects.h" + +#include "event.h" + +#include "audio_sample.h" +#include "wildcard.h" +#include "filehandle.h" +#include "bigmem.h" + +#include "string_simple.h" + +#define PFC_INCLUDED 1 + +namespace pfc { + void selftest(); +} + +#ifndef PFC_SET_THREAD_DESCRIPTION +#define PFC_SET_THREAD_DESCRIPTION(X) +#endif + +#endif //___PFC_H___ diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/pfc.vcxproj --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/pfc.vcxproj Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,1018 @@ + + + + + Debug FB2K + ARM64 + + + Debug FB2K + ARM64EC + + + Debug + ARM64 + + + Debug + ARM64EC + + + Debug + Win32 + + + Debug + x64 + + + Debug FB2K + Win32 + + + Debug FB2K + x64 + + + Release FB2K + ARM64 + + + Release FB2K + ARM64EC + + + Release FB2K + Win32 + + + Release FB2K + x64 + + + Release + ARM64 + + + Release + ARM64EC + + + Release + Win32 + + + Release + x64 + + + + {EBFFFB4E-261D-44D3-B89C-957B31A0BF9C} + pfc + 10.0 + + + + StaticLibrary + true + v142 + Unicode + + + StaticLibrary + true + v142 + Unicode + + + StaticLibrary + true + v142 + Unicode + + + StaticLibrary + true + v143 + Unicode + + + StaticLibrary + true + v143 + Unicode + + + StaticLibrary + true + v142 + Unicode + + + StaticLibrary + true + v143 + Unicode + + + StaticLibrary + true + v143 + Unicode + + + StaticLibrary + v142 + Unicode + + + StaticLibrary + v142 + Unicode + + + StaticLibrary + v142 + Unicode + + + StaticLibrary + v143 + Unicode + + + StaticLibrary + v143 + Unicode + + + StaticLibrary + v142 + Unicode + + + StaticLibrary + v143 + Unicode + + + StaticLibrary + v143 + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + + + + Disabled + EnableFastChecks + Use + pfc-lite.h + Level3 + true + ProgramDatabase + MultiThreadedDebugDLL + 4715 + true + false + Fast + stdcpp17 + true + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + + + + + Disabled + EnableFastChecks + Use + pfc-lite.h + Level3 + true + ProgramDatabase + MultiThreadedDebugDLL + 4715 + true + false + Fast + stdcpp17 + true + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + + + + + Disabled + EnableFastChecks + Use + pfc-lite.h + Level3 + true + ProgramDatabase + MultiThreadedDebugDLL + 4715 + true + false + stdcpp17 + true + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + + + + + Disabled + EnableFastChecks + Use + pfc-lite.h + Level3 + true + ProgramDatabase + MultiThreadedDebugDLL + 4715 + true + false + stdcpp17 + true + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + + + + + Disabled + EnableFastChecks + Use + pfc-lite.h + Level3 + true + ProgramDatabase + MultiThreadedDebugDLL + 4715 + true + false + stdcpp17 + true + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + + + + + Disabled + EnableFastChecks + Use + pfc-lite.h + Level3 + true + ProgramDatabase + MultiThreadedDebugDLL + 4715 + true + false + stdcpp17 + true + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + + + + + Disabled + EnableFastChecks + Use + pfc-lite.h + Level3 + true + ProgramDatabase + MultiThreadedDebugDLL + 4715 + true + false + stdcpp17 + true + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + + + + + Disabled + EnableFastChecks + Use + pfc-lite.h + Level3 + true + ProgramDatabase + MultiThreadedDebugDLL + 4715 + true + false + stdcpp17 + true + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + + + + + MaxSpeed + true + false + Fast + false + Use + pfc-lite.h + Level3 + true + ProgramDatabase + /d2notypeopt %(AdditionalOptions) + 4715 + true + true + NDEBUG;_UNICODE;UNICODE;%(PreprocessorDefinitions) + stdcpp17 + true + true + MultiThreadedDLL + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + + + + + MaxSpeed + true + false + Fast + false + Use + pfc-lite.h + Level3 + true + ProgramDatabase + /d2notypeopt %(AdditionalOptions) + 4715 + true + true + NDEBUG;_UNICODE;UNICODE;%(PreprocessorDefinitions) + stdcpp17 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + + + + + MaxSpeed + true + false + Fast + false + Use + pfc-lite.h + Level3 + true + ProgramDatabase + MultiThreadedDLL + /d2notypeopt %(AdditionalOptions) + 4715 + true + true + NDEBUG;_UNICODE;UNICODE;%(PreprocessorDefinitions) + stdcpp17 + true + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + + + + + MaxSpeed + true + false + Fast + false + Use + pfc-lite.h + Level3 + true + ProgramDatabase + MultiThreadedDLL + /d2notypeopt %(AdditionalOptions) + 4715 + true + true + NDEBUG;_UNICODE;UNICODE;%(PreprocessorDefinitions) + stdcpp17 + true + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + + + + + MaxSpeed + true + false + Fast + false + Use + pfc-lite.h + Level3 + true + ProgramDatabase + MultiThreadedDLL + /d2notypeopt %(AdditionalOptions) + 4715 + true + true + NDEBUG;_UNICODE;UNICODE;%(PreprocessorDefinitions) + stdcpp17 + true + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + + + + + MaxSpeed + true + false + Fast + false + Use + pfc-lite.h + Level3 + true + ProgramDatabase + MultiThreadedDLL + /d2notypeopt %(AdditionalOptions) + 4715 + true + true + NDEBUG;_UNICODE;UNICODE;%(PreprocessorDefinitions) + stdcpp17 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + + + + + MaxSpeed + true + false + Fast + false + Use + pfc-lite.h + Level3 + true + ProgramDatabase + MultiThreadedDLL + /d2notypeopt %(AdditionalOptions) + 4715 + true + true + NDEBUG;_UNICODE;UNICODE;%(PreprocessorDefinitions) + stdcpp17 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + + + + + MaxSpeed + true + false + Fast + false + Use + pfc-lite.h + Level3 + true + ProgramDatabase + MultiThreadedDLL + /d2notypeopt %(AdditionalOptions) + 4715 + true + true + NDEBUG;_UNICODE;UNICODE;%(PreprocessorDefinitions) + stdcpp17 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Disabled + Disabled + Disabled + Disabled + Disabled + Disabled + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + EnableFastChecks + EnableFastChecks + EnableFastChecks + EnableFastChecks + EnableFastChecks + EnableFastChecks + EnableFastChecks + EnableFastChecks + MaxSpeed + MaxSpeed + MaxSpeed + MaxSpeed + MaxSpeed + MaxSpeed + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + + + + + + + + Disabled + Disabled + Disabled + Disabled + Disabled + Disabled + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + EnableFastChecks + EnableFastChecks + EnableFastChecks + EnableFastChecks + EnableFastChecks + EnableFastChecks + EnableFastChecks + EnableFastChecks + MaxSpeed + MaxSpeed + MaxSpeed + MaxSpeed + MaxSpeed + MaxSpeed + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + Disabled + Disabled + Disabled + Disabled + Disabled + Disabled + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + EnableFastChecks + EnableFastChecks + EnableFastChecks + EnableFastChecks + EnableFastChecks + EnableFastChecks + EnableFastChecks + EnableFastChecks + MaxSpeed + MaxSpeed + MaxSpeed + MaxSpeed + MaxSpeed + MaxSpeed + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + + + + true + true + true + true + true + true + true + true + + + + + + Disabled + Disabled + Disabled + Disabled + Disabled + Disabled + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + EnableFastChecks + EnableFastChecks + EnableFastChecks + EnableFastChecks + EnableFastChecks + EnableFastChecks + EnableFastChecks + EnableFastChecks + MaxSpeed + MaxSpeed + MaxSpeed + MaxSpeed + MaxSpeed + MaxSpeed + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + + + + Disabled + Disabled + Disabled + Disabled + Disabled + Disabled + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + EnableFastChecks + EnableFastChecks + EnableFastChecks + EnableFastChecks + EnableFastChecks + EnableFastChecks + EnableFastChecks + EnableFastChecks + Create + Create + Create + Create + Create + Create + Create + Create + MaxSpeed + MaxSpeed + MaxSpeed + MaxSpeed + MaxSpeed + MaxSpeed + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + Create + Create + Create + Create + Create + Create + Create + Create + + + + + + + + + + + Disabled + Disabled + Disabled + Disabled + Disabled + Disabled + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + EnableFastChecks + EnableFastChecks + EnableFastChecks + EnableFastChecks + EnableFastChecks + EnableFastChecks + EnableFastChecks + EnableFastChecks + MaxSpeed + MaxSpeed + MaxSpeed + MaxSpeed + MaxSpeed + MaxSpeed + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + + + + + + + + + + + + \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/pfc.vcxproj.filters --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/pfc.vcxproj.filters Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,386 @@ + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Doc + + + Doc + + + + + {70b1137d-0c8f-4bb0-8adb-d406ad38bdd0} + + + {225fc8b6-5fca-4e3f-b56e-1ad97e992841} + + + {e1ea3e94-74b7-464e-ab17-69508b52a4e6} + + + \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/pfc.xcodeproj/project.pbxproj --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/pfc.xcodeproj/project.pbxproj Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,903 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 54; + objects = { + +/* Begin PBXBuildFile section */ + 0F0794D427C90AA4006BAD7F /* fixed_map.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F0794CF27C90AA4006BAD7F /* fixed_map.h */; }; + 0F0794D527C90AA4006BAD7F /* charDownConvert.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F0794D027C90AA4006BAD7F /* charDownConvert.h */; }; + 0F0794D627C90AA4006BAD7F /* SmartStrStr-table.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F0794D127C90AA4006BAD7F /* SmartStrStr-table.h */; }; + 0F0794D727C90AA4006BAD7F /* charDownConvert.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F0794D227C90AA4006BAD7F /* charDownConvert.cpp */; }; + 0F0794D827C90AA4006BAD7F /* SmartStrStr-twoCharMappings.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F0794D327C90AA4006BAD7F /* SmartStrStr-twoCharMappings.h */; }; + 0F0794D927C90AA8006BAD7F /* charDownConvert.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F0794D227C90AA4006BAD7F /* charDownConvert.cpp */; }; + 0F14904D242E44C300D0BD81 /* notifyList.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F14904C242E44C300D0BD81 /* notifyList.h */; }; + 0F14904F242E44ED00D0BD81 /* autoref.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F14904E242E44ED00D0BD81 /* autoref.h */; }; + 0F149051242E454C00D0BD81 /* weakRef.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F149050242E454C00D0BD81 /* weakRef.h */; }; + 0F22012C2B0CCEA60074C1FC /* sortstring.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F2201292B0CCEA60074C1FC /* sortstring.h */; }; + 0F22012D2B0CCEA60074C1FC /* string_simple.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F22012A2B0CCEA60074C1FC /* string_simple.h */; }; + 0F22012E2B0CCEA60074C1FC /* sort2.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F22012B2B0CCEA60074C1FC /* sort2.h */; }; + 0F2201322B0CCF3D0074C1FC /* CFObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F2201312B0CCF3D0074C1FC /* CFObject.h */; }; + 0F2F4BF7250BFF660014812D /* pfc-fb2k-hooks.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F2F4BEF250BFF660014812D /* pfc-fb2k-hooks.h */; }; + 0F2F4BF8250BFF660014812D /* killswitch.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F2F4BF0250BFF660014812D /* killswitch.h */; }; + 0F2F4BF9250BFF660014812D /* pfc-fb2k-hooks.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F2F4BF1250BFF660014812D /* pfc-fb2k-hooks.cpp */; }; + 0F2F4BFA250BFF660014812D /* pfc-fb2k-hooks.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F2F4BF1250BFF660014812D /* pfc-fb2k-hooks.cpp */; }; + 0F2F4BFB250BFF660014812D /* stdsort.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F2F4BF2250BFF660014812D /* stdsort.h */; }; + 0F2F4BFC250BFF660014812D /* suppress_fb2k_hooks.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F2F4BF3250BFF660014812D /* suppress_fb2k_hooks.h */; }; + 0F2F4BFD250BFF660014812D /* platform-objects.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F2F4BF4250BFF660014812D /* platform-objects.h */; }; + 0F2F4BFE250BFF660014812D /* pocket_char_ops.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F2F4BF5250BFF660014812D /* pocket_char_ops.h */; }; + 0F2F4BFF250BFF660014812D /* cmd_thread.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F2F4BF6250BFF660014812D /* cmd_thread.h */; }; + 0F54079726C2964500A118C8 /* splitString2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FB717E126C295370040D7FE /* splitString2.cpp */; }; + 0F643510253A250600D6335A /* string-conv-lite.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F64350D253A250600D6335A /* string-conv-lite.h */; }; + 0F643511253A250600D6335A /* pp-winapi.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F64350E253A250600D6335A /* pp-winapi.h */; }; + 0F643512253A250600D6335A /* string-conv-lite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F64350F253A250600D6335A /* string-conv-lite.cpp */; }; + 0F643513253A250600D6335A /* string-conv-lite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F64350F253A250600D6335A /* string-conv-lite.cpp */; }; + 0F65005525122FD5001B03BA /* string-compare.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F65005125122FD5001B03BA /* string-compare.cpp */; }; + 0F65005625122FD5001B03BA /* string-compare.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F65005125122FD5001B03BA /* string-compare.cpp */; }; + 0F65005725122FD5001B03BA /* string-compare.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F65005225122FD5001B03BA /* string-compare.h */; }; + 0F65005825122FD5001B03BA /* string-part.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F65005325122FD5001B03BA /* string-part.h */; }; + 0F65005925122FD5001B03BA /* string-lite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F65005425122FD5001B03BA /* string-lite.cpp */; }; + 0F65005A25122FD5001B03BA /* string-lite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F65005425122FD5001B03BA /* string-lite.cpp */; }; + 0F7A1B6A2A692C88004F89FB /* filetimetools.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F7A1B682A692C88004F89FB /* filetimetools.cpp */; }; + 0F7A1B6B2A692C88004F89FB /* filetimetools.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F7A1B682A692C88004F89FB /* filetimetools.cpp */; }; + 0F7A1B6C2A692C88004F89FB /* filetimetools.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F7A1B692A692C88004F89FB /* filetimetools.h */; }; + 0F7EDDAA27FAFDA5000996AA /* unicode-normalize.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F7EDDA827FAFDA5000996AA /* unicode-normalize.cpp */; }; + 0F7EDDAB27FAFDA5000996AA /* unicode-normalize.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F7EDDA827FAFDA5000996AA /* unicode-normalize.cpp */; }; + 0F7EDDAC27FAFDA5000996AA /* unicode-normalize.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F7EDDA927FAFDA5000996AA /* unicode-normalize.h */; }; + 0FAC031727C8EC6500BA9E97 /* SmartStrStr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FAC031527C8EC6500BA9E97 /* SmartStrStr.cpp */; }; + 0FAC031827C8EC6500BA9E97 /* SmartStrStr.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FAC031627C8EC6500BA9E97 /* SmartStrStr.h */; }; + 0FAC031927C8EC6A00BA9E97 /* SmartStrStr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FAC031527C8EC6500BA9E97 /* SmartStrStr.cpp */; }; + 0FB717E226C295370040D7FE /* splitString2.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FB717E026C295370040D7FE /* splitString2.h */; }; + 0FB717E326C295370040D7FE /* splitString2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FB717E126C295370040D7FE /* splitString2.cpp */; }; + 0FFFAEAE23C9C9580023328B /* crashWithMessage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FFFAEAD23C9C9580023328B /* crashWithMessage.cpp */; }; + 0FFFAEAF23C9DB640023328B /* crashWithMessage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FFFAEAD23C9C9580023328B /* crashWithMessage.cpp */; }; + B10D405B19ADFADB004D2596 /* audio_math.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1D8A0CD198FB83D00A23435 /* audio_math.cpp */; }; + B10D405C19ADFADB004D2596 /* audio_sample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1D8A0CE198FB83D00A23435 /* audio_sample.cpp */; }; + B10D405D19ADFADB004D2596 /* base64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1DD35C6198A702E00EF7043 /* base64.cpp */; }; + B10D405E19ADFADB004D2596 /* bit_array.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1DD35CB198A702E00EF7043 /* bit_array.cpp */; }; + B10D405F19ADFADB004D2596 /* bsearch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1DD35CE198A702E00EF7043 /* bsearch.cpp */; }; + B10D406019ADFADB004D2596 /* cpuid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1DD35D3198A702E00EF7043 /* cpuid.cpp */; }; + B10D406119ADFADB004D2596 /* filehandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1C37D7E19922EF500EE6ABC /* filehandle.cpp */; }; + B10D406219ADFADB004D2596 /* guid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1DD35D6198A702E00EF7043 /* guid.cpp */; }; + B10D406319ADFADB004D2596 /* nix-objects.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1DD35DF198A702E00EF7043 /* nix-objects.cpp */; }; + B10D406419ADFADB004D2596 /* other.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1DD35E3198A702E00EF7043 /* other.cpp */; }; + B10D406519ADFADB004D2596 /* pathUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1DD35E5198A702E00EF7043 /* pathUtils.cpp */; }; + B10D406619ADFADB004D2596 /* printf.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1DD35EA198A702E00EF7043 /* printf.cpp */; }; + B10D406719ADFADB004D2596 /* selftest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1DD35F0198A702E00EF7043 /* selftest.cpp */; }; + B10D406819ADFADB004D2596 /* sort.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1DD35F1198A702E00EF7043 /* sort.cpp */; }; + B10D406919ADFADB004D2596 /* stdafx.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1DD35F3198A702E00EF7043 /* stdafx.cpp */; }; + B10D406A19ADFADB004D2596 /* string_base.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1DD35F7198A702E00EF7043 /* string_base.cpp */; }; + B10D406B19ADFADB004D2596 /* string_conv.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1DD35F4198A702E00EF7043 /* string_conv.cpp */; }; + B10D406D19ADFADB004D2596 /* synchro_nix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1DD35FD198A702E00EF7043 /* synchro_nix.cpp */; }; + B10D406E19ADFADB004D2596 /* threads.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1DD3600198A702E00EF7043 /* threads.cpp */; }; + B10D406F19ADFADB004D2596 /* timers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1DD35EB198A702E00EF7043 /* timers.cpp */; }; + B10D407019ADFADB004D2596 /* utf8.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1DD3603198A702E00EF7043 /* utf8.cpp */; }; + B10D407119ADFADB004D2596 /* wildcard.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1B502D3198FF75000525EAF /* wildcard.cpp */; }; + B10D407219ADFADB004D2596 /* win-objects.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1DD3604198A702E00EF7043 /* win-objects.cpp */; }; + B10D407319ADFE52004D2596 /* obj-c.mm in Sources */ = {isa = PBXBuildFile; fileRef = B1DD35E1198A702E00EF7043 /* obj-c.mm */; }; + B125C8AD1F46D9A900ADB97B /* once.h in Headers */ = {isa = PBXBuildFile; fileRef = B125C8AC1F46D9A900ADB97B /* once.h */; }; + B12CBBC81BD4D96A00952805 /* bigmem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B12CBBC61BD4D96A00952805 /* bigmem.cpp */; }; + B12CBBC91BD4D96A00952805 /* bigmem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B12CBBC61BD4D96A00952805 /* bigmem.cpp */; }; + B12CBBCA1BD4D96A00952805 /* bigmem.h in Headers */ = {isa = PBXBuildFile; fileRef = B12CBBC71BD4D96A00952805 /* bigmem.h */; }; + B16695F719ACC12A0001728F /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B16695F619ACC12A0001728F /* Foundation.framework */; }; + B17EB26E1E85358D0057E2A4 /* pool.h in Headers */ = {isa = PBXBuildFile; fileRef = B17EB26B1E85358D0057E2A4 /* pool.h */; }; + B17EB26F1E85358D0057E2A4 /* splitString.h in Headers */ = {isa = PBXBuildFile; fileRef = B17EB26C1E85358D0057E2A4 /* splitString.h */; }; + B17EB2701E85358D0057E2A4 /* wait_queue.h in Headers */ = {isa = PBXBuildFile; fileRef = B17EB26D1E85358D0057E2A4 /* wait_queue.h */; }; + B1B502D5198FF75000525EAF /* wildcard.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1B502D3198FF75000525EAF /* wildcard.cpp */; }; + B1B502D6198FF75000525EAF /* wildcard.h in Headers */ = {isa = PBXBuildFile; fileRef = B1B502D4198FF75000525EAF /* wildcard.h */; }; + B1C37D7F19922EF500EE6ABC /* filehandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1C37D7E19922EF500EE6ABC /* filehandle.cpp */; }; + B1CF88B71BD6657F00F42F87 /* fpu.h in Headers */ = {isa = PBXBuildFile; fileRef = B1CF88B41BD6657F00F42F87 /* fpu.h */; }; + B1CF88B81BD6657F00F42F87 /* mem_block.h in Headers */ = {isa = PBXBuildFile; fileRef = B1CF88B51BD6657F00F42F87 /* mem_block.h */; }; + B1CF88B91BD6657F00F42F87 /* string-lite.h in Headers */ = {isa = PBXBuildFile; fileRef = B1CF88B61BD6657F00F42F87 /* string-lite.h */; }; + B1D8A0D0198FB83D00A23435 /* audio_math.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1D8A0CD198FB83D00A23435 /* audio_math.cpp */; }; + B1D8A0D1198FB83D00A23435 /* audio_sample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1D8A0CE198FB83D00A23435 /* audio_sample.cpp */; }; + B1D8A0D2198FB83D00A23435 /* audio_sample.h in Headers */ = {isa = PBXBuildFile; fileRef = B1D8A0CF198FB83D00A23435 /* audio_sample.h */; }; + B1DD3606198A702E00EF7043 /* alloc.h in Headers */ = {isa = PBXBuildFile; fileRef = B1DD35C3198A702E00EF7043 /* alloc.h */; }; + B1DD3607198A702E00EF7043 /* array.h in Headers */ = {isa = PBXBuildFile; fileRef = B1DD35C4198A702E00EF7043 /* array.h */; }; + B1DD3608198A702E00EF7043 /* avltree.h in Headers */ = {isa = PBXBuildFile; fileRef = B1DD35C5198A702E00EF7043 /* avltree.h */; }; + B1DD3609198A702E00EF7043 /* base64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1DD35C6198A702E00EF7043 /* base64.cpp */; }; + B1DD360A198A702E00EF7043 /* base64.h in Headers */ = {isa = PBXBuildFile; fileRef = B1DD35C7198A702E00EF7043 /* base64.h */; }; + B1DD360B198A702E00EF7043 /* binary_search.h in Headers */ = {isa = PBXBuildFile; fileRef = B1DD35C8198A702E00EF7043 /* binary_search.h */; }; + B1DD360C198A702E00EF7043 /* bit_array_impl_part2.h in Headers */ = {isa = PBXBuildFile; fileRef = B1DD35C9198A702E00EF7043 /* bit_array_impl_part2.h */; }; + B1DD360D198A702E00EF7043 /* bit_array_impl.h in Headers */ = {isa = PBXBuildFile; fileRef = B1DD35CA198A702E00EF7043 /* bit_array_impl.h */; }; + B1DD360E198A702E00EF7043 /* bit_array.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1DD35CB198A702E00EF7043 /* bit_array.cpp */; }; + B1DD360F198A702E00EF7043 /* bit_array.h in Headers */ = {isa = PBXBuildFile; fileRef = B1DD35CC198A702E00EF7043 /* bit_array.h */; }; + B1DD3610198A702E00EF7043 /* bsearch_inline.h in Headers */ = {isa = PBXBuildFile; fileRef = B1DD35CD198A702E00EF7043 /* bsearch_inline.h */; }; + B1DD3611198A702E00EF7043 /* bsearch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1DD35CE198A702E00EF7043 /* bsearch.cpp */; }; + B1DD3612198A702E00EF7043 /* bsearch.h in Headers */ = {isa = PBXBuildFile; fileRef = B1DD35CF198A702E00EF7043 /* bsearch.h */; }; + B1DD3613198A702E00EF7043 /* byte_order.h in Headers */ = {isa = PBXBuildFile; fileRef = B1DD35D0198A702E00EF7043 /* byte_order.h */; }; + B1DD3614198A702E00EF7043 /* chain_list_v2.h in Headers */ = {isa = PBXBuildFile; fileRef = B1DD35D1198A702E00EF7043 /* chain_list_v2.h */; }; + B1DD3615198A702E00EF7043 /* com_ptr_t.h in Headers */ = {isa = PBXBuildFile; fileRef = B1DD35D2198A702E00EF7043 /* com_ptr_t.h */; }; + B1DD3616198A702E00EF7043 /* cpuid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1DD35D3198A702E00EF7043 /* cpuid.cpp */; }; + B1DD3617198A702E00EF7043 /* cpuid.h in Headers */ = {isa = PBXBuildFile; fileRef = B1DD35D4198A702E00EF7043 /* cpuid.h */; }; + B1DD3618198A702E00EF7043 /* event.h in Headers */ = {isa = PBXBuildFile; fileRef = B1DD35D5198A702E00EF7043 /* event.h */; }; + B1DD3619198A702E00EF7043 /* guid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1DD35D6198A702E00EF7043 /* guid.cpp */; }; + B1DD361A198A702E00EF7043 /* guid.h in Headers */ = {isa = PBXBuildFile; fileRef = B1DD35D7198A702E00EF7043 /* guid.h */; }; + B1DD361C198A702E00EF7043 /* int_types.h in Headers */ = {isa = PBXBuildFile; fileRef = B1DD35D9198A702E00EF7043 /* int_types.h */; }; + B1DD361D198A702E00EF7043 /* iterators.h in Headers */ = {isa = PBXBuildFile; fileRef = B1DD35DA198A702E00EF7043 /* iterators.h */; }; + B1DD361E198A702E00EF7043 /* list.h in Headers */ = {isa = PBXBuildFile; fileRef = B1DD35DB198A702E00EF7043 /* list.h */; }; + B1DD361F198A702E00EF7043 /* map.h in Headers */ = {isa = PBXBuildFile; fileRef = B1DD35DC198A702E00EF7043 /* map.h */; }; + B1DD3621198A702E00EF7043 /* memalign.h in Headers */ = {isa = PBXBuildFile; fileRef = B1DD35DE198A702E00EF7043 /* memalign.h */; }; + B1DD3622198A702E00EF7043 /* nix-objects.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1DD35DF198A702E00EF7043 /* nix-objects.cpp */; }; + B1DD3623198A702E00EF7043 /* nix-objects.h in Headers */ = {isa = PBXBuildFile; fileRef = B1DD35E0198A702E00EF7043 /* nix-objects.h */; }; + B1DD3624198A702E00EF7043 /* obj-c.mm in Sources */ = {isa = PBXBuildFile; fileRef = B1DD35E1198A702E00EF7043 /* obj-c.mm */; }; + B1DD3625198A702E00EF7043 /* order_helper.h in Headers */ = {isa = PBXBuildFile; fileRef = B1DD35E2198A702E00EF7043 /* order_helper.h */; }; + B1DD3626198A702E00EF7043 /* other.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1DD35E3198A702E00EF7043 /* other.cpp */; }; + B1DD3627198A702E00EF7043 /* other.h in Headers */ = {isa = PBXBuildFile; fileRef = B1DD35E4198A702E00EF7043 /* other.h */; }; + B1DD3628198A702E00EF7043 /* pathUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1DD35E5198A702E00EF7043 /* pathUtils.cpp */; }; + B1DD3629198A702E00EF7043 /* pathUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = B1DD35E6198A702E00EF7043 /* pathUtils.h */; }; + B1DD362A198A702E00EF7043 /* pfc.h in Headers */ = {isa = PBXBuildFile; fileRef = B1DD35E7198A702E00EF7043 /* pfc.h */; }; + B1DD362B198A702E00EF7043 /* primitives_part2.h in Headers */ = {isa = PBXBuildFile; fileRef = B1DD35E8198A702E00EF7043 /* primitives_part2.h */; }; + B1DD362C198A702E00EF7043 /* primitives.h in Headers */ = {isa = PBXBuildFile; fileRef = B1DD35E9198A702E00EF7043 /* primitives.h */; }; + B1DD362D198A702E00EF7043 /* printf.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1DD35EA198A702E00EF7043 /* printf.cpp */; }; + B1DD362E198A702E00EF7043 /* timers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1DD35EB198A702E00EF7043 /* timers.cpp */; }; + B1DD362F198A702E00EF7043 /* timers.h in Headers */ = {isa = PBXBuildFile; fileRef = B1DD35EC198A702E00EF7043 /* timers.h */; }; + B1DD3630198A702E00EF7043 /* ptr_list.h in Headers */ = {isa = PBXBuildFile; fileRef = B1DD35ED198A702E00EF7043 /* ptr_list.h */; }; + B1DD3631198A702E00EF7043 /* rcptr.h in Headers */ = {isa = PBXBuildFile; fileRef = B1DD35EE198A702E00EF7043 /* rcptr.h */; }; + B1DD3632198A702E00EF7043 /* ref_counter.h in Headers */ = {isa = PBXBuildFile; fileRef = B1DD35EF198A702E00EF7043 /* ref_counter.h */; }; + B1DD3633198A702E00EF7043 /* selftest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1DD35F0198A702E00EF7043 /* selftest.cpp */; }; + B1DD3634198A702E00EF7043 /* sort.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1DD35F1198A702E00EF7043 /* sort.cpp */; }; + B1DD3635198A702E00EF7043 /* sort.h in Headers */ = {isa = PBXBuildFile; fileRef = B1DD35F2198A702E00EF7043 /* sort.h */; }; + B1DD3636198A702E00EF7043 /* stdafx.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1DD35F3198A702E00EF7043 /* stdafx.cpp */; }; + B1DD3637198A702E00EF7043 /* string_conv.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1DD35F4198A702E00EF7043 /* string_conv.cpp */; }; + B1DD3638198A702E00EF7043 /* string_conv.h in Headers */ = {isa = PBXBuildFile; fileRef = B1DD35F5198A702E00EF7043 /* string_conv.h */; }; + B1DD3639198A702E00EF7043 /* string_list.h in Headers */ = {isa = PBXBuildFile; fileRef = B1DD35F6198A702E00EF7043 /* string_list.h */; }; + B1DD363A198A702E00EF7043 /* string_base.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1DD35F7198A702E00EF7043 /* string_base.cpp */; }; + B1DD363B198A702E00EF7043 /* string_base.h in Headers */ = {isa = PBXBuildFile; fileRef = B1DD35F8198A702E00EF7043 /* string_base.h */; }; + B1DD363F198A702E00EF7043 /* syncd_storage.h in Headers */ = {isa = PBXBuildFile; fileRef = B1DD35FC198A702E00EF7043 /* syncd_storage.h */; }; + B1DD3640198A702E00EF7043 /* synchro_nix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1DD35FD198A702E00EF7043 /* synchro_nix.cpp */; }; + B1DD3641198A702E00EF7043 /* synchro_nix.h in Headers */ = {isa = PBXBuildFile; fileRef = B1DD35FE198A702E00EF7043 /* synchro_nix.h */; }; + B1DD3642198A702E00EF7043 /* synchro_win.h in Headers */ = {isa = PBXBuildFile; fileRef = B1DD35FF198A702E00EF7043 /* synchro_win.h */; }; + B1DD3643198A702E00EF7043 /* threads.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1DD3600198A702E00EF7043 /* threads.cpp */; }; + B1DD3644198A702E00EF7043 /* threads.h in Headers */ = {isa = PBXBuildFile; fileRef = B1DD3601198A702E00EF7043 /* threads.h */; }; + B1DD3645198A702E00EF7043 /* traits.h in Headers */ = {isa = PBXBuildFile; fileRef = B1DD3602198A702E00EF7043 /* traits.h */; }; + B1DD3646198A702E00EF7043 /* utf8.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1DD3603198A702E00EF7043 /* utf8.cpp */; }; + B1DD3647198A702E00EF7043 /* win-objects.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1DD3604198A702E00EF7043 /* win-objects.cpp */; }; + B1DD3648198A702E00EF7043 /* win-objects.h in Headers */ = {isa = PBXBuildFile; fileRef = B1DD3605198A702E00EF7043 /* win-objects.h */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + B16695F219ACC12A0001728F /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = "include/$(PRODUCT_NAME)"; + dstSubfolderSpec = 16; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 0F0794CF27C90AA4006BAD7F /* fixed_map.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fixed_map.h; sourceTree = ""; }; + 0F0794D027C90AA4006BAD7F /* charDownConvert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = charDownConvert.h; sourceTree = ""; }; + 0F0794D127C90AA4006BAD7F /* SmartStrStr-table.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "SmartStrStr-table.h"; sourceTree = ""; }; + 0F0794D227C90AA4006BAD7F /* charDownConvert.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = charDownConvert.cpp; sourceTree = ""; }; + 0F0794D327C90AA4006BAD7F /* SmartStrStr-twoCharMappings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "SmartStrStr-twoCharMappings.h"; sourceTree = ""; }; + 0F14904C242E44C300D0BD81 /* notifyList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = notifyList.h; sourceTree = ""; }; + 0F14904E242E44ED00D0BD81 /* autoref.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = autoref.h; sourceTree = ""; }; + 0F149050242E454C00D0BD81 /* weakRef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = weakRef.h; sourceTree = ""; }; + 0F17B3DA2B5E8F0E00FC86C1 /* event_std.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = event_std.h; sourceTree = ""; }; + 0F2201292B0CCEA60074C1FC /* sortstring.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sortstring.h; sourceTree = ""; }; + 0F22012A2B0CCEA60074C1FC /* string_simple.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = string_simple.h; sourceTree = ""; }; + 0F22012B2B0CCEA60074C1FC /* sort2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sort2.h; sourceTree = ""; }; + 0F2201312B0CCF3D0074C1FC /* CFObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFObject.h; sourceTree = ""; }; + 0F2F4BEF250BFF660014812D /* pfc-fb2k-hooks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "pfc-fb2k-hooks.h"; sourceTree = ""; }; + 0F2F4BF0250BFF660014812D /* killswitch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = killswitch.h; sourceTree = ""; }; + 0F2F4BF1250BFF660014812D /* pfc-fb2k-hooks.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "pfc-fb2k-hooks.cpp"; sourceTree = ""; }; + 0F2F4BF2250BFF660014812D /* stdsort.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = stdsort.h; sourceTree = ""; }; + 0F2F4BF3250BFF660014812D /* suppress_fb2k_hooks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = suppress_fb2k_hooks.h; sourceTree = ""; }; + 0F2F4BF4250BFF660014812D /* platform-objects.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "platform-objects.h"; sourceTree = ""; }; + 0F2F4BF5250BFF660014812D /* pocket_char_ops.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pocket_char_ops.h; sourceTree = ""; }; + 0F2F4BF6250BFF660014812D /* cmd_thread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cmd_thread.h; sourceTree = ""; }; + 0F64350D253A250600D6335A /* string-conv-lite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "string-conv-lite.h"; sourceTree = ""; }; + 0F64350E253A250600D6335A /* pp-winapi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "pp-winapi.h"; sourceTree = ""; }; + 0F64350F253A250600D6335A /* string-conv-lite.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "string-conv-lite.cpp"; sourceTree = ""; }; + 0F65005125122FD5001B03BA /* string-compare.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "string-compare.cpp"; sourceTree = ""; }; + 0F65005225122FD5001B03BA /* string-compare.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "string-compare.h"; sourceTree = ""; }; + 0F65005325122FD5001B03BA /* string-part.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "string-part.h"; sourceTree = ""; }; + 0F65005425122FD5001B03BA /* string-lite.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "string-lite.cpp"; sourceTree = ""; }; + 0F7A1B682A692C88004F89FB /* filetimetools.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = filetimetools.cpp; sourceTree = ""; }; + 0F7A1B692A692C88004F89FB /* filetimetools.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = filetimetools.h; sourceTree = ""; }; + 0F7EDDA827FAFDA5000996AA /* unicode-normalize.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = "unicode-normalize.cpp"; sourceTree = ""; }; + 0F7EDDA927FAFDA5000996AA /* unicode-normalize.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "unicode-normalize.h"; sourceTree = ""; }; + 0FAC031527C8EC6500BA9E97 /* SmartStrStr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SmartStrStr.cpp; sourceTree = ""; }; + 0FAC031627C8EC6500BA9E97 /* SmartStrStr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SmartStrStr.h; sourceTree = ""; }; + 0FB717E026C295370040D7FE /* splitString2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = splitString2.h; sourceTree = ""; }; + 0FB717E126C295370040D7FE /* splitString2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = splitString2.cpp; sourceTree = ""; }; + 0FFFAEAD23C9C9580023328B /* crashWithMessage.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = crashWithMessage.cpp; sourceTree = ""; }; + B125C8AC1F46D9A900ADB97B /* once.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = once.h; sourceTree = ""; }; + B12CBBB61BD3F08800952805 /* pfc-lite.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "pfc-lite.h"; sourceTree = ""; }; + B12CBBB71BD3F0D100952805 /* string-interface.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "string-interface.h"; sourceTree = ""; }; + B12CBBB91BD4A01400952805 /* debug.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = debug.h; sourceTree = ""; }; + B12CBBC61BD4D96A00952805 /* bigmem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = bigmem.cpp; sourceTree = ""; }; + B12CBBC71BD4D96A00952805 /* bigmem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bigmem.h; sourceTree = ""; }; + B12CBBD01BD4DD4600952805 /* ptrholder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ptrholder.h; sourceTree = ""; }; + B12CBBD11BD4DE8100952805 /* synchro.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = synchro.h; sourceTree = ""; }; + B16695F419ACC12A0001728F /* libpfc-iOS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libpfc-iOS.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + B16695F619ACC12A0001728F /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + B166960419ACC12A0001728F /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; + B166960719ACC12A0001728F /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; }; + B17EB26B1E85358D0057E2A4 /* pool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pool.h; sourceTree = ""; }; + B17EB26C1E85358D0057E2A4 /* splitString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = splitString.h; sourceTree = ""; }; + B17EB26D1E85358D0057E2A4 /* wait_queue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wait_queue.h; sourceTree = ""; }; + B1B502D3198FF75000525EAF /* wildcard.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wildcard.cpp; sourceTree = ""; }; + B1B502D4198FF75000525EAF /* wildcard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wildcard.h; sourceTree = ""; }; + B1C37D7D19922EEB00EE6ABC /* filehandle.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = filehandle.h; sourceTree = ""; }; + B1C37D7E19922EF500EE6ABC /* filehandle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = filehandle.cpp; sourceTree = ""; }; + B1CF88B41BD6657F00F42F87 /* fpu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fpu.h; sourceTree = ""; }; + B1CF88B51BD6657F00F42F87 /* mem_block.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mem_block.h; sourceTree = ""; }; + B1CF88B61BD6657F00F42F87 /* string-lite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "string-lite.h"; sourceTree = ""; }; + B1D8A0CD198FB83D00A23435 /* audio_math.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = audio_math.cpp; sourceTree = ""; }; + B1D8A0CE198FB83D00A23435 /* audio_sample.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = audio_sample.cpp; sourceTree = ""; }; + B1D8A0CF198FB83D00A23435 /* audio_sample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = audio_sample.h; sourceTree = ""; }; + B1DD35AF198A6FAA00EF7043 /* libpfc-Mac.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libpfc-Mac.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + B1DD35C3198A702E00EF7043 /* alloc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = alloc.h; sourceTree = ""; }; + B1DD35C4198A702E00EF7043 /* array.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = array.h; sourceTree = ""; }; + B1DD35C5198A702E00EF7043 /* avltree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = avltree.h; sourceTree = ""; }; + B1DD35C6198A702E00EF7043 /* base64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = base64.cpp; sourceTree = ""; }; + B1DD35C7198A702E00EF7043 /* base64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = base64.h; sourceTree = ""; }; + B1DD35C8198A702E00EF7043 /* binary_search.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = binary_search.h; sourceTree = ""; }; + B1DD35C9198A702E00EF7043 /* bit_array_impl_part2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bit_array_impl_part2.h; sourceTree = ""; }; + B1DD35CA198A702E00EF7043 /* bit_array_impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bit_array_impl.h; sourceTree = ""; }; + B1DD35CB198A702E00EF7043 /* bit_array.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = bit_array.cpp; sourceTree = ""; }; + B1DD35CC198A702E00EF7043 /* bit_array.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bit_array.h; sourceTree = ""; }; + B1DD35CD198A702E00EF7043 /* bsearch_inline.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bsearch_inline.h; sourceTree = ""; }; + B1DD35CE198A702E00EF7043 /* bsearch.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = bsearch.cpp; sourceTree = ""; }; + B1DD35CF198A702E00EF7043 /* bsearch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bsearch.h; sourceTree = ""; }; + B1DD35D0198A702E00EF7043 /* byte_order.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = byte_order.h; sourceTree = ""; }; + B1DD35D1198A702E00EF7043 /* chain_list_v2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = chain_list_v2.h; sourceTree = ""; }; + B1DD35D2198A702E00EF7043 /* com_ptr_t.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = com_ptr_t.h; sourceTree = ""; }; + B1DD35D3198A702E00EF7043 /* cpuid.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cpuid.cpp; sourceTree = ""; }; + B1DD35D4198A702E00EF7043 /* cpuid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cpuid.h; sourceTree = ""; }; + B1DD35D5198A702E00EF7043 /* event.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = event.h; sourceTree = ""; }; + B1DD35D6198A702E00EF7043 /* guid.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = guid.cpp; sourceTree = ""; }; + B1DD35D7198A702E00EF7043 /* guid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = guid.h; sourceTree = ""; }; + B1DD35D9198A702E00EF7043 /* int_types.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = int_types.h; sourceTree = ""; }; + B1DD35DA198A702E00EF7043 /* iterators.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = iterators.h; sourceTree = ""; }; + B1DD35DB198A702E00EF7043 /* list.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = list.h; sourceTree = ""; }; + B1DD35DC198A702E00EF7043 /* map.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = map.h; sourceTree = ""; }; + B1DD35DE198A702E00EF7043 /* memalign.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = memalign.h; sourceTree = ""; }; + B1DD35DF198A702E00EF7043 /* nix-objects.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "nix-objects.cpp"; sourceTree = ""; }; + B1DD35E0198A702E00EF7043 /* nix-objects.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "nix-objects.h"; sourceTree = ""; }; + B1DD35E1198A702E00EF7043 /* obj-c.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "obj-c.mm"; sourceTree = ""; }; + B1DD35E2198A702E00EF7043 /* order_helper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = order_helper.h; sourceTree = ""; }; + B1DD35E3198A702E00EF7043 /* other.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = other.cpp; sourceTree = ""; }; + B1DD35E4198A702E00EF7043 /* other.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = other.h; sourceTree = ""; }; + B1DD35E5198A702E00EF7043 /* pathUtils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = pathUtils.cpp; sourceTree = ""; }; + B1DD35E6198A702E00EF7043 /* pathUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pathUtils.h; sourceTree = ""; }; + B1DD35E7198A702E00EF7043 /* pfc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pfc.h; sourceTree = ""; }; + B1DD35E8198A702E00EF7043 /* primitives_part2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = primitives_part2.h; sourceTree = ""; }; + B1DD35E9198A702E00EF7043 /* primitives.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = primitives.h; sourceTree = ""; }; + B1DD35EA198A702E00EF7043 /* printf.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = printf.cpp; sourceTree = ""; }; + B1DD35EB198A702E00EF7043 /* timers.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = timers.cpp; sourceTree = ""; }; + B1DD35EC198A702E00EF7043 /* timers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = timers.h; sourceTree = ""; }; + B1DD35ED198A702E00EF7043 /* ptr_list.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ptr_list.h; sourceTree = ""; }; + B1DD35EE198A702E00EF7043 /* rcptr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = rcptr.h; sourceTree = ""; }; + B1DD35EF198A702E00EF7043 /* ref_counter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ref_counter.h; sourceTree = ""; }; + B1DD35F0198A702E00EF7043 /* selftest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = selftest.cpp; sourceTree = ""; }; + B1DD35F1198A702E00EF7043 /* sort.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sort.cpp; sourceTree = ""; }; + B1DD35F2198A702E00EF7043 /* sort.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sort.h; sourceTree = ""; }; + B1DD35F3198A702E00EF7043 /* stdafx.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = stdafx.cpp; sourceTree = ""; }; + B1DD35F4198A702E00EF7043 /* string_conv.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = string_conv.cpp; sourceTree = ""; }; + B1DD35F5198A702E00EF7043 /* string_conv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = string_conv.h; sourceTree = ""; }; + B1DD35F6198A702E00EF7043 /* string_list.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = string_list.h; sourceTree = ""; }; + B1DD35F7198A702E00EF7043 /* string_base.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = string_base.cpp; sourceTree = ""; }; + B1DD35F8198A702E00EF7043 /* string_base.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = string_base.h; sourceTree = ""; }; + B1DD35FC198A702E00EF7043 /* syncd_storage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = syncd_storage.h; sourceTree = ""; }; + B1DD35FD198A702E00EF7043 /* synchro_nix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = synchro_nix.cpp; sourceTree = ""; }; + B1DD35FE198A702E00EF7043 /* synchro_nix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = synchro_nix.h; sourceTree = ""; }; + B1DD35FF198A702E00EF7043 /* synchro_win.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = synchro_win.h; sourceTree = ""; }; + B1DD3600198A702E00EF7043 /* threads.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = threads.cpp; sourceTree = ""; }; + B1DD3601198A702E00EF7043 /* threads.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = threads.h; sourceTree = ""; }; + B1DD3602198A702E00EF7043 /* traits.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = traits.h; sourceTree = ""; }; + B1DD3603198A702E00EF7043 /* utf8.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = utf8.cpp; sourceTree = ""; }; + B1DD3604198A702E00EF7043 /* win-objects.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "win-objects.cpp"; sourceTree = ""; }; + B1DD3605198A702E00EF7043 /* win-objects.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "win-objects.h"; sourceTree = ""; }; + B1EFBAC51B90658600C2CE84 /* lockless.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = lockless.h; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + B16695F119ACC12A0001728F /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + B16695F719ACC12A0001728F /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + B1DD35AC198A6FAA00EF7043 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + B16695F519ACC12A0001728F /* Frameworks */ = { + isa = PBXGroup; + children = ( + B16695F619ACC12A0001728F /* Foundation.framework */, + B166960419ACC12A0001728F /* XCTest.framework */, + B166960719ACC12A0001728F /* UIKit.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + B1DD35A6198A6FAA00EF7043 = { + isa = PBXGroup; + children = ( + B1DD35C2198A701100EF7043 /* Source */, + B16695F519ACC12A0001728F /* Frameworks */, + B1DD35B0198A6FAA00EF7043 /* Products */, + ); + sourceTree = ""; + }; + B1DD35B0198A6FAA00EF7043 /* Products */ = { + isa = PBXGroup; + children = ( + B1DD35AF198A6FAA00EF7043 /* libpfc-Mac.a */, + B16695F419ACC12A0001728F /* libpfc-iOS.a */, + ); + name = Products; + sourceTree = ""; + }; + B1DD35C2198A701100EF7043 /* Source */ = { + isa = PBXGroup; + children = ( + 0F17B3DA2B5E8F0E00FC86C1 /* event_std.h */, + 0F2201312B0CCF3D0074C1FC /* CFObject.h */, + 0F22012B2B0CCEA60074C1FC /* sort2.h */, + 0F2201292B0CCEA60074C1FC /* sortstring.h */, + 0F22012A2B0CCEA60074C1FC /* string_simple.h */, + 0F7A1B682A692C88004F89FB /* filetimetools.cpp */, + 0F7A1B692A692C88004F89FB /* filetimetools.h */, + 0F0794D227C90AA4006BAD7F /* charDownConvert.cpp */, + 0F0794D027C90AA4006BAD7F /* charDownConvert.h */, + 0F0794CF27C90AA4006BAD7F /* fixed_map.h */, + 0F0794D127C90AA4006BAD7F /* SmartStrStr-table.h */, + 0F0794D327C90AA4006BAD7F /* SmartStrStr-twoCharMappings.h */, + 0FAC031527C8EC6500BA9E97 /* SmartStrStr.cpp */, + 0FAC031627C8EC6500BA9E97 /* SmartStrStr.h */, + B1DD35C3198A702E00EF7043 /* alloc.h */, + B1DD35C4198A702E00EF7043 /* array.h */, + B1D8A0CD198FB83D00A23435 /* audio_math.cpp */, + B1D8A0CE198FB83D00A23435 /* audio_sample.cpp */, + B1D8A0CF198FB83D00A23435 /* audio_sample.h */, + 0F14904E242E44ED00D0BD81 /* autoref.h */, + B1DD35C5198A702E00EF7043 /* avltree.h */, + B1DD35C6198A702E00EF7043 /* base64.cpp */, + B1DD35C7198A702E00EF7043 /* base64.h */, + B12CBBC61BD4D96A00952805 /* bigmem.cpp */, + B12CBBC71BD4D96A00952805 /* bigmem.h */, + B1DD35C8198A702E00EF7043 /* binary_search.h */, + B1DD35C9198A702E00EF7043 /* bit_array_impl_part2.h */, + B1DD35CA198A702E00EF7043 /* bit_array_impl.h */, + B1DD35CB198A702E00EF7043 /* bit_array.cpp */, + B1DD35CC198A702E00EF7043 /* bit_array.h */, + B1DD35CD198A702E00EF7043 /* bsearch_inline.h */, + B1DD35CE198A702E00EF7043 /* bsearch.cpp */, + B1DD35CF198A702E00EF7043 /* bsearch.h */, + B1DD35D0198A702E00EF7043 /* byte_order.h */, + B1DD35D1198A702E00EF7043 /* chain_list_v2.h */, + 0F2F4BF6250BFF660014812D /* cmd_thread.h */, + B1DD35D2198A702E00EF7043 /* com_ptr_t.h */, + B1DD35D3198A702E00EF7043 /* cpuid.cpp */, + B1DD35D4198A702E00EF7043 /* cpuid.h */, + 0FFFAEAD23C9C9580023328B /* crashWithMessage.cpp */, + B12CBBB91BD4A01400952805 /* debug.h */, + B1DD35D5198A702E00EF7043 /* event.h */, + B1C37D7E19922EF500EE6ABC /* filehandle.cpp */, + B1C37D7D19922EEB00EE6ABC /* filehandle.h */, + B1CF88B41BD6657F00F42F87 /* fpu.h */, + B1DD35D6198A702E00EF7043 /* guid.cpp */, + B1DD35D7198A702E00EF7043 /* guid.h */, + B1DD35D9198A702E00EF7043 /* int_types.h */, + B1DD35DA198A702E00EF7043 /* iterators.h */, + 0F2F4BF0250BFF660014812D /* killswitch.h */, + B1DD35DB198A702E00EF7043 /* list.h */, + B1EFBAC51B90658600C2CE84 /* lockless.h */, + B1DD35DC198A702E00EF7043 /* map.h */, + B1CF88B51BD6657F00F42F87 /* mem_block.h */, + B1DD35DE198A702E00EF7043 /* memalign.h */, + B1DD35DF198A702E00EF7043 /* nix-objects.cpp */, + B1DD35E0198A702E00EF7043 /* nix-objects.h */, + 0F14904C242E44C300D0BD81 /* notifyList.h */, + B1DD35E1198A702E00EF7043 /* obj-c.mm */, + B125C8AC1F46D9A900ADB97B /* once.h */, + B1DD35E2198A702E00EF7043 /* order_helper.h */, + B1DD35E3198A702E00EF7043 /* other.cpp */, + B1DD35E4198A702E00EF7043 /* other.h */, + B1DD35E5198A702E00EF7043 /* pathUtils.cpp */, + B1DD35E6198A702E00EF7043 /* pathUtils.h */, + 0F2F4BF1250BFF660014812D /* pfc-fb2k-hooks.cpp */, + 0F2F4BEF250BFF660014812D /* pfc-fb2k-hooks.h */, + B12CBBB61BD3F08800952805 /* pfc-lite.h */, + B1DD35E7198A702E00EF7043 /* pfc.h */, + 0F2F4BF4250BFF660014812D /* platform-objects.h */, + 0F2F4BF5250BFF660014812D /* pocket_char_ops.h */, + B17EB26B1E85358D0057E2A4 /* pool.h */, + 0F64350E253A250600D6335A /* pp-winapi.h */, + B1DD35E8198A702E00EF7043 /* primitives_part2.h */, + B1DD35E9198A702E00EF7043 /* primitives.h */, + B1DD35EA198A702E00EF7043 /* printf.cpp */, + B1DD35ED198A702E00EF7043 /* ptr_list.h */, + B12CBBD01BD4DD4600952805 /* ptrholder.h */, + B1DD35EE198A702E00EF7043 /* rcptr.h */, + B1DD35EF198A702E00EF7043 /* ref_counter.h */, + B1DD35F0198A702E00EF7043 /* selftest.cpp */, + B1DD35F1198A702E00EF7043 /* sort.cpp */, + B1DD35F2198A702E00EF7043 /* sort.h */, + B17EB26C1E85358D0057E2A4 /* splitString.h */, + 0FB717E126C295370040D7FE /* splitString2.cpp */, + 0FB717E026C295370040D7FE /* splitString2.h */, + B1DD35F3198A702E00EF7043 /* stdafx.cpp */, + 0F2F4BF2250BFF660014812D /* stdsort.h */, + B1DD35F7198A702E00EF7043 /* string_base.cpp */, + B1DD35F8198A702E00EF7043 /* string_base.h */, + B1DD35F4198A702E00EF7043 /* string_conv.cpp */, + B1DD35F5198A702E00EF7043 /* string_conv.h */, + B1DD35F6198A702E00EF7043 /* string_list.h */, + 0F65005125122FD5001B03BA /* string-compare.cpp */, + 0F65005225122FD5001B03BA /* string-compare.h */, + 0F64350F253A250600D6335A /* string-conv-lite.cpp */, + 0F64350D253A250600D6335A /* string-conv-lite.h */, + B12CBBB71BD3F0D100952805 /* string-interface.h */, + 0F65005425122FD5001B03BA /* string-lite.cpp */, + B1CF88B61BD6657F00F42F87 /* string-lite.h */, + 0F65005325122FD5001B03BA /* string-part.h */, + 0F2F4BF3250BFF660014812D /* suppress_fb2k_hooks.h */, + B1DD35FC198A702E00EF7043 /* syncd_storage.h */, + B1DD35FD198A702E00EF7043 /* synchro_nix.cpp */, + B1DD35FE198A702E00EF7043 /* synchro_nix.h */, + B1DD35FF198A702E00EF7043 /* synchro_win.h */, + B12CBBD11BD4DE8100952805 /* synchro.h */, + B1DD3600198A702E00EF7043 /* threads.cpp */, + B1DD3601198A702E00EF7043 /* threads.h */, + B1DD35EB198A702E00EF7043 /* timers.cpp */, + B1DD35EC198A702E00EF7043 /* timers.h */, + B1DD3602198A702E00EF7043 /* traits.h */, + B1DD3603198A702E00EF7043 /* utf8.cpp */, + B17EB26D1E85358D0057E2A4 /* wait_queue.h */, + 0F149050242E454C00D0BD81 /* weakRef.h */, + B1B502D3198FF75000525EAF /* wildcard.cpp */, + B1B502D4198FF75000525EAF /* wildcard.h */, + B1DD3604198A702E00EF7043 /* win-objects.cpp */, + B1DD3605198A702E00EF7043 /* win-objects.h */, + 0F7EDDA827FAFDA5000996AA /* unicode-normalize.cpp */, + 0F7EDDA927FAFDA5000996AA /* unicode-normalize.h */, + ); + name = Source; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + B1DD35AD198A6FAA00EF7043 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + B1DD361E198A702E00EF7043 /* list.h in Headers */, + 0F2F4BF7250BFF660014812D /* pfc-fb2k-hooks.h in Headers */, + B12CBBCA1BD4D96A00952805 /* bigmem.h in Headers */, + B1DD3629198A702E00EF7043 /* pathUtils.h in Headers */, + B1DD3615198A702E00EF7043 /* com_ptr_t.h in Headers */, + B1DD360D198A702E00EF7043 /* bit_array_impl.h in Headers */, + 0F7EDDAC27FAFDA5000996AA /* unicode-normalize.h in Headers */, + B1DD3617198A702E00EF7043 /* cpuid.h in Headers */, + 0F643510253A250600D6335A /* string-conv-lite.h in Headers */, + B1DD3635198A702E00EF7043 /* sort.h in Headers */, + B1DD3648198A702E00EF7043 /* win-objects.h in Headers */, + B1DD3607198A702E00EF7043 /* array.h in Headers */, + 0F2201322B0CCF3D0074C1FC /* CFObject.h in Headers */, + B1DD360B198A702E00EF7043 /* binary_search.h in Headers */, + 0F22012D2B0CCEA60074C1FC /* string_simple.h in Headers */, + B1DD3621198A702E00EF7043 /* memalign.h in Headers */, + B1B502D6198FF75000525EAF /* wildcard.h in Headers */, + B1DD361A198A702E00EF7043 /* guid.h in Headers */, + B1DD362F198A702E00EF7043 /* timers.h in Headers */, + 0F0794D827C90AA4006BAD7F /* SmartStrStr-twoCharMappings.h in Headers */, + B1DD3638198A702E00EF7043 /* string_conv.h in Headers */, + B1DD3610198A702E00EF7043 /* bsearch_inline.h in Headers */, + 0F65005725122FD5001B03BA /* string-compare.h in Headers */, + 0F14904F242E44ED00D0BD81 /* autoref.h in Headers */, + 0F0794D527C90AA4006BAD7F /* charDownConvert.h in Headers */, + 0FAC031827C8EC6500BA9E97 /* SmartStrStr.h in Headers */, + B1DD3641198A702E00EF7043 /* synchro_nix.h in Headers */, + B1CF88B91BD6657F00F42F87 /* string-lite.h in Headers */, + B1DD360C198A702E00EF7043 /* bit_array_impl_part2.h in Headers */, + B1DD3645198A702E00EF7043 /* traits.h in Headers */, + 0F2F4BFB250BFF660014812D /* stdsort.h in Headers */, + B1DD361F198A702E00EF7043 /* map.h in Headers */, + 0F2F4BF8250BFF660014812D /* killswitch.h in Headers */, + B1DD3612198A702E00EF7043 /* bsearch.h in Headers */, + 0F2F4BFE250BFF660014812D /* pocket_char_ops.h in Headers */, + 0F149051242E454C00D0BD81 /* weakRef.h in Headers */, + B1CF88B81BD6657F00F42F87 /* mem_block.h in Headers */, + B1DD3614198A702E00EF7043 /* chain_list_v2.h in Headers */, + 0F0794D627C90AA4006BAD7F /* SmartStrStr-table.h in Headers */, + B1DD3627198A702E00EF7043 /* other.h in Headers */, + 0F2F4BFC250BFF660014812D /* suppress_fb2k_hooks.h in Headers */, + B17EB26E1E85358D0057E2A4 /* pool.h in Headers */, + 0F22012E2B0CCEA60074C1FC /* sort2.h in Headers */, + B17EB26F1E85358D0057E2A4 /* splitString.h in Headers */, + 0F2F4BFF250BFF660014812D /* cmd_thread.h in Headers */, + B1DD362B198A702E00EF7043 /* primitives_part2.h in Headers */, + 0F2F4BFD250BFF660014812D /* platform-objects.h in Headers */, + B1DD3632198A702E00EF7043 /* ref_counter.h in Headers */, + 0F22012C2B0CCEA60074C1FC /* sortstring.h in Headers */, + B1DD3630198A702E00EF7043 /* ptr_list.h in Headers */, + B17EB2701E85358D0057E2A4 /* wait_queue.h in Headers */, + B1DD362C198A702E00EF7043 /* primitives.h in Headers */, + B1DD3639198A702E00EF7043 /* string_list.h in Headers */, + B1DD361C198A702E00EF7043 /* int_types.h in Headers */, + B1DD3618198A702E00EF7043 /* event.h in Headers */, + 0F7A1B6C2A692C88004F89FB /* filetimetools.h in Headers */, + B1DD3608198A702E00EF7043 /* avltree.h in Headers */, + B1DD3606198A702E00EF7043 /* alloc.h in Headers */, + 0F14904D242E44C300D0BD81 /* notifyList.h in Headers */, + B1DD3644198A702E00EF7043 /* threads.h in Headers */, + 0F65005825122FD5001B03BA /* string-part.h in Headers */, + B1DD3623198A702E00EF7043 /* nix-objects.h in Headers */, + B1DD363F198A702E00EF7043 /* syncd_storage.h in Headers */, + B1DD362A198A702E00EF7043 /* pfc.h in Headers */, + B1DD3613198A702E00EF7043 /* byte_order.h in Headers */, + B1DD3631198A702E00EF7043 /* rcptr.h in Headers */, + 0F0794D427C90AA4006BAD7F /* fixed_map.h in Headers */, + B1DD3642198A702E00EF7043 /* synchro_win.h in Headers */, + 0F643511253A250600D6335A /* pp-winapi.h in Headers */, + B1DD360F198A702E00EF7043 /* bit_array.h in Headers */, + B1DD360A198A702E00EF7043 /* base64.h in Headers */, + B1D8A0D2198FB83D00A23435 /* audio_sample.h in Headers */, + B125C8AD1F46D9A900ADB97B /* once.h in Headers */, + B1DD363B198A702E00EF7043 /* string_base.h in Headers */, + B1DD361D198A702E00EF7043 /* iterators.h in Headers */, + 0FB717E226C295370040D7FE /* splitString2.h in Headers */, + B1DD3625198A702E00EF7043 /* order_helper.h in Headers */, + B1CF88B71BD6657F00F42F87 /* fpu.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + B16695F319ACC12A0001728F /* pfc-iOS */ = { + isa = PBXNativeTarget; + buildConfigurationList = B166961819ACC12A0001728F /* Build configuration list for PBXNativeTarget "pfc-iOS" */; + buildPhases = ( + B16695F019ACC12A0001728F /* Sources */, + B16695F119ACC12A0001728F /* Frameworks */, + B16695F219ACC12A0001728F /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "pfc-iOS"; + productName = "pfc-iOS"; + productReference = B16695F419ACC12A0001728F /* libpfc-iOS.a */; + productType = "com.apple.product-type.library.static"; + }; + B1DD35AE198A6FAA00EF7043 /* pfc-Mac */ = { + isa = PBXNativeTarget; + buildConfigurationList = B1DD35B3198A6FAA00EF7043 /* Build configuration list for PBXNativeTarget "pfc-Mac" */; + buildPhases = ( + B1DD35AB198A6FAA00EF7043 /* Sources */, + B1DD35AC198A6FAA00EF7043 /* Frameworks */, + B1DD35AD198A6FAA00EF7043 /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "pfc-Mac"; + productName = pfc; + productReference = B1DD35AF198A6FAA00EF7043 /* libpfc-Mac.a */; + productType = "com.apple.product-type.library.static"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + B1DD35A7198A6FAA00EF7043 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 1320; + ORGANIZATIONNAME = "___FULLUSERNAME___"; + }; + buildConfigurationList = B1DD35AA198A6FAA00EF7043 /* Build configuration list for PBXProject "pfc" */; + compatibilityVersion = "Xcode 12.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = B1DD35A6198A6FAA00EF7043; + productRefGroup = B1DD35B0198A6FAA00EF7043 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + B1DD35AE198A6FAA00EF7043 /* pfc-Mac */, + B16695F319ACC12A0001728F /* pfc-iOS */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + B16695F019ACC12A0001728F /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + B10D405C19ADFADB004D2596 /* audio_sample.cpp in Sources */, + B10D406A19ADFADB004D2596 /* string_base.cpp in Sources */, + 0F643513253A250600D6335A /* string-conv-lite.cpp in Sources */, + B10D405B19ADFADB004D2596 /* audio_math.cpp in Sources */, + B10D406E19ADFADB004D2596 /* threads.cpp in Sources */, + B10D406619ADFADB004D2596 /* printf.cpp in Sources */, + 0F54079726C2964500A118C8 /* splitString2.cpp in Sources */, + 0FFFAEAF23C9DB640023328B /* crashWithMessage.cpp in Sources */, + 0F65005A25122FD5001B03BA /* string-lite.cpp in Sources */, + B10D406419ADFADB004D2596 /* other.cpp in Sources */, + B10D406519ADFADB004D2596 /* pathUtils.cpp in Sources */, + B10D406319ADFADB004D2596 /* nix-objects.cpp in Sources */, + B10D406219ADFADB004D2596 /* guid.cpp in Sources */, + B10D405F19ADFADB004D2596 /* bsearch.cpp in Sources */, + B10D406719ADFADB004D2596 /* selftest.cpp in Sources */, + 0F7A1B6B2A692C88004F89FB /* filetimetools.cpp in Sources */, + B10D406919ADFADB004D2596 /* stdafx.cpp in Sources */, + B10D406819ADFADB004D2596 /* sort.cpp in Sources */, + 0F65005625122FD5001B03BA /* string-compare.cpp in Sources */, + B12CBBC91BD4D96A00952805 /* bigmem.cpp in Sources */, + B10D406D19ADFADB004D2596 /* synchro_nix.cpp in Sources */, + B10D406019ADFADB004D2596 /* cpuid.cpp in Sources */, + 0F7EDDAB27FAFDA5000996AA /* unicode-normalize.cpp in Sources */, + B10D405D19ADFADB004D2596 /* base64.cpp in Sources */, + B10D406B19ADFADB004D2596 /* string_conv.cpp in Sources */, + 0F0794D927C90AA8006BAD7F /* charDownConvert.cpp in Sources */, + B10D407019ADFADB004D2596 /* utf8.cpp in Sources */, + B10D407319ADFE52004D2596 /* obj-c.mm in Sources */, + 0FAC031927C8EC6A00BA9E97 /* SmartStrStr.cpp in Sources */, + B10D407119ADFADB004D2596 /* wildcard.cpp in Sources */, + 0F2F4BFA250BFF660014812D /* pfc-fb2k-hooks.cpp in Sources */, + B10D405E19ADFADB004D2596 /* bit_array.cpp in Sources */, + B10D407219ADFADB004D2596 /* win-objects.cpp in Sources */, + B10D406119ADFADB004D2596 /* filehandle.cpp in Sources */, + B10D406F19ADFADB004D2596 /* timers.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + B1DD35AB198A6FAA00EF7043 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + B1DD3647198A702E00EF7043 /* win-objects.cpp in Sources */, + B1DD3611198A702E00EF7043 /* bsearch.cpp in Sources */, + 0F643512253A250600D6335A /* string-conv-lite.cpp in Sources */, + B1DD3609198A702E00EF7043 /* base64.cpp in Sources */, + B1DD363A198A702E00EF7043 /* string_base.cpp in Sources */, + B1DD362D198A702E00EF7043 /* printf.cpp in Sources */, + 0FB717E326C295370040D7FE /* splitString2.cpp in Sources */, + 0FFFAEAE23C9C9580023328B /* crashWithMessage.cpp in Sources */, + 0F65005925122FD5001B03BA /* string-lite.cpp in Sources */, + B1D8A0D1198FB83D00A23435 /* audio_sample.cpp in Sources */, + B1DD3637198A702E00EF7043 /* string_conv.cpp in Sources */, + B1C37D7F19922EF500EE6ABC /* filehandle.cpp in Sources */, + B1DD3643198A702E00EF7043 /* threads.cpp in Sources */, + B1DD3624198A702E00EF7043 /* obj-c.mm in Sources */, + B1D8A0D0198FB83D00A23435 /* audio_math.cpp in Sources */, + 0F7A1B6A2A692C88004F89FB /* filetimetools.cpp in Sources */, + B1DD3628198A702E00EF7043 /* pathUtils.cpp in Sources */, + B1DD3646198A702E00EF7043 /* utf8.cpp in Sources */, + 0F65005525122FD5001B03BA /* string-compare.cpp in Sources */, + B1DD3636198A702E00EF7043 /* stdafx.cpp in Sources */, + B12CBBC81BD4D96A00952805 /* bigmem.cpp in Sources */, + B1DD362E198A702E00EF7043 /* timers.cpp in Sources */, + 0F7EDDAA27FAFDA5000996AA /* unicode-normalize.cpp in Sources */, + B1DD3622198A702E00EF7043 /* nix-objects.cpp in Sources */, + B1DD3640198A702E00EF7043 /* synchro_nix.cpp in Sources */, + 0F0794D727C90AA4006BAD7F /* charDownConvert.cpp in Sources */, + B1DD3633198A702E00EF7043 /* selftest.cpp in Sources */, + B1DD3626198A702E00EF7043 /* other.cpp in Sources */, + 0FAC031727C8EC6500BA9E97 /* SmartStrStr.cpp in Sources */, + B1DD360E198A702E00EF7043 /* bit_array.cpp in Sources */, + B1DD3619198A702E00EF7043 /* guid.cpp in Sources */, + 0F2F4BF9250BFF660014812D /* pfc-fb2k-hooks.cpp in Sources */, + B1DD3634198A702E00EF7043 /* sort.cpp in Sources */, + B1DD3616198A702E00EF7043 /* cpuid.cpp in Sources */, + B1B502D5198FF75000525EAF /* wildcard.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + B166961419ACC12A0001728F /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + DSTROOT = /tmp/pfc_iOS.dst; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + }; + name = Debug; + }; + B166961519ACC12A0001728F /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + DSTROOT = /tmp/pfc_iOS.dst; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + B1DD35B1198A6FAA00EF7043 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "pfc-lite.h"; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 12.1; + MACOSX_DEPLOYMENT_TARGET = 11.0; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SKIP_INSTALL = YES; + }; + name = Debug; + }; + B1DD35B2198A6FAA00EF7043 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_NO_COMMON_BLOCKS = YES; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "pfc-lite.h"; + GCC_PREPROCESSOR_DEFINITIONS = "NDEBUG=1"; + GCC_SYMBOLS_PRIVATE_EXTERN = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 12.1; + MACOSX_DEPLOYMENT_TARGET = 11.0; + SDKROOT = macosx; + SKIP_INSTALL = YES; + }; + name = Release; + }; + B1DD35B4198A6FAA00EF7043 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + COMBINE_HIDPI_IMAGES = YES; + EXECUTABLE_PREFIX = lib; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + B1DD35B5198A6FAA00EF7043 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + COMBINE_HIDPI_IMAGES = YES; + EXECUTABLE_PREFIX = lib; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + B166961819ACC12A0001728F /* Build configuration list for PBXNativeTarget "pfc-iOS" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + B166961419ACC12A0001728F /* Debug */, + B166961519ACC12A0001728F /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + B1DD35AA198A6FAA00EF7043 /* Build configuration list for PBXProject "pfc" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + B1DD35B1198A6FAA00EF7043 /* Debug */, + B1DD35B2198A6FAA00EF7043 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + B1DD35B3198A6FAA00EF7043 /* Build configuration list for PBXNativeTarget "pfc-Mac" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + B1DD35B4198A6FAA00EF7043 /* Debug */, + B1DD35B5198A6FAA00EF7043 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = B1DD35A7198A6FAA00EF7043 /* Project object */; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/platform-objects.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/platform-objects.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,8 @@ +#pragma once + +#ifdef _WIN32 +#include "win-objects.h" +#else +#include "nix-objects.h" +#endif + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/pocket_char_ops.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/pocket_char_ops.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,269 @@ +#pragma once + +// Standalone header (no dependencies) with implementations of PFC UTF-8 & UTF-16 manipulation routines + +static const uint8_t mask_tab[6] = { 0x80,0xE0,0xF0,0xF8,0xFC,0xFE }; + +static const uint8_t val_tab[6] = { 0,0xC0,0xE0,0xF0,0xF8,0xFC }; + +size_t utf8_char_len_from_header(char p_c) noexcept +{ + size_t cnt = 0; + for (;;) + { + if ((p_c & mask_tab[cnt]) == val_tab[cnt]) break; + if (++cnt >= 6) return 0; + } + + return cnt + 1; + +} +size_t utf8_decode_char(const char *p_utf8, unsigned & wide) noexcept { + const uint8_t * utf8 = (const uint8_t*)p_utf8; + const size_t max = 6; + + if (utf8[0]<0x80) { + wide = utf8[0]; + return utf8[0]>0 ? 1 : 0; + } + wide = 0; + + unsigned res = 0; + unsigned n; + unsigned cnt = 0; + for (;;) + { + if ((*utf8&mask_tab[cnt]) == val_tab[cnt]) break; + if (++cnt >= max) return 0; + } + cnt++; + + if (cnt == 2 && !(*utf8 & 0x1E)) return 0; + + if (cnt == 1) + res = *utf8; + else + res = (0xFF >> (cnt + 1))&*utf8; + + for (n = 1; n> (7 - cnt))) + return 0; + + res = (res << 6) | (utf8[n] & 0x3F); + } + + wide = res; + + return cnt; +} + +size_t utf8_decode_char(const char *p_utf8, unsigned & wide, size_t max) noexcept +{ + const uint8_t * utf8 = (const uint8_t*)p_utf8; + + if (max == 0) { + wide = 0; + return 0; + } + + if (utf8[0]<0x80) { + wide = utf8[0]; + return utf8[0]>0 ? 1 : 0; + } + if (max>6) max = 6; + wide = 0; + + unsigned res = 0; + unsigned n; + unsigned cnt = 0; + for (;;) + { + if ((*utf8&mask_tab[cnt]) == val_tab[cnt]) break; + if (++cnt >= max) return 0; + } + cnt++; + + if (cnt == 2 && !(*utf8 & 0x1E)) return 0; + + if (cnt == 1) + res = *utf8; + else + res = (0xFF >> (cnt + 1))&*utf8; + + for (n = 1; n> (7 - cnt))) + return 0; + + res = (res << 6) | (utf8[n] & 0x3F); + } + + wide = res; + + return cnt; +} + + +size_t utf8_encode_char(unsigned wide, char * target) noexcept +{ + size_t count; + + if (wide < 0x80) + count = 1; + else if (wide < 0x800) + count = 2; + else if (wide < 0x10000) + count = 3; + else if (wide < 0x200000) + count = 4; + else if (wide < 0x4000000) + count = 5; + else if (wide <= 0x7FFFFFFF) + count = 6; + else + return 0; + //if (count>max) return 0; + + if (target == 0) + return count; + + switch (count) + { + case 6: + target[5] = 0x80 | (wide & 0x3F); + wide = wide >> 6; + wide |= 0x4000000; + [[fallthrough]]; + case 5: + target[4] = 0x80 | (wide & 0x3F); + wide = wide >> 6; + wide |= 0x200000; + [[fallthrough]]; + case 4: + target[3] = 0x80 | (wide & 0x3F); + wide = wide >> 6; + wide |= 0x10000; + [[fallthrough]]; + case 3: + target[2] = 0x80 | (wide & 0x3F); + wide = wide >> 6; + wide |= 0x800; + [[fallthrough]]; + case 2: + target[1] = 0x80 | (wide & 0x3F); + wide = wide >> 6; + wide |= 0xC0; + [[fallthrough]]; + case 1: + target[0] = wide & 0xFF; + } + + return count; +} + +size_t utf16_encode_char(unsigned cur_wchar, char16_t * out) noexcept +{ + if (cur_wchar < 0x10000) { + *out = (char16_t)cur_wchar; return 1; + } else if (cur_wchar < (1 << 20)) { + unsigned c = cur_wchar - 0x10000; + //MSDN: + //The first (high) surrogate is a 16-bit code value in the range U+D800 to U+DBFF. The second (low) surrogate is a 16-bit code value in the range U+DC00 to U+DFFF. Using surrogates, Unicode can support over one million characters. For more details about surrogates, refer to The Unicode Standard, version 2.0. + out[0] = (char16_t)(0xD800 | (0x3FF & (c >> 10))); + out[1] = (char16_t)(0xDC00 | (0x3FF & c)); + return 2; + } else { + *out = '?'; return 1; + } +} + +size_t utf16_decode_char(const char16_t * p_source, unsigned * p_out, size_t p_source_length) noexcept { + if (p_source_length == 0) { *p_out = 0; return 0; } else if (p_source_length == 1) { + *p_out = p_source[0]; + return 1; + } else { + size_t retval = 0; + unsigned decoded = p_source[0]; + if (decoded != 0) + { + retval = 1; + if ((decoded & 0xFC00) == 0xD800) + { + unsigned low = p_source[1]; + if ((low & 0xFC00) == 0xDC00) + { + decoded = 0x10000 + (((decoded & 0x3FF) << 10) | (low & 0x3FF)); + retval = 2; + } + } + } + *p_out = decoded; + return retval; + } +} + +unsigned utf8_get_char(const char * src) +{ + unsigned rv = 0; + utf8_decode_char(src, rv); + return rv; +} + + +size_t utf8_char_len(const char * s, size_t max) noexcept +{ + unsigned dummy; + return utf8_decode_char(s, dummy, max); +} + +size_t skip_utf8_chars(const char * ptr, size_t count) noexcept +{ + size_t num = 0; + for (; count && ptr[num]; count--) + { + size_t d = utf8_char_len(ptr + num, (size_t)(-1)); + if (d <= 0) break; + num += d; + } + return num; +} + +bool is_valid_utf8(const char * param, size_t max) { + size_t walk = 0; + while (walk < max && param[walk] != 0) { + size_t d; + unsigned dummy; + d = utf8_decode_char(param + walk, dummy, max - walk); + if (d == 0) return false; + walk += d; + if (walk > max) { + // should not get here + return false; + } + } + return true; +} + +bool is_canonical_utf8(const char * param, size_t max) { + char scratch[6]; + size_t walk = 0; + while (walk < max && param[walk] != 0) { + size_t d; + unsigned c; + d = utf8_decode_char(param + walk, c, max - walk); + if (d == 0) return false; // bad UTF-8 + walk += d; + if (walk > max) { + // should not get here + return false; + } + if (utf8_encode_char(c, scratch) != d) return false; + } + return true; + +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/pool.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/pool.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,42 @@ +#pragma once +#include "synchro.h" +#include +#include + +namespace pfc { + template + class objPool { + public: + objPool() : m_maxCount(pfc_infinite) {} + typedef std::shared_ptr objRef_t; + + objRef_t get() { + insync(m_sync); + auto i = m_pool.begin(); + if ( i == m_pool.end() ) return nullptr; + auto ret = *i; + m_pool.erase(i); + return ret; + } + objRef_t make() { + auto obj = get(); + if ( ! obj ) obj = std::make_shared(); + return obj; + } + void setMaxCount(size_t c) { + insync(m_sync); + m_maxCount = c; + } + void put(objRef_t obj) { + insync(m_sync); + if ( m_pool.size() < m_maxCount ) { + m_pool.push_back(obj); + } + } + private: + size_t m_maxCount; + std::list m_pool; + critical_section m_sync; + }; + +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/pp-winapi.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/pp-winapi.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,105 @@ +#if !defined(PP_WINAPI_H_INCLUDED) && defined(_WIN32) +#define PP_WINAPI_H_INCLUDED + +#ifdef WINAPI_FAMILY_PARTITION + +#if ! WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) + +#ifndef CreateEvent // SPECIAL HACK: disable this stuff if somehow these functions are already defined + +inline HANDLE CreateEventW(LPSECURITY_ATTRIBUTES lpEventAttributes, BOOL bManualReset, BOOL bInitialState, LPCTSTR lpName) { + DWORD flags = 0; + if (bManualReset) flags |= CREATE_EVENT_MANUAL_RESET; + if (bInitialState) flags |= CREATE_EVENT_INITIAL_SET; + DWORD rights = SYNCHRONIZE | EVENT_MODIFY_STATE; + return CreateEventEx(lpEventAttributes, lpName, flags, rights); +} + +#define CreateEvent CreateEventW + +inline DWORD WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds) { + return WaitForSingleObjectEx(hHandle, dwMilliseconds, FALSE); +} + +inline DWORD WaitForMultipleObjects(DWORD nCount, const HANDLE *lpHandles, BOOL bWaitAll, DWORD dwMilliseconds) { + return WaitForMultipleObjectsEx(nCount, lpHandles, bWaitAll, dwMilliseconds, FALSE); +} + +inline void InitializeCriticalSection(LPCRITICAL_SECTION lpCriticalSection) { + InitializeCriticalSectionEx(lpCriticalSection, 0, 0); +} + +#endif // #ifndef CreateEvent + + +#ifndef CreateMutex + +inline HANDLE CreateMutexW(LPSECURITY_ATTRIBUTES lpMutexAttributes, BOOL bInitialOwner, LPCTSTR lpName) { + DWORD rights = MUTEX_MODIFY_STATE | SYNCHRONIZE; + DWORD flags = 0; + if (bInitialOwner) flags |= CREATE_MUTEX_INITIAL_OWNER; + return CreateMutexExW(lpMutexAttributes, lpName, flags, rights); +} + +#define CreateMutex CreateMutexW + +#endif // CreateMutex + + +#ifndef FindFirstFile + +inline HANDLE FindFirstFileW(LPCTSTR lpFileName, LPWIN32_FIND_DATA lpFindFileData) { + return FindFirstFileEx(lpFileName, FindExInfoStandard, lpFindFileData, FindExSearchNameMatch, NULL, 0); +} + +#define FindFirstFile FindFirstFileW + +#endif // #ifndef FindFirstFile + +// No reliable way to detect if GetFileSizeEx is present?? Give ours another name +inline BOOL GetFileSizeEx_Fallback(HANDLE hFile, PLARGE_INTEGER lpFileSize) { + FILE_STANDARD_INFO info; + if (!GetFileInformationByHandleEx(hFile, FileStandardInfo, &info, sizeof(info))) return FALSE; + *lpFileSize = info.EndOfFile; + return TRUE; +} + +#define PP_GetFileSizeEx_Fallback_Present + +#ifndef CreateFile + +inline HANDLE CreateFileW(LPCTSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile) { + CREATEFILE2_EXTENDED_PARAMETERS arg = {}; + arg.dwSize = sizeof(arg); + arg.hTemplateFile = hTemplateFile; + arg.lpSecurityAttributes = lpSecurityAttributes; + arg.dwFileAttributes = dwFlagsAndAttributes & 0x0000FFFF; + arg.dwFileFlags = dwFlagsAndAttributes & 0xFFFF0000; + return CreateFile2(lpFileName, dwDesiredAccess, dwShareMode, dwCreationDisposition, &arg); +} + +#define CreateFile CreateFileW + +#endif // #ifndef CreateFile + +#ifndef GetFileAttributes + +inline DWORD GetFileAttributesW(const wchar_t * path) { + WIN32_FILE_ATTRIBUTE_DATA data = {}; + if (!GetFileAttributesEx(path, GetFileExInfoStandard, &data)) return 0xFFFFFFFF; + return data.dwFileAttributes; +} + +#define GetFileAttributes GetFileAttributesW + +#endif // #ifndef GetFileAttributes + +#endif // #if ! WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) + +#endif // #ifdef WINAPI_FAMILY_PARTITION + +#ifndef PP_GetFileSizeEx_Fallback_Present +#define GetFileSizeEx_Fallback GetFileSizeEx +#endif + +#endif // !defined(PP_WINAPI_H_INCLUDED) && defined(_WIN32) diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/primitives.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/primitives.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,1021 @@ +#pragma once + +#include + +#include "traits.h" +#include "bit_array.h" + +#define tabsize(x) ((size_t)(sizeof(x)/sizeof(*x))) +#define PFC_TABSIZE(x) ((size_t)(sizeof(x)/sizeof(*x))) + +// Retained for compatibility. Do not use. Use C++11 template instead. +#define TEMPLATE_CONSTRUCTOR_FORWARD_FLOOD_WITH_INITIALIZER(THISCLASS,MEMBER,INITIALIZER) \ + THISCLASS() : MEMBER() INITIALIZER \ + template THISCLASS(const t_param1 & p_param1) : MEMBER(p_param1) INITIALIZER \ + template THISCLASS(const t_param1 & p_param1,const t_param2 & p_param2) : MEMBER(p_param1,p_param2) INITIALIZER \ + template THISCLASS(const t_param1 & p_param1,const t_param2 & p_param2,const t_param3 & p_param3) : MEMBER(p_param1,p_param2,p_param3) INITIALIZER \ + template THISCLASS(const t_param1 & p_param1,const t_param2 & p_param2,const t_param3 & p_param3,const t_param4 & p_param4) : MEMBER(p_param1,p_param2,p_param3,p_param4) INITIALIZER \ + template THISCLASS(const t_param1 & p_param1,const t_param2 & p_param2,const t_param3 & p_param3,const t_param4 & p_param4,const t_param5 & p_param5) : MEMBER(p_param1,p_param2,p_param3,p_param4,p_param5) INITIALIZER \ + template THISCLASS(const t_param1 & p_param1,const t_param2 & p_param2,const t_param3 & p_param3,const t_param4 & p_param4,const t_param5 & p_param5,const t_param6 & p_param6) : MEMBER(p_param1,p_param2,p_param3,p_param4,p_param5,p_param6) INITIALIZER \ + template THISCLASS(const t_param1 & p_param1,const t_param2 & p_param2,const t_param3 & p_param3,const t_param4 & p_param4,const t_param5 & p_param5,const t_param6 & p_param6,const t_param7 & p_param7) : MEMBER(p_param1,p_param2,p_param3,p_param4,p_param5,p_param6,p_param7) INITIALIZER \ + template THISCLASS(const t_param1 & p_param1,const t_param2 & p_param2,const t_param3 & p_param3,const t_param4 & p_param4,const t_param5 & p_param5,const t_param6 & p_param6,const t_param7 & p_param7, const t_param8 & p_param8) : MEMBER(p_param1,p_param2,p_param3,p_param4,p_param5,p_param6,p_param7, p_param8) INITIALIZER + +#define TEMPLATE_CONSTRUCTOR_FORWARD_FLOOD(THISCLASS,MEMBER) TEMPLATE_CONSTRUCTOR_FORWARD_FLOOD_WITH_INITIALIZER(THISCLASS,MEMBER,{}) + + +#ifdef _WIN32 + +#ifndef _MSC_VER +#error MSVC expected +#endif + +// MSVC specific - part of fb2k ABI - cannot ever change on MSVC/Windows + +#define PFC_DECLARE_EXCEPTION(NAME,BASECLASS,DEFAULTMSG) \ +class NAME : public BASECLASS { \ +public: \ + static const char * g_what() {return DEFAULTMSG;} \ + NAME() : BASECLASS(DEFAULTMSG,0) {} \ + NAME(const char * p_msg) : BASECLASS(p_msg) {} \ + NAME(const char * p_msg,int) : BASECLASS(p_msg,0) {} \ + NAME(const NAME & p_source) : BASECLASS(p_source) {} \ +}; + +namespace pfc { + template PFC_NORETURN inline void throw_exception_with_message(const char * p_message) { + throw t_exception(p_message); + } +} + +#else + +#define PFC_DECLARE_EXCEPTION(NAME,BASECLASS,DEFAULTMSG) \ +class NAME : public BASECLASS { \ +public: \ + static const char * g_what() {return DEFAULTMSG;} \ + const char* what() const throw() {return DEFAULTMSG;} \ +}; + +namespace pfc { + template class __exception_with_message_t : public t_base { + private: typedef __exception_with_message_t t_self; + public: + __exception_with_message_t(const char * p_message) : m_message(NULL) { + set_message(p_message); + } + __exception_with_message_t() : m_message(NULL) {} + __exception_with_message_t(const t_self & p_source) : m_message(NULL) {set_message(p_source.m_message);} + + const char* what() const throw() {return m_message != NULL ? m_message : "unnamed exception";} + + const t_self & operator=(const t_self & p_source) {set_message(p_source.m_message);} + + ~__exception_with_message_t() throw() {cleanup();} + + private: + void set_message(const char * p_message) throw() { + cleanup(); + if (p_message != NULL) m_message = strdup(p_message); + } + void cleanup() throw() { + if (m_message != NULL) {free(m_message); m_message = NULL;} + } + char * m_message; + }; + template PFC_NORETURN void throw_exception_with_message(const char * p_message) { + throw __exception_with_message_t(p_message); + } +} +#endif + +namespace pfc { + + template class assert_same_type; + template class assert_same_type {}; + + template + class is_same_type { public: enum {value = false}; }; + template + class is_same_type { public: enum {value = true}; }; + + template class static_assert_t; + template<> class static_assert_t {}; + +#define PFC_STATIC_ASSERT(X) { ::pfc::static_assert_t<(X)>(); } + + template + void assert_raw_type() {static_assert_t< !traits_t::needs_constructor && !traits_t::needs_destructor >();} + + template class assert_byte_type; + template<> class assert_byte_type {}; + template<> class assert_byte_type {}; + template<> class assert_byte_type {}; + + + template void __unsafe__memcpy_t(t_type * p_dst,const t_type * p_src,t_size p_count) { + ::memcpy(reinterpret_cast(p_dst), reinterpret_cast(p_src), p_count * sizeof(t_type)); + } + + template void __unsafe__in_place_destructor_t(t_type & p_item) throw() { + if constexpr (traits_t::needs_destructor) try{ p_item.~t_type(); } catch(...) {} + } + + template void __unsafe__in_place_constructor_t(t_type & p_item) { + if constexpr (traits_t::needs_constructor) { + t_type * ret = new(&p_item) t_type; + PFC_ASSERT(ret == &p_item); + (void) ret; // suppress warning + } + } + + template void __unsafe__in_place_destructor_array_t(t_type * p_items, t_size p_count) throw() { + if constexpr (traits_t::needs_destructor) { + t_type * walk = p_items; + for(t_size n=p_count;n;--n) __unsafe__in_place_destructor_t(*(walk++)); + } + } + + template t_type * __unsafe__in_place_constructor_array_t(t_type * p_items,t_size p_count) { + if constexpr (traits_t::needs_constructor) { + t_size walkptr = 0; + try { + for(walkptr=0;walkptr t_type * __unsafe__in_place_resize_array_t(t_type * p_items,t_size p_from,t_size p_to) { + if (p_from < p_to) __unsafe__in_place_constructor_array_t(p_items + p_from, p_to - p_from); + else if (p_from > p_to) __unsafe__in_place_destructor_array_t(p_items + p_to, p_from - p_to); + return p_items; + } + + template void __unsafe__in_place_constructor_copy_t(t_type & p_item,const t_copy & p_copyfrom) { + if constexpr (traits_t::needs_constructor) { + t_type * ret = new(&p_item) t_type(p_copyfrom); + PFC_ASSERT(ret == &p_item); + (void) ret; // suppress warning + } else { + p_item = p_copyfrom; + } + } + + template t_type * __unsafe__in_place_constructor_array_copy_t(t_type * p_items,t_size p_count, const t_copy * p_copyfrom) { + t_size walkptr = 0; + try { + for(walkptr=0;walkptr t_type * __unsafe__in_place_constructor_array_copy_partial_t(t_type * p_items,t_size p_count, const t_copy * p_copyfrom,t_size p_copyfrom_count) { + if (p_copyfrom_count > p_count) p_copyfrom_count = p_count; + __unsafe__in_place_constructor_array_copy_t(p_items,p_copyfrom_count,p_copyfrom); + try { + __unsafe__in_place_constructor_array_t(p_items + p_copyfrom_count,p_count - p_copyfrom_count); + } catch(...) { + __unsafe__in_place_destructor_array_t(p_items,p_copyfrom_count); + throw; + } + return p_items; + } + + template t_ret implicit_cast(t_ret val) {return val;} + + template + t_ret * safe_ptr_cast(t_param * p_param) { + if constexpr (pfc::is_same_type::value) return p_param; + else { + if (p_param == NULL) return NULL; + else return p_param; + } + } + + typedef std::exception exception; + + PFC_DECLARE_EXCEPTION(exception_overflow,exception,"Overflow"); + PFC_DECLARE_EXCEPTION(exception_bug_check,exception,"Bug check"); + PFC_DECLARE_EXCEPTION(exception_invalid_params,exception_bug_check,"Invalid parameters"); + PFC_DECLARE_EXCEPTION(exception_unexpected_recursion,exception_bug_check,"Unexpected recursion"); + PFC_DECLARE_EXCEPTION(exception_not_implemented,exception_bug_check,"Feature not implemented"); + PFC_DECLARE_EXCEPTION(exception_dynamic_assert,exception_bug_check,"dynamic_assert failure"); + + template + t_ret downcast_guarded(const t_param & p_param) { + t_ret temp = (t_ret) p_param; + if ((t_param) temp != p_param) throw exception_overflow(); + return temp; + } + + template + t_ret downcast_guarded_ex(const t_param & p_param) { + t_ret temp = (t_ret) p_param; + if ((t_param) temp != p_param) throw t_exception(); + return temp; + } + + template + void accumulate_guarded(t_acc & p_acc, const t_add & p_add) { + t_acc delta = downcast_guarded(p_add); + delta += p_acc; + if (delta < p_acc) throw exception_overflow(); + p_acc = delta; + } + + //deprecated + inline void bug_check_assert(bool p_condition, const char * p_msg) { + if (!p_condition) { + PFC_ASSERT(0); + throw_exception_with_message(p_msg); + } + } + //deprecated + inline void bug_check_assert(bool p_condition) { + if (!p_condition) { + PFC_ASSERT(0); + throw exception_bug_check(); + } + } + + inline void dynamic_assert(bool p_condition, const char * p_msg) { + if (!p_condition) { + PFC_ASSERT(0); + throw_exception_with_message(p_msg); + } + } + inline void dynamic_assert(bool p_condition) { + if (!p_condition) { + PFC_ASSERT(0); + throw exception_dynamic_assert(); + } + } + + template + inline void swap_multi_t(T * p_buffer1,T * p_buffer2,t_size p_size) { + T * walk1 = p_buffer1, * walk2 = p_buffer2; + for(t_size n=p_size;n;--n) { + T temp (* walk1); + *walk1 = *walk2; + *walk2 = temp; + walk1++; walk2++; + } + } + + template + inline void swap_multi_t(T * p_buffer1,T * p_buffer2) { + T * walk1 = p_buffer1, * walk2 = p_buffer2; + for(t_size n=p_size;n;--n) { + T temp (* walk1); + *walk1 = *walk2; + *walk2 = temp; + walk1++; walk2++; + } + } + + + template + inline void __unsafe__swap_raw_t(void * p_object1, void * p_object2) { + if constexpr (p_size % sizeof(t_size) == 0) { + swap_multi_t(reinterpret_cast(p_object1),reinterpret_cast(p_object2)); + } else { + swap_multi_t(reinterpret_cast(p_object1),reinterpret_cast(p_object2)); + } + } + + template + inline void swap_t(T & p_item1, T & p_item2) { + if constexpr (traits_t::realloc_safe) { + __unsafe__swap_raw_t( reinterpret_cast( &p_item1 ), reinterpret_cast( &p_item2 ) ); + } else { + T temp( std::move(p_item2) ); + p_item2 = std::move(p_item1); + p_item1 = std::move(temp); + } + } + + //! This is similar to plain p_item1 = p_item2; assignment, but optimized for the case where p_item2 content is no longer needed later on. This can be overridden for specific classes for optimal performance. \n + //! p_item2 value is undefined after performing a move_t. For an example, in certain cases move_t will fall back to swap_t. + template + inline void move_t(T & p_item1, T & p_item2) { + p_item1 = std::move(p_item2); + } + + template + t_size array_size_t(const t_array & p_array) {return p_array.get_size();} + + template + t_size array_size_t(const t_item (&p_array)[p_width]) {return p_width;} + + template static bool array_isLast(const t_array & arr, const t_item & item) { + const t_size size = pfc::array_size_t(arr); + return size > 0 && arr[size-1] == item; + } + template static bool array_isFirst(const t_array & arr, const t_item & item) { + const t_size size = pfc::array_size_t(arr); + return size > 0 && arr[0] == item; + } + + template + inline void fill_t(t_array & p_buffer,const t_size p_count, const t_filler & p_filler) { + for(t_size n=0;n + inline void fill_ptr_t(t_array * p_buffer,const t_size p_count, const t_filler & p_filler) { + for(t_size n=0;n + inline int compare_t(const t_item1 & p_item1, const t_item2 & p_item2) { + if (p_item1 < p_item2) return -1; + else if (p_item1 > p_item2) return 1; + else return 0; + } + + //! For use with avltree/map etc. + class comparator_default { + public: + template + inline static int compare(const t_item1 & p_item1,const t_item2 & p_item2) {return pfc::compare_t(p_item1,p_item2);} + }; + + template class comparator_pointer { public: + template static int compare(const t_item1 & p_item1,const t_item2 & p_item2) {return t_comparator::compare(*p_item1,*p_item2);} + }; + + template class comparator_dual { public: + template static int compare(const t_item1 & p_item1,const t_item2 & p_item2) { + int state = t_primary::compare(p_item1,p_item2); + if (state != 0) return state; + return t_secondary::compare(p_item1,p_item2); + } + }; + + class comparator_memcmp { + public: + template + inline static int compare(const t_item1 & p_item1,const t_item2 & p_item2) { + static_assert_t(); + return memcmp(&p_item1,&p_item2,sizeof(t_item1)); + } + }; + + template + t_size subtract_sorted_lists_calculate_count(const t_source1 & p_source1, const t_source2 & p_source2) { + t_size walk1 = 0, walk2 = 0, walk_out = 0; + const t_size max1 = p_source1.get_size(), max2 = p_source2.get_size(); + for(;;) { + int state; + if (walk1 < max1 && walk2 < max2) { + state = pfc::compare_t(p_source1[walk1],p_source2[walk2]); + } else if (walk1 < max1) { + state = -1; + } else if (walk2 < max2) { + state = 1; + } else { + break; + } + if (state < 0) walk_out++; + if (state <= 0) walk1++; + if (state >= 0) walk2++; + } + return walk_out; + } + + //! Subtracts p_source2 contents from p_source1 and stores result in p_destination. Both source lists must be sorted. + //! Note: duplicates will be carried over (and ignored for p_source2). + template + void subtract_sorted_lists(t_destination & p_destination,const t_source1 & p_source1, const t_source2 & p_source2) { + p_destination.set_size(subtract_sorted_lists_calculate_count(p_source1,p_source2)); + t_size walk1 = 0, walk2 = 0, walk_out = 0; + const t_size max1 = p_source1.get_size(), max2 = p_source2.get_size(); + for(;;) { + int state; + if (walk1 < max1 && walk2 < max2) { + state = pfc::compare_t(p_source1[walk1],p_source2[walk2]); + } else if (walk1 < max1) { + state = -1; + } else if (walk2 < max2) { + state = 1; + } else { + break; + } + + + if (state < 0) p_destination[walk_out++] = p_source1[walk1]; + if (state <= 0) walk1++; + if (state >= 0) walk2++; + } + } + + template + t_size merge_sorted_lists_calculate_count(const t_source1 & p_source1, const t_source2 & p_source2) { + t_size walk1 = 0, walk2 = 0, walk_out = 0; + const t_size max1 = p_source1.get_size(), max2 = p_source2.get_size(); + for(;;) { + int state; + if (walk1 < max1 && walk2 < max2) { + state = pfc::compare_t(p_source1[walk1],p_source2[walk2]); + } else if (walk1 < max1) { + state = -1; + } else if (walk2 < max2) { + state = 1; + } else { + break; + } + if (state <= 0) walk1++; + if (state >= 0) walk2++; + walk_out++; + } + return walk_out; + } + + //! Merges p_source1 and p_source2, storing content in p_destination. Both source lists must be sorted. + //! Note: duplicates will be carried over. + template + void merge_sorted_lists(t_destination & p_destination,const t_source1 & p_source1, const t_source2 & p_source2) { + p_destination.set_size(merge_sorted_lists_calculate_count(p_source1,p_source2)); + t_size walk1 = 0, walk2 = 0, walk_out = 0; + const t_size max1 = p_source1.get_size(), max2 = p_source2.get_size(); + for(;;) { + int state; + if (walk1 < max1 && walk2 < max2) { + state = pfc::compare_t(p_source1[walk1],p_source2[walk2]); + } else if (walk1 < max1) { + state = -1; + } else if (walk2 < max2) { + state = 1; + } else { + break; + } + if (state < 0) { + p_destination[walk_out] = p_source1[walk1++]; + } else if (state > 0) { + p_destination[walk_out] = p_source2[walk2++]; + } else { + p_destination[walk_out] = p_source1[walk1]; + walk1++; walk2++; + } + walk_out++; + } + } + + template + inline t_size append_t(t_array & p_array, T && p_item) + { + t_size old_count = p_array.get_size(); + p_array.set_size(old_count + 1); + p_array[old_count] = std::forward(p_item); + return old_count; + } + + template + inline t_size append_swap_t(t_array & p_array,T & p_item) + { + t_size old_count = p_array.get_size(); + p_array.set_size(old_count + 1); + swap_t(p_array[old_count],p_item); + return old_count; + } + + template + inline t_size insert_uninitialized_t(t_array & p_array,t_size p_index) { + t_size old_count = p_array.get_size(); + if (p_index > old_count) p_index = old_count; + p_array.set_size(old_count + 1); + for(t_size n=old_count;n>p_index;n--) move_t(p_array[n], p_array[n-1]); + return p_index; + } + + template + inline t_size insert_t(t_array & p_array,const T & p_item,t_size p_index) { + t_size old_count = p_array.get_size(); + if (p_index > old_count) p_index = old_count; + p_array.set_size(old_count + 1); + for(t_size n=old_count;n>p_index;n--) + move_t(p_array[n], p_array[n-1]); + p_array[p_index] = p_item; + return p_index; + } + template + void insert_array_t( array1_t & outArray, size_t insertAt, array2_t const & inArray, size_t inArraySize) { + const size_t oldSize = outArray.get_size(); + if (insertAt > oldSize) insertAt = oldSize; + const size_t newSize = oldSize + inArraySize; + outArray.set_size( newSize ); + for(size_t m = oldSize; m != insertAt; --m) { + move_t( outArray[ m - 1 + inArraySize], outArray[m - 1] ); + } + for(size_t w = 0; w < inArraySize; ++w) { + outArray[ insertAt + w ] = inArray[ w ]; + } + } + + template + inline t_size insert_multi_t(t_array & p_array,const in_array_t & p_items, size_t p_itemCount, t_size p_index) { + const t_size old_count = p_array.get_size(); + const size_t new_count = old_count + p_itemCount; + if (p_index > old_count) p_index = old_count; + p_array.set_size(new_count); + size_t toMove = old_count - p_index; + for(size_t w = 0; w < toMove; ++w) { + move_t( p_array[new_count - 1 - w], p_array[old_count - 1 - w] ); + } + + for(size_t w = 0; w < p_itemCount; ++w) { + p_array[p_index+w] = p_items[w]; + } + + return p_index; + } + template + inline t_size insert_swap_t(t_array & p_array,T & p_item,t_size p_index) { + t_size old_count = p_array.get_size(); + if (p_index > old_count) p_index = old_count; + p_array.set_size(old_count + 1); + for(t_size n=old_count;n>p_index;n--) + swap_t(p_array[n],p_array[n-1]); + swap_t(p_array[p_index],p_item); + return p_index; + } + + + template + inline T max_t(const T & item1, const T & item2) {return item1 > item2 ? item1 : item2;}; + + template + inline T min_t(const T & item1, const T & item2) {return item1 < item2 ? item1 : item2;}; + + template + inline T abs_t(T item) {return item<0 ? -item : item;} + + template + inline T sqr_t(T item) {return item * item;} + + template + inline T clip_t(const T & p_item, const T & p_min, const T & p_max) { + if (p_item < p_min) return p_min; + else if (p_item <= p_max) return p_item; + else return p_max; + } + + + + + + template + inline void delete_t(T* ptr) {delete ptr;} + + template + inline void delete_array_t(T* ptr) {delete[] ptr;} + + template + inline T* clone_t(T* ptr) {return new T(*ptr);} + + + template + inline t_int mul_safe_t(t_int p_val1,t_int p_val2) { + if (p_val1 == 0 || p_val2 == 0) return 0; + t_int temp = (t_int) (p_val1 * p_val2); + if (temp / p_val1 != p_val2) throw t_exception(); + return temp; + } + template + t_int multiply_guarded(t_int v1, t_int v2) { + return mul_safe_t(v1, v2); + } + template t_int add_unsigned_clipped(t_int v1, t_int v2) { + t_int v = v1 + v2; + if (v < v1) return ~0; + return v; + } + template t_int sub_unsigned_clipped(t_int v1, t_int v2) { + t_int v = v1 - v2; + if (v > v1) return 0; + return v; + } + template void acc_unsigned_clipped(t_int & v1, t_int v2) { + v1 = add_unsigned_clipped(v1, v2); + } + + template + void memcpy_t(t_dst* p_dst,const t_src* p_src,t_size p_count) { + for(t_size n=0;n + void copy_array_loop_t(t_dst & p_dst,const t_src & p_src,t_size p_count) { + for(t_size n=0;n + void memcpy_backwards_t(t_dst * p_dst,const t_src * p_src,t_size p_count) { + p_dst += p_count; p_src += p_count; + for(t_size n=0;n + void memset_t(T * p_buffer,const t_val & p_val,t_size p_count) { + for(t_size n=0;n + void memset_t(T &p_buffer,const t_val & p_val) { + const t_size width = pfc::array_size_t(p_buffer); + for(t_size n=0;n + void memset_null_t(T * p_buffer,t_size p_count) { + for(t_size n=0;n + void memset_null_t(T &p_buffer) { + const t_size width = pfc::array_size_t(p_buffer); + for(t_size n=0;n + void memmove_t(T* p_dst,const T* p_src,t_size p_count) { + if (p_dst == p_src) {/*do nothing*/} + else if (p_dst > p_src && p_dst < p_src + p_count) memcpy_backwards_t(p_dst,p_src,p_count); + else memcpy_t(p_dst,p_src,p_count); + } + + template void memxor_t(TVal * out, const TVal * s1, const TVal * s2, t_size count) { + for(t_size walk = 0; walk < count; ++walk) out[walk] = s1[walk] ^ s2[walk]; + } + inline static void memxor(void * target, const void * source1, const void * source2, t_size size) { + memxor_t( reinterpret_cast(target), reinterpret_cast(source1), reinterpret_cast(source2), size); + } + + template + T* new_ptr_check_t(T* p_ptr) { + if (p_ptr == NULL) throw std::bad_alloc(); + return p_ptr; + } + + template + int sgn_t(const T & p_val) { + if (p_val < 0) return -1; + else if (p_val > 0) return 1; + else return 0; + } + + template const T* empty_string_t(); + + template<> inline const char * empty_string_t() {return "";} + template<> inline const wchar_t * empty_string_t() {return L"";} + + + template + type_t replace_t(type_t & p_var,arg_t && p_newval) { + auto oldval = std::move(p_var); + p_var = std::forward(p_newval); + return oldval; + } + + template + t_type replace_null_t(t_type & p_var) { + t_type ret = std::move(p_var); + p_var = 0; + return ret; + } + + template + inline bool is_ptr_aligned_t(const void * p_ptr) { + static_assert_t< (p_size_pow2 & (p_size_pow2 - 1)) == 0 >(); + return ( ((t_size)p_ptr) & (p_size_pow2-1) ) == 0; + } + + + template + void array_rangecheck_t(const t_array & p_array,t_size p_index) { + if (p_index >= pfc::array_size_t(p_array)) throw pfc::exception_overflow(); + } + + template + void array_rangecheck_t(const t_array & p_array,t_size p_from,t_size p_to) { + if (p_from > p_to) throw pfc::exception_overflow(); + array_rangecheck_t(p_array,p_from); array_rangecheck_t(p_array,p_to); + } + + t_int32 rint32(double p_val); + t_int64 rint64(double p_val); + + //! Returns amount of items left. + template + inline size_t remove_if_t( array_t & arr, pred_t pred ) { + const size_t inCount = arr.size(); + size_t walk = 0; + + for (;; ) { + if ( walk == inCount ) return inCount; + if ( pred(arr[walk]) ) break; + ++ walk; + } + + size_t total = walk; + + ++ walk; // already know that at walk is pred() positive + + for( ; walk < inCount; ++ walk ) { + if ( !pred(arr[walk] ) ) { + move_t(arr[total++], arr[walk]); + } + } + arr.resize(total); + + return total; + } + + //! Returns amount of items left. + template + inline t_size remove_mask_t(t_array & p_array,const bit_array & p_mask) + { + t_size n,count = p_array.size(), total = 0; + + n = total = p_mask.find(true,0,count); + + if (n + t_size find_duplicates_sorted_t(t_array p_array,t_size p_count,t_compare p_compare,bit_array_var & p_out) { + t_size ret = 0; + t_size n; + if (p_count > 0) + { + p_out.set(0,false); + for(n=1;n + t_size find_duplicates_sorted_permutation_t(t_array p_array,t_size p_count,t_compare p_compare,t_permutation const & p_permutation,bit_array_var & p_out) { + t_size ret = 0; + t_size n; + if (p_count > 0) { + p_out.set(p_permutation[0],false); + for(n=1;n + t_size strlen_t(const t_char * p_string,t_size p_length = ~0) { + for(t_size walk = 0;;walk++) { + if (walk >= p_length || p_string[walk] == 0) return walk; + } + } + + + template + class __list_to_array_enumerator { + public: + __list_to_array_enumerator(t_array & p_array) : m_walk(), m_array(p_array) {} + template + void operator() (const t_item & p_item) { + PFC_ASSERT(m_walk < m_array.get_size()); + m_array[m_walk++] = p_item; + } + void finalize() { + PFC_ASSERT(m_walk == m_array.get_size()); + } + private: + t_size m_walk; + t_array & m_array; + }; + + template + void list_to_array(t_array & p_array,const t_list & p_list) { + p_array.set_size(p_list.get_count()); + __list_to_array_enumerator enumerator(p_array); + p_list.enumerate(enumerator); + enumerator.finalize(); + } + + template + class enumerator_add_item { + public: + enumerator_add_item(t_receiver & p_receiver) : m_receiver(p_receiver) {} + template void operator() (const t_item & p_item) {m_receiver.add_item(p_item);} + private: + t_receiver & m_receiver; + }; + + template + void overwrite_list_enumerated(t_receiver & p_receiver,const t_giver & p_giver) { + enumerator_add_item wrapper(p_receiver); + p_giver.enumerate(wrapper); + } + + template + void copy_list_enumerated(t_receiver & p_receiver,const t_giver & p_giver) { + p_receiver.remove_all(); + overwrite_list_enumerated(p_receiver,p_giver); + } + + inline bool lxor(bool p_val1,bool p_val2) { + return p_val1 == !p_val2; + } + + template + inline void min_acc(t_val & p_acc,const t_val & p_val) { + if (p_val < p_acc) p_acc = p_val; + } + + template + inline void max_acc(t_val & p_acc,const t_val & p_val) { + if (p_val > p_acc) p_acc = p_val; + } + + t_uint64 pow_int(t_uint64 base, t_uint64 exp) noexcept; + double exp_int(double base, int exp) noexcept; + + + template + class incrementScope { + public: + incrementScope(t_val & i) : v(i) {++v;} + ~incrementScope() {--v;} + private: + t_val & v; + }; + template + incrementScope autoIncrement(obj_t& v) { return incrementScope(v); } + + constexpr inline unsigned countBits32(uint32_t i) { + const uint32_t mask = 0x11111111; + uint32_t acc = i & mask; + acc += (i >> 1) & mask; + acc += (i >> 2) & mask; + acc += (i >> 3) & mask; + + const uint32_t mask2 = 0x0F0F0F0F; + uint32_t acc2 = acc & mask2; + acc2 += (acc >> 4) & mask2; + + const uint32_t mask3 = 0x00FF00FF; + uint32_t acc3 = acc2 & mask3; + acc3 += (acc2 >> 8) & mask3; + + return (acc3 & 0xFFFF) + ((acc3 >> 16) & 0xFFFF); + } + + // Forward declarations + template + void copy_array_t(t_to & p_to,const t_from & p_from); + + template + void fill_array_t(t_array & p_array,const t_value & p_value); + + // Generic no-op for breakpointing stuff + inline void nop() {} + + template + class vartoggle_t { + T oldval; T& var; + public: + vartoggle_t(const vartoggle_t&) = delete; + void operator=(const vartoggle_t&) = delete; + template + vartoggle_t(T& p_var, arg_t&& val) : var(p_var) { + oldval = std::move(var); + var = std::forward(val); + } + ~vartoggle_t() { var = std::move(oldval); } + }; + + template + vartoggle_t autoToggle(T& p_var, arg_t&& val) { + return vartoggle_t(p_var, std::forward(val)); + } + + template + class vartoggle_volatile_t { + T oldval; volatile T& var; + public: + template + vartoggle_volatile_t(volatile T& p_var, arg_t && val) : var(p_var) { + oldval = std::move(var); + var = std::forward(val); + } + ~vartoggle_volatile_t() { var = std::move(oldval); } + }; + + typedef vartoggle_t booltoggle; + + template + class singleton { + public: + static obj_t instance; + }; + template + obj_t singleton::instance; + +}; +#define PFC_SINGLETON(X) ::pfc::singleton::instance + + +#define PFC_CLASS_NOT_COPYABLE(THISCLASSNAME,THISTYPE) \ + THISCLASSNAME(const THISTYPE&) = delete; \ + const THISTYPE & operator=(const THISTYPE &) = delete; + +#define PFC_CLASS_NOT_COPYABLE_EX(THISTYPE) PFC_CLASS_NOT_COPYABLE(THISTYPE,THISTYPE) + + +namespace pfc { + template + t_size strlen_max_t(const t_char* ptr, t_size max) noexcept { + PFC_ASSERT(ptr != NULL || max == 0); + t_size n = 0; + while (n < max && ptr[n] != 0) n++; + return n; + } + + inline t_size strlen_max(const char* ptr, t_size max) noexcept { return strlen_max_t(ptr, max); } + inline t_size wcslen_max(const wchar_t* ptr, t_size max) noexcept { return strlen_max_t(ptr, max); } + +#ifdef _WINDOWS + inline t_size tcslen_max(const TCHAR* ptr, t_size max) noexcept { return strlen_max_t(ptr, max); } +#endif +} + +namespace pfc { + class autoScope { + public: + autoScope() {} + autoScope(std::function&& f) : m_cleanup(std::move(f)) {} + + template void increment(what_t& obj) { + reset(); + ++obj; + m_cleanup = [&obj] { --obj; }; + } + template void toggle(what_t& obj, arg_t && val) { + reset(); + what_t old = obj; + obj = std::forward(val); + m_cleanup = [v = std::move(old), &obj]{ + obj = std::move(v); + }; + } + void operator() (std::function&& f) { + reset(); m_cleanup = std::move(f); + } + + ~autoScope() { + if (m_cleanup) m_cleanup(); + } + + void cancel() { + m_cleanup = nullptr; + } + + void reset() { + if (m_cleanup) { + m_cleanup(); + m_cleanup = nullptr; + } + } + + autoScope(const autoScope&) = delete; + void operator=(const autoScope&) = delete; + + operator bool() const { return !!m_cleanup; } + private: + std::function m_cleanup; + }; + typedef autoScope onLeaving; +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/primitives_part2.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/primitives_part2.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,26 @@ +#pragma once + +namespace pfc { + template + static bool guess_reorder_pattern(pfc::array_t & out, const t_list1 & from, const t_list2 & to) { + typedef typename t_list1::t_item t_item; + const t_size count = from.get_size(); + if (count != to.get_size()) return false; + out.set_size(count); + for(t_size walk = 0; walk < count; ++walk) out[walk] = walk; + //required output: to[n] = from[out[n]]; + typedef pfc::chain_list_v2_t t_queue; + pfc::map_t content; + for(t_size walk = 0; walk < count; ++walk) { + content.find_or_add(from[walk]).add_item(walk); + } + for(t_size walk = 0; walk < count; ++walk) { + t_queue * q = content.query_ptr(to[walk]); + if (q == NULL) return false; + if (q->get_count() == 0) return false; + out[walk] = *q->first(); + q->remove(q->first()); + } + return true; + } +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/printf.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/printf.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,132 @@ +#include "pfc-lite.h" +#include "string_base.h" + +//implementations of deprecated string_printf methods, with a pragma to disable warnings when they reference other deprecated methods. + +#ifndef _MSC_VER +#define _itoa_s itoa +#define _ultoa_s ultoa +#endif + +#ifdef _MSC_VER +#pragma warning(disable:4996) +#endif + +namespace pfc { + string8 string_printf(const char * fmt, ...) { + string8 ret; + va_list list; + va_start(list, fmt); + string_printf_here_va(ret, fmt, list); + va_end(list); + return ret; + } + string8 string_printf_va(const char * fmt, va_list list) { + string8 ret; + string_printf_here_va(ret, fmt, list); + return ret; + } + void string_printf_here(string_base & out, const char * fmt, ...) { + va_list list; + va_start(list, fmt); + string_printf_here_va(out, fmt, list); + va_end(list); + } + void string_printf_here_va(string_base & out, const char * fmt, va_list list) { + out.reset(); + while(*fmt) + { + if (*fmt=='%') + { + fmt++; + if (*fmt=='%') + { + out.add_char('%'); + fmt++; + } + else + { + bool force_sign = false; + if (*fmt=='+') + { + force_sign = true; + fmt++; + } + char padchar = (*fmt == '0') ? '0' : ' '; + t_size pad = 0; + while(*fmt>='0' && *fmt<='9') + { + pad = pad * 10 + (*fmt - '0'); + fmt++; + } + + if (*fmt=='s' || *fmt=='S') + { + const char * ptr = va_arg(list,const char*); + t_size len = strlen(ptr); + if (pad>len) out.add_chars(padchar,pad-len); + out.add_string(ptr); + fmt++; + + } + else if (*fmt=='i' || *fmt=='I' || *fmt=='d' || *fmt=='D') + { + int val = va_arg(list,int); + if (force_sign && val>0) out.add_char('+'); + auto temp = pfc::format_int( val ); + t_size len = strlen(temp); + if (pad>len) out.add_chars(padchar,pad-len); + out.add_string(temp); + fmt++; + } + else if (*fmt=='u' || *fmt=='U') + { + int val = va_arg(list,int); + if (force_sign && val>0) out.add_char('+'); + auto temp = pfc::format_uint(val); + t_size len = strlen(temp); + if (pad>len) out.add_chars(padchar,pad-len); + out.add_string(temp); + fmt++; + } + else if (*fmt=='x' || *fmt=='X') + { + auto val = va_arg(list,unsigned); + if (force_sign && val>0) out.add_char('+'); + auto temp = pfc::format_uint(val, 0, 16); + if (*fmt=='X') + { + char * t = const_cast< char* > ( temp.c_str() ); + while(*t) + { + *t = pfc::ascii_toupper(*t); + t++; + } + } else { + char* t = const_cast (temp.c_str()); + while (*t) + { + *t = pfc::ascii_tolower(*t); + t++; + } + } + t_size len = strlen(temp); + if (pad>len) out.add_chars(padchar,pad-len); + out.add_string(temp); + fmt++; + } + else if (*fmt=='c' || *fmt=='C') + { + out.add_char(va_arg(list,int)); + fmt++; + } + } + } + else + { + out.add_char(*(fmt++)); + } + } + } + +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/ptr_list.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/ptr_list.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,40 @@ +#pragma once +#include "list.h" + +namespace pfc { + + template > + class ptr_list_t : public B { + public: + typedef ptr_list_t self_t; + + void free_by_idx(t_size n) {free_mask(bit_array_one(n));} + void free_all() {this->remove_all_ex(free);} + void free_mask(const bit_array & p_mask) {this->remove_mask_ex(p_mask,free);} + + void delete_item(T* ptr) {delete_by_idx(find_item(ptr));} + + void delete_by_idx(t_size p_index) { + delete_mask(bit_array_one(p_index)); + } + + void delete_all() { + this->remove_all_ex(pfc::delete_t); + } + + void delete_mask(const bit_array & p_mask) { + this->remove_mask_ex(p_mask,pfc::delete_t); + } + + T * operator[](t_size n) const {return this->get_item(n);} + }; + + template + class ptr_list_hybrid_t : public ptr_list_t > { + public: + }; + + typedef ptr_list_t ptr_list; + + template class traits_t > : public traits_t {}; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/ptrholder.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/ptrholder.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,86 @@ +#pragma once + +// ptrholder_t<> : std::unique_ptr<> equivalent +// Obsolete, use std::unique_ptr<> instead +// Warning: release() deletes instead of letting go of ownership, contrary to std::unique_ptr<> + +namespace pfc { + class releaser_delete { + public: + template static void release(T* p_ptr) { delete p_ptr; } + }; + class releaser_delete_array { + public: + template static void release(T* p_ptr) { delete[] p_ptr; } + }; + class releaser_free { + public: + static void release(void* p_ptr) { free(p_ptr); } + }; + + //! Assumes t_freefunc to never throw exceptions. + template + class ptrholder_t { + private: + typedef ptrholder_t t_self; + public: + inline ptrholder_t(T* p_ptr) : m_ptr(p_ptr) {} + inline ptrholder_t() : m_ptr(NULL) {} + inline ~ptrholder_t() { t_releaser::release(m_ptr); } + inline bool is_valid() const { return m_ptr != NULL; } + inline bool is_empty() const { return m_ptr == NULL; } + inline T* operator->() const { return m_ptr; } + inline T* get_ptr() const { return m_ptr; } + inline void release() { t_releaser::release(replace_null_t(m_ptr));; } + inline void attach(T* p_ptr) { release(); m_ptr = p_ptr; } + inline const t_self& operator=(T* p_ptr) { set(p_ptr); return *this; } + inline T* detach() { return pfc::replace_null_t(m_ptr); } + inline T& operator*() const { return *m_ptr; } + + inline t_self& operator<<(t_self& p_source) { attach(p_source.detach()); return *this; } + inline t_self& operator>>(t_self& p_dest) { p_dest.attach(detach()); return *this; } + + //deprecated + inline void set(T* p_ptr) { attach(p_ptr); } + + ptrholder_t(t_self&& other) {m_ptr = other.detach(); } + const t_self& operator=(t_self&& other) { attach(other.detach()); return *this; } + private: + ptrholder_t(const t_self&) = delete; + const t_self& operator=(const t_self&) = delete; + + T* m_ptr; + }; + + //avoid "void&" breakage + template + class ptrholder_t { + private: + typedef void T; + typedef ptrholder_t t_self; + public: + inline ptrholder_t(T* p_ptr) : m_ptr(p_ptr) {} + inline ptrholder_t() : m_ptr(NULL) {} + inline ~ptrholder_t() { t_releaser::release(m_ptr); } + inline bool is_valid() const { return m_ptr != NULL; } + inline bool is_empty() const { return m_ptr == NULL; } + inline T* operator->() const { return m_ptr; } + inline T* get_ptr() const { return m_ptr; } + inline void release() { t_releaser::release(replace_null_t(m_ptr));; } + inline void attach(T* p_ptr) { release(); m_ptr = p_ptr; } + inline const t_self& operator=(T* p_ptr) { set(p_ptr); return *this; } + inline T* detach() { return pfc::replace_null_t(m_ptr); } + + inline t_self& operator<<(t_self& p_source) { attach(p_source.detach()); return *this; } + inline t_self& operator>>(t_self& p_dest) { p_dest.attach(detach()); return *this; } + + //deprecated + inline void set(T* p_ptr) { attach(p_ptr); } + private: + ptrholder_t(const t_self&) = delete; + const t_self& operator=(const t_self&) = delete; + + T* m_ptr; + }; + +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/rcptr.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/rcptr.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,177 @@ +#pragma once + +namespace pfc { + + struct _rcptr_null; + typedef _rcptr_null* t_rcptr_null; + + static const t_rcptr_null rcptr_null = NULL; + + class rc_container_base { + public: + long add_ref() throw() { + return ++m_counter; + } + long release() throw() { + long ret = --m_counter; + if (ret == 0) PFC_ASSERT_NO_EXCEPTION( delete this ); + return ret; + } + protected: + virtual ~rc_container_base() {} + private: + refcounter m_counter; + }; + + template + class rc_container_t : public rc_container_base { + public: + template + rc_container_t(arg_t && ... arg) : m_object(std::forward(arg) ...) {} + + t_object m_object; + }; + + template + class rcptr_t { + private: + typedef rcptr_t t_self; + typedef rc_container_base t_container; + typedef rc_container_t t_container_impl; + public: + rcptr_t(t_rcptr_null) throw() {_clear();} + rcptr_t() throw() {_clear();} + rcptr_t(const t_self & p_source) throw() {__init(p_source);} + t_self const & operator=(const t_self & p_source) throw() {__copy(p_source); return *this;} + + template + rcptr_t(const rcptr_t & p_source) throw() {__init(p_source);} + template + const t_self & operator=(const rcptr_t & p_source) throw() {__copy(p_source); return *this;} + + rcptr_t(t_self && p_source) throw() {_move(p_source);} + const t_self & operator=(t_self && p_source) throw() {release(); _move(p_source); return *this;} + + const t_self & operator=(t_rcptr_null) throw() {release(); return *this;} + +/* template + operator rcptr_t() const throw() { + rcptr_t temp; + if (is_valid()) temp.__set_from_cast(this->m_container,this->m_ptr); + return temp; + }*/ + + + template + bool operator==(const rcptr_t & p_other) const throw() { + return m_container == p_other.__container(); + } + + template + bool operator!=(const rcptr_t & p_other) const throw() { + return m_container != p_other.__container(); + } + + void __set_from_cast(t_container * p_container,t_object * p_ptr) throw() { + //addref first because in rare cases this is the same pointer as the one we currently own + if (p_container != NULL) p_container->add_ref(); + release(); + m_container = p_container; + m_ptr = p_ptr; + } + + bool is_valid() const throw() {return m_container != NULL;} + bool is_empty() const throw() {return m_container == NULL;} + + + ~rcptr_t() throw() {release();} + + void release() throw() { + t_container * temp = m_container; + m_ptr = NULL; + m_container = NULL; + if (temp != NULL) temp->release(); + } + + + template + rcptr_t static_cast_t() const throw() { + rcptr_t temp; + if (is_valid()) temp.__set_from_cast(this->m_container,static_cast(this->m_ptr)); + return temp; + } + + void new_t() { + on_new(new t_container_impl()); + } + + template + void new_t(arg_t && ... arg) { + on_new(new t_container_impl(std::forward(arg) ...)); + } + + static t_self g_new_t() { + t_self temp; + temp.new_t(); + return temp; + } + + template + static t_self g_new_t(arg_t && ... arg) { + t_self temp; + temp.new_t(std::forward(arg) ...); + return temp; + } + + t_object & operator*() const throw() {return *this->m_ptr;} + + t_object * operator->() const throw() {return this->m_ptr;} + + + t_container * __container() const throw() {return m_container;} + + // FOR INTERNAL USE ONLY + void _clear() throw() {m_container = NULL; m_ptr = NULL;} + private: + + template + void __init(const rcptr_t & p_source) throw() { + m_container = p_source.__container(); + m_ptr = &*p_source; + if (m_container != NULL) m_container->add_ref(); + } + template + void _move(rcptr_t & p_source) throw() { + m_container = p_source.__container(); + m_ptr = &*p_source; + p_source._clear(); + } + template + void __copy(const rcptr_t & p_source) throw() { + __set_from_cast(p_source.__container(),&*p_source); + } + void on_new(t_container_impl * p_container) throw() { + this->release(); + p_container->add_ref(); + this->m_ptr = &p_container->m_object; + this->m_container = p_container; + } + + t_container * m_container; + t_object * m_ptr; + }; + + template + rcptr_t rcnew_t(arg_t && ... arg) { + rcptr_t temp; + temp.new_t(std::forward(arg) ...); + return temp; + } + + class traits_rcptr : public traits_default { + public: + enum { realloc_safe = true, constructor_may_fail = false }; + }; + + template class traits_t > : public traits_rcptr {}; +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/ref_counter.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/ref_counter.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,108 @@ +#pragma once + +#include "traits.h" +#include "lockless.h" +#include "primitives.h" + +namespace pfc { + + class NOVTABLE refcounted_object_root + { + public: + void refcount_add_ref() throw() {++m_counter;} + void refcount_release() throw() {if (--m_counter == 0) delete this;} + void _refcount_release_temporary() throw() {--m_counter;}//for internal use only! + protected: + refcounted_object_root() {} + virtual ~refcounted_object_root() {} + private: + refcounter m_counter; + }; + + template + class refcounted_object_ptr_t { + private: + typedef refcounted_object_ptr_t t_self; + public: + inline refcounted_object_ptr_t() throw() : m_ptr(NULL) {} + inline refcounted_object_ptr_t(T* p_ptr) throw() : m_ptr(NULL) {copy(p_ptr);} + inline refcounted_object_ptr_t(const t_self & p_source) throw() : m_ptr(NULL) {copy(p_source);} + inline refcounted_object_ptr_t(t_self && p_source) throw() { m_ptr = p_source.m_ptr; p_source.m_ptr = NULL; } + + template + inline refcounted_object_ptr_t(t_source * p_ptr) throw() : m_ptr(NULL) {copy(p_ptr);} + + template + inline refcounted_object_ptr_t(const refcounted_object_ptr_t & p_source) throw() : m_ptr(NULL) {copy(p_source);} + + inline ~refcounted_object_ptr_t() throw() {if (m_ptr != NULL) m_ptr->refcount_release();} + + template + inline void copy(t_source * p_ptr) throw() { + T* torel = pfc::replace_t(m_ptr,pfc::safe_ptr_cast(p_ptr)); + if (m_ptr != NULL) m_ptr->refcount_add_ref(); + if (torel != NULL) torel->refcount_release(); + + } + + template + inline void copy(const refcounted_object_ptr_t & p_source) throw() {copy(p_source.get_ptr());} + + + inline const t_self & operator=(const t_self & p_source) throw() {copy(p_source); return *this;} + inline const t_self & operator=(t_self && p_source) throw() {attach(p_source.detach()); return *this;} + inline const t_self & operator=(T * p_ptr) throw() {copy(p_ptr); return *this;} + + template inline t_self & operator=(const refcounted_object_ptr_t & p_source) throw() {copy(p_source); return *this;} + template inline t_self & operator=(t_source * p_ptr) throw() {copy(p_ptr); return *this;} + + inline void release() throw() { + T * temp = pfc::replace_t(m_ptr,(T*)NULL); + if (temp != NULL) temp->refcount_release(); + } + + + inline T& operator*() const throw() {return *m_ptr;} + + inline T* operator->() const throw() {PFC_ASSERT(m_ptr != NULL);return m_ptr;} + + inline T* get_ptr() const throw() {return m_ptr;} + + inline bool is_valid() const throw() {return m_ptr != NULL;} + inline bool is_empty() const throw() {return m_ptr == NULL;} + + inline bool operator==(const t_self & p_item) const throw() {return m_ptr == p_item.get_ptr();} + inline bool operator!=(const t_self & p_item) const throw() {return m_ptr != p_item.get_ptr();} + inline bool operator>(const t_self & p_item) const throw() {return m_ptr > p_item.get_ptr();} + inline bool operator<(const t_self & p_item) const throw() {return m_ptr < p_item.get_ptr();} + + + inline T* _duplicate_ptr() const throw()//should not be used ! temporary ! + { + if (m_ptr) m_ptr->refcount_add_ref(); + return m_ptr; + } + + inline T* detach() throw() {//should not be used ! temporary ! + T* ret = m_ptr; + m_ptr = 0; + return ret; + } + + inline void attach(T * p_ptr) throw() {//should not be used ! temporary ! + release(); + m_ptr = p_ptr; + } + inline t_self & operator<<(t_self & p_source) throw() {attach(p_source.detach());return *this;} + inline t_self & operator>>(t_self & p_dest) throw() {p_dest.attach(detach());return *this;} + private: + T* m_ptr; + }; + + template + class traits_t > : public traits_default { + public: + enum { realloc_safe = true, constructor_may_fail = false}; + }; + +}; \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/selftest.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/selftest.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,131 @@ +#include "pfc-lite.h" +#include "pfc.h" +#include "string-conv-lite.h" +#include "SmartStrStr.h" + +namespace { + class foo {}; +} + +inline pfc::string_base& operator<<(pfc::string_base& p_fmt, foo p_source) { (void)p_source; p_fmt.add_string_("FOO"); return p_fmt; } + +namespace { + using namespace pfc; + class thread_selftest : public thread { + public: + void threadProc() { + pfc::event ev; + ev.wait_for(1); + m_event.set_state(true); + ev.wait_for(1); + } + pfc::event m_event; + + void selftest() { + lores_timer timer; timer.start(); + this->start(arg_t()); + if (!m_event.wait_for(-1)) { + PFC_ASSERT(!"Should not get here"); + return; + } + PFC_ASSERT(fabs(timer.query() - 1.0) < 0.1); + this->waitTillDone(); + PFC_ASSERT(fabs(timer.query() - 2.0) < 0.1); + } + }; +} + +namespace pfc { + + static pfc::string8 testFormatter() { + return PFC_string_formatter() << "foo" << 1 << 2 << 3; + } + + + // Self test routines that need to be executed to do their payload + void selftest_runtime() { + + { + string test = "foo123"; + auto wide = pfc::wideFromUTF8(test); + auto narrow = pfc::utf8FromWide(wide); + PFC_ASSERT(test == narrow); + } + { + auto fmt = testFormatter(); + PFC_ASSERT(fmt == "foo123"); + } + { + auto fmt = pfc::format("foo", 1, 2, 3); + PFC_ASSERT(fmt == "foo123"); + } + + +#if 0 // misfires occassionally, don't run it each time + { + thread_selftest t; t.selftest(); + } +#endif + + { + stringLite s = "foo"; + PFC_ASSERT( (s + 2) == (s.c_str() + 2) ); + } + + { + stringLite s = "foo"; + s.insert_chars(2, "00"); + PFC_ASSERT( strcmp(s, "fo00o" ) == 0 ); + s.remove_chars(2, 2); + PFC_ASSERT( strcmp(s, "foo" ) == 0); + } + + { + pfc::map_t map; + map["1"] = 1; + map["2"] = 2; + map["3"] = 3; + PFC_ASSERT(map.get_count() == 3); + PFC_ASSERT(map["1"] == 1); + PFC_ASSERT(map["2"] == 2); + PFC_ASSERT(map["3"] == 3); + } + } + // Self test routines that fail at compile time if there's something seriously wrong + void selftest_static() { + PFC_STATIC_ASSERT(sizeof(t_uint8) == 1); + PFC_STATIC_ASSERT(sizeof(t_uint16) == 2); + PFC_STATIC_ASSERT(sizeof(t_uint32) == 4); + PFC_STATIC_ASSERT(sizeof(t_uint64) == 8); + + PFC_STATIC_ASSERT(sizeof(t_int8) == 1); + PFC_STATIC_ASSERT(sizeof(t_int16) == 2); + PFC_STATIC_ASSERT(sizeof(t_int32) == 4); + PFC_STATIC_ASSERT(sizeof(t_int64) == 8); + + PFC_STATIC_ASSERT(sizeof(t_float32) == 4); + PFC_STATIC_ASSERT(sizeof(t_float64) == 8); + + PFC_STATIC_ASSERT(sizeof(t_size) == sizeof(void*)); + PFC_STATIC_ASSERT(sizeof(t_ssize) == sizeof(void*)); + + PFC_STATIC_ASSERT(sizeof(wchar_t) == 2 || sizeof(wchar_t) == 4); + + PFC_STATIC_ASSERT(sizeof(GUID) == 16); + + typedef pfc::avltree_t t_asdf; + t_asdf asdf; asdf.add_item(1); + t_asdf::iterator iter = asdf._first_var(); + t_asdf::const_iterator iter2 = asdf._first_var(); + + PFC_string_formatter() << "foo" << 1337 << foo(); + + pfc::list_t l; l.add_item(3); + } + + void selftest() { + selftest_static(); selftest_runtime(); + + debugLog out; out << "PFC selftest OK"; + } +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/sort.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/sort.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,282 @@ +#include "pfc-lite.h" +#include "sort.h" +#include "sort2.h" +#include "bit_array_impl.h" +#include "ref_counter.h" + +#if defined(_M_IX86) || defined(_M_IX64) +#include +#define PFC_HAVE_RDTSC +#endif + +namespace pfc { + +void swap_void(void * item1,void * item2,t_size width) +{ + unsigned char * ptr1 = (unsigned char*)item1, * ptr2 = (unsigned char*)item2; + t_size n; + unsigned char temp; + for(n=0;n done; + done.set_size(done_size); + pfc::memset_t(done,(unsigned char)0); + t_size n; + for(n=0;nn); + PFC_ASSERT(n done; + done.set_size(done_size); + pfc::memset_t(done,(unsigned char)0); + t_size n; + for(n=0;nn); + PFC_ASSERT(n 0) pfc::swap_t(p_elem1,p_elem2); +} + + +#ifdef PFC_HAVE_RDTSC +static inline t_uint64 uniqueVal() {return __rdtsc();} +#else +static counter uniqueValCounter; +static counter::t_val uniqueVal() { + return ++uniqueValCounter; +} +#endif + +static t_size myrand(t_size count) { + const uint64_t rm = (uint64_t)RAND_MAX + 1; + uint64_t m = 1; + uint64_t v = 0; + for(;;) { + v += rand() * m; + m *= rm; + if (m >= count) break; + } + v ^= uniqueVal(); + return (t_size)(v % count); +} + +inline static t_size __pivot_helper(pfc::sort_callback & p_callback,t_size const p_base,t_size const p_count) { + PFC_ASSERT(p_count > 2); + + //t_size val1 = p_base, val2 = p_base + (p_count / 2), val3 = p_base + (p_count - 1); + + t_size val1 = myrand(p_count), val2 = myrand(p_count-1), val3 = myrand(p_count-2); + if (val2 >= val1) val2++; + if (val3 >= val1) val3++; + if (val3 >= val2) val3++; + + val1 += p_base; val2 += p_base; val3 += p_base; + + __sort_2elem_helper(p_callback,val1,val2); + __sort_2elem_helper(p_callback,val1,val3); + __sort_2elem_helper(p_callback,val2,val3); + + return val2; +} + +static void newsort(pfc::sort_callback & p_callback,t_size const p_base,t_size const p_count) { + if (p_count <= 4) { + squaresort(p_callback,p_base,p_count); + return; + } + + t_size pivot = __pivot_helper(p_callback,p_base,p_count); + + { + const t_size target = p_base + p_count - 1; + if (pivot != target) { + p_callback.swap(pivot,target); pivot = target; + } + } + + + t_size partition = p_base; + { + bool asdf = false; + for(t_size walk = p_base; walk < pivot; ++walk) { + const int comp = p_callback.compare(walk,pivot); + bool trigger = false; + if (comp == 0) { + trigger = asdf; + asdf = !asdf; + } else if (comp < 0) { + trigger = true; + } + if (trigger) { + if (partition != walk) p_callback.swap(partition,walk); + partition++; + } + } + } + if (pivot != partition) { + p_callback.swap(pivot,partition); pivot = partition; + } + + newsort(p_callback,p_base,pivot-p_base); + newsort(p_callback,pivot+1,p_count-(pivot+1-p_base)); +} + +void sort(pfc::sort_callback & p_callback,t_size p_num) { + srand((unsigned int)(uniqueVal() ^ p_num)); + newsort(p_callback,0,p_num); +} + + +void sort_void(void * base,t_size num,t_size width,int (*comp)(const void *, const void *) ) +{ + sort_void_ex(base,num,width,comp,swap_void); +} + + + + +sort_callback_stabilizer::sort_callback_stabilizer(sort_callback & p_chain,t_size p_count) +: m_chain(p_chain) +{ + m_order.set_size(p_count); + t_size n; + for(n=0;n + class reorder_callback_impl_t : public reorder_callback + { + public: + reorder_callback_impl_t(t_container & p_data) : m_data(p_data) {} + void swap(t_size p_index1,t_size p_index2) + { + pfc::swap_t(m_data[p_index1],m_data[p_index2]); + } + private: + t_container & m_data; + }; + + class reorder_callback_impl_delta : public reorder_callback + { + public: + reorder_callback_impl_delta(reorder_callback & p_data,t_size p_delta) : m_data(p_data), m_delta(p_delta) {} + void swap(t_size p_index1,t_size p_index2) + { + m_data.swap(p_index1+m_delta,p_index2+m_delta); + } + private: + reorder_callback & m_data; + t_size m_delta; + }; + + template + void reorder_t(t_container & p_data,const t_size * p_order,t_size p_count) + { + reorder_callback_impl_t cb(p_data); + reorder(cb,p_order,p_count); + } + + template + void reorder_partial_t(t_container & p_data,t_size p_base,const t_size * p_order,t_size p_count) + { + reorder_callback_impl_t cb1(p_data); + reorder_callback_impl_delta cb2( cb1, p_base ); + reorder(cb2,p_order,p_count); +// reorder(reorder_callback_impl_delta(reorder_callback_impl_t(p_data),p_base),p_order,p_count); + } + + template + class reorder_callback_impl_ptr_t : public reorder_callback + { + public: + reorder_callback_impl_ptr_t(T * p_data) : m_data(p_data) {} + void swap(t_size p_index1,t_size p_index2) + { + pfc::swap_t(m_data[p_index1],m_data[p_index2]); + } + private: + T* m_data; + }; + + + template + void reorder_ptr_t(T* p_data,const t_size * p_order,t_size p_count) + { + reorder_callback_impl_ptr_t cb(p_data); + reorder(cb,p_order,p_count); + } + + + + class NOVTABLE sort_callback + { + public: + virtual int compare(t_size p_index1, t_size p_index2) const = 0; + virtual void swap(t_size p_index1, t_size p_index2) = 0; + void swap_check(t_size p_index1, t_size p_index2) {if (compare(p_index1,p_index2) > 0) swap(p_index1,p_index2);} + }; + + class sort_callback_stabilizer : public sort_callback + { + public: + sort_callback_stabilizer(sort_callback & p_chain,t_size p_count); + virtual int compare(t_size p_index1, t_size p_index2) const; + virtual void swap(t_size p_index1, t_size p_index2); + private: + sort_callback & m_chain; + array_t m_order; + }; + + void sort(sort_callback & p_callback,t_size p_count); + void sort_stable(sort_callback & p_callback,t_size p_count); + + void sort_void_ex(void *base,t_size num,t_size width, int (*comp)(const void *, const void *),void (*swap)(void *, void *, t_size) ); + void sort_void(void * base,t_size num,t_size width,int (*comp)(const void *, const void *) ); + + template + class sort_callback_impl_simple_wrap_t : public sort_callback + { + public: + sort_callback_impl_simple_wrap_t(t_container & p_data, t_compare p_compare) : m_data(p_data), m_compare(p_compare) {} + int compare(t_size p_index1, t_size p_index2) const + { + return m_compare(m_data[p_index1],m_data[p_index2]); + } + + void swap(t_size p_index1, t_size p_index2) + { + swap_t(m_data[p_index1],m_data[p_index2]); + } + private: + t_container & m_data; + t_compare m_compare; + }; + + template + class sort_callback_impl_auto_wrap_t : public sort_callback + { + public: + sort_callback_impl_auto_wrap_t(t_container & p_data) : m_data(p_data) {} + int compare(t_size p_index1, t_size p_index2) const + { + return compare_t(m_data[p_index1],m_data[p_index2]); + } + + void swap(t_size p_index1, t_size p_index2) + { + swap_t(m_data[p_index1],m_data[p_index2]); + } + private: + t_container & m_data; + }; + + template + class sort_callback_impl_permutation_wrap_t : public sort_callback + { + public: + sort_callback_impl_permutation_wrap_t(const t_container & p_data, t_compare p_compare,t_permutation const & p_permutation) : m_data(p_data), m_compare(p_compare), m_permutation(p_permutation) {} + int compare(t_size p_index1, t_size p_index2) const + { + return m_compare(m_data[m_permutation[p_index1]],m_data[m_permutation[p_index2]]); + } + + void swap(t_size p_index1, t_size p_index2) + { + swap_t(m_permutation[p_index1],m_permutation[p_index2]); + } + private: + const t_container & m_data; + t_compare m_compare; + t_permutation const & m_permutation; + }; + + template + static void sort_t(t_container & p_data,t_compare p_compare,t_size p_count) + { + sort_callback_impl_simple_wrap_t cb(p_data,p_compare); + sort(cb,p_count); + } + + template + static void sort_stable_t(t_container & p_data,t_compare p_compare,t_size p_count) + { + sort_callback_impl_simple_wrap_t cb(p_data,p_compare); + sort_stable(cb,p_count); + } + + template + static void sort_get_permutation_t(const t_container & p_data,t_compare p_compare,t_size p_count,t_permutation const & p_permutation) + { + sort_callback_impl_permutation_wrap_t cb(p_data,p_compare,p_permutation); + sort(cb,p_count); + } + + template + static void sort_stable_get_permutation_t(const t_container & p_data,t_compare p_compare,t_size p_count,t_permutation const & p_permutation) + { + sort_callback_impl_permutation_wrap_t cb(p_data,p_compare,p_permutation); + sort_stable(cb,p_count); + } + +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/sort2.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/sort2.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,34 @@ +#pragma once + +#include "sort.h" + +// 2023 additions + + +namespace pfc { + + typedef array_t permutation_t; + + permutation_t make_identitiy(size_t); + + template + permutation_t sort_get_permutation(container_t const& data, compare_t compare) { + const size_t count = std::size(data); + auto ret = make_identitiy( count ); + if ( count > 0 ) sort_get_permutation_t(data, compare, count, ret.get_ptr() ); + return ret; + } + template + permutation_t sort_stable_get_permutation(container_t const& data, compare_t compare) { + const size_t count = std::size(data); + auto ret = make_identitiy( count ); + if ( count > 0 ) sort_stable_get_permutation_t(data, compare, count, ret.get_ptr() ); + return ret; + } + + template + void reorder(container_t& data, permutation_t const& order) { + PFC_ASSERT( std::size(data) == std::size(order) ); + reorder_t( data, order.get_ptr(), order.get_size() ); + } +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/sortstring.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/sortstring.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,30 @@ +#pragma once + +#ifdef _WIN32 +#include // std::unique_ptr<> +#endif +#ifdef __APPLE__ +#include "CFObject.h" +#endif + +namespace pfc { +#ifdef _WIN32 + typedef std::unique_ptr sortString_t; + sortString_t makeSortString(const char* str); + sortString_t makeSortString(const wchar_t* str); + int sortStringCompare(sortString_t const& s1, sortString_t const& s2); + int sortStringCompareI(sortString_t const& s1, sortString_t const& s2); +#elif defined(__APPLE__) + typedef CFObject sortString_t; + sortString_t makeSortString(const char* str); + int sortStringCompare(sortString_t const& s1, sortString_t const& s2); + int sortStringCompareI(sortString_t const& s1, sortString_t const& s2); +#else +#define PFC_SORTSTRING_GENERIC + typedef pfc::string8 sortString_t; + inline sortString_t makeSortString(const char* str) { return str; } + inline sortString_t makeSortString(pfc::string8&& str) { return std::move(str); } + int sortStringCompare(const char* str1, const char* str2); + int sortStringCompareI(const char* str1, const char* str2); +#endif +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/splitString.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/splitString.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,144 @@ +#pragma once +#include "array.h" +#include "string_base.h" + +namespace pfc { + template + void splitStringEx(t_output& p_output, const t_splitCheck& p_check, const char* p_string, t_size p_stringLen = SIZE_MAX) { + t_size walk = 0, splitBase = 0; + const t_size max = strlen_max(p_string, p_stringLen); + for (; walk < max;) { + t_size delta = p_check(p_string + walk, max - walk); + if (delta > 0) { + if (walk > splitBase) p_output(p_string + splitBase, walk - splitBase); + splitBase = walk + delta; + } else { + delta = utf8_char_len(p_string + walk, max - walk); + if (delta == 0) break; + } + walk += delta; + } + if (walk > splitBase) p_output(p_string + splitBase, walk - splitBase); + } + + class __splitStringSimple_calculateSubstringCount { + public: + __splitStringSimple_calculateSubstringCount() : m_count() {} + void operator() (const char*, t_size) { ++m_count; } + t_size get() const { return m_count; } + private: + t_size m_count; + }; + + template class _splitStringSimple_check; + + template<> class _splitStringSimple_check { + public: + _splitStringSimple_check(const char* p_chars) { + m_chars.set_size(strlen_utf8(p_chars)); + for (t_size walk = 0, ptr = 0; walk < m_chars.get_size(); ++walk) { + ptr += utf8_decode_char(p_chars + ptr, m_chars[walk]); + } + } + t_size operator()(const char* p_string, t_size p_stringLen) const { + t_uint32 c; + t_size delta = utf8_decode_char(p_string, c, p_stringLen); + if (delta > 0) { + for (t_size walk = 0; walk < m_chars.get_size(); ++walk) { + if (m_chars[walk] == c) return delta; + } + } + return 0; + } + private: + array_t m_chars; + }; + template<> class _splitStringSimple_check { + public: + _splitStringSimple_check(char c) : m_char(c) {} + t_size operator()(const char* str, t_size len) const { + PFC_ASSERT(len > 0); (void)len; + if (*str == m_char) return 1; + else return 0; + } + private: + const char m_char; + }; + template + class __splitStringSimple_arrayWrapper { + public: + __splitStringSimple_arrayWrapper(t_array& p_array) : m_walk(), m_array(p_array) {} + void operator()(const char* p_string, t_size p_stringLen) { + m_array[m_walk++] = string_part(p_string, p_stringLen); + } + private: + t_size m_walk; + t_array& m_array; + }; + template + class __splitStringSimple_listWrapper { + public: + __splitStringSimple_listWrapper(t_list& p_list) : m_list(p_list) {} + void operator()(const char* p_string, t_size p_stringLen) { + m_list += string_part(p_string, p_stringLen); + } + private: + t_list& m_list; + }; + + template + void splitStringSimple_toArray(t_array& p_output, t_split p_split, const char* p_string, t_size p_stringLen = SIZE_MAX) { + _splitStringSimple_check strCheck(p_split); + + { + __splitStringSimple_calculateSubstringCount wrapper; + splitStringEx(wrapper, strCheck, p_string, p_stringLen); + p_output.set_size(wrapper.get()); + } + + { + __splitStringSimple_arrayWrapper wrapper(p_output); + splitStringEx(wrapper, strCheck, p_string, p_stringLen); + } + } + template + void splitStringSimple_toList(t_list& p_output, t_split p_split, const char* p_string, t_size p_stringLen = SIZE_MAX) { + _splitStringSimple_check strCheck(p_split); + + __splitStringSimple_listWrapper wrapper(p_output); + splitStringEx(wrapper, strCheck, p_string, p_stringLen); + } + + template void splitStringByLines(t_out& out, const char* str) { + for (;;) { + const char* next = strchr(str, '\n'); + if (next == NULL) { + out += string_part(str, strlen(str)); break; + } + const char* walk = next; + while (walk > str && walk[-1] == '\r') --walk; + out += string_part(str, walk - str); + str = next + 1; + } + } + template void splitStringByChar(t_out& out, const char* str, char c) { + for (;;) { + const char* next = strchr(str, c); + if (next == NULL) { + out += string_part(str, strlen(str)); break; + } + out += string_part(str, next - str); + str = next + 1; + } + } + template void splitStringBySubstring(t_out& out, const char* str, const char* split) { + for (;;) { + const char* next = strstr(str, split); + if (next == NULL) { + out += string_part(str, strlen(str)); break; + } + out += string_part(str, next - str); + str = next + strlen(split); + } + } +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/splitString2.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/splitString2.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,56 @@ +#include "pfc-lite.h" +#include "pfc.h" +#include "splitString.h" +#include "splitString2.h" + +namespace { + class counter_t { + public: + size_t count = 0; + inline void operator+=(pfc::string_part_ref const& p) { (void)p; ++count; } + }; + template + class wrapper_t { + public: + ret_t * ret; + + inline void operator+=(pfc::string_part_ref const & p) { + ret->emplace_back(p); + } + }; +} + +namespace pfc { + + std::list splitString2(const char* str, const char* delim) { + std::list ret; + wrapper_t w; w.ret = &ret; + pfc::splitStringBySubstring(w, str, delim); + return ret; + } + std::list splitStringByLines2(const char* str) { + std::list ret; + wrapper_t w; w.ret = &ret; + pfc::splitStringByLines(w, str); + return ret; + } + + std::vector splitString2v(const char* str, const char* delim) { + counter_t counter; + pfc::splitStringBySubstring(counter, str, delim); + std::vector ret; ret.reserve(counter.count); + wrapper_t w; w.ret = &ret; + pfc::splitStringBySubstring(w, str, delim); + return ret; + + } + std::vector splitStringByLines2v(const char* str) { + counter_t counter; + pfc::splitStringByLines(counter, str); + std::vector ret; ret.reserve(counter.count); + wrapper_t w; w.ret = &ret; + pfc::splitStringByLines(w, str); + return ret; + } + +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/splitString2.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/splitString2.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,9 @@ +#pragma once +#include +#include +namespace pfc { + std::list splitString2(const char* str, const char* delim); + std::list splitStringByLines2(const char* str); + std::vector splitString2v(const char* str, const char* delim); + std::vector splitStringByLines2v(const char* str); +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/stdafx.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/stdafx.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,2 @@ +//cpp used to generate precompiled header +#include "pfc-lite.h" \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/stdsort.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/stdsort.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,28 @@ +#pragma once + +// OPTIONAL pfc feature, include on need to use basis +// std sort interop methods + +#include +#include +#include + +namespace pfc { + + std::vector sort_identity( size_t count ) { + std::vector ret; ret.resize(count); + for( size_t walk = 0; walk < ret.size(); ++ walk) ret[walk] = walk; + return ret; + } + + template + std::vector sort_get_order(iterator_t i1, iterator_t i2, predicate_t pred ) { + auto ret = sort_identity( i2 - i1 ); + auto pred2 = [pred, i1] (size_t idx1, size_t idx2) { + return pred( *(i1+idx1), *(i1+idx2)); + }; + std::sort(ret.begin(), ret.end(), pred2); + return ret; + } + +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/string-compare.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/string-compare.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,244 @@ +#include "pfc-lite.h" + +#include "string-compare.h" +#include "string_base.h" +#include "debug.h" +#include "bsearch_inline.h" +#include "sortstring.h" + +namespace pfc { + unsigned charToANSI(unsigned GotChar, unsigned fallback) { + if (GotChar < 128) return GotChar; + + static constexpr uint16_t from[] = {L'\u00C0', L'\u00C1', L'\u00C2', L'\u00C3', L'\u00C4', L'\u00C5', L'\u00C7', L'\u00C8', L'\u00C9', L'\u00CA', L'\u00CB', L'\u00CC', L'\u00CD', L'\u00CE', L'\u00CF', L'\u00D1', L'\u00D2', L'\u00D3', L'\u00D4', L'\u00D5', L'\u00D6', L'\u00D8', L'\u00D9', L'\u00DA', L'\u00DB', L'\u00DC', L'\u00DD', L'\u00E0', L'\u00E1', L'\u00E2', L'\u00E3', L'\u00E4', L'\u00E5', L'\u00E7', L'\u00E8', L'\u00E9', L'\u00EA', L'\u00EB', L'\u00EC', L'\u00ED', L'\u00EE', L'\u00EF', L'\u00F0', L'\u00F1', L'\u00F2', L'\u00F3', L'\u00F4', L'\u00F5', L'\u00F6', L'\u00F8', L'\u00F9', L'\u00FA', L'\u00FB', L'\u00FC', L'\u00FD', L'\u0100', L'\u0101', L'\u0102', L'\u0103', L'\u0104', L'\u0105', L'\u0106', L'\u0107', L'\u0108', L'\u0109', L'\u010A', L'\u010B', L'\u010C', L'\u010D', L'\u010E', L'\u010F', L'\u0110', L'\u0111', L'\u0112', L'\u0113', L'\u0114', L'\u0115', L'\u0116', L'\u0117', L'\u0118', L'\u0119', L'\u011A', L'\u011B', L'\u011C', L'\u011D', L'\u011E', L'\u011F', L'\u0120', L'\u0121', L'\u0122', L'\u0123', L'\u0128', L'\u0129', L'\u012A', L'\u012B', L'\u012C', L'\u012D', L'\u012E', L'\u012F', L'\u0130', L'\u0131', L'\u0134', L'\u0135', L'\u0136', L'\u0137', L'\u0139', L'\u013A', L'\u013B', L'\u013C', L'\u013D', L'\u013E', L'\u013F', L'\u0140', L'\u0141', L'\u0142', L'\u0143', L'\u0144', L'\u0145', L'\u0146', L'\u0147', L'\u0148', L'\u0149', L'\u014A', L'\u014B', L'\u014C', L'\u014D', L'\u014E', L'\u014F', L'\u0150', L'\u0151', L'\u0154', L'\u0155', L'\u0156', L'\u0157', L'\u0158', L'\u0159', L'\u015A', L'\u015B', L'\u015C', L'\u015D', L'\u015E', L'\u015F', L'\u0160', L'\u0161', L'\u0162', L'\u0163', L'\u0164', L'\u0165', L'\u0166', L'\u0167', L'\u0168', L'\u0169', L'\u016A', L'\u016B', L'\u016C', L'\u016D', L'\u016E', L'\u016F', L'\u0170', L'\u0171', L'\u0172', L'\u0173', L'\u0174', L'\u0175', L'\u0176', L'\u0177', L'\u0178', L'\u0179', L'\u017A', L'\u017B', L'\u017C', L'\u017D', L'\u017E'}; + static constexpr uint16_t to[] = {L'\u0041', L'\u0041', L'\u0041', L'\u0041', L'\u0041', L'\u0041', L'\u0043', L'\u0045', L'\u0045', L'\u0045', L'\u0045', L'\u0049', L'\u0049', L'\u0049', L'\u0049', L'\u004E', L'\u004F', L'\u004F', L'\u004F', L'\u004F', L'\u004F', L'\u004F', L'\u0055', L'\u0055', L'\u0055', L'\u0055', L'\u0059', L'\u0061', L'\u0061', L'\u0061', L'\u0061', L'\u0061', L'\u0061', L'\u0063', L'\u0065', L'\u0065', L'\u0065', L'\u0065', L'\u0069', L'\u0069', L'\u0069', L'\u0069', L'\u006F', L'\u006E', L'\u006F', L'\u006F', L'\u006F', L'\u006F', L'\u006F', L'\u006F', L'\u0075', L'\u0075', L'\u0075', L'\u0075', L'\u0079', L'\u0041', L'\u0061', L'\u0041', L'\u0061', L'\u0041', L'\u0061', L'\u0043', L'\u0063', L'\u0043', L'\u0063', L'\u0043', L'\u0063', L'\u0043', L'\u0063', L'\u0044', L'\u0064', L'\u0044', L'\u0064', L'\u0045', L'\u0065', L'\u0045', L'\u0065', L'\u0045', L'\u0065', L'\u0045', L'\u0065', L'\u0045', L'\u0065', L'\u0047', L'\u0067', L'\u0047', L'\u0067', L'\u0047', L'\u0067', L'\u0047', L'\u0067', L'\u0049', L'\u0069', L'\u0049', L'\u0069', L'\u0049', L'\u0069', L'\u0049', L'\u0069', L'\u0049', L'\u0069', L'\u004A', L'\u006A', L'\u004B', L'\u006B', L'\u004C', L'\u006C', L'\u004C', L'\u006C', L'\u004C', L'\u006C', L'\u004C', L'\u006C', L'\u004C', L'\u006C', L'\u004E', L'\u006E', L'\u004E', L'\u006E', L'\u004E', L'\u006E', L'\u006E', L'\u004E', L'\u006E', L'\u004F', L'\u006F', L'\u004F', L'\u006F', L'\u004F', L'\u006F', L'\u0052', L'\u0072', L'\u0052', L'\u0072', L'\u0052', L'\u0072', L'\u0053', L'\u0073', L'\u0053', L'\u0073', L'\u0053', L'\u0073', L'\u0053', L'\u0073', L'\u0054', L'\u0074', L'\u0054', L'\u0074', L'\u0054', L'\u0074', L'\u0055', L'\u0075', L'\u0055', L'\u0075', L'\u0055', L'\u0075', L'\u0055', L'\u0075', L'\u0055', L'\u0075', L'\u0055', L'\u0075', L'\u0057', L'\u0077', L'\u0059', L'\u0079', L'\u0059', L'\u005A', L'\u007A', L'\u005A', L'\u007A', L'\u005A', L'\u007A'}; + static_assert(std::size(from) == std::size(to)); + + size_t idx; + if (bsearch_simple_inline_t(from, std::size(from), GotChar, idx)) { + return to[idx]; + } + + return fallback; + } + + int stricmp_ascii_partial(const char* str, const char* substr) throw() { + size_t walk = 0; + for (;;) { + char c1 = str[walk]; + char c2 = substr[walk]; + c1 = ascii_tolower(c1); c2 = ascii_tolower(c2); + if (c2 == 0) return 0; // substr terminated = ret0 regardless of str content + if (c1 < c2) return -1; // ret -1 early + else if (c1 > c2) return 1; // ret 1 early + // else c1 == c2 and c2 != 0 so c1 != 0 either + ++walk; // go on + } + } + + bool stringEqualsI_ascii_ex(const char* s1, size_t len1, const char* s2, size_t len2) throw() { + t_size walk1 = 0, walk2 = 0; + for (;;) { + char c1 = (walk1 < len1) ? s1[walk1] : 0; + char c2 = (walk2 < len2) ? s2[walk2] : 0; + c1 = ascii_tolower(c1); c2 = ascii_tolower(c2); + if (c1 != c2) return false; + if (c1 == 0) return true; + walk1++; + walk2++; + } + } + + int stricmp_ascii_ex(const char* const s1, t_size const len1, const char* const s2, t_size const len2) throw() { + t_size walk1 = 0, walk2 = 0; + for (;;) { + char c1 = (walk1 < len1) ? s1[walk1] : 0; + char c2 = (walk2 < len2) ? s2[walk2] : 0; + c1 = ascii_tolower(c1); c2 = ascii_tolower(c2); + if (c1 < c2) return -1; + else if (c1 > c2) return 1; + else if (c1 == 0) return 0; + walk1++; + walk2++; + } + } + + int wstricmp_ascii(const wchar_t* s1, const wchar_t* s2) throw() { + for (;;) { + wchar_t c1 = *s1, c2 = *s2; + + if (c1 > 0 && c2 > 0 && c1 < 128 && c2 < 128) { + c1 = ascii_tolower_lookup((char)c1); + c2 = ascii_tolower_lookup((char)c2); + } else { + if (c1 == 0 && c2 == 0) return 0; + } + if (c1 < c2) return -1; + else if (c1 > c2) return 1; + else if (c1 == 0) return 0; + + s1++; + s2++; + } + } + + int stricmp_ascii(const char* s1, const char* s2) throw() { + for (;;) { + char c1 = *s1, c2 = *s2; + + if (c1 > 0 && c2 > 0) { + c1 = ascii_tolower_lookup(c1); + c2 = ascii_tolower_lookup(c2); + } else { + if (c1 == 0 && c2 == 0) return 0; + } + if (c1 < c2) return -1; + else if (c1 > c2) return 1; + else if (c1 == 0) return 0; + + s1++; + s2++; + } + } + + static int naturalSortCompareInternal(const char* s1, const char* s2, bool insensitive) throw() { + for (;; ) { + unsigned c1, c2; + size_t d1 = utf8_decode_char(s1, c1); + size_t d2 = utf8_decode_char(s2, c2); + if (d1 == 0 && d2 == 0) { + return 0; + } + if (char_is_numeric(c1) && char_is_numeric(c2)) { + // Numeric block in both strings, do natural sort magic here + size_t l1 = 1, l2 = 1; + while (char_is_numeric(s1[l1])) ++l1; + while (char_is_numeric(s2[l2])) ++l2; + + size_t l = max_t(l1, l2); + for (int pass = 0; pass < 2; ++pass) { + const char filler = pass ? 'z' : '0'; + for (size_t w = 0; w < l; ++w) { + char digit1 = filler, digit2 = filler; + + t_ssize off; + + off = w + l1 - l; + if (off >= 0) { + digit1 = s1[w - l + l1]; + } + off = w + l2 - l; + if (off >= 0) { + digit2 = s2[w - l + l2]; + } + if (digit1 < digit2) return -1; + if (digit1 > digit2) return 1; + } + } + s1 += l1; s2 += l2; + continue; + } + + unsigned alt1 = charToANSI(c1, c1), alt2 = charToANSI(c2, c2); + if (alt1 != c1 || alt2 != c2) { + if (insensitive) { + alt1 = charLower(alt1); + alt2 = charLower(alt2); + } + if (alt1 < alt2) return -1; + if (alt1 > alt2) return 1; + } + + if (insensitive) { + c1 = charLower(c1); + c2 = charLower(c2); + } + if (c1 < c2) return -1; + if (c1 > c2) return 1; + + s1 += d1; s2 += d2; + } + } + int naturalSortCompare(const char* s1, const char* s2) throw() { + int v = naturalSortCompareInternal(s1, s2, true); + if (v) return v; + v = naturalSortCompareInternal(s1, s2, false); + if (v) return v; + return strcmp(s1, s2); + } + + int naturalSortCompareI(const char* s1, const char* s2) throw() { + return naturalSortCompareInternal(s1, s2, true); + } +#ifdef _WIN32 + int winNaturalSortCompare(const char* s1, const char* s2); + int winNaturalSortCompareI(const char* s1, const char* s2); +#endif +#ifdef __APPLE__ + int appleNaturalSortCompare(const char* s1, const char* s2); + int appleNaturalSortCompareI(const char* s1, const char* s2); +#endif + int sysNaturalSortCompare(const char* s1, const char* s2) { +#ifdef _WIN32 + return winNaturalSortCompare(s1, s2); +#elif defined(__APPLE__) + return appleNaturalSortCompare(s1, s2); +#else + return naturalSortCompare(s1, s2); +#endif + } + int sysNaturalSortCompareI(const char* s1, const char* s2) { +#ifdef _WIN32 + return winNaturalSortCompareI(s1, s2); +#elif defined(__APPLE__) + return appleNaturalSortCompareI(s1, s2); +#else + return naturalSortCompareI(s1, s2); +#endif + } + const char* _stringComparatorCommon::myStringToPtr(string_part_ref) { + pfc::crash(); + } + + int stringCompareCaseInsensitiveEx(string_part_ref s1, string_part_ref s2) { + t_size w1 = 0, w2 = 0; + for (;;) { + unsigned c1, c2; t_size d1, d2; + d1 = utf8_decode_char(s1.m_ptr + w1, c1, s1.m_len - w1); + d2 = utf8_decode_char(s2.m_ptr + w2, c2, s2.m_len - w2); + if (d1 == 0 && d2 == 0) return 0; + else if (d1 == 0) return -1; + else if (d2 == 0) return 1; + else { + c1 = charLower(c1); c2 = charLower(c2); + if (c1 < c2) return -1; + else if (c1 > c2) return 1; + } + w1 += d1; w2 += d2; + } + } + int stringCompareCaseInsensitive(const char* s1, const char* s2) { + for (;;) { + unsigned c1, c2; t_size d1, d2; + d1 = utf8_decode_char(s1, c1); + d2 = utf8_decode_char(s2, c2); + if (d1 == 0 && d2 == 0) return 0; + else if (d1 == 0) return -1; + else if (d2 == 0) return 1; + else { + c1 = charLower(c1); c2 = charLower(c2); + if (c1 < c2) return -1; + else if (c1 > c2) return 1; + } + s1 += d1; s2 += d2; + } + } +#ifdef PFC_SORTSTRING_GENERIC + int sortStringCompare(const char* str1, const char* str2) { + return naturalSortCompare(str1, str2); + } + int sortStringCompareI(const char* str1, const char* str2) { + return naturalSortCompareI(str1, str2); + } +#endif +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/string-compare.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/string-compare.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,135 @@ +#pragma once +#include "string-part.h" +#include "primitives.h" + +namespace pfc { + int wstricmp_ascii(const wchar_t* s1, const wchar_t* s2) throw(); + int stricmp_ascii(const char* s1, const char* s2) throw(); + int stricmp_ascii_ex(const char* s1, t_size len1, const char* s2, t_size len2) throw(); + + // Platform-independant lowlevel natural sort implementation + int naturalSortCompare(const char* s1, const char* s2) throw(); + int naturalSortCompareI(const char* s1, const char* s2) throw(); + + // System-specialized natural sort compare, better ordering of Unicode text, specialized for Apple and MS platforms + // Falls back to naturalSortCompare/naturalSortCompareI where not available + int sysNaturalSortCompare(const char* s1, const char* s2); + int sysNaturalSortCompareI(const char* s1, const char* s2); + + int strcmp_ex(const char* p1, t_size n1, const char* p2, t_size n2) throw(); + int strcmp_nc(const char* p1, size_t n1, const char* p2, size_t n2) throw(); + + bool stringEqualsI_utf8(const char* p1, const char* p2) throw(); + bool stringEqualsI_ascii(const char* p1, const char* p2) throw(); + bool stringEqualsI_ascii_ex(const char* p1, size_t l1, const char* p2, size_t l2) throw(); + + int stringCompareCaseInsensitive(const char* s1, const char* s2); + int stringCompareCaseInsensitiveEx(string_part_ref s1, string_part_ref s2); + + template inline const char* stringToPtr(T const& val) { return val.c_str(); } + inline const char* stringToPtr(const char* val) { return val; } + + class _stringComparatorCommon { + protected: + template static const char* myStringToPtr(const T& val) { return stringToPtr(val); } + static const char* myStringToPtr(string_part_ref); + }; + + class stringComparatorCaseSensitive : private _stringComparatorCommon { + public: + template + static int compare(T1 const& v1, T2 const& v2) { + if (is_same_type::value || is_same_type::value) { + return compare_ex(stringToRef(v1), stringToRef(v2)); + } else { + return strcmp(myStringToPtr(v1), myStringToPtr(v2)); + } + } + static int compare_ex(string_part_ref v1, string_part_ref v2) { + return strcmp_ex(v1.m_ptr, v1.m_len, v2.m_ptr, v2.m_len); + } + static int compare_ex(const char* v1, t_size l1, const char* v2, t_size l2) { + return strcmp_ex(v1, l1, v2, l2); + } + }; + class stringComparatorCaseInsensitive : private _stringComparatorCommon { + public: + template + static int compare(T1 const& v1, T2 const& v2) { + if constexpr (is_same_type::value || is_same_type::value) { + return stringCompareCaseInsensitiveEx(stringToRef(v1), stringToRef(v2)); + } else { + return stringCompareCaseInsensitive(myStringToPtr(v1), myStringToPtr(v2)); + } + } + }; + class stringComparatorCaseInsensitiveASCII : private _stringComparatorCommon { + public: + template + static int compare(T1 const& v1, T2 const& v2) { + if constexpr (is_same_type::value || is_same_type::value) { + return compare_ex(stringToRef(v1), stringToRef(v2)); + } else { + return stricmp_ascii(myStringToPtr(v1), myStringToPtr(v2)); + } + } + static int compare_ex(string_part_ref v1, string_part_ref v2) { + return stricmp_ascii_ex(v1.m_ptr, v1.m_len, v2.m_ptr, v2.m_len); + } + static int compare_ex(const char* v1, t_size l1, const char* v2, t_size l2) { + return stricmp_ascii_ex(v1, l1, v2, l2); + } + }; + + class comparator_strcmp { + public: + inline static int compare(const char* p_item1, const char* p_item2) { return strcmp(p_item1, p_item2); } + inline static int compare(const wchar_t* item1, const wchar_t* item2) { return wcscmp(item1, item2); } + + static int compare(const char* p_item1, string_part_ref p_item2) { + return strcmp_ex(p_item1, SIZE_MAX, p_item2.m_ptr, p_item2.m_len); + } + static int compare(string_part_ref p_item1, string_part_ref p_item2) { + return strcmp_ex(p_item1.m_ptr, p_item1.m_len, p_item2.m_ptr, p_item2.m_len); + } + static int compare(string_part_ref p_item1, const char* p_item2) { + return strcmp_ex(p_item1.m_ptr, p_item1.m_len, p_item2, SIZE_MAX); + } + }; + + class comparator_stricmp_ascii { + public: + inline static int compare(const char* p_item1, const char* p_item2) { return stricmp_ascii(p_item1, p_item2); } + }; + + + class comparator_naturalSort { + public: + inline static int compare(const char* i1, const char* i2) throw() { return naturalSortCompare(i1, i2); } + }; + + + template int _strcmp_partial_ex(const t_char* p_string, t_size p_string_length, const t_char* p_substring, t_size p_substring_length) throw() { + for (t_size walk = 0; walk < p_substring_length; walk++) { + t_char stringchar = (walk >= p_string_length ? 0 : p_string[walk]); + t_char substringchar = p_substring[walk]; + int result = compare_t(stringchar, substringchar); + if (result != 0) return result; + } + return 0; + } + + template int strcmp_partial_ex_t(const t_char* p_string, t_size p_string_length, const t_char* p_substring, t_size p_substring_length) throw() { + p_string_length = strlen_max_t(p_string, p_string_length); p_substring_length = strlen_max_t(p_substring, p_substring_length); + return _strcmp_partial_ex(p_string, p_string_length, p_substring, p_substring_length); + } + + template + int strcmp_partial_t(const t_char* p_string, const t_char* p_substring) throw() { return strcmp_partial_ex_t(p_string, SIZE_MAX, p_substring, SIZE_MAX); } + + inline int strcmp_partial_ex(const char* str, t_size strLen, const char* substr, t_size substrLen) throw() { return strcmp_partial_ex_t(str, strLen, substr, substrLen); } + inline int strcmp_partial(const char* str, const char* substr) throw() { return strcmp_partial_t(str, substr); } + + int stricmp_ascii_partial(const char* str, const char* substr) throw(); + +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/string-conv-lite.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/string-conv-lite.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,32 @@ +#include "pfc-lite.h" +#include "string_conv.h" +#include "string-conv-lite.h" + +namespace pfc { + wstringLite wideFromUTF8(const char* pUTF8, size_t inSize) { + wstringLite ret; + size_t estimate = pfc::stringcvt::estimate_utf8_to_wide(pUTF8, inSize); + ret.m_buffer.resize(estimate); + pfc::stringcvt::convert_utf8_to_wide(ret.m_buffer.get_ptr(), estimate, pUTF8, inSize); + return ret; + } + string8 utf8FromWide(const wchar_t* pWide, size_t inSize) { + string8 ret; + size_t estimate = pfc::stringcvt::estimate_wide_to_utf8(pWide,inSize); + PFC_ASSERT(estimate > 0); + char* ptr = ret.lock_buffer(estimate-1/*nullterm included in estimate*/); + pfc::stringcvt::convert_wide_to_utf8(ptr, estimate, pWide, inSize); + ret.unlock_buffer(); + return ret; + } + wstringLite wideFromUTF8(const char* pUTF8) { + wstringLite ret; + size_t estimate = pfc::stringcvt::estimate_utf8_to_wide(pUTF8); + ret.m_buffer.resize(estimate); + pfc::stringcvt::convert_utf8_to_wide_unchecked(ret.m_buffer.get_ptr(), pUTF8); + return ret; + } + string8 utf8FromWide(const wchar_t* pWide) { + return utf8FromWide(pWide, SIZE_MAX); + } +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/string-conv-lite.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/string-conv-lite.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,22 @@ +#pragma once +#include "array.h" +#include "string_base.h" +namespace pfc { + + class wstringLite { + public: + const wchar_t* c_str() const noexcept { + return m_buffer.size() > 0 ? m_buffer.get_ptr() : L""; + } + operator const wchar_t* () const noexcept { return c_str(); } + size_t length() const noexcept { return wcslen(c_str()); } + + pfc::array_t m_buffer; + }; + + wstringLite wideFromUTF8(const char* pUTF8, size_t inSize); + string8 utf8FromWide(const wchar_t* pWide, size_t inSize); + + wstringLite wideFromUTF8(const char* pUTF8); + string8 utf8FromWide(const wchar_t* pWide); +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/string-interface.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/string-interface.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,111 @@ +#pragma once + +namespace pfc { + inline t_size _strParamLen(const char* str) { return strlen(str); } + + class NOVTABLE string_receiver { + public: + virtual void add_string(const char* p_string, t_size p_string_size = SIZE_MAX) = 0; + inline void add_string_(const char* str) { add_string(str, _strParamLen(str)); } + + void add_char(t_uint32 c);//adds unicode char to the string + void add_byte(char c) { add_string(&c, 1); } + void add_chars(t_uint32 p_char, t_size p_count) { for (; p_count; p_count--) add_char(p_char); } + protected: + string_receiver() {} + ~string_receiver() {} + }; + + class NOVTABLE string_base : public pfc::string_receiver { + public: + virtual const char* get_ptr() const = 0; + const char* c_str() const { return get_ptr(); } + virtual void add_string(const char* p_string, t_size p_length = SIZE_MAX) = 0;//same as string_receiver method + virtual void set_string(const char* p_string, t_size p_length = SIZE_MAX) { reset(); add_string(p_string, p_length); } + virtual void truncate(t_size len) = 0; + virtual t_size get_length() const { return strlen(get_ptr()); } + virtual char* lock_buffer(t_size p_requested_length) = 0; + virtual void unlock_buffer() = 0; + + void set_string_(const char* str) { set_string(str, _strParamLen(str)); } + + inline const char* toString() const { return get_ptr(); } + + //! For compatibility with old conventions. + inline t_size length() const { return get_length(); } + + inline void reset() { truncate(0); } + inline void clear() { truncate(0); } + + inline bool is_empty() const { return *get_ptr() == 0; } + + void skip_trailing_chars(const char* lstChars); + void skip_trailing_char(unsigned c = ' '); + + bool is_valid_utf8() const; + + void convert_to_lower_ascii(const char* src, char replace = '?'); + + inline const string_base& operator= (const char* src) { set_string_(src); return *this; } + inline const string_base& operator+= (const char* src) { add_string_(src); return *this; } + inline const string_base& operator= (const string_base& src) { set_string(src); return *this; } + inline const string_base& operator+= (const string_base& src) { add_string(src); return *this; } + + bool operator==(const string_base& p_other) const { return strcmp(*this, p_other) == 0; } + bool operator!=(const string_base& p_other) const { return strcmp(*this, p_other) != 0; } + bool operator>(const string_base& p_other) const { return strcmp(*this, p_other) > 0; } + bool operator<(const string_base& p_other) const { return strcmp(*this, p_other) < 0; } + bool operator>=(const string_base& p_other) const { return strcmp(*this, p_other) >= 0; } + bool operator<=(const string_base& p_other) const { return strcmp(*this, p_other) <= 0; } + + inline operator const char* () const { return get_ptr(); } + + t_size scan_filename() const; + + t_size find_first(char p_char, t_size p_start = 0) const; + t_size find_last(char p_char, t_size p_start = SIZE_MAX) const; + t_size find_first(const char* p_string, t_size p_start = 0) const; + t_size find_last(const char* p_string, t_size p_start = SIZE_MAX) const; + + void fix_dir_separator(char c = '\\'); // Backwards compat function, "do what I mean" applied on non Windows + void end_with(char c); + void end_with_slash(); + bool ends_with(char c) const; + void delimit(const char* c) { if (length() > 0) add_string(c); } + char last_char() const; + void truncate_last_char(); + void truncate_number_suffix(); + + //! Truncates string at first encountered end-of-line mark, starting search from startBytes position, in bytes.. + bool truncate_eol(t_size startBytes = 0); + //! Truncates string at first encountered end-of-line mark, starting search from startBytes position, in bytes. + //! Adds append value if string was altered. + bool fix_eol(const char* append = " (...)", t_size startBytes = 0); + //! Limits string length to the specified value in actual characters. + //! That is, multi-byte UTF-8 characters will be counted as one and never broken apart. + bool limit_length(t_size length_in_chars, const char* append = " (...)"); + + void truncate_filename() { truncate(scan_filename()); } + void truncate_to_parent_path(); + void add_filename(const char* fn) { end_with_slash(); *this += fn; } + + //! Replaces one string with another. Returns the number of occurances - zero if the string was not altered. + size_t replace_string(const char* replace, const char* replaceWith, t_size start = 0); + //! Replaces one string with another, writing the output to another string object. \n + //! Returns the number of occurances replaced. \n + //! Special: returns zero if no occurances were found - and the target string is NOT modified if so. Use with care! + size_t replace_string_ex(pfc::string_base& target, const char* replace, const char* replaceWith, t_size start = 0) const; + + string_base& _formatter() const { return const_cast(*this); } + + bool has_prefix(const char* prefix) const; + bool has_prefix_i(const char* prefix) const; + bool has_suffix(const char* suffix) const; + bool has_suffix_i(const char* suffix) const; + + bool equals(const char* other) const; + protected: + string_base() {} + ~string_base() {} + }; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/string-lite.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/string-lite.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,347 @@ +#include "pfc-lite.h" +#include "string-lite.h" +#include "string_base.h" + +namespace pfc { + const unsigned alloc_minimum = 128; + + void stringLite::add_string(const char* p_string, t_size p_string_size) { + add_string_nc(p_string, strlen_max(p_string, p_string_size)); + } + + void stringLite::add_string_nc(const char* ptr, size_t length) { + if (length > 0) { + const size_t base = m_length; + const size_t newLen = base + length; + makeRoom(newLen); + auto p = (char*)m_mem.ptr(); + memcpy(p + base, ptr, length); + p[newLen] = 0; + m_length = newLen; + m_ptr = p; + } + + } + + void stringLite::set_string(const char* p_string, t_size p_length) { + set_string_nc(p_string, strlen_max(p_string, p_length)); + } + + void stringLite::set_string_nc(const char* ptr, size_t length) { + if (length > 0) { + makeRoom(length); + auto p = (char*)m_mem.ptr(); + memcpy(p, ptr, length); + p[length] = 0; + m_ptr = p; + m_length = length; + } else { + clear(); + } + } + + void stringLite::truncate(t_size len) { + if (len < m_length) { + makeRoom(len); + if (len > 0) { + auto p = (char*)m_mem.ptr(); + p[len] = 0; + m_ptr = p; + } else { + m_ptr = ""; + } + m_length = len; + } + } + + char* stringLite::lock_buffer(t_size p_requested_length) { + makeRoom(p_requested_length); + memset(m_mem.ptr(), 0, m_mem.size()); + return (char*)m_mem.ptr(); + } + void stringLite::unlock_buffer() { + auto p = (char*)m_mem.ptr(); + m_ptr = p; + m_length = strlen(p); + } + + void stringLite::clear() noexcept { + m_ptr = ""; + m_length = 0; + if (!m_noShrink && m_mem.size() > alloc_minimum) m_mem.clear(); + } + void stringLite::copy(stringLite const& other) { + set_string_nc(other.m_ptr, other.m_length); + // m_noShrink deliberately NOT transferred + } + void stringLite::move(stringLite& other) noexcept { + m_ptr = other.m_ptr; + m_length = other.m_length; + m_mem = std::move(other.m_mem); + m_noShrink = other.m_noShrink; + other._clear(); + } + void stringLite::_clear() noexcept { + m_ptr = ""; + m_length = 0; + } + void stringLite::makeRoom(size_t newLength) { + size_t size = newLength + 1; // null term + if (m_mem.size() < size) { + size_t target = (size / 2) * 3; + if (target < alloc_minimum) target = alloc_minimum; + m_mem.resize(target); + } else if (!m_noShrink && m_mem.size() / 2 >= size) { + size_t target = size; + if (target < alloc_minimum) target = alloc_minimum; + m_mem.resize(target); + } + } + + stringLite const& stringLite::operator=(const string_base& src) { + set_string_nc(src.c_str(), src.length()); + return *this; + } + + stringLite::stringLite(const string_base& src) { + set_string_nc(src.c_str(), src.length()); + } + + stringLite::stringLite(string_part_ref const& ref) { + set_string_nc(ref.m_ptr, ref.m_len); + } + stringLite const& stringLite::operator=(const string_part_ref& ref) { + set_string_nc(ref.m_ptr, ref.m_len); return *this; + } + + size_t stringLite::replace_nontext_chars(char p_replace) { + auto p = (char*)m_mem.ptr(); + size_t ret = 0; + for (size_t w = 0; w < m_length; ++w) { + if ((uint8_t)p[w] < 32) { p[w] = p_replace; ++ret; } + } + return ret; + } + size_t stringLite::replace_char(unsigned c1, unsigned c2) { + if (c1 < 128 && c2 < 128) return replace_byte((char)c1, (char)c2); + else { + unsigned start = 0; + stringLite temp(get_ptr() + start); + truncate(start); + const char* ptr = temp; + t_size rv = 0; + while (*ptr) + { + unsigned test; + t_size delta = utf8_decode_char(ptr, test); + if (delta == 0 || test == 0) break; + if (test == c1) { test = c2; rv++; } + add_char(test); + ptr += delta; + } + return rv; + } + } + + size_t stringLite::replace_byte(char c1, char c2) { + auto p = (char*)m_mem.ptr(); + size_t ret = 0; + for (size_t w = 0; w < m_length; ++w) { + if (p[w] == c1) { p[w] = c2; ++ret; } + } + return ret; + } + + void stringLite::set_char(size_t offset, char c) { + + if (offset < m_length) { + if (c == 0) { + truncate(offset); + } else { + auto p = (char*)m_mem.ptr(); + p[offset] = c; + } + } + } + void stringLite::prealloc(size_t s) { + m_noShrink = true; + makeRoom(s); + } + + void stringLite::remove_chars(t_size first, t_size count) { + if (count == 0) return; + if (count == m_length) { + clear(); + } else { + PFC_ASSERT(first + count > first); + PFC_ASSERT(first + count <= m_length); + + auto p = (char*)m_mem.ptr(); + size_t last = first + count; + size_t trailing = m_length - last; + memmove(p + first, p + last, trailing + 1); + + size_t newLen = m_length - count; + makeRoom(newLen); + m_length = newLen; + m_ptr = (char*)m_mem.ptr(); + } + } + void stringLite::insert_chars_nc(t_size first, const char* src, t_size count) { + if (count == 0) return; + if (first > m_length) first = m_length; + size_t trailing = m_length - first; + size_t newLen = m_length + count; + makeRoom(newLen); + auto p = (char*)m_mem.ptr(); + memmove(p + first + count, p + first, trailing + 1); + memcpy(p + first, src, count); + m_length = newLen; + m_ptr = p; + } + void stringLite::insert_chars(t_size first, const char* src, t_size count) { + insert_chars_nc(first, src, strlen_max(src, count)); + } + void stringLite::insert_chars(t_size first, const char* src) { + insert_chars_nc(first, src, strlen(src)); + } + bool stringLite::equals(const stringLite& other) const noexcept { + return equals(*this, other); + } + bool stringLite::equals(const char* other) const noexcept { + return strcmp(c_str(), other) == 0; + } + bool stringLite::equals(const stringLite& v1, const stringLite& v2) noexcept { + if (v1.m_length != v2.m_length) return false; + return memcmp(v1.m_ptr, v2.m_ptr, v1.m_length) == 0; + } + bool stringLite::greater(const char* v1, size_t s1, const char* v2, size_t s2) noexcept { + if (s1 > s2) return true; + if (s1 < s2) return false; + return memcmp(v1, v2, s1) > 0; + } + bool stringLite::greater(const stringLite& v1, const stringLite& v2) noexcept { + return greater(v1.m_ptr, v1.m_length, v2.m_ptr, v2.m_length); + } + stringLite stringLite::lowerCase() const { + stringLite ret; + pfc::stringToLowerAppend(ret, this->c_str(), this->length()); + return ret; + } + stringLite stringLite::upperCase() const { + stringLite ret; + pfc::stringToUpperAppend(ret, this->c_str(), this->length()); + return ret; + } + + stringLite stringLite::subString(t_size base) const { + if (base > length()) throw exception_overflow(); + return string(c_str() + base); + } + stringLite stringLite::subString(t_size base, t_size count) const { + return string(c_str() + base, count); + } + + + t_size stringLite::indexOf(char c, t_size base) const { + return pfc::string_find_first(ptr(), c, base); + } + t_size stringLite::lastIndexOf(char c, t_size base) const { + return pfc::string_find_last(ptr(), c, base); + } + t_size stringLite::indexOf(stringp s, t_size base) const { + return pfc::string_find_first(ptr(), s, base); + } + t_size stringLite::lastIndexOf(stringp s, t_size base) const { + return pfc::string_find_last(ptr(), s, base); + } + t_size stringLite::indexOfAnyChar(stringp _s, t_size base) const { + string s(_s); + const t_size len = length(); + const char* content = ptr(); + for (t_size walk = base; walk < len; ++walk) { + if (s.contains(content[walk])) return walk; + } + return SIZE_MAX; + } + t_size stringLite::lastIndexOfAnyChar(stringp _s, t_size base) const { + string s(_s); + const char* content = ptr(); + for (t_size _walk = min_t(base, length()); _walk > 0; --_walk) { + const t_size walk = _walk - 1; + if (s.contains(content[walk])) return walk; + } + return SIZE_MAX; + } + bool stringLite::startsWith(char c) const { + return (*this)[0] == c; + } + bool stringLite::startsWith(stringp s) const { + const char* walk = ptr(); + const char* subWalk = s; + for (;;) { + if (*subWalk == 0) return true; + if (*walk != *subWalk) return false; + walk++; subWalk++; + } + } + bool stringLite::endsWith(char c) const { + const t_size len = length(); + if (len == 0) return false; + return ptr()[len - 1] == c; + } + bool stringLite::endsWith(stringp s) const { + const t_size len = length(), subLen = stringp_length(s); + if (subLen > len) return false; + return subString(len - subLen) == s; + } + + char stringLite::firstChar() const { + return (*this)[0]; + } + char stringLite::lastChar() const { + const t_size len = length(); + return len > 0 ? (*this)[len - 1] : (char)0; + } + bool stringLite::contains(char c) const { return indexOf(c) != SIZE_MAX; } + bool stringLite::contains(stringp s) const { return indexOf(s) != SIZE_MAX; } + bool stringLite::containsAnyChar(stringp s) const { return indexOfAnyChar(s) != SIZE_MAX; } + + stringLite stringLite::replace(stringp strOld, stringp strNew) const { + stringLite ret; + size_t status = this->replace_string_ex(ret, strOld, strNew); + if (status == 0) ret = *this; + return ret; + } + + stringLite stringLite::trim(char c) const { + size_t base = 0, end = 0; + const char* p = c_str(); + size_t walk = 0; + while (p[walk] == c) ++walk; + base = end = walk; + while (p[walk] != 0) { + if (p[walk] != c) end = walk + 1; + ++walk; + } + stringLite ret; + ret.set_string_nc(p + base, end - base); + return ret; + } + + bool stringLite::operator==(const stringLite& other) const noexcept { return equals(*this, other); } + bool stringLite::operator!=(const stringLite& other) const noexcept { return !equals(*this, other); } + bool stringLite::operator==(const char* other) const noexcept { return strcmp(c_str(), other) == 0; } + bool stringLite::operator!=(const char* other) const noexcept { return strcmp(c_str(), other) != 0; } + bool stringLite::operator>(const stringLite& other) const noexcept { return greater(*this, other); } + bool stringLite::operator<(const stringLite& other) const noexcept { return greater(other, *this); } + bool stringLite::operator>(const char* other) const noexcept { return greater(m_ptr, m_length, other, strlen(other)); } + bool stringLite::operator<(const char* other) const noexcept { return greater(other, strlen(other), m_ptr, m_length); } + bool stringLite::operator>=(const stringLite& other) const noexcept { return !greater(other, *this); } + bool stringLite::operator<=(const stringLite& other) const noexcept { return !greater(*this, other); } + bool stringLite::operator>=(const char* other) const noexcept { return !greater(other, strlen(other), m_ptr, m_length); } + bool stringLite::operator<=(const char* other) const noexcept { return !greater(m_ptr, m_length, other, strlen(other)); } + +} + + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/string-lite.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/string-lite.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,145 @@ +#pragma once + +#include "string-interface.h" +#include "mem_block.h" +#include "string-compare.h" + +namespace pfc { + + typedef const char* stringp; + inline size_t stringp_length(stringp s) noexcept { return strlen(s); } + + class stringLite : public string_base { + public: + struct tagNoShrink {}; + struct tagPrealloc { size_t amount; }; + stringLite(tagNoShrink) { this->setNoShrink(); } + stringLite(tagPrealloc const& tag) { this->prealloc(tag.amount); } + stringLite() {} + stringLite( const stringLite & other ) { copy(other); } + stringLite( stringLite && other ) noexcept { move(other); } + stringLite( const char * p, size_t len = SIZE_MAX ) { set_string( p, len ); } + stringLite( string_part_ref const & ); + stringLite( string_base const& ); + + stringLite const & operator=( const stringLite & other ) { copy(other); return *this; } + stringLite const & operator=( stringLite && other ) noexcept { move(other); return *this; } + stringLite const & operator=( const char * p ) { set_string( p ); return *this; } + stringLite const & operator=( const string_part_ref & ); + stringLite const & operator=( const string_base & ); + + const char * get_ptr() const { return m_ptr; } + operator const char*() const { return m_ptr; } + const char* c_str() const { return m_ptr; } + const char* ptr() const { return m_ptr; } + void add_string(const char * p_string,t_size p_string_size = SIZE_MAX); + void set_string(const char * p_string,t_size p_length = SIZE_MAX); + void add_string_nc( const char * ptr, size_t length ); + void set_string_nc( const char * ptr, size_t length ); + void truncate(t_size len); + t_size get_length() const { return m_length; } + char * lock_buffer(t_size p_requested_length); + void unlock_buffer(); + void set_char(size_t offset,char c); + void prealloc(size_t); + void setNoShrink(bool v = true) { m_noShrink = v; } + + size_t replace_nontext_chars(char p_replace = '_'); + size_t replace_char(unsigned c1,unsigned c2); + size_t replace_byte(char c1,char c2); + void remove_chars(t_size first,t_size count); + void insert_chars(t_size first,const char * src, t_size count); + void insert_chars_nc(t_size first,const char * src, t_size count); + void insert_chars(t_size first,const char * src); + + bool operator==(const stringLite& other) const noexcept; + bool operator!=(const stringLite& other) const noexcept; + bool operator==(const char* other) const noexcept; + bool operator!=(const char* other) const noexcept; + bool operator>(const stringLite& other) const noexcept; + bool operator<(const stringLite& other) const noexcept; + bool operator>(const char* other) const noexcept; + bool operator<(const char* other) const noexcept; + bool operator>=(const stringLite& other) const noexcept; + bool operator<=(const stringLite& other) const noexcept; + bool operator>=(const char* other) const noexcept; + bool operator<=(const char* other) const noexcept; + + + stringLite const& operator+=(const stringLite& other) { add_string(other.c_str(), other.length()); return *this; } + stringLite const& operator+=(const char* other) { add_string(other); return *this; } + stringLite const& operator+=(string_part_ref other) { add_string_nc(other.m_ptr, other.m_len); return *this; } + + stringLite operator+(const stringLite& other) const {stringLite ret = *this; ret += other; return ret;} + stringLite operator+(const char * other) const { stringLite ret = *this; ret += other; return ret; } + stringLite operator+(string_part_ref other) const { stringLite ret = *this; ret += other; return ret; } + + bool equals(const stringLite& other) const noexcept; + bool equals(const char* other) const noexcept; + static bool equals( const stringLite & v1, const stringLite & v2 ) noexcept; + static bool greater( const stringLite & v1, const stringLite & v2 ) noexcept; + static bool greater( const char * v1, size_t s1, const char * v2, size_t s2) noexcept; + + void clear() noexcept; + void copy( stringLite const & other ); + void move( stringLite & other ) noexcept; + + stringLite lowerCase() const; + stringLite upperCase() const; + stringLite toLower() const { return lowerCase(); } + stringLite toUpper() const { return upperCase(); } + + typedef stringComparatorCaseSensitive comparatorCaseSensitive; + typedef stringComparatorCaseInsensitive comparatorCaseInsensitive; + typedef stringComparatorCaseInsensitiveASCII comparatorCaseInsensitiveASCII; + + static bool g_equals(const stringLite& p_item1, const stringLite& p_item2) { return p_item1 == p_item2; } + static bool g_equalsCaseInsensitive(const stringLite& p_item1, const stringLite& p_item2) { return comparatorCaseInsensitive::compare(p_item1, p_item2) == 0; } + + stringLite subString(t_size base) const; + stringLite subString(t_size base, t_size count) const; + static bool isNonTextChar(char c) { return c >= 0 && c < 32; } + + //! @returns SIZE_MAX if not found. + size_t indexOf(char c, t_size base = 0) const; + //! @returns SIZE_MAX if not found. + size_t lastIndexOf(char c, size_t base = SIZE_MAX) const; + //! @returns SIZE_MAX if not found. + size_t indexOf(stringp s, size_t base = 0) const; + //! @returns SIZE_MAX if not found. + size_t lastIndexOf(stringp s, size_t base = SIZE_MAX) const; + //! @returns SIZE_MAX if not found. + size_t indexOfAnyChar(stringp s, size_t base = 0) const; + //! @returns SIZE_MAX if not found. + size_t lastIndexOfAnyChar(stringp s, size_t base = SIZE_MAX) const; + + bool contains(char c) const; + bool contains(stringp s) const; + + bool containsAnyChar(stringp s) const; + + bool startsWith(char c) const; + bool startsWith(stringp s) const; + bool endsWith(char c) const; + bool endsWith(stringp s) const; + + char firstChar() const; + char lastChar() const; + + bool isEmpty() const { return empty(); } + bool empty() const { return length() == 0;} + + stringLite replace(stringp strOld, stringp strNew) const; + stringLite trim(char c) const; + private: + void _clear() noexcept; + void makeRoom( size_t size ); + const char * m_ptr = ""; + size_t m_length = 0; + mem_block m_mem; + bool m_noShrink = false; + }; + + typedef stringLite string8; + typedef stringLite string_formatter; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/string-part.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/string-part.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,24 @@ +#pragma once + +namespace pfc { + struct string_part_ref { + const char* m_ptr; + t_size m_len; + + + static string_part_ref make(const char* ptr, t_size len); + string_part_ref substring(t_size base) const; + string_part_ref substring(t_size base, t_size len) const; + static string_part_ref make(const char* str); + bool equals(string_part_ref other) const; + bool equals(const char* str) const; + }; + + inline string_part_ref string_part(const char* ptr, t_size len) { + string_part_ref val = { ptr, len }; return val; + } + + template static string_part_ref stringToRef(T const& val) { return string_part(stringToPtr(val), val.length()); } + inline string_part_ref stringToRef(string_part_ref val) { return val; } + inline string_part_ref stringToRef(const char* val) { return string_part(val, strlen(val)); } +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/string_base.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/string_base.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,1403 @@ +#include "pfc-lite.h" +#include "string_base.h" +#include "pathUtils.h" +#include "primitives.h" +#include "other.h" +#include +#include +#include "splitString2.h" + +namespace pfc { + +bool string_base::is_valid_utf8() const { return pfc::is_valid_utf8(get_ptr()); } +t_size string_base::scan_filename() const { return pfc::scan_filename(get_ptr()); } +t_size string_base::find_first(char p_char, t_size p_start) const { return pfc::string_find_first(get_ptr(), p_char, p_start); } +t_size string_base::find_last(char p_char, t_size p_start) const { return pfc::string_find_last(get_ptr(), p_char, p_start); } +t_size string_base::find_first(const char* p_string, t_size p_start) const { return pfc::string_find_first(get_ptr(), p_string, p_start); } +t_size string_base::find_last(const char* p_string, t_size p_start) const { return pfc::string_find_last(get_ptr(), p_string, p_start); } +bool string_base::has_prefix(const char* prefix) const { return string_has_prefix(get_ptr(), prefix); } +bool string_base::has_prefix_i(const char* prefix) const { return string_has_prefix_i(get_ptr(), prefix); } +bool string_base::has_suffix(const char* suffix) const { return string_has_suffix(get_ptr(), suffix); } +bool string_base::has_suffix_i(const char* suffix) const { return string_has_suffix_i(get_ptr(), suffix); } +bool string_base::equals(const char* other) const { return strcmp(*this, other) == 0; } + +void string_receiver::add_char(t_uint32 p_char) +{ + char temp[8]; + t_size len = utf8_encode_char(p_char,temp); + if (len>0) add_string(temp,len); +} + +void string_base::skip_trailing_chars( const char * lstCharsStr ) { + std::set lstChars; + for ( ;; ) { + unsigned c; + auto delta = utf8_decode_char( lstCharsStr, c ); + if ( delta == 0 ) break; + lstCharsStr += delta; + lstChars.insert( c ); + } + + const char * str = get_ptr(); + t_size ptr,trunc = 0; + bool need_trunc = false; + for(ptr=0;str[ptr];) + { + unsigned c; + t_size delta = utf8_decode_char(str+ptr,c); + if (delta==0) break; + if ( lstChars.count( c ) > 0 ) + { + if (!need_trunc) { + need_trunc = true; + trunc = ptr; + } + } + else + { + need_trunc = false; + } + ptr += delta; + } + if (need_trunc) truncate(trunc); +} + +void string_base::skip_trailing_char(unsigned skip) +{ + const char * str = get_ptr(); + t_size ptr,trunc = 0; + bool need_trunc = false; + for(ptr=0;str[ptr];) + { + unsigned c; + t_size delta = utf8_decode_char(str+ptr,c); + if (delta==0) break; + if (c==skip) + { + if (!need_trunc) { + need_trunc = true; + trunc = ptr; + } + } + else + { + need_trunc = false; + } + ptr += delta; + } + if (need_trunc) truncate(trunc); +} + +string8 format_time(uint64_t p_seconds) { + string8 ret; + t_uint64 length = p_seconds; + unsigned weeks,days,hours,minutes,seconds; + + weeks = (unsigned)( ( length / (60*60*24*7) ) ); + days = (unsigned)( ( length / (60*60*24) ) % 7 ); + hours = (unsigned) ( ( length / (60 * 60) ) % 24); + minutes = (unsigned) ( ( length / (60 ) ) % 60 ); + seconds = (unsigned) ( ( length ) % 60 ); + + if (weeks) { + ret << weeks << "wk "; + } + if (days || weeks) { + ret << days << "d "; + } + if (hours || days || weeks) { + ret << hours << ":" << format_uint(minutes,2) << ":" << format_uint(seconds,2); + } else { + ret << minutes << ":" << format_uint(seconds,2); + } + return ret; +} + +bool is_path_separator(unsigned c) +{ +#ifdef _WIN32 + return c=='\\' || c=='/' || c=='|' || c==':'; +#else + return c == '/'; +#endif +} + +bool is_path_bad_char(unsigned c) +{ +#ifdef _WINDOWS + return c=='\\' || c=='/' || c=='|' || c==':' || c=='*' || c=='?' || c=='\"' || c=='>' || c=='<'; +#else + return c=='/' || c=='*' || c=='?'; +#endif +} + + + +char * strdup_n(const char * src,t_size len) +{ + len = strlen_max(src,len); + char * ret = (char*)malloc(len+1); + if (ret) + { + memcpy(ret,src,len); + ret[len]=0; + } + return ret; +} + +string8 string_filename(const char * fn) +{ + string8 ret; + fn += pfc::scan_filename(fn); + const char * ptr=fn,*dot=0; + while(*ptr && *ptr!='?') + { + if (*ptr=='.') dot=ptr; + ptr++; + } + + if (dot && dot>fn) ret.set_string(fn,dot-fn); + else ret.set_string(fn); + return ret; +} + +const char * extract_ext_v2( const char * filenameDotExt ) { + auto split = strrchr(filenameDotExt, '.'); + return split ? split+1 : ""; +} + +string8 remove_ext_v2( const char * filenameDotExt ) { + auto split = strrchr(filenameDotExt, '.'); + string8 ret; + if ( split ) ret.set_string_nc( filenameDotExt, split-filenameDotExt ); + else ret = filenameDotExt; + return ret; +} + +const char * filename_ext_v2( const char * fn, char slash ) { + if ( slash == 0 ) { + slash = pfc::io::path::getDefaultSeparator(); + } + size_t split = pfc::string_find_last( fn, slash ); + if ( split == SIZE_MAX ) return fn; + return fn + split + 1; +} + +string8 string_filename_ext(const char * fn) +{ + string8 ret; + fn += pfc::scan_filename(fn); + const char * ptr = fn; + while(*ptr && *ptr!='?') ptr++; + ret.set_string(fn,ptr-fn); + return ret; +} + +size_t find_extension_offset(const char * src) { + const char * start = src + pfc::scan_filename(src); + const char * end = start + strlen(start); + const char * ptr = end - 1; + while (ptr > start && *ptr != '.') + { + if (*ptr == '?') end = ptr; + ptr--; + } + + if (ptr >= start && *ptr == '.') + { + return ptr - src; + } + + return SIZE_MAX; +} + +string8 string_extension(const char * src) +{ + string8 ret; + const char * start = src + pfc::scan_filename(src); + const char * end = start + strlen(start); + const char * ptr = end-1; + while(ptr>start && *ptr!='.') + { + if (*ptr=='?') end=ptr; + ptr--; + } + + if (ptr>=start && *ptr=='.') + { + ptr++; + ret.set_string(ptr, end-ptr); + } + return ret; +} + + +bool has_path_bad_chars(const char * param) +{ + while(*param) + { + if (is_path_bad_char(*param)) return true; + param++; + } + return false; +} + +void float_to_string(char * out,t_size out_max,double val,unsigned precision,bool b_sign) { + pfc::string_fixed_t<63> temp; + t_size outptr; + + if (out_max == 0) return; + out_max--;//for null terminator + + outptr = 0; + + if (outptr == out_max) {out[outptr]=0;return;} + + if (val<0) {out[outptr++] = '-'; val = -val;} + else if (val > 0 && b_sign) {out[outptr++] = '+';} + + if (outptr == out_max) {out[outptr]=0;return;} + + + { + double powval = pow((double)10.0,(double)precision); + temp << (t_int64)floor(val * powval + 0.5); + //_i64toa(blargh,temp,10); + } + + const t_size temp_len = temp.length(); + if (temp_len <= precision) + { + out[outptr++] = '0'; + if (outptr == out_max) {out[outptr]=0;return;} + out[outptr++] = '.'; + if (outptr == out_max) {out[outptr]=0;return;} + t_size d; + for(d=precision-temp_len;d;d--) + { + out[outptr++] = '0'; + if (outptr == out_max) {out[outptr]=0;return;} + } + for(d=0;d='0' && *src<='9') + { + int d = *src - '0'; + val = val * 10 + d; + if (got_dot) div--; + src++; + } + else if (*src=='.' || *src==',') + { + if (got_dot) break; + got_dot = true; + src++; + } + else if (*src=='E' || *src=='e') + { + src++; + div += atoi(src); + break; + } + else break; + } + if (neg) val = -val; + + if (val != 0) { + // SPECIAL FIX: ensure 0.2 and 0.200000 return the EXACT same float + while (val % 10 == 0) { + val /= 10; ++div; + } + } + return (double) val * exp_int(10, div); +} + +double string_to_float(const char * src) noexcept { + return pfc_string_to_float_internal(src); +} +double string_to_float(const char * src,t_size max) noexcept { + char blargh[128]; + if (max > 127) max = 127; + t_size walk; + for(walk = 0; walk < max && src[walk]; walk++) blargh[walk] = src[walk]; + blargh[walk] = 0; + return pfc_string_to_float_internal(blargh); +} + + + +void string_base::convert_to_lower_ascii(const char * src,char replace) +{ + reset(); + PFC_ASSERT(replace>0); + while(*src) + { + unsigned c; + t_size delta = utf8_decode_char(src,c); + if (delta==0) {c = replace; delta = 1;} + else if (c>=0x80) c = replace; + add_byte((char)c); + src += delta; + } +} + +void convert_to_lower_ascii(const char * src,t_size max,char * out,char replace) +{ + t_size ptr = 0; + PFC_ASSERT(replace>0); + while(ptr=0x80) c = replace; + *(out++) = (char)c; + ptr += delta; + } + *out = 0; +} + +t_size strstr_ex(const char * p_string,t_size p_string_len,const char * p_substring,t_size p_substring_len) noexcept +{ + p_string_len = strlen_max(p_string,p_string_len); + p_substring_len = strlen_max(p_substring,p_substring_len); + t_size index = 0; + while(index + p_substring_len <= p_string_len) + { + if (memcmp(p_string+index,p_substring,p_substring_len) == 0) return index; + t_size delta = utf8_char_len(p_string+index,p_string_len - index); + if (delta == 0) break; + index += delta; + } + return SIZE_MAX; +} + +unsigned atoui_ex(const char * p_string,t_size p_string_len) noexcept +{ + unsigned ret = 0; t_size ptr = 0; + while(ptr= '0' && c <= '9' ) ) break; + ret = ret * 10 + (unsigned)( c - '0' ); + ptr++; + } + return ret; +} + +int strcmp_nc(const char* p1, size_t n1, const char * p2, size_t n2) noexcept { + t_size idx = 0; + for(;;) + { + if (idx == n1 && idx == n2) return 0; + else if (idx == n1) return -1;//end of param1 + else if (idx == n2) return 1;//end of param2 + + char c1 = p1[idx], c2 = p2[idx]; + if (c1c2) return 1; + + idx++; + } +} + +int strcmp_ex(const char* p1,t_size n1,const char* p2,t_size n2) noexcept +{ + n1 = strlen_max(p1,n1); n2 = strlen_max(p2,n2); + return strcmp_nc(p1, n1, p2, n2); +} + +t_uint64 atoui64_ex(const char * src,t_size len) noexcept { + len = strlen_max(src,len); + t_uint64 ret = 0, mul = 1; + t_size ptr = len; + t_size start = 0; +// start += skip_spacing(src+start,len-start); + + while(ptr>start) + { + char c = src[--ptr]; + if (c>='0' && c<='9') + { + ret += (c-'0') * mul; + mul *= 10; + } + else + { + ret = 0; + mul = 1; + } + } + return ret; +} + + +t_int64 atoi64_ex(const char * src,t_size len) noexcept +{ + len = strlen_max(src,len); + t_int64 ret = 0, mul = 1; + t_size ptr = len; + t_size start = 0; + bool neg = false; +// start += skip_spacing(src+start,len-start); + if (start < len && src[start] == '-') {neg = true; start++;} +// start += skip_spacing(src+start,len-start); + + while(ptr>start) + { + char c = src[--ptr]; + if (c>='0' && c<='9') + { + ret += (c-'0') * mul; + mul *= 10; + } + else + { + ret = 0; + mul = 1; + } + } + return neg ? -ret : ret; +} + + +string8 format_float(double p_val,unsigned p_width,unsigned p_prec) +{ + string8 m_buffer; + char temp[64]; + float_to_string(temp,64,p_val,p_prec,false); + temp[63] = 0; + t_size len = strlen(temp); + if (len < p_width) + m_buffer.add_chars(' ',p_width-len); + m_buffer += temp; + return m_buffer; +} + +char format_hex_char(unsigned p_val) +{ + PFC_ASSERT(p_val < 16); + return (p_val < 10) ? (char)p_val + '0' : (char)p_val - 10 + 'A'; +} + +format_int_t format_hex(t_uint64 p_val,unsigned p_width) +{ + format_int_t ret; + + if (p_width > 16) p_width = 16; + else if (p_width == 0) p_width = 1; + char temp[16]; + unsigned n; + for(n=0;n<16;n++) + { + temp[15-n] = format_hex_char((unsigned)(p_val & 0xF)); + p_val >>= 4; + } + + for(n=0;n<16 && temp[n] == '0';n++) {} + + if (n > 16 - p_width) n = 16 - p_width; + + char * out = ret.m_buffer; + for(;n<16;n++) + *(out++) = temp[n]; + *out = 0; + return ret; +} + +char format_hex_char_lowercase(unsigned p_val) +{ + PFC_ASSERT(p_val < 16); + return (p_val < 10) ? (char)p_val + '0' : (char)p_val - 10 + 'a'; +} + +format_int_t format_hex_lowercase(t_uint64 p_val,unsigned p_width) +{ + format_int_t ret; + if (p_width > 16) p_width = 16; + else if (p_width == 0) p_width = 1; + char temp[16]; + unsigned n; + for(n=0;n<16;n++) + { + temp[15-n] = format_hex_char_lowercase((unsigned)(p_val & 0xF)); + p_val >>= 4; + } + + for(n=0;n<16 && temp[n] == '0';n++) {} + + if (n > 16 - p_width) n = 16 - p_width; + + char * out = ret.m_buffer; + for(;n<16;n++) + *(out++) = temp[n]; + *out = 0; + return ret; +} + +format_int_t format_uint(t_uint64 val,unsigned p_width,unsigned p_base) +{ + format_int_t ret; + + enum {max_width = PFC_TABSIZE(ret.m_buffer) - 1}; + + if (p_width > max_width) p_width = max_width; + else if (p_width == 0) p_width = 1; + + char temp[max_width]; + + unsigned n; + for(n=0;n max_width - p_width) n = max_width - p_width; + + char * out = ret.m_buffer; + + for(;n max_width) p_width = max_width; + else if (p_width == 0) p_width = 1; + + if (neg && p_width > 1) p_width --; + + char temp[max_width]; + + unsigned n; + for(n=0;n max_width - p_width) n = max_width - p_width; + + char * out = ret.m_buffer; + + if (neg) *(out++) = '-'; + + for(;n 0 && p_spacing != 0) m_formatter << p_spacing; + m_formatter << format_hex_lowercase(buffer[n],2); + } + return m_formatter; +} + +string8 format_hexdump(const void * p_buffer,t_size p_bytes,const char * p_spacing) +{ + string8 m_formatter; + t_size n; + const t_uint8 * buffer = (const t_uint8*)p_buffer; + for(n=0;n 0 && p_spacing != 0) m_formatter << p_spacing; + m_formatter << format_hex(buffer[n],2); + } + return m_formatter; +} + + + +string8 string_replace_extension(const char * p_path,const char * p_ext) +{ + string8 m_data; + m_data = p_path; + t_size dot = m_data.find_last('.'); + if (dot < m_data.scan_filename()) + {//argh + m_data += "."; + m_data += p_ext; + } + else + { + m_data.truncate(dot+1); + m_data += p_ext; + } + return m_data; +} + +string8 string_directory(const char * p_path) +{ + string8 ret; + t_size ptr = scan_filename(p_path); + if (ptr > 1) { + if (is_path_separator(p_path[ptr-1]) && !is_path_separator(p_path[ptr-2])) --ptr; + } + ret.set_string(p_path,ptr); + return ret; +} + +t_size scan_filename(const char * ptr) +{ + t_size n; + t_size _used = strlen(ptr); + for(n=_used;n!=0;n--) + { + if (is_path_separator(ptr[n-1])) return n; + } + return 0; +} + + + +t_size string_find_first(const char * p_string,char p_tofind,t_size p_start) { + for(t_size walk = p_start; p_string[walk]; ++walk) { + if (p_string[walk] == p_tofind) return walk; + } + return SIZE_MAX; +} +t_size string_find_last(const char * p_string,char p_tofind,t_size p_start) { + return string_find_last_ex(p_string,SIZE_MAX,&p_tofind,1,p_start); +} +t_size string_find_first(const char * p_string,const char * p_tofind,t_size p_start) { + return string_find_first_ex(p_string,SIZE_MAX,p_tofind,SIZE_MAX,p_start); +} +t_size string_find_last(const char * p_string,const char * p_tofind,t_size p_start) { + return string_find_last_ex(p_string,SIZE_MAX,p_tofind,SIZE_MAX,p_start); +} + +t_size string_find_first_ex(const char * p_string,t_size p_string_length,char p_tofind,t_size p_start) { + for(t_size walk = p_start; walk < p_string_length && p_string[walk]; ++walk) { + if (p_string[walk] == p_tofind) return walk; + } + return SIZE_MAX; +} +t_size string_find_last_ex(const char * p_string,t_size p_string_length,char p_tofind,t_size p_start) { + return string_find_last_ex(p_string,p_string_length,&p_tofind,1,p_start); +} +t_size string_find_first_ex(const char * p_string,t_size p_string_length,const char * p_tofind,t_size p_tofind_length,t_size p_start) { + p_string_length = strlen_max(p_string,p_string_length); p_tofind_length = strlen_max(p_tofind,p_tofind_length); + if (p_string_length >= p_tofind_length) { + t_size max = p_string_length - p_tofind_length; + for(t_size walk = p_start; walk <= max; walk++) { + if (_strcmp_partial_ex(p_string+walk,p_string_length-walk,p_tofind,p_tofind_length) == 0) return walk; + } + } + return SIZE_MAX; +} +t_size string_find_last_ex(const char * p_string,t_size p_string_length,const char * p_tofind,t_size p_tofind_length,t_size p_start) { + p_string_length = strlen_max(p_string,p_string_length); p_tofind_length = strlen_max(p_tofind,p_tofind_length); + if (p_string_length >= p_tofind_length) { + t_size max = min_t(p_string_length - p_tofind_length,p_start); + for(t_size walk = max; walk != (t_size)(-1); walk--) { + if (_strcmp_partial_ex(p_string+walk,p_string_length-walk,p_tofind,p_tofind_length) == 0) return walk; + } + } + return SIZE_MAX; +} + +t_size string_find_first_nc(const char * p_string,t_size p_string_length,char c,t_size p_start) { + for(t_size walk = p_start; walk < p_string_length; walk++) { + if (p_string[walk] == c) return walk; + } + return SIZE_MAX; +} + +t_size string_find_first_nc(const char * p_string,t_size p_string_length,const char * p_tofind,t_size p_tofind_length,t_size p_start) { + if (p_string_length >= p_tofind_length) { + t_size max = p_string_length - p_tofind_length; + for(t_size walk = p_start; walk <= max; walk++) { + if (memcmp(p_string+walk, p_tofind, p_tofind_length) == 0) return walk; + } + } + return SIZE_MAX; +} + + +bool string_is_numeric(const char * p_string,t_size p_length) noexcept { + bool retval = false; + for(t_size walk = 0; walk < p_length && p_string[walk] != 0; walk++) { + if (!char_is_numeric(p_string[walk])) {retval = false; break;} + retval = true; + } + return retval; +} + + +void string_base::end_with(char p_char) { + if (!ends_with(p_char)) add_byte(p_char); +} +bool string_base::ends_with(char c) const { + t_size length = get_length(); + return length > 0 && get_ptr()[length-1] == c; +} + +void string_base::end_with_slash() { + end_with( io::path::getDefaultSeparator() ); +} + +char string_base::last_char() const { + size_t l = this->length(); + if (l == 0) return 0; + return this->get_ptr()[l-1]; +} +void string_base::truncate_last_char() { + size_t l = this->length(); + if (l > 0) this->truncate( l - 1 ); +} + +void string_base::truncate_number_suffix() { + size_t l = this->length(); + const char * const p = this->get_ptr(); + while( l > 0 && char_is_numeric( p[l-1] ) ) --l; + truncate( l ); +} + +bool is_multiline(const char * p_string,t_size p_len) { + for(t_size n = 0; n < p_len && p_string[n]; n++) { + switch(p_string[n]) { + case '\r': + case '\n': + return true; + } + } + return false; +} + +static t_uint64 pow10_helper(unsigned p_extra) { + t_uint64 ret = 1; + for(unsigned n = 0; n < p_extra; n++ ) ret *= 10; + return ret; +} + +static uint64_t safeMulAdd(uint64_t prev, unsigned scale, uint64_t add) { + if (add >= scale || scale == 0) throw pfc::exception_invalid_params(); + uint64_t v = prev * scale + add; + if (v / scale != prev) throw pfc::exception_invalid_params(); + return v; +} + +static size_t parseNumber(const char * in, uint64_t & outNumber) { + size_t walk = 0; + uint64_t total = 0; + for (;;) { + char c = in[walk]; + if (!pfc::char_is_numeric(c)) break; + unsigned v = (unsigned)(c - '0'); + uint64_t newVal = total * 10 + v; + if (newVal / 10 != total) throw pfc::exception_overflow(); + total = newVal; + ++walk; + } + outNumber = total; + return walk; +} + +double parse_timecode(const char * in) { + char separator = 0; + uint64_t seconds = 0; + unsigned colons = 0; + for (;;) { + uint64_t number = 0; + size_t digits = parseNumber(in, number); + if (digits == 0) throw pfc::exception_invalid_params(); + in += digits; + char nextSeparator = *in; + switch (separator) { // *previous* separator + case '.': + if (nextSeparator != 0) throw pfc::exception_bug_check(); + return (double)seconds + (double)pfc::exp_int(10, -(int)digits) * number; + case 0: // is first number in the string + seconds = number; + break; + case ':': + if (colons == 2) throw pfc::exception_invalid_params(); + ++colons; + seconds = safeMulAdd(seconds, 60, number); + break; + } + + if (nextSeparator == 0) { + // end of string + return (double)seconds; + } + + ++in; + separator = nextSeparator; + } +} + +string8 format_time_ex(double p_seconds,unsigned p_extra) { + string8 ret; + if (p_seconds < 0) {ret << "-"; p_seconds = -p_seconds;} + t_uint64 pow10 = pow10_helper(p_extra); + t_uint64 ticks = pfc::rint64(pow10 * p_seconds); + + ret << pfc::format_time(ticks / pow10); + if (p_extra>0) { + ret << "." << pfc::format_uint(ticks % pow10, p_extra); + } + return ret; +} + +void stringToUpperHere(string_base& p_out, const char* p_source, t_size p_sourceLen) { + p_out.clear(); + stringToUpperAppend(p_out, p_source, p_sourceLen); +} +void stringToLowerHere(string_base& p_out, const char* p_source, t_size p_sourceLen) { + p_out.clear(); + stringToLowerAppend(p_out, p_source, p_sourceLen); +} + +void stringToUpperAppend(string_base & out, const char * src, t_size len) { + while(len && *src) { + unsigned c; t_size d; + d = utf8_decode_char(src,c,len); + if (d==0 || d>len) break; + out.add_char(charUpper(c)); + src+=d; + len-=d; + } +} +void stringToLowerAppend(string_base & out, const char * src, t_size len) { + while(len && *src) { + unsigned c; t_size d; + d = utf8_decode_char(src,c,len); + if (d==0 || d>len) break; + out.add_char(charLower(c)); + src+=d; + len-=d; + } +} + +string8 format_file_size_short(uint64_t size, uint64_t * outUsedScale) { + string8 ret; + t_uint64 scale = 1; + const char * unit = "B"; + const char * const unitTable[] = {"B","KB","MB","GB","TB"}; + for(t_size walk = 1; walk < PFC_TABSIZE(unitTable); ++walk) { + t_uint64 next = scale * 1024; + if (size < next) break; + scale = next; unit = unitTable[walk]; + } + ret << ( size / scale ); + + if (scale > 1 && ret.length() < 3) { + t_size digits = 3 - ret.length(); + const t_uint64 mask = pow_int(10,digits); + t_uint64 remaining = ( (size * mask / scale) % mask ); + while(digits > 0 && (remaining % 10) == 0) { + remaining /= 10; --digits; + } + if (digits > 0) { + ret << "." << format_uint(remaining, (t_uint32)digits); + } + } + ret << " " << unit; + if (outUsedScale != nullptr) *outUsedScale = scale; + return ret; +} + +pfc::string8 format_index(size_t idx) { + return idx == SIZE_MAX ? "" : pfc::format_uint(idx); +} + +pfc::string8 format_permutation(const size_t* arg, size_t n) { + pfc::string_formatter ret; + for( size_t walk = 0; walk < n; ++ walk ) { + if (arg[walk] != walk) { + if ( !ret.is_empty() ) ret << ", "; + ret << arg[walk] << "->" << walk; + } + } + return ret; +} +pfc::string8 format_mask(pfc::bit_array const& mask, size_t n) { + pfc::string_formatter ret; + mask.for_each(true, 0, n, [&] (size_t idx) { + if (!ret.is_empty() ) ret << ", "; + ret << idx; + }); + return ret; +} + +bool string_base::truncate_eol(t_size start) +{ + const char * ptr = get_ptr() + start; + for(t_size n=start;*ptr;n++) + { + if (*ptr==10 || *ptr==13) + { + truncate(n); + return true; + } + ptr++; + } + return false; +} + +bool string_base::fix_eol(const char * append,t_size start) +{ + const bool rv = truncate_eol(start); + if (rv) add_string(append); + return rv; +} + +bool string_base::limit_length(t_size length_in_chars,const char * append) +{ + bool rv = false; + const char * base = get_ptr(), * ptr = base; + while(length_in_chars && utf8_advance(ptr)) length_in_chars--; + if (length_in_chars==0) + { + truncate(ptr-base); + add_string(append); + rv = true; + } + return rv; +} + +void string_base::truncate_to_parent_path() { + size_t at = scan_filename(); +#ifdef _WIN32 + while(at > 0 && (*this)[at-1] == '\\') --at; + if (at > 0 && (*this)[at-1] == ':' && (*this)[at] == '\\') ++at; +#else + // Strip trailing / + while(at > 0 && (*this)[at-1] == '/') --at; + + // Hit empty? Bring root / back to life + if (at == 0 && (*this)[0] == '/') ++at; + + // Deal with proto:// + if (at > 0 && (*this)[at-1] == ':') { + while((*this)[at] == '/') ++at; + } +#endif + this->truncate( at ); +} + +size_t string_base::replace_string(const char * replace, const char * replaceWith, t_size start) { + string_formatter temp; + size_t ret = replace_string_ex(temp, replace, replaceWith, start); + if ( ret > 0 ) * this = temp; + return ret; +} +size_t string_base::replace_string_ex (string_base & temp, const char * replace, const char * replaceWith, t_size start) const { + size_t srcDone = 0, walk = start; + size_t occurances = 0; + const char * const source = this->get_ptr(); + bool clear = false; + const size_t replaceLen = strlen( replace ); + for(;;) { + const char * ptr = strstr( source + walk, replace ); + if (ptr == NULL) { + // end + if (srcDone == 0) { + return 0; // string not altered + } + temp.add_string( source + srcDone ); + break; + } + ++occurances; + walk = ptr - source; + if (! clear ) { + temp.reset(); + clear = true; + } + temp.add_string( source + srcDone, walk - srcDone ); + temp.add_string( replaceWith ); + walk += replaceLen; + srcDone = walk; + } + return occurances; +} + +void urlEncodeAppendRaw(pfc::string_base & out, const char * in, t_size inSize) { + for(t_size walk = 0; walk < inSize; ++walk) { + const char c = in[walk]; + if (c == ' ') out.add_byte('+'); + else if (pfc::char_is_ascii_alphanumeric(c) || c == '_') out.add_byte(c); + else out << "%" << pfc::format_hex((t_uint8)c, 2); + } +} +void urlEncodeAppend(pfc::string_base & out, const char * in) { + for(;;) { + const char c = *(in++); + if (c == 0) break; + else if (c == ' ') out.add_byte('+'); + else if (pfc::char_is_ascii_alphanumeric(c) || c == '_') out.add_byte(c); + else out << "%" << pfc::format_hex((t_uint8)c, 2); + } +} +void urlEncode(pfc::string_base & out, const char * in) { + out.reset(); urlEncodeAppend(out, in); +} + +unsigned char_to_dec(char c) { + PFC_ASSERT(c != 0); + if (c >= '0' && c <= '9') return (unsigned)(c - '0'); + else throw exception_invalid_params(); +} + +unsigned char_to_hex(char c) { + if (c >= '0' && c <= '9') return (unsigned)(c - '0'); + else if (c >= 'a' && c <= 'f') return (unsigned)(c - 'a' + 10); + else if (c >= 'A' && c <= 'F') return (unsigned)(c - 'A' + 10); + else throw exception_invalid_params(); +} + + +static constexpr t_uint8 ascii_tolower_table[128] = {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F,0x40,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x5B,0x5C,0x5D,0x5E,0x5F,0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x7B,0x7C,0x7D,0x7E,0x7F}; + +uint32_t charLower(uint32_t param) +{ + if (param<128) { + return ascii_tolower_table[param]; + } +#ifdef PFC_WINDOWS_DESKTOP_APP + else if (param<0x10000) { + return (uint32_t)(size_t)CharLowerW((WCHAR*)(size_t)param); + } +#endif + else return param; +} + +uint32_t charUpper(uint32_t param) +{ + if (param<128) { + if (param>='a' && param<='z') param -= (uint32_t)( 'a' - 'A' ); + return param; + } +#ifdef PFC_WINDOWS_DESKTOP_APP + else if (param<0x10000) { + return (uint32_t)(size_t)CharUpperW((WCHAR*)(size_t)param); + } +#endif + else return param; +} + + +bool stringEqualsI_ascii(const char * p1,const char * p2) noexcept { + for(;;) + { + char c1 = *p1; + char c2 = *p2; + if (c1 > 0 && c2 > 0) { + if (ascii_tolower_table[ (unsigned) c1 ] != ascii_tolower_table[ (unsigned) c2 ]) return false; + } else { + if (c1 == 0 && c2 == 0) return true; + if (c1 == 0 || c2 == 0) return false; + if (c1 != c2) return false; + } + ++p1; ++p2; + } +} + +bool stringEqualsI_utf8(const char * p1,const char * p2) noexcept +{ + for(;;) + { + char c1 = *p1; + char c2 = *p2; + if (c1 > 0 && c2 > 0) { + if (ascii_tolower_table[ (unsigned) c1 ] != ascii_tolower_table[ (unsigned) c2 ]) return false; + ++p1; ++p2; + } else { + if (c1 == 0 && c2 == 0) return true; + if (c1 == 0 || c2 == 0) return false; + unsigned w1,w2; t_size d1,d2; + d1 = utf8_decode_char(p1,w1); + d2 = utf8_decode_char(p2,w2); + if (d1 == 0 || d2 == 0) return false; // bad UTF-8, bail + if (w1 != w2) { + if (charLower(w1) != charLower(w2)) return false; + } + p1 += d1; + p2 += d2; + } + } +} + +char ascii_tolower_lookup(char c) { + PFC_ASSERT( c >= 0); + return (char)ascii_tolower_table[ (unsigned) c ]; +} + +void string_base::fix_dir_separator(char c) { +#ifdef _WIN32 + end_with(c); +#else + end_with_slash(); +#endif +} + + + bool string_has_prefix( const char * string, const char * prefix ) { + for(size_t w = 0; ; ++w ) { + char c = prefix[w]; + if (c == 0) return true; + if (string[w] != c) return false; + } + } + const char* string_skip_prefix_i(const char* string, const char* prefix) { + const char* p1 = string; const char* p2 = prefix; + for (;;) { + unsigned w1, w2; size_t d1, d2; + d1 = utf8_decode_char(p1, w1); + d2 = utf8_decode_char(p2, w2); + if (d2 == 0) return p1; + if (d1 == 0) return nullptr; + if (w1 != w2) { + if (charLower(w1) != charLower(w2)) return nullptr; + } + p1 += d1; p2 += d2; + } + } + bool string_has_prefix_i( const char * string, const char * prefix ) { + return string_skip_prefix_i(string, prefix) != nullptr; + } + bool string_has_suffix( const char * string, const char * suffix ) { + size_t len = strlen( string ); + size_t suffixLen = strlen( suffix ); + if (suffixLen > len) return false; + size_t base = len - suffixLen; + return memcmp( string + base, suffix, suffixLen * sizeof(char)) == 0; + } + bool string_has_suffix_i( const char * string, const char * suffix ) { + for(;;) { + if (*string == 0) return false; + if (stringEqualsI_utf8( string, suffix )) return true; + if (!utf8_advance(string)) return false; + } + } + + char * strDup(const char * src) { +#ifdef _MSC_VER + return _strdup(src); +#else + return strdup(src); +#endif + } + + + string_part_ref string_part_ref::make(const char * ptr, t_size len) { + string_part_ref val = {ptr, len}; return val; + } + + string_part_ref string_part_ref::substring(t_size base) const { + PFC_ASSERT( base <= m_len ); + return make(m_ptr + base, m_len - base); + } + string_part_ref string_part_ref::substring(t_size base, t_size len) const { + PFC_ASSERT( base <= m_len && base + len <= m_len ); + return make(m_ptr + base, len); + } + + string_part_ref string_part_ref::make( const char * str ) {return make( str, strlen(str) ); } + + bool string_part_ref::equals( string_part_ref other ) const { + if ( other.m_len != this->m_len ) return false; + return memcmp( other.m_ptr, this->m_ptr, m_len ) == 0; + } + bool string_part_ref::equals( const char * str ) const { + return equals(make(str) ); + } + + string8 lineEndingsToWin(const char * str) { + string8 ret; + const char * walk = str; + for( ;; ) { + const char * eol = strchr( walk, '\n' ); + if ( eol == nullptr ) { + ret += walk; break; + } + const char * next = eol + 1; + if ( eol > walk ) { + if (eol[-1] == '\r') --eol; + if ( eol > walk ) ret.add_string_nc(walk, eol-walk); + } + ret.add_string_nc("\r\n",2); + walk = next; + } + return ret; + } + + + string8 format_char(char c) { + string8 ret; ret.add_byte(c); return ret; + } + + string8 format_ptr( const void * ptr ) { + string8 temp; + temp << "0x"; + temp << format_hex_lowercase( (size_t) ptr, sizeof(ptr) * 2 ); + return temp; + } + + + string8 format_pad_left(t_size p_chars, t_uint32 p_padding, const char * p_string, t_size p_string_length) { + string8 m_buffer; + t_size source_len = 0, source_walk = 0; + + while (source_walk < p_string_length && source_len < p_chars) { + unsigned dummy; + t_size delta = pfc::utf8_decode_char(p_string + source_walk, dummy, p_string_length - source_walk); + if (delta == 0) break; + source_len++; + source_walk += delta; + } + + m_buffer.add_string(p_string, source_walk); + m_buffer.add_chars(p_padding, p_chars - source_len); + return m_buffer; + } + + string8 format_pad_right(t_size p_chars, t_uint32 p_padding, const char * p_string, t_size p_string_length) { + string8 m_buffer; + t_size source_len = 0, source_walk = 0; + + while (source_walk < p_string_length && source_len < p_chars) { + unsigned dummy; + t_size delta = pfc::utf8_decode_char(p_string + source_walk, dummy, p_string_length - source_walk); + if (delta == 0) break; + source_len++; + source_walk += delta; + } + + m_buffer.add_chars(p_padding, p_chars - source_len); + m_buffer.add_string(p_string, source_walk); + return m_buffer; + } + + string8 stringToUpper(const char * str, size_t len) { + string8 ret; + stringToUpperAppend(ret, str, len); + return ret; + } + string8 stringToLower(const char * str, size_t len) { + string8 ret; + stringToLowerAppend(ret, str, len); + return ret; + } + + pfc::string8 prefixLines(const char* str, const char* prefix, const char * setEOL) { + const auto temp = pfc::splitStringByLines2(str); + pfc::string8 ret; ret.prealloc(1024); + for (auto& line : temp) { + if ( line.length() > 0 ) ret << prefix << line << setEOL; + } + return ret; + } + + pfc::string8 recover_invalid_utf8(const char* in, const char* subst) { + pfc::string8 ret; ret.prealloc(strlen(in)); + for (;;) { + char c = *in; + if (c == 0) break; + if (c < ' ') { + ret += subst; + } else { + ret.add_byte(c); + } + ++in; + } + return ret; + } + static bool is_spacing(char c) { + switch (c) { + case ' ': case '\n': case '\r': case '\t': return true; + default: return false; + } + } + pfc::string8 string_trim_spacing(const char* in) { + const char* temp_ptr = in; + while (is_spacing(*temp_ptr)) temp_ptr++; + const char* temp_start = temp_ptr; + const char* temp_end = temp_ptr; + while (*temp_ptr) + { + if (!is_spacing(*temp_ptr)) temp_end = temp_ptr + 1; + temp_ptr++; + } + + return string_part_ref { temp_start, (size_t)(temp_end - temp_start) }; + } +} //namespace pfc diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/string_base.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/string_base.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,438 @@ +#pragma once + +#include // std::forward + +#include "primitives.h" +#include "string-part.h" + +namespace pfc { + + t_size scan_filename(const char * ptr); + + bool is_path_separator(unsigned c); + bool is_path_bad_char(unsigned c); + bool is_valid_utf8(const char * param,t_size max = SIZE_MAX); + bool is_canonical_utf8(const char * param, size_t max = SIZE_MAX); + bool is_lower_ascii(const char * param); + bool is_multiline(const char * p_string,t_size p_len = SIZE_MAX); + bool has_path_bad_chars(const char * param); + void convert_to_lower_ascii(const char * src,t_size max,char * out,char replace = '?');//out should be at least strlen(src)+1 long + + template inline char_t ascii_tolower(char_t c) {if (c >= 'A' && c <= 'Z') c += 'a' - 'A'; return c;} + template inline char_t ascii_toupper(char_t c) {if (c >= 'a' && c <= 'z') c += 'A' - 'a'; return c;} + + t_size string_find_first(const char * p_string,char p_tofind,t_size p_start = 0); //returns infinite if not found + t_size string_find_last(const char * p_string,char p_tofind,t_size p_start = SIZE_MAX); //returns infinite if not found + t_size string_find_first(const char * p_string,const char * p_tofind,t_size p_start = 0); //returns infinite if not found + t_size string_find_last(const char * p_string,const char * p_tofind,t_size p_start = SIZE_MAX); //returns infinite if not found + + t_size string_find_first_ex(const char * p_string,t_size p_string_length,char p_tofind,t_size p_start = 0); //returns infinite if not found + t_size string_find_last_ex(const char * p_string,t_size p_string_length,char p_tofind,t_size p_start = SIZE_MAX); //returns infinite if not found + t_size string_find_first_ex(const char * p_string,t_size p_string_length,const char * p_tofind,t_size p_tofind_length,t_size p_start = 0); //returns infinite if not found + t_size string_find_last_ex(const char * p_string,t_size p_string_length,const char * p_tofind,t_size p_tofind_length,t_size p_start = SIZE_MAX); //returns infinite if not found + + + t_size string_find_first_nc(const char * p_string,t_size p_string_length,char c,t_size p_start = 0); // lengths MUST be valid, no checks are performed (faster than the other flavour) + t_size string_find_first_nc(const char * p_string,t_size p_string_length,const char * p_tofind,t_size p_tofind_length,t_size p_start = 0); // lengths MUST be valid, no checks are performed (faster than the other falvour); + + + bool string_has_prefix( const char * string, const char * prefix ); + bool string_has_prefix_i( const char * string, const char * prefix ); + const char * string_skip_prefix_i(const char* string, const char* prefix); + bool string_has_suffix( const char * string, const char * suffix ); + bool string_has_suffix_i( const char * string, const char * suffix ); + + bool string_is_numeric(const char * p_string,t_size p_length = SIZE_MAX) noexcept; + template inline bool char_is_numeric(char_t p_char) noexcept {return p_char >= '0' && p_char <= '9';} + inline bool char_is_hexnumeric(char p_char) noexcept {return char_is_numeric(p_char) || (p_char >= 'a' && p_char <= 'f') || (p_char >= 'A' && p_char <= 'F');} + inline bool char_is_ascii_alpha_upper(char p_char) noexcept {return p_char >= 'A' && p_char <= 'Z';} + inline bool char_is_ascii_alpha_lower(char p_char) noexcept {return p_char >= 'a' && p_char <= 'z';} + inline bool char_is_ascii_alpha(char p_char) noexcept {return char_is_ascii_alpha_lower(p_char) || char_is_ascii_alpha_upper(p_char);} + inline bool char_is_ascii_alphanumeric(char p_char) noexcept {return char_is_ascii_alpha(p_char) || char_is_numeric(p_char);} + + unsigned atoui_ex(const char * ptr,t_size max) noexcept; + t_int64 atoi64_ex(const char * ptr,t_size max) noexcept; + t_uint64 atoui64_ex(const char * ptr,t_size max) noexcept; + + //Throws exception_invalid_params on failure. + unsigned char_to_hex(char c); + unsigned char_to_dec(char c); + + //Throws exception_invalid_params or exception_overflow on failure. + template t_uint atohex(const char * in, t_size inLen) { + t_uint ret = 0; + const t_uint guard = (t_uint)0xF << (sizeof(t_uint) * 8 - 4); + for(t_size walk = 0; walk < inLen; ++walk) { + if (ret & guard) throw exception_overflow(); + ret = (ret << 4) | char_to_hex(in[walk]); + } + return ret; + } + template t_uint atodec(const char * in, t_size inLen) { + t_uint ret = 0; + for(t_size walk = 0; walk < inLen; ++walk) { + const t_uint prev = ret; + ret = (ret * 10) + char_to_dec(in[walk]); + if ((ret / 10) != prev) throw exception_overflow(); + } + return ret; + } + + t_size strlen_utf8(const char * s,t_size num = SIZE_MAX) noexcept;//returns number of characters in utf8 string; num - no. of bytes (optional) + t_size utf8_char_len(const char * s,t_size max = SIZE_MAX) noexcept;//returns size of utf8 character pointed by s, in bytes, 0 on error + t_size utf8_char_len_from_header(char c) noexcept; + t_size utf8_chars_to_bytes(const char* string, t_size count) noexcept; + + size_t strcpy_utf8_truncate(const char * src,char * out,size_t maxbytes); + + template void strcpy_t( char_t * out, const char_t * in ) { + for(;;) { char_t c = *in++; *out++ = c; if (c == 0) break; } + } + + t_size utf8_decode_char(const char * src,unsigned & out,t_size src_bytes) noexcept;//returns length in bytes + t_size utf8_decode_char(const char * src,unsigned & out) noexcept;//returns length in bytes + + t_size utf8_encode_char(unsigned c,char * out) noexcept;//returns used length in bytes, max 6 + + + t_size utf16_decode_char(const char16_t * p_source,unsigned * p_out,t_size p_source_length = SIZE_MAX) noexcept; + t_size utf16_encode_char(unsigned c,char16_t * out) noexcept; + +#ifdef _MSC_VER + t_size utf16_decode_char(const wchar_t * p_source,unsigned * p_out,t_size p_source_length = SIZE_MAX) noexcept; + t_size utf16_encode_char(unsigned c,wchar_t * out) noexcept; +#endif + + t_size wide_decode_char(const wchar_t * p_source,unsigned * p_out,t_size p_source_length = SIZE_MAX) noexcept; + t_size wide_encode_char(unsigned c,wchar_t * out) noexcept; + + size_t uni_char_length(const char *); + size_t uni_char_length(const char16_t *); + size_t uni_char_length(const wchar_t *); + + size_t uni_decode_char(const char16_t * p_source, unsigned & p_out, size_t p_source_length = SIZE_MAX) noexcept; + size_t uni_decode_char(const char * p_source, unsigned & p_out, size_t p_source_length = SIZE_MAX) noexcept; + size_t uni_decode_char(const wchar_t * p_source, unsigned & p_out, size_t p_source_length = SIZE_MAX) noexcept; + + size_t uni_encode_char(unsigned c, char* out) noexcept; + size_t uni_encode_char(unsigned c, char16_t* out) noexcept; + size_t uni_encode_char(unsigned c, wchar_t* out) noexcept; + +#ifdef __cpp_char8_t + inline size_t uni_char_length(const char8_t* arg) { return uni_char_length(reinterpret_cast(arg)); } + inline size_t uni_decode_char(const char8_t* p_source, unsigned& p_out, size_t p_source_length = SIZE_MAX) noexcept { return uni_decode_char(reinterpret_cast(p_source), p_out, p_source_length); } + inline size_t uni_encode_char(unsigned c, char8_t* out) noexcept { return uni_encode_char(c, reinterpret_cast(out)); } +#endif + t_size strstr_ex(const char * p_string,t_size p_string_len,const char * p_substring,t_size p_substring_len) noexcept; + + + t_size skip_utf8_chars(const char * ptr,t_size count) noexcept; + char * strdup_n(const char * src,t_size len); + + unsigned utf8_get_char(const char * src); + + inline bool utf8_advance(const char * & var) noexcept { + t_size delta = utf8_char_len(var); + var += delta; + return delta>0; + } + + inline bool utf8_advance(char * & var) noexcept { + t_size delta = utf8_char_len(var); + var += delta; + return delta>0; + } + + inline const char * utf8_char_next(const char * src) noexcept {return src + utf8_char_len(src);} + inline char * utf8_char_next(char * src) noexcept {return src + utf8_char_len(src);} + + template + class string_fixed_t : public pfc::string_base { + public: + inline string_fixed_t() {init();} + inline string_fixed_t(const string_fixed_t & p_source) {init(); *this = p_source;} + inline string_fixed_t(const char * p_source) {init(); set_string(p_source);} + + inline const string_fixed_t & operator=(const string_fixed_t & p_source) {set_string(p_source);return *this;} + inline const string_fixed_t & operator=(const char * p_source) {set_string(p_source);return *this;} + + char * lock_buffer(t_size p_requested_length) { + if (p_requested_length >= max_length) return NULL; + memset(m_data,0,sizeof(m_data)); + return m_data; + } + void unlock_buffer() { + m_length = strlen(m_data); + } + + inline operator const char * () const {return m_data;} + + const char * get_ptr() const {return m_data;} + + void add_string(const char * ptr,t_size len) { + len = strlen_max(ptr,len); + if (m_length + len < m_length || m_length + len > max_length) throw pfc::exception_overflow(); + for(t_size n=0;n max_length) len = max_length; + if (m_length > len) { + m_length = len; + m_data[len] = 0; + } + } + t_size get_length() const {return m_length;} + private: + inline void init() { + PFC_STATIC_ASSERT(max_length>1); + m_length = 0; m_data[0] = 0; + } + t_size m_length; + char m_data[max_length+1]; + }; + + typedef stringLite string8_fastalloc; + typedef stringLite string8_fast; + typedef stringLite string8_fast_aggressive; + typedef stringLite string_formatter; + typedef stringLite string; + +} + +namespace pfc { + + class string_buffer { + private: + string_base & m_owner; + char * m_buffer; + public: + explicit string_buffer(string_base & p_string,t_size p_requested_length) : m_owner(p_string) {m_buffer = m_owner.lock_buffer(p_requested_length);} + ~string_buffer() {m_owner.unlock_buffer();} + char * get_ptr() {return m_buffer;} + operator char* () {return m_buffer;} + }; + + string8 string_printf(const char * fmt, ...); + string8 string_printf_va(const char * fmt, va_list list); + void string_printf_here(string_base & out, const char * fmt, ...); + void string_printf_here_va(string_base & out, const char * fmt, va_list list); + + string8 format_time(uint64_t seconds); + string8 format_time_ex(double seconds, unsigned extra = 3); + + + double parse_timecode( const char * tc ); + + string8 string_filename(const char * fn); + string8 string_filename_ext(const char * fn); + + const char * filename_ext_v2 ( const char * fn, char slash = 0 ); + string8 remove_ext_v2( const char * fileNameDotExt ); // Just removes extension, assumes argument to hold just filename.ext, not whole path + const char * extract_ext_v2( const char * fileNameDotExt ); // Just extracts extension, assumes argument to hold just filename.ext, not whole path + + size_t find_extension_offset(const char * src); + string8 string_extension(const char * src); + string8 string_replace_extension(const char * p_path, const char * p_ext); + string8 string_directory(const char * p_path); + + void float_to_string(char * out,t_size out_max,double val,unsigned precision,bool force_sign = false);//doesnt add E+X etc, has internal range limits, useful for storing float numbers as strings without having to bother with international coma/dot settings BS + double string_to_float(const char * src,t_size len) noexcept; + double string_to_float(const char * src) noexcept; + + string8 format_float(double p_val,unsigned p_width = 0,unsigned p_prec = 7); + + struct format_int_t { + char m_buffer[64] = {}; + inline const char* c_str() const { return m_buffer; } + inline const char* get_ptr() const { return m_buffer; } + inline operator const char* () const { return c_str(); } + }; + + format_int_t format_int(t_int64 p_val, unsigned p_width = 0, unsigned p_base = 10); + format_int_t format_uint(t_uint64 p_val, unsigned p_width = 0, unsigned p_base = 10); + format_int_t format_hex(t_uint64 p_val, unsigned p_width = 0); + format_int_t format_hex_lowercase(t_uint64 p_val, unsigned p_width = 0); + + char format_hex_char_lowercase(unsigned p_val); + char format_hex_char(unsigned p_val); + + + //typedef string8_fastalloc string_formatter; +#define PFC_string_formatter() ::pfc::string_formatter()._formatter() + + string8 format_ptr( const void * ptr ); + string8 format_hexdump(const void * p_buffer,t_size p_bytes,const char * p_spacing = " "); + string8 format_hexdump_lowercase(const void * p_buffer,t_size p_bytes,const char * p_spacing = " "); + string8 format_fixedpoint(t_int64 p_val,unsigned p_point); + + string8 format_char(char c); + + string8 format_pad_left(t_size p_chars, t_uint32 p_padding /* = ' ' */, const char * p_string, t_size p_string_length = ~0); + + string8 format_pad_right(t_size p_chars, t_uint32 p_padding /* = ' ' */, const char * p_string, t_size p_string_length = ~0); + + string8 format_file_size_short(uint64_t size, uint64_t * outScaleUsed = nullptr); + + string8 format_index(size_t idx); + string8 format_permutation(const size_t* arg, size_t n); + string8 format_mask(bit_array const& mask, size_t n); +} + +inline pfc::string_base & operator<<(pfc::string_base & p_fmt,const char * p_source) {p_fmt.add_string_(p_source); return p_fmt;} + pfc::string_base & operator<<(pfc::string_base & p_fmt,const wchar_t* p_source); // string_conv.cpp +inline pfc::string_base & operator<<(pfc::string_base & p_fmt,pfc::string_part_ref source) {p_fmt.add_string(source.m_ptr, source.m_len); return p_fmt;} +inline pfc::string_base & operator<<(pfc::string_base & p_fmt,short p_val) {p_fmt.add_string(pfc::format_int(p_val)); return p_fmt;} +inline pfc::string_base & operator<<(pfc::string_base & p_fmt,unsigned short p_val) {p_fmt.add_string(pfc::format_uint(p_val)); return p_fmt;} +inline pfc::string_base & operator<<(pfc::string_base & p_fmt,int p_val) {p_fmt.add_string(pfc::format_int(p_val)); return p_fmt;} +inline pfc::string_base & operator<<(pfc::string_base & p_fmt,unsigned p_val) {p_fmt.add_string(pfc::format_uint(p_val)); return p_fmt;} +inline pfc::string_base & operator<<(pfc::string_base & p_fmt,long p_val) {p_fmt.add_string(pfc::format_int(p_val)); return p_fmt;} +inline pfc::string_base & operator<<(pfc::string_base & p_fmt,unsigned long p_val) {p_fmt.add_string(pfc::format_uint(p_val)); return p_fmt;} +inline pfc::string_base & operator<<(pfc::string_base & p_fmt,long long p_val) {p_fmt.add_string(pfc::format_int(p_val)); return p_fmt;} +inline pfc::string_base & operator<<(pfc::string_base & p_fmt,unsigned long long p_val) {p_fmt.add_string(pfc::format_uint(p_val)); return p_fmt;} +inline pfc::string_base & operator<<(pfc::string_base & p_fmt,double p_val) {p_fmt.add_string(pfc::format_float(p_val)); return p_fmt;} +inline pfc::string_base & operator<<(pfc::string_base & p_fmt,std::exception const & p_exception) {p_fmt.add_string(p_exception.what()); return p_fmt;} +inline pfc::string_base & operator<<(pfc::string_base & p_fmt,pfc::format_int_t const& in) { p_fmt.add_string(in.c_str()); return p_fmt; } + + +namespace pfc { + + + template string8 format_array(t_source const & source, const char * separator = ", ") { + string8 ret; + const t_size count = array_size_t(source); + if (count > 0) { + ret << source[0]; + for(t_size walk = 1; walk < count; ++walk) ret << separator << source[walk]; + } + return ret; + }; + + + template string8 format_hexdump_ex(const TWord * buffer, t_size bufLen, const char * spacing = " ") { + string8 ret; + for(t_size n = 0; n < bufLen; n++) { + if (n > 0 && spacing != NULL) ret << spacing; + ret << format_hex(buffer[n],sizeof(TWord) * 2); + } + return ret; + } + + + + + + typedef stringLite string_simple; +} + + +namespace pfc { + + + void stringToUpperAppend(string_base & p_out, const char * p_source, t_size p_sourceLen = SIZE_MAX); + void stringToLowerAppend(string_base & p_out, const char * p_source, t_size p_sourceLen = SIZE_MAX); + void stringToUpperHere(string_base& p_out, const char* p_source, t_size p_sourceLen = SIZE_MAX); + void stringToLowerHere(string_base& p_out, const char* p_source, t_size p_sourceLen = SIZE_MAX); + t_uint32 charLower(t_uint32 param); + t_uint32 charUpper(t_uint32 param); + char ascii_tolower_lookup(char c); + + + class string_base_ref : public string_base { + public: + string_base_ref(const char * ptr) : m_ptr(ptr), m_len(strlen(ptr)) {} + const char * get_ptr() const {return m_ptr;} + t_size get_length() const {return m_len;} + private: + void add_string(const char *,t_size) {throw pfc::exception_not_implemented();} + void set_string(const char *,t_size) {throw pfc::exception_not_implemented();} + void truncate(t_size) {throw pfc::exception_not_implemented();} + char * lock_buffer(t_size) {throw pfc::exception_not_implemented();} + void unlock_buffer() {throw pfc::exception_not_implemented();} + private: + const char * const m_ptr; + t_size const m_len; + }; + + //! Writes a string to a fixed-size buffer. Truncates the string if necessary. Always writes a null terminator. + template + void stringToBuffer(TChar (&buffer)[len], const TSource & source) { + PFC_STATIC_ASSERT(len>0); + t_size walk; + for(walk = 0; walk < len - 1 && source[walk] != 0; ++walk) { + buffer[walk] = source[walk]; + } + buffer[walk] = 0; + } + + //! Same as stringToBuffer() but throws exception_overflow() if the string could not be fully written, including null terminator. + template + void stringToBufferGuarded(TChar (&buffer)[len], const TSource & source) { + t_size walk; + for(walk = 0; source[walk] != 0; ++walk) { + if (walk >= len) throw exception_overflow(); + buffer[walk] = source[walk]; + } + if (walk >= len) throw exception_overflow(); + buffer[walk] = 0; + } + + + void urlEncodeAppendRaw(pfc::string_base & out, const char * in, t_size inSize); + void urlEncodeAppend(pfc::string_base & out, const char * in); + void urlEncode(pfc::string_base & out, const char * in); + + + char * strDup(const char * src); // POSIX strdup() clone, prevent MSVC complaining + + string8 lineEndingsToWin( const char * str ); + + string8 stringToUpper( const char * str, size_t len = SIZE_MAX ); + string8 stringToLower( const char * str, size_t len = SIZE_MAX ); + + template static void stringCombine(pfc::string_base& out, t_source const& in, const char* separator, const char* separatorLast) { + out.reset(); + for (typename t_source::const_iterator walk = in.first(); walk.is_valid(); ++walk) { + if (!out.is_empty()) { + if (walk == in.last()) out << separatorLast; + else out << separator; + } + out << stringToPtr(*walk); + } + } + + template + string stringCombineList(const TList& list, stringp separator) { + typename TList::const_iterator iter = list.first(); + string acc; + if (iter.is_valid()) { + acc = *iter; + for (++iter; iter.is_valid(); ++iter) { + acc = acc + separator + *iter; + } + } + return acc; + } + + + inline void formatHere(pfc::string_base&) {} + template void formatHere(pfc::string_base& out, first_t && first, args_t && ... args) { + out << std::forward(first); + formatHere(out, std::forward(args) ...); + } + + + template + inline string format(args_t && ... args) { + string ret; formatHere(ret, std::forward(args) ...); return ret; + } + + pfc::string8 prefixLines(const char* str, const char* prefix, const char * setEOL = "\n"); + + + pfc::string8 recover_invalid_utf8(const char* in, const char* subst = "_"); + + pfc::string8 string_trim_spacing(const char* in); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/string_conv.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/string_conv.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,500 @@ +#include "pfc-lite.h" +#include "string_conv.h" +#include "string_base.h" + + +namespace { + template + class string_writer_t { + public: + string_writer_t(t_char * p_buffer,t_size p_size) : m_buffer(p_buffer), m_size(p_size), m_writeptr(0) {} + + void write(t_char p_char) { + if (isChecked) { + if (m_writeptr < m_size) { + m_buffer[m_writeptr++] = p_char; + } + } else { + m_buffer[m_writeptr++] = p_char; + } + } + void write_multi(const t_char * p_buffer,t_size p_count) { + if (isChecked) { + const t_size delta = pfc::min_t(p_count,m_size-m_writeptr); + for(t_size n=0;n(m_writeptr,m_size-1); + m_buffer[terminator] = 0; + return terminator; + } else { + m_buffer[m_writeptr] = 0; + return m_writeptr; + } + } + bool is_overrun() const { + return m_writeptr >= m_size; + } + private: + t_char * m_buffer; + t_size m_size; + t_size m_writeptr; + }; + + + + + static constexpr uint16_t mappings1252[] = { + /*0x80*/ 0x20AC, // #EURO SIGN + /*0x81*/ 0, // #UNDEFINED + /*0x82*/ 0x201A, // #SINGLE LOW-9 QUOTATION MARK + /*0x83*/ 0x0192, // #LATIN SMALL LETTER F WITH HOOK + /*0x84*/ 0x201E, // #DOUBLE LOW-9 QUOTATION MARK + /*0x85*/ 0x2026, // #HORIZONTAL ELLIPSIS + /*0x86*/ 0x2020, // #DAGGER + /*0x87*/ 0x2021, // #DOUBLE DAGGER + /*0x88*/ 0x02C6, // #MODIFIER LETTER CIRCUMFLEX ACCENT + /*0x89*/ 0x2030, // #PER MILLE SIGN + /*0x8A*/ 0x0160, // #LATIN CAPITAL LETTER S WITH CARON + /*0x8B*/ 0x2039, // #SINGLE LEFT-POINTING ANGLE QUOTATION MARK + /*0x8C*/ 0x0152, // #LATIN CAPITAL LIGATURE OE + /*0x8D*/ 0, // #UNDEFINED + /*0x8E*/ 0x017D, // #LATIN CAPITAL LETTER Z WITH CARON + /*0x8F*/ 0, // #UNDEFINED + /*0x90*/ 0, // #UNDEFINED + /*0x91*/ 0x2018, // #LEFT SINGLE QUOTATION MARK + /*0x92*/ 0x2019, // #RIGHT SINGLE QUOTATION MARK + /*0x93*/ 0x201C, // #LEFT DOUBLE QUOTATION MARK + /*0x94*/ 0x201D, // #RIGHT DOUBLE QUOTATION MARK + /*0x95*/ 0x2022, // #BULLET + /*0x96*/ 0x2013, // #EN DASH + /*0x97*/ 0x2014, // #EM DASH + /*0x98*/ 0x02DC, // #SMALL TILDE + /*0x99*/ 0x2122, // #TRADE MARK SIGN + /*0x9A*/ 0x0161, // #LATIN SMALL LETTER S WITH CARON + /*0x9B*/ 0x203A, // #SINGLE RIGHT-POINTING ANGLE QUOTATION MARK + /*0x9C*/ 0x0153, // #LATIN SMALL LIGATURE OE + /*0x9D*/ 0, // #UNDEFINED + /*0x9E*/ 0x017E, // #LATIN SMALL LETTER Z WITH CARON + /*0x9F*/ 0x0178, // #LATIN CAPITAL LETTER Y WITH DIAERESIS + }; + + static bool charImport1252(uint32_t & unichar, char c) { + uint8_t uc = (uint8_t) c; + if (uc == 0) return false; + else if (uc < 0x80) {unichar = uc; return true;} + else if (uc < 0xA0) { + uint32_t t = mappings1252[uc-0x80]; + if (t == 0) return false; + unichar = t; return true; + } else { + unichar = uc; return true; + } + } + + static bool charExport1252(char & c, uint32_t unichar) { + if (unichar == 0) return false; + else if (unichar < 0x80 || (unichar >= 0xa0 && unichar <= 0xFF)) {c = (char)(uint8_t)unichar; return true;} + for(size_t walk = 0; walk < PFC_TABSIZE(mappings1252); ++walk) { + if (unichar == mappings1252[walk]) { + c = (char)(uint8_t)(walk + 0x80); + return true; + } + } + return false; + } + struct asciiMap_t {uint16_t from; uint8_t to;}; + static constexpr asciiMap_t g_asciiMap[] = { + {160,32},{161,33},{162,99},{164,36},{165,89},{166,124},{169,67},{170,97},{171,60},{173,45},{174,82},{178,50},{179,51},{183,46},{184,44},{185,49},{186,111},{187,62},{192,65},{193,65},{194,65},{195,65},{196,65},{197,65},{198,65},{199,67},{200,69},{201,69},{202,69},{203,69},{204,73},{205,73},{206,73},{207,73},{208,68},{209,78},{210,79},{211,79},{212,79},{213,79},{214,79},{216,79},{217,85},{218,85},{219,85},{220,85},{221,89},{224,97},{225,97},{226,97},{227,97},{228,97},{229,97},{230,97},{231,99},{232,101},{233,101},{234,101},{235,101},{236,105},{237,105},{238,105},{239,105},{241,110},{242,111},{243,111},{244,111},{245,111},{246,111},{248,111},{249,117},{250,117},{251,117},{252,117},{253,121},{255,121},{256,65},{257,97},{258,65},{259,97},{260,65},{261,97},{262,67},{263,99},{264,67},{265,99},{266,67},{267,99},{268,67},{269,99},{270,68},{271,100},{272,68},{273,100},{274,69},{275,101},{276,69},{277,101},{278,69},{279,101},{280,69},{281,101},{282,69},{283,101},{284,71},{285,103},{286,71},{287,103},{288,71},{289,103},{290,71},{291,103},{292,72},{293,104},{294,72},{295,104},{296,73},{297,105},{298,73},{299,105},{300,73},{301,105},{302,73},{303,105},{304,73},{305,105},{308,74},{309,106},{310,75},{311,107},{313,76},{314,108},{315,76},{316,108},{317,76},{318,108},{321,76},{322,108},{323,78},{324,110},{325,78},{326,110},{327,78},{328,110},{332,79},{333,111},{334,79},{335,111},{336,79},{337,111},{338,79},{339,111},{340,82},{341,114},{342,82},{343,114},{344,82},{345,114},{346,83},{347,115},{348,83},{349,115},{350,83},{351,115},{352,83},{353,115},{354,84},{355,116},{356,84},{357,116},{358,84},{359,116},{360,85},{361,117},{362,85},{363,117},{364,85},{365,117},{366,85},{367,117},{368,85},{369,117},{370,85},{371,117},{372,87},{373,119},{374,89},{375,121},{376,89},{377,90},{378,122},{379,90},{380,122},{381,90},{382,122},{384,98},{393,68},{401,70},{402,102},{407,73},{410,108},{415,79},{416,79},{417,111},{427,116},{430,84},{431,85},{432,117},{438,122},{461,65},{462,97},{463,73},{464,105},{465,79},{466,111},{467,85},{468,117},{469,85},{470,117},{471,85},{472,117},{473,85},{474,117},{475,85},{476,117},{478,65},{479,97},{484,71},{485,103},{486,71},{487,103},{488,75},{489,107},{490,79},{491,111},{492,79},{493,111},{496,106},{609,103},{697,39},{698,34},{700,39},{708,94},{710,94},{712,39},{715,96},{717,95},{732,126},{768,96},{770,94},{771,126},{782,34},{817,95},{818,95},{8192,32},{8193,32},{8194,32},{8195,32},{8196,32},{8197,32},{8198,32},{8208,45},{8209,45},{8211,45},{8212,45},{8216,39},{8217,39},{8218,44},{8220,34},{8221,34},{8222,34},{8226,46},{8230,46},{8242,39},{8245,96},{8249,60},{8250,62},{8482,84},{65281,33},{65282,34},{65283,35},{65284,36},{65285,37},{65286,38},{65287,39},{65288,40},{65289,41},{65290,42},{65291,43},{65292,44},{65293,45},{65294,46},{65295,47},{65296,48},{65297,49},{65298,50},{65299,51},{65300,52},{65301,53},{65302,54},{65303,55},{65304,56},{65305,57},{65306,58},{65307,59},{65308,60},{65309,61},{65310,62},{65312,64},{65313,65},{65314,66},{65315,67},{65316,68},{65317,69},{65318,70},{65319,71},{65320,72},{65321,73},{65322,74},{65323,75},{65324,76},{65325,77},{65326,78},{65327,79},{65328,80},{65329,81},{65330,82},{65331,83},{65332,84},{65333,85},{65334,86},{65335,87},{65336,88},{65337,89},{65338,90},{65339,91},{65340,92},{65341,93},{65342,94},{65343,95},{65344,96},{65345,97},{65346,98},{65347,99},{65348,100},{65349,101},{65350,102},{65351,103},{65352,104},{65353,105},{65354,106},{65355,107},{65356,108},{65357,109},{65358,110},{65359,111},{65360,112},{65361,113},{65362,114},{65363,115},{65364,116},{65365,117},{65366,118},{65367,119},{65368,120},{65369,121},{65370,122},{65371,123},{65372,124},{65373,125},{65374,126}}; + +} + +namespace pfc { + namespace stringcvt { + + char charToASCII( unsigned c ) { + if (c < 128) return (char)c; + unsigned lo = 0, hi = PFC_TABSIZE(g_asciiMap); + while( lo < hi ) { + const unsigned mid = (lo + hi) / 2; + const asciiMap_t entry = g_asciiMap[mid]; + if ( c > entry.from ) { + lo = mid + 1; + } else if (c < entry.from) { + hi = mid; + } else { + return (char)entry.to; + } + } + return '?'; + } + + t_size convert_utf8_to_wide(wchar_t * p_out,t_size p_out_size,const char * p_in,t_size p_in_size) { + const t_size insize = p_in_size; + t_size inptr = 0; + string_writer_t writer(p_out,p_out_size); + + while(inptr < insize && !writer.is_overrun()) { + unsigned newchar = 0; + t_size delta = utf8_decode_char(p_in + inptr,newchar,insize - inptr); + if (delta == 0 || newchar == 0) break; + PFC_ASSERT(inptr + delta <= insize); + inptr += delta; + writer.write_as_wide(newchar); + } + + return writer.finalize(); + } + + t_size convert_utf8_to_wide_unchecked(wchar_t * p_out,const char * p_in) { + t_size inptr = 0; + string_writer_t writer(p_out,SIZE_MAX); + + while(!writer.is_overrun()) { + unsigned newchar = 0; + t_size delta = utf8_decode_char(p_in + inptr,newchar); + if (delta == 0 || newchar == 0) break; + inptr += delta; + writer.write_as_wide(newchar); + } + + return writer.finalize(); + } + + t_size convert_wide_to_utf8(char * p_out,t_size p_out_size,const wchar_t * p_in,t_size p_in_size) { + const t_size insize = p_in_size; + t_size inptr = 0; + string_writer_t writer(p_out,p_out_size); + + while(inptr < insize && !writer.is_overrun()) { + unsigned newchar = 0; + t_size delta = wide_decode_char(p_in + inptr,&newchar,insize - inptr); + if (delta == 0 || newchar == 0) break; + PFC_ASSERT(inptr + delta <= insize); + inptr += delta; + writer.write_as_utf8(newchar); + } + + return writer.finalize(); + } + + t_size estimate_utf8_to_wide(const char * p_in) { + t_size inptr = 0; + t_size retval = 1;//1 for null terminator + for(;;) { + unsigned newchar = 0; + t_size delta = utf8_decode_char(p_in + inptr,newchar); + if (delta == 0 || newchar == 0) break; + inptr += delta; + + { + wchar_t temp[2]; + retval += wide_encode_char(newchar,temp); + } + } + return retval; + } + + t_size estimate_utf8_to_wide(const char * p_in,t_size p_in_size) { + const t_size insize = p_in_size; + t_size inptr = 0; + t_size retval = 1;//1 for null terminator + while(inptr < insize) { + unsigned newchar = 0; + t_size delta = utf8_decode_char(p_in + inptr,newchar,insize - inptr); + if (delta == 0 || newchar == 0) break; + PFC_ASSERT(inptr + delta <= insize); + inptr += delta; + + { + wchar_t temp[2]; + retval += wide_encode_char(newchar,temp); + } + } + return retval; + } + + t_size estimate_wide_to_utf8(const wchar_t * p_in,t_size p_in_size) { + const t_size insize = p_in_size; + t_size inptr = 0; + t_size retval = 1;//1 for null terminator + while(inptr < insize) { + unsigned newchar = 0; + t_size delta = wide_decode_char(p_in + inptr,&newchar,insize - inptr); + if (delta == 0 || newchar == 0) break; + PFC_ASSERT(inptr + delta <= insize); + inptr += delta; + + { + char temp[6]; + delta = utf8_encode_char(newchar,temp); + if (delta == 0) break; + retval += delta; + } + } + return retval; + } + + t_size estimate_wide_to_win1252( const wchar_t * p_in, t_size p_in_size ) { + const t_size insize = p_in_size; + t_size inptr = 0; + t_size retval = 1;//1 for null terminator + while(inptr < insize) { + unsigned newchar = 0; + t_size delta = wide_decode_char(p_in + inptr,&newchar,insize - inptr); + if (delta == 0 || newchar == 0) break; + PFC_ASSERT(inptr + delta <= insize); + inptr += delta; + + ++retval; + } + return retval; + + } + + t_size convert_wide_to_win1252( char * p_out, t_size p_out_size, const wchar_t * p_in, t_size p_in_size ) { + const t_size insize = p_in_size; + t_size inptr = 0; + string_writer_t writer(p_out,p_out_size); + + while(inptr < insize && !writer.is_overrun()) { + unsigned newchar = 0; + t_size delta = wide_decode_char(p_in + inptr,&newchar,insize - inptr); + if (delta == 0 || newchar == 0) break; + PFC_ASSERT(inptr + delta <= insize); + inptr += delta; + + char temp; + if (!charExport1252( temp, newchar )) temp = '?'; + writer.write( temp ); + } + + return writer.finalize(); + + } + + t_size estimate_win1252_to_wide( const char * p_source, t_size p_source_size ) { + return strlen_max_t( p_source, p_source_size ) + 1; + } + + t_size convert_win1252_to_wide( wchar_t * p_out, t_size p_out_size, const char * p_in, t_size p_in_size ) { + const t_size insize = p_in_size; + t_size inptr = 0; + string_writer_t writer(p_out,p_out_size); + + while(inptr < insize && !writer.is_overrun()) { + char inChar = p_in[inptr]; + if (inChar == 0) break; + ++inptr; + + unsigned out; + if (!charImport1252( out , inChar )) out = '?'; + writer.write_as_wide( out ); + } + + return writer.finalize(); + } + + t_size estimate_utf8_to_win1252( const char * p_in, t_size p_in_size ) { + const t_size insize = p_in_size; + t_size inptr = 0; + t_size retval = 1;//1 for null terminator + while(inptr < insize) { + unsigned newchar = 0; + t_size delta = utf8_decode_char(p_in + inptr,newchar,insize - inptr); + if (delta == 0 || newchar == 0) break; + PFC_ASSERT(inptr + delta <= insize); + inptr += delta; + + ++retval; + } + return retval; + } + t_size convert_utf8_to_win1252( char * p_out, t_size p_out_size, const char * p_in, t_size p_in_size ) { + const t_size insize = p_in_size; + t_size inptr = 0; + string_writer_t writer(p_out,p_out_size); + + while(inptr < insize && !writer.is_overrun()) { + unsigned newchar = 0; + t_size delta = utf8_decode_char(p_in + inptr,newchar,insize - inptr); + if (delta == 0 || newchar == 0) break; + PFC_ASSERT(inptr + delta <= insize); + inptr += delta; + + char temp; + if (!charExport1252( temp, newchar )) temp = '?'; + writer.write( temp ); + } + + return writer.finalize(); + } + + t_size estimate_win1252_to_utf8( const char * p_in, t_size p_in_size ) { + const size_t insize = p_in_size; + t_size inptr = 0; + t_size retval = 1; // 1 for null terminator + while(inptr < insize) { + unsigned newchar; + char c = p_in[inptr]; + if (c == 0) break; + ++inptr; + if (!charImport1252( newchar, c)) newchar = '?'; + + char temp[6]; + retval += pfc::utf8_encode_char( newchar, temp ); + } + return retval; + } + + t_size convert_win1252_to_utf8( char * p_out, t_size p_out_size, const char * p_in, t_size p_in_size ) { + const t_size insize = p_in_size; + t_size inptr = 0; + string_writer_t writer(p_out,p_out_size); + + while(inptr < insize && !writer.is_overrun()) { + char inChar = p_in[inptr]; + if (inChar == 0) break; + ++inptr; + + unsigned out; + if (!charImport1252( out , inChar )) out = '?'; + writer.write_as_utf8( out ); + } + + return writer.finalize(); + } + + t_size estimate_utf8_to_ascii( const char * p_source, t_size p_source_size ) { + return estimate_utf8_to_win1252( p_source, p_source_size ); + } + t_size convert_utf8_to_ascii( char * p_out, t_size p_out_size, const char * p_in, t_size p_in_size ) { + const t_size insize = p_in_size; + t_size inptr = 0; + string_writer_t writer(p_out,p_out_size); + + while(inptr < insize && !writer.is_overrun()) { + unsigned newchar = 0; + t_size delta = utf8_decode_char(p_in + inptr,newchar,insize - inptr); + if (delta == 0 || newchar == 0) break; + PFC_ASSERT(inptr + delta <= insize); + inptr += delta; + + writer.write( charToASCII(newchar) ); + } + + return writer.finalize(); + } + + + + // 2016-05-16 additions + // Explicit UTF-16 converters + t_size estimate_utf16_to_utf8( const char16_t * p_in, size_t p_in_size ) { + const t_size insize = p_in_size; + t_size inptr = 0; + t_size retval = 1;//1 for null terminator + while(inptr < insize) { + unsigned newchar = 0; + t_size delta = utf16_decode_char(p_in + inptr,&newchar,insize - inptr); + if (delta == 0 || newchar == 0) break; + PFC_ASSERT(inptr + delta <= insize); + inptr += delta; + + { + char temp[6]; + delta = utf8_encode_char(newchar,temp); + if (delta == 0) break; + retval += delta; + } + } + return retval; + } + t_size convert_utf16_to_utf8( char * p_out, size_t p_out_size, const char16_t * p_in, size_t p_in_size ) { + const t_size insize = p_in_size; + t_size inptr = 0; + string_writer_t writer(p_out,p_out_size); + + while(inptr < insize && !writer.is_overrun()) { + unsigned newchar = 0; + t_size delta = utf16_decode_char(p_in + inptr,&newchar,insize - inptr); + if (delta == 0 || newchar == 0) break; + PFC_ASSERT(inptr + delta <= insize); + inptr += delta; + writer.write_as_utf8(newchar); + } + + return writer.finalize(); + } + + } +} + +#ifdef _WINDOWS + + +namespace pfc { + namespace stringcvt { + + + t_size convert_codepage_to_wide(unsigned p_codepage,wchar_t * p_out,t_size p_out_size,const char * p_source,t_size p_source_size) { + if (p_out_size == 0) return 0; + memset(p_out,0,p_out_size * sizeof(*p_out)); + MultiByteToWideChar(p_codepage,0,p_source, pfc::downcast_guarded(p_source_size),p_out, pfc::downcast_guarded(p_out_size)); + p_out[p_out_size-1] = 0; + return wcslen(p_out); + } + + t_size convert_wide_to_codepage(unsigned p_codepage,char * p_out,t_size p_out_size,const wchar_t * p_source,t_size p_source_size) { + if (p_out_size == 0) return 0; + memset(p_out,0,p_out_size * sizeof(*p_out)); + WideCharToMultiByte(p_codepage,0,p_source,pfc::downcast_guarded(p_source_size),p_out,pfc::downcast_guarded(p_out_size),0,FALSE); + p_out[p_out_size-1] = 0; + return strlen(p_out); + } + + t_size estimate_codepage_to_wide(unsigned p_codepage,const char * p_source,t_size p_source_size) { + return MultiByteToWideChar(p_codepage,0,p_source, pfc::downcast_guarded(strlen_max(p_source,p_source_size)),0,0) + 1; + } + t_size estimate_wide_to_codepage(unsigned p_codepage,const wchar_t * p_source,t_size p_source_size) { + return WideCharToMultiByte(p_codepage,0,p_source, pfc::downcast_guarded(wcslen_max(p_source,p_source_size)),0,0,0,FALSE) + 1; + } + } + +} + +#endif //_WINDOWS + +pfc::string_base & operator<<(pfc::string_base & p_fmt, const wchar_t * p_str) { + p_fmt.add_string(pfc::stringcvt::string_utf8_from_wide(p_str) ); return p_fmt; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/string_conv.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/string_conv.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,586 @@ +#pragma once + +#include "array.h" + +namespace pfc { + + namespace stringcvt { + //! Converts UTF-8 characters to wide character. + //! @param p_out Output buffer, receives converted string, with null terminator. + //! @param p_out_size Size of output buffer, in characters. If converted string is too long, it will be truncated. Null terminator is always written, unless p_out_size is zero. + //! @param p_source String to convert. + //! @param p_source_size Number of characters to read from p_source. If reading stops if null terminator is encountered earlier. + //! @returns Number of characters written, not counting null terminator. + t_size convert_utf8_to_wide(wchar_t * p_out,t_size p_out_size,const char * p_source,t_size p_source_size); + + + //! Estimates buffer size required to convert specified UTF-8 string to widechar. + //! @param p_source String to be converted. + //! @param p_source_size Number of characters to read from p_source. If reading stops if null terminator is encountered earlier. + //! @returns Number of characters to allocate, including space for null terminator. + t_size estimate_utf8_to_wide(const char * p_source,t_size p_source_size); + + t_size estimate_utf8_to_wide(const char * p_source); + + //! Converts wide character string to UTF-8. + //! @param p_out Output buffer, receives converted string, with null terminator. + //! @param p_out_size Size of output buffer, in characters. If converted string is too long, it will be truncated. Null terminator is always written, unless p_out_size is zero. + //! @param p_source String to convert. + //! @param p_source_size Number of characters to read from p_source. If reading stops if null terminator is encountered earlier. + //! @returns Number of characters written, not counting null terminator. + t_size convert_wide_to_utf8(char * p_out,t_size p_out_size,const wchar_t * p_source,t_size p_source_size); + + //! Estimates buffer size required to convert specified wide character string to UTF-8. + //! @param p_source String to be converted. + //! @param p_source_size Number of characters to read from p_source. If reading stops if null terminator is encountered earlier. + //! @returns Number of characters to allocate, including space for null terminator. + t_size estimate_wide_to_utf8(const wchar_t * p_source,t_size p_source_size); + + t_size estimate_utf8_to_ascii( const char * p_source, t_size p_source_size ); + t_size convert_utf8_to_ascii( char * p_out, t_size p_out_size, const char * p_source, t_size p_source_size ); + + t_size estimate_wide_to_win1252( const wchar_t * p_source, t_size p_source_size ); + t_size convert_wide_to_win1252( char * p_out, t_size p_out_size, const wchar_t * p_source, t_size p_source_size ); + t_size estimate_win1252_to_wide( const char * p_source, t_size p_source_size ); + t_size convert_win1252_to_wide( wchar_t * p_out, t_size p_out_size, const char * p_source, t_size p_source_size ); + + t_size estimate_utf8_to_win1252( const char * p_source, t_size p_source_size ); + t_size convert_utf8_to_win1252( char * p_out, t_size p_out_size, const char * p_source, t_size p_source_size ); + t_size estimate_win1252_to_utf8( const char * p_source, t_size p_source_size ); + t_size convert_win1252_to_utf8( char * p_out, t_size p_out_size, const char * p_source, t_size p_source_size ); + + // 2016-05-16 additions + // Explicit UTF-16 converters + t_size estimate_utf16_to_utf8( const char16_t * p_source, size_t p_source_size ); + t_size convert_utf16_to_utf8( char * p_out, size_t p_out_size, const char16_t * p_source, size_t p_source_size ); + + + //! estimate_utf8_to_wide_quick() functions use simple math to determine buffer size required for the conversion. The result is not accurate length of output string - it's just a safe estimate of required buffer size, possibly bigger than what's really needed. \n + //! These functions are meant for scenarios when speed is more important than memory usage. + inline t_size estimate_utf8_to_wide_quick(t_size sourceLen) { + return sourceLen + 1; + } + inline t_size estimate_utf8_to_wide_quick(const char * source) { + return estimate_utf8_to_wide_quick(strlen(source)); + } + inline t_size estimate_utf8_to_wide_quick(const char * source, t_size sourceLen) { + return estimate_utf8_to_wide_quick(strlen_max(source, sourceLen)); + } + t_size convert_utf8_to_wide_unchecked(wchar_t * p_out,const char * p_source); + + template const t_char * null_string_t(); + template<> inline const char * null_string_t() {return "";} + template<> inline const wchar_t * null_string_t() {return L"";} + + template t_size strlen_t(const t_char * p_string,t_size p_string_size = SIZE_MAX) { + for(t_size n=0;n bool string_is_empty_t(const t_char * p_string,t_size p_string_size = SIZE_MAX) { + if (p_string_size == 0) return true; + return p_string[0] == 0; + } + + template class t_alloc = pfc::alloc_standard> class char_buffer_t { + public: + char_buffer_t() {} + char_buffer_t(const char_buffer_t & p_source) : m_buffer(p_source.m_buffer) {} + void set_size(t_size p_count) {m_buffer.set_size(p_count);} + t_char * get_ptr_var() {return m_buffer.get_ptr();} + const t_char * get_ptr() const { + return m_buffer.get_size() > 0 ? m_buffer.get_ptr() : null_string_t(); + } + private: + pfc::array_t m_buffer; + }; + + template class t_alloc = pfc::alloc_standard> + class string_utf8_from_wide_t { + public: + string_utf8_from_wide_t() {} + string_utf8_from_wide_t(const wchar_t * p_source,t_size p_source_size = SIZE_MAX) {convert(p_source,p_source_size);} + + void convert(const wchar_t * p_source,t_size p_source_size = SIZE_MAX) { + t_size size = estimate_wide_to_utf8(p_source,p_source_size); + m_buffer.set_size(size); + convert_wide_to_utf8( m_buffer.get_ptr_var(),size,p_source,p_source_size); + } + + operator const char * () const {return get_ptr();} + const char * get_ptr() const {return m_buffer.get_ptr();} + const char * toString() const {return get_ptr();} + bool is_empty() const {return string_is_empty_t(get_ptr());} + t_size length() const {return strlen_t(get_ptr());} + + private: + char_buffer_t m_buffer; + }; + typedef string_utf8_from_wide_t<> string_utf8_from_wide; + + template class t_alloc = pfc::alloc_standard> + class string_wide_from_utf8_t { + public: + string_wide_from_utf8_t() {} + string_wide_from_utf8_t(const char* p_source) {convert(p_source);} + string_wide_from_utf8_t(const char* p_source,t_size p_source_size) {convert(p_source,p_source_size);} + + void convert(const char* p_source,t_size p_source_size) { + const t_size size = estimate_size(p_source, p_source_size); + m_buffer.set_size(size); + convert_utf8_to_wide( m_buffer.get_ptr_var(),size,p_source,p_source_size ); + } + void convert(const char * p_source) { + m_buffer.set_size( estimate_size(p_source) ); + convert_utf8_to_wide_unchecked(m_buffer.get_ptr_var(), p_source); + } + + operator const wchar_t * () const {return get_ptr();} + const wchar_t * get_ptr() const {return m_buffer.get_ptr();} + bool is_empty() const {return string_is_empty_t(get_ptr());} + t_size length() const {return strlen_t(get_ptr());} + + void append(const char* p_source,t_size p_source_size) { + const t_size base = length(); + const t_size size = estimate_size(p_source, p_source_size); + m_buffer.set_size(base + size); + convert_utf8_to_wide( m_buffer.get_ptr_var() + base, size, p_source, p_source_size ); + } + void append(const char * p_source) { + const t_size base = length(); + m_buffer.set_size( base + estimate_size(p_source) ); + convert_utf8_to_wide_unchecked(m_buffer.get_ptr_var() + base, p_source); + } + + enum { alloc_prioritizes_speed = t_alloc::alloc_prioritizes_speed }; + private: + + inline t_size estimate_size(const char * source, t_size sourceLen) { + return alloc_prioritizes_speed ? estimate_utf8_to_wide_quick(source, sourceLen) : estimate_utf8_to_wide(source,sourceLen); + } + inline t_size estimate_size(const char * source) { + return alloc_prioritizes_speed ? estimate_utf8_to_wide_quick(source) : estimate_utf8_to_wide(source,SIZE_MAX); + } + char_buffer_t m_buffer; + }; + typedef string_wide_from_utf8_t<> string_wide_from_utf8; + typedef string_wide_from_utf8_t string_wide_from_utf8_fast; + + + template class t_alloc = pfc::alloc_standard> + class string_wide_from_win1252_t { + public: + string_wide_from_win1252_t() {} + string_wide_from_win1252_t(const char * p_source,t_size p_source_size = SIZE_MAX) {convert(p_source,p_source_size);} + + void convert(const char * p_source,t_size p_source_size = SIZE_MAX) { + t_size size = estimate_win1252_to_wide(p_source,p_source_size); + m_buffer.set_size(size); + convert_win1252_to_wide(m_buffer.get_ptr_var(),size,p_source,p_source_size); + } + + operator const wchar_t * () const {return get_ptr();} + const wchar_t * get_ptr() const {return m_buffer.get_ptr();} + bool is_empty() const {return string_is_empty_t(get_ptr());} + t_size length() const {return strlen_t(get_ptr());} + + private: + char_buffer_t m_buffer; + }; + typedef string_wide_from_win1252_t<> string_wide_from_win1252; + + + template class t_alloc = pfc::alloc_standard> + class string_win1252_from_wide_t { + public: + string_win1252_from_wide_t() {} + string_win1252_from_wide_t(const wchar_t * p_source,t_size p_source_size = SIZE_MAX) {convert(p_source,p_source_size);} + + void convert(const wchar_t * p_source,t_size p_source_size = SIZE_MAX) { + t_size size = estimate_wide_to_win1252(p_source,p_source_size); + m_buffer.set_size(size); + convert_wide_to_win1252(m_buffer.get_ptr_var(),size,p_source,p_source_size); + } + + operator const char * () const {return get_ptr();} + const char * get_ptr() const {return m_buffer.get_ptr();} + bool is_empty() const {return string_is_empty_t(get_ptr());} + t_size length() const {return strlen_t(get_ptr());} + + private: + char_buffer_t m_buffer; + }; + typedef string_win1252_from_wide_t<> string_win1252_from_wide; + + + template class t_alloc = pfc::alloc_standard> + class string_utf8_from_win1252_t { + public: + string_utf8_from_win1252_t() {} + string_utf8_from_win1252_t(const char * p_source,t_size p_source_size = SIZE_MAX) {convert(p_source,p_source_size);} + + void convert(const char * p_source,t_size p_source_size = SIZE_MAX) { + t_size size = estimate_win1252_to_utf8(p_source,p_source_size); + m_buffer.set_size(size); + convert_win1252_to_utf8(m_buffer.get_ptr_var(),size,p_source,p_source_size); + } + + operator const char * () const {return get_ptr();} + const char * get_ptr() const {return m_buffer.get_ptr();} + bool is_empty() const {return string_is_empty_t(get_ptr());} + t_size length() const {return strlen_t(get_ptr());} + + private: + char_buffer_t m_buffer; + }; + typedef string_utf8_from_win1252_t<> string_utf8_from_win1252; + + + template class t_alloc = pfc::alloc_standard> + class string_win1252_from_utf8_t { + public: + string_win1252_from_utf8_t() {} + string_win1252_from_utf8_t(const char * p_source,t_size p_source_size = SIZE_MAX) {convert(p_source,p_source_size);} + + void convert(const char * p_source,t_size p_source_size = SIZE_MAX) { + t_size size = estimate_utf8_to_win1252(p_source,p_source_size); + m_buffer.set_size(size); + convert_utf8_to_win1252(m_buffer.get_ptr_var(),size,p_source,p_source_size); + } + + operator const char * () const {return get_ptr();} + const char * get_ptr() const {return m_buffer.get_ptr();} + bool is_empty() const {return string_is_empty_t(get_ptr());} + t_size length() const {return strlen_t(get_ptr());} + + private: + char_buffer_t m_buffer; + }; + typedef string_win1252_from_utf8_t<> string_win1252_from_utf8; + + class string_ascii_from_utf8 { + public: + string_ascii_from_utf8() {} + string_ascii_from_utf8( const char * p_source, t_size p_source_size = SIZE_MAX) { convert(p_source, p_source_size); } + + void convert( const char * p_source, t_size p_source_size = SIZE_MAX) { + t_size size = estimate_utf8_to_ascii(p_source, p_source_size); + m_buffer.set_size(size); + convert_utf8_to_ascii(m_buffer.get_ptr_var(), size, p_source, p_source_size); + } + + operator const char * () const {return get_ptr();} + const char * get_ptr() const {return m_buffer.get_ptr();} + bool is_empty() const {return string_is_empty_t(get_ptr());} + t_size length() const {return strlen_t(get_ptr());} + + private: + char_buffer_t m_buffer; + }; + + class string_utf8_from_utf16 { + public: + string_utf8_from_utf16() {} + string_utf8_from_utf16( const char16_t * p_source, size_t p_source_size = SIZE_MAX) {convert(p_source, p_source_size);} + + void convert( const char16_t * p_source, size_t p_source_size = SIZE_MAX) { + size_t size = estimate_utf16_to_utf8(p_source, p_source_size); + m_buffer.set_size(size); + convert_utf16_to_utf8(m_buffer.get_ptr_var(), size, p_source, p_source_size ); + } + + operator const char * () const {return get_ptr();} + const char * get_ptr() const {return m_buffer.get_ptr();} + bool is_empty() const {return string_is_empty_t(get_ptr());} + t_size length() const {return strlen_t(get_ptr());} + + private: + char_buffer_t m_buffer; + }; + + } +#ifdef _WINDOWS + namespace stringcvt { + + enum { + codepage_system = CP_ACP, + codepage_ascii = 20127, + codepage_iso_8859_1 = 28591, + }; + + + + //! Converts string from specified codepage to wide character. + //! @param p_out Output buffer, receives converted string, with null terminator. + //! @param p_codepage Codepage ID of source string. + //! @param p_source String to convert. + //! @param p_source_size Number of characters to read from p_source. If reading stops if null terminator is encountered earlier. + //! @param p_out_size Size of output buffer, in characters. If converted string is too long, it will be truncated. Null terminator is always written, unless p_out_size is zero. + //! @returns Number of characters written, not counting null terminator. + t_size convert_codepage_to_wide(unsigned p_codepage,wchar_t * p_out,t_size p_out_size,const char * p_source,t_size p_source_size); + + //! Estimates buffer size required to convert specified string from specified codepage to wide character. + //! @param p_codepage Codepage ID of source string. + //! @param p_source String to be converted. + //! @param p_source_size Number of characters to read from p_source. If reading stops if null terminator is encountered earlier. + //! @returns Number of characters to allocate, including space for null terminator. + t_size estimate_codepage_to_wide(unsigned p_codepage,const char * p_source,t_size p_source_size); + + //! Converts string from wide character to specified codepage. + //! @param p_codepage Codepage ID of source string. + //! @param p_out Output buffer, receives converted string, with null terminator. + //! @param p_out_size Size of output buffer, in characters. If converted string is too long, it will be truncated. Null terminator is always written, unless p_out_size is zero. + //! @param p_source String to convert. + //! @param p_source_size Number of characters to read from p_source. If reading stops if null terminator is encountered earlier. + //! @returns Number of characters written, not counting null terminator. + t_size convert_wide_to_codepage(unsigned p_codepage,char * p_out,t_size p_out_size,const wchar_t * p_source,t_size p_source_size); + + //! Estimates buffer size required to convert specified wide character string to specified codepage. + //! @param p_codepage Codepage ID of source string. + //! @param p_source String to be converted. + //! @param p_source_size Number of characters to read from p_source. If reading stops if null terminator is encountered earlier. + //! @returns Number of characters to allocate, including space for null terminator. + t_size estimate_wide_to_codepage(unsigned p_codepage,const wchar_t * p_source,t_size p_source_size); + + + //! Converts string from system codepage to wide character. + //! @param p_out Output buffer, receives converted string, with null terminator. + //! @param p_source String to convert. + //! @param p_source_size Number of characters to read from p_source. If reading stops if null terminator is encountered earlier. + //! @param p_out_size Size of output buffer, in characters. If converted string is too long, it will be truncated. Null terminator is always written, unless p_out_size is zero. + //! @returns Number of characters written, not counting null terminator. + inline t_size convert_ansi_to_wide(wchar_t * p_out,t_size p_out_size,const char * p_source,t_size p_source_size) { + return convert_codepage_to_wide(codepage_system,p_out,p_out_size,p_source,p_source_size); + } + + //! Estimates buffer size required to convert specified system codepage string to wide character. + //! @param p_source String to be converted. + //! @param p_source_size Number of characters to read from p_source. If reading stops if null terminator is encountered earlier. + //! @returns Number of characters to allocate, including space for null terminator. + inline t_size estimate_ansi_to_wide(const char * p_source,t_size p_source_size) { + return estimate_codepage_to_wide(codepage_system,p_source,p_source_size); + } + + //! Converts string from wide character to system codepage. + //! @param p_out Output buffer, receives converted string, with null terminator. + //! @param p_out_size Size of output buffer, in characters. If converted string is too long, it will be truncated. Null terminator is always written, unless p_out_size is zero. + //! @param p_source String to convert. + //! @param p_source_size Number of characters to read from p_source. If reading stops if null terminator is encountered earlier. + //! @returns Number of characters written, not counting null terminator. + inline t_size convert_wide_to_ansi(char * p_out,t_size p_out_size,const wchar_t * p_source,t_size p_source_size) { + return convert_wide_to_codepage(codepage_system,p_out,p_out_size,p_source,p_source_size); + } + + //! Estimates buffer size required to convert specified wide character string to system codepage. + //! @param p_source String to be converted. + //! @param p_source_size Number of characters to read from p_source. If reading stops if null terminator is encountered earlier. + //! @returns Number of characters to allocate, including space for null terminator. + inline t_size estimate_wide_to_ansi(const wchar_t * p_source,t_size p_source_size) { + return estimate_wide_to_codepage(codepage_system,p_source,p_source_size); + } + + + template class t_alloc = pfc::alloc_standard> + class string_wide_from_codepage_t { + public: + string_wide_from_codepage_t() {} + string_wide_from_codepage_t(const string_wide_from_codepage_t & p_source) : m_buffer(p_source.m_buffer) {} + string_wide_from_codepage_t(unsigned p_codepage,const char * p_source,t_size p_source_size = SIZE_MAX) {convert(p_codepage,p_source,p_source_size);} + + void convert(unsigned p_codepage,const char * p_source,t_size p_source_size = SIZE_MAX) { + t_size size = estimate_codepage_to_wide(p_codepage,p_source,p_source_size); + m_buffer.set_size(size); + convert_codepage_to_wide(p_codepage, m_buffer.get_ptr_var(),size,p_source,p_source_size); + } + + operator const wchar_t * () const {return get_ptr();} + const wchar_t * get_ptr() const {return m_buffer.get_ptr();} + bool is_empty() const {return string_is_empty_t(get_ptr());} + t_size length() const {return strlen_t(get_ptr());} + + private: + char_buffer_t m_buffer; + }; + typedef string_wide_from_codepage_t<> string_wide_from_codepage; + + + template class t_alloc = pfc::alloc_standard> + class string_codepage_from_wide_t { + public: + string_codepage_from_wide_t() {} + string_codepage_from_wide_t(const string_codepage_from_wide_t & p_source) : m_buffer(p_source.m_buffer) {} + string_codepage_from_wide_t(unsigned p_codepage,const wchar_t * p_source,t_size p_source_size = SIZE_MAX) {convert(p_codepage,p_source,p_source_size);} + + void convert(unsigned p_codepage,const wchar_t * p_source,t_size p_source_size = SIZE_MAX) { + t_size size = estimate_wide_to_codepage(p_codepage,p_source,p_source_size); + m_buffer.set_size(size); + convert_wide_to_codepage(p_codepage, m_buffer.get_ptr_var(),size,p_source,p_source_size); + } + + operator const char * () const {return get_ptr();} + const char * get_ptr() const {return m_buffer.get_ptr();} + bool is_empty() const {return string_is_empty_t(get_ptr());} + t_size length() const {return strlen_t(get_ptr());} + + private: + char_buffer_t m_buffer; + }; + typedef string_codepage_from_wide_t<> string_codepage_from_wide; + + class string_codepage_from_utf8 { + public: + string_codepage_from_utf8() {} + string_codepage_from_utf8(const string_codepage_from_utf8 & p_source) : m_buffer(p_source.m_buffer) {} + string_codepage_from_utf8(unsigned p_codepage,const char * p_source,t_size p_source_size = SIZE_MAX) {convert(p_codepage,p_source,p_source_size);} + + void convert(unsigned p_codepage,const char * p_source,t_size p_source_size = SIZE_MAX) { + string_wide_from_utf8 temp; + temp.convert(p_source,p_source_size); + t_size size = estimate_wide_to_codepage(p_codepage,temp,SIZE_MAX); + m_buffer.set_size(size); + convert_wide_to_codepage(p_codepage,m_buffer.get_ptr_var(),size,temp,SIZE_MAX); + } + + operator const char * () const {return get_ptr();} + const char * get_ptr() const {return m_buffer.get_ptr();} + bool is_empty() const {return string_is_empty_t(get_ptr());} + t_size length() const {return strlen_t(get_ptr());} + + private: + char_buffer_t m_buffer; + }; + + class string_utf8_from_codepage { + public: + string_utf8_from_codepage() {} + string_utf8_from_codepage(const string_utf8_from_codepage & p_source) : m_buffer(p_source.m_buffer) {} + string_utf8_from_codepage(unsigned p_codepage,const char * p_source,t_size p_source_size = SIZE_MAX) {convert(p_codepage,p_source,p_source_size);} + + void convert(unsigned p_codepage,const char * p_source,t_size p_source_size = SIZE_MAX) { + string_wide_from_codepage temp; + temp.convert(p_codepage,p_source,p_source_size); + t_size size = estimate_wide_to_utf8(temp,SIZE_MAX); + m_buffer.set_size(size); + convert_wide_to_utf8( m_buffer.get_ptr_var(),size,temp,SIZE_MAX); + } + + operator const char * () const {return get_ptr();} + const char * get_ptr() const {return m_buffer.get_ptr();} + bool is_empty() const {return string_is_empty_t(get_ptr());} + t_size length() const {return strlen_t(get_ptr());} + + private: + char_buffer_t m_buffer; + }; + + + class string_utf8_from_ansi { + public: + string_utf8_from_ansi() {} + string_utf8_from_ansi(const string_utf8_from_ansi & p_source) : m_buffer(p_source.m_buffer) {} + string_utf8_from_ansi(const char * p_source,t_size p_source_size = SIZE_MAX) : m_buffer(codepage_system,p_source,p_source_size) {} + operator const char * () const {return get_ptr();} + const char * get_ptr() const {return m_buffer.get_ptr();} + const char * toString() const {return get_ptr();} + bool is_empty() const {return string_is_empty_t(get_ptr());} + t_size length() const {return strlen_t(get_ptr());} + void convert(const char * p_source,t_size p_source_size = SIZE_MAX) {m_buffer.convert(codepage_system,p_source,p_source_size);} + + private: + string_utf8_from_codepage m_buffer; + }; + + class string_ansi_from_utf8 { + public: + string_ansi_from_utf8() {} + string_ansi_from_utf8(const string_ansi_from_utf8 & p_source) : m_buffer(p_source.m_buffer) {} + string_ansi_from_utf8(const char * p_source,t_size p_source_size = SIZE_MAX) : m_buffer(codepage_system,p_source,p_source_size) {} + operator const char * () const {return get_ptr();} + const char * get_ptr() const {return m_buffer.get_ptr();} + bool is_empty() const {return string_is_empty_t(get_ptr());} + t_size length() const {return strlen_t(get_ptr());} + + void convert(const char * p_source,t_size p_source_size = SIZE_MAX) {m_buffer.convert(codepage_system,p_source,p_source_size);} + + private: + string_codepage_from_utf8 m_buffer; + }; + + class string_wide_from_ansi { + public: + string_wide_from_ansi() {} + string_wide_from_ansi(const string_wide_from_ansi & p_source) : m_buffer(p_source.m_buffer) {} + string_wide_from_ansi(const char * p_source,t_size p_source_size = SIZE_MAX) : m_buffer(codepage_system,p_source,p_source_size) {} + operator const wchar_t * () const {return get_ptr();} + const wchar_t * get_ptr() const {return m_buffer.get_ptr();} + bool is_empty() const {return string_is_empty_t(get_ptr());} + t_size length() const {return strlen_t(get_ptr());} + + void convert(const char * p_source,t_size p_source_size = SIZE_MAX) {m_buffer.convert(codepage_system,p_source,p_source_size);} + + private: + string_wide_from_codepage m_buffer; + }; + + class string_ansi_from_wide { + public: + string_ansi_from_wide() {} + string_ansi_from_wide(const string_ansi_from_wide & p_source) : m_buffer(p_source.m_buffer) {} + string_ansi_from_wide(const wchar_t * p_source,t_size p_source_size = SIZE_MAX) : m_buffer(codepage_system,p_source,p_source_size) {} + operator const char * () const {return get_ptr();} + const char * get_ptr() const {return m_buffer.get_ptr();} + bool is_empty() const {return string_is_empty_t(get_ptr());} + t_size length() const {return strlen_t(get_ptr());} + + void convert(const wchar_t * p_source,t_size p_source_size = SIZE_MAX) {m_buffer.convert(codepage_system,p_source,p_source_size);} + + private: + string_codepage_from_wide m_buffer; + }; + +#ifdef UNICODE + typedef string_wide_from_utf8 string_os_from_utf8; + typedef string_utf8_from_wide string_utf8_from_os; + typedef string_wide_from_utf8_fast string_os_from_utf8_fast; +#else + typedef string_ansi_from_utf8 string_os_from_utf8; + typedef string_utf8_from_ansi string_utf8_from_os; + typedef string_ansi_from_utf8 string_os_from_utf8_fast; +#endif + + class string_utf8_from_os_ex { + public: + template string_utf8_from_os_ex(const t_source * source, t_size sourceLen = SIZE_MAX) { + convert(source,sourceLen); + } + + void convert(const char * source, t_size sourceLen = SIZE_MAX) { + m_buffer = string_utf8_from_ansi(source,sourceLen); + } + void convert(const wchar_t * source, t_size sourceLen = SIZE_MAX) { + m_buffer = string_utf8_from_wide(source,sourceLen); + } + + operator const char * () const {return get_ptr();} + const char * get_ptr() const {return m_buffer.get_ptr();} + bool is_empty() const {return m_buffer.is_empty();} + t_size length() const {return m_buffer.length();} + const char * toString() const {return get_ptr();} + private: + string8 m_buffer; + }; + } + +#else + namespace stringcvt { + typedef string_win1252_from_wide string_ansi_from_wide; + typedef string_wide_from_win1252 string_wide_from_ansi; + typedef string_win1252_from_utf8 string_ansi_from_utf8; + typedef string_utf8_from_win1252 string_utf8_from_ansi; + } +#endif +}; + +pfc::string_base & operator<<(pfc::string_base & p_fmt, const wchar_t * p_str); diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/string_list.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/string_list.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,46 @@ +#pragma once + +#include "list.h" + +namespace pfc { + + typedef list_base_const_t string_list_const; + + class string_list_impl : public string_list_const + { + public: + t_size get_count() const {return m_data.get_size();} + void get_item_ex(const char* & p_out, t_size n) const {p_out = m_data[n];} + + const char * operator[] (t_size n) const {return m_data[n];} + void add_item(const char * p_string) {pfc::append_t(m_data, p_string);} + + template void add_items(const t_what & p_source) {_append(p_source);} + + void remove_all() {m_data.set_size(0);} + + string_list_impl() {} + template string_list_impl(const t_what & p_source) {_copy(p_source);} + template string_list_impl & operator=(const t_what & p_source) {_copy(p_source); return *this;} + template string_list_impl & operator|=(const string_list_impl & p_source) {_append(p_source); return *this;} + template string_list_impl & operator+=(const t_what & p_source) {pfc::append_t(m_data, p_source); return *this;} + + void set_item(size_t idx, const char* str) { m_data[idx] = str; } + + void remove_mask(bit_array const& mask) { pfc::remove_mask_t(m_data, mask); } + private: + template void _append(const t_what & p_source) { + const t_size toadd = p_source.get_size(), base = m_data.get_size(); + m_data.set_size(base+toadd); + for(t_size n=0;n void _copy(const t_what & p_source) { + const t_size newcount = p_source.get_size(); + m_data.set_size(newcount); + for(t_size n=0;n m_data; + }; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/string_simple.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/string_simple.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,59 @@ +#pragma once +#include "array.h" +namespace pfc { + // FOR LEGACY CODE ONLY + // DO NOT USE IN NEW CODE + template + class string_simple_t { + private: + typedef string_simple_t t_self; + public: + t_size length() const { + t_size s = m_buffer.get_size(); + if (s == 0) return 0; else return s - 1; + } + bool is_empty() const { return m_buffer.get_size() == 0; } + + void set_string_nc(const t_char* p_source, t_size p_length) { + if (p_length == 0) { + m_buffer.set_size(0); + } else { + m_buffer.set_size(p_length + 1); + pfc::memcpy_t(m_buffer.get_ptr(), p_source, p_length); + m_buffer[p_length] = 0; + } + } + void set_string(const t_char* p_source) { + set_string_nc(p_source, pfc::strlen_t(p_source)); + } + void set_string(const t_char* p_source, t_size p_length) { + set_string_nc(p_source, strlen_max_t(p_source, p_length)); + } + void add_string(const t_char* p_source, t_size p_length) { + add_string_nc(p_source, strlen_max_t(p_source, p_length)); + } + void add_string(const t_char* p_source) { + add_string_nc(p_source, strlen_t(p_source)); + } + void add_string_nc(const t_char* p_source, t_size p_length) { + if (p_length > 0) { + t_size base = length(); + m_buffer.set_size(base + p_length + 1); + memcpy_t(m_buffer.get_ptr() + base, p_source, p_length); + m_buffer[base + p_length] = 0; + } + } + string_simple_t() {} + string_simple_t(const t_char* p_source) { set_string(p_source); } + string_simple_t(const t_char* p_source, t_size p_length) { set_string(p_source, p_length); } + const t_self& operator=(const t_char* p_source) { set_string(p_source); return *this; } + operator const t_char* () const { return get_ptr(); } + const t_char* get_ptr() const { return m_buffer.get_size() > 0 ? m_buffer.get_ptr() : pfc::empty_string_t(); } + const t_char* c_str() const { return get_ptr(); } + private: + pfc::array_t m_buffer; + }; + + template class traits_t > : public traits_t > {}; + +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/suppress_fb2k_hooks.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/suppress_fb2k_hooks.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,20 @@ +#pragma once + +/* +foobar2000 shared.dll hook implementations +If you're getting linker multiple-definition errors on these, change build configuration of PFC from "Debug" / "Release" to "Debug FB2K" / "Release FB2K" +Configurations with "FB2K" suffix disable compilation of pfc-fb2k-hooks.cpp allowing these methods to be redirected to shared.dll calls +*/ + +namespace pfc { + [[noreturn]] void crashImpl(); + [[noreturn]] void crashHook() { + crashImpl(); + } +#ifdef _WIN32 + BOOL winFormatSystemErrorMessageImpl(pfc::string_base & p_out, DWORD p_code); + BOOL winFormatSystemErrorMessageHook(pfc::string_base & p_out, DWORD p_code) { + return winFormatSystemErrorMessageImpl(p_out, p_code); + } +#endif +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/syncd_storage.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/syncd_storage.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,109 @@ +#pragma once +#include "synchro.h" + +namespace pfc { +// Read/write lock guarded object store for safe concurrent access +template +class syncd_storage { +private: + typedef syncd_storage t_self; +public: + syncd_storage() {} + template + syncd_storage(const t_source & p_source) : m_object(p_source) {} + template + void set(t_source && p_in) { + inWriteSync(m_sync); + m_object = std::forward( p_in ); + } + template + void get(t_destination & p_out) const { + inReadSync(m_sync); + p_out = m_object; + } + t_object get() const { + inReadSync(m_sync); + return m_object; + } + template + const t_self & operator=(t_source && p_source) {set(std::forward(p_source)); return *this;} +private: + mutable ::pfc::readWriteLock m_sync; + t_object m_object; +}; + +// Read/write lock guarded object store for safe concurrent access +// With 'has changed since last read' flag +template +class syncd_storage_flagged { +private: + typedef syncd_storage_flagged t_self; +public: + syncd_storage_flagged() : m_changed_flag(false) {} + template + syncd_storage_flagged(const t_source & p_source, bool initChanged = false) : m_changed_flag(initChanged), m_object(p_source) {} + void set_changed(bool p_flag = true) { + inWriteSync(m_sync); + m_changed_flag = p_flag; + } + template + void set(t_source && p_in) { + inWriteSync(m_sync); + m_object = std::forward(p_in); + m_changed_flag = true; + } + bool has_changed() const { + // No point in locking here + // inReadSync(m_sync); + return m_changed_flag; + } + t_object peek() const {inReadSync(m_sync); return m_object;} + template + bool get_if_changed(t_destination & p_out) { + inReadSync(m_sync); + if (m_changed_flag) { + p_out = m_object; + m_changed_flag = false; + return true; + } else { + return false; + } + } + t_object get() { + inReadSync(m_sync); + m_changed_flag = false; + return m_object; + } + t_object get( bool & bHasChanged ) { + inReadSync(m_sync); + bHasChanged = m_changed_flag; + m_changed_flag = false; + return m_object; + } + template + void get(t_destination & p_out) { + inReadSync(m_sync); + p_out = m_object; + m_changed_flag = false; + } + template + const t_self & operator=(t_source && p_source) {set(std::forward(p_source)); return *this;} + + template + bool compare_and_set(arg_t&& arg) { + inWriteSync(m_sync); + bool ret = false; + if (arg != m_object) { + m_object = std::forward(arg); + m_changed_flag = true; + ret = true; + } + return ret; + } +private: + mutable volatile bool m_changed_flag; + mutable ::pfc::readWriteLock m_sync; + t_object m_object; +}; + +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/synchro.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/synchro.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,76 @@ +#pragma once + +#include // std::remove_reference + +#ifdef _WIN32 +#include "synchro_win.h" +#else +#include "synchro_nix.h" +#endif + +namespace pfc { + class dummyLock { + public: + void enterRead() noexcept {} + void enterWrite() noexcept {} + void leaveRead() noexcept {} + void leaveWrite() noexcept {} + void enter() noexcept {} + void leave() noexcept {} + void lock() noexcept {} + void unlock() noexcept {} + }; + + template + class mutexScope_ { + private: + typedef mutexScope_ self_t; + public: + mutexScope_( mutex_t * m ) noexcept : m_mutex(m) { m_mutex->enter(); } + mutexScope_( mutex_t & m ) noexcept : m_mutex(&m) { m_mutex->enter(); } + ~mutexScope_( ) noexcept {m_mutex->leave();} + private: + void operator=( const self_t & ) = delete; + mutexScope_(const self_t & ) = delete; + + mutex_t * m_mutex; + }; + typedef mutexScope_ mutexScope; + + template + class _readWriteLock_scope_read { + public: + _readWriteLock_scope_read( lock_t & lock ) noexcept : m_lock( lock ) { m_lock.enterRead(); } + ~_readWriteLock_scope_read() noexcept {m_lock.leaveRead();} + private: + _readWriteLock_scope_read( const _readWriteLock_scope_read &) = delete; + void operator=( const _readWriteLock_scope_read &) = delete; + lock_t & m_lock; + }; + template + class _readWriteLock_scope_write { + public: + _readWriteLock_scope_write( lock_t & lock ) noexcept : m_lock( lock ) { m_lock.enterWrite(); } + ~_readWriteLock_scope_write() noexcept {m_lock.leaveWrite();} + private: + _readWriteLock_scope_write( const _readWriteLock_scope_write &) = delete; + void operator=( const _readWriteLock_scope_write &) = delete; + lock_t & m_lock; + }; +} + + +#define PFC_INSYNC_READ( X ) ::pfc::_readWriteLock_scope_read::type > _asdf_l_readWriteLock_scope_read( X ) +#define PFC_INSYNC_WRITE( X ) ::pfc::_readWriteLock_scope_write::type > _asdf_l_readWriteLock_scope_write( X ) + +typedef pfc::mutexScope c_insync; + +#define PFC_INSYNC(X) pfc::mutexScope_< typename std::remove_reference::type > blah____sync(X) + + + +// Legacy macros +#define inReadSync( X ) PFC_INSYNC_READ(X) +#define inWriteSync( X ) PFC_INSYNC_WRITE(X) +#define insync( X ) PFC_INSYNC(X) + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/synchro_nix.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/synchro_nix.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,33 @@ +#include "pfc.h" + +#ifndef _WIN32 + +namespace pfc { + + void mutexBase::create( const pthread_mutexattr_t * attr ) { + if (pthread_mutex_init( &obj, attr) != 0) { + throw exception_bug_check(); + } + } + void mutexBase::destroy() { + pthread_mutex_destroy( &obj ); + } + void mutexBase::createRecur() { + mutexAttr a; a.setRecursive(); create(&a.attr); + } + void mutexBase::create( const mutexAttr & a ) { + create( & a.attr ); + } + + void readWriteLockBase::create( const pthread_rwlockattr_t * attr ) { + if (pthread_rwlock_init( &obj, attr) != 0) { + throw exception_bug_check(); + } + } + void readWriteLockBase::create( const readWriteLockAttr & a) { + create(&a.attr); + } + +} + +#endif // _WIN32 diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/synchro_nix.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/synchro_nix.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,119 @@ +#pragma once +#include + +namespace pfc { + class mutexAttr { + public: + mutexAttr() {pthread_mutexattr_init(&attr);} + ~mutexAttr() {pthread_mutexattr_destroy(&attr);} + void setType(int type) {pthread_mutexattr_settype(&attr, type);} + int getType() const {int rv = 0; pthread_mutexattr_gettype(&attr, &rv); return rv; } + void setRecursive() {setType(PTHREAD_MUTEX_RECURSIVE);} + bool isRecursive() {return getType() == PTHREAD_MUTEX_RECURSIVE;} + void setProcessShared() {pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED);} + operator const pthread_mutexattr_t & () const {return attr;} + operator pthread_mutexattr_t & () {return attr;} + pthread_mutexattr_t attr; + private: + mutexAttr(const mutexAttr&) = delete; void operator=(const mutexAttr&) = delete; + }; + + class mutexBase { + public: + void lock() noexcept {pthread_mutex_lock(&obj);} + void unlock() noexcept {pthread_mutex_unlock(&obj);} + + void enter() noexcept {lock();} + void leave() noexcept {unlock();} + bool tryEnter() noexcept {return pthread_mutex_trylock(&obj) == 0; } + + void create( const pthread_mutexattr_t * attr ); + void create( const mutexAttr & ); + void createRecur(); + void destroy(); + protected: + mutexBase() {} + ~mutexBase() {} + private: + pthread_mutex_t obj; + + void operator=( const mutexBase & ) = delete; + mutexBase( const mutexBase & ) = delete; + }; + + + + class mutex : public mutexBase { + public: + mutex() {create(NULL);} + ~mutex() {destroy();} + }; + + class mutexRecur : public mutexBase { + public: + mutexRecur() {createRecur();} + ~mutexRecur() {destroy();} + }; + + + class mutexRecurStatic : public mutexBase { + public: + mutexRecurStatic() {createRecur();} + }; + + + + typedef mutexBase mutexBase_t; + + + class readWriteLockAttr { + public: + readWriteLockAttr() {pthread_rwlockattr_init( & attr ); } + ~readWriteLockAttr() {pthread_rwlockattr_destroy( & attr ) ;} + + void setProcessShared( bool val = true ) { + pthread_rwlockattr_setpshared( &attr, val ? PTHREAD_PROCESS_SHARED : PTHREAD_PROCESS_PRIVATE ); + } + + pthread_rwlockattr_t attr; + + private: + readWriteLockAttr(const readWriteLockAttr&) = delete; + void operator=(const readWriteLockAttr & ) = delete; + }; + + class readWriteLockBase { + public: + void create( const pthread_rwlockattr_t * attr ); + void create( const readWriteLockAttr & ); + void destroy() {pthread_rwlock_destroy( & obj ); } + + void enterRead() noexcept {pthread_rwlock_rdlock( &obj ); } + void enterWrite() noexcept {pthread_rwlock_wrlock( &obj ); } + void leaveRead() noexcept {pthread_rwlock_unlock( &obj ); } + void leaveWrite() noexcept {pthread_rwlock_unlock( &obj ); } + protected: + readWriteLockBase() {} + ~readWriteLockBase() {} + private: + pthread_rwlock_t obj; + + void operator=( const readWriteLockBase & ) = delete; + readWriteLockBase( const readWriteLockBase & ) = delete; + }; + + + class readWriteLock : public readWriteLockBase { + public: + readWriteLock() {create(NULL);} + ~readWriteLock() {destroy();} + }; + + + +} + + + +typedef pfc::mutexRecur critical_section; +typedef pfc::mutexRecurStatic critical_section_static; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/synchro_win.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/synchro_win.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,71 @@ +#pragma once + +class _critical_section_base { +protected: + CRITICAL_SECTION sec; +public: + _critical_section_base() = default; + inline void enter() noexcept {EnterCriticalSection(&sec);} + inline void leave() noexcept {LeaveCriticalSection(&sec);} + inline void create() noexcept { +#ifdef PFC_WINDOWS_DESKTOP_APP + InitializeCriticalSection(&sec); +#else + InitializeCriticalSectionEx(&sec,0,0); +#endif + } + inline void destroy() noexcept {DeleteCriticalSection(&sec);} + inline bool tryEnter() noexcept { return !!TryEnterCriticalSection(&sec); } +private: + _critical_section_base(const _critical_section_base&) = delete; + void operator=(const _critical_section_base&) = delete; +}; + +// Static-lifetime critical section, no cleanup - valid until process termination +class critical_section_static : public _critical_section_base { +public: + critical_section_static() noexcept {create();} +#if !PFC_LEAK_STATIC_OBJECTS + ~critical_section_static() noexcept {destroy();} +#endif +}; + +// Regular critical section, intended for any lifetime scopes +class critical_section : public _critical_section_base { +public: + critical_section() noexcept {create();} + ~critical_section() noexcept {destroy();} +}; + +namespace pfc { + +// Read write lock - Vista-and-newer friendly lock that allows concurrent reads from a resource that permits such +// Warning, non-recursion proof +class readWriteLock { +public: + readWriteLock() = default; + + void enterRead() noexcept { + AcquireSRWLockShared( & theLock ); + } + void enterWrite() noexcept { + AcquireSRWLockExclusive( & theLock ); + } + void leaveRead() noexcept { + ReleaseSRWLockShared( & theLock ); + } + void leaveWrite() noexcept { + ReleaseSRWLockExclusive( &theLock ); + } + +private: + readWriteLock(const readWriteLock&) = delete; + void operator=(const readWriteLock&) = delete; + + SRWLOCK theLock = SRWLOCK_INIT; +}; + +typedef ::_critical_section_base mutexBase_t; +typedef ::critical_section mutex; + +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/targetver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/targetver.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,6 @@ +#pragma once + +#ifndef _WIN32_WINNT +#define _WIN32_WINNT 0x0601 +#include +#endif \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/threadSafeObj.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/threadSafeObj.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,39 @@ +#pragma once +namespace pfc { + + template + struct threadSafeObjCommon { + typedef mutex_t_ mutex_t; + typedef obj_t_ obj_t; + template threadSafeObjCommon( arg_t && ... arg ) : m_obj(std::forward(arg) ... ) {} + mutex_t m_mutex; + obj_t m_obj; + }; + + template + class threadSafeObjLock { + typedef threadSafeObjLock self_t; + common_t & m_common; + public: + typename common_t::obj_t & operator*() { return m_common.m_obj; } + typename common_t::obj_t * operator->() { return & m_common.m_obj; } + + threadSafeObjLock( common_t & arg ) : m_common(arg) { m_common.m_mutex.lock(); } + ~threadSafeObjLock( ) { m_common.m_mutex.unlock(); } + threadSafeObjLock( const self_t & ) = delete; + void operator=( const self_t & ) = delete; + }; + + template + class threadSafeObj { + typedef threadSafeObjCommon common_t; + typedef threadSafeObjLock lock_t; + common_t m_common; + public: + template + threadSafeObj( arg_t && ... arg ) : m_common( std::forward(arg) ... ) {} + + lock_t get() { return lock_t(m_common); } + }; + +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/threads.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/threads.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,358 @@ +#include "pfc-lite.h" + +#ifdef _WIN32 +#include "pp-winapi.h" +#endif + +#ifdef __APPLE__ +#include +#include +#endif + +#include "threads.h" +#include "debug.h" +#include + +#include + +#ifndef _WIN32 +namespace { + class c_pthread_attr { + public: + c_pthread_attr() { + pthread_attr_init(&a); + } + ~c_pthread_attr() { + pthread_attr_destroy(&a); + } + void apply( const pfc::thread::arg_t & arg ) { +#ifdef __APPLE__ + if ( arg.appleThreadQOS != 0 ) { + pthread_attr_set_qos_class_np( &a, (qos_class_t) arg.appleThreadQOS, arg.appleRealtivePriority ); + } +#endif + if ( arg.nixSchedPolicy >= 0 ) { + pthread_attr_setschedpolicy(&a, arg.nixSchedPolicy); + pthread_attr_setschedparam(&a, &arg.nixSchedParam); + } + } + pthread_attr_t a; + + c_pthread_attr( const c_pthread_attr & ) = delete; + void operator=( const c_pthread_attr & ) = delete; + }; +} +#endif + +namespace pfc { + unsigned getOptimalWorkerThreadCount() { + return std::thread::hardware_concurrency(); + } + + unsigned getOptimalWorkerThreadCountEx(size_t taskCountLimit) { + if (taskCountLimit <= 1) return 1; + return (unsigned)pfc::min_t(taskCountLimit,getOptimalWorkerThreadCount()); + } + + + void thread::entry() { + try { + threadProc(); + } catch(...) {} + } + + void thread::couldNotCreateThread() { + PFC_ASSERT(!"Could not create thread"); + // Something terminally wrong, better crash leaving a good debug trace + crash(); + } + +#ifdef _WIN32 + thread::thread() : m_thread(INVALID_HANDLE_VALUE) + { + } + + void thread::close() { + if (isActive()) { + + int ctxPriority = GetThreadPriority( GetCurrentThread() ); + if (ctxPriority > GetThreadPriority( m_thread ) ) SetThreadPriority( m_thread, ctxPriority ); + + if (WaitForSingleObject(m_thread,INFINITE) != WAIT_OBJECT_0) couldNotCreateThread(); + CloseHandle(m_thread); m_thread = INVALID_HANDLE_VALUE; + } + } + bool thread::isActive() const { + return m_thread != INVALID_HANDLE_VALUE; + } + + static HANDLE MyBeginThread( unsigned (__stdcall * proc)(void *) , void * arg, DWORD * outThreadID, int priority) { + HANDLE thread; +#ifdef PFC_WINDOWS_DESKTOP_APP + thread = (HANDLE)_beginthreadex(NULL, 0, proc, arg, CREATE_SUSPENDED, (unsigned int*)outThreadID); +#else + thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)proc, arg, CREATE_SUSPENDED, outThreadID); +#endif + if (thread == NULL) thread::couldNotCreateThread(); + SetThreadPriority(thread, priority); + ResumeThread(thread); + return thread; + } + void thread::winStart(int priority, DWORD * outThreadID) { + close(); + m_thread = MyBeginThread(g_entry, reinterpret_cast(this), outThreadID, priority); + } + void thread::start(arg_t const & arg) { + winStart(arg.winThreadPriority, nullptr); + } + + unsigned CALLBACK thread::g_entry(void* p_instance) { + reinterpret_cast(p_instance)->entry(); return 0; + } + +#else + thread::thread() : m_thread(), m_threadValid() { + } + +#ifndef __APPLE__ // Apple specific entrypoint in obj-c.mm + void * thread::g_entry( void * arg ) { + reinterpret_cast( arg )->entry(); + return NULL; + } +#endif + + void thread::start(arg_t const & arg) { + close(); +#ifdef __APPLE__ + appleStartThreadPrologue(); +#endif + pthread_t thread; + + c_pthread_attr attr; + + pthread_attr_setdetachstate(&attr.a, PTHREAD_CREATE_JOINABLE); + + attr.apply( arg ); + + if (pthread_create(&thread, &attr.a, g_entry, reinterpret_cast(this)) != 0) couldNotCreateThread(); + + m_threadValid = true; + m_thread = thread; + } + + void thread::close() { + if (m_threadValid) { + void * rv = NULL; + pthread_join( m_thread, & rv ); m_thread = 0; + m_threadValid = false; + } + } + + bool thread::isActive() const { + return m_threadValid; + } +#endif +#ifdef _WIN32 + unsigned CALLBACK winSplitThreadProc(void* arg) { + auto f = reinterpret_cast *>(arg); + (*f)(); + delete f; + return 0; + } +#else + void * nixSplitThreadProc(void * arg) { + auto f = reinterpret_cast *>(arg); +#ifdef __APPLE__ + inAutoReleasePool([f] { + (*f)(); + delete f; + }); +#else + (*f)(); + delete f; +#endif + return NULL; + } +#endif + + void splitThread( std::function f ) { + splitThread( thread::argCurrentThread(), f ); + } + + void splitThread(thread::arg_t const & arg, std::function f) { + auto arg2 = std::make_unique >(f); +#ifdef _WIN32 + HANDLE h = MyBeginThread(winSplitThreadProc, arg2.get(), NULL, arg.winThreadPriority ); + CloseHandle(h); +#else +#ifdef __APPLE__ + thread::appleStartThreadPrologue(); +#endif + pthread_t thread; + + c_pthread_attr attr; + + attr.apply( arg ); + + if (pthread_create(&thread, &attr.a, nixSplitThreadProc, arg2.get()) != 0) thread::couldNotCreateThread(); + + pthread_detach(thread); +#endif + arg2.release(); + } +#ifndef __APPLE__ + // Stub for non Apple + void inAutoReleasePool(std::function f) { f(); } +#endif + + + void thread2::startHere(std::function e) { + setEntry(e); start(); + } + void thread2::startHere(arg_t const& arg, std::function e) { + setEntry(e); start(arg); + } + + void thread2::setEntry(std::function e) { + PFC_ASSERT(!isActive()); + m_entryPoint = e; + } + + void thread2::threadProc() { + m_entryPoint(); + } + + thread::handle_t thread::handleToCurrent() { +#ifdef _WIN32 + return GetCurrentThread(); +#else + return pthread_self(); +#endif + } + + thread::arg_t thread::argDefault() { + return arg_t(); + } + + thread::arg_t thread::argCurrentThread() { + arg_t arg; +#ifdef _WIN32 + arg.winThreadPriority = GetThreadPriority( GetCurrentThread() ); +#endif +#ifdef __APPLE__ + qos_class_t qos_class = QOS_CLASS_UNSPECIFIED; + int relative_priority = 0; + if (pthread_get_qos_class_np(pthread_self(), &qos_class, &relative_priority) == 0) { + arg.appleThreadQOS = (int) qos_class; + arg.appleRealtivePriority = relative_priority; + } +#endif +#ifndef _WIN32 + { + int policy; sched_param param; + if (pthread_getschedparam( pthread_self(), &policy, ¶m) == 0) { + arg.nixSchedPolicy = policy; + arg.nixSchedParam = param; + } + } +#endif + return arg; + } + + thread::arg_t thread::argBackground() { +#ifdef _WIN32 + return argWinPriority(THREAD_PRIORITY_LOWEST); +#elif defined(__APPLE__) + return argAppleQOS((int)QOS_CLASS_BACKGROUND); +#else + return argNixPriority(SCHED_OTHER, 0); +#endif + } + + thread::arg_t thread::argHighPriority() { +#ifdef _WIN32 + return argWinPriority(THREAD_PRIORITY_HIGHEST); +#elif defined(__ANDROID__) + // No SCHED_FIFO or SCHED_RR on Android + return argNixPriority(SCHED_OTHER, 100); +#else + return argNixPriority(SCHED_RR, 75); +#endif + } + + thread::arg_t thread::argPlayback() { + // It would be nice to use realtime priority yet lock ourselves to the slow cores, but that just doesn't work + // Using priority overrides the request for the slow cores (QOS_CLASS_BACKGROUND) + // ret.appleThreadQOS = (int) QOS_CLASS_BACKGROUND; + +#ifdef _WIN32 + return argWinPriority(THREAD_PRIORITY_TIME_CRITICAL); +#elif defined(__ANDROID__) + // No SCHED_FIFO or SCHED_RR on Android + return argNixPriority(SCHED_OTHER, 100); +#else + return argNixPriority(SCHED_FIFO, 100); +#endif + + } + + thread::arg_t thread::argUserInitiated() { +#ifdef _WIN32 + return argWinPriority(THREAD_PRIORITY_BELOW_NORMAL); +#elif defined(__APPLE__) + return argAppleQOS((int) QOS_CLASS_USER_INITIATED); +#else + return argNixPriority(SCHED_OTHER, 25); +#endif + } + +#ifdef _WIN32 + thread::arg_t thread::argWinPriority(int priority) { + arg_t arg; + arg.winThreadPriority = priority; + return arg; + } +#endif +#ifdef __APPLE__ + thread::arg_t thread::argAppleQOS(int qos) { + arg_t arg; + arg.appleThreadQOS = qos; + return arg; + } +#endif +#ifndef _WIN32 + thread::arg_t thread::argNixPriority(int policy, int percent) { + int pval; + if ( percent <= 0 ) pval = sched_get_priority_min(policy); + else if ( percent >= 100 ) pval = sched_get_priority_max(policy); + else { + const int pmin = sched_get_priority_min(policy), pmax = sched_get_priority_max(policy); + if (pmax > pmin) { + pval = pmin + ((pmax - pmin) * percent / 100); + } else { + pval = pmin; + } + } + arg_t ret; + ret.nixSchedPolicy = policy; + ret.nixSchedParam = sched_param { pval }; + return ret; + } +#endif + void thread::setCurrentPriority(arg_t const& arg) { +#ifdef _WIN32 + ::SetThreadPriority(GetCurrentThread(), arg.winThreadPriority); +#else +#ifdef __APPLE__ + if (arg.appleThreadQOS != 0) { + pthread_set_qos_class_self_np((qos_class_t)arg.appleThreadQOS, arg.appleRealtivePriority); + } + +#endif + if (arg.nixSchedPolicy >= 0) { + pthread_setschedparam(pthread_self(), arg.nixSchedPolicy, &arg.nixSchedParam); + } +#endif + } + +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/threads.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/threads.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,117 @@ +#pragma once + +#include + +#ifdef _WIN32 +#include +#else +#include +#endif +namespace pfc { + unsigned getOptimalWorkerThreadCount(); + unsigned getOptimalWorkerThreadCountEx(size_t taskCountLimit); + + //! IMPORTANT: all classes derived from thread must call waitTillDone() in their destructor, to avoid object destruction during a virtual function call! + class thread { + public: +#ifdef _WIN32 + typedef HANDLE handle_t; +#else + typedef pthread_t handle_t; +#endif + // Returns a psuedo-handle meant only for local use, see win32 GetCurrentThread() semantics + static handle_t handleToCurrent(); + + struct arg_t { +#ifdef _WIN32 + int winThreadPriority = 0; // THREAD_PRIORITY_NORMAL +#endif +#ifdef __APPLE__ + // see: pthread_set_qos_class_self_np + int appleThreadQOS = 0; // QOS_CLASS_UNSPECIFIED + int appleRealtivePriority = 0; // valid only if appleThreadQOS is set +#endif +#ifndef _WIN32 + int nixSchedPolicy = -1; // not set - cannot use 0 because SCHED_OTHER is 0 on Linux + sched_param nixSchedParam = {}; // valid only if nixSchedPolicy is set +#endif + }; + + static arg_t argDefault(); + static arg_t argCurrentThread(); + static arg_t argBackground(); + static arg_t argHighPriority(); + static arg_t argPlayback(); + static arg_t argUserInitiated(); +#ifdef _WIN32 + static arg_t argWinPriority(int priority); +#endif +#ifdef __APPLE__ + static arg_t argAppleQOS(int qos); +#endif +#ifndef _WIN32 + static arg_t argNixPriority( int policy, int percent ); +#endif + + //! Critical error handler function, never returns + PFC_NORETURN static void couldNotCreateThread(); + + thread(); + ~thread() {PFC_ASSERT(!isActive()); waitTillDone();} + void start( arg_t const & arg = argCurrentThread() ); + //! Valid thread object (created and not joined)? + bool isActive() const; + //! Joins the thread: blocks until complete, releases resources. \n + //! After waitTillDone() returns, isActive() becomes false. \n + //! No-op if thread not started. + void waitTillDone() {close();} +#ifdef _WIN32 + void winStart(int priority, DWORD * outThreadID); + HANDLE winThreadHandle() { return m_thread; } +#else + pthread_t posixThreadHandle() { return m_thread; } +#endif +#ifdef __APPLE__ + static void appleStartThreadPrologue(); +#endif + + static void setCurrentPriority(arg_t const&); + protected: + virtual void threadProc() {PFC_ASSERT(!"Stub thread entry - should not get here");} + private: + void close(); +#ifdef _WIN32 + static unsigned CALLBACK g_entry(void* p_instance); +#else + static void * g_entry( void * arg ); +#endif + void entry(); + + handle_t m_thread; +#ifndef _WIN32 + bool m_threadValid; // there is no invalid pthread_t, so we keep a separate 'valid' flag +#endif + + PFC_CLASS_NOT_COPYABLE_EX(thread) + }; + + //! Thread class using lambda entrypoint rather than function override + class thread2 : public thread { + public: + ~thread2() { waitTillDone(); } + void startHere(std::function e); + void startHere(arg_t const& arg, std::function e); + void setEntry(std::function e); + private: + void threadProc(); + + std::function m_entryPoint; + }; + + void splitThread(std::function f); + void splitThread(pfc::thread::arg_t const & arg, std::function f); + + //! Apple specific; executes the function in a release pool scope. \n + //! On non Apple platforms it just invokes the function. + void inAutoReleasePool(std::function f); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/timers.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/timers.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,123 @@ +#include "pfc-lite.h" + +#include "timers.h" +#include "debug.h" + +#if defined(_WIN32) && defined(PFC_HAVE_PROFILER) +#include +#endif + +#ifndef _WIN32 +#include "nix-objects.h" +#include +#endif + +namespace pfc { + +#ifdef PFC_HAVE_PROFILER + +profiler_static::profiler_static(const char * p_name) +{ + name = p_name; + total_time = 0; + num_called = 0; +} + +static void profilerMsg(const char* msg) { +#ifdef _WIN32 + if (!IsDebuggerPresent()) { + static HANDLE hWriteTo = INVALID_HANDLE_VALUE; + static bool initialized = false; + if (!initialized) { + initialized = true; + wchar_t path[1024] = {}; + if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_DESKTOP, NULL, SHGFP_TYPE_CURRENT, path))) { + size_t l = wcslen(path); + if (l > 0) { + if (path[l - 1] != '\\') { + wcscat_s(path, L"\\"); + } + wchar_t fn[256]; + wsprintf(fn, L"profiler-%u.txt", GetProcessId(GetCurrentProcess())); + wcscat_s(path, fn); + hWriteTo = CreateFile(path, GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, 0, NULL); + } + } + } + if (hWriteTo != INVALID_HANDLE_VALUE) { + SetFilePointer(hWriteTo, 0, 0, SEEK_END); + pfc::string8 temp = msg; + temp += "\r\n"; + DWORD written = 0; + WriteFile(hWriteTo, temp.c_str(), (DWORD) temp.length(), &written, NULL); + } + } +#endif + outputDebugLine(msg); +} + +profiler_static::~profiler_static() +{ + try { + pfc::string8 message; + message << "profiler: " << pfc::format_pad_left(48,' ',name) << " - " << + pfc::format_pad_right(16,' ',pfc::format_uint(total_time) ) << " cycles"; + + if (num_called > 0) { + message << " (executed " << num_called << " times, " << (total_time / num_called) << " average)"; + } + profilerMsg(message); + } catch(...) { + //should never happen + OutputDebugString(_T("unexpected profiler failure\n")); + } +} +#endif + +#ifndef _WIN32 + + void hires_timer::start() { + m_start = nixGetTime(); + } + double hires_timer::query() const { + return nixGetTime() - m_start; + } + double hires_timer::query_reset() { + double t = nixGetTime(); + double r = t - m_start; + m_start = t; + return r; + } + pfc::string8 hires_timer::queryString(unsigned precision) const { + return format_time_ex( query(), precision ).get_ptr(); + } +#endif + + + uint64_t fileTimeWtoU(uint64_t ft) { + return (ft - 116444736000000000 + /*rounding*/10000000/2) / 10000000; + } + uint64_t fileTimeUtoW(uint64_t ft) { + return (ft * 10000000) + 116444736000000000; + } +#ifndef _WIN32 + uint64_t fileTimeUtoW(const timespec & ts) { + uint64_t ft = (uint64_t)ts.tv_sec * 10000000 + (uint64_t)ts.tv_nsec / 100; + return ft + 116444736000000000; + } +#endif + + uint64_t fileTimeNow() { +#ifdef _WIN32 + uint64_t ret; + GetSystemTimeAsFileTime((FILETIME*)&ret); + return ret; +#else // not _WIN32 + timespec ts = {}; + auto status = clock_gettime( CLOCK_REALTIME, &ts); + PFC_ASSERT( status == 0 ); (void) status; + return fileTimeUtoW(ts); +#endif // _WIN32 or not + } + +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/timers.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/timers.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,190 @@ +#pragma once + +#include "string_base.h" + +#if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64)) + +#define PFC_HAVE_PROFILER + +#include +namespace pfc { + class profiler_static { + public: + profiler_static(const char * p_name); + ~profiler_static(); + void add_time(t_int64 delta) { total_time += delta;num_called++; } + private: + const char * name; + t_uint64 total_time, num_called; + }; + + class profiler_local { + public: + profiler_local(profiler_static * p_owner) { + owner = p_owner; + start = __rdtsc(); + } + ~profiler_local() { + t_int64 end = __rdtsc(); + owner->add_time(end - start); + } + private: + t_int64 start; + profiler_static * owner; + }; + +} +#define profiler(name) \ + static pfc::profiler_static profiler_static_##name(#name); \ + pfc::profiler_local profiler_local_##name(&profiler_static_##name); + + +#endif + +#ifdef _WIN32 + +namespace pfc { + typedef uint64_t tickcount_t; + inline tickcount_t getTickCount() { return GetTickCount64(); } + +class hires_timer { +public: + hires_timer() : m_start() {} + static hires_timer create_and_start() { + hires_timer t; t.start(); return t; + } + void start() { + m_start = g_query(); + } + double query() const { + return _query( g_query() ); + } + double query_reset() { + t_uint64 current = g_query(); + double ret = _query(current); + m_start = current; + return ret; + } + pfc::string8 queryString(unsigned precision = 6) const { + return pfc::format_time_ex( query(), precision ).get_ptr(); + } +private: + double _query(t_uint64 p_val) const { + return (double)( p_val - m_start ) * m_mul; + } + static t_uint64 g_query() { + LARGE_INTEGER val; + if (!QueryPerformanceCounter(&val)) throw pfc::exception_not_implemented(); + return val.QuadPart; + } + static double init_mul() { + return 1.0 / (double)g_query_freq(); + } + static t_uint64 g_query_freq() { + LARGE_INTEGER val; + if (!QueryPerformanceFrequency(&val)) throw pfc::exception_not_implemented(); + PFC_ASSERT(val.QuadPart > 0); + return val.QuadPart; + } + t_uint64 m_start; + double m_mul = init_mul(); +}; + +class lores_timer { +public: + lores_timer() {} + static lores_timer create_and_start() { + lores_timer t; t.start(); return t; + } + void start() { + _start(getTickCount()); + } + + double query() const { + return _query(getTickCount()); + } + double query_reset() { + tickcount_t time = getTickCount(); + double ret = _query(time); + _start(time); + return ret; + } + pfc::string8 queryString(unsigned precision = 3) const { + return pfc::format_time_ex( query(), precision ).get_ptr(); + } +private: + void _start(tickcount_t p_time) { + m_start = p_time; + } + double _query(tickcount_t p_time) const { + return (double)(p_time - m_start) / 1000.0; + } + t_uint64 m_start = 0; +}; + +class media_timer { + typedef DWORD val_t; + static val_t _now() { return timeGetTime(); } +public: + void start() { + _start(_now()); + } + double query() const { + return _query(_now()); + } + double query_reset() { + auto now = _now(); + double ret = _query(now); + _start(now); + return ret; + } + pfc::string8 queryString(unsigned precision = 3) const { + return pfc::format_time_ex(query(), precision).get_ptr(); + } + static media_timer create_and_start() { + media_timer t; t.start(); return t; + } +private: + void _start(val_t t) { m_start = t; } + double _query(val_t t) const { return (t - m_start) / 1000.0; } + val_t m_start = 0; +}; +} +#else // not _WIN32 + +namespace pfc { + +class hires_timer { +public: + hires_timer() : m_start() {} + void start(); + double query() const; + double query_reset(); + pfc::string8 queryString(unsigned precision = 3) const; + + static hires_timer create_and_start() { + hires_timer t; t.start(); return t; + } +private: + double m_start; +}; + +typedef hires_timer lores_timer; +typedef hires_timer media_timer; + +} + +#endif // _WIN32 + +#ifndef _WIN32 +struct timespec; +#endif + +namespace pfc { + uint64_t fileTimeWtoU(uint64_t ft); + uint64_t fileTimeUtoW(uint64_t ft); +#ifndef _WIN32 + uint64_t fileTimeUtoW( timespec const & ts ); +#endif + uint64_t fileTimeNow(); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/traits.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/traits.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,85 @@ +#pragma once + +namespace pfc { + + class traits_default { + public: + enum { + realloc_safe = false, + needs_destructor = true, + needs_constructor = true, + constructor_may_fail = true + }; + }; + + class traits_default_movable { + public: + enum { + realloc_safe = true, + needs_destructor = true, + needs_constructor = true, + constructor_may_fail = true + }; + }; + + class traits_rawobject : public traits_default { + public: + enum { + realloc_safe = true, + needs_destructor = false, + needs_constructor = false, + constructor_may_fail = false + }; + }; + + class traits_vtable { + public: + enum { + realloc_safe = true, + needs_destructor = true, + needs_constructor = true, + constructor_may_fail = false + }; + }; + + template class traits_t : public traits_default {}; + + template + class combine_traits { + public: + enum { + realloc_safe = (traits1::realloc_safe && traits2::realloc_safe), + needs_destructor = (traits1::needs_destructor || traits2::needs_destructor), + needs_constructor = (traits1::needs_constructor || traits2::needs_constructor), + constructor_may_fail = (traits1::constructor_may_fail || traits2::constructor_may_fail), + }; + }; + + template + class traits_combined : public combine_traits,traits_t > {}; + + template class traits_t : public traits_rawobject {}; + + template<> class traits_t : public traits_rawobject {}; + template<> class traits_t : public traits_rawobject {}; + template<> class traits_t : public traits_rawobject {}; + template<> class traits_t : public traits_rawobject {}; + template<> class traits_t : public traits_rawobject {}; + template<> class traits_t : public traits_rawobject {}; + template<> class traits_t : public traits_rawobject {}; + template<> class traits_t : public traits_rawobject {}; + template<> class traits_t : public traits_rawobject {}; + template<> class traits_t : public traits_rawobject {}; + template<> class traits_t : public traits_rawobject {}; + template<> class traits_t : public traits_rawobject {}; + template<> class traits_t : public traits_rawobject {}; + + template<> class traits_t : public traits_rawobject {}; + template<> class traits_t : public traits_rawobject {}; + + template<> class traits_t : public traits_rawobject {}; + + template + class traits_t : public traits_t {}; + +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/unicode-normalize.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/unicode-normalize.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,429 @@ +#include "pfc-lite.h" +#include "unicode-normalize.h" +#include "string_base.h" +#include + + + +static constexpr uint16_t modifiers[] = +{0x0300, 0x0301, 0x0302, 0x0303, 0x0304, 0x0306, 0x0307, 0x0308, 0x0309, 0x030A, 0x030B, 0x030C, 0x030F, 0x0311, 0x0313, 0x0314, 0x031B, 0x0323, 0x0324, 0x0325, 0x0326, 0x0327, 0x0328, 0x032D, 0x032E, 0x0330, 0x0331, 0x0338, 0x0342, 0x0345, 0x05B4, 0x05B7, 0x05B8, 0x05B9, 0x05BC, 0x05BF, 0x05C1, 0x05C2, 0x0653, 0x0654, 0x0655, 0x093C, 0x09BC, 0x09BE, 0x09D7, 0x0A3C, 0x0B3C, 0x0B3E, 0x0B56, 0x0B57, 0x0BBE, 0x0BD7, 0x0C56, 0x0CC2, 0x0CD5, 0x0CD6, 0x0D3E, 0x0D57, 0x0DCA, 0x0DCF, 0x0DDF, 0x0F72, 0x0F74, 0x0F80, 0x0FB5, 0x0FB7, 0x102E, 0x1161, 0x1162, 0x1163, 0x1164, 0x1165, 0x1166, 0x1167, 0x1168, 0x1169, 0x116A, 0x116B, 0x116C, 0x116D, 0x116E, 0x116F, 0x1170, 0x1171, 0x1172, 0x1173, 0x1174, 0x1175, 0x11A8, 0x11A9, 0x11AA, 0x11AB, 0x11AC, 0x11AD, 0x11AE, 0x11AF, 0x11B0, 0x11B1, 0x11B2, 0x11B3, 0x11B4, 0x11B5, 0x11B6, 0x11B7, 0x11B8, 0x11B9, 0x11BA, 0x11BB, 0x11BC, 0x11BD, 0x11BE, 0x11BF, 0x11C0, 0x11C1, 0x11C2, 0x1B35, 0x3099, 0x309A}; + +static bool is_modifier( unsigned c ) { + if (c < modifiers[0]) return false; // common case, bail early + unsigned lo = 0, hi = (unsigned) std::size(modifiers); + do { + unsigned mid = (lo+hi)/2; + unsigned hit = modifiers[mid]; + if ( c < hit ) hi = mid; + else if ( c > hit ) lo = mid + 1; + else return true; + } while(lo < hi); + return false; +} + +static constexpr struct { + uint16_t form1; + uint16_t form2[2]; +} normtable[] = { + {0x00C0, {0x0041,0x0300}}, + {0x00C1, {0x0041,0x0301}}, + {0x00C2, {0x0041,0x0302}}, + {0x00C3, {0x0041,0x0303}}, + {0x00C4, {0x0041,0x0308}}, + {0x00C5, {0x0041,0x030A}}, + {0x00C7, {0x0043,0x0327}}, + {0x00C8, {0x0045,0x0300}}, + {0x00C9, {0x0045,0x0301}}, + {0x00CA, {0x0045,0x0302}}, + {0x00CB, {0x0045,0x0308}}, + {0x00CC, {0x0049,0x0300}}, + {0x00CD, {0x0049,0x0301}}, + {0x00CE, {0x0049,0x0302}}, + {0x00CF, {0x0049,0x0308}}, + {0x00D1, {0x004E,0x0303}}, + {0x00D2, {0x004F,0x0300}}, + {0x00D3, {0x004F,0x0301}}, + {0x00D4, {0x004F,0x0302}}, + {0x00D5, {0x004F,0x0303}}, + {0x00D6, {0x004F,0x0308}}, + {0x00D9, {0x0055,0x0300}}, + {0x00DA, {0x0055,0x0301}}, + {0x00DB, {0x0055,0x0302}}, + {0x00DC, {0x0055,0x0308}}, + {0x00DD, {0x0059,0x0301}}, + {0x00E0, {0x0061,0x0300}}, + {0x00E1, {0x0061,0x0301}}, + {0x00E2, {0x0061,0x0302}}, + {0x00E3, {0x0061,0x0303}}, + {0x00E4, {0x0061,0x0308}}, + {0x00E5, {0x0061,0x030A}}, + {0x00E7, {0x0063,0x0327}}, + {0x00E8, {0x0065,0x0300}}, + {0x00E9, {0x0065,0x0301}}, + {0x00EA, {0x0065,0x0302}}, + {0x00EB, {0x0065,0x0308}}, + {0x00EC, {0x0069,0x0300}}, + {0x00ED, {0x0069,0x0301}}, + {0x00EE, {0x0069,0x0302}}, + {0x00EF, {0x0069,0x0308}}, + {0x00F1, {0x006E,0x0303}}, + {0x00F2, {0x006F,0x0300}}, + {0x00F3, {0x006F,0x0301}}, + {0x00F4, {0x006F,0x0302}}, + {0x00F5, {0x006F,0x0303}}, + {0x00F6, {0x006F,0x0308}}, + {0x00F9, {0x0075,0x0300}}, + {0x00FA, {0x0075,0x0301}}, + {0x00FB, {0x0075,0x0302}}, + {0x00FC, {0x0075,0x0308}}, + {0x00FD, {0x0079,0x0301}}, + {0x00FF, {0x0079,0x0308}}, + {0x0100, {0x0041,0x0304}}, + {0x0101, {0x0061,0x0304}}, + {0x0102, {0x0041,0x0306}}, + {0x0103, {0x0061,0x0306}}, + {0x0104, {0x0041,0x0328}}, + {0x0105, {0x0061,0x0328}}, + {0x0106, {0x0043,0x0301}}, + {0x0107, {0x0063,0x0301}}, + {0x0108, {0x0043,0x0302}}, + {0x0109, {0x0063,0x0302}}, + {0x010A, {0x0043,0x0307}}, + {0x010B, {0x0063,0x0307}}, + {0x010C, {0x0043,0x030C}}, + {0x010D, {0x0063,0x030C}}, + {0x010E, {0x0044,0x030C}}, + {0x010F, {0x0064,0x030C}}, + {0x0112, {0x0045,0x0304}}, + {0x0113, {0x0065,0x0304}}, + {0x0114, {0x0045,0x0306}}, + {0x0115, {0x0065,0x0306}}, + {0x0116, {0x0045,0x0307}}, + {0x0117, {0x0065,0x0307}}, + {0x0118, {0x0045,0x0328}}, + {0x0119, {0x0065,0x0328}}, + {0x011A, {0x0045,0x030C}}, + {0x011B, {0x0065,0x030C}}, + {0x011C, {0x0047,0x0302}}, + {0x011D, {0x0067,0x0302}}, + {0x011E, {0x0047,0x0306}}, + {0x011F, {0x0067,0x0306}}, + {0x0120, {0x0047,0x0307}}, + {0x0121, {0x0067,0x0307}}, + {0x0122, {0x0047,0x0327}}, + {0x0123, {0x0067,0x0327}}, + {0x0124, {0x0048,0x0302}}, + {0x0125, {0x0068,0x0302}}, + {0x0128, {0x0049,0x0303}}, + {0x0129, {0x0069,0x0303}}, + {0x012A, {0x0049,0x0304}}, + {0x012B, {0x0069,0x0304}}, + {0x012C, {0x0049,0x0306}}, + {0x012D, {0x0069,0x0306}}, + {0x012E, {0x0049,0x0328}}, + {0x012F, {0x0069,0x0328}}, + {0x0130, {0x0049,0x0307}}, + {0x0134, {0x004A,0x0302}}, + {0x0135, {0x006A,0x0302}}, + {0x0136, {0x004B,0x0327}}, + {0x0137, {0x006B,0x0327}}, + {0x0139, {0x004C,0x0301}}, + {0x013A, {0x006C,0x0301}}, + {0x013B, {0x004C,0x0327}}, + {0x013C, {0x006C,0x0327}}, + {0x013D, {0x004C,0x030C}}, + {0x013E, {0x006C,0x030C}}, + {0x0143, {0x004E,0x0301}}, + {0x0144, {0x006E,0x0301}}, + {0x0145, {0x004E,0x0327}}, + {0x0146, {0x006E,0x0327}}, + {0x0147, {0x004E,0x030C}}, + {0x0148, {0x006E,0x030C}}, + {0x014C, {0x004F,0x0304}}, + {0x014D, {0x006F,0x0304}}, + {0x014E, {0x004F,0x0306}}, + {0x014F, {0x006F,0x0306}}, + {0x0150, {0x004F,0x030B}}, + {0x0151, {0x006F,0x030B}}, + {0x0154, {0x0052,0x0301}}, + {0x0155, {0x0072,0x0301}}, + {0x0156, {0x0052,0x0327}}, + {0x0157, {0x0072,0x0327}}, + {0x0158, {0x0052,0x030C}}, + {0x0159, {0x0072,0x030C}}, + {0x015A, {0x0053,0x0301}}, + {0x015B, {0x0073,0x0301}}, + {0x015C, {0x0053,0x0302}}, + {0x015D, {0x0073,0x0302}}, + {0x015E, {0x0053,0x0327}}, + {0x015F, {0x0073,0x0327}}, + {0x0160, {0x0053,0x030C}}, + {0x0161, {0x0073,0x030C}}, + {0x0162, {0x0054,0x0327}}, + {0x0163, {0x0074,0x0327}}, + {0x0164, {0x0054,0x030C}}, + {0x0165, {0x0074,0x030C}}, + {0x0168, {0x0055,0x0303}}, + {0x0169, {0x0075,0x0303}}, + {0x016A, {0x0055,0x0304}}, + {0x016B, {0x0075,0x0304}}, + {0x016C, {0x0055,0x0306}}, + {0x016D, {0x0075,0x0306}}, + {0x016E, {0x0055,0x030A}}, + {0x016F, {0x0075,0x030A}}, + {0x0170, {0x0055,0x030B}}, + {0x0171, {0x0075,0x030B}}, + {0x0172, {0x0055,0x0328}}, + {0x0173, {0x0075,0x0328}}, + {0x0174, {0x0057,0x0302}}, + {0x0175, {0x0077,0x0302}}, + {0x0176, {0x0059,0x0302}}, + {0x0177, {0x0079,0x0302}}, + {0x0178, {0x0059,0x0308}}, + {0x0179, {0x005A,0x0301}}, + {0x017A, {0x007A,0x0301}}, + {0x017B, {0x005A,0x0307}}, + {0x017C, {0x007A,0x0307}}, + {0x017D, {0x005A,0x030C}}, + {0x017E, {0x007A,0x030C}}, + {0x01A0, {0x004F,0x031B}}, + {0x01A1, {0x006F,0x031B}}, + {0x01AF, {0x0055,0x031B}}, + {0x01B0, {0x0075,0x031B}}, + {0x01CD, {0x0041,0x030C}}, + {0x01CE, {0x0061,0x030C}}, + {0x01CF, {0x0049,0x030C}}, + {0x01D0, {0x0069,0x030C}}, + {0x01D1, {0x004F,0x030C}}, + {0x01D2, {0x006F,0x030C}}, + {0x01D3, {0x0055,0x030C}}, + {0x01D4, {0x0075,0x030C}}, + {0x01E2, {0x00C6,0x0304}}, + {0x01E3, {0x00E6,0x0304}}, + {0x01E6, {0x0047,0x030C}}, + {0x01E7, {0x0067,0x030C}}, + {0x01E8, {0x004B,0x030C}}, + {0x01E9, {0x006B,0x030C}}, + {0x01EA, {0x004F,0x0328}}, + {0x01EB, {0x006F,0x0328}}, + {0x01EE, {0x01B7,0x030C}}, + {0x01EF, {0x0292,0x030C}}, + {0x01F0, {0x006A,0x030C}}, + {0x01F4, {0x0047,0x0301}}, + {0x01F5, {0x0067,0x0301}}, + {0x01F8, {0x004E,0x0300}}, + {0x01F9, {0x006E,0x0300}}, + {0x01FC, {0x00C6,0x0301}}, + {0x01FD, {0x00E6,0x0301}}, + {0x01FE, {0x00D8,0x0301}}, + {0x01FF, {0x00F8,0x0301}}, + {0x0200, {0x0041,0x030F}}, + {0x0201, {0x0061,0x030F}}, + {0x0202, {0x0041,0x0311}}, + {0x0203, {0x0061,0x0311}}, + {0x0204, {0x0045,0x030F}}, + {0x0205, {0x0065,0x030F}}, + {0x0206, {0x0045,0x0311}}, + {0x0207, {0x0065,0x0311}}, + {0x0208, {0x0049,0x030F}}, + {0x0209, {0x0069,0x030F}}, + {0x020A, {0x0049,0x0311}}, + {0x020B, {0x0069,0x0311}}, + {0x020C, {0x004F,0x030F}}, + {0x020D, {0x006F,0x030F}}, + {0x020E, {0x004F,0x0311}}, + {0x020F, {0x006F,0x0311}}, + {0x0210, {0x0052,0x030F}}, + {0x0211, {0x0072,0x030F}}, + {0x0212, {0x0052,0x0311}}, + {0x0213, {0x0072,0x0311}}, + {0x0214, {0x0055,0x030F}}, + {0x0215, {0x0075,0x030F}}, + {0x0216, {0x0055,0x0311}}, + {0x0217, {0x0075,0x0311}}, + {0x0218, {0x0053,0x0326}}, + {0x0219, {0x0073,0x0326}}, + {0x021A, {0x0054,0x0326}}, + {0x021B, {0x0074,0x0326}}, + {0x021E, {0x0048,0x030C}}, + {0x021F, {0x0068,0x030C}}, + {0x0226, {0x0041,0x0307}}, + {0x0227, {0x0061,0x0307}}, + {0x0228, {0x0045,0x0327}}, + {0x0229, {0x0065,0x0327}}, + {0x022E, {0x004F,0x0307}}, + {0x022F, {0x006F,0x0307}}, + {0x0232, {0x0059,0x0304}}, + {0x0233, {0x0079,0x0304}}, + {0x0344, {0x0308,0x0301}}, + {0x0385, {0x00A8,0x0301}}, + {0x0386, {0x0391,0x0301}}, + {0x0388, {0x0395,0x0301}}, + {0x0389, {0x0397,0x0301}}, + {0x038A, {0x0399,0x0301}}, + {0x038C, {0x039F,0x0301}}, + {0x038E, {0x03A5,0x0301}}, + {0x038F, {0x03A9,0x0301}}, + {0x03AA, {0x0399,0x0308}}, + {0x03AB, {0x03A5,0x0308}}, + {0x03AC, {0x03B1,0x0301}}, + {0x03AD, {0x03B5,0x0301}}, + {0x03AE, {0x03B7,0x0301}}, + {0x03AF, {0x03B9,0x0301}}, + {0x03CA, {0x03B9,0x0308}}, + {0x03CB, {0x03C5,0x0308}}, + {0x03CC, {0x03BF,0x0301}}, + {0x03CD, {0x03C5,0x0301}}, + {0x03CE, {0x03C9,0x0301}}, + {0x03D3, {0x03D2,0x0301}}, + {0x03D4, {0x03D2,0x0308}}, + {0x0400, {0x0415,0x0300}}, + {0x0401, {0x0415,0x0308}}, + {0x0403, {0x0413,0x0301}}, + {0x0407, {0x0406,0x0308}}, + {0x040C, {0x041A,0x0301}}, + {0x040D, {0x0418,0x0300}}, + {0x040E, {0x0423,0x0306}}, + {0x0419, {0x0418,0x0306}}, + {0x0439, {0x0438,0x0306}}, + {0x0450, {0x0435,0x0300}}, + {0x0451, {0x0435,0x0308}}, + {0x0453, {0x0433,0x0301}}, + {0x0457, {0x0456,0x0308}}, + {0x045C, {0x043A,0x0301}}, + {0x045D, {0x0438,0x0300}}, + {0x045E, {0x0443,0x0306}}, + {0x0476, {0x0474,0x030F}}, + {0x0477, {0x0475,0x030F}}, + {0x04C1, {0x0416,0x0306}}, + {0x04C2, {0x0436,0x0306}}, + {0x04D0, {0x0410,0x0306}}, + {0x04D1, {0x0430,0x0306}}, + {0x04D2, {0x0410,0x0308}}, + {0x04D3, {0x0430,0x0308}}, + {0x04D6, {0x0415,0x0306}}, + {0x04D7, {0x0435,0x0306}}, + {0x04DA, {0x04D8,0x0308}}, + {0x04DB, {0x04D9,0x0308}}, + {0x04DC, {0x0416,0x0308}}, + {0x04DD, {0x0436,0x0308}}, + {0x04DE, {0x0417,0x0308}}, + {0x04DF, {0x0437,0x0308}}, + {0x04E2, {0x0418,0x0304}}, + {0x04E3, {0x0438,0x0304}}, + {0x04E4, {0x0418,0x0308}}, + {0x04E5, {0x0438,0x0308}}, + {0x04E6, {0x041E,0x0308}}, + {0x04E7, {0x043E,0x0308}}, + {0x04EA, {0x04E8,0x0308}}, + {0x04EB, {0x04E9,0x0308}}, + {0x04EC, {0x042D,0x0308}}, + {0x04ED, {0x044D,0x0308}}, + {0x04EE, {0x0423,0x0304}}, + {0x04EF, {0x0443,0x0304}}, + {0x04F0, {0x0423,0x0308}}, + {0x04F1, {0x0443,0x0308}}, + {0x04F2, {0x0423,0x030B}}, + {0x04F3, {0x0443,0x030B}}, + {0x04F4, {0x0427,0x0308}}, + {0x04F5, {0x0447,0x0308}}, + {0x04F8, {0x042B,0x0308}}, + {0x04F9, {0x044B,0x0308}}, +}; + + +static const uint16_t * match( uint16_t c ) { + size_t lo = 0, hi = std::size(normtable); + do { + size_t mid = (lo+hi)/2; + auto & rec = normtable[mid]; + if ( rec.form1 < c ) lo = mid + 1; + else if ( rec.form1 > c ) hi = mid; + else return rec.form2; + } while( lo < hi ); + return nullptr; +} +namespace { + class shortener { + public: + shortener() { + for (auto& walk : normtable) { + m_data[walk.form2[0]][walk.form2[1]] = walk.form1; + } + } + + std::map< uint16_t, std::map > m_data; + }; +} + +namespace pfc { + pfc::string8 unicodeNormalizeD_Lite(const char* in) { + pfc::string8 ret; ret.prealloc(1024); + for (;; ) { + unsigned c; + auto d = utf8_decode_char(in, c); + if (d == 0) break; + in += d; + const uint16_t* m = nullptr; + if (c < 0x10000) { + m = match((uint16_t)c); + } + if (m != nullptr) { + ret.add_char(m[0]); + ret.add_char(m[1]); + } else { + ret.add_char(c); + } + } + + return ret; + } + pfc::string8 unicodeNormalizeC_Lite(const char* in) { + static shortener g_shortener; auto& data = g_shortener.m_data; + pfc::string8 ret; ret.prealloc(strlen(in)); + for (;; ) { + unsigned c; + auto d = pfc::utf8_decode_char(in, c); + if (d == 0) break; + in += d; + if ( c < 0x10000 ) { + auto iter1 = data.find((uint16_t)c); + if (iter1 != data.end()) { + unsigned next; + auto d2 = pfc::utf8_decode_char(in, next); + if (d2 != 0) { + auto& data2 = iter1->second; + auto iter2 = data2.find(next); + if (iter2 != data2.end()) { + in += d2; + ret.add_char(iter2->second); continue; + } + } + } + } + ret.add_char(c); + } + return ret; + } + bool stringContainsFormD(const char* in) { + for (;; ) { + unsigned c; + auto d = pfc::utf8_decode_char(in, c); + if (d == 0) return false; + if (is_modifier(c)) return true; + in += d; + } + } +} +#if ! defined(__APPLE__) && !defined(_WIN32) +namespace pfc { + pfc::string8 unicodeNormalizeD(const char* in) { + return unicodeNormalizeD_Lite(in); + } + pfc::string8 unicodeNormalizeC(const char* in) { + return unicodeNormalizeC_Lite(in); + } +} + +#endif // #if ! defined(__APPLE__) && !defined(_WIN32) + diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/unicode-normalize.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/unicode-normalize.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,20 @@ +#pragma once + +namespace pfc { + + // Unicode normalization. + // If you have no idea WTF this is about - good for you. The less you know the better for your sanity. + + // _Lite versions are simplified portable versions implemented using hardcoded tables, they're not meant to be complete. They cover only a subset of known two-char sequences. + // Normal versions (not _Lite) are implemented using operating system methods where possible (MS, Apple), fall back to calling _Lite otherwise. + + // Normalize to form C + pfc::string8 unicodeNormalizeC(const char * in); + pfc::string8 unicodeNormalizeC_Lite(const char* in); + + // Normalize to form D + pfc::string8 unicodeNormalizeD(const char* in); + pfc::string8 unicodeNormalizeD_Lite(const char* in); + + bool stringContainsFormD(const char* in); +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/utf8.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/utf8.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,160 @@ +#include "pfc-lite.h" +#include "string_base.h" + +namespace pfc { +//utf8 stuff +#include "pocket_char_ops.h" + +#ifdef _MSC_VER + t_size utf16_decode_char(const wchar_t * p_source,unsigned * p_out,t_size p_source_length) throw() { + PFC_STATIC_ASSERT( sizeof(wchar_t) == sizeof(char16_t) ); + return wide_decode_char( p_source, p_out, p_source_length ); + } + t_size utf16_encode_char(unsigned c,wchar_t * out) throw() { + PFC_STATIC_ASSERT( sizeof(wchar_t) == sizeof(char16_t) ); + return wide_encode_char( c, out ); + } +#endif + + t_size wide_decode_char(const wchar_t * p_source,unsigned * p_out,t_size p_source_length) throw() { + PFC_STATIC_ASSERT( sizeof( wchar_t ) == sizeof( char16_t ) || sizeof( wchar_t ) == sizeof( unsigned ) ); + if constexpr (sizeof( wchar_t ) == sizeof( char16_t ) ) { + return utf16_decode_char( reinterpret_cast< const char16_t *>(p_source), p_out, p_source_length ); + } else { + if (p_source_length == 0) { * p_out = 0; return 0; } + * p_out = p_source [ 0 ]; + return 1; + } + } + t_size wide_encode_char(unsigned c,wchar_t * out) throw() { + PFC_STATIC_ASSERT( sizeof( wchar_t ) == sizeof( char16_t ) || sizeof( wchar_t ) == sizeof( unsigned ) ); + if constexpr (sizeof( wchar_t ) == sizeof( char16_t ) ) { + return utf16_encode_char( c, reinterpret_cast< char16_t * >(out) ); + } else { + * out = (wchar_t) c; + return 1; + } + } + + size_t uni_decode_char(const char16_t * p_source, unsigned & p_out, size_t p_source_length) noexcept { + return utf16_decode_char(p_source, &p_out, p_source_length); + } + size_t uni_decode_char(const char * p_source, unsigned & p_out, size_t p_source_length) noexcept { + return utf8_decode_char(p_source, p_out, p_source_length); + } + size_t uni_decode_char(const wchar_t * p_source, unsigned & p_out, size_t p_source_length) noexcept { + if constexpr ( sizeof(wchar_t) == sizeof(char16_t)) { + return utf16_decode_char( reinterpret_cast(p_source), &p_out, p_source_length); + } else { + if (p_source_length > 0) { + unsigned c = (unsigned)*p_source; + if (c != 0) { + p_out = c; return 1; + } + } + p_out = 0; return 0; + } + } + + size_t uni_char_length(const char * arg) { + return utf8_char_len(arg); + } + size_t uni_char_length(const char16_t * arg) { + unsigned dontcare; + return utf16_decode_char(arg, &dontcare); + } + size_t uni_char_length(const wchar_t * arg) { + if constexpr ( sizeof(wchar_t) == sizeof(char16_t) ) { + unsigned dontcare; + return utf16_decode_char(reinterpret_cast(arg), &dontcare); + } else { + return *arg == 0 ? 0 : 1; + } + } + + size_t uni_encode_char(unsigned c, char* out) noexcept { + PFC_ASSERT(c != 0); + return utf8_encode_char(c, out); + } + size_t uni_encode_char(unsigned c, char16_t* out) noexcept { + PFC_ASSERT(c != 0); + return utf16_encode_char(c, out); + } + size_t uni_encode_char(unsigned c, wchar_t* out) noexcept { + PFC_ASSERT(c != 0); + if constexpr ( sizeof(wchar_t) == sizeof(char16_t)) { + return utf16_encode_char(c, reinterpret_cast(out)); + } else { + *out = (wchar_t)c; return 1; + } + } + + +bool is_lower_ascii(const char * param) +{ + while(*param) + { + if (*param<0) return false; + param++; + } + return true; +} + +static bool check_end_of_string(const char * ptr) +{ + return !*ptr; +} + +size_t strcpy_utf8_truncate(const char * src,char * out,size_t maxbytes) +{ + size_t rv = 0 , ptr = 0; + if (maxbytes>0) + { + maxbytes--;//for null + while(!check_end_of_string(src) && maxbytes>0) + { + size_t delta = utf8_char_len(src); + if (delta>maxbytes || delta==0) break; + maxbytes -= delta; + do + { + out[ptr++] = *(src++); + } while(--delta); + rv = ptr; + } + out[rv]=0; + } + return rv; +} + +t_size strlen_utf8(const char * p,t_size num) noexcept +{ + unsigned w; + t_size d; + t_size ret = 0; + for(;num;) + { + d = utf8_decode_char(p,w); + if (w==0 || d<=0) break; + ret++; + p+=d; + num-=d; + } + return ret; +} + +t_size utf8_chars_to_bytes(const char * string,t_size count) noexcept +{ + t_size bytes = 0; + while(count) + { + unsigned dummy; + t_size delta = utf8_decode_char(string+bytes,dummy); + if (delta==0) break; + bytes += delta; + count--; + } + return bytes; +} + +} \ No newline at end of file diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/wait_queue.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/wait_queue.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,215 @@ +#pragma once + +#include +#include "synchro.h" + +namespace pfc { + + template + class waitQueue { + public: + waitQueue() : m_eof() {} + + template + void put( arg_t && obj ) { + mutexScope guard( m_mutex ); + m_list.push_back( std::forward(obj) ); + if ( m_list.size() == 1 ) m_canRead.set_state( true ); + } + + void set_eof() { + mutexScope guard(m_mutex); + m_eof = true; + m_canRead.set_state(true); + } + bool wait_read( double timeout ) { + return m_canRead.wait_for( timeout ); + } + eventHandle_t get_event_handle() { + return m_canRead.get_handle(); + } + + bool get( obj_t & out ) { + for ( ;; ) { + m_canRead.wait_for(-1); + mutexScope guard(m_mutex); + auto i = m_list.begin(); + if ( i == m_list.end() ) { + if (m_eof) return false; + continue; + } + out = std::move(*i); + m_list.erase( i ); + didGet(); + return true; + } + } + + bool get( obj_t & out, pfc::eventHandle_t hAbort, bool * didAbort = nullptr ) { + if (didAbort != nullptr) * didAbort = false; + for ( ;; ) { + if (pfc::event::g_twoEventWait( hAbort, m_canRead.get_handle(), -1) == 1) { + if (didAbort != nullptr) * didAbort = true; + return false; + } + mutexScope guard(m_mutex); + auto i = m_list.begin(); + if ( i == m_list.end() ) { + if (m_eof) return false; + continue; + } + out = std::move(*i); + m_list.erase( i ); + didGet(); + return true; + } + } + void clear() { + mutexScope guard(m_mutex); + m_eof = false; + m_list.clear(); + m_canRead.set_state(false); + } + private: + void didGet() { + if (!m_eof && m_list.size() == 0) m_canRead.set_state(false); + } + bool m_eof; + std::list m_list; + mutex m_mutex; + event m_canRead; + }; + + template + class waitQueue2 { + protected: + typedef obj_t_ obj_t; + typedef std::list list_t; + virtual bool canWriteCheck(list_t const &) { return true; } + + public: + void waitWrite() { + m_canWrite.wait_for(-1); + } + bool waitWrite(pfc::eventHandle_t hAbort) { + return event::g_twoEventWait( hAbort, m_canWrite.get_handle(), -1) == 2; + } + eventHandle_t waitWriteHandle() { + return m_canWrite.get_handle(); + } + + waitQueue2() { + m_canWrite.set_state(true); + } + + template + void put(arg_t && obj) { + mutexScope guard(m_mutex); + m_list.push_back(std::forward(obj)); + if (m_list.size() == 1) m_canRead.set_state(true); + refreshCanWrite(); + } + + void set_eof() { + mutexScope guard(m_mutex); + m_eof = true; + m_canRead.set_state(true); + m_canWrite.set_state(false); + } + + bool get(obj_t & out) { + for (;; ) { + m_canRead.wait_for(-1); + mutexScope guard(m_mutex); + auto i = m_list.begin(); + if (i == m_list.end()) { + if (m_eof) return false; + continue; + } + out = std::move(*i); + m_list.erase(i); + didGet(); + return true; + } + } + + typedef std::function receive_peek_t; + // Block until there's something to return + return multiple objects at once. + // Use peek function (optional) to stop reading / leave remaining items for the next call to pick up. + std::list receive(pfc::eventHandle_t hAbort, receive_peek_t peek = nullptr , bool* didAbort = nullptr) { + if (didAbort != nullptr) *didAbort = false; + std::list ret; + for (bool retry = false; ; retry = true ) { + // try without wait first, only place where this is really used can poll abort before/after without system calls + if (retry && pfc::event::g_twoEventWait(hAbort, m_canRead.get_handle(), -1) == 1) { + if (didAbort != nullptr) *didAbort = true; + break; + } + mutexScope guard(m_mutex); + auto i = m_list.begin(); + if (i == m_list.end()) { + if (m_eof) break; + continue; + } + bool bDidGet = false; + do { + if (peek && !peek(*i)) break; + auto n = i; ++n; + ret.splice(ret.end(), m_list, i); + i = std::move(n); + bDidGet = true; + } while (i != m_list.end()); + if ( bDidGet ) didGet(); + break; + } + return ret; + } + + bool get(obj_t & out, pfc::eventHandle_t hAbort, bool * didAbort = nullptr) { + if (didAbort != nullptr) * didAbort = false; + for (;; ) { + if (pfc::event::g_twoEventWait(hAbort, m_canRead.get_handle(), -1) == 1) { + if (didAbort != nullptr) * didAbort = true; + return false; + } + mutexScope guard(m_mutex); + auto i = m_list.begin(); + if (i == m_list.end()) { + if (m_eof) return false; + continue; + } + out = std::move(*i); + m_list.erase(i); + didGet(); + return true; + } + } + + void clear() { + mutexScope guard(m_mutex); + m_list.clear(); + m_eof = false; + m_canRead.set_state(false); + m_canWrite.set_state(true); + } + private: + void didGet() { + // mutex assumed locked + if (m_eof) return; + if (m_list.empty()) { + m_canRead.set_state(false); + m_canWrite.set_state(true); + } else { + m_canWrite.set_state(canWriteCheck(m_list)); + } + } + void refreshCanWrite() { + // mutex assumed locked + m_canWrite.set_state( !m_eof && canWriteCheck(m_list)); + } + bool m_eof = false; + std::list m_list; + mutex m_mutex; + event m_canRead, m_canWrite; + }; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/weakRef.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/weakRef.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,71 @@ +#pragma once + +// PFC weakRef class +// Create weak references to objects that automatically become invalidated upon destruction of the object +// Note that this is NOT thread safe and meant for single thread usage. If you require thread safety, provide your own means, such as mutexlocking of weakRef::get() and the destruction of your objects. + +#include // std::shared_ptr + +namespace pfc { + typedef std::shared_ptr weakRefKillSwitch_t; + + template + class weakRef { + typedef weakRef self_t; + public: + static self_t _make(target_t * target, weakRefKillSwitch_t ks) { + self_t ret; + ret.m_target = target; + ret.m_ks = ks; + return ret; + } + + + bool isValid() const { + return m_ks && !*m_ks; + } + + target_t * get() const { + if (!isValid()) return nullptr; + return m_target; + } + target_t * operator() () const { + return get(); + } + private: + target_t * m_target = nullptr; + weakRefKillSwitch_t m_ks; + }; + + template + class weakRefTarget { + public: + weakRefTarget() {} + + typedef weakRef weakRef_t; + + weakRef weakRef() { + PFC_ASSERT(!*m_ks); + class_t * ptr = static_cast(this); + return weakRef_t::_make(ptr, m_ks); + } + + // Optional: explicitly invalidates all weak references to this object. Called implicitly by the destructor, but you can do it yourself earlier. + void weakRefShutdown() { + *m_ks = true; + } + ~weakRefTarget() { + weakRefShutdown(); + } + + // Optional: obtain a reference to the killswitch if you wish to use it directly + weakRefKillSwitch_t weakRefKS() const { + return m_ks; + } + private: + std::shared_ptr m_ks = std::make_shared(false); + + weakRefTarget(const weakRefTarget &) = delete; + void operator=(const weakRefTarget &) = delete; + }; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/wildcard.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/wildcard.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,52 @@ +#include "pfc-lite.h" +#include "wildcard.h" +#include "string_base.h" + +static bool test_recur(const char * fn,const char * rm,bool b_sep) +{ + for(;;) + { + if ((b_sep && *rm==';') || *rm==0) return *fn==0; + else if (*rm=='*') + { + rm++; + do + { + if (test_recur(fn,rm,b_sep)) return true; + } while(pfc::utf8_advance(fn)); + return false; + } + else if (*fn==0) return false; + else if (*rm!='?' && pfc::charLower(pfc::utf8_get_char(fn))!=pfc::charLower(pfc::utf8_get_char(rm))) return false; + + fn = pfc::utf8_char_next(fn); rm = pfc::utf8_char_next(rm); + } +} + +bool wildcard_helper::test_path(const char * path,const char * pattern,bool b_sep) {return test(path + pfc::scan_filename(path),pattern,b_sep);} + +bool wildcard_helper::test(const char * fn,const char * pattern,bool b_sep) +{ + if (!b_sep) return test_recur(fn,pattern,false); + const char * rm=pattern; + while(*rm) + { + if (test_recur(fn,rm,true)) return true; + while(*rm && *rm!=';') rm++; + if (*rm==';') + { + while(*rm==';') rm++; + while(*rm==' ') rm++; + } + }; + + return false; +} + +bool wildcard_helper::has_wildcards(const char * str) {return strchr(str,'*') || strchr(str,'?');} + +const char * wildcard_helper::get_wildcard_list() {return "*?";} + +bool wildcard_helper::is_wildcard(char c) { + return c == '*' || c == '?'; +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/wildcard.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/wildcard.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,10 @@ +#pragma once + +namespace wildcard_helper +{ + bool test_path(const char * path,const char * pattern,bool b_separate_by_semicolon = false);//will extract filename from path first + bool test(const char * str,const char * pattern,bool b_separate_by_semicolon = false);//tests if str matches pattern + bool has_wildcards(const char * str); + const char * get_wildcard_list(); + bool is_wildcard(char c); +}; diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/win-objects.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/win-objects.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,563 @@ +#include "pfc-lite.h" + +#ifdef _WIN32 +#include "win-objects.h" +#include "array.h" +#include "pp-winapi.h" +#include "string_conv.h" +#include "string_base.h" +#include "debug.h" +#include "string-conv-lite.h" + +#include "pfc-fb2k-hooks.h" + +#include "sortstring.h" + +// StrCmpLogicalW() +#include +#pragma comment(lib, "Shlwapi.lib") + +namespace pfc { + +BOOL winFormatSystemErrorMessageImpl(pfc::string_base & p_out,DWORD p_code) { + switch(p_code) { + case ERROR_CHILD_NOT_COMPLETE: + p_out = "Application cannot be run in Win32 mode."; + return TRUE; + case ERROR_INVALID_ORDINAL: + p_out = "Invalid ordinal."; + return TRUE; + case ERROR_INVALID_STARTING_CODESEG: + p_out = "Invalid code segment."; + return TRUE; + case ERROR_INVALID_STACKSEG: + p_out = "Invalid stack segment."; + return TRUE; + case ERROR_INVALID_MODULETYPE: + p_out = "Invalid module type."; + return TRUE; + case ERROR_INVALID_EXE_SIGNATURE: + p_out = "Invalid executable signature."; + return TRUE; + case ERROR_BAD_EXE_FORMAT: + p_out = "Not a valid Win32 application."; + return TRUE; + case ERROR_EXE_MACHINE_TYPE_MISMATCH: + p_out = "Machine type mismatch."; + return TRUE; + case ERROR_EXE_CANNOT_MODIFY_SIGNED_BINARY: + case ERROR_EXE_CANNOT_MODIFY_STRONG_SIGNED_BINARY: + p_out = "Unable to modify a signed binary."; + return TRUE; + default: + { +#ifdef PFC_WINDOWS_DESKTOP_APP + TCHAR temp[512]; + if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,0,p_code,0,temp,_countof(temp),0) == 0) return FALSE; + for(t_size n=0;n<_countof(temp);n++) { + switch(temp[n]) { + case '\n': + case '\r': + temp[n] = ' '; + break; + } + } + p_out = stringcvt::string_utf8_from_os(temp,_countof(temp)); + return TRUE; +#else + return FALSE; +#endif + } + } +} +void winPrefixPath(pfc::string_base & out, const char * p_path) { + if (pfc::string_has_prefix(p_path, "..\\") || strstr(p_path, "\\..\\") ) { + // do not touch relative paths if we somehow got them here + out = p_path; + return; + } + const char * prepend_header = "\\\\?\\"; + const char * prepend_header_net = "\\\\?\\UNC\\"; + if (pfc::strcmp_partial( p_path, prepend_header ) == 0) { out = p_path; return; } + out.reset(); + if (pfc::strcmp_partial(p_path,"\\\\") != 0) { + out << prepend_header << p_path; + } else { + out << prepend_header_net << (p_path+2); + } +}; + +BOOL winFormatSystemErrorMessage(pfc::string_base & p_out, DWORD p_code) { + return winFormatSystemErrorMessageHook( p_out, p_code ); +} +void winUnPrefixPath(pfc::string_base & out, const char * p_path) { + const char * prepend_header = "\\\\?\\"; + const char * prepend_header_net = "\\\\?\\UNC\\"; + if (pfc::strcmp_partial(p_path, prepend_header_net) == 0) { + out = PFC_string_formatter() << "\\\\" << (p_path + strlen(prepend_header_net) ); + return; + } + if (pfc::strcmp_partial(p_path, prepend_header) == 0) { + out = (p_path + strlen(prepend_header)); + return; + } + out = p_path; +} + +string8 winPrefixPath(const char * in) { + string8 temp; winPrefixPath(temp, in); return temp; +} +string8 winUnPrefixPath(const char * in) { + string8 temp; winUnPrefixPath(temp, in); return temp; +} + +} // namespace pfc + +pfc::string8 format_win32_error(DWORD p_code) { + pfc::LastErrorRevertScope revert; + pfc::string8 buffer; + if (p_code == 0) buffer = "Undefined error"; + else if (!pfc::winFormatSystemErrorMessage(buffer,p_code)) buffer << "Unknown error code (" << (unsigned)p_code << ")"; + return buffer; +} + +static void format_hresult_stamp_hex(pfc::string8 & buffer, HRESULT p_code) { + buffer << " (0x" << pfc::format_hex((t_uint32)p_code, 8) << ")"; +} + +pfc::string8 format_hresult(HRESULT p_code) { + pfc::string8 buffer; + if (!pfc::winFormatSystemErrorMessage(buffer,(DWORD)p_code)) buffer = "Unknown error code"; + format_hresult_stamp_hex(buffer, p_code); + return buffer; +} +pfc::string8 format_hresult(HRESULT p_code, const char * msgOverride) { + pfc::string8 buffer = msgOverride; + format_hresult_stamp_hex(buffer, p_code); + return buffer; +} + + +#ifdef PFC_WINDOWS_DESKTOP_APP + +namespace pfc { + HWND findOwningPopup(HWND p_wnd) + { + HWND walk = p_wnd; + while (walk != 0 && (GetWindowLong(walk, GWL_STYLE) & WS_CHILD) != 0) + walk = GetParent(walk); + return walk ? walk : p_wnd; + } + string8 getWindowClassName(HWND wnd) { + TCHAR temp[1024] = {}; + if (GetClassName(wnd, temp, PFC_TABSIZE(temp)) == 0) { + PFC_ASSERT(!"Should not get here"); + return ""; + } + return pfc::stringcvt::string_utf8_from_os(temp).get_ptr(); + } + void setWindowText(HWND wnd, const char * txt) { + SetWindowText(wnd, stringcvt::string_os_from_utf8(txt)); + } + string8 getWindowText(HWND wnd) { + PFC_ASSERT(wnd != NULL); + int len = GetWindowTextLength(wnd); + if (len >= 0) + { + len++; + pfc::array_t temp; + temp.set_size(len); + temp[0] = 0; + if (GetWindowText(wnd, temp.get_ptr(), len) > 0) + { + return stringcvt::string_utf8_from_os(temp.get_ptr(), len).get_ptr(); + } + } + return ""; + } +} + +void uAddWindowStyle(HWND p_wnd,LONG p_style) { + SetWindowLong(p_wnd,GWL_STYLE, GetWindowLong(p_wnd,GWL_STYLE) | p_style); +} + +void uRemoveWindowStyle(HWND p_wnd,LONG p_style) { + SetWindowLong(p_wnd,GWL_STYLE, GetWindowLong(p_wnd,GWL_STYLE) & ~p_style); +} + +void uAddWindowExStyle(HWND p_wnd,LONG p_style) { + SetWindowLong(p_wnd,GWL_EXSTYLE, GetWindowLong(p_wnd,GWL_EXSTYLE) | p_style); +} + +void uRemoveWindowExStyle(HWND p_wnd,LONG p_style) { + SetWindowLong(p_wnd,GWL_EXSTYLE, GetWindowLong(p_wnd,GWL_EXSTYLE) & ~p_style); +} + +unsigned MapDialogWidth(HWND p_dialog,unsigned p_value) { + RECT temp; + temp.left = 0; temp.right = p_value; temp.top = temp.bottom = 0; + if (!MapDialogRect(p_dialog,&temp)) return 0; + return temp.right; +} + +bool IsKeyPressed(unsigned vk) { + return (GetKeyState(vk) & 0x8000) ? true : false; +} + +//! Returns current modifier keys pressed, using win32 MOD_* flags. +unsigned GetHotkeyModifierFlags() { + unsigned ret = 0; + if (IsKeyPressed(VK_CONTROL)) ret |= MOD_CONTROL; + if (IsKeyPressed(VK_SHIFT)) ret |= MOD_SHIFT; + if (IsKeyPressed(VK_MENU)) ret |= MOD_ALT; + if (IsKeyPressed(VK_LWIN) || IsKeyPressed(VK_RWIN)) ret |= MOD_WIN; + return ret; +} + + + +bool CClipboardOpenScope::Open(HWND p_owner) { + Close(); + if (OpenClipboard(p_owner)) { + m_open = true; + return true; + } else { + return false; + } +} +void CClipboardOpenScope::Close() { + if (m_open) { + m_open = false; + CloseClipboard(); + } +} + + +CGlobalLockScope::CGlobalLockScope(HGLOBAL p_handle) : m_ptr(GlobalLock(p_handle)), m_handle(p_handle) { + if (m_ptr == NULL) throw std::bad_alloc(); +} +CGlobalLockScope::~CGlobalLockScope() { + if (m_ptr != NULL) GlobalUnlock(m_handle); +} + +bool IsPointInsideControl(const POINT& pt, HWND wnd) { + HWND walk = WindowFromPoint(pt); + for(;;) { + if (walk == NULL) return false; + if (walk == wnd) return true; + if (GetWindowLong(walk,GWL_STYLE) & WS_POPUP) return false; + walk = GetParent(walk); + } +} +bool IsPopupWindowChildOf(HWND child, HWND parent) { + HWND walk = child; + while (walk != parent && walk != NULL) { + walk = GetParent(walk); + } + return walk == parent; +} +bool IsWindowChildOf(HWND child, HWND parent) { + HWND walk = child; + while(walk != parent && walk != NULL && (GetWindowLong(walk,GWL_STYLE) & WS_CHILD) != 0) { + walk = GetParent(walk); + } + return walk == parent; +} +void ResignActiveWindow(HWND wnd) { + if (IsPopupWindowChildOf(GetActiveWindow(), wnd)) { + HWND parent = GetParent(wnd); + if ( parent != NULL ) SetActiveWindow(parent); + } +} +void win32_menu::release() { + if (m_menu != NULL) { + DestroyMenu(m_menu); + m_menu = NULL; + } +} + +void win32_menu::create_popup() { + release(); + SetLastError(NO_ERROR); + m_menu = CreatePopupMenu(); + if (m_menu == NULL) throw exception_win32(GetLastError()); +} + +#endif // #ifdef PFC_WINDOWS_DESKTOP_APP + +void win32_event::create(bool p_manualreset,bool p_initialstate) { + release(); + SetLastError(NO_ERROR); + m_handle = CreateEvent(NULL,p_manualreset ? TRUE : FALSE, p_initialstate ? TRUE : FALSE,NULL); + if (m_handle == NULL) throw exception_win32(GetLastError()); +} + +void win32_event::release() { + HANDLE temp = detach(); + if (temp != NULL) CloseHandle(temp); +} + + +DWORD win32_event::g_calculate_wait_time(double p_seconds) { + DWORD time = 0; + if (p_seconds> 0) { + time = pfc::rint32(p_seconds * 1000.0); + if (time == 0) time = 1; + } else if (p_seconds < 0) { + time = INFINITE; + } + return time; +} + +//! Returns true when signaled, false on timeout +bool win32_event::g_wait_for(HANDLE p_event,double p_timeout_seconds) { + SetLastError(NO_ERROR); + DWORD status = WaitForSingleObject(p_event,g_calculate_wait_time(p_timeout_seconds)); + switch(status) { + case WAIT_FAILED: + throw exception_win32(GetLastError()); + case WAIT_OBJECT_0: + return true; + case WAIT_TIMEOUT: + return false; + default: + pfc::crash(); + } +} + +void win32_event::set_state(bool p_state) { + PFC_ASSERT(m_handle != NULL); + if (p_state) SetEvent(m_handle); + else ResetEvent(m_handle); +} + +size_t win32_event::g_multiWait(const HANDLE* events, size_t count, double timeout) { + auto status = WaitForMultipleObjects((DWORD)count, events, FALSE, g_calculate_wait_time(timeout)); + size_t idx = (size_t)(status - WAIT_OBJECT_0); + if (idx < count) { + return idx; + } + if (status == WAIT_TIMEOUT) return SIZE_MAX; + pfc::crash(); +} +size_t win32_event::g_multiWait( std::initializer_list const & arg, double timeout ) { + return g_multiWait(arg.begin(), arg.size(), timeout); +} + +int win32_event::g_twoEventWait( HANDLE ev1, HANDLE ev2, double timeout ) { + HANDLE h[2] = {ev1, ev2}; + switch(WaitForMultipleObjects(2, h, FALSE, g_calculate_wait_time( timeout ) )) { + default: + pfc::crash(); + case WAIT_TIMEOUT: + return 0; + case WAIT_OBJECT_0: + return 1; + case WAIT_OBJECT_0 + 1: + return 2; + } +} + +int win32_event::g_twoEventWait( win32_event & ev1, win32_event & ev2, double timeout ) { + return g_twoEventWait( ev1.get_handle(), ev2.get_handle(), timeout ); +} + +#ifdef PFC_WINDOWS_DESKTOP_APP + +void win32_icon::release() { + HICON temp = detach(); + if (temp != NULL) DestroyIcon(temp); +} + + +void win32_accelerator::load(HINSTANCE p_inst,const TCHAR * p_id) { + release(); + SetLastError(NO_ERROR); + m_accel = LoadAccelerators(p_inst,p_id); + if (m_accel == NULL) { + throw exception_win32(GetLastError()); + } +} + +void win32_accelerator::release() { + if (m_accel != NULL) { + DestroyAcceleratorTable(m_accel); + m_accel = NULL; + } +} + +#endif // #ifdef PFC_WINDOWS_DESKTOP_APP + +void uSleepSeconds(double p_time,bool p_alertable) { + SleepEx(win32_event::g_calculate_wait_time(p_time),p_alertable ? TRUE : FALSE); +} + + +#ifdef PFC_WINDOWS_DESKTOP_APP + +WORD GetWindowsVersionCode() throw() { + const DWORD ver = GetVersion(); + return (WORD)HIBYTE(LOWORD(ver)) | ((WORD)LOBYTE(LOWORD(ver)) << 8); +} + + +namespace pfc { + bool isShiftKeyPressed() { + return IsKeyPressed(VK_SHIFT); + } + bool isCtrlKeyPressed() { + return IsKeyPressed(VK_CONTROL); + } + bool isAltKeyPressed() { + return IsKeyPressed(VK_MENU); + } + + void winSetThreadDescription(HANDLE hThread, const wchar_t * desc) { +#if _WIN32_WINNT >= 0xA00 + SetThreadDescription(hThread, desc); +#else + auto proc = GetProcAddress(GetModuleHandle(L"KernelBase.dll"), "SetThreadDescription"); + if (proc == nullptr) { + proc = GetProcAddress(GetModuleHandle(L"kernel32.dll"), "SetThreadDescription"); + } + if (proc != nullptr) { + typedef HRESULT(__stdcall * pSetThreadDescription_t)(HANDLE hThread, PCWSTR lpThreadDescription); + auto proc2 = reinterpret_cast(proc); + proc2(hThread, desc); + } +#endif + } + pfc::string8 format_window(HWND wnd) { + pfc::string_formatter ret; + ret << "0x" << format_hex( (size_t)wnd ); + auto title = getWindowText(wnd); + if (title.length() > 0) { + ret << " [" << title << "]"; + } + return ret; + } + +#define _(X) {X, #X} + struct winStyle_t { + DWORD v; const char * n; + }; + static const winStyle_t winStyles[] = { + _(WS_POPUP), _(WS_CHILD), _(WS_MINIMIZE), _(WS_VISIBLE), + _(WS_DISABLED), _(WS_CLIPSIBLINGS), _(WS_CLIPCHILDREN), _(WS_MAXIMIZE), + _(WS_BORDER), _(WS_DLGFRAME), _(WS_VSCROLL), _(WS_HSCROLL), + _(WS_SYSMENU), _(WS_THICKFRAME), _(WS_GROUP), _(WS_TABSTOP), + _(WS_MINIMIZEBOX), _(WS_MAXIMIZEBOX) + }; + + pfc::string8 format_windowStyle(DWORD style) { + pfc::string_formatter ret; + ret << "0x" << format_hex( style, 8 ); + if (style != 0) { + pfc::string_formatter label; + for (auto& s : winStyles) if (style & s.v) { + if ( label.length() > 0 ) label << "|"; + label << s.n; + } + if (label.length() > 0) { + ret << " [" << label << "]"; + } + } + return ret; + } +} + +#else +// If unknown / not available on this architecture, return false always +namespace pfc { + bool isShiftKeyPressed() { + return false; + } + bool isCtrlKeyPressed() { + return false; + } + bool isAltKeyPressed() { + return false; + } +} + +#endif // #ifdef PFC_WINDOWS_DESKTOP_APP + +namespace pfc { + void winSleep( double seconds ) { + DWORD ms = INFINITE; + if (seconds > 0) { + ms = rint32(seconds * 1000); + if (ms < 1) ms = 1; + } else if (seconds == 0) { + ms = 0; + } + Sleep(ms); + } + void sleepSeconds(double seconds) { + winSleep(seconds); + } + void yield() { + Sleep(1); + } + + static pfc::string8 winUnicodeNormalize(const char* str, NORM_FORM form) { + pfc::string8 ret; + if (str != nullptr && *str != 0) { + auto w = wideFromUTF8(str); + int needed = NormalizeString(form, w, -1, nullptr, 0); + if (needed > 0) { + pfc::array_t buf; buf.resize(needed); + int status = NormalizeString(form, w, -1, buf.get_ptr(), needed); + if (status > 0) { + ret = utf8FromWide(buf.get_ptr()); + } + } + } + return ret; + } + pfc::string8 unicodeNormalizeD(const char* str) { + return winUnicodeNormalize(str, NormalizationD); + } + pfc::string8 unicodeNormalizeC(const char* str) { + return winUnicodeNormalize(str, NormalizationC); + } + int winNaturalSortCompare(const char* s1, const char* s2) { + int ret = winNaturalSortCompareI(s1, s2); + if (ret == 0) ret = strcmp(s1, s2); + return ret; + } + int winNaturalSortCompare(const wchar_t* s1, const wchar_t* s2) { + int ret = winNaturalSortCompareI(s1, s2); + if (ret == 0) ret = wcscmp(s1, s2); + return ret; + } + int winNaturalSortCompareI(const char* s1, const char* s2) { + return winNaturalSortCompareI(wideFromUTF8(s1), wideFromUTF8(s2)); + } + int winNaturalSortCompareI(const wchar_t* s1, const wchar_t* s2) { + return StrCmpLogicalW(s1, s2); + } + +#ifndef PFC_SORTSTRING_GENERIC + sortString_t makeSortString(const char* in) { + auto out = std::make_unique(pfc::stringcvt::estimate_utf8_to_wide(in)); + pfc::stringcvt::convert_utf8_to_wide_unchecked(out.get(), in); + return out; + } + sortString_t makeSortString(const wchar_t* in) { + size_t l = wcslen(in) + 1; + auto out = std::make_unique(l+1); + memcpy(out.get(), in, sizeof(wchar_t) * l); + return out; + } + int sortStringCompare(sortString_t const& s1, sortString_t const& s2) { + return winNaturalSortCompare(s1.get(), s2.get()); + } + int sortStringCompareI(sortString_t const& s1, sortString_t const& s2) { + return winNaturalSortCompareI(s1.get(), s2.get()); + } +#endif +} + + +#endif // _WIN32 diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/pfc/win-objects.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/win-objects.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,348 @@ +#pragma once + +#include "ref_counter.h" + +namespace pfc { + BOOL winFormatSystemErrorMessage(pfc::string_base & p_out,DWORD p_code); + + // Prefix filesystem paths with \\?\ and \\?\UNC where appropriate. + void winPrefixPath(pfc::string_base & out, const char * p_path); + // Reverse winPrefixPath + void winUnPrefixPath(pfc::string_base & out, const char * p_path); + + string8 winPrefixPath( const char * in ); + string8 winUnPrefixPath( const char * in ); + + class LastErrorRevertScope { + public: + LastErrorRevertScope() : m_val(GetLastError()) {} + ~LastErrorRevertScope() { SetLastError(m_val); } + + private: + const DWORD m_val; + }; + + string8 getWindowText(HWND wnd); + void setWindowText(HWND wnd, const char * txt); + string8 getWindowClassName( HWND wnd ); + HWND findOwningPopup(HWND wnd); +} + +pfc::string8 format_win32_error(DWORD code); +pfc::string8 format_hresult(HRESULT code); +pfc::string8 format_hresult(HRESULT code, const char * msgOverride); + +class exception_win32 : public std::exception { +public: + exception_win32(DWORD p_code) : std::exception(format_win32_error(p_code)), m_code(p_code) {} + DWORD get_code() const {return m_code;} +private: + DWORD m_code; +}; + +#ifdef PFC_WINDOWS_DESKTOP_APP + +void uAddWindowStyle(HWND p_wnd,LONG p_style); +void uRemoveWindowStyle(HWND p_wnd,LONG p_style); +void uAddWindowExStyle(HWND p_wnd,LONG p_style); +void uRemoveWindowExStyle(HWND p_wnd,LONG p_style); +unsigned MapDialogWidth(HWND p_dialog,unsigned p_value); +bool IsKeyPressed(unsigned vk); + +//! Returns current modifier keys pressed, using win32 MOD_* flags. +unsigned GetHotkeyModifierFlags(); + +class CClipboardOpenScope { +public: + CClipboardOpenScope() : m_open(false) {} + ~CClipboardOpenScope() {Close();} + bool Open(HWND p_owner); + void Close(); +private: + bool m_open; + + PFC_CLASS_NOT_COPYABLE_EX(CClipboardOpenScope) +}; + +class CGlobalLockScope { +public: + CGlobalLockScope(HGLOBAL p_handle); + ~CGlobalLockScope(); + void * GetPtr() const {return m_ptr;} + t_size GetSize() const {return GlobalSize(m_handle);} +private: + void * m_ptr; + HGLOBAL m_handle; + + PFC_CLASS_NOT_COPYABLE_EX(CGlobalLockScope) +}; + +template class CGlobalLockScopeT { +public: + CGlobalLockScopeT(HGLOBAL handle) : m_scope(handle) {} + TItem * GetPtr() const {return reinterpret_cast(m_scope.GetPtr());} + t_size GetSize() const { + const t_size val = m_scope.GetSize(); + PFC_ASSERT( val % sizeof(TItem) == 0 ); + return val / sizeof(TItem); + } +private: + CGlobalLockScope m_scope; +}; + +//! Resigns active window status passing it to the parent window, if wnd or a child popup of is active. \n +//! Use this to mitigate Windows 10 1809 active window handling bugs - call prior to DestroyWindow() +void ResignActiveWindow(HWND wnd); +//! Is point inside a control? +bool IsPointInsideControl(const POINT& pt, HWND wnd); +//! Is a control inside window? Also returns true if child==parent. +bool IsWindowChildOf(HWND child, HWND parent); +//! Is window a child (popup or control) of window? Also returns true if child==parent. +bool IsPopupWindowChildOf(HWND child, HWND parent); + +class win32_menu { +public: + win32_menu(HMENU p_initval) : m_menu(p_initval) {} + win32_menu() : m_menu(NULL) {} + ~win32_menu() {release();} + void release(); + void set(HMENU p_menu) {release(); m_menu = p_menu;} + void create_popup(); + HMENU get() const {return m_menu;} + HMENU detach() {return pfc::replace_t(m_menu,(HMENU)NULL);} + + bool is_valid() const {return m_menu != NULL;} +private: + win32_menu(const win32_menu &) = delete; + void operator=(const win32_menu &) = delete; + + HMENU m_menu; +}; + +#endif + +class win32_event { +public: + win32_event() : m_handle(NULL) {} + ~win32_event() {release();} + + void create(bool p_manualreset,bool p_initialstate); + + void set(HANDLE p_handle) {release(); m_handle = p_handle;} + HANDLE get() const {return m_handle;} + HANDLE get_handle() const {return m_handle;} + HANDLE detach() {return pfc::replace_t(m_handle,(HANDLE)NULL);} + bool is_valid() const {return m_handle != NULL;} + + void release(); + + //! Returns true when signaled, false on timeout + bool wait_for(double p_timeout_seconds) {return g_wait_for(get(),p_timeout_seconds);} + void wait() { wait_for(-1); } + void wait_and_clear() { wait(); set_state(false); } + + static DWORD g_calculate_wait_time(double p_seconds); + + //! Returns true when signaled, false on timeout + static bool g_wait_for(HANDLE p_event,double p_timeout_seconds); + + void set_state(bool p_state); + bool is_set() { return wait_for(0); } + + // Two-wait event functions, return 0 on timeout, 1 on evt1 set, 2 on evt2 set + static int g_twoEventWait( win32_event & ev1, win32_event & ev2, double timeout ); + static int g_twoEventWait( HANDLE ev1, HANDLE ev2, double timeout ); + + // Multi-wait. Returns SIZE_MAX on timeout, 0 based event index if either event becomes set. + static size_t g_multiWait(const HANDLE* events, size_t count, double timeout); + static size_t g_multiWait( std::initializer_list const & arg, double timeout ); +private: + win32_event(const win32_event&) = delete; + void operator=(const win32_event &) = delete; + + HANDLE m_handle; +}; + +namespace pfc { + typedef HANDLE eventHandle_t; + + static constexpr eventHandle_t eventInvalid = NULL; + + class event : public win32_event { + public: + event(bool initial = false) { create(true, initial); } + + HANDLE get_handle() const { return win32_event::get(); } + }; +} + +void uSleepSeconds(double p_time,bool p_alertable); + +#ifdef PFC_WINDOWS_DESKTOP_APP + +class win32_icon { +public: + win32_icon(HICON p_initval) : m_icon(p_initval) {} + win32_icon() : m_icon(NULL) {} + ~win32_icon() {release();} + + void release(); + + void set(HICON p_icon) {release(); m_icon = p_icon;} + HICON get() const {return m_icon;} + HICON detach() {return pfc::replace_t(m_icon,(HICON)NULL);} + + bool is_valid() const {return m_icon != NULL;} + +private: + win32_icon(const win32_icon&) = delete; + const win32_icon & operator=(const win32_icon &) = delete; + + HICON m_icon; +}; + +class win32_accelerator { +public: + win32_accelerator() : m_accel(NULL) {} + ~win32_accelerator() {release();} + HACCEL get() const {return m_accel;} + + void load(HINSTANCE p_inst,const TCHAR * p_id); + void release(); +private: + HACCEL m_accel; + PFC_CLASS_NOT_COPYABLE_EX(win32_accelerator); +}; + +class SelectObjectScope { +public: + SelectObjectScope(HDC p_dc,HGDIOBJ p_obj) throw() : m_dc(p_dc), m_obj(SelectObject(p_dc,p_obj)) {} + ~SelectObjectScope() throw() {SelectObject(m_dc,m_obj);} +private: + PFC_CLASS_NOT_COPYABLE_EX(SelectObjectScope) + HDC m_dc; + HGDIOBJ m_obj; +}; + +// WARNING: Windows is known to truncate the coordinates to float32 internally instead of retaining original int +// With large values, this OffsetWindowOrgEx behaves erratically +class OffsetWindowOrgScope { +public: + OffsetWindowOrgScope(HDC dc, const POINT & pt) throw() : m_dc(dc), m_pt(pt) { + OffsetWindowOrgEx(m_dc, m_pt.x, m_pt.y, NULL); + } + ~OffsetWindowOrgScope() throw() { + OffsetWindowOrgEx(m_dc, -m_pt.x, -m_pt.y, NULL); + } + +private: + const HDC m_dc; + const POINT m_pt; +}; +class DCStateScope { +public: + DCStateScope(HDC p_dc) throw() : m_dc(p_dc) { + m_state = SaveDC(m_dc); + } + ~DCStateScope() throw() { + RestoreDC(m_dc,m_state); + } +private: + const HDC m_dc; + int m_state; +}; +#endif // #ifdef PFC_WINDOWS_DESKTOP_APP + +class exception_com : public std::exception { +public: + exception_com(HRESULT p_code) : std::exception(format_hresult(p_code)), m_code(p_code) {} + exception_com(HRESULT p_code, const char * msg) : std::exception(format_hresult(p_code, msg)), m_code(p_code) {} + HRESULT get_code() const {return m_code;} +private: + HRESULT m_code; +}; + +#ifdef PFC_WINDOWS_DESKTOP_APP + +// Same format as _WIN32_WINNT macro. +WORD GetWindowsVersionCode() throw(); + +#endif + +//! Simple implementation of a COM reference counter. The initial reference count is zero, so it can be used with pfc::com_ptr_t<> with plain operator=/constructor rather than attach(). +template class ImplementCOMRefCounter : public TBase { +public: + template ImplementCOMRefCounter(arg_t && ... arg) : TBase(std::forward(arg) ...) {} + + ULONG STDMETHODCALLTYPE AddRef() override { + return ++m_refcounter; + } + ULONG STDMETHODCALLTYPE Release() override { + long val = --m_refcounter; + if (val == 0) delete this; + return val; + } +protected: + virtual ~ImplementCOMRefCounter() {} +private: + pfc::refcounter m_refcounter; +}; + + + +template +class CoTaskMemObject { +public: + CoTaskMemObject() : m_ptr() {} + + ~CoTaskMemObject() {CoTaskMemFree(m_ptr);} + void Reset() {CoTaskMemFree(pfc::replace_null_t(m_ptr));} + TPtr * Receive() {Reset(); return &m_ptr;} + + TPtr m_ptr; + PFC_CLASS_NOT_COPYABLE(CoTaskMemObject, CoTaskMemObject ); +}; + + +namespace pfc { + bool isShiftKeyPressed(); + bool isCtrlKeyPressed(); + bool isAltKeyPressed(); + + class winHandle { + public: + winHandle(HANDLE h_ = INVALID_HANDLE_VALUE) : h(h_) {} + ~winHandle() { Close(); } + void Close() { + if (h != INVALID_HANDLE_VALUE && h != NULL ) { CloseHandle(h); h = INVALID_HANDLE_VALUE; } + } + + void Attach(HANDLE h_) { Close(); h = h_; } + HANDLE Detach() { HANDLE t = h; h = INVALID_HANDLE_VALUE; return t; } + + HANDLE Get() const { return h; } + operator HANDLE() const { return h; } + + HANDLE h; + private: + winHandle(const winHandle&) = delete; + void operator=(const winHandle&) = delete; + }; + + void winSleep( double seconds ); + void sleepSeconds(double seconds); + void yield(); + +#ifdef PFC_WINDOWS_DESKTOP_APP + void winSetThreadDescription(HANDLE hThread, const wchar_t * desc); + + pfc::string8 format_window(HWND wnd); + pfc::string8 format_windowStyle(DWORD); +#endif // PFC_WINDOWS_DESKTOP_APP + + int winNaturalSortCompare(const char* s1, const char* s2); + int winNaturalSortCompare(const wchar_t* s1, const wchar_t* s2); + int winNaturalSortCompareI(const char* s1, const char* s2); + int winNaturalSortCompareI(const wchar_t* s1, const wchar_t* s2); + +} diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/sdk-license.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/sdk-license.txt Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,12 @@ +foobar2000 2.x SDK +Copyright (c) 2002-2024, Peter Pawlowski +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. +Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Note that separate less restrictive licenses apply to the included 'pfc' and 'libPPUI' libraries. See license files included in respective folders for details. diff -r e9bb126753e7 -r 20d02a178406 foosdk/sdk/sdk-readme.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/sdk-readme.html Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,19 @@ + + + + + foobar2000 SDK Readme + + +

+foobar2000 SDK, version 2024-12-02 +

+

+Documentation:
+SDK Change Log
+foobar2000 Development Overview +

+ + diff -r e9bb126753e7 -r 20d02a178406 foosdk/wtl/Include/atlapp.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/wtl/Include/atlapp.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,1216 @@ +// Windows Template Library - WTL version 10.0 +// Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. +// +// This file is a part of the Windows Template Library. +// The use and distribution terms for this software are covered by the +// Microsoft Public License (http://opensource.org/licenses/MS-PL) +// which can be found in the file MS-PL.txt at the root folder. + +#ifndef __ATLAPP_H__ +#define __ATLAPP_H__ + +#pragma once + +#ifndef __cplusplus + #error WTL requires C++ compilation (use a .cpp suffix) +#endif + +#ifndef __ATLBASE_H__ + #error atlapp.h requires atlbase.h to be included first +#endif + +#ifdef _WIN32_WCE + #error WTL10 doesn't support Windows CE +#endif + +#ifdef _ATL_NO_COMMODULE + #error WTL requires that _ATL_NO_COMMODULE is not defined +#endif + +#ifdef _ATL_NO_WIN_SUPPORT + #error WTL requires that _ATL_NO_WIN_SUPPORT is not defined +#endif + +#if (_MSC_VER < 1400) + #error WTL10 requires C++ compiler version 14 (Visual C++ 2005) or higher +#endif + +#if (WINVER < 0x0501) + #error WTL requires WINVER >= 0x0501 +#endif + +#if (_WIN32_WINNT < 0x0501) + #error WTL requires _WIN32_WINNT >= 0x0501 +#endif + +#if (_WIN32_IE < 0x0600) + #error WTL requires _WIN32_IE >= 0x0600 +#endif + +#if (_ATL_VER < 0x0800) + #error WTL10 requires ATL version 8 or higher +#endif + +#ifdef _ATL_MIN_CRT + #error WTL10 doesn't support _ATL_MIN_CRT +#endif + +#ifdef _ATL_NO_MSIMG + #error WTL10 doesn't support _ATL_NO_MSIMG +#endif + +#include +#ifdef _MT + #include // for _beginthreadex +#endif + +#include +#pragma comment(lib, "comctl32.lib") + +#include +#include + +// Check for VS2005 without newer WinSDK +#if (_MSC_VER == 1400) && !defined(RB_GETEXTENDEDSTYLE) + #error WTL10 requires WinSDK 6.0 ot higher +#endif + +#include +#pragma comment(lib, "uxtheme.lib") + +#if defined(_SYSINFOAPI_H_) && defined(NOT_BUILD_WINDOWS_DEPRECATE) + #include +#endif + +#include "atlres.h" + + +/////////////////////////////////////////////////////////////////////////////// +// WTL version number + +#define _WTL_VER 0x1000 // version 10.0 + + +/////////////////////////////////////////////////////////////////////////////// +// Classes in this file: +// +// CMessageFilter +// CIdleHandler +// CMessageLoop +// +// CAppModule +// CServerAppModule +// +// Global functions: +// AtlInitCommonControls() +// AtlGetDefaultGuiFont() +// AtlCreateControlFont() +// AtlCreateBoldFont() +// AtlGetStringPtr() + + +/////////////////////////////////////////////////////////////////////////////// +// Miscellaneous global support + +// define useful macros from winuser.h +#ifndef IS_INTRESOURCE + #define IS_INTRESOURCE(_r) (((ULONG_PTR)(_r) >> 16) == 0) +#endif // IS_INTRESOURCE + +// protect template members from windowsx.h macros +#ifdef _INC_WINDOWSX + #undef SubclassWindow +#endif // _INC_WINDOWSX + +// define useful macros from windowsx.h +#ifndef GET_X_LPARAM + #define GET_X_LPARAM(lParam) ((int)(short)LOWORD(lParam)) +#endif +#ifndef GET_Y_LPARAM + #define GET_Y_LPARAM(lParam) ((int)(short)HIWORD(lParam)) +#endif + +// Dummy structs for compiling with /CLR +#ifdef _MANAGED + __if_not_exists(_IMAGELIST::_IMAGELIST) { struct _IMAGELIST { }; } + __if_not_exists(_TREEITEM::_TREEITEM) { struct _TREEITEM { }; } + __if_not_exists(_PSP::_PSP) { struct _PSP { }; } +#endif + +// Forward declaration for ATL11 fix +#if (_ATL_VER >= 0x0B00) + namespace ATL { HRESULT AtlGetCommCtrlVersion(LPDWORD pdwMajor, LPDWORD pdwMinor); } +#endif + +#ifndef WM_MOUSEHWHEEL + #define WM_MOUSEHWHEEL 0x020E +#endif + +// Used for stack allocations with ATL::CTempBuffer +#ifndef _WTL_STACK_ALLOC_THRESHOLD + #define _WTL_STACK_ALLOC_THRESHOLD 512 +#endif + + +namespace WTL +{ + +DECLARE_TRACE_CATEGORY(atlTraceUI) +#ifdef _DEBUG + __declspec(selectany) ATL::CTraceCategory atlTraceUI(_T("atlTraceUI")); +#endif // _DEBUG + +// Common Controls initialization helper +inline BOOL AtlInitCommonControls(DWORD dwFlags) +{ + INITCOMMONCONTROLSEX iccx = { sizeof(INITCOMMONCONTROLSEX), dwFlags }; + BOOL bRet = ::InitCommonControlsEx(&iccx); + ATLASSERT(bRet); + return bRet; +} + +// Default GUI font helper - "MS Shell Dlg" stock font +inline HFONT AtlGetDefaultGuiFont() +{ + return (HFONT)::GetStockObject(DEFAULT_GUI_FONT); +} + +// Control font helper - default font for controls not in a dialog +// (NOTE: Caller owns the font, and should destroy it when it's no longer needed) +inline HFONT AtlCreateControlFont() +{ + LOGFONT lf = {}; + ATLVERIFY(::SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(LOGFONT), &lf, 0) != FALSE); + HFONT hFont = ::CreateFontIndirect(&lf); + ATLASSERT(hFont != NULL); + return hFont; +} + +// Bold font helper +// (NOTE: Caller owns the font, and should destroy it when it's no longer needed) +inline HFONT AtlCreateBoldFont(HFONT hFont = NULL) +{ + LOGFONT lf = {}; + if(hFont == NULL) + ATLVERIFY(::SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(LOGFONT), &lf, 0) != FALSE); + else + ATLVERIFY(::GetObject(hFont, sizeof(LOGFONT), &lf) == sizeof(LOGFONT)); + lf.lfWeight = FW_BOLD; + HFONT hFontBold = ::CreateFontIndirect(&lf); + ATLASSERT(hFontBold != NULL); + return hFontBold; +} + +// Resource string pointer +inline LPCWSTR AtlGetStringPtr(UINT uID, int* pch = NULL) +{ + LPCWSTR lpstr = NULL; + int nRet = ::LoadStringW(ATL::_AtlBaseModule.GetResourceInstance(), uID, (LPWSTR)&lpstr, 0); + if(pch != NULL) + *pch = nRet; + return lpstr; +} + + +/////////////////////////////////////////////////////////////////////////////// +// RunTimeHelper - helper functions for Windows version and structure sizes + +#ifndef _WTL_NO_RUNTIME_STRUCT_SIZE + +#ifndef _SIZEOF_STRUCT + #define _SIZEOF_STRUCT(structname, member) (((int)((LPBYTE)(&((structname*)0)->member) - ((LPBYTE)((structname*)0)))) + sizeof(((structname*)0)->member)) +#endif + +#if (_WIN32_WINNT >= 0x0600) && !defined(REBARBANDINFO_V6_SIZE) + #define REBARBANDINFO_V6_SIZE _SIZEOF_STRUCT(REBARBANDINFO, cxHeader) +#endif // (_WIN32_WINNT >= 0x0600) && !defined(REBARBANDINFO_V6_SIZE) + +#if (_WIN32_WINNT >= 0x0600) && !defined(LVGROUP_V5_SIZE) + #define LVGROUP_V5_SIZE _SIZEOF_STRUCT(LVGROUP, uAlign) +#endif // (_WIN32_WINNT >= 0x0600) && !defined(LVGROUP_V5_SIZE) + +#if (_WIN32_WINNT >= 0x0600) && !defined(LVTILEINFO_V5_SIZE) + #define LVTILEINFO_V5_SIZE _SIZEOF_STRUCT(LVTILEINFO, puColumns) +#endif // (_WIN32_WINNT >= 0x0600) && !defined(LVTILEINFO_V5_SIZE) + +#if defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN) && !defined(MCHITTESTINFO_V1_SIZE) + #define MCHITTESTINFO_V1_SIZE _SIZEOF_STRUCT(MCHITTESTINFO, st) +#endif // defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN) && !defined(MCHITTESTINFO_V1_SIZE) + +#if (WINVER >= 0x0600) && !defined(NONCLIENTMETRICS_V1_SIZE) + #define NONCLIENTMETRICS_V1_SIZE _SIZEOF_STRUCT(NONCLIENTMETRICS, lfMessageFont) +#endif // (WINVER >= 0x0600) && !defined(NONCLIENTMETRICS_V1_SIZE) + +#ifndef TTTOOLINFO_V2_SIZE + #define TTTOOLINFO_V2_SIZE _SIZEOF_STRUCT(TTTOOLINFO, lParam) +#endif + +#endif // !_WTL_NO_RUNTIME_STRUCT_SIZE + +namespace RunTimeHelper +{ + inline bool IsCommCtrl6() + { + DWORD dwMajor = 0, dwMinor = 0; + HRESULT hRet = ATL::AtlGetCommCtrlVersion(&dwMajor, &dwMinor); + return (SUCCEEDED(hRet) && (dwMajor >= 6)); + } + + inline bool IsVista() + { +#ifdef _versionhelpers_H_INCLUDED_ + return ::IsWindowsVistaOrGreater(); +#else // !_versionhelpers_H_INCLUDED_ + OSVERSIONINFO ovi = { sizeof(OSVERSIONINFO) }; + BOOL bRet = ::GetVersionEx(&ovi); + return ((bRet != FALSE) && (ovi.dwMajorVersion >= 6)); +#endif // _versionhelpers_H_INCLUDED_ + } + + inline bool IsThemeAvailable() + { + return IsCommCtrl6() && (::IsThemeActive() != FALSE) && (::IsAppThemed() != FALSE); + } + + inline bool IsWin7() + { +#ifdef _versionhelpers_H_INCLUDED_ + return ::IsWindows7OrGreater(); +#else // !_versionhelpers_H_INCLUDED_ + OSVERSIONINFO ovi = { sizeof(OSVERSIONINFO) }; + BOOL bRet = ::GetVersionEx(&ovi); + return ((bRet != FALSE) && ((ovi.dwMajorVersion > 6) || ((ovi.dwMajorVersion == 6) && (ovi.dwMinorVersion >= 1)))); +#endif // _versionhelpers_H_INCLUDED_ + } + + inline bool IsRibbonUIAvailable() + { + static INT iRibbonUI = -1; + +#if defined(NTDDI_WIN7) && (NTDDI_VERSION >= NTDDI_WIN7) + if (iRibbonUI == -1) + { + HMODULE hRibbonDLL = ::LoadLibrary(_T("propsys.dll")); + if (hRibbonDLL != NULL) + { + const GUID CLSID_UIRibbonFramework = { 0x926749fa, 0x2615, 0x4987, { 0x88, 0x45, 0xc3, 0x3e, 0x65, 0xf2, 0xb9, 0x57 } }; + // block - create instance + { + ATL::CComPtr pIUIFramework; + iRibbonUI = SUCCEEDED(pIUIFramework.CoCreateInstance(CLSID_UIRibbonFramework)) ? 1 : 0; + } + ::FreeLibrary(hRibbonDLL); + } + else + { + iRibbonUI = 0; + } + } +#endif // defined(NTDDI_WIN7) && (NTDDI_VERSION >= NTDDI_WIN7) + + return (iRibbonUI == 1); + } + + inline UINT SizeOf_REBARBANDINFO() + { + UINT uSize = sizeof(REBARBANDINFO); +#if !defined(_WTL_NO_RUNTIME_STRUCT_SIZE) && (_WIN32_WINNT >= 0x0600) + if(!(IsVista() && IsCommCtrl6())) + uSize = REBARBANDINFO_V6_SIZE; +#endif // !defined(_WTL_NO_RUNTIME_STRUCT_SIZE) && (_WIN32_WINNT >= 0x0600) + return uSize; + } + + inline UINT SizeOf_LVGROUP() + { + UINT uSize = sizeof(LVGROUP); +#if !defined(_WTL_NO_RUNTIME_STRUCT_SIZE) && (_WIN32_WINNT >= 0x0600) + if(!IsVista()) + uSize = LVGROUP_V5_SIZE; +#endif // !defined(_WTL_NO_RUNTIME_STRUCT_SIZE) && (_WIN32_WINNT >= 0x0600) + return uSize; + } + + inline UINT SizeOf_LVTILEINFO() + { + UINT uSize = sizeof(LVTILEINFO); +#if !defined(_WTL_NO_RUNTIME_STRUCT_SIZE) && (_WIN32_WINNT >= 0x0600) + if(!IsVista()) + uSize = LVTILEINFO_V5_SIZE; +#endif // !defined(_WTL_NO_RUNTIME_STRUCT_SIZE) && (_WIN32_WINNT >= 0x0600) + return uSize; + } + + inline UINT SizeOf_MCHITTESTINFO() + { + UINT uSize = sizeof(MCHITTESTINFO); +#if !defined(_WTL_NO_RUNTIME_STRUCT_SIZE) && defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN) + if(!(IsVista() && IsCommCtrl6())) + uSize = MCHITTESTINFO_V1_SIZE; +#endif // !defined(_WTL_NO_RUNTIME_STRUCT_SIZE) && defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN) + return uSize; + } + + inline UINT SizeOf_NONCLIENTMETRICS() + { + UINT uSize = sizeof(NONCLIENTMETRICS); +#if !defined(_WTL_NO_RUNTIME_STRUCT_SIZE) && (WINVER >= 0x0600) + if(!IsVista()) + uSize = NONCLIENTMETRICS_V1_SIZE; +#endif // !defined(_WTL_NO_RUNTIME_STRUCT_SIZE) && (WINVER >= 0x0600) + return uSize; + } + + inline UINT SizeOf_TOOLINFO() + { + UINT uSize = sizeof(TOOLINFO); +#ifndef _WTL_NO_RUNTIME_STRUCT_SIZE + if(!IsVista()) + uSize = TTTOOLINFO_V2_SIZE; +#endif + return uSize; + } +} // namespace RunTimeHelper + + +/////////////////////////////////////////////////////////////////////////////// +// ModuleHelper - helper functions for ATL (deprecated) + +namespace ModuleHelper +{ + inline HINSTANCE GetModuleInstance() + { + return ATL::_AtlBaseModule.GetModuleInstance(); + } + + inline HINSTANCE GetResourceInstance() + { + return ATL::_AtlBaseModule.GetResourceInstance(); + } + + inline void AddCreateWndData(ATL::_AtlCreateWndData* pData, void* pObject) + { + ATL::_AtlWinModule.AddCreateWndData(pData, pObject); + } + + inline void* ExtractCreateWndData() + { + return ATL::_AtlWinModule.ExtractCreateWndData(); + } +} // namespace ModuleHelper + + +/////////////////////////////////////////////////////////////////////////////// +// SecureHelper - WTL10 requires use of secure functions +// these are here only for compatibility with existing projects + +namespace SecureHelper +{ + inline void strcpyA_x(char* lpstrDest, size_t cchDest, const char* lpstrSrc) + { + ATL::Checked::strcpy_s(lpstrDest, cchDest, lpstrSrc); + } + + inline void strcpyW_x(wchar_t* lpstrDest, size_t cchDest, const wchar_t* lpstrSrc) + { + ATL::Checked::wcscpy_s(lpstrDest, cchDest, lpstrSrc); + } + + inline void strcpy_x(LPTSTR lpstrDest, size_t cchDest, LPCTSTR lpstrSrc) + { +#ifdef _UNICODE + strcpyW_x(lpstrDest, cchDest, lpstrSrc); +#else + strcpyA_x(lpstrDest, cchDest, lpstrSrc); +#endif + } + + inline errno_t strncpyA_x(char* lpstrDest, size_t cchDest, const char* lpstrSrc, size_t cchCount) + { + return ATL::Checked::strncpy_s(lpstrDest, cchDest, lpstrSrc, cchCount); + } + + inline errno_t strncpyW_x(wchar_t* lpstrDest, size_t cchDest, const wchar_t* lpstrSrc, size_t cchCount) + { + return ATL::Checked::wcsncpy_s(lpstrDest, cchDest, lpstrSrc, cchCount); + } + + inline errno_t strncpy_x(LPTSTR lpstrDest, size_t cchDest, LPCTSTR lpstrSrc, size_t cchCount) + { +#ifdef _UNICODE + return strncpyW_x(lpstrDest, cchDest, lpstrSrc, cchCount); +#else + return strncpyA_x(lpstrDest, cchDest, lpstrSrc, cchCount); +#endif + } + + inline void strcatA_x(char* lpstrDest, size_t cchDest, const char* lpstrSrc) + { + ATL::Checked::strcat_s(lpstrDest, cchDest, lpstrSrc); + } + + inline void strcatW_x(wchar_t* lpstrDest, size_t cchDest, const wchar_t* lpstrSrc) + { + ATL::Checked::wcscat_s(lpstrDest, cchDest, lpstrSrc); + } + + inline void strcat_x(LPTSTR lpstrDest, size_t cchDest, LPCTSTR lpstrSrc) + { +#ifdef _UNICODE + strcatW_x(lpstrDest, cchDest, lpstrSrc); +#else + strcatA_x(lpstrDest, cchDest, lpstrSrc); +#endif + } + + inline void memcpy_x(void* pDest, size_t cbDest, const void* pSrc, size_t cbSrc) + { + ATL::Checked::memcpy_s(pDest, cbDest, pSrc, cbSrc); + } + + inline void memmove_x(void* pDest, size_t cbDest, const void* pSrc, size_t cbSrc) + { + ATL::Checked::memmove_s(pDest, cbDest, pSrc, cbSrc); + } + + inline int vsprintf_x(LPTSTR lpstrBuff, size_t cchBuff, LPCTSTR lpstrFormat, va_list args) + { + return _vstprintf_s(lpstrBuff, cchBuff, lpstrFormat, args); + } + + inline int wvsprintf_x(LPTSTR lpstrBuff, size_t cchBuff, LPCTSTR lpstrFormat, va_list args) + { + return _vstprintf_s(lpstrBuff, cchBuff, lpstrFormat, args); + } + + inline int sprintf_x(LPTSTR lpstrBuff, size_t cchBuff, LPCTSTR lpstrFormat, ...) + { + va_list args; + va_start(args, lpstrFormat); + int nRes = vsprintf_x(lpstrBuff, cchBuff, lpstrFormat, args); + va_end(args); + return nRes; + } + + inline int wsprintf_x(LPTSTR lpstrBuff, size_t cchBuff, LPCTSTR lpstrFormat, ...) + { + va_list args; + va_start(args, lpstrFormat); + int nRes = wvsprintf_x(lpstrBuff, cchBuff, lpstrFormat, args); + va_end(args); + return nRes; + } +} // namespace SecureHelper + + +/////////////////////////////////////////////////////////////////////////////// +// MinCrtHelper - WTL10 doesn't support _ATL_MIN_CRT, +// these are here only for compatibility with existing projects + +namespace MinCrtHelper +{ + inline int _isspace(TCHAR ch) + { + return _istspace(ch); + } + + inline int _isdigit(TCHAR ch) + { + return _istdigit(ch); + } + + inline int _atoi(LPCTSTR str) + { + return _ttoi(str); + } + + inline LPCTSTR _strrchr(LPCTSTR str, TCHAR ch) + { + return _tcsrchr(str, ch); + } + + inline LPTSTR _strrchr(LPTSTR str, TCHAR ch) + { + return _tcsrchr(str, ch); + } +} // namespace MinCrtHelper + + +/////////////////////////////////////////////////////////////////////////////// +// GenericWndClass - generic window class usable for subclassing + +// Use in dialog templates to specify a placeholder to be subclassed +// Specify as a custom control with class name WTL_GenericWindow +// Call Rregister() before creating dialog (for example, in WinMain) +namespace GenericWndClass +{ + inline LPCTSTR GetName() + { + return _T("WTL_GenericWindow"); + } + + inline ATOM Register() + { + WNDCLASSEX wc = { sizeof(WNDCLASSEX) }; + wc.lpfnWndProc = ::DefWindowProc; + wc.hInstance = ModuleHelper::GetModuleInstance(); + wc.hCursor = ::LoadCursor(NULL, IDC_ARROW); + wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); + wc.lpszClassName = GetName(); + ATOM atom = ::RegisterClassEx(&wc); + ATLASSERT(atom != 0); + return atom; + } + + inline BOOL Unregister() // only needed for DLLs or tmp use + { + return ::UnregisterClass(GetName(), ModuleHelper::GetModuleInstance()); + } +} // namespace GenericWndClass + + +/////////////////////////////////////////////////////////////////////////////// +// CMessageFilter - Interface for message filter support + +class CMessageFilter +{ +public: + virtual BOOL PreTranslateMessage(MSG* pMsg) = 0; +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CIdleHandler - Interface for idle processing + +class CIdleHandler +{ +public: + virtual BOOL OnIdle() = 0; +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CMessageLoop - message loop implementation + +class CMessageLoop +{ +public: + ATL::CSimpleArray m_aMsgFilter; + ATL::CSimpleArray m_aIdleHandler; + MSG m_msg; + + CMessageLoop() + { } + + virtual ~CMessageLoop() + { } + +// Message filter operations + BOOL AddMessageFilter(CMessageFilter* pMessageFilter) + { + return m_aMsgFilter.Add(pMessageFilter); + } + + BOOL RemoveMessageFilter(CMessageFilter* pMessageFilter) + { + return m_aMsgFilter.Remove(pMessageFilter); + } + +// Idle handler operations + BOOL AddIdleHandler(CIdleHandler* pIdleHandler) + { + return m_aIdleHandler.Add(pIdleHandler); + } + + BOOL RemoveIdleHandler(CIdleHandler* pIdleHandler) + { + return m_aIdleHandler.Remove(pIdleHandler); + } + +// message loop + int Run() + { + BOOL bDoIdle = TRUE; + int nIdleCount = 0; + BOOL bRet; + + for(;;) + { + while(bDoIdle && !::PeekMessage(&m_msg, NULL, 0, 0, PM_NOREMOVE)) + { + if(!OnIdle(nIdleCount++)) + bDoIdle = FALSE; + } + + bRet = ::GetMessage(&m_msg, NULL, 0, 0); + + if(bRet == -1) + { + ATLTRACE2(atlTraceUI, 0, _T("::GetMessage returned -1 (error)\n")); + continue; // error, don't process + } + else if(!bRet) + { + ATLTRACE2(atlTraceUI, 0, _T("CMessageLoop::Run - exiting\n")); + break; // WM_QUIT, exit message loop + } + + if(!PreTranslateMessage(&m_msg)) + { + ::TranslateMessage(&m_msg); + ::DispatchMessage(&m_msg); + } + + if(IsIdleMessage(&m_msg)) + { + bDoIdle = TRUE; + nIdleCount = 0; + } + } + + return (int)m_msg.wParam; + } + + static BOOL IsIdleMessage(MSG* pMsg) + { + // These messages should NOT cause idle processing + switch(pMsg->message) + { + case WM_MOUSEMOVE: + case WM_NCMOUSEMOVE: + case WM_PAINT: + case 0x0118: // WM_SYSTIMER (caret blink) + return FALSE; + } + + return TRUE; + } + +// Overrideables + // Override to change message filtering + virtual BOOL PreTranslateMessage(MSG* pMsg) + { + // loop backwards + for(int i = m_aMsgFilter.GetSize() - 1; i >= 0; i--) + { + CMessageFilter* pMessageFilter = m_aMsgFilter[i]; + if((pMessageFilter != NULL) && pMessageFilter->PreTranslateMessage(pMsg)) + return TRUE; + } + return FALSE; // not translated + } + + // override to change idle processing + virtual BOOL OnIdle(int /*nIdleCount*/) + { + for(int i = 0; i < m_aIdleHandler.GetSize(); i++) + { + CIdleHandler* pIdleHandler = m_aIdleHandler[i]; + if(pIdleHandler != NULL) + pIdleHandler->OnIdle(); + } + return FALSE; // don't continue + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CStaticDataInitCriticalSectionLock and CWindowCreateCriticalSectionLock +// internal classes to manage critical sections for ATL (deprecated) + +class CStaticDataInitCriticalSectionLock +{ +public: + ATL::CComCritSecLock m_cslock; + + CStaticDataInitCriticalSectionLock() : m_cslock(ATL::_pAtlModule->m_csStaticDataInitAndTypeInfo, false) + { } + + HRESULT Lock() + { + return m_cslock.Lock(); + } + + void Unlock() + { + m_cslock.Unlock(); + } +}; + + +class CWindowCreateCriticalSectionLock +{ +public: + ATL::CComCritSecLock m_cslock; + + CWindowCreateCriticalSectionLock() : m_cslock(ATL::_AtlWinModule.m_csWindowCreate, false) + { } + + HRESULT Lock() + { + return m_cslock.Lock(); + } + + void Unlock() + { + m_cslock.Unlock(); + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CAppModule - module class for an application + +#if (_MSC_VER == 1400) // VS2005 + #pragma warning(push) + #pragma warning(disable : 4244) + #pragma warning(disable : 4312) +#endif + +class CAppModule : public ATL::CComModule +{ +public: + DWORD m_dwMainThreadID; + ATL::CSimpleMap* m_pMsgLoopMap; + ATL::CSimpleArray* m_pSettingChangeNotify; + +// Overrides of CComModule::Init and Term + HRESULT Init(ATL::_ATL_OBJMAP_ENTRY* pObjMap, HINSTANCE hInstance, const GUID* pLibID = NULL) + { + HRESULT hRet = CComModule::Init(pObjMap, hInstance, pLibID); + if(FAILED(hRet)) + return hRet; + + m_dwMainThreadID = ::GetCurrentThreadId(); + typedef ATL::CSimpleMap _mapClass; + m_pMsgLoopMap = NULL; + ATLTRY(m_pMsgLoopMap = new _mapClass); + if(m_pMsgLoopMap == NULL) + return E_OUTOFMEMORY; + m_pSettingChangeNotify = NULL; + + return hRet; + } + + void Term() + { + TermSettingChangeNotify(); + delete m_pMsgLoopMap; + CComModule::Term(); + } + +// Message loop map methods + BOOL AddMessageLoop(CMessageLoop* pMsgLoop) + { + CStaticDataInitCriticalSectionLock lock; + if(FAILED(lock.Lock())) + { + ATLTRACE2(atlTraceUI, 0, _T("ERROR : Unable to lock critical section in CAppModule::AddMessageLoop.\n")); + ATLASSERT(FALSE); + return FALSE; + } + + ATLASSERT(pMsgLoop != NULL); + ATLASSERT(m_pMsgLoopMap->Lookup(::GetCurrentThreadId()) == NULL); // not in map yet + + BOOL bRet = m_pMsgLoopMap->Add(::GetCurrentThreadId(), pMsgLoop); + + lock.Unlock(); + + return bRet; + } + + BOOL RemoveMessageLoop() + { + CStaticDataInitCriticalSectionLock lock; + if(FAILED(lock.Lock())) + { + ATLTRACE2(atlTraceUI, 0, _T("ERROR : Unable to lock critical section in CAppModule::RemoveMessageLoop.\n")); + ATLASSERT(FALSE); + return FALSE; + } + + BOOL bRet = m_pMsgLoopMap->Remove(::GetCurrentThreadId()); + + lock.Unlock(); + + return bRet; + } + + CMessageLoop* GetMessageLoop(DWORD dwThreadID = ::GetCurrentThreadId()) const + { + CStaticDataInitCriticalSectionLock lock; + if(FAILED(lock.Lock())) + { + ATLTRACE2(atlTraceUI, 0, _T("ERROR : Unable to lock critical section in CAppModule::GetMessageLoop.\n")); + ATLASSERT(FALSE); + return NULL; + } + + CMessageLoop* pLoop = m_pMsgLoopMap->Lookup(dwThreadID); + + lock.Unlock(); + + return pLoop; + } + +// Setting change notify methods + // Note: Call this from the main thread for MSDI apps + BOOL InitSettingChangeNotify(DLGPROC pfnDlgProc = _SettingChangeDlgProc) + { + CStaticDataInitCriticalSectionLock lock; + if(FAILED(lock.Lock())) + { + ATLTRACE2(atlTraceUI, 0, _T("ERROR : Unable to lock critical section in CAppModule::InitSettingChangeNotify.\n")); + ATLASSERT(FALSE); + return FALSE; + } + + if(m_pSettingChangeNotify == NULL) + { + typedef ATL::CSimpleArray _notifyClass; + ATLTRY(m_pSettingChangeNotify = new _notifyClass); + ATLASSERT(m_pSettingChangeNotify != NULL); + } + + BOOL bRet = (m_pSettingChangeNotify != NULL); + if(bRet && (m_pSettingChangeNotify->GetSize() == 0)) + { + // init everything + _ATL_EMPTY_DLGTEMPLATE templ; + HWND hNtfWnd = ::CreateDialogIndirect(GetModuleInstance(), &templ, NULL, pfnDlgProc); + ATLASSERT(::IsWindow(hNtfWnd)); + if(::IsWindow(hNtfWnd)) + { + ::SetWindowLongPtr(hNtfWnd, GWLP_USERDATA, (LONG_PTR)this); + bRet = m_pSettingChangeNotify->Add(hNtfWnd); + } + else + { + bRet = FALSE; + } + } + + lock.Unlock(); + + return bRet; + } + + void TermSettingChangeNotify() + { + CStaticDataInitCriticalSectionLock lock; + if(FAILED(lock.Lock())) + { + ATLTRACE2(atlTraceUI, 0, _T("ERROR : Unable to lock critical section in CAppModule::TermSettingChangeNotify.\n")); + ATLASSERT(FALSE); + return; + } + + if((m_pSettingChangeNotify != NULL) && (m_pSettingChangeNotify->GetSize() > 0)) + ::DestroyWindow((*m_pSettingChangeNotify)[0]); + delete m_pSettingChangeNotify; + m_pSettingChangeNotify = NULL; + + lock.Unlock(); + } + + BOOL AddSettingChangeNotify(HWND hWnd) + { + CStaticDataInitCriticalSectionLock lock; + if(FAILED(lock.Lock())) + { + ATLTRACE2(atlTraceUI, 0, _T("ERROR : Unable to lock critical section in CAppModule::AddSettingChangeNotify.\n")); + ATLASSERT(FALSE); + return FALSE; + } + + ATLASSERT(::IsWindow(hWnd)); + BOOL bRet = FALSE; + if(InitSettingChangeNotify() != FALSE) + bRet = m_pSettingChangeNotify->Add(hWnd); + + lock.Unlock(); + + return bRet; + } + + BOOL RemoveSettingChangeNotify(HWND hWnd) + { + CStaticDataInitCriticalSectionLock lock; + if(FAILED(lock.Lock())) + { + ATLTRACE2(atlTraceUI, 0, _T("ERROR : Unable to lock critical section in CAppModule::RemoveSettingChangeNotify.\n")); + ATLASSERT(FALSE); + return FALSE; + } + + BOOL bRet = FALSE; + if(m_pSettingChangeNotify != NULL) + bRet = m_pSettingChangeNotify->Remove(hWnd); + + lock.Unlock(); + + return bRet; + } + +// Implementation - setting change notify dialog template and dialog procedure + struct _ATL_EMPTY_DLGTEMPLATE : DLGTEMPLATE + { + _ATL_EMPTY_DLGTEMPLATE() + { + memset(this, 0, sizeof(_ATL_EMPTY_DLGTEMPLATE)); + style = WS_POPUP; + } + WORD wMenu, wClass, wTitle; + }; + + static INT_PTR CALLBACK _SettingChangeDlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) + { + if(uMsg == WM_SETTINGCHANGE) + { + CAppModule* pModule = (CAppModule*)::GetWindowLongPtr(hWnd, GWLP_USERDATA); + ATLASSERT(pModule != NULL); + ATLASSERT(pModule->m_pSettingChangeNotify != NULL); + const UINT uTimeout = 1500; // ms + for(int i = 1; i < pModule->m_pSettingChangeNotify->GetSize(); i++) + ::SendMessageTimeout((*pModule->m_pSettingChangeNotify)[i], uMsg, wParam, lParam, SMTO_ABORTIFHUNG, uTimeout, NULL); + + return TRUE; + } + + return FALSE; + } +}; + +#if (_MSC_VER == 1400) // VS2005 + #pragma warning(pop) +#endif + + +/////////////////////////////////////////////////////////////////////////////// +// CServerAppModule - module class for a COM server application + +class CServerAppModule : public CAppModule +{ +public: + HANDLE m_hEventShutdown; + bool m_bActivity; + DWORD m_dwTimeOut; + DWORD m_dwPause; + +// Override of CAppModule::Init + HRESULT Init(ATL::_ATL_OBJMAP_ENTRY* pObjMap, HINSTANCE hInstance, const GUID* pLibID = NULL) + { + m_dwTimeOut = 5000; + m_dwPause = 1000; + return CAppModule::Init(pObjMap, hInstance, pLibID); + } + + void Term() + { + if((m_hEventShutdown != NULL) && ::CloseHandle(m_hEventShutdown)) + m_hEventShutdown = NULL; + CAppModule::Term(); + } + +// COM Server methods + LONG Unlock() throw() + { + LONG lRet = CComModule::Unlock(); + if(lRet == 0) + { + m_bActivity = true; + ::SetEvent(m_hEventShutdown); // tell monitor that we transitioned to zero + } + return lRet; + } + + void MonitorShutdown() + { + for(;;) + { + ::WaitForSingleObject(m_hEventShutdown, INFINITE); + DWORD dwWait = 0; + do + { + m_bActivity = false; + dwWait = ::WaitForSingleObject(m_hEventShutdown, m_dwTimeOut); + } + while(dwWait == WAIT_OBJECT_0); + // timed out + if(!m_bActivity && (m_nLockCnt == 0)) // if no activity let's really bail + { +#if defined(_WIN32_DCOM) && defined(_ATL_FREE_THREADED) + ::CoSuspendClassObjects(); + if(!m_bActivity && (m_nLockCnt == 0)) +#endif + break; + } + } + // This handle should be valid now. If it isn't, + // check if _Module.Term was called first (it shouldn't) + if(::CloseHandle(m_hEventShutdown)) + m_hEventShutdown = NULL; + ::PostThreadMessage(m_dwMainThreadID, WM_QUIT, 0, 0); + } + + bool StartMonitor() + { + m_hEventShutdown = ::CreateEvent(NULL, false, false, NULL); + if(m_hEventShutdown == NULL) + return false; + DWORD dwThreadID = 0; +#ifdef _MT + HANDLE hThread = (HANDLE)_beginthreadex(NULL, 0, (UINT (WINAPI*)(void*))MonitorProc, this, 0, (UINT*)&dwThreadID); +#else + HANDLE hThread = ::CreateThread(NULL, 0, MonitorProc, this, 0, &dwThreadID); +#endif + bool bRet = (hThread != NULL); + if(bRet) + ::CloseHandle(hThread); + return bRet; + } + + static DWORD WINAPI MonitorProc(void* pv) + { + CServerAppModule* p = (CServerAppModule*)pv; + p->MonitorShutdown(); + return 0; + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CRegKeyEx - not used any more, here only for compatibility with old projects + +typedef ATL::CRegKey CRegKeyEx; + +} // namespace WTL + + +/////////////////////////////////////////////////////////////////////////////// +// CString forward reference (enables CString use in atluser.h and atlgdi.h) + +#if (defined(_WTL_USE_CSTRING) || defined(_WTL_FORWARD_DECLARE_CSTRING)) && !defined(__ATLSTR_H__) + #include +#endif + +// CString namespace +#define _CSTRING_NS ATL + +// Type classes namespace +#define _WTYPES_NS + + +/////////////////////////////////////////////////////////////////////////////// +// General DLL version helpers (removed in ATL11) + +#if (_ATL_VER >= 0x0B00) + +namespace ATL +{ + +inline HRESULT AtlGetDllVersion(HINSTANCE hInstDLL, DLLVERSIONINFO* pDllVersionInfo) +{ + ATLASSERT(pDllVersionInfo != NULL); + if(pDllVersionInfo == NULL) + return E_INVALIDARG; + + // We must get this function explicitly because some DLLs don't implement it. + DLLGETVERSIONPROC pfnDllGetVersion = (DLLGETVERSIONPROC)::GetProcAddress(hInstDLL, "DllGetVersion"); + if(pfnDllGetVersion == NULL) + return E_NOTIMPL; + + return (*pfnDllGetVersion)(pDllVersionInfo); +} + +inline HRESULT AtlGetDllVersion(LPCTSTR lpstrDllName, DLLVERSIONINFO* pDllVersionInfo) +{ + HINSTANCE hInstDLL = ::LoadLibrary(lpstrDllName); + if(hInstDLL == NULL) + return E_FAIL; + HRESULT hRet = AtlGetDllVersion(hInstDLL, pDllVersionInfo); + ::FreeLibrary(hInstDLL); + return hRet; +} + +// Common Control Versions: +// Win95/WinNT 4.0 maj=4 min=00 +// IE 3.x maj=4 min=70 +// IE 4.0 maj=4 min=71 +inline HRESULT AtlGetCommCtrlVersion(LPDWORD pdwMajor, LPDWORD pdwMinor) +{ + ATLASSERT((pdwMajor != NULL) && (pdwMinor != NULL)); + if((pdwMajor == NULL) || (pdwMinor == NULL)) + return E_INVALIDARG; + + DLLVERSIONINFO dvi; + ::ZeroMemory(&dvi, sizeof(dvi)); + dvi.cbSize = sizeof(dvi); + HRESULT hRet = AtlGetDllVersion(_T("comctl32.dll"), &dvi); + + if(SUCCEEDED(hRet)) + { + *pdwMajor = dvi.dwMajorVersion; + *pdwMinor = dvi.dwMinorVersion; + } + else if(hRet == E_NOTIMPL) + { + // If DllGetVersion is not there, then the DLL is a version + // previous to the one shipped with IE 3.x + *pdwMajor = 4; + *pdwMinor = 0; + hRet = S_OK; + } + + return hRet; +} + +// Shell Versions: +// Win95/WinNT 4.0 maj=4 min=00 +// IE 3.x, IE 4.0 without Web Integrated Desktop maj=4 min=00 +// IE 4.0 with Web Integrated Desktop maj=4 min=71 +// IE 4.01 with Web Integrated Desktop maj=4 min=72 +inline HRESULT AtlGetShellVersion(LPDWORD pdwMajor, LPDWORD pdwMinor) +{ + ATLASSERT((pdwMajor != NULL) && (pdwMinor != NULL)); + if((pdwMajor == NULL) || (pdwMinor == NULL)) + return E_INVALIDARG; + + DLLVERSIONINFO dvi; + ::ZeroMemory(&dvi, sizeof(dvi)); + dvi.cbSize = sizeof(dvi); + HRESULT hRet = AtlGetDllVersion(_T("shell32.dll"), &dvi); + + if(SUCCEEDED(hRet)) + { + *pdwMajor = dvi.dwMajorVersion; + *pdwMinor = dvi.dwMinorVersion; + } + else if(hRet == E_NOTIMPL) + { + // If DllGetVersion is not there, then the DLL is a version + // previous to the one shipped with IE 4.x + *pdwMajor = 4; + *pdwMinor = 0; + hRet = S_OK; + } + + return hRet; +} + +} // namespace ATL + +#endif // (_ATL_VER >= 0x0B00) + + +// These are always included +#include "atlwinx.h" +#include "atluser.h" +#include "atlgdi.h" + +#ifndef _WTL_NO_AUTOMATIC_NAMESPACE +using namespace WTL; +#endif // !_WTL_NO_AUTOMATIC_NAMESPACE + +#endif // __ATLAPP_H__ diff -r e9bb126753e7 -r 20d02a178406 foosdk/wtl/Include/atlcrack.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/wtl/Include/atlcrack.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,2422 @@ +// Windows Template Library - WTL version 10.0 +// Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. +// +// This file is a part of the Windows Template Library. +// The use and distribution terms for this software are covered by the +// Microsoft Public License (http://opensource.org/licenses/MS-PL) +// which can be found in the file MS-PL.txt at the root folder. + +#ifndef __ATLCRACK_H__ +#define __ATLCRACK_H__ + +#pragma once + +#ifndef __ATLAPP_H__ + #error atlcrack.h requires atlapp.h to be included first +#endif + + +/////////////////////////////////////////////////////////////////////////////// +// Message map macro for cracked handlers + +// Note about message maps with cracked handlers: +// You can use BEGIN_MSG_MAP for classes that derive from CWindowImpl/CDialogImpl, +// but must use BEGIN_MSG_MAP_EX for classes that don't. + +#define BEGIN_MSG_MAP_EX(theClass) \ +public: \ + BOOL m_bMsgHandled; \ + /* "handled" management for cracked handlers */ \ + BOOL IsMsgHandled() const \ + { \ + return m_bMsgHandled; \ + } \ + void SetMsgHandled(BOOL bHandled) \ + { \ + m_bMsgHandled = bHandled; \ + } \ + BOOL ProcessWindowMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT& lResult, DWORD dwMsgMapID = 0) \ + { \ + BOOL bOldMsgHandled = m_bMsgHandled; \ + BOOL bRet = _ProcessWindowMessage(hWnd, uMsg, wParam, lParam, lResult, dwMsgMapID); \ + m_bMsgHandled = bOldMsgHandled; \ + return bRet; \ + } \ + BOOL _ProcessWindowMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT& lResult, DWORD dwMsgMapID) \ + { \ + BOOL bHandled = TRUE; \ + (hWnd); \ + (uMsg); \ + (wParam); \ + (lParam); \ + (lResult); \ + (bHandled); \ + switch(dwMsgMapID) \ + { \ + case 0: + + +/////////////////////////////////////////////////////////////////////////////// +// Standard Windows message macros + +// int OnCreate(LPCREATESTRUCT lpCreateStruct) +#define MSG_WM_CREATE(func) \ + if (uMsg == WM_CREATE) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func((LPCREATESTRUCT)lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// BOOL OnInitDialog(CWindow wndFocus, LPARAM lInitParam) +#define MSG_WM_INITDIALOG(func) \ + if (uMsg == WM_INITDIALOG) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func((HWND)wParam, lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// BOOL OnCopyData(CWindow wnd, PCOPYDATASTRUCT pCopyDataStruct) +#define MSG_WM_COPYDATA(func) \ + if (uMsg == WM_COPYDATA) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func((HWND)wParam, (PCOPYDATASTRUCT)lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnDestroy() +#define MSG_WM_DESTROY(func) \ + if (uMsg == WM_DESTROY) \ + { \ + this->SetMsgHandled(TRUE); \ + func(); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnMove(CPoint ptPos) +#define MSG_WM_MOVE(func) \ + if (uMsg == WM_MOVE) \ + { \ + this->SetMsgHandled(TRUE); \ + func(::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnSize(UINT nType, CSize size) +#define MSG_WM_SIZE(func) \ + if (uMsg == WM_SIZE) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CSize(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnActivate(UINT nState, BOOL bMinimized, CWindow wndOther) +#define MSG_WM_ACTIVATE(func) \ + if (uMsg == WM_ACTIVATE) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)LOWORD(wParam), (BOOL)HIWORD(wParam), (HWND)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnSetFocus(CWindow wndOld) +#define MSG_WM_SETFOCUS(func) \ + if (uMsg == WM_SETFOCUS) \ + { \ + this->SetMsgHandled(TRUE); \ + func((HWND)wParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnKillFocus(CWindow wndFocus) +#define MSG_WM_KILLFOCUS(func) \ + if (uMsg == WM_KILLFOCUS) \ + { \ + this->SetMsgHandled(TRUE); \ + func((HWND)wParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnEnable(BOOL bEnable) +#define MSG_WM_ENABLE(func) \ + if (uMsg == WM_ENABLE) \ + { \ + this->SetMsgHandled(TRUE); \ + func((BOOL)wParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnPaint(CDCHandle dc) +#define MSG_WM_PAINT(func) \ + if (uMsg == WM_PAINT) \ + { \ + this->SetMsgHandled(TRUE); \ + func((HDC)wParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnClose() +#define MSG_WM_CLOSE(func) \ + if (uMsg == WM_CLOSE) \ + { \ + this->SetMsgHandled(TRUE); \ + func(); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// BOOL OnQueryEndSession(UINT nSource, UINT uLogOff) +#define MSG_WM_QUERYENDSESSION(func) \ + if (uMsg == WM_QUERYENDSESSION) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func((UINT)wParam, (UINT)lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// BOOL OnQueryOpen() +#define MSG_WM_QUERYOPEN(func) \ + if (uMsg == WM_QUERYOPEN) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func(); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// BOOL OnEraseBkgnd(CDCHandle dc) +#define MSG_WM_ERASEBKGND(func) \ + if (uMsg == WM_ERASEBKGND) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func((HDC)wParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnSysColorChange() +#define MSG_WM_SYSCOLORCHANGE(func) \ + if (uMsg == WM_SYSCOLORCHANGE) \ + { \ + this->SetMsgHandled(TRUE); \ + func(); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnEndSession(BOOL bEnding, UINT uLogOff) +#define MSG_WM_ENDSESSION(func) \ + if (uMsg == WM_ENDSESSION) \ + { \ + this->SetMsgHandled(TRUE); \ + func((BOOL)wParam, (UINT)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnShowWindow(BOOL bShow, UINT nStatus) +#define MSG_WM_SHOWWINDOW(func) \ + if (uMsg == WM_SHOWWINDOW) \ + { \ + this->SetMsgHandled(TRUE); \ + func((BOOL)wParam, (int)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// HBRUSH OnCtlColorEdit(CDCHandle dc, CEdit edit) +#define MSG_WM_CTLCOLOREDIT(func) \ + if (uMsg == WM_CTLCOLOREDIT) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// HBRUSH OnCtlColorListBox(CDCHandle dc, CListBox listBox) +#define MSG_WM_CTLCOLORLISTBOX(func) \ + if (uMsg == WM_CTLCOLORLISTBOX) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// HBRUSH OnCtlColorBtn(CDCHandle dc, CButton button) +#define MSG_WM_CTLCOLORBTN(func) \ + if (uMsg == WM_CTLCOLORBTN) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// HBRUSH OnCtlColorDlg(CDCHandle dc, CWindow wnd) +#define MSG_WM_CTLCOLORDLG(func) \ + if (uMsg == WM_CTLCOLORDLG) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// HBRUSH OnCtlColorScrollBar(CDCHandle dc, CScrollBar scrollBar) +#define MSG_WM_CTLCOLORSCROLLBAR(func) \ + if (uMsg == WM_CTLCOLORSCROLLBAR) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// HBRUSH OnCtlColorStatic(CDCHandle dc, CStatic wndStatic) +#define MSG_WM_CTLCOLORSTATIC(func) \ + if (uMsg == WM_CTLCOLORSTATIC) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnSettingChange(UINT uFlags, LPCTSTR lpszSection) +#define MSG_WM_SETTINGCHANGE(func) \ + if (uMsg == WM_SETTINGCHANGE) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, (LPCTSTR)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnDevModeChange(LPCTSTR lpDeviceName) +#define MSG_WM_DEVMODECHANGE(func) \ + if (uMsg == WM_DEVMODECHANGE) \ + { \ + this->SetMsgHandled(TRUE); \ + func((LPCTSTR)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnActivateApp(BOOL bActive, DWORD dwThreadID) +#define MSG_WM_ACTIVATEAPP(func) \ + if (uMsg == WM_ACTIVATEAPP) \ + { \ + this->SetMsgHandled(TRUE); \ + func((BOOL)wParam, (DWORD)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnFontChange() +#define MSG_WM_FONTCHANGE(func) \ + if (uMsg == WM_FONTCHANGE) \ + { \ + this->SetMsgHandled(TRUE); \ + func(); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnTimeChange() +#define MSG_WM_TIMECHANGE(func) \ + if (uMsg == WM_TIMECHANGE) \ + { \ + this->SetMsgHandled(TRUE); \ + func(); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnCancelMode() +#define MSG_WM_CANCELMODE(func) \ + if (uMsg == WM_CANCELMODE) \ + { \ + this->SetMsgHandled(TRUE); \ + func(); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// BOOL OnSetCursor(CWindow wnd, UINT nHitTest, UINT message) +#define MSG_WM_SETCURSOR(func) \ + if (uMsg == WM_SETCURSOR) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func((HWND)wParam, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam)); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// int OnMouseActivate(CWindow wndTopLevel, UINT nHitTest, UINT message) +#define MSG_WM_MOUSEACTIVATE(func) \ + if (uMsg == WM_MOUSEACTIVATE) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func((HWND)wParam, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam)); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnChildActivate() +#define MSG_WM_CHILDACTIVATE(func) \ + if (uMsg == WM_CHILDACTIVATE) \ + { \ + this->SetMsgHandled(TRUE); \ + func(); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnGetMinMaxInfo(LPMINMAXINFO lpMMI) +#define MSG_WM_GETMINMAXINFO(func) \ + if (uMsg == WM_GETMINMAXINFO) \ + { \ + this->SetMsgHandled(TRUE); \ + func((LPMINMAXINFO)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnIconEraseBkgnd(CDCHandle dc) +#define MSG_WM_ICONERASEBKGND(func) \ + if (uMsg == WM_ICONERASEBKGND) \ + { \ + this->SetMsgHandled(TRUE); \ + func((HDC)wParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnSpoolerStatus(UINT nStatus, UINT nJobs) +#define MSG_WM_SPOOLERSTATUS(func) \ + if (uMsg == WM_SPOOLERSTATUS) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, (UINT)LOWORD(lParam)); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct) +#define MSG_WM_DRAWITEM(func) \ + if (uMsg == WM_DRAWITEM) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, (LPDRAWITEMSTRUCT)lParam); \ + lResult = TRUE; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct) +#define MSG_WM_MEASUREITEM(func) \ + if (uMsg == WM_MEASUREITEM) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, (LPMEASUREITEMSTRUCT)lParam); \ + lResult = TRUE; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnDeleteItem(int nIDCtl, LPDELETEITEMSTRUCT lpDeleteItemStruct) +#define MSG_WM_DELETEITEM(func) \ + if (uMsg == WM_DELETEITEM) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, (LPDELETEITEMSTRUCT)lParam); \ + lResult = TRUE; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +//int OnCharToItem(UINT nChar, UINT nIndex, CListBox listBox) +#define MSG_WM_CHARTOITEM(func) \ + if (uMsg == WM_CHARTOITEM) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), (HWND)lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// int OnVKeyToItem(UINT nKey, UINT nIndex, CListBox listBox) +#define MSG_WM_VKEYTOITEM(func) \ + if (uMsg == WM_VKEYTOITEM) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), (HWND)lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// HCURSOR OnQueryDragIcon() +#define MSG_WM_QUERYDRAGICON(func) \ + if (uMsg == WM_QUERYDRAGICON) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func(); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// int OnCompareItem(int nIDCtl, LPCOMPAREITEMSTRUCT lpCompareItemStruct) +#define MSG_WM_COMPAREITEM(func) \ + if (uMsg == WM_COMPAREITEM) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func((UINT)wParam, (LPCOMPAREITEMSTRUCT)lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnCompacting(UINT nCpuTime) +#define MSG_WM_COMPACTING(func) \ + if (uMsg == WM_COMPACTING) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// BOOL OnNcCreate(LPCREATESTRUCT lpCreateStruct) +#define MSG_WM_NCCREATE(func) \ + if (uMsg == WM_NCCREATE) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func((LPCREATESTRUCT)lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnNcDestroy() +#define MSG_WM_NCDESTROY(func) \ + if (uMsg == WM_NCDESTROY) \ + { \ + this->SetMsgHandled(TRUE); \ + func(); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// LRESULT OnNcCalcSize(BOOL bCalcValidRects, LPARAM lParam) +#define MSG_WM_NCCALCSIZE(func) \ + if (uMsg == WM_NCCALCSIZE) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = func((BOOL)wParam, lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// UINT OnNcHitTest(CPoint point) +#define MSG_WM_NCHITTEST(func) \ + if (uMsg == WM_NCHITTEST) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func(::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnNcPaint(CRgnHandle rgn) +#define MSG_WM_NCPAINT(func) \ + if (uMsg == WM_NCPAINT) \ + { \ + this->SetMsgHandled(TRUE); \ + func((HRGN)wParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// BOOL OnNcActivate(BOOL bActive) +#define MSG_WM_NCACTIVATE(func) \ + if (uMsg == WM_NCACTIVATE) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func((BOOL)wParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// UINT OnGetDlgCode(LPMSG lpMsg) +#define MSG_WM_GETDLGCODE(func) \ + if (uMsg == WM_GETDLGCODE) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func((LPMSG)lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnNcMouseMove(UINT nHitTest, CPoint point) +#define MSG_WM_NCMOUSEMOVE(func) \ + if (uMsg == WM_NCMOUSEMOVE) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnNcLButtonDown(UINT nHitTest, CPoint point) +#define MSG_WM_NCLBUTTONDOWN(func) \ + if (uMsg == WM_NCLBUTTONDOWN) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnNcLButtonUp(UINT nHitTest, CPoint point) +#define MSG_WM_NCLBUTTONUP(func) \ + if (uMsg == WM_NCLBUTTONUP) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnNcLButtonDblClk(UINT nHitTest, CPoint point) +#define MSG_WM_NCLBUTTONDBLCLK(func) \ + if (uMsg == WM_NCLBUTTONDBLCLK) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnNcRButtonDown(UINT nHitTest, CPoint point) +#define MSG_WM_NCRBUTTONDOWN(func) \ + if (uMsg == WM_NCRBUTTONDOWN) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnNcRButtonUp(UINT nHitTest, CPoint point) +#define MSG_WM_NCRBUTTONUP(func) \ + if (uMsg == WM_NCRBUTTONUP) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnNcRButtonDblClk(UINT nHitTest, CPoint point) +#define MSG_WM_NCRBUTTONDBLCLK(func) \ + if (uMsg == WM_NCRBUTTONDBLCLK) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnNcMButtonDown(UINT nHitTest, CPoint point) +#define MSG_WM_NCMBUTTONDOWN(func) \ + if (uMsg == WM_NCMBUTTONDOWN) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnNcMButtonUp(UINT nHitTest, CPoint point) +#define MSG_WM_NCMBUTTONUP(func) \ + if (uMsg == WM_NCMBUTTONUP) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnNcMButtonDblClk(UINT nHitTest, CPoint point) +#define MSG_WM_NCMBUTTONDBLCLK(func) \ + if (uMsg == WM_NCMBUTTONDBLCLK) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) +#define MSG_WM_KEYDOWN(func) \ + if (uMsg == WM_KEYDOWN) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) +#define MSG_WM_KEYUP(func) \ + if (uMsg == WM_KEYUP) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnChar(TCHAR chChar, UINT nRepCnt, UINT nFlags) +#define MSG_WM_CHAR(func) \ + if (uMsg == WM_CHAR) \ + { \ + this->SetMsgHandled(TRUE); \ + func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnDeadChar(TCHAR chChar, UINT nRepCnt, UINT nFlags) +#define MSG_WM_DEADCHAR(func) \ + if (uMsg == WM_DEADCHAR) \ + { \ + this->SetMsgHandled(TRUE); \ + func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) +#define MSG_WM_SYSKEYDOWN(func) \ + if (uMsg == WM_SYSKEYDOWN) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnSysKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) +#define MSG_WM_SYSKEYUP(func) \ + if (uMsg == WM_SYSKEYUP) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnSysChar(TCHAR chChar, UINT nRepCnt, UINT nFlags) +#define MSG_WM_SYSCHAR(func) \ + if (uMsg == WM_SYSCHAR) \ + { \ + this->SetMsgHandled(TRUE); \ + func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnSysDeadChar(TCHAR chChar, UINT nRepCnt, UINT nFlags) +#define MSG_WM_SYSDEADCHAR(func) \ + if (uMsg == WM_SYSDEADCHAR) \ + { \ + this->SetMsgHandled(TRUE); \ + func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnSysCommand(UINT nID, CPoint point) +#define MSG_WM_SYSCOMMAND(func) \ + if (uMsg == WM_SYSCOMMAND) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnTCard(UINT idAction, DWORD dwActionData) +#define MSG_WM_TCARD(func) \ + if (uMsg == WM_TCARD) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, (DWORD)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnTimer(UINT_PTR nIDEvent) +#define MSG_WM_TIMER(func) \ + if (uMsg == WM_TIMER) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT_PTR)wParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar pScrollBar) +#define MSG_WM_HSCROLL(func) \ + if (uMsg == WM_HSCROLL) \ + { \ + this->SetMsgHandled(TRUE); \ + func((int)LOWORD(wParam), (short)HIWORD(wParam), (HWND)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar pScrollBar) +#define MSG_WM_VSCROLL(func) \ + if (uMsg == WM_VSCROLL) \ + { \ + this->SetMsgHandled(TRUE); \ + func((int)LOWORD(wParam), (short)HIWORD(wParam), (HWND)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnInitMenu(CMenuHandle menu) +#define MSG_WM_INITMENU(func) \ + if (uMsg == WM_INITMENU) \ + { \ + this->SetMsgHandled(TRUE); \ + func((HMENU)wParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnInitMenuPopup(CMenuHandle menuPopup, UINT nIndex, BOOL bSysMenu) +#define MSG_WM_INITMENUPOPUP(func) \ + if (uMsg == WM_INITMENUPOPUP) \ + { \ + this->SetMsgHandled(TRUE); \ + func((HMENU)wParam, (UINT)LOWORD(lParam), (BOOL)HIWORD(lParam)); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnMenuSelect(UINT nItemID, UINT nFlags, CMenuHandle menu) +#define MSG_WM_MENUSELECT(func) \ + if (uMsg == WM_MENUSELECT) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), (HMENU)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// LRESULT OnMenuChar(UINT nChar, UINT nFlags, CMenuHandle menu) +#define MSG_WM_MENUCHAR(func) \ + if (uMsg == WM_MENUCHAR) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = func((TCHAR)LOWORD(wParam), (UINT)HIWORD(wParam), (HMENU)lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// LRESULT OnNotify(int idCtrl, LPNMHDR pnmh) +#define MSG_WM_NOTIFY(func) \ + if (uMsg == WM_NOTIFY) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = func((int)wParam, (LPNMHDR)lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnEnterIdle(UINT nWhy, CWindow wndWho) +#define MSG_WM_ENTERIDLE(func) \ + if (uMsg == WM_ENTERIDLE) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, (HWND)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnMouseMove(UINT nFlags, CPoint point) +#define MSG_WM_MOUSEMOVE(func) \ + if (uMsg == WM_MOUSEMOVE) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt) +#define MSG_WM_MOUSEWHEEL(func) \ + if (uMsg == WM_MOUSEWHEEL) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func((UINT)LOWORD(wParam), (short)HIWORD(wParam), ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnLButtonDown(UINT nFlags, CPoint point) +#define MSG_WM_LBUTTONDOWN(func) \ + if (uMsg == WM_LBUTTONDOWN) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnLButtonUp(UINT nFlags, CPoint point) +#define MSG_WM_LBUTTONUP(func) \ + if (uMsg == WM_LBUTTONUP) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnLButtonDblClk(UINT nFlags, CPoint point) +#define MSG_WM_LBUTTONDBLCLK(func) \ + if (uMsg == WM_LBUTTONDBLCLK) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnRButtonDown(UINT nFlags, CPoint point) +#define MSG_WM_RBUTTONDOWN(func) \ + if (uMsg == WM_RBUTTONDOWN) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnRButtonUp(UINT nFlags, CPoint point) +#define MSG_WM_RBUTTONUP(func) \ + if (uMsg == WM_RBUTTONUP) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnRButtonDblClk(UINT nFlags, CPoint point) +#define MSG_WM_RBUTTONDBLCLK(func) \ + if (uMsg == WM_RBUTTONDBLCLK) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnMButtonDown(UINT nFlags, CPoint point) +#define MSG_WM_MBUTTONDOWN(func) \ + if (uMsg == WM_MBUTTONDOWN) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnMButtonUp(UINT nFlags, CPoint point) +#define MSG_WM_MBUTTONUP(func) \ + if (uMsg == WM_MBUTTONUP) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnMButtonDblClk(UINT nFlags, CPoint point) +#define MSG_WM_MBUTTONDBLCLK(func) \ + if (uMsg == WM_MBUTTONDBLCLK) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnParentNotify(UINT message, UINT nChildID, LPARAM lParam) +#define MSG_WM_PARENTNOTIFY(func) \ + if (uMsg == WM_PARENTNOTIFY) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnMDIActivate(CWindow wndActivate, CWindow wndDeactivate) +#define MSG_WM_MDIACTIVATE(func) \ + if (uMsg == WM_MDIACTIVATE) \ + { \ + this->SetMsgHandled(TRUE); \ + func((HWND)wParam, (HWND)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnRenderFormat(UINT nFormat) +#define MSG_WM_RENDERFORMAT(func) \ + if (uMsg == WM_RENDERFORMAT) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnRenderAllFormats() +#define MSG_WM_RENDERALLFORMATS(func) \ + if (uMsg == WM_RENDERALLFORMATS) \ + { \ + this->SetMsgHandled(TRUE); \ + func(); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnDestroyClipboard() +#define MSG_WM_DESTROYCLIPBOARD(func) \ + if (uMsg == WM_DESTROYCLIPBOARD) \ + { \ + this->SetMsgHandled(TRUE); \ + func(); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnDrawClipboard() +#define MSG_WM_DRAWCLIPBOARD(func) \ + if (uMsg == WM_DRAWCLIPBOARD) \ + { \ + this->SetMsgHandled(TRUE); \ + func(); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnPaintClipboard(CWindow wndViewer, const LPPAINTSTRUCT lpPaintStruct) +#define MSG_WM_PAINTCLIPBOARD(func) \ + if (uMsg == WM_PAINTCLIPBOARD) \ + { \ + this->SetMsgHandled(TRUE); \ + func((HWND)wParam, (const LPPAINTSTRUCT)::GlobalLock((HGLOBAL)lParam)); \ + ::GlobalUnlock((HGLOBAL)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnVScrollClipboard(CWindow wndViewer, UINT nSBCode, UINT nPos) +#define MSG_WM_VSCROLLCLIPBOARD(func) \ + if (uMsg == WM_VSCROLLCLIPBOARD) \ + { \ + this->SetMsgHandled(TRUE); \ + func((HWND)wParam, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam)); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnContextMenu(CWindow wnd, CPoint point) +#define MSG_WM_CONTEXTMENU(func) \ + if (uMsg == WM_CONTEXTMENU) \ + { \ + this->SetMsgHandled(TRUE); \ + func((HWND)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnSizeClipboard(CWindow wndViewer, const LPRECT lpRect) +#define MSG_WM_SIZECLIPBOARD(func) \ + if (uMsg == WM_SIZECLIPBOARD) \ + { \ + this->SetMsgHandled(TRUE); \ + func((HWND)wParam, (const LPRECT)::GlobalLock((HGLOBAL)lParam)); \ + ::GlobalUnlock((HGLOBAL)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnAskCbFormatName(UINT nMaxCount, LPTSTR lpszString) +#define MSG_WM_ASKCBFORMATNAME(func) \ + if (uMsg == WM_ASKCBFORMATNAME) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, (LPTSTR)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnChangeCbChain(CWindow wndRemove, CWindow wndAfter) +#define MSG_WM_CHANGECBCHAIN(func) \ + if (uMsg == WM_CHANGECBCHAIN) \ + { \ + this->SetMsgHandled(TRUE); \ + func((HWND)wParam, (HWND)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnHScrollClipboard(CWindow wndViewer, UINT nSBCode, UINT nPos) +#define MSG_WM_HSCROLLCLIPBOARD(func) \ + if (uMsg == WM_HSCROLLCLIPBOARD) \ + { \ + this->SetMsgHandled(TRUE); \ + func((HWND)wParam, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam)); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// BOOL OnQueryNewPalette() +#define MSG_WM_QUERYNEWPALETTE(func) \ + if (uMsg == WM_QUERYNEWPALETTE) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func(); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnPaletteChanged(CWindow wndFocus) +#define MSG_WM_PALETTECHANGED(func) \ + if (uMsg == WM_PALETTECHANGED) \ + { \ + this->SetMsgHandled(TRUE); \ + func((HWND)wParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnPaletteIsChanging(CWindow wndPalChg) +#define MSG_WM_PALETTEISCHANGING(func) \ + if (uMsg == WM_PALETTEISCHANGING) \ + { \ + this->SetMsgHandled(TRUE); \ + func((HWND)wParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnDropFiles(HDROP hDropInfo) +#define MSG_WM_DROPFILES(func) \ + if (uMsg == WM_DROPFILES) \ + { \ + this->SetMsgHandled(TRUE); \ + func((HDROP)wParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnWindowPosChanging(LPWINDOWPOS lpWndPos) +#define MSG_WM_WINDOWPOSCHANGING(func) \ + if (uMsg == WM_WINDOWPOSCHANGING) \ + { \ + this->SetMsgHandled(TRUE); \ + func((LPWINDOWPOS)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnWindowPosChanged(LPWINDOWPOS lpWndPos) +#define MSG_WM_WINDOWPOSCHANGED(func) \ + if (uMsg == WM_WINDOWPOSCHANGED) \ + { \ + this->SetMsgHandled(TRUE); \ + func((LPWINDOWPOS)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnExitMenuLoop(BOOL fIsTrackPopupMenu) +#define MSG_WM_EXITMENULOOP(func) \ + if (uMsg == WM_EXITMENULOOP) \ + { \ + this->SetMsgHandled(TRUE); \ + func((BOOL)wParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnEnterMenuLoop(BOOL fIsTrackPopupMenu) +#define MSG_WM_ENTERMENULOOP(func) \ + if (uMsg == WM_ENTERMENULOOP) \ + { \ + this->SetMsgHandled(TRUE); \ + func((BOOL)wParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnStyleChanged(int nStyleType, LPSTYLESTRUCT lpStyleStruct) +#define MSG_WM_STYLECHANGED(func) \ + if (uMsg == WM_STYLECHANGED) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, (LPSTYLESTRUCT)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnStyleChanging(int nStyleType, LPSTYLESTRUCT lpStyleStruct) +#define MSG_WM_STYLECHANGING(func) \ + if (uMsg == WM_STYLECHANGING) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, (LPSTYLESTRUCT)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnSizing(UINT fwSide, LPRECT pRect) +#define MSG_WM_SIZING(func) \ + if (uMsg == WM_SIZING) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, (LPRECT)lParam); \ + lResult = TRUE; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnMoving(UINT fwSide, LPRECT pRect) +#define MSG_WM_MOVING(func) \ + if (uMsg == WM_MOVING) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, (LPRECT)lParam); \ + lResult = TRUE; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnCaptureChanged(CWindow wnd) +#define MSG_WM_CAPTURECHANGED(func) \ + if (uMsg == WM_CAPTURECHANGED) \ + { \ + this->SetMsgHandled(TRUE); \ + func((HWND)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// BOOL OnDeviceChange(UINT nEventType, DWORD_PTR dwData) +#define MSG_WM_DEVICECHANGE(func) \ + if (uMsg == WM_DEVICECHANGE) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func((UINT)wParam, (DWORD_PTR)lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnCommand(UINT uNotifyCode, int nID, CWindow wndCtl) +#define MSG_WM_COMMAND(func) \ + if (uMsg == WM_COMMAND) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnDisplayChange(UINT uBitsPerPixel, CSize sizeScreen) +#define MSG_WM_DISPLAYCHANGE(func) \ + if (uMsg == WM_DISPLAYCHANGE) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, ::CSize(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnEnterSizeMove() +#define MSG_WM_ENTERSIZEMOVE(func) \ + if (uMsg == WM_ENTERSIZEMOVE) \ + { \ + this->SetMsgHandled(TRUE); \ + func(); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnExitSizeMove() +#define MSG_WM_EXITSIZEMOVE(func) \ + if (uMsg == WM_EXITSIZEMOVE) \ + { \ + this->SetMsgHandled(TRUE); \ + func(); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// HFONT OnGetFont() +#define MSG_WM_GETFONT(func) \ + if (uMsg == WM_GETFONT) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func(); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// LRESULT OnGetHotKey() +#define MSG_WM_GETHOTKEY(func) \ + if (uMsg == WM_GETHOTKEY) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = func(); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// HICON OnGetIcon() +#define MSG_WM_GETICON(func) \ + if (uMsg == WM_GETICON) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func((UINT)wParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// int OnGetText(int cchTextMax, LPTSTR lpszText) +#define MSG_WM_GETTEXT(func) \ + if (uMsg == WM_GETTEXT) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func((int)wParam, (LPTSTR)lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// int OnGetTextLength() +#define MSG_WM_GETTEXTLENGTH(func) \ + if (uMsg == WM_GETTEXTLENGTH) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func(); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnHelp(LPHELPINFO lpHelpInfo) +#define MSG_WM_HELP(func) \ + if (uMsg == WM_HELP) \ + { \ + this->SetMsgHandled(TRUE); \ + func((LPHELPINFO)lParam); \ + lResult = TRUE; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnHotKey(int nHotKeyID, UINT uModifiers, UINT uVirtKey) +#define MSG_WM_HOTKEY(func) \ + if (uMsg == WM_HOTKEY) \ + { \ + this->SetMsgHandled(TRUE); \ + func((int)wParam, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam)); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnInputLangChange(DWORD dwCharSet, HKL hKbdLayout) +#define MSG_WM_INPUTLANGCHANGE(func) \ + if (uMsg == WM_INPUTLANGCHANGE) \ + { \ + this->SetMsgHandled(TRUE); \ + func((DWORD)wParam, (HKL)lParam); \ + lResult = TRUE; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnInputLangChangeRequest(BOOL bSysCharSet, HKL hKbdLayout) +#define MSG_WM_INPUTLANGCHANGEREQUEST(func) \ + if (uMsg == WM_INPUTLANGCHANGEREQUEST) \ + { \ + this->SetMsgHandled(TRUE); \ + func((BOOL)wParam, (HKL)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnNextDlgCtl(BOOL bHandle, WPARAM wCtlFocus) +#define MSG_WM_NEXTDLGCTL(func) \ + if (uMsg == WM_NEXTDLGCTL) \ + { \ + this->SetMsgHandled(TRUE); \ + func((BOOL)LOWORD(lParam), wParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnNextMenu(int nVirtKey, LPMDINEXTMENU lpMdiNextMenu) +#define MSG_WM_NEXTMENU(func) \ + if (uMsg == WM_NEXTMENU) \ + { \ + this->SetMsgHandled(TRUE); \ + func((int)wParam, (LPMDINEXTMENU)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// int OnNotifyFormat(CWindow wndFrom, int nCommand) +#define MSG_WM_NOTIFYFORMAT(func) \ + if (uMsg == WM_NOTIFYFORMAT) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func((HWND)wParam, (int)lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// BOOL OnPowerBroadcast(DWORD dwPowerEvent, DWORD_PTR dwData) +#define MSG_WM_POWERBROADCAST(func) \ + if (uMsg == WM_POWERBROADCAST) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func((DWORD)wParam, (DWORD_PTR)lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnPrint(CDCHandle dc, UINT uFlags) +#define MSG_WM_PRINT(func) \ + if (uMsg == WM_PRINT) \ + { \ + this->SetMsgHandled(TRUE); \ + func((HDC)wParam, (UINT)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnPrintClient(CDCHandle dc, UINT uFlags) +#define MSG_WM_PRINTCLIENT(func) \ + if (uMsg == WM_PRINTCLIENT) \ + { \ + this->SetMsgHandled(TRUE); \ + func((HDC)wParam, (UINT)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnRasDialEvent(RASCONNSTATE rasconnstate, DWORD dwError) +#define MSG_WM_RASDIALEVENT(func) \ + if (uMsg == WM_RASDIALEVENT) \ + { \ + this->SetMsgHandled(TRUE); \ + func((RASCONNSTATE)wParam, (DWORD)lParam); \ + lResult = TRUE; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnSetFont(CFontHandle font, BOOL bRedraw) +#define MSG_WM_SETFONT(func) \ + if (uMsg == WM_SETFONT) \ + { \ + this->SetMsgHandled(TRUE); \ + func((HFONT)wParam, (BOOL)LOWORD(lParam)); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// int OnSetHotKey(int nVirtKey, UINT uFlags) +#define MSG_WM_SETHOTKEY(func) \ + if (uMsg == WM_SETHOTKEY) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func((int)LOBYTE(LOWORD(wParam)), (UINT)HIBYTE(LOWORD(wParam))); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// HICON OnSetIcon(UINT uType, HICON hIcon) +#define MSG_WM_SETICON(func) \ + if (uMsg == WM_SETICON) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func((UINT)wParam, (HICON)lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnSetRedraw(BOOL bRedraw) +#define MSG_WM_SETREDRAW(func) \ + if (uMsg == WM_SETREDRAW) \ + { \ + this->SetMsgHandled(TRUE); \ + func((BOOL)wParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// int OnSetText(LPCTSTR lpstrText) +#define MSG_WM_SETTEXT(func) \ + if (uMsg == WM_SETTEXT) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func((LPCTSTR)lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnUserChanged() +#define MSG_WM_USERCHANGED(func) \ + if (uMsg == WM_USERCHANGED) \ + { \ + this->SetMsgHandled(TRUE); \ + func(); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +/////////////////////////////////////////////////////////////////////////////// +// Newer Windows messages + +// void OnMouseHover(WPARAM wParam, CPoint ptPos) +#define MSG_WM_MOUSEHOVER(func) \ + if (uMsg == WM_MOUSEHOVER) \ + { \ + this->SetMsgHandled(TRUE); \ + func(wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnMouseLeave() +#define MSG_WM_MOUSELEAVE(func) \ + if (uMsg == WM_MOUSELEAVE) \ + { \ + this->SetMsgHandled(TRUE); \ + func(); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnMenuRButtonUp(WPARAM wParam, CMenuHandle menu) +#define MSG_WM_MENURBUTTONUP(func) \ + if (uMsg == WM_MENURBUTTONUP) \ + { \ + this->SetMsgHandled(TRUE); \ + func(wParam, (HMENU)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// LRESULT OnMenuDrag(WPARAM wParam, CMenuHandle menu) +#define MSG_WM_MENUDRAG(func) \ + if (uMsg == WM_MENUDRAG) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = func(wParam, (HMENU)lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// LRESULT OnMenuGetObject(PMENUGETOBJECTINFO info) +#define MSG_WM_MENUGETOBJECT(func) \ + if (uMsg == WM_MENUGETOBJECT) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = func((PMENUGETOBJECTINFO)lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnUnInitMenuPopup(UINT nID, CMenuHandle menu) +#define MSG_WM_UNINITMENUPOPUP(func) \ + if (uMsg == WM_UNINITMENUPOPUP) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)HIWORD(lParam), (HMENU)wParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnMenuCommand(WPARAM nIndex, CMenuHandle menu) +#define MSG_WM_MENUCOMMAND(func) \ + if (uMsg == WM_MENUCOMMAND) \ + { \ + this->SetMsgHandled(TRUE); \ + func(wParam, (HMENU)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// BOOL OnAppCommand(CWindow wndFocus, short cmd, WORD uDevice, int dwKeys) +#define MSG_WM_APPCOMMAND(func) \ + if (uMsg == WM_APPCOMMAND) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func((HWND)wParam, GET_APPCOMMAND_LPARAM(lParam), GET_DEVICE_LPARAM(lParam), GET_KEYSTATE_LPARAM(lParam)); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnNCXButtonDown(int fwButton, short nHittest, CPoint ptPos) +#define MSG_WM_NCXBUTTONDOWN(func) \ + if (uMsg == WM_NCXBUTTONDOWN) \ + { \ + this->SetMsgHandled(TRUE); \ + func(GET_XBUTTON_WPARAM(wParam), GET_NCHITTEST_WPARAM(wParam), ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + lResult = (LRESULT)TRUE; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnNCXButtonUp(int fwButton, short nHittest, CPoint ptPos) +#define MSG_WM_NCXBUTTONUP(func) \ + if (uMsg == WM_NCXBUTTONUP) \ + { \ + this->SetMsgHandled(TRUE); \ + func(GET_XBUTTON_WPARAM(wParam), GET_NCHITTEST_WPARAM(wParam), ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + lResult = (LRESULT)TRUE; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnNCXButtonDblClk(int fwButton, short nHittest, CPoint ptPos) +#define MSG_WM_NCXBUTTONDBLCLK(func) \ + if (uMsg == WM_NCXBUTTONDBLCLK) \ + { \ + this->SetMsgHandled(TRUE); \ + func(GET_XBUTTON_WPARAM(wParam), GET_NCHITTEST_WPARAM(wParam), ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + lResult = (LRESULT)TRUE; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnXButtonDown(int fwButton, int dwKeys, CPoint ptPos) +#define MSG_WM_XBUTTONDOWN(func) \ + if (uMsg == WM_XBUTTONDOWN) \ + { \ + this->SetMsgHandled(TRUE); \ + func(GET_XBUTTON_WPARAM(wParam), GET_KEYSTATE_WPARAM(wParam), ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + lResult = (LRESULT)TRUE; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnXButtonUp(int fwButton, int dwKeys, CPoint ptPos) +#define MSG_WM_XBUTTONUP(func) \ + if (uMsg == WM_XBUTTONUP) \ + { \ + this->SetMsgHandled(TRUE); \ + func(GET_XBUTTON_WPARAM(wParam), GET_KEYSTATE_WPARAM(wParam), ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + lResult = (LRESULT)TRUE; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnXButtonDblClk(int fwButton, int dwKeys, CPoint ptPos) +#define MSG_WM_XBUTTONDBLCLK(func) \ + if (uMsg == WM_XBUTTONDBLCLK) \ + { \ + this->SetMsgHandled(TRUE); \ + func(GET_XBUTTON_WPARAM(wParam), GET_KEYSTATE_WPARAM(wParam), ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + lResult = (LRESULT)TRUE; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnChangeUIState(WORD nAction, WORD nState) +#define MSG_WM_CHANGEUISTATE(func) \ + if (uMsg == WM_CHANGEUISTATE) \ + { \ + this->SetMsgHandled(TRUE); \ + func(LOWORD(wParam), HIWORD(wParam)); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnUpdateUIState(WORD nAction, WORD nState) +#define MSG_WM_UPDATEUISTATE(func) \ + if (uMsg == WM_UPDATEUISTATE) \ + { \ + this->SetMsgHandled(TRUE); \ + func(LOWORD(wParam), HIWORD(wParam)); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// LRESULT OnQueryUIState() +#define MSG_WM_QUERYUISTATE(func) \ + if (uMsg == WM_QUERYUISTATE) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = func(); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnInput(WPARAM RawInputCode, HRAWINPUT hRawInput) +#define MSG_WM_INPUT(func) \ + if (uMsg == WM_INPUT) \ + { \ + this->SetMsgHandled(TRUE); \ + func(GET_RAWINPUT_CODE_WPARAM(wParam), (HRAWINPUT)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnUniChar(TCHAR nChar, UINT nRepCnt, UINT nFlags) +#define MSG_WM_UNICHAR(func) \ + if (uMsg == WM_UNICHAR) \ + { \ + this->SetMsgHandled(TRUE); \ + func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \ + if(this->IsMsgHandled()) \ + { \ + lResult = (wParam == UNICODE_NOCHAR) ? TRUE : FALSE; \ + return TRUE; \ + } \ + } + +// void OnWTSSessionChange(WPARAM nStatusCode, DWORD dwSessionID) +#define MSG_WM_WTSSESSION_CHANGE(func) \ + if (uMsg == WM_WTSSESSION_CHANGE) \ + { \ + this->SetMsgHandled(TRUE); \ + func(wParam, (DWORD)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnThemeChanged() +#define MSG_WM_THEMECHANGED(func) \ + if (uMsg == WM_THEMECHANGED) \ + { \ + this->SetMsgHandled(TRUE); \ + func(); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +#if (_WIN32_WINNT >= 0x0600) + +// BOOL OnMouseHWheel(UINT nFlags, short zDelta, CPoint pt) +#define MSG_WM_MOUSEHWHEEL(func) \ + if (uMsg == WM_MOUSEHWHEEL) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func((UINT)LOWORD(wParam), (short)HIWORD(wParam), ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +#endif // (_WIN32_WINNT >= 0x0600) + +#if (WINVER >= 0x0601) + +// void OnGesture(ULONGLONG ullArguments, HGESTUREINFO hGestureInfo) +#define MSG_WM_GESTURE(func) \ + if (uMsg == WM_GESTURE) \ + { \ + this->SetMsgHandled(TRUE); \ + func((ULONGLONG)wParam, (HGESTUREINFO)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnGestureNotify(PGESTURENOTIFYSTRUCT pGestureNotifyStruct) +#define MSG_WM_GESTURENOTIFY(func) \ + if (uMsg == WM_GESTURENOTIFY) \ + { \ + func((PGESTURENOTIFYSTRUCT)lParam); \ + } + +// void OnDpiChanged(UINT nDpiX, UINT nDpiY, PRECT pRect) +#define MSG_WM_DPICHANGED(func) \ + if (uMsg == WM_DPICHANGED) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), (PRECT)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +#endif // (WINVER >= 0x0601) + +/////////////////////////////////////////////////////////////////////////////// +// ATL defined messages + +// BOOL OnForwardMsg(LPMSG Msg, DWORD nUserData) +#define MSG_WM_FORWARDMSG(func) \ + if (uMsg == WM_FORWARDMSG) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func((LPMSG)lParam, (DWORD)wParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +/////////////////////////////////////////////////////////////////////////////// +// Dialog specific messages + +// LRESULT OnDMGetDefID() +#define MSG_DM_GETDEFID(func) \ + if (uMsg == DM_GETDEFID) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = func(); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnDMSetDefID(UINT DefID) +#define MSG_DM_SETDEFID(func) \ + if (uMsg == DM_SETDEFID) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam); \ + lResult = TRUE; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnDMReposition() +#define MSG_DM_REPOSITION(func) \ + if (uMsg == DM_REPOSITION) \ + { \ + this->SetMsgHandled(TRUE); \ + func(); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +/////////////////////////////////////////////////////////////////////////////// +// Reflected messages + +// void OnReflectedCommand(UINT uNotifyCode, int nID, CWindow wndCtl) +#define MSG_OCM_COMMAND(func) \ + if (uMsg == OCM_COMMAND) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// LRESULT OnReflectedNotify(int idCtrl, LPNMHDR pnmh) +#define MSG_OCM_NOTIFY(func) \ + if (uMsg == OCM_NOTIFY) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = func((int)wParam, (LPNMHDR)lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnReflectedParentNotify(UINT message, UINT nChildID, LPARAM lParam) +#define MSG_OCM_PARENTNOTIFY(func) \ + if (uMsg == OCM_PARENTNOTIFY) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnReflectedDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct) +#define MSG_OCM_DRAWITEM(func) \ + if (uMsg == OCM_DRAWITEM) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, (LPDRAWITEMSTRUCT)lParam); \ + lResult = TRUE; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnReflectedMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct) +#define MSG_OCM_MEASUREITEM(func) \ + if (uMsg == OCM_MEASUREITEM) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, (LPMEASUREITEMSTRUCT)lParam); \ + lResult = TRUE; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// int OnReflectedCompareItem(int nIDCtl, LPCOMPAREITEMSTRUCT lpCompareItemStruct) +#define MSG_OCM_COMPAREITEM(func) \ + if (uMsg == OCM_COMPAREITEM) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func((UINT)wParam, (LPCOMPAREITEMSTRUCT)lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnReflectedDeleteItem(int nIDCtl, LPDELETEITEMSTRUCT lpDeleteItemStruct) +#define MSG_OCM_DELETEITEM(func) \ + if (uMsg == OCM_DELETEITEM) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)wParam, (LPDELETEITEMSTRUCT)lParam); \ + lResult = TRUE; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// int OnReflectedVKeyToItem(UINT nKey, UINT nIndex, CListBox listBox) +#define MSG_OCM_VKEYTOITEM(func) \ + if (uMsg == OCM_VKEYTOITEM) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), (HWND)lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +//int OnReflectedCharToItem(UINT nChar, UINT nIndex, CListBox listBox) +#define MSG_OCM_CHARTOITEM(func) \ + if (uMsg == OCM_CHARTOITEM) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), (HWND)lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnReflectedHScroll(UINT nSBCode, UINT nPos, CScrollBar pScrollBar) +#define MSG_OCM_HSCROLL(func) \ + if (uMsg == OCM_HSCROLL) \ + { \ + this->SetMsgHandled(TRUE); \ + func((int)LOWORD(wParam), (short)HIWORD(wParam), (HWND)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnReflectedVScroll(UINT nSBCode, UINT nPos, CScrollBar pScrollBar) +#define MSG_OCM_VSCROLL(func) \ + if (uMsg == OCM_VSCROLL) \ + { \ + this->SetMsgHandled(TRUE); \ + func((int)LOWORD(wParam), (short)HIWORD(wParam), (HWND)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// HBRUSH OnReflectedCtlColorEdit(CDCHandle dc, CEdit edit) +#define MSG_OCM_CTLCOLOREDIT(func) \ + if (uMsg == OCM_CTLCOLOREDIT) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// HBRUSH OnReflectedCtlColorListBox(CDCHandle dc, CListBox listBox) +#define MSG_OCM_CTLCOLORLISTBOX(func) \ + if (uMsg == OCM_CTLCOLORLISTBOX) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// HBRUSH OnReflectedCtlColorBtn(CDCHandle dc, CButton button) +#define MSG_OCM_CTLCOLORBTN(func) \ + if (uMsg == OCM_CTLCOLORBTN) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// HBRUSH OnReflectedCtlColorDlg(CDCHandle dc, CWindow wnd) +#define MSG_OCM_CTLCOLORDLG(func) \ + if (uMsg == OCM_CTLCOLORDLG) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// HBRUSH OnReflectedCtlColorScrollBar(CDCHandle dc, CScrollBar scrollBar) +#define MSG_OCM_CTLCOLORSCROLLBAR(func) \ + if (uMsg == OCM_CTLCOLORSCROLLBAR) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// HBRUSH OnReflectedCtlColorStatic(CDCHandle dc, CStatic wndStatic) +#define MSG_OCM_CTLCOLORSTATIC(func) \ + if (uMsg == OCM_CTLCOLORSTATIC) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +/////////////////////////////////////////////////////////////////////////////// +// Edit specific messages + +// void OnClear() +#define MSG_WM_CLEAR(func) \ + if (uMsg == WM_CLEAR) \ + { \ + this->SetMsgHandled(TRUE); \ + func(); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnCopy() +#define MSG_WM_COPY(func) \ + if (uMsg == WM_COPY) \ + { \ + this->SetMsgHandled(TRUE); \ + func(); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnCut() +#define MSG_WM_CUT(func) \ + if (uMsg == WM_CUT) \ + { \ + this->SetMsgHandled(TRUE); \ + func(); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnPaste() +#define MSG_WM_PASTE(func) \ + if (uMsg == WM_PASTE) \ + { \ + this->SetMsgHandled(TRUE); \ + func(); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnUndo() +#define MSG_WM_UNDO(func) \ + if (uMsg == WM_UNDO) \ + { \ + this->SetMsgHandled(TRUE); \ + func(); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +/////////////////////////////////////////////////////////////////////////////// +// Generic message handlers + +// LRESULT OnMessageHandlerEX(UINT uMsg, WPARAM wParam, LPARAM lParam) +#define MESSAGE_HANDLER_EX(msg, func) \ + if(uMsg == msg) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = func(uMsg, wParam, lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// LRESULT OnMessageRangeHandlerEX(UINT uMsg, WPARAM wParam, LPARAM lParam) +#define MESSAGE_RANGE_HANDLER_EX(msgFirst, msgLast, func) \ + if((uMsg >= msgFirst) && (uMsg <= msgLast)) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = func(uMsg, wParam, lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +/////////////////////////////////////////////////////////////////////////////// +// Commands and notifications + +// void OnCommandHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl) +#define COMMAND_HANDLER_EX(id, code, func) \ + if ((uMsg == WM_COMMAND) && (code == HIWORD(wParam)) && (id == LOWORD(wParam))) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnCommandIDHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl) +#define COMMAND_ID_HANDLER_EX(id, func) \ + if ((uMsg == WM_COMMAND) && (id == LOWORD(wParam))) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnCommandCodeHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl) +#define COMMAND_CODE_HANDLER_EX(code, func) \ + if ((uMsg == WM_COMMAND) && (code == HIWORD(wParam))) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// LRESULT OnNotifyHandlerEX(LPNMHDR pnmh) +#define NOTIFY_HANDLER_EX(id, cd, func) \ + if ((uMsg == WM_NOTIFY) && (cd == ((LPNMHDR)lParam)->code) && (id == ((LPNMHDR)lParam)->idFrom)) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = func((LPNMHDR)lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// LRESULT OnNotifyIDHandlerEX(LPNMHDR pnmh) +#define NOTIFY_ID_HANDLER_EX(id, func) \ + if ((uMsg == WM_NOTIFY) && (id == ((LPNMHDR)lParam)->idFrom)) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = func((LPNMHDR)lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// LRESULT OnNotifyCodeHandlerEX(LPNMHDR pnmh) +#define NOTIFY_CODE_HANDLER_EX(cd, func) \ + if ((uMsg == WM_NOTIFY) && (cd == ((LPNMHDR)lParam)->code)) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = func((LPNMHDR)lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnCommandRangeHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl) +#define COMMAND_RANGE_HANDLER_EX(idFirst, idLast, func) \ + if((uMsg == WM_COMMAND) && (LOWORD(wParam) >= idFirst) && (LOWORD(wParam) <= idLast)) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnCommandRangeCodeHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl) +#define COMMAND_RANGE_CODE_HANDLER_EX(idFirst, idLast, code, func) \ + if((uMsg == WM_COMMAND) && (code == HIWORD(wParam)) && (LOWORD(wParam) >= idFirst) && (LOWORD(wParam) <= idLast)) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// LRESULT OnNotifyRangeHandlerEX(LPNMHDR pnmh) +#define NOTIFY_RANGE_HANDLER_EX(idFirst, idLast, func) \ + if((uMsg == WM_NOTIFY) && (((LPNMHDR)lParam)->idFrom >= idFirst) && (((LPNMHDR)lParam)->idFrom <= idLast)) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = func((LPNMHDR)lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// LRESULT OnNotifyRangeCodeHandlerEX(LPNMHDR pnmh) +#define NOTIFY_RANGE_CODE_HANDLER_EX(idFirst, idLast, cd, func) \ + if((uMsg == WM_NOTIFY) && (cd == ((LPNMHDR)lParam)->code) && (((LPNMHDR)lParam)->idFrom >= idFirst) && (((LPNMHDR)lParam)->idFrom <= idLast)) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = func((LPNMHDR)lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// LRESULT OnReflectedCommandHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl) +#define REFLECTED_COMMAND_HANDLER_EX(id, code, func) \ + if ((uMsg == OCM_COMMAND) && (code == HIWORD(wParam)) && (id == LOWORD(wParam))) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// LRESULT OnReflectedCommandIDHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl) +#define REFLECTED_COMMAND_ID_HANDLER_EX(id, func) \ + if ((uMsg == OCM_COMMAND) && (id == LOWORD(wParam))) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// LRESULT OnReflectedCommandCodeHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl) +#define REFLECTED_COMMAND_CODE_HANDLER_EX(code, func) \ + if ((uMsg == OCM_COMMAND) && (code == HIWORD(wParam))) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// LRESULT OnReflectedNotifyHandlerEX(LPNMHDR pnmh) +#define REFLECTED_NOTIFY_HANDLER_EX(id, cd, func) \ + if ((uMsg == OCM_NOTIFY) && (cd == ((LPNMHDR)lParam)->code) && (id == ((LPNMHDR)lParam)->idFrom)) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = func((LPNMHDR)lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// LRESULT OnReflectedNotifyIDHandlerEX(LPNMHDR pnmh) +#define REFLECTED_NOTIFY_ID_HANDLER_EX(id, func) \ + if ((uMsg == OCM_NOTIFY) && (id == ((LPNMHDR)lParam)->idFrom)) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = func((LPNMHDR)lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// LRESULT OnReflectedNotifyCodeHandlerEX(LPNMHDR pnmh) +#define REFLECTED_NOTIFY_CODE_HANDLER_EX(cd, func) \ + if ((uMsg == OCM_NOTIFY) && (cd == ((LPNMHDR)lParam)->code)) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = func((LPNMHDR)lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnReflectedCommandRangeHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl) +#define REFLECTED_COMMAND_RANGE_HANDLER_EX(idFirst, idLast, func) \ + if((uMsg == OCM_COMMAND) && (LOWORD(wParam) >= idFirst) && (LOWORD(wParam) <= idLast)) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnReflectedCommandRangeCodeHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl) +#define REFLECTED_COMMAND_RANGE_CODE_HANDLER_EX(idFirst, idLast, code, func) \ + if((uMsg == OCM_COMMAND) && (code == HIWORD(wParam)) && (LOWORD(wParam) >= idFirst) && (LOWORD(wParam) <= idLast)) \ + { \ + this->SetMsgHandled(TRUE); \ + func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \ + lResult = 0; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// LRESULT OnReflectedNotifyRangeHandlerEX(LPNMHDR pnmh) +#define REFLECTED_NOTIFY_RANGE_HANDLER_EX(idFirst, idLast, func) \ + if((uMsg == OCM_NOTIFY) && (((LPNMHDR)lParam)->idFrom >= idFirst) && (((LPNMHDR)lParam)->idFrom <= idLast)) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = func((LPNMHDR)lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// LRESULT OnReflectedNotifyRangeCodeHandlerEX(LPNMHDR pnmh) +#define REFLECTED_NOTIFY_RANGE_CODE_HANDLER_EX(idFirst, idLast, cd, func) \ + if((uMsg == OCM_NOTIFY) && (cd == ((LPNMHDR)lParam)->code) && (((LPNMHDR)lParam)->idFrom >= idFirst) && (((LPNMHDR)lParam)->idFrom <= idLast)) \ + { \ + this->SetMsgHandled(TRUE); \ + lResult = func((LPNMHDR)lParam); \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +// void OnAppCommandHandler(UINT uDevice, DWORD dwKeys, CWindow wndFocus) +#define APPCOMMAND_HANDLER_EX(cmd, func) \ + if((uMsg == WM_APPCOMMAND) && (cmd == GET_APPCOMMAND_LPARAM(lParam))) \ + { \ + this->SetMsgHandled(TRUE); \ + func(GET_DEVICE_LPARAM(lParam), GET_KEYSTATE_LPARAM(lParam), (HWND)wParam); \ + lResult = TRUE; \ + if(this->IsMsgHandled()) \ + return TRUE; \ + } + +#endif // __ATLCRACK_H__ diff -r e9bb126753e7 -r 20d02a178406 foosdk/wtl/Include/atlctrls.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/wtl/Include/atlctrls.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,9731 @@ +// Windows Template Library - WTL version 10.0 +// Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. +// +// This file is a part of the Windows Template Library. +// The use and distribution terms for this software are covered by the +// Microsoft Public License (http://opensource.org/licenses/MS-PL) +// which can be found in the file MS-PL.txt at the root folder. + +#ifndef __ATLCTRLS_H__ +#define __ATLCTRLS_H__ + +#pragma once + +#ifndef __ATLAPP_H__ + #error atlctrls.h requires atlapp.h to be included first +#endif + +#ifndef __ATLWIN_H__ + #error atlctrls.h requires atlwin.h to be included first +#endif + +#include +#include + +#if (_RICHEDIT_VER < 0x0300) + #error WTL10 requires RichEdit version 3 or higher +#endif + +// protect template members from windowsx.h macros +#ifdef _INC_WINDOWSX + #undef GetNextSibling + #undef GetPrevSibling +#endif // _INC_WINDOWSX + + +/////////////////////////////////////////////////////////////////////////////// +// Classes in this file: +// +// CStaticT - CStatic +// CButtonT - CButton +// CListBoxT - CListBox +// CComboBoxT - CComboBox +// CEditT - CEdit +// CEditCommands +// CScrollBarT - CScrollBar +// +// CImageListT - CImageList, CImageListManaged +// CListViewCtrlT - CListViewCtrl +// CTreeViewCtrlT - CTreeViewCtrl +// CTreeItemT - CTreeItem +// CTreeViewCtrlExT - CTreeViewCtrlEx +// CHeaderCtrlT - CHeaderCtrl +// CToolBarCtrlT - CToolBarCtrl +// CStatusBarCtrlT - CStatusBarCtrl +// CTabCtrlT - CTabCtrl +// CToolInfo +// CToolTipCtrlT - CToolTipCtrl +// CTrackBarCtrlT - CTrackBarCtrl +// CUpDownCtrlT - CUpDownCtrl +// CProgressBarCtrlT - CProgressBarCtrl +// CHotKeyCtrlT - CHotKeyCtrl +// CAnimateCtrlT - CAnimateCtrl +// CRichEditCtrlT - CRichEditCtrl +// CRichEditCommands +// CDragListBoxT - CDragListBox +// CDragListNotifyImpl +// CReBarCtrlT - CReBarCtrl +// CComboBoxExT - CComboBoxEx +// CDateTimePickerCtrlT - CDateTimePickerCtrl +// CMonthCalendarCtrlT - CMonthCalendarCtrl +// CFlatScrollBarImpl +// CFlatScrollBarT - CFlatScrollBar +// CIPAddressCtrlT - CIPAddressCtrl +// CPagerCtrlT - CPagerCtrl +// CLinkCtrlT - CLinkCtrl +// +// CCustomDraw + + +namespace WTL +{ + +// These are wrapper classes for Windows standard and common controls. +// To implement a window based on a control, use following: +// Example: Implementing a window based on a list box +// +// class CMyListBox : CWindowImpl +// { +// public: +// BEGIN_MSG_MAP(CMyListBox) +// // put your message handler entries here +// END_MSG_MAP() +// }; + + + +// --- Standard Windows controls --- + +/////////////////////////////////////////////////////////////////////////////// +// CStatic - client side for a Windows STATIC control + +template +class CStaticT : public TBase +{ +public: +// Constructors + CStaticT(HWND hWnd = NULL) : TBase(hWnd) + { } + + CStaticT< TBase >& operator =(HWND hWnd) + { + this->m_hWnd = hWnd; + return *this; + } + + HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, + DWORD dwStyle = 0, DWORD dwExStyle = 0, + ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) + { + return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); + } + +// Attributes + static LPCTSTR GetWndClassName() + { + return _T("STATIC"); + } + + HICON GetIcon() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HICON)::SendMessage(this->m_hWnd, STM_GETICON, 0, 0L); + } + + HICON SetIcon(HICON hIcon) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HICON)::SendMessage(this->m_hWnd, STM_SETICON, (WPARAM)hIcon, 0L); + } + + HENHMETAFILE GetEnhMetaFile() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HENHMETAFILE)::SendMessage(this->m_hWnd, STM_GETIMAGE, IMAGE_ENHMETAFILE, 0L); + } + + HENHMETAFILE SetEnhMetaFile(HENHMETAFILE hMetaFile) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HENHMETAFILE)::SendMessage(this->m_hWnd, STM_SETIMAGE, IMAGE_ENHMETAFILE, (LPARAM)hMetaFile); + } + + CBitmapHandle GetBitmap() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return CBitmapHandle((HBITMAP)::SendMessage(this->m_hWnd, STM_GETIMAGE, IMAGE_BITMAP, 0L)); + } + + CBitmapHandle SetBitmap(HBITMAP hBitmap) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return CBitmapHandle((HBITMAP)::SendMessage(this->m_hWnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBitmap)); + } + + HCURSOR GetCursor() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HCURSOR)::SendMessage(this->m_hWnd, STM_GETIMAGE, IMAGE_CURSOR, 0L); + } + + HCURSOR SetCursor(HCURSOR hCursor) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HCURSOR)::SendMessage(this->m_hWnd, STM_SETIMAGE, IMAGE_CURSOR, (LPARAM)hCursor); + } +}; + +typedef CStaticT CStatic; + + +/////////////////////////////////////////////////////////////////////////////// +// CButton - client side for a Windows BUTTON control + +template +class CButtonT : public TBase +{ +public: +// Constructors + CButtonT(HWND hWnd = NULL) : TBase(hWnd) + { } + + CButtonT< TBase >& operator =(HWND hWnd) + { + this->m_hWnd = hWnd; + return *this; + } + + HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, + DWORD dwStyle = 0, DWORD dwExStyle = 0, + ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) + { + return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); + } + +// Attributes + static LPCTSTR GetWndClassName() + { + return _T("BUTTON"); + } + + UINT GetState() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, BM_GETSTATE, 0, 0L); + } + + void SetState(BOOL bHighlight) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, BM_SETSTATE, bHighlight, 0L); + } + + int GetCheck() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, BM_GETCHECK, 0, 0L); + } + + void SetCheck(int nCheck) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, BM_SETCHECK, nCheck, 0L); + } + + UINT GetButtonStyle() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::GetWindowLong(this->m_hWnd, GWL_STYLE) & 0xFFFF; + } + + void SetButtonStyle(UINT nStyle, BOOL bRedraw = TRUE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, BM_SETSTYLE, nStyle, (LPARAM)bRedraw); + } + + HICON GetIcon() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HICON)::SendMessage(this->m_hWnd, BM_GETIMAGE, IMAGE_ICON, 0L); + } + + HICON SetIcon(HICON hIcon) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HICON)::SendMessage(this->m_hWnd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); + } + + CBitmapHandle GetBitmap() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return CBitmapHandle((HBITMAP)::SendMessage(this->m_hWnd, BM_GETIMAGE, IMAGE_BITMAP, 0L)); + } + + CBitmapHandle SetBitmap(HBITMAP hBitmap) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return CBitmapHandle((HBITMAP)::SendMessage(this->m_hWnd, BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBitmap)); + } + + BOOL GetIdealSize(LPSIZE lpSize) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, BCM_GETIDEALSIZE, 0, (LPARAM)lpSize); + } + + BOOL GetImageList(PBUTTON_IMAGELIST pButtonImagelist) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, BCM_GETIMAGELIST, 0, (LPARAM)pButtonImagelist); + } + + BOOL SetImageList(PBUTTON_IMAGELIST pButtonImagelist) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, BCM_SETIMAGELIST, 0, (LPARAM)pButtonImagelist); + } + + BOOL GetTextMargin(LPRECT lpRect) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, BCM_GETTEXTMARGIN, 0, (LPARAM)lpRect); + } + + BOOL SetTextMargin(LPRECT lpRect) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, BCM_SETTEXTMARGIN, 0, (LPARAM)lpRect); + } + +#if (WINVER >= 0x0600) + void SetDontClick(BOOL bDontClick) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, BM_SETDONTCLICK, (WPARAM)bDontClick, 0L); + } +#endif // (WINVER >= 0x0600) + +#if (_WIN32_WINNT >= 0x0600) + BOOL SetDropDownState(BOOL bDropDown) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & (BS_SPLITBUTTON | BS_DEFSPLITBUTTON)) != 0); + return (BOOL)::SendMessage(this->m_hWnd, BCM_SETDROPDOWNSTATE, (WPARAM)bDropDown, 0L); + } + + BOOL GetSplitInfo(PBUTTON_SPLITINFO pSplitInfo) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & (BS_SPLITBUTTON | BS_DEFSPLITBUTTON)) != 0); + return (BOOL)::SendMessage(this->m_hWnd, BCM_GETSPLITINFO, 0, (LPARAM)pSplitInfo); + } + + BOOL SetSplitInfo(PBUTTON_SPLITINFO pSplitInfo) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & (BS_SPLITBUTTON | BS_DEFSPLITBUTTON)) != 0); + return (BOOL)::SendMessage(this->m_hWnd, BCM_SETSPLITINFO, 0, (LPARAM)pSplitInfo); + } + + int GetNoteLength() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & (BS_COMMANDLINK | BS_DEFCOMMANDLINK)) != 0); + return (int)::SendMessage(this->m_hWnd, BCM_GETNOTELENGTH, 0, 0L); + } + + BOOL GetNote(LPWSTR lpstrNoteText, int cchNoteText) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & (BS_COMMANDLINK | BS_DEFCOMMANDLINK)) != 0); + return (BOOL)::SendMessage(this->m_hWnd, BCM_GETNOTE, cchNoteText, (LPARAM)lpstrNoteText); + } + + BOOL SetNote(LPCWSTR lpstrNoteText) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & (BS_COMMANDLINK | BS_DEFCOMMANDLINK)) != 0); + return (BOOL)::SendMessage(this->m_hWnd, BCM_SETNOTE, 0, (LPARAM)lpstrNoteText); + } + + LRESULT SetElevationRequiredState(BOOL bSet) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return ::SendMessage(this->m_hWnd, BCM_SETSHIELD, 0, (LPARAM)bSet); + } +#endif // (_WIN32_WINNT >= 0x0600) + +// Operations + void Click() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, BM_CLICK, 0, 0L); + } +}; + +typedef CButtonT CButton; + + +/////////////////////////////////////////////////////////////////////////////// +// CListBox - client side for a Windows LISTBOX control + +template +class CListBoxT : public TBase +{ +public: +// Constructors + CListBoxT(HWND hWnd = NULL) : TBase(hWnd) + { } + + CListBoxT< TBase >& operator =(HWND hWnd) + { + this->m_hWnd = hWnd; + return *this; + } + + HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, + DWORD dwStyle = 0, DWORD dwExStyle = 0, + ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) + { + return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); + } + +// Attributes + static LPCTSTR GetWndClassName() + { + return _T("LISTBOX"); + } + + // for entire listbox + int GetCount() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_GETCOUNT, 0, 0L); + } + + int SetCount(int cItems) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(((this->GetStyle() & LBS_NODATA) != 0) && ((this->GetStyle() & LBS_HASSTRINGS) == 0)); + return (int)::SendMessage(this->m_hWnd, LB_SETCOUNT, cItems, 0L); + } + + int GetHorizontalExtent() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_GETHORIZONTALEXTENT, 0, 0L); + } + + void SetHorizontalExtent(int cxExtent) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, LB_SETHORIZONTALEXTENT, cxExtent, 0L); + } + + int GetTopIndex() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_GETTOPINDEX, 0, 0L); + } + + int SetTopIndex(int nIndex) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_SETTOPINDEX, nIndex, 0L); + } + + LCID GetLocale() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (LCID)::SendMessage(this->m_hWnd, LB_GETLOCALE, 0, 0L); + } + + LCID SetLocale(LCID nNewLocale) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (LCID)::SendMessage(this->m_hWnd, LB_SETLOCALE, (WPARAM)nNewLocale, 0L); + } + + DWORD GetListBoxInfo() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, LB_GETLISTBOXINFO, 0, 0L); + } + + // for single-selection listboxes + int GetCurSel() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) == 0); + return (int)::SendMessage(this->m_hWnd, LB_GETCURSEL, 0, 0L); + } + + int SetCurSel(int nSelect) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) == 0); + return (int)::SendMessage(this->m_hWnd, LB_SETCURSEL, nSelect, 0L); + } + + // for multiple-selection listboxes + int GetSel(int nIndex) const // also works for single-selection + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_GETSEL, nIndex, 0L); + } + + int SetSel(int nIndex, BOOL bSelect = TRUE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0); + return (int)::SendMessage(this->m_hWnd, LB_SETSEL, bSelect, nIndex); + } + + int GetSelCount() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0); + return (int)::SendMessage(this->m_hWnd, LB_GETSELCOUNT, 0, 0L); + } + + int GetSelItems(int nMaxItems, LPINT rgIndex) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0); + return (int)::SendMessage(this->m_hWnd, LB_GETSELITEMS, nMaxItems, (LPARAM)rgIndex); + } + + int GetAnchorIndex() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0); + return (int)::SendMessage(this->m_hWnd, LB_GETANCHORINDEX, 0, 0L); + } + + void SetAnchorIndex(int nIndex) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0); + ::SendMessage(this->m_hWnd, LB_SETANCHORINDEX, nIndex, 0L); + } + + int GetCaretIndex() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_GETCARETINDEX, 0, 0); + } + + int SetCaretIndex(int nIndex, BOOL bScroll = TRUE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_SETCARETINDEX, nIndex, MAKELONG(bScroll, 0)); + } + + // for listbox items + DWORD_PTR GetItemData(int nIndex) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD_PTR)::SendMessage(this->m_hWnd, LB_GETITEMDATA, nIndex, 0L); + } + + int SetItemData(int nIndex, DWORD_PTR dwItemData) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_SETITEMDATA, nIndex, (LPARAM)dwItemData); + } + + void* GetItemDataPtr(int nIndex) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (void*)::SendMessage(this->m_hWnd, LB_GETITEMDATA, nIndex, 0L); + } + + int SetItemDataPtr(int nIndex, void* pData) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return SetItemData(nIndex, (DWORD_PTR)pData); + } + + int GetItemRect(int nIndex, LPRECT lpRect) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_GETITEMRECT, nIndex, (LPARAM)lpRect); + } + + int GetText(int nIndex, LPTSTR lpszBuffer) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_GETTEXT, nIndex, (LPARAM)lpszBuffer); + } + +#ifdef _OLEAUTO_H_ + BOOL GetTextBSTR(int nIndex, BSTR& bstrText) const + { + USES_CONVERSION; + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(bstrText == NULL); + + int nLen = GetTextLen(nIndex); + if(nLen == LB_ERR) + return FALSE; + + ATL::CTempBuffer buff; + LPTSTR lpstrText = buff.Allocate(nLen + 1); + if(lpstrText == NULL) + return FALSE; + + if(GetText(nIndex, lpstrText) == LB_ERR) + return FALSE; + + bstrText = ::SysAllocString(T2OLE(lpstrText)); + return (bstrText != NULL) ? TRUE : FALSE; + } +#endif // _OLEAUTO_H_ + +#ifdef __ATLSTR_H__ + int GetText(int nIndex, ATL::CString& strText) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + int cchLen = GetTextLen(nIndex); + if(cchLen == LB_ERR) + return LB_ERR; + int nRet = LB_ERR; + LPTSTR lpstr = strText.GetBufferSetLength(cchLen); + if(lpstr != NULL) + { + nRet = GetText(nIndex, lpstr); + strText.ReleaseBuffer(); + } + return nRet; + } +#endif // __ATLSTR_H__ + + int GetTextLen(int nIndex) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_GETTEXTLEN, nIndex, 0L); + } + + int GetItemHeight(int nIndex) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_GETITEMHEIGHT, nIndex, 0L); + } + + int SetItemHeight(int nIndex, UINT cyItemHeight) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_SETITEMHEIGHT, nIndex, MAKELONG(cyItemHeight, 0)); + } + + // Settable only attributes + void SetColumnWidth(int cxWidth) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, LB_SETCOLUMNWIDTH, cxWidth, 0L); + } + + BOOL SetTabStops(int nTabStops, LPINT rgTabStops) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & LBS_USETABSTOPS) != 0); + return (BOOL)::SendMessage(this->m_hWnd, LB_SETTABSTOPS, nTabStops, (LPARAM)rgTabStops); + } + + BOOL SetTabStops() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & LBS_USETABSTOPS) != 0); + return (BOOL)::SendMessage(this->m_hWnd, LB_SETTABSTOPS, 0, 0L); + } + + BOOL SetTabStops(const int& cxEachStop) // takes an 'int' + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & LBS_USETABSTOPS) != 0); + return (BOOL)::SendMessage(this->m_hWnd, LB_SETTABSTOPS, 1, (LPARAM)(LPINT)&cxEachStop); + } + +// Operations + int InitStorage(int nItems, UINT nBytes) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_INITSTORAGE, (WPARAM)nItems, nBytes); + } + + void ResetContent() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, LB_RESETCONTENT, 0, 0L); + } + + UINT ItemFromPoint(POINT pt, BOOL& bOutside) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + DWORD dw = (DWORD)::SendMessage(this->m_hWnd, LB_ITEMFROMPOINT, 0, MAKELPARAM(pt.x, pt.y)); + bOutside = (BOOL)HIWORD(dw); + return (UINT)LOWORD(dw); + } + + // manipulating listbox items + int AddString(LPCTSTR lpszItem) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_ADDSTRING, 0, (LPARAM)lpszItem); + } + + int DeleteString(UINT nIndex) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_DELETESTRING, nIndex, 0L); + } + + int InsertString(int nIndex, LPCTSTR lpszItem) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_INSERTSTRING, nIndex, (LPARAM)lpszItem); + } + + int Dir(UINT attr, LPCTSTR lpszWildCard) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_DIR, attr, (LPARAM)lpszWildCard); + } + + int AddFile(LPCTSTR lpstrFileName) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_ADDFILE, 0, (LPARAM)lpstrFileName); + } + + // selection helpers + int FindString(int nStartAfter, LPCTSTR lpszItem) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_FINDSTRING, nStartAfter, (LPARAM)lpszItem); + } + + int FindStringExact(int nIndexStart, LPCTSTR lpszFind) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_FINDSTRINGEXACT, nIndexStart, (LPARAM)lpszFind); + } + + int SelectString(int nStartAfter, LPCTSTR lpszItem) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LB_SELECTSTRING, nStartAfter, (LPARAM)lpszItem); + } + + int SelItemRange(BOOL bSelect, int nFirstItem, int nLastItem) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0); + ATLASSERT(nFirstItem <= nLastItem); + return bSelect ? (int)::SendMessage(this->m_hWnd, LB_SELITEMRANGEEX, nFirstItem, nLastItem) : (int)::SendMessage(this->m_hWnd, LB_SELITEMRANGEEX, nLastItem, nFirstItem); + } +}; + +typedef CListBoxT CListBox; + + +/////////////////////////////////////////////////////////////////////////////// +// CComboBox - client side for a Windows COMBOBOX control + +template +class CComboBoxT : public TBase +{ +public: +// Constructors + CComboBoxT(HWND hWnd = NULL) : TBase(hWnd) + { } + + CComboBoxT< TBase >& operator =(HWND hWnd) + { + this->m_hWnd = hWnd; + return *this; + } + + HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, + DWORD dwStyle = 0, DWORD dwExStyle = 0, + ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) + { + return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); + } + +// Attributes + static LPCTSTR GetWndClassName() + { + return _T("COMBOBOX"); + } + + // for entire combo box + int GetCount() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_GETCOUNT, 0, 0L); + } + + int GetCurSel() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_GETCURSEL, 0, 0L); + } + + int SetCurSel(int nSelect) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_SETCURSEL, nSelect, 0L); + } + + LCID GetLocale() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (LCID)::SendMessage(this->m_hWnd, CB_GETLOCALE, 0, 0L); + } + + LCID SetLocale(LCID nNewLocale) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (LCID)::SendMessage(this->m_hWnd, CB_SETLOCALE, (WPARAM)nNewLocale, 0L); + } + + int GetTopIndex() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_GETTOPINDEX, 0, 0L); + } + + int SetTopIndex(int nIndex) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_SETTOPINDEX, nIndex, 0L); + } + + UINT GetHorizontalExtent() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, CB_GETHORIZONTALEXTENT, 0, 0L); + } + + void SetHorizontalExtent(UINT nExtent) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, CB_SETHORIZONTALEXTENT, nExtent, 0L); + } + + int GetDroppedWidth() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_GETDROPPEDWIDTH, 0, 0L); + } + + int SetDroppedWidth(UINT nWidth) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_SETDROPPEDWIDTH, nWidth, 0L); + } + + BOOL GetComboBoxInfo(PCOMBOBOXINFO pComboBoxInfo) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, CB_GETCOMBOBOXINFO, 0, (LPARAM)pComboBoxInfo); + } + + // for edit control + DWORD GetEditSel() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, CB_GETEDITSEL, 0, 0L); + } + + BOOL SetEditSel(int nStartChar, int nEndChar) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, CB_SETEDITSEL, 0, MAKELONG(nStartChar, nEndChar)); + } + + // for combobox item + DWORD_PTR GetItemData(int nIndex) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD_PTR)::SendMessage(this->m_hWnd, CB_GETITEMDATA, nIndex, 0L); + } + + int SetItemData(int nIndex, DWORD_PTR dwItemData) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_SETITEMDATA, nIndex, (LPARAM)dwItemData); + } + + void* GetItemDataPtr(int nIndex) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (void*)GetItemData(nIndex); + } + + int SetItemDataPtr(int nIndex, void* pData) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return SetItemData(nIndex, (DWORD_PTR)pData); + } + + int GetLBText(int nIndex, LPTSTR lpszText) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_GETLBTEXT, nIndex, (LPARAM)lpszText); + } + + BOOL GetLBTextBSTR(int nIndex, BSTR& bstrText) const + { + USES_CONVERSION; + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(bstrText == NULL); + + int nLen = GetLBTextLen(nIndex); + if(nLen == CB_ERR) + return FALSE; + + ATL::CTempBuffer buff; + LPTSTR lpstrText = buff.Allocate(nLen + 1); + if(lpstrText == NULL) + return FALSE; + + if(GetLBText(nIndex, lpstrText) == CB_ERR) + return FALSE; + + bstrText = ::SysAllocString(T2OLE(lpstrText)); + return (bstrText != NULL) ? TRUE : FALSE; + } + +#ifdef __ATLSTR_H__ + int GetLBText(int nIndex, ATL::CString& strText) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + int cchLen = GetLBTextLen(nIndex); + if(cchLen == CB_ERR) + return CB_ERR; + int nRet = CB_ERR; + LPTSTR lpstr = strText.GetBufferSetLength(cchLen); + if(lpstr != NULL) + { + nRet = GetLBText(nIndex, lpstr); + strText.ReleaseBuffer(); + } + return nRet; + } +#endif // __ATLSTR_H__ + + int GetLBTextLen(int nIndex) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_GETLBTEXTLEN, nIndex, 0L); + } + + int GetItemHeight(int nIndex) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_GETITEMHEIGHT, nIndex, 0L); + } + + int SetItemHeight(int nIndex, UINT cyItemHeight) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_SETITEMHEIGHT, nIndex, MAKELONG(cyItemHeight, 0)); + } + + BOOL GetExtendedUI() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, CB_GETEXTENDEDUI, 0, 0L); + } + + int SetExtendedUI(BOOL bExtended = TRUE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_SETEXTENDEDUI, bExtended, 0L); + } + + void GetDroppedControlRect(LPRECT lprect) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)lprect); + } + + BOOL GetDroppedState() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, CB_GETDROPPEDSTATE, 0, 0L); + } + + int GetMinVisible() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_GETMINVISIBLE, 0, 0L); + } + + BOOL SetMinVisible(int nMinVisible) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, CB_SETMINVISIBLE, nMinVisible, 0L); + } + + // Vista only + BOOL GetCueBannerText(LPWSTR lpwText, int cchText) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, CB_GETCUEBANNER, (WPARAM)lpwText, cchText); + } + + // Vista only + BOOL SetCueBannerText(LPCWSTR lpcwText) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, CB_SETCUEBANNER, 0, (LPARAM)lpcwText); + } + +// Operations + int InitStorage(int nItems, UINT nBytes) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_INITSTORAGE, (WPARAM)nItems, nBytes); + } + + void ResetContent() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, CB_RESETCONTENT, 0, 0L); + } + + // for edit control + BOOL LimitText(int nMaxChars) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, CB_LIMITTEXT, nMaxChars, 0L); + } + + // for drop-down combo boxes + void ShowDropDown(BOOL bShowIt = TRUE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, CB_SHOWDROPDOWN, bShowIt, 0L); + } + + // manipulating listbox items + int AddString(LPCTSTR lpszString) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_ADDSTRING, 0, (LPARAM)lpszString); + } + + int DeleteString(UINT nIndex) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_DELETESTRING, nIndex, 0L); + } + + int InsertString(int nIndex, LPCTSTR lpszString) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_INSERTSTRING, nIndex, (LPARAM)lpszString); + } + + int Dir(UINT attr, LPCTSTR lpszWildCard) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_DIR, attr, (LPARAM)lpszWildCard); + } + + // selection helpers + int FindString(int nStartAfter, LPCTSTR lpszString) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_FINDSTRING, nStartAfter, (LPARAM)lpszString); + } + + int FindStringExact(int nIndexStart, LPCTSTR lpszFind) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_FINDSTRINGEXACT, nIndexStart, (LPARAM)lpszFind); + } + + int SelectString(int nStartAfter, LPCTSTR lpszString) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CB_SELECTSTRING, nStartAfter, (LPARAM)lpszString); + } + + // Clipboard operations + void Clear() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, WM_CLEAR, 0, 0L); + } + + void Copy() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, WM_COPY, 0, 0L); + } + + void Cut() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, WM_CUT, 0, 0L); + } + + void Paste() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, WM_PASTE, 0, 0L); + } +}; + +typedef CComboBoxT CComboBox; + + +/////////////////////////////////////////////////////////////////////////////// +// CEdit - client side for a Windows EDIT control + +template +class CEditT : public TBase +{ +public: +// Constructors + CEditT(HWND hWnd = NULL) : TBase(hWnd) + { } + + CEditT< TBase >& operator =(HWND hWnd) + { + this->m_hWnd = hWnd; + return *this; + } + + HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, + DWORD dwStyle = 0, DWORD dwExStyle = 0, + ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) + { + return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); + } + +// Attributes + static LPCTSTR GetWndClassName() + { + return _T("EDIT"); + } + + BOOL CanUndo() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_CANUNDO, 0, 0L); + } + + int GetLineCount() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_GETLINECOUNT, 0, 0L); + } + + BOOL GetModify() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_GETMODIFY, 0, 0L); + } + + void SetModify(BOOL bModified = TRUE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETMODIFY, bModified, 0L); + } + + void GetRect(LPRECT lpRect) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_GETRECT, 0, (LPARAM)lpRect); + } + + DWORD GetSel() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, EM_GETSEL, 0, 0L); + } + + void GetSel(int& nStartChar, int& nEndChar) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_GETSEL, (WPARAM)&nStartChar, (LPARAM)&nEndChar); + } + + HLOCAL GetHandle() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HLOCAL)::SendMessage(this->m_hWnd, EM_GETHANDLE, 0, 0L); + } + + void SetHandle(HLOCAL hBuffer) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETHANDLE, (WPARAM)hBuffer, 0L); + } + + DWORD GetMargins() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, EM_GETMARGINS, 0, 0L); + } + + void GetMargins(UINT& nLeft, UINT& nRight) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, EM_GETMARGINS, 0, 0L); + nLeft = LOWORD(dwRet); + nRight = HIWORD(dwRet); + } + + void SetMargins(UINT nLeft, UINT nRight, WORD wFlags = EC_LEFTMARGIN | EC_RIGHTMARGIN) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETMARGINS, wFlags, MAKELONG(nLeft, nRight)); + } + + UINT GetLimitText() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, EM_GETLIMITTEXT, 0, 0L); + } + + void SetLimitText(UINT nMax) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETLIMITTEXT, nMax, 0L); + } + + POINT PosFromChar(UINT nChar) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, EM_POSFROMCHAR, nChar, 0); + POINT point = { GET_X_LPARAM(dwRet), GET_Y_LPARAM(dwRet) }; + return point; + } + + int CharFromPos(POINT pt, int* pLine = NULL) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, EM_CHARFROMPOS, 0, MAKELPARAM(pt.x, pt.y)); + if(pLine != NULL) + *pLine = (int)(short)HIWORD(dwRet); + return (int)(short)LOWORD(dwRet); + } + + // NOTE: first word in lpszBuffer must contain the size of the buffer! + int GetLine(int nIndex, LPTSTR lpszBuffer) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_GETLINE, nIndex, (LPARAM)lpszBuffer); + } + + int GetLine(int nIndex, LPTSTR lpszBuffer, int nMaxLength) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + *(LPWORD)lpszBuffer = (WORD)nMaxLength; + return (int)::SendMessage(this->m_hWnd, EM_GETLINE, nIndex, (LPARAM)lpszBuffer); + } + + TCHAR GetPasswordChar() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (TCHAR)::SendMessage(this->m_hWnd, EM_GETPASSWORDCHAR, 0, 0L); + } + + void SetPasswordChar(TCHAR ch) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETPASSWORDCHAR, ch, 0L); + } + + EDITWORDBREAKPROC GetWordBreakProc() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (EDITWORDBREAKPROC)::SendMessage(this->m_hWnd, EM_GETWORDBREAKPROC, 0, 0L); + } + + void SetWordBreakProc(EDITWORDBREAKPROC ewbprc) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETWORDBREAKPROC, 0, (LPARAM)ewbprc); + } + + int GetFirstVisibleLine() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_GETFIRSTVISIBLELINE, 0, 0L); + } + + int GetThumb() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & ES_MULTILINE) != 0); + return (int)::SendMessage(this->m_hWnd, EM_GETTHUMB, 0, 0L); + } + + BOOL SetReadOnly(BOOL bReadOnly = TRUE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETREADONLY, bReadOnly, 0L); + } + + UINT GetImeStatus(UINT uStatus) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, EM_GETIMESTATUS, uStatus, 0L); + } + + UINT SetImeStatus(UINT uStatus, UINT uData) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, EM_SETIMESTATUS, uStatus, uData); + } + + BOOL GetCueBannerText(LPCWSTR lpstrText, int cchText) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_GETCUEBANNER, (WPARAM)lpstrText, cchText); + } + + // bKeepWithFocus - Vista only + BOOL SetCueBannerText(LPCWSTR lpstrText, BOOL bKeepWithFocus = FALSE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETCUEBANNER, (WPARAM)bKeepWithFocus, (LPARAM)(lpstrText)); + } + +// Operations + void EmptyUndoBuffer() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_EMPTYUNDOBUFFER, 0, 0L); + } + + BOOL FmtLines(BOOL bAddEOL) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_FMTLINES, bAddEOL, 0L); + } + + void LimitText(int nChars = 0) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_LIMITTEXT, nChars, 0L); + } + + int LineFromChar(int nIndex = -1) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_LINEFROMCHAR, nIndex, 0L); + } + + int LineIndex(int nLine = -1) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_LINEINDEX, nLine, 0L); + } + + int LineLength(int nLine = -1) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_LINELENGTH, nLine, 0L); + } + + void LineScroll(int nLines, int nChars = 0) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_LINESCROLL, nChars, nLines); + } + + void ReplaceSel(LPCTSTR lpszNewText, BOOL bCanUndo = FALSE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_REPLACESEL, (WPARAM) bCanUndo, (LPARAM)lpszNewText); + } + + void SetRect(LPCRECT lpRect) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETRECT, 0, (LPARAM)lpRect); + } + + void SetRectNP(LPCRECT lpRect) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETRECTNP, 0, (LPARAM)lpRect); + } + + void SetSel(DWORD dwSelection, BOOL bNoScroll = FALSE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETSEL, LOWORD(dwSelection), HIWORD(dwSelection)); + if(!bNoScroll) + ::SendMessage(this->m_hWnd, EM_SCROLLCARET, 0, 0L); + } + + void SetSel(int nStartChar, int nEndChar, BOOL bNoScroll = FALSE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETSEL, nStartChar, nEndChar); + if(!bNoScroll) + ::SendMessage(this->m_hWnd, EM_SCROLLCARET, 0, 0L); + } + + void SetSelAll(BOOL bNoScroll = FALSE) + { + SetSel(0, -1, bNoScroll); + } + + void SetSelNone(BOOL bNoScroll = FALSE) + { + SetSel(-1, 0, bNoScroll); + } + + BOOL SetTabStops(int nTabStops, LPINT rgTabStops) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETTABSTOPS, nTabStops, (LPARAM)rgTabStops); + } + + BOOL SetTabStops() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETTABSTOPS, 0, 0L); + } + + BOOL SetTabStops(const int& cxEachStop) // takes an 'int' + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETTABSTOPS, 1, (LPARAM)(LPINT)&cxEachStop); + } + + void ScrollCaret() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SCROLLCARET, 0, 0L); + } + + int Scroll(int nScrollAction) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & ES_MULTILINE) != 0); + LRESULT lRet = ::SendMessage(this->m_hWnd, EM_SCROLL, nScrollAction, 0L); + if(!(BOOL)HIWORD(lRet)) + return -1; // failed + return (int)(short)LOWORD(lRet); + + } + + void InsertText(int nInsertAfterChar, LPCTSTR lpstrText, BOOL bNoScroll = FALSE, BOOL bCanUndo = FALSE) + { + SetSel(nInsertAfterChar, nInsertAfterChar, bNoScroll); + ReplaceSel(lpstrText, bCanUndo); + } + + void AppendText(LPCTSTR lpstrText, BOOL bNoScroll = FALSE, BOOL bCanUndo = FALSE) + { + InsertText(this->GetWindowTextLength(), lpstrText, bNoScroll, bCanUndo); + } + + BOOL ShowBalloonTip(PEDITBALLOONTIP pEditBaloonTip) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SHOWBALLOONTIP, 0, (LPARAM)pEditBaloonTip); + } + + BOOL HideBalloonTip() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_HIDEBALLOONTIP, 0, 0L); + } + +#if (_WIN32_WINNT >= 0x0600) + DWORD GetHilite() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, EM_GETHILITE, 0, 0L); + } + + void GetHilite(int& nStartChar, int& nEndChar) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, EM_GETHILITE, 0, 0L); + nStartChar = (int)(short)LOWORD(dwRet); + nEndChar = (int)(short)HIWORD(dwRet); + } + + void SetHilite(int nStartChar, int nEndChar) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETHILITE, nStartChar, nEndChar); + } +#endif // (_WIN32_WINNT >= 0x0600) + + // Clipboard operations + BOOL Undo() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_UNDO, 0, 0L); + } + + void Clear() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, WM_CLEAR, 0, 0L); + } + + void Copy() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, WM_COPY, 0, 0L); + } + + void Cut() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, WM_CUT, 0, 0L); + } + + void Paste() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, WM_PASTE, 0, 0L); + } + + // New messages added in Windows 10.0.17763 +#if defined(NTDDI_VERSION) && defined(NTDDI_WIN10_RS5) && (NTDDI_VERSION >= NTDDI_WIN10_RS5) + DWORD SetExtendedStyle(DWORD dwStyle, DWORD dwMask) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return ::SendMessage(this->m_hWnd, EM_SETEXTENDEDSTYLE, dwMask, dwStyle); + } + + DWORD GetExtendedStyle() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return ::SendMessage(this->m_hWnd, EM_GETEXTENDEDSTYLE, 0, 0L); + } + + BOOL SetEndOfLine(EC_ENDOFLINE eolType) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETENDOFLINE, eolType, 0L); + } + + EC_ENDOFLINE GetEndOfLine() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (EC_ENDOFLINE)::SendMessage(this->m_hWnd, EM_GETENDOFLINE, 0, 0L); + } + + BOOL EnableSearchWeb(BOOL bEnable) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_ENABLESEARCHWEB, (WPARAM)bEnable, 0L); + } + + void SearchWeb() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SEARCHWEB, 0, 0L); + } + + BOOL SetCaretIndex(DWORD dwCaretIndex) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETCARETINDEX, dwCaretIndex, 0L); + } + + DWORD GetCaretIndex() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return ::SendMessage(this->m_hWnd, EM_GETCARETINDEX, 0, 0L); + } + + BOOL GetZoom(int& nNum, int& nDen) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_GETZOOM, (WPARAM)&nNum, (LPARAM)&nDen); + } + + BOOL SetZoom(int nNum, int nDen) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((nNum >= 0) && (nNum <= 64)); + ATLASSERT((nDen >= 0) && (nDen <= 64)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETZOOM, nNum, nDen); + } + + DWORD GetFileLineFromChar(DWORD dwCharIndex) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return ::SendMessage(this->m_hWnd, EM_FILELINEFROMCHAR, dwCharIndex, 0L); + } + + DWORD GetFileLineIndex(DWORD dwLineNum) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return ::SendMessage(this->m_hWnd, EM_FILELINEINDEX, dwLineNum, 0L); + } + + DWORD GetFileLineLength(DWORD dwCharIndex) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return ::SendMessage(this->m_hWnd, EM_FILELINELENGTH, dwCharIndex, 0L); + } + + DWORD GetFileLine(DWORD dwLineNum, LPTSTR lpstrLine, WORD wLen) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + WORD* pw = (WORD*)lpstrLine; + *pw = wLen; + return ::SendMessage(this->m_hWnd, EM_GETFILELINE, dwLineNum, (LPARAM)lpstrLine); + } + +#ifdef __ATLSTR_H__ + ATL::CString GetFileLine(DWORD dwLineNum) const + { + ATL::CString strLine; + DWORD dwCharIndex = GetFileLineIndex(dwLineNum); + if(dwCharIndex != (DWORD)-1) + { + DWORD dwLen = GetFileLineLength(dwCharIndex); + if(dwLen > 0) + { + LPTSTR lpstrLine = strLine.GetBufferSetLength(dwLen); + ATLVERIFY(GetFileLine(dwLineNum, lpstrLine, (WORD)dwLen) == dwLen); + strLine.ReleaseBuffer(); + } + } + + return strLine; + } +#endif // __ATLSTR_H__ + + DWORD GetFileLineCount() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return ::SendMessage(this->m_hWnd, EM_GETFILELINECOUNT, 0, 0L); + } +#endif // defined(NTDDI_VERSION) && defined(NTDDI_WIN10_RS5) && (NTDDI_VERSION >= NTDDI_WIN10_RS5) +}; + +typedef CEditT CEdit; + + +/////////////////////////////////////////////////////////////////////////////// +// CEditCommands - message handlers for standard EDIT commands + +// Chain to CEditCommands message map. Your class must also derive from CEdit. +// Example: +// class CMyEdit : public CWindowImpl, +// public CEditCommands +// { +// public: +// BEGIN_MSG_MAP(CMyEdit) +// // your handlers... +// CHAIN_MSG_MAP_ALT(CEditCommands, 1) +// END_MSG_MAP() +// // other stuff... +// }; + +template +class CEditCommands +{ +public: + BEGIN_MSG_MAP(CEditCommands< T >) + ALT_MSG_MAP(1) + COMMAND_ID_HANDLER(ID_EDIT_CLEAR, OnEditClear) + COMMAND_ID_HANDLER(ID_EDIT_CLEAR_ALL, OnEditClearAll) + COMMAND_ID_HANDLER(ID_EDIT_COPY, OnEditCopy) + COMMAND_ID_HANDLER(ID_EDIT_CUT, OnEditCut) + COMMAND_ID_HANDLER(ID_EDIT_PASTE, OnEditPaste) + COMMAND_ID_HANDLER(ID_EDIT_SELECT_ALL, OnEditSelectAll) + COMMAND_ID_HANDLER(ID_EDIT_UNDO, OnEditUndo) + END_MSG_MAP() + + LRESULT OnEditClear(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) + { + T* pT = static_cast(this); + pT->Clear(); + return 0; + } + + LRESULT OnEditClearAll(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) + { + T* pT = static_cast(this); + pT->SetSel(0, -1); + pT->Clear(); + return 0; + } + + LRESULT OnEditCopy(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) + { + T* pT = static_cast(this); + pT->Copy(); + return 0; + } + + LRESULT OnEditCut(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) + { + T* pT = static_cast(this); + pT->Cut(); + return 0; + } + + LRESULT OnEditPaste(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) + { + T* pT = static_cast(this); + pT->Paste(); + return 0; + } + + LRESULT OnEditSelectAll(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) + { + T* pT = static_cast(this); + pT->SetSel(0, -1); + return 0; + } + + LRESULT OnEditUndo(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) + { + T* pT = static_cast(this); + pT->Undo(); + return 0; + } + +// State (update UI) helpers + BOOL CanCut() const + { return HasSelection(); } + + BOOL CanCopy() const + { return HasSelection(); } + + BOOL CanClear() const + { return HasSelection(); } + + BOOL CanSelectAll() const + { return HasText(); } + + BOOL CanFind() const + { return HasText(); } + + BOOL CanRepeat() const + { return HasText(); } + + BOOL CanReplace() const + { return HasText(); } + + BOOL CanClearAll() const + { return HasText(); } + +// Implementation + BOOL HasSelection() const + { + const T* pT = static_cast(this); + int nMin = 0, nMax = 0; + ::SendMessage(pT->m_hWnd, EM_GETSEL, (WPARAM)&nMin, (LPARAM)&nMax); + return (nMin != nMax); + } + + BOOL HasText() const + { + const T* pT = static_cast(this); + return (pT->GetWindowTextLength() > 0); + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CScrollBar - client side for a Windows SCROLLBAR control + +template +class CScrollBarT : public TBase +{ +public: +// Constructors + CScrollBarT(HWND hWnd = NULL) : TBase(hWnd) + { } + + CScrollBarT< TBase >& operator =(HWND hWnd) + { + this->m_hWnd = hWnd; + return *this; + } + + HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, + DWORD dwStyle = 0, DWORD dwExStyle = 0, + ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) + { + return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); + } + +// Attributes + static LPCTSTR GetWndClassName() + { + return _T("SCROLLBAR"); + } + + int GetScrollPos() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return ::GetScrollPos(this->m_hWnd, SB_CTL); + } + + int SetScrollPos(int nPos, BOOL bRedraw = TRUE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return ::SetScrollPos(this->m_hWnd, SB_CTL, nPos, bRedraw); + } + + void GetScrollRange(LPINT lpMinPos, LPINT lpMaxPos) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::GetScrollRange(this->m_hWnd, SB_CTL, lpMinPos, lpMaxPos); + } + + void SetScrollRange(int nMinPos, int nMaxPos, BOOL bRedraw = TRUE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SetScrollRange(this->m_hWnd, SB_CTL, nMinPos, nMaxPos, bRedraw); + } + + BOOL GetScrollInfo(LPSCROLLINFO lpScrollInfo) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return ::GetScrollInfo(this->m_hWnd, SB_CTL, lpScrollInfo); + } + + int SetScrollInfo(LPSCROLLINFO lpScrollInfo, BOOL bRedraw = TRUE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return ::SetScrollInfo(this->m_hWnd, SB_CTL, lpScrollInfo, bRedraw); + } + + int GetScrollLimit() const + { + SCROLLINFO info = { sizeof(SCROLLINFO), SIF_RANGE | SIF_PAGE }; + ::GetScrollInfo(this->m_hWnd, SB_CTL, &info); + if(info.nPage > 1) + info.nMax -= info.nPage - 1; + + return info.nMax; + } + + BOOL GetScrollBarInfo(PSCROLLBARINFO pScrollBarInfo) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, SBM_GETSCROLLBARINFO, 0, (LPARAM)pScrollBarInfo); + } + +// Operations + void ShowScrollBar(BOOL bShow = TRUE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::ShowScrollBar(this->m_hWnd, SB_CTL, bShow); + } + + BOOL EnableScrollBar(UINT nArrowFlags = ESB_ENABLE_BOTH) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return ::EnableScrollBar(this->m_hWnd, SB_CTL, nArrowFlags); + } +}; + +typedef CScrollBarT CScrollBar; + + +// --- Windows Common Controls --- + +/////////////////////////////////////////////////////////////////////////////// +// CImageList + +// forward declarations +template class CImageListT; +typedef CImageListT CImageList; +typedef CImageListT CImageListManaged; + + +template +class CImageListT +{ +public: +// Data members + HIMAGELIST m_hImageList; + +// Constructor/destructor/operators + CImageListT(HIMAGELIST hImageList = NULL) : m_hImageList(hImageList) + { } + + ~CImageListT() + { + if(t_bManaged && (m_hImageList != NULL)) + Destroy(); + } + + CImageListT& operator =(HIMAGELIST hImageList) + { + Attach(hImageList); + return *this; + } + + void Attach(HIMAGELIST hImageList) + { + if(t_bManaged && (m_hImageList != NULL) && (m_hImageList != hImageList)) + ImageList_Destroy(m_hImageList); + m_hImageList = hImageList; + } + + HIMAGELIST Detach() + { + HIMAGELIST hImageList = m_hImageList; + m_hImageList = NULL; + return hImageList; + } + + operator HIMAGELIST() const { return m_hImageList; } + + bool IsNull() const { return (m_hImageList == NULL); } + +// Attributes + int GetImageCount() const + { + ATLASSERT(m_hImageList != NULL); + return ImageList_GetImageCount(m_hImageList); + } + + COLORREF GetBkColor() const + { + ATLASSERT(m_hImageList != NULL); + return ImageList_GetBkColor(m_hImageList); + } + + COLORREF SetBkColor(COLORREF cr) + { + ATLASSERT(m_hImageList != NULL); + return ImageList_SetBkColor(m_hImageList, cr); + } + + BOOL GetImageInfo(int nImage, IMAGEINFO* pImageInfo) const + { + ATLASSERT(m_hImageList != NULL); + return ImageList_GetImageInfo(m_hImageList, nImage, pImageInfo); + } + + HICON GetIcon(int nIndex, UINT uFlags = ILD_NORMAL) const + { + ATLASSERT(m_hImageList != NULL); + return ImageList_GetIcon(m_hImageList, nIndex, uFlags); + } + + BOOL GetIconSize(int& cx, int& cy) const + { + ATLASSERT(m_hImageList != NULL); + return ImageList_GetIconSize(m_hImageList, &cx, &cy); + } + + BOOL GetIconSize(SIZE& size) const + { + ATLASSERT(m_hImageList != NULL); + return ImageList_GetIconSize(m_hImageList, (int*)&size.cx, (int*)&size.cy); + } + + BOOL SetIconSize(int cx, int cy) + { + ATLASSERT(m_hImageList != NULL); + return ImageList_SetIconSize(m_hImageList, cx, cy); + } + + BOOL SetIconSize(SIZE size) + { + ATLASSERT(m_hImageList != NULL); + return ImageList_SetIconSize(m_hImageList, size.cx, size.cy); + } + + BOOL SetImageCount(UINT uNewCount) + { + ATLASSERT(m_hImageList != NULL); + return ImageList_SetImageCount(m_hImageList, uNewCount); + } + + BOOL SetOverlayImage(int nImage, int nOverlay) + { + ATLASSERT(m_hImageList != NULL); + return ImageList_SetOverlayImage(m_hImageList, nImage, nOverlay); + } + +// Operations + BOOL Create(int cx, int cy, UINT nFlags, int nInitial, int nGrow) + { + ATLASSERT(m_hImageList == NULL); + m_hImageList = ImageList_Create(cx, cy, nFlags, nInitial, nGrow); + return (m_hImageList != NULL) ? TRUE : FALSE; + } + + BOOL Create(ATL::_U_STRINGorID bitmap, int cx, int nGrow, COLORREF crMask) + { + ATLASSERT(m_hImageList == NULL); + m_hImageList = ImageList_LoadBitmap(ModuleHelper::GetResourceInstance(), bitmap.m_lpstr, cx, nGrow, crMask); + return (m_hImageList != NULL) ? TRUE : FALSE; + } + + BOOL CreateFromImage(ATL::_U_STRINGorID image, int cx, int nGrow, COLORREF crMask, UINT uType, UINT uFlags = LR_DEFAULTCOLOR | LR_DEFAULTSIZE) + { + ATLASSERT(m_hImageList == NULL); + m_hImageList = ImageList_LoadImage(ModuleHelper::GetResourceInstance(), image.m_lpstr, cx, nGrow, crMask, uType, uFlags); + return (m_hImageList != NULL) ? TRUE : FALSE; + } + + BOOL Merge(HIMAGELIST hImageList1, int nImage1, HIMAGELIST hImageList2, int nImage2, int dx, int dy) + { + ATLASSERT(m_hImageList == NULL); + m_hImageList = ImageList_Merge(hImageList1, nImage1, hImageList2, nImage2, dx, dy); + return (m_hImageList != NULL) ? TRUE : FALSE; + } + +#ifdef __IStream_INTERFACE_DEFINED__ + BOOL CreateFromStream(LPSTREAM lpStream) + { + ATLASSERT(m_hImageList == NULL); + m_hImageList = ImageList_Read(lpStream); + return (m_hImageList != NULL) ? TRUE : FALSE; + } +#endif // __IStream_INTERFACE_DEFINED__ + + BOOL Destroy() + { + if (m_hImageList == NULL) + return FALSE; + BOOL bRet = ImageList_Destroy(m_hImageList); + if(bRet) + m_hImageList = NULL; + return bRet; + } + + int Add(HBITMAP hBitmap, HBITMAP hBitmapMask = NULL) + { + ATLASSERT(m_hImageList != NULL); + return ImageList_Add(m_hImageList, hBitmap, hBitmapMask); + } + + int Add(HBITMAP hBitmap, COLORREF crMask) + { + ATLASSERT(m_hImageList != NULL); + return ImageList_AddMasked(m_hImageList, hBitmap, crMask); + } + + BOOL Remove(int nImage) + { + ATLASSERT(m_hImageList != NULL); + return ImageList_Remove(m_hImageList, nImage); + } + + BOOL RemoveAll() + { + ATLASSERT(m_hImageList != NULL); + return ImageList_RemoveAll(m_hImageList); + } + + BOOL Replace(int nImage, HBITMAP hBitmap, HBITMAP hBitmapMask) + { + ATLASSERT(m_hImageList != NULL); + return ImageList_Replace(m_hImageList, nImage, hBitmap, hBitmapMask); + } + + int AddIcon(HICON hIcon) + { + ATLASSERT(m_hImageList != NULL); + return ImageList_AddIcon(m_hImageList, hIcon); + } + + int ReplaceIcon(int nImage, HICON hIcon) + { + ATLASSERT(m_hImageList != NULL); + return ImageList_ReplaceIcon(m_hImageList, nImage, hIcon); + } + + HICON ExtractIcon(int nImage) + { + ATLASSERT(m_hImageList != NULL); + return ImageList_ExtractIcon(NULL, m_hImageList, nImage); + } + + BOOL Draw(HDC hDC, int nImage, int x, int y, UINT nStyle) + { + ATLASSERT(m_hImageList != NULL); + ATLASSERT(hDC != NULL); + return ImageList_Draw(m_hImageList, nImage, hDC, x, y, nStyle); + } + + BOOL Draw(HDC hDC, int nImage, POINT pt, UINT nStyle) + { + ATLASSERT(m_hImageList != NULL); + ATLASSERT(hDC != NULL); + return ImageList_Draw(m_hImageList, nImage, hDC, pt.x, pt.y, nStyle); + } + + BOOL DrawEx(int nImage, HDC hDC, int x, int y, int dx, int dy, COLORREF rgbBk, COLORREF rgbFg, UINT fStyle) + { + ATLASSERT(m_hImageList != NULL); + ATLASSERT(hDC != NULL); + return ImageList_DrawEx(m_hImageList, nImage, hDC, x, y, dx, dy, rgbBk, rgbFg, fStyle); + } + + BOOL DrawEx(int nImage, HDC hDC, RECT& rect, COLORREF rgbBk, COLORREF rgbFg, UINT fStyle) + { + ATLASSERT(m_hImageList != NULL); + ATLASSERT(hDC != NULL); + return ImageList_DrawEx(m_hImageList, nImage, hDC, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, rgbBk, rgbFg, fStyle); + } + + static BOOL DrawIndirect(IMAGELISTDRAWPARAMS* pimldp) + { + return ImageList_DrawIndirect(pimldp); + } + + BOOL Copy(int nSrc, int nDst, UINT uFlags = ILCF_MOVE) + { + ATLASSERT(m_hImageList != NULL); + return ImageList_Copy(m_hImageList, nDst, m_hImageList, nSrc, uFlags); + } + +#ifdef __IStream_INTERFACE_DEFINED__ + static HIMAGELIST Read(LPSTREAM lpStream) + { + return ImageList_Read(lpStream); + } + + BOOL Write(LPSTREAM lpStream) + { + ATLASSERT(m_hImageList != NULL); + return ImageList_Write(m_hImageList, lpStream); + } + + static HRESULT ReadEx(DWORD dwFlags, LPSTREAM lpStream, REFIID riid, PVOID* ppv) + { + return ImageList_ReadEx(dwFlags, lpStream, riid, ppv); + } + + HRESULT WriteEx(DWORD dwFlags, LPSTREAM lpStream) + { + ATLASSERT(m_hImageList != NULL); + return ImageList_WriteEx(m_hImageList, dwFlags, lpStream); + } +#endif // __IStream_INTERFACE_DEFINED__ + + // Drag operations + BOOL BeginDrag(int nImage, POINT ptHotSpot) + { + ATLASSERT(m_hImageList != NULL); + return ImageList_BeginDrag(m_hImageList, nImage, ptHotSpot.x, ptHotSpot.y); + } + + BOOL BeginDrag(int nImage, int xHotSpot, int yHotSpot) + { + ATLASSERT(m_hImageList != NULL); + return ImageList_BeginDrag(m_hImageList, nImage, xHotSpot, yHotSpot); + } + + static void EndDrag() + { + ImageList_EndDrag(); + } + + static BOOL DragMove(POINT pt) + { + return ImageList_DragMove(pt.x, pt.y); + } + + static BOOL DragMove(int x, int y) + { + return ImageList_DragMove(x, y); + } + + BOOL SetDragCursorImage(int nDrag, POINT ptHotSpot) + { + ATLASSERT(m_hImageList != NULL); + return ImageList_SetDragCursorImage(m_hImageList, nDrag, ptHotSpot.x, ptHotSpot.y); + } + + BOOL SetDragCursorImage(int nDrag, int xHotSpot, int yHotSpot) + { + ATLASSERT(m_hImageList != NULL); + return ImageList_SetDragCursorImage(m_hImageList, nDrag, xHotSpot, yHotSpot); + } + + static BOOL DragShowNolock(BOOL bShow = TRUE) + { + return ImageList_DragShowNolock(bShow); + } + + static CImageList GetDragImage(LPPOINT lpPoint, LPPOINT lpPointHotSpot) + { + return CImageList(ImageList_GetDragImage(lpPoint, lpPointHotSpot)); + } + + static BOOL DragEnter(HWND hWnd, POINT point) + { + return ImageList_DragEnter(hWnd, point.x, point.y); + } + + static BOOL DragEnter(HWND hWnd, int x, int y) + { + return ImageList_DragEnter(hWnd, x, y); + } + + static BOOL DragLeave(HWND hWnd) + { + return ImageList_DragLeave(hWnd); + } + + CImageList Duplicate() const + { + ATLASSERT(m_hImageList != NULL); + return CImageList(ImageList_Duplicate(m_hImageList)); + } + + static CImageList Duplicate(HIMAGELIST hImageList) + { + ATLASSERT(hImageList != NULL); + return CImageList(ImageList_Duplicate(hImageList)); + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CToolTipCtrl + +class CToolInfo : public TOOLINFO +{ +public: + CToolInfo(UINT nFlags, HWND hWnd, UINT_PTR nIDTool = 0, LPRECT lpRect = NULL, LPTSTR lpstrText = LPSTR_TEXTCALLBACK, LPARAM lUserParam = NULL) + { + Init(nFlags, hWnd, nIDTool, lpRect, lpstrText, lUserParam); + } + + operator LPTOOLINFO() { return this; } + + operator LPARAM() { return (LPARAM)this; } + + void Init(UINT nFlags, HWND hWnd, UINT_PTR nIDTool = 0, LPRECT lpRect = NULL, LPTSTR lpstrText = LPSTR_TEXTCALLBACK, LPARAM lUserParam = NULL) + { + ATLASSERT(::IsWindow(hWnd)); + memset(this, 0, sizeof(TOOLINFO)); + cbSize = RunTimeHelper::SizeOf_TOOLINFO(); + uFlags = nFlags; + if(nIDTool == 0) + { + hwnd = ::GetParent(hWnd); + uFlags |= TTF_IDISHWND; + uId = (UINT_PTR)hWnd; + } + else + { + hwnd = hWnd; + uId = nIDTool; + } + if(lpRect != NULL) + rect = *lpRect; + hinst = ModuleHelper::GetResourceInstance(); + lpszText = lpstrText; + lParam = lUserParam; + } +}; + +template +class CToolTipCtrlT : public TBase +{ +public: +// Constructors + CToolTipCtrlT(HWND hWnd = NULL) : TBase(hWnd) + { } + + CToolTipCtrlT< TBase >& operator =(HWND hWnd) + { + this->m_hWnd = hWnd; + return *this; + } + + HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, + DWORD dwStyle = 0, DWORD dwExStyle = 0, + ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) + { + return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); + } + +// Attributes + static LPCTSTR GetWndClassName() + { + return TOOLTIPS_CLASS; + } + + void GetText(LPTOOLINFO lpToolInfo) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_GETTEXT, 0, (LPARAM)&lpToolInfo); + } + + void GetText(LPTSTR lpstrText, HWND hWnd, UINT_PTR nIDTool = 0) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(hWnd != NULL); + CToolInfo ti(0, hWnd, nIDTool, NULL, lpstrText); + ::SendMessage(this->m_hWnd, TTM_GETTEXT, 0, ti); + } + + BOOL GetToolInfo(LPTOOLINFO lpToolInfo) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TTM_GETTOOLINFO, 0, (LPARAM)lpToolInfo); + } + + BOOL GetToolInfo(HWND hWnd, UINT_PTR nIDTool, UINT* puFlags, LPRECT lpRect, LPTSTR lpstrText) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(hWnd != NULL); + ATLASSERT(puFlags != NULL); + ATLASSERT(lpRect != NULL); + CToolInfo ti(0, hWnd, nIDTool, NULL, lpstrText); + BOOL bRet = (BOOL)::SendMessage(this->m_hWnd, TTM_GETTOOLINFO, 0, ti); + if(bRet != FALSE) + { + *puFlags = ti.uFlags; + *lpRect = ti.rect; + } + return bRet; + } + + void SetToolInfo(LPTOOLINFO lpToolInfo) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_SETTOOLINFO, 0, (LPARAM)lpToolInfo); + } + + void SetToolRect(LPTOOLINFO lpToolInfo) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_NEWTOOLRECT, 0, (LPARAM)lpToolInfo); + } + + void SetToolRect(HWND hWnd, UINT_PTR nIDTool, LPCRECT lpRect) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(hWnd != NULL); + ATLASSERT(nIDTool != 0); + + CToolInfo ti(0, hWnd, nIDTool, (LPRECT)lpRect, NULL); + ::SendMessage(this->m_hWnd, TTM_NEWTOOLRECT, 0, ti); + } + + int GetToolCount() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TTM_GETTOOLCOUNT, 0, 0L); + } + + int GetDelayTime(DWORD dwType) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TTM_GETDELAYTIME, dwType, 0L); + } + + void SetDelayTime(DWORD dwType, int nTime) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_SETDELAYTIME, dwType, MAKELPARAM(nTime, 0)); + } + + void GetMargin(LPRECT lpRect) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_GETMARGIN, 0, (LPARAM)lpRect); + } + + void SetMargin(LPRECT lpRect) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_SETMARGIN, 0, (LPARAM)lpRect); + } + + int GetMaxTipWidth() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TTM_GETMAXTIPWIDTH, 0, 0L); + } + + int SetMaxTipWidth(int nWidth) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TTM_SETMAXTIPWIDTH, 0, nWidth); + } + + COLORREF GetTipBkColor() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, TTM_GETTIPBKCOLOR, 0, 0L); + } + + void SetTipBkColor(COLORREF clr) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_SETTIPBKCOLOR, (WPARAM)clr, 0L); + } + + COLORREF GetTipTextColor() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, TTM_GETTIPTEXTCOLOR, 0, 0L); + } + + void SetTipTextColor(COLORREF clr) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_SETTIPTEXTCOLOR, (WPARAM)clr, 0L); + } + + BOOL GetCurrentTool(LPTOOLINFO lpToolInfo) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TTM_GETCURRENTTOOL, 0, (LPARAM)lpToolInfo); + } + + SIZE GetBubbleSize(LPTOOLINFO lpToolInfo) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, TTM_GETBUBBLESIZE, 0, (LPARAM)lpToolInfo); + SIZE size = { GET_X_LPARAM(dwRet), GET_Y_LPARAM(dwRet) }; + return size; + } + + BOOL SetTitle(UINT_PTR uIcon, LPCTSTR lpstrTitle) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TTM_SETTITLE, uIcon, (LPARAM)lpstrTitle); + } + + + BOOL SetTitle(HICON hIcon, LPCTSTR lpstrTitle) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TTM_SETTITLE, (WPARAM)hIcon, (LPARAM)lpstrTitle); + } + + void GetTitle(PTTGETTITLE pTTGetTitle) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_GETTITLE, 0, (LPARAM)pTTGetTitle); + } + + void SetWindowTheme(LPCWSTR lpstrTheme) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_SETWINDOWTHEME, 0, (LPARAM)lpstrTheme); + } + +// Operations + void Activate(BOOL bActivate) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_ACTIVATE, bActivate, 0L); + } + + BOOL AddTool(LPTOOLINFO lpToolInfo) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TTM_ADDTOOL, 0, (LPARAM)lpToolInfo); + } + + BOOL AddTool(HWND hWnd, ATL::_U_STRINGorID text = LPSTR_TEXTCALLBACK, LPCRECT lpRectTool = NULL, UINT_PTR nIDTool = 0) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(hWnd != NULL); + // the toolrect and toolid must both be zero or both valid + ATLASSERT(((lpRectTool != NULL) && (nIDTool != 0)) || ((lpRectTool == NULL) && (nIDTool == 0))); + + CToolInfo ti(0, hWnd, nIDTool, (LPRECT)lpRectTool, (LPTSTR)text.m_lpstr); + return (BOOL)::SendMessage(this->m_hWnd, TTM_ADDTOOL, 0, ti); + } + + void DelTool(LPTOOLINFO lpToolInfo) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_DELTOOL, 0, (LPARAM)lpToolInfo); + } + + void DelTool(HWND hWnd, UINT_PTR nIDTool = 0) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(hWnd != NULL); + + CToolInfo ti(0, hWnd, nIDTool, NULL, NULL); + ::SendMessage(this->m_hWnd, TTM_DELTOOL, 0, ti); + } + + BOOL HitTest(LPTTHITTESTINFO lpHitTestInfo) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TTM_HITTEST, 0, (LPARAM)lpHitTestInfo); + } + + BOOL HitTest(HWND hWnd, POINT pt, LPTOOLINFO lpToolInfo) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(hWnd != NULL); + ATLASSERT(lpToolInfo != NULL); + + TTHITTESTINFO hti = {}; + hti.ti.cbSize = RunTimeHelper::SizeOf_TOOLINFO(); + hti.hwnd = hWnd; + hti.pt.x = pt.x; + hti.pt.y = pt.y; + if((BOOL)::SendMessage(this->m_hWnd, TTM_HITTEST, 0, (LPARAM)&hti) != FALSE) + { + *lpToolInfo = hti.ti; + return TRUE; + } + return FALSE; + } + + void RelayEvent(LPMSG lpMsg) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_RELAYEVENT, 0, (LPARAM)lpMsg); + } + + void UpdateTipText(LPTOOLINFO lpToolInfo) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_UPDATETIPTEXT, 0, (LPARAM)lpToolInfo); + } + + void UpdateTipText(ATL::_U_STRINGorID text, HWND hWnd, UINT_PTR nIDTool = 0) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(hWnd != NULL); + + CToolInfo ti(0, hWnd, nIDTool, NULL, (LPTSTR)text.m_lpstr); + ::SendMessage(this->m_hWnd, TTM_UPDATETIPTEXT, 0, ti); + } + + BOOL EnumTools(UINT_PTR nTool, LPTOOLINFO lpToolInfo) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TTM_ENUMTOOLS, nTool, (LPARAM)lpToolInfo); + } + + void Pop() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_POP, 0, 0L); + } + + void TrackActivate(LPTOOLINFO lpToolInfo, BOOL bActivate) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_TRACKACTIVATE, bActivate, (LPARAM)lpToolInfo); + } + + void TrackActivate(HWND hWnd, UINT_PTR nIDTool, BOOL bActivate) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(hWnd != NULL); + + CToolInfo ti(0, hWnd, nIDTool); + ::SendMessage(this->m_hWnd, TTM_TRACKACTIVATE, bActivate, ti); + } + + void TrackPosition(int xPos, int yPos) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_TRACKPOSITION, 0, MAKELPARAM(xPos, yPos)); + } + + void Update() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_UPDATE, 0, 0L); + } + + BOOL AdjustRect(LPRECT lpRect, BOOL bLarger /*= TRUE*/) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TTM_ADJUSTRECT, bLarger, (LPARAM)lpRect); + } + + void Popup() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TTM_POPUP, 0, 0L); + } +}; + +typedef CToolTipCtrlT CToolTipCtrl; + + +/////////////////////////////////////////////////////////////////////////////// +// CHeaderCtrl + +template +class CHeaderCtrlT : public TBase +{ +public: +// Constructors + CHeaderCtrlT(HWND hWnd = NULL) : TBase(hWnd) + { } + + CHeaderCtrlT< TBase >& operator =(HWND hWnd) + { + this->m_hWnd = hWnd; + return *this; + } + + HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, + DWORD dwStyle = 0, DWORD dwExStyle = 0, + ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) + { + return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); + } + +// Attributes + static LPCTSTR GetWndClassName() + { + return WC_HEADER; + } + + int GetItemCount() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, HDM_GETITEMCOUNT, 0, 0L); + } + + BOOL GetItem(int nIndex, LPHDITEM pHeaderItem) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, HDM_GETITEM, nIndex, (LPARAM)pHeaderItem); + } + + BOOL SetItem(int nIndex, LPHDITEM pHeaderItem) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, HDM_SETITEM, nIndex, (LPARAM)pHeaderItem); + } + + CImageList GetImageList() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, HDM_GETIMAGELIST, 0, 0L)); + } + + CImageList SetImageList(HIMAGELIST hImageList) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, HDM_SETIMAGELIST, 0, (LPARAM)hImageList)); + } + + BOOL GetOrderArray(int nSize, int* lpnArray) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, HDM_GETORDERARRAY, nSize, (LPARAM)lpnArray); + } + + BOOL SetOrderArray(int nSize, int* lpnArray) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, HDM_SETORDERARRAY, nSize, (LPARAM)lpnArray); + } + + BOOL GetItemRect(int nIndex, LPRECT lpItemRect) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, HDM_GETITEMRECT, nIndex, (LPARAM)lpItemRect); + } + + int SetHotDivider(BOOL bPos, DWORD dwInputValue) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, HDM_SETHOTDIVIDER, bPos, dwInputValue); + } + + BOOL GetUnicodeFormat() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, HDM_GETUNICODEFORMAT, 0, 0L); + } + + BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, HDM_SETUNICODEFORMAT, bUnicode, 0L); + } + + int GetBitmapMargin() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, HDM_GETBITMAPMARGIN, 0, 0L); + } + + int SetBitmapMargin(int nWidth) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, HDM_SETBITMAPMARGIN, nWidth, 0L); + } + + int SetFilterChangeTimeout(DWORD dwTimeOut) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, HDM_SETFILTERCHANGETIMEOUT, 0, dwTimeOut); + } + +#if (_WIN32_WINNT >= 0x0600) + BOOL GetItemDropDownRect(int nIndex, LPRECT lpRect) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, HDM_GETITEMDROPDOWNRECT, nIndex, (LPARAM)lpRect); + } + + BOOL GetOverflowRect(LPRECT lpRect) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, HDM_GETOVERFLOWRECT, 0, (LPARAM)lpRect); + } + + int GetFocusedItem() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, HDM_GETFOCUSEDITEM, 0, 0L); + } + + BOOL SetFocusedItem(int nIndex) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, HDM_SETFOCUSEDITEM, 0, nIndex); + } +#endif // (_WIN32_WINNT >= 0x0600) + +// Operations + int InsertItem(int nIndex, LPHDITEM phdi) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, HDM_INSERTITEM, nIndex, (LPARAM)phdi); + } + + int AddItem(LPHDITEM phdi) + { + return InsertItem(GetItemCount(), phdi); + } + + BOOL DeleteItem(int nIndex) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, HDM_DELETEITEM, nIndex, 0L); + } + + BOOL Layout(HD_LAYOUT* pHeaderLayout) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, HDM_LAYOUT, 0, (LPARAM)pHeaderLayout); + } + + int HitTest(LPHDHITTESTINFO lpHitTestInfo) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, HDM_HITTEST, 0, (LPARAM)lpHitTestInfo); + } + + int OrderToIndex(int nOrder) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, HDM_ORDERTOINDEX, nOrder, 0L); + } + + CImageList CreateDragImage(int nIndex) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, HDM_CREATEDRAGIMAGE, nIndex, 0L)); + } + + int EditFilter(int nColumn, BOOL bDiscardChanges) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, HDM_EDITFILTER, nColumn, MAKELPARAM(bDiscardChanges, 0)); + } + + int ClearFilter(int nColumn) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, HDM_CLEARFILTER, nColumn, 0L); + } + + int ClearAllFilters() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, HDM_CLEARFILTER, (WPARAM)-1, 0L); + } +}; + +typedef CHeaderCtrlT CHeaderCtrl; + + +/////////////////////////////////////////////////////////////////////////////// +// CListViewCtrl + +template +class CListViewCtrlT : public TBase +{ +public: +// Constructors + CListViewCtrlT(HWND hWnd = NULL) : TBase(hWnd) + { } + + CListViewCtrlT< TBase >& operator =(HWND hWnd) + { + this->m_hWnd = hWnd; + return *this; + } + + HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, + DWORD dwStyle = 0, DWORD dwExStyle = 0, + ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) + { + return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); + } + +// Attributes + static LPCTSTR GetWndClassName() + { + return WC_LISTVIEW; + } + + COLORREF GetBkColor() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, LVM_GETBKCOLOR, 0, 0L); + } + + BOOL SetBkColor(COLORREF cr) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETBKCOLOR, 0, cr); + } + + CImageList GetImageList(int nImageListType) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, LVM_GETIMAGELIST, nImageListType, 0L)); + } + + CImageList SetImageList(HIMAGELIST hImageList, int nImageList) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, LVM_SETIMAGELIST, nImageList, (LPARAM)hImageList)); + } + + int GetItemCount() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_GETITEMCOUNT, 0, 0L); + } + + BOOL SetItemCount(int nItems) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETITEMCOUNT, nItems, 0L); + } + + BOOL GetItem(LPLVITEM pItem) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETITEM, 0, (LPARAM)pItem); + } + + BOOL SetItem(const LVITEM* pItem) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETITEM, 0, (LPARAM)pItem); + } + + BOOL SetItem(int nItem, int nSubItem, UINT nMask, LPCTSTR lpszItem, + int nImage, UINT nState, UINT nStateMask, LPARAM lParam) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + LVITEM lvi = {}; + lvi.mask = nMask; + lvi.iItem = nItem; + lvi.iSubItem = nSubItem; + lvi.stateMask = nStateMask; + lvi.state = nState; + lvi.pszText = (LPTSTR) lpszItem; + lvi.iImage = nImage; + lvi.lParam = lParam; + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETITEM, 0, (LPARAM)&lvi); + } + + UINT GetItemState(int nItem, UINT nMask) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, LVM_GETITEMSTATE, nItem, nMask); + } + + BOOL SetItemState(int nItem, UINT nState, UINT nStateMask) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + LVITEM lvi = {}; + lvi.state = nState; + lvi.stateMask = nStateMask; + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETITEMSTATE, nItem, (LPARAM)&lvi); + } + + BOOL SetItemState(int nItem, LPLVITEM pItem) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETITEMSTATE, nItem, (LPARAM)pItem); + } + + BOOL GetItemText(int nItem, int nSubItem, BSTR& bstrText) const + { + USES_CONVERSION; + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(bstrText == NULL); + LVITEM lvi = {}; + lvi.iSubItem = nSubItem; + + LPTSTR lpstrText = NULL; + int nRes = 0; + for(int nLen = 256; ; nLen *= 2) + { + ATLTRY(lpstrText = new TCHAR[nLen]); + if(lpstrText == NULL) + break; + lpstrText[0] = NULL; + lvi.cchTextMax = nLen; + lvi.pszText = lpstrText; + nRes = (int)::SendMessage(this->m_hWnd, LVM_GETITEMTEXT, (WPARAM)nItem, (LPARAM)&lvi); + if(nRes < nLen - 1) + break; + delete [] lpstrText; + lpstrText = NULL; + } + + if(lpstrText != NULL) + { + if(nRes != 0) + bstrText = ::SysAllocString(T2OLE(lpstrText)); + delete [] lpstrText; + } + + return (bstrText != NULL) ? TRUE : FALSE; + } + +#ifdef __ATLSTR_H__ + int GetItemText(int nItem, int nSubItem, ATL::CString& strText) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + LVITEM lvi = {}; + lvi.iSubItem = nSubItem; + + strText.Empty(); + int nRes = 0; + for(int nLen = 256; ; nLen *= 2) + { + lvi.cchTextMax = nLen; + lvi.pszText = strText.GetBufferSetLength(nLen); + if(lvi.pszText == NULL) + { + nRes = 0; + break; + } + nRes = (int)::SendMessage(this->m_hWnd, LVM_GETITEMTEXT, (WPARAM)nItem, (LPARAM)&lvi); + if(nRes < nLen - 1) + break; + } + strText.ReleaseBuffer(); + return nRes; + } +#endif // __ATLSTR_H__ + + int GetItemText(int nItem, int nSubItem, LPTSTR lpszText, int nLen) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + LVITEM lvi = {}; + lvi.iSubItem = nSubItem; + lvi.cchTextMax = nLen; + lvi.pszText = lpszText; + return (int)::SendMessage(this->m_hWnd, LVM_GETITEMTEXT, (WPARAM)nItem, (LPARAM)&lvi); + } + + BOOL SetItemText(int nItem, int nSubItem, LPCTSTR lpszText) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return SetItem(nItem, nSubItem, LVIF_TEXT, lpszText, 0, 0, 0, 0); + } + + DWORD_PTR GetItemData(int nItem) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + LVITEM lvi = {}; + lvi.iItem = nItem; + lvi.mask = LVIF_PARAM; + BOOL bRet = (BOOL)::SendMessage(this->m_hWnd, LVM_GETITEM, 0, (LPARAM)&lvi); + return (DWORD_PTR)(bRet ? lvi.lParam : NULL); + } + + BOOL SetItemData(int nItem, DWORD_PTR dwData) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return SetItem(nItem, 0, LVIF_PARAM, NULL, 0, 0, 0, (LPARAM)dwData); + } + + UINT GetCallbackMask() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, LVM_GETCALLBACKMASK, 0, 0L); + } + + BOOL SetCallbackMask(UINT nMask) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETCALLBACKMASK, nMask, 0L); + } + + BOOL GetItemPosition(int nItem, LPPOINT lpPoint) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETITEMPOSITION, nItem, (LPARAM)lpPoint); + } + + BOOL SetItemPosition(int nItem, POINT pt) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(((this->GetStyle() & LVS_TYPEMASK) == LVS_ICON) || ((this->GetStyle() & LVS_TYPEMASK) == LVS_SMALLICON)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETITEMPOSITION32, nItem, (LPARAM)&pt); + } + + BOOL SetItemPosition(int nItem, int x, int y) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(((this->GetStyle() & LVS_TYPEMASK) == LVS_ICON) || ((this->GetStyle() & LVS_TYPEMASK) == LVS_SMALLICON)); + POINT pt = { x, y }; + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETITEMPOSITION32, nItem, (LPARAM)&pt); + } + + int GetStringWidth(LPCTSTR lpsz) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_GETSTRINGWIDTH, 0, (LPARAM)lpsz); + } + + CEdit GetEditControl() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return CEdit((HWND)::SendMessage(this->m_hWnd, LVM_GETEDITCONTROL, 0, 0L)); + } + + BOOL GetColumn(int nCol, LVCOLUMN* pColumn) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETCOLUMN, nCol, (LPARAM)pColumn); + } + + BOOL SetColumn(int nCol, const LVCOLUMN* pColumn) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETCOLUMN, nCol, (LPARAM)pColumn); + } + + int GetColumnWidth(int nCol) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_GETCOLUMNWIDTH, nCol, 0L); + } + + BOOL SetColumnWidth(int nCol, int cx) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETCOLUMNWIDTH, nCol, MAKELPARAM(cx, 0)); + } + + BOOL GetViewRect(LPRECT lpRect) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETVIEWRECT, 0, (LPARAM)lpRect); + } + + COLORREF GetTextColor() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, LVM_GETTEXTCOLOR, 0, 0L); + } + + BOOL SetTextColor(COLORREF cr) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETTEXTCOLOR, 0, cr); + } + + COLORREF GetTextBkColor() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, LVM_GETTEXTBKCOLOR, 0, 0L); + } + + BOOL SetTextBkColor(COLORREF cr) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETTEXTBKCOLOR, 0, cr); + } + + int GetTopIndex() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_GETTOPINDEX, 0, 0L); + } + + int GetCountPerPage() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_GETCOUNTPERPAGE, 0, 0L); + } + + BOOL GetOrigin(LPPOINT lpPoint) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETORIGIN, 0, (LPARAM)lpPoint); + } + + UINT GetSelectedCount() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, LVM_GETSELECTEDCOUNT, 0, 0L); + } + + BOOL GetItemRect(int nItem, LPRECT lpRect, UINT nCode) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + lpRect->left = nCode; + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETITEMRECT, (WPARAM)nItem, (LPARAM)lpRect); + } + + HCURSOR GetHotCursor() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HCURSOR)::SendMessage(this->m_hWnd, LVM_GETHOTCURSOR, 0, 0L); + } + + HCURSOR SetHotCursor(HCURSOR hHotCursor) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HCURSOR)::SendMessage(this->m_hWnd, LVM_SETHOTCURSOR, 0, (LPARAM)hHotCursor); + } + + int GetHotItem() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_GETHOTITEM, 0, 0L); + } + + int SetHotItem(int nIndex) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_SETHOTITEM, nIndex, 0L); + } + + BOOL GetColumnOrderArray(int nCount, int* lpnArray) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETCOLUMNORDERARRAY, nCount, (LPARAM)lpnArray); + } + + BOOL SetColumnOrderArray(int nCount, int* lpnArray) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETCOLUMNORDERARRAY, nCount, (LPARAM)lpnArray); + } + + CHeaderCtrl GetHeader() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return CHeaderCtrl((HWND)::SendMessage(this->m_hWnd, LVM_GETHEADER, 0, 0L)); + } + + BOOL GetSubItemRect(int nItem, int nSubItem, int nFlag, LPRECT lpRect) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & LVS_TYPEMASK) == LVS_REPORT); + ATLASSERT(lpRect != NULL); + lpRect->top = nSubItem; + lpRect->left = nFlag; + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETSUBITEMRECT, nItem, (LPARAM)lpRect); + } + + DWORD SetIconSpacing(int cx, int cy) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & LVS_TYPEMASK) == LVS_ICON); + return (DWORD)::SendMessage(this->m_hWnd, LVM_SETICONSPACING, 0, MAKELPARAM(cx, cy)); + } + + int GetISearchString(LPTSTR lpstr) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_GETISEARCHSTRING, 0, (LPARAM)lpstr); + } + + void GetItemSpacing(SIZE& sizeSpacing, BOOL bSmallIconView = FALSE) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, LVM_GETITEMSPACING, bSmallIconView, 0L); + sizeSpacing.cx = GET_X_LPARAM(dwRet); + sizeSpacing.cy = GET_Y_LPARAM(dwRet); + } + + // single-selection only + int GetSelectedIndex() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & LVS_SINGLESEL) != 0); + return (int)::SendMessage(this->m_hWnd, LVM_GETNEXTITEM, (WPARAM)-1, MAKELPARAM(LVNI_ALL | LVNI_SELECTED, 0)); + } + + BOOL GetSelectedItem(LPLVITEM pItem) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & LVS_SINGLESEL) != 0); + ATLASSERT(pItem != NULL); + pItem->iItem = (int)::SendMessage(this->m_hWnd, LVM_GETNEXTITEM, (WPARAM)-1, MAKELPARAM(LVNI_ALL | LVNI_SELECTED, 0)); + if(pItem->iItem == -1) + return FALSE; + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETITEM, 0, (LPARAM)pItem); + } + + // extended list view styles + DWORD GetExtendedListViewStyle() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0L); + } + + // dwExMask = 0 means all styles + DWORD SetExtendedListViewStyle(DWORD dwExStyle, DWORD dwExMask = 0) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, LVM_SETEXTENDEDLISTVIEWSTYLE, dwExMask, dwExStyle); + } + + // checkboxes only + BOOL GetCheckState(int nIndex) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((GetExtendedListViewStyle() & LVS_EX_CHECKBOXES) != 0); + UINT uRet = GetItemState(nIndex, LVIS_STATEIMAGEMASK); + return (uRet >> 12) - 1; + } + + BOOL SetCheckState(int nItem, BOOL bCheck) + { + int nCheck = bCheck ? 2 : 1; // one based index + return SetItemState(nItem, INDEXTOSTATEIMAGEMASK(nCheck), LVIS_STATEIMAGEMASK); + } + + // view type + DWORD GetViewType() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (this->GetStyle() & LVS_TYPEMASK); + } + + DWORD SetViewType(DWORD dwType) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((dwType == LVS_ICON) || (dwType == LVS_SMALLICON) || (dwType == LVS_LIST) || (dwType == LVS_REPORT)); + DWORD dwOldType = GetViewType(); + if(dwType != dwOldType) + this->ModifyStyle(LVS_TYPEMASK, (dwType & LVS_TYPEMASK)); + return dwOldType; + } + + BOOL GetBkImage(LPLVBKIMAGE plvbki) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETBKIMAGE, 0, (LPARAM)plvbki); + } + + BOOL SetBkImage(LPLVBKIMAGE plvbki) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETBKIMAGE, 0, (LPARAM)plvbki); + } + + int GetSelectionMark() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_GETSELECTIONMARK, 0, 0L); + } + + int SetSelectionMark(int nIndex) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_SETSELECTIONMARK, 0, nIndex); + } + + BOOL GetWorkAreas(int nWorkAreas, LPRECT lpRect) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETWORKAREAS, nWorkAreas, (LPARAM)lpRect); + } + + BOOL SetWorkAreas(int nWorkAreas, LPRECT lpRect) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETWORKAREAS, nWorkAreas, (LPARAM)lpRect); + } + + DWORD GetHoverTime() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((GetExtendedListViewStyle() & (LVS_EX_TRACKSELECT | LVS_EX_ONECLICKACTIVATE | LVS_EX_TWOCLICKACTIVATE)) != 0); + return (DWORD)::SendMessage(this->m_hWnd, LVM_GETHOVERTIME, 0, 0L); + } + + DWORD SetHoverTime(DWORD dwHoverTime) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((GetExtendedListViewStyle() & (LVS_EX_TRACKSELECT | LVS_EX_ONECLICKACTIVATE | LVS_EX_TWOCLICKACTIVATE)) != 0); + return (DWORD)::SendMessage(this->m_hWnd, LVM_SETHOVERTIME, 0, dwHoverTime); + } + + BOOL GetNumberOfWorkAreas(int* pnWorkAreas) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETNUMBEROFWORKAREAS, 0, (LPARAM)pnWorkAreas); + } + + BOOL SetItemCountEx(int nItems, DWORD dwFlags) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(((this->GetStyle() & LVS_OWNERDATA) != 0) && (((this->GetStyle() & LVS_TYPEMASK) == LVS_REPORT) || ((this->GetStyle() & LVS_TYPEMASK) == LVS_LIST))); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETITEMCOUNT, nItems, dwFlags); + } + + CToolTipCtrl GetToolTips() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return CToolTipCtrl((HWND)::SendMessage(this->m_hWnd, LVM_GETTOOLTIPS, 0, 0L)); + } + + CToolTipCtrl SetToolTips(HWND hWndTT) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return CToolTipCtrl((HWND)::SendMessage(this->m_hWnd, LVM_SETTOOLTIPS, (WPARAM)hWndTT, 0L)); + } + + BOOL GetUnicodeFormat() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETUNICODEFORMAT, 0, 0L); + } + + BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETUNICODEFORMAT, bUnicode, 0L); + } + + int GetSelectedColumn() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_GETSELECTEDCOLUMN, 0, 0L); + } + + void SetSelectedColumn(int nColumn) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, LVM_SETSELECTEDCOLUMN, nColumn, 0L); + } + + DWORD GetView() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, LVM_GETVIEW, 0, 0L); + } + + int SetView(DWORD dwView) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_SETVIEW, dwView, 0L); + } + + BOOL IsGroupViewEnabled() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_ISGROUPVIEWENABLED, 0, 0L); + } + + int GetGroupInfo(int nGroupID, PLVGROUP pGroup) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_GETGROUPINFO, nGroupID, (LPARAM)pGroup); + } + + int SetGroupInfo(int nGroupID, PLVGROUP pGroup) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_SETGROUPINFO, nGroupID, (LPARAM)pGroup); + } + + void GetGroupMetrics(PLVGROUPMETRICS pGroupMetrics) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, LVM_GETGROUPMETRICS, 0, (LPARAM)pGroupMetrics); + } + + void SetGroupMetrics(PLVGROUPMETRICS pGroupMetrics) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, LVM_SETGROUPMETRICS, 0, (LPARAM)pGroupMetrics); + } + + void GetTileViewInfo(PLVTILEVIEWINFO pTileViewInfo) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, LVM_GETTILEVIEWINFO, 0, (LPARAM)pTileViewInfo); + } + + BOOL SetTileViewInfo(PLVTILEVIEWINFO pTileViewInfo) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETTILEVIEWINFO, 0, (LPARAM)pTileViewInfo); + } + + void GetTileInfo(PLVTILEINFO pTileInfo) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, LVM_GETTILEINFO, 0, (LPARAM)pTileInfo); + } + + BOOL SetTileInfo(PLVTILEINFO pTileInfo) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETTILEINFO, 0, (LPARAM)pTileInfo); + } + + BOOL GetInsertMark(LPLVINSERTMARK pInsertMark) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETINSERTMARK, 0, (LPARAM)pInsertMark); + } + + BOOL SetInsertMark(LPLVINSERTMARK pInsertMark) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETINSERTMARK, 0, (LPARAM)pInsertMark); + } + + int GetInsertMarkRect(LPRECT lpRect) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_GETINSERTMARKRECT, 0, (LPARAM)lpRect); + } + + COLORREF GetInsertMarkColor() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, LVM_GETINSERTMARKCOLOR, 0, 0L); + } + + COLORREF SetInsertMarkColor(COLORREF clr) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, LVM_SETINSERTMARKCOLOR, 0, clr); + } + + COLORREF GetOutlineColor() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, LVM_GETOUTLINECOLOR, 0, 0L); + } + + COLORREF SetOutlineColor(COLORREF clr) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, LVM_SETOUTLINECOLOR, 0, clr); + } + +#if (_WIN32_WINNT >= 0x0600) + int GetGroupCount() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_GETGROUPCOUNT, 0, 0L); + } + + BOOL GetGroupInfoByIndex(int nIndex, PLVGROUP pGroup) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETGROUPINFOBYINDEX, nIndex, (LPARAM)pGroup); + } + + BOOL GetGroupRect(int nGroupID, int nType, LPRECT lpRect) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(lpRect != NULL); + if(lpRect != NULL) + lpRect->top = nType; + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETGROUPRECT, nGroupID, (LPARAM)lpRect); + } + + UINT GetGroupState(int nGroupID, UINT uMask) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, LVM_GETGROUPSTATE, nGroupID, (LPARAM)uMask); + } + + int GetFocusedGroup() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_GETFOCUSEDGROUP, 0, 0L); + } + + BOOL GetEmptyText(LPWSTR lpstrText, int cchText) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETEMPTYTEXT, cchText, (LPARAM)lpstrText); + } + + BOOL GetFooterRect(LPRECT lpRect) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETFOOTERRECT, 0, (LPARAM)lpRect); + } + + BOOL GetFooterInfo(LPLVFOOTERINFO lpFooterInfo) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETFOOTERINFO, 0, (LPARAM)lpFooterInfo); + } + + BOOL GetFooterItemRect(int nItem, LPRECT lpRect) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETFOOTERITEMRECT, nItem, (LPARAM)lpRect); + } + + BOOL GetFooterItem(int nItem, LPLVFOOTERITEM lpFooterItem) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETFOOTERITEM, nItem, (LPARAM)lpFooterItem); + } + + BOOL GetItemIndexRect(PLVITEMINDEX pItemIndex, int nSubItem, int nType, LPRECT lpRect) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(pItemIndex != NULL); + ATLASSERT(lpRect != NULL); + if(lpRect != NULL) + { + lpRect->top = nSubItem; + lpRect->left = nType; + } + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETITEMINDEXRECT, (WPARAM)pItemIndex, (LPARAM)lpRect); + } + + BOOL SetItemIndexState(PLVITEMINDEX pItemIndex, UINT uState, UINT dwMask) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + LVITEM lvi = {}; + lvi.state = uState; + lvi.stateMask = dwMask; + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETITEMINDEXSTATE, (WPARAM)pItemIndex, (LPARAM)&lvi); + } + + BOOL GetNextItemIndex(PLVITEMINDEX pItemIndex, WORD wFlags) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_GETNEXTITEMINDEX, (WPARAM)pItemIndex, MAKELPARAM(wFlags, 0)); + } +#endif // (_WIN32_WINNT >= 0x0600) + +// Operations + int InsertColumn(int nCol, const LVCOLUMN* pColumn) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_INSERTCOLUMN, nCol, (LPARAM)pColumn); + } + + int InsertColumn(int nCol, LPCTSTR lpszColumnHeading, int nFormat = LVCFMT_LEFT, + int nWidth = -1, int nSubItem = -1, int iImage = -1, int iOrder = -1) + { + LVCOLUMN column = {}; + column.mask = LVCF_TEXT | LVCF_FMT; + column.pszText = (LPTSTR)lpszColumnHeading; + column.fmt = nFormat; + if (nWidth != -1) + { + column.mask |= LVCF_WIDTH; + column.cx = nWidth; + } + if (nSubItem != -1) + { + column.mask |= LVCF_SUBITEM; + column.iSubItem = nSubItem; + } + if (iImage != -1) + { + column.mask |= LVCF_IMAGE; + column.iImage = iImage; + } + if (iOrder != -1) + { + column.mask |= LVCF_ORDER; + column.iOrder = iOrder; + } + return InsertColumn(nCol, &column); + } + + BOOL DeleteColumn(int nCol) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_DELETECOLUMN, nCol, 0L); + } + + int InsertItem(UINT nMask, int nItem, LPCTSTR lpszItem, UINT nState, UINT nStateMask, int nImage, LPARAM lParam) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + LVITEM item = {}; + item.mask = nMask; + item.iItem = nItem; + item.iSubItem = 0; + item.pszText = (LPTSTR)lpszItem; + item.state = nState; + item.stateMask = nStateMask; + item.iImage = nImage; + item.lParam = lParam; + return InsertItem(&item); + } + + int InsertItem(const LVITEM* pItem) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_INSERTITEM, 0, (LPARAM)pItem); + } + + int InsertItem(int nItem, LPCTSTR lpszItem) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return InsertItem(LVIF_TEXT, nItem, lpszItem, 0, 0, 0, 0); + } + + int InsertItem(int nItem, LPCTSTR lpszItem, int nImage) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return InsertItem(LVIF_TEXT|LVIF_IMAGE, nItem, lpszItem, 0, 0, nImage, 0); + } + + int GetNextItem(int nItem, int nFlags) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_GETNEXTITEM, nItem, MAKELPARAM(nFlags, 0)); + } + + BOOL DeleteItem(int nItem) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_DELETEITEM, nItem, 0L); + } + + BOOL DeleteAllItems() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_DELETEALLITEMS, 0, 0L); + } + + int FindItem(LVFINDINFO* pFindInfo, int nStart = -1) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_FINDITEM, nStart, (LPARAM)pFindInfo); + } + + int FindItem(LPCTSTR lpstrFind, bool bPartial = true, bool bWrap = false, int nStart = -1) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + LVFINDINFO lvfi = {}; + lvfi.flags = LVFI_STRING | (bWrap ? LVFI_WRAP : 0) | (bPartial ? LVFI_PARTIAL : 0); + lvfi.psz = lpstrFind; + return (int)::SendMessage(this->m_hWnd, LVM_FINDITEM, nStart, (LPARAM)&lvfi); + } + + int HitTest(LVHITTESTINFO* pHitTestInfo) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_HITTEST, 0, (LPARAM)pHitTestInfo); + } + + int HitTest(POINT pt, UINT* pFlags) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + LVHITTESTINFO hti = {}; + hti.pt = pt; + int nRes = (int)::SendMessage(this->m_hWnd, LVM_HITTEST, 0, (LPARAM)&hti); + if (pFlags != NULL) + *pFlags = hti.flags; + return nRes; + } + + BOOL EnsureVisible(int nItem, BOOL bPartialOK) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_ENSUREVISIBLE, nItem, MAKELPARAM(bPartialOK, 0)); + } + + BOOL Scroll(int cx, int cy) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SCROLL, cx, cy); + } + + BOOL Scroll(SIZE size) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SCROLL, size.cx, size.cy); + } + + BOOL RedrawItems(int nFirst, int nLast) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_REDRAWITEMS, nFirst, nLast); + } + + BOOL Arrange(UINT nCode) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_ARRANGE, nCode, 0L); + } + + CEdit EditLabel(int nItem) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return CEdit((HWND)::SendMessage(this->m_hWnd, LVM_EDITLABEL, nItem, 0L)); + } + + BOOL Update(int nItem) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_UPDATE, nItem, 0L); + } + + BOOL SortItems(PFNLVCOMPARE pfnCompare, LPARAM lParamSort) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SORTITEMS, (WPARAM)lParamSort, (LPARAM)pfnCompare); + } + + CImageList RemoveImageList(int nImageList) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, LVM_SETIMAGELIST, (WPARAM)nImageList, NULL)); + } + + CImageList CreateDragImage(int nItem, LPPOINT lpPoint) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, LVM_CREATEDRAGIMAGE, nItem, (LPARAM)lpPoint)); + } + + DWORD ApproximateViewRect(int cx = -1, int cy = -1, int nCount = -1) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, LVM_APPROXIMATEVIEWRECT, nCount, MAKELPARAM(cx, cy)); + } + + int SubItemHitTest(LPLVHITTESTINFO lpInfo) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_SUBITEMHITTEST, 0, (LPARAM)lpInfo); + } + + int AddColumn(LPCTSTR strColumn, int nItem, int nSubItem = -1, + int nMask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM, + int nFmt = LVCFMT_LEFT) + { + const int cxOffset = 15; + ATLASSERT(::IsWindow(this->m_hWnd)); + LVCOLUMN lvc = {}; + lvc.mask = nMask; + lvc.fmt = nFmt; + lvc.pszText = (LPTSTR)strColumn; + lvc.cx = GetStringWidth(lvc.pszText) + cxOffset; + if(nMask & LVCF_SUBITEM) + lvc.iSubItem = (nSubItem != -1) ? nSubItem : nItem; + return InsertColumn(nItem, &lvc); + } + + int AddItem(int nItem, int nSubItem, LPCTSTR strItem, int nImageIndex = -3) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + LVITEM lvItem = {}; + lvItem.mask = LVIF_TEXT; + lvItem.iItem = nItem; + lvItem.iSubItem = nSubItem; + lvItem.pszText = (LPTSTR)strItem; + if(nImageIndex != -3) + { + lvItem.mask |= LVIF_IMAGE; + lvItem.iImage = nImageIndex; + } + if(nSubItem == 0) + return InsertItem(&lvItem); + return SetItem(&lvItem) ? nItem : -1; + } + + BOOL SortItemsEx(PFNLVCOMPARE pfnCompare, LPARAM lParamSort) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SORTITEMSEX, (WPARAM)lParamSort, (LPARAM)pfnCompare); + } + + int InsertGroup(int nItem, PLVGROUP pGroup) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_INSERTGROUP, nItem, (LPARAM)pGroup); + } + + int AddGroup(PLVGROUP pGroup) + { + return InsertGroup(-1, pGroup); + } + + int RemoveGroup(int nGroupID) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_REMOVEGROUP, nGroupID, 0L); + } + + void MoveGroup(int nGroupID, int nItem) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, LVM_MOVEGROUP, nGroupID, nItem); + } + + void MoveItemToGroup(int nItem, int nGroupID) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, LVM_MOVEITEMTOGROUP, nItem, nGroupID); + } + + int EnableGroupView(BOOL bEnable) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_ENABLEGROUPVIEW, bEnable, 0L); + } + + int SortGroups(PFNLVGROUPCOMPARE pCompareFunc, LPVOID lpVoid = NULL) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_SORTGROUPS, (WPARAM)pCompareFunc, (LPARAM)lpVoid); + } + + void InsertGroupSorted(PLVINSERTGROUPSORTED pInsertGroupSorted) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, LVM_INSERTGROUPSORTED, (WPARAM)pInsertGroupSorted, 0L); + } + + void RemoveAllGroups() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, LVM_REMOVEALLGROUPS, 0, 0L); + } + + BOOL HasGroup(int nGroupID) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_HASGROUP, nGroupID, 0L); + } + + BOOL InsertMarkHitTest(LPPOINT lpPoint, LPLVINSERTMARK pInsertMark) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_INSERTMARKHITTEST, (WPARAM)lpPoint, (LPARAM)pInsertMark); + } + + BOOL SetInfoTip(PLVSETINFOTIP pSetInfoTip) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LVM_SETINFOTIP, 0, (LPARAM)pSetInfoTip); + } + + void CancelEditLabel() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, LVM_CANCELEDITLABEL, 0, 0L); + } + + UINT MapIndexToID(int nIndex) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, LVM_MAPINDEXTOID, nIndex, 0L); + } + + int MapIDToIndex(UINT uID) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_MAPIDTOINDEX, uID, 0L); + } + +#if (_WIN32_WINNT >= 0x0600) + int HitTestEx(LPLVHITTESTINFO lpHitTestInfo) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_HITTEST, (WPARAM)-1, (LPARAM)lpHitTestInfo); + } + + int HitTestEx(POINT pt, UINT* pFlags) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + LVHITTESTINFO hti = {}; + hti.pt = pt; + int nRes = (int)::SendMessage(this->m_hWnd, LVM_HITTEST, (WPARAM)-1, (LPARAM)&hti); + if (pFlags != NULL) + *pFlags = hti.flags; + return nRes; + } + + int SubItemHitTestEx(LPLVHITTESTINFO lpHitTestInfo) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LVM_SUBITEMHITTEST, (WPARAM)-1, (LPARAM)lpHitTestInfo); + } +#endif // (_WIN32_WINNT >= 0x0600) + + // Note: selects only one item + BOOL SelectItem(int nIndex) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + + // multi-selection only: de-select all items + if((this->GetStyle() & LVS_SINGLESEL) == 0) + SetItemState(-1, 0, LVIS_SELECTED); + + BOOL bRet = SetItemState(nIndex, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED); + if(bRet) + { + SetSelectionMark(nIndex); + bRet = EnsureVisible(nIndex, FALSE); + } + + return bRet; + } + + // multi-selection only + BOOL SelectAllItems(bool bSelect = true) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & LVS_SINGLESEL) == 0); + + return SetItemState(-1, bSelect ? LVIS_SELECTED : 0, LVIS_SELECTED); + } +}; + +typedef CListViewCtrlT CListViewCtrl; + + +/////////////////////////////////////////////////////////////////////////////// +// CTreeViewCtrl + +template +class CTreeViewCtrlT : public TBase +{ +public: +// Constructors + CTreeViewCtrlT(HWND hWnd = NULL) : TBase(hWnd) + { } + + CTreeViewCtrlT< TBase >& operator =(HWND hWnd) + { + this->m_hWnd = hWnd; + return *this; + } + + HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, + DWORD dwStyle = 0, DWORD dwExStyle = 0, + ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) + { + return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); + } + +// Attributes + static LPCTSTR GetWndClassName() + { + return WC_TREEVIEW; + } + + UINT GetCount() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, TVM_GETCOUNT, 0, 0L); + } + + UINT GetIndent() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, TVM_GETINDENT, 0, 0L); + } + + void SetIndent(UINT nIndent) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TVM_SETINDENT, nIndent, 0L); + } + + CImageList GetImageList(int nImageListType = TVSIL_NORMAL) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TVM_GETIMAGELIST, (WPARAM)nImageListType, 0L)); + } + + CImageList SetImageList(HIMAGELIST hImageList, int nImageListType = TVSIL_NORMAL) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TVM_SETIMAGELIST, (WPARAM)nImageListType, (LPARAM)hImageList)); + } + + BOOL GetItem(LPTVITEM pItem) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_GETITEM, 0, (LPARAM)pItem); + } + + BOOL SetItem(LPTVITEM pItem) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_SETITEM, 0, (LPARAM)pItem); + } + + BOOL SetItem(HTREEITEM hItem, UINT nMask, LPCTSTR lpszItem, int nImage, + int nSelectedImage, UINT nState, UINT nStateMask, LPARAM lParam) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + TVITEM item = {}; + item.hItem = hItem; + item.mask = nMask; + item.pszText = (LPTSTR) lpszItem; + item.iImage = nImage; + item.iSelectedImage = nSelectedImage; + item.state = nState; + item.stateMask = nStateMask; + item.lParam = lParam; + return (BOOL)::SendMessage(this->m_hWnd, TVM_SETITEM, 0, (LPARAM)&item); + } + + BOOL GetItemText(HTREEITEM hItem, LPTSTR lpstrText, int nLen) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(lpstrText != NULL); + + TVITEM item = {}; + item.hItem = hItem; + item.mask = TVIF_TEXT; + item.pszText = lpstrText; + item.cchTextMax = nLen; + + return (BOOL)::SendMessage(this->m_hWnd, TVM_GETITEM, 0, (LPARAM)&item); + } + + BOOL GetItemText(HTREEITEM hItem, BSTR& bstrText) const + { + USES_CONVERSION; + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(bstrText == NULL); + TVITEM item = {}; + item.hItem = hItem; + item.mask = TVIF_TEXT; + + LPTSTR lpstrText = NULL; + BOOL bRet = FALSE; + for(int nLen = 256; ; nLen *= 2) + { + ATLTRY(lpstrText = new TCHAR[nLen]); + if(lpstrText == NULL) + break; + lpstrText[0] = NULL; + item.pszText = lpstrText; + item.cchTextMax = nLen; + bRet = (BOOL)::SendMessage(this->m_hWnd, TVM_GETITEM, 0, (LPARAM)&item); + if(!bRet || (lstrlen(item.pszText) < (nLen - 1))) + break; + delete [] lpstrText; + lpstrText = NULL; + } + + if(lpstrText != NULL) + { + if(bRet) + bstrText = ::SysAllocString(T2OLE(lpstrText)); + delete [] lpstrText; + } + + return (bstrText != NULL) ? TRUE : FALSE; + } + +#ifdef __ATLSTR_H__ + BOOL GetItemText(HTREEITEM hItem, ATL::CString& strText) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + TVITEM item = {}; + item.hItem = hItem; + item.mask = TVIF_TEXT; + + strText.Empty(); + BOOL bRet = FALSE; + for(int nLen = 256; ; nLen *= 2) + { + item.pszText = strText.GetBufferSetLength(nLen); + if(item.pszText == NULL) + { + bRet = FALSE; + break; + } + item.cchTextMax = nLen; + bRet = (BOOL)::SendMessage(this->m_hWnd, TVM_GETITEM, 0, (LPARAM)&item); + if(!bRet || (lstrlen(item.pszText) < (nLen - 1))) + break; + } + strText.ReleaseBuffer(); + return bRet; + } +#endif // __ATLSTR_H__ + + BOOL SetItemText(HTREEITEM hItem, LPCTSTR lpszItem) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return SetItem(hItem, TVIF_TEXT, lpszItem, 0, 0, 0, 0, NULL); + } + + BOOL GetItemImage(HTREEITEM hItem, int& nImage, int& nSelectedImage) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + TVITEM item = {}; + item.hItem = hItem; + item.mask = TVIF_IMAGE|TVIF_SELECTEDIMAGE; + BOOL bRes = (BOOL)::SendMessage(this->m_hWnd, TVM_GETITEM, 0, (LPARAM)&item); + if (bRes) + { + nImage = item.iImage; + nSelectedImage = item.iSelectedImage; + } + return bRes; + } + + BOOL SetItemImage(HTREEITEM hItem, int nImage, int nSelectedImage) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return SetItem(hItem, TVIF_IMAGE|TVIF_SELECTEDIMAGE, NULL, nImage, nSelectedImage, 0, 0, NULL); + } + + UINT GetItemState(HTREEITEM hItem, UINT nStateMask) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (((UINT)::SendMessage(this->m_hWnd, TVM_GETITEMSTATE, (WPARAM)hItem, (LPARAM)nStateMask)) & nStateMask); + } + + BOOL SetItemState(HTREEITEM hItem, UINT nState, UINT nStateMask) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return SetItem(hItem, TVIF_STATE, NULL, 0, 0, nState, nStateMask, NULL); + } + + DWORD_PTR GetItemData(HTREEITEM hItem) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + TVITEM item = {}; + item.hItem = hItem; + item.mask = TVIF_PARAM; + BOOL bRet = (BOOL)::SendMessage(this->m_hWnd, TVM_GETITEM, 0, (LPARAM)&item); + return (DWORD_PTR)(bRet ? item.lParam : NULL); + } + + BOOL SetItemData(HTREEITEM hItem, DWORD_PTR dwData) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return SetItem(hItem, TVIF_PARAM, NULL, 0, 0, 0, 0, (LPARAM)dwData); + } + + CEdit GetEditControl() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return CEdit((HWND)::SendMessage(this->m_hWnd, TVM_GETEDITCONTROL, 0, 0L)); + } + + UINT GetVisibleCount() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, TVM_GETVISIBLECOUNT, 0, 0L); + } + + BOOL GetItemRect(HTREEITEM hItem, LPRECT lpRect, BOOL bTextOnly) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + *(HTREEITEM*)lpRect = hItem; + return (BOOL)::SendMessage(this->m_hWnd, TVM_GETITEMRECT, (WPARAM)bTextOnly, (LPARAM)lpRect); + } + + BOOL ItemHasChildren(HTREEITEM hItem) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + TVITEM item = {}; + item.hItem = hItem; + item.mask = TVIF_CHILDREN; + ::SendMessage(this->m_hWnd, TVM_GETITEM, 0, (LPARAM)&item); + return item.cChildren; + } + + CToolTipCtrl GetToolTips() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return CToolTipCtrl((HWND)::SendMessage(this->m_hWnd, TVM_GETTOOLTIPS, 0, 0L)); + } + + CToolTipCtrl SetToolTips(HWND hWndTT) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return CToolTipCtrl((HWND)::SendMessage(this->m_hWnd, TVM_SETTOOLTIPS, (WPARAM)hWndTT, 0L)); + } + + int GetISearchString(LPTSTR lpstr) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TVM_GETISEARCHSTRING, 0, (LPARAM)lpstr); + } + + // checkboxes only + BOOL GetCheckState(HTREEITEM hItem) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & TVS_CHECKBOXES) != 0); + UINT uRet = GetItemState(hItem, TVIS_STATEIMAGEMASK); + return (uRet >> 12) - 1; + } + + BOOL SetCheckState(HTREEITEM hItem, BOOL bCheck) + { + int nCheck = bCheck ? 2 : 1; // one based index + return SetItemState(hItem, INDEXTOSTATEIMAGEMASK(nCheck), TVIS_STATEIMAGEMASK); + } + + COLORREF GetBkColor() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, TVM_GETBKCOLOR, 0, 0L); + } + + COLORREF SetBkColor(COLORREF clr) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, TVM_SETBKCOLOR, 0, (LPARAM)clr); + } + + COLORREF GetInsertMarkColor() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, TVM_GETINSERTMARKCOLOR, 0, 0L); + } + + COLORREF SetInsertMarkColor(COLORREF clr) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, TVM_SETINSERTMARKCOLOR, 0, (LPARAM)clr); + } + + int GetItemHeight() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TVM_GETITEMHEIGHT, 0, 0L); + } + + int SetItemHeight(int cyHeight) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TVM_SETITEMHEIGHT, cyHeight, 0L); + } + + int GetScrollTime() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TVM_GETSCROLLTIME, 0, 0L); + } + + int SetScrollTime(int nScrollTime) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TVM_SETSCROLLTIME, nScrollTime, 0L); + } + + COLORREF GetTextColor() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, TVM_GETTEXTCOLOR, 0, 0L); + } + + COLORREF SetTextColor(COLORREF clr) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, TVM_SETTEXTCOLOR, 0, (LPARAM)clr); + } + + BOOL GetUnicodeFormat() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_GETUNICODEFORMAT, 0, 0L); + } + + BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_SETUNICODEFORMAT, bUnicode, 0L); + } + + COLORREF GetLineColor() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, TVM_GETLINECOLOR, 0, 0L); + } + + COLORREF SetLineColor(COLORREF clrNew /*= CLR_DEFAULT*/) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, TVM_SETLINECOLOR, 0, (LPARAM)clrNew); + } + + BOOL GetItem(LPTVITEMEX pItem) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_GETITEM, 0, (LPARAM)pItem); + } + + BOOL SetItem(LPTVITEMEX pItem) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_SETITEM, 0, (LPARAM)pItem); + } + + DWORD GetExtendedStyle() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, TVM_GETEXTENDEDSTYLE, 0, 0L); + } + + DWORD SetExtendedStyle(DWORD dwStyle, DWORD dwMask) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, TVM_SETEXTENDEDSTYLE, dwMask, dwStyle); + } + +#if (_WIN32_WINNT >= 0x0600) + BOOL SetAutoScrollInfo(UINT uPixPerSec, UINT uUpdateTime) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_SETAUTOSCROLLINFO, (WPARAM)uPixPerSec, (LPARAM)uUpdateTime); + } + + DWORD GetSelectedCount() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, TVM_GETSELECTEDCOUNT, 0, 0L); + } + + BOOL GetItemPartRect(HTREEITEM hItem, TVITEMPART partID, LPRECT lpRect) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + TVGETITEMPARTRECTINFO gipri = { hItem, lpRect, partID }; + return (BOOL)::SendMessage(this->m_hWnd, TVM_GETITEMPARTRECT, 0, (LPARAM)&gipri); + } +#endif // (_WIN32_WINNT >= 0x0600) + +// Operations + HTREEITEM InsertItem(LPTVINSERTSTRUCT lpInsertStruct) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_INSERTITEM, 0, (LPARAM)lpInsertStruct); + } + + HTREEITEM InsertItem(LPCTSTR lpszItem, int nImage, + int nSelectedImage, HTREEITEM hParent, HTREEITEM hInsertAfter) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return InsertItem(TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE, lpszItem, nImage, nSelectedImage, 0, 0, 0, hParent, hInsertAfter); + } + + HTREEITEM InsertItem(LPCTSTR lpszItem, HTREEITEM hParent, HTREEITEM hInsertAfter) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return InsertItem(TVIF_TEXT, lpszItem, 0, 0, 0, 0, 0, hParent, hInsertAfter); + } + + HTREEITEM InsertItem(UINT nMask, LPCTSTR lpszItem, int nImage, + int nSelectedImage, UINT nState, UINT nStateMask, LPARAM lParam, + HTREEITEM hParent, HTREEITEM hInsertAfter) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + TVINSERTSTRUCT tvis = {}; + tvis.hParent = hParent; + tvis.hInsertAfter = hInsertAfter; + tvis.item.mask = nMask; + tvis.item.pszText = (LPTSTR) lpszItem; + tvis.item.iImage = nImage; + tvis.item.iSelectedImage = nSelectedImage; + tvis.item.state = nState; + tvis.item.stateMask = nStateMask; + tvis.item.lParam = lParam; + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_INSERTITEM, 0, (LPARAM)&tvis); + } + + BOOL DeleteItem(HTREEITEM hItem) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_DELETEITEM, 0, (LPARAM)hItem); + } + + BOOL DeleteAllItems() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_DELETEITEM, 0, (LPARAM)TVI_ROOT); + } + + BOOL Expand(HTREEITEM hItem, UINT nCode = TVE_EXPAND) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_EXPAND, nCode, (LPARAM)hItem); + } + + HTREEITEM GetNextItem(HTREEITEM hItem, UINT nCode) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, nCode, (LPARAM)hItem); + } + + HTREEITEM GetChildItem(HTREEITEM hItem) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_CHILD, (LPARAM)hItem); + } + + HTREEITEM GetNextSiblingItem(HTREEITEM hItem) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_NEXT, (LPARAM)hItem); + } + + HTREEITEM GetPrevSiblingItem(HTREEITEM hItem) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_PREVIOUS, (LPARAM)hItem); + } + + HTREEITEM GetParentItem(HTREEITEM hItem) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_PARENT, (LPARAM)hItem); + } + + HTREEITEM GetFirstVisibleItem() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_FIRSTVISIBLE, 0L); + } + + HTREEITEM GetNextVisibleItem(HTREEITEM hItem) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_NEXTVISIBLE, (LPARAM)hItem); + } + + HTREEITEM GetPrevVisibleItem(HTREEITEM hItem) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_PREVIOUSVISIBLE, (LPARAM)hItem); + } + + HTREEITEM GetSelectedItem() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_CARET, 0L); + } + + HTREEITEM GetDropHilightItem() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_DROPHILITE, 0L); + } + + HTREEITEM GetRootItem() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_ROOT, 0L); + } + + HTREEITEM GetLastVisibleItem() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_LASTVISIBLE, 0L); + } + + HTREEITEM GetNextSelectedItem() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_NEXTSELECTED, 0L); + } + + BOOL Select(HTREEITEM hItem, UINT nCode) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_SELECTITEM, nCode, (LPARAM)hItem); + } + + BOOL SelectItem(HTREEITEM hItem) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_SELECTITEM, TVGN_CARET, (LPARAM)hItem); + } + + BOOL SelectDropTarget(HTREEITEM hItem) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_SELECTITEM, TVGN_DROPHILITE, (LPARAM)hItem); + } + + BOOL SelectSetFirstVisible(HTREEITEM hItem) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_SELECTITEM, TVGN_FIRSTVISIBLE, (LPARAM)hItem); + } + + CEdit EditLabel(HTREEITEM hItem) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return CEdit((HWND)::SendMessage(this->m_hWnd, TVM_EDITLABEL, 0, (LPARAM)hItem)); + } + + BOOL EndEditLabelNow(BOOL bCancel) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_ENDEDITLABELNOW, bCancel, 0L); + } + + HTREEITEM HitTest(TVHITTESTINFO* pHitTestInfo) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_HITTEST, 0, (LPARAM)pHitTestInfo); + } + + HTREEITEM HitTest(POINT pt, UINT* pFlags) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + TVHITTESTINFO hti = {}; + hti.pt = pt; + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_HITTEST, 0, (LPARAM)&hti); + if (pFlags != NULL) + *pFlags = hti.flags; + return hTreeItem; + } + + BOOL SortChildren(HTREEITEM hItem, BOOL bRecurse = FALSE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_SORTCHILDREN, (WPARAM)bRecurse, (LPARAM)hItem); + } + + BOOL EnsureVisible(HTREEITEM hItem) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_ENSUREVISIBLE, 0, (LPARAM)hItem); + } + + BOOL SortChildrenCB(LPTVSORTCB pSort, BOOL bRecurse = FALSE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_SORTCHILDRENCB, (WPARAM)bRecurse, (LPARAM)pSort); + } + + CImageList RemoveImageList(int nImageList) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TVM_SETIMAGELIST, (WPARAM)nImageList, NULL)); + } + + CImageList CreateDragImage(HTREEITEM hItem) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TVM_CREATEDRAGIMAGE, 0, (LPARAM)hItem)); + } + + BOOL SetInsertMark(HTREEITEM hTreeItem, BOOL bAfter) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_SETINSERTMARK, bAfter, (LPARAM)hTreeItem); + } + + BOOL RemoveInsertMark() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TVM_SETINSERTMARK, 0, 0L); + } + + HTREEITEM MapAccIDToHTREEITEM(UINT uID) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_MAPACCIDTOHTREEITEM, uID, 0L); + } + + UINT MapHTREEITEMToAccID(HTREEITEM hTreeItem) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, TVM_MAPHTREEITEMTOACCID, (WPARAM)hTreeItem, 0L); + } + +#if (_WIN32_WINNT >= 0x0600) + void ShowInfoTip(HTREEITEM hItem) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TVM_SHOWINFOTIP, 0, (LPARAM)hItem); + } +#endif // (_WIN32_WINNT >= 0x0600) +}; + +typedef CTreeViewCtrlT CTreeViewCtrl; + + +/////////////////////////////////////////////////////////////////////////////// +// CTreeViewCtrlEx + +// forward declaration +template class CTreeViewCtrlExT; + +// Note: TBase here is for CTreeViewCtrlExT, and not for CTreeItemT itself +template +class CTreeItemT +{ +public: + HTREEITEM m_hTreeItem; + CTreeViewCtrlExT* m_pTreeView; + +// Construction + CTreeItemT(HTREEITEM hTreeItem = NULL, CTreeViewCtrlExT* pTreeView = NULL) : m_hTreeItem(hTreeItem), m_pTreeView(pTreeView) + { } + + CTreeItemT(const CTreeItemT& posSrc) + { + *this = posSrc; + } + + operator HTREEITEM() { return m_hTreeItem; } + + CTreeItemT& operator =(const CTreeItemT& itemSrc) + { + m_hTreeItem = itemSrc.m_hTreeItem; + m_pTreeView = itemSrc.m_pTreeView; + return *this; + } + +// Attributes + CTreeViewCtrlExT* GetTreeView() const { return m_pTreeView; } + + BOOL operator !() const { return m_hTreeItem == NULL; } + + BOOL IsNull() const { return m_hTreeItem == NULL; } + + BOOL GetRect(LPRECT lpRect, BOOL bTextOnly) const; + BOOL GetText(LPTSTR lpstrText, int nLen) const; + BOOL GetText(BSTR& bstrText) const; +#ifdef __ATLSTR_H__ + BOOL GetText(ATL::CString& strText) const; +#endif // __ATLSTR_H__ + BOOL SetText(LPCTSTR lpszItem); + BOOL GetImage(int& nImage, int& nSelectedImage) const; + BOOL SetImage(int nImage, int nSelectedImage); + UINT GetState(UINT nStateMask) const; + BOOL SetState(UINT nState, UINT nStateMask); + DWORD_PTR GetData() const; + BOOL SetData(DWORD_PTR dwData); + BOOL SetItem(UINT nMask, LPCTSTR lpszItem, int nImage, int nSelectedImage, UINT nState, UINT nStateMask, LPARAM lParam); + +// Operations + CTreeItemT InsertAfter(LPCTSTR lpstrItem, HTREEITEM hItemAfter, int nImageIndex) + { + return _Insert(lpstrItem, nImageIndex, hItemAfter); + } + + CTreeItemT AddHead(LPCTSTR lpstrItem, int nImageIndex) + { + return _Insert(lpstrItem, nImageIndex, TVI_FIRST); + } + + CTreeItemT AddTail(LPCTSTR lpstrItem, int nImageIndex) + { + return _Insert(lpstrItem, nImageIndex, TVI_LAST); + } + + CTreeItemT GetChild() const; + CTreeItemT GetNext(UINT nCode) const; + CTreeItemT GetNextSibling() const; + CTreeItemT GetPrevSibling() const; + CTreeItemT GetParent() const; + CTreeItemT GetFirstVisible() const; + CTreeItemT GetNextVisible() const; + CTreeItemT GetPrevVisible() const; + CTreeItemT GetSelected() const; + CTreeItemT GetDropHilight() const; + CTreeItemT GetRoot() const; + CTreeItemT GetLastVisible() const; + CTreeItemT GetNextSelected() const; + BOOL HasChildren() const; + BOOL Delete(); + BOOL Expand(UINT nCode = TVE_EXPAND); + BOOL Select(UINT nCode); + BOOL Select(); + BOOL SelectDropTarget(); + BOOL SelectSetFirstVisible(); + HWND EditLabel(); + HIMAGELIST CreateDragImage(); + BOOL SortChildren(BOOL bRecurse = FALSE); + BOOL EnsureVisible(); + CTreeItemT _Insert(LPCTSTR lpstrItem, int nImageIndex, HTREEITEM hItemAfter); + int GetImageIndex() const; + BOOL SetInsertMark(BOOL bAfter); + UINT MapHTREEITEMToAccID() const; +#if (_WIN32_WINNT >= 0x0600) + void ShowInfoTip(); + BOOL GetPartRect(TVITEMPART partID, LPRECT lpRect) const; +#endif // (_WIN32_WINNT >= 0x0600) +}; + +typedef CTreeItemT CTreeItem; + + +template +class CTreeViewCtrlExT : public CTreeViewCtrlT< TBase > +{ +public: +// Constructors + CTreeViewCtrlExT(HWND hWnd = NULL) : CTreeViewCtrlT< TBase >(hWnd) + { } + + CTreeViewCtrlExT< TBase >& operator =(HWND hWnd) + { + this->m_hWnd = hWnd; + return *this; + } + +// Operations (overides that return CTreeItem) + CTreeItemT InsertItem(LPTVINSERTSTRUCT lpInsertStruct) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_INSERTITEM, 0, (LPARAM)lpInsertStruct); + return CTreeItemT(hTreeItem, this); + } + + CTreeItemT InsertItem(LPCTSTR lpszItem, int nImage, + int nSelectedImage, HTREEITEM hParent, HTREEITEM hInsertAfter) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return InsertItem(TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE, lpszItem, nImage, nSelectedImage, 0, 0, 0, hParent, hInsertAfter); + } + + CTreeItemT InsertItem(LPCTSTR lpszItem, HTREEITEM hParent, HTREEITEM hInsertAfter) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return InsertItem(TVIF_TEXT, lpszItem, 0, 0, 0, 0, 0, hParent, hInsertAfter); + } + + CTreeItemT GetNextItem(HTREEITEM hItem, UINT nCode) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, nCode, (LPARAM)hItem); + return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this); + } + + CTreeItemT GetChildItem(HTREEITEM hItem) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_CHILD, (LPARAM)hItem); + return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this); + } + + CTreeItemT GetNextSiblingItem(HTREEITEM hItem) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_NEXT, (LPARAM)hItem); + return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this); + } + + CTreeItemT GetPrevSiblingItem(HTREEITEM hItem) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_PREVIOUS, (LPARAM)hItem); + return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this); + } + + CTreeItemT GetParentItem(HTREEITEM hItem) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_PARENT, (LPARAM)hItem); + return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this); + } + + CTreeItemT GetFirstVisibleItem() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_FIRSTVISIBLE, 0L); + return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this); + } + + CTreeItemT GetNextVisibleItem(HTREEITEM hItem) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_NEXTVISIBLE, (LPARAM)hItem); + return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this); + } + + CTreeItemT GetPrevVisibleItem(HTREEITEM hItem) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_PREVIOUSVISIBLE, (LPARAM)hItem); + return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this); + } + + CTreeItemT GetSelectedItem() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_CARET, 0L); + return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this); + } + + CTreeItemT GetDropHilightItem() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_DROPHILITE, 0L); + return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this); + } + + CTreeItemT GetRootItem() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_ROOT, 0L); + return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this); + } + + CTreeItemT GetLastVisibleItem() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_LASTVISIBLE, 0L); + return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this); + } + + CTreeItemT GetNextSelectedItem() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_NEXTSELECTED, 0L); + return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this); + } + + CTreeItemT HitTest(TVHITTESTINFO* pHitTestInfo) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_HITTEST, 0, (LPARAM)pHitTestInfo); + return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this); + } + + CTreeItemT InsertItem(UINT nMask, LPCTSTR lpszItem, int nImage, + int nSelectedImage, UINT nState, UINT nStateMask, LPARAM lParam, + HTREEITEM hParent, HTREEITEM hInsertAfter) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + TVINSERTSTRUCT tvis = {}; + tvis.hParent = hParent; + tvis.hInsertAfter = hInsertAfter; + tvis.item.mask = nMask; + tvis.item.pszText = (LPTSTR) lpszItem; + tvis.item.iImage = nImage; + tvis.item.iSelectedImage = nSelectedImage; + tvis.item.state = nState; + tvis.item.stateMask = nStateMask; + tvis.item.lParam = lParam; + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_INSERTITEM, 0, (LPARAM)&tvis); + return CTreeItemT(hTreeItem, this); + } + + CTreeItemT HitTest(POINT pt, UINT* pFlags) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + TVHITTESTINFO hti = {}; + hti.pt = pt; + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_HITTEST, 0, (LPARAM)&hti); + if (pFlags != NULL) + *pFlags = hti.flags; + return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this); + } + + CTreeItemT MapAccIDToHTREEITEM(UINT uID) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_MAPACCIDTOHTREEITEM, uID, 0L); + return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this); + } +}; + +typedef CTreeViewCtrlExT CTreeViewCtrlEx; + + +// CTreeItem inline methods +template +inline BOOL CTreeItemT::GetRect(LPRECT lpRect, BOOL bTextOnly) const +{ + ATLASSERT(m_pTreeView != NULL); + return m_pTreeView->GetItemRect(m_hTreeItem,lpRect,bTextOnly); +} + +template +inline CTreeItemT CTreeItemT::GetNext(UINT nCode) const +{ + ATLASSERT(m_pTreeView != NULL); + return m_pTreeView->GetNextItem(m_hTreeItem,nCode); +} + +template +inline CTreeItemT CTreeItemT::GetChild() const +{ + ATLASSERT(m_pTreeView != NULL); + return m_pTreeView->GetChildItem(m_hTreeItem); +} + +template +inline CTreeItemT CTreeItemT::GetNextSibling() const +{ + ATLASSERT(m_pTreeView != NULL); + return m_pTreeView->GetNextSiblingItem(m_hTreeItem); +} + +template +inline CTreeItemT CTreeItemT::GetPrevSibling() const +{ + ATLASSERT(m_pTreeView != NULL); + return m_pTreeView->GetPrevSiblingItem(m_hTreeItem); +} + +template +inline CTreeItemT CTreeItemT::GetParent() const +{ + ATLASSERT(m_pTreeView != NULL); + return m_pTreeView->GetParentItem(m_hTreeItem); +} + +template +inline CTreeItemT CTreeItemT::GetFirstVisible() const +{ + ATLASSERT(m_pTreeView != NULL); + return m_pTreeView->GetFirstVisibleItem(); +} + +template +inline CTreeItemT CTreeItemT::GetNextVisible() const +{ + ATLASSERT(m_pTreeView != NULL); + return m_pTreeView->GetNextVisibleItem(m_hTreeItem); +} + +template +inline CTreeItemT CTreeItemT::GetPrevVisible() const +{ + ATLASSERT(m_pTreeView != NULL); + return m_pTreeView->GetPrevVisibleItem(m_hTreeItem); +} + +template +inline CTreeItemT CTreeItemT::GetSelected() const +{ + ATLASSERT(m_pTreeView != NULL); + return m_pTreeView->GetSelectedItem(); +} + +template +inline CTreeItemT CTreeItemT::GetDropHilight() const +{ + ATLASSERT(m_pTreeView != NULL); + return m_pTreeView->GetDropHilightItem(); +} + +template +inline CTreeItemT CTreeItemT::GetRoot() const +{ + ATLASSERT(m_pTreeView != NULL); + return m_pTreeView->GetRootItem(); +} + +template +inline CTreeItemT CTreeItemT::GetLastVisible() const +{ + ATLASSERT(m_pTreeView != NULL); + return m_pTreeView->GetLastVisibleItem(); +} + +template +inline CTreeItemT CTreeItemT::GetNextSelected() const +{ + ATLASSERT(m_pTreeView != NULL); + return m_pTreeView->GetNextSelectedItem(); +} + +template +inline BOOL CTreeItemT::GetText(LPTSTR lpstrText, int nLen) const +{ + ATLASSERT(m_pTreeView != NULL); + return m_pTreeView->GetItemText(m_hTreeItem, lpstrText, nLen); +} + +#ifdef _OLEAUTO_H_ +template +inline BOOL CTreeItemT::GetText(BSTR& bstrText) const +{ + ATLASSERT(m_pTreeView != NULL); + return m_pTreeView->GetItemText(m_hTreeItem, bstrText); +} +#endif // _OLEAUTO_H_ + +#ifdef __ATLSTR_H__ +template +inline BOOL CTreeItemT::GetText(ATL::CString& strText) const +{ + ATLASSERT(m_pTreeView != NULL); + return m_pTreeView->GetItemText(m_hTreeItem, strText); +} +#endif // __ATLSTR_H__ + +template +inline BOOL CTreeItemT::GetImage(int& nImage, int& nSelectedImage) const +{ + ATLASSERT(m_pTreeView != NULL); + return m_pTreeView->GetItemImage(m_hTreeItem,nImage,nSelectedImage); +} + +template +inline UINT CTreeItemT::GetState(UINT nStateMask) const +{ + ATLASSERT(m_pTreeView != NULL); + return m_pTreeView->GetItemState(m_hTreeItem,nStateMask); +} + +template +inline DWORD_PTR CTreeItemT::GetData() const +{ + ATLASSERT(m_pTreeView != NULL); + return m_pTreeView->GetItemData(m_hTreeItem); +} + +template +inline BOOL CTreeItemT::SetItem(UINT nMask, LPCTSTR lpszItem, int nImage, + int nSelectedImage, UINT nState, UINT nStateMask, LPARAM lParam) +{ + ATLASSERT(m_pTreeView != NULL); + return m_pTreeView->SetItem(m_hTreeItem, nMask, lpszItem, nImage, nSelectedImage, nState, nStateMask, lParam); +} + +template +inline BOOL CTreeItemT::SetText(LPCTSTR lpszItem) +{ + ATLASSERT(m_pTreeView != NULL); + return m_pTreeView->SetItemText(m_hTreeItem,lpszItem); +} + +template +inline BOOL CTreeItemT::SetImage(int nImage, int nSelectedImage) +{ + ATLASSERT(m_pTreeView != NULL); + return m_pTreeView->SetItemImage(m_hTreeItem,nImage,nSelectedImage); +} + +template +inline BOOL CTreeItemT::SetState(UINT nState, UINT nStateMask) +{ + ATLASSERT(m_pTreeView != NULL); + return m_pTreeView->SetItemState(m_hTreeItem,nState,nStateMask); +} + +template +inline BOOL CTreeItemT::SetData(DWORD_PTR dwData) +{ + ATLASSERT(m_pTreeView != NULL); + return m_pTreeView->SetItemData(m_hTreeItem,dwData); +} + +template +inline BOOL CTreeItemT::HasChildren() const +{ + ATLASSERT(m_pTreeView != NULL); + return m_pTreeView->ItemHasChildren(m_hTreeItem); +} + +template +inline BOOL CTreeItemT::Delete() +{ + ATLASSERT(m_pTreeView != NULL); + return m_pTreeView->DeleteItem(m_hTreeItem); +} + +template +inline BOOL CTreeItemT::Expand(UINT nCode /*= TVE_EXPAND*/) +{ + ATLASSERT(m_pTreeView != NULL); + return m_pTreeView->Expand(m_hTreeItem,nCode); +} + +template +inline BOOL CTreeItemT::Select(UINT nCode) +{ + ATLASSERT(m_pTreeView != NULL); + return m_pTreeView->Select(m_hTreeItem,nCode); +} + +template +inline BOOL CTreeItemT::Select() +{ + ATLASSERT(m_pTreeView != NULL); + return m_pTreeView->SelectItem(m_hTreeItem); +} + +template +inline BOOL CTreeItemT::SelectDropTarget() +{ + ATLASSERT(m_pTreeView != NULL); + return m_pTreeView->SelectDropTarget(m_hTreeItem); +} + +template +inline BOOL CTreeItemT::SelectSetFirstVisible() +{ + ATLASSERT(m_pTreeView != NULL); + return m_pTreeView->SelectSetFirstVisible(m_hTreeItem); +} + +template +inline HWND CTreeItemT::EditLabel() +{ + ATLASSERT(m_pTreeView != NULL); + return m_pTreeView->EditLabel(m_hTreeItem); +} + +template +inline HIMAGELIST CTreeItemT::CreateDragImage() +{ + ATLASSERT(m_pTreeView != NULL); + return m_pTreeView->CreateDragImage(m_hTreeItem); +} + +template +inline BOOL CTreeItemT::SortChildren(BOOL bRecurse /*= FALSE*/) +{ + ATLASSERT(m_pTreeView != NULL); + return m_pTreeView->SortChildren(m_hTreeItem, bRecurse); +} + +template +inline BOOL CTreeItemT::EnsureVisible() +{ + ATLASSERT(m_pTreeView != NULL); + return m_pTreeView->EnsureVisible(m_hTreeItem); +} + +template +inline CTreeItemT CTreeItemT::_Insert(LPCTSTR lpstrItem, int nImageIndex, HTREEITEM hItemAfter) +{ + ATLASSERT(m_pTreeView != NULL); + TVINSERTSTRUCT ins = {}; + ins.hParent = m_hTreeItem; + ins.hInsertAfter = hItemAfter; + ins.item.mask = TVIF_TEXT; + ins.item.pszText = (LPTSTR)lpstrItem; + if(nImageIndex != -1) + { + ins.item.mask |= TVIF_IMAGE | TVIF_SELECTEDIMAGE; + ins.item.iImage = nImageIndex; + ins.item.iSelectedImage = nImageIndex; + } + return CTreeItemT(m_pTreeView->InsertItem(&ins), m_pTreeView); +} + +template +inline int CTreeItemT::GetImageIndex() const +{ + ATLASSERT(m_pTreeView != NULL); + TVITEM item = {}; + item.mask = TVIF_HANDLE | TVIF_IMAGE; + item.hItem = m_hTreeItem; + m_pTreeView->GetItem(&item); + return item.iImage; +} + +template +inline BOOL CTreeItemT::SetInsertMark(BOOL bAfter) +{ + ATLASSERT(m_pTreeView != NULL); + return m_pTreeView->SetInsertMark(m_hTreeItem, bAfter); +} + +template +inline UINT CTreeItemT::MapHTREEITEMToAccID() const +{ + ATLASSERT(m_pTreeView != NULL); + return m_pTreeView->MapHTREEITEMToAccID(m_hTreeItem); +} + +#if (_WIN32_WINNT >= 0x0600) +template +inline void CTreeItemT::ShowInfoTip() +{ + ATLASSERT(m_pTreeView != NULL); + m_pTreeView->ShowInfoTip(m_hTreeItem); +} + +template +inline BOOL CTreeItemT::GetPartRect(TVITEMPART partID, LPRECT lpRect) const +{ + ATLASSERT(m_pTreeView != NULL); + return m_pTreeView->GetItemPartRect(m_hTreeItem, partID, lpRect); +} +#endif // (_WIN32_WINNT >= 0x0600) + + +/////////////////////////////////////////////////////////////////////////////// +// CToolBarCtrl + +template +class CToolBarCtrlT : public TBase +{ +public: +// Construction + CToolBarCtrlT(HWND hWnd = NULL) : TBase(hWnd) + { } + + CToolBarCtrlT< TBase >& operator =(HWND hWnd) + { + this->m_hWnd = hWnd; + return *this; + } + + HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, + DWORD dwStyle = 0, DWORD dwExStyle = 0, + ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) + { + return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); + } + +// Attributes + static LPCTSTR GetWndClassName() + { + return TOOLBARCLASSNAME; + } + + BOOL IsButtonEnabled(int nID) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_ISBUTTONENABLED, nID, 0L); + } + + BOOL IsButtonChecked(int nID) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_ISBUTTONCHECKED, nID, 0L); + } + + BOOL IsButtonPressed(int nID) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_ISBUTTONPRESSED, nID, 0L); + } + + BOOL IsButtonHidden(int nID) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return(BOOL) ::SendMessage(this->m_hWnd, TB_ISBUTTONHIDDEN, nID, 0L); + } + + BOOL IsButtonIndeterminate(int nID) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_ISBUTTONINDETERMINATE, nID, 0L); + } + + int GetState(int nID) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TB_GETSTATE, nID, 0L); + } + + BOOL SetState(int nID, UINT nState) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_SETSTATE, nID, MAKELPARAM(nState, 0)); + } + + BOOL GetButton(int nIndex, LPTBBUTTON lpButton) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_GETBUTTON, nIndex, (LPARAM)lpButton); + } + + int GetButtonCount() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TB_BUTTONCOUNT, 0, 0L); + } + + BOOL GetItemRect(int nIndex, LPRECT lpRect) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_GETITEMRECT, nIndex, (LPARAM)lpRect); + } + + void SetButtonStructSize(int nSize = sizeof(TBBUTTON)) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TB_BUTTONSTRUCTSIZE, nSize, 0L); + } + + BOOL SetButtonSize(SIZE size) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_SETBUTTONSIZE, 0, MAKELPARAM(size.cx, size.cy)); + } + + BOOL SetButtonSize(int cx, int cy) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_SETBUTTONSIZE, 0, MAKELPARAM(cx, cy)); + } + + BOOL SetBitmapSize(SIZE size) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_SETBITMAPSIZE, 0, MAKELPARAM(size.cx, size.cy)); + } + + BOOL SetBitmapSize(int cx, int cy) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_SETBITMAPSIZE, 0, MAKELPARAM(cx, cy)); + } + + CToolTipCtrl GetToolTips() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return CToolTipCtrl((HWND)::SendMessage(this->m_hWnd, TB_GETTOOLTIPS, 0, 0L)); + } + + void SetToolTips(HWND hWndToolTip) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TB_SETTOOLTIPS, (WPARAM)hWndToolTip, 0L); + } + + void SetNotifyWnd(HWND hWnd) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TB_SETPARENT, (WPARAM)hWnd, 0L); + } + + int GetRows() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TB_GETROWS, 0, 0L); + } + + void SetRows(int nRows, BOOL bLarger, LPRECT lpRect) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TB_SETROWS, MAKELPARAM(nRows, bLarger), (LPARAM)lpRect); + } + + BOOL SetCmdID(int nIndex, UINT nID) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_SETCMDID, nIndex, nID); + } + + DWORD GetBitmapFlags() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, TB_GETBITMAPFLAGS, 0, 0L); + } + + int GetBitmap(int nID) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TB_GETBITMAP, nID, 0L); + } + + int GetButtonText(int nID, LPTSTR lpstrText) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TB_GETBUTTONTEXT, nID, (LPARAM)lpstrText); + } + + // nIndex - IE5 or higher only + CImageList GetImageList(int nIndex = 0) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TB_GETIMAGELIST, nIndex, 0L)); + } + + // nIndex - IE5 or higher only + CImageList SetImageList(HIMAGELIST hImageList, int nIndex = 0) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TB_SETIMAGELIST, nIndex, (LPARAM)hImageList)); + } + + // nIndex - IE5 or higher only + CImageList GetDisabledImageList(int nIndex = 0) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TB_GETDISABLEDIMAGELIST, nIndex, 0L)); + } + + // nIndex - IE5 or higher only + CImageList SetDisabledImageList(HIMAGELIST hImageList, int nIndex = 0) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TB_SETDISABLEDIMAGELIST, nIndex, (LPARAM)hImageList)); + } + + // nIndex - IE5 or higher only + CImageList GetHotImageList(int nIndex = 0) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TB_GETHOTIMAGELIST, nIndex, 0L)); + } + + // nIndex - IE5 or higher only + CImageList SetHotImageList(HIMAGELIST hImageList, int nIndex = 0) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TB_SETHOTIMAGELIST, nIndex, (LPARAM)hImageList)); + } + + DWORD GetStyle() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, TB_GETSTYLE, 0, 0L); + } + + void SetStyle(DWORD dwStyle) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TB_SETSTYLE, 0, dwStyle); + } + + DWORD GetButtonSize() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, TB_GETBUTTONSIZE, 0, 0L); + } + + void GetButtonSize(SIZE& size) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, TB_GETBUTTONSIZE, 0, 0L); + size.cx = LOWORD(dwRet); + size.cy = HIWORD(dwRet); + } + + BOOL GetRect(int nID, LPRECT lpRect) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_GETRECT, nID, (LPARAM)lpRect); + } + + int GetTextRows() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TB_GETTEXTROWS, 0, 0L); + } + + BOOL SetButtonWidth(int cxMin, int cxMax) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_SETBUTTONWIDTH, 0, MAKELPARAM(cxMin, cxMax)); + } + + BOOL SetIndent(int nIndent) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_SETINDENT, nIndent, 0L); + } + + BOOL SetMaxTextRows(int nMaxTextRows) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_SETMAXTEXTROWS, nMaxTextRows, 0L); + } + + BOOL GetAnchorHighlight() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_GETANCHORHIGHLIGHT, 0, 0L); + } + + BOOL SetAnchorHighlight(BOOL bEnable = TRUE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_SETANCHORHIGHLIGHT, bEnable, 0L); + } + + int GetButtonInfo(int nID, LPTBBUTTONINFO lptbbi) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TB_GETBUTTONINFO, nID, (LPARAM)lptbbi); + } + + BOOL SetButtonInfo(int nID, LPTBBUTTONINFO lptbbi) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_SETBUTTONINFO, nID, (LPARAM)lptbbi); + } + + BOOL SetButtonInfo(int nID, DWORD dwMask, BYTE Style, BYTE State, LPCTSTR lpszItem, + int iImage, WORD cx, int iCommand, DWORD_PTR lParam) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + TBBUTTONINFO tbbi = {}; + tbbi.cbSize = sizeof(TBBUTTONINFO); + tbbi.dwMask = dwMask; + tbbi.idCommand = iCommand; + tbbi.iImage = iImage; + tbbi.fsState = State; + tbbi.fsStyle = Style; + tbbi.cx = cx; + tbbi.pszText = (LPTSTR) lpszItem; + tbbi.lParam = lParam; + return (BOOL)::SendMessage(this->m_hWnd, TB_SETBUTTONINFO, nID, (LPARAM)&tbbi); + } + + int GetHotItem() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TB_GETHOTITEM, 0, 0L); + } + + int SetHotItem(int nItem) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TB_SETHOTITEM, nItem, 0L); + } + + BOOL IsButtonHighlighted(int nButtonID) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_ISBUTTONHIGHLIGHTED, nButtonID, 0L); + } + + DWORD SetDrawTextFlags(DWORD dwMask, DWORD dwFlags) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, TB_SETDRAWTEXTFLAGS, dwMask, dwFlags); + } + + BOOL GetColorScheme(LPCOLORSCHEME lpcs) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_GETCOLORSCHEME, 0, (LPARAM)lpcs); + } + + void SetColorScheme(LPCOLORSCHEME lpcs) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TB_SETCOLORSCHEME, 0, (LPARAM)lpcs); + } + + DWORD GetExtendedStyle() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, TB_GETEXTENDEDSTYLE, 0, 0L); + } + + DWORD SetExtendedStyle(DWORD dwStyle) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, TB_SETEXTENDEDSTYLE, 0, dwStyle); + } + + void GetInsertMark(LPTBINSERTMARK lptbim) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TB_GETINSERTMARK, 0, (LPARAM)lptbim); + } + + void SetInsertMark(LPTBINSERTMARK lptbim) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TB_SETINSERTMARK, 0, (LPARAM)lptbim); + } + + COLORREF GetInsertMarkColor() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, TB_GETINSERTMARKCOLOR, 0, 0L); + } + + COLORREF SetInsertMarkColor(COLORREF clr) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, TB_SETINSERTMARKCOLOR, 0, (LPARAM)clr); + } + + BOOL GetMaxSize(LPSIZE lpSize) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_GETMAXSIZE, 0, (LPARAM)lpSize); + } + + void GetPadding(LPSIZE lpSizePadding) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(lpSizePadding != NULL); + DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, TB_GETPADDING, 0, 0L); + lpSizePadding->cx = GET_X_LPARAM(dwRet); + lpSizePadding->cy = GET_Y_LPARAM(dwRet); + } + + void SetPadding(int cx, int cy, LPSIZE lpSizePadding = NULL) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, TB_SETPADDING, 0, MAKELPARAM(cx, cy)); + if(lpSizePadding != NULL) + { + lpSizePadding->cx = GET_X_LPARAM(dwRet); + lpSizePadding->cy = GET_Y_LPARAM(dwRet); + } + } + + BOOL GetUnicodeFormat() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_GETUNICODEFORMAT, 0, 0L); + } + + BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_SETUNICODEFORMAT, bUnicode, 0L); + } + + int GetString(int nString, LPTSTR lpstrString, int cchMaxLen) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TB_GETSTRING, MAKEWPARAM(cchMaxLen, nString), (LPARAM)lpstrString); + } + + int GetStringBSTR(int nString, BSTR& bstrString) const + { + USES_CONVERSION; + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(bstrString == NULL); + int nLength = (int)(short)LOWORD(::SendMessage(this->m_hWnd, TB_GETSTRING, MAKEWPARAM(0, nString), NULL)); + if(nLength != -1) + { + ATL::CTempBuffer buff; + LPTSTR lpstrText = buff.Allocate(nLength + 1); + if(lpstrText != NULL) + { + nLength = (int)::SendMessage(this->m_hWnd, TB_GETSTRING, MAKEWPARAM(nLength + 1, nString), (LPARAM)lpstrText); + if(nLength != -1) + bstrString = ::SysAllocString(T2OLE(lpstrText)); + } + else + { + nLength = -1; + } + } + + return nLength; + } + +#ifdef __ATLSTR_H__ + int GetString(int nString, ATL::CString& str) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + int nLength = (int)(short)LOWORD(::SendMessage(this->m_hWnd, TB_GETSTRING, MAKEWPARAM(0, nString), NULL)); + if(nLength != -1) + { + LPTSTR lpstr = str.GetBufferSetLength(nLength + 1); + if(lpstr != NULL) + nLength = (int)::SendMessage(this->m_hWnd, TB_GETSTRING, MAKEWPARAM(nLength + 1, nString), (LPARAM)lpstr); + else + nLength = -1; + str.ReleaseBuffer(); + } + return nLength; + } +#endif // __ATLSTR_H__ + + void GetMetrics(LPTBMETRICS lptbm) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TB_GETMETRICS, 0, (LPARAM)lptbm); + } + + void SetMetrics(LPTBMETRICS lptbm) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TB_SETMETRICS, 0, (LPARAM)lptbm); + } + + void SetWindowTheme(LPCWSTR lpstrTheme) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TB_SETWINDOWTHEME, 0, (LPARAM)lpstrTheme); + } + +#if (_WIN32_WINNT >= 0x0600) + CImageList GetPressedImageList(int nIndex = 0) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TB_GETPRESSEDIMAGELIST, nIndex, 0L)); + } + + CImageList SetPressedImageList(HIMAGELIST hImageList, int nIndex = 0) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TB_SETPRESSEDIMAGELIST, nIndex, (LPARAM)hImageList)); + } + + void GetItemDropDownRect(int nIndex, LPRECT lpRect) const + { +#ifndef TB_GETITEMDROPDOWNRECT + const int TB_GETITEMDROPDOWNRECT = WM_USER + 103; +#endif + ATLASSERT(::IsWindow(this->m_hWnd)); + BOOL bRet = (BOOL)::SendMessage(this->m_hWnd, TB_GETITEMDROPDOWNRECT, nIndex, (LPARAM)lpRect); + (void)bRet; // avoid level 4 warning + ATLASSERT(bRet != FALSE); + } +#endif // (_WIN32_WINNT >= 0x0600) + +// Operations + BOOL EnableButton(int nID, BOOL bEnable = TRUE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_ENABLEBUTTON, nID, MAKELPARAM(bEnable, 0)); + } + + BOOL CheckButton(int nID, BOOL bCheck = TRUE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_CHECKBUTTON, nID, MAKELPARAM(bCheck, 0)); + } + + BOOL PressButton(int nID, BOOL bPress = TRUE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_PRESSBUTTON, nID, MAKELPARAM(bPress, 0)); + } + + BOOL HideButton(int nID, BOOL bHide = TRUE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_HIDEBUTTON, nID, MAKELPARAM(bHide, 0)); + } + + BOOL Indeterminate(int nID, BOOL bIndeterminate = TRUE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_INDETERMINATE, nID, MAKELPARAM(bIndeterminate, 0)); + } + + int AddBitmap(int nNumButtons, UINT nBitmapID) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + TBADDBITMAP tbab = {}; + tbab.hInst = ModuleHelper::GetResourceInstance(); + ATLASSERT(tbab.hInst != NULL); + tbab.nID = nBitmapID; + return (int)::SendMessage(this->m_hWnd, TB_ADDBITMAP, (WPARAM)nNumButtons, (LPARAM)&tbab); + } + + int AddBitmap(int nNumButtons, HBITMAP hBitmap) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + TBADDBITMAP tbab = {}; + tbab.hInst = NULL; + tbab.nID = (UINT_PTR)hBitmap; + return (int)::SendMessage(this->m_hWnd, TB_ADDBITMAP, (WPARAM)nNumButtons, (LPARAM)&tbab); + } + + BOOL AddButtons(int nNumButtons, LPCTBBUTTON lpButtons) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_ADDBUTTONS, nNumButtons, (LPARAM)lpButtons); + } + + BOOL InsertButton(int nIndex, LPCTBBUTTON lpButton) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_INSERTBUTTON, nIndex, (LPARAM)lpButton); + } + + BOOL InsertButton(int nIndex, int iCommand, BYTE Style, BYTE State, int iBitmap, + INT_PTR iString, DWORD_PTR lParam) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + TBBUTTON tbb = {}; + tbb.fsStyle = Style; + tbb.fsState = State; + tbb.idCommand = iCommand; + tbb.iBitmap = iBitmap; + tbb.iString = iString; + tbb.dwData = lParam; + return (BOOL)::SendMessage(this->m_hWnd, TB_INSERTBUTTON, nIndex, (LPARAM)&tbb); + } + + BOOL InsertButton(int nIndex, int iCommand, BYTE Style, BYTE State, int iBitmap, + LPCTSTR lpszItem, DWORD_PTR lParam) + { + return InsertButton(nIndex, iCommand, Style, State, iBitmap, (INT_PTR)lpszItem, lParam); + } + + BOOL AddButton(LPTBBUTTON lpButton) + { + return InsertButton(-1, lpButton); + } + + BOOL AddButton(int iCommand, BYTE Style, BYTE State, int iBitmap, INT_PTR iString, DWORD_PTR lParam) + { + return InsertButton(-1, iCommand, Style, State, iBitmap, iString, lParam); + } + + BOOL AddButton(int iCommand, BYTE Style, BYTE State, int iBitmap, LPCTSTR lpszItem, DWORD_PTR lParam) + { + return InsertButton(-1, iCommand, Style, State, iBitmap, lpszItem, lParam); + } + + BOOL DeleteButton(int nIndex) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_DELETEBUTTON, nIndex, 0L); + } + + BOOL InsertSeparator(int nIndex, int cxWidth = 8) + { + return InsertButton(nIndex, 0, BTNS_SEP, 0, cxWidth, (INT_PTR)0, 0); + } + + BOOL AddSeparator(int cxWidth = 8) + { + return AddButton(0, BTNS_SEP, 0, cxWidth, (INT_PTR)0, 0); + } + + int CommandToIndex(UINT nID) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TB_COMMANDTOINDEX, nID, 0L); + } + + void SaveState(HKEY hKeyRoot, LPCTSTR lpszSubKey, LPCTSTR lpszValueName) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + TBSAVEPARAMS tbs = {}; + tbs.hkr = hKeyRoot; + tbs.pszSubKey = lpszSubKey; + tbs.pszValueName = lpszValueName; + ::SendMessage(this->m_hWnd, TB_SAVERESTORE, (WPARAM)TRUE, (LPARAM)&tbs); + } + + void RestoreState(HKEY hKeyRoot, LPCTSTR lpszSubKey, LPCTSTR lpszValueName) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + TBSAVEPARAMS tbs = {}; + tbs.hkr = hKeyRoot; + tbs.pszSubKey = lpszSubKey; + tbs.pszValueName = lpszValueName; + ::SendMessage(this->m_hWnd, TB_SAVERESTORE, (WPARAM)FALSE, (LPARAM)&tbs); + } + + void Customize() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TB_CUSTOMIZE, 0, 0L); + } + + int AddString(UINT nStringID) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TB_ADDSTRING, (WPARAM)ModuleHelper::GetResourceInstance(), (LPARAM)nStringID); + } + + int AddStrings(LPCTSTR lpszStrings) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TB_ADDSTRING, 0, (LPARAM)lpszStrings); + } + + void AutoSize() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TB_AUTOSIZE, 0, 0L); + } + + BOOL ChangeBitmap(int nID, int nBitmap) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_CHANGEBITMAP, nID, MAKELPARAM(nBitmap, 0)); + } + + int LoadImages(int nBitmapID) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TB_LOADIMAGES, nBitmapID, (LPARAM)ModuleHelper::GetResourceInstance()); + } + + int LoadStdImages(int nBitmapID) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TB_LOADIMAGES, nBitmapID, (LPARAM)HINST_COMMCTRL); + } + + BOOL ReplaceBitmap(LPTBREPLACEBITMAP ptbrb) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_REPLACEBITMAP, 0, (LPARAM)ptbrb); + } + + int HitTest(LPPOINT lpPoint) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TB_HITTEST, 0, (LPARAM)lpPoint); + } + + BOOL InsertMarkHitTest(LPPOINT lpPoint, LPTBINSERTMARK lptbim) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_INSERTMARKHITTEST, (WPARAM)lpPoint, (LPARAM)lptbim); + } + + BOOL InsertMarkHitTest(int x, int y, LPTBINSERTMARK lptbim) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + POINT pt = { x, y }; + return (BOOL)::SendMessage(this->m_hWnd, TB_INSERTMARKHITTEST, (WPARAM)&pt, (LPARAM)lptbim); + } + + BOOL MapAccelerator(TCHAR chAccel, int& nID) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_MAPACCELERATOR, (WPARAM)chAccel, (LPARAM)&nID); + } + + BOOL MarkButton(int nID, BOOL bHighlight = TRUE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_MARKBUTTON, nID, MAKELPARAM(bHighlight, 0)); + } + + BOOL MoveButton(int nOldPos, int nNewPos) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TB_MOVEBUTTON, nOldPos, nNewPos); + } + + HRESULT GetObject(REFIID iid, LPVOID* ppvObject) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HRESULT)::SendMessage(this->m_hWnd, TB_GETOBJECT, (WPARAM)&iid, (LPARAM)ppvObject); + } +}; + +typedef CToolBarCtrlT CToolBarCtrl; + + +/////////////////////////////////////////////////////////////////////////////// +// CStatusBarCtrl + +template +class CStatusBarCtrlT : public TBase +{ +public: +// Constructors + CStatusBarCtrlT(HWND hWnd = NULL) : TBase(hWnd) + { } + + CStatusBarCtrlT< TBase >& operator =(HWND hWnd) + { + this->m_hWnd = hWnd; + return *this; + } + + HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, + DWORD dwStyle = 0, DWORD dwExStyle = 0, + ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) + { + return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); + } + +// Methods + static LPCTSTR GetWndClassName() + { + return STATUSCLASSNAME; + } + + int GetParts(int nParts, int* pParts) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, SB_GETPARTS, nParts, (LPARAM)pParts); + } + + BOOL SetParts(int nParts, int* pWidths) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, SB_SETPARTS, nParts, (LPARAM)pWidths); + } + + int GetTextLength(int nPane, int* pType = NULL) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(nPane < 256); + DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, SB_GETTEXTLENGTH, (WPARAM)nPane, 0L); + if (pType != NULL) + *pType = (int)(short)HIWORD(dwRet); + return (int)(short)LOWORD(dwRet); + } + + int GetText(int nPane, LPTSTR lpszText, int* pType = NULL) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(nPane < 256); + DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, SB_GETTEXT, (WPARAM)nPane, (LPARAM)lpszText); + if(pType != NULL) + *pType = (int)(short)HIWORD(dwRet); + return (int)(short)LOWORD(dwRet); + } + + BOOL GetTextBSTR(int nPane, BSTR& bstrText, int* pType = NULL) const + { + USES_CONVERSION; + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(nPane < 256); + ATLASSERT(bstrText == NULL); + int nLength = (int)(short)LOWORD(::SendMessage(this->m_hWnd, SB_GETTEXTLENGTH, (WPARAM)nPane, 0L)); + if(nLength == 0) + return FALSE; + + ATL::CTempBuffer buff; + LPTSTR lpstrText = buff.Allocate(nLength + 1); + if(lpstrText == NULL) + return FALSE; + + if(!GetText(nPane, lpstrText, pType)) + return FALSE; + + bstrText = ::SysAllocString(T2OLE(lpstrText)); + return (bstrText != NULL) ? TRUE : FALSE; + } + +#ifdef __ATLSTR_H__ + int GetText(int nPane, ATL::CString& strText, int* pType = NULL) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(nPane < 256); + int nLength = (int)(short)LOWORD(::SendMessage(this->m_hWnd, SB_GETTEXTLENGTH, (WPARAM)nPane, 0L)); + if(nLength == 0) + return 0; + + LPTSTR lpstr = strText.GetBufferSetLength(nLength); + if(lpstr == NULL) + return 0; + return GetText(nPane, lpstr, pType); + } +#endif // __ATLSTR_H__ + + BOOL SetText(int nPane, LPCTSTR lpszText, int nType = 0) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(nPane < 256); + return (BOOL)::SendMessage(this->m_hWnd, SB_SETTEXT, (nPane | nType), (LPARAM)lpszText); + } + + BOOL GetRect(int nPane, LPRECT lpRect) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(nPane < 256); + return (BOOL)::SendMessage(this->m_hWnd, SB_GETRECT, nPane, (LPARAM)lpRect); + } + + BOOL GetBorders(int* pBorders) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, SB_GETBORDERS, 0, (LPARAM)pBorders); + } + + BOOL GetBorders(int& nHorz, int& nVert, int& nSpacing) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + int borders[3] = {}; + BOOL bResult = (BOOL)::SendMessage(this->m_hWnd, SB_GETBORDERS, 0, (LPARAM)&borders); + if(bResult) + { + nHorz = borders[0]; + nVert = borders[1]; + nSpacing = borders[2]; + } + return bResult; + } + + void SetMinHeight(int nMin) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, SB_SETMINHEIGHT, nMin, 0L); + } + + BOOL SetSimple(BOOL bSimple = TRUE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, SB_SIMPLE, bSimple, 0L); + } + + BOOL IsSimple() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, SB_ISSIMPLE, 0, 0L); + } + + BOOL GetUnicodeFormat() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, SB_GETUNICODEFORMAT, 0, 0L); + } + + BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, SB_SETUNICODEFORMAT, bUnicode, 0L); + } + + void GetTipText(int nPane, LPTSTR lpstrText, int nSize) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(nPane < 256); + ::SendMessage(this->m_hWnd, SB_GETTIPTEXT, MAKEWPARAM(nPane, nSize), (LPARAM)lpstrText); + } + + void SetTipText(int nPane, LPCTSTR lpstrText) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(nPane < 256); + ::SendMessage(this->m_hWnd, SB_SETTIPTEXT, nPane, (LPARAM)lpstrText); + } + + COLORREF SetBkColor(COLORREF clrBk) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, SB_SETBKCOLOR, 0, (LPARAM)clrBk); + } + + HICON GetIcon(int nPane) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(nPane < 256); + return (HICON)::SendMessage(this->m_hWnd, SB_GETICON, nPane, 0L); + } + + BOOL SetIcon(int nPane, HICON hIcon) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(nPane < 256); + return (BOOL)::SendMessage(this->m_hWnd, SB_SETICON, nPane, (LPARAM)hIcon); + } +}; + +typedef CStatusBarCtrlT CStatusBarCtrl; + + +/////////////////////////////////////////////////////////////////////////////// +// CTabCtrl + +template +class CTabCtrlT : public TBase +{ +public: +// Constructors + CTabCtrlT(HWND hWnd = NULL) : TBase(hWnd) + { } + + CTabCtrlT< TBase >& operator =(HWND hWnd) + { + this->m_hWnd = hWnd; + return *this; + } + + HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, + DWORD dwStyle = 0, DWORD dwExStyle = 0, + ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) + { + return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); + } + +// Attributes + static LPCTSTR GetWndClassName() + { + return WC_TABCONTROL; + } + + CImageList GetImageList() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TCM_GETIMAGELIST, 0, 0L)); + } + + CImageList SetImageList(HIMAGELIST hImageList) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TCM_SETIMAGELIST, 0, (LPARAM)hImageList)); + } + + int GetItemCount() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TCM_GETITEMCOUNT, 0, 0L); + } + + BOOL GetItem(int nItem, LPTCITEM pTabCtrlItem) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TCM_GETITEM, nItem, (LPARAM)pTabCtrlItem); + } + + BOOL SetItem(int nItem, LPTCITEM pTabCtrlItem) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TCM_SETITEM, nItem, (LPARAM)pTabCtrlItem); + } + + int SetItem(int nItem, UINT mask, LPCTSTR lpszItem, DWORD dwState, DWORD dwStateMask, int iImage, LPARAM lParam) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + TCITEM tci = {}; + tci.mask = mask; + tci.pszText = (LPTSTR) lpszItem; + tci.dwState = dwState; + tci.dwStateMask = dwStateMask; + tci.iImage = iImage; + tci.lParam = lParam; + return (int)::SendMessage(this->m_hWnd, TCM_SETITEM, nItem, (LPARAM)&tci); + } + + BOOL GetItemRect(int nItem, LPRECT lpRect) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TCM_GETITEMRECT, nItem, (LPARAM)lpRect); + } + + int GetCurSel() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TCM_GETCURSEL, 0, 0L); + } + + int SetCurSel(int nItem) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TCM_SETCURSEL, nItem, 0L); + } + + SIZE SetItemSize(SIZE size) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + DWORD dwSize = (DWORD)::SendMessage(this->m_hWnd, TCM_SETITEMSIZE, 0, MAKELPARAM(size.cx, size.cy)); + SIZE sizeRet = { GET_X_LPARAM(dwSize), GET_Y_LPARAM(dwSize) }; + return sizeRet; + } + + void SetItemSize(int cx, int cy) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TCM_SETITEMSIZE, 0, MAKELPARAM(cx, cy)); + } + + void SetPadding(SIZE size) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TCM_SETPADDING, 0, MAKELPARAM(size.cx, size.cy)); + } + + int GetRowCount() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TCM_GETROWCOUNT, 0, 0L); + } + + CToolTipCtrl GetToolTips() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return CToolTipCtrl((HWND)::SendMessage(this->m_hWnd, TCM_GETTOOLTIPS, 0, 0L)); + } + + // this method is deprecated, please use GetToolTips + CToolTipCtrl GetTooltips() const { return GetToolTips(); } + + void SetToolTips(HWND hWndToolTip) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TCM_SETTOOLTIPS, (WPARAM)hWndToolTip, 0L); + } + + // this method is deprecated, please use SetToolTips + void SetTooltips(HWND hWndToolTip) { SetToolTips(hWndToolTip); } + + int GetCurFocus() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TCM_GETCURFOCUS, 0, 0L); + } + + void SetCurFocus(int nItem) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TCM_SETCURFOCUS, nItem, 0L); + } + + BOOL SetItemExtra(int cbExtra) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(GetItemCount() == 0); // must be empty + return (BOOL)::SendMessage(this->m_hWnd, TCM_SETITEMEXTRA, cbExtra, 0L); + } + + int SetMinTabWidth(int nWidth = -1) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TCM_SETMINTABWIDTH, 0, nWidth); + } + + DWORD GetExtendedStyle() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, TCM_GETEXTENDEDSTYLE, 0, 0L); + } + + DWORD SetExtendedStyle(DWORD dwExMask, DWORD dwExStyle) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, TCM_SETEXTENDEDSTYLE, dwExMask, dwExStyle); + } + + BOOL GetUnicodeFormat() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TCM_GETUNICODEFORMAT, 0, 0L); + } + + BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TCM_SETUNICODEFORMAT, bUnicode, 0L); + } + +// Operations + int InsertItem(int nItem, LPTCITEM pTabCtrlItem) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TCM_INSERTITEM, nItem, (LPARAM)pTabCtrlItem); + } + + int InsertItem(int nItem, UINT mask, LPCTSTR lpszItem, int iImage, LPARAM lParam) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + TCITEM tci = {}; + tci.mask = mask; + tci.pszText = (LPTSTR) lpszItem; + tci.iImage = iImage; + tci.lParam = lParam; + return (int)::SendMessage(this->m_hWnd, TCM_INSERTITEM, nItem, (LPARAM)&tci); + } + + int InsertItem(int nItem, LPCTSTR lpszItem) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + TCITEM tci = {}; + tci.mask = TCIF_TEXT; + tci.pszText = (LPTSTR) lpszItem; + return (int)::SendMessage(this->m_hWnd, TCM_INSERTITEM, nItem, (LPARAM)&tci); + } + + int AddItem(LPTCITEM pTabCtrlItem) + { + return InsertItem(GetItemCount(), pTabCtrlItem); + } + + int AddItem(UINT mask, LPCTSTR lpszItem, int iImage, LPARAM lParam) + { + return InsertItem(GetItemCount(), mask, lpszItem, iImage, lParam); + } + + int AddItem(LPCTSTR lpszItem) + { + return InsertItem(GetItemCount(), lpszItem); + } + + BOOL DeleteItem(int nItem) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TCM_DELETEITEM, nItem, 0L); + } + + BOOL DeleteAllItems() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TCM_DELETEALLITEMS, 0, 0L); + } + + void AdjustRect(BOOL bLarger, LPRECT lpRect) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TCM_ADJUSTRECT, bLarger, (LPARAM)lpRect); + } + + void RemoveImage(int nImage) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TCM_REMOVEIMAGE, nImage, 0L); + } + + int HitTest(TC_HITTESTINFO* pHitTestInfo) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TCM_HITTEST, 0, (LPARAM)pHitTestInfo); + } + + void DeselectAll(BOOL bExcludeFocus = TRUE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TCM_DESELECTALL, bExcludeFocus, 0L); + } + + BOOL HighlightItem(int nIndex, BOOL bHighlight = TRUE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TCM_HIGHLIGHTITEM, nIndex, MAKELPARAM(bHighlight, 0)); + } +}; + +typedef CTabCtrlT CTabCtrl; + + +/////////////////////////////////////////////////////////////////////////////// +// CTrackBarCtrl + +template +class CTrackBarCtrlT : public TBase +{ +public: +// Constructors + CTrackBarCtrlT(HWND hWnd = NULL) : TBase(hWnd) + { } + + CTrackBarCtrlT< TBase >& operator =(HWND hWnd) + { + this->m_hWnd = hWnd; + return *this; + } + + HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, + DWORD dwStyle = 0, DWORD dwExStyle = 0, + ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) + { + return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); + } + +// Attributes + static LPCTSTR GetWndClassName() + { + return TRACKBAR_CLASS; + } + + int GetLineSize() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TBM_GETLINESIZE, 0, 0L); + } + + int SetLineSize(int nSize) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TBM_SETLINESIZE, 0, nSize); + } + + int GetPageSize() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TBM_GETPAGESIZE, 0, 0L); + } + + int SetPageSize(int nSize) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TBM_SETPAGESIZE, 0, nSize); + } + + int GetRangeMin() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TBM_GETRANGEMIN, 0, 0L); + } + + void SetRangeMin(int nMin, BOOL bRedraw = FALSE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TBM_SETRANGEMIN, bRedraw, nMin); + } + + int GetRangeMax() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TBM_GETRANGEMAX, 0, 0L); + } + + void SetRangeMax(int nMax, BOOL bRedraw = FALSE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TBM_SETRANGEMAX, bRedraw, nMax); + } + + void GetRange(int& nMin, int& nMax) const + { + nMin = GetRangeMin(); + nMax = GetRangeMax(); + } + + void SetRange(int nMin, int nMax, BOOL bRedraw = TRUE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TBM_SETRANGE, bRedraw, MAKELPARAM(nMin, nMax)); + } + + int GetSelStart() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TBM_GETSELSTART, 0, 0L); + } + + void SetSelStart(int nMin, BOOL bRedraw = FALSE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TBM_SETSELSTART, bRedraw, (LPARAM)nMin); + } + + int GetSelEnd() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TBM_GETSELEND, 0, 0L); + } + + void SetSelEnd(int nMax, BOOL bRedraw = FALSE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TBM_SETSELEND, bRedraw, (LPARAM)nMax); + } + + void GetSelection(int& nMin, int& nMax) const + { + nMin = GetSelStart(); + nMax = GetSelEnd(); + } + + void SetSelection(int nMin, int nMax, BOOL bRedraw = TRUE) + { + SetSelStart(nMin, FALSE); + SetSelEnd(nMax, bRedraw); + } + + void GetChannelRect(LPRECT lprc) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TBM_GETCHANNELRECT, 0, (LPARAM)lprc); + } + + void GetThumbRect(LPRECT lprc) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TBM_GETTHUMBRECT, 0, (LPARAM)lprc); + } + + int GetPos() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TBM_GETPOS, 0, 0L); + } + + void SetPos(int nPos) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TBM_SETPOS, TRUE, nPos); + } + + UINT GetNumTics() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, TBM_GETNUMTICS, 0, 0L); + } + + DWORD* GetTicArray() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD*)::SendMessage(this->m_hWnd, TBM_GETPTICS, 0, 0L); + } + + int GetTic(int nTic) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TBM_GETTIC, nTic, 0L); + } + + BOOL SetTic(int nTic) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TBM_SETTIC, 0, nTic); + } + + int GetTicPos(int nTic) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TBM_GETTICPOS, nTic, 0L); + } + + void SetTicFreq(int nFreq) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TBM_SETTICFREQ, nFreq, 0L); + } + + int GetThumbLength() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TBM_GETTHUMBLENGTH, 0, 0L); + } + + void SetThumbLength(int nLength) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TBM_SETTHUMBLENGTH, nLength, 0L); + } + + void SetSel(int nStart, int nEnd, BOOL bRedraw = TRUE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & TBS_ENABLESELRANGE) != 0); + ::SendMessage(this->m_hWnd, TBM_SETSEL, bRedraw, MAKELPARAM(nStart, nEnd)); + } + + ATL::CWindow GetBuddy(BOOL bLeft = TRUE) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return ATL::CWindow((HWND)::SendMessage(this->m_hWnd, TBM_GETBUDDY, bLeft, 0L)); + } + + ATL::CWindow SetBuddy(HWND hWndBuddy, BOOL bLeft = TRUE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return ATL::CWindow((HWND)::SendMessage(this->m_hWnd, TBM_SETBUDDY, bLeft, (LPARAM)hWndBuddy)); + } + + CToolTipCtrl GetToolTips() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return CToolTipCtrl((HWND)::SendMessage(this->m_hWnd, TBM_GETTOOLTIPS, 0, 0L)); + } + + void SetToolTips(HWND hWndTT) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TBM_SETTOOLTIPS, (WPARAM)hWndTT, 0L); + } + + int SetTipSide(int nSide) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, TBM_SETTIPSIDE, nSide, 0L); + } + + BOOL GetUnicodeFormat() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TBM_GETUNICODEFORMAT, 0, 0L); + } + + BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, TBM_SETUNICODEFORMAT, bUnicode, 0L); + } + +// Operations + void ClearSel(BOOL bRedraw = FALSE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TBM_CLEARSEL, bRedraw, 0L); + } + + void VerifyPos() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TBM_SETPOS, FALSE, 0L); + } + + void ClearTics(BOOL bRedraw = FALSE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, TBM_CLEARTICS, bRedraw, 0L); + } +}; + +typedef CTrackBarCtrlT CTrackBarCtrl; + + +/////////////////////////////////////////////////////////////////////////////// +// CUpDownCtrl + +template +class CUpDownCtrlT : public TBase +{ +public: +// Constructors + CUpDownCtrlT(HWND hWnd = NULL) : TBase(hWnd) + { } + + CUpDownCtrlT< TBase >& operator =(HWND hWnd) + { + this->m_hWnd = hWnd; + return *this; + } + + HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, + DWORD dwStyle = 0, DWORD dwExStyle = 0, + ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) + { + return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); + } + +// Attributes + static LPCTSTR GetWndClassName() + { + return UPDOWN_CLASS; + } + + UINT GetAccel(int nAccel, UDACCEL* pAccel) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)LOWORD(::SendMessage(this->m_hWnd, UDM_GETACCEL, nAccel, (LPARAM)pAccel)); + } + + BOOL SetAccel(int nAccel, UDACCEL* pAccel) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)LOWORD(::SendMessage(this->m_hWnd, UDM_SETACCEL, nAccel, (LPARAM)pAccel)); + } + + UINT GetBase() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)LOWORD(::SendMessage(this->m_hWnd, UDM_GETBASE, 0, 0L)); + } + + int SetBase(int nBase) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, UDM_SETBASE, nBase, 0L); + } + + ATL::CWindow GetBuddy() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return ATL::CWindow((HWND)::SendMessage(this->m_hWnd, UDM_GETBUDDY, 0, 0L)); + } + + ATL::CWindow SetBuddy(HWND hWndBuddy) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return ATL::CWindow((HWND)::SendMessage(this->m_hWnd, UDM_SETBUDDY, (WPARAM)hWndBuddy, 0L)); + } + + int GetPos(LPBOOL lpbError = NULL) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, UDM_GETPOS, 0, 0L); + // Note: Seems that Windows always sets error to TRUE if + // UDS_SETBUDDYINT style is not used + if(lpbError != NULL) + *lpbError = (HIWORD(dwRet) != 0) ? TRUE : FALSE; + return (int)(short)LOWORD(dwRet); + } + + int SetPos(int nPos) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)(short)LOWORD(::SendMessage(this->m_hWnd, UDM_SETPOS, 0, MAKELPARAM(nPos, 0))); + } + + DWORD GetRange() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, UDM_GETRANGE, 0, 0L); + } + + void GetRange(int& nLower, int& nUpper) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, UDM_GETRANGE, 0, 0L); + nLower = (int)(short)HIWORD(dwRet); + nUpper = (int)(short)LOWORD(dwRet); + } + + void SetRange(int nLower, int nUpper) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, UDM_SETRANGE, 0, MAKELPARAM(nUpper, nLower)); + } + + void SetRange32(int nLower, int nUpper) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, UDM_SETRANGE32, nLower, nUpper); + } + + void GetRange32(int& nLower, int& nUpper) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, UDM_GETRANGE32, (WPARAM)&nLower, (LPARAM)&nUpper); + } + + BOOL GetUnicodeFormat() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, UDM_GETUNICODEFORMAT, 0, 0L); + } + + BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, UDM_SETUNICODEFORMAT, bUnicode, 0L); + } + + int GetPos32(LPBOOL lpbError = NULL) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + // Note: Seems that Windows always sets error to TRUE if + // UDS_SETBUDDYINT style is not used + return (int)::SendMessage(this->m_hWnd, UDM_GETPOS32, 0, (LPARAM)lpbError); + } + + int SetPos32(int nPos) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, UDM_SETPOS32, 0, (LPARAM)nPos); + } +}; + +typedef CUpDownCtrlT CUpDownCtrl; + + +/////////////////////////////////////////////////////////////////////////////// +// CProgressBarCtrl + +template +class CProgressBarCtrlT : public TBase +{ +public: +// Constructors + CProgressBarCtrlT(HWND hWnd = NULL) : TBase(hWnd) + { } + + CProgressBarCtrlT< TBase >& operator =(HWND hWnd) + { + this->m_hWnd = hWnd; + return *this; + } + + HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, + DWORD dwStyle = 0, DWORD dwExStyle = 0, + ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) + { + return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); + } + +// Attributes + static LPCTSTR GetWndClassName() + { + return PROGRESS_CLASS; + } + + DWORD SetRange(int nLower, int nUpper) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, PBM_SETRANGE, 0, MAKELPARAM(nLower, nUpper)); + } + + int SetPos(int nPos) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)(short)LOWORD(::SendMessage(this->m_hWnd, PBM_SETPOS, nPos, 0L)); + } + + int OffsetPos(int nPos) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)(short)LOWORD(::SendMessage(this->m_hWnd, PBM_DELTAPOS, nPos, 0L)); + } + + int SetStep(int nStep) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)(short)LOWORD(::SendMessage(this->m_hWnd, PBM_SETSTEP, nStep, 0L)); + } + + UINT GetPos() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, PBM_GETPOS, 0, 0L); + } + + void GetRange(PPBRANGE pPBRange) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(pPBRange != NULL); + ::SendMessage(this->m_hWnd, PBM_GETRANGE, TRUE, (LPARAM)pPBRange); + } + + void GetRange(int& nLower, int& nUpper) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + PBRANGE range = {}; + ::SendMessage(this->m_hWnd, PBM_GETRANGE, TRUE, (LPARAM)&range); + nLower = range.iLow; + nUpper = range.iHigh; + } + + int GetRangeLimit(BOOL bLowLimit) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, PBM_GETRANGE, bLowLimit, (LPARAM)NULL); + } + + DWORD SetRange32(int nMin, int nMax) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, PBM_SETRANGE32, nMin, nMax); + } + + COLORREF SetBarColor(COLORREF clr) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, PBM_SETBARCOLOR, 0, (LPARAM)clr); + } + + COLORREF SetBkColor(COLORREF clr) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, PBM_SETBKCOLOR, 0, (LPARAM)clr); + } + +#ifdef PBM_SETMARQUEE + BOOL SetMarquee(BOOL bMarquee, UINT uUpdateTime = 0U) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, PBM_SETMARQUEE, (WPARAM)bMarquee, (LPARAM)uUpdateTime); + } +#endif + +#if (_WIN32_WINNT >= 0x0600) + int GetStep() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, PBM_GETSTEP, 0, 0L); + } + + COLORREF GetBkColor() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, PBM_GETBKCOLOR, 0, 0L); + } + + COLORREF GetBarColor() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, PBM_GETBARCOLOR, 0, 0L); + } + + int GetState() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, PBM_GETSTATE, 0, 0L); + } + + int SetState(int nState) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, PBM_SETSTATE, nState, 0L); + } +#endif // (_WIN32_WINNT >= 0x0600) + +// Operations + int StepIt() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)(short)LOWORD(::SendMessage(this->m_hWnd, PBM_STEPIT, 0, 0L)); + } +}; + +typedef CProgressBarCtrlT CProgressBarCtrl; + + +/////////////////////////////////////////////////////////////////////////////// +// CHotKeyCtrl + +template +class CHotKeyCtrlT : public TBase +{ +public: +// Constructors + CHotKeyCtrlT(HWND hWnd = NULL) : TBase(hWnd) + { } + + CHotKeyCtrlT< TBase >& operator =(HWND hWnd) + { + this->m_hWnd = hWnd; + return *this; + } + + HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, + DWORD dwStyle = 0, DWORD dwExStyle = 0, + ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) + { + return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); + } + +// Attributes + static LPCTSTR GetWndClassName() + { + return HOTKEY_CLASS; + } + + DWORD GetHotKey() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, HKM_GETHOTKEY, 0, 0L); + } + + void GetHotKey(WORD &wVirtualKeyCode, WORD &wModifiers) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + DWORD dw = (DWORD)::SendMessage(this->m_hWnd, HKM_GETHOTKEY, 0, 0L); + wVirtualKeyCode = LOBYTE(LOWORD(dw)); + wModifiers = HIBYTE(LOWORD(dw)); + } + + void SetHotKey(WORD wVirtualKeyCode, WORD wModifiers) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, HKM_SETHOTKEY, MAKEWORD(wVirtualKeyCode, wModifiers), 0L); + } + + void SetRules(WORD wInvalidComb, WORD wModifiers) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, HKM_SETRULES, wInvalidComb, MAKELPARAM(wModifiers, 0)); + } +}; + +typedef CHotKeyCtrlT CHotKeyCtrl; + + +/////////////////////////////////////////////////////////////////////////////// +// CAnimateCtrl + +template +class CAnimateCtrlT : public TBase +{ +public: +// Constructors + CAnimateCtrlT(HWND hWnd = NULL) : TBase(hWnd) + { } + + CAnimateCtrlT< TBase >& operator =(HWND hWnd) + { + this->m_hWnd = hWnd; + return *this; + } + + HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, + DWORD dwStyle = 0, DWORD dwExStyle = 0, + ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) + { + return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); + } + +// Attributes + static LPCTSTR GetWndClassName() + { + return ANIMATE_CLASS; + } + +// Operations + BOOL Open(ATL::_U_STRINGorID FileName) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, ACM_OPEN, 0, (LPARAM)FileName.m_lpstr); + } + + BOOL Play(UINT nFrom, UINT nTo, UINT nRep) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, ACM_PLAY, nRep, MAKELPARAM(nFrom, nTo)); + } + + BOOL Stop() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, ACM_STOP, 0, 0L); + } + + BOOL Close() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, ACM_OPEN, 0, 0L); + } + + BOOL Seek(UINT nTo) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, ACM_PLAY, 0, MAKELPARAM(nTo, nTo)); + } + + // Vista only + BOOL IsPlaying() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, ACM_ISPLAYING, 0, 0L); + } +}; + +typedef CAnimateCtrlT CAnimateCtrl; + + +/////////////////////////////////////////////////////////////////////////////// +// CRichEditCtrl + +#if !defined(_UNICODE) && (_RICHEDIT_VER >= 0x0500) + #undef MSFTEDIT_CLASS + #define MSFTEDIT_CLASS "RICHEDIT50W" +#endif + +template +class CRichEditCtrlT : public TBase +{ +public: +// Constructors + CRichEditCtrlT(HWND hWnd = NULL) : TBase(hWnd) + { } + + CRichEditCtrlT< TBase >& operator =(HWND hWnd) + { + this->m_hWnd = hWnd; + return *this; + } + + HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, + DWORD dwStyle = 0, DWORD dwExStyle = 0, + ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) + { + return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); + } + +// Attributes + static LPCTSTR GetWndClassName() + { +#if (_RICHEDIT_VER >= 0x0500) + return MSFTEDIT_CLASS; +#else + return RICHEDIT_CLASS; +#endif + } + + static LPCTSTR GetLibraryName() + { +#if (_RICHEDIT_VER >= 0x0500) + return _T("MSFTEDIT.DLL"); +#else + return _T("RICHED20.DLL"); +#endif + } + + int GetLineCount() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_GETLINECOUNT, 0, 0L); + } + + BOOL GetModify() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_GETMODIFY, 0, 0L); + } + + void SetModify(BOOL bModified = TRUE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETMODIFY, bModified, 0L); + } + + void GetRect(LPRECT lpRect) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_GETRECT, 0, (LPARAM)lpRect); + } + + DWORD GetOptions() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, EM_GETOPTIONS, 0, 0L); + } + + DWORD SetOptions(WORD wOperation, DWORD dwOptions) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, EM_SETOPTIONS, wOperation, dwOptions); + } + + // NOTE: first word in lpszBuffer must contain the size of the buffer! + int GetLine(int nIndex, LPTSTR lpszBuffer) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_GETLINE, nIndex, (LPARAM)lpszBuffer); + } + + int GetLine(int nIndex, LPTSTR lpszBuffer, int nMaxLength) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + *(LPWORD)lpszBuffer = (WORD)nMaxLength; + return (int)::SendMessage(this->m_hWnd, EM_GETLINE, nIndex, (LPARAM)lpszBuffer); + } + + BOOL CanUndo() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_CANUNDO, 0, 0L); + } + + BOOL CanPaste(UINT nFormat = 0) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_CANPASTE, nFormat, 0L); + } + + void GetSel(LONG& nStartChar, LONG& nEndChar) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + CHARRANGE cr = {}; + ::SendMessage(this->m_hWnd, EM_EXGETSEL, 0, (LPARAM)&cr); + nStartChar = cr.cpMin; + nEndChar = cr.cpMax; + } + + void GetSel(CHARRANGE &cr) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_EXGETSEL, 0, (LPARAM)&cr); + } + + int SetSel(LONG nStartChar, LONG nEndChar) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + CHARRANGE cr = { nStartChar, nEndChar }; + return (int)::SendMessage(this->m_hWnd, EM_EXSETSEL, 0, (LPARAM)&cr); + } + + int SetSel(CHARRANGE &cr) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_EXSETSEL, 0, (LPARAM)&cr); + } + + int SetSelAll() + { + return SetSel(0, -1); + } + + int SetSelNone() + { + return SetSel(-1, 0); + } + + DWORD GetDefaultCharFormat(CHARFORMAT& cf) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + cf.cbSize = sizeof(CHARFORMAT); + return (DWORD)::SendMessage(this->m_hWnd, EM_GETCHARFORMAT, 0, (LPARAM)&cf); + } + + DWORD GetSelectionCharFormat(CHARFORMAT& cf) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + cf.cbSize = sizeof(CHARFORMAT); + return (DWORD)::SendMessage(this->m_hWnd, EM_GETCHARFORMAT, 1, (LPARAM)&cf); + } + + DWORD GetEventMask() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, EM_GETEVENTMASK, 0, 0L); + } + + LONG GetLimitText() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (LONG)::SendMessage(this->m_hWnd, EM_GETLIMITTEXT, 0, 0L); + } + + DWORD GetParaFormat(PARAFORMAT& pf) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + pf.cbSize = sizeof(PARAFORMAT); + return (DWORD)::SendMessage(this->m_hWnd, EM_GETPARAFORMAT, 0, (LPARAM)&pf); + } + + LONG GetSelText(LPTSTR lpstrBuff) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (LONG)::SendMessage(this->m_hWnd, EM_GETSELTEXT, 0, (LPARAM)lpstrBuff); + } + + BOOL GetSelTextBSTR(BSTR& bstrText) const + { + USES_CONVERSION; + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(bstrText == NULL); + + CHARRANGE cr = {}; + ::SendMessage(this->m_hWnd, EM_EXGETSEL, 0, (LPARAM)&cr); + + ATL::CTempBuffer buff; + LPTSTR lpstrText = buff.Allocate(cr.cpMax - cr.cpMin + 1); + if(lpstrText == NULL) + return FALSE; + if(::SendMessage(this->m_hWnd, EM_GETSELTEXT, 0, (LPARAM)lpstrText) == 0) + return FALSE; + + bstrText = ::SysAllocString(T2W(lpstrText)); + + return (bstrText != NULL) ? TRUE : FALSE; + } + +#ifdef __ATLSTR_H__ + LONG GetSelText(ATL::CString& strText) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + + CHARRANGE cr = {}; + ::SendMessage(this->m_hWnd, EM_EXGETSEL, 0, (LPARAM)&cr); + + LONG lLen = 0; + LPTSTR lpstrText = strText.GetBufferSetLength(cr.cpMax - cr.cpMin); + if(lpstrText != NULL) + { + lLen = (LONG)::SendMessage(this->m_hWnd, EM_GETSELTEXT, 0, (LPARAM)lpstrText); + strText.ReleaseBuffer(); + } + + return lLen; + } +#endif // __ATLSTR_H__ + + WORD GetSelectionType() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (WORD)::SendMessage(this->m_hWnd, EM_SELECTIONTYPE, 0, 0L); + } + + COLORREF SetBackgroundColor(COLORREF cr) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, EM_SETBKGNDCOLOR, 0, cr); + } + + COLORREF SetBackgroundColor() // sets to system background + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, EM_SETBKGNDCOLOR, 1, 0); + } + + BOOL SetCharFormat(CHARFORMAT& cf, WORD wFlags) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + cf.cbSize = sizeof(CHARFORMAT); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETCHARFORMAT, (WPARAM)wFlags, (LPARAM)&cf); + } + + BOOL SetDefaultCharFormat(CHARFORMAT& cf) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + cf.cbSize = sizeof(CHARFORMAT); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETCHARFORMAT, 0, (LPARAM)&cf); + } + + BOOL SetSelectionCharFormat(CHARFORMAT& cf) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + cf.cbSize = sizeof(CHARFORMAT); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf); + } + + BOOL SetWordCharFormat(CHARFORMAT& cf) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + cf.cbSize = sizeof(CHARFORMAT); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETCHARFORMAT, SCF_SELECTION | SCF_WORD, (LPARAM)&cf); + } + + DWORD SetEventMask(DWORD dwEventMask) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, EM_SETEVENTMASK, 0, dwEventMask); + } + + BOOL SetParaFormat(PARAFORMAT& pf) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + pf.cbSize = sizeof(PARAFORMAT); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETPARAFORMAT, 0, (LPARAM)&pf); + } + + BOOL SetTargetDevice(HDC hDC, int cxLineWidth) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETTARGETDEVICE, (WPARAM)hDC, cxLineWidth); + } + + int GetTextLength() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, WM_GETTEXTLENGTH, 0, 0L); + } + + BOOL SetReadOnly(BOOL bReadOnly = TRUE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETREADONLY, bReadOnly, 0L); + } + + int GetFirstVisibleLine() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_GETFIRSTVISIBLELINE, 0, 0L); + } + + int GetTextRange(TEXTRANGE* pTextRange) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_GETTEXTRANGE, 0, (LPARAM)pTextRange); + } + + int GetTextRange(LONG nStartChar, LONG nEndChar, LPTSTR lpstrText) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + TEXTRANGE tr = {}; + tr.chrg.cpMin = nStartChar; + tr.chrg.cpMax = nEndChar; + tr.lpstrText = lpstrText; + return (int)::SendMessage(this->m_hWnd, EM_GETTEXTRANGE, 0, (LPARAM)&tr); + } + + DWORD GetDefaultCharFormat(CHARFORMAT2& cf) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + cf.cbSize = sizeof(CHARFORMAT2); + return (DWORD)::SendMessage(this->m_hWnd, EM_GETCHARFORMAT, 0, (LPARAM)&cf); + } + + BOOL SetCharFormat(CHARFORMAT2& cf, WORD wFlags) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + cf.cbSize = sizeof(CHARFORMAT2); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETCHARFORMAT, (WPARAM)wFlags, (LPARAM)&cf); + } + + BOOL SetDefaultCharFormat(CHARFORMAT2& cf) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + cf.cbSize = sizeof(CHARFORMAT2); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETCHARFORMAT, 0, (LPARAM)&cf); + } + + DWORD GetSelectionCharFormat(CHARFORMAT2& cf) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + cf.cbSize = sizeof(CHARFORMAT2); + return (DWORD)::SendMessage(this->m_hWnd, EM_GETCHARFORMAT, 1, (LPARAM)&cf); + } + + BOOL SetSelectionCharFormat(CHARFORMAT2& cf) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + cf.cbSize = sizeof(CHARFORMAT2); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf); + } + + BOOL SetWordCharFormat(CHARFORMAT2& cf) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + cf.cbSize = sizeof(CHARFORMAT2); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETCHARFORMAT, SCF_SELECTION | SCF_WORD, (LPARAM)&cf); + } + + DWORD GetParaFormat(PARAFORMAT2& pf) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + pf.cbSize = sizeof(PARAFORMAT2); + return (DWORD)::SendMessage(this->m_hWnd, EM_GETPARAFORMAT, 0, (LPARAM)&pf); + } + + BOOL SetParaFormat(PARAFORMAT2& pf) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + pf.cbSize = sizeof(PARAFORMAT2); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETPARAFORMAT, 0, (LPARAM)&pf); + } + + TEXTMODE GetTextMode() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (TEXTMODE)::SendMessage(this->m_hWnd, EM_GETTEXTMODE, 0, 0L); + } + + BOOL SetTextMode(TEXTMODE enumTextMode) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return !(BOOL)::SendMessage(this->m_hWnd, EM_SETTEXTMODE, enumTextMode, 0L); + } + + UNDONAMEID GetUndoName() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UNDONAMEID)::SendMessage(this->m_hWnd, EM_GETUNDONAME, 0, 0L); + } + + UNDONAMEID GetRedoName() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UNDONAMEID)::SendMessage(this->m_hWnd, EM_GETREDONAME, 0, 0L); + } + + BOOL CanRedo() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_CANREDO, 0, 0L); + } + + BOOL GetAutoURLDetect() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_GETAUTOURLDETECT, 0, 0L); + } + + BOOL SetAutoURLDetect(BOOL bAutoDetect = TRUE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return !(BOOL)::SendMessage(this->m_hWnd, EM_AUTOURLDETECT, bAutoDetect, 0L); + } + + // this method is deprecated, please use SetAutoURLDetect + BOOL EnableAutoURLDetect(BOOL bEnable = TRUE) { return SetAutoURLDetect(bEnable); } + + UINT SetUndoLimit(UINT uUndoLimit) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, EM_SETUNDOLIMIT, uUndoLimit, 0L); + } + + void SetPalette(HPALETTE hPalette) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETPALETTE, (WPARAM)hPalette, 0L); + } + + int GetTextEx(GETTEXTEX* pGetTextEx, LPTSTR lpstrText) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_GETTEXTEX, (WPARAM)pGetTextEx, (LPARAM)lpstrText); + } + + int GetTextEx(LPTSTR lpstrText, int nTextLen, DWORD dwFlags = GT_DEFAULT, UINT uCodePage = CP_ACP, LPCSTR lpDefaultChar = NULL, LPBOOL lpUsedDefChar = NULL) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + GETTEXTEX gte = {}; + gte.cb = nTextLen * sizeof(TCHAR); + gte.codepage = uCodePage; + gte.flags = dwFlags; + gte.lpDefaultChar = lpDefaultChar; + gte.lpUsedDefChar = lpUsedDefChar; + return (int)::SendMessage(this->m_hWnd, EM_GETTEXTEX, (WPARAM)>e, (LPARAM)lpstrText); + } + + int GetTextLengthEx(GETTEXTLENGTHEX* pGetTextLengthEx) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_GETTEXTLENGTHEX, (WPARAM)pGetTextLengthEx, 0L); + } + + int GetTextLengthEx(DWORD dwFlags = GTL_DEFAULT, UINT uCodePage = CP_ACP) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + GETTEXTLENGTHEX gtle = {}; + gtle.codepage = uCodePage; + gtle.flags = dwFlags; + return (int)::SendMessage(this->m_hWnd, EM_GETTEXTLENGTHEX, (WPARAM)>le, 0L); + } + + EDITWORDBREAKPROC GetWordBreakProc() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (EDITWORDBREAKPROC)::SendMessage(this->m_hWnd, EM_GETWORDBREAKPROC, 0, 0L); + } + + void SetWordBreakProc(EDITWORDBREAKPROC ewbprc) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETWORDBREAKPROC, 0, (LPARAM)ewbprc); + } + + int SetTextEx(SETTEXTEX* pSetTextEx, LPCTSTR lpstrText) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_SETTEXTEX, (WPARAM)pSetTextEx, (LPARAM)lpstrText); + } + + int SetTextEx(LPCTSTR lpstrText, DWORD dwFlags = ST_DEFAULT, UINT uCodePage = CP_ACP) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + SETTEXTEX ste = {}; + ste.flags = dwFlags; + ste.codepage = uCodePage; + return (int)::SendMessage(this->m_hWnd, EM_SETTEXTEX, (WPARAM)&ste, (LPARAM)lpstrText); + } + + int GetEditStyle() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_GETEDITSTYLE, 0, 0L); + } + + int SetEditStyle(int nStyle, int nMask = -1) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + if(nMask == -1) + nMask = nStyle; // set everything specified + return (int)::SendMessage(this->m_hWnd, EM_SETEDITSTYLE, nStyle, nMask); + } + + BOOL SetFontSize(int nFontSizeDelta) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((nFontSizeDelta >= -1637) && (nFontSizeDelta <= 1638)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETFONTSIZE, nFontSizeDelta, 0L); + } + + void GetScrollPos(LPPOINT lpPoint) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(lpPoint != NULL); + ::SendMessage(this->m_hWnd, EM_GETSCROLLPOS, 0, (LPARAM)lpPoint); + } + + void SetScrollPos(LPPOINT lpPoint) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(lpPoint != NULL); + ::SendMessage(this->m_hWnd, EM_SETSCROLLPOS, 0, (LPARAM)lpPoint); + } + + BOOL GetZoom(int& nNum, int& nDen) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_GETZOOM, (WPARAM)&nNum, (LPARAM)&nDen); + } + + BOOL SetZoom(int nNum, int nDen) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((nNum >= 0) && (nNum <= 64)); + ATLASSERT((nDen >= 0) && (nDen <= 64)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETZOOM, nNum, nDen); + } + + BOOL SetZoomOff() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETZOOM, 0, 0L); + } + + void SetMargins(UINT nLeft, UINT nRight, WORD wFlags = EC_LEFTMARGIN | EC_RIGHTMARGIN) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETMARGINS, wFlags, MAKELONG(nLeft, nRight)); + } + + WORD GetTypographyOptions() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (WORD)::SendMessage(this->m_hWnd, EM_GETTYPOGRAPHYOPTIONS, 0, 0L); + } + + BOOL SetTypographyOptions(WORD wOptions, WORD wMask) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETTYPOGRAPHYOPTIONS, wOptions, wMask); + } + +// Operations + void LimitText(LONG nChars = 0) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_EXLIMITTEXT, 0, nChars); + } + + int LineFromChar(LONG nIndex) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_EXLINEFROMCHAR, 0, nIndex); + } + + POINT PosFromChar(LONG nChar) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + POINT point = {}; + ::SendMessage(this->m_hWnd, EM_POSFROMCHAR, (WPARAM)&point, nChar); + return point; + } + + int CharFromPos(POINT pt) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + POINTL ptl = { pt.x, pt.y }; + return (int)::SendMessage(this->m_hWnd, EM_CHARFROMPOS, 0, (LPARAM)&ptl); + } + + void EmptyUndoBuffer() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_EMPTYUNDOBUFFER, 0, 0L); + } + + int LineIndex(int nLine = -1) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_LINEINDEX, nLine, 0L); + } + + int LineLength(int nLine = -1) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, EM_LINELENGTH, nLine, 0L); + } + + BOOL LineScroll(int nLines) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_LINESCROLL, 0, nLines); + } + + void ReplaceSel(LPCTSTR lpszNewText, BOOL bCanUndo = FALSE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_REPLACESEL, (WPARAM) bCanUndo, (LPARAM)lpszNewText); + } + + void SetRect(LPCRECT lpRect) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETRECT, 0, (LPARAM)lpRect); + } + + BOOL DisplayBand(LPRECT pDisplayRect) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_DISPLAYBAND, 0, (LPARAM)pDisplayRect); + } + + LONG FindText(DWORD dwFlags, FINDTEXT& ft) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); +#ifdef _UNICODE + return (LONG)::SendMessage(this->m_hWnd, EM_FINDTEXTW, dwFlags, (LPARAM)&ft); +#else + return (LONG)::SendMessage(this->m_hWnd, EM_FINDTEXT, dwFlags, (LPARAM)&ft); +#endif + } + + LONG FindText(DWORD dwFlags, FINDTEXTEX& ft) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); +#ifdef _UNICODE + return (LONG)::SendMessage(this->m_hWnd, EM_FINDTEXTEXW, dwFlags, (LPARAM)&ft); +#else + return (LONG)::SendMessage(this->m_hWnd, EM_FINDTEXTEX, dwFlags, (LPARAM)&ft); +#endif + } + + LONG FormatRange(FORMATRANGE& fr, BOOL bDisplay = TRUE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (LONG)::SendMessage(this->m_hWnd, EM_FORMATRANGE, bDisplay, (LPARAM)&fr); + } + + LONG FormatRange(FORMATRANGE* pFormatRange, BOOL bDisplay = TRUE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (LONG)::SendMessage(this->m_hWnd, EM_FORMATRANGE, bDisplay, (LPARAM)pFormatRange); + } + + void HideSelection(BOOL bHide = TRUE, BOOL bChangeStyle = FALSE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_HIDESELECTION, bHide, bChangeStyle); + } + + void PasteSpecial(UINT uClipFormat, DWORD dwAspect = 0, HMETAFILE hMF = 0) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + REPASTESPECIAL reps = { dwAspect, (DWORD_PTR)hMF }; + ::SendMessage(this->m_hWnd, EM_PASTESPECIAL, uClipFormat, (LPARAM)&reps); + } + + void RequestResize() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_REQUESTRESIZE, 0, 0L); + } + + LONG StreamIn(UINT uFormat, EDITSTREAM& es) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (LONG)::SendMessage(this->m_hWnd, EM_STREAMIN, uFormat, (LPARAM)&es); + } + + LONG StreamOut(UINT uFormat, EDITSTREAM& es) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (LONG)::SendMessage(this->m_hWnd, EM_STREAMOUT, uFormat, (LPARAM)&es); + } + + DWORD FindWordBreak(int nCode, LONG nStartChar) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, EM_FINDWORDBREAK, nCode, nStartChar); + } + + // Additional operations + void ScrollCaret() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SCROLLCARET, 0, 0L); + } + + int InsertText(long nInsertAfterChar, LPCTSTR lpstrText, BOOL bCanUndo = FALSE) + { + int nRet = SetSel(nInsertAfterChar, nInsertAfterChar); + ReplaceSel(lpstrText, bCanUndo); + return nRet; + } + + int AppendText(LPCTSTR lpstrText, BOOL bCanUndo = FALSE) + { + return InsertText(this->GetWindowTextLength(), lpstrText, bCanUndo); + } + + // Clipboard operations + BOOL Undo() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_UNDO, 0, 0L); + } + + void Clear() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, WM_CLEAR, 0, 0L); + } + + void Copy() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, WM_COPY, 0, 0L); + } + + void Cut() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, WM_CUT, 0, 0L); + } + + void Paste() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, WM_PASTE, 0, 0L); + } + + // OLE support + IRichEditOle* GetOleInterface() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + IRichEditOle *pRichEditOle = NULL; + ::SendMessage(this->m_hWnd, EM_GETOLEINTERFACE, 0, (LPARAM)&pRichEditOle); + return pRichEditOle; + } + + BOOL SetOleCallback(IRichEditOleCallback* pCallback) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETOLECALLBACK, 0, (LPARAM)pCallback); + } + + BOOL Redo() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_REDO, 0, 0L); + } + + void StopGroupTyping() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_STOPGROUPTYPING, 0, 0L); + } + + void ShowScrollBar(int nBarType, BOOL bVisible = TRUE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SHOWSCROLLBAR, nBarType, bVisible); + } + + BOOL SetTabStops(int nTabStops, LPINT rgTabStops) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETTABSTOPS, nTabStops, (LPARAM)rgTabStops); + } + + BOOL SetTabStops() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETTABSTOPS, 0, 0L); + } + + BOOL SetTabStops(const int& cxEachStop) // takes an 'int' + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETTABSTOPS, 1, (LPARAM)(LPINT)&cxEachStop); + } + +#if (_RICHEDIT_VER >= 0x0800) + AutoCorrectProc GetAutoCorrectProc() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (AutoCorrectProc)::SendMessage(this->m_hWnd, EM_GETAUTOCORRECTPROC, 0, 0L); + } + + BOOL SetAutoCorrectProc(AutoCorrectProc pfn) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETAUTOCORRECTPROC, (WPARAM)pfn, 0L); + } + + BOOL CallAutoCorrectProc(WCHAR ch) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_CALLAUTOCORRECTPROC, (WPARAM)ch, 0L); + } + + DWORD GetEditStyleEx() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, EM_GETEDITSTYLEEX, 0, 0L); + } + + DWORD SetEditStyleEx(DWORD dwStyleEx, DWORD dwMask) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, EM_SETEDITSTYLEEX, dwStyleEx, dwMask); + } + + DWORD GetStoryType(int nStoryIndex) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, EM_GETSTORYTYPE, nStoryIndex, 0L); + } + + DWORD SetStoryType(int nStoryIndex, DWORD dwStoryType) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, EM_SETSTORYTYPE, nStoryIndex, dwStoryType); + } + + DWORD GetEllipsisMode() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + + DWORD dwMode = 0; + BOOL bRet = (BOOL)::SendMessage(this->m_hWnd, EM_GETELLIPSISMODE, 0, (LPARAM)&dwMode); + (void)bRet; // avoid level 4 warning + ATLASSERT(bRet != FALSE); + + return dwMode; + } + + BOOL SetEllipsisMode(DWORD dwEllipsisMode) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETELLIPSISMODE, 0, dwEllipsisMode); + } + + BOOL GetEllipsisState() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_GETELLIPSISSTATE, 0, 0L); + } + + BOOL GetTouchOptions(int nTouchOptions) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_GETTOUCHOPTIONS, nTouchOptions, 0L); + } + + void SetTouchOptions(int nTouchOptions, BOOL bEnable) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, EM_SETTOUCHOPTIONS, nTouchOptions, bEnable); + } + + HRESULT InsertTable(TABLEROWPARMS* pRowParams, TABLECELLPARMS* pCellParams) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HRESULT)::SendMessage(this->m_hWnd, EM_INSERTTABLE, (WPARAM)pRowParams, (LPARAM)pCellParams); + } + + HRESULT GetTableParams(TABLEROWPARMS* pRowParams, TABLECELLPARMS* pCellParams) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HRESULT)::SendMessage(this->m_hWnd, EM_GETTABLEPARMS, (WPARAM)pRowParams, (LPARAM)pCellParams); + } + + HRESULT SetTableParams(TABLEROWPARMS* pRowParams, TABLECELLPARMS* pCellParams) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HRESULT)::SendMessage(this->m_hWnd, EM_SETTABLEPARMS, (WPARAM)pRowParams, (LPARAM)pCellParams); + } + + HRESULT InsertImage(RICHEDIT_IMAGE_PARAMETERS* pParams) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HRESULT)::SendMessage(this->m_hWnd, EM_INSERTIMAGE, 0, (LPARAM)pParams); + } + + BOOL SetUiaName(LPCTSTR lpstrName) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, EM_SETUIANAME, 0, (LPARAM)lpstrName); + } +#endif // (_RICHEDIT_VER >= 0x0800) +}; + +typedef CRichEditCtrlT CRichEditCtrl; + + +/////////////////////////////////////////////////////////////////////////////// +// CRichEditCommands - message handlers for standard EDIT commands + +// Chain to CRichEditCommands message map. Your class must also derive from CRichEditCtrl. +// Example: +// class CMyRichEdit : public CWindowImpl, +// public CRichEditCommands +// { +// public: +// BEGIN_MSG_MAP(CMyRichEdit) +// // your handlers... +// CHAIN_MSG_MAP_ALT(CRichEditCommands, 1) +// END_MSG_MAP() +// // other stuff... +// }; + +template +class CRichEditCommands : public CEditCommands< T > +{ +public: + BEGIN_MSG_MAP(CRichEditCommands< T >) + ALT_MSG_MAP(1) + COMMAND_ID_HANDLER(ID_EDIT_CLEAR, CEditCommands< T >::OnEditClear) + COMMAND_ID_HANDLER(ID_EDIT_CLEAR_ALL, CEditCommands< T >::OnEditClearAll) + COMMAND_ID_HANDLER(ID_EDIT_COPY, CEditCommands< T >::OnEditCopy) + COMMAND_ID_HANDLER(ID_EDIT_CUT, CEditCommands< T >::OnEditCut) + COMMAND_ID_HANDLER(ID_EDIT_PASTE, CEditCommands< T >::OnEditPaste) + COMMAND_ID_HANDLER(ID_EDIT_SELECT_ALL, CEditCommands< T >::OnEditSelectAll) + COMMAND_ID_HANDLER(ID_EDIT_UNDO, CEditCommands< T >::OnEditUndo) + COMMAND_ID_HANDLER(ID_EDIT_REDO, OnEditRedo) + END_MSG_MAP() + + LRESULT OnEditRedo(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) + { + T* pT = static_cast(this); + pT->Redo(); + return 0; + } + +// State (update UI) helpers + BOOL CanCut() const + { return HasSelection(); } + + BOOL CanCopy() const + { return HasSelection(); } + + BOOL CanClear() const + { return HasSelection(); } + +// Implementation + BOOL HasSelection() const + { + const T* pT = static_cast(this); + return (pT->GetSelectionType() != SEL_EMPTY); + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CDragListBox + +template +class CDragListBoxT : public CListBoxT< TBase > +{ +public: +// Constructors + CDragListBoxT(HWND hWnd = NULL) : CListBoxT< TBase >(hWnd) + { } + + CDragListBoxT< TBase >& operator =(HWND hWnd) + { + this->m_hWnd = hWnd; + return *this; + } + + HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, + DWORD dwStyle = 0, DWORD dwExStyle = 0, + ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) + { + HWND hWnd = TBase::Create(TBase::GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); + if(hWnd != NULL) + MakeDragList(); + return hWnd; + } + +// Operations + BOOL MakeDragList() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((this->GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) == 0); + return ::MakeDragList(this->m_hWnd); + } + + int LBItemFromPt(POINT pt, BOOL bAutoScroll = TRUE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return ::LBItemFromPt(this->m_hWnd, pt, bAutoScroll); + } + + void DrawInsert(int nItem) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::DrawInsert(this->GetParent(), this->m_hWnd, nItem); + } + + static UINT GetDragListMessage() + { + static UINT uDragListMessage = 0; + if(uDragListMessage == 0) + { + CStaticDataInitCriticalSectionLock lock; + if(FAILED(lock.Lock())) + { + ATLTRACE2(atlTraceUI, 0, _T("ERROR : Unable to lock critical section in CDragListBox::GetDragListMessage.\n")); + ATLASSERT(FALSE); + return 0; + } + + if(uDragListMessage == 0) + uDragListMessage = ::RegisterWindowMessage(DRAGLISTMSGSTRING); + + lock.Unlock(); + } + ATLASSERT(uDragListMessage != 0); + return uDragListMessage; + } +}; + +typedef CDragListBoxT CDragListBox; + +template +class CDragListNotifyImpl +{ +public: + BEGIN_MSG_MAP(CDragListNotifyImpl< T >) + MESSAGE_HANDLER(CDragListBox::GetDragListMessage(), OnDragListNotify) + END_MSG_MAP() + + LRESULT OnDragListNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) + { + (void)uMsg; // avoid level 4 warning + ATLASSERT(uMsg == CDragListBox::GetDragListMessage()); + T* pT = static_cast(this); + LPDRAGLISTINFO lpDragListInfo = (LPDRAGLISTINFO)lParam; + LRESULT lRet = 0; + switch(lpDragListInfo->uNotification) + { + case DL_BEGINDRAG: + lRet = (LPARAM)pT->OnBeginDrag((int)wParam, lpDragListInfo->hWnd, lpDragListInfo->ptCursor); + break; + case DL_CANCELDRAG: + pT->OnCancelDrag((int)wParam, lpDragListInfo->hWnd, lpDragListInfo->ptCursor); + break; + case DL_DRAGGING: + lRet = (LPARAM)pT->OnDragging((int)wParam, lpDragListInfo->hWnd, lpDragListInfo->ptCursor); + break; + case DL_DROPPED: + pT->OnDropped((int)wParam, lpDragListInfo->hWnd, lpDragListInfo->ptCursor); + break; + default: + ATLTRACE2(atlTraceUI, 0, _T("Unknown DragListBox notification\n")); + bHandled = FALSE; // don't handle it + break; + } + return lRet; + } + +// Overrideables + BOOL OnBeginDrag(int /*nCtlID*/, HWND /*hWndDragList*/, POINT /*ptCursor*/) + { + return TRUE; // allow dragging + } + + void OnCancelDrag(int /*nCtlID*/, HWND /*hWndDragList*/, POINT /*ptCursor*/) + { + // nothing to do + } + + int OnDragging(int /*nCtlID*/, HWND /*hWndDragList*/, POINT /*ptCursor*/) + { + return 0; // don't change cursor + } + + void OnDropped(int /*nCtlID*/, HWND /*hWndDragList*/, POINT /*ptCursor*/) + { + // nothing to do + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CReBarCtrl + +template +class CReBarCtrlT : public TBase +{ +public: +// Constructors + CReBarCtrlT(HWND hWnd = NULL) : TBase(hWnd) + { } + + CReBarCtrlT< TBase >& operator =(HWND hWnd) + { + this->m_hWnd = hWnd; + return *this; + } + + HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, + DWORD dwStyle = 0, DWORD dwExStyle = 0, + ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) + { + return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); + } + +// Attributes + static LPCTSTR GetWndClassName() + { + return REBARCLASSNAME; + } + + UINT GetBandCount() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, RB_GETBANDCOUNT, 0, 0L); + } + + BOOL GetBandInfo(int nBand, LPREBARBANDINFO lprbbi) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, RB_GETBANDINFO, nBand, (LPARAM)lprbbi); + } + + BOOL SetBandInfo(int nBand, LPREBARBANDINFO lprbbi) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, RB_SETBANDINFO, nBand, (LPARAM)lprbbi); + } + + BOOL GetBarInfo(LPREBARINFO lprbi) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, RB_GETBARINFO, 0, (LPARAM)lprbi); + } + + BOOL SetBarInfo(LPREBARINFO lprbi) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, RB_SETBARINFO, 0, (LPARAM)lprbi); + } + + CImageList GetImageList() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + REBARINFO rbi = {}; + rbi.cbSize = sizeof(REBARINFO); + rbi.fMask = RBIM_IMAGELIST; + BOOL bRet = (BOOL)::SendMessage(this->m_hWnd, RB_GETBARINFO, 0, (LPARAM)&rbi); + return CImageList((bRet != FALSE) ? rbi.himl : NULL); + } + + BOOL SetImageList(HIMAGELIST hImageList) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + REBARINFO rbi = {}; + rbi.cbSize = sizeof(REBARINFO); + rbi.fMask = RBIM_IMAGELIST; + rbi.himl = hImageList; + return (BOOL)::SendMessage(this->m_hWnd, RB_SETBARINFO, 0, (LPARAM)&rbi); + } + + UINT GetRowCount() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, RB_GETROWCOUNT, 0, 0L); + } + + UINT GetRowHeight(int nBand) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, RB_GETROWHEIGHT, nBand, 0L); + } + + COLORREF GetTextColor() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, RB_GETTEXTCOLOR, 0, 0L); + } + + COLORREF SetTextColor(COLORREF clr) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, RB_SETTEXTCOLOR, 0, (LPARAM)clr); + } + + COLORREF GetBkColor() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, RB_GETBKCOLOR, 0, 0L); + } + + COLORREF SetBkColor(COLORREF clr) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, RB_SETBKCOLOR, 0, (LPARAM)clr); + } + + UINT GetBarHeight() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (UINT)::SendMessage(this->m_hWnd, RB_GETBARHEIGHT, 0, 0L); + } + + BOOL GetRect(int nBand, LPRECT lpRect) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, RB_GETRECT, nBand, (LPARAM)lpRect); + } + + CToolTipCtrl GetToolTips() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return CToolTipCtrl((HWND)::SendMessage(this->m_hWnd, RB_GETTOOLTIPS, 0, 0L)); + } + + void SetToolTips(HWND hwndToolTip) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, RB_SETTOOLTIPS, (WPARAM)hwndToolTip, 0L); + } + + void GetBandBorders(int nBand, LPRECT lpRect) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(lpRect != NULL); + ::SendMessage(this->m_hWnd, RB_GETBANDBORDERS, nBand, (LPARAM)lpRect); + } + + BOOL GetColorScheme(LPCOLORSCHEME lpColorScheme) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(lpColorScheme != NULL); + return (BOOL)::SendMessage(this->m_hWnd, RB_GETCOLORSCHEME, 0, (LPARAM)lpColorScheme); + } + + void SetColorScheme(LPCOLORSCHEME lpColorScheme) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(lpColorScheme != NULL); + ::SendMessage(this->m_hWnd, RB_SETCOLORSCHEME, 0, (LPARAM)lpColorScheme); + } + + HPALETTE GetPalette() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HPALETTE)::SendMessage(this->m_hWnd, RB_GETPALETTE, 0, 0L); + } + + HPALETTE SetPalette(HPALETTE hPalette) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HPALETTE)::SendMessage(this->m_hWnd, RB_SETPALETTE, 0, (LPARAM)hPalette); + } + + BOOL GetUnicodeFormat() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, RB_GETUNICODEFORMAT, 0, 0L); + } + + BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, RB_SETUNICODEFORMAT, bUnicode, 0L); + } + + // requires uxtheme.h to be included to use MARGINS struct +#ifndef _UXTHEME_H_ + typedef struct _MARGINS* PMARGINS; +#endif // !_UXTHEME_H_ + void GetBandMargins(PMARGINS pMargins) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, RB_GETBANDMARGINS, 0, (LPARAM)pMargins); + } + + void SetWindowTheme(LPCWSTR lpstrTheme) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, RB_SETWINDOWTHEME, 0, (LPARAM)lpstrTheme); + } + + DWORD GetExtendedStyle() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, RB_GETEXTENDEDSTYLE, 0, 0L); + } + + DWORD SetExtendedStyle(DWORD dwStyle, DWORD dwMask) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, RB_SETEXTENDEDSTYLE, dwMask, dwStyle); + } + +// Operations + BOOL InsertBand(int nBand, LPREBARBANDINFO lprbbi) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, RB_INSERTBAND, nBand, (LPARAM)lprbbi); + } + + BOOL AddBand(LPREBARBANDINFO lprbbi) + { + return InsertBand(-1, lprbbi); + } + + BOOL DeleteBand(int nBand) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, RB_DELETEBAND, nBand, 0L); + } + + ATL::CWindow SetNotifyWnd(HWND hWnd) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return ATL::CWindow((HWND)::SendMessage(this->m_hWnd, RB_SETPARENT, (WPARAM)hWnd, 0L)); + } + + void BeginDrag(int nBand, DWORD dwPos) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, RB_BEGINDRAG, nBand, dwPos); + } + + void BeginDrag(int nBand, int xPos, int yPos) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, RB_BEGINDRAG, nBand, MAKELPARAM(xPos, yPos)); + } + + void EndDrag() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, RB_ENDDRAG, 0, 0L); + } + + void DragMove(DWORD dwPos) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, RB_DRAGMOVE, 0, dwPos); + } + + void DragMove(int xPos, int yPos) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, RB_DRAGMOVE, 0, MAKELPARAM(xPos, yPos)); + } + + void GetDropTarget(IDropTarget** ppDropTarget) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, RB_GETDROPTARGET, 0, (LPARAM)ppDropTarget); + } + + void MaximizeBand(int nBand, BOOL bIdeal = FALSE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, RB_MAXIMIZEBAND, nBand, bIdeal); + } + + void MinimizeBand(int nBand) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, RB_MINIMIZEBAND, nBand, 0L); + } + + BOOL SizeToRect(LPRECT lpRect) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, RB_SIZETORECT, 0, (LPARAM)lpRect); + } + + int IdToIndex(UINT uBandID) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, RB_IDTOINDEX, uBandID, 0L); + } + + int HitTest(LPRBHITTESTINFO lprbht) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, RB_HITTEST, 0, (LPARAM)lprbht); + } + + BOOL ShowBand(int nBand, BOOL bShow) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, RB_SHOWBAND, nBand, bShow); + } + + BOOL MoveBand(int nBand, int nNewPos) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((nNewPos >= 0) && (nNewPos <= ((int)GetBandCount() - 1))); + return (BOOL)::SendMessage(this->m_hWnd, RB_MOVEBAND, nBand, nNewPos); + } + + void PushChevron(int nBand, LPARAM lAppValue) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, RB_PUSHCHEVRON, nBand, lAppValue); + } + +// Extra operations + void LockBands(bool bLock) + { + int nBandCount = GetBandCount(); + for(int i =0; i < nBandCount; i++) + { + REBARBANDINFO rbbi = { RunTimeHelper::SizeOf_REBARBANDINFO() }; + rbbi.fMask = RBBIM_STYLE; + BOOL bRet = GetBandInfo(i, &rbbi); + ATLASSERT(bRet); + + if((rbbi.fStyle & RBBS_GRIPPERALWAYS) == 0) + { + rbbi.fStyle |= RBBS_GRIPPERALWAYS; + bRet = SetBandInfo(i, &rbbi); + ATLASSERT(bRet); + rbbi.fStyle &= ~RBBS_GRIPPERALWAYS; + } + + if(bLock) + rbbi.fStyle |= RBBS_NOGRIPPER; + else + rbbi.fStyle &= ~RBBS_NOGRIPPER; + + bRet = SetBandInfo(i, &rbbi); + ATLASSERT(bRet); + } + } + +#if (_WIN32_WINNT >= 0x0600) + BOOL SetBandWidth(int nBand, int cxWidth) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, RB_SETBANDWIDTH, nBand, cxWidth); + } +#endif // (_WIN32_WINNT >= 0x0600) +}; + +typedef CReBarCtrlT CReBarCtrl; + + +/////////////////////////////////////////////////////////////////////////////// +// CComboBoxEx + +template +class CComboBoxExT : public CComboBoxT< TBase > +{ +public: +// Constructors + CComboBoxExT(HWND hWnd = NULL) : CComboBoxT< TBase >(hWnd) + { } + + CComboBoxExT< TBase >& operator =(HWND hWnd) + { + this->m_hWnd = hWnd; + return *this; + } + + HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, + DWORD dwStyle = 0, DWORD dwExStyle = 0, + ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) + { + return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); + } + +// Attributes + static LPCTSTR GetWndClassName() + { + return WC_COMBOBOXEX; + } + + CImageList GetImageList() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, CBEM_GETIMAGELIST, 0, 0L)); + } + + CImageList SetImageList(HIMAGELIST hImageList) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, CBEM_SETIMAGELIST, 0, (LPARAM)hImageList)); + } + + DWORD GetExtendedStyle() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, CBEM_GETEXTENDEDSTYLE, 0, 0L); + } + + DWORD SetExtendedStyle(DWORD dwExMask, DWORD dwExStyle) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, CBEM_SETEXTENDEDSTYLE, dwExMask, dwExStyle); + } + + BOOL GetUnicodeFormat() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, CBEM_GETUNICODEFORMAT, 0, 0L); + } + + BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, CBEM_SETUNICODEFORMAT, bUnicode, 0L); + } + + void SetWindowTheme(LPCWSTR lpstrTheme) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, CBEM_SETWINDOWTHEME, 0, (LPARAM)lpstrTheme); + } + +// Operations + int InsertItem(const COMBOBOXEXITEM* lpcCBItem) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CBEM_INSERTITEM, 0, (LPARAM)lpcCBItem); + } + + int InsertItem(UINT nMask, int nIndex, LPCTSTR lpszItem, int nImage, int nSelImage, + int iIndent, int iOverlay, LPARAM lParam) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + COMBOBOXEXITEM cbex = {}; + cbex.mask = nMask; + cbex.iItem = nIndex; + cbex.pszText = (LPTSTR) lpszItem; + cbex.iImage = nImage; + cbex.iSelectedImage = nSelImage; + cbex.iIndent = iIndent; + cbex.iOverlay = iOverlay; + cbex.lParam = lParam; + return (int)::SendMessage(this->m_hWnd, CBEM_INSERTITEM, 0, (LPARAM)&cbex); + } + + int InsertItem(int nIndex, LPCTSTR lpszItem, int nImage, int nSelImage, int iIndent, LPARAM lParam = 0) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + COMBOBOXEXITEM cbex = {}; + cbex.mask = CBEIF_TEXT | CBEIF_IMAGE | CBEIF_SELECTEDIMAGE | CBEIF_INDENT | CBEIF_LPARAM; + cbex.iItem = nIndex; + cbex.pszText = (LPTSTR) lpszItem; + cbex.iImage = nImage; + cbex.iSelectedImage = nSelImage; + cbex.iIndent = iIndent; + cbex.lParam = lParam; + return (int)::SendMessage(this->m_hWnd, CBEM_INSERTITEM, 0, (LPARAM)&cbex); + } + + int AddItem(UINT nMask, LPCTSTR lpszItem, int nImage, int nSelImage, int iIndent, int iOverlay, LPARAM lParam) + { + return InsertItem(nMask, -1, lpszItem, nImage, nSelImage, iIndent, iOverlay, lParam); + } + + int AddItem(LPCTSTR lpszItem, int nImage, int nSelImage, int iIndent, LPARAM lParam = 0) + { + return InsertItem(-1, lpszItem, nImage, nSelImage, iIndent, lParam); + } + + int DeleteItem(int nIndex) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, CBEM_DELETEITEM, nIndex, 0L); + } + + BOOL GetItem(PCOMBOBOXEXITEM pCBItem) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, CBEM_GETITEM, 0, (LPARAM)pCBItem); + } + + BOOL SetItem(const COMBOBOXEXITEM* lpcCBItem) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, CBEM_SETITEM, 0, (LPARAM)lpcCBItem); + } + + int SetItem(int nIndex, UINT nMask, LPCTSTR lpszItem, int nImage, int nSelImage, + int iIndent, int iOverlay, LPARAM lParam) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + COMBOBOXEXITEM cbex = {}; + cbex.mask = nMask; + cbex.iItem = nIndex; + cbex.pszText = (LPTSTR) lpszItem; + cbex.iImage = nImage; + cbex.iSelectedImage = nSelImage; + cbex.iIndent = iIndent; + cbex.iOverlay = iOverlay; + cbex.lParam = lParam; + return (int)::SendMessage(this->m_hWnd, CBEM_SETITEM, 0, (LPARAM)&cbex); + } + + BOOL GetItemText(int nIndex, LPTSTR lpszItem, int nLen) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(lpszItem != NULL); + + COMBOBOXEXITEM cbex = {}; + cbex.mask = CBEIF_TEXT; + cbex.iItem = nIndex; + cbex.pszText = lpszItem; + cbex.cchTextMax = nLen; + + return (BOOL)::SendMessage(this->m_hWnd, CBEM_GETITEM, 0, (LPARAM)&cbex); + } + + BOOL GetItemText(int nIndex, BSTR& bstrText) const + { + USES_CONVERSION; + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(bstrText == NULL); + + COMBOBOXEXITEM cbex = {}; + cbex.mask = CBEIF_TEXT; + cbex.iItem = nIndex; + + LPTSTR lpstrText = NULL; + BOOL bRet = FALSE; + for(int nLen = 256; ; nLen *= 2) + { + ATLTRY(lpstrText = new TCHAR[nLen]); + if(lpstrText == NULL) + break; + lpstrText[0] = NULL; + cbex.pszText = lpstrText; + cbex.cchTextMax = nLen; + bRet = (BOOL)::SendMessage(this->m_hWnd, CBEM_GETITEM, 0, (LPARAM)&cbex); + if(!bRet || (lstrlen(cbex.pszText) < (nLen - 1))) + break; + delete [] lpstrText; + lpstrText = NULL; + } + + if(lpstrText != NULL) + { + if(bRet) + bstrText = ::SysAllocString(T2OLE(lpstrText)); + delete [] lpstrText; + } + + return (bstrText != NULL) ? TRUE : FALSE; + } + +#ifdef __ATLSTR_H__ + BOOL GetItemText(int nIndex, ATL::CString& strText) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + + COMBOBOXEXITEM cbex = {}; + cbex.mask = CBEIF_TEXT; + cbex.iItem = nIndex; + + strText.Empty(); + BOOL bRet = FALSE; + for(int nLen = 256; ; nLen *= 2) + { + cbex.pszText = strText.GetBufferSetLength(nLen); + if(cbex.pszText == NULL) + { + bRet = FALSE; + break; + } + cbex.cchTextMax = nLen; + bRet = (BOOL)::SendMessage(this->m_hWnd, CBEM_GETITEM, 0, (LPARAM)&cbex); + if(!bRet || (lstrlen(cbex.pszText) < (nLen - 1))) + break; + } + strText.ReleaseBuffer(); + return bRet; + } +#endif // __ATLSTR_H__ + + BOOL SetItemText(int nIndex, LPCTSTR lpszItem) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return SetItem(nIndex, CBEIF_TEXT, lpszItem, 0, 0, 0, 0, 0); + } + + CComboBox GetComboCtrl() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return CComboBox((HWND)::SendMessage(this->m_hWnd, CBEM_GETCOMBOCONTROL, 0, 0L)); + } + + CEdit GetEditCtrl() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return CEdit((HWND)::SendMessage(this->m_hWnd, CBEM_GETEDITCONTROL, 0, 0L)); + } + + BOOL HasEditChanged() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, CBEM_HASEDITCHANGED, 0, 0L); + } + +// Non-functional + int AddString(LPCTSTR /*lpszItem*/) + { + ATLASSERT(FALSE); // Not available in CComboBoxEx; use InsertItem + return 0; + } + + int InsertString(int /*nIndex*/, LPCTSTR /*lpszString*/) + { + ATLASSERT(FALSE); // Not available in CComboBoxEx; use InsertItem + return 0; + } + + int Dir(UINT /*attr*/, LPCTSTR /*lpszWildCard*/) + { + ATLASSERT(FALSE); // Not available in CComboBoxEx + return 0; + } + + int FindString(int /*nStartAfter*/, LPCTSTR /*lpszString*/) const + { + ATLASSERT(FALSE); // Not available in CComboBoxEx; try FindStringExact + return 0; + } +}; + +typedef CComboBoxExT CComboBoxEx; + + +/////////////////////////////////////////////////////////////////////////////// +// CMonthCalendarCtrl + +template +class CMonthCalendarCtrlT : public TBase +{ +public: +// Constructors + CMonthCalendarCtrlT(HWND hWnd = NULL) : TBase(hWnd) + { } + + CMonthCalendarCtrlT< TBase >& operator =(HWND hWnd) + { + this->m_hWnd = hWnd; + return *this; + } + + HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, + DWORD dwStyle = 0, DWORD dwExStyle = 0, + ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) + { + return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); + } + +// Attributes + static LPCTSTR GetWndClassName() + { + return MONTHCAL_CLASS; + } + + COLORREF GetColor(int nColorType) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, MCM_GETCOLOR, nColorType, 0L); + } + + COLORREF SetColor(int nColorType, COLORREF clr) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, MCM_SETCOLOR, nColorType, clr); + } + + BOOL GetCurSel(LPSYSTEMTIME lpSysTime) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, MCM_GETCURSEL, 0, (LPARAM)lpSysTime); + } + + BOOL SetCurSel(LPSYSTEMTIME lpSysTime) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, MCM_SETCURSEL, 0, (LPARAM)lpSysTime); + } + + int GetFirstDayOfWeek(BOOL* pbLocaleVal = NULL) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, MCM_GETFIRSTDAYOFWEEK, 0, 0L); + if(pbLocaleVal != NULL) + *pbLocaleVal = (BOOL)HIWORD(dwRet); + return (int)(short)LOWORD(dwRet); + } + + int SetFirstDayOfWeek(int nDay, BOOL* pbLocaleVal = NULL) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, MCM_SETFIRSTDAYOFWEEK, 0, nDay); + if(pbLocaleVal != NULL) + *pbLocaleVal = (BOOL)HIWORD(dwRet); + return (int)(short)LOWORD(dwRet); + } + + int GetMaxSelCount() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, MCM_GETMAXSELCOUNT, 0, 0L); + } + + BOOL SetMaxSelCount(int nMax) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, MCM_SETMAXSELCOUNT, nMax, 0L); + } + + int GetMonthDelta() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, MCM_GETMONTHDELTA, 0, 0L); + } + + int SetMonthDelta(int nDelta) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, MCM_SETMONTHDELTA, nDelta, 0L); + } + + DWORD GetRange(LPSYSTEMTIME lprgSysTimeArray) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, MCM_GETRANGE, 0, (LPARAM)lprgSysTimeArray); + } + + BOOL SetRange(DWORD dwFlags, LPSYSTEMTIME lprgSysTimeArray) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, MCM_SETRANGE, dwFlags, (LPARAM)lprgSysTimeArray); + } + + BOOL GetSelRange(LPSYSTEMTIME lprgSysTimeArray) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, MCM_GETSELRANGE, 0, (LPARAM)lprgSysTimeArray); + } + + BOOL SetSelRange(LPSYSTEMTIME lprgSysTimeArray) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, MCM_SETSELRANGE, 0, (LPARAM)lprgSysTimeArray); + } + + BOOL GetToday(LPSYSTEMTIME lpSysTime) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, MCM_GETTODAY, 0, (LPARAM)lpSysTime); + } + + void SetToday(LPSYSTEMTIME lpSysTime) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, MCM_SETTODAY, 0, (LPARAM)lpSysTime); + } + + BOOL GetMinReqRect(LPRECT lpRectInfo) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, MCM_GETMINREQRECT, 0, (LPARAM)lpRectInfo); + } + + int GetMaxTodayWidth() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, MCM_GETMAXTODAYWIDTH, 0, 0L); + } + + BOOL GetUnicodeFormat() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, MCM_GETUNICODEFORMAT, 0, 0L); + } + + BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, MCM_SETUNICODEFORMAT, bUnicode, 0L); + } + +#if defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN) + DWORD GetCurrentView() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, MCM_GETCURRENTVIEW, 0, 0L); + } + + BOOL SetCurrentView(DWORD dwView) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, MCM_SETCURRENTVIEW, 0, dwView); + } + + DWORD GetCalendarCount() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, MCM_GETCALENDARCOUNT, 0, 0L); + } + + BOOL GetCalendarGridInfo(PMCGRIDINFO pGridInfo) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, MCM_GETCALENDARGRIDINFO, 0, (LPARAM)pGridInfo); + } + + CALID GetCALID() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (CALID)::SendMessage(this->m_hWnd, MCM_GETCALID, 0, 0L); + } + + void SetCALID(CALID calid) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, MCM_SETCALID, (LPARAM)calid, 0L); + } + + int GetCalendarBorder() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, MCM_GETCALENDARBORDER, 0, 0L); + } + + void SetCalendarBorder(int cxyBorder, BOOL bSet = TRUE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, MCM_SETCALENDARBORDER, (WPARAM)bSet, (LPARAM)cxyBorder); + } +#endif // defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN) + +// Operations + int GetMonthRange(DWORD dwFlags, LPSYSTEMTIME lprgSysTimeArray) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, MCM_GETMONTHRANGE, dwFlags, (LPARAM)lprgSysTimeArray); + } + + BOOL SetDayState(int nMonths, LPMONTHDAYSTATE lpDayStateArray) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, MCM_SETDAYSTATE, nMonths, (LPARAM)lpDayStateArray); + } + + DWORD HitTest(PMCHITTESTINFO pMCHitTest) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, MCM_HITTEST, 0, (LPARAM)pMCHitTest); + } + +#if defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN) + void SizeRectToMin(LPRECT lpRect) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, MCM_SIZERECTTOMIN, 0, (LPARAM)lpRect); + } +#endif // defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN) +}; + +typedef CMonthCalendarCtrlT CMonthCalendarCtrl; + + +/////////////////////////////////////////////////////////////////////////////// +// CDateTimePickerCtrl + +template +class CDateTimePickerCtrlT : public TBase +{ +public: +// Constructors + CDateTimePickerCtrlT(HWND hWnd = NULL) : TBase(hWnd) + { } + + CDateTimePickerCtrlT< TBase >& operator =(HWND hWnd) + { + this->m_hWnd = hWnd; + return *this; + } + + HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, + DWORD dwStyle = 0, DWORD dwExStyle = 0, + ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) + { + return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); + } + +// Operations + static LPCTSTR GetWndClassName() + { + return DATETIMEPICK_CLASS; + } + + BOOL SetFormat(LPCTSTR lpszFormat) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, DTM_SETFORMAT, 0, (LPARAM)lpszFormat); + } + + COLORREF GetMonthCalColor(int nColorType) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, DTM_GETMCCOLOR, nColorType, 0L); + } + + COLORREF SetMonthCalColor(int nColorType, COLORREF clr) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, DTM_SETMCCOLOR, nColorType, clr); + } + + DWORD GetRange(LPSYSTEMTIME lpSysTimeArray) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, DTM_GETRANGE, 0, (LPARAM)lpSysTimeArray); + } + + BOOL SetRange(DWORD dwFlags, LPSYSTEMTIME lpSysTimeArray) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, DTM_SETRANGE, dwFlags, (LPARAM)lpSysTimeArray); + } + + DWORD GetSystemTime(LPSYSTEMTIME lpSysTime) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)lpSysTime); + } + + BOOL SetSystemTime(DWORD dwFlags, LPSYSTEMTIME lpSysTime) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, DTM_SETSYSTEMTIME, dwFlags, (LPARAM)lpSysTime); + } + + CMonthCalendarCtrl GetMonthCal() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return CMonthCalendarCtrl((HWND)::SendMessage(this->m_hWnd, DTM_GETMONTHCAL, 0, 0L)); + } + + CFontHandle GetMonthCalFont() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return CFontHandle((HFONT)::SendMessage(this->m_hWnd, DTM_GETMCFONT, 0, 0L)); + } + + void SetMonthCalFont(HFONT hFont, BOOL bRedraw = TRUE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, DTM_SETMCFONT, (WPARAM)hFont, MAKELPARAM(bRedraw, 0)); + } + +#if defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN) + DWORD GetMonthCalStyle() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, DTM_GETMCSTYLE, 0, 0L); + } + + DWORD SetMonthCalStyle(DWORD dwStyle) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (DWORD)::SendMessage(this->m_hWnd, DTM_SETMCSTYLE, 0, (LPARAM)dwStyle); + } + + void GetDateTimePickerInfo(LPDATETIMEPICKERINFO lpPickerInfo) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, DTM_GETDATETIMEPICKERINFO, 0, (LPARAM)lpPickerInfo); + } + + BOOL GetIdealSize(LPSIZE lpSize) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, DTM_GETIDEALSIZE, 0, (LPARAM)lpSize); + } + + void CloseMonthCal() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, DTM_CLOSEMONTHCAL, 0, 0L); + } +#endif // defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN) +}; + +typedef CDateTimePickerCtrlT CDateTimePickerCtrl; + + +/////////////////////////////////////////////////////////////////////////////// +// CFlatScrollBarImpl - support for flat scroll bars + +template +class CFlatScrollBarImpl +{ +public: +// Initialization + BOOL FlatSB_Initialize() + { + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + return ::InitializeFlatSB(pT->m_hWnd); + } + + HRESULT FlatSB_Uninitialize() + { + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + return ::UninitializeFlatSB(pT->m_hWnd); + } + +// Flat scroll bar properties + BOOL FlatSB_GetScrollProp(UINT uIndex, LPINT lpnValue) const + { + const T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + return ::FlatSB_GetScrollProp(pT->m_hWnd, uIndex, lpnValue); + } + + BOOL FlatSB_SetScrollProp(UINT uIndex, int nValue, BOOL bRedraw = TRUE) + { + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + return ::FlatSB_SetScrollProp(pT->m_hWnd, uIndex, nValue, bRedraw); + } + +// Attributes + int FlatSB_GetScrollPos(int nBar) const + { + const T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + return ::FlatSB_GetScrollPos(pT->m_hWnd, nBar); + } + + int FlatSB_SetScrollPos(int nBar, int nPos, BOOL bRedraw = TRUE) + { + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + return ::FlatSB_SetScrollPos(pT->m_hWnd, nBar, nPos, bRedraw); + } + + BOOL FlatSB_GetScrollRange(int nBar, LPINT lpMinPos, LPINT lpMaxPos) const + { + const T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + return ::FlatSB_GetScrollRange(pT->m_hWnd, nBar, lpMinPos, lpMaxPos); + } + + BOOL FlatSB_SetScrollRange(int nBar, int nMinPos, int nMaxPos, BOOL bRedraw = TRUE) + { + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + return ::FlatSB_SetScrollRange(pT->m_hWnd, nBar, nMinPos, nMaxPos, bRedraw); + } + + BOOL FlatSB_GetScrollInfo(int nBar, LPSCROLLINFO lpScrollInfo) const + { + const T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + return ::FlatSB_GetScrollInfo(pT->m_hWnd, nBar, lpScrollInfo); + } + + int FlatSB_SetScrollInfo(int nBar, LPSCROLLINFO lpScrollInfo, BOOL bRedraw = TRUE) + { + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + return ::FlatSB_SetScrollInfo(pT->m_hWnd, nBar, lpScrollInfo, bRedraw); + } + +// Operations + BOOL FlatSB_ShowScrollBar(UINT nBar, BOOL bShow = TRUE) + { + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + return ::FlatSB_ShowScrollBar(pT->m_hWnd, nBar, bShow); + } + + BOOL FlatSB_EnableScrollBar(UINT uSBFlags, UINT uArrowFlags = ESB_ENABLE_BOTH) + { + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + return ::FlatSB_EnableScrollBar(pT->m_hWnd, uSBFlags, uArrowFlags); + } +}; + +template +class CFlatScrollBarT : public TBase, public CFlatScrollBarImpl > +{ +public: + CFlatScrollBarT(HWND hWnd = NULL) : TBase(hWnd) + { } + + CFlatScrollBarT< TBase >& operator =(HWND hWnd) + { + this->m_hWnd = hWnd; + return *this; + } +}; + +typedef CFlatScrollBarT CFlatScrollBar; + + +/////////////////////////////////////////////////////////////////////////////// +// CIPAddressCtrl + +template +class CIPAddressCtrlT : public TBase +{ +public: +// Constructors + CIPAddressCtrlT(HWND hWnd = NULL) : TBase(hWnd) + { } + + CIPAddressCtrlT< TBase >& operator =(HWND hWnd) + { + this->m_hWnd = hWnd; + return *this; + } + + HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, + DWORD dwStyle = 0, DWORD dwExStyle = 0, + ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) + { + return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); + } + +// Atteributes + static LPCTSTR GetWndClassName() + { + return WC_IPADDRESS; + } + + BOOL IsBlank() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, IPM_ISBLANK, 0, 0L); + } + + int GetAddress(LPDWORD lpdwAddress) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, IPM_GETADDRESS, 0, (LPARAM)lpdwAddress); + } + + void SetAddress(DWORD dwAddress) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, IPM_SETADDRESS, 0, dwAddress); + } + + void ClearAddress() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, IPM_CLEARADDRESS, 0, 0L); + } + + void SetRange(int nField, WORD wRange) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, IPM_SETRANGE, nField, wRange); + } + + void SetRange(int nField, BYTE nMin, BYTE nMax) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, IPM_SETRANGE, nField, MAKEIPRANGE(nMin, nMax)); + } + + void SetFocus(int nField) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, IPM_SETFOCUS, nField, 0L); + } +}; + +typedef CIPAddressCtrlT CIPAddressCtrl; + + +/////////////////////////////////////////////////////////////////////////////// +// CPagerCtrl + +template +class CPagerCtrlT : public TBase +{ +public: +// Constructors + CPagerCtrlT(HWND hWnd = NULL) : TBase(hWnd) + { } + + CPagerCtrlT< TBase >& operator =(HWND hWnd) + { + this->m_hWnd = hWnd; + return *this; + } + + HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, + DWORD dwStyle = 0, DWORD dwExStyle = 0, + ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) + { + return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); + } + +// Attributes + static LPCTSTR GetWndClassName() + { + return WC_PAGESCROLLER; + } + + int GetButtonSize() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, PGM_GETBUTTONSIZE, 0, 0L); + } + + int SetButtonSize(int nButtonSize) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, PGM_SETBUTTONSIZE, 0, nButtonSize); + } + + DWORD GetButtonState(int nButton) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((nButton == PGB_TOPORLEFT) || (nButton == PGB_BOTTOMORRIGHT)); + return (DWORD)::SendMessage(this->m_hWnd, PGM_GETBUTTONSTATE, 0, nButton); + } + + COLORREF GetBkColor() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, PGM_GETBKCOLOR, 0, 0L); + } + + COLORREF SetBkColor(COLORREF clrBk) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (COLORREF)::SendMessage(this->m_hWnd, PGM_SETBKCOLOR, 0, (LPARAM)clrBk); + } + + int GetBorder() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, PGM_GETBORDER, 0, 0L); + } + + int SetBorder(int nBorderSize) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, PGM_SETBORDER, 0, nBorderSize); + } + + int GetPos() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, PGM_GETPOS, 0, 0L); + } + + int SetPos(int nPos) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, PGM_SETPOS, 0, nPos); + } + +// Operations + void SetChild(HWND hWndChild) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, PGM_SETCHILD, 0, (LPARAM)hWndChild); + } + + void ForwardMouse(BOOL bForward = TRUE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, PGM_FORWARDMOUSE, bForward, 0L); + } + + void RecalcSize() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ::SendMessage(this->m_hWnd, PGM_RECALCSIZE, 0, 0L); + } + + void GetDropTarget(IDropTarget** ppDropTarget) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(ppDropTarget != NULL); + ::SendMessage(this->m_hWnd, PGM_GETDROPTARGET, 0, (LPARAM)ppDropTarget); + } +}; + +typedef CPagerCtrlT CPagerCtrl; + + +/////////////////////////////////////////////////////////////////////////////// +// CLinkCtrl - Windows SYSLINK control + +template +class CLinkCtrlT : public TBase +{ +public: +// Constructors + CLinkCtrlT(HWND hWnd = NULL) : TBase(hWnd) + { } + + CLinkCtrlT< TBase >& operator =(HWND hWnd) + { + this->m_hWnd = hWnd; + return *this; + } + + HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, + DWORD dwStyle = 0, DWORD dwExStyle = 0, + ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) + { + return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); + } + +// Attributes + static LPCTSTR GetWndClassName() + { +#ifdef _UNICODE + return WC_LINK; +#else // !_UNICODE + return "SysLink"; +#endif // !_UNICODE + } + + int GetIdealHeight(int cxMaxWidth = 0) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LM_GETIDEALHEIGHT, cxMaxWidth, 0L); + } + + BOOL GetItem(PLITEM pLItem) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LM_GETITEM, 0, (LPARAM)pLItem); + } + + BOOL SetItem(PLITEM pLItem) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LM_SETITEM, 0, (LPARAM)pLItem); + } + + // Vista only + int GetIdealSize(SIZE& size, int cxMaxWidth = 0) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (int)::SendMessage(this->m_hWnd, LM_GETIDEALSIZE, cxMaxWidth, (LPARAM)&size); + } + +// Operations + BOOL HitTest(PLHITTESTINFO pLHitTestInfo) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (BOOL)::SendMessage(this->m_hWnd, LM_HITTEST, 0, (LPARAM)pLHitTestInfo); + } +}; + +typedef CLinkCtrlT CLinkCtrl; + + +/////////////////////////////////////////////////////////////////////////////// +// CCustomDraw - MI class for custom-draw support + +template +class CCustomDraw +{ +public: +// Message map and handlers + BEGIN_MSG_MAP(CCustomDraw< T >) + NOTIFY_CODE_HANDLER(NM_CUSTOMDRAW, OnCustomDraw) + ALT_MSG_MAP(1) + REFLECTED_NOTIFY_CODE_HANDLER(NM_CUSTOMDRAW, OnCustomDraw) + END_MSG_MAP() + +// message handler + LRESULT OnCustomDraw(int idCtrl, LPNMHDR pnmh, BOOL& bHandled) + { + T* pT = static_cast(this); + pT->SetMsgHandled(TRUE); + LPNMCUSTOMDRAW lpNMCustomDraw = (LPNMCUSTOMDRAW)pnmh; + DWORD dwRet = 0; + switch(lpNMCustomDraw->dwDrawStage) + { + case CDDS_PREPAINT: + dwRet = pT->OnPrePaint(idCtrl, lpNMCustomDraw); + break; + case CDDS_POSTPAINT: + dwRet = pT->OnPostPaint(idCtrl, lpNMCustomDraw); + break; + case CDDS_PREERASE: + dwRet = pT->OnPreErase(idCtrl, lpNMCustomDraw); + break; + case CDDS_POSTERASE: + dwRet = pT->OnPostErase(idCtrl, lpNMCustomDraw); + break; + case CDDS_ITEMPREPAINT: + dwRet = pT->OnItemPrePaint(idCtrl, lpNMCustomDraw); + break; + case CDDS_ITEMPOSTPAINT: + dwRet = pT->OnItemPostPaint(idCtrl, lpNMCustomDraw); + break; + case CDDS_ITEMPREERASE: + dwRet = pT->OnItemPreErase(idCtrl, lpNMCustomDraw); + break; + case CDDS_ITEMPOSTERASE: + dwRet = pT->OnItemPostErase(idCtrl, lpNMCustomDraw); + break; + case (CDDS_ITEMPREPAINT | CDDS_SUBITEM): + dwRet = pT->OnSubItemPrePaint(idCtrl, lpNMCustomDraw); + break; + default: + pT->SetMsgHandled(FALSE); + break; + } + bHandled = pT->IsMsgHandled(); + return dwRet; + } + +// Overrideables + DWORD OnPrePaint(int /*idCtrl*/, LPNMCUSTOMDRAW /*lpNMCustomDraw*/) + { + return CDRF_DODEFAULT; + } + + DWORD OnPostPaint(int /*idCtrl*/, LPNMCUSTOMDRAW /*lpNMCustomDraw*/) + { + return CDRF_DODEFAULT; + } + + DWORD OnPreErase(int /*idCtrl*/, LPNMCUSTOMDRAW /*lpNMCustomDraw*/) + { + return CDRF_DODEFAULT; + } + + DWORD OnPostErase(int /*idCtrl*/, LPNMCUSTOMDRAW /*lpNMCustomDraw*/) + { + return CDRF_DODEFAULT; + } + + DWORD OnItemPrePaint(int /*idCtrl*/, LPNMCUSTOMDRAW /*lpNMCustomDraw*/) + { + return CDRF_DODEFAULT; + } + + DWORD OnItemPostPaint(int /*idCtrl*/, LPNMCUSTOMDRAW /*lpNMCustomDraw*/) + { + return CDRF_DODEFAULT; + } + + DWORD OnItemPreErase(int /*idCtrl*/, LPNMCUSTOMDRAW /*lpNMCustomDraw*/) + { + return CDRF_DODEFAULT; + } + + DWORD OnItemPostErase(int /*idCtrl*/, LPNMCUSTOMDRAW /*lpNMCustomDraw*/) + { + return CDRF_DODEFAULT; + } + + DWORD OnSubItemPrePaint(int /*idCtrl*/, LPNMCUSTOMDRAW /*lpNMCustomDraw*/) + { + return CDRF_DODEFAULT; + } +}; + +} // namespace WTL + +#endif // __ATLCTRLS_H__ diff -r e9bb126753e7 -r 20d02a178406 foosdk/wtl/Include/atlctrlw.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/wtl/Include/atlctrlw.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,4007 @@ +// Windows Template Library - WTL version 10.0 +// Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. +// +// This file is a part of the Windows Template Library. +// The use and distribution terms for this software are covered by the +// Microsoft Public License (http://opensource.org/licenses/MS-PL) +// which can be found in the file MS-PL.txt at the root folder. + +#ifndef __ATLCTRLW_H__ +#define __ATLCTRLW_H__ + +#pragma once + +#ifndef __ATLAPP_H__ + #error atlctrlw.h requires atlapp.h to be included first +#endif + +#ifndef __ATLCTRLS_H__ + #error atlctrlw.h requires atlctrls.h to be included first +#endif + +// Define _WTL_CMDBAR_VISTA_MENUS as 0 to exclude Vista menus support +#ifndef _WTL_CMDBAR_VISTA_MENUS + #define _WTL_CMDBAR_VISTA_MENUS 1 +#endif + +// Note: Define _WTL_CMDBAR_VISTA_STD_MENUBAR to use Vista standard menubar look with Vista menus + + +/////////////////////////////////////////////////////////////////////////////// +// Classes in this file: +// +// CCommandBarCtrlImpl +// CCommandBarCtrl +// CMDICommandBarCtrlImpl +// CMDICommandBarCtrl + + +namespace WTL +{ + +/////////////////////////////////////////////////////////////////////////////// +// Command Bars + +// Window Styles: +#define CBRWS_TOP CCS_TOP +#define CBRWS_BOTTOM CCS_BOTTOM +#define CBRWS_NORESIZE CCS_NORESIZE +#define CBRWS_NOPARENTALIGN CCS_NOPARENTALIGN +#define CBRWS_NODIVIDER CCS_NODIVIDER + +// Extended styles +#define CBR_EX_TRANSPARENT 0x00000001L +#define CBR_EX_SHAREMENU 0x00000002L +#define CBR_EX_ALTFOCUSMODE 0x00000004L +#define CBR_EX_TRACKALWAYS 0x00000008L +#define CBR_EX_NOVISTAMENUS 0x00000010L + +// standard command bar styles +#define ATL_SIMPLE_CMDBAR_PANE_STYLE \ + (WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | CBRWS_NODIVIDER | CBRWS_NORESIZE | CBRWS_NOPARENTALIGN) + +// Messages - support chevrons for frame windows +#define CBRM_GETCMDBAR (WM_USER + 301) // returns command bar HWND +#define CBRM_GETMENU (WM_USER + 302) // returns loaded or attached menu +#define CBRM_TRACKPOPUPMENU (WM_USER + 303) // displays a popup menu + +typedef struct tagCBRPOPUPMENU +{ + int cbSize; + HMENU hMenu; // popup menu do display + UINT uFlags; // TPM_* flags for ::TrackPopupMenuEx + int x; + int y; + LPTPMPARAMS lptpm; // ptr to TPMPARAMS for ::TrackPopupMenuEx +} CBRPOPUPMENU, *LPCBRPOPUPMENU; + +// helper class +template +class CSimpleStack : public ATL::CSimpleArray< T > +{ +public: + BOOL Push(T t) + { +#ifdef _CMDBAR_EXTRA_TRACE + ATLTRACE2(atlTraceUI, 0, _T("CmdBar - STACK-PUSH (%8.8X) size = %i\n"), t, GetSize()); +#endif + return this->Add(t); + } + + T Pop() + { + int nLast = this->GetSize() - 1; + if(nLast < 0) + return NULL; // must be able to convert to NULL + T t = this->m_aT[nLast]; +#ifdef _CMDBAR_EXTRA_TRACE + ATLTRACE2(atlTraceUI, 0, _T("CmdBar - STACK-POP (%8.8X) size = %i\n"), t, GetSize()); +#endif + if(!this->RemoveAt(nLast)) + return NULL; + return t; + } + + T GetCurrent() + { + int nLast = this->GetSize() - 1; + if(nLast < 0) + return NULL; // must be able to convert to NULL + return this->m_aT[nLast]; + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CCommandBarCtrlBase - base class for the Command Bar implementation + +class CCommandBarCtrlBase : public CToolBarCtrl +{ +public: + struct _MsgHookData + { + HHOOK hMsgHook; + DWORD dwUsage; + + _MsgHookData() : hMsgHook(NULL), dwUsage(0) + { } + }; + + typedef ATL::CSimpleMap CMsgHookMap; + static CMsgHookMap* s_pmapMsgHook; + + static HHOOK s_hCreateHook; + static CCommandBarCtrlBase* s_pCurrentBar; + static bool s_bStaticInit; + + CSimpleStack m_stackMenuWnd; + CSimpleStack m_stackMenuHandle; + + HWND m_hWndHook; + DWORD m_dwMagic; + + + CCommandBarCtrlBase() : m_hWndHook(NULL), m_dwMagic(1314) + { + // init static variables + if(!s_bStaticInit) + { + CStaticDataInitCriticalSectionLock lock; + if(FAILED(lock.Lock())) + { + ATLTRACE2(atlTraceUI, 0, _T("ERROR : Unable to lock critical section in CCommandBarCtrlBase::CCommandBarCtrlBase.\n")); + ATLASSERT(FALSE); + return; + } + + if(!s_bStaticInit) + { + // Just in case... + AtlInitCommonControls(ICC_COOL_CLASSES | ICC_BAR_CLASSES); + // done + s_bStaticInit = true; + } + + lock.Unlock(); + } + } + + bool IsCommandBarBase() const { return m_dwMagic == 1314; } +}; + +__declspec(selectany) CCommandBarCtrlBase::CMsgHookMap* CCommandBarCtrlBase::s_pmapMsgHook = NULL; +__declspec(selectany) HHOOK CCommandBarCtrlBase::s_hCreateHook = NULL; +__declspec(selectany) CCommandBarCtrlBase* CCommandBarCtrlBase::s_pCurrentBar = NULL; +__declspec(selectany) bool CCommandBarCtrlBase::s_bStaticInit = false; + + +/////////////////////////////////////////////////////////////////////////////// +// CCommandBarCtrl - ATL implementation of Command Bars + +template +class ATL_NO_VTABLE CCommandBarCtrlImpl : public ATL::CWindowImpl< T, TBase, TWinTraits > +{ +public: + DECLARE_WND_SUPERCLASS2(NULL, T, TBase::GetWndClassName()) + +// Declarations + struct _MenuItemData // menu item data + { + DWORD dwMagic; + LPTSTR lpstrText; + UINT fType; + UINT fState; + int iButton; + + _MenuItemData() : dwMagic(0x1313), lpstrText(NULL), fType(0U), fState(0U), iButton(0) + { } + + bool IsCmdBarMenuItem() { return (dwMagic == 0x1313); } + }; + + struct _ToolBarData // toolbar resource data + { + WORD wVersion; + WORD wWidth; + WORD wHeight; + WORD wItemCount; + //WORD aItems[wItemCount] + + WORD* items() + { return (WORD*)(this+1); } + }; + +// Constants + enum _CmdBarDrawConstants + { + s_kcxGap = 1, + s_kcxTextMargin = 2, + s_kcxButtonMargin = 3, + s_kcyButtonMargin = 3 + }; + + enum + { + _nMaxMenuItemTextLength = 100, + _chChevronShortcut = _T('/') + }; + +#ifndef DT_HIDEPREFIX + enum { DT_HIDEPREFIX = 0x00100000 }; +#endif // !DT_HIDEPREFIX + +// Data members + HMENU m_hMenu; + HIMAGELIST m_hImageList; + ATL::CSimpleValArray m_arrCommand; + + DWORD m_dwExtendedStyle; // Command Bar specific extended styles + + ATL::CContainedWindow m_wndParent; + + bool m_bMenuActive:1; + bool m_bAttachedMenu:1; + bool m_bImagesVisible:1; + bool m_bPopupItem:1; + bool m_bContextMenu:1; + bool m_bEscapePressed:1; + bool m_bSkipMsg:1; + bool m_bParentActive:1; + bool m_bFlatMenus:1; + bool m_bUseKeyboardCues:1; + bool m_bShowKeyboardCues:1; + bool m_bAllowKeyboardCues:1; + bool m_bKeyboardInput:1; + bool m_bAlphaImages:1; + bool m_bLayoutRTL:1; + bool m_bSkipPostDown:1; + bool m_bVistaMenus:1; + + int m_nPopBtn; + int m_nNextPopBtn; + + SIZE m_szBitmap; + SIZE m_szButton; + + COLORREF m_clrMask; + CFont m_fontMenu; // used internally, only to measure text + + UINT m_uSysKey; + + HWND m_hWndFocus; // Alternate focus mode + + int m_cxExtraSpacing; + +#if _WTL_CMDBAR_VISTA_MENUS + ATL::CSimpleValArray m_arrVistaBitmap; // Bitmaps for Vista menus +#endif // _WTL_CMDBAR_VISTA_MENUS + +// Constructor/destructor + CCommandBarCtrlImpl() : + m_hMenu(NULL), + m_hImageList(NULL), + m_dwExtendedStyle(CBR_EX_TRANSPARENT | CBR_EX_SHAREMENU | CBR_EX_TRACKALWAYS), + m_wndParent(this, 1), + m_bMenuActive(false), + m_bAttachedMenu(false), + m_bImagesVisible(true), + m_bPopupItem(false), + m_bContextMenu(false), + m_bEscapePressed(false), + m_bSkipMsg(false), + m_bParentActive(true), + m_bFlatMenus(false), + m_bUseKeyboardCues(false), + m_bShowKeyboardCues(false), + m_bAllowKeyboardCues(true), + m_bKeyboardInput(false), + m_bAlphaImages(false), + m_bLayoutRTL(false), + m_bSkipPostDown(false), + m_bVistaMenus(false), + m_nPopBtn(-1), + m_nNextPopBtn(-1), + m_clrMask(RGB(192, 192, 192)), + m_uSysKey(0), + m_hWndFocus(NULL), + m_cxExtraSpacing(0) + { + SetImageSize(16, 15); // default + } + + ~CCommandBarCtrlImpl() + { + if(m_wndParent.IsWindow()) +/*scary!*/ m_wndParent.UnsubclassWindow(); + + if((m_hMenu != NULL) && ((m_dwExtendedStyle & CBR_EX_SHAREMENU) == 0)) + ::DestroyMenu(m_hMenu); + + if(m_hImageList != NULL) + ::ImageList_Destroy(m_hImageList); + } + +// Attributes + DWORD GetCommandBarExtendedStyle() const + { + return m_dwExtendedStyle; + } + + DWORD SetCommandBarExtendedStyle(DWORD dwExtendedStyle, DWORD dwMask = 0) + { + DWORD dwPrevStyle = m_dwExtendedStyle; + if(dwMask == 0) + m_dwExtendedStyle = dwExtendedStyle; + else + m_dwExtendedStyle = (m_dwExtendedStyle & ~dwMask) | (dwExtendedStyle & dwMask); + return dwPrevStyle; + } + + CMenuHandle GetMenu() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return m_hMenu; + } + + COLORREF GetImageMaskColor() const + { + return m_clrMask; + } + + COLORREF SetImageMaskColor(COLORREF clrMask) + { + COLORREF clrOld = m_clrMask; + m_clrMask = clrMask; + return clrOld; + } + + bool GetImagesVisible() const + { + return m_bImagesVisible; + } + + bool SetImagesVisible(bool bVisible) + { + bool bOld = m_bImagesVisible; + m_bImagesVisible = bVisible; + return bOld; + } + + void GetImageSize(SIZE& size) const + { + size = m_szBitmap; + } + + bool SetImageSize(SIZE& size) + { + return SetImageSize(size.cx, size.cy); + } + + bool SetImageSize(int cx, int cy) + { + if(m_hImageList != NULL) + { + if(::ImageList_GetImageCount(m_hImageList) == 0) // empty + { + ::ImageList_Destroy(m_hImageList); + m_hImageList = NULL; + } + else + { + return false; // can't set, image list exists + } + } + + if((cx == 0) || (cy == 0)) + return false; + + m_szBitmap.cx = cx; + m_szBitmap.cy = cy; + m_szButton.cx = m_szBitmap.cx + 2 * s_kcxButtonMargin; + m_szButton.cy = m_szBitmap.cy + 2 * s_kcyButtonMargin; + + return true; + } + + bool GetAlphaImages() const + { + return m_bAlphaImages; + } + + bool SetAlphaImages(bool bAlphaImages) + { + if(m_hImageList != NULL) + { + if(::ImageList_GetImageCount(m_hImageList) == 0) // empty + { + ::ImageList_Destroy(m_hImageList); + m_hImageList = NULL; + } + else + { + return false; // can't set, image list exists + } + } + + m_bAlphaImages = bAlphaImages; + return true; + } + + HWND GetCmdBar() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return (HWND)::SendMessage(this->m_hWnd, CBRM_GETCMDBAR, 0, 0L); + } + +// Methods + HWND Create(HWND hWndParent, RECT& rcPos, LPCTSTR szWindowName = NULL, + DWORD dwStyle = 0, DWORD dwExStyle = 0, + UINT nID = 0, LPVOID lpCreateParam = NULL) + { + // These styles are required for command bars + dwStyle |= TBSTYLE_LIST | TBSTYLE_FLAT; + return ATL::CWindowImpl< T, TBase, TWinTraits >::Create(hWndParent, rcPos, szWindowName, dwStyle, dwExStyle, nID, lpCreateParam); + } + + BOOL AttachToWindow(HWND hWnd) + { + ATLASSERT(this->m_hWnd == NULL); + ATLASSERT(::IsWindow(hWnd)); + BOOL bRet = this->SubclassWindow(hWnd); + if(bRet) + { + m_bAttachedMenu = true; + T* pT = static_cast(this); + pT->GetSystemSettings(); + } + return bRet; + } + + BOOL LoadMenu(ATL::_U_STRINGorID menu) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + + if(m_bAttachedMenu) // doesn't work in this mode + return FALSE; + if(menu.m_lpstr == NULL) + return FALSE; + + HMENU hMenu = ::LoadMenu(ModuleHelper::GetResourceInstance(), menu.m_lpstr); + if(hMenu == NULL) + return FALSE; + + return AttachMenu(hMenu); + } + + BOOL AttachMenu(HMENU hMenu) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((hMenu == NULL) || ::IsMenu(hMenu)); + if((hMenu != NULL) && !::IsMenu(hMenu)) + return FALSE; + +#if _WTL_CMDBAR_VISTA_MENUS + // remove Vista bitmaps if used + if(m_bVistaMenus && (m_hMenu != NULL)) + { + T* pT = static_cast(this); + pT->_RemoveVistaBitmapsFromMenu(); + } +#endif // _WTL_CMDBAR_VISTA_MENUS + + // destroy old menu, if needed, and set new one + if((m_hMenu != NULL) && ((m_dwExtendedStyle & CBR_EX_SHAREMENU) == 0)) + ::DestroyMenu(m_hMenu); + + m_hMenu = hMenu; + + if(m_bAttachedMenu) // Nothing else in this mode + return TRUE; + + // Build buttons according to menu + this->SetRedraw(FALSE); + + // Clear all buttons + int nCount = this->GetButtonCount(); + for(int i = 0; i < nCount; i++) + ATLVERIFY(this->DeleteButton(0) != FALSE); + + // Add buttons for each menu item + if(m_hMenu != NULL) + { + int nItems = ::GetMenuItemCount(m_hMenu); + + T* pT = static_cast(this); + (void)pT; // avoid level 4 warning + TCHAR szString[pT->_nMaxMenuItemTextLength] = {}; + for(int i = 0; i < nItems; i++) + { + CMenuItemInfo mii; + mii.fMask = MIIM_TYPE | MIIM_STATE | MIIM_SUBMENU; + mii.fType = MFT_STRING; + mii.dwTypeData = szString; + mii.cch = pT->_nMaxMenuItemTextLength; + BOOL bRet = ::GetMenuItemInfo(m_hMenu, i, TRUE, &mii); + ATLASSERT(bRet); + // If we have more than the buffer, we assume we have bitmaps bits + if(lstrlen(szString) > pT->_nMaxMenuItemTextLength - 1) + { + mii.fType = MFT_BITMAP; + ::SetMenuItemInfo(m_hMenu, i, TRUE, &mii); + szString[0] = 0; + } + + // NOTE: Command Bar currently supports only drop-down menu items + ATLASSERT(mii.hSubMenu != NULL); + + TBBUTTON btn = {}; + btn.iBitmap = 0; + btn.idCommand = i; + btn.fsState = (BYTE)(((mii.fState & MFS_DISABLED) == 0) ? TBSTATE_ENABLED : 0); + btn.fsStyle = BTNS_BUTTON | BTNS_AUTOSIZE | BTNS_DROPDOWN; + btn.dwData = 0; + btn.iString = 0; + + bRet = this->InsertButton(-1, &btn); + ATLASSERT(bRet); + + TBBUTTONINFO bi = {}; + bi.cbSize = sizeof(TBBUTTONINFO); + bi.dwMask = TBIF_TEXT; + bi.pszText = szString; + + bRet = this->SetButtonInfo(i, &bi); + ATLASSERT(bRet); + } + } + + this->SetRedraw(TRUE); + this->Invalidate(); + this->UpdateWindow(); + + return TRUE; + } + + BOOL LoadImages(ATL::_U_STRINGorID image) + { + return _LoadImagesHelper(image, false); + } + + BOOL LoadMappedImages(UINT nIDImage, UINT nFlags = 0, LPCOLORMAP lpColorMap = NULL, int nMapSize = 0) + { + return _LoadImagesHelper(nIDImage, true, nFlags , lpColorMap, nMapSize); + } + + BOOL _LoadImagesHelper(ATL::_U_STRINGorID image, bool bMapped, UINT nFlags = 0, LPCOLORMAP lpColorMap = NULL, int nMapSize = 0) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + HINSTANCE hInstance = ModuleHelper::GetResourceInstance(); + + HRSRC hRsrc = ::FindResource(hInstance, image.m_lpstr, (LPTSTR)RT_TOOLBAR); + if(hRsrc == NULL) + return FALSE; + + HGLOBAL hGlobal = ::LoadResource(hInstance, hRsrc); + if(hGlobal == NULL) + return FALSE; + + _ToolBarData* pData = (_ToolBarData*)::LockResource(hGlobal); + if(pData == NULL) + return FALSE; + ATLASSERT(pData->wVersion == 1); + + WORD* pItems = pData->items(); + int nItems = pData->wItemCount; + + // Set internal data + SetImageSize(pData->wWidth, pData->wHeight); + + // Create image list if needed + if(m_hImageList == NULL) + { + // Check if the bitmap is 32-bit (alpha channel) bitmap (valid for Windows XP only) + T* pT = static_cast(this); + m_bAlphaImages = AtlIsAlphaBitmapResource(image); + + if(!pT->CreateInternalImageList(pData->wItemCount)) + return FALSE; + } + +#if _WTL_CMDBAR_VISTA_MENUS + int nOldImageCount = ::ImageList_GetImageCount(m_hImageList); +#endif // _WTL_CMDBAR_VISTA_MENUS + + // Add bitmap to our image list + CBitmap bmp; + if(bMapped) + { + ATLASSERT(HIWORD(PtrToUlong(image.m_lpstr)) == 0); // if mapped, must be a numeric ID + int nIDImage = (int)(short)LOWORD(PtrToUlong(image.m_lpstr)); + bmp.LoadMappedBitmap(nIDImage, (WORD)nFlags, lpColorMap, nMapSize); + } + else + { + if(m_bAlphaImages) + bmp = (HBITMAP)::LoadImage(ModuleHelper::GetResourceInstance(), image.m_lpstr, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_DEFAULTSIZE); + else + bmp.LoadBitmap(image.m_lpstr); + } + ATLASSERT(bmp.m_hBitmap != NULL); + if(bmp.m_hBitmap == NULL) + return FALSE; + if(::ImageList_AddMasked(m_hImageList, bmp, m_clrMask) == -1) + return FALSE; + + // Fill the array with command IDs + for(int i = 0; i < nItems; i++) + { + if(pItems[i] != 0) + m_arrCommand.Add(pItems[i]); + } + + int nImageCount = ::ImageList_GetImageCount(m_hImageList); + ATLASSERT(nImageCount == m_arrCommand.GetSize()); + if(nImageCount != m_arrCommand.GetSize()) + return FALSE; + +#if _WTL_CMDBAR_VISTA_MENUS + if(RunTimeHelper::IsVista()) + { + T* pT = static_cast(this); + pT->_AddVistaBitmapsFromImageList(nOldImageCount, nImageCount - nOldImageCount); + ATLASSERT(nImageCount == m_arrVistaBitmap.GetSize()); + } +#endif // _WTL_CMDBAR_VISTA_MENUS + + return TRUE; + } + + BOOL AddBitmap(ATL::_U_STRINGorID bitmap, int nCommandID) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + CBitmap bmp; + bmp.LoadBitmap(bitmap.m_lpstr); + if(bmp.m_hBitmap == NULL) + return FALSE; + return AddBitmap(bmp, nCommandID); + } + + BOOL AddBitmap(HBITMAP hBitmap, UINT nCommandID) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + T* pT = static_cast(this); + // Create image list if it doesn't exist + if(m_hImageList == NULL) + { + if(!pT->CreateInternalImageList(1)) + return FALSE; + } + // check bitmap size + CBitmapHandle bmp = hBitmap; + SIZE size = {}; + bmp.GetSize(size); + if((size.cx != m_szBitmap.cx) || (size.cy != m_szBitmap.cy)) + { + ATLASSERT(FALSE); // must match size! + return FALSE; + } + // add bitmap + int nRet = ::ImageList_AddMasked(m_hImageList, hBitmap, m_clrMask); + if(nRet == -1) + return FALSE; + BOOL bRet = m_arrCommand.Add((WORD)nCommandID); + ATLASSERT(::ImageList_GetImageCount(m_hImageList) == m_arrCommand.GetSize()); +#if _WTL_CMDBAR_VISTA_MENUS + if(RunTimeHelper::IsVista()) + { + pT->_AddVistaBitmapFromImageList(m_arrCommand.GetSize() - 1); + ATLASSERT(m_arrVistaBitmap.GetSize() == m_arrCommand.GetSize()); + } +#endif // _WTL_CMDBAR_VISTA_MENUS + return bRet; + } + + BOOL AddIcon(ATL::_U_STRINGorID icon, UINT nCommandID) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + HICON hIcon = ::LoadIcon(ModuleHelper::GetResourceInstance(), icon.m_lpstr); + if(hIcon == NULL) + return FALSE; + return AddIcon(hIcon, nCommandID); + } + + BOOL AddIcon(HICON hIcon, UINT nCommandID) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + T* pT = static_cast(this); + // create image list if it doesn't exist + if(m_hImageList == NULL) + { + if(!pT->CreateInternalImageList(1)) + return FALSE; + } + + int nRet = ::ImageList_AddIcon(m_hImageList, hIcon); + if(nRet == -1) + return FALSE; + BOOL bRet = m_arrCommand.Add((WORD)nCommandID); + ATLASSERT(::ImageList_GetImageCount(m_hImageList) == m_arrCommand.GetSize()); +#if _WTL_CMDBAR_VISTA_MENUS + if(RunTimeHelper::IsVista()) + { + pT->_AddVistaBitmapFromImageList(m_arrCommand.GetSize() - 1); + ATLASSERT(m_arrVistaBitmap.GetSize() == m_arrCommand.GetSize()); + } +#endif // _WTL_CMDBAR_VISTA_MENUS + return bRet; + } + + BOOL ReplaceBitmap(ATL::_U_STRINGorID bitmap, int nCommandID) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + CBitmap bmp; + bmp.LoadBitmap(bitmap.m_lpstr); + if(bmp.m_hBitmap == NULL) + return FALSE; + return ReplaceBitmap(bmp, nCommandID); + } + + BOOL ReplaceBitmap(HBITMAP hBitmap, UINT nCommandID) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + BOOL bRet = FALSE; + for(int i = 0; i < m_arrCommand.GetSize(); i++) + { + if(m_arrCommand[i] == nCommandID) + { + bRet = ::ImageList_Remove(m_hImageList, i); + if(bRet) + { + m_arrCommand.RemoveAt(i); +#if _WTL_CMDBAR_VISTA_MENUS + if(RunTimeHelper::IsVista()) + { + if(m_arrVistaBitmap[i] != NULL) + ::DeleteObject(m_arrVistaBitmap[i]); + m_arrVistaBitmap.RemoveAt(i); + } +#endif // _WTL_CMDBAR_VISTA_MENUS + } + break; + } + } + if(bRet) + bRet = AddBitmap(hBitmap, nCommandID); + return bRet; + } + + BOOL ReplaceIcon(ATL::_U_STRINGorID icon, UINT nCommandID) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + HICON hIcon = ::LoadIcon(ModuleHelper::GetResourceInstance(), icon.m_lpstr); + if(hIcon == NULL) + return FALSE; + return ReplaceIcon(hIcon, nCommandID); + } + + BOOL ReplaceIcon(HICON hIcon, UINT nCommandID) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + BOOL bRet = FALSE; + for(int i = 0; i < m_arrCommand.GetSize(); i++) + { + if(m_arrCommand[i] == nCommandID) + { + bRet = (::ImageList_ReplaceIcon(m_hImageList, i, hIcon) != -1); +#if _WTL_CMDBAR_VISTA_MENUS + if(RunTimeHelper::IsVista() && (bRet != FALSE)) + { + T* pT = static_cast(this); + pT->_ReplaceVistaBitmapFromImageList(i); + } +#endif // _WTL_CMDBAR_VISTA_MENUS + break; + } + } + return bRet; + } + + BOOL RemoveImage(int nCommandID) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + + BOOL bRet = FALSE; + for(int i = 0; i < m_arrCommand.GetSize(); i++) + { + if(m_arrCommand[i] == nCommandID) + { + bRet = ::ImageList_Remove(m_hImageList, i); + if(bRet) + { + m_arrCommand.RemoveAt(i); +#if _WTL_CMDBAR_VISTA_MENUS + if(RunTimeHelper::IsVista()) + { + if(m_arrVistaBitmap[i] != NULL) + ::DeleteObject(m_arrVistaBitmap[i]); + m_arrVistaBitmap.RemoveAt(i); + } +#endif // _WTL_CMDBAR_VISTA_MENUS + } + break; + } + } + return bRet; + } + + BOOL RemoveAllImages() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + + ATLTRACE2(atlTraceUI, 0, _T("CmdBar - Removing all images\n")); + BOOL bRet = ::ImageList_RemoveAll(m_hImageList); + if(bRet) + { + m_arrCommand.RemoveAll(); +#if _WTL_CMDBAR_VISTA_MENUS + for(int i = 0; i < m_arrVistaBitmap.GetSize(); i++) + { + if(m_arrVistaBitmap[i] != NULL) + ::DeleteObject(m_arrVistaBitmap[i]); + } + m_arrVistaBitmap.RemoveAll(); +#endif // _WTL_CMDBAR_VISTA_MENUS + } + return bRet; + } + + BOOL TrackPopupMenu(HMENU hMenu, UINT uFlags, int x, int y, LPTPMPARAMS lpParams = NULL) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(::IsMenu(hMenu)); + if(!::IsMenu(hMenu)) + return FALSE; + m_bContextMenu = true; + if(m_bUseKeyboardCues) + m_bShowKeyboardCues = m_bKeyboardInput; + T* pT = static_cast(this); + return pT->DoTrackPopupMenu(hMenu, uFlags, x, y, lpParams); + } + + BOOL SetMDIClient(HWND /*hWndMDIClient*/) + { + // Use CMDICommandBarCtrl for MDI support + ATLASSERT(FALSE); + return FALSE; + } + +// Message map and handlers + BEGIN_MSG_MAP(CCommandBarCtrlImpl) + MESSAGE_HANDLER(WM_CREATE, OnCreate) + MESSAGE_HANDLER(WM_DESTROY, OnDestroy) + MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground) + MESSAGE_HANDLER(WM_INITMENU, OnInitMenu) + MESSAGE_HANDLER(WM_INITMENUPOPUP, OnInitMenuPopup) + MESSAGE_HANDLER(WM_MENUSELECT, OnMenuSelect) + MESSAGE_HANDLER(GetAutoPopupMessage(), OnInternalAutoPopup) + MESSAGE_HANDLER(GetGetBarMessage(), OnInternalGetBar) + MESSAGE_HANDLER(WM_SETTINGCHANGE, OnSettingChange) + MESSAGE_HANDLER(WM_MENUCHAR, OnMenuChar) + MESSAGE_HANDLER(WM_KILLFOCUS, OnKillFocus) + + MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown) + MESSAGE_HANDLER(WM_KEYUP, OnKeyUp) + MESSAGE_HANDLER(WM_CHAR, OnChar) + MESSAGE_HANDLER(WM_SYSKEYDOWN, OnSysKeyDown) + MESSAGE_HANDLER(WM_SYSKEYUP, OnSysKeyUp) + MESSAGE_HANDLER(WM_SYSCHAR, OnSysChar) +// public API handlers - these stay to support chevrons in atlframe.h + MESSAGE_HANDLER(CBRM_GETMENU, OnAPIGetMenu) + MESSAGE_HANDLER(CBRM_TRACKPOPUPMENU, OnAPITrackPopupMenu) + MESSAGE_HANDLER(CBRM_GETCMDBAR, OnAPIGetCmdBar) + + MESSAGE_HANDLER(WM_DRAWITEM, OnDrawItem) + MESSAGE_HANDLER(WM_MEASUREITEM, OnMeasureItem) + + MESSAGE_HANDLER(WM_FORWARDMSG, OnForwardMsg) + ALT_MSG_MAP(1) // Parent window messages + NOTIFY_CODE_HANDLER(TBN_HOTITEMCHANGE, OnParentHotItemChange) + NOTIFY_CODE_HANDLER(TBN_DROPDOWN, OnParentDropDown) + MESSAGE_HANDLER(WM_INITMENUPOPUP, OnParentInitMenuPopup) + MESSAGE_HANDLER(GetGetBarMessage(), OnParentInternalGetBar) + MESSAGE_HANDLER(WM_SYSCOMMAND, OnParentSysCommand) + MESSAGE_HANDLER(CBRM_GETMENU, OnParentAPIGetMenu) + MESSAGE_HANDLER(WM_MENUCHAR, OnParentMenuChar) + MESSAGE_HANDLER(CBRM_TRACKPOPUPMENU, OnParentAPITrackPopupMenu) + MESSAGE_HANDLER(CBRM_GETCMDBAR, OnParentAPIGetCmdBar) + MESSAGE_HANDLER(WM_SETTINGCHANGE, OnParentSettingChange) + + MESSAGE_HANDLER(WM_DRAWITEM, OnParentDrawItem) + MESSAGE_HANDLER(WM_MEASUREITEM, OnParentMeasureItem) + + MESSAGE_HANDLER(WM_ACTIVATE, OnParentActivate) + NOTIFY_CODE_HANDLER(NM_CUSTOMDRAW, OnParentCustomDraw) + ALT_MSG_MAP(2) // MDI client window messages + // Use CMDICommandBarCtrl for MDI support + ALT_MSG_MAP(3) // Message hook messages + MESSAGE_HANDLER(WM_MOUSEMOVE, OnHookMouseMove) + MESSAGE_HANDLER(WM_SYSKEYDOWN, OnHookSysKeyDown) + MESSAGE_HANDLER(WM_SYSKEYUP, OnHookSysKeyUp) + MESSAGE_HANDLER(WM_SYSCHAR, OnHookSysChar) + MESSAGE_HANDLER(WM_KEYDOWN, OnHookKeyDown) + MESSAGE_HANDLER(WM_NEXTMENU, OnHookNextMenu) + MESSAGE_HANDLER(WM_CHAR, OnHookChar) + END_MSG_MAP() + + LRESULT OnForwardMsg(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/) + { + LPMSG pMsg = (LPMSG)lParam; + if((pMsg->message >= WM_MOUSEFIRST) && (pMsg->message <= WM_MOUSELAST)) + m_bKeyboardInput = false; + else if((pMsg->message >= WM_KEYFIRST) && (pMsg->message <= WM_KEYLAST)) + m_bKeyboardInput = true; + LRESULT lRet = 0; + ProcessWindowMessage(pMsg->hwnd, pMsg->message, pMsg->wParam, pMsg->lParam, lRet, 3); + return lRet; + } + + LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) + { + // Let the toolbar initialize itself + LRESULT lRet = this->DefWindowProc(uMsg, wParam, lParam); + // get and use system settings + T* pT = static_cast(this); + pT->GetSystemSettings(); + // Parent init + ATL::CWindow wndParent = this->GetParent(); + ATL::CWindow wndTopLevelParent = wndParent.GetTopLevelParent(); + m_wndParent.SubclassWindow(wndTopLevelParent); + // Toolbar Init + this->SetButtonStructSize(); + this->SetImageList(NULL); + + // Create message hook if needed + CWindowCreateCriticalSectionLock lock; + if(FAILED(lock.Lock())) + { + ATLTRACE2(atlTraceUI, 0, _T("ERROR : Unable to lock critical section in CCommandBarCtrlImpl::OnCreate.\n")); + ATLASSERT(FALSE); + return -1; + } + + if(this->s_pmapMsgHook == NULL) + { + ATLTRY(this->s_pmapMsgHook = new CCommandBarCtrlBase::CMsgHookMap); + ATLASSERT(this->s_pmapMsgHook != NULL); + } + + if(this->s_pmapMsgHook != NULL) + { + DWORD dwThreadID = ::GetCurrentThreadId(); + CCommandBarCtrlBase::_MsgHookData* pData = this->s_pmapMsgHook->Lookup(dwThreadID); + if(pData == NULL) + { + ATLTRY(pData = new CCommandBarCtrlBase::_MsgHookData); + ATLASSERT(pData != NULL); + HHOOK hMsgHook = ::SetWindowsHookEx(WH_GETMESSAGE, MessageHookProc, ModuleHelper::GetModuleInstance(), dwThreadID); + ATLASSERT(hMsgHook != NULL); + if((pData != NULL) && (hMsgHook != NULL)) + { + pData->hMsgHook = hMsgHook; + pData->dwUsage = 1; + BOOL bRet = this->s_pmapMsgHook->Add(dwThreadID, pData); + (void)bRet; // avoid level 4 warning + ATLASSERT(bRet); + } + } + else + { + (pData->dwUsage)++; + } + } + lock.Unlock(); + + // Get layout + m_bLayoutRTL = ((this->GetExStyle() & WS_EX_LAYOUTRTL) != 0); + + return lRet; + } + + LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) + { + LRESULT lRet = this->DefWindowProc(uMsg, wParam, lParam); + +#if _WTL_CMDBAR_VISTA_MENUS + if(m_bVistaMenus && (m_hMenu != NULL)) + { + T* pT = static_cast(this); + pT->_RemoveVistaBitmapsFromMenu(); + } + + for(int i = 0; i < m_arrVistaBitmap.GetSize(); i++) + { + if(m_arrVistaBitmap[i] != NULL) + ::DeleteObject(m_arrVistaBitmap[i]); + } +#endif // _WTL_CMDBAR_VISTA_MENUS + + if(m_bAttachedMenu) // nothing to do in this mode + return lRet; + + CWindowCreateCriticalSectionLock lock; + if(FAILED(lock.Lock())) + { + ATLTRACE2(atlTraceUI, 0, _T("ERROR : Unable to lock critical section in CCommandBarCtrlImpl::OnDestroy.\n")); + ATLASSERT(FALSE); + return lRet; + } + + if(this->s_pmapMsgHook != NULL) + { + DWORD dwThreadID = ::GetCurrentThreadId(); + CCommandBarCtrlBase::_MsgHookData* pData = this->s_pmapMsgHook->Lookup(dwThreadID); + if(pData != NULL) + { + (pData->dwUsage)--; + if(pData->dwUsage == 0) + { + BOOL bRet = ::UnhookWindowsHookEx(pData->hMsgHook); + ATLASSERT(bRet); + bRet = this->s_pmapMsgHook->Remove(dwThreadID); + ATLASSERT(bRet); + if(bRet) + delete pData; + } + + if(this->s_pmapMsgHook->GetSize() == 0) + { + delete this->s_pmapMsgHook; + this->s_pmapMsgHook = NULL; + } + } + } + + lock.Unlock(); + + return lRet; + } + + LRESULT OnKeyDown(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled) + { +#ifdef _CMDBAR_EXTRA_TRACE + ATLTRACE2(atlTraceUI, 0, _T("CmdBar - OnKeyDown\n")); +#endif + if(m_bAttachedMenu) // nothing to do in this mode + { + bHandled = FALSE; + return 1; + } + + bHandled = FALSE; + // Simulate Alt+Space for the parent + if(wParam == VK_SPACE) + { + m_wndParent.PostMessage(WM_SYSKEYDOWN, wParam, lParam | (1 << 29)); + bHandled = TRUE; + } + else if((wParam == VK_LEFT) || (wParam == VK_RIGHT)) + { + WPARAM wpNext = m_bLayoutRTL ? VK_LEFT : VK_RIGHT; + + if(!m_bMenuActive) + { + T* pT = static_cast(this); + int nBtn = this->GetHotItem(); + int nNextBtn = (wParam == wpNext) ? pT->GetNextMenuItem(nBtn) : pT->GetPreviousMenuItem(nBtn); + if(nNextBtn == -2) + { + this->SetHotItem(-1); + if(pT->DisplayChevronMenu()) + bHandled = TRUE; + } + } + } + return 0; + } + + LRESULT OnKeyUp(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) + { +#ifdef _CMDBAR_EXTRA_TRACE + ATLTRACE2(atlTraceUI, 0, _T("CmdBar - OnKeyUp\n")); +#endif + if(m_bAttachedMenu) // nothing to do in this mode + { + bHandled = FALSE; + return 1; + } + + if(wParam != VK_SPACE) + bHandled = FALSE; + + return 0; + } + + LRESULT OnChar(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) + { +#ifdef _CMDBAR_EXTRA_TRACE + ATLTRACE2(atlTraceUI, 0, _T("CmdBar - OnChar\n")); +#endif + if(m_bAttachedMenu) // nothing to do in this mode + { + bHandled = FALSE; + return 1; + } + + if(wParam != VK_SPACE) + bHandled = FALSE; + else + return 0; + // Security + if(!m_wndParent.IsWindowEnabled() || (::GetFocus() != this->m_hWnd)) + return 0; + + // Handle mnemonic press when we have focus + int nBtn = 0; + if((wParam != VK_RETURN) && !this->MapAccelerator((TCHAR)LOWORD(wParam), nBtn)) + { + if((TCHAR)LOWORD(wParam) != _chChevronShortcut) + ::MessageBeep(0); + } + else + { + RECT rcClient = {}; + this->GetClientRect(&rcClient); + RECT rcBtn = {}; + this->GetItemRect(nBtn, &rcBtn); + TBBUTTON tbb = {}; + this->GetButton(nBtn, &tbb); + if(((tbb.fsState & TBSTATE_ENABLED) != 0) && ((tbb.fsState & TBSTATE_HIDDEN) == 0) && (rcBtn.right <= rcClient.right)) + { + this->PostMessage(WM_KEYDOWN, VK_DOWN, 0L); + if(wParam != VK_RETURN) + this->SetHotItem(nBtn); + } + else + { + ::MessageBeep(0); + bHandled = TRUE; + } + } + return 0; + } + + LRESULT OnSysKeyDown(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) + { +#ifdef _CMDBAR_EXTRA_TRACE + ATLTRACE2(atlTraceUI, 0, _T("CmdBar - OnSysKeyDown\n")); +#endif + bHandled = FALSE; + return 0; + } + + LRESULT OnSysKeyUp(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) + { +#ifdef _CMDBAR_EXTRA_TRACE + ATLTRACE2(atlTraceUI, 0, _T("CmdBar - OnSysKeyUp\n")); +#endif + bHandled = FALSE; + return 0; + } + + LRESULT OnSysChar(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) + { +#ifdef _CMDBAR_EXTRA_TRACE + ATLTRACE2(atlTraceUI, 0, _T("CmdBar - OnSysChar\n")); +#endif + bHandled = FALSE; + return 0; + } + + LRESULT OnEraseBackground(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) + { + if(m_bAttachedMenu || (m_dwExtendedStyle & CBR_EX_TRANSPARENT)) + { + bHandled = FALSE; + return 0; + } + + CDCHandle dc = (HDC)wParam; + RECT rect = {}; + this->GetClientRect(&rect); + dc.FillRect(&rect, COLOR_MENU); + + return 1; // don't do the default erase + } + + LRESULT OnInitMenu(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) + { + int nIndex = this->GetHotItem(); + this->SendMessage(WM_MENUSELECT, MAKEWPARAM(nIndex, MF_POPUP|MF_HILITE), (LPARAM)m_hMenu); + bHandled = FALSE; + return 1; + } + + LRESULT OnInitMenuPopup(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) + { + if((BOOL)HIWORD(lParam)) // System menu, do nothing + { + bHandled = FALSE; + return 1; + } + + if(!(m_bAttachedMenu || m_bMenuActive)) // Not attached or ours, do nothing + { + bHandled = FALSE; + return 1; + } + +#ifdef _CMDBAR_EXTRA_TRACE + ATLTRACE2(atlTraceUI, 0, _T("CmdBar - OnInitMenuPopup\n")); +#endif + // forward to the parent or subclassed window, so it can handle update UI + LRESULT lRet = 0; + if(m_bAttachedMenu) + lRet = this->DefWindowProc(uMsg, wParam, (lParam || m_bContextMenu) ? lParam : this->GetHotItem()); + else + lRet = m_wndParent.DefWindowProc(uMsg, wParam, (lParam || m_bContextMenu) ? lParam : this->GetHotItem()); + +#if _WTL_CMDBAR_VISTA_MENUS + // If Vista menus are active, just set bitmaps and return + if(m_bVistaMenus) + { + CMenuHandle menu = (HMENU)wParam; + ATLASSERT(menu.m_hMenu != NULL); + + for(int i = 0; i < menu.GetMenuItemCount(); i++) + { + WORD nID = (WORD)menu.GetMenuItemID(i); + int nIndex = m_arrCommand.Find(nID); + + CMenuItemInfo mii; + mii.fMask = MIIM_BITMAP; + mii.hbmpItem = (m_bImagesVisible && (nIndex != -1)) ? m_arrVistaBitmap[nIndex] : NULL; + menu.SetMenuItemInfo(i, TRUE, &mii); + } + + return lRet; + } +#endif // _WTL_CMDBAR_VISTA_MENUS + + // Convert menu items to ownerdraw, add our data + if(m_bImagesVisible) + { + CMenuHandle menuPopup = (HMENU)wParam; + ATLASSERT(menuPopup.m_hMenu != NULL); + + T* pT = static_cast(this); + (void)pT; // avoid level 4 warning + TCHAR szString[pT->_nMaxMenuItemTextLength] = {}; + BOOL bRet = FALSE; + for(int i = 0; i < menuPopup.GetMenuItemCount(); i++) + { + CMenuItemInfo mii; + mii.cch = pT->_nMaxMenuItemTextLength; + mii.fMask = MIIM_CHECKMARKS | MIIM_DATA | MIIM_ID | MIIM_STATE | MIIM_SUBMENU | MIIM_TYPE; + mii.dwTypeData = szString; + bRet = menuPopup.GetMenuItemInfo(i, TRUE, &mii); + ATLASSERT(bRet); + + if(!(mii.fType & MFT_OWNERDRAW)) // Not already an ownerdraw item + { + mii.fMask = MIIM_DATA | MIIM_TYPE | MIIM_STATE; + _MenuItemData* pMI = NULL; + ATLTRY(pMI = new _MenuItemData); + ATLASSERT(pMI != NULL); + if(pMI != NULL) + { + pMI->fType = mii.fType; + pMI->fState = mii.fState; + mii.fType |= MFT_OWNERDRAW; + pMI->iButton = -1; + for(int j = 0; j < m_arrCommand.GetSize(); j++) + { + if(m_arrCommand[j] == mii.wID) + { + pMI->iButton = j; + break; + } + } + int cchLen = lstrlen(szString) + 1; + pMI->lpstrText = NULL; + ATLTRY(pMI->lpstrText = new TCHAR[cchLen]); + ATLASSERT(pMI->lpstrText != NULL); + if(pMI->lpstrText != NULL) + ATL::Checked::tcscpy_s(pMI->lpstrText, cchLen, szString); + mii.dwItemData = (ULONG_PTR)pMI; + bRet = menuPopup.SetMenuItemInfo(i, TRUE, &mii); + ATLASSERT(bRet); + } + } + } + + // Add it to the list + this->m_stackMenuHandle.Push(menuPopup.m_hMenu); + } + + return lRet; + } + + LRESULT OnMenuSelect(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) + { + if(!m_bAttachedMenu) // Not attached, do nothing, forward to parent + { + m_bPopupItem = (lParam != NULL) && ((HMENU)lParam != m_hMenu) && (HIWORD(wParam) & MF_POPUP); + if(m_wndParent.IsWindow()) + m_wndParent.SendMessage(uMsg, wParam, lParam); + bHandled = FALSE; + return 1; + } + + // Check if a menu is closing, do a cleanup + if((HIWORD(wParam) == 0xFFFF) && (lParam == NULL)) // Menu closing + { +#ifdef _CMDBAR_EXTRA_TRACE + ATLTRACE2(atlTraceUI, 0, _T("CmdBar - OnMenuSelect - CLOSING!!!!\n")); +#endif + ATLASSERT(this->m_stackMenuWnd.GetSize() == 0); + // Restore the menu items to the previous state for all menus that were converted + if(m_bImagesVisible) + { + HMENU hMenu = NULL; + while((hMenu = this->m_stackMenuHandle.Pop()) != NULL) + { + CMenuHandle menuPopup = hMenu; + ATLASSERT(menuPopup.m_hMenu != NULL); + // Restore state and delete menu item data + BOOL bRet = FALSE; + for(int i = 0; i < menuPopup.GetMenuItemCount(); i++) + { + CMenuItemInfo mii; + mii.fMask = MIIM_DATA | MIIM_TYPE; + bRet = menuPopup.GetMenuItemInfo(i, TRUE, &mii); + ATLASSERT(bRet); + + _MenuItemData* pMI = (_MenuItemData*)mii.dwItemData; + if(_IsValidMem(pMI) && pMI->IsCmdBarMenuItem()) + { + mii.fMask = MIIM_DATA | MIIM_TYPE | MIIM_STATE; + mii.fType = pMI->fType; + mii.dwTypeData = pMI->lpstrText; + mii.cch = lstrlen(pMI->lpstrText); + mii.dwItemData = NULL; + + bRet = menuPopup.SetMenuItemInfo(i, TRUE, &mii); + ATLASSERT(bRet); + + delete [] pMI->lpstrText; + pMI->dwMagic = 0x6666; + delete pMI; + } + } + } + } + } + + bHandled = FALSE; + return 1; + } + + LRESULT OnInternalAutoPopup(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + int nIndex = (int)wParam; + T* pT = static_cast(this); + pT->DoPopupMenu(nIndex, false); + return 0; + } + + LRESULT OnInternalGetBar(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + // Let's make sure we're not embedded in another process + if((LPVOID)wParam != NULL) + *((DWORD*)wParam) = GetCurrentProcessId(); + if(this->IsWindowVisible()) + return (LRESULT)static_cast(this); + else + return NULL; + } + + LRESULT OnSettingChange(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + if((wParam == SPI_SETNONCLIENTMETRICS) || (wParam == SPI_SETKEYBOARDCUES) || (wParam == SPI_SETFLATMENU)) + { + T* pT = static_cast(this); + pT->GetSystemSettings(); + } + + return 0; + } + + LRESULT OnWindowPosChanging(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) + { + LRESULT lRet = this->DefWindowProc(uMsg, wParam, lParam); + + LPWINDOWPOS lpWP = (LPWINDOWPOS)lParam; + int cyMin = ::GetSystemMetrics(SM_CYMENU); + if(lpWP->cy < cyMin) + lpWP->cy = cyMin; + + return lRet; + } + + LRESULT OnMenuChar(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled) + { +#ifdef _CMDBAR_EXTRA_TRACE + ATLTRACE2(atlTraceUI, 0, _T("CmdBar - OnMenuChar\n")); +#endif + bHandled = TRUE; + T* pT = static_cast(this); + + LRESULT lRet; + if(m_bMenuActive && (LOWORD(wParam) != 0x0D)) + lRet = 0; + else + lRet = MAKELRESULT(1, 1); + + if(m_bMenuActive && (HIWORD(wParam) == MF_POPUP)) + { + // Convert character to lower/uppercase and possibly Unicode, using current keyboard layout + TCHAR ch = (TCHAR)LOWORD(wParam); + CMenuHandle menu = (HMENU)lParam; + int nCount = ::GetMenuItemCount(menu); + int nRetCode = MNC_EXECUTE; + BOOL bRet = FALSE; + TCHAR szString[pT->_nMaxMenuItemTextLength] = {}; + WORD wMnem = 0; + bool bFound = false; + for(int i = 0; i < nCount; i++) + { + CMenuItemInfo mii; + mii.cch = pT->_nMaxMenuItemTextLength; + mii.fMask = MIIM_CHECKMARKS | MIIM_DATA | MIIM_ID | MIIM_STATE | MIIM_SUBMENU | MIIM_TYPE; + mii.dwTypeData = szString; + bRet = menu.GetMenuItemInfo(i, TRUE, &mii); + if(!bRet || (mii.fType & MFT_SEPARATOR)) + continue; + _MenuItemData* pmd = (_MenuItemData*)mii.dwItemData; + if(_IsValidMem(pmd) && pmd->IsCmdBarMenuItem()) + { + LPTSTR p = pmd->lpstrText; + + if(p != NULL) + { + while(*p && (*p != _T('&'))) + p = ::CharNext(p); + if((p != NULL) && *p) + { + DWORD dwP = MAKELONG(*(++p), 0); + DWORD dwC = MAKELONG(ch, 0); + if(::CharLower((LPTSTR)ULongToPtr(dwP)) == ::CharLower((LPTSTR)ULongToPtr(dwC))) + { + if(!bFound) + { + wMnem = (WORD)i; + bFound = true; + } + else + { + nRetCode = MNC_SELECT; + break; + } + } + } + } + } + } + if(bFound) + { + if(nRetCode == MNC_EXECUTE) + { + this->PostMessage(TB_SETHOTITEM, (WPARAM)-1, 0L); + pT->GiveFocusBack(); + } + bHandled = TRUE; + lRet = MAKELRESULT(wMnem, nRetCode); + } + } + else if(!m_bMenuActive) + { + int nBtn = 0; + if(!this->MapAccelerator((TCHAR)LOWORD(wParam), nBtn)) + { + bHandled = FALSE; + this->PostMessage(TB_SETHOTITEM, (WPARAM)-1, 0L); + pT->GiveFocusBack(); + + // check if we should display chevron menu + if((TCHAR)LOWORD(wParam) == pT->_chChevronShortcut) + { + if(pT->DisplayChevronMenu()) + bHandled = TRUE; + } + } + else if(m_wndParent.IsWindowEnabled()) + { + RECT rcClient = {}; + this->GetClientRect(&rcClient); + RECT rcBtn = {}; + this->GetItemRect(nBtn, &rcBtn); + TBBUTTON tbb = {}; + this->GetButton(nBtn, &tbb); + if(((tbb.fsState & TBSTATE_ENABLED) != 0) && ((tbb.fsState & TBSTATE_HIDDEN) == 0) && (rcBtn.right <= rcClient.right)) + { + if(m_bUseKeyboardCues && !m_bShowKeyboardCues) + { + m_bAllowKeyboardCues = true; + ShowKeyboardCues(true); + } + pT->TakeFocus(); + this->PostMessage(WM_KEYDOWN, VK_DOWN, 0L); + this->SetHotItem(nBtn); + } + else + { + ::MessageBeep(0); + } + } + } + + return lRet; + } + + LRESULT OnKillFocus(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) + { + if(m_bUseKeyboardCues && m_bShowKeyboardCues) + ShowKeyboardCues(false); + + bHandled = FALSE; + return 1; + } + + LRESULT OnDrawItem(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled) + { + LPDRAWITEMSTRUCT lpDrawItemStruct = (LPDRAWITEMSTRUCT)lParam; + _MenuItemData* pmd = (_MenuItemData*)lpDrawItemStruct->itemData; + if((lpDrawItemStruct->CtlType == ODT_MENU) && _IsValidMem(pmd) && pmd->IsCmdBarMenuItem()) + { + T* pT = static_cast(this); + pT->DrawItem(lpDrawItemStruct); + } + else + { + bHandled = FALSE; + } + return (LRESULT)TRUE; + } + + LRESULT OnMeasureItem(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled) + { + LPMEASUREITEMSTRUCT lpMeasureItemStruct = (LPMEASUREITEMSTRUCT)lParam; + _MenuItemData* pmd = (_MenuItemData*)lpMeasureItemStruct->itemData; + if((lpMeasureItemStruct->CtlType == ODT_MENU) && _IsValidMem(pmd) && pmd->IsCmdBarMenuItem()) + { + T* pT = static_cast(this); + pT->MeasureItem(lpMeasureItemStruct); + } + else + { + bHandled = FALSE; + } + return (LRESULT)TRUE; + } + +// API message handlers + LRESULT OnAPIGetMenu(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + return (LRESULT)m_hMenu; + } + + LRESULT OnAPITrackPopupMenu(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/) + { + if(lParam == NULL) + return FALSE; + LPCBRPOPUPMENU lpCBRPopupMenu = (LPCBRPOPUPMENU)lParam; + if(lpCBRPopupMenu->cbSize != sizeof(CBRPOPUPMENU)) + return FALSE; + + T* pT = static_cast(this); + return pT->TrackPopupMenu(lpCBRPopupMenu->hMenu, lpCBRPopupMenu->uFlags, lpCBRPopupMenu->x, lpCBRPopupMenu->y, lpCBRPopupMenu->lptpm); + } + + LRESULT OnAPIGetCmdBar(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + return (LRESULT)this->m_hWnd; + } + +// Parent window message handlers + LRESULT OnParentHotItemChange(int /*idCtrl*/, LPNMHDR pnmh, BOOL& bHandled) + { + LPNMTBHOTITEM lpNMHT = (LPNMTBHOTITEM)pnmh; + + // Check if this comes from us + if(pnmh->hwndFrom != this->m_hWnd) + { + bHandled = FALSE; + return 0; + } + + bool bBlockTracking = false; + if((m_dwExtendedStyle & CBR_EX_TRACKALWAYS) == 0) + { + DWORD dwProcessID; + ::GetWindowThreadProcessId(::GetActiveWindow(), &dwProcessID); + bBlockTracking = (::GetCurrentProcessId() != dwProcessID); + } + + if((!m_wndParent.IsWindowEnabled() || bBlockTracking) && (lpNMHT->dwFlags & HICF_MOUSE)) + return 1; + + bHandled = FALSE; + + // Send WM_MENUSELECT to the app if it needs to display a status text + if(!(lpNMHT->dwFlags & HICF_MOUSE) && !(lpNMHT->dwFlags & HICF_ACCELERATOR) && !(lpNMHT->dwFlags & HICF_LMOUSE)) + { + if(lpNMHT->dwFlags & HICF_ENTERING) + m_wndParent.SendMessage(WM_MENUSELECT, 0, (LPARAM)m_hMenu); + if(lpNMHT->dwFlags & HICF_LEAVING) + m_wndParent.SendMessage(WM_MENUSELECT, MAKEWPARAM(0, 0xFFFF), NULL); + } + + return 0; + } + + LRESULT OnParentDropDown(int /*idCtrl*/, LPNMHDR pnmh, BOOL& bHandled) + { + // Check if this comes from us + if(pnmh->hwndFrom != this->m_hWnd) + { + bHandled = FALSE; + return 1; + } + + T* pT = static_cast(this); + if(::GetFocus() != this->m_hWnd) + pT->TakeFocus(); + LPNMTOOLBAR pNMToolBar = (LPNMTOOLBAR)pnmh; + int nIndex = this->CommandToIndex(pNMToolBar->iItem); + m_bContextMenu = false; + m_bEscapePressed = false; + pT->DoPopupMenu(nIndex, true); + + return TBDDRET_DEFAULT; + } + + LRESULT OnParentInitMenuPopup(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) + { + return OnInitMenuPopup(uMsg, wParam, lParam, bHandled); + } + + LRESULT OnParentInternalGetBar(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) + { + return OnInternalGetBar(uMsg, wParam, lParam, bHandled); + } + + LRESULT OnParentSysCommand(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) + { + bHandled = FALSE; + if(((m_uSysKey == VK_MENU) + || ((m_uSysKey == VK_F10) && !(::GetKeyState(VK_SHIFT) & 0x80)) + || (m_uSysKey == VK_SPACE)) + && (wParam == SC_KEYMENU)) + { + T* pT = static_cast(this); + if(::GetFocus() == this->m_hWnd) + { + pT->GiveFocusBack(); // exit menu "loop" + this->PostMessage(TB_SETHOTITEM, (WPARAM)-1, 0L); + } + else if((m_uSysKey != VK_SPACE) && !m_bSkipMsg) + { + if(m_bUseKeyboardCues && !m_bShowKeyboardCues && m_bAllowKeyboardCues) + ShowKeyboardCues(true); + + pT->TakeFocus(); // enter menu "loop" + bHandled = TRUE; + } + else if(m_uSysKey != VK_SPACE) + { + bHandled = TRUE; + } + } + m_bSkipMsg = false; + return 0; + } + + LRESULT OnParentAPIGetMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) + { + return OnAPIGetMenu(uMsg, wParam, lParam, bHandled); + } + + LRESULT OnParentMenuChar(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) + { + return OnMenuChar(uMsg, wParam, lParam, bHandled); + } + + LRESULT OnParentAPITrackPopupMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) + { + return OnAPITrackPopupMenu(uMsg, wParam, lParam, bHandled); + } + + LRESULT OnParentAPIGetCmdBar(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) + { + return OnAPIGetCmdBar(uMsg, wParam, lParam, bHandled); + } + + LRESULT OnParentSettingChange(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) + { + OnSettingChange(uMsg, wParam, lParam, bHandled); + bHandled = FALSE; + return 1; + } + + LRESULT OnParentDrawItem(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) + { + return OnDrawItem(uMsg, wParam, lParam, bHandled); + } + + LRESULT OnParentMeasureItem(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) + { + return OnMeasureItem(uMsg, wParam, lParam, bHandled); + } + + LRESULT OnParentActivate(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) + { + m_bParentActive = (LOWORD(wParam) != WA_INACTIVE); + if(!m_bParentActive && m_bUseKeyboardCues && m_bShowKeyboardCues) + { + ShowKeyboardCues(false); // this will repaint our window + } + else + { + this->Invalidate(); + this->UpdateWindow(); + } + bHandled = FALSE; + return 1; + } + + LRESULT OnParentCustomDraw(int /*idCtrl*/, LPNMHDR pnmh, BOOL& bHandled) + { + LRESULT lRet = CDRF_DODEFAULT; + bHandled = FALSE; + if(pnmh->hwndFrom == this->m_hWnd) + { + LPNMTBCUSTOMDRAW lpTBCustomDraw = (LPNMTBCUSTOMDRAW)pnmh; + if(lpTBCustomDraw->nmcd.dwDrawStage == CDDS_PREPAINT) + { + lRet = CDRF_NOTIFYITEMDRAW; + bHandled = TRUE; + } + else if(lpTBCustomDraw->nmcd.dwDrawStage == CDDS_ITEMPREPAINT) + { +#if _WTL_CMDBAR_VISTA_MENUS && defined(_WTL_CMDBAR_VISTA_STD_MENUBAR) + if(m_bVistaMenus) + { + ::SetRectEmpty(&lpTBCustomDraw->rcText); + lRet = CDRF_NOTIFYPOSTPAINT; + bHandled = TRUE; + } + else +#endif // _WTL_CMDBAR_VISTA_MENUS && defined(_WTL_CMDBAR_VISTA_STD_MENUBAR) + { + if(m_bFlatMenus) + { + bool bDisabled = ((lpTBCustomDraw->nmcd.uItemState & CDIS_DISABLED) == CDIS_DISABLED); + if(!bDisabled && (((lpTBCustomDraw->nmcd.uItemState & CDIS_HOT) == CDIS_HOT) || + (lpTBCustomDraw->nmcd.uItemState & CDIS_SELECTED) == CDIS_SELECTED)) + { + ::FillRect(lpTBCustomDraw->nmcd.hdc, &lpTBCustomDraw->nmcd.rc, ::GetSysColorBrush(COLOR_MENUHILIGHT)); + ::FrameRect(lpTBCustomDraw->nmcd.hdc, &lpTBCustomDraw->nmcd.rc, ::GetSysColorBrush(COLOR_HIGHLIGHT)); + lpTBCustomDraw->clrText = ::GetSysColor(m_bParentActive ? COLOR_HIGHLIGHTTEXT : COLOR_GRAYTEXT); + } + else if(bDisabled || !m_bParentActive) + { + lpTBCustomDraw->clrText = ::GetSysColor(COLOR_GRAYTEXT); + } + + _ParentCustomDrawHelper(lpTBCustomDraw); + + lRet = CDRF_SKIPDEFAULT; + bHandled = TRUE; + } + else if(!m_bParentActive) + { + lpTBCustomDraw->clrText = ::GetSysColor(COLOR_GRAYTEXT); + bHandled = TRUE; + } + } + } +#if _WTL_CMDBAR_VISTA_MENUS && defined(_WTL_CMDBAR_VISTA_STD_MENUBAR) + else if (lpTBCustomDraw->nmcd.dwDrawStage == CDDS_ITEMPOSTPAINT) + { + bool bDisabled = ((lpTBCustomDraw->nmcd.uItemState & CDIS_DISABLED) == CDIS_DISABLED); + if(bDisabled || !m_bParentActive) + lpTBCustomDraw->clrText = ::GetSysColor(COLOR_GRAYTEXT); + + _ParentCustomDrawHelper(lpTBCustomDraw); + + lRet = CDRF_SKIPDEFAULT; + bHandled = TRUE; + } +#endif // _WTL_CMDBAR_VISTA_MENUS && defined(_WTL_CMDBAR_VISTA_STD_MENUBAR) + } + return lRet; + } + + void _ParentCustomDrawHelper(LPNMTBCUSTOMDRAW lpTBCustomDraw) + { + CDCHandle dc = lpTBCustomDraw->nmcd.hdc; + dc.SetTextColor(lpTBCustomDraw->clrText); + dc.SetBkMode(lpTBCustomDraw->nStringBkMode); + + HFONT hFont = this->GetFont(); + HFONT hFontOld = NULL; + if(hFont != NULL) + hFontOld = dc.SelectFont(hFont); + + const int cchText = 200; + TCHAR szText[cchText] = {}; + TBBUTTONINFO tbbi = {}; + tbbi.cbSize = sizeof(TBBUTTONINFO); + tbbi.dwMask = TBIF_TEXT; + tbbi.pszText = szText; + tbbi.cchText = cchText; + this->GetButtonInfo((int)lpTBCustomDraw->nmcd.dwItemSpec, &tbbi); + + dc.DrawText(szText, -1, &lpTBCustomDraw->nmcd.rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER | (m_bShowKeyboardCues ? 0 : DT_HIDEPREFIX)); + + if(hFont != NULL) + dc.SelectFont(hFontOld); + } + +// Message hook handlers + LRESULT OnHookMouseMove(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) + { + static POINT s_point = { -1, -1 }; + DWORD dwPoint = ::GetMessagePos(); + POINT point = { GET_X_LPARAM(dwPoint), GET_Y_LPARAM(dwPoint) }; + + bHandled = FALSE; + if(m_bMenuActive) + { + if(::WindowFromPoint(point) == this->m_hWnd) + { + this->ScreenToClient(&point); + int nHit = this->HitTest(&point); + + if(((point.x != s_point.x) || (point.y != s_point.y)) && (nHit >= 0) && (nHit < ::GetMenuItemCount(m_hMenu)) && (nHit != m_nPopBtn) && (m_nPopBtn != -1)) + { + TBBUTTON tbb = {}; + this->GetButton(nHit, &tbb); + if((tbb.fsState & TBSTATE_ENABLED) != 0) + { + m_nNextPopBtn = nHit | 0xFFFF0000; + HWND hWndMenu = this->m_stackMenuWnd.GetCurrent(); + ATLASSERT(hWndMenu != NULL); + + // this one is needed to close a menu if mouse button was down + ::PostMessage(hWndMenu, WM_LBUTTONUP, 0, MAKELPARAM(point.x, point.y)); + // this one closes a popup menu + ::PostMessage(hWndMenu, WM_KEYDOWN, VK_ESCAPE, 0L); + + bHandled = TRUE; + } + } + } + } + else + { + this->ScreenToClient(&point); + } + + s_point = point; + return 0; + } + + LRESULT OnHookSysKeyDown(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) + { + bHandled = FALSE; +#ifdef _CMDBAR_EXTRA_TRACE + ATLTRACE2(atlTraceUI, 0, _T("CmdBar - Hook WM_SYSKEYDOWN (0x%2.2X)\n"), wParam); +#endif + + if((wParam == VK_MENU) && m_bParentActive && m_bUseKeyboardCues && !m_bShowKeyboardCues && m_bAllowKeyboardCues) + ShowKeyboardCues(true); + + if((wParam != VK_SPACE) && !m_bMenuActive && (::GetFocus() == this->m_hWnd)) + { + m_bAllowKeyboardCues = false; + this->PostMessage(TB_SETHOTITEM, (WPARAM)-1, 0L); + T* pT = static_cast(this); + pT->GiveFocusBack(); + m_bSkipMsg = true; + } + else + { + if((wParam == VK_SPACE) && m_bUseKeyboardCues && m_bShowKeyboardCues) + { + m_bAllowKeyboardCues = true; + ShowKeyboardCues(false); + } + m_uSysKey = (UINT)wParam; + } + return 0; + } + + LRESULT OnHookSysKeyUp(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) + { + if(!m_bAllowKeyboardCues) + m_bAllowKeyboardCues = true; + bHandled = FALSE; + (void)wParam; // avoid level 4 warning +#ifdef _CMDBAR_EXTRA_TRACE + ATLTRACE2(atlTraceUI, 0, _T("CmdBar - Hook WM_SYSKEYUP (0x%2.2X)\n"), wParam); +#endif + return 0; + } + + LRESULT OnHookSysChar(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) + { + bHandled = FALSE; +#ifdef _CMDBAR_EXTRA_TRACE + ATLTRACE2(atlTraceUI, 0, _T("CmdBar - Hook WM_SYSCHAR (0x%2.2X)\n"), wParam); +#endif + + if(!m_bMenuActive && (this->m_hWndHook != this->m_hWnd) && (wParam != VK_SPACE)) + bHandled = TRUE; + return 0; + } + + LRESULT OnHookKeyDown(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) + { +#ifdef _CMDBAR_EXTRA_TRACE + ATLTRACE2(atlTraceUI, 0, _T("CmdBar - Hook WM_KEYDOWN (0x%2.2X)\n"), wParam); +#endif + bHandled = FALSE; + T* pT = static_cast(this); + + if((wParam == VK_ESCAPE) && (this->m_stackMenuWnd.GetSize() <= 1)) + { + if(m_bMenuActive && !m_bContextMenu) + { + int nHot = this->GetHotItem(); + if(nHot == -1) + nHot = m_nPopBtn; + if(nHot == -1) + nHot = 0; + this->SetHotItem(nHot); + bHandled = TRUE; + pT->TakeFocus(); + m_bEscapePressed = true; // To keep focus + m_bSkipPostDown = false; + } + else if((::GetFocus() == this->m_hWnd) && m_wndParent.IsWindow()) + { + this->SetHotItem(-1); + pT->GiveFocusBack(); + bHandled = TRUE; + } + } + else if((wParam == VK_RETURN) || (wParam == VK_UP) || (wParam == VK_DOWN)) + { + if(!m_bMenuActive && (::GetFocus() == this->m_hWnd) && m_wndParent.IsWindow()) + { + int nHot = this->GetHotItem(); + if(nHot != -1) + { + if(wParam != VK_RETURN) + { + if(!m_bSkipPostDown) + { + this->PostMessage(WM_KEYDOWN, VK_DOWN, 0L); + m_bSkipPostDown = true; + } + else + { + ATLTRACE2(atlTraceUI, 0, _T("CmdBar - skipping posting another VK_DOWN\n")); + m_bSkipPostDown = false; + } + } + } + else + { + ATLTRACE2(atlTraceUI, 0, _T("CmdBar - Can't find hot button\n")); + } + } + if((wParam == VK_RETURN) && m_bMenuActive) + { + this->PostMessage(TB_SETHOTITEM, (WPARAM)-1, 0L); + m_nNextPopBtn = -1; + pT->GiveFocusBack(); + } + } + else if((wParam == VK_LEFT) || (wParam == VK_RIGHT)) + { + WPARAM wpNext = m_bLayoutRTL ? VK_LEFT : VK_RIGHT; + WPARAM wpPrev = m_bLayoutRTL ? VK_RIGHT : VK_LEFT; + + if(m_bMenuActive && !m_bContextMenu && !((wParam == wpNext) && m_bPopupItem)) + { + bool bAction = false; + if((wParam == wpPrev) && (this->s_pCurrentBar->m_stackMenuWnd.GetSize() == 1)) + { + m_nNextPopBtn = pT->GetPreviousMenuItem(m_nPopBtn); + if(m_nNextPopBtn != -1) + bAction = true; + } + else if(wParam == wpNext) + { + m_nNextPopBtn = pT->GetNextMenuItem(m_nPopBtn); + if(m_nNextPopBtn != -1) + bAction = true; + } + HWND hWndMenu = this->m_stackMenuWnd.GetCurrent(); + ATLASSERT(hWndMenu != NULL); + + // Close the popup menu + if(bAction) + { + ::PostMessage(hWndMenu, WM_KEYDOWN, VK_ESCAPE, 0L); + if(wParam == wpNext) + { + int cItem = this->m_stackMenuWnd.GetSize() - 1; + while(cItem >= 0) + { + hWndMenu = this->m_stackMenuWnd[cItem]; + if(hWndMenu != NULL) + ::PostMessage(hWndMenu, WM_KEYDOWN, VK_ESCAPE, 0L); + cItem--; + } + } + if(m_nNextPopBtn == -2) + { + m_nNextPopBtn = -1; + pT->DisplayChevronMenu(); + } + bHandled = TRUE; + } + } + } + return 0; + } + + LRESULT OnHookNextMenu(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) + { +#ifdef _CMDBAR_EXTRA_TRACE + ATLTRACE2(atlTraceUI, 0, _T("CmdBar - Hook WM_NEXTMENU\n")); +#endif + bHandled = FALSE; + return 1; + } + + LRESULT OnHookChar(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) + { +#ifdef _CMDBAR_EXTRA_TRACE + ATLTRACE2(atlTraceUI, 0, _T("CmdBar - Hook WM_CHAR (0x%2.2X)\n"), wParam); +#endif + bHandled = (wParam == VK_ESCAPE); + return 0; + } + +// Implementation - ownerdraw overrideables and helpers + void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) + { + T* pT = static_cast(this); + if(m_bFlatMenus) + pT->DrawItemFlat(lpDrawItemStruct); + else + pT->DrawItem3D(lpDrawItemStruct); + + } + + void DrawItem3D(LPDRAWITEMSTRUCT lpDrawItemStruct) + { + _MenuItemData* pmd = (_MenuItemData*)lpDrawItemStruct->itemData; + CDCHandle dc = lpDrawItemStruct->hDC; + const RECT& rcItem = lpDrawItemStruct->rcItem; + T* pT = static_cast(this); + + if(pmd->fType & MFT_SEPARATOR) + { + // draw separator + RECT rc = rcItem; + rc.top += (rc.bottom - rc.top) / 2; // vertical center + dc.DrawEdge(&rc, EDGE_ETCHED, BF_TOP); // draw separator line + } + else // not a separator + { + BOOL bDisabled = lpDrawItemStruct->itemState & ODS_GRAYED; + BOOL bSelected = lpDrawItemStruct->itemState & ODS_SELECTED; + BOOL bChecked = lpDrawItemStruct->itemState & ODS_CHECKED; + BOOL bHasImage = FALSE; + + if(LOWORD(lpDrawItemStruct->itemID) == (WORD)-1) + bSelected = FALSE; + RECT rcButn = { rcItem.left, rcItem.top, rcItem.left + m_szButton.cx, rcItem.top + m_szButton.cy }; // button rect + ::OffsetRect(&rcButn, 0, ((rcItem.bottom - rcItem.top) - (rcButn.bottom - rcButn.top)) / 2); // center vertically + + int iButton = pmd->iButton; + if(iButton >= 0) + { + bHasImage = TRUE; + + // calc drawing point + SIZE sz = { rcButn.right - rcButn.left - m_szBitmap.cx, rcButn.bottom - rcButn.top - m_szBitmap.cy }; + sz.cx /= 2; + sz.cy /= 2; + POINT point = { rcButn.left + sz.cx, rcButn.top + sz.cy }; + + // fill background depending on state + if(!bChecked || (bSelected && !bDisabled)) + { + if(!bDisabled) + dc.FillRect(&rcButn, (bChecked && !bSelected) ? COLOR_3DLIGHT : COLOR_MENU); + else + dc.FillRect(&rcButn, COLOR_MENU); + } + else + { + COLORREF crTxt = dc.SetTextColor(::GetSysColor(COLOR_BTNFACE)); + COLORREF crBk = dc.SetBkColor(::GetSysColor(COLOR_BTNHILIGHT)); + CBrush hbr(CDCHandle::GetHalftoneBrush()); + dc.SetBrushOrg(rcButn.left, rcButn.top); + dc.FillRect(&rcButn, hbr); + dc.SetTextColor(crTxt); + dc.SetBkColor(crBk); + } + + // draw disabled or normal + if(!bDisabled) + { + // draw pushed-in or popped-out edge + if(bSelected || bChecked) + { + RECT rc2 = rcButn; + dc.DrawEdge(&rc2, bChecked ? BDR_SUNKENOUTER : BDR_RAISEDINNER, BF_RECT); + } + // draw the image + ::ImageList_Draw(m_hImageList, iButton, dc, point.x, point.y, ILD_TRANSPARENT); + } + else + { + HBRUSH hBrushBackground = bChecked ? NULL : ::GetSysColorBrush(COLOR_MENU); + pT->DrawBitmapDisabled(dc, iButton, point, hBrushBackground); + } + } + else + { + // no image - look for custom checked/unchecked bitmaps + CMenuItemInfo info; + info.fMask = MIIM_CHECKMARKS | MIIM_TYPE; + ::GetMenuItemInfo((HMENU)lpDrawItemStruct->hwndItem, lpDrawItemStruct->itemID, MF_BYCOMMAND, &info); + if(bChecked || (info.hbmpUnchecked != NULL)) + { + BOOL bRadio = ((info.fType & MFT_RADIOCHECK) != 0); + bHasImage = pT->DrawCheckmark(dc, rcButn, bSelected, bDisabled, bRadio, bChecked ? info.hbmpChecked : info.hbmpUnchecked); + } + } + + // draw item text + int cxButn = m_szButton.cx; + COLORREF colorBG = ::GetSysColor(bSelected ? COLOR_HIGHLIGHT : COLOR_MENU); + if(bSelected || (lpDrawItemStruct->itemAction == ODA_SELECT)) + { + RECT rcBG = rcItem; + if(bHasImage) + rcBG.left += cxButn + s_kcxGap; + dc.FillRect(&rcBG, bSelected ? COLOR_HIGHLIGHT : COLOR_MENU); + } + + // calc text rectangle and colors + RECT rcText = rcItem; + rcText.left += cxButn + s_kcxGap + s_kcxTextMargin; + rcText.right -= cxButn; + dc.SetBkMode(TRANSPARENT); + COLORREF colorText = ::GetSysColor(bDisabled ? (bSelected ? COLOR_GRAYTEXT : COLOR_3DSHADOW) : (bSelected ? COLOR_HIGHLIGHTTEXT : COLOR_MENUTEXT)); + + // font already selected by Windows + if(bDisabled && (!bSelected || (colorText == colorBG))) + { + // disabled - draw shadow text shifted down and right 1 pixel (unles selected) + RECT rcDisabled = rcText; + ::OffsetRect(&rcDisabled, 1, 1); + pT->DrawMenuText(dc, rcDisabled, pmd->lpstrText, ::GetSysColor(COLOR_3DHILIGHT)); + } + pT->DrawMenuText(dc, rcText, pmd->lpstrText, colorText); // finally! + } + } + + void DrawItemFlat(LPDRAWITEMSTRUCT lpDrawItemStruct) + { + _MenuItemData* pmd = (_MenuItemData*)lpDrawItemStruct->itemData; + CDCHandle dc = lpDrawItemStruct->hDC; + const RECT& rcItem = lpDrawItemStruct->rcItem; + T* pT = static_cast(this); + + BOOL bDisabled = lpDrawItemStruct->itemState & ODS_GRAYED; + BOOL bSelected = lpDrawItemStruct->itemState & ODS_SELECTED; + BOOL bChecked = lpDrawItemStruct->itemState & ODS_CHECKED; + + // paint background + if(bSelected || (lpDrawItemStruct->itemAction == ODA_SELECT)) + { + if(bSelected) + { + dc.FillRect(&rcItem, ::GetSysColorBrush(COLOR_MENUHILIGHT)); + dc.FrameRect(&rcItem, ::GetSysColorBrush(COLOR_HIGHLIGHT)); + } + else + { + dc.FillRect(&rcItem, ::GetSysColorBrush(COLOR_MENU)); + } + } + + if(pmd->fType & MFT_SEPARATOR) + { + // draw separator + RECT rc = rcItem; + rc.top += (rc.bottom - rc.top) / 2; // vertical center + dc.DrawEdge(&rc, EDGE_ETCHED, BF_TOP); // draw separator line + } + else // not a separator + { + if(LOWORD(lpDrawItemStruct->itemID) == (WORD)-1) + bSelected = FALSE; + RECT rcButn = { rcItem.left, rcItem.top, rcItem.left + m_szButton.cx, rcItem.top + m_szButton.cy }; // button rect + ::OffsetRect(&rcButn, 0, ((rcItem.bottom - rcItem.top) - (rcButn.bottom - rcButn.top)) / 2); // center vertically + + // draw background and border for checked items + if(bChecked) + { + RECT rcCheck = rcButn; + ::InflateRect(&rcCheck, -1, -1); + if(bSelected) + dc.FillRect(&rcCheck, ::GetSysColorBrush(COLOR_MENU)); + dc.FrameRect(&rcCheck, ::GetSysColorBrush(COLOR_HIGHLIGHT)); + } + + int iButton = pmd->iButton; + if(iButton >= 0) + { + // calc drawing point + SIZE sz = { rcButn.right - rcButn.left - m_szBitmap.cx, rcButn.bottom - rcButn.top - m_szBitmap.cy }; + sz.cx /= 2; + sz.cy /= 2; + POINT point = { rcButn.left + sz.cx, rcButn.top + sz.cy }; + + // draw disabled or normal + if(!bDisabled) + { + ::ImageList_Draw(m_hImageList, iButton, dc, point.x, point.y, ILD_TRANSPARENT); + } + else + { + HBRUSH hBrushBackground = ::GetSysColorBrush((bSelected && !(bDisabled && bChecked)) ? COLOR_MENUHILIGHT : COLOR_MENU); + HBRUSH hBrushDisabledImage = ::GetSysColorBrush(COLOR_3DSHADOW); + pT->DrawBitmapDisabled(dc, iButton, point, hBrushBackground, hBrushBackground, hBrushDisabledImage); + } + } + else + { + // no image - look for custom checked/unchecked bitmaps + CMenuItemInfo info; + info.fMask = MIIM_CHECKMARKS | MIIM_TYPE; + ::GetMenuItemInfo((HMENU)lpDrawItemStruct->hwndItem, lpDrawItemStruct->itemID, MF_BYCOMMAND, &info); + if(bChecked || (info.hbmpUnchecked != NULL)) + { + BOOL bRadio = ((info.fType & MFT_RADIOCHECK) != 0); + pT->DrawCheckmark(dc, rcButn, bSelected, bDisabled, bRadio, bChecked ? info.hbmpChecked : info.hbmpUnchecked); + } + } + + // draw item text + int cxButn = m_szButton.cx; + // calc text rectangle and colors + RECT rcText = rcItem; + rcText.left += cxButn + s_kcxGap + s_kcxTextMargin; + rcText.right -= cxButn; + dc.SetBkMode(TRANSPARENT); + COLORREF colorText = ::GetSysColor(bDisabled ? (bSelected ? COLOR_GRAYTEXT : COLOR_3DSHADOW) : (bSelected ? COLOR_HIGHLIGHTTEXT : COLOR_MENUTEXT)); + + pT->DrawMenuText(dc, rcText, pmd->lpstrText, colorText); // finally! + } + } + + void DrawMenuText(CDCHandle& dc, RECT& rc, LPCTSTR lpstrText, COLORREF color) + { + int nTab = -1; + const int nLen = lstrlen(lpstrText); + for(int i = 0; i < nLen; i++) + { + if(lpstrText[i] == _T('\t')) + { + nTab = i; + break; + } + } + dc.SetTextColor(color); + dc.DrawText(lpstrText, nTab, &rc, DT_SINGLELINE | DT_LEFT | DT_VCENTER | (m_bShowKeyboardCues ? 0 : DT_HIDEPREFIX)); + if(nTab != -1) + dc.DrawText(&lpstrText[nTab + 1], -1, &rc, DT_SINGLELINE | DT_RIGHT | DT_VCENTER | (m_bShowKeyboardCues ? 0 : DT_HIDEPREFIX)); + } + + void DrawBitmapDisabled(CDCHandle& dc, int nImage, POINT point, + HBRUSH hBrushBackground = ::GetSysColorBrush(COLOR_3DFACE), + HBRUSH hBrush3DEffect = ::GetSysColorBrush(COLOR_3DHILIGHT), + HBRUSH hBrushDisabledImage = ::GetSysColorBrush(COLOR_3DSHADOW)) + { + if(m_bAlphaImages) + { + IMAGELISTDRAWPARAMS ildp = {}; + ildp.cbSize = sizeof(IMAGELISTDRAWPARAMS); + ildp.himl = m_hImageList; + ildp.i = nImage; + ildp.hdcDst = dc; + ildp.x = point.x; + ildp.y = point.y; + ildp.cx = 0; + ildp.cy = 0; + ildp.xBitmap = 0; + ildp.yBitmap = 0; + ildp.fStyle = ILD_TRANSPARENT; + ildp.fState = ILS_SATURATE; + ildp.Frame = 0; + ::ImageList_DrawIndirect(&ildp); + } + else + { + // create memory DC + CDC dcMem; + dcMem.CreateCompatibleDC(dc); + // create mono or color bitmap + CBitmap bmp; + bmp.CreateCompatibleBitmap(dc, m_szBitmap.cx, m_szBitmap.cy); + ATLASSERT(bmp.m_hBitmap != NULL); + // draw image into memory DC--fill BG white first + HBITMAP hBmpOld = dcMem.SelectBitmap(bmp); + dcMem.PatBlt(0, 0, m_szBitmap.cx, m_szBitmap.cy, WHITENESS); + // If white is the text color, we can't use the normal painting since + // it would blend with the WHITENESS, but the mask is OK + UINT uDrawStyle = (::GetSysColor(COLOR_BTNTEXT) == RGB(255, 255, 255)) ? ILD_MASK : ILD_NORMAL; + ::ImageList_Draw(m_hImageList, nImage, dcMem, 0, 0, uDrawStyle); + dc.DitherBlt(point.x, point.y, m_szBitmap.cx, m_szBitmap.cy, dcMem, NULL, 0, 0, hBrushBackground, hBrush3DEffect, hBrushDisabledImage); + dcMem.SelectBitmap(hBmpOld); // restore + } + } + + // old name + BOOL Draw3DCheckmark(CDCHandle& dc, const RECT& rc, BOOL bSelected, BOOL bDisabled, BOOL bRadio, HBITMAP hBmpCheck) + { + return DrawCheckmark(dc, rc, bSelected, bDisabled, bRadio, hBmpCheck); + } + + BOOL DrawCheckmark(CDCHandle& dc, const RECT& rc, BOOL bSelected, BOOL bDisabled, BOOL bRadio, HBITMAP hBmpCheck) + { + // get checkmark bitmap, if none, use Windows standard + SIZE size = {}; + CBitmapHandle bmp = hBmpCheck; + if(hBmpCheck != NULL) + { + bmp.GetSize(size); + } + else + { + size.cx = ::GetSystemMetrics(SM_CXMENUCHECK); + size.cy = ::GetSystemMetrics(SM_CYMENUCHECK); + bmp.CreateCompatibleBitmap(dc, size.cx, size.cy); + ATLASSERT(bmp.m_hBitmap != NULL); + } + // center bitmap in caller's rectangle + RECT rcDest = rc; + if((rc.right - rc.left) > size.cx) + { + rcDest.left = rc.left + (rc.right - rc.left - size.cx) / 2; + rcDest.right = rcDest.left + size.cx; + } + if((rc.bottom - rc.top) > size.cy) + { + rcDest.top = rc.top + (rc.bottom - rc.top - size.cy) / 2; + rcDest.bottom = rcDest.top + size.cy; + } + // paint background + if(!m_bFlatMenus) + { + if(bSelected && !bDisabled) + { + dc.FillRect(&rcDest, COLOR_MENU); + } + else + { + COLORREF clrTextOld = dc.SetTextColor(::GetSysColor(COLOR_BTNFACE)); + COLORREF clrBkOld = dc.SetBkColor(::GetSysColor(COLOR_BTNHILIGHT)); + CBrush hbr(CDCHandle::GetHalftoneBrush()); + dc.SetBrushOrg(rcDest.left, rcDest.top); + dc.FillRect(&rcDest, hbr); + dc.SetTextColor(clrTextOld); + dc.SetBkColor(clrBkOld); + } + } + + // create source image + CDC dcSource; + dcSource.CreateCompatibleDC(dc); + HBITMAP hBmpOld = dcSource.SelectBitmap(bmp); + // set colors + const COLORREF clrBlack = RGB(0, 0, 0); + const COLORREF clrWhite = RGB(255, 255, 255); + COLORREF clrTextOld = dc.SetTextColor(clrBlack); + COLORREF clrBkOld = dc.SetBkColor(clrWhite); + // create mask + CDC dcMask; + dcMask.CreateCompatibleDC(dc); + CBitmap bmpMask; + bmpMask.CreateBitmap(size.cx, size.cy, 1, 1, NULL); + HBITMAP hBmpOld1 = dcMask.SelectBitmap(bmpMask); + + // draw the checkmark transparently + int cx = rcDest.right - rcDest.left; + int cy = rcDest.bottom - rcDest.top; + if(hBmpCheck != NULL) + { + // build mask based on transparent color + dcSource.SetBkColor(m_clrMask); + dcMask.SetBkColor(clrBlack); + dcMask.SetTextColor(clrWhite); + dcMask.BitBlt(0, 0, size.cx, size.cy, dcSource, 0, 0, SRCCOPY); + // draw bitmap using the mask + dc.BitBlt(rcDest.left, rcDest.top, cx, cy, dcSource, 0, 0, SRCINVERT); + dc.BitBlt(rcDest.left, rcDest.top, cx, cy, dcMask, 0, 0, SRCAND); + dc.BitBlt(rcDest.left, rcDest.top, cx, cy, dcSource, 0, 0, SRCINVERT); + } + else + { + const DWORD ROP_DSno = 0x00BB0226L; + const DWORD ROP_DSa = 0x008800C6L; + const DWORD ROP_DSo = 0x00EE0086L; + const DWORD ROP_DSna = 0x00220326L; + + // draw mask + RECT rcSource = { 0, 0, __min(size.cx, rc.right - rc.left), __min(size.cy, rc.bottom - rc.top) }; + dcMask.DrawFrameControl(&rcSource, DFC_MENU, bRadio ? DFCS_MENUBULLET : DFCS_MENUCHECK); + + // draw shadow if disabled + if(!m_bFlatMenus && bDisabled) + { + // offset by one pixel + int x = rcDest.left + 1; + int y = rcDest.top + 1; + // paint source bitmap + const int nColor = COLOR_3DHILIGHT; + dcSource.FillRect(&rcSource, nColor); + // draw checkmark - special case black and white colors + COLORREF clrCheck = ::GetSysColor(nColor); + if(clrCheck == clrWhite) + { + dc.BitBlt(x, y, cx, cy, dcMask, 0, 0, ROP_DSno); + dc.BitBlt(x, y, cx, cy, dcSource, 0, 0, ROP_DSa); + } + else + { + if(clrCheck != clrBlack) + { + ATLASSERT(dcSource.GetTextColor() == clrBlack); + ATLASSERT(dcSource.GetBkColor() == clrWhite); + dcSource.BitBlt(0, 0, size.cx, size.cy, dcMask, 0, 0, ROP_DSna); + } + dc.BitBlt(x, y, cx, cy, dcMask, 0, 0, ROP_DSa); + dc.BitBlt(x, y, cx, cy, dcSource, 0, 0, ROP_DSo); + } + } + + // paint source bitmap + const int nColor = bDisabled ? COLOR_BTNSHADOW : COLOR_MENUTEXT; + dcSource.FillRect(&rcSource, nColor); + // draw checkmark - special case black and white colors + COLORREF clrCheck = ::GetSysColor(nColor); + if(clrCheck == clrWhite) + { + dc.BitBlt(rcDest.left, rcDest.top, cx, cy, dcMask, 0, 0, ROP_DSno); + dc.BitBlt(rcDest.left, rcDest.top, cx, cy, dcSource, 0, 0, ROP_DSa); + } + else + { + if(clrCheck != clrBlack) + { + ATLASSERT(dcSource.GetTextColor() == clrBlack); + ATLASSERT(dcSource.GetBkColor() == clrWhite); + dcSource.BitBlt(0, 0, size.cx, size.cy, dcMask, 0, 0, ROP_DSna); + } + dc.BitBlt(rcDest.left, rcDest.top, cx, cy, dcMask, 0, 0, ROP_DSa); + dc.BitBlt(rcDest.left, rcDest.top, cx, cy, dcSource, 0, 0, ROP_DSo); + } + } + // restore all + dc.SetTextColor(clrTextOld); + dc.SetBkColor(clrBkOld); + dcSource.SelectBitmap(hBmpOld); + dcMask.SelectBitmap(hBmpOld1); + if(hBmpCheck == NULL) + bmp.DeleteObject(); + // draw pushed-in hilight + if(!m_bFlatMenus && !bDisabled) + { + if(rc.right - rc.left > size.cx) + ::InflateRect(&rcDest, 1,1); // inflate checkmark by one pixel all around + dc.DrawEdge(&rcDest, BDR_SUNKENOUTER, BF_RECT); + } + + return TRUE; + } + + void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct) + { + _MenuItemData* pmd = (_MenuItemData*)lpMeasureItemStruct->itemData; + + if(pmd->fType & MFT_SEPARATOR) // separator - use half system height and zero width + { + lpMeasureItemStruct->itemHeight = ::GetSystemMetrics(SM_CYMENU) / 2; + lpMeasureItemStruct->itemWidth = 0; + } + else + { + // compute size of text - use DrawText with DT_CALCRECT + CWindowDC dc(NULL); + CFont fontBold; + HFONT hOldFont = NULL; + if(pmd->fState & MFS_DEFAULT) + { + // need bold version of font + LOGFONT lf = {}; + m_fontMenu.GetLogFont(lf); + lf.lfWeight += 200; + fontBold.CreateFontIndirect(&lf); + ATLASSERT(fontBold.m_hFont != NULL); + hOldFont = dc.SelectFont(fontBold); + } + else + { + hOldFont = dc.SelectFont(m_fontMenu); + } + + RECT rcText = {}; + dc.DrawText(pmd->lpstrText, -1, &rcText, DT_SINGLELINE | DT_LEFT | DT_VCENTER | DT_CALCRECT); + int cx = rcText.right - rcText.left; + dc.SelectFont(hOldFont); + + LOGFONT lf = {}; + m_fontMenu.GetLogFont(lf); + int cy = lf.lfHeight; + if(cy < 0) + cy = -cy; + const int cyMargin = 8; + cy += cyMargin; + + // height of item is the bigger of these two + lpMeasureItemStruct->itemHeight = __max(cy, (int)m_szButton.cy); + + // width is width of text plus a bunch of stuff + cx += 2 * s_kcxTextMargin; // L/R margin for readability + cx += s_kcxGap; // space between button and menu text + cx += 2 * m_szButton.cx; // button width (L=button; R=empty margin) + cx += m_cxExtraSpacing; // extra between item text and accelerator keys + + // Windows adds 1 to returned value + cx -= ::GetSystemMetrics(SM_CXMENUCHECK) - 1; + lpMeasureItemStruct->itemWidth = cx; // done deal + } + } + +// Implementation - Hook procs + static LRESULT CALLBACK CreateHookProc(int nCode, WPARAM wParam, LPARAM lParam) + { + const int cchClassName = 7; + TCHAR szClassName[cchClassName] = {}; + + if(nCode == HCBT_CREATEWND) + { + HWND hWndMenu = (HWND)wParam; +#ifdef _CMDBAR_EXTRA_TRACE + ATLTRACE2(atlTraceUI, 0, _T("CmdBar - HCBT_CREATEWND (HWND = %8.8X)\n"), hWndMenu); +#endif + + ::GetClassName(hWndMenu, szClassName, cchClassName); + if(!lstrcmp(_T("#32768"), szClassName)) + CCommandBarCtrlBase::s_pCurrentBar->m_stackMenuWnd.Push(hWndMenu); + } + else if(nCode == HCBT_DESTROYWND) + { + HWND hWndMenu = (HWND)wParam; +#ifdef _CMDBAR_EXTRA_TRACE + ATLTRACE2(atlTraceUI, 0, _T("CmdBar - HCBT_DESTROYWND (HWND = %8.8X)\n"), hWndMenu); +#endif + + ::GetClassName(hWndMenu, szClassName, cchClassName); + if(!lstrcmp(_T("#32768"), szClassName)) + { + ATLASSERT(hWndMenu == CCommandBarCtrlBase::s_pCurrentBar->m_stackMenuWnd.GetCurrent()); + CCommandBarCtrlBase::s_pCurrentBar->m_stackMenuWnd.Pop(); + } + } + + return ::CallNextHookEx(CCommandBarCtrlBase::s_hCreateHook, nCode, wParam, lParam); + } + + static LRESULT CALLBACK MessageHookProc(int nCode, WPARAM wParam, LPARAM lParam) + { + LPMSG pMsg = (LPMSG)lParam; + + if((nCode == HC_ACTION) && (wParam == PM_REMOVE) && (pMsg->message != GetGetBarMessage()) && (pMsg->message != WM_FORWARDMSG)) + { + CCommandBarCtrlBase* pCmdBar = NULL; + HWND hWnd = pMsg->hwnd; + DWORD dwPID = 0; + while((pCmdBar == NULL) && (hWnd != NULL)) + { + pCmdBar = (CCommandBarCtrlBase*)::SendMessage(hWnd, GetGetBarMessage(), (WPARAM)&dwPID, 0L); + hWnd = ::GetParent(hWnd); + } + + if((pCmdBar != NULL) && (dwPID == GetCurrentProcessId())) + { + pCmdBar->m_hWndHook = pMsg->hwnd; + ATLASSERT(pCmdBar->IsCommandBarBase()); + + if(::IsWindow(pCmdBar->m_hWnd)) + pCmdBar->SendMessage(WM_FORWARDMSG, 0, (LPARAM)pMsg); + else + ATLTRACE2(atlTraceUI, 0, _T("CmdBar - Hook skipping message, can't find command bar!\n")); + } + } + + LRESULT lRet = 0; + ATLASSERT(CCommandBarCtrlBase::s_pmapMsgHook != NULL); + if(CCommandBarCtrlBase::s_pmapMsgHook != NULL) + { + DWORD dwThreadID = ::GetCurrentThreadId(); + CCommandBarCtrlBase::_MsgHookData* pData = CCommandBarCtrlBase::s_pmapMsgHook->Lookup(dwThreadID); + if(pData != NULL) + { + lRet = ::CallNextHookEx(pData->hMsgHook, nCode, wParam, lParam); + } + } + return lRet; + } + +// Implementation + void DoPopupMenu(int nIndex, bool bAnimate) + { +#ifdef _CMDBAR_EXTRA_TRACE + ATLTRACE2(atlTraceUI, 0, _T("CmdBar - DoPopupMenu, bAnimate = %s\n"), bAnimate ? "true" : "false"); +#endif + T* pT = static_cast(this); + + // get popup menu and it's position + RECT rect = {}; + this->GetItemRect(nIndex, &rect); + POINT pt = { rect.left, rect.bottom }; + this->MapWindowPoints(NULL, &pt, 1); + this->MapWindowPoints(NULL, &rect); + TPMPARAMS TPMParams = {}; + TPMParams.cbSize = sizeof(TPMPARAMS); + TPMParams.rcExclude = rect; + HMENU hMenuPopup = ::GetSubMenu(m_hMenu, nIndex); + ATLASSERT(hMenuPopup != NULL); + + // get button ID + TBBUTTON tbb = {}; + this->GetButton(nIndex, &tbb); + int nCmdID = tbb.idCommand; + + m_nPopBtn = nIndex; // remember current button's index + + // press button and display popup menu + this->PressButton(nCmdID, TRUE); + this->SetHotItem(nCmdID); + pT->DoTrackPopupMenu(hMenuPopup, TPM_LEFTBUTTON | TPM_VERTICAL | TPM_LEFTALIGN | TPM_TOPALIGN | + (bAnimate ? TPM_VERPOSANIMATION : TPM_NOANIMATION), pt.x, pt.y, &TPMParams); + this->PressButton(nCmdID, FALSE); + if(::GetFocus() != this->m_hWnd) + this->SetHotItem(-1); + + m_nPopBtn = -1; // restore + + // eat next message if click is on the same button + MSG msg = {}; + if(::PeekMessage(&msg, this->m_hWnd, WM_LBUTTONDOWN, WM_LBUTTONDOWN, PM_NOREMOVE) && ::PtInRect(&rect, msg.pt)) + ::PeekMessage(&msg, this->m_hWnd, WM_LBUTTONDOWN, WM_LBUTTONDOWN, PM_REMOVE); + + // check if another popup menu should be displayed + if(m_nNextPopBtn != -1) + { + this->PostMessage(GetAutoPopupMessage(), m_nNextPopBtn & 0xFFFF); + if(!(m_nNextPopBtn & 0xFFFF0000) && !m_bPopupItem) + this->PostMessage(WM_KEYDOWN, VK_DOWN, 0); + m_nNextPopBtn = -1; + } + else + { + m_bContextMenu = false; + // If user didn't hit escape, give focus back + if(!m_bEscapePressed) + { + if(m_bUseKeyboardCues && m_bShowKeyboardCues) + m_bAllowKeyboardCues = false; + pT->GiveFocusBack(); + } + else + { + this->SetHotItem(nCmdID); + this->SetAnchorHighlight(TRUE); + } + } + } + + BOOL DoTrackPopupMenu(HMENU hMenu, UINT uFlags, int x, int y, LPTPMPARAMS lpParams = NULL) + { + CMenuHandle menuPopup = hMenu; + + CWindowCreateCriticalSectionLock lock; + if(FAILED(lock.Lock())) + { + ATLTRACE2(atlTraceUI, 0, _T("ERROR : Unable to lock critical section in CCommandBarCtrlImpl::DoTrackPopupMenu.\n")); + ATLASSERT(FALSE); + return FALSE; + } + + ATLASSERT(this->s_hCreateHook == NULL); + + this->s_pCurrentBar = static_cast(this); + + this->s_hCreateHook = ::SetWindowsHookEx(WH_CBT, CreateHookProc, ModuleHelper::GetModuleInstance(), GetCurrentThreadId()); + ATLASSERT(this->s_hCreateHook != NULL); + + m_bPopupItem = false; + m_bMenuActive = true; + + BOOL bTrackRet = menuPopup.TrackPopupMenuEx(uFlags, x, y, this->m_hWnd, lpParams); + m_bMenuActive = false; + + ::UnhookWindowsHookEx(this->s_hCreateHook); + + this->s_hCreateHook = NULL; + this->s_pCurrentBar = NULL; + + lock.Unlock(); + + // cleanup - convert menus back to original state +#ifdef _CMDBAR_EXTRA_TRACE + ATLTRACE2(atlTraceUI, 0, _T("CmdBar - TrackPopupMenu - cleanup\n")); +#endif + + ATLASSERT(this->m_stackMenuWnd.GetSize() == 0); + + this->UpdateWindow(); + ATL::CWindow wndTL = this->GetTopLevelParent(); + wndTL.UpdateWindow(); + + // restore the menu items to the previous state for all menus that were converted + if(m_bImagesVisible) + { + HMENU hMenuSav = NULL; + while((hMenuSav = this->m_stackMenuHandle.Pop()) != NULL) + { + menuPopup = hMenuSav; + BOOL bRet = FALSE; + // restore state and delete menu item data + for(int i = 0; i < menuPopup.GetMenuItemCount(); i++) + { + CMenuItemInfo mii; + mii.fMask = MIIM_DATA | MIIM_TYPE | MIIM_ID; + bRet = menuPopup.GetMenuItemInfo(i, TRUE, &mii); + ATLASSERT(bRet); + + _MenuItemData* pMI = (_MenuItemData*)mii.dwItemData; + if(_IsValidMem(pMI) && pMI->IsCmdBarMenuItem()) + { + mii.fMask = MIIM_DATA | MIIM_TYPE | MIIM_STATE; + mii.fType = pMI->fType; + mii.fState = pMI->fState; + mii.dwTypeData = pMI->lpstrText; + mii.cch = lstrlen(pMI->lpstrText); + mii.dwItemData = NULL; + + bRet = menuPopup.SetMenuItemInfo(i, TRUE, &mii); + // this one triggers WM_MEASUREITEM + menuPopup.ModifyMenu(i, MF_BYPOSITION | mii.fType | mii.fState, mii.wID, pMI->lpstrText); + ATLASSERT(bRet); + + delete [] pMI->lpstrText; + delete pMI; + } + } + } + } + return bTrackRet; + } + + int GetPreviousMenuItem(int nBtn) const + { + if(nBtn == -1) + return -1; + RECT rcClient = {}; + this->GetClientRect(&rcClient); + int nNextBtn; + for(nNextBtn = nBtn - 1; nNextBtn != nBtn; nNextBtn--) + { + if(nNextBtn < 0) + nNextBtn = ::GetMenuItemCount(m_hMenu) - 1; + TBBUTTON tbb = {}; + this->GetButton(nNextBtn, &tbb); + RECT rcBtn = {}; + this->GetItemRect(nNextBtn, &rcBtn); + if(rcBtn.right > rcClient.right) + { + nNextBtn = -2; // chevron + break; + } + if(((tbb.fsState & TBSTATE_ENABLED) != 0) && ((tbb.fsState & TBSTATE_HIDDEN) == 0)) + break; + } + return (nNextBtn != nBtn) ? nNextBtn : -1; + } + + int GetNextMenuItem(int nBtn) const + { + if(nBtn == -1) + return -1; + RECT rcClient = {}; + this->GetClientRect(&rcClient); + int nNextBtn = 0; + int nCount = ::GetMenuItemCount(m_hMenu); + for(nNextBtn = nBtn + 1; nNextBtn != nBtn; nNextBtn++) + { + if(nNextBtn >= nCount) + nNextBtn = 0; + TBBUTTON tbb = {}; + this->GetButton(nNextBtn, &tbb); + RECT rcBtn = {}; + this->GetItemRect(nNextBtn, &rcBtn); + if(rcBtn.right > rcClient.right) + { + nNextBtn = -2; // chevron + break; + } + if(((tbb.fsState & TBSTATE_ENABLED) != 0) && ((tbb.fsState & TBSTATE_HIDDEN) == 0)) + break; + } + return (nNextBtn != nBtn) ? nNextBtn : -1; + } + + bool DisplayChevronMenu() + { + // assume we are in a rebar + HWND hWndReBar = this->GetParent(); + int nCount = (int)::SendMessage(hWndReBar, RB_GETBANDCOUNT, 0, 0L); + bool bRet = false; + for(int i = 0; i < nCount; i++) + { + REBARBANDINFO rbbi = { RunTimeHelper::SizeOf_REBARBANDINFO(), RBBIM_CHILD | RBBIM_STYLE }; + BOOL bRetBandInfo = (BOOL)::SendMessage(hWndReBar, RB_GETBANDINFO, i, (LPARAM)&rbbi); + if(bRetBandInfo && (rbbi.hwndChild == this->m_hWnd)) + { + if((rbbi.fStyle & RBBS_USECHEVRON) != 0) + { + ::PostMessage(hWndReBar, RB_PUSHCHEVRON, i, 0L); + this->PostMessage(WM_KEYDOWN, VK_DOWN, 0L); + bRet = true; + } + break; + } + } + return bRet; + } + + void GetSystemSettings() + { + // refresh our font + NONCLIENTMETRICS info = { RunTimeHelper::SizeOf_NONCLIENTMETRICS() }; + BOOL bRet = ::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(info), &info, 0); + ATLASSERT(bRet); + if(bRet) + { + LOGFONT logfont = {}; + if(m_fontMenu.m_hFont != NULL) + m_fontMenu.GetLogFont(logfont); + if((logfont.lfHeight != info.lfMenuFont.lfHeight) || + (logfont.lfWidth != info.lfMenuFont.lfWidth) || + (logfont.lfEscapement != info.lfMenuFont.lfEscapement) || + (logfont.lfOrientation != info.lfMenuFont.lfOrientation) || + (logfont.lfWeight != info.lfMenuFont.lfWeight) || + (logfont.lfItalic != info.lfMenuFont.lfItalic) || + (logfont.lfUnderline != info.lfMenuFont.lfUnderline) || + (logfont.lfStrikeOut != info.lfMenuFont.lfStrikeOut) || + (logfont.lfCharSet != info.lfMenuFont.lfCharSet) || + (logfont.lfOutPrecision != info.lfMenuFont.lfOutPrecision) || + (logfont.lfClipPrecision != info.lfMenuFont.lfClipPrecision) || + (logfont.lfQuality != info.lfMenuFont.lfQuality) || + (logfont.lfPitchAndFamily != info.lfMenuFont.lfPitchAndFamily) || + (lstrcmp(logfont.lfFaceName, info.lfMenuFont.lfFaceName) != 0)) + { + HFONT hFontMenu = ::CreateFontIndirect(&info.lfMenuFont); + ATLASSERT(hFontMenu != NULL); + if(hFontMenu != NULL) + { + if(m_fontMenu.m_hFont != NULL) + m_fontMenu.DeleteObject(); + m_fontMenu.Attach(hFontMenu); + this->SetFont(m_fontMenu); + this->AddStrings(_T("NS\0")); // for proper item height + this->AutoSize(); + } + } + } + + // check if we need extra spacing for menu item text + CWindowDC dc(this->m_hWnd); + HFONT hFontOld = dc.SelectFont(m_fontMenu); + RECT rcText = {}; + dc.DrawText(_T("\t"), -1, &rcText, DT_SINGLELINE | DT_LEFT | DT_VCENTER | DT_CALCRECT); + if((rcText.right - rcText.left) < 4) + { + ::SetRectEmpty(&rcText); + dc.DrawText(_T("x"), -1, &rcText, DT_SINGLELINE | DT_LEFT | DT_VCENTER | DT_CALCRECT); + m_cxExtraSpacing = rcText.right - rcText.left; + } + else + { + m_cxExtraSpacing = 0; + } + dc.SelectFont(hFontOld); + + // get Windows version +#ifndef _versionhelpers_H_INCLUDED_ + OSVERSIONINFO ovi = { sizeof(OSVERSIONINFO) }; + ::GetVersionEx(&ovi); +#endif // !_versionhelpers_H_INCLUDED_ + + // query keyboard cues mode (Windows 2000 or later) +#ifdef _versionhelpers_H_INCLUDED_ + if(::IsWindowsVersionOrGreater(5, 0, 0)) +#else // !_versionhelpers_H_INCLUDED_ + if (ovi.dwMajorVersion >= 5) +#endif // _versionhelpers_H_INCLUDED_ + { + BOOL bRetVal = TRUE; + bRet = ::SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &bRetVal, 0); + m_bUseKeyboardCues = (bRet && !bRetVal); + m_bAllowKeyboardCues = true; + ShowKeyboardCues(!m_bUseKeyboardCues); + } + + // query flat menu mode (Windows XP or later) +#ifdef _versionhelpers_H_INCLUDED_ + if(::IsWindowsXPOrGreater()) +#else // !_versionhelpers_H_INCLUDED_ + if (((ovi.dwMajorVersion == 5) && (ovi.dwMinorVersion >= 1)) || (ovi.dwMajorVersion > 5)) +#endif // _versionhelpers_H_INCLUDED_ + { + BOOL bRetVal = FALSE; + bRet = ::SystemParametersInfo(SPI_GETFLATMENU, 0, &bRetVal, 0); + m_bFlatMenus = (bRet && bRetVal); + } + +#if _WTL_CMDBAR_VISTA_MENUS + // check if we should use Vista menus + bool bVistaMenus = (((m_dwExtendedStyle & CBR_EX_NOVISTAMENUS) == 0) && RunTimeHelper::IsVista() && RunTimeHelper::IsThemeAvailable()); + if(!bVistaMenus && m_bVistaMenus && (m_hMenu != NULL) && (m_arrCommand.GetSize() > 0)) + { + T* pT = static_cast(this); + pT->_RemoveVistaBitmapsFromMenu(); + } + + m_bVistaMenus = bVistaMenus; +#endif // _WTL_CMDBAR_VISTA_MENUS + +#ifdef _CMDBAR_EXTRA_TRACE + ATLTRACE2(atlTraceUI, 0, _T("CmdBar - GetSystemSettings:\n m_bFlatMenus = %s\n m_bUseKeyboardCues = %s m_bVistaMenus = %s\n"), + m_bFlatMenus ? "true" : "false", m_bUseKeyboardCues ? "true" : "false", m_bVistaMenus ? "true" : "false"); +#endif + } + +// Implementation - alternate focus mode support + void TakeFocus() + { + if((m_dwExtendedStyle & CBR_EX_ALTFOCUSMODE) && (m_hWndFocus == NULL)) + m_hWndFocus = ::GetFocus(); + this->SetFocus(); + } + + void GiveFocusBack() + { + if(m_bParentActive) + { + if((m_dwExtendedStyle & CBR_EX_ALTFOCUSMODE) && ::IsWindow(m_hWndFocus)) + ::SetFocus(m_hWndFocus); + else if(!(m_dwExtendedStyle & CBR_EX_ALTFOCUSMODE) && m_wndParent.IsWindow()) + m_wndParent.SetFocus(); + } + m_hWndFocus = NULL; + this->SetAnchorHighlight(FALSE); + if(m_bUseKeyboardCues && m_bShowKeyboardCues) + this->ShowKeyboardCues(false); + m_bSkipPostDown = false; + } + + void ShowKeyboardCues(bool bShow) + { + m_bShowKeyboardCues = bShow; + this->SetDrawTextFlags(DT_HIDEPREFIX, m_bShowKeyboardCues ? 0 : DT_HIDEPREFIX); + this->Invalidate(); + this->UpdateWindow(); + } + +// Implementation - internal message helpers + static UINT GetAutoPopupMessage() + { + static UINT uAutoPopupMessage = 0; + if(uAutoPopupMessage == 0) + { + CStaticDataInitCriticalSectionLock lock; + if(FAILED(lock.Lock())) + { + ATLTRACE2(atlTraceUI, 0, _T("ERROR : Unable to lock critical section in CCommandBarCtrlImpl::GetAutoPopupMessage.\n")); + ATLASSERT(FALSE); + return 0; + } + + if(uAutoPopupMessage == 0) + uAutoPopupMessage = ::RegisterWindowMessage(_T("WTL_CmdBar_InternalAutoPopupMsg")); + + lock.Unlock(); + } + ATLASSERT(uAutoPopupMessage != 0); + return uAutoPopupMessage; + } + + static UINT GetGetBarMessage() + { + static UINT uGetBarMessage = 0; + if(uGetBarMessage == 0) + { + CStaticDataInitCriticalSectionLock lock; + if(FAILED(lock.Lock())) + { + ATLTRACE2(atlTraceUI, 0, _T("ERROR : Unable to lock critical section in CCommandBarCtrlImpl::GetGetBarMessage.\n")); + ATLASSERT(FALSE); + return 0; + } + + if(uGetBarMessage == 0) + uGetBarMessage = ::RegisterWindowMessage(_T("WTL_CmdBar_InternalGetBarMsg")); + + lock.Unlock(); + } + ATLASSERT(uGetBarMessage != 0); + return uGetBarMessage; + } + +// Implementation + bool CreateInternalImageList(int cImages) + { + UINT uFlags = (m_bAlphaImages ? ILC_COLOR32 : ILC_COLOR24) | ILC_MASK; + m_hImageList = ::ImageList_Create(m_szBitmap.cx, m_szBitmap.cy, uFlags, cImages, 1); + ATLASSERT(m_hImageList != NULL); + return (m_hImageList != NULL); + } + +// Implementation - support for Vista menus +#if _WTL_CMDBAR_VISTA_MENUS + void _AddVistaBitmapsFromImageList(int nStartIndex, int nCount) + { + // Create display compatible memory DC + CClientDC dc(NULL); + CDC dcMem; + dcMem.CreateCompatibleDC(dc); + HBITMAP hBitmapSave = dcMem.GetCurrentBitmap(); + + T* pT = static_cast(this); + // Create bitmaps for all menu items + for(int i = 0; i < nCount; i++) + { + HBITMAP hBitmap = pT->_CreateVistaBitmapHelper(nStartIndex + i, dc, dcMem); + dcMem.SelectBitmap(hBitmapSave); + m_arrVistaBitmap.Add(hBitmap); + } + } + + void _AddVistaBitmapFromImageList(int nIndex) + { + // Create display compatible memory DC + CClientDC dc(NULL); + CDC dcMem; + dcMem.CreateCompatibleDC(dc); + HBITMAP hBitmapSave = dcMem.GetCurrentBitmap(); + + // Create bitmap for menu item + T* pT = static_cast(this); + HBITMAP hBitmap = pT->_CreateVistaBitmapHelper(nIndex, dc, dcMem); + + // Select saved bitmap back and add bitmap to the array + dcMem.SelectBitmap(hBitmapSave); + m_arrVistaBitmap.Add(hBitmap); + } + + void _ReplaceVistaBitmapFromImageList(int nIndex) + { + // Delete existing bitmap + if(m_arrVistaBitmap[nIndex] != NULL) + ::DeleteObject(m_arrVistaBitmap[nIndex]); + + // Create display compatible memory DC + CClientDC dc(NULL); + CDC dcMem; + dcMem.CreateCompatibleDC(dc); + HBITMAP hBitmapSave = dcMem.GetCurrentBitmap(); + + // Create bitmap for menu item + T* pT = static_cast(this); + HBITMAP hBitmap = pT->_CreateVistaBitmapHelper(nIndex, dc, dcMem); + + // Select saved bitmap back and replace bitmap in the array + dcMem.SelectBitmap(hBitmapSave); + m_arrVistaBitmap.SetAtIndex(nIndex, hBitmap); + } + + HBITMAP _CreateVistaBitmapHelper(int nIndex, HDC hDCSource, HDC hDCTarget) + { + // Create 32-bit bitmap + BITMAPINFO bi = {}; + bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + bi.bmiHeader.biWidth = m_szBitmap.cx; + bi.bmiHeader.biHeight = m_szBitmap.cy; + bi.bmiHeader.biPlanes = 1; + bi.bmiHeader.biBitCount = 32; + bi.bmiHeader.biCompression = BI_RGB; + bi.bmiHeader.biSizeImage = 0; + bi.bmiHeader.biXPelsPerMeter = 0; + bi.bmiHeader.biYPelsPerMeter = 0; + bi.bmiHeader.biClrUsed = 0; + bi.bmiHeader.biClrImportant = 0; + HBITMAP hBitmap = ::CreateDIBSection(hDCSource, &bi, DIB_RGB_COLORS, NULL, NULL, 0); + ATLASSERT(hBitmap != NULL); + + // Select bitmap into target DC and draw from image list to it + if(hBitmap != NULL) + { + ::SelectObject(hDCTarget, hBitmap); + + IMAGELISTDRAWPARAMS ildp = {}; + ildp.cbSize = sizeof(IMAGELISTDRAWPARAMS); + ildp.himl = m_hImageList; + ildp.i = nIndex; + ildp.hdcDst = hDCTarget; + ildp.x = 0; + ildp.y = 0; + ildp.cx = 0; + ildp.cy = 0; + ildp.xBitmap = 0; + ildp.yBitmap = 0; + ildp.fStyle = ILD_TRANSPARENT; + ildp.fState = ILS_ALPHA; + ildp.Frame = 255; + ::ImageList_DrawIndirect(&ildp); + } + + return hBitmap; + } + + void _RemoveVistaBitmapsFromMenu() + { + CMenuHandle menu = m_hMenu; + for(int i = 0; i < m_arrCommand.GetSize(); i++) + { + CMenuItemInfo mii; + mii.fMask = MIIM_BITMAP; + mii.hbmpItem = NULL; + menu.SetMenuItemInfo(m_arrCommand[i], FALSE, &mii); + } + } +#endif // _WTL_CMDBAR_VISTA_MENUS + +// Implementation helper + static bool _IsValidMem(void* pMem) + { + bool bRet = false; + if(pMem != NULL) + { + MEMORY_BASIC_INFORMATION mbi = {}; + ::VirtualQuery(pMem, &mbi, sizeof(MEMORY_BASIC_INFORMATION)); + bRet = (mbi.BaseAddress != NULL) && ((mbi.Protect & (PAGE_READONLY | PAGE_READWRITE)) != 0); + } + + return bRet; + } +}; + + +class CCommandBarCtrl : public CCommandBarCtrlImpl +{ +public: + DECLARE_WND_SUPERCLASS(_T("WTL_CommandBar"), GetWndClassName()) +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CMDICommandBarCtrl - ATL implementation of Command Bars for MDI apps + +template +class ATL_NO_VTABLE CMDICommandBarCtrlImpl : public CCommandBarCtrlImpl< T, TBase, TWinTraits> +{ +public: +// Data members + ATL::CContainedWindow m_wndMDIClient; + bool m_bChildMaximized; + HWND m_hWndChildMaximized; + HICON m_hIconChildMaximized; + int m_nBtnPressed; + int m_nBtnWasPressed; + + int m_cxyOffset; // offset between nonclient elements + int m_cxIconWidth; // small icon width + int m_cyIconHeight; // small icon height + int m_cxBtnWidth; // nonclient button width + int m_cyBtnHeight; // nonclient button height + int m_cxLeft; // left nonclient area width + int m_cxRight; // right nonclient area width + + HTHEME m_hTheme; + +// Constructor/destructor + CMDICommandBarCtrlImpl() : + m_wndMDIClient(this, 2), m_bChildMaximized(false), + m_hWndChildMaximized(NULL), m_hIconChildMaximized(NULL), + m_nBtnPressed(-1), m_nBtnWasPressed(-1), + m_cxyOffset(2), + m_cxIconWidth(16), m_cyIconHeight(16), + m_cxBtnWidth(16), m_cyBtnHeight(14), + m_cxLeft(20), m_cxRight(55), + m_hTheme(NULL) + { } + + ~CMDICommandBarCtrlImpl() + { + if(m_wndMDIClient.IsWindow()) +/*scary!*/ m_wndMDIClient.UnsubclassWindow(); + } + +// Operations + BOOL SetMDIClient(HWND hWndMDIClient) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(::IsWindow(hWndMDIClient)); + if(!::IsWindow(hWndMDIClient)) + return FALSE; + +#ifdef _DEBUG + // BLOCK: Test if the passed window is MDICLIENT + { + LPCTSTR lpszMDIClientClass = _T("MDICLIENT"); + const int nNameLen = 9 + 1; // "MDICLIENT" + NULL + TCHAR szClassName[nNameLen] = {}; + ::GetClassName(hWndMDIClient, szClassName, nNameLen); + ATLASSERT(lstrcmpi(szClassName, lpszMDIClientClass) == 0); + } +#endif // _DEBUG + + if(m_wndMDIClient.IsWindow()) +/*scary!*/ m_wndMDIClient.UnsubclassWindow(); + + return m_wndMDIClient.SubclassWindow(hWndMDIClient); + } + +// Message maps + typedef CCommandBarCtrlImpl< T, TBase, TWinTraits > _baseClass; + BEGIN_MSG_MAP(CMDICommandBarCtrlImpl) + MESSAGE_HANDLER(WM_CREATE, OnCreate) + MESSAGE_HANDLER(WM_DESTROY, OnDestroy) + MESSAGE_HANDLER(_GetThemeChangedMsg(), OnThemeChanged) + MESSAGE_HANDLER(WM_SIZE, OnSize) + MESSAGE_HANDLER(WM_NCCALCSIZE, OnNcCalcSize) + MESSAGE_HANDLER(WM_NCPAINT, OnNcPaint) + MESSAGE_HANDLER(WM_NCHITTEST, OnNcHitTest) + MESSAGE_HANDLER(WM_NCLBUTTONDOWN, OnNcLButtonDown) + MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove) + MESSAGE_HANDLER(WM_LBUTTONUP, OnLButtonUp) + MESSAGE_HANDLER(WM_NCLBUTTONDBLCLK, OnNcLButtonDblClk) + MESSAGE_HANDLER(WM_CAPTURECHANGED, OnCaptureChanged) + CHAIN_MSG_MAP(_baseClass) + ALT_MSG_MAP(1) // Parent window messages + MESSAGE_HANDLER(WM_ACTIVATE, OnParentActivate) + CHAIN_MSG_MAP_ALT(_baseClass, 1) + ALT_MSG_MAP(2) // MDI client window messages + MESSAGE_HANDLER(WM_MDISETMENU, OnMDISetMenu) + // no chaining needed since this was moved from the base class here + ALT_MSG_MAP(3) // Message hook messages + MESSAGE_RANGE_HANDLER(0, 0xFFFF, OnAllHookMessages) + CHAIN_MSG_MAP_ALT(_baseClass, 3) + END_MSG_MAP() + +// Additional MDI message handlers + LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) + { + LRESULT lRet = _baseClass::OnCreate(uMsg, wParam, lParam, bHandled); + if(lRet == (LRESULT)-1) + return lRet; + + T* pT = static_cast(this); + pT->_OpenThemeData(); + + return lRet; + } + + LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) + { + LRESULT lRet = _baseClass::OnDestroy(uMsg, wParam, lParam, bHandled); + + T* pT = static_cast(this); + pT->_CloseThemeData(); + + return lRet; + } + + LRESULT OnThemeChanged(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + T* pT = static_cast(this); + pT->_CloseThemeData(); + pT->_OpenThemeData(); + + return 0; + } + + LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) + { + LRESULT lRet = this->DefWindowProc(uMsg, wParam, lParam); + T* pT = static_cast(this); + pT->_AdjustBtnSize(GET_Y_LPARAM(lParam)); + return lRet; + } + + LRESULT OnNcCalcSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) + { + LRESULT lRet = this->DefWindowProc(uMsg, wParam, lParam); + + if(m_bChildMaximized && (BOOL)wParam) + { + LPNCCALCSIZE_PARAMS lpParams = (LPNCCALCSIZE_PARAMS)lParam; + if(this->m_bLayoutRTL) + { + lpParams->rgrc[0].left += m_cxRight; + lpParams->rgrc[0].right -= m_cxLeft; + } + else + { + lpParams->rgrc[0].left += m_cxLeft; + lpParams->rgrc[0].right -= m_cxRight; + } + } + + return lRet; + } + + LRESULT OnNcPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) + { + LRESULT lRet = this->DefWindowProc(uMsg, wParam, lParam); + + if(!m_bChildMaximized) + return lRet; + + ATLASSERT((m_hWndChildMaximized != NULL) && (m_hIconChildMaximized != NULL)); + + // get DC and window rectangle + CWindowDC dc(this->m_hWnd); + RECT rect = {}; + this->GetWindowRect(&rect); + int cxWidth = rect.right - rect.left; + int cyHeight = rect.bottom - rect.top; + + // paint left side nonclient background and draw icon + ::SetRect(&rect, 0, 0, m_cxLeft, cyHeight); + if(m_hTheme != NULL) + { + ::DrawThemeParentBackground(this->m_hWnd, dc, &rect); + } + else + { + if((this->m_dwExtendedStyle & CBR_EX_TRANSPARENT) != 0) + dc.FillRect(&rect, COLOR_3DFACE); + else + dc.FillRect(&rect, COLOR_MENU); + } + + RECT rcIcon = {}; + T* pT = static_cast(this); + pT->_CalcIconRect(cxWidth, cyHeight, rcIcon); + dc.DrawIconEx(rcIcon.left, rcIcon.top, m_hIconChildMaximized, m_cxIconWidth, m_cyIconHeight); + + // paint right side nonclient background + ::SetRect(&rect, cxWidth - m_cxRight, 0, cxWidth, cyHeight); + if(m_hTheme != NULL) + { + // this is to account for the left non-client area + POINT ptOrg = {}; + dc.GetViewportOrg(&ptOrg); + dc.SetViewportOrg(ptOrg.x + m_cxLeft, ptOrg.y); + ::OffsetRect(&rect, -m_cxLeft, 0); + + ::DrawThemeParentBackground(this->m_hWnd, dc, &rect); + + // restore + dc.SetViewportOrg(ptOrg); + ::OffsetRect(&rect, m_cxLeft, 0); + } + else + { + if((this->m_dwExtendedStyle & CBR_EX_TRANSPARENT) != 0) + dc.FillRect(&rect, COLOR_3DFACE); + else + dc.FillRect(&rect, COLOR_MENU); + } + + // draw buttons + RECT arrRect[3] = {}; + pT->_CalcBtnRects(cxWidth, cyHeight, arrRect); + pT->_DrawMDIButton(dc, arrRect, -1); // draw all buttons + + return lRet; + } + + LRESULT OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) + { + LRESULT lRet = this->DefWindowProc(uMsg, wParam, lParam); + if(m_bChildMaximized) + { + RECT rect = {}; + this->GetWindowRect(&rect); + POINT pt = { GET_X_LPARAM(lParam) - rect.left, GET_Y_LPARAM(lParam) - rect.top }; + if(this->m_bLayoutRTL) + { + if((pt.x < m_cxRight) || (pt.x > ((rect.right - rect.left) - m_cxLeft))) + lRet = HTBORDER; + } + else + { + if((pt.x < m_cxLeft) || (pt.x > ((rect.right - rect.left) - m_cxRight))) + lRet = HTBORDER; + } + } + return lRet; + } + + LRESULT OnNcLButtonDown(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled) + { + if(!m_bChildMaximized) + { + bHandled = FALSE; + return 1; + } + + ATLASSERT(_DebugCheckChild()); + + POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; + RECT rect = {}; + this->GetWindowRect(&rect); + pt.x -= rect.left; + pt.y -= rect.top; + + RECT rcIcon = {}; + T* pT = static_cast(this); + pT->_CalcIconRect(rect.right - rect.left, rect.bottom - rect.top, rcIcon, this->m_bLayoutRTL); + RECT arrRect[3] = {}; + pT->_CalcBtnRects(rect.right - rect.left, rect.bottom - rect.top, arrRect, this->m_bLayoutRTL); + + if(::PtInRect(&rcIcon, pt)) + { +#ifdef _CMDBAR_EXTRA_TRACE + ATLTRACE2(atlTraceUI, 0, _T("MDI CmdBar - LButtonDown: icon\n")); +#endif + CMenuHandle menu = ::GetSystemMenu(m_hWndChildMaximized, FALSE); + UINT uRet = (UINT)menu.TrackPopupMenu(TPM_LEFTBUTTON | TPM_VERTICAL | TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RETURNCMD | + TPM_VERPOSANIMATION, this->m_bLayoutRTL ? rect.right : rect.left, rect.bottom, m_hWndChildMaximized); + + // eat next message if click is on the same button + ::OffsetRect(&rcIcon, rect.left, rect.top); + MSG msg = {}; + if(::PeekMessage(&msg, this->m_hWnd, WM_NCLBUTTONDOWN, WM_NCLBUTTONDOWN, PM_NOREMOVE) && ::PtInRect(&rcIcon, msg.pt)) + ::PeekMessage(&msg, this->m_hWnd, WM_NCLBUTTONDOWN, WM_NCLBUTTONDOWN, PM_REMOVE); + + if(uRet != 0) + ::SendMessage(m_hWndChildMaximized, WM_SYSCOMMAND, uRet, 0L); + } + else if(::PtInRect(&arrRect[0], pt)) + { +#ifdef _CMDBAR_EXTRA_TRACE + ATLTRACE2(atlTraceUI, 0, _T("MDI CmdBar - LButtonDown: close button\n")); +#endif + m_nBtnWasPressed = m_nBtnPressed = 0; + } + else if(::PtInRect(&arrRect[1], pt)) + { +#ifdef _CMDBAR_EXTRA_TRACE + ATLTRACE2(atlTraceUI, 0, _T("MDI CmdBar - LButtonDown: restore button\n")); +#endif + m_nBtnWasPressed = m_nBtnPressed = 1; + } + else if(::PtInRect(&arrRect[2], pt)) + { +#ifdef _CMDBAR_EXTRA_TRACE + ATLTRACE2(atlTraceUI, 0, _T("MDI CmdBar - LButtonDown: minimize button\n")); +#endif + m_nBtnWasPressed = m_nBtnPressed = 2; + } + else + { + bHandled = FALSE; + } + + // draw the button state if it was pressed + if(m_nBtnPressed != -1) + { + this->SetCapture(); + CWindowDC dc(this->m_hWnd); + pT->_CalcBtnRects(rect.right - rect.left, rect.bottom - rect.top, arrRect); + pT->_DrawMDIButton(dc, arrRect, m_nBtnPressed); + } + + return 0; + } + + LRESULT OnMouseMove(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled) + { + if(!m_bChildMaximized || (::GetCapture() != this->m_hWnd) || (m_nBtnWasPressed == -1)) + { + bHandled = FALSE; + return 1; + } + + POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; + this->ClientToScreen(&pt); + RECT rect = {}; + this->GetWindowRect(&rect); + pt.x -= rect.left; + pt.y -= rect.top; + RECT arrRect[3] = {}; + T* pT = static_cast(this); + pT->_CalcBtnRects(rect.right - rect.left, rect.bottom - rect.top, arrRect, this->m_bLayoutRTL); + int nOldBtnPressed = m_nBtnPressed; + m_nBtnPressed = ::PtInRect(&arrRect[m_nBtnWasPressed], pt) ? m_nBtnWasPressed : -1; + if(nOldBtnPressed != m_nBtnPressed) + { + CWindowDC dc(this->m_hWnd); + pT->_CalcBtnRects(rect.right - rect.left, rect.bottom - rect.top, arrRect); + pT->_DrawMDIButton(dc, arrRect, (m_nBtnPressed != -1) ? m_nBtnPressed : nOldBtnPressed); + } + + return 0; + } + + LRESULT OnLButtonUp(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled) + { + if(!m_bChildMaximized || (::GetCapture() != this->m_hWnd) || (m_nBtnWasPressed == -1)) + { + bHandled = FALSE; + return 1; + } + + ATLASSERT(_DebugCheckChild()); + + POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; + this->ClientToScreen(&pt); + RECT rect = {}; + this->GetWindowRect(&rect); + pt.x -= rect.left; + pt.y -= rect.top; + + int nBtn = m_nBtnWasPressed; + ReleaseCapture(); + + RECT arrRect[3] = {}; + T* pT = static_cast(this); + pT->_CalcBtnRects(rect.right - rect.left, rect.bottom - rect.top, arrRect, this->m_bLayoutRTL); + if(::PtInRect(&arrRect[nBtn], pt)) + { + switch(nBtn) + { + case 0: // close +#ifdef _CMDBAR_EXTRA_TRACE + ATLTRACE2(atlTraceUI, 0, _T("MDI CmdBar - LButtonUp: close button\n")); +#endif + ::SendMessage(m_hWndChildMaximized, WM_SYSCOMMAND, SC_CLOSE, 0L); + break; + case 1: // restore +#ifdef _CMDBAR_EXTRA_TRACE + ATLTRACE2(atlTraceUI, 0, _T("MDI CmdBar - LButtonUp: restore button\n")); +#endif + ::SendMessage(m_hWndChildMaximized, WM_SYSCOMMAND, SC_RESTORE, 0L); + break; + case 2: // minimize +#ifdef _CMDBAR_EXTRA_TRACE + ATLTRACE2(atlTraceUI, 0, _T("MDI CmdBar - LButtonUp: minimize button\n")); +#endif + ::SendMessage(m_hWndChildMaximized, WM_SYSCOMMAND, SC_MINIMIZE, 0L); + break; + default: + break; + } + } + + return 0; + } + + LRESULT OnNcLButtonDblClk(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled) + { + if(!m_bChildMaximized || (m_nBtnWasPressed != -1)) + { + bHandled = FALSE; + return 1; + } + + ATLASSERT(_DebugCheckChild()); + + POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; + RECT rect = {}; + this->GetWindowRect(&rect); + pt.x -= rect.left; + pt.y -= rect.top; + + RECT rcIcon = {}; + T* pT = static_cast(this); + pT->_CalcIconRect(rect.right - rect.left, rect.bottom - rect.top, rcIcon, this->m_bLayoutRTL); + RECT arrRect[3] = {}; + pT->_CalcBtnRects(rect.right - rect.left, rect.bottom - rect.top, arrRect, this->m_bLayoutRTL); + + if(::PtInRect(&rcIcon, pt)) + { + CMenuHandle menu = ::GetSystemMenu(m_hWndChildMaximized, FALSE); + UINT uDefID = menu.GetMenuDefaultItem(); + if(uDefID == (UINT)-1) + uDefID = SC_CLOSE; + ::SendMessage(m_hWndChildMaximized, WM_SYSCOMMAND, uDefID, 0L); + } + + return 0; + } + + LRESULT OnCaptureChanged(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) + { + if(m_bChildMaximized) + { + if(m_nBtnPressed != -1) + { + ATLASSERT(m_nBtnPressed == m_nBtnWasPressed); // must be + m_nBtnPressed = -1; + RECT rect = {}; + this->GetWindowRect(&rect); + RECT arrRect[3] = {}; + T* pT = static_cast(this); + pT->_CalcBtnRects(rect.right - rect.left, rect.bottom - rect.top, arrRect); + CWindowDC dc(this->m_hWnd); + pT->_DrawMDIButton(dc, arrRect, m_nBtnWasPressed); + } + m_nBtnWasPressed = -1; + } + else + { + bHandled = FALSE; + } + return 0; + } + +// Parent window message handlers + LRESULT OnParentActivate(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) + { + this->m_bParentActive = (LOWORD(wParam) != WA_INACTIVE); + this->RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_UPDATENOW); + bHandled = FALSE; + return 1; + } + +// MDI client window message handlers + LRESULT OnMDISetMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) + { + m_wndMDIClient.DefWindowProc(uMsg, NULL, lParam); + HMENU hOldMenu = this->GetMenu(); + BOOL bRet = this->AttachMenu((HMENU)wParam); + (void)bRet; // avoid level 4 warning + ATLASSERT(bRet); + + T* pT = static_cast(this); + pT->UpdateRebarBandIdealSize(); + + return (LRESULT)hOldMenu; + } + +// All messages from the message hook + LRESULT OnAllHookMessages(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) + { + T* pT = static_cast(this); + pT->_ProcessAllHookMessages(uMsg, wParam, lParam); + + bHandled = FALSE; + return 1; + } + +// Overrideables + // override this to provide different ideal size + void UpdateRebarBandIdealSize() + { + // assuming we are in a rebar, change ideal size to our size + // we hope that if we are not in a rebar, nCount will be 0 + int nCount = (int)this->GetParent().SendMessage(RB_GETBANDCOUNT, 0, 0L); + for(int i = 0; i < nCount; i++) + { + REBARBANDINFO rbi = { RunTimeHelper::SizeOf_REBARBANDINFO(), RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_IDEALSIZE }; + this->GetParent().SendMessage(RB_GETBANDINFO, i, (LPARAM)&rbi); + if(rbi.hwndChild == this->m_hWnd) + { + rbi.fMask = RBBIM_IDEALSIZE; + rbi.cxIdeal = m_bChildMaximized ? m_cxLeft + m_cxRight : 0; + int nBtnCount = this->GetButtonCount(); + if(nBtnCount > 0) + { + RECT rect = {}; + this->GetItemRect(nBtnCount - 1, &rect); + rbi.cxIdeal += rect.right; + } + this->GetParent().SendMessage(RB_SETBANDINFO, i, (LPARAM)&rbi); + break; + } + } + } + + // all hook messages - check for the maximized MDI child window change + void _ProcessAllHookMessages(UINT uMsg, WPARAM /*wParam*/, LPARAM /*lParam*/) + { + if((uMsg == WM_MDIGETACTIVE) || (uMsg == WM_MDISETMENU)) + return; + + BOOL bMaximized = FALSE; + HWND hWndChild = (HWND)::SendMessage(m_wndMDIClient, WM_MDIGETACTIVE, 0, (LPARAM)&bMaximized); + bool bMaxOld = m_bChildMaximized; + m_bChildMaximized = ((hWndChild != NULL) && bMaximized); + HICON hIconOld = m_hIconChildMaximized; + + if(m_bChildMaximized) + { + if(m_hWndChildMaximized != hWndChild) + { + ATL::CWindow wnd = m_hWndChildMaximized = hWndChild; + m_hIconChildMaximized = wnd.GetIcon(FALSE); + if(m_hIconChildMaximized == NULL) + { + m_hIconChildMaximized = wnd.GetIcon(TRUE); + if(m_hIconChildMaximized == NULL) // no icon set with WM_SETICON, get the class one + m_hIconChildMaximized = (HICON)::GetClassLongPtr(wnd, GCLP_HICONSM); + } + } + } + else + { + m_hWndChildMaximized = NULL; + m_hIconChildMaximized = NULL; + } + + if(bMaxOld != m_bChildMaximized) + { +#ifdef _CMDBAR_EXTRA_TRACE + ATLTRACE2(atlTraceUI, 0, _T("MDI CmdBar - All messages hook change: m_bChildMaximized = %s\n"), m_bChildMaximized ? "true" : "false"); +#endif + // assuming we are in a rebar, change our size to accomodate new state + // we hope that if we are not in a rebar, nCount will be 0 + int nCount = (int)this->GetParent().SendMessage(RB_GETBANDCOUNT, 0, 0L); + int cxDiff = (m_bChildMaximized ? 1 : -1) * (m_cxLeft + m_cxRight); + for(int i = 0; i < nCount; i++) + { + REBARBANDINFO rbi = { RunTimeHelper::SizeOf_REBARBANDINFO(), RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_IDEALSIZE | RBBIM_STYLE }; + this->GetParent().SendMessage(RB_GETBANDINFO, i, (LPARAM)&rbi); + if(rbi.hwndChild == this->m_hWnd) + { + if((rbi.fStyle & RBBS_USECHEVRON) != 0) + { + rbi.fMask = RBBIM_CHILDSIZE | RBBIM_IDEALSIZE; + rbi.cxMinChild += cxDiff; + rbi.cxIdeal += cxDiff; + this->GetParent().SendMessage(RB_SETBANDINFO, i, (LPARAM)&rbi); + } + break; + } + } + } + + if((bMaxOld != m_bChildMaximized) || (hIconOld != m_hIconChildMaximized)) + { + // force size change and redraw everything + RECT rect = {}; + this->GetWindowRect(&rect); + ::MapWindowPoints(NULL, this->GetParent(), (LPPOINT)&rect, 2); + this->SetRedraw(FALSE); + this->SetWindowPos(NULL, 0, 0, 1, 1, SWP_NOZORDER | SWP_NOMOVE); + this->SetWindowPos(NULL, &rect, SWP_NOZORDER | SWP_NOMOVE); + this->SetRedraw(TRUE); + this->RedrawWindow(NULL, NULL, RDW_FRAME | RDW_INVALIDATE | RDW_UPDATENOW); + } + } + +// Implementation + void GetSystemSettings() + { +#ifdef _CMDBAR_EXTRA_TRACE + ATLTRACE2(atlTraceUI, 0, _T("MDI CmdBar - GetSystemSettings\n")); +#endif + _baseClass::GetSystemSettings(); + + NONCLIENTMETRICS info = { RunTimeHelper::SizeOf_NONCLIENTMETRICS() }; + BOOL bRet = ::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(info), &info, 0); + ATLASSERT(bRet); + if(bRet) + { + m_cxIconWidth = ::GetSystemMetrics(SM_CXSMICON); + m_cyIconHeight = ::GetSystemMetrics(SM_CYSMICON); + m_cxLeft = m_cxIconWidth; + + if(m_hTheme != NULL) + { + m_cxBtnWidth = info.iCaptionWidth - 2 * m_cxyOffset; + m_cyBtnHeight = info.iCaptionHeight - 2 * m_cxyOffset; + m_cxRight = 3 * m_cxBtnWidth; + } + else + { + m_cxBtnWidth = info.iCaptionWidth - m_cxyOffset; + m_cyBtnHeight = info.iCaptionHeight - 2 * m_cxyOffset; + m_cxRight = 3 * m_cxBtnWidth + m_cxyOffset; + } + } + + RECT rect = {}; + this->GetClientRect(&rect); + T* pT = static_cast(this); + pT->_AdjustBtnSize(rect.bottom); + } + + void _AdjustBtnSize(int cyHeight) + { + if((cyHeight > 1) && (m_cyBtnHeight > cyHeight)) + { + if(m_hTheme != NULL) + { + m_cyBtnHeight = cyHeight; + m_cxBtnWidth = cyHeight; + m_cxRight = 3 * m_cxBtnWidth; + } + else + { + m_cyBtnHeight = cyHeight; + m_cxBtnWidth = cyHeight + m_cxyOffset; + m_cxRight = 3 * m_cxBtnWidth + m_cxyOffset; + } + } + } + + void _CalcIconRect(int cxWidth, int cyHeight, RECT& rect, bool bInvertX = false) const + { + int xStart = (m_cxLeft - m_cxIconWidth) / 2; + if(xStart < 0) + xStart = 0; + int yStart = (cyHeight - m_cyIconHeight) / 2; + if(yStart < 0) + yStart = 0; + + if(bInvertX) + ::SetRect(&rect, cxWidth - (xStart + m_cxBtnWidth), yStart, cxWidth - xStart, yStart + m_cyBtnHeight); + else + ::SetRect(&rect, xStart, yStart, xStart + m_cxBtnWidth, yStart + m_cyBtnHeight); + } + + void _CalcBtnRects(int cxWidth, int cyHeight, RECT arrRect[3], bool bInvertX = false) const + { + int yStart = (cyHeight - m_cyBtnHeight) / 2; + if(yStart < 0) + yStart = 0; + + RECT rcBtn = { cxWidth - m_cxBtnWidth, yStart, cxWidth, yStart + m_cyBtnHeight }; + int nDirection = -1; + if(bInvertX) + { + ::SetRect(&rcBtn, 0, yStart, m_cxBtnWidth, yStart + m_cyBtnHeight); + nDirection = 1; + } + + arrRect[0] = rcBtn; + if(m_hTheme != NULL) + ::OffsetRect(&rcBtn, nDirection * m_cxBtnWidth, 0); + else + ::OffsetRect(&rcBtn, nDirection * (m_cxBtnWidth + m_cxyOffset), 0); + arrRect[1] = rcBtn; + ::OffsetRect(&rcBtn, nDirection * m_cxBtnWidth, 0); + arrRect[2] = rcBtn; + } + + void _DrawMDIButton(CWindowDC& dc, LPRECT pRects, int nBtn) + { + if(m_hTheme != NULL) + { +#ifndef __VSSYM32_H__ + const int WP_MDICLOSEBUTTON = 20; + const int CBS_NORMAL = 1; + const int CBS_PUSHED = 3; + const int CBS_DISABLED = 4; + const int WP_MDIRESTOREBUTTON = 22; + const int RBS_NORMAL = 1; + const int RBS_PUSHED = 3; + const int RBS_DISABLED = 4; + const int WP_MDIMINBUTTON = 16; + const int MINBS_NORMAL = 1; + const int MINBS_PUSHED = 3; + const int MINBS_DISABLED = 4; +#endif // __VSSYM32_H__ + if((nBtn == -1) || (nBtn == 0)) + ::DrawThemeBackground(m_hTheme, dc, WP_MDICLOSEBUTTON, this->m_bParentActive ? ((m_nBtnPressed == 0) ? CBS_PUSHED : CBS_NORMAL) : CBS_DISABLED, &pRects[0], NULL); + if((nBtn == -1) || (nBtn == 1)) + ::DrawThemeBackground(m_hTheme, dc, WP_MDIRESTOREBUTTON, this->m_bParentActive ? ((m_nBtnPressed == 1) ? RBS_PUSHED : RBS_NORMAL) : RBS_DISABLED, &pRects[1], NULL); + if((nBtn == -1) || (nBtn == 2)) + ::DrawThemeBackground(m_hTheme, dc, WP_MDIMINBUTTON, this->m_bParentActive ? ((m_nBtnPressed == 2) ? MINBS_PUSHED : MINBS_NORMAL) : MINBS_DISABLED, &pRects[2], NULL); + } + else + { + if((nBtn == -1) || (nBtn == 0)) + dc.DrawFrameControl(&pRects[0], DFC_CAPTION, DFCS_CAPTIONCLOSE | ((m_nBtnPressed == 0) ? DFCS_PUSHED : 0)); + if((nBtn == -1) || (nBtn == 1)) + dc.DrawFrameControl(&pRects[1], DFC_CAPTION, DFCS_CAPTIONRESTORE | ((m_nBtnPressed == 1) ? DFCS_PUSHED : 0)); + if((nBtn == -1) || (nBtn == 2)) + dc.DrawFrameControl(&pRects[2], DFC_CAPTION, DFCS_CAPTIONMIN | ((m_nBtnPressed == 2) ? DFCS_PUSHED : 0)); + } + } + + static UINT _GetThemeChangedMsg() + { +#ifndef WM_THEMECHANGED + static const UINT WM_THEMECHANGED = 0x031A; +#endif // !WM_THEMECHANGED + return WM_THEMECHANGED; + } + + void _OpenThemeData() + { + if(RunTimeHelper::IsThemeAvailable()) + m_hTheme = ::OpenThemeData(this->m_hWnd, L"Window"); + } + + void _CloseThemeData() + { + if(m_hTheme != NULL) + { + ::CloseThemeData(m_hTheme); + m_hTheme = NULL; + } + } + + bool _DebugCheckChild() + { +#ifdef _DEBUG + BOOL bMaximized = FALSE; + HWND hWndChild = (HWND)::SendMessage(m_wndMDIClient, WM_MDIGETACTIVE, 0, (LPARAM)&bMaximized); + return (bMaximized && (hWndChild == m_hWndChildMaximized)); +#else // !_DEBUG + return true; +#endif // !_DEBUG + } +}; + +class CMDICommandBarCtrl : public CMDICommandBarCtrlImpl +{ +public: + DECLARE_WND_SUPERCLASS(_T("WTL_MDICommandBar"), GetWndClassName()) +}; + +} // namespace WTL + +#endif // __ATLCTRLW_H__ diff -r e9bb126753e7 -r 20d02a178406 foosdk/wtl/Include/atlctrlx.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/wtl/Include/atlctrlx.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,5256 @@ +// Windows Template Library - WTL version 10.0 +// Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. +// +// This file is a part of the Windows Template Library. +// The use and distribution terms for this software are covered by the +// Microsoft Public License (http://opensource.org/licenses/MS-PL) +// which can be found in the file MS-PL.txt at the root folder. + +#ifndef __ATLCTRLX_H__ +#define __ATLCTRLX_H__ + +#pragma once + +#ifndef __ATLAPP_H__ + #error atlctrlx.h requires atlapp.h to be included first +#endif + +#ifndef __ATLCTRLS_H__ + #error atlctrlx.h requires atlctrls.h to be included first +#endif + + +/////////////////////////////////////////////////////////////////////////////// +// Classes in this file: +// +// CBitmapButtonImpl +// CBitmapButton +// CCheckListViewCtrlImpl +// CCheckListViewCtrl +// CHyperLinkImpl +// CHyperLink +// CWaitCursor +// CCustomWaitCursor +// CMultiPaneStatusBarCtrlImpl +// CMultiPaneStatusBarCtrl +// CPaneContainerImpl +// CPaneContainer +// CSortListViewImpl +// CSortListViewCtrlImpl +// CSortListViewCtrl +// CTabViewImpl +// CTabView + +namespace WTL +{ + +/////////////////////////////////////////////////////////////////////////////// +// CBitmapButton - bitmap button implementation + +// bitmap button extended styles +#define BMPBTN_HOVER 0x00000001 +#define BMPBTN_AUTO3D_SINGLE 0x00000002 +#define BMPBTN_AUTO3D_DOUBLE 0x00000004 +#define BMPBTN_AUTOSIZE 0x00000008 +#define BMPBTN_SHAREIMAGELISTS 0x00000010 +#define BMPBTN_AUTOFIRE 0x00000020 +#define BMPBTN_CHECK 0x00000040 +#define BMPBTN_AUTOCHECK 0x00000080 + +// Note: BMPBTN_CHECK/BMPBTN_AUTOCHECK disables BN_DOUBLECLICKED, +// BMPBTN_AUTOFIRE doesn't work with BMPBTN_CHECK/BMPBTN_AUTOCHECK + +template +class ATL_NO_VTABLE CBitmapButtonImpl : public ATL::CWindowImpl< T, TBase, TWinTraits > +{ +public: + DECLARE_WND_SUPERCLASS2(NULL, T, TBase::GetWndClassName()) + + enum + { + _nImageNormal = 0, + _nImagePushed, + _nImageFocusOrHover, + _nImageDisabled, + + _nImageCount = 4, + }; + + enum + { + ID_TIMER_FIRST = 1000, + ID_TIMER_REPEAT = 1001 + }; + + // Bitmap button specific extended styles + DWORD m_dwExtendedStyle; + + CImageList m_ImageList; + int m_nImage[_nImageCount]; + + CToolTipCtrl m_tip; + LPTSTR m_lpstrToolTipText; + + // Internal states + unsigned m_fMouseOver:1; + unsigned m_fFocus:1; + unsigned m_fPressed:1; + unsigned m_fChecked:1; + + +// Constructor/Destructor + CBitmapButtonImpl(DWORD dwExtendedStyle = BMPBTN_AUTOSIZE, HIMAGELIST hImageList = NULL) : + m_dwExtendedStyle(dwExtendedStyle), m_ImageList(hImageList), + m_lpstrToolTipText(NULL), + m_fMouseOver(0), m_fFocus(0), m_fPressed(0), m_fChecked(0) + { + m_nImage[_nImageNormal] = -1; + m_nImage[_nImagePushed] = -1; + m_nImage[_nImageFocusOrHover] = -1; + m_nImage[_nImageDisabled] = -1; + +#ifdef _DEBUG + if(((m_dwExtendedStyle & BMPBTN_AUTOFIRE) != 0) && IsCheckMode()) + ATLTRACE2(atlTraceUI, 0, _T("CBitmapButtonImpl - Check mode and BMPBTN_AUTOFIRE cannot be used together, BMPBTN_AUTOFIRE will be ignored.\n")); +#endif // _DEBUG + } + + ~CBitmapButtonImpl() + { + if((m_dwExtendedStyle & BMPBTN_SHAREIMAGELISTS) == 0) + m_ImageList.Destroy(); + delete [] m_lpstrToolTipText; + } + + // overridden to provide proper initialization + BOOL SubclassWindow(HWND hWnd) + { + BOOL bRet = ATL::CWindowImpl< T, TBase, TWinTraits >::SubclassWindow(hWnd); + if(bRet != FALSE) + { + T* pT = static_cast(this); + pT->Init(); + } + + return bRet; + } + +// Attributes + DWORD GetBitmapButtonExtendedStyle() const + { + return m_dwExtendedStyle; + } + + DWORD SetBitmapButtonExtendedStyle(DWORD dwExtendedStyle, DWORD dwMask = 0) + { + DWORD dwPrevStyle = m_dwExtendedStyle; + if(dwMask == 0) + m_dwExtendedStyle = dwExtendedStyle; + else + m_dwExtendedStyle = (m_dwExtendedStyle & ~dwMask) | (dwExtendedStyle & dwMask); + +#ifdef _DEBUG + if(((m_dwExtendedStyle & BMPBTN_AUTOFIRE) != 0) && IsCheckMode()) + ATLTRACE2(atlTraceUI, 0, _T("CBitmapButtonImpl - Check mode and BMPBTN_AUTOFIRE cannot be used together, BMPBTN_AUTOFIRE will be ignored.\n")); +#endif // _DEBUG + + return dwPrevStyle; + } + + HIMAGELIST GetImageList() const + { + return m_ImageList; + } + + HIMAGELIST SetImageList(HIMAGELIST hImageList) + { + HIMAGELIST hImageListPrev = m_ImageList; + m_ImageList = hImageList; + if(((m_dwExtendedStyle & BMPBTN_AUTOSIZE) != 0) && ::IsWindow(this->m_hWnd)) + SizeToImage(); + + return hImageListPrev; + } + + int GetToolTipTextLength() const + { + return (m_lpstrToolTipText == NULL) ? -1 : lstrlen(m_lpstrToolTipText); + } + + bool GetToolTipText(LPTSTR lpstrText, int nLength) const + { + ATLASSERT(lpstrText != NULL); + if(m_lpstrToolTipText == NULL) + return false; + + errno_t nRet = ATL::Checked::tcsncpy_s(lpstrText, nLength, m_lpstrToolTipText, _TRUNCATE); + + return ((nRet == 0) || (nRet == STRUNCATE)); + } + + bool SetToolTipText(LPCTSTR lpstrText) + { + if(m_lpstrToolTipText != NULL) + { + delete [] m_lpstrToolTipText; + m_lpstrToolTipText = NULL; + } + + if(lpstrText == NULL) + { + if(m_tip.IsWindow()) + m_tip.Activate(FALSE); + return true; + } + + int cchLen = lstrlen(lpstrText) + 1; + ATLTRY(m_lpstrToolTipText = new TCHAR[cchLen]); + if(m_lpstrToolTipText == NULL) + return false; + + ATL::Checked::tcscpy_s(m_lpstrToolTipText, cchLen, lpstrText); + if(m_tip.IsWindow()) + { + m_tip.Activate(TRUE); + m_tip.AddTool(this->m_hWnd, m_lpstrToolTipText); + } + + return true; + } + + bool GetCheck() const + { + return (m_fChecked == 1); + } + + void SetCheck(bool bCheck, bool bUpdate = true) + { + m_fChecked = bCheck ? 1 : 0; + + if(bUpdate) + { + this->Invalidate(); + this->UpdateWindow(); + } + } + +// Operations + void SetImages(int nNormal, int nPushed = -1, int nFocusOrHover = -1, int nDisabled = -1) + { + if(nNormal != -1) + m_nImage[_nImageNormal] = nNormal; + if(nPushed != -1) + m_nImage[_nImagePushed] = nPushed; + if(nFocusOrHover != -1) + m_nImage[_nImageFocusOrHover] = nFocusOrHover; + if(nDisabled != -1) + m_nImage[_nImageDisabled] = nDisabled; + } + + BOOL SizeToImage() + { + ATLASSERT(::IsWindow(this->m_hWnd) && (m_ImageList.m_hImageList != NULL)); + int cx = 0; + int cy = 0; + if(!m_ImageList.GetIconSize(cx, cy)) + return FALSE; + return this->ResizeClient(cx, cy); + } + +// Overrideables + void DoPaint(CDCHandle dc) + { + ATLASSERT(m_ImageList.m_hImageList != NULL); // image list must be set + ATLASSERT(m_nImage[0] != -1); // main bitmap must be set + + // set bitmap according to the current button state + bool bHover = IsHoverMode(); + bool bPressed = (m_fPressed == 1) || (IsCheckMode() && (m_fChecked == 1)); + int nImage = -1; + if(!this->IsWindowEnabled()) + nImage = m_nImage[_nImageDisabled]; + else if(bPressed) + nImage = m_nImage[_nImagePushed]; + else if((!bHover && (m_fFocus == 1)) || (bHover && (m_fMouseOver == 1))) + nImage = m_nImage[_nImageFocusOrHover]; + + // if none is set, use default one + if(nImage == -1) + nImage = m_nImage[_nImageNormal]; + + // draw the button image + bool bAuto3D = (m_dwExtendedStyle & (BMPBTN_AUTO3D_SINGLE | BMPBTN_AUTO3D_DOUBLE)) != 0; + int xyPos = (bPressed && bAuto3D && (m_nImage[_nImagePushed] == -1)) ? 1 : 0; + m_ImageList.Draw(dc, nImage, xyPos, xyPos, ILD_NORMAL); + + // draw 3D border if required + if(bAuto3D) + { + RECT rect = {}; + this->GetClientRect(&rect); + + if(bPressed) + dc.DrawEdge(&rect, ((m_dwExtendedStyle & BMPBTN_AUTO3D_SINGLE) != 0) ? BDR_SUNKENOUTER : EDGE_SUNKEN, BF_RECT); + else if(!bHover || (m_fMouseOver == 1)) + dc.DrawEdge(&rect, ((m_dwExtendedStyle & BMPBTN_AUTO3D_SINGLE) != 0) ? BDR_RAISEDINNER : EDGE_RAISED, BF_RECT); + + if(!bHover && (m_fFocus == 1)) + { + ::InflateRect(&rect, -2 * ::GetSystemMetrics(SM_CXEDGE), -2 * ::GetSystemMetrics(SM_CYEDGE)); + dc.DrawFocusRect(&rect); + } + } + } + +// Message map and handlers + BEGIN_MSG_MAP(CBitmapButtonImpl) + MESSAGE_HANDLER(WM_CREATE, OnCreate) + MESSAGE_HANDLER(WM_DESTROY, OnDestroy) + MESSAGE_RANGE_HANDLER(WM_MOUSEFIRST, WM_MOUSELAST, OnMouseMessage) + MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground) + MESSAGE_HANDLER(WM_PAINT, OnPaint) + MESSAGE_HANDLER(WM_PRINTCLIENT, OnPaint) + MESSAGE_HANDLER(WM_SETFOCUS, OnFocus) + MESSAGE_HANDLER(WM_KILLFOCUS, OnFocus) + MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown) + MESSAGE_HANDLER(WM_LBUTTONDBLCLK, OnLButtonDblClk) + MESSAGE_HANDLER(WM_LBUTTONUP, OnLButtonUp) + MESSAGE_HANDLER(WM_CAPTURECHANGED, OnCaptureChanged) + MESSAGE_HANDLER(WM_ENABLE, OnEnable) + MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove) + MESSAGE_HANDLER(WM_MOUSELEAVE, OnMouseLeave) + MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown) + MESSAGE_HANDLER(WM_KEYUP, OnKeyUp) + MESSAGE_HANDLER(WM_TIMER, OnTimer) + MESSAGE_HANDLER(WM_UPDATEUISTATE, OnUpdateUiState) + END_MSG_MAP() + + LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) + { + T* pT = static_cast(this); + pT->Init(); + + bHandled = FALSE; + return 1; + } + + LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) + { + if(m_tip.IsWindow()) + { + m_tip.DestroyWindow(); + m_tip.m_hWnd = NULL; + } + bHandled = FALSE; + return 1; + } + + LRESULT OnMouseMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) + { + MSG msg = { this->m_hWnd, uMsg, wParam, lParam }; + if(m_tip.IsWindow()) + m_tip.RelayEvent(&msg); + bHandled = FALSE; + return 1; + } + + LRESULT OnEraseBackground(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + return 1; // no background needed + } + + LRESULT OnPaint(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + T* pT = static_cast(this); + if(wParam != NULL) + { + pT->DoPaint((HDC)wParam); + } + else + { + CPaintDC dc(this->m_hWnd); + pT->DoPaint(dc.m_hDC); + } + return 0; + } + + LRESULT OnFocus(UINT uMsg, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) + { + m_fFocus = (uMsg == WM_SETFOCUS) ? 1 : 0; + this->Invalidate(); + this->UpdateWindow(); + bHandled = FALSE; + return 1; + } + + LRESULT OnLButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) + { + LRESULT lRet = 0; + if(IsHoverMode()) + this->SetCapture(); + else + lRet = this->DefWindowProc(uMsg, wParam, lParam); + if(::GetCapture() == this->m_hWnd) + { + m_fPressed = 1; + this->Invalidate(); + this->UpdateWindow(); + } + if(((m_dwExtendedStyle & BMPBTN_AUTOFIRE) != 0) && !IsCheckMode()) + { + int nElapse = 250; + int nDelay = 0; + if(::SystemParametersInfo(SPI_GETKEYBOARDDELAY, 0, &nDelay, 0)) + nElapse += nDelay * 250; // all milli-seconds + this->SetTimer(ID_TIMER_FIRST, nElapse); + } + return lRet; + } + + LRESULT OnLButtonDblClk(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) + { + LRESULT lRet = 0; + if(!IsHoverMode() && !IsCheckMode()) + lRet = this->DefWindowProc(uMsg, wParam, lParam); + if(::GetCapture() != this->m_hWnd) + this->SetCapture(); + if(m_fPressed == 0) + { + m_fPressed = 1; + this->Invalidate(); + this->UpdateWindow(); + } + return lRet; + } + + LRESULT OnLButtonUp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) + { + if(((m_dwExtendedStyle & BMPBTN_AUTOCHECK) != 0) && (m_fPressed == 1)) + SetCheck(!GetCheck(), false); + + LRESULT lRet = 0; + if(!IsHoverMode() && !IsCheckMode()) + lRet = this->DefWindowProc(uMsg, wParam, lParam); + if(::GetCapture() == this->m_hWnd) + { + if((IsHoverMode() || IsCheckMode()) && (m_fPressed == 1)) + this->GetParent().SendMessage(WM_COMMAND, MAKEWPARAM(this->GetDlgCtrlID(), BN_CLICKED), (LPARAM)this->m_hWnd); + ::ReleaseCapture(); + } + return lRet; + } + + LRESULT OnCaptureChanged(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) + { + if(m_fPressed == 1) + { + m_fPressed = 0; + this->Invalidate(); + this->UpdateWindow(); + } + bHandled = FALSE; + return 1; + } + + LRESULT OnEnable(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) + { + this->Invalidate(); + this->UpdateWindow(); + bHandled = FALSE; + return 1; + } + + LRESULT OnMouseMove(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled) + { + if(::GetCapture() == this->m_hWnd) + { + POINT ptCursor = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; + this->ClientToScreen(&ptCursor); + RECT rect = {}; + this->GetWindowRect(&rect); + unsigned int uPressed = ::PtInRect(&rect, ptCursor) ? 1 : 0; + if(m_fPressed != uPressed) + { + m_fPressed = uPressed; + this->Invalidate(); + this->UpdateWindow(); + } + } + else if(IsHoverMode() && m_fMouseOver == 0) + { + m_fMouseOver = 1; + this->Invalidate(); + this->UpdateWindow(); + StartTrackMouseLeave(); + } + bHandled = FALSE; + return 1; + } + + LRESULT OnMouseLeave(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + if(m_fMouseOver == 1) + { + m_fMouseOver = 0; + this->Invalidate(); + this->UpdateWindow(); + } + return 0; + } + + LRESULT OnKeyDown(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) + { + if((wParam == VK_SPACE) && IsHoverMode()) + return 0; // ignore if in hover mode + if((wParam == VK_SPACE) && (m_fPressed == 0)) + { + m_fPressed = 1; + this->Invalidate(); + this->UpdateWindow(); + } + bHandled = FALSE; + return 1; + } + + LRESULT OnKeyUp(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) + { + if((wParam == VK_SPACE) && IsHoverMode()) + return 0; // ignore if in hover mode + if((wParam == VK_SPACE) && (m_fPressed == 1)) + { + m_fPressed = 0; + if((m_dwExtendedStyle & BMPBTN_AUTOCHECK) != 0) + SetCheck(!GetCheck(), false); + this->Invalidate(); + this->UpdateWindow(); + } + bHandled = FALSE; + return 1; + } + + LRESULT OnTimer(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + ATLASSERT((m_dwExtendedStyle & BMPBTN_AUTOFIRE) != 0); + switch(wParam) // timer ID + { + case ID_TIMER_FIRST: + this->KillTimer(ID_TIMER_FIRST); + if(m_fPressed == 1) + { + this->GetParent().SendMessage(WM_COMMAND, MAKEWPARAM(this->GetDlgCtrlID(), BN_CLICKED), (LPARAM)this->m_hWnd); + int nElapse = 250; + int nRepeat = 40; + if(::SystemParametersInfo(SPI_GETKEYBOARDSPEED, 0, &nRepeat, 0)) + nElapse = 10000 / (10 * nRepeat + 25); // milli-seconds, approximated + this->SetTimer(ID_TIMER_REPEAT, nElapse); + } + break; + case ID_TIMER_REPEAT: + if(m_fPressed == 1) + this->GetParent().SendMessage(WM_COMMAND, MAKEWPARAM(this->GetDlgCtrlID(), BN_CLICKED), (LPARAM)this->m_hWnd); + else if(::GetCapture() != this->m_hWnd) + this->KillTimer(ID_TIMER_REPEAT); + break; + default: // not our timer + break; + } + return 0; + } + + LRESULT OnUpdateUiState(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + // If the control is subclassed or superclassed, this message can cause + // repainting without WM_PAINT. We don't use this state, so just do nothing. + return 0; + } + +// Implementation + void Init() + { + // We need this style to prevent Windows from painting the button + this->ModifyStyle(0, BS_OWNERDRAW); + + // create a tool tip + m_tip.Create(this->m_hWnd); + ATLASSERT(m_tip.IsWindow()); + if(m_tip.IsWindow() && (m_lpstrToolTipText != NULL)) + { + m_tip.Activate(TRUE); + m_tip.AddTool(this->m_hWnd, m_lpstrToolTipText); + } + + if((m_ImageList.m_hImageList != NULL) && ((m_dwExtendedStyle & BMPBTN_AUTOSIZE) != 0)) + SizeToImage(); + } + + BOOL StartTrackMouseLeave() + { + TRACKMOUSEEVENT tme = {}; + tme.cbSize = sizeof(tme); + tme.dwFlags = TME_LEAVE; + tme.hwndTrack = this->m_hWnd; + return ::TrackMouseEvent(&tme); + } + + bool IsHoverMode() const + { + return ((m_dwExtendedStyle & BMPBTN_HOVER) != 0); + } + + bool IsCheckMode() const + { + return ((m_dwExtendedStyle & (BMPBTN_CHECK | BMPBTN_AUTOCHECK)) != 0); + } +}; + +class CBitmapButton : public CBitmapButtonImpl +{ +public: + DECLARE_WND_SUPERCLASS(_T("WTL_BitmapButton"), GetWndClassName()) + + CBitmapButton(DWORD dwExtendedStyle = BMPBTN_AUTOSIZE, HIMAGELIST hImageList = NULL) : + CBitmapButtonImpl(dwExtendedStyle, hImageList) + { } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CCheckListCtrlView - list view control with check boxes + +template +class CCheckListViewCtrlImplTraits +{ +public: + static DWORD GetWndStyle(DWORD dwStyle) + { + return (dwStyle == 0) ? t_dwStyle : dwStyle; + } + + static DWORD GetWndExStyle(DWORD dwExStyle) + { + return (dwExStyle == 0) ? t_dwExStyle : dwExStyle; + } + + static DWORD GetExtendedLVStyle() + { + return t_dwExListViewStyle; + } +}; + +typedef CCheckListViewCtrlImplTraits CCheckListViewCtrlTraits; + +template +class ATL_NO_VTABLE CCheckListViewCtrlImpl : public ATL::CWindowImpl +{ +public: + DECLARE_WND_SUPERCLASS2(NULL, T, TBase::GetWndClassName()) + +// Attributes + static DWORD GetExtendedLVStyle() + { + return TWinTraits::GetExtendedLVStyle(); + } + +// Operations + BOOL SubclassWindow(HWND hWnd) + { + BOOL bRet = ATL::CWindowImpl< T, TBase, TWinTraits >::SubclassWindow(hWnd); + if(bRet != FALSE) + { + T* pT = static_cast(this); + pT->Init(); + } + + return bRet; + } + + void CheckSelectedItems(int nCurrItem) + { + // first check if this item is selected + LVITEM lvi = {}; + lvi.iItem = nCurrItem; + lvi.iSubItem = 0; + lvi.mask = LVIF_STATE; + lvi.stateMask = LVIS_SELECTED; + this->GetItem(&lvi); + // if item is not selected, don't do anything + if(!(lvi.state & LVIS_SELECTED)) + return; + // new check state will be reverse of the current state, + BOOL bCheck = !this->GetCheckState(nCurrItem); + int nItem = -1; + int nOldItem = -1; + while((nItem = this->GetNextItem(nOldItem, LVNI_SELECTED)) != -1) + { + if(nItem != nCurrItem) + this->SetCheckState(nItem, bCheck); + nOldItem = nItem; + } + } + +// Implementation + void Init() + { + T* pT = static_cast(this); + (void)pT; // avoid level 4 warning + ATLASSERT((pT->GetExtendedLVStyle() & LVS_EX_CHECKBOXES) != 0); + this->SetExtendedListViewStyle(pT->GetExtendedLVStyle()); + } + +// Message map and handlers + BEGIN_MSG_MAP(CCheckListViewCtrlImpl) + MESSAGE_HANDLER(WM_CREATE, OnCreate) + MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown) + MESSAGE_HANDLER(WM_LBUTTONDBLCLK, OnLButtonDown) + MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown) + END_MSG_MAP() + + LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) + { + // first let list view control initialize everything + LRESULT lRet = this->DefWindowProc(uMsg, wParam, lParam); + if(lRet == 0) + { + T* pT = static_cast(this); + pT->Init(); + } + + return lRet; + } + + LRESULT OnLButtonDown(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled) + { + POINT ptMsg = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; + LVHITTESTINFO lvh = {}; + lvh.pt = ptMsg; + if((this->HitTest(&lvh) != -1) && (lvh.flags == LVHT_ONITEMSTATEICON) && (::GetKeyState(VK_CONTROL) >= 0)) + { + T* pT = static_cast(this); + pT->CheckSelectedItems(lvh.iItem); + } + bHandled = FALSE; + return 1; + } + + LRESULT OnKeyDown(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) + { + if(wParam == VK_SPACE) + { + int nCurrItem = this->GetNextItem(-1, LVNI_FOCUSED); + if((nCurrItem != -1) && (::GetKeyState(VK_CONTROL) >= 0)) + { + T* pT = static_cast(this); + pT->CheckSelectedItems(nCurrItem); + } + } + bHandled = FALSE; + return 1; + } +}; + +class CCheckListViewCtrl : public CCheckListViewCtrlImpl +{ +public: + DECLARE_WND_SUPERCLASS(_T("WTL_CheckListView"), GetWndClassName()) +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CHyperLink - hyper link control implementation + +#define HLINK_UNDERLINED 0x00000000 +#define HLINK_NOTUNDERLINED 0x00000001 +#define HLINK_UNDERLINEHOVER 0x00000002 +#define HLINK_COMMANDBUTTON 0x00000004 +#define HLINK_NOTIFYBUTTON 0x0000000C +#define HLINK_USETAGS 0x00000010 +#define HLINK_USETAGSBOLD 0x00000030 +#define HLINK_NOTOOLTIP 0x00000040 +#define HLINK_AUTOCREATELINKFONT 0x00000080 +#define HLINK_SINGLELINE 0x00000100 + +// Notes: +// - HLINK_USETAGS and HLINK_USETAGSBOLD are always left-aligned +// - When HLINK_USETAGSBOLD is used, the underlined styles will be ignored + +template +class ATL_NO_VTABLE CHyperLinkImpl : public ATL::CWindowImpl< T, TBase, TWinTraits > +{ +public: + LPTSTR m_lpstrLabel; + LPTSTR m_lpstrHyperLink; + + HCURSOR m_hCursor; + HFONT m_hFontLink; + HFONT m_hFontNormal; + + RECT m_rcLink; + CToolTipCtrl m_tip; + + COLORREF m_clrLink; + COLORREF m_clrVisited; + + DWORD m_dwExtendedStyle; // Hyper Link specific extended styles + + bool m_bPaintLabel:1; + bool m_bVisited:1; + bool m_bHover:1; + bool m_bInternalLinkFont:1; + bool m_bInternalNormalFont:1; + + +// Constructor/Destructor + CHyperLinkImpl(DWORD dwExtendedStyle = HLINK_UNDERLINED) : + m_lpstrLabel(NULL), m_lpstrHyperLink(NULL), + m_hCursor(NULL), m_hFontLink(NULL), m_hFontNormal(NULL), + m_clrLink(RGB(0, 0, 255)), m_clrVisited(RGB(128, 0, 128)), + m_dwExtendedStyle(dwExtendedStyle), + m_bPaintLabel(true), m_bVisited(false), + m_bHover(false), m_bInternalLinkFont(false), m_bInternalNormalFont(false) + { + ::SetRectEmpty(&m_rcLink); + } + + ~CHyperLinkImpl() + { + delete [] m_lpstrLabel; + delete [] m_lpstrHyperLink; + } + +// Attributes + DWORD GetHyperLinkExtendedStyle() const + { + return m_dwExtendedStyle; + } + + DWORD SetHyperLinkExtendedStyle(DWORD dwExtendedStyle, DWORD dwMask = 0) + { + DWORD dwPrevStyle = m_dwExtendedStyle; + if(dwMask == 0) + m_dwExtendedStyle = dwExtendedStyle; + else + m_dwExtendedStyle = (m_dwExtendedStyle & ~dwMask) | (dwExtendedStyle & dwMask); + return dwPrevStyle; + } + + bool GetLabel(LPTSTR lpstrBuffer, int nLength) const + { + if(m_lpstrLabel == NULL) + return false; + ATLASSERT(lpstrBuffer != NULL); + if(nLength <= lstrlen(m_lpstrLabel)) + return false; + + ATL::Checked::tcscpy_s(lpstrBuffer, nLength, m_lpstrLabel); + + return true; + } + + bool SetLabel(LPCTSTR lpstrLabel) + { + delete [] m_lpstrLabel; + m_lpstrLabel = NULL; + int cchLen = lstrlen(lpstrLabel) + 1; + ATLTRY(m_lpstrLabel = new TCHAR[cchLen]); + if(m_lpstrLabel == NULL) + return false; + + ATL::Checked::tcscpy_s(m_lpstrLabel, cchLen, lpstrLabel); + T* pT = static_cast(this); + pT->CalcLabelRect(); + + if(this->m_hWnd != NULL) + this->SetWindowText(lpstrLabel); // Set this for accessibility + + return true; + } + + bool GetHyperLink(LPTSTR lpstrBuffer, int nLength) const + { + if(m_lpstrHyperLink == NULL) + return false; + ATLASSERT(lpstrBuffer != NULL); + if(nLength <= lstrlen(m_lpstrHyperLink)) + return false; + + ATL::Checked::tcscpy_s(lpstrBuffer, nLength, m_lpstrHyperLink); + + return true; + } + + bool SetHyperLink(LPCTSTR lpstrLink) + { + delete [] m_lpstrHyperLink; + m_lpstrHyperLink = NULL; + int cchLen = lstrlen(lpstrLink) + 1; + ATLTRY(m_lpstrHyperLink = new TCHAR[cchLen]); + if(m_lpstrHyperLink == NULL) + return false; + + ATL::Checked::tcscpy_s(m_lpstrHyperLink, cchLen, lpstrLink); + if(m_lpstrLabel == NULL) + { + T* pT = static_cast(this); + pT->CalcLabelRect(); + } + + if(m_tip.IsWindow()) + { + m_tip.Activate(TRUE); + m_tip.AddTool(this->m_hWnd, m_lpstrHyperLink, &m_rcLink, 1); + } + + return true; + } + + HFONT GetLinkFont() const + { + return m_hFontLink; + } + + void SetLinkFont(HFONT hFont) + { + if(m_bInternalLinkFont) + { + ::DeleteObject(m_hFontLink); + m_bInternalLinkFont = false; + } + + m_hFontLink = hFont; + + T* pT = static_cast(this); + pT->CalcLabelRect(); + } + + int GetIdealHeight() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + if((m_lpstrLabel == NULL) && (m_lpstrHyperLink == NULL)) + return -1; + if(!m_bPaintLabel) + return -1; + + UINT uFormat = IsSingleLine() ? DT_SINGLELINE : DT_WORDBREAK; + + CClientDC dc(this->m_hWnd); + RECT rect = {}; + this->GetClientRect(&rect); + HFONT hFontOld = dc.SelectFont(m_hFontNormal); + RECT rcText = rect; + dc.DrawText(_T("NS"), -1, &rcText, DT_LEFT | uFormat | DT_CALCRECT); + dc.SelectFont(m_hFontLink); + RECT rcLink = rect; + dc.DrawText(_T("NS"), -1, &rcLink, DT_LEFT | uFormat | DT_CALCRECT); + dc.SelectFont(hFontOld); + return __max(rcText.bottom - rcText.top, rcLink.bottom - rcLink.top); + } + + bool GetIdealSize(SIZE& size) const + { + int cx = 0, cy = 0; + bool bRet = GetIdealSize(cx, cy); + if(bRet) + { + size.cx = cx; + size.cy = cy; + } + return bRet; + } + + bool GetIdealSize(int& cx, int& cy) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + if((m_lpstrLabel == NULL) && (m_lpstrHyperLink == NULL)) + return false; + if(!m_bPaintLabel) + return false; + + CClientDC dc(this->m_hWnd); + RECT rcClient = {}; + this->GetClientRect(&rcClient); + RECT rcAll = rcClient; + + if(IsUsingTags()) + { + // find tags and label parts + LPTSTR lpstrLeft = NULL; + int cchLeft = 0; + LPTSTR lpstrLink = NULL; + int cchLink = 0; + LPTSTR lpstrRight = NULL; + int cchRight = 0; + + const T* pT = static_cast(this); + pT->CalcLabelParts(lpstrLeft, cchLeft, lpstrLink, cchLink, lpstrRight, cchRight); + + // get label part rects + UINT uFormat = IsSingleLine() ? DT_SINGLELINE : DT_WORDBREAK; + + HFONT hFontOld = dc.SelectFont(m_hFontNormal); + RECT rcLeft = rcClient; + dc.DrawText(lpstrLeft, cchLeft, &rcLeft, DT_LEFT | uFormat | DT_CALCRECT); + + dc.SelectFont(m_hFontLink); + RECT rcLink = { rcLeft.right, rcLeft.top, rcClient.right, rcClient.bottom }; + dc.DrawText(lpstrLink, cchLink, &rcLink, DT_LEFT | uFormat | DT_CALCRECT); + + dc.SelectFont(m_hFontNormal); + RECT rcRight = { rcLink.right, rcLink.top, rcClient.right, rcClient.bottom }; + dc.DrawText(lpstrRight, cchRight, &rcRight, DT_LEFT | uFormat | DT_CALCRECT); + + dc.SelectFont(hFontOld); + + int cyMax = __max(rcLeft.bottom, __max(rcLink.bottom, rcRight.bottom)); + ::SetRect(&rcAll, rcLeft.left, rcLeft.top, rcRight.right, cyMax); + } + else + { + HFONT hOldFont = NULL; + if(m_hFontLink != NULL) + hOldFont = dc.SelectFont(m_hFontLink); + LPTSTR lpstrText = (m_lpstrLabel != NULL) ? m_lpstrLabel : m_lpstrHyperLink; + DWORD dwStyle = this->GetStyle(); + UINT uFormat = DT_LEFT; + if (dwStyle & SS_CENTER) + uFormat = DT_CENTER; + else if (dwStyle & SS_RIGHT) + uFormat = DT_RIGHT; + uFormat |= IsSingleLine() ? DT_SINGLELINE : DT_WORDBREAK; + dc.DrawText(lpstrText, -1, &rcAll, uFormat | DT_CALCRECT); + if(m_hFontLink != NULL) + dc.SelectFont(hOldFont); + if (dwStyle & SS_CENTER) + { + int dx = (rcClient.right - rcAll.right) / 2; + ::OffsetRect(&rcAll, dx, 0); + } + else if (dwStyle & SS_RIGHT) + { + int dx = rcClient.right - rcAll.right; + ::OffsetRect(&rcAll, dx, 0); + } + } + + cx = rcAll.right - rcAll.left; + cy = rcAll.bottom - rcAll.top; + + return true; + } + + // for command buttons only + bool GetToolTipText(LPTSTR lpstrBuffer, int nLength) const + { + ATLASSERT(IsCommandButton()); + return GetHyperLink(lpstrBuffer, nLength); + } + + bool SetToolTipText(LPCTSTR lpstrToolTipText) + { + ATLASSERT(IsCommandButton()); + return SetHyperLink(lpstrToolTipText); + } + +// Operations + BOOL SubclassWindow(HWND hWnd) + { + ATLASSERT(this->m_hWnd == NULL); + ATLASSERT(::IsWindow(hWnd)); + if(m_hFontNormal == NULL) + m_hFontNormal = (HFONT)::SendMessage(hWnd, WM_GETFONT, 0, 0L); + + BOOL bRet = ATL::CWindowImpl< T, TBase, TWinTraits >::SubclassWindow(hWnd); + if(bRet != FALSE) + { + T* pT = static_cast(this); + pT->Init(); + } + + return bRet; + } + + bool Navigate() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + bool bRet = true; + if(IsNotifyButton()) + { + NMHDR nmhdr = { this->m_hWnd, (UINT_PTR)this->GetDlgCtrlID(), NM_CLICK }; + this->GetParent().SendMessage(WM_NOTIFY, this->GetDlgCtrlID(), (LPARAM)&nmhdr); + } + else if(IsCommandButton()) + { + this->GetParent().SendMessage(WM_COMMAND, MAKEWPARAM(this->GetDlgCtrlID(), BN_CLICKED), (LPARAM)this->m_hWnd); + } + else + { + ATLASSERT(m_lpstrHyperLink != NULL); + DWORD_PTR dwRet = (DWORD_PTR)::ShellExecute(0, _T("open"), m_lpstrHyperLink, 0, 0, SW_SHOWNORMAL); + bRet = (dwRet > 32); + ATLASSERT(bRet); + if(bRet) + { + m_bVisited = true; + this->Invalidate(); + } + } + return bRet; + } + + void CreateLinkFontFromNormal() + { + if(m_bInternalLinkFont) + { + ::DeleteObject(m_hFontLink); + m_bInternalLinkFont = false; + } + + CFontHandle font = (m_hFontNormal != NULL) ? m_hFontNormal : (HFONT)::GetStockObject(SYSTEM_FONT); + LOGFONT lf = {}; + font.GetLogFont(&lf); + + if(IsUsingTagsBold()) + lf.lfWeight = FW_BOLD; + else if(!IsNotUnderlined()) + lf.lfUnderline = TRUE; + + m_hFontLink = ::CreateFontIndirect(&lf); + m_bInternalLinkFont = true; + ATLASSERT(m_hFontLink != NULL); + } + +// Message map and handlers + BEGIN_MSG_MAP(CHyperLinkImpl) + MESSAGE_HANDLER(WM_CREATE, OnCreate) + MESSAGE_HANDLER(WM_DESTROY, OnDestroy) + MESSAGE_RANGE_HANDLER(WM_MOUSEFIRST, WM_MOUSELAST, OnMouseMessage) + MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground) + MESSAGE_HANDLER(WM_PAINT, OnPaint) + MESSAGE_HANDLER(WM_PRINTCLIENT, OnPaint) + MESSAGE_HANDLER(WM_SETFOCUS, OnFocus) + MESSAGE_HANDLER(WM_KILLFOCUS, OnFocus) + MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove) + MESSAGE_HANDLER(WM_MOUSELEAVE, OnMouseLeave) + MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown) + MESSAGE_HANDLER(WM_LBUTTONUP, OnLButtonUp) + MESSAGE_HANDLER(WM_CHAR, OnChar) + MESSAGE_HANDLER(WM_GETDLGCODE, OnGetDlgCode) + MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor) + MESSAGE_HANDLER(WM_ENABLE, OnEnable) + MESSAGE_HANDLER(WM_GETFONT, OnGetFont) + MESSAGE_HANDLER(WM_SETFONT, OnSetFont) + MESSAGE_HANDLER(WM_UPDATEUISTATE, OnUpdateUiState) + MESSAGE_HANDLER(WM_SIZE, OnSize) + END_MSG_MAP() + + LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + T* pT = static_cast(this); + pT->Init(); + return 0; + } + + LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) + { + if(m_tip.IsWindow()) + { + m_tip.DestroyWindow(); + m_tip.m_hWnd = NULL; + } + + if(m_bInternalLinkFont) + { + ::DeleteObject(m_hFontLink); + m_hFontLink = NULL; + m_bInternalLinkFont = false; + } + + if(m_bInternalNormalFont) + { + ::DeleteObject(m_hFontNormal); + m_hFontNormal = NULL; + m_bInternalNormalFont = false; + } + + bHandled = FALSE; + return 1; + } + + LRESULT OnMouseMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) + { + MSG msg = { this->m_hWnd, uMsg, wParam, lParam }; + if(m_tip.IsWindow() && IsUsingToolTip()) + m_tip.RelayEvent(&msg); + bHandled = FALSE; + return 1; + } + + LRESULT OnEraseBackground(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + return 1; // no background painting needed (we do it all during WM_PAINT) + } + + LRESULT OnPaint(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) + { + if(!m_bPaintLabel) + { + bHandled = FALSE; + return 1; + } + + T* pT = static_cast(this); + if(wParam != NULL) + { + pT->DoEraseBackground((HDC)wParam); + pT->DoPaint((HDC)wParam); + } + else + { + CPaintDC dc(this->m_hWnd); + pT->DoEraseBackground(dc.m_hDC); + pT->DoPaint(dc.m_hDC); + } + + return 0; + } + + LRESULT OnFocus(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) + { + if(m_bPaintLabel) + this->Invalidate(); + else + bHandled = FALSE; + return 0; + } + + LRESULT OnMouseMove(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled) + { + POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; + if(((m_lpstrHyperLink != NULL) || IsCommandButton()) && ::PtInRect(&m_rcLink, pt)) + { + ::SetCursor(m_hCursor); + if(IsUnderlineHover()) + { + if(!m_bHover) + { + m_bHover = true; + this->InvalidateRect(&m_rcLink); + this->UpdateWindow(); + StartTrackMouseLeave(); + } + } + } + else + { + if(IsUnderlineHover()) + { + if(m_bHover) + { + m_bHover = false; + this->InvalidateRect(&m_rcLink); + this->UpdateWindow(); + } + } + bHandled = FALSE; + } + return 0; + } + + LRESULT OnMouseLeave(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + if(IsUnderlineHover() && m_bHover) + { + m_bHover = false; + this->InvalidateRect(&m_rcLink); + this->UpdateWindow(); + } + return 0; + } + + LRESULT OnLButtonDown(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/) + { + POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; + if(::PtInRect(&m_rcLink, pt)) + { + this->SetFocus(); + this->SetCapture(); + } + return 0; + } + + LRESULT OnLButtonUp(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/) + { + if(GetCapture() == this->m_hWnd) + { + ReleaseCapture(); + POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; + if(::PtInRect(&m_rcLink, pt)) + { + T* pT = static_cast(this); + pT->Navigate(); + } + } + return 0; + } + + LRESULT OnChar(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + if((wParam == VK_RETURN) || (wParam == VK_SPACE)) + { + T* pT = static_cast(this); + pT->Navigate(); + } + return 0; + } + + LRESULT OnGetDlgCode(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + return DLGC_WANTCHARS; + } + + LRESULT OnSetCursor(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) + { + POINT pt = {}; + GetCursorPos(&pt); + this->ScreenToClient(&pt); + if(((m_lpstrHyperLink != NULL) || IsCommandButton()) && ::PtInRect(&m_rcLink, pt)) + { + return TRUE; + } + bHandled = FALSE; + return FALSE; + } + + LRESULT OnEnable(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + this->Invalidate(); + this->UpdateWindow(); + return 0; + } + + LRESULT OnGetFont(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + return (LRESULT)m_hFontNormal; + } + + LRESULT OnSetFont(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) + { + if(m_bInternalNormalFont) + { + ::DeleteObject(m_hFontNormal); + m_bInternalNormalFont = false; + } + + bool bCreateLinkFont = m_bInternalLinkFont; + + m_hFontNormal = (HFONT)wParam; + + if(bCreateLinkFont || IsAutoCreateLinkFont()) + CreateLinkFontFromNormal(); + + T* pT = static_cast(this); + pT->CalcLabelRect(); + + if((BOOL)lParam) + { + this->Invalidate(); + this->UpdateWindow(); + } + + return 0; + } + + LRESULT OnUpdateUiState(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + // If the control is subclassed or superclassed, this message can cause + // repainting without WM_PAINT. We don't use this state, so just do nothing. + return 0; + } + + LRESULT OnSize(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + T* pT = static_cast(this); + pT->CalcLabelRect(); + pT->Invalidate(); + return 0; + } + +// Implementation + void Init() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + + // Check if we should paint a label + const int cchBuff = 8; + TCHAR szBuffer[cchBuff] = {}; + if(::GetClassName(this->m_hWnd, szBuffer, cchBuff)) + { + if(lstrcmpi(szBuffer, _T("static")) == 0) + { + this->ModifyStyle(0, SS_NOTIFY); // we need this + DWORD dwStyle = this->GetStyle() & 0x000000FF; + if((dwStyle == SS_ICON) || (dwStyle == SS_BLACKRECT) || (dwStyle == SS_GRAYRECT) || + (dwStyle == SS_WHITERECT) || (dwStyle == SS_BLACKFRAME) || (dwStyle == SS_GRAYFRAME) || + (dwStyle == SS_WHITEFRAME) || (dwStyle == SS_OWNERDRAW) || + (dwStyle == SS_BITMAP) || (dwStyle == SS_ENHMETAFILE)) + m_bPaintLabel = false; + } + } + + // create or load a cursor + m_hCursor = ::LoadCursor(NULL, IDC_HAND); + ATLASSERT(m_hCursor != NULL); + + // set fonts + if(m_bPaintLabel) + { + if(m_hFontNormal == NULL) + { + m_hFontNormal = AtlCreateControlFont(); + m_bInternalNormalFont = true; + } + + if(m_hFontLink == NULL) + CreateLinkFontFromNormal(); + } + + // create a tool tip + m_tip.Create(this->m_hWnd); + ATLASSERT(m_tip.IsWindow()); + + // set label (defaults to window text) + if(m_lpstrLabel == NULL) + { + int nLen = this->GetWindowTextLength(); + if(nLen > 0) + { + ATLTRY(m_lpstrLabel = new TCHAR[nLen + 1]); + if(m_lpstrLabel != NULL) + ATLVERIFY(this->GetWindowText(m_lpstrLabel, nLen + 1) > 0); + } + } + + T* pT = static_cast(this); + pT->CalcLabelRect(); + + // set hyperlink (defaults to label), or just activate tool tip if already set + if((m_lpstrHyperLink == NULL) && !IsCommandButton()) + { + if(m_lpstrLabel != NULL) + SetHyperLink(m_lpstrLabel); + } + else + { + m_tip.Activate(TRUE); + m_tip.AddTool(this->m_hWnd, m_lpstrHyperLink, &m_rcLink, 1); + } + + // set link colors + if(m_bPaintLabel) + { + ATL::CRegKey rk; + LONG lRet = rk.Open(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Internet Explorer\\Settings")); + if(lRet == ERROR_SUCCESS) + { + const int cchValue = 12; + TCHAR szValue[cchValue] = {}; + ULONG ulCount = cchValue; + lRet = rk.QueryStringValue(_T("Anchor Color"), szValue, &ulCount); + if(lRet == ERROR_SUCCESS) + { + COLORREF clr = pT->_ParseColorString(szValue); + ATLASSERT(clr != CLR_INVALID); + if(clr != CLR_INVALID) + m_clrLink = clr; + } + + ulCount = cchValue; + lRet = rk.QueryStringValue(_T("Anchor Color Visited"), szValue, &ulCount); + if(lRet == ERROR_SUCCESS) + { + COLORREF clr = pT->_ParseColorString(szValue); + ATLASSERT(clr != CLR_INVALID); + if(clr != CLR_INVALID) + m_clrVisited = clr; + } + } + } + } + + static COLORREF _ParseColorString(LPTSTR lpstr) + { + int c[3] = { -1, -1, -1 }; + LPTSTR p = NULL; + for(int i = 0; i < 2; i++) + { + for(p = lpstr; *p != _T('\0'); p = ::CharNext(p)) + { + if(*p == _T(',')) + { + *p = _T('\0'); + c[i] = _ttoi(lpstr); + lpstr = &p[1]; + break; + } + } + if(c[i] == -1) + return CLR_INVALID; + } + if(*lpstr == _T('\0')) + return CLR_INVALID; + c[2] = _ttoi(lpstr); + + return RGB(c[0], c[1], c[2]); + } + + bool CalcLabelRect() + { + if(!::IsWindow(this->m_hWnd)) + return false; + if((m_lpstrLabel == NULL) && (m_lpstrHyperLink == NULL)) + return false; + + CClientDC dc(this->m_hWnd); + RECT rcClient = {}; + this->GetClientRect(&rcClient); + m_rcLink = rcClient; + if(!m_bPaintLabel) + return true; + + if(IsUsingTags()) + { + // find tags and label parts + LPTSTR lpstrLeft = NULL; + int cchLeft = 0; + LPTSTR lpstrLink = NULL; + int cchLink = 0; + LPTSTR lpstrRight = NULL; + int cchRight = 0; + + T* pT = static_cast(this); + pT->CalcLabelParts(lpstrLeft, cchLeft, lpstrLink, cchLink, lpstrRight, cchRight); + ATLASSERT(lpstrLink != NULL); + ATLASSERT(cchLink > 0); + + // get label part rects + HFONT hFontOld = dc.SelectFont(m_hFontNormal); + + UINT uFormat = IsSingleLine() ? DT_SINGLELINE : DT_WORDBREAK; + + RECT rcLeft = rcClient; + if(lpstrLeft != NULL) + dc.DrawText(lpstrLeft, cchLeft, &rcLeft, DT_LEFT | uFormat | DT_CALCRECT); + + dc.SelectFont(m_hFontLink); + RECT rcLink = rcClient; + if(lpstrLeft != NULL) + rcLink.left = rcLeft.right; + dc.DrawText(lpstrLink, cchLink, &rcLink, DT_LEFT | uFormat | DT_CALCRECT); + + dc.SelectFont(hFontOld); + + m_rcLink = rcLink; + } + else + { + HFONT hOldFont = NULL; + if(m_hFontLink != NULL) + hOldFont = dc.SelectFont(m_hFontLink); + LPTSTR lpstrText = (m_lpstrLabel != NULL) ? m_lpstrLabel : m_lpstrHyperLink; + DWORD dwStyle = this->GetStyle(); + UINT uFormat = DT_LEFT; + if (dwStyle & SS_CENTER) + uFormat = DT_CENTER; + else if (dwStyle & SS_RIGHT) + uFormat = DT_RIGHT; + uFormat |= IsSingleLine() ? DT_SINGLELINE : DT_WORDBREAK; + dc.DrawText(lpstrText, -1, &m_rcLink, uFormat | DT_CALCRECT); + if(m_hFontLink != NULL) + dc.SelectFont(hOldFont); + if (dwStyle & SS_CENTER) + { + int dx = (rcClient.right - m_rcLink.right) / 2; + ::OffsetRect(&m_rcLink, dx, 0); + } + else if (dwStyle & SS_RIGHT) + { + int dx = rcClient.right - m_rcLink.right; + ::OffsetRect(&m_rcLink, dx, 0); + } + } + + return true; + } + + void CalcLabelParts(LPTSTR& lpstrLeft, int& cchLeft, LPTSTR& lpstrLink, int& cchLink, LPTSTR& lpstrRight, int& cchRight) const + { + lpstrLeft = NULL; + cchLeft = 0; + lpstrLink = NULL; + cchLink = 0; + lpstrRight = NULL; + cchRight = 0; + + LPTSTR lpstrText = (m_lpstrLabel != NULL) ? m_lpstrLabel : m_lpstrHyperLink; + int cchText = lstrlen(lpstrText); + bool bOutsideLink = true; + for(int i = 0; i < cchText; i++) + { + if(lpstrText[i] != _T('<')) + continue; + + if(bOutsideLink) + { + if(::CompareString(LOCALE_USER_DEFAULT, NORM_IGNORECASE, &lpstrText[i], 3, _T(""), 3) == CSTR_EQUAL) + { + if(i > 0) + { + lpstrLeft = lpstrText; + cchLeft = i; + } + lpstrLink = &lpstrText[i + 3]; + bOutsideLink = false; + } + } + else + { + if(::CompareString(LOCALE_USER_DEFAULT, NORM_IGNORECASE, &lpstrText[i], 4, _T(""), 4) == CSTR_EQUAL) + { + cchLink = i - 3 - cchLeft; + if(lpstrText[i + 4] != 0) + { + lpstrRight = &lpstrText[i + 4]; + cchRight = cchText - (i + 4); + break; + } + } + } + } + + } + + void DoEraseBackground(CDCHandle dc) + { + HBRUSH hBrush = (HBRUSH)this->GetParent().SendMessage(WM_CTLCOLORSTATIC, (WPARAM)dc.m_hDC, (LPARAM)this->m_hWnd); + if(hBrush != NULL) + { + RECT rect = {}; + this->GetClientRect(&rect); + dc.FillRect(&rect, hBrush); + } + } + + void DoPaint(CDCHandle dc) + { + if(IsUsingTags()) + { + // find tags and label parts + LPTSTR lpstrLeft = NULL; + int cchLeft = 0; + LPTSTR lpstrLink = NULL; + int cchLink = 0; + LPTSTR lpstrRight = NULL; + int cchRight = 0; + + T* pT = static_cast(this); + pT->CalcLabelParts(lpstrLeft, cchLeft, lpstrLink, cchLink, lpstrRight, cchRight); + + // get label part rects + RECT rcClient = {}; + this->GetClientRect(&rcClient); + + dc.SetBkMode(TRANSPARENT); + HFONT hFontOld = dc.SelectFont(m_hFontNormal); + + UINT uFormat = IsSingleLine() ? DT_SINGLELINE : DT_WORDBREAK; + + if(lpstrLeft != NULL) + dc.DrawText(lpstrLeft, cchLeft, &rcClient, DT_LEFT | uFormat); + + COLORREF clrOld = dc.SetTextColor(this->IsWindowEnabled() ? (m_bVisited ? m_clrVisited : m_clrLink) : (::GetSysColor(COLOR_GRAYTEXT))); + if((m_hFontLink != NULL) && (!IsUnderlineHover() || (IsUnderlineHover() && m_bHover))) + dc.SelectFont(m_hFontLink); + else + dc.SelectFont(m_hFontNormal); + + dc.DrawText(lpstrLink, cchLink, &m_rcLink, DT_LEFT | uFormat); + + dc.SetTextColor(clrOld); + dc.SelectFont(m_hFontNormal); + if(lpstrRight != NULL) + { + RECT rcRight = { m_rcLink.right, m_rcLink.top, rcClient.right, rcClient.bottom }; + dc.DrawText(lpstrRight, cchRight, &rcRight, DT_LEFT | uFormat); + } + + if(GetFocus() == this->m_hWnd) + dc.DrawFocusRect(&m_rcLink); + + dc.SelectFont(hFontOld); + } + else + { + dc.SetBkMode(TRANSPARENT); + COLORREF clrOld = dc.SetTextColor(this->IsWindowEnabled() ? (m_bVisited ? m_clrVisited : m_clrLink) : (::GetSysColor(COLOR_GRAYTEXT))); + + HFONT hFontOld = NULL; + if((m_hFontLink != NULL) && (!IsUnderlineHover() || (IsUnderlineHover() && m_bHover))) + hFontOld = dc.SelectFont(m_hFontLink); + else + hFontOld = dc.SelectFont(m_hFontNormal); + + LPTSTR lpstrText = (m_lpstrLabel != NULL) ? m_lpstrLabel : m_lpstrHyperLink; + + DWORD dwStyle = this->GetStyle(); + UINT uFormat = DT_LEFT; + if (dwStyle & SS_CENTER) + uFormat = DT_CENTER; + else if (dwStyle & SS_RIGHT) + uFormat = DT_RIGHT; + uFormat |= IsSingleLine() ? DT_SINGLELINE : DT_WORDBREAK; + + dc.DrawText(lpstrText, -1, &m_rcLink, uFormat); + + if(GetFocus() == this->m_hWnd) + dc.DrawFocusRect(&m_rcLink); + + dc.SetTextColor(clrOld); + dc.SelectFont(hFontOld); + } + } + + BOOL StartTrackMouseLeave() + { + TRACKMOUSEEVENT tme = {}; + tme.cbSize = sizeof(tme); + tme.dwFlags = TME_LEAVE; + tme.hwndTrack = this->m_hWnd; + return ::TrackMouseEvent(&tme); + } + +// Implementation helpers + bool IsUnderlined() const + { + return ((m_dwExtendedStyle & (HLINK_NOTUNDERLINED | HLINK_UNDERLINEHOVER)) == 0); + } + + bool IsNotUnderlined() const + { + return ((m_dwExtendedStyle & HLINK_NOTUNDERLINED) != 0); + } + + bool IsUnderlineHover() const + { + return ((m_dwExtendedStyle & HLINK_UNDERLINEHOVER) != 0); + } + + bool IsCommandButton() const + { + return ((m_dwExtendedStyle & HLINK_COMMANDBUTTON) != 0); + } + + bool IsNotifyButton() const + { + return ((m_dwExtendedStyle & HLINK_NOTIFYBUTTON) == HLINK_NOTIFYBUTTON); + } + + bool IsUsingTags() const + { + return ((m_dwExtendedStyle & HLINK_USETAGS) != 0); + } + + bool IsUsingTagsBold() const + { + return ((m_dwExtendedStyle & HLINK_USETAGSBOLD) == HLINK_USETAGSBOLD); + } + + bool IsUsingToolTip() const + { + return ((m_dwExtendedStyle & HLINK_NOTOOLTIP) == 0); + } + + bool IsAutoCreateLinkFont() const + { + return ((m_dwExtendedStyle & HLINK_AUTOCREATELINKFONT) == HLINK_AUTOCREATELINKFONT); + } + + bool IsSingleLine() const + { + return ((m_dwExtendedStyle & HLINK_SINGLELINE) == HLINK_SINGLELINE); + } +}; + +class CHyperLink : public CHyperLinkImpl +{ +public: + DECLARE_WND_CLASS(_T("WTL_HyperLink")) +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CWaitCursor - displays a wait cursor + +class CWaitCursor +{ +public: +// Data + HCURSOR m_hWaitCursor; + HCURSOR m_hOldCursor; + bool m_bInUse; + +// Constructor/destructor + CWaitCursor(bool bSet = true, LPCTSTR lpstrCursor = IDC_WAIT, bool bSys = true) : m_hOldCursor(NULL), m_bInUse(false) + { + HINSTANCE hInstance = bSys ? NULL : ModuleHelper::GetResourceInstance(); + m_hWaitCursor = ::LoadCursor(hInstance, lpstrCursor); + ATLASSERT(m_hWaitCursor != NULL); + + if(bSet) + Set(); + } + + ~CWaitCursor() + { + Restore(); + } + +// Methods + bool Set() + { + if(m_bInUse) + return false; + m_hOldCursor = ::SetCursor(m_hWaitCursor); + m_bInUse = true; + return true; + } + + bool Restore() + { + if(!m_bInUse) + return false; + ::SetCursor(m_hOldCursor); + m_bInUse = false; + return true; + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CCustomWaitCursor - for custom and animated cursors + +class CCustomWaitCursor : public CWaitCursor +{ +public: +// Constructor/destructor + CCustomWaitCursor(ATL::_U_STRINGorID cursor, bool bSet = true, HINSTANCE hInstance = NULL) : + CWaitCursor(false, IDC_WAIT, true) + { + if(hInstance == NULL) + hInstance = ModuleHelper::GetResourceInstance(); + m_hWaitCursor = (HCURSOR)::LoadImage(hInstance, cursor.m_lpstr, IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE); + + if(bSet) + Set(); + } + + ~CCustomWaitCursor() + { + Restore(); + ::DestroyCursor(m_hWaitCursor); + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CMultiPaneStatusBarCtrl - Status Bar with multiple panes + +template +class ATL_NO_VTABLE CMultiPaneStatusBarCtrlImpl : public ATL::CWindowImpl< T, TBase > +{ +public: + DECLARE_WND_SUPERCLASS2(NULL, T, TBase::GetWndClassName()) + +// Data + enum { m_cxPaneMargin = 3 }; + + int m_nPanes; + int* m_pPane; + +// Constructor/destructor + CMultiPaneStatusBarCtrlImpl() : m_nPanes(0), m_pPane(NULL) + { } + + ~CMultiPaneStatusBarCtrlImpl() + { + delete [] m_pPane; + } + +// Methods + HWND Create(HWND hWndParent, LPCTSTR lpstrText, DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | SBARS_SIZEGRIP, UINT nID = ATL_IDW_STATUS_BAR) + { + return ATL::CWindowImpl< T, TBase >::Create(hWndParent, this->rcDefault, lpstrText, dwStyle, 0, nID); + } + + HWND Create(HWND hWndParent, UINT nTextID = ATL_IDS_IDLEMESSAGE, DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | SBARS_SIZEGRIP, UINT nID = ATL_IDW_STATUS_BAR) + { + const int cchMax = 128; // max text length is 127 for status bars (+1 for null) + TCHAR szText[cchMax] = {}; + ::LoadString(ModuleHelper::GetResourceInstance(), nTextID, szText, cchMax); + return Create(hWndParent, szText, dwStyle, nID); + } + + BOOL SetPanes(int* pPanes, int nPanes, bool bSetText = true) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(nPanes > 0); + + m_nPanes = nPanes; + delete [] m_pPane; + m_pPane = NULL; + + ATLTRY(m_pPane = new int[nPanes]); + ATLASSERT(m_pPane != NULL); + if(m_pPane == NULL) + return FALSE; + + ATL::CTempBuffer buff; + int* pPanesPos = buff.Allocate(nPanes); + ATLASSERT(pPanesPos != NULL); + if(pPanesPos == NULL) + return FALSE; + + ATL::Checked::memcpy_s(m_pPane, nPanes * sizeof(int), pPanes, nPanes * sizeof(int)); + + // get status bar DC and set font + CClientDC dc(this->m_hWnd); + HFONT hOldFont = dc.SelectFont(this->GetFont()); + + // get status bar borders + int arrBorders[3] = {}; + this->GetBorders(arrBorders); + + const int cchBuff = 128; + TCHAR szBuff[cchBuff] = {}; + int cxLeft = arrBorders[0]; + + // calculate right edge of each part + for(int i = 0; i < nPanes; i++) + { + if(pPanes[i] == ID_DEFAULT_PANE) + { + // make very large, will be resized later + pPanesPos[i] = INT_MAX / 2; + } + else + { + ::LoadString(ModuleHelper::GetResourceInstance(), pPanes[i], szBuff, cchBuff); + SIZE size = {}; + dc.GetTextExtent(szBuff, lstrlen(szBuff), &size); + T* pT = static_cast(this); + (void)pT; // avoid level 4 warning + pPanesPos[i] = cxLeft + size.cx + arrBorders[2] + 2 * pT->m_cxPaneMargin; + } + cxLeft = pPanesPos[i]; + } + + BOOL bRet = this->SetParts(nPanes, pPanesPos); + + if(bRet && bSetText) + { + for(int i = 0; i < nPanes; i++) + { + if(pPanes[i] != ID_DEFAULT_PANE) + { + ::LoadString(ModuleHelper::GetResourceInstance(), pPanes[i], szBuff, cchBuff); + SetPaneText(m_pPane[i], szBuff); + } + } + } + + dc.SelectFont(hOldFont); + return bRet; + } + + bool GetPaneTextLength(int nPaneID, int* pcchLength = NULL, int* pnType = NULL) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + int nIndex = GetPaneIndexFromID(nPaneID); + if(nIndex == -1) + return false; + + int nLength = this->GetTextLength(nIndex, pnType); + if(pcchLength != NULL) + *pcchLength = nLength; + + return true; + } + + BOOL GetPaneText(int nPaneID, LPTSTR lpstrText, int* pcchLength = NULL, int* pnType = NULL) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + int nIndex = GetPaneIndexFromID(nPaneID); + if(nIndex == -1) + return FALSE; + + int nLength = this->GetText(nIndex, lpstrText, pnType); + if(pcchLength != NULL) + *pcchLength = nLength; + + return TRUE; + } + +#ifdef __ATLSTR_H__ + BOOL GetPaneText(int nPaneID, ATL::CString& strText, int* pcchLength = NULL, int* pnType = NULL) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + int nIndex = GetPaneIndexFromID(nPaneID); + if(nIndex == -1) + return FALSE; + + int nLength = this->GetText(nIndex, strText, pnType); + if(pcchLength != NULL) + *pcchLength = nLength; + + return TRUE; + } +#endif // __ATLSTR_H__ + + BOOL SetPaneText(int nPaneID, LPCTSTR lpstrText, int nType = 0) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + int nIndex = GetPaneIndexFromID(nPaneID); + if(nIndex == -1) + return FALSE; + + return this->SetText(nIndex, lpstrText, nType); + } + + BOOL GetPaneRect(int nPaneID, LPRECT lpRect) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + int nIndex = GetPaneIndexFromID(nPaneID); + if(nIndex == -1) + return FALSE; + + return this->GetRect(nIndex, lpRect); + } + + BOOL SetPaneWidth(int nPaneID, int cxWidth) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(nPaneID != ID_DEFAULT_PANE); // Can't resize this one + int nIndex = GetPaneIndexFromID(nPaneID); + if(nIndex == -1) + return FALSE; + + // get pane positions + ATL::CTempBuffer buff; + int* pPanesPos = buff.Allocate(m_nPanes); + if(pPanesPos == NULL) + return FALSE; + this->GetParts(m_nPanes, pPanesPos); + // calculate offset + int cxPaneWidth = pPanesPos[nIndex] - ((nIndex == 0) ? 0 : pPanesPos[nIndex - 1]); + int cxOff = cxWidth - cxPaneWidth; + // find variable width pane + int nDef = m_nPanes; + for(int i = 0; i < m_nPanes; i++) + { + if(m_pPane[i] == ID_DEFAULT_PANE) + { + nDef = i; + break; + } + } + // resize + if(nIndex < nDef) // before default pane + { + for(int i = nIndex; i < nDef; i++) + pPanesPos[i] += cxOff; + + } + else // after default one + { + for(int i = nDef; i < nIndex; i++) + pPanesPos[i] -= cxOff; + } + // set pane postions + return this->SetParts(m_nPanes, pPanesPos); + } + + BOOL GetPaneTipText(int nPaneID, LPTSTR lpstrText, int nSize) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + int nIndex = GetPaneIndexFromID(nPaneID); + if(nIndex == -1) + return FALSE; + + this->GetTipText(nIndex, lpstrText, nSize); + return TRUE; + } + + BOOL SetPaneTipText(int nPaneID, LPCTSTR lpstrText) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + int nIndex = GetPaneIndexFromID(nPaneID); + if(nIndex == -1) + return FALSE; + + this->SetTipText(nIndex, lpstrText); + return TRUE; + } + + BOOL GetPaneIcon(int nPaneID, HICON& hIcon) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + int nIndex = GetPaneIndexFromID(nPaneID); + if(nIndex == -1) + return FALSE; + + hIcon = this->GetIcon(nIndex); + return TRUE; + } + + BOOL SetPaneIcon(int nPaneID, HICON hIcon) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + int nIndex = GetPaneIndexFromID(nPaneID); + if(nIndex == -1) + return FALSE; + + return this->SetIcon(nIndex, hIcon); + } + +// Message map and handlers + BEGIN_MSG_MAP(CMultiPaneStatusBarCtrlImpl< T >) + MESSAGE_HANDLER(WM_SIZE, OnSize) + END_MSG_MAP() + + LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) + { + LRESULT lRet = this->DefWindowProc(uMsg, wParam, lParam); + if((wParam != SIZE_MINIMIZED) && (m_nPanes > 0)) + { + T* pT = static_cast(this); + pT->UpdatePanesLayout(); + } + return lRet; + } + +// Implementation + BOOL UpdatePanesLayout() + { + // get pane positions + ATL::CTempBuffer buff; + int* pPanesPos = buff.Allocate(m_nPanes); + ATLASSERT(pPanesPos != NULL); + if(pPanesPos == NULL) + return FALSE; + int nRet = this->GetParts(m_nPanes, pPanesPos); + ATLASSERT(nRet == m_nPanes); + if(nRet != m_nPanes) + return FALSE; + // calculate offset + RECT rcClient = {}; + this->GetClientRect(&rcClient); + int cxOff = rcClient.right - pPanesPos[m_nPanes - 1]; + // Move panes left if size grip box is present + if((this->GetStyle() & SBARS_SIZEGRIP) != 0) + cxOff -= ::GetSystemMetrics(SM_CXVSCROLL) + ::GetSystemMetrics(SM_CXEDGE); + // find variable width pane + int i; + for(i = 0; i < m_nPanes; i++) + { + if(m_pPane[i] == ID_DEFAULT_PANE) + break; + } + // resize all panes from the variable one to the right + if((i < m_nPanes) && (pPanesPos[i] + cxOff) > ((i == 0) ? 0 : pPanesPos[i - 1])) + { + for(; i < m_nPanes; i++) + pPanesPos[i] += cxOff; + } + // set pane postions + return this->SetParts(m_nPanes, pPanesPos); + } + + int GetPaneIndexFromID(int nPaneID) const + { + for(int i = 0; i < m_nPanes; i++) + { + if(m_pPane[i] == nPaneID) + return i; + } + + return -1; // not found + } +}; + +class CMultiPaneStatusBarCtrl : public CMultiPaneStatusBarCtrlImpl +{ +public: + DECLARE_WND_SUPERCLASS(_T("WTL_MultiPaneStatusBar"), GetWndClassName()) +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CPaneContainer - provides header with title and close button for panes + +// pane container extended styles +#define PANECNT_NOCLOSEBUTTON 0x00000001 +#define PANECNT_VERTICAL 0x00000002 +#define PANECNT_FLATBORDER 0x00000004 +#define PANECNT_NOBORDER 0x00000008 +#define PANECNT_DIVIDER 0x00000010 +#define PANECNT_GRADIENT 0x00000020 + +template +class ATL_NO_VTABLE CPaneContainerImpl : public ATL::CWindowImpl< T, TBase, TWinTraits >, public CCustomDraw< T > +{ +public: + DECLARE_WND_CLASS_EX2(NULL, T, 0, -1) + +// Constants + enum + { + m_cxyBorder = 2, + m_cxyTextOffset = 4, + m_cxyBtnOffset = 1, + + m_cchTitle = 80, + + m_cxImageTB = 13, + m_cyImageTB = 11, + m_cxyBtnAddTB = 7, + + m_cxToolBar = m_cxImageTB + m_cxyBtnAddTB + m_cxyBorder + m_cxyBtnOffset, + + m_xBtnImageLeft = 6, + m_yBtnImageTop = 5, + m_xBtnImageRight = 12, + m_yBtnImageBottom = 11, + + m_nCloseBtnID = ID_PANE_CLOSE + }; + +// Data members + CToolBarCtrl m_tb; + ATL::CWindow m_wndClient; + int m_cxyHeader; + TCHAR m_szTitle[m_cchTitle]; + DWORD m_dwExtendedStyle; // Pane container specific extended styles + HFONT m_hFont; + bool m_bInternalFont; + + +// Constructor + CPaneContainerImpl() : m_cxyHeader(0), m_dwExtendedStyle(0), m_hFont(NULL), m_bInternalFont(false) + { + m_szTitle[0] = 0; + } + +// Attributes + DWORD GetPaneContainerExtendedStyle() const + { + return m_dwExtendedStyle; + } + + DWORD SetPaneContainerExtendedStyle(DWORD dwExtendedStyle, DWORD dwMask = 0) + { + DWORD dwPrevStyle = m_dwExtendedStyle; + if(dwMask == 0) + m_dwExtendedStyle = dwExtendedStyle; + else + m_dwExtendedStyle = (m_dwExtendedStyle & ~dwMask) | (dwExtendedStyle & dwMask); + if(this->m_hWnd != NULL) + { + T* pT = static_cast(this); + bool bUpdate = false; + + if(((dwPrevStyle & PANECNT_NOCLOSEBUTTON) != 0) && ((m_dwExtendedStyle & PANECNT_NOCLOSEBUTTON) == 0)) // add close button + { + pT->CreateCloseButton(); + bUpdate = true; + } + else if(((dwPrevStyle & PANECNT_NOCLOSEBUTTON) == 0) && ((m_dwExtendedStyle & PANECNT_NOCLOSEBUTTON) != 0)) // remove close button + { + pT->DestroyCloseButton(); + bUpdate = true; + } + + if((dwPrevStyle & PANECNT_VERTICAL) != (m_dwExtendedStyle & PANECNT_VERTICAL)) // change orientation + { + pT->CalcSize(); + bUpdate = true; + } + + if((dwPrevStyle & (PANECNT_FLATBORDER | PANECNT_NOBORDER)) != + (m_dwExtendedStyle & (PANECNT_FLATBORDER | PANECNT_NOBORDER))) // change border + { + bUpdate = true; + } + + if((dwPrevStyle & PANECNT_GRADIENT) != (m_dwExtendedStyle & PANECNT_GRADIENT)) // change background + { + bUpdate = true; + } + + if(bUpdate) + pT->UpdateLayout(); + } + return dwPrevStyle; + } + + HWND GetClient() const + { + return m_wndClient; + } + + HWND SetClient(HWND hWndClient) + { + HWND hWndOldClient = m_wndClient; + m_wndClient = hWndClient; + if(this->m_hWnd != NULL) + { + T* pT = static_cast(this); + pT->UpdateLayout(); + } + return hWndOldClient; + } + + BOOL GetTitle(LPTSTR lpstrTitle, int cchLength) const + { + ATLASSERT(lpstrTitle != NULL); + + errno_t nRet = ATL::Checked::tcsncpy_s(lpstrTitle, cchLength, m_szTitle, _TRUNCATE); + + return ((nRet == 0) || (nRet == STRUNCATE)); + } + + BOOL SetTitle(LPCTSTR lpstrTitle) + { + ATLASSERT(lpstrTitle != NULL); + + errno_t nRet = ATL::Checked::tcsncpy_s(m_szTitle, m_cchTitle, lpstrTitle, _TRUNCATE); + bool bRet = ((nRet == 0) || (nRet == STRUNCATE)); + if(bRet && (this->m_hWnd != NULL)) + { + T* pT = static_cast(this); + pT->UpdateLayout(); + } + + return bRet; + } + + int GetTitleLength() const + { + return lstrlen(m_szTitle); + } + +// Methods + HWND Create(HWND hWndParent, LPCTSTR lpstrTitle = NULL, DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, + DWORD dwExStyle = 0, UINT nID = 0, LPVOID lpCreateParam = NULL) + { + if(lpstrTitle != NULL) + ATL::Checked::tcsncpy_s(m_szTitle, m_cchTitle, lpstrTitle, _TRUNCATE); + return ATL::CWindowImpl< T, TBase, TWinTraits >::Create(hWndParent, this->rcDefault, NULL, dwStyle, dwExStyle, nID, lpCreateParam); + } + + HWND Create(HWND hWndParent, UINT uTitleID, DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, + DWORD dwExStyle = 0, UINT nID = 0, LPVOID lpCreateParam = NULL) + { + if(uTitleID != 0U) + ::LoadString(ModuleHelper::GetResourceInstance(), uTitleID, m_szTitle, m_cchTitle); + return ATL::CWindowImpl< T, TBase, TWinTraits >::Create(hWndParent, this->rcDefault, NULL, dwStyle, dwExStyle, nID, lpCreateParam); + } + + BOOL SubclassWindow(HWND hWnd) + { + BOOL bRet = ATL::CWindowImpl< T, TBase, TWinTraits >::SubclassWindow(hWnd); + if(bRet != FALSE) + { + T* pT = static_cast(this); + pT->Init(); + + RECT rect = {}; + this->GetClientRect(&rect); + pT->UpdateLayout(rect.right, rect.bottom); + } + + return bRet; + } + + BOOL EnableCloseButton(BOOL bEnable) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + T* pT = static_cast(this); + (void)pT; // avoid level 4 warning + return (m_tb.m_hWnd != NULL) ? m_tb.EnableButton(pT->m_nCloseBtnID, bEnable) : FALSE; + } + + void UpdateLayout() + { + RECT rcClient = {}; + this->GetClientRect(&rcClient); + T* pT = static_cast(this); + pT->UpdateLayout(rcClient.right, rcClient.bottom); + } + +// Message map and handlers + BEGIN_MSG_MAP(CPaneContainerImpl) + MESSAGE_HANDLER(WM_CREATE, OnCreate) + MESSAGE_HANDLER(WM_DESTROY, OnDestroy) + MESSAGE_HANDLER(WM_SIZE, OnSize) + MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus) + MESSAGE_HANDLER(WM_GETFONT, OnGetFont) + MESSAGE_HANDLER(WM_SETFONT, OnSetFont) + MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground) + MESSAGE_HANDLER(WM_PAINT, OnPaint) + MESSAGE_HANDLER(WM_PRINTCLIENT, OnPaint) + MESSAGE_HANDLER(WM_NOTIFY, OnNotify) + MESSAGE_HANDLER(WM_COMMAND, OnCommand) + FORWARD_NOTIFICATIONS() + END_MSG_MAP() + + LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + T* pT = static_cast(this); + pT->Init(); + + return 0; + } + + LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + if(m_bInternalFont) + { + ::DeleteObject(m_hFont); + m_hFont = NULL; + m_bInternalFont = false; + } + + return 0; + } + + LRESULT OnSize(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/) + { + T* pT = static_cast(this); + pT->UpdateLayout(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); + return 0; + } + + LRESULT OnSetFocus(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + if(m_wndClient.m_hWnd != NULL) + m_wndClient.SetFocus(); + return 0; + } + + LRESULT OnGetFont(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + return (LRESULT)m_hFont; + } + + LRESULT OnSetFont(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) + { + if(m_bInternalFont) + { + ::DeleteObject(m_hFont); + m_bInternalFont = false; + } + + m_hFont = (HFONT)wParam; + + T* pT = static_cast(this); + pT->CalcSize(); + + if((BOOL)lParam != FALSE) + pT->UpdateLayout(); + + return 0; + } + + LRESULT OnEraseBackground(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + T* pT = static_cast(this); + pT->DrawPaneTitleBackground((HDC)wParam); + + return 1; + } + + LRESULT OnPaint(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + T* pT = static_cast(this); + if(wParam != NULL) + { + pT->DrawPaneTitle((HDC)wParam); + + if(m_wndClient.m_hWnd == NULL) // no client window + pT->DrawPane((HDC)wParam); + } + else + { + CPaintDC dc(this->m_hWnd); + pT->DrawPaneTitle(dc.m_hDC); + + if(m_wndClient.m_hWnd == NULL) // no client window + pT->DrawPane(dc.m_hDC); + } + + return 0; + } + + LRESULT OnNotify(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled) + { + if(m_tb.m_hWnd == NULL) + { + bHandled = FALSE; + return 1; + } + + T* pT = static_cast(this); + (void)pT; // avoid level 4 warning + LPNMHDR lpnmh = (LPNMHDR)lParam; + LRESULT lRet = 0; + + // pass toolbar custom draw notifications to the base class + if((lpnmh->code == NM_CUSTOMDRAW) && (lpnmh->hwndFrom == m_tb.m_hWnd)) + lRet = CCustomDraw< T >::OnCustomDraw(0, lpnmh, bHandled); + // tooltip notifications come with the tooltip window handle and button ID, + // pass them to the parent if we don't handle them + else if((lpnmh->code == TTN_GETDISPINFO) && (lpnmh->idFrom == pT->m_nCloseBtnID)) + bHandled = pT->GetToolTipText(lpnmh); + // only let notifications not from the toolbar go to the parent + else if((lpnmh->hwndFrom != m_tb.m_hWnd) && (lpnmh->idFrom != pT->m_nCloseBtnID)) + bHandled = FALSE; + + return lRet; + } + + LRESULT OnCommand(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled) + { + // if command comes from the close button, substitute HWND of the pane container instead + if((m_tb.m_hWnd != NULL) && ((HWND)lParam == m_tb.m_hWnd)) + return this->GetParent().SendMessage(WM_COMMAND, wParam, (LPARAM)this->m_hWnd); + + bHandled = FALSE; + return 1; + } + +// Custom draw overrides + DWORD OnPrePaint(int /*idCtrl*/, LPNMCUSTOMDRAW /*lpNMCustomDraw*/) + { + return CDRF_NOTIFYITEMDRAW; // we need per-item notifications + } + + DWORD OnItemPrePaint(int /*idCtrl*/, LPNMCUSTOMDRAW /*lpNMCustomDraw*/) + { + return CDRF_NOTIFYPOSTPAINT; + } + + DWORD OnItemPostPaint(int /*idCtrl*/, LPNMCUSTOMDRAW lpNMCustomDraw) + { + CDCHandle dc = lpNMCustomDraw->hdc; + RECT& rc = lpNMCustomDraw->rc; + + RECT rcImage = { m_xBtnImageLeft, m_yBtnImageTop, m_xBtnImageRight + 1, m_yBtnImageBottom + 1 }; + ::OffsetRect(&rcImage, rc.left, rc.top); + T* pT = static_cast(this); + + if((lpNMCustomDraw->uItemState & CDIS_DISABLED) != 0) + { + RECT rcShadow = rcImage; + ::OffsetRect(&rcShadow, 1, 1); + CPen pen1; + pen1.CreatePen(PS_SOLID, 0, ::GetSysColor(COLOR_3DHILIGHT)); + pT->DrawButtonImage(dc, rcShadow, pen1); + CPen pen2; + pen2.CreatePen(PS_SOLID, 0, ::GetSysColor(COLOR_3DSHADOW)); + pT->DrawButtonImage(dc, rcImage, pen2); + } + else + { + if((lpNMCustomDraw->uItemState & CDIS_SELECTED) != 0) + ::OffsetRect(&rcImage, 1, 1); + CPen pen; + pen.CreatePen(PS_SOLID, 0, ::GetSysColor(COLOR_BTNTEXT)); + pT->DrawButtonImage(dc, rcImage, pen); + } + + return CDRF_DODEFAULT; // continue with the default item painting + } + +// Implementation - overrideable methods + void Init() + { + if(m_hFont == NULL) + { + // The same as AtlCreateControlFont() for horizontal pane + LOGFONT lf = {}; + ATLVERIFY(::SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(LOGFONT), &lf, 0) != FALSE); + if(IsVertical()) + lf.lfEscapement = 900; // 90 degrees + m_hFont = ::CreateFontIndirect(&lf); + m_bInternalFont = true; + } + + T* pT = static_cast(this); + pT->CalcSize(); + + if((m_dwExtendedStyle & PANECNT_NOCLOSEBUTTON) == 0) + pT->CreateCloseButton(); + } + + void UpdateLayout(int cxWidth, int cyHeight) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + RECT rect = {}; + + if(IsVertical()) + { + ::SetRect(&rect, 0, 0, m_cxyHeader, cyHeight); + if(m_tb.m_hWnd != NULL) + m_tb.SetWindowPos(NULL, m_cxyBorder, m_cxyBorder + m_cxyBtnOffset, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE); + + if(m_wndClient.m_hWnd != NULL) + m_wndClient.SetWindowPos(NULL, m_cxyHeader, 0, cxWidth - m_cxyHeader, cyHeight, SWP_NOZORDER); + else + rect.right = cxWidth; + } + else + { + ::SetRect(&rect, 0, 0, cxWidth, m_cxyHeader); + if(m_tb.m_hWnd != NULL) + m_tb.SetWindowPos(NULL, rect.right - m_cxToolBar, m_cxyBorder + m_cxyBtnOffset, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE); + + if(m_wndClient.m_hWnd != NULL) + m_wndClient.SetWindowPos(NULL, 0, m_cxyHeader, cxWidth, cyHeight - m_cxyHeader, SWP_NOZORDER); + else + rect.bottom = cyHeight; + } + + this->InvalidateRect(&rect); + } + + void CreateCloseButton() + { + ATLASSERT(m_tb.m_hWnd == NULL); + // create toolbar for the "x" button + m_tb.Create(this->m_hWnd, this->rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | CCS_NODIVIDER | CCS_NORESIZE | CCS_NOPARENTALIGN | CCS_NOMOVEY | TBSTYLE_TOOLTIPS | TBSTYLE_FLAT, 0); + ATLASSERT(m_tb.IsWindow()); + + if(m_tb.m_hWnd != NULL) + { + T* pT = static_cast(this); + (void)pT; // avoid level 4 warning + + m_tb.SetButtonStructSize(); + + TBBUTTON tbbtn = {}; + tbbtn.idCommand = pT->m_nCloseBtnID; + tbbtn.fsState = TBSTATE_ENABLED; + tbbtn.fsStyle = BTNS_BUTTON; + m_tb.AddButtons(1, &tbbtn); + + m_tb.SetBitmapSize(m_cxImageTB, m_cyImageTB); + m_tb.SetButtonSize(m_cxImageTB + m_cxyBtnAddTB, m_cyImageTB + m_cxyBtnAddTB); + + if(IsVertical()) + m_tb.SetWindowPos(NULL, m_cxyBorder + m_cxyBtnOffset, m_cxyBorder + m_cxyBtnOffset, m_cxImageTB + m_cxyBtnAddTB, m_cyImageTB + m_cxyBtnAddTB + 1, SWP_NOZORDER | SWP_NOACTIVATE); + else + m_tb.SetWindowPos(NULL, 0, 0, m_cxImageTB + m_cxyBtnAddTB, m_cyImageTB + m_cxyBtnAddTB + 1, SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE); + } + } + + void DestroyCloseButton() + { + if(m_tb.m_hWnd != NULL) + m_tb.DestroyWindow(); + } + + void CalcSize() + { + T* pT = static_cast(this); + CFontHandle font = pT->GetTitleFont(); + if(font.IsNull()) + font = (HFONT)::GetStockObject(SYSTEM_FONT); + LOGFONT lf = {}; + font.GetLogFont(lf); + if(IsVertical()) + { + m_cxyHeader = m_cxImageTB + m_cxyBtnAddTB + m_cxyBorder + 1; + } + else + { + int cyFont = abs(lf.lfHeight) + m_cxyBorder + 2 * m_cxyTextOffset; + int cyBtn = m_cyImageTB + m_cxyBtnAddTB + m_cxyBorder + 2 * m_cxyBtnOffset + 1; + m_cxyHeader = __max(cyFont, cyBtn); + } + } + + HFONT GetTitleFont() const + { + return m_hFont; + } + + BOOL GetToolTipText(LPNMHDR /*lpnmh*/) + { + return FALSE; + } + + void DrawPaneTitle(CDCHandle dc) + { + RECT rect = {}; + this->GetClientRect(&rect); + + UINT uBorder = BF_LEFT | BF_TOP | BF_ADJUST; + if(IsVertical()) + { + rect.right = rect.left + m_cxyHeader; + uBorder |= BF_BOTTOM; + } + else + { + rect.bottom = rect.top + m_cxyHeader; + uBorder |= BF_RIGHT; + } + + if((m_dwExtendedStyle & PANECNT_NOBORDER) == 0) + { + if((m_dwExtendedStyle & PANECNT_FLATBORDER) != 0) + uBorder |= BF_FLAT; + dc.DrawEdge(&rect, EDGE_ETCHED, uBorder); + } + + if((m_dwExtendedStyle & PANECNT_DIVIDER) != 0) + { + uBorder = BF_FLAT | BF_ADJUST | (IsVertical() ? BF_RIGHT : BF_BOTTOM); + dc.DrawEdge(&rect, BDR_SUNKENOUTER, uBorder); + } + + // draw title text + dc.SetTextColor(::GetSysColor(COLOR_WINDOWTEXT)); + dc.SetBkMode(TRANSPARENT); + T* pT = static_cast(this); + HFONT hFontOld = dc.SelectFont(pT->GetTitleFont()); + + if(IsVertical()) + { + rect.top += m_cxyTextOffset; + rect.bottom -= m_cxyTextOffset; + if(m_tb.m_hWnd != NULL) + rect.top += m_cxToolBar;; + + RECT rcCalc = { rect.left, rect.bottom, rect.right, rect.top }; + int cxFont = dc.DrawText(m_szTitle, -1, &rcCalc, DT_TOP | DT_SINGLELINE | DT_END_ELLIPSIS | DT_CALCRECT); + RECT rcText = {}; + rcText.left = (rect.right - rect.left - cxFont) / 2; + rcText.right = rcText.left + (rect.bottom - rect.top); + rcText.top = rect.bottom; + rcText.bottom = rect.top; + dc.DrawText(m_szTitle, -1, &rcText, DT_TOP | DT_SINGLELINE | DT_END_ELLIPSIS); + } + else + { + rect.left += m_cxyTextOffset; + rect.right -= m_cxyTextOffset; + if(m_tb.m_hWnd != NULL) + rect.right -= m_cxToolBar;; + + dc.DrawText(m_szTitle, -1, &rect, DT_LEFT | DT_SINGLELINE | DT_VCENTER | DT_END_ELLIPSIS); + } + + dc.SelectFont(hFontOld); + } + + void DrawPaneTitleBackground(CDCHandle dc) + { + RECT rect = {}; + this->GetClientRect(&rect); + if(IsVertical()) + rect.right = m_cxyHeader; + else + rect.bottom = m_cxyHeader; + + if((m_dwExtendedStyle & PANECNT_GRADIENT) != 0) + dc.GradientFillRect(rect, ::GetSysColor(COLOR_WINDOW), ::GetSysColor(COLOR_3DFACE), IsVertical()); + else + dc.FillRect(&rect, COLOR_3DFACE); + } + + // called only if pane is empty + void DrawPane(CDCHandle dc) + { + RECT rect = {}; + this->GetClientRect(&rect); + if(IsVertical()) + rect.left += m_cxyHeader; + else + rect.top += m_cxyHeader; + if((this->GetExStyle() & WS_EX_CLIENTEDGE) == 0) + dc.DrawEdge(&rect, EDGE_SUNKEN, BF_RECT | BF_ADJUST); + dc.FillRect(&rect, COLOR_APPWORKSPACE); + } + + // drawing helper - draws "x" button image + void DrawButtonImage(CDCHandle dc, RECT& rcImage, HPEN hPen) + { + HPEN hPenOld = dc.SelectPen(hPen); + + dc.MoveTo(rcImage.left, rcImage.top); + dc.LineTo(rcImage.right, rcImage.bottom); + dc.MoveTo(rcImage.left + 1, rcImage.top); + dc.LineTo(rcImage.right + 1, rcImage.bottom); + + dc.MoveTo(rcImage.left, rcImage.bottom - 1); + dc.LineTo(rcImage.right, rcImage.top - 1); + dc.MoveTo(rcImage.left + 1, rcImage.bottom - 1); + dc.LineTo(rcImage.right + 1, rcImage.top - 1); + + dc.SelectPen(hPenOld); + } + + bool IsVertical() const + { + return ((m_dwExtendedStyle & PANECNT_VERTICAL) != 0); + } +}; + +class CPaneContainer : public CPaneContainerImpl +{ +public: + DECLARE_WND_CLASS_EX(_T("WTL_PaneContainer"), 0, -1) +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CSortListViewCtrl - implements sorting for a listview control + +// sort listview extended styles +#define SORTLV_USESHELLBITMAPS 0x00000001 + +// Notification sent to parent when sort column is changed by user clicking header. +#define SLVN_SORTCHANGED LVN_LAST + +// A LPNMSORTLISTVIEW is sent with the SLVN_SORTCHANGED notification +typedef struct tagNMSORTLISTVIEW +{ + NMHDR hdr; + int iNewSortColumn; + int iOldSortColumn; +} NMSORTLISTVIEW, *LPNMSORTLISTVIEW; + +// Column sort types. Can be set on a per-column basis with the SetColumnSortType method. +enum +{ + LVCOLSORT_NONE, + LVCOLSORT_TEXT, // default + LVCOLSORT_TEXTNOCASE, + LVCOLSORT_LONG, + LVCOLSORT_DOUBLE, + LVCOLSORT_DECIMAL, + LVCOLSORT_DATETIME, + LVCOLSORT_DATE, + LVCOLSORT_TIME, + LVCOLSORT_CUSTOM, + LVCOLSORT_LAST = LVCOLSORT_CUSTOM +}; + + +template +class CSortListViewImpl +{ +public: + enum + { + m_cchCmpTextMax = 32, // overrideable + m_cxSortImage = 16, + m_cySortImage = 15, + m_cxSortArrow = 11, + m_cySortArrow = 6, + m_iSortUp = 0, // index of sort bitmaps + m_iSortDown = 1, + m_nShellSortUpID = 133 + }; + + // passed to LVCompare functions as lParam1 and lParam2 + struct LVCompareParam + { + int iItem; + DWORD_PTR dwItemData; + union + { + long lValue; + double dblValue; + DECIMAL decValue; + LPCTSTR pszValue; + }; + }; + + // passed to LVCompare functions as the lParamSort parameter + struct LVSortInfo + { + T* pT; + int iSortCol; + bool bDescending; + }; + + bool m_bSortDescending; + bool m_bCommCtrl6; + int m_iSortColumn; + CBitmap m_bmSort[2]; + int m_fmtOldSortCol; + HBITMAP m_hbmOldSortCol; + DWORD m_dwSortLVExtendedStyle; + ATL::CSimpleArray m_arrColSortType; + bool m_bUseWaitCursor; + + CSortListViewImpl() : + m_bSortDescending(false), + m_bCommCtrl6(false), + m_iSortColumn(-1), + m_fmtOldSortCol(0), + m_hbmOldSortCol(NULL), + m_dwSortLVExtendedStyle(SORTLV_USESHELLBITMAPS), + m_bUseWaitCursor(true) + { + DWORD dwMajor = 0; + DWORD dwMinor = 0; + HRESULT hRet = ATL::AtlGetCommCtrlVersion(&dwMajor, &dwMinor); + m_bCommCtrl6 = SUCCEEDED(hRet) && (dwMajor >= 6); + } + +// Attributes + void SetSortColumn(int iCol) + { + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + CHeaderCtrl header = pT->GetHeader(); + ATLASSERT(header.m_hWnd != NULL); + ATLASSERT((iCol >= -1) && (iCol < m_arrColSortType.GetSize())); + + int iOldSortCol = m_iSortColumn; + m_iSortColumn = iCol; + if(m_bCommCtrl6) + { + const int nMask = HDF_SORTUP | HDF_SORTDOWN; + HDITEM hditem = { HDI_FORMAT }; + if((iOldSortCol != iCol) && (iOldSortCol >= 0) && header.GetItem(iOldSortCol, &hditem)) + { + hditem.fmt &= ~nMask; + header.SetItem(iOldSortCol, &hditem); + } + if((iCol >= 0) && header.GetItem(iCol, &hditem)) + { + hditem.fmt &= ~nMask; + hditem.fmt |= m_bSortDescending ? HDF_SORTDOWN : HDF_SORTUP; + header.SetItem(iCol, &hditem); + } + return; + } + + if(m_bmSort[m_iSortUp].IsNull()) + pT->CreateSortBitmaps(); + + // restore previous sort column's bitmap, if any, and format + HDITEM hditem = { HDI_BITMAP | HDI_FORMAT }; + if((iOldSortCol != iCol) && (iOldSortCol >= 0)) + { + hditem.hbm = m_hbmOldSortCol; + hditem.fmt = m_fmtOldSortCol; + header.SetItem(iOldSortCol, &hditem); + } + + // save new sort column's bitmap and format, and add our sort bitmap + if((iCol >= 0) && header.GetItem(iCol, &hditem)) + { + if(iOldSortCol != iCol) + { + m_fmtOldSortCol = hditem.fmt; + m_hbmOldSortCol = hditem.hbm; + } + hditem.fmt &= ~HDF_IMAGE; + hditem.fmt |= HDF_BITMAP | HDF_BITMAP_ON_RIGHT; + int i = m_bSortDescending ? m_iSortDown : m_iSortUp; + hditem.hbm = m_bmSort[i]; + header.SetItem(iCol, &hditem); + } + } + + int GetSortColumn() const + { + return m_iSortColumn; + } + + void SetColumnSortType(int iCol, WORD wType) + { + ATLASSERT((iCol >= 0) && (iCol < m_arrColSortType.GetSize())); + ATLASSERT((wType >= LVCOLSORT_NONE) && (wType <= LVCOLSORT_LAST)); + m_arrColSortType[iCol] = wType; + } + + WORD GetColumnSortType(int iCol) const + { + ATLASSERT((iCol >= 0) && (iCol < m_arrColSortType.GetSize())); + return m_arrColSortType[iCol]; + } + + int GetColumnCount() const + { + const T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + CHeaderCtrl header = pT->GetHeader(); + return header.m_hWnd != NULL ? header.GetItemCount() : 0; + } + + bool IsSortDescending() const + { + return m_bSortDescending; + } + + DWORD GetSortListViewExtendedStyle() const + { + return m_dwSortLVExtendedStyle; + } + + DWORD SetSortListViewExtendedStyle(DWORD dwExtendedStyle, DWORD dwMask = 0) + { + DWORD dwPrevStyle = m_dwSortLVExtendedStyle; + if(dwMask == 0) + m_dwSortLVExtendedStyle = dwExtendedStyle; + else + m_dwSortLVExtendedStyle = (m_dwSortLVExtendedStyle & ~dwMask) | (dwExtendedStyle & dwMask); + return dwPrevStyle; + } + +// Operations + bool DoSortItems(int iCol, bool bDescending = false) + { + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + ATLASSERT((iCol >= 0) && (iCol < m_arrColSortType.GetSize())); + + WORD wType = m_arrColSortType[iCol]; + if(wType == LVCOLSORT_NONE) + return false; + + int nCount = pT->GetItemCount(); + if(nCount < 2) + { + m_bSortDescending = bDescending; + SetSortColumn(iCol); + return true; + } + + CWaitCursor waitCursor(false); + if(m_bUseWaitCursor) + waitCursor.Set(); + + LVCompareParam* pParam = NULL; + ATLTRY(pParam = new LVCompareParam[nCount]); + PFNLVCOMPARE pFunc = NULL; + TCHAR pszTemp[pT->m_cchCmpTextMax] = {}; + bool bStrValue = false; + + switch(wType) + { + case LVCOLSORT_TEXT: + pFunc = (PFNLVCOMPARE)pT->LVCompareText; + case LVCOLSORT_TEXTNOCASE: + if(pFunc == NULL) + pFunc = (PFNLVCOMPARE)pT->LVCompareTextNoCase; + case LVCOLSORT_CUSTOM: + { + if(pFunc == NULL) + pFunc = (PFNLVCOMPARE)pT->LVCompareCustom; + + for(int i = 0; i < nCount; i++) + { + pParam[i].iItem = i; + pParam[i].dwItemData = pT->GetItemData(i); + pParam[i].pszValue = new TCHAR[pT->m_cchCmpTextMax]; + pT->GetItemText(i, iCol, (LPTSTR)pParam[i].pszValue, pT->m_cchCmpTextMax); + pT->SetItemData(i, (DWORD_PTR)&pParam[i]); + } + bStrValue = true; + } + break; + case LVCOLSORT_LONG: + { + pFunc = (PFNLVCOMPARE)pT->LVCompareLong; + for(int i = 0; i < nCount; i++) + { + pParam[i].iItem = i; + pParam[i].dwItemData = pT->GetItemData(i); + pT->GetItemText(i, iCol, pszTemp, pT->m_cchCmpTextMax); + pParam[i].lValue = pT->StrToLong(pszTemp); + pT->SetItemData(i, (DWORD_PTR)&pParam[i]); + } + } + break; + case LVCOLSORT_DOUBLE: + { + pFunc = (PFNLVCOMPARE)pT->LVCompareDouble; + for(int i = 0; i < nCount; i++) + { + pParam[i].iItem = i; + pParam[i].dwItemData = pT->GetItemData(i); + pT->GetItemText(i, iCol, pszTemp, pT->m_cchCmpTextMax); + pParam[i].dblValue = pT->StrToDouble(pszTemp); + pT->SetItemData(i, (DWORD_PTR)&pParam[i]); + } + } + break; + case LVCOLSORT_DECIMAL: + { + pFunc = (PFNLVCOMPARE)pT->LVCompareDecimal; + for(int i = 0; i < nCount; i++) + { + pParam[i].iItem = i; + pParam[i].dwItemData = pT->GetItemData(i); + pT->GetItemText(i, iCol, pszTemp, pT->m_cchCmpTextMax); + pT->StrToDecimal(pszTemp, &pParam[i].decValue); + pT->SetItemData(i, (DWORD_PTR)&pParam[i]); + } + } + break; + case LVCOLSORT_DATETIME: + case LVCOLSORT_DATE: + case LVCOLSORT_TIME: + { + pFunc = (PFNLVCOMPARE)pT->LVCompareDouble; + DWORD dwFlags = LOCALE_NOUSEROVERRIDE; + if(wType == LVCOLSORT_DATE) + dwFlags |= VAR_DATEVALUEONLY; + else if(wType == LVCOLSORT_TIME) + dwFlags |= VAR_TIMEVALUEONLY; + for(int i = 0; i < nCount; i++) + { + pParam[i].iItem = i; + pParam[i].dwItemData = pT->GetItemData(i); + pT->GetItemText(i, iCol, pszTemp, pT->m_cchCmpTextMax); + pParam[i].dblValue = pT->DateStrToDouble(pszTemp, dwFlags); + pT->SetItemData(i, (DWORD_PTR)&pParam[i]); + } + } + break; + default: + ATLTRACE2(atlTraceUI, 0, _T("Unknown value for sort type in CSortListViewImpl::DoSortItems()\n")); + break; + } // switch(wType) + + ATLASSERT(pFunc != NULL); + LVSortInfo lvsi = { pT, iCol, bDescending }; + bool bRet = ((BOOL)pT->DefWindowProc(LVM_SORTITEMS, (WPARAM)&lvsi, (LPARAM)pFunc) != FALSE); + for(int i = 0; i < nCount; i++) + { + DWORD_PTR dwItemData = pT->GetItemData(i); + LVCompareParam* p = (LVCompareParam*)dwItemData; + ATLASSERT(p != NULL); + if(bStrValue) + delete [] (TCHAR*)p->pszValue; + pT->SetItemData(i, p->dwItemData); + } + delete [] pParam; + + if(bRet) + { + m_bSortDescending = bDescending; + SetSortColumn(iCol); + } + + if(m_bUseWaitCursor) + waitCursor.Restore(); + + return bRet; + } + + void CreateSortBitmaps() + { + if((m_dwSortLVExtendedStyle & SORTLV_USESHELLBITMAPS) != 0) + { + bool bFree = false; + LPCTSTR pszModule = _T("shell32.dll"); + HINSTANCE hShell = ::GetModuleHandle(pszModule); + + if (hShell == NULL) + { + hShell = ::LoadLibrary(pszModule); + bFree = true; + } + + if (hShell != NULL) + { + bool bSuccess = true; + for(int i = m_iSortUp; i <= m_iSortDown; i++) + { + if(!m_bmSort[i].IsNull()) + m_bmSort[i].DeleteObject(); + m_bmSort[i] = (HBITMAP)::LoadImage(hShell, MAKEINTRESOURCE(m_nShellSortUpID + i), + IMAGE_BITMAP, 0, 0, LR_LOADMAP3DCOLORS); + if(m_bmSort[i].IsNull()) + { + bSuccess = false; + break; + } + } + if(bFree) + ::FreeLibrary(hShell); + if(bSuccess) + return; + } + } + + T* pT = static_cast(this); + for(int i = m_iSortUp; i <= m_iSortDown; i++) + { + if(!m_bmSort[i].IsNull()) + m_bmSort[i].DeleteObject(); + + CDC dcMem; + CClientDC dc(::GetDesktopWindow()); + dcMem.CreateCompatibleDC(dc.m_hDC); + m_bmSort[i].CreateCompatibleBitmap(dc.m_hDC, m_cxSortImage, m_cySortImage); + HBITMAP hbmOld = dcMem.SelectBitmap(m_bmSort[i]); + RECT rc = { 0, 0, m_cxSortImage, m_cySortImage }; + pT->DrawSortBitmap(dcMem.m_hDC, i, &rc); + dcMem.SelectBitmap(hbmOld); + dcMem.DeleteDC(); + } + } + + void NotifyParentSortChanged(int iNewSortCol, int iOldSortCol) + { + T* pT = static_cast(this); + int nID = pT->GetDlgCtrlID(); + NMSORTLISTVIEW nm = { { pT->m_hWnd, (UINT_PTR)nID, SLVN_SORTCHANGED }, iNewSortCol, iOldSortCol }; + ::SendMessage(pT->GetParent(), WM_NOTIFY, (WPARAM)nID, (LPARAM)&nm); + } + +// Overrideables + int CompareItemsCustom(LVCompareParam* /*pItem1*/, LVCompareParam* /*pItem2*/, int /*iSortCol*/) + { + // pItem1 and pItem2 contain valid iItem, dwItemData, and pszValue members. + // If item1 > item2 return 1, if item1 < item2 return -1, else return 0. + return 0; + } + + void DrawSortBitmap(CDCHandle dc, int iBitmap, LPRECT prc) + { + dc.FillRect(prc, ::GetSysColorBrush(COLOR_BTNFACE)); + HBRUSH hbrOld = dc.SelectBrush(::GetSysColorBrush(COLOR_BTNSHADOW)); + CPen pen; + pen.CreatePen(PS_SOLID, 0, ::GetSysColor(COLOR_BTNSHADOW)); + HPEN hpenOld = dc.SelectPen(pen); + POINT ptOrg = { (m_cxSortImage - m_cxSortArrow) / 2, (m_cySortImage - m_cySortArrow) / 2 }; + if(iBitmap == m_iSortUp) + { + POINT pts[3] = + { + { ptOrg.x + m_cxSortArrow / 2, ptOrg.y }, + { ptOrg.x, ptOrg.y + m_cySortArrow - 1 }, + { ptOrg.x + m_cxSortArrow - 1, ptOrg.y + m_cySortArrow - 1 } + }; + dc.Polygon(pts, 3); + } + else + { + POINT pts[3] = + { + { ptOrg.x, ptOrg.y }, + { ptOrg.x + m_cxSortArrow / 2, ptOrg.y + m_cySortArrow - 1 }, + { ptOrg.x + m_cxSortArrow - 1, ptOrg.y } + }; + dc.Polygon(pts, 3); + } + dc.SelectBrush(hbrOld); + dc.SelectPen(hpenOld); + } + + double DateStrToDouble(LPCTSTR lpstr, DWORD dwFlags) + { + ATLASSERT(lpstr != NULL); + if((lpstr == NULL) || (lpstr[0] == _T('\0'))) + return 0; + + USES_CONVERSION; + HRESULT hRet = E_FAIL; + DATE dRet = 0; + if (FAILED(hRet = ::VarDateFromStr((LPOLESTR)T2COLE(lpstr), LANG_USER_DEFAULT, dwFlags, &dRet))) + { + ATLTRACE2(atlTraceUI, 0, _T("VarDateFromStr failed with result of 0x%8.8X\n"), hRet); + dRet = 0; + } + return dRet; + } + + long StrToLong(LPCTSTR lpstr) + { + ATLASSERT(lpstr != NULL); + if((lpstr == NULL) || (lpstr[0] == _T('\0'))) + return 0; + + USES_CONVERSION; + HRESULT hRet = E_FAIL; + long lRet = 0; + if (FAILED(hRet = ::VarI4FromStr((LPOLESTR)T2COLE(lpstr), LANG_USER_DEFAULT, LOCALE_NOUSEROVERRIDE, &lRet))) + { + ATLTRACE2(atlTraceUI, 0, _T("VarI4FromStr failed with result of 0x%8.8X\n"), hRet); + lRet = 0; + } + return lRet; + } + + double StrToDouble(LPCTSTR lpstr) + { + ATLASSERT(lpstr != NULL); + if((lpstr == NULL) || (lpstr[0] == _T('\0'))) + return 0; + + USES_CONVERSION; + HRESULT hRet = E_FAIL; + double dblRet = 0; + if (FAILED(hRet = ::VarR8FromStr((LPOLESTR)T2COLE(lpstr), LANG_USER_DEFAULT, LOCALE_NOUSEROVERRIDE, &dblRet))) + { + ATLTRACE2(atlTraceUI, 0, _T("VarR8FromStr failed with result of 0x%8.8X\n"), hRet); + dblRet = 0; + } + return dblRet; + } + + bool StrToDecimal(LPCTSTR lpstr, DECIMAL* pDecimal) + { + ATLASSERT(lpstr != NULL); + ATLASSERT(pDecimal != NULL); + if((lpstr == NULL) || (pDecimal == NULL)) + return false; + + USES_CONVERSION; + HRESULT hRet = E_FAIL; + if (FAILED(hRet = ::VarDecFromStr((LPOLESTR)T2COLE(lpstr), LANG_USER_DEFAULT, LOCALE_NOUSEROVERRIDE, pDecimal))) + { + ATLTRACE2(atlTraceUI, 0, _T("VarDecFromStr failed with result of 0x%8.8X\n"), hRet); + pDecimal->Lo64 = 0; + pDecimal->Hi32 = 0; + pDecimal->signscale = 0; + return false; + } + return true; + } + +// Overrideable PFNLVCOMPARE functions + static int CALLBACK LVCompareText(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) + { + ATLASSERT((lParam1 != NULL) && (lParam2 != NULL) && (lParamSort != NULL)); + + LVCompareParam* pParam1 = (LVCompareParam*)lParam1; + LVCompareParam* pParam2 = (LVCompareParam*)lParam2; + LVSortInfo* pInfo = (LVSortInfo*)lParamSort; + + int nRet = lstrcmp(pParam1->pszValue, pParam2->pszValue); + return pInfo->bDescending ? -nRet : nRet; + } + + static int CALLBACK LVCompareTextNoCase(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) + { + ATLASSERT((lParam1 != NULL) && (lParam2 != NULL) && (lParamSort != NULL)); + + LVCompareParam* pParam1 = (LVCompareParam*)lParam1; + LVCompareParam* pParam2 = (LVCompareParam*)lParam2; + LVSortInfo* pInfo = (LVSortInfo*)lParamSort; + + int nRet = lstrcmpi(pParam1->pszValue, pParam2->pszValue); + return pInfo->bDescending ? -nRet : nRet; + } + + static int CALLBACK LVCompareLong(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) + { + ATLASSERT((lParam1 != NULL) && (lParam2 != NULL) && (lParamSort != NULL)); + + LVCompareParam* pParam1 = (LVCompareParam*)lParam1; + LVCompareParam* pParam2 = (LVCompareParam*)lParam2; + LVSortInfo* pInfo = (LVSortInfo*)lParamSort; + + int nRet = 0; + if(pParam1->lValue > pParam2->lValue) + nRet = 1; + else if(pParam1->lValue < pParam2->lValue) + nRet = -1; + return pInfo->bDescending ? -nRet : nRet; + } + + static int CALLBACK LVCompareDouble(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) + { + ATLASSERT((lParam1 != NULL) && (lParam2 != NULL) && (lParamSort != NULL)); + + LVCompareParam* pParam1 = (LVCompareParam*)lParam1; + LVCompareParam* pParam2 = (LVCompareParam*)lParam2; + LVSortInfo* pInfo = (LVSortInfo*)lParamSort; + + int nRet = 0; + if(pParam1->dblValue > pParam2->dblValue) + nRet = 1; + else if(pParam1->dblValue < pParam2->dblValue) + nRet = -1; + return pInfo->bDescending ? -nRet : nRet; + } + + static int CALLBACK LVCompareCustom(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) + { + ATLASSERT((lParam1 != NULL) && (lParam2 != NULL) && (lParamSort != NULL)); + + LVCompareParam* pParam1 = (LVCompareParam*)lParam1; + LVCompareParam* pParam2 = (LVCompareParam*)lParam2; + LVSortInfo* pInfo = (LVSortInfo*)lParamSort; + + int nRet = pInfo->pT->CompareItemsCustom(pParam1, pParam2, pInfo->iSortCol); + return pInfo->bDescending ? -nRet : nRet; + } + + static int CALLBACK LVCompareDecimal(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) + { + ATLASSERT((lParam1 != NULL) && (lParam2 != NULL) && (lParamSort != NULL)); + + LVCompareParam* pParam1 = (LVCompareParam*)lParam1; + LVCompareParam* pParam2 = (LVCompareParam*)lParam2; + LVSortInfo* pInfo = (LVSortInfo*)lParamSort; + + int nRet = (int)::VarDecCmp(&pParam1->decValue, &pParam2->decValue); + nRet--; + return pInfo->bDescending ? -nRet : nRet; + } + + BEGIN_MSG_MAP(CSortListViewImpl) + MESSAGE_HANDLER(LVM_INSERTCOLUMN, OnInsertColumn) + MESSAGE_HANDLER(LVM_DELETECOLUMN, OnDeleteColumn) + NOTIFY_CODE_HANDLER(HDN_ITEMCLICKA, OnHeaderItemClick) + NOTIFY_CODE_HANDLER(HDN_ITEMCLICKW, OnHeaderItemClick) + MESSAGE_HANDLER(WM_SETTINGCHANGE, OnSettingChange) + END_MSG_MAP() + + LRESULT OnInsertColumn(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) + { + T* pT = static_cast(this); + LRESULT lRet = pT->DefWindowProc(uMsg, wParam, lParam); + if(lRet == -1) + return -1; + + WORD wType = 0; + m_arrColSortType.Add(wType); + int nCount = m_arrColSortType.GetSize(); + ATLASSERT(nCount == GetColumnCount()); + + for(int i = nCount - 1; i > lRet; i--) + m_arrColSortType[i] = m_arrColSortType[i - 1]; + m_arrColSortType[(int)lRet] = LVCOLSORT_TEXT; + + if(lRet <= m_iSortColumn) + m_iSortColumn++; + + return lRet; + } + + LRESULT OnDeleteColumn(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) + { + T* pT = static_cast(this); + LRESULT lRet = pT->DefWindowProc(uMsg, wParam, lParam); + if(lRet == 0) + return 0; + + int iCol = (int)wParam; + if(m_iSortColumn == iCol) + m_iSortColumn = -1; + else if(m_iSortColumn > iCol) + m_iSortColumn--; + m_arrColSortType.RemoveAt(iCol); + + return lRet; + } + + LRESULT OnHeaderItemClick(int /*idCtrl*/, LPNMHDR pnmh, BOOL& bHandled) + { + LPNMHEADER p = (LPNMHEADER)pnmh; + if(p->iButton == 0) + { + int iOld = m_iSortColumn; + bool bDescending = (m_iSortColumn == p->iItem) ? !m_bSortDescending : false; + if(DoSortItems(p->iItem, bDescending)) + NotifyParentSortChanged(p->iItem, iOld); + } + bHandled = FALSE; + return 0; + } + + LRESULT OnSettingChange(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) + { + if(wParam == SPI_SETNONCLIENTMETRICS) + GetSystemSettings(); + bHandled = FALSE; + return 0; + } + + void GetSystemSettings() + { + if(!m_bCommCtrl6 && !m_bmSort[m_iSortUp].IsNull()) + { + T* pT = static_cast(this); + pT->CreateSortBitmaps(); + if(m_iSortColumn != -1) + SetSortColumn(m_iSortColumn); + } + } + +}; + + +typedef ATL::CWinTraits CSortListViewCtrlTraits; + +template +class ATL_NO_VTABLE CSortListViewCtrlImpl: public ATL::CWindowImpl, public CSortListViewImpl +{ +public: + DECLARE_WND_SUPERCLASS2(NULL, T, TBase::GetWndClassName()) + + bool SortItems(int iCol, bool bDescending = false) + { + return this->DoSortItems(iCol, bDescending); + } + + BEGIN_MSG_MAP(CSortListViewCtrlImpl) + MESSAGE_HANDLER(LVM_INSERTCOLUMN, CSortListViewImpl::OnInsertColumn) + MESSAGE_HANDLER(LVM_DELETECOLUMN, CSortListViewImpl::OnDeleteColumn) + NOTIFY_CODE_HANDLER(HDN_ITEMCLICKA, CSortListViewImpl::OnHeaderItemClick) + NOTIFY_CODE_HANDLER(HDN_ITEMCLICKW, CSortListViewImpl::OnHeaderItemClick) + MESSAGE_HANDLER(WM_SETTINGCHANGE, CSortListViewImpl::OnSettingChange) + END_MSG_MAP() +}; + +class CSortListViewCtrl : public CSortListViewCtrlImpl +{ +public: + DECLARE_WND_SUPERCLASS(_T("WTL_SortListViewCtrl"), GetWndClassName()) +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CTabView - implements tab view window + +// TabView Notifications +#define TBVN_PAGEACTIVATED (0U-741) +#define TBVN_CONTEXTMENU (0U-742) +#define TBVN_TABCLOSEBTN (0U-743) // return 0 to close page, 1 to keep open +// internal +#define TBVN_CLOSEBTNMOUSELEAVE (0U-744) + +// Notification data for TBVN_CONTEXTMENU +struct TBVCONTEXTMENUINFO +{ + NMHDR hdr; + POINT pt; +}; + +typedef TBVCONTEXTMENUINFO* LPTBVCONTEXTMENUINFO; + + +// Helper class for tab item hover close button +class CTabViewCloseBtn : public ATL::CWindowImpl +{ +public: + DECLARE_WND_CLASS_EX(_T("WTL_TabView_CloseBtn"), 0, -1) + + enum { _xyBtnImageLeftTop = 3, _xyBtnImageRightBottom = 9 }; + + bool m_bHover; + bool m_bPressed; + CToolTipCtrl m_tip; + + CTabViewCloseBtn() : m_bHover(false), m_bPressed(false) + { } + +// Message map and handlers + BEGIN_MSG_MAP(CTabViewCloseBtn) + MESSAGE_RANGE_HANDLER(WM_MOUSEFIRST, WM_MOUSELAST, OnMouseMessage) + MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown) + MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove) + MESSAGE_HANDLER(WM_MOUSELEAVE, OnMouseLeave) + MESSAGE_HANDLER(WM_LBUTTONUP, OnLButtonUp) + MESSAGE_HANDLER(WM_CAPTURECHANGED, OnCaptureChanged) + MESSAGE_HANDLER(WM_PAINT, OnPaint) + MESSAGE_HANDLER(WM_PRINTCLIENT, OnPaint) + FORWARD_NOTIFICATIONS() + END_MSG_MAP() + + LRESULT OnMouseMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) + { + MSG msg = { m_hWnd, uMsg, wParam, lParam }; + if(m_tip.IsWindow() != FALSE) + m_tip.RelayEvent(&msg); + + bHandled = FALSE; + return 1; + } + + LRESULT OnLButtonDown(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + SetCapture(); + m_bHover = false; + m_bPressed = true; + Invalidate(FALSE); + UpdateWindow(); + + return 0; + } + + LRESULT OnMouseMove(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/) + { + if(::GetCapture() == m_hWnd) + { + POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; + ClientToScreen(&pt); + RECT rect = {}; + GetWindowRect(&rect); + bool bPressed = (::PtInRect(&rect, pt) != FALSE); + if(m_bPressed != bPressed) + { + m_bPressed = bPressed; + Invalidate(FALSE); + UpdateWindow(); + } + } + else + { + if(!m_bHover) + { + m_bHover = true; + Invalidate(FALSE); + UpdateWindow(); + } + + TRACKMOUSEEVENT tme = { sizeof(TRACKMOUSEEVENT), TME_LEAVE, m_hWnd }; + ::TrackMouseEvent(&tme); + } + + return 0; + } + + LRESULT OnMouseLeave(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + if(m_bHover) + { + m_bHover = false; + Invalidate(FALSE); + UpdateWindow(); + } + + NMHDR nmhdr = { m_hWnd, (UINT_PTR)GetDlgCtrlID(), TBVN_CLOSEBTNMOUSELEAVE }; + GetParent().SendMessage(WM_NOTIFY, GetDlgCtrlID(), (LPARAM)&nmhdr); + + return 0; + } + + LRESULT OnLButtonUp(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + if(::GetCapture() == m_hWnd) + { + bool bAction = m_bPressed; + ReleaseCapture(); + + if(bAction) + GetParent().SendMessage(WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(), BN_CLICKED), (LPARAM)m_hWnd); + } + + return 0; + } + + LRESULT OnCaptureChanged(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + if(m_bPressed) + { + m_bPressed = false; + Invalidate(FALSE); + UpdateWindow(); + } + + return 0; + } + + LRESULT OnPaint(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + if(wParam != NULL) + { + DoPaint((HDC)wParam); + } + else + { + CPaintDC dc(this->m_hWnd); + DoPaint(dc.m_hDC); + } + + return 0; + } + + // painting helper + void DoPaint(CDCHandle dc) + { + RECT rect = {}; + GetClientRect(&rect); + + RECT rcImage = { _xyBtnImageLeftTop, _xyBtnImageLeftTop, _xyBtnImageRightBottom + 1, _xyBtnImageRightBottom + 1 }; + ::OffsetRect(&rcImage, rect.left, rect.top); + if(m_bPressed) + ::OffsetRect(&rcImage, 1, 0); + + // draw button frame and background + CPen penFrame; + penFrame.CreatePen(PS_SOLID, 0, ::GetSysColor((m_bHover || m_bPressed) ? COLOR_BTNTEXT : COLOR_BTNSHADOW)); + HPEN hPenOld = dc.SelectPen(penFrame); + + CBrush brush; + brush.CreateSysColorBrush(m_bPressed ? COLOR_BTNSHADOW : COLOR_WINDOW); + HBRUSH hBrushOld = dc.SelectBrush(brush); + + dc.Rectangle(&rect); + + // draw button "X" + CPen penX; + penX.CreatePen(PS_SOLID, 0, ::GetSysColor(COLOR_BTNTEXT)); + dc.SelectPen(penX); + + dc.MoveTo(rcImage.left, rcImage.top); + dc.LineTo(rcImage.right, rcImage.bottom); + dc.MoveTo(rcImage.left + 1, rcImage.top); + dc.LineTo(rcImage.right + 1, rcImage.bottom); + + dc.MoveTo(rcImage.left, rcImage.bottom - 1); + dc.LineTo(rcImage.right, rcImage.top - 1); + dc.MoveTo(rcImage.left + 1, rcImage.bottom - 1); + dc.LineTo(rcImage.right + 1, rcImage.top - 1); + + dc.SelectPen(hPenOld); + dc.SelectBrush(hBrushOld); + } +}; + + +template +class ATL_NO_VTABLE CTabViewImpl : public ATL::CWindowImpl< T, TBase, TWinTraits > +{ +public: + DECLARE_WND_CLASS_EX2(NULL, T, 0, COLOR_APPWORKSPACE) + +// Declarations and enums + struct TABVIEWPAGE + { + HWND hWnd; + LPTSTR lpstrTitle; + LPVOID pData; + }; + + struct TCITEMEXTRA + { + TCITEMHEADER tciheader; + TABVIEWPAGE tvpage; + + operator LPTCITEM() { return (LPTCITEM)this; } + }; + + enum + { + m_nTabID = 1313, + m_cxMoveMark = 6, + m_cyMoveMark = 3, + m_nMenuItemsMax = (ID_WINDOW_TABLAST - ID_WINDOW_TABFIRST + 1) + }; + + enum { _nAutoScrollTimerID = 4321 }; + + enum AutoScroll + { + _AUTOSCROLL_NONE = 0, + _AUTOSCROLL_LEFT = -1, + _AUTOSCROLL_RIGHT = 1 + }; + + enum CloseBtn + { + _cxCloseBtn = 14, + _cyCloseBtn = 13, + _cxCloseBtnMargin = 4, + _cxCloseBtnMarginSel = 1, + + _nCloseBtnID = ID_PANE_CLOSE + }; + +// Data members + ATL::CContainedWindowT m_tab; + int m_cyTabHeight; + + int m_nActivePage; + + int m_nInsertItem; + POINT m_ptStartDrag; + + CMenuHandle m_menu; + + int m_cchTabTextLength; + + int m_nMenuItemsCount; + + ATL::CWindow m_wndTitleBar; + LPTSTR m_lpstrTitleBarBase; + int m_cchTitleBarLength; + + CImageList m_ilDrag; + + AutoScroll m_AutoScroll; + CUpDownCtrl m_ud; + + CTabViewCloseBtn m_btnClose; + int m_nCloseItem; + + bool m_bDestroyPageOnRemove:1; + bool m_bDestroyImageList:1; + bool m_bActivePageMenuItem:1; + bool m_bActiveAsDefaultMenuItem:1; + bool m_bEmptyMenuItem:1; + bool m_bWindowsMenuItem:1; + bool m_bNoTabDrag:1; + bool m_bNoTabDragAutoScroll:1; + bool m_bTabCloseButton:1; + // internal + bool m_bTabCapture:1; + bool m_bTabDrag:1; + bool m_bInternalFont:1; + +// Constructor/destructor + CTabViewImpl() : + m_tab(this, 1), + m_cyTabHeight(0), + m_nActivePage(-1), + m_nInsertItem(-1), + m_cchTabTextLength(30), + m_nMenuItemsCount(10), + m_lpstrTitleBarBase(NULL), + m_cchTitleBarLength(100), + m_AutoScroll(_AUTOSCROLL_NONE), + m_nCloseItem(-1), + m_bDestroyPageOnRemove(true), + m_bDestroyImageList(true), + m_bActivePageMenuItem(true), + m_bActiveAsDefaultMenuItem(false), + m_bEmptyMenuItem(false), + m_bWindowsMenuItem(false), + m_bNoTabDrag(false), + m_bNoTabDragAutoScroll(false), + m_bTabCloseButton(true), + m_bTabCapture(false), + m_bTabDrag(false), + m_bInternalFont(false) + { + m_ptStartDrag.x = 0; + m_ptStartDrag.y = 0; + } + + ~CTabViewImpl() + { + delete [] m_lpstrTitleBarBase; + } + +// Message filter function - to be called from PreTranslateMessage of the main window + BOOL PreTranslateMessage(MSG* pMsg) + { + if(this->IsWindow() == FALSE) + return FALSE; + + BOOL bRet = FALSE; + + // Check for TabView built-in accelerators (Ctrl+Tab/Ctrl+Shift+Tab - next/previous page) + int nCount = GetPageCount(); + if(nCount > 0) + { + bool bControl = (::GetKeyState(VK_CONTROL) < 0); + if((pMsg->message == WM_KEYDOWN) && (pMsg->wParam == VK_TAB) && bControl) + { + if(nCount > 1) + { + int nPage = m_nActivePage; + bool bShift = (::GetKeyState(VK_SHIFT) < 0); + if(bShift) + nPage = (nPage > 0) ? (nPage - 1) : (nCount - 1); + else + nPage = ((nPage >= 0) && (nPage < (nCount - 1))) ? (nPage + 1) : 0; + + SetActivePage(nPage); + T* pT = static_cast(this); + pT->OnPageActivated(m_nActivePage); + } + + bRet = TRUE; + } + } + + // If we are doing drag-drop, check for Escape key that cancels it + if(bRet == FALSE) + { + if(m_bTabCapture && (pMsg->message == WM_KEYDOWN) && (pMsg->wParam == VK_ESCAPE)) + { + ::ReleaseCapture(); + bRet = TRUE; + } + } + + // Pass the message to the active page + if(bRet == FALSE) + { + if(m_nActivePage != -1) + bRet = (BOOL)::SendMessage(GetPageHWND(m_nActivePage), WM_FORWARDMSG, 0, (LPARAM)pMsg); + } + + return bRet; + } + +// Attributes + int GetPageCount() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return m_tab.GetItemCount(); + } + + int GetActivePage() const + { + return m_nActivePage; + } + + void SetActivePage(int nPage) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(IsValidPageIndex(nPage)); + + T* pT = static_cast(this); + + this->SetRedraw(FALSE); + + if(m_nActivePage != -1) + ::ShowWindow(GetPageHWND(m_nActivePage), SW_HIDE); + m_nActivePage = nPage; + m_tab.SetCurSel(m_nActivePage); + ::ShowWindow(GetPageHWND(m_nActivePage), SW_SHOW); + + pT->UpdateLayout(); + + this->SetRedraw(TRUE); + this->RedrawWindow(NULL, NULL, RDW_FRAME | RDW_INVALIDATE | RDW_UPDATENOW | RDW_ALLCHILDREN); + + if(::GetFocus() != m_tab.m_hWnd) + ::SetFocus(GetPageHWND(m_nActivePage)); + + pT->UpdateTitleBar(); + pT->UpdateMenu(); + } + + HIMAGELIST GetImageList() const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return m_tab.GetImageList(); + } + + HIMAGELIST SetImageList(HIMAGELIST hImageList) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return m_tab.SetImageList(hImageList); + } + + void SetWindowMenu(HMENU hMenu) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + + m_menu = hMenu; + + T* pT = static_cast(this); + pT->UpdateMenu(); + } + + void SetTitleBarWindow(HWND hWnd) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + + delete [] m_lpstrTitleBarBase; + m_lpstrTitleBarBase = NULL; + + m_wndTitleBar = hWnd; + if(hWnd == NULL) + return; + + int cchLen = m_wndTitleBar.GetWindowTextLength() + 1; + ATLTRY(m_lpstrTitleBarBase = new TCHAR[cchLen]); + if(m_lpstrTitleBarBase != NULL) + { + m_wndTitleBar.GetWindowText(m_lpstrTitleBarBase, cchLen); + T* pT = static_cast(this); + pT->UpdateTitleBar(); + } + } + +// Page attributes + HWND GetPageHWND(int nPage) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(IsValidPageIndex(nPage)); + + TCITEMEXTRA tcix = {}; + tcix.tciheader.mask = TCIF_PARAM; + m_tab.GetItem(nPage, tcix); + + return tcix.tvpage.hWnd; + } + + LPCTSTR GetPageTitle(int nPage) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(IsValidPageIndex(nPage)); + + TCITEMEXTRA tcix = {}; + tcix.tciheader.mask = TCIF_PARAM; + if(m_tab.GetItem(nPage, tcix) == FALSE) + return NULL; + + return tcix.tvpage.lpstrTitle; + } + + bool SetPageTitle(int nPage, LPCTSTR lpstrTitle) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(IsValidPageIndex(nPage)); + + T* pT = static_cast(this); + + int cchBuff = lstrlen(lpstrTitle) + 1; + LPTSTR lpstrBuff = NULL; + ATLTRY(lpstrBuff = new TCHAR[cchBuff]); + if(lpstrBuff == NULL) + return false; + + ATL::Checked::tcscpy_s(lpstrBuff, cchBuff, lpstrTitle); + TCITEMEXTRA tcix = {}; + tcix.tciheader.mask = TCIF_PARAM; + if(m_tab.GetItem(nPage, tcix) == FALSE) + return false; + + ATL::CTempBuffer buff; + LPTSTR lpstrTabText = buff.Allocate(m_cchTabTextLength + 1); + if(lpstrTabText == NULL) + return false; + + delete [] tcix.tvpage.lpstrTitle; + + pT->ShortenTitle(lpstrTitle, lpstrTabText, m_cchTabTextLength + 1); + + tcix.tciheader.mask = TCIF_TEXT | TCIF_PARAM; + tcix.tciheader.pszText = lpstrTabText; + tcix.tvpage.lpstrTitle = lpstrBuff; + if(m_tab.SetItem(nPage, tcix) == FALSE) + return false; + + pT->UpdateTitleBar(); + pT->UpdateMenu(); + + return true; + } + + LPVOID GetPageData(int nPage) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(IsValidPageIndex(nPage)); + + TCITEMEXTRA tcix = {}; + tcix.tciheader.mask = TCIF_PARAM; + m_tab.GetItem(nPage, tcix); + + return tcix.tvpage.pData; + } + + LPVOID SetPageData(int nPage, LPVOID pData) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(IsValidPageIndex(nPage)); + + TCITEMEXTRA tcix = {}; + tcix.tciheader.mask = TCIF_PARAM; + m_tab.GetItem(nPage, tcix); + LPVOID pDataOld = tcix.tvpage.pData; + + tcix.tvpage.pData = pData; + m_tab.SetItem(nPage, tcix); + + return pDataOld; + } + + int GetPageImage(int nPage) const + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(IsValidPageIndex(nPage)); + + TCITEMEXTRA tcix = {}; + tcix.tciheader.mask = TCIF_IMAGE; + m_tab.GetItem(nPage, tcix); + + return tcix.tciheader.iImage; + } + + int SetPageImage(int nPage, int nImage) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(IsValidPageIndex(nPage)); + + TCITEMEXTRA tcix = {}; + tcix.tciheader.mask = TCIF_IMAGE; + m_tab.GetItem(nPage, tcix); + int nImageOld = tcix.tciheader.iImage; + + tcix.tciheader.iImage = nImage; + m_tab.SetItem(nPage, tcix); + + return nImageOld; + } + +// Operations + bool AddPage(HWND hWndView, LPCTSTR lpstrTitle, int nImage = -1, LPVOID pData = NULL) + { + return InsertPage(GetPageCount(), hWndView, lpstrTitle, nImage, pData); + } + + bool InsertPage(int nPage, HWND hWndView, LPCTSTR lpstrTitle, int nImage = -1, LPVOID pData = NULL) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT((nPage == GetPageCount()) || IsValidPageIndex(nPage)); + + T* pT = static_cast(this); + + int cchBuff = lstrlen(lpstrTitle) + 1; + LPTSTR lpstrBuff = NULL; + ATLTRY(lpstrBuff = new TCHAR[cchBuff]); + if(lpstrBuff == NULL) + return false; + + ATL::Checked::tcscpy_s(lpstrBuff, cchBuff, lpstrTitle); + + ATL::CTempBuffer buff; + LPTSTR lpstrTabText = buff.Allocate(m_cchTabTextLength + 1); + if(lpstrTabText == NULL) + return false; + + pT->ShortenTitle(lpstrTitle, lpstrTabText, m_cchTabTextLength + 1); + + this->SetRedraw(FALSE); + + TCITEMEXTRA tcix = {}; + tcix.tciheader.mask = TCIF_TEXT | TCIF_IMAGE | TCIF_PARAM; + tcix.tciheader.pszText = lpstrTabText; + tcix.tciheader.iImage = nImage; + tcix.tvpage.hWnd = hWndView; + tcix.tvpage.lpstrTitle = lpstrBuff; + tcix.tvpage.pData = pData; + int nItem = m_tab.InsertItem(nPage, tcix); + if(nItem == -1) + { + delete [] lpstrBuff; + this->SetRedraw(TRUE); + return false; + } + + // adjust active page index, if inserted before it + if(nPage <= m_nActivePage) + m_nActivePage++; + + SetActivePage(nItem); + pT->OnPageActivated(m_nActivePage); + + if(GetPageCount() == 1) + pT->ShowTabControl(true); + + pT->UpdateLayout(); + + this->SetRedraw(TRUE); + this->RedrawWindow(NULL, NULL, RDW_FRAME | RDW_INVALIDATE | RDW_UPDATENOW | RDW_ALLCHILDREN); + + return true; + } + + void RemovePage(int nPage) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + ATLASSERT(IsValidPageIndex(nPage)); + + T* pT = static_cast(this); + + this->SetRedraw(FALSE); + + if(GetPageCount() == 1) + pT->ShowTabControl(false); + + if(m_bDestroyPageOnRemove) + ::DestroyWindow(GetPageHWND(nPage)); + else + ::ShowWindow(GetPageHWND(nPage), SW_HIDE); + LPTSTR lpstrTitle = (LPTSTR)GetPageTitle(nPage); + delete [] lpstrTitle; + + ATLVERIFY(m_tab.DeleteItem(nPage) != FALSE); + + if(m_nActivePage == nPage) + { + m_nActivePage = -1; + + if(nPage > 0) + { + SetActivePage(nPage - 1); + } + else if(GetPageCount() > 0) + { + SetActivePage(nPage); + } + else + { + this->SetRedraw(TRUE); + this->Invalidate(); + this->UpdateWindow(); + pT->UpdateTitleBar(); + pT->UpdateMenu(); + } + } + else + { + nPage = (nPage < m_nActivePage) ? (m_nActivePage - 1) : m_nActivePage; + m_nActivePage = -1; + SetActivePage(nPage); + } + + pT->OnPageActivated(m_nActivePage); + } + + void RemoveAllPages() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + + if(GetPageCount() == 0) + return; + + T* pT = static_cast(this); + + this->SetRedraw(FALSE); + + pT->ShowTabControl(false); + + for(int i = 0; i < GetPageCount(); i++) + { + if(m_bDestroyPageOnRemove) + ::DestroyWindow(GetPageHWND(i)); + else + ::ShowWindow(GetPageHWND(i), SW_HIDE); + LPTSTR lpstrTitle = (LPTSTR)GetPageTitle(i); + delete [] lpstrTitle; + } + m_tab.DeleteAllItems(); + + m_nActivePage = -1; + pT->OnPageActivated(m_nActivePage); + + this->SetRedraw(TRUE); + this->Invalidate(); + this->UpdateWindow(); + + pT->UpdateTitleBar(); + pT->UpdateMenu(); + } + + int PageIndexFromHwnd(HWND hWnd) const + { + int nIndex = -1; + + for(int i = 0; i < GetPageCount(); i++) + { + if(GetPageHWND(i) == hWnd) + { + nIndex = i; + break; + } + } + + return nIndex; + } + + void BuildWindowMenu(HMENU hMenu, int nMenuItemsCount = 10, bool bEmptyMenuItem = true, bool bWindowsMenuItem = true, bool bActivePageMenuItem = true, bool bActiveAsDefaultMenuItem = false) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + + CMenuHandle menu = hMenu; + T* pT = static_cast(this); + (void)pT; // avoid level 4 warning + int nFirstPos = 0; + + // Find first menu item in our range + for(nFirstPos = 0; nFirstPos < menu.GetMenuItemCount(); nFirstPos++) + { + UINT nID = menu.GetMenuItemID(nFirstPos); + if(((nID >= ID_WINDOW_TABFIRST) && (nID <= ID_WINDOW_TABLAST)) || (nID == ID_WINDOW_SHOWTABLIST)) + break; + } + + // Remove all menu items for tab pages + BOOL bRet = TRUE; + while(bRet != FALSE) + bRet = menu.DeleteMenu(nFirstPos, MF_BYPOSITION); + + // Add separator if it's not already there + int nPageCount = GetPageCount(); + if((bWindowsMenuItem || (nPageCount > 0)) && (nFirstPos > 0)) + { + CMenuItemInfo mii; + mii.fMask = MIIM_TYPE; + menu.GetMenuItemInfo(nFirstPos - 1, TRUE, &mii); + if((nFirstPos <= 0) || ((mii.fType & MFT_SEPARATOR) == 0)) + { + menu.AppendMenu(MF_SEPARATOR); + nFirstPos++; + } + } + + // Add menu items for all pages + if(nPageCount > 0) + { + // Append menu items for all pages + const int cchPrefix = 3; // 2 digits + space + nMenuItemsCount = __min(__min(nPageCount, nMenuItemsCount), (int)m_nMenuItemsMax); + ATLASSERT(nMenuItemsCount < 100); // 2 digits only + if(nMenuItemsCount >= 100) + nMenuItemsCount = 99; + + for(int i = 0; i < nMenuItemsCount; i++) + { + LPCTSTR lpstrTitle = GetPageTitle(i); + int nLen = lstrlen(lpstrTitle); + ATL::CTempBuffer buff; + LPTSTR lpstrText = buff.Allocate(cchPrefix + nLen + 1); + ATLASSERT(lpstrText != NULL); + if(lpstrText != NULL) + { + LPCTSTR lpstrFormat = (i < 9) ? _T("&%i %s") : _T("%i %s"); + _stprintf_s(lpstrText, cchPrefix + nLen + 1, lpstrFormat, i + 1, lpstrTitle); + menu.AppendMenu(MF_STRING, ID_WINDOW_TABFIRST + i, lpstrText); + } + } + + // Mark active page + if(bActivePageMenuItem && (m_nActivePage != -1)) + { + if(bActiveAsDefaultMenuItem) + { + menu.SetMenuDefaultItem((UINT)-1, TRUE); + menu.SetMenuDefaultItem(nFirstPos + m_nActivePage, TRUE); + } + else + { + menu.CheckMenuRadioItem(nFirstPos, nFirstPos + nMenuItemsCount, nFirstPos + m_nActivePage, MF_BYPOSITION); + } + } + } + else + { + if(bEmptyMenuItem) + { + menu.AppendMenu(MF_BYPOSITION | MF_STRING, ID_WINDOW_TABFIRST, pT->GetEmptyListText()); + menu.EnableMenuItem(ID_WINDOW_TABFIRST, MF_GRAYED); + } + + // Remove separator if nothing else is there + if(!bEmptyMenuItem && !bWindowsMenuItem && (nFirstPos > 0)) + { + CMenuItemInfo mii; + mii.fMask = MIIM_TYPE; + menu.GetMenuItemInfo(nFirstPos - 1, TRUE, &mii); + if((mii.fType & MFT_SEPARATOR) != 0) + menu.DeleteMenu(nFirstPos - 1, MF_BYPOSITION); + } + } + + // Add "Windows..." menu item + if(bWindowsMenuItem) + menu.AppendMenu(MF_BYPOSITION | MF_STRING, ID_WINDOW_SHOWTABLIST, pT->GetWindowsMenuItemText()); + } + + BOOL SubclassWindow(HWND hWnd) + { + BOOL bRet = ATL::CWindowImpl< T, TBase, TWinTraits >::SubclassWindow(hWnd); + if(bRet != FALSE) + { + T* pT = static_cast(this); + pT->CreateTabControl(); + pT->UpdateLayout(); + } + + return bRet; + } + +// Message map and handlers + BEGIN_MSG_MAP(CTabViewImpl) + MESSAGE_HANDLER(WM_CREATE, OnCreate) + MESSAGE_HANDLER(WM_DESTROY, OnDestroy) + MESSAGE_HANDLER(WM_SIZE, OnSize) + MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus) + MESSAGE_HANDLER(WM_GETFONT, OnGetFont) + MESSAGE_HANDLER(WM_SETFONT, OnSetFont) + MESSAGE_HANDLER(WM_TIMER, OnTimer) + MESSAGE_HANDLER(WM_CONTEXTMENU, OnTabContextMenu) + NOTIFY_HANDLER(m_nTabID, TCN_SELCHANGE, OnTabChanged) + NOTIFY_ID_HANDLER(m_nTabID, OnTabNotification) + NOTIFY_CODE_HANDLER(TTN_GETDISPINFO, OnTabGetDispInfo) + FORWARD_NOTIFICATIONS() + ALT_MSG_MAP(1) // tab control + MESSAGE_HANDLER(WM_LBUTTONDOWN, OnTabLButtonDown) + MESSAGE_HANDLER(WM_LBUTTONUP, OnTabLButtonUp) + MESSAGE_HANDLER(WM_CAPTURECHANGED, OnTabCaptureChanged) + MESSAGE_HANDLER(WM_MOUSEMOVE, OnTabMouseMove) + MESSAGE_HANDLER(WM_MOUSELEAVE, OnTabMouseLeave) + NOTIFY_HANDLER(T::_nCloseBtnID, TBVN_CLOSEBTNMOUSELEAVE, OnTabCloseBtnMouseLeave) + COMMAND_HANDLER(T::_nCloseBtnID, BN_CLICKED, OnTabCloseBtnClicked) + END_MSG_MAP() + + LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + T* pT = static_cast(this); + pT->CreateTabControl(); + + return 0; + } + + LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + RemoveAllPages(); + + if(m_bDestroyImageList) + { + CImageList il = m_tab.SetImageList(NULL); + if(il.m_hImageList != NULL) + il.Destroy(); + } + + if(m_bInternalFont) + { + HFONT hFont = m_tab.GetFont(); + m_tab.SetFont(NULL, FALSE); + ::DeleteObject(hFont); + m_bInternalFont = false; + } + + m_ud.m_hWnd = NULL; + + return 0; + } + + LRESULT OnSize(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + T* pT = static_cast(this); + pT->UpdateLayout(); + return 0; + } + + LRESULT OnSetFocus(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + if(m_nActivePage != -1) + ::SetFocus(GetPageHWND(m_nActivePage)); + return 0; + } + + LRESULT OnGetFont(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + return m_tab.SendMessage(WM_GETFONT); + } + + LRESULT OnSetFont(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) + { + if(m_bInternalFont) + { + HFONT hFont = m_tab.GetFont(); + m_tab.SetFont(NULL, FALSE); + ::DeleteObject(hFont); + m_bInternalFont = false; + } + + m_tab.SendMessage(WM_SETFONT, wParam, lParam); + + T* pT = static_cast(this); + m_cyTabHeight = pT->CalcTabHeight(); + + if((BOOL)lParam != FALSE) + pT->UpdateLayout(); + + return 0; + } + + LRESULT OnTimer(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) + { + if(wParam == _nAutoScrollTimerID) + { + T* pT = static_cast(this); + pT->DoAutoScroll(); + } + else + { + bHandled = FALSE; + } + + return 0; + } + + LRESULT OnTabContextMenu(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled) + { + POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; + int nPage = m_nActivePage; + bool bAction = false; + if((HWND)wParam == m_tab.m_hWnd) + { + if((pt.x == -1) && (pt.y == -1)) // keyboard + { + RECT rect = {}; + m_tab.GetItemRect(m_nActivePage, &rect); + pt.x = rect.left; + pt.y = rect.bottom; + m_tab.ClientToScreen(&pt); + bAction = true; + } + else if(::WindowFromPoint(pt) == m_tab.m_hWnd) + { + TCHITTESTINFO hti = {}; + hti.pt = pt; + this->ScreenToClient(&hti.pt); + nPage = m_tab.HitTest(&hti); + + bAction = true; + } + } + + if(bAction) + { + T* pT = static_cast(this); + pT->OnContextMenu(nPage, pt); + } + else + { + bHandled = FALSE; + } + + return 0; + } + + LRESULT OnTabChanged(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/) + { + if(m_bTabCloseButton && (m_btnClose.m_hWnd != NULL)) + { + T* pT = static_cast(this); + RECT rcClose = {}; + pT->CalcCloseButtonRect(m_nCloseItem, rcClose); + m_btnClose.SetWindowPos(NULL, &rcClose, SWP_NOZORDER | SWP_NOACTIVATE); + } + + SetActivePage(m_tab.GetCurSel()); + T* pT = static_cast(this); + pT->OnPageActivated(m_nActivePage); + + return 0; + } + + LRESULT OnTabNotification(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/) + { + // nothing to do - this just blocks all tab control + // notifications from being propagated further + return 0; + } + + LRESULT OnTabGetDispInfo(int /*idCtrl*/, LPNMHDR pnmh, BOOL& bHandled) + { + LPNMTTDISPINFO pTTDI = (LPNMTTDISPINFO)pnmh; + if(pTTDI->hdr.hwndFrom == m_tab.GetTooltips()) + { + T* pT = static_cast(this); + pT->UpdateTooltipText(pTTDI); + } + else + { + bHandled = FALSE; + } + + return 0; + } + +// Tab control message handlers + LRESULT OnTabLButtonDown(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled) + { + if(!m_bNoTabDrag && (m_tab.GetItemCount() > 1)) + { + m_bTabCapture = true; + m_tab.SetCapture(); + + m_ptStartDrag.x = GET_X_LPARAM(lParam); + m_ptStartDrag.y = GET_Y_LPARAM(lParam); + } + + bHandled = FALSE; + return 0; + } + + LRESULT OnTabLButtonUp(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled) + { + if(m_bTabCapture) + { + if(m_bTabDrag) + { + T* pT = static_cast(this); + POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; + int nItem = pT->DragHitTest(pt); + if(nItem != -1) + MovePage(m_nActivePage, nItem); + } + + ::ReleaseCapture(); + } + + bHandled = FALSE; + return 0; + } + + LRESULT OnTabCaptureChanged(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) + { + if(m_bTabCapture) + { + m_bTabCapture = false; + + if(m_bTabDrag) + { + m_bTabDrag = false; + + T* pT = static_cast(this); + if(!m_bNoTabDragAutoScroll) + pT->StartStopAutoScroll(-1); + + pT->DrawMoveMark(-1); + + m_ilDrag.DragLeave(GetDesktopWindow()); + m_ilDrag.EndDrag(); + + m_ilDrag.Destroy(); + m_ilDrag.m_hImageList = NULL; + } + } + + bHandled = FALSE; + return 0; + } + + LRESULT OnTabMouseMove(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled) + { + bHandled = FALSE; + + if(m_bTabCapture) + { + POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; + + if(!m_bTabDrag) + { + if((abs(m_ptStartDrag.x - GET_X_LPARAM(lParam)) >= ::GetSystemMetrics(SM_CXDRAG)) || + (abs(m_ptStartDrag.y - GET_Y_LPARAM(lParam)) >= ::GetSystemMetrics(SM_CYDRAG))) + { + T* pT = static_cast(this); + pT->GenerateDragImage(m_nActivePage); + + int cxCursor = ::GetSystemMetrics(SM_CXCURSOR); + int cyCursor = ::GetSystemMetrics(SM_CYCURSOR); + m_ilDrag.BeginDrag(0, -(cxCursor / 2), -(cyCursor / 2)); + POINT ptEnter = m_ptStartDrag; + m_tab.ClientToScreen(&ptEnter); + m_ilDrag.DragEnter(GetDesktopWindow(), ptEnter); + + m_bTabDrag = true; + } + } + + if(m_bTabDrag) + { + T* pT = static_cast(this); + int nItem = pT->DragHitTest(pt); + + pT->SetMoveCursor(nItem != -1); + + if(m_nInsertItem != nItem) + pT->DrawMoveMark(nItem); + + if(!m_bNoTabDragAutoScroll) + pT->StartStopAutoScroll(pt.x); + + m_ilDrag.DragShowNolock((nItem != -1) ? TRUE : FALSE); + m_tab.ClientToScreen(&pt); + m_ilDrag.DragMove(pt); + + bHandled = TRUE; + } + } + else if(m_bTabCloseButton) + { + TCHITTESTINFO thti = {}; + thti.pt.x = GET_X_LPARAM(lParam); + thti.pt.y = GET_Y_LPARAM(lParam); + + int nItem = m_tab.HitTest(&thti); + if(nItem >= 0) + { + ATLTRACE(_T("+++++ item = %i\n"), nItem); + + T* pT = static_cast(this); + if(m_btnClose.m_hWnd == NULL) + { + pT->CreateCloseButton(nItem); + m_nCloseItem = nItem; + } + else if(m_nCloseItem != nItem) + { + RECT rcClose = {}; + pT->CalcCloseButtonRect(nItem, rcClose); + m_btnClose.SetWindowPos(NULL, &rcClose, SWP_NOZORDER | SWP_NOACTIVATE); + m_nCloseItem = nItem; + } + + TRACKMOUSEEVENT tme = { sizeof(TRACKMOUSEEVENT), TME_LEAVE, m_tab.m_hWnd }; + ::TrackMouseEvent(&tme); + } + } + + return 0; + } + + LRESULT OnTabMouseLeave(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) + { + bHandled = FALSE; + + if(m_btnClose.m_hWnd != NULL) + { + POINT pt = {}; + ::GetCursorPos(&pt); + RECT rect = {}; + m_btnClose.GetWindowRect(&rect); + if(::PtInRect(&rect, pt) == FALSE) + { + m_nCloseItem = -1; + T* pT = static_cast(this); + pT->DestroyCloseButton(); + } + else + { + bHandled = TRUE; + } + } + + return 0; + } + + LRESULT OnTabCloseBtnMouseLeave(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/) + { + TCHITTESTINFO thti = {}; + ::GetCursorPos(&thti.pt); + m_tab.ScreenToClient(&thti.pt); + int nItem = m_tab.HitTest(&thti); + if(nItem == -1) + m_tab.SendMessage(WM_MOUSELEAVE); + + return 0; + } + + LRESULT OnTabCloseBtnClicked(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) + { + T* pT = static_cast(this); + pT->OnTabCloseBtn(m_nCloseItem); + + return 0; + } + +// Implementation helpers + bool IsValidPageIndex(int nPage) const + { + return ((nPage >= 0) && (nPage < GetPageCount())); + } + + bool MovePage(int nMovePage, int nInsertBeforePage) + { + ATLASSERT(IsValidPageIndex(nMovePage)); + ATLASSERT(IsValidPageIndex(nInsertBeforePage)); + + if(!IsValidPageIndex(nMovePage) || !IsValidPageIndex(nInsertBeforePage)) + return false; + + if(nMovePage == nInsertBeforePage) + return true; // nothing to do + + ATL::CTempBuffer buff; + LPTSTR lpstrTabText = buff.Allocate(m_cchTabTextLength + 1); + if(lpstrTabText == NULL) + return false; + TCITEMEXTRA tcix = {}; + tcix.tciheader.mask = TCIF_TEXT | TCIF_IMAGE | TCIF_PARAM; + tcix.tciheader.pszText = lpstrTabText; + tcix.tciheader.cchTextMax = m_cchTabTextLength + 1; + BOOL bRet = m_tab.GetItem(nMovePage, tcix); + ATLASSERT(bRet != FALSE); + if(bRet == FALSE) + return false; + + int nInsertItem = (nInsertBeforePage > nMovePage) ? nInsertBeforePage + 1 : nInsertBeforePage; + int nNewItem = m_tab.InsertItem(nInsertItem, tcix); + ATLASSERT(nNewItem == nInsertItem); + if(nNewItem != nInsertItem) + { + ATLVERIFY(m_tab.DeleteItem(nNewItem)); + return false; + } + + if(nMovePage > nInsertBeforePage) + ATLVERIFY(m_tab.DeleteItem(nMovePage + 1) != FALSE); + else if(nMovePage < nInsertBeforePage) + ATLVERIFY(m_tab.DeleteItem(nMovePage) != FALSE); + + SetActivePage(nInsertBeforePage); + T* pT = static_cast(this); + pT->OnPageActivated(m_nActivePage); + + return true; + } + +// Implementation overrideables + bool CreateTabControl() + { + m_tab.Create(this->m_hWnd, this->rcDefault, NULL, WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | TCS_TOOLTIPS, 0, m_nTabID); + ATLASSERT(m_tab.m_hWnd != NULL); + if(m_tab.m_hWnd == NULL) + return false; + + m_tab.SetFont(AtlCreateControlFont()); + m_bInternalFont = true; + + m_tab.SetItemExtra(sizeof(TABVIEWPAGE)); + + T* pT = static_cast(this); + m_cyTabHeight = pT->CalcTabHeight(); + + return true; + } + + int CalcTabHeight() + { + int nCount = m_tab.GetItemCount(); + TCHAR szText[] = _T("NS"); + TCITEMEXTRA tcix = {}; + tcix.tciheader.mask = TCIF_TEXT; + tcix.tciheader.pszText = szText; + int nIndex = m_tab.InsertItem(nCount, tcix); + + RECT rect = { 0, 0, 1000, 1000 }; + m_tab.AdjustRect(FALSE, &rect); + + RECT rcWnd = { 0, 0, 1000, rect.top }; + ::AdjustWindowRectEx(&rcWnd, m_tab.GetStyle(), FALSE, m_tab.GetExStyle()); + + int nHeight = rcWnd.bottom - rcWnd.top; + + m_tab.DeleteItem(nIndex); + + return nHeight; + } + + void ShowTabControl(bool bShow) + { + m_tab.ShowWindow(bShow ? SW_SHOWNOACTIVATE : SW_HIDE); + T* pT = static_cast(this); + pT->UpdateLayout(); + } + + void UpdateLayout() + { + RECT rect = {}; + this->GetClientRect(&rect); + + int cyOffset = 0; + if(m_tab.IsWindow() && ((m_tab.GetStyle() & WS_VISIBLE) != 0)) + { + m_tab.SetWindowPos(NULL, 0, 0, rect.right - rect.left, m_cyTabHeight, SWP_NOZORDER); + cyOffset = m_cyTabHeight; + } + + if(m_nActivePage != -1) + ::SetWindowPos(GetPageHWND(m_nActivePage), NULL, 0, cyOffset, rect.right - rect.left, rect.bottom - rect.top - cyOffset, SWP_NOZORDER); + } + + void UpdateMenu() + { + if(m_menu.m_hMenu != NULL) + BuildWindowMenu(m_menu, m_nMenuItemsCount, m_bEmptyMenuItem, m_bWindowsMenuItem, m_bActivePageMenuItem, m_bActiveAsDefaultMenuItem); + } + + void UpdateTitleBar() + { + if(!m_wndTitleBar.IsWindow() || (m_lpstrTitleBarBase == NULL)) + return; // nothing to do + + if(m_nActivePage != -1) + { + T* pT = static_cast(this); + LPCTSTR lpstrTitle = pT->GetPageTitle(m_nActivePage); + LPCTSTR lpstrDivider = pT->GetTitleDividerText(); + int cchBuffer = m_cchTitleBarLength + lstrlen(lpstrDivider) + lstrlen(m_lpstrTitleBarBase) + 1; + ATL::CTempBuffer buff; + LPTSTR lpstrPageTitle = buff.Allocate(cchBuffer); + ATLASSERT(lpstrPageTitle != NULL); + if(lpstrPageTitle != NULL) + { + pT->ShortenTitle(lpstrTitle, lpstrPageTitle, m_cchTitleBarLength + 1); + ATL::Checked::tcscat_s(lpstrPageTitle, cchBuffer, lpstrDivider); + ATL::Checked::tcscat_s(lpstrPageTitle, cchBuffer, m_lpstrTitleBarBase); + } + else + { + lpstrPageTitle = m_lpstrTitleBarBase; + } + + m_wndTitleBar.SetWindowText(lpstrPageTitle); + } + else + { + m_wndTitleBar.SetWindowText(m_lpstrTitleBarBase); + } + } + + void DrawMoveMark(int nItem) + { + T* pT = static_cast(this); + + if(m_nInsertItem != -1) + { + RECT rect = {}; + pT->GetMoveMarkRect(rect); + m_tab.InvalidateRect(&rect); + } + + m_nInsertItem = nItem; + + if(m_nInsertItem != -1) + { + CClientDC dc(m_tab.m_hWnd); + + RECT rect = {}; + pT->GetMoveMarkRect(rect); + + CPen pen; + pen.CreatePen(PS_SOLID, 1, ::GetSysColor(COLOR_WINDOWTEXT)); + CBrush brush; + brush.CreateSolidBrush(::GetSysColor(COLOR_WINDOWTEXT)); + + HPEN hPenOld = dc.SelectPen(pen); + HBRUSH hBrushOld = dc.SelectBrush(brush); + + int x = rect.left; + int y = rect.top; + POINT ptsTop[3] = { { x, y }, { x + m_cxMoveMark, y }, { x + (m_cxMoveMark / 2), y + m_cyMoveMark } }; + dc.Polygon(ptsTop, 3); + + y = rect.bottom - 1; + POINT ptsBottom[3] = { { x, y }, { x + m_cxMoveMark, y }, { x + (m_cxMoveMark / 2), y - m_cyMoveMark } }; + dc.Polygon(ptsBottom, 3); + + dc.SelectPen(hPenOld); + dc.SelectBrush(hBrushOld); + } + } + + void GetMoveMarkRect(RECT& rect) const + { + m_tab.GetClientRect(&rect); + + RECT rcItem = {}; + m_tab.GetItemRect(m_nInsertItem, &rcItem); + + if(m_nInsertItem <= m_nActivePage) + { + rect.left = rcItem.left - m_cxMoveMark / 2 - 1; + rect.right = rcItem.left + m_cxMoveMark / 2; + } + else + { + rect.left = rcItem.right - m_cxMoveMark / 2 - 1; + rect.right = rcItem.right + m_cxMoveMark / 2; + } + } + + void SetMoveCursor(bool bCanMove) + { + ::SetCursor(::LoadCursor(NULL, bCanMove ? IDC_ARROW : IDC_NO)); + } + + void GenerateDragImage(int nItem) + { + ATLASSERT(IsValidPageIndex(nItem)); + + RECT rcItem = {}; + m_tab.GetItemRect(nItem, &rcItem); + ::InflateRect(&rcItem, 2, 2); // make bigger to cover selected item + + ATLASSERT(m_ilDrag.m_hImageList == NULL); + m_ilDrag.Create(rcItem.right - rcItem.left, rcItem.bottom - rcItem.top, ILC_COLORDDB | ILC_MASK, 1, 1); + + CClientDC dc(this->m_hWnd); + CDC dcMem; + dcMem.CreateCompatibleDC(dc); + ATLASSERT(dcMem.m_hDC != NULL); + dcMem.SetViewportOrg(-rcItem.left, -rcItem.top); + + CBitmap bmp; + bmp.CreateCompatibleBitmap(dc, rcItem.right - rcItem.left, rcItem.bottom - rcItem.top); + ATLASSERT(bmp.m_hBitmap != NULL); + + HBITMAP hBmpOld = dcMem.SelectBitmap(bmp); + m_tab.SendMessage(WM_PRINTCLIENT, (WPARAM)dcMem.m_hDC); + dcMem.SelectBitmap(hBmpOld); + + ATLVERIFY(m_ilDrag.Add(bmp.m_hBitmap, RGB(255, 0, 255)) != -1); + } + + void ShortenTitle(LPCTSTR lpstrTitle, LPTSTR lpstrShortTitle, int cchShortTitle) + { + if(lstrlen(lpstrTitle) >= cchShortTitle) + { + LPCTSTR lpstrEllipsis = _T("..."); + int cchEllipsis = lstrlen(lpstrEllipsis); + ATL::Checked::tcsncpy_s(lpstrShortTitle, cchShortTitle, lpstrTitle, cchShortTitle - cchEllipsis - 1); + ATL::Checked::tcscat_s(lpstrShortTitle, cchShortTitle, lpstrEllipsis); + } + else + { + ATL::Checked::tcscpy_s(lpstrShortTitle, cchShortTitle, lpstrTitle); + } + } + + void UpdateTooltipText(LPNMTTDISPINFO pTTDI) + { + ATLASSERT(pTTDI != NULL); + pTTDI->lpszText = (LPTSTR)GetPageTitle((int)pTTDI->hdr.idFrom); + } + + int DragHitTest(POINT pt) const + { + RECT rect = {}; + this->GetClientRect(&rect); + if(::PtInRect(&rect, pt) == FALSE) + return -1; + + m_tab.GetClientRect(&rect); + TCHITTESTINFO hti = {}; + hti.pt.x = pt.x; + hti.pt.y = rect.bottom / 2; // use middle to ignore + int nItem = m_tab.HitTest(&hti); + if(nItem == -1) + { + int nLast = m_tab.GetItemCount() - 1; + RECT rcItem = {}; + m_tab.GetItemRect(nLast, &rcItem); + if(pt.x >= rcItem.right) + nItem = nLast; + } + + return nItem; + } + + void StartStopAutoScroll(int x) + { + AutoScroll scroll = _AUTOSCROLL_NONE; + if(x != -1) + { + RECT rect = {}; + m_tab.GetClientRect(&rect); + int dx = ::GetSystemMetrics(SM_CXVSCROLL); + if((x >= 0) && (x < dx)) + { + RECT rcItem = {}; + m_tab.GetItemRect(0, &rcItem); + if(rcItem.left < rect.left) + scroll = _AUTOSCROLL_LEFT; + } + else if((x >= (rect.right - dx)) && (x < rect.right)) + { + RECT rcItem = {}; + m_tab.GetItemRect(m_tab.GetItemCount() - 1, &rcItem); + if(rcItem.right > rect.right) + scroll = _AUTOSCROLL_RIGHT; + } + } + + if(scroll != _AUTOSCROLL_NONE) + { + if(m_ud.m_hWnd == NULL) + m_ud = m_tab.GetWindow(GW_CHILD); + + if(m_AutoScroll != scroll) + { + m_AutoScroll = scroll; + this->SetTimer(_nAutoScrollTimerID, 300); + } + } + else + { + this->KillTimer(_nAutoScrollTimerID); + m_AutoScroll = _AUTOSCROLL_NONE; + } + } + + void DoAutoScroll() + { + ATLASSERT(m_AutoScroll != _AUTOSCROLL_NONE); + + int nMin = -1, nMax = -1; + m_ud.GetRange(nMin, nMax); + int nPos = m_ud.GetPos(); + + int nNewPos = -1; + if((m_AutoScroll == _AUTOSCROLL_LEFT) && (nPos > nMin)) + nNewPos = nPos - 1; + else if((m_AutoScroll == _AUTOSCROLL_RIGHT) && (nPos < nMax)) + nNewPos = nPos + 1; + if(nNewPos != -1) + { + m_tab.SendMessage(WM_HSCROLL, MAKEWPARAM(SB_THUMBPOSITION, nNewPos)); + m_tab.SendMessage(WM_HSCROLL, MAKEWPARAM(SB_ENDSCROLL, 0)); + + POINT pt = {}; + ::GetCursorPos(&pt); + m_tab.ScreenToClient(&pt); + m_tab.SendMessage(WM_MOUSEMOVE, NULL, MAKELPARAM(pt.x, pt.y)); + } + } + +// Text for menu items and title bar - override to provide different strings + static LPCTSTR GetEmptyListText() + { + return _T("(Empty)"); + } + + static LPCTSTR GetWindowsMenuItemText() + { + return _T("&Windows..."); + } + + static LPCTSTR GetTitleDividerText() + { + return _T(" - "); + } + +// Notifications - override to provide different behavior + void OnPageActivated(int nPage) + { + NMHDR nmhdr = {}; + nmhdr.hwndFrom = this->m_hWnd; + nmhdr.idFrom = nPage; + nmhdr.code = TBVN_PAGEACTIVATED; + this->GetParent().SendMessage(WM_NOTIFY, this->GetDlgCtrlID(), (LPARAM)&nmhdr); + } + + void OnContextMenu(int nPage, POINT pt) + { + TBVCONTEXTMENUINFO cmi = {}; + cmi.hdr.hwndFrom = this->m_hWnd; + cmi.hdr.idFrom = nPage; + cmi.hdr.code = TBVN_CONTEXTMENU; + cmi.pt = pt; + this->GetParent().SendMessage(WM_NOTIFY, this->GetDlgCtrlID(), (LPARAM)&cmi); + } + + void OnTabCloseBtn(int nPage) + { + NMHDR nmhdr = {}; + nmhdr.hwndFrom = this->m_hWnd; + nmhdr.idFrom = nPage; + nmhdr.code = TBVN_TABCLOSEBTN; + LRESULT lRet = this->GetParent().SendMessage(WM_NOTIFY, this->GetDlgCtrlID(), (LPARAM)&nmhdr); + if(lRet == 0) // default - close page + { + T* pT = static_cast(this); + pT->RemovePage(m_nCloseItem); + m_nCloseItem = -1; + pT->DestroyCloseButton(); + } + else + { + m_tab.SendMessage(WM_MOUSELEAVE); + } + } + +// Close button overrideables + void CreateCloseButton(int nItem) + { + ATLASSERT(m_btnClose.m_hWnd == NULL); + + m_btnClose.m_bPressed = false; + + T* pT = static_cast(this); + RECT rcClose = {}; + pT->CalcCloseButtonRect(nItem, rcClose); + m_btnClose.Create(m_tab.m_hWnd, rcClose, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 0, T::_nCloseBtnID); + ATLASSERT(m_btnClose.IsWindow()); + + if(m_btnClose.m_hWnd != NULL) + { + // create a tool tip + ATLASSERT(m_btnClose.m_tip.m_hWnd == NULL); + m_btnClose.m_tip.Create(m_btnClose.m_hWnd); + ATLASSERT(m_btnClose.m_tip.IsWindow()); + + if(m_btnClose.m_tip.IsWindow()) + { + m_btnClose.m_tip.Activate(TRUE); + + RECT rect = {}; + m_btnClose.GetClientRect(&rect); + m_btnClose.m_tip.AddTool(m_btnClose.m_hWnd, LPSTR_TEXTCALLBACK, &rect, T::_nCloseBtnID); + } + } + } + + void DestroyCloseButton() + { + ATLASSERT(m_btnClose.m_hWnd != NULL); + + if(m_btnClose.m_hWnd != NULL) + { + if(m_btnClose.m_tip.IsWindow()) + { + m_btnClose.m_tip.DestroyWindow(); + m_btnClose.m_tip.m_hWnd = NULL; + } + + m_btnClose.DestroyWindow(); + } + } + + void CalcCloseButtonRect(int nItem, RECT& rcClose) + { + RECT rcItem = {}; + m_tab.GetItemRect(nItem, &rcItem); + + int cy = (rcItem.bottom - rcItem.top - _cyCloseBtn) / 2; + int cx = (nItem == m_tab.GetCurSel()) ? _cxCloseBtnMarginSel : _cxCloseBtnMargin; + ::SetRect(&rcClose, rcItem.right - cx - _cxCloseBtn, rcItem.top + cy, + rcItem.right - cx, rcItem.top + cy + _cyCloseBtn); + } +}; + +class CTabView : public CTabViewImpl +{ +public: + DECLARE_WND_CLASS_EX(_T("WTL_TabView"), 0, COLOR_APPWORKSPACE) +}; + +} // namespace WTL + +#endif // __ATLCTRLX_H__ diff -r e9bb126753e7 -r 20d02a178406 foosdk/wtl/Include/atlddx.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/wtl/Include/atlddx.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,667 @@ +// Windows Template Library - WTL version 10.0 +// Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. +// +// This file is a part of the Windows Template Library. +// The use and distribution terms for this software are covered by the +// Microsoft Public License (http://opensource.org/licenses/MS-PL) +// which can be found in the file MS-PL.txt at the root folder. + +#ifndef __ATLDDX_H__ +#define __ATLDDX_H__ + +#pragma once + +#ifndef __ATLAPP_H__ + #error atlddx.h requires atlapp.h to be included first +#endif + +#include + + +/////////////////////////////////////////////////////////////////////////////// +// Classes in this file: +// +// CWinDataExchange + + +namespace WTL +{ + +// Constants +#define DDX_LOAD FALSE +#define DDX_SAVE TRUE + +// DDX map macros +#define BEGIN_DDX_MAP(thisClass) \ + BOOL DoDataExchange(BOOL bSaveAndValidate = FALSE, UINT nCtlID = (UINT)-1) \ + { \ + (bSaveAndValidate); \ + (nCtlID); + +#define DDX_TEXT(nID, var) \ + if((nCtlID == (UINT)-1) || (nCtlID == nID)) \ + { \ + if(!DDX_Text(nID, var, sizeof(var), bSaveAndValidate)) \ + return FALSE; \ + } + +#define DDX_TEXT_LEN(nID, var, len) \ + if((nCtlID == (UINT)-1) || (nCtlID == nID)) \ + { \ + if(!DDX_Text(nID, var, sizeof(var), bSaveAndValidate, TRUE, len)) \ + return FALSE; \ + } + +#define DDX_INT(nID, var) \ + if((nCtlID == (UINT)-1) || (nCtlID == nID)) \ + { \ + if(!DDX_Int(nID, var, TRUE, bSaveAndValidate)) \ + return FALSE; \ + } + +#define DDX_INT_RANGE(nID, var, min, max) \ + if((nCtlID == (UINT)-1) || (nCtlID == nID)) \ + { \ + if(!DDX_Int(nID, var, TRUE, bSaveAndValidate, TRUE, min, max)) \ + return FALSE; \ + } + +#define DDX_UINT(nID, var) \ + if((nCtlID == (UINT)-1) || (nCtlID == nID)) \ + { \ + if(!DDX_Int(nID, var, FALSE, bSaveAndValidate)) \ + return FALSE; \ + } + +#define DDX_UINT_RANGE(nID, var, min, max) \ + if((nCtlID == (UINT)-1) || (nCtlID == nID)) \ + { \ + if(!DDX_Int(nID, var, FALSE, bSaveAndValidate, TRUE, min, max)) \ + return FALSE; \ + } + +#define DDX_FLOAT(nID, var) \ + if((nCtlID == (UINT)-1) || (nCtlID == nID)) \ + { \ + if(!DDX_Float(nID, var, bSaveAndValidate)) \ + return FALSE; \ + } + +#define DDX_FLOAT_RANGE(nID, var, min, max) \ + if((nCtlID == (UINT)-1) || (nCtlID == nID)) \ + { \ + if(!DDX_Float(nID, var, bSaveAndValidate, TRUE, min, max)) \ + return FALSE; \ + } +#define DDX_FLOAT_P(nID, var, precision) \ + if((nCtlID == (UINT)-1) || (nCtlID == nID)) \ + { \ + if(!DDX_Float(nID, var, bSaveAndValidate, FALSE, 0, 0, precision)) \ + return FALSE; \ + } + +#define DDX_FLOAT_P_RANGE(nID, var, min, max, precision) \ + if((nCtlID == (UINT)-1) || (nCtlID == nID)) \ + { \ + if(!DDX_Float(nID, var, bSaveAndValidate, TRUE, min, max, precision)) \ + return FALSE; \ + } + +#define DDX_CONTROL(nID, obj) \ + if((nCtlID == (UINT)-1) || (nCtlID == nID)) \ + DDX_Control(nID, obj, bSaveAndValidate); + +#define DDX_CONTROL_HANDLE(nID, obj) \ + if((nCtlID == (UINT)-1) || (nCtlID == nID)) \ + DDX_Control_Handle(nID, obj, bSaveAndValidate); + +#define DDX_CHECK(nID, var) \ + if((nCtlID == (UINT)-1) || (nCtlID == nID)) \ + DDX_Check(nID, var, bSaveAndValidate); + +#define DDX_RADIO(nID, var) \ + if((nCtlID == (UINT)-1) || (nCtlID == nID)) \ + DDX_Radio(nID, var, bSaveAndValidate); + +#define END_DDX_MAP() \ + return TRUE; \ + } + +// DDX support for Tab, Combo, ListBox and ListView selection index +// Note: Specialized versions require atlctrls.h to be included first + +#define DDX_INDEX(CtrlClass, nID, var) \ + if((nCtlID == (UINT)-1) || (nCtlID == nID)) \ + DDX_Index(nID, var, bSaveAndValidate); + +#ifdef __ATLCTRLS_H__ + #define DDX_TAB_INDEX(nID, var) DDX_INDEX(WTL::CTabCtrl, nID, var) + #define DDX_COMBO_INDEX(nID, var) DDX_INDEX(WTL::CComboBox, nID, var) + #define DDX_LISTBOX_INDEX(nID, var) DDX_INDEX(WTL::CListBox, nID, var) + #define DDX_LISTVIEW_INDEX(nID, var) DDX_INDEX(WTL::CListViewCtrl, nID, var) +#endif // __ATLCTRLS_H__ + + +/////////////////////////////////////////////////////////////////////////////// +// CWinDataExchange - provides support for DDX + +template +class CWinDataExchange +{ +public: +// Data exchange method - override in your derived class + BOOL DoDataExchange(BOOL /*bSaveAndValidate*/ = FALSE, UINT /*nCtlID*/ = (UINT)-1) + { + // this one should never be called, override it in + // your derived class by implementing DDX map + ATLASSERT(FALSE); + return FALSE; + } + +// Helpers for validation error reporting + enum _XDataType + { + ddxDataNull = 0, + ddxDataText = 1, + ddxDataInt = 2, + ddxDataFloat = 3, + ddxDataDouble = 4 + }; + + struct _XTextData + { + int nLength; + int nMaxLength; + }; + + struct _XIntData + { + long nVal; + long nMin; + long nMax; + }; + + struct _XFloatData + { + double nVal; + double nMin; + double nMax; + }; + + struct _XData + { + _XDataType nDataType; + union + { + _XTextData textData; + _XIntData intData; + _XFloatData floatData; + }; + }; + +// Text exchange + BOOL DDX_Text(UINT nID, LPTSTR lpstrText, int cbSize, BOOL bSave, BOOL bValidate = FALSE, int nLength = 0) + { + T* pT = static_cast(this); + BOOL bSuccess = TRUE; + + if(bSave) + { + HWND hWndCtrl = pT->GetDlgItem(nID); + int nRetLen = ::GetWindowText(hWndCtrl, lpstrText, cbSize / sizeof(TCHAR)); + if(nRetLen < ::GetWindowTextLength(hWndCtrl)) + bSuccess = FALSE; + } + else + { + ATLASSERT(!bValidate || (lstrlen(lpstrText) <= nLength)); + bSuccess = pT->SetDlgItemText(nID, lpstrText); + } + + if(!bSuccess) + { + pT->OnDataExchangeError(nID, bSave); + } + else if(bSave && bValidate) // validation + { + ATLASSERT(nLength > 0); + if(lstrlen(lpstrText) > nLength) + { + _XData data = { ddxDataText }; + data.textData.nLength = lstrlen(lpstrText); + data.textData.nMaxLength = nLength; + pT->OnDataValidateError(nID, bSave, data); + bSuccess = FALSE; + } + } + return bSuccess; + } + + BOOL DDX_Text(UINT nID, BSTR& bstrText, int /*cbSize*/, BOOL bSave, BOOL bValidate = FALSE, int nLength = 0) + { + T* pT = static_cast(this); + BOOL bSuccess = TRUE; + + if(bSave) + { + bSuccess = pT->GetDlgItemText(nID, bstrText); + } + else + { + USES_CONVERSION; + LPTSTR lpstrText = OLE2T(bstrText); + ATLASSERT(!bValidate || (lstrlen(lpstrText) <= nLength)); + bSuccess = pT->SetDlgItemText(nID, lpstrText); + } + + if(!bSuccess) + { + pT->OnDataExchangeError(nID, bSave); + } + else if(bSave && bValidate) // validation + { + ATLASSERT(nLength > 0); + if((int)::SysStringLen(bstrText) > nLength) + { + _XData data = { ddxDataText }; + data.textData.nLength = (int)::SysStringLen(bstrText); + data.textData.nMaxLength = nLength; + pT->OnDataValidateError(nID, bSave, data); + bSuccess = FALSE; + } + } + return bSuccess; + } + + BOOL DDX_Text(UINT nID, ATL::CComBSTR& bstrText, int /*cbSize*/, BOOL bSave, BOOL bValidate = FALSE, int nLength = 0) + { + T* pT = static_cast(this); + BOOL bSuccess = TRUE; + + if(bSave) + { + bSuccess = pT->GetDlgItemText(nID, (BSTR&)bstrText); + } + else + { + USES_CONVERSION; + LPTSTR lpstrText = OLE2T(bstrText); + ATLASSERT(!bValidate || (lstrlen(lpstrText) <= nLength)); + bSuccess = pT->SetDlgItemText(nID, lpstrText); + } + + if(!bSuccess) + { + pT->OnDataExchangeError(nID, bSave); + } + else if(bSave && bValidate) // validation + { + ATLASSERT(nLength > 0); + if((int)bstrText.Length() > nLength) + { + _XData data = { ddxDataText }; + data.textData.nLength = (int)bstrText.Length(); + data.textData.nMaxLength = nLength; + pT->OnDataValidateError(nID, bSave, data); + bSuccess = FALSE; + } + } + return bSuccess; + } + +#ifdef __ATLSTR_H__ + BOOL DDX_Text(UINT nID, ATL::CString& strText, int /*cbSize*/, BOOL bSave, BOOL bValidate = FALSE, int nLength = 0) + { + T* pT = static_cast(this); + BOOL bSuccess = TRUE; + + if(bSave) + { + HWND hWndCtrl = pT->GetDlgItem(nID); + int nLen = ::GetWindowTextLength(hWndCtrl); + int nRetLen = -1; + LPTSTR lpstr = strText.GetBufferSetLength(nLen); + if(lpstr != NULL) + { + nRetLen = ::GetWindowText(hWndCtrl, lpstr, nLen + 1); + strText.ReleaseBuffer(); + } + if(nRetLen < nLen) + bSuccess = FALSE; + } + else + { + bSuccess = pT->SetDlgItemText(nID, strText); + } + + if(!bSuccess) + { + pT->OnDataExchangeError(nID, bSave); + } + else if(bSave && bValidate) // validation + { + ATLASSERT(nLength > 0); + if(strText.GetLength() > nLength) + { + _XData data = { ddxDataText }; + data.textData.nLength = strText.GetLength(); + data.textData.nMaxLength = nLength; + pT->OnDataValidateError(nID, bSave, data); + bSuccess = FALSE; + } + } + return bSuccess; + } +#endif // __ATLSTR_H__ + +// Numeric exchange + template + BOOL DDX_Int(UINT nID, Type& nVal, BOOL bSigned, BOOL bSave, BOOL bValidate = FALSE, Type nMin = 0, Type nMax = 0) + { + T* pT = static_cast(this); + BOOL bSuccess = TRUE; + + if(bSave) + { + nVal = (Type)pT->GetDlgItemInt(nID, &bSuccess, bSigned); + } + else + { + ATLASSERT(!bValidate || ((nVal >= nMin) && (nVal <= nMax))); + bSuccess = pT->SetDlgItemInt(nID, nVal, bSigned); + } + + if(!bSuccess) + { + pT->OnDataExchangeError(nID, bSave); + } + else if(bSave && bValidate) // validation + { + ATLASSERT(nMin != nMax); + if((nVal < nMin) || (nVal > nMax)) + { + _XData data = { ddxDataInt }; + data.intData.nVal = (long)nVal; + data.intData.nMin = (long)nMin; + data.intData.nMax = (long)nMax; + pT->OnDataValidateError(nID, bSave, data); + bSuccess = FALSE; + } + } + return bSuccess; + } + +// Float exchange + static BOOL _AtlSimpleFloatParse(LPCTSTR lpszText, double& d) + { + ATLASSERT(lpszText != NULL); + while ((*lpszText == _T(' ')) || (*lpszText == _T('\t'))) + lpszText++; + + TCHAR chFirst = lpszText[0]; + d = _tcstod(lpszText, (LPTSTR*)&lpszText); + if ((d == 0.0) && (chFirst != _T('0'))) + return FALSE; // could not convert + while ((*lpszText == _T(' ')) || (*lpszText == _T('\t'))) + lpszText++; + + if (*lpszText != _T('\0')) + return FALSE; // not terminated properly + + return TRUE; + } + + BOOL DDX_Float(UINT nID, float& nVal, BOOL bSave, BOOL bValidate = FALSE, float nMin = 0.F, float nMax = 0.F, int nPrecision = FLT_DIG) + { + T* pT = static_cast(this); + BOOL bSuccess = TRUE; + const int cchBuff = 32; + TCHAR szBuff[cchBuff] = {}; + + if(bSave) + { + pT->GetDlgItemText(nID, szBuff, cchBuff); + double d = 0; + if(_AtlSimpleFloatParse(szBuff, d)) + nVal = (float)d; + else + bSuccess = FALSE; + } + else + { + ATLASSERT(!bValidate || ((nVal >= nMin) && (nVal <= nMax))); + _stprintf_s(szBuff, cchBuff, _T("%.*g"), nPrecision, nVal); + bSuccess = pT->SetDlgItemText(nID, szBuff); + } + + if(!bSuccess) + { + pT->OnDataExchangeError(nID, bSave); + } + else if(bSave && bValidate) // validation + { + ATLASSERT(nMin != nMax); + if((nVal < nMin) || (nVal > nMax)) + { + _XData data = { ddxDataFloat }; + data.floatData.nVal = (double)nVal; + data.floatData.nMin = (double)nMin; + data.floatData.nMax = (double)nMax; + pT->OnDataValidateError(nID, bSave, data); + bSuccess = FALSE; + } + } + return bSuccess; + } + + BOOL DDX_Float(UINT nID, double& nVal, BOOL bSave, BOOL bValidate = FALSE, double nMin = 0., double nMax = 0., int nPrecision = DBL_DIG) + { + T* pT = static_cast(this); + BOOL bSuccess = TRUE; + const int cchBuff = 32; + TCHAR szBuff[cchBuff] = {}; + + if(bSave) + { + pT->GetDlgItemText(nID, szBuff, cchBuff); + double d = 0; + if(_AtlSimpleFloatParse(szBuff, d)) + nVal = d; + else + bSuccess = FALSE; + } + else + { + ATLASSERT(!bValidate || ((nVal >= nMin) && (nVal <= nMax))); + _stprintf_s(szBuff, cchBuff, _T("%.*g"), nPrecision, nVal); + bSuccess = pT->SetDlgItemText(nID, szBuff); + } + + if(!bSuccess) + { + pT->OnDataExchangeError(nID, bSave); + } + else if(bSave && bValidate) // validation + { + ATLASSERT(nMin != nMax); + if((nVal < nMin) || (nVal > nMax)) + { + _XData data = { ddxDataFloat }; + data.floatData.nVal = nVal; + data.floatData.nMin = nMin; + data.floatData.nMax = nMax; + pT->OnDataValidateError(nID, bSave, data); + bSuccess = FALSE; + } + } + return bSuccess; + } + +// Full control subclassing (for CWindowImpl derived controls) + template + void DDX_Control(UINT nID, TControl& ctrl, BOOL bSave) + { + if(!bSave && (ctrl.m_hWnd == NULL)) + { + T* pT = static_cast(this); + ctrl.SubclassWindow(pT->GetDlgItem(nID)); + } + } + +// Simple control attaching (for HWND wrapper controls) + template + void DDX_Control_Handle(UINT nID, TControl& ctrl, BOOL bSave) + { + if(!bSave && (ctrl.m_hWnd == NULL)) + { + T* pT = static_cast(this); + ctrl = pT->GetDlgItem(nID); + } + } + +// Control state + void DDX_Check(UINT nID, int& nValue, BOOL bSave) + { + T* pT = static_cast(this); + HWND hWndCtrl = pT->GetDlgItem(nID); + if(bSave) + { + nValue = (int)::SendMessage(hWndCtrl, BM_GETCHECK, 0, 0L); + ATLASSERT((nValue >= 0) && (nValue <= 2)); + } + else + { + if((nValue < 0) || (nValue > 2)) + { + ATLTRACE2(atlTraceUI, 0, _T("ATL: Warning - dialog data checkbox value (%d) out of range.\n"), nValue); + nValue = 0; // default to off + } + ::SendMessage(hWndCtrl, BM_SETCHECK, nValue, 0L); + } + } + + // variant that supports bool (checked/not-checked, no intermediate state) + void DDX_Check(UINT nID, bool& bCheck, BOOL bSave) + { + int nValue = bCheck ? 1 : 0; + DDX_Check(nID, nValue, bSave); + + if(bSave) + { + if(nValue == 2) + ATLTRACE2(atlTraceUI, 0, _T("ATL: Warning - checkbox state (%d) out of supported range.\n"), nValue); + bCheck = (nValue == 1); + } + } + + void DDX_Radio(UINT nID, int& nValue, BOOL bSave) + { + T* pT = static_cast(this); + HWND hWndCtrl = pT->GetDlgItem(nID); + ATLASSERT(hWndCtrl != NULL); + + // must be first in a group of auto radio buttons + ATLASSERT(::GetWindowLong(hWndCtrl, GWL_STYLE) & WS_GROUP); + ATLASSERT(::SendMessage(hWndCtrl, WM_GETDLGCODE, 0, 0L) & DLGC_RADIOBUTTON); + + if(bSave) + nValue = -1; // value if none found + + // walk all children in group + int nButton = 0; + do + { + if(::SendMessage(hWndCtrl, WM_GETDLGCODE, 0, 0L) & DLGC_RADIOBUTTON) + { + // control in group is a radio button + if(bSave) + { + if(::SendMessage(hWndCtrl, BM_GETCHECK, 0, 0L) != 0) + { + ATLASSERT(nValue == -1); // only set once + nValue = nButton; + } + } + else + { + // select button + ::SendMessage(hWndCtrl, BM_SETCHECK, (nButton == nValue), 0L); + } + nButton++; + } + else + { + ATLTRACE2(atlTraceUI, 0, _T("ATL: Warning - skipping non-radio button in group.\n")); + } + hWndCtrl = ::GetWindow(hWndCtrl, GW_HWNDNEXT); + } + while ((hWndCtrl != NULL) && !(GetWindowLong(hWndCtrl, GWL_STYLE) & WS_GROUP)); + } + +// DDX support for Tab, Combo, ListBox and ListView selection index + template + INT _getSel(TCtrl& tCtrl) + { + return tCtrl.GetCurSel(); + } + + template + void _setSel(TCtrl& tCtrl, INT iSel) + { + if(iSel < 0) + tCtrl.SetCurSel(-1); + else + tCtrl.SetCurSel(iSel); + } + +#ifdef __ATLCTRLS_H__ + // ListViewCtrl specialization + template <> + INT _getSel(WTL::CListViewCtrl& tCtrl) + { + return tCtrl.GetSelectedIndex(); + } + + template <> + void _setSel(WTL::CListViewCtrl& tCtrl, INT iSel) + { + if(iSel < 0) + tCtrl.SelectItem(-1); + else + tCtrl.SelectItem(iSel); + } +#endif // __ATLCTRLS_H__ + + template + void DDX_Index(UINT nID, INT& nVal, BOOL bSave) + { + T* pT = static_cast(this); + TCtrl ctrl(pT->GetDlgItem(nID)); + + if(bSave) + nVal = _getSel(ctrl); + else + _setSel(ctrl, nVal); + } + +// Overrideables + void OnDataExchangeError(UINT nCtrlID, BOOL /*bSave*/) + { + // Override to display an error message + ::MessageBeep((UINT)-1); + T* pT = static_cast(this); + ::SetFocus(pT->GetDlgItem(nCtrlID)); + } + + void OnDataValidateError(UINT nCtrlID, BOOL /*bSave*/, _XData& /*data*/) + { + // Override to display an error message + ::MessageBeep((UINT)-1); + T* pT = static_cast(this); + ::SetFocus(pT->GetDlgItem(nCtrlID)); + } +}; + +} // namespace WTL + +#endif // __ATLDDX_H__ diff -r e9bb126753e7 -r 20d02a178406 foosdk/wtl/Include/atldlgs.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/wtl/Include/atldlgs.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,6231 @@ +// Windows Template Library - WTL version 10.0 +// Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. +// +// This file is a part of the Windows Template Library. +// The use and distribution terms for this software are covered by the +// Microsoft Public License (http://opensource.org/licenses/MS-PL) +// which can be found in the file MS-PL.txt at the root folder. + +#ifndef __ATLDLGS_H__ +#define __ATLDLGS_H__ + +#pragma once + +#ifndef __ATLAPP_H__ + #error atldlgs.h requires atlapp.h to be included first +#endif + +#ifndef __ATLWIN_H__ + #error atldlgs.h requires atlwin.h to be included first +#endif + +#include + +#if (_WIN32_WINNT >= 0x0600) + #include +#endif // (_WIN32_WINNT >= 0x0600) + + +/////////////////////////////////////////////////////////////////////////////// +// Classes in this file: +// +// CFileDialogImpl +// CFileDialog +// CSimpleFileDialog +// CMultiFileDialogImpl +// CMultiFileDialog +// CShellFileDialogImpl +// CShellFileOpenDialogImpl +// CShellFileOpenDialog +// CShellFileSaveDialogImpl +// CShellFileSaveDialog +// CFolderDialogImpl +// CFolderDialog +// CFontDialogImpl +// CFontDialog +// CRichEditFontDialogImpl +// CRichEditFontDialog +// CColorDialogImpl +// CColorDialog +// CPrintDialogImpl +// CPrintDialog +// CPrintDialogExImpl +// CPrintDialogEx +// CPageSetupDialogImpl +// CPageSetupDialog +// CFindReplaceDialogImpl +// CFindReplaceDialog +// +// CDialogBaseUnits +// CMemDlgTemplate +// CIndirectDialogImpl +// +// CPropertySheetWindow +// CPropertySheetImpl +// CPropertySheet +// CPropertyPageWindow +// CPropertyPageImpl +// CPropertyPage +// CAxPropertyPageImpl +// CAxPropertyPage +// +// CWizard97SheetWindow +// CWizard97SheetImpl +// CWizard97Sheet +// CWizard97PageWindow +// CWizard97PageImpl +// CWizard97ExteriorPageImpl +// CWizard97InteriorPageImpl +// +// CAeroWizardFrameWindow +// CAeroWizardFrameImpl +// CAeroWizardFrame +// CAeroWizardPageWindow +// CAeroWizardPageImpl +// CAeroWizardPage +// CAeroWizardAxPageImpl +// CAeroWizardAxPage +// +// CTaskDialogConfig +// CTaskDialogImpl +// CTaskDialog +// +// Global functions: +// AtlTaskDialog() + + +namespace WTL +{ + +/////////////////////////////////////////////////////////////////////////////// +// CFileDialogImpl - used for File Open or File Save As + +template +class ATL_NO_VTABLE CFileDialogImpl : public ATL::CDialogImplBase +{ +public: + OPENFILENAME m_ofn; + BOOL m_bOpenFileDialog; // TRUE for file open, FALSE for file save + TCHAR m_szFileTitle[_MAX_FNAME]; // contains file title after return + TCHAR m_szFileName[_MAX_PATH]; // contains full path name after return + + CFileDialogImpl(BOOL bOpenFileDialog, // TRUE for FileOpen, FALSE for FileSaveAs + LPCTSTR lpszDefExt = NULL, + LPCTSTR lpszFileName = NULL, + DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, + LPCTSTR lpszFilter = NULL, + HWND hWndParent = NULL) : m_bOpenFileDialog(bOpenFileDialog) + { + memset(&m_ofn, 0, sizeof(m_ofn)); // initialize structure to 0/NULL + m_ofn.lStructSize = sizeof(m_ofn); + m_ofn.lpstrFile = m_szFileName; + m_ofn.nMaxFile = _MAX_PATH; + m_ofn.lpstrDefExt = lpszDefExt; + m_ofn.lpstrFileTitle = (LPTSTR)m_szFileTitle; + m_ofn.nMaxFileTitle = _MAX_FNAME; + m_ofn.Flags = dwFlags | OFN_EXPLORER | OFN_ENABLEHOOK | OFN_ENABLESIZING; + m_ofn.lpstrFilter = lpszFilter; + m_ofn.hInstance = ModuleHelper::GetResourceInstance(); + m_ofn.lpfnHook = (LPOFNHOOKPROC)T::StartDialogProc; + m_ofn.hwndOwner = hWndParent; + + m_szFileName[0] = _T('\0'); + m_szFileTitle[0] = _T('\0'); + + // setup initial file name + if(lpszFileName != NULL) + ATL::Checked::tcsncpy_s(m_szFileName, _countof(m_szFileName), lpszFileName, _TRUNCATE); + } + + INT_PTR DoModal(HWND hWndParent = ::GetActiveWindow()) + { + ATLASSERT((m_ofn.Flags & OFN_ENABLEHOOK) != 0); + ATLASSERT(m_ofn.lpfnHook != NULL); // can still be a user hook + + ATLASSERT((m_ofn.Flags & OFN_EXPLORER) != 0); + + if(m_ofn.hwndOwner == NULL) // set only if not specified before + m_ofn.hwndOwner = hWndParent; + + ATLASSERT(m_hWnd == NULL); + + // Allocate the thunk structure here, where we can fail gracefully. + BOOL bRetTh = m_thunk.Init(NULL, NULL); + if(bRetTh == FALSE) + { + ::SetLastError(ERROR_OUTOFMEMORY); + return -1; + } + + ModuleHelper::AddCreateWndData(&m_thunk.cd, (ATL::CDialogImplBase*)this); + + BOOL bRet = (m_bOpenFileDialog != FALSE) ? ::GetOpenFileName(&m_ofn) : ::GetSaveFileName(&m_ofn); + + m_hWnd = NULL; + + return (bRet != FALSE) ? IDOK : IDCANCEL; + } + +// Attributes + ATL::CWindow GetFileDialogWindow() const + { + ATLASSERT(::IsWindow(m_hWnd)); + return ATL::CWindow(GetParent()); + } + + int GetFilePath(LPTSTR lpstrFilePath, int nLength) const + { + ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT((m_ofn.Flags & OFN_EXPLORER) != 0); + + return (int)GetFileDialogWindow().SendMessage(CDM_GETFILEPATH, nLength, (LPARAM)lpstrFilePath); + } + + int GetFolderIDList(LPVOID lpBuff, int nLength) const + { + ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT((m_ofn.Flags & OFN_EXPLORER) != 0); + + return (int)GetFileDialogWindow().SendMessage(CDM_GETFOLDERIDLIST, nLength, (LPARAM)lpBuff); + } + + int GetFolderPath(LPTSTR lpstrFolderPath, int nLength) const + { + ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT((m_ofn.Flags & OFN_EXPLORER) != 0); + + return (int)GetFileDialogWindow().SendMessage(CDM_GETFOLDERPATH, nLength, (LPARAM)lpstrFolderPath); + } + + int GetSpec(LPTSTR lpstrSpec, int nLength) const + { + ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT((m_ofn.Flags & OFN_EXPLORER) != 0); + + return (int)GetFileDialogWindow().SendMessage(CDM_GETSPEC, nLength, (LPARAM)lpstrSpec); + } + + void SetControlText(int nCtrlID, LPCTSTR lpstrText) + { + ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT((m_ofn.Flags & OFN_EXPLORER) != 0); + + GetFileDialogWindow().SendMessage(CDM_SETCONTROLTEXT, nCtrlID, (LPARAM)lpstrText); + } + + void SetDefExt(LPCTSTR lpstrExt) + { + ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT((m_ofn.Flags & OFN_EXPLORER) != 0); + + GetFileDialogWindow().SendMessage(CDM_SETDEFEXT, 0, (LPARAM)lpstrExt); + } + + BOOL GetReadOnlyPref() const // return TRUE if readonly checked + { + return ((m_ofn.Flags & OFN_READONLY) != 0) ? TRUE : FALSE; + } + +// Operations + void HideControl(int nCtrlID) + { + ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT((m_ofn.Flags & OFN_EXPLORER) != 0); + + GetFileDialogWindow().SendMessage(CDM_HIDECONTROL, nCtrlID); + } + +// Special override for common dialogs + BOOL EndDialog(INT_PTR /*nRetCode*/ = 0) + { + ATLASSERT(::IsWindow(m_hWnd)); + GetFileDialogWindow().SendMessage(WM_COMMAND, MAKEWPARAM(IDCANCEL, 0)); + return TRUE; + } + +// Message map and handlers + BEGIN_MSG_MAP(CFileDialogImpl) + NOTIFY_CODE_HANDLER(CDN_FILEOK, _OnFileOK) + NOTIFY_CODE_HANDLER(CDN_FOLDERCHANGE, _OnFolderChange) + NOTIFY_CODE_HANDLER(CDN_HELP, _OnHelp) + NOTIFY_CODE_HANDLER(CDN_INITDONE, _OnInitDone) + NOTIFY_CODE_HANDLER(CDN_SELCHANGE, _OnSelChange) + NOTIFY_CODE_HANDLER(CDN_SHAREVIOLATION, _OnShareViolation) + NOTIFY_CODE_HANDLER(CDN_TYPECHANGE, _OnTypeChange) + NOTIFY_CODE_HANDLER(CDN_INCLUDEITEM, _OnIncludeItem) + END_MSG_MAP() + + LRESULT _OnFileOK(int /*idCtrl*/, LPNMHDR pnmh, BOOL& /*bHandled*/) + { + ATLASSERT(::IsWindow(m_hWnd)); + T* pT = static_cast(this); + return !pT->OnFileOK((LPOFNOTIFY)pnmh); + } + + LRESULT _OnFolderChange(int /*idCtrl*/, LPNMHDR pnmh, BOOL& /*bHandled*/) + { + ATLASSERT(::IsWindow(m_hWnd)); + T* pT = static_cast(this); + pT->OnFolderChange((LPOFNOTIFY)pnmh); + return 0; + } + + LRESULT _OnHelp(int /*idCtrl*/, LPNMHDR pnmh, BOOL& /*bHandled*/) + { + ATLASSERT(::IsWindow(m_hWnd)); + T* pT = static_cast(this); + pT->OnHelp((LPOFNOTIFY)pnmh); + return 0; + } + + LRESULT _OnInitDone(int /*idCtrl*/, LPNMHDR pnmh, BOOL& /*bHandled*/) + { + ATLASSERT(::IsWindow(m_hWnd)); + T* pT = static_cast(this); + pT->OnInitDone((LPOFNOTIFY)pnmh); + return 0; + } + + LRESULT _OnSelChange(int /*idCtrl*/, LPNMHDR pnmh, BOOL& /*bHandled*/) + { + ATLASSERT(::IsWindow(m_hWnd)); + T* pT = static_cast(this); + pT->OnSelChange((LPOFNOTIFY)pnmh); + return 0; + } + + LRESULT _OnShareViolation(int /*idCtrl*/, LPNMHDR pnmh, BOOL& /*bHandled*/) + { + ATLASSERT(::IsWindow(m_hWnd)); + T* pT = static_cast(this); + return pT->OnShareViolation((LPOFNOTIFY)pnmh); + } + + LRESULT _OnTypeChange(int /*idCtrl*/, LPNMHDR pnmh, BOOL& /*bHandled*/) + { + ATLASSERT(::IsWindow(m_hWnd)); + T* pT = static_cast(this); + pT->OnTypeChange((LPOFNOTIFY)pnmh); + return 0; + } + + LRESULT _OnIncludeItem(int /*idCtrl*/, LPNMHDR pnmh, BOOL& /*bHandled*/) + { + ATLASSERT(::IsWindow(m_hWnd)); + T* pT = static_cast(this); + return pT->OnIncludeItem((LPOFNOTIFYEX)pnmh); + } + +// Overrideables + BOOL OnFileOK(LPOFNOTIFY /*lpon*/) + { + return TRUE; + } + + void OnFolderChange(LPOFNOTIFY /*lpon*/) + { + } + + void OnHelp(LPOFNOTIFY /*lpon*/) + { + } + + void OnInitDone(LPOFNOTIFY /*lpon*/) + { + } + + void OnSelChange(LPOFNOTIFY /*lpon*/) + { + } + + int OnShareViolation(LPOFNOTIFY /*lpon*/) + { + return 0; + } + + void OnTypeChange(LPOFNOTIFY /*lpon*/) + { + } + + BOOL OnIncludeItem(LPOFNOTIFYEX /*lponex*/) + { + return TRUE; // include item + } +}; + +class CFileDialog : public CFileDialogImpl +{ +public: + CFileDialog(BOOL bOpenFileDialog, // TRUE for FileOpen, FALSE for FileSaveAs + LPCTSTR lpszDefExt = NULL, + LPCTSTR lpszFileName = NULL, + DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, + LPCTSTR lpszFilter = NULL, + HWND hWndParent = NULL) + : CFileDialogImpl(bOpenFileDialog, lpszDefExt, lpszFileName, dwFlags, lpszFilter, hWndParent) + { } + + // override base class map and references to handlers + DECLARE_EMPTY_MSG_MAP() +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CSimpleFileDialog - simple class for non-customized Open/SaveAs dialogs + +class CSimpleFileDialog +{ +public: + OPENFILENAME m_ofn; + BOOL m_bOpenFileDialog; // TRUE for file open, FALSE for file save + TCHAR m_szFileTitle[_MAX_FNAME]; // contains file title after return + TCHAR m_szFileName[_MAX_PATH]; // contains full path name after return + + CSimpleFileDialog(BOOL bOpenFileDialog, // TRUE for FileOpen, FALSE for FileSaveAs + LPCTSTR lpszDefExt = NULL, + LPCTSTR lpszFileName = NULL, + DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, + LPCTSTR lpszFilter = NULL, + HWND hWndParent = NULL) : m_bOpenFileDialog(bOpenFileDialog) + { + memset(&m_ofn, 0, sizeof(m_ofn)); // initialize structure to 0/NULL + m_ofn.lStructSize = sizeof(m_ofn); + m_ofn.lpstrFile = m_szFileName; + m_ofn.nMaxFile = _MAX_PATH; + m_ofn.lpstrDefExt = lpszDefExt; + m_ofn.lpstrFileTitle = (LPTSTR)m_szFileTitle; + m_ofn.nMaxFileTitle = _MAX_FNAME; + m_ofn.Flags = dwFlags | OFN_EXPLORER | OFN_ENABLESIZING; + m_ofn.lpstrFilter = lpszFilter; + m_ofn.hInstance = ModuleHelper::GetResourceInstance(); + m_ofn.hwndOwner = hWndParent; + + m_szFileName[0] = _T('\0'); + m_szFileTitle[0] = _T('\0'); + + // setup initial file name + if(lpszFileName != NULL) + ATL::Checked::tcsncpy_s(m_szFileName, _countof(m_szFileName), lpszFileName, _TRUNCATE); + } + + INT_PTR DoModal(HWND hWndParent = ::GetActiveWindow()) + { + ATLASSERT((m_ofn.Flags & OFN_EXPLORER) != 0); + + if(m_ofn.hwndOwner == NULL) // set only if not specified before + m_ofn.hwndOwner = hWndParent; + + BOOL bRet = (m_bOpenFileDialog != FALSE) ? ::GetOpenFileName(&m_ofn) : ::GetSaveFileName(&m_ofn); + + return (bRet != FALSE) ? IDOK : IDCANCEL; + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// Multi File Dialog - Multi-select File Open dialog + +// The class dynamically resizes the buffer as the file selection changes +// (as described in Knowledge Base article 131462). It also expands selected +// shortcut files to take into account the full path of the target file. +// Note that this doesn't work on Win9x for the old style dialogs, as well as +// on NT for non-Unicode builds. + +#ifndef _WTL_FIXED_OFN_BUFFER_LENGTH + #define _WTL_FIXED_OFN_BUFFER_LENGTH 0x10000 +#endif + +template +class ATL_NO_VTABLE CMultiFileDialogImpl : public CFileDialogImpl< T > +{ +public: + mutable LPCTSTR m_pNextFile; +#ifndef _UNICODE + bool m_bIsNT; +#endif + + CMultiFileDialogImpl( + LPCTSTR lpszDefExt = NULL, + LPCTSTR lpszFileName = NULL, + DWORD dwFlags = OFN_HIDEREADONLY, + LPCTSTR lpszFilter = NULL, + HWND hWndParent = NULL) + : CFileDialogImpl(TRUE, lpszDefExt, lpszFileName, dwFlags, lpszFilter, hWndParent), + m_pNextFile(NULL) + { + this->m_ofn.Flags |= OFN_ALLOWMULTISELECT; // Force multiple selection mode + +#ifndef _UNICODE +#ifdef _versionhelpers_H_INCLUDED_ + OSVERSIONINFOEX ovi = { sizeof(OSVERSIONINFOEX) }; + ovi.dwPlatformId = VER_PLATFORM_WIN32_NT; + DWORDLONG const dwlConditionMask = ::VerSetConditionMask(0, VER_PLATFORMID, VER_EQUAL); + m_bIsNT = (::VerifyVersionInfo(&ovi, VER_PLATFORMID, dwlConditionMask) != FALSE); +#else // !_versionhelpers_H_INCLUDED_ + OSVERSIONINFO ovi = { sizeof(OSVERSIONINFO) }; + ::GetVersionEx(&ovi); + m_bIsNT = (ovi.dwPlatformId == VER_PLATFORM_WIN32_NT); +#endif // _versionhelpers_H_INCLUDED_ + if (m_bIsNT) + { + // On NT platforms, GetOpenFileNameA thunks to GetOpenFileNameW and there + // is absolutely nothing we can do except to start off with a large buffer. + ATLVERIFY(ResizeFilenameBuffer(_WTL_FIXED_OFN_BUFFER_LENGTH)); + } +#endif + } + + ~CMultiFileDialogImpl() + { + if (this->m_ofn.lpstrFile != this->m_szFileName) // Free the buffer if we allocated it + delete[] this->m_ofn.lpstrFile; + } + +// Operations + // Get the directory that the files were chosen from. + // The function returns the number of characters copied, not including the terminating zero. + // If the buffer is NULL, the function returns the required size, in characters, including the terminating zero. + // If the function fails, the return value is zero. + int GetDirectory(LPTSTR pBuffer, int nBufLen) const + { + if (this->m_ofn.lpstrFile == NULL) + return 0; + + LPCTSTR pStr = this->m_ofn.lpstrFile; + int nLength = lstrlen(pStr); + if (pStr[nLength + 1] == 0) + { + // The OFN buffer contains a single item so extract its path. + LPCTSTR pSep = _tcsrchr(pStr, _T('\\')); + if (pSep != NULL) + nLength = (int)(DWORD_PTR)(pSep - pStr); + } + + int nRet = 0; + if (pBuffer == NULL) // If the buffer is NULL, return the required length + { + nRet = nLength + 1; + } + else if (nBufLen > nLength) + { + ATL::Checked::tcsncpy_s(pBuffer, nBufLen, pStr, nLength); + nRet = nLength; + } + + return nRet; + } + +#ifdef __ATLSTR_H__ + bool GetDirectory(ATL::CString& strDir) const + { + bool bRet = false; + + int nLength = GetDirectory(NULL, 0); + if (nLength > 0) + { + bRet = (GetDirectory(strDir.GetBuffer(nLength), nLength) > 0); + strDir.ReleaseBuffer(nLength - 1); + } + + return bRet; + } +#endif // __ATLSTR_H__ + + // Get the first filename as a pointer into the buffer. + LPCTSTR GetFirstFileName() const + { + if (this->m_ofn.lpstrFile == NULL) + return NULL; + + m_pNextFile = NULL; // Reset internal buffer pointer + + LPCTSTR pStr = this->m_ofn.lpstrFile; + int nLength = lstrlen(pStr); + if (pStr[nLength + 1] != 0) + { + // Multiple items were selected. The first string is the directory, + // so skip forwards to the second string. + pStr += nLength + 1; + + // Set up m_pNext so it points to the second item (or null). + m_pNextFile = pStr; + GetNextFileName(); + } + else + { + // A single item was selected. Skip forward past the path. + LPCTSTR pSep = _tcsrchr(pStr, _T('\\')); + if (pSep != NULL) + pStr = pSep + 1; + } + + return pStr; + } + + // Get the next filename as a pointer into the buffer. + LPCTSTR GetNextFileName() const + { + if (m_pNextFile == NULL) + return NULL; + + LPCTSTR pStr = m_pNextFile; + // Set "m_pNextFile" to point to the next file name, or null if we + // have reached the last file in the list. + int nLength = lstrlen(pStr); + m_pNextFile = (pStr[nLength + 1] != 0) ? &pStr[nLength + 1] : NULL; + + return pStr; + } + + // Get the first filename as a full path. + // The function returns the number of characters copied, not including the terminating zero. + // If the buffer is NULL, the function returns the required size, in characters, including the terminating zero. + // If the function fails, the return value is zero. + int GetFirstPathName(LPTSTR pBuffer, int nBufLen) const + { + LPCTSTR pStr = GetFirstFileName(); + int nLengthDir = GetDirectory(NULL, 0); + if((pStr == NULL) || (nLengthDir == 0)) + return 0; + + // Figure out the required length. + int nLengthTotal = nLengthDir + lstrlen(pStr); + + int nRet = 0; + if(pBuffer == NULL) // If the buffer is NULL, return the required length + { + nRet = nLengthTotal + 1; + } + else if (nBufLen > nLengthTotal) // If the buffer is big enough, go ahead and construct the path + { + GetDirectory(pBuffer, nBufLen); + ATL::Checked::tcscat_s(pBuffer, nBufLen, _T("\\")); + ATL::Checked::tcscat_s(pBuffer, nBufLen, pStr); + nRet = nLengthTotal; + } + + return nRet; + } + +#ifdef __ATLSTR_H__ + bool GetFirstPathName(ATL::CString& strPath) const + { + bool bRet = false; + + int nLength = GetFirstPathName(NULL, 0); + if (nLength > 0) + { + bRet = (GetFirstPathName(strPath.GetBuffer(nLength), nLength) > 0); + strPath.ReleaseBuffer(nLength - 1); + } + + return bRet; + } +#endif // __ATLSTR_H__ + + // Get the next filename as a full path. + // The function returns the number of characters copied, not including the terminating zero. + // If the buffer is NULL, the function returns the required size, in characters, including the terminating zero. + // If the function fails, the return value is zero. + // The internal position marker is moved forward only if the function succeeds and the buffer was large enough. + int GetNextPathName(LPTSTR pBuffer, int nBufLen) const + { + if (m_pNextFile == NULL) + return 0; + + int nRet = 0; + LPCTSTR pStr = m_pNextFile; + // Does the filename contain a backslash? + if (_tcsrchr(pStr, _T('\\')) != NULL) + { + // Yes, so we'll assume it's a full path. + int nLength = lstrlen(pStr); + + if (pBuffer == NULL) // If the buffer is NULL, return the required length + { + nRet = nLength + 1; + } + else if (nBufLen > nLength) // The buffer is big enough, so go ahead and copy the filename + { + ATL::Checked::tcscpy_s(pBuffer, nBufLen, GetNextFileName()); + nRet = nBufLen; + } + } + else + { + // The filename is relative, so construct the full path. + int nLengthDir = GetDirectory(NULL, 0); + if (nLengthDir > 0) + { + // Calculate the required space. + int nLengthTotal = nLengthDir + lstrlen(pStr); + + if(pBuffer == NULL) // If the buffer is NULL, return the required length + { + nRet = nLengthTotal + 1; + } + else if (nBufLen > nLengthTotal) // If the buffer is big enough, go ahead and construct the path + { + GetDirectory(pBuffer, nBufLen); + ATL::Checked::tcscat_s(pBuffer, nBufLen, _T("\\")); + ATL::Checked::tcscat_s(pBuffer, nBufLen, GetNextFileName()); + nRet = nLengthTotal; + } + } + } + + return nRet; + } + +#ifdef __ATLSTR_H__ + bool GetNextPathName(ATL::CString& strPath) const + { + bool bRet = false; + + int nLength = GetNextPathName(NULL, 0); + if (nLength > 0) + { + bRet = (GetNextPathName(strPath.GetBuffer(nLength), nLength) > 0); + strPath.ReleaseBuffer(nLength - 1); + } + + return bRet; + } +#endif // __ATLSTR_H__ + +// Implementation + bool ResizeFilenameBuffer(DWORD dwLength) + { + if (dwLength > this->m_ofn.nMaxFile) + { + // Free the old buffer. + if (this->m_ofn.lpstrFile != this->m_szFileName) + { + delete[] this->m_ofn.lpstrFile; + this->m_ofn.lpstrFile = NULL; + this->m_ofn.nMaxFile = 0; + } + + // Allocate the new buffer. + LPTSTR lpstrBuff = NULL; + ATLTRY(lpstrBuff = new TCHAR[dwLength]); + if (lpstrBuff != NULL) + { + this->m_ofn.lpstrFile = lpstrBuff; + this->m_ofn.lpstrFile[0] = 0; + this->m_ofn.nMaxFile = dwLength; + } + } + + return (this->m_ofn.lpstrFile != NULL); + } + + void OnSelChange(LPOFNOTIFY /*lpon*/) + { +#ifndef _UNICODE + // There is no point resizing the buffer in ANSI builds running on NT. + if (m_bIsNT) + return; +#endif + + // Get the buffer length required to hold the spec. + int nLength = this->GetSpec(NULL, 0); + if (nLength <= 1) + return; // no files are selected, presumably + + // Add room for the directory, and an extra terminating zero. + nLength += this->GetFolderPath(NULL, 0) + 1; + + if (!ResizeFilenameBuffer(nLength)) + { + ATLASSERT(FALSE); + return; + } + + // If we are not following links then our work is done. + if ((this->m_ofn.Flags & OFN_NODEREFERENCELINKS) != 0) + return; + + // Get the file spec, which is the text in the edit control. + if (this->GetSpec(this->m_ofn.lpstrFile, this->m_ofn.nMaxFile) <= 0) + return; + + // Get the ID-list of the current folder. + int nBytes = this->GetFolderIDList(NULL, 0); +#ifdef STRICT_TYPED_ITEMIDS + ATL::CTempBuffer idlist; +#else + ATL::CTempBuffer idlist; +#endif + idlist.AllocateBytes(nBytes); + if ((nBytes <= 0) || (this->GetFolderIDList(idlist, nBytes) <= 0)) + return; + + // First bind to the desktop folder, then to the current folder. + ATL::CComPtr pDesktop, pFolder; + if (FAILED(::SHGetDesktopFolder(&pDesktop))) + return; + if (FAILED(pDesktop->BindToObject(idlist, NULL, IID_IShellFolder, (void**)&pFolder))) + return; + + // Work through the file spec, looking for quoted filenames. If we find a shortcut file, then + // we need to add enough extra buffer space to hold its target path. + DWORD nExtraChars = 0; + bool bInsideQuotes = false; + LPCTSTR pAnchor = this->m_ofn.lpstrFile; + LPCTSTR pChar = this->m_ofn.lpstrFile; + for ( ; *pChar; ++pChar) + { + // Look for quotation marks. + if (*pChar == _T('\"')) + { + // We are either entering or leaving a passage of quoted text. + bInsideQuotes = !bInsideQuotes; + + // Is it an opening or closing quote? + if (bInsideQuotes) + { + // We found an opening quote, so set "pAnchor" to the following character. + pAnchor = pChar + 1; + } + else // closing quote + { + // Each quoted entity should be shorter than MAX_PATH. + if (pChar - pAnchor >= MAX_PATH) + return; + + // Get the ID-list and attributes of the file. + USES_CONVERSION; + int nFileNameLength = (int)(DWORD_PTR)(pChar - pAnchor); + TCHAR szFileName[MAX_PATH] = {}; + ATL::Checked::tcsncpy_s(szFileName, MAX_PATH, pAnchor, nFileNameLength); +#ifdef STRICT_TYPED_ITEMIDS + PIDLIST_RELATIVE pidl = NULL; +#else + LPITEMIDLIST pidl = NULL; +#endif + DWORD dwAttrib = SFGAO_LINK; + if (SUCCEEDED(pFolder->ParseDisplayName(NULL, NULL, T2W(szFileName), NULL, &pidl, &dwAttrib))) + { + // Is it a shortcut file? + if (dwAttrib & SFGAO_LINK) + { + // Bind to its IShellLink interface. + ATL::CComPtr pLink; + if (SUCCEEDED(pFolder->BindToObject(pidl, NULL, IID_IShellLink, (void**)&pLink))) + { + // Get the shortcut's target path. + TCHAR szPath[MAX_PATH] = {}; + if (SUCCEEDED(pLink->GetPath(szPath, MAX_PATH, NULL, 0))) + { + // If the target path is longer than the shortcut name, then add on the number + // of extra characters that are required. + int nNewLength = lstrlen(szPath); + if (nNewLength > nFileNameLength) + nExtraChars += nNewLength - nFileNameLength; + } + } + } + + // Free the ID-list returned by ParseDisplayName. + ::CoTaskMemFree(pidl); + } + } + } + } + + // If we need more space for shortcut targets, then reallocate. + if (nExtraChars > 0) + ATLVERIFY(ResizeFilenameBuffer(this->m_ofn.nMaxFile + nExtraChars)); + } +}; + +class CMultiFileDialog : public CMultiFileDialogImpl +{ +public: + CMultiFileDialog( + LPCTSTR lpszDefExt = NULL, + LPCTSTR lpszFileName = NULL, + DWORD dwFlags = OFN_HIDEREADONLY, + LPCTSTR lpszFilter = NULL, + HWND hWndParent = NULL) + : CMultiFileDialogImpl(lpszDefExt, lpszFileName, dwFlags, lpszFilter, hWndParent) + { } + + BEGIN_MSG_MAP(CMultiFileDialog) + CHAIN_MSG_MAP(CMultiFileDialogImpl) + END_MSG_MAP() +}; + + +/////////////////////////////////////////////////////////////////////////////// +// Shell File Dialog - new Shell File Open and Save dialogs in Vista + +// Note: Use GetPtr() to access dialog interface methods. +// Example: +// CShellFileOpenDialog dlg; +// dlg.GetPtr()->SetTitle(L"MyFileOpenDialog"); + +#if (_WIN32_WINNT >= 0x0600) + +/////////////////////////////////////////////////////////////////////////////// +// CShellFileDialogImpl - base class for CShellFileOpenDialogImpl and CShellFileSaveDialogImpl + +template +class ATL_NO_VTABLE CShellFileDialogImpl : public IFileDialogEvents +{ +public: +// Operations + INT_PTR DoModal(HWND hWndParent = ::GetActiveWindow()) + { + INT_PTR nRet = -1; + + T* pT = static_cast(this); + if(pT->m_spFileDlg == NULL) + { + ATLASSERT(FALSE); + return nRet; + } + + DWORD dwCookie = 0; + pT->_Advise(dwCookie); + + HRESULT hRet = pT->m_spFileDlg->Show(hWndParent); + if(SUCCEEDED(hRet)) + nRet = IDOK; + else if(hRet == HRESULT_FROM_WIN32(ERROR_CANCELLED)) + nRet = IDCANCEL; + else + ATLASSERT(FALSE); // error + + pT->_Unadvise(dwCookie); + + return nRet; + } + + bool IsNull() const + { + const T* pT = static_cast(this); + return (pT->m_spFileDlg == NULL); + } + +// Operations - get file path after dialog returns + HRESULT GetFilePath(LPWSTR lpstrFilePath, int cchLength) + { + T* pT = static_cast(this); + ATLASSERT(pT->m_spFileDlg != NULL); + + ATL::CComPtr spItem; + HRESULT hRet = pT->m_spFileDlg->GetResult(&spItem); + + if(SUCCEEDED(hRet)) + hRet = GetFileNameFromShellItem(spItem, SIGDN_FILESYSPATH, lpstrFilePath, cchLength); + + return hRet; + } + + HRESULT GetFileTitle(LPWSTR lpstrFileTitle, int cchLength) + { + T* pT = static_cast(this); + ATLASSERT(pT->m_spFileDlg != NULL); + + ATL::CComPtr spItem; + HRESULT hRet = pT->m_spFileDlg->GetResult(&spItem); + + if(SUCCEEDED(hRet)) + hRet = GetFileNameFromShellItem(spItem, SIGDN_NORMALDISPLAY, lpstrFileTitle, cchLength); + + return hRet; + } + +#ifdef __ATLSTR_H__ + HRESULT GetFilePath(ATL::CString& strFilePath) + { + T* pT = static_cast(this); + ATLASSERT(pT->m_spFileDlg != NULL); + + ATL::CComPtr spItem; + HRESULT hRet = pT->m_spFileDlg->GetResult(&spItem); + + if(SUCCEEDED(hRet)) + hRet = GetFileNameFromShellItem(spItem, SIGDN_FILESYSPATH, strFilePath); + + return hRet; + } + + HRESULT GetFileTitle(ATL::CString& strFileTitle) + { + T* pT = static_cast(this); + ATLASSERT(pT->m_spFileDlg != NULL); + + ATL::CComPtr spItem; + HRESULT hRet = pT->m_spFileDlg->GetResult(&spItem); + + if(SUCCEEDED(hRet)) + hRet = GetFileNameFromShellItem(spItem, SIGDN_NORMALDISPLAY, strFileTitle); + + return hRet; + } +#endif // __ATLSTR_H__ + +// Helpers for IShellItem + static HRESULT GetFileNameFromShellItem(IShellItem* pShellItem, SIGDN type, LPWSTR lpstr, int cchLength) + { + ATLASSERT(pShellItem != NULL); + + LPWSTR lpstrName = NULL; + HRESULT hRet = pShellItem->GetDisplayName(type, &lpstrName); + + if(SUCCEEDED(hRet)) + { + if(lstrlenW(lpstrName) < cchLength) + { + ATL::Checked::wcscpy_s(lpstr, cchLength, lpstrName); + } + else + { + ATLASSERT(FALSE); + hRet = DISP_E_BUFFERTOOSMALL; + } + + ::CoTaskMemFree(lpstrName); + } + + return hRet; + } + +#ifdef __ATLSTR_H__ + static HRESULT GetFileNameFromShellItem(IShellItem* pShellItem, SIGDN type, ATL::CString& str) + { + ATLASSERT(pShellItem != NULL); + + LPWSTR lpstrName = NULL; + HRESULT hRet = pShellItem->GetDisplayName(type, &lpstrName); + + if(SUCCEEDED(hRet)) + { + str = lpstrName; + ::CoTaskMemFree(lpstrName); + } + + return hRet; + } +#endif // __ATLSTR_H__ + +// Implementation + void _Advise(DWORD& dwCookie) + { + T* pT = static_cast(this); + ATLASSERT(pT->m_spFileDlg != NULL); + HRESULT hRet = pT->m_spFileDlg->Advise((IFileDialogEvents*)this, &dwCookie); + ATLVERIFY(SUCCEEDED(hRet)); + } + + void _Unadvise(DWORD dwCookie) + { + T* pT = static_cast(this); + ATLASSERT(pT->m_spFileDlg != NULL); + HRESULT hRet = pT->m_spFileDlg->Unadvise(dwCookie); + ATLVERIFY(SUCCEEDED(hRet)); + } + + void _Init(LPCWSTR lpszFileName, DWORD dwOptions, LPCWSTR lpszDefExt, const COMDLG_FILTERSPEC* arrFilterSpec, UINT uFilterSpecCount) + { + T* pT = static_cast(this); + ATLASSERT(pT->m_spFileDlg != NULL); + + HRESULT hRet = E_FAIL; + + if(lpszFileName != NULL) + { + hRet = pT->m_spFileDlg->SetFileName(lpszFileName); + ATLASSERT(SUCCEEDED(hRet)); + } + + hRet = pT->m_spFileDlg->SetOptions(dwOptions); + ATLASSERT(SUCCEEDED(hRet)); + + if(lpszDefExt != NULL) + { + hRet = pT->m_spFileDlg->SetDefaultExtension(lpszDefExt); + ATLASSERT(SUCCEEDED(hRet)); + } + + if((arrFilterSpec != NULL) && (uFilterSpecCount != 0U)) + { + hRet = pT->m_spFileDlg->SetFileTypes(uFilterSpecCount, arrFilterSpec); + ATLASSERT(SUCCEEDED(hRet)); + } + } + +// Implementation - IUnknown interface + STDMETHOD(QueryInterface)(REFIID riid, void** ppvObject) + { + if(ppvObject == NULL) + return E_POINTER; + + T* pT = static_cast(this); + if(IsEqualGUID(riid, IID_IUnknown) || IsEqualGUID(riid, IID_IFileDialogEvents)) + { + *ppvObject = (IFileDialogEvents*)pT; + // AddRef() not needed + return S_OK; + } + + return E_NOINTERFACE; + } + + virtual ULONG STDMETHODCALLTYPE AddRef() + { + return 1; + } + + virtual ULONG STDMETHODCALLTYPE Release() + { + return 1; + } + +// Implementation - IFileDialogEvents interface + virtual HRESULT STDMETHODCALLTYPE OnFileOk(IFileDialog* pfd) + { + T* pT = static_cast(this); + ATLASSERT(pT->m_spFileDlg.IsEqualObject(pfd)); + (void)pfd; // avoid level 4 warning + return pT->OnFileOk(); + } + + virtual HRESULT STDMETHODCALLTYPE OnFolderChanging(IFileDialog* pfd, IShellItem* psiFolder) + { + T* pT = static_cast(this); + ATLASSERT(pT->m_spFileDlg.IsEqualObject(pfd)); + (void)pfd; // avoid level 4 warning + return pT->OnFolderChanging(psiFolder); + } + + virtual HRESULT STDMETHODCALLTYPE OnFolderChange(IFileDialog* pfd) + { + T* pT = static_cast(this); + ATLASSERT(pT->m_spFileDlg.IsEqualObject(pfd)); + (void)pfd; // avoid level 4 warning + return pT->OnFolderChange(); + } + + virtual HRESULT STDMETHODCALLTYPE OnSelectionChange(IFileDialog* pfd) + { + T* pT = static_cast(this); + ATLASSERT(pT->m_spFileDlg.IsEqualObject(pfd)); + (void)pfd; // avoid level 4 warning + return pT->OnSelectionChange(); + } + + virtual HRESULT STDMETHODCALLTYPE OnShareViolation(IFileDialog* pfd, IShellItem* psi, FDE_SHAREVIOLATION_RESPONSE* pResponse) + { + T* pT = static_cast(this); + ATLASSERT(pT->m_spFileDlg.IsEqualObject(pfd)); + (void)pfd; // avoid level 4 warning + return pT->OnShareViolation(psi, pResponse); + } + + virtual HRESULT STDMETHODCALLTYPE OnTypeChange(IFileDialog* pfd) + { + T* pT = static_cast(this); + ATLASSERT(pT->m_spFileDlg.IsEqualObject(pfd)); + (void)pfd; // avoid level 4 warning + return pT->OnTypeChange(); + } + + virtual HRESULT STDMETHODCALLTYPE OnOverwrite(IFileDialog* pfd, IShellItem* psi, FDE_OVERWRITE_RESPONSE* pResponse) + { + T* pT = static_cast(this); + ATLASSERT(pT->m_spFileDlg.IsEqualObject(pfd)); + (void)pfd; // avoid level 4 warning + return pT->OnOverwrite(psi, pResponse); + } + +// Overrideables - Event handlers + HRESULT OnFileOk() + { + return E_NOTIMPL; + } + + HRESULT OnFolderChanging(IShellItem* /*psiFolder*/) + { + return E_NOTIMPL; + } + + HRESULT OnFolderChange() + { + return E_NOTIMPL; + } + + HRESULT OnSelectionChange() + { + return E_NOTIMPL; + } + + HRESULT OnShareViolation(IShellItem* /*psi*/, FDE_SHAREVIOLATION_RESPONSE* /*pResponse*/) + { + return E_NOTIMPL; + } + + HRESULT OnTypeChange() + { + return E_NOTIMPL; + } + + HRESULT OnOverwrite(IShellItem* /*psi*/, FDE_OVERWRITE_RESPONSE* /*pResponse*/) + { + return E_NOTIMPL; + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CShellFileOpenDialogImpl - implements new Shell File Open dialog + +template +class ATL_NO_VTABLE CShellFileOpenDialogImpl : public CShellFileDialogImpl< T > +{ +public: + ATL::CComPtr m_spFileDlg; + + CShellFileOpenDialogImpl(LPCWSTR lpszFileName = NULL, + DWORD dwOptions = FOS_FORCEFILESYSTEM | FOS_PATHMUSTEXIST | FOS_FILEMUSTEXIST, + LPCWSTR lpszDefExt = NULL, + const COMDLG_FILTERSPEC* arrFilterSpec = NULL, + UINT uFilterSpecCount = 0U) + { + HRESULT hRet = m_spFileDlg.CoCreateInstance(CLSID_FileOpenDialog); + + if(SUCCEEDED(hRet)) + this->_Init(lpszFileName, dwOptions, lpszDefExt, arrFilterSpec, uFilterSpecCount); + } + + virtual ~CShellFileOpenDialogImpl() + { } + + IFileOpenDialog* GetPtr() + { + return m_spFileDlg; + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CShellFileOpenDialog - new Shell File Open dialog without events + +class CShellFileOpenDialog : public CShellFileOpenDialogImpl +{ +public: + CShellFileOpenDialog(LPCWSTR lpszFileName = NULL, + DWORD dwOptions = FOS_FORCEFILESYSTEM | FOS_PATHMUSTEXIST | FOS_FILEMUSTEXIST, + LPCWSTR lpszDefExt = NULL, + const COMDLG_FILTERSPEC* arrFilterSpec = NULL, + UINT uFilterSpecCount = 0U) : CShellFileOpenDialogImpl(lpszFileName, dwOptions, lpszDefExt, arrFilterSpec, uFilterSpecCount) + { } + + virtual ~CShellFileOpenDialog() + { } + +// Implementation (remove _Advise/_Unadvise code using template magic) + void _Advise(DWORD& /*dwCookie*/) + { } + + void _Unadvise(DWORD /*dwCookie*/) + { } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CShellFileSaveDialogImpl - implements new Shell File Save dialog + +template +class ATL_NO_VTABLE CShellFileSaveDialogImpl : public CShellFileDialogImpl< T > +{ +public: + ATL::CComPtr m_spFileDlg; + + CShellFileSaveDialogImpl(LPCWSTR lpszFileName = NULL, + DWORD dwOptions = FOS_FORCEFILESYSTEM | FOS_PATHMUSTEXIST | FOS_OVERWRITEPROMPT, + LPCWSTR lpszDefExt = NULL, + const COMDLG_FILTERSPEC* arrFilterSpec = NULL, + UINT uFilterSpecCount = 0U) + { + HRESULT hRet = m_spFileDlg.CoCreateInstance(CLSID_FileSaveDialog); + + if(SUCCEEDED(hRet)) + this->_Init(lpszFileName, dwOptions, lpszDefExt, arrFilterSpec, uFilterSpecCount); + } + + virtual ~CShellFileSaveDialogImpl() + { } + + IFileSaveDialog* GetPtr() + { + return m_spFileDlg; + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CShellFileSaveDialog - new Shell File Save dialog without events + +class CShellFileSaveDialog : public CShellFileSaveDialogImpl +{ +public: + CShellFileSaveDialog(LPCWSTR lpszFileName = NULL, + DWORD dwOptions = FOS_FORCEFILESYSTEM | FOS_PATHMUSTEXIST | FOS_OVERWRITEPROMPT, + LPCWSTR lpszDefExt = NULL, + const COMDLG_FILTERSPEC* arrFilterSpec = NULL, + UINT uFilterSpecCount = 0U) : CShellFileSaveDialogImpl(lpszFileName, dwOptions, lpszDefExt, arrFilterSpec, uFilterSpecCount) + { } + + virtual ~CShellFileSaveDialog() + { } + +// Implementation (remove _Advise/_Unadvise code using template magic) + void _Advise(DWORD& /*dwCookie*/) + { } + + void _Unadvise(DWORD /*dwCookie*/) + { } +}; + +#endif // (_WIN32_WINNT >= 0x0600) + + +/////////////////////////////////////////////////////////////////////////////// +// CFolderDialogImpl - used for browsing for a folder + +template +class ATL_NO_VTABLE CFolderDialogImpl +{ +public: + BROWSEINFO m_bi; + LPCTSTR m_lpstrInitialFolder; + LPCITEMIDLIST m_pidlInitialSelection; + bool m_bExpandInitialSelection; + TCHAR m_szFolderDisplayName[MAX_PATH]; + TCHAR m_szFolderPath[MAX_PATH]; +#ifdef STRICT_TYPED_ITEMIDS + PIDLIST_ABSOLUTE m_pidlSelected; +#else + LPITEMIDLIST m_pidlSelected; +#endif + HWND m_hWnd; // used only in the callback function + +// Constructor + CFolderDialogImpl(HWND hWndParent = NULL, LPCTSTR lpstrTitle = NULL, UINT uFlags = BIF_RETURNONLYFSDIRS) : + m_lpstrInitialFolder(NULL), m_pidlInitialSelection(NULL), m_bExpandInitialSelection(false), m_pidlSelected(NULL), m_hWnd(NULL) + { + memset(&m_bi, 0, sizeof(m_bi)); // initialize structure to 0/NULL + + m_bi.hwndOwner = hWndParent; + m_bi.pidlRoot = NULL; + m_bi.pszDisplayName = m_szFolderDisplayName; + m_bi.lpszTitle = lpstrTitle; + m_bi.ulFlags = uFlags; + m_bi.lpfn = BrowseCallbackProc; + m_bi.lParam = (LPARAM)static_cast(this); + + m_szFolderPath[0] = 0; + m_szFolderDisplayName[0] = 0; + } + + ~CFolderDialogImpl() + { + ::CoTaskMemFree(m_pidlSelected); + } + +// Operations + INT_PTR DoModal(HWND hWndParent = ::GetActiveWindow()) + { + if(m_bi.hwndOwner == NULL) // set only if not specified before + m_bi.hwndOwner = hWndParent; + + // Clear out any previous results + m_szFolderPath[0] = 0; + m_szFolderDisplayName[0] = 0; + ::CoTaskMemFree(m_pidlSelected); + + INT_PTR nRet = IDCANCEL; + m_pidlSelected = ::SHBrowseForFolder(&m_bi); + + if(m_pidlSelected != NULL) + { + nRet = IDOK; + + // If BIF_RETURNONLYFSDIRS is set, we try to get the filesystem path. + // Otherwise, the caller must handle the ID-list directly. + if((m_bi.ulFlags & BIF_RETURNONLYFSDIRS) != 0) + { + if(::SHGetPathFromIDList(m_pidlSelected, m_szFolderPath) == FALSE) + nRet = IDCANCEL; + } + } + + return nRet; + } + + // Methods to call before DoModal + void SetInitialFolder(LPCTSTR lpstrInitialFolder, bool bExpand = true) + { + // lpstrInitialFolder may be a file if BIF_BROWSEINCLUDEFILES is specified + m_lpstrInitialFolder = lpstrInitialFolder; + m_bExpandInitialSelection = bExpand; + } + + void SetInitialSelection(LPCITEMIDLIST pidl, bool bExpand = true) + { + m_pidlInitialSelection = pidl; + m_bExpandInitialSelection = bExpand; + } + +#ifdef STRICT_TYPED_ITEMIDS + void SetRootFolder(PCIDLIST_ABSOLUTE pidl) +#else + void SetRootFolder(LPCITEMIDLIST pidl) +#endif + { + m_bi.pidlRoot = pidl; + } + + // Methods to call after DoModal + LPITEMIDLIST GetSelectedItem(bool bDetach = false) + { + LPITEMIDLIST pidl = m_pidlSelected; + if(bDetach) + m_pidlSelected = NULL; + + return pidl; + } + + LPCTSTR GetFolderPath() const + { + return m_szFolderPath; + } + + LPCTSTR GetFolderDisplayName() const + { + return m_szFolderDisplayName; + } + + int GetFolderImageIndex() const + { + return m_bi.iImage; + } + +// Callback function and overrideables + static int CALLBACK BrowseCallbackProc(HWND hWnd, UINT uMsg, LPARAM lParam, LPARAM lpData) + { + int nRet = 0; + T* pT = (T*)lpData; + bool bClear = false; + if(pT->m_hWnd == NULL) + { + pT->m_hWnd = hWnd; + bClear = true; + } + else + { + ATLASSERT(pT->m_hWnd == hWnd); + } + + switch(uMsg) + { + case BFFM_INITIALIZED: + // Set initial selection + // Note that m_pidlInitialSelection, if set, takes precedence over m_lpstrInitialFolder + if(pT->m_pidlInitialSelection != NULL) + pT->SetSelection(pT->m_pidlInitialSelection); + else if(pT->m_lpstrInitialFolder != NULL) + pT->SetSelection(pT->m_lpstrInitialFolder); + + // Expand initial selection if appropriate + if(pT->m_bExpandInitialSelection && ((pT->m_bi.ulFlags & BIF_NEWDIALOGSTYLE) != 0)) + { + if(pT->m_pidlInitialSelection != NULL) + pT->SetExpanded(pT->m_pidlInitialSelection); + else if(pT->m_lpstrInitialFolder != NULL) + pT->SetExpanded(pT->m_lpstrInitialFolder); + } + pT->OnInitialized(); + break; + case BFFM_SELCHANGED: + pT->OnSelChanged((LPITEMIDLIST)lParam); + break; + case BFFM_VALIDATEFAILED: + nRet = pT->OnValidateFailed((LPCTSTR)lParam); + break; + case BFFM_IUNKNOWN: + pT->OnIUnknown((IUnknown*)lParam); + break; + default: + ATLTRACE2(atlTraceUI, 0, _T("Unknown message received in CFolderDialogImpl::BrowseCallbackProc\n")); + break; + } + + if(bClear) + pT->m_hWnd = NULL; + return nRet; + } + + void OnInitialized() + { + } + + void OnSelChanged(LPITEMIDLIST /*pItemIDList*/) + { + } + + int OnValidateFailed(LPCTSTR /*lpstrFolderPath*/) + { + return 1; // 1=continue, 0=EndDialog + } + + void OnIUnknown(IUnknown* /*pUnknown*/) + { + } + + // Commands - valid to call only from handlers + void EnableOK(BOOL bEnable) + { + ATLASSERT(m_hWnd != NULL); + ::SendMessage(m_hWnd, BFFM_ENABLEOK, 0, bEnable); + } + + void SetSelection(LPCITEMIDLIST pItemIDList) + { + ATLASSERT(m_hWnd != NULL); + ::SendMessage(m_hWnd, BFFM_SETSELECTION, FALSE, (LPARAM)pItemIDList); + } + + void SetSelection(LPCTSTR lpstrFolderPath) + { + ATLASSERT(m_hWnd != NULL); + ::SendMessage(m_hWnd, BFFM_SETSELECTION, TRUE, (LPARAM)lpstrFolderPath); + } + + void SetStatusText(LPCTSTR lpstrText) + { + ATLASSERT(m_hWnd != NULL); + ::SendMessage(m_hWnd, BFFM_SETSTATUSTEXT, 0, (LPARAM)lpstrText); + } + + void SetOKText(LPCTSTR lpstrOKText) + { + ATLASSERT(m_hWnd != NULL); + USES_CONVERSION; + LPCWSTR lpstr = T2CW(lpstrOKText); + ::SendMessage(m_hWnd, BFFM_SETOKTEXT, 0, (LPARAM)lpstr); + } + + void SetExpanded(LPCITEMIDLIST pItemIDList) + { + ATLASSERT(m_hWnd != NULL); + ::SendMessage(m_hWnd, BFFM_SETEXPANDED, FALSE, (LPARAM)pItemIDList); + } + + void SetExpanded(LPCTSTR lpstrFolderPath) + { + ATLASSERT(m_hWnd != NULL); + USES_CONVERSION; + LPCWSTR lpstr = T2CW(lpstrFolderPath); + ::SendMessage(m_hWnd, BFFM_SETEXPANDED, TRUE, (LPARAM)lpstr); + } +}; + +class CFolderDialog : public CFolderDialogImpl +{ +public: + CFolderDialog(HWND hWndParent = NULL, LPCTSTR lpstrTitle = NULL, UINT uFlags = BIF_RETURNONLYFSDIRS) + : CFolderDialogImpl(hWndParent, lpstrTitle, uFlags) + { } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CCommonDialogImplBase - base class for common dialog classes + +class ATL_NO_VTABLE CCommonDialogImplBase : public ATL::CWindowImplBase +{ +public: + static UINT_PTR APIENTRY HookProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) + { + if(uMsg != WM_INITDIALOG) + return 0; + CCommonDialogImplBase* pT = (CCommonDialogImplBase*)ModuleHelper::ExtractCreateWndData(); + ATLASSERT(pT != NULL); + ATLASSERT(pT->m_hWnd == NULL); + ATLASSERT(::IsWindow(hWnd)); + // subclass dialog's window + if(!pT->SubclassWindow(hWnd)) + { + ATLTRACE2(atlTraceUI, 0, _T("Subclassing a common dialog failed\n")); + return 0; + } + // check message map for WM_INITDIALOG handler + LRESULT lRes = 0; + if(pT->ProcessWindowMessage(pT->m_hWnd, uMsg, wParam, lParam, lRes, 0) == FALSE) + return 0; + return lRes; + } + +// Special override for common dialogs + BOOL EndDialog(INT_PTR /*nRetCode*/ = 0) + { + ATLASSERT(::IsWindow(m_hWnd)); + SendMessage(WM_COMMAND, MAKEWPARAM(IDABORT, 0)); + return TRUE; + } + +// Implementation - try to override these, to prevent errors + HWND Create(HWND, ATL::_U_RECT, LPCTSTR, DWORD, DWORD, ATL::_U_MENUorID, ATOM, LPVOID) + { + ATLASSERT(FALSE); // should not be called + return NULL; + } + + static LRESULT CALLBACK StartWindowProc(HWND /*hWnd*/, UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/) + { + ATLASSERT(FALSE); // should not be called + return 0; + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CFontDialogImpl - font selection dialog + +template +class ATL_NO_VTABLE CFontDialogImpl : public CCommonDialogImplBase +{ +public: + enum { _cchStyleName = 64 }; + + CHOOSEFONT m_cf; + TCHAR m_szStyleName[_cchStyleName]; // contains style name after return + LOGFONT m_lf; // default LOGFONT to store the info + +// Constructors + CFontDialogImpl(LPLOGFONT lplfInitial = NULL, + DWORD dwFlags = CF_EFFECTS | CF_SCREENFONTS, + HDC hDCPrinter = NULL, + HWND hWndParent = NULL) + { + memset(&m_cf, 0, sizeof(m_cf)); + memset(&m_lf, 0, sizeof(m_lf)); + memset(&m_szStyleName, 0, sizeof(m_szStyleName)); + + m_cf.lStructSize = sizeof(m_cf); + m_cf.hwndOwner = hWndParent; + m_cf.rgbColors = RGB(0, 0, 0); + m_cf.lpszStyle = (LPTSTR)&m_szStyleName; + m_cf.Flags = dwFlags | CF_ENABLEHOOK; + m_cf.lpfnHook = (LPCFHOOKPROC)T::HookProc; + + if(lplfInitial != NULL) + { + m_cf.lpLogFont = lplfInitial; + m_cf.Flags |= CF_INITTOLOGFONTSTRUCT; + m_lf = *lplfInitial; + } + else + { + m_cf.lpLogFont = &m_lf; + } + + if(hDCPrinter != NULL) + { + m_cf.hDC = hDCPrinter; + m_cf.Flags |= CF_PRINTERFONTS; + } + } + +// Operations + INT_PTR DoModal(HWND hWndParent = ::GetActiveWindow()) + { + ATLASSERT((m_cf.Flags & CF_ENABLEHOOK) != 0); + ATLASSERT(m_cf.lpfnHook != NULL); // can still be a user hook + + if(m_cf.hwndOwner == NULL) // set only if not specified before + m_cf.hwndOwner = hWndParent; + + ATLASSERT(m_hWnd == NULL); + + // Allocate the thunk structure here, where we can fail gracefully. + BOOL bRetTh = m_thunk.Init(NULL, NULL); + if(bRetTh == FALSE) + { + ::SetLastError(ERROR_OUTOFMEMORY); + return -1; + } + + ModuleHelper::AddCreateWndData(&m_thunk.cd, (CCommonDialogImplBase*)this); + + BOOL bRet = ::ChooseFont(&m_cf); + + m_hWnd = NULL; + + if(bRet) // copy logical font from user's initialization buffer (if needed) + ATL::Checked::memcpy_s(&m_lf, sizeof(m_lf), m_cf.lpLogFont, sizeof(m_lf)); + + return bRet ? IDOK : IDCANCEL; + } + + // works only when the dialog is dislayed or after + void GetCurrentFont(LPLOGFONT lplf) const + { + ATLASSERT(lplf != NULL); + + if(m_hWnd != NULL) + ::SendMessage(m_hWnd, WM_CHOOSEFONT_GETLOGFONT, 0, (LPARAM)lplf); + else + *lplf = m_lf; + } + + // works only when the dialog is dislayed or before + void SetLogFont(LPLOGFONT lplf) + { + ATLASSERT(lplf != NULL); + + if(m_hWnd != NULL) + { + ::SendMessage(m_hWnd, WM_CHOOSEFONT_SETLOGFONT, 0, (LPARAM)lplf); + } + else + { + m_lf = *lplf; + m_cf.Flags |= CF_INITTOLOGFONTSTRUCT; + } + } + + void SetFlags(DWORD dwFlags) + { + if(m_hWnd != NULL) + { + CHOOSEFONT cf = { sizeof(CHOOSEFONT) }; + cf.Flags = dwFlags; + ::SendMessage(m_hWnd, WM_CHOOSEFONT_SETFLAGS, 0, (LPARAM)&cf); + } + else + { + m_cf.Flags = dwFlags; + } + } + + // Helpers for parsing information after successful return + LPCTSTR GetFaceName() const // return the face name of the font + { + return (LPCTSTR)m_cf.lpLogFont->lfFaceName; + } + + LPCTSTR GetStyleName() const // return the style name of the font + { + return m_cf.lpszStyle; + } + + int GetSize() const // return the pt size of the font + { + return m_cf.iPointSize; + } + + COLORREF GetColor() const // return the color of the font + { + return m_cf.rgbColors; + } + + int GetWeight() const // return the chosen font weight + { + return (int)m_cf.lpLogFont->lfWeight; + } + + BOOL IsStrikeOut() const // return TRUE if strikeout + { + return (m_cf.lpLogFont->lfStrikeOut) ? TRUE : FALSE; + } + + BOOL IsUnderline() const // return TRUE if underline + { + return (m_cf.lpLogFont->lfUnderline) ? TRUE : FALSE; + } + + BOOL IsBold() const // return TRUE if bold font + { + return (m_cf.lpLogFont->lfWeight == FW_BOLD) ? TRUE : FALSE; + } + + BOOL IsItalic() const // return TRUE if italic font + { + return m_cf.lpLogFont->lfItalic ? TRUE : FALSE; + } +}; + +class CFontDialog : public CFontDialogImpl +{ +public: + CFontDialog(LPLOGFONT lplfInitial = NULL, + DWORD dwFlags = CF_EFFECTS | CF_SCREENFONTS, + HDC hDCPrinter = NULL, + HWND hWndParent = NULL) + : CFontDialogImpl(lplfInitial, dwFlags, hDCPrinter, hWndParent) + { } + + DECLARE_EMPTY_MSG_MAP() +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CRichEditFontDialogImpl - font selection for the Rich Edit ctrl + +#ifdef _RICHEDIT_ + +template +class ATL_NO_VTABLE CRichEditFontDialogImpl : public CFontDialogImpl< T > +{ +public: + CRichEditFontDialogImpl(const CHARFORMAT& charformat, + DWORD dwFlags = CF_SCREENFONTS, + HDC hDCPrinter = NULL, + HWND hWndParent = NULL) + : CFontDialogImpl< T >(NULL, dwFlags, hDCPrinter, hWndParent) + { + this->m_cf.Flags |= CF_INITTOLOGFONTSTRUCT; + this->m_cf.Flags |= FillInLogFont(charformat); + this->m_cf.lpLogFont = &this->m_lf; + + if((charformat.dwMask & CFM_COLOR) != 0) + this->m_cf.rgbColors = charformat.crTextColor; + } + + void GetCharFormat(CHARFORMAT& cf) const + { + USES_CONVERSION; + cf.dwEffects = 0; + cf.dwMask = 0; + if((this->m_cf.Flags & CF_NOSTYLESEL) == 0) + { + cf.dwMask |= CFM_BOLD | CFM_ITALIC; + cf.dwEffects |= this->IsBold() ? CFE_BOLD : 0; + cf.dwEffects |= this->IsItalic() ? CFE_ITALIC : 0; + } + if((this->m_cf.Flags & CF_NOSIZESEL) == 0) + { + cf.dwMask |= CFM_SIZE; + // GetSize() returns in tenths of points so mulitply by 2 to get twips + cf.yHeight = this->GetSize() * 2; + } + + if((this->m_cf.Flags & CF_NOFACESEL) == 0) + { + cf.dwMask |= CFM_FACE; + cf.bPitchAndFamily = this->m_cf.lpLogFont->lfPitchAndFamily; + ATL::Checked::tcscpy_s(cf.szFaceName, _countof(cf.szFaceName), this->GetFaceName()); + } + + if((this->m_cf.Flags & CF_EFFECTS) != 0) + { + cf.dwMask |= CFM_UNDERLINE | CFM_STRIKEOUT | CFM_COLOR; + cf.dwEffects |= this->IsUnderline() ? CFE_UNDERLINE : 0; + cf.dwEffects |= this->IsStrikeOut() ? CFE_STRIKEOUT : 0; + cf.crTextColor = this->GetColor(); + } + if((this->m_cf.Flags & CF_NOSCRIPTSEL) == 0) + { + cf.bCharSet = this->m_cf.lpLogFont->lfCharSet; + cf.dwMask |= CFM_CHARSET; + } + cf.yOffset = 0; + } + + DWORD FillInLogFont(const CHARFORMAT& cf) + { + USES_CONVERSION; + DWORD dwFlags = 0; + if((cf.dwMask & CFM_SIZE) != 0) + { + HDC hDC = ::CreateDC(_T("DISPLAY"), NULL, NULL, NULL); + LONG yPerInch = ::GetDeviceCaps(hDC, LOGPIXELSY); + this->m_lf.lfHeight = -(int)((cf.yHeight * yPerInch) / 1440); + } + else + this->m_lf.lfHeight = 0; + + this->m_lf.lfWidth = 0; + this->m_lf.lfEscapement = 0; + this->m_lf.lfOrientation = 0; + + if((cf.dwMask & (CFM_ITALIC | CFM_BOLD)) == (CFM_ITALIC | CFM_BOLD)) + { + this->m_lf.lfWeight = ((cf.dwEffects & CFE_BOLD) != 0) ? FW_BOLD : FW_NORMAL; + this->m_lf.lfItalic = (BYTE)(((cf.dwEffects & CFE_ITALIC) != 0) ? TRUE : FALSE); + } + else + { + dwFlags |= CF_NOSTYLESEL; + this->m_lf.lfWeight = FW_DONTCARE; + this->m_lf.lfItalic = FALSE; + } + + if((cf.dwMask & (CFM_UNDERLINE | CFM_STRIKEOUT | CFM_COLOR)) == (CFM_UNDERLINE|CFM_STRIKEOUT|CFM_COLOR)) + { + dwFlags |= CF_EFFECTS; + this->m_lf.lfUnderline = (BYTE)(((cf.dwEffects & CFE_UNDERLINE) != 0) ? TRUE : FALSE); + this->m_lf.lfStrikeOut = (BYTE)(((cf.dwEffects & CFE_STRIKEOUT) != 0) ? TRUE : FALSE); + } + else + { + this->m_lf.lfUnderline = (BYTE)FALSE; + this->m_lf.lfStrikeOut = (BYTE)FALSE; + } + + if((cf.dwMask & CFM_CHARSET) != 0) + this->m_lf.lfCharSet = cf.bCharSet; + else + dwFlags |= CF_NOSCRIPTSEL; + this->m_lf.lfOutPrecision = OUT_DEFAULT_PRECIS; + this->m_lf.lfClipPrecision = CLIP_DEFAULT_PRECIS; + this->m_lf.lfQuality = DEFAULT_QUALITY; + if((cf.dwMask & CFM_FACE) != 0) + { + this->m_lf.lfPitchAndFamily = cf.bPitchAndFamily; + ATL::Checked::tcscpy_s(this->m_lf.lfFaceName, _countof(this->m_lf.lfFaceName), cf.szFaceName); + } + else + { + this->m_lf.lfPitchAndFamily = DEFAULT_PITCH|FF_DONTCARE; + this->m_lf.lfFaceName[0] = (TCHAR)0; + } + return dwFlags; + } +}; + +class CRichEditFontDialog : public CRichEditFontDialogImpl +{ +public: + CRichEditFontDialog(const CHARFORMAT& charformat, + DWORD dwFlags = CF_SCREENFONTS, + HDC hDCPrinter = NULL, + HWND hWndParent = NULL) + : CRichEditFontDialogImpl(charformat, dwFlags, hDCPrinter, hWndParent) + { } + + DECLARE_EMPTY_MSG_MAP() +}; + +#endif // _RICHEDIT_ + + +/////////////////////////////////////////////////////////////////////////////// +// CColorDialogImpl - color selection + +template +class ATL_NO_VTABLE CColorDialogImpl : public CCommonDialogImplBase +{ +public: + CHOOSECOLOR m_cc; + +// Constructor + CColorDialogImpl(COLORREF clrInit = 0, DWORD dwFlags = 0, HWND hWndParent = NULL) + { + memset(&m_cc, 0, sizeof(m_cc)); + + m_cc.lStructSize = sizeof(m_cc); + m_cc.lpCustColors = GetCustomColors(); + m_cc.hwndOwner = hWndParent; + m_cc.Flags = dwFlags | CC_ENABLEHOOK; + m_cc.lpfnHook = (LPCCHOOKPROC)T::HookProc; + + if(clrInit != 0) + { + m_cc.rgbResult = clrInit; + m_cc.Flags |= CC_RGBINIT; + } + } + +// Operations + INT_PTR DoModal(HWND hWndParent = ::GetActiveWindow()) + { + ATLASSERT((m_cc.Flags & CC_ENABLEHOOK) != 0); + ATLASSERT(m_cc.lpfnHook != NULL); // can still be a user hook + + if(m_cc.hwndOwner == NULL) // set only if not specified before + m_cc.hwndOwner = hWndParent; + + ATLASSERT(m_hWnd == NULL); + + // Allocate the thunk structure here, where we can fail gracefully. + BOOL bRetTh = m_thunk.Init(NULL, NULL); + if(bRetTh == FALSE) + { + ::SetLastError(ERROR_OUTOFMEMORY); + return -1; + } + + ModuleHelper::AddCreateWndData(&m_thunk.cd, (CCommonDialogImplBase*)this); + + BOOL bRet = ::ChooseColor(&m_cc); + + m_hWnd = NULL; + + return bRet ? IDOK : IDCANCEL; + } + + // Set the current color while dialog is displayed + void SetCurrentColor(COLORREF clr) + { + ATLASSERT(::IsWindow(m_hWnd)); + SendMessage(_GetSetRGBMessage(), 0, (LPARAM)clr); + } + + // Get the selected color after DoModal returns, or in OnColorOK + COLORREF GetColor() const + { + return m_cc.rgbResult; + } + +// Special override for the color dialog + static UINT_PTR APIENTRY HookProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) + { + if((uMsg != WM_INITDIALOG) && (uMsg != _GetColorOKMessage())) + return 0; + + LPCHOOSECOLOR lpCC = (LPCHOOSECOLOR)lParam; + CCommonDialogImplBase* pT = NULL; + + if(uMsg == WM_INITDIALOG) + { + pT = (CCommonDialogImplBase*)ModuleHelper::ExtractCreateWndData(); + lpCC->lCustData = (LPARAM)pT; + ATLASSERT(pT != NULL); + ATLASSERT(pT->m_hWnd == NULL); + ATLASSERT(::IsWindow(hWnd)); + // subclass dialog's window + if(!pT->SubclassWindow(hWnd)) + { + ATLTRACE2(atlTraceUI, 0, _T("Subclassing a Color common dialog failed\n")); + return 0; + } + } + else if(uMsg == _GetColorOKMessage()) + { + pT = (CCommonDialogImplBase*)lpCC->lCustData; + ATLASSERT(pT != NULL); + ATLASSERT(::IsWindow(pT->m_hWnd)); + } + else + { + ATLASSERT(FALSE); + return 0; + } + + // pass to the message map + LRESULT lRes = 0; + if(pT->ProcessWindowMessage(pT->m_hWnd, uMsg, wParam, lParam, lRes, 0) == FALSE) + return 0; + + return lRes; + } + +// Helpers + static COLORREF* GetCustomColors() + { + static COLORREF rgbCustomColors[16] = + { + RGB(255, 255, 255), RGB(255, 255, 255), + RGB(255, 255, 255), RGB(255, 255, 255), + RGB(255, 255, 255), RGB(255, 255, 255), + RGB(255, 255, 255), RGB(255, 255, 255), + RGB(255, 255, 255), RGB(255, 255, 255), + RGB(255, 255, 255), RGB(255, 255, 255), + RGB(255, 255, 255), RGB(255, 255, 255), + RGB(255, 255, 255), RGB(255, 255, 255), + }; + + return rgbCustomColors; + } + + static UINT _GetSetRGBMessage() + { + static UINT uSetRGBMessage = 0; + if(uSetRGBMessage == 0) + { + CStaticDataInitCriticalSectionLock lock; + if(FAILED(lock.Lock())) + { + ATLTRACE2(atlTraceUI, 0, _T("ERROR : Unable to lock critical section in CColorDialogImpl::_GetSetRGBMessage.\n")); + ATLASSERT(FALSE); + return 0; + } + + if(uSetRGBMessage == 0) + uSetRGBMessage = ::RegisterWindowMessage(SETRGBSTRING); + + lock.Unlock(); + } + ATLASSERT(uSetRGBMessage != 0); + return uSetRGBMessage; + } + + static UINT _GetColorOKMessage() + { + static UINT uColorOKMessage = 0; + if(uColorOKMessage == 0) + { + CStaticDataInitCriticalSectionLock lock; + if(FAILED(lock.Lock())) + { + ATLTRACE2(atlTraceUI, 0, _T("ERROR : Unable to lock critical section in CColorDialogImpl::_GetColorOKMessage.\n")); + ATLASSERT(FALSE); + return 0; + } + + if(uColorOKMessage == 0) + uColorOKMessage = ::RegisterWindowMessage(COLOROKSTRING); + + lock.Unlock(); + } + ATLASSERT(uColorOKMessage != 0); + return uColorOKMessage; + } + +// Message map and handlers + BEGIN_MSG_MAP(CColorDialogImpl) + MESSAGE_HANDLER(_GetColorOKMessage(), _OnColorOK) + END_MSG_MAP() + + LRESULT _OnColorOK(UINT, WPARAM, LPARAM, BOOL&) + { + T* pT = static_cast(this); + return pT->OnColorOK(); + } + +// Overrideable + BOOL OnColorOK() // validate color + { + return FALSE; + } +}; + +class CColorDialog : public CColorDialogImpl +{ +public: + CColorDialog(COLORREF clrInit = 0, DWORD dwFlags = 0, HWND hWndParent = NULL) + : CColorDialogImpl(clrInit, dwFlags, hWndParent) + { } + + // override base class map and references to handlers + DECLARE_EMPTY_MSG_MAP() +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CPrintDialogImpl - used for Print... and PrintSetup... + +// global helper +static inline HDC _AtlCreateDC(HGLOBAL hDevNames, HGLOBAL hDevMode) +{ + if(hDevNames == NULL) + return NULL; + + LPDEVNAMES lpDevNames = (LPDEVNAMES)::GlobalLock(hDevNames); + LPDEVMODE lpDevMode = (hDevMode != NULL) ? (LPDEVMODE)::GlobalLock(hDevMode) : NULL; + + if(lpDevNames == NULL) + return NULL; + + HDC hDC = ::CreateDC((LPCTSTR)lpDevNames + lpDevNames->wDriverOffset, + (LPCTSTR)lpDevNames + lpDevNames->wDeviceOffset, + (LPCTSTR)lpDevNames + lpDevNames->wOutputOffset, + lpDevMode); + + ::GlobalUnlock(hDevNames); + if(hDevMode != NULL) + ::GlobalUnlock(hDevMode); + return hDC; +} + +#pragma warning(push) +#pragma warning(disable: 4512) // assignment operator could not be generated + +template +class ATL_NO_VTABLE CPrintDialogImpl : public CCommonDialogImplBase +{ +public: + // print dialog parameter block (note this is a reference) + PRINTDLG& m_pd; + +// Constructors + CPrintDialogImpl(BOOL bPrintSetupOnly = FALSE, // TRUE for Print Setup, FALSE for Print Dialog + DWORD dwFlags = PD_ALLPAGES | PD_USEDEVMODECOPIES | PD_NOPAGENUMS | PD_NOSELECTION, + HWND hWndParent = NULL) + : m_pd(m_pdActual) + { + memset(&m_pdActual, 0, sizeof(m_pdActual)); + + m_pd.lStructSize = sizeof(m_pdActual); + m_pd.hwndOwner = hWndParent; + m_pd.Flags = (dwFlags | PD_ENABLEPRINTHOOK | PD_ENABLESETUPHOOK); + m_pd.lpfnPrintHook = (LPPRINTHOOKPROC)T::HookProc; + m_pd.lpfnSetupHook = (LPSETUPHOOKPROC)T::HookProc; + + if(bPrintSetupOnly) + m_pd.Flags |= PD_PRINTSETUP; + else + m_pd.Flags |= PD_RETURNDC; + + m_pd.Flags &= ~PD_RETURNIC; // do not support information context + } + +// Operations + INT_PTR DoModal(HWND hWndParent = ::GetActiveWindow()) + { + ATLASSERT((m_pd.Flags & PD_ENABLEPRINTHOOK) != 0); + ATLASSERT((m_pd.Flags & PD_ENABLESETUPHOOK) != 0); + ATLASSERT(m_pd.lpfnPrintHook != NULL); // can still be a user hook + ATLASSERT(m_pd.lpfnSetupHook != NULL); // can still be a user hook + ATLASSERT((m_pd.Flags & PD_RETURNDEFAULT) == 0); // use GetDefaults for this + + if(m_pd.hwndOwner == NULL) // set only if not specified before + m_pd.hwndOwner = hWndParent; + + ATLASSERT(m_hWnd == NULL); + + // Allocate the thunk structure here, where we can fail gracefully. + BOOL bRetTh = m_thunk.Init(NULL, NULL); + if(bRetTh == FALSE) + { + ::SetLastError(ERROR_OUTOFMEMORY); + return -1; + } + + ModuleHelper::AddCreateWndData(&m_thunk.cd, (CCommonDialogImplBase*)this); + + BOOL bRet = ::PrintDlg(&m_pd); + + m_hWnd = NULL; + + return bRet ? IDOK : IDCANCEL; + } + + // GetDefaults will not display a dialog but will get device defaults + BOOL GetDefaults() + { + m_pd.Flags |= PD_RETURNDEFAULT; + ATLASSERT(m_pd.hDevMode == NULL); // must be NULL + ATLASSERT(m_pd.hDevNames == NULL); // must be NULL + + return ::PrintDlg(&m_pd); + } + + // Helpers for parsing information after successful return num. copies requested + int GetCopies() const + { + if((m_pd.Flags & PD_USEDEVMODECOPIES) != 0) + { + LPDEVMODE lpDevMode = GetDevMode(); + return (lpDevMode != NULL) ? lpDevMode->dmCopies : -1; + } + + return m_pd.nCopies; + } + + BOOL PrintCollate() const // TRUE if collate checked + { + return ((m_pd.Flags & PD_COLLATE) != 0) ? TRUE : FALSE; + } + + BOOL PrintSelection() const // TRUE if printing selection + { + return ((m_pd.Flags & PD_SELECTION) != 0) ? TRUE : FALSE; + } + + BOOL PrintAll() const // TRUE if printing all pages + { + return (!PrintRange() && !PrintSelection()) ? TRUE : FALSE; + } + + BOOL PrintRange() const // TRUE if printing page range + { + return ((m_pd.Flags & PD_PAGENUMS) != 0) ? TRUE : FALSE; + } + + BOOL PrintToFile() const // TRUE if printing to a file + { + return ((m_pd.Flags & PD_PRINTTOFILE) != 0) ? TRUE : FALSE; + } + + int GetFromPage() const // starting page if valid + { + return PrintRange() ? m_pd.nFromPage : -1; + } + + int GetToPage() const // ending page if valid + { + return PrintRange() ? m_pd.nToPage : -1; + } + + LPDEVMODE GetDevMode() const // return DEVMODE + { + if(m_pd.hDevMode == NULL) + return NULL; + + return (LPDEVMODE)::GlobalLock(m_pd.hDevMode); + } + + LPCTSTR GetDriverName() const // return driver name + { + if(m_pd.hDevNames == NULL) + return NULL; + + LPDEVNAMES lpDev = (LPDEVNAMES)::GlobalLock(m_pd.hDevNames); + if(lpDev == NULL) + return NULL; + + return (LPCTSTR)lpDev + lpDev->wDriverOffset; + } + + LPCTSTR GetDeviceName() const // return device name + { + if(m_pd.hDevNames == NULL) + return NULL; + + LPDEVNAMES lpDev = (LPDEVNAMES)::GlobalLock(m_pd.hDevNames); + if(lpDev == NULL) + return NULL; + + return (LPCTSTR)lpDev + lpDev->wDeviceOffset; + } + + LPCTSTR GetPortName() const // return output port name + { + if(m_pd.hDevNames == NULL) + return NULL; + + LPDEVNAMES lpDev = (LPDEVNAMES)::GlobalLock(m_pd.hDevNames); + if(lpDev == NULL) + return NULL; + + return (LPCTSTR)lpDev + lpDev->wOutputOffset; + } + + HDC GetPrinterDC() const // return HDC (caller must delete) + { + ATLASSERT((m_pd.Flags & PD_RETURNDC) != 0); + return m_pd.hDC; + } + + // This helper creates a DC based on the DEVNAMES and DEVMODE structures. + // This DC is returned, but also stored in m_pd.hDC as though it had been + // returned by CommDlg. It is assumed that any previously obtained DC + // has been/will be deleted by the user. This may be + // used without ever invoking the print/print setup dialogs. + HDC CreatePrinterDC() + { + m_pd.hDC = _AtlCreateDC(m_pd.hDevNames, m_pd.hDevMode); + return m_pd.hDC; + } + +// Implementation + PRINTDLG m_pdActual; // the Print/Print Setup need to share this + + // The following handle the case of print setup... from the print dialog + CPrintDialogImpl(PRINTDLG& pdInit) : m_pd(pdInit) + { } + + BEGIN_MSG_MAP(CPrintDialogImpl) +#ifdef psh1 + COMMAND_ID_HANDLER(psh1, OnPrintSetup) // print setup button when print is displayed +#else // !psh1 + COMMAND_ID_HANDLER(0x0400, OnPrintSetup) // value from dlgs.h +#endif // !psh1 + END_MSG_MAP() + + LRESULT OnPrintSetup(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& /*bHandled*/) + { + T dlgSetup(m_pd); + ModuleHelper::AddCreateWndData(&dlgSetup.m_thunk.cd, (CCommonDialogImplBase*)&dlgSetup); + return DefWindowProc(WM_COMMAND, MAKEWPARAM(wID, wNotifyCode), (LPARAM)hWndCtl); + } +}; + +class CPrintDialog : public CPrintDialogImpl +{ +public: + CPrintDialog(BOOL bPrintSetupOnly = FALSE, + DWORD dwFlags = PD_ALLPAGES | PD_USEDEVMODECOPIES | PD_NOPAGENUMS | PD_NOSELECTION, + HWND hWndParent = NULL) + : CPrintDialogImpl(bPrintSetupOnly, dwFlags, hWndParent) + { } + + CPrintDialog(PRINTDLG& pdInit) : CPrintDialogImpl(pdInit) + { } +}; + +#pragma warning(pop) + + +/////////////////////////////////////////////////////////////////////////////// +// CPrintDialogExImpl - new print dialog for Windows 2000 + +} // namespace WTL + +#include + +extern "C" const __declspec(selectany) IID IID_IPrintDialogCallback = {0x5852a2c3, 0x6530, 0x11d1, {0xb6, 0xa3, 0x0, 0x0, 0xf8, 0x75, 0x7b, 0xf9}}; +extern "C" const __declspec(selectany) IID IID_IPrintDialogServices = {0x509aaeda, 0x5639, 0x11d1, {0xb6, 0xa1, 0x0, 0x0, 0xf8, 0x75, 0x7b, 0xf9}}; + +namespace WTL +{ + +template +class ATL_NO_VTABLE CPrintDialogExImpl : + public ATL::CWindow, + public ATL::CMessageMap, + public IPrintDialogCallback, + public ATL::IObjectWithSiteImpl< T > +{ +public: + PRINTDLGEX m_pdex; + +// Constructor + CPrintDialogExImpl(DWORD dwFlags = PD_ALLPAGES | PD_USEDEVMODECOPIES | PD_NOPAGENUMS | PD_NOSELECTION | PD_NOCURRENTPAGE, + HWND hWndParent = NULL) + { + memset(&m_pdex, 0, sizeof(m_pdex)); + + m_pdex.lStructSize = sizeof(PRINTDLGEX); + m_pdex.hwndOwner = hWndParent; + m_pdex.Flags = dwFlags; + m_pdex.nStartPage = START_PAGE_GENERAL; + // callback object will be set in DoModal + + m_pdex.Flags &= ~PD_RETURNIC; // do not support information context + } + +// Operations + HRESULT DoModal(HWND hWndParent = ::GetActiveWindow()) + { + ATLASSERT(m_hWnd == NULL); + ATLASSERT((m_pdex.Flags & PD_RETURNDEFAULT) == 0); // use GetDefaults for this + + if(m_pdex.hwndOwner == NULL) // set only if not specified before + m_pdex.hwndOwner = hWndParent; + + T* pT = static_cast(this); + m_pdex.lpCallback = (IUnknown*)(IPrintDialogCallback*)pT; + + HRESULT hResult = ::PrintDlgEx(&m_pdex); + + m_hWnd = NULL; + + return hResult; + } + + BOOL EndDialog(INT_PTR /*nRetCode*/ = 0) + { + ATLASSERT(::IsWindow(m_hWnd)); + SendMessage(WM_COMMAND, MAKEWPARAM(IDABORT, 0)); + return TRUE; + } + + // GetDefaults will not display a dialog but will get device defaults + HRESULT GetDefaults() + { + ATLASSERT(m_pdex.hDevMode == NULL); // must be NULL + ATLASSERT(m_pdex.hDevNames == NULL); // must be NULL + + if(m_pdex.hwndOwner == NULL) // set only if not specified before + m_pdex.hwndOwner = ::GetActiveWindow(); + + m_pdex.Flags |= PD_RETURNDEFAULT; + HRESULT hRet = ::PrintDlgEx(&m_pdex); + m_pdex.Flags &= ~PD_RETURNDEFAULT; + + return hRet; + } + + // Helpers for parsing information after successful return num. copies requested + int GetCopies() const + { + if((m_pdex.Flags & PD_USEDEVMODECOPIES) != 0) + { + LPDEVMODE lpDevMode = GetDevMode(); + return (lpDevMode != NULL) ? lpDevMode->dmCopies : -1; + } + + return m_pdex.nCopies; + } + + BOOL PrintCollate() const // TRUE if collate checked + { + return ((m_pdex.Flags & PD_COLLATE) != 0) ? TRUE : FALSE; + } + + BOOL PrintSelection() const // TRUE if printing selection + { + return ((m_pdex.Flags & PD_SELECTION) != 0) ? TRUE : FALSE; + } + + BOOL PrintAll() const // TRUE if printing all pages + { + return (!PrintRange() && !PrintSelection()) ? TRUE : FALSE; + } + + BOOL PrintRange() const // TRUE if printing page range + { + return ((m_pdex.Flags & PD_PAGENUMS) != 0) ? TRUE : FALSE; + } + + BOOL PrintToFile() const // TRUE if printing to a file + { + return ((m_pdex.Flags & PD_PRINTTOFILE) != 0) ? TRUE : FALSE; + } + + LPDEVMODE GetDevMode() const // return DEVMODE + { + if(m_pdex.hDevMode == NULL) + return NULL; + + return (LPDEVMODE)::GlobalLock(m_pdex.hDevMode); + } + + LPCTSTR GetDriverName() const // return driver name + { + if(m_pdex.hDevNames == NULL) + return NULL; + + LPDEVNAMES lpDev = (LPDEVNAMES)::GlobalLock(m_pdex.hDevNames); + if(lpDev == NULL) + return NULL; + + return (LPCTSTR)lpDev + lpDev->wDriverOffset; + } + + LPCTSTR GetDeviceName() const // return device name + { + if(m_pdex.hDevNames == NULL) + return NULL; + + LPDEVNAMES lpDev = (LPDEVNAMES)::GlobalLock(m_pdex.hDevNames); + if(lpDev == NULL) + return NULL; + + return (LPCTSTR)lpDev + lpDev->wDeviceOffset; + } + + LPCTSTR GetPortName() const // return output port name + { + if(m_pdex.hDevNames == NULL) + return NULL; + + LPDEVNAMES lpDev = (LPDEVNAMES)::GlobalLock(m_pdex.hDevNames); + if(lpDev == NULL) + return NULL; + + return (LPCTSTR)lpDev + lpDev->wOutputOffset; + } + + HDC GetPrinterDC() const // return HDC (caller must delete) + { + ATLASSERT((m_pdex.Flags & PD_RETURNDC) != 0); + return m_pdex.hDC; + } + + // This helper creates a DC based on the DEVNAMES and DEVMODE structures. + // This DC is returned, but also stored in m_pdex.hDC as though it had been + // returned by CommDlg. It is assumed that any previously obtained DC + // has been/will be deleted by the user. This may be + // used without ever invoking the print/print setup dialogs. + HDC CreatePrinterDC() + { + m_pdex.hDC = _AtlCreateDC(m_pdex.hDevNames, m_pdex.hDevMode); + return m_pdex.hDC; + } + +// Implementation - interfaces + +// IUnknown + STDMETHOD(QueryInterface)(REFIID riid, void** ppvObject) + { + if(ppvObject == NULL) + return E_POINTER; + + T* pT = static_cast(this); + if(IsEqualGUID(riid, IID_IUnknown) || IsEqualGUID(riid, IID_IPrintDialogCallback)) + { + *ppvObject = (IPrintDialogCallback*)pT; + // AddRef() not needed + return S_OK; + } + else if(IsEqualGUID(riid, IID_IObjectWithSite)) + { + *ppvObject = (IObjectWithSite*)pT; + // AddRef() not needed + return S_OK; + } + + return E_NOINTERFACE; + } + + virtual ULONG STDMETHODCALLTYPE AddRef() + { + return 1; + } + + virtual ULONG STDMETHODCALLTYPE Release() + { + return 1; + } + +// IPrintDialogCallback + STDMETHOD(InitDone)() + { + return S_FALSE; + } + + STDMETHOD(SelectionChange)() + { + return S_FALSE; + } + + STDMETHOD(HandleMessage)(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT* plResult) + { + // set up m_hWnd the first time + if(m_hWnd == NULL) + Attach(hWnd); + + // call message map + HRESULT hRet = ProcessWindowMessage(hWnd, uMsg, wParam, lParam, *plResult, 0) ? S_OK : S_FALSE; + if((hRet == S_OK) && (uMsg == WM_NOTIFY)) // return in DWLP_MSGRESULT + ::SetWindowLongPtr(GetParent(), DWLP_MSGRESULT, (LONG_PTR)*plResult); + + if((uMsg == WM_INITDIALOG) && (hRet == S_OK) && ((BOOL)*plResult != FALSE)) + hRet = S_FALSE; + + return hRet; + } +}; + +class CPrintDialogEx : public CPrintDialogExImpl +{ +public: + CPrintDialogEx( + DWORD dwFlags = PD_ALLPAGES | PD_USEDEVMODECOPIES | PD_NOPAGENUMS | PD_NOSELECTION | PD_NOCURRENTPAGE, + HWND hWndParent = NULL) + : CPrintDialogExImpl(dwFlags, hWndParent) + { } + + DECLARE_EMPTY_MSG_MAP() +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CPageSetupDialogImpl - Page Setup dialog + +template +class ATL_NO_VTABLE CPageSetupDialogImpl : public CCommonDialogImplBase +{ +public: + PAGESETUPDLG m_psd; + ATL::CWndProcThunk m_thunkPaint; + +// Constructors + CPageSetupDialogImpl(DWORD dwFlags = PSD_MARGINS | PSD_INWININIINTLMEASURE, HWND hWndParent = NULL) + { + memset(&m_psd, 0, sizeof(m_psd)); + + m_psd.lStructSize = sizeof(m_psd); + m_psd.hwndOwner = hWndParent; + m_psd.Flags = (dwFlags | PSD_ENABLEPAGESETUPHOOK | PSD_ENABLEPAGEPAINTHOOK); + m_psd.lpfnPageSetupHook = (LPPAGESETUPHOOK)T::HookProc; + m_thunkPaint.Init((WNDPROC)T::PaintHookProc, this); + m_psd.lpfnPagePaintHook = (LPPAGEPAINTHOOK)m_thunkPaint.GetWNDPROC(); + } + + DECLARE_EMPTY_MSG_MAP() + +// Attributes + LPDEVMODE GetDevMode() const // return DEVMODE + { + if(m_psd.hDevMode == NULL) + return NULL; + + return (LPDEVMODE)::GlobalLock(m_psd.hDevMode); + } + + LPCTSTR GetDriverName() const // return driver name + { + if(m_psd.hDevNames == NULL) + return NULL; + + LPDEVNAMES lpDev = (LPDEVNAMES)::GlobalLock(m_psd.hDevNames); + return (LPCTSTR)lpDev + lpDev->wDriverOffset; + } + + LPCTSTR GetDeviceName() const // return device name + { + if(m_psd.hDevNames == NULL) + return NULL; + + LPDEVNAMES lpDev = (LPDEVNAMES)::GlobalLock(m_psd.hDevNames); + return (LPCTSTR)lpDev + lpDev->wDeviceOffset; + } + + LPCTSTR GetPortName() const // return output port name + { + if(m_psd.hDevNames == NULL) + return NULL; + + LPDEVNAMES lpDev = (LPDEVNAMES)::GlobalLock(m_psd.hDevNames); + return (LPCTSTR)lpDev + lpDev->wOutputOffset; + } + + HDC CreatePrinterDC() + { + return _AtlCreateDC(m_psd.hDevNames, m_psd.hDevMode); + } + + SIZE GetPaperSize() const + { + SIZE size = { m_psd.ptPaperSize.x, m_psd.ptPaperSize.y }; + return size; + } + + void GetMargins(LPRECT lpRectMargins, LPRECT lpRectMinMargins) const + { + if(lpRectMargins != NULL) + *lpRectMargins = m_psd.rtMargin; + if(lpRectMinMargins != NULL) + *lpRectMinMargins = m_psd.rtMinMargin; + } + +// Operations + INT_PTR DoModal(HWND hWndParent = ::GetActiveWindow()) + { + ATLASSERT((m_psd.Flags & PSD_ENABLEPAGESETUPHOOK) != 0); + ATLASSERT((m_psd.Flags & PSD_ENABLEPAGEPAINTHOOK) != 0); + ATLASSERT(m_psd.lpfnPageSetupHook != NULL); // can still be a user hook + ATLASSERT(m_psd.lpfnPagePaintHook != NULL); // can still be a user hook + + if(m_psd.hwndOwner == NULL) // set only if not specified before + m_psd.hwndOwner = hWndParent; + + ATLASSERT(m_hWnd == NULL); + + // Allocate the thunk structure here, where we can fail gracefully. + BOOL bRetTh = m_thunk.Init(NULL, NULL); + if(bRetTh == FALSE) + { + ::SetLastError(ERROR_OUTOFMEMORY); + return -1; + } + + ModuleHelper::AddCreateWndData(&m_thunk.cd, (CCommonDialogImplBase*)this); + + BOOL bRet = ::PageSetupDlg(&m_psd); + + m_hWnd = NULL; + + return bRet ? IDOK : IDCANCEL; + } + +// Implementation + static UINT_PTR CALLBACK PaintHookProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) + { + T* pT = (T*)hWnd; + UINT_PTR uRet = 0; + switch(uMsg) + { + case WM_PSD_PAGESETUPDLG: + uRet = pT->PreDrawPage(LOWORD(wParam), HIWORD(wParam), (LPPAGESETUPDLG)lParam); + break; + case WM_PSD_FULLPAGERECT: + case WM_PSD_MINMARGINRECT: + case WM_PSD_MARGINRECT: + case WM_PSD_GREEKTEXTRECT: + case WM_PSD_ENVSTAMPRECT: + case WM_PSD_YAFULLPAGERECT: + uRet = pT->OnDrawPage(uMsg, (HDC)wParam, (LPRECT)lParam); + break; + default: + ATLTRACE2(atlTraceUI, 0, _T("CPageSetupDialogImpl::PaintHookProc - unknown message received\n")); + break; + } + return uRet; + } + +// Overridables + UINT_PTR PreDrawPage(WORD /*wPaper*/, WORD /*wFlags*/, LPPAGESETUPDLG /*pPSD*/) + { + // return 1 to prevent any more drawing + return 0; + } + + UINT_PTR OnDrawPage(UINT /*uMsg*/, HDC /*hDC*/, LPRECT /*lpRect*/) + { + return 0; // do the default + } +}; + +class CPageSetupDialog : public CPageSetupDialogImpl +{ +public: + CPageSetupDialog(DWORD dwFlags = PSD_MARGINS | PSD_INWININIINTLMEASURE, HWND hWndParent = NULL) + : CPageSetupDialogImpl(dwFlags, hWndParent) + { } + + // override PaintHookProc and references to handlers + static UINT_PTR CALLBACK PaintHookProc(HWND, UINT, WPARAM, LPARAM) + { + return 0; + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CFindReplaceDialogImpl - Find/FindReplace modeless dialogs + +template +class ATL_NO_VTABLE CFindReplaceDialogImpl : public CCommonDialogImplBase +{ +public: + enum { _cchFindReplaceBuffer = 128 }; + + FINDREPLACE m_fr; + TCHAR m_szFindWhat[_cchFindReplaceBuffer]; + TCHAR m_szReplaceWith[_cchFindReplaceBuffer]; + +// Constructors + CFindReplaceDialogImpl() + { + memset(&m_fr, 0, sizeof(m_fr)); + m_szFindWhat[0] = _T('\0'); + m_szReplaceWith[0] = _T('\0'); + + m_fr.lStructSize = sizeof(m_fr); + m_fr.Flags = FR_ENABLEHOOK; + m_fr.lpfnHook = (LPFRHOOKPROC)T::HookProc; + m_fr.lpstrFindWhat = (LPTSTR)m_szFindWhat; + m_fr.wFindWhatLen = _cchFindReplaceBuffer; + m_fr.lpstrReplaceWith = (LPTSTR)m_szReplaceWith; + m_fr.wReplaceWithLen = _cchFindReplaceBuffer; + } + + // Note: You must allocate the object on the heap. + // If you do not, you must override OnFinalMessage() + virtual void OnFinalMessage(HWND /*hWnd*/) + { + delete this; + } + + HWND Create(BOOL bFindDialogOnly, // TRUE for Find, FALSE for FindReplace + LPCTSTR lpszFindWhat, + LPCTSTR lpszReplaceWith = NULL, + DWORD dwFlags = FR_DOWN, + HWND hWndParent = NULL) + { + ATLASSERT((m_fr.Flags & FR_ENABLEHOOK) != 0); + ATLASSERT(m_fr.lpfnHook != NULL); + + m_fr.Flags |= dwFlags; + + if(hWndParent == NULL) + m_fr.hwndOwner = ::GetActiveWindow(); + else + m_fr.hwndOwner = hWndParent; + ATLASSERT(m_fr.hwndOwner != NULL); // must have an owner for modeless dialog + + if(lpszFindWhat != NULL) + ATL::Checked::tcsncpy_s(m_szFindWhat, _countof(m_szFindWhat), lpszFindWhat, _TRUNCATE); + + if(lpszReplaceWith != NULL) + ATL::Checked::tcsncpy_s(m_szReplaceWith, _countof(m_szReplaceWith), lpszReplaceWith, _TRUNCATE); + + ATLASSERT(m_hWnd == NULL); + + // Allocate the thunk structure here, where we can fail gracefully. + BOOL bRet = m_thunk.Init(NULL, NULL); + if(bRet == FALSE) + { + ::SetLastError(ERROR_OUTOFMEMORY); + return NULL; + } + + ModuleHelper::AddCreateWndData(&m_thunk.cd, (CCommonDialogImplBase*)this); + + HWND hWnd = NULL; + if(bFindDialogOnly) + hWnd = ::FindText(&m_fr); + else + hWnd = ::ReplaceText(&m_fr); + + ATLASSERT(m_hWnd == hWnd); + return hWnd; + } + + static UINT GetFindReplaceMsg() + { + static const UINT nMsgFindReplace = ::RegisterWindowMessage(FINDMSGSTRING); + return nMsgFindReplace; + } + // call while handling FINDMSGSTRING registered message + // to retreive the object + static T* PASCAL GetNotifier(LPARAM lParam) + { + ATLASSERT(lParam != NULL); + T* pDlg = (T*)(lParam - offsetof(T, m_fr)); + return pDlg; + } + +// Operations + // Helpers for parsing information after successful return + LPCTSTR GetFindString() const // get find string + { + return (LPCTSTR)m_fr.lpstrFindWhat; + } + + LPCTSTR GetReplaceString() const // get replacement string + { + return (LPCTSTR)m_fr.lpstrReplaceWith; + } + + BOOL SearchDown() const // TRUE if search down, FALSE is up + { + return ((m_fr.Flags & FR_DOWN) != 0) ? TRUE : FALSE; + } + + BOOL FindNext() const // TRUE if command is find next + { + return ((m_fr.Flags & FR_FINDNEXT) != 0) ? TRUE : FALSE; + } + + BOOL MatchCase() const // TRUE if matching case + { + return ((m_fr.Flags & FR_MATCHCASE) != 0) ? TRUE : FALSE; + } + + BOOL MatchWholeWord() const // TRUE if matching whole words only + { + return ((m_fr.Flags & FR_WHOLEWORD) != 0) ? TRUE : FALSE; + } + + BOOL ReplaceCurrent() const // TRUE if replacing current string + { + return ((m_fr. Flags & FR_REPLACE) != 0) ? TRUE : FALSE; + } + + BOOL ReplaceAll() const // TRUE if replacing all occurrences + { + return ((m_fr.Flags & FR_REPLACEALL) != 0) ? TRUE : FALSE; + } + + BOOL IsTerminating() const // TRUE if terminating dialog + { + return ((m_fr.Flags & FR_DIALOGTERM) != 0) ? TRUE : FALSE ; + } +}; + +class CFindReplaceDialog : public CFindReplaceDialogImpl +{ +public: + DECLARE_EMPTY_MSG_MAP() +}; + + +///////////////////////////////////////////////////////////////////////// +// CDialogBaseUnits - Dialog Units helper +// + +class CDialogBaseUnits +{ +public: + SIZE m_sizeUnits; + +// Constructors + CDialogBaseUnits() + { + // The base units of the out-dated System Font + LONG nDlgBaseUnits = ::GetDialogBaseUnits(); + m_sizeUnits.cx = LOWORD(nDlgBaseUnits); + m_sizeUnits.cy = HIWORD(nDlgBaseUnits); + } + + CDialogBaseUnits(HWND hWnd) + { + if(!InitDialogBaseUnits(hWnd)) { + LONG nDlgBaseUnits = ::GetDialogBaseUnits(); + m_sizeUnits.cx = LOWORD(nDlgBaseUnits); + m_sizeUnits.cy = HIWORD(nDlgBaseUnits); + } + } + + CDialogBaseUnits(HFONT hFont, HWND hWnd = NULL) + { + if(!InitDialogBaseUnits(hFont, hWnd)) { + LONG nDlgBaseUnits = ::GetDialogBaseUnits(); + m_sizeUnits.cx = LOWORD(nDlgBaseUnits); + m_sizeUnits.cy = HIWORD(nDlgBaseUnits); + } + } + + CDialogBaseUnits(const LOGFONT& lf, HWND hWnd = NULL) + { + if(!InitDialogBaseUnits(lf, hWnd)) { + LONG nDlgBaseUnits = ::GetDialogBaseUnits(); + m_sizeUnits.cx = LOWORD(nDlgBaseUnits); + m_sizeUnits.cy = HIWORD(nDlgBaseUnits); + } + } + +// Operations + BOOL InitDialogBaseUnits(HWND hWnd) + { + ATLASSERT(::IsWindow(hWnd)); + RECT rc = { 0, 0, 4, 8 }; + if(!::MapDialogRect(hWnd, &rc)) return FALSE; + m_sizeUnits.cx = rc.right; + m_sizeUnits.cy = rc.bottom; + return TRUE; + } + + BOOL InitDialogBaseUnits(const LOGFONT& lf, HWND hWnd = NULL) + { + CFont font; + font.CreateFontIndirect(&lf); + if(font.IsNull()) return FALSE; + return InitDialogBaseUnits(font, hWnd); + } + + BOOL InitDialogBaseUnits(HFONT hFont, HWND hWnd = NULL) + { + ATLASSERT(hFont != NULL); + CWindowDC dc = hWnd; + TEXTMETRIC tmText = {}; + SIZE sizeText = {}; + HFONT hFontOld = dc.SelectFont(hFont); + dc.GetTextMetrics(&tmText); + m_sizeUnits.cy = tmText.tmHeight + tmText.tmExternalLeading; + dc.GetTextExtent(_T("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"), 52, &sizeText); + m_sizeUnits.cx = (sizeText.cx + 26) / 52; + dc.SelectFont(hFontOld); + return TRUE; + } + + SIZE GetDialogBaseUnits() const + { + return m_sizeUnits; + } + + INT MapDialogPixelsX(INT x) const + { + return ::MulDiv(x, 4, m_sizeUnits.cx); // Pixels X to DLU + } + + INT MapDialogPixelsY(INT y) const + { + return ::MulDiv(y, 8, m_sizeUnits.cy); // Pixels Y to DLU + } + + POINT MapDialogPixels(POINT pt) const + { + POINT out = { MapDialogPixelsX(pt.x), MapDialogPixelsY(pt.y) }; + return out; + } + + SIZE MapDialogPixels(SIZE input) const + { + SIZE out = { MapDialogPixelsX(input.cx), MapDialogPixelsY(input.cy) }; + return out; + } + + RECT MapDialogPixels(const RECT& input) const + { + RECT out = { MapDialogPixelsX(input.left), MapDialogPixelsY(input.top), MapDialogPixelsX(input.right), MapDialogPixelsY(input.bottom) }; + return out; + } + + INT MapDialogUnitsX(INT x) const + { + return ::MulDiv(x, m_sizeUnits.cx, 4); // DLU to Pixels X + } + + INT MapDialogUnitsY(INT y) const + { + return ::MulDiv(y, m_sizeUnits.cy, 8); // DLU to Pixels Y + } + + POINT MapDialogUnits(POINT pt) const + { + POINT out = { MapDialogUnitsX(pt.x), MapDialogUnitsY(pt.y) }; + return out; + } + + SIZE MapDialogUnits(SIZE input) const + { + SIZE out = { MapDialogUnitsX(input.cx), MapDialogUnitsY(input.cy) }; + return out; + } + + RECT MapDialogUnits(const RECT& input) const + { + RECT out = { MapDialogUnitsX(input.left), MapDialogUnitsY(input.top), MapDialogUnitsX(input.right), MapDialogUnitsY(input.bottom) }; + return out; + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CMemDlgTemplate - in-memory dialog template - DLGTEMPLATE or DLGTEMPLATEEX + +// traits suitable for dialog controls +typedef ATL::CWinTraits CDlgControlWinTraits; + +template +class CMemDlgTemplateT +{ +public: + typedef ATL::_DialogSplitHelper::DLGTEMPLATEEX DLGTEMPLATEEX; + typedef ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX DLGITEMTEMPLATEEX; + + enum StdCtrlType + { + CTRL_BUTTON = 0x0080, + CTRL_EDIT = 0x0081, + CTRL_STATIC = 0x0082, + CTRL_LISTBOX = 0x0083, + CTRL_SCROLLBAR = 0x0084, + CTRL_COMBOBOX = 0x0085 + }; + + HANDLE m_hData; + LPBYTE m_pData; + LPBYTE m_pPtr; + SIZE_T m_cAllocated; + + CMemDlgTemplateT() : m_hData(NULL), m_pData(NULL), m_pPtr(NULL), m_cAllocated(0) + { } + + ~CMemDlgTemplateT() + { + Reset(); + } + + bool IsValid() const + { + return (m_pData != NULL); + } + + bool IsTemplateEx() const + { + return (IsValid() && ((DLGTEMPLATEEX*)m_pData)->signature == 0xFFFF); + } + + LPDLGTEMPLATE GetTemplatePtr() + { + return reinterpret_cast(m_pData); + } + + DLGTEMPLATEEX* GetTemplateExPtr() + { + return reinterpret_cast(m_pData); + } + + void Reset() + { + if (IsValid()) + { + ::GlobalUnlock(m_pData); + ATLVERIFY(::GlobalFree(m_hData) == NULL); + } + + m_hData = NULL; + m_pData = NULL; + m_pPtr = NULL; + m_cAllocated = 0; + } + + void Create(bool bDlgEx, LPCTSTR lpszCaption, const RECT& rc, DWORD dwStyle = 0, DWORD dwExStyle = 0, + LPCTSTR lpstrFontName = NULL, WORD wFontSize = 0, WORD wWeight = 0, BYTE bItalic = 0, BYTE bCharset = 0, DWORD dwHelpID = 0, + ATL::_U_STRINGorID ClassName = 0U, ATL::_U_STRINGorID Menu = 0U) + { + Create(bDlgEx, lpszCaption, (short) rc.left, (short) rc.top, (short) (rc.right - rc.left), (short) (rc.bottom - rc.top), dwStyle, dwExStyle, + lpstrFontName, wFontSize, wWeight, bItalic, bCharset, dwHelpID, ClassName.m_lpstr, Menu.m_lpstr); + } + + void Create(bool bDlgEx, LPCTSTR lpszCaption, short nX, short nY, short nWidth, short nHeight, DWORD dwStyle = 0, DWORD dwExStyle = 0, + LPCTSTR lpstrFontName = NULL, WORD wFontSize = 0, WORD wWeight = 0, BYTE bItalic = 0, BYTE bCharset = 0, DWORD dwHelpID = 0, + ATL::_U_STRINGorID ClassName = 0U, ATL::_U_STRINGorID Menu = 0U) + { + // Should have DS_SETFONT style to set the dialog font name and size + if (lpstrFontName != NULL) + { + dwStyle |= DS_SETFONT; + } + else + { + dwStyle &= ~DS_SETFONT; + } + + if (bDlgEx) + { + DLGTEMPLATEEX dlg = {1, 0xFFFF, dwHelpID, dwExStyle, dwStyle, 0, nX, nY, nWidth, nHeight}; + AddData(&dlg, sizeof(dlg)); + } + else + { + DLGTEMPLATE dlg = {dwStyle, dwExStyle, 0, nX, nY, nWidth, nHeight}; + AddData(&dlg, sizeof(dlg)); + } + + if (Menu.m_lpstr == NULL) + { + WORD menuData = 0; + AddData(&menuData, sizeof(WORD)); + } + else if (IS_INTRESOURCE(Menu.m_lpstr)) + { + WORD menuData[] = { 0xFFFF, LOWORD(Menu.m_lpstr) }; + AddData(menuData, sizeof(menuData)); + } + else + { + AddString(Menu.m_lpstr); + } + + if (ClassName.m_lpstr == NULL) + { + WORD classData = 0; + AddData(&classData, sizeof(WORD)); + } + else if (IS_INTRESOURCE(ClassName.m_lpstr)) + { + WORD classData[] = { 0xFFFF, LOWORD(ClassName.m_lpstr) }; + AddData(classData, sizeof(classData)); + } + else + { + AddString(ClassName.m_lpstr); + } + + // Set dialog caption + AddString(lpszCaption); + + if (lpstrFontName != NULL) + { + AddData(&wFontSize, sizeof(wFontSize)); + + if (bDlgEx) + { + AddData(&wWeight, sizeof(wWeight)); + AddData(&bItalic, sizeof(bItalic)); + AddData(&bCharset, sizeof(bCharset)); + } + + AddString(lpstrFontName); + } + } + + void AddControl(ATL::_U_STRINGorID ClassName, WORD wId, const RECT& rc, DWORD dwStyle, DWORD dwExStyle, + ATL::_U_STRINGorID Text, const WORD* pCreationData = NULL, WORD nCreationData = 0, DWORD dwHelpID = 0) + { + AddControl(ClassName.m_lpstr, wId, (short) rc.left, (short) rc.top, (short) (rc.right - rc.left), (short) (rc.bottom - rc.top), dwStyle, dwExStyle, + Text.m_lpstr, pCreationData, nCreationData, dwHelpID); + } + + void AddControl(ATL::_U_STRINGorID ClassName, WORD wId, short nX, short nY, short nWidth, short nHeight, DWORD dwStyle, DWORD dwExStyle, + ATL::_U_STRINGorID Text, const WORD* pCreationData = NULL, WORD nCreationData = 0, DWORD dwHelpID = 0) + { + ATLASSERT(IsValid()); + + // DWORD align data + const DWORD_PTR dwDwordAlignBits = sizeof(DWORD) - 1; + m_pPtr = (LPBYTE)(((DWORD_PTR)m_pPtr + dwDwordAlignBits) & (~dwDwordAlignBits)); + + if (IsTemplateEx()) + { + DLGTEMPLATEEX* dlg = (DLGTEMPLATEEX*)m_pData; + dlg->cDlgItems++; + + DLGITEMTEMPLATEEX item = {dwHelpID, TWinTraits::GetWndExStyle(0) | dwExStyle, TWinTraits::GetWndStyle(0) | dwStyle, nX, nY, nWidth, nHeight, wId}; + AddData(&item, sizeof(item)); + } + else + { + LPDLGTEMPLATE dlg = (LPDLGTEMPLATE)m_pData; + dlg->cdit++; + + DLGITEMTEMPLATE item = {TWinTraits::GetWndStyle(0) | dwStyle, TWinTraits::GetWndExStyle(0) | dwExStyle, nX, nY, nWidth, nHeight, wId}; + AddData(&item, sizeof(item)); + } + + ATLASSERT(ClassName.m_lpstr != NULL); + if (IS_INTRESOURCE(ClassName.m_lpstr)) + { + WORD wData[] = { 0xFFFF, LOWORD(ClassName.m_lpstr) }; + AddData(wData, sizeof(wData)); + } + else + { + AddString(ClassName.m_lpstr); + } + + if (Text.m_lpstr == NULL) + { + WORD classData = 0; + AddData(&classData, sizeof(WORD)); + } + else if (IS_INTRESOURCE(Text.m_lpstr)) + { + WORD wData[] = { 0xFFFF, LOWORD(Text.m_lpstr) }; + AddData(wData, sizeof(wData)); + } + else + { + AddString(Text.m_lpstr); + } + + AddData(&nCreationData, sizeof(nCreationData)); + + if ((nCreationData != 0)) + { + ATLASSERT(pCreationData != NULL); + AddData(pCreationData, nCreationData * sizeof(WORD)); + } + } + + void AddStdControl(StdCtrlType CtrlType, WORD wId, short nX, short nY, short nWidth, short nHeight, + DWORD dwStyle, DWORD dwExStyle, ATL::_U_STRINGorID Text, const WORD* pCreationData = NULL, WORD nCreationData = 0, DWORD dwHelpID = 0) + { + AddControl(CtrlType, wId, nX, nY, nWidth, nHeight, dwStyle, dwExStyle, Text, pCreationData, nCreationData, dwHelpID); + } + + void AddData(LPCVOID pData, size_t nData) + { + ATLASSERT(pData != NULL); + + const SIZE_T ALLOCATION_INCREMENT = 1024; + + if (m_pData == NULL) + { + m_cAllocated = ((nData / ALLOCATION_INCREMENT) + 1) * ALLOCATION_INCREMENT; + m_hData = ::GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, m_cAllocated); + ATLASSERT(m_hData != NULL); + m_pPtr = m_pData = static_cast(::GlobalLock(m_hData)); + ATLASSERT(m_pData != NULL); + } + else if (((m_pPtr - m_pData) + nData) > m_cAllocated) + { + SIZE_T ptrPos = (m_pPtr - m_pData); + m_cAllocated += ((nData / ALLOCATION_INCREMENT) + 1) * ALLOCATION_INCREMENT; + ::GlobalUnlock(m_pData); + m_hData = ::GlobalReAlloc(m_hData, m_cAllocated, GMEM_MOVEABLE | GMEM_ZEROINIT); + ATLASSERT(m_hData != NULL); + m_pData = static_cast(::GlobalLock(m_hData)); + ATLASSERT(m_pData != NULL); + m_pPtr = m_pData + ptrPos; + } + + ATL::Checked::memcpy_s(m_pPtr, m_cAllocated - (m_pPtr - m_pData), pData, nData); + + m_pPtr += nData; + } + + void AddString(LPCTSTR lpszStr) + { + if (lpszStr == NULL) + { + WCHAR szEmpty = 0; + AddData(&szEmpty, sizeof(szEmpty)); + } + else + { + USES_CONVERSION; + LPCWSTR lpstr = T2CW(lpszStr); + int nSize = lstrlenW(lpstr) + 1; + AddData(lpstr, nSize * sizeof(WCHAR)); + } + } +}; + +typedef CMemDlgTemplateT CMemDlgTemplate; + + +/////////////////////////////////////////////////////////////////////////////// +// Dialog and control macros for indirect dialogs + +// for DLGTEMPLATE +#define BEGIN_DIALOG(x, y, width, height) \ + void DoInitTemplate() \ + { \ + bool bExTemplate = false; \ + short nX = x, nY = y, nWidth = width, nHeight = height; \ + LPCTSTR szCaption = NULL; \ + DWORD dwStyle = WS_POPUP | WS_BORDER | WS_SYSMENU; \ + DWORD dwExStyle = 0; \ + LPCTSTR szFontName = NULL; \ + WORD wFontSize = 0; \ + WORD wWeight = 0; \ + BYTE bItalic = 0; \ + BYTE bCharset = 0; \ + DWORD dwHelpID = 0; \ + ATL::_U_STRINGorID Menu = 0U; \ + ATL::_U_STRINGorID ClassName = 0U; + +// for DLGTEMPLATEEX +#define BEGIN_DIALOG_EX(x, y, width, height, helpID) \ + void DoInitTemplate() \ + { \ + bool bExTemplate = true; \ + short nX = x, nY = y, nWidth = width, nHeight = height; \ + LPCTSTR szCaption = NULL; \ + DWORD dwStyle = WS_POPUP | WS_BORDER | WS_SYSMENU; \ + DWORD dwExStyle = 0; \ + LPCTSTR szFontName = NULL; \ + WORD wFontSize = 0; \ + WORD wWeight = 0; \ + BYTE bItalic = 0; \ + BYTE bCharset = 0; \ + DWORD dwHelpID = helpID; \ + ATL::_U_STRINGorID Menu = 0U; \ + ATL::_U_STRINGorID ClassName = 0U; + +#define END_DIALOG() \ + m_Template.Create(bExTemplate, szCaption, nX, nY, nWidth, nHeight, dwStyle, dwExStyle, szFontName, wFontSize, wWeight, bItalic, bCharset, dwHelpID, ClassName, Menu); \ + } + +#define DIALOG_CAPTION(caption) \ + szCaption = caption; +#define DIALOG_STYLE(style) \ + dwStyle = style; +#define DIALOG_EXSTYLE(exStyle) \ + dwExStyle = exStyle; +#define DIALOG_FONT(pointSize, typeFace) \ + wFontSize = pointSize; \ + szFontName = typeFace; +#define DIALOG_FONT_EX(pointsize, typeface, weight, italic, charset) \ + ATLASSERT(bExTemplate); \ + wFontSize = pointsize; \ + szFontName = typeface; \ + wWeight = weight; \ + bItalic = italic; \ + bCharset = charset; +#define DIALOG_MENU(menuName) \ + Menu = menuName; +#define DIALOG_CLASS(className) \ + ClassName = className; + +#define BEGIN_CONTROLS_MAP() \ + void DoInitControls() \ + { + +#define END_CONTROLS_MAP() \ + } + + +#define CONTROL_LTEXT(text, id, x, y, width, height, style, exStyle) \ + m_Template.AddStdControl(m_Template.CTRL_STATIC, (WORD)id, x, y, width, height, style | SS_LEFT | WS_GROUP, exStyle, text, NULL, 0); +#define CONTROL_CTEXT(text, id, x, y, width, height, style, exStyle) \ + m_Template.AddStdControl(m_Template.CTRL_STATIC, (WORD)id, x, y, width, height, style | SS_CENTER | WS_GROUP, exStyle, text, NULL, 0); +#define CONTROL_RTEXT(text, id, x, y, width, height, style, exStyle) \ + m_Template.AddStdControl(m_Template.CTRL_STATIC, (WORD)id, x, y, width, height, style | SS_RIGHT | WS_GROUP, exStyle, text, NULL, 0); +#define CONTROL_PUSHBUTTON(text, id, x, y, width, height, style, exStyle) \ + m_Template.AddStdControl(m_Template.CTRL_BUTTON, (WORD)id, x, y, width, height, style | BS_PUSHBUTTON | WS_TABSTOP, exStyle, text, NULL, 0); +#define CONTROL_DEFPUSHBUTTON(text, id, x, y, width, height, style, exStyle) \ + m_Template.AddStdControl(m_Template.CTRL_BUTTON, (WORD)id, x, y, width, height, style | BS_DEFPUSHBUTTON | WS_TABSTOP, exStyle, text, NULL, 0); +#define CONTROL_PUSHBOX(text, id, x, y, width, height, style, exStyle) \ + m_Template.AddStdControl(m_Template.CTRL_BUTTON, (WORD)id, x, y, width, height, style | BS_PUSHBOX | WS_TABSTOP, exStyle, text, NULL, 0); +#define CONTROL_STATE3(text, id, x, y, width, height, style, exStyle) \ + m_Template.AddStdControl(m_Template.CTRL_BUTTON, (WORD)id, x, y, width, height, style | BS_3STATE | WS_TABSTOP, exStyle, text, NULL, 0); +#define CONTROL_AUTO3STATE(text, id, x, y, width, height, style, exStyle) \ + m_Template.AddStdControl(m_Template.CTRL_BUTTON, (WORD)id, x, y, width, height, style | BS_AUTO3STATE | WS_TABSTOP, exStyle, text, NULL, 0); +#define CONTROL_CHECKBOX(text, id, x, y, width, height, style, exStyle) \ + m_Template.AddStdControl(m_Template.CTRL_BUTTON, (WORD)id, x, y, width, height, style | BS_CHECKBOX | WS_TABSTOP, exStyle, text, NULL, 0); +#define CONTROL_AUTOCHECKBOX(text, id, x, y, width, height, style, exStyle) \ + m_Template.AddStdControl(m_Template.CTRL_BUTTON, (WORD)id, x, y, width, height, style | BS_AUTOCHECKBOX | WS_TABSTOP, exStyle, text, NULL, 0); +#define CONTROL_RADIOBUTTON(text, id, x, y, width, height, style, exStyle) \ + m_Template.AddStdControl(m_Template.CTRL_BUTTON, (WORD)id, x, y, width, height, style | BS_RADIOBUTTON | WS_TABSTOP, exStyle, text, NULL, 0); +#define CONTROL_AUTORADIOBUTTON(text, id, x, y, width, height, style, exStyle) \ + m_Template.AddStdControl(m_Template.CTRL_BUTTON, (WORD)id, x, y, width, height, style | BS_AUTORADIOBUTTON | WS_TABSTOP, exStyle, text, NULL, 0); +#define CONTROL_COMBOBOX(id, x, y, width, height, style, exStyle) \ + m_Template.AddStdControl(m_Template.CTRL_COMBOBOX, (WORD)id, x, y, width, height, style | CBS_DROPDOWN | WS_TABSTOP, exStyle, (LPCTSTR)NULL, NULL, 0); +#define CONTROL_EDITTEXT(id, x, y, width, height, style, exStyle) \ + m_Template.AddStdControl(m_Template.CTRL_EDIT, (WORD)id, x, y, width, height, style | ES_LEFT | WS_BORDER | WS_TABSTOP, exStyle, (LPCTSTR)NULL, NULL, 0); +#define CONTROL_GROUPBOX(text, id, x, y, width, height, style, exStyle) \ + m_Template.AddStdControl(m_Template.CTRL_BUTTON, (WORD)id, x, y, width, height, style | BS_GROUPBOX, exStyle, text, NULL, 0); +#define CONTROL_LISTBOX(id, x, y, width, height, style, exStyle) \ + m_Template.AddStdControl(m_Template.CTRL_LISTBOX, (WORD)id, x, y, width, height, style | LBS_NOTIFY | WS_BORDER, exStyle, (LPCTSTR)NULL, NULL, 0); +#define CONTROL_SCROLLBAR(id, x, y, width, height, style, exStyle) \ + m_Template.AddStdControl(m_Template.CTRL_SCROLLBAR, (WORD)id, x, y, width, height, style | SBS_HORZ, exStyle, (LPCTSTR)NULL, NULL, 0); +#define CONTROL_ICON(text, id, x, y, width, height, style, exStyle) \ + m_Template.AddStdControl(m_Template.CTRL_STATIC, (WORD)id, x, y, width, height, style | SS_ICON, exStyle, text, NULL, 0); +#define CONTROL_CONTROL(text, id, className, style, x, y, width, height, exStyle) \ + m_Template.AddControl(className, (WORD)id, x, y, width, height, style, exStyle, text, NULL, 0); + + +/////////////////////////////////////////////////////////////////////////////// +// CIndirectDialogImpl - dialogs with template in memory + +template +class ATL_NO_VTABLE CIndirectDialogImpl : public ATL::CDialogImpl< T, TBase > +{ +public: + enum { IDD = 0 }; // no dialog template resource + + TDlgTemplate m_Template; + + void CreateTemplate() + { + T* pT = static_cast(this); + pT->DoInitTemplate(); + pT->DoInitControls(); + } + + INT_PTR DoModal(HWND hWndParent = ::GetActiveWindow(), LPARAM dwInitParam = NULL) + { + T* pT = static_cast(this); + ATLASSERT(pT->m_hWnd == NULL); + + if(!m_Template.IsValid()) + CreateTemplate(); + + // Allocate the thunk structure here, where we can fail gracefully. + BOOL bRet = this->m_thunk.Init(NULL, NULL); + if(bRet == FALSE) + { + ::SetLastError(ERROR_OUTOFMEMORY); + return -1; + } + + ModuleHelper::AddCreateWndData(&this->m_thunk.cd, (ATL::CDialogImplBaseT< TBase >*)pT); + +#ifdef _DEBUG + this->m_bModal = true; +#endif // _DEBUG + + return ::DialogBoxIndirectParam(ModuleHelper::GetResourceInstance(), m_Template.GetTemplatePtr(), hWndParent, (DLGPROC)T::StartDialogProc, dwInitParam); + } + + HWND Create(HWND hWndParent, LPARAM dwInitParam = NULL) + { + T* pT = static_cast(this); + ATLASSERT(pT->m_hWnd == NULL); + + if(!m_Template.IsValid()) + CreateTemplate(); + + // Allocate the thunk structure here, where we can fail gracefully. + BOOL bRet = this->m_thunk.Init(NULL, NULL); + if(bRet == FALSE) + { + ::SetLastError(ERROR_OUTOFMEMORY); + return NULL; + } + + ModuleHelper::AddCreateWndData(&this->m_thunk.cd, (ATL::CDialogImplBaseT< TBase >*)pT); + +#ifdef _DEBUG + this->m_bModal = false; +#endif // _DEBUG + + HWND hWnd = ::CreateDialogIndirectParam(ModuleHelper::GetResourceInstance(), (LPCDLGTEMPLATE)m_Template.GetTemplatePtr(), hWndParent, (DLGPROC)T::StartDialogProc, dwInitParam); + ATLASSERT(this->m_hWnd == hWnd); + + return hWnd; + } + + // for CComControl + HWND Create(HWND hWndParent, RECT&, LPARAM dwInitParam = NULL) + { + return Create(hWndParent, dwInitParam); + } + + void DoInitTemplate() + { + ATLASSERT(FALSE); // MUST be defined in derived class + } + + void DoInitControls() + { + ATLASSERT(FALSE); // MUST be defined in derived class + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CPropertySheetWindow - client side for a property sheet + +class CPropertySheetWindow : public ATL::CWindow +{ +public: +// Constructors + CPropertySheetWindow(HWND hWnd = NULL) : ATL::CWindow(hWnd) + { } + + CPropertySheetWindow& operator =(HWND hWnd) + { + m_hWnd = hWnd; + return *this; + } + +// Attributes + int GetPageCount() const + { + ATLASSERT(::IsWindow(m_hWnd)); + HWND hWndTabCtrl = GetTabControl(); + ATLASSERT(hWndTabCtrl != NULL); + return (int)::SendMessage(hWndTabCtrl, TCM_GETITEMCOUNT, 0, 0L); + } + + HWND GetActivePage() const + { + ATLASSERT(::IsWindow(m_hWnd)); + return (HWND)::SendMessage(m_hWnd, PSM_GETCURRENTPAGEHWND, 0, 0L); + } + + int GetActiveIndex() const + { + ATLASSERT(::IsWindow(m_hWnd)); + HWND hWndTabCtrl = GetTabControl(); + ATLASSERT(hWndTabCtrl != NULL); + return (int)::SendMessage(hWndTabCtrl, TCM_GETCURSEL, 0, 0L); + } + + BOOL SetActivePage(int nPageIndex) + { + ATLASSERT(::IsWindow(m_hWnd)); + return (BOOL)::SendMessage(m_hWnd, PSM_SETCURSEL, nPageIndex, 0L); + } + + BOOL SetActivePage(HPROPSHEETPAGE hPage) + { + ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(hPage != NULL); + return (BOOL)::SendMessage(m_hWnd, PSM_SETCURSEL, 0, (LPARAM)hPage); + } + + BOOL SetActivePageByID(int nPageID) + { + ATLASSERT(::IsWindow(m_hWnd)); + return (BOOL)::SendMessage(m_hWnd, PSM_SETCURSELID, 0, nPageID); + } + + void SetTitle(LPCTSTR lpszText, UINT nStyle = 0) + { + ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT((nStyle & ~PSH_PROPTITLE) == 0); // only PSH_PROPTITLE is valid + ATLASSERT(lpszText != NULL); + ::SendMessage(m_hWnd, PSM_SETTITLE, nStyle, (LPARAM)lpszText); + } + + HWND GetTabControl() const + { + ATLASSERT(::IsWindow(m_hWnd)); + return (HWND)::SendMessage(m_hWnd, PSM_GETTABCONTROL, 0, 0L); + } + + void SetFinishText(LPCTSTR lpszText) + { + ATLASSERT(::IsWindow(m_hWnd)); + ::SendMessage(m_hWnd, PSM_SETFINISHTEXT, 0, (LPARAM)lpszText); + } + + void SetWizardButtons(DWORD dwFlags) + { + ATLASSERT(::IsWindow(m_hWnd)); + ::PostMessage(m_hWnd, PSM_SETWIZBUTTONS, 0, dwFlags); + } + +// Operations + BOOL AddPage(HPROPSHEETPAGE hPage) + { + ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(hPage != NULL); + return (BOOL)::SendMessage(m_hWnd, PSM_ADDPAGE, 0, (LPARAM)hPage); + } + + BOOL AddPage(LPCPROPSHEETPAGE pPage) + { + ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(pPage != NULL); + HPROPSHEETPAGE hPage = ::CreatePropertySheetPage(pPage); + if(hPage == NULL) + return FALSE; + return (BOOL)::SendMessage(m_hWnd, PSM_ADDPAGE, 0, (LPARAM)hPage); + } + + BOOL InsertPage(int nNewPageIndex, HPROPSHEETPAGE hPage) + { + ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(hPage != NULL); + return (BOOL)::SendMessage(m_hWnd, PSM_INSERTPAGE, nNewPageIndex, (LPARAM)hPage); + } + + BOOL InsertPage(int nNewPageIndex, LPCPROPSHEETPAGE pPage) + { + ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(pPage != NULL); + HPROPSHEETPAGE hPage = ::CreatePropertySheetPage(pPage); + if(hPage == NULL) + return FALSE; + return (BOOL)::SendMessage(m_hWnd, PSM_INSERTPAGE, nNewPageIndex, (LPARAM)hPage); + } + + BOOL InsertPage(HPROPSHEETPAGE hPageInsertAfter, HPROPSHEETPAGE hPage) + { + ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(hPage != NULL); + return (BOOL)::SendMessage(m_hWnd, PSM_INSERTPAGE, (WPARAM)hPageInsertAfter, (LPARAM)hPage); + } + + BOOL InsertPage(HPROPSHEETPAGE hPageInsertAfter, LPCPROPSHEETPAGE pPage) + { + ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(pPage != NULL); + HPROPSHEETPAGE hPage = ::CreatePropertySheetPage(pPage); + if(hPage == NULL) + return FALSE; + return (BOOL)::SendMessage(m_hWnd, PSM_INSERTPAGE, (WPARAM)hPageInsertAfter, (LPARAM)hPage); + } + + void RemovePage(int nPageIndex) + { + ATLASSERT(::IsWindow(m_hWnd)); + ::SendMessage(m_hWnd, PSM_REMOVEPAGE, nPageIndex, 0L); + } + + void RemovePage(HPROPSHEETPAGE hPage) + { + ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(hPage != NULL); + ::SendMessage(m_hWnd, PSM_REMOVEPAGE, 0, (LPARAM)hPage); + } + + BOOL PressButton(int nButton) + { + ATLASSERT(::IsWindow(m_hWnd)); + return (BOOL)::SendMessage(m_hWnd, PSM_PRESSBUTTON, nButton, 0L); + } + + BOOL Apply() + { + ATLASSERT(::IsWindow(m_hWnd)); + return (BOOL)::SendMessage(m_hWnd, PSM_APPLY, 0, 0L); + } + + void CancelToClose() + { + ATLASSERT(::IsWindow(m_hWnd)); + ::SendMessage(m_hWnd, PSM_CANCELTOCLOSE, 0, 0L); + } + + void SetModified(HWND hWndPage, BOOL bChanged = TRUE) + { + ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(::IsWindow(hWndPage)); + UINT uMsg = bChanged ? PSM_CHANGED : PSM_UNCHANGED; + ::SendMessage(m_hWnd, uMsg, (WPARAM)hWndPage, 0L); + } + + LRESULT QuerySiblings(WPARAM wParam, LPARAM lParam) + { + ATLASSERT(::IsWindow(m_hWnd)); + return ::SendMessage(m_hWnd, PSM_QUERYSIBLINGS, wParam, lParam); + } + + void RebootSystem() + { + ATLASSERT(::IsWindow(m_hWnd)); + ::SendMessage(m_hWnd, PSM_REBOOTSYSTEM, 0, 0L); + } + + void RestartWindows() + { + ATLASSERT(::IsWindow(m_hWnd)); + ::SendMessage(m_hWnd, PSM_RESTARTWINDOWS, 0, 0L); + } + + BOOL IsDialogMessage(LPMSG lpMsg) + { + ATLASSERT(::IsWindow(m_hWnd)); + return (BOOL)::SendMessage(m_hWnd, PSM_ISDIALOGMESSAGE, 0, (LPARAM)lpMsg); + } + + int HwndToIndex(HWND hWnd) const + { + ATLASSERT(::IsWindow(m_hWnd)); + return (int)::SendMessage(m_hWnd, PSM_HWNDTOINDEX, (WPARAM)hWnd, 0L); + } + + HWND IndexToHwnd(int nIndex) const + { + ATLASSERT(::IsWindow(m_hWnd)); + return (HWND)::SendMessage(m_hWnd, PSM_INDEXTOHWND, nIndex, 0L); + } + + int PageToIndex(HPROPSHEETPAGE hPage) const + { + ATLASSERT(::IsWindow(m_hWnd)); + return (int)::SendMessage(m_hWnd, PSM_PAGETOINDEX, 0, (LPARAM)hPage); + } + + HPROPSHEETPAGE IndexToPage(int nIndex) const + { + ATLASSERT(::IsWindow(m_hWnd)); + return (HPROPSHEETPAGE)::SendMessage(m_hWnd, PSM_INDEXTOPAGE, nIndex, 0L); + } + + int IdToIndex(int nID) const + { + ATLASSERT(::IsWindow(m_hWnd)); + return (int)::SendMessage(m_hWnd, PSM_IDTOINDEX, 0, nID); + } + + int IndexToId(int nIndex) const + { + ATLASSERT(::IsWindow(m_hWnd)); + return (int)::SendMessage(m_hWnd, PSM_INDEXTOID, nIndex, 0L); + } + + int GetResult() const + { + ATLASSERT(::IsWindow(m_hWnd)); + return (int)::SendMessage(m_hWnd, PSM_GETRESULT, 0, 0L); + } + + BOOL RecalcPageSizes() + { + ATLASSERT(::IsWindow(m_hWnd)); + return (BOOL)::SendMessage(m_hWnd, PSM_RECALCPAGESIZES, 0, 0L); + } + + void SetHeaderTitle(int nIndex, LPCTSTR lpstrHeaderTitle) + { + ATLASSERT(::IsWindow(m_hWnd)); + ::SendMessage(m_hWnd, PSM_SETHEADERTITLE, nIndex, (LPARAM)lpstrHeaderTitle); + } + + void SetHeaderSubTitle(int nIndex, LPCTSTR lpstrHeaderSubTitle) + { + ATLASSERT(::IsWindow(m_hWnd)); + ::SendMessage(m_hWnd, PSM_SETHEADERSUBTITLE, nIndex, (LPARAM)lpstrHeaderSubTitle); + } + +// Implementation - override to prevent usage + HWND Create(LPCTSTR, HWND, ATL::_U_RECT = NULL, LPCTSTR = NULL, DWORD = 0, DWORD = 0, ATL::_U_MENUorID = 0U, LPVOID = NULL) + { + ATLASSERT(FALSE); + return NULL; + } +}; + +/////////////////////////////////////////////////////////////////////////////// +// CPropertySheetImpl - implements a property sheet + +template +class ATL_NO_VTABLE CPropertySheetImpl : public ATL::CWindowImplBaseT< TBase > +{ +public: + PROPSHEETHEADER m_psh; + ATL::CSimpleArray m_arrPages; + +// Construction/Destruction + CPropertySheetImpl(ATL::_U_STRINGorID title = (LPCTSTR)NULL, UINT uStartPage = 0, HWND hWndParent = NULL) + { + memset(&m_psh, 0, sizeof(PROPSHEETHEADER)); + m_psh.dwSize = sizeof(PROPSHEETHEADER); + m_psh.dwFlags = PSH_USECALLBACK; + m_psh.hInstance = ModuleHelper::GetResourceInstance(); + m_psh.phpage = NULL; // will be set later + m_psh.nPages = 0; // will be set later + m_psh.pszCaption = title.m_lpstr; + m_psh.nStartPage = uStartPage; + m_psh.hwndParent = hWndParent; // if NULL, will be set in DoModal/Create + m_psh.pfnCallback = T::PropSheetCallback; + } + + ~CPropertySheetImpl() + { + if(m_arrPages.GetSize() > 0) // sheet never created, destroy all pages + { + for(int i = 0; i < m_arrPages.GetSize(); i++) + ::DestroyPropertySheetPage((HPROPSHEETPAGE)m_arrPages[i]); + } + } + +// Callback function and overrideables + static int CALLBACK PropSheetCallback(HWND hWnd, UINT uMsg, LPARAM lParam) + { + (void)lParam; // avoid level 4 warning + int nRet = 0; + + if(uMsg == PSCB_INITIALIZED) + { + ATLASSERT(hWnd != NULL); + T* pT = (T*)ModuleHelper::ExtractCreateWndData(); + // subclass the sheet window + pT->SubclassWindow(hWnd); + // remove page handles array + pT->_CleanUpPages(); + + pT->OnSheetInitialized(); + } + + return nRet; + } + + void OnSheetInitialized() + { + } + +// Create method + HWND Create(HWND hWndParent = NULL) + { + ATLASSERT(this->m_hWnd == NULL); + + m_psh.dwFlags |= PSH_MODELESS; + if(m_psh.hwndParent == NULL) + m_psh.hwndParent = hWndParent; + m_psh.phpage = (HPROPSHEETPAGE*)m_arrPages.GetData(); + m_psh.nPages = m_arrPages.GetSize(); + + T* pT = static_cast(this); + + // Allocate the thunk structure here, where we can fail gracefully. + BOOL bRet = pT->m_thunk.Init(NULL, NULL); + if(bRet == FALSE) + { + ::SetLastError(ERROR_OUTOFMEMORY); + return NULL; + } + + ModuleHelper::AddCreateWndData(&pT->m_thunk.cd, pT); + + HWND hWnd = (HWND)::PropertySheet(&m_psh); + _CleanUpPages(); // ensure clean-up, required if call failed + + ATLASSERT(this->m_hWnd == hWnd); + + return hWnd; + } + + INT_PTR DoModal(HWND hWndParent = ::GetActiveWindow()) + { + ATLASSERT(this->m_hWnd == NULL); + + m_psh.dwFlags &= ~PSH_MODELESS; + if(m_psh.hwndParent == NULL) + m_psh.hwndParent = hWndParent; + m_psh.phpage = (HPROPSHEETPAGE*)m_arrPages.GetData(); + m_psh.nPages = m_arrPages.GetSize(); + + T* pT = static_cast(this); + + // Allocate the thunk structure here, where we can fail gracefully. + BOOL bRet = pT->m_thunk.Init(NULL, NULL); + if(bRet == FALSE) + { + ::SetLastError(ERROR_OUTOFMEMORY); + return -1; + } + + ModuleHelper::AddCreateWndData(&pT->m_thunk.cd, pT); + + INT_PTR nRet = ::PropertySheet(&m_psh); + _CleanUpPages(); // ensure clean-up, required if call failed + + return nRet; + } + + // implementation helper - clean up pages array + void _CleanUpPages() + { + m_psh.nPages = 0; + m_psh.phpage = NULL; + m_arrPages.RemoveAll(); + } + +// Attributes (extended overrides of client class methods) +// These now can be called before the sheet is created +// Note: Calling these after the sheet is created gives unpredictable results + int GetPageCount() const + { + if(this->m_hWnd == NULL) // not created yet + return m_arrPages.GetSize(); + return TBase::GetPageCount(); + } + + int GetActiveIndex() const + { + if(this->m_hWnd == NULL) // not created yet + return m_psh.nStartPage; + return TBase::GetActiveIndex(); + } + + HPROPSHEETPAGE GetPage(int nPageIndex) const + { + ATLASSERT(this->m_hWnd == NULL); // can't do this after it's created + return (HPROPSHEETPAGE)m_arrPages[nPageIndex]; + } + + int GetPageIndex(HPROPSHEETPAGE hPage) const + { + ATLASSERT(this->m_hWnd == NULL); // can't do this after it's created + return m_arrPages.Find((HPROPSHEETPAGE&)hPage); + } + + BOOL SetActivePage(int nPageIndex) + { + if(this->m_hWnd == NULL) // not created yet + { + ATLASSERT((nPageIndex >= 0) && (nPageIndex < m_arrPages.GetSize())); + m_psh.nStartPage = nPageIndex; + return TRUE; + } + return TBase::SetActivePage(nPageIndex); + } + + BOOL SetActivePage(HPROPSHEETPAGE hPage) + { + ATLASSERT(hPage != NULL); + if(this->m_hWnd == NULL) // not created yet + { + int nPageIndex = GetPageIndex(hPage); + if(nPageIndex == -1) + return FALSE; + + return SetActivePage(nPageIndex); + } + return TBase::SetActivePage(hPage); + + } + + void SetTitle(LPCTSTR lpszText, UINT nStyle = 0) + { + ATLASSERT((nStyle & ~PSH_PROPTITLE) == 0); // only PSH_PROPTITLE is valid + ATLASSERT(lpszText != NULL); + + if(this->m_hWnd == NULL) + { + // set internal state + m_psh.pszCaption = lpszText; // must exist until sheet is created + m_psh.dwFlags &= ~PSH_PROPTITLE; + m_psh.dwFlags |= nStyle; + } + else + { + // set external state + TBase::SetTitle(lpszText, nStyle); + } + } + + void SetWizardMode() + { + m_psh.dwFlags |= PSH_WIZARD; + } + + void EnableHelp() + { + m_psh.dwFlags |= PSH_HASHELP; + } + +// Operations + BOOL AddPage(HPROPSHEETPAGE hPage) + { + ATLASSERT(hPage != NULL); + BOOL bRet = FALSE; + if(this->m_hWnd != NULL) + bRet = TBase::AddPage(hPage); + else // sheet not created yet, use internal data + bRet = m_arrPages.Add((HPROPSHEETPAGE&)hPage); + return bRet; + } + + BOOL AddPage(LPCPROPSHEETPAGE pPage) + { + ATLASSERT(pPage != NULL); + HPROPSHEETPAGE hPage = ::CreatePropertySheetPage(pPage); + if(hPage == NULL) + return FALSE; + BOOL bRet = AddPage(hPage); + if(!bRet) + ::DestroyPropertySheetPage(hPage); + return bRet; + } + + BOOL RemovePage(HPROPSHEETPAGE hPage) + { + ATLASSERT(hPage != NULL); + if(this->m_hWnd == NULL) // not created yet + { + int nPage = GetPageIndex(hPage); + if(nPage == -1) + return FALSE; + return RemovePage(nPage); + } + TBase::RemovePage(hPage); + return TRUE; + + } + + BOOL RemovePage(int nPageIndex) + { + BOOL bRet = TRUE; + if(this->m_hWnd != NULL) + TBase::RemovePage(nPageIndex); + else // sheet not created yet, use internal data + bRet = m_arrPages.RemoveAt(nPageIndex); + return bRet; + } + + void SetHeader(LPCTSTR szbmHeader) + { + ATLASSERT(this->m_hWnd == NULL); // can't do this after it's created + + m_psh.dwFlags &= ~PSH_WIZARD; + m_psh.dwFlags |= (PSH_HEADER | PSH_WIZARD97); + m_psh.pszbmHeader = szbmHeader; + } + + void SetHeader(HBITMAP hbmHeader) + { + ATLASSERT(this->m_hWnd == NULL); // can't do this after it's created + + m_psh.dwFlags &= ~PSH_WIZARD; + m_psh.dwFlags |= (PSH_HEADER | PSH_USEHBMHEADER | PSH_WIZARD97); + m_psh.hbmHeader = hbmHeader; + } + + void SetWatermark(LPCTSTR szbmWatermark, HPALETTE hplWatermark = NULL) + { + ATLASSERT(this->m_hWnd == NULL); // can't do this after it's created + + m_psh.dwFlags &= ~PSH_WIZARD; + m_psh.dwFlags |= PSH_WATERMARK | PSH_WIZARD97; + m_psh.pszbmWatermark = szbmWatermark; + + if(hplWatermark != NULL) + { + m_psh.dwFlags |= PSH_USEHPLWATERMARK; + m_psh.hplWatermark = hplWatermark; + } + } + + void SetWatermark(HBITMAP hbmWatermark, HPALETTE hplWatermark = NULL) + { + ATLASSERT(this->m_hWnd == NULL); // can't do this after it's created + + m_psh.dwFlags &= ~PSH_WIZARD; + m_psh.dwFlags |= (PSH_WATERMARK | PSH_USEHBMWATERMARK | PSH_WIZARD97); + m_psh.hbmWatermark = hbmWatermark; + + if(hplWatermark != NULL) + { + m_psh.dwFlags |= PSH_USEHPLWATERMARK; + m_psh.hplWatermark = hplWatermark; + } + } + + void StretchWatermark(bool bStretchWatermark) + { + ATLASSERT(this->m_hWnd == NULL); // can't do this after it's created + if(bStretchWatermark) + m_psh.dwFlags |= PSH_STRETCHWATERMARK; + else + m_psh.dwFlags &= ~PSH_STRETCHWATERMARK; + } + +// Message map and handlers + BEGIN_MSG_MAP(CPropertySheetImpl) + MESSAGE_HANDLER(WM_COMMAND, OnCommand) + MESSAGE_HANDLER(WM_SYSCOMMAND, OnSysCommand) + END_MSG_MAP() + + LRESULT OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) + { + LRESULT lRet = this->DefWindowProc(uMsg, wParam, lParam); + if((HIWORD(wParam) == BN_CLICKED) && ((LOWORD(wParam) == IDOK) || (LOWORD(wParam) == IDCANCEL)) && + ((m_psh.dwFlags & PSH_MODELESS) != 0) && (this->GetActivePage() == NULL)) + this->DestroyWindow(); + return lRet; + } + + LRESULT OnSysCommand(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) + { + if(((m_psh.dwFlags & PSH_MODELESS) == PSH_MODELESS) && ((wParam & 0xFFF0) == SC_CLOSE)) + this->SendMessage(WM_CLOSE); + else + bHandled = FALSE; + return 0; + } +}; + +// for non-customized sheets +class CPropertySheet : public CPropertySheetImpl +{ +public: + CPropertySheet(ATL::_U_STRINGorID title = (LPCTSTR)NULL, UINT uStartPage = 0, HWND hWndParent = NULL) + : CPropertySheetImpl(title, uStartPage, hWndParent) + { } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CPropertyPageWindow - client side for a property page + +class CPropertyPageWindow : public ATL::CWindow +{ +public: +// Constructors + CPropertyPageWindow(HWND hWnd = NULL) : ATL::CWindow(hWnd) + { } + + CPropertyPageWindow& operator =(HWND hWnd) + { + m_hWnd = hWnd; + return *this; + } + +// Attributes + CPropertySheetWindow GetPropertySheet() const + { + ATLASSERT(::IsWindow(m_hWnd)); + return CPropertySheetWindow(GetParent()); + } + +// Operations + BOOL Apply() + { + ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(GetParent() != NULL); + return GetPropertySheet().Apply(); + } + + void CancelToClose() + { + ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(GetParent() != NULL); + GetPropertySheet().CancelToClose(); + } + + void SetModified(BOOL bChanged = TRUE) + { + ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(GetParent() != NULL); + GetPropertySheet().SetModified(m_hWnd, bChanged); + } + + LRESULT QuerySiblings(WPARAM wParam, LPARAM lParam) + { + ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(GetParent() != NULL); + return GetPropertySheet().QuerySiblings(wParam, lParam); + } + + void RebootSystem() + { + ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(GetParent() != NULL); + GetPropertySheet().RebootSystem(); + } + + void RestartWindows() + { + ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(GetParent() != NULL); + GetPropertySheet().RestartWindows(); + } + + void SetWizardButtons(DWORD dwFlags) + { + ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(GetParent() != NULL); + GetPropertySheet().SetWizardButtons(dwFlags); + } + +// Implementation - overrides to prevent usage + HWND Create(LPCTSTR, HWND, ATL::_U_RECT = NULL, LPCTSTR = NULL, DWORD = 0, DWORD = 0, ATL::_U_MENUorID = 0U, LPVOID = NULL) + { + ATLASSERT(FALSE); + return NULL; + } +}; + +/////////////////////////////////////////////////////////////////////////////// +// CPropertyPageImpl - implements a property page + +#if defined(_WTL_FORCE_OLD_PAGE_NOTIFY_HANDLERS) && defined(_WTL_NEW_PAGE_NOTIFY_HANDLERS) + #error _WTL_FORCE_OLD_PAGE_NOTIFY_HANDLERS and _WTL_NEW_PAGE_NOTIFY_HANDLERS cannot be both defined +#endif + +#if !defined(_WTL_FORCE_OLD_PAGE_NOTIFY_HANDLERS) && !defined(_WTL_NEW_PAGE_NOTIFY_HANDLERS) + #define _WTL_NEW_PAGE_NOTIFY_HANDLERS +#endif + +// NOTE: _WTL_NEW_PAGE_NOTIFY_HANDLERS is now defined by default. +// It enables use of new notification handlers that +// return direct values without any restrictions. +// Define _WTL_FORCE_OLD_PAGE_NOTIFY_HANDLERS to use old handlers. + +template +class ATL_NO_VTABLE CPropertyPageImpl : public ATL::CDialogImplBaseT< TBase > +{ +public: + PROPSHEETPAGE m_psp; + + operator PROPSHEETPAGE*() { return &m_psp; } + +// Construction + CPropertyPageImpl(ATL::_U_STRINGorID title = (LPCTSTR)NULL) + { + // initialize PROPSHEETPAGE struct + memset(&m_psp, 0, sizeof(PROPSHEETPAGE)); + m_psp.dwSize = sizeof(PROPSHEETPAGE); + m_psp.dwFlags = PSP_USECALLBACK; + m_psp.hInstance = ModuleHelper::GetResourceInstance(); + T* pT = static_cast(this); + m_psp.pszTemplate = MAKEINTRESOURCE(pT->IDD); + m_psp.pfnDlgProc = (DLGPROC)T::StartDialogProc; + m_psp.pfnCallback = T::PropPageCallback; + m_psp.lParam = (LPARAM)pT; + + if(title.m_lpstr != NULL) + SetTitle(title); + } + +// Callback function and overrideables + static UINT CALLBACK PropPageCallback(HWND hWnd, UINT uMsg, LPPROPSHEETPAGE ppsp) + { + (void)hWnd; // avoid level 4 warning + ATLASSERT(hWnd == NULL); + T* pT = (T*)ppsp->lParam; + UINT uRet = 0; + + switch(uMsg) + { + case PSPCB_CREATE: + { + ATL::CDialogImplBaseT< TBase >* pPage = (ATL::CDialogImplBaseT< TBase >*)pT; + ModuleHelper::AddCreateWndData(&pPage->m_thunk.cd, pPage); + uRet = pT->OnPageCreate() ? 1 : 0; + } + break; + case PSPCB_ADDREF: + pT->OnPageAddRef(); + break; + case PSPCB_RELEASE: + pT->OnPageRelease(); + break; + default: + break; + } + + return uRet; + } + + bool OnPageCreate() + { + return true; // true - allow page to be created, false - prevent creation + } + + void OnPageAddRef() + { + } + + void OnPageRelease() + { + } + +// Create method + HPROPSHEETPAGE Create() + { + return ::CreatePropertySheetPage(&m_psp); + } + +// Attributes + void SetTitle(ATL::_U_STRINGorID title) + { + m_psp.pszTitle = title.m_lpstr; + m_psp.dwFlags |= PSP_USETITLE; + } + + void SetHeaderTitle(LPCTSTR lpstrHeaderTitle) + { + ATLASSERT(this->m_hWnd == NULL); // can't do this after it's created + m_psp.dwFlags |= PSP_USEHEADERTITLE; + m_psp.pszHeaderTitle = lpstrHeaderTitle; + } + + void SetHeaderSubTitle(LPCTSTR lpstrHeaderSubTitle) + { + ATLASSERT(this->m_hWnd == NULL); // can't do this after it's created + m_psp.dwFlags |= PSP_USEHEADERSUBTITLE; + m_psp.pszHeaderSubTitle = lpstrHeaderSubTitle; + } + +// Operations + void EnableHelp() + { + m_psp.dwFlags |= PSP_HASHELP; + } + +// Message map and handlers + BEGIN_MSG_MAP(CPropertyPageImpl) + MESSAGE_HANDLER(WM_NOTIFY, OnNotify) + END_MSG_MAP() + + LRESULT OnNotify(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + NMHDR* pNMHDR = (NMHDR*)lParam; + + // don't handle messages not from the page/sheet itself + if((pNMHDR->hwndFrom != this->m_hWnd) && (pNMHDR->hwndFrom != ::GetParent(this->m_hWnd))) + { + bHandled = FALSE; + return 1; + } + + T* pT = static_cast(this); + LRESULT lResult = 0; + switch(pNMHDR->code) + { +#ifdef _WTL_NEW_PAGE_NOTIFY_HANDLERS + case PSN_SETACTIVE: + lResult = pT->OnSetActive(); + break; + case PSN_KILLACTIVE: + lResult = pT->OnKillActive(); + break; + case PSN_APPLY: + lResult = pT->OnApply(); + break; + case PSN_RESET: + pT->OnReset(); + break; + case PSN_QUERYCANCEL: + lResult = pT->OnQueryCancel(); + break; + case PSN_WIZNEXT: + lResult = pT->OnWizardNext(); + break; + case PSN_WIZBACK: + lResult = pT->OnWizardBack(); + break; + case PSN_WIZFINISH: + lResult = pT->OnWizardFinish(); + break; + case PSN_HELP: + pT->OnHelp(); + break; + case PSN_GETOBJECT: + if(!pT->OnGetObject((LPNMOBJECTNOTIFY)lParam)) + bHandled = FALSE; + break; + case PSN_TRANSLATEACCELERATOR: + { + LPPSHNOTIFY lpPSHNotify = (LPPSHNOTIFY)lParam; + lResult = pT->OnTranslateAccelerator((LPMSG)lpPSHNotify->lParam); + } + break; + case PSN_QUERYINITIALFOCUS: + { + LPPSHNOTIFY lpPSHNotify = (LPPSHNOTIFY)lParam; + lResult = (LRESULT)pT->OnQueryInitialFocus((HWND)lpPSHNotify->lParam); + } + break; + +#else // !_WTL_NEW_PAGE_NOTIFY_HANDLERS + case PSN_SETACTIVE: + lResult = pT->OnSetActive() ? 0 : -1; + break; + case PSN_KILLACTIVE: + lResult = !pT->OnKillActive(); + break; + case PSN_APPLY: + lResult = pT->OnApply() ? PSNRET_NOERROR : PSNRET_INVALID_NOCHANGEPAGE; + break; + case PSN_RESET: + pT->OnReset(); + break; + case PSN_QUERYCANCEL: + lResult = !pT->OnQueryCancel(); + break; + case PSN_WIZNEXT: + lResult = pT->OnWizardNext(); + break; + case PSN_WIZBACK: + lResult = pT->OnWizardBack(); + break; + case PSN_WIZFINISH: + lResult = !pT->OnWizardFinish(); + break; + case PSN_HELP: + pT->OnHelp(); + break; + case PSN_GETOBJECT: + if(!pT->OnGetObject((LPNMOBJECTNOTIFY)lParam)) + bHandled = FALSE; + break; + case PSN_TRANSLATEACCELERATOR: + { + LPPSHNOTIFY lpPSHNotify = (LPPSHNOTIFY)lParam; + lResult = pT->OnTranslateAccelerator((LPMSG)lpPSHNotify->lParam) ? PSNRET_MESSAGEHANDLED : PSNRET_NOERROR; + } + break; + case PSN_QUERYINITIALFOCUS: + { + LPPSHNOTIFY lpPSHNotify = (LPPSHNOTIFY)lParam; + lResult = (LRESULT)pT->OnQueryInitialFocus((HWND)lpPSHNotify->lParam); + } + break; + +#endif // !_WTL_NEW_PAGE_NOTIFY_HANDLERS + default: + bHandled = FALSE; // not handled + } + + return lResult; + } + +// Overridables +#ifdef _WTL_NEW_PAGE_NOTIFY_HANDLERS + int OnSetActive() + { + // 0 = allow activate + // -1 = go back that was active + // page ID = jump to page + return 0; + } + + BOOL OnKillActive() + { + // FALSE = allow deactivate + // TRUE = prevent deactivation + return FALSE; + } + + int OnApply() + { + // PSNRET_NOERROR = apply OK + // PSNRET_INVALID = apply not OK, return to this page + // PSNRET_INVALID_NOCHANGEPAGE = apply not OK, don't change focus + return PSNRET_NOERROR; + } + + void OnReset() + { + } + + BOOL OnQueryCancel() + { + // FALSE = allow cancel + // TRUE = prevent cancel + return FALSE; + } + + int OnWizardBack() + { + // 0 = goto previous page + // -1 = prevent page change + // >0 = jump to page by dlg ID + return 0; + } + + int OnWizardNext() + { + // 0 = goto next page + // -1 = prevent page change + // >0 = jump to page by dlg ID + return 0; + } + + INT_PTR OnWizardFinish() + { + // FALSE = allow finish + // TRUE = prevent finish + // HWND = prevent finish and set focus to HWND (CommCtrl 5.80 only) + return FALSE; + } + + void OnHelp() + { + } + + BOOL OnGetObject(LPNMOBJECTNOTIFY /*lpObjectNotify*/) + { + return FALSE; // not processed + } + + int OnTranslateAccelerator(LPMSG /*lpMsg*/) + { + // PSNRET_NOERROR - message not handled + // PSNRET_MESSAGEHANDLED - message handled + return PSNRET_NOERROR; + } + + HWND OnQueryInitialFocus(HWND /*hWndFocus*/) + { + // NULL = set focus to default control + // HWND = set focus to HWND + return NULL; + } + +#else // !_WTL_NEW_PAGE_NOTIFY_HANDLERS + BOOL OnSetActive() + { + return TRUE; + } + + BOOL OnKillActive() + { + return TRUE; + } + + BOOL OnApply() + { + return TRUE; + } + + void OnReset() + { + } + + BOOL OnQueryCancel() + { + return TRUE; // ok to cancel + } + + int OnWizardBack() + { + // 0 = goto previous page + // -1 = prevent page change + // >0 = jump to page by dlg ID + return 0; + } + + int OnWizardNext() + { + // 0 = goto next page + // -1 = prevent page change + // >0 = jump to page by dlg ID + return 0; + } + + BOOL OnWizardFinish() + { + return TRUE; + } + + void OnHelp() + { + } + + BOOL OnGetObject(LPNMOBJECTNOTIFY /*lpObjectNotify*/) + { + return FALSE; // not processed + } + + BOOL OnTranslateAccelerator(LPMSG /*lpMsg*/) + { + return FALSE; // not translated + } + + HWND OnQueryInitialFocus(HWND /*hWndFocus*/) + { + return NULL; // default + } + +#endif // !_WTL_NEW_PAGE_NOTIFY_HANDLERS +}; + +// for non-customized pages +template +class CPropertyPage : public CPropertyPageImpl > +{ +public: + enum { IDD = t_wDlgTemplateID }; + + CPropertyPage(ATL::_U_STRINGorID title = (LPCTSTR)NULL) : CPropertyPageImpl(title) + { } + + DECLARE_EMPTY_MSG_MAP() +}; + +/////////////////////////////////////////////////////////////////////////////// +// CAxPropertyPageImpl - property page that hosts ActiveX controls + +#ifndef _ATL_NO_HOSTING + +// Note: You must #include to use these classes + +template +class ATL_NO_VTABLE CAxPropertyPageImpl : public CPropertyPageImpl< T, TBase > +{ +public: +// Data members + HGLOBAL m_hInitData; + HGLOBAL m_hDlgRes; + HGLOBAL m_hDlgResSplit; + +// Constructor/destructor + CAxPropertyPageImpl(ATL::_U_STRINGorID title = (LPCTSTR)NULL) : + CPropertyPageImpl< T, TBase >(title), + m_hInitData(NULL), m_hDlgRes(NULL), m_hDlgResSplit(NULL) + { + T* pT = static_cast(this); + (void)pT; // avoid level 4 warning + + // initialize ActiveX hosting and modify dialog template + ATL::AtlAxWinInit(); + + HINSTANCE hInstance = ModuleHelper::GetResourceInstance(); + LPCTSTR lpTemplateName = MAKEINTRESOURCE(pT->IDD); + HRSRC hDlg = ::FindResource(hInstance, lpTemplateName, (LPTSTR)RT_DIALOG); + if(hDlg != NULL) + { + HRSRC hDlgInit = ::FindResource(hInstance, lpTemplateName, (LPTSTR)_ATL_RT_DLGINIT); + + BYTE* pInitData = NULL; + if(hDlgInit != NULL) + { + m_hInitData = ::LoadResource(hInstance, hDlgInit); + pInitData = (BYTE*)::LockResource(m_hInitData); + } + + m_hDlgRes = ::LoadResource(hInstance, hDlg); + DLGTEMPLATE* pDlg = (DLGTEMPLATE*)::LockResource(m_hDlgRes); + LPCDLGTEMPLATE lpDialogTemplate = ATL::_DialogSplitHelper::SplitDialogTemplate(pDlg, pInitData); + if(lpDialogTemplate != pDlg) + m_hDlgResSplit = GlobalHandle(lpDialogTemplate); + + // set up property page to use in-memory dialog template + if(lpDialogTemplate != NULL) + { + this->m_psp.dwFlags |= PSP_DLGINDIRECT; + this->m_psp.pResource = lpDialogTemplate; + } + else + { + ATLASSERT(FALSE && _T("CAxPropertyPageImpl - ActiveX initializtion failed!")); + } + } + else + { + ATLASSERT(FALSE && _T("CAxPropertyPageImpl - Cannot find dialog template!")); + } + } + + ~CAxPropertyPageImpl() + { + if(m_hInitData != NULL) + { + UnlockResource(m_hInitData); + FreeResource(m_hInitData); + } + if(m_hDlgRes != NULL) + { + UnlockResource(m_hDlgRes); + FreeResource(m_hDlgRes); + } + if(m_hDlgResSplit != NULL) + { + ::GlobalFree(m_hDlgResSplit); + } + } + +// Methods + // call this one to handle keyboard message for ActiveX controls + BOOL PreTranslateMessage(LPMSG pMsg) + { + if (((pMsg->message < WM_KEYFIRST) || (pMsg->message > WM_KEYLAST)) && + ((pMsg->message < WM_MOUSEFIRST) || (pMsg->message > WM_MOUSELAST))) + return FALSE; + // find a direct child of the dialog from the window that has focus + HWND hWndCtl = ::GetFocus(); + if (this->IsChild(hWndCtl) && (::GetParent(hWndCtl) != this->m_hWnd)) + { + do + { + hWndCtl = ::GetParent(hWndCtl); + } + while (::GetParent(hWndCtl) != this->m_hWnd); + } + // give controls a chance to translate this message + return (BOOL)::SendMessage(hWndCtl, WM_FORWARDMSG, 0, (LPARAM)pMsg); + } + +// Overridables + // new default implementation for ActiveX hosting pages +#ifdef _WTL_NEW_PAGE_NOTIFY_HANDLERS + int OnTranslateAccelerator(LPMSG lpMsg) + { + T* pT = static_cast(this); + return (pT->PreTranslateMessage(lpMsg) != FALSE) ? PSNRET_MESSAGEHANDLED : PSNRET_NOERROR; + } +#else // !_WTL_NEW_PAGE_NOTIFY_HANDLERS + BOOL OnTranslateAccelerator(LPMSG lpMsg) + { + T* pT = static_cast(this); + return pT->PreTranslateMessage(lpMsg); + } +#endif // !_WTL_NEW_PAGE_NOTIFY_HANDLERS + + int GetIDD() + { + return( static_cast(this)->IDD ); + } + + virtual DLGPROC GetDialogProc() + { + return DialogProc; + } + + static INT_PTR CALLBACK DialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) + { + CAxPropertyPageImpl< T, TBase >* pThis = (CAxPropertyPageImpl< T, TBase >*)hWnd; + if (uMsg == WM_INITDIALOG) + { + HRESULT hr; + if (FAILED(hr = pThis->CreateActiveXControls(pThis->GetIDD()))) + { + ATLASSERT(FALSE); + return FALSE; + } + } + return CPropertyPageImpl< T, TBase >::DialogProc(hWnd, uMsg, wParam, lParam); + } + +// ActiveX controls creation + virtual HRESULT CreateActiveXControls(UINT nID) + { + // Load dialog template and InitData + HRSRC hDlgInit = ::FindResource(ATL::_AtlBaseModule.GetResourceInstance(), MAKEINTRESOURCE(nID), (LPTSTR)_ATL_RT_DLGINIT); + BYTE* pInitData = NULL; + HGLOBAL hData = NULL; + HRESULT hr = S_OK; + if (hDlgInit != NULL) + { + hData = ::LoadResource(ATL::_AtlBaseModule.GetResourceInstance(), hDlgInit); + if (hData != NULL) + pInitData = (BYTE*) ::LockResource(hData); + } + + HRSRC hDlg = ::FindResource(ATL::_AtlBaseModule.GetResourceInstance(), MAKEINTRESOURCE(nID), (LPTSTR)RT_DIALOG); + if (hDlg != NULL) + { + HGLOBAL hResource = ::LoadResource(ATL::_AtlBaseModule.GetResourceInstance(), hDlg); + DLGTEMPLATE* pDlg = NULL; + if (hResource != NULL) + { + pDlg = (DLGTEMPLATE*) ::LockResource(hResource); + if (pDlg != NULL) + { + // Get first control on the template + BOOL bDialogEx = ATL::_DialogSplitHelper::IsDialogEx(pDlg); + WORD nItems = ATL::_DialogSplitHelper::DlgTemplateItemCount(pDlg); + + // Get first control on the dialog + DLGITEMTEMPLATE* pItem = ATL::_DialogSplitHelper::FindFirstDlgItem(pDlg); + HWND hWndPrev = this->GetWindow(GW_CHILD); + + // Create all ActiveX cotnrols in the dialog template and place them in the correct tab order (z-order) + for (WORD nItem = 0; nItem < nItems; nItem++) + { + DWORD wID = bDialogEx ? ((ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX*)pItem)->id : pItem->id; + if (ATL::_DialogSplitHelper::IsActiveXControl(pItem, bDialogEx)) + { + BYTE* pData = NULL; + DWORD dwLen = ATL::_DialogSplitHelper::FindCreateData(wID, pInitData, &pData); + ATL::CComPtr spStream; + if (dwLen != 0) + { + HGLOBAL h = GlobalAlloc(GHND, dwLen); + if (h != NULL) + { + BYTE* pBytes = (BYTE*) GlobalLock(h); + BYTE* pSource = pData; + ATL::Checked::memcpy_s(pBytes, dwLen, pSource, dwLen); + GlobalUnlock(h); + CreateStreamOnHGlobal(h, TRUE, &spStream); + } + else + { + hr = E_OUTOFMEMORY; + break; + } + } + + ATL::CComBSTR bstrLicKey; + hr = ATL::_DialogSplitHelper::ParseInitData(spStream, &bstrLicKey.m_str); + if (SUCCEEDED(hr)) + { + ATL::CAxWindow2 wnd; + // Get control caption. + LPWSTR pszClassName = + bDialogEx ? + (LPWSTR)(((ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX*)pItem) + 1) : + (LPWSTR)(pItem + 1); + // Get control rect. + RECT rect = {}; + rect.left = bDialogEx ? ((ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX*)pItem)->x : pItem->x; + rect.top = bDialogEx ? ((ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX*)pItem)->y : pItem->y; + rect.right = rect.left + (bDialogEx ? ((ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX*)pItem)->cx : pItem->cx); + rect.bottom = rect.top + (bDialogEx ? ((ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX*)pItem)->cy : pItem->cy); + + // Convert from dialog units to screen units + this->MapDialogRect(&rect); + + // Create AxWindow with a NULL caption. + wnd.Create(this->m_hWnd, + &rect, + NULL, + (bDialogEx ? + ((ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX*)pItem)->style : + pItem->style) | WS_TABSTOP, + bDialogEx ? + ((ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX*)pItem)->exStyle : + 0, + bDialogEx ? + ((ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX*)pItem)->id : + pItem->id, + NULL); + + if (wnd != NULL) + { + // Set the Help ID + if (bDialogEx && ((ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX*)pItem)->helpID != 0) + wnd.SetWindowContextHelpId(((ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX*)pItem)->helpID); + // Try to create the ActiveX control. + hr = wnd.CreateControlLic(pszClassName, spStream, NULL, bstrLicKey); + if (FAILED(hr)) + break; + // Set the correct tab position. + if (nItem == 0) + hWndPrev = HWND_TOP; + wnd.SetWindowPos(hWndPrev, 0,0,0,0,SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); + hWndPrev = wnd; + } + else + { + hr = ATL::AtlHresultFromLastError(); + } + } + } + else + { + if (nItem != 0) + hWndPrev = ::GetWindow(hWndPrev, GW_HWNDNEXT); + } + pItem = ATL::_DialogSplitHelper::FindNextDlgItem(pItem, bDialogEx); + } + } + else + hr = ATL::AtlHresultFromLastError(); + } + else + hr = ATL::AtlHresultFromLastError(); + } + return hr; + } + +// Event handling support + HRESULT AdviseSinkMap(bool bAdvise) + { + if(!bAdvise && (this->m_hWnd == NULL)) + { + // window is gone, controls are already unadvised + ATLTRACE2(atlTraceUI, 0, _T("CAxPropertyPageImpl::AdviseSinkMap called after the window was destroyed\n")); + return S_OK; + } + HRESULT hRet = E_NOTIMPL; + __if_exists(T::_GetSinkMapFinder) + { + T* pT = static_cast(this); + hRet = AtlAdviseSinkMap(pT, bAdvise); + } + return hRet; + } + +// Message map and handlers + typedef CPropertyPageImpl< T, TBase> _baseClass; + BEGIN_MSG_MAP(CAxPropertyPageImpl) + MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) + MESSAGE_HANDLER(WM_DESTROY, OnDestroy) + CHAIN_MSG_MAP(_baseClass) + END_MSG_MAP() + + LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) + { + // initialize controls in dialog with DLGINIT resource section + this->ExecuteDlgInit(static_cast(this)->IDD); + AdviseSinkMap(true); + bHandled = FALSE; + return 1; + } + + LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) + { + AdviseSinkMap(false); + bHandled = FALSE; + return 1; + } +}; + +// for non-customized pages +template +class CAxPropertyPage : public CAxPropertyPageImpl > +{ +public: + enum { IDD = t_wDlgTemplateID }; + + CAxPropertyPage(ATL::_U_STRINGorID title = (LPCTSTR)NULL) : CAxPropertyPageImpl(title) + { } + + BEGIN_MSG_MAP(CAxPropertyPage) + CHAIN_MSG_MAP(CAxPropertyPageImpl >) + END_MSG_MAP() +}; + +#endif // _ATL_NO_HOSTING + + +/////////////////////////////////////////////////////////////////////////////// +// Wizard97 Support + +// Sample wizard dialog resources: +// +// IDD_WIZ97_INTERIOR_BLANK DIALOG 0, 0, 317, 143 +// STYLE DS_SETFONT | WS_CHILD | WS_DISABLED | WS_CAPTION +// CAPTION "Wizard97 Property Page - Interior" +// FONT 8, "MS Shell Dlg" +// BEGIN +// END +// +// IDD_WIZ97_EXTERIOR_BLANK DIALOGEX 0, 0, 317, 193 +// STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_DISABLED | WS_CAPTION +// CAPTION "Wizard97 Property Page - Welcome/Complete" +// FONT 8, "MS Shell Dlg", 0, 0, 0x0 +// BEGIN +// LTEXT "Welcome to the X Wizard",IDC_WIZ97_EXTERIOR_TITLE,115,8, +// 195,24 +// LTEXT "Wizard Explanation\r\n(The height of the static text should be in multiples of 8 dlus)", +// IDC_STATIC,115,40,195,16 +// LTEXT "h",IDC_WIZ97_BULLET1,118,64,8,8 +// LTEXT "List Item 1 (the h is turned into a bullet)",IDC_STATIC, +// 127,63,122,8 +// LTEXT "h",IDC_WIZ97_BULLET2,118,79,8,8 +// LTEXT "List Item 2. Keep 7 dlus between paragraphs",IDC_STATIC, +// 127,78,33,8 +// CONTROL "&Do not show this Welcome page again", +// IDC_WIZ97_WELCOME_NOTAGAIN,"Button",BS_AUTOCHECKBOX | +// WS_TABSTOP,115,169,138,10 +// END +// +// GUIDELINES DESIGNINFO +// BEGIN +// IDD_WIZ97_INTERIOR_BLANK, DIALOG +// BEGIN +// LEFTMARGIN, 7 +// RIGHTMARGIN, 310 +// VERTGUIDE, 21 +// VERTGUIDE, 31 +// VERTGUIDE, 286 +// VERTGUIDE, 296 +// TOPMARGIN, 7 +// BOTTOMMARGIN, 136 +// HORZGUIDE, 8 +// END +// +// IDD_WIZ97_EXTERIOR_BLANK, DIALOG +// BEGIN +// RIGHTMARGIN, 310 +// VERTGUIDE, 115 +// VERTGUIDE, 118 +// VERTGUIDE, 127 +// TOPMARGIN, 7 +// BOTTOMMARGIN, 186 +// HORZGUIDE, 8 +// HORZGUIDE, 32 +// HORZGUIDE, 40 +// HORZGUIDE, 169 +// END +// END + +/////////////////////////////////////////////////////////////////////////////// +// CWizard97SheetWindow - client side for a Wizard 97 style wizard sheet + +class CWizard97SheetWindow : public CPropertySheetWindow +{ +public: +// Constructors + CWizard97SheetWindow(HWND hWnd = NULL) : CPropertySheetWindow(hWnd) + { } + + CWizard97SheetWindow& operator =(HWND hWnd) + { + m_hWnd = hWnd; + return *this; + } + +// Operations + HFONT GetExteriorPageTitleFont(void) + { + ATLASSERT(::IsWindow(m_hWnd)); + return (HFONT)::SendMessage(m_hWnd, GetMessage_GetExteriorPageTitleFont(), 0, 0L); + } + + HFONT GetBulletFont(void) + { + ATLASSERT(::IsWindow(m_hWnd)); + return (HFONT)::SendMessage(m_hWnd, GetMessage_GetBulletFont(), 0, 0L); + } + +// Helpers + static UINT GetMessage_GetExteriorPageTitleFont() + { + static UINT uGetExteriorPageTitleFont = 0; + if(uGetExteriorPageTitleFont == 0) + { + CStaticDataInitCriticalSectionLock lock; + if(FAILED(lock.Lock())) + { + ATLTRACE2(atlTraceUI, 0, _T("ERROR : Unable to lock critical section in CWizard97SheetWindow::GetMessage_GetExteriorPageTitleFont().\n")); + ATLASSERT(FALSE); + return 0; + } + + if(uGetExteriorPageTitleFont == 0) + uGetExteriorPageTitleFont = ::RegisterWindowMessage(_T("GetExteriorPageTitleFont_531AF056-B8BE-4c4c-B786-AC608DF0DF12")); + + lock.Unlock(); + } + ATLASSERT(uGetExteriorPageTitleFont != 0); + return uGetExteriorPageTitleFont; + } + + static UINT GetMessage_GetBulletFont() + { + static UINT uGetBulletFont = 0; + if(uGetBulletFont == 0) + { + CStaticDataInitCriticalSectionLock lock; + if(FAILED(lock.Lock())) + { + ATLTRACE2(atlTraceUI, 0, _T("ERROR : Unable to lock critical section in CWizard97SheetWindow::GetMessage_GetBulletFont().\n")); + ATLASSERT(FALSE); + return 0; + } + + if(uGetBulletFont == 0) + uGetBulletFont = ::RegisterWindowMessage(_T("GetBulletFont_AD347D08-8F65-45ef-982E-6352E8218AD5")); + + lock.Unlock(); + } + ATLASSERT(uGetBulletFont != 0); + return uGetBulletFont; + } + +// Implementation - override to prevent usage + HWND Create(LPCTSTR, HWND, ATL::_U_RECT = NULL, LPCTSTR = NULL, DWORD = 0, DWORD = 0, ATL::_U_MENUorID = 0U, LPVOID = NULL) + { + ATLASSERT(FALSE); + return NULL; + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CWizard97SheetImpl - implements a Wizard 97 style wizard sheet + +template +class ATL_NO_VTABLE CWizard97SheetImpl : public CPropertySheetImpl< T, TBase > +{ +protected: +// Typedefs + typedef CWizard97SheetImpl< T, TBase > thisClass; + typedef CPropertySheetImpl< T, TBase > baseClass; + +// Member variables + CFont m_fontExteriorPageTitle; // Welcome and Completion page title font + CFont m_fontBullet; // Bullet font (used on static text 'h' to produce a small bullet) + bool m_bReceivedFirstSizeMessage; + +public: + CWizard97SheetImpl(ATL::_U_STRINGorID title, ATL::_U_STRINGorID headerBitmap, ATL::_U_STRINGorID watermarkBitmap, UINT uStartPage = 0, HWND hWndParent = NULL) : + baseClass(title, uStartPage, hWndParent), + m_bReceivedFirstSizeMessage(false) + { + this->m_psh.dwFlags &= ~(PSH_NOCONTEXTHELP); + this->m_psh.dwFlags &= ~(PSH_WIZARD | PSH_WIZARD_LITE); + + this->m_psh.dwFlags |= (PSH_HASHELP | PSH_WIZARDCONTEXTHELP); + this->m_psh.dwFlags |= PSH_WIZARD97; + + baseClass::SetHeader(headerBitmap.m_lpstr); + baseClass::SetWatermark(watermarkBitmap.m_lpstr); + } + +// Overrides from base class + void OnSheetInitialized() + { + T* pT = static_cast(this); + pT->_InitializeFonts(); + + // We'd like to center the wizard here, but its too early. + // Instead, we'll do CenterWindow upon our first WM_SIZE message + } + +// Initialization + void _InitializeFonts() + { + // Setup the Title and Bullet Font + // (Property pages can send the "get external page title font" and "get bullet font" messages) + // The derived class needs to do the actual SetFont for the dialog items) + + CFontHandle fontThisDialog = this->GetFont(); + CClientDC dcScreen(NULL); + + LOGFONT titleLogFont = {}; + LOGFONT bulletLogFont = {}; + fontThisDialog.GetLogFont(&titleLogFont); + fontThisDialog.GetLogFont(&bulletLogFont); + + // The Wizard 97 Spec recommends to do the Title Font + // as Verdana Bold, 12pt. + titleLogFont.lfCharSet = DEFAULT_CHARSET; + titleLogFont.lfWeight = FW_BOLD; + ATL::Checked::tcscpy_s(titleLogFont.lfFaceName, _countof(titleLogFont.lfFaceName), _T("Verdana Bold")); + INT titleFontPointSize = 12; + titleLogFont.lfHeight = -::MulDiv(titleFontPointSize, dcScreen.GetDeviceCaps(LOGPIXELSY), 72); + m_fontExteriorPageTitle.CreateFontIndirect(&titleLogFont); + + // The Wizard 97 Spec recommends to do Bullets by having + // static text of "h" in the Marlett font. + bulletLogFont.lfCharSet = DEFAULT_CHARSET; + bulletLogFont.lfWeight = FW_NORMAL; + ATL::Checked::tcscpy_s(bulletLogFont.lfFaceName, _countof(bulletLogFont.lfFaceName), _T("Marlett")); + INT bulletFontSize = 8; + bulletLogFont.lfHeight = -::MulDiv(bulletFontSize, dcScreen.GetDeviceCaps(LOGPIXELSY), 72); + m_fontBullet.CreateFontIndirect(&bulletLogFont); + } + +// Message Handling + BEGIN_MSG_MAP(thisClass) + MESSAGE_HANDLER(CWizard97SheetWindow::GetMessage_GetExteriorPageTitleFont(), OnGetExteriorPageTitleFont) + MESSAGE_HANDLER(CWizard97SheetWindow::GetMessage_GetBulletFont(), OnGetBulletFont) + MESSAGE_HANDLER(WM_SIZE, OnSize) + CHAIN_MSG_MAP(baseClass) + END_MSG_MAP() + + LRESULT OnGetExteriorPageTitleFont(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + return (LRESULT)(HFONT)m_fontExteriorPageTitle; + } + + LRESULT OnGetBulletFont(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + return (LRESULT)(HFONT)m_fontBullet; + } + + LRESULT OnSize(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) + { + if(!m_bReceivedFirstSizeMessage) + { + m_bReceivedFirstSizeMessage = true; + this->CenterWindow(); + } + + bHandled = FALSE; + return 0; + } +}; + +// for non-customized sheets +class CWizard97Sheet : public CWizard97SheetImpl +{ +protected: +// Typedefs + typedef CWizard97Sheet thisClass; + typedef CWizard97SheetImpl baseClass; + +public: + CWizard97Sheet(ATL::_U_STRINGorID title, ATL::_U_STRINGorID headerBitmap, ATL::_U_STRINGorID watermarkBitmap, UINT uStartPage = 0, HWND hWndParent = NULL) : + baseClass(title, headerBitmap, watermarkBitmap, uStartPage, hWndParent) + { } + + BEGIN_MSG_MAP(thisClass) + CHAIN_MSG_MAP(baseClass) + END_MSG_MAP() +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CWizard97PageWindow - client side for a Wizard 97 style wizard page + +#define WIZARD97_EXTERIOR_CXDLG 317 +#define WIZARD97_EXTERIOR_CYDLG 193 + +#define WIZARD97_INTERIOR_CXDLG 317 +#define WIZARD97_INTERIOR_CYDLG 143 + +class CWizard97PageWindow : public CPropertyPageWindow +{ +public: +// Constructors + CWizard97PageWindow(HWND hWnd = NULL) : CPropertyPageWindow(hWnd) + { } + + CWizard97PageWindow& operator =(HWND hWnd) + { + m_hWnd = hWnd; + return *this; + } + +// Attributes + CWizard97SheetWindow GetPropertySheet() const + { + ATLASSERT(::IsWindow(m_hWnd)); + return CWizard97SheetWindow(GetParent()); + } + +// Operations + HFONT GetExteriorPageTitleFont(void) + { + ATLASSERT(::IsWindow(m_hWnd)); + return GetPropertySheet().GetExteriorPageTitleFont(); + } + + HFONT GetBulletFont(void) + { + ATLASSERT(::IsWindow(m_hWnd)); + return GetPropertySheet().GetBulletFont(); + } + +// Implementation - overrides to prevent usage + HWND Create(LPCTSTR, HWND, ATL::_U_RECT = NULL, LPCTSTR = NULL, DWORD = 0, DWORD = 0, ATL::_U_MENUorID = 0U, LPVOID = NULL) + { + ATLASSERT(FALSE); + return NULL; + } + +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CWizard97PageImpl - implements a Wizard 97 style wizard page + +template +class ATL_NO_VTABLE CWizard97PageImpl : public CPropertyPageImpl< T, TBase > +{ +protected: +// Typedefs + typedef CWizard97PageImpl< T, TBase > thisClass; + typedef CPropertyPageImpl< T, TBase > baseClass; + +public: + CWizard97PageImpl(ATL::_U_STRINGorID title = (LPCTSTR)NULL) : baseClass(title) + { } + +// Message Handling + BEGIN_MSG_MAP(thisClass) + CHAIN_MSG_MAP(baseClass) + END_MSG_MAP() +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CWizard97ExteriorPageImpl - implements a Wizard 97 style exterior wizard page + +template +class ATL_NO_VTABLE CWizard97ExteriorPageImpl : public CPropertyPageImpl< T, TBase > +{ +protected: +// Typedefs + typedef CWizard97ExteriorPageImpl< T, TBase > thisClass; + typedef CPropertyPageImpl< T, TBase > baseClass; + +public: +// Constructors + CWizard97ExteriorPageImpl(ATL::_U_STRINGorID title = (LPCTSTR)NULL) : baseClass(title) + { + this->m_psp.dwFlags |= PSP_HASHELP; + this->m_psp.dwFlags |= PSP_HIDEHEADER; + } + +// Message Handling + BEGIN_MSG_MAP(thisClass) + CHAIN_MSG_MAP(baseClass) + END_MSG_MAP() +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CWizard97InteriorPageImpl - implements a Wizard 97 style interior wizard page + +template +class ATL_NO_VTABLE CWizard97InteriorPageImpl : public CPropertyPageImpl< T, TBase > +{ +protected: +// Typedefs + typedef CWizard97InteriorPageImpl< T, TBase > thisClass; + typedef CPropertyPageImpl< T, TBase > baseClass; + +public: +// Constructors + CWizard97InteriorPageImpl(ATL::_U_STRINGorID title = (LPCTSTR)NULL) : baseClass(title) + { + this->m_psp.dwFlags |= PSP_HASHELP; + this->m_psp.dwFlags &= ~PSP_HIDEHEADER; + this->m_psp.dwFlags |= PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE; + + // Be sure to have the derived class define this in the constructor. + // We'll default it to something obvious in case its forgotten. + baseClass::SetHeaderTitle(_T("Call SetHeaderTitle in Derived Class")); + baseClass::SetHeaderSubTitle(_T("Call SetHeaderSubTitle in the constructor of the Derived Class.")); + } + +// Message Handling + BEGIN_MSG_MAP(thisClass) + CHAIN_MSG_MAP(baseClass) + END_MSG_MAP() +}; + + +/////////////////////////////////////////////////////////////////////////////// +// Aero Wizard support + +#if (_WIN32_WINNT >= 0x0600) + +/////////////////////////////////////////////////////////////////////////////// +// CAeroWizardFrameWindow - client side for an Aero Wizard frame window + +class CAeroWizardFrameWindow : public CPropertySheetWindow +{ +public: +// Constructors + CAeroWizardFrameWindow(HWND hWnd = NULL) : CPropertySheetWindow(hWnd) + { } + + CAeroWizardFrameWindow& operator =(HWND hWnd) + { + m_hWnd = hWnd; + return *this; + } + +// Operations - new, Aero Wizard only + void SetNextText(LPCWSTR lpszText) + { + ATLASSERT(::IsWindow(m_hWnd)); + ::SendMessage(m_hWnd, PSM_SETNEXTTEXT, 0, (LPARAM)lpszText); + } + + void ShowWizardButtons(DWORD dwButtons, DWORD dwStates) + { + ATLASSERT(::IsWindow(m_hWnd)); + ::PostMessage(m_hWnd, PSM_SHOWWIZBUTTONS, (WPARAM)dwStates, (LPARAM)dwButtons); + } + + void EnableWizardButtons(DWORD dwButtons, DWORD dwStates) + { + ATLASSERT(::IsWindow(m_hWnd)); + ::PostMessage(m_hWnd, PSM_ENABLEWIZBUTTONS, (WPARAM)dwStates, (LPARAM)dwButtons); + } + + void SetButtonText(DWORD dwButton, LPCWSTR lpszText) + { + ATLASSERT(::IsWindow(m_hWnd)); + ::SendMessage(m_hWnd, PSM_SETBUTTONTEXT, (WPARAM)dwButton, (LPARAM)lpszText); + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CAeroWizardFrameImpl - implements an Aero Wizard frame + +template +class ATL_NO_VTABLE CAeroWizardFrameImpl : public CPropertySheetImpl +{ +public: +// Constructor + CAeroWizardFrameImpl(ATL::_U_STRINGorID title = (LPCTSTR)NULL, UINT uStartPage = 0, HWND hWndParent = NULL) : + CPropertySheetImpl(title, uStartPage, hWndParent) + { + this->m_psh.dwFlags |= PSH_WIZARD | PSH_AEROWIZARD; + } + +// Operations + void EnableResizing() + { + ATLASSERT(this->m_hWnd == NULL); // can't do this after it's created + this->m_psh.dwFlags |= PSH_RESIZABLE; + } + + void UseHeaderBitmap() + { + ATLASSERT(this->m_hWnd == NULL); // can't do this after it's created + this->m_psh.dwFlags |= PSH_HEADERBITMAP; + } + + void SetNoMargin() + { + ATLASSERT(this->m_hWnd == NULL); // can't do this after it's created + this->m_psh.dwFlags |= PSH_NOMARGIN; + } + +// Override to prevent use + HWND Create(HWND /*hWndParent*/ = NULL) + { + ATLASSERT(FALSE); // not supported for Aero Wizard + return NULL; + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CAeroWizardFrame - for non-customized frames + +class CAeroWizardFrame : public CAeroWizardFrameImpl +{ +public: + CAeroWizardFrame(ATL::_U_STRINGorID title = (LPCTSTR)NULL, UINT uStartPage = 0, HWND hWndParent = NULL) + : CAeroWizardFrameImpl(title, uStartPage, hWndParent) + { } + + BEGIN_MSG_MAP(CAeroWizardFrame) + MESSAGE_HANDLER(WM_COMMAND, CAeroWizardFrameImpl::OnCommand) + END_MSG_MAP() +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CAeroWizardPageWindow - client side for an Aero Wizard page + +class CAeroWizardPageWindow : public CPropertyPageWindow +{ +public: +// Constructors + CAeroWizardPageWindow(HWND hWnd = NULL) : CPropertyPageWindow(hWnd) + { } + + CAeroWizardPageWindow& operator =(HWND hWnd) + { + m_hWnd = hWnd; + return *this; + } + +// Attributes + CAeroWizardFrameWindow GetAeroWizardFrame() const + { + ATLASSERT(::IsWindow(m_hWnd)); + // This is not really top-level frame window, but it processes all frame messages + return CAeroWizardFrameWindow(GetParent()); + } + +// Operations - new, Aero Wizard only + void SetNextText(LPCWSTR lpszText) + { + ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(GetParent() != NULL); + GetAeroWizardFrame().SetNextText(lpszText); + } + + void ShowWizardButtons(DWORD dwButtons, DWORD dwStates) + { + ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(GetParent() != NULL); + GetAeroWizardFrame().ShowWizardButtons(dwButtons, dwStates); + } + + void EnableWizardButtons(DWORD dwButtons, DWORD dwStates) + { + ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(GetParent() != NULL); + GetAeroWizardFrame().EnableWizardButtons(dwButtons, dwStates); + } + + void SetButtonText(DWORD dwButton, LPCWSTR lpszText) + { + ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT(GetParent() != NULL); + GetAeroWizardFrame().SetButtonText(dwButton, lpszText); + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CAeroWizardPageImpl - implements an Aero Wizard page + +template +class ATL_NO_VTABLE CAeroWizardPageImpl : public CPropertyPageImpl +{ +public: + CAeroWizardPageImpl(ATL::_U_STRINGorID title = (LPCTSTR)NULL) : CPropertyPageImpl(title) + { } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CAeroWizardPage - for non-customized pages + +template +class CAeroWizardPage : public CAeroWizardPageImpl > +{ +public: + enum { IDD = t_wDlgTemplateID }; + + CAeroWizardPage(ATL::_U_STRINGorID title = (LPCTSTR)NULL) : CAeroWizardPageImpl(title) + { } + + DECLARE_EMPTY_MSG_MAP() +}; + + +#ifndef _ATL_NO_HOSTING + +// Note: You must #include to use these classes + +/////////////////////////////////////////////////////////////////////////////// +// CAeroWizardAxPageImpl - Aero Wizard page that hosts ActiveX controls + +template +class ATL_NO_VTABLE CAeroWizardAxPageImpl : public CAxPropertyPageImpl< T, TBase > +{ +public: + CAeroWizardAxPageImpl(ATL::_U_STRINGorID title = (LPCTSTR)NULL) : CAxPropertyPageImpl< T, TBase >(title) + { } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CAeroWizardAxPage - for non-customized pages + +template +class CAeroWizardAxPage : public CAeroWizardAxPageImpl > +{ +public: + enum { IDD = t_wDlgTemplateID }; + + CAeroWizardAxPage(ATL::_U_STRINGorID title = (LPCTSTR)NULL) : CAeroWizardAxPageImpl(title) + { } + + BEGIN_MSG_MAP(CAeroWizardAxPage) + CHAIN_MSG_MAP(CAeroWizardAxPageImpl >) + END_MSG_MAP() +}; + +#endif // _ATL_NO_HOSTING + +#endif // (_WIN32_WINNT >= 0x0600) + + +/////////////////////////////////////////////////////////////////////////////// +// TaskDialog support + +#if (_WIN32_WINNT >= 0x0600) || defined(_WTL_TASKDIALOG) + +/////////////////////////////////////////////////////////////////////////////// +// AtlTaskDialog - support for TaskDialog() function + +inline int AtlTaskDialog(HWND hWndParent, + ATL::_U_STRINGorID WindowTitle, ATL::_U_STRINGorID MainInstructionText, ATL::_U_STRINGorID ContentText, + TASKDIALOG_COMMON_BUTTON_FLAGS dwCommonButtons = 0U, ATL::_U_STRINGorID Icon = (LPCTSTR)NULL) +{ + int nRet = -1; + +#ifdef _WTL_TASKDIALOG_DIRECT + USES_CONVERSION; + HRESULT hRet = ::TaskDialog(hWndParent, ModuleHelper::GetResourceInstance(), + IS_INTRESOURCE(WindowTitle.m_lpstr) ? (LPCWSTR) WindowTitle.m_lpstr : T2CW(WindowTitle.m_lpstr), + IS_INTRESOURCE(MainInstructionText.m_lpstr) ? (LPCWSTR) MainInstructionText.m_lpstr : T2CW(MainInstructionText.m_lpstr), + IS_INTRESOURCE(ContentText.m_lpstr) ? (LPCWSTR) ContentText.m_lpstr : T2CW(ContentText.m_lpstr), + dwCommonButtons, + IS_INTRESOURCE(Icon.m_lpstr) ? (LPCWSTR) Icon.m_lpstr : T2CW(Icon.m_lpstr), + &nRet); + ATLVERIFY(SUCCEEDED(hRet)); +#else + // This allows apps to run on older versions of Windows + typedef HRESULT (STDAPICALLTYPE *PFN_TaskDialog)(HWND hwndParent, HINSTANCE hInstance, PCWSTR pszWindowTitle, PCWSTR pszMainInstruction, PCWSTR pszContent, TASKDIALOG_COMMON_BUTTON_FLAGS dwCommonButtons, PCWSTR pszIcon, int* pnButton); + + HMODULE m_hCommCtrlDLL = ::LoadLibrary(_T("comctl32.dll")); + if(m_hCommCtrlDLL != NULL) + { + PFN_TaskDialog pfnTaskDialog = (PFN_TaskDialog)::GetProcAddress(m_hCommCtrlDLL, "TaskDialog"); + if(pfnTaskDialog != NULL) + { + USES_CONVERSION; + HRESULT hRet = pfnTaskDialog(hWndParent, ModuleHelper::GetResourceInstance(), + IS_INTRESOURCE(WindowTitle.m_lpstr) ? (LPCWSTR) WindowTitle.m_lpstr : T2CW(WindowTitle.m_lpstr), + IS_INTRESOURCE(MainInstructionText.m_lpstr) ? (LPCWSTR) MainInstructionText.m_lpstr : T2CW(MainInstructionText.m_lpstr), + IS_INTRESOURCE(ContentText.m_lpstr) ? (LPCWSTR) ContentText.m_lpstr : T2CW(ContentText.m_lpstr), + dwCommonButtons, + IS_INTRESOURCE(Icon.m_lpstr) ? (LPCWSTR) Icon.m_lpstr : T2CW(Icon.m_lpstr), + &nRet); + ATLVERIFY(SUCCEEDED(hRet)); + } + + ::FreeLibrary(m_hCommCtrlDLL); + } +#endif + + return nRet; +} + + +/////////////////////////////////////////////////////////////////////////////// +// CTaskDialogConfig - TASKDIALOGCONFIG wrapper + +class CTaskDialogConfig : public TASKDIALOGCONFIG +{ +public: +// Constructor + CTaskDialogConfig() + { + Init(); + } + + void Init() + { + memset(this, 0, sizeof(TASKDIALOGCONFIG)); // initialize structure to 0/NULL + this->cbSize = sizeof(TASKDIALOGCONFIG); + this->hInstance = ModuleHelper::GetResourceInstance(); + } + +// Operations - setting values + // common buttons + void SetCommonButtons(TASKDIALOG_COMMON_BUTTON_FLAGS dwCommonButtonsArg) + { + this->dwCommonButtons = dwCommonButtonsArg; + } + + // window title text + void SetWindowTitle(UINT nID) + { + this->pszWindowTitle = MAKEINTRESOURCEW(nID); + } + + void SetWindowTitle(LPCWSTR lpstrWindowTitle) + { + this->pszWindowTitle = lpstrWindowTitle; + } + + // main icon + void SetMainIcon(HICON hIcon) + { + this->dwFlags |= TDF_USE_HICON_MAIN; + this->hMainIcon = hIcon; + } + + void SetMainIcon(UINT nID) + { + this->dwFlags &= ~TDF_USE_HICON_MAIN; + this->pszMainIcon = MAKEINTRESOURCEW(nID); + } + + void SetMainIcon(LPCWSTR lpstrMainIcon) + { + this->dwFlags &= ~TDF_USE_HICON_MAIN; + this->pszMainIcon = lpstrMainIcon; + } + + // main instruction text + void SetMainInstructionText(UINT nID) + { + this->pszMainInstruction = MAKEINTRESOURCEW(nID); + } + + void SetMainInstructionText(LPCWSTR lpstrMainInstruction) + { + this->pszMainInstruction = lpstrMainInstruction; + } + + // content text + void SetContentText(UINT nID) + { + this->pszContent = MAKEINTRESOURCEW(nID); + } + + void SetContentText(LPCWSTR lpstrContent) + { + this->pszContent = lpstrContent; + } + + // buttons + void SetButtons(const TASKDIALOG_BUTTON* pButtonsArg, UINT cButtonsArg, int nDefaultButtonArg = 0) + { + this->pButtons = pButtonsArg; + this->cButtons = cButtonsArg; + if(nDefaultButtonArg != 0) + this->nDefaultButton = nDefaultButtonArg; + } + + void SetDefaultButton(int nDefaultButtonArg) + { + this->nDefaultButton = nDefaultButtonArg; + } + + // radio buttons + void SetRadioButtons(const TASKDIALOG_BUTTON* pRadioButtonsArg, UINT cRadioButtonsArg, int nDefaultRadioButtonArg = 0) + { + this->pRadioButtons = pRadioButtonsArg; + this->cRadioButtons = cRadioButtonsArg; + if(nDefaultRadioButtonArg != 0) + this->nDefaultRadioButton = nDefaultRadioButtonArg; + } + + void SetDefaultRadioButton(int nDefaultRadioButtonArg) + { + this->nDefaultRadioButton = nDefaultRadioButtonArg; + } + + // verification text + void SetVerificationText(UINT nID) + { + this->pszVerificationText = MAKEINTRESOURCEW(nID); + } + + void SetVerificationText(LPCWSTR lpstrVerificationText) + { + this->pszVerificationText = lpstrVerificationText; + } + + // expanded information text + void SetExpandedInformationText(UINT nID) + { + this->pszExpandedInformation = MAKEINTRESOURCEW(nID); + } + + void SetExpandedInformationText(LPCWSTR lpstrExpandedInformation) + { + this->pszExpandedInformation = lpstrExpandedInformation; + } + + // expanded control text + void SetExpandedControlText(UINT nID) + { + this->pszExpandedControlText = MAKEINTRESOURCEW(nID); + } + + void SetExpandedControlText(LPCWSTR lpstrExpandedControlText) + { + this->pszExpandedControlText = lpstrExpandedControlText; + } + + // collapsed control text + void SetCollapsedControlText(UINT nID) + { + this->pszCollapsedControlText = MAKEINTRESOURCEW(nID); + } + + void SetCollapsedControlText(LPCWSTR lpstrCollapsedControlText) + { + this->pszCollapsedControlText = lpstrCollapsedControlText; + } + + // footer icon + void SetFooterIcon(HICON hIcon) + { + this->dwFlags |= TDF_USE_HICON_FOOTER; + this->hFooterIcon = hIcon; + } + + void SetFooterIcon(UINT nID) + { + this->dwFlags &= ~TDF_USE_HICON_FOOTER; + this->pszFooterIcon = MAKEINTRESOURCEW(nID); + } + + void SetFooterIcon(LPCWSTR lpstrFooterIcon) + { + this->dwFlags &= ~TDF_USE_HICON_FOOTER; + this->pszFooterIcon = lpstrFooterIcon; + } + + // footer text + void SetFooterText(UINT nID) + { + this->pszFooter = MAKEINTRESOURCEW(nID); + } + + void SetFooterText(LPCWSTR lpstrFooterText) + { + this->pszFooter = lpstrFooterText; + } + + // width (in DLUs) + void SetWidth(UINT cxWidthArg) + { + this->cxWidth = cxWidthArg; + } + + // modify flags + void ModifyFlags(DWORD dwRemove, DWORD dwAdd) + { + this->dwFlags = (this->dwFlags & ~dwRemove) | dwAdd; + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CTaskDialogImpl - implements a Task Dialog + +template +class ATL_NO_VTABLE CTaskDialogImpl +{ +public: + CTaskDialogConfig m_tdc; + HWND m_hWnd; // used only in callback functions + +// Constructor + CTaskDialogImpl(HWND hWndParent = NULL) : m_hWnd(NULL) + { + m_tdc.hwndParent = hWndParent; + m_tdc.pfCallback = T::TaskDialogCallback; + m_tdc.lpCallbackData = (LONG_PTR)static_cast(this); + } + +// Operations + HRESULT DoModal(HWND hWndParent = ::GetActiveWindow(), int* pnButton = NULL, int* pnRadioButton = NULL, BOOL* pfVerificationFlagChecked = NULL) + { + if(m_tdc.hwndParent == NULL) + m_tdc.hwndParent = hWndParent; + +#ifdef _WTL_TASKDIALOG_DIRECT + return ::TaskDialogIndirect(&m_tdc, pnButton, pnRadioButton, pfVerificationFlagChecked); +#else + + // This allows apps to run on older versions of Windows + typedef HRESULT (STDAPICALLTYPE *PFN_TaskDialogIndirect)(const TASKDIALOGCONFIG* pTaskConfig, int* pnButton, int* pnRadioButton, BOOL* pfVerificationFlagChecked); + + HRESULT hRet = E_UNEXPECTED; + HMODULE m_hCommCtrlDLL = ::LoadLibrary(_T("comctl32.dll")); + if(m_hCommCtrlDLL != NULL) + { + PFN_TaskDialogIndirect pfnTaskDialogIndirect = (PFN_TaskDialogIndirect)::GetProcAddress(m_hCommCtrlDLL, "TaskDialogIndirect"); + if(pfnTaskDialogIndirect != NULL) + hRet = pfnTaskDialogIndirect(&m_tdc, pnButton, pnRadioButton, pfVerificationFlagChecked); + + ::FreeLibrary(m_hCommCtrlDLL); + } + + return hRet; +#endif + } + +// Operations - setting values of TASKDIALOGCONFIG + // common buttons + void SetCommonButtons(TASKDIALOG_COMMON_BUTTON_FLAGS dwCommonButtons) + { m_tdc.SetCommonButtons(dwCommonButtons); } + // window title text + void SetWindowTitle(UINT nID) + { m_tdc.SetWindowTitle(nID); } + void SetWindowTitle(LPCWSTR lpstrWindowTitle) + { m_tdc.SetWindowTitle(lpstrWindowTitle); } + // main icon + void SetMainIcon(HICON hIcon) + { m_tdc.SetMainIcon(hIcon); } + void SetMainIcon(UINT nID) + { m_tdc.SetMainIcon(nID); } + void SetMainIcon(LPCWSTR lpstrMainIcon) + { m_tdc.SetMainIcon(lpstrMainIcon); } + // main instruction text + void SetMainInstructionText(UINT nID) + { m_tdc.SetMainInstructionText(nID); } + void SetMainInstructionText(LPCWSTR lpstrMainInstruction) + { m_tdc.SetMainInstructionText(lpstrMainInstruction); } + // content text + void SetContentText(UINT nID) + { m_tdc.SetContentText(nID); } + void SetContentText(LPCWSTR lpstrContent) + { m_tdc.SetContentText(lpstrContent); } + // buttons + void SetButtons(const TASKDIALOG_BUTTON* pButtons, UINT cButtons, int nDefaultButton = 0) + { m_tdc.SetButtons(pButtons, cButtons, nDefaultButton); } + void SetDefaultButton(int nDefaultButton) + { m_tdc.SetDefaultButton(nDefaultButton); } + // radio buttons + void SetRadioButtons(const TASKDIALOG_BUTTON* pRadioButtons, UINT cRadioButtons, int nDefaultRadioButton = 0) + { m_tdc.SetRadioButtons(pRadioButtons, cRadioButtons, nDefaultRadioButton); } + void SetDefaultRadioButton(int nDefaultRadioButton) + { m_tdc.SetDefaultRadioButton(nDefaultRadioButton); } + // verification text + void SetVerificationText(UINT nID) + { m_tdc.SetVerificationText(nID); } + void SetVerificationText(LPCWSTR lpstrVerificationText) + { m_tdc.SetVerificationText(lpstrVerificationText); } + // expanded information text + void SetExpandedInformationText(UINT nID) + { m_tdc.SetExpandedInformationText(nID); } + void SetExpandedInformationText(LPCWSTR lpstrExpandedInformation) + { m_tdc.SetExpandedInformationText(lpstrExpandedInformation); } + // expanded control text + void SetExpandedControlText(UINT nID) + { m_tdc.SetExpandedControlText(nID); } + void SetExpandedControlText(LPCWSTR lpstrExpandedControlText) + { m_tdc.SetExpandedControlText(lpstrExpandedControlText); } + // collapsed control text + void SetCollapsedControlText(UINT nID) + { m_tdc.SetCollapsedControlText(nID); } + void SetCollapsedControlText(LPCWSTR lpstrCollapsedControlText) + { m_tdc.SetCollapsedControlText(lpstrCollapsedControlText); } + // footer icon + void SetFooterIcon(HICON hIcon) + { m_tdc.SetFooterIcon(hIcon); } + void SetFooterIcon(UINT nID) + { m_tdc.SetFooterIcon(nID); } + void SetFooterIcon(LPCWSTR lpstrFooterIcon) + { m_tdc.SetFooterIcon(lpstrFooterIcon); } + // footer text + void SetFooterText(UINT nID) + { m_tdc.SetFooterText(nID); } + void SetFooterText(LPCWSTR lpstrFooterText) + { m_tdc.SetFooterText(lpstrFooterText); } + // width (in DLUs) + void SetWidth(UINT cxWidth) + { m_tdc.SetWidth(cxWidth); } + // modify flags + void ModifyFlags(DWORD dwRemove, DWORD dwAdd) + { m_tdc.ModifyFlags(dwRemove, dwAdd); } + +// Implementation + static HRESULT CALLBACK TaskDialogCallback(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LONG_PTR lpRefData) + { + T* pT = (T*)lpRefData; + ATLASSERT((pT->m_hWnd == NULL) || (pT->m_hWnd == hWnd)); + + BOOL bRet = FALSE; + switch(uMsg) + { + case TDN_DIALOG_CONSTRUCTED: + pT->m_hWnd = hWnd; + pT->OnDialogConstructed(); + break; + case TDN_CREATED: + pT->OnCreated(); + break; + case TDN_BUTTON_CLICKED: + bRet = pT->OnButtonClicked((int)wParam); + break; + case TDN_RADIO_BUTTON_CLICKED: + pT->OnRadioButtonClicked((int)wParam); + break; + case TDN_HYPERLINK_CLICKED: + pT->OnHyperlinkClicked((LPCWSTR)lParam); + break; + case TDN_EXPANDO_BUTTON_CLICKED: + pT->OnExpandoButtonClicked((wParam != 0)); + break; + case TDN_VERIFICATION_CLICKED: + pT->OnVerificationClicked((wParam != 0)); + break; + case TDN_HELP: + pT->OnHelp(); + break; + case TDN_TIMER: + bRet = pT->OnTimer((DWORD)wParam); + break; + case TDN_NAVIGATED: + pT->OnNavigated(); + break; + case TDN_DESTROYED: + pT->OnDestroyed(); + pT->m_hWnd = NULL; + break; + default: + ATLTRACE2(atlTraceUI, 0, _T("Unknown notification received in CTaskDialogImpl::TaskDialogCallback\n")); + break; + } + + return (bRet != FALSE) ? S_OK : S_FALSE; + } + +// Overrideables - notification handlers + void OnDialogConstructed() + { + } + + void OnCreated() + { + } + + BOOL OnButtonClicked(int /*nButton*/) + { + return FALSE; // don't prevent dialog to close + } + + void OnRadioButtonClicked(int /*nRadioButton*/) + { + } + + void OnHyperlinkClicked(LPCWSTR /*pszHREF*/) + { + } + + void OnExpandoButtonClicked(bool /*bExpanded*/) + { + } + + void OnVerificationClicked(bool /*bChecked*/) + { + } + + void OnHelp() + { + } + + BOOL OnTimer(DWORD /*dwTickCount*/) + { + return FALSE; // don't reset counter + } + + void OnNavigated() + { + } + + void OnDestroyed() + { + } + +// Commands - valid to call only from handlers + void NavigatePage(TASKDIALOGCONFIG& tdc) + { + ATLASSERT(m_hWnd != NULL); + + tdc.cbSize = sizeof(TASKDIALOGCONFIG); + if(tdc.hwndParent == NULL) + tdc.hwndParent = m_tdc.hwndParent; + tdc.pfCallback = m_tdc.pfCallback; + tdc.lpCallbackData = m_tdc.lpCallbackData; + (TASKDIALOGCONFIG)m_tdc = tdc; + + ::SendMessage(m_hWnd, TDM_NAVIGATE_PAGE, 0, (LPARAM)&tdc); + } + + // modify TASKDIALOGCONFIG values, then call this to update task dialog + void NavigatePage() + { + ATLASSERT(m_hWnd != NULL); + ::SendMessage(m_hWnd, TDM_NAVIGATE_PAGE, 0, (LPARAM)&m_tdc); + } + + void ClickButton(int nButton) + { + ATLASSERT(m_hWnd != NULL); + ::SendMessage(m_hWnd, TDM_CLICK_BUTTON, nButton, 0L); + } + + void SetMarqueeProgressBar(BOOL bMarquee) + { + ATLASSERT(m_hWnd != NULL); + ::SendMessage(m_hWnd, TDM_SET_MARQUEE_PROGRESS_BAR, bMarquee, 0L); + } + + BOOL SetProgressBarState(int nNewState) + { + ATLASSERT(m_hWnd != NULL); + return (BOOL)::SendMessage(m_hWnd, TDM_SET_PROGRESS_BAR_STATE, nNewState, 0L); + } + + DWORD SetProgressBarRange(int nMinRange, int nMaxRange) + { + ATLASSERT(m_hWnd != NULL); + return (DWORD)::SendMessage(m_hWnd, TDM_SET_PROGRESS_BAR_RANGE, 0, MAKELPARAM(nMinRange, nMaxRange)); + } + + int SetProgressBarPos(int nNewPos) + { + ATLASSERT(m_hWnd != NULL); + return (int)::SendMessage(m_hWnd, TDM_SET_PROGRESS_BAR_POS, nNewPos, 0L); + } + + BOOL SetProgressBarMarquee(BOOL bMarquee, UINT uSpeed) + { + ATLASSERT(m_hWnd != NULL); + return (BOOL)::SendMessage(m_hWnd, TDM_SET_PROGRESS_BAR_MARQUEE, bMarquee, uSpeed); + } + + void SetElementText(TASKDIALOG_ELEMENTS element, LPCWSTR lpstrText) + { + ATLASSERT(m_hWnd != NULL); + ::SendMessage(m_hWnd, TDM_SET_ELEMENT_TEXT, element, (LPARAM)lpstrText); + } + + void ClickRadioButton(int nRadioButton) + { + ATLASSERT(m_hWnd != NULL); + ::SendMessage(m_hWnd, TDM_CLICK_RADIO_BUTTON, nRadioButton, 0L); + } + + void EnableButton(int nButton, BOOL bEnable) + { + ATLASSERT(m_hWnd != NULL); + ::SendMessage(m_hWnd, TDM_ENABLE_BUTTON, nButton, bEnable); + } + + void EnableRadioButton(int nButton, BOOL bEnable) + { + ATLASSERT(m_hWnd != NULL); + ::SendMessage(m_hWnd, TDM_ENABLE_RADIO_BUTTON, nButton, bEnable); + } + + void ClickVerification(BOOL bCheck, BOOL bFocus) + { + ATLASSERT(m_hWnd != NULL); + ::SendMessage(m_hWnd, TDM_CLICK_VERIFICATION, bCheck, bFocus); + } + + void UpdateElementText(TASKDIALOG_ELEMENTS element, LPCWSTR lpstrText) + { + ATLASSERT(m_hWnd != NULL); + ::SendMessage(m_hWnd, TDM_UPDATE_ELEMENT_TEXT, element, (LPARAM)lpstrText); + } + + void SetButtonElevationRequiredState(int nButton, BOOL bElevation) + { + ATLASSERT(m_hWnd != NULL); + ::SendMessage(m_hWnd, TDM_SET_BUTTON_ELEVATION_REQUIRED_STATE, nButton, bElevation); + } + + void UpdateIcon(TASKDIALOG_ICON_ELEMENTS element, HICON hIcon) + { + ATLASSERT(m_hWnd != NULL); +#ifdef _DEBUG + if(element == TDIE_ICON_MAIN) + ATLASSERT((m_tdc.dwFlags & TDF_USE_HICON_MAIN) != 0); + else if(element == TDIE_ICON_FOOTER) + ATLASSERT((m_tdc.dwFlags & TDF_USE_HICON_FOOTER) != 0); +#endif // _DEBUG + ::SendMessage(m_hWnd, TDM_UPDATE_ICON, element, (LPARAM)hIcon); + } + + void UpdateIcon(TASKDIALOG_ICON_ELEMENTS element, LPCWSTR lpstrIcon) + { + ATLASSERT(m_hWnd != NULL); +#ifdef _DEBUG + if(element == TDIE_ICON_MAIN) + ATLASSERT((m_tdc.dwFlags & TDF_USE_HICON_MAIN) == 0); + else if(element == TDIE_ICON_FOOTER) + ATLASSERT((m_tdc.dwFlags & TDF_USE_HICON_FOOTER) == 0); +#endif // _DEBUG + ::SendMessage(m_hWnd, TDM_UPDATE_ICON, element, (LPARAM)lpstrIcon); + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CTaskDialog - for non-customized task dialogs + +class CTaskDialog : public CTaskDialogImpl +{ +public: + CTaskDialog(HWND hWndParent = NULL) : CTaskDialogImpl(hWndParent) + { + m_tdc.pfCallback = NULL; + } +}; + +#endif // (_WIN32_WINNT >= 0x0600) || defined(_WTL_TASKDIALOG) + +} // namespace WTL + +#endif // __ATLDLGS_H__ diff -r e9bb126753e7 -r 20d02a178406 foosdk/wtl/Include/atldwm.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/wtl/Include/atldwm.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,498 @@ +// Windows Template Library - WTL version 10.0 +// Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. +// +// This file is a part of the Windows Template Library. +// The use and distribution terms for this software are covered by the +// Microsoft Public License (http://opensource.org/licenses/MS-PL) +// which can be found in the file MS-PL.txt at the root folder. + +#ifndef __ATLDWM_H__ +#define __ATLDWM_H__ + +#pragma once + +#ifndef __ATLAPP_H__ + #error atldwm.h requires atlapp.h to be included first +#endif + +#ifndef __ATLWIN_H__ + #error atldwm.h requires atlwin.h to be included first +#endif + +#if (_WIN32_WINNT < 0x0600) + #error atldwm.h requires _WIN32_WINNT >= 0x0600 +#endif + +#ifndef _DWMAPI_H_ + #include +#endif +#pragma comment(lib, "dwmapi.lib") + +// Note: To create an application that also runs on older versions of Windows, +// use delay load of dwmapi.dll and ensure that no calls to the DWM API are +// Delay load is NOT AUTOMATIC for VC++ 7, you have to link to delayimp.lib, +// and add dwmapi.dll in the Linker.Input.Delay Loaded DLLs section of the +// project properties. + + +/////////////////////////////////////////////////////////////////////////////// +// Classes in this file: +// +// CDwm +// CDwmImpl +// CDwmWindowT - CDwmWindow +// CDwmThumbnailT +// CDwmThumbnail +// CDwmThumbnailHandle +// CAeroControlImpl + + +namespace WTL +{ + +/////////////////////////////////////////////////////////////////////////////// +// CDwm - wrapper for DWM handle + +class CDwm +{ +public: +// Data members + static int m_nIsDwmSupported; + +// Constructor + CDwm() + { + IsDwmSupported(); + } + +// Dwm support helper + static bool IsDwmSupported() + { + if(m_nIsDwmSupported == -1) + { + CStaticDataInitCriticalSectionLock lock; + if(FAILED(lock.Lock())) + { + ATLTRACE2(atlTraceUI, 0, _T("ERROR : Unable to lock critical section in CDwm::IsDwmSupported.\n")); + ATLASSERT(FALSE); + return false; + } + + if(m_nIsDwmSupported == -1) + { + HMODULE hDwmDLL = ::LoadLibrary(_T("dwmapi.dll")); + m_nIsDwmSupported = (hDwmDLL != NULL) ? 1 : 0; + if(hDwmDLL != NULL) + ::FreeLibrary(hDwmDLL); + } + + lock.Unlock(); + } + + ATLASSERT(m_nIsDwmSupported != -1); + return (m_nIsDwmSupported == 1); + } + +// Operations + BOOL DwmIsCompositionEnabled() const + { + if(!IsDwmSupported()) + return FALSE; + + BOOL bRes = FALSE; + return (SUCCEEDED(::DwmIsCompositionEnabled(&bRes)) && bRes) ? TRUE : FALSE; + } + + BOOL DwmEnableComposition(UINT fEnable) + { + if(!IsDwmSupported()) + return FALSE; + + return SUCCEEDED(::DwmEnableComposition(fEnable)) ? TRUE : FALSE; + } + + BOOL DwmEnableMMCSS(BOOL fEnableMMCSS) + { + if(!IsDwmSupported()) + return FALSE; + + return SUCCEEDED(::DwmEnableMMCSS(fEnableMMCSS)) ? TRUE : FALSE; + } + + HRESULT DwmGetColorizationColor(DWORD* pcrColorization, BOOL* pfOpaqueBlend) + { + if(!IsDwmSupported()) + return E_NOTIMPL; + + return ::DwmGetColorizationColor(pcrColorization, pfOpaqueBlend); + } + + HRESULT DwmFlush() + { + if(!IsDwmSupported()) + return E_NOTIMPL; + + return ::DwmFlush(); + } +}; + +__declspec(selectany) int CDwm::m_nIsDwmSupported = -1; + + +/////////////////////////////////////////////////////////////////////////////// +// CDwmImpl - DWM window support + +template +class CDwmImpl : public TBase +{ +public: + HRESULT DwmEnableBlurBehindWindow(const DWM_BLURBEHIND* pBB) + { + if(!this->IsDwmSupported()) + return E_NOTIMPL; + + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + return ::DwmEnableBlurBehindWindow(pT->m_hWnd, pBB); + } + + HRESULT DwmExtendFrameIntoClientArea(const MARGINS* pMargins) + { + if(!this->IsDwmSupported()) + return E_NOTIMPL; + + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + return ::DwmExtendFrameIntoClientArea(pT->m_hWnd, pMargins); + } + + HRESULT DwmExtendFrameIntoEntireClientArea() + { + MARGINS margins = { -1 }; + return DwmExtendFrameIntoClientArea(&margins); + } + + HRESULT DwmGetCompositionTimingInfo(DWM_TIMING_INFO* pTimingInfo) + { + if(!this->IsDwmSupported()) + return E_NOTIMPL; + + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + return ::DwmGetCompositionTimingInfo(pT->m_hWnd, pTimingInfo); + } + + HRESULT DwmGetWindowAttribute(DWORD dwAttribute, PVOID pvAttribute, DWORD cbAttribute) + { + if(!this->IsDwmSupported()) + return E_NOTIMPL; + + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + return ::DwmGetWindowAttribute(pT->m_hWnd, dwAttribute, pvAttribute, cbAttribute); + } + + HRESULT DwmModifyPreviousDxFrameDuration(INT cRefreshes, BOOL fRelative) + { + if(!this->IsDwmSupported()) + return E_NOTIMPL; + + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + return ::DwmModifyPreviousDxFrameDuration(pT->m_hWnd, cRefreshes, fRelative); + } + + HRESULT DwmSetDxFrameDuration(INT cRefreshes) + { + if(!this->IsDwmSupported()) + return E_NOTIMPL; + + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + return ::DwmSetDxFrameDuration(pT->m_hWnd, cRefreshes); + } + + HRESULT DwmSetPresentParameters(DWM_PRESENT_PARAMETERS* pPresentParams) + { + if(!this->IsDwmSupported()) + return E_NOTIMPL; + + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + return ::DwmSetPresentParameters(pT->m_hWnd, pPresentParams); + } + + HRESULT DwmSetWindowAttribute(DWORD dwAttribute, LPCVOID pvAttribute, DWORD cbAttribute) + { + if(!this->IsDwmSupported()) + return E_NOTIMPL; + + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + return ::DwmSetWindowAttribute(pT->m_hWnd, dwAttribute, pvAttribute, cbAttribute); + } + + HRESULT DwmAttachMilContent() + { + if(!this->IsDwmSupported()) + return E_NOTIMPL; + + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + return ::DwmAttachMilContent(pT->m_hWnd); + } + + HRESULT DwmDetachMilContent() + { + if(!this->IsDwmSupported()) + return E_NOTIMPL; + + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + return ::DwmDetachMilContent(pT->m_hWnd); + } +}; + +template +class CDwmWindowT : public TBase, public CDwmImpl > +{ +public: + CDwmWindowT(HWND hWnd = NULL) : TBase(hWnd) + { } + + CDwmWindowT< TBase >& operator =(HWND hWnd) + { + this->m_hWnd = hWnd; + return *this; + } +}; + +typedef CDwmWindowT CDwmWindow; + + +/////////////////////////////////////////////////////////////////////////////// +// CDwmThumbnail - provides DWM thumbnail support + +template +class CDwmThumbnailT : public TBase +{ +public: +// Data members + HTHUMBNAIL m_hThumbnail; + +// Constructor + CDwmThumbnailT(HTHUMBNAIL hThumbnail = NULL) : m_hThumbnail(hThumbnail) + { } + + ~CDwmThumbnailT() + { + if(t_bManaged && (m_hThumbnail != NULL)) + Unregister(); + } + +// Operations + CDwmThumbnailT& operator =(HTHUMBNAIL hThumbnail) + { + Attach(hThumbnail); + return *this; + } + + void Attach(HTHUMBNAIL hThumbnailNew) + { + if(t_bManaged && (m_hThumbnail != NULL) && (m_hThumbnail != hThumbnailNew)) + Unregister(); + m_hThumbnail = hThumbnailNew; + } + + HTHUMBNAIL Detach() + { + HTHUMBNAIL hThumbnail = m_hThumbnail; + m_hThumbnail = NULL; + return hThumbnail; + } + + HRESULT Register(HWND hwndDestination, HWND hwndSource) + { + ATLASSERT(::IsWindow(hwndDestination)); + ATLASSERT(::IsWindow(hwndSource)); + ATLASSERT(m_hThumbnail==NULL); + + if(!this->IsDwmSupported()) + return E_NOTIMPL; + + return ::DwmRegisterThumbnail(hwndDestination, hwndSource, &m_hThumbnail); + } + + HRESULT Unregister() + { + if(!this->IsDwmSupported()) + return E_NOTIMPL; + if(m_hThumbnail == NULL) + return S_FALSE; + + HRESULT Hr = ::DwmUnregisterThumbnail(m_hThumbnail); + if(SUCCEEDED(Hr)) + m_hThumbnail = NULL; + + return Hr; + } + + operator HTHUMBNAIL() const { return m_hThumbnail; } + + bool IsNull() const { return (m_hThumbnail == NULL); } + + HRESULT UpdateProperties(const DWM_THUMBNAIL_PROPERTIES* ptnProperties) + { + if(!this->IsDwmSupported()) + return E_NOTIMPL; + + ATLASSERT(m_hThumbnail != NULL); + return ::DwmUpdateThumbnailProperties(m_hThumbnail, ptnProperties); + } + +// Attributes + HRESULT QuerySourceSize(PSIZE pSize) + { + if(!this->IsDwmSupported()) + return E_NOTIMPL; + + ATLASSERT(m_hThumbnail != NULL); + return ::DwmQueryThumbnailSourceSize(m_hThumbnail, pSize); + } +}; + +typedef CDwmThumbnailT CDwmThumbnail; +typedef CDwmThumbnailT CDwmThumbnailHandle; + + +#ifdef __ATLTHEME_H__ + +/////////////////////////////////////////////////////////////////////////////// +// CAeroControlImpl - Base class for controls on Glass + +template +class CAeroControlImpl : public CThemeImpl, + public CBufferedPaintImpl, + public ATL::CWindowImpl +{ +public: + typedef CThemeImpl _themeClass; + typedef CBufferedPaintImpl _baseClass; + typedef ATL::CWindowImpl _windowClass; + + CAeroControlImpl() + { + this->m_PaintParams.dwFlags = BPPF_ERASE; + } + + static LPCWSTR GetThemeName() + { +#ifdef _UNICODE + return TBase::GetWndClassName(); +#else + ATLASSERT(!_T("Return UNICODE string of window classname / theme class")); + return NULL; +#endif // _UNICODE + } + +// Message map and handlers + BEGIN_MSG_MAP(CAeroControlImpl) + MESSAGE_HANDLER(WM_CREATE, OnCreate) + MESSAGE_HANDLER(WM_ACTIVATE, OnActivate) + CHAIN_MSG_MAP(_themeClass) + CHAIN_MSG_MAP(_baseClass) + END_MSG_MAP() + + LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) + { + T* pT = static_cast(this); + pT->Init(); + + bHandled = FALSE; + return 0; + } + + LRESULT OnActivate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) + { + if(this->IsThemingSupported()) + this->Invalidate(FALSE); + + bHandled = FALSE; + return 0; + } + +// Operations + BOOL SubclassWindow(HWND hWnd) + { + ATLASSERT(this->m_hWnd == NULL); + ATLASSERT(::IsWindow(hWnd)); + BOOL bRet = _windowClass::SubclassWindow(hWnd); + if(bRet) + { + T* pT = static_cast(this); + pT->Init(); + } + + return bRet; + } + +// Implementation + LRESULT DefWindowProc() + { + const ATL::_ATL_MSG* pMsg = this->m_pCurrentMsg; + LRESULT lRes = 0; + if(pMsg != NULL) + lRes = DefWindowProc(pMsg->message, pMsg->wParam, pMsg->lParam); + + return lRes; + } + + LRESULT DefWindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam) + { + T* pT = static_cast(this); + LRESULT lRes = 0; + if(::DwmDefWindowProc(pT->m_hWnd, uMsg, wParam, lParam, &lRes) != FALSE) + return lRes; + + return _windowClass::DefWindowProc(uMsg, wParam, lParam); + } + + void DoBufferedPaint(HDC hDC, RECT& rcPaint) + { + T* pT = static_cast(this); + HDC hDCPaint = NULL; + RECT rcClient = {}; + this->GetClientRect(&rcClient); + this->m_BufferedPaint.Begin(hDC, &rcClient, this->m_dwFormat, &this->m_PaintParams, &hDCPaint); + ATLASSERT(hDCPaint != NULL); + pT->DoAeroPaint(hDCPaint, rcClient, rcPaint); + this->m_BufferedPaint.End(); + } + + void DoPaint(HDC /*hdc*/, RECT& /*rcClient*/) + { + DefWindowProc(); + } + +// Overridables + void Init() + { + T* pT = static_cast(this); + (void)pT; // avoid level 4 warning + this->SetThemeClassList(pT->GetThemeName()); + if(this->m_lpstrThemeClassList != NULL) + this->OpenThemeData(); + } + + void DoAeroPaint(HDC hDC, RECT& /*rcClient*/, RECT& rcPaint) + { + DefWindowProc(WM_PAINT, (WPARAM) hDC, 0L); + this->m_BufferedPaint.MakeOpaque(&rcPaint); + } +}; + +#endif // __ATLTHEME_H__ + +} // namespace WTL + +#endif // __ATLDWM_H__ diff -r e9bb126753e7 -r 20d02a178406 foosdk/wtl/Include/atlfind.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/wtl/Include/atlfind.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,884 @@ +// Windows Template Library - WTL version 10.0 +// Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. +// +// This file is a part of the Windows Template Library. +// The use and distribution terms for this software are covered by the +// Microsoft Public License (http://opensource.org/licenses/MS-PL) +// which can be found in the file MS-PL.txt at the root folder. + +#ifndef __ATLFIND_H__ +#define __ATLFIND_H__ + +#pragma once + +#ifndef __ATLCTRLS_H__ + #error atlfind.h requires atlctrls.h to be included first +#endif + +#ifndef __ATLDLGS_H__ + #error atlfind.h requires atldlgs.h to be included first +#endif + +#ifndef __ATLSTR_H__ + #error atlfind.h requires CString +#endif + + +/////////////////////////////////////////////////////////////////////////////// +// Classes in this file: +// +// CEditFindReplaceImplBase +// CEditFindReplaceImpl +// CRichEditFindReplaceImpl + + +namespace WTL +{ + +/////////////////////////////////////////////////////////////////////////////// +// CEditFindReplaceImplBase - Base class for mixin classes that +// help implement Find/Replace for CEdit or CRichEditCtrl based window classes. + +template +class CEditFindReplaceImplBase +{ +protected: +// Typedefs + typedef CEditFindReplaceImplBase thisClass; + +// Enumerations + enum TranslationTextItem + { + eText_OnReplaceAllMessage = 0, + eText_OnReplaceAllTitle = 1, + eText_OnTextNotFoundMessage = 2, + eText_OnTextNotFoundTitle = 3 + }; + +public: +// Data members + TFindReplaceDialog* m_pFindReplaceDialog; + ATL::CString m_sFindNext, m_sReplaceWith; + BOOL m_bFindOnly, m_bFirstSearch, m_bMatchCase, m_bWholeWord, m_bFindDown; + LONG m_nInitialSearchPos; + HCURSOR m_hOldCursor; + +// Constructors + CEditFindReplaceImplBase() : + m_pFindReplaceDialog(NULL), + m_bFindOnly(TRUE), + m_bFirstSearch(TRUE), + m_bMatchCase(FALSE), + m_bWholeWord(FALSE), + m_bFindDown(TRUE), + m_nInitialSearchPos(0), + m_hOldCursor(NULL) + { + } + +// Message Handlers + BEGIN_MSG_MAP(thisClass) + ALT_MSG_MAP(1) + MESSAGE_HANDLER(TFindReplaceDialog::GetFindReplaceMsg(), OnFindReplaceCmd) + COMMAND_ID_HANDLER(ID_EDIT_FIND, OnEditFind) + COMMAND_ID_HANDLER(ID_EDIT_REPEAT, OnEditRepeat) + COMMAND_ID_HANDLER(ID_EDIT_REPLACE, OnEditReplace) + END_MSG_MAP() + + LRESULT OnFindReplaceCmd(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/) + { + T* pT = static_cast(this); + + TFindReplaceDialog* pDialog = TFindReplaceDialog::GetNotifier(lParam); + if(pDialog == NULL) + { + ATLASSERT(FALSE); + ::MessageBeep(MB_ICONERROR); + return 1; + } + ATLASSERT(pDialog == m_pFindReplaceDialog); + + LPFINDREPLACE findReplace = (LPFINDREPLACE)lParam; + if((m_pFindReplaceDialog != NULL) && (findReplace != NULL)) + { + if(pDialog->FindNext()) + { + pT->OnFindNext(pDialog->GetFindString(), pDialog->SearchDown(), + pDialog->MatchCase(), pDialog->MatchWholeWord()); + } + else if(pDialog->ReplaceCurrent()) + { + pT->OnReplaceSel(pDialog->GetFindString(), + pDialog->SearchDown(), pDialog->MatchCase(), pDialog->MatchWholeWord(), + pDialog->GetReplaceString()); + } + else if(pDialog->ReplaceAll()) + { + pT->OnReplaceAll(pDialog->GetFindString(), pDialog->GetReplaceString(), + pDialog->MatchCase(), pDialog->MatchWholeWord()); + } + else if(pDialog->IsTerminating()) + { + // Dialog is going away (but hasn't gone away yet) + // OnFinalMessage will "delete this" + pT->OnTerminatingFindReplaceDialog(m_pFindReplaceDialog); + m_pFindReplaceDialog = NULL; + } + } + + return 0; + } + + LRESULT OnEditFind(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) + { + T* pT = static_cast(this); + pT->FindReplace(TRUE); + + return 0; + } + + LRESULT OnEditRepeat(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) + { + T* pT = static_cast(this); + + // If the user is holding down SHIFT when hitting F3, we'll + // search in reverse. Otherwise, we'll search forward. + // (be sure to have an accelerator mapped to ID_EDIT_REPEAT + // for both F3 and Shift+F3) + m_bFindDown = !((::GetKeyState(VK_SHIFT) & 0x8000) == 0x8000); + + if(m_sFindNext.IsEmpty()) + { + pT->FindReplace(TRUE); + } + else + { + if(!pT->FindTextSimple(m_sFindNext, m_bMatchCase, m_bWholeWord, m_bFindDown)) + pT->TextNotFound(m_sFindNext); + } + + return 0; + } + + LRESULT OnEditReplace(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& bHandled) + { + T* pT = static_cast(this); + + DWORD style = pT->GetStyle(); + if((style & ES_READONLY) != ES_READONLY) + { + pT->FindReplace(FALSE); + } + else + { + // Don't allow replace when the edit control is read only + bHandled = FALSE; + } + + return 0; + } + +// Operations (overrideable) + TFindReplaceDialog* CreateFindReplaceDialog(BOOL bFindOnly, // TRUE for Find, FALSE for FindReplace + LPCTSTR lpszFindWhat, + LPCTSTR lpszReplaceWith = NULL, + DWORD dwFlags = FR_DOWN, + HWND hWndParent = NULL) + { + // You can override all of this in a derived class + + TFindReplaceDialog* findReplaceDialog = new TFindReplaceDialog(); + if(findReplaceDialog == NULL) + { + ::MessageBeep(MB_ICONHAND); + } + else + { + HWND hWndFindReplace = findReplaceDialog->Create(bFindOnly, + lpszFindWhat, lpszReplaceWith, dwFlags, hWndParent); + if(hWndFindReplace == NULL) + { + delete findReplaceDialog; + findReplaceDialog = NULL; + } + else + { + findReplaceDialog->SetActiveWindow(); + findReplaceDialog->ShowWindow(SW_SHOW); + } + } + + return findReplaceDialog; + } + + void AdjustDialogPosition(HWND hWndDialog) + { + ATLASSERT((hWndDialog != NULL) && ::IsWindow(hWndDialog)); + + T* pT = static_cast(this); + LONG nStartChar = 0, nEndChar = 0; + // Send EM_GETSEL so we can use both Edit and RichEdit + // (CEdit::GetSel uses int&, and CRichEditCtrlT::GetSel uses LONG&) + ::SendMessage(pT->m_hWnd, EM_GETSEL, (WPARAM)&nStartChar, (LPARAM)&nEndChar); + POINT point = pT->PosFromChar(nStartChar); + pT->ClientToScreen(&point); + RECT rect = {}; + ::GetWindowRect(hWndDialog, &rect); + if(::PtInRect(&rect, point) != FALSE) + { + if(point.y > (rect.bottom - rect.top)) + { + ::OffsetRect(&rect, 0, point.y - rect.bottom - 20); + } + else + { + int nVertExt = GetSystemMetrics(SM_CYSCREEN); + if((point.y + (rect.bottom - rect.top)) < nVertExt) + ::OffsetRect(&rect, 0, 40 + point.y - rect.top); + } + + ::MoveWindow(hWndDialog, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, TRUE); + } + } + + DWORD GetFindReplaceDialogFlags() const + { + DWORD dwFlags = 0; + if(m_bFindDown) + dwFlags |= FR_DOWN; + if(m_bMatchCase) + dwFlags |= FR_MATCHCASE; + if(m_bWholeWord) + dwFlags |= FR_WHOLEWORD; + + return dwFlags; + } + + void FindReplace(BOOL bFindOnly) + { + T* pT = static_cast(this); + m_bFirstSearch = TRUE; + if(m_pFindReplaceDialog != NULL) + { + if(m_bFindOnly == bFindOnly) + { + m_pFindReplaceDialog->SetActiveWindow(); + m_pFindReplaceDialog->ShowWindow(SW_SHOW); + return; + } + else + { + m_pFindReplaceDialog->SendMessage(WM_CLOSE); + ATLASSERT(m_pFindReplaceDialog == NULL); + } + } + + ATLASSERT(m_pFindReplaceDialog == NULL); + + ATL::CString findNext; + pT->GetSelText(findNext); + // if selection is empty or spans multiple lines use old find text + if(findNext.IsEmpty() || (findNext.FindOneOf(_T("\n\r")) != -1)) + findNext = m_sFindNext; + ATL::CString replaceWith = m_sReplaceWith; + DWORD dwFlags = pT->GetFindReplaceDialogFlags(); + + m_pFindReplaceDialog = pT->CreateFindReplaceDialog(bFindOnly, + findNext, replaceWith, dwFlags, pT->operator HWND()); + ATLASSERT(m_pFindReplaceDialog != NULL); + if(m_pFindReplaceDialog != NULL) + m_bFindOnly = bFindOnly; + } + + BOOL SameAsSelected(LPCTSTR lpszCompare, BOOL bMatchCase, BOOL /*bWholeWord*/) + { + T* pT = static_cast(this); + + // check length first + size_t nLen = lstrlen(lpszCompare); + LONG nStartChar = 0, nEndChar = 0; + // Send EM_GETSEL so we can use both Edit and RichEdit + // (CEdit::GetSel uses int&, and CRichEditCtrlT::GetSel uses LONG&) + ::SendMessage(pT->m_hWnd, EM_GETSEL, (WPARAM)&nStartChar, (LPARAM)&nEndChar); + if(nLen != (size_t)(nEndChar - nStartChar)) + return FALSE; + + // length is the same, check contents + ATL::CString selectedText; + pT->GetSelText(selectedText); + + return (bMatchCase && (selectedText.Compare(lpszCompare) == 0)) || + (!bMatchCase && (selectedText.CompareNoCase(lpszCompare) == 0)); + } + + void TextNotFound(LPCTSTR lpszFind) + { + T* pT = static_cast(this); + m_bFirstSearch = TRUE; + pT->OnTextNotFound(lpszFind); + } + + ATL::CString GetTranslationText(enum TranslationTextItem eItem) const + { + ATL::CString text; + switch(eItem) + { + case eText_OnReplaceAllMessage: + text = _T("Replaced %d occurances of \"%s\" with \"%s\""); + break; + case eText_OnReplaceAllTitle: + text = _T("Replace All"); + break; + case eText_OnTextNotFoundMessage: + text = _T("Unable to find the text \"%s\""); + break; + case eText_OnTextNotFoundTitle: + text = _T("Text not found"); + break; + } + + return text; + } + +// Overrideable Handlers + void OnFindNext(LPCTSTR lpszFind, BOOL bFindDown, BOOL bMatchCase, BOOL bWholeWord) + { + T* pT = static_cast(this); + + m_sFindNext = lpszFind; + m_bMatchCase = bMatchCase; + m_bWholeWord = bWholeWord; + m_bFindDown = bFindDown; + + if(!pT->FindTextSimple(m_sFindNext, m_bMatchCase, m_bWholeWord, m_bFindDown)) + pT->TextNotFound(m_sFindNext); + else + pT->AdjustDialogPosition(m_pFindReplaceDialog->operator HWND()); + } + + void OnReplaceSel(LPCTSTR lpszFind, BOOL bFindDown, BOOL bMatchCase, BOOL bWholeWord, LPCTSTR lpszReplace) + { + T* pT = static_cast(this); + + m_sFindNext = lpszFind; + m_sReplaceWith = lpszReplace; + m_bMatchCase = bMatchCase; + m_bWholeWord = bWholeWord; + m_bFindDown = bFindDown; + + if(pT->SameAsSelected(m_sFindNext, m_bMatchCase, m_bWholeWord)) + pT->ReplaceSel(m_sReplaceWith); + + if(!pT->FindTextSimple(m_sFindNext, m_bMatchCase, m_bWholeWord, m_bFindDown)) + pT->TextNotFound(m_sFindNext); + else + pT->AdjustDialogPosition(m_pFindReplaceDialog->operator HWND()); + } + + void OnReplaceAll(LPCTSTR lpszFind, LPCTSTR lpszReplace, BOOL bMatchCase, BOOL bWholeWord) + { + T* pT = static_cast(this); + + m_sFindNext = lpszFind; + m_sReplaceWith = lpszReplace; + m_bMatchCase = bMatchCase; + m_bWholeWord = bWholeWord; + m_bFindDown = TRUE; + + // no selection or different than what looking for + if(!pT->SameAsSelected(m_sFindNext, m_bMatchCase, m_bWholeWord)) + { + if(!pT->FindTextSimple(m_sFindNext, m_bMatchCase, m_bWholeWord, m_bFindDown)) + { + pT->TextNotFound(m_sFindNext); + return; + } + } + + pT->OnReplaceAllCoreBegin(); + + int replaceCount=0; + do + { + ++replaceCount; + pT->ReplaceSel(m_sReplaceWith); + } while(pT->FindTextSimple(m_sFindNext, m_bMatchCase, m_bWholeWord, m_bFindDown)); + + pT->OnReplaceAllCoreEnd(replaceCount); + } + + void OnReplaceAllCoreBegin() + { + T* pT = static_cast(this); + + m_hOldCursor = ::SetCursor(::LoadCursor(NULL, IDC_WAIT)); + + pT->HideSelection(TRUE, FALSE); + + } + + void OnReplaceAllCoreEnd(int replaceCount) + { + T* pT = static_cast(this); + pT->HideSelection(FALSE, FALSE); + + ::SetCursor(m_hOldCursor); + + ATL::CString message = pT->GetTranslationText(eText_OnReplaceAllMessage); + if(message.GetLength() > 0) + { + ATL::CString formattedMessage; + formattedMessage.Format(message, replaceCount, (LPCTSTR)m_sFindNext, (LPCTSTR)m_sReplaceWith); + if(m_pFindReplaceDialog != NULL) + { + m_pFindReplaceDialog->MessageBox(formattedMessage, + pT->GetTranslationText(eText_OnReplaceAllTitle), + MB_OK | MB_ICONINFORMATION | MB_APPLMODAL); + } + else + { + pT->MessageBox(formattedMessage, + pT->GetTranslationText(eText_OnReplaceAllTitle), + MB_OK | MB_ICONINFORMATION | MB_APPLMODAL); + } + } + } + + void OnTextNotFound(LPCTSTR lpszFind) + { + T* pT = static_cast(this); + ATL::CString message = pT->GetTranslationText(eText_OnTextNotFoundMessage); + if(message.GetLength() > 0) + { + ATL::CString formattedMessage; + formattedMessage.Format(message, lpszFind); + if(m_pFindReplaceDialog != NULL) + { + m_pFindReplaceDialog->MessageBox(formattedMessage, + pT->GetTranslationText(eText_OnTextNotFoundTitle), + MB_OK | MB_ICONINFORMATION | MB_APPLMODAL); + } + else + { + pT->MessageBox(formattedMessage, + pT->GetTranslationText(eText_OnTextNotFoundTitle), + MB_OK | MB_ICONINFORMATION | MB_APPLMODAL); + } + } + else + { + ::MessageBeep(MB_ICONHAND); + } + } + + void OnTerminatingFindReplaceDialog(TFindReplaceDialog*& /*findReplaceDialog*/) + { + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CEditFindReplaceImpl - Mixin class for implementing Find/Replace for CEdit +// based window classes. + +// Chain to CEditFindReplaceImpl message map. Your class must also derive from CEdit. +// Example: +// class CMyEdit : public CWindowImpl, +// public CEditFindReplaceImpl +// { +// public: +// BEGIN_MSG_MAP(CMyEdit) +// // your handlers... +// CHAIN_MSG_MAP_ALT(CEditFindReplaceImpl, 1) +// END_MSG_MAP() +// // other stuff... +// }; + +template +class CEditFindReplaceImpl : public CEditFindReplaceImplBase +{ +protected: + typedef CEditFindReplaceImpl thisClass; + typedef CEditFindReplaceImplBase baseClass; + +public: +// Message Handlers + BEGIN_MSG_MAP(thisClass) + ALT_MSG_MAP(1) + CHAIN_MSG_MAP_ALT(baseClass, 1) + END_MSG_MAP() + +// Operations + // Supported only for RichEdit, so this does nothing for Edit + void HideSelection(BOOL /*bHide*/ = TRUE, BOOL /*bChangeStyle*/ = FALSE) + { + } + +// Operations (overrideable) + BOOL FindTextSimple(LPCTSTR lpszFind, BOOL bMatchCase, BOOL bWholeWord, BOOL bFindDown = TRUE) + { + T* pT = static_cast(this); + + ATLASSERT(lpszFind != NULL); + ATLASSERT(*lpszFind != _T('\0')); + + UINT nLen = pT->GetBufferLength(); + int nStartChar = 0, nEndChar = 0; + pT->GetSel(nStartChar, nEndChar); + UINT nStart = nStartChar; + int iDir = bFindDown ? +1 : -1; + + // can't find a match before the first character + if((nStart == 0) && (iDir < 0)) + return FALSE; + + LPCTSTR lpszText = pT->LockBuffer(); + + bool isDBCS = false; +#ifdef _MBCS + CPINFO info = {}; + ::GetCPInfo(::GetOEMCP(), &info); + isDBCS = (info.MaxCharSize > 1); +#endif + + if(iDir < 0) + { + // always go back one for search backwards + nStart -= int((lpszText + nStart) - ::CharPrev(lpszText, lpszText + nStart)); + } + else if((nStartChar != nEndChar) && (pT->SameAsSelected(lpszFind, bMatchCase, bWholeWord))) + { + // easy to go backward/forward with SBCS +#ifndef _UNICODE + if(::IsDBCSLeadByte(lpszText[nStart])) + nStart++; +#endif + nStart += iDir; + } + + // handle search with nStart past end of buffer + UINT nLenFind = ::lstrlen(lpszFind); + if((nStart + nLenFind - 1) >= nLen) + { + if((iDir < 0) && (nLen >= nLenFind)) + { + if(isDBCS) + { + // walk back to previous character n times + nStart = nLen; + int n = nLenFind; + while(n--) + { + nStart -= int((lpszText + nStart) - ::CharPrev(lpszText, lpszText + nStart)); + } + } + else + { + // single-byte character set is easy and fast + nStart = nLen - nLenFind; + } + ATLASSERT((nStart + nLenFind - 1) <= nLen); + } + else + { + pT->UnlockBuffer(); + return FALSE; + } + } + + // start the search at nStart + LPCTSTR lpsz = lpszText + nStart; + typedef int (WINAPI* CompareProc)(LPCTSTR str1, LPCTSTR str2); + CompareProc pfnCompare = bMatchCase ? lstrcmp : lstrcmpi; + + if(isDBCS) + { + // double-byte string search + LPCTSTR lpszStop = NULL; + if(iDir > 0) + { + // start at current and find _first_ occurrance + lpszStop = lpszText + nLen - nLenFind + 1; + } + else + { + // start at top and find _last_ occurrance + lpszStop = lpsz; + lpsz = lpszText; + } + + LPCTSTR lpszFound = NULL; + while(lpsz <= lpszStop) + { +#ifndef _UNICODE + if(!bMatchCase || ((*lpsz == *lpszFind) && (!::IsDBCSLeadByte(*lpsz) || (lpsz[1] == lpszFind[1])))) +#else + if(!bMatchCase || ((*lpsz == *lpszFind) && (lpsz[1] == lpszFind[1]))) +#endif + { + LPTSTR lpch = (LPTSTR)(lpsz + nLenFind); + TCHAR chSave = *lpch; + *lpch = _T('\0'); + int nResult = (*pfnCompare)(lpsz, lpszFind); + *lpch = chSave; + if(nResult == 0) + { + lpszFound = lpsz; + if(iDir > 0) + break; + } + } + lpsz = ::CharNext(lpsz); + } + pT->UnlockBuffer(); + + if(lpszFound != NULL) + { + int n = (int)(lpszFound - lpszText); + pT->SetSel(n, n + nLenFind); + return TRUE; + } + } + else + { + // single-byte string search + UINT nCompare = 0; + if(iDir < 0) + nCompare = (UINT)(lpsz - lpszText) + 1; + else + nCompare = nLen - (UINT)(lpsz - lpszText) - nLenFind + 1; + + while(nCompare > 0) + { + ATLASSERT(lpsz >= lpszText); + ATLASSERT((lpsz + nLenFind - 1) <= (lpszText + nLen - 1)); + + LPSTR lpch = (LPSTR)(lpsz + nLenFind); + char chSave = *lpch; + *lpch = '\0'; + int nResult = (*pfnCompare)(lpsz, lpszFind); + *lpch = chSave; + if(nResult == 0) + { + pT->UnlockBuffer(); + int n = (int)(lpsz - lpszText); + pT->SetSel(n, n + nLenFind); + return TRUE; + } + + // restore character at end of search + *lpch = chSave; + + // move on to next substring + nCompare--; + lpsz += iDir; + } + pT->UnlockBuffer(); + } + + return FALSE; + } + + LPCTSTR LockBuffer() const + { + const T* pT = static_cast(this); + ATLASSERT(pT->m_hWnd != NULL); + +#ifndef _UNICODE + // If common controls version 6 is in use (such as via theming), then EM_GETHANDLE + // will always return a UNICODE string. You're really not supposed to superclass + // or subclass common controls with an ANSI windows procedure. + DWORD dwMajor = 0, dwMinor = 0; + HRESULT hRet = ATL::AtlGetCommCtrlVersion(&dwMajor, &dwMinor); + if(SUCCEEDED(hRet) && (dwMajor >= 6)) + { + ATLTRACE2(atlTraceUI, 0, _T("AtlFind Warning: You have compiled for MBCS/ANSI but are using common controls version 6 or later which are always Unicode.\r\n")); + ATLASSERT(FALSE); + } +#endif // !_UNICODE + + HLOCAL hLocal = pT->GetHandle(); + ATLASSERT(hLocal != NULL); + LPCTSTR lpszText = (LPCTSTR)::LocalLock(hLocal); + ATLASSERT(lpszText != NULL); + + return lpszText; + } + + void UnlockBuffer() const + { + const T* pT = static_cast(this); + ATLASSERT(pT->m_hWnd != NULL); + + HLOCAL hLocal = pT->GetHandle(); + ATLASSERT(hLocal != NULL); + ::LocalUnlock(hLocal); + } + + UINT GetBufferLength() const + { + const T* pT = static_cast(this); + ATLASSERT(pT->m_hWnd != NULL); + + UINT nLen = 0; + LPCTSTR lpszText = pT->LockBuffer(); + if(lpszText != NULL) + nLen = ::lstrlen(lpszText); + pT->UnlockBuffer(); + + return nLen; + } + + LONG EndOfLine(LPCTSTR lpszText, UINT nLen, UINT nIndex) const + { + LPCTSTR lpsz = lpszText + nIndex; + LPCTSTR lpszStop = lpszText + nLen; + while((lpsz < lpszStop) && (*lpsz != _T('\r'))) + ++lpsz; + return LONG(lpsz - lpszText); + } + + LONG GetSelText(ATL::CString& strText) const + { + const T* pT = static_cast(this); + + int nStartChar = 0, nEndChar = 0; + pT->GetSel(nStartChar, nEndChar); + ATLASSERT((UINT)nEndChar <= pT->GetBufferLength()); + LPCTSTR lpszText = pT->LockBuffer(); + LONG nLen = pT->EndOfLine(lpszText, nEndChar, nStartChar) - nStartChar; + ATL::Checked::memcpy_s(strText.GetBuffer(nLen), nLen * sizeof(TCHAR), lpszText + nStartChar, nLen * sizeof(TCHAR)); + strText.ReleaseBuffer(nLen); + pT->UnlockBuffer(); + + return nLen; + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CRichEditFindReplaceImpl - Mixin class for implementing Find/Replace for CRichEditCtrl +// based window classes. + +// Chain to CRichEditFindReplaceImpl message map. Your class must also derive from CRichEditCtrl. +// Example: +// class CMyRichEdit : public CWindowImpl, +// public CRichEditFindReplaceImpl +// { +// public: +// BEGIN_MSG_MAP(CMyRichEdit) +// // your handlers... +// CHAIN_MSG_MAP_ALT(CRichEditFindReplaceImpl, 1) +// END_MSG_MAP() +// // other stuff... +// }; + +template +class CRichEditFindReplaceImpl : public CEditFindReplaceImplBase +{ +protected: + typedef CRichEditFindReplaceImpl thisClass; + typedef CEditFindReplaceImplBase baseClass; + +public: + BEGIN_MSG_MAP(thisClass) + ALT_MSG_MAP(1) + CHAIN_MSG_MAP_ALT(baseClass, 1) + END_MSG_MAP() + +// Operations (overrideable) + BOOL FindTextSimple(LPCTSTR lpszFind, BOOL bMatchCase, BOOL bWholeWord, BOOL bFindDown = TRUE) + { + T* pT = static_cast(this); + + ATLASSERT(lpszFind != NULL); + FINDTEXTEX ft = {}; + + pT->GetSel(ft.chrg); + if(this->m_bFirstSearch) + { + if(bFindDown) + this->m_nInitialSearchPos = ft.chrg.cpMin; + else + this->m_nInitialSearchPos = ft.chrg.cpMax; + this->m_bFirstSearch = FALSE; + } + + ft.lpstrText = (LPTSTR)lpszFind; + + if(ft.chrg.cpMin != ft.chrg.cpMax) // i.e. there is a selection + { + if(bFindDown) + { + ft.chrg.cpMin++; + } + else + { + // won't wraparound backwards + ft.chrg.cpMin = __max(ft.chrg.cpMin, 0); + } + } + + DWORD dwFlags = bMatchCase ? FR_MATCHCASE : 0; + dwFlags |= bWholeWord ? FR_WHOLEWORD : 0; + + ft.chrg.cpMax = pT->GetTextLength() + this->m_nInitialSearchPos; + + if(bFindDown) + { + if(this->m_nInitialSearchPos >= 0) + ft.chrg.cpMax = pT->GetTextLength(); + + dwFlags |= FR_DOWN; + ATLASSERT(ft.chrg.cpMax >= ft.chrg.cpMin); + } + else + { + if(this->m_nInitialSearchPos >= 0) + ft.chrg.cpMax = 0; + + dwFlags &= ~FR_DOWN; + ATLASSERT(ft.chrg.cpMax <= ft.chrg.cpMin); + } + + BOOL bRet = FALSE; + if(pT->FindAndSelect(dwFlags, ft) != -1) + { + bRet = TRUE; // we found the text + } + else if(this->m_nInitialSearchPos > 0) + { + // if the original starting point was not the beginning + // of the buffer and we haven't already been here + if(bFindDown) + { + ft.chrg.cpMin = 0; + ft.chrg.cpMax = this->m_nInitialSearchPos; + } + else + { + ft.chrg.cpMin = pT->GetTextLength(); + ft.chrg.cpMax = this->m_nInitialSearchPos; + } + this->m_nInitialSearchPos = this->m_nInitialSearchPos - pT->GetTextLength(); + + bRet = (pT->FindAndSelect(dwFlags, ft) != -1) ? TRUE : FALSE; + } + + return bRet; + } + + long FindAndSelect(DWORD dwFlags, FINDTEXTEX& ft) + { + T* pT = static_cast(this); + LONG index = pT->FindText(dwFlags, ft); + if(index != -1) // i.e. we found something + pT->SetSel(ft.chrgText); + + return index; + } +}; + +} // namespace WTL + +#endif // __ATLFIND_H__ diff -r e9bb126753e7 -r 20d02a178406 foosdk/wtl/Include/atlframe.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/wtl/Include/atlframe.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,3577 @@ +// Windows Template Library - WTL version 10.0 +// Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. +// +// This file is a part of the Windows Template Library. +// The use and distribution terms for this software are covered by the +// Microsoft Public License (http://opensource.org/licenses/MS-PL) +// which can be found in the file MS-PL.txt at the root folder. + +#ifndef __ATLFRAME_H__ +#define __ATLFRAME_H__ + +#pragma once + +#ifndef __ATLAPP_H__ + #error atlframe.h requires atlapp.h to be included first +#endif + +#ifndef __ATLWIN_H__ + #error atlframe.h requires atlwin.h to be included first +#endif + + +/////////////////////////////////////////////////////////////////////////////// +// Classes in this file: +// +// CFrameWindowImpl +// CMDIWindow +// CMDIFrameWindowImpl +// CMDIChildWindowImpl +// COwnerDraw +// CUpdateUIBase +// CUpdateUI +// CDynamicUpdateUI +// CAutoUpdateUI +// CDialogResize +// CDynamicDialogLayout +// CDoubleBufferImpl +// CDoubleBufferWindowImpl +// +// Global functions: +// AtlCreateSimpleToolBar() + + +namespace WTL +{ + +/////////////////////////////////////////////////////////////////////////////// +// CFrameWndClassInfo - Manages frame window Windows class information + +class CFrameWndClassInfo +{ +public: + enum { cchAutoName = 5 + sizeof(void*) * 2 }; // sizeof(void*) * 2 is the number of digits %p outputs + WNDCLASSEX m_wc; + LPCTSTR m_lpszOrigName; + WNDPROC pWndProc; + LPCTSTR m_lpszCursorID; + BOOL m_bSystemCursor; + ATOM m_atom; + TCHAR m_szAutoName[cchAutoName]; + UINT m_uCommonResourceID; + + ATOM Register(WNDPROC* pProc) + { + if (m_atom == 0) + { + CWindowCreateCriticalSectionLock lock; + if(FAILED(lock.Lock())) + { + ATLTRACE2(atlTraceUI, 0, _T("ERROR : Unable to lock critical section in CFrameWndClassInfo::Register.\n")); + ATLASSERT(FALSE); + return 0; + } + + if(m_atom == 0) + { + HINSTANCE hInst = ModuleHelper::GetModuleInstance(); + + if (m_lpszOrigName != NULL) + { + ATLASSERT(pProc != NULL); + LPCTSTR lpsz = m_wc.lpszClassName; + WNDPROC proc = m_wc.lpfnWndProc; + + WNDCLASSEX wc = { sizeof(WNDCLASSEX) }; + // try process local class first + if(!::GetClassInfoEx(ModuleHelper::GetModuleInstance(), m_lpszOrigName, &wc)) + { + // try global class + if(!::GetClassInfoEx(NULL, m_lpszOrigName, &wc)) + { + lock.Unlock(); + return 0; + } + } + m_wc = wc; + pWndProc = m_wc.lpfnWndProc; + m_wc.lpszClassName = lpsz; + m_wc.lpfnWndProc = proc; + } + else + { + m_wc.hCursor = ::LoadCursor(m_bSystemCursor ? NULL : hInst, m_lpszCursorID); + } + + m_wc.hInstance = hInst; + m_wc.style &= ~CS_GLOBALCLASS; // we don't register global classes + if (m_wc.lpszClassName == NULL) + { + _stprintf_s(m_szAutoName, cchAutoName, _T("ATL:%p"), &m_wc); + m_wc.lpszClassName = m_szAutoName; + } + + WNDCLASSEX wcTemp = m_wc; + m_atom = (ATOM)::GetClassInfoEx(m_wc.hInstance, m_wc.lpszClassName, &wcTemp); + if (m_atom == 0) + { + if(m_uCommonResourceID != 0) // use it if not zero + { + m_wc.hIcon = (HICON)::LoadImage(ModuleHelper::GetResourceInstance(), + MAKEINTRESOURCE(m_uCommonResourceID), IMAGE_ICON, + ::GetSystemMetrics(SM_CXICON), ::GetSystemMetrics(SM_CYICON), LR_DEFAULTCOLOR); + m_wc.hIconSm = (HICON)::LoadImage(ModuleHelper::GetResourceInstance(), + MAKEINTRESOURCE(m_uCommonResourceID), IMAGE_ICON, + ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR); + } + m_atom = ::RegisterClassEx(&m_wc); + } + } + + lock.Unlock(); + } + + if (m_lpszOrigName != NULL) + { + ATLASSERT(pProc != NULL); + ATLASSERT(pWndProc != NULL); + *pProc = pWndProc; + } + + return m_atom; + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// Macros for declaring frame window WNDCLASS + +#define DECLARE_FRAME_WND_CLASS(WndClassName, uCommonResourceID) \ +static WTL::CFrameWndClassInfo& GetWndClassInfo() \ +{ \ + static WTL::CFrameWndClassInfo wc = \ + { \ + { sizeof(WNDCLASSEX), 0, StartWindowProc, \ + 0, 0, NULL, NULL, NULL, (HBRUSH)(COLOR_WINDOW + 1), NULL, WndClassName, NULL }, \ + NULL, NULL, IDC_ARROW, TRUE, 0, _T(""), uCommonResourceID \ + }; \ + return wc; \ +} + +#define DECLARE_FRAME_WND_CLASS_EX(WndClassName, uCommonResourceID, style, bkgnd) \ +static WTL::CFrameWndClassInfo& GetWndClassInfo() \ +{ \ + static WTL::CFrameWndClassInfo wc = \ + { \ + { sizeof(WNDCLASSEX), style, StartWindowProc, \ + 0, 0, NULL, NULL, NULL, (HBRUSH)(bkgnd + 1), NULL, WndClassName, NULL }, \ + NULL, NULL, IDC_ARROW, TRUE, 0, _T(""), uCommonResourceID \ + }; \ + return wc; \ +} + +#define DECLARE_FRAME_WND_SUPERCLASS(WndClassName, OrigWndClassName, uCommonResourceID) \ +static WTL::CFrameWndClassInfo& GetWndClassInfo() \ +{ \ + static WTL::CFrameWndClassInfo wc = \ + { \ + { sizeof(WNDCLASSEX), 0, StartWindowProc, \ + 0, 0, NULL, NULL, NULL, NULL, NULL, WndClassName, NULL }, \ + OrigWndClassName, NULL, NULL, TRUE, 0, _T(""), uCommonResourceID \ + }; \ + return wc; \ +} + +// These are for templated classes +#define DECLARE_FRAME_WND_CLASS2(WndClassName, EnclosingClass, uCommonResourceID) \ +static WTL::CFrameWndClassInfo& GetWndClassInfo() \ +{ \ + static WTL::CFrameWndClassInfo wc = \ + { \ + { sizeof(WNDCLASSEX), 0, EnclosingClass::StartWindowProc, \ + 0, 0, NULL, NULL, NULL, (HBRUSH)(COLOR_WINDOW + 1), NULL, WndClassName, NULL }, \ + NULL, NULL, IDC_ARROW, TRUE, 0, _T(""), uCommonResourceID \ + }; \ + return wc; \ +} + +#define DECLARE_FRAME_WND_CLASS_EX2(WndClassName, EnclosingClass, uCommonResourceID, style, bkgnd) \ +static WTL::CFrameWndClassInfo& GetWndClassInfo() \ +{ \ + static WTL::CFrameWndClassInfo wc = \ + { \ + { sizeof(WNDCLASSEX), style, EnclosingClass::StartWindowProc, \ + 0, 0, NULL, NULL, NULL, (HBRUSH)(bkgnd + 1), NULL, WndClassName, NULL }, \ + NULL, NULL, IDC_ARROW, TRUE, 0, _T(""), uCommonResourceID \ + }; \ + return wc; \ +} + +#define DECLARE_FRAME_WND_SUPERCLASS2(WndClassName, EnclosingClass, OrigWndClassName, uCommonResourceID) \ +static WTL::CFrameWndClassInfo& GetWndClassInfo() \ +{ \ + static WTL::CFrameWndClassInfo wc = \ + { \ + { sizeof(WNDCLASSEX), 0, EnclosingClass::StartWindowProc, \ + 0, 0, NULL, NULL, NULL, NULL, NULL, WndClassName, NULL }, \ + OrigWndClassName, NULL, NULL, TRUE, 0, _T(""), uCommonResourceID \ + }; \ + return wc; \ +} + + +/////////////////////////////////////////////////////////////////////////////// +// CFrameWindowImpl + +// Client window command chaining macro (only for frame windows) +#define CHAIN_CLIENT_COMMANDS() \ + if((uMsg == WM_COMMAND) && (this->m_hWndClient != NULL)) \ + ::SendMessage(this->m_hWndClient, uMsg, wParam, lParam); + +// standard toolbar styles +#define ATL_SIMPLE_TOOLBAR_STYLE \ + (WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | TBSTYLE_TOOLTIPS) +// toolbar in a rebar pane +#define ATL_SIMPLE_TOOLBAR_PANE_STYLE \ + (WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | CCS_NODIVIDER | CCS_NORESIZE | CCS_NOPARENTALIGN | TBSTYLE_TOOLTIPS | TBSTYLE_FLAT) +// standard rebar styles + #define ATL_SIMPLE_REBAR_STYLE \ + (WS_CHILD | WS_VISIBLE | WS_BORDER | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | RBS_VARHEIGHT | RBS_BANDBORDERS | RBS_AUTOSIZE) +// rebar without borders + #define ATL_SIMPLE_REBAR_NOBORDER_STYLE \ + (WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | RBS_VARHEIGHT | RBS_BANDBORDERS | RBS_AUTOSIZE | CCS_NODIVIDER) + +// command bar support +#if !defined(__ATLCTRLW_H__) + +#define CBRM_GETCMDBAR (WM_USER + 301) // returns command bar HWND +#define CBRM_GETMENU (WM_USER + 302) // returns loaded or attached menu +#define CBRM_TRACKPOPUPMENU (WM_USER + 303) // displays a popup menu + +struct _AtlFrameWnd_CmdBarPopupMenu +{ + int cbSize; + HMENU hMenu; + UINT uFlags; + int x; + int y; + LPTPMPARAMS lptpm; +}; + +#define CBRPOPUPMENU _AtlFrameWnd_CmdBarPopupMenu + +#endif // !defined(__ATLCTRLW_H__) + + +template +class ATL_NO_VTABLE CFrameWindowImplBase : public ATL::CWindowImplBaseT< TBase, TWinTraits > +{ +public: + typedef CFrameWindowImplBase _thisClass; + DECLARE_FRAME_WND_CLASS2(NULL, _thisClass, 0) + + struct _ChevronMenuInfo + { + HMENU hMenu; + LPNMREBARCHEVRON lpnm; + bool bCmdBar; + }; + +// Data members + HWND m_hWndToolBar; + HWND m_hWndStatusBar; + HWND m_hWndClient; + + HACCEL m_hAccel; + +// Constructor + CFrameWindowImplBase() : + m_hWndToolBar(NULL), + m_hWndStatusBar(NULL), + m_hWndClient(NULL), + m_hAccel(NULL) + { } + +// Methods + HWND Create(HWND hWndParent, ATL::_U_RECT rect, LPCTSTR szWindowName, DWORD dwStyle, DWORD dwExStyle, ATL::_U_MENUorID MenuOrID, ATOM atom, LPVOID lpCreateParam) + { + ATLASSERT(this->m_hWnd == NULL); + + // Allocate the thunk structure here, where we can fail gracefully. + BOOL bRet = this->m_thunk.Init(NULL, NULL); + if(bRet == FALSE) + { + ::SetLastError(ERROR_OUTOFMEMORY); + return NULL; + } + + if(atom == 0) + return NULL; + + ModuleHelper::AddCreateWndData(&this->m_thunk.cd, this); + + if((MenuOrID.m_hMenu == NULL) && (dwStyle & WS_CHILD)) + MenuOrID.m_hMenu = (HMENU)(UINT_PTR)this; + if(rect.m_lpRect == NULL) + rect.m_lpRect = &TBase::rcDefault; + + HWND hWnd = ::CreateWindowEx(dwExStyle, MAKEINTATOM(atom), szWindowName, + dwStyle, rect.m_lpRect->left, rect.m_lpRect->top, rect.m_lpRect->right - rect.m_lpRect->left, + rect.m_lpRect->bottom - rect.m_lpRect->top, hWndParent, MenuOrID.m_hMenu, + ModuleHelper::GetModuleInstance(), lpCreateParam); + + ATLASSERT((hWnd == NULL) || (this->m_hWnd == hWnd)); + + return hWnd; + } + + static HWND CreateSimpleToolBarCtrl(HWND hWndParent, UINT nResourceID, BOOL bInitialSeparator = FALSE, + DWORD dwStyle = ATL_SIMPLE_TOOLBAR_STYLE, UINT nID = ATL_IDW_TOOLBAR) + { + HINSTANCE hInst = ModuleHelper::GetResourceInstance(); + HRSRC hRsrc = ::FindResource(hInst, MAKEINTRESOURCE(nResourceID), RT_TOOLBAR); + if (hRsrc == NULL) + return NULL; + + HGLOBAL hGlobal = ::LoadResource(hInst, hRsrc); + if (hGlobal == NULL) + return NULL; + + _AtlToolBarData* pData = (_AtlToolBarData*)::LockResource(hGlobal); + if (pData == NULL) + return NULL; + ATLASSERT(pData->wVersion == 1); + + WORD* pItems = pData->items(); + int nItems = pData->wItemCount + (bInitialSeparator ? 1 : 0); + ATL::CTempBuffer buff; + TBBUTTON* pTBBtn = buff.Allocate(nItems); + ATLASSERT(pTBBtn != NULL); + if(pTBBtn == NULL) + return NULL; + + const int cxSeparator = 8; + + // set initial separator (half width) + if(bInitialSeparator) + { + pTBBtn[0].iBitmap = cxSeparator / 2; + pTBBtn[0].idCommand = 0; + pTBBtn[0].fsState = 0; + pTBBtn[0].fsStyle = BTNS_SEP; + pTBBtn[0].dwData = 0; + pTBBtn[0].iString = 0; + } + + int nBmp = 0; + for(int i = 0, j = bInitialSeparator ? 1 : 0; i < pData->wItemCount; i++, j++) + { + if(pItems[i] != 0) + { + pTBBtn[j].iBitmap = nBmp++; + pTBBtn[j].idCommand = pItems[i]; + pTBBtn[j].fsState = TBSTATE_ENABLED; + pTBBtn[j].fsStyle = BTNS_BUTTON; + pTBBtn[j].dwData = 0; + pTBBtn[j].iString = 0; + } + else + { + pTBBtn[j].iBitmap = cxSeparator; + pTBBtn[j].idCommand = 0; + pTBBtn[j].fsState = 0; + pTBBtn[j].fsStyle = BTNS_SEP; + pTBBtn[j].dwData = 0; + pTBBtn[j].iString = 0; + } + } + + HWND hWnd = ::CreateWindowEx(0, TOOLBARCLASSNAME, NULL, dwStyle, 0, 0, 100, 100, hWndParent, (HMENU)LongToHandle(nID), ModuleHelper::GetModuleInstance(), NULL); + if(hWnd == NULL) + { + ATLASSERT(FALSE); + return NULL; + } + + ::SendMessage(hWnd, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0L); + + // check if font is taller than our bitmaps + CFontHandle font = (HFONT)::SendMessage(hWnd, WM_GETFONT, 0, 0L); + if(font.IsNull()) + font = (HFONT)::GetStockObject(SYSTEM_FONT); + LOGFONT lf = {}; + font.GetLogFont(lf); + WORD cyFontHeight = (WORD)abs(lf.lfHeight); + + WORD bitsPerPixel = AtlGetBitmapResourceBitsPerPixel(nResourceID); + if(bitsPerPixel > 4) + { + COLORREF crMask = CLR_DEFAULT; + if(bitsPerPixel == 32) + { + // 32-bit color bitmap with alpha channel (valid for Windows XP and later) + crMask = CLR_NONE; + } + HIMAGELIST hImageList = ImageList_LoadImage(ModuleHelper::GetResourceInstance(), MAKEINTRESOURCE(nResourceID), pData->wWidth, 1, crMask, IMAGE_BITMAP, LR_CREATEDIBSECTION | LR_DEFAULTSIZE); + ATLASSERT(hImageList != NULL); + ::SendMessage(hWnd, TB_SETIMAGELIST, 0, (LPARAM)hImageList); + } + else + { + TBADDBITMAP tbab = {}; + tbab.hInst = hInst; + tbab.nID = nResourceID; + ::SendMessage(hWnd, TB_ADDBITMAP, nBmp, (LPARAM)&tbab); + } + + ::SendMessage(hWnd, TB_ADDBUTTONS, nItems, (LPARAM)pTBBtn); + ::SendMessage(hWnd, TB_SETBITMAPSIZE, 0, MAKELONG(pData->wWidth, __max(pData->wHeight, cyFontHeight))); + const int cxyButtonMargin = 7; + ::SendMessage(hWnd, TB_SETBUTTONSIZE, 0, MAKELONG(pData->wWidth + cxyButtonMargin, __max(pData->wHeight, cyFontHeight) + cxyButtonMargin)); + + return hWnd; + } + + static HWND CreateSimpleReBarCtrl(HWND hWndParent, DWORD dwStyle = ATL_SIMPLE_REBAR_STYLE, UINT nID = ATL_IDW_TOOLBAR) + { + // Ensure style combinations for proper rebar painting + if(dwStyle & CCS_NODIVIDER && (dwStyle & WS_BORDER)) + dwStyle &= ~WS_BORDER; + else if(!(dwStyle & WS_BORDER) && !(dwStyle & CCS_NODIVIDER)) + dwStyle |= CCS_NODIVIDER; + + // Create rebar window + HWND hWndReBar = ::CreateWindowEx(0, REBARCLASSNAME, NULL, dwStyle, 0, 0, 100, 100, hWndParent, (HMENU)LongToHandle(nID), ModuleHelper::GetModuleInstance(), NULL); + if(hWndReBar == NULL) + { + ATLTRACE2(atlTraceUI, 0, _T("Failed to create rebar.\n")); + return NULL; + } + + // Initialize and send the REBARINFO structure + REBARINFO rbi = { sizeof(REBARINFO), 0 }; + if(::SendMessage(hWndReBar, RB_SETBARINFO, 0, (LPARAM)&rbi) == 0) + { + ATLTRACE2(atlTraceUI, 0, _T("Failed to initialize rebar.\n")); + ::DestroyWindow(hWndReBar); + return NULL; + } + + return hWndReBar; + } + + BOOL CreateSimpleReBar(DWORD dwStyle = ATL_SIMPLE_REBAR_STYLE, UINT nID = ATL_IDW_TOOLBAR) + { + ATLASSERT(!::IsWindow(m_hWndToolBar)); + m_hWndToolBar = CreateSimpleReBarCtrl(this->m_hWnd, dwStyle, nID); + return (m_hWndToolBar != NULL); + } + + static BOOL AddSimpleReBarBandCtrl(HWND hWndReBar, HWND hWndBand, int nID = 0, LPCTSTR lpstrTitle = NULL, BOOL bNewRow = FALSE, int cxWidth = 0, BOOL bFullWidthAlways = FALSE) + { + ATLASSERT(::IsWindow(hWndReBar)); // must be already created +#ifdef _DEBUG + // block - check if this is really a rebar + { + TCHAR lpszClassName[sizeof(REBARCLASSNAME)] = {}; + ::GetClassName(hWndReBar, lpszClassName, sizeof(REBARCLASSNAME)); + ATLASSERT(lstrcmp(lpszClassName, REBARCLASSNAME) == 0); + } +#endif // _DEBUG + ATLASSERT(::IsWindow(hWndBand)); // must be already created + + // Get number of buttons on the toolbar + int nBtnCount = (int)::SendMessage(hWndBand, TB_BUTTONCOUNT, 0, 0L); + + // Set band info structure + REBARBANDINFO rbBand = { RunTimeHelper::SizeOf_REBARBANDINFO() }; + rbBand.fMask = RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_STYLE | RBBIM_ID | RBBIM_SIZE | RBBIM_IDEALSIZE; + if(lpstrTitle != NULL) + rbBand.fMask |= RBBIM_TEXT; + rbBand.fStyle = RBBS_CHILDEDGE; + if(nBtnCount > 0) // add chevron style for toolbar with buttons + rbBand.fStyle |= RBBS_USECHEVRON; + if(bNewRow) + rbBand.fStyle |= RBBS_BREAK; + + rbBand.lpText = (LPTSTR)lpstrTitle; + rbBand.hwndChild = hWndBand; + if(nID == 0) // calc band ID + nID = ATL_IDW_BAND_FIRST + (int)::SendMessage(hWndReBar, RB_GETBANDCOUNT, 0, 0L); + rbBand.wID = nID; + + // Calculate the size of the band + BOOL bRet = FALSE; + RECT rcTmp = {}; + if(nBtnCount > 0) + { + bRet = (BOOL)::SendMessage(hWndBand, TB_GETITEMRECT, nBtnCount - 1, (LPARAM)&rcTmp); + ATLASSERT(bRet); + rbBand.cx = (cxWidth != 0) ? cxWidth : rcTmp.right; + rbBand.cyMinChild = rcTmp.bottom - rcTmp.top; + if(bFullWidthAlways) + { + rbBand.cxMinChild = rbBand.cx; + } + else if(lpstrTitle == NULL) + { + bRet = (BOOL)::SendMessage(hWndBand, TB_GETITEMRECT, 0, (LPARAM)&rcTmp); + ATLASSERT(bRet); + rbBand.cxMinChild = rcTmp.right; + } + else + { + rbBand.cxMinChild = 0; + } + } + else // no buttons, either not a toolbar or really has no buttons + { + bRet = ::GetWindowRect(hWndBand, &rcTmp); + ATLASSERT(bRet); + rbBand.cx = (cxWidth != 0) ? cxWidth : (rcTmp.right - rcTmp.left); + rbBand.cxMinChild = bFullWidthAlways ? rbBand.cx : 0; + rbBand.cyMinChild = rcTmp.bottom - rcTmp.top; + } + + rbBand.cxIdeal = rbBand.cx; + + // Add the band + LRESULT lRes = ::SendMessage(hWndReBar, RB_INSERTBAND, (WPARAM)-1, (LPARAM)&rbBand); + if(lRes == 0) + { + ATLTRACE2(atlTraceUI, 0, _T("Failed to add a band to the rebar.\n")); + return FALSE; + } + + DWORD dwExStyle = (DWORD)::SendMessage(hWndBand, TB_GETEXTENDEDSTYLE, 0, 0L); + ::SendMessage(hWndBand, TB_SETEXTENDEDSTYLE, 0, dwExStyle | TBSTYLE_EX_HIDECLIPPEDBUTTONS); + + return TRUE; + } + + BOOL AddSimpleReBarBand(HWND hWndBand, LPCTSTR lpstrTitle = NULL, BOOL bNewRow = FALSE, int cxWidth = 0, BOOL bFullWidthAlways = FALSE) + { + ATLASSERT(::IsWindow(m_hWndToolBar)); // must be an existing rebar + ATLASSERT(::IsWindow(hWndBand)); // must be created + return AddSimpleReBarBandCtrl(m_hWndToolBar, hWndBand, 0, lpstrTitle, bNewRow, cxWidth, bFullWidthAlways); + } + + void SizeSimpleReBarBands() + { + ATLASSERT(::IsWindow(m_hWndToolBar)); // must be an existing rebar + + int nCount = (int)::SendMessage(m_hWndToolBar, RB_GETBANDCOUNT, 0, 0L); + + for(int i = 0; i < nCount; i++) + { + REBARBANDINFO rbBand = { RunTimeHelper::SizeOf_REBARBANDINFO() }; + rbBand.fMask = RBBIM_SIZE; + BOOL bRet = (BOOL)::SendMessage(m_hWndToolBar, RB_GETBANDINFO, i, (LPARAM)&rbBand); + ATLASSERT(bRet); + RECT rect = {}; + ::SendMessage(m_hWndToolBar, RB_GETBANDBORDERS, i, (LPARAM)&rect); + rbBand.cx += rect.left + rect.right; + bRet = (BOOL)::SendMessage(m_hWndToolBar, RB_SETBANDINFO, i, (LPARAM)&rbBand); + ATLASSERT(bRet); + } + } + + BOOL CreateSimpleStatusBar(LPCTSTR lpstrText, DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | SBARS_SIZEGRIP, UINT nID = ATL_IDW_STATUS_BAR) + { + ATLASSERT(!::IsWindow(m_hWndStatusBar)); + m_hWndStatusBar = ::CreateStatusWindow(dwStyle, lpstrText, this->m_hWnd, nID); + return (m_hWndStatusBar != NULL); + } + + BOOL CreateSimpleStatusBar(UINT nTextID = ATL_IDS_IDLEMESSAGE, DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | SBARS_SIZEGRIP, UINT nID = ATL_IDW_STATUS_BAR) + { + const int cchMax = 128; // max text length is 127 for status bars (+1 for null) + TCHAR szText[cchMax] = {}; + ::LoadString(ModuleHelper::GetResourceInstance(), nTextID, szText, cchMax); + return CreateSimpleStatusBar(szText, dwStyle, nID); + } + + void UpdateLayout(BOOL bResizeBars = TRUE) + { + RECT rect = {}; + this->GetClientRect(&rect); + + // position bars and offset their dimensions + UpdateBarsPosition(rect, bResizeBars); + + // resize client window + if(m_hWndClient != NULL) + ::SetWindowPos(m_hWndClient, NULL, rect.left, rect.top, + rect.right - rect.left, rect.bottom - rect.top, + SWP_NOZORDER | SWP_NOACTIVATE); + } + + void UpdateBarsPosition(RECT& rect, BOOL bResizeBars = TRUE) + { + // resize toolbar + if((m_hWndToolBar != NULL) && ((DWORD)::GetWindowLong(m_hWndToolBar, GWL_STYLE) & WS_VISIBLE)) + { + if(bResizeBars != FALSE) + { + ::SendMessage(m_hWndToolBar, WM_SIZE, 0, 0); + ::InvalidateRect(m_hWndToolBar, NULL, TRUE); + } + RECT rectTB = {}; + ::GetWindowRect(m_hWndToolBar, &rectTB); + rect.top += rectTB.bottom - rectTB.top; + } + + // resize status bar + if((m_hWndStatusBar != NULL) && ((DWORD)::GetWindowLong(m_hWndStatusBar, GWL_STYLE) & WS_VISIBLE)) + { + if(bResizeBars != FALSE) + ::SendMessage(m_hWndStatusBar, WM_SIZE, 0, 0); + RECT rectSB = {}; + ::GetWindowRect(m_hWndStatusBar, &rectSB); + rect.bottom -= rectSB.bottom - rectSB.top; + } + } + + BOOL PreTranslateMessage(MSG* pMsg) + { + if((m_hAccel != NULL) && ::TranslateAccelerator(this->m_hWnd, m_hAccel, pMsg)) + return TRUE; + return FALSE; + } + + BEGIN_MSG_MAP(CFrameWindowImplBase) + MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground) + MESSAGE_HANDLER(WM_MENUSELECT, OnMenuSelect) + MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus) + MESSAGE_HANDLER(WM_DESTROY, OnDestroy) + NOTIFY_CODE_HANDLER(TTN_GETDISPINFOA, OnToolTipTextA) + NOTIFY_CODE_HANDLER(TTN_GETDISPINFOW, OnToolTipTextW) + END_MSG_MAP() + + LRESULT OnEraseBackground(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) + { + if(m_hWndClient != NULL) // view will paint itself instead + return 1; + + bHandled = FALSE; + return 0; + } + + LRESULT OnMenuSelect(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled) + { + bHandled = FALSE; + + if(m_hWndStatusBar == NULL) + return 1; + + WORD wFlags = HIWORD(wParam); + if((wFlags == 0xFFFF) && (lParam == NULL)) // menu closing + { + ::SendMessage(m_hWndStatusBar, SB_SIMPLE, FALSE, 0L); + } + else + { + const int cchBuff = 256; + TCHAR szBuff[cchBuff] = {}; + if(!(wFlags & MF_POPUP)) + { + WORD wID = LOWORD(wParam); + // check for special cases + if((wID >= 0xF000) && (wID < 0xF1F0)) // system menu IDs + wID = (WORD)(((wID - 0xF000) >> 4) + ATL_IDS_SCFIRST); + else if((wID >= ID_FILE_MRU_FIRST) && (wID <= ID_FILE_MRU_LAST)) // MRU items + wID = ATL_IDS_MRU_FILE; + else if((wID >= ATL_IDM_FIRST_MDICHILD) && (wID <= ATL_IDM_LAST_MDICHILD)) // MDI child windows + wID = ATL_IDS_MDICHILD; + + int nRet = ::LoadString(ModuleHelper::GetResourceInstance(), wID, szBuff, cchBuff); + for(int i = 0; i < nRet; i++) + { + if(szBuff[i] == _T('\n')) + { + szBuff[i] = 0; + break; + } + } + } + ::SendMessage(m_hWndStatusBar, SB_SIMPLE, TRUE, 0L); + ::SendMessage(m_hWndStatusBar, SB_SETTEXT, (255 | SBT_NOBORDERS), (LPARAM)szBuff); + } + + return 1; + } + + LRESULT OnSetFocus(UINT, WPARAM, LPARAM, BOOL& bHandled) + { + if(m_hWndClient != NULL) + ::SetFocus(m_hWndClient); + + bHandled = FALSE; + return 1; + } + + LRESULT OnDestroy(UINT, WPARAM, LPARAM, BOOL& bHandled) + { + if((this->GetStyle() & (WS_CHILD | WS_POPUP)) == 0) + ::PostQuitMessage(1); + + bHandled = FALSE; + return 1; + } + + LRESULT OnToolTipTextA(int idCtrl, LPNMHDR pnmh, BOOL& /*bHandled*/) + { + LPNMTTDISPINFOA pDispInfo = (LPNMTTDISPINFOA)pnmh; + if((idCtrl != 0) && !(pDispInfo->uFlags & TTF_IDISHWND)) + { + const int cchBuff = 256; + char szBuff[cchBuff] = {}; + int nRet = ::LoadStringA(ModuleHelper::GetResourceInstance(), idCtrl, szBuff, cchBuff); + for(int i = 0; i < nRet; i++) + { + if(szBuff[i] == '\n') + { + ATL::Checked::strncpy_s(pDispInfo->szText, _countof(pDispInfo->szText), &szBuff[i + 1], _TRUNCATE); + break; + } + } + if(nRet > 0) // string was loaded, save it + pDispInfo->uFlags |= TTF_DI_SETITEM; + } + + return 0; + } + + LRESULT OnToolTipTextW(int idCtrl, LPNMHDR pnmh, BOOL& /*bHandled*/) + { + LPNMTTDISPINFOW pDispInfo = (LPNMTTDISPINFOW)pnmh; + if((idCtrl != 0) && !(pDispInfo->uFlags & TTF_IDISHWND)) + { + const int cchBuff = 256; + wchar_t szBuff[cchBuff] = {}; + int nRet = ::LoadStringW(ModuleHelper::GetResourceInstance(), idCtrl, szBuff, cchBuff); + for(int i = 0; i < nRet; i++) + { + if(szBuff[i] == L'\n') + { + ATL::Checked::wcsncpy_s(pDispInfo->szText, _countof(pDispInfo->szText), &szBuff[i + 1], _TRUNCATE); + break; + } + } + if(nRet > 0) // string was loaded, save it + pDispInfo->uFlags |= TTF_DI_SETITEM; + } + + return 0; + } + +// Implementation - chevron menu support + bool PrepareChevronMenu(_ChevronMenuInfo& cmi) + { + // get rebar and toolbar + REBARBANDINFO rbbi = { RunTimeHelper::SizeOf_REBARBANDINFO() }; + rbbi.fMask = RBBIM_CHILD; + BOOL bRet = (BOOL)::SendMessage(cmi.lpnm->hdr.hwndFrom, RB_GETBANDINFO, cmi.lpnm->uBand, (LPARAM)&rbbi); + ATLASSERT(bRet); + + // assume the band is a toolbar + ATL::CWindow wnd = rbbi.hwndChild; + int nCount = (int)wnd.SendMessage(TB_BUTTONCOUNT); + if(nCount <= 0) // probably not a toolbar + return false; + + // check if it's a command bar + CMenuHandle menuCmdBar = (HMENU)wnd.SendMessage(CBRM_GETMENU); + cmi.bCmdBar = (menuCmdBar.m_hMenu != NULL); + + // build a menu from hidden items + CMenuHandle menu; + bRet = menu.CreatePopupMenu(); + ATLASSERT(bRet); + RECT rcClient = {}; + bRet = wnd.GetClientRect(&rcClient); + ATLASSERT(bRet); + for(int i = 0; i < nCount; i++) + { + TBBUTTON tbb = {}; + bRet = (BOOL)wnd.SendMessage(TB_GETBUTTON, i, (LPARAM)&tbb); + ATLASSERT(bRet); + // skip hidden buttons + if((tbb.fsState & TBSTATE_HIDDEN) != 0) + continue; + RECT rcButton = {}; + bRet = (BOOL)wnd.SendMessage(TB_GETITEMRECT, i, (LPARAM)&rcButton); + ATLASSERT(bRet); + bool bEnabled = ((tbb.fsState & TBSTATE_ENABLED) != 0); + if((rcButton.right > rcClient.right) || (rcButton.bottom > rcClient.bottom)) + { + if(tbb.fsStyle & BTNS_SEP) + { + if(menu.GetMenuItemCount() > 0) + menu.AppendMenu(MF_SEPARATOR); + } + else if(cmi.bCmdBar) + { + const int cchBuff = 200; + TCHAR szBuff[cchBuff] = {}; + CMenuItemInfo mii; + mii.fMask = MIIM_TYPE | MIIM_SUBMENU; + mii.dwTypeData = szBuff; + mii.cch = cchBuff; + bRet = menuCmdBar.GetMenuItemInfo(i, TRUE, &mii); + ATLASSERT(bRet); + // Note: CmdBar currently supports only drop-down items + ATLASSERT(::IsMenu(mii.hSubMenu)); + bRet = menu.AppendMenu(MF_STRING | MF_POPUP | (bEnabled ? MF_ENABLED : MF_GRAYED), (UINT_PTR)mii.hSubMenu, mii.dwTypeData); + ATLASSERT(bRet); + } + else + { + // get button's text + const int cchBuff = 200; + TCHAR szBuff[cchBuff] = {}; + LPCTSTR lpstrText = szBuff; + TBBUTTONINFO tbbi = {}; + tbbi.cbSize = sizeof(TBBUTTONINFO); + tbbi.dwMask = TBIF_TEXT; + tbbi.pszText = szBuff; + tbbi.cchText = cchBuff; + if((wnd.SendMessage(TB_GETBUTTONINFO, tbb.idCommand, (LPARAM)&tbbi) == -1) || (szBuff[0] == 0)) + { + // no text for this button, try a resource string + lpstrText = _T(""); + int nRet = ::LoadString(ModuleHelper::GetResourceInstance(), tbb.idCommand, szBuff, cchBuff); + for(int n = 0; n < nRet; n++) + { + if(szBuff[n] == _T('\n')) + { + lpstrText = &szBuff[n + 1]; + break; + } + } + } + bRet = menu.AppendMenu(MF_STRING | (bEnabled ? MF_ENABLED : MF_GRAYED), tbb.idCommand, lpstrText); + ATLASSERT(bRet); + } + } + } + + if(menu.GetMenuItemCount() == 0) // no hidden buttons after all + { + menu.DestroyMenu(); + ::MessageBeep((UINT)-1); + return false; + } + + cmi.hMenu = menu; + return true; + } + + void DisplayChevronMenu(_ChevronMenuInfo& cmi) + { + // convert chevron rect to screen coordinates + ATL::CWindow wndFrom = cmi.lpnm->hdr.hwndFrom; + POINT pt = { cmi.lpnm->rc.left, cmi.lpnm->rc.bottom }; + wndFrom.MapWindowPoints(NULL, &pt, 1); + RECT rc = cmi.lpnm->rc; + wndFrom.MapWindowPoints(NULL, &rc); + // set up flags and rect + UINT uMenuFlags = TPM_LEFTBUTTON | TPM_VERTICAL | TPM_LEFTALIGN | TPM_TOPALIGN | TPM_VERPOSANIMATION; + TPMPARAMS TPMParams = {}; + TPMParams.cbSize = sizeof(TPMPARAMS); + TPMParams.rcExclude = rc; + // check if this window has a command bar + HWND hWndCmdBar = (HWND)::SendMessage(this->m_hWnd, CBRM_GETCMDBAR, 0, 0L); + if(::IsWindow(hWndCmdBar)) + { + CBRPOPUPMENU CBRPopupMenu = { sizeof(CBRPOPUPMENU), cmi.hMenu, uMenuFlags, pt.x, pt.y, &TPMParams }; + ::SendMessage(hWndCmdBar, CBRM_TRACKPOPUPMENU, 0, (LPARAM)&CBRPopupMenu); + } + else + { + CMenuHandle menu = cmi.hMenu; + menu.TrackPopupMenuEx(uMenuFlags, pt.x, pt.y, this->m_hWnd, &TPMParams); + } + } + + void CleanupChevronMenu(_ChevronMenuInfo& cmi) + { + CMenuHandle menu = cmi.hMenu; + // if menu is from a command bar, detach submenus so they are not destroyed + if(cmi.bCmdBar) + { + for(int i = menu.GetMenuItemCount() - 1; i >=0; i--) + menu.RemoveMenu(i, MF_BYPOSITION); + } + // destroy menu + menu.DestroyMenu(); + // convert chevron rect to screen coordinates + ATL::CWindow wndFrom = cmi.lpnm->hdr.hwndFrom; + RECT rc = cmi.lpnm->rc; + wndFrom.MapWindowPoints(NULL, &rc); + // eat next message if click is on the same button + MSG msg = {}; + if(::PeekMessage(&msg, this->m_hWnd, WM_LBUTTONDOWN, WM_LBUTTONDOWN, PM_NOREMOVE) && ::PtInRect(&rc, msg.pt)) + ::PeekMessage(&msg, this->m_hWnd, WM_LBUTTONDOWN, WM_LBUTTONDOWN, PM_REMOVE); + } +}; + + +template +class ATL_NO_VTABLE CFrameWindowImpl : public CFrameWindowImplBase< TBase, TWinTraits > +{ +public: + HWND Create(HWND hWndParent = NULL, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, + DWORD dwStyle = 0, DWORD dwExStyle = 0, + HMENU hMenu = NULL, LPVOID lpCreateParam = NULL) + { + ATOM atom = T::GetWndClassInfo().Register(&this->m_pfnSuperWindowProc); + + dwStyle = T::GetWndStyle(dwStyle); + dwExStyle = T::GetWndExStyle(dwExStyle); + + if(rect.m_lpRect == NULL) + rect.m_lpRect = &TBase::rcDefault; + + return CFrameWindowImplBase< TBase, TWinTraits >::Create(hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, hMenu, atom, lpCreateParam); + } + + HWND CreateEx(HWND hWndParent = NULL, ATL::_U_RECT rect = NULL, DWORD dwStyle = 0, DWORD dwExStyle = 0, LPVOID lpCreateParam = NULL) + { + const int cchName = 256; + TCHAR szWindowName[cchName] = {}; + ::LoadString(ModuleHelper::GetResourceInstance(), T::GetWndClassInfo().m_uCommonResourceID, szWindowName, cchName); + HMENU hMenu = ::LoadMenu(ModuleHelper::GetResourceInstance(), MAKEINTRESOURCE(T::GetWndClassInfo().m_uCommonResourceID)); + + T* pT = static_cast(this); + HWND hWnd = pT->Create(hWndParent, rect, szWindowName, dwStyle, dwExStyle, hMenu, lpCreateParam); + + if(hWnd != NULL) + this->m_hAccel = ::LoadAccelerators(ModuleHelper::GetResourceInstance(), MAKEINTRESOURCE(T::GetWndClassInfo().m_uCommonResourceID)); + + return hWnd; + } + + BOOL CreateSimpleToolBar(UINT nResourceID = 0, DWORD dwStyle = ATL_SIMPLE_TOOLBAR_STYLE, UINT nID = ATL_IDW_TOOLBAR) + { + if(nResourceID == 0) + nResourceID = T::GetWndClassInfo().m_uCommonResourceID; + ATLASSERT(!::IsWindow(this->m_hWndToolBar)); + this->m_hWndToolBar = T::CreateSimpleToolBarCtrl(this->m_hWnd, nResourceID, TRUE, dwStyle, nID); + return (this->m_hWndToolBar != NULL); + } + +// message map and handlers + typedef CFrameWindowImplBase< TBase, TWinTraits > _baseClass; + + BEGIN_MSG_MAP(CFrameWindowImpl) + MESSAGE_HANDLER(WM_SIZE, OnSize) +#ifndef _ATL_NO_REBAR_SUPPORT + NOTIFY_CODE_HANDLER(RBN_AUTOSIZE, OnReBarAutoSize) + NOTIFY_CODE_HANDLER(RBN_CHEVRONPUSHED, OnChevronPushed) +#endif // !_ATL_NO_REBAR_SUPPORT + CHAIN_MSG_MAP(_baseClass) + END_MSG_MAP() + + LRESULT OnSize(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) + { + if(wParam != SIZE_MINIMIZED) + { + T* pT = static_cast(this); + pT->UpdateLayout(); + } + bHandled = FALSE; + return 1; + } + +#ifndef _ATL_NO_REBAR_SUPPORT + LRESULT OnReBarAutoSize(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/) + { + T* pT = static_cast(this); + pT->UpdateLayout(FALSE); + return 0; + } + + LRESULT OnChevronPushed(int /*idCtrl*/, LPNMHDR pnmh, BOOL& bHandled) + { + T* pT = static_cast(this); + typename CFrameWindowImplBase< TBase, TWinTraits >::_ChevronMenuInfo cmi = { NULL, (LPNMREBARCHEVRON)pnmh, false }; + if(!pT->PrepareChevronMenu(cmi)) + { + bHandled = FALSE; + return 1; + } + // display a popup menu with hidden items + pT->DisplayChevronMenu(cmi); + // cleanup + pT->CleanupChevronMenu(cmi); + return 0; + } +#endif // !_ATL_NO_REBAR_SUPPORT +}; + + +/////////////////////////////////////////////////////////////////////////////// +// AtlCreateSimpleToolBar - helper for creating simple toolbars + +inline HWND AtlCreateSimpleToolBar(HWND hWndParent, UINT nResourceID, BOOL bInitialSeparator = FALSE, + DWORD dwStyle = ATL_SIMPLE_TOOLBAR_STYLE, UINT nID = ATL_IDW_TOOLBAR) +{ + return CFrameWindowImplBase<>::CreateSimpleToolBarCtrl(hWndParent, nResourceID, bInitialSeparator, dwStyle, nID); +} + + +/////////////////////////////////////////////////////////////////////////////// +// CMDIWindow + +#ifndef _WTL_MDIWINDOWMENU_TEXT + #define _WTL_MDIWINDOWMENU_TEXT _T("&Window") +#endif + +class CMDIWindow : public ATL::CWindow +{ +public: +// Data members + HWND m_hWndMDIClient; + HMENU m_hMenu; + +// Constructors + CMDIWindow(HWND hWnd = NULL) : ATL::CWindow(hWnd), m_hWndMDIClient(NULL), m_hMenu(NULL) + { } + + CMDIWindow& operator =(HWND hWnd) + { + m_hWnd = hWnd; + return *this; + } + +// Operations + HWND MDIGetActive(BOOL* lpbMaximized = NULL) + { + ATLASSERT(::IsWindow(m_hWndMDIClient)); + return (HWND)::SendMessage(m_hWndMDIClient, WM_MDIGETACTIVE, 0, (LPARAM)lpbMaximized); + } + + void MDIActivate(HWND hWndChildToActivate) + { + ATLASSERT(::IsWindow(m_hWndMDIClient)); + ATLASSERT(::IsWindow(hWndChildToActivate)); + ::SendMessage(m_hWndMDIClient, WM_MDIACTIVATE, (WPARAM)hWndChildToActivate, 0); + } + + void MDINext(HWND hWndChild, BOOL bPrevious = FALSE) + { + ATLASSERT(::IsWindow(m_hWndMDIClient)); + ATLASSERT((hWndChild == NULL) || ::IsWindow(hWndChild)); + ::SendMessage(m_hWndMDIClient, WM_MDINEXT, (WPARAM)hWndChild, (LPARAM)bPrevious); + } + + void MDIMaximize(HWND hWndChildToMaximize) + { + ATLASSERT(::IsWindow(m_hWndMDIClient)); + ATLASSERT(::IsWindow(hWndChildToMaximize)); + ::SendMessage(m_hWndMDIClient, WM_MDIMAXIMIZE, (WPARAM)hWndChildToMaximize, 0); + } + + void MDIRestore(HWND hWndChildToRestore) + { + ATLASSERT(::IsWindow(m_hWndMDIClient)); + ATLASSERT(::IsWindow(hWndChildToRestore)); + ::SendMessage(m_hWndMDIClient, WM_MDIRESTORE, (WPARAM)hWndChildToRestore, 0); + } + + void MDIDestroy(HWND hWndChildToDestroy) + { + ATLASSERT(::IsWindow(m_hWndMDIClient)); + ATLASSERT(::IsWindow(hWndChildToDestroy)); + ::SendMessage(m_hWndMDIClient, WM_MDIDESTROY, (WPARAM)hWndChildToDestroy, 0); + } + + BOOL MDICascade(UINT uFlags = 0) + { + ATLASSERT(::IsWindow(m_hWndMDIClient)); + return (BOOL)::SendMessage(m_hWndMDIClient, WM_MDICASCADE, (WPARAM)uFlags, 0); + } + + BOOL MDITile(UINT uFlags = MDITILE_HORIZONTAL) + { + ATLASSERT(::IsWindow(m_hWndMDIClient)); + return (BOOL)::SendMessage(m_hWndMDIClient, WM_MDITILE, (WPARAM)uFlags, 0); + } + + void MDIIconArrange() + { + ATLASSERT(::IsWindow(m_hWndMDIClient)); + ::SendMessage(m_hWndMDIClient, WM_MDIICONARRANGE, 0, 0); + } + + HMENU MDISetMenu(HMENU hMenuFrame, HMENU hMenuWindow) + { + ATLASSERT(::IsWindow(m_hWndMDIClient)); + return (HMENU)::SendMessage(m_hWndMDIClient, WM_MDISETMENU, (WPARAM)hMenuFrame, (LPARAM)hMenuWindow); + } + + HMENU MDIRefreshMenu() + { + ATLASSERT(::IsWindow(m_hWndMDIClient)); + return (HMENU)::SendMessage(m_hWndMDIClient, WM_MDIREFRESHMENU, 0, 0); + } + +// Additional operations + static HMENU GetStandardWindowMenu(HMENU hMenu) + { + int nCount = ::GetMenuItemCount(hMenu); + if(nCount == -1) + return NULL; + int nLen = ::GetMenuString(hMenu, nCount - 2, NULL, 0, MF_BYPOSITION); + if(nLen == 0) + return NULL; + ATL::CTempBuffer buff; + LPTSTR lpszText = buff.Allocate(nLen + 1); + if(lpszText == NULL) + return NULL; + if(::GetMenuString(hMenu, nCount - 2, lpszText, nLen + 1, MF_BYPOSITION) != nLen) + return NULL; + if(lstrcmp(lpszText, _WTL_MDIWINDOWMENU_TEXT) != 0) + return NULL; + return ::GetSubMenu(hMenu, nCount - 2); + } + + void SetMDIFrameMenu() + { + HMENU hWindowMenu = GetStandardWindowMenu(m_hMenu); + MDISetMenu(m_hMenu, hWindowMenu); + MDIRefreshMenu(); + ::DrawMenuBar(GetMDIFrame()); + } + + HWND GetMDIFrame() const + { + return ::GetParent(m_hWndMDIClient); + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CMDIFrameWindowImpl + +// MDI child command chaining macro (only for MDI frame windows) +#define CHAIN_MDI_CHILD_COMMANDS() \ + if(uMsg == WM_COMMAND) \ + { \ + HWND hWndChild = this->MDIGetActive(); \ + if(hWndChild != NULL) \ + ::SendMessage(hWndChild, uMsg, wParam, lParam); \ + } + +template +class ATL_NO_VTABLE CMDIFrameWindowImpl : public CFrameWindowImplBase +{ +public: + HWND Create(HWND hWndParent = NULL, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, + DWORD dwStyle = 0, DWORD dwExStyle = 0, + HMENU hMenu = NULL, LPVOID lpCreateParam = NULL) + { + this->m_hMenu = hMenu; + ATOM atom = T::GetWndClassInfo().Register(&this->m_pfnSuperWindowProc); + + dwStyle = T::GetWndStyle(dwStyle); + dwExStyle = T::GetWndExStyle(dwExStyle); + + if(rect.m_lpRect == NULL) + rect.m_lpRect = &TBase::rcDefault; + + return CFrameWindowImplBase::Create(hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, hMenu, atom, lpCreateParam); + } + + HWND CreateEx(HWND hWndParent = NULL, ATL::_U_RECT rect = NULL, DWORD dwStyle = 0, DWORD dwExStyle = 0, LPVOID lpCreateParam = NULL) + { + const int cchName = 256; + TCHAR szWindowName[cchName] = {}; + ::LoadString(ModuleHelper::GetResourceInstance(), T::GetWndClassInfo().m_uCommonResourceID, szWindowName, cchName); + HMENU hMenu = ::LoadMenu(ModuleHelper::GetResourceInstance(), MAKEINTRESOURCE(T::GetWndClassInfo().m_uCommonResourceID)); + + T* pT = static_cast(this); + HWND hWnd = pT->Create(hWndParent, rect, szWindowName, dwStyle, dwExStyle, hMenu, lpCreateParam); + + if(hWnd != NULL) + this->m_hAccel = ::LoadAccelerators(ModuleHelper::GetResourceInstance(), MAKEINTRESOURCE(T::GetWndClassInfo().m_uCommonResourceID)); + + return hWnd; + } + + BOOL CreateSimpleToolBar(UINT nResourceID = 0, DWORD dwStyle = ATL_SIMPLE_TOOLBAR_STYLE, UINT nID = ATL_IDW_TOOLBAR) + { + ATLASSERT(!::IsWindow(this->m_hWndToolBar)); + if(nResourceID == 0) + nResourceID = T::GetWndClassInfo().m_uCommonResourceID; + this->m_hWndToolBar = T::CreateSimpleToolBarCtrl(this->m_hWnd, nResourceID, TRUE, dwStyle, nID); + return (this->m_hWndToolBar != NULL); + } + + virtual WNDPROC GetWindowProc() + { + return MDIFrameWindowProc; + } + + static LRESULT CALLBACK MDIFrameWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) + { + CMDIFrameWindowImpl< T, TBase, TWinTraits >* pThis = (CMDIFrameWindowImpl< T, TBase, TWinTraits >*)hWnd; + // set a ptr to this message and save the old value + ATL::_ATL_MSG msg(pThis->m_hWnd, uMsg, wParam, lParam); + const ATL::_ATL_MSG* pOldMsg = pThis->m_pCurrentMsg; + pThis->m_pCurrentMsg = &msg; + // pass to the message map to process + LRESULT lRes = 0; + BOOL bRet = pThis->ProcessWindowMessage(pThis->m_hWnd, uMsg, wParam, lParam, lRes, 0); + // restore saved value for the current message + ATLASSERT(pThis->m_pCurrentMsg == &msg); + pThis->m_pCurrentMsg = pOldMsg; + // do the default processing if message was not handled + if(!bRet) + { + if(uMsg != WM_NCDESTROY) + { + lRes = pThis->DefWindowProc(uMsg, wParam, lParam); + } + else + { + // unsubclass, if needed + LONG_PTR pfnWndProc = ::GetWindowLongPtr(pThis->m_hWnd, GWLP_WNDPROC); + lRes = pThis->DefWindowProc(uMsg, wParam, lParam); + if((pThis->m_pfnSuperWindowProc != ::DefWindowProc) && (::GetWindowLongPtr(pThis->m_hWnd, GWLP_WNDPROC) == pfnWndProc)) + ::SetWindowLongPtr(pThis->m_hWnd, GWLP_WNDPROC, (LONG_PTR)pThis->m_pfnSuperWindowProc); + // mark window as destryed + pThis->m_dwState |= ATL::CWindowImplRoot< TBase >::WINSTATE_DESTROYED; + } + } + if((pThis->m_dwState & ATL::CWindowImplRoot< TBase >::WINSTATE_DESTROYED) && (pThis->m_pCurrentMsg == NULL)) + { + // clear out window handle + HWND hWndThis = pThis->m_hWnd; + pThis->m_hWnd = NULL; + pThis->m_dwState &= ~ATL::CWindowImplRoot< TBase >::WINSTATE_DESTROYED; + // clean up after window is destroyed + pThis->OnFinalMessage(hWndThis); + } + return lRes; + } + + // Overriden to call DefWindowProc which uses DefFrameProc + LRESULT DefWindowProc() + { + const ATL::_ATL_MSG* pMsg = this->m_pCurrentMsg; + LRESULT lRes = 0; + if (pMsg != NULL) + lRes = DefWindowProc(pMsg->message, pMsg->wParam, pMsg->lParam); + return lRes; + } + + LRESULT DefWindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam) + { + return ::DefFrameProc(this->m_hWnd, this->m_hWndMDIClient, uMsg, wParam, lParam); + } + + BOOL PreTranslateMessage(MSG* pMsg) + { + if(CFrameWindowImplBase::PreTranslateMessage(pMsg)) + return TRUE; + return ::TranslateMDISysAccel(this->m_hWndMDIClient, pMsg); + } + + HWND CreateMDIClient(HMENU hWindowMenu = NULL, UINT nID = ATL_IDW_CLIENT, UINT nFirstChildID = ATL_IDM_FIRST_MDICHILD) + { + DWORD dwStyle = WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | MDIS_ALLCHILDSTYLES; + DWORD dwExStyle = WS_EX_CLIENTEDGE; + + CLIENTCREATESTRUCT ccs = {}; + ccs.hWindowMenu = hWindowMenu; + ccs.idFirstChild = nFirstChildID; + + if((this->GetStyle() & (WS_HSCROLL | WS_VSCROLL)) != 0) + { + // parent MDI frame's scroll styles move to the MDICLIENT + dwStyle |= (this->GetStyle() & (WS_HSCROLL | WS_VSCROLL)); + + // fast way to turn off the scrollbar bits (without a resize) + this->ModifyStyle(WS_HSCROLL | WS_VSCROLL, 0, SWP_NOREDRAW | SWP_FRAMECHANGED); + } + + // Create MDICLIENT window + this->m_hWndClient = ::CreateWindowEx(dwExStyle, _T("MDIClient"), NULL, + dwStyle, 0, 0, 1, 1, this->m_hWnd, (HMENU)LongToHandle(nID), + ModuleHelper::GetModuleInstance(), (LPVOID)&ccs); + if (this->m_hWndClient == NULL) + { + ATLTRACE2(atlTraceUI, 0, _T("MDI Frame failed to create MDICLIENT.\n")); + return NULL; + } + + // Move it to the top of z-order + ::BringWindowToTop(this->m_hWndClient); + + // set as MDI client window + this->m_hWndMDIClient = this->m_hWndClient; + + // update to proper size + T* pT = static_cast(this); + pT->UpdateLayout(); + + return this->m_hWndClient; + } + + typedef CFrameWindowImplBase _baseClass; + + BEGIN_MSG_MAP(CMDIFrameWindowImpl) + MESSAGE_HANDLER(WM_SIZE, OnSize) + MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus) + MESSAGE_HANDLER(WM_MDISETMENU, OnMDISetMenu) +#ifndef _ATL_NO_REBAR_SUPPORT + NOTIFY_CODE_HANDLER(RBN_AUTOSIZE, OnReBarAutoSize) + NOTIFY_CODE_HANDLER(RBN_CHEVRONPUSHED, OnChevronPushed) +#endif // !_ATL_NO_REBAR_SUPPORT + CHAIN_MSG_MAP(_baseClass) + END_MSG_MAP() + + LRESULT OnSize(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + if(wParam != SIZE_MINIMIZED) + { + T* pT = static_cast(this); + pT->UpdateLayout(); + } + // message must be handled, otherwise DefFrameProc would resize the client again + return 0; + } + + LRESULT OnSetFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) + { + // don't allow CFrameWindowImplBase to handle this one + return DefWindowProc(uMsg, wParam, lParam); + } + + LRESULT OnMDISetMenu(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + this->SetMDIFrameMenu(); + return 0; + } + +#ifndef _ATL_NO_REBAR_SUPPORT + LRESULT OnReBarAutoSize(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/) + { + T* pT = static_cast(this); + pT->UpdateLayout(FALSE); + return 0; + } + + LRESULT OnChevronPushed(int /*idCtrl*/, LPNMHDR pnmh, BOOL& bHandled) + { + T* pT = static_cast(this); + typename CFrameWindowImplBase::_ChevronMenuInfo cmi = { NULL, (LPNMREBARCHEVRON)pnmh, false }; + if(!pT->PrepareChevronMenu(cmi)) + { + bHandled = FALSE; + return 1; + } + // display a popup menu with hidden items + pT->DisplayChevronMenu(cmi); + // cleanup + pT->CleanupChevronMenu(cmi); + return 0; + } +#endif // !_ATL_NO_REBAR_SUPPORT +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CMDIChildWindowImpl + +template +class ATL_NO_VTABLE CMDIChildWindowImpl : public CFrameWindowImplBase +{ +public: + HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, + DWORD dwStyle = 0, DWORD dwExStyle = 0, + UINT nMenuID = 0, LPVOID lpCreateParam = NULL) + { + ATOM atom = T::GetWndClassInfo().Register(&this->m_pfnSuperWindowProc); + + if(nMenuID != 0) + this->m_hMenu = ::LoadMenu(ModuleHelper::GetResourceInstance(), MAKEINTRESOURCE(nMenuID)); + + dwStyle = T::GetWndStyle(dwStyle); + dwExStyle = T::GetWndExStyle(dwExStyle); + + dwExStyle |= WS_EX_MDICHILD; // force this one + this->m_pfnSuperWindowProc = ::DefMDIChildProc; + this->m_hWndMDIClient = hWndParent; + ATLASSERT(::IsWindow(this->m_hWndMDIClient)); + + if(rect.m_lpRect == NULL) + rect.m_lpRect = &TBase::rcDefault; + + // If the currently active MDI child is maximized, we want to create this one maximized too + ATL::CWindow wndParent = hWndParent; + BOOL bMaximized = FALSE; + wndParent.SendMessage(WM_MDIGETACTIVE, 0, (LPARAM)&bMaximized); + if(bMaximized) + wndParent.SetRedraw(FALSE); + + HWND hWnd = CFrameWindowImplBase::Create(hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, (UINT)0U, atom, lpCreateParam); + + if(bMaximized) + { + // Maximize and redraw everything + if(hWnd != NULL) + this->MDIMaximize(hWnd); + wndParent.SetRedraw(TRUE); + wndParent.RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_ALLCHILDREN); + ::SetFocus(this->GetMDIFrame()); // focus will be set back to this window + } + else if((hWnd != NULL) && ::IsWindowVisible(this->m_hWnd) && !::IsChild(hWnd, ::GetFocus())) + { + ::SetFocus(hWnd); + } + + return hWnd; + } + + HWND CreateEx(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR lpcstrWindowName = NULL, DWORD dwStyle = 0, DWORD dwExStyle = 0, LPVOID lpCreateParam = NULL) + { + const int cchName = 256; + TCHAR szWindowName[cchName] = {}; + if(lpcstrWindowName == NULL) + { + ::LoadString(ModuleHelper::GetResourceInstance(), T::GetWndClassInfo().m_uCommonResourceID, szWindowName, cchName); + lpcstrWindowName = szWindowName; + } + + T* pT = static_cast(this); + HWND hWnd = pT->Create(hWndParent, rect, lpcstrWindowName, dwStyle, dwExStyle, T::GetWndClassInfo().m_uCommonResourceID, lpCreateParam); + + if(hWnd != NULL) + this->m_hAccel = ::LoadAccelerators(ModuleHelper::GetResourceInstance(), MAKEINTRESOURCE(T::GetWndClassInfo().m_uCommonResourceID)); + + return hWnd; + } + + BOOL CreateSimpleToolBar(UINT nResourceID = 0, DWORD dwStyle = ATL_SIMPLE_TOOLBAR_STYLE, UINT nID = ATL_IDW_TOOLBAR) + { + ATLASSERT(!::IsWindow(this->m_hWndToolBar)); + if(nResourceID == 0) + nResourceID = T::GetWndClassInfo().m_uCommonResourceID; + this->m_hWndToolBar = T::CreateSimpleToolBarCtrl(this->m_hWnd, nResourceID, TRUE, dwStyle, nID); + return (this->m_hWndToolBar != NULL); + } + + BOOL UpdateClientEdge(LPRECT lpRect = NULL) + { + // only adjust for active MDI child window + HWND hWndChild = this->MDIGetActive(); + if((hWndChild != NULL) && (hWndChild != this->m_hWnd)) + return FALSE; + + // need to adjust the client edge style as max/restore happens + DWORD dwStyle = ::GetWindowLong(this->m_hWndMDIClient, GWL_EXSTYLE); + DWORD dwNewStyle = dwStyle; + if((hWndChild != NULL) && ((this->GetExStyle() & WS_EX_CLIENTEDGE) == 0) && ((this->GetStyle() & WS_MAXIMIZE) != 0)) + dwNewStyle &= ~(WS_EX_CLIENTEDGE); + else + dwNewStyle |= WS_EX_CLIENTEDGE; + + if(dwStyle != dwNewStyle) + { + // SetWindowPos will not move invalid bits + ::RedrawWindow(this->m_hWndMDIClient, NULL, NULL, + RDW_INVALIDATE | RDW_ALLCHILDREN); + // remove/add WS_EX_CLIENTEDGE to MDI client area + ::SetWindowLong(this->m_hWndMDIClient, GWL_EXSTYLE, dwNewStyle); + ::SetWindowPos(this->m_hWndMDIClient, NULL, 0, 0, 0, 0, + SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | + SWP_NOZORDER | SWP_NOCOPYBITS); + + // return new client area + if (lpRect != NULL) + ::GetClientRect(this->m_hWndMDIClient, lpRect); + + return TRUE; + } + + return FALSE; + } + + typedef CFrameWindowImplBase _baseClass; + BEGIN_MSG_MAP(CMDIChildWindowImpl) + MESSAGE_HANDLER(WM_SIZE, OnSize) + MESSAGE_HANDLER(WM_WINDOWPOSCHANGED, OnWindowPosChanged) + MESSAGE_HANDLER(WM_MOUSEACTIVATE, OnMouseActivate) + MESSAGE_HANDLER(WM_MENUSELECT, OnMenuSelect) + MESSAGE_HANDLER(WM_MDIACTIVATE, OnMDIActivate) + MESSAGE_HANDLER(WM_DESTROY, OnDestroy) +#ifndef _ATL_NO_REBAR_SUPPORT + NOTIFY_CODE_HANDLER(RBN_AUTOSIZE, OnReBarAutoSize) + NOTIFY_CODE_HANDLER(RBN_CHEVRONPUSHED, OnChevronPushed) +#endif // !_ATL_NO_REBAR_SUPPORT + CHAIN_MSG_MAP(_baseClass) + END_MSG_MAP() + + LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) + { + this->DefWindowProc(uMsg, wParam, lParam); // needed for MDI children + if(wParam != SIZE_MINIMIZED) + { + T* pT = static_cast(this); + pT->UpdateLayout(); + } + return 0; + } + + LRESULT OnWindowPosChanged(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled) + { + // update MDI client edge and adjust MDI child rect + LPWINDOWPOS lpWndPos = (LPWINDOWPOS)lParam; + + if(!(lpWndPos->flags & SWP_NOSIZE)) + { + RECT rectClient = {}; + if(UpdateClientEdge(&rectClient) && ((this->GetStyle() & WS_MAXIMIZE) != 0)) + { + ::AdjustWindowRectEx(&rectClient, this->GetStyle(), FALSE, this->GetExStyle()); + lpWndPos->x = rectClient.left; + lpWndPos->y = rectClient.top; + lpWndPos->cx = rectClient.right - rectClient.left; + lpWndPos->cy = rectClient.bottom - rectClient.top; + } + } + + bHandled = FALSE; + return 1; + } + + LRESULT OnMouseActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) + { + LRESULT lRes = this->DefWindowProc(uMsg, wParam, lParam); + + // Activate this MDI window if needed + if((lRes == MA_ACTIVATE) || (lRes == MA_ACTIVATEANDEAT)) + { + if(this->MDIGetActive() != this->m_hWnd) + this->MDIActivate(this->m_hWnd); + } + + return lRes; + } + + LRESULT OnMenuSelect(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) + { + return ::SendMessage(this->GetMDIFrame(), uMsg, wParam, lParam); + } + + LRESULT OnMDIActivate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled) + { + if(((HWND)lParam == this->m_hWnd) && (this->m_hMenu != NULL)) + this->SetMDIFrameMenu(); + else if((HWND)lParam == NULL) + ::SendMessage(this->GetMDIFrame(), WM_MDISETMENU, 0, 0); + + bHandled = FALSE; + return 1; + } + + LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) + { + if(this->m_hMenu != NULL) + { + ::DestroyMenu(this->m_hMenu); + this->m_hMenu = NULL; + } + UpdateClientEdge(); + bHandled = FALSE; + return 1; + } + +#ifndef _ATL_NO_REBAR_SUPPORT + LRESULT OnReBarAutoSize(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/) + { + T* pT = static_cast(this); + pT->UpdateLayout(FALSE); + return 0; + } + + LRESULT OnChevronPushed(int /*idCtrl*/, LPNMHDR pnmh, BOOL& bHandled) + { + T* pT = static_cast(this); + typename CFrameWindowImplBase::_ChevronMenuInfo cmi = { NULL, (LPNMREBARCHEVRON)pnmh, false }; + if(!pT->PrepareChevronMenu(cmi)) + { + bHandled = FALSE; + return 1; + } + // display a popup menu with hidden items + pT->DisplayChevronMenu(cmi); + // cleanup + pT->CleanupChevronMenu(cmi); + return 0; + } +#endif // !_ATL_NO_REBAR_SUPPORT +}; + + +/////////////////////////////////////////////////////////////////////////////// +// COwnerDraw - MI class for owner-draw support + +template +class COwnerDraw +{ +public: +// Message map and handlers + BEGIN_MSG_MAP(COwnerDraw< T >) + MESSAGE_HANDLER(WM_DRAWITEM, OnDrawItem) + MESSAGE_HANDLER(WM_MEASUREITEM, OnMeasureItem) + MESSAGE_HANDLER(WM_COMPAREITEM, OnCompareItem) + MESSAGE_HANDLER(WM_DELETEITEM, OnDeleteItem) + ALT_MSG_MAP(1) + MESSAGE_HANDLER(OCM_DRAWITEM, OnDrawItem) + MESSAGE_HANDLER(OCM_MEASUREITEM, OnMeasureItem) + MESSAGE_HANDLER(OCM_COMPAREITEM, OnCompareItem) + MESSAGE_HANDLER(OCM_DELETEITEM, OnDeleteItem) + END_MSG_MAP() + + LRESULT OnDrawItem(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled) + { + T* pT = static_cast(this); + pT->SetMsgHandled(TRUE); + pT->DrawItem((LPDRAWITEMSTRUCT)lParam); + bHandled = pT->IsMsgHandled(); + return (LRESULT)TRUE; + } + + LRESULT OnMeasureItem(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled) + { + T* pT = static_cast(this); + pT->SetMsgHandled(TRUE); + pT->MeasureItem((LPMEASUREITEMSTRUCT)lParam); + bHandled = pT->IsMsgHandled(); + return (LRESULT)TRUE; + } + + LRESULT OnCompareItem(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled) + { + T* pT = static_cast(this); + pT->SetMsgHandled(TRUE); + bHandled = pT->IsMsgHandled(); + return (LRESULT)pT->CompareItem((LPCOMPAREITEMSTRUCT)lParam); + } + + LRESULT OnDeleteItem(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled) + { + T* pT = static_cast(this); + pT->SetMsgHandled(TRUE); + pT->DeleteItem((LPDELETEITEMSTRUCT)lParam); + bHandled = pT->IsMsgHandled(); + return (LRESULT)TRUE; + } + +// Overrideables + void DrawItem(LPDRAWITEMSTRUCT /*lpDrawItemStruct*/) + { + // must be implemented + ATLASSERT(FALSE); + } + + void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct) + { + if(lpMeasureItemStruct->CtlType != ODT_MENU) + { + // return default height for a system font + T* pT = static_cast(this); + HWND hWnd = pT->GetDlgItem(lpMeasureItemStruct->CtlID); + CClientDC dc(hWnd); + TEXTMETRIC tm = {}; + dc.GetTextMetrics(&tm); + + lpMeasureItemStruct->itemHeight = tm.tmHeight; + } + else + lpMeasureItemStruct->itemHeight = ::GetSystemMetrics(SM_CYMENU); + } + + int CompareItem(LPCOMPAREITEMSTRUCT /*lpCompareItemStruct*/) + { + // all items are equal + return 0; + } + + void DeleteItem(LPDELETEITEMSTRUCT /*lpDeleteItemStruct*/) + { + // default - nothing + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// Update UI macros + +// these build the Update UI map inside a class definition +#define BEGIN_UPDATE_UI_MAP(thisClass) \ + static const CUpdateUIBase::_AtlUpdateUIMap* GetUpdateUIMap() \ + { \ + static const CUpdateUIBase::_AtlUpdateUIMap theMap[] = \ + { + +#define UPDATE_ELEMENT(nID, wType) \ + { nID, wType }, + +#define END_UPDATE_UI_MAP() \ + { (WORD)-1, 0 } \ + }; \ + return theMap; \ + } + +/////////////////////////////////////////////////////////////////////////////// +// CUpdateUI - manages UI elements updating + +class CUpdateUIBase +{ +public: + // constants + enum + { + // UI element type + UPDUI_MENUPOPUP = 0x0001, + UPDUI_MENUBAR = 0x0002, + UPDUI_CHILDWINDOW = 0x0004, + UPDUI_TOOLBAR = 0x0008, + UPDUI_STATUSBAR = 0x0010, + // state + UPDUI_ENABLED = 0x0000, + UPDUI_DISABLED = 0x0100, + UPDUI_CHECKED = 0x0200, + UPDUI_CHECKED2 = 0x0400, + UPDUI_RADIO = 0x0800, + UPDUI_DEFAULT = 0x1000, + UPDUI_TEXT = 0x2000, + // internal state + UPDUI_CLEARDEFAULT = 0x4000, + }; + + // element data + struct _AtlUpdateUIElement + { + HWND m_hWnd; + WORD m_wType; + + bool operator ==(const _AtlUpdateUIElement& e) const + { return ((m_hWnd == e.m_hWnd) && (m_wType == e.m_wType)); } + }; + + // map data + struct _AtlUpdateUIMap + { + WORD m_nID; + WORD m_wType; + + bool operator ==(const _AtlUpdateUIMap& e) const + { return ((m_nID == e.m_nID) && (m_wType == e.m_wType)); } + }; + + // instance data +#pragma warning(push) +#pragma warning(disable: 4201) // nameless unions are part of C++ + + struct _AtlUpdateUIData + { + WORD m_wState; + union + { + void* m_lpData; + LPTSTR m_lpstrText; + struct + { + WORD m_nIDFirst; + WORD m_nIDLast; + }; + }; + + bool operator ==(const _AtlUpdateUIData& e) const + { return ((m_wState == e.m_wState) && (m_lpData == e.m_lpData)); } + }; + +#pragma warning(pop) + + ATL::CSimpleArray<_AtlUpdateUIElement> m_UIElements; // elements data + const _AtlUpdateUIMap* m_pUIMap; // static UI data + _AtlUpdateUIData* m_pUIData; // instance UI data + WORD m_wDirtyType; // global dirty flag + + bool m_bBlockAccelerators; + + +// Constructor, destructor + CUpdateUIBase() : m_pUIMap(NULL), m_pUIData(NULL), m_wDirtyType(0), m_bBlockAccelerators(false) + { } + + ~CUpdateUIBase() + { + if((m_pUIMap != NULL) && (m_pUIData != NULL)) + { + const _AtlUpdateUIMap* pUIMap = m_pUIMap; + _AtlUpdateUIData* pUIData = m_pUIData; + while(pUIMap->m_nID != (WORD)-1) + { + if(pUIData->m_wState & UPDUI_TEXT) + delete [] pUIData->m_lpstrText; + pUIMap++; + pUIData++; + } + delete [] m_pUIData; + } + } + +// Check for disabled commands + bool UIGetBlockAccelerators() const + { + return m_bBlockAccelerators; + } + + bool UISetBlockAccelerators(bool bBlock) + { + bool bOld = m_bBlockAccelerators; + m_bBlockAccelerators = bBlock; + return bOld; + } + +// Add elements + BOOL UIAddMenuBar(HWND hWnd) // menu bar (main menu) + { + if(hWnd == NULL) + return FALSE; + _AtlUpdateUIElement e; + e.m_hWnd = hWnd; + e.m_wType = UPDUI_MENUBAR; + return m_UIElements.Add(e); + } + + BOOL UIAddToolBar(HWND hWnd) // toolbar + { + if(hWnd == NULL) + return FALSE; + _AtlUpdateUIElement e; + e.m_hWnd = hWnd; + e.m_wType = UPDUI_TOOLBAR; + return m_UIElements.Add(e); + } + + BOOL UIAddStatusBar(HWND hWnd) // status bar + { + if(hWnd == NULL) + return FALSE; + _AtlUpdateUIElement e; + e.m_hWnd = hWnd; + e.m_wType = UPDUI_STATUSBAR; + return m_UIElements.Add(e); + } + + BOOL UIAddChildWindowContainer(HWND hWnd) // child window + { + if(hWnd == NULL) + return FALSE; + _AtlUpdateUIElement e; + e.m_hWnd = hWnd; + e.m_wType = UPDUI_CHILDWINDOW; + return m_UIElements.Add(e); + } + +// Message map for popup menu updates and accelerator blocking + BEGIN_MSG_MAP(CUpdateUIBase) + MESSAGE_HANDLER(WM_INITMENUPOPUP, OnInitMenuPopup) + MESSAGE_HANDLER(WM_COMMAND, OnCommand) + END_MSG_MAP() + + LRESULT OnInitMenuPopup(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) + { + bHandled = FALSE; + HMENU hMenu = (HMENU)wParam; + if(hMenu == NULL) + return 1; + _AtlUpdateUIData* pUIData = m_pUIData; + if(pUIData == NULL) + return 1; + const _AtlUpdateUIMap* pMap = m_pUIMap; + while(pMap->m_nID != (WORD)-1) + { + if(pMap->m_wType & UPDUI_MENUPOPUP) + { + UIUpdateMenuBarElement(pMap->m_nID, pUIData, hMenu); + + if((pUIData->m_wState & UPDUI_RADIO) != 0) + ::CheckMenuRadioItem(hMenu, pUIData->m_nIDFirst, pUIData->m_nIDLast, pMap->m_nID, MF_BYCOMMAND); + } + pMap++; + pUIData++; + } + return 0; + } + + LRESULT OnCommand(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) + { + bHandled = FALSE; + if(m_bBlockAccelerators && (HIWORD(wParam) == 1)) // accelerators only + { + int nID = LOWORD(wParam); + if((UIGetState(nID) & UPDUI_DISABLED) == UPDUI_DISABLED) + { + ATLTRACE2(atlTraceUI, 0, _T("CUpdateUIBase::OnCommand - blocked disabled command 0x%4.4X\n"), nID); + bHandled = TRUE; // eat the command, UI item is disabled + } + } + return 0; + } + +// methods for setting UI element state + BOOL UIEnable(int nID, BOOL bEnable, BOOL bForceUpdate = FALSE) + { + const _AtlUpdateUIMap* pMap = m_pUIMap; + _AtlUpdateUIData* pUIData = m_pUIData; + if(pUIData == NULL) + return FALSE; + + for( ; pMap->m_nID != (WORD)-1; pMap++, pUIData++) + { + if(nID == (int)pMap->m_nID) + { + if(bEnable) + { + if(pUIData->m_wState & UPDUI_DISABLED) + { + pUIData->m_wState |= pMap->m_wType; + pUIData->m_wState &= ~UPDUI_DISABLED; + } + } + else + { + if(!(pUIData->m_wState & UPDUI_DISABLED)) + { + pUIData->m_wState |= pMap->m_wType; + pUIData->m_wState |= UPDUI_DISABLED; + } + } + + if(bForceUpdate) + pUIData->m_wState |= pMap->m_wType; + if(pUIData->m_wState & pMap->m_wType) + m_wDirtyType |= pMap->m_wType; + + break; // found + } + } + + return TRUE; + } + + BOOL UISetCheck(int nID, int nCheck, BOOL bForceUpdate = FALSE) + { + const _AtlUpdateUIMap* pMap = m_pUIMap; + _AtlUpdateUIData* pUIData = m_pUIData; + if(pUIData == NULL) + return FALSE; + + for( ; pMap->m_nID != (WORD)-1; pMap++, pUIData++) + { + if(nID == (int)pMap->m_nID) + { + switch(nCheck) + { + case 0: + if((pUIData->m_wState & UPDUI_CHECKED) || (pUIData->m_wState & UPDUI_CHECKED2)) + { + pUIData->m_wState |= pMap->m_wType; + pUIData->m_wState &= ~(UPDUI_CHECKED | UPDUI_CHECKED2); + } + break; + case 1: + if(!(pUIData->m_wState & UPDUI_CHECKED)) + { + pUIData->m_wState |= pMap->m_wType; + pUIData->m_wState &= ~UPDUI_CHECKED2; + pUIData->m_wState |= UPDUI_CHECKED; + } + break; + case 2: + if(!(pUIData->m_wState & UPDUI_CHECKED2)) + { + pUIData->m_wState |= pMap->m_wType; + pUIData->m_wState &= ~UPDUI_CHECKED; + pUIData->m_wState |= UPDUI_CHECKED2; + } + break; + } + + if(bForceUpdate) + pUIData->m_wState |= pMap->m_wType; + if(pUIData->m_wState & pMap->m_wType) + m_wDirtyType |= pMap->m_wType; + + break; // found + } + } + + return TRUE; + } + + // variant that supports bool (checked/not-checked, no intermediate state) + BOOL UISetCheck(int nID, bool bCheck, BOOL bForceUpdate = FALSE) + { + return UISetCheck(nID, bCheck ? 1 : 0, bForceUpdate); + } + + BOOL UISetRadio(int nID, BOOL bRadio, BOOL bForceUpdate = FALSE) + { + const _AtlUpdateUIMap* pMap = m_pUIMap; + _AtlUpdateUIData* pUIData = m_pUIData; + if(pUIData == NULL) + return FALSE; + + for( ; pMap->m_nID != (WORD)-1; pMap++, pUIData++) + { + if(nID == (int)pMap->m_nID) + { + if(bRadio) + { + if(!(pUIData->m_wState & UPDUI_RADIO)) + { + pUIData->m_wState |= pMap->m_wType; + pUIData->m_wState |= UPDUI_RADIO; + } + } + else + { + if(pUIData->m_wState & UPDUI_RADIO) + { + pUIData->m_wState |= pMap->m_wType; + pUIData->m_wState &= ~UPDUI_RADIO; + } + } + + if(bForceUpdate) + pUIData->m_wState |= pMap->m_wType; + if(pUIData->m_wState & pMap->m_wType) + m_wDirtyType |= pMap->m_wType; + + break; // found + } + } + + return TRUE; + } + + // for menu items + BOOL UISetRadioMenuItem(int nID, int nIDFirst, int nIDLast, BOOL bForceUpdate = FALSE) + { + const _AtlUpdateUIMap* pMap = m_pUIMap; + _AtlUpdateUIData* pUIData = m_pUIData; + if(pUIData == NULL) + return FALSE; + + for( ; pMap->m_nID != (WORD)-1; pMap++, pUIData++) + { + if(nID == (int)pMap->m_nID) + { + pUIData->m_wState |= pMap->m_wType; + pUIData->m_wState |= UPDUI_RADIO; + pUIData->m_nIDFirst = (WORD)nIDFirst; + pUIData->m_nIDLast = (WORD)nIDLast; + + if(bForceUpdate) + pUIData->m_wState |= pMap->m_wType; + if(pUIData->m_wState & pMap->m_wType) + m_wDirtyType |= pMap->m_wType; + } + else if((pMap->m_nID >= nIDFirst) && (pMap->m_nID <= nIDLast)) + { + if(pUIData->m_wState & UPDUI_RADIO) + { + pUIData->m_wState &= ~pMap->m_wType; + pUIData->m_wState &= ~UPDUI_RADIO; + pUIData->m_nIDFirst = 0; + pUIData->m_nIDLast = 0; + } + } + + if(pMap->m_nID == nIDLast) + break; + } + + return TRUE; + } + + BOOL UISetText(int nID, LPCTSTR lpstrText, BOOL bForceUpdate = FALSE) + { + const _AtlUpdateUIMap* pMap = m_pUIMap; + _AtlUpdateUIData* pUIData = m_pUIData; + if(pUIData == NULL) + return FALSE; + if(lpstrText == NULL) + lpstrText = _T(""); + + for( ; pMap->m_nID != (WORD)-1; pMap++, pUIData++) + { + if(nID == (int)pMap->m_nID) + { + if((pUIData->m_lpstrText == NULL) || lstrcmp(pUIData->m_lpstrText, lpstrText)) + { + delete [] pUIData->m_lpstrText; + pUIData->m_lpstrText = NULL; + int nStrLen = lstrlen(lpstrText); + ATLTRY(pUIData->m_lpstrText = new TCHAR[nStrLen + 1]); + if(pUIData->m_lpstrText == NULL) + { + ATLTRACE2(atlTraceUI, 0, _T("UISetText - memory allocation failed\n")); + break; + } + ATL::Checked::tcscpy_s(pUIData->m_lpstrText, nStrLen + 1, lpstrText); + pUIData->m_wState |= (UPDUI_TEXT | pMap->m_wType); + } + + if(bForceUpdate) + pUIData->m_wState |= (UPDUI_TEXT | pMap->m_wType); + if(pUIData->m_wState & pMap->m_wType) + m_wDirtyType |= pMap->m_wType; + + break; // found + } + } + + return TRUE; + } + + BOOL UISetDefault(int nID, BOOL bDefault, BOOL bForceUpdate = FALSE) + { + const _AtlUpdateUIMap* pMap = m_pUIMap; + _AtlUpdateUIData* pUIData = m_pUIData; + if(pUIData == NULL) + return FALSE; + + for( ; pMap->m_nID != (WORD)-1; pMap++, pUIData++) + { + if(nID == (int)pMap->m_nID) + { + if(bDefault) + { + if((pUIData->m_wState & UPDUI_DEFAULT) == 0) + { + pUIData->m_wState |= pMap->m_wType; + pUIData->m_wState |= UPDUI_DEFAULT; + } + } + else + { + if((pUIData->m_wState & UPDUI_DEFAULT) != 0) + { + pUIData->m_wState |= pMap->m_wType; + pUIData->m_wState &= ~UPDUI_DEFAULT; + pUIData->m_wState |= UPDUI_CLEARDEFAULT; + } + } + + if(bForceUpdate) + pUIData->m_wState |= pMap->m_wType; + if(pUIData->m_wState & pMap->m_wType) + m_wDirtyType |= pMap->m_wType; + + break; // found + } + } + + return TRUE; + } + +// methods for complete state set/get + BOOL UISetState(int nID, DWORD dwState) + { + const _AtlUpdateUIMap* pMap = m_pUIMap; + _AtlUpdateUIData* pUIData = m_pUIData; + if(pUIData == NULL) + return FALSE; + for( ; pMap->m_nID != (WORD)-1; pMap++, pUIData++) + { + if(nID == (int)pMap->m_nID) + { + pUIData->m_wState = (WORD)(dwState | pMap->m_wType); + m_wDirtyType |= pMap->m_wType; + break; // found + } + } + return TRUE; + } + + DWORD UIGetState(int nID) + { + const _AtlUpdateUIMap* pMap = m_pUIMap; + _AtlUpdateUIData* pUIData = m_pUIData; + if(pUIData == NULL) + return 0; + for( ; pMap->m_nID != (WORD)-1; pMap++, pUIData++) + { + if(nID == (int)pMap->m_nID) + return pUIData->m_wState; + } + return 0; + } + +// methods for updating UI + BOOL UIUpdateMenuBar(BOOL bForceUpdate = FALSE, BOOL bMainMenu = FALSE) + { + if(!(m_wDirtyType & UPDUI_MENUBAR) && !bForceUpdate) + return TRUE; + + const _AtlUpdateUIMap* pMap = m_pUIMap; + _AtlUpdateUIData* pUIData = m_pUIData; + if(pUIData == NULL) + return FALSE; + + while(pMap->m_nID != (WORD)-1) + { + for(int i = 0; i < m_UIElements.GetSize(); i++) + { + if(m_UIElements[i].m_wType == UPDUI_MENUBAR) + { + HMENU hMenu = ::GetMenu(m_UIElements[i].m_hWnd); + if((hMenu != NULL) && (pUIData->m_wState & UPDUI_MENUBAR) && (pMap->m_wType & UPDUI_MENUBAR)) + UIUpdateMenuBarElement(pMap->m_nID, pUIData, hMenu); + } + if(bMainMenu) + ::DrawMenuBar(m_UIElements[i].m_hWnd); + } + pMap++; + pUIData->m_wState &= ~UPDUI_MENUBAR; + if(pUIData->m_wState & UPDUI_TEXT) + { + delete [] pUIData->m_lpstrText; + pUIData->m_lpstrText = NULL; + pUIData->m_wState &= ~UPDUI_TEXT; + } + pUIData++; + } + + m_wDirtyType &= ~UPDUI_MENUBAR; + return TRUE; + } + + BOOL UIUpdateToolBar(BOOL bForceUpdate = FALSE) + { + if(!(m_wDirtyType & UPDUI_TOOLBAR) && !bForceUpdate) + return TRUE; + + const _AtlUpdateUIMap* pMap = m_pUIMap; + _AtlUpdateUIData* pUIData = m_pUIData; + if(pUIData == NULL) + return FALSE; + + while(pMap->m_nID != (WORD)-1) + { + for(int i = 0; i < m_UIElements.GetSize(); i++) + { + if(m_UIElements[i].m_wType == UPDUI_TOOLBAR) + { + if((pUIData->m_wState & UPDUI_TOOLBAR) && (pMap->m_wType & UPDUI_TOOLBAR)) + UIUpdateToolBarElement(pMap->m_nID, pUIData, m_UIElements[i].m_hWnd); + } + } + pMap++; + pUIData->m_wState &= ~UPDUI_TOOLBAR; + pUIData++; + } + + m_wDirtyType &= ~UPDUI_TOOLBAR; + return TRUE; + } + + BOOL UIUpdateStatusBar(BOOL bForceUpdate = FALSE) + { + if(!(m_wDirtyType & UPDUI_STATUSBAR) && !bForceUpdate) + return TRUE; + + const _AtlUpdateUIMap* pMap = m_pUIMap; + _AtlUpdateUIData* pUIData = m_pUIData; + if(pUIData == NULL) + return FALSE; + + while(pMap->m_nID != (WORD)-1) + { + for(int i = 0; i < m_UIElements.GetSize(); i++) + { + if(m_UIElements[i].m_wType == UPDUI_STATUSBAR) + { + if((pUIData->m_wState & UPDUI_STATUSBAR) && (pMap->m_wType & UPDUI_STATUSBAR)) + UIUpdateStatusBarElement(pMap->m_nID, pUIData, m_UIElements[i].m_hWnd); + } + } + pMap++; + pUIData->m_wState &= ~UPDUI_STATUSBAR; + if(pUIData->m_wState & UPDUI_TEXT) + { + delete [] pUIData->m_lpstrText; + pUIData->m_lpstrText = NULL; + pUIData->m_wState &= ~UPDUI_TEXT; + } + pUIData++; + } + + m_wDirtyType &= ~UPDUI_STATUSBAR; + return TRUE; + } + + BOOL UIUpdateChildWindows(BOOL bForceUpdate = FALSE) + { + if(!(m_wDirtyType & UPDUI_CHILDWINDOW) && !bForceUpdate) + return TRUE; + + const _AtlUpdateUIMap* pMap = m_pUIMap; + _AtlUpdateUIData* pUIData = m_pUIData; + if(pUIData == NULL) + return FALSE; + + while(pMap->m_nID != (WORD)-1) + { + for(int i = 0; i < m_UIElements.GetSize(); i++) + { + if(m_UIElements[i].m_wType == UPDUI_CHILDWINDOW) + { + if((pUIData->m_wState & UPDUI_CHILDWINDOW) && (pMap->m_wType & UPDUI_CHILDWINDOW)) + UIUpdateChildWindow(pMap->m_nID, pUIData, m_UIElements[i].m_hWnd); + } + } + pMap++; + pUIData->m_wState &= ~UPDUI_CHILDWINDOW; + if(pUIData->m_wState & UPDUI_TEXT) + { + delete [] pUIData->m_lpstrText; + pUIData->m_lpstrText = NULL; + pUIData->m_wState &= ~UPDUI_TEXT; + } + pUIData++; + } + + m_wDirtyType &= ~UPDUI_CHILDWINDOW; + return TRUE; + } + +// internal element specific methods + static void UIUpdateMenuBarElement(int nID, _AtlUpdateUIData* pUIData, HMENU hMenu) + { + if((pUIData->m_wState & UPDUI_CLEARDEFAULT) != 0) + { + ::SetMenuDefaultItem(hMenu, (UINT)-1, 0); + pUIData->m_wState &= ~UPDUI_CLEARDEFAULT; + } + + CMenuItemInfo mii; + mii.fMask = MIIM_STATE; + mii.wID = nID; + + if((pUIData->m_wState & UPDUI_DISABLED) != 0) + mii.fState |= MFS_DISABLED | MFS_GRAYED; + else + mii.fState |= MFS_ENABLED; + + if((pUIData->m_wState & UPDUI_CHECKED) != 0) + mii.fState |= MFS_CHECKED; + else + mii.fState |= MFS_UNCHECKED; + + if((pUIData->m_wState & UPDUI_DEFAULT) != 0) + mii.fState |= MFS_DEFAULT; + + if((pUIData->m_wState & UPDUI_TEXT) != 0) + { + CMenuItemInfo miiNow; + miiNow.fMask = MIIM_TYPE; + miiNow.wID = nID; + if(::GetMenuItemInfo(hMenu, nID, FALSE, &miiNow)) + { + mii.fMask |= MIIM_TYPE; + // MFT_BITMAP and MFT_SEPARATOR don't go together with MFT_STRING + mii.fType |= (miiNow.fType & ~(MFT_BITMAP | MFT_SEPARATOR)) | MFT_STRING; + mii.dwTypeData = pUIData->m_lpstrText; + } + } + + ::SetMenuItemInfo(hMenu, nID, FALSE, &mii); + } + + static void UIUpdateToolBarElement(int nID, _AtlUpdateUIData* pUIData, HWND hWndToolBar) + { + // Note: only handles enabled/disabled, checked state, and radio (press) + ::SendMessage(hWndToolBar, TB_ENABLEBUTTON, nID, (LPARAM)(pUIData->m_wState & UPDUI_DISABLED) ? FALSE : TRUE); + ::SendMessage(hWndToolBar, TB_CHECKBUTTON, nID, (LPARAM)(pUIData->m_wState & UPDUI_CHECKED) ? TRUE : FALSE); + ::SendMessage(hWndToolBar, TB_INDETERMINATE, nID, (LPARAM)(pUIData->m_wState & UPDUI_CHECKED2) ? TRUE : FALSE); + ::SendMessage(hWndToolBar, TB_PRESSBUTTON, nID, (LPARAM)(pUIData->m_wState & UPDUI_RADIO) ? TRUE : FALSE); + } + + static void UIUpdateStatusBarElement(int nID, _AtlUpdateUIData* pUIData, HWND hWndStatusBar) + { + // Note: only handles text + if(pUIData->m_wState & UPDUI_TEXT) + ::SendMessage(hWndStatusBar, SB_SETTEXT, nID, (LPARAM)pUIData->m_lpstrText); + } + + static void UIUpdateChildWindow(int nID, _AtlUpdateUIData* pUIData, HWND hWnd) + { + HWND hChild = ::GetDlgItem(hWnd, nID); + + ::EnableWindow(hChild, (pUIData->m_wState & UPDUI_DISABLED) ? FALSE : TRUE); + // for check and radio, assume that window is a button + int nCheck = BST_UNCHECKED; + if((pUIData->m_wState & UPDUI_CHECKED) || (pUIData->m_wState & UPDUI_RADIO)) + nCheck = BST_CHECKED; + else if(pUIData->m_wState & UPDUI_CHECKED2) + nCheck = BST_INDETERMINATE; + ::SendMessage(hChild, BM_SETCHECK, nCheck, 0L); + if(pUIData->m_wState & UPDUI_DEFAULT) + { + DWORD dwRet = (DWORD)::SendMessage(hWnd, DM_GETDEFID, 0, 0L); + if(HIWORD(dwRet) == DC_HASDEFID) + { + HWND hOldDef = ::GetDlgItem(hWnd, (int)(short)LOWORD(dwRet)); + // remove BS_DEFPUSHBUTTON + ::SendMessage(hOldDef, BM_SETSTYLE, BS_PUSHBUTTON, MAKELPARAM(TRUE, 0)); + } + ::SendMessage(hWnd, DM_SETDEFID, nID, 0L); + } + if(pUIData->m_wState & UPDUI_TEXT) + ::SetWindowText(hChild, pUIData->m_lpstrText); + } +}; + +template +class CUpdateUI : public CUpdateUIBase +{ +public: + CUpdateUI() + { + T* pT = static_cast(this); + (void)pT; // avoid level 4 warning + const _AtlUpdateUIMap* pMap = pT->GetUpdateUIMap(); + m_pUIMap = pMap; + ATLASSERT(m_pUIMap != NULL); + int nCount = 1; + for( ; pMap->m_nID != (WORD)-1; nCount++) + pMap++; + + // check for duplicates (debug only) +#ifdef _DEBUG + for(int i = 0; i < nCount; i++) + { + for(int j = 0; j < nCount; j++) + { + // shouldn't have duplicates in the update UI map + if(i != j) + ATLASSERT(m_pUIMap[j].m_nID != m_pUIMap[i].m_nID); + } + } +#endif // _DEBUG + + ATLTRY(m_pUIData = new _AtlUpdateUIData[nCount]); + ATLASSERT(m_pUIData != NULL); + + if(m_pUIData != NULL) + memset(m_pUIData, 0, sizeof(_AtlUpdateUIData) * nCount); + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CDynamicUpdateUI - allows update elements to dynamically added and removed +// in addition to a static update UI map + +template +class CDynamicUpdateUI : public CUpdateUIBase +{ +public: +// Data members + ATL::CSimpleArray<_AtlUpdateUIMap> m_arrUIMap; // copy of the static UI data + ATL::CSimpleArray<_AtlUpdateUIData> m_arrUIData; // instance UI data + +// Constructor/destructor + CDynamicUpdateUI() + { + T* pT = static_cast(this); + (void)pT; // avoid level 4 warning + const _AtlUpdateUIMap* pMap = pT->GetUpdateUIMap(); + ATLASSERT(pMap != NULL); + + for(;;) + { + BOOL bRet = m_arrUIMap.Add(*(_AtlUpdateUIMap*)pMap); + ATLASSERT(bRet); + + if(bRet != FALSE) + { + _AtlUpdateUIData data = { 0, NULL }; + bRet = m_arrUIData.Add(data); + ATLASSERT(bRet); + } + + if(pMap->m_nID == (WORD)-1) + break; + + pMap++; + } + + ATLASSERT(m_arrUIMap.GetSize() == m_arrUIData.GetSize()); + +#ifdef _DEBUG + // check for duplicates (debug only) + for(int i = 0; i < m_arrUIMap.GetSize(); i++) + { + for(int j = 0; j < m_arrUIMap.GetSize(); j++) + { + // shouldn't have duplicates in the update UI map + if(i != j) + ATLASSERT(m_arrUIMap[j].m_nID != m_arrUIMap[i].m_nID); + } + } +#endif // _DEBUG + + // Set internal data pointers to point to the new data arrays + m_pUIMap = m_arrUIMap.m_aT; + m_pUIData = m_arrUIData.m_aT; + } + + ~CDynamicUpdateUI() + { + for(int i = 0; i < m_arrUIData.GetSize(); i++) + { + if((m_arrUIData[i].m_wState & UPDUI_TEXT) != 0) + delete [] m_arrUIData[i].m_lpstrText; + } + + // Reset internal data pointers (memory will be released by CSimpleArray d-tor) + m_pUIMap = NULL; + m_pUIData = NULL; + } + +// Methods for dynamically adding and removing update elements + bool UIAddUpdateElement(WORD nID, WORD wType) + { + // check for duplicates + for(int i = 0; i < m_arrUIMap.GetSize(); i++) + { + // shouldn't have duplicates in the update UI map + ATLASSERT(m_arrUIMap[i].m_nID != nID); + if(m_arrUIMap[i].m_nID == nID) + return false; + } + + bool bRetVal = false; + + // Add new end element + _AtlUpdateUIMap uumEnd = { (WORD)-1, 0 }; + BOOL bRet = m_arrUIMap.Add(uumEnd); + ATLASSERT(bRet); + + if(bRet != FALSE) + { + _AtlUpdateUIData uud = { 0, NULL }; + bRet = m_arrUIData.Add(uud); + ATLASSERT(bRet); + + // Set new data to the previous end element + if(bRet != FALSE) + { + int nSize = m_arrUIMap.GetSize(); + _AtlUpdateUIMap uum = { nID, wType }; + m_arrUIMap.SetAtIndex(nSize - 2, uum); + m_arrUIData.SetAtIndex(nSize - 2, uud); + + // Set internal data pointers again, just in case that memory moved + m_pUIMap = m_arrUIMap.m_aT; + m_pUIData = m_arrUIData.m_aT; + + bRetVal = true; + } + } + + return bRetVal; + } + + bool UIRemoveUpdateElement(WORD nID) + { + bool bRetVal = false; + + for(int i = 0; i < m_arrUIMap.GetSize(); i++) + { + if(m_arrUIMap[i].m_nID == nID) + { + if((m_arrUIData[i].m_wState & UPDUI_TEXT) != 0) + delete [] m_arrUIData[i].m_lpstrText; + + BOOL bRet = m_arrUIMap.RemoveAt(i); + ATLASSERT(bRet); + bRet = m_arrUIData.RemoveAt(i); + ATLASSERT(bRet); + + bRetVal = true; + break; + } + } + + return bRetVal; + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CAutoUpdateUI : Automatic mapping of UI elements + +template +class CAutoUpdateUI : public CDynamicUpdateUI +{ +public: + LPCTSTR UIGetText(int nID) + { + for(int i = 0; i < this->m_arrUIMap.GetSize(); i++) + { + if(this->m_arrUIMap[i].m_nID == nID) + return this->m_arrUIData[i].m_lpstrText; + } + + return NULL; + } + +// Element + template + bool UIAddElement(UINT nID) + { + // check for existing UI map element + for(int i = 0; i < this->m_arrUIMap.GetSize(); i++) + { + if(this->m_arrUIMap[i].m_nID == nID) + { + // set requested type + this->m_arrUIMap[i].m_wType |= t_wType; + return true; + } + } + + // Add element to UI map with requested type + return this->UIAddUpdateElement((WORD)nID, t_wType); + } + + template + bool UIRemoveElement(UINT nID) + { + for(int i = 0; i < this->m_arrUIMap.GetSize(); i++) + { + if(this->m_arrUIMap[i].m_nID == nID) // matching UI map element + { + WORD wType = this->m_arrUIMap[i].m_wType & ~t_wType; + if (wType != 0) // has other types + { + this->m_arrUIMap[i].m_wType = wType; // keep other types + return true; + } + else + { + return this->UIRemoveUpdateElement((WORD)nID); + } + } + } + + return false; + } + +// Menu + bool UIAddMenu(HMENU hMenu, bool bSetText = false) + { + ATLASSERT(::IsMenu(hMenu)); + MENUITEMINFO mii = {sizeof(MENUITEMINFO), MIIM_TYPE | MIIM_ID | MIIM_SUBMENU}; + + // Complete the UI map + for (INT uItem = 0; CMenuHandle(hMenu).GetMenuItemInfo(uItem, TRUE, &mii); uItem++) + { + if(mii.hSubMenu) + { + // Add submenu to UI map + UIAddMenu(mii.hSubMenu, bSetText); + } + else if (mii.wID != 0) + { + // Add element to UI map + UIAddElement::UPDUI_MENUPOPUP>(mii.wID); + if (bSetText) + { + TCHAR sText[64] = {}; + if (GetMenuString(hMenu, uItem, sText, 64, MF_BYPOSITION)) + this->UISetText(mii.wID, sText); + } + } + } + + return true; + } + + bool UIAddMenu(UINT uID, bool bSetText = false) + { + CMenu menu; + ATLVERIFY(menu.LoadMenu(uID)); + return UIAddMenu(menu, bSetText); + } + +// ToolBar + bool UIAddToolBar(HWND hWndToolBar) + { + ATLASSERT(::IsWindow(hWndToolBar)); + TBBUTTONINFO tbbi = { sizeof(TBBUTTONINFO), TBIF_COMMAND | TBIF_STYLE | TBIF_BYINDEX }; + + // Add toolbar buttons + for (int uItem = 0; ::SendMessage(hWndToolBar, TB_GETBUTTONINFO, uItem, (LPARAM)&tbbi) != -1; uItem++) + { + if (tbbi.fsStyle ^ BTNS_SEP) + UIAddElement::UPDUI_TOOLBAR>(tbbi.idCommand); + } + + // Add embedded controls if any + if (::GetWindow(hWndToolBar, GW_CHILD)) + UIAddChildWindowContainer(hWndToolBar); + + return (CUpdateUIBase::UIAddToolBar(hWndToolBar) != FALSE); + } + +// Container + bool UIAddChildWindowContainer(HWND hWnd) + { + ATLASSERT(::IsWindow(hWnd)); + + // Add children controls if any + for (ATL::CWindow wCtl = ::GetWindow(hWnd, GW_CHILD); wCtl.IsWindow(); wCtl = wCtl.GetWindow(GW_HWNDNEXT)) + { + int id = wCtl.GetDlgCtrlID(); + if(id != 0) + UIAddElement::UPDUI_CHILDWINDOW>(id); + } + + return (CUpdateUIBase::UIAddChildWindowContainer(hWnd) != FALSE); + } + +// StatusBar + BOOL UIUpdateStatusBar(BOOL bForceUpdate = FALSE) + { + if(!(this->m_wDirtyType & CDynamicUpdateUI::UPDUI_STATUSBAR) && !bForceUpdate) + return TRUE; + + for(int i = 0; i < this->m_arrUIMap.GetSize(); i++) + { + for(int e = 0; e < this->m_UIElements.GetSize(); e++) + { + if((this->m_UIElements[e].m_wType == CDynamicUpdateUI::UPDUI_STATUSBAR) && + (this->m_arrUIMap[i].m_wType & CDynamicUpdateUI::UPDUI_STATUSBAR) && + (this->m_arrUIData[i].m_wState & CDynamicUpdateUI::UPDUI_STATUSBAR)) + { + this->UIUpdateStatusBarElement(this->m_arrUIMap[i].m_nID, &this->m_arrUIData[i], this->m_UIElements[e].m_hWnd); + this->m_arrUIData[i].m_wState &= ~CDynamicUpdateUI::UPDUI_STATUSBAR; + if(this->m_arrUIData[i].m_wState & CDynamicUpdateUI::UPDUI_TEXT) + this->m_arrUIData[i].m_wState &= ~CDynamicUpdateUI::UPDUI_TEXT; + } + } + } + + this->m_wDirtyType &= ~CDynamicUpdateUI::UPDUI_STATUSBAR; + return TRUE; + } + + bool UIAddStatusBar(HWND hWndStatusBar, INT nPanes = 1) + { + ATLASSERT(::IsWindow(hWndStatusBar)); + + // Add StatusBar panes + for (int iPane = 0; iPane < nPanes; iPane++) + UIAddElement::UPDUI_STATUSBAR>(ID_DEFAULT_PANE + iPane); + + return (CUpdateUIBase::UIAddStatusBar(hWndStatusBar) != FALSE); + } + +// UI Map used if derived class has none + BEGIN_UPDATE_UI_MAP(CAutoUpdateUI) + END_UPDATE_UI_MAP() +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CDialogResize - provides support for resizing dialog controls +// (works for any window that has child controls) + +// Put CDialogResize in the list of base classes for a dialog (or even plain window), +// then implement DLGRESIZE map by specifying controls and groups of control +// and using DLSZ_* values to specify how are they supposed to be resized. +// +// Notes: +// - Resizeable border (WS_THICKFRAME style) should be set in the dialog template +// for top level dialogs (popup or overlapped), so that users can resize the dialog. +// - Some flags cannot be combined; for instance DLSZ_CENTER_X overrides DLSZ_SIZE_X, +// DLSZ_SIZE_X overrides DLSZ_MOVE_X. X and Y flags can be combined. +// - Order of controls is important - group controls are resized and moved based +// on the position of the previous control in a group. + +// dialog resize map macros +struct _AtlDlgResizeMap +{ + int m_nCtlID; + DWORD m_dwResizeFlags; +}; + +#define BEGIN_DLGRESIZE_MAP(thisClass) \ + static const WTL::_AtlDlgResizeMap* GetDlgResizeMap() \ + { \ + static const WTL::_AtlDlgResizeMap theMap[] = \ + { + +#define END_DLGRESIZE_MAP() \ + { -1, 0 }, \ + }; \ + return theMap; \ + } + +#define DLGRESIZE_CONTROL(id, flags) \ + { id, flags }, + +#define BEGIN_DLGRESIZE_GROUP() \ + { -1, _DLSZ_BEGIN_GROUP }, + +#define END_DLGRESIZE_GROUP() \ + { -1, _DLSZ_END_GROUP }, + + +template +class CDialogResize +{ +public: +// Data declarations and members + enum + { + DLSZ_SIZE_X = 0x00000001, + DLSZ_SIZE_Y = 0x00000002, + DLSZ_MOVE_X = 0x00000004, + DLSZ_MOVE_Y = 0x00000008, + DLSZ_REPAINT = 0x00000010, + DLSZ_CENTER_X = 0x00000020, + DLSZ_CENTER_Y = 0x00000040, + + // internal use only + _DLSZ_BEGIN_GROUP = 0x00001000, + _DLSZ_END_GROUP = 0x00002000, + _DLSZ_GRIPPER = 0x00004000 + }; + + struct _AtlDlgResizeData + { + int m_nCtlID; + DWORD m_dwResizeFlags; + RECT m_rect; + + int GetGroupCount() const + { + return (int)LOBYTE(HIWORD(m_dwResizeFlags)); + } + + void SetGroupCount(int nCount) + { + ATLASSERT((nCount > 0) && (nCount < 256)); + DWORD dwCount = (DWORD)MAKELONG(0, MAKEWORD(nCount, 0)); + m_dwResizeFlags &= 0xFF00FFFF; + m_dwResizeFlags |= dwCount; + } + + bool operator ==(const _AtlDlgResizeData& r) const + { return ((m_nCtlID == r.m_nCtlID) && (m_dwResizeFlags == r.m_dwResizeFlags)); } + }; + + ATL::CSimpleArray<_AtlDlgResizeData> m_arrData; + SIZE m_sizeDialog; + POINT m_ptMinTrackSize; + bool m_bGripper; + + +// Constructor + CDialogResize() : m_bGripper(false) + { + m_sizeDialog.cx = 0; + m_sizeDialog.cy = 0; + m_ptMinTrackSize.x = -1; + m_ptMinTrackSize.y = -1; + } + +// Operations + void DlgResize_Init(bool bAddGripper = true, bool bUseMinTrackSize = true, DWORD dwForceStyle = WS_CLIPCHILDREN) + { + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + + DWORD dwStyle = pT->GetStyle(); + +#ifdef _DEBUG + // Debug only: Check if top level dialogs have a resizeable border. + if(((dwStyle & WS_CHILD) == 0) && ((dwStyle & WS_THICKFRAME) == 0)) + ATLTRACE2(atlTraceUI, 0, _T("DlgResize_Init - warning: top level dialog without the WS_THICKFRAME style - user cannot resize it\n")); +#endif // _DEBUG + + // Force specified styles (default WS_CLIPCHILDREN reduces flicker) + if((dwStyle & dwForceStyle) != dwForceStyle) + pT->ModifyStyle(0, dwForceStyle); + + // Adding this style removes an empty icon that dialogs with WS_THICKFRAME have. + // Setting icon to NULL is required when XP themes are active. + // Note: This will not prevent adding an icon for the dialog using SetIcon() + if((dwStyle & WS_CHILD) == 0) + { + pT->ModifyStyleEx(0, WS_EX_DLGMODALFRAME); + if(pT->GetIcon(FALSE) == NULL) + pT->SetIcon(NULL, FALSE); + } + + // Cleanup in case of multiple initialization + // block: first check for the gripper control, destroy it if needed + { + ATL::CWindow wndGripper = pT->GetDlgItem(ATL_IDW_STATUS_BAR); + if(wndGripper.IsWindow() && (m_arrData.GetSize() > 0) && (m_arrData[0].m_dwResizeFlags & _DLSZ_GRIPPER) != 0) + wndGripper.DestroyWindow(); + } + // clear out everything else + m_arrData.RemoveAll(); + m_sizeDialog.cx = 0; + m_sizeDialog.cy = 0; + m_ptMinTrackSize.x = -1; + m_ptMinTrackSize.y = -1; + + // Get initial dialog client size + RECT rectDlg = {}; + pT->GetClientRect(&rectDlg); + m_sizeDialog.cx = rectDlg.right; + m_sizeDialog.cy = rectDlg.bottom; + + // Create gripper if requested + m_bGripper = false; + if(bAddGripper) + { + // shouldn't exist already + ATLASSERT(!pT->GetDlgItem(ATL_IDW_STATUS_BAR).IsWindow()); + if(!pT->GetDlgItem(ATL_IDW_STATUS_BAR).IsWindow()) + { + ATL::CWindow wndGripper; + wndGripper.Create(_T("SCROLLBAR"), pT->m_hWnd, rectDlg, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | SBS_SIZEBOX | SBS_SIZEGRIP | SBS_SIZEBOXBOTTOMRIGHTALIGN, 0, ATL_IDW_STATUS_BAR); + ATLASSERT(wndGripper.IsWindow()); + if(wndGripper.IsWindow()) + { + m_bGripper = true; + RECT rectCtl = {}; + wndGripper.GetWindowRect(&rectCtl); + ::MapWindowPoints(NULL, pT->m_hWnd, (LPPOINT)&rectCtl, 2); + _AtlDlgResizeData data = { ATL_IDW_STATUS_BAR, DLSZ_MOVE_X | DLSZ_MOVE_Y | DLSZ_REPAINT | _DLSZ_GRIPPER, { rectCtl.left, rectCtl.top, rectCtl.right, rectCtl.bottom } }; + m_arrData.Add(data); + } + } + } + + // Get min track position if requested + if(bUseMinTrackSize) + { + if((dwStyle & WS_CHILD) != 0) + { + RECT rect = {}; + pT->GetClientRect(&rect); + m_ptMinTrackSize.x = rect.right - rect.left; + m_ptMinTrackSize.y = rect.bottom - rect.top; + } + else + { + RECT rect = {}; + pT->GetWindowRect(&rect); + m_ptMinTrackSize.x = rect.right - rect.left; + m_ptMinTrackSize.y = rect.bottom - rect.top; + } + } + + // Walk the map and initialize data + const _AtlDlgResizeMap* pMap = pT->GetDlgResizeMap(); + ATLASSERT(pMap != NULL); + int nGroupStart = -1; + for(int nCount = 1; !((pMap->m_nCtlID == -1) && (pMap->m_dwResizeFlags == 0)); nCount++, pMap++) + { + if(pMap->m_nCtlID == -1) + { + switch(pMap->m_dwResizeFlags) + { + case _DLSZ_BEGIN_GROUP: + ATLASSERT(nGroupStart == -1); + nGroupStart = m_arrData.GetSize(); + break; + case _DLSZ_END_GROUP: + { + ATLASSERT(nGroupStart != -1); + int nGroupCount = m_arrData.GetSize() - nGroupStart; + m_arrData[nGroupStart].SetGroupCount(nGroupCount); + nGroupStart = -1; + } + break; + default: + ATLASSERT(FALSE && _T("Invalid DLGRESIZE Map Entry")); + break; + } + } + else + { + // this ID conflicts with the default gripper one + ATLASSERT(m_bGripper ? (pMap->m_nCtlID != ATL_IDW_STATUS_BAR) : TRUE); + + ATL::CWindow ctl = pT->GetDlgItem(pMap->m_nCtlID); + ATLASSERT(ctl.IsWindow()); + RECT rectCtl = {}; + ctl.GetWindowRect(&rectCtl); + ::MapWindowPoints(NULL, pT->m_hWnd, (LPPOINT)&rectCtl, 2); + + DWORD dwGroupFlag = ((nGroupStart != -1) && (m_arrData.GetSize() == nGroupStart)) ? _DLSZ_BEGIN_GROUP : 0; + _AtlDlgResizeData data = { pMap->m_nCtlID, pMap->m_dwResizeFlags | dwGroupFlag, { rectCtl.left, rectCtl.top, rectCtl.right, rectCtl.bottom } }; + m_arrData.Add(data); + } + } + ATLASSERT((nGroupStart == -1) && _T("No End Group Entry in the DLGRESIZE Map")); + } + + void DlgResize_UpdateLayout(int cxWidth, int cyHeight) + { + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + + // Restrict minimum size if requested + if(((pT->GetStyle() & WS_CHILD) != 0) && (m_ptMinTrackSize.x != -1) && (m_ptMinTrackSize.y != -1)) + { + if(cxWidth < m_ptMinTrackSize.x) + cxWidth = m_ptMinTrackSize.x; + if(cyHeight < m_ptMinTrackSize.y) + cyHeight = m_ptMinTrackSize.y; + } + + BOOL bVisible = pT->IsWindowVisible(); + if(bVisible) + pT->SetRedraw(FALSE); + + for(int i = 0; i < m_arrData.GetSize(); i++) + { + if((m_arrData[i].m_dwResizeFlags & _DLSZ_BEGIN_GROUP) != 0) // start of a group + { + int nGroupCount = m_arrData[i].GetGroupCount(); + ATLASSERT((nGroupCount > 0) && ((i + nGroupCount - 1) < m_arrData.GetSize())); + RECT rectGroup = m_arrData[i].m_rect; + + int j = 1; + for(j = 1; j < nGroupCount; j++) + { + rectGroup.left = __min(rectGroup.left, m_arrData[i + j].m_rect.left); + rectGroup.top = __min(rectGroup.top, m_arrData[i + j].m_rect.top); + rectGroup.right = __max(rectGroup.right, m_arrData[i + j].m_rect.right); + rectGroup.bottom = __max(rectGroup.bottom, m_arrData[i + j].m_rect.bottom); + } + + for(j = 0; j < nGroupCount; j++) + { + _AtlDlgResizeData* pDataPrev = NULL; + if(j > 0) + pDataPrev = &(m_arrData[i + j - 1]); + pT->DlgResize_PositionControl(cxWidth, cyHeight, rectGroup, m_arrData[i + j], true, pDataPrev); + } + + i += nGroupCount - 1; // increment to skip all group controls + } + else // one control entry + { + RECT rectGroup = {}; + pT->DlgResize_PositionControl(cxWidth, cyHeight, rectGroup, m_arrData[i], false); + } + } + + if(bVisible) + pT->SetRedraw(TRUE); + + pT->RedrawWindow(NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_UPDATENOW | RDW_ALLCHILDREN); + } + +// Message map and handlers + BEGIN_MSG_MAP(CDialogResize) + MESSAGE_HANDLER(WM_SIZE, OnSize) + MESSAGE_HANDLER(WM_GETMINMAXINFO, OnGetMinMaxInfo) + END_MSG_MAP() + + LRESULT OnSize(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) + { + T* pT = static_cast(this); + if(m_bGripper) + { + ATL::CWindow wndGripper = pT->GetDlgItem(ATL_IDW_STATUS_BAR); + if(wParam == SIZE_MAXIMIZED) + wndGripper.ShowWindow(SW_HIDE); + else if(wParam == SIZE_RESTORED) + wndGripper.ShowWindow(SW_SHOW); + } + if(wParam != SIZE_MINIMIZED) + { + ATLASSERT(::IsWindow(pT->m_hWnd)); + pT->DlgResize_UpdateLayout(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); + } + return 0; + } + + LRESULT OnGetMinMaxInfo(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/) + { + if((m_ptMinTrackSize.x != -1) && (m_ptMinTrackSize.y != -1)) + { + LPMINMAXINFO lpMMI = (LPMINMAXINFO)lParam; + lpMMI->ptMinTrackSize = m_ptMinTrackSize; + } + return 0; + } + +// Implementation + bool DlgResize_PositionControl(int cxWidth, int cyHeight, RECT& rectGroup, _AtlDlgResizeData& data, bool bGroup, + _AtlDlgResizeData* pDataPrev = NULL) + { + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + ATL::CWindow ctl; + RECT rectCtl = {}; + + ctl = pT->GetDlgItem(data.m_nCtlID); + if(!ctl.GetWindowRect(&rectCtl)) + return false; + ::MapWindowPoints(NULL, pT->m_hWnd, (LPPOINT)&rectCtl, 2); + + if(bGroup) + { + if((data.m_dwResizeFlags & DLSZ_CENTER_X) != 0) + { + int cxRight = rectGroup.right + cxWidth - m_sizeDialog.cx; + int cxCtl = data.m_rect.right - data.m_rect.left; + rectCtl.left = rectGroup.left + (cxRight - rectGroup.left - cxCtl) / 2; + rectCtl.right = rectCtl.left + cxCtl; + } + else if((data.m_dwResizeFlags & (DLSZ_SIZE_X | DLSZ_MOVE_X)) != 0) + { + rectCtl.left = rectGroup.left + ::MulDiv(data.m_rect.left - rectGroup.left, rectGroup.right - rectGroup.left + (cxWidth - m_sizeDialog.cx), rectGroup.right - rectGroup.left); + + if((data.m_dwResizeFlags & DLSZ_SIZE_X) != 0) + { + rectCtl.right = rectGroup.left + ::MulDiv(data.m_rect.right - rectGroup.left, rectGroup.right - rectGroup.left + (cxWidth - m_sizeDialog.cx), rectGroup.right - rectGroup.left); + + if(pDataPrev != NULL) + { + ATL::CWindow ctlPrev = pT->GetDlgItem(pDataPrev->m_nCtlID); + RECT rcPrev = {}; + ctlPrev.GetWindowRect(&rcPrev); + ::MapWindowPoints(NULL, pT->m_hWnd, (LPPOINT)&rcPrev, 2); + int dxAdjust = (rectCtl.left - rcPrev.right) - (data.m_rect.left - pDataPrev->m_rect.right); + rcPrev.right += dxAdjust; + ctlPrev.SetWindowPos(NULL, &rcPrev, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOMOVE); + } + } + else + { + rectCtl.right = rectCtl.left + (data.m_rect.right - data.m_rect.left); + } + } + + if((data.m_dwResizeFlags & DLSZ_CENTER_Y) != 0) + { + int cyBottom = rectGroup.bottom + cyHeight - m_sizeDialog.cy; + int cyCtl = data.m_rect.bottom - data.m_rect.top; + rectCtl.top = rectGroup.top + (cyBottom - rectGroup.top - cyCtl) / 2; + rectCtl.bottom = rectCtl.top + cyCtl; + } + else if((data.m_dwResizeFlags & (DLSZ_SIZE_Y | DLSZ_MOVE_Y)) != 0) + { + rectCtl.top = rectGroup.top + ::MulDiv(data.m_rect.top - rectGroup.top, rectGroup.bottom - rectGroup.top + (cyHeight - m_sizeDialog.cy), rectGroup.bottom - rectGroup.top); + + if((data.m_dwResizeFlags & DLSZ_SIZE_Y) != 0) + { + rectCtl.bottom = rectGroup.top + ::MulDiv(data.m_rect.bottom - rectGroup.top, rectGroup.bottom - rectGroup.top + (cyHeight - m_sizeDialog.cy), rectGroup.bottom - rectGroup.top); + + if(pDataPrev != NULL) + { + ATL::CWindow ctlPrev = pT->GetDlgItem(pDataPrev->m_nCtlID); + RECT rcPrev = {}; + ctlPrev.GetWindowRect(&rcPrev); + ::MapWindowPoints(NULL, pT->m_hWnd, (LPPOINT)&rcPrev, 2); + int dxAdjust = (rectCtl.top - rcPrev.bottom) - (data.m_rect.top - pDataPrev->m_rect.bottom); + rcPrev.bottom += dxAdjust; + ctlPrev.SetWindowPos(NULL, &rcPrev, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOMOVE); + } + } + else + { + rectCtl.bottom = rectCtl.top + (data.m_rect.bottom - data.m_rect.top); + } + } + } + else // no group + { + if((data.m_dwResizeFlags & DLSZ_CENTER_X) != 0) + { + int cxCtl = data.m_rect.right - data.m_rect.left; + rectCtl.left = (cxWidth - cxCtl) / 2; + rectCtl.right = rectCtl.left + cxCtl; + } + else if((data.m_dwResizeFlags & (DLSZ_SIZE_X | DLSZ_MOVE_X)) != 0) + { + rectCtl.right = data.m_rect.right + (cxWidth - m_sizeDialog.cx); + + if((data.m_dwResizeFlags & DLSZ_MOVE_X) != 0) + rectCtl.left = rectCtl.right - (data.m_rect.right - data.m_rect.left); + } + + if((data.m_dwResizeFlags & DLSZ_CENTER_Y) != 0) + { + int cyCtl = data.m_rect.bottom - data.m_rect.top; + rectCtl.top = (cyHeight - cyCtl) / 2; + rectCtl.bottom = rectCtl.top + cyCtl; + } + else if((data.m_dwResizeFlags & (DLSZ_SIZE_Y | DLSZ_MOVE_Y)) != 0) + { + rectCtl.bottom = data.m_rect.bottom + (cyHeight - m_sizeDialog.cy); + + if((data.m_dwResizeFlags & DLSZ_MOVE_Y) != 0) + rectCtl.top = rectCtl.bottom - (data.m_rect.bottom - data.m_rect.top); + } + } + + if((data.m_dwResizeFlags & DLSZ_REPAINT) != 0) + ctl.Invalidate(); + + if((data.m_dwResizeFlags & (DLSZ_SIZE_X | DLSZ_SIZE_Y | DLSZ_MOVE_X | DLSZ_MOVE_Y | DLSZ_REPAINT | DLSZ_CENTER_X | DLSZ_CENTER_Y)) != 0) + ctl.SetWindowPos(NULL, &rectCtl, SWP_NOZORDER | SWP_NOACTIVATE); + + return true; + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CDynamicDialogLayout - support for dialog dynamic layout resource info +// (AFX_DIALOG_LAYOUT) in VS2015 and higher + +#if (_MSC_VER >= 1900) + +template +class CDynamicDialogLayout +{ +public: +// Data declarations + struct _AtlDynamicLayoutData + { + HWND m_hWnd; + char m_nMoveRatioX; + char m_nMoveRatioY; + char m_nSizeRatioX; + char m_nSizeRatioY; + RECT m_rcInit; + }; + +// Data members + ATL::CSimpleArray<_AtlDynamicLayoutData> m_arrLayoutData; + SIZE m_szParentInit; + POINT m_ptMinTrackSize; + bool m_bGripper; + +// Constructor + CDynamicDialogLayout() : m_bGripper(false) + { + m_szParentInit.cx = 0; + m_szParentInit.cy = 0; + m_ptMinTrackSize.x = -1; + m_ptMinTrackSize.y = -1; + } + +// Methods + void InitDynamicLayout(bool bAddGripper = true, bool bMinTrackSize = true) + { + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + + // Cleanup in case of multiple initialization + // block: first check for the gripper control, destroy it if needed + { + ATL::CWindow wndGripper = pT->GetDlgItem(ATL_IDW_STATUS_BAR); + if(wndGripper.IsWindow() != FALSE) + wndGripper.DestroyWindow(); + } + // clear out everything else + m_arrLayoutData.RemoveAll(); + m_ptMinTrackSize.x = -1; + m_ptMinTrackSize.y = -1; + m_szParentInit.cx = 0; + m_szParentInit.cy = 0; + m_bGripper = false; + + CResource rcLayout; + if(rcLayout.Load(_T("AFX_DIALOG_LAYOUT"), pT->IDD)) + { + int nCount = rcLayout.GetSize() / sizeof(WORD); + if(nCount > 1) + { + RECT rcParent = {}; + pT->GetWindowRect(&rcParent); + m_szParentInit.cx = rcParent.right - rcParent.left; + m_szParentInit.cy = rcParent.bottom - rcParent.top; + + WORD* pnData = (WORD*)rcLayout.Lock(); + WORD wVersion = *pnData; // AFX_DIALOG_LAYOUT version + ATLASSERT(wVersion == 0); + if(wVersion == 0) + { + pnData++; // skip version + ATL::CWindow wndChild = pT->GetWindow(GW_CHILD); + for(int i = 0; (i < nCount) && (wndChild.m_hWnd != NULL); i += 4) + { + char nMoveRatioX = _GetDataPct(pnData[i]); + char nMoveRatioY = _GetDataPct(pnData[i + 1]); + char nSizeRatioX = _GetDataPct(pnData[i + 2]); + char nSizeRatioY = _GetDataPct(pnData[i + 3]); + + bool bValid = ((nMoveRatioX != -1) && (nMoveRatioY != -1) && (nSizeRatioX != -1) && (nSizeRatioY != -1)); + bool bAction = ((nMoveRatioX != 0) || (nMoveRatioY != 0) || (nSizeRatioX != 0) || (nSizeRatioY != 0)); + if(bValid && bAction) + { + _AtlDynamicLayoutData LayoutData = { wndChild.m_hWnd, nMoveRatioX, nMoveRatioY, nSizeRatioX, nSizeRatioY }; + wndChild.GetWindowRect(&LayoutData.m_rcInit); + pT->ScreenToClient(&LayoutData.m_rcInit); + m_arrLayoutData.Add(LayoutData); + } + + wndChild = wndChild.GetWindow(GW_HWNDNEXT); + } + } + + rcLayout.Release(); + } + } + + if(bAddGripper) + { + RECT rcDialog = {}; + pT->GetClientRect(&rcDialog); + + ATL::CWindow wndGripper = pT->GetDlgItem(ATL_IDW_STATUS_BAR); + if(wndGripper.m_hWnd != NULL) + wndGripper.DestroyWindow(); + + wndGripper.Create(_T("SCROLLBAR"), pT->m_hWnd, rcDialog, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | SBS_SIZEBOX | SBS_SIZEGRIP | SBS_SIZEBOXBOTTOMRIGHTALIGN, 0, ATL_IDW_STATUS_BAR); + ATLASSERT(wndGripper.m_hWnd != NULL); + if(wndGripper.m_hWnd != NULL) + { + m_bGripper = true; + _AtlDynamicLayoutData LayoutData = { wndGripper.m_hWnd, 100, 100, 0, 0 }; + wndGripper.GetWindowRect(&LayoutData.m_rcInit); + pT->ScreenToClient(&LayoutData.m_rcInit); + m_arrLayoutData.Add(LayoutData); + } + } + + if(bMinTrackSize) + { + RECT rcMinTrack = {}; + if((pT->GetStyle() & WS_CHILD) != 0) + pT->GetClientRect(&rcMinTrack); + else + pT->GetWindowRect(&rcMinTrack); + + m_ptMinTrackSize.x = rcMinTrack.right - rcMinTrack.left; + m_ptMinTrackSize.y = rcMinTrack.bottom - rcMinTrack.top; + } + } + + void UpdateDynamicLayout() + { + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + + int nCount = m_arrLayoutData.GetSize(); + if(nCount == 0) + return; + + RECT rcParent = {}; + pT->GetWindowRect(&rcParent); + + int nDeltaWidth = rcParent.right - rcParent.left - m_szParentInit.cx; + int nDeltaHeight = rcParent.bottom - rcParent.top - m_szParentInit.cy; + + HDWP hDwp = ::BeginDeferWindowPos(nCount); + + for(int i = 0; i < nCount; i++) + { + _AtlDynamicLayoutData& LayoutData = m_arrLayoutData[i]; + + ATLASSERT(::IsWindow(LayoutData.m_hWnd) != FALSE); + + int nID = ::GetDlgCtrlID(LayoutData.m_hWnd); + UINT nFlags = (SWP_NOMOVE | SWP_NOSIZE); + RECT rcItem = LayoutData.m_rcInit; + + if(((nID == ATL_IDW_STATUS_BAR) || (nDeltaWidth >= 0)) && (LayoutData.m_nMoveRatioX != 0)) + { + rcItem.left += ::MulDiv(nDeltaWidth, LayoutData.m_nMoveRatioX, 100); + rcItem.right += ::MulDiv(nDeltaWidth, LayoutData.m_nMoveRatioX, 100); + nFlags &= ~SWP_NOMOVE; + } + + if(((nID == ATL_IDW_STATUS_BAR) || (nDeltaHeight >= 0)) && (LayoutData.m_nMoveRatioY != 0)) + { + rcItem.top += ::MulDiv(nDeltaHeight, LayoutData.m_nMoveRatioY, 100); + rcItem.bottom += ::MulDiv(nDeltaHeight, LayoutData.m_nMoveRatioY, 100); + nFlags &= ~SWP_NOMOVE; + } + + if((nDeltaWidth >= 0) && (LayoutData.m_nSizeRatioX != 0)) + { + rcItem.right += ::MulDiv(nDeltaWidth, LayoutData.m_nSizeRatioX, 100); + nFlags &= ~SWP_NOSIZE; + } + + if((nDeltaHeight >= 0) && (LayoutData.m_nSizeRatioY != 0)) + { + rcItem.bottom += ::MulDiv(nDeltaHeight, LayoutData.m_nSizeRatioY, 100); + nFlags &= ~SWP_NOSIZE; + } + + if(nFlags != (SWP_NOMOVE | SWP_NOSIZE)) + ::DeferWindowPos(hDwp, LayoutData.m_hWnd, NULL, rcItem.left, rcItem.top, rcItem.right - rcItem.left, rcItem.bottom - rcItem.top, nFlags | SWP_NOZORDER | SWP_NOREPOSITION | SWP_NOACTIVATE | SWP_NOCOPYBITS); + } + + ::EndDeferWindowPos(hDwp); + } + +// Message map and handlers + BEGIN_MSG_MAP(CDynamicDialogLayout) + MESSAGE_HANDLER(WM_SIZE, OnSize) + MESSAGE_HANDLER(WM_GETMINMAXINFO, OnGetMinMaxInfo) + END_MSG_MAP() + + LRESULT OnSize(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + T* pT = static_cast(this); + + if(m_bGripper) + { + ATL::CWindow wndGripper = pT->GetDlgItem(ATL_IDW_STATUS_BAR); + if(wndGripper.m_hWnd != NULL) + { + if(wParam == SIZE_MAXIMIZED) + wndGripper.ShowWindow(SW_HIDE); + else if(wParam == SIZE_RESTORED) + wndGripper.ShowWindow(SW_SHOW); + } + } + + if(wParam != SIZE_MINIMIZED) + pT->UpdateDynamicLayout(); + + return 0; + } + + LRESULT OnGetMinMaxInfo(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/) + { + if((m_ptMinTrackSize.x != -1) && (m_ptMinTrackSize.y != -1)) + { + LPMINMAXINFO lpMMI = (LPMINMAXINFO)lParam; + lpMMI->ptMinTrackSize = m_ptMinTrackSize; + } + + return 0; + } + +// Implementation + char _GetDataPct(WORD wResData) + { + ATLASSERT((wResData >= 0) && (wResData <= 100)); + char nPct = (char)LOBYTE(wResData); + if((nPct < 0) || (nPct > 100)) + nPct = -1; + + return nPct; + } +}; + +#endif // (_MSC_VER >= 1900) + + +/////////////////////////////////////////////////////////////////////////////// +// CDoubleBufferImpl - Provides double-buffer painting support to any window + +template +class CDoubleBufferImpl +{ +public: +// Overrideables + void DoPaint(CDCHandle /*dc*/) + { + // must be implemented in a derived class + ATLASSERT(FALSE); + } + +// Message map and handlers + BEGIN_MSG_MAP(CDoubleBufferImpl) + MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground) + MESSAGE_HANDLER(WM_PAINT, OnPaint) + MESSAGE_HANDLER(WM_PRINTCLIENT, OnPaint) + END_MSG_MAP() + + LRESULT OnEraseBackground(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + return 1; // no background painting needed + } + + LRESULT OnPaint(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + + if(wParam != NULL) + { + RECT rect = {}; + pT->GetClientRect(&rect); + CMemoryDC dcMem((HDC)wParam, rect); + pT->DoPaint(dcMem.m_hDC); + } + else + { + CPaintDC dc(pT->m_hWnd); + CMemoryDC dcMem(dc.m_hDC, dc.m_ps.rcPaint); + pT->DoPaint(dcMem.m_hDC); + } + + return 0; + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CDoubleBufferWindowImpl - Implements a double-buffer painting window + +template +class ATL_NO_VTABLE CDoubleBufferWindowImpl : public ATL::CWindowImpl< T, TBase, TWinTraits >, public CDoubleBufferImpl< T > +{ +public: + BEGIN_MSG_MAP(CDoubleBufferWindowImpl) + CHAIN_MSG_MAP(CDoubleBufferImpl< T >) + END_MSG_MAP() +}; + + +// command bar support +#if !defined(__ATLCTRLW_H__) + #undef CBRM_GETMENU + #undef CBRM_TRACKPOPUPMENU + #undef CBRM_GETCMDBAR + #undef CBRPOPUPMENU +#endif // !defined(__ATLCTRLW_H__) + +} // namespace WTL + +#endif // __ATLFRAME_H__ diff -r e9bb126753e7 -r 20d02a178406 foosdk/wtl/Include/atlgdi.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/wtl/Include/atlgdi.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,3442 @@ +// Windows Template Library - WTL version 10.0 +// Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. +// +// This file is a part of the Windows Template Library. +// The use and distribution terms for this software are covered by the +// Microsoft Public License (http://opensource.org/licenses/MS-PL) +// which can be found in the file MS-PL.txt at the root folder. + +#ifndef __ATLGDI_H__ +#define __ATLGDI_H__ + +#pragma once + +#ifndef __ATLAPP_H__ + #error atlgdi.h requires atlapp.h to be included first +#endif + + +// protect template members from windowsx.h macros +#ifdef _INC_WINDOWSX + #undef CopyRgn + #undef CreateBrush + #undef CreatePen + #undef SelectBrush + #undef SelectPen + #undef SelectFont + #undef SelectBitmap +#endif // _INC_WINDOWSX + +// required libraries +#pragma comment(lib, "msimg32.lib") +#if !defined(_ATL_NO_OPENGL) + #pragma comment(lib, "opengl32.lib") +#endif + + +/////////////////////////////////////////////////////////////////////////////// +// Classes in this file: +// +// CPenT +// CBrushT +// CLogFont +// CFontT +// CBitmapT +// CPaletteT +// CRgnT +// CDCT +// CPaintDC +// CClientDC +// CWindowDC +// CMemoryDC +// CEnhMetaFileInfo +// CEnhMetaFileT +// CEnhMetaFileDC + + +namespace WTL +{ + +/////////////////////////////////////////////////////////////////////////////// +// Bitmap resource helpers to extract bitmap information for a bitmap resource + +inline LPBITMAPINFOHEADER AtlGetBitmapResourceInfo(HMODULE hModule, ATL::_U_STRINGorID image) +{ + HRSRC hResource = ::FindResource(hModule, image.m_lpstr, RT_BITMAP); + ATLASSERT(hResource != NULL); + HGLOBAL hGlobal = ::LoadResource(hModule, hResource); + ATLASSERT(hGlobal != NULL); + LPBITMAPINFOHEADER pBitmapInfoHeader = (LPBITMAPINFOHEADER)::LockResource(hGlobal); + ATLASSERT(pBitmapInfoHeader != NULL); + return pBitmapInfoHeader; +} + +inline WORD AtlGetBitmapResourceBitsPerPixel(HMODULE hModule, ATL::_U_STRINGorID image) +{ + LPBITMAPINFOHEADER pBitmapInfoHeader = AtlGetBitmapResourceInfo(hModule, image); + ATLASSERT(pBitmapInfoHeader != NULL); + return pBitmapInfoHeader->biBitCount; +} + +inline WORD AtlGetBitmapResourceBitsPerPixel(ATL::_U_STRINGorID image) +{ + return AtlGetBitmapResourceBitsPerPixel(ModuleHelper::GetResourceInstance(), image); +} + +/////////////////////////////////////////////////////////////////////////////// +// 32-bit (alpha channel) bitmap resource helper + +// Note: 32-bit (alpha channel) images work only on Windows XP with Common Controls version 6. +// If you want your app to work on older version of Windows, load non-alpha images if Common +// Controls version is less than 6. + +inline bool AtlIsAlphaBitmapResource(ATL::_U_STRINGorID image) +{ + return (AtlGetBitmapResourceBitsPerPixel(image) == 32); +} + + +/////////////////////////////////////////////////////////////////////////////// +// CPen + +template +class CPenT +{ +public: +// Data members + HPEN m_hPen; + +// Constructor/destructor/operators + CPenT(HPEN hPen = NULL) : m_hPen(hPen) + { } + + ~CPenT() + { + if(t_bManaged && (m_hPen != NULL)) + DeleteObject(); + } + + CPenT& operator =(HPEN hPen) + { + Attach(hPen); + return *this; + } + + void Attach(HPEN hPen) + { + if(t_bManaged && (m_hPen != NULL) && (m_hPen != hPen)) + ::DeleteObject(m_hPen); + m_hPen = hPen; + } + + HPEN Detach() + { + HPEN hPen = m_hPen; + m_hPen = NULL; + return hPen; + } + + operator HPEN() const { return m_hPen; } + + bool IsNull() const { return (m_hPen == NULL); } + +// Create methods + HPEN CreatePen(int nPenStyle, int nWidth, COLORREF crColor) + { + ATLASSERT(m_hPen == NULL); + m_hPen = ::CreatePen(nPenStyle, nWidth, crColor); + return m_hPen; + } + + HPEN CreatePen(int nPenStyle, int nWidth, const LOGBRUSH* pLogBrush, int nStyleCount = 0, const DWORD* lpStyle = NULL) + { + ATLASSERT(m_hPen == NULL); + m_hPen = ::ExtCreatePen(nPenStyle, nWidth, pLogBrush, nStyleCount, lpStyle); + return m_hPen; + } + + HPEN CreatePenIndirect(LPLOGPEN lpLogPen) + { + ATLASSERT(m_hPen == NULL); + m_hPen = ::CreatePenIndirect(lpLogPen); + return m_hPen; + } + + BOOL DeleteObject() + { + ATLASSERT(m_hPen != NULL); + BOOL bRet = ::DeleteObject(m_hPen); + if(bRet) + m_hPen = NULL; + return bRet; + } + +// Attributes + int GetLogPen(LOGPEN* pLogPen) const + { + ATLASSERT(m_hPen != NULL); + return ::GetObject(m_hPen, sizeof(LOGPEN), pLogPen); + } + + bool GetLogPen(LOGPEN& LogPen) const + { + ATLASSERT(m_hPen != NULL); + return (::GetObject(m_hPen, sizeof(LOGPEN), &LogPen) == sizeof(LOGPEN)); + } + + int GetExtLogPen(EXTLOGPEN* pLogPen, int nSize = sizeof(EXTLOGPEN)) const + { + ATLASSERT(m_hPen != NULL); + return ::GetObject(m_hPen, nSize, pLogPen); + } + + bool GetExtLogPen(EXTLOGPEN& ExtLogPen, int nSize = sizeof(EXTLOGPEN)) const + { + ATLASSERT(m_hPen != NULL); + int nRet = ::GetObject(m_hPen, nSize, &ExtLogPen); + return ((nRet > 0) && (nRet <= nSize)); + } +}; + +typedef CPenT CPenHandle; +typedef CPenT CPen; + + +/////////////////////////////////////////////////////////////////////////////// +// CBrush + +template +class CBrushT +{ +public: +// Data members + HBRUSH m_hBrush; + +// Constructor/destructor/operators + CBrushT(HBRUSH hBrush = NULL) : m_hBrush(hBrush) + { } + + ~CBrushT() + { + if(t_bManaged && (m_hBrush != NULL)) + DeleteObject(); + } + + CBrushT& operator =(HBRUSH hBrush) + { + Attach(hBrush); + return *this; + } + + void Attach(HBRUSH hBrush) + { + if(t_bManaged && (m_hBrush != NULL) && (m_hBrush != hBrush)) + ::DeleteObject(m_hBrush); + m_hBrush = hBrush; + } + + HBRUSH Detach() + { + HBRUSH hBrush = m_hBrush; + m_hBrush = NULL; + return hBrush; + } + + operator HBRUSH() const { return m_hBrush; } + + bool IsNull() const { return (m_hBrush == NULL); } + +// Create methods + HBRUSH CreateSolidBrush(COLORREF crColor) + { + ATLASSERT(m_hBrush == NULL); + m_hBrush = ::CreateSolidBrush(crColor); + return m_hBrush; + } + + HBRUSH CreateHatchBrush(int nIndex, COLORREF crColor) + { + ATLASSERT(m_hBrush == NULL); + m_hBrush = ::CreateHatchBrush(nIndex, crColor); + return m_hBrush; + } + + HBRUSH CreateBrushIndirect(const LOGBRUSH* lpLogBrush) + { + ATLASSERT(m_hBrush == NULL); + m_hBrush = ::CreateBrushIndirect(lpLogBrush); + return m_hBrush; + } + + HBRUSH CreatePatternBrush(HBITMAP hBitmap) + { + ATLASSERT(m_hBrush == NULL); + m_hBrush = ::CreatePatternBrush(hBitmap); + return m_hBrush; + } + + HBRUSH CreateDIBPatternBrush(HGLOBAL hPackedDIB, UINT nUsage) + { + ATLASSERT(hPackedDIB != NULL); + const void* lpPackedDIB = GlobalLock(hPackedDIB); + ATLASSERT(lpPackedDIB != NULL); + m_hBrush = ::CreateDIBPatternBrushPt(lpPackedDIB, nUsage); + GlobalUnlock(hPackedDIB); + return m_hBrush; + } + + HBRUSH CreateDIBPatternBrush(const void* lpPackedDIB, UINT nUsage) + { + ATLASSERT(m_hBrush == NULL); + m_hBrush = ::CreateDIBPatternBrushPt(lpPackedDIB, nUsage); + return m_hBrush; + } + + HBRUSH CreateSysColorBrush(int nIndex) + { + ATLASSERT(m_hBrush == NULL); + m_hBrush = ::GetSysColorBrush(nIndex); + return m_hBrush; + } + + BOOL DeleteObject() + { + ATLASSERT(m_hBrush != NULL); + BOOL bRet = ::DeleteObject(m_hBrush); + if(bRet) + m_hBrush = NULL; + return bRet; + } + +// Attributes + int GetLogBrush(LOGBRUSH* pLogBrush) const + { + ATLASSERT(m_hBrush != NULL); + return ::GetObject(m_hBrush, sizeof(LOGBRUSH), pLogBrush); + } + + bool GetLogBrush(LOGBRUSH& LogBrush) const + { + ATLASSERT(m_hBrush != NULL); + return (::GetObject(m_hBrush, sizeof(LOGBRUSH), &LogBrush) == sizeof(LOGBRUSH)); + } +}; + +typedef CBrushT CBrushHandle; +typedef CBrushT CBrush; + + +/////////////////////////////////////////////////////////////////////////////// +// CFont + +class CLogFont : public LOGFONT +{ +public: + CLogFont() + { + memset(this, 0, sizeof(LOGFONT)); + } + + CLogFont(const LOGFONT& lf) + { + Copy(&lf); + } + + CLogFont(HFONT hFont) + { + ATLASSERT(::GetObjectType(hFont) == OBJ_FONT); + ::GetObject(hFont, sizeof(LOGFONT), (LOGFONT*)this); + } + + HFONT CreateFontIndirect() + { + return ::CreateFontIndirect(this); + } + + void SetBold() + { + lfWeight = FW_BOLD; + } + + bool IsBold() const + { + return (lfWeight >= FW_BOLD); + } + + void MakeBolder(int iScale = 1) + { + lfWeight += FW_BOLD * iScale; + } + + void MakeLarger(int iScale) + { + if(lfHeight > 0) + lfHeight += iScale; + else + lfHeight -= iScale; + } + + void SetHeight(LONG nPointSize, HDC hDC = NULL) + { + HDC hDC1 = (hDC != NULL) ? hDC : ::GetDC(NULL); + // For MM_TEXT mapping mode + lfHeight = -::MulDiv(nPointSize, ::GetDeviceCaps(hDC1, LOGPIXELSY), 72); + if(hDC == NULL) + ::ReleaseDC(NULL, hDC1); + } + + LONG GetHeight(HDC hDC = NULL) const + { + HDC hDC1 = (hDC != NULL) ? hDC : ::GetDC(NULL); + // For MM_TEXT mapping mode + LONG nPointSize = ::MulDiv(-lfHeight, 72, ::GetDeviceCaps(hDC1, LOGPIXELSY)); + if(hDC == NULL) + ::ReleaseDC(NULL, hDC1); + + return nPointSize; + } + + LONG GetDeciPointHeight(HDC hDC = NULL) const + { + HDC hDC1 = (hDC != NULL) ? hDC : ::GetDC(NULL); + POINT ptOrg = { 0, 0 }; + ::DPtoLP(hDC1, &ptOrg, 1); + POINT pt = { 0, 0 }; + pt.y = abs(lfHeight) + ptOrg.y; + ::LPtoDP(hDC1, &pt, 1); + LONG nDeciPoint = ::MulDiv(pt.y, 720, ::GetDeviceCaps(hDC1, LOGPIXELSY)); // 72 points/inch, 10 decipoints/point + if(hDC == NULL) + ::ReleaseDC(NULL, hDC1); + + return nDeciPoint; + } + + void SetHeightFromDeciPoint(LONG nDeciPtHeight, HDC hDC = NULL) + { + HDC hDC1 = (hDC != NULL) ? hDC : ::GetDC(NULL); + POINT pt = { 0, 0 }; + pt.y = ::MulDiv(::GetDeviceCaps(hDC1, LOGPIXELSY), nDeciPtHeight, 720); // 72 points/inch, 10 decipoints/point + ::DPtoLP(hDC1, &pt, 1); + POINT ptOrg = { 0, 0 }; + ::DPtoLP(hDC1, &ptOrg, 1); + lfHeight = -abs(pt.y - ptOrg.y); + if(hDC == NULL) + ::ReleaseDC(NULL, hDC1); + } + + void SetCaptionFont() + { + NONCLIENTMETRICS ncm = { RunTimeHelper::SizeOf_NONCLIENTMETRICS() }; + ATLVERIFY(::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(ncm), &ncm, 0)); + Copy(&ncm.lfCaptionFont); + } + + void SetMenuFont() + { + NONCLIENTMETRICS ncm = { RunTimeHelper::SizeOf_NONCLIENTMETRICS() }; + ATLVERIFY(::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(ncm), &ncm, 0)); + Copy(&ncm.lfMenuFont); + } + + void SetStatusFont() + { + NONCLIENTMETRICS ncm = { RunTimeHelper::SizeOf_NONCLIENTMETRICS() }; + ATLVERIFY(::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(ncm), &ncm, 0)); + Copy(&ncm.lfStatusFont); + } + + void SetMessageBoxFont() + { + NONCLIENTMETRICS ncm = { RunTimeHelper::SizeOf_NONCLIENTMETRICS() }; + ATLVERIFY(::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(ncm), &ncm, 0)); + Copy(&ncm.lfMessageFont); + } + + void Copy(const LOGFONT* pLogFont) + { + ATLASSERT(pLogFont != NULL); + *(LOGFONT*)this = *pLogFont; + } + + CLogFont& operator =(const CLogFont& src) + { + Copy(&src); + return *this; + } + + CLogFont& operator =(const LOGFONT& src) + { + Copy(&src); + return *this; + } + + CLogFont& operator =(HFONT hFont) + { + ATLASSERT(::GetObjectType(hFont) == OBJ_FONT); + ::GetObject(hFont, sizeof(LOGFONT), (LOGFONT*)this); + return *this; + } + + bool operator ==(const LOGFONT& logfont) const + { + return((logfont.lfHeight == lfHeight) && + (logfont.lfWidth == lfWidth) && + (logfont.lfEscapement == lfEscapement) && + (logfont.lfOrientation == lfOrientation) && + (logfont.lfWeight == lfWeight) && + (logfont.lfItalic == lfItalic) && + (logfont.lfUnderline == lfUnderline) && + (logfont.lfStrikeOut == lfStrikeOut) && + (logfont.lfCharSet == lfCharSet) && + (logfont.lfOutPrecision == lfOutPrecision) && + (logfont.lfClipPrecision == lfClipPrecision) && + (logfont.lfQuality == lfQuality) && + (logfont.lfPitchAndFamily == lfPitchAndFamily) && + (lstrcmp(logfont.lfFaceName, lfFaceName) == 0)); + } +}; + + +template +class CFontT +{ +public: +// Data members + HFONT m_hFont; + +// Constructor/destructor/operators + CFontT(HFONT hFont = NULL) : m_hFont(hFont) + { } + + ~CFontT() + { + if(t_bManaged && (m_hFont != NULL)) + DeleteObject(); + } + + CFontT& operator =(HFONT hFont) + { + Attach(hFont); + return *this; + } + + void Attach(HFONT hFont) + { + if(t_bManaged && (m_hFont != NULL) && (m_hFont != hFont)) + ::DeleteObject(m_hFont); + m_hFont = hFont; + } + + HFONT Detach() + { + HFONT hFont = m_hFont; + m_hFont = NULL; + return hFont; + } + + operator HFONT() const { return m_hFont; } + + bool IsNull() const { return (m_hFont == NULL); } + +// Create methods + HFONT CreateFontIndirect(const LOGFONT* lpLogFont) + { + ATLASSERT(m_hFont == NULL); + m_hFont = ::CreateFontIndirect(lpLogFont); + return m_hFont; + } + + HFONT CreateFontIndirectEx(CONST ENUMLOGFONTEXDV* penumlfex) + { + ATLASSERT(m_hFont == NULL); + m_hFont = ::CreateFontIndirectEx(penumlfex); + return m_hFont; + } + + HFONT CreateFont(int nHeight, int nWidth, int nEscapement, + int nOrientation, int nWeight, BYTE bItalic, BYTE bUnderline, + BYTE cStrikeOut, BYTE nCharSet, BYTE nOutPrecision, + BYTE nClipPrecision, BYTE nQuality, BYTE nPitchAndFamily, + LPCTSTR lpszFacename) + { + ATLASSERT(m_hFont == NULL); + m_hFont = ::CreateFont(nHeight, nWidth, nEscapement, + nOrientation, nWeight, bItalic, bUnderline, cStrikeOut, + nCharSet, nOutPrecision, nClipPrecision, nQuality, + nPitchAndFamily, lpszFacename); + return m_hFont; + } + + HFONT CreatePointFont(int nPointSize, LPCTSTR lpszFaceName, HDC hDC = NULL, bool bBold = false, bool bItalic = false) + { + LOGFONT logFont = {}; + logFont.lfCharSet = DEFAULT_CHARSET; + logFont.lfHeight = nPointSize; + ATL::Checked::tcsncpy_s(logFont.lfFaceName, _countof(logFont.lfFaceName), lpszFaceName, _TRUNCATE); + + if(bBold) + logFont.lfWeight = FW_BOLD; + if(bItalic) + logFont.lfItalic = (BYTE)TRUE; + + return CreatePointFontIndirect(&logFont, hDC); + } + + HFONT CreatePointFontIndirect(const LOGFONT* lpLogFont, HDC hDC = NULL) + { + HDC hDC1 = (hDC != NULL) ? hDC : ::GetDC(NULL); + + // convert nPointSize to logical units based on hDC + LOGFONT logFont = *lpLogFont; + POINT pt = { 0, 0 }; + pt.y = ::MulDiv(::GetDeviceCaps(hDC1, LOGPIXELSY), logFont.lfHeight, 720); // 72 points/inch, 10 decipoints/point + ::DPtoLP(hDC1, &pt, 1); + POINT ptOrg = { 0, 0 }; + ::DPtoLP(hDC1, &ptOrg, 1); + logFont.lfHeight = -abs(pt.y - ptOrg.y); + + if(hDC == NULL) + ::ReleaseDC(NULL, hDC1); + + return CreateFontIndirect(&logFont); + } + + BOOL DeleteObject() + { + ATLASSERT(m_hFont != NULL); + BOOL bRet = ::DeleteObject(m_hFont); + if(bRet) + m_hFont = NULL; + return bRet; + } + +// Attributes + int GetLogFont(LOGFONT* pLogFont) const + { + ATLASSERT(m_hFont != NULL); + return ::GetObject(m_hFont, sizeof(LOGFONT), pLogFont); + } + + bool GetLogFont(LOGFONT& LogFont) const + { + ATLASSERT(m_hFont != NULL); + return (::GetObject(m_hFont, sizeof(LOGFONT), &LogFont) == sizeof(LOGFONT)); + } +}; + +typedef CFontT CFontHandle; +typedef CFontT CFont; + + +/////////////////////////////////////////////////////////////////////////////// +// CBitmap + +template +class CBitmapT +{ +public: +// Data members + HBITMAP m_hBitmap; + +// Constructor/destructor/operators + CBitmapT(HBITMAP hBitmap = NULL) : m_hBitmap(hBitmap) + { } + + ~CBitmapT() + { + if(t_bManaged && (m_hBitmap != NULL)) + DeleteObject(); + } + + CBitmapT& operator =(HBITMAP hBitmap) + { + Attach(hBitmap); + return *this; + } + + void Attach(HBITMAP hBitmap) + { + if(t_bManaged && (m_hBitmap != NULL) && (m_hBitmap != hBitmap)) + ::DeleteObject(m_hBitmap); + m_hBitmap = hBitmap; + } + + HBITMAP Detach() + { + HBITMAP hBitmap = m_hBitmap; + m_hBitmap = NULL; + return hBitmap; + } + + operator HBITMAP() const { return m_hBitmap; } + + bool IsNull() const { return (m_hBitmap == NULL); } + +// Create and load methods + HBITMAP LoadBitmap(ATL::_U_STRINGorID bitmap) + { + ATLASSERT(m_hBitmap == NULL); + m_hBitmap = ::LoadBitmap(ModuleHelper::GetResourceInstance(), bitmap.m_lpstr); + return m_hBitmap; + } + + HBITMAP LoadOEMBitmap(UINT nIDBitmap) // for OBM_/OCR_/OIC_ + { + ATLASSERT(m_hBitmap == NULL); + m_hBitmap = ::LoadBitmap(NULL, MAKEINTRESOURCE(nIDBitmap)); + return m_hBitmap; + } + + HBITMAP LoadMappedBitmap(UINT nIDBitmap, UINT nFlags = 0, LPCOLORMAP lpColorMap = NULL, int nMapSize = 0) + { + ATLASSERT(m_hBitmap == NULL); + m_hBitmap = ::CreateMappedBitmap(ModuleHelper::GetResourceInstance(), nIDBitmap, (WORD)nFlags, lpColorMap, nMapSize); + return m_hBitmap; + } + + HBITMAP CreateBitmap(int nWidth, int nHeight, UINT nPlanes, UINT nBitsPerPixel, const void* lpBits) + { + ATLASSERT(m_hBitmap == NULL); + m_hBitmap = ::CreateBitmap(nWidth, nHeight, nPlanes, nBitsPerPixel, lpBits); + return m_hBitmap; + } + + HBITMAP CreateBitmapIndirect(LPBITMAP lpBitmap) + { + ATLASSERT(m_hBitmap == NULL); + m_hBitmap = ::CreateBitmapIndirect(lpBitmap); + return m_hBitmap; + } + + HBITMAP CreateCompatibleBitmap(HDC hDC, int nWidth, int nHeight) + { + ATLASSERT(m_hBitmap == NULL); + m_hBitmap = ::CreateCompatibleBitmap(hDC, nWidth, nHeight); + return m_hBitmap; + } + + HBITMAP CreateDiscardableBitmap(HDC hDC, int nWidth, int nHeight) + { + ATLASSERT(m_hBitmap == NULL); + m_hBitmap = ::CreateDiscardableBitmap(hDC, nWidth, nHeight); + return m_hBitmap; + } + + BOOL DeleteObject() + { + ATLASSERT(m_hBitmap != NULL); + BOOL bRet = ::DeleteObject(m_hBitmap); + if(bRet) + m_hBitmap = NULL; + return bRet; + } + +// Attributes + int GetBitmap(BITMAP* pBitMap) const + { + ATLASSERT(m_hBitmap != NULL); + return ::GetObject(m_hBitmap, sizeof(BITMAP), pBitMap); + } + + bool GetBitmap(BITMAP& bm) const + { + ATLASSERT(m_hBitmap != NULL); + return (::GetObject(m_hBitmap, sizeof(BITMAP), &bm) == sizeof(BITMAP)); + } + + bool GetSize(SIZE& size) const + { + ATLASSERT(m_hBitmap != NULL); + BITMAP bm = {}; + if(!GetBitmap(&bm)) + return false; + size.cx = bm.bmWidth; + size.cy = bm.bmHeight; + return true; + } + + DWORD GetBitmapBits(DWORD dwCount, LPVOID lpBits) const + { + ATLASSERT(m_hBitmap != NULL); + return ::GetBitmapBits(m_hBitmap, dwCount, lpBits); + } + + DWORD SetBitmapBits(DWORD dwCount, const void* lpBits) + { + ATLASSERT(m_hBitmap != NULL); + return ::SetBitmapBits(m_hBitmap, dwCount, lpBits); + } + + BOOL GetBitmapDimension(LPSIZE lpSize) const + { + ATLASSERT(m_hBitmap != NULL); + return ::GetBitmapDimensionEx(m_hBitmap, lpSize); + } + + BOOL SetBitmapDimension(int nWidth, int nHeight, LPSIZE lpSize = NULL) + { + ATLASSERT(m_hBitmap != NULL); + return ::SetBitmapDimensionEx(m_hBitmap, nWidth, nHeight, lpSize); + } + +// DIB support + HBITMAP CreateDIBitmap(HDC hDC, CONST BITMAPINFOHEADER* lpbmih, DWORD dwInit, CONST VOID* lpbInit, CONST BITMAPINFO* lpbmi, UINT uColorUse) + { + ATLASSERT(m_hBitmap == NULL); + m_hBitmap = ::CreateDIBitmap(hDC, lpbmih, dwInit, lpbInit, lpbmi, uColorUse); + return m_hBitmap; + } + + HBITMAP CreateDIBSection(HDC hDC, CONST BITMAPINFO* lpbmi, UINT uColorUse, VOID** ppvBits, HANDLE hSection, DWORD dwOffset) + { + ATLASSERT(m_hBitmap == NULL); + m_hBitmap = ::CreateDIBSection(hDC, lpbmi, uColorUse, ppvBits, hSection, dwOffset); + return m_hBitmap; + } + + int GetDIBits(HDC hDC, UINT uStartScan, UINT cScanLines, LPVOID lpvBits, LPBITMAPINFO lpbmi, UINT uColorUse) const + { + ATLASSERT(m_hBitmap != NULL); + return ::GetDIBits(hDC, m_hBitmap, uStartScan, cScanLines, lpvBits, lpbmi, uColorUse); + } + + int SetDIBits(HDC hDC, UINT uStartScan, UINT cScanLines, CONST VOID* lpvBits, CONST BITMAPINFO* lpbmi, UINT uColorUse) + { + ATLASSERT(m_hBitmap != NULL); + return ::SetDIBits(hDC, m_hBitmap, uStartScan, cScanLines, lpvBits, lpbmi, uColorUse); + } +}; + +typedef CBitmapT CBitmapHandle; +typedef CBitmapT CBitmap; + + +/////////////////////////////////////////////////////////////////////////////// +// CPalette + +template +class CPaletteT +{ +public: +// Data members + HPALETTE m_hPalette; + +// Constructor/destructor/operators + CPaletteT(HPALETTE hPalette = NULL) : m_hPalette(hPalette) + { } + + ~CPaletteT() + { + if(t_bManaged && (m_hPalette != NULL)) + DeleteObject(); + } + + CPaletteT& operator =(HPALETTE hPalette) + { + Attach(hPalette); + return *this; + } + + void Attach(HPALETTE hPalette) + { + if(t_bManaged && (m_hPalette != NULL) && (m_hPalette != hPalette)) + ::DeleteObject(m_hPalette); + m_hPalette = hPalette; + } + + HPALETTE Detach() + { + HPALETTE hPalette = m_hPalette; + m_hPalette = NULL; + return hPalette; + } + + operator HPALETTE() const { return m_hPalette; } + + bool IsNull() const { return (m_hPalette == NULL); } + +// Create methods + HPALETTE CreatePalette(LPLOGPALETTE lpLogPalette) + { + ATLASSERT(m_hPalette == NULL); + m_hPalette = ::CreatePalette(lpLogPalette); + return m_hPalette; + } + + HPALETTE CreateHalftonePalette(HDC hDC) + { + ATLASSERT(m_hPalette == NULL); + ATLASSERT(hDC != NULL); + m_hPalette = ::CreateHalftonePalette(hDC); + return m_hPalette; + } + + BOOL DeleteObject() + { + ATLASSERT(m_hPalette != NULL); + BOOL bRet = ::DeleteObject(m_hPalette); + if(bRet) + m_hPalette = NULL; + return bRet; + } + +// Attributes + int GetEntryCount() const + { + ATLASSERT(m_hPalette != NULL); + WORD nEntries = 0; + ::GetObject(m_hPalette, sizeof(WORD), &nEntries); + return (int)nEntries; + } + + UINT GetPaletteEntries(UINT nStartIndex, UINT nNumEntries, LPPALETTEENTRY lpPaletteColors) const + { + ATLASSERT(m_hPalette != NULL); + return ::GetPaletteEntries(m_hPalette, nStartIndex, nNumEntries, lpPaletteColors); + } + + UINT SetPaletteEntries(UINT nStartIndex, UINT nNumEntries, LPPALETTEENTRY lpPaletteColors) + { + ATLASSERT(m_hPalette != NULL); + return ::SetPaletteEntries(m_hPalette, nStartIndex, nNumEntries, lpPaletteColors); + } + +// Operations + void AnimatePalette(UINT nStartIndex, UINT nNumEntries, LPPALETTEENTRY lpPaletteColors) + { + ATLASSERT(m_hPalette != NULL); + ::AnimatePalette(m_hPalette, nStartIndex, nNumEntries, lpPaletteColors); + } + + BOOL ResizePalette(UINT nNumEntries) + { + ATLASSERT(m_hPalette != NULL); + return ::ResizePalette(m_hPalette, nNumEntries); + } + + UINT GetNearestPaletteIndex(COLORREF crColor) const + { + ATLASSERT(m_hPalette != NULL); + return ::GetNearestPaletteIndex(m_hPalette, crColor); + } +}; + +typedef CPaletteT CPaletteHandle; +typedef CPaletteT CPalette; + + +/////////////////////////////////////////////////////////////////////////////// +// CRgn + +template +class CRgnT +{ +public: +// Data members + HRGN m_hRgn; + +// Constructor/destructor/operators + CRgnT(HRGN hRgn = NULL) : m_hRgn(hRgn) + { } + + ~CRgnT() + { + if(t_bManaged && (m_hRgn != NULL)) + DeleteObject(); + } + + CRgnT& operator =(HRGN hRgn) + { + Attach(hRgn); + return *this; + } + + void Attach(HRGN hRgn) + { + if(t_bManaged && (m_hRgn != NULL) && (m_hRgn != hRgn)) + ::DeleteObject(m_hRgn); + m_hRgn = hRgn; + } + + HRGN Detach() + { + HRGN hRgn = m_hRgn; + m_hRgn = NULL; + return hRgn; + } + + operator HRGN() const { return m_hRgn; } + + bool IsNull() const { return (m_hRgn == NULL); } + +// Create methods + HRGN CreateRectRgn(int x1, int y1, int x2, int y2) + { + ATLASSERT(m_hRgn == NULL); + m_hRgn = ::CreateRectRgn(x1, y1, x2, y2); + return m_hRgn; + } + + HRGN CreateRectRgnIndirect(LPCRECT lpRect) + { + ATLASSERT(m_hRgn == NULL); + m_hRgn = ::CreateRectRgnIndirect(lpRect); + return m_hRgn; + } + + HRGN CreateEllipticRgn(int x1, int y1, int x2, int y2) + { + ATLASSERT(m_hRgn == NULL); + m_hRgn = ::CreateEllipticRgn(x1, y1, x2, y2); + return m_hRgn; + } + + HRGN CreateEllipticRgnIndirect(LPCRECT lpRect) + { + ATLASSERT(m_hRgn == NULL); + m_hRgn = ::CreateEllipticRgnIndirect(lpRect); + return m_hRgn; + } + + HRGN CreatePolygonRgn(const POINT* lpPoints, int nCount, int nMode) + { + ATLASSERT(m_hRgn == NULL); + m_hRgn = ::CreatePolygonRgn(lpPoints, nCount, nMode); + return m_hRgn; + } + + HRGN CreatePolyPolygonRgn(const POINT* lpPoints, const INT* lpPolyCounts, int nCount, int nPolyFillMode) + { + ATLASSERT(m_hRgn == NULL); + m_hRgn = ::CreatePolyPolygonRgn(lpPoints, lpPolyCounts, nCount, nPolyFillMode); + return m_hRgn; + } + + HRGN CreateRoundRectRgn(int x1, int y1, int x2, int y2, int x3, int y3) + { + ATLASSERT(m_hRgn == NULL); + m_hRgn = ::CreateRoundRectRgn(x1, y1, x2, y2, x3, y3); + return m_hRgn; + } + + HRGN CreateFromPath(HDC hDC) + { + ATLASSERT(m_hRgn == NULL); + ATLASSERT(hDC != NULL); + m_hRgn = ::PathToRegion(hDC); + return m_hRgn; + } + + HRGN CreateFromData(const XFORM* lpXForm, int nCount, const RGNDATA* pRgnData) + { + ATLASSERT(m_hRgn == NULL); + m_hRgn = ::ExtCreateRegion(lpXForm, nCount, pRgnData); + return m_hRgn; + } + + BOOL DeleteObject() + { + ATLASSERT(m_hRgn != NULL); + BOOL bRet = ::DeleteObject(m_hRgn); + if(bRet) + m_hRgn = NULL; + return bRet; + } + +// Operations + void SetRectRgn(int x1, int y1, int x2, int y2) + { + ATLASSERT(m_hRgn != NULL); + ::SetRectRgn(m_hRgn, x1, y1, x2, y2); + } + + void SetRectRgn(LPCRECT lpRect) + { + ATLASSERT(m_hRgn != NULL); + ::SetRectRgn(m_hRgn, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom); + } + + int CombineRgn(HRGN hRgnSrc1, HRGN hRgnSrc2, int nCombineMode) + { + ATLASSERT(m_hRgn != NULL); + return ::CombineRgn(m_hRgn, hRgnSrc1, hRgnSrc2, nCombineMode); + } + + int CombineRgn(HRGN hRgnSrc, int nCombineMode) + { + ATLASSERT(m_hRgn != NULL); + return ::CombineRgn(m_hRgn, m_hRgn, hRgnSrc, nCombineMode); + } + + int CopyRgn(HRGN hRgnSrc) + { + ATLASSERT(m_hRgn != NULL); + return ::CombineRgn(m_hRgn, hRgnSrc, NULL, RGN_COPY); + } + + BOOL EqualRgn(HRGN hRgn) const + { + ATLASSERT(m_hRgn != NULL); + return ::EqualRgn(m_hRgn, hRgn); + } + + int OffsetRgn(int x, int y) + { + ATLASSERT(m_hRgn != NULL); + return ::OffsetRgn(m_hRgn, x, y); + } + + int OffsetRgn(POINT point) + { + ATLASSERT(m_hRgn != NULL); + return ::OffsetRgn(m_hRgn, point.x, point.y); + } + + int GetRgnBox(LPRECT lpRect) const + { + ATLASSERT(m_hRgn != NULL); + return ::GetRgnBox(m_hRgn, lpRect); + } + + BOOL PtInRegion(int x, int y) const + { + ATLASSERT(m_hRgn != NULL); + return ::PtInRegion(m_hRgn, x, y); + } + + BOOL PtInRegion(POINT point) const + { + ATLASSERT(m_hRgn != NULL); + return ::PtInRegion(m_hRgn, point.x, point.y); + } + + BOOL RectInRegion(LPCRECT lpRect) const + { + ATLASSERT(m_hRgn != NULL); + return ::RectInRegion(m_hRgn, lpRect); + } + + int GetRegionData(LPRGNDATA lpRgnData, int nDataSize) const + { + ATLASSERT(m_hRgn != NULL); + return (int)::GetRegionData(m_hRgn, nDataSize, lpRgnData); + } +}; + +typedef CRgnT CRgnHandle; +typedef CRgnT CRgn; + + +/////////////////////////////////////////////////////////////////////////////// +// CDC - The device context class + +template +class CDCT; +typedef CDCT CDCHandle; +typedef CDCT CDC; + +template +class CDCT +{ +public: +// Data members + HDC m_hDC; + +// Constructor/destructor/operators + CDCT(HDC hDC = NULL) : m_hDC(hDC) + { + } + + ~CDCT() + { + if(t_bManaged && (m_hDC != NULL)) + ::DeleteDC(Detach()); + } + + CDCT& operator =(HDC hDC) + { + Attach(hDC); + return *this; + } + + void Attach(HDC hDC) + { + if(t_bManaged && (m_hDC != NULL) && (m_hDC != hDC)) + ::DeleteDC(m_hDC); + m_hDC = hDC; + } + + HDC Detach() + { + HDC hDC = m_hDC; + m_hDC = NULL; + return hDC; + } + + operator HDC() const { return m_hDC; } + + bool IsNull() const { return (m_hDC == NULL); } + +// Operations + HWND WindowFromDC() const + { + ATLASSERT(m_hDC != NULL); + return ::WindowFromDC(m_hDC); + } + + CPenHandle GetCurrentPen() const + { + ATLASSERT(m_hDC != NULL); + return CPenHandle((HPEN)::GetCurrentObject(m_hDC, OBJ_PEN)); + } + + CBrushHandle GetCurrentBrush() const + { + ATLASSERT(m_hDC != NULL); + return CBrushHandle((HBRUSH)::GetCurrentObject(m_hDC, OBJ_BRUSH)); + } + + CPaletteHandle GetCurrentPalette() const + { + ATLASSERT(m_hDC != NULL); + return CPaletteHandle((HPALETTE)::GetCurrentObject(m_hDC, OBJ_PAL)); + } + + CFontHandle GetCurrentFont() const + { + ATLASSERT(m_hDC != NULL); + return CFontHandle((HFONT)::GetCurrentObject(m_hDC, OBJ_FONT)); + } + + CBitmapHandle GetCurrentBitmap() const + { + ATLASSERT(m_hDC != NULL); + return CBitmapHandle((HBITMAP)::GetCurrentObject(m_hDC, OBJ_BITMAP)); + } + + HDC CreateDC(LPCTSTR lpszDriverName, LPCTSTR lpszDeviceName, LPCTSTR lpszOutput, const DEVMODE* lpInitData) + { + ATLASSERT(m_hDC == NULL); + m_hDC = ::CreateDC(lpszDriverName, lpszDeviceName, lpszOutput, lpInitData); + return m_hDC; + } + + HDC CreateCompatibleDC(HDC hDC = NULL) + { + ATLASSERT(m_hDC == NULL); + m_hDC = ::CreateCompatibleDC(hDC); + return m_hDC; + } + + BOOL DeleteDC() + { + if(m_hDC == NULL) + return FALSE; + BOOL bRet = ::DeleteDC(m_hDC); + if(bRet) + m_hDC = NULL; + return bRet; + } + +// Device-Context Functions + int SaveDC() + { + ATLASSERT(m_hDC != NULL); + return ::SaveDC(m_hDC); + } + + BOOL RestoreDC(int nSavedDC) + { + ATLASSERT(m_hDC != NULL); + return ::RestoreDC(m_hDC, nSavedDC); + } + + int GetDeviceCaps(int nIndex) const + { + ATLASSERT(m_hDC != NULL); + return ::GetDeviceCaps(m_hDC, nIndex); + } + + UINT SetBoundsRect(LPCRECT lpRectBounds, UINT flags) + { + ATLASSERT(m_hDC != NULL); + return ::SetBoundsRect(m_hDC, lpRectBounds, flags); + } + + UINT GetBoundsRect(LPRECT lpRectBounds, UINT flags) const + { + ATLASSERT(m_hDC != NULL); + return ::GetBoundsRect(m_hDC, lpRectBounds, flags); + } + + BOOL ResetDC(const DEVMODE* lpDevMode) + { + ATLASSERT(m_hDC != NULL); + return ::ResetDC(m_hDC, lpDevMode) != NULL; + } + +// Drawing-Tool Functions + BOOL GetBrushOrg(LPPOINT lpPoint) const + { + ATLASSERT(m_hDC != NULL); + return ::GetBrushOrgEx(m_hDC, lpPoint); + } + + BOOL SetBrushOrg(int x, int y, LPPOINT lpPoint = NULL) + { + ATLASSERT(m_hDC != NULL); + return ::SetBrushOrgEx(m_hDC, x, y, lpPoint); + } + + BOOL SetBrushOrg(POINT point, LPPOINT lpPointRet = NULL) + { + ATLASSERT(m_hDC != NULL); + return ::SetBrushOrgEx(m_hDC, point.x, point.y, lpPointRet); + } + + int EnumObjects(int nObjectType, int (CALLBACK* lpfn)(LPVOID, LPARAM), LPARAM lpData) + { + ATLASSERT(m_hDC != NULL); +#ifdef STRICT + return ::EnumObjects(m_hDC, nObjectType, (GOBJENUMPROC)lpfn, lpData); +#else + return ::EnumObjects(m_hDC, nObjectType, (GOBJENUMPROC)lpfn, (LPVOID)lpData); +#endif + } + +// Type-safe selection helpers + HPEN SelectPen(HPEN hPen) + { + ATLASSERT(m_hDC != NULL); + ATLASSERT((hPen == NULL) || (::GetObjectType(hPen) == OBJ_PEN) || (::GetObjectType(hPen) == OBJ_EXTPEN)); + return (HPEN)::SelectObject(m_hDC, hPen); + } + + HBRUSH SelectBrush(HBRUSH hBrush) + { + ATLASSERT(m_hDC != NULL); + ATLASSERT((hBrush == NULL) || (::GetObjectType(hBrush) == OBJ_BRUSH)); + return (HBRUSH)::SelectObject(m_hDC, hBrush); + } + + HFONT SelectFont(HFONT hFont) + { + ATLASSERT(m_hDC != NULL); + ATLASSERT((hFont == NULL) || (::GetObjectType(hFont) == OBJ_FONT)); + return (HFONT)::SelectObject(m_hDC, hFont); + } + + HBITMAP SelectBitmap(HBITMAP hBitmap) + { + ATLASSERT(m_hDC != NULL); + ATLASSERT((hBitmap == NULL) || (::GetObjectType(hBitmap) == OBJ_BITMAP)); + return (HBITMAP)::SelectObject(m_hDC, hBitmap); + } + + int SelectRgn(HRGN hRgn) // special return for regions + { + ATLASSERT(m_hDC != NULL); + ATLASSERT((hRgn == NULL) || (::GetObjectType(hRgn) == OBJ_REGION)); + return PtrToInt(::SelectObject(m_hDC, hRgn)); + } + +// Type-safe selection helpers for stock objects + HPEN SelectStockPen(int nPen) + { + ATLASSERT(m_hDC != NULL); + ATLASSERT((nPen == WHITE_PEN) || (nPen == BLACK_PEN) || (nPen == NULL_PEN) || (nPen == DC_PEN)); + return SelectPen((HPEN)::GetStockObject(nPen)); + } + + HBRUSH SelectStockBrush(int nBrush) + { + ATLASSERT(((nBrush >= WHITE_BRUSH) && (nBrush <= HOLLOW_BRUSH)) || (nBrush == DC_BRUSH)); + return SelectBrush((HBRUSH)::GetStockObject(nBrush)); + } + + HFONT SelectStockFont(int nFont) + { + ATLASSERT(((nFont >= OEM_FIXED_FONT) && (nFont <= SYSTEM_FIXED_FONT)) || (nFont == DEFAULT_GUI_FONT)); + return SelectFont((HFONT)::GetStockObject(nFont)); + } + + HPALETTE SelectStockPalette(int nPalette, BOOL bForceBackground) + { + ATLASSERT(nPalette == DEFAULT_PALETTE); // the only one supported + return SelectPalette((HPALETTE)::GetStockObject(nPalette), bForceBackground); + } + +// Color and Color Palette Functions + COLORREF GetNearestColor(COLORREF crColor) const + { + ATLASSERT(m_hDC != NULL); + return ::GetNearestColor(m_hDC, crColor); + } + + HPALETTE SelectPalette(HPALETTE hPalette, BOOL bForceBackground) + { + ATLASSERT(m_hDC != NULL); + + return ::SelectPalette(m_hDC, hPalette, bForceBackground); + } + + UINT RealizePalette() + { + ATLASSERT(m_hDC != NULL); + return ::RealizePalette(m_hDC); + } + + void UpdateColors() + { + ATLASSERT(m_hDC != NULL); + ::UpdateColors(m_hDC); + } + +// Drawing-Attribute Functions + COLORREF GetBkColor() const + { + ATLASSERT(m_hDC != NULL); + return ::GetBkColor(m_hDC); + } + + int GetBkMode() const + { + ATLASSERT(m_hDC != NULL); + return ::GetBkMode(m_hDC); + } + + int GetPolyFillMode() const + { + ATLASSERT(m_hDC != NULL); + return ::GetPolyFillMode(m_hDC); + } + + int GetROP2() const + { + ATLASSERT(m_hDC != NULL); + return ::GetROP2(m_hDC); + } + + int GetStretchBltMode() const + { + ATLASSERT(m_hDC != NULL); + return ::GetStretchBltMode(m_hDC); + } + + COLORREF GetTextColor() const + { + ATLASSERT(m_hDC != NULL); + return ::GetTextColor(m_hDC); + } + + COLORREF SetBkColor(COLORREF crColor) + { + ATLASSERT(m_hDC != NULL); + return ::SetBkColor(m_hDC, crColor); + } + + int SetBkMode(int nBkMode) + { + ATLASSERT(m_hDC != NULL); + return ::SetBkMode(m_hDC, nBkMode); + } + + int SetPolyFillMode(int nPolyFillMode) + { + ATLASSERT(m_hDC != NULL); + return ::SetPolyFillMode(m_hDC, nPolyFillMode); + } + + int SetROP2(int nDrawMode) + { + ATLASSERT(m_hDC != NULL); + return ::SetROP2(m_hDC, nDrawMode); + } + + int SetStretchBltMode(int nStretchMode) + { + ATLASSERT(m_hDC != NULL); + return ::SetStretchBltMode(m_hDC, nStretchMode); + } + + COLORREF SetTextColor(COLORREF crColor) + { + ATLASSERT(m_hDC != NULL); + return ::SetTextColor(m_hDC, crColor); + } + + BOOL GetColorAdjustment(LPCOLORADJUSTMENT lpColorAdjust) const + { + ATLASSERT(m_hDC != NULL); + return ::GetColorAdjustment(m_hDC, lpColorAdjust); + } + + BOOL SetColorAdjustment(const COLORADJUSTMENT* lpColorAdjust) + { + ATLASSERT(m_hDC != NULL); + return ::SetColorAdjustment(m_hDC, lpColorAdjust); + } + +// Mapping Functions + int GetMapMode() const + { + ATLASSERT(m_hDC != NULL); + return ::GetMapMode(m_hDC); + } + + BOOL GetViewportOrg(LPPOINT lpPoint) const + { + ATLASSERT(m_hDC != NULL); + return ::GetViewportOrgEx(m_hDC, lpPoint); + } + + int SetMapMode(int nMapMode) + { + ATLASSERT(m_hDC != NULL); + return ::SetMapMode(m_hDC, nMapMode); + } + + // Viewport Origin + BOOL SetViewportOrg(int x, int y, LPPOINT lpPoint = NULL) + { + ATLASSERT(m_hDC != NULL); + return ::SetViewportOrgEx(m_hDC, x, y, lpPoint); + } + + BOOL SetViewportOrg(POINT point, LPPOINT lpPointRet = NULL) + { + ATLASSERT(m_hDC != NULL); + return SetViewportOrg(point.x, point.y, lpPointRet); + } + + BOOL OffsetViewportOrg(int nWidth, int nHeight, LPPOINT lpPoint = NULL) + { + ATLASSERT(m_hDC != NULL); + return ::OffsetViewportOrgEx(m_hDC, nWidth, nHeight, lpPoint); + } + + // Viewport Extent + BOOL GetViewportExt(LPSIZE lpSize) const + { + ATLASSERT(m_hDC != NULL); + return ::GetViewportExtEx(m_hDC, lpSize); + } + + BOOL SetViewportExt(int x, int y, LPSIZE lpSize = NULL) + { + ATLASSERT(m_hDC != NULL); + return ::SetViewportExtEx(m_hDC, x, y, lpSize); + } + + BOOL SetViewportExt(SIZE size, LPSIZE lpSizeRet = NULL) + { + ATLASSERT(m_hDC != NULL); + return SetViewportExt(size.cx, size.cy, lpSizeRet); + } + + BOOL ScaleViewportExt(int xNum, int xDenom, int yNum, int yDenom, LPSIZE lpSize = NULL) + { + ATLASSERT(m_hDC != NULL); + return ::ScaleViewportExtEx(m_hDC, xNum, xDenom, yNum, yDenom, lpSize); + } + + // Window Origin + BOOL GetWindowOrg(LPPOINT lpPoint) const + { + ATLASSERT(m_hDC != NULL); + return ::GetWindowOrgEx(m_hDC, lpPoint); + } + + BOOL SetWindowOrg(int x, int y, LPPOINT lpPoint = NULL) + { + ATLASSERT(m_hDC != NULL); + return ::SetWindowOrgEx(m_hDC, x, y, lpPoint); + } + + BOOL SetWindowOrg(POINT point, LPPOINT lpPointRet = NULL) + { + ATLASSERT(m_hDC != NULL); + return SetWindowOrg(point.x, point.y, lpPointRet); + } + + BOOL OffsetWindowOrg(int nWidth, int nHeight, LPPOINT lpPoint = NULL) + { + ATLASSERT(m_hDC != NULL); + return ::OffsetWindowOrgEx(m_hDC, nWidth, nHeight, lpPoint); + } + + // Window extent + BOOL GetWindowExt(LPSIZE lpSize) const + { + ATLASSERT(m_hDC != NULL); + return ::GetWindowExtEx(m_hDC, lpSize); + } + + BOOL SetWindowExt(int x, int y, LPSIZE lpSize = NULL) + { + ATLASSERT(m_hDC != NULL); + return ::SetWindowExtEx(m_hDC, x, y, lpSize); + } + + BOOL SetWindowExt(SIZE size, LPSIZE lpSizeRet = NULL) + { + ATLASSERT(m_hDC != NULL); + return SetWindowExt(size.cx, size.cy, lpSizeRet); + } + + BOOL ScaleWindowExt(int xNum, int xDenom, int yNum, int yDenom, LPSIZE lpSize = NULL) + { + ATLASSERT(m_hDC != NULL); + return ::ScaleWindowExtEx(m_hDC, xNum, xDenom, yNum, yDenom, lpSize); + } + +// Coordinate Functions + BOOL DPtoLP(LPPOINT lpPoints, int nCount = 1) const + { + ATLASSERT(m_hDC != NULL); + return ::DPtoLP(m_hDC, lpPoints, nCount); + } + + BOOL DPtoLP(LPRECT lpRect) const + { + ATLASSERT(m_hDC != NULL); + return ::DPtoLP(m_hDC, (LPPOINT)lpRect, 2); + } + + BOOL DPtoLP(LPSIZE lpSize) const + { + SIZE sizeWinExt = {}; + if(!GetWindowExt(&sizeWinExt)) + return FALSE; + SIZE sizeVpExt = {}; + if(!GetViewportExt(&sizeVpExt)) + return FALSE; + lpSize->cx = ::MulDiv(lpSize->cx, abs(sizeWinExt.cx), abs(sizeVpExt.cx)); + lpSize->cy = ::MulDiv(lpSize->cy, abs(sizeWinExt.cy), abs(sizeVpExt.cy)); + return TRUE; + } + + BOOL LPtoDP(LPPOINT lpPoints, int nCount = 1) const + { + ATLASSERT(m_hDC != NULL); + return ::LPtoDP(m_hDC, lpPoints, nCount); + } + + BOOL LPtoDP(LPRECT lpRect) const + { + ATLASSERT(m_hDC != NULL); + return ::LPtoDP(m_hDC, (LPPOINT)lpRect, 2); + } + + BOOL LPtoDP(LPSIZE lpSize) const + { + SIZE sizeWinExt = {}; + if(!GetWindowExt(&sizeWinExt)) + return FALSE; + SIZE sizeVpExt = {}; + if(!GetViewportExt(&sizeVpExt)) + return FALSE; + lpSize->cx = ::MulDiv(lpSize->cx, abs(sizeVpExt.cx), abs(sizeWinExt.cx)); + lpSize->cy = ::MulDiv(lpSize->cy, abs(sizeVpExt.cy), abs(sizeWinExt.cy)); + return TRUE; + } + +// Special Coordinate Functions (useful for dealing with metafiles and OLE) + #define HIMETRIC_INCH 2540 // HIMETRIC units per inch + + void DPtoHIMETRIC(LPSIZE lpSize) + { + ATLASSERT(m_hDC != NULL); + int nMapMode = GetMapMode(); + if((nMapMode < MM_ISOTROPIC) && (nMapMode != MM_TEXT)) + { + // when using a constrained map mode, map against physical inch + SetMapMode(MM_HIMETRIC); + DPtoLP(lpSize); + SetMapMode(nMapMode); + } + else + { + // map against logical inch for non-constrained mapping modes + int cxPerInch = GetDeviceCaps(LOGPIXELSX); + int cyPerInch = GetDeviceCaps(LOGPIXELSY); + ATLASSERT((cxPerInch != 0) && (cyPerInch != 0)); + lpSize->cx = ::MulDiv(lpSize->cx, HIMETRIC_INCH, cxPerInch); + lpSize->cy = ::MulDiv(lpSize->cy, HIMETRIC_INCH, cyPerInch); + } + } + + void HIMETRICtoDP(LPSIZE lpSize) + { + ATLASSERT(m_hDC != NULL); + int nMapMode = GetMapMode(); + if((nMapMode < MM_ISOTROPIC) && (nMapMode != MM_TEXT)) + { + // when using a constrained map mode, map against physical inch + SetMapMode(MM_HIMETRIC); + LPtoDP(lpSize); + SetMapMode(nMapMode); + } + else + { + // map against logical inch for non-constrained mapping modes + int cxPerInch = GetDeviceCaps(LOGPIXELSX); + int cyPerInch = GetDeviceCaps(LOGPIXELSY); + ATLASSERT((cxPerInch != 0) && (cyPerInch != 0)); + lpSize->cx = ::MulDiv(lpSize->cx, cxPerInch, HIMETRIC_INCH); + lpSize->cy = ::MulDiv(lpSize->cy, cyPerInch, HIMETRIC_INCH); + } + } + + void LPtoHIMETRIC(LPSIZE lpSize) + { + LPtoDP(lpSize); + DPtoHIMETRIC(lpSize); + } + + void HIMETRICtoLP(LPSIZE lpSize) + { + HIMETRICtoDP(lpSize); + DPtoLP(lpSize); + } + +// Region Functions + BOOL FillRgn(HRGN hRgn, HBRUSH hBrush) + { + ATLASSERT(m_hDC != NULL); + return ::FillRgn(m_hDC, hRgn, hBrush); + } + + BOOL FrameRgn(HRGN hRgn, HBRUSH hBrush, int nWidth, int nHeight) + { + ATLASSERT(m_hDC != NULL); + return ::FrameRgn(m_hDC, hRgn, hBrush, nWidth, nHeight); + } + + BOOL InvertRgn(HRGN hRgn) + { + ATLASSERT(m_hDC != NULL); + return ::InvertRgn(m_hDC, hRgn); + } + + BOOL PaintRgn(HRGN hRgn) + { + ATLASSERT(m_hDC != NULL); + return ::PaintRgn(m_hDC, hRgn); + } + +// Clipping Functions + int GetClipBox(LPRECT lpRect) const + { + ATLASSERT(m_hDC != NULL); + return ::GetClipBox(m_hDC, lpRect); + } + + int GetClipRgn(CRgn& region) const + { + ATLASSERT(m_hDC != NULL); + if(region.IsNull()) + region.CreateRectRgn(0, 0, 0, 0); + + int nRet = ::GetClipRgn(m_hDC, region); + if(nRet != 1) + region.DeleteObject(); + + return nRet; + } + + BOOL PtVisible(int x, int y) const + { + ATLASSERT(m_hDC != NULL); + return ::PtVisible(m_hDC, x, y); + } + + BOOL PtVisible(POINT point) const + { + ATLASSERT(m_hDC != NULL); + return ::PtVisible(m_hDC, point.x, point.y); + } + + BOOL RectVisible(LPCRECT lpRect) const + { + ATLASSERT(m_hDC != NULL); + return ::RectVisible(m_hDC, lpRect); + } + + int SelectClipRgn(HRGN hRgn) + { + ATLASSERT(m_hDC != NULL); + return ::SelectClipRgn(m_hDC, (HRGN)hRgn); + } + + int ExcludeClipRect(int x1, int y1, int x2, int y2) + { + ATLASSERT(m_hDC != NULL); + return ::ExcludeClipRect(m_hDC, x1, y1, x2, y2); + } + + int ExcludeClipRect(LPCRECT lpRect) + { + ATLASSERT(m_hDC != NULL); + return ::ExcludeClipRect(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom); + } + + int ExcludeUpdateRgn(HWND hWnd) + { + ATLASSERT(m_hDC != NULL); + return ::ExcludeUpdateRgn(m_hDC, hWnd); + } + + int IntersectClipRect(int x1, int y1, int x2, int y2) + { + ATLASSERT(m_hDC != NULL); + return ::IntersectClipRect(m_hDC, x1, y1, x2, y2); + } + + int IntersectClipRect(LPCRECT lpRect) + { + ATLASSERT(m_hDC != NULL); + return ::IntersectClipRect(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom); + } + + int OffsetClipRgn(int x, int y) + { + ATLASSERT(m_hDC != NULL); + return ::OffsetClipRgn(m_hDC, x, y); + } + + int OffsetClipRgn(SIZE size) + { + ATLASSERT(m_hDC != NULL); + return ::OffsetClipRgn(m_hDC, size.cx, size.cy); + } + + int SelectClipRgn(HRGN hRgn, int nMode) + { + ATLASSERT(m_hDC != NULL); + return ::ExtSelectClipRgn(m_hDC, hRgn, nMode); + } + +// Line-Output Functions + BOOL GetCurrentPosition(LPPOINT lpPoint) const + { + ATLASSERT(m_hDC != NULL); + return ::GetCurrentPositionEx(m_hDC, lpPoint); + } + + BOOL MoveTo(int x, int y, LPPOINT lpPoint = NULL) + { + ATLASSERT(m_hDC != NULL); + return ::MoveToEx(m_hDC, x, y, lpPoint); + } + + BOOL MoveTo(POINT point, LPPOINT lpPointRet = NULL) + { + ATLASSERT(m_hDC != NULL); + return MoveTo(point.x, point.y, lpPointRet); + } + + BOOL LineTo(int x, int y) + { + ATLASSERT(m_hDC != NULL); + return ::LineTo(m_hDC, x, y); + } + + BOOL LineTo(POINT point) + { + ATLASSERT(m_hDC != NULL); + return LineTo(point.x, point.y); + } + + BOOL Arc(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) + { + ATLASSERT(m_hDC != NULL); + return ::Arc(m_hDC, x1, y1, x2, y2, x3, y3, x4, y4); + } + + BOOL Arc(LPCRECT lpRect, POINT ptStart, POINT ptEnd) + { + ATLASSERT(m_hDC != NULL); + return ::Arc(m_hDC, lpRect->left, lpRect->top, + lpRect->right, lpRect->bottom, ptStart.x, ptStart.y, + ptEnd.x, ptEnd.y); + } + + BOOL Polyline(const POINT* lpPoints, int nCount) + { + ATLASSERT(m_hDC != NULL); + return ::Polyline(m_hDC, lpPoints, nCount); + } + + BOOL AngleArc(int x, int y, int nRadius, float fStartAngle, float fSweepAngle) + { + ATLASSERT(m_hDC != NULL); + return ::AngleArc(m_hDC, x, y, nRadius, fStartAngle, fSweepAngle); + } + + BOOL ArcTo(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) + { + ATLASSERT(m_hDC != NULL); + return ::ArcTo(m_hDC, x1, y1, x2, y2, x3, y3, x4, y4); + } + + BOOL ArcTo(LPCRECT lpRect, POINT ptStart, POINT ptEnd) + { + ATLASSERT(m_hDC != NULL); + return ArcTo(lpRect->left, lpRect->top, lpRect->right, + lpRect->bottom, ptStart.x, ptStart.y, ptEnd.x, ptEnd.y); + } + + int GetArcDirection() const + { + ATLASSERT(m_hDC != NULL); + return ::GetArcDirection(m_hDC); + } + + int SetArcDirection(int nArcDirection) + { + ATLASSERT(m_hDC != NULL); + return ::SetArcDirection(m_hDC, nArcDirection); + } + + BOOL PolyDraw(const POINT* lpPoints, const BYTE* lpTypes, int nCount) + { + ATLASSERT(m_hDC != NULL); + return ::PolyDraw(m_hDC, lpPoints, lpTypes, nCount); + } + + BOOL PolylineTo(const POINT* lpPoints, int nCount) + { + ATLASSERT(m_hDC != NULL); + return ::PolylineTo(m_hDC, lpPoints, nCount); + } + + BOOL PolyPolyline(const POINT* lpPoints, + const DWORD* lpPolyPoints, int nCount) + { + ATLASSERT(m_hDC != NULL); + return ::PolyPolyline(m_hDC, lpPoints, lpPolyPoints, nCount); + } + + BOOL PolyBezier(const POINT* lpPoints, int nCount) + { + ATLASSERT(m_hDC != NULL); + return ::PolyBezier(m_hDC, lpPoints, nCount); + } + + BOOL PolyBezierTo(const POINT* lpPoints, int nCount) + { + ATLASSERT(m_hDC != NULL); + return ::PolyBezierTo(m_hDC, lpPoints, nCount); + } + +// Simple Drawing Functions + BOOL FillRect(LPCRECT lpRect, HBRUSH hBrush) + { + ATLASSERT(m_hDC != NULL); + return ::FillRect(m_hDC, lpRect, hBrush); + } + + BOOL FillRect(LPCRECT lpRect, int nColorIndex) + { + ATLASSERT(m_hDC != NULL); + return ::FillRect(m_hDC, lpRect, (HBRUSH)LongToPtr(nColorIndex + 1)); + } + + BOOL FrameRect(LPCRECT lpRect, HBRUSH hBrush) + { + ATLASSERT(m_hDC != NULL); + return ::FrameRect(m_hDC, lpRect, hBrush); + } + + BOOL InvertRect(LPCRECT lpRect) + { + ATLASSERT(m_hDC != NULL); + return ::InvertRect(m_hDC, lpRect); + } + + BOOL DrawIcon(int x, int y, HICON hIcon) + { + ATLASSERT(m_hDC != NULL); + return ::DrawIcon(m_hDC, x, y, hIcon); + } + + BOOL DrawIcon(POINT point, HICON hIcon) + { + ATLASSERT(m_hDC != NULL); + return ::DrawIcon(m_hDC, point.x, point.y, hIcon); + } + + BOOL DrawIconEx(int x, int y, HICON hIcon, int cxWidth, int cyWidth, UINT uStepIfAniCur = 0, HBRUSH hbrFlickerFreeDraw = NULL, UINT uFlags = DI_NORMAL) + { + ATLASSERT(m_hDC != NULL); + return ::DrawIconEx(m_hDC, x, y, hIcon, cxWidth, cyWidth, uStepIfAniCur, hbrFlickerFreeDraw, uFlags); + } + + BOOL DrawIconEx(POINT point, HICON hIcon, SIZE size, UINT uStepIfAniCur = 0, HBRUSH hbrFlickerFreeDraw = NULL, UINT uFlags = DI_NORMAL) + { + ATLASSERT(m_hDC != NULL); + return ::DrawIconEx(m_hDC, point.x, point.y, hIcon, size.cx, size.cy, uStepIfAniCur, hbrFlickerFreeDraw, uFlags); + } + + BOOL DrawState(POINT pt, SIZE size, HBITMAP hBitmap, UINT nFlags, HBRUSH hBrush = NULL) + { + ATLASSERT(m_hDC != NULL); + return ::DrawState(m_hDC, hBrush, NULL, (LPARAM)hBitmap, 0, pt.x, pt.y, size.cx, size.cy, nFlags | DST_BITMAP); + } + + BOOL DrawState(POINT pt, SIZE size, HICON hIcon, UINT nFlags, HBRUSH hBrush = NULL) + { + ATLASSERT(m_hDC != NULL); + return ::DrawState(m_hDC, hBrush, NULL, (LPARAM)hIcon, 0, pt.x, pt.y, size.cx, size.cy, nFlags | DST_ICON); + } + + BOOL DrawState(POINT pt, SIZE size, LPCTSTR lpszText, UINT nFlags, BOOL bPrefixText = TRUE, int nTextLen = 0, HBRUSH hBrush = NULL) + { + ATLASSERT(m_hDC != NULL); + return ::DrawState(m_hDC, hBrush, NULL, (LPARAM)lpszText, (WPARAM)nTextLen, pt.x, pt.y, size.cx, size.cy, nFlags | (bPrefixText ? DST_PREFIXTEXT : DST_TEXT)); + } + + BOOL DrawState(POINT pt, SIZE size, DRAWSTATEPROC lpDrawProc, LPARAM lData, UINT nFlags, HBRUSH hBrush = NULL) + { + ATLASSERT(m_hDC != NULL); + return ::DrawState(m_hDC, hBrush, lpDrawProc, lData, 0, pt.x, pt.y, size.cx, size.cy, nFlags | DST_COMPLEX); + } + +// Ellipse and Polygon Functions + BOOL Chord(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) + { + ATLASSERT(m_hDC != NULL); + return ::Chord(m_hDC, x1, y1, x2, y2, x3, y3, x4, y4); + } + + BOOL Chord(LPCRECT lpRect, POINT ptStart, POINT ptEnd) + { + ATLASSERT(m_hDC != NULL); + return ::Chord(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom, ptStart.x, ptStart.y, ptEnd.x, ptEnd.y); + } + + void DrawFocusRect(LPCRECT lpRect) + { + ATLASSERT(m_hDC != NULL); + ::DrawFocusRect(m_hDC, lpRect); + } + + BOOL Ellipse(int x1, int y1, int x2, int y2) + { + ATLASSERT(m_hDC != NULL); + return ::Ellipse(m_hDC, x1, y1, x2, y2); + } + + BOOL Ellipse(LPCRECT lpRect) + { + ATLASSERT(m_hDC != NULL); + return ::Ellipse(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom); + } + + BOOL Pie(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) + { + ATLASSERT(m_hDC != NULL); + return ::Pie(m_hDC, x1, y1, x2, y2, x3, y3, x4, y4); + } + + BOOL Pie(LPCRECT lpRect, POINT ptStart, POINT ptEnd) + { + ATLASSERT(m_hDC != NULL); + return ::Pie(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom, ptStart.x, ptStart.y, ptEnd.x, ptEnd.y); + } + + BOOL Polygon(const POINT* lpPoints, int nCount) + { + ATLASSERT(m_hDC != NULL); + return ::Polygon(m_hDC, lpPoints, nCount); + } + + BOOL PolyPolygon(const POINT* lpPoints, const INT* lpPolyCounts, int nCount) + { + ATLASSERT(m_hDC != NULL); + return ::PolyPolygon(m_hDC, lpPoints, lpPolyCounts, nCount); + } + + BOOL Rectangle(int x1, int y1, int x2, int y2) + { + ATLASSERT(m_hDC != NULL); + return ::Rectangle(m_hDC, x1, y1, x2, y2); + } + + BOOL Rectangle(LPCRECT lpRect) + { + ATLASSERT(m_hDC != NULL); + return ::Rectangle(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom); + } + + BOOL RoundRect(int x1, int y1, int x2, int y2, int x3, int y3) + { + ATLASSERT(m_hDC != NULL); + return ::RoundRect(m_hDC, x1, y1, x2, y2, x3, y3); + } + + BOOL RoundRect(LPCRECT lpRect, POINT point) + { + ATLASSERT(m_hDC != NULL); + return ::RoundRect(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom, point.x, point.y); + } + +// Bitmap Functions + BOOL PatBlt(int x, int y, int nWidth, int nHeight, DWORD dwRop) + { + ATLASSERT(m_hDC != NULL); + return ::PatBlt(m_hDC, x, y, nWidth, nHeight, dwRop); + } + + BOOL BitBlt(int x, int y, int nWidth, int nHeight, HDC hSrcDC, + int xSrc, int ySrc, DWORD dwRop) + { + ATLASSERT(m_hDC != NULL); + return ::BitBlt(m_hDC, x, y, nWidth, nHeight, hSrcDC, xSrc, ySrc, dwRop); + } + + BOOL StretchBlt(int x, int y, int nWidth, int nHeight, HDC hSrcDC, int xSrc, int ySrc, int nSrcWidth, int nSrcHeight, DWORD dwRop) + { + ATLASSERT(m_hDC != NULL); + return ::StretchBlt(m_hDC, x, y, nWidth, nHeight, hSrcDC, xSrc, ySrc, nSrcWidth, nSrcHeight, dwRop); + } + + COLORREF GetPixel(int x, int y) const + { + ATLASSERT(m_hDC != NULL); + return ::GetPixel(m_hDC, x, y); + } + + COLORREF GetPixel(POINT point) const + { + ATLASSERT(m_hDC != NULL); + return ::GetPixel(m_hDC, point.x, point.y); + } + + COLORREF SetPixel(int x, int y, COLORREF crColor) + { + ATLASSERT(m_hDC != NULL); + return ::SetPixel(m_hDC, x, y, crColor); + } + + COLORREF SetPixel(POINT point, COLORREF crColor) + { + ATLASSERT(m_hDC != NULL); + return ::SetPixel(m_hDC, point.x, point.y, crColor); + } + + BOOL FloodFill(int x, int y, COLORREF crColor) + { + ATLASSERT(m_hDC != NULL); + return ::FloodFill(m_hDC, x, y, crColor); + } + + BOOL ExtFloodFill(int x, int y, COLORREF crColor, UINT nFillType) + { + ATLASSERT(m_hDC != NULL); + return ::ExtFloodFill(m_hDC, x, y, crColor, nFillType); + } + + BOOL MaskBlt(int x, int y, int nWidth, int nHeight, HDC hSrcDC, int xSrc, int ySrc, HBITMAP hMaskBitmap, int xMask, int yMask, DWORD dwRop) + { + ATLASSERT(m_hDC != NULL); + return ::MaskBlt(m_hDC, x, y, nWidth, nHeight, hSrcDC, xSrc, ySrc, hMaskBitmap, xMask, yMask, dwRop); + } + + BOOL PlgBlt(LPPOINT lpPoint, HDC hSrcDC, int xSrc, int ySrc, int nWidth, int nHeight, HBITMAP hMaskBitmap, int xMask, int yMask) + { + ATLASSERT(m_hDC != NULL); + return ::PlgBlt(m_hDC, lpPoint, hSrcDC, xSrc, ySrc, nWidth, nHeight, hMaskBitmap, xMask, yMask); + } + + BOOL SetPixelV(int x, int y, COLORREF crColor) + { + ATLASSERT(m_hDC != NULL); + return ::SetPixelV(m_hDC, x, y, crColor); + } + + BOOL SetPixelV(POINT point, COLORREF crColor) + { + ATLASSERT(m_hDC != NULL); + return ::SetPixelV(m_hDC, point.x, point.y, crColor); + } + + BOOL TransparentBlt(int x, int y, int nWidth, int nHeight, HDC hSrcDC, int xSrc, int ySrc, int nSrcWidth, int nSrcHeight, UINT crTransparent) + { + ATLASSERT(m_hDC != NULL); + return ::TransparentBlt(m_hDC, x, y, nWidth, nHeight, hSrcDC, xSrc, ySrc, nSrcWidth, nSrcHeight, crTransparent); + } + + BOOL GradientFill(const PTRIVERTEX pVertices, DWORD nVertices, void* pMeshElements, DWORD nMeshElements, DWORD dwMode) + { + ATLASSERT(m_hDC != NULL); + return ::GradientFill(m_hDC, pVertices, nVertices, pMeshElements, nMeshElements, dwMode); + } + + BOOL GradientFillRect(RECT& rect, COLORREF clr1, COLORREF clr2, bool bHorizontal) + { + ATLASSERT(m_hDC != NULL); + + TRIVERTEX arrTvx[2] = { { 0 }, { 0 } }; + + arrTvx[0].x = rect.left; + arrTvx[0].y = rect.top; + arrTvx[0].Red = MAKEWORD(0, GetRValue(clr1)); + arrTvx[0].Green = MAKEWORD(0, GetGValue(clr1)); + arrTvx[0].Blue = MAKEWORD(0, GetBValue(clr1)); + arrTvx[0].Alpha = 0; + + arrTvx[1].x = rect.right; + arrTvx[1].y = rect.bottom; + arrTvx[1].Red = MAKEWORD(0, GetRValue(clr2)); + arrTvx[1].Green = MAKEWORD(0, GetGValue(clr2)); + arrTvx[1].Blue = MAKEWORD(0, GetBValue(clr2)); + arrTvx[1].Alpha = 0; + + GRADIENT_RECT gr = { 0, 1 }; + + return ::GradientFill(m_hDC, arrTvx, 2, &gr, 1, bHorizontal ? GRADIENT_FILL_RECT_H : GRADIENT_FILL_RECT_V); + } + + BOOL AlphaBlend(int x, int y, int nWidth, int nHeight, HDC hSrcDC, int xSrc, int ySrc, int nSrcWidth, int nSrcHeight, BLENDFUNCTION bf) + { + ATLASSERT(m_hDC != NULL); + return ::AlphaBlend(m_hDC, x, y, nWidth, nHeight, hSrcDC, xSrc, ySrc, nSrcWidth, nSrcHeight, bf); + } + +// Extra bitmap functions + // Helper function for painting a disabled toolbar or menu bitmap + // This function can take either an HBITMAP (for SS) or a DC with + // the bitmap already painted (for cmdbar) + BOOL DitherBlt(int x, int y, int nWidth, int nHeight, HDC hSrcDC, HBITMAP hBitmap, int xSrc, int ySrc, + HBRUSH hBrushBackground = ::GetSysColorBrush(COLOR_3DFACE), + HBRUSH hBrush3DEffect = ::GetSysColorBrush(COLOR_3DHILIGHT), + HBRUSH hBrushDisabledImage = ::GetSysColorBrush(COLOR_3DSHADOW)) + { + ATLASSERT((m_hDC != NULL) || (hBitmap != NULL)); + ATLASSERT((nWidth > 0) && (nHeight > 0)); + + // Create a generic DC for all BitBlts + CDCT dc = (hSrcDC != NULL) ? hSrcDC : ::CreateCompatibleDC(m_hDC); + ATLASSERT(dc.m_hDC != NULL); + if(dc.m_hDC == NULL) + return FALSE; + + // Create a DC for the monochrome DIB section + CDCT dcBW = ::CreateCompatibleDC(m_hDC); + ATLASSERT(dcBW.m_hDC != NULL); + if(dcBW.m_hDC == NULL) + { + if(hSrcDC == NULL) + dc.DeleteDC(); + return FALSE; + } + + // Create the monochrome DIB section with a black and white palette + struct RGBBWBITMAPINFO + { + BITMAPINFOHEADER bmiHeader; + RGBQUAD bmiColors[2]; + }; + + RGBBWBITMAPINFO rgbBWBitmapInfo = + { + { sizeof(BITMAPINFOHEADER), nWidth, nHeight, 1, 1, BI_RGB, 0, 0, 0, 0, 0 }, + { { 0x00, 0x00, 0x00, 0x00 }, { 0xFF, 0xFF, 0xFF, 0x00 } } + }; + + VOID* pbitsBW; + CBitmap bmpBW = ::CreateDIBSection(dcBW, (LPBITMAPINFO)&rgbBWBitmapInfo, DIB_RGB_COLORS, &pbitsBW, NULL, 0); + ATLASSERT(bmpBW.m_hBitmap != NULL); + if(bmpBW.m_hBitmap == NULL) + { + if(hSrcDC == NULL) + dc.DeleteDC(); + return FALSE; + } + + // Attach the monochrome DIB section and the bitmap to the DCs + HBITMAP hbmOldBW = dcBW.SelectBitmap(bmpBW); + HBITMAP hbmOldDC = NULL; + if(hBitmap != NULL) + hbmOldDC = dc.SelectBitmap(hBitmap); + + // Block: Dark gray removal: we want (128, 128, 128) pixels to become black and not white + { + CDCT dcTemp1 = ::CreateCompatibleDC(m_hDC); + CDCT dcTemp2 = ::CreateCompatibleDC(m_hDC); + CBitmap bmpTemp1; + bmpTemp1.CreateCompatibleBitmap(dc, nWidth, nHeight); + CBitmap bmpTemp2; + bmpTemp2.CreateBitmap(nWidth, nHeight, 1, 1, NULL); + HBITMAP hOldBmp1 = dcTemp1.SelectBitmap(bmpTemp1); + HBITMAP hOldBmp2 = dcTemp2.SelectBitmap(bmpTemp2); + // Let's copy our image, it will be altered + dcTemp1.BitBlt(0, 0, nWidth, nHeight, dc, xSrc, ySrc, SRCCOPY); + + // All dark gray pixels will become white, the others black + dcTemp1.SetBkColor(RGB(128, 128, 128)); + dcTemp2.BitBlt(0, 0, nWidth, nHeight, dcTemp1, 0, 0, SRCCOPY); + // Do an XOR to set to black these white pixels + dcTemp1.BitBlt(0, 0, nWidth, nHeight, dcTemp2, 0, 0, SRCINVERT); + + // BitBlt the bitmap into the monochrome DIB section + // The DIB section will do a true monochrome conversion + // The magenta background being closer to white will become white + dcBW.BitBlt(0, 0, nWidth, nHeight, dcTemp1, 0, 0, SRCCOPY); + + // Cleanup + dcTemp1.SelectBitmap(hOldBmp1); + dcTemp2.SelectBitmap(hOldBmp2); + } + + // Paint the destination rectangle using hBrushBackground + if(hBrushBackground != NULL) + { + RECT rc = { x, y, x + nWidth, y + nHeight }; + FillRect(&rc, hBrushBackground); + } + + // BitBlt the black bits in the monochrome bitmap into hBrush3DEffect color in the destination DC + // The magic ROP comes from the Charles Petzold's book + HBRUSH hOldBrush = SelectBrush(hBrush3DEffect); + BitBlt(x + 1, y + 1, nWidth, nHeight, dcBW, 0, 0, 0xB8074A); + + // BitBlt the black bits in the monochrome bitmap into hBrushDisabledImage color in the destination DC + SelectBrush(hBrushDisabledImage); + BitBlt(x, y, nWidth, nHeight, dcBW, 0, 0, 0xB8074A); + + SelectBrush(hOldBrush); + dcBW.SelectBitmap(hbmOldBW); + dc.SelectBitmap(hbmOldDC); + + if(hSrcDC == NULL) + dc.DeleteDC(); + + return TRUE; + } + +// Text Functions + BOOL TextOut(int x, int y, LPCTSTR lpszString, int nCount = -1) + { + ATLASSERT(m_hDC != NULL); + if(nCount == -1) + nCount = lstrlen(lpszString); + return ::TextOut(m_hDC, x, y, lpszString, nCount); + } + + BOOL ExtTextOut(int x, int y, UINT nOptions, LPCRECT lpRect, LPCTSTR lpszString, int nCount = -1, LPINT lpDxWidths = NULL) + { + ATLASSERT(m_hDC != NULL); + if(nCount == -1) + nCount = lstrlen(lpszString); + ATLASSERT((nCount >= 0) && (nCount <= 8192)); + return ::ExtTextOut(m_hDC, x, y, nOptions, lpRect, lpszString, (UINT)nCount, lpDxWidths); + } + + SIZE TabbedTextOut(int x, int y, LPCTSTR lpszString, int nCount = -1, int nTabPositions = 0, LPINT lpnTabStopPositions = NULL, int nTabOrigin = 0) + { + ATLASSERT(m_hDC != NULL); + if(nCount == -1) + nCount = lstrlen(lpszString); + LONG lRes = ::TabbedTextOut(m_hDC, x, y, lpszString, nCount, nTabPositions, lpnTabStopPositions, nTabOrigin); + SIZE size = { GET_X_LPARAM(lRes), GET_Y_LPARAM(lRes) }; + return size; + } + + int DrawText(LPCTSTR lpstrText, int cchText, LPRECT lpRect, UINT uFormat) + { + ATLASSERT(m_hDC != NULL); + ATLASSERT((uFormat & DT_MODIFYSTRING) == 0); + return ::DrawText(m_hDC, lpstrText, cchText, lpRect, uFormat); + } + + int DrawText(LPTSTR lpstrText, int cchText, LPRECT lpRect, UINT uFormat) + { + ATLASSERT(m_hDC != NULL); + return ::DrawText(m_hDC, lpstrText, cchText, lpRect, uFormat); + } + + int DrawTextEx(LPTSTR lpstrText, int cchText, LPRECT lpRect, UINT uFormat, LPDRAWTEXTPARAMS lpDTParams = NULL) + { + ATLASSERT(m_hDC != NULL); + return ::DrawTextEx(m_hDC, lpstrText, cchText, lpRect, uFormat, lpDTParams); + } + + // Note - ::DrawShadowText() is present only if comctl32.dll version 6 is loaded + int DrawShadowText(LPCWSTR lpstrText, int cchText, LPRECT lpRect, DWORD dwFlags, COLORREF clrText, COLORREF clrShadow, int xOffset, int yOffset) + { + ATLASSERT(m_hDC != NULL); + ATLASSERT(lpRect != NULL); + return ::DrawShadowText(m_hDC, lpstrText, cchText, lpRect, dwFlags, clrText, clrShadow, xOffset, yOffset); + } + + BOOL GetTextExtent(LPCTSTR lpszString, int nCount, LPSIZE lpSize) const + { + ATLASSERT(m_hDC != NULL); + if(nCount == -1) + nCount = lstrlen(lpszString); + return ::GetTextExtentPoint32(m_hDC, lpszString, nCount, lpSize); + } + + BOOL GetTextExtentExPoint(LPCTSTR lpszString, int cchString, LPSIZE lpSize, int nMaxExtent, LPINT lpnFit = NULL, LPINT alpDx = NULL) + { + ATLASSERT(m_hDC != NULL); + return ::GetTextExtentExPoint(m_hDC, lpszString, cchString, nMaxExtent, lpnFit, alpDx, lpSize); + } + + DWORD GetTabbedTextExtent(LPCTSTR lpszString, int nCount = -1, int nTabPositions = 0, LPINT lpnTabStopPositions = NULL) const + { + ATLASSERT(m_hDC != NULL); + if(nCount == -1) + nCount = lstrlen(lpszString); + return ::GetTabbedTextExtent(m_hDC, lpszString, nCount, nTabPositions, lpnTabStopPositions); + } + + BOOL GrayString(HBRUSH hBrush, BOOL (CALLBACK* lpfnOutput)(HDC, LPARAM, int), LPARAM lpData, int nCount, int x, int y, int nWidth, int nHeight) + { + ATLASSERT(m_hDC != NULL); + return ::GrayString(m_hDC, hBrush, (GRAYSTRINGPROC)lpfnOutput, lpData, nCount, x, y, nWidth, nHeight); + } + + UINT GetTextAlign() const + { + ATLASSERT(m_hDC != NULL); + return ::GetTextAlign(m_hDC); + } + + UINT SetTextAlign(UINT nFlags) + { + ATLASSERT(m_hDC != NULL); + return ::SetTextAlign(m_hDC, nFlags); + } + + int GetTextFace(LPTSTR lpszFacename, int nCount) const + { + ATLASSERT(m_hDC != NULL); + return ::GetTextFace(m_hDC, nCount, lpszFacename); + } + + int GetTextFaceLen() const + { + ATLASSERT(m_hDC != NULL); + return ::GetTextFace(m_hDC, 0, NULL); + } + +#ifdef _OLEAUTO_H_ + BOOL GetTextFace(BSTR& bstrFace) const + { + USES_CONVERSION; + ATLASSERT(m_hDC != NULL); + ATLASSERT(bstrFace == NULL); + + int nLen = GetTextFaceLen(); + if(nLen == 0) + return FALSE; + + ATL::CTempBuffer buff; + LPTSTR lpszText = buff.Allocate(nLen); + if(lpszText == NULL) + return FALSE; + + if(!GetTextFace(lpszText, nLen)) + return FALSE; + + bstrFace = ::SysAllocString(T2OLE(lpszText)); + return (bstrFace != NULL) ? TRUE : FALSE; + } +#endif + +#ifdef __ATLSTR_H__ + int GetTextFace(ATL::CString& strFace) const + { + ATLASSERT(m_hDC != NULL); + + int nLen = GetTextFaceLen(); + if(nLen == 0) + return 0; + + LPTSTR lpstr = strFace.GetBufferSetLength(nLen); + if(lpstr == NULL) + return 0; + int nRet = GetTextFace(lpstr, nLen); + strFace.ReleaseBuffer(); + return nRet; + } +#endif // __ATLSTR_H__ + + BOOL GetTextMetrics(LPTEXTMETRIC lpMetrics) const + { + ATLASSERT(m_hDC != NULL); + return ::GetTextMetrics(m_hDC, lpMetrics); + } + + int SetTextJustification(int nBreakExtra, int nBreakCount) + { + ATLASSERT(m_hDC != NULL); + return ::SetTextJustification(m_hDC, nBreakExtra, nBreakCount); + } + + int GetTextCharacterExtra() const + { + ATLASSERT(m_hDC != NULL); + return ::GetTextCharacterExtra(m_hDC); + } + + int SetTextCharacterExtra(int nCharExtra) + { + ATLASSERT(m_hDC != NULL); + return ::SetTextCharacterExtra(m_hDC, nCharExtra); + } + +// Advanced Drawing + BOOL DrawEdge(LPRECT lpRect, UINT nEdge, UINT nFlags) + { + ATLASSERT(m_hDC != NULL); + return ::DrawEdge(m_hDC, lpRect, nEdge, nFlags); + } + + BOOL DrawFrameControl(LPRECT lpRect, UINT nType, UINT nState) + { + ATLASSERT(m_hDC != NULL); + return ::DrawFrameControl(m_hDC, lpRect, nType, nState); + } + +// Scrolling Functions + BOOL ScrollDC(int dx, int dy, LPCRECT lpRectScroll, LPCRECT lpRectClip, HRGN hRgnUpdate, LPRECT lpRectUpdate) + { + ATLASSERT(m_hDC != NULL); + return ::ScrollDC(m_hDC, dx, dy, lpRectScroll, lpRectClip, hRgnUpdate, lpRectUpdate); + } + +// Font Functions + BOOL GetCharWidth(UINT nFirstChar, UINT nLastChar, LPINT lpBuffer) const + { + ATLASSERT(m_hDC != NULL); + return ::GetCharWidth(m_hDC, nFirstChar, nLastChar, lpBuffer); + } + + // GetCharWidth32 is not supported under Win9x + BOOL GetCharWidth32(UINT nFirstChar, UINT nLastChar, LPINT lpBuffer) const + { + ATLASSERT(m_hDC != NULL); + return ::GetCharWidth32(m_hDC, nFirstChar, nLastChar, lpBuffer); + } + + DWORD SetMapperFlags(DWORD dwFlag) + { + ATLASSERT(m_hDC != NULL); + return ::SetMapperFlags(m_hDC, dwFlag); + } + + BOOL GetAspectRatioFilter(LPSIZE lpSize) const + { + ATLASSERT(m_hDC != NULL); + return ::GetAspectRatioFilterEx(m_hDC, lpSize); + } + + BOOL GetCharABCWidths(UINT nFirstChar, UINT nLastChar, LPABC lpabc) const + { + ATLASSERT(m_hDC != NULL); + return ::GetCharABCWidths(m_hDC, nFirstChar, nLastChar, lpabc); + } + + DWORD GetFontData(DWORD dwTable, DWORD dwOffset, LPVOID lpData, DWORD cbData) const + { + ATLASSERT(m_hDC != NULL); + return ::GetFontData(m_hDC, dwTable, dwOffset, lpData, cbData); + } + + int GetKerningPairs(int nPairs, LPKERNINGPAIR lpkrnpair) const + { + ATLASSERT(m_hDC != NULL); + return ::GetKerningPairs(m_hDC, nPairs, lpkrnpair); + } + + UINT GetOutlineTextMetrics(UINT cbData, LPOUTLINETEXTMETRIC lpotm) const + { + ATLASSERT(m_hDC != NULL); + return ::GetOutlineTextMetrics(m_hDC, cbData, lpotm); + } + + DWORD GetGlyphOutline(UINT nChar, UINT nFormat, LPGLYPHMETRICS lpgm, DWORD cbBuffer, LPVOID lpBuffer, const MAT2* lpmat2) const + { + ATLASSERT(m_hDC != NULL); + return ::GetGlyphOutline(m_hDC, nChar, nFormat, lpgm, cbBuffer, lpBuffer, lpmat2); + } + + BOOL GetCharABCWidths(UINT nFirstChar, UINT nLastChar, LPABCFLOAT lpABCF) const + { + ATLASSERT(m_hDC != NULL); + return ::GetCharABCWidthsFloat(m_hDC, nFirstChar, nLastChar, lpABCF); + } + + BOOL GetCharWidth(UINT nFirstChar, UINT nLastChar, float* lpFloatBuffer) const + { + ATLASSERT(m_hDC != NULL); + return ::GetCharWidthFloat(m_hDC, nFirstChar, nLastChar, lpFloatBuffer); + } + +// Printer/Device Escape Functions + int Escape(int nEscape, int nCount, LPCSTR lpszInData, LPVOID lpOutData) + { + ATLASSERT(m_hDC != NULL); + return ::Escape(m_hDC, nEscape, nCount, lpszInData, lpOutData); + } + + int Escape(int nEscape, int nInputSize, LPCSTR lpszInputData, + int nOutputSize, LPSTR lpszOutputData) + { + ATLASSERT(m_hDC != NULL); + return ::ExtEscape(m_hDC, nEscape, nInputSize, lpszInputData, nOutputSize, lpszOutputData); + } + + int DrawEscape(int nEscape, int nInputSize, LPCSTR lpszInputData) + { + ATLASSERT(m_hDC != NULL); + return ::DrawEscape(m_hDC, nEscape, nInputSize, lpszInputData); + } + + // Escape helpers + int StartDoc(LPCTSTR lpszDocName) // old Win3.0 version + { + DOCINFO di = {}; + di.cbSize = sizeof(DOCINFO); + di.lpszDocName = lpszDocName; + return StartDoc(&di); + } + + int StartDoc(LPDOCINFO lpDocInfo) + { + ATLASSERT(m_hDC != NULL); + return ::StartDoc(m_hDC, lpDocInfo); + } + + int StartPage() + { + ATLASSERT(m_hDC != NULL); + return ::StartPage(m_hDC); + } + + int EndPage() + { + ATLASSERT(m_hDC != NULL); + return ::EndPage(m_hDC); + } + + int SetAbortProc(BOOL (CALLBACK* lpfn)(HDC, int)) + { + ATLASSERT(m_hDC != NULL); + return ::SetAbortProc(m_hDC, (ABORTPROC)lpfn); + } + + int AbortDoc() + { + ATLASSERT(m_hDC != NULL); + return ::AbortDoc(m_hDC); + } + + int EndDoc() + { + ATLASSERT(m_hDC != NULL); + return ::EndDoc(m_hDC); + } + +// MetaFile Functions + BOOL PlayMetaFile(HMETAFILE hMF) + { + ATLASSERT(m_hDC != NULL); + if(::GetDeviceCaps(m_hDC, TECHNOLOGY) == DT_METAFILE) + { + // playing metafile in metafile, just use core windows API + return ::PlayMetaFile(m_hDC, hMF); + } + + // for special playback, lParam == pDC + return ::EnumMetaFile(m_hDC, hMF, EnumMetaFileProc, (LPARAM)this); + } + + BOOL PlayMetaFile(HENHMETAFILE hEnhMetaFile, LPCRECT lpBounds) + { + ATLASSERT(m_hDC != NULL); + return ::PlayEnhMetaFile(m_hDC, hEnhMetaFile, lpBounds); + } + + BOOL AddMetaFileComment(UINT nDataSize, const BYTE* pCommentData) // can be used for enhanced metafiles only + { + ATLASSERT(m_hDC != NULL); + return ::GdiComment(m_hDC, nDataSize, pCommentData); + } + + // Special handling for metafile playback + static int CALLBACK EnumMetaFileProc(HDC hDC, HANDLETABLE* pHandleTable, METARECORD* pMetaRec, int nHandles, LPARAM lParam) + { + CDCT* pDC = (CDCT*)lParam; + + switch (pMetaRec->rdFunction) + { + case META_SETMAPMODE: + pDC->SetMapMode((int)(short)pMetaRec->rdParm[0]); + break; + case META_SETWINDOWEXT: + pDC->SetWindowExt((int)(short)pMetaRec->rdParm[1], (int)(short)pMetaRec->rdParm[0]); + break; + case META_SETWINDOWORG: + pDC->SetWindowOrg((int)(short)pMetaRec->rdParm[1], (int)(short)pMetaRec->rdParm[0]); + break; + case META_SETVIEWPORTEXT: + pDC->SetViewportExt((int)(short)pMetaRec->rdParm[1], (int)(short)pMetaRec->rdParm[0]); + break; + case META_SETVIEWPORTORG: + pDC->SetViewportOrg((int)(short)pMetaRec->rdParm[1], (int)(short)pMetaRec->rdParm[0]); + break; + case META_SCALEWINDOWEXT: + pDC->ScaleWindowExt((int)(short)pMetaRec->rdParm[3], (int)(short)pMetaRec->rdParm[2], + (int)(short)pMetaRec->rdParm[1], (int)(short)pMetaRec->rdParm[0]); + break; + case META_SCALEVIEWPORTEXT: + pDC->ScaleViewportExt((int)(short)pMetaRec->rdParm[3], (int)(short)pMetaRec->rdParm[2], + (int)(short)pMetaRec->rdParm[1], (int)(short)pMetaRec->rdParm[0]); + break; + case META_OFFSETVIEWPORTORG: + pDC->OffsetViewportOrg((int)(short)pMetaRec->rdParm[1], (int)(short)pMetaRec->rdParm[0]); + break; + case META_SAVEDC: + pDC->SaveDC(); + break; + case META_RESTOREDC: + pDC->RestoreDC((int)(short)pMetaRec->rdParm[0]); + break; + case META_SETBKCOLOR: + pDC->SetBkColor(*(UNALIGNED COLORREF*)&pMetaRec->rdParm[0]); + break; + case META_SETTEXTCOLOR: + pDC->SetTextColor(*(UNALIGNED COLORREF*)&pMetaRec->rdParm[0]); + break; + + // need to watch out for SelectObject(HFONT), for custom font mapping + case META_SELECTOBJECT: + { + HGDIOBJ hObject = pHandleTable->objectHandle[pMetaRec->rdParm[0]]; + UINT nObjType = ::GetObjectType(hObject); + if(nObjType == 0) + { + // object type is unknown, determine if it is a font + HFONT hStockFont = (HFONT)::GetStockObject(SYSTEM_FONT); + HFONT hFontOld = (HFONT)::SelectObject(pDC->m_hDC, hStockFont); + HGDIOBJ hObjOld = ::SelectObject(pDC->m_hDC, hObject); + if(hObjOld == hStockFont) + { + // got the stock object back, so must be selecting a font + pDC->SelectFont((HFONT)hObject); + break; // don't play the default record + } + else + { + // didn't get the stock object back, so restore everything + ::SelectObject(pDC->m_hDC, hFontOld); + ::SelectObject(pDC->m_hDC, hObjOld); + } + // and fall through to PlayMetaFileRecord... + } + else if(nObjType == OBJ_FONT) + { + // play back as CDCHandle::SelectFont(HFONT) + pDC->SelectFont((HFONT)hObject); + break; // don't play the default record + } + } + // fall through... + + default: + ::PlayMetaFileRecord(hDC, pHandleTable, pMetaRec, nHandles); + break; + } + + return 1; + } + +// Path Functions + BOOL AbortPath() + { + ATLASSERT(m_hDC != NULL); + return ::AbortPath(m_hDC); + } + + BOOL BeginPath() + { + ATLASSERT(m_hDC != NULL); + return ::BeginPath(m_hDC); + } + + BOOL CloseFigure() + { + ATLASSERT(m_hDC != NULL); + return ::CloseFigure(m_hDC); + } + + BOOL EndPath() + { + ATLASSERT(m_hDC != NULL); + return ::EndPath(m_hDC); + } + + BOOL FillPath() + { + ATLASSERT(m_hDC != NULL); + return ::FillPath(m_hDC); + } + + BOOL FlattenPath() + { + ATLASSERT(m_hDC != NULL); + return ::FlattenPath(m_hDC); + } + + BOOL StrokeAndFillPath() + { + ATLASSERT(m_hDC != NULL); + return ::StrokeAndFillPath(m_hDC); + } + + BOOL StrokePath() + { + ATLASSERT(m_hDC != NULL); + return ::StrokePath(m_hDC); + } + + BOOL WidenPath() + { + ATLASSERT(m_hDC != NULL); + return ::WidenPath(m_hDC); + } + + BOOL GetMiterLimit(PFLOAT pfMiterLimit) const + { + ATLASSERT(m_hDC != NULL); + return ::GetMiterLimit(m_hDC, pfMiterLimit); + } + + BOOL SetMiterLimit(float fMiterLimit) + { + ATLASSERT(m_hDC != NULL); + return ::SetMiterLimit(m_hDC, fMiterLimit, NULL); + } + + int GetPath(LPPOINT lpPoints, LPBYTE lpTypes, int nCount) const + { + ATLASSERT(m_hDC != NULL); + return ::GetPath(m_hDC, lpPoints, lpTypes, nCount); + } + + BOOL SelectClipPath(int nMode) + { + ATLASSERT(m_hDC != NULL); + return ::SelectClipPath(m_hDC, nMode); + } + +// Misc Helper Functions + static CBrushHandle PASCAL GetHalftoneBrush() + { + HBRUSH halftoneBrush = NULL; + WORD grayPattern[8] = {}; + for(int i = 0; i < 8; i++) + grayPattern[i] = (WORD)(0x5555 << (i & 1)); + HBITMAP grayBitmap = CreateBitmap(8, 8, 1, 1, &grayPattern); + if(grayBitmap != NULL) + { + halftoneBrush = ::CreatePatternBrush(grayBitmap); + DeleteObject(grayBitmap); + } + return CBrushHandle(halftoneBrush); + } + + void DrawDragRect(LPCRECT lpRect, SIZE size, LPCRECT lpRectLast, SIZE sizeLast, HBRUSH hBrush = NULL, HBRUSH hBrushLast = NULL) + { + // first, determine the update region and select it + CRgn rgnOutside; + rgnOutside.CreateRectRgnIndirect(lpRect); + RECT rect = *lpRect; + ::InflateRect(&rect, -size.cx, -size.cy); + ::IntersectRect(&rect, &rect, lpRect); + CRgn rgnInside; + rgnInside.CreateRectRgnIndirect(&rect); + CRgn rgnNew; + rgnNew.CreateRectRgn(0, 0, 0, 0); + rgnNew.CombineRgn(rgnOutside, rgnInside, RGN_XOR); + + HBRUSH hBrushOld = NULL; + CBrush brushHalftone; + if(hBrush == NULL) + brushHalftone = hBrush = CDCHandle::GetHalftoneBrush(); + if(hBrushLast == NULL) + hBrushLast = hBrush; + + CRgn rgnLast; + CRgn rgnUpdate; + if(lpRectLast != NULL) + { + // find difference between new region and old region + rgnLast.CreateRectRgn(0, 0, 0, 0); + rgnOutside.SetRectRgn(lpRectLast->left, lpRectLast->top, lpRectLast->right, lpRectLast->bottom); + rect = *lpRectLast; + ::InflateRect(&rect, -sizeLast.cx, -sizeLast.cy); + ::IntersectRect(&rect, &rect, lpRectLast); + rgnInside.SetRectRgn(rect.left, rect.top, rect.right, rect.bottom); + rgnLast.CombineRgn(rgnOutside, rgnInside, RGN_XOR); + + // only diff them if brushes are the same + if(hBrush == hBrushLast) + { + rgnUpdate.CreateRectRgn(0, 0, 0, 0); + rgnUpdate.CombineRgn(rgnLast, rgnNew, RGN_XOR); + } + } + if((hBrush != hBrushLast) && (lpRectLast != NULL)) + { + // brushes are different -- erase old region first + SelectClipRgn(rgnLast); + GetClipBox(&rect); + hBrushOld = SelectBrush(hBrushLast); + PatBlt(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, PATINVERT); + SelectBrush(hBrushOld); + hBrushOld = NULL; + } + + // draw into the update/new region + SelectClipRgn(rgnUpdate.IsNull() ? rgnNew : rgnUpdate); + GetClipBox(&rect); + hBrushOld = SelectBrush(hBrush); + PatBlt(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, PATINVERT); + + // cleanup DC + if(hBrushOld != NULL) + SelectBrush(hBrushOld); + SelectClipRgn(NULL); + } + + void FillSolidRect(LPCRECT lpRect, COLORREF clr) + { + ATLASSERT(m_hDC != NULL); + + COLORREF clrOld = ::SetBkColor(m_hDC, clr); + ATLASSERT(clrOld != CLR_INVALID); + if(clrOld != CLR_INVALID) + { + ::ExtTextOut(m_hDC, 0, 0, ETO_OPAQUE, lpRect, NULL, 0, NULL); + ::SetBkColor(m_hDC, clrOld); + } + } + + void FillSolidRect(int x, int y, int cx, int cy, COLORREF clr) + { + ATLASSERT(m_hDC != NULL); + + RECT rect = { x, y, x + cx, y + cy }; + FillSolidRect(&rect, clr); + } + + void Draw3dRect(LPCRECT lpRect, COLORREF clrTopLeft, COLORREF clrBottomRight) + { + Draw3dRect(lpRect->left, lpRect->top, lpRect->right - lpRect->left, + lpRect->bottom - lpRect->top, clrTopLeft, clrBottomRight); + } + + void Draw3dRect(int x, int y, int cx, int cy, COLORREF clrTopLeft, COLORREF clrBottomRight) + { + FillSolidRect(x, y, cx - 1, 1, clrTopLeft); + FillSolidRect(x, y, 1, cy - 1, clrTopLeft); + FillSolidRect(x + cx, y, -1, cy, clrBottomRight); + FillSolidRect(x, y + cy, cx, -1, clrBottomRight); + } + +// DIB support + int SetDIBitsToDevice(int x, int y, DWORD dwWidth, DWORD dwHeight, int xSrc, int ySrc, UINT uStartScan, UINT cScanLines, CONST VOID* lpvBits, CONST BITMAPINFO* lpbmi, UINT uColorUse) + { + ATLASSERT(m_hDC != NULL); + return ::SetDIBitsToDevice(m_hDC, x, y, dwWidth, dwHeight, xSrc, ySrc, uStartScan, cScanLines, lpvBits, lpbmi, uColorUse); + } + + int StretchDIBits(int x, int y, int nWidth, int nHeight, int xSrc, int ySrc, int nSrcWidth, int nSrcHeight, CONST VOID* lpvBits, CONST BITMAPINFO* lpbmi, UINT uColorUse, DWORD dwRop) + { + ATLASSERT(m_hDC != NULL); + return ::StretchDIBits(m_hDC, x, y, nWidth, nHeight, xSrc, ySrc, nSrcWidth, nSrcHeight, lpvBits, lpbmi, uColorUse, dwRop); + } + + UINT GetDIBColorTable(UINT uStartIndex, UINT cEntries, RGBQUAD* pColors) const + { + ATLASSERT(m_hDC != NULL); + return ::GetDIBColorTable(m_hDC, uStartIndex, cEntries, pColors); + } + + UINT SetDIBColorTable(UINT uStartIndex, UINT cEntries, CONST RGBQUAD* pColors) + { + ATLASSERT(m_hDC != NULL); + return ::SetDIBColorTable(m_hDC, uStartIndex, cEntries, pColors); + } + +// OpenGL support +#if !defined(_ATL_NO_OPENGL) + int ChoosePixelFormat(CONST PIXELFORMATDESCRIPTOR* ppfd) + { + ATLASSERT(m_hDC != NULL); + return ::ChoosePixelFormat(m_hDC, ppfd); + } + + int DescribePixelFormat(int iPixelFormat, UINT nBytes, LPPIXELFORMATDESCRIPTOR ppfd) + { + ATLASSERT(m_hDC != NULL); + return ::DescribePixelFormat(m_hDC, iPixelFormat, nBytes, ppfd); + } + + int GetPixelFormat() const + { + ATLASSERT(m_hDC != NULL); + return ::GetPixelFormat(m_hDC); + } + + BOOL SetPixelFormat(int iPixelFormat, CONST PIXELFORMATDESCRIPTOR* ppfd) + { + ATLASSERT(m_hDC != NULL); + return ::SetPixelFormat(m_hDC, iPixelFormat, ppfd); + } + + BOOL SwapBuffers() + { + ATLASSERT(m_hDC != NULL); + return ::SwapBuffers(m_hDC); + } + + HGLRC wglCreateContext() + { + ATLASSERT(m_hDC != NULL); + return ::wglCreateContext(m_hDC); + } + + HGLRC wglCreateLayerContext(int iLayerPlane) + { + ATLASSERT(m_hDC != NULL); + return ::wglCreateLayerContext(m_hDC, iLayerPlane); + } + + BOOL wglMakeCurrent(HGLRC hglrc) + { + ATLASSERT(m_hDC != NULL); + return ::wglMakeCurrent(m_hDC, hglrc); + } + + BOOL wglUseFontBitmaps(DWORD dwFirst, DWORD dwCount, DWORD listBase) + { + ATLASSERT(m_hDC != NULL); + return ::wglUseFontBitmaps(m_hDC, dwFirst, dwCount, listBase); + } + + BOOL wglUseFontOutlines(DWORD dwFirst, DWORD dwCount, DWORD listBase, FLOAT deviation, FLOAT extrusion, int format, LPGLYPHMETRICSFLOAT lpgmf) + { + ATLASSERT(m_hDC != NULL); + return ::wglUseFontOutlines(m_hDC, dwFirst, dwCount, listBase, deviation, extrusion, format, lpgmf); + } + + BOOL wglDescribeLayerPlane(int iPixelFormat, int iLayerPlane, UINT nBytes, LPLAYERPLANEDESCRIPTOR plpd) + { + ATLASSERT(m_hDC != NULL); + return ::wglDescribeLayerPlane(m_hDC, iPixelFormat, iLayerPlane, nBytes, plpd); + } + + int wglSetLayerPaletteEntries(int iLayerPlane, int iStart, int cEntries, CONST COLORREF* pclr) + { + ATLASSERT(m_hDC != NULL); + return ::wglSetLayerPaletteEntries(m_hDC, iLayerPlane, iStart, cEntries, pclr); + } + + int wglGetLayerPaletteEntries(int iLayerPlane, int iStart, int cEntries, COLORREF* pclr) + { + ATLASSERT(m_hDC != NULL); + return ::wglGetLayerPaletteEntries(m_hDC, iLayerPlane, iStart, cEntries, pclr); + } + + BOOL wglRealizeLayerPalette(int iLayerPlane, BOOL bRealize) + { + ATLASSERT(m_hDC != NULL); + return ::wglRealizeLayerPalette(m_hDC, iLayerPlane, bRealize); + } + + BOOL wglSwapLayerBuffers(UINT uPlanes) + { + ATLASSERT(m_hDC != NULL); + return ::wglSwapLayerBuffers(m_hDC, uPlanes); + } +#endif // !defined(_ATL_NO_OPENGL) + + COLORREF GetDCPenColor() const + { + ATLASSERT(m_hDC != NULL); + return ::GetDCPenColor(m_hDC); + } + + COLORREF SetDCPenColor(COLORREF clr) + { + ATLASSERT(m_hDC != NULL); + return ::SetDCPenColor(m_hDC, clr); + } + + COLORREF GetDCBrushColor() const + { + ATLASSERT(m_hDC != NULL); + return ::GetDCBrushColor(m_hDC); + } + + COLORREF SetDCBrushColor(COLORREF clr) + { + ATLASSERT(m_hDC != NULL); + return ::SetDCBrushColor(m_hDC, clr); + } + + DWORD GetFontUnicodeRanges(LPGLYPHSET lpgs) const + { + ATLASSERT(m_hDC != NULL); + return ::GetFontUnicodeRanges(m_hDC, lpgs); + } + + DWORD GetGlyphIndices(LPCTSTR lpstr, int cch, LPWORD pgi, DWORD dwFlags) const + { + ATLASSERT(m_hDC != NULL); + return ::GetGlyphIndices(m_hDC, lpstr, cch, pgi, dwFlags); + } + + BOOL GetTextExtentPointI(LPWORD pgiIn, int cgi, LPSIZE lpSize) const + { + ATLASSERT(m_hDC != NULL); + return ::GetTextExtentPointI(m_hDC, pgiIn, cgi, lpSize); + } + + BOOL GetTextExtentExPointI(LPWORD pgiIn, int cgi, int nMaxExtent, LPINT lpnFit, LPINT alpDx, LPSIZE lpSize) const + { + ATLASSERT(m_hDC != NULL); + return ::GetTextExtentExPointI(m_hDC, pgiIn, cgi, nMaxExtent, lpnFit, alpDx, lpSize); + } + + BOOL GetCharWidthI(UINT giFirst, UINT cgi, LPWORD pgi, LPINT lpBuffer) const + { + ATLASSERT(m_hDC != NULL); + return ::GetCharWidthI(m_hDC, giFirst, cgi, pgi, lpBuffer); + } + + BOOL GetCharABCWidthsI(UINT giFirst, UINT cgi, LPWORD pgi, LPABC lpabc) const + { + ATLASSERT(m_hDC != NULL); + return ::GetCharABCWidthsI(m_hDC, giFirst, cgi, pgi, lpabc); + } + + BOOL ColorCorrectPalette(HPALETTE hPalette, DWORD dwFirstEntry, DWORD dwNumOfEntries) + { + ATLASSERT(m_hDC != NULL); + return ::ColorCorrectPalette(m_hDC, hPalette, dwFirstEntry, dwNumOfEntries); + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CDC Helpers + +class CPaintDC : public CDC +{ +public: +// Data members + HWND m_hWnd; + PAINTSTRUCT m_ps; + +// Constructor/destructor + CPaintDC(HWND hWnd) + { + ATLASSERT(::IsWindow(hWnd)); + m_hWnd = hWnd; + m_hDC = ::BeginPaint(hWnd, &m_ps); + } + + ~CPaintDC() + { + ATLASSERT(m_hDC != NULL); + ATLASSERT(::IsWindow(m_hWnd)); + ::EndPaint(m_hWnd, &m_ps); + Detach(); + } +}; + +class CClientDC : public CDC +{ +public: +// Data members + HWND m_hWnd; + +// Constructor/destructor + CClientDC(HWND hWnd) + { + ATLASSERT((hWnd == NULL) || ::IsWindow(hWnd)); + m_hWnd = hWnd; + m_hDC = ::GetDC(hWnd); + } + + ~CClientDC() + { + ATLASSERT(m_hDC != NULL); + ::ReleaseDC(m_hWnd, Detach()); + } +}; + +class CWindowDC : public CDC +{ +public: +// Data members + HWND m_hWnd; + +// Constructor/destructor + CWindowDC(HWND hWnd) + { + ATLASSERT((hWnd == NULL) || ::IsWindow(hWnd)); + m_hWnd = hWnd; + m_hDC = ::GetWindowDC(hWnd); + } + + ~CWindowDC() + { + ATLASSERT(m_hDC != NULL); + ::ReleaseDC(m_hWnd, Detach()); + } +}; + +class CMemoryDC : public CDC +{ +public: +// Data members + HDC m_hDCOriginal; + RECT m_rcPaint; + CBitmap m_bmp; + HBITMAP m_hBmpOld; + +// Constructor/destructor + CMemoryDC(HDC hDC, const RECT& rcPaint) : m_hDCOriginal(hDC), m_hBmpOld(NULL) + { + m_rcPaint = rcPaint; + CreateCompatibleDC(m_hDCOriginal); + ATLASSERT(m_hDC != NULL); + m_bmp.CreateCompatibleBitmap(m_hDCOriginal, m_rcPaint.right - m_rcPaint.left, m_rcPaint.bottom - m_rcPaint.top); + ATLASSERT(m_bmp.m_hBitmap != NULL); + m_hBmpOld = SelectBitmap(m_bmp); + SetViewportOrg(-m_rcPaint.left, -m_rcPaint.top); + } + + ~CMemoryDC() + { + ::BitBlt(m_hDCOriginal, m_rcPaint.left, m_rcPaint.top, m_rcPaint.right - m_rcPaint.left, m_rcPaint.bottom - m_rcPaint.top, m_hDC, m_rcPaint.left, m_rcPaint.top, SRCCOPY); + SelectBitmap(m_hBmpOld); + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// Enhanced metafile support + +class CEnhMetaFileInfo +{ +public: +// Data members + HENHMETAFILE m_hEMF; + BYTE* m_pBits; + TCHAR* m_pDesc; + ENHMETAHEADER m_header; + PIXELFORMATDESCRIPTOR m_pfd; + +// Constructor/destructor + CEnhMetaFileInfo(HENHMETAFILE hEMF) : m_hEMF(hEMF), m_pBits(NULL), m_pDesc(NULL) + { } + + ~CEnhMetaFileInfo() + { + delete [] m_pBits; + delete [] m_pDesc; + } + +// Operations + BYTE* GetEnhMetaFileBits() + { + ATLASSERT(m_hEMF != NULL); + UINT nBytes = ::GetEnhMetaFileBits(m_hEMF, 0, NULL); + delete [] m_pBits; + m_pBits = NULL; + ATLTRY(m_pBits = new BYTE[nBytes]); + if (m_pBits != NULL) + ::GetEnhMetaFileBits(m_hEMF, nBytes, m_pBits); + return m_pBits; + } + + LPTSTR GetEnhMetaFileDescription() + { + ATLASSERT(m_hEMF != NULL); + UINT nLen = ::GetEnhMetaFileDescription(m_hEMF, 0, NULL); + delete [] m_pDesc; + m_pDesc = NULL; + ATLTRY(m_pDesc = new TCHAR[nLen]); + if (m_pDesc != NULL) + nLen = ::GetEnhMetaFileDescription(m_hEMF, nLen, m_pDesc); + return m_pDesc; + } + + ENHMETAHEADER* GetEnhMetaFileHeader() + { + ATLASSERT(m_hEMF != NULL); + memset(&m_header, 0, sizeof(m_header)); + m_header.iType = EMR_HEADER; + m_header.nSize = sizeof(ENHMETAHEADER); + UINT n = ::GetEnhMetaFileHeader(m_hEMF, sizeof(ENHMETAHEADER), &m_header); + return (n != 0) ? &m_header : NULL; + } + + PIXELFORMATDESCRIPTOR* GetEnhMetaFilePixelFormat() + { + ATLASSERT(m_hEMF != NULL); + memset(&m_pfd, 0, sizeof(m_pfd)); + UINT n = ::GetEnhMetaFilePixelFormat(m_hEMF, sizeof(m_pfd), &m_pfd); + return (n != 0) ? &m_pfd : NULL; + } +}; + + +template +class CEnhMetaFileT +{ +public: +// Data members + HENHMETAFILE m_hEMF; + +// Constructor/destructor + CEnhMetaFileT(HENHMETAFILE hEMF = NULL) : m_hEMF(hEMF) + { + } + + ~CEnhMetaFileT() + { + if(t_bManaged && (m_hEMF != NULL)) + DeleteObject(); + } + +// Operations + CEnhMetaFileT& operator =(HENHMETAFILE hEMF) + { + Attach(hEMF); + return *this; + } + + void Attach(HENHMETAFILE hEMF) + { + if(t_bManaged && (m_hEMF != NULL) && (m_hEMF != hEMF)) + DeleteObject(); + m_hEMF = hEMF; + } + + HENHMETAFILE Detach() + { + HENHMETAFILE hEMF = m_hEMF; + m_hEMF = NULL; + return hEMF; + } + + operator HENHMETAFILE() const { return m_hEMF; } + + bool IsNull() const { return (m_hEMF == NULL); } + + BOOL DeleteObject() + { + ATLASSERT(m_hEMF != NULL); + BOOL bRet = ::DeleteEnhMetaFile(m_hEMF); + m_hEMF = NULL; + return bRet; + } + + UINT GetEnhMetaFileBits(UINT cbBuffer, LPBYTE lpbBuffer) const + { + ATLASSERT(m_hEMF != NULL); + return ::GetEnhMetaFileBits(m_hEMF, cbBuffer, lpbBuffer); + } + + UINT GetEnhMetaFileDescription(UINT cchBuffer, LPTSTR lpszDescription) const + { + ATLASSERT(m_hEMF != NULL); + return ::GetEnhMetaFileDescription(m_hEMF, cchBuffer, lpszDescription); + } + + UINT GetEnhMetaFileHeader(LPENHMETAHEADER lpemh) const + { + ATLASSERT(m_hEMF != NULL); + lpemh->iType = EMR_HEADER; + lpemh->nSize = sizeof(ENHMETAHEADER); + return ::GetEnhMetaFileHeader(m_hEMF, sizeof(ENHMETAHEADER), lpemh); + } + + UINT GetEnhMetaFilePaletteEntries(UINT cEntries, LPPALETTEENTRY lppe) const + { + ATLASSERT(m_hEMF != NULL); + return ::GetEnhMetaFilePaletteEntries(m_hEMF, cEntries, lppe); + } + + UINT GetEnhMetaFilePixelFormat(DWORD cbBuffer, PIXELFORMATDESCRIPTOR* ppfd) const + { + ATLASSERT(m_hEMF != NULL); + return ::GetEnhMetaFilePixelFormat(m_hEMF, cbBuffer, ppfd); + } +}; + +typedef CEnhMetaFileT CEnhMetaFileHandle; +typedef CEnhMetaFileT CEnhMetaFile; + + +class CEnhMetaFileDC : public CDC +{ +public: +// Constructor/destructor + CEnhMetaFileDC() + { + } + + CEnhMetaFileDC(HDC hdc, LPCRECT lpRect) + { + Create(hdc, NULL, lpRect, NULL); + ATLASSERT(m_hDC != NULL); + } + + CEnhMetaFileDC(HDC hdcRef, LPCTSTR lpFilename, LPCRECT lpRect, LPCTSTR lpDescription) + { + Create(hdcRef, lpFilename, lpRect, lpDescription); + ATLASSERT(m_hDC != NULL); + } + + ~CEnhMetaFileDC() + { + HENHMETAFILE hEMF = Close(); + if (hEMF != NULL) + ::DeleteEnhMetaFile(hEMF); + } + +// Operations + void Create(HDC hdcRef, LPCTSTR lpFilename, LPCRECT lpRect, LPCTSTR lpDescription) + { + ATLASSERT(m_hDC == NULL); + m_hDC = ::CreateEnhMetaFile(hdcRef, lpFilename, lpRect, lpDescription); + } + + HENHMETAFILE Close() + { + HENHMETAFILE hEMF = NULL; + if (m_hDC != NULL) + { + hEMF = ::CloseEnhMetaFile(m_hDC); + m_hDC = NULL; + } + return hEMF; + } +}; + +} // namespace WTL + +#endif // __ATLGDI_H__ diff -r e9bb126753e7 -r 20d02a178406 foosdk/wtl/Include/atlmisc.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/wtl/Include/atlmisc.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,1348 @@ +// Windows Template Library - WTL version 10.0 +// Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. +// +// This file is a part of the Windows Template Library. +// The use and distribution terms for this software are covered by the +// Microsoft Public License (http://opensource.org/licenses/MS-PL) +// which can be found in the file MS-PL.txt at the root folder. + +#ifndef __ATLMISC_H__ +#define __ATLMISC_H__ + +#pragma once + +#ifndef __ATLAPP_H__ + #error atlmisc.h requires atlapp.h to be included first +#endif + +#ifndef _WTL_NO_COMPATIBILITY_INCLUDES + #include + #include +#endif // _WTL_NO_COMPATIBILITY_INCLUDES + + +/////////////////////////////////////////////////////////////////////////////// +// Classes in this file: +// +// CRecentDocumentListBase +// CRecentDocumentList +// CFindFile +// CRegProperty +// CRegPropertyImpl +// +// Global functions: +// AtlGetStockPen() +// AtlGetStockBrush() +// AtlGetStockFont() +// AtlGetStockPalette() +// +// AtlCompactPath() + + +namespace WTL +{ + +/////////////////////////////////////////////////////////////////////////////// +// CSize scalar operators + +#if !defined(_WTL_NO_SIZE_SCALAR) && defined(__ATLTYPES_H__) + +template +inline CSize operator *(SIZE s, Num n) +{ + return CSize((int)(s.cx * n), (int)(s.cy * n)); +}; + +template +inline void operator *=(SIZE & s, Num n) +{ + s = s * n; +}; + +template +inline CSize operator /(SIZE s, Num n) +{ + return CSize((int)(s.cx / n), (int)(s.cy / n)); +}; + +template +inline void operator /=(SIZE & s, Num n) +{ + s = s / n; +}; + +#endif // !defined(_WTL_NO_SIZE_SCALAR) && defined(__ATLTYPES_H__) + + +/////////////////////////////////////////////////////////////////////////////// +// CRecentDocumentList - MRU List Support + +#ifndef _WTL_MRUEMPTY_TEXT + #define _WTL_MRUEMPTY_TEXT _T("(empty)") +#endif + +// forward declaration +inline bool AtlCompactPath(LPTSTR lpstrOut, LPCTSTR lpstrIn, int cchLen); + +template +class CRecentDocumentListBase +{ +public: +// Declarations + struct _DocEntry + { + TCHAR szDocName[t_cchItemLen]; + bool operator ==(const _DocEntry& de) const + { return (lstrcmpi(szDocName, de.szDocName) == 0); } + }; + + enum + { + m_nMaxEntries_Min = 2, + m_nMaxEntries_Max = t_nLastID - t_nFirstID + 1, + m_cchMaxItemLen_Min = 6, + m_cchMaxItemLen_Max = t_cchItemLen, + m_cchItemNameLen = 11 + }; + +// Data members + ATL::CSimpleArray<_DocEntry> m_arrDocs; + int m_nMaxEntries; // default is 4 + HMENU m_hMenu; + + TCHAR m_szNoEntries[t_cchItemLen]; + + int m_cchMaxItemLen; + +// Constructor + CRecentDocumentListBase() : m_nMaxEntries(4), m_hMenu(NULL), m_cchMaxItemLen(-1) + { + // These ASSERTs verify values of the template arguments + ATLASSERT(t_cchItemLen > m_cchMaxItemLen_Min); + ATLASSERT(m_nMaxEntries_Max > m_nMaxEntries_Min); + } + +// Attributes + HMENU GetMenuHandle() const + { + return m_hMenu; + } + + void SetMenuHandle(HMENU hMenu) + { + ATLASSERT((hMenu == NULL) || ::IsMenu(hMenu)); + m_hMenu = hMenu; + if((m_hMenu == NULL) || (::GetMenuString(m_hMenu, t_nFirstID, m_szNoEntries, t_cchItemLen, MF_BYCOMMAND) == 0)) + { + T* pT = static_cast(this); + (void)pT; // avoid level 4 warning + ATL::Checked::tcsncpy_s(m_szNoEntries, _countof(m_szNoEntries), pT->GetMRUEmptyText(), _TRUNCATE); + } + } + + int GetMaxEntries() const + { + return m_nMaxEntries; + } + + void SetMaxEntries(int nMaxEntries) + { + ATLASSERT((nMaxEntries >= m_nMaxEntries_Min) && (nMaxEntries <= m_nMaxEntries_Max)); + if(nMaxEntries < m_nMaxEntries_Min) + nMaxEntries = m_nMaxEntries_Min; + else if(nMaxEntries > m_nMaxEntries_Max) + nMaxEntries = m_nMaxEntries_Max; + m_nMaxEntries = nMaxEntries; + } + + int GetMaxItemLength() const + { + return m_cchMaxItemLen; + } + + void SetMaxItemLength(int cchMaxLen) + { + ATLASSERT(((cchMaxLen >= m_cchMaxItemLen_Min) && (cchMaxLen <= m_cchMaxItemLen_Max)) || (cchMaxLen == -1)); + if(cchMaxLen != -1) + { + if(cchMaxLen < m_cchMaxItemLen_Min) + cchMaxLen = m_cchMaxItemLen_Min; + else if(cchMaxLen > m_cchMaxItemLen_Max) + cchMaxLen = m_cchMaxItemLen_Max; + } + m_cchMaxItemLen = cchMaxLen; + T* pT = static_cast(this); + pT->UpdateMenu(); + } + +// Operations + BOOL AddToList(LPCTSTR lpstrDocName) + { + _DocEntry de; + errno_t nRet = ATL::Checked::tcsncpy_s(de.szDocName, _countof(de.szDocName), lpstrDocName, _TRUNCATE); + if((nRet != 0) && (nRet != STRUNCATE)) + return FALSE; + + for(int i = 0; i < m_arrDocs.GetSize(); i++) + { + if(lstrcmpi(m_arrDocs[i].szDocName, lpstrDocName) == 0) + { + m_arrDocs.RemoveAt(i); + break; + } + } + + if(m_arrDocs.GetSize() == m_nMaxEntries) + m_arrDocs.RemoveAt(0); + + BOOL bRet = m_arrDocs.Add(de); + if(bRet) + { + T* pT = static_cast(this); + bRet = pT->UpdateMenu(); + } + return bRet; + } + + // This function is deprecated because it is not safe. + // Use the version below that accepts the buffer length. + __declspec(deprecated) + BOOL GetFromList(int /*nItemID*/, LPTSTR /*lpstrDocName*/) + { + ATLASSERT(FALSE); + return FALSE; + } + + BOOL GetFromList(int nItemID, LPTSTR lpstrDocName, int cchLength) + { + int nIndex = m_arrDocs.GetSize() - (nItemID - t_nFirstID) - 1; + if((nIndex < 0) || (nIndex >= m_arrDocs.GetSize())) + return FALSE; + if(lstrlen(m_arrDocs[nIndex].szDocName) >= cchLength) + return FALSE; + ATL::Checked::tcscpy_s(lpstrDocName, cchLength, m_arrDocs[nIndex].szDocName); + + return TRUE; + } + +#ifdef __ATLSTR_H__ + BOOL GetFromList(int nItemID, ATL::CString& strDocName) + { + int nIndex = m_arrDocs.GetSize() - (nItemID - t_nFirstID) - 1; + if((nIndex < 0) || (nIndex >= m_arrDocs.GetSize())) + return FALSE; + strDocName = m_arrDocs[nIndex].szDocName; + return TRUE; + } +#endif // __ATLSTR_H__ + + BOOL RemoveFromList(int nItemID) + { + int nIndex = m_arrDocs.GetSize() - (nItemID - t_nFirstID) - 1; + BOOL bRet = m_arrDocs.RemoveAt(nIndex); + if(bRet) + { + T* pT = static_cast(this); + bRet = pT->UpdateMenu(); + } + return bRet; + } + + BOOL MoveToTop(int nItemID) + { + int nIndex = m_arrDocs.GetSize() - (nItemID - t_nFirstID) - 1; + if((nIndex < 0) || (nIndex >= m_arrDocs.GetSize())) + return FALSE; + _DocEntry de; + de = m_arrDocs[nIndex]; + m_arrDocs.RemoveAt(nIndex); + BOOL bRet = m_arrDocs.Add(de); + if(bRet) + { + T* pT = static_cast(this); + bRet = pT->UpdateMenu(); + } + return bRet; + } + + BOOL ReadFromRegistry(LPCTSTR lpstrRegKey) + { + T* pT = static_cast(this); + ATL::CRegKey rkParent; + ATL::CRegKey rk; + + LONG lRet = rkParent.Open(HKEY_CURRENT_USER, lpstrRegKey); + if(lRet != ERROR_SUCCESS) + return FALSE; + lRet = rk.Open(rkParent, pT->GetRegKeyName()); + if(lRet != ERROR_SUCCESS) + return FALSE; + + DWORD dwRet = 0; + lRet = rk.QueryDWORDValue(pT->GetRegCountName(), dwRet); + if(lRet != ERROR_SUCCESS) + return FALSE; + SetMaxEntries(dwRet); + + m_arrDocs.RemoveAll(); + + TCHAR szRetString[t_cchItemLen] = {}; + _DocEntry de; + + for(int nItem = m_nMaxEntries; nItem > 0; nItem--) + { + TCHAR szBuff[m_cchItemNameLen] = {}; + _stprintf_s(szBuff, m_cchItemNameLen, pT->GetRegItemName(), nItem); + ULONG ulCount = t_cchItemLen; + lRet = rk.QueryStringValue(szBuff, szRetString, &ulCount); + if(lRet == ERROR_SUCCESS) + { + ATL::Checked::tcscpy_s(de.szDocName, _countof(de.szDocName), szRetString); + m_arrDocs.Add(de); + } + } + + rk.Close(); + rkParent.Close(); + + return pT->UpdateMenu(); + } + + BOOL WriteToRegistry(LPCTSTR lpstrRegKey) + { + T* pT = static_cast(this); + (void)pT; // avoid level 4 warning + ATL::CRegKey rkParent; + ATL::CRegKey rk; + + LONG lRet = rkParent.Create(HKEY_CURRENT_USER, lpstrRegKey); + if(lRet != ERROR_SUCCESS) + return FALSE; + lRet = rk.Create(rkParent, pT->GetRegKeyName()); + if(lRet != ERROR_SUCCESS) + return FALSE; + + lRet = rk.SetDWORDValue(pT->GetRegCountName(), m_nMaxEntries); + ATLASSERT(lRet == ERROR_SUCCESS); + + // set new values + int nItem; + for(nItem = m_arrDocs.GetSize(); nItem > 0; nItem--) + { + TCHAR szBuff[m_cchItemNameLen] = {}; + _stprintf_s(szBuff, m_cchItemNameLen, pT->GetRegItemName(), nItem); + TCHAR szDocName[t_cchItemLen] = {}; + GetFromList(t_nFirstID + nItem - 1, szDocName, t_cchItemLen); + lRet = rk.SetStringValue(szBuff, szDocName); + ATLASSERT(lRet == ERROR_SUCCESS); + } + + // delete unused keys + for(nItem = m_arrDocs.GetSize() + 1; nItem <= m_nMaxEntries_Max; nItem++) + { + TCHAR szBuff[m_cchItemNameLen] = {}; + _stprintf_s(szBuff, m_cchItemNameLen, pT->GetRegItemName(), nItem); + rk.DeleteValue(szBuff); + } + + rk.Close(); + rkParent.Close(); + + return TRUE; + } + +// Implementation + BOOL UpdateMenu() + { + if(m_hMenu == NULL) + return FALSE; + ATLASSERT(::IsMenu(m_hMenu)); + + int nItems = ::GetMenuItemCount(m_hMenu); + int nInsertPoint = 0; + for(int i = 0; i < nItems; i++) + { + CMenuItemInfo mi; + mi.fMask = MIIM_ID; + ::GetMenuItemInfo(m_hMenu, i, TRUE, &mi); + if (mi.wID == t_nFirstID) + { + nInsertPoint = i; + break; + } + } + + ATLASSERT((nInsertPoint < nItems) && "You need a menu item with an ID = t_nFirstID"); + + for(int j = t_nFirstID; j < (t_nFirstID + m_nMaxEntries); j++) + { + // keep the first one as an insertion point + if (j != t_nFirstID) + ::DeleteMenu(m_hMenu, j, MF_BYCOMMAND); + } + + TCHAR szItemText[t_cchItemLen + 6] = {}; // add space for &, 2 digits, and a space + int nSize = m_arrDocs.GetSize(); + int nItem = 0; + if(nSize > 0) + { + for(nItem = 0; nItem < nSize; nItem++) + { + if(m_cchMaxItemLen == -1) + { + _stprintf_s(szItemText, t_cchItemLen + 6, _T("&%i %s"), nItem + 1, m_arrDocs[nSize - 1 - nItem].szDocName); + } + else + { + TCHAR szBuff[t_cchItemLen] = {}; + T* pT = static_cast(this); + (void)pT; // avoid level 4 warning + bool bRet = pT->CompactDocumentName(szBuff, m_arrDocs[nSize - 1 - nItem].szDocName, m_cchMaxItemLen); + (void)bRet; // avoid level 4 warning + ATLASSERT(bRet); + _stprintf_s(szItemText, t_cchItemLen + 6, _T("&%i %s"), nItem + 1, szBuff); + } + + ::InsertMenu(m_hMenu, nInsertPoint + nItem, MF_BYPOSITION | MF_STRING, t_nFirstID + nItem, szItemText); + } + } + else // empty + { + ::InsertMenu(m_hMenu, nInsertPoint, MF_BYPOSITION | MF_STRING, t_nFirstID, m_szNoEntries); + ::EnableMenuItem(m_hMenu, t_nFirstID, MF_GRAYED); + nItem++; + } + ::DeleteMenu(m_hMenu, nInsertPoint + nItem, MF_BYPOSITION); + + return TRUE; + } + +// Overrideables + // override to provide a different method of compacting document names + static bool CompactDocumentName(LPTSTR lpstrOut, LPCTSTR lpstrIn, int cchLen) + { + return AtlCompactPath(lpstrOut, lpstrIn, cchLen); + } + + static LPCTSTR GetRegKeyName() + { + return _T("Recent Document List"); + } + + static LPCTSTR GetRegCountName() + { + return _T("DocumentCount"); + } + + static LPCTSTR GetRegItemName() + { + // Note: This string is a format string used with wsprintf(). + // Resulting formatted string must be m_cchItemNameLen or less + // characters long, including the terminating null character. + return _T("Document%i"); + } + + static LPCTSTR GetMRUEmptyText() + { + return _WTL_MRUEMPTY_TEXT; + } +}; + +class CRecentDocumentList : public CRecentDocumentListBase +{ +public: +// nothing here +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CFindFile - file search helper class + +class CFindFile +{ +public: +// Data members + HANDLE m_hFind; + WIN32_FIND_DATA m_fd; + LPTSTR m_lpszRoot; + const TCHAR m_chDirSeparator; + BOOL m_bFound; + +// Constructor/destructor + CFindFile() : m_hFind(NULL), m_lpszRoot(NULL), m_chDirSeparator(_T('\\')), m_bFound(FALSE) + { } + + ~CFindFile() + { + Close(); + } + +// Attributes + ULONGLONG GetFileSize() const + { + ATLASSERT(m_hFind != NULL); + + ULARGE_INTEGER nFileSize = {}; + if(m_bFound) + { + nFileSize.LowPart = m_fd.nFileSizeLow; + nFileSize.HighPart = m_fd.nFileSizeHigh; + } + else + { + nFileSize.QuadPart = 0; + } + + return nFileSize.QuadPart; + } + + BOOL GetFileName(LPTSTR lpstrFileName, int cchLength) const + { + ATLASSERT(m_hFind != NULL); + if(lstrlen(m_fd.cFileName) >= cchLength) + return FALSE; + + if(m_bFound) + ATL::Checked::tcscpy_s(lpstrFileName, cchLength, m_fd.cFileName); + + return m_bFound; + } + + BOOL GetFilePath(LPTSTR lpstrFilePath, int cchLength) const + { + ATLASSERT(m_hFind != NULL); + + int nLen = lstrlen(m_lpszRoot); + ATLASSERT(nLen > 0); + if(nLen == 0) + return FALSE; + + bool bAddSep = (m_lpszRoot[nLen - 1] != m_chDirSeparator); + + if((lstrlen(m_lpszRoot) + (bAddSep ? 1 : 0)) >= cchLength) + return FALSE; + + ATL::Checked::tcscpy_s(lpstrFilePath, cchLength, m_lpszRoot); + + if(bAddSep) + { + TCHAR szSeparator[2] = { m_chDirSeparator, 0 }; + ATL::Checked::tcscat_s(lpstrFilePath, cchLength, szSeparator); + } + + ATL::Checked::tcscat_s(lpstrFilePath, cchLength, m_fd.cFileName); + + return TRUE; + } + + BOOL GetFileTitle(LPTSTR lpstrFileTitle, int cchLength) const + { + ATLASSERT(m_hFind != NULL); + + TCHAR szBuff[MAX_PATH] = {}; + if(!GetFileName(szBuff, MAX_PATH)) + return FALSE; + + if((lstrlen(szBuff) >= cchLength) || (cchLength < 1)) + return FALSE; + + // find the last dot + LPTSTR pstrDot = _tcsrchr(szBuff, _T('.')); + if(pstrDot != NULL) + *pstrDot = 0; + + ATL::Checked::tcscpy_s(lpstrFileTitle, cchLength, szBuff); + + return TRUE; + } + + BOOL GetFileURL(LPTSTR lpstrFileURL, int cchLength) const + { + ATLASSERT(m_hFind != NULL); + + LPCTSTR lpstrFileURLPrefix = _T("file://"); + const int cchPrefix = lstrlen(lpstrFileURLPrefix); + if(cchPrefix >= cchLength) + return FALSE; + + ATL::Checked::tcscpy_s(lpstrFileURL, cchLength, lpstrFileURLPrefix); + + return GetFilePath(&lpstrFileURL[cchPrefix], cchLength - cchPrefix); + } + + BOOL GetRoot(LPTSTR lpstrRoot, int cchLength) const + { + ATLASSERT(m_hFind != NULL); + if(lstrlen(m_lpszRoot) >= cchLength) + return FALSE; + + ATL::Checked::tcscpy_s(lpstrRoot, cchLength, m_lpszRoot); + + return TRUE; + } + +#ifdef __ATLSTR_H__ + ATL::CString GetFileName() const + { + ATLASSERT(m_hFind != NULL); + + ATL::CString ret; + + if(m_bFound) + ret = m_fd.cFileName; + return ret; + } + + ATL::CString GetFilePath() const + { + ATLASSERT(m_hFind != NULL); + + ATL::CString strResult = m_lpszRoot; + int nLen = strResult.GetLength(); + ATLASSERT(nLen > 0); + if(nLen == 0) + return strResult; + + if(strResult[nLen - 1] != m_chDirSeparator) + strResult += m_chDirSeparator; + strResult += GetFileName(); + return strResult; + } + + ATL::CString GetFileTitle() const + { + ATLASSERT(m_hFind != NULL); + + ATL::CString strResult; + GetFileTitle(strResult.GetBuffer(MAX_PATH), MAX_PATH); + strResult.ReleaseBuffer(); + + return strResult; + } + + ATL::CString GetFileURL() const + { + ATLASSERT(m_hFind != NULL); + + ATL::CString strResult("file://"); + strResult += GetFilePath(); + return strResult; + } + + ATL::CString GetRoot() const + { + ATLASSERT(m_hFind != NULL); + + ATL::CString str = m_lpszRoot; + return str; + } +#endif // __ATLSTR_H__ + + BOOL GetLastWriteTime(FILETIME* pTimeStamp) const + { + ATLASSERT(m_hFind != NULL); + ATLASSERT(pTimeStamp != NULL); + + if(m_bFound && (pTimeStamp != NULL)) + { + *pTimeStamp = m_fd.ftLastWriteTime; + return TRUE; + } + + return FALSE; + } + + BOOL GetLastAccessTime(FILETIME* pTimeStamp) const + { + ATLASSERT(m_hFind != NULL); + ATLASSERT(pTimeStamp != NULL); + + if(m_bFound && (pTimeStamp != NULL)) + { + *pTimeStamp = m_fd.ftLastAccessTime; + return TRUE; + } + + return FALSE; + } + + BOOL GetCreationTime(FILETIME* pTimeStamp) const + { + ATLASSERT(m_hFind != NULL); + + if(m_bFound && (pTimeStamp != NULL)) + { + *pTimeStamp = m_fd.ftCreationTime; + return TRUE; + } + + return FALSE; + } + + BOOL MatchesMask(DWORD dwMask) const + { + ATLASSERT(m_hFind != NULL); + + if(m_bFound) + return ((m_fd.dwFileAttributes & dwMask) != 0); + + return FALSE; + } + + BOOL IsDots() const + { + ATLASSERT(m_hFind != NULL); + + // return TRUE if the file name is "." or ".." and + // the file is a directory + + BOOL bResult = FALSE; + if(m_bFound && IsDirectory()) + { + if((m_fd.cFileName[0] == _T('.')) && ((m_fd.cFileName[1] == _T('\0')) || ((m_fd.cFileName[1] == _T('.')) && (m_fd.cFileName[2] == _T('\0'))))) + bResult = TRUE; + } + + return bResult; + } + + BOOL IsReadOnly() const + { + return MatchesMask(FILE_ATTRIBUTE_READONLY); + } + + BOOL IsDirectory() const + { + return MatchesMask(FILE_ATTRIBUTE_DIRECTORY); + } + + BOOL IsCompressed() const + { + return MatchesMask(FILE_ATTRIBUTE_COMPRESSED); + } + + BOOL IsSystem() const + { + return MatchesMask(FILE_ATTRIBUTE_SYSTEM); + } + + BOOL IsHidden() const + { + return MatchesMask(FILE_ATTRIBUTE_HIDDEN); + } + + BOOL IsTemporary() const + { + return MatchesMask(FILE_ATTRIBUTE_TEMPORARY); + } + + BOOL IsNormal() const + { + return MatchesMask(FILE_ATTRIBUTE_NORMAL); + } + + BOOL IsArchived() const + { + return MatchesMask(FILE_ATTRIBUTE_ARCHIVE); + } + +// Operations + BOOL FindFile(LPCTSTR pstrName = NULL, bool bAutoLongPath = false) + { + Close(); + + if(pstrName == NULL) + pstrName = _T("*.*"); + + if(bAutoLongPath && (lstrlen(pstrName) >= MAX_PATH)) + { + LPCTSTR lpstrPrefix = _T("\\\\?\\"); + int cchLongPath = lstrlen(lpstrPrefix) + lstrlen(pstrName) + 1; + ATL::CTempBuffer buff; + LPTSTR lpstrLongPath = buff.Allocate(cchLongPath); + if(lpstrLongPath != NULL) + { + ATL::Checked::tcscpy_s(lpstrLongPath, cchLongPath, lpstrPrefix); + ATL::Checked::tcscat_s(lpstrLongPath, cchLongPath, pstrName); + m_hFind = ::FindFirstFile(lpstrLongPath, &m_fd); + } + } + else + { + m_hFind = ::FindFirstFile(pstrName, &m_fd); + } + + if(m_hFind == INVALID_HANDLE_VALUE) + return FALSE; + + int cchRoot = ::GetFullPathName(pstrName, 0, NULL, NULL); + if(cchRoot > 0) + ATLTRY(m_lpszRoot = new TCHAR[cchRoot]); + if(m_lpszRoot == NULL) + return FALSE; + + bool bFullPath = (::GetFullPathName(pstrName, cchRoot, m_lpszRoot, NULL) != 0); + + // passed name isn't a valid path but was found by the API + ATLASSERT(bFullPath); + if(!bFullPath) + { + Close(); + ::SetLastError(ERROR_INVALID_NAME); + return FALSE; + } + else + { + // find the last separator + LPTSTR pstrSep = _tcsrchr(m_lpszRoot, m_chDirSeparator); + if(pstrSep != NULL) + *pstrSep = _T('\0'); + } + + m_bFound = TRUE; + + return TRUE; + } + + BOOL FindNextFile() + { + ATLASSERT(m_hFind != NULL); + + if(m_hFind == NULL) + return FALSE; + + if(!m_bFound) + return FALSE; + + m_bFound = ::FindNextFile(m_hFind, &m_fd); + + return m_bFound; + } + + void Close() + { + m_bFound = FALSE; + + delete [] m_lpszRoot; + m_lpszRoot = NULL; + + if((m_hFind != NULL) && (m_hFind != INVALID_HANDLE_VALUE)) + { + ::FindClose(m_hFind); + m_hFind = NULL; + } + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CRegProperty and CRegPropertyImpl<> - properties stored in registry + +// How to use: Derive a class from CRegPropertyImpl, add data members +// for properties, and add REGPROP map to map properties to registry value names. +// You can then call Read() and Write() methods to read and write properties to/from registry. +// You can also use CRegProperty class directly, for one time read/write, or for custom stuff. + +#define REGPROP_CURRENTUSER 0x0000 +#define REGPROP_LOCALMACHINE 0x0001 +#define REGPROP_READONLY 0x0002 +#define REGPROP_WRITEONLY 0x0004 + +class CRegProperty +{ +public: +// Type declarations + struct BinaryProp + { + void* pBinary; + ULONG uSize; // buffer size in bytes, used size after read + + BinaryProp() : pBinary(NULL), uSize(0U) + { } + }; + + struct CharArrayProp + { + LPTSTR lpstrText; + ULONG uSize; // buffer size in chars + + CharArrayProp() : lpstrText(NULL), uSize(0U) + { } + }; + +// Data members + ATL::CRegKey m_regkey; + WORD m_wFlags; + +// Constructor + CRegProperty() : m_wFlags(REGPROP_CURRENTUSER) + { } + +// Registry key methods + LSTATUS OpenRegKey(LPCTSTR lpstrRegKey, bool bWrite) + { + ATLASSERT(m_regkey.m_hKey == NULL); + + HKEY hKey = ((m_wFlags & REGPROP_LOCALMACHINE) != 0) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; + REGSAM sam = KEY_READ | KEY_WRITE; + LSTATUS lRet = -1; + if(bWrite) + lRet = m_regkey.Create(hKey, lpstrRegKey, NULL, 0, ((m_wFlags & REGPROP_WRITEONLY) != 0) ? KEY_WRITE : sam); + else + lRet = m_regkey.Open(hKey, lpstrRegKey, ((m_wFlags & REGPROP_READONLY) != 0) ? KEY_READ : sam); + + return lRet; + } + + void CloseRegKey() + { + LSTATUS lRet = m_regkey.Close(); + (void)lRet; // avoid level 4 warning + ATLASSERT(lRet == ERROR_SUCCESS); + } + +// Flag methods + WORD GetFlags() const + { + return m_wFlags; + } + + WORD SetFlags(WORD wFlags, WORD wMask = 0) + { + WORD wPrevFlags = m_wFlags; + if(wMask == 0) + m_wFlags = wFlags; + else + m_wFlags = (m_wFlags & ~wMask) | (wFlags & wMask); + + return wPrevFlags; + } + +// Generic read/write methods + template + LSTATUS ReadProp(LPCTSTR lpstrRegValue, TProp& prop) + { + ATLASSERT(m_regkey.m_hKey != NULL); + + DWORD dwRet = 0; + LSTATUS lRet = m_regkey.QueryDWORDValue(lpstrRegValue, dwRet); + if(lRet == ERROR_SUCCESS) + prop = static_cast(dwRet); + + return lRet; + } + + template + LSTATUS WriteProp(LPCTSTR lpstrRegValue, TProp& prop) + { + ATLASSERT(m_regkey.m_hKey != NULL); + + return m_regkey.SetDWORDValue(lpstrRegValue, (DWORD)prop); + } + +// Specialization for bool + template <> + LSTATUS ReadProp(LPCTSTR lpstrRegValue, bool& bProp) + { + ATLASSERT(m_regkey.m_hKey != NULL); + + DWORD dwRet = 0; + LSTATUS lRet = m_regkey.QueryDWORDValue(lpstrRegValue, dwRet); + if(lRet == ERROR_SUCCESS) + bProp = (dwRet != 0); + + return lRet; + } + + template <> + LSTATUS WriteProp(LPCTSTR lpstrRegValue, bool& bProp) + { + ATLASSERT(m_regkey.m_hKey != NULL); + + return m_regkey.SetDWORDValue(lpstrRegValue, bProp ? 1 : 0); + } + +// Specialization for HFONT + template <> + LSTATUS ReadProp(LPCTSTR lpstrRegValue, HFONT& hFont) + { + ATLASSERT(m_regkey.m_hKey != NULL); + + LOGFONT lf = {}; + ULONG uSize = sizeof(lf); + LSTATUS lRet = m_regkey.QueryBinaryValue(lpstrRegValue, &lf, &uSize); + if(lRet == ERROR_SUCCESS) + { + if(hFont != NULL) + ::DeleteObject(hFont); + + hFont = ::CreateFontIndirect(&lf); + if(hFont == NULL) + lRet = ERROR_INVALID_DATA; + } + + return lRet; + } + + template <> + LSTATUS WriteProp(LPCTSTR lpstrRegValue, HFONT& hFont) + { + ATLASSERT(m_regkey.m_hKey != NULL); + + CLogFont lf(hFont); + return m_regkey.SetBinaryValue(lpstrRegValue, &lf, sizeof(lf)); + } + +// Specialization for BinaryProp + template <> + LSTATUS ReadProp(LPCTSTR lpstrRegValue, BinaryProp& binProp) + { + ATLASSERT(m_regkey.m_hKey != NULL); + + ULONG uSize = 0U; + LSTATUS lRet = m_regkey.QueryBinaryValue(lpstrRegValue, NULL, &uSize); + if(lRet == ERROR_SUCCESS) + { + if(uSize <= binProp.uSize) + lRet = m_regkey.QueryBinaryValue(lpstrRegValue, binProp.pBinary, &binProp.uSize); + else + lRet = ERROR_OUTOFMEMORY; + } + + return lRet; + } + + template <> + LSTATUS WriteProp(LPCTSTR lpstrRegValue, BinaryProp& binProp) + { + ATLASSERT(m_regkey.m_hKey != NULL); + + return m_regkey.SetBinaryValue(lpstrRegValue, binProp.pBinary, binProp.uSize); + } + +// Specialization for CharArrayProp + template <> + LSTATUS ReadProp(LPCTSTR lpstrRegValue, CharArrayProp& caProp) + { + ATLASSERT(m_regkey.m_hKey != NULL); + + ULONG uSize = 0U; + LSTATUS lRet = m_regkey.QueryStringValue(lpstrRegValue, NULL, &uSize); + if(lRet == ERROR_SUCCESS) + { + if(uSize <= caProp.uSize) + lRet = m_regkey.QueryStringValue(lpstrRegValue, caProp.lpstrText, &caProp.uSize); + else + lRet = ERROR_OUTOFMEMORY; + } + + return lRet; + } + + template <> + LSTATUS WriteProp(LPCTSTR lpstrRegValue, CharArrayProp& caProp) + { + ATLASSERT(m_regkey.m_hKey != NULL); + + return m_regkey.SetStringValue(lpstrRegValue, caProp.lpstrText); + } + +// Specialization for CString +#ifdef __ATLSTR_H__ + template <> + LSTATUS ReadProp(LPCTSTR lpstrRegValue, ATL::CString& strProp) + { + ATLASSERT(m_regkey.m_hKey != NULL); + + ULONG uSize = 0U; + LSTATUS lRet = m_regkey.QueryStringValue(lpstrRegValue, NULL, &uSize); + if(lRet == ERROR_SUCCESS) + { + lRet = m_regkey.QueryStringValue(lpstrRegValue, strProp.GetBufferSetLength(uSize), &uSize); + strProp.ReleaseBuffer(); + } + + return lRet; + } + + template <> + LSTATUS WriteProp(LPCTSTR lpstrRegValue, ATL::CString& strProp) + { + ATLASSERT(m_regkey.m_hKey != NULL); + + return m_regkey.SetStringValue(lpstrRegValue, (LPCTSTR)strProp); + } +#endif // __ATLSTR_H__ + +// Static methods for one time read/write + template + static bool ReadOne(LPCTSTR lpstrRegKey, LPCTSTR lpstrRegValue, TProp& prop, WORD wFlags = REGPROP_CURRENTUSER) + { + CRegProperty rp; + rp.SetFlags(wFlags); + LSTATUS lRet = rp.OpenRegKey(lpstrRegKey, false); + if(lRet == ERROR_SUCCESS) + { + lRet = rp.ReadProp(lpstrRegValue, prop); + rp.CloseRegKey(); + } + + return (lRet == ERROR_SUCCESS) || (lRet == ERROR_FILE_NOT_FOUND); + } + + template + static bool WriteOne(LPCTSTR lpstrRegKey, LPCTSTR lpstrRegValue, TProp& prop, WORD wFlags = REGPROP_CURRENTUSER) + { + CRegProperty rp; + rp.SetFlags(wFlags); + LSTATUS lRet = rp.OpenRegKey(lpstrRegKey, true); + if(lRet == ERROR_SUCCESS) + { + lRet = rp.WriteProp(lpstrRegValue, prop); + rp.CloseRegKey(); + } + + return (lRet == ERROR_SUCCESS); + } +}; + + +#define BEGIN_REGPROP_MAP(class) \ + void ReadWriteAll(bool bWrite) \ + { + +#define REG_PROPERTY(name, prop) \ + this->ReadWriteProp(name, prop, bWrite); + +#define END_REGPROP_MAP() \ + } + +template +class CRegPropertyImpl : public CRegProperty +{ +public: +// Methods + void Read(LPCTSTR lpstrRegKey) + { + T* pT = static_cast(this); + LSTATUS lRet = pT->OpenRegKey(lpstrRegKey, false); + if(lRet == ERROR_SUCCESS) + { + pT->ReadWriteAll(false); + pT->OnRead(lpstrRegKey); + + pT->CloseRegKey(); + } + else if(lRet != ERROR_FILE_NOT_FOUND) + { + pT->OnReadError(NULL, lRet); + } + } + + void Write(LPCTSTR lpstrRegKey) + { + T* pT = static_cast(this); + LSTATUS lRet = pT->OpenRegKey(lpstrRegKey, true); + if(lRet == ERROR_SUCCESS) + { + pT->ReadWriteAll(true); + pT->OnWrite(lpstrRegKey); + + pT->CloseRegKey(); + } + else + { + pT->OnWriteError(NULL, lRet); + } + } + +// Implementation + template + void ReadWriteProp(LPCTSTR lpstrRegValue, TProp& prop, bool bWrite) + { + T* pT = static_cast(this); + if(bWrite) + { + LSTATUS lRet = pT->WriteProp(lpstrRegValue, prop); + if(lRet != ERROR_SUCCESS) + pT->OnWriteError(lpstrRegValue, lRet); + } + else + { + LSTATUS lRet = pT->ReadProp(lpstrRegValue, prop); + if((lRet != ERROR_SUCCESS) && (lRet != ERROR_FILE_NOT_FOUND)) + pT->OnReadError(lpstrRegValue, lRet); + } + } + +// Overrideable handlers + void OnRead(LPCTSTR /*lpstrRegValue*/) + { } + + void OnWrite(LPCTSTR /*lpstrRegValue*/) + { } + + void OnReadError(LPCTSTR /*lpstrRegValue*/, LSTATUS /*lError*/) + { + ATLASSERT(FALSE); + } + + void OnWriteError(LPCTSTR /*lpstrRegValue*/, LSTATUS /*lError*/) + { + ATLASSERT(FALSE); + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// Global functions for stock GDI objects + +inline HPEN AtlGetStockPen(int nPen) +{ + ATLASSERT((nPen == WHITE_PEN) || (nPen == BLACK_PEN) || (nPen == NULL_PEN) || (nPen == DC_PEN)); + return (HPEN)::GetStockObject(nPen); +} + +inline HBRUSH AtlGetStockBrush(int nBrush) +{ + ATLASSERT(((nBrush >= WHITE_BRUSH) && (nBrush <= HOLLOW_BRUSH)) || (nBrush == DC_BRUSH)); + return (HBRUSH)::GetStockObject(nBrush); +} + +inline HFONT AtlGetStockFont(int nFont) +{ + ATLASSERT(((nFont >= OEM_FIXED_FONT) && (nFont <= SYSTEM_FIXED_FONT)) || (nFont == DEFAULT_GUI_FONT)); + return (HFONT)::GetStockObject(nFont); +} + +inline HPALETTE AtlGetStockPalette(int nPalette) +{ + ATLASSERT(nPalette == DEFAULT_PALETTE); // the only one supported + return (HPALETTE)::GetStockObject(nPalette); +} + + +/////////////////////////////////////////////////////////////////////////////// +// Global function for compacting a path by replacing parts with ellipsis + +// helper for multi-byte character sets +inline bool _IsDBCSTrailByte(LPCTSTR lpstr, int nChar) +{ +#ifndef _UNICODE + int i = nChar; + for( ; i > 0; i--) + { + if(!::IsDBCSLeadByte(lpstr[i - 1])) + break; + } + return ((nChar > 0) && (((nChar - i) & 1) != 0)); +#else // _UNICODE + (void)lpstr; // avoid level 4 warning + (void)nChar; // avoid level 4 warning + return false; +#endif // _UNICODE +} + +inline bool AtlCompactPath(LPTSTR lpstrOut, LPCTSTR lpstrIn, int cchLen) +{ + ATLASSERT(lpstrOut != NULL); + ATLASSERT(lpstrIn != NULL); + ATLASSERT(cchLen > 0); + + LPCTSTR szEllipsis = _T("..."); + const int cchEndEllipsis = 3; + const int cchMidEllipsis = 4; + + if(lstrlen(lpstrIn) < cchLen) + { + ATL::Checked::tcscpy_s(lpstrOut, cchLen, lpstrIn); + return true; + } + + lpstrOut[0] = 0; + + // check if the separator is a slash or a backslash + TCHAR chSlash = _T('\\'); + for(LPTSTR lpstr = (LPTSTR)lpstrIn; *lpstr != 0; lpstr = ::CharNext(lpstr)) + { + if((*lpstr == _T('/')) || (*lpstr == _T('\\'))) + chSlash = *lpstr; + } + + // find the filename portion of the path + LPCTSTR lpstrFileName = lpstrIn; + for(LPCTSTR pPath = lpstrIn; *pPath; pPath = ::CharNext(pPath)) + { + if(((pPath[0] == _T('\\')) || (pPath[0] == _T(':')) || (pPath[0] == _T('/'))) + && pPath[1] && (pPath[1] != _T('\\')) && (pPath[1] != _T('/'))) + lpstrFileName = pPath + 1; + } + int cchFileName = lstrlen(lpstrFileName); + + // handle just the filename without a path + if((lpstrFileName == lpstrIn) && (cchLen > cchEndEllipsis)) + { + bool bRet = (ATL::Checked::tcsncpy_s(lpstrOut, cchLen, lpstrIn, cchLen - cchEndEllipsis - 1) == 0); + if(bRet) + { +#ifndef _UNICODE + if(_IsDBCSTrailByte(lpstrIn, cchLen - cchEndEllipsis)) + lpstrOut[cchLen - cchEndEllipsis - 1] = 0; +#endif // _UNICODE + ATL::Checked::tcscat_s(lpstrOut, cchLen, szEllipsis); + } + return bRet; + } + + // handle just ellipsis + if((cchLen < (cchMidEllipsis + cchEndEllipsis))) + { + for(int i = 0; i < cchLen - 1; i++) + lpstrOut[i] = ((i + 1) == cchMidEllipsis) ? chSlash : _T('.'); + lpstrOut[cchLen - 1] = 0; + return true; + } + + // calc how much we have to copy + int cchToCopy = cchLen - (cchMidEllipsis + cchFileName) - 1; + + if(cchToCopy < 0) + cchToCopy = 0; + +#ifndef _UNICODE + if((cchToCopy > 0) && _IsDBCSTrailByte(lpstrIn, cchToCopy)) + cchToCopy--; +#endif // _UNICODE + + bool bRet = (ATL::Checked::tcsncpy_s(lpstrOut, cchLen, lpstrIn, cchToCopy) == 0); + if(!bRet) + return false; + + // add ellipsis + ATL::Checked::tcscat_s(lpstrOut, cchLen, szEllipsis); + TCHAR szSlash[2] = { chSlash, 0 }; + ATL::Checked::tcscat_s(lpstrOut, cchLen, szSlash); + + // add filename (and ellipsis, if needed) + if(cchLen > (cchMidEllipsis + cchFileName)) + { + ATL::Checked::tcscat_s(lpstrOut, cchLen, lpstrFileName); + } + else + { + cchToCopy = cchLen - cchMidEllipsis - cchEndEllipsis - 1; +#ifndef _UNICODE + if((cchToCopy > 0) && _IsDBCSTrailByte(lpstrFileName, cchToCopy)) + cchToCopy--; +#endif // _UNICODE + bRet = (ATL::Checked::tcsncpy_s(&lpstrOut[cchMidEllipsis], cchLen - cchMidEllipsis, lpstrFileName, cchToCopy) == 0); + if(bRet) + ATL::Checked::tcscat_s(lpstrOut, cchLen, szEllipsis); + } + + return bRet; +} + +} // namespace WTL + +#endif // __ATLMISC_H__ diff -r e9bb126753e7 -r 20d02a178406 foosdk/wtl/Include/atlprint.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/wtl/Include/atlprint.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,1103 @@ +// Windows Template Library - WTL version 10.0 +// Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. +// +// This file is a part of the Windows Template Library. +// The use and distribution terms for this software are covered by the +// Microsoft Public License (http://opensource.org/licenses/MS-PL) +// which can be found in the file MS-PL.txt at the root folder. + +#ifndef __ATLPRINT_H__ +#define __ATLPRINT_H__ + +#pragma once + +#ifndef __ATLAPP_H__ + #error atlprint.h requires atlapp.h to be included first +#endif + +#ifndef __ATLWIN_H__ + #error atlprint.h requires atlwin.h to be included first +#endif + +#include + + +/////////////////////////////////////////////////////////////////////////////// +// Classes in this file: +// +// CPrinterInfo +// CPrinterT +// CDevModeT +// CPrinterDC +// CPrintJobInfo +// CPrintJob +// CPrintPreview +// CPrintPreviewWindowImpl +// CPrintPreviewWindow +// CZoomPrintPreviewWindowImpl +// CZoomPrintPreviewWindow + +namespace WTL +{ + +/////////////////////////////////////////////////////////////////////////////// +// CPrinterInfo - This class wraps all of the PRINTER_INFO_* structures +// and provided by ::GetPrinter. + +template +class _printer_info +{ +public: + typedef void infotype; +}; + +template <> class _printer_info<1> { public: typedef PRINTER_INFO_1 infotype; }; +template <> class _printer_info<2> { public: typedef PRINTER_INFO_2 infotype; }; +template <> class _printer_info<3> { public: typedef PRINTER_INFO_3 infotype; }; +template <> class _printer_info<4> { public: typedef PRINTER_INFO_4 infotype; }; +template <> class _printer_info<5> { public: typedef PRINTER_INFO_5 infotype; }; +template <> class _printer_info<6> { public: typedef PRINTER_INFO_6 infotype; }; +template <> class _printer_info<7> { public: typedef PRINTER_INFO_7 infotype; }; +template <> class _printer_info<8> { public: typedef PRINTER_INFO_8 infotype; }; +template <> class _printer_info<9> { public: typedef PRINTER_INFO_9 infotype; }; + + +template +class CPrinterInfo +{ +public: +// Data members + typename _printer_info::infotype* m_pi; + +// Constructor/destructor + CPrinterInfo() : m_pi(NULL) + { } + + CPrinterInfo(HANDLE hPrinter) : m_pi(NULL) + { + GetPrinterInfo(hPrinter); + } + + ~CPrinterInfo() + { + Cleanup(); + } + +// Operations + bool GetPrinterInfo(HANDLE hPrinter) + { + Cleanup(); + return GetPrinterInfoHelper(hPrinter, (BYTE**)&m_pi, t_nInfo); + } + +// Implementation + void Cleanup() + { + delete [] (BYTE*)m_pi; + m_pi = NULL; + } + + static bool GetPrinterInfoHelper(HANDLE hPrinter, BYTE** pi, int nIndex) + { + ATLASSERT(pi != NULL); + DWORD dw = 0; + BYTE* pb = NULL; + ::GetPrinter(hPrinter, nIndex, NULL, 0, &dw); + if (dw > 0) + { + ATLTRY(pb = new BYTE[dw]); + if (pb != NULL) + { + memset(pb, 0, dw); + DWORD dwNew; + if (!::GetPrinter(hPrinter, nIndex, pb, dw, &dwNew)) + { + delete [] pb; + pb = NULL; + } + } + } + *pi = pb; + return (pb != NULL); + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CPrinter - Wrapper class for a HANDLE to a printer + +template +class CPrinterT +{ +public: +// Data members + HANDLE m_hPrinter; + +// Constructor/destructor + CPrinterT(HANDLE hPrinter = NULL) : m_hPrinter(hPrinter) + { } + + ~CPrinterT() + { + ClosePrinter(); + } + +// Operations + CPrinterT& operator =(HANDLE hPrinter) + { + if (hPrinter != m_hPrinter) + { + ClosePrinter(); + m_hPrinter = hPrinter; + } + return *this; + } + + bool IsNull() const { return (m_hPrinter == NULL); } + + bool OpenPrinter(HANDLE hDevNames, const DEVMODE* pDevMode = NULL) + { + bool b = false; + DEVNAMES* pdn = (DEVNAMES*)::GlobalLock(hDevNames); + if (pdn != NULL) + { + LPTSTR lpszPrinterName = (LPTSTR)pdn + pdn->wDeviceOffset; + b = OpenPrinter(lpszPrinterName, pDevMode); + ::GlobalUnlock(hDevNames); + } + return b; + } + + bool OpenPrinter(LPCTSTR lpszPrinterName, const DEVMODE* pDevMode = NULL) + { + ClosePrinter(); + PRINTER_DEFAULTS pdefs = { NULL, (DEVMODE*)pDevMode, PRINTER_ACCESS_USE }; + ::OpenPrinter((LPTSTR) lpszPrinterName, &m_hPrinter, (pDevMode == NULL) ? NULL : &pdefs); + + return (m_hPrinter != NULL); + } + + bool OpenPrinter(LPCTSTR lpszPrinterName, PRINTER_DEFAULTS* pprintdefs) + { + ClosePrinter(); + ::OpenPrinter((LPTSTR) lpszPrinterName, &m_hPrinter, pprintdefs); + return (m_hPrinter != NULL); + } + + bool OpenDefaultPrinter(const DEVMODE* pDevMode = NULL) + { + ClosePrinter(); + + DWORD cchBuff = 0; + ::GetDefaultPrinter(NULL, &cchBuff); + TCHAR* pszBuff = new TCHAR[cchBuff]; + BOOL bRet = ::GetDefaultPrinter(pszBuff, &cchBuff); + if(bRet != FALSE) + { + PRINTER_DEFAULTS pdefs = { NULL, (DEVMODE*)pDevMode, PRINTER_ACCESS_USE }; + ::OpenPrinter(pszBuff, &m_hPrinter, (pDevMode == NULL) ? NULL : &pdefs); + } + delete [] pszBuff; + + return m_hPrinter != NULL; + } + + void ClosePrinter() + { + if (m_hPrinter != NULL) + { + if (t_bManaged) + ::ClosePrinter(m_hPrinter); + m_hPrinter = NULL; + } + } + + bool PrinterProperties(HWND hWnd = NULL) + { + if (hWnd == NULL) + hWnd = ::GetActiveWindow(); + return !!::PrinterProperties(hWnd, m_hPrinter); + } + + HANDLE CopyToHDEVNAMES() const + { + HANDLE hDevNames = NULL; + CPrinterInfo<5> pinfon5; + CPrinterInfo<2> pinfon2; + LPTSTR lpszPrinterName = NULL; + LPTSTR lpszPortName = NULL; + // Some printers fail for PRINTER_INFO_5 in some situations + if(pinfon5.GetPrinterInfo(m_hPrinter)) + { + lpszPrinterName = pinfon5.m_pi->pPrinterName; + lpszPortName = pinfon5.m_pi->pPortName; + } + else if(pinfon2.GetPrinterInfo(m_hPrinter)) + { + lpszPrinterName = pinfon2.m_pi->pPrinterName; + lpszPortName = pinfon2.m_pi->pPortName; + } + + if(lpszPrinterName != NULL) + { + int nLen = sizeof(DEVNAMES) + (lstrlen(lpszPrinterName) + 1 + lstrlen(lpszPortName) + 1) * sizeof(TCHAR); + hDevNames = ::GlobalAlloc(GMEM_MOVEABLE, nLen); + BYTE* pv = (BYTE*)::GlobalLock(hDevNames); + DEVNAMES* pdev = (DEVNAMES*)pv; + if(pv != NULL) + { + memset(pv, 0, nLen); + pdev->wDeviceOffset = sizeof(DEVNAMES); + pv = pv + sizeof(DEVNAMES); // now points to end + ATL::Checked::tcscpy_s((LPTSTR)pv, lstrlen(lpszPrinterName) + 1, lpszPrinterName); + pdev->wOutputOffset = (WORD)(sizeof(DEVNAMES) + (lstrlen(lpszPrinterName) + 1) * sizeof(TCHAR)); + pv = pv + (lstrlen(lpszPrinterName) + 1) * sizeof(TCHAR); + ATL::Checked::tcscpy_s((LPTSTR)pv, lstrlen(lpszPortName) + 1, lpszPortName); + ::GlobalUnlock(hDevNames); + } + } + + return hDevNames; + } + + HDC CreatePrinterDC(const DEVMODE* pdm = NULL) const + { + CPrinterInfo<5> pinfo5; + CPrinterInfo<2> pinfo2; + HDC hDC = NULL; + LPTSTR lpszPrinterName = NULL; + // Some printers fail for PRINTER_INFO_5 in some situations + if (pinfo5.GetPrinterInfo(m_hPrinter)) + lpszPrinterName = pinfo5.m_pi->pPrinterName; + else if (pinfo2.GetPrinterInfo(m_hPrinter)) + lpszPrinterName = pinfo2.m_pi->pPrinterName; + if (lpszPrinterName != NULL) + hDC = ::CreateDC(NULL, lpszPrinterName, NULL, pdm); + return hDC; + } + + HDC CreatePrinterIC(const DEVMODE* pdm = NULL) const + { + CPrinterInfo<5> pinfo5; + CPrinterInfo<2> pinfo2; + HDC hDC = NULL; + LPTSTR lpszPrinterName = NULL; + // Some printers fail for PRINTER_INFO_5 in some situations + if (pinfo5.GetPrinterInfo(m_hPrinter)) + lpszPrinterName = pinfo5.m_pi->pPrinterName; + else if (pinfo2.GetPrinterInfo(m_hPrinter)) + lpszPrinterName = pinfo2.m_pi->pPrinterName; + if (lpszPrinterName != NULL) + hDC = ::CreateIC(NULL, lpszPrinterName, NULL, pdm); + return hDC; + } + + void Attach(HANDLE hPrinter) + { + ClosePrinter(); + m_hPrinter = hPrinter; + } + + HANDLE Detach() + { + HANDLE hPrinter = m_hPrinter; + m_hPrinter = NULL; + return hPrinter; + } + + operator HANDLE() const { return m_hPrinter; } +}; + +typedef CPrinterT CPrinterHandle; +typedef CPrinterT CPrinter; + + +/////////////////////////////////////////////////////////////////////////////// +// CDevMode - Wrapper class for DEVMODE + +template +class CDevModeT +{ +public: +// Data members + HANDLE m_hDevMode; + DEVMODE* m_pDevMode; + +// Constructor/destructor + CDevModeT(HANDLE hDevMode = NULL) : m_hDevMode(hDevMode) + { + m_pDevMode = (m_hDevMode != NULL) ? (DEVMODE*)::GlobalLock(m_hDevMode) : NULL; + } + + ~CDevModeT() + { + Cleanup(); + } + +// Operations + CDevModeT& operator =(HANDLE hDevMode) + { + Attach(hDevMode); + return *this; + } + + void Attach(HANDLE hDevModeNew) + { + Cleanup(); + m_hDevMode = hDevModeNew; + m_pDevMode = (m_hDevMode != NULL) ? (DEVMODE*)::GlobalLock(m_hDevMode) : NULL; + } + + HANDLE Detach() + { + if (m_hDevMode != NULL) + ::GlobalUnlock(m_hDevMode); + HANDLE hDevMode = m_hDevMode; + m_hDevMode = NULL; + return hDevMode; + } + + bool IsNull() const { return (m_hDevMode == NULL); } + + bool CopyFromPrinter(HANDLE hPrinter) + { + CPrinterInfo<2> pinfo; + bool b = pinfo.GetPrinterInfo(hPrinter); + if (b) + b = CopyFromDEVMODE(pinfo.m_pi->pDevMode); + return b; + } + + bool CopyFromDEVMODE(const DEVMODE* pdm) + { + if (pdm == NULL) + return false; + int nSize = pdm->dmSize + pdm->dmDriverExtra; + HANDLE h = ::GlobalAlloc(GMEM_MOVEABLE, nSize); + if (h != NULL) + { + void* p = ::GlobalLock(h); + ATL::Checked::memcpy_s(p, nSize, pdm, nSize); + ::GlobalUnlock(h); + } + Attach(h); + return (h != NULL); + } + + bool CopyFromHDEVMODE(HANDLE hdm) + { + bool b = false; + if (hdm != NULL) + { + DEVMODE* pdm = (DEVMODE*)::GlobalLock(hdm); + b = CopyFromDEVMODE(pdm); + ::GlobalUnlock(hdm); + } + return b; + } + + HANDLE CopyToHDEVMODE() + { + if ((m_hDevMode == NULL) || (m_pDevMode == NULL)) + return NULL; + int nSize = m_pDevMode->dmSize + m_pDevMode->dmDriverExtra; + HANDLE h = ::GlobalAlloc(GMEM_MOVEABLE, nSize); + if (h != NULL) + { + void* p = ::GlobalLock(h); + ATL::Checked::memcpy_s(p, nSize, m_pDevMode, nSize); + ::GlobalUnlock(h); + } + return h; + } + + // If this devmode was for another printer, this will create a new devmode + // based on the existing devmode, but retargeted at the new printer + bool UpdateForNewPrinter(HANDLE hPrinter) + { + bool bRet = false; + LONG nLen = ::DocumentProperties(NULL, hPrinter, NULL, NULL, NULL, 0); + ATL::CTempBuffer buff; + DEVMODE* pdm = buff.AllocateBytes(nLen); + if(pdm != NULL) + { + memset(pdm, 0, nLen); + LONG l = ::DocumentProperties(NULL, hPrinter, NULL, pdm, m_pDevMode, DM_IN_BUFFER | DM_OUT_BUFFER); + if (l == IDOK) + bRet = CopyFromDEVMODE(pdm); + } + + return bRet; + } + + bool DocumentProperties(HANDLE hPrinter, HWND hWnd = NULL) + { + CPrinterInfo<1> pi; + pi.GetPrinterInfo(hPrinter); + if (hWnd == NULL) + hWnd = ::GetActiveWindow(); + + bool bRet = false; + LONG nLen = ::DocumentProperties(hWnd, hPrinter, pi.m_pi->pName, NULL, NULL, 0); + ATL::CTempBuffer buff; + DEVMODE* pdm = buff.AllocateBytes(nLen); + if(pdm != NULL) + { + memset(pdm, 0, nLen); + LONG l = ::DocumentProperties(hWnd, hPrinter, pi.m_pi->pName, pdm, m_pDevMode, DM_IN_BUFFER | DM_OUT_BUFFER | DM_PROMPT); + if (l == IDOK) + bRet = CopyFromDEVMODE(pdm); + } + + return bRet; + } + + operator HANDLE() const { return m_hDevMode; } + + operator DEVMODE*() const { return m_pDevMode; } + +// Implementation + void Cleanup() + { + if (m_hDevMode != NULL) + { + ::GlobalUnlock(m_hDevMode); + if(t_bManaged) + ::GlobalFree(m_hDevMode); + m_hDevMode = NULL; + } + } +}; + +typedef CDevModeT CDevModeHandle; +typedef CDevModeT CDevMode; + + +/////////////////////////////////////////////////////////////////////////////// +// CPrinterDC + +class CPrinterDC : public CDC +{ +public: +// Constructors/destructor + CPrinterDC() + { + CPrinter printer; + printer.OpenDefaultPrinter(); + Attach(printer.CreatePrinterDC()); + ATLASSERT(m_hDC != NULL); + } + + CPrinterDC(HANDLE hPrinter, const DEVMODE* pdm = NULL) + { + CPrinterHandle p; + p.Attach(hPrinter); + Attach(p.CreatePrinterDC(pdm)); + ATLASSERT(m_hDC != NULL); + } + + ~CPrinterDC() + { + DeleteDC(); + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CPrintJob - Wraps a set of tasks for a specific printer (StartDoc/EndDoc) +// Handles aborting, background printing + +// Defines callbacks used by CPrintJob (not a COM interface) +class ATL_NO_VTABLE IPrintJobInfo +{ +public: + virtual void BeginPrintJob(HDC hDC) = 0; // allocate handles needed, etc. + virtual void EndPrintJob(HDC hDC, bool bAborted) = 0; // free handles, etc. + virtual void PrePrintPage(UINT nPage, HDC hDC) = 0; + virtual bool PrintPage(UINT nPage, HDC hDC) = 0; + virtual void PostPrintPage(UINT nPage, HDC hDC) = 0; + // If you want per page devmodes, return the DEVMODE* to use for nPage. + // You can optimize by only returning a new DEVMODE* when it is different + // from the one for nLastPage, otherwise return NULL. + // When nLastPage==0, the current DEVMODE* will be the default passed to + // StartPrintJob. + // Note: During print preview, nLastPage will always be "0". + virtual DEVMODE* GetNewDevModeForPage(UINT nLastPage, UINT nPage) = 0; + virtual bool IsValidPage(UINT nPage) = 0; +}; + +// Provides a default implementatin for IPrintJobInfo +// Typically, MI'd into a document or view class +class ATL_NO_VTABLE CPrintJobInfo : public IPrintJobInfo +{ +public: + virtual void BeginPrintJob(HDC /*hDC*/) // allocate handles needed, etc + { + } + + virtual void EndPrintJob(HDC /*hDC*/, bool /*bAborted*/) // free handles, etc + { + } + + virtual void PrePrintPage(UINT /*nPage*/, HDC hDC) + { + m_nPJState = ::SaveDC(hDC); + } + + virtual bool PrintPage(UINT /*nPage*/, HDC /*hDC*/) = 0; + + virtual void PostPrintPage(UINT /*nPage*/, HDC hDC) + { + RestoreDC(hDC, m_nPJState); + } + + virtual DEVMODE* GetNewDevModeForPage(UINT /*nLastPage*/, UINT /*nPage*/) + { + return NULL; + } + + virtual bool IsValidPage(UINT /*nPage*/) + { + return true; + } + +// Implementation - data + int m_nPJState; +}; + + +class CPrintJob +{ +public: +// Data members + CPrinterHandle m_printer; + IPrintJobInfo* m_pInfo; + DEVMODE* m_pDefDevMode; + DOCINFO m_docinfo; + int m_nJobID; + bool m_bCancel; + bool m_bComplete; + unsigned long m_nStartPage; + unsigned long m_nEndPage; + +// Constructor/destructor + CPrintJob() : m_nJobID(0), m_bCancel(false), m_bComplete(true) + { } + + ~CPrintJob() + { + ATLASSERT(IsJobComplete()); // premature destruction? + } + +// Operations + bool IsJobComplete() const + { + return m_bComplete; + } + + bool StartPrintJob(bool bBackground, HANDLE hPrinter, DEVMODE* pDefaultDevMode, + IPrintJobInfo* pInfo, LPCTSTR lpszDocName, + unsigned long nStartPage, unsigned long nEndPage, + bool bPrintToFile = false, LPCTSTR lpstrOutputFile = NULL) + { + ATLASSERT(m_bComplete); // previous job not done yet? + if (pInfo == NULL) + return false; + + memset(&m_docinfo, 0, sizeof(m_docinfo)); + m_docinfo.cbSize = sizeof(m_docinfo); + m_docinfo.lpszDocName = lpszDocName; + m_pInfo = pInfo; + m_nStartPage = nStartPage; + m_nEndPage = nEndPage; + m_printer.Attach(hPrinter); + m_pDefDevMode = pDefaultDevMode; + m_bComplete = false; + + if(bPrintToFile) + m_docinfo.lpszOutput = (lpstrOutputFile != NULL) ? lpstrOutputFile : _T("FILE:"); + + if (!bBackground) + { + m_bComplete = true; + return StartHelper(); + } + + // Create a thread and return + DWORD dwThreadID = 0; +#ifdef _MT + HANDLE hThread = (HANDLE)_beginthreadex(NULL, 0, (UINT (WINAPI*)(void*))StartProc, this, 0, (UINT*)&dwThreadID); +#else + HANDLE hThread = ::CreateThread(NULL, 0, StartProc, (void*)this, 0, &dwThreadID); +#endif + if (hThread == NULL) + return false; + + ::CloseHandle(hThread); + + return true; + } + +// Implementation + static DWORD WINAPI StartProc(void* p) + { + CPrintJob* pThis = (CPrintJob*)p; + pThis->StartHelper(); + pThis->m_bComplete = true; + return 0; + } + + bool StartHelper() + { + CDC dcPrinter; + dcPrinter.Attach(m_printer.CreatePrinterDC(m_pDefDevMode)); + if (dcPrinter.IsNull()) + return false; + + m_nJobID = ::StartDoc(dcPrinter, &m_docinfo); + if (m_nJobID <= 0) + return false; + + m_pInfo->BeginPrintJob(dcPrinter); + + // print all the pages now + unsigned long nLastPage = 0; + for (unsigned long nPage = m_nStartPage; nPage <= m_nEndPage; nPage++) + { + if (!m_pInfo->IsValidPage(nPage)) + break; + DEVMODE* pdm = m_pInfo->GetNewDevModeForPage(nLastPage, nPage); + if (pdm != NULL) + dcPrinter.ResetDC(pdm); + dcPrinter.StartPage(); + m_pInfo->PrePrintPage(nPage, dcPrinter); + if (!m_pInfo->PrintPage(nPage, dcPrinter)) + m_bCancel = true; + m_pInfo->PostPrintPage(nPage, dcPrinter); + dcPrinter.EndPage(); + if (m_bCancel) + break; + nLastPage = nPage; + } + + m_pInfo->EndPrintJob(dcPrinter, m_bCancel); + if (m_bCancel) + ::AbortDoc(dcPrinter); + else + ::EndDoc(dcPrinter); + m_nJobID = 0; + return true; + } + + // Cancels a print job. Can be called asynchronously. + void CancelPrintJob() + { + m_bCancel = true; + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CPrintPreview - Adds print preview support to an existing window + +class CPrintPreview +{ +public: +// Data members + IPrintJobInfo* m_pInfo; + CPrinterHandle m_printer; + CEnhMetaFile m_meta; + DEVMODE* m_pDefDevMode; + DEVMODE* m_pCurDevMode; + SIZE m_sizeCurPhysOffset; + +// Constructor + CPrintPreview() : m_pInfo(NULL), m_pDefDevMode(NULL), m_pCurDevMode(NULL) + { + m_sizeCurPhysOffset.cx = 0; + m_sizeCurPhysOffset.cy = 0; + } + +// Operations + void SetPrintPreviewInfo(HANDLE hPrinter, DEVMODE* pDefaultDevMode, IPrintJobInfo* pji) + { + m_printer.Attach(hPrinter); + m_pDefDevMode = pDefaultDevMode; + m_pInfo = pji; + m_nCurPage = 0; + m_pCurDevMode = NULL; + } + + void SetEnhMetaFile(HENHMETAFILE hEMF) + { + m_meta = hEMF; + } + + void SetPage(int nPage) + { + if (!m_pInfo->IsValidPage(nPage)) + return; + m_nCurPage = nPage; + m_pCurDevMode = m_pInfo->GetNewDevModeForPage(0, nPage); + if (m_pCurDevMode == NULL) + m_pCurDevMode = m_pDefDevMode; + CDC dcPrinter = m_printer.CreatePrinterDC(m_pCurDevMode); + + int iWidth = dcPrinter.GetDeviceCaps(PHYSICALWIDTH); + int iHeight = dcPrinter.GetDeviceCaps(PHYSICALHEIGHT); + int nLogx = dcPrinter.GetDeviceCaps(LOGPIXELSX); + int nLogy = dcPrinter.GetDeviceCaps(LOGPIXELSY); + + RECT rcMM = { 0, 0, ::MulDiv(iWidth, 2540, nLogx), ::MulDiv(iHeight, 2540, nLogy) }; + + m_sizeCurPhysOffset.cx = dcPrinter.GetDeviceCaps(PHYSICALOFFSETX); + m_sizeCurPhysOffset.cy = dcPrinter.GetDeviceCaps(PHYSICALOFFSETY); + + CEnhMetaFileDC dcMeta(dcPrinter, &rcMM); + m_pInfo->PrePrintPage(nPage, dcMeta); + m_pInfo->PrintPage(nPage, dcMeta); + m_pInfo->PostPrintPage(nPage, dcMeta); + m_meta.Attach(dcMeta.Close()); + } + + void GetPageRect(RECT& rc, LPRECT prc) + { + int x1 = rc.right-rc.left; + int y1 = rc.bottom - rc.top; + if ((x1 < 0) || (y1 < 0)) + return; + + CEnhMetaFileInfo emfinfo(m_meta); + ENHMETAHEADER* pmh = emfinfo.GetEnhMetaFileHeader(); + + // Compute whether we are OK vertically or horizontally + int x2 = pmh->szlDevice.cx; + int y2 = pmh->szlDevice.cy; + int y1p = MulDiv(x1, y2, x2); + int x1p = MulDiv(y1, x2, y2); + ATLASSERT((x1p <= x1) || (y1p <= y1)); + if (x1p <= x1) + { + prc->left = rc.left + (x1 - x1p) / 2; + prc->right = prc->left + x1p; + prc->top = rc.top; + prc->bottom = rc.bottom; + } + else + { + prc->left = rc.left; + prc->right = rc.right; + prc->top = rc.top + (y1 - y1p) / 2; + prc->bottom = prc->top + y1p; + } + } + +// Painting helpers + void DoPaint(CDCHandle dc) + { + // this one is not used + } + + void DoPaint(CDCHandle dc, RECT& rc) + { + CEnhMetaFileInfo emfinfo(m_meta); + ENHMETAHEADER* pmh = emfinfo.GetEnhMetaFileHeader(); + int nOffsetX = MulDiv(m_sizeCurPhysOffset.cx, rc.right-rc.left, pmh->szlDevice.cx); + int nOffsetY = MulDiv(m_sizeCurPhysOffset.cy, rc.bottom-rc.top, pmh->szlDevice.cy); + + dc.OffsetWindowOrg(-nOffsetX, -nOffsetY); + dc.PlayMetaFile(m_meta, &rc); + } + +// Implementation - data + int m_nCurPage; +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CPrintPreviewWindow - Implements a print preview window + +template +class ATL_NO_VTABLE CPrintPreviewWindowImpl : public ATL::CWindowImpl, public CPrintPreview +{ +public: + DECLARE_WND_CLASS_EX2(NULL, T, CS_VREDRAW | CS_HREDRAW, -1) + + enum { m_cxOffset = 10, m_cyOffset = 10 }; + +// Constructor + CPrintPreviewWindowImpl() : m_nMinPage(0), m_nMaxPage(0) + { } + +// Operations + void SetPrintPreviewInfo(HANDLE hPrinter, DEVMODE* pDefaultDevMode, + IPrintJobInfo* pji, int nMinPage, int nMaxPage) + { + CPrintPreview::SetPrintPreviewInfo(hPrinter, pDefaultDevMode, pji); + m_nMinPage = nMinPage; + m_nMaxPage = nMaxPage; + } + + bool NextPage() + { + if (m_nCurPage == m_nMaxPage) + return false; + SetPage(m_nCurPage + 1); + this->Invalidate(); + return true; + } + + bool PrevPage() + { + if (m_nCurPage == m_nMinPage) + return false; + if (m_nCurPage == 0) + return false; + SetPage(m_nCurPage - 1); + this->Invalidate(); + return true; + } + +// Message map and handlers + BEGIN_MSG_MAP(CPrintPreviewWindowImpl) + MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBkgnd) + MESSAGE_HANDLER(WM_PAINT, OnPaint) + MESSAGE_HANDLER(WM_PRINTCLIENT, OnPaint) + END_MSG_MAP() + + LRESULT OnEraseBkgnd(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + return 1; // no need for the background + } + + LRESULT OnPaint(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + T* pT = static_cast(this); + RECT rc = {}; + + if(wParam != NULL) + { + pT->DoPrePaint((HDC)wParam, rc); + pT->DoPaint((HDC)wParam, rc); + } + else + { + CPaintDC dc(this->m_hWnd); + pT->DoPrePaint(dc.m_hDC, rc); + pT->DoPaint(dc.m_hDC, rc); + } + + return 0; + } + +// Painting helper + void DoPrePaint(CDCHandle dc, RECT& rc) + { + RECT rcClient = {}; + this->GetClientRect(&rcClient); + RECT rcArea = rcClient; + T* pT = static_cast(this); + (void)pT; // avoid level 4 warning + ::InflateRect(&rcArea, -pT->m_cxOffset, -pT->m_cyOffset); + if (rcArea.left > rcArea.right) + rcArea.right = rcArea.left; + if (rcArea.top > rcArea.bottom) + rcArea.bottom = rcArea.top; + GetPageRect(rcArea, &rc); + CRgn rgn1, rgn2; + rgn1.CreateRectRgnIndirect(&rc); + rgn2.CreateRectRgnIndirect(&rcClient); + rgn2.CombineRgn(rgn1, RGN_DIFF); + dc.SelectClipRgn(rgn2); + dc.FillRect(&rcClient, COLOR_BTNSHADOW); + dc.SelectClipRgn(NULL); + dc.FillRect(&rc, (HBRUSH)::GetStockObject(WHITE_BRUSH)); + } + +// Implementation - data + int m_nMinPage; + int m_nMaxPage; +}; + + +class CPrintPreviewWindow : public CPrintPreviewWindowImpl +{ +public: + DECLARE_WND_CLASS_EX(_T("WTL_PrintPreview"), CS_VREDRAW | CS_HREDRAW, -1) +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CZoomPrintPreviewWindowImpl - Implements print preview window with zooming + +#ifdef __ATLSCRL_H__ + +template +class ATL_NO_VTABLE CZoomPrintPreviewWindowImpl : public CPrintPreviewWindowImpl< T, TBase, TWinTraits >, public CZoomScrollImpl< T > +{ +public: + bool m_bSized; + + CZoomPrintPreviewWindowImpl() + { + this->SetScrollExtendedStyle(SCRL_DISABLENOSCROLL); + InitZoom(); + } + + // should be called to reset data members before recreating window + void InitZoom() + { + m_bSized = false; + this->m_nZoomMode = ZOOMMODE_OFF; + this->m_fZoomScaleMin = 1.0; + this->m_fZoomScale = 1.0; + } + + BEGIN_MSG_MAP(CZoomPrintPreviewWindowImpl) + MESSAGE_HANDLER(WM_SETCURSOR, CZoomScrollImpl< T >::OnSetCursor) + MESSAGE_HANDLER(WM_VSCROLL, CScrollImpl< T >::OnVScroll) + MESSAGE_HANDLER(WM_HSCROLL, CScrollImpl< T >::OnHScroll) + MESSAGE_HANDLER(WM_MOUSEWHEEL, CScrollImpl< T >::OnMouseWheel) + MESSAGE_HANDLER(WM_MOUSEHWHEEL, CScrollImpl< T >::OnMouseHWheel) + MESSAGE_HANDLER(WM_SETTINGCHANGE, CScrollImpl< T >::OnSettingChange) + MESSAGE_HANDLER(WM_LBUTTONDOWN, CZoomScrollImpl< T >::OnLButtonDown) + MESSAGE_HANDLER(WM_MOUSEMOVE, CZoomScrollImpl< T >::OnMouseMove) + MESSAGE_HANDLER(WM_LBUTTONUP, CZoomScrollImpl< T >::OnLButtonUp) + MESSAGE_HANDLER(WM_CAPTURECHANGED, CZoomScrollImpl< T >::OnCaptureChanged) + MESSAGE_HANDLER(WM_SIZE, OnSize) + MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBkgnd) + MESSAGE_HANDLER(WM_PAINT, OnPaint) + MESSAGE_HANDLER(WM_PRINTCLIENT, OnPaint) + ALT_MSG_MAP(1) + COMMAND_ID_HANDLER(ID_SCROLL_UP, CScrollImpl< T >::OnScrollUp) + COMMAND_ID_HANDLER(ID_SCROLL_DOWN, CScrollImpl< T >::OnScrollDown) + COMMAND_ID_HANDLER(ID_SCROLL_PAGE_UP, CScrollImpl< T >::OnScrollPageUp) + COMMAND_ID_HANDLER(ID_SCROLL_PAGE_DOWN, CScrollImpl< T >::OnScrollPageDown) + COMMAND_ID_HANDLER(ID_SCROLL_TOP, CScrollImpl< T >::OnScrollTop) + COMMAND_ID_HANDLER(ID_SCROLL_BOTTOM, CScrollImpl< T >::OnScrollBottom) + COMMAND_ID_HANDLER(ID_SCROLL_LEFT, CScrollImpl< T >::OnScrollLeft) + COMMAND_ID_HANDLER(ID_SCROLL_RIGHT, CScrollImpl< T >::OnScrollRight) + COMMAND_ID_HANDLER(ID_SCROLL_PAGE_LEFT, CScrollImpl< T >::OnScrollPageLeft) + COMMAND_ID_HANDLER(ID_SCROLL_PAGE_RIGHT, CScrollImpl< T >::OnScrollPageRight) + COMMAND_ID_HANDLER(ID_SCROLL_ALL_LEFT, CScrollImpl< T >::OnScrollAllLeft) + COMMAND_ID_HANDLER(ID_SCROLL_ALL_RIGHT, CScrollImpl< T >::OnScrollAllRight) + END_MSG_MAP() + + LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) + { + SIZE sizeClient = {GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)}; + POINT ptOffset = this->m_ptOffset; + SIZE sizeAll = this->m_sizeAll; + this->SetScrollSize(sizeClient); + if(sizeAll.cx > 0) + ptOffset.x = ::MulDiv(ptOffset.x, this->m_sizeAll.cx, sizeAll.cx); + if(sizeAll.cy > 0) + ptOffset.y = ::MulDiv(ptOffset.y, this->m_sizeAll.cy, sizeAll.cy); + this->SetScrollOffset(ptOffset); + CScrollImpl< T >::OnSize(uMsg, wParam, lParam, bHandled); + if(!m_bSized) + { + m_bSized = true; + T* pT = static_cast(this); + pT->ShowScrollBar(SB_HORZ, TRUE); + pT->ShowScrollBar(SB_VERT, TRUE); + } + return 0; + } + + LRESULT OnEraseBkgnd(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + return 1; + } + + LRESULT OnPaint(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + T* pT = static_cast(this); + RECT rc = {}; + + if(wParam != NULL) + { + CDCHandle dc = (HDC)wParam; + int nMapModeSav = dc.GetMapMode(); + dc.SetMapMode(MM_ANISOTROPIC); + SIZE szWindowExt = { 0, 0 }; + dc.SetWindowExt(this->m_sizeLogAll, &szWindowExt); + SIZE szViewportExt = { 0, 0 }; + dc.SetViewportExt(this->m_sizeAll, &szViewportExt); + POINT ptViewportOrg = { 0, 0 }; + dc.SetViewportOrg(-this->m_ptOffset.x, -this->m_ptOffset.y, &ptViewportOrg); + + pT->DoPrePaint(dc, rc); + pT->DoPaint(dc, rc); + + dc.SetMapMode(nMapModeSav); + dc.SetWindowExt(szWindowExt); + dc.SetViewportExt(szViewportExt); + dc.SetViewportOrg(ptViewportOrg); + } + else + { + CPaintDC dc(pT->m_hWnd); + pT->PrepareDC(dc.m_hDC); + pT->DoPrePaint(dc.m_hDC, rc); + pT->DoPaint(dc.m_hDC, rc); + } + + return 0; + } + + // Painting helpers + void DoPaint(CDCHandle dc) + { + // this one is not used + } + + void DoPrePaint(CDCHandle dc, RECT& rc) + { + RECT rcClient = {}; + this->GetClientRect(&rcClient); + RECT rcArea = rcClient; + T* pT = static_cast(this); + (void)pT; // avoid level 4 warning + ::InflateRect(&rcArea, -pT->m_cxOffset, -pT->m_cyOffset); + if (rcArea.left > rcArea.right) + rcArea.right = rcArea.left; + if (rcArea.top > rcArea.bottom) + rcArea.bottom = rcArea.top; + this->GetPageRect(rcArea, &rc); + HBRUSH hbrOld = dc.SelectBrush(::GetSysColorBrush(COLOR_BTNSHADOW)); + dc.PatBlt(rcClient.left, rcClient.top, rc.left - rcClient.left, rcClient.bottom - rcClient.top, PATCOPY); + dc.PatBlt(rc.left, rcClient.top, rc.right - rc.left, rc.top - rcClient.top, PATCOPY); + dc.PatBlt(rc.right, rcClient.top, rcClient.right - rc.right, rcClient.bottom - rcClient.top, PATCOPY); + dc.PatBlt(rc.left, rc.bottom, rc.right - rc.left, rcClient.bottom - rc.bottom, PATCOPY); + dc.SelectBrush((HBRUSH)::GetStockObject(WHITE_BRUSH)); + dc.PatBlt(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY); + dc.SelectBrush(::GetSysColorBrush(COLOR_3DDKSHADOW)); + dc.PatBlt(rc.right, rc.top + 4, 4, rc.bottom - rc.top, PATCOPY); + dc.PatBlt(rc.left + 4, rc.bottom, rc.right - rc.left, 4, PATCOPY); + dc.SelectBrush(hbrOld); + } + + void DoPaint(CDCHandle dc, RECT& rc) + { + CEnhMetaFileInfo emfinfo(this->m_meta); + ENHMETAHEADER* pmh = emfinfo.GetEnhMetaFileHeader(); + int nOffsetX = MulDiv(this->m_sizeCurPhysOffset.cx, rc.right-rc.left, pmh->szlDevice.cx); + int nOffsetY = MulDiv(this->m_sizeCurPhysOffset.cy, rc.bottom-rc.top, pmh->szlDevice.cy); + + dc.OffsetWindowOrg(-nOffsetX, -nOffsetY); + dc.PlayMetaFile(this->m_meta, &rc); + } +}; + +class CZoomPrintPreviewWindow : public CZoomPrintPreviewWindowImpl +{ +public: + DECLARE_WND_CLASS_EX(_T("WTL_ZoomPrintPreview"), CS_VREDRAW | CS_HREDRAW, -1) +}; + +#endif // __ATLSCRL_H__ + +} // namespace WTL + +#endif // __ATLPRINT_H__ diff -r e9bb126753e7 -r 20d02a178406 foosdk/wtl/Include/atlres.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/wtl/Include/atlres.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,259 @@ +// Windows Template Library - WTL version 10.0 +// Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. +// +// This file is a part of the Windows Template Library. +// The use and distribution terms for this software are covered by the +// Microsoft Public License (http://opensource.org/licenses/MS-PL) +// which can be found in the file MS-PL.txt at the root folder. + +#ifndef __ATLRES_H__ +#define __ATLRES_H__ + +#pragma once + + +#ifdef RC_INVOKED +#ifndef _INC_WINDOWS + + #define _INC_WINDOWS + + #define VS_VERSION_INFO 1 + + #ifdef APSTUDIO_INVOKED + #define APSTUDIO_HIDDEN_SYMBOLS // Ignore following symbols + #endif // APSTUDIO_INVOKED + + #ifndef WINVER + #define WINVER 0x0500 + #endif // !WINVER + + #include + + // operation messages sent to DLGINIT + #define LB_ADDSTRING (WM_USER+1) + #define CB_ADDSTRING (WM_USER+3) + + #ifdef APSTUDIO_INVOKED + #undef APSTUDIO_HIDDEN_SYMBOLS + #endif // APSTUDIO_INVOKED + + #ifdef IDC_STATIC + #undef IDC_STATIC + #endif // IDC_STATIC + #define IDC_STATIC (-1) + +#endif // !_INC_WINDOWS +#endif // RC_INVOKED + +#ifdef APSTUDIO_INVOKED + #define APSTUDIO_HIDDEN_SYMBOLS +#endif // APSTUDIO_INVOKED + +/////////////////////////////////////////////////////////////////////////////// +// ATL resource types + +#ifndef RC_INVOKED + #define RT_DLGINIT MAKEINTRESOURCE(240) + #define RT_TOOLBAR MAKEINTRESOURCE(241) +#endif // RC_INVOKED + +/////////////////////////////////////////////////////////////////////////////// + +#ifdef APSTUDIO_INVOKED + #undef APSTUDIO_HIDDEN_SYMBOLS +#endif // APSTUDIO_INVOKED + +/////////////////////////////////////////////////////////////////////////////// +// Standard window components + +#define ID_SEPARATOR 0 // special separator value +#define ID_DEFAULT_PANE 0 // default status bar pane + +#ifndef RC_INVOKED // code only +// standard control bars (IDW = window ID) + #define ATL_IDW_TOOLBAR 0xE800 // main Toolbar for window + #define ATL_IDW_STATUS_BAR 0xE801 // Status bar window + #define ATL_IDW_COMMAND_BAR 0xE802 // Command bar window + +// parts of a frame window + #define ATL_IDW_CLIENT 0xE900 + #define ATL_IDW_PANE_FIRST 0xE900 // first pane (256 max) + #define ATL_IDW_PANE_LAST 0xE9FF + #define ATL_IDW_HSCROLL_FIRST 0xEA00 // first Horz scrollbar (16 max) + #define ATL_IDW_VSCROLL_FIRST 0xEA10 // first Vert scrollbar (16 max) + + #define ATL_IDW_SIZE_BOX 0xEA20 // size box for splitters + #define ATL_IDW_PANE_SAVE 0xEA21 // to shift ATL_IDW_PANE_FIRST + +// bands for a rebar + #define ATL_IDW_BAND_FIRST 0xEB00 + #define ATL_IDW_BAND_LAST 0xEBFF +#endif // !RC_INVOKED + +/////////////////////////////////////////////////////////////////////////////// +// Standard Commands + +// File commands +#define ID_FILE_NEW 0xE100 +#define ID_FILE_OPEN 0xE101 +#define ID_FILE_CLOSE 0xE102 +#define ID_FILE_SAVE 0xE103 +#define ID_FILE_SAVE_AS 0xE104 +#define ID_FILE_PAGE_SETUP 0xE105 +#define ID_FILE_PRINT_SETUP 0xE106 +#define ID_FILE_PRINT 0xE107 +#define ID_FILE_PRINT_DIRECT 0xE108 +#define ID_FILE_PRINT_PREVIEW 0xE109 +#define ID_FILE_UPDATE 0xE10A +#define ID_FILE_SAVE_COPY_AS 0xE10B +#define ID_FILE_SEND_MAIL 0xE10C + +#define ID_FILE_MRU_FIRST 0xE110 +#define ID_FILE_MRU_FILE1 0xE110 // range - 16 max +#define ID_FILE_MRU_FILE2 0xE111 +#define ID_FILE_MRU_FILE3 0xE112 +#define ID_FILE_MRU_FILE4 0xE113 +#define ID_FILE_MRU_FILE5 0xE114 +#define ID_FILE_MRU_FILE6 0xE115 +#define ID_FILE_MRU_FILE7 0xE116 +#define ID_FILE_MRU_FILE8 0xE117 +#define ID_FILE_MRU_FILE9 0xE118 +#define ID_FILE_MRU_FILE10 0xE119 +#define ID_FILE_MRU_FILE11 0xE11A +#define ID_FILE_MRU_FILE12 0xE11B +#define ID_FILE_MRU_FILE13 0xE11C +#define ID_FILE_MRU_FILE14 0xE11D +#define ID_FILE_MRU_FILE15 0xE11E +#define ID_FILE_MRU_FILE16 0xE11F +#define ID_FILE_MRU_LAST 0xE11F + +// Edit commands +#define ID_EDIT_CLEAR 0xE120 +#define ID_EDIT_CLEAR_ALL 0xE121 +#define ID_EDIT_COPY 0xE122 +#define ID_EDIT_CUT 0xE123 +#define ID_EDIT_FIND 0xE124 +#define ID_EDIT_PASTE 0xE125 +#define ID_EDIT_PASTE_LINK 0xE126 +#define ID_EDIT_PASTE_SPECIAL 0xE127 +#define ID_EDIT_REPEAT 0xE128 +#define ID_EDIT_REPLACE 0xE129 +#define ID_EDIT_SELECT_ALL 0xE12A +#define ID_EDIT_UNDO 0xE12B +#define ID_EDIT_REDO 0xE12C +#define ID_EDIT_DELETE ID_EDIT_CLEAR +#define ID_EDIT_FIND_NEXT ID_EDIT_REPEAT +#define ID_EDIT_FIND_PREVIOUS 0xE12D + +// Window commands +#define ID_WINDOW_NEW 0xE130 +#define ID_WINDOW_ARRANGE 0xE131 +#define ID_WINDOW_CASCADE 0xE132 +#define ID_WINDOW_TILE_HORZ 0xE133 +#define ID_WINDOW_TILE_VERT 0xE134 +#define ID_WINDOW_SPLIT 0xE135 +#ifndef RC_INVOKED // code only + #define ATL_IDM_WINDOW_FIRST 0xE130 + #define ATL_IDM_WINDOW_LAST 0xE13F + #define ATL_IDM_FIRST_MDICHILD 0xFF00 // window list starts here + #define ATL_IDM_LAST_MDICHILD 0xFFFD +#endif // !RC_INVOKED +// TabView +#define ID_WINDOW_TABFIRST 0xFF00 // = ATL_IDM_FIRST_MDICHILD +#define ID_WINDOW_TABLAST 0xFFFD +#define ID_WINDOW_SHOWTABLIST 0xFFFE + +// Help and App commands +#define ID_APP_ABOUT 0xE140 +#define ID_APP_EXIT 0xE141 +#define ID_HELP_INDEX 0xE142 +#define ID_HELP_FINDER 0xE143 +#define ID_HELP_USING 0xE144 +#define ID_CONTEXT_HELP 0xE145 // shift-F1 +// special commands for processing help +#define ID_HELP 0xE146 // first attempt for F1 +#define ID_DEFAULT_HELP 0xE147 // last attempt + +// Misc +#define ID_NEXT_PANE 0xE150 +#define ID_PREV_PANE 0xE151 +#define ID_PANE_CLOSE 0xE152 +#define ID_PANE_NEXT ID_NEXT_PANE +#define ID_PANE_PREVIOUS ID_PREV_PANE + +// Format +#define ID_FORMAT_FONT 0xE160 + +// Scroll +#define ID_SCROLL_UP 0xE170 +#define ID_SCROLL_DOWN 0xE171 +#define ID_SCROLL_PAGE_UP 0xE172 +#define ID_SCROLL_PAGE_DOWN 0xE173 +#define ID_SCROLL_TOP 0xE174 +#define ID_SCROLL_BOTTOM 0xE175 +#define ID_SCROLL_LEFT 0xE176 +#define ID_SCROLL_RIGHT 0xE177 +#define ID_SCROLL_PAGE_LEFT 0xE178 +#define ID_SCROLL_PAGE_RIGHT 0xE179 +#define ID_SCROLL_ALL_LEFT 0xE17A +#define ID_SCROLL_ALL_RIGHT 0xE17B + +// OLE commands +#define ID_OLE_INSERT_NEW 0xE200 +#define ID_OLE_EDIT_LINKS 0xE201 +#define ID_OLE_EDIT_CONVERT 0xE202 +#define ID_OLE_EDIT_CHANGE_ICON 0xE203 +#define ID_OLE_EDIT_PROPERTIES 0xE204 +#define ID_OLE_VERB_FIRST 0xE210 // range - 16 max +#ifndef RC_INVOKED // code only + #define ID_OLE_VERB_LAST 0xE21F +#endif // !RC_INVOKED + +// View commands (same number used as IDW used for toolbar and status bar) +#define ID_VIEW_TOOLBAR 0xE800 +#define ID_VIEW_STATUS_BAR 0xE801 +#define ID_VIEW_REFRESH 0xE803 +#define ID_VIEW_RIBBON 0xE804 + +/////////////////////////////////////////////////////////////////////////////// +// Standard control IDs + +#ifdef IDC_STATIC + #undef IDC_STATIC +#endif // IDC_STATIC +#define IDC_STATIC (-1) // all static controls + +/////////////////////////////////////////////////////////////////////////////// +// Standard string error/warnings + +// idle status bar message +#define ATL_IDS_IDLEMESSAGE 0xE001 + +#ifndef RC_INVOKED // code only + #define ATL_IDS_SCFIRST 0xEF00 +#endif // !RC_INVOKED + +#define ATL_IDS_SCSIZE 0xEF00 +#define ATL_IDS_SCMOVE 0xEF01 +#define ATL_IDS_SCMINIMIZE 0xEF02 +#define ATL_IDS_SCMAXIMIZE 0xEF03 +#define ATL_IDS_SCNEXTWINDOW 0xEF04 +#define ATL_IDS_SCPREVWINDOW 0xEF05 +#define ATL_IDS_SCCLOSE 0xEF06 +#define ATL_IDS_SCRESTORE 0xEF12 +#define ATL_IDS_SCTASKLIST 0xEF13 + +#define ATL_IDS_MDICHILD 0xEF1F +#define ATL_IDS_MRU_FILE 0xEFDA + +/////////////////////////////////////////////////////////////////////////////// +// Misc. control IDs + +// Property Sheet control id's (determined with Spy++) +#define ID_APPLY_NOW 0x3021 +#define ID_WIZBACK 0x3023 +#define ID_WIZNEXT 0x3024 +#define ID_WIZFINISH 0x3025 +#define ATL_IDC_TAB_CONTROL 0x3020 + +#endif // __ATLRES_H__ diff -r e9bb126753e7 -r 20d02a178406 foosdk/wtl/Include/atlribbon.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/wtl/Include/atlribbon.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,3488 @@ +// Windows Template Library - WTL version 10.0 +// Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. +// +// This file is a part of the Windows Template Library. +// The use and distribution terms for this software are covered by the +// Microsoft Public License (http://opensource.org/licenses/MS-PL) +// which can be found in the file MS-PL.txt at the root folder. + +#ifndef __ATLRIBBON_H__ +#define __ATLRIBBON_H__ + +#pragma once + +#if (_MSC_VER < 1500) + #error atlribbon.h requires Visual C++ 2008 compiler or higher +#endif + +#ifndef _UNICODE + #error atlribbon.h requires the Unicode character set +#endif + +#if !defined(NTDDI_WIN7) || (NTDDI_VERSION < NTDDI_WIN7) + #error atlribbon.h requires the Windows 7 SDK or higher +#endif + +#ifndef __ATLAPP_H__ + #error atlribbon.h requires atlapp.h to be included first +#endif + +#include // for RecentDocumentList classes +#include // for Frame and UpdateUI classes +#include // required for atlctrlw.h +#include // for CCommandBarCtrl + +#ifndef __ATLSTR_H__ + #pragma warning(push) + #pragma warning(disable: 4530) // unwind semantics not enabled + #include + #pragma warning(pop) +#endif + +#include +#pragma comment(lib, "dwmapi.lib") + +#include "UIRibbon.h" +#include "UIRibbonPropertyHelpers.h" +#pragma comment(lib, "propsys.lib") + +#include // for CHARFORMAT2 + + +/////////////////////////////////////////////////////////////////////////////// +// Classes in this file: +// +// CRibbonUpdateUI : Automatic mapping of ribbon UI elements +// +// RibbonUI::Text +// RibbonUI::CharFormat +// RibbonUI::ICtrl +// RibbonUI::CtrlImpl +// RibbonUI::CommandCtrlImpl +// RibbonUI::ItemProperty +// RibbonUI::CollectionImplBase +// RibbonUI::CollectionImpl +// RibbonUI::TextCollectionImpl +// RibbonUI::ItemCollectionImpl +// RibbonUI::ComboCollectionImpl +// RibbonUI::CommandCollectionImpl +// RibbonUI::ToolbarCollectionImpl +// RibbonUI::SimpleCollectionImpl +// RibbonUI::CollectionCtrlImpl +// RibbonUI::ToolbarGalleryCtrlImpl +// RibbonUI::SimpleCollectionCtrlImpl +// RibbonUI::RecentItemsCtrlImpl +// RibbonUI::FontCtrlImpl +// RibbonUI::ColorCtrlImpl +// RibbonUI::SpinnerCtrlImpl +// +// RibbonUI::CRibbonImpl +// CRibbonImpl::CRibbonComboCtrl +// CRibbonImpl::CRibbonItemGalleryCtrl +// CRibbonImpl::CRibbonCommandGalleryCtrl +// CRibbonImpl::CRibbonToolbarGalleryCtrl +// CRibbonImpl::CRibbonSimpleComboCtrl +// CRibbonImpl::CRibbonSimpleGalleryCtrl +// CRibbonImpl::CRibbonRecentItemsCtrl +// CRibbonImpl::CRibbonColorCtrl +// CRibbonImpl::CRibbonFontCtrl +// CRibbonImpl::CRibbonSpinnerCtrl +// CRibbonImpl::CRibbonFloatSpinnerCtrl +// CRibbonImpl::CRibbonCommandCtrl +// +// CRibbonFrameWindowImplBase +// CRibbonFrameWindowImpl +// CRibbonMDIFrameWindowImpl +// CRibbonPersist +// +// Global functions: +// RibbonUI::SetPropertyVal() +// RibbonUI::GetImage() + + +// Constants + +#ifndef RIBBONUI_MAX_TEXT + #define RIBBONUI_MAX_TEXT 128 +#endif + +#define TWIPS_PER_POINT 20 // For font size + + +namespace WTL +{ + +/////////////////////////////////////////////////////////////////////////////// +// CRibbonUpdateUI : Automatic mapping of ribbon UI elements + +template +class CRibbonUpdateUI : public CAutoUpdateUI +{ +public: + enum + { + UPDUI_RIBBON = 0x0080, + UPDUI_PERSIST = 0x0020 + }; + + bool IsRibbonElement(const CUpdateUIBase::_AtlUpdateUIMap& UIMap) + { + return (UIMap.m_wType & UPDUI_RIBBON) != 0; + } + + bool IsRibbonID(UINT nID) + { + for(int i = 0; i < this->m_arrUIMap.GetSize(); i++) + { + if(this->m_arrUIMap[i].m_nID == nID) + return IsRibbonElement(this->m_arrUIMap[i]); + } + + return false; + } + +// Element + bool UIAddRibbonElement(UINT nID) + { + return this->UIAddElement(nID); + } + + bool UIRemoveRibbonElement(UINT nID) + { + return this->UIRemoveElement(nID); + } + + bool UIPersistElement(UINT nID, bool bPersist = true) + { + return bPersist ? + this->UIAddElement(nID) : + this->UIRemoveElement(nID); + } + +// methods for Ribbon elements + BOOL UISetText(int nID, LPCWSTR sText, BOOL bForceUpdate = FALSE) + { + T* pT = static_cast(this); + BOOL bRes = CUpdateUIBase::UISetText(nID, sText, bForceUpdate); + if (pT->IsRibbonUI() && IsRibbonID(nID)) + bRes = SUCCEEDED(pT->InvalidateProperty(nID, UI_PKEY_Label)); + return bRes; + } + + BOOL UISetText(int nID, UINT uIdResource, BOOL bForceUpdate = FALSE) + { + ATL::CTempBuffer sText(RIBBONUI_MAX_TEXT); + int nRet = ATL::AtlLoadString(uIdResource, sText, RIBBONUI_MAX_TEXT); + if(nRet > 0) + UISetText(nID, sText, bForceUpdate); + return (nRet > 0) ? TRUE : FALSE; + } + + LPCTSTR UIGetText(int nID) + { + T* pT = static_cast(this); + LPCTSTR sUI = CAutoUpdateUI::UIGetText(nID); + + // replace 'tab' by 'space' for RibbonUI elements + if (sUI && pT->IsRibbonUI() && IsRibbonID(nID) && wcschr(sUI, L'\t')) + { + static WCHAR sText[RIBBONUI_MAX_TEXT] = {}; + wcscpy_s(sText, sUI); + WCHAR* pch = wcschr(sText, L'\t'); + if (pch != NULL) + *pch = L' '; + return sText; + } + else + { + return sUI; + } + } + + BOOL UIEnable(int nID, BOOL bEnable, BOOL bForceUpdate = FALSE) + { + T* pT = static_cast(this); + BOOL bRes = CUpdateUIBase::UIEnable(nID, bEnable, bForceUpdate); + if (pT->IsRibbonUI() && IsRibbonID(nID)) + bRes = SUCCEEDED(pT->SetProperty((WORD)nID, UI_PKEY_Enabled, bEnable)); + return bRes; + } + + BOOL UISetCheck(int nID, INT nCheck, BOOL bForceUpdate = FALSE) + { + if ((nCheck == 0) || (nCheck == 1)) + return UISetCheck(nID, nCheck != 0, bForceUpdate); + else + return CUpdateUIBase::UISetCheck(nID, nCheck, bForceUpdate); + } + + BOOL UISetCheck(int nID, bool bCheck, BOOL bForceUpdate = FALSE) + { + T* pT = static_cast(this); + BOOL bRes = CUpdateUIBase::UISetCheck(nID, bCheck, bForceUpdate); + if (bRes && pT->IsRibbonUI() && IsRibbonID(nID)) + bRes = SUCCEEDED(pT->SetProperty((WORD)nID, UI_PKEY_BooleanValue, bCheck)); + return bRes; + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// RibbonUI namespace +// + +namespace RibbonUI +{ + +// Minimal string allocation support for various PROPERTYKEY values +#ifdef __ATLSTR_H__ + typedef ATL::CString Text; +#else + class Text : public std::wstring + { + public: + Text(std::wstring& s) : std::wstring(s) + { } + Text(LPCWSTR s) : std::wstring(s) + { } + Text() + { } + bool IsEmpty() + { + return empty(); + } + operator LPCWSTR() + { + return c_str(); + } + Text& operator =(LPCWSTR s) + { + return static_cast(std::wstring::operator =(s)); + } + }; +#endif // __ATLSTR_H__ + +// PROPERTYKEY enum and helpers +enum k_KEY +{ + // state + k_Enabled = 1, k_BooleanValue = 200, + // text properties + k_LabelDescription = 2, k_Keytip = 3, k_Label = 4, k_TooltipDescription = 5, k_TooltipTitle = 6, + // image properties + k_LargeImage = 7, k_LargeHighContrastImage = 8, k_SmallImage = 9, k_SmallHighContrastImage = 10, + // collection properties + k_ItemsSource = 101, k_Categories = 102, k_SelectedItem = 104, + // collection item properties + k_CommandId = 100, k_CategoryId = 103, k_CommandType = 105, k_ItemImage = 106, + // combo control property + k_StringValue = 202, + // spinner control properties + k_DecimalValue = 201, k_MaxValue = 203, k_MinValue, k_Increment, k_DecimalPlaces, k_FormatString, k_RepresentativeString = 208, + // font control properties + k_FontProperties = 300, k_FontProperties_Family, k_FontProperties_Size, k_FontProperties_Bold, k_FontProperties_Italic = 304, + k_FontProperties_Underline = 305, k_FontProperties_Strikethrough, k_FontProperties_VerticalPositioning, k_FontProperties_ForegroundColor = 308, + k_FontProperties_BackgroundColor = 309, k_FontProperties_ForegroundColorType, k_FontProperties_BackgroundColorType, k_FontProperties_ChangedProperties = 312, + k_FontProperties_DeltaSize = 313, + // recent items properties + k_RecentItems = 350, k_Pinned = 351, + // color control properties + k_Color = 400, k_ColorType = 401, k_ColorMode, + k_ThemeColorsCategoryLabel = 403, k_StandardColorsCategoryLabel, k_RecentColorsCategoryLabel = 405, k_AutomaticColorLabel = 406, + k_NoColorLabel = 407, k_MoreColorsLabel = 408, + k_ThemeColors = 409, k_StandardColors = 410, k_ThemeColorsTooltips = 411, k_StandardColorsTooltips = 412, + // Ribbon state + k_Viewable = 1000, k_Minimized = 1001, k_QuickAccessToolbarDock = 1002, k_ContextAvailable = 1100, + // Ribbon UI colors + k_GlobalBackgroundColor = 2000, k_GlobalHighlightColor, k_GlobalTextColor = 2002 +}; + +inline k_KEY k_(REFPROPERTYKEY key) +{ + return (k_KEY)key.fmtid.Data1; +} + +// PROPERTYKEY value assignment and specializations +// +template +HRESULT SetPropertyVal(REFPROPERTYKEY key, V val, PROPVARIANT* ppv) +{ + switch (k_(key)) + { + case k_Enabled: + case k_BooleanValue: + return InitPropVariantFromBoolean(val, ppv); + default: + return UIInitPropertyFromUInt32(key, val, ppv); + } +} + +inline HRESULT SetPropertyVal(REFPROPERTYKEY key, DOUBLE val, PROPVARIANT* ppv) +{ + return SetPropertyVal(key, (LONG)val, ppv); +} + +inline HRESULT SetPropertyVal(REFPROPERTYKEY key, IUIImage* val, PROPVARIANT* ppv) +{ + HRESULT hr = UIInitPropertyFromImage(key, val, ppv); + ATLVERIFY(val->Release() == 1); + return hr; +} + +inline HRESULT SetPropertyVal(REFPROPERTYKEY key, IUnknown* val, PROPVARIANT* ppv) +{ + return UIInitPropertyFromInterface(key, val, ppv); +} + +inline HRESULT SetPropertyVal(REFPROPERTYKEY key, IPropertyStore* val, PROPVARIANT* ppv) +{ + return UIInitPropertyFromInterface(key, val, ppv); +} + +inline HRESULT SetPropertyVal(REFPROPERTYKEY key, SAFEARRAY* val, PROPVARIANT* ppv) +{ + return UIInitPropertyFromIUnknownArray(key, val, ppv); +} + +inline HRESULT SetPropertyVal(REFPROPERTYKEY key, DECIMAL* val, PROPVARIANT* ppv) +{ + return UIInitPropertyFromDecimal(key, *val, ppv); +} + +inline HRESULT SetPropertyVal(REFPROPERTYKEY key, bool val, PROPVARIANT* ppv) +{ + return UIInitPropertyFromBoolean(key, val, ppv); +} + +inline HRESULT SetPropertyVal(REFPROPERTYKEY key, LPCWSTR val, PROPVARIANT* ppv) +{ + return UIInitPropertyFromString(key, val, ppv); +} + +// CharFormat helper struct for RibbonUI font control +// +struct CharFormat : CHARFORMAT2 +{ + // Default constructor + CharFormat() + { + cbSize = sizeof(CHARFORMAT2); + Reset(); + } + + // Copy constructor + CharFormat(const CharFormat& cf) + { + ::CopyMemory(this, &cf, sizeof(CHARFORMAT2)); + } + + // Assign operator + CharFormat& operator =(const CharFormat& cf) + { + ::CopyMemory(this, &cf, sizeof(CHARFORMAT2)); + return (*this); + } + + void Reset() + { + uValue = dwMask = dwEffects = 0; + PropVariantInit(&propvar); + } + + void operator <<(IPropertyStore* pStore) + { + if (pStore == NULL) + { + ATLASSERT(FALSE); + return; + } + + static void (CharFormat::*Getk_[])(IPropertyStore*) = + { + &CharFormat::Getk_Family, + &CharFormat::Getk_FontProperties_Size, + &CharFormat::Getk_MaskEffectBold, + &CharFormat::Getk_MaskEffectItalic, + &CharFormat::Getk_MaskEffectUnderline, + &CharFormat::Getk_MaskEffectStrikeout, + &CharFormat::Getk_VerticalPositioning, + &CharFormat::Getk_Color, + &CharFormat::Getk_ColorBack, + &CharFormat::Getk_ColorType, + &CharFormat::Getk_ColorTypeBack, + }; + + DWORD nProps = 0; + Reset(); + + ATLVERIFY(SUCCEEDED(pStore->GetCount(&nProps))); + for (DWORD iProp = 0; iProp < nProps; iProp++) + { + PROPERTYKEY key; + ATLVERIFY(SUCCEEDED(pStore->GetAt(iProp, &key))); + ATLASSERT(k_(key) >= k_FontProperties_Family); + + if (k_(key) <= k_FontProperties_BackgroundColorType) + (this->*Getk_[k_(key) - k_FontProperties_Family])(pStore); + } + } + + void operator >>(IPropertyStore* pStore) + { + if (pStore == NULL) + { + ATLASSERT(FALSE); + return; + } + + PutFace(pStore); + PutSize(pStore); + PutMaskEffect(CFM_BOLD, CFE_BOLD, UI_PKEY_FontProperties_Bold, pStore); + PutMaskEffect(CFM_ITALIC, CFE_ITALIC, UI_PKEY_FontProperties_Italic, pStore); + PutMaskEffect(CFM_UNDERLINE, CFE_UNDERLINE, UI_PKEY_FontProperties_Underline, pStore); + PutMaskEffect(CFM_STRIKEOUT, CFE_STRIKEOUT, UI_PKEY_FontProperties_Strikethrough, pStore); + PutVerticalPos(pStore); + PutColor(pStore); + PutBackColor(pStore); + } + +private: + PROPVARIANT propvar; + UINT uValue; + + // Getk_ functions + void Getk_Family(IPropertyStore* pStore) + { + if (SUCCEEDED(pStore->GetValue(UI_PKEY_FontProperties_Family, &propvar))) + { + PropVariantToString(propvar, szFaceName, LF_FACESIZE); + if (*szFaceName) + dwMask |= CFM_FACE; + } + } + + void Getk_FontProperties_Size(IPropertyStore* pStore) + { + if (SUCCEEDED(pStore->GetValue(UI_PKEY_FontProperties_Size, &propvar))) + { + DECIMAL decSize = {}; + UIPropertyToDecimal(UI_PKEY_FontProperties_Size, propvar, &decSize); + DOUBLE dSize = 0; + VarR8FromDec(&decSize, &dSize); + if (dSize > 0) + { + dwMask |= CFM_SIZE; + yHeight = (LONG)(dSize * TWIPS_PER_POINT); + } + } + } + + void Getk_MaskEffectBold(IPropertyStore* pStore) + { + Getk_MaskEffectAll(pStore, CFM_BOLD, CFE_BOLD, UI_PKEY_FontProperties_Bold); + } + + void Getk_MaskEffectItalic(IPropertyStore* pStore) + { + Getk_MaskEffectAll(pStore, CFM_ITALIC, CFE_ITALIC, UI_PKEY_FontProperties_Italic); + } + + void Getk_MaskEffectUnderline(IPropertyStore* pStore) + { + Getk_MaskEffectAll(pStore, CFM_UNDERLINE, CFE_UNDERLINE, UI_PKEY_FontProperties_Underline); + } + + void Getk_MaskEffectStrikeout(IPropertyStore* pStore) + { + Getk_MaskEffectAll(pStore, CFM_STRIKEOUT, CFE_STRIKEOUT, UI_PKEY_FontProperties_Strikethrough); + } + + void Getk_MaskEffectAll(IPropertyStore* pStore, DWORD _dwMask, DWORD _dwEffects, REFPROPERTYKEY key) + { + if (SUCCEEDED(pStore->GetValue(key, &propvar))) + { + UIPropertyToUInt32(key, propvar, &uValue); + if ((UI_FONTPROPERTIES)uValue != UI_FONTPROPERTIES_NOTAVAILABLE) + { + dwMask |= _dwMask; + dwEffects |= ((UI_FONTPROPERTIES)uValue == UI_FONTPROPERTIES_SET) ? _dwEffects : 0; + } + } + } + + void Getk_VerticalPositioning(IPropertyStore* pStore) + { + if (SUCCEEDED(pStore->GetValue(UI_PKEY_FontProperties_VerticalPositioning, &propvar))) + { + UIPropertyToUInt32(UI_PKEY_FontProperties_VerticalPositioning, propvar, &uValue); + UI_FONTVERTICALPOSITION uVerticalPosition = (UI_FONTVERTICALPOSITION) uValue; + if ((uVerticalPosition != UI_FONTVERTICALPOSITION_NOTAVAILABLE)) + { + dwMask |= (CFM_SUPERSCRIPT | CFM_SUBSCRIPT); + if (uVerticalPosition != UI_FONTVERTICALPOSITION_NOTSET) + { + dwEffects |= (uVerticalPosition == UI_FONTVERTICALPOSITION_SUPERSCRIPT) ? CFE_SUPERSCRIPT : CFE_SUBSCRIPT; + } + } + } + } + + void Getk_Color(IPropertyStore* pStore) + { + Getk_ColorAll(pStore, CFM_COLOR, UI_PKEY_FontProperties_ForegroundColor); + } + + void Getk_ColorBack(IPropertyStore* pStore) + { + Getk_ColorAll(pStore, CFM_BACKCOLOR, UI_PKEY_FontProperties_BackgroundColor); + } + + void Getk_ColorAll(IPropertyStore* pStore, DWORD _dwMask, REFPROPERTYKEY key) + { + UINT32 color = 0; + if (SUCCEEDED(pStore->GetValue(key, &propvar))) + { + UIPropertyToUInt32(key, propvar, &color); + dwMask |= _dwMask; + + if (_dwMask == CFM_COLOR) + crTextColor = color; + else + crBackColor = color; + } + } + + void Getk_ColorType(IPropertyStore* pStore) + { + Getk_ColorTypeAll(pStore, CFM_COLOR, CFE_AUTOCOLOR, UI_SWATCHCOLORTYPE_AUTOMATIC, UI_PKEY_FontProperties_ForegroundColor); + + } + + void Getk_ColorTypeBack(IPropertyStore* pStore) + { + Getk_ColorTypeAll(pStore, CFM_BACKCOLOR, CFE_AUTOBACKCOLOR, UI_SWATCHCOLORTYPE_NOCOLOR, UI_PKEY_FontProperties_BackgroundColor); + } + + void Getk_ColorTypeAll(IPropertyStore* pStore, DWORD _dwMask, DWORD _dwEffects, UI_SWATCHCOLORTYPE _type, REFPROPERTYKEY key) + { + if (SUCCEEDED(pStore->GetValue(key, &propvar))) + { + UIPropertyToUInt32(key, propvar, &uValue); + if (_type == (UI_SWATCHCOLORTYPE)uValue) + { + dwMask |= _dwMask; + dwEffects |= _dwEffects; + } + } + } + + // Put functions + void PutMaskEffect(WORD dwMaskVal, WORD dwEffectVal, REFPROPERTYKEY key, IPropertyStore* pStore) + { + PROPVARIANT var; + UI_FONTPROPERTIES uProp = UI_FONTPROPERTIES_NOTAVAILABLE; + if ((dwMask & dwMaskVal) != 0) + uProp = dwEffects & dwEffectVal ? UI_FONTPROPERTIES_SET : UI_FONTPROPERTIES_NOTSET; + SetPropertyVal(key, uProp, &var); + pStore->SetValue(key, var); + } + + void PutVerticalPos(IPropertyStore* pStore) + { + PROPVARIANT var; + UI_FONTVERTICALPOSITION uProp = UI_FONTVERTICALPOSITION_NOTAVAILABLE; + + if ((dwMask & CFE_SUBSCRIPT) != 0) + { + if ((dwMask & CFM_SUBSCRIPT) && (dwEffects & CFE_SUBSCRIPT)) + uProp = UI_FONTVERTICALPOSITION_SUBSCRIPT; + else + uProp = UI_FONTVERTICALPOSITION_SUPERSCRIPT; + } + else if ((dwMask & CFM_OFFSET) != 0) + { + if (yOffset > 0) + uProp = UI_FONTVERTICALPOSITION_SUPERSCRIPT; + else if (yOffset < 0) + uProp = UI_FONTVERTICALPOSITION_SUBSCRIPT; + } + + SetPropertyVal(UI_PKEY_FontProperties_VerticalPositioning, uProp, &var); + pStore->SetValue(UI_PKEY_FontProperties_VerticalPositioning, var); + } + + void PutFace(IPropertyStore* pStore) + { + PROPVARIANT var; + SetPropertyVal(UI_PKEY_FontProperties_Family, + dwMask & CFM_FACE ? szFaceName : L"", &var); + pStore->SetValue(UI_PKEY_FontProperties_Family, var); + } + + void PutSize(IPropertyStore* pStore) + { + PROPVARIANT var; + DECIMAL decVal; + + if ((dwMask & CFM_SIZE) != 0) + VarDecFromR8((DOUBLE)yHeight / TWIPS_PER_POINT, &decVal); + else + VarDecFromI4(0, &decVal); + + SetPropertyVal(UI_PKEY_FontProperties_Size, &decVal, &var); + pStore->SetValue(UI_PKEY_FontProperties_Size, var); + } + + void PutColor(IPropertyStore* pStore) + { + if ((dwMask & CFM_COLOR) != 0) + { + if ((dwEffects & CFE_AUTOCOLOR) == 0) + { + SetPropertyVal(UI_PKEY_FontProperties_ForegroundColorType, UI_SWATCHCOLORTYPE_RGB, &propvar); + pStore->SetValue(UI_PKEY_FontProperties_ForegroundColorType, propvar); + + SetPropertyVal(UI_PKEY_FontProperties_ForegroundColor, crTextColor, &propvar); + pStore->SetValue(UI_PKEY_FontProperties_ForegroundColor, propvar); + } + else + { + SetPropertyVal(UI_PKEY_FontProperties_ForegroundColorType, UI_SWATCHCOLORTYPE_AUTOMATIC, &propvar); + pStore->SetValue(UI_PKEY_FontProperties_ForegroundColorType, propvar); + } + } + } + + void PutBackColor(IPropertyStore* pStore) + { + if (((dwMask & CFM_BACKCOLOR) != 0) && ((dwEffects & CFE_AUTOBACKCOLOR) == 0)) + { + SetPropertyVal(UI_PKEY_FontProperties_BackgroundColorType, UI_SWATCHCOLORTYPE_RGB, &propvar); + pStore->SetValue(UI_PKEY_FontProperties_BackgroundColorType, propvar); + + SetPropertyVal(UI_PKEY_FontProperties_BackgroundColor, crBackColor, &propvar); + pStore->SetValue(UI_PKEY_FontProperties_BackgroundColor, propvar); + } + else + { + SetPropertyVal(UI_PKEY_FontProperties_BackgroundColorType, UI_SWATCHCOLORTYPE_NOCOLOR, &propvar); + pStore->SetValue(UI_PKEY_FontProperties_BackgroundColorType, propvar); + } + } +}; + +// IUIImage helper +// +inline IUIImage* GetImage(HBITMAP hbm, UI_OWNERSHIP owner) +{ + ATLASSERT(hbm); + IUIImage* pIUII = NULL; + ATL::CComPtr pIFB; + + if SUCCEEDED(pIFB.CoCreateInstance(CLSID_UIRibbonImageFromBitmapFactory)) + ATLVERIFY(SUCCEEDED(pIFB->CreateImage(hbm, owner, &pIUII))); + + return pIUII; +} + + +/////////////////////////////////////////////////////////////////////////////// +// Ribbon control classes + +// RibbonUI::ICtrl abstract interface of RibbonUI::CRibbonImpl and all RibbonUI control classes +// +struct ICtrl +{ + virtual HRESULT DoExecute(UINT nCmdID, UI_EXECUTIONVERB verb, + const PROPERTYKEY* key, const PROPVARIANT* ppropvarValue, + IUISimplePropertySet* pCommandExecutionProperties) = 0; + + virtual HRESULT DoUpdateProperty(UINT nCmdID, REFPROPERTYKEY key, + const PROPVARIANT* ppropvarCurrentValue, PROPVARIANT* ppropvarNewValue) = 0; +}; + +// RibbonUI::CtrlImpl base class for all ribbon controls +// +template +class ATL_NO_VTABLE CtrlImpl : public ICtrl +{ +protected: + T* m_pWndRibbon; + +public: + typedef T WndRibbon; + + CtrlImpl() : m_pWndRibbon(T::pWndRibbon) + { } + + virtual ~CtrlImpl() + { } + + WndRibbon& GetWndRibbon() + { + return *m_pWndRibbon; + } + + static WORD GetID() + { + return t_ID; + } + + Text m_sTxt[5]; + + // Operations + HRESULT Invalidate() + { + return GetWndRibbon().InvalidateCtrl(GetID()); + } + + HRESULT Invalidate(REFPROPERTYKEY key, UI_INVALIDATIONS flags = UI_INVALIDATIONS_PROPERTY) + { + return GetWndRibbon().InvalidateProperty(GetID(), key, flags); + } + + HRESULT SetText(REFPROPERTYKEY key, LPCWSTR sTxt, bool bUpdate = false) + { + ATLASSERT((k_(key) <= k_TooltipTitle) && (k_(key) >= k_LabelDescription)); + + m_sTxt[k_(key) - k_LabelDescription] = sTxt; + + return bUpdate ? + GetWndRibbon().InvalidateProperty(GetID(), key) : + S_OK; + } + + // Implementation + template + HRESULT SetProperty(REFPROPERTYKEY key, V val) + { + return GetWndRibbon().SetProperty(GetID(), key, val); + } + + HRESULT OnGetText(REFPROPERTYKEY key, PROPVARIANT* ppv) + { + ATLASSERT((k_(key) <= k_TooltipTitle) && (k_(key) >= k_LabelDescription)); + + const INT iText = k_(key) - k_LabelDescription; + if (m_sTxt[iText].IsEmpty()) + if (LPCWSTR sText = GetWndRibbon().OnRibbonQueryText(GetID(), key)) + m_sTxt[iText] = sText; + + return !m_sTxt[iText].IsEmpty() ? + SetPropertyVal(key, (LPCWSTR)m_sTxt[iText], ppv) : + S_OK; + } + + virtual HRESULT DoExecute(UINT nCmdID, UI_EXECUTIONVERB verb, + const PROPERTYKEY* key, const PROPVARIANT* ppropvarValue, + IUISimplePropertySet* pCommandExecutionProperties) + { + ATLASSERT(nCmdID == t_ID); + return GetWndRibbon().DoExecute(nCmdID, verb, key, ppropvarValue, pCommandExecutionProperties); + } + + virtual HRESULT DoUpdateProperty(UINT nCmdID, REFPROPERTYKEY key, + const PROPVARIANT* ppropvarCurrentValue, PROPVARIANT* ppropvarNewValue) + { + ATLASSERT(nCmdID == t_ID); + + const INT iMax = k_TooltipTitle - k_LabelDescription; + const INT iVal = k_(key) - k_LabelDescription; + + return (iVal <= iMax) && (iVal >= 0) ? + OnGetText(key, ppropvarNewValue) : + GetWndRibbon().DoUpdateProperty(nCmdID, key, ppropvarCurrentValue, ppropvarNewValue); + } +}; + +// CommandCtrlImpl base class for most ribbon controls +// +template +class CommandCtrlImpl : public CtrlImpl +{ +public: + CBitmap m_hbm[4]; + + HRESULT SetImage(REFPROPERTYKEY key, HBITMAP hbm, bool bUpdate = false) + { + ATLASSERT((k_(key) <= k_SmallHighContrastImage) && (k_(key) >= k_LargeImage)); + + m_hbm[k_(key) - k_LargeImage].Attach(hbm); + + return bUpdate ? + this->GetWndRibbon().InvalidateProperty(this->GetID(), key) : + S_OK; + } + + HRESULT OnGetImage(REFPROPERTYKEY key, PROPVARIANT* ppv) + { + ATLASSERT((k_(key) <= k_SmallHighContrastImage) && (k_(key) >= k_LargeImage)); + + const INT iImage = k_(key) - k_LargeImage; + + if (m_hbm[iImage].IsNull()) + m_hbm[iImage] = this->GetWndRibbon().OnRibbonQueryImage(this->GetID(), key); + + return m_hbm[iImage].IsNull() ? + E_NOTIMPL : + SetPropertyVal(key, GetImage(m_hbm[iImage], UI_OWNERSHIP_COPY), ppv); + } + + virtual HRESULT DoUpdateProperty(UINT nCmdID, REFPROPERTYKEY key, + const PROPVARIANT* ppropvarCurrentValue, PROPVARIANT* ppropvarNewValue) + { + ATLASSERT (nCmdID == this->GetID()); + + return (k_(key) <= k_SmallHighContrastImage) && (k_(key) >= k_LargeImage) ? + OnGetImage(key, ppropvarNewValue) : + CtrlImpl::DoUpdateProperty(nCmdID, key, ppropvarCurrentValue, ppropvarNewValue); + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// Ribbon collection base classes + +// ItemProperty class: ribbon callback for each item in a collection +// + +#pragma warning(push) +#pragma warning(disable: 4512) // assignment operator could not be generated + +template +class ItemProperty : public IUISimplePropertySet +{ +public: + ItemProperty(UINT i, TCollection* pCollection) : m_Index(i), m_pCollection(pCollection) + { } + + const UINT m_Index; + TCollection* m_pCollection; + + // IUISimplePropertySet method. + STDMETHODIMP GetValue(REFPROPERTYKEY key, PROPVARIANT *value) + { + return m_pCollection->OnGetItem(m_Index, key, value); + } + + // IUnknown methods. + STDMETHODIMP_(ULONG) AddRef() + { + return 1; + } + + STDMETHODIMP_(ULONG) Release() + { + return 1; + } + + STDMETHODIMP QueryInterface(REFIID iid, void** ppv) + { + if ((iid == __uuidof(IUnknown)) || (iid == __uuidof(IUISimplePropertySet))) + { + *ppv = this; + return S_OK; + } + else + { + return E_NOINTERFACE; + } + } +}; + +#pragma warning(pop) + + +// CollectionImplBase: base class for all RibbonUI collections +// +template +class CollectionImplBase +{ + typedef CollectionImplBase thisClass; + +public: + CollectionImplBase() + { + for (int i = 0; i < t_size; i++) + m_apItems[i] = new ItemProperty(i, static_cast(this)); + } + + ~CollectionImplBase() + { + for (int i = 0; i < t_size; i++) + delete m_apItems[i]; + } + +// Data members + ItemProperty* m_apItems[t_size]; +}; + +// CollectionImpl: handles categories and collecton resizing +// +template +class CollectionImpl : public CollectionImplBase, t_items + t_categories> +{ + typedef CollectionImpl thisClass; +public: + typedef thisClass Collection; + + CollectionImpl() : m_size(t_items) + { + ::FillMemory(m_auItemCat, sizeof(m_auItemCat), 0xff); // UI_COLLECTION_INVALIDINDEX + } + + UINT32 m_auItemCat[t_items]; + Text m_asCatName[__max(t_categories, 1)]; + size_t m_size; + +// Operations + HRESULT SetItemCategory(UINT uItem, UINT uCat, bool bUpdate = false) + { + ATLASSERT((uItem < t_items) && (uCat < t_categories)); + + m_auItemCat[uItem] = uCat; + + return bUpdate ? InvalidateItems() : S_OK; + } + + HRESULT SetCategoryText(UINT uCat, LPCWSTR sText, bool bUpdate = false) + { + ATLASSERT(uCat < t_categories); + + m_asCatName[uCat] = sText; + + return bUpdate ? InvalidateCategories() : S_OK; + } + + HRESULT Resize(size_t size, bool bUpdate = false) + { + ATLASSERT(size <= t_items); + + m_size = size; + + return bUpdate ? InvalidateItems() : S_OK; + } + +// Implementation + HRESULT OnGetItem(UINT uIndex, REFPROPERTYKEY key, PROPVARIANT *value) + { + ATLASSERT(uIndex < t_items + t_categories); + TCtrl* pCtrl = static_cast(this); + + return uIndex < t_items ? + pCtrl->DoGetItem(uIndex, key, value) : + pCtrl->DoGetCategory(uIndex - t_items, key, value); + } + + HRESULT DoGetItem(UINT uItem, REFPROPERTYKEY key, PROPVARIANT *value) + { + ATLASSERT(k_(key) == k_CategoryId); + UINT32 uCat = UI_COLLECTION_INVALIDINDEX; + + if (t_categories != 0) + { + if (m_auItemCat[uItem] == UI_COLLECTION_INVALIDINDEX) + { + typename TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); + m_auItemCat[uItem] = ribbon.OnRibbonQueryItemCategory(TCtrl::GetID(), uItem); + } + uCat = m_auItemCat[uItem]; + } + + return SetPropertyVal(key, uCat, value); + } + + HRESULT DoGetCategory(UINT uCat, REFPROPERTYKEY key, PROPVARIANT *value) + { + HRESULT hr = S_OK; + + switch (k_(key)) + { + case k_Label: + if (m_asCatName[uCat].IsEmpty()) + { + typename TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); + m_asCatName[uCat] = ribbon.OnRibbonQueryCategoryText(TCtrl::GetID(), uCat); + } + hr = SetPropertyVal(key, (LPCWSTR)m_asCatName[uCat], value); + break; + case k_CategoryId: + hr = SetPropertyVal(key, uCat, value); + break; + default: + ATLASSERT(FALSE); + break; + } + + return hr; + } + + HRESULT InvalidateItems() + { + return static_cast(this)->Invalidate(UI_PKEY_ItemsSource); + } + + HRESULT InvalidateCategories() + { + return static_cast(this)->Invalidate(UI_PKEY_Categories); + } + + HRESULT DoUpdateProperty(UINT nCmdID, REFPROPERTYKEY key, + const PROPVARIANT* ppropvarCurrentValue, PROPVARIANT* /*ppropvarNewValue*/) + { + ATLASSERT(nCmdID == TCtrl::GetID()); + (void)nCmdID; // avoid level 4 warning + + HRESULT hr = E_NOTIMPL; + switch (k_(key)) + { + case k_ItemsSource: + { + ATL::CComQIPtr pIUICollection(ppropvarCurrentValue->punkVal); + ATLASSERT(pIUICollection); + hr = pIUICollection->Clear(); + for (UINT i = 0; i < m_size; i++) + { + if FAILED(hr = pIUICollection->Add(this->m_apItems[i])) + break; + } + ATLASSERT(SUCCEEDED(hr)); + } + break; + case k_Categories: + if (t_categories != 0) + { + ATL::CComQIPtr pIUICategory(ppropvarCurrentValue->punkVal); + ATLASSERT(pIUICategory.p); + hr = pIUICategory->Clear(); + for (UINT i = t_items; i < (t_items + t_categories); i++) + { + if FAILED(hr = pIUICategory->Add(this->m_apItems[i])) + break; + } + ATLASSERT(SUCCEEDED(hr)); + } + break; + } + + return hr; + } +}; + +// TextCollectionImpl: handles item labels and selection +// +template +class TextCollectionImpl : public CollectionImpl +{ + typedef TextCollectionImpl thisClass; +public: + typedef thisClass TextCollection; + + TextCollectionImpl() : m_uSelected(UI_COLLECTION_INVALIDINDEX) + { } + + Text m_asText[t_items]; + UINT m_uSelected; + + // Operations + HRESULT SetItemText(UINT uItem, LPCWSTR sText, bool bUpdate = false) + { + ATLASSERT(uItem < t_items); + + m_asText[uItem] = sText; + + return bUpdate ? this->InvalidateItems() : S_OK; + } + + UINT GetSelected() + { + return m_uSelected; + } + + HRESULT Select(UINT uItem, bool bUpdate = false) + { + ATLASSERT((uItem < t_items) || (uItem == UI_COLLECTION_INVALIDINDEX)); + + m_uSelected = uItem; + + typename TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); + return bUpdate ? + ribbon.SetProperty(TCtrl::GetID(), UI_PKEY_SelectedItem, uItem) : + S_OK; + } + +// Implementation + HRESULT DoGetItem(UINT uItem, REFPROPERTYKEY key, PROPVARIANT *value) + { + ATLASSERT(uItem < t_items); + + if (k_(key) == k_Label) + { + if (m_asText[uItem].IsEmpty()) + { + typename TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); + m_asText[uItem] = ribbon.OnRibbonQueryItemText(TCtrl::GetID(), uItem); + } + return SetPropertyVal(key, (LPCWSTR)m_asText[uItem], value); + } + else + { + return CollectionImpl::Collection::DoGetItem(uItem, key, value); + } + } + + HRESULT DoUpdateProperty(UINT nCmdID, REFPROPERTYKEY key, + const PROPVARIANT* ppropvarCurrentValue, PROPVARIANT* ppropvarNewValue) + { + ATLASSERT(nCmdID == TCtrl::GetID()); + + if (k_(key) == k_SelectedItem) + { + typename TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); + UINT uSel = UI_COLLECTION_INVALIDINDEX; + if ((m_uSelected == UI_COLLECTION_INVALIDINDEX) && + ribbon.OnRibbonQuerySelectedItem(TCtrl::GetID(), uSel)) + m_uSelected = uSel; + + return SetPropertyVal(key, m_uSelected, ppropvarNewValue); + } + else + { + return CollectionImpl::Collection::DoUpdateProperty(nCmdID, key, ppropvarCurrentValue, ppropvarNewValue); + } + } +}; + +// ItemCollectionImpl: handles item image +// +template +class ItemCollectionImpl : public TextCollectionImpl +{ + typedef ItemCollectionImpl thisClass; +public: + typedef thisClass ItemCollection; + + ItemCollectionImpl() + { + ::ZeroMemory(m_aBitmap, sizeof(m_aBitmap)); + } + + CBitmap m_aBitmap[t_items]; + + // Operations + HRESULT SetItemImage(UINT uIndex, HBITMAP hbm, bool bUpdate = false) + { + ATLASSERT(uIndex < t_items); + + m_aBitmap[uIndex] = hbm; + + return bUpdate ? this->InvalidateItems() : S_OK; + } + +// Implementation + HRESULT DoGetItem(UINT uItem, REFPROPERTYKEY key, PROPVARIANT *value) + { + ATLASSERT(uItem < t_items); + + if (k_(key) == k_ItemImage) + { + if (m_aBitmap[uItem].IsNull()) + { + typename TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); + m_aBitmap[uItem] = ribbon.OnRibbonQueryItemImage(TCtrl::GetID(), uItem); + } + return m_aBitmap[uItem].IsNull() ? + E_NOTIMPL : + SetPropertyVal(key, GetImage(m_aBitmap[uItem], UI_OWNERSHIP_COPY), value); + } + else + { + return TextCollectionImpl::TextCollection::DoGetItem(uItem, key, value); + } + } +}; + +// ComboCollectionImpl: handles combo text +// +template +class ComboCollectionImpl : public ItemCollectionImpl +{ + typedef ComboCollectionImpl thisClass; +public: + typedef thisClass ComboCollection; + + // Operations + HRESULT SetComboText(LPCWSTR sText) + { + typename TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); + return ribbon.IsRibbonUI() ? + ribbon.SetProperty(TCtrl::GetID(), UI_PKEY_StringValue, sText) : + S_OK; + } + + LPCWSTR GetComboText() + { + static WCHAR sCombo[RIBBONUI_MAX_TEXT] = {}; + typename TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); + PROPVARIANT var; + if (ribbon.IsRibbonUI()) + { + HRESULT hr = ribbon.GetIUIFrameworkPtr()->GetUICommandProperty(TCtrl::GetID(), UI_PKEY_StringValue, &var); + hr = PropVariantToString(var, sCombo, RIBBONUI_MAX_TEXT); + return sCombo; + } + return NULL; + } +}; + +// CommandCollectionImpl: handles RibbonUI command collection controls +// +template +class CommandCollectionImpl : public CollectionImpl +{ + typedef CommandCollectionImpl thisClass; +public: + typedef thisClass CommandCollection; + + CommandCollectionImpl() + { + ::ZeroMemory(m_auCmd, sizeof(m_auCmd)); + ::ZeroMemory(m_aCmdType, sizeof(m_aCmdType)); + } + + UINT32 m_auCmd[t_items]; + BYTE m_aCmdType[t_items]; + + // Operations + HRESULT SetItemCommand(UINT uItem, UINT32 uCommandID, bool bUpdate = false) + { + ATLASSERT(uItem < t_items); + + if (uCommandID == m_auCmd[uItem]) + return S_OK; + + typename TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); + + m_auCmd[uItem] = uCommandID; + if (uCommandID != 0) + ribbon.UIAddRibbonElement(uCommandID); + + return bUpdate ? this->InvalidateItems() : S_OK; + } + + HRESULT SetItemCommandType(UINT uItem, UI_COMMANDTYPE type, bool bUpdate = false) + { + ATLASSERT(uItem < t_items); + + m_aCmdType[uItem] = (BYTE)type; + + return bUpdate ? this->InvalidateItems() : S_OK; + } + +// Implementation + HRESULT DoGetItem(UINT uItem, REFPROPERTYKEY key, PROPVARIANT *value) + { + ATLASSERT(uItem < t_items); + typename TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); + + HRESULT hr = E_FAIL; + switch (k_(key)) + { + case k_CommandId: + if (m_auCmd[uItem] == 0) + SetItemCommand(uItem, ribbon.OnRibbonQueryItemCommand(TCtrl::GetID(), uItem)); + hr = SetPropertyVal(key, m_auCmd[uItem], value); + break; + case k_CommandType: + if (m_aCmdType[uItem] == UI_COMMANDTYPE_UNKNOWN) + SetItemCommandType(uItem, ribbon.OnRibbonQueryItemCommandType(TCtrl::GetID(), uItem)); + hr = SetPropertyVal(key, UINT32(m_aCmdType[uItem]), value); + break; + case k_CategoryId: + default: + hr = CollectionImpl::Collection::DoGetItem(uItem, key, value); + break; + } + + return hr; + } + + HRESULT Select(UINT /*uItem*/, bool /*bUpdate*/ = false) + { + ATLASSERT(FALSE); + return S_OK; + } +}; + +// SimpleCollectionImpl: collection class for ribbon simple collection controls +// +template +class SimpleCollectionImpl : public CollectionImplBase, t_size> +{ + typedef SimpleCollectionImpl thisClass; +public: + typedef CollectionImplBase CollectionBase; + typedef thisClass SimpleCollection; + +// Implementation + HRESULT OnGetItem(UINT uItem, REFPROPERTYKEY key, PROPVARIANT *value) + { + ATLASSERT(uItem < t_size); + typename TCtrl::WndRibbon& ribbon = static_cast(this)->GetWndRibbon(); + + HRESULT hr = E_NOTIMPL; + switch (k_(key)) + { + case k_ItemImage: + if (HBITMAP hbm = ribbon.DefRibbonQueryItemImage(TCtrl::GetID(), uItem)) + hr = SetPropertyVal(key, GetImage(hbm, UI_OWNERSHIP_TRANSFER), value); + break; + case k_Label: + if (LPCWSTR sText = ribbon.DefRibbonQueryItemText(TCtrl::GetID(), uItem)) + hr = SetPropertyVal(key, (LPCWSTR)sText, value); + break; + case k_CommandType: + hr = SetPropertyVal(key, t_CommandType, value); + break; + case k_CommandId: + hr = SetPropertyVal(key, ribbon.DefRibbonQueryItemCommand(TCtrl::GetID(), uItem), value); + break; + case k_CategoryId: + hr = SetPropertyVal(key, UI_COLLECTION_INVALIDINDEX, value); + break; + default: + ATLASSERT(FALSE); + break; + } + + return hr; + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// Ribbon collection control classes + +// CollectionCtrlImpl: specializable class for ribbon collection controls +// +template +class CollectionCtrlImpl : public CommandCtrlImpl, public TCollection +{ + typedef CollectionCtrlImpl thisClass; +public: + typedef CommandCtrlImpl CommandCtrl; + typedef TCollection Collection; + + // Implementation + virtual HRESULT DoUpdateProperty(UINT nCmdID, REFPROPERTYKEY key, + const PROPVARIANT* ppropvarCurrentValue, PROPVARIANT* ppropvarNewValue) + { + ATLASSERT(nCmdID == this->GetID()); + ATLASSERT(ppropvarNewValue); + + HRESULT hr = Collection::DoUpdateProperty(nCmdID, key, ppropvarCurrentValue, ppropvarNewValue); + if FAILED(hr) + hr = CommandCtrl::DoUpdateProperty(nCmdID, key, ppropvarCurrentValue, ppropvarNewValue); + + return hr; + } + + virtual HRESULT DoExecute(UINT nCmdID, UI_EXECUTIONVERB verb, + const PROPERTYKEY* key, const PROPVARIANT* ppropvarValue, + IUISimplePropertySet* /*pCommandExecutionProperties*/) + { + ATLASSERT (nCmdID == this->GetID()); + (void)nCmdID; // avoid level4 warning + + if (key == NULL) // gallery button pressed + { + this->GetWndRibbon().OnRibbonItemSelected(this->GetID(), UI_EXECUTIONVERB_EXECUTE, UI_COLLECTION_INVALIDINDEX); + return S_OK; + } + + ATLASSERT(k_(*key) == k_SelectedItem); + ATLASSERT(ppropvarValue); + + HRESULT hr = S_OK; + UINT32 uSel = 0xffff; + hr = UIPropertyToUInt32(*key, *ppropvarValue, &uSel); + + if (SUCCEEDED(hr)) + { + if (this->GetWndRibbon().OnRibbonItemSelected(this->GetID(), verb, uSel)) + TCollection::Select(uSel); + } + + return hr; + } +}; + +// ToolbarGalleryCtrlImpl: base class for ribbon toolbar gallery controls +// +template +class ToolbarGalleryCtrlImpl : public CollectionCtrlImpl, t_size>> +{ +public: + ToolbarGalleryCtrlImpl() + { + CResource tbres; + ATLVERIFY(tbres.Load(RT_TOOLBAR, t_idTB)); + _AtlToolBarData* pData = (_AtlToolBarData*)tbres.Lock(); + ATLASSERT(pData); + ATLASSERT(pData->wVersion == 1); + + WORD* pItems = pData->items(); + INT j = 0; + for (int i = 0; (i < pData->wItemCount) && (j < t_size); i++) + { + if (pItems[i] != 0) + { + this->m_aCmdType[j] = UI_COMMANDTYPE_ACTION; + this->m_auCmd[j++] = pItems[i]; + } + } + + if (j < t_size) + this->Resize(j); + } + + HRESULT DoGetItem(UINT uItem, REFPROPERTYKEY key, PROPVARIANT *value) + { + ATLASSERT(uItem < this->m_size); + ATLASSERT(this->m_auCmd[uItem]); + + HRESULT hr = E_FAIL; + switch (k_(key)) + { + case k_CommandId: + hr = SetPropertyVal(key, this->m_auCmd[uItem], value); + break; + case k_CommandType: + hr = SetPropertyVal(key, UINT32(this->m_aCmdType[uItem]), value); + break; + case k_CategoryId: + hr = SetPropertyVal(key, UI_COLLECTION_INVALIDINDEX, value); + break; + default: + ATLASSERT(FALSE); + break; + } + + return hr; + } +}; + + +// SimpleCollectionCtrlImpl: base class for simple gallery and listbox controls +// +template +class SimpleCollectionCtrlImpl : + public CommandCtrlImpl, + public SimpleCollectionImpl, t_size, t_CommandType> +{ + typedef SimpleCollectionCtrlImpl thisClass; +public: + typedef thisClass SimpleCollection; + + SimpleCollectionCtrlImpl() : m_uSelected(0) + { } + + UINT m_uSelected; + + HRESULT Select(UINT uItem, bool bUpdate = false) + { + ATLASSERT((uItem < t_size) || (uItem == UI_COLLECTION_INVALIDINDEX)); + + m_uSelected = uItem; + + return bUpdate ? + this->GetWndRibbon().SetProperty(this->GetID(), UI_PKEY_SelectedItem, uItem) : + S_OK; + } + + // Implementation + virtual HRESULT DoUpdateProperty(UINT nCmdID, REFPROPERTYKEY key, + const PROPVARIANT* ppropvarCurrentValue, PROPVARIANT* ppropvarNewValue) + { + ATLASSERT(nCmdID == this->GetID()); + ATLASSERT(ppropvarNewValue != NULL); + + HRESULT hr = S_OK; + switch (k_(key)) + { + case k_ItemsSource: + { + ATL::CComQIPtr pIUICollection(ppropvarCurrentValue->punkVal); + ATLASSERT(pIUICollection.p); + hr = pIUICollection->Clear(); + for (UINT i = 0; i < t_size; i++) + { + if FAILED(hr = pIUICollection->Add(this->m_apItems[i])) + break; + } + ATLASSERT(SUCCEEDED(hr)); + } + break; + case k_SelectedItem: + hr = SetPropertyVal(UI_PKEY_SelectedItem, m_uSelected, ppropvarNewValue); + break; + default: + hr = CommandCtrlImpl::DoUpdateProperty(nCmdID, key, ppropvarCurrentValue, ppropvarNewValue); + break; + } + + return hr; + } + + virtual HRESULT DoExecute(UINT nCmdID, UI_EXECUTIONVERB verb, + const PROPERTYKEY* key, const PROPVARIANT* ppropvarValue, + IUISimplePropertySet* /*pCommandExecutionProperties*/) + { + ATLASSERT (nCmdID == this->GetID()); + (void)nCmdID; // avoid level 4 warning + + HRESULT hr = S_OK; + if (key == NULL) // gallery button pressed + { + this->GetWndRibbon().OnRibbonItemSelected(this->GetID(), UI_EXECUTIONVERB_EXECUTE, UI_COLLECTION_INVALIDINDEX); + return hr; + } + ATLASSERT(k_(*key) == k_SelectedItem); + ATLASSERT(ppropvarValue); + + if SUCCEEDED(hr = UIPropertyToUInt32(*key, *ppropvarValue, &m_uSelected)) + this->GetWndRibbon().OnRibbonItemSelected(this->GetID(), verb, m_uSelected); + + return hr; + } +}; + +// RecentItemsCtrlImpl +// +template +class RecentItemsCtrlImpl : + public CtrlImpl, + public CollectionImplBase, TDocList::m_nMaxEntries_Max>, + public TDocList +{ + typedef RecentItemsCtrlImpl thisClass; +public: + typedef thisClass RecentItems; + + // Implementation + HRESULT OnGetItem(UINT uItem, REFPROPERTYKEY key, PROPVARIANT *value) + { + ATLASSERT((INT)uItem < this->GetMaxEntries()); + + LPCWSTR sPath = this->m_arrDocs[uItem].szDocName; + HRESULT hr = E_NOTIMPL; + switch (k_(key)) + { + case k_Label: + hr = SetPropertyVal(key, this->GetWndRibbon().OnRibbonQueryRecentItemName(sPath), value); + break; + case k_LabelDescription: + hr = SetPropertyVal(key, sPath, value); + break; + default: + ATLASSERT(FALSE); + break; + } + + return hr; + } + + virtual HRESULT DoUpdateProperty(UINT nCmdID, REFPROPERTYKEY key, + const PROPVARIANT* ppropvarCurrentValue, PROPVARIANT* ppropvarNewValue) + { + ATLASSERT(nCmdID == this->GetID()); + ATLASSERT(ppropvarNewValue); + + HRESULT hr = S_OK; + switch (k_(key)) + { + case k_RecentItems: + if (SAFEARRAY* psa = SafeArrayCreateVector(VT_UNKNOWN, 0, this->m_arrDocs.GetSize())) + { + const int iLastIndex = this->m_arrDocs.GetSize() - 1; + for (LONG i = 0; i <= iLastIndex; i++) + SafeArrayPutElement(psa, &i, this->m_apItems[iLastIndex - i]); // reverse order + + hr = SetPropertyVal(key, psa, ppropvarNewValue); + SafeArrayDestroy(psa); + } + break; + default: + hr = CtrlImpl::DoUpdateProperty(nCmdID, key, ppropvarCurrentValue, ppropvarNewValue); + break; + } + + return hr; + } + + virtual HRESULT DoExecute(UINT nCmdID, UI_EXECUTIONVERB verb, + const PROPERTYKEY* key, const PROPVARIANT* ppropvarValue, + IUISimplePropertySet* /*pCommandExecutionProperties*/) + { + ATLASSERT(nCmdID == this->GetID()); + (void)nCmdID; // avoid level 4 warning + ATLASSERT(verb == UI_EXECUTIONVERB_EXECUTE); + (void)verb; // avoid level 4 warning + ATLASSERT((key) && (k_(*key) == k_SelectedItem)); + ATLASSERT(ppropvarValue); + + UINT32 uSel = 0xffff; + HRESULT hr = UIPropertyToUInt32(*key, *ppropvarValue, &uSel); + if SUCCEEDED(hr) + { + ATLASSERT(uSel < (UINT)this->GetMaxEntries()); + this->GetWndRibbon().DefCommandExecute(ID_FILE_MRU_FIRST + uSel); + } + + return hr; + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// Ribbon stand-alone control classes + +// FontCtrlImpl +// +template +class FontCtrlImpl : public CtrlImpl +{ +public: + + CharFormat m_cf; + +// Implementation + virtual HRESULT DoExecute(UINT nCmdID, UI_EXECUTIONVERB verb, + const PROPERTYKEY* key, const PROPVARIANT* ppropvarValue, + IUISimplePropertySet* pCommandExecutionProperties) + { + ATLASSERT (nCmdID == this->GetID()); + (void)nCmdID; // avoid level 4 warning + ATLASSERT ((key) && (k_(*key) == k_FontProperties)); + (void)key; // avoid level 4 warning + + HRESULT hr = E_INVALIDARG; + switch (verb) + { + case UI_EXECUTIONVERB_PREVIEW: + case UI_EXECUTIONVERB_EXECUTE: + ATLASSERT(pCommandExecutionProperties); + PROPVARIANT propvar; + + if (SUCCEEDED(hr = pCommandExecutionProperties->GetValue(UI_PKEY_FontProperties_ChangedProperties, &propvar))) + m_cf << ATL::CComQIPtr(propvar.punkVal); + break; + + case UI_EXECUTIONVERB_CANCELPREVIEW: + ATLASSERT(ppropvarValue); + ATL::CComPtr pStore; + + if (SUCCEEDED(hr = UIPropertyToInterface(UI_PKEY_FontProperties, *ppropvarValue, &pStore))) + m_cf << pStore; + break; + } + + if (SUCCEEDED(hr)) + this->GetWndRibbon().OnRibbonFontCtrlExecute(this->GetID(), verb, &m_cf); + else + ATLASSERT(FALSE); + + return hr; + } + + virtual HRESULT DoUpdateProperty(UINT nCmdID, REFPROPERTYKEY key, + const PROPVARIANT* ppropvarCurrentValue, PROPVARIANT* ppropvarNewValue) + { + if ((k_(key) == k_FontProperties) && (this->GetWndRibbon().OnRibbonQueryFont(t_ID, m_cf))) + { + ATL::CComQIPtr pStore(ppropvarCurrentValue->punkVal); + m_cf >> pStore; + return SetPropertyVal(key, pStore.p, ppropvarNewValue); + } + else + { + return CtrlImpl::DoUpdateProperty(nCmdID, key, ppropvarCurrentValue, ppropvarNewValue); + } + } +}; + +// ColorCtrlImpl +// +template +class ColorCtrlImpl : public CommandCtrlImpl +{ +public: + ColorCtrlImpl() : m_colorType(UI_SWATCHCOLORTYPE_NOCOLOR), m_color(0x800080) /*MAGENTA*/ + { } + + UINT32 m_colorType; // value in UI_SWATCHCOLORTYPE + COLORREF m_color; + Text m_sLabels[6]; // k_MoreColorsLabel to k_ThemeColorsCategoryLabel + ATL::CSimpleArray m_aColors[2]; + ATL::CSimpleArray m_aTooltips[2]; + + // Operations + HRESULT SetColor(COLORREF color, bool bUpdate = false) + { + if (m_colorType != UI_SWATCHCOLORTYPE_RGB) + SetColorType(UI_SWATCHCOLORTYPE_RGB, bUpdate); + m_color = color; + return bUpdate ? this->SetProperty(UI_PKEY_Color, color) : S_OK; + } + + HRESULT SetColorType(UI_SWATCHCOLORTYPE type, bool bUpdate = false) + { + m_colorType = type; + return bUpdate ? this->SetProperty(UI_PKEY_ColorType, type) : S_OK; + } + + HRESULT SetColorLabel(REFPROPERTYKEY key, LPCWSTR sLabel, bool bUpdate = false) + { + ATLASSERT((k_(key) >= k_ThemeColorsCategoryLabel) && (k_(key) <= k_MoreColorsLabel)); + m_sLabels[k_(key) - k_ThemeColorsCategoryLabel] = sLabel; + return bUpdate ? this->SetProperty(key, sLabel) : S_OK; + } + + HRESULT SetColorArray(REFPROPERTYKEY key, COLORREF* pColor, bool bUpdate = false) + { + ATLASSERT((k_(key) == k_ThemeColors) || (k_(key) == k_StandardColors)); + + const INT ic = k_(key) - k_ThemeColors; + m_aColors[ic].RemoveAll(); + while (*pColor != 0x800080) /*MAGENTA*/ + m_aColors[ic].Add(*pColor++); + + if (bUpdate) + { + PROPVARIANT var; + if SUCCEEDED(InitPropVariantFromUInt32Vector(m_aColors[ic].GetData(), m_aColors[ic].GetSize(), &var)) + return this->SetProperty(key, var); + else + return E_INVALIDARG; + } + else + { + return S_OK; + } + } + + HRESULT SetColorTooltips(REFPROPERTYKEY key, LPCWSTR* ppsTT, bool bUpdate = false) + { + ATLASSERT((k_(key) == k_ThemeColorsTooltips) || (k_(key) == k_StandardColorsTooltips)); + + const INT ic = k_(key) - k_ThemeColorsTooltips; + m_aTooltips[ic].RemoveAll(); + while (*ppsTT) + m_aTooltips[ic].Add(*ppsTT++); + + if (bUpdate) + { + PROPVARIANT var; + if SUCCEEDED(InitPropVariantFromStringVector(m_aTooltips[ic].GetData(), m_aTooltips[ic].GetSize(), &var)) + return this->SetProperty(key, var); + else + return E_INVALIDARG; + } + else + { + return S_OK; + } + } + + // Implementation + virtual HRESULT DoExecute(UINT nCmdID, UI_EXECUTIONVERB verb, + const PROPERTYKEY* key, const PROPVARIANT* ppropvarValue, + IUISimplePropertySet* pCommandExecutionProperties) + { + ATLASSERT (nCmdID == this->GetID()); + (void)nCmdID; // avoid level 4 warning + ATLASSERT (key && (k_(*key) == k_ColorType)); + (void)key; // avoid level 4 warning + ATLASSERT (ppropvarValue); + + HRESULT hr = PropVariantToUInt32(*ppropvarValue, &m_colorType); + ATLASSERT(SUCCEEDED(hr)); + + if (SUCCEEDED(hr) && (m_colorType == UI_SWATCHCOLORTYPE_RGB)) + { + ATLASSERT(pCommandExecutionProperties); + PROPVARIANT var; + if SUCCEEDED(hr = pCommandExecutionProperties->GetValue(UI_PKEY_Color, &var)) + hr = PropVariantToUInt32(var, &m_color); + } + + if SUCCEEDED(hr) + this->GetWndRibbon().OnRibbonColorCtrlExecute(this->GetID(), verb, (UI_SWATCHCOLORTYPE)m_colorType/*uType*/, m_color); + else + ATLASSERT(FALSE); // something was wrong + + return hr; + } + + virtual HRESULT DoUpdateProperty(UINT nCmdID, REFPROPERTYKEY key, + const PROPVARIANT* ppropvarCurrentValue, PROPVARIANT* ppropvarNewValue) + { + ATLASSERT (nCmdID == this->GetID()); + + HRESULT hr = E_NOTIMPL; + + switch (k_(key)) + { + case k_ColorType: + hr = SetPropertyVal(key, m_colorType, ppropvarNewValue); + break; + case k_Color: + if (m_color == 0x800080) /*MAGENTA*/ + m_color = this->GetWndRibbon().OnRibbonQueryColor(this->GetID()); + hr = SetPropertyVal(key, m_color, ppropvarNewValue); + break; + case k_ColorMode: + break; + case k_ThemeColorsCategoryLabel: + case k_StandardColorsCategoryLabel: + case k_RecentColorsCategoryLabel: + case k_AutomaticColorLabel: + case k_NoColorLabel: + case k_MoreColorsLabel: + { + const UINT iLabel = k_(key) - k_ThemeColorsCategoryLabel; + if (m_sLabels[iLabel].IsEmpty()) + if (LPCWSTR psLabel = this->GetWndRibbon().OnRibbonQueryColorLabel(this->GetID(), key)) + m_sLabels[iLabel] = psLabel; + if (!m_sLabels[iLabel].IsEmpty()) + hr = SetPropertyVal(key, (LPCWSTR)m_sLabels[iLabel], ppropvarNewValue); + } + break; + case k_ThemeColors: + case k_StandardColors: + { + const INT ic = k_(key) - k_ThemeColors; + if (!m_aColors[ic].GetSize()) + if (COLORREF* pColor = this->GetWndRibbon().OnRibbonQueryColorArray(this->GetID(), key)) + SetColorArray(key, pColor); + if (INT iMax = m_aColors[ic].GetSize()) + hr = InitPropVariantFromUInt32Vector(m_aColors[ic].GetData(), iMax, ppropvarNewValue); + } + break; + case k_ThemeColorsTooltips: + case k_StandardColorsTooltips: + { + const INT ic = k_(key) - k_ThemeColorsTooltips; + if (m_aTooltips[ic].GetSize() == 0) + if (LPCWSTR* ppsTT = this->GetWndRibbon().OnRibbonQueryColorTooltips(this->GetID(), key)) + SetColorTooltips(key, ppsTT); + if (INT iMax = m_aTooltips[ic].GetSize()) + hr = InitPropVariantFromStringVector(m_aTooltips[ic].GetData(), iMax, ppropvarNewValue); + } + break; + default: + hr = CommandCtrlImpl::DoUpdateProperty(nCmdID, key, ppropvarCurrentValue, ppropvarNewValue); + break; + } + + return hr; + } +}; + +// SpinnerCtrlImpl +// +template +class SpinnerCtrlImpl : public CtrlImpl +{ +public: + SpinnerCtrlImpl() + { + m_Values[0] = m_Values[2] = m_Values[4] = 0; + m_Values[1] = 100; + m_Values[3] = 1; + } + + V m_Values[5]; + // k_DecimalValue = 201, k_MaxValue = 203, k_MinValue, k_Increment, k_DecimalPlaces + + Text m_FormatString; + Text m_RepresentativeString; + + // Operations + HRESULT SetDecimalPlaces(V vPlaces, bool bUpdate = false) + { + return SetValue(UI_PKEY_DecimalPlaces, vPlaces, bUpdate); + } + + HRESULT SetMin(V vMin, bool bUpdate = false) + { + return SetValue(UI_PKEY_MinValue, vMin, bUpdate); + } + + HRESULT SetMax(V vMax, bool bUpdate = false) + { + return SetValue(UI_PKEY_MaxValue, vMax, bUpdate); + } + + HRESULT SetVal(V vVal, bool bUpdate = false) + { + return SetValue(UI_PKEY_DecimalValue, vVal, bUpdate); + } + + HRESULT SetIncrement(V vIncrement, bool bUpdate = false) + { + return SetValue(UI_PKEY_Increment, vIncrement, bUpdate); + } + + HRESULT SetFormatString(LPCWSTR sFormat, bool bUpdate = false) + { + return SetText(UI_PKEY_FormatString, sFormat, bUpdate); + } + + HRESULT SetRepresentativeString(LPCWSTR sRepresentative, bool bUpdate = false) + { + return SetText(UI_PKEY_RepresentativeString, sRepresentative, bUpdate); + } + + // Implementation + HRESULT SetText(REFPROPERTYKEY key, LPCWSTR sText, bool bUpdate = false) + { + switch (k_(key)) + { + case k_FormatString: + m_FormatString = sText; + break; + case k_RepresentativeString: + m_RepresentativeString = sText; + break; + default: + return CtrlImpl::SetText(key, sText, bUpdate); + } + + return bUpdate ? + this->GetWndRibbon().InvalidateProperty(this->GetID(), key) : + S_OK; + } + + HRESULT SetValue(REFPROPERTYKEY key, V val, bool bUpdate = false) + { + ATLASSERT((k_(key) <= k_DecimalPlaces) && (k_(key) >= k_DecimalValue)); + + const INT iVal = k_(key) == k_DecimalValue ? 0 : k_(key) - k_StringValue; + m_Values[iVal] = val; + + if (bUpdate) + { + if(k_(key) == k_DecimalValue) + { + DECIMAL decVal; + InitDecimal(val, &decVal); + return this->SetProperty(key, &decVal); + } + else + { + return this->GetWndRibbon().InvalidateProperty(this->GetID(), key); + } + } + else + { + return S_OK; + } + } + + HRESULT QueryValue(REFPROPERTYKEY key, LONG* plVal) + { + return this->GetWndRibbon().OnRibbonQuerySpinnerValue(this->GetID(), key, plVal) ? S_OK : S_FALSE; + } + + HRESULT QueryValue(REFPROPERTYKEY key, DOUBLE* pdVal) + { + return this->GetWndRibbon().OnRibbonQueryFloatSpinnerValue(this->GetID(), key, pdVal) ? S_OK : S_FALSE; + } + + HRESULT OnGetValue(REFPROPERTYKEY key, PROPVARIANT* ppv) + { + ATLASSERT((k_(key) <= k_DecimalPlaces) && (k_(key) >= k_DecimalValue)); + + const INT iVal = k_(key) == k_DecimalValue ? 0 : k_(key) - k_StringValue; + + QueryValue(key, m_Values + iVal); + + if (k_(key) == k_DecimalPlaces) + { + return SetPropertyVal(key, m_Values[iVal], ppv); + } + else + { + DECIMAL decVal; + InitDecimal(m_Values[iVal], &decVal); + return SetPropertyVal(key, &decVal, ppv); + } + } + + HRESULT OnGetText(REFPROPERTYKEY key, Text& sVal, PROPVARIANT* ppv) + { + if (LPCWSTR sNew = this->GetWndRibbon().OnRibbonQueryText(this->GetID(), key)) + sVal = sNew; + return SetPropertyVal(key, (LPCWSTR)sVal, ppv); + } + + virtual HRESULT DoExecute(UINT nCmdID, UI_EXECUTIONVERB verb, + const PROPERTYKEY* key, const PROPVARIANT* ppropvarValue, + IUISimplePropertySet* /*pCommandExecutionProperties*/) + { + ATLASSERT (nCmdID == this->GetID()); + (void)nCmdID; // avoid level 4 warning + ATLASSERT (key && (k_(*key) == k_DecimalValue)); + (void)key; // avoid level 4 warning + ATLASSERT (verb == UI_EXECUTIONVERB_EXECUTE); + (void)verb; // avoid level 4 warning + + DECIMAL decVal; + + HRESULT hr = UIPropertyToDecimal(UI_PKEY_DecimalValue, *ppropvarValue, &decVal); + hr = InitVal(m_Values[0], &decVal); + + this->GetWndRibbon().OnRibbonSpinnerCtrlExecute(this->GetID(), &m_Values[0]); + + return hr; + } + + virtual HRESULT DoUpdateProperty(UINT nCmdID, REFPROPERTYKEY key, + const PROPVARIANT* ppropvarCurrentValue, PROPVARIANT* ppropvarNewValue) + { + ATLASSERT (nCmdID == this->GetID()); + + HRESULT hr = E_NOTIMPL; + switch (k_(key)) + { + case k_DecimalPlaces: + case k_DecimalValue: + case k_Increment: + case k_MaxValue: + case k_MinValue: + hr = OnGetValue(key, ppropvarNewValue); + break; + case k_FormatString: + if (m_FormatString.IsEmpty()) + return OnGetText(key, m_FormatString, ppropvarNewValue); + break; + case k_RepresentativeString: + if (m_RepresentativeString.IsEmpty()) + return OnGetText(key, m_RepresentativeString, ppropvarNewValue); + break; + default: + hr = CtrlImpl::DoUpdateProperty(nCmdID, key, ppropvarCurrentValue, ppropvarNewValue); + break; + } + + return hr; + } + + // decimal conversion helpers + static HRESULT InitDecimal(LONG& val, DECIMAL* pDecimal) + { + return ::VarDecFromI4(val, pDecimal); + } + + static HRESULT InitDecimal(DOUBLE& val, DECIMAL* pDecimal) + { + return ::VarDecFromR8(val, pDecimal); + } + + static HRESULT InitVal(LONG& val, const DECIMAL* pDecimal) + { + return ::VarI4FromDec(pDecimal, &val); + } + + static HRESULT InitVal(DOUBLE& val, const DECIMAL* pDecimal) + { + return ::VarR8FromDec(pDecimal, &val); + } +}; + +// CRibbonImpl Ribbon implementation class +// +template +class CRibbonImpl : + public CRibbonUpdateUI, + public ICtrl, + public IUIApplication, + public IUICommandHandler +{ + typedef CRibbonImpl thisClass; +public: + typedef thisClass Ribbon; + typedef T WndRibbon; + + CRibbonImpl() : m_bRibbonUI(false), m_hgRibbonSettings(NULL) + { +#ifdef _DEBUG + m_cRef = 1; +#endif + pWndRibbon = static_cast(this); + HRESULT hr = ::CoInitialize(NULL); + if(SUCCEEDED(hr)) + if (RunTimeHelper::IsRibbonUIAvailable()) + hr = m_pIUIFramework.CoCreateInstance(CLSID_UIRibbonFramework); + else + ATLTRACE2(atlTraceUI, 0, _T("Ribbon UI not available\n")); + + if FAILED(hr) + ATLTRACE2(atlTraceUI, 0, _T("Ribbon construction failed\n")); + + ATLASSERT(SUCCEEDED(hr)); + } + + virtual ~CRibbonImpl() + { + ::GlobalFree(m_hgRibbonSettings); + m_pIUIFramework.Release(); + ::CoUninitialize(); + } + + ICtrl& GetRibbonCtrl(UINT) + { + return static_cast(*this); + } + + ATL::CComPtr m_pIUIFramework; + bool m_bRibbonUI; + HGLOBAL m_hgRibbonSettings; + + bool IsRibbonUI() + { + return m_bRibbonUI; + } + + IUIFramework* GetIUIFrameworkPtr() + { + return m_pIUIFramework; + } + + template + I* GetRibbonViewPtr(UINT32 uID) + { + ATLASSERT(m_pIUIFramework); + ATL::CComPtr pI; + return m_pIUIFramework->GetView(uID, __uuidof(I), (void**) &pI) == S_OK ? + pI : + NULL; + } + + IUIRibbon* GetRibbonPtr() + { + return GetRibbonViewPtr(0); + } + + IUIContextualUI* GetMenuPtr(UINT32 uID) + { + ATLASSERT(uID); + return GetRibbonViewPtr(uID); + } + + UINT GetRibbonHeight() + { + ATLASSERT(IsRibbonUI()); + + UINT32 cy = 0; + if (ATL::CComPtr pIUIRibbon = GetRibbonPtr()) + pIUIRibbon->GetHeight(&cy); + return cy; + } + + HRESULT CreateRibbon(LPCWSTR sResName = L"APPLICATION_RIBBON") + { + T* pT = static_cast(this); + ATLASSERT(GetIUIFrameworkPtr() && !IsRibbonUI()); + ATLASSERT(pT->IsWindow()); + + HRESULT hr = m_pIUIFramework->Initialize(pT->m_hWnd, this); + + if (hr == S_OK) + hr = m_pIUIFramework->LoadUI(ModuleHelper::GetResourceInstance(), sResName); + + return hr; + } + + HRESULT DestroyRibbon() + { + T* pT = static_cast(this); + ATLASSERT(GetIUIFrameworkPtr() && IsRibbonUI()); + ATLASSERT(pT->IsWindow()); + + HRESULT hRes = m_pIUIFramework->Destroy(); + if (!RunTimeHelper::IsWin7()) + pT->SetWindowRgn(NULL, TRUE); // Vista Basic bug workaround + return hRes; + } + +// Ribbon persistency + HRESULT operator >>(IStream* pIStream) + { + ATLASSERT(GetIUIFrameworkPtr()); + ATLASSERT(pIStream); + + HRESULT hr = E_FAIL; + if (ATL::CComPtr pIUIRibbon = GetRibbonPtr()) + { + const LARGE_INTEGER li0 = {}; + pIStream->Seek(li0, STREAM_SEEK_SET, NULL); + hr = pIUIRibbon->SaveSettingsToStream(pIStream); + pIStream->Commit(STGC_DEFAULT); + } + + return hr; + } + + HRESULT operator <<(IStream* pIStream) + { + ATLASSERT(GetIUIFrameworkPtr()); + ATLASSERT(pIStream); + + HRESULT hr = E_FAIL; + if (ATL::CComPtr pIUIRibbon = GetRibbonPtr()) + { + const LARGE_INTEGER li0 = {}; + pIStream->Seek(li0, STREAM_SEEK_SET, NULL); + hr = pIUIRibbon->LoadSettingsFromStream(pIStream); + } + + return hr; + } + + void ResetRibbonSettings() + { + if (m_hgRibbonSettings != NULL) + { + ::GlobalFree(m_hgRibbonSettings); + m_hgRibbonSettings = NULL; + } + } + + HRESULT SaveRibbonSettings() + { + ATLASSERT(GetIUIFrameworkPtr()); + ATLASSERT(static_cast(this)->IsWindow()); + + HRESULT hr = E_FAIL; + ATL::CComPtr pIStream; + + if SUCCEEDED(hr = ::CreateStreamOnHGlobal(m_hgRibbonSettings, FALSE, &pIStream)) + hr = *this >> pIStream; + + if (SUCCEEDED(hr) && (m_hgRibbonSettings == NULL)) + hr = ::GetHGlobalFromStream(pIStream, &m_hgRibbonSettings); + + if FAILED(hr) + ResetRibbonSettings(); + + return hr; + } + + HRESULT RestoreRibbonSettings() + { + ATLASSERT(GetIUIFrameworkPtr()); + ATLASSERT(m_hgRibbonSettings); + ATLASSERT(static_cast(this)->IsWindow()); + + HRESULT hr = E_FAIL; + ATL::CComPtr pIStream; + + if SUCCEEDED(hr = ::CreateStreamOnHGlobal(m_hgRibbonSettings, FALSE, &pIStream)) + hr = *this << pIStream; + + if FAILED(hr) + ResetRibbonSettings(); + + return hr; + } + +// QAT dock states + UI_CONTROLDOCK GetQATDock() + { + ATLASSERT(GetIUIFrameworkPtr()); + ATLASSERT(IsRibbonUI()); + + UINT32 uDock = 0; + PROPVARIANT propvar; + ATL::CComQIPtrpIPS(GetRibbonPtr()); + + if ((pIPS != NULL) && SUCCEEDED(pIPS->GetValue(UI_PKEY_QuickAccessToolbarDock, &propvar)) && + SUCCEEDED(UIPropertyToUInt32(UI_PKEY_QuickAccessToolbarDock, propvar, &uDock))) + return (UI_CONTROLDOCK)uDock; + + ATLASSERT(FALSE); // something was wrong + return (UI_CONTROLDOCK)0; + } + + bool SetQATDock(UI_CONTROLDOCK dockState) + { + ATLASSERT(GetIUIFrameworkPtr()); + ATLASSERT(IsRibbonUI()); + + PROPVARIANT propvar; + ATLVERIFY(SUCCEEDED(SetPropertyVal(UI_PKEY_QuickAccessToolbarDock, dockState, &propvar))); + + ATL::CComQIPtrpIPS(GetRibbonPtr()); + if ((pIPS != NULL) && SUCCEEDED(pIPS->SetValue(UI_PKEY_QuickAccessToolbarDock, propvar))) + { + pIPS->Commit(); + return true; + } + + ATLASSERT(FALSE); // something was wrong + return false; + } + +// Ribbon display states + bool GetRibbonDisplayState(REFPROPERTYKEY key) + { + ATLASSERT(GetIUIFrameworkPtr()); + ATLASSERT(IsRibbonUI()); + ATLASSERT((k_(key) == k_Viewable) || (k_(key) == k_Minimized)); + + PROPVARIANT propvar; + ATL::CComQIPtrpIPS(GetRibbonPtr()); + + if ((pIPS != NULL) && SUCCEEDED(pIPS->GetValue(key, &propvar))) + { + BOOL bState = FALSE; + if SUCCEEDED(UIPropertyToBoolean(key, propvar, &bState)) + return (bState != FALSE); + } + + ATLASSERT(FALSE); // something was wrong + return false; + } + + bool SetRibbonDisplayState(REFPROPERTYKEY key, bool bState = true) + { + ATLASSERT(GetIUIFrameworkPtr()); + ATLASSERT(IsRibbonUI()); + ATLASSERT((k_(key) == k_Viewable) || (k_(key) == k_Minimized)); + + PROPVARIANT propvar; + ATLVERIFY(SUCCEEDED(SetPropertyVal(key, bState, &propvar))); + + ATL::CComQIPtrpIPS(GetRibbonPtr()); + + if ((pIPS != NULL) && SUCCEEDED(pIPS->SetValue(key, propvar))) + { + pIPS->Commit(); + return true; + } + + ATLASSERT(FALSE); // something was wrong + return false; + } + + bool IsRibbonMinimized() + { + return GetRibbonDisplayState(UI_PKEY_Minimized); + } + + bool MinimizeRibbon(bool bMinimize = true) + { + return SetRibbonDisplayState(UI_PKEY_Minimized, bMinimize); + } + + bool IsRibbonHidden() + { + return !GetRibbonDisplayState(UI_PKEY_Viewable); + } + + bool HideRibbon(bool bHide = true) + { + return SetRibbonDisplayState(UI_PKEY_Viewable, !bHide); + } + +// Ribbon colors + UI_HSBCOLOR GetRibbonColor(REFPROPERTYKEY key) + { + ATLASSERT(GetIUIFrameworkPtr()); + ATLASSERT(IsRibbonUI()); + ATLASSERT((k_(key) >= k_GlobalBackgroundColor) && (k_(key) <= k_GlobalTextColor)); + + PROPVARIANT propvar; + ATL::CComQIPtrpIPS(GetIUIFrameworkPtr()); + + if ((pIPS != NULL) && SUCCEEDED(pIPS->GetValue(key, &propvar))) + { + UINT32 color = 0; + if SUCCEEDED(UIPropertyToUInt32(key, propvar, &color)) + return color; + } + + ATLASSERT(FALSE); // something was wrong + return 0; + } + + bool SetRibbonColor(REFPROPERTYKEY key, UI_HSBCOLOR color) + { + ATLASSERT(GetIUIFrameworkPtr()); + ATLASSERT(IsRibbonUI()); + ATLASSERT((k_(key) >= k_GlobalBackgroundColor) && (k_(key) <= k_GlobalTextColor)); + + PROPVARIANT propvar; + ATLVERIFY(SUCCEEDED(SetPropertyVal(key, color, &propvar))); + + ATL::CComQIPtrpIPS(GetIUIFrameworkPtr()); + + if ((pIPS != NULL) && SUCCEEDED(pIPS->SetValue(key, propvar))) + { + pIPS->Commit(); + return true; + } + + ATLASSERT(FALSE); // something was wrong + return false; + } + +// Ribbon modes + HRESULT SetRibbonModes(INT32 iModes) + { + ATLASSERT(IsRibbonUI()); + return GetIUIFrameworkPtr()->SetModes(iModes); + } + +// Ribbon contextual tab + UI_CONTEXTAVAILABILITY GetRibbonContextAvail(UINT32 uID) + { + ATLASSERT(GetIUIFrameworkPtr()); + + PROPVARIANT propvar; + if (IsRibbonUI() && + SUCCEEDED(GetIUIFrameworkPtr()->GetUICommandProperty(uID, UI_PKEY_ContextAvailable, &propvar))) + { + UINT uav; + if (SUCCEEDED(PropVariantToUInt32(propvar, &uav))) + { + CUpdateUIBase::UIEnable(uID, uav != UI_CONTEXTAVAILABILITY_NOTAVAILABLE); + CUpdateUIBase::UISetCheck(uID, uav == UI_CONTEXTAVAILABILITY_ACTIVE); + return (UI_CONTEXTAVAILABILITY)uav; + } + } + + return UI_CONTEXTAVAILABILITY_NOTAVAILABLE; + } + + HRESULT SetRibbonContextAvail(UINT32 uID, UI_CONTEXTAVAILABILITY cav) + { + CUpdateUIBase::UIEnable(uID, cav != UI_CONTEXTAVAILABILITY_NOTAVAILABLE); + CUpdateUIBase::UISetCheck(uID, cav == UI_CONTEXTAVAILABILITY_ACTIVE); + + return SetProperty((WORD)uID, UI_PKEY_ContextAvailable, UINT32(cav)); + } + +// Ribbon context menu + bool HasRibbonMenu(UINT32 uID) + { + ATL::CComPtr pI = GetMenuPtr(uID); + return pI != NULL; + } + + HRESULT TrackRibbonMenu(UINT32 uID, INT32 x, INT32 y) + { + ATLASSERT(HasRibbonMenu(uID)); + + return IsRibbonUI() ? + ATL::CComPtr(GetMenuPtr(uID))->ShowAtLocation(x, y) : + E_FAIL; + } + + HRESULT TrackRibbonMenu(UINT32 uID, LPARAM lParam) + { + return TrackRibbonMenu(uID, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); + } + +// Overrideables + HBITMAP OnRibbonQueryImage(UINT nCmdID, REFPROPERTYKEY /*key*/) + { + return DefRibbonQueryImage(nCmdID); + } + + LPCWSTR OnRibbonQueryText(UINT nCmdID, REFPROPERTYKEY key) + { + return DefRibbonQueryText(nCmdID, key); + } + + bool OnRibbonQueryState(UINT nCmdID, REFPROPERTYKEY key) + { + return DefRibbonQueryState(nCmdID, key); + } + + UI_CONTEXTAVAILABILITY OnRibbonQueryTabAvail(UINT nCmdID) + { + DWORD dwState = this->UIGetState(nCmdID); + return ((dwState & CUpdateUIBase::UPDUI_DISABLED) == CUpdateUIBase::UPDUI_DISABLED) ? + UI_CONTEXTAVAILABILITY_NOTAVAILABLE : + (((dwState & CUpdateUIBase::UPDUI_CHECKED) == CUpdateUIBase::UPDUI_CHECKED) ? + UI_CONTEXTAVAILABILITY_ACTIVE : + UI_CONTEXTAVAILABILITY_AVAILABLE); + } + + LPCWSTR OnRibbonQueryComboText(UINT32 /*uCtrlID*/) + { + return NULL; + } + + LPCWSTR OnRibbonQueryCategoryText(UINT32 /*uCtrlID*/, UINT32 /*uCat*/) + { + return L"Category"; + } + + UINT32 OnRibbonQueryItemCategory(UINT32 /*uCtrlID*/, UINT32 /*uItem*/) + { + return 0; + } + + LPCWSTR OnRibbonQueryItemText(UINT32 uCtrlID, UINT32 uItem) + { + return DefRibbonQueryItemText(uCtrlID, uItem); + } + + bool OnRibbonQuerySelectedItem(UINT32 /*uCtrlID*/, UINT32& /*uSel*/) + { + return false; + } + + HBITMAP OnRibbonQueryItemImage(UINT32 uCtrlID, UINT32 uItem) + { + return DefRibbonQueryItemImage(uCtrlID, uItem); + } + + UINT32 OnRibbonQueryItemCommand(UINT32 uCtrlID, UINT32 uItem) + { + return DefRibbonQueryItemCommand(uCtrlID, uItem); + } + + UI_COMMANDTYPE OnRibbonQueryItemCommandType(UINT32 /*uCtrlID*/, UINT32 /*uItem*/) + { + return UI_COMMANDTYPE_ACTION; + } + + LPCWSTR OnRibbonQueryRecentItemName(LPCWSTR sPath) + { + return ::PathFindFileName(sPath); + } + + bool OnRibbonQueryFont(UINT /*nId*/, CHARFORMAT2& /*cf*/) + { + return false; + } + + bool OnRibbonQuerySpinnerValue(UINT /*nCmdID*/, REFPROPERTYKEY /*key*/, LONG* /*pVal*/) + { + return false; + } + + bool OnRibbonQueryFloatSpinnerValue(UINT /*nCmdID*/, REFPROPERTYKEY /*key*/, DOUBLE* /*pVal*/) + { + return false; + } + + COLORREF OnRibbonQueryColor(UINT /*nCmdID*/) + { + return 0x800080; /*MAGENTA*/ + } + + LPCWSTR OnRibbonQueryColorLabel(UINT /*nCmdID*/, REFPROPERTYKEY /*key*/) + { + return NULL; + } + + COLORREF* OnRibbonQueryColorArray(UINT /*nCmdID*/, REFPROPERTYKEY /*key*/) + { + return NULL; + } + + LPCWSTR* OnRibbonQueryColorTooltips(UINT /*nCmdID*/, REFPROPERTYKEY /*key*/) + { + return NULL; + } + + bool OnRibbonItemSelected(UINT32 uCtrlID, UI_EXECUTIONVERB verb, UINT32 uItem) + { + DefCommandExecute(MAKELONG(uCtrlID, verb), uItem); + return true; + } + + void OnRibbonColorCtrlExecute(UINT32 uCtrlID, UI_EXECUTIONVERB verb, UI_SWATCHCOLORTYPE uType, COLORREF color) + { + DefRibbonColorCtrlExecute(uCtrlID, verb, uType, color); + } + + void OnRibbonFontCtrlExecute(UINT32 uCtrlID, UI_EXECUTIONVERB verb, CHARFORMAT2* pcf) + { + DefCommandExecute(MAKELONG(uCtrlID, verb), (LPARAM)pcf); + } + + void OnRibbonSpinnerCtrlExecute(UINT32 uCtrlID, LONG* pVal) + { + DefCommandExecute(uCtrlID, *pVal); + } + + void OnRibbonSpinnerCtrlExecute(UINT32 uCtrlID, DOUBLE* pVal) + { + DefCommandExecute(uCtrlID, (LPARAM)pVal); + } + + void OnRibbonCommandExecute(UINT32 uCmdID) + { + DefCommandExecute(uCmdID); + } + +// Default implementations + HBITMAP DefRibbonQueryImage(UINT nCmdID) + { + return AtlLoadBitmapImage(nCmdID, LR_CREATEDIBSECTION); + } + + bool DefRibbonQueryState(UINT nCmdID, REFPROPERTYKEY key) + { + DWORD dwState = this->UIGetState(nCmdID); + bool bRet = false; + switch (k_(key)) + { + case k_BooleanValue: + bRet = (dwState & CUpdateUIBase::UPDUI_CHECKED) == CUpdateUIBase::UPDUI_CHECKED; + break; + case k_Enabled: + bRet = (dwState & CUpdateUIBase::UPDUI_DISABLED) != CUpdateUIBase::UPDUI_DISABLED; + break; + default: + ATLASSERT(FALSE); + break; + } + + return bRet; + } + + LPCTSTR DefRibbonQueryText(UINT nCmdID, REFPROPERTYKEY key) + { + static WCHAR sText[RIBBONUI_MAX_TEXT] = {}; + + if (k_(key) == k_Label) + return this->UIGetText(nCmdID); + + if (ATL::AtlLoadString(nCmdID, sText, RIBBONUI_MAX_TEXT)) + { + PWCHAR pTitle = wcschr(sText, L'\n'); + switch (k_(key)) + { + case k_Keytip: + if (PWCHAR pAmp = wcschr(sText, L'&')) + pTitle = pAmp; + if (pTitle != NULL) + *(pTitle + 2) = NULL; // fall through + case k_TooltipTitle: + return pTitle ? ++pTitle : NULL; + case k_TooltipDescription: + case k_LabelDescription: + if (pTitle != NULL) + *pTitle = NULL; + return sText; + } + } + + return NULL; + } + + LPCWSTR DefRibbonQueryItemText(UINT32 uCtrlID, UINT32 uItem) + { + return DefRibbonQueryText(uCtrlID + 1 + uItem, UI_PKEY_LabelDescription); + } + + HBITMAP DefRibbonQueryItemImage(UINT32 uCtrlID, UINT32 uItem) + { + return DefRibbonQueryImage(uCtrlID + 1 + uItem); + } + + UINT32 DefRibbonQueryItemCommand(UINT32 uCtrlID, UINT32 uItem) + { + return uCtrlID + 1 + uItem; + } + + void DefRibbonColorCtrlExecute(UINT32 uCtrlID, UI_EXECUTIONVERB verb, UI_SWATCHCOLORTYPE uType, COLORREF color) + { + switch(uType) + { + case UI_SWATCHCOLORTYPE_RGB: + break; + case UI_SWATCHCOLORTYPE_AUTOMATIC: + color = ::GetSysColor(COLOR_WINDOWTEXT); + break; + case UI_SWATCHCOLORTYPE_NOCOLOR: + color = ::GetSysColor(COLOR_WINDOW); + break; + default: + ATLASSERT(FALSE); + break; + } + + DefCommandExecute(MAKELONG(uCtrlID, verb), color); + } + + void DefCommandExecute(UINT32 uCmd, LPARAM lParam = 0) + { + static_cast(this)->PostMessage(WM_COMMAND, uCmd, lParam); + } + +// Elements setting helpers + HRESULT InvalidateCtrl(UINT32 nID) + { + return IsRibbonUI() ? + GetIUIFrameworkPtr()->InvalidateUICommand(nID, UI_INVALIDATIONS_ALLPROPERTIES, NULL) : + E_FAIL; + } + + HRESULT InvalidateProperty(UINT32 nID, REFPROPERTYKEY key, UI_INVALIDATIONS flags = UI_INVALIDATIONS_PROPERTY) + { + return IsRibbonUI() ? + GetIUIFrameworkPtr()->InvalidateUICommand(nID, flags, &key) : + E_FAIL; + } + + template + HRESULT SetProperty(WORD wID, REFPROPERTYKEY key, V val) + { + if (IsRibbonUI()) + { + PROPVARIANT var; + if (SUCCEEDED(RibbonUI::SetPropertyVal(key, val, &var))) + { + return SetProperty(wID, key, var); + } + return E_INVALIDARG; + } + else + { + return E_FAIL; + } + } + + template <> + HRESULT SetProperty(WORD nID, REFPROPERTYKEY key, PROPVARIANT var) + { + return IsRibbonUI() ? + GetIUIFrameworkPtr()->SetUICommandProperty(nID, key, var) : + E_FAIL; + } + +// Interfaces + // IUIApplication + STDMETHODIMP OnViewChanged(UINT32, UI_VIEWTYPE, IUnknown*, UI_VIEWVERB verb, INT32) + { + switch (verb) + { + case UI_VIEWVERB_CREATE: + m_bRibbonUI = true; + if (m_hgRibbonSettings != NULL) + RestoreRibbonSettings(); + break; + case UI_VIEWVERB_SIZE: + static_cast(this)->UpdateLayout(FALSE); + break; + case UI_VIEWVERB_DESTROY: + SaveRibbonSettings(); + m_bRibbonUI = false; + break; + } + + return S_OK; + } + + STDMETHODIMP OnCreateUICommand(UINT32 nCmdID, UI_COMMANDTYPE typeID, IUICommandHandler** ppCommandHandler) + { + this->UIAddRibbonElement(nCmdID); + if (typeID == UI_COMMANDTYPE_CONTEXT) + CUpdateUIBase::UIEnable(nCmdID, false); + *ppCommandHandler = this; + return S_OK; + } + + STDMETHODIMP OnDestroyUICommand(UINT32 nCmdID, UI_COMMANDTYPE, IUICommandHandler*) + { + this->UIRemoveRibbonElement(nCmdID); + return S_OK; + } + + // IUICommandHandler + STDMETHODIMP Execute(UINT nCmdID, + UI_EXECUTIONVERB verb, + const PROPERTYKEY* key, + const PROPVARIANT* ppropvarValue, + IUISimplePropertySet* pCommandExecutionProperties) + { + T* pT =static_cast(this); + return pT->GetRibbonCtrl(nCmdID).DoExecute(nCmdID, verb, key, ppropvarValue, pCommandExecutionProperties); + } + + STDMETHODIMP UpdateProperty(UINT nCmdID, REFPROPERTYKEY key, + const PROPVARIANT* ppropvarCurrentValue, PROPVARIANT* ppropvarNewValue) + { + T* pT =static_cast(this); + return pT->GetRibbonCtrl(nCmdID).DoUpdateProperty(nCmdID, key, ppropvarCurrentValue, ppropvarNewValue); + } + +#ifdef _DEBUG + // IUnknown methods (heavyweight) + STDMETHODIMP_(ULONG) AddRef() + { + return InterlockedIncrement(&m_cRef); + } + + STDMETHODIMP_(ULONG) Release() + { + LONG cRef = InterlockedDecrement(&m_cRef); + if (cRef == 0) // NoOp for breakpoint + { + cRef = 0; + } + + return cRef; + } + + STDMETHODIMP QueryInterface(REFIID iid, void** ppv) + { + if (ppv == NULL) + { + return E_POINTER; + } + else if ((iid == __uuidof(IUnknown)) || + (iid == __uuidof(IUICommandHandler)) || + (iid == __uuidof(IUIApplication))) + { + *ppv = this; + AddRef(); + return S_OK; + } + else + { + return E_NOINTERFACE; + } + } + + LONG m_cRef; +#else + // IUnknown methods (lightweight) + STDMETHODIMP QueryInterface(REFIID iid, void** ppv) + { + if ((iid == __uuidof(IUnknown)) || + (iid == __uuidof(IUICommandHandler)) || + (iid == __uuidof(IUIApplication))) + { + *ppv = this; + return S_OK; + } + return E_NOINTERFACE; + } + ULONG STDMETHODCALLTYPE AddRef() + { + return 1; + } + ULONG STDMETHODCALLTYPE Release() + { + return 1; + } +#endif + +// CRibbonImpl ICtrl implementation + virtual HRESULT DoExecute(UINT nCmdID, UI_EXECUTIONVERB verb, + const PROPERTYKEY* key, const PROPVARIANT* ppropvarValue, + IUISimplePropertySet* /*pCommandExecutionProperties*/) + { + if (key != NULL) + { + if(k_(*key) != k_BooleanValue) + { + ATLTRACE2(atlTraceUI, 0, _T("Control ID %d is not handled\n"), nCmdID); + return E_NOTIMPL; + } + BOOL bChecked = FALSE; + ATLVERIFY(SUCCEEDED(PropVariantToBoolean(*ppropvarValue, &bChecked))); + CUpdateUIBase::UISetCheck(nCmdID, bChecked); + } + + ATLASSERT(verb == UI_EXECUTIONVERB_EXECUTE); + (void)verb; // avoid level 4 warning + + static_cast(this)->OnRibbonCommandExecute(nCmdID); + + return S_OK; + } + + virtual HRESULT DoUpdateProperty(UINT nCmdID, REFPROPERTYKEY key, + const PROPVARIANT* /*ppropvarCurrentValue*/, PROPVARIANT* ppropvarNewValue) + { + T* pT = static_cast(this); + HRESULT hr = E_NOTIMPL; + switch (k_(key)) + { + case k_LargeImage: + case k_LargeHighContrastImage: + case k_SmallImage: + case k_SmallHighContrastImage: + if (HBITMAP hbm = pT->OnRibbonQueryImage(nCmdID, key)) + hr = SetPropertyVal(key, GetImage(hbm, UI_OWNERSHIP_TRANSFER), ppropvarNewValue); + break; + case k_Label: + case k_Keytip: + case k_TooltipTitle: + case k_TooltipDescription: + case k_LabelDescription: + if (LPCWSTR sText = pT->OnRibbonQueryText(nCmdID, key)) + hr = SetPropertyVal(key, sText, ppropvarNewValue); + break; + case k_BooleanValue: + case k_Enabled: + hr = SetPropertyVal(key, pT->OnRibbonQueryState(nCmdID, key), ppropvarNewValue); + break; + case k_ContextAvailable: + hr = SetPropertyVal(key, pT->OnRibbonQueryTabAvail(nCmdID), ppropvarNewValue); + break; + } + + return hr; + } + +// CRibbonImpl::CRibbonXXXCtrl specialized classes + //CRibbonComboCtrl + template + class CRibbonComboCtrl : public CollectionCtrlImpl, t_items, t_categories>> + { + public: + CRibbonComboCtrl() + { } + }; + + // CRibbonItemGalleryCtrl + template + class CRibbonItemGalleryCtrl : public CollectionCtrlImpl, t_items, t_categories>> + { + public: + CRibbonItemGalleryCtrl() + { } + }; + + // CRibbonCommandGalleryCtrl + template + class CRibbonCommandGalleryCtrl : public CollectionCtrlImpl, t_items, t_categories>> + { + public: + CRibbonCommandGalleryCtrl() + { } + }; + + // CRibbonToolbarGalleryCtrl + template + class CRibbonToolbarGalleryCtrl : public ToolbarGalleryCtrlImpl + { }; + + // CRibbonSimpleComboCtrl + template + class CRibbonSimpleComboCtrl : public SimpleCollectionCtrlImpl + { }; + + // CRibbonSimpleGalleryCtrl + template + class CRibbonSimpleGalleryCtrl : public SimpleCollectionCtrlImpl + { }; + + //CRibbonRecentItemsCtrl + template + class CRibbonRecentItemsCtrl : public RecentItemsCtrlImpl + { + public: + CRibbonRecentItemsCtrl() + { } + }; + + // CRibbonColorCtrl + template + class CRibbonColorCtrl : public ColorCtrlImpl + { + public: + CRibbonColorCtrl() + { } + }; + + //CRibbonFontCtrl + template + class CRibbonFontCtrl : public FontCtrlImpl + { + public: + CRibbonFontCtrl() + { } + }; + + // CRibbonSpinnerCtrl + template + class CRibbonSpinnerCtrl : public SpinnerCtrlImpl + { + public: + CRibbonSpinnerCtrl() + { } + }; + + // CRibbonFloatSpinnerCtrl + template + class CRibbonFloatSpinnerCtrl : public SpinnerCtrlImpl + { + public: + CRibbonFloatSpinnerCtrl() + { + this->m_Values[4] = 1; // 1 decimal + } + }; + + // CRibbonCommandCtrl + template + class CRibbonCommandCtrl : public CommandCtrlImpl + { + public: + CRibbonCommandCtrl() + { } + }; + +// Control classes access to T instance (re-initialized in constructor) + static T* pWndRibbon; +}; + +template +__declspec(selectany) T* CRibbonImpl::pWndRibbon; + +// Control map element +#pragma warning(push) +#pragma warning(disable: 4510 610 4512) // missing default constructor, can't be instatiated, assignment operator could not be generated +typedef struct +{ + UINT uID; + ICtrl& ctrl; +} _ribbonCtrl; +#pragma warning(pop) + +} // namespace RibbonUI + + +/////////////////////////////////////////////////////////////////////////////// +// RibbonUI Control map + +// Control map macros +#define BEGIN_RIBBON_CONTROL_MAP(theClass) \ + WTL::RibbonUI::ICtrl& GetRibbonCtrl(UINT id) \ + { \ + WTL::RibbonUI::_ribbonCtrl _ctrls[] = \ + { + +#define RIBBON_CONTROL(member) {member.GetID(), static_cast(member)}, + +#define END_RIBBON_CONTROL_MAP() \ + {0, *this} \ + }; \ + int i = 0; \ + for(; i < _countof(_ctrls) - 1; i++) \ + if (_ctrls[i].uID == id) \ + break; \ + return _ctrls[i].ctrl; \ +} + +// Control message map macros +#define RIBBON_GALLERY_CONTROL_HANDLER(id, func) \ + if((uMsg == WM_COMMAND) && (id == LOWORD(wParam))) \ + { \ + bHandled = TRUE; \ + lResult = func((UI_EXECUTIONVERB)HIWORD(wParam), LOWORD(wParam), (UINT)lParam, bHandled); \ + if(bHandled) \ + return TRUE; \ + } + +#define RIBBON_COMBO_CONTROL_HANDLER(id, func) \ + RIBBON_GALLERY_CONTROL_HANDLER(id, func) + +#define RIBBON_FONT_CONTROL_HANDLER(id, func) \ + if((uMsg == WM_COMMAND) && (id == LOWORD(wParam))) \ + { \ + bHandled = TRUE; \ + lResult = func((UI_EXECUTIONVERB)HIWORD(wParam), LOWORD(wParam), (CHARFORMAT2*)lParam, bHandled); \ + if(bHandled) \ + return TRUE; \ + } + +#define RIBBON_COLOR_CONTROL_HANDLER(id, func) \ + if((uMsg == WM_COMMAND) && (id == LOWORD(wParam))) \ + { \ + bHandled = TRUE; \ + lResult = func((UI_EXECUTIONVERB)HIWORD(wParam), LOWORD(wParam), (COLORREF)lParam, bHandled); \ + if(bHandled) \ + return TRUE; \ + } + +#define RIBBON_SPINNER_CONTROL_HANDLER(id, func) \ + if((uMsg == WM_COMMAND) && (id == wParam)) \ + { \ + bHandled = TRUE; \ + lResult = func((WORD)wParam, (LONG)lParam, bHandled); \ + if(bHandled) \ + return TRUE; \ + } + +#define RIBBON_FLOATSPINNER_CONTROL_HANDLER(id, func) \ + if((uMsg == WM_COMMAND) && (id == wParam)) \ + { \ + bHandled = TRUE; \ + lResult = func((WORD)wParam, (DOUBLE*)lParam, bHandled); \ + if(bHandled) \ + return TRUE; \ + } + +// Handler prototypes +/* + LRESULT OnRibbonGalleryCtrl(UI_EXECUTIONVERB verb, WORD wID, UINT uSel, BOOL& bHandled); + LRESULT OnRibbonComboCtrl(UI_EXECUTIONVERB verb, WORD wID, UINT uSel, BOOL& bHandled); + LRESULT OnRibbonFontCtrl(UI_EXECUTIONVERB verb, WORD wID, CHARFORMAT2* pcf, BOOL& bHandled); + LRESULT OnRibbonColorCtrl(UI_EXECUTIONVERB verb, WORD wID, COLORREF color, BOOL& bHandled); + LRESULT OnRibbonSpinnerCtrl(WORD wID, LONG lVal, BOOL& bHandled); + LRESULT OnRibbonFloatSpinnerCtrl(WORD wID, DOUBLE* pdVal, BOOL& bHandled); +*/ + + +/////////////////////////////////////////////////////////////////////////////// +// Ribbon frame classes + +// CRibbonFrameWindowImplBase +// +template +class ATL_NO_VTABLE CRibbonFrameWindowImplBase : public TFrameImpl, public RibbonUI::CRibbonImpl +{ + typedef TFrameImpl baseFrame; + bool m_bUseCommandBarBitmaps; + bool m_bWin7Fix; + +public: +// Construction + CRibbonFrameWindowImplBase(bool bUseCommandBarBitmaps = true) : + m_bUseCommandBarBitmaps(bUseCommandBarBitmaps), m_bWin7Fix(false) + { + __if_not_exists(T::m_CmdBar) + { + m_bUseCommandBarBitmaps = false; + } + } + +// Win7 Aero fix helpers + void ResetFrame() + { + const MARGINS margins = { 0, 0, 0, 0 }; + ::DwmExtendFrameIntoClientArea(this->m_hWnd, &margins); + } + + INT CalcWin7Fix() + { + ResetFrame(); + RECT rc = {}; + ::AdjustWindowRectEx(&rc, T::GetWndStyle(0), this->GetMenu() != NULL, T::GetWndExStyle(0)); + return -rc.top; + } + + bool NeedWin7Fix() + { + BOOL bComp = FALSE; + return m_bWin7Fix && RunTimeHelper::IsWin7() && SUCCEEDED(DwmIsCompositionEnabled(&bComp)) && bComp; + } + +// Operations + bool UseCommandBarBitmaps(bool bUse) + { + __if_exists(T::m_CmdBar) + { + return m_bUseCommandBarBitmaps = bUse; + } + __if_not_exists(T::m_CmdBar) + { + (void)bUse; // avoid level 4 warning + return false; + } + } + + bool ShowRibbonUI(bool bShow, INT32 imodes = UI_MAKEAPPMODE(0), LPCWSTR sResName = L"APPLICATION_RIBBON") + { + if (!RunTimeHelper::IsRibbonUIAvailable()) + return false; + + ATLASSERT(this->GetIUIFrameworkPtr()); + + if (this->IsRibbonUI() == bShow) + return bShow; + + bool bVisible = (this->IsWindowVisible() != FALSE); + if(bVisible && !bShow) + this->SetRedraw(FALSE); + + if (bShow && ::IsWindow(this->m_hWndToolBar)) + { + ::ShowWindow(this->m_hWndToolBar, SW_HIDE); + UpdateLayout(); + } + + m_bWin7Fix = !bShow; + + HRESULT hr = bShow ? this->CreateRibbon(sResName) : this->DestroyRibbon(); + + m_bWin7Fix = SUCCEEDED(hr) && !bShow; + + if (SUCCEEDED(hr)) + { + if(::IsWindow(this->m_hWndToolBar) && !bShow) + { + ::ShowWindow(this->m_hWndToolBar, SW_SHOWNA); + UpdateLayout(); + } + else if (bShow) + { + this->PostMessage(WM_SIZE); + this->SetRibbonModes(imodes); + } + } + + if(bVisible && !bShow) + { + this->SetRedraw(TRUE); + this->RedrawWindow(NULL, NULL, RDW_FRAME | RDW_ERASE | RDW_INVALIDATE | RDW_UPDATENOW | RDW_ALLCHILDREN); + } + + return SUCCEEDED(hr) ? bShow : !bShow; + } + +// Overrideables + HBITMAP OnRibbonQueryImage(UINT nCmdID, REFPROPERTYKEY key) + { + if ((key == UI_PKEY_SmallImage) && m_bUseCommandBarBitmaps) + { + if (HBITMAP hbm = GetCommandBarBitmap(nCmdID)) + return (HBITMAP)::CopyImage(hbm, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION); + } + + return this->DefRibbonQueryImage(nCmdID); + } + + BEGIN_MSG_MAP(CRibbonFrameWindowImplBase) + if (!this->IsRibbonUI() && NeedWin7Fix()) + { + MESSAGE_HANDLER(WM_SIZING, OnSizing) + MESSAGE_HANDLER(WM_SIZE, OnSize) + MESSAGE_HANDLER(WM_ACTIVATE, OnActivate) + MESSAGE_HANDLER(WM_NCCALCSIZE, OnNCCalcSize) + } + CHAIN_MSG_MAP(CRibbonUpdateUI) + CHAIN_MSG_MAP(baseFrame) + END_MSG_MAP() + +// Message handlers for Win7 Aero + LRESULT OnSizing(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) + { + switch (wParam) + { + case WMSZ_TOP: + case WMSZ_TOPLEFT: + case WMSZ_TOPRIGHT: + this->SetWindowPos(NULL, (LPRECT)lParam, SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED); + break; + default: + this->DefWindowProc(); + break; + } + + return 1; // handled + } + + LRESULT OnSize(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) + { + if (wParam != SIZE_MINIMIZED) + this->SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); + + bHandled = FALSE; + return 1; + } + + LRESULT OnActivate(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) + { + if(wParam != WA_INACTIVE) + this->SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); + + bHandled = FALSE; + return 1; + } + + LRESULT OnNCCalcSize(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) + { + ATLASSERT(!this->IsRibbonUI() && NeedWin7Fix()); + + LRESULT lRet = this->DefWindowProc(); + + if(wParam) + { + LPNCCALCSIZE_PARAMS pParams = (LPNCCALCSIZE_PARAMS)lParam; + pParams->rgrc[0].top = pParams->rgrc[1].top + CalcWin7Fix(); + } + + return lRet; + } + +// Overrides + void UpdateLayout(BOOL bResizeBars = TRUE) + { + RECT rect = {}; + this->GetClientRect(&rect); + + if (this->IsRibbonUI() && !this->IsRibbonHidden()) + { + rect.top += this->GetRibbonHeight(); + } + else if (!this->IsRibbonUI() && NeedWin7Fix()) + { + ResetFrame(); + } + + // position bars and offset their dimensions + this->UpdateBarsPosition(rect, bResizeBars); + + // resize client window + if(this->m_hWndClient != NULL) + ::SetWindowPos(this->m_hWndClient, NULL, rect.left, rect.top, + rect.right - rect.left, rect.bottom - rect.top, + SWP_NOZORDER | SWP_NOACTIVATE); + } + + // Implementation + HBITMAP GetCommandBarBitmap(UINT nCmdID) + { + __if_exists (T::m_CmdBar) + { + ATLASSERT(RunTimeHelper::IsVista()); + T* pT =static_cast(this); + int nIndex = pT->m_CmdBar.m_arrCommand.Find((WORD&)nCmdID); + return (nIndex == -1) ? NULL : pT->m_CmdBar.m_arrVistaBitmap[nIndex]; + } + __if_not_exists (T::m_CmdBar) + { + (void)nCmdID; // avoid level 4 warning + return NULL; + } + } +}; + +// CRibbonFrameWindowImpl +// +template +class ATL_NO_VTABLE CRibbonFrameWindowImpl : public CRibbonFrameWindowImplBase> +{ }; + +// CRibbonMDIFrameWindowImpl +// +template +class ATL_NO_VTABLE CRibbonMDIFrameWindowImpl : public CRibbonFrameWindowImplBase> +{ }; + + +/////////////////////////////////////////////////////////////////////////////// +// CRibbonPersist helper for RibbonUI persistency + +class CRibbonPersist +{ +public: + CRibbonPersist(LPCWSTR sAppKey) + { + ATLASSERT(sAppKey && *sAppKey); + m_Key.Create(HKEY_CURRENT_USER, sAppKey); + ATLASSERT(m_Key.m_hKey); + } + + ATL::CRegKey m_Key; + + LONG Save(bool bRibbonUI, HGLOBAL hgSettings = NULL) + { + ATL::CRegKey key; + const DWORD dwUI = bRibbonUI; + + LONG lRet = key.Create(m_Key, L"Ribbon"); + if(lRet != ERROR_SUCCESS) + return lRet; + + lRet = key.SetDWORDValue(L"UI", dwUI); + if(lRet != ERROR_SUCCESS) + return lRet; + + if (hgSettings != NULL) + { + LPBYTE pVal = (LPBYTE)::GlobalLock(hgSettings); + if (pVal != NULL) + { + lRet = key.SetBinaryValue(L"Settings", pVal, (ULONG)::GlobalSize(hgSettings)); + ::GlobalUnlock(hgSettings); + } + else + { + lRet = GetLastError(); + } + } + + return lRet; + } + + LONG Restore(bool& bRibbonUI, HGLOBAL& hgSettings) + { + ATLASSERT(hgSettings == NULL); + + ATL::CRegKey key; + + LONG lRet = key.Open(m_Key, L"Ribbon"); + if(lRet != ERROR_SUCCESS) + return lRet; + + DWORD dwUI = 0xffff; + lRet = key.QueryDWORDValue(L"UI", dwUI); + if(lRet == ERROR_SUCCESS) + bRibbonUI = dwUI == 1; + else + return lRet; + + ULONG ulSize = 0; + lRet = key.QueryBinaryValue(L"Settings", NULL, &ulSize); + if (lRet == ERROR_SUCCESS) + { + ATLASSERT(ulSize != 0); + + hgSettings = ::GlobalAlloc(GHND, ulSize); + if (hgSettings != NULL) + { + LPBYTE pData = (LPBYTE)::GlobalLock(hgSettings); + if (pData != NULL) + { + lRet = key.QueryBinaryValue(L"Settings", pData, &ulSize); + } + else + { + lRet = GetLastError(); + ::GlobalFree(hgSettings); + hgSettings = NULL; + } + } + else + { + lRet = GetLastError(); + } + } + return lRet; + } + + LONG Delete() + { + return m_Key.DeleteSubKey(L"Ribbon"); + } +}; + +} // namespace WTL + +#endif // __ATLRIBBON_H__ diff -r e9bb126753e7 -r 20d02a178406 foosdk/wtl/Include/atlscrl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/wtl/Include/atlscrl.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,2127 @@ +// Windows Template Library - WTL version 10.0 +// Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. +// +// This file is a part of the Windows Template Library. +// The use and distribution terms for this software are covered by the +// Microsoft Public License (http://opensource.org/licenses/MS-PL) +// which can be found in the file MS-PL.txt at the root folder. + +#ifndef __ATLSCRL_H__ +#define __ATLSCRL_H__ + +#pragma once + +#ifndef __ATLAPP_H__ + #error atlscrl.h requires atlapp.h to be included first +#endif + +#ifndef __ATLWIN_H__ + #error atlscrl.h requires atlwin.h to be included first +#endif + + +/////////////////////////////////////////////////////////////////////////////// +// Classes in this file: +// +// CScrollImpl +// CScrollWindowImpl +// CMapScrollImpl +// CMapScrollWindowImpl +// CFSBWindowT +// CZoomScrollImpl +// CZoomScrollWindowImpl +// CScrollContainerImpl +// CScrollContainer + +namespace WTL +{ + +/////////////////////////////////////////////////////////////////////////////// +// CScrollImpl - Provides scrolling support to any window + +// Scroll extended styles +#define SCRL_SCROLLCHILDREN 0x00000001 +#define SCRL_ERASEBACKGROUND 0x00000002 +#define SCRL_NOTHUMBTRACKING 0x00000004 +#define SCRL_SMOOTHSCROLL 0x00000008 +#define SCRL_DISABLENOSCROLLV 0x00000010 +#define SCRL_DISABLENOSCROLLH 0x00000020 +#define SCRL_DISABLENOSCROLL (SCRL_DISABLENOSCROLLV | SCRL_DISABLENOSCROLLH) + + +template +class CScrollImpl +{ +public: + enum { uSCROLL_FLAGS = SW_INVALIDATE }; + + POINT m_ptOffset; + SIZE m_sizeAll; + SIZE m_sizeLine; + SIZE m_sizePage; + SIZE m_sizeClient; + int m_zDelta; // current wheel value + int m_nWheelLines; // number of lines to scroll on wheel + int m_zHDelta; // current horizontal wheel value + int m_nHWheelChars; // number of chars to scroll on horizontal wheel + UINT m_uScrollFlags; + DWORD m_dwExtendedStyle; // scroll specific extended styles + +// Constructor + CScrollImpl() : m_zDelta(0), m_nWheelLines(3), + m_zHDelta(0), m_nHWheelChars(3), + m_uScrollFlags(0U), m_dwExtendedStyle(0) + { + m_ptOffset.x = 0; + m_ptOffset.y = 0; + m_sizeAll.cx = 0; + m_sizeAll.cy = 0; + m_sizePage.cx = 0; + m_sizePage.cy = 0; + m_sizeLine.cx = 0; + m_sizeLine.cy = 0; + m_sizeClient.cx = 0; + m_sizeClient.cy = 0; + + SetScrollExtendedStyle(SCRL_SCROLLCHILDREN | SCRL_ERASEBACKGROUND); + } + +// Attributes & Operations + DWORD GetScrollExtendedStyle() const + { + return m_dwExtendedStyle; + } + + DWORD SetScrollExtendedStyle(DWORD dwExtendedStyle, DWORD dwMask = 0) + { + DWORD dwPrevStyle = m_dwExtendedStyle; + if(dwMask == 0) + m_dwExtendedStyle = dwExtendedStyle; + else + m_dwExtendedStyle = (m_dwExtendedStyle & ~dwMask) | (dwExtendedStyle & dwMask); + // cache scroll flags + T* pT = static_cast(this); + (void)pT; // avoid level 4 warning + m_uScrollFlags = pT->uSCROLL_FLAGS | (IsScrollingChildren() ? SW_SCROLLCHILDREN : 0) | (IsErasingBackground() ? SW_ERASE : 0); + m_uScrollFlags |= (IsSmoothScroll() ? SW_SMOOTHSCROLL : 0); + return dwPrevStyle; + } + + // offset operations + void SetScrollOffset(int x, int y, BOOL bRedraw = TRUE) + { + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + + pT->AdjustScrollOffset(x, y); + + int dx = m_ptOffset.x - x; + int dy = m_ptOffset.y - y; + m_ptOffset.x = x; + m_ptOffset.y = y; + + // block: set horizontal scroll bar + { + SCROLLINFO si = { sizeof(SCROLLINFO) }; + si.fMask = SIF_POS; + if((m_dwExtendedStyle & SCRL_DISABLENOSCROLLH) != 0) + si.fMask |= SIF_DISABLENOSCROLL; + si.nPos = m_ptOffset.x; + pT->SetScrollInfo(SB_HORZ, &si, bRedraw); + } + + // block: set vertical scroll bar + { + SCROLLINFO si = { sizeof(SCROLLINFO) }; + si.fMask = SIF_POS; + if((m_dwExtendedStyle & SCRL_DISABLENOSCROLLV) != 0) + si.fMask |= SIF_DISABLENOSCROLL; + si.nPos = m_ptOffset.y; + pT->SetScrollInfo(SB_VERT, &si, bRedraw); + } + + // Move all children if needed + if(IsScrollingChildren() && ((dx != 0) || (dy != 0))) + { + for(HWND hWndChild = ::GetWindow(pT->m_hWnd, GW_CHILD); hWndChild != NULL; hWndChild = ::GetWindow(hWndChild, GW_HWNDNEXT)) + { + RECT rect = {}; + ::GetWindowRect(hWndChild, &rect); + ::MapWindowPoints(NULL, pT->m_hWnd, (LPPOINT)&rect, 1); + ::SetWindowPos(hWndChild, NULL, rect.left + dx, rect.top + dy, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE); + } + } + + if(bRedraw) + pT->Invalidate(); + } + + void SetScrollOffset(POINT ptOffset, BOOL bRedraw = TRUE) + { + SetScrollOffset(ptOffset.x, ptOffset.y, bRedraw); + } + + void GetScrollOffset(POINT& ptOffset) const + { + ptOffset = m_ptOffset; + } + + // size operations + void SetScrollSize(int cx, int cy, BOOL bRedraw = TRUE, bool bResetOffset = true) + { + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + + m_sizeAll.cx = cx; + m_sizeAll.cy = cy; + + int x = 0; + int y = 0; + if(!bResetOffset) + { + x = m_ptOffset.x; + y = m_ptOffset.y; + pT->AdjustScrollOffset(x, y); + } + + int dx = m_ptOffset.x - x; + int dy = m_ptOffset.y - y; + m_ptOffset.x = x; + m_ptOffset.y = y; + + // block: set horizontal scroll bar + { + SCROLLINFO si = { sizeof(SCROLLINFO) }; + si.fMask = SIF_PAGE | SIF_RANGE | SIF_POS; + if((m_dwExtendedStyle & SCRL_DISABLENOSCROLLH) != 0) + si.fMask |= SIF_DISABLENOSCROLL; + si.nMin = 0; + si.nMax = m_sizeAll.cx - 1; + si.nPage = m_sizeClient.cx; + si.nPos = m_ptOffset.x; + pT->SetScrollInfo(SB_HORZ, &si, bRedraw); + } + + // block: set vertical scroll bar + { + SCROLLINFO si = { sizeof(SCROLLINFO) }; + si.fMask = SIF_PAGE | SIF_RANGE | SIF_POS; + if((m_dwExtendedStyle & SCRL_DISABLENOSCROLLV) != 0) + si.fMask |= SIF_DISABLENOSCROLL; + si.nMin = 0; + si.nMax = m_sizeAll.cy - 1; + si.nPage = m_sizeClient.cy; + si.nPos = m_ptOffset.y; + pT->SetScrollInfo(SB_VERT, &si, bRedraw); + } + + // Move all children if needed + if(IsScrollingChildren() && ((dx != 0) || (dy != 0))) + { + for(HWND hWndChild = ::GetWindow(pT->m_hWnd, GW_CHILD); hWndChild != NULL; hWndChild = ::GetWindow(hWndChild, GW_HWNDNEXT)) + { + RECT rect = {}; + ::GetWindowRect(hWndChild, &rect); + ::MapWindowPoints(NULL, pT->m_hWnd, (LPPOINT)&rect, 1); + ::SetWindowPos(hWndChild, NULL, rect.left + dx, rect.top + dy, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE); + } + } + + SetScrollLine(0, 0); + SetScrollPage(0, 0); + + if(bRedraw) + pT->Invalidate(); + } + + void SetScrollSize(SIZE size, BOOL bRedraw = TRUE, bool bResetOffset = true) + { + SetScrollSize(size.cx, size.cy, bRedraw, bResetOffset); + } + + void GetScrollSize(SIZE& sizeWnd) const + { + sizeWnd = m_sizeAll; + } + + // line operations + void SetScrollLine(int cxLine, int cyLine) + { + ATLASSERT((cxLine >= 0) && (cyLine >= 0)); + ATLASSERT((m_sizeAll.cx != 0) && (m_sizeAll.cy != 0)); + + m_sizeLine.cx = T::CalcLineOrPage(cxLine, m_sizeAll.cx, 100); + m_sizeLine.cy = T::CalcLineOrPage(cyLine, m_sizeAll.cy, 100); + } + + void SetScrollLine(SIZE sizeLine) + { + SetScrollLine(sizeLine.cx, sizeLine.cy); + } + + void GetScrollLine(SIZE& sizeLine) const + { + sizeLine = m_sizeLine; + } + + // page operations + void SetScrollPage(int cxPage, int cyPage) + { + ATLASSERT((cxPage >= 0) && (cyPage >= 0)); + ATLASSERT((m_sizeAll.cx != 0) && (m_sizeAll.cy != 0)); + + m_sizePage.cx = T::CalcLineOrPage(cxPage, m_sizeAll.cx, 10); + m_sizePage.cy = T::CalcLineOrPage(cyPage, m_sizeAll.cy, 10); + } + + void SetScrollPage(SIZE sizePage) + { + SetScrollPage(sizePage.cx, sizePage.cy); + } + + void GetScrollPage(SIZE& sizePage) const + { + sizePage = m_sizePage; + } + + // commands + void ScrollLineDown() + { + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + pT->DoScroll(SB_VERT, SB_LINEDOWN, (int&)m_ptOffset.y, m_sizeAll.cy, m_sizePage.cy, m_sizeLine.cy); + } + + void ScrollLineUp() + { + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + pT->DoScroll(SB_VERT, SB_LINEUP, (int&)m_ptOffset.y, m_sizeAll.cy, m_sizePage.cy, m_sizeLine.cy); + } + + void ScrollPageDown() + { + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + pT->DoScroll(SB_VERT, SB_PAGEDOWN, (int&)m_ptOffset.y, m_sizeAll.cy, m_sizePage.cy, m_sizeLine.cy); + } + + void ScrollPageUp() + { + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + pT->DoScroll(SB_VERT, SB_PAGEUP, (int&)m_ptOffset.y, m_sizeAll.cy, m_sizePage.cy, m_sizeLine.cy); + } + + void ScrollTop() + { + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + pT->DoScroll(SB_VERT, SB_TOP, (int&)m_ptOffset.y, m_sizeAll.cy, m_sizePage.cy, m_sizeLine.cy); + } + + void ScrollBottom() + { + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + pT->DoScroll(SB_VERT, SB_BOTTOM, (int&)m_ptOffset.y, m_sizeAll.cy, m_sizePage.cy, m_sizeLine.cy); + } + + void ScrollLineRight() + { + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + pT->DoScroll(SB_HORZ, SB_LINEDOWN, (int&)m_ptOffset.x, m_sizeAll.cx, m_sizePage.cx, m_sizeLine.cx); + } + + void ScrollLineLeft() + { + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + pT->DoScroll(SB_HORZ, SB_LINEUP, (int&)m_ptOffset.x, m_sizeAll.cx, m_sizePage.cx, m_sizeLine.cx); + } + + void ScrollPageRight() + { + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + pT->DoScroll(SB_HORZ, SB_PAGEDOWN, (int&)m_ptOffset.x, m_sizeAll.cx, m_sizePage.cx, m_sizeLine.cx); + } + + void ScrollPageLeft() + { + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + pT->DoScroll(SB_HORZ, SB_PAGEUP, (int&)m_ptOffset.x, m_sizeAll.cx, m_sizePage.cx, m_sizeLine.cx); + } + + void ScrollAllLeft() + { + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + pT->DoScroll(SB_HORZ, SB_TOP, (int&)m_ptOffset.x, m_sizeAll.cx, m_sizePage.cx, m_sizeLine.cx); + } + + void ScrollAllRight() + { + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + pT->DoScroll(SB_HORZ, SB_BOTTOM, (int&)m_ptOffset.x, m_sizeAll.cx, m_sizePage.cx, m_sizeLine.cx); + } + + // scroll to make point/view/window visible + void ScrollToView(POINT pt) + { + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + RECT rect = { pt.x, pt.y, pt.x, pt.y }; + pT->ScrollToView(rect); + } + + void ScrollToView(RECT& rect) + { + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + + RECT rcClient = {}; + pT->GetClientRect(&rcClient); + + int x = m_ptOffset.x; + if(rect.left < m_ptOffset.x) + x = rect.left; + else if(rect.right > (m_ptOffset.x + rcClient.right)) + x = rect.right - rcClient.right; + + int y = m_ptOffset.y; + if(rect.top < m_ptOffset.y) + y = rect.top; + else if(rect.bottom > (m_ptOffset.y + rcClient.bottom)) + y = rect.bottom - rcClient.bottom; + + SetScrollOffset(x, y); + } + + void ScrollToView(HWND hWnd) + { + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + + RECT rect = {}; + ::GetWindowRect(hWnd, &rect); + ::OffsetRect(&rect, m_ptOffset.x, m_ptOffset.y); + ::MapWindowPoints(NULL, pT->m_hWnd, (LPPOINT)&rect, 2); + ScrollToView(rect); + } + + BEGIN_MSG_MAP(CScrollImpl) + MESSAGE_HANDLER(WM_CREATE, OnCreate) + MESSAGE_HANDLER(WM_VSCROLL, OnVScroll) + MESSAGE_HANDLER(WM_HSCROLL, OnHScroll) + MESSAGE_HANDLER(WM_MOUSEWHEEL, OnMouseWheel) + MESSAGE_HANDLER(WM_MOUSEHWHEEL, OnMouseHWheel) + MESSAGE_HANDLER(WM_SETTINGCHANGE, OnSettingChange) + MESSAGE_HANDLER(WM_SIZE, OnSize) + MESSAGE_HANDLER(WM_PAINT, OnPaint) + MESSAGE_HANDLER(WM_PRINTCLIENT, OnPaint) + // standard scroll commands + ALT_MSG_MAP(1) + COMMAND_ID_HANDLER(ID_SCROLL_UP, OnScrollUp) + COMMAND_ID_HANDLER(ID_SCROLL_DOWN, OnScrollDown) + COMMAND_ID_HANDLER(ID_SCROLL_PAGE_UP, OnScrollPageUp) + COMMAND_ID_HANDLER(ID_SCROLL_PAGE_DOWN, OnScrollPageDown) + COMMAND_ID_HANDLER(ID_SCROLL_TOP, OnScrollTop) + COMMAND_ID_HANDLER(ID_SCROLL_BOTTOM, OnScrollBottom) + COMMAND_ID_HANDLER(ID_SCROLL_LEFT, OnScrollLeft) + COMMAND_ID_HANDLER(ID_SCROLL_RIGHT, OnScrollRight) + COMMAND_ID_HANDLER(ID_SCROLL_PAGE_LEFT, OnScrollPageLeft) + COMMAND_ID_HANDLER(ID_SCROLL_PAGE_RIGHT, OnScrollPageRight) + COMMAND_ID_HANDLER(ID_SCROLL_ALL_LEFT, OnScrollAllLeft) + COMMAND_ID_HANDLER(ID_SCROLL_ALL_RIGHT, OnScrollAllRight) + END_MSG_MAP() + + LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) + { + T* pT = static_cast(this); + pT->GetSystemSettings(); + + bHandled = FALSE; + return 1; + } + + LRESULT OnVScroll(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + pT->DoScroll(SB_VERT, (int)(short)LOWORD(wParam), (int&)m_ptOffset.y, m_sizeAll.cy, m_sizePage.cy, m_sizeLine.cy); + return 0; + } + + LRESULT OnHScroll(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + pT->DoScroll(SB_HORZ, (int)(short)LOWORD(wParam), (int&)m_ptOffset.x, m_sizeAll.cx, m_sizePage.cx, m_sizeLine.cx); + return 0; + } + + LRESULT OnMouseWheel(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + + int zDelta = (int)GET_WHEEL_DELTA_WPARAM(wParam); + int nScrollCode = (m_nWheelLines == WHEEL_PAGESCROLL) ? ((zDelta > 0) ? SB_PAGEUP : SB_PAGEDOWN) : ((zDelta > 0) ? SB_LINEUP : SB_LINEDOWN); + m_zDelta += zDelta; // cumulative + int zTotal = (m_nWheelLines == WHEEL_PAGESCROLL) ? abs(m_zDelta) : abs(m_zDelta) * m_nWheelLines; + if(m_sizeAll.cy > m_sizeClient.cy) + { + for(int i = 0; i < zTotal; i += WHEEL_DELTA) + { + pT->DoScroll(SB_VERT, nScrollCode, (int&)m_ptOffset.y, m_sizeAll.cy, m_sizePage.cy, m_sizeLine.cy); + pT->UpdateWindow(); + } + } + else if(m_sizeAll.cx > m_sizeClient.cx) // can't scroll vertically, scroll horizontally + { + for(int i = 0; i < zTotal; i += WHEEL_DELTA) + { + pT->DoScroll(SB_HORZ, nScrollCode, (int&)m_ptOffset.x, m_sizeAll.cx, m_sizePage.cx, m_sizeLine.cx); + pT->UpdateWindow(); + } + } + m_zDelta %= WHEEL_DELTA; + + return 0; + } + + LRESULT OnMouseHWheel(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + + int zDelta = (int)GET_WHEEL_DELTA_WPARAM(wParam); + int nScrollCode = (m_nHWheelChars == WHEEL_PAGESCROLL) ? ((zDelta > 0) ? SB_PAGERIGHT : SB_PAGELEFT) : ((zDelta > 0) ? SB_LINERIGHT : SB_LINELEFT); + m_zHDelta += zDelta; // cumulative + int zTotal = (m_nHWheelChars == WHEEL_PAGESCROLL) ? abs(m_zHDelta) : abs(m_zHDelta) * m_nHWheelChars; + if(m_sizeAll.cx > m_sizeClient.cx) + { + for(int i = 0; i < zTotal; i += WHEEL_DELTA) + { + pT->DoScroll(SB_HORZ, nScrollCode, (int&)m_ptOffset.x, m_sizeAll.cx, m_sizePage.cx, m_sizeLine.cx); + pT->UpdateWindow(); + } + } + m_zHDelta %= WHEEL_DELTA; + + return 0; + } + + LRESULT OnSettingChange(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + GetSystemSettings(); + return 0; + } + + LRESULT OnSize(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled) + { + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + + pT->DoSize(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); + + bHandled = FALSE; + return 1; + } + + LRESULT OnPaint(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + if(wParam != NULL) + { + CDCHandle dc = (HDC)wParam; + POINT ptViewportOrg = { 0, 0 }; + dc.SetViewportOrg(-m_ptOffset.x, -m_ptOffset.y, &ptViewportOrg); + pT->DoPaint(dc); + dc.SetViewportOrg(ptViewportOrg); + } + else + { + CPaintDC dc(pT->m_hWnd); + dc.SetViewportOrg(-m_ptOffset.x, -m_ptOffset.y); + pT->DoPaint(dc.m_hDC); + } + return 0; + } + + // scrolling handlers + LRESULT OnScrollUp(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) + { + ScrollLineUp(); + return 0; + } + + LRESULT OnScrollDown(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) + { + ScrollLineDown(); + return 0; + } + + LRESULT OnScrollPageUp(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) + { + ScrollPageUp(); + return 0; + } + + LRESULT OnScrollPageDown(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) + { + ScrollPageDown(); + return 0; + } + + LRESULT OnScrollTop(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) + { + ScrollTop(); + return 0; + } + + LRESULT OnScrollBottom(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) + { + ScrollBottom(); + return 0; + } + + LRESULT OnScrollLeft(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) + { + ScrollLineLeft(); + return 0; + } + + LRESULT OnScrollRight(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) + { + ScrollLineRight(); + return 0; + } + + LRESULT OnScrollPageLeft(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) + { + ScrollPageLeft(); + return 0; + } + + LRESULT OnScrollPageRight(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) + { + ScrollPageRight(); + return 0; + } + + LRESULT OnScrollAllLeft(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) + { + ScrollAllLeft(); + return 0; + } + + LRESULT OnScrollAllRight(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) + { + ScrollAllRight(); + return 0; + } + +// Overrideables + void DoPaint(CDCHandle /*dc*/) + { + // must be implemented in a derived class + ATLASSERT(FALSE); + } + +// Implementation + void DoSize(int cx, int cy) + { + m_sizeClient.cx = cx; + m_sizeClient.cy = cy; + + T* pT = static_cast(this); + + // block: set horizontal scroll bar + { + SCROLLINFO si = { sizeof(SCROLLINFO) }; + si.fMask = SIF_PAGE | SIF_RANGE | SIF_POS; + si.nMin = 0; + si.nMax = m_sizeAll.cx - 1; + if((m_dwExtendedStyle & SCRL_DISABLENOSCROLLH) != 0) + si.fMask |= SIF_DISABLENOSCROLL; + si.nPage = m_sizeClient.cx; + si.nPos = m_ptOffset.x; + pT->SetScrollInfo(SB_HORZ, &si, TRUE); + } + + // block: set vertical scroll bar + { + SCROLLINFO si = { sizeof(SCROLLINFO) }; + si.fMask = SIF_PAGE | SIF_RANGE | SIF_POS; + si.nMin = 0; + si.nMax = m_sizeAll.cy - 1; + if((m_dwExtendedStyle & SCRL_DISABLENOSCROLLV) != 0) + si.fMask |= SIF_DISABLENOSCROLL; + si.nPage = m_sizeClient.cy; + si.nPos = m_ptOffset.y; + pT->SetScrollInfo(SB_VERT, &si, TRUE); + } + + int x = m_ptOffset.x; + int y = m_ptOffset.y; + if(pT->AdjustScrollOffset(x, y)) + { + // Children will be moved in SetScrollOffset, if needed + pT->ScrollWindowEx(m_ptOffset.x - x, m_ptOffset.y - y, (m_uScrollFlags & ~SCRL_SCROLLCHILDREN)); + SetScrollOffset(x, y, FALSE); + } + } + + void DoScroll(int nType, int nScrollCode, int& cxyOffset, int cxySizeAll, int cxySizePage, int cxySizeLine) + { + T* pT = static_cast(this); + RECT rect = {}; + pT->GetClientRect(&rect); + int cxyClient = (nType == SB_VERT) ? rect.bottom : rect.right; + int cxyMax = cxySizeAll - cxyClient; + + if(cxyMax < 0) // can't scroll, client area is bigger + return; + + bool bUpdate = true; + int cxyScroll = 0; + + switch(nScrollCode) + { + case SB_TOP: // top or all left + cxyScroll = cxyOffset; + cxyOffset = 0; + break; + case SB_BOTTOM: // bottom or all right + cxyScroll = cxyOffset - cxyMax; + cxyOffset = cxyMax; + break; + case SB_LINEUP: // line up or line left + if(cxyOffset >= cxySizeLine) + { + cxyScroll = cxySizeLine; + cxyOffset -= cxySizeLine; + } + else + { + cxyScroll = cxyOffset; + cxyOffset = 0; + } + break; + case SB_LINEDOWN: // line down or line right + if(cxyOffset < cxyMax - cxySizeLine) + { + cxyScroll = -cxySizeLine; + cxyOffset += cxySizeLine; + } + else + { + cxyScroll = cxyOffset - cxyMax; + cxyOffset = cxyMax; + } + break; + case SB_PAGEUP: // page up or page left + if(cxyOffset >= cxySizePage) + { + cxyScroll = cxySizePage; + cxyOffset -= cxySizePage; + } + else + { + cxyScroll = cxyOffset; + cxyOffset = 0; + } + break; + case SB_PAGEDOWN: // page down or page right + if(cxyOffset < cxyMax - cxySizePage) + { + cxyScroll = -cxySizePage; + cxyOffset += cxySizePage; + } + else + { + cxyScroll = cxyOffset - cxyMax; + cxyOffset = cxyMax; + } + break; + case SB_THUMBTRACK: + if(IsNoThumbTracking()) + break; + // else fall through + case SB_THUMBPOSITION: + { + SCROLLINFO si = { sizeof(SCROLLINFO), SIF_TRACKPOS }; + if(pT->GetScrollInfo(nType, &si)) + { + cxyScroll = cxyOffset - si.nTrackPos; + cxyOffset = si.nTrackPos; + } + } + break; + case SB_ENDSCROLL: + default: + bUpdate = false; + break; + } + + if(bUpdate && (cxyScroll != 0)) + { + pT->SetScrollPos(nType, cxyOffset, TRUE); + if(nType == SB_VERT) + pT->ScrollWindowEx(0, cxyScroll, m_uScrollFlags); + else + pT->ScrollWindowEx(cxyScroll, 0, m_uScrollFlags); + } + } + + static int CalcLineOrPage(int nVal, int nMax, int nDiv) + { + if(nVal == 0) + { + nVal = nMax / nDiv; + if(nVal < 1) + nVal = 1; + } + else if(nVal > nMax) + { + nVal = nMax; + } + + return nVal; + } + + bool AdjustScrollOffset(int& x, int& y) + { + int xOld = x; + int yOld = y; + + int cxMax = m_sizeAll.cx - m_sizeClient.cx; + if(x > cxMax) + x = (cxMax >= 0) ? cxMax : 0; + else if(x < 0) + x = 0; + + int cyMax = m_sizeAll.cy - m_sizeClient.cy; + if(y > cyMax) + y = (cyMax >= 0) ? cyMax : 0; + else if(y < 0) + y = 0; + + return ((x != xOld) || (y != yOld)); + } + + void GetSystemSettings() + { + ::SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &m_nWheelLines, 0); + +#ifndef SPI_GETWHEELSCROLLCHARS + const UINT SPI_GETWHEELSCROLLCHARS = 0x006C; +#endif + ::SystemParametersInfo(SPI_GETWHEELSCROLLCHARS, 0, &m_nHWheelChars, 0); + } + + bool IsScrollingChildren() const + { + return (m_dwExtendedStyle & SCRL_SCROLLCHILDREN) != 0; + } + + bool IsErasingBackground() const + { + return (m_dwExtendedStyle & SCRL_ERASEBACKGROUND) != 0; + } + + bool IsNoThumbTracking() const + { + return (m_dwExtendedStyle & SCRL_NOTHUMBTRACKING) != 0; + } + + bool IsSmoothScroll() const + { + return (m_dwExtendedStyle & SCRL_SMOOTHSCROLL) != 0; + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CScrollWindowImpl - Implements a scrollable window + +template +class ATL_NO_VTABLE CScrollWindowImpl : public ATL::CWindowImpl, public CScrollImpl< T > +{ +public: + BOOL SubclassWindow(HWND hWnd) + { + BOOL bRet = ATL::CWindowImpl< T, TBase, TWinTraits >::SubclassWindow(hWnd); + if(bRet != FALSE) + { + T* pT = static_cast(this); + pT->GetSystemSettings(); + + RECT rect = {}; + this->GetClientRect(&rect); + pT->DoSize(rect.right, rect.bottom); + } + + return bRet; + } + + BEGIN_MSG_MAP(CScrollWindowImpl) + MESSAGE_HANDLER(WM_VSCROLL, CScrollImpl< T >::OnVScroll) + MESSAGE_HANDLER(WM_HSCROLL, CScrollImpl< T >::OnHScroll) + MESSAGE_HANDLER(WM_MOUSEWHEEL, CScrollImpl< T >::OnMouseWheel) + MESSAGE_HANDLER(WM_MOUSEHWHEEL, CScrollImpl< T >::OnMouseHWheel) + MESSAGE_HANDLER(WM_SETTINGCHANGE, CScrollImpl< T >::OnSettingChange) + MESSAGE_HANDLER(WM_SIZE, CScrollImpl< T >::OnSize) + MESSAGE_HANDLER(WM_PAINT, CScrollImpl< T >::OnPaint) + MESSAGE_HANDLER(WM_PRINTCLIENT, CScrollImpl< T >::OnPaint) + ALT_MSG_MAP(1) + COMMAND_ID_HANDLER(ID_SCROLL_UP, CScrollImpl< T >::OnScrollUp) + COMMAND_ID_HANDLER(ID_SCROLL_DOWN, CScrollImpl< T >::OnScrollDown) + COMMAND_ID_HANDLER(ID_SCROLL_PAGE_UP, CScrollImpl< T >::OnScrollPageUp) + COMMAND_ID_HANDLER(ID_SCROLL_PAGE_DOWN, CScrollImpl< T >::OnScrollPageDown) + COMMAND_ID_HANDLER(ID_SCROLL_TOP, CScrollImpl< T >::OnScrollTop) + COMMAND_ID_HANDLER(ID_SCROLL_BOTTOM, CScrollImpl< T >::OnScrollBottom) + COMMAND_ID_HANDLER(ID_SCROLL_LEFT, CScrollImpl< T >::OnScrollLeft) + COMMAND_ID_HANDLER(ID_SCROLL_RIGHT, CScrollImpl< T >::OnScrollRight) + COMMAND_ID_HANDLER(ID_SCROLL_PAGE_LEFT, CScrollImpl< T >::OnScrollPageLeft) + COMMAND_ID_HANDLER(ID_SCROLL_PAGE_RIGHT, CScrollImpl< T >::OnScrollPageRight) + COMMAND_ID_HANDLER(ID_SCROLL_ALL_LEFT, CScrollImpl< T >::OnScrollAllLeft) + COMMAND_ID_HANDLER(ID_SCROLL_ALL_RIGHT, CScrollImpl< T >::OnScrollAllRight) + END_MSG_MAP() +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CMapScrollImpl - Provides mapping and scrolling support to any window + +template +class CMapScrollImpl : public CScrollImpl< T > +{ +public: + int m_nMapMode; + RECT m_rectLogAll; + SIZE m_sizeLogLine; + SIZE m_sizeLogPage; + +// Constructor + CMapScrollImpl() : m_nMapMode(MM_TEXT) + { + ::SetRectEmpty(&m_rectLogAll); + m_sizeLogPage.cx = 0; + m_sizeLogPage.cy = 0; + m_sizeLogLine.cx = 0; + m_sizeLogLine.cy = 0; + } + +// Attributes & Operations + // mapping mode operations + void SetScrollMapMode(int nMapMode) + { + ATLASSERT((nMapMode >= MM_MIN) && (nMapMode <= MM_MAX_FIXEDSCALE)); + m_nMapMode = nMapMode; + } + + int GetScrollMapMode() const + { + ATLASSERT((m_nMapMode >= MM_MIN) && (m_nMapMode <= MM_MAX_FIXEDSCALE)); + return m_nMapMode; + } + + // offset operations + void SetScrollOffset(int x, int y, BOOL bRedraw = TRUE) + { + ATLASSERT((m_nMapMode >= MM_MIN) && (m_nMapMode <= MM_MAX_FIXEDSCALE)); + POINT ptOff = { x, y }; + // block: convert logical to device units + { + CWindowDC dc(NULL); + dc.SetMapMode(m_nMapMode); + dc.LPtoDP(&ptOff); + } + CScrollImpl< T >::SetScrollOffset(ptOff, bRedraw); + } + + void SetScrollOffset(POINT ptOffset, BOOL bRedraw = TRUE) + { + SetScrollOffset(ptOffset.x, ptOffset.y, bRedraw); + } + + void GetScrollOffset(POINT& ptOffset) const + { + ATLASSERT((m_nMapMode >= MM_MIN) && (m_nMapMode <= MM_MAX_FIXEDSCALE)); + ptOffset = this->m_ptOffset; + // block: convert device to logical units + { + CWindowDC dc(NULL); + dc.SetMapMode(m_nMapMode); + dc.DPtoLP(&ptOffset); + } + } + + // size operations + void SetScrollSize(int xMin, int yMin, int xMax, int yMax, BOOL bRedraw = TRUE, bool bResetOffset = true) + { + ATLASSERT((xMax > xMin) && (yMax > yMin)); + ATLASSERT((m_nMapMode >= MM_MIN) && (m_nMapMode <= MM_MAX_FIXEDSCALE)); + + ::SetRect(&m_rectLogAll, xMin, yMin, xMax, yMax); + + SIZE sizeAll = {}; + sizeAll.cx = xMax - xMin + 1; + sizeAll.cy = yMax - yMin + 1; + // block: convert logical to device units + { + CWindowDC dc(NULL); + dc.SetMapMode(m_nMapMode); + dc.LPtoDP(&sizeAll); + } + CScrollImpl< T >::SetScrollSize(sizeAll, bRedraw, bResetOffset); + SetScrollLine(0, 0); + SetScrollPage(0, 0); + } + + void SetScrollSize(RECT& rcScroll, BOOL bRedraw = TRUE, bool bResetOffset = true) + { + SetScrollSize(rcScroll.left, rcScroll.top, rcScroll.right, rcScroll.bottom, bRedraw, bResetOffset); + } + + void SetScrollSize(int cx, int cy, BOOL bRedraw = TRUE, bool bResetOffset = true) + { + SetScrollSize(0, 0, cx, cy, bRedraw, bResetOffset); + } + + void SetScrollSize(SIZE size, BOOL bRedraw = TRUE, bool bResetOffset = true) + { + SetScrollSize(0, 0, size.cx, size.cy, bRedraw, bResetOffset); + } + + void GetScrollSize(RECT& rcScroll) const + { + ATLASSERT((m_nMapMode >= MM_MIN) && (m_nMapMode <= MM_MAX_FIXEDSCALE)); + rcScroll = m_rectLogAll; + } + + // line operations + void SetScrollLine(int cxLine, int cyLine) + { + ATLASSERT((cxLine >= 0) && (cyLine >= 0)); + ATLASSERT((m_nMapMode >= MM_MIN) && (m_nMapMode <= MM_MAX_FIXEDSCALE)); + + m_sizeLogLine.cx = cxLine; + m_sizeLogLine.cy = cyLine; + SIZE sizeLine = m_sizeLogLine; + // block: convert logical to device units + { + CWindowDC dc(NULL); + dc.SetMapMode(m_nMapMode); + dc.LPtoDP(&sizeLine); + } + CScrollImpl< T >::SetScrollLine(sizeLine); + } + + void SetScrollLine(SIZE sizeLine) + { + SetScrollLine(sizeLine.cx, sizeLine.cy); + } + + void GetScrollLine(SIZE& sizeLine) const + { + ATLASSERT((m_nMapMode >= MM_MIN) && (m_nMapMode <= MM_MAX_FIXEDSCALE)); + sizeLine = m_sizeLogLine; + } + + // page operations + void SetScrollPage(int cxPage, int cyPage) + { + ATLASSERT((cxPage >= 0) && (cyPage >= 0)); + ATLASSERT((m_nMapMode >= MM_MIN) && (m_nMapMode <= MM_MAX_FIXEDSCALE)); + + m_sizeLogPage.cx = cxPage; + m_sizeLogPage.cy = cyPage; + SIZE sizePage = m_sizeLogPage; + // block: convert logical to device units + { + CWindowDC dc(NULL); + dc.SetMapMode(m_nMapMode); + dc.LPtoDP(&sizePage); + } + CScrollImpl< T >::SetScrollPage(sizePage); + } + + void SetScrollPage(SIZE sizePage) + { + SetScrollPage(sizePage.cx, sizePage.cy); + } + + void GetScrollPage(SIZE& sizePage) const + { + ATLASSERT((m_nMapMode >= MM_MIN) && (m_nMapMode <= MM_MAX_FIXEDSCALE)); + sizePage = m_sizeLogPage; + } + + BEGIN_MSG_MAP(CMapScrollImpl) + MESSAGE_HANDLER(WM_VSCROLL, CScrollImpl< T >::OnVScroll) + MESSAGE_HANDLER(WM_HSCROLL, CScrollImpl< T >::OnHScroll) + MESSAGE_HANDLER(WM_MOUSEWHEEL, CScrollImpl< T >::OnMouseWheel) + MESSAGE_HANDLER(WM_MOUSEHWHEEL, CScrollImpl< T >::OnMouseHWheel) + MESSAGE_HANDLER(WM_SETTINGCHANGE, CScrollImpl< T >::OnSettingChange) + MESSAGE_HANDLER(WM_SIZE, CScrollImpl< T >::OnSize) + MESSAGE_HANDLER(WM_PAINT, OnPaint) + MESSAGE_HANDLER(WM_PRINTCLIENT, OnPaint) + ALT_MSG_MAP(1) + COMMAND_ID_HANDLER(ID_SCROLL_UP, CScrollImpl< T >::OnScrollUp) + COMMAND_ID_HANDLER(ID_SCROLL_DOWN, CScrollImpl< T >::OnScrollDown) + COMMAND_ID_HANDLER(ID_SCROLL_PAGE_UP, CScrollImpl< T >::OnScrollPageUp) + COMMAND_ID_HANDLER(ID_SCROLL_PAGE_DOWN, CScrollImpl< T >::OnScrollPageDown) + COMMAND_ID_HANDLER(ID_SCROLL_TOP, CScrollImpl< T >::OnScrollTop) + COMMAND_ID_HANDLER(ID_SCROLL_BOTTOM, CScrollImpl< T >::OnScrollBottom) + COMMAND_ID_HANDLER(ID_SCROLL_LEFT, CScrollImpl< T >::OnScrollLeft) + COMMAND_ID_HANDLER(ID_SCROLL_RIGHT, CScrollImpl< T >::OnScrollRight) + COMMAND_ID_HANDLER(ID_SCROLL_PAGE_LEFT, CScrollImpl< T >::OnScrollPageLeft) + COMMAND_ID_HANDLER(ID_SCROLL_PAGE_RIGHT, CScrollImpl< T >::OnScrollPageRight) + COMMAND_ID_HANDLER(ID_SCROLL_ALL_LEFT, CScrollImpl< T >::OnScrollAllLeft) + COMMAND_ID_HANDLER(ID_SCROLL_ALL_RIGHT, CScrollImpl< T >::OnScrollAllRight) + END_MSG_MAP() + + LRESULT OnPaint(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + if(wParam != NULL) + { + CDCHandle dc = (HDC)wParam; + int nMapModeSav = dc.GetMapMode(); + dc.SetMapMode(m_nMapMode); + POINT ptViewportOrg = { 0, 0 }; + if(m_nMapMode == MM_TEXT) + dc.SetViewportOrg(-this->m_ptOffset.x, -this->m_ptOffset.y, &ptViewportOrg); + else + dc.SetViewportOrg(-this->m_ptOffset.x, -this->m_ptOffset.y + this->m_sizeAll.cy, &ptViewportOrg); + POINT ptWindowOrg = { 0, 0 }; + dc.SetWindowOrg(m_rectLogAll.left, m_rectLogAll.top, &ptWindowOrg); + + pT->DoPaint(dc); + + dc.SetMapMode(nMapModeSav); + dc.SetViewportOrg(ptViewportOrg); + dc.SetWindowOrg(ptWindowOrg); + } + else + { + CPaintDC dc(pT->m_hWnd); + dc.SetMapMode(m_nMapMode); + if(m_nMapMode == MM_TEXT) + dc.SetViewportOrg(-this->m_ptOffset.x, -this->m_ptOffset.y); + else + dc.SetViewportOrg(-this->m_ptOffset.x, -this->m_ptOffset.y + this->m_sizeAll.cy); + dc.SetWindowOrg(m_rectLogAll.left, m_rectLogAll.top); + pT->DoPaint(dc.m_hDC); + } + return 0; + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CMapScrollWindowImpl - Implements scrolling window with mapping + +template +class ATL_NO_VTABLE CMapScrollWindowImpl : public ATL::CWindowImpl< T, TBase, TWinTraits >, public CMapScrollImpl< T > +{ +public: + BOOL SubclassWindow(HWND hWnd) + { + BOOL bRet = ATL::CWindowImpl< T, TBase, TWinTraits >::SubclassWindow(hWnd); + if(bRet != FALSE) + { + T* pT = static_cast(this); + pT->GetSystemSettings(); + + RECT rect = {}; + this->GetClientRect(&rect); + pT->DoSize(rect.right, rect.bottom); + } + + return bRet; + } + + BEGIN_MSG_MAP(CMapScrollWindowImpl) + MESSAGE_HANDLER(WM_VSCROLL, CScrollImpl< T >::OnVScroll) + MESSAGE_HANDLER(WM_HSCROLL, CScrollImpl< T >::OnHScroll) + MESSAGE_HANDLER(WM_MOUSEWHEEL, CScrollImpl< T >::OnMouseWheel) + MESSAGE_HANDLER(WM_MOUSEHWHEEL, CScrollImpl< T >::OnMouseHWheel) + MESSAGE_HANDLER(WM_SETTINGCHANGE, CScrollImpl< T >::OnSettingChange) + MESSAGE_HANDLER(WM_SIZE, CScrollImpl< T >::OnSize) + MESSAGE_HANDLER(WM_PAINT, CMapScrollImpl< T >::OnPaint) + MESSAGE_HANDLER(WM_PRINTCLIENT, CMapScrollImpl< T >::OnPaint) + ALT_MSG_MAP(1) + COMMAND_ID_HANDLER(ID_SCROLL_UP, CScrollImpl< T >::OnScrollUp) + COMMAND_ID_HANDLER(ID_SCROLL_DOWN, CScrollImpl< T >::OnScrollDown) + COMMAND_ID_HANDLER(ID_SCROLL_PAGE_UP, CScrollImpl< T >::OnScrollPageUp) + COMMAND_ID_HANDLER(ID_SCROLL_PAGE_DOWN, CScrollImpl< T >::OnScrollPageDown) + COMMAND_ID_HANDLER(ID_SCROLL_TOP, CScrollImpl< T >::OnScrollTop) + COMMAND_ID_HANDLER(ID_SCROLL_BOTTOM, CScrollImpl< T >::OnScrollBottom) + COMMAND_ID_HANDLER(ID_SCROLL_LEFT, CScrollImpl< T >::OnScrollLeft) + COMMAND_ID_HANDLER(ID_SCROLL_RIGHT, CScrollImpl< T >::OnScrollRight) + COMMAND_ID_HANDLER(ID_SCROLL_PAGE_LEFT, CScrollImpl< T >::OnScrollPageLeft) + COMMAND_ID_HANDLER(ID_SCROLL_PAGE_RIGHT, CScrollImpl< T >::OnScrollPageRight) + COMMAND_ID_HANDLER(ID_SCROLL_ALL_LEFT, CScrollImpl< T >::OnScrollAllLeft) + COMMAND_ID_HANDLER(ID_SCROLL_ALL_RIGHT, CScrollImpl< T >::OnScrollAllRight) + END_MSG_MAP() +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CFSBWindow - Use as a base instead of CWindow to get flat scroll bar support + +#ifdef __ATLCTRLS_H__ + +template +class CFSBWindowT : public TBase, public CFlatScrollBarImpl > +{ +public: +// Constructors + CFSBWindowT(HWND hWnd = NULL) : TBase(hWnd) + { } + + CFSBWindowT< TBase >& operator =(HWND hWnd) + { + this->m_hWnd = hWnd; + return *this; + } + +// CWindow overrides that use flat scroll bar API +// (only those methods that are used by scroll window classes) + int SetScrollPos(int nBar, int nPos, BOOL bRedraw = TRUE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return this->FlatSB_SetScrollPos(nBar, nPos, bRedraw); + } + + BOOL GetScrollInfo(int nBar, LPSCROLLINFO lpScrollInfo) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return this->FlatSB_GetScrollInfo(nBar, lpScrollInfo); + } + + BOOL SetScrollInfo(int nBar, LPSCROLLINFO lpScrollInfo, BOOL bRedraw = TRUE) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + return this->FlatSB_SetScrollInfo(nBar, lpScrollInfo, bRedraw); + } +}; + +typedef CFSBWindowT CFSBWindow; + +#endif // __ATLCTRLS_H__ + + +/////////////////////////////////////////////////////////////////////////////// +// CZoomScrollImpl - Provides zooming and scrolling support to any window + +// The zoom modes that can be set with the SetZoomMode method +enum +{ + ZOOMMODE_OFF, + ZOOMMODE_IN, // If left mouse button is clicked or dragged, zoom in on point clicked or rectangle dragged. + ZOOMMODE_OUT // If left mouse button clicked, zoom out on point clicked. +}; + +// Notification to parent that zoom scale changed as a result of user mouse action. +#define ZSN_ZOOMCHANGED (NM_FIRST - 50) + +template +class CZoomScrollImpl : public CScrollImpl< T > +{ +public: + enum { m_cxyMinZoomRect = 12 }; // min rect size to zoom in on rect. + + struct _ChildPlacement + { + HWND hWnd; + int x; + int y; + int cx; + int cy; + + bool operator ==(const _ChildPlacement& cp) const { return (memcmp(this, &cp, sizeof(_ChildPlacement)) == 0); } + }; + +// Data members + SIZE m_sizeLogAll; + SIZE m_sizeLogLine; + SIZE m_sizeLogPage; + float m_fZoomScale; + float m_fZoomScaleMin; + float m_fZoomScaleMax; + float m_fZoomDelta; // Used in ZOOMMODE_IN and ZOOMMODE_OUT on left-button click. + int m_nZoomMode; + RECT m_rcTrack; + bool m_bTracking; + + bool m_bZoomChildren; + ATL::CSimpleArray<_ChildPlacement> m_arrChildren; + +// Constructor + CZoomScrollImpl(): m_fZoomScale(1.0f), m_fZoomScaleMin(0.1f), m_fZoomScaleMax(100.0f), m_fZoomDelta(0.5f), + m_nZoomMode(ZOOMMODE_OFF), m_bTracking(false), m_bZoomChildren(false) + { + m_sizeLogAll.cx = 0; + m_sizeLogAll.cy = 0; + m_sizeLogPage.cx = 0; + m_sizeLogPage.cy = 0; + m_sizeLogLine.cx = 0; + m_sizeLogLine.cy = 0; + ::SetRectEmpty(&m_rcTrack); + } + +// Attributes & Operations + // size operations + void SetScrollSize(int cxLog, int cyLog, BOOL bRedraw = TRUE, bool bResetOffset = true) + { + ATLASSERT((cxLog >= 0) && (cyLog >= 0)); + + // Set up the defaults + if((cxLog == 0) && (cyLog == 0)) + { + cxLog = 1; + cyLog = 1; + } + + m_sizeLogAll.cx = cxLog; + m_sizeLogAll.cy = cyLog; + SIZE sizeAll = {}; + sizeAll.cx = (int)((float)m_sizeLogAll.cx * m_fZoomScale); + sizeAll.cy = (int)((float)m_sizeLogAll.cy * m_fZoomScale); + + CScrollImpl< T >::SetScrollSize(sizeAll, bRedraw, bResetOffset); + } + + void SetScrollSize(SIZE sizeLog, BOOL bRedraw = TRUE, bool bResetOffset = true) + { + SetScrollSize(sizeLog.cx, sizeLog.cy, bRedraw, bResetOffset); + } + + void GetScrollSize(SIZE& sizeLog) const + { + sizeLog = m_sizeLogAll; + } + + // line operations + void SetScrollLine(int cxLogLine, int cyLogLine) + { + ATLASSERT((cxLogLine >= 0) && (cyLogLine >= 0)); + + m_sizeLogLine.cx = cxLogLine; + m_sizeLogLine.cy = cyLogLine; + + SIZE sizeLine = {}; + sizeLine.cx = (int)((float)m_sizeLogLine.cx * m_fZoomScale); + sizeLine.cy = (int)((float)m_sizeLogLine.cy * m_fZoomScale); + CScrollImpl< T >::SetScrollLine(sizeLine); + } + + void SetScrollLine(SIZE sizeLogLine) + { + SetScrollLine(sizeLogLine.cx, sizeLogLine.cy); + } + + void GetScrollLine(SIZE& sizeLogLine) const + { + sizeLogLine = m_sizeLogLine; + } + + // page operations + void SetScrollPage(int cxLogPage, int cyLogPage) + { + ATLASSERT((cxLogPage >= 0) && (cyLogPage >= 0)); + + m_sizeLogPage.cx = cxLogPage; + m_sizeLogPage.cy = cyLogPage; + + SIZE sizePage = {}; + sizePage.cx = (int)((float)m_sizeLogPage.cx * m_fZoomScale); + sizePage.cy = (int)((float)m_sizeLogPage.cy * m_fZoomScale); + + CScrollImpl< T >::SetScrollPage(sizePage); + } + + void SetScrollPage(SIZE sizeLogPage) + { + SetScrollPage(sizeLogPage.cx, sizeLogPage.cy); + } + + void GetScrollPage(SIZE& sizeLogPage) const + { + sizeLogPage = m_sizeLogPage; + } + + void SetZoomScale(float fZoomScale) + { + ATLASSERT(fZoomScale > 0.0f); + if(fZoomScale <= 0.0f) + return; + + m_fZoomScale = fZoomScale; + if(m_fZoomScale < m_fZoomScaleMin) + m_fZoomScale = m_fZoomScaleMin; + else if(m_fZoomScale > m_fZoomScaleMax) + m_fZoomScale = m_fZoomScaleMax; + } + + float GetZoomScale() const + { + return m_fZoomScale; + } + + void SetZoomScaleMin(float fZoomScaleMin) + { + ATLASSERT(fZoomScaleMin > 0.0f); + ATLASSERT(fZoomScaleMin <= m_fZoomScaleMax); + + m_fZoomScaleMin = fZoomScaleMin; + } + + float GetZoomScaleMin() const + { + return m_fZoomScaleMin; + } + + void SetZoomScaleMax(float fZoomScaleMax) + { + ATLASSERT(fZoomScaleMax > 0.0f); + ATLASSERT(m_fZoomScaleMin <= fZoomScaleMax); + + m_fZoomScaleMax = fZoomScaleMax; + } + + float GetZoomScaleMax() const + { + return m_fZoomScaleMax; + } + + void SetZoomDelta(float fZoomDelta) + { + ATLASSERT(fZoomDelta >= 0.0f); + + if(fZoomDelta >= 0.0f) + m_fZoomDelta = fZoomDelta; + } + + float GetZoomDelta() const + { + return m_fZoomDelta; + } + + void SetZoomMode(int nZoomMode) + { + m_nZoomMode = nZoomMode; + } + + int GetZoomMode() const + { + return m_nZoomMode; + } + + void SetZoomChildren(bool bEnable = true) + { + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + + m_bZoomChildren = bEnable; + + m_arrChildren.RemoveAll(); + if(m_bZoomChildren) + { + for(HWND hWndChild = ::GetWindow(pT->m_hWnd, GW_CHILD); hWndChild != NULL; hWndChild = ::GetWindow(hWndChild, GW_HWNDNEXT)) + { + RECT rect = {}; + ::GetWindowRect(hWndChild, &rect); + ::MapWindowPoints(NULL, pT->m_hWnd, (LPPOINT)&rect, 2); + + _ChildPlacement cp = {}; + cp.hWnd = hWndChild; + cp.x = rect.left; + cp.y = rect.top; + cp.cx = rect.right - rect.left; + cp.cy = rect.bottom - rect.top; + m_arrChildren.Add(cp); + } + } + } + + bool GetZoomChildren() const + { + return m_bZoomChildren; + } + + void Zoom(int x, int y, float fZoomScale) + { + if(fZoomScale <= 0.0f) + return; + + if(fZoomScale < m_fZoomScaleMin) + fZoomScale = m_fZoomScaleMin; + else if(fZoomScale > m_fZoomScaleMax) + fZoomScale = m_fZoomScaleMax; + + T* pT = static_cast(this); + POINT pt = { x, y }; + if(!pT->PtInDevRect(pt)) + return; + + pT->ViewDPtoLP(&pt); + pT->Zoom(fZoomScale, false); + pT->CenterOnLogicalPoint(pt); + } + + void Zoom(POINT pt, float fZoomScale) + { + T* pT = static_cast(this); + pT->Zoom(pt.x, pt.y, fZoomScale); + } + + void Zoom(RECT& rc) + { + T* pT = static_cast(this); + RECT rcZoom = rc; + pT->NormalizeRect(rcZoom); + SIZE size = { rcZoom.right - rcZoom.left, rcZoom.bottom - rcZoom.top }; + POINT pt = { rcZoom.left + size.cx / 2, rcZoom.top + size.cy / 2 }; + if((size.cx < m_cxyMinZoomRect) || (size.cy < m_cxyMinZoomRect)) + { + pT->Zoom(pt, m_fZoomScale + m_fZoomDelta); + return; + } + + ATLASSERT((size.cx > 0) && (size.cy > 0)); + + float fScaleH = (float)(this->m_sizeClient.cx + 1) / (float)size.cx; + float fScaleV = (float)(this->m_sizeClient.cy + 1) / (float)size.cy; + float fZoomScale = __min(fScaleH, fScaleV) * m_fZoomScale; + pT->Zoom(pt, fZoomScale); + } + + void Zoom(float fZoomScale, bool bCenter = true) + { + if(fZoomScale <= 0.0f) + return; + + if(fZoomScale < m_fZoomScaleMin) + fZoomScale = m_fZoomScaleMin; + else if(fZoomScale > m_fZoomScaleMax) + fZoomScale = m_fZoomScaleMax; + + T* pT = static_cast(this); + POINT pt = { 0, 0 }; + if(bCenter) + { + RECT rcClient = {}; + ::GetClientRect(pT->m_hWnd, &rcClient); + pt.x = rcClient.right / 2; + pt.y = rcClient.bottom / 2; + pT->ViewDPtoLP(&pt); + } + + // Modify the Viewport extent + SIZE sizeAll = {}; + sizeAll.cx = (int)((float)m_sizeLogAll.cx * fZoomScale); + sizeAll.cy = (int)((float)m_sizeLogAll.cy * fZoomScale); + + // Update scroll bars and window + CScrollImpl< T >::SetScrollSize(sizeAll); + + // Zoom all children if needed + if(m_bZoomChildren && (m_fZoomScale != fZoomScale)) + { + for(int i = 0; i < m_arrChildren.GetSize(); i++) + { + ATLASSERT(::IsWindow(m_arrChildren[i].hWnd)); + + ::SetWindowPos(m_arrChildren[i].hWnd, NULL, + (int)((float)m_arrChildren[i].x * fZoomScale + 0.5f), + (int)((float)m_arrChildren[i].y * fZoomScale + 0.5f), + (int)((float)m_arrChildren[i].cx * fZoomScale + 0.5f), + (int)((float)m_arrChildren[i].cy * fZoomScale + 0.5f), + SWP_NOZORDER | SWP_NOACTIVATE); + } + } + + // Set new zoom scale + m_fZoomScale = fZoomScale; + + if(bCenter) + pT->CenterOnLogicalPoint(pt); + } + + void ZoomIn(bool bCenter = true) + { + T* pT = static_cast(this); + pT->Zoom(m_fZoomScale + m_fZoomDelta, bCenter); + } + + void ZoomOut(bool bCenter = true) + { + T* pT = static_cast(this); + pT->Zoom(m_fZoomScale - m_fZoomDelta, bCenter); + } + + void ZoomDefault(bool bCenter = true) + { + T* pT = static_cast(this); + pT->Zoom(1.0f, bCenter); + } + + // Helper functions + void PrepareDC(CDCHandle dc) + { + ATLASSERT((this->m_sizeAll.cx >= 0) && (this->m_sizeAll.cy >= 0)); + dc.SetMapMode(MM_ANISOTROPIC); + dc.SetWindowExt(this->m_sizeLogAll); + dc.SetViewportExt(this->m_sizeAll); + dc.SetViewportOrg(-this->m_ptOffset.x, -this->m_ptOffset.y); + } + + void ViewDPtoLP(LPPOINT lpPoints, int nCount = 1) + { + ATLASSERT(lpPoints); + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + + CWindowDC dc(pT->m_hWnd); + pT->PrepareDC(dc.m_hDC); + dc.DPtoLP(lpPoints, nCount); + } + + void ViewLPtoDP(LPPOINT lpPoints, int nCount = 1) + { + ATLASSERT(lpPoints); + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + + CWindowDC dc(pT->m_hWnd); + pT->PrepareDC(dc.m_hDC); + dc.LPtoDP(lpPoints, nCount); + } + + void ClientToDevice(POINT &pt) + { + pt.x += this->m_ptOffset.x; + pt.y += this->m_ptOffset.y; + } + + void DeviceToClient(POINT &pt) + { + pt.x -= this->m_ptOffset.x; + pt.y -= this->m_ptOffset.y; + } + + void CenterOnPoint(POINT pt) + { + T* pT = static_cast(this); + RECT rect = {}; + pT->GetClientRect(&rect); + + int xOfs = pt.x - (rect.right / 2) + this->m_ptOffset.x; + if(xOfs < 0) + { + xOfs = 0; + } + else + { + int xMax = __max((int)(this->m_sizeAll.cx - rect.right), 0); + if(xOfs > xMax) + xOfs = xMax; + } + + int yOfs = pt.y - (rect.bottom / 2) + this->m_ptOffset.y; + if(yOfs < 0) + { + yOfs = 0; + } + else + { + int yMax = __max((int)(this->m_sizeAll.cy - rect.bottom), 0); + if(yOfs > yMax) + yOfs = yMax; + } + + CScrollImpl< T >::SetScrollOffset(xOfs, yOfs); + } + + void CenterOnLogicalPoint(POINT ptLog) + { + T* pT = static_cast(this); + pT->ViewLPtoDP(&ptLog); + pT->DeviceToClient(ptLog); + pT->CenterOnPoint(ptLog); + } + + BOOL PtInDevRect(POINT pt) + { + RECT rc = { 0, 0, this->m_sizeAll.cx, this->m_sizeAll.cy }; + ::OffsetRect(&rc, -this->m_ptOffset.x, -this->m_ptOffset.y); + return ::PtInRect(&rc, pt); + } + + void NormalizeRect(RECT& rc) + { + if(rc.left > rc.right) + { + int r = rc.right; + rc.right = rc.left; + rc.left = r; + } + + if(rc.top > rc.bottom) + { + int b = rc.bottom; + rc.bottom = rc.top; + rc.top = b; + } + } + + void DrawTrackRect() + { + T* pT = static_cast(this); + const SIZE sizeLines = { 2, 2 }; + RECT rc = m_rcTrack; + pT->NormalizeRect(rc); + if(!::IsRectEmpty(&rc)) + { + CClientDC dc(pT->m_hWnd); + dc.DrawDragRect(&rc, sizeLines, NULL, sizeLines); + } + } + + void NotifyParentZoomChanged() + { + T* pT = static_cast(this); + int nId = pT->GetDlgCtrlID(); + NMHDR nmhdr = { pT->m_hWnd, (UINT_PTR)nId, ZSN_ZOOMCHANGED }; + ::SendMessage(pT->GetParent(), WM_NOTIFY, (WPARAM)nId, (LPARAM)&nmhdr); + } + + void DoWheelZoom(int zDelta) + { + float fZoomScale = m_fZoomScale + ((zDelta > 0) ? m_fZoomDelta : -m_fZoomDelta); + T* pT = static_cast(this); + pT->Zoom(fZoomScale); + pT->NotifyParentZoomChanged(); + } + + BEGIN_MSG_MAP(CZoomScrollImpl) + MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor) + MESSAGE_HANDLER(WM_VSCROLL, CScrollImpl< T >::OnVScroll) + MESSAGE_HANDLER(WM_HSCROLL, CScrollImpl< T >::OnHScroll) + MESSAGE_HANDLER(WM_MOUSEWHEEL, OnMouseWheel) + MESSAGE_HANDLER(WM_MOUSEHWHEEL, CScrollImpl< T >::OnMouseHWheel) + MESSAGE_HANDLER(WM_SETTINGCHANGE, CScrollImpl< T >::OnSettingChange) + MESSAGE_HANDLER(WM_SIZE, CScrollImpl< T >::OnSize) + MESSAGE_HANDLER(WM_PAINT, OnPaint) + MESSAGE_HANDLER(WM_PRINTCLIENT, OnPaint) + MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown) + MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove) + MESSAGE_HANDLER(WM_LBUTTONUP, OnLButtonUp) + MESSAGE_HANDLER(WM_CAPTURECHANGED, OnCaptureChanged) + ALT_MSG_MAP(1) + COMMAND_ID_HANDLER(ID_SCROLL_UP, CScrollImpl< T >::OnScrollUp) + COMMAND_ID_HANDLER(ID_SCROLL_DOWN, CScrollImpl< T >::OnScrollDown) + COMMAND_ID_HANDLER(ID_SCROLL_PAGE_UP, CScrollImpl< T >::OnScrollPageUp) + COMMAND_ID_HANDLER(ID_SCROLL_PAGE_DOWN, CScrollImpl< T >::OnScrollPageDown) + COMMAND_ID_HANDLER(ID_SCROLL_TOP, CScrollImpl< T >::OnScrollTop) + COMMAND_ID_HANDLER(ID_SCROLL_BOTTOM, CScrollImpl< T >::OnScrollBottom) + COMMAND_ID_HANDLER(ID_SCROLL_LEFT, CScrollImpl< T >::OnScrollLeft) + COMMAND_ID_HANDLER(ID_SCROLL_RIGHT, CScrollImpl< T >::OnScrollRight) + COMMAND_ID_HANDLER(ID_SCROLL_PAGE_LEFT, CScrollImpl< T >::OnScrollPageLeft) + COMMAND_ID_HANDLER(ID_SCROLL_PAGE_RIGHT, CScrollImpl< T >::OnScrollPageRight) + COMMAND_ID_HANDLER(ID_SCROLL_ALL_LEFT, CScrollImpl< T >::OnScrollAllLeft) + COMMAND_ID_HANDLER(ID_SCROLL_ALL_RIGHT, CScrollImpl< T >::OnScrollAllRight) + END_MSG_MAP() + + LRESULT OnSetCursor(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled) + { + if((LOWORD(lParam) == HTCLIENT) && (m_nZoomMode != ZOOMMODE_OFF)) + { + T* pT = static_cast(this); + if((HWND)wParam == pT->m_hWnd) + { + DWORD dwPos = ::GetMessagePos(); + POINT pt = { GET_X_LPARAM(dwPos), GET_Y_LPARAM(dwPos) }; + pT->ScreenToClient(&pt); + if(pT->PtInDevRect(pt)) + { + ::SetCursor(::LoadCursor(NULL, IDC_CROSS)); + return 1; + } + } + } + + bHandled = FALSE; + return 0; + } + + LRESULT OnMouseWheel(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) + { + if((GET_KEYSTATE_WPARAM(wParam) & MK_CONTROL) != 0) // handle zoom if Ctrl is pressed + { + int zDelta = (int)GET_WHEEL_DELTA_WPARAM(wParam); + T* pT = static_cast(this); + pT->DoWheelZoom(zDelta); + } + else + { + CScrollImpl< T >::OnMouseWheel(uMsg, wParam, lParam, bHandled); + } + + return 0; + } + + LRESULT OnPaint(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + ATLASSERT((m_sizeLogAll.cx >= 0) && (m_sizeLogAll.cy >= 0)); + ATLASSERT((this->m_sizeAll.cx >= 0) && (this->m_sizeAll.cy >= 0)); + + if(wParam != NULL) + { + CDCHandle dc = (HDC)wParam; + int nMapModeSav = dc.GetMapMode(); + dc.SetMapMode(MM_ANISOTROPIC); + SIZE szWindowExt = { 0, 0 }; + dc.SetWindowExt(m_sizeLogAll, &szWindowExt); + SIZE szViewportExt = { 0, 0 }; + dc.SetViewportExt(this->m_sizeAll, &szViewportExt); + POINT ptViewportOrg = { 0, 0 }; + dc.SetViewportOrg(-this->m_ptOffset.x, -this->m_ptOffset.y, &ptViewportOrg); + + pT->DoPaint(dc); + + dc.SetMapMode(nMapModeSav); + dc.SetWindowExt(szWindowExt); + dc.SetViewportExt(szViewportExt); + dc.SetViewportOrg(ptViewportOrg); + } + else + { + CPaintDC dc(pT->m_hWnd); + pT->PrepareDC(dc.m_hDC); + pT->DoPaint(dc.m_hDC); + } + + return 0; + } + + LRESULT OnLButtonDown(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled) + { + if((m_nZoomMode == ZOOMMODE_IN) && !m_bTracking) + { + T* pT = static_cast(this); + POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; + if(pT->PtInDevRect(pt)) + { + pT->SetCapture(); + m_bTracking = true; + ::SetRect(&m_rcTrack, pt.x, pt.y, pt.x, pt.y); + + RECT rcClip; + pT->GetClientRect(&rcClip); + if((this->m_ptOffset.x == 0) && (this->m_ptOffset.y == 0)) + { + if(rcClip.right > this->m_sizeAll.cx) + rcClip.right = this->m_sizeAll.cx; + if(rcClip.bottom > this->m_sizeAll.cy) + rcClip.bottom = this->m_sizeAll.cy; + } + ::MapWindowPoints(pT->m_hWnd, NULL, (LPPOINT)&rcClip, 2); + ::ClipCursor(&rcClip); + } + } + + bHandled = FALSE; + return 0; + } + + LRESULT OnMouseMove(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled) + { + if(m_bTracking) + { + T* pT = static_cast(this); + POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; + if(pT->PtInDevRect(pt)) + { + pT->DrawTrackRect(); + m_rcTrack.right = pt.x + 1; + m_rcTrack.bottom = pt.y + 1; + pT->DrawTrackRect(); + } + } + + bHandled = FALSE; + return 0; + } + + LRESULT OnLButtonUp(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled) + { + ::ReleaseCapture(); + if(m_nZoomMode == ZOOMMODE_OUT) + { + T* pT = static_cast(this); + pT->Zoom(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), m_fZoomScale - m_fZoomDelta); + pT->NotifyParentZoomChanged(); + } + + bHandled = FALSE; + return 0; + } + + LRESULT OnCaptureChanged(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) + { + if(m_bTracking) + { + m_bTracking = false; + T* pT = static_cast(this); + pT->DrawTrackRect(); + pT->Zoom(m_rcTrack); + pT->NotifyParentZoomChanged(); + ::SetRectEmpty(&m_rcTrack); + ::ClipCursor(NULL); + } + + bHandled = FALSE; + return 0; + } +}; + +/////////////////////////////////////////////////////////////////////////////// +// CZoomScrollWindowImpl - Implements scrolling window with zooming + +template +class ATL_NO_VTABLE CZoomScrollWindowImpl : public ATL::CWindowImpl< T, TBase, TWinTraits >, public CZoomScrollImpl< T > +{ +public: + BOOL SubclassWindow(HWND hWnd) + { + BOOL bRet = ATL::CWindowImpl< T, TBase, TWinTraits >::SubclassWindow(hWnd); + if(bRet != FALSE) + { + T* pT = static_cast(this); + pT->GetSystemSettings(); + + RECT rect = {}; + this->GetClientRect(&rect); + pT->DoSize(rect.right, rect.bottom); + } + + return bRet; + } + + BEGIN_MSG_MAP(CZoomScrollWindowImpl) + MESSAGE_HANDLER(WM_SETCURSOR, CZoomScrollImpl< T >::OnSetCursor) + MESSAGE_HANDLER(WM_VSCROLL, CScrollImpl< T >::OnVScroll) + MESSAGE_HANDLER(WM_HSCROLL, CScrollImpl< T >::OnHScroll) + MESSAGE_HANDLER(WM_MOUSEWHEEL, CZoomScrollImpl< T >::OnMouseWheel) + MESSAGE_HANDLER(WM_MOUSEHWHEEL, CScrollImpl< T >::OnMouseHWheel) + MESSAGE_HANDLER(WM_SETTINGCHANGE, CScrollImpl< T >::OnSettingChange) + MESSAGE_HANDLER(WM_SIZE, CScrollImpl< T >::OnSize) + MESSAGE_HANDLER(WM_PAINT, CZoomScrollImpl< T >::OnPaint) + MESSAGE_HANDLER(WM_PRINTCLIENT, CZoomScrollImpl< T >::OnPaint) + MESSAGE_HANDLER(WM_LBUTTONDOWN, CZoomScrollImpl< T >::OnLButtonDown) + MESSAGE_HANDLER(WM_MOUSEMOVE, CZoomScrollImpl< T >::OnMouseMove) + MESSAGE_HANDLER(WM_LBUTTONUP, CZoomScrollImpl< T >::OnLButtonUp) + MESSAGE_HANDLER(WM_CAPTURECHANGED, CZoomScrollImpl< T >::OnCaptureChanged) + ALT_MSG_MAP(1) + COMMAND_ID_HANDLER(ID_SCROLL_UP, CScrollImpl< T >::OnScrollUp) + COMMAND_ID_HANDLER(ID_SCROLL_DOWN, CScrollImpl< T >::OnScrollDown) + COMMAND_ID_HANDLER(ID_SCROLL_PAGE_UP, CScrollImpl< T >::OnScrollPageUp) + COMMAND_ID_HANDLER(ID_SCROLL_PAGE_DOWN, CScrollImpl< T >::OnScrollPageDown) + COMMAND_ID_HANDLER(ID_SCROLL_TOP, CScrollImpl< T >::OnScrollTop) + COMMAND_ID_HANDLER(ID_SCROLL_BOTTOM, CScrollImpl< T >::OnScrollBottom) + COMMAND_ID_HANDLER(ID_SCROLL_LEFT, CScrollImpl< T >::OnScrollLeft) + COMMAND_ID_HANDLER(ID_SCROLL_RIGHT, CScrollImpl< T >::OnScrollRight) + COMMAND_ID_HANDLER(ID_SCROLL_PAGE_LEFT, CScrollImpl< T >::OnScrollPageLeft) + COMMAND_ID_HANDLER(ID_SCROLL_PAGE_RIGHT, CScrollImpl< T >::OnScrollPageRight) + COMMAND_ID_HANDLER(ID_SCROLL_ALL_LEFT, CScrollImpl< T >::OnScrollAllLeft) + COMMAND_ID_HANDLER(ID_SCROLL_ALL_RIGHT, CScrollImpl< T >::OnScrollAllRight) + END_MSG_MAP() +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CScrollContainer + +template +class ATL_NO_VTABLE CScrollContainerImpl : public CScrollWindowImpl< T, TBase, TWinTraits > +{ +public: + DECLARE_WND_CLASS_EX2(NULL, T, 0, -1) + + typedef CScrollWindowImpl< T, TBase, TWinTraits > _baseClass; + +// Data members + ATL::CWindow m_wndClient; + bool m_bAutoSizeClient; + bool m_bDrawEdgeIfEmpty; + +// Constructor + CScrollContainerImpl() : m_bAutoSizeClient(true), m_bDrawEdgeIfEmpty(false) + { + // Set CScrollWindowImpl extended style + this->SetScrollExtendedStyle(SCRL_SCROLLCHILDREN); + } + +// Attributes + HWND GetClient() const + { + return m_wndClient; + } + + HWND SetClient(HWND hWndClient, bool bClientSizeAsMin = true) + { + ATLASSERT(::IsWindow(this->m_hWnd)); + + HWND hWndOldClient = m_wndClient; + m_wndClient = hWndClient; + + this->SetRedraw(FALSE); + this->SetScrollSize(1, 1, FALSE); + + if(m_wndClient.m_hWnd != NULL) + { + m_wndClient.SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOSIZE); + + if(bClientSizeAsMin) + { + RECT rect = {}; + m_wndClient.GetWindowRect(&rect); + if(((rect.right - rect.left) > 0) && ((rect.bottom - rect.top) > 0)) + this->SetScrollSize(rect.right - rect.left, rect.bottom - rect.top, FALSE); + } + + T* pT = static_cast(this); + pT->UpdateLayout(); + } + + this->SetRedraw(TRUE); + this->RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_UPDATENOW | RDW_ALLCHILDREN); + + return hWndOldClient; + } + +// Message map and handlers + BEGIN_MSG_MAP(CScrollContainerImpl) + MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus) + MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground) + CHAIN_MSG_MAP(_baseClass) + FORWARD_NOTIFICATIONS() + ALT_MSG_MAP(1) + CHAIN_MSG_MAP_ALT(_baseClass, 1) + END_MSG_MAP() + + LRESULT OnSetFocus(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + if(m_wndClient.m_hWnd != NULL) + m_wndClient.SetFocus(); + + return 0; + } + + LRESULT OnEraseBackground(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + return 1; // no background needed + } + +// Overrides for CScrollWindowImpl + void DoSize(int cx, int cy) + { + _baseClass::DoSize(cx, cy); + + T* pT = static_cast(this); + pT->UpdateLayout(); + } + + void DoPaint(CDCHandle dc) + { + if(!m_bAutoSizeClient || (m_wndClient.m_hWnd == NULL)) + { + T* pT = static_cast(this); + RECT rect = {}; + pT->GetContainerRect(rect); + + if(m_bDrawEdgeIfEmpty && (m_wndClient.m_hWnd == NULL)) + dc.DrawEdge(&rect, EDGE_SUNKEN, BF_RECT | BF_ADJUST); + + dc.FillRect(&rect, COLOR_APPWORKSPACE); + } + } + + void ScrollToView(POINT pt) + { + CScrollWindowImpl< T, TBase, TWinTraits >::ScrollToView(pt); + } + + void ScrollToView(RECT& rect) + { + CScrollWindowImpl< T, TBase, TWinTraits >::ScrollToView(rect); + } + + void ScrollToView(HWND hWnd) // client window coordinates + { + T* pT = static_cast(this); + (void)pT; // avoid level 4 warning + ATLASSERT(::IsWindow(pT->m_hWnd)); + ATLASSERT(m_wndClient.IsWindow()); + + RECT rect = {}; + ::GetWindowRect(hWnd, &rect); + ::MapWindowPoints(NULL, m_wndClient.m_hWnd, (LPPOINT)&rect, 2); + ScrollToView(rect); + } + +// Implementation - overrideable methods + void UpdateLayout() + { + ATLASSERT(::IsWindow(this->m_hWnd)); + + if(m_bAutoSizeClient && (m_wndClient.m_hWnd != NULL)) + { + T* pT = static_cast(this); + RECT rect = {}; + pT->GetContainerRect(rect); + + m_wndClient.SetWindowPos(NULL, &rect, SWP_NOZORDER | SWP_NOMOVE); + } + else + { + this->Invalidate(); + } + } + + void GetContainerRect(RECT& rect) + { + this->GetClientRect(&rect); + + if(rect.right < this->m_sizeAll.cx) + rect.right = this->m_sizeAll.cx; + + if(rect.bottom < this->m_sizeAll.cy) + rect.bottom = this->m_sizeAll.cy; + } +}; + +class CScrollContainer : public CScrollContainerImpl +{ +public: + DECLARE_WND_CLASS_EX(_T("WTL_ScrollContainer"), 0, -1) +}; + +} // namespace WTL + +#endif // __ATLSCRL_H__ diff -r e9bb126753e7 -r 20d02a178406 foosdk/wtl/Include/atlsplit.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/wtl/Include/atlsplit.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,1129 @@ +// Windows Template Library - WTL version 10.0 +// Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. +// +// This file is a part of the Windows Template Library. +// The use and distribution terms for this software are covered by the +// Microsoft Public License (http://opensource.org/licenses/MS-PL) +// which can be found in the file MS-PL.txt at the root folder. + +#ifndef __ATLSPLIT_H__ +#define __ATLSPLIT_H__ + +#pragma once + +#ifndef __ATLAPP_H__ + #error atlsplit.h requires atlapp.h to be included first +#endif + +#ifndef __ATLWIN_H__ + #error atlsplit.h requires atlwin.h to be included first +#endif + + +/////////////////////////////////////////////////////////////////////////////// +// Classes in this file: +// +// CSplitterImpl +// CSplitterWindowImpl +// CSplitterWindowT - CSplitterWindow, CHorSplitterWindow + + +namespace WTL +{ + +/////////////////////////////////////////////////////////////////////////////// +// CSplitterImpl - Provides splitter support to any window + +// Splitter panes constants +#define SPLIT_PANE_LEFT 0 +#define SPLIT_PANE_RIGHT 1 +#define SPLIT_PANE_TOP SPLIT_PANE_LEFT +#define SPLIT_PANE_BOTTOM SPLIT_PANE_RIGHT +#define SPLIT_PANE_NONE -1 + +// Splitter extended styles +#define SPLIT_PROPORTIONAL 0x00000001 +#define SPLIT_NONINTERACTIVE 0x00000002 +#define SPLIT_RIGHTALIGNED 0x00000004 +#define SPLIT_BOTTOMALIGNED SPLIT_RIGHTALIGNED +#define SPLIT_GRADIENTBAR 0x00000008 +#define SPLIT_FLATBAR 0x00000020 +#define SPLIT_FIXEDBARSIZE 0x00000010 + +// Note: SPLIT_PROPORTIONAL and SPLIT_RIGHTALIGNED/SPLIT_BOTTOMALIGNED are +// mutually exclusive. If both are set, splitter defaults to SPLIT_PROPORTIONAL. +// Also, SPLIT_FLATBAR overrides SPLIT_GRADIENTBAR if both are set. + + +template +class CSplitterImpl +{ +public: + enum { m_nPanesCount = 2, m_nPropMax = INT_MAX, m_cxyStep = 10 }; + + bool m_bVertical; + HWND m_hWndPane[m_nPanesCount]; + RECT m_rcSplitter; + int m_xySplitterPos; // splitter bar position + int m_xySplitterPosNew; // internal - new position while moving + HWND m_hWndFocusSave; + int m_nDefActivePane; + int m_cxySplitBar; // splitter bar width/height + HCURSOR m_hCursor; + int m_cxyMin; // minimum pane size + int m_cxyBarEdge; // splitter bar edge + bool m_bFullDrag; + int m_cxyDragOffset; // internal + int m_nProportionalPos; + bool m_bUpdateProportionalPos; + DWORD m_dwExtendedStyle; // splitter specific extended styles + int m_nSinglePane; // single pane mode + int m_xySplitterDefPos; // default position + bool m_bProportionalDefPos; // porportinal def pos + +// Constructor + CSplitterImpl(bool bVertical = true) : + m_bVertical(bVertical), m_xySplitterPos(-1), m_xySplitterPosNew(-1), m_hWndFocusSave(NULL), + m_nDefActivePane(SPLIT_PANE_NONE), m_cxySplitBar(4), m_hCursor(NULL), m_cxyMin(0), m_cxyBarEdge(0), + m_bFullDrag(true), m_cxyDragOffset(0), m_nProportionalPos(0), m_bUpdateProportionalPos(true), + m_dwExtendedStyle(SPLIT_PROPORTIONAL), m_nSinglePane(SPLIT_PANE_NONE), + m_xySplitterDefPos(-1), m_bProportionalDefPos(false) + { + m_hWndPane[SPLIT_PANE_LEFT] = NULL; + m_hWndPane[SPLIT_PANE_RIGHT] = NULL; + + ::SetRectEmpty(&m_rcSplitter); + } + +// Attributes + void SetSplitterRect(LPRECT lpRect = NULL, bool bUpdate = true) + { + if(lpRect == NULL) + { + T* pT = static_cast(this); + pT->GetClientRect(&m_rcSplitter); + } + else + { + m_rcSplitter = *lpRect; + } + + if(IsProportional()) + UpdateProportionalPos(); + else if(IsRightAligned()) + UpdateRightAlignPos(); + + if(bUpdate) + UpdateSplitterLayout(); + } + + void GetSplitterRect(LPRECT lpRect) const + { + ATLASSERT(lpRect != NULL); + *lpRect = m_rcSplitter; + } + + bool SetSplitterPos(int xyPos = -1, bool bUpdate = true) + { + if(xyPos == -1) // -1 == default position + { + if(m_bProportionalDefPos) + { + ATLASSERT((m_xySplitterDefPos >= 0) && (m_xySplitterDefPos <= m_nPropMax)); + + if(m_bVertical) + xyPos = ::MulDiv(m_xySplitterDefPos, m_rcSplitter.right - m_rcSplitter.left - m_cxySplitBar - m_cxyBarEdge, m_nPropMax); + else + xyPos = ::MulDiv(m_xySplitterDefPos, m_rcSplitter.bottom - m_rcSplitter.top - m_cxySplitBar - m_cxyBarEdge, m_nPropMax); + } + else if(m_xySplitterDefPos != -1) + { + xyPos = m_xySplitterDefPos; + } + else // not set, use middle position + { + if(m_bVertical) + xyPos = (m_rcSplitter.right - m_rcSplitter.left - m_cxySplitBar - m_cxyBarEdge) / 2; + else + xyPos = (m_rcSplitter.bottom - m_rcSplitter.top - m_cxySplitBar - m_cxyBarEdge) / 2; + } + } + + // Adjust if out of valid range + int cxyMax = 0; + if(m_bVertical) + cxyMax = m_rcSplitter.right - m_rcSplitter.left; + else + cxyMax = m_rcSplitter.bottom - m_rcSplitter.top; + + if(xyPos < m_cxyMin + m_cxyBarEdge) + xyPos = m_cxyMin; + else if(xyPos > (cxyMax - m_cxySplitBar - m_cxyBarEdge - m_cxyMin)) + xyPos = cxyMax - m_cxySplitBar - m_cxyBarEdge - m_cxyMin; + + // Set new position and update if requested + bool bRet = (m_xySplitterPos != xyPos); + m_xySplitterPos = xyPos; + + if(m_bUpdateProportionalPos) + { + if(IsProportional()) + StoreProportionalPos(); + else if(IsRightAligned()) + StoreRightAlignPos(); + } + else + { + m_bUpdateProportionalPos = true; + } + + if(bUpdate && bRet) + UpdateSplitterLayout(); + + return bRet; + } + + int GetSplitterPos() const + { + return m_xySplitterPos; + } + + void SetSplitterPosPct(int nPct, bool bUpdate = true) + { + ATLASSERT((nPct >= 0) && (nPct <= 100)); + + m_nProportionalPos = ::MulDiv(nPct, m_nPropMax, 100); + UpdateProportionalPos(); + + if(bUpdate) + UpdateSplitterLayout(); + } + + int GetSplitterPosPct() const + { + int cxyTotal = m_bVertical ? (m_rcSplitter.right - m_rcSplitter.left - m_cxySplitBar - m_cxyBarEdge) : (m_rcSplitter.bottom - m_rcSplitter.top - m_cxySplitBar - m_cxyBarEdge); + return ((cxyTotal > 0) && (m_xySplitterPos >= 0)) ? ::MulDiv(m_xySplitterPos, 100, cxyTotal) : -1; + } + + bool SetSinglePaneMode(int nPane = SPLIT_PANE_NONE) + { + ATLASSERT((nPane == SPLIT_PANE_LEFT) || (nPane == SPLIT_PANE_RIGHT) || (nPane == SPLIT_PANE_NONE)); + if(!((nPane == SPLIT_PANE_LEFT) || (nPane == SPLIT_PANE_RIGHT) || (nPane == SPLIT_PANE_NONE))) + return false; + + if(nPane != SPLIT_PANE_NONE) + { + if(::IsWindowVisible(m_hWndPane[nPane]) == FALSE) + ::ShowWindow(m_hWndPane[nPane], SW_SHOW); + int nOtherPane = (nPane == SPLIT_PANE_LEFT) ? SPLIT_PANE_RIGHT : SPLIT_PANE_LEFT; + ::ShowWindow(m_hWndPane[nOtherPane], SW_HIDE); + if(m_nDefActivePane != nPane) + m_nDefActivePane = nPane; + } + else if(m_nSinglePane != SPLIT_PANE_NONE) + { + int nOtherPane = (m_nSinglePane == SPLIT_PANE_LEFT) ? SPLIT_PANE_RIGHT : SPLIT_PANE_LEFT; + ::ShowWindow(m_hWndPane[nOtherPane], SW_SHOW); + } + + m_nSinglePane = nPane; + UpdateSplitterLayout(); + + return true; + } + + int GetSinglePaneMode() const + { + return m_nSinglePane; + } + + DWORD GetSplitterExtendedStyle() const + { + return m_dwExtendedStyle; + } + + DWORD SetSplitterExtendedStyle(DWORD dwExtendedStyle, DWORD dwMask = 0) + { + DWORD dwPrevStyle = m_dwExtendedStyle; + if(dwMask == 0) + m_dwExtendedStyle = dwExtendedStyle; + else + m_dwExtendedStyle = (m_dwExtendedStyle & ~dwMask) | (dwExtendedStyle & dwMask); + +#ifdef _DEBUG + if(IsProportional() && IsRightAligned()) + ATLTRACE2(atlTraceUI, 0, _T("CSplitterImpl::SetSplitterExtendedStyle - SPLIT_PROPORTIONAL and SPLIT_RIGHTALIGNED are mutually exclusive, defaulting to SPLIT_PROPORTIONAL.\n")); +#endif // _DEBUG + + return dwPrevStyle; + } + + void SetSplitterDefaultPos(int xyPos = -1) + { + m_xySplitterDefPos = xyPos; + m_bProportionalDefPos = false; + } + + void SetSplitterDefaultPosPct(int nPct) + { + ATLASSERT((nPct >= 0) && (nPct <= 100)); + + m_xySplitterDefPos = ::MulDiv(nPct, m_nPropMax, 100); + m_bProportionalDefPos = true; + } + +// Splitter operations + void SetSplitterPanes(HWND hWndLeftTop, HWND hWndRightBottom, bool bUpdate = true) + { + m_hWndPane[SPLIT_PANE_LEFT] = hWndLeftTop; + m_hWndPane[SPLIT_PANE_RIGHT] = hWndRightBottom; + ATLASSERT((m_hWndPane[SPLIT_PANE_LEFT] == NULL) || (m_hWndPane[SPLIT_PANE_RIGHT] == NULL) || (m_hWndPane[SPLIT_PANE_LEFT] != m_hWndPane[SPLIT_PANE_RIGHT])); + if(bUpdate) + UpdateSplitterLayout(); + } + + bool SetSplitterPane(int nPane, HWND hWnd, bool bUpdate = true) + { + ATLASSERT((nPane == SPLIT_PANE_LEFT) || (nPane == SPLIT_PANE_RIGHT)); + if((nPane != SPLIT_PANE_LEFT) && (nPane != SPLIT_PANE_RIGHT)) + return false; + + m_hWndPane[nPane] = hWnd; + ATLASSERT((m_hWndPane[SPLIT_PANE_LEFT] == NULL) || (m_hWndPane[SPLIT_PANE_RIGHT] == NULL) || (m_hWndPane[SPLIT_PANE_LEFT] != m_hWndPane[SPLIT_PANE_RIGHT])); + if(bUpdate) + UpdateSplitterLayout(); + + return true; + } + + HWND GetSplitterPane(int nPane) const + { + ATLASSERT((nPane == SPLIT_PANE_LEFT) || (nPane == SPLIT_PANE_RIGHT)); + if((nPane != SPLIT_PANE_LEFT) && (nPane != SPLIT_PANE_RIGHT)) + return NULL; + + return m_hWndPane[nPane]; + } + + bool SetActivePane(int nPane) + { + ATLASSERT((nPane == SPLIT_PANE_LEFT) || (nPane == SPLIT_PANE_RIGHT)); + if((nPane != SPLIT_PANE_LEFT) && (nPane != SPLIT_PANE_RIGHT)) + return false; + if((m_nSinglePane != SPLIT_PANE_NONE) && (nPane != m_nSinglePane)) + return false; + + ::SetFocus(m_hWndPane[nPane]); + m_nDefActivePane = nPane; + + return true; + } + + int GetActivePane() const + { + int nRet = SPLIT_PANE_NONE; + HWND hWndFocus = ::GetFocus(); + if(hWndFocus != NULL) + { + for(int nPane = 0; nPane < m_nPanesCount; nPane++) + { + if((hWndFocus == m_hWndPane[nPane]) || (::IsChild(m_hWndPane[nPane], hWndFocus) != FALSE)) + { + nRet = nPane; + break; + } + } + } + + return nRet; + } + + bool ActivateNextPane(bool bNext = true) + { + int nPane = m_nSinglePane; + if(nPane == SPLIT_PANE_NONE) + { + switch(GetActivePane()) + { + case SPLIT_PANE_LEFT: + nPane = SPLIT_PANE_RIGHT; + break; + case SPLIT_PANE_RIGHT: + nPane = SPLIT_PANE_LEFT; + break; + default: + nPane = bNext ? SPLIT_PANE_LEFT : SPLIT_PANE_RIGHT; + break; + } + } + + return SetActivePane(nPane); + } + + bool SetDefaultActivePane(int nPane) + { + ATLASSERT((nPane == SPLIT_PANE_LEFT) || (nPane == SPLIT_PANE_RIGHT)); + if((nPane != SPLIT_PANE_LEFT) && (nPane != SPLIT_PANE_RIGHT)) + return false; + + m_nDefActivePane = nPane; + + return true; + } + + bool SetDefaultActivePane(HWND hWnd) + { + for(int nPane = 0; nPane < m_nPanesCount; nPane++) + { + if(hWnd == m_hWndPane[nPane]) + { + m_nDefActivePane = nPane; + return true; + } + } + + return false; // not found + } + + int GetDefaultActivePane() const + { + return m_nDefActivePane; + } + + void DrawSplitter(CDCHandle dc) + { + ATLASSERT(dc.m_hDC != NULL); + if((m_nSinglePane == SPLIT_PANE_NONE) && (m_xySplitterPos == -1)) + return; + + T* pT = static_cast(this); + if(m_nSinglePane == SPLIT_PANE_NONE) + { + pT->DrawSplitterBar(dc); + + for(int nPane = 0; nPane < m_nPanesCount; nPane++) + { + if(m_hWndPane[nPane] == NULL) + pT->DrawSplitterPane(dc, nPane); + } + } + else + { + if(m_hWndPane[m_nSinglePane] == NULL) + pT->DrawSplitterPane(dc, m_nSinglePane); + } + } + + // call to initiate moving splitter bar with keyboard + void MoveSplitterBar() + { + T* pT = static_cast(this); + + int x = 0; + int y = 0; + if(m_bVertical) + { + x = m_xySplitterPos + (m_cxySplitBar / 2) + m_cxyBarEdge; + y = (m_rcSplitter.bottom - m_rcSplitter.top - m_cxySplitBar - m_cxyBarEdge) / 2; + } + else + { + x = (m_rcSplitter.right - m_rcSplitter.left - m_cxySplitBar - m_cxyBarEdge) / 2; + y = m_xySplitterPos + (m_cxySplitBar / 2) + m_cxyBarEdge; + } + + POINT pt = { x, y }; + pT->ClientToScreen(&pt); + ::SetCursorPos(pt.x, pt.y); + + m_xySplitterPosNew = m_xySplitterPos; + pT->SetCapture(); + m_hWndFocusSave = pT->SetFocus(); + ::SetCursor(m_hCursor); + if(!m_bFullDrag) + DrawGhostBar(); + if(m_bVertical) + m_cxyDragOffset = x - m_rcSplitter.left - m_xySplitterPos; + else + m_cxyDragOffset = y - m_rcSplitter.top - m_xySplitterPos; + } + + void SetOrientation(bool bVertical, bool bUpdate = true) + { + if(m_bVertical != bVertical) + { + m_bVertical = bVertical; + + m_hCursor = ::LoadCursor(NULL, m_bVertical ? IDC_SIZEWE : IDC_SIZENS); + + T* pT = static_cast(this); + pT->GetSystemSettings(false); + + if(m_bVertical) + m_xySplitterPos = ::MulDiv(m_xySplitterPos, m_rcSplitter.right - m_rcSplitter.left, m_rcSplitter.bottom - m_rcSplitter.top); + else + m_xySplitterPos = ::MulDiv(m_xySplitterPos, m_rcSplitter.bottom - m_rcSplitter.top, m_rcSplitter.right - m_rcSplitter.left); + } + + if(bUpdate) + UpdateSplitterLayout(); + } + +// Overrideables + void DrawSplitterBar(CDCHandle dc) + { + RECT rect = {}; + if(GetSplitterBarRect(&rect)) + { + dc.FillRect(&rect, COLOR_3DFACE); + + if((m_dwExtendedStyle & SPLIT_FLATBAR) != 0) + { + RECT rect1 = rect; + if(m_bVertical) + rect1.right = rect1.left + 1; + else + rect1.bottom = rect1.top + 1; + dc.FillRect(&rect1, COLOR_WINDOW); + + rect1 = rect; + if(m_bVertical) + rect1.left = rect1.right - 1; + else + rect1.top = rect1.bottom - 1; + dc.FillRect(&rect1, COLOR_3DSHADOW); + } + else if((m_dwExtendedStyle & SPLIT_GRADIENTBAR) != 0) + { + RECT rect2 = rect; + if(m_bVertical) + rect2.left = (rect.left + rect.right) / 2 - 1; + else + rect2.top = (rect.top + rect.bottom) / 2 - 1; + + dc.GradientFillRect(rect2, ::GetSysColor(COLOR_3DFACE), ::GetSysColor(COLOR_3DSHADOW), m_bVertical); + } + + // draw 3D edge if needed + T* pT = static_cast(this); + if((pT->GetExStyle() & WS_EX_CLIENTEDGE) != 0) + dc.DrawEdge(&rect, EDGE_RAISED, m_bVertical ? (BF_LEFT | BF_RIGHT) : (BF_TOP | BF_BOTTOM)); + } + } + + // called only if pane is empty + void DrawSplitterPane(CDCHandle dc, int nPane) + { + RECT rect = {}; + if(GetSplitterPaneRect(nPane, &rect)) + { + T* pT = static_cast(this); + if((pT->GetExStyle() & WS_EX_CLIENTEDGE) == 0) + dc.DrawEdge(&rect, EDGE_SUNKEN, BF_RECT | BF_ADJUST); + dc.FillRect(&rect, COLOR_APPWORKSPACE); + } + } + +// Message map and handlers + BEGIN_MSG_MAP(CSplitterImpl) + MESSAGE_HANDLER(WM_CREATE, OnCreate) + MESSAGE_HANDLER(WM_PAINT, OnPaint) + MESSAGE_HANDLER(WM_PRINTCLIENT, OnPaint) + if(IsInteractive()) + { + MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor) + MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove) + MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown) + MESSAGE_HANDLER(WM_LBUTTONUP, OnLButtonUp) + MESSAGE_HANDLER(WM_LBUTTONDBLCLK, OnLButtonDoubleClick) + MESSAGE_HANDLER(WM_CAPTURECHANGED, OnCaptureChanged) + MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown) + } + MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus) + MESSAGE_HANDLER(WM_MOUSEACTIVATE, OnMouseActivate) + MESSAGE_HANDLER(WM_SETTINGCHANGE, OnSettingChange) + END_MSG_MAP() + + LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) + { + T* pT = static_cast(this); + pT->Init(); + + bHandled = FALSE; + return 1; + } + + LRESULT OnPaint(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + T* pT = static_cast(this); + + // try setting position if not set + if((m_nSinglePane == SPLIT_PANE_NONE) && (m_xySplitterPos == -1)) + pT->SetSplitterPos(); + + // do painting + if(wParam != NULL) + { + pT->DrawSplitter((HDC)wParam); + } + else + { + CPaintDC dc(pT->m_hWnd); + pT->DrawSplitter(dc.m_hDC); + } + + return 0; + } + + LRESULT OnSetCursor(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled) + { + T* pT = static_cast(this); + if(((HWND)wParam == pT->m_hWnd) && (LOWORD(lParam) == HTCLIENT)) + { + DWORD dwPos = ::GetMessagePos(); + POINT ptPos = { GET_X_LPARAM(dwPos), GET_Y_LPARAM(dwPos) }; + pT->ScreenToClient(&ptPos); + if(IsOverSplitterBar(ptPos.x, ptPos.y)) + return 1; + } + + bHandled = FALSE; + return 0; + } + + LRESULT OnMouseMove(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled) + { + T* pT = static_cast(this); + int xPos = GET_X_LPARAM(lParam); + int yPos = GET_Y_LPARAM(lParam); + if(::GetCapture() == pT->m_hWnd) + { + int xyNewSplitPos = 0; + if(m_bVertical) + xyNewSplitPos = xPos - m_rcSplitter.left - m_cxyDragOffset; + else + xyNewSplitPos = yPos - m_rcSplitter.top - m_cxyDragOffset; + + if(xyNewSplitPos == -1) // avoid -1, that means default position + xyNewSplitPos = -2; + + if(m_xySplitterPos != xyNewSplitPos) + { + if(m_bFullDrag) + { + if(pT->SetSplitterPos(xyNewSplitPos, true)) + pT->UpdateWindow(); + } + else + { + DrawGhostBar(); + pT->SetSplitterPos(xyNewSplitPos, false); + DrawGhostBar(); + } + } + } + else // not dragging, just set cursor + { + if(IsOverSplitterBar(xPos, yPos)) + ::SetCursor(m_hCursor); + bHandled = FALSE; + } + + return 0; + } + + LRESULT OnLButtonDown(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled) + { + T* pT = static_cast(this); + int xPos = GET_X_LPARAM(lParam); + int yPos = GET_Y_LPARAM(lParam); + if((::GetCapture() != pT->m_hWnd) && IsOverSplitterBar(xPos, yPos)) + { + m_xySplitterPosNew = m_xySplitterPos; + pT->SetCapture(); + m_hWndFocusSave = pT->SetFocus(); + ::SetCursor(m_hCursor); + if(!m_bFullDrag) + DrawGhostBar(); + if(m_bVertical) + m_cxyDragOffset = xPos - m_rcSplitter.left - m_xySplitterPos; + else + m_cxyDragOffset = yPos - m_rcSplitter.top - m_xySplitterPos; + } + else if((::GetCapture() == pT->m_hWnd) && !IsOverSplitterBar(xPos, yPos)) + { + ::ReleaseCapture(); + } + + bHandled = FALSE; + return 1; + } + + LRESULT OnLButtonUp(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) + { + T* pT = static_cast(this); + if(::GetCapture() == pT->m_hWnd) + { + m_xySplitterPosNew = m_xySplitterPos; + ::ReleaseCapture(); + } + + bHandled = FALSE; + return 1; + } + + LRESULT OnLButtonDoubleClick(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + T* pT = static_cast(this); + pT->SetSplitterPos(); // default + + return 0; + } + + LRESULT OnCaptureChanged(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + if(!m_bFullDrag) + DrawGhostBar(); + + if((m_xySplitterPosNew != -1) && (!m_bFullDrag || (m_xySplitterPos != m_xySplitterPosNew))) + { + m_xySplitterPos = m_xySplitterPosNew; + m_xySplitterPosNew = -1; + UpdateSplitterLayout(); + T* pT = static_cast(this); + pT->UpdateWindow(); + } + + if(m_hWndFocusSave != NULL) + ::SetFocus(m_hWndFocusSave); + + return 0; + } + + LRESULT OnKeyDown(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) + { + T* pT = static_cast(this); + if(::GetCapture() == pT->m_hWnd) + { + switch(wParam) + { + case VK_RETURN: + m_xySplitterPosNew = m_xySplitterPos; + // FALLTHROUGH + case VK_ESCAPE: + ::ReleaseCapture(); + break; + case VK_LEFT: + case VK_RIGHT: + if(m_bVertical) + { + POINT pt = {}; + ::GetCursorPos(&pt); + int xyPos = m_xySplitterPos + ((wParam == VK_LEFT) ? -pT->m_cxyStep : pT->m_cxyStep); + int cxyMax = m_rcSplitter.right - m_rcSplitter.left; + if(xyPos < (m_cxyMin + m_cxyBarEdge)) + xyPos = m_cxyMin; + else if(xyPos > (cxyMax - m_cxySplitBar - m_cxyBarEdge - m_cxyMin)) + xyPos = cxyMax - m_cxySplitBar - m_cxyBarEdge - m_cxyMin; + pt.x += xyPos - m_xySplitterPos; + ::SetCursorPos(pt.x, pt.y); + } + break; + case VK_UP: + case VK_DOWN: + if(!m_bVertical) + { + POINT pt = {}; + ::GetCursorPos(&pt); + int xyPos = m_xySplitterPos + ((wParam == VK_UP) ? -pT->m_cxyStep : pT->m_cxyStep); + int cxyMax = m_rcSplitter.bottom - m_rcSplitter.top; + if(xyPos < (m_cxyMin + m_cxyBarEdge)) + xyPos = m_cxyMin; + else if(xyPos > (cxyMax - m_cxySplitBar - m_cxyBarEdge - m_cxyMin)) + xyPos = cxyMax - m_cxySplitBar - m_cxyBarEdge - m_cxyMin; + pt.y += xyPos - m_xySplitterPos; + ::SetCursorPos(pt.x, pt.y); + } + break; + default: + break; + } + } + else + { + bHandled = FALSE; + } + + return 0; + } + + LRESULT OnSetFocus(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM, BOOL& bHandled) + { + T* pT = static_cast(this); + if(::GetCapture() != pT->m_hWnd) + { + if(m_nSinglePane == SPLIT_PANE_NONE) + { + if((m_nDefActivePane == SPLIT_PANE_LEFT) || (m_nDefActivePane == SPLIT_PANE_RIGHT)) + ::SetFocus(m_hWndPane[m_nDefActivePane]); + } + else + { + ::SetFocus(m_hWndPane[m_nSinglePane]); + } + } + + bHandled = FALSE; + return 1; + } + + LRESULT OnMouseActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) + { + T* pT = static_cast(this); + LRESULT lRet = pT->DefWindowProc(uMsg, wParam, lParam); + if((lRet == MA_ACTIVATE) || (lRet == MA_ACTIVATEANDEAT)) + { + DWORD dwPos = ::GetMessagePos(); + POINT pt = { GET_X_LPARAM(dwPos), GET_Y_LPARAM(dwPos) }; + pT->ScreenToClient(&pt); + RECT rcPane = {}; + for(int nPane = 0; nPane < m_nPanesCount; nPane++) + { + if(GetSplitterPaneRect(nPane, &rcPane) && (::PtInRect(&rcPane, pt) != FALSE)) + { + m_nDefActivePane = nPane; + break; + } + } + } + + return lRet; + } + + LRESULT OnSettingChange(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + T* pT = static_cast(this); + pT->GetSystemSettings(true); + + return 0; + } + +// Implementation - internal helpers + void Init() + { + m_hCursor = ::LoadCursor(NULL, m_bVertical ? IDC_SIZEWE : IDC_SIZENS); + + T* pT = static_cast(this); + pT->GetSystemSettings(false); + } + + void UpdateSplitterLayout() + { + if((m_nSinglePane == SPLIT_PANE_NONE) && (m_xySplitterPos == -1)) + return; + + T* pT = static_cast(this); + RECT rect = {}; + if(m_nSinglePane == SPLIT_PANE_NONE) + { + if(GetSplitterBarRect(&rect)) + pT->InvalidateRect(&rect); + + for(int nPane = 0; nPane < m_nPanesCount; nPane++) + { + if(GetSplitterPaneRect(nPane, &rect)) + { + if(m_hWndPane[nPane] != NULL) + ::SetWindowPos(m_hWndPane[nPane], NULL, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_NOZORDER); + else + pT->InvalidateRect(&rect); + } + } + } + else + { + if(GetSplitterPaneRect(m_nSinglePane, &rect)) + { + if(m_hWndPane[m_nSinglePane] != NULL) + ::SetWindowPos(m_hWndPane[m_nSinglePane], NULL, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_NOZORDER); + else + pT->InvalidateRect(&rect); + } + } + } + + bool GetSplitterBarRect(LPRECT lpRect) const + { + ATLASSERT(lpRect != NULL); + if((m_nSinglePane != SPLIT_PANE_NONE) || (m_xySplitterPos == -1)) + return false; + + if(m_bVertical) + { + lpRect->left = m_rcSplitter.left + m_xySplitterPos; + lpRect->top = m_rcSplitter.top; + lpRect->right = m_rcSplitter.left + m_xySplitterPos + m_cxySplitBar + m_cxyBarEdge; + lpRect->bottom = m_rcSplitter.bottom; + } + else + { + lpRect->left = m_rcSplitter.left; + lpRect->top = m_rcSplitter.top + m_xySplitterPos; + lpRect->right = m_rcSplitter.right; + lpRect->bottom = m_rcSplitter.top + m_xySplitterPos + m_cxySplitBar + m_cxyBarEdge; + } + + return true; + } + + bool GetSplitterPaneRect(int nPane, LPRECT lpRect) const + { + ATLASSERT((nPane == SPLIT_PANE_LEFT) || (nPane == SPLIT_PANE_RIGHT)); + ATLASSERT(lpRect != NULL); + bool bRet = true; + if(m_nSinglePane != SPLIT_PANE_NONE) + { + if(nPane == m_nSinglePane) + *lpRect = m_rcSplitter; + else + bRet = false; + } + else if(nPane == SPLIT_PANE_LEFT) + { + if(m_bVertical) + { + lpRect->left = m_rcSplitter.left; + lpRect->top = m_rcSplitter.top; + lpRect->right = m_rcSplitter.left + m_xySplitterPos; + lpRect->bottom = m_rcSplitter.bottom; + } + else + { + lpRect->left = m_rcSplitter.left; + lpRect->top = m_rcSplitter.top; + lpRect->right = m_rcSplitter.right; + lpRect->bottom = m_rcSplitter.top + m_xySplitterPos; + } + } + else if(nPane == SPLIT_PANE_RIGHT) + { + if(m_bVertical) + { + lpRect->left = m_rcSplitter.left + m_xySplitterPos + m_cxySplitBar + m_cxyBarEdge; + lpRect->top = m_rcSplitter.top; + lpRect->right = m_rcSplitter.right; + lpRect->bottom = m_rcSplitter.bottom; + } + else + { + lpRect->left = m_rcSplitter.left; + lpRect->top = m_rcSplitter.top + m_xySplitterPos + m_cxySplitBar + m_cxyBarEdge; + lpRect->right = m_rcSplitter.right; + lpRect->bottom = m_rcSplitter.bottom; + } + } + else + { + bRet = false; + } + + return bRet; + } + + bool IsOverSplitterRect(int x, int y) const + { + // -1 == don't check + return (((x == -1) || ((x >= m_rcSplitter.left) && (x <= m_rcSplitter.right))) && + ((y == -1) || ((y >= m_rcSplitter.top) && (y <= m_rcSplitter.bottom)))); + } + + bool IsOverSplitterBar(int x, int y) const + { + if(m_nSinglePane != SPLIT_PANE_NONE) + return false; + if((m_xySplitterPos == -1) || !IsOverSplitterRect(x, y)) + return false; + int xy = m_bVertical ? x : y; + int xyOff = m_bVertical ? m_rcSplitter.left : m_rcSplitter.top; + + return ((xy >= (xyOff + m_xySplitterPos)) && (xy < (xyOff + m_xySplitterPos + m_cxySplitBar + m_cxyBarEdge))); + } + + void DrawGhostBar() + { + RECT rect = {}; + if(GetSplitterBarRect(&rect)) + { + // convert client to window coordinates + T* pT = static_cast(this); + RECT rcWnd = {}; + pT->GetWindowRect(&rcWnd); + ::MapWindowPoints(NULL, pT->m_hWnd, (LPPOINT)&rcWnd, 2); + ::OffsetRect(&rect, -rcWnd.left, -rcWnd.top); + + // invert the brush pattern (looks just like frame window sizing) + CWindowDC dc(pT->m_hWnd); + CBrush brush(CDCHandle::GetHalftoneBrush()); + if(brush.m_hBrush != NULL) + { + CBrushHandle brushOld = dc.SelectBrush(brush); + dc.PatBlt(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, PATINVERT); + dc.SelectBrush(brushOld); + } + } + } + + void GetSystemSettings(bool bUpdate) + { + if((m_dwExtendedStyle & SPLIT_FIXEDBARSIZE) == 0) + { + m_cxySplitBar = ::GetSystemMetrics(m_bVertical ? SM_CXSIZEFRAME : SM_CYSIZEFRAME); + } + + T* pT = static_cast(this); + if((pT->GetExStyle() & WS_EX_CLIENTEDGE) != 0) + { + m_cxyBarEdge = 2 * ::GetSystemMetrics(m_bVertical ? SM_CXEDGE : SM_CYEDGE); + m_cxyMin = 0; + } + else + { + m_cxyBarEdge = 0; + m_cxyMin = 2 * ::GetSystemMetrics(m_bVertical ? SM_CXEDGE : SM_CYEDGE); + } + + ::SystemParametersInfo(SPI_GETDRAGFULLWINDOWS, 0, &m_bFullDrag, 0); + + if(bUpdate) + UpdateSplitterLayout(); + } + + bool IsProportional() const + { + return ((m_dwExtendedStyle & SPLIT_PROPORTIONAL) != 0); + } + + void StoreProportionalPos() + { + int cxyTotal = m_bVertical ? (m_rcSplitter.right - m_rcSplitter.left - m_cxySplitBar - m_cxyBarEdge) : (m_rcSplitter.bottom - m_rcSplitter.top - m_cxySplitBar - m_cxyBarEdge); + if(cxyTotal > 0) + m_nProportionalPos = ::MulDiv(m_xySplitterPos, m_nPropMax, cxyTotal); + else + m_nProportionalPos = 0; + ATLTRACE2(atlTraceUI, 0, _T("CSplitterImpl::StoreProportionalPos - %i\n"), m_nProportionalPos); + } + + void UpdateProportionalPos() + { + int cxyTotal = m_bVertical ? (m_rcSplitter.right - m_rcSplitter.left - m_cxySplitBar - m_cxyBarEdge) : (m_rcSplitter.bottom - m_rcSplitter.top - m_cxySplitBar - m_cxyBarEdge); + if(cxyTotal > 0) + { + int xyNewPos = ::MulDiv(m_nProportionalPos, cxyTotal, m_nPropMax); + m_bUpdateProportionalPos = false; + T* pT = static_cast(this); + pT->SetSplitterPos(xyNewPos, false); + } + } + + bool IsRightAligned() const + { + return ((m_dwExtendedStyle & SPLIT_RIGHTALIGNED) != 0); + } + + void StoreRightAlignPos() + { + int cxyTotal = m_bVertical ? (m_rcSplitter.right - m_rcSplitter.left - m_cxySplitBar - m_cxyBarEdge) : (m_rcSplitter.bottom - m_rcSplitter.top - m_cxySplitBar - m_cxyBarEdge); + if(cxyTotal > 0) + m_nProportionalPos = cxyTotal - m_xySplitterPos; + else + m_nProportionalPos = 0; + ATLTRACE2(atlTraceUI, 0, _T("CSplitterImpl::StoreRightAlignPos - %i\n"), m_nProportionalPos); + } + + void UpdateRightAlignPos() + { + int cxyTotal = m_bVertical ? (m_rcSplitter.right - m_rcSplitter.left - m_cxySplitBar - m_cxyBarEdge) : (m_rcSplitter.bottom - m_rcSplitter.top - m_cxySplitBar - m_cxyBarEdge); + if(cxyTotal > 0) + { + m_bUpdateProportionalPos = false; + T* pT = static_cast(this); + pT->SetSplitterPos(cxyTotal - m_nProportionalPos, false); + } + } + + bool IsInteractive() const + { + return ((m_dwExtendedStyle & SPLIT_NONINTERACTIVE) == 0); + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CSplitterWindowImpl - Implements a splitter window + +template +class ATL_NO_VTABLE CSplitterWindowImpl : public ATL::CWindowImpl< T, TBase, TWinTraits >, public CSplitterImpl< T > +{ +public: + DECLARE_WND_CLASS_EX2(NULL, T, CS_DBLCLKS, COLOR_WINDOW) + + CSplitterWindowImpl(bool bVertical = true) : CSplitterImpl< T >(bVertical) + { } + + BOOL SubclassWindow(HWND hWnd) + { + BOOL bRet = ATL::CWindowImpl< T, TBase, TWinTraits >::SubclassWindow(hWnd); + if(bRet != FALSE) + { + T* pT = static_cast(this); + pT->Init(); + + this->SetSplitterRect(); + } + + return bRet; + } + + BEGIN_MSG_MAP(CSplitterWindowImpl) + MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground) + MESSAGE_HANDLER(WM_SIZE, OnSize) + CHAIN_MSG_MAP(CSplitterImpl< T >) + FORWARD_NOTIFICATIONS() + END_MSG_MAP() + + LRESULT OnEraseBackground(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + // handled, no background painting needed + return 1; + } + + LRESULT OnSize(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) + { + if(wParam != SIZE_MINIMIZED) + this->SetSplitterRect(); + + bHandled = FALSE; + return 1; + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CSplitterWindow/CHorSplitterWindow - Implements splitter windows to be used as is + +template +class CSplitterWindowT : public CSplitterWindowImpl > +{ +public: + DECLARE_WND_CLASS_EX2(_T("WTL_SplitterWindow"), CSplitterWindowT, CS_DBLCLKS, COLOR_WINDOW) + + CSplitterWindowT() : CSplitterWindowImpl >(t_bVertical) + { } +}; + +typedef CSplitterWindowT CSplitterWindow; +typedef CSplitterWindowT CHorSplitterWindow; + +} // namespace WTL + +#endif // __ATLSPLIT_H__ diff -r e9bb126753e7 -r 20d02a178406 foosdk/wtl/Include/atltheme.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/wtl/Include/atltheme.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,1190 @@ +// Windows Template Library - WTL version 10.0 +// Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. +// +// This file is a part of the Windows Template Library. +// The use and distribution terms for this software are covered by the +// Microsoft Public License (http://opensource.org/licenses/MS-PL) +// which can be found in the file MS-PL.txt at the root folder. + +#ifndef __ATLTHEME_H__ +#define __ATLTHEME_H__ + +#pragma once + +#ifndef __ATLAPP_H__ + #error atltheme.h requires atlapp.h to be included first +#endif + +#ifndef __ATLWIN_H__ + #error atltheme.h requires atlwin.h to be included first +#endif + +#include + +// Note: To create an application that also runs on older versions of Windows, +// use delay load of uxtheme.dll and ensure that no calls to the Theme API are +// made if theming is not supported. It is enough to check if m_hTheme is NULL. +// Example: +// if(m_hTheme != NULL) +// { +// DrawThemeBackground(dc, BP_PUSHBUTTON, PBS_NORMAL, &rect, NULL); +// DrawThemeText(dc, BP_PUSHBUTTON, PBS_NORMAL, L"Button", -1, DT_SINGLELINE | DT_CENTER | DT_VCENTER, 0, &rect); +// } +// else +// { +// dc.DrawFrameControl(&rect, DFC_BUTTON, DFCS_BUTTONPUSH); +// dc.DrawText(_T("Button"), -1, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER); +// } +// +// Delay load is NOT AUTOMATIC for VC++ 7, you have to link to delayimp.lib, +// and add uxtheme.dll in the Linker.Input.Delay Loaded DLLs section of the +// project properties. + + +/////////////////////////////////////////////////////////////////////////////// +// Classes in this file: +// +// CTheme +// CThemeImpl +// +// CBufferedPaint +// CBufferedPaintImpl +// CBufferedPaintWindowImpl +// CBufferedAnimation +// CBufferedAnimationImpl +// CBufferedAnimationWindowImpl +// +// Global functions: +// AtlDrawThemeClientEdge() + + +namespace WTL +{ + +/////////////////////////////////////////////////////////////////////////////// +// CTheme - wrapper for theme handle + +class CTheme +{ +public: +// Data members + HTHEME m_hTheme; + static int m_nIsThemingSupported; + +// Constructor + CTheme(HTHEME hTheme = NULL) : m_hTheme(hTheme) + { + IsThemingSupported(); + } + +// Operators and helpers + bool IsThemeNull() const + { + return (m_hTheme == NULL); + } + + CTheme& operator =(HTHEME hTheme) + { + m_hTheme = hTheme; + return *this; + } + + operator HTHEME() const + { + return m_hTheme; + } + + void Attach(HTHEME hTheme) + { + m_hTheme = hTheme; + } + + HTHEME Detach() + { + HTHEME hTheme = m_hTheme; + m_hTheme = NULL; + return hTheme; + } + +// Theme support helper + static bool IsThemingSupported() + { + if(m_nIsThemingSupported == -1) + { + CStaticDataInitCriticalSectionLock lock; + if(FAILED(lock.Lock())) + { + ATLTRACE2(atlTraceUI, 0, _T("ERROR : Unable to lock critical section in CTheme::IsThemingSupported.\n")); + ATLASSERT(FALSE); + return false; + } + + if(m_nIsThemingSupported == -1) + { + HMODULE hThemeDLL = ::LoadLibrary(_T("uxtheme.dll")); + m_nIsThemingSupported = (hThemeDLL != NULL) ? 1 : 0; + if(hThemeDLL != NULL) + ::FreeLibrary(hThemeDLL); + } + + lock.Unlock(); + } + + ATLASSERT(m_nIsThemingSupported != -1); + return (m_nIsThemingSupported == 1); + } + +// Operations and theme properties + HTHEME OpenThemeData(HWND hWnd, LPCWSTR pszClassList) + { + if(!IsThemingSupported()) + return NULL; + + ATLASSERT(m_hTheme == NULL); + m_hTheme = ::OpenThemeData(hWnd, pszClassList); + return m_hTheme; + } + + HRESULT CloseThemeData() + { + HRESULT hRet = S_FALSE; + if(m_hTheme != NULL) + { + hRet = ::CloseThemeData(m_hTheme); + if(SUCCEEDED(hRet)) + m_hTheme = NULL; + } + return hRet; + } + + HRESULT DrawThemeBackground(HDC hDC, int nPartID, int nStateID, LPCRECT pRect, LPCRECT pClipRect = NULL) + { + ATLASSERT(m_hTheme != NULL); + return ::DrawThemeBackground(m_hTheme, hDC, nPartID, nStateID, pRect, pClipRect); + } + +// Missing in original uxtheme.h +#ifdef DTBG_CLIPRECT + HRESULT DrawThemeBackgroundEx(HDC hDC, int nPartID, int nStateID, LPCRECT pRect, const DTBGOPTS* pOptions = NULL) + { + ATLASSERT(m_hTheme != NULL); + return ::DrawThemeBackgroundEx(m_hTheme, hDC, nPartID, nStateID, pRect, pOptions); + } +#endif // DTBG_CLIPRECT + + HRESULT DrawThemeText(HDC hDC, int nPartID, int nStateID, LPCWSTR pszText, int nCharCount, DWORD dwTextFlags, DWORD dwTextFlags2, LPCRECT pRect) + { + ATLASSERT(m_hTheme != NULL); + return ::DrawThemeText(m_hTheme, hDC, nPartID, nStateID, pszText, nCharCount, dwTextFlags, dwTextFlags2, pRect); + } + + HRESULT GetThemeBackgroundContentRect(HDC hDC, int nPartID, int nStateID, LPCRECT pBoundingRect, LPRECT pContentRect) const + { + ATLASSERT(m_hTheme != NULL); + return ::GetThemeBackgroundContentRect(m_hTheme, hDC, nPartID, nStateID, pBoundingRect, pContentRect); + } + + HRESULT GetThemeBackgroundExtent(HDC hDC, int nPartID, int nStateID, LPCRECT pContentRect, LPRECT pExtentRect) const + { + ATLASSERT(m_hTheme != NULL); + return ::GetThemeBackgroundExtent(m_hTheme, hDC, nPartID, nStateID, pContentRect, pExtentRect); + } + + HRESULT GetThemePartSize(HDC hDC, int nPartID, int nStateID, LPCRECT pRect, enum THEMESIZE eSize, LPSIZE pSize) const + { + ATLASSERT(m_hTheme != NULL); + return ::GetThemePartSize(m_hTheme, hDC, nPartID, nStateID, pRect, eSize, pSize); + } + + HRESULT GetThemeTextExtent(HDC hDC, int nPartID, int nStateID, LPCWSTR pszText, int nCharCount, DWORD dwTextFlags, LPCRECT pBoundingRect, LPRECT pExtentRect) const + { + ATLASSERT(m_hTheme != NULL); + return ::GetThemeTextExtent(m_hTheme, hDC, nPartID, nStateID, pszText, nCharCount, dwTextFlags, pBoundingRect, pExtentRect); + } + + HRESULT GetThemeTextMetrics(HDC hDC, int nPartID, int nStateID, PTEXTMETRICW pTextMetric) const + { + ATLASSERT(m_hTheme != NULL); + return ::GetThemeTextMetrics(m_hTheme, hDC, nPartID, nStateID, pTextMetric); + } + + HRESULT GetThemeBackgroundRegion(HDC hDC, int nPartID, int nStateID, LPCRECT pRect, HRGN* pRegion) const + { + ATLASSERT(m_hTheme != NULL); + return ::GetThemeBackgroundRegion(m_hTheme, hDC, nPartID, nStateID, pRect, pRegion); + } + + HRESULT HitTestThemeBackground(HDC hDC, int nPartID, int nStateID, DWORD dwOptions, LPCRECT pRect, HRGN hrgn, POINT ptTest, WORD* pwHitTestCode) const + { + ATLASSERT(m_hTheme != NULL); + return ::HitTestThemeBackground(m_hTheme, hDC, nPartID, nStateID, dwOptions, pRect, hrgn, ptTest, pwHitTestCode); + } + + HRESULT DrawThemeEdge(HDC hDC, int nPartID, int nStateID, LPCRECT pDestRect, UINT uEdge, UINT uFlags, LPRECT pContentRect = NULL) + { + ATLASSERT(m_hTheme != NULL); + return ::DrawThemeEdge(m_hTheme, hDC, nPartID, nStateID, pDestRect, uEdge, uFlags, pContentRect); + } + + HRESULT DrawThemeIcon(HDC hDC, int nPartID, int nStateID, LPCRECT pRect, HIMAGELIST himl, int nImageIndex) + { + ATLASSERT(m_hTheme != NULL); + return ::DrawThemeIcon(m_hTheme, hDC, nPartID, nStateID, pRect, himl, nImageIndex); + } + + BOOL IsThemePartDefined(int nPartID, int nStateID) const + { + ATLASSERT(m_hTheme != NULL); + return ::IsThemePartDefined(m_hTheme, nPartID, nStateID); + } + + BOOL IsThemeBackgroundPartiallyTransparent(int nPartID, int nStateID) const + { + ATLASSERT(m_hTheme != NULL); + return ::IsThemeBackgroundPartiallyTransparent(m_hTheme, nPartID, nStateID); + } + + HRESULT GetThemeColor(int nPartID, int nStateID, int nPropID, COLORREF* pColor) const + { + ATLASSERT(m_hTheme != NULL); + return ::GetThemeColor(m_hTheme, nPartID, nStateID, nPropID, pColor); + } + + HRESULT GetThemeMetric(HDC hDC, int nPartID, int nStateID, int nPropID, int* pnVal) const + { + ATLASSERT(m_hTheme != NULL); + return ::GetThemeMetric(m_hTheme, hDC, nPartID, nStateID, nPropID, pnVal); + } + + HRESULT GetThemeString(int nPartID, int nStateID, int nPropID, LPWSTR pszBuff, int cchMaxBuffChars) const + { + ATLASSERT(m_hTheme != NULL); + return ::GetThemeString(m_hTheme, nPartID, nStateID, nPropID, pszBuff, cchMaxBuffChars); + } + + HRESULT GetThemeBool(int nPartID, int nStateID, int nPropID, BOOL* pfVal) const + { + ATLASSERT(m_hTheme != NULL); + return ::GetThemeBool(m_hTheme, nPartID, nStateID, nPropID, pfVal); + } + + HRESULT GetThemeInt(int nPartID, int nStateID, int nPropID, int* pnVal) const + { + ATLASSERT(m_hTheme != NULL); + return ::GetThemeInt(m_hTheme, nPartID, nStateID, nPropID, pnVal); + } + + HRESULT GetThemeEnumValue(int nPartID, int nStateID, int nPropID, int* pnVal) const + { + ATLASSERT(m_hTheme != NULL); + return ::GetThemeEnumValue(m_hTheme, nPartID, nStateID, nPropID, pnVal); + } + + HRESULT GetThemePosition(int nPartID, int nStateID, int nPropID, LPPOINT pPoint) const + { + ATLASSERT(m_hTheme != NULL); + return ::GetThemePosition(m_hTheme, nPartID, nStateID, nPropID, pPoint); + } + + // deprecated + HRESULT GetThemeFont(int nPartID, HDC hDC, int nStateID, int nPropID, LOGFONTW* pFont) const + { + ATLASSERT(m_hTheme != NULL); + return ::GetThemeFont(m_hTheme, hDC, nPartID, nStateID, nPropID, pFont); + } + + HRESULT GetThemeFont(HDC hDC, int nPartID, int nStateID, int nPropID, LOGFONTW* pFont) const + { + ATLASSERT(m_hTheme != NULL); + return ::GetThemeFont(m_hTheme, hDC, nPartID, nStateID, nPropID, pFont); + } + + HRESULT GetThemeRect(int nPartID, int nStateID, int nPropID, LPRECT pRect) const + { + ATLASSERT(m_hTheme != NULL); + return ::GetThemeRect(m_hTheme, nPartID, nStateID, nPropID, pRect); + } + + HRESULT GetThemeMargins(HDC hDC, int nPartID, int nStateID, int nPropID, LPRECT pRect, PMARGINS pMargins) const + { + ATLASSERT(m_hTheme != NULL); + return ::GetThemeMargins(m_hTheme, hDC, nPartID, nStateID, nPropID, pRect, pMargins); + } + + HRESULT GetThemeIntList(int nPartID, int nStateID, int nPropID, INTLIST* pIntList) const + { + ATLASSERT(m_hTheme != NULL); + return ::GetThemeIntList(m_hTheme, nPartID, nStateID, nPropID, pIntList); + } + + HRESULT GetThemePropertyOrigin(int nPartID, int nStateID, int nPropID, enum PROPERTYORIGIN* pOrigin) const + { + ATLASSERT(m_hTheme != NULL); + return ::GetThemePropertyOrigin(m_hTheme, nPartID, nStateID, nPropID, pOrigin); + } + + HRESULT GetThemeFilename(int nPartID, int nStateID, int nPropID, LPWSTR pszThemeFileName, int cchMaxBuffChars) const + { + ATLASSERT(m_hTheme != NULL); + return ::GetThemeFilename(m_hTheme, nPartID, nStateID, nPropID, pszThemeFileName, cchMaxBuffChars); + } + + COLORREF GetThemeSysColor(int nColorID) const + { + ATLASSERT(m_hTheme != NULL); + return ::GetThemeSysColor(m_hTheme, nColorID); + } + + HBRUSH GetThemeSysColorBrush(int nColorID) const + { + ATLASSERT(m_hTheme != NULL); + return ::GetThemeSysColorBrush(m_hTheme, nColorID); + } + + int GetThemeSysSize(int nSizeID) const + { + ATLASSERT(m_hTheme != NULL); + return ::GetThemeSysSize(m_hTheme, nSizeID); + } + + BOOL GetThemeSysBool(int nBoolID) const + { + ATLASSERT(m_hTheme != NULL); + return ::GetThemeSysBool(m_hTheme, nBoolID); + } + + HRESULT GetThemeSysFont(int nFontID, LOGFONTW* plf) const + { + ATLASSERT(m_hTheme != NULL); + return ::GetThemeSysFont(m_hTheme, nFontID, plf); + } + + HRESULT GetThemeSysString(int nStringID, LPWSTR pszStringBuff, int cchMaxStringChars) const + { + ATLASSERT(m_hTheme != NULL); + return ::GetThemeSysString(m_hTheme, nStringID, pszStringBuff, cchMaxStringChars); + } + + HRESULT GetThemeSysInt(int nIntID, int* pnValue) const + { + ATLASSERT(m_hTheme != NULL); + return ::GetThemeSysInt(m_hTheme, nIntID, pnValue); + } + + HTHEME OpenThemeDataEx(HWND hWnd, LPCWSTR pszClassList, DWORD dwFlags) + { + if(!IsThemingSupported()) + return NULL; + + ATLASSERT(m_hTheme == NULL); + m_hTheme = ::OpenThemeDataEx(hWnd, pszClassList, dwFlags); + return m_hTheme; + } + +#if (_WIN32_WINNT >= 0x0600) + HRESULT DrawThemeTextEx(HDC hDC, int nPartID, int nStateID, LPCWSTR pszText, int cchText, DWORD dwTextFlags, LPRECT lpRect, const DTTOPTS* pOptions) + { + ATLASSERT(m_hTheme != NULL); + return ::DrawThemeTextEx(m_hTheme, hDC, nPartID, nStateID, pszText, cchText, dwTextFlags, lpRect, pOptions); + } + + HRESULT GetThemeTransitionDuration(int nPartID, int nFromStateID, int nToStateID, int nPropID, DWORD& dwDuration) + { + ATLASSERT(m_hTheme != NULL); + return ::GetThemeTransitionDuration(m_hTheme, nPartID, nFromStateID, nToStateID, nPropID, &dwDuration); + } +#endif // (_WIN32_WINNT >= 0x0600) + +#if (_WIN32_WINNT >= 0x0600) + HRESULT GetThemeBitmap(int nPartID, int nStateID, int nPropID, ULONG uFlags, HBITMAP& hBitmap) + { + ATLASSERT(m_hTheme != NULL); + return ::GetThemeBitmap(m_hTheme, nPartID, nStateID, nPropID, uFlags, &hBitmap); + } + + HRESULT GetThemeStream(int nPartID, int nStateID, int nPropID, VOID** ppvStream, DWORD* pcbStream, HINSTANCE hInstance) + { + ATLASSERT(m_hTheme != NULL); + return ::GetThemeStream(m_hTheme, nPartID, nStateID, nPropID, ppvStream, pcbStream, hInstance); + } +#endif // (_WIN32_WINNT >= 0x0600) + +#if (_WIN32_WINNT >= 0x0602) + HRESULT GetThemeAnimationProperty(int iStoryboardId, int iTargetId, TA_PROPERTY eProperty, VOID* pvProperty, DWORD cbSize, DWORD* pcbSizeOut) + { + ATLASSERT(m_hTheme != NULL); + return ::GetThemeAnimationProperty(m_hTheme, iStoryboardId, iTargetId, eProperty, pvProperty, cbSize, pcbSizeOut); + } + + HRESULT GetThemeAnimationTransform(int iStoryboardId, int iTargetId, DWORD dwTransformIndex, TA_TRANSFORM* pTransform, DWORD cbSize, DWORD* pcbSizeOut) + { + ATLASSERT(m_hTheme != NULL); + return ::GetThemeAnimationTransform(m_hTheme, iStoryboardId, iTargetId, dwTransformIndex, pTransform, cbSize, pcbSizeOut); + } + + HRESULT GetThemeTimingFunction(int iTimingFunctionId, TA_TIMINGFUNCTION* pTimingFunction, DWORD cbSize, DWORD* pcbSizeOut) + { + ATLASSERT(m_hTheme != NULL); + return ::GetThemeTimingFunction(m_hTheme, iTimingFunctionId, pTimingFunction, cbSize, pcbSizeOut); + } +#endif // (_WIN32_WINNT >= 0x0602) +}; + +__declspec(selectany) int CTheme::m_nIsThemingSupported = -1; + + +/////////////////////////////////////////////////////////////////////////////// +// CThemeImpl - theme support implementation + +// Derive from this class to implement window with theme support. +// Example: +// class CMyThemeWindow : public CWindowImpl, public CThemeImpl +// { +// ... +// BEGIN_MSG_MAP(CMyThemeWindow) +// CHAIN_MSG_MAP(CThemeImpl) +// ... +// END_MSG_MAP() +// ... +// }; +// +// If you set theme class list, the class will automaticaly open/close/reopen theme data. + + +// Helper for drawing theme client edge +inline bool AtlDrawThemeClientEdge(HTHEME hTheme, HWND hWnd, HRGN hRgnUpdate = NULL, HBRUSH hBrush = NULL, int nPartID = 0, int nStateID = 0) +{ + ATLASSERT(hTheme != NULL); + ATLASSERT(::IsWindow(hWnd)); + + CWindowDC dc(hWnd); + if(dc.IsNull()) + return false; + + // Get border size + int cxBorder = ::GetSystemMetrics(SM_CXBORDER); + int cyBorder = ::GetSystemMetrics(SM_CYBORDER); + if(SUCCEEDED(::GetThemeInt(hTheme, nPartID, nStateID, TMT_SIZINGBORDERWIDTH, &cxBorder))) + cyBorder = cxBorder; + + RECT rect = {}; + ::GetWindowRect(hWnd, &rect); + + // Remove the client edge from the update region + int cxEdge = ::GetSystemMetrics(SM_CXEDGE); + int cyEdge = ::GetSystemMetrics(SM_CYEDGE); + ::InflateRect(&rect, -cxEdge, -cyEdge); + CRgn rgn; + rgn.CreateRectRgnIndirect(&rect); + if(rgn.IsNull()) + return false; + + if(hRgnUpdate != NULL) + rgn.CombineRgn(hRgnUpdate, rgn, RGN_AND); + + ::OffsetRect(&rect, -rect.left, -rect.top); + + ::OffsetRect(&rect, cxEdge, cyEdge); + dc.ExcludeClipRect(&rect); + ::InflateRect(&rect, cxEdge, cyEdge); + + ::DrawThemeBackground(hTheme, dc, nPartID, nStateID, &rect, NULL); + + // Use background brush too, since theme border might not cover everything + if((cxBorder < cxEdge) && (cyBorder < cyEdge)) + { + if(hBrush == NULL) + hBrush = (HBRUSH)::GetClassLongPtr(hWnd, GCLP_HBRBACKGROUND); + + ::InflateRect(&rect, cxBorder - cxEdge, cyBorder - cyEdge); + dc.FillRect(&rect, hBrush); + } + + ::DefWindowProc(hWnd, WM_NCPAINT, (WPARAM)rgn.m_hRgn, 0L); + + return true; +} + + +// Theme extended styles +#define THEME_EX_3DCLIENTEDGE 0x00000001 +#define THEME_EX_THEMECLIENTEDGE 0x00000002 + +template +class CThemeImpl : public TBase +{ +public: +// Data members + LPWSTR m_lpstrThemeClassList; + DWORD m_dwExtendedStyle; // theme specific extended styles + +// Constructor & destructor + CThemeImpl() : m_lpstrThemeClassList(NULL), m_dwExtendedStyle(0) + { } + + ~CThemeImpl() + { + delete [] m_lpstrThemeClassList; + } + +// Attributes + bool SetThemeClassList(LPCWSTR lpstrThemeClassList) + { + if(m_lpstrThemeClassList != NULL) + { + delete [] m_lpstrThemeClassList; + m_lpstrThemeClassList = NULL; + } + + if(lpstrThemeClassList == NULL) + return true; + + int cchLen = lstrlenW(lpstrThemeClassList) + 1; + ATLTRY(m_lpstrThemeClassList = new WCHAR[cchLen]); + if(m_lpstrThemeClassList == NULL) + return false; + + ATL::Checked::wcscpy_s(m_lpstrThemeClassList, cchLen, lpstrThemeClassList); + + return true; + } + + bool GetThemeClassList(LPWSTR lpstrThemeClassList, int cchListBuffer) const + { + int cchLen = lstrlenW(m_lpstrThemeClassList) + 1; + if(cchListBuffer < cchLen) + return false; + + ATL::Checked::wcscpy_s(lpstrThemeClassList, cchListBuffer, m_lpstrThemeClassList); + + return true; + } + + LPCWSTR GetThemeClassList() const + { + return m_lpstrThemeClassList; + } + + DWORD SetThemeExtendedStyle(DWORD dwExtendedStyle, DWORD dwMask = 0) + { + DWORD dwPrevStyle = m_dwExtendedStyle; + if(dwMask == 0) + m_dwExtendedStyle = dwExtendedStyle; + else + m_dwExtendedStyle = (m_dwExtendedStyle & ~dwMask) | (dwExtendedStyle & dwMask); + + return dwPrevStyle; + } + + DWORD GetThemeExtendedStyle() const + { + return m_dwExtendedStyle; + } + +// Operations + HTHEME OpenThemeData() + { + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + ATLASSERT(m_lpstrThemeClassList != NULL); + if(m_lpstrThemeClassList == NULL) + return NULL; + this->CloseThemeData(); + + return TBase::OpenThemeData(pT->m_hWnd, m_lpstrThemeClassList); + } + + HTHEME OpenThemeData(LPCWSTR pszClassList) + { + if(!SetThemeClassList(pszClassList)) + return NULL; + + return OpenThemeData(); + } + + HRESULT SetWindowTheme(LPCWSTR pszSubAppName, LPCWSTR pszSubIDList) + { + if(!this->IsThemingSupported()) + return S_FALSE; + + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + return ::SetWindowTheme(pT->m_hWnd, pszSubAppName, pszSubIDList); + } + + HTHEME GetWindowTheme() const + { + if(!this->IsThemingSupported()) + return NULL; + + const T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + return ::GetWindowTheme(pT->m_hWnd); + } + + HRESULT EnableThemeDialogTexture(DWORD dwFlags) + { + if(!this->IsThemingSupported()) + return S_FALSE; + + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + return ::EnableThemeDialogTexture(pT->m_hWnd, dwFlags); + } + + BOOL IsThemeDialogTextureEnabled() const + { + if(!this->IsThemingSupported()) + return FALSE; + + const T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + return ::IsThemeDialogTextureEnabled(pT->m_hWnd); + } + + HRESULT DrawThemeParentBackground(HDC hDC, const RECT* pRect = NULL) + { + if(!this->IsThemingSupported()) + return S_FALSE; + + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + return ::DrawThemeParentBackground(pT->m_hWnd, hDC, pRect); + } + +#if (_WIN32_WINNT >= 0x0600) + HRESULT SetWindowThemeAttribute(WINDOWTHEMEATTRIBUTETYPE type, PVOID pvAttribute, DWORD cbAttribute) + { + if(!this->IsThemingSupported()) + return S_FALSE; + + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + return ::SetWindowThemeAttribute(pT->m_hWnd, type, pvAttribute, cbAttribute); + } + + HRESULT SetWindowThemeNonClientAttributes(DWORD dwAttributes, DWORD dwMask) + { + if(!this->IsThemingSupported()) + return S_FALSE; + + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + WTA_OPTIONS opt = { dwAttributes, dwMask }; + return ::SetWindowThemeAttribute(pT->m_hWnd, WTA_NONCLIENT, (PVOID)&opt, sizeof(opt)); + } + + HRESULT DrawThemeParentBackgroundEx(HDC hDC, DWORD dwFlags, const RECT* lpRect = NULL) + { + if(!this->IsThemingSupported()) + return S_FALSE; + + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + return ::DrawThemeParentBackgroundEx(pT->m_hWnd, hDC, dwFlags, lpRect); + } +#endif // (_WIN32_WINNT >= 0x0600) + +// Message map and handlers + // Note: If you handle any of these messages in your derived class, + // it is better to put CHAIN_MSG_MAP at the start of your message map. + BEGIN_MSG_MAP(CThemeImpl) + MESSAGE_HANDLER(WM_CREATE, OnCreate) + MESSAGE_HANDLER(WM_DESTROY, OnDestroy) + MESSAGE_HANDLER(WM_THEMECHANGED, OnThemeChanged) + MESSAGE_HANDLER(WM_NCPAINT, OnNcPaint) + END_MSG_MAP() + + LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) + { + if(m_lpstrThemeClassList != NULL) + OpenThemeData(); + + bHandled = FALSE; + return 1; + } + + LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) + { + this->CloseThemeData(); + + bHandled = FALSE; + return 1; + } + + LRESULT OnThemeChanged(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) + { + this->CloseThemeData(); + if(m_lpstrThemeClassList != NULL) + this->OpenThemeData(); + + bHandled = FALSE; + return 1; + } + + LRESULT OnNcPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) + { + T* pT = static_cast(this); + ATLASSERT(::IsWindow(pT->m_hWnd)); + LRESULT lRet = 0; + bHandled = FALSE; + if(this->IsThemingSupported() && ((pT->GetExStyle() & WS_EX_CLIENTEDGE) != 0)) + { + if((m_dwExtendedStyle & THEME_EX_3DCLIENTEDGE) != 0) + { + lRet = ::DefWindowProc(pT->m_hWnd, uMsg, wParam, lParam); + bHandled = TRUE; + } + else if((this->m_hTheme != NULL) && ((m_dwExtendedStyle & THEME_EX_THEMECLIENTEDGE) != 0)) + { + HRGN hRgn = (wParam != 1) ? (HRGN)wParam : NULL; + if(pT->DrawThemeClientEdge(hRgn)) + bHandled = TRUE; + } + } + + return lRet; + } + +// Drawing helper + bool DrawThemeClientEdge(HRGN hRgnUpdate) + { + T* pT = static_cast(this); + return AtlDrawThemeClientEdge(this->m_hTheme, pT->m_hWnd, hRgnUpdate, NULL, 0, 0); + } +}; + +/////////////////////////////////////////////////////////////////////////////// +// Buffered Paint and Animation + +#if (_WIN32_WINNT >= 0x0600) + +/////////////////////////////////////////////////////////////////////////////// +// CBufferedPaintBase - Buffered Paint support for othe classes + +class CBufferedPaintBase +{ +public: + static int m_nIsBufferedPaintSupported; + + CBufferedPaintBase() + { + if(IsBufferedPaintSupported()) + ATLVERIFY(SUCCEEDED(::BufferedPaintInit())); + } + + ~CBufferedPaintBase() + { + if(IsBufferedPaintSupported()) + ATLVERIFY(SUCCEEDED(::BufferedPaintUnInit())); + } + + static bool IsBufferedPaintSupported() + { + if(m_nIsBufferedPaintSupported == -1) + { + CStaticDataInitCriticalSectionLock lock; + if(FAILED(lock.Lock())) + { + ATLTRACE2(atlTraceUI, 0, _T("ERROR : Unable to lock critical section in CBufferedPaintBase::IsBufferedPaintSupported.\n")); + ATLASSERT(FALSE); + return false; + } + + if(m_nIsBufferedPaintSupported == -1) + m_nIsBufferedPaintSupported = RunTimeHelper::IsVista() ? 1 : 0; + + lock.Unlock(); + } + + ATLASSERT(m_nIsBufferedPaintSupported != -1); + return (m_nIsBufferedPaintSupported == 1); + } +}; + +__declspec(selectany) int CBufferedPaintBase::m_nIsBufferedPaintSupported = -1; + + +/////////////////////////////////////////////////////////////////////////////// +// CBufferedPaint - support for buffered paint functions + +class CBufferedPaint +{ +public: + HPAINTBUFFER m_hPaintBuffer; + + CBufferedPaint() : m_hPaintBuffer(NULL) + { } + + ~CBufferedPaint() + { + ATLVERIFY(SUCCEEDED(End())); + } + + bool IsNull() const + { + return (m_hPaintBuffer == NULL); + } + + HPAINTBUFFER Begin(HDC hdcTarget, const RECT* prcTarget, BP_BUFFERFORMAT dwFormat, BP_PAINTPARAMS* pPaintParams, HDC* phdcPaint) + { + ATLASSERT(m_hPaintBuffer == NULL); + m_hPaintBuffer = ::BeginBufferedPaint(hdcTarget, prcTarget, dwFormat, pPaintParams, phdcPaint); + return m_hPaintBuffer; + } + + HRESULT End(BOOL bUpdate = TRUE) + { + HRESULT hRet = S_FALSE; + if(m_hPaintBuffer != NULL) + { + hRet = ::EndBufferedPaint(m_hPaintBuffer, bUpdate); + m_hPaintBuffer = NULL; + } + return hRet; + } + + HRESULT GetTargetRect(LPRECT pRect) const + { + ATLASSERT(m_hPaintBuffer != NULL); + return ::GetBufferedPaintTargetRect(m_hPaintBuffer, pRect); + } + + HDC GetTargetDC() const + { + ATLASSERT(m_hPaintBuffer != NULL); + return ::GetBufferedPaintTargetDC(m_hPaintBuffer); + } + + HDC GetPaintDC() const + { + ATLASSERT(m_hPaintBuffer != NULL); + return ::GetBufferedPaintDC(m_hPaintBuffer); + } + + HRESULT GetBits(RGBQUAD** ppbBuffer, int* pcxRow) const + { + ATLASSERT(m_hPaintBuffer != NULL); + return ::GetBufferedPaintBits(m_hPaintBuffer, ppbBuffer, pcxRow); + } + + HRESULT Clear(const RECT* pRect = NULL) + { + ATLASSERT(m_hPaintBuffer != NULL); + return ::BufferedPaintClear(m_hPaintBuffer, pRect); + } + + HRESULT SetAlpha(BYTE alpha, const RECT* pRect = NULL) + { + ATLASSERT(m_hPaintBuffer != NULL); + return ::BufferedPaintSetAlpha(m_hPaintBuffer, pRect, alpha); + } + + HRESULT MakeOpaque(const RECT* pRect = NULL) + { + ATLASSERT(m_hPaintBuffer != NULL); + return ::BufferedPaintSetAlpha(m_hPaintBuffer, pRect, 255); + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CBufferedPaintImpl - provides buffered paint for any window + +template +class ATL_NO_VTABLE CBufferedPaintImpl : public CBufferedPaintBase +{ +public: + CBufferedPaint m_BufferedPaint; + BP_BUFFERFORMAT m_dwFormat; + BP_PAINTPARAMS m_PaintParams; + + CBufferedPaintImpl() : m_dwFormat(BPBF_TOPDOWNDIB) + { + memset(&m_PaintParams, 0, sizeof(BP_PAINTPARAMS)); + m_PaintParams.cbSize = sizeof(BP_PAINTPARAMS); + } + +// Message map and handlers + BEGIN_MSG_MAP(CBufferedPaintImpl) + MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground) + MESSAGE_HANDLER(WM_PAINT, OnPaint) + MESSAGE_HANDLER(WM_PRINTCLIENT, OnPaint) + END_MSG_MAP() + + LRESULT OnEraseBackground(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + return 1; // no background needed + } + + LRESULT OnPaint(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + T* pT = static_cast(this); + if(wParam != NULL) + { + RECT rect = {}; + pT->GetClientRect(&rect); + pT->DoPaint((HDC)wParam, rect); + } + else + { + CPaintDC dc(pT->m_hWnd); + pT->DoBufferedPaint(dc.m_hDC, dc.m_ps.rcPaint); + } + + return 0; + } + +// Overrideables + void DoBufferedPaint(CDCHandle dc, RECT& rect) + { + HDC hDCPaint = NULL; + if(IsBufferedPaintSupported()) + m_BufferedPaint.Begin(dc, &rect, m_dwFormat, &m_PaintParams, &hDCPaint); + + T* pT = static_cast(this); + if(hDCPaint != NULL) + pT->DoPaint(hDCPaint, rect); + else + pT->DoPaint(dc.m_hDC, rect); + + if(IsBufferedPaintSupported()) + m_BufferedPaint.End(); + } + + void DoPaint(CDCHandle /*dc*/, RECT& /*rect*/) + { + // must be implemented in a derived class + ATLASSERT(FALSE); + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CBufferedPaintWindowImpl - implements a window that uses buffered paint + +template +class ATL_NO_VTABLE CBufferedPaintWindowImpl : + public ATL::CWindowImpl, + public CBufferedPaintImpl< T > +{ +public: + BEGIN_MSG_MAP(CBufferedPaintWindowImpl) + CHAIN_MSG_MAP(CBufferedPaintImpl< T >) + END_MSG_MAP() +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CBufferedAnimation - support for buffered animation + +class CBufferedAnimation +{ +public: + HANIMATIONBUFFER m_hAnimationBuffer; + + CBufferedAnimation() : m_hAnimationBuffer(NULL) + { } + + ~CBufferedAnimation() + { + ATLVERIFY(SUCCEEDED(End())); + } + + bool IsNull() const + { + return (m_hAnimationBuffer == NULL); + } + + HANIMATIONBUFFER Begin(HWND hWnd, HDC hDCTarget, const RECT* pRectTarget, BP_BUFFERFORMAT dwFormat, BP_PAINTPARAMS* pPaintParams, BP_ANIMATIONPARAMS* pAnimationParams, HDC* phdcFrom, HDC* phdcTo) + { + ATLASSERT(m_hAnimationBuffer == NULL); + m_hAnimationBuffer = ::BeginBufferedAnimation(hWnd, hDCTarget, pRectTarget, dwFormat, pPaintParams, pAnimationParams, phdcFrom, phdcTo); + return m_hAnimationBuffer; + } + + HRESULT End(BOOL bUpdate = TRUE) + { + HRESULT hRet = S_FALSE; + if(m_hAnimationBuffer != NULL) + { + hRet = ::EndBufferedAnimation(m_hAnimationBuffer, bUpdate); + m_hAnimationBuffer = NULL; + } + return hRet; + } + + static bool IsRendering(HWND hWnd, HDC hDC) + { + return (::BufferedPaintRenderAnimation(hWnd, hDC) != FALSE); + } + + static HRESULT StopAllAnimations(HWND hWnd) + { + return ::BufferedPaintStopAllAnimations(hWnd); + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CBufferedAnimationImpl - provides buffered animation support for any window + +// Note: You can either use m_State and m_NewState to store the state information +// for the animation change, or map your state to those data members. DoPaint() +// should only rely on the state information that is passed to it. + +template +class ATL_NO_VTABLE CBufferedAnimationImpl : public CBufferedPaintBase +{ +public: + BP_BUFFERFORMAT m_dwFormat; + BP_PAINTPARAMS m_PaintParams; + BP_ANIMATIONPARAMS m_AnimationParams; + + TState m_State; + TState m_NewState; + + CBufferedAnimationImpl(TState InitialState) : m_dwFormat(BPBF_TOPDOWNDIB) + { + memset(&m_PaintParams, 0, sizeof(BP_PAINTPARAMS)); + m_PaintParams.cbSize = sizeof(BP_PAINTPARAMS); + + memset(&m_AnimationParams, 0, sizeof(BP_ANIMATIONPARAMS)); + m_AnimationParams.cbSize = sizeof(BP_ANIMATIONPARAMS); + m_AnimationParams.style = BPAS_LINEAR; + m_AnimationParams.dwDuration = 500; + + T* pT = static_cast(this); + pT->SetState(InitialState); + pT->SetNewState(InitialState); + } + + DWORD GetDuration() const + { + return m_AnimationParams.dwDuration; + } + + void SetDuration(DWORD dwDuration) + { + m_AnimationParams.dwDuration = dwDuration; + } + + void DoAnimation(TState NewState, const RECT* pRect = NULL) + { + T* pT = static_cast(this); + pT->SetNewState(NewState); + + pT->InvalidateRect(pRect, FALSE); + pT->UpdateWindow(); + + pT->SetState(NewState); + } + +// Message map and handlers + BEGIN_MSG_MAP(CBufferedAnimationImpl) + MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground) + MESSAGE_HANDLER(WM_PAINT, OnPaint) + MESSAGE_HANDLER(WM_PRINTCLIENT, OnPaint) + END_MSG_MAP() + + LRESULT OnEraseBackground(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + return 1; // no background needed + } + + LRESULT OnPaint(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + T* pT = static_cast(this); + if(wParam != NULL) + { + RECT rect = {}; + pT->GetClientRect(&rect); + pT->DoPaint((HDC)wParam, rect, m_NewState); + } + else + { + CPaintDC dc(pT->m_hWnd); + pT->DoAnimationPaint(dc.m_hDC, dc.m_ps.rcPaint); + } + + return 0; + } + +// Overrideables + void SetState(TState State) + { + m_State = State; + } + + void SetNewState(TState State) + { + m_NewState = State; + } + + bool AreStatesEqual() const + { + return (m_State == m_NewState); + } + + void DoAnimationPaint(CDCHandle dc, RECT& rect) + { + T* pT = static_cast(this); + if(IsBufferedPaintSupported() && CBufferedAnimation::IsRendering(pT->m_hWnd, dc)) + return; + + DWORD dwDurationSave = m_AnimationParams.dwDuration; + if(pT->AreStatesEqual()) + m_AnimationParams.dwDuration = 0; + + HDC hdcFrom = NULL, hdcTo = NULL; + CBufferedAnimation ba; + if(IsBufferedPaintSupported()) + ba.Begin(pT->m_hWnd, dc, &rect, m_dwFormat, &m_PaintParams, &m_AnimationParams, &hdcFrom, &hdcTo); + + if(!ba.IsNull()) + { + if(hdcFrom != NULL) + pT->DoPaint(hdcFrom, rect, m_State); + + if (hdcTo != NULL) + pT->DoPaint(hdcTo, rect, m_NewState); + } + else + { + pT->DoPaint(dc.m_hDC, rect, m_NewState); + } + + m_AnimationParams.dwDuration = dwDurationSave; + } + + void DoPaint(CDCHandle /*dc*/, RECT& /*rect*/, TState /*State*/) + { + // must be implemented in a derived class + ATLASSERT(FALSE); + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CBufferedAnimationWindowImpl - implements a window that uses buffered animation + +template +class ATL_NO_VTABLE CBufferedAnimationWindowImpl : + public ATL::CWindowImpl, + public CBufferedAnimationImpl< T, TState > +{ +public: + CBufferedAnimationWindowImpl(TState InitialState) : CBufferedAnimationImpl< T, TState >(InitialState) + { } + + typedef CBufferedAnimationImpl< T, TState > _baseBufferedAnimation; + BEGIN_MSG_MAP(CBufferedAnimationWindowImpl) + CHAIN_MSG_MAP(_baseBufferedAnimation) + END_MSG_MAP() +}; + +#endif // (_WIN32_WINNT >= 0x0600) + +} // namespace WTL + +#endif // __ATLTHEME_H__ diff -r e9bb126753e7 -r 20d02a178406 foosdk/wtl/Include/atluser.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/wtl/Include/atluser.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,1231 @@ +// Windows Template Library - WTL version 10.0 +// Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. +// +// This file is a part of the Windows Template Library. +// The use and distribution terms for this software are covered by the +// Microsoft Public License (http://opensource.org/licenses/MS-PL) +// which can be found in the file MS-PL.txt at the root folder. + +#ifndef __ATLUSER_H__ +#define __ATLUSER_H__ + +#pragma once + +#ifndef __ATLAPP_H__ + #error atluser.h requires atlapp.h to be included first +#endif + + +/////////////////////////////////////////////////////////////////////////////// +// Classes in this file: +// +// CMenuItemInfo +// CMenuT +// CAcceleratorT +// CIconT +// CCursorT +// CResource +// +// Global functions: +// AtlMessageBox() +// +// AtlLoadAccelerators() +// AtlLoadMenu() +// AtlLoadBitmap() +// AtlLoadSysBitmap() +// AtlLoadCursor() +// AtlLoadSysCursor() +// AtlLoadIcon() +// AtlLoadSysIcon() +// AtlLoadBitmapImage() +// AtlLoadCursorImage() +// AtlLoadIconImage() +// AtlLoadSysBitmapImage() +// AtlLoadSysCursorImage() +// AtlLoadSysIconImage() +// AtlLoadString() + + +namespace WTL +{ + +/////////////////////////////////////////////////////////////////////////////// +// AtlMessageBox - accepts both memory and resource based strings + +inline int AtlMessageBox(HWND hWndOwner, ATL::_U_STRINGorID message, ATL::_U_STRINGorID title = (LPCTSTR)NULL, UINT uType = MB_OK | MB_ICONINFORMATION) +{ + ATLASSERT((hWndOwner == NULL) || ::IsWindow(hWndOwner)); + + LPTSTR lpstrMessage = NULL; + if(IS_INTRESOURCE(message.m_lpstr)) + { + for(int nLen = 256; ; nLen *= 2) + { + ATLTRY(lpstrMessage = new TCHAR[nLen]); + if(lpstrMessage == NULL) + { + ATLASSERT(FALSE); + return 0; + } + int nRes = ::LoadString(ModuleHelper::GetResourceInstance(), LOWORD(message.m_lpstr), lpstrMessage, nLen); + if(nRes < nLen - 1) + break; + delete [] lpstrMessage; + lpstrMessage = NULL; + } + + message.m_lpstr = lpstrMessage; + } + + LPTSTR lpstrTitle = NULL; + if(IS_INTRESOURCE(title.m_lpstr) && (LOWORD(title.m_lpstr) != 0)) + { + for(int nLen = 256; ; nLen *= 2) + { + ATLTRY(lpstrTitle = new TCHAR[nLen]); + if(lpstrTitle == NULL) + { + ATLASSERT(FALSE); + return 0; + } + int nRes = ::LoadString(ModuleHelper::GetResourceInstance(), LOWORD(title.m_lpstr), lpstrTitle, nLen); + if(nRes < nLen - 1) + break; + delete [] lpstrTitle; + lpstrTitle = NULL; + } + + title.m_lpstr = lpstrTitle; + } + + int nRet = ::MessageBox(hWndOwner, message.m_lpstr, title.m_lpstr, uType); + + delete [] lpstrMessage; + delete [] lpstrTitle; + + return nRet; +} + + +/////////////////////////////////////////////////////////////////////////////// +// CMenu + +class CMenuItemInfo : public MENUITEMINFO +{ +public: + CMenuItemInfo() + { + memset(this, 0, sizeof(MENUITEMINFO)); + cbSize = sizeof(MENUITEMINFO); + } +}; + + +// forward declarations +template class CMenuT; +typedef CMenuT CMenuHandle; +typedef CMenuT CMenu; + + +template +class CMenuT +{ +public: +// Data members + HMENU m_hMenu; + +// Constructor/destructor/operators + CMenuT(HMENU hMenu = NULL) : m_hMenu(hMenu) + { } + + ~CMenuT() + { + if(t_bManaged && (m_hMenu != NULL)) + DestroyMenu(); + } + + CMenuT& operator =(HMENU hMenu) + { + Attach(hMenu); + return *this; + } + + void Attach(HMENU hMenuNew) + { + ATLASSERT(::IsMenu(hMenuNew)); + if(t_bManaged && (m_hMenu != NULL) && (m_hMenu != hMenuNew)) + ::DestroyMenu(m_hMenu); + m_hMenu = hMenuNew; + } + + HMENU Detach() + { + HMENU hMenu = m_hMenu; + m_hMenu = NULL; + return hMenu; + } + + operator HMENU() const { return m_hMenu; } + + bool IsNull() const { return (m_hMenu == NULL); } + + BOOL IsMenu() const + { + return ::IsMenu(m_hMenu); + } + +// Create/destroy methods + BOOL CreateMenu() + { + ATLASSERT(m_hMenu == NULL); + m_hMenu = ::CreateMenu(); + return (m_hMenu != NULL) ? TRUE : FALSE; + } + + BOOL CreatePopupMenu() + { + ATLASSERT(m_hMenu == NULL); + m_hMenu = ::CreatePopupMenu(); + return (m_hMenu != NULL) ? TRUE : FALSE; + } + + BOOL LoadMenu(ATL::_U_STRINGorID menu) + { + ATLASSERT(m_hMenu == NULL); + m_hMenu = ::LoadMenu(ModuleHelper::GetResourceInstance(), menu.m_lpstr); + return (m_hMenu != NULL) ? TRUE : FALSE; + } + + BOOL LoadMenuIndirect(const void* lpMenuTemplate) + { + ATLASSERT(m_hMenu == NULL); + m_hMenu = ::LoadMenuIndirect(lpMenuTemplate); + return (m_hMenu != NULL) ? TRUE : FALSE; + } + + BOOL DestroyMenu() + { + if (m_hMenu == NULL) + return FALSE; + BOOL bRet = ::DestroyMenu(m_hMenu); + if(bRet) + m_hMenu = NULL; + return bRet; + } + +// Menu Operations + BOOL DeleteMenu(UINT nPosition, UINT nFlags) + { + ATLASSERT(::IsMenu(m_hMenu)); + return ::DeleteMenu(m_hMenu, nPosition, nFlags); + } + + BOOL TrackPopupMenu(UINT nFlags, int x, int y, HWND hWnd, LPCRECT lpRect = NULL) + { + ATLASSERT(::IsMenu(m_hMenu)); + x = _FixTrackMenuPopupX(x, y); + return ::TrackPopupMenu(m_hMenu, nFlags, x, y, 0, hWnd, lpRect); + } + + BOOL TrackPopupMenuEx(UINT uFlags, int x, int y, HWND hWnd, LPTPMPARAMS lptpm = NULL) + { + ATLASSERT(::IsMenu(m_hMenu)); + x = _FixTrackMenuPopupX(x, y); + return ::TrackPopupMenuEx(m_hMenu, uFlags, x, y, hWnd, lptpm); + } + + // helper that fixes popup menu X position when it's off-screen + static int _FixTrackMenuPopupX(int x, int y) + { + POINT pt = { x, y }; + HMONITOR hMonitor = ::MonitorFromPoint(pt, MONITOR_DEFAULTTONULL); + if(hMonitor == NULL) + { + HMONITOR hMonitorNear = ::MonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST); + if(hMonitorNear != NULL) + { + MONITORINFO mi = { sizeof(MONITORINFO) }; + if(::GetMonitorInfo(hMonitorNear, &mi) != FALSE) + { + if(x < mi.rcWork.left) + x = mi.rcWork.left; + else if(x > mi.rcWork.right) + x = mi.rcWork.right; + } + } + } + + return x; + } + + BOOL GetMenuInfo(LPMENUINFO lpMenuInfo) const + { + ATLASSERT(::IsMenu(m_hMenu)); + return ::GetMenuInfo(m_hMenu, lpMenuInfo); + } + + BOOL SetMenuInfo(LPCMENUINFO lpMenuInfo) + { + ATLASSERT(::IsMenu(m_hMenu)); + return ::SetMenuInfo(m_hMenu, lpMenuInfo); + } + +// Menu Item Operations + BOOL AppendMenu(UINT nFlags, UINT_PTR nIDNewItem = 0, LPCTSTR lpszNewItem = NULL) + { + ATLASSERT(::IsMenu(m_hMenu)); + return ::AppendMenu(m_hMenu, nFlags, nIDNewItem, lpszNewItem); + } + + BOOL AppendMenu(UINT nFlags, HMENU hSubMenu, LPCTSTR lpszNewItem) + { + ATLASSERT(::IsMenu(m_hMenu)); + ATLASSERT(::IsMenu(hSubMenu)); + return ::AppendMenu(m_hMenu, nFlags | MF_POPUP, (UINT_PTR)hSubMenu, lpszNewItem); + } + + BOOL AppendMenu(UINT nFlags, UINT_PTR nIDNewItem, HBITMAP hBmp) + { + ATLASSERT(::IsMenu(m_hMenu)); + return ::AppendMenu(m_hMenu, nFlags | MF_BITMAP, nIDNewItem, (LPCTSTR)hBmp); + } + + BOOL AppendMenu(UINT nFlags, HMENU hSubMenu, HBITMAP hBmp) + { + ATLASSERT(::IsMenu(m_hMenu)); + ATLASSERT(::IsMenu(hSubMenu)); + return ::AppendMenu(m_hMenu, nFlags | (MF_BITMAP | MF_POPUP), (UINT_PTR)hSubMenu, (LPCTSTR)hBmp); + } + + UINT CheckMenuItem(UINT nIDCheckItem, UINT nCheck) + { + ATLASSERT(::IsMenu(m_hMenu)); + return (UINT)::CheckMenuItem(m_hMenu, nIDCheckItem, nCheck); + } + + UINT EnableMenuItem(UINT nIDEnableItem, UINT nEnable) + { + ATLASSERT(::IsMenu(m_hMenu)); + return ::EnableMenuItem(m_hMenu, nIDEnableItem, nEnable); + } + + BOOL HiliteMenuItem(HWND hWnd, UINT uIDHiliteItem, UINT uHilite) + { + ATLASSERT(::IsMenu(m_hMenu)); + return ::HiliteMenuItem(hWnd, m_hMenu, uIDHiliteItem, uHilite); + } + + int GetMenuItemCount() const + { + ATLASSERT(::IsMenu(m_hMenu)); + return ::GetMenuItemCount(m_hMenu); + } + + UINT GetMenuItemID(int nPos) const + { + ATLASSERT(::IsMenu(m_hMenu)); + return ::GetMenuItemID(m_hMenu, nPos); + } + + UINT GetMenuState(UINT nID, UINT nFlags) const + { + ATLASSERT(::IsMenu(m_hMenu)); + return ::GetMenuState(m_hMenu, nID, nFlags); + } + + int GetMenuString(UINT nIDItem, LPTSTR lpString, int nMaxCount, UINT nFlags) const + { + ATLASSERT(::IsMenu(m_hMenu)); + return ::GetMenuString(m_hMenu, nIDItem, lpString, nMaxCount, nFlags); + } + + int GetMenuStringLen(UINT nIDItem, UINT nFlags) const + { + ATLASSERT(::IsMenu(m_hMenu)); + return ::GetMenuString(m_hMenu, nIDItem, NULL, 0, nFlags); + } + + BOOL GetMenuString(UINT nIDItem, BSTR& bstrText, UINT nFlags) const + { + USES_CONVERSION; + ATLASSERT(::IsMenu(m_hMenu)); + ATLASSERT(bstrText == NULL); + + int nLen = GetMenuStringLen(nIDItem, nFlags); + if(nLen == 0) + { + bstrText = ::SysAllocString(OLESTR("")); + return (bstrText != NULL) ? TRUE : FALSE; + } + + nLen++; // increment to include terminating NULL char + ATL::CTempBuffer buff; + LPTSTR lpszText = buff.Allocate(nLen); + if(lpszText == NULL) + return FALSE; + + if(!GetMenuString(nIDItem, lpszText, nLen, nFlags)) + return FALSE; + + bstrText = ::SysAllocString(T2OLE(lpszText)); + return (bstrText != NULL) ? TRUE : FALSE; + } + +#ifdef __ATLSTR_H__ + int GetMenuString(UINT nIDItem, ATL::CString& strText, UINT nFlags) const + { + ATLASSERT(::IsMenu(m_hMenu)); + + int nLen = GetMenuStringLen(nIDItem, nFlags); + if(nLen == 0) + return 0; + + nLen++; // increment to include terminating NULL char + LPTSTR lpstr = strText.GetBufferSetLength(nLen); + if(lpstr == NULL) + return 0; + int nRet = GetMenuString(nIDItem, lpstr, nLen, nFlags); + strText.ReleaseBuffer(); + return nRet; + } +#endif // __ATLSTR_H__ + + CMenuHandle GetSubMenu(int nPos) const + { + ATLASSERT(::IsMenu(m_hMenu)); + return CMenuHandle(::GetSubMenu(m_hMenu, nPos)); + } + + BOOL InsertMenu(UINT nPosition, UINT nFlags, UINT_PTR nIDNewItem = 0, LPCTSTR lpszNewItem = NULL) + { + ATLASSERT(::IsMenu(m_hMenu)); + return ::InsertMenu(m_hMenu, nPosition, nFlags, nIDNewItem, lpszNewItem); + } + + BOOL InsertMenu(UINT nPosition, UINT nFlags, HMENU hSubMenu, LPCTSTR lpszNewItem) + { + ATLASSERT(::IsMenu(m_hMenu)); + ATLASSERT(::IsMenu(hSubMenu)); + return ::InsertMenu(m_hMenu, nPosition, nFlags | MF_POPUP, (UINT_PTR)hSubMenu, lpszNewItem); + } + + BOOL InsertMenu(UINT nPosition, UINT nFlags, UINT_PTR nIDNewItem, HBITMAP hBmp) + { + ATLASSERT(::IsMenu(m_hMenu)); + return ::InsertMenu(m_hMenu, nPosition, nFlags | MF_BITMAP, nIDNewItem, (LPCTSTR)hBmp); + } + + BOOL InsertMenu(UINT nPosition, UINT nFlags, HMENU hSubMenu, HBITMAP hBmp) + { + ATLASSERT(::IsMenu(m_hMenu)); + ATLASSERT(::IsMenu(hSubMenu)); + return ::InsertMenu(m_hMenu, nPosition, nFlags | (MF_BITMAP | MF_POPUP), (UINT_PTR)hSubMenu, (LPCTSTR)hBmp); + } + + BOOL ModifyMenu(UINT nPosition, UINT nFlags, UINT_PTR nIDNewItem = 0, LPCTSTR lpszNewItem = NULL) + { + ATLASSERT(::IsMenu(m_hMenu)); + return ::ModifyMenu(m_hMenu, nPosition, nFlags, nIDNewItem, lpszNewItem); + } + + BOOL ModifyMenu(UINT nPosition, UINT nFlags, HMENU hSubMenu, LPCTSTR lpszNewItem) + { + ATLASSERT(::IsMenu(m_hMenu)); + ATLASSERT(::IsMenu(hSubMenu)); + return ::ModifyMenu(m_hMenu, nPosition, nFlags | MF_POPUP, (UINT_PTR)hSubMenu, lpszNewItem); + } + + BOOL ModifyMenu(UINT nPosition, UINT nFlags, UINT_PTR nIDNewItem, HBITMAP hBmp) + { + ATLASSERT(::IsMenu(m_hMenu)); + return ::ModifyMenu(m_hMenu, nPosition, nFlags | MF_BITMAP, nIDNewItem, (LPCTSTR)hBmp); + } + + BOOL ModifyMenu(UINT nPosition, UINT nFlags, HMENU hSubMenu, HBITMAP hBmp) + { + ATLASSERT(::IsMenu(m_hMenu)); + ATLASSERT(::IsMenu(hSubMenu)); + return ::ModifyMenu(m_hMenu, nPosition, nFlags | (MF_BITMAP | MF_POPUP), (UINT_PTR)hSubMenu, (LPCTSTR)hBmp); + } + + BOOL RemoveMenu(UINT nPosition, UINT nFlags) + { + ATLASSERT(::IsMenu(m_hMenu)); + return ::RemoveMenu(m_hMenu, nPosition, nFlags); + } + + BOOL SetMenuItemBitmaps(UINT nPosition, UINT nFlags, HBITMAP hBmpUnchecked, HBITMAP hBmpChecked) + { + ATLASSERT(::IsMenu(m_hMenu)); + return ::SetMenuItemBitmaps(m_hMenu, nPosition, nFlags, hBmpUnchecked, hBmpChecked); + } + + BOOL CheckMenuRadioItem(UINT nIDFirst, UINT nIDLast, UINT nIDItem, UINT nFlags) + { + ATLASSERT(::IsMenu(m_hMenu)); + return ::CheckMenuRadioItem(m_hMenu, nIDFirst, nIDLast, nIDItem, nFlags); + } + + BOOL GetMenuItemInfo(UINT uItem, BOOL bByPosition, LPMENUITEMINFO lpmii) const + { + ATLASSERT(::IsMenu(m_hMenu)); + return (BOOL)::GetMenuItemInfo(m_hMenu, uItem, bByPosition, lpmii); + } + + BOOL SetMenuItemInfo(UINT uItem, BOOL bByPosition, LPMENUITEMINFO lpmii) + { + ATLASSERT(::IsMenu(m_hMenu)); + return (BOOL)::SetMenuItemInfo(m_hMenu, uItem, bByPosition, lpmii); + } + + BOOL InsertMenuItem(UINT uItem, BOOL bByPosition, LPMENUITEMINFO lpmii) + { + ATLASSERT(::IsMenu(m_hMenu)); + return (BOOL)::InsertMenuItem(m_hMenu, uItem, bByPosition, lpmii); + } + + UINT GetMenuDefaultItem(BOOL bByPosition = FALSE, UINT uFlags = 0U) const + { + ATLASSERT(::IsMenu(m_hMenu)); + return ::GetMenuDefaultItem(m_hMenu, (UINT)bByPosition, uFlags); + } + + BOOL SetMenuDefaultItem(UINT uItem = (UINT)-1, BOOL bByPosition = FALSE) + { + ATLASSERT(::IsMenu(m_hMenu)); + return ::SetMenuDefaultItem(m_hMenu, uItem, (UINT)bByPosition); + } + + BOOL GetMenuItemRect(HWND hWnd, UINT uItem, LPRECT lprcItem) const + { + ATLASSERT(::IsMenu(m_hMenu)); + return ::GetMenuItemRect(hWnd, m_hMenu, uItem, lprcItem); + } + + int MenuItemFromPoint(HWND hWnd, POINT point) const + { + ATLASSERT(::IsMenu(m_hMenu)); + return ::MenuItemFromPoint(hWnd, m_hMenu, point); + } + +// Context Help Functions + BOOL SetMenuContextHelpId(DWORD dwContextHelpId) + { + ATLASSERT(::IsMenu(m_hMenu)); + return ::SetMenuContextHelpId(m_hMenu, dwContextHelpId); + } + + DWORD GetMenuContextHelpId() const + { + ATLASSERT(::IsMenu(m_hMenu)); + return ::GetMenuContextHelpId(m_hMenu); + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// CAccelerator + +template +class CAcceleratorT +{ +public: + HACCEL m_hAccel; + +// Constructor/destructor/operators + CAcceleratorT(HACCEL hAccel = NULL) : m_hAccel(hAccel) + { } + + ~CAcceleratorT() + { + if(t_bManaged && (m_hAccel != NULL)) + ::DestroyAcceleratorTable(m_hAccel); + } + + CAcceleratorT& operator =(HACCEL hAccel) + { + Attach(hAccel); + return *this; + } + + void Attach(HACCEL hAccel) + { + if(t_bManaged && (m_hAccel != NULL)) + ::DestroyAcceleratorTable(m_hAccel); + m_hAccel = hAccel; + } + + HACCEL Detach() + { + HACCEL hAccel = m_hAccel; + m_hAccel = NULL; + return hAccel; + } + + operator HACCEL() const { return m_hAccel; } + + bool IsNull() const { return m_hAccel == NULL; } + +// Create/destroy methods + HACCEL LoadAccelerators(ATL::_U_STRINGorID accel) + { + ATLASSERT(m_hAccel == NULL); + m_hAccel = ::LoadAccelerators(ModuleHelper::GetResourceInstance(), accel.m_lpstr); + return m_hAccel; + } + + HACCEL CreateAcceleratorTable(LPACCEL pAccel, int cEntries) + { + ATLASSERT(m_hAccel == NULL); + ATLASSERT(pAccel != NULL); + m_hAccel = ::CreateAcceleratorTable(pAccel, cEntries); + return m_hAccel; + } + + void DestroyObject() + { + if(m_hAccel != NULL) + { + ::DestroyAcceleratorTable(m_hAccel); + m_hAccel = NULL; + } + } + +// Operations + int CopyAcceleratorTable(LPACCEL lpAccelDst, int cEntries) + { + ATLASSERT(m_hAccel != NULL); + ATLASSERT(lpAccelDst != NULL); + return ::CopyAcceleratorTable(m_hAccel, lpAccelDst, cEntries); + } + + int GetEntriesCount() const + { + ATLASSERT(m_hAccel != NULL); + return ::CopyAcceleratorTable(m_hAccel, NULL, 0); + } + + BOOL TranslateAccelerator(HWND hWnd, LPMSG pMsg) + { + ATLASSERT(m_hAccel != NULL); + ATLASSERT(::IsWindow(hWnd)); + ATLASSERT(pMsg != NULL); + return ::TranslateAccelerator(hWnd, m_hAccel, pMsg); + } +}; + +typedef CAcceleratorT CAcceleratorHandle; +typedef CAcceleratorT CAccelerator; + + +/////////////////////////////////////////////////////////////////////////////// +// CIcon + +template +class CIconT +{ +public: + HICON m_hIcon; + +// Constructor/destructor/operators + CIconT(HICON hIcon = NULL) : m_hIcon(hIcon) + { } + + ~CIconT() + { + if(t_bManaged && (m_hIcon != NULL)) + ::DestroyIcon(m_hIcon); + } + + CIconT& operator =(HICON hIcon) + { + Attach(hIcon); + return *this; + } + + void Attach(HICON hIcon) + { + if(t_bManaged && (m_hIcon != NULL)) + ::DestroyIcon(m_hIcon); + m_hIcon = hIcon; + } + + HICON Detach() + { + HICON hIcon = m_hIcon; + m_hIcon = NULL; + return hIcon; + } + + operator HICON() const { return m_hIcon; } + + bool IsNull() const { return m_hIcon == NULL; } + +// Create/destroy methods + HICON LoadIcon(ATL::_U_STRINGorID icon) + { + ATLASSERT(m_hIcon == NULL); + m_hIcon = ::LoadIcon(ModuleHelper::GetResourceInstance(), icon.m_lpstr); + return m_hIcon; + } + + HICON LoadIcon(ATL::_U_STRINGorID icon, int cxDesired, int cyDesired, UINT fuLoad = 0) + { + ATLASSERT(m_hIcon == NULL); + m_hIcon = (HICON) ::LoadImage(ModuleHelper::GetResourceInstance(), icon.m_lpstr, IMAGE_ICON, cxDesired, cyDesired, fuLoad); + return m_hIcon; + } + + HICON LoadOEMIcon(LPCTSTR lpstrIconName) + { + ATLASSERT(m_hIcon == NULL); + ATLASSERT(IsOEMIcon(lpstrIconName)); + m_hIcon = ::LoadIcon(NULL, lpstrIconName); + return m_hIcon; + } + + HICON CreateIcon(int nWidth, int nHeight, BYTE cPlanes, BYTE cBitsPixel, CONST BYTE* lpbANDbits, CONST BYTE *lpbXORbits) + { + ATLASSERT(m_hIcon == NULL); + ATLASSERT(lpbANDbits != NULL); + ATLASSERT(lpbXORbits != NULL); + m_hIcon = ::CreateIcon(ModuleHelper::GetResourceInstance(), nWidth, nHeight, cPlanes, cBitsPixel, lpbANDbits, lpbXORbits); + return m_hIcon; + } + + HICON CreateIconFromResource(PBYTE pBits, DWORD dwResSize, DWORD dwVersion = 0x00030000) + { + ATLASSERT(m_hIcon == NULL); + ATLASSERT(pBits != NULL); + m_hIcon = ::CreateIconFromResource(pBits, dwResSize, TRUE, dwVersion); + return m_hIcon; + } + + HICON CreateIconFromResourceEx(PBYTE pbBits, DWORD cbBits, DWORD dwVersion = 0x00030000, int cxDesired = 0, int cyDesired = 0, UINT uFlags = LR_DEFAULTCOLOR) + { + ATLASSERT(m_hIcon == NULL); + ATLASSERT(pbBits != NULL); + ATLASSERT(cbBits > 0); + m_hIcon = ::CreateIconFromResourceEx(pbBits, cbBits, TRUE, dwVersion, cxDesired, cyDesired, uFlags); + return m_hIcon; + } + + HICON CreateIconIndirect(PICONINFO pIconInfo) + { + ATLASSERT(m_hIcon == NULL); + ATLASSERT(pIconInfo != NULL); + m_hIcon = ::CreateIconIndirect(pIconInfo); + return m_hIcon; + } + + HICON ExtractIcon(LPCTSTR lpszExeFileName, UINT nIconIndex) + { + ATLASSERT(m_hIcon == NULL); + ATLASSERT(lpszExeFileName != NULL); + m_hIcon = ::ExtractIcon(ModuleHelper::GetModuleInstance(), lpszExeFileName, nIconIndex); + return m_hIcon; + } + + HICON ExtractAssociatedIcon(HINSTANCE hInst, LPTSTR lpIconPath, LPWORD lpiIcon) + { + ATLASSERT(m_hIcon == NULL); + ATLASSERT(lpIconPath != NULL); + ATLASSERT(lpiIcon != NULL); + m_hIcon = ::ExtractAssociatedIcon(hInst, lpIconPath, lpiIcon); + return m_hIcon; + } + + BOOL DestroyIcon() + { + ATLASSERT(m_hIcon != NULL); + BOOL bRet = ::DestroyIcon(m_hIcon); + if(bRet != FALSE) + m_hIcon = NULL; + return bRet; + } + +// Operations + HICON CopyIcon() + { + ATLASSERT(m_hIcon != NULL); + return ::CopyIcon(m_hIcon); + } + + HICON DuplicateIcon() + { + ATLASSERT(m_hIcon != NULL); + return ::DuplicateIcon(NULL, m_hIcon); + } + + BOOL DrawIcon(HDC hDC, int x, int y) + { + ATLASSERT(m_hIcon != NULL); + return ::DrawIcon(hDC, x, y, m_hIcon); + } + + BOOL DrawIcon(HDC hDC, POINT pt) + { + ATLASSERT(m_hIcon != NULL); + return ::DrawIcon(hDC, pt.x, pt.y, m_hIcon); + } + + BOOL DrawIconEx(HDC hDC, int x, int y, int cxWidth, int cyWidth, UINT uStepIfAniCur = 0, HBRUSH hbrFlickerFreeDraw = NULL, UINT uFlags = DI_NORMAL) + { + ATLASSERT(m_hIcon != NULL); + return ::DrawIconEx(hDC, x, y, m_hIcon, cxWidth, cyWidth, uStepIfAniCur, hbrFlickerFreeDraw, uFlags); + } + + BOOL DrawIconEx(HDC hDC, POINT pt, SIZE size, UINT uStepIfAniCur = 0, HBRUSH hbrFlickerFreeDraw = NULL, UINT uFlags = DI_NORMAL) + { + ATLASSERT(m_hIcon != NULL); + return ::DrawIconEx(hDC, pt.x, pt.y, m_hIcon, size.cx, size.cy, uStepIfAniCur, hbrFlickerFreeDraw, uFlags); + } + + BOOL GetIconInfo(PICONINFO pIconInfo) const + { + ATLASSERT(m_hIcon != NULL); + ATLASSERT(pIconInfo != NULL); + return ::GetIconInfo(m_hIcon, pIconInfo); + } + +#if (_WIN32_WINNT >= 0x0600) + BOOL GetIconInfoEx(PICONINFOEX pIconInfo) const + { + ATLASSERT(m_hIcon != NULL); + ATLASSERT(pIconInfo != NULL); + return ::GetIconInfoEx(m_hIcon, pIconInfo); + } +#endif // (_WIN32_WINNT >= 0x0600) + +#if defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN) + HRESULT LoadIconMetric(ATL::_U_STRINGorID icon, int lims) + { + ATLASSERT(m_hIcon == NULL); + USES_CONVERSION; + return ::LoadIconMetric(ModuleHelper::GetResourceInstance(), T2CW(icon.m_lpstr), lims, &m_hIcon); + } + + HRESULT LoadIconWithScaleDown(ATL::_U_STRINGorID icon, int cx, int cy) + { + ATLASSERT(m_hIcon == NULL); + USES_CONVERSION; + return ::LoadIconWithScaleDown(ModuleHelper::GetResourceInstance(), T2CW(icon.m_lpstr), cx, cy, &m_hIcon); + } + + HRESULT LoadOEMIconMetric(LPCTSTR lpstrIconName, int lims) + { + ATLASSERT(m_hIcon == NULL); + ATLASSERT(IsOEMIcon(lpstrIconName)); + return ::LoadIconMetric(NULL, (LPCWSTR)lpstrIconName, lims, &m_hIcon); + } + + HRESULT LoadOEMIconWithScaleDown(LPCTSTR lpstrIconName, int cx, int cy) + { + ATLASSERT(m_hIcon == NULL); + ATLASSERT(IsOEMIcon(lpstrIconName)); + USES_CONVERSION; + return ::LoadIconWithScaleDown(NULL, (LPCWSTR)lpstrIconName, cx, cy, &m_hIcon); + } +#endif // defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN) + + // Helper + static bool IsOEMIcon(LPCTSTR lpstrIconName) + { +#if (WINVER >= 0x0600) + return ((lpstrIconName == IDI_APPLICATION) || (lpstrIconName == IDI_ASTERISK) || (lpstrIconName == IDI_EXCLAMATION) || + (lpstrIconName == IDI_HAND) || (lpstrIconName == IDI_QUESTION) || (lpstrIconName == IDI_WINLOGO) || + (lpstrIconName == IDI_SHIELD)); +#else // !(WINVER >= 0x0600) + return ((lpstrIconName == IDI_APPLICATION) || (lpstrIconName == IDI_ASTERISK) || (lpstrIconName == IDI_EXCLAMATION) || + (lpstrIconName == IDI_HAND) || (lpstrIconName == IDI_QUESTION) || (lpstrIconName == IDI_WINLOGO)); +#endif // !(WINVER >= 0x0600) + } +}; + +typedef CIconT CIconHandle; +typedef CIconT CIcon; + + +/////////////////////////////////////////////////////////////////////////////// +// CCursor + +// protect template member from a winuser.h macro +#ifdef CopyCursor + #undef CopyCursor +#endif + +template +class CCursorT +{ +public: + HCURSOR m_hCursor; + +// Constructor/destructor/operators + CCursorT(HCURSOR hCursor = NULL) : m_hCursor(hCursor) + { } + + ~CCursorT() + { + if(t_bManaged && (m_hCursor != NULL)) + DestroyCursor(); + } + + CCursorT& operator =(HCURSOR hCursor) + { + Attach(hCursor); + return *this; + } + + void Attach(HCURSOR hCursor) + { + if(t_bManaged && (m_hCursor != NULL)) + DestroyCursor(); + m_hCursor = hCursor; + } + + HCURSOR Detach() + { + HCURSOR hCursor = m_hCursor; + m_hCursor = NULL; + return hCursor; + } + + operator HCURSOR() const { return m_hCursor; } + + bool IsNull() const { return m_hCursor == NULL; } + +// Create/destroy methods + HCURSOR LoadCursor(ATL::_U_STRINGorID cursor) + { + ATLASSERT(m_hCursor == NULL); + m_hCursor = ::LoadCursor(ModuleHelper::GetResourceInstance(), cursor.m_lpstr); + return m_hCursor; + } + + HCURSOR LoadSysCursor(LPCTSTR lpstrCursorName) + { + ATLASSERT(m_hCursor == NULL); + ATLASSERT((lpstrCursorName == IDC_ARROW) || (lpstrCursorName == IDC_IBEAM) || (lpstrCursorName == IDC_WAIT) || + (lpstrCursorName == IDC_CROSS) || (lpstrCursorName == IDC_UPARROW) || (lpstrCursorName == IDC_SIZE) || + (lpstrCursorName == IDC_ICON) || (lpstrCursorName == IDC_SIZENWSE) || (lpstrCursorName == IDC_SIZENESW) || + (lpstrCursorName == IDC_SIZEWE) || (lpstrCursorName == IDC_SIZENS) || (lpstrCursorName == IDC_SIZEALL) || + (lpstrCursorName == IDC_NO) || (lpstrCursorName == IDC_APPSTARTING) || (lpstrCursorName == IDC_HELP) || + (lpstrCursorName == IDC_HAND)); + m_hCursor = ::LoadCursor(NULL, lpstrCursorName); + return m_hCursor; + } + + // deprecated + HCURSOR LoadOEMCursor(LPCTSTR lpstrCursorName) + { + return LoadSysCursor(lpstrCursorName); + } + + HCURSOR LoadCursor(ATL::_U_STRINGorID cursor, int cxDesired, int cyDesired, UINT fuLoad = 0) + { + ATLASSERT(m_hCursor == NULL); + m_hCursor = (HCURSOR) ::LoadImage(ModuleHelper::GetResourceInstance(), cursor.m_lpstr, IMAGE_CURSOR, cxDesired, cyDesired, fuLoad); + return m_hCursor; + } + + HCURSOR LoadCursorFromFile(LPCTSTR pstrFilename) + { + ATLASSERT(m_hCursor == NULL); + ATLASSERT(pstrFilename != NULL); + m_hCursor = ::LoadCursorFromFile(pstrFilename); + return m_hCursor; + } + + HCURSOR CreateCursor(int xHotSpot, int yHotSpot, int nWidth, int nHeight, CONST VOID *pvANDPlane, CONST VOID *pvXORPlane) + { + ATLASSERT(m_hCursor == NULL); + m_hCursor = ::CreateCursor(ModuleHelper::GetResourceInstance(), xHotSpot, yHotSpot, nWidth, nHeight, pvANDPlane, pvXORPlane); + return m_hCursor; + } + + HCURSOR CreateCursorFromResource(PBYTE pBits, DWORD dwResSize, DWORD dwVersion = 0x00030000) + { + ATLASSERT(m_hCursor == NULL); + ATLASSERT(pBits != NULL); + m_hCursor = (HCURSOR)::CreateIconFromResource(pBits, dwResSize, FALSE, dwVersion); + return m_hCursor; + } + + HCURSOR CreateCursorFromResourceEx(PBYTE pbBits, DWORD cbBits, DWORD dwVersion = 0x00030000, int cxDesired = 0, int cyDesired = 0, UINT uFlags = LR_DEFAULTCOLOR) + { + ATLASSERT(m_hCursor == NULL); + ATLASSERT(pbBits != NULL); + ATLASSERT(cbBits > 0); + m_hCursor = (HCURSOR)::CreateIconFromResourceEx(pbBits, cbBits, FALSE, dwVersion, cxDesired, cyDesired, uFlags); + return m_hCursor; + } + + BOOL DestroyCursor() + { + ATLASSERT(m_hCursor != NULL); + BOOL bRet = ::DestroyCursor(m_hCursor); + if(bRet != FALSE) + m_hCursor = NULL; + return bRet; + } + +// Operations + HCURSOR CopyCursor() + { + ATLASSERT(m_hCursor != NULL); + return (HCURSOR)::CopyIcon((HICON)m_hCursor); + } + + BOOL GetCursorInfo(LPCURSORINFO pCursorInfo) + { + ATLASSERT(m_hCursor != NULL); + ATLASSERT(pCursorInfo != NULL); + return ::GetCursorInfo(pCursorInfo); + } +}; + +typedef CCursorT CCursorHandle; +typedef CCursorT CCursor; + + +/////////////////////////////////////////////////////////////////////////////// +// CResource - Wraps a generic Windows resource. +// Use it with custom resource types other than the +// standard RT_CURSOR, RT_BITMAP, etc. + +class CResource +{ +public: + HGLOBAL m_hGlobal; + HRSRC m_hResource; + +// Constructor/destructor + CResource() : m_hGlobal(NULL), m_hResource(NULL) + { } + + ~CResource() + { + Release(); + } + +// Load methods + bool Load(ATL::_U_STRINGorID Type, ATL::_U_STRINGorID ID) + { + ATLASSERT(m_hResource == NULL); + ATLASSERT(m_hGlobal == NULL); + + m_hResource = ::FindResource(ModuleHelper::GetResourceInstance(), ID.m_lpstr, Type.m_lpstr); + if(m_hResource == NULL) + return false; + + m_hGlobal = ::LoadResource(ModuleHelper::GetResourceInstance(), m_hResource); + if(m_hGlobal == NULL) + { + m_hResource = NULL; + return false; + } + + return true; + } + + bool LoadEx(ATL::_U_STRINGorID ID, ATL::_U_STRINGorID Type, WORD wLanguage) + { + ATLASSERT(m_hResource == NULL); + ATLASSERT(m_hGlobal == NULL); + + m_hResource = ::FindResourceEx(ModuleHelper::GetResourceInstance(), Type.m_lpstr, ID.m_lpstr, wLanguage); + if(m_hResource == NULL) + return false; + + m_hGlobal = ::LoadResource(ModuleHelper::GetResourceInstance(), m_hResource); + if(m_hGlobal == NULL) + { + m_hResource = NULL; + return false; + } + + return true; + } + +// Misc. operations + DWORD GetSize() const + { + ATLASSERT(m_hResource != NULL); + return ::SizeofResource(ModuleHelper::GetResourceInstance(), m_hResource); + } + + LPVOID Lock() + { + ATLASSERT(m_hResource != NULL); + ATLASSERT(m_hGlobal != NULL); + LPVOID pVoid = ::LockResource(m_hGlobal); + ATLASSERT(pVoid != NULL); + return pVoid; + } + + void Release() + { + if(m_hGlobal != NULL) + { + FreeResource(m_hGlobal); + m_hGlobal = NULL; + m_hResource = NULL; + } + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// Toolbar resource descriptor + +struct _AtlToolBarData +{ + WORD wVersion; + WORD wWidth; + WORD wHeight; + WORD wItemCount; + + WORD* items() + { return (WORD*)(this+1); } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// Global functions for loading resources + +inline HACCEL AtlLoadAccelerators(ATL::_U_STRINGorID table) +{ + return ::LoadAccelerators(ModuleHelper::GetResourceInstance(), table.m_lpstr); +} + +inline HMENU AtlLoadMenu(ATL::_U_STRINGorID menu) +{ + return ::LoadMenu(ModuleHelper::GetResourceInstance(), menu.m_lpstr); +} + +inline HBITMAP AtlLoadBitmap(ATL::_U_STRINGorID bitmap) +{ + return ::LoadBitmap(ModuleHelper::GetResourceInstance(), bitmap.m_lpstr); +} + +#ifdef OEMRESOURCE +inline HBITMAP AtlLoadSysBitmap(ATL::_U_STRINGorID bitmap) +{ +#ifdef _DEBUG + WORD wID = LOWORD(bitmap.m_lpstr); + ATLASSERT((wID >= 32734) && (wID <= 32767)); +#endif // _DEBUG + return ::LoadBitmap(NULL, bitmap.m_lpstr); +} +#endif // OEMRESOURCE + +inline HCURSOR AtlLoadCursor(ATL::_U_STRINGorID cursor) +{ + return ::LoadCursor(ModuleHelper::GetResourceInstance(), cursor.m_lpstr); +} + +inline HCURSOR AtlLoadSysCursor(LPCTSTR lpCursorName) +{ + ATLASSERT((lpCursorName == IDC_ARROW) || (lpCursorName == IDC_IBEAM) || (lpCursorName == IDC_WAIT) || + (lpCursorName == IDC_CROSS) || (lpCursorName == IDC_UPARROW) || (lpCursorName == IDC_SIZE) || + (lpCursorName == IDC_ICON) || (lpCursorName == IDC_SIZENWSE) || (lpCursorName == IDC_SIZENESW) || + (lpCursorName == IDC_SIZEWE) || (lpCursorName == IDC_SIZENS) || (lpCursorName == IDC_SIZEALL) || + (lpCursorName == IDC_NO) || (lpCursorName == IDC_APPSTARTING) || (lpCursorName == IDC_HELP) || + (lpCursorName == IDC_HAND)); + return ::LoadCursor(NULL, lpCursorName); +} + +inline HICON AtlLoadIcon(ATL::_U_STRINGorID icon) +{ + return ::LoadIcon(ModuleHelper::GetResourceInstance(), icon.m_lpstr); +} + +inline HICON AtlLoadSysIcon(LPCTSTR lpIconName) +{ +#if (WINVER >= 0x0600) + ATLASSERT((lpIconName == IDI_APPLICATION) || (lpIconName == IDI_ASTERISK) || (lpIconName == IDI_EXCLAMATION) || + (lpIconName == IDI_HAND) || (lpIconName == IDI_QUESTION) || (lpIconName == IDI_WINLOGO) || + (lpIconName == IDI_SHIELD)); +#else // !(WINVER >= 0x0600) + ATLASSERT((lpIconName == IDI_APPLICATION) || (lpIconName == IDI_ASTERISK) || (lpIconName == IDI_EXCLAMATION) || + (lpIconName == IDI_HAND) || (lpIconName == IDI_QUESTION) || (lpIconName == IDI_WINLOGO)); +#endif // !(WINVER >= 0x0600) + return ::LoadIcon(NULL, lpIconName); +} + +inline HBITMAP AtlLoadBitmapImage(ATL::_U_STRINGorID bitmap, UINT fuLoad = LR_DEFAULTCOLOR) +{ + return (HBITMAP)::LoadImage(ModuleHelper::GetResourceInstance(), bitmap.m_lpstr, IMAGE_BITMAP, 0, 0, fuLoad); +} + +inline HCURSOR AtlLoadCursorImage(ATL::_U_STRINGorID cursor, UINT fuLoad = LR_DEFAULTCOLOR | LR_DEFAULTSIZE, int cxDesired = 0, int cyDesired = 0) +{ + return (HCURSOR)::LoadImage(ModuleHelper::GetResourceInstance(), cursor.m_lpstr, IMAGE_CURSOR, cxDesired, cyDesired, fuLoad); +} + +inline HICON AtlLoadIconImage(ATL::_U_STRINGorID icon, UINT fuLoad = LR_DEFAULTCOLOR | LR_DEFAULTSIZE, int cxDesired = 0, int cyDesired = 0) +{ + return (HICON)::LoadImage(ModuleHelper::GetResourceInstance(), icon.m_lpstr, IMAGE_ICON, cxDesired, cyDesired, fuLoad); +} + +#ifdef OEMRESOURCE +inline HBITMAP AtlLoadSysBitmapImage(WORD wBitmapID, UINT fuLoad = LR_DEFAULTCOLOR) +{ + ATLASSERT((wBitmapID >= 32734) && (wBitmapID <= 32767)); + ATLASSERT((fuLoad & LR_LOADFROMFILE) == 0); // this one doesn't load from a file + return (HBITMAP)::LoadImage(NULL, MAKEINTRESOURCE(wBitmapID), IMAGE_BITMAP, 0, 0, fuLoad); +} +#endif // OEMRESOURCE + +inline HCURSOR AtlLoadSysCursorImage(ATL::_U_STRINGorID cursor, UINT fuLoad = LR_DEFAULTCOLOR | LR_DEFAULTSIZE, int cxDesired = 0, int cyDesired = 0) +{ +#ifdef _DEBUG + WORD wID = LOWORD(cursor.m_lpstr); + ATLASSERT(((wID >= 32512) && (wID <= 32516)) || ((wID >= 32640) && (wID <= 32648)) || (wID == 32650) || (wID == 32651)); + ATLASSERT((fuLoad & LR_LOADFROMFILE) == 0); // this one doesn't load from a file +#endif // _DEBUG + return (HCURSOR)::LoadImage(NULL, cursor.m_lpstr, IMAGE_CURSOR, cxDesired, cyDesired, fuLoad); +} + +inline HICON AtlLoadSysIconImage(ATL::_U_STRINGorID icon, UINT fuLoad = LR_DEFAULTCOLOR | LR_DEFAULTSIZE, int cxDesired = 0, int cyDesired = 0) +{ +#ifdef _DEBUG + WORD wID = LOWORD(icon.m_lpstr); + ATLASSERT((wID >= 32512) && (wID <= 32517)); + ATLASSERT((fuLoad & LR_LOADFROMFILE) == 0); // this one doesn't load from a file +#endif // _DEBUG + return (HICON)::LoadImage(NULL, icon.m_lpstr, IMAGE_ICON, cxDesired, cyDesired, fuLoad); +} + +inline bool AtlLoadString(UINT uID, BSTR& bstrText) +{ + USES_CONVERSION; + ATLASSERT(bstrText == NULL); + + LPTSTR lpstrText = NULL; + int nRes = 0; + for(int nLen = 256; ; nLen *= 2) + { + ATLTRY(lpstrText = new TCHAR[nLen]); + if(lpstrText == NULL) + break; + nRes = ::LoadString(ModuleHelper::GetResourceInstance(), uID, lpstrText, nLen); + if(nRes < nLen - 1) + break; + delete [] lpstrText; + lpstrText = NULL; + } + + if(lpstrText != NULL) + { + if(nRes != 0) + bstrText = ::SysAllocString(T2OLE(lpstrText)); + delete [] lpstrText; + } + + return (bstrText != NULL) ? true : false; +} + +} // namespace WTL + +#endif // __ATLUSER_H__ diff -r e9bb126753e7 -r 20d02a178406 foosdk/wtl/Include/atlwinx.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/wtl/Include/atlwinx.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,599 @@ +// Windows Template Library - WTL version 10.0 +// Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. +// +// This file is a part of the Windows Template Library. +// The use and distribution terms for this software are covered by the +// Microsoft Public License (http://opensource.org/licenses/MS-PL) +// which can be found in the file MS-PL.txt at the root folder. + +#ifndef __ATLWINX_H__ +#define __ATLWINX_H__ + +#pragma once + +#ifndef __ATLAPP_H__ + #error atlwinx.h requires atlapp.h to be included first +#endif + +#include + + +/////////////////////////////////////////////////////////////////////////////// +// Classes in this file: +// +// CWindowEx + + +///////////////////////////////////////////////////////////////////////////// +// Additional macros needed for template classes + +#ifndef DECLARE_WND_CLASS_EX2 + #define DECLARE_WND_CLASS_EX2(WndClassName, EnclosingClass, style, bkgnd) \ + static ATL::CWndClassInfo& GetWndClassInfo() \ + { \ + static ATL::CWndClassInfo wc = \ + { \ + { sizeof(WNDCLASSEX), style, EnclosingClass::StartWindowProc, \ + 0, 0, NULL, NULL, NULL, (HBRUSH)(bkgnd + 1), NULL, WndClassName, NULL }, \ + NULL, NULL, IDC_ARROW, TRUE, 0, _T("") \ + }; \ + return wc; \ + } +#endif // DECLARE_WND_CLASS_EX2 + +#ifndef DECLARE_WND_SUPERCLASS2 + #define DECLARE_WND_SUPERCLASS2(WndClassName, EnclosingClass, OrigWndClassName) \ + static ATL::CWndClassInfo& GetWndClassInfo() \ + { \ + static ATL::CWndClassInfo wc = \ + { \ + { sizeof(WNDCLASSEX), 0, EnclosingClass::StartWindowProc, \ + 0, 0, NULL, NULL, NULL, NULL, NULL, WndClassName, NULL }, \ + OrigWndClassName, NULL, NULL, TRUE, 0, _T("") \ + }; \ + return wc; \ + } +#endif // DECLARE_WND_SUPERCLASS2 + + +/////////////////////////////////////////////////////////////////////////////// +// Command Chaining Macros + +#define CHAIN_COMMANDS(theChainClass) \ + if(uMsg == WM_COMMAND) \ + CHAIN_MSG_MAP(theChainClass) + +#define CHAIN_COMMANDS_ALT(theChainClass, msgMapID) \ + if(uMsg == WM_COMMAND) \ + CHAIN_MSG_MAP_ALT(theChainClass, msgMapID) + +#define CHAIN_COMMANDS_MEMBER(theChainMember) \ + if(uMsg == WM_COMMAND) \ + CHAIN_MSG_MAP_MEMBER(theChainMember) + +#define CHAIN_COMMANDS_ALT_MEMBER(theChainMember, msgMapID) \ + if(uMsg == WM_COMMAND) \ + CHAIN_MSG_MAP_ALT_MEMBER(theChainMember, msgMapID) + + +/////////////////////////////////////////////////////////////////////////////// +// Macros for parent message map to selectively reflect control messages + +// NOTE: ReflectNotifications is a member of ATL's CWindowImplRoot +// (and overridden in 2 cases - CContainedWindowT and CAxHostWindow) +// Since we can't modify ATL, we'll provide the needed additions +// in a separate function (that is not a member of CWindowImplRoot) + +namespace WTL +{ + +inline LRESULT WtlReflectNotificationsFiltered(HWND hWndParent, UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled, + UINT uMsgFilter = WM_NULL, UINT_PTR idFromFilter = 0, HWND hWndChildFilter = NULL) +{ + if((uMsgFilter != WM_NULL) && (uMsgFilter != uMsg)) + { + // The notification message doesn't match the filter. + bHandled = FALSE; + return 1; + } + + HWND hWndChild = NULL; + UINT_PTR idFrom = 0; + + switch(uMsg) + { + case WM_COMMAND: + if(lParam != NULL) // not from a menu + { + hWndChild = (HWND)lParam; + idFrom = (UINT_PTR)LOWORD(wParam); + } + break; + case WM_NOTIFY: + hWndChild = ((LPNMHDR)lParam)->hwndFrom; + idFrom = ((LPNMHDR)lParam)->idFrom; + break; + case WM_PARENTNOTIFY: + switch(LOWORD(wParam)) + { + case WM_CREATE: + case WM_DESTROY: + hWndChild = (HWND)lParam; + idFrom = (UINT_PTR)HIWORD(wParam); + break; + default: + hWndChild = ::GetDlgItem(hWndParent, HIWORD(wParam)); + idFrom = (UINT_PTR)::GetDlgCtrlID(hWndChild); + break; + } + break; + case WM_DRAWITEM: + if(wParam) // not from a menu + { + hWndChild = ((LPDRAWITEMSTRUCT)lParam)->hwndItem; + idFrom = (UINT_PTR)wParam; + } + break; + case WM_MEASUREITEM: + if(wParam) // not from a menu + { + hWndChild = ::GetDlgItem(hWndParent, ((LPMEASUREITEMSTRUCT)lParam)->CtlID); + idFrom = (UINT_PTR)wParam; + } + break; + case WM_COMPAREITEM: + if(wParam) // not from a menu + { + hWndChild = ((LPCOMPAREITEMSTRUCT)lParam)->hwndItem; + idFrom = (UINT_PTR)wParam; + } + break; + case WM_DELETEITEM: + if(wParam) // not from a menu + { + hWndChild = ((LPDELETEITEMSTRUCT)lParam)->hwndItem; + idFrom = (UINT_PTR)wParam; + } + break; + case WM_VKEYTOITEM: + case WM_CHARTOITEM: + case WM_HSCROLL: + case WM_VSCROLL: + hWndChild = (HWND)lParam; + idFrom = (UINT_PTR)::GetDlgCtrlID(hWndChild); + break; + case WM_CTLCOLORBTN: + case WM_CTLCOLORDLG: + case WM_CTLCOLOREDIT: + case WM_CTLCOLORLISTBOX: + case WM_CTLCOLORMSGBOX: + case WM_CTLCOLORSCROLLBAR: + case WM_CTLCOLORSTATIC: + hWndChild = (HWND)lParam; + idFrom = (UINT_PTR)::GetDlgCtrlID(hWndChild); + break; + default: + break; + } + + if((hWndChild == NULL) || + ((hWndChildFilter != NULL) && (hWndChildFilter != hWndChild))) + { + // Either hWndChild isn't valid, or + // hWndChild doesn't match the filter. + bHandled = FALSE; + return 1; + } + + if((idFromFilter != 0) && (idFromFilter != idFrom)) + { + // The dialog control id doesn't match the filter. + bHandled = FALSE; + return 1; + } + + ATLASSERT(::IsWindow(hWndChild)); + LRESULT lResult = ::SendMessage(hWndChild, OCM__BASE + uMsg, wParam, lParam); + if((lResult == 0) && (uMsg >= WM_CTLCOLORMSGBOX) && (uMsg <= WM_CTLCOLORSTATIC)) + { + // Try to prevent problems with WM_CTLCOLOR* messages when + // the message wasn't really handled + bHandled = FALSE; + } + + return lResult; +} + +} // namespace WTL + +// Try to prevent problems with WM_CTLCOLOR* messages when +// the message wasn't really handled +#define REFLECT_NOTIFICATIONS_EX() \ +{ \ + bHandled = TRUE; \ + lResult = this->ReflectNotifications(uMsg, wParam, lParam, bHandled); \ + if((lResult == 0) && (uMsg >= WM_CTLCOLORMSGBOX) && (uMsg <= WM_CTLCOLORSTATIC)) \ + bHandled = FALSE; \ + if(bHandled) \ + return TRUE; \ +} + +#define REFLECT_NOTIFICATIONS_MSG_FILTERED(uMsgFilter) \ + { \ + bHandled = TRUE; \ + lResult = WTL::WtlReflectNotificationsFiltered(this->m_hWnd, uMsg, wParam, lParam, bHandled, uMsgFilter, 0, NULL); \ + if(bHandled) \ + return TRUE; \ + } + +#define REFLECT_NOTIFICATIONS_ID_FILTERED(idFromFilter) \ + { \ + bHandled = TRUE; \ + lResult = WTL::WtlReflectNotificationsFiltered(this->m_hWnd, uMsg, wParam, lParam, bHandled, WM_NULL, idFromFilter, NULL); \ + if(bHandled) \ + return TRUE; \ + } + +#define REFLECT_NOTIFICATIONS_HWND_FILTERED(hWndChildFilter) \ + { \ + bHandled = TRUE; \ + lResult = WTL::WtlReflectNotificationsFiltered(this->m_hWnd, uMsg, wParam, lParam, bHandled, WM_NULL, 0, hWndChildFilter); \ + if(bHandled) \ + return TRUE; \ + } + +#define REFLECT_NOTIFICATIONS_MSG_ID_FILTERED(uMsgFilter, idFromFilter) \ + { \ + bHandled = TRUE; \ + lResult = WTL::WtlReflectNotificationsFiltered(this->m_hWnd, uMsg, wParam, lParam, bHandled, uMsgFilter, idFromFilter, NULL); \ + if(bHandled) \ + return TRUE; \ + } + +#define REFLECT_NOTIFICATIONS_MSG_HWND_FILTERED(uMsgFilter, hWndChildFilter) \ + { \ + bHandled = TRUE; \ + lResult = WTL::WtlReflectNotificationsFiltered(this->m_hWnd, uMsg, wParam, lParam, bHandled, uMsgFilter, 0, hWndChildFilter); \ + if(bHandled) \ + return TRUE; \ + } + +#define REFLECT_COMMAND(id, code) \ + if((uMsg == WM_COMMAND) && (id == LOWORD(wParam)) && (code == HIWORD(wParam))) \ + { \ + bHandled = TRUE; \ + lResult = this->ReflectNotifications(uMsg, wParam, lParam, bHandled); \ + if(bHandled) \ + return TRUE; \ + } + +#define REFLECT_COMMAND_ID(id) \ + if((uMsg == WM_COMMAND) && (id == LOWORD(wParam))) \ + { \ + bHandled = TRUE; \ + lResult = this->ReflectNotifications(uMsg, wParam, lParam, bHandled); \ + if(bHandled) \ + return TRUE; \ + } + +#define REFLECT_COMMAND_CODE(code) \ + if((uMsg == WM_COMMAND) && (code == HIWORD(wParam))) \ + { \ + bHandled = TRUE; \ + lResult = this->ReflectNotifications(uMsg, wParam, lParam, bHandled); \ + if(bHandled) \ + return TRUE; \ + } + +#define REFLECT_COMMAND_RANGE(idFirst, idLast) \ + if((uMsg == WM_COMMAND) && (LOWORD(wParam) >= idFirst) && (LOWORD(wParam) <= idLast)) \ + { \ + bHandled = TRUE; \ + lResult = this->ReflectNotifications(uMsg, wParam, lParam, bHandled); \ + if(bHandled) \ + return TRUE; \ + } + +#define REFLECT_COMMAND_RANGE_CODE(idFirst, idLast, code) \ + if((uMsg == WM_COMMAND) && (code == HIWORD(wParam)) && (LOWORD(wParam) >= idFirst) && (LOWORD(wParam) <= idLast)) \ + { \ + bHandled = TRUE; \ + lResult = this->ReflectNotifications(uMsg, wParam, lParam, bHandled); \ + if(bHandled) \ + return TRUE; \ + } + +#define REFLECT_NOTIFY(id, cd) \ + if((uMsg == WM_NOTIFY) && (id == ((LPNMHDR)lParam)->idFrom) && (cd == ((LPNMHDR)lParam)->code)) \ + { \ + bHandled = TRUE; \ + lResult = this->ReflectNotifications(uMsg, wParam, lParam, bHandled); \ + if(bHandled) \ + return TRUE; \ + } + +#define REFLECT_NOTIFY_ID(id) \ + if((uMsg == WM_NOTIFY) && (id == ((LPNMHDR)lParam)->idFrom)) \ + { \ + bHandled = TRUE; \ + lResult = this->ReflectNotifications(uMsg, wParam, lParam, bHandled); \ + if(bHandled) \ + return TRUE; \ + } + +#define REFLECT_NOTIFY_CODE(cd) \ + if((uMsg == WM_NOTIFY) && (cd == ((LPNMHDR)lParam)->code)) \ + { \ + bHandled = TRUE; \ + lResult = this->ReflectNotifications(uMsg, wParam, lParam, bHandled); \ + if(bHandled) \ + return TRUE; \ + } + +#define REFLECT_NOTIFY_RANGE(idFirst, idLast) \ + if((uMsg == WM_NOTIFY) && (((LPNMHDR)lParam)->idFrom >= idFirst) && (((LPNMHDR)lParam)->idFrom <= idLast)) \ + { \ + bHandled = TRUE; \ + lResult = this->ReflectNotifications(uMsg, wParam, lParam, bHandled); \ + if(bHandled) \ + return TRUE; \ + } + +#define REFLECT_NOTIFY_RANGE_CODE(idFirst, idLast, cd) \ + if((uMsg == WM_NOTIFY) && (cd == ((LPNMHDR)lParam)->code) && (((LPNMHDR)lParam)->idFrom >= idFirst) && (((LPNMHDR)lParam)->idFrom <= idLast)) \ + { \ + bHandled = TRUE; \ + lResult = this->ReflectNotifications(uMsg, wParam, lParam, bHandled); \ + if(bHandled) \ + return TRUE; \ + } + + +/////////////////////////////////////////////////////////////////////////////// +// GetClassLong/SetClassLong redefinition to avoid problems with class members + +#ifdef SetClassLongPtrA + #undef SetClassLongPtrA + inline LONG_PTR SetClassLongPtrA(HWND hWnd, int nIndex, LONG_PTR dwNewLong) + { + return ::SetClassLongA(hWnd, nIndex, LONG(dwNewLong)); + } +#endif + +#ifdef SetClassLongPtrW + #undef SetClassLongPtrW + inline LONG_PTR SetClassLongPtrW(HWND hWnd, int nIndex, LONG_PTR dwNewLong) + { + return ::SetClassLongW(hWnd, nIndex, LONG(dwNewLong)); + } +#endif + +#ifdef GetClassLongPtrA + #undef GetClassLongPtrA + inline LONG_PTR GetClassLongPtrA(HWND hWnd, int nIndex) + { + return ::GetClassLongA(hWnd, nIndex); + } +#endif + +#ifdef GetClassLongPtrW + #undef GetClassLongPtrW + inline LONG_PTR GetClassLongPtrW(HWND hWnd, int nIndex) + { + return ::GetClassLongW(hWnd, nIndex); + } +#endif + + +/////////////////////////////////////////////////////////////////////////////// +// CWindowEx - extension of ATL::CWindow + +namespace WTL +{ + +class CWindowEx : public ATL::CWindow +{ +public: + CWindowEx(HWND hWnd = NULL) : ATL::CWindow(hWnd) + { } + + CWindowEx& operator =(HWND hWnd) + { + m_hWnd = hWnd; + return *this; + } + + operator HWND() const + { + return m_hWnd; + } + +// Methods + BOOL PrintWindow(HDC hDC, UINT uFlags = 0) + { + ATLASSERT(::IsWindow(m_hWnd)); + return ::PrintWindow(m_hWnd, hDC, uFlags); + } + + BOOL DragDetect(POINT pt) + { + ATLASSERT(::IsWindow(m_hWnd)); + return ::DragDetect(m_hWnd, pt); + } + + BOOL DragDetect() + { + ATLASSERT(::IsWindow(m_hWnd)); + + POINT pt = {}; + ::GetCursorPos(&pt); + return ::DragDetect(m_hWnd, pt); + } + + CWindowEx GetAncestor(UINT uFlags) const + { + ATLASSERT(::IsWindow(m_hWnd)); + return CWindowEx(::GetAncestor(m_hWnd, uFlags)); + } + + // Note: Does not work properly on Vista Aero and above + BOOL AnimateWindow(DWORD dwFlags, DWORD dwTime = 200) + { + ATLASSERT(::IsWindow(m_hWnd)); + return ::AnimateWindow(m_hWnd, dwTime, dwFlags); + } + + BOOL FlashWindowEx(DWORD dwFlags, UINT uCount, DWORD dwTimeout = 0) + { + ATLASSERT(::IsWindow(m_hWnd)); + + FLASHWINFO fi = { sizeof(FLASHWINFO) }; + fi.hwnd = m_hWnd; + fi.dwFlags = dwFlags; + fi.uCount = uCount; + fi.dwTimeout = dwTimeout; + return ::FlashWindowEx(&fi); + } + + BOOL StopFlashWindowEx() + { + ATLASSERT(::IsWindow(m_hWnd)); + + FLASHWINFO fi = { sizeof(FLASHWINFO) }; + fi.hwnd = m_hWnd; + fi.dwFlags = FLASHW_STOP; + return ::FlashWindowEx(&fi); + } + +// Class long properties + DWORD GetClassLong(int nIndex) const + { + ATLASSERT(::IsWindow(m_hWnd)); + return ::GetClassLong(m_hWnd, nIndex); + } + + DWORD SetClassLong(int nIndex, LONG dwNewLong) + { + ATLASSERT(::IsWindow(m_hWnd)); + return ::SetClassLong(m_hWnd, nIndex, dwNewLong); + } + + ULONG_PTR GetClassLongPtr(int nIndex) const + { + ATLASSERT(::IsWindow(m_hWnd)); + return ::GetClassLongPtr(m_hWnd, nIndex); + } + + ULONG_PTR SetClassLongPtr(int nIndex, LONG_PTR dwNewLong) + { + ATLASSERT(::IsWindow(m_hWnd)); + return ::SetClassLongPtr(m_hWnd, nIndex, dwNewLong); + } + +// Layered windows + BOOL SetLayeredWindowAttributes(COLORREF crlKey, BYTE byteAlpha, DWORD dwFlags) + { + ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT((GetExStyle() & WS_EX_LAYERED) != 0); + + return ::SetLayeredWindowAttributes(m_hWnd, crlKey, byteAlpha, dwFlags); + } + + BOOL UpdateLayeredWindow(HDC hdcDst, LPPOINT pptDst, LPSIZE psize, HDC hdcSrc, LPPOINT pptSrc, COLORREF crlKey, BLENDFUNCTION* pblend, DWORD dwFlags) + { + ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT((GetExStyle() & WS_EX_LAYERED) != 0); + + return ::UpdateLayeredWindow(m_hWnd, hdcDst, pptDst, psize, hdcSrc, pptSrc, crlKey, pblend, dwFlags); + } + + BOOL UpdateLayeredWindow(LPPOINT pptDst = NULL) + { + ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT((GetExStyle() & WS_EX_LAYERED) != 0); + + return ::UpdateLayeredWindow(m_hWnd, NULL, pptDst, NULL, NULL, NULL, CLR_NONE, NULL, 0); + } + + BOOL GetLayeredWindowAttributes(COLORREF* pcrlKey, BYTE* pbyteAlpha, DWORD* pdwFlags) const + { + ATLASSERT(::IsWindow(m_hWnd)); + ATLASSERT((GetExStyle() & WS_EX_LAYERED) != 0); + + return ::GetLayeredWindowAttributes(m_hWnd, pcrlKey, pbyteAlpha, pdwFlags); + } + +// Mouse tracking + BOOL StartTrackMouseLeave() + { + ATLASSERT(::IsWindow(m_hWnd)); + + TRACKMOUSEEVENT tme = {}; + tme.cbSize = sizeof(TRACKMOUSEEVENT); + tme.dwFlags = TME_LEAVE; + tme.hwndTrack = m_hWnd; + return ::TrackMouseEvent(&tme); + } + + BOOL StartTrackMouse(DWORD dwFlags, DWORD dwHoverTime = HOVER_DEFAULT) + { + ATLASSERT(::IsWindow(m_hWnd)); + + TRACKMOUSEEVENT tme = {}; + tme.cbSize = sizeof(TRACKMOUSEEVENT); + tme.dwFlags = dwFlags; + tme.hwndTrack = m_hWnd; + tme.dwHoverTime = dwHoverTime; + return ::TrackMouseEvent(&tme); + } + + BOOL CancelTrackMouse(DWORD dwType) + { + ATLASSERT(::IsWindow(m_hWnd)); + + TRACKMOUSEEVENT tme = {}; + tme.cbSize = sizeof(TRACKMOUSEEVENT); + tme.dwFlags = TME_CANCEL | dwType; + tme.hwndTrack = m_hWnd; + return ::TrackMouseEvent(&tme); + } + +// CString support +#ifdef __ATLSTR_H__ + int GetWindowText(ATL::CString& strText) const + { + int nLength = GetWindowTextLength(); + LPTSTR pszText = strText.GetBuffer(nLength + 1); + nLength = ::GetWindowText(m_hWnd, pszText, nLength + 1); + strText.ReleaseBuffer(nLength); + + return nLength; + } + + UINT GetDlgItemText(int nID, ATL::CString& strText) const + { + ATLASSERT(::IsWindow(m_hWnd)); + + HWND hItem = GetDlgItem(nID); + if(hItem != NULL) + { + int nLength = ::GetWindowTextLength(hItem); + LPTSTR pszText = strText.GetBuffer(nLength + 1); + nLength = ::GetWindowText(hItem, pszText, nLength + 1); + strText.ReleaseBuffer(nLength); + + return nLength; + } + else + { + strText.Empty(); + + return 0; + } + } +#endif // __ATLSTR_H__ +}; + +} // namespace WTL + +#endif // __ATLWINX_H__ diff -r e9bb126753e7 -r 20d02a178406 foosdk/wtl/MS-PL.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/wtl/MS-PL.txt Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,22 @@ +Microsoft Public License (MS-PL) + +This license governs use of the accompanying software. If you use the software, you +accept this license. If you do not accept the license, do not use the software. + +1. Definitions +The terms "reproduce," "reproduction," "derivative works," and "distribution" have the +same meaning here as under U.S. copyright law. +A "contribution" is the original software, or any additions or changes to the software. +A "contributor" is any person that distributes its contribution under this license. +"Licensed patents" are a contributor's patent claims that read directly on its contribution. + +2. Grant of Rights +(A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create. +(B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software. + +3. Conditions and Limitations +(A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. +(B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically. +(C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software. +(D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license. +(E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement. diff -r e9bb126753e7 -r 20d02a178406 foosdk/wtl/ReadMe.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/wtl/ReadMe.html Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,2581 @@ + + + + + + Windows Template Library + + + + + + + + + + + + + + + + + + + + + + + + +
+ Windows Template Library - WTL 10 +                + version 10.0.10077 (2020-03-17) +

Copyright © 2020 Microsoft Corporation, WTL Team. All rights reserved.

+ This file is a part of the Windows Template Library.
+ The use and distribution terms for this software are covered by the
+ Microsoft Public License (http://opensource.org/licenses/MS-PL)
+ which can be found in the file MS-PL.txt at the root folder. +

+


+ +

Welcome to the Windows Template Library, version 10. This document contains the following topics:

+ + +


+ +

Introduction

+

+ Windows Template Library, or WTL, is a set of + classes that extend ATL to support more complex user interfaces for either + applications or various UI components, while maintaining the big advantage of + ATL - small and fast code. WTL classes were designed to be the best and the + easiest way to implement rich Win32 based UI for ATL based applications, + servers, components, and controls. +

+ +

+ WTL provides support for implementing many + user interface elements, from frame and popup windows, to MDI, standard and + common controls, common dialogs, property sheets and pages, GDI objects, UI + updating, scrollable windows, splitter windows, command bars, etc. The WTL + classes are mostly templated and use minimal instance data and inline functions. + They were not designed as a framework, so they do not force a particular + application model, and can accommodate any. The classes do not use hooks or + thread local storage, so they have no restrictions that those techniques impose. + They also have no inter-dependencies and can be freely mixed with straight SDK + code. In summary, WTL delivers very small and efficient code, very close in size + and speed to SDK programs, while presenting a more logical, object oriented + model to a programmer. +

+


+ +

Features and Installation

+ +

+ This is the ninth public release of WTL. This version is released + under the Microsoft Public License, enabling developers from the WTL community to + contribute to the library. +

+

+ WTL classes can be used with all versions of VC++ from 2005 to the newest, 2019. + AppWizard for Visual Studio is included. +

+

+ The WTL classes are provided in header files located in the include directory. + The only header files that must be included is atlapp.h, while others can be used when needed. + The name of the file doesn't mean that you have to create an application, just that + atlapp.h contains base definitions required for WTL projects. +

+

+ To install WTL, just copy the whole directory structure, or unpack the archive file, + to the location of your choice. Please be sure to add the WTL\include directory + to the list of include directories in VC++, so that the compiler + can find them when you include them in your projects. +

+

+ Setup programs for the AppWizard are provided. After executing the setup script, + ATL/WTL AppWizard will appear in the list of AppWizards when you select File.New.Project + in VC++ IDE. The file AppWiz\setup.js is the setup script for all supported versions of Visual Studio. +

+

+ To manually install AppWizard for VC++ 2005, copy all WTLAppWiz.* files from AppWiz\Files to VC++ + projects directory, %VCDIR%\VC\vcprojects, where %VCDIR% is the directory + where VC++ 2005 is installed. After that, open WTL10AppWiz.vsz and modify the + line that contains ABSOLUTE_PATH to contain %WTLDIR%\AppWiz\Files, where + %WTLDIR% is the directory where WTL files are. +

+ +

Compiler/IDE/ATL support:

+
    +
  • Visual C++ 2005    (ATL 8.0)
  • +
  • Visual C++ 2008    (ATL 9.0)
  • +
  • Visual C++ 2010    (ATL 10.0)
  • +
  • Visual C++ 2012    (ATL 11.0)
  • +
  • Visual C++ 2013    (ATL 12.0)
  • +
  • Visual C++ 2015    (ATL 14.0)
  • +
  • Visual C++ 2017    (ATL 14.0)
  • +
  • Visual C++ 2019    (ATL 14.0)
  • +
+


+ +

Windows SDK support (optional):

+
    +
  • Windows SDK 6.0 or newer
  • +
+


+


+ +

Packing List

+


+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
File Name:Description:

readme.htmlthis file
MS-PL.txtMicrosoft Public License
 
include\
    atlapp.hmessage loop, interfaces, + general app stuff
    atlcrack.hmessage cracker macros
    atlctrls.hstandard and common control + classes
    atlctrlw.hcommand bar class
    atlctrlx.hbitmap button, check list view, + and other controls
    atlddx.hdata exchange for dialogs and + windows
    atldlgs.hcommon dialog classes, property + sheet and page classes
    atldwm.hDWM support classes
    atlfind.hFind/Replace support for Edit + and RichEdit
    atlframe.hframe window classes, MDI, + update UI classes
    atlgdi.hDC classes, GDI object classes
    atlmisc.hWTL ports of CPoint, CRect, + CSize, CString, etc.
    atlprint.hprinting and print preview
    atlres.hstandard resource IDs
    atlribbon.hRibbonUI support
    atlscrl.hscrollable windows
    atlsplit.hsplitter windows
    atltheme.hWindows XP theme classes
    atluser.hmenu class, USER object classes
    atlwinx.hextensions of ATL windowing + support
 
Samples\
    Aero\...Vista Aero glass showcase
    Alpha\...Windows XP 32-bit (alpha) + toolbar images
    BmpView\...bitmap file view sample
    GuidGen\...WTL version of the GuidGen + sample
    MDIDocVw\...WTL version of the MDI sample
    MemDlg\...In-memory dialog sample
    MTPad\...multithreaded notepad sample
    MTPad7\...MTPad with RibbonUI
    TabBrowser\...Web browser using TabView
    Wizard97Test\...Wizard97 showcase + sample
    WTLExplorer\...Explorer-like application + sample
 
AppWiz\
    setup.jsAppWizard setup program for all versions of + Visual Studio
    Files\...WTL AppWizard files
+


+


+ +

Class Overview

+


+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
usage:       mi base   -   a base class (multiple inheritance)
 client   -   wrapper class for a handle
 as-is   -   to be used directly
 impl   -   implements a window (has + WindowProc) or other support
 helper   -   a helper class
 base   -   implementation base class
+


+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
class name:usage:description:

App/module support
CAppModuleas-isapp support, CComModule derived
CServerAppModuleas-ismodule for COM servers
CMessageLoopas-ismessage loop
CMessageFiltermi basemessage filter interface
CIdleHandlermi baseidle time handler interface

Frame windows
CFrameWindowImplBasebase 
CFrameWindowImplimplframe window support
COwnerDrawimpl mi baseowner-draw msg map and handlers
CDialogResize + impl mi basesupport for resizing dialogs
CDoubleBufferImpl + impl midouble-buffer painting support
CDoubleBufferWindowImpl + impldouble-buffer painting window

MDI windows
CMDIWindowclientMDI methods
CMDIFrameWindowImplimplMDI frame window
CMDIChildWindowImplimplMDI child window

Update UI
CUpdateUIBasebase 
CUpdateUImi base classprovides support for UI update
CDynamicUpdateUImi base classprovides dynamic support for UI update

Standard controls
CStaticclientstatic ctrl
CButtonclientbutton ctrl
CListBoxclientlist box ctrl
CComboBoxclientcombo box ctrl
CEditclientedit ctrl
CEditCommandsmistandard edit command support
CScrollBarclientscroll bar ctrl

Common controls
CImageListclientimage list
CListViewCtrlclientlist view ctrl
CTreeViewCtrlclienttree view ctrl
CTreeItemhelper 
CTreeViewCtrlExclientuses CTreeItem
CHeaderCtrlclientheader bar ctrl
CToolBarCtrlclienttoolbar ctrl
CStatusBarCtrlclientstatus bar ctrl
CTabCtrlclienttab ctrl
CToolTipCtrlclienttool tip ctrl
CToolInfohelper 
CTrackBarCtrlclienttrackbar ctrl
CUpDownCtrlclientup-down ctrl
CProgressBarCtrlclientprogress bar ctrl
CHotKeyCtrlclienthot key ctrl
CAnimateCtrlclientanimation ctrl
CRichEditCtrlclientrich edit ctrl
CRichEditCommandsmistd rich edit commands support
CDragListBoxclientdrag list box
CDragListNotifyImplimpl mi classsupport for notifications
CReBarCtrlclientrebar ctrl
CComboBoxExclientextended combo box
CDateTimePickerCtrlclientdate-time ctrl
CFlatScrollBarImplmi implflat scroll bars support
CFlatScrollBaras-isflat scroll bars support
CIPAddressCtrlclientIP address ctrl
CMonthCalendarCtrlclientmonth calendar ctrl
CCustomDrawimpl mi classcustom draw handling support

Property sheet & page
CPropertySheetWindowclient 
CPropertySheetImplimplproperty sheet
CPropertySheetas-is 
CPropertyPageWindowclient 
CPropertyPageImplimplproperty page
CPropertyPageas-is 
CAxPropertyPageImplimplproperty page with ActiveX
CAxPropertyPageas-is 
CWizard97SheetWindowclient 
CWizard97SheetImplimplWizard97 property sheet
CWizard97Sheetas-is 
CWizard97PageWindowclient 
CWizard97PageImplimplWizard97 property page
CWizard97ExteriorPageImplimplWizard97 exterior page
CWizard97InteriorPageImplimplWizard97 interior page
CAeroWizardFrameWindowclient 
CAeroWizardFrameImplimplAero Wizard frame
CAeroWizardFrameas-is 
CAeroWizardPageWindowclient 
CAeroWizardPageImplimplAero Wizard page
CAeroWizardPageas-is 
CAeroWizardAxPageImplimplAero Wizard page with ActiveX
CAeroWizardAxPageas-is 

Common dialogs
CFileDialogImplimplGetOpenFileName/GetSaveFileName
CFileDialogas-is 
CSimpleFileDialogas-isno customization
CMultiFileDialogImplimplMulti-select GetOpenFileName
CMultiFileDialogas-is 
CShellFileDialogImplbase 
CShellFileOpenDialogImplimplShell File Open dialog
CShellFileOpenDialogas-is 
CShellFileSaveDialogImplimplShell File Save dialog
CShellFileSaveDialogas-is 
CFolderDialogImplimpldirectory picker
CFolderDialogas-is 
CFontDialogImplimplChooseFont common dialog
CFontDialogas-is 
CRichEditFontDialogImplimplChooseFont for rich edit
CRichEditFontDialogas-is 
CColorDialogImplimplChooseColor common dialog
CColorDialogas-is 
CPrintDialogImplimplPrintDlg common dialog
CPrintDialogas-is 
CPrintDialogExImplimplnew Win2000 print dialog
CPrintDialogExas-is 
CPageSetupDialogImplimplPageSetupDlg common dialog
CPageSetupDialogas-is 
CFindReplaceDialogImplimplFindText/ReplaceText
CFindReplaceDialogas-is 

User support
CMenuclientmenu support
CMenuItemInfoas-isMENUITEMINFO wrapper
CAcceleratorclientaccelerator table
CIconclienticon object
CCursorclientcursor object
CResourceclientgeneric resource object

GDI support
CDCclientDC support
CPaintDCclientfor handling WM_PAINT
CClientDCclientfor GetDC
CWindowDCclientfor GetWindowDC
CMemoryDCclientin-memory DC
CPenclientGDI pen object
CBrushclientGDI brush object
CLogFontas-isLOGFONT wrapper
CFontclientGDI font object
CBitmapclientGDI bitmap object
CPaletteclientGDI palette object
CRgnclientGDI region object

Enhanced controls
CCommandBarCtrlImplimplcommand bar
CCommandBarCtrlas-is 
CBitmapButtonImplimplbitmap button
CBitmapButtonas-is 
CCheckListViewCtrlImplimplcheck list box
CCheckListViewCtrlas-is 
CHyperLinkImplimplhyper link control
CHyperLinkas-is 
CWaitCursoras-iswait cursor
CCustomWaitCursoras-iscustom and animated wait cursor
CMultiPaneStatusBarCtrlImplimplstatus bar with multiple panes
CMultiPaneStatusBarCtrlas-is 
CPaneContainerImplimplpane window container
CPaneContaineras-is 
CSortListViewImplimplsorting list view control
CSortListViewCtrlImplimpl 
CSortListViewCtrlas-is 
CTabViewImpl;impltab view window
CTabViewas-is 

Scrolling window support
CScrollImplimpl miscrolling support
CScrollWindowImplimplscrollable window
CMapScrollImplimpl miscrolling support with map modes
CMapScrollWindowImplimplscrollable window with map modes
CZoomScrollImplimpl mizooming support
CZoomScrollWindowImplimplzooming window
CScrollContainerImplimplscroll container window
CScrollContaineras-is 

Splitter window support
CSplitterImplimpl misplitter support
CSplitterWindowImplimplsplitter window
CSplitterWindowas-is 

Theming support
CThemeclientWindows XP theme
CThemeImplimpltheming support for a window

Buffered paint and animation support
CBufferedPaintas-isbuffered paint
CBufferedPaintImplimpl mibuffered paint support
CBufferedPaintWindowImplimplwindow with buffered paint
CBufferedAnimationas-isbuffered animation
CBufferedAnimationImplimpl mibuffered animation support
CBufferedAnimationWindowImplimplwindow with buffered animation

Edit and RichEdit Find/Replace support
CEditFindReplaceImplBasebase 
CEditFindReplaceImplmiEdit Find/Replace support
CRichEditFindReplaceImplmiRichEdit Find/Replace support

Printing support
CPrinterInfoas-isprint info support
CPrinterclientprinter handle wrapper
CDevModeclientDEVMODE wrapper
CPrinterDCclientprinting DC support
CPrintJobInfoclientprint job info
CPrintJobclientprint job support
CPrintPreviewmiprint preview support
CPrintPreviewWindowImplimplprint preview window
CPrintPreviewWindowas-is 
CZoomPrintPreviewWindowImplimplzooming print preview window
CZoomPrintPreviewWindowas-is 

Miscellaneous
CWinDataExchangemidata exchange for controls
CRecentDocumentListmi or as-issupport for MRU list
CFindFileas-isfile search support
CRegPropertyas-isregistry properties support
CRegPropertyImplimplregistry properties via map

In-memory dialog
CDialogBaseUnitshelperdialog units helper
CMemDlgTemplateas-isIn-memory dialog template
CIndirectDialogImplimplIn-memory dialog class

Task dialog
CTaskDialogImplimplTask Dialog in Vista
CTaskDialogas-is 

DWM classes
CDwmclientDWM handle warapper
CDwmImplimpl baseDWM support
CDwmWindowimplDWM window support
CDwmThumbnailclientDWM thumbnail wrapper
CAeroControlImplimplsupport for Aero controls

Ribbon classes
CRibbonUpdateUImi baseautomatic mapping of ribbon UI elements
RibbonUI::CtrlImplbase implbase class for all ribbon controls
RibbonUI::CommandCtrlImplbase implbase class for ribbon controls
RibbonUI::CollectionImplBasebasebase class for all RibbonUI collections
RibbonUI::CollectionImplimplRibbonUI collections
RibbonUI::CollectionCtrlImplimplspecializable class for ribbon collection controls
RibbonUI::ToolbarGalleryCtrlImplbase implbase class for ribbon toolbar gallery controls
RibbonUI::CRibbonImplimplRibbon implementation class
CRibbonFrameWindowImplBasebasebase frame class for Ribbon
CRibbonFrameWindowImplimplRibbon frame window class
CRibbonMDIFrameWindowImplimplRibbon MDI frame window class
CRibbonPersistas-isRibbon persistance support
+


+


+ +

ATL/WTL AppWizard

+ +

ATL/WTL AppWizard generates starting code for a WTL application. It has options to create code for different application types and features.

+

You can choose the following options:

+
    +
  • Application type (SDI, multi thread SDI, MDI, TabView, Explorer, dialog based)
  • +
  • Support for hosting ActiveX controls
  • +
  • COM server support
  • +
  • Class implementation in .CPP files
  • +
  • Common Control manifest
  • +
  • Unicode character set
  • +
  • Toolbar, rebar, command bar, status bar
  • +
  • View window, and it's type (generic, dialog form, or a list box, edit, list view, tree view, rich edit, HTML page, scroll window)
  • +
  • For dialog based apps or a form based view window - support for hosting ActiveX controls in the dialog
  • +
+


+ +

ATL/WTL AppWizard supports VC++ 2005, 2008, 2010, 2012, 2013, 2015, 2017, and 2019.

+


+


+ +

How to use WTL in an MFC project

+ +

If you want to use WTL in an MFC project, you need to put these 2 lines before including atlapp.h:

+

+ namespace ATL { using ::CString; };
+ #define _WTL_NO_AUTOMATIC_NAMESPACE +

+

The first line tells WTL to use CString from global namespace, because CString is defined that way in MFC. +The second line prevents name collisions between WTL and MFC. Use the WTL namespace prefix explicitly.

+ +


+


+ +


+ +

WTL Releases

+


+ +

History

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
WTL 10?
WTL 9.12015
WTL 9.02014
WTL 8.02007
WTL 7.52005
WTL 7.12003
WTL 7.02002
WTL 3.12000
WTL 3.01999
+


+ +

Changes Between WTL 10 and 9.1

+

TODO

+


+ +

Changes Between WTL 9.1 and 9.0

+

New and improved:

+
+

+ Full compatibility with VS2015
+ NuGet support and package
+ Microsoft Public License (MS-PL)
+ New sample: MemDlg - demonstrates use of in-memory dialogs +

+
+


+ +

Fixes and enhancements:

+
+

+ Fixes for code analysis warnings
+ Fixes for strict const-qualification conformance (/Zc:strictStrings)
+ CEditFindReplaceImpl::UseShadowBuffer(): Use AtlGetCommCtrlVersion() instead of GetProcAddress()
+ Misc improvements: missing initialization, undefined messages, better #ifdefs
+ CFrameWndClassInfo: Use GetSystemMetrics() for icon sizes
+ BEGIN_MSG_MAP_EX and BEGIN_DDX_MAP: Fix for C4555: expression has no effect
+ CResource::LoadEx(): Fix for the wrong order for parameters to ::FindResourceEx()
+ CPaneContainerImpl: +

+
    +
  • New extended styles: PANECNT_DIVIDER and PANECNT_GRADIENT
  • +
  • Fixed background drawing for close button
  • +
+

+ CImageListManaged: Fix for assert when using attach or operator =
+ WTLExplorer sample cleanup
+ GenericWndClass::Register(): Fix for Windows CE
+ App Wizard: Improved code for generating project configurations
+ CSplitterImpl::OnCaptureChanged(): Fixed so it moves splitter bar only if move was in progress
+ CDynamicUpdateUI::UIRemoveUpdateElement() leaks memory if UPDUI_TEXT is set
+ CToolInfo and CToolTipCtrl: nIDTool argument should be UINT_PTR instead of UINT
+ CSplitterImpl: Added GetSplitterPosPct()
+ CCommandBarCtrlImpl: Fixed incorrect use of m_wndParent when AttachToWindow() is used +

+
+


+ +

Changes Between WTL 9.0 and 8.0

+

New and improved:

+
+

+ Full compatibility with VS2008, VS2010, VS2012, and VS2013
+ New CRegKeyEx class for uniform support for registry
+ New MinCrtHelper functions for uniform support for _ATL_MIN_CRT
+ New DWM classes in atldwm.h
+ New Ribbon classes in atlribbon.h
+ New CDialogBaseUnits class
+ Extended DDX support to TabCtrl, ComboBox, ListBox and ListView selection index
+ Improved font handling in CHyperLink, CPaneContainer, CTabView
+ CHyperlink: Added options for auto-create link font and single-line mode
+ CBitmapButtonImpl: Added checked state, GetCheck()/SetCheck(), and check mode extended styles
+ UpdateUI: Added support for radio menu items for popup menus
+ Added support for new VersionHelpers.h in WinSDK 8.1 - GetVersionEx() is now deprecated
+ Improved global support for old SDK headers, and for original headers in VC6 and VC7.x
+ Global support for builds with NOMINMAX defined
+ Global support for builds with STRICT_TYPED_ITEMIDS defined
+ Global support for builds with _ATL_ALL_USER_WARNINGS defined
+ Splitter Window: +

+
    +
  • Added keyboard handling
  • +
  • Added default position for splitter bar
  • +
  • Changed orientation from template argument to data member to reduce memory use
  • +
  • Added SPLIT_GRADIENTBAR and SPLIT_FIXEDBARSIZE extended styles
  • +
+

+ Added CImageListManaged to manage the lifetime of wrapped image list
+ Added Vista standard menu bar look option for Command bar
+ Added new Rich Edit wrappers for _RICHEDIT_VER >= 0x0800
+ Added new Win8 methods to Theme classes
+ Added override of SubclassWindow() to CSplitterWindowImpl, CPaneContainerImpl, CTabViewImpl,
+   CScrollImpl, CMapScrollImpl, CZoomScrollImpl, and CScrollContainerImpl
+ CZoomScrollImpl: +

+
    +
  • Added zoom child windows option
  • +
  • Added zoom scale max limit
  • +
+

+ AppWizard: +

+
    +
  • Support for VS2008, VS2010, VS2012, and VS2013
  • +
  • New universal setup for all versions of Visual Studio
  • +
  • Support for ribbon control
  • +
+

+ Updated samples and added VS2005 project files
+ New sample: MTPad7 - demonstrates Ribbon UI +

+
+


+ +

Fixes and enhancements:

+
+

General:

+
    +
  • Fixed security warning for _vstprintf in atlapp.h
  • +
  • Added RunTimeHelper::IsThemeAvailable that detects if themes can be used in the app
  • +
  • VS2012: DLL version functions are defined as they are removed from ATL11
  • +
  • Added CWndProcThunk initialization for _ATL_VER >= 0x0800
  • +
  • Added RunTimeHelper::SizeOf_TOOLINFO() for different Windows versions at runtime
  • +
  • Added AtlCreateControlFont()
  • +
+


+

Controls:

+
    +
  • Extended CListViewCtrl::SelectItem() to multi-selection list view controls
  • +
  • Added another variant of CListViewCtrl::FindItem for strings
  • +
  • Added new CToolBarCtrl methods - InsertSeparator() and AddSeparator()
  • +
  • Added CToolBarCtrl::GetItemDropDownRect()
  • +
  • Added another variant of CToolTipCtrl::TrackActivate()
  • +
+


+

Cracked Handlers:

+
    +
  • Fixed handlers with menu arguments
  • +
  • Fixed MSG_WM_SYSCOMMAND handler
  • +
  • Added MSG_WM_MOUSEHWHEEL handler
  • +
+


+

App Wizard:

+
    +
  • Fix for TabView project code generation
  • +
  • Improved generated code for VC++ Express to support various versions of ATL
  • +
  • Fix for missing UIUpdateChildWindows() in dialog projects
  • +
+


+

App Wizard CE / App Wizard Mobile:

+
    +
  • Updated AppWizCE for VS2008 - used different CLSID for Platforms object
  • +
  • Fix: VS2008 uses _SECURE_ATL code only
  • +
  • Fix for resource creation failure
  • +
+


+

Misc:

+
    +
  • Fix: CLogFont uses ::GetDeviceCaps with wrong default hDC = NULL
  • +
  • Fixed CPen::GetExtLogPen
  • +
  • Fixed CFrameWindowImpl::OnToolTipText*() handlers not to reset text buffer
  • +
  • Added support for chevron menus for multi-line toolbars
  • +
  • Fix: CFileDialog(false) fails on Windows Mobile 5 or 6
  • +
  • Fix: CFolderDialog::SetOKText should use lParam for string
  • +
  • Added CFolderDialog::SetPidlRoot()
  • +
  • Fixed CMemDlgTemplate::AddControl
  • +
  • Added option to disable item dragging in CTabViewImpl
  • +
  • Fixed CTabView::ShowTabControl(false) and UpdateLayout() to hide empty space
  • +
  • CTabView: Fixed value of the active page when inserting pages before it
  • +
  • PaneContainer: Added support for vertical title bar text
  • +
  • atlsplit.h: Added missing support for WM_PRINTCLIENT
  • +
  • Fix: CScrollImpl should not scroll horizontally if not needed
  • +
  • Fixed CScrollImpl::ScrollToView() to use offset correctly
  • +
  • Fixed CPrintDialogExImpl::GetDefaults()
  • +
  • atltheme.h: Added CBufferedAnimation::StopAllAnimations()
  • +
  • Added support for I64 format to CString::Format()
  • +
  • Fix: CStdIndirectDialogImpl - DLGTEMPLATEEX not supported on Mobile devices
  • +
  • Fix: Missing CRichInkCtrlT::SetSel(), added CRichInkCtrlT::Undo()
  • +
+
+


+ +

Changes Between WTL 8.0 and 7.5

+

New and improved:

+
+

RunTimeHelper functions for + correct struct sizes on different versions of Windows
ModuleHelper functions for uniform support of ATL3 and ATL7 module classes
SecureHelper functions for support of secure and non-secure run-time + functions
Support for new Vista features:

+
    +
  • Support for new messages for common controls, dialogs, etc.
  • +
  • Support for TaskDialog
  • +
  • New Shell file dialogs (IFileOpenDialog and IFileSaveDialog)
  • +
  • New Aero Wizard support classes
  • +
  • New classes for Buffered Paint and Buffered Animation
  • +
+

+ New TabView classes
New dialog class that uses in-memory dialog templates
New CMultiFileDialogImpl and CMultiFileDialog classes that support + multi-select file dialogs
Added message cracker handler prototypes for all handlers
Replaced use of _alloca with CTempBuffer everywhere (and added CTempBuffer + version for ATL3)
New classes for find/replace support for Edit or RichEdit
New class CFileDialogEx that supports GetOpenFileNameEx for Windows Mobile 5
+ New features for the App Wizard: +

+
    +
  • New default version values
  • +
  • Unicode build option
  • +
  • Support for TabView applications
  • +
  • Support for Explorer applications
  • +
+

Updates for the desktop App Wizard:

+
    +
  • Added calls to set font for views based on controls that use font
  • +
  • Added scroll window as another view type
  • +
+

Support for VC2005 Express:

+
    +
  • Setup for VS2005x
  • +
  • Changes in default.js to take into account that VC2005x does not have a resource editor
  • +
  • Generated code allows use of ATL3 from the Platform SDK
  • +
+

New AppWizard for Mobile 2003 and 2005 platforms
+ New samples:

+
    +
  • Aero - demonstrates the Vista Glass UI
  • +
  • MiniPie - Windows Mobile 2005 PPC and Smartphone sample
  • +
  • TabBrowser - a web browser using TabView class
  • +
+

MTPad sample updated to show usage of CRichEditFindReplaceImpl and CEditCommands/CRichEditCommands

+
+


+ +

Fixes and enhancements:

+
+

Command Bar:

+
    +
  • Added support for menu items with bitmaps on Vista
  • +
  • Fix: Keyboard cues shown even if the window is disabled
  • +
+


+

CFolderDialog:

+
    +
  • Added support for PIDLs in addition to the file path
  • +
  • Replaced use of SHGetMalloc with CoTaskMemFree
  • +
+


+

Scroll Windows:

+
    +
  • Fix: CZoomScrollImpl - some methods should be overridable
  • +
  • Added support for WM_MOUSEHWHEEL in CScrollImpl
  • +
+


+

App Wizard:

+
    +
  • Fix: AppWizard fails to add files if C:\Temp does not exist
  • +
  • Fix: App Wizard generates security warning when loaded
  • +
  • Fix: App Wizard generates level 4 warning for modal dlg project
  • +
  • Fix: App Wizard setupXX.js scripts silently fail on Vista
  • +
  • Fix: Added code to unregister message filer and idle processing
  • +
  • Fix: Added WS_CLIPSIBLINGS to dialog forms to avoid rebar drawing problems
  • +
+


+

App Wizard CE:

+
    +
  • Fix: App Wizard CE should not have rich edit as a view option
  • +
  • Fix: App Wizard CE generates level 4 warnings for single instance apps
  • +
  • Added support for Windows Mobile 6 SDKs
  • +
+


+

Cracked Handlers:

+
    +
  • Fix: Corrected MSG_WM_TIMER and handler prototype, removed unused argument (breaking change)
  • +
  • Fix: atlcrack.h does not support WTL namespace
  • +
+


+

CDialogResize:

+
    +
  • Added SetIcon(NULL, FALSE) for CDialogResize to remove the generic icon for resizable dialogs
  • +
  • Fix: Enabled size/move for both X and Y
  • +
  • Added center flags for controls
  • +
+


+

CFrameWindowImpl:

+
    +
  • Fix: Const issue with title argument of AddSimpleReBarBand
  • +
  • Fix: DECLARE_FRAME_WND_CLASS definition missing WTL namespace
  • +
+


+

Windows CE:

+
    +
  • Fix: Some symbols not defined for CE 4.0
  • +
  • Fix: Incorrect WinCE exclusions
  • +
  • Fix: Pocket PC - assert after navigating a CHyperLink
  • +
  • Fix: Property sheet with listview on WM5.0 causes stack overflow
  • +
  • Fix: CFindFile::GetFilePath() fails on diskless root requests
  • +
  • Fix: VS 2005 dialog editor bug - DS_FIXEDSYS used but not defined
  • +
  • Fix: Windows Mobile 2005 compatibility issues
  • +
  • Fix: CFullScreenFrame on Smartphone 20003
  • +
  • Fix: SmartPhone back key handling in CAppWindow
  • +
  • Added orientation aware support to CAppStdDialogImpl
  • +
  • Added CAxDialogImpl base for CStdDialogImpl, CStdDialogResizeImpl and CStdOrientedDialogImpl
  • +
  • Added various CStdDialogxxx enhancements
  • +
  • Fix: CStdDialogBase does not scale dialog title on VGA
  • +
  • Fix: DIBINFO16 triggers code analysis warning
  • +
  • Added LPCTSTR AtlLoadString(UINT uID) - CE only overload
  • +
  • Added imaging draw support to CZoomScrollImpl
  • +
  • Added CBottomTabViewImpl and CBottomTabView classes for PPC
  • +
+


+

CFindFile:

+
    +
  • Fix: CFindFile class uses CRT functions
  • +
  • Fix: FindFile() uses lstrcpy without checking length
  • +
+


+

General:

+
    +
  • Fix: Adding ReBar bands fails with new Windows SDK
  • +
  • Added support for relative include paths
  • +
  • Fix: Using std::min and std::max
  • +
  • Fix: Problems using WTL with MFC
  • +
  • Improved support for Secure CRT
  • +
  • Changed implementation of CSize, CPoint, CRect, and CString to be inside class definitions
  • +
  • atltheme.h: Corrected method signatures for differences in uxtheme.h versions
  • +
  • Replaced malloc/free with new/delete where appropriate
  • +
+


+

Misc:

+
    +
  • Fix: CString::FormatV can cause GPF with Unicode strings
  • +
  • CHyperLink: Added handler for WM_SIZE
  • +
  • Fix: CTheme needs constructor from HTHEME handle
  • +
  • Added Add* methods to several control classes in atlctrls.h to augment Insert* methods
  • +
  • Fix: Incorrect casting in CRichEditCtrl::GetLine()
  • +
  • Fix: CTreeViewCtrl::GetItemState changed to return only state-bits as specified by mask
  • +
  • Fix: CBitmapButton::DoPaint - wrong button image
  • +
  • Added another variant of CDCT::Drawtext with LPTSTR argument that allows text change
  • +
  • Fix: CRecentDocumentListBase::AddToList() uses lstrcpy
  • +
  • Fix: AtlLoadString(uID, lpBuffer, nBufferMax) has unnecessary code
  • +
  • Fix: CCursor::LoadOEMCursor asserts on IDC_HAND
  • +
  • Fix: Memory leak when using CRT functions while printing
  • +
  • Fix: Undefined CString namespace
  • +
  • CPaneContainer: Added border styles
  • +
  • CSplitterImpl: Added SetSplitterPosPct, and changed App Wizard code to use it
  • +
+
+


+


+ +

Changes Between WTL 7.5 and 7.1

+


+

New and improved:

+
+

+ VS2005 Compatibility: + Added support for Visual Studio 2005 - both desktop and Windows CE
+ Classes for icons, cursors, accelerator tables
+ CSortListViewImpl, CSortListViewCtrlImpl, and CSortListViewCtrl classes
+ Impl classes for Wizard 97 style wizards: CWizard97Sheet, + CWizard97Page, CWizard97ExteriorPage, CWizard97InteriorPage
+ CMemoryDC and CDoubleBufferWindowImpl classes
+ Windows CE specific classes in new header, atlwince.h
+ CScrollContainer class
+ CZoomScrollImpl and CZoomScrollWindowImpl classes
+ CZoomPrintPreviewWindowImpl and CZoomPrintPreviewWindow classes
+ Global functions: AtlGetBitmapResourceInfo, + AtlGetBitmapResourceBitsPerPixel
+ New REFLECT_* macros to enable selective reflection of messages
+ App Wizard: Added App Wizard for VS2005
+ App Wizard: Added App Wizard for Windows CE for VS2005
+ New samples: WTLExplorer, ImageView, SPControls
+

+
+


+ +

Fixes and enhancements:

+
+

Command Bar:

+
    +
  • DrawBitmapDisabled() doesn't work correctly on Longhorn
  • +
  • Submenu size not correct if command bar is off-screen
  • +
  • Added handler for WM_SETTINGCHANGE to improve theme color changes
  • +
  • Better support for 8/16/24-bit images
  • +
  • Command Bar with 2 Levels of submenus remains active
  • +
  • Hook procedure fails to call next hook
  • +
  • OnDestroy() should not decrement hook use if AttachToWindow() is used
  • +
+


+

MDI Command Bar:

+
    +
  • Grows bigger if you switch between two maximized MDI child window types
  • +
  • Move all hook messages processing to a separate function and use pT
  • +
  • MDI icon & buttons should have themed background
  • +
  • Should make MDI buttons gray when inactive
     
  • +
+

CString:

+
    +
  • Helper functions not overloaded properly
  • +
  • Some return types are 'const CString&' and could be just 'CString&'
  • +
  • FormatV() passes size in characters to _alloca, should be in bytes
  • +
  • Fixed stack corruption in FormatV()
  • +
  • Improved boundaries checking for integer overflows/underflows
     
  • +
+

CScrollImpl:

+
    +
  • Scroll bars problem when changing range
  • +
  • SetScrollOffset() doesn't move child windows
  • +
  • Range and thumb drawing problems
  • +
  • Possible overflow in OnMouseWheel()
  • +
  • Support for SIF_DISABLENOSCROLL
  • +
  • Added ScrollToView methods
  • +
+


+

CMapScrollImpl:

+
    +
  • SetScrollSize() incorrectly inverts xMin and xMax
  • +
  • SetScrollSize() uses bRedraw = NULL
  • +
+


+

CTheme:

+
    +
  • GetThemeFont() bad parameter ordering
  • +
  • Uses LOGFONT and TEXTMETRIC incorrectly (SDK header problem)
  • +
+


+

CFrameWindowImpl:

+
    +
  • Improved sizing for Windows CE
  • +
  • CreateSimpleToolBarCtrl() should handle 24-bit bitmaps
  • +
  • Changed WinCE CCECommandBarCtrl typedef and added a PPC CMenuBarCtrl
  • +
  • UpdatesBarPosition() doesn't take Windows CE command bar into account
  • +
+


+

CDialogResize:

+
    +
  • Enabled use for Windows CE
  • +
  • Add WS_EX_DLGMODALFRAME to prevent empty icon
  • +
+


+

CReBarCtrl:

+
    +
  • Background not painted when resized
  • +
  • Fixed typo in LockBands()
  • +
  • MaximizeBand needs BOOL fIdeal argument
  • +
+


+

CRichEdit:

+
    +
  • GetSelText() should support UNICODE strings
  • +
  • GetSelText() uses lpstr instead of lpstrText
  • +
+


+

CHyperLink:

+
    +
  • Added _xttoi() helper to avoid CRT in _ATL_MIN_CRT
  • +
  • Fixed resource leak by destroying tooltip window
     
  • +
+

CPropertySheetImpl:

+
    +
  • Improved support for Windows CE
  • +
  • Sheet without title generates a memory fault on Windows CE
  • +
+


+

CFolderDialog:

+
    +
  • Add a way to set an initial folder
  • +
  • Uses BFFM_IUNKNOWN which is not always defined
  • +
+


+

Update UI:

+
    +
  • Add support to dynamically add UpdateUI elements
  • +
  • UIUpdateMenuBarElement() should use EnableMenu() instead of SetMenuItemInfo() for Windows CE
  • +
+


+

CDC:

+
    +
  • FillSolidRect() should restore background color
  • +
  • GetClipRgn() method missing
  • +
+


+

Printing:

+
    +
  • CPrinter::CreatePrinterDC() and CreatePrinterIC() members should be const
  • +
  • CDevMode::CopyToHDEVMODE() is missing a call to GlobalUnlock()
  • +
+


+

AppWizard:

+
    +
  • Use WTL subfolder to create WTL category for VC7.x and VC8
  • +
  • Rename files from WTLApp7x to WTLAppWiz, and add VS2005 setup file
  • +
  • Fixed setup for x64
  • +
+


+

General:

+
    +
  • Redefinition of _MAX_FNAME with Dinkumware Standard C++ Library on Windows CE
  • +
  • Added ATLVERIFY macro for ATL3
  • +
  • Support warning level 4
  • +
  • Missing methods CToolBarCtrl::SetButtonInfo, InsertButton, CTabCtrl::SetItem, CComboBoxEx::InsertItem, SetItem
  • +
  • Missing support for WM_PRINTCLIENT
  • +
  • Removed usage of IsBad* functions
  • +
  • Fixed various compiler warnings
  • +
  • TCHAR bugs in various files
  • +
  • Improved Windows CE support and changes for Visual Studio 2005
  • +
+


+

Misc:

+
    +
  • CMDIChildWindowImpl: HMENU should be destroyed in OnDestroy()
  • +
  • CStatic: Should use STM_SETIMAGE instead of STM_SETICON for SetIcon() on Windows CE
  • +
  • CButton: GetButtonStyle() uses wrong mask
  • +
  • CImageList: Made Duplicate() method const
  • +
  • CListViewCtrl: Made SubItemHitTest() method const
  • +
  • CTreeViewCtrl: GetItem() and SetItem() incorrectly restricted to _WIN32_IE >= 0x0500
  • +
  • CMonthCalendarCtrl: GetMonthRange() should be GetMaxTodayWidth()
  • +
  • CDateTimePickerCtrl: SetFormat() should have const argument
  • +
  • CBitmapButtonImpl: Fixed resource leak by destroying tooltip window
  • +
  • CMultiPaneStatusBarCtrlImpl: Cannot handle wide panes without resource strings
  • +
  • CCheckListViewCtrlImpl: Call CheckSelectedItems() through pT
  • +
  • CPaneContainerImpl: SetPaneContainerExtendedStyle() should use pT to call CalcSize()
  • +
  • CFindFile: Enabled for Windows CE
  • +
  • CPropertyPageImpl: Added handlers for callback messages
  • +
  • atlcrack.h: Added return value for MSG_WM_APPCOMMAND
  • +
  • CMenu: New method variants: AppendMenu, InsterMenu, ModifyMenu
  • +
  • CFont: Added arguments for bold and italic to CreatePointFont()
  • +
  • CSize: Added scalar operators for WTL::CSize and ATL::CSize
  • +
  • CRecentDocumentList: Allow changing the "DocumentCount" and "Document%i" registry values strings
  • +
  • CSplitterWindowImpl: Enabled use for Windows CE
  • +
+
+


+ +

Changes Between WTL 7.1 and 7.0

+

New and improved:

+
+

VC7 Compatibility: Support for ATL7 Module classes and critical sections and AppWizard setup for VC++ 7.1

+

Windows CE Support: Full compatibility with Windows CE platforms and AppWizard for eMbedded Visual C++

+

Namespace Support: Automatic "using ATL" (ATL7 only) or "using WTL" can now be turned off

+

CHyperLink New Features: not underlined, underlined when hover, command button, link tags

+

CCustomWaitCursor class supports custom and animated wait cursors

+

AtlCreateBoldFont() for creating bold version of an existing font

+
+


+

Fixes and enhancements:

+
+

CFrameWindowImpl:

+
    +
  • CreateSimpleToolBarCtrl() - remove dead code, improve error checking, add a global function that uses it
  • +
  • Fix - PrepareChevronMenu() fails to get toolbar strings for Unicode
  • +
  • CFrameWindowImplBase::Create() - improve ASSERT not to use m_hWnd if creation fails
  • +
  • Fix - CFrameWndClassInfo::Register - should use %p formatting only for _WIN32_WINNT >= 0x0500 or for _WIN64
  • +
  • Fix - Chevron menus not positioned correctly with RTL
  • +
  • Fix - CMDIChildWindowImpl: Problems creating maximized child windows and handling focus
  • +
  • Fix - CMDIChildWindowImpl: Should activate on WM_MOUSEACTIVATE
  • +
+


+

UpdateUI:

+
    +
  • Fix - Incorrectly clears default item from the system menu in MDI apps
  • +
  • Added UISetCheck with bool instead of int for the check state
  • +
+


+

DDX:

+
    +
  • Fix - Doesn't provide a way to change floating point precision
  • +
  • Added DDX_CONTROL_HANDLE for non-CWindowImpl objects
  • +
  • Added DDX_Check variant with bool instead of int for the check state
  • +
+


+

Command Bar:

+
    +
  • Fix - OnDrawItem() and OnMeasureItem() don't do a good check for owner-draw menu items
  • +
  • Fix - Disabled 32-bit images not painted correctly in 3D menu mode
  • +
  • Fix - Popup menus not positioned correctly with RTL
  • +
  • Fix - Uses GCL_HICONSM instead of GCLP_HICONSM with GetClassLongPtr()
  • +
+


+

MDI Command Bar:

+
    +
  • Fix - Doesn't refresh icon if MDI children are different
  • +
  • OnAllHookMessages() - improve code to handle MDI child window class icon
  • +
  • Fix - OnNcLButtonDown() uses TPM_VERPOSANIMATION without checking Windows version
  • +
  • Fix - Maximized MDI buttons in wrong place for RTL
  • +
  • Should adjust cxIdeal for rebar bands for IE4
  • +
  • Add support for different top-level menu widths by handling ideal size for rebar bands
  • +
+


+

AppWizard:

+
    +
  • Fix - Doesn't support MSDI application as a COM Server
  • +
  • Fix - MDI with Form View - stack overflow closing maximized MDI child windows
  • +
  • Fix - Generates VERSION resource name 'test1' regardless of the project name
  • +
  • Fix - Dialog project with control hosting doesn't derive a dialog from CAxDialogImpl
  • +
  • Fix - COM Server doesn't register type library
  • +
  • Fix - COM Server doesn't register AppID properly
  • +
+


+

CTreeViewCtrl:

+
    +
  • Fix - GetItemData() needs better return value
  • +
  • Fix - GetItemState() should use TVM_GETITEMSTATE instead of TVM_GETITEM for IE5
  • +
  • GetItem() and SetItem() - added new variants that use TVITEMEX
  • +
  • Fix - SortChildren() should add recurse flag argument
  • +
  • Fix - CTreeItem doesn't support CTreeViewCtrlExT that has different TBase than CWindow
  • +
+


+

CThemeImpl:

+
    +
  • Fix - Uses scalar delete instead of the vector one
  • +
  • Fix - EnableThemeDialogTexture() argument is BOOL instead of DWORD
  • +
+


+

CFolderDialog:

+
    +
  • Fix - EnableOK() passes wrong arguments to BFFM_ENABLEOK
  • +
  • Fix - Always clears m_hWnd, which causes problem for nested messages
  • +
+


+

CDialogResize:

+
    +
  • Fix - DlgResize_Init() forces dialog to be visible by using SetRedraw()
  • +
  • Forcing WS_THICKFRAME is not enough to make dialog resizable
  • +
  • Min track size should be used for child dialogs as well
  • +
  • Fix - DlgResize_PositionControl() incorrectly checks return value from MapWindowPoints()
  • +
+


+

CAppModule:

+
    +
  • Fix - CAppModule methods not thread-safe
  • +
  • Fix - AddSettingChangeNotify() unusable in multithreaded apps because of delayed initialization
  • +
+


+

CString:

+
    +
  • Fix - Delete() doesn't allow deleting more than the length of the string
  • +
  • Fix - Append() can cause buffer overrun
  • +
  • Fix - MakeReverse() can cause an infinite loop
  • +
  • Fix - _cstrstr() unnecessarily inefficient
  • +
  • Fix - FindOneOf() is not DBCS-aware
  • +
  • Fix - Format() does not recognize %E
  • +
  • Fix - TrimLeft() and TrimRight() are only half-way DBCS-aware
  • +
  • Fix - May cause assertions or undefined behavior with SBCS
  • +
+


+

CRecentDocumentList:

+
    +
  • Fix - SetMaxEntries() has an incorrect ASSERT
  • +
  • Add CString variant of the GetFromList() method
  • +
  • Add a way to replace command IDs used for the MRU list
  • +
  • Add a way to replace registry key name
  • +
+


+

Misc:

+
    +
  • CMessageLoop::Run() - improve the loop by checking bDoIdle before calling PeekMessage()
  • +
  • CServerAppModule: Clean-up unused code
  • +
  • Fix - CServerAppModule::MonitorProc() - no need to call _endthreadex()
  • +
  • Fix - CListBox::GetText() and CComboBox::GetLBText() (CString variants) don't check for LBERR/CB_ERR
  • +
  • Fix - CAxPropertyPageImpl doesn't create ActiveX controls with ATL7
  • +
  • Fix - CDC::GetTextExtentExPoint() missing
  • +
  • CDC::SetWindowExt() should have default value NULL for the lpSizeRet argument
  • +
  • Fix - CPropertySheetWindow missing methods for PSM_INSERTPAGE, PSM_SETHEADERTITLE, and PSM_SETHEADERSUBTITLE; + AddPage should return BOOL
  • +
  • Fix - CMapScrollImpl::SetScrollSize() uses wrong variable
  • +
  • Fix - CHyperLink: WM_UPDATEUISTATE causes repaint without WM_PAINT
  • +
  • Fix - CUpDownCtrl::GetPos() returns incorrect value
  • +
  • Fix - CUpDownCtrl::GetPos32() doesn't have default arg value
  • +
  • Fix - CMultiPaneStatusBarCtrl: Always uses size grip for positioning panes
  • +
  • Fix - CTabCtrl::InsertItem() should return int, not BOOL
  • +
  • CReBarCtrl: Added LockBands() method
  • +
  • Fix - CFont: uninitialized variable passed to DPtoLP
  • +
  • Fix - CPrintDialogImpl: Crash when displaying Print Setup dialog
  • +
  • Fix - CPageSetupDialogImpl::PaintHookProc() - should use T* and return UINT_PTR instead of UINT
  • +
  • Fix - CPrintJob doesn't support printing to a file
  • +
  • Fix - CSplitterImpl: Doesn't handle WM_CAPTURECHANGED - can get in an invalid state
  • +
  • CRichEditCtrl: Add method for EM_SETTABSTOPS
  • +
  • Fix - CFindFile::GetFilePath() checks for a trailing slash, but doesn't use that info
  • +
+


+

General:

+
    +
  • Fix - Problems compiling with /Zc:forScope ('for' loop scope conformance)
  • +
  • Use named constants instead of values for pixel sizes, buffer lengths, etc.
  • +
  • Support building with Managed C++ (/CLR)
  • +
  • CMenuItemInfo - add run-time support for different versions of Windows
  • +
  • CommCtrl.h change - additional fields in IMAGELISTDRAWPARAMS now depend on _WIN32_IE instead of _WIN32_WINNT
  • +
  • Fix - Incorrect usage of CRegKey::QueryStringValue()
  • +
  • Fix - Operator = for GDI and USER wrappers leaks handle if it's managed variant
  • +
  • Fix - GDI and USER wrappers break under self-assignments
  • +
  • Fix - Chaining messages with cracked handlers broken with ATL7
  • +
  • Initialize all variables and structures prior to use
  • +
  • Use new common control struct names
  • +
+
+


+ +

Changes Between WTL 7.0 and 3.1

+

New classes and features:

+
+

Support for new Common Controls v6 messages

+

Support for Visual Studio .NET and ATL 7.0

+

WTLApp70 - new AppWizard for Visual Studio .NET

+

CThemeImpl - implements support for Windows XP themes

+

CMDICommandBarCtrl - implements Command Bar for MDI applications

+
+


+

Fixes and enhancements:

+
+

Command Bar:

+
    +
  • Bogus assert in OnDestroy
  • +
  • Check marks can be truncated in large font settings
  • +
  • Use pT to access GetSystemSettings, DrawMenuText, DrawBitmapDisabled, Draw3DCheckmark, DoPopupMenu, + DoTrackPopupMenu, TakeFocus, GiveFocusBack, so they can be overridden
  • +
  • No hot-tracking if main window is not active
  • +
  • Top level items not painted inactive if app looses activation while drop down menu is displayed
  • +
  • Added Windows XP flat menus support
  • +
  • Drop-down menu doesn't close if clicked again (Windows XP only)
  • +
  • Menu item text and accelerator text too close with some settings
  • +
  • Keyboard can still access clipped menu items
  • +
  • Added support for hiding keyboard navigation indicators until Alt key is pressed (system setting)
  • +
  • Added AddIcon and ReplaceIcon variants for icon resources
  • +
  • Image size calculated differently in different places
  • +
  • Add support for 32-bit (alpha channel) bitmaps for Windows XP
  • +
  • Fixed width calculation for default menu items
  • +
+


+

CFrameWindowImpl:

+
    +
  • AddSimpleReBarBandCtrl sets toolbar extended styles without preserving old ones
  • +
  • PrepareChevronMenu should not create menu items for buttons with TBSTATE_HIDDEN
  • +
  • TPM_VERPOSANIMATION will not be defined in atlframe.h if atlctrlw.h is included first
  • +
  • CreateSimpleToolBarCtrl - height might be too small if large font is used
  • +
  • PrepareChevronMenu uses TB_GETBUTTONTEXT, better use TB_GETBUTTONINFO
  • +
  • Chevron menu doesn't close if clicked again (Windows XP only)
  • +
  • Should check local classes for superclassing
  • +
  • Add support for 32-bit (alpha channel) bitmaps for Windows XP
  • +
+


+

Update UI:

+
    +
  • UISetText can clear other menu item flags
  • +
  • CUpdateUI::UIUpdateState assigns value with |= instead of =
  • +
  • Added UISetDefault() and fix default state to work with menus
  • +
+


+

CString:

+
    +
  • GetBuffer() and GetBufferSetLength() should return NULL in out-of-memory condition
  • +
  • Added missing methods: separate c-tors for LPCSTR and LPCWSTR, CollateNoCase, TrimRight and TrimLeft variants, Find + variants, moved FormatV to public
  • +
  • Fix _IsValidString usage
  • +
  • FormatV incorrectly calculates buffer size (too big)
  • +
  • Usage of _ttoi causes problems with _ATL_MIN_CRT in VC7
  • +
+


+

CDC:

+
    +
  • GetTabbedTextExtent() should return DWORD instead of BOOL
  • +
  • Add FillRect() that accept color index instead of a brush handle
  • +
  • DrawDragRect() leaks regions and a brush
  • +
  • Improved DitherBlt() - added brushes as arguments for used colors
  • +
  • Added DrawShadowText() (uses LoadLibrary/GetProcAddress to run on older Windows)
  • +
+


+

CListViewCtrl:

+
    +
  • SetItemState should use LVM_SETITEMSTATE
  • +
  • SetItemCount should return a BOOL
  • +
+


+

CRichEditCtrl:

+
    +
  • Added SetCharFormat() variant that accepts flags (for SCF_ALL)
  • +
  • CharFromPos() should pass a pointer to POINTL in lParam
  • +
  • GetTextRange() - should add Unicode variant for rich edit version >= 2
  • +
  • Added another FormatRange() that can accept a pointer to FORMATRANGE (needed for passing NULL to clear cache)
  • +
+


+

CHyperLink:

+
    +
  • Allow overriding of Navigate and CalcLabelRect
  • +
  • Doesn't handle right or center alignment
  • +
+


+

CColorDialog:

+
    +
  • Has static variables that were not initialized with _ATL_MIN_CRT
  • +
  • Fixed HookProc for ColorOK message - the message is not sent, but the hook proc is called directly
  • +
+


+

atlcrack.h:

+
    +
  • MSG_WM_TIMER crack macro should cast to TIMERPROC instead of TIMERPROC*
  • +
  • Add cracked handlers for all new messages in Common Controls 6
  • +
+


+

atlapp.h:

+
    +
  • Fixed problems with atlTraceUI with ATL7
  • +
  • #ifdefs for ATL7 were in the wrong place
  • +
+


+

atlctrls.h:

+
    +
  • Add support in control classes for all new messages in Common Controls 6
  • +
+


+

CRecentDocumentList:

+
    +
  • AtlCompactPath corrupts memory if filename is longer than requested compact size
  • +
  • ReadFromRegistry incorrectly checks for error when reading from registry
  • +
+


+

CSplitterWindow:

+
    +
  • Incorrect calculation of middle position
  • +
  • 3D border now drawn only if WS_EX_CLIENTEDGE is set
  • +
+


+

Printing:

+
    +
  • Uses DWORD instead of an int for a job ID
  • +
  • CPrintJob::CancelPrintJob shouldn't have a return value
  • +
+


+

Misc:

+
    +
  • CRegKey::QueryValue and SetValue are deprecated in ATL7
  • +
  • Added direct support for ATL7
  • +
  • Replace ScreenToClient and ClientToScreen with MapWindowPoints to support RTL layout
  • +
  • CFindFile::GetFilePath(LPTSTR...) returns path without the file name
  • +
  • MDI: Updating client edge in WM_WINDOWPOSCHANGING causes minimize/maximize/restore animation problems, + use WM_WINDOWPOSCHANGED
  • +
  • Custom Draw: Added CCustomDraw::OnSubItemPrePaint() overrideable method
  • +
  • CFolderDialogImpl uses 'this' for BROWSEINFO.lParam instead of T*
  • +
  • CImageList::Destroy shouldn't use Detach()
  • +
  • ATL7 has its own AtlLoadString
  • +
  • CPropertySheet doesn't close when you press X button
  • +
  • Fixed problems for _U_STRINGorID and others that moved from atlbase.h to atlwin.h in ATL7
  • +
  • Add AtlMessageBox() that accepts either in-memory or resource strings
  • +
  • CScrollImpl: fixed bug with scrolling child windows
  • +
  • CPropertyPageImpl: Add new notification handlers to enable direct return values + (use #ifdef _WTL_NEW_PAGE_NOTIFY_HANDLERS to use them)
  • +
  • Add AtlInitCommonControls() to simplify use
  • +
  • DDX: Fixed usage of the size of char arrays for DDX
  • +
  • CPageSetupDialog: changed usage of CWndProcThunk because of changes in ATL7
  • +
  • Fix confusing precedence in expressions
  • +
  • Removed forward declarations because default values for template arguments + shouldn't be specified in two places (we don't need them anyway)
  • +
  • Win64: Fix /Wp64 warnings from 32-bit VC7 compiler caused by SDK headers
  • +
  • Fix direct usage of English strings (they can be #defined to something else now)
  • +
  • AtlGetCommCtrlVersion not defined if _ATL_DLL is in ATL 3.0 (and CmdBar is using it)
  • +
+


+

AppWizard:

+
    +
  • Added manifest for Common Controls 6
  • +
  • Loading Rich Edit DLL should use HMODULE
  • +
  • Should not use atlimpl.cpp for ATL7
  • +
  • Added message handler prototypes to generated files
  • +
  • VERSION resource always has VALUE "OLESelfRegister" (now only for COM servers)
  • +
  • Added option for putting implementation in CPP files
  • +
  • d-tor for the thread manager class in MSDI project executed after the heap is destroyed
  • +
  • Wrong settings when changing to a dialog project and back (AppWizard 6.0 only)
  • +
  • Remove cut/copy/paste accelerators for form view and dialogs projects
  • +
  • Fix toolbar bitmaps so they are not transparent (problem with Windows XP flat menus only)
  • +
  • Used CMDICommandBarCtrl for MDI apps
  • +
  • Add symbols required for VC7 Class Wizard to recognize an ATL project
  • +
  • Changed default styles for the rebar, so it does look OK without CmdBar and with manifest
  • +
  • Added setup programs for both AppWizards
  • +
  • Remove ignored resource attributes: MOVEABLE, PURE, etc. (AppWizard 7.0 only)
  • +
  • Add call to DefWindowProc to WinMain to resolve possible problems if MSLU is used
  • +
+


+

Samples:

+
    +
  • Updated toolbar bitmaps, added #ifdefs for ATL7, added manifest file for CommCtrl6, qualified _U_RECT with WTL + namespace, updated use of deprecated CRegKey functions, added VC7 projects
  • +
  • Added Alpha sample
  • +
+
+


+ +

Changes Between WTL 3.1 and 3.0

+

New classes:

+
+

+ CPaneContainer - implements a window that provides a title bar and a close button (like Explorer) +

+

+ CDialogResize - an MI class that allows resizing of dialogs (or any windows with child windows/controls) +

+

+ CAxPropertyPageImpl - implements a property page that can host ActiveX controls +

+
+


+

Fixes and enhancements:

+
+

+ CServerAppModule now clears m_hEventShutdown to avoid calling CloseHandle twice +

+


+

CString:

+
    +
  • operator += now leaves original string intact if it's out of memory
  • +
  • Fixed bad DWORD_PTR usage in TrimRight, TrimLeft, Replace, Remove
  • +
  • Removed dependencies on CRT for projects that don't use it
  • +
  • Insert - fixed string corruption in release builds
  • +
  • Added optional floating point formatting (for projects that use CRT)
  • +
+


+

+ CEdit and CRichEditCtrl: SetSelAll and SetSelNone had reversed implementation +

+


+

+ atlres.h: Changed IDs so that they are compatible with MFC's afxres.h +

+


+

Command Bar:

+
    +
  • Added LoadMappedImages()
  • +
  • Changed handling of left and right arrow keys so that they don't close context menus
  • +
  • Add code to handle left/right arrow keys correctly on mirrored (RTL) systems
  • +
  • Removed handler that eats parent window's WM_SETTINGCHANGE
  • +
  • Fixed bitmap resource leak in Draw3DCheckmark
  • +
  • Fixed incorrect usage of CharLower in OnMenuChar
  • +
  • Fixed wrong color for the disabled items in hi-contrast mode
  • +
  • Added code to gray menu items if main window is inactive
  • +
  • Fixed keyboard mnemonic handling for IE 4
  • +
  • Fixed hook problems with multiple cmdbars in the same thread
  • +
  • Added support for radio menu items
  • +
  • Added support for disabled top-level menu items (also added in CFrameWindowImpl::PrepareChevronMenu)
  • +
  • Added keyboard shortcut (Alt+/) to invoke chevron menu
  • +
  • Added support to override menu item length in a derived class
  • +
+


+

CBitmapButton:

+
    +
  • Bypassed BUTTON DefWindowProc for hover style so that the button doesn't take focus
  • +
  • Added BMPBTN_AUTOFIRE extended style
  • +
+


+

CDC:

+
    +
  • Added _WTL_FORWARD_DECLARE_CSTRING define to allow usage of methods that accept CString
  • +
  • Fixed errors in GetTextFace and GetMenuItemString
  • +
  • Added GetCharWidth32
  • +
  • Added DrawIconEx method
  • +
+


+

CMenu:

+
    +
  • Implement following missing methods:
    +     GetMenuDefaultItem
    +     GetMenuInfo
    +     GetMenuItemRect
    +     HiliteMenuItem
    +     IsMenu
    +     MenuItemFromPoint
    +     SetMenuDefaultItem
    +     SetMenuInfo
  • +
  • GetMenuString - fixed to include space for terminating NULL character in returning string
  • +
+


+

+ GDI and USER classes should destroy the GDI/USER objects in Attach if GDI/USER resource is managed +

+


+

CFrameWindowImpl:

+
    +
  • OnToolTipText shouldn't save tool tip text if it's not for a menu
  • +
  • AddSimpleReBarBandCtrl now adds chevron style only for toolbars with buttons
  • +
  • AddSimpleReBarBand(Ctrl) - calc band ID if not specified
  • +
+


+

CRecentDocumentList:

+
    +
  • Fix - UpdateMenu deletes wrong menu item when the list is empty
  • +
  • Added code to allow restricting the number of characters displayed by MRU menu items
  • +
+


+

Update UI:

+
    +
  • Added support for blocking accelerators for disabled items
  • +
  • Improved search code assuming there are no duplicate entries (and added checks for duplicates)
  • +
+


+

CSplitterWindow:

+
    +
  • CSplitterWindowImpl should derive from CSplitterImpl<T , t_bVertical> to allow overriding of methods
  • +
  • Added single pane mode and SetSinglePaneMode/GetSinglePaneMode
  • +
  • Added right/bottom aligned resize mode using extended styles SPLIT_RIGHTALIGNED/SPLIT_BOTTOMALIGNED
  • +
+


+

+ atlcrack.h: Added handlers for following new + messages:
+     WM_APPCOMMAND
+     WM_NCXBUTTONDOWN
+     WM_NCXBUTTONUP
+     WM_NCXBUTTONDBLCLK
+     WM_XBUTTONDOWN
+     WM_XBUTTONUP
+     WM_XBUTTONDBLCLK +

+


+

Win64:

+
    +
  • Dialog return value should use DWLP_MSGRESULT and SetWindowLongPtr
  • +
  • CMenu::InsertMenu, AppendMenu, ModifyMenu should have UINT_PTR for the menu ID
  • +
  • Added appropriate type casts
  • +
  • CFrameWindowImpl::m_szAutoName - changed the size to fit the pointer value size
  • +
  • CListViewCtrl::SortItems should use LPARAM for user data instead of DWORD
  • +
+


+

Misc:

+
    +
  • Added optional mask argument to all methods for setting extended styles
  • +
  • CMDIWindow::MDIRestore - fixed to send WM_MDIRESTORE instead of WM_MDIICONARRANGE
  • +
  • CListViewCtrl: Added SortItemsEx method
  • +
  • CToolBarCtrl::GetButtonInfo - fixed to return int instead of BOOL
  • +
  • Added CToolBarCtrl::SetButtonSize and SetBitmapSize that accept cx and cy instead of SIZE
  • +
  • Printing: Changed how GetNewDevModeForPage works (comments in code)
  • +
  • CFileDialogImpl::_OnTypeChange incorrectly calls pT->OnSelChange instead of pT->OnTypeChange
  • +
  • CMultiPaneStatusBarCtrl::GetPaneTipText - fixed to use index instead of and ID internally
  • +
  • CWinDataExchange: Added references to arguments of DoDataExchange, so there are no level 4 warning + even if the map is empty
  • +
  • CPropertySheetWindow: Added new, IE 5.0 specific methods
  • +
  • CPropertyPageImpl: Added new, IE 5.0 specific methods
  • +
+


+

AppWizard:

+
    +
  • added calls to RemoveMessageFilter and RemoveIdleHandler in CMainFrame::OnDestroy for COM server projects
  • +
  • added scroll bars for HTML view
  • +
  • CAppServerModule now handles -embedding as well as -automation
  • +
  • corrected code in CMainFrame::OnShowToolBar to correctly identify the toolbar in a rebar
  • +
  • dialog based app code now derives from CUpdateUI as public
  • +
+
+


+ +

- end of readme.html -

+ + + +